public static function GetPagesSeoUrl($cat_id, $name, $slug = false) { $title = $name; if ($slug) { $title = DwHelper::url_slug($name); } $url = Yii::app()->request->baseUrl . "/" . Yii::app()->language . "/page/" . $cat_id . "/" . $title; return $url; }
public function __construct($id, $module = null) { $language = Yii::app()->request->getParam('language', DEFAULT_LANGUAGE); DwHelper::SetLanguage($language); //set meta data $this->keywords = LuxSeo::getParam('keywords'); $this->title = LuxSeo::getParam('title'); $this->description = LuxSeo::getParam('description'); parent::__construct($id, $module); }
public function actionUpdateContacts() { /* @var $contacts LuxContactInfo */ /* @var $contactsLng LuxContactInfoLng */ $id = Yii::app()->request->getParam('id', null); $label = Yii::app()->request->getParam('label', null); $email_1 = Yii::app()->request->getParam('email_1', null); $phone_1 = Yii::app()->request->getParam('phone_1', null); $phone_2 = Yii::app()->request->getParam('phone_2', null); $email_admin = Yii::app()->request->getParam('email_admin', null); $map_link = Yii::app()->request->getParam('map_link', null); $small_text_lng = Yii::app()->request->getParam('info', array()); $subject_lng = Yii::app()->request->getParam('subject', array()); $title_lng = Yii::app()->request->getParam('title', array()); $contacts = LuxContactInfo::model()->findByPk($id); if ($contacts == null) { $contacts = new LuxContactInfo(); } $contacts->email_1 = $email_1; $contacts->phone_1 = $phone_1; $contacts->phone_2 = $phone_2; $contacts->administrator_email = $email_admin; $contacts->map_link = $map_link; $contacts->label = $label; $old_f_name = $contacts->map_image; $new_f_name = DwHelper::uploadPicAndGetPath($_FILES, 'map_img', $old_f_name); if ($new_f_name != "") { $contacts->map_image = $new_f_name; } if ($contacts->isNewRecord) { $contacts->save(); } else { $contacts->update(); } foreach (Constants::GetLngArray() as $lng) { $contactsLng = $contacts->getLngObject($lng); $contactsLng->small_text = $small_text_lng[$lng]; $contactsLng->feedback_subject = $subject_lng[$lng]; $contactsLng->text = $title_lng[$lng]; if ($contactsLng->isNewRecord) { $contactsLng->save(); } else { $contactsLng->update(); } } $this->redirect($this->createUrl('/admin/inlux/contacts')); }
public static function uploadFileAndGetPath($FILES, $fieldName, $delete_old, $type = AdminFunctions::VALIDATE_TYPES_ADOBE, $returnFullPath = false, &$size = null) { if ($FILES[$fieldName]['size'] > 0) { //get type $mimeType = $FILES[$fieldName]['type']; //explode name string to get extension $extensionArr = explode(".", $_FILES[$fieldName]['name']); //get temp name $tmp_name = $FILES[$fieldName]['tmp_name']; //if type is valid if (AdminFunctions::IsValidFileType($mimeType, $type)) { //empty extension by default $extension = ''; //get extension from exploded string-array if possible if (count($extensionArr) > 1) { $extension = $extensionArr[count($extensionArr) - 1]; } //make random file name and add extension to it $randomFileName = AdminFunctions::generateString(15) . "." . $extension; //make new file path $newFilePath = Constants::UPLOAD_FILE_DIR . $randomFileName; //try to copy if (copy($tmp_name, $newFilePath)) { if ($size != null) { $size = $FILES[$fieldName]['size']; } DwHelper::deleteFile($delete_old); if ($returnFullPath) { return $newFilePath; } else { return $randomFileName; } } else { return ""; } } else { return ""; } } else { return ""; } }
public function actionUpdatePage() { /* @var $item LmtContentUnit */ //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 = LmtContentUnit::model()->findByPk($id); //if not found - that means we need create if ($item == null) { $item = new LmtContentUnit(); } //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("LmtContentUnit", $tree_id, "tree_id"); } else { $item->priority = DwHelper::getNextPriority("LmtContentUnit"); } //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("LmtContentUnit", $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/lmt/pageslist' . $prefixRedirect)); }