public static function display_seo()
 {
     $pageTitle = Yii::app()->name;
     $pageDescription = Yii::app()->name;
     if (isset($_GET['id'])) {
         $meta = Seo::model()->findByAttributes(array('controller' => Yii::app()->controller->id, 'action' => Yii::app()->controller->action->id, 'item_id' => $_GET['id']));
         if ($meta) {
             $pageTitle = $meta->title;
             $pageDescription = $meta->description;
         }
     }
     echo PHP_EOL . '<meta name="description" content="' . CHtml::encode($pageDescription) . '">' . PHP_EOL;
     echo '<title>' . CHtml::encode($pageTitle) . '</title>' . PHP_EOL;
 }
 public function parseUrl($manager, $request, $pathInfo, $rawPathInfo)
 {
     //file_put_contents("log.txt", print_r($pathInfo, true), FILE_APPEND);
     $al = $pathInfo;
     // предположим, что передавамый путь псевдоним
     $alias = Seo::model()->findByAttributes(array('url' => $al));
     if (!$alias) {
         // если ничего загрузить не удалось
         return false;
         // возращаем обычный url
     } else {
         //file_put_contents("log.txt", print_r($_GET, true));
         $route = $alias->controller . '/' . $alias->action;
         // скливаем маршрут из контроллера и действия
         //$_GET = $this->ParamsStringIntoArray('id='.$alias->item_id); // "набиваем" $_GET массив оригинальными значениями, извлекая их из строки $alias->item_id
         $_GET['id'] = $alias->item_id;
         return $route;
         // возвращаем оригинальный маршрут (GET параметры уже прикреплены)
     }
 }
Exemple #3
0
 public function autosetSeoData($pageName, $params = array())
 {
     array_unshift($params, $pageName);
     $pageId = implode('_', $params);
     $seo = Seo::model()->findByAttributes(array('page_identifier' => $pageId));
     if (!$seo) {
         return;
     }
     $this->pageTitle = $seo->page_title;
     $this->setMetaDescription($seo->meta_description);
     $this->setMetaKeywords($seo->meta_keyword);
 }
Exemple #4
0
 public function checkUrl($url)
 {
     $seo = array();
     if (!empty($url)) {
         if (Seo::model()->countByAttributes(array('url' => $url)) <= 0) {
             $new = new Seo();
             $new->url = $url;
             $new->save();
             $seo['title'] = CHtml::encode($this->pageTitle) . ' - Happy Momments';
             $seo['keywords'] = 'праздник, фотограф, свадьба, видеооператор, HM Агент';
             $seo['description'] = 'Все для организации праздника';
             $seo['top_text'] = '';
             $seo['bottom_text'] = '';
             return $seo;
         } else {
             $meta = Seo::model()->findByAttributes(array('url' => $url));
             if (!is_null($meta->title)) {
                 $seo['title'] = CHtml::encode($meta->title) . ' - Happy Momments';
             } else {
                 $seo['title'] = CHtml::encode($this->pageTitle) . ' - Happy Momments';
             }
             if (!is_null($meta->keywords)) {
                 $seo['keywords'] = CHtml::encode($meta->keywords);
             } else {
                 $seo['keywords'] = 'праздник, фотограф, свадьба, видеооператор, HM Агент';
             }
             if (!is_null($meta->description)) {
                 $seo['description'] = CHtml::encode($meta->description);
             } else {
                 $seo['description'] = 'Все для организации праздника';
             }
             if (!is_null($meta->description)) {
                 $seo['top_text'] = CHtml::encode($meta->top_text);
             } else {
                 $seo['top_text'] = '';
             }
             if (!is_null($meta->description)) {
                 $seo['bottom_text'] = CHtml::encode($meta->bottom_text);
             } else {
                 $seo['bottom_text'] = '';
             }
             return $seo;
         }
     } else {
         $seo['title'] = CHtml::encode($this->pageTitle) . ' - Happy Momments';
         $seo['keywords'] = 'праздник, фотограф, свадьба, видеооператор, HM Агент';
         $seo['description'] = 'Все для организации праздника';
         $seo['top_text'] = '';
         $seo['bottom_text'] = '';
         return $seo;
     }
 }
 public function afterSave()
 {
     parent::afterSave();
     if (empty($this->url)) {
         $this->url = new Seo();
         $this->url->controller = "bookInfo";
         $this->url->action = "about";
         $this->url->item_id = $this->id;
         $url = UserFunctions::translit($this->author->name . "_" . $this->name);
         if (!is_null(Seo::model()->findByAttributes(array('url' => $url)))) {
             $url .= time();
         }
         $this->url->url = $url;
         if ($this->url->save()) {
             $this->seo_id = $this->url->id;
         }
         $this->save();
     }
 }
 /**
  * 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 $id the ID of the model to be loaded
  * @return Seo the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Seo::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Exemple #7
0
<?php

if (Seo::model()->findByPk(6)) {
    $seo = Seo::model()->findByPk(6);
    $this->pageTitle = Yii::app()->name . ' - ' . $seo->SeoTitle;
    Yii::app()->clientScript->registerMetaTag($seo->SeoKeywords, 'keywords');
    Yii::app()->clientScript->registerMetaTag($seo->SeoDescription, 'description');
}
?>
<div class="member_section">
<div class="login_home"> <a href="<?php 
echo Yii::app()->getHomeUrl(true);
?>
"><img src="<?php 
echo Yii::app()->theme->baseUrl;
?>
/images/login_home_img.png" alt="" /></a> </div>
  <div class="login_arrow"> <a href="javascript:history.back()"><img src="<?php 
echo Yii::app()->theme->baseUrl;
?>
/images/login_representation_img.png" alt="" /></a> </div>
  <div class="clear"></div>
<div class="photos_section">
<div class="row">
<?php 
$this->widget('ext.EAjaxUpload.EAjaxUpload', array('id' => 'uploadFileImages', 'config' => array('action' => Yii::app()->createUrl('profile/uploadProfileImages'), 'allowedExtensions' => array("jpg", "jpeg", "gif", "png"), 'sizeLimit' => 2 * 1024 * 1024, 'auto' => true, 'multiple' => true, 'onComplete' => 'js:function(id, fileName, responseJSON){
		  var ua = window.navigator.userAgent;
            var msie = ua.indexOf("MSIE ");
			if (msie > 0){
				 window.location.reload(true);
			}else{
Exemple #8
0
 public static function getParam($type = 'title')
 {
     /* @var $seo Seo */
     $seoArr = Seo::model()->findAll();
     $seo = $seoArr[0];
     $result = "";
     if ($seo != null) {
         switch ($type) {
             case 'title':
                 $jsonArr = $seo->site_title;
                 $arr = json_decode($jsonArr, true);
                 $result = $arr[$language = Yii::app()->language];
                 break;
             case 'keywords':
                 $jsonArr = $seo->site_keywords;
                 $arr = json_decode($jsonArr, true);
                 $result = $arr[$language = Yii::app()->language];
                 break;
             case 'description':
                 $jsonArr = $seo->site_description;
                 $arr = json_decode($jsonArr, true);
                 $result = $arr[$language = Yii::app()->language];
                 break;
         }
     }
     return $result;
 }
 public function actionUpdateseo()
 {
     /* @var $seo Seo*/
     //get id from request
     $id = Yii::app()->request->getParam('id', null);
     //get params from request
     $keywords = Yii::app()->request->getParam('keywords', null);
     $title = Yii::app()->request->getParam('title', null);
     $description = Yii::app()->request->getParam('description', null);
     $keywords_json = json_encode($keywords);
     $title_json = json_encode($title);
     $description_json = json_encode($description);
     //if id not given - redirect to index
     if ($id == null) {
         $this->redirect($this->createUrl('/admin/panel/index'));
     }
     //find record by id
     $seo = Seo::model()->findByPk($id);
     //if error by some mysterious reasons - send user to index
     if ($seo == null) {
         $this->redirect($this->createUrl('/admin/panel/index'));
     }
     //update
     $seo->site_description = $description_json;
     $seo->site_title = $title_json;
     $seo->site_keywords = $keywords_json;
     $seo->update();
     //redirect back
     $this->redirect($this->createUrl('/admin/panel/seo'));
 }