protected function setParams()
 {
     global $routes;
     $do = $this->request->get('do', '');
     unset($this->request->get['do']);
     unset($this->request->request['do']);
     if (!empty($do) && (preg_match('/^(?P<lang>[a-zA-Z]{2})\\/(?P<target>[a-zA-Z0-9]+)\\/(?P<action>[a-zA-Z0-9]+)\\/?(?P<params>.*?)?\\/?$/', $do, $matches) || preg_match('/^(?P<lang>[a-zA-Z]{2})\\/(?P<target>[a-zA-Z0-9]+)\\/?(?P<params>.*?)?\\/?$/', $do, $matches) || preg_match('/^(?P<target>[a-zA-Z0-9]{3,})\\/(?P<action>[a-zA-Z0-9]+)\\/?(?P<params>.*?)?\\/?$/', $do, $matches) || preg_match('/^(?P<target>[a-zA-Z0-9]{3,})\\/?(?P<params>.*?)?\\/?$/', $do, $matches) || preg_match('/^(?P<lang>[a-zA-Z]{2})\\/?$/', $do, $matches))) {
     }
     $lang = !empty($matches['lang']) ? $matches['lang'] : '';
     $this->target = !empty($matches['target']) ? $matches['target'] : DEFAULT_CONTROLLER_TARGET;
     $this->action = !empty($matches['action']) ? $matches['action'] : DEFAULT_CONTROLLER_ACTION;
     $this->params = !empty($matches['params']) ? explode('/', $matches['params']) : array();
     $router = new Router($lang, $routes);
     $router->dispatch($this);
     $this->route = $this->target . '/' . $this->action . '/' . implode('/', $this->params);
     $this->uri = ROOT_HTTP . $this->target . '/' . $this->action . '/';
     if (empty($lang)) {
         $lang = Lang::getDefaultLang();
     }
     $this->lang = new Lang($lang);
     $this->querystring = parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY);
     $this->querystring = (!empty($this->querystring) ? '?' : '') . $this->querystring;
     if (get_magic_quotes_gpc()) {
         $this->request = Utils::stripslashes($this->request);
         $this->post = Utils::stripslashes($this->post);
         $this->get = Utils::stripslashes($this->get);
     }
     $this->session = !SESSION_DISABLED ? Session::getInstance(SESSION_DEFAULT_NAME) : null;
 }
Example #2
0
 public function init()
 {
     $this->app = Yii::app();
     $this->showSearchForm = false;
     $this->defaultLang = Yii::app()->language;
     $this->activeLangs = array($this->defaultLang => $this->defaultLang);
     if (!isFree()) {
         $this->defaultLang = Lang::getDefaultLang();
         $this->activeLangs = Lang::getActiveLangs();
     }
     parent::init();
 }
Example #3
0
 public function init()
 {
     Yii::import('application.modules.notifier.models.NotifierModel');
     $this->lang['admin'] = Lang::getAdminMailLang();
     $this->lang['default'] = Lang::getDefaultLang();
     $this->lang['current'] = Yii::app()->language;
     Yii::app()->setLanguage($this->lang['admin']);
     $this->_adminRules = array('onNewBooking' => array('fields' => array('username', 'comment', 'useremail', 'phone', 'date_start', 'date_end', 'apartment_id', 'ownerEmail'), 'i18nFields' => array('time_inVal', 'time_outVal', 'type'), 'active' => param('module_notifier_adminNewBooking', 1)), 'onNewSimpleBookingForRent' => array('fields' => array('username', 'comment', 'useremail', 'phone', 'date_start', 'date_end'), 'i18nFields' => array('time_inVal', 'time_outVal', 'type'), 'active' => param('module_notifier_adminNewBooking', 1)), 'onNewSimpleBookingForBuy' => array('fields' => array('username', 'comment', 'useremail', 'phone'), 'i18nFields' => array('type'), 'active' => param('module_notifier_adminNewBooking', 1)), 'onNewUser' => array('fields' => array('email', 'username'), 'url' => array('/users/backend/main/admin'), 'active' => param('module_notifier_adminNewUser', 1)), 'onNewContactform' => array('fields' => array('name', 'email', 'phone', 'theme', 'body'), 'active' => param('module_notifier_adminNewContactform', 1)), 'onOfflinePayment' => array('fields' => array('amount', 'currency_charcode'), 'active' => param('module_notifier_adminNewPayment', 1)), 'onRequestProperty' => array('fields' => array('senderName', 'senderEmail', 'senderPhone', 'body', 'ownerName', 'ownerEmail', 'apartmentUrl'), 'active' => param('module_request_property_send_admin', 1)), 'onNewComment' => array('fields' => array('rating', 'user_email', 'body', 'user_name'), 'active' => param('module_notifier_userNewComment', 1)), 'onNewApartment' => array('fields' => array('id'), 'active' => param('module_notifier_adminNewApartment', 1), 'url' => array('/apartments/backend/main/admin')), 'onNewComplain' => array('fields' => array('apartment_id', 'email', 'name', 'body'), 'active' => param('module_notifier_adminNewComplain', 1)), 'onNewReview' => array('fields' => array('name', 'body'), 'active' => param('module_notifier_adminNewReview', 1)));
     Yii::app()->setLanguage($this->lang['current']);
     $this->setLang();
     $this->_userRules = array('onNewBooking' => array('fields' => array('username', 'comment', 'useremail', 'phone', 'date_start', 'date_end', 'apartment_id'), 'i18nFields' => array('time_inVal', 'time_outVal', 'type'), 'active' => param('module_notifier_ownerNewBooking', 1)), 'onNewUser' => array('fields' => array('email', 'password', 'activateLink'), 'url' => array('/usercpanel/main/index'), 'active' => param('module_notifier_userNewUser', 1)), 'onRecoveryPassword' => array('fields' => array('email', 'temprecoverpassword', 'recoverPasswordLink'), 'url' => array('/usercpanel/main/index'), 'active' => 1), 'onNewComment' => array('fields' => array('rating', 'user_email', 'body', 'user_name'), 'active' => param('module_notifier_adminNewComment', 1)), 'onRequestProperty' => array('fields' => array('senderName', 'senderEmail', 'senderPhone', 'body', 'ownerName', 'apartmentUrl', 'ownerEmail'), 'active' => param('module_request_property_send_user', 1)), 'onNewAgent' => array('fields' => array('username', 'email', 'phone'), 'active' => param('module_notifier_new_agent', 1)), 'onNewPrivateMessage' => array('fields' => array('username', 'messageEmailSend'), 'url' => array('/usercpanel/main/index'), 'active' => param('module_messages_private_message', 1)));
     $this->init = 1;
     $this->restoreLang();
 }
Example #4
0
 public function init()
 {
     Yii::import('application.modules.notifier.models.NotifierModel');
     $this->lang['admin'] = Lang::getAdminMailLang();
     $this->lang['default'] = Lang::getDefaultLang();
     $this->lang['current'] = Yii::app()->language;
     Yii::app()->setLanguage($this->lang['admin']);
     $this->_adminRules = array('onNewBooking' => array('fields' => array('username', 'comment', 'useremail', 'phone', 'date_start', 'date_end', 'apartment_id', 'ownerEmail'), 'i18nFields' => array('time_inVal', 'time_outVal', 'type'), 'active' => param('module_notifier_adminNewBooking', 1)), 'onNewUser' => array('fields' => array('email', 'username'), 'url' => array('/users/backend/main/admin'), 'active' => param('module_notifier_adminNewUser', 1)), 'onNewContactform' => array('fields' => array('name', 'email', 'phone', 'body'), 'subject' => tt('New message (contact form)', 'notifier'), 'body' => tt('New message from ::name (::email ::phone). Message text: ::body', 'notifier') . "\n", 'active' => param('module_notifier_adminNewContactform', 1)), 'onOfflinePayment' => array('fields' => array('amount', 'currency_charcode'), 'subject' => tt('New payment through a bank.', 'notifier'), 'body' => tt('New payment through a bank in the amount of ::amount ::currency_charcode', 'notifier'), 'active' => param('module_notifier_adminNewPayment', 1)), 'onRequestProperty' => array('fields' => array('senderName', 'senderEmail', 'senderPhone', 'body', 'ownerName', 'ownerEmail', 'apartmentUrl'), 'active' => param('module_request_property_send_admin', 1)), 'onNewComment' => array('fields' => array('rating', 'user_email', 'body', 'user_name'), 'active' => param('module_notifier_userNewComment', 1)), 'onNewApartment' => array('fields' => array('id'), 'active' => param('module_notifier_adminNewApartment', 1)), 'onNewComplain' => array('fields' => array('apartment_id', 'email', 'name', 'body'), 'subject' => Yii::t('module_notifier', 'New complain added.'), 'body' => Yii::t('module_notifier', 'New complain was added. From ::name (::email). Complain text: ::body') . "\n" . Yii::t('module_notifier', 'You can view it at') . ' ::host' . Yii::app()->controller->createUrl('/apartmentsComplain/backend/main/admin'), 'active' => param('module_notifier_adminNewComplain', 1)), 'onNewReview' => array('fields' => array('name', 'body'), 'active' => param('module_notifier_adminNewReview', 1)));
     Yii::app()->setLanguage($this->lang['current']);
     $this->setLang();
     $this->_userRules = array('onNewBooking' => array('fields' => array('username', 'comment', 'useremail', 'phone', 'date_start', 'date_end', 'apartment_id'), 'i18nFields' => array('time_inVal', 'time_outVal', 'type'), 'active' => param('module_notifier_ownerNewBooking', 1)), 'onNewUser' => array('fields' => array('email', 'password', 'activateLink'), 'url' => array('/usercpanel/main/index'), 'active' => param('module_notifier_userNewUser', 1)), 'onRecoveryPassword' => array('fields' => array('email', 'temprecoverpassword', 'recoverPasswordLink'), 'url' => array('/usercpanel/main/index'), 'active' => 1), 'onNewComment' => array('fields' => array('rating', 'user_email', 'body', 'user_name'), 'active' => param('module_notifier_adminNewComment', 1)), 'onRequestProperty' => array('fields' => array('senderName', 'senderEmail', 'senderPhone', 'body', 'ownerName', 'apartmentUrl', 'ownerEmail'), 'active' => param('module_request_property_send_user', 1)), 'onNewAgent' => array('fields' => array('username', 'email', 'phone'), 'active' => param('module_notifier_new_agent', 1)));
     $this->init = 1;
     $this->restoreLang();
 }
Example #5
0
 public function actionError()
 {
     if (demo()) {
         $defaultLang = Lang::getDefaultLang();
         if ($defaultLang == Yii::app()->request->getPathInfo() && $defaultLang) {
             $this->redirect(array('/site/index'));
         }
     }
     $this->layout = '//layouts/inner';
     if ($error = Yii::app()->errorHandler->error) {
         if (Yii::app()->request->isAjaxRequest) {
             echo $error['message'];
         } else {
             $this->render('error', $error);
         }
     }
 }
Example #6
0
function setLang($lang = null)
{
    if (isFree()) {
        return;
    }
    $app = Yii::app();
    $lang = $lang ? $lang : Lang::getDefaultLang();
    $app->setLanguage($lang);
    $activeLangs = Lang::getActiveLangs();
    if (isset($_GET['lang'])) {
        $tmplang = $_GET['lang'];
        //deb($tmplang);
        if (isset($activeLangs[$tmplang])) {
            $lang = $tmplang;
            $app->setLanguage($lang);
        }
        setLangCookie($lang);
        /*
         * другой код, например обновление кеша некоторых компонентов, которые изменяются при смене языка
         */
    } else {
        $user = $app->user;
        if ($user->hasState('_lang')) {
            $tmplang = $user->getState('_lang');
            if (isset($activeLangs[$tmplang])) {
                $lang = $tmplang;
                $app->setLanguage($lang);
            } else {
                setLangCookie($lang);
            }
        } else {
            if (isset($app->request->cookies['_lang'])) {
                $tmplang = $app->request->cookies['_lang']->value;
                if (isset($activeLangs[$tmplang])) {
                    $lang = $tmplang;
                    $app->setLanguage($lang);
                } else {
                    setLangCookie($lang);
                }
            }
        }
    }
    Lang::getActiveLangs(false, true);
}
Example #7
0
 public function actionViewFeed()
 {
     $oldLang = Yii::app()->language;
     Controller::disableProfiler();
     $defaultLangs = Lang::getDefaultLang();
     Yii::app()->language = $defaultLangs;
     // если есть русский или украинский языки, но они не дефолтные. установим на время их.
     if ($defaultLangs != 'ru' || $defaultLangs != 'uk') {
         $allLangs = Lang::getActiveLangs();
         if (array_key_exists('ru', $allLangs)) {
             Yii::app()->language = 'ru';
         } elseif (array_key_exists('uk', $allLangs)) {
             Yii::app()->language = 'uk';
         }
     }
     $items = $this->generateFeed();
     if (is_array($items) && count($items) > 0) {
         header('Content-type: text/xml');
         header('Pragma: public');
         header('Cache-control: private');
         header('Expires: -1');
         $xmlWriter = new XMLWriter();
         $xmlWriter->openMemory();
         $xmlWriter->setIndent(true);
         $xmlWriter->startDocument('1.0', 'UTF-8');
         $xmlWriter->startElement('realty-feed');
         $xmlWriter->writeAttribute('xmlns', 'http://webmaster.yandex.ru/schemas/feed/realty/2010-06');
         $xmlWriter->writeElement('generation-date', $this->generationDate);
         foreach ($items as $item) {
             if (isset($item['id'])) {
                 $this->prepareItem($item, $xmlWriter);
             }
         }
         $xmlWriter->endElement();
         // end realty-feed (xmlns)
         echo $xmlWriter->outputMemory();
     } else {
         echo 'no elements';
     }
     // установим обратно пользовательский язык
     Yii::app()->language = $oldLang;
 }
Example #8
0
 public function init()
 {
     parent::init();
     if (isFree()) {
         $this->defLang = Yii::app()->language;
         $this->currLang = Yii::app()->language;
         $this->mask = 'type;priceType;objType;countryName;regionName;cityName;isPricePoa;price;priceTo;numberRooms;floor;floorTotal;square;landSquare;sleeps;title;description;near;location;exchange;bathroom;safety;comfort;kitchen;employment;entertainment;services;terms;photos;lat;lng';
     } else {
         $this->allLangs = Lang::model()->findAll(array('condition' => 'active = 1'));
         $this->mask = 'type;priceType;objType;countryName;regionName;cityName;isPricePoa;price;priceTo;numberRooms;floor;floorTotal;square;landSquare;sleeps';
         $this->defLang = Lang::getDefaultLang();
         $this->currLang = Yii::app()->language;
         if ($this->allLangs) {
             foreach ($this->i18nMaskFields as $i18nMaskField) {
                 foreach ($this->allLangs as $lang) {
                     $this->mask .= ";{$i18nMaskField}_{$lang->name_iso}";
                 }
             }
         }
         $this->mask .= ';bathroom;safety;comfort;kitchen;employment;entertainment;services;terms;photos;lat;lng';
     }
 }
 protected function setParams()
 {
     global $routes;
     $do = $this->request->get('do', '');
     unset($this->request->get['do']);
     unset($this->request->request['do']);
     if (!empty($do) && (preg_match('/^(?P<lang>[a-zA-Z]{2})\\/(?P<target>[a-zA-Z0-9]+)\\/(?P<action>[a-zA-Z0-9]+)\\/?(?P<params>.*?)?\\/?$/', $do, $matches) || preg_match('/^(?P<lang>[a-zA-Z]{2})\\/(?P<target>[a-zA-Z0-9]+)\\/?(?P<params>.*?)?\\/?$/', $do, $matches) || preg_match('/^(?P<target>[a-zA-Z0-9]{3,})\\/(?P<action>[a-zA-Z0-9]+)\\/?(?P<params>.*?)?\\/?$/', $do, $matches) || preg_match('/^(?P<target>[a-zA-Z0-9]{3,})\\/?(?P<params>.*?)?\\/?$/', $do, $matches) || preg_match('/^(?P<lang>[a-zA-Z]{2})\\/?$/', $do, $matches))) {
     }
     $lang = !empty($matches['lang']) ? $matches['lang'] : '';
     $this->target = !empty($matches['target']) ? $matches['target'] : 'home';
     $this->action = !empty($matches['action']) ? $matches['action'] : 'index';
     $this->params = !empty($matches['params']) ? explode('/', $matches['params']) : array();
     /*
     echo 'LANG >> '.$lang.'<br>';
     echo 'TARGET >> '.print_r($this->target, true).'<br>';
     echo 'ACTION >> '.print_r($this->action, true).'<br>';
     echo 'PARAMS >> '.print_r($this->params, true).'<br>';
     */
     $router = new Router($lang, $routes);
     $router->dispatch($this);
     //$path = trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/');
     //$root_path = trim(ROOT_DIR.'/'.(!empty($lang) ? $lang : ''), '/');
     $this->route = $this->target . '/' . $this->action . '/' . implode('/', $this->params);
     $this->uri = ROOT_HTTP . $this->target . '/' . $this->action . '/';
     if (empty($lang)) {
         $lang = Lang::getDefaultLang();
     }
     $this->lang = new Lang($lang);
     $this->querystring = parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY);
     $this->querystring = (!empty($this->querystring) ? '?' : '') . $this->querystring;
     if (get_magic_quotes_gpc()) {
         $this->request = Utils::stripslashes($this->request);
         $this->post = Utils::stripslashes($this->post);
         $this->get = Utils::stripslashes($this->get);
     }
 }
Example #10
0
 public function createUrl($route, $params = array(), $ampersand = '&')
 {
     if ($route != 'min/serve' && $route != 'site/uploadimage') {
         $langs = Lang::getActiveLangs();
         $countLangs = count($langs);
         $defaultLang = Lang::getDefaultLang();
         if (isset($params['lang']) && $params['lang'] == $defaultLang && $this->isInstalled) {
             if (!param('useBootstrap')) {
                 unset($params['lang']);
             }
         } else {
             if (Yii::app()->language != $defaultLang && !isFree() && empty($params['lang']) && $countLangs > 1) {
                 $params['lang'] = Yii::app()->language;
             }
         }
         if (!$this->isInstalled && $countLangs == 1 && $route != 'install') {
             $params['lang'] = Yii::app()->language;
         }
         if (!$this->isInstalled && $countLangs > 1 && !isset($params['lang']) && $route != 'install') {
             $params['lang'] = Yii::app()->language;
         }
     }
     return parent::createUrl($route, $params, $ampersand);
 }
Example #11
0
 public function getI18nTimeOut($time_out)
 {
     $result = array();
     $default = Lang::getDefaultLang();
     $admin = Lang::getAdminMailLang();
     $current = Yii::app()->language;
     $sql = 'SELECT title_' . $default . ' as title FROM {{apartment_times_in}} WHERE id=' . $time_out;
     $result['default'] = Yii::app()->db->createCommand($sql)->queryScalar();
     if ($admin != $default) {
         $sql = 'SELECT title_' . $admin . ' as title FROM {{apartment_times_in}} WHERE id=' . $time_out;
         $result['admin'] = Yii::app()->db->createCommand($sql)->queryScalar();
     } else {
         $result['admin'] = $result['default'];
     }
     if ($current != $default) {
         $sql = 'SELECT title_' . $current . ' as title FROM {{apartment_times_in}} WHERE id=' . $time_out;
         $result['current'] = Yii::app()->db->createCommand($sql)->queryScalar();
     } else {
         $result['current'] = $result['default'];
     }
     return $result;
 }
Example #12
0
 public static function preparePosting(Apartment $model)
 {
     if ($model) {
         $message = '';
         $defaultLang = Lang::getDefaultLang();
         $tmp = 'title_' . $defaultLang;
         if (isset($model->{$tmp})) {
             $message .= $model->{$tmp};
         }
         // vkontakte
         if (SocialpostingModel::getSocialParamValue('useVkontakte')) {
             $vkApId = SocialpostingModel::getSocialParamValue('vkontakteApplicationId');
             $vkToken = SocialpostingModel::getSocialParamValue('vkontakteToken');
             $vkUsId = SocialpostingModel::getSocialParamValue('vkontakteUserId');
             //if ($vkApId && $vkToken && !is_numeric($model->autoVKPostId)) {
             if ($vkApId && $vkToken && utf8_strlen($model->autoVKPostId) < 1) {
                 if ($message) {
                     $imageUrl = null;
                     $res = Images::getMainThumb(300, 200, $model->images);
                     if ($res['link']) {
                         $imageUrl = $res['link'];
                     }
                     $post = self::addPostToVK($message, $vkApId, $vkToken, $vkUsId, $model->getUrl(), $imageUrl);
                     //logs(var_export($post, false));
                     //logs(var_export($post, true));
                     $postId = '0';
                     if ($post && isset($post->response)) {
                         $postId = isset($post->response->post_id) && $post->response->post_id ? $post->response->post_id : 0;
                     }
                     $model->autoVKPostId = $postId;
                     $model->update(array('autoVKPostId'));
                     /*$sql = 'UPDATE {{apartment}} SET autoVKPostId = "'.strip_tags(addslashes($postId)).'" WHERE id = '.$model->id;
                     		Yii::app()->db->createCommand($sql)->execute();*/
                 }
             }
         }
         // twitter
         if (SocialpostingModel::getSocialParamValue('useTwitter')) {
             $twApiKey = SocialpostingModel::getSocialParamValue('twitterApiKey');
             $twApiSecret = SocialpostingModel::getSocialParamValue('twitterApiSecret');
             $twTokenKey = SocialpostingModel::getSocialParamValue('twitterTokenKey');
             $twTokenSecret = SocialpostingModel::getSocialParamValue('twitterTokenSecret');
             //if ($twApiKey && $twApiSecret && $twTokenKey && $twTokenSecret && !is_numeric($model->autoTwitterPostId)) {
             if ($twApiKey && $twApiSecret && $twTokenKey && $twTokenSecret && utf8_strlen($model->autoTwitterPostId) < 1) {
                 if ($message) {
                     $post = self::addPostToTw($message, $twApiKey, $twApiSecret, $twTokenKey, $twTokenSecret, $model->getUrl());
                     //logs(var_export($post, false));
                     //logs(var_export($post, true));
                     $postId = '0';
                     if ($post && isset($post->id_str)) {
                         $postId = $post->id_str ? $post->id_str : 0;
                     }
                     $model->autoTwitterPostId = strip_tags(addslashes($postId));
                     $model->update(array('autoTwitterPostId'));
                     /*$sql = 'UPDATE {{apartment}} SET autoTwitterPostId = "'.strip_tags(addslashes($postId)).'" WHERE id = '.$model->id;
                     		Yii::app()->db->createCommand($sql)->execute();*/
                 }
             }
         }
     }
     return true;
 }
Example #13
0
 /**
  * @param $url
  * @param $modelName
  * @return SeoFriendlyUrl
  */
 public static function getForView($url, $modelName)
 {
     if (param('urlExtension')) {
         $url = rstrtrim($url, '.html');
     }
     $seo = SeoFriendlyUrl::model()->findByAttributes(array('model_name' => $modelName, 'url_' . Yii::app()->language => $url));
     if ($seo) {
         $activeLangs = Lang::getActiveLangs();
         foreach ($activeLangs as $lang) {
             $field = 'url_' . $lang;
             if (isset(self::$_prefixUrlArray[$modelName]) && isset($seo->{$field})) {
                 $prefix = $seo->direct_url ? '' : ($lang == Lang::getDefaultLang() ? '' : $lang . '/') . self::$_prefixUrlArray[$modelName];
                 if ($seo->{$field}) {
                     self::$seoLangUrls[$lang] = Yii::app()->baseUrl . '/' . $prefix . $seo->{$field} . (param('urlExtension') ? '.html' : '');
                 } else {
                     self::$seoLangUrls[$lang] = Yii::app()->baseUrl . '/' . $prefix . $seo->model_id;
                 }
                 //deb(self::$seoLangUrls);exit;
             }
         }
     }
     return $seo;
 }
Example #14
0
 /** For Notifier
  * @return array
  */
 public static function getI18nTypesArray()
 {
     $types = array();
     self::fillI18nArray($types, 'current', Yii::app()->language);
     self::fillI18nArray($types, 'default', Lang::getDefaultLang());
     self::fillI18nArray($types, 'admin', Lang::getAdminMailLang());
     return $types;
 }