/** * 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 = "Описание продукции"; $id = (int) Yii::app()->request->getParam("id", 0); if ($id > 0) { $item = CatalogItems::fetchParam($id); $otherItem = CatalogItems::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("id!=:id AND category_id=:cid")->setParams(array(":id" => $item->id, ":cid" => $item->category_id->id))->setOrderBy("price")->setLimit(10)); $hotItem = CatalogItems::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("id!=:id AND is_hot=:hot")->setParams(array(":id" => $item->id, ":hot" => 1))->setOrderBy("price")->setLimit(10)); if ($item->id > 0) { $favorites = Yii::app()->request->getParam("favorites", ""); if ($favorites == "add") { $res = Yii::app()->favorites->add("catalog_items", $item->id); } $newComment = new CatalogItemsCommentsAdd(); // Сохраняем комментарий if (!empty($_POST["sentComment"])) { $newComment->setAttributesFromArray($_POST["CatalogItemsCommentsAdd"]); $newComment->date = time(); $newComment->user_id = Yii::app()->user->id; $newComment->item_id = $id; if ($newComment->save()) { $newComment->formMessage = "Комментарий успешно отправлен."; $newComment->onNewComment(new CModelEvent($newComment), array("id" => $item->id, "name" => $item->name, "subject" => $newComment->subject, "link" => SiteHelper::createUrl("/user/items/index", array("id" => $newComment->item_id)))); } } $listComments = CatalogItemsComments::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("item_id=:item_id AND is_valid=1")->setParams(array(":item_id" => $item->id))->setOrderBy("date DESC")); $this->render("item", array("item" => $item, "otherItem" => $otherItem, "hotItem" => $hotItem, "addForm" => $newComment, "listComments" => $listComments)); } else { $this->redirect("/"); } } else { $this->redirect("/"); } }
/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { $limit = 30; $p = (int) Yii::app()->request->getParam("p", 1); $catalog = Yii::app()->request->getParam("catalog", ""); Yii::app()->page->title = "Выставить слаг"; if (!empty($catalog)) { $catalogS = SiteHelper::getCamelCase($catalog); $items = $catalogS::fetchAll(DBQueryParamsClass::CreateParams()->setLimit($limit)->setCache(0)->setPage($p)); //echo sizeof( $items )."*"; //die; foreach ($items as $item) { //echo "#".$item->id."<br/>"; $item->description = str_replace("< ", "<", $item->description); if (!$item->save()) { print_r($item->getErrors()); //die; } } if (sizeof($items) == $limit) { $this->redirect(SiteHelper::createUrl("/console/CheckDescriptionTag", array("catalog" => $catalog, "p" => $p + 1))); } } else { $items = array(); } $this->render("index", array("items" => $items)); }
public function actionRecharge() { if (!Yii::app()->user->isGuest) { $error = ""; if (!empty($_POST["recharge_submit"])) { $newPlantRequest = new OrderRequest(); $price = (int) $_POST["price"]; if ($price > 0) { $newPlantRequest->user_id = Yii::app()->user->id; $newPlantRequest->type_id = 2; $newPlantRequest->status_id = 2; $newPlantRequest->date = time(); $newPlantRequest->amount = $price; if ($newPlantRequest->save()) { $this->redirect(SiteHelper::createUrl("/merchant/index", array("id" => $newPlantRequest->id))); } } else { $error = "Вы ввели не верную сумму"; } } Yii::app()->page->title = "Пополнения счета"; $this->render("recharge", array("error" => $error)); } else { $this->redirect(SiteHelper::createUrl("/")); } }
/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { $limit = 30; $p = (int) Yii::app()->request->getParam("p", 1); $catalog = Yii::app()->request->getParam("catalog", ""); Yii::app()->page->title = "Выставить слаг"; if (!empty($catalog)) { $catalogS = SiteHelper::getCamelCase($catalog); $items = $catalogS::fetchAll(DBQueryParamsClass::CreateParams()->setLimit($limit)->setCache(0)->setPage($p)); //echo sizeof( $items )."*"; //die; for ($i = 0; $i < sizeof($items); $i++) { if (strpos($items[$i]->description, "</xml>") !== false) { $arr = explode("</xml>", $items[$i]->description); $items[$i]->description = $arr[1]; if (empty($items[$i]->description)) { $items[$i]->description = " - "; } if (!$items[$i]->save()) { //print_r( $items[$i]->getErrors() ); //die; } } } if (sizeof($items) == $limit) { $this->redirect(SiteHelper::createUrl("/console/CheckDescription", array("catalog" => $catalog, "p" => $p + 1))); } } else { $items = array(); } $this->render("index", array("items" => $items)); }
/** * 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 actionDescription($gallError = "") { $this->firmId = (int) Yii::app()->request->getParam("fid", 0); $id = (int) Yii::app()->request->getParam("id", 0); // Если не указан ID фирмы, то берем ID из описания тура if ($id > 0 && $this->firmId == 0) { $tourModel = CatalogTours::fetch($id); if ($tourModel->id > 0 && $tourModel->firm_id && $tourModel->firm_id->id > 0) { $this->firmId = $tourModel->firm_id->id; } } if ($this->firmId == 0) { die("id==0"); $this->redirect(SiteHelper::createUrl("/user/firms")); } $firmModel = CatalogFirms::fetch($this->firmId); if ($firmModel->id == 0) { die("id==not correct"); $this->redirect(SiteHelper::createUrl("/user/firms")); } parent::init(); $this->addModel = "CatalogToursAdd"; $this->tableName = "catalog_tours"; $this->name = Yii::t("user", "туры"); $_POST["CatalogToursAdd"]["firm_id"] = $this->firmId; $_POST["CatalogToursAdd"]["user_id"] = Yii::app()->user->getId(); parent::actionDescription(); }
public function run() { if ($this->beginCache("socialLink_block_" . Yii::app()->getLanguage(), array('duration' => 3600))) { if (!$this->url) { $this->url = SiteHelper::createUrl("") . $_SERVER["REQUEST_URI"]; } $this->render("socialLink", array("id" => $this->id, "url" => $this->url)); $this->endCache(); } }
/** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'admin' page. * @param integer $id the ID of the model to be deleted */ public function actionDelete() { if ($this->id > 0) { $item = ExBanner::fetch($this->id); if ($item->id > 0) { $item->delete(); $this->redirect(SiteHelper::createUrl("/console/banners")); } } $this->redirect(SiteHelper::createUrl("/console/banners")); }
/** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'admin' page. * @param integer $id the ID of the model to be deleted */ public function actionDelete() { if ($this->id > 0) { $item = CatComments::fetch($this->id); if ($item->id > 0) { $item->delete(); $this->redirect(SiteHelper::createUrl("/console/comments")); } } $this->redirect(SiteHelper::createUrl("/console/comments")); }
public function actionDescription() { $slug = Yii::app()->request->getParam("slug", ""); if (!empty($slug)) { $item = CatalogMaps::fetchBySlug("map-" . $slug); Yii::app()->page->setTitle($item->name); $list = CatalogWheters::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("city_id=:id")->setParams(array(":id" => $item->city_id->id))->setLimit(-1)); $this->render("description", array("item" => $item, "list" => $list)); } else { $this->redirect(SiteHelper::createUrl("/uzbekistanMaps")); } }
/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { if (!Yii::app()->user->isGuest) { Yii::app()->page->title = "Оплата"; /* if( $_POST["register_submit_button"] ) { $gateway = Yii::app()->getComponent('payment')->getGateway('PaypalExpress'); $response = $gateway->setupPurchase(100, array( 'return_url' => $this->createAbsoluteUrl( '/payment/callback', array('success' => 1, 'order_id' => 1) ), 'cancel_return_url' => $this->createAbsoluteUrl( '/payment/callback', array('failed' => 1, 'order_id' => 1) ), 'items' => array( array( 'description' => 'Bla bla', 'unit_price' => 100, 'quantity' => 1, 'id' => 1 ) ) )); if ($response->success()) { $this->redirect($gateway->urlForToken($response->token())); } // payment controller::callback action // IPN if (isset($_REQUEST['success'], $_GET['token'], $_GET['PayerID'])) { $gateway = Yii::app()->getComponent('payment')->getGateway('PaypalExpress'); $response = $gateway->get_details_for($_GET['token'], $_GET['PayerID']); $response = $gateway->purchase($response->amount()); if ($response->success()) { // success payment } else { //error payment } } }*/ $id = Yii::app()->request->getParam("id", 0); if ($id > 0) { $order = OrderRequest::fetch($id); if ($order->id > 0 && $order->del == 0) { $this->render('index', array("controller" => $this, "model" => $order)); } } else { $this->redirect(SiteHelper::createUrl("/user/requsets")); } } }
public function run() { if ($this->beginCache('widgetInfo_' . $this->class . $this->category_id . "_" . Yii::app()->getLanguage(), array('duration' => 3600))) { $className = $this->class; if ($this->category_id > 0) { $dopCondition = " AND category_id='" . (int) $this->category_id . "'"; } else { $dopCondition = ""; } $this->render("infoWidget", array('title' => $this->title, 'link' => SiteHelper::createUrl($this->link . "/description"), 'linkAll' => SiteHelper::createUrl($this->link), 'list' => $className::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("image>''" . $dopCondition)->setOrderBy("id DESC")->setLimit(9)))); $this->endCache(); } }
/** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'admin' page. * @param integer $id the ID of the model to be deleted */ public function actionDelete() { if ($this->id > 0) { $item = I18n::fetch($this->id); if ($item->id > 0) { $item->delete(); $itemTranslate = I18nTranslate::fetch($this->id); $itemTranslate->delete(); $this->redirect(SiteHelper::createUrl("/console/variable")); } } $this->redirect(SiteHelper::createUrl("/console/variable")); }
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 actionIndex($slugInput = "") { $error = false; $slug = !empty($_GET["slug"]) ? $slug = SiteHelper::checkedVaribal($_GET["slug"]) : ""; if (empty($slug) && !empty($slugInput)) { $slug = $slugInput; } if (!empty($slug)) { $page = CatalogContent::fetchBySlug($slug); } if (!empty($page) && $page->id > 0) { $this->render('index', array("page" => $page)); } else { $this->redirect("/site/error"); } }
/** * Adds one vote to the subject votes count, a like or dislike. * @param integer $vote_id the ID of the subject * @param string $vote the vote: either like or dislike */ public function actionVote($subject_id, $vote = "") { global $arr_response; if (!Yii::app()->user->isGuest) { $subject_count = Subject::add_vote($subject_id, $vote, Yii::app()->user->id); if ($subject_count['success'] == true) { $arr_response['subject_vote'] = SiteHelper::subject_vote($subject_count['subject_id'], $subject_count['likes'], $subject_count['dislikes'], true); $arr_response['response_message'] = Yii::t('subject', 'Vote sent.'); } else { $arr_response['response_code'] = 409; $arr_response['response_message'] = $subject_count['message']; } } else { $arr_response['response_code'] = 401; $arr_response['response_message'] = Yii::t('subject', 'Sorry, you must log in to be able to vote.'); } }
public function run($args) { $list = array("catalog_users", "catalog_firms", "catalog_tours", "catalog_firms_service", "catalog_firms_items"); for ($i = 0; $i < sizeof($list); $i++) { $catalog = SiteHelper::getCamelCase($list[$i]); $listItems = $catalog::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("!EXISTS(SELECT id FROM notifications_queue WHERE catalog='" . $list[$i] . "' AND item_id=" . $list[$i] . "_as.id)")->setLimit(50)->setOrderBy("rating")); //$listItems = $catalog::fetchAll( DBQueryParamsClass::CreateParams()->setConditions("id=13")->setLimit( 100 )->setOrderBy("rating") ); if (sizeof($listItems) > 0) { foreach ($listItems as $item) { $tableName = $item->tableName(); switch ($item->tableName()) { case "catalog_users": if ($item->active == 0) { AutoNotifier::onRegistration($item); } else { $countFirms = CatalogFirms::count(DBQueryParamsClass::CreateParams()->setConditions("user_id=:uid")->setParams(array(":uid" => $item->id))); if ($countFirms == 0) { $tableName = "catalog_users_con"; AutoNotifier::onRegistrationConfirm($item); } else { continue 2; } } break; case "catalog_firms": $item->onAddFirm(new CModelEvent($item), array("status" => "reminder")); break; case "catalog_tours": $item->onAddTour(new CModelEvent($item), array("status" => "reminder")); break; case "catalog_firms_items": $item->onAddFirmsItems(new CModelEvent($item), array("status" => "reminder")); break; case "catalog_firms_service": $item->onAddFirmsService(new CModelEvent($item), array("status" => "reminder")); break; case "catalog_firms_banner": $item->onAddFirmsBanners(new CModelEvent($item), array("status" => "reminder")); break; } AutoNotifier::addInNotificationsQueue($tableName, $item->id, 0); } return ""; } } }
public function actionSave() { $addModel = new CatalogWorkAdd(); if (!empty($_POST["CatalogWorkAdd"]) && !Yii::app()->user->isGuest) { $addModel->setAttributesFromArray($_POST["CatalogWorkAdd"]); $addModel->user_id = Yii::app()->user->getId(); $addModel->status_id = 1; $addModel->active = 1; $addModel->date = time(); if ($addModel->save()) { $id = $addModel->id; $this->redirect(SiteHelper::createUrl("/adsUsers", array("saved" => $id))); } else { $p = (int) Yii::app()->request->getParam("p", 1); $items = CatalogWork::fetchAll(DBQueryParamsClass::CreateParams()->setCache(0)->setLimit(25)->setPage($p)->setOrderBy("id DESC")); $this->render("index", array("items" => $items, "addModel" => $addModel)); } } }
public function check_passwords($attribute, $params) { if (!$this->hasErrors()) { $key = !empty($_GET["key"]) ? SiteHelper::checkedVaribal($_GET["key"], "string") : ""; $confirm = CatalogUsersConfirm::findByAttributes(array("confirm_key" => $key)); if (!empty($confirm) && sizeof($confirm) == 1) { $userModel = CatalogUsers::fetch($confirm[0]->user_id->id); if ($userModel->active == 0) { $error = Yii::t("models", "Ваш аккаунт не активирован"); } } else { $error = Yii::t("models", "Указан не верный ключ"); } if (!empty($error)) { $this->addErrors(array("0" => $error)); } else { $confirm[0]->delete(); } } }
public function check_exists_params($attribute, $params) { if (!$this->hasErrors()) { $identity = new UserIdentity($this->email, $this->password); $errorCode = $identity->authenticate(); if ($errorCode == 0) { Yii::app()->user->login($identity); } else { if ($errorCode == 100) { $textError = Yii::t("models", "Вы не подтвердили Свой Email") . ":" . $this->email . "<br/>"; $textError .= Yii::t("models", "Вам по почте должно было прийти письмо для подтверждения регистрации.") . "<br/><br/><b>" . Yii::t("models", "Письмо не пришло?") . "</b><br/><a href=\"" . SiteHelper::createUrl("/user/default/resend", array("email" => $this->email)) . "\">" . Yii::t("models", "отправить заново письмо для подтверждения регистрации на") . " " . $this->email . "</a>\n <br/><br/><b>" . Yii::t("models", "Все равно не пришло?</b><br/>Это странно, тогда Вам необходимо будет написать, с Email который вы указали при регистрации, письмо в службу тех. поддержки") . " <a href=\"mailto:" . Yii::app()->params["supportEmail"] . "\">" . Yii::app()->params["supportEmail"] . "</a><br/>" . Yii::t("models", "Пример письма:<br/>Заголовок письма - У меня проблемы с регистрацией<br/>Текст сообщения - Разберитесь пожалуйста"); $this->addErrors(array("0" => $textError)); } else { $textError = "Вы ввели не верный Email или ПАРОЛЬ<br/>"; $textError .= "<br/><b>" . Yii::t("models", "Забыли пароль?") . "</b><br/><a href=\"" . SiteHelper::createUrl("/user/default/lost") . "\">" . Yii::t("models", "восстановить пароль") . "</a>"; $this->addErrors(array("0" => $textError)); } } } }
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("/")); } }
/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { $limit = 50; $p = (int) Yii::app()->request->getParam("p", 1); $catalog = Yii::app()->request->getParam("catalog", ""); Yii::app()->page->title = "Выставить слаг"; if (!empty($catalog)) { $catalogS = SiteHelper::getCamelCase($catalog); $items = $catalogS::fetchAll(DBQueryParamsClass::CreateParams()->setLimit($limit)->setCache(0)->setPage($p)); sizeof($items); for ($i = 0; $i < sizeof($items); $i++) { $items[$i]->slug = SiteHelper::getSlug($items[$i]); } if (sizeof($items) > 0) { $this->redirect(SiteHelper::createUrl("/console/SetSlug", array("catalog" => $catalog, "p" => $p + 1))); } } else { $items = array(); } $this->render("index", array("items" => $items)); }
public function run($args) { $list = NotificationsQueue::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("date<=:date AND step>-1")->setParams(array(":date" => time()))->setLimit(50)->setCache(0)); foreach ($list as $item) { $catalogClass = SiteHelper::getCamelCase($item->catalog); $itemObj = $catalogClass::fetch($item->item_id); if (!$item->step) { $item->step = 0; } $step = $item->step < 8 ? $item->step + 1 : -1; //print_r( $item ); // Добавляем в очередь на нотификацию // В течении 24 часов после добавления или сохранения пользователю приходят уведомления // О том что заполнил не полностью, не опубликовал, не добавил картинок и т.д. AutoNotifier::addInNotificationsQueue($item->catalog, $itemObj->id, $step); switch ($item->catalog) { case "catalog_users": AutoNotifier::onRegistration($itemObj); break; case "catalog_users_con": AutoNotifier::onRegistrationConfirm($itemObj); break; case "catalog_firms": $itemObj->onAddFirm(new CModelEvent($itemObj), array("status" => "reminder")); break; case "catalog_tours": $itemObj->onAddTour(new CModelEvent($itemObj), array("status" => "reminder")); break; case "catalog_firms_items": $itemObj->onAddFirmsItems(new CModelEvent($itemObj), array("status" => "reminder")); break; case "catalog_firms_service": $itemObj->onAddFirmsService(new CModelEvent($itemObj), array("status" => "reminder")); break; case "catalog_firms_banner": $itemObj->onAddFirmsBanners(new CModelEvent($itemObj), array("status" => "reminder")); break; } } }
public static function setTranslate($model, $transModel, $lang = "en") { $lA = explode("-", $lang); $lang = $lA[0]; $name = TranslateHelper::translate($model->name, $lang); if (property_exists($model, "description")) { if ($model->description) { $text = TranslateHelper::translate($model->description, $lang); } else { $text = ""; } } $text = str_replace(array("< p", "< div"), array("<p", "<div"), $text); $requiredFields = $model->getSafeAtributes(); for ($i = 0; $i < sizeof($requiredFields); $i++) { $field = trim($requiredFields[$i]); $transModel->{$field} = $model->{$field}; } $transModel->id = $model->id; $transModel->name = $name; if (property_exists($transModel, "location")) { if ($model->location) { $transModel->location = TranslateHelper::translate($model->location, $lang); } } if (property_exists($transModel, "address")) { if ($model->address) { $transModel->address = TranslateHelper::translate($model->address, $lang); } } if (property_exists($model, "description")) { $transModel->description = $text; } if (!$transModel->save()) { print_r($transModel->getErrors()); } elseif (property_exists($transModel, "slug")) { SiteHelper::getSlug($transModel); } }
public function init() { parent::init(); $this->addModel = "CatalogFirmsServiceAdd"; $this->tableName = "catalog_firms_service"; $this->name = Yii::t("user", "Услуги компании"); $this->firmId = (int) Yii::app()->request->getParam("fid", 0); $id = (int) Yii::app()->request->getParam("id", 0); $return = false; // Если не указан ID фирмы, то берем ID из описания тура if ($id > 0 && $this->firmId == 0) { $class = $this->addModel; $tourModel = $class::fetch($id); if ($tourModel->id > 0 && $tourModel->firm_id && $tourModel->firm_id->id > 0) { $this->firmId = $tourModel->firm_id->id; } else { $return = true; } } if ($return == true) { $this->redirect(SiteHelper::createUrl("/user/firms")); } }
public function renderTags($slug) { if (Yii::app()->controller->beginCache($slug . "-page-" . Yii::app()->getLanguage(), array('duration' => 3600 * 24 * 3))) { $params = $this->tag_params; if (!empty($params[$slug])) { $paramArray = $params[$slug]; } elseif (!empty($params["default"])) { $paramArray = $params["default"]; } $listClass = array("key01", "key02", "key03", "key04", "key05", "key06"); if (!empty($paramArray)) { $listTags = array(); foreach ($paramArray as $key => $value) { $modelClass = SiteHelper::getCamelCase($key); $sql = "del=0"; if (!empty($value[2])) { $sql .= " AND " . $value[2]; } $link = SiteHelper::createUrl($value[0]); $listItems = $modelClass::fetchAll(DBQueryParamsClass::CreateParams()->setConditions($sql)->setLimit($value[1])->setOrderBy("id DESC")); foreach ($listItems as $item) { if ($item->slug) { $randClass = array_rand($listClass, 1); $item->name = SiteHelper::getSubTextOnWorld($item->name, 60); $listTags[] = '<a href="' . $link . "/" . $item->slug . '.html" title="' . SiteHelper::getStringForTitle($item->name) . '" class="' . $listClass[$randClass] . '">' . $item->name . '</a>'; } } } shuffle($listTags); shuffle($listTags); foreach ($listTags as $key => $item) { echo $item . " "; } } Yii::app()->controller->endCache(); } }
</div> <a href="<?php echo SiteHelper::createUrl("/tours/description") . "/" . $tour->slug; ?> .html" title="<?php echo SiteHelper::getStringForTitle($tour->category_id->name . "," . $tour->name); ?> "><?php echo SiteHelper::getSubTextOnWorld($tour->name, 100); ?> </a><br/> <?php echo SiteHelper::getSubTextOnWorld($tour->description, 150); ?> <div class="LParams"> <a href="<?php echo SiteHelper::createUrl("/travelAgency/description") . "/" . $tour->firm_id->slug; ?> .html" title="<?php echo Yii::t("page", "туристическая фирма"); ?> <?php echo SiteHelper::getStringForTitle($tour->firm_id->name); ?> "><?php echo $tour->firm_id->name; ?> </a> </div> </div>
echo Yii::t("user", "Удалить"); ?> </a> </div> </td> </tr> <?php } ?> </table> <?php if (sizeof($items) == 0) { ?> <div class="textAlignCenter"><?php echo Yii::t("page", "Список пуст"); ?> </div><?php } ?> <br/> <br/> <center> <a href="<?php echo SiteHelper::createUrl("/user/sales/description"); ?> "><?php echo Yii::t("user", "Добавить акцию"); ?> </a> </center> </div>
static function saveRelation(CCModel $model, $values) { foreach ($model->relations() as $value) { if ($value[0] == "CManyManyRelation") { $leftClass = $value[1]; $rightClass = SiteHelper::getCamelCase($model->tableName()); CatRelations::sql("DELETE FROM cat_relations WHERE ( leftClass='" . $leftClass . "' AND rightClass='" . $rightClass . "') OR ( leftClass='" . $rightClass . "' AND rightClass='" . $leftClass . "') "); foreach ($values as $value2) { $new = new CatRelations(); $new->leftClass = $leftClass; $new->rightClass = $rightClass; $new->leftId = $value2; $new->rightId = $model->id; $new->save(); $new = new CatRelations(); $new->leftClass = $rightClass; $new->rightClass = $leftClass; $new->leftId = $model->id; $new->rightId = $value2; $new->save(); } } } }
public function render($view, $data = array(), $return = false) { if ($this->beforeRender($view)) { if (!Yii::app()->user->isGuest) { $userModel = CatalogUsers::fetch(Yii::app()->user->getId()); if ($userModel->id > 0) { $USER = $userModel; } else { Yii::app()->user->logout(); $this->redirect(SiteHelper::createUrl("/")); } } else { $USER = new CatalogUsers(); } $data = array_merge($data, array("Theme" => Yii::app()->getTheme(), "controller" => $this, "USER" => $USER)); $output = $this->renderPartial($view, $data, true); if (($layoutFile = $this->getLayoutFile($this->layout)) !== false) { $output = $this->renderFile($layoutFile, array_merge($data, array("content" => $output)), true); } $this->afterRender($view, $output); $output = $this->processOutput($output); if ($return) { return $output; } else { echo $output; } } }