137 lines
5.7 KiB
PHP
137 lines
5.7 KiB
PHP
<?php
|
|
dcCore::app()->tpl->addBlock('PhotoblogNav', array('tplPhotoblog','PhotoblogNav'));
|
|
dcCore::app()->tpl->addValue('PhotoblogThumbURL', array('tplPhotoblog','PhotoblogThumbURL'));
|
|
dcCore::app()->tpl->addValue('PhotoblogThumbSize', array('tplPhotoblog','PhotoblogThumbSize'));
|
|
dcCore::app()->tpl->addValue('PhotoblogEntryContent', array('tplPhotoblog','PhotoblogEntryContent'));
|
|
dcCore::app()->tpl->addValue('PhotoblogEntryExcerpt', array('tplPhotoblog','PhotoblogEntryExcerpt'));
|
|
|
|
class tplPhotoblog #extends dcUrlHandlers
|
|
{
|
|
public static function PhotoblogEntryExcerpt($attr)
|
|
{
|
|
$urls = '0';
|
|
if (!empty($attr['absolute_urls'])) {
|
|
$urls = '1';
|
|
}
|
|
|
|
$full_size = false;
|
|
if (!empty($attr['full_size'])) {
|
|
$full_size = true;
|
|
}
|
|
|
|
$f = dcCore::app()->tpl->getFilters($attr);
|
|
$content = 'dcCore::app()->ctx->posts->getExcerpt('.$urls.')';
|
|
|
|
// The theme designer wants to use thumbnails in the display
|
|
if (!$full_size) {
|
|
$content = 'str_replace(dcPhotoblog::getPostImages(dcCore::app()->ctx->posts->post_id),'.
|
|
'dcPhotoblog::getPostImagesColorThumb(dcCore::app()->ctx->posts->post_id,false),'.
|
|
$content.')';
|
|
}
|
|
return '<?php echo '.sprintf($f, $content).'; ?>';
|
|
}
|
|
|
|
public static function PhotoblogEntryContent($attr)
|
|
{
|
|
$urls = '0';
|
|
if (!empty($attr['absolute_urls'])) {
|
|
$urls = '1';
|
|
}
|
|
|
|
$full_size = false;
|
|
if (!empty($attr['full_size'])) {
|
|
$full_size = true;
|
|
}
|
|
|
|
$f = dcCore::app()->tpl->getFilters($attr);
|
|
$content = 'dcCore::app()->ctx->posts->getContent('.$urls.')';
|
|
|
|
// The theme designer wants to use thumbnails in the display
|
|
if (!$full_size) {
|
|
$content = 'str_replace(dcPhotoblog::getPostImages(dcCore::app()->ctx->posts->post_id),'.
|
|
'dcPhotoblog::getPostImagesColorThumb(dcCore::app()->ctx->posts->post_id,false),'.
|
|
$content.')';
|
|
}
|
|
return '<?php echo '.sprintf($f, $content).'; ?>';
|
|
}
|
|
|
|
public static function PhotoblogThumbURL($attr)
|
|
{
|
|
$f = dcCore::app()->tpl->getFilters($attr);
|
|
$is_forarchive = isset($attr['archive']) ? ($attr['archive'] == 1) : 'false';
|
|
if (isset($attr['type']) && (strtolower($attr['type']) == 'color')) {
|
|
$type = 'Color';
|
|
} else {
|
|
$type = 'BW';
|
|
}
|
|
return '<?php echo '.sprintf($f, 'dcPhotoblog::getPostImage'.$type.'Thumb(dcCore::app()->ctx->posts->post_id, ' . $is_forarchive . ')').'; ?>';
|
|
}
|
|
|
|
public static function PhotoblogThumbSize($attr)
|
|
{
|
|
$dimension = (isset($attr['dimension']) && (strtolower($attr['dimension']) == 'width')) ? '_width' : '_height';
|
|
$type = (isset($attr['archive']) && ($attr['archive'] == 1)) ? '_archive' : '_nav';
|
|
return '<?php echo dcCore::app()->blog->settings->photoblog_thumbnail'.$dimension.$type.'; ?>';
|
|
}
|
|
|
|
/*dtd
|
|
<!ELEMENT tpl:PhotoblogNav - - -- Photoblog navigation loop -->
|
|
<!ATTLIST tpl:PhotoblogNav
|
|
nbEntries CDATA #IMPLIED -- number of posts to retrieve
|
|
dir (-1|0|1) #IMPLIED -- direction of posts lookup from current post
|
|
reverse (0|1) #IMPLIED -- reverse order of output
|
|
category CDATA #IMPLIED -- get entries for specific categories only (multiple comma-separated categories can be specified. Use "!" as prefix to exclude a category)
|
|
no_category CDATA #IMPLIED -- get entries without category
|
|
>
|
|
*/
|
|
public static function PhotoblogNav($args, $content)
|
|
{
|
|
$nb_entries = isset($args['nbEntries']) ? (integer) $args['nbEntries'] : 0;
|
|
$dir = isset($args['dir']) ? (integer) $args['dir'] : 1;
|
|
if (!isset($args['reverse'])) {
|
|
$reverse = ($dir < 0);
|
|
} else {
|
|
$reverse = ((integer) $args['reverse'] != 0);
|
|
}
|
|
if ($reverse) {
|
|
$for_loop = 'for ($i = dcCore::app()->ctx->posts->count() - 1; $i >= 0; $i--)';
|
|
} else {
|
|
$for_loop = 'for ($i = 0; $i < dcCore::app()->ctx->posts->count(); $i++)';
|
|
}
|
|
$p = '';
|
|
if (isset($args['category'])) {
|
|
$p .= "\$params['cat_url'] = '".addslashes($args['category'])."';\n";
|
|
$p .= "context::categoryPostParam(\$params);\n";
|
|
}
|
|
if (isset($args['no_category'])) {
|
|
$p .= "@\$params['sql'] .= ' AND P.cat_id IS NULL ';\n";
|
|
$p .= "unset(\$params['cat_url']);\n";
|
|
}
|
|
$p .= "\$params['nav_post_id'] = (integer) \dcCore::app()->ctx->posts->post_id;\n";
|
|
$p .= "\$params['nav_post_dt'] = strtotime(\dcCore::app()->ctx->posts->post_dt);\n";
|
|
$p .= "\$params['dir'] = $dir;\n";
|
|
$p .= "\$params['nb_entries'] = $nb_entries;\n";
|
|
|
|
if (class_exists('contextNav')) {
|
|
$nextPostsClass = 'contextNav';
|
|
$p .= "\$params['nav'] = isset(\$_REQUEST['nav']) ? \$_REQUEST['nav'] : '';\n";
|
|
$p .= "\$params['nav_param'] = isset(\$_REQUEST['navParam']) ? \$_REQUEST['navParam'] : '';\n";
|
|
} else {
|
|
$nextPostsClass = 'dcPhotoblog';
|
|
}
|
|
|
|
return '<?php ' . "\n" .
|
|
$p .
|
|
'$next_post = '.$nextPostsClass.'::getNextPosts($params);' . "\n" .
|
|
'unset($params);' . "\n".
|
|
'if ($next_post !== null) : ?>' . "\n" .
|
|
'<?php dcCore::app()->ctx->posts = $next_post; unset($next_post);' . "\n" .
|
|
$for_loop . " : ?>\n" .
|
|
'<?php dcCore::app()->ctx->posts->index($i); ?>' . "\n" .
|
|
$content .
|
|
'<?php endfor; dcCore::app()->ctx->posts = null; ?>' . "\n" .
|
|
"<?php endif; ?>\n";
|
|
}
|
|
|
|
}
|