protected function renderContent() { //import model Yii::import('application.modules.support.models.SupportMailSetting'); Yii::import('application.modules.support.models.SupportContacts'); $model = OmmuMeta::model()->findByPk(1, array('select' => 'office_place, office_village, office_district, office_city, office_province, office_country, office_zipcode, office_phone, office_fax, office_hotline, office_email')); $this->render('front_contact_details', array('model' => $model)); }
protected function renderContent() { $module = strtolower(Yii::app()->controller->module->id); $controller = strtolower(Yii::app()->controller->id); $action = strtolower(Yii::app()->controller->action->id); $currentAction = strtolower(Yii::app()->controller->id . '/' . Yii::app()->controller->action->id); $currentModule = strtolower(Yii::app()->controller->module->id . '/' . Yii::app()->controller->id); $currentModuleAction = strtolower(Yii::app()->controller->module->id . '/' . Yii::app()->controller->id . '/' . Yii::app()->controller->action->id); //import model Yii::import('application.modules.support.models.SupportContactCategory'); Yii::import('application.modules.support.models.SupportContacts'); $model = OmmuMeta::model()->findByPk(1); $criteriaSosMed = new CDbCriteria(); $criteriaSosMed->condition = 't.publish = :publish'; $criteriaSosMed->params = array(':publish' => 1); $criteriaSosMed->order = 't.id DESC'; $criteriaSosMed->group = 't.cat_id'; $SosMed = SupportContacts::model()->findAll($criteriaSosMed); $this->render('contact_meta_information', array('module' => $module, 'controller' => $controller, 'action' => $action, 'currentAction' => $currentAction, 'currentModule' => $currentModule, 'currentModuleAction' => $currentModuleAction, 'model' => $model, 'SosMed' => $SosMed)); }
public function render($view, $data = null, $return = false) { if ($this->beforeRender($view)) { /** * Custom condition ** * guest page * registers all meta tags * unset session user_id (after register) * set theme is active * Set comment plugin_id * Set owner and user info * */ // set language sessions if (isset($_GET['lang']) && $_GET['lang'] != '') { Yii::app()->session['language'] = $_GET['lang']; } // guest page if ($this->dialogFixed == true) { $this->pageGuest = true; } // registers all meta tags if (!Yii::app()->request->isAjaxRequest) { $meta = OmmuMeta::model()->findByPk(1, array('select' => 'office_on, google_on, twitter_on, facebook_on')); if ($meta->office_on == 1) { Yii::app()->meta->renderGoogleOwnerMetaTags(); } if ($meta->google_on == 1) { Yii::app()->meta->renderGooglePlusMetaTags(); } if ($meta->facebook_on == 1) { Yii::app()->meta->renderFacebookMetaTags(); } if ($meta->twitter_on == 1) { Yii::app()->meta->renderTwitterMetaTags(); } } // unset session user_id (after register) if (isset(Yii::app()->session['signup_user_id']) && ($currentModule != 'users/signup' || $currentModuleAction == 'users/signup/success')) { unset(Yii::app()->session['signup_user_id']); } // set theme is active if (!Yii::app()->request->isAjaxRequest) { Yii::app()->session['theme_active'] = Yii::app()->theme->name; if ($this->dialogDetail == true) { Yii::app()->session['current_url'] = $this->dialogGroundUrl; } } // Set owner and user info if (empty($this->ownerId)) { $owner = !Yii::app()->user->isGuest ? 'Hi, ' . Yii::app()->user->displayname : 'Hi, Guest'; Yii::app()->params['owner_id'] = ''; } else { $user = Users::model()->findByPk($this->ownerId, array('select' => 'displayname')); $owner = $user->displayname; Yii::app()->params['owner_id'] = $this->ownerId; } Yii::app()->params['owner'] = $owner; parent::render($view, $data, $return); } }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionSetting() { $model = OmmuMeta::model()->findByPk(1); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['OmmuMeta'])) { $model->attributes = $_POST['OmmuMeta']; $model->scenario = 'contact'; $jsonError = CActiveForm::validate($model); if (strlen($jsonError) > 2) { $errors = $model->getErrors(); $summary['msg'] = "<div class='errorSummary'><strong>" . Yii::t('phrase', 'Please fix the following input errors:') . "</strong>"; $summary['msg'] .= "<ul>"; foreach ($errors as $key => $value) { $summary['msg'] .= "<li>{$value[0]}</li>"; } $summary['msg'] .= "</ul></div>"; $message = json_decode($jsonError, true); $merge = array_merge_recursive($summary, $message); $encode = json_encode($merge); echo $encode; } else { if (isset($_GET['enablesave']) && $_GET['enablesave'] == 1) { if ($model->save()) { echo CJSON::encode(array('type' => 0, 'msg' => '<div class="errorSummary success"><strong>' . Yii::t('phrase', 'Address setting success updated.') . '</strong></div>')); } else { print_r($model->getErrors()); } } } Yii::app()->end(); } else { $this->pageTitle = Yii::t('phrase', 'Address Settings'); $this->pageDescription = ''; $this->pageMeta = ''; $this->render('admin_setting', array('model' => $model)); } }
/** * Lists all models. */ public function actionOffice() { $this->layout = false; $model = OmmuMeta::model()->findAll(array()); $setting = OmmuSettings::model()->findByPk(1, array('select' => 'site_title')); $return = array(); $return['maps'] = array('icon' => Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->request->baseUrl . '/public/marker_default.png', 'width' => 42, 'height' => 48); $i = 0; foreach ($model as $val) { $i++; $point = explode(',', $val->office_location); $return['data'][] = array('id' => $i, 'lat' => $point[0], 'lng' => $point[1], 'name' => $val->office_name != '' ? $val->office_name : $setting->site_title, 'address' => $val->office_place . '. ' . $val->office_village . ', ' . $val->office_district . ', ' . $val->view_meta->city . ', ' . $val->view_meta->province . ', ' . $val->view_meta->country . ', ' . $val->office_zipcode); } echo CJSON::encode($return); }
/** * Initialize * * load some custom components here, for example * theme, url manager, or config from database Alhamdulillah :) */ public function init() { /** * set default themes */ $theme = $this->getDefaultTheme(); if (isset($_GET['theme'])) { $theme = trim($_GET['theme']); } Yii::app()->theme = $theme; /** * controllerMap */ $themePath = Yii::getPathOfAlias('webroot.themes.' . $theme) . DS . $theme . '.yaml'; $arrayThemeSpyc = Spyc::YAMLLoad($themePath); $controllerSpyc = $arrayThemeSpyc['controller']; if (!empty($controllerSpyc)) { foreach ($controllerSpyc as $key => $val) { $controllerMap[$key] = 'webroot.themes.' . $theme . '.controllers.' . $val; } Yii::app()->controllerMap = $controllerMap; } /** * set url manager */ $rules = array('' => 'site/index', '<action:(login|logout)>' => 'site/<action>', '<id:\\d+>-<t:[\\w\\-]+>-<a:[\\w\\-]+>' => 'page/view', '<id:\\d+>-<t:[\\w\\-]+>' => 'page/view', '<module:\\w+>/<controller:\\w+>/<t:[\\w\\-]+>-<id:\\d+>-<category:\\d+>' => '<module>/<controller>/index', '<module:\\w+>/<controller:\\w+>/<t:[\\w\\-]+>-<category:\\d+>' => '<module>/<controller>/index', '<module:\\w+>/<controller:\\w+>/<t:[\\w\\-]+>-<id:\\d+>' => '<module>/<controller>/index', '<module:\\w+>/<controller:\\w+>/<id:\\d+>' => '<module>/<controller>/index', '<module:\\w+>/<controller:\\w+>' => '<module>/<controller>/index', '<module:\\w+>/<controller:\\w+>/view/<t:[\\w\\-]+>-<id:\\d+>-<photo:\\d+>' => '<module>/<controller>/view', '<module:\\w+>/<controller:\\w+>/view/<t:[\\w\\-]+>-<id:\\d+>' => '<module>/<controller>/view', '<module:\\w+>/<controller:\\w+>/<action:\\w+>/<t:[\\w\\-]+>-<id:\\d+>' => '<module>/<controller>/<action>', '<module:\\w+>/<controller:\\w+>/<action:\\w+>/<id:\\d+>' => '<module>/<controller>/<action>', '<module:\\w+>/<controller:\\w+>/<action:\\w+>' => '<module>/<controller>/<action>', '<module:\\w+>/<controller:\\w+>' => '<module>/<controller>', '<controller:\\w+>/<t:[\\w\\-]+>-<id:\\d+>-<category:\\d+>' => '<controller>/index', '<controller:\\w+>/<t:[\\w\\-]+>-<category:\\d+>' => '<controller>/index', '<controller:\\w+>/<t:[\\w\\-]+>-<id:\\d+>' => '<controller>/index', '<controller:\\w+>/<id:\\d+>' => '<controller>/index', '<controller:\\w+>' => '<controller>/index', '<controller:\\w+>/view/<t:[\\w\\-]+>-<id:\\d+>-<photo:\\d+>' => '<controller>/view', '<controller:\\w+>/view/<t:[\\w\\-]+>-<id:\\d+>' => '<controller>/view', '<controller:\\w+>/<action:\\w+>/<t:[\\w\\-]+>-<id:\\d+>' => '<controller>/<action>', '<controller:\\w+>/<action:\\w+>/<id:\\d+>' => '<controller>/<action>', '<controller:\\w+>/<action:\\w+>' => '<controller>/<action>', '<controller:\\w+>' => '<controller>'); /** * Set default controller for homepage, it can be controller, action or module * example: * controller: 'site' * controller from module: 'pose/site/index'. */ $default = OmmuPlugins::model()->findByAttributes(array('defaults' => 1), array('select' => 'folder')); if ($default == null || $default->folder == '-' || $default->actived == '2') { $rules[''] = 'site/index'; } else { $url = $default->folder != '-' ? $default->folder : 'site/index'; Yii::app()->defaultController = trim($url); $rules[''] = trim($url); } /** * Split rules into 2 part and then insert url from tabel between them. * and then merge all array back to $rules. */ $module = OmmuPlugins::model()->findAll(array('select' => 'folder', 'condition' => 'actived != 0')); $moduleRules = array(); $sliceRules = $this->getRulePos($rules); if ($module !== null) { foreach ($module as $key => $val) { $moduleRules[$val->folder] = $val->folder; } } $rules = array_merge($sliceRules['before'], $moduleRules, $sliceRules['after']); Yii::app()->setComponents(array('urlManager' => array('urlFormat' => 'path', 'showScriptName' => false, 'rules' => $rules))); Yii::setPathOfAlias('modules', Yii::app()->basePath . DIRECTORY_SEPARATOR . 'modules'); /** * Registers meta tags declared * google discoverability * google plus * facebook opengraph * twitter */ $meta = OmmuMeta::model()->findByPk(1); $images = $meta->meta_image != '' ? $meta->meta_image : 'meta_default.png'; $metaImages = Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->request->baseUrl . '/public/' . $images; // Google Discoverability mata tags $point = explode(',', $meta->office_location); // Facebook mata tags $arrayFacebookGlobal = array('og:type' => $meta->facebook_type == 1 ? 'profile' : 'website', 'og:title' => 'MY_WEBSITE_NAME', 'og:description' => 'MY_WEBSITE_DESCRIPTION', 'og:image' => $metaImages); if ($meta->facebook_sitename != '') { $arrayFacebookGlobal['og:site_name'] = $meta->facebook_sitename; } if ($meta->facebook_see_also != '') { $arrayFacebookGlobal['og:see_also'] = $meta->facebook_see_also; } if ($meta->facebook_admins != '') { $arrayFacebookGlobal['fb:admins'] = $meta->facebook_admins; } if ($meta->facebook_type == 1) { $arrayFacebook = array('profile:first_name' => $meta->facebook_profile_firstname, 'profile:last_name' => $meta->facebook_profile_lastname, 'profile:username' => $meta->facebook_profile_username); } else { $arrayFacebook = array(); } // Twitter mata tags if ($meta->twitter_card == 1) { $cardType = 'summary'; $arrayTwitter = array(); } else { if ($meta->twitter_card == 2) { $cardType = 'summary_large_image'; $arrayTwitter = array(); } else { if ($meta->twitter_card == 3) { $cardType = 'photo'; $arrayTwitter = array('twitter:image:width' => $meta->twitter_photo_width, 'twitter:image:height' => $meta->twitter_photo_height); } else { $cardType = 'app'; if ($meta->twitter_country != '') { $arrayTwitter['twitter:app:country'] = $meta->twitter_country; } if ($meta->twitter_iphone_name != '') { $arrayTwitter['twitter:app:name:iphone'] = $meta->twitter_iphone_name; } if ($meta->twitter_iphone_id != '') { $arrayTwitter['twitter:app:id:iphone'] = $meta->twitter_iphone_id; } if ($meta->twitter_iphone_url != '') { $arrayTwitter['twitter:app:url:iphone'] = $meta->twitter_iphone_url; } if ($meta->twitter_ipad_name != '') { $arrayTwitter['twitter:app:name:ipad'] = $meta->twitter_ipad_name; } if ($meta->twitter_ipad_id != '') { $arrayTwitter['twitter:app:id:ipad'] = $meta->twitter_ipad_id; } if ($meta->twitter_ipad_url != '') { $arrayTwitter['twitter:app:url:ipad'] = $meta->twitter_ipad_url; } if ($meta->twitter_googleplay_name != '') { $arrayTwitter['twitter:app:name:googleplay'] = $meta->twitter_googleplay_name; } if ($meta->twitter_googleplay_id != '') { $arrayTwitter['twitter:app:id:googleplay'] = $meta->twitter_googleplay_id; } if ($meta->twitter_googleplay_url != '') { $arrayTwitter['twitter:app:url:googleplay'] = $meta->twitter_googleplay_url; } if (empty($arrayTwitter)) { $arrayTwitter = array(); } } } } $arrayTwitterGlobal = array('twitter:card' => $cardType, 'twitter:site' => $meta->twitter_site, 'twitter:title' => 'MY_WEBSITE_NAME', 'twitter:description' => 'MY_WEBSITE_DESCRIPTION', 'twitter:image' => $metaImages); if (in_array($meta->twitter_card, array(2))) { $arrayTwitterGlobal['twitter:creator'] = $meta->twitter_creator; } if ($meta->meta_image_alt != '' && in_array($meta->meta_image_alt, array(1, 2))) { $arrayTwitterGlobal['twitter:image:alt'] = $meta->meta_image_alt; } /** * Registe Meta Tags */ Yii::app()->setComponents(array('meta' => array('class' => 'application.components.plugin.MetaTags', 'googleOwnerTags' => array('place:location:latitude' => $point[0], 'place:location:longitude' => $point[1], 'business:contact_data:street_address' => $meta->office_place . ', ' . $meta->office_village . ', ' . $meta->office_district, 'business:contact_data:country_name' => $meta->view_meta->country, 'business:contact_data:locality' => $meta->view_meta->city, 'business:contact_data:region' => $meta->office_district, 'business:contact_data:postal_code' => $meta->office_zipcode, 'business:contact_data:email' => $meta->office_email, 'business:contact_data:phone_number' => $meta->office_phone, 'business:contact_data:fax_number' => $meta->office_fax, 'business:contact_data:website' => $meta->office_website), 'googlePlusTags' => array('name' => 'MY_WEBSITE_NAME', 'description' => 'MY_WEBSITE_DESCRIPTION', 'image' => $metaImages), 'facebookTags' => CMap::mergeArray($arrayFacebookGlobal, $arrayFacebook), 'twitterTags' => CMap::mergeArray($arrayTwitterGlobal, $arrayTwitter)))); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = OmmuMeta::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, Yii::t('phrase', 'The requested page does not exist.')); } return $model; }