2021-09-07 12:33:18 +00:00
|
|
|
<?php
|
2021-09-07 13:21:38 +00:00
|
|
|
/**
|
|
|
|
* @brief cinecturlink2, a plugin for Dotclear 2
|
2021-11-02 22:55:41 +00:00
|
|
|
*
|
2021-09-07 13:21:38 +00:00
|
|
|
* @package Dotclear
|
|
|
|
* @subpackage Plugin
|
2021-11-02 22:55:41 +00:00
|
|
|
*
|
2021-09-07 13:21:38 +00:00
|
|
|
* @author Jean-Christian Denis and Contributors
|
2021-11-02 22:55:41 +00:00
|
|
|
*
|
2021-09-07 13:21:38 +00:00
|
|
|
* @copyright Jean-Christian Denis
|
|
|
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
*/
|
2021-09-07 12:33:18 +00:00
|
|
|
if (!defined('DC_RC_PATH')) {
|
2021-09-07 13:21:38 +00:00
|
|
|
return null;
|
2021-09-07 12:33:18 +00:00
|
|
|
}
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
require_once dirname(__FILE__) . '/_widgets.php';
|
2021-09-07 12:33:18 +00:00
|
|
|
|
|
|
|
$core->blog->settings->addNamespace('cinecturlink2');
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
$c2_tpl_values = [
|
2021-09-07 13:21:38 +00:00
|
|
|
'c2PageFeedID',
|
|
|
|
'c2PageFeedURL',
|
|
|
|
'c2PageURL',
|
|
|
|
'c2PageTitle',
|
|
|
|
'c2PageDescription',
|
|
|
|
|
|
|
|
'c2EntryIfOdd',
|
|
|
|
'c2EntryIfFirst',
|
|
|
|
'c2EntryFeedID',
|
|
|
|
'c2EntryID',
|
|
|
|
'c2EntryTitle',
|
|
|
|
'c2EntryDescription',
|
|
|
|
'c2EntryFromAuthor',
|
|
|
|
'c2EntryAuthorCommonName',
|
|
|
|
'c2EntryAuthorDisplayName',
|
|
|
|
'c2EntryAuthorEmail',
|
|
|
|
'c2EntryAuthorID',
|
|
|
|
'c2EntryAuthorLink',
|
|
|
|
'c2EntryAuthorURL',
|
|
|
|
'c2EntryLang',
|
|
|
|
'c2EntryURL',
|
|
|
|
'c2EntryCategory',
|
|
|
|
'c2EntryCategoryID',
|
|
|
|
'c2EntryCategoryURL',
|
|
|
|
'c2EntryImg',
|
|
|
|
'c2EntryDate',
|
|
|
|
'c2EntryTime',
|
|
|
|
|
|
|
|
'c2PaginationCounter',
|
|
|
|
'c2PaginationCurrent',
|
|
|
|
'c2PaginationURL',
|
|
|
|
|
|
|
|
'c2CategoryFeedID',
|
|
|
|
'c2CategoryFeedURL',
|
|
|
|
'c2CategoryID',
|
|
|
|
'c2CategoryTitle',
|
|
|
|
'c2CategoryDescription',
|
|
|
|
'c2CategoryURL'
|
2021-11-02 22:55:41 +00:00
|
|
|
];
|
2021-09-07 12:33:18 +00:00
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
$c2_tpl_blocks = [
|
2021-09-07 13:21:38 +00:00
|
|
|
'c2If',
|
2021-09-07 12:33:18 +00:00
|
|
|
|
2021-09-07 13:21:38 +00:00
|
|
|
'c2Entries',
|
|
|
|
'c2EntriesHeader',
|
|
|
|
'c2EntriesFooter',
|
|
|
|
'c2EntryIf',
|
2021-09-07 12:33:18 +00:00
|
|
|
|
2021-09-07 13:21:38 +00:00
|
|
|
'c2Pagination',
|
|
|
|
'c2PaginationIf',
|
2021-09-07 12:33:18 +00:00
|
|
|
|
2021-09-07 13:21:38 +00:00
|
|
|
'c2Categories',
|
|
|
|
'c2CategoriesHeader',
|
|
|
|
'c2CategoriesFooter',
|
|
|
|
'c2CategoryIf'
|
2021-11-02 22:55:41 +00:00
|
|
|
];
|
2021-09-07 12:33:18 +00:00
|
|
|
|
|
|
|
if ($core->blog->settings->cinecturlink2->cinecturlink2_active) {
|
2021-11-02 22:55:41 +00:00
|
|
|
foreach ($c2_tpl_blocks as $v) {
|
|
|
|
$core->tpl->addBlock($v, ['tplCinecturlink2', $v]);
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
2021-11-02 22:55:41 +00:00
|
|
|
foreach ($c2_tpl_values as $v) {
|
|
|
|
$core->tpl->addValue($v, ['tplCinecturlink2', $v]);
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
2021-11-02 22:55:41 +00:00
|
|
|
} else {
|
|
|
|
foreach (array_merge($c2_tpl_blocks, $c2_tpl_values) as $v) {
|
|
|
|
$core->tpl->addBlock($v, ['tplCinecturlink2', 'disable']);
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
2021-09-07 12:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class urlCinecturlink2 extends dcUrlHandlers
|
|
|
|
{
|
2021-09-07 13:21:38 +00:00
|
|
|
public static function c2Page($args)
|
|
|
|
{
|
|
|
|
global $core, $_ctx;
|
|
|
|
$core->blog->settings->addNamespace('cinecturlink2');
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
if (!$core->blog->settings->cinecturlink2->cinecturlink2_active
|
|
|
|
|| !$core->blog->settings->cinecturlink2->cinecturlink2_public_active) {
|
2021-09-07 13:21:38 +00:00
|
|
|
self::p404();
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$core->tpl->setPath(
|
|
|
|
$core->tpl->getPath(),
|
2021-11-02 22:55:41 +00:00
|
|
|
dirname(__FILE__) . '/default-templates/'
|
2021-09-07 13:21:38 +00:00
|
|
|
);
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
$params = [];
|
2021-09-07 13:21:38 +00:00
|
|
|
|
|
|
|
$n = self::getPageArgs($args, 'c2page');
|
|
|
|
if ($n) {
|
|
|
|
$GLOBALS['c2_page_number'] = $n;
|
|
|
|
}
|
|
|
|
|
|
|
|
$caturl = $core->blog->settings->cinecturlink2->cinecturlink2_public_caturl;
|
2021-11-02 22:55:41 +00:00
|
|
|
if (!$caturl) {
|
|
|
|
$caturl = 'c2cat';
|
|
|
|
}
|
2021-09-07 13:21:38 +00:00
|
|
|
|
|
|
|
$c = self::getPageArgs($args, $caturl);
|
|
|
|
if ($c) {
|
|
|
|
if (is_numeric($c)) {
|
2021-11-02 22:55:41 +00:00
|
|
|
$params['cat_id'] = (int) $c;
|
|
|
|
} else {
|
2021-09-07 13:21:38 +00:00
|
|
|
$params['cat_title'] = urldecode($c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$f = self::getPageArgs($args, 'feed');
|
2021-11-02 22:55:41 +00:00
|
|
|
if ($f && in_array($f, ['atom', 'rss2'])) {
|
2021-09-07 13:21:38 +00:00
|
|
|
$mime = $f == 'atom' ? 'application/atom+xml' : 'application/xml';
|
|
|
|
|
|
|
|
//$_ctx->short_feed_items = $core->blog->settings->system->short_feed_items;
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
$params['limit'] = $core->blog->settings->system->nb_post_per_feed;
|
2021-09-07 13:21:38 +00:00
|
|
|
$_ctx->c2_page_params = $params;
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
header('X-Robots-Tag: ' . context::robotsPolicy($core->blog->settings->system->robots_policy, ''));
|
|
|
|
self::serveDocument('cinecturlink2-' . $f . '.xml', $mime);
|
|
|
|
} else {
|
2021-09-07 13:21:38 +00:00
|
|
|
$d = self::getPageArgs($args, 'c2detail');
|
|
|
|
if ($d) {
|
|
|
|
if (is_numeric($d)) {
|
2021-11-02 22:55:41 +00:00
|
|
|
$params['link_id'] = (int) $d;
|
|
|
|
} else {
|
2021-09-07 13:21:38 +00:00
|
|
|
$params['link_title'] = urldecode($d);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
$params['limit'] = $core->blog->settings->cinecturlink2->cinecturlink2_public_nbrpp;
|
2021-09-07 13:21:38 +00:00
|
|
|
$_ctx->c2_page_params = $params;
|
|
|
|
|
|
|
|
self::serveDocument('cinecturlink2.html', 'text/html');
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected static function getPageArgs(&$args, $part)
|
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
if (preg_match('#(^|/)' . $part . '/([^/]+)#', $args, $m)) {
|
|
|
|
$args = preg_replace('#(^|/)' . $part . '/([^/]+)#', '', $args);
|
2021-09-07 13:21:38 +00:00
|
|
|
|
|
|
|
return $m[2];
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2021-09-07 12:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class tplCinecturlink2
|
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
public static function disable($a, $c = null)
|
2021-09-07 13:21:38 +00:00
|
|
|
{
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2PageURL($a)
|
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
return '<?php echo ' . sprintf($GLOBALS['core']->tpl->getFilters($a), '$core->blog->url.$core->url->getBase(\'cinecturlink2\')') . '; ?>';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2PageTitle($a)
|
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
return "<?php \$title = (string) \$core->blog->settings->cinecturlink2->cinecturlink2_public_title; if (empty(\$title)) { \$title = __('My cinecturlink'); } echo " . sprintf($GLOBALS['core']->tpl->getFilters($a), '$title') . '; ?>';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2PageFeedURL($a)
|
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
return '<?php echo ' . sprintf($GLOBALS['core']->tpl->getFilters($a), '$core->blog->url.$core->url->getBase("cinecturlink2")."/feed/' . (!empty($a['type']) && preg_match('#^(rss2|atom)$#', $a['type']) ? $a['type'] : 'atom') . '"') . '; ?>';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2PageFeedID($a)
|
|
|
|
{
|
2021-11-03 00:31:17 +00:00
|
|
|
return 'urn:md5:<?php echo md5($core->blog->id."cinecturlink2"); ?>';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2PageDescription($a)
|
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
return '<?php $description = (string) $core->blog->settings->cinecturlink2->cinecturlink2_public_description; echo ' . sprintf($GLOBALS['core']->tpl->getFilters($a), '$description') . '; ?>';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
public static function c2If($a, $c)
|
2021-09-07 13:21:38 +00:00
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
$if = [];
|
2021-09-07 13:21:38 +00:00
|
|
|
|
|
|
|
$operator = isset($a['operator']) ? self::getOperator($a['operator']) : '&&';
|
|
|
|
|
|
|
|
if (isset($a['request_link'])) {
|
2021-11-02 22:55:41 +00:00
|
|
|
$sign = (bool) $a['request_link'] ? '' : '!';
|
|
|
|
$if[] = $sign . '(isset($_ctx->c2_page_params["link_id"]) || isset($_ctx->c2_page_params["link_title"]))';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($a['request_cat'])) {
|
2021-11-02 22:55:41 +00:00
|
|
|
$sign = (bool) $a['request_cat'] ? '' : '!';
|
|
|
|
$if[] = $sign . '(isset($_ctx->c2_page_params["cat_id"]) || isset($_ctx->c2_page_params["cat_title"]))';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
return empty($if) ? $c : '<?php if(' . implode(' ' . $operator . ' ', $if) . ") : ?>\n" . $c . "<?php endif; ?>\n";
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2Entries($a, $c)
|
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
$lastn = isset($a['lastn']) ? abs((int) $a['lastn']) + 0 : -1;
|
2021-09-07 13:21:38 +00:00
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
$res = 'if (!isset($c2_page_number)) { $c2_page_number = 1; }' . "\n";
|
2021-09-07 13:21:38 +00:00
|
|
|
|
|
|
|
if ($lastn != 0) {
|
|
|
|
if ($lastn > 0) {
|
2021-11-02 22:55:41 +00:00
|
|
|
$res .= "\$params['limit'] = " . $lastn . ";\n";
|
|
|
|
} else {
|
2021-09-07 13:21:38 +00:00
|
|
|
$res .= "if (!isset(\$params['limit']) || \$params['limit'] < 1) { \$params['limit'] = 10; }\n";
|
|
|
|
}
|
2021-11-02 22:55:41 +00:00
|
|
|
if (!isset($a['ignore_pagination']) || $a['ignore_pagination'] == '0') {
|
2021-09-07 13:21:38 +00:00
|
|
|
$res .= "\$params['limit'] = array(((\$c2_page_number-1)*\$params['limit']),\$params['limit']);\n";
|
2021-11-02 22:55:41 +00:00
|
|
|
} else {
|
2021-09-07 13:21:38 +00:00
|
|
|
$res .= "\$params['limit'] = array(0, \$params['limit']);\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($a['category'])) {
|
|
|
|
if ($a['category'] == 'null') {
|
|
|
|
$res .= "\$params['sql'] = ' AND L.cat_id IS NULL ';\n";
|
2021-11-02 22:55:41 +00:00
|
|
|
} elseif (is_numeric($a['category'])) {
|
|
|
|
$res .= "\$params['cat_id'] = " . (int) $a['category'] . ";\n";
|
|
|
|
} else {
|
|
|
|
$res .= "\$params['cat_title'] = '" . $a['category'] . "';\n";
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
$sort = isset($a['sort']) && $a['sort'] == 'asc' ? ' asc' : ' desc';
|
|
|
|
$sortby = isset($a['order']) && in_array($a['order'], ['link_count','link_upddt','link_creadt','link_note','link_title']) ? $a['order'] : 'link_upddt';
|
|
|
|
|
|
|
|
$res .= "\$params['order'] = '" . $sortby . $sort . "';\n";
|
|
|
|
|
|
|
|
return
|
|
|
|
"<?php \n" .
|
|
|
|
"\$params = is_array(\$_ctx->c2_page_params) ? \$_ctx->c2_page_params : array(); \n" .
|
|
|
|
$res .
|
|
|
|
"\$_ctx->c2_params = \$params; unset(\$params);\n" .
|
|
|
|
"if (!\$_ctx->exists('cinecturlink')) { \$_ctx->cinecturlink = new cinecturlink2(\$core); } \n" .
|
|
|
|
"\$_ctx->c2_entries = \$_ctx->cinecturlink->getLinks(\$_ctx->c2_params); \n" .
|
|
|
|
'while ($_ctx->c2_entries->fetch()) : ?>' . $c . '<?php endwhile; ' . "\n" .
|
|
|
|
"\$_ctx->c2_entries = null; \$_ctx->c2_params = null; \n" .
|
2021-09-07 13:21:38 +00:00
|
|
|
"?>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2EntriesHeader($a, $c)
|
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
return '<?php if ($_ctx->c2_entries->isStart()) : ?>' . $c . '<?php endif; ?>';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2EntriesFooter($a, $c)
|
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
return '<?php if ($_ctx->c2_entries->isEnd()) : ?>' . $c . '<?php endif; ?>';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2EntryIf($a, $c)
|
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
$if = [];
|
2021-09-07 13:21:38 +00:00
|
|
|
|
|
|
|
$operator = isset($a['operator']) ? self::getOperator($a['operator']) : '&&';
|
|
|
|
|
|
|
|
if (isset($a['has_category'])) {
|
2021-11-02 22:55:41 +00:00
|
|
|
$sign = (bool) $a['has_category'] ? '!' : '=';
|
|
|
|
$if[] = '($_ctx->exists("c2_entries") && "" ' . $sign . '= $_ctx->c2_entries->cat_title)';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
return empty($if) ? $c : '<?php if(' . implode(' ' . $operator . ' ', $if) . ") : ?>\n" . $c . "<?php endif; ?>\n";
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2EntryIfFirst($a)
|
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
return '<?php if ($_ctx->c2_entries->index() == 0) { echo "' . (isset($a['return']) ? addslashes(html::escapeHTML($a['return'])) : 'first') . '"; } ?>';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2EntryIfOdd($a)
|
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
return '<?php if (($_ctx->c2_entries->index()+1)%2 == 1) { echo "' . (isset($a['return']) ? addslashes(html::escapeHTML($a['return'])) : 'odd') . '"; } ?>';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2EntryFeedID($a)
|
|
|
|
{
|
2021-11-03 00:31:17 +00:00
|
|
|
return 'urn:md5:<?php echo md5($_ctx->c2_entries->blog_id.$_ctx->c2_entries->link_id.$_ctx->c2_entries->link_creadt); ?>';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2EntryID($a)
|
|
|
|
{
|
|
|
|
return self::getGenericValue('$_ctx->c2_entries->link_id', $a);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2EntryTitle($a)
|
|
|
|
{
|
|
|
|
return self::getGenericValue('$_ctx->c2_entries->link_title', $a);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2EntryDescription($a)
|
|
|
|
{
|
|
|
|
return self::getGenericValue('$_ctx->c2_entries->link_desc', $a);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2EntryAuthorCommonName($a)
|
|
|
|
{
|
|
|
|
return self::getGenericValue('dcUtils::getUserCN($_ctx->c2_entries->user_id,$_ctx->c2_entries->user_name,$_ctx->c2_entries->user_firstname,$_ctx->c2_entries->user_displayname)', $a);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2EntryAuthorDisplayName($a)
|
|
|
|
{
|
|
|
|
return self::getGenericValue('$_ctx->c2_entries->user_displayname', $a);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2EntryAuthorID($a)
|
|
|
|
{
|
|
|
|
return self::getGenericValue('$_ctx->c2_entries->user_id', $a);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2EntryAuthorEmail($a)
|
|
|
|
{
|
|
|
|
return self::getGenericValue((isset($a['spam_protected']) && !$a['spam_protected'] ? '$_ctx->c2_entries->user_email' : "strtr(\$_ctx->c2_entries->user_email,array('@'=>'%40','.'=>'%2e'))"), $a);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2EntryAuthorLink($a)
|
|
|
|
{
|
|
|
|
return self::getGenericValue('sprintf(($_ctx->c2_entries->user_url ? \'<a href="%2$s">%1$s</a>\' : \'%1$s\'),html::escapeHTML(dcUtils::getUserCN($_ctx->c2_entries->user_id,$_ctx->c2_entries->user_name,$_ctx->c2_entries->user_firstname,$_ctx->c2_entries->user_displayname)),html::escapeHTML($_ctx->c2_entries->user_url))', $a);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2EntryAuthorURL($a)
|
|
|
|
{
|
|
|
|
return self::getGenericValue('$_ctx->c2_entries->user_url', $a);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2EntryFromAuthor($a)
|
|
|
|
{
|
|
|
|
return self::getGenericValue('$_ctx->c2_entries->link_author', $a);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2EntryLang($a)
|
|
|
|
{
|
|
|
|
return self::getGenericValue('$_ctx->c2_entries->link_lang', $a);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2EntryURL($a)
|
|
|
|
{
|
|
|
|
return self::getGenericValue('$_ctx->c2_entries->link_url', $a);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2EntryCategory($a)
|
|
|
|
{
|
|
|
|
return self::getGenericValue('$_ctx->c2_entries->cat_title', $a);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2EntryCategoryID($a)
|
|
|
|
{
|
|
|
|
return self::getGenericValue('$_ctx->c2_entries->cat_id', $a);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2EntryCategoryURL($a)
|
|
|
|
{
|
|
|
|
return self::getGenericValue('$core->blog->url.$core->url->getBase("cinecturlink2")."/".$core->blog->settings->cinecturlink2->cinecturlink2_public_caturl."/".urlencode($_ctx->c2_entries->cat_title)', $a);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2EntryImg($a)
|
|
|
|
{
|
|
|
|
global $core;
|
2021-11-02 22:55:41 +00:00
|
|
|
$f = $core->tpl->getFilters($a);
|
2021-09-07 13:21:38 +00:00
|
|
|
$style = isset($a['style']) ? html::escapeHTML($a['style']) : '';
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
return
|
|
|
|
"<?php if (\$_ctx->exists('c2_entries')) { " .
|
|
|
|
'$widthmax = (integer) $core->blog->settings->cinecturlink2->cinecturlink2_widthmax; ' .
|
|
|
|
"\$img = sprintf('<img src=\"%s\" alt=\"%s\" %s/>'," .
|
|
|
|
'$_ctx->c2_entries->link_img, ' .
|
|
|
|
"html::escapeHTML(\$_ctx->c2_entries->link_title.' - '.\$_ctx->c2_entries->link_author), " .
|
|
|
|
"(\$widthmax ? ' style=\"width:'.\$widthmax.'px;$style\"' : '') " .
|
|
|
|
'); ' .
|
|
|
|
'echo ' . sprintf($f, '$img') . "; unset(\$img); } ?> \n";
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2EntryDate($a)
|
|
|
|
{
|
|
|
|
$format = !empty($a['format']) ? addslashes($a['format']) : '';
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
if (!empty($a['rfc822'])) {
|
2021-11-03 00:31:17 +00:00
|
|
|
$p = 'dt::rfc822(strtotime($_ctx->c2_entries->link_creadt), $core->blog->settings->system->blog_timezone)';
|
2021-11-02 22:55:41 +00:00
|
|
|
} elseif (!empty($a['iso8601'])) {
|
2021-11-03 00:31:17 +00:00
|
|
|
$p = 'dt::iso8601(strtotime($_ctx->c2_entries->link_creadt), $core->blog->settings->system->blog_timezone)';
|
2021-11-02 22:55:41 +00:00
|
|
|
} elseif ($format) {
|
|
|
|
$p = "dt::dt2str('" . $format . "', \$_ctx->c2_entries->link_creadt)";
|
|
|
|
} else {
|
|
|
|
$p = 'dt::dt2str($core->blog->settings->system->date_format, $_ctx->c2_entries->link_creadt)';
|
|
|
|
}
|
2021-09-07 13:21:38 +00:00
|
|
|
|
|
|
|
return self::getGenericValue($p, $a);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2EntryTime($a)
|
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
return self::getGenericValue('dt::dt2str(' . (!empty($a['format']) ? "'" . addslashes($a['format']) . "'" : '$core->blog->settings->system->time_format') . ', $_ctx->c2_entries->link_creadt)', $a);
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2Pagination($a, $c)
|
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
$p = "<?php\n" .
|
|
|
|
"\$params = \$_ctx->c2_params;\n" .
|
|
|
|
"\$_ctx->c2_pagination = \$_ctx->cinecturlink->getLinks(\$params,true); unset(\$params);\n" .
|
2021-09-07 13:21:38 +00:00
|
|
|
"?>\n";
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
return isset($a['no_context']) ? $p . $c : $p . '<?php if ($_ctx->c2_pagination->f(0) > $_ctx->c2_entries->count()) : ?>' . $c . '<?php endif; ?>';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2PaginationCounter($a)
|
|
|
|
{
|
|
|
|
return self::getGenericValue('cinecturlink2Context::PaginationNbPages()', $a);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2PaginationCurrent($a)
|
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
return self::getGenericValue('cinecturlink2Context::PaginationPosition(' . (isset($a['offset']) ? (int) $a['offset'] : 0) . ')', $a);
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2PaginationIf($a, $c)
|
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
$if = [];
|
2021-09-07 13:21:38 +00:00
|
|
|
|
|
|
|
if (isset($a['start'])) {
|
2021-11-02 22:55:41 +00:00
|
|
|
$sign = (bool) $a['start'] ? '' : '!';
|
|
|
|
$if[] = $sign . 'cinecturlink2Context::PaginationStart()';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
if (isset($a['end'])) {
|
2021-11-02 22:55:41 +00:00
|
|
|
$sign = (bool) $a['end'] ? '' : '!';
|
|
|
|
$if[] = $sign . 'cinecturlink2Context::PaginationEnd()';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
return empty($if) ? $c : '<?php if(' . implode(' && ', $if) . ') : ?>' . $c . '<?php endif; ?>';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2PaginationURL($a)
|
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
return self::getGenericValue('cinecturlink2Context::PaginationURL(' . (isset($a['offset']) ? (int) $a['offset'] : 0) . ')', $a);
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2Categories($a, $c)
|
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
return
|
|
|
|
"<?php \n" .
|
|
|
|
"if (!\$_ctx->exists('cinecturlink')) { \$_ctx->cinecturlink = new cinecturlink2(\$core); } \n" .
|
|
|
|
"\$_ctx->c2_categories = \$_ctx->cinecturlink->getCategories(); \n" .
|
|
|
|
'while ($_ctx->c2_categories->fetch()) : ?>' . $c . '<?php endwhile; ' . "\n" .
|
|
|
|
"\$_ctx->c2_categories = null; \n" .
|
2021-09-07 13:21:38 +00:00
|
|
|
"?>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2CategoriesHeader($a, $c)
|
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
return '<?php if ($_ctx->c2_categories->isStart()) : ?>' . $c . '<?php endif; ?>';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2CategoriesFooter($a, $c)
|
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
return '<?php if ($_ctx->c2_categories->isEnd()) : ?>' . $c . '<?php endif; ?>';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2CategoryIf($a, $c)
|
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
$if = [];
|
2021-09-07 13:21:38 +00:00
|
|
|
|
|
|
|
if (isset($a['current'])) {
|
2021-11-02 22:55:41 +00:00
|
|
|
$sign = (bool) $a['current'] ? '' : '!';
|
|
|
|
$if[] = $sign . 'cinecturlink2Context::CategoryCurrent()';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
if (isset($a['first'])) {
|
2021-11-02 22:55:41 +00:00
|
|
|
$sign = (bool) $a['first'] ? '' : '!';
|
|
|
|
$if[] = $sign . '$_ctx->c2_categories->isStart()';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
return empty($if) ? $c : '<?php if(' . implode(' && ', $if) . ') : ?>' . $c . '<?php endif; ?>';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2CategoryFeedURL($a)
|
|
|
|
{
|
|
|
|
$p = !empty($a['type']) ? $a['type'] : 'atom';
|
|
|
|
|
|
|
|
if (!preg_match('#^(rss2|atom)$#', $p)) {
|
|
|
|
$p = 'atom';
|
|
|
|
}
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
return '<?php echo ' . sprintf($GLOBALS['core']->tpl->getFilters($a), '$core->blog->url.$core->url->getBase("cinecturlink2")."/".$core->blog->settings->cinecturlink2->cinecturlink2_public_caturl."/".urlencode($_ctx->c2_categories->cat_title)."/feed/' . $p . '"') . '; ?>';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2CategoryFeedID($a)
|
|
|
|
{
|
2021-11-03 00:31:17 +00:00
|
|
|
return 'urn:md5:<?php echo md5($core->blog->id."cinecturlink2".$_ctx->c2_categories->cat_id); ?>';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2CategoryID($a)
|
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
return "<?php if (\$_ctx->exists('c2_categories')) { echo " . sprintf($GLOBALS['core']->tpl->getFilters($a), '$_ctx->c2_categories->cat_id') . '; } ?>';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2CategoryTitle($a)
|
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
return "<?php if (\$_ctx->exists('c2_categories')) { echo " . sprintf($GLOBALS['core']->tpl->getFilters($a), '$_ctx->c2_categories->cat_title') . '; } ?>';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2CategoryDescription($a)
|
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
return "<?php if (\$_ctx->exists('c2_categories')) { echo " . sprintf($GLOBALS['core']->tpl->getFilters($a), '$_ctx->c2_categories->cat_desc') . '; } ?>';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function c2CategoryURL($a)
|
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
return "<?php if (\$_ctx->exists('c2_categories')) { echo " . sprintf($GLOBALS['core']->tpl->getFilters($a), '$core->blog->url.$core->url->getBase("cinecturlink2")."/".$core->blog->settings->cinecturlink2->cinecturlink2_public_caturl."/".urlencode($_ctx->c2_categories->cat_title)') . '; } ?>';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
protected static function getGenericValue($p, $a)
|
2021-09-07 13:21:38 +00:00
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
return "<?php if (\$_ctx->exists('c2_entries')) { echo " . sprintf($GLOBALS['core']->tpl->getFilters($a), "$p") . '; } ?>';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected static function getOperator($op)
|
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
switch (strtolower($op)) {
|
2021-09-07 13:21:38 +00:00
|
|
|
case 'or':
|
|
|
|
case '||':
|
|
|
|
return '||';
|
|
|
|
case 'and':
|
|
|
|
case '&&':
|
|
|
|
default:
|
|
|
|
return '&&';
|
|
|
|
}
|
|
|
|
}
|
2021-11-02 22:55:41 +00:00
|
|
|
}
|