Example #1
0
/**
 * Recalculates banner category counters
 *
 * @param string $cat Cat code
 * @return int
 * @global CotDB $db
 */
function cot_brs_sync($cat)
{
    $cond = array(array('category', $cat));
    return brs_model_Banner::count($cond);
}
Example #2
0
 protected function afterDelete()
 {
     // Обновить структуру
     $count = brs_model_Banner::count(array(array('category', $this->_data['category'])));
     static::$_db->update(cot::$db->structure, array('structure_count' => $count), "structure_area='brs' AND structure_code=?", $this->_data['category']);
     cot::$cache && cot::$cache->db->remove('structure', 'system');
 }
Example #3
0
 /**
  * Панель управления
  * Список баннеров
  */
 public function indexAction()
 {
     global $admintitle, $adminpath;
     $admintitle = cot::$L['brs_banners'];
     $adminpath[] = array(cot_url('admin', array('m' => 'brs')), cot::$L['brs_banners']);
     $sortFields = array('id' => 'ID', 'title' => cot::$L['Title'], 'category' => cot::$L['Category'], 'published' => cot::$L['brs_published'], 'client' => cot::$L['brs_client'], 'impressions' => cot::$L['brs_impressions'], 'clicks' => cot::$L['brs_clicks'], 'publish_up' => cot::$L['brs_publish_up'], 'publish_down' => cot::$L['brs_publish_down']);
     $sort = cot_import('s', 'G', 'ALP');
     // order field name
     $way = cot_import('w', 'G', 'ALP', 4);
     // order way (asc, desc)
     $f = cot_import('f', 'G', 'ARR');
     // filters
     $maxrowsperpage = cot::$cfg['maxrowsperpage'];
     if ($maxrowsperpage < 1) {
         $maxrowsperpage = 1;
     }
     list($pg, $d, $durl) = cot_import_pagenav('d', $maxrowsperpage);
     //page number for banners list
     $sort = empty($sort) ? 'title' : $sort;
     $way = empty($way) || !in_array($way, array('asc', 'desc')) ? 'asc' : $way;
     $urlParams = array('m' => 'brs');
     if ($sort != 'title') {
         $urlParams['s'] = $sort;
     }
     if ($way != 'asc') {
         $urlParams['w'] = $way;
     }
     $condition = array();
     if (!empty($f)) {
         foreach ($f as $key => $val) {
             $val = trim(cot_import($val, 'D', 'TXT'));
             if (empty($val) && $val !== '0') {
                 continue;
             }
             if (in_array($key, array('title'))) {
                 $condition[] = array($key, "*{$val}*");
                 $urlParams["f[{$key}]"] = $val;
             } else {
                 $condition[] = array($key, $val);
                 $urlParams["f[{$key}]"] = $val;
             }
         }
     } else {
         $f = array();
     }
     $totallines = brs_model_Banner::count($condition);
     $items = brs_model_Banner::find($condition, $maxrowsperpage, $d, $sort . ' ' . $way);
     $pagenav = cot_pagenav('admin', $urlParams, $d, $totallines, $maxrowsperpage, 'd', '', true);
     $template = array('brs', 'admin', 'list');
     $clients = brs_model_Client::keyValPairs();
     if (!$clients) {
         $clients = array();
     }
     $filterForm = array('hidden' => '', 'title' => array('element' => cot_inputbox('text', 'f[title]', $f['title']), 'label' => brs_model_Banner::fieldLabel('title')), 'category' => array('element' => brs_selectbox_structure('brs', $f['category'], 'f[category]', '', false, false, true), 'label' => brs_model_Banner::fieldLabel('category')), 'client' => array('element' => cot_selectbox($f['client'], 'f[client]', array_keys($clients), array_values($clients)), 'label' => brs_model_Banner::fieldLabel('client')), 'published' => array('element' => cot_selectbox($f['published'], 'f[published]', array(0, 1), array(cot::$L['No'], cot::$L['Yes'])), 'label' => brs_model_Banner::fieldLabel('published')), 'sort' => array('element' => cot_selectbox($sort, 's', array_keys($sortFields), array_values($sortFields), false), 'label' => cot::$L['adm_sort']), 'way' => array('element' => cot_selectbox($way, 'w', array('asc', 'desc'), array(cot::$L['Ascending'], cot::$L['Descending']), false)));
     if (isset(cot::$cfg['plugin']['urleditor']) && cot::$cfg['plugin']['urleditor']['preset'] != 'handy') {
         $filterForm['hidden'] .= cot_inputbox('hidden', 'm', 'brs');
     }
     $view = new View();
     $view->page_title = $admintitle;
     $view->fistNumber = $d + 1;
     $view->items = $items;
     $view->clients = $clients;
     $view->totalitems = $totallines;
     $view->filterForm = $filterForm;
     $view->pagenav = $pagenav;
     //        $view->addNewUrl = $addNewUrl;
     $view->urlParams = $urlParams;
     $view->filter = $f;
     /* === Hook === */
     foreach (cot_getextplugins('brs.admin.list.view') as $pl) {
         include $pl;
     }
     /* ===== */
     return $view->render($template);
 }