public function run() { $category_left = LuxTree::model()->findByAttributes(array('type' => Constants::LUX_TYPE_HOME_PAGE_1, 'status' => Constants::STATUS_VISIBLE)); $category_right = LuxTree::model()->findByAttributes(array('type' => Constants::LUX_TYPE_HOME_PAGE_2, 'status' => Constants::STATUS_VISIBLE)); if ($category_left != null) { $left_blocks = LuxContentUnit::model()->findAllByAttributes(array('tree_id' => $category_left->id)); } else { $left_blocks = array(); } if ($category_right != null) { $right_blocks = LuxContentUnit::model()->findAllByAttributes(array('tree_id' => $category_right->id)); } else { $right_blocks = array(); } $this->render('title_part', array('left_blocks' => $left_blocks, 'right_blocks' => $right_blocks, 'part' => $this->part)); }
public function actionUpdatePage() { /* @var $item LuxContentUnit */ //get parameters from request $id = Yii::app()->request->getParam('id', null); $label = Yii::app()->request->getParam('label', ''); $status = Yii::app()->request->getParam('status', Constants::STATUS_HIDDEN); $tree_id = Yii::app()->request->getParam('tree_id', ''); //get multi-language arrays $titles = Yii::app()->request->getParam('title', array()); $texts = Yii::app()->request->getParam('text', array()); //try find by id $item = LuxContentUnit::model()->findByPk($id); //if not found - that means we need create if ($item == null) { $item = new LuxContentUnit(); } //changed category or not $changed = false; if (!$item->getIsNewRecord() && $item->tree_id != $tree_id) { $changed = true; } //set main params $item->label = $label; $item->status = $status; $item->type = Constants::TYPE_TEXT_BLOCK; $item->tree_id = $tree_id; //upload thumbnail $old_f_name = $item->thumb; $new_f_name = DwHelper::uploadPicAndGetPath($_FILES, 'thumbnail', $old_f_name); if ($new_f_name != "") { $item->thumb = $new_f_name; } //if this is creation if ($item->getIsNewRecord()) { //set new priority considering category if ($tree_id != '') { $item->priority = DwHelper::getNextPriorityComplex("LuxContentUnit", $tree_id, "tree_id"); } else { $item->priority = DwHelper::getNextPriority("LuxContentUnit"); } //set dates $item->date_created = time(); $item->date_changed = time(); //save $item->save(); } else { //if changed category - get next priority in category if ($changed) { $item->priority = DwHelper::getNextPriorityComplex("LuxContentUnit", $tree_id, "tree_id"); } //set date of changing $item->date_changed = time(); //update $item->update(); } //get language objects foreach (Constants::GetLngArray() as $lng) { //get lng object $itemLng = $item->getLngObject($lng); //set data $itemLng->title = $titles[$lng]; $itemLng->text = $texts[$lng]; //update or create if not exist if ($itemLng->getIsNewRecord()) { $itemLng->save(); } else { $itemLng->update(); } } //prefix for category in url $prefixRedirect = ""; //if have category - set url prefix if ($tree_id != '') { $prefixRedirect = "/cat/" . $tree_id; } //back to list $this->redirect($this->createUrl('/admin/inlux/pageslist' . $prefixRedirect)); }