| @@ -39,7 +39,7 @@ | ||
| 39 | 39 |      { | 
| 40 | 40 |          if ($this->translateModel && defined('LANG')) { | 
| 41 | 41 | // Если есть массив переводов и установлена константа активного языка или другого языка | 
| 42 | -            if(self::$custom_lang){ | |
| 42 | +            if (self::$custom_lang) { | |
| 43 | 43 | self::setLang(self::$custom_lang); | 
| 44 | 44 |              } else { | 
| 45 | 45 | self::setLang(LANG); // Устанавливаем текущий язык | 
| @@ -39,7 +39,7 @@ | ||
| 39 | 39 |      { | 
| 40 | 40 |          if ($this->translateModel && defined('LANG')) { | 
| 41 | 41 | // Если есть массив переводов и установлена константа активного языка или другого языка | 
| 42 | -            if(self::$custom_lang){ | |
| 42 | +            if(self::$custom_lang) { | |
| 43 | 43 | self::setLang(self::$custom_lang); | 
| 44 | 44 |              } else { | 
| 45 | 45 | self::setLang(LANG); // Устанавливаем текущий язык | 
| @@ -82,6 +82,7 @@ discard block | ||
| 82 | 82 | * | 
| 83 | 83 | * ModelName::setTranslateCache(false); // Устанавливаем флаг. Отключение кеша необходимо при работе с моделями в админке | 
| 84 | 84 | * $entries = ModelName::find(); // Извлекаем данные | 
| 85 | + * @param boolean $value | |
| 85 | 86 | */ | 
| 86 | 87 | public static function setTranslateCache($value) | 
| 87 | 88 |      { | 
| @@ -90,6 +91,7 @@ discard block | ||
| 90 | 91 | |
| 91 | 92 | /** | 
| 92 | 93 | * Извлечение единичного перевода по имени переменной | 
| 94 | + * @param string $key | |
| 93 | 95 | */ | 
| 94 | 96 | public function getMLVariable($key) | 
| 95 | 97 |      { | 
| @@ -99,6 +101,9 @@ discard block | ||
| 99 | 101 | |
| 100 | 102 | } | 
| 101 | 103 | |
| 104 | + /** | |
| 105 | + * @param string $key | |
| 106 | + */ | |
| 102 | 107 | public function setMLVariable($key, $value, $lang = null) | 
| 103 | 108 |      { | 
| 104 | 109 |          if (!$this->getId()) { | 
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | <?php | 
| 2 | 2 | /** | 
| 3 | - * @copyright Copyright (c) 2011 - 2014 Aleksandr Torosh (http://wezoom.com.ua) | |
| 4 | - * @author Aleksandr Torosh <[email protected]> | |
| 5 | - */ | |
| 3 | + * @copyright Copyright (c) 2011 - 2014 Aleksandr Torosh (http://wezoom.com.ua) | |
| 4 | + * @author Aleksandr Torosh <[email protected]> | |
| 5 | + */ | |
| 6 | 6 | |
| 7 | 7 | namespace Cms\Controller; | 
| 8 | 8 | |
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | <?php | 
| 2 | 2 | /** | 
| 3 | - * @copyright Copyright (c) 2011 - 2014 Aleksandr Torosh (http://wezoom.net) | |
| 4 | - * @author Aleksandr Torosh <[email protected]> | |
| 5 | - */ | |
| 3 | + * @copyright Copyright (c) 2011 - 2014 Aleksandr Torosh (http://wezoom.net) | |
| 4 | + * @author Aleksandr Torosh <[email protected]> | |
| 5 | + */ | |
| 6 | 6 | |
| 7 | 7 | namespace Cms\Model; | 
| 8 | 8 | |
| @@ -53,7 +53,7 @@ | ||
| 53 | 53 |      { | 
| 54 | 54 | $save = []; | 
| 55 | 55 | $languages = Language::find(); | 
| 56 | -        foreach($languages as $lang) { | |
| 56 | +        foreach ($languages as $lang) { | |
| 57 | 57 | $save[$lang->getIso()] = [""=>""]; | 
| 58 | 58 | } | 
| 59 | 59 | |
| @@ -34,6 +34,9 @@ discard block | ||
| 34 | 34 | return $translates[$lang]; | 
| 35 | 35 | } | 
| 36 | 36 | |
| 37 | + /** | |
| 38 | + * @param string $phrase | |
| 39 | + */ | |
| 37 | 40 | public function findByPhraseAndLang($phrase, $lang = null) | 
| 38 | 41 |      { | 
| 39 | 42 |          if (!$lang) { | 
| @@ -97,7 +100,7 @@ discard block | ||
| 97 | 100 | } | 
| 98 | 101 | |
| 99 | 102 | /** | 
| 100 | - * @param mixed $phrase | |
| 103 | + * @param string $phrase | |
| 101 | 104 | */ | 
| 102 | 105 | public function setPhrase($phrase) | 
| 103 | 106 |      { | 
| @@ -7,7 +7,6 @@ | ||
| 7 | 7 | namespace Cms\Model; | 
| 8 | 8 | |
| 9 | 9 | use Application\Mvc\Helper\CmsCache; | 
| 10 | -use Phalcon\DI; | |
| 11 | 10 | use Phalcon\Mvc\Model; | 
| 12 | 11 | |
| 13 | 12 | class Translate extends Model | 
| @@ -15,23 +15,23 @@ discard block | ||
| 15 | 15 | |
| 16 | 16 | public function initialize() | 
| 17 | 17 |      { | 
| 18 | -        $this->cacheViewKey =  HOST_HASH . md5('Sitemap\Model\Sitemap'); | |
| 18 | +        $this->cacheViewKey = HOST_HASH . md5('Sitemap\Model\Sitemap'); | |
| 19 | 19 | |
| 20 | 20 | $this->models = [ | 
| 21 | 21 | [ | 
| 22 | 22 | 'class' => 'Publication', | 
| 23 | 23 | 'model' => 'Publication', | 
| 24 | 24 | 'where' => "", // preview_inner='0' , etc. | 
| 25 | -                'getLink' => function($model, $lang){ | |
| 25 | +                'getLink' => function ($model, $lang) { | |
| 26 | 26 | return $this->langUrlCustom([ | 
| 27 | 27 | 'for' => 'publication', | 
| 28 | 28 | 'type' => $model->getTypeSlug(), | 
| 29 | 29 | 'slug' => $model->getSlug()], $lang); | 
| 30 | 30 | } | 
| 31 | - ],[ | |
| 31 | + ], [ | |
| 32 | 32 | 'class' => 'Page', | 
| 33 | 33 | 'model' => 'Page', | 
| 34 | -                'getLink'      => function($model, $lang){ | |
| 34 | +                'getLink'      => function ($model, $lang) { | |
| 35 | 35 | return $this->langUrlCustom([ | 
| 36 | 36 | 'for' => 'page', | 
| 37 | 37 | 'slug' => $model->getSlug()], $lang); | 
| @@ -43,19 +43,19 @@ discard block | ||
| 43 | 43 | |
| 44 | 44 | public function indexAction() | 
| 45 | 45 |      { | 
| 46 | - $this->view->setRenderLevel( \Phalcon\Mvc\View::LEVEL_NO_RENDER ); | |
| 46 | + $this->view->setRenderLevel(\Phalcon\Mvc\View::LEVEL_NO_RENDER); | |
| 47 | 47 |          $cache = $this->getDi()->get('cache'); | 
| 48 | 48 | $sitemap_xml = $cache->get($this->cacheViewKey); | 
| 49 | 49 | |
| 50 | -        if(!$sitemap_xml){ | |
| 50 | +        if (!$sitemap_xml) { | |
| 51 | 51 | $langs = Language::find(['columns' => 'iso,primary']); | 
| 52 | 52 | |
| 53 | 53 | //link(s) for main-page(s) | 
| 54 | -            foreach ($langs as $lang){ | |
| 54 | +            foreach ($langs as $lang) { | |
| 55 | 55 | $suffix = !$lang['primary'] ? $lang['iso'] . '/' : ''; | 
| 56 | 56 | $this->links[] = [ | 
| 57 | - 'url' => 'http://' . $_SERVER['HTTP_HOST'] . '/' . $suffix, | |
| 58 | -                    'updated_at' => date('c',time()), | |
| 57 | + 'url' => 'http://' . $_SERVER['HTTP_HOST'] . '/' . $suffix, | |
| 58 | +                    'updated_at' => date('c', time()), | |
| 59 | 59 | ]; | 
| 60 | 60 | } | 
| 61 | 61 | |
| @@ -68,9 +68,9 @@ discard block | ||
| 68 | 68 |                  foreach ($langs as $lang) { | 
| 69 | 69 |                      foreach ($rows as $row) { | 
| 70 | 70 | $row::setCustomLang($lang->iso); | 
| 71 | -                        if($row->getSlug() !== 'index' && $row->getTitle()){ | |
| 71 | +                        if ($row->getSlug() !== 'index' && $row->getTitle()) { | |
| 72 | 72 | $this->links[] = [ | 
| 73 | - 'url' => 'http://' . $_SERVER['HTTP_HOST'] . $m['getLink']($row, $lang->iso), | |
| 73 | + 'url' => 'http://' . $_SERVER['HTTP_HOST'] . $m['getLink']($row, $lang->iso), | |
| 74 | 74 |                                  'updated_at' => date('c', strtotime($row->getUpdatedAt())), | 
| 75 | 75 | ]; | 
| 76 | 76 | } | 
| @@ -97,7 +97,7 @@ discard block | ||
| 97 | 97 | |
| 98 | 98 | private function getRawXml() | 
| 99 | 99 |      { | 
| 100 | - $this->view->setRenderLevel( \Phalcon\Mvc\View::LEVEL_ACTION_VIEW ); | |
| 100 | + $this->view->setRenderLevel(\Phalcon\Mvc\View::LEVEL_ACTION_VIEW); | |
| 101 | 101 | $this->view->links = $this->links; | 
| 102 | 102 | $this->view->start(); | 
| 103 | 103 |          $this->view->setLayoutsDir('../views/'); | 
| @@ -22,7 +22,7 @@ discard block | ||
| 22 | 22 | 'class' => 'Publication', | 
| 23 | 23 | 'model' => 'Publication', | 
| 24 | 24 | 'where' => "", // preview_inner='0' , etc. | 
| 25 | -                'getLink' => function($model, $lang){ | |
| 25 | +                'getLink' => function($model, $lang) { | |
| 26 | 26 | return $this->langUrlCustom([ | 
| 27 | 27 | 'for' => 'publication', | 
| 28 | 28 | 'type' => $model->getTypeSlug(), | 
| @@ -31,7 +31,7 @@ discard block | ||
| 31 | 31 | ],[ | 
| 32 | 32 | 'class' => 'Page', | 
| 33 | 33 | 'model' => 'Page', | 
| 34 | -                'getLink'      => function($model, $lang){ | |
| 34 | +                'getLink'      => function($model, $lang) { | |
| 35 | 35 | return $this->langUrlCustom([ | 
| 36 | 36 | 'for' => 'page', | 
| 37 | 37 | 'slug' => $model->getSlug()], $lang); | 
| @@ -47,11 +47,11 @@ discard block | ||
| 47 | 47 |          $cache = $this->getDi()->get('cache'); | 
| 48 | 48 | $sitemap_xml = $cache->get($this->cacheViewKey); | 
| 49 | 49 | |
| 50 | -        if(!$sitemap_xml){ | |
| 50 | +        if(!$sitemap_xml) { | |
| 51 | 51 | $langs = Language::find(['columns' => 'iso,primary']); | 
| 52 | 52 | |
| 53 | 53 | //link(s) for main-page(s) | 
| 54 | -            foreach ($langs as $lang){ | |
| 54 | +            foreach ($langs as $lang) { | |
| 55 | 55 | $suffix = !$lang['primary'] ? $lang['iso'] . '/' : ''; | 
| 56 | 56 | $this->links[] = [ | 
| 57 | 57 | 'url' => 'http://' . $_SERVER['HTTP_HOST'] . '/' . $suffix, | 
| @@ -68,7 +68,7 @@ discard block | ||
| 68 | 68 |                  foreach ($langs as $lang) { | 
| 69 | 69 |                      foreach ($rows as $row) { | 
| 70 | 70 | $row::setCustomLang($lang->iso); | 
| 71 | -                        if($row->getSlug() !== 'index' && $row->getTitle()){ | |
| 71 | +                        if($row->getSlug() !== 'index' && $row->getTitle()) { | |
| 72 | 72 | $this->links[] = [ | 
| 73 | 73 | 'url' => 'http://' . $_SERVER['HTTP_HOST'] . $m['getLink']($row, $lang->iso), | 
| 74 | 74 |                                  'updated_at' => date('c', strtotime($row->getUpdatedAt())), | 
| @@ -145,6 +145,9 @@ | ||
| 145 | 145 | } | 
| 146 | 146 | } | 
| 147 | 147 | |
| 148 | + /** | |
| 149 | + * @param integer $active | |
| 150 | + */ | |
| 148 | 151 | public function setActive($active) | 
| 149 | 152 |      { | 
| 150 | 153 | $this->active = $active; | 
| @@ -6,7 +6,6 @@ | ||
| 6 | 6 | |
| 7 | 7 | namespace Admin\Model; | 
| 8 | 8 | use Phalcon\Validation; | 
| 9 | -use Phalcon\Validation\Validator\Email as EmailValidator; | |
| 10 | 9 | use Phalcon\Validation\Validator\Uniqueness as UniquenessValidator; | 
| 11 | 10 | use stdClass; | 
| 12 | 11 | |
| @@ -45,20 +45,20 @@ | ||
| 45 | 45 | public function validation() | 
| 46 | 46 |      { | 
| 47 | 47 | |
| 48 | - $validator = new Validation(); | |
| 49 | -       $validator->add('login', new UniquenessValidator( | |
| 50 | - [ | |
| 51 | - "model" => $this, | |
| 52 | -               "message" => $this->getDi()->get('helper')->translate("The Login must be unique") | |
| 53 | - ] | |
| 54 | - )); | |
| 55 | -       $validator->add('email', new UniquenessValidator( | |
| 56 | - [ | |
| 57 | - "model" => $this, | |
| 58 | -               "message" => $this->getDi()->get('helper')->translate("The Email must be unique") | |
| 59 | - ] | |
| 60 | - )); | |
| 61 | - return $this->validate($validator); | |
| 48 | + $validator = new Validation(); | |
| 49 | +        $validator->add('login', new UniquenessValidator( | |
| 50 | + [ | |
| 51 | + "model" => $this, | |
| 52 | +                "message" => $this->getDi()->get('helper')->translate("The Login must be unique") | |
| 53 | + ] | |
| 54 | + )); | |
| 55 | +        $validator->add('email', new UniquenessValidator( | |
| 56 | + [ | |
| 57 | + "model" => $this, | |
| 58 | +                "message" => $this->getDi()->get('helper')->translate("The Email must be unique") | |
| 59 | + ] | |
| 60 | + )); | |
| 61 | + return $this->validate($validator); | |
| 62 | 62 | } | 
| 63 | 63 | |
| 64 | 64 | public function getId() | 
| @@ -21,7 +21,8 @@ discard block | ||
| 21 | 21 | * | 
| 22 | 22 | * @return string|false The hashed password, or false on error. | 
| 23 | 23 | */ | 
| 24 | -    function password_hash($password, $algo, array $options = array()) { | |
| 24 | + function password_hash($password, $algo, array $options = array()) | |
| 25 | +    { | |
| 25 | 26 |          if (!function_exists('crypt')) { | 
| 26 | 27 |              trigger_error("Crypt must be loaded for password_hash to function", E_USER_WARNING); | 
| 27 | 28 | return null; | 
| @@ -149,7 +150,8 @@ discard block | ||
| 149 | 150 | * | 
| 150 | 151 | * @return array The array of information about the hash. | 
| 151 | 152 | */ | 
| 152 | -    function password_get_info($hash) { | |
| 153 | + function password_get_info($hash) | |
| 154 | +    { | |
| 153 | 155 | $return = array( | 
| 154 | 156 | 'algo' => 0, | 
| 155 | 157 | 'algoName' => 'unknown', | 
| @@ -175,7 +177,8 @@ discard block | ||
| 175 | 177 | * | 
| 176 | 178 | * @return boolean True if the password needs to be rehashed. | 
| 177 | 179 | */ | 
| 178 | -    function password_needs_rehash($hash, $algo, array $options = array()) { | |
| 180 | + function password_needs_rehash($hash, $algo, array $options = array()) | |
| 181 | +    { | |
| 179 | 182 | $info = password_get_info($hash); | 
| 180 | 183 |          if ($info['algo'] != $algo) { | 
| 181 | 184 | return true; | 
| @@ -199,7 +202,8 @@ discard block | ||
| 199 | 202 | * | 
| 200 | 203 | * @return boolean If the password matches the hash | 
| 201 | 204 | */ | 
| 202 | -    function password_verify($password, $hash) { | |
| 205 | + function password_verify($password, $hash) | |
| 206 | +    { | |
| 203 | 207 |          if (!function_exists('crypt')) { | 
| 204 | 208 |              trigger_error("Crypt must be loaded for password_verify to function", E_USER_WARNING); | 
| 205 | 209 | return false; | 
| @@ -252,6 +252,9 @@ | ||
| 252 | 252 | } | 
| 253 | 253 | } | 
| 254 | 254 | |
| 255 | + /** | |
| 256 | + * @param integer $preview_inner | |
| 257 | + */ | |
| 255 | 258 | public function setPreviewInner($preview_inner) | 
| 256 | 259 |      { | 
| 257 | 260 | $this->preview_inner = $preview_inner; | 
| @@ -3,7 +3,6 @@ | ||
| 3 | 3 | namespace Publication\Model; | 
| 4 | 4 | |
| 5 | 5 | use Application\Mvc\Model\Model; | 
| 6 | -use Phalcon\Validation; | |
| 7 | 6 | use Phalcon\Validation\Validator\Uniqueness as UniquenessValidator; | 
| 8 | 7 | use Application\Localization\Transliterator; | 
| 9 | 8 | |
| @@ -62,13 +62,13 @@ | ||
| 62 | 62 | |
| 63 | 63 | public function validation() | 
| 64 | 64 |      { | 
| 65 | -      $validator->add('slug', new UniquenessValidator( | |
| 66 | - [ | |
| 67 | - "model" => $this, | |
| 68 | -              "message" => $this->getDi()->get('helper')->translate("Publishcation with slug is already exists") | |
| 69 | - ] | |
| 70 | - )); | |
| 71 | - return $this->validate($validator); | |
| 65 | +        $validator->add('slug', new UniquenessValidator( | |
| 66 | + [ | |
| 67 | + "model" => $this, | |
| 68 | +                "message" => $this->getDi()->get('helper')->translate("Publishcation with slug is already exists") | |
| 69 | + ] | |
| 70 | + )); | |
| 71 | + return $this->validate($validator); | |
| 72 | 72 | } | 
| 73 | 73 | |
| 74 | 74 | public function afterValidation() | 
| @@ -54,13 +54,13 @@ | ||
| 54 | 54 | |
| 55 | 55 | public function validation() | 
| 56 | 56 |      { | 
| 57 | -      $validator->add('slug', new UniquenessValidator( | |
| 58 | - [ | |
| 59 | - "model" => $this, | |
| 60 | -              "message" => $this->getDi()->get('helper')->translate("Page with slug is already exists") | |
| 61 | - ] | |
| 62 | - )); | |
| 63 | - return $this->validate($validator); | |
| 57 | +        $validator->add('slug', new UniquenessValidator( | |
| 58 | + [ | |
| 59 | + "model" => $this, | |
| 60 | +                "message" => $this->getDi()->get('helper')->translate("Page with slug is already exists") | |
| 61 | + ] | |
| 62 | + )); | |
| 63 | + return $this->validate($validator); | |
| 64 | 64 | } | 
| 65 | 65 | |
| 66 | 66 | public static function findCachedBySlug($slug) | 
| @@ -3,7 +3,6 @@ | ||
| 3 | 3 | namespace Publication\Model; | 
| 4 | 4 | |
| 5 | 5 | use Application\Mvc\Model\Model; | 
| 6 | -use Phalcon\Validation; | |
| 7 | 6 | use Phalcon\Validation\Validator\Uniqueness as UniquenessValidator; | 
| 8 | 7 | use Application\Localization\Transliterator; | 
| 9 | 8 | |