public function actionIndex()
 {
     Yii::app()->page->title = Yii::t("page", "Частные туристические объявления");
     $p = (int) Yii::app()->request->getParam("p", 1);
     $saved = (int) Yii::app()->request->getParam("saved", 0);
     $categoryId = "status_id = 1";
     $categoryModel = new CatalogItemsCategory();
     foreach ($_GET as $key => $item) {
         if (!empty($_GET[$key]) && $_GET[$key] != "null") {
             continue;
         }
         $categoryModel = CatalogItemsCategory::fetchBySlug($key);
         if ($categoryModel->id > 0) {
             $categoryId = $categoryModel->id;
         }
         break;
     }
     $addModel = new CatalogItemsAdd();
     if (!empty($saved)) {
         $addModel->formMessage = Yii::t("addsuser", "Ваше объявление успешно опубликовано.<br/>Для добавления большого количества картинок для объявления или его редактирования пройдите по ссылке") . " <a href=\"" . SiteHelper::createUrl("/user/items/description", array("id" => $saved)) . "\">" . SiteHelper::createUrl("/user/items/description", array("id" => $saved)) . "</a>";
     }
     $condition = "";
     $params = array();
     if ($categoryId > 0) {
         $params = array_merge($params, array(":category" => $categoryId));
         $condition = " category_id=:category";
     }
     $items = CatalogItems::fetchAll(DBQueryParamsClass::CreateParams()->setConditions($condition)->setParams($params)->setCache(0)->setLimit(25)->setPage($p)->setOrderBy("id DESC"));
     $this->render("index", array("items" => $items, "categoryModel" => $categoryModel, "addModel" => $addModel));
 }
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     Yii::app()->page->title = "Каталог продукции";
     if (!Yii::app()->user->isGuest) {
         $itemModel = new CatalogItemsAdd();
         if (!empty($_POST["save_profile"])) {
             $itemModel->setAttributesFromArray($_POST["CatalogItemsAdd"]);
             $itemModel->user_id = Yii::app()->user->id;
             $itemModel->status_id = 3;
             // По умолчанию не активен
             $itemModel->date = time();
             if ($itemModel->saveParam()) {
                 $itemModel->onAddItem(new CModelEvent($itemModel), array("id" => $itemModel->id, "subject" => $itemModel->name, "date" => date("d.m.Y"), "description" => SiteHelper::getSubTextOnWorld($itemModel->description, 200), "link" => Yii::app()->params["adminEmail"] . SiteHelper::createUrl("/user/items/description/", array("id" => $itemModel->id))));
                 $this->redirect(SiteHelper::createUrl("/catalog/add/save", array("id" => $itemModel->id)));
             }
         }
         $addDopParams = null;
         if ($itemModel->category_id && $itemModel->category_id->id > 0) {
             $categoryModel = CatalogItemsCategory::fetch($itemModel->category_id->id);
             if ($categoryModel->table_name) {
                 $catalogClass = SiteHelper::getCamelCase($categoryModel->table_name);
                 $addDopParams = new $catalogClass();
             }
         }
         $this->render("add", array("form" => $itemModel, "addDopParams" => $addDopParams));
     } else {
         Yii::app()->session['redirect'] = SiteHelper::createUrl("/catalog/add");
         $this->render("addauthWidget");
     }
 }
 public function refreshParam()
 {
     if ($this->category_id > 0) {
         $categoryModel = CatalogItemsCategory::fetch($this->category_id);
         if ($categoryModel->table_name) {
             $categoryTable = SiteHelper::getCamelCase($categoryModel->table_name);
             $paramItem = $categoryTable::findByAttributes(array("item_id" => $this->id));
             if (sizeof($paramItem) > 0) {
                 $this->param = $paramItem[0];
             } else {
                 $this->param = new $categoryTable();
             }
         }
     }
 }
 public function textFind($findText)
 {
     Yii::app()->page->title = "Поиск продукции";
     if (!empty($findText)) {
         $arrayData = array();
         $listCid = CatalogItemsCategory::sql("SELECT c2.name as cid_name, c.name, c.id, count(i.id) as c FROM catalog_items_category c, catalog_items_category c2, catalog_items i WHERE ( i.name like '%" . $findText . "%' OR i.description like '%" . $findText . "%' ) AND c.id=i.category_id AND c2.id = c.owner GROUP BY i.category_id");
         for ($i = 0; $i < sizeof($listCid); $i++) {
             $cidName = $listCid[$i]["cid_name"];
             if (!empty($arrayData[$cidName]["count"])) {
                 $arrayData[$cidName]["count"] += $listCid[$i]["c"];
             } else {
                 $arrayData[$cidName]["count"] = $listCid[$i]["c"];
             }
             $arrayData[$cidName]["items"][] = $listCid[$i];
         }
         $items = CatalogItems::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("name like '%" . $findText . "%' OR description like '%" . $findText . "%'")->setLimit(10));
         $this->render("index", array("arrayData" => $arrayData, "items" => $items));
     } else {
         $this->redirect(SiteHelper::createUrl("/"));
     }
 }
Exemple #5
0
        <div class="blockName">категории</div>
        <ul>
        <?php 
foreach (CatalogItemsCategory::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("owner=:cat AND id!=2")->setParams(array(":cat" => 0))->setOrderBy("name")) as $item) {
    ?>
            <li>
                <a href="#" class="BNcat" title="<?php 
    echo $item->name;
    ?>
"><?php 
    echo $item->name;
    ?>
</a>
                <?php 
    $i = 0;
    foreach (CatalogItemsCategory::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("owner=:cat")->setParams(array(":cat" => $item->id))->setOrderBy("name")) as $item2) {
        ?>
                    <?php 
        if ($i == 0) {
            ?>
<ul <?php 
            if ($cidOwner->owner != $item->id) {
                ?>
class="displayNone"<?php 
            }
            ?>
><?php 
        }
        ?>
                    <li><a href="<?php 
        echo SiteHelper::createUrl("/catalog/default/index", array("cid" => $item2->id));
Exemple #6
0
<div class="leftBlock">
    <?php 
$this->widget("authWidget");
?>
    <div id="LMenu">
        <div class="MNHeader"><?php 
echo Yii::t("page", "Категории объявлений");
?>
</div>
        <?php 
foreach (CatalogItemsCategory::fetchAll(DBQueryParamsClass::CreateParams()->setOrderBy("pos, name")) as $item) {
    ?>
            <div class="LMItem">
                <a href="<?php 
    echo SiteHelper::createUrl("/adsUsers") . "/" . $item->slug;
    ?>
.html" title="<?php 
    echo $item->name;
    ?>
 - <?php 
    echo Yii::t("page", "категория частных объявлений");
    ?>
"><?php 
    echo $item->name;
    ?>
</a>
            </div>
        <?php 
}
?>
    </div>