From a43e4015cd83fa1206fc7e11ecfeec1842be437e Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Tue, 2 Nov 2021 23:55:41 +0100 Subject: [PATCH] fix PRS12 CS --- README.md | 11 +- _admin.php | 29 +-- _config.php | 54 ++-- _define.php | 19 +- _install.php | 55 ++-- _prepend.php | 17 +- _public.php | 275 ++++++++++---------- _uninstall.php | 129 ++++++---- _widgets.php | 113 ++++---- inc/class.cinecturlink2.php | 119 +++++---- inc/lib.cinecturlink2.activityreport.php | 9 +- inc/lib.cinecturlink2.context.php | 30 ++- inc/lib.cinecturlink2.list.php | 61 +++-- inc/lib.sitemaps.cinecturlink2.php | 15 +- index.php | 314 ++++++++++++----------- 15 files changed, 635 insertions(+), 615 deletions(-) diff --git a/README.md b/README.md index 4e8945b..1a93873 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,11 @@ # README -[![Release version](https://img.shields.io/github/v/release/JcDenis/cinecturlink2)](https://github.com/JcDenis/cinecturlink2/releases) -[![Release date](https://img.shields.io/github/release-date/JcDenis/cinecturlink2)](https://github.com/JcDenis/cinecturlink2/releases) -[![Issue tracking](https://img.shields.io/github/issues/JcDenis/cinecturlink2)](https://github.com/JcDenis/cinecturlink2/issues) -[![Dotclear version](https://img.shields.io/badge/dotclear-v2.19-blue.svg)](https://fr.dotclear.org/download) -[![License](https://img.shields.io/badge/license-GPL%20v2-blue.svg)](https://github.com/JcDenis/cinecturlink2/blob/master/LICENSE) +[![Release](https://img.shields.io/github/v/release/JcDenis/cinecturlink2)](https://github.com/JcDenis/cinecturlink2/releases) +[![Date](https://img.shields.io/github/release-date/JcDenis/cinecturlink2)](https://github.com/JcDenis/cinecturlink2/releases) +[![Issues](https://img.shields.io/github/issues/JcDenis/cinecturlink2)](https://github.com/JcDenis/cinecturlink2/issues) +[![Dotclear](https://img.shields.io/badge/dotclear-v2.19-blue.svg)](https://fr.dotclear.org/download) +[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/cinecturlink2) +[![License](https://img.shields.io/github/license/JcDenis/cinecturlink2)](https://github.com/JcDenis/cinecturlink2/blob/master/LICENSE) ## WHAT IS CINECTURLINK2 ? diff --git a/_admin.php b/_admin.php index c4b3374..f551f60 100644 --- a/_admin.php +++ b/_admin.php @@ -1,16 +1,15 @@ addItem( $core->adminurl->get('admin.plugin.cinecturlink2'), dcPage::getPF('cinecturlink2/icon.png'), preg_match( - '/' . preg_quote($core->adminurl->get('admin.plugin.cinecturlink2')) . '(&.*)?$/', + '/' . preg_quote($core->adminurl->get('admin.plugin.cinecturlink2')) . '(&.*)?$/', $_SERVER['REQUEST_URI'] ), $core->auth->check('contentadmin', $core->blog->id) ); $core->addBehavior( - 'adminColumnsLists', + 'adminColumnsLists', ['cinecturlink2AdminBehaviors', 'adminColumnsLists'] ); $core->addBehavior( - 'adminFiltersLists', + 'adminFiltersLists', ['cinecturlink2AdminBehaviors', 'adminFiltersLists'] ); $core->addBehavior( @@ -86,19 +85,19 @@ class cinecturlink2AdminBehaviors public static function adminDashboardFavorites($core, $favs) { $favs->register('cinecturlink2', [ - 'title' => __('My cinecturlink'), - 'url' => $core->adminurl->get('admin.plugin.cinecturlink2').'#links', - 'small-icon' => dcPage::getPF('cinecturlink2/icon.png'), - 'large-icon' => dcPage::getPF('cinecturlink2/icon-big.png'), + 'title' => __('My cinecturlink'), + 'url' => $core->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'] + 'active_cb' => ['cinecturlink2AdminBehaviors', 'adminDashboardFavoritesActive'] ]); } public static function adminDashboardFavoritesActive($request, $params) { - return $request == 'plugin.php' - && isset($params['p']) + return $request == 'plugin.php' + && isset($params['p']) && $params['p'] == 'cinecturlink2'; } -} \ No newline at end of file +} diff --git a/_config.php b/_config.php index 872fa01..f2e277b 100644 --- a/_config.php +++ b/_config.php @@ -1,33 +1,32 @@ getURL().'#plugins' : $_REQUEST['redir']; +$redir = empty($_REQUEST['redir']) ? + $list->getURL() . '#plugins' : $_REQUEST['redir']; $core->blog->settings->addNamespace('cinecturlink2'); -$s = $core->blog->settings->cinecturlink2; -$cinecturlink2_active = (boolean) $s->cinecturlink2_active; -$cinecturlink2_widthmax = abs((integer) $s->cinecturlink2_widthmax); -$cinecturlink2_folder = (string) $s->cinecturlink2_folder; -$cinecturlink2_triggeronrandom = (boolean) $s->cinecturlink2_triggeronrandom; -$cinecturlink2_public_active = (boolean) $s->cinecturlink2_public_active; -$cinecturlink2_public_title = (string) $s->cinecturlink2_public_title; +$s = $core->blog->settings->cinecturlink2; +$cinecturlink2_active = (bool) $s->cinecturlink2_active; +$cinecturlink2_widthmax = abs((int) $s->cinecturlink2_widthmax); +$cinecturlink2_folder = (string) $s->cinecturlink2_folder; +$cinecturlink2_triggeronrandom = (bool) $s->cinecturlink2_triggeronrandom; +$cinecturlink2_public_active = (bool) $s->cinecturlink2_public_active; +$cinecturlink2_public_title = (string) $s->cinecturlink2_public_title; $cinecturlink2_public_description = (string) $s->cinecturlink2_public_description; -$cinecturlink2_public_nbrpp = (integer) $s->cinecturlink2_public_nbrpp; +$cinecturlink2_public_nbrpp = (int) $s->cinecturlink2_public_nbrpp; if ($cinecturlink2_public_nbrpp < 1) { $cinecturlink2_public_nbrpp = 10; } @@ -36,18 +35,17 @@ $combo_dirs = cinecturlink2::getPublicDirs($core); if (!empty($_POST['save'])) { try { - - $cinecturlink2_active = !empty($_POST['cinecturlink2_active']); - $cinecturlink2_widthmax = abs((integer) $_POST['cinecturlink2_widthmax']); - $cinecturlink2_newdir = (string) files::tidyFileName($_POST['cinecturlink2_newdir']); - $cinecturlink2_folder = empty($cinecturlink2_newdir) ? + $cinecturlink2_active = !empty($_POST['cinecturlink2_active']); + $cinecturlink2_widthmax = abs((int) $_POST['cinecturlink2_widthmax']); + $cinecturlink2_newdir = (string) files::tidyFileName($_POST['cinecturlink2_newdir']); + $cinecturlink2_folder = empty($cinecturlink2_newdir) ? (string) files::tidyFileName($_POST['cinecturlink2_folder']) : $cinecturlink2_newdir; - $cinecturlink2_triggeronrandom = !empty($_POST['cinecturlink2_triggeronrandom']); - $cinecturlink2_public_active = !empty($_POST['cinecturlink2_public_active']); - $cinecturlink2_public_title = (string) $_POST['cinecturlink2_public_title']; + $cinecturlink2_triggeronrandom = !empty($_POST['cinecturlink2_triggeronrandom']); + $cinecturlink2_public_active = !empty($_POST['cinecturlink2_public_active']); + $cinecturlink2_public_title = (string) $_POST['cinecturlink2_public_title']; $cinecturlink2_public_description = (string) $_POST['cinecturlink2_public_description']; - $cinecturlink2_public_nbrpp = (integer) $_POST['cinecturlink2_public_nbrpp']; + $cinecturlink2_public_nbrpp = (int) $_POST['cinecturlink2_public_nbrpp']; if ($cinecturlink2_public_nbrpp < 1) { $cinecturlink2_public_nbrpp = 10; } @@ -72,7 +70,7 @@ if (!empty($_POST['save'])) { __('Configuration successfully updated.') ); $core->adminurl->redirect( - 'admin.plugins', + 'admin.plugins', ['module' => 'cinecturlink2', 'conf' => 1, 'redir' => $list->getRedir()] ); } catch (Exception $e) { @@ -88,10 +86,10 @@ echo ' form::checkbox('cinecturlink2_active', 1, $cinecturlink2_active) . __('Enable plugin') . '

-

' . +

' . form::combo('cinecturlink2_folder', $combo_dirs, $cinecturlink2_folder) . '

-

' . +

' . form::field('cinecturlink2_newdir', 60, 64, '', 'maximal') . '

' . @@ -115,7 +113,7 @@ __('Update cache when use "Random" or "Number of view" order on widget (Need rel

-

' . sprintf(__('Public page has url: %s'), '' . $core->blog->url . $core->url->getBase('cinecturlink2') . '') . '

+

' . sprintf(__('Public page has url: %s'), '' . $core->blog->url . $core->url->getBase('cinecturlink2') . '') . '

' . form::field('cinecturlink2_public_title', 60, 255, $cinecturlink2_public_title, 'maximal') . '

@@ -140,4 +138,4 @@ form::number('cinecturlink2_public_nbrpp', 1, 100, $cinecturlink2_public_nbrpp)
  • ' . sprintf(__('The plugin Cinecturlink2 is compatible with plugin %s.'), 'Activity report') . '
  • -'; \ No newline at end of file +'; diff --git a/_define.php b/_define.php index a2e48f2..f5255a4 100644 --- a/_define.php +++ b/_define.php @@ -1,16 +1,15 @@ registerModule( 'Jean-Christian Denis and Contributors', '0.9.1', [ - 'requires' => [['core', '2.19']], + 'requires' => [['core', '2.19']], 'permissions' => 'contentadmin', - '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' + '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' ] -); \ No newline at end of file +); diff --git a/_install.php b/_install.php index 4a7a717..307f244 100644 --- a/_install.php +++ b/_install.php @@ -1,16 +1,15 @@ =')) { try { $s = new dbStruct($core->con, $core->prefix); $s->cinecturlink2 - ->link_id ('bigint', 0, false) - ->blog_id ('varchar', 32, false) - ->cat_id ('bigint', 0, true) - ->user_id ('varchar', 32, true) - ->link_type ('varchar', 32, false, "'cinecturlink'") - ->link_title ('varchar', 255, false) - ->link_desc ('varchar', 255, false) - ->link_author ('varchar', 255, false) - ->link_lang ('varchar', 5, false, "'en'") - ->link_url ('varchar', 255, false) - ->link_img ('varchar', 255, false) - ->link_creadt ('timestamp', 0, false, 'now()') - ->link_upddt ('timestamp', 0, false, 'now()') - ->link_pos ('smallint', 0, false, "'0'") + ->link_id('bigint', 0, false) + ->blog_id('varchar', 32, false) + ->cat_id('bigint', 0, true) + ->user_id('varchar', 32, true) + ->link_type('varchar', 32, false, "'cinecturlink'") + ->link_title('varchar', 255, false) + ->link_desc('varchar', 255, false) + ->link_author('varchar', 255, false) + ->link_lang('varchar', 5, false, "'en'") + ->link_url('varchar', 255, false) + ->link_img('varchar', 255, false) + ->link_creadt('timestamp', 0, false, 'now()') + ->link_upddt('timestamp', 0, false, 'now()') + ->link_pos('smallint', 0, false, "'0'") ->link_note('smallint', 0, false, "'10'") ->link_count('bigint', 0, false, "'0'") @@ -51,19 +50,19 @@ try { ->index('idx_cinecturlink2_type', 'btree', 'link_type'); $s->cinecturlink2_cat - ->cat_id ('bigint', 0, false) - ->blog_id ('varchar', 32, false) - ->cat_title ('varchar', 255, false) - ->cat_desc ('varchar', 255, false) - ->cat_creadt ('timestamp', 0, false, 'now()') - ->cat_upddt ('timestamp', 0, false, 'now()') - ->cat_pos ('smallint', 0, false, "'0'") + ->cat_id('bigint', 0, false) + ->blog_id('varchar', 32, false) + ->cat_title('varchar', 255, false) + ->cat_desc('varchar', 255, false) + ->cat_creadt('timestamp', 0, false, 'now()') + ->cat_upddt('timestamp', 0, false, 'now()') + ->cat_pos('smallint', 0, false, "'0'") ->primary('pk_cinecturlink2_cat', 'cat_id') ->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($core->con, $core->prefix); $changes = $si->synchronize($s); $core->blog->settings->addNamespace('cinecturlink2'); @@ -74,7 +73,7 @@ try { $s->put('cinecturlink2_triggeronrandom', false, 'boolean', 'Open link in new window', false, true); $s->put('cinecturlink2_public_active', false, 'boolean', 'Enable cinecturlink2', false, true); $s->put('cinecturlink2_public_title', '', 'string', 'Title of public page', false, true); - $s->put('cinecturlink2_public_description', '', 'string','Description of public page', false, true); + $s->put('cinecturlink2_public_description', '', 'string', 'Description of public page', false, true); $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); @@ -88,4 +87,4 @@ try { $core->error->add($e->getMessage()); } -return false; \ No newline at end of file +return false; diff --git a/_prepend.php b/_prepend.php index d664ea7..fbeb6d8 100644 --- a/_prepend.php +++ b/_prepend.php @@ -1,26 +1,25 @@ url->register( @@ -41,4 +40,4 @@ $core->addBehavior( if (defined('ACTIVITY_REPORT')) { cinecturlink2ActivityReportBehaviors::add($core); -} \ No newline at end of file +} diff --git a/_public.php b/_public.php index 7ddb514..c9b8dcd 100644 --- a/_public.php +++ b/_public.php @@ -1,26 +1,24 @@ blog->settings->addNamespace('cinecturlink2'); -$c2_tpl_values = array( +$c2_tpl_values = [ 'c2PageFeedID', 'c2PageFeedURL', 'c2PageURL', @@ -59,9 +57,9 @@ $c2_tpl_values = array( 'c2CategoryTitle', 'c2CategoryDescription', 'c2CategoryURL' -); +]; -$c2_tpl_blocks = array( +$c2_tpl_blocks = [ 'c2If', 'c2Entries', @@ -76,21 +74,18 @@ $c2_tpl_blocks = array( 'c2CategoriesHeader', 'c2CategoriesFooter', 'c2CategoryIf' -); +]; if ($core->blog->settings->cinecturlink2->cinecturlink2_active) { - - foreach($c2_tpl_blocks as $v) { - $core->tpl->addBlock($v, array('tplCinecturlink2', $v)); + foreach ($c2_tpl_blocks as $v) { + $core->tpl->addBlock($v, ['tplCinecturlink2', $v]); } - foreach($c2_tpl_values as $v) { - $core->tpl->addValue($v, array('tplCinecturlink2', $v)); + foreach ($c2_tpl_values as $v) { + $core->tpl->addValue($v, ['tplCinecturlink2', $v]); } -} -else { - - foreach(array_merge($c2_tpl_blocks, $c2_tpl_values) as $v) { - $core->tpl->addBlock($v, array('tplCinecturlink2', 'disable')); +} else { + foreach (array_merge($c2_tpl_blocks, $c2_tpl_values) as $v) { + $core->tpl->addBlock($v, ['tplCinecturlink2', 'disable']); } } @@ -101,9 +96,8 @@ class urlCinecturlink2 extends dcUrlHandlers global $core, $_ctx; $core->blog->settings->addNamespace('cinecturlink2'); - if (!$core->blog->settings->cinecturlink2->cinecturlink2_active - || !$core->blog->settings->cinecturlink2->cinecturlink2_public_active) - { + if (!$core->blog->settings->cinecturlink2->cinecturlink2_active + || !$core->blog->settings->cinecturlink2->cinecturlink2_public_active) { self::p404(); return null; @@ -111,10 +105,10 @@ class urlCinecturlink2 extends dcUrlHandlers $core->tpl->setPath( $core->tpl->getPath(), - dirname(__FILE__).'/default-templates/' + dirname(__FILE__) . '/default-templates/' ); - $params = array(); + $params = []; $n = self::getPageArgs($args, 'c2page'); if ($n) { @@ -122,42 +116,41 @@ class urlCinecturlink2 extends dcUrlHandlers } $caturl = $core->blog->settings->cinecturlink2->cinecturlink2_public_caturl; - if (!$caturl) $caturl = 'c2cat'; + if (!$caturl) { + $caturl = 'c2cat'; + } $c = self::getPageArgs($args, $caturl); if ($c) { if (is_numeric($c)) { - $params['cat_id'] = (integer) $c; - } - else { + $params['cat_id'] = (int) $c; + } else { $params['cat_title'] = urldecode($c); } } $f = self::getPageArgs($args, 'feed'); - if ($f && in_array($f, array('atom', 'rss2'))) { + 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; - $params['limit'] = $core->blog->settings->system->nb_post_per_feed; + $params['limit'] = $core->blog->settings->system->nb_post_per_feed; $_ctx->c2_page_params = $params; - header('X-Robots-Tag: '.context::robotsPolicy($core->blog->settings->system->robots_policy, '')); - self::serveDocument('cinecturlink2-'.$f.'.xml', $mime); - } - else { + header('X-Robots-Tag: ' . context::robotsPolicy($core->blog->settings->system->robots_policy, '')); + self::serveDocument('cinecturlink2-' . $f . '.xml', $mime); + } else { $d = self::getPageArgs($args, 'c2detail'); if ($d) { if (is_numeric($d)) { - $params['link_id'] = (integer) $d; - } - else { + $params['link_id'] = (int) $d; + } else { $params['link_title'] = urldecode($d); } } - $params['limit'] = $core->blog->settings->cinecturlink2->cinecturlink2_public_nbrpp; + $params['limit'] = $core->blog->settings->cinecturlink2->cinecturlink2_public_nbrpp; $_ctx->c2_page_params = $params; self::serveDocument('cinecturlink2.html', 'text/html'); @@ -168,8 +161,8 @@ class urlCinecturlink2 extends dcUrlHandlers protected static function getPageArgs(&$args, $part) { - if (preg_match('#(^|/)'.$part.'/([^/]+)#', $args, $m)) { - $args = preg_replace('#(^|/)'.$part.'/([^/]+)#', '', $args); + if (preg_match('#(^|/)' . $part . '/([^/]+)#', $args, $m)) { + $args = preg_replace('#(^|/)' . $part . '/([^/]+)#', '', $args); return $m[2]; } @@ -180,24 +173,24 @@ class urlCinecturlink2 extends dcUrlHandlers class tplCinecturlink2 { - public static function disable($a, $c=null) + public static function disable($a, $c = null) { return ''; } public static function c2PageURL($a) { - return "tpl->getFilters($a), '$core->blog->url.$core->url->getBase(\'cinecturlink2\')')."; ?>"; + return 'tpl->getFilters($a), '$core->blog->url.$core->url->getBase(\'cinecturlink2\')') . '; ?>'; } public static function c2PageTitle($a) { - return "blog->settings->cinecturlink2->cinecturlink2_public_title; if (empty(\$title)) { \$title = __('My cinecturlink'); } echo ".sprintf($GLOBALS['core']->tpl->getFilters($a), '$title')."; ?>"; + return "blog->settings->cinecturlink2->cinecturlink2_public_title; if (empty(\$title)) { \$title = __('My cinecturlink'); } echo " . sprintf($GLOBALS['core']->tpl->getFilters($a), '$title') . '; ?>'; } public static function c2PageFeedURL($a) { - return "tpl->getFilters($a),'$core->blog->url.$core->url->getBase("cinecturlink2")."/feed/'.(!empty($a['type']) && preg_match('#^(rss2|atom)$#', $a['type']) ? $a['type'] : 'atom').'"')."; ?>"; + return 'tpl->getFilters($a), '$core->blog->url.$core->url->getBase("cinecturlink2")."/feed/' . (!empty($a['type']) && preg_match('#^(rss2|atom)$#', $a['type']) ? $a['type'] : 'atom') . '"') . '; ?>'; } public static function c2PageFeedID($a) @@ -207,45 +200,43 @@ class tplCinecturlink2 public static function c2PageDescription($a) { - return "blog->settings->cinecturlink2->cinecturlink2_public_description; echo ".sprintf($GLOBALS['core']->tpl->getFilters($a), '$description')."; ?>"; + return 'blog->settings->cinecturlink2->cinecturlink2_public_description; echo ' . sprintf($GLOBALS['core']->tpl->getFilters($a), '$description') . '; ?>'; } - public static function c2If($a ,$c) + public static function c2If($a, $c) { - $if = array(); + $if = []; $operator = isset($a['operator']) ? self::getOperator($a['operator']) : '&&'; if (isset($a['request_link'])) { - $sign = (boolean) $a['request_link'] ? '' : '!'; - $if[] = $sign.'(isset($_ctx->c2_page_params["link_id"]) || isset($_ctx->c2_page_params["link_title"]))'; + $sign = (bool) $a['request_link'] ? '' : '!'; + $if[] = $sign . '(isset($_ctx->c2_page_params["link_id"]) || isset($_ctx->c2_page_params["link_title"]))'; } if (isset($a['request_cat'])) { - $sign = (boolean) $a['request_cat'] ? '' : '!'; - $if[] = $sign.'(isset($_ctx->c2_page_params["cat_id"]) || isset($_ctx->c2_page_params["cat_title"]))'; + $sign = (bool) $a['request_cat'] ? '' : '!'; + $if[] = $sign . '(isset($_ctx->c2_page_params["cat_id"]) || isset($_ctx->c2_page_params["cat_title"]))'; } - return empty($if) ? $c : "\n".$c."\n"; + return empty($if) ? $c : '\n" . $c . "\n"; } public static function c2Entries($a, $c) { - $lastn = isset($a['lastn']) ? abs((integer) $a['lastn'])+0 : -1; + $lastn = isset($a['lastn']) ? abs((int) $a['lastn']) + 0 : -1; - $res = 'if (!isset($c2_page_number)) { $c2_page_number = 1; }'."\n"; + $res = 'if (!isset($c2_page_number)) { $c2_page_number = 1; }' . "\n"; if ($lastn != 0) { if ($lastn > 0) { - $res .= "\$params['limit'] = ".$lastn.";\n"; - } - else { + $res .= "\$params['limit'] = " . $lastn . ";\n"; + } else { $res .= "if (!isset(\$params['limit']) || \$params['limit'] < 1) { \$params['limit'] = 10; }\n"; } - if (!isset($a['ignore_pagination']) || $a['ignore_pagination'] == "0") { + if (!isset($a['ignore_pagination']) || $a['ignore_pagination'] == '0') { $res .= "\$params['limit'] = array(((\$c2_page_number-1)*\$params['limit']),\$params['limit']);\n"; - } - else { + } else { $res .= "\$params['limit'] = array(0, \$params['limit']);\n"; } } @@ -253,65 +244,62 @@ class tplCinecturlink2 if (isset($a['category'])) { if ($a['category'] == 'null') { $res .= "\$params['sql'] = ' AND L.cat_id IS NULL ';\n"; - } - elseif (is_numeric($a['category'])) { - $res .= "\$params['cat_id'] = ".(integer) $a['category'].";\n"; - } - else { - $res .= "\$params['cat_title'] = '".$a['category']."';\n"; + } elseif (is_numeric($a['category'])) { + $res .= "\$params['cat_id'] = " . (int) $a['category'] . ";\n"; + } else { + $res .= "\$params['cat_title'] = '" . $a['category'] . "';\n"; } } - $sort = isset($a['sort']) && $a['sort'] == 'asc' ? ' asc' : ' desc'; - $sortby = isset($a['order']) && in_array($a['order'],array('link_count','link_upddt','link_creadt','link_note','link_title')) ? $a['order'] : 'link_upddt'; + $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"; + $res .= "\$params['order'] = '" . $sortby . $sort . "';\n"; - return - "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.'c2_entries = null; \$_ctx->c2_params = null; \n". + return + "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 . 'c2_entries = null; \$_ctx->c2_params = null; \n" . "?>\n"; } public static function c2EntriesHeader($a, $c) { - return "c2_entries->isStart()) : ?>".$c.""; + return 'c2_entries->isStart()) : ?>' . $c . ''; } public static function c2EntriesFooter($a, $c) { - return "c2_entries->isEnd()) : ?>".$c.""; + return 'c2_entries->isEnd()) : ?>' . $c . ''; } public static function c2EntryIf($a, $c) { - $if = array(); + $if = []; $operator = isset($a['operator']) ? self::getOperator($a['operator']) : '&&'; if (isset($a['has_category'])) { - $sign = (boolean) $a['has_category'] ? '!' : '='; - $if[] = '($_ctx->exists("c2_entries") && "" '.$sign.'= $_ctx->c2_entries->cat_title)'; + $sign = (bool) $a['has_category'] ? '!' : '='; + $if[] = '($_ctx->exists("c2_entries") && "" ' . $sign . '= $_ctx->c2_entries->cat_title)'; } - return empty($if) ? $c : "\n".$c."\n"; + return empty($if) ? $c : '\n" . $c . "\n"; } public static function c2EntryIfFirst($a) { - return 'c2_entries->index() == 0) { echo "'.(isset($a['return']) ? addslashes(html::escapeHTML($a['return'])) : 'first').'"; } ?>'; + return 'c2_entries->index() == 0) { echo "' . (isset($a['return']) ? addslashes(html::escapeHTML($a['return'])) : 'first') . '"; } ?>'; } public static function c2EntryIfOdd($a) { - return 'c2_entries->index()+1)%2 == 1) { echo "'.(isset($a['return']) ? addslashes(html::escapeHTML($a['return'])) : 'odd').'"; } ?>'; + return 'c2_entries->index()+1)%2 == 1) { echo "' . (isset($a['return']) ? addslashes(html::escapeHTML($a['return'])) : 'odd') . '"; } ?>'; } public static function c2EntryFeedID($a) @@ -397,50 +385,50 @@ class tplCinecturlink2 public static function c2EntryImg($a) { global $core; - $f = $core->tpl->getFilters($a); + $f = $core->tpl->getFilters($a); $style = isset($a['style']) ? html::escapeHTML($a['style']) : ''; - return - "exists('c2_entries')) { ". - "\$widthmax = (integer) \$core->blog->settings->cinecturlink2->cinecturlink2_widthmax; ". - "\$img = sprintf('\"%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"; + return + "exists('c2_entries')) { " . + '$widthmax = (integer) $core->blog->settings->cinecturlink2->cinecturlink2_widthmax; ' . + "\$img = sprintf('\"%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"; } public static function c2EntryDate($a) { $format = !empty($a['format']) ? addslashes($a['format']) : ''; - if (!empty($a['rfc822'])) - $p = "dt::rfc822(strtotime(\$_ctx->c2_entries->link_creadt), \$_ctx->posts->post_tz)"; - elseif (!empty($a['iso8601'])) - $p = "dt::iso8601(strtotime(\$_ctx->c2_entries->link_creadt), \$_ctx->posts->post_tz)"; - 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)"; + if (!empty($a['rfc822'])) { + $p = 'dt::rfc822(strtotime($_ctx->c2_entries->link_creadt), $_ctx->posts->post_tz)'; + } elseif (!empty($a['iso8601'])) { + $p = 'dt::iso8601(strtotime($_ctx->c2_entries->link_creadt), $_ctx->posts->post_tz)'; + } 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)'; + } return self::getGenericValue($p, $a); } 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']) . "'" : '$core->blog->settings->system->time_format') . ', $_ctx->c2_entries->link_creadt)', $a); } public static function c2Pagination($a, $c) { - $p = - "c2_params;\n". - "\$_ctx->c2_pagination = \$_ctx->cinecturlink->getLinks(\$params,true); unset(\$params);\n". + $p = "c2_params;\n" . + "\$_ctx->c2_pagination = \$_ctx->cinecturlink->getLinks(\$params,true); unset(\$params);\n" . "?>\n"; - return isset($a['no_context']) ? $p.$c : $p.'c2_pagination->f(0) > $_ctx->c2_entries->count()) : ?>'.$c.''; + return isset($a['no_context']) ? $p . $c : $p . 'c2_pagination->f(0) > $_ctx->c2_entries->count()) : ?>' . $c . ''; } public static function c2PaginationCounter($a) @@ -450,65 +438,65 @@ class tplCinecturlink2 public static function c2PaginationCurrent($a) { - return self::getGenericValue('cinecturlink2Context::PaginationPosition('.(isset($a['offset']) ? (integer) $a['offset'] : 0).')', $a); + return self::getGenericValue('cinecturlink2Context::PaginationPosition(' . (isset($a['offset']) ? (int) $a['offset'] : 0) . ')', $a); } public static function c2PaginationIf($a, $c) { - $if = array(); + $if = []; if (isset($a['start'])) { - $sign = (boolean) $a['start'] ? '' : '!'; - $if[] = $sign.'cinecturlink2Context::PaginationStart()'; + $sign = (bool) $a['start'] ? '' : '!'; + $if[] = $sign . 'cinecturlink2Context::PaginationStart()'; } if (isset($a['end'])) { - $sign = (boolean) $a['end'] ? '' : '!'; - $if[] = $sign.'cinecturlink2Context::PaginationEnd()'; + $sign = (bool) $a['end'] ? '' : '!'; + $if[] = $sign . 'cinecturlink2Context::PaginationEnd()'; } - return empty($if) ? $c : ''.$c.''; + return empty($if) ? $c : '' . $c . ''; } public static function c2PaginationURL($a) { - return self::getGenericValue('cinecturlink2Context::PaginationURL('.(isset($a['offset']) ? (integer) $a['offset'] : 0).')', $a); + return self::getGenericValue('cinecturlink2Context::PaginationURL(' . (isset($a['offset']) ? (int) $a['offset'] : 0) . ')', $a); } public static function c2Categories($a, $c) { - return - "exists('cinecturlink')) { \$_ctx->cinecturlink = new cinecturlink2(\$core); } \n". - "\$_ctx->c2_categories = \$_ctx->cinecturlink->getCategories(); \n". - 'while ($_ctx->c2_categories->fetch()) : ?>'.$c.'c2_categories = null; \n". + return + "exists('cinecturlink')) { \$_ctx->cinecturlink = new cinecturlink2(\$core); } \n" . + "\$_ctx->c2_categories = \$_ctx->cinecturlink->getCategories(); \n" . + 'while ($_ctx->c2_categories->fetch()) : ?>' . $c . 'c2_categories = null; \n" . "?>\n"; } public static function c2CategoriesHeader($a, $c) { - return "c2_categories->isStart()) : ?>".$c.""; + return 'c2_categories->isStart()) : ?>' . $c . ''; } public static function c2CategoriesFooter($a, $c) { - return "c2_categories->isEnd()) : ?>".$c.""; + return 'c2_categories->isEnd()) : ?>' . $c . ''; } public static function c2CategoryIf($a, $c) { - $if = array(); + $if = []; if (isset($a['current'])) { - $sign = (boolean) $a['current'] ? '' : '!'; - $if[] = $sign.'cinecturlink2Context::CategoryCurrent()'; + $sign = (bool) $a['current'] ? '' : '!'; + $if[] = $sign . 'cinecturlink2Context::CategoryCurrent()'; } if (isset($a['first'])) { - $sign = (boolean) $a['first'] ? '' : '!'; - $if[] = $sign.'$_ctx->c2_categories->isStart()'; + $sign = (bool) $a['first'] ? '' : '!'; + $if[] = $sign . '$_ctx->c2_categories->isStart()'; } - return empty($if) ? $c : ''.$c.''; + return empty($if) ? $c : '' . $c . ''; } public static function c2CategoryFeedURL($a) @@ -519,7 +507,7 @@ class tplCinecturlink2 $p = 'atom'; } - return "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 '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 . '"') . '; ?>'; } public static function c2CategoryFeedID($a) @@ -529,33 +517,32 @@ class tplCinecturlink2 public static function c2CategoryID($a) { - return "exists('c2_categories')) { echo ".sprintf($GLOBALS['core']->tpl->getFilters($a), '$_ctx->c2_categories->cat_id')."; } ?>"; + return "exists('c2_categories')) { echo " . sprintf($GLOBALS['core']->tpl->getFilters($a), '$_ctx->c2_categories->cat_id') . '; } ?>'; } public static function c2CategoryTitle($a) { - return "exists('c2_categories')) { echo ".sprintf($GLOBALS['core']->tpl->getFilters($a), '$_ctx->c2_categories->cat_title')."; } ?>"; + return "exists('c2_categories')) { echo " . sprintf($GLOBALS['core']->tpl->getFilters($a), '$_ctx->c2_categories->cat_title') . '; } ?>'; } public static function c2CategoryDescription($a) { - return "exists('c2_categories')) { echo ".sprintf($GLOBALS['core']->tpl->getFilters($a), '$_ctx->c2_categories->cat_desc')."; } ?>"; + return "exists('c2_categories')) { echo " . sprintf($GLOBALS['core']->tpl->getFilters($a), '$_ctx->c2_categories->cat_desc') . '; } ?>'; } public static function c2CategoryURL($a) { - return "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 "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)') . '; } ?>'; } - protected static function getGenericValue($p,$a) + protected static function getGenericValue($p, $a) { - return "exists('c2_entries')) { echo ".sprintf($GLOBALS['core']->tpl->getFilters($a), "$p")."; } ?>"; + return "exists('c2_entries')) { echo " . sprintf($GLOBALS['core']->tpl->getFilters($a), "$p") . '; } ?>'; } protected static function getOperator($op) { - switch (strtolower($op)) - { + switch (strtolower($op)) { case 'or': case '||': return '||'; @@ -565,4 +552,4 @@ class tplCinecturlink2 return '&&'; } } -} \ No newline at end of file +} diff --git a/_uninstall.php b/_uninstall.php index dfb24d5..433a238 100644 --- a/_uninstall.php +++ b/_uninstall.php @@ -1,86 +1,125 @@ addUserAction( - /* type */ 'settings', - /* action */ 'delete_all', - /* ns */ 'cinecturlink2', - /* desc */ __('delete all settings') + /* type */ + 'settings', + /* action */ + 'delete_all', + /* ns */ + 'cinecturlink2', + /* desc */ + __('delete all settings') ); $this->addUserAction( - /* type */ 'tables', - /* action */ 'delete', - /* ns */ 'cinecturlink2', - /* desc */ sprintf(__('delete %s table'), 'cinecturlink2') + /* type */ + 'tables', + /* action */ + 'delete', + /* ns */ + 'cinecturlink2', + /* desc */ + sprintf(__('delete %s table'), 'cinecturlink2') ); $this->addUserAction( - /* type */ 'tables', - /* action */ 'delete', - /* ns */ 'cinecturlink2_cat', - /* desc */ sprintf(__('delete %s table'), 'cinecturlink2_cat') + /* type */ + 'tables', + /* action */ + 'delete', + /* ns */ + 'cinecturlink2_cat', + /* desc */ + sprintf(__('delete %s table'), 'cinecturlink2_cat') ); $this->addUserAction( - /* type */ 'versions', - /* action */ 'delete', - /* ns */ 'cinecturlink2', - /* desc */ __('delete the version number') + /* type */ + 'versions', + /* action */ + 'delete', + /* ns */ + 'cinecturlink2', + /* desc */ + __('delete the version number') ); $this->addUserAction( - /* type */ 'plugins', - /* action */ 'delete', - /* ns */ 'cinecturlink2', - /* desc */ __('delete plugin files') + /* type */ + 'plugins', + /* action */ + 'delete', + /* ns */ + 'cinecturlink2', + /* desc */ + __('delete plugin files') ); $this->addDirectAction( - /* type */ 'settings', - /* action */ 'delete_all', - /* ns */ 'cinecturlink2', - /* desc */ sprintf(__('delete all %s settings'), 'cinecturlink2') + /* type */ + 'settings', + /* action */ + 'delete_all', + /* ns */ + 'cinecturlink2', + /* desc */ + sprintf(__('delete all %s settings'), 'cinecturlink2') ); $this->addDirectAction( - /* type */ 'tables', - /* action */ 'delete', - /* ns */ 'cinecturlink2', - /* desc */ sprintf(__('delete %s table'), 'cinecturlink2') + /* type */ + 'tables', + /* action */ + 'delete', + /* ns */ + 'cinecturlink2', + /* desc */ + sprintf(__('delete %s table'), 'cinecturlink2') ); $this->addDirectAction( - /* type */ 'tables', - /* action */ 'delete', - /* ns */ 'cinecturlink2_cat', - /* desc */ sprintf(__('delete %s table'), 'cinecturlink2_cat') + /* type */ + 'tables', + /* action */ + 'delete', + /* ns */ + 'cinecturlink2_cat', + /* desc */ + sprintf(__('delete %s table'), 'cinecturlink2_cat') ); $this->addDirectAction( - /* type */ 'versions', - /* action */ 'delete', - /* ns */ 'cinecturlink2', - /* desc */ sprintf(__('delete %s version number'), 'cinecturlink2') + /* type */ + 'versions', + /* action */ + 'delete', + /* ns */ + 'cinecturlink2', + /* desc */ + sprintf(__('delete %s version number'), 'cinecturlink2') ); $this->addDirectAction( - /* type */ 'plugins', - /* action */ 'delete', - /* ns */ 'cinecturlink2', - /* description */ sprintf(__('delete %s plugin files'), 'cinecturlink2') -); \ No newline at end of file + /* type */ + 'plugins', + /* action */ + 'delete', + /* ns */ + 'cinecturlink2', + /* description */ + sprintf(__('delete %s plugin files'), 'cinecturlink2') +); diff --git a/_widgets.php b/_widgets.php index c3d8151..21843f8 100644 --- a/_widgets.php +++ b/_widgets.php @@ -1,16 +1,15 @@ '', __('Uncategorized') => 'null']; - $categories = $C2->getCategories(); - while($categories->fetch()) { - $cat_title = html::escapeHTML($categories->cat_title); + $categories = $C2->getCategories(); + while ($categories->fetch()) { + $cat_title = html::escapeHTML($categories->cat_title); $categories_combo[$cat_title] = $categories->cat_id; } $sortby_combo = [ - __('Update date') => 'link_upddt', - __('My rating') => 'link_note', - __('Title') => 'link_title', - __('Random') => 'RANDOM', + __('Update date') => 'link_upddt', + __('My rating') => 'link_note', + __('Title') => 'link_title', + __('Random') => 'RANDOM', __('Number of views') => 'COUNTER' ]; $order_combo = [ - __('Ascending') => 'asc', + __('Ascending') => 'asc', __('Descending') => 'desc' ]; @@ -160,7 +159,7 @@ class cinecturlink2Widget { global $core; - $core->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) @@ -174,13 +173,12 @@ class cinecturlink2Widget if ($w->category) { if ($w->category == 'null') { $params['sql'] = ' AND L.cat_id IS NULL '; - } - elseif (is_numeric($w->category)) { - $params['cat_id'] = (integer) $w->category; + } elseif (is_numeric($w->category)) { + $params['cat_id'] = (int) $w->category; } } - $limit = abs((integer) $w->limit); + $limit = abs((int) $w->limit); // Tirage aléatoire: Consomme beaucoup de ressources! if ($w->sortby == 'RANDOM') { @@ -190,15 +188,15 @@ class cinecturlink2Widget return null; } - $ids= []; - while($big_rs->fetch()) { + $ids = []; + while ($big_rs->fetch()) { $ids[] = $big_rs->link_id; } shuffle($ids); $ids = array_slice($ids, 0, $limit); $params['link_id'] = []; - foreach($ids as $id) { + foreach ($ids as $id) { $params['link_id'][] = $id; } } elseif ($w->sortby == 'COUNTER') { @@ -216,26 +214,25 @@ class cinecturlink2Widget return null; } - $widthmax = (integer) $core->blog->settings->cinecturlink2->cinecturlink2_widthmax; - $style = $widthmax ? ' style="width:' . $widthmax . 'px;"' : ''; + $widthmax = (int) $core->blog->settings->cinecturlink2->cinecturlink2_widthmax; + $style = $widthmax ? ' style="width:' . $widthmax . 'px;"' : ''; $entries = []; - while($rs->fetch()) { - $url = $rs->link_url; - $img = $rs->link_img; - $title = html::escapeHTML($rs->link_title); + while ($rs->fetch()) { + $url = $rs->link_url; + $img = $rs->link_img; + $title = html::escapeHTML($rs->link_title); $author = html::escapeHTML($rs->link_author); - $cat = html::escapeHTML($rs->cat_title); - $note = $w->shownote ? ' (' . $rs->link_note . '/20)' : ''; - $desc = $w->showdesc ? '
    ' . html::escapeHTML($rs->link_desc) . '' : ''; - $lang = $rs->link_lang ? ' hreflang="' . $rs->link_lang . '"' : ''; - $count = abs((integer) $rs->link_count); + $cat = html::escapeHTML($rs->cat_title); + $note = $w->shownote ? ' (' . $rs->link_note . '/20)' : ''; + $desc = $w->showdesc ? '
    ' . html::escapeHTML($rs->link_desc) . '' : ''; + $lang = $rs->link_lang ? ' hreflang="' . $rs->link_lang . '"' : ''; + $count = abs((int) $rs->link_count); # --BEHAVIOR-- cinecturlink2WidgetLinks $bhv = $core->callBehavior('cinecturlink2WidgetLinks', $rs->link_id); - $entries[] = - '

    ' . + $entries[] = '

    ' . ($w->withlink && !empty($url) ? '' : '') . '' . $title . '' . $note . '
    ' . ($w->showauthor ? $author . '
    ' : '') . '
    ' . @@ -245,15 +242,14 @@ class cinecturlink2Widget '

    ' . $bhv; try { - $cur = $core->con->openCursor($C2->table); + $cur = $core->con->openCursor($C2->table); $cur->link_count = ($count + 1); $C2->updLink($rs->link_id, $cur, false); } catch (Exception $e) { - } } # Tirage aléatoire - if ($w->sortby == 'RANDOM' + if ($w->sortby == 'RANDOM' || $w->sortby == 'COUNTER' ) { shuffle($entries); @@ -263,11 +259,12 @@ class cinecturlink2Widget } return $w->renderDiv( - $w->content_only, - 'cinecturlink2list '. $w->class, - '', - ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') . implode(' ',$entries) . - ($w->showpagelink && $core->blog->settings->cinecturlink2->cinecturlink2_public_active ? + $w->content_only, + 'cinecturlink2list ' . $w->class, + '', + ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') . implode(' ', $entries) . + ( + $w->showpagelink && $core->blog->settings->cinecturlink2->cinecturlink2_public_active ? '

    ' . __('More links') . '

    ' : '' ) ); @@ -277,7 +274,7 @@ class cinecturlink2Widget { global $core; - $core->blog->settings->addNamespace('cinecturlink2'); + $core->blog->settings->addNamespace('cinecturlink2'); if (!$core->blog->settings->cinecturlink2->cinecturlink2_active || !$core->blog->settings->cinecturlink2->cinecturlink2_public_active @@ -293,33 +290,31 @@ class cinecturlink2Widget return null; } - $res = []; - $res[] = - '
  • blog->url . $core->url->getBase('cinecturlink2') . '" title="' . __('view all links') . '">' . __('all links') . - ''. ($w->shownumlink ? ' ('. ($C2->getLinks([], true)->f(0)) . ')' : '') . + '' . ($w->shownumlink ? ' (' . ($C2->getLinks([], true)->f(0)) . ')' : '') . '
  • '; - while($rs->fetch()) { - $res[] = - '
  • blog->url . $core->url->getBase('cinecturlink2') . '/' . + $core->blog->settings->cinecturlink2->cinecturlink2_public_caturl . '/' . urlencode($rs->cat_title) . - '" title="'.__('view links of this category') . '">' . + '" title="' . __('view links of this category') . '">' . html::escapeHTML($rs->cat_title) . - ''. ($w->shownumlink ? ' (' . + '' . ($w->shownumlink ? ' (' . ($C2->getLinks(['cat_id' => $rs->cat_id], true)->f(0)) . ')' : '') . '
  • '; } return $w->renderDiv( - $w->content_only, - 'cinecturlink2cat '. $w->class, - '', - ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') . - '' + $w->content_only, + 'cinecturlink2cat ' . $w->class, + '', + ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') . + '' ); } -} \ No newline at end of file +} diff --git a/inc/class.cinecturlink2.php b/inc/class.cinecturlink2.php index f1d28e7..e74abfe 100644 --- a/inc/class.cinecturlink2.php +++ b/inc/class.cinecturlink2.php @@ -1,16 +1,15 @@ blog->settings->addNamespace('cinecturlink2'); - $this->core = $core; - $this->con = $core->con; + $this->core = $core; + $this->con = $core->con; $this->table = $core->prefix . 'cinecturlink2'; - $this->blog = $core->con->escape($core->blog->id); + $this->blog = $core->con->escape($core->blog->id); } /** * Get links - * + * * @param array $params Query params * @param boolean $count_only Count only result * @return record record instance @@ -63,8 +62,7 @@ class cinecturlink2 $content_req .= implode(', ', $params['columns']) . ', '; } - $strReq = - 'SELECT L.link_id, L.blog_id, L.cat_id, L.user_id, L.link_type, ' . + $strReq = 'SELECT L.link_id, L.blog_id, L.cat_id, L.user_id, L.link_type, ' . $content_req . 'L.link_creadt, L.link_upddt, L.link_note, L.link_count, ' . 'L.link_title, L.link_desc, L.link_author, ' . @@ -74,8 +72,7 @@ class cinecturlink2 'C.cat_title, C.cat_desc '; } - $strReq .= - 'FROM '. $this->table . ' L ' . + $strReq .= 'FROM ' . $this->table . ' L ' . 'INNER JOIN ' . $this->core->prefix . 'user U ON U.user_id = L.user_id ' . 'LEFT OUTER JOIN ' . $this->table . '_cat C ON L.cat_id = C.cat_id '; @@ -97,18 +94,18 @@ class cinecturlink2 if (!empty($params['link_id'])) { if (is_array($params['link_id'])) { - array_walk($params['link_id'], function(&$v, $k){ if($v !== null) { $v = (integer) $v;}}); + array_walk($params['link_id'], function (&$v, $k) { if ($v !== null) { $v = (int) $v;}}); } else { - $params['link_id'] = [(integer) $params['link_id']]; + $params['link_id'] = [(int) $params['link_id']]; } $strReq .= 'AND L.link_id ' . $this->con->in($params['link_id']); } if (!empty($params['cat_id'])) { if (is_array($params['cat_id'])) { - array_walk($params['cat_id'], function(&$v, $k) { if($v !== null) { $v = (integer) $v;}}); + array_walk($params['cat_id'], function (&$v, $k) { if ($v !== null) { $v = (int) $v;}}); } else { - $params['cat_id'] = [(integer) $params['cat_id']]; + $params['cat_id'] = [(int) $params['cat_id']]; } $strReq .= 'AND L.cat_id ' . $this->con->in($params['cat_id']); } @@ -145,7 +142,7 @@ class cinecturlink2 /** * Add link - * + * * @param cursor $cur cursor instance */ public function addLink(cursor $cur) @@ -166,17 +163,18 @@ class cinecturlink2 $cur->link_note = 10; } - $cur->link_id = $this->getNextLinkId(); - $cur->blog_id = $this->blog; - $cur->user_id = $this->core->auth->userID(); + $cur->link_id = $this->getNextLinkId(); + $cur->blog_id = $this->blog; + $cur->user_id = $this->core->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; - $cur->link_count = 0; + $cur->link_upddt = date('Y-m-d H:i:s'); + $cur->link_pos = 0; + $cur->link_count = 0; $cur->insert(); $this->con->unlock(); } catch (Exception $e) { $this->con->unlock(); + throw $e; } $this->trigger(); @@ -189,14 +187,14 @@ class cinecturlink2 /** * Update link - * + * * @param integer $id Link ID * @param cursor $cur cursor instance * @param boolean $behavior Call related behaviors */ public function updLink($id, cursor $cur, $behavior = true) { - $id = (integer) $id; + $id = (int) $id; if (empty($id)) { throw new Exception(__('No such link ID')); @@ -204,7 +202,7 @@ class cinecturlink2 $cur->link_upddt = date('Y-m-d H:i:s'); - $cur->update("WHERE link_id = " . $id . " AND blog_id = '" . $this->blog . "' "); + $cur->update('WHERE link_id = ' . $id . " AND blog_id = '" . $this->blog . "' "); $this->trigger(); if ($behavior) { @@ -215,12 +213,12 @@ class cinecturlink2 /** * Delete link - * + * * @param integer $id Link ID */ public function delLink($id) { - $id = (integer) $id; + $id = (int) $id; if (empty($id)) { throw new Exception(__('No such link ID')); @@ -240,7 +238,7 @@ class cinecturlink2 /** * Get next link ID - * + * * @return integer Next link ID */ private function getNextLinkId() @@ -252,7 +250,7 @@ class cinecturlink2 /** * Get categories - * + * * @param array $params Query params * @param boolean $count_only Count only result * @return record record instance @@ -261,15 +259,13 @@ class cinecturlink2 { if ($count_only) { $strReq = 'SELECT count(C.cat_id) '; - } - else { + } else { $content_req = ''; if (!empty($params['columns']) && is_array($params['columns'])) { $content_req .= implode(', ', $params['columns']) . ', '; } - $strReq = - 'SELECT C.cat_id, C.blog_id, C.cat_title, C.cat_desc, ' . + $strReq = 'SELECT C.cat_id, C.blog_id, C.cat_title, C.cat_desc, ' . $content_req . 'C.cat_pos, C.cat_creadt, C.cat_upddt '; } @@ -284,18 +280,18 @@ 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 = (integer) $v; }}); + array_walk($params['cat_id'], function (&$v, $k) { if ($v !== null) { $v = (int) $v; }}); } else { - $params['cat_id'] = [(integer) $params['cat_id']]; + $params['cat_id'] = [(int) $params['cat_id']]; } $strReq .= 'AND C.cat_id ' . $this->con->in($params['cat_id']); } 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 = (integer) $v;}}); + array_walk($params['exclude_cat_id'], function (&$v, $k) { if ($v !== null) {$v = (int) $v;}}); } else { - $params['exclude_cat_id'] = [(integer) $params['exclude_cat_id']]; + $params['exclude_cat_id'] = [(int) $params['exclude_cat_id']]; } $strReq .= 'AND C.cat_id NOT ' . $this->con->in($params['exclude_cat_id']); } @@ -325,7 +321,7 @@ class cinecturlink2 /** * Add category - * + * * @param cursor $cur cursor instance * @return integer New category ID */ @@ -341,15 +337,16 @@ class cinecturlink2 throw new Exception(__('No category description')); } - $cur->cat_id = $this->getNextCatId(); - $cur->cat_pos = $this->getNextCatPos(); - $cur->blog_id = $this->blog; + $cur->cat_id = $this->getNextCatId(); + $cur->cat_pos = $this->getNextCatPos(); + $cur->blog_id = $this->blog; $cur->cat_creadt = date('Y-m-d H:i:s'); - $cur->cat_upddt = date('Y-m-d H:i:s'); + $cur->cat_upddt = date('Y-m-d H:i:s'); $cur->insert(); $this->con->unlock(); } catch (Exception $e) { $this->con->unlock(); + throw $e; } $this->trigger(); @@ -359,13 +356,13 @@ class cinecturlink2 /** * Update category - * + * * @param integer $id Category ID * @param cursor $cur cursor instance */ public function updCategory($id, cursor $cur) { - $id = (integer) $id; + $id = (int) $id; if (empty($id)) { throw new Exception(__('No such category ID')); @@ -373,18 +370,18 @@ class cinecturlink2 $cur->cat_upddt = date('Y-m-d H:i:s'); - $cur->update("WHERE cat_id = " . $id . " AND blog_id = '" . $this->blog . "' "); + $cur->update('WHERE cat_id = ' . $id . " AND blog_id = '" . $this->blog . "' "); $this->trigger(); } /** * Delete category - * + * * @param integer $id Category ID */ public function delCategory($id) { - $id = (integer) $id; + $id = (int) $id; if (empty($id)) { throw new Exception(__('No such category ID')); @@ -397,17 +394,17 @@ class cinecturlink2 ); # Update link cat to NULL - $cur = $this->con->openCursor($this->table); - $cur->cat_id = NULL; + $cur = $this->con->openCursor($this->table); + $cur->cat_id = null; $cur->link_upddt = date('Y-m-d H:i:s'); - $cur->update("WHERE cat_id = " . $id . " AND blog_id = '" . $this->blog . "' "); + $cur->update('WHERE cat_id = ' . $id . " AND blog_id = '" . $this->blog . "' "); $this->trigger(); } /** * Get next category ID - * + * * @return integer Next category ID */ private function getNextCatId() @@ -419,7 +416,7 @@ class cinecturlink2 /** * Get next category position - * + * * @return integer Next category position */ private function getNextCatPos() @@ -440,7 +437,7 @@ class cinecturlink2 /** * Check if a directory exists and is writable - * + * * @param string $root Root * @param string $folder Folder to create into root folder * @param boolean $throw Throw exception or not @@ -453,27 +450,29 @@ class cinecturlink2 if ($throw) { throw new Exception(__('Failed to create public folder for images.')); } + return false; } } + return true; } /** * Get list of public directories - * + * * @param dcCore $core Core instance * @return array Directories */ public static function getPublicDirs($core) { $dirs = []; - $all = files::getDirList($core->blog->public_path); - foreach($all['dirs'] as $dir) { - $dir = substr($dir, strlen($core->blog->public_path) + 1); + $all = files::getDirList($core->blog->public_path); + foreach ($all['dirs'] as $dir) { + $dir = substr($dir, strlen($core->blog->public_path) + 1); $dirs[$dir] = $dir; } return $dirs; } -} \ No newline at end of file +} diff --git a/inc/lib.cinecturlink2.activityreport.php b/inc/lib.cinecturlink2.activityreport.php index cc3a464..5c9a8db 100644 --- a/inc/lib.cinecturlink2.activityreport.php +++ b/inc/lib.cinecturlink2.activityreport.php @@ -1,16 +1,15 @@ activityReport->addLog('cinecturlink2', 'delete', $logs); } -} \ No newline at end of file +} diff --git a/inc/lib.cinecturlink2.context.php b/inc/lib.cinecturlink2.context.php index 37c165b..ef3c6f2 100644 --- a/inc/lib.cinecturlink2.context.php +++ b/inc/lib.cinecturlink2.context.php @@ -1,16 +1,15 @@ c2_pagination === null) { return false; } - $nb_posts = $_ctx->c2_pagination->f(0); + $nb_posts = $_ctx->c2_pagination->f(0); $nb_per_page = $_ctx->c2_params['limit'][1]; - $nb_pages = ceil($nb_posts/$nb_per_page); + $nb_pages = ceil($nb_posts / $nb_per_page); return $nb_pages; } @@ -34,11 +33,12 @@ class cinecturlink2Context } else { $p = 1; } - $p = $p+$offset; + $p = $p + $offset; $n = self::PaginationNbPages(); if (!$n) { return $p; } + return $p > $n || $p <= 0 ? 1 : $p; } @@ -47,14 +47,16 @@ class cinecturlink2Context if (isset($GLOBALS['c2_page_number'])) { return self::PaginationPosition() == 1; } + return true; } public static function PaginationEnd() - { + { if (isset($GLOBALS['c2_page_number'])) { return self::PaginationPosition() == self::PaginationNbPages(); } + return false; } @@ -74,9 +76,10 @@ class cinecturlink2Context } # If search param if (!empty($_GET['q'])) { - $s = strpos($url,'?') !== false ? '&' : '?'; + $s = strpos($url, '?') !== false ? '&' : '?'; $url .= $s . 'q=' . rawurlencode($_GET['q']); } + return $url; } @@ -84,21 +87,22 @@ class cinecturlink2Context { global $_ctx; - if (!isset($_ctx->c2_page_params['cat_id']) + if (!isset($_ctx->c2_page_params['cat_id']) && !isset($_ctx->c2_page_params['cat_title']) ) { return false; } - if (isset($_ctx->c2_page_params['cat_id']) + if (isset($_ctx->c2_page_params['cat_id']) && $_ctx->c2_page_params['cat_id'] == $_ctx->c2_categories->cat_id ) { return true; } - if (isset($_ctx->c2_page_params['cat_title']) + if (isset($_ctx->c2_page_params['cat_title']) && $_ctx->c2_page_params['cat_title'] == $_ctx->c2_categories->cat_title ) { return true; } + return false; } -} \ No newline at end of file +} diff --git a/inc/lib.cinecturlink2.list.php b/inc/lib.cinecturlink2.list.php index ff3c35c..c971e81 100644 --- a/inc/lib.cinecturlink2.list.php +++ b/inc/lib.cinecturlink2.list.php @@ -1,16 +1,15 @@ core = &$core; - $this->rs = &$rs; - $this->rs_count = $rs_count; + $this->core = &$core; + $this->rs = &$rs; + $this->rs_count = $rs_count; $this->html_prev = __('« prev.'); $this->html_next = __('next »'); } @@ -58,33 +57,33 @@ class adminlistCinecturlink2 echo '

    ' . __('No link') . '

    '; } } else { - $pager = new dcPager($page, $this->rs_count, $nb_per_page, 10); + $pager = new dcPager($page, $this->rs_count, $nb_per_page, 10); $links = []; if (isset($_REQUEST['links'])) { foreach ($_REQUEST['links'] as $v) { - $links[(integer) $v] = true; + $links[(int) $v] = true; } } $cols = [ - 'title' => '' . __('Title') . '', - 'author' => '' . __('Author') . '', - 'desc' => '' . __('Description') . '', - 'link' => '' . __('Links') . '', - 'cat' => '' . __('Category') . '', - 'note' => '' . __('Rating') . '', - 'date' => '' . __('Date') . '' + 'title' => '' . __('Title') . '', + 'author' => '' . __('Author') . '', + 'desc' => '' . __('Description') . '', + 'link' => '' . __('Links') . '', + 'cat' => '' . __('Category') . '', + 'note' => '' . __('Rating') . '', + 'date' => '' . __('Date') . '' ]; $cols = new ArrayObject($cols); $this->userColumns('c2link', $cols); - $html_block = - '
    ' . + $html_block = '
    ' . '' . - '' . + ) . '' . '' . '' . implode(iterator_to_array($cols)) . '' . '' . @@ -111,11 +110,11 @@ class adminlistCinecturlink2 { $cols = [ 'check' => '', 'title' => '', 'link' => '', 'cat' => '', 'date' => '' @@ -157,6 +156,6 @@ class adminlistCinecturlink2 $cols = new ArrayObject($cols); $this->userColumns('c2link', $cols); - return '' . implode(iterator_to_array($cols)) . '' . "\n"; + return '' . implode(iterator_to_array($cols)) . '' . "\n"; } -} \ No newline at end of file +} diff --git a/inc/lib.sitemaps.cinecturlink2.php b/inc/lib.sitemaps.cinecturlink2.php index b644bd8..9852186 100644 --- a/inc/lib.sitemaps.cinecturlink2.php +++ b/inc/lib.sitemaps.cinecturlink2.php @@ -1,16 +1,15 @@ blog->settings->addNamespace('sitemaps'); - if ($core->plugins->moduleExists('cinecturlink2') + if ($core->plugins->moduleExists('cinecturlink2') && $core->blog->settings->sitemaps->sitemaps_cinecturlink2_url ) { $freq = $sitemaps->getFrequency($core->blog->settings->sitemaps->sitemaps_cinecturlink2_fq); @@ -33,11 +32,11 @@ class sitemapsCinecturlink2 $sitemaps->addEntry($base, $prio, $freq); $core->blog->settings->addNamespace('cinecturlink2'); - $C2 = new cinecturlink2($core); + $C2 = new cinecturlink2($core); $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 . '/' . $core->blog->settings->cinecturlink2->cinecturlink2_public_caturl . '/' . urlencode($cats->cat_title), $prio, $freq); } } } -} \ No newline at end of file +} diff --git a/index.php b/index.php index 905e968..1fbe244 100644 --- a/index.php +++ b/index.php @@ -1,40 +1,39 @@ auth->getInfo('user_lang'); -$linkimage = $_POST['linkimage'] ?? ''; -$linknote = $_POST['linknote'] ?? ''; -$catid = $_REQUEST['catid'] ?? ''; -$cattitle = $_POST['cattitle'] ?? ''; -$catdesc = $_POST['catdesc'] ?? ''; -$redir = $_REQUEST['redir'] ?? ''; -$part = $_REQUEST['part'] ?? 'links'; -$entries = $_POST['entries'] ?? []; -$headers = ''; +$linkurl = $_POST['linkurl'] ?? ''; +$linkcat = $_POST['linkcat'] ?? null; +$linklang = $_POST['linklang'] ?? $core->auth->getInfo('user_lang'); +$linkimage = $_POST['linkimage'] ?? ''; +$linknote = $_POST['linknote'] ?? ''; +$catid = $_REQUEST['catid'] ?? ''; +$cattitle = $_POST['cattitle'] ?? ''; +$catdesc = $_POST['catdesc'] ?? ''; +$redir = $_REQUEST['redir'] ?? ''; +$part = $_REQUEST['part'] ?? 'links'; +$entries = $_POST['entries'] ?? []; +$headers = ''; $breadcrumb = [ - __('Plugins') => '', + __('Plugins') => '', __('My cinecturlink') => $core->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'links']) ]; if (!in_array($part, ['links', 'link', 'cats', 'cat', 'dellinks', 'updlinksnote', 'updlinkscat'])) { @@ -45,11 +44,11 @@ if (!is_array($entries)) { } try { - $C2 = new cinecturlink2($core); - $categories = $C2->getCategories(); + $C2 = new cinecturlink2($core); + $categories = $C2->getCategories(); $categories_combo = ['-' => '']; - while($categories->fetch()) { - $cat_title = html::escapeHTML($categories->cat_title); + while ($categories->fetch()) { + $cat_title = html::escapeHTML($categories->cat_title); $categories_combo[$cat_title] = $categories->cat_id; } } catch (Exception $e) { @@ -87,10 +86,10 @@ if ($part == 'updlinksnote') { try { // update group of links note if (!empty($entries) && isset($_POST['newlinknote'])) { - while($links->fetch()) { + while ($links->fetch()) { if (in_array($links->link_id, $entries)) { - $cur = $core->con->openCursor($C2->table); - $cur->link_note = (integer) $_POST['newlinknote']; + $cur = $core->con->openCursor($C2->table); + $cur->link_note = (int) $_POST['newlinknote']; $C2->updLink($links->link_id, $cur); } } @@ -113,10 +112,10 @@ if ($part == 'updlinkscat') { try { // update group of links category if (!empty($entries) && !empty($_POST['newcatid'])) { - while($links->fetch()) { + while ($links->fetch()) { if (in_array($links->link_id, $entries)) { - $cur = $core->con->openCursor($C2->table); - $cur->cat_id = (integer) $_POST['newcatid']; + $cur = $core->con->openCursor($C2->table); + $cur->cat_id = (int) $_POST['newcatid']; $C2->updLink($links->link_id, $cur); } } @@ -133,39 +132,41 @@ if ($part == 'updlinkscat') { $core->error->add($e->getMessage()); } $breadcrumb[__('Update links category')] = ''; -} +} if ($part == 'links') { $action_combo = [ - __('Delete') => 'dellinks', + __('Delete') => 'dellinks', __('Change category') => 'updlinkscat', - __('Change rating') => 'updlinksnote' + __('Change rating') => 'updlinksnote' ]; $c2link_filter = new adminGenericFilter($core, 'c2link'); $c2link_filter->add('part', 'links'); $c2link_filter->add(dcAdminFilters::getPageFilter()); $c2link_filter->add(dcAdminFilters::getSelectFilter( - 'catid', __('Category:'), $categories_combo, 'cat_id' + 'catid', + __('Category:'), + $categories_combo, + 'cat_id' )); - $params = $c2link_filter->params(); - $params['link_type'] = 'cinecturlink'; + $params = $c2link_filter->params(); + $params['link_type'] = 'cinecturlink'; $params['no_content'] = true; $links_list = null; try { - $links = $C2->getLinks($params); - $links_counter = $C2->getLinks($params,true)->f(0); - $links_list = new adminlistCinecturlink2($core, $links, $links_counter); + $links = $C2->getLinks($params); + $links_counter = $C2->getLinks($params, true)->f(0); + $links_list = new adminlistCinecturlink2($core, $links, $links_counter); } catch (Exception $e) { $core->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' => $core->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'links'])]) . dcPage::jsFilterControl($c2link_filter->show()) . dcPage::jsLoad(dcPage::getPF('cinecturlink2/js/c2links.js')); } @@ -174,14 +175,15 @@ if ($part == 'link') { $langs_combo = l10n::getISOcodes(true); $notes_combo = range(0, 20); $media_combo = $tmp_media_combo = $dir = null; + try { $allowed_media = ['png', 'jpg', 'gif', 'bmp', 'jpeg']; - $core->media = new dcMedia($core); + $core->media = new dcMedia($core); $core->media->chdir($core->blog->settings->cinecturlink2->cinecturlink2_folder); $core->media->getDir(); - $dir =& $core->media->dir; + $dir = & $core->media->dir; - foreach($dir['files'] as $file) { + foreach ($dir['files'] as $file) { if (!in_array(files::getExtension($file->relname), $allowed_media)) { continue; } @@ -197,7 +199,7 @@ if ($part == 'link') { if (!empty($_POST['save'])) { try { cinecturlink2::makePublicDir( - DC_ROOT . '/' .$core->blog->settings->system->public_path, + DC_ROOT . '/' . $core->blog->settings->system->public_path, $core->blog->settings->cinecturlink2->cinecturlink2_folder ); if (empty($linktitle)) { @@ -210,15 +212,15 @@ if ($part == 'link') { throw new Exception(__('You must provide a link to an image.')); } - $cur = $core->con->openCursor($C2->table); - $cur->link_title = $linktitle; - $cur->link_desc = $linkdesc; + $cur = $core->con->openCursor($C2->table); + $cur->link_title = $linktitle; + $cur->link_desc = $linkdesc; $cur->link_author = $linkauthor; - $cur->link_url = $linkurl; - $cur->cat_id = $linkcat == '' ? null : $linkcat; - $cur->link_lang = $linklang; - $cur->link_img = $linkimage; - $cur->link_note = $linknote; + $cur->link_url = $linkurl; + $cur->cat_id = $linkcat == '' ? null : $linkcat; + $cur->link_lang = $linklang; + $cur->link_img = $linkimage; + $cur->link_note = $linknote; // create a link if (empty($linkid)) { @@ -243,11 +245,12 @@ if ($part == 'link') { __('Link successfully updated.') ); } - $core->adminurl->redirect('admin.plugin.cinecturlink2', + $core->adminurl->redirect( + 'admin.plugin.cinecturlink2', [ - 'part' => 'link', + 'part' => 'link', 'linkid' => $linkid, - 'redir' => $redir + 'redir' => $redir ] ); } catch (Exception $e) { @@ -275,19 +278,18 @@ if ($part == 'link') { if (!empty($linkid)) { $link = $C2->getLinks(['link_id' => $linkid]); if (!$link->isEmpty()) { - $linktitle = $link->link_title; - $linkdesc = $link->link_desc; + $linktitle = $link->link_title; + $linkdesc = $link->link_desc; $linkauthor = $link->link_author; - $linkurl = $link->link_url; - $linkcat = $link->cat_id; - $linklang = $link->link_lang; - $linkimage = $link->link_img; - $linknote = $link->link_note; + $linkurl = $link->link_url; + $linkcat = $link->cat_id; + $linklang = $link->link_lang; + $linkimage = $link->link_img; + $linknote = $link->link_note; } } $breadcrumb[(empty($linkid) ? __('New link') : __('Edit link'))] = ''; - $headers .= - dcPage::jsVars(['dotclear.c2_lang' => $core->auth->getInfo('user_lang')]) . + $headers .= dcPage::jsVars(['dotclear.c2_lang' => $core->auth->getInfo('user_lang')]) . dcPage::jsLoad(dcPage::getPF('cinecturlink2/js/c2link.js')); } @@ -308,9 +310,9 @@ if ($part == 'cats') { $catorder = explode(',', $catorder); } $i = 0; - foreach($catorder as $id) { + foreach ($catorder as $id) { $i++; - $cur = $core->con->openCursor($C2->table . '_cat'); + $cur = $core->con->openCursor($C2->table . '_cat'); $cur->cat_pos = $i; $C2->updCategory($id, $cur); } @@ -329,7 +331,6 @@ if ($part == 'cats') { ); $core->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'cats']); } - } catch (Exception $e) { $core->error->add($e->getMessage()); } @@ -338,8 +339,7 @@ if ($part == 'cats') { $core->auth->user_prefs->addWorkspace('accessibility'); if (!$core->auth->user_prefs->accessibility->nodragdrop) { - $headers .= - dcPage::jsLoad('js/jquery/jquery-ui.custom.js') . + $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')); } @@ -353,9 +353,9 @@ if ($part == 'cat') { if ($exists) { throw new Exception(__('Category with same name already exists.')); } - $cur = $core->con->openCursor($C2->table . '_cat'); + $cur = $core->con->openCursor($C2->table . '_cat'); $cur->cat_title = $cattitle; - $cur->cat_desc = $catdesc; + $cur->cat_desc = $catdesc; $catid = $C2->addCategory($cur); @@ -370,9 +370,9 @@ if ($part == 'cat') { if ($exists) { throw new Exception(__('Category with same name already exists.')); } - $cur = $core->con->openCursor($C2->table . '_cat'); + $cur = $core->con->openCursor($C2->table . '_cat'); $cur->cat_title = $cattitle; - $cur->cat_desc = $catdesc; + $cur->cat_desc = $catdesc; $C2->updCategory($catid, $cur); @@ -393,19 +393,19 @@ if ($part == 'cat') { } catch (Exception $e) { $core->error->add($e->getMessage()); } - $breadcrumb[__('Categories')] = $core->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'cats']); + $breadcrumb[__('Categories')] = $core->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'cats']); $breadcrumb[(empty($catid) ? __('New category') : __('Edit category'))] = ''; } -echo -''.__('Cinecturlink 2').'' . +echo +'' . __('Cinecturlink 2') . '' . $headers . -''. +'' . dcPage::breadcrumb($breadcrumb) . dcPage::notices(); if (!empty($redir)) { - echo '

    ' . __('Back') .'

    '; + echo '

    ' . __('Back') . '

    '; } if (!empty($title)) { echo '

    ' . $title . '

    '; @@ -413,10 +413,10 @@ if (!empty($title)) { if ($part == 'updlinksnote') { if ($links->isEmpty()) { - echo '

    '.__('There is no link').'

    '; + echo '

    ' . __('There is no link') . '

    '; } else { echo '

    ' . __('Links') . '

      '; - while($links->fetch()) { + while ($links->fetch()) { echo '
    • ' . $links->link_title . ' ' . $links->link_note . '/20
    • '; } echo '
    '; @@ -425,19 +425,20 @@ if ($part == 'updlinksnote') { ' . '

    ' . form::number('newlinknote', [ - 'min' => 0, - 'max' => 20, - 'default' => 10 + 'min' => 0, + 'max' => 20, + 'default' => 10 ]) . '/20' . '

    ' . '

    ' . ' ' . - '' . __('Cancel') . ' (c) '; - foreach($entries as $id) { + foreach ($entries as $id) { echo form::hidden(['entries[]'], $id); } - echo + echo form::hidden('part', 'updlinksnote') . form::hidden('redir', $redir) . $core->formNonce() . '

    ' . @@ -447,10 +448,10 @@ if ($part == 'updlinksnote') { if ($part == 'updlinkscat') { if ($links->isEmpty()) { - echo '

    '.__('There is no link').'

    '; + echo '

    ' . __('There is no link') . '

    '; } else { echo '

    ' . __('Links') . '

      '; - while($links->fetch()) { + while ($links->fetch()) { echo '
    • ' . $links->link_title . ' ' . $links->link_note . '/20
    • '; } echo '
    '; @@ -460,13 +461,14 @@ if ($part == 'updlinkscat') { '

    ' . form::combo('newcatid', $categories_combo, $catid) . '

    ' . ' ' . - '' . __('Cancel') . ' (c) '; - foreach($entries as $id) { + foreach ($entries as $id) { echo form::hidden(['entries[]'], $id); } - echo + echo form::hidden('part', 'updlinkscat') . form::hidden('redir', $redir) . $core->formNonce() . '

    ' . @@ -474,29 +476,32 @@ if ($part == 'updlinkscat') { } } -if ($part == "links") { +if ($part == 'links') { $links_redir = $core->adminurl->get('admin.plugin.cinecturlink2', $c2link_filter->values()); - echo + echo '

    ' . - '' . __('Edit categories') .' ' . + '' . __('Edit categories') . ' ' . '

    ' . - '

    ' . __('New Link') .' ' . __('New Category') .'

    '; + '

    ' . __('New Link') . ' ' . __('New Category') . '

    '; if ($links->isEmpty() && !$c2link_filter->show()) { - echo '

    '.__('There is no link').'

    '; + echo '

    ' . __('There is no link') . '

    '; } else { - $c2link_filter->display('admin.plugin.cinecturlink2', + $c2link_filter->display( + 'admin.plugin.cinecturlink2', form::hidden('p', 'cinecturlink2') . form::hidden('part', 'links') ); - $links_list->display($c2link_filter->page, $c2link_filter->nb, + $links_list->display( + $c2link_filter->page, + $c2link_filter->nb, '' . '%s' . @@ -518,8 +523,7 @@ if ($part == "links") { } } -if ($part == "link") { - +if ($part == 'link') { echo ' @@ -529,18 +533,18 @@ if ($part == "link") { form::field('linktitle', 60, 255, html::escapeHTML($linktitle), 'maximal') . '

    ' . + form::field('linkurl', 60, 255, html::escapeHTML($linkurl), 'maximal') . '' . '' . __('Search with Google') . '' . '

    ' . + form::field('linkimage', 60, 255, html::escapeHTML($linkimage), 'maximal') . '' . '' . __('Search with Amazon') . '' . '

    '; @@ -553,9 +557,9 @@ if ($part == "link") {

    ' . - '

    ' . - __('Go to media manager to add image to cinecturlink path.') . + '

    ' . + __('Go to media manager to add image to cinecturlink path.') . '

    '; } @@ -570,17 +574,17 @@ if ($part == "link") { '

    ' . form::number('linknote', [ - 'min' => 0, - 'max' => 20, - 'default' => $linknote + 'min' => 0, + 'max' => 20, + 'default' => $linknote ]) . '/20' . '

    ' . ' ' . - '' . __('Cancel') . ' (c) '. + '' . __('Cancel') . ' (c) ' . '' . form::hidden('linkid', $linkid) . form::hidden('part', 'link') . @@ -590,70 +594,69 @@ if ($part == "link") { '; } -if ($part == "cats") { - echo - '

    ' . __('New Category') .'

    '; + ) . + '">' . __('New Category') . '

    '; if ($categories->isEmpty()) { - echo '

    '.__('There is no category').'

    '; - } - else { + echo '

    ' . __('There is no category') . '

    '; + } else { echo '
    ' . ($filter ? + '' . ( + $filter ? sprintf(__('List of %s links matching the filter.'), $this->rs_count) : sprintf(__('List of links (%s)'), $this->rs_count) - ). '
    ' . - form::checkbox(['entries[]'], $this->rs->link_id, ['checked' => $checked]) . + form::checkbox(['entries[]'], $this->rs->link_id, ['checked' => $checked]) . '' . '' . html::escapeHTML($this->rs->link_title) . '' . @@ -127,16 +126,16 @@ class adminlistCinecturlink2 html::escapeHTML($this->rs->link_desc) . '' . - 'rs->link_url . '" title="' . + html::escapeHTML($this->rs->link_url) . '">' . __('URL') . ' ' . - 'rs->link_img . '" title="' . + html::escapeHTML($this->rs->link_img) . '">' . __('image') . ' ' . '' . '' . html::escapeHTML($this->rs->cat_title) . '' . @@ -147,8 +146,8 @@ class adminlistCinecturlink2 '' . dt::dt2str( - $this->core->blog->settings->system->date_format . ', ' . $this->core->blog->settings->system->time_format, - $this->rs->link_upddt, + $this->core->blog->settings->system->date_format . ', ' . $this->core->blog->settings->system->time_format, + $this->rs->link_upddt, $this->core->auth->getInfo('user_tz') ) . '
    - - + + '; $i = 0; - while($categories->fetch()) { + while ($categories->fetch()) { $id = $categories->cat_id; - echo + echo '' . ' - '; @@ -664,12 +667,12 @@ if ($part == "cats") {
    ' . __('Categories list') . '
    '.__('name').''.__('description').'' . __('name') . '' . __('description') . '
    ' . form::number(['order[' . $id . ']'], [ 'min' => 1, 'max' => $categories->count(), - 'default' => $i +1, + 'default' => $i + 1, 'class' => 'position', 'extra_html' => 'title="' . sprintf(__('position of %s'), html::escapeHTML($categories->cat_title)) . '"' ]) . form::hidden(['dynorder[]', 'dynorder-' . $i], $id) . ' ' . form::checkbox(['items_selected[]', 'ims-' . $i], $id) . '' . html::escapeHTML($categories->cat_title) . ' ' . html::escapeHTML($categories->cat_desc) . '
    -

    '.__('Check to delete').'

    +

    ' . __('Check to delete') . '

    ' . ' ' . - '' . __('Cancel') . ' (c) '. + '' . __('Cancel') . ' (c) ' . '' . form::hidden('im_order', '') . form::hidden('part', 'cats') . @@ -683,19 +686,20 @@ if ($part == 'cat') { $category = $C2->getCategories(['cat_id' => $catid]); if (!$category->isEmpty()) { $cattitle = $category->cat_title; - $catdesc = $category->cat_desc; + $catdesc = $category->cat_desc; } } if ($catid) { $links = $C2->getLinks(['cat_id' => $catid], true)->f(0); - echo '

    ' . (empty($links) ? + echo '

    ' . ( + empty($links) ? __('No link uses this category.') : sprintf(__('A link uses this category.', '%s links use this category.', $links), $links) ) . '

    '; } echo ' - +

    @@ -704,9 +708,9 @@ if ($part == 'cat') { '

    ' . ' ' . - '' . __('Cancel') . ' (c) '. + '' . __('Cancel') . ' (c) ' . (!empty($catid) ? ' ' : '') . form::hidden('catid', $catid) . form::hidden('part', 'cat') . @@ -716,4 +720,4 @@ if ($part == 'cat') { dcPage::helpBlock('cinecturlink2'); -echo ''; \ No newline at end of file +echo '';