/** * Список рассылок * @return string * @throws Exception */ public function indexAction() { global $admintitle, $adminpath, $Ls; $admintitle = cot::$L['subscribe_subscribes']; $adminpath[] = array(cot_url('admin', array('m' => 'subscribe')), $admintitle); $sort = cot_import('s', 'G', 'ALP'); // order field name $way = cot_import('w', 'G', 'ALP', 4); // order way (asc, desc) $maxrowsperpage = cot::$cfg['maxrowsperpage']; if ($maxrowsperpage < 1) { $maxrowsperpage = 1; } list($pg, $d, $durl) = cot_import_pagenav('d', $maxrowsperpage); //page number for pages list /* === Hook === */ foreach (cot_getextplugins('subscribe.admin.list.first') as $pl) { include $pl; } /* ===== */ $sort = empty($sort) ? 'title' : $sort; $way = empty($way) || !in_array($way, array('asc', 'desc')) ? 'asc' : $way; $urlParams = array('m' => 'subscribe'); if ($sort != 'title') { $urlParams['s'] = $sort; } if ($way != 'asc') { $urlParams['w'] = $way; } $where = array(); $states = array(-1 => cot::$R['code_option_empty'], 0 => cot::$L['Disabled'], 1 => cot::$L['Enabled']); // Фильтры $allowedFilters = array('id', 'title', 'active'); $f = cot_import('f', 'G', 'ARR'); $filterForm = array('hidden' => ''); if (!empty($f)) { foreach ($f as $key => $val) { if (!in_array($key, $allowedFilters)) { unset($f[$key]); } } if (!empty($f['id'])) { $where['id'] = array('id', $f['id']); $urlParams['f[id]'] = $f['id']; } $f['active'] = isset($_GET['f']['active']) ? cot_import($_GET['f']['active'], 'D', 'INT') : -2; if ($f['active'] == -1) { unset($where['active']); } elseif ($f['active'] >= 0 && $f['active'] < 2) { $where['active'] = array('active', $f['active']); $urlParams['f[active]'] = $f['active']; } if (!empty($f['title'])) { $where['title'] = array('title', '*' . $f['title'] . '*'); $urlParams['f[title]'] = $f['title']; } } if (isset(cot::$cfg['plugin']['urleditor']) && cot::$cfg['plugin']['urleditor']['preset'] != 'handy') { $filterForm['hidden'] .= cot_inputbox('hidden', 'm', 'brs'); } $condition = array(); foreach ($where as $key => $val) { $condition[] = $val; } $order = array(array($sort, $way)); /* === Hook === */ foreach (cot_getextplugins('subscribe.admin.list.query') as $pl) { include $pl; } /* ===== */ $totallines = subscribe_model_Subscribe::count($condition); $items = null; if ($totallines > 0) { $items = subscribe_model_Subscribe::find($condition, $maxrowsperpage, $d, $order); } // Если передан номер страницы превышающий максимальный if (empty($items) && $totallines > 0 && $pg > 1) { $totalpages = ceil($totallines / $maxrowsperpage); $args = $urlParams; if ($totalpages > 1) { if (cot::$cfg['easypagenav']) { $args['d'] = $totalpages; } else { $args['d'] = ($totalpages - 1) * $maxrowsperpage; } } cot_redirect(cot_url('admin', $args, '', true)); } $addNewUrl = cot_url('admin', array('m' => 'subscribe', 'a' => 'edit')); /* === Hook === */ foreach (cot_getextplugins('subscribe.admin.list.main') as $pl) { include $pl; } /* ===== */ $pagenav = cot_pagenav('admin', $urlParams, $d, $totallines, $maxrowsperpage, 'd', '', true); if (empty($pagenav['current'])) { $pagenav['current'] = 1; } $pagenav['page'] = $pagenav['current']; if (!cot::$cfg['easypagenav']) { $pagenav['page'] = ($pagenav['current'] - 1) * $maxrowsperpage; } $template = array('subscribe', 'admin', 'list'); $view = new View(); $view->page_title = $admintitle; $view->fistNumber = $d + 1; $view->items = $items; $view->totalitems = $totallines; $view->filterForm = $filterForm; $view->pagenav = $pagenav; $view->addNewUrl = $addNewUrl; $view->urlParams = $urlParams; $view->filter = $f; $view->states = $states; /* === Hook === */ foreach (cot_getextplugins('subscribe.admin.list.view') as $pl) { include $pl; } /* ===== */ return $view->render($template); }
/** * Список рассылок */ public function indexAction() { $maxrowsperpage = cot::$cfg['maxrowsperpage']; if ($maxrowsperpage < 1) { $maxrowsperpage = 1; } list($pg, $d, $durl) = cot_import_pagenav('d', $maxrowsperpage); //page number for pages list $sort = 'title'; $way = 'asc'; /* === Hook === */ foreach (cot_getextplugins('subscribe.list.first') as $pl) { include $pl; } /* ===== */ $urlParams = array(); $canonicalUrlParams = array(); if ($durl > 1) { $canonicalUrlParams['d'] = $durl; } $where = array(); cot::$out['subtitle'] = $title = cot::$L['subscribe_subscribes']; // Building the canonical URL cot::$out['canonical_uri'] = cot_url('subscribe', $canonicalUrlParams); $condition = array(array('active', 1), array('periodical', 1)); $order = array(array('active', 'desc'), array($sort, $way)); $userSubscribesCondition = array(); if (cot::$usr['id'] > 0) { $userSubscribesCondition[] = array('active', 1); $userSubscribesCondition[] = array('user', cot::$usr['id']); if (!empty(cot::$usr['profile']['user_email'])) { //$userSubscribesCondition[] = array('email', cot::$usr['profile']['user_email'], '=', 'OR'); $userSubscribesCondition = array(array('SQL', 'active=1 AND (user='******'id'] . ' OR email=' . cot::$db->quote(cot::$usr['profile']['user_email']) . ')')); } } /* === Hook === */ foreach (cot_getextplugins('subscribe.list.query') as $pl) { include $pl; } /* ===== */ $totallines = subscribe_model_Subscribe::count($condition); $items = null; if ($totallines > 0) { $items = subscribe_model_Subscribe::find($condition, $maxrowsperpage, $d, $order); } // Подписки пользователя $userSubscribes = null; $userSubscribesIds = array(); if (!empty($items)) { if (cot::$usr['id'] > 0) { $userSubscribes = subscribe_model_Subscriber::find($userSubscribesCondition, 0, 0, array(array('active', 'desc'))); if (!empty($userSubscribes)) { foreach ($userSubscribes as $usRow) { $userSubscribesIds[] = $usRow->rawValue('subscribe'); } } } } /* === Hook === */ foreach (cot_getextplugins('subscribe.list.main') as $pl) { include $pl; } /* ===== */ if (cot::$usr['id'] > 0) { Resources::linkFileFooter(cot::$cfg['modules_dir'] . '/subscribe/js/subscriber.js'); } $crumbs = array(cot::$L['subscribe_subscribes']); $pagenav = cot_pagenav('subscribe', $urlParams, $d, $totallines, $maxrowsperpage); if (empty($pagenav['current'])) { $pagenav['current'] = 1; } $breadcrumbs = ''; if (!empty($crumbs)) { $breadcrumbs = cot_breadcrumbs($crumbs, cot::$cfg['homebreadcrumb'], true); } $template = array('subscribe', 'list'); // $pageUrlParams = $urlParams; // if($durl > 1) $pageUrlParams['d'] = $durl; $view = new View(); $view->breadcrumbs = $breadcrumbs; $view->page_title = htmlspecialchars($title); $view->items = $items; $view->userSubscribes = $userSubscribes; $view->userSubscribesIds = $userSubscribesIds; $view->totalitems = $totallines; $view->pagenav = $pagenav; $view->urlParams = $urlParams; // $view->pageUrlParams = $pageUrlParams; /* === Hook === */ foreach (cot_getextplugins('subscribe.list.view') as $pl) { include $pl; } /* ===== */ return $view->render($template); }