function findListCount($options = array()) { /*$cache = Cache::read('BlogCategoryList'); $cacheKey = 'BlogCategoryList-'.Configure::read('Config.language'); if(!empty($cache[$cacheKey])){ return $cache[$cacheKey]; }*/ App::import('Lib', 'Blog.BlogConfig'); $defOpt = BlogConfig::load('categoryList'); $opt = Set::merge($defOpt, $options); $this->BlogCategory = ClassRegistry::init('Blog.BlogCategory'); $this->BlogCategory->recursive = 1; $categoryList = array(); if ($opt['allCategoriesLink']) { $chTotal = $this->BlogCategory->BlogPost->find('count'); $categoryList[0] = array('id' => null, 'title' => __($opt['allCategoriesLink']['label'], true), 'count' => $chTotal); } $joinModel = $this->BlogCategory->BlogCategoriesBlogPost; $findOpt = array('fields' => array($this->BlogCategory->alias . '.id', $this->BlogCategory->alias . '.title', 'COUNT(' . $this->BlogCategory->BlogPost->alias . '.' . $this->BlogCategory->BlogPost->primaryKey . ') as `count`'), 'conditions' => array($this->BlogCategory->BlogPost->alias . '.active' => true), 'group' => array($this->BlogCategory->alias . '.' . $this->BlogCategory->primaryKey), 'joins' => array(array('alias' => $joinModel->alias, 'table' => $joinModel->table, 'type' => 'INNER', 'conditions' => array($joinModel->alias . '.blog_category_id = ' . $this->BlogCategory->alias . '.' . $this->BlogCategory->primaryKey)), array('alias' => $this->BlogCategory->BlogPost->alias, 'table' => $this->BlogCategory->BlogPost->table, 'type' => 'INNER', 'conditions' => array($joinModel->alias . '.blog_post_id = ' . $this->BlogCategory->BlogPost->alias . '.' . $this->BlogCategory->BlogPost->primaryKey))), 'recursive' => -1); $categories = $this->BlogCategory->find('all', $findOpt); if (!empty($categories)) { foreach ($categories as $k => $cat) { $cb = $cat[0]['count']; if ($cb > 0 || $opt['hideEmpty'] != true) { $categoryList[$cat['BlogCategory']['id']] = array('id' => $cat['BlogCategory']['id'], 'title' => $cat['BlogCategory']['title'], 'count' => $cb); } } } //pr($categories); /*$cache[$cacheKey] = $categoryList; Cache::write('BlogCategoryList', $cache);*/ return $categoryList; }
function __construct($id = false, $table = NULL, $ds = NULL) { if (in_array('Search', App::objects('plugin'))) { $this->actsAs[] = 'Search.Searchable'; } if (in_array('Comment', App::objects('plugin'))) { $this->actsAs[] = 'Comment.Commented'; } App::import('Lib', 'Blog.BlogConfig'); $this->multimedia['multimedia']['fields']['format'] = BlogConfig::load('cropFormats'); parent::__construct($id, $table, $ds); }
function beforeFilter() { parent::beforeFilter(); $this->checked_blogger = false; if (!empty($this->user['User']['id'])) { $this->checked_blogger = $this->Acl->check(array('model' => 'User', 'foreign_key' => $this->user['User']['id']), 'blog_post'); } $this->set('checked_blogger', $this->checked_blogger); $this->allow_blogger_edit = false; if (!empty($this->user['User']['id']) && BlogConfig::load('useBlogger')) { $this->allow_blogger_edit = $this->Acl->check(array('model' => 'User', 'foreign_key' => $this->user['User']['id']), 'blogger_edit'); } //$this->allow_blogger_edit = true; $this->set('allow_blogger_edit', $this->allow_blogger_edit); if (!isset($this->params['admin']) || $this->params['admin'] == false) { //List of categories of blog $listCategories = $this->BlogFunctions->findListCount(); $this->set(compact('listCategories')); //List of Archives $listArchives = $this->BlogFunctions->findArchivesCount(null, $this->lang); $this->set(compact('listArchives')); } }