diff --git a/index.php b/index.php index 57ba539..d897817 100644 --- a/index.php +++ b/index.php @@ -12,13 +12,12 @@ */ if (!defined('DC_CONTEXT_ADMIN')) { - return null; } if ($core->getVersion('zoneclearFeedServer') != - $core->plugins->moduleInfo('zoneclearFeedServer', 'version')) { - + $core->plugins->moduleInfo('zoneclearFeedServer', 'version') +) { return null; } @@ -33,92 +32,87 @@ $zcfs = new zoneclearFeedServer($core); ############################################################ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') { - - $feed_id = ''; - $feed_name = ''; - $feed_desc = ''; - $feed_owner = ''; - $feed_tweeter = ''; - $feed_url = ''; - $feed_feed = ''; - $feed_lang = $core->auth->getInfo('user_lang'); - $feed_tags = ''; + $feed_id = ''; + $feed_name = ''; + $feed_desc = ''; + $feed_owner = ''; + $feed_tweeter = ''; + $feed_url = ''; + $feed_feed = ''; + $feed_lang = $core->auth->getInfo('user_lang'); + $feed_tags = ''; $feed_get_tags = '0'; - $feed_cat_id = ''; - $feed_status = '0'; - $feed_upd_int = 3600; + $feed_cat_id = ''; + $feed_status = '0'; + $feed_upd_int = 3600; $can_view_page = true; - $feed_headlink = ''; - $feed_link = '%s'; + $feed_headlink = ''; + $feed_link = '%s'; $next_link = $prev_link = $next_headlink = $prev_headlink = null; # Combos - $combo_langs = l10n::getISOcodes(true); - $combo_status = $zcfs->getAllStatus(); - $combo_upd_int = $zcfs->getAllUpdateInterval(); - $combo_categories = array('-' => ''); + $combo_langs = l10n::getISOcodes(true); + $combo_status = $zcfs->getAllStatus(); + $combo_upd_int = $zcfs->getAllUpdateInterval(); + $combo_categories = ['-' => '']; try { - $categories = $core->blog->getCategories(array( - 'post_type' => 'post' - )); + $categories = $core->blog->getCategories(['post_type' => 'post']); while ($categories->fetch()) { $combo_categories[ - str_repeat(' ', $categories->level-1). - '• '.html::escapeHTML($categories->cat_title) + str_repeat(' ', $categories->level-1) . + '• ' . html::escapeHTML($categories->cat_title) ] = $categories->cat_id; } - } - catch (Exception $e) { + } catch (Exception $e) { $core->error->add($e->getMessage()); } # Get entry informations if (!empty($_REQUEST['feed_id'])) { - $feed = $zcfs->getFeeds(array('feed_id' => $_REQUEST['feed_id'])); + $feed = $zcfs->getFeeds(['feed_id' => $_REQUEST['feed_id']]); if ($feed->isEmpty()) { $core->error->add(__('This feed does not exist.')); $can_view_page = false; - } - else { - $feed_id = $feed->feed_id; - $feed_name = $feed->feed_name; - $feed_desc = $feed->feed_desc; - $feed_owner = $feed->feed_owner; - $feed_tweeter = $feed->feed_tweeter; - $feed_url = $feed->feed_url; - $feed_feed = $feed->feed_feed; - $feed_lang = $feed->feed_lang; - $feed_tags = $feed->feed_tags; + } else { + $feed_id = $feed->feed_id; + $feed_name = $feed->feed_name; + $feed_desc = $feed->feed_desc; + $feed_owner = $feed->feed_owner; + $feed_tweeter = $feed->feed_tweeter; + $feed_url = $feed->feed_url; + $feed_feed = $feed->feed_feed; + $feed_lang = $feed->feed_lang; + $feed_tags = $feed->feed_tags; $feed_get_tags = $feed->feed_get_tags; - $feed_cat_id = $feed->cat_id; - $feed_status = $feed->feed_status; - $feed_upd_int = $feed->feed_upd_int; + $feed_cat_id = $feed->cat_id; + $feed_status = $feed->feed_status; + $feed_upd_int = $feed->feed_upd_int; $next_params = array( - 'sql' => 'AND feed_id < '.$feed_id.' ', + 'sql' => 'AND feed_id < ' . $feed_id . ' ', 'limit' => 1 ); $next_rs = $zcfs->getFeeds($next_params); $prev_params = array( - 'sql' => 'AND feed_id > '.$feed_id.' ', + 'sql' => 'AND feed_id > ' . $feed_id . ' ', 'limit' => 1 ); $prev_rs = $zcfs->getFeeds($prev_params); if (!$next_rs->isEmpty()) { - $next_link = sprintf($feed_link,$next_rs->feed_id, - html::escapeHTML($next_rs->feed_name), __('next feed').' »'); + $next_link = sprintf($feed_link, $next_rs->feed_id, + html::escapeHTML($next_rs->feed_name), __('next feed') . ' »'); $next_headlink = sprintf($feed_headlink, 'next', html::escapeHTML($next_rs->feed_name), $next_rs->feed_id); } if (!$prev_rs->isEmpty()) { - $prev_link = sprintf($feed_link,$prev_rs->feed_id, - html::escapeHTML($prev_rs->feed_name), '« '.__('previous feed')); + $prev_link = sprintf($feed_link, $prev_rs->feed_id, + html::escapeHTML($prev_rs->feed_name), '« ' . __('previous feed')); $prev_headlink = sprintf($feed_headlink, 'previous', html::escapeHTML($prev_rs->feed_name), $prev_rs->feed_id); } @@ -127,20 +121,20 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') { if (!empty($_POST['action']) && $_POST['action'] == 'savefeed') { try { - $feed_name = $_POST['feed_name']; - $feed_desc = $_POST['feed_desc']; - $feed_owner = $_POST['feed_owner']; + $feed_name = $_POST['feed_name']; + $feed_desc = $_POST['feed_desc']; + $feed_owner = $_POST['feed_owner']; $feed_tweeter = $_POST['feed_tweeter']; $feed_url = $_POST['feed_url']; - $feed_feed = $_POST['feed_feed']; - $feed_lang = $_POST['feed_lang']; - $feed_tags = $_POST['feed_tags']; - $feed_get_tags = empty($_POST['feed_get_tags']) ? 0 : 1; - $feed_cat_id = $_POST['feed_cat_id']; + $feed_feed = $_POST['feed_feed']; + $feed_lang = $_POST['feed_lang']; + $feed_tags = $_POST['feed_tags']; + $feed_get_tags = empty($_POST['feed_get_tags']) ? 0 : 1; + $feed_cat_id = $_POST['feed_cat_id']; + $feed_upd_int = $_POST['feed_upd_int']; if (isset($_POST['feed_status'])) { $feed_status = (integer) $_POST['feed_status']; } - $feed_upd_int = $_POST['feed_upd_int']; $testfeed_params['feed_feed'] = $feed_feed; if ($feed_id) { @@ -165,85 +159,63 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') { if ($feed_cat_id != '' && !$get_feed_cat_id) { throw new Exception(__('You must provide valid category.')); } - } - catch (Exception $e) { + } catch (Exception $e) { $core->error->add($e->getMessage()); } } - if (!empty($_POST['action']) && $_POST['action'] == 'savefeed' - && !$core->error->flag() - ) { - + if (!empty($_POST['action']) && $_POST['action'] == 'savefeed' && !$core->error->flag()) { $cur = $zcfs->openCursor(); - $cur->feed_name = $feed_name; - $cur->feed_desc = $feed_desc; - $cur->feed_owner = $feed_owner; - $cur->feed_tweeter = $feed_tweeter; - $cur->feed_url = $feed_url; - $cur->feed_feed = $feed_feed; - $cur->feed_lang = $feed_lang; - $cur->feed_tags = $feed_tags; + $cur->feed_name = $feed_name; + $cur->feed_desc = $feed_desc; + $cur->feed_owner = $feed_owner; + $cur->feed_tweeter = $feed_tweeter; + $cur->feed_url = $feed_url; + $cur->feed_feed = $feed_feed; + $cur->feed_lang = $feed_lang; + $cur->feed_tags = $feed_tags; $cur->feed_get_tags = (integer) $feed_get_tags; - $cur->cat_id = $feed_cat_id != '' ? (integer) $feed_cat_id : null; - $cur->feed_status = (integer) $feed_status; - $cur->feed_upd_int = (integer) $feed_upd_int; + $cur->cat_id = $feed_cat_id != '' ? (integer) $feed_cat_id : null; + $cur->feed_status = (integer) $feed_status; + $cur->feed_upd_int = (integer) $feed_upd_int; # Update feed if ($feed_id) { try { # --BEHAVIOR-- adminBeforeZoneclearFeedServerFeedUpdate - $core->callBehavior( - 'adminBeforeZoneclearFeedServerFeedUpdate', - $cur, - $feed_id - ); + $core->callBehavior('adminBeforeZoneclearFeedServerFeedUpdate', $cur, $feed_id); $zcfs->updFeed($feed_id, $cur); # --BEHAVIOR-- adminAfterZoneclearFeedServerFeedUpdate - $core->callBehavior( - 'adminAfterZoneclearFeedServerFeedUpdate', - $cur, - $feed_id - ); + $core->callBehavior('adminAfterZoneclearFeedServerFeedUpdate', $cur, $feed_id); dcPage::addSuccessNotice( __('Feed successfully updated.') ); - http::redirect( - $p_url.'&part=feed&feed_id='.$feed_id + $core->adminurl->redirect( + 'admin.plugin.zoneclearFeedServer', ['part' => 'feed', 'feed_id' => $feed_id] ); - } - catch (Exception $e) { + } catch (Exception $e) { $core->error->add($e->getMessage()); } - } - else { + } else { try { # --BEHAVIOR-- adminBeforeZoneclearFeedServerFeedCreate - $core->callBehavior( - 'adminBeforeZoneclearFeedServerFeedCreate', - $cur - ); + $core->callBehavior('adminBeforeZoneclearFeedServerFeedCreate', $cur); $return_id = $zcfs->addFeed($cur); # --BEHAVIOR-- adminAfterZoneclearFeedServerFeedCreate - $core->callBehavior( - 'adminAfterZoneclearFeedServerFeedCreate', - $cur, - $return_id - ); + $core->callBehavior('adminAfterZoneclearFeedServerFeedCreate', $cur, $return_id); dcPage::addSuccessNotice( __('Feed successfully created.') ); - http::redirect( - $p_url.'&part=feed&feed_id='.$return_id + $core->adminurl->redirect( + 'admin.plugin.zoneclearFeedServer', ['part' => 'feed', 'feed_id' => $return_id] ); - } - catch (Exception $e) { + } catch (Exception $e) { $core->error->add($e->getMessage()); } } @@ -251,29 +223,25 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') { # Prepared entries list if ($feed_id && $can_view_page) { - # Posts action + # action $posts_actions_page = new dcPostsActionsPage( $core, 'plugin.php', [ - 'p' => 'zoneclearFeedServer', + 'p' => 'zoneclearFeedServer', 'part' => 'feed', - 'feed_id' => $feed_id, - '_ANCHOR' => 'entries' + 'feed_id' => $feed_id, + '_ANCHOR' => 'entries' ] ); - if ($posts_actions_page->process()) { return null; } - /* Get posts - -------------------------------------------------------- */ + # filters $post_filter = new adminZcfsPostFilter($core); $post_filter->add('part', 'feed'); $post_filter->add('feed_id', $feed_id); - - # get list params $params = $post_filter->params(); # lexical sort @@ -286,15 +254,14 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') { # --BEHAVIOR-- adminPostsSortbyLexCombo $core->callBehavior('adminPostsSortbyLexCombo', [& $sortby_lex]); - $params['order'] = (array_key_exists($post_filter->sortby, $sortby_lex) ? + $params['no_content'] = true; + $params['feed_id'] = $feed_id; + $params['order'] = (array_key_exists($post_filter->sortby, $sortby_lex) ? $core->con->lexFields($sortby_lex[$post_filter->sortby]) : $post_filter->sortby) . ' ' . $post_filter->order; - $params['no_content'] = true; - - # Get posts + # posts try { - $params['feed_id'] = $feed_id; $posts = $zcfs->getPostsByFeed($params); $counter = $zcfs->getPostsByFeed($params,true); $post_list = new zcfsEntriesList( @@ -302,49 +269,45 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') { $posts, $counter->f(0) ); - } - catch (Exception $e) { + } catch (Exception $e) { $core->error->add($e->getMessage()); } } - # Display + # display echo - '
'; + echo '
'. - ''. - __('New feed').'
'; + '' . + '' . + __('New feed') . '
'; - $feeds_filter->display('admin.plugin.zoneclearFeedServer', form::hidden('p', 'zoneclearFeedServer') . form::hidden('part', 'feeds')); + $feeds_filter->display( + 'admin.plugin.zoneclearFeedServer', + $core->adminurl->getHiddenFormFields('admin.plugin.zoneclearFeedServer', ['part', 'feeds']) + ); $feeds_list->feedsDisplay($feeds_filter->page, $feeds_filter->nb, - '', - false + $feeds_filter->show() ); }