prepare to DC 2.24

This commit is contained in:
Jean-Christian Paul Denis 2022-11-17 22:01:00 +01:00
parent 8b4dd4c2ba
commit 4301e8c133
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
13 changed files with 316 additions and 336 deletions

View File

@ -14,30 +14,30 @@ if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
require_once dirname(__FILE__) . '/_widgets.php';
require_once __DIR__ . '/_widgets.php';
$_menu['Plugins']->addItem(
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
__('My cinecturlink'),
$core->adminurl->get('admin.plugin.cinecturlink2'),
dcCore::app()->adminurl->get('admin.plugin.cinecturlink2'),
dcPage::getPF('cinecturlink2/icon.png'),
preg_match(
'/' . preg_quote($core->adminurl->get('admin.plugin.cinecturlink2')) . '(&.*)?$/',
'/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.cinecturlink2')) . '(&.*)?$/',
$_SERVER['REQUEST_URI']
),
$core->auth->check('contentadmin', $core->blog->id)
dcCore::app()->auth->check(dcAuth::PERMISSION_CONTENT_ADMIN, dcCore::app()->blog->id)
);
$core->addBehavior(
'adminColumnsLists',
dcCore::app()->addBehavior(
'adminColumnsListsV2',
['cinecturlink2AdminBehaviors', 'adminColumnsLists']
);
$core->addBehavior(
'adminFiltersLists',
dcCore::app()->addBehavior(
'adminFiltersListsV2',
['cinecturlink2AdminBehaviors', 'adminFiltersLists']
);
$core->addBehavior(
'adminDashboardFavorites',
dcCore::app()->addBehavior(
'adminDashboardFavoritesV2',
['cinecturlink2AdminBehaviors', 'adminDashboardFavorites']
);
@ -52,11 +52,11 @@ class cinecturlink2AdminBehaviors
__('Author') => 'link_author',
__('Description') => 'link_desc',
__('Link') => 'link_url',
__('Rating') => 'link_note'
__('Rating') => 'link_note',
];
}
public static function adminColumnsLists($core, $cols)
public static function adminColumnsLists($cols)
{
$cols['c2link'] = [
__('Cinecturlink'),
@ -67,30 +67,30 @@ class cinecturlink2AdminBehaviors
'desc' => [false, __('Description')],
'link' => [true, __('Liens')],
'note' => [true, __('Rating')],
]
],
];
}
public static function adminFiltersLists($core, $sorts)
public static function adminFiltersLists($sorts)
{
$sorts['c2link'] = [
__('Cinecturlink'),
self::adminSortbyCombo(),
'link_upddt',
'desc',
[__('Links per page'), 30]
[__('Links per page'), 30],
];
}
public static function adminDashboardFavorites($core, $favs)
public static function adminDashboardFavorites($favs)
{
$favs->register('cinecturlink2', [
'title' => __('My cinecturlink'),
'url' => $core->adminurl->get('admin.plugin.cinecturlink2') . '#links',
'url' => dcCore::app()->adminurl->get('admin.plugin.cinecturlink2') . '#links',
'small-icon' => dcPage::getPF('cinecturlink2/icon.png'),
'large-icon' => dcPage::getPF('cinecturlink2/icon-big.png'),
'permissions' => $core->auth->check('contentadmin', $core->blog->id),
'active_cb' => ['cinecturlink2AdminBehaviors', 'adminDashboardFavoritesActive']
'permissions' => dcCore::app()->auth->check('contentadmin', dcCore::app()->blog->id),
'active_cb' => ['cinecturlink2AdminBehaviors', 'adminDashboardFavoritesActive'],
]);
}

View File

@ -15,13 +15,13 @@ if (!defined('DC_CONTEXT_MODULE')) {
}
# Check user perms
dcPage::check('admin');
dcPage::check(dcAuth::PERMISSION_ADMIN);
$redir = empty($_REQUEST['redir']) ?
$list->getURL() . '#plugins' : $_REQUEST['redir'];
dcCore::app()->admin->list->getURL() . '#plugins' : $_REQUEST['redir'];
$core->blog->settings->addNamespace('cinecturlink2');
$s = $core->blog->settings->cinecturlink2;
dcCore::app()->blog->settings->addNamespace('cinecturlink2');
$s = dcCore::app()->blog->settings->cinecturlink2;
$cinecturlink2_active = (bool) $s->cinecturlink2_active;
$cinecturlink2_widthmax = abs((int) $s->cinecturlink2_widthmax);
$cinecturlink2_folder = (string) $s->cinecturlink2_folder;
@ -34,7 +34,7 @@ if ($cinecturlink2_public_nbrpp < 1) {
$cinecturlink2_public_nbrpp = 10;
}
$combo_dirs = cinecturlink2::getPublicDirs($core);
$combo_dirs = cinecturlink2::getPublicDirs();
if (!empty($_POST['save'])) {
try {
@ -56,7 +56,7 @@ if (!empty($_POST['save'])) {
throw new Exception(__('You must provide a specific folder for images.'));
}
cinecturlink2::makePublicDir(
DC_ROOT . '/' . $core->blog->settings->system->public_path,
DC_ROOT . '/' . dcCore::app()->blog->settings->system->public_path,
$cinecturlink2_folder,
true
);
@ -69,15 +69,15 @@ if (!empty($_POST['save'])) {
$s->put('cinecturlink2_folder', $cinecturlink2_folder);
$s->put('cinecturlink2_triggeronrandom', $cinecturlink2_triggeronrandom);
dcPage::addSuccessNotice(
dcAdminNotices::addSuccessNotice(
__('Configuration successfully updated.')
);
$core->adminurl->redirect(
dcCore::app()->adminurl->redirect(
'admin.plugins',
['module' => 'cinecturlink2', 'conf' => 1, 'redir' => $list->getRedir()]
['module' => 'cinecturlink2', 'conf' => 1, 'redir' => dcCore::app()->admin->list->getRedir()]
);
} catch (Exception $e) {
$core->error->add($e->getMessage());
dcCore::app()->error->add($e->getMessage());
}
}
@ -116,7 +116,7 @@ __('Update cache when use "Random" or "Number of view" order on widget (Need rel
<p><label class="classic" for="cinecturlink2_public_active">' .
form::checkbox('cinecturlink2_public_active', 1, $cinecturlink2_public_active) .
__('Enable public page') . '</label></p>
<p class="form-note">' . sprintf(__('Public page has url: %s'), '<a href="' . $core->blog->url . $core->url->getBase('cinecturlink2') . '" title="public page">' . $core->blog->url . $core->url->getBase('cinecturlink2') . '</a>') . '</p>
<p class="form-note">' . sprintf(__('Public page has url: %s'), '<a href="' . dcCore::app()->blog->url . dcCore::app()->url->getBase('cinecturlink2') . '" title="public page">' . dcCore::app()->blog->url . dcCore::app()->url->getBase('cinecturlink2') . '</a>') . '</p>
<p><label for="cinecturlink2_public_title">' . __('Title of the public page:') . '</label>' .
form::field('cinecturlink2_public_title', 60, 255, $cinecturlink2_public_title, 'maximal') . '</p>

View File

@ -24,13 +24,13 @@ $this->registerModule(
'Cinecturlink 2',
'Widgets and pages about books, musics, films, blogs you are interested in',
'Jean-Christian Denis and Contributors',
'1.0.0',
'1.1.0',
[
'requires' => [['core', '2.20']],
'permissions' => 'contentadmin',
'requires' => [['core', '2.24']],
'permissions' => dcAuth::PERMISSION_CONTENT_ADMIN,
'type' => 'plugin',
'support' => 'https://github.com/JcDenis/cinecturlink2',
'details' => 'https://plugins.dotaddict.org/dc2/details/cinecturlink2',
'repository' => 'https://raw.githubusercontent.com/JcDenis/cinecturlink2/master/dcstore.xml'
'repository' => 'https://raw.githubusercontent.com/JcDenis/cinecturlink2/master/dcstore.xml',
]
);

View File

@ -14,15 +14,15 @@ if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
$new_version = $core->plugins->moduleInfo('cinecturlink2', 'version');
$old_version = $core->getVersion('cinecturlink2');
$new_version = dcCore::app()->plugins->moduleInfo('cinecturlink2', 'version');
$old_version = dcCore::app()->getVersion('cinecturlink2');
if (version_compare($old_version, $new_version, '>=')) {
return;
}
try {
$s = new dbStruct($core->con, $core->prefix);
$s = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
$s->cinecturlink2
->link_id('bigint', 0, false)
->blog_id('varchar', 32, false)
@ -62,11 +62,11 @@ try {
->index('idx_cinecturlink2_cat_blog_id', 'btree', 'blog_id')
->unique('uk_cinecturlink2_cat_title', 'cat_title', 'blog_id');
$si = new dbStruct($core->con, $core->prefix);
$si = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
$changes = $si->synchronize($s);
$core->blog->settings->addNamespace('cinecturlink2');
$s = $core->blog->settings->cinecturlink2;
dcCore::app()->blog->settings->addNamespace('cinecturlink2');
$s = dcCore::app()->blog->settings->cinecturlink2;
$s->put('cinecturlink2_active', true, 'boolean', 'Enable cinecturlink2', false, true);
$s->put('cinecturlink2_widthmax', 100, 'integer', 'Maximum width of picture', false, true);
$s->put('cinecturlink2_folder', 'cinecturlink', 'string', 'Public folder of pictures', false, true);
@ -77,14 +77,14 @@ try {
$s->put('cinecturlink2_public_nbrpp', 20, 'integer', 'Number of entries per page on public page', false, true);
$s->put('cinecturlink2_public_caturl', 'c2cat', 'string', 'Part of URL for a category list', false, true);
$core->setVersion(
dcCore::app()->setVersion(
'cinecturlink2',
$core->plugins->moduleInfo('cinecturlink2', 'version')
dcCore::app()->plugins->moduleInfo('cinecturlink2', 'version')
);
return true;
} catch (Exception $e) {
$core->error->add($e->getMessage());
dcCore::app()->error->add($e->getMessage());
}
return false;

View File

@ -14,30 +14,28 @@ if (!defined('DC_RC_PATH')) {
return null;
}
$d = dirname(__FILE__) . '/inc/';
Clearbricks::lib()->autoload(['cinecturlink2' => __DIR__ . '/inc/class.cinecturlink2.php']);
Clearbricks::lib()->autoload(['cinecturlink2Context' => __DIR__ . '/inc/lib.cinecturlink2.context.php']);
Clearbricks::lib()->autoload(['adminlistCinecturlink2' => __DIR__ . '/inc/lib.cinecturlink2.list.php']);
Clearbricks::lib()->autoload(['sitemapsCinecturlink2' => __DIR__ . '/inc/lib.sitemaps.cinecturlink2.php']);
Clearbricks::lib()->autoload(['cinecturlink2ActivityReportBehaviors' => __DIR__ . '/inc/lib.cinecturlink2.activityreport.php']);
$__autoload['cinecturlink2'] = $d . 'class.cinecturlink2.php';
$__autoload['cinecturlink2Context'] = $d . 'lib.cinecturlink2.context.php';
$__autoload['adminlistCinecturlink2'] = $d . 'lib.cinecturlink2.list.php';
$__autoload['sitemapsCinecturlink2'] = $d . 'lib.sitemaps.cinecturlink2.php';
$__autoload['cinecturlink2ActivityReportBehaviors'] = $d . 'lib.cinecturlink2.activityreport.php';
$core->url->register(
dcCore::app()->url->register(
'cinecturlink2',
'cinecturlink',
'^cinecturlink(?:/(.+))?$',
['urlCinecturlink2', 'c2Page']
);
$core->addBehavior(
dcCore::app()->addBehavior(
'sitemapsDefineParts',
['sitemapsCinecturlink2', 'sitemapsDefineParts']
);
$core->addBehavior(
dcCore::app()->addBehavior(
'sitemapsURLsCollect',
['sitemapsCinecturlink2', 'sitemapsURLsCollect']
);
if (defined('ACTIVITY_REPORT')) {
cinecturlink2ActivityReportBehaviors::add($core);
cinecturlink2ActivityReportBehaviors::add();
}

View File

@ -14,9 +14,9 @@ if (!defined('DC_RC_PATH')) {
return null;
}
require_once dirname(__FILE__) . '/_widgets.php';
require_once __DIR__ . '/_widgets.php';
$core->blog->settings->addNamespace('cinecturlink2');
dcCore::app()->blog->settings->addNamespace('cinecturlink2');
$c2_tpl_values = [
'c2PageFeedID',
@ -56,7 +56,7 @@ $c2_tpl_values = [
'c2CategoryID',
'c2CategoryTitle',
'c2CategoryDescription',
'c2CategoryURL'
'c2CategoryURL',
];
$c2_tpl_blocks = [
@ -73,19 +73,19 @@ $c2_tpl_blocks = [
'c2Categories',
'c2CategoriesHeader',
'c2CategoriesFooter',
'c2CategoryIf'
'c2CategoryIf',
];
if ($core->blog->settings->cinecturlink2->cinecturlink2_active) {
if (dcCore::app()->blog->settings->cinecturlink2->cinecturlink2_active) {
foreach ($c2_tpl_blocks as $v) {
$core->tpl->addBlock($v, ['tplCinecturlink2', $v]);
dcCore::app()->tpl->addBlock($v, ['tplCinecturlink2', $v]);
}
foreach ($c2_tpl_values as $v) {
$core->tpl->addValue($v, ['tplCinecturlink2', $v]);
dcCore::app()->tpl->addValue($v, ['tplCinecturlink2', $v]);
}
} else {
foreach (array_merge($c2_tpl_blocks, $c2_tpl_values) as $v) {
$core->tpl->addBlock($v, ['tplCinecturlink2', 'disable']);
dcCore::app()->tpl->addBlock($v, ['tplCinecturlink2', 'disable']);
}
}
@ -93,19 +93,19 @@ class urlCinecturlink2 extends dcUrlHandlers
{
public static function c2Page($args)
{
global $core, $_ctx;
$core->blog->settings->addNamespace('cinecturlink2');
dcCore::app()->blog->settings->addNamespace('cinecturlink2');
$args = (string) $args;
if (!$core->blog->settings->cinecturlink2->cinecturlink2_active
|| !$core->blog->settings->cinecturlink2->cinecturlink2_public_active) {
if (!dcCore::app()->blog->settings->cinecturlink2->cinecturlink2_active
|| !dcCore::app()->blog->settings->cinecturlink2->cinecturlink2_public_active) {
self::p404();
return null;
}
$core->tpl->setPath(
$core->tpl->getPath(),
dirname(__FILE__) . '/default-templates/'
dcCore::app()->tpl->setPath(
dcCore::app()->tpl->getPath(),
__DIR__ . '/default-templates/'
);
$params = [];
@ -115,7 +115,7 @@ class urlCinecturlink2 extends dcUrlHandlers
$GLOBALS['c2_page_number'] = $n;
}
$caturl = $core->blog->settings->cinecturlink2->cinecturlink2_public_caturl;
$caturl = dcCore::app()->blog->settings->cinecturlink2->cinecturlink2_public_caturl;
if (!$caturl) {
$caturl = 'c2cat';
}
@ -133,12 +133,12 @@ class urlCinecturlink2 extends dcUrlHandlers
if ($f && in_array($f, ['atom', 'rss2'])) {
$mime = $f == 'atom' ? 'application/atom+xml' : 'application/xml';
//$_ctx->short_feed_items = $core->blog->settings->system->short_feed_items;
//dcCore::app()->ctx->short_feed_items = dcCore::app()->blog->settings->system->short_feed_items;
$params['limit'] = $core->blog->settings->system->nb_post_per_feed;
$_ctx->c2_page_params = $params;
$params['limit'] = dcCore::app()->blog->settings->system->nb_post_per_feed;
dcCore::app()->ctx->c2_page_params = $params;
header('X-Robots-Tag: ' . context::robotsPolicy($core->blog->settings->system->robots_policy, ''));
header('X-Robots-Tag: ' . context::robotsPolicy(dcCore::app()->blog->settings->system->robots_policy, ''));
self::serveDocument('cinecturlink2-' . $f . '.xml', $mime);
} else {
$d = self::getPageArgs($args, 'c2detail');
@ -150,8 +150,8 @@ class urlCinecturlink2 extends dcUrlHandlers
}
}
$params['limit'] = $core->blog->settings->cinecturlink2->cinecturlink2_public_nbrpp;
$_ctx->c2_page_params = $params;
$params['limit'] = dcCore::app()->blog->settings->cinecturlink2->cinecturlink2_public_nbrpp;
dcCore::app()->ctx->c2_page_params = $params;
self::serveDocument('cinecturlink2.html', 'text/html');
}
@ -180,27 +180,27 @@ class tplCinecturlink2
public static function c2PageURL($a)
{
return '<?php echo ' . sprintf($GLOBALS['core']->tpl->getFilters($a), '$core->blog->url.$core->url->getBase(\'cinecturlink2\')') . '; ?>';
return '<?php echo ' . sprintf(dcCore::app()->tpl->getFilters($a), 'dcCore::app()->blog->url.dcCore::app()->url->getBase(\'cinecturlink2\')') . '; ?>';
}
public static function c2PageTitle($a)
{
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') . '; ?>';
return "<?php \$title = (string) dcCore::app()->blog->settings->cinecturlink2->cinecturlink2_public_title; if (empty(\$title)) { \$title = __('My cinecturlink'); } echo " . sprintf(dcCore::app()->tpl->getFilters($a), '$title') . '; ?>';
}
public static function c2PageFeedURL($a)
{
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') . '"') . '; ?>';
return '<?php echo ' . sprintf(dcCore::app()->tpl->getFilters($a), 'dcCore::app()->blog->url.dcCore::app()->url->getBase("cinecturlink2")."/feed/' . (!empty($a['type']) && preg_match('#^(rss2|atom)$#', $a['type']) ? $a['type'] : 'atom') . '"') . '; ?>';
}
public static function c2PageFeedID($a)
{
return 'urn:md5:<?php echo md5($core->blog->id."cinecturlink2"); ?>';
return 'urn:md5:<?php echo md5(dcCore::app()->blog->id."cinecturlink2"); ?>';
}
public static function c2PageDescription($a)
{
return '<?php $description = (string) $core->blog->settings->cinecturlink2->cinecturlink2_public_description; echo ' . sprintf($GLOBALS['core']->tpl->getFilters($a), '$description') . '; ?>';
return '<?php $description = (string) dcCore::app()->blog->settings->cinecturlink2->cinecturlink2_public_description; echo ' . sprintf(dcCore::app()->tpl->getFilters($a), '$description') . '; ?>';
}
public static function c2If($a, $c)
@ -211,12 +211,12 @@ class tplCinecturlink2
if (isset($a['request_link'])) {
$sign = (bool) $a['request_link'] ? '' : '!';
$if[] = $sign . '(isset($_ctx->c2_page_params["link_id"]) || isset($_ctx->c2_page_params["link_title"]))';
$if[] = $sign . '(isset(dcCore::app()->ctx->c2_page_params["link_id"]) || isset(dcCore::app()->ctx->c2_page_params["link_title"]))';
}
if (isset($a['request_cat'])) {
$sign = (bool) $a['request_cat'] ? '' : '!';
$if[] = $sign . '(isset($_ctx->c2_page_params["cat_id"]) || isset($_ctx->c2_page_params["cat_title"]))';
$if[] = $sign . '(isset(dcCore::app()->ctx->c2_page_params["cat_id"]) || isset(dcCore::app()->ctx->c2_page_params["cat_title"]))';
}
return empty($if) ? $c : '<?php if(' . implode(' ' . $operator . ' ', $if) . ") : ?>\n" . $c . "<?php endif; ?>\n";
@ -258,24 +258,24 @@ class tplCinecturlink2
return
"<?php \n" .
"\$params = is_array(\$_ctx->c2_page_params) ? \$_ctx->c2_page_params : array(); \n" .
"\$params = is_array(dcCore::app()->ctx->c2_page_params) ? dcCore::app()->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" .
"dcCore::app()->ctx->c2_params = \$params; unset(\$params);\n" .
"if (!dcCore::app()->ctx->exists('cinecturlink')) { dcCore::app()->ctx->cinecturlink = new cinecturlink2(); } \n" .
"dcCore::app()->ctx->c2_entries = dcCore::app()->ctx->cinecturlink->getLinks(dcCore::app()->ctx->c2_params); \n" .
'while (dcCore::app()->ctx->c2_entries->fetch()) : ?>' . $c . '<?php endwhile; ' . "\n" .
"dcCore::app()->ctx->pop('c2_entries'); dcCore::app()->ctx->pop('c2_params'); \n" .
"?>\n";
}
public static function c2EntriesHeader($a, $c)
{
return '<?php if ($_ctx->c2_entries->isStart()) : ?>' . $c . '<?php endif; ?>';
return '<?php if (dcCore::app()->ctx->c2_entries->isStart()) : ?>' . $c . '<?php endif; ?>';
}
public static function c2EntriesFooter($a, $c)
{
return '<?php if ($_ctx->c2_entries->isEnd()) : ?>' . $c . '<?php endif; ?>';
return '<?php if (dcCore::app()->ctx->c2_entries->isEnd()) : ?>' . $c . '<?php endif; ?>';
}
public static function c2EntryIf($a, $c)
@ -286,7 +286,7 @@ class tplCinecturlink2
if (isset($a['has_category'])) {
$sign = (bool) $a['has_category'] ? '!' : '=';
$if[] = '($_ctx->exists("c2_entries") && "" ' . $sign . '= $_ctx->c2_entries->cat_title)';
$if[] = '(dcCore::app()->ctx->exists("c2_entries") && "" ' . $sign . '= dcCore::app()->ctx->c2_entries->cat_title)';
}
return empty($if) ? $c : '<?php if(' . implode(' ' . $operator . ' ', $if) . ") : ?>\n" . $c . "<?php endif; ?>\n";
@ -294,106 +294,105 @@ class tplCinecturlink2
public static function c2EntryIfFirst($a)
{
return '<?php if ($_ctx->c2_entries->index() == 0) { echo "' . (isset($a['return']) ? addslashes(html::escapeHTML($a['return'])) : 'first') . '"; } ?>';
return '<?php if (dcCore::app()->ctx->c2_entries->index() == 0) { echo "' . (isset($a['return']) ? addslashes(html::escapeHTML($a['return'])) : 'first') . '"; } ?>';
}
public static function c2EntryIfOdd($a)
{
return '<?php if (($_ctx->c2_entries->index()+1)%2 == 1) { echo "' . (isset($a['return']) ? addslashes(html::escapeHTML($a['return'])) : 'odd') . '"; } ?>';
return '<?php if ((dcCore::app()->ctx->c2_entries->index()+1)%2 == 1) { echo "' . (isset($a['return']) ? addslashes(html::escapeHTML($a['return'])) : 'odd') . '"; } ?>';
}
public static function c2EntryFeedID($a)
{
return 'urn:md5:<?php echo md5($_ctx->c2_entries->blog_id.$_ctx->c2_entries->link_id.$_ctx->c2_entries->link_creadt); ?>';
return 'urn:md5:<?php echo md5(dcCore::app()->ctx->c2_entries->blog_id.dcCore::app()->ctx->c2_entries->link_id.dcCore::app()->ctx->c2_entries->link_creadt); ?>';
}
public static function c2EntryID($a)
{
return self::getGenericValue('$_ctx->c2_entries->link_id', $a);
return self::getGenericValue('dcCore::app()->ctx->c2_entries->link_id', $a);
}
public static function c2EntryTitle($a)
{
return self::getGenericValue('$_ctx->c2_entries->link_title', $a);
return self::getGenericValue('dcCore::app()->ctx->c2_entries->link_title', $a);
}
public static function c2EntryDescription($a)
{
return self::getGenericValue('$_ctx->c2_entries->link_desc', $a);
return self::getGenericValue('dcCore::app()->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);
return self::getGenericValue('dcUtils::getUserCN(dcCore::app()->ctx->c2_entries->user_id,dcCore::app()->ctx->c2_entries->user_name,dcCore::app()->ctx->c2_entries->user_firstname,dcCore::app()->ctx->c2_entries->user_displayname)', $a);
}
public static function c2EntryAuthorDisplayName($a)
{
return self::getGenericValue('$_ctx->c2_entries->user_displayname', $a);
return self::getGenericValue('dcCore::app()->ctx->c2_entries->user_displayname', $a);
}
public static function c2EntryAuthorID($a)
{
return self::getGenericValue('$_ctx->c2_entries->user_id', $a);
return self::getGenericValue('dcCore::app()->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);
return self::getGenericValue((isset($a['spam_protected']) && !$a['spam_protected'] ? 'dcCore::app()->ctx->c2_entries->user_email' : "strtr(dcCore::app()->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);
return self::getGenericValue('sprintf((dcCore::app()->ctx->c2_entries->user_url ? \'<a href="%2$s">%1$s</a>\' : \'%1$s\'),html::escapeHTML(dcUtils::getUserCN(dcCore::app()->ctx->c2_entries->user_id,dcCore::app()->ctx->c2_entries->user_name,dcCore::app()->ctx->c2_entries->user_firstname,dcCore::app()->ctx->c2_entries->user_displayname)),html::escapeHTML(dcCore::app()->ctx->c2_entries->user_url))', $a);
}
public static function c2EntryAuthorURL($a)
{
return self::getGenericValue('$_ctx->c2_entries->user_url', $a);
return self::getGenericValue('dcCore::app()->ctx->c2_entries->user_url', $a);
}
public static function c2EntryFromAuthor($a)
{
return self::getGenericValue('$_ctx->c2_entries->link_author', $a);
return self::getGenericValue('dcCore::app()->ctx->c2_entries->link_author', $a);
}
public static function c2EntryLang($a)
{
return self::getGenericValue('$_ctx->c2_entries->link_lang', $a);
return self::getGenericValue('dcCore::app()->ctx->c2_entries->link_lang', $a);
}
public static function c2EntryURL($a)
{
return self::getGenericValue('$_ctx->c2_entries->link_url', $a);
return self::getGenericValue('dcCore::app()->ctx->c2_entries->link_url', $a);
}
public static function c2EntryCategory($a)
{
return self::getGenericValue('$_ctx->c2_entries->cat_title', $a);
return self::getGenericValue('dcCore::app()->ctx->c2_entries->cat_title', $a);
}
public static function c2EntryCategoryID($a)
{
return self::getGenericValue('$_ctx->c2_entries->cat_id', $a);
return self::getGenericValue('dcCore::app()->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);
return self::getGenericValue('dcCore::app()->blog->url.dcCore::app()->url->getBase("cinecturlink2")."/".dcCore::app()->blog->settings->cinecturlink2->cinecturlink2_public_caturl."/".urlencode(dcCore::app()->ctx->c2_entries->cat_title)', $a);
}
public static function c2EntryImg($a)
{
global $core;
$f = $core->tpl->getFilters($a);
$f = dcCore::app()->tpl->getFilters($a);
$style = isset($a['style']) ? html::escapeHTML($a['style']) : '';
return
"<?php if (\$_ctx->exists('c2_entries')) { " .
'$widthmax = (integer) $core->blog->settings->cinecturlink2->cinecturlink2_widthmax; ' .
"<?php if (dcCore::app()->ctx->exists('c2_entries')) { " .
'$widthmax = (integer) dcCore::app()->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), " .
'dcCore::app()->ctx->c2_entries->link_img, ' .
"html::escapeHTML(dcCore::app()->ctx->c2_entries->link_title.' - '.dcCore::app()->ctx->c2_entries->link_author), " .
"(\$widthmax ? ' style=\"width:'.\$widthmax.'px;$style\"' : '') " .
'); ' .
'echo ' . sprintf($f, '$img') . "; unset(\$img); } ?> \n";
@ -404,13 +403,13 @@ class tplCinecturlink2
$format = !empty($a['format']) ? addslashes($a['format']) : '';
if (!empty($a['rfc822'])) {
$p = 'dt::rfc822(strtotime($_ctx->c2_entries->link_creadt), $core->blog->settings->system->blog_timezone)';
$p = 'dt::rfc822(strtotime(dcCore::app()->ctx->c2_entries->link_creadt), dcCore::app()->blog->settings->system->blog_timezone)';
} elseif (!empty($a['iso8601'])) {
$p = 'dt::iso8601(strtotime($_ctx->c2_entries->link_creadt), $core->blog->settings->system->blog_timezone)';
$p = 'dt::iso8601(strtotime(dcCore::app()->ctx->c2_entries->link_creadt), dcCore::app()->blog->settings->system->blog_timezone)';
} elseif ($format) {
$p = "dt::dt2str('" . $format . "', \$_ctx->c2_entries->link_creadt)";
$p = "dt::dt2str('" . $format . "', dcCore::app()->ctx->c2_entries->link_creadt)";
} else {
$p = 'dt::dt2str($core->blog->settings->system->date_format, $_ctx->c2_entries->link_creadt)';
$p = 'dt::dt2str(dcCore::app()->blog->settings->system->date_format, dcCore::app()->ctx->c2_entries->link_creadt)';
}
return self::getGenericValue($p, $a);
@ -418,17 +417,17 @@ class tplCinecturlink2
public static function c2EntryTime($a)
{
return self::getGenericValue('dt::dt2str(' . (!empty($a['format']) ? "'" . addslashes($a['format']) . "'" : '$core->blog->settings->system->time_format') . ', $_ctx->c2_entries->link_creadt)', $a);
return self::getGenericValue('dt::dt2str(' . (!empty($a['format']) ? "'" . addslashes($a['format']) . "'" : 'dcCore::app()->blog->settings->system->time_format') . ', dcCore::app()->ctx->c2_entries->link_creadt)', $a);
}
public static function c2Pagination($a, $c)
{
$p = "<?php\n" .
"\$params = \$_ctx->c2_params;\n" .
"\$_ctx->c2_pagination = \$_ctx->cinecturlink->getLinks(\$params,true); unset(\$params);\n" .
"\$params = dcCore::app()->ctx->c2_params;\n" .
"dcCore::app()->ctx->c2_pagination = dcCore::app()->ctx->cinecturlink->getLinks(\$params,true); unset(\$params);\n" .
"?>\n";
return isset($a['no_context']) ? $p . $c : $p . '<?php if ($_ctx->c2_pagination->f(0) > $_ctx->c2_entries->count()) : ?>' . $c . '<?php endif; ?>';
return isset($a['no_context']) ? $p . $c : $p . '<?php if (dcCore::app()->ctx->c2_pagination->f(0) > dcCore::app()->ctx->c2_entries->count()) : ?>' . $c . '<?php endif; ?>';
}
public static function c2PaginationCounter($a)
@ -466,21 +465,21 @@ class tplCinecturlink2
{
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" .
"if (!dcCore::app()->ctx->exists('cinecturlink')) { dcCore::app()->ctx->cinecturlink = new cinecturlink2(); } \n" .
"dcCore::app()->ctx->c2_categories = dcCore::app()->ctx->cinecturlink->getCategories(); \n" .
'while (dcCore::app()->ctx->c2_categories->fetch()) : ?>' . $c . '<?php endwhile; ' . "\n" .
"dcCore::app()->ctx->c2_categories = null; \n" .
"?>\n";
}
public static function c2CategoriesHeader($a, $c)
{
return '<?php if ($_ctx->c2_categories->isStart()) : ?>' . $c . '<?php endif; ?>';
return '<?php if (dcCore::app()->ctx->c2_categories->isStart()) : ?>' . $c . '<?php endif; ?>';
}
public static function c2CategoriesFooter($a, $c)
{
return '<?php if ($_ctx->c2_categories->isEnd()) : ?>' . $c . '<?php endif; ?>';
return '<?php if (dcCore::app()->ctx->c2_categories->isEnd()) : ?>' . $c . '<?php endif; ?>';
}
public static function c2CategoryIf($a, $c)
@ -493,7 +492,7 @@ class tplCinecturlink2
}
if (isset($a['first'])) {
$sign = (bool) $a['first'] ? '' : '!';
$if[] = $sign . '$_ctx->c2_categories->isStart()';
$if[] = $sign . 'dcCore::app()->ctx->c2_categories->isStart()';
}
return empty($if) ? $c : '<?php if(' . implode(' && ', $if) . ') : ?>' . $c . '<?php endif; ?>';
@ -507,37 +506,37 @@ class tplCinecturlink2
$p = 'atom';
}
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 . '"') . '; ?>';
return '<?php echo ' . sprintf(dcCore::app()->tpl->getFilters($a), 'dcCore::app()->blog->url.dcCore::app()->url->getBase("cinecturlink2")."/".dcCore::app()->blog->settings->cinecturlink2->cinecturlink2_public_caturl."/".urlencode(dcCore::app()->ctx->c2_categories->cat_title)."/feed/' . $p . '"') . '; ?>';
}
public static function c2CategoryFeedID($a)
{
return 'urn:md5:<?php echo md5($core->blog->id."cinecturlink2".$_ctx->c2_categories->cat_id); ?>';
return 'urn:md5:<?php echo md5(dcCore::app()->blog->id."cinecturlink2".dcCore::app()->ctx->c2_categories->cat_id); ?>';
}
public static function c2CategoryID($a)
{
return "<?php if (\$_ctx->exists('c2_categories')) { echo " . sprintf($GLOBALS['core']->tpl->getFilters($a), '$_ctx->c2_categories->cat_id') . '; } ?>';
return "<?php if (dcCore::app()->ctx->exists('c2_categories')) { echo " . sprintf(dcCore::app()->tpl->getFilters($a), 'dcCore::app()->ctx->c2_categories->cat_id') . '; } ?>';
}
public static function c2CategoryTitle($a)
{
return "<?php if (\$_ctx->exists('c2_categories')) { echo " . sprintf($GLOBALS['core']->tpl->getFilters($a), '$_ctx->c2_categories->cat_title') . '; } ?>';
return "<?php if (dcCore::app()->ctx->exists('c2_categories')) { echo " . sprintf(dcCore::app()->tpl->getFilters($a), 'dcCore::app()->ctx->c2_categories->cat_title') . '; } ?>';
}
public static function c2CategoryDescription($a)
{
return "<?php if (\$_ctx->exists('c2_categories')) { echo " . sprintf($GLOBALS['core']->tpl->getFilters($a), '$_ctx->c2_categories->cat_desc') . '; } ?>';
return "<?php if (dcCore::app()->ctx->exists('c2_categories')) { echo " . sprintf(dcCore::app()->tpl->getFilters($a), 'dcCore::app()->ctx->c2_categories->cat_desc') . '; } ?>';
}
public static function c2CategoryURL($a)
{
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)') . '; } ?>';
return "<?php if (dcCore::app()->ctx->exists('c2_categories')) { echo " . sprintf(dcCore::app()->tpl->getFilters($a), 'dcCore::app()->blog->url.dcCore::app()->url->getBase("cinecturlink2")."/".dcCore::app()->blog->settings->cinecturlink2->cinecturlink2_public_caturl."/".urlencode(dcCore::app()->ctx->c2_categories->cat_title)') . '; } ?>';
}
protected static function getGenericValue($p, $a)
{
return "<?php if (\$_ctx->exists('c2_entries')) { echo " . sprintf($GLOBALS['core']->tpl->getFilters($a), "$p") . '; } ?>';
return "<?php if (dcCore::app()->ctx->exists('c2_entries')) { echo " . sprintf(dcCore::app()->tpl->getFilters($a), "$p") . '; } ?>';
}
protected static function getOperator($op)

View File

@ -14,11 +14,11 @@ if (!defined('DC_RC_PATH')) {
return null;
}
$core->addBehavior(
dcCore::app()->addBehavior(
'initWidgets',
['cinecturlink2Widget', 'adminLinks']
);
$core->addBehavior(
dcCore::app()->addBehavior(
'initWidgets',
['cinecturlink2Widget', 'adminCats']
);
@ -27,9 +27,7 @@ class cinecturlink2Widget
{
public static function adminLinks($w)
{
global $core;
$C2 = new cinecturlink2($core);
$C2 = new cinecturlink2();
$categories_combo = ['' => '', __('Uncategorized') => 'null'];
$categories = $C2->getCategories();
@ -43,11 +41,11 @@ class cinecturlink2Widget
__('My rating') => 'link_note',
__('Title') => 'link_title',
__('Random') => 'RANDOM',
__('Number of views') => 'COUNTER'
__('Number of views') => 'COUNTER',
];
$order_combo = [
__('Ascending') => 'asc',
__('Descending') => 'desc'
__('Descending') => 'desc',
];
$w
@ -157,18 +155,16 @@ class cinecturlink2Widget
public static function publicLinks($w)
{
global $core;
dcCore::app()->blog->settings->addNamespace('cinecturlink2');
$core->blog->settings->addNamespace('cinecturlink2');
if (!$core->blog->settings->cinecturlink2->cinecturlink2_active
|| $w->homeonly == 1 && !$core->url->isHome($core->url->type)
|| $w->homeonly == 2 && $core->url->isHome($core->url->type)
if (!dcCore::app()->blog->settings->cinecturlink2->cinecturlink2_active
|| $w->homeonly == 1 && !dcCore::app()->url->isHome(dcCore::app()->url->type)
|| $w->homeonly == 2 && dcCore::app()->url->isHome(dcCore::app()->url->type)
) {
return null;
}
$C2 = new cinecturlink2($core);
$C2 = new cinecturlink2();
if ($w->category) {
if ($w->category == 'null') {
@ -214,7 +210,7 @@ class cinecturlink2Widget
return null;
}
$widthmax = (int) $core->blog->settings->cinecturlink2->cinecturlink2_widthmax;
$widthmax = (int) dcCore::app()->blog->settings->cinecturlink2->cinecturlink2_widthmax;
$style = $widthmax ? ' style="width:' . $widthmax . 'px;"' : '';
$entries = [];
@ -230,7 +226,7 @@ class cinecturlink2Widget
$count = abs((int) $rs->link_count);
# --BEHAVIOR-- cinecturlink2WidgetLinks
$bhv = $core->callBehavior('cinecturlink2WidgetLinks', $rs->link_id);
$bhv = dcCore::app()->callBehavior('cinecturlink2WidgetLinks', $rs->link_id);
$entries[] = '<p style="text-align:center;">' .
($w->withlink && !empty($url) ? '<a href="' . $url . '"' . $lang . ' title="' . $cat . '">' : '') .
@ -242,7 +238,7 @@ class cinecturlink2Widget
'</p>' . $bhv;
try {
$cur = $core->con->openCursor($C2->table);
$cur = dcCore::app()->con->openCursor($C2->table);
$cur->link_count = ($count + 1);
$C2->updLink($rs->link_id, $cur, false);
} catch (Exception $e) {
@ -253,8 +249,8 @@ class cinecturlink2Widget
|| $w->sortby == 'COUNTER'
) {
shuffle($entries);
if ($core->blog->settings->cinecturlink2->cinecturlink2_triggeronrandom) {
$core->blog->triggerBlog();
if (dcCore::app()->blog->settings->cinecturlink2->cinecturlink2_triggeronrandom) {
dcCore::app()->blog->triggerBlog();
}
}
@ -264,27 +260,25 @@ class cinecturlink2Widget
'',
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') . implode(' ', $entries) .
(
$w->showpagelink && $core->blog->settings->cinecturlink2->cinecturlink2_public_active ?
'<p><a href="' . $core->blog->url . $core->url->getBase('cinecturlink2') . '" title="' . __('view all links') . '">' . __('More links') . '</a></p>' : ''
$w->showpagelink && dcCore::app()->blog->settings->cinecturlink2->cinecturlink2_public_active ?
'<p><a href="' . dcCore::app()->blog->url . dcCore::app()->url->getBase('cinecturlink2') . '" title="' . __('view all links') . '">' . __('More links') . '</a></p>' : ''
)
);
}
public static function publicCats($w)
{
global $core;
dcCore::app()->blog->settings->addNamespace('cinecturlink2');
$core->blog->settings->addNamespace('cinecturlink2');
if (!$core->blog->settings->cinecturlink2->cinecturlink2_active
|| !$core->blog->settings->cinecturlink2->cinecturlink2_public_active
|| $w->homeonly == 1 && !$core->url->isHome($core->url->type)
|| $w->homeonly == 2 && $core->url->isHome($core->url->type)
if (!dcCore::app()->blog->settings->cinecturlink2->cinecturlink2_active
|| !dcCore::app()->blog->settings->cinecturlink2->cinecturlink2_public_active
|| $w->homeonly == 1 && !dcCore::app()->url->isHome(dcCore::app()->url->type)
|| $w->homeonly == 2 && dcCore::app()->url->isHome(dcCore::app()->url->type)
) {
return null;
}
$C2 = new cinecturlink2($core);
$C2 = new cinecturlink2();
$rs = $C2->getCategories([]);
if ($rs->isEmpty()) {
return null;
@ -292,15 +286,15 @@ class cinecturlink2Widget
$res = [];
$res[] = '<li><a href="' .
$core->blog->url . $core->url->getBase('cinecturlink2') .
dcCore::app()->blog->url . dcCore::app()->url->getBase('cinecturlink2') .
'" title="' . __('view all links') . '">' . __('all links') .
'</a>' . ($w->shownumlink ? ' (' . ($C2->getLinks([], true)->f(0)) . ')' : '') .
'</li>';
while ($rs->fetch()) {
$res[] = '<li><a href="' .
$core->blog->url . $core->url->getBase('cinecturlink2') . '/' .
$core->blog->settings->cinecturlink2->cinecturlink2_public_caturl . '/' .
dcCore::app()->blog->url . dcCore::app()->url->getBase('cinecturlink2') . '/' .
dcCore::app()->blog->settings->cinecturlink2->cinecturlink2_public_caturl . '/' .
urlencode($rs->cat_title) .
'" title="' . __('view links of this category') . '">' .
html::escapeHTML($rs->cat_title) .

View File

@ -21,8 +21,6 @@ if (!defined('DC_RC_PATH')) {
*/
class cinecturlink2
{
/** @var dcCore dcCore instance */
public $core;
/** @var dbLayer dbLayer instance */
public $con;
/** @var string Cinecturlink table name */
@ -32,17 +30,14 @@ class cinecturlink2
/**
* Contructor
*
* @param dcCore $core dcCore instance
*/
public function __construct(dcCore $core)
public function __construct()
{
$core->blog->settings->addNamespace('cinecturlink2');
dcCore::app()->blog->settings->addNamespace('cinecturlink2');
$this->core = $core;
$this->con = $core->con;
$this->table = $core->prefix . 'cinecturlink2';
$this->blog = $core->con->escape($core->blog->id);
$this->con = dcCore::app()->con;
$this->table = dcCore::app()->prefix . 'cinecturlink2';
$this->blog = dcCore::app()->con->escape(dcCore::app()->blog->id);
}
/**
@ -73,7 +68,7 @@ class cinecturlink2
}
$strReq .= 'FROM ' . $this->table . ' L ' .
'INNER JOIN ' . $this->core->prefix . 'user U ON U.user_id = L.user_id ' .
'INNER JOIN ' . dcCore::app()->prefix . 'user U ON U.user_id = L.user_id ' .
'LEFT OUTER JOIN ' . $this->table . '_cat C ON L.cat_id = C.cat_id ';
if (!empty($params['from'])) {
@ -103,7 +98,9 @@ class cinecturlink2
if (!empty($params['cat_id'])) {
if (is_array($params['cat_id'])) {
array_walk($params['cat_id'], function (&$v, $k) { if ($v !== null) { $v = (int) $v;}});
array_walk($params['cat_id'], function (&$v, $k) { if ($v !== null) {
$v = (int) $v;
}});
} else {
$params['cat_id'] = [(int) $params['cat_id']];
}
@ -174,7 +171,7 @@ class cinecturlink2
$cur->link_id = $this->getNextLinkId();
$cur->blog_id = $this->blog;
$cur->user_id = $this->core->auth->userID();
$cur->user_id = dcCore::app()->auth->userID();
$cur->link_creadt = date('Y-m-d H:i:s');
$cur->link_upddt = date('Y-m-d H:i:s');
$cur->link_pos = 0;
@ -189,7 +186,7 @@ class cinecturlink2
$this->trigger();
# --BEHAVIOR-- cinecturlink2AfterAddLink
$this->core->callBehavior('cinecturlink2AfterAddLink', $cur);
dcCore::app()->callBehavior('cinecturlink2AfterAddLink', $cur);
return $cur->link_id;
}
@ -216,7 +213,7 @@ class cinecturlink2
if ($behavior) {
# --BEHAVIOR-- cinecturlink2AfterUpdLink
$this->core->callBehavior('cinecturlink2AfterUpdLink', $cur, $id);
dcCore::app()->callBehavior('cinecturlink2AfterUpdLink', $cur, $id);
}
}
@ -234,7 +231,7 @@ class cinecturlink2
}
# --BEHAVIOR-- cinecturlink2BeforeDelLink
$this->core->callBehavior('cinecturlink2BeforeDelLink', $id);
dcCore::app()->callBehavior('cinecturlink2BeforeDelLink', $id);
$this->con->execute(
'DELETE FROM ' . $this->table . ' ' .
@ -289,7 +286,9 @@ class cinecturlink2
if (!empty($params['cat_id'])) {
if (is_array($params['cat_id'])) {
array_walk($params['cat_id'], function (&$v, $k) { if ($v !== null) { $v = (int) $v; }});
array_walk($params['cat_id'], function (&$v, $k) { if ($v !== null) {
$v = (int) $v;
}});
} else {
$params['cat_id'] = [(int) $params['cat_id']];
}
@ -298,7 +297,9 @@ class cinecturlink2
if (isset($params['exclude_cat_id']) && $params['exclude_cat_id'] !== '') {
if (is_array($params['exclude_cat_id'])) {
array_walk($params['exclude_cat_id'], function (&$v, $k) { if ($v !== null) {$v = (int) $v;}});
array_walk($params['exclude_cat_id'], function (&$v, $k) { if ($v !== null) {
$v = (int) $v;
}});
} else {
$params['exclude_cat_id'] = [(int) $params['exclude_cat_id']];
}
@ -441,7 +442,7 @@ class cinecturlink2
*/
private function trigger()
{
$this->core->blog->triggerBlog();
dcCore::app()->blog->triggerBlog();
}
/**
@ -470,15 +471,14 @@ class cinecturlink2
/**
* Get list of public directories
*
* @param dcCore $core Core instance
* @return array Directories
*/
public static function getPublicDirs($core)
public static function getPublicDirs()
{
$dirs = [];
$all = files::getDirList($core->blog->public_path);
$all = files::getDirList(dcCore::app()->blog->public_path);
foreach ($all['dirs'] as $dir) {
$dir = substr($dir, strlen($core->blog->public_path) + 1);
$dir = substr($dir, strlen(dcCore::app()->blog->public_path) + 1);
$dirs[$dir] = $dir;
}

View File

@ -16,12 +16,12 @@ if (!defined('DC_RC_PATH')) {
class cinecturlink2ActivityReportBehaviors
{
public static function add($core)
public static function add()
{
$core->activityReport->addGroup('cinecturlink2', __('Plugin cinecturlink2'));
dcCore::app()->activityReport->addGroup('cinecturlink2', __('Plugin cinecturlink2'));
// from BEHAVIOR cinecturlink2AfterAddLink in cinecturlink2/inc/class.cinecturlink2.php
$core->activityReport->addAction(
dcCore::app()->activityReport->addAction(
'cinecturlink2',
'create',
__('link creation'),
@ -30,7 +30,7 @@ class cinecturlink2ActivityReportBehaviors
['cinecturlink2ActivityReportBehaviors', 'addLink']
);
// from BEHAVIOR cinecturlink2AfterUpdLink in cinecturlink2/inc/class.cinecturlink2.php
$core->activityReport->addAction(
dcCore::app()->activityReport->addAction(
'cinecturlink2',
'update',
__('updating link'),
@ -39,7 +39,7 @@ class cinecturlink2ActivityReportBehaviors
['cinecturlink2ActivityReportBehaviors', 'updLink']
);
// from BEHAVIOR cinecturlink2BeforeDelLink in cinecturlink2/inc/class.cinecturlink2.php
$core->activityReport->addAction(
dcCore::app()->activityReport->addAction(
'cinecturlink2',
'delete',
__('link deletion'),
@ -51,38 +51,34 @@ class cinecturlink2ActivityReportBehaviors
public static function addLink($cur)
{
global $core;
$logs = [
$cur->link_title,
$core->auth->getInfo('user_cn')
dcCore::app()->auth->getInfo('user_cn'),
];
$core->activityReport->addLog('cinecturlink2', 'create', $logs);
dcCore::app()->activityReport->addLog('cinecturlink2', 'create', $logs);
}
public static function updLink($cur, $id)
{
global $core;
$C2 = new cinecturlink2($core);
$C2 = new cinecturlink2();
$rs = $C2->getLinks(['link_id' => $id]);
$logs = [
$rs->link_title,
$core->auth->getInfo('user_cn')
dcCore::app()->auth->getInfo('user_cn'),
];
$core->activityReport->addLog('cinecturlink2', 'update', $logs);
dcCore::app()->activityReport->addLog('cinecturlink2', 'update', $logs);
}
public static function delLink($id)
{
global $core;
$C2 = new cinecturlink2($core);
$C2 = new cinecturlink2();
$rs = $C2->getLinks(['link_id' => $id]);
$logs = [
$rs->link_title,
$core->auth->getInfo('user_cn')
dcCore::app()->auth->getInfo('user_cn'),
];
$core->activityReport->addLog('cinecturlink2', 'delete', $logs);
dcCore::app()->activityReport->addLog('cinecturlink2', 'delete', $logs);
}
}

View File

@ -14,13 +14,11 @@ class cinecturlink2Context
{
public static function PaginationNbPages()
{
global $_ctx;
if ($_ctx->c2_pagination === null) {
if (dcCore::app()->ctx->c2_pagination === null) {
return false;
}
$nb_posts = $_ctx->c2_pagination->f(0);
$nb_per_page = $_ctx->c2_params['limit'][1];
$nb_posts = dcCore::app()->ctx->c2_pagination->f(0);
$nb_per_page = dcCore::app()->ctx->c2_params['limit'][1];
$nb_pages = ceil($nb_posts / $nb_per_page);
return $nb_pages;
@ -68,7 +66,7 @@ class cinecturlink2Context
$args = preg_replace('#(^|/)c2page/([0-9]+)$#', '', $args);
$url = $GLOBALS['core']->blog->url . $args;
$url = dcCore::app()->blog->url . $args;
if ($n > 1) {
$url = preg_replace('#/$#', '', $url);
@ -85,20 +83,18 @@ class cinecturlink2Context
public static function categoryCurrent()
{
global $_ctx;
if (!isset($_ctx->c2_page_params['cat_id'])
&& !isset($_ctx->c2_page_params['cat_title'])
if (!isset(dcCore::app()->ctx->c2_page_params['cat_id'])
&& !isset(dcCore::app()->ctx->c2_page_params['cat_title'])
) {
return false;
}
if (isset($_ctx->c2_page_params['cat_id'])
&& $_ctx->c2_page_params['cat_id'] == $_ctx->c2_categories->cat_id
if (isset(dcCore::app()->ctx->c2_page_params['cat_id'])
&& dcCore::app()->ctx->c2_page_params['cat_id'] == dcCore::app()->ctx->c2_categories->cat_id
) {
return true;
}
if (isset($_ctx->c2_page_params['cat_title'])
&& $_ctx->c2_page_params['cat_title'] == $_ctx->c2_categories->cat_title
if (isset(dcCore::app()->ctx->c2_page_params['cat_title'])
&& dcCore::app()->ctx->c2_page_params['cat_title'] == dcCore::app()->ctx->c2_categories->cat_title
) {
return true;
}

View File

@ -18,15 +18,13 @@ class adminlistCinecturlink2
{
public $redir = '';
protected $core;
protected $rs;
protected $rs_count;
protected $html_prev;
protected $html_next;
public function __construct(dcCore $core, $rs, $rs_count)
public function __construct($rs, $rs_count)
{
$this->core = &$core;
$this->rs = &$rs;
$this->rs_count = $rs_count;
$this->html_prev = __('&#171; prev.');
@ -35,7 +33,7 @@ class adminlistCinecturlink2
public function userColumns($type, $cols)
{
$cols_user = @$this->core->auth->user_prefs->interface->cols;
$cols_user = @dcCore::app()->auth->user_prefs->interface->cols;
if (is_array($cols_user) || $cols_user instanceof ArrayObject) {
if (isset($cols_user[$type])) {
foreach ($cols_user[$type] as $cn => $cd) {
@ -72,7 +70,7 @@ class adminlistCinecturlink2
'link' => '<th scope="col">' . __('Links') . '</th>',
'cat' => '<th scope="col">' . __('Category') . '</th>',
'note' => '<th scope="col">' . __('Rating') . '</th>',
'date' => '<th scope="col">' . __('Date') . '</th>'
'date' => '<th scope="col">' . __('Date') . '</th>',
];
$cols = new ArrayObject($cols);
$this->userColumns('c2link', $cols);
@ -111,7 +109,7 @@ class adminlistCinecturlink2
form::checkbox(['entries[]'], $this->rs->link_id, ['checked' => $checked]) .
'</td>',
'title' => '<td class="nowrap" scope="row">' .
'<a href="' . $this->core->adminurl->get(
'<a href="' . dcCore::app()->adminurl->get(
'admin.plugin.cinecturlink2',
['part' => 'link', 'linkid' => $this->rs->link_id, 'redir' => $this->redir]
) . '" title="' . __('Edit') . '">' .
@ -132,7 +130,7 @@ class adminlistCinecturlink2
'">' . __('image') . '</a> ' .
'</td>',
'cat' => '<td class="nowrap minimal">' .
'<a href="' . $this->core->adminurl->get(
'<a href="' . dcCore::app()->adminurl->get(
'admin.plugin.cinecturlink2',
['part' => 'cat', 'catid' => $this->rs->cat_id, 'redir' => $this->redir]
) . '" title="' . __('Edit') . '">' .
@ -144,11 +142,11 @@ class adminlistCinecturlink2
'</td>',
'date' => '<td class="nowrap count minimal">' .
dt::dt2str(
$this->core->blog->settings->system->date_format . ', ' . $this->core->blog->settings->system->time_format,
dcCore::app()->blog->settings->system->date_format . ', ' . dcCore::app()->blog->settings->system->time_format,
$this->rs->link_upddt,
$this->core->auth->getInfo('user_tz')
dcCore::app()->auth->getInfo('user_tz')
) .
'</td>'
'</td>',
];
$cols = new ArrayObject($cols);

View File

@ -19,23 +19,22 @@ class sitemapsCinecturlink2
public static function sitemapsURLsCollect($sitemaps)
{
global $core;
$core->blog->settings->addNamespace('sitemaps');
dcCore::app()->blog->settings->addNamespace('sitemaps');
if ($core->plugins->moduleExists('cinecturlink2')
&& $core->blog->settings->sitemaps->sitemaps_cinecturlink2_url
if (dcCore::app()->plugins->moduleExists('cinecturlink2')
&& dcCore::app()->blog->settings->sitemaps->sitemaps_cinecturlink2_url
) {
$freq = $sitemaps->getFrequency($core->blog->settings->sitemaps->sitemaps_cinecturlink2_fq);
$prio = $sitemaps->getPriority($core->blog->settings->sitemaps->sitemaps_cinecturlink2_pr);
$base = $core->blog->url . $core->url->getBase('cinecturlink2');
$freq = $sitemaps->getFrequency(dcCore::app()->blog->settings->sitemaps->sitemaps_cinecturlink2_fq);
$prio = $sitemaps->getPriority(dcCore::app()->blog->settings->sitemaps->sitemaps_cinecturlink2_pr);
$base = dcCore::app()->blog->url . dcCore::app()->url->getBase('cinecturlink2');
$sitemaps->addEntry($base, $prio, $freq);
$core->blog->settings->addNamespace('cinecturlink2');
$C2 = new cinecturlink2($core);
dcCore::app()->blog->settings->addNamespace('cinecturlink2');
$C2 = new cinecturlink2();
$cats = $C2->getCategories();
while ($cats->fetch()) {
$sitemaps->addEntry($base . '/' . $core->blog->settings->cinecturlink2->cinecturlink2_public_caturl . '/' . urlencode($cats->cat_title), $prio, $freq);
$sitemaps->addEntry($base . '/' . dcCore::app()->blog->settings->cinecturlink2->cinecturlink2_public_caturl . '/' . urlencode($cats->cat_title), $prio, $freq);
}
}
}

178
index.php
View File

@ -14,7 +14,7 @@ if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
dcPage::check('contentadmin');
dcPage::check(dcAuth::PERMISSION_CONTENT_ADMIN);
$linkid = $_REQUEST['linkid'] ?? '';
$linktitle = $_POST['linktitle'] ?? '';
@ -22,7 +22,7 @@ $linkdesc = $_POST['linkdesc'] ?? '';
$linkauthor = $_POST['linkauthor'] ?? '';
$linkurl = $_POST['linkurl'] ?? '';
$linkcat = $_POST['linkcat'] ?? null;
$linklang = $_POST['linklang'] ?? $core->auth->getInfo('user_lang');
$linklang = $_POST['linklang'] ?? dcCore::app()->auth->getInfo('user_lang');
$linkimage = $_POST['linkimage'] ?? '';
$linknote = $_POST['linknote'] ?? '';
$catid = $_REQUEST['catid'] ?? '';
@ -34,7 +34,7 @@ $entries = $_POST['entries'] ?? [];
$headers = '';
$breadcrumb = [
__('Plugins') => '',
__('My cinecturlink') => $core->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'links'])
__('My cinecturlink') => dcCore::app()->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'links']),
];
if (!in_array($part, ['links', 'link', 'cats', 'cat', 'dellinks', 'updlinksnote', 'updlinkscat'])) {
$part = 'links';
@ -44,7 +44,7 @@ if (!is_array($entries)) {
}
try {
$C2 = new cinecturlink2($core);
$C2 = new cinecturlink2();
$categories = $C2->getCategories();
$categories_combo = ['-' => ''];
while ($categories->fetch()) {
@ -52,7 +52,7 @@ try {
$categories_combo[$cat_title] = $categories->cat_id;
}
} catch (Exception $e) {
$core->error->add($e->getMessage());
dcCore::app()->error->add($e->getMessage());
}
if ($part == 'dellinks') {
@ -62,13 +62,13 @@ if ($part == 'dellinks') {
foreach ($entries as $id) {
$C2->delLink($id);
}
dcPage::addSuccessNotice(
dcAdminNotices::addSuccessNotice(
__('Links successfully deleted.')
);
$core->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'links']);
dcCore::app()->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'links']);
}
} catch (Exception $e) {
$core->error->add($e->getMessage());
dcCore::app()->error->add($e->getMessage());
}
$breadcrumb[__('Delete links')] = '';
}
@ -78,7 +78,7 @@ if (in_array($part, ['updlinksnote', 'updlinkscat'])) {
try {
$links = $C2->getLinks(['link_id' => $entries]);
} catch (Exception $e) {
$core->error->add($e->getMessage());
dcCore::app()->error->add($e->getMessage());
}
}
@ -88,22 +88,22 @@ if ($part == 'updlinksnote') {
if (!empty($entries) && isset($_POST['newlinknote'])) {
while ($links->fetch()) {
if (in_array($links->link_id, $entries)) {
$cur = $core->con->openCursor($C2->table);
$cur = dcCore::app()->con->openCursor($C2->table);
$cur->link_note = (int) $_POST['newlinknote'];
$C2->updLink($links->link_id, $cur);
}
}
dcPage::addSuccessNotice(
dcAdminNotices::addSuccessNotice(
__('Links successfully updated.')
);
if (!empty($_POST['redir'])) {
http::redirect($redir);
} else {
$core->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'links']);
dcCore::app()->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'links']);
}
}
} catch (Exception $e) {
$core->error->add($e->getMessage());
dcCore::app()->error->add($e->getMessage());
}
$breadcrumb[__('Update links rating')] = '';
}
@ -114,22 +114,22 @@ if ($part == 'updlinkscat') {
if (!empty($entries) && !empty($_POST['newcatid'])) {
while ($links->fetch()) {
if (in_array($links->link_id, $entries)) {
$cur = $core->con->openCursor($C2->table);
$cur = dcCore::app()->con->openCursor($C2->table);
$cur->cat_id = (int) $_POST['newcatid'];
$C2->updLink($links->link_id, $cur);
}
}
dcPage::addSuccessNotice(
dcAdminNotices::addSuccessNotice(
__('Links successfully updated.')
);
if (!empty($_POST['redir'])) {
http::redirect($redir);
} else {
$core->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'links']);
dcCore::app()->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'links']);
}
}
} catch (Exception $e) {
$core->error->add($e->getMessage());
dcCore::app()->error->add($e->getMessage());
}
$breadcrumb[__('Update links category')] = '';
}
@ -138,10 +138,10 @@ if ($part == 'links') {
$action_combo = [
__('Delete') => 'dellinks',
__('Change category') => 'updlinkscat',
__('Change rating') => 'updlinksnote'
__('Change rating') => 'updlinksnote',
];
$c2link_filter = new adminGenericFilter($core, 'c2link');
$c2link_filter = new adminGenericFilterV2('c2link');
$c2link_filter->add('part', 'links');
$c2link_filter->add(dcAdminFilters::getPageFilter());
$c2link_filter->add(dcAdminFilters::getSearchFilter());
@ -161,13 +161,13 @@ if ($part == 'links') {
try {
$links = $C2->getLinks($params);
$links_counter = $C2->getLinks($params, true)->f(0);
$links_list = new adminlistCinecturlink2($core, $links, $links_counter);
$links_list = new adminlistCinecturlink2($links, $links_counter);
} catch (Exception $e) {
$core->error->add($e->getMessage());
dcCore::app()->error->add($e->getMessage());
}
$breadcrumb[__('My cinecturlink')] = '';
$headers .= dcPage::jsVars(['dotclear.filter_reset_url' => $core->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'links'])]) .
$headers .= dcPage::jsVars(['dotclear.filter_reset_url' => dcCore::app()->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'links'])]) .
dcPage::jsFilterControl($c2link_filter->show()) .
dcPage::jsLoad(dcPage::getPF('cinecturlink2/js/c2links.js'));
}
@ -179,10 +179,10 @@ if ($part == 'link') {
try {
$allowed_media = ['png', 'jpg', 'gif', 'bmp', 'jpeg'];
$core->media = new dcMedia($core);
$core->media->chdir($core->blog->settings->cinecturlink2->cinecturlink2_folder);
$core->media->getDir();
$dir = & $core->media->dir;
dcCore::app()->media = new dcMedia();
dcCore::app()->media->chdir(dcCore::app()->blog->settings->cinecturlink2->cinecturlink2_folder);
dcCore::app()->media->getDir();
$dir = & dcCore::app()->media->dir;
foreach ($dir['files'] as $file) {
if (!in_array(files::getExtension($file->relname), $allowed_media)) {
@ -194,14 +194,14 @@ if ($part == 'link') {
$media_combo = array_merge(['-' => ''], $tmp_media_combo);
}
} catch (Exception $e) {
//$core->error->add($e->getMessage());
//dcCore::app()->error->add($e->getMessage());
}
if (!empty($_POST['save'])) {
try {
cinecturlink2::makePublicDir(
DC_ROOT . '/' . $core->blog->settings->system->public_path,
$core->blog->settings->cinecturlink2->cinecturlink2_folder
DC_ROOT . '/' . dcCore::app()->blog->settings->system->public_path,
dcCore::app()->blog->settings->cinecturlink2->cinecturlink2_folder
);
if (empty($linktitle)) {
throw new Exception(__('You must provide a title.'));
@ -213,7 +213,7 @@ if ($part == 'link') {
throw new Exception(__('You must provide a link to an image.'));
}
$cur = $core->con->openCursor($C2->table);
$cur = dcCore::app()->con->openCursor($C2->table);
$cur->link_title = $linktitle;
$cur->link_desc = $linkdesc;
$cur->link_author = $linkauthor;
@ -231,7 +231,7 @@ if ($part == 'link') {
}
$linkid = $C2->addLink($cur);
dcPage::addSuccessNotice(
dcAdminNotices::addSuccessNotice(
__('Link successfully created.')
);
// update a link
@ -242,20 +242,20 @@ if ($part == 'link') {
}
$C2->updLink($linkid, $cur);
dcPage::addSuccessNotice(
dcAdminNotices::addSuccessNotice(
__('Link successfully updated.')
);
}
$core->adminurl->redirect(
dcCore::app()->adminurl->redirect(
'admin.plugin.cinecturlink2',
[
'part' => 'link',
'linkid' => $linkid,
'redir' => $redir
'redir' => $redir,
]
);
} catch (Exception $e) {
$core->error->add($e->getMessage());
dcCore::app()->error->add($e->getMessage());
}
}
@ -263,16 +263,16 @@ if ($part == 'link') {
try {
$C2->delLink($linkid);
dcPage::addSuccessNotice(
dcAdminNotices::addSuccessNotice(
__('Link successfully deleted.')
);
if (!empty($_POST['redir'])) {
http::redirect($redir);
} else {
$core->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'links']);
dcCore::app()->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'links']);
}
} catch (Exception $e) {
$core->error->add($e->getMessage());
dcCore::app()->error->add($e->getMessage());
}
}
@ -290,7 +290,7 @@ if ($part == 'link') {
}
}
$breadcrumb[(empty($linkid) ? __('New link') : __('Edit link'))] = '';
$headers .= dcPage::jsVars(['dotclear.c2_lang' => $core->auth->getInfo('user_lang')]) .
$headers .= dcPage::jsVars(['dotclear.c2_lang' => dcCore::app()->auth->getInfo('user_lang')]) .
dcPage::jsLoad(dcPage::getPF('cinecturlink2/js/c2link.js'));
}
@ -313,33 +313,33 @@ if ($part == 'cats') {
$i = 0;
foreach ($catorder as $id) {
$i++;
$cur = $core->con->openCursor($C2->table . '_cat');
$cur = dcCore::app()->con->openCursor($C2->table . '_cat');
$cur->cat_pos = $i;
$C2->updCategory($id, $cur);
}
dcPage::addSuccessNotice(
dcAdminNotices::addSuccessNotice(
__('Categories successfully reordered.')
);
$core->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'cats']);
dcCore::app()->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'cats']);
}
// delete categories
if (!empty($_POST['delete']) && !empty($_POST['items_selected'])) {
foreach ($_POST['items_selected'] as $id) {
$C2->delCategory($id);
}
dcPage::addSuccessNotice(
dcAdminNotices::addSuccessNotice(
__('Categories successfully deleted.')
);
$core->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'cats']);
dcCore::app()->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'cats']);
}
} catch (Exception $e) {
$core->error->add($e->getMessage());
dcCore::app()->error->add($e->getMessage());
}
$breadcrumb[__('Categories')] = '';
$core->auth->user_prefs->addWorkspace('accessibility');
if (!$core->auth->user_prefs->accessibility->nodragdrop) {
dcCore::app()->auth->user_prefs->addWorkspace('accessibility');
if (!dcCore::app()->auth->user_prefs->accessibility->nodragdrop) {
$headers .= dcPage::jsLoad('js/jquery/jquery-ui.custom.js') .
dcPage::jsLoad('js/jquery/jquery.ui.touch-punch.js') .
dcPage::jsLoad(dcPage::getPF('cinecturlink2/js/c2cats.js'));
@ -354,16 +354,16 @@ if ($part == 'cat') {
if ($exists) {
throw new Exception(__('Category with same name already exists.'));
}
$cur = $core->con->openCursor($C2->table . '_cat');
$cur = dcCore::app()->con->openCursor($C2->table . '_cat');
$cur->cat_title = $cattitle;
$cur->cat_desc = $catdesc;
$catid = $C2->addCategory($cur);
dcPage::addSuccessNotice(
dcAdminNotices::addSuccessNotice(
__('Category successfully created.')
);
$core->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'cats']);
dcCore::app()->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'cats']);
}
// update category
if (!empty($_POST['save']) && !empty($catid) && !empty($cattitle) && !empty($catdesc)) {
@ -371,30 +371,30 @@ if ($part == 'cat') {
if ($exists) {
throw new Exception(__('Category with same name already exists.'));
}
$cur = $core->con->openCursor($C2->table . '_cat');
$cur = dcCore::app()->con->openCursor($C2->table . '_cat');
$cur->cat_title = $cattitle;
$cur->cat_desc = $catdesc;
$C2->updCategory($catid, $cur);
dcPage::addSuccessNotice(
dcAdminNotices::addSuccessNotice(
__('Category successfully updated.')
);
$core->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'cats']);
dcCore::app()->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'cats']);
}
// delete category
if (!empty($_POST['delete']) && !empty($catid)) {
$C2->delCategory($catid);
dcPage::addSuccessNotice(
dcAdminNotices::addSuccessNotice(
__('Category successfully deleted.')
);
$core->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'cats']);
dcCore::app()->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'cats']);
}
} catch (Exception $e) {
$core->error->add($e->getMessage());
dcCore::app()->error->add($e->getMessage());
}
$breadcrumb[__('Categories')] = $core->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'cats']);
$breadcrumb[__('Categories')] = dcCore::app()->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'cats']);
$breadcrumb[(empty($catid) ? __('New category') : __('Edit category'))] = '';
}
@ -423,18 +423,18 @@ if ($part == 'updlinksnote') {
echo '</ul>';
echo '<h4>' . __('Rating') . '</h4>
<form method="post" action="' . $core->adminurl->get('admin.plugin.cinecturlink2') . '">' .
<form method="post" action="' . dcCore::app()->adminurl->get('admin.plugin.cinecturlink2') . '">' .
'<p><label for="newlinknote" class="ib">' . __('New rating:') . '</label> ' .
form::number('newlinknote', [
'min' => 0,
'max' => 20,
'default' => 10
'default' => 10,
]) . '/20' . '</p>' .
'<p>' .
'<input type="submit" value="' . __('Save') . ' (s)" accesskey="s" name="save" /> ' .
'<a id="post-cancel" href="' . (
$redir ? $redir :
$core->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'links'])
dcCore::app()->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'links'])
) . '" class="button" accesskey="c">' . __('Cancel') . ' (c)</a> ';
foreach ($entries as $id) {
echo form::hidden(['entries[]'], $id);
@ -442,7 +442,7 @@ if ($part == 'updlinksnote') {
echo
form::hidden('part', 'updlinksnote') .
form::hidden('redir', $redir) .
$core->formNonce() . '</p>' .
dcCore::app()->formNonce() . '</p>' .
'</form>';
}
}
@ -458,13 +458,13 @@ if ($part == 'updlinkscat') {
echo '</ul>';
echo '<h4>' . __('Category') . '</h4>
<form method="post" action="' . $core->adminurl->get('admin.plugin.cinecturlink2') . '">' .
<form method="post" action="' . dcCore::app()->adminurl->get('admin.plugin.cinecturlink2') . '">' .
'<p><label for="newcatid" class="ib">' . __('New category:') . '</label> ' .
form::combo('newcatid', $categories_combo, $catid) . '</p>' .
'<input type="submit" value="' . __('Save') . ' (s)" accesskey="s" name="save" /> ' .
'<a id="post-cancel" href="' . (
$redir ? $redir :
$core->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'links'])
dcCore::app()->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'links'])
) . '" class="button" accesskey="c">' . __('Cancel') . ' (c)</a> ';
foreach ($entries as $id) {
echo form::hidden(['entries[]'], $id);
@ -472,19 +472,19 @@ if ($part == 'updlinkscat') {
echo
form::hidden('part', 'updlinkscat') .
form::hidden('redir', $redir) .
$core->formNonce() . '</p>' .
dcCore::app()->formNonce() . '</p>' .
'</form>';
}
}
if ($part == 'links') {
$links_redir = $core->adminurl->get('admin.plugin.cinecturlink2', $c2link_filter->values());
$links_redir = dcCore::app()->adminurl->get('admin.plugin.cinecturlink2', $c2link_filter->values());
echo
'<p class="top-add"><a class="button add" href="' .
$core->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'link', 'redir' => $links_redir]) .
dcCore::app()->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'link', 'redir' => $links_redir]) .
'">' . __('New Link') . '</a> <a class="button add" href="' .
$core->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'cats', 'redir' => $links_redir]) .
dcCore::app()->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'cats', 'redir' => $links_redir]) .
'">' . __('Edit categories') . ' </a></p>';
if ($links->isEmpty() && !$c2link_filter->show()) {
@ -498,7 +498,7 @@ if ($part == 'links') {
$links_list->display(
$c2link_filter->page,
$c2link_filter->nb,
'<form action="' . $core->adminurl->get('admin.plugin.cinecturlink2') . '" method="post" id="form-entries">' .
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.cinecturlink2') . '" method="post" id="form-entries">' .
'%s' .
@ -508,9 +508,9 @@ if ($part == 'links') {
'<p class="col right"><label for="action" class="classic">' . __('Selected links action:') . '</label> ' .
form::combo('part', $action_combo) .
'<input id="do-action" type="submit" value="' . __('ok') . '" disabled /></p>' .
$core->adminurl->getHiddenFormFields('admin.plugin.cinecturlink2', array_diff_key($c2link_filter->values(), ['part' => ''])) .
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.cinecturlink2', array_diff_key($c2link_filter->values(), ['part' => ''])) .
form::hidden(['redir'], $links_redir) .
$core->formNonce() .
dcCore::app()->formNonce() .
'</div>' .
'</form>',
$c2link_filter->show(),
@ -521,7 +521,7 @@ if ($part == 'links') {
if ($part == 'link') {
echo '
<form id="newlinkform" method="post" action="' . $core->adminurl->get('admin.plugin.cinecturlink2') . '">
<form id="newlinkform" method="post" action="' . dcCore::app()->adminurl->get('admin.plugin.cinecturlink2') . '">
<div class="two-cols clearfix">
<div class="col70">
@ -554,7 +554,7 @@ if ($part == 'link') {
form::combo('newimageselect', $media_combo, '', 'maximal') .
'</label></p>' .
'<p class="form-note"><a href="' .
$core->adminurl->get('admin.media', ['d' => (string) $core->blog->settings->cinecturlink2->cinecturlink2_folder]) . '">' .
dcCore::app()->adminurl->get('admin.media', ['d' => (string) dcCore::app()->blog->settings->cinecturlink2->cinecturlink2_folder]) . '">' .
__('Go to media manager to add image to cinecturlink path.') .
'<a></p>';
}
@ -572,20 +572,20 @@ if ($part == 'link') {
form::number('linknote', [
'min' => 0,
'max' => 20,
'default' => $linknote
'default' => $linknote,
]) . '/20' . '</p>
</div></div>
<p class="border-top">' .
'<input type="submit" value="' . __('Save') . ' (s)" accesskey="s" name="save" /> ' .
'<a id="post-cancel" href="' .
$core->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'links']) .
dcCore::app()->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'links']) .
'" class="button" accesskey="c">' . __('Cancel') . ' (c)</a> ' .
'<input type="submit" class="delete" value="' . __('Delete') . '" name="delete" />' .
form::hidden('linkid', $linkid) .
form::hidden('part', 'link') .
form::hidden('redir', $redir) .
$core->formNonce() . '
dcCore::app()->formNonce() . '
</p>
</form>';
}
@ -593,17 +593,17 @@ if ($part == 'link') {
if ($part == 'cats') {
echo
'<p class="top-add"><a class="button add" href="' .
$core->adminurl->get(
dcCore::app()->adminurl->get(
'admin.plugin.cinecturlink2',
[
'part' => 'cat',
'redir' => $core->adminurl->get(
'redir' => dcCore::app()->adminurl->get(
'admin.plugin.cinecturlink2',
[
'part' => 'cats',
'redir' => $redir,
]
)
),
]
) .
'">' . __('New Category') . ' </a></p>';
@ -612,7 +612,7 @@ if ($part == 'cats') {
echo '<p>' . __('There is no category') . '</p>';
} else {
echo '
<form id="c2items" method="post" action="' . $core->adminurl->get('admin.plugin.cinecturlink2') . '">
<form id="c2items" method="post" action="' . dcCore::app()->adminurl->get('admin.plugin.cinecturlink2') . '">
<div class="table-outer">
<table class="dragable">
<caption>' . __('Categories list') . '</caption>
@ -634,23 +634,23 @@ if ($part == 'cats') {
'max' => $categories->count(),
'default' => $i + 1,
'class' => 'position',
'extra_html' => 'title="' . sprintf(__('position of %s'), html::escapeHTML($categories->cat_title)) . '"'
'extra_html' => 'title="' . sprintf(__('position of %s'), html::escapeHTML($categories->cat_title)) . '"',
]) .
form::hidden(['dynorder[]', 'dynorder-' . $i], $id) . '</td>
<td class="minimal">' . form::checkbox(['items_selected[]', 'ims-' . $i], $id) . '</td>
<td class="nowrap"><a title="' . __('Edit') . '" href="' .
$core->adminurl->get(
dcCore::app()->adminurl->get(
'admin.plugin.cinecturlink2',
[
'part' => 'cat',
'catid' => $id,
'redir' => $core->adminurl->get(
'redir' => dcCore::app()->adminurl->get(
'admin.plugin.cinecturlink2',
[
'part' => 'cats',
'redir' => $redir
'redir' => $redir,
]
)
),
]
) .
'">' . html::escapeHTML($categories->cat_title) . '</a></td>
@ -667,12 +667,12 @@ if ($part == 'cats') {
<p class="border-top">' .
'<input type="submit" value="' . __('Save order') . ' (s)" accesskey="s" name="save" /> ' .
'<a id="post-cancel" href="' .
$core->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'cats']) .
dcCore::app()->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'cats']) .
'" class="button" accesskey="c">' . __('Cancel') . ' (c)</a> ' .
'<input type="submit" class="delete" value="' . __('Delete selection') . '" name="delete" />' .
form::hidden('im_order', '') .
form::hidden('part', 'cats') .
$core->formNonce() . '</p>' .
dcCore::app()->formNonce() . '</p>' .
'</form>';
}
}
@ -695,7 +695,7 @@ if ($part == 'cat') {
) . '</p>';
}
echo '
<form method="post" action="' . $core->adminurl->get('admin.plugin.cinecturlink2') . '">
<form method="post" action="' . dcCore::app()->adminurl->get('admin.plugin.cinecturlink2') . '">
<p><label for="cattitle">' . __('Title:') . ' ' .
form::field('cattitle', 60, 64, $cattitle, 'maximal') .
'</label></p>
@ -705,12 +705,12 @@ if ($part == 'cat') {
<p class="border-top">' .
'<input type="submit" value="' . __('Save') . ' (s)" accesskey="s" name="save" /> ' .
'<a id="post-cancel" href="' .
$core->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'cats']) .
dcCore::app()->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'cats']) .
'" class="button" accesskey="c">' . __('Cancel') . ' (c)</a> ' .
(!empty($catid) ? ' <input type="submit" class="delete" value="' . __('Delete') . '" name="delete" />' : '') .
form::hidden('catid', $catid) .
form::hidden('part', 'cat') .
$core->formNonce() . '</p>' .
dcCore::app()->formNonce() . '</p>' .
'</form>';
}