Beispiel #1
0
 public function prepareMenu()
 {
     switch ($this->lang) {
         case 19:
             $this->menu = array(0 => array('class' => 'card', 'model' => Content::model()->findByPk(1)), 1 => array('class' => 'product', 'model' => Content::model()->findByPk(2)), 2 => array('class' => 'gift', 'model' => Content::model()->findByPk(3)), 3 => array('class' => 'week l1', 'model' => Content::model()->findByPk(4)));
             $this->innerMenu = array(0 => array('class' => 'bottle_product', 'model' => CatalogCategories::model()->findByPk(1)), 1 => array('class' => 'alcohol_product', 'model' => CatalogCategories::model()->findByPk(2)), 2 => array('class' => 'fizz_product', 'model' => CatalogCategories::model()->findByPk(3)), 3 => array('class' => 'accessories_product', 'model' => CatalogCategories::model()->findByPk(4)), 4 => array('class' => 'read_wine_product', 'model' => NewsCategories::model()->findByPk(15)), 5 => array('class' => 'boutique_product', 'model' => null, 'url' => '/boutiques', 'name' => 'О бутиках'));
             $this->catalogMenu = array(0 => array('class' => 'bottle', 'model' => CatalogCategories::model()->findByPk(1)), 1 => array('class' => 'alcohol', 'model' => CatalogCategories::model()->findByPk(2)), 2 => array('class' => 'fizz', 'model' => CatalogCategories::model()->findByPk(3)), 3 => array('class' => 'accessories', 'model' => CatalogCategories::model()->findByPk(4)), 4 => array('class' => 'read_wine', 'model' => NewsCategories::model()->findByPk(15)), 5 => array('class' => 'boutique', 'model' => null, 'url' => '/boutiques', 'name' => 'О бутиках'));
             break;
         case 20:
             $this->menu = array(0 => array('class' => 'card l1', 'model' => Content::model()->findByPk(10)), 1 => array('class' => 'product l1', 'model' => Content::model()->findByPk(11)), 2 => array('class' => 'gift l1', 'model' => Content::model()->findByPk(12)), 3 => array('class' => 'week l1', 'model' => Content::model()->findByPk(13)));
             $this->innerMenu = array(0 => array('class' => 'bottle_product', 'model' => CatalogCategories::model()->findByPk(5)), 1 => array('class' => 'alcohol_product', 'model' => CatalogCategories::model()->findByPk(6)), 2 => array('class' => 'fizz_product', 'model' => CatalogCategories::model()->findByPk(7)), 3 => array('class' => 'accessories_product', 'model' => CatalogCategories::model()->findByPk(8)), 4 => array('class' => 'read_wine_product', 'model' => NewsCategories::model()->findByPk(9)), 5 => array('class' => 'boutique_product', 'model' => null, 'url' => '/boutiques', 'name' => 'About boutiques'));
             $this->catalogMenu = array(0 => array('class' => 'bottle', 'model' => CatalogCategories::model()->findByPk(5)), 1 => array('class' => 'alcohol', 'model' => CatalogCategories::model()->findByPk(6)), 2 => array('class' => 'fizz', 'model' => CatalogCategories::model()->findByPk(7)), 3 => array('class' => 'accessories', 'model' => CatalogCategories::model()->findByPk(8)), 4 => array('class' => 'read_wine', 'model' => NewsCategories::model()->findByPk(9)), 5 => array('class' => 'boutique', 'model' => null, 'url' => '/boutiques', 'name' => 'About boutiques'));
             break;
         case 21:
             $this->menu = array(0 => array('class' => 'card', 'model' => Content::model()->findByPk(14)), 1 => array('class' => 'product l1', 'model' => Content::model()->findByPk(15)), 2 => array('class' => 'gift', 'model' => Content::model()->findByPk(16)), 3 => array('class' => 'week l1', 'model' => Content::model()->findByPk(17)));
             $this->innerMenu = array(0 => array('class' => 'bottle_product', 'model' => CatalogCategories::model()->findByPk(9)), 1 => array('class' => 'alcohol_product', 'model' => CatalogCategories::model()->findByPk(10)), 2 => array('class' => 'fizz_product', 'model' => CatalogCategories::model()->findByPk(11)), 3 => array('class' => 'accessories_product', 'model' => CatalogCategories::model()->findByPk(12)), 4 => array('class' => 'read_wine_product', 'model' => NewsCategories::model()->findByPk(10)), 5 => array('class' => '', 'model' => null, 'url' => '/boutiques', 'name' => 'Boutiques'));
             $this->catalogMenu = array(0 => array('class' => 'bottle', 'model' => CatalogCategories::model()->findByPk(9)), 1 => array('class' => 'alcohol', 'model' => CatalogCategories::model()->findByPk(10)), 2 => array('class' => 'fizz', 'model' => CatalogCategories::model()->findByPk(11)), 3 => array('class' => 'accessories', 'model' => CatalogCategories::model()->findByPk(12)), 4 => array('class' => 'read_wine', 'model' => NewsCategories::model()->findByPk(10)), 5 => array('class' => 'boutique', 'model' => null, 'url' => '/boutiques', 'name' => 'Boutiques'));
             break;
         default:
             $this->menu = array(0 => array('class' => 'card l1', 'model' => Content::model()->findByPk(1)), 1 => array('class' => 'product l1', 'model' => Content::model()->findByPk(2)), 2 => array('class' => 'gift l1', 'model' => Content::model()->findByPk(3)), 3 => array('class' => 'week l1', 'model' => Content::model()->findByPk(4)));
             $this->innerMenu = array(0 => array('class' => 'bottle_product', 'model' => CatalogCategories::model()->findByPk(1)), 1 => array('class' => 'alcohol_product', 'model' => CatalogCategories::model()->findByPk(2)), 2 => array('class' => 'fizz_product', 'model' => CatalogCategories::model()->findByPk(3)), 3 => array('class' => 'accessories_product', 'model' => CatalogCategories::model()->findByPk(4)), 4 => array('class' => 'read_wine_product', 'model' => NewsCategories::model()->findByPk(15)), 5 => array('class' => 'boutique_product', 'model' => null, 'url' => '/boutiques', 'name' => 'О бутиках'));
             $this->catalogMenu = array(0 => array('class' => 'bottle', 'model' => CatalogCategories::model()->findByPk(1)), 1 => array('class' => 'alcohol', 'model' => CatalogCategories::model()->findByPk(2)), 2 => array('class' => 'fizz', 'model' => CatalogCategories::model()->findByPk(3)), 3 => array('class' => 'accessories', 'model' => CatalogCategories::model()->findByPk(4)), 4 => array('class' => 'read_wine', 'model' => NewsCategories::model()->findByPk(15)), 5 => array('class' => 'boutique', 'model' => null, 'url' => '/boutiques', 'name' => 'О бутиках'));
             break;
     }
 }
Beispiel #2
0
 public function actionCategory($category)
 {
     // главная страница категории новостей
     $model = NewsCategories::model()->findByAttributes(array("url" => $category));
     if (empty($model)) {
         $this->redirect("/");
     }
     if ($category == "novosti" || $category == "news" || $category == "Nouvelles") {
         $this->pageTitle = $model->title;
         $criteria = new CDbCriteria();
         $criteria->condition = "category_id =" . $model->id;
         $criteria->addCondition("lang_id = " . $this->lang);
         $modelNews = News::model()->findAll($criteria);
         $this->render("indexNovosti", array("content" => $modelNews, "categoryid" => $model->id, "categoryName" => $category));
     } else {
         $this->pageTitle = $model->title;
         $criteria = new CDbCriteria();
         $criteria->condition = "is_active=1 AND category_id =" . $model->id;
         $criteria->addCondition("lang_id = " . $this->lang);
         $modelNews = News::model()->findAll($criteria);
         $nCriteria = new CDbCriteria();
         $nCriteria->condition = "lang_id =" . $this->lang . " AND is_active=1";
         $ArtNewCategories = NewsCategories::model()->findAll($nCriteria);
         $this->render("indexEct", array("content" => $modelNews, "categories" => $ArtNewCategories));
     }
 }
 /**
  * Parse news categories insert tags
  *
  * @param string $tag
  *
  * @return string|bool
  */
 public function parseCategoriesTags($tag)
 {
     $chunks = trimsplit('::', $tag);
     if ($chunks[0] === 'news_categories') {
         $className = \NewsCategories\NewsCategories::getModelClass();
         $param = NewsCategories::getParameterName();
         if (($newsModel = $className::findPublishedByIdOrAlias(\Input::get($param))) !== null) {
             return $newsModel->{$chunks[1]};
         }
     }
     return false;
 }
Beispiel #4
0
 /**
  * Add the categories to the template
  * @param object
  * @param array
  */
 public function addCategoriesToTemplate($objTemplate, $arrData)
 {
     if (isset($arrData['categories'])) {
         $arrCategories = array();
         $arrCategoriesList = array();
         $categories = deserialize($arrData['categories']);
         if (is_array($categories) && !empty($categories)) {
             $strClass = \NewsCategories\NewsCategories::getModelClass();
             $objCategories = $strClass::findPublishedByIds($categories);
             // Add the categories to template
             if ($objCategories !== null) {
                 /** @var NewsCategoryModel $objCategory */
                 foreach ($objCategories as $objCategory) {
                     $strName = $objCategory->frontendTitle ? $objCategory->frontendTitle : $objCategory->title;
                     $arrCategories[$objCategory->id] = $objCategory->row();
                     $arrCategories[$objCategory->id]['name'] = $strName;
                     $arrCategories[$objCategory->id]['class'] = 'category_' . $objCategory->id . ($objCategory->cssClass ? ' ' . $objCategory->cssClass : '');
                     $arrCategories[$objCategory->id]['linkTitle'] = specialchars($strName);
                     $arrCategories[$objCategory->id]['href'] = '';
                     $arrCategories[$objCategory->id]['hrefWithParam'] = '';
                     $arrCategories[$objCategory->id]['targetPage'] = null;
                     // Add the target page
                     if (($targetPage = $objCategory->getTargetPage()) !== null) {
                         $arrCategories[$objCategory->id]['href'] = $targetPage->getFrontendUrl();
                         $arrCategories[$objCategory->id]['hrefWithParam'] = $targetPage->getFrontendUrl('/' . NewsCategories::getParameterName() . '/' . $objCategory->alias);
                         $arrCategories[$objCategory->id]['targetPage'] = $targetPage;
                     }
                     // Register a function to generate category URL manually
                     $arrCategories[$objCategory->id]['getUrl'] = function (\PageModel $page) use($objCategory) {
                         return $objCategory->getUrl($page);
                     };
                     // Generate categories list
                     $arrCategoriesList[$objCategory->id] = $strName;
                 }
                 // Sort the category list alphabetically
                 asort($arrCategoriesList);
                 // Sort the categories alphabetically
                 uasort($arrCategories, function ($a, $b) {
                     return strnatcasecmp($a['name'], $b['name']);
                 });
             }
         }
         $objTemplate->categories = $arrCategories;
         $objTemplate->categoriesList = $arrCategoriesList;
     }
 }
Beispiel #5
0
 public function taggedAction($tag)
 {
     $tag = $this->filter->sanitize($tag, "alphanum");
     Phalcon_Tag::setTitle('Tagged ' . $tag);
     $category = Categories::findFirst("name='{$tag}'");
     if ($category == false) {
         return $this->_forward('index/index');
     }
     $news = array();
     $newsCategories = NewsCategories::find(array("categories_id='" . $category->id . "'"));
     foreach ($newsCategories as $newCategory) {
         $news[] = $newCategory->getNews();
     }
     $this->view->setVar("activeYear", 0);
     $this->view->setVar("tag", $tag);
     $this->view->setVar("news", $news);
     $this->view->setVar("years", News::count(array('group' => 'year')));
 }
 /**
  * Filter the news by categories
  * @param array
  * @return array
  */
 protected static function filterByCategories($arrColumns)
 {
     $t = static::$strTable;
     // Use the default filter
     if (is_array($GLOBALS['NEWS_FILTER_DEFAULT']) && !empty($GLOBALS['NEWS_FILTER_DEFAULT'])) {
         $arrCategories = static::getCategoriesCache();
         if (!empty($arrCategories)) {
             $arrIds = array();
             // Get the news IDs for particular categories
             foreach ($GLOBALS['NEWS_FILTER_DEFAULT'] as $category) {
                 if (isset($arrCategories[$category])) {
                     $arrIds = array_merge($arrCategories[$category], $arrIds);
                 }
             }
             $strKey = 'category';
             // Preserve the default category
             if ($GLOBALS['NEWS_FILTER_PRESERVE']) {
                 $strKey = 'category_default';
             }
             $arrColumns[$strKey] = "{$t}.id IN (" . implode(',', empty($arrIds) ? array(0) : array_unique($arrIds)) . ")";
         }
     }
     // Exclude particular news items
     if (is_array($GLOBALS['NEWS_FILTER_EXCLUDE']) && !empty($GLOBALS['NEWS_FILTER_EXCLUDE'])) {
         $arrColumns[] = "{$t}.id NOT IN (" . implode(',', array_map('intval', $GLOBALS['NEWS_FILTER_EXCLUDE'])) . ")";
     }
     $strParam = NewsCategories::getParameterName();
     // Try to find by category
     if ($GLOBALS['NEWS_FILTER_CATEGORIES'] && \Input::get($strParam)) {
         $strClass = \NewsCategories\NewsCategories::getModelClass();
         $objCategory = $strClass::findPublishedByIdOrAlias(\Input::get($strParam));
         if ($objCategory === null) {
             return null;
         }
         $arrCategories = static::getCategoriesCache();
         $arrColumns['category'] = "{$t}.id IN (" . implode(',', empty($arrCategories[$objCategory->id]) ? array(0) : $arrCategories[$objCategory->id]) . ")";
     }
     return $arrColumns;
 }
Beispiel #7
0
 public function taggedAction($tag)
 {
     $tag = $this->filter->sanitize($tag, "alphanum");
     $exists = $this->view->getCache()->exists($tag);
     if (!$exists) {
         Phalcon\Tag::setTitle('Tagged ' . $tag);
         $category = Categories::findFirst("name='{$tag}'");
         if ($category == false) {
             return $this->dispatcher->forward(array('controller' => 'index', 'action' => 'index'));
         }
         $news = array();
         $newsCategories = NewsCategories::find(array("categories_id='" . $category->id . "'"));
         foreach ($newsCategories as $newCategory) {
             $news[] = $newCategory->getNews();
         }
         $this->view->setVar("activeYear", 0);
         $this->view->setVar("tag", $tag);
         $this->view->setVar("news", $news);
         $this->view->setVar("years", News::count(array('group' => 'year')));
     }
     $this->view->cache(array("lifetime" => 86400, "key" => $tag));
 }
Beispiel #8
0
 /**
  * Returns the static model of the specified AR class.
  * @param string $className active record class name.
  * @return ANewsCategories the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
 /**
  * Recursively compile the news categories and return it as HTML string
  * @param integer
  * @param integer
  * @return string
  */
 protected function renderNewsCategories($intPid, $arrIds, $strUrl, $intLevel = 1)
 {
     $strClass = \NewsCategories\NewsCategories::getModelClass();
     $objCategories = $strClass::findPublishedByPidAndIds($intPid, $arrIds);
     if ($objCategories === null) {
         return '';
     }
     $strParam = NewsCategories::getParameterName();
     $arrCategories = array();
     // Layout template fallback
     if ($this->navigationTpl == '') {
         $this->navigationTpl = 'nav_newscategories';
     }
     $objTemplate = new \FrontendTemplate($this->navigationTpl);
     $objTemplate->type = get_class($this);
     $objTemplate->cssID = $this->cssID;
     $objTemplate->level = 'level_' . $intLevel;
     $objTemplate->showQuantity = $this->news_showQuantity;
     $count = 0;
     $total = $objCategories->count();
     // Add the "reset categories" link
     if ($this->news_resetCategories && $intLevel == 1) {
         $intNewsQuantity = 0;
         // Get the news quantity
         if ($this->news_showQuantity) {
             $intNewsQuantity = \NewsModel::countPublishedByCategoryAndPids($this->news_archives);
         }
         $blnActive = \Input::get($strParam) ? false : true;
         $arrCategories[] = array('isActive' => $blnActive, 'subitems' => '', 'class' => 'reset first' . ($total == 1 ? ' last' : '') . ' even' . ($blnActive ? ' active' : ''), 'title' => specialchars($GLOBALS['TL_LANG']['MSC']['resetCategories'][1]), 'linkTitle' => specialchars($GLOBALS['TL_LANG']['MSC']['resetCategories'][1]), 'link' => $GLOBALS['TL_LANG']['MSC']['resetCategories'][0], 'href' => ampersand(str_replace('/' . $strParam . '/%s', '', $strUrl)), 'quantity' => $intNewsQuantity);
         $count = 1;
         $total++;
     }
     $intLevel++;
     // Render categories
     while ($objCategories->next()) {
         $strSubcategories = '';
         // Get the subcategories
         if ($objCategories->subcategories) {
             $strSubcategories = $this->renderNewsCategories($objCategories->id, $arrIds, $strUrl, $intLevel);
         }
         $blnActive = $this->objActiveCategory !== null && $this->objActiveCategory->id == $objCategories->id;
         $strClass = 'news_category_' . $objCategories->id . ($objCategories->cssClass ? ' ' . $objCategories->cssClass : '') . (++$count == 1 ? ' first' : '') . ($count == $total ? ' last' : '') . ($count % 2 == 0 ? ' odd' : ' even') . ($blnActive ? ' active' : '') . ($strSubcategories != '' ? ' submenu' : '') . (in_array($objCategories->id, $this->arrCategoryTrail) ? ' trail' : '');
         $strTitle = $objCategories->frontendTitle ?: $objCategories->title;
         $arrRow = $objCategories->row();
         $arrRow['isActive'] = $blnActive;
         $arrRow['subitems'] = $strSubcategories;
         $arrRow['class'] = $strClass;
         $arrRow['title'] = specialchars($strTitle, true);
         $arrRow['linkTitle'] = specialchars($strTitle, true);
         $arrRow['link'] = $strTitle;
         $arrRow['href'] = ampersand(sprintf($strUrl, $GLOBALS['TL_CONFIG']['disableAlias'] ? $objCategories->id : $objCategories->alias));
         $arrRow['quantity'] = 0;
         // Get the news quantity
         if ($this->news_showQuantity) {
             $arrRow['quantity'] = \NewsModel::countPublishedByCategoryAndPids($this->news_archives, $objCategories->id);
         }
         $arrCategories[] = $arrRow;
     }
     $objTemplate->items = $arrCategories;
     return !empty($arrCategories) ? $objTemplate->parse() : '';
 }
Beispiel #10
0
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                <a href="/admin/news/add" class="btn btn-success" title="Добавить новость"><i class="fa fa-plus"></i> Добавить новость</a>
                <a href="/admin/news/categories/add" class="btn btn-success" title="Добавить категорию"><i class="fa fa-plus"></i> Добавить категорию</a>
                <a href="/admin/news/categories/list" class="btn btn-success" title="Управление категориями">Управление категориями</a>
            </div>
            <div class="panel-body">
                <?php 
$this->widget('CCustomGridView', array('id' => 'news-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'cookey' => 'news-size', 'columns' => array(array('name' => 'id', 'headerHtmlOptions' => array('style' => 'width: 100px')), array('class' => 'booster.widgets.TbEditableColumn', 'name' => 'category_id', 'value' => 'NewsCategories::model()->findByPk($data->category_id)->name', 'editable' => array('url' => $this->createUrl('eip'), 'placement' => 'right', 'type' => 'select', 'source' => CHtml::listData(NewsCategories::model()->findAll(), "id", "name")), 'filter' => CHtml::dropDownList("News[category_id]", '', CHtml::listData(NewsCategories::model()->findAll(), "id", "name"), array("class" => "form-control")), 'headerHtmlOptions' => array('style' => 'width: 130px')), array('class' => 'booster.widgets.TbEditableColumn', 'name' => 'name', 'editable' => array('url' => $this->createUrl('eip'), 'placement' => 'right'), 'filter' => CHtml::tag("input", array("name" => "News[name]", "type" => "text", "class" => "form-control"))), array('class' => 'booster.widgets.TbEditableColumn', 'name' => 'url', 'editable' => array('url' => $this->createUrl('eip'), 'placement' => 'right'), 'filter' => CHtml::tag("input", array("name" => "News[url]", "type" => "text", "class" => "form-control"))), array('class' => 'booster.widgets.TbEditableColumn', 'name' => 'lang_id', 'value' => 'ListsItems::model()->findByPk($data->lang_id)->name', 'editable' => array('url' => $this->createUrl('eip'), 'placement' => 'right', 'type' => 'select', 'source' => CHtml::listData(ListsItems::model()->findAllByAttributes(array("list_id" => 11)), "id", "name")), 'filter' => CHtml::dropDownList("News[lang_id]", '', array_merge(array('' => ''), CHtml::listData(ListsItems::model()->findAllByAttributes(array("list_id" => 11)), "id", "name")), array("class" => "form-control")), 'headerHtmlOptions' => array('style' => 'width: 70px')), array('class' => 'CCustomTogleColumn', 'toggleAction' => 'toggleActivity', 'name' => 'is_active', 'headerHtmlOptions' => array('style' => 'width: 120px')), array('header' => 'Действие', 'class' => 'CCustomButtonColumn')), 'pager' => array('class' => 'CCustomPager')));
?>
            </div>
        </div>
    </div>
</div>
Beispiel #11
0
 public function actionToggleActivity()
 {
     if (isset($_REQUEST['pk'])) {
         $model = NewsCategories::model()->findByPk($_REQUEST['pk']);
         if (is_object($model)) {
             $model->is_active = $model->is_active ? 0 : 1;
             if ($model->save()) {
                 return true;
             }
         }
     }
     return false;
 }
 /**
  * Get the category URL
  *
  * @param \PageModel $page
  *
  * @return string
  */
 public function getUrl(\PageModel $page)
 {
     $page->loadDetails();
     return $page->getFrontendUrl('/' . NewsCategories::getParameterName($page->rootId) . '/' . $this->alias);
 }
Beispiel #13
0
				  
		
				  
                        <div class="blog_rock clearfix">
								  <?php 
if (!empty($model->related)) {
    foreach ($model->related as $numb) {
        $array[] = $numb->related_object_id;
    }
    $criteria = new CDbCriteria();
    $criteria->addInCondition('id', $array);
    $svNews = News::model()->findAll($criteria);
    $i = 0;
    foreach ($svNews as $items) {
        $criteriaa = new CDbCriteria();
        $svNews = NewsCategories::model()->findByAttributes(array("id" => $items->category_id));
        $url = "/news/" . $svNews->url . "/" . $items->url;
        if ($i == 0) {
            $class = "rock_content";
        } else {
            $class = "";
        }
        ?>
								   <div class="cellule <?php 
        echo $class;
        ?>
">
										<a href="<?php 
        echo $url;
        ?>
" class="bondfoto"><img src="<?php 
Beispiel #14
0
                                        <?php 
    }
    ?>
                                    </select>
                                    <?php 
}
?>
                            </div>
                            <div class="form-group">
                                <label>Название</label>
                                <input type="text" name="data[name]" value="" class="form-control alt-name-source copy-to" />
                            </div>
                            <div class="form-group">
                                <label>Категория</label>
                                <?php 
$categories = NewsCategories::model()->findAllByAttributes(array("is_active" => 1, "is_deleted" => 0));
if (is_array($categories) && count($categories)) {
    ?>
                                    <select name="data[category_id]" class="form-control">
                                    <?php 
    foreach ($categories as $cat) {
        ?>
                                        <option value="<?php 
        echo $cat->id;
        ?>
"><?php 
        echo CHtml::encode($cat->name);
        ?>
</option>
                                        <?php 
    }
Beispiel #15
0
</div>
<?php 
}
if (isset($news) && is_array($news) && count($news)) {
    switch ($this->lang) {
        case 19:
            $category = NewsCategories::model()->findByPk(1);
            break;
        case 20:
            $category = NewsCategories::model()->findByPk(7);
            break;
        case 21:
            $category = NewsCategories::model()->findByPk(8);
            break;
        default:
            $category = NewsCategories::model()->findByPk(1);
            break;
    }
    ?>
<div id="news"  class="clearfix">
    <div class="about"><a href="<?php 
    echo $category->getUrl();
    ?>
"><?php 
    echo $category->name;
    ?>
</a></div>
    <div class="cellNews">
        <ul>
            <?php 
    function renderMonthName($monthValue, $lang)
 /**
  * Get the filtered news IDs
  *
  * @return array
  */
 protected function getFilteredNewsIds()
 {
     $arrCategories = \NewsModel::getCategoriesCache();
     if (empty($arrCategories)) {
         return array();
     }
     $arrIds = array();
     // Use the default filter
     if (is_array($this->news_filterDefault) && !empty($this->news_filterDefault)) {
         foreach ($this->news_filterDefault as $category) {
             if (isset($arrCategories[$category])) {
                 $arrIds = array_merge($arrCategories[$category], $arrIds);
             }
         }
     }
     $strParam = NewsCategories::getParameterName();
     // Current category
     if ($this->news_filterCategories && \Input::get($strParam)) {
         $strClass = \NewsCategories\NewsCategories::getModelClass();
         $objCategory = $strClass::findPublishedByIdOrAlias(\Input::get($strParam));
         if ($objCategory === null) {
             return array();
         }
         // Preserve the default filter
         if ($this->news_filterPreserve) {
             $arrIds = array_merge($arrCategories[$objCategory->id], $arrIds);
         } else {
             $arrIds = $arrCategories[$objCategory->id];
         }
     }
     return array_unique($arrIds);
 }
Beispiel #17
0
    if (stripos($new->title, 'testing') !== false) {
        $categories['testing'] = true;
    }
    if (stripos($new->title, 'security') !== false) {
        $categories['security'] = true;
    }
    if (preg_match('/ [0-9]{4}/', $new->title)) {
        $categories['conf'] = true;
    }
    if (preg_match('/RC[0-9]{1}/', $new->title)) {
        $categories['testing'] = true;
    }
    if (stripos($new->title, 'alpha') !== false) {
        $categories['testing'] = true;
    }
    if (stripos($new->title, 'beta') !== false) {
        $categories['testing'] = true;
    }
    if (stripos($new->title, 'documentation') !== false) {
        $categories['documentation'] = true;
    }
    if (count($categories) == 0) {
        $categories['other'] = true;
    }
    foreach ($categories as $category => $one) {
        $newCategory = new NewsCategories();
        $newCategory->news_id = $new->id;
        $newCategory->categories_id = $categoriesCode[$category];
        $newCategory->save();
    }
}
Beispiel #18
0
        echo count($modelNews);
        ?>
 <?php 
        echo Localization::translate("result_name_search", $this->lang);
        ?>
</a></p>
                    <div id="new-aboutWine" class="clearfix">
                    <div id="blog" class="clearfix">
                    <?php 
        if (!empty($modelNews)) {
            $i = 0;
            foreach ($modelNews as $object) {
                if ($i == 3) {
                    break;
                }
                $url = NewsCategories::model()->findByAttributes(array("id" => $object->category_id));
                ?>
					  <div class="cellule">
                            <a href="/news/<?php 
                echo $url->url;
                ?>
/<?php 
                echo $object->url;
                ?>
" class="bondfoto"><img src="<?php 
                echo $object->anons_pic;
                ?>
" alt="<?php 
                echo $object->name;
                ?>
"></a>