object(Articles)#296 (21) { ["_oldTags":"Articles":private]=> string(3) "Yii" ["_linkStr"]=> string(20) "yii_1_poisk_po_saitu" ["widget"]=> int(1) ["dir"]=> string(36) "upload/articles/yii_1_poisk_po_saitu" ["_url":"Articles":private]=> NULL ["_categories":"Articles":private]=> NULL ["categoryId"]=> string(1) "7" ["layout1"]=> string(0) "" ["referer"]=> string(0) "" ["attributesArray"]=> array(0) { } ["_new":"CActiveRecord":private]=> bool(false) ["_attributes":"CActiveRecord":private]=> array(26) { ["id"]=> string(2) "47" ["category"]=> string(1) "7" ["categoryOn"]=> string(1) "1" ["level"]=> string(1) "0" ["name"]=> string(33) "Yii 1: поиск по сайту" ["nameOn"]=> string(1) "1" ["linkStr"]=> string(20) "yii_1_poisk_po_saitu" ["text"]=> string(6071) "

Для проекта на Yii 1 сделаем поиск по статьям.

Поиск будет производиться по тегам и слову/словочетанию.

Сам код контроллера 



<?php

class SearchController extends Controller {

    public function actionTag($tag) {
        $tags = CHtml::encode($tag);
        if (isset($tags)) {
            $criteria = new CDbCriteria(array(
                'condition' => 'status=1',
                'order' => 'updated DESC',
            ));
            $criteria->addSearchCondition('tags', $tags);

            $dataProvider = new CActiveDataProvider('Articles', array(
                'pagination' => array(
                    'pageSize' => 7,
                    'pageVar' => 'page',
                ),
                'criteria' => $criteria,
            ));
            if ($dataProvider) {
                $this->breadcrumbs = array('Поиск по тегу: "' . $tags . '"');
                $this->pageTitle('Поиск по тегу: "' . $tags . '"');
                $this->render('tag', array(
                    'dataProvider' => $dataProvider,
                    'tag' => $tags,
                ));
            } else
                throw new CHttpException(404, 'Page not found');
        } else
            throw new CHttpException(404, 'Page not found');
    }

    public function actionIndex() {
        $query = Yii::app()->request->getParam('searchword', null);
        if (iconv_strlen($query, 'UTF-8') < 3) {
            if (isset($_GET['searchword']))
                Yii::app()->user->setFlash("error", "Минимальная длина слова для поиска должна быть больше 3 символов!");
            $query = "";
			$this->pageTitle('Поиск');
			$this->breadcrumbs = array('Поиск');
            $this->render('search');
        }
        else {
            $criteria = new CDbCriteria();
	    $criteria->addSearchCondition('status', 1);
            $criteria->addSearchCondition('name', $query);

            $criteria->addSearchCondition('text', $query, true, 'OR');

            $dataProvider = new CActiveDataProvider('Articles', array(
                'pagination' => array(
                    'pageSize' => 7, 
                    'pageVar' => 'page',
                ),
                'criteria' => $criteria,
            ));

            if ($dataProvider) {
                $this->breadcrumbs = array('Поиск: "' . $query . '"');
                $this->pageTitle('Поиск: "' . $query . '"');
                $this->render('index', array(
                    'dataProvider' => $dataProvider,
                    'query' => $query,
                ));
            } else {
                throw new CHttpException(404, 'Page not found');
            }
        }
    }

}

Функция $this->pageTitle('Поиск по тегу: "' . $tags . '"'); класса Controller устанавливает title страницы.

Ее код:


<?php

class Controller extends CController {

...
public function pageTitle($title) {
        $_title = CHtml::encode($title);
        if ($this->nameTitle) {
            return $this->pageTitle = $this->name . " - " . $_title;
        } else {
            return $this->pageTitle = "" . $_title;
        }
    }
...

}

Все будет выводиться с помощью стандартного виджета Yii CListView.

При выводе найденных статей, используется функция Helper::getFragment($name, $query), которая выводит сокращенное название статьи и Helper::getDescription($text), которая выводит описание статьи до разметки в тексте "<p><!-- pagebreak --></p>".

Далее ставиться ссылка "подробнее".

 

У меня эти функции в классе Helper, в котором находятся необходимые функции форматирования.

Код функций:


<?php

...
    public static function getFragment($text, $word, $symb = 200) {
        $text = strip_tags($text);
        $word = strip_tags($word);
        if ($word) {
            $pos = max(mb_stripos($text, $word, null, 'UTF-8') - 100, 0);
            $fragment = mb_substr($text, $pos, $symb, 'UTF-8');
            $highlighted = preg_replace('~(' . $word . ')~ui', '$1', $fragment);
        } else {
            $highlighted = mb_substr($text, 0, $symb, 'UTF-8');
        }
        return $highlighted;
    }
	
    public static function getDescription($text) {
        $_text=$text;
		$text = strstr($text, 'pagebreak');
		if($text !== false){		
			$text = explode("<p><!-- pagebreak --></p>", $_text);      
			return $text[0];
		} else {
			return "";
		}
    }
...


Скачать пример поиска на Yii.

Этот пример не надеется на премию "лучший пример поиска на Yii" ! =)
" ["layout"]=> string(11) "column2-8-4" ["avtor"]=> string(0) "" ["avtorOn"]=> string(1) "0" ["source"]=> string(0) "" ["sourceOn"]=> string(1) "0" ["status"]=> string(1) "1" ["image"]=> string(0) "" ["viewInRss"]=> string(1) "1" ["isHome"]=> string(1) "0" ["seoDescr"]=> string(77) "Yii 1: поиск по сайту. Как сделать поиск на Yii?" ["seoKey"]=> string(15) "yii, поиск" ["tags"]=> string(3) "Yii" ["tagsOn"]=> string(1) "1" ["dataOn"]=> string(1) "0" ["numViews"]=> int(2516) ["numViewsOn"]=> string(1) "1" ["updated"]=> int(1664700901) ["created"]=> string(10) "1570482000" } ["_related":"CActiveRecord":private]=> array(1) { ["categories"]=> object(Category)#328 (18) { ["view1"]=> string(0) "" ["ierarh"]=> int(0) ["oldLinkStr"]=> string(0) "" ["categoryId"]=> NULL ["layout1"]=> string(0) "" ["referer"]=> string(0) "" ["attributesArray"]=> array(0) { } ["_new":"CActiveRecord":private]=> bool(false) ["_attributes":"CActiveRecord":private]=> array(15) { ["id"]=> string(1) "7" ["parentId"]=> string(1) "0" ["level"]=> string(1) "0" ["linkStr"]=> string(3) "web" ["name"]=> string(24) "Web-технологии" ["text"]=> string(122) "
Описываются примеры реализации технологий WEB
" ["layout"]=> string(11) "column2-8-4" ["view"]=> string(7) "default" ["viewArt"]=> string(1) "1" ["viewArtAll"]=> string(1) "0" ["viewParent"]=> string(1) "0" ["sortArt"]=> string(0) "" ["status"]=> string(1) "1" ["updated"]=> string(10) "1617707774" ["created"]=> string(10) "1398888000" } ["_related":"CActiveRecord":private]=> array(0) { } ["_c":"CActiveRecord":private]=> NULL ["_pk":"CActiveRecord":private]=> string(1) "7" ["_alias":"CActiveRecord":private]=> string(1) "t" ["_errors":"CModel":private]=> array(0) { } ["_validators":"CModel":private]=> NULL ["_scenario":"CModel":private]=> string(6) "update" ["_e":"CComponent":private]=> array(2) { ["onbeforesave"]=> object(CList)#331 (5) { ["_d":"CList":private]=> array(1) { [0]=> array(2) { [0]=> object(AutoTimestampBehavior)#329 (6) { ["created"]=> string(7) "created" ["modified"]=> string(7) "updated" ["_enabled":"CBehavior":private]=> bool(true) ["_owner":"CBehavior":private]=> *RECURSION* ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } [1]=> string(10) "beforeSave" } } ["_c":"CList":private]=> int(1) ["_r":"CList":private]=> bool(false) ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } ["onafterconstruct"]=> object(CList)#333 (5) { ["_d":"CList":private]=> array(1) { [0]=> array(2) { [0]=> object(AdminBehavior)#330 (8) { ["columns"]=> array(10) { ["id"]=> array(3) { ["name"]=> string(2) "id" ["header"]=> string(1) "#" ["filter"]=> string(0) "" } [0]=> array(8) { ["class"]=> string(13) "DToggleColumn" ["name"]=> string(4) "name" ["header"]=> string(16) "Название" ["type"]=> string(4) "link" ["model"]=> string(8) "Category" ["titles"]=> array(1) { [1]=> string(12) "$model->name" } ["linkUrl"]=> string(87) ""/admin/category/update/".$data->id.($data->parentId ? "?parentId=".$data->parentId:"")" ["htmlOptions"]=> array(1) { ["style"]=> string(11) "width:400px" } } [1]=> array(9) { ["class"]=> string(13) "DToggleColumn" ["name"]=> string(8) "parentId" ["header"]=> string(0) "" ["type"]=> string(7) "linkCat" ["model"]=> string(8) "Category" ["value"]=> string(67) ""Подкатегорий: ".count(Category::findChilds($data->id))" ["linkUrl"]=> string(38) ""/admin/category/?parentId=".$data->id" ["htmlOptions"]=> array(1) { ["style"]=> string(11) "width:200px" } ["filter"]=> bool(false) } ["linkStr"]=> array(8) { ["class"]=> string(13) "DToggleColumn" ["name"]=> string(7) "linkStr" ["header"]=> string(10) "Алиас" ["type"]=> string(4) "link" ["model"]=> string(8) "Category" ["titles"]=> string(43) "Открыть в новой вкладке" ["linkUrl"]=> string(18) ""/".$data->linkStr" ["htmlOptions"]=> array(1) { ["style"]=> string(48) "text-align:left;max-width:30px;overflow: hidden;" } } [2]=> array(5) { ["class"]=> string(34) "bootstrap.widgets.TbEditableColumn" ["name"]=> string(5) "level" ["editable"]=> array(3) { ["name"]=> string(5) "level" ["url"]=> string(26) "/admin/updateLevelCategory" ["placement"]=> string(3) "top" } ["filter"]=> bool(false) ["htmlOptions"]=> array(1) { ["style"]=> string(30) "width:50px;text-align: center;" } } [3]=> array(13) { ["class"]=> string(13) "DToggleColumn" ["name"]=> string(5) "level" ["upDown"]=> string(1) "0" ["header"]=> string(1) " " ["filter"]=> bool(false) ["countItems"]=> NULL ["type"]=> string(6) "upDown" ["model"]=> string(8) "Category" ["titles"]=> array(1) { [1]=> string(33) "переместить вверх" } ["onImageUrl"]=> string(20) "/images/orderMAX.png" ["imageSize"]=> string(4) "20px" ["linkUrl"]=> string(74) ""/admin/orderMAX/".$this->model."-".$data->id."?parentId=".$data->parentId" ["htmlOptions"]=> array(1) { ["style"]=> string(28) "width:20px;text-align:center" } } [4]=> array(13) { ["class"]=> string(13) "DToggleColumn" ["name"]=> string(5) "level" ["upDown"]=> string(1) "1" ["header"]=> string(1) " " ["filter"]=> bool(false) ["type"]=> string(6) "upDown" ["model"]=> string(8) "Category" ["countItems"]=> NULL ["titles"]=> array(1) { [1]=> string(31) "переместить вниз" } ["onImageUrl"]=> string(20) "/images/orderMIN.png" ["imageSize"]=> string(4) "20px" ["linkUrl"]=> string(74) ""/admin/orderMIN/".$this->model."-".$data->id."?parentId=".$data->parentId" ["htmlOptions"]=> array(1) { ["style"]=> string(29) "width:40px;padding-right:20px" } } [5]=> array(12) { ["class"]=> string(13) "DToggleColumn" ["name"]=> string(6) "status" ["header"]=> string(18) "Состояние" ["filter"]=> array(2) { [0]=> string(34) "снято с публикации" [1]=> string(24) "опубликовано" } ["type"]=> string(6) "status" ["model"]=> string(8) "Category" ["titles"]=> array(2) { [0]=> string(24) "опубликовать" [1]=> string(34) "снять с публикации" } ["onImageUrl"]=> string(15) "/images/yes.png" ["offImageUrl"]=> string(14) "/images/no.png" ["imageSize"]=> string(2) "15" ["linkUrl"]=> string(43) ""/admin/status/".$this->model."-".$data->id" ["htmlOptions"]=> array(1) { ["style"]=> string(26) "text-align:left;width:30px" } } ["created"]=> array(5) { ["name"]=> string(7) "created" ["header"]=> string(16) "Дата created" ["filter"]=> bool(false) ["value"]=> string(59) "date(Yii::app()->controller->dateFormatAdm, $data->created)" ["htmlOptions"]=> array(1) { ["style"]=> string(15) "text-align:left" } } ["updated"]=> array(5) { ["name"]=> string(7) "updated" ["header"]=> string(16) "Дата updated" ["filter"]=> bool(false) ["value"]=> string(59) "date(Yii::app()->controller->dateFormatAdm, $data->updated)" ["htmlOptions"]=> array(1) { ["style"]=> string(15) "text-align:left" } } } ["childs"]=> array(0) { } ["fields"]=> array(1) { [0]=> array(1) { ["tabbable"]=> array(2) { [0]=> array(9) { ["name0"]=> string(16) "Основные" [0]=> array(3) { ["name"]=> string(21) "ID категории" ["attribute"]=> string(2) "id" ["type"]=> string(4) "text" } [1]=> array(3) { ["name"]=> string(16) "Название" ["attribute"]=> string(4) "name" ["type"]=> string(12) "textFieldRow" } [2]=> array(3) { ["name"]=> string(25) "Алиас (ссылка)" ["attribute"]=> string(7) "linkStr" ["type"]=> string(12) "textFieldRow" } [3]=> array(4) { ["name"]=> string(0) "" ["attribute"]=> string(10) "oldLinkStr" ["type"]=> string(6) "hidden" ["doubleAtt"]=> string(7) "linkStr" } [4]=> array(4) { ["name"]=> string(35) "Корневая категория" ["attribute"]=> string(8) "parentId" ["type"]=> string(22) "dropDownIerarhCategory" ["data"]=> array(1) { ["updateAtt"]=> string(10) "categoryId" } } [5]=> array(4) { ["name"]=> string(21) "ID категории" ["attribute"]=> string(10) "categoryId" ["type"]=> string(12) "textFieldRow" ["doubleAtt"]=> string(8) "parentId" } [6]=> array(3) { ["name"]=> string(14) "Порядок" ["attribute"]=> string(5) "level" ["type"]=> string(12) "textFieldRow" } [7]=> array(3) { ["name"]=> string(16) "Описание" ["attribute"]=> string(4) "text" ["type"]=> string(7) "tinymce" } } [1]=> array(9) { ["name1"]=> string(26) "Дополнительно" [0]=> array(5) { ["name"]=> string(10) "Макет" ["attribute"]=> string(7) "layout1" ["type"]=> string(10) "dropDownCl" ["array"]=> array(5) { ["column1-12"]=> string(10) "column1-12" ["column2-4-8"]=> string(11) "column2-4-8" ["column2-6-6"]=> string(11) "column2-6-6" ["column2-8-4"]=> string(11) "column2-8-4" ["column2-3-9"]=> string(11) "column2-3-9" } ["addField"]=> array(1) { [0]=> array(3) { ["name"]=> string(25) "Текущий макет" ["attribute"]=> string(6) "layout" ["type"]=> string(4) "text" } } } [1]=> array(5) { ["name"]=> string(25) "Вид категории" ["attribute"]=> string(5) "view1" ["type"]=> string(10) "dropDownCl" ["array"]=> array(3) { ["viewItems"]=> string(9) "viewItems" ["viewItems1"]=> string(10) "viewItems1" ["default"]=> string(7) "default" } ["addField"]=> array(1) { [0]=> array(3) { ["name"]=> string(21) "Текущий вид" ["attribute"]=> string(4) "view" ["type"]=> string(4) "text" } } } [2]=> array(3) { ["name"]=> string(52) "Отображать статьи категории" ["attribute"]=> string(7) "viewArt" ["type"]=> string(15) "toggleButtonRow" } [3]=> array(3) { ["name"]=> string(45) "Отображать подкатегории" ["attribute"]=> string(10) "viewParent" ["type"]=> string(15) "toggleButtonRow" } [4]=> array(3) { ["name"]=> string(58) "Отображать статьи подкатегорий" ["attribute"]=> string(10) "viewArtAll" ["type"]=> string(15) "toggleButtonRow" } [5]=> array(3) { ["name"]=> string(18) "Состояние" ["attribute"]=> string(6) "status" ["type"]=> string(15) "toggleButtonRow" } [6]=> array(3) { ["name"]=> string(25) "Дата создания" ["attribute"]=> string(7) "created" ["type"]=> string(13) "datePickerRow" } [7]=> array(3) { ["name"]=> string(29) "Дата обновления" ["attribute"]=> string(7) "updated" ["type"]=> string(13) "datePickerRow" } } } } } ["ierarh"]=> bool(true) ["_enabled":"CBehavior":private]=> bool(true) ["_owner":"CBehavior":private]=> *RECURSION* ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } [1]=> string(14) "afterConstruct" } } ["_c":"CList":private]=> int(1) ["_r":"CList":private]=> bool(false) ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } } ["_m":"CComponent":private]=> array(2) { ["AutoTimestampBehavior"]=> object(AutoTimestampBehavior)#329 (6) { ["created"]=> string(7) "created" ["modified"]=> string(7) "updated" ["_enabled":"CBehavior":private]=> bool(true) ["_owner":"CBehavior":private]=> *RECURSION* ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } ["AdminBehavior"]=> object(AdminBehavior)#330 (8) { ["columns"]=> array(10) { ["id"]=> array(3) { ["name"]=> string(2) "id" ["header"]=> string(1) "#" ["filter"]=> string(0) "" } [0]=> array(8) { ["class"]=> string(13) "DToggleColumn" ["name"]=> string(4) "name" ["header"]=> string(16) "Название" ["type"]=> string(4) "link" ["model"]=> string(8) "Category" ["titles"]=> array(1) { [1]=> string(12) "$model->name" } ["linkUrl"]=> string(87) ""/admin/category/update/".$data->id.($data->parentId ? "?parentId=".$data->parentId:"")" ["htmlOptions"]=> array(1) { ["style"]=> string(11) "width:400px" } } [1]=> array(9) { ["class"]=> string(13) "DToggleColumn" ["name"]=> string(8) "parentId" ["header"]=> string(0) "" ["type"]=> string(7) "linkCat" ["model"]=> string(8) "Category" ["value"]=> string(67) ""Подкатегорий: ".count(Category::findChilds($data->id))" ["linkUrl"]=> string(38) ""/admin/category/?parentId=".$data->id" ["htmlOptions"]=> array(1) { ["style"]=> string(11) "width:200px" } ["filter"]=> bool(false) } ["linkStr"]=> array(8) { ["class"]=> string(13) "DToggleColumn" ["name"]=> string(7) "linkStr" ["header"]=> string(10) "Алиас" ["type"]=> string(4) "link" ["model"]=> string(8) "Category" ["titles"]=> string(43) "Открыть в новой вкладке" ["linkUrl"]=> string(18) ""/".$data->linkStr" ["htmlOptions"]=> array(1) { ["style"]=> string(48) "text-align:left;max-width:30px;overflow: hidden;" } } [2]=> array(5) { ["class"]=> string(34) "bootstrap.widgets.TbEditableColumn" ["name"]=> string(5) "level" ["editable"]=> array(3) { ["name"]=> string(5) "level" ["url"]=> string(26) "/admin/updateLevelCategory" ["placement"]=> string(3) "top" } ["filter"]=> bool(false) ["htmlOptions"]=> array(1) { ["style"]=> string(30) "width:50px;text-align: center;" } } [3]=> array(13) { ["class"]=> string(13) "DToggleColumn" ["name"]=> string(5) "level" ["upDown"]=> string(1) "0" ["header"]=> string(1) " " ["filter"]=> bool(false) ["countItems"]=> NULL ["type"]=> string(6) "upDown" ["model"]=> string(8) "Category" ["titles"]=> array(1) { [1]=> string(33) "переместить вверх" } ["onImageUrl"]=> string(20) "/images/orderMAX.png" ["imageSize"]=> string(4) "20px" ["linkUrl"]=> string(74) ""/admin/orderMAX/".$this->model."-".$data->id."?parentId=".$data->parentId" ["htmlOptions"]=> array(1) { ["style"]=> string(28) "width:20px;text-align:center" } } [4]=> array(13) { ["class"]=> string(13) "DToggleColumn" ["name"]=> string(5) "level" ["upDown"]=> string(1) "1" ["header"]=> string(1) " " ["filter"]=> bool(false) ["type"]=> string(6) "upDown" ["model"]=> string(8) "Category" ["countItems"]=> NULL ["titles"]=> array(1) { [1]=> string(31) "переместить вниз" } ["onImageUrl"]=> string(20) "/images/orderMIN.png" ["imageSize"]=> string(4) "20px" ["linkUrl"]=> string(74) ""/admin/orderMIN/".$this->model."-".$data->id."?parentId=".$data->parentId" ["htmlOptions"]=> array(1) { ["style"]=> string(29) "width:40px;padding-right:20px" } } [5]=> array(12) { ["class"]=> string(13) "DToggleColumn" ["name"]=> string(6) "status" ["header"]=> string(18) "Состояние" ["filter"]=> array(2) { [0]=> string(34) "снято с публикации" [1]=> string(24) "опубликовано" } ["type"]=> string(6) "status" ["model"]=> string(8) "Category" ["titles"]=> array(2) { [0]=> string(24) "опубликовать" [1]=> string(34) "снять с публикации" } ["onImageUrl"]=> string(15) "/images/yes.png" ["offImageUrl"]=> string(14) "/images/no.png" ["imageSize"]=> string(2) "15" ["linkUrl"]=> string(43) ""/admin/status/".$this->model."-".$data->id" ["htmlOptions"]=> array(1) { ["style"]=> string(26) "text-align:left;width:30px" } } ["created"]=> array(5) { ["name"]=> string(7) "created" ["header"]=> string(16) "Дата created" ["filter"]=> bool(false) ["value"]=> string(59) "date(Yii::app()->controller->dateFormatAdm, $data->created)" ["htmlOptions"]=> array(1) { ["style"]=> string(15) "text-align:left" } } ["updated"]=> array(5) { ["name"]=> string(7) "updated" ["header"]=> string(16) "Дата updated" ["filter"]=> bool(false) ["value"]=> string(59) "date(Yii::app()->controller->dateFormatAdm, $data->updated)" ["htmlOptions"]=> array(1) { ["style"]=> string(15) "text-align:left" } } } ["childs"]=> array(0) { } ["fields"]=> array(1) { [0]=> array(1) { ["tabbable"]=> array(2) { [0]=> array(9) { ["name0"]=> string(16) "Основные" [0]=> array(3) { ["name"]=> string(21) "ID категории" ["attribute"]=> string(2) "id" ["type"]=> string(4) "text" } [1]=> array(3) { ["name"]=> string(16) "Название" ["attribute"]=> string(4) "name" ["type"]=> string(12) "textFieldRow" } [2]=> array(3) { ["name"]=> string(25) "Алиас (ссылка)" ["attribute"]=> string(7) "linkStr" ["type"]=> string(12) "textFieldRow" } [3]=> array(4) { ["name"]=> string(0) "" ["attribute"]=> string(10) "oldLinkStr" ["type"]=> string(6) "hidden" ["doubleAtt"]=> string(7) "linkStr" } [4]=> array(4) { ["name"]=> string(35) "Корневая категория" ["attribute"]=> string(8) "parentId" ["type"]=> string(22) "dropDownIerarhCategory" ["data"]=> array(1) { ["updateAtt"]=> string(10) "categoryId" } } [5]=> array(4) { ["name"]=> string(21) "ID категории" ["attribute"]=> string(10) "categoryId" ["type"]=> string(12) "textFieldRow" ["doubleAtt"]=> string(8) "parentId" } [6]=> array(3) { ["name"]=> string(14) "Порядок" ["attribute"]=> string(5) "level" ["type"]=> string(12) "textFieldRow" } [7]=> array(3) { ["name"]=> string(16) "Описание" ["attribute"]=> string(4) "text" ["type"]=> string(7) "tinymce" } } [1]=> array(9) { ["name1"]=> string(26) "Дополнительно" [0]=> array(5) { ["name"]=> string(10) "Макет" ["attribute"]=> string(7) "layout1" ["type"]=> string(10) "dropDownCl" ["array"]=> array(5) { ["column1-12"]=> string(10) "column1-12" ["column2-4-8"]=> string(11) "column2-4-8" ["column2-6-6"]=> string(11) "column2-6-6" ["column2-8-4"]=> string(11) "column2-8-4" ["column2-3-9"]=> string(11) "column2-3-9" } ["addField"]=> array(1) { [0]=> array(3) { ["name"]=> string(25) "Текущий макет" ["attribute"]=> string(6) "layout" ["type"]=> string(4) "text" } } } [1]=> array(5) { ["name"]=> string(25) "Вид категории" ["attribute"]=> string(5) "view1" ["type"]=> string(10) "dropDownCl" ["array"]=> array(3) { ["viewItems"]=> string(9) "viewItems" ["viewItems1"]=> string(10) "viewItems1" ["default"]=> string(7) "default" } ["addField"]=> array(1) { [0]=> array(3) { ["name"]=> string(21) "Текущий вид" ["attribute"]=> string(4) "view" ["type"]=> string(4) "text" } } } [2]=> array(3) { ["name"]=> string(52) "Отображать статьи категории" ["attribute"]=> string(7) "viewArt" ["type"]=> string(15) "toggleButtonRow" } [3]=> array(3) { ["name"]=> string(45) "Отображать подкатегории" ["attribute"]=> string(10) "viewParent" ["type"]=> string(15) "toggleButtonRow" } [4]=> array(3) { ["name"]=> string(58) "Отображать статьи подкатегорий" ["attribute"]=> string(10) "viewArtAll" ["type"]=> string(15) "toggleButtonRow" } [5]=> array(3) { ["name"]=> string(18) "Состояние" ["attribute"]=> string(6) "status" ["type"]=> string(15) "toggleButtonRow" } [6]=> array(3) { ["name"]=> string(25) "Дата создания" ["attribute"]=> string(7) "created" ["type"]=> string(13) "datePickerRow" } [7]=> array(3) { ["name"]=> string(29) "Дата обновления" ["attribute"]=> string(7) "updated" ["type"]=> string(13) "datePickerRow" } } } } } ["ierarh"]=> bool(true) ["_enabled":"CBehavior":private]=> bool(true) ["_owner":"CBehavior":private]=> *RECURSION* ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } } } } ["_c":"CActiveRecord":private]=> NULL ["_pk":"CActiveRecord":private]=> string(2) "47" ["_alias":"CActiveRecord":private]=> string(1) "t" ["_errors":"CModel":private]=> array(0) { } ["_validators":"CModel":private]=> NULL ["_scenario":"CModel":private]=> string(6) "update" ["_e":"CComponent":private]=> array(2) { ["onbeforesave"]=> object(CList)#299 (5) { ["_d":"CList":private]=> array(1) { [0]=> array(2) { [0]=> object(AutoTimestampBehavior)#297 (6) { ["created"]=> string(7) "created" ["modified"]=> string(7) "updated" ["_enabled":"CBehavior":private]=> bool(true) ["_owner":"CBehavior":private]=> *RECURSION* ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } [1]=> string(10) "beforeSave" } } ["_c":"CList":private]=> int(1) ["_r":"CList":private]=> bool(false) ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } ["onafterconstruct"]=> object(CList)#301 (5) { ["_d":"CList":private]=> array(1) { [0]=> array(2) { [0]=> object(AdminBehavior)#298 (8) { ["columns"]=> array(11) { ["id"]=> array(4) { ["name"]=> string(2) "id" ["header"]=> string(2) "ID" ["filter"]=> string(0) "" ["htmlOptions"]=> array(1) { ["style"]=> string(14) "min-width:30px" } } [0]=> array(5) { ["class"]=> string(12) "EImageColumn" ["name"]=> string(5) "image" ["pathPrefix"]=> string(17) "/upload/articles/" ["htmlOptions"]=> array(1) { ["style"]=> string(12) "width: 50px;" } ["defaultImage"]=> string(32) "/themes/tester40/img/default.png" } [1]=> array(9) { ["class"]=> string(13) "DToggleColumn" ["name"]=> string(4) "name" ["header"]=> string(16) "Название" ["type"]=> string(4) "link" ["model"]=> string(8) "Articles" ["titles"]=> array(1) { [1]=> string(12) "$model->name" } ["dataToggle"]=> array(2) { ["title"]=> string(43) "Количество просмотров: " ["data"]=> string(8) "numViews" } ["linkUrl"]=> string(134) ""/admin/articles/update/" . $data->id . (isset($_GET["Articles"]["category"])?"?Articles[category]=".$_GET["Articles"]["category"]:"")" ["htmlOptions"]=> array(1) { ["style"]=> string(11) "width:500px" } } ["category"]=> array(6) { ["name"]=> string(8) "category" ["header"]=> string(18) "Категория" ["value"]=> string(23) "$data->artCatBehCache()" ["filter"]=> string(0) "" ["type"]=> string(3) "raw" ["htmlOptions"]=> array(1) { ["style"]=> string(15) "min-width:100px" } } [2]=> array(5) { ["class"]=> string(34) "bootstrap.widgets.TbEditableColumn" ["name"]=> string(5) "level" ["editable"]=> array(3) { ["name"]=> string(5) "level" ["url"]=> string(26) "/admin/updateLevelArticles" ["placement"]=> string(3) "top" } ["filter"]=> bool(false) ["htmlOptions"]=> array(1) { ["style"]=> string(30) "width:50px;text-align: center;" } } [3]=> array(13) { ["class"]=> string(13) "DToggleColumn" ["name"]=> string(5) "level" ["upDown"]=> string(1) "0" ["header"]=> string(1) " " ["filter"]=> bool(false) ["countItems"]=> int(0) ["type"]=> string(6) "upDown" ["model"]=> string(8) "Articles" ["titles"]=> array(1) { [1]=> string(33) "переместить вверх" } ["onImageUrl"]=> string(20) "/images/orderMAX.png" ["imageSize"]=> string(4) "20px" ["linkUrl"]=> string(74) ""/admin/orderMAX/".$this->model."-".$data->id."?category=".$data->category" ["htmlOptions"]=> array(1) { ["style"]=> string(28) "width:20px;text-align:center" } } [4]=> array(13) { ["class"]=> string(13) "DToggleColumn" ["name"]=> string(5) "level" ["upDown"]=> string(1) "1" ["header"]=> string(1) " " ["filter"]=> bool(false) ["type"]=> string(6) "upDown" ["model"]=> string(8) "Articles" ["countItems"]=> int(0) ["titles"]=> array(1) { [1]=> string(31) "переместить вниз" } ["onImageUrl"]=> string(20) "/images/orderMIN.png" ["imageSize"]=> string(4) "20px" ["linkUrl"]=> string(74) ""/admin/orderMIN/".$this->model."-".$data->id."?category=".$data->category" ["htmlOptions"]=> array(1) { ["style"]=> string(29) "width:40px;padding-right:20px" } } [5]=> array(12) { ["class"]=> string(13) "DToggleColumn" ["name"]=> string(6) "isHome" ["header"]=> string(1) " " ["filter"]=> bool(false) ["type"]=> string(6) "isHome" ["model"]=> string(8) "Articles" ["titles"]=> array(2) { [0]=> string(33) "сделать стартовой" [1]=> string(28) "снять с главной" } ["onImageUrl"]=> string(19) "/images/default.png" ["offImageUrl"]=> string(22) "/images/notdefault.png" ["imageSize"]=> string(4) "20px" ["linkUrl"]=> string(41) ""/admin/home/".$this->model."-".$data->id" ["htmlOptions"]=> array(1) { ["style"]=> string(14) "min-width:30px" } } [6]=> array(12) { ["class"]=> string(13) "DToggleColumn" ["name"]=> string(6) "status" ["header"]=> string(1) " " ["filter"]=> array(2) { [0]=> string(34) "снято с публикации" [1]=> string(24) "опубликовано" } ["type"]=> string(6) "status" ["model"]=> string(8) "Articles" ["titles"]=> array(2) { [0]=> string(24) "опубликовать" [1]=> string(34) "снять с публикации" } ["onImageUrl"]=> string(15) "/images/yes.png" ["offImageUrl"]=> string(14) "/images/no.png" ["imageSize"]=> string(4) "20px" ["linkUrl"]=> string(43) ""/admin/status/".$this->model."-".$data->id" ["htmlOptions"]=> array(1) { ["style"]=> string(10) "width:70px" } } ["created"]=> array(4) { ["name"]=> string(7) "created" ["header"]=> string(16) "Дата created" ["value"]=> string(59) "date(Yii::app()->controller->dateFormatAdm, $data->created)" ["htmlOptions"]=> array(1) { ["style"]=> string(15) "text-align:left" } } ["updated"]=> array(5) { ["name"]=> string(7) "updated" ["header"]=> string(16) "Дата updated" ["value"]=> string(59) "date(Yii::app()->controller->dateFormatAdm, $data->updated)" ["filter"]=> bool(false) ["htmlOptions"]=> array(1) { ["style"]=> string(16) "min-width:150px;" } } } ["childs"]=> array(0) { } ["fields"]=> array(2) { [0]=> array(1) { ["tabbable"]=> array(2) { [0]=> array(14) { ["name0"]=> string(16) "Основные" [0]=> array(3) { ["name"]=> string(19) "ID страницы" ["attribute"]=> string(2) "id" ["type"]=> string(4) "text" } [1]=> array(3) { ["name"]=> string(18) "Заголовок" ["attribute"]=> string(4) "name" ["type"]=> string(12) "textFieldRow" } [2]=> array(3) { ["name"]=> string(39) "Показывать заголовок" ["attribute"]=> string(6) "nameOn" ["type"]=> string(15) "toggleButtonRow" } [3]=> array(3) { ["name"]=> string(25) "Алиас (ссылка)" ["attribute"]=> string(7) "linkStr" ["type"]=> string(12) "textFieldRow" } [4]=> array(3) { ["name"]=> string(18) "Состояние" ["attribute"]=> string(6) "status" ["type"]=> string(15) "toggleButtonRow" } [5]=> array(4) { ["name"]=> string(18) "Категория" ["attribute"]=> string(8) "category" ["type"]=> string(22) "dropDownIerarhCategory" ["data"]=> array(1) { ["updateAtt"]=> string(10) "categoryId" } } [6]=> array(4) { ["name"]=> string(21) "ID категории" ["attribute"]=> string(10) "categoryId" ["type"]=> string(12) "textFieldRow" ["doubleAtt"]=> string(8) "category" } [7]=> array(3) { ["name"]=> string(14) "Порядок" ["attribute"]=> string(5) "level" ["type"]=> string(12) "textFieldRow" } [8]=> array(3) { ["name"]=> string(38) "Показывать в ленте RSS" ["attribute"]=> string(9) "viewInRss" ["type"]=> string(15) "toggleButtonRow" } [9]=> array(4) { ["name"]=> string(38) "Изображение к статье" ["attribute"]=> string(5) "image" ["type"]=> string(4) "file" ["htmlOptions"]=> array(3) { ["data-toggle"]=> string(7) "tooltip" ["data-placement"]=> string(5) "right" ["data-original-title"]=> string(25) "Выберите файл" } } [10]=> array(5) { ["name"]=> string(22) "Изображение" ["attribute"]=> string(5) "image" ["type"]=> string(5) "image" ["src"]=> string(35) "http://tester40.ru/upload/articles/" ["htmlOptions"]=> array(4) { ["style"]=> string(9) "width:30%" ["data-toggle"]=> string(7) "tooltip" ["data-placement"]=> string(5) "right" ["data-original-title"]=> string(71) "Нажмите, для просмотра полного размера" } } [11]=> array(4) { ["name"]=> string(42) "Путь к файлу на сервере" ["attribute"]=> string(5) "image" ["type"]=> string(4) "text" ["before"]=> string(17) "/upload/articles/" } [12]=> array(4) { ["name"]=> string(33) "Содержание статьи" ["attribute"]=> string(4) "text" ["type"]=> string(7) "tinymce" ["widgetInText"]=> int(1) } } [1]=> array(13) { ["name1"]=> string(18) "Параметры" [0]=> array(5) { ["name"]=> string(10) "Макет" ["attribute"]=> string(7) "layout1" ["type"]=> string(10) "dropDownCl" ["array"]=> array(5) { ["column1-12"]=> string(10) "column1-12" ["column2-4-8"]=> string(11) "column2-4-8" ["column2-6-6"]=> string(11) "column2-6-6" ["column2-8-4"]=> string(11) "column2-8-4" ["column2-3-9"]=> string(11) "column2-3-9" } ["addField"]=> array(1) { [0]=> array(3) { ["name"]=> string(25) "Текущий макет" ["attribute"]=> string(6) "layout" ["type"]=> string(4) "text" } } } [1]=> array(3) { ["name"]=> string(39) "Отображать Категорию" ["attribute"]=> string(10) "categoryOn" ["type"]=> string(15) "toggleButtonRow" } [2]=> array(4) { ["name"]=> string(31) "Отображать метки" ["attribute"]=> string(6) "tagsOn" ["type"]=> string(15) "toggleButtonRow" ["addField"]=> array(1) { [0]=> array(4) { ["name"]=> string(10) "Метки" ["attribute"]=> string(4) "tags" ["type"]=> string(11) "textAreaRow" ["htmlOptions"]=> array(3) { ["data-toggle"]=> string(7) "tooltip" ["data-placement"]=> string(5) "right" ["data-original-title"]=> string(25) "через запятую" } } } } [3]=> array(4) { ["name"]=> string(33) "Отображать автора" ["attribute"]=> string(7) "avtorOn" ["type"]=> string(15) "toggleButtonRow" ["addField"]=> array(1) { [0]=> array(3) { ["name"]=> string(10) "Автор" ["attribute"]=> string(5) "avtor" ["type"]=> string(12) "textFieldRow" } } } [4]=> array(4) { ["name"]=> string(37) "Отображать источник" ["attribute"]=> string(8) "sourceOn" ["type"]=> string(15) "toggleButtonRow" ["addField"]=> array(1) { [0]=> array(3) { ["name"]=> string(16) "Источник" ["attribute"]=> string(6) "source" ["type"]=> string(12) "textFieldRow" } } } [5]=> array(3) { ["name"]=> string(29) "Отображать дату" ["attribute"]=> string(6) "dataOn" ["type"]=> string(15) "toggleButtonRow" } [6]=> array(3) { ["name"]=> string(25) "Дата создания" ["attribute"]=> string(7) "created" ["type"]=> string(13) "datePickerRow" } [7]=> array(3) { ["name"]=> string(27) "Meta описание (SEO)" ["attribute"]=> string(8) "seoDescr" ["type"]=> string(11) "textAreaRow" } [8]=> array(3) { ["name"]=> string(38) "Meta ключевые слова (SEO)" ["attribute"]=> string(6) "seoKey" ["type"]=> string(11) "textAreaRow" } [9]=> array(3) { ["name"]=> string(62) "Отображать количество просмотров" ["attribute"]=> string(10) "numViewsOn" ["type"]=> string(15) "toggleButtonRow" } [10]=> array(3) { ["name"]=> string(41) "Количество просмотров" ["attribute"]=> string(8) "numViews" ["type"]=> string(4) "text" } [11]=> array(3) { ["name"]=> string(29) "Дата обновления" ["attribute"]=> string(7) "updated" ["type"]=> string(13) "datePickerRow" } } } } [1]=> array(4) { ["name"]=> string(16) "Редирект" ["attribute"]=> string(7) "referer" ["type"]=> string(6) "hidden" ["noVisibleHR"]=> string(0) "" } } ["ierarh"]=> int(0) ["_enabled":"CBehavior":private]=> bool(true) ["_owner":"CBehavior":private]=> *RECURSION* ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } [1]=> string(14) "afterConstruct" } } ["_c":"CList":private]=> int(1) ["_r":"CList":private]=> bool(false) ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } } ["_m":"CComponent":private]=> array(2) { ["AutoTimestampBehavior"]=> object(AutoTimestampBehavior)#297 (6) { ["created"]=> string(7) "created" ["modified"]=> string(7) "updated" ["_enabled":"CBehavior":private]=> bool(true) ["_owner":"CBehavior":private]=> *RECURSION* ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } ["AdminBehavior"]=> object(AdminBehavior)#298 (8) { ["columns"]=> array(11) { ["id"]=> array(4) { ["name"]=> string(2) "id" ["header"]=> string(2) "ID" ["filter"]=> string(0) "" ["htmlOptions"]=> array(1) { ["style"]=> string(14) "min-width:30px" } } [0]=> array(5) { ["class"]=> string(12) "EImageColumn" ["name"]=> string(5) "image" ["pathPrefix"]=> string(17) "/upload/articles/" ["htmlOptions"]=> array(1) { ["style"]=> string(12) "width: 50px;" } ["defaultImage"]=> string(32) "/themes/tester40/img/default.png" } [1]=> array(9) { ["class"]=> string(13) "DToggleColumn" ["name"]=> string(4) "name" ["header"]=> string(16) "Название" ["type"]=> string(4) "link" ["model"]=> string(8) "Articles" ["titles"]=> array(1) { [1]=> string(12) "$model->name" } ["dataToggle"]=> array(2) { ["title"]=> string(43) "Количество просмотров: " ["data"]=> string(8) "numViews" } ["linkUrl"]=> string(134) ""/admin/articles/update/" . $data->id . (isset($_GET["Articles"]["category"])?"?Articles[category]=".$_GET["Articles"]["category"]:"")" ["htmlOptions"]=> array(1) { ["style"]=> string(11) "width:500px" } } ["category"]=> array(6) { ["name"]=> string(8) "category" ["header"]=> string(18) "Категория" ["value"]=> string(23) "$data->artCatBehCache()" ["filter"]=> string(0) "" ["type"]=> string(3) "raw" ["htmlOptions"]=> array(1) { ["style"]=> string(15) "min-width:100px" } } [2]=> array(5) { ["class"]=> string(34) "bootstrap.widgets.TbEditableColumn" ["name"]=> string(5) "level" ["editable"]=> array(3) { ["name"]=> string(5) "level" ["url"]=> string(26) "/admin/updateLevelArticles" ["placement"]=> string(3) "top" } ["filter"]=> bool(false) ["htmlOptions"]=> array(1) { ["style"]=> string(30) "width:50px;text-align: center;" } } [3]=> array(13) { ["class"]=> string(13) "DToggleColumn" ["name"]=> string(5) "level" ["upDown"]=> string(1) "0" ["header"]=> string(1) " " ["filter"]=> bool(false) ["countItems"]=> int(0) ["type"]=> string(6) "upDown" ["model"]=> string(8) "Articles" ["titles"]=> array(1) { [1]=> string(33) "переместить вверх" } ["onImageUrl"]=> string(20) "/images/orderMAX.png" ["imageSize"]=> string(4) "20px" ["linkUrl"]=> string(74) ""/admin/orderMAX/".$this->model."-".$data->id."?category=".$data->category" ["htmlOptions"]=> array(1) { ["style"]=> string(28) "width:20px;text-align:center" } } [4]=> array(13) { ["class"]=> string(13) "DToggleColumn" ["name"]=> string(5) "level" ["upDown"]=> string(1) "1" ["header"]=> string(1) " " ["filter"]=> bool(false) ["type"]=> string(6) "upDown" ["model"]=> string(8) "Articles" ["countItems"]=> int(0) ["titles"]=> array(1) { [1]=> string(31) "переместить вниз" } ["onImageUrl"]=> string(20) "/images/orderMIN.png" ["imageSize"]=> string(4) "20px" ["linkUrl"]=> string(74) ""/admin/orderMIN/".$this->model."-".$data->id."?category=".$data->category" ["htmlOptions"]=> array(1) { ["style"]=> string(29) "width:40px;padding-right:20px" } } [5]=> array(12) { ["class"]=> string(13) "DToggleColumn" ["name"]=> string(6) "isHome" ["header"]=> string(1) " " ["filter"]=> bool(false) ["type"]=> string(6) "isHome" ["model"]=> string(8) "Articles" ["titles"]=> array(2) { [0]=> string(33) "сделать стартовой" [1]=> string(28) "снять с главной" } ["onImageUrl"]=> string(19) "/images/default.png" ["offImageUrl"]=> string(22) "/images/notdefault.png" ["imageSize"]=> string(4) "20px" ["linkUrl"]=> string(41) ""/admin/home/".$this->model."-".$data->id" ["htmlOptions"]=> array(1) { ["style"]=> string(14) "min-width:30px" } } [6]=> array(12) { ["class"]=> string(13) "DToggleColumn" ["name"]=> string(6) "status" ["header"]=> string(1) " " ["filter"]=> array(2) { [0]=> string(34) "снято с публикации" [1]=> string(24) "опубликовано" } ["type"]=> string(6) "status" ["model"]=> string(8) "Articles" ["titles"]=> array(2) { [0]=> string(24) "опубликовать" [1]=> string(34) "снять с публикации" } ["onImageUrl"]=> string(15) "/images/yes.png" ["offImageUrl"]=> string(14) "/images/no.png" ["imageSize"]=> string(4) "20px" ["linkUrl"]=> string(43) ""/admin/status/".$this->model."-".$data->id" ["htmlOptions"]=> array(1) { ["style"]=> string(10) "width:70px" } } ["created"]=> array(4) { ["name"]=> string(7) "created" ["header"]=> string(16) "Дата created" ["value"]=> string(59) "date(Yii::app()->controller->dateFormatAdm, $data->created)" ["htmlOptions"]=> array(1) { ["style"]=> string(15) "text-align:left" } } ["updated"]=> array(5) { ["name"]=> string(7) "updated" ["header"]=> string(16) "Дата updated" ["value"]=> string(59) "date(Yii::app()->controller->dateFormatAdm, $data->updated)" ["filter"]=> bool(false) ["htmlOptions"]=> array(1) { ["style"]=> string(16) "min-width:150px;" } } } ["childs"]=> array(0) { } ["fields"]=> array(2) { [0]=> array(1) { ["tabbable"]=> array(2) { [0]=> array(14) { ["name0"]=> string(16) "Основные" [0]=> array(3) { ["name"]=> string(19) "ID страницы" ["attribute"]=> string(2) "id" ["type"]=> string(4) "text" } [1]=> array(3) { ["name"]=> string(18) "Заголовок" ["attribute"]=> string(4) "name" ["type"]=> string(12) "textFieldRow" } [2]=> array(3) { ["name"]=> string(39) "Показывать заголовок" ["attribute"]=> string(6) "nameOn" ["type"]=> string(15) "toggleButtonRow" } [3]=> array(3) { ["name"]=> string(25) "Алиас (ссылка)" ["attribute"]=> string(7) "linkStr" ["type"]=> string(12) "textFieldRow" } [4]=> array(3) { ["name"]=> string(18) "Состояние" ["attribute"]=> string(6) "status" ["type"]=> string(15) "toggleButtonRow" } [5]=> array(4) { ["name"]=> string(18) "Категория" ["attribute"]=> string(8) "category" ["type"]=> string(22) "dropDownIerarhCategory" ["data"]=> array(1) { ["updateAtt"]=> string(10) "categoryId" } } [6]=> array(4) { ["name"]=> string(21) "ID категории" ["attribute"]=> string(10) "categoryId" ["type"]=> string(12) "textFieldRow" ["doubleAtt"]=> string(8) "category" } [7]=> array(3) { ["name"]=> string(14) "Порядок" ["attribute"]=> string(5) "level" ["type"]=> string(12) "textFieldRow" } [8]=> array(3) { ["name"]=> string(38) "Показывать в ленте RSS" ["attribute"]=> string(9) "viewInRss" ["type"]=> string(15) "toggleButtonRow" } [9]=> array(4) { ["name"]=> string(38) "Изображение к статье" ["attribute"]=> string(5) "image" ["type"]=> string(4) "file" ["htmlOptions"]=> array(3) { ["data-toggle"]=> string(7) "tooltip" ["data-placement"]=> string(5) "right" ["data-original-title"]=> string(25) "Выберите файл" } } [10]=> array(5) { ["name"]=> string(22) "Изображение" ["attribute"]=> string(5) "image" ["type"]=> string(5) "image" ["src"]=> string(35) "http://tester40.ru/upload/articles/" ["htmlOptions"]=> array(4) { ["style"]=> string(9) "width:30%" ["data-toggle"]=> string(7) "tooltip" ["data-placement"]=> string(5) "right" ["data-original-title"]=> string(71) "Нажмите, для просмотра полного размера" } } [11]=> array(4) { ["name"]=> string(42) "Путь к файлу на сервере" ["attribute"]=> string(5) "image" ["type"]=> string(4) "text" ["before"]=> string(17) "/upload/articles/" } [12]=> array(4) { ["name"]=> string(33) "Содержание статьи" ["attribute"]=> string(4) "text" ["type"]=> string(7) "tinymce" ["widgetInText"]=> int(1) } } [1]=> array(13) { ["name1"]=> string(18) "Параметры" [0]=> array(5) { ["name"]=> string(10) "Макет" ["attribute"]=> string(7) "layout1" ["type"]=> string(10) "dropDownCl" ["array"]=> array(5) { ["column1-12"]=> string(10) "column1-12" ["column2-4-8"]=> string(11) "column2-4-8" ["column2-6-6"]=> string(11) "column2-6-6" ["column2-8-4"]=> string(11) "column2-8-4" ["column2-3-9"]=> string(11) "column2-3-9" } ["addField"]=> array(1) { [0]=> array(3) { ["name"]=> string(25) "Текущий макет" ["attribute"]=> string(6) "layout" ["type"]=> string(4) "text" } } } [1]=> array(3) { ["name"]=> string(39) "Отображать Категорию" ["attribute"]=> string(10) "categoryOn" ["type"]=> string(15) "toggleButtonRow" } [2]=> array(4) { ["name"]=> string(31) "Отображать метки" ["attribute"]=> string(6) "tagsOn" ["type"]=> string(15) "toggleButtonRow" ["addField"]=> array(1) { [0]=> array(4) { ["name"]=> string(10) "Метки" ["attribute"]=> string(4) "tags" ["type"]=> string(11) "textAreaRow" ["htmlOptions"]=> array(3) { ["data-toggle"]=> string(7) "tooltip" ["data-placement"]=> string(5) "right" ["data-original-title"]=> string(25) "через запятую" } } } } [3]=> array(4) { ["name"]=> string(33) "Отображать автора" ["attribute"]=> string(7) "avtorOn" ["type"]=> string(15) "toggleButtonRow" ["addField"]=> array(1) { [0]=> array(3) { ["name"]=> string(10) "Автор" ["attribute"]=> string(5) "avtor" ["type"]=> string(12) "textFieldRow" } } } [4]=> array(4) { ["name"]=> string(37) "Отображать источник" ["attribute"]=> string(8) "sourceOn" ["type"]=> string(15) "toggleButtonRow" ["addField"]=> array(1) { [0]=> array(3) { ["name"]=> string(16) "Источник" ["attribute"]=> string(6) "source" ["type"]=> string(12) "textFieldRow" } } } [5]=> array(3) { ["name"]=> string(29) "Отображать дату" ["attribute"]=> string(6) "dataOn" ["type"]=> string(15) "toggleButtonRow" } [6]=> array(3) { ["name"]=> string(25) "Дата создания" ["attribute"]=> string(7) "created" ["type"]=> string(13) "datePickerRow" } [7]=> array(3) { ["name"]=> string(27) "Meta описание (SEO)" ["attribute"]=> string(8) "seoDescr" ["type"]=> string(11) "textAreaRow" } [8]=> array(3) { ["name"]=> string(38) "Meta ключевые слова (SEO)" ["attribute"]=> string(6) "seoKey" ["type"]=> string(11) "textAreaRow" } [9]=> array(3) { ["name"]=> string(62) "Отображать количество просмотров" ["attribute"]=> string(10) "numViewsOn" ["type"]=> string(15) "toggleButtonRow" } [10]=> array(3) { ["name"]=> string(41) "Количество просмотров" ["attribute"]=> string(8) "numViews" ["type"]=> string(4) "text" } [11]=> array(3) { ["name"]=> string(29) "Дата обновления" ["attribute"]=> string(7) "updated" ["type"]=> string(13) "datePickerRow" } } } } [1]=> array(4) { ["name"]=> string(16) "Редирект" ["attribute"]=> string(7) "referer" ["type"]=> string(6) "hidden" ["noVisibleHR"]=> string(0) "" } } ["ierarh"]=> int(0) ["_enabled":"CBehavior":private]=> bool(true) ["_owner":"CBehavior":private]=> *RECURSION* ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } } }
Yii 1: поиск по сайту - #Web-шпаргалка

Yii 1: поиск по сайту

Yii   2516  

Для проекта на Yii 1 сделаем поиск по статьям.

Поиск будет производиться по тегам и слову/словочетанию.

Сам код контроллера 



<?php

class SearchController extends Controller {

    public function actionTag($tag) {
        $tags = CHtml::encode($tag);
        if (isset($tags)) {
            $criteria = new CDbCriteria(array(
                'condition' => 'status=1',
                'order' => 'updated DESC',
            ));
            $criteria->addSearchCondition('tags', $tags);

            $dataProvider = new CActiveDataProvider('Articles', array(
                'pagination' => array(
                    'pageSize' => 7,
                    'pageVar' => 'page',
                ),
                'criteria' => $criteria,
            ));
            if ($dataProvider) {
                $this->breadcrumbs = array('Поиск по тегу: "' . $tags . '"');
                $this->pageTitle('Поиск по тегу: "' . $tags . '"');
                $this->render('tag', array(
                    'dataProvider' => $dataProvider,
                    'tag' => $tags,
                ));
            } else
                throw new CHttpException(404, 'Page not found');
        } else
            throw new CHttpException(404, 'Page not found');
    }

    public function actionIndex() {
        $query = Yii::app()->request->getParam('searchword', null);
        if (iconv_strlen($query, 'UTF-8') < 3) {
            if (isset($_GET['searchword']))
                Yii::app()->user->setFlash("error", "Минимальная длина слова для поиска должна быть больше 3 символов!");
            $query = "";
			$this->pageTitle('Поиск');
			$this->breadcrumbs = array('Поиск');
            $this->render('search');
        }
        else {
            $criteria = new CDbCriteria();
	    $criteria->addSearchCondition('status', 1);
            $criteria->addSearchCondition('name', $query);

            $criteria->addSearchCondition('text', $query, true, 'OR');

            $dataProvider = new CActiveDataProvider('Articles', array(
                'pagination' => array(
                    'pageSize' => 7, 
                    'pageVar' => 'page',
                ),
                'criteria' => $criteria,
            ));

            if ($dataProvider) {
                $this->breadcrumbs = array('Поиск: "' . $query . '"');
                $this->pageTitle('Поиск: "' . $query . '"');
                $this->render('index', array(
                    'dataProvider' => $dataProvider,
                    'query' => $query,
                ));
            } else {
                throw new CHttpException(404, 'Page not found');
            }
        }
    }

}

Функция $this->pageTitle('Поиск по тегу: "' . $tags . '"'); класса Controller устанавливает title страницы.

Ее код:


<?php

class Controller extends CController {

...
public function pageTitle($title) {
        $_title = CHtml::encode($title);
        if ($this->nameTitle) {
            return $this->pageTitle = $this->name . " - " . $_title;
        } else {
            return $this->pageTitle = "" . $_title;
        }
    }
...

}

Все будет выводиться с помощью стандартного виджета Yii CListView.

При выводе найденных статей, используется функция Helper::getFragment($name, $query), которая выводит сокращенное название статьи и Helper::getDescription($text), которая выводит описание статьи до разметки в тексте "<p><!-- pagebreak --></p>".

Далее ставиться ссылка "подробнее".

 

У меня эти функции в классе Helper, в котором находятся необходимые функции форматирования.

Код функций:


<?php

...
    public static function getFragment($text, $word, $symb = 200) {
        $text = strip_tags($text);
        $word = strip_tags($word);
        if ($word) {
            $pos = max(mb_stripos($text, $word, null, 'UTF-8') - 100, 0);
            $fragment = mb_substr($text, $pos, $symb, 'UTF-8');
            $highlighted = preg_replace('~(' . $word . ')~ui', '$1', $fragment);
        } else {
            $highlighted = mb_substr($text, 0, $symb, 'UTF-8');
        }
        return $highlighted;
    }
	
    public static function getDescription($text) {
        $_text=$text;
		$text = strstr($text, 'pagebreak');
		if($text !== false){		
			$text = explode("<p><!-- pagebreak --></p>", $_text);      
			return $text[0];
		} else {
			return "";
		}
    }
...


Скачать пример поиска на Yii.

Этот пример не надеется на премию "лучший пример поиска на Yii" ! =)


Поиск

Метки