387 lines
13 KiB
PHP
387 lines
13 KiB
PHP
<?php
|
|
use_helper('stCurrency', 'stText', 'stProductImage', 'stText', 'stUrl');
|
|
sfLoader::loadHelpers('stProduct', 'stProduct');
|
|
|
|
st_theme_use_stylesheet('stBlogPlugin.css');
|
|
|
|
$url_params = array(
|
|
'module' => 'stBlogFrontend',
|
|
'action' => 'list',
|
|
);
|
|
|
|
if (!empty($blog)) {
|
|
|
|
$blog_id = $blog->getId();
|
|
|
|
$smarty->assign('config_date', $config->get('date'));
|
|
|
|
if ($config->get('date')==2) {
|
|
|
|
$date = explode(" ", $blog->getCreatedAt());
|
|
|
|
$date = explode("-", $date[0]);
|
|
|
|
$date = $date[2]."-".$date[1]."-".$date[0];
|
|
|
|
} elseif ($config->get('date')==1) {
|
|
|
|
|
|
$date = explode(" ", $blog->getUpdatedAt());
|
|
|
|
$date = explode("-", $date[0]);
|
|
|
|
$date = $date[2]."-".$date[1]."-".$date[0];
|
|
|
|
} else {
|
|
|
|
$date = NULL;
|
|
|
|
}
|
|
|
|
|
|
$smarty->assign('name', $blog->getName());
|
|
|
|
$smarty->assign('show_date', $config->get('post_show_date'));
|
|
|
|
$smarty->assign('show_gallery', $config->get('post_show_gallery'));
|
|
|
|
$smarty->assign('show_gallery_thumb', $config->get('post_show_gallery_thumb'));
|
|
|
|
if (@$blog_category)
|
|
{
|
|
$url_params['url'] = $blog_category->getUrl();
|
|
$smarty->assign('blog_category_url', st_url_for($url_params));
|
|
$smarty->assign('blog_category_name', $blog_category->getName());
|
|
}
|
|
|
|
$smarty->assign('image_main_page', image_tag(st_asset_image_path('/'.sfConfig::get('sf_upload_dir_name').'/blog/main/'.$blog->getImageMainPage(), 'gallery', 'blog'), array('alt' => $blog->getName())));
|
|
|
|
if ($blog->getImage()!="") {
|
|
$smarty->assign('image', image_tag(st_asset_image_path('/'.sfConfig::get('sf_upload_dir_name').'/blog/post/'.$blog->getImage(), 'gallery', 'blog'), array('alt' => $blog->getName())));
|
|
}else{
|
|
$smarty->assign('image', image_tag(st_asset_image_path('/'.sfConfig::get('sf_upload_dir_name').'/blog/main/'.$blog->getImageMainPage(), 'gallery', 'blog'), array('alt' => $blog->getName())));
|
|
}
|
|
|
|
if($blog->getGallery()){
|
|
|
|
$gallery = array();
|
|
foreach ($blog->getGallery() as $image) {
|
|
//$gallery[] = '/'.sfConfig::get('sf_upload_dir_name').'/blog/main/'.$image;
|
|
$gallery[] = st_asset_image_path('/'.sfConfig::get('sf_upload_dir_name').'/blog/main/'.$image, 'gallery', 'blog');
|
|
}
|
|
|
|
$smarty->assign('gallery', $gallery);
|
|
}else{
|
|
|
|
if($blog->getImageMainPage()){
|
|
$gallery = array();
|
|
//$gallery[] = '/'.sfConfig::get('sf_upload_dir_name').'/blog/main/'.$blog->getImageMainPage();
|
|
$gallery[] = st_asset_image_path('/'.sfConfig::get('sf_upload_dir_name').'/blog/main/'.$blog->getImageMainPage(), 'gallery', 'blog');
|
|
$smarty->assign('gallery', $gallery);
|
|
}
|
|
}
|
|
|
|
$smarty->assign('post_date', $date);
|
|
|
|
$smarty->assign('cta_head', $blog->getCtaDescriptionHead());
|
|
|
|
$smarty->assign('cta_foot', $blog->getCtaDescriptionFoot());
|
|
|
|
$smarty->assign('cta_name', $blog->getCtaName());
|
|
|
|
$smarty->assign('cta_url', $blog->getCtaUrl());
|
|
|
|
$smarty->assign('cta_position', $blog->getCtaPosition());
|
|
|
|
|
|
$cta_url = $blog->getCtaUrl();
|
|
|
|
if (substr($cta_url, 0, 1) === '/') {
|
|
$cta_target = "_parent";
|
|
} else {
|
|
$cta_target = "_blank";
|
|
}
|
|
|
|
$smarty->assign('cta_target', $cta_target);
|
|
|
|
|
|
$smarty->assign('post_show_sidebar', $config->get('post_show_sidebar'));
|
|
|
|
$smarty->assign('short_description', $blog->getShortDescription());
|
|
|
|
$smarty->assign('head_description', $blog->getHeadDescription());
|
|
|
|
if (!$blog->getLongDescription())
|
|
{
|
|
|
|
$smarty->assign('long_description', $blog->getShortDescription());
|
|
|
|
} else {
|
|
|
|
|
|
$cta_tag = '<div id="blog-cta">
|
|
<div class="tinymce_html clearfix">'.$blog->getCtaDescriptionHead().'</div>
|
|
|
|
<div style="text-align: '.$blog->getCtaPosition().'">
|
|
|
|
<a style id="cta-btn" class="btn btn-primary" target="'.$cta_target.'" href="'.$blog->getCtaUrl().'" >'.$blog->getCtaName().'</a>
|
|
</div>
|
|
|
|
<div class="tinymce_html clearfix">'.$blog->getCtaDescriptionFoot().'</div>
|
|
</div>';
|
|
|
|
$long_description = preg_replace('/{CTA}/', $cta_tag, $blog->getLongDescription());
|
|
|
|
|
|
$smarty->assign('long_description', $long_description);
|
|
|
|
}
|
|
|
|
|
|
$smarty->assign('date', $config->get('list_date'));
|
|
|
|
$smarty->assign('show_image', $config->get('list_show_image'));
|
|
|
|
$smarty->assign('show_title', $config->get('list_show_title'));
|
|
|
|
$smarty->assign('post_grid', $config->get('list_post_grid'));
|
|
|
|
$smarty->assign('show_more', $config->get('list_show_more'));
|
|
|
|
$smarty->assign('show_image_position', $config->get('list_show_image_position'));
|
|
|
|
$smarty->assign('display_type', $config->get('list_display_type'));
|
|
|
|
$smarty->assign('show_date', $config->get('list_show_date'));
|
|
|
|
|
|
|
|
$smarty->assign('r_date', $config->get('list_r_date'));
|
|
|
|
$smarty->assign('r_show_date', $config->get('list_r_show_date'));
|
|
|
|
$smarty->assign('r_show_image', $config->get('list_r_show_image'));
|
|
|
|
$smarty->assign('r_show_title', $config->get('list_r_show_title'));
|
|
|
|
$smarty->assign('r_post_grid', $config->get('list_r_post_grid'));
|
|
|
|
$smarty->assign('r_show_more', $config->get('list_r_show_more'));
|
|
|
|
$smarty->assign('r_show_image_position', $config->get('list_r_show_image_position'));
|
|
|
|
$smarty->assign('r_display_type', $config->get('list_r_display_type'));
|
|
|
|
$smarty->assign('product_r_name', $config->get('product_r_name', null, true));
|
|
|
|
$smarty->assign('post_r_name', $config->get('post_r_name', null, true));
|
|
|
|
|
|
}
|
|
|
|
if (@$blogs)
|
|
{
|
|
$results = array();
|
|
|
|
foreach ($blogs as $blog)
|
|
{
|
|
|
|
// if ($blog_id != $blog->getId()) {
|
|
|
|
$blog_url = st_url_for('stBlogFrontend/show?url=' . $blog->getFriendlyUrl());
|
|
|
|
$row['id'] = $blog->getId();
|
|
|
|
$row['active'] = $blog->getActive();
|
|
|
|
$row['name'] = $blog->getName();
|
|
|
|
if ($blog->getAlternativeUrl()) {
|
|
$row['link'] = st_link_to($blog->getName(), $blog->getAlternativeUrl());
|
|
|
|
$row['url'] = $blog->getAlternativeUrl();
|
|
} else {
|
|
$row['link'] = st_link_to($blog->getName(), 'stBlogFrontend/show?url=' . $blog->getFriendlyUrl());
|
|
|
|
$row['url'] = st_url_for('stBlogFrontend/show?url=' . $blog->getFriendlyUrl());
|
|
}
|
|
|
|
|
|
$results[] = $row;
|
|
//}
|
|
}
|
|
|
|
$smarty->assign('post_from_category', $results);
|
|
}
|
|
|
|
if ($categorys)
|
|
{
|
|
$results = array();
|
|
|
|
foreach ($categorys as $category)
|
|
{
|
|
$url_params['url'] = $category->getUrl();
|
|
|
|
$row['id'] = $category->getId();
|
|
|
|
$row['name'] = $blog->getName();
|
|
|
|
$url = st_url_for($url_params);
|
|
|
|
$row['link'] = '<a href="'.$url.'">'.$category->getName().'</a>';
|
|
|
|
$row['url'] = $url;
|
|
|
|
$results[] = $row;
|
|
}
|
|
|
|
$smarty->assign('categorys', $results);
|
|
}
|
|
|
|
if (@$recommends) {
|
|
|
|
$results = array();
|
|
|
|
foreach ($recommends as $blog) {
|
|
|
|
$blog_url = st_url_for('stBlogFrontend/show?url=' . $blog->getFriendlyUrl());
|
|
|
|
$row['id'] = $blog->getId();
|
|
|
|
$row['active'] = $blog->getActive();
|
|
|
|
$row['name'] = $blog->getName();
|
|
|
|
if ($blog->getAlternativeUrl()) {
|
|
$row['link'] = st_link_to($blog->getName(), $blog->getAlternativeUrl());
|
|
} else {
|
|
$row['link'] = st_link_to($blog->getName(), 'stBlogFrontend/show?url=' . $blog->getFriendlyUrl());
|
|
}
|
|
|
|
if ($blog->getAlternativeUrl()) {
|
|
$row['url'] = $blog->getAlternativeUrl();
|
|
} else {
|
|
$row['url'] = st_url_for('stBlogFrontend/show?url=' . $blog->getFriendlyUrl());
|
|
}
|
|
|
|
$row['short_description'] = st_link_to(st_truncate_text($blog->getShortDescription(), '100', '...'), 'stBlogFrontend/show?url=' . $blog->getFriendlyUrl());
|
|
|
|
$row['untruncated_short_description'] = st_link_to($blog->getShortDescription(), 'stBlogFrontend/show?url=' . $blog->getFriendlyUrl());
|
|
|
|
$row['unlinked_short_description'] = st_truncate_text($blog->getShortDescription(), '100', '...');
|
|
|
|
$row['clear_short_description'] = $blog->getShortDescription();
|
|
|
|
$row['long_description'] = st_link_to(st_truncate_text($blog->getLongDescription(), '100', '...'), 'stBlogFrontend/show?url=' . $blog->getFriendlyUrl());
|
|
|
|
$row['untruncated_long_description'] = st_link_to($blog->getLongDescription(), 'stBlogFrontend/show?url=' . $blog->getFriendlyUrl());
|
|
|
|
$row['unlinked_long_description'] = st_truncate_text($blog->getLongDescription(), '100', '...');
|
|
|
|
$row['clear_long_description'] = $blog->getLongDescription();
|
|
|
|
if (!$blog->getShortDescription() || $blog->getShortDescription()=="") {
|
|
$row['short_description_char_count'] = Blog::trim_post($blog->getLongDescription(), $config->get('list_char_numbers'));
|
|
} else {
|
|
$row['short_description_char_count'] = Blog::trim_post($blog->getShortDescription(), $config->get('list_char_numbers'));
|
|
}
|
|
$row['long_description_char_count'] = Blog::trim_post($blog->getLongDescription(), $config->get('list_char_numbers'));
|
|
|
|
if ($config->get('date')==2) {
|
|
|
|
if ($blog->getCreatedAt()) {
|
|
$date = explode(" ", $blog->getCreatedAt());
|
|
|
|
$date = explode("-", $date[0]);
|
|
|
|
$row['date'] = $date[2]."-".$date[1]."-".$date[0];
|
|
} else {
|
|
$row['date'] = "";
|
|
}
|
|
|
|
|
|
} elseif ($config->get('date')==1) {
|
|
|
|
$date = explode(" ", $blog->getUpdatedAt());
|
|
|
|
$date = explode("-", $date[0]);
|
|
|
|
$row['date'] = $date[2]."-".$date[1]."-".$date[0];
|
|
|
|
} else {
|
|
|
|
$row['date'] = NULL;
|
|
}
|
|
if ($blog->getAlternativeUrl()) {
|
|
$row['image_main_page_rwd'] = st_link_to(image_tag(st_asset_image_path($blog->getImagePath(), 'thumb', 'blog'), array('alt' => $blog->getName())), $blog->getAlternativeUrl(), array());
|
|
} else {
|
|
$row['image_main_page_rwd'] = st_link_to(image_tag(st_asset_image_path($blog->getImagePath(), 'thumb', 'blog'), array('alt' => $blog->getName())), 'stBlogFrontend/show?url=' . $blog->getFriendlyUrl(), array());
|
|
}
|
|
$row['image_name'] = $blog->getImageMainPage();
|
|
|
|
$row['image_main_page'] = st_link_to(image_tag('/'.sfConfig::get('sf_upload_dir_name').'/blog/main/'.$blog->getImageMainPage(), array('alt' => $blog->getName())), 'stBlogFrontend/show?url=' . $blog->getFriendlyUrl());
|
|
|
|
$row['image'] = st_link_to(image_tag('/'.sfConfig::get('sf_upload_dir_name').'/blog/post/'.$blog->getImage(), array('alt' => $blog->getName())), 'stBlogFrontend/show?url=' . $blog->getFriendlyUrl(), array());
|
|
|
|
$results[] = $row;
|
|
}
|
|
|
|
$smarty->assign('recommends', $results);
|
|
}
|
|
|
|
$product_config = stConfig::getInstance(sfContext::getInstance(), 'stProduct');
|
|
|
|
|
|
$description_type = $config->get('products_r_description_type');
|
|
|
|
$cut_description = $config->get('products_r_description_show');
|
|
|
|
$max_desc_length = $config->get('products_r_description_char');
|
|
|
|
$smarty->assign('products_r_post_grid', $config->get('products_r_post_grid'));
|
|
|
|
|
|
if ($products) {
|
|
$results = array();
|
|
|
|
foreach ($products as $product) {
|
|
|
|
$product_url = st_url_for('stProduct/show?url='.$product->getUrl());;
|
|
|
|
$row['id'] = $product->getId();
|
|
|
|
$row['name'] = $product->getName();
|
|
|
|
$row['url'] = $url;
|
|
|
|
$row['image'] = content_tag('a', st_product_image_tag($product, 'big'), array('href' =>$product_url));
|
|
|
|
$row['link'] = st_link_to($product->getName(), 'stProduct/show?url='.$product->getUrl());
|
|
|
|
if ($description_type == 'short') {
|
|
if ($cut_description && st_check_strlen($product->getShortDescription()) > $max_desc_length) {
|
|
$row['description'] = st_truncate_text($product->getShortDescription(), $max_desc_length, '...');
|
|
} else {
|
|
$row['description'] = strip_tags($product->getShortDescription());
|
|
}
|
|
}
|
|
elseif ($description_type == 'full')
|
|
{
|
|
if ($cut_description && st_check_strlen($product->getDescription()) > $max_desc_length) {
|
|
$row['description'] = st_truncate_text($product->getDescription(), $max_desc_length, '...');
|
|
} else {
|
|
$row['description'] = strip_tags($product->getDescription());
|
|
}
|
|
}
|
|
|
|
$results[] = $row;
|
|
}
|
|
|
|
$smarty->assign('products', $results);
|
|
}
|
|
|
|
$smarty->assign('blog_index_url', st_url_for('stBlogFrontend/list'));
|
|
|
|
$smarty->display('blog_show.html');
|
|
|
|
?>
|