/**
  * Запуск валидации
  *
  * @param mixed $sValue    Данные для валидации
  *
  * @return bool|string
  */
 public function validate($sValue)
 {
     if (is_array($sValue)) {
         return $this->getMessage(E::ModuleLang()->Get('validate_tags_empty', null, false), 'msg', array('min' => $this->min, 'max' => $this->max));
     }
     if ($this->allowEmpty && $this->isEmpty($sValue)) {
         return true;
     }
     $aTags = explode($this->sep, trim($sValue, "\r\n\t\v ."));
     $aTagsNew = array();
     $aTagsNewLow = array();
     foreach ($aTags as $sTag) {
         $sTag = trim($sTag, "\r\n\t\v .");
         $iLength = mb_strlen($sTag, 'UTF-8');
         if ($iLength >= $this->min and $iLength <= $this->max and !in_array(mb_strtolower($sTag, 'UTF-8'), $aTagsNewLow)) {
             $aTagsNew[] = $sTag;
             $aTagsNewLow[] = mb_strtolower($sTag, 'UTF-8');
         }
     }
     $iCount = count($aTagsNew);
     if ($iCount > $this->count) {
         return $this->getMessage(E::ModuleLang()->Get('validate_tags_count_more', null, false), 'msg', array('count' => $this->count));
     } elseif (!$iCount) {
         return $this->getMessage(E::ModuleLang()->Get('validate_tags_empty', null, false), 'msg', array('min' => $this->min, 'max' => $this->max));
     }
     /**
      * Если проверка от сущности, то возвращаем обновленное значение
      */
     if ($this->oEntityCurrent) {
         $this->setValueOfCurrentEntity($this->sFieldCurrent, join($this->sep, $aTagsNew));
     }
     return true;
 }
Esempio n. 2
0
 /**
  * Валидация пользователя
  *
  * @param string $sValue     Значение
  * @param array  $aParams    Параметры
  *
  * @return bool
  */
 public function ValidateTarget($sValue, $aParams)
 {
     if (($oUserTarget = E::ModuleUser()->GetUserById($sValue)) && $this->getUserId() != $oUserTarget->getId()) {
         return true;
     }
     return E::ModuleLang()->Get('user_note_target_error');
 }
Esempio n. 3
0
 /**
  * @param string $sSkinXML
  * @param array $aData
  */
 public function LoadFromXml($sSkinXML, $aData = null)
 {
     if (Is_null($aData)) {
         $aData = array();
     }
     $oXml = @simplexml_load_string($sSkinXML);
     if (!$oXml) {
         $sXml = '<?xml version="1.0" encoding="UTF-8"?>
             <skin>
                 <name><lang name="default">' . (isset($aData['id']) ? $aData['id'] : '') . '</lang></name>' . '</skin>';
         $oXml = @simplexml_load_string($sXml);
     }
     // Обрабатываем данные манифеста
     $sLang = E::ModuleLang()->GetLang();
     $this->_xlang($oXml, 'name', $sLang);
     $this->_xlang($oXml, 'author', $sLang);
     $this->_xlang($oXml, 'description', $sLang, true);
     //$oXml->homepage = E::ModuleText()->Parser((string)$oXml->homepage);
     $oXml->homepage = filter_var((string) $oXml->homepage, FILTER_SANITIZE_URL);
     if ($sId = (string) $oXml->id) {
         $aData['id'] = $sId;
     }
     $aData['property'] = $oXml;
     $this->setProps($aData);
 }
 protected function SubmitComment()
 {
     /**
      * Проверям авторизован ли пользователь
      */
     if (!E::ModuleUser()->IsAuthorization()) {
         E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('need_authorization'), E::ModuleLang()->Get('error'));
         return;
     }
     $xResult = E::Module('PluginMagicrules\\Rule')->CheckRuleAction('create_comment', $this->oUserCurrent);
     if (true === $xResult) {
         $xResult = E::Module('PluginMagicrules\\Rule')->CheckRuleCreateAction('comment', $this->oUserCurrent);
     }
     if (true === $xResult) {
         return parent::SubmitComment();
     } else {
         if (is_string($xResult)) {
             E::ModuleMessage()->AddErrorSingle($xResult, E::ModuleLang()->Get('attention'));
             return;
         } else {
             E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('plugin.magicrules.check_rule_action_error'), E::ModuleLang()->Get('attention'));
             return;
         }
     }
 }
 protected function _text($sText)
 {
     $sText = (string) $sText;
     if ($sText && substr($sText, 0, 2) == '{{' && substr($sText, -2) == '}}') {
         $sText = E::ModuleLang()->Get('plugin.magicrules.' . substr($sText, 2, strlen($sText) - 4));
     }
     return $sText;
 }
 /**
  * Запуск валидации
  *
  * @param mixed $sValue    Данные для валидации
  *
  * @return bool|string
  */
 public function validate($sValue)
 {
     if ($this->allowEmpty && $this->isEmpty($sValue)) {
         return true;
     }
     if (!$this->strict && $sValue != $this->trueValue && $sValue != $this->falseValue || $this->strict && $sValue !== $this->trueValue && $sValue !== $this->falseValue) {
         return $this->getMessage(E::ModuleLang()->Get('validate_boolean_invalid', null, false), 'msg', array('true' => $this->trueValue, 'false' => $this->falseValue));
     }
     return true;
 }
 public function getLangText($sTextTemplate, $sLang = NULL)
 {
     return preg_replace_callback('~(\\{\\{\\S*\\}\\})~', function ($sTextTemplatePart) {
         $sTextTemplatePart = array_shift($sTextTemplatePart);
         if (!is_null($sText = E::ModuleLang()->Get(substr($sTextTemplatePart, 2, strlen($sTextTemplatePart) - 4)))) {
             return $sText;
         }
         return $sTextTemplatePart;
     }, $sTextTemplate);
 }
 /**
  * Запуск валидации
  *
  * @param mixed $sValue    Данные для валидации
  *
  * @return bool|string
  */
 public function validate($sValue)
 {
     if ($this->allowEmpty && $this->isEmpty($sValue)) {
         return true;
     }
     if (E::ModuleCaptcha()->Verify(mb_strtolower($sValue)) !== 0) {
         return $this->getMessage(E::ModuleLang()->Get('validate_captcha_not_valid', null, false), 'msg');
     }
     return E::ModuleCaptcha()->Verify(mb_strtolower($sValue)) === 0;
 }
Esempio n. 9
0
 public function EventDownloadFile()
 {
     $this->SetTemplate(false);
     $sTopicId = $this->GetParam(0);
     $sFieldId = $this->GetParam(1);
     E::ModuleSecurity()->ValidateSendForm();
     if (!($oTopic = E::ModuleTopic()->GetTopicById($sTopicId))) {
         return parent::EventNotFound();
     }
     if (!($this->oType = E::ModuleTopic()->GetContentType($oTopic->getType()))) {
         return parent::EventNotFound();
     }
     if (!($oField = E::ModuleTopic()->GetContentFieldById($sFieldId))) {
         return parent::EventNotFound();
     }
     if ($oField->getContentId() != $this->oType->getContentId()) {
         return parent::EventNotFound();
     }
     //получаем объект файла
     $oFile = $oTopic->getFieldFile($oField->getFieldId());
     //получаем объект поля топика, содержащий данные о файле
     $oValue = $oTopic->getField($oField->getFieldId());
     if ($oFile && $oValue) {
         if (preg_match("/^(http:\\/\\/)/i", $oFile->getFileUrl())) {
             $sFullPath = $oFile->getFileUrl();
             R::Location($sFullPath);
         } else {
             $sFullPath = Config::Get('path.root.dir') . $oFile->getFileUrl();
         }
         $sFilename = $oFile->getFileName();
         /*
          * Обновляем данные
          */
         $aFileObj = array();
         $aFileObj['file_name'] = $oFile->getFileName();
         $aFileObj['file_url'] = $oFile->getFileUrl();
         $aFileObj['file_size'] = $oFile->getFileSize();
         $aFileObj['file_extension'] = $oFile->getFileExtension();
         $aFileObj['file_downloads'] = $oFile->getFileDownloads() + 1;
         $sText = serialize($aFileObj);
         $oValue->setValue($sText);
         $oValue->setValueSource($sText);
         //сохраняем
         E::ModuleTopic()->UpdateContentFieldValue($oValue);
         /*
          * Отдаем файл
          */
         header('Content-type: ' . $oFile->getFileExtension());
         header('Content-Disposition: attachment; filename="' . $sFilename . '"');
         F::File_PrintChunked($sFullPath);
     } else {
         E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('content_download_file_error'));
         return R::Action('error');
     }
 }
 /**
  * Запуск валидации
  *
  * @param mixed $sValue    Данные для валидации
  *
  * @return bool|string
  */
 public function validate($sValue)
 {
     if ($this->requiredValue !== null) {
         if (!$this->strict && $sValue != $this->requiredValue || $this->strict && $sValue !== $this->requiredValue) {
             return $this->getMessage(E::ModuleLang()->Get('validate_required_must_be', null, false), 'msg', array('value' => $this->requiredValue));
         }
     } else {
         if ($this->isEmpty($sValue, true)) {
             return $this->getMessage(E::ModuleLang()->Get('validate_required_cannot_blank', null, false), 'msg');
         }
     }
     return true;
 }
Esempio n. 11
0
 public function EventConfig()
 {
     $sFile = Plugin::GetPath(__CLASS__) . 'config/sphinx-src.conf';
     $sText = F::File_GetContents($sFile);
     $sPath = F::File_NormPath(Config::Get('plugin.sphinx.path') . '/');
     $sDescription = E::ModuleLang()->Get('plugin.sphinx.conf_description', array('path' => $sPath, 'prefix' => Config::Get('plugin.sphinx.prefix')));
     $sDescription = preg_replace('/\\s\\s+/', ' ', str_replace("\n", "\n## ", $sDescription));
     $sTitle = E::ModuleLang()->Get('plugin.sphinx.conf_title');
     $aData = array('{{title}}' => $sTitle, '{{description}}' => $sDescription, '{{db_type}}' => Config::Get('db.params.type') == 'postgresql' ? 'pgsql' : 'mysql', '{{db_host}}' => Config::Get('db.params.host'), '{{db_user}}' => Config::Get('db.params.user'), '{{db_pass}}' => Config::Get('db.params.pass'), '{{db_name}}' => Config::Get('db.params.dbname'), '{{db_port}}' => Config::Get('db.params.port'), '{{db_prefix}}' => Config::Get('db.table.prefix'), '{{db_socket}}' => Config::Get('plugin.sphinx.db_socket'), '{{spinx_prefix}}' => Config::Get('plugin.sphinx.prefix'), '{{spinx_path}}' => $sPath);
     $sText = str_replace(array_keys($aData), array_values($aData), $sText);
     echo '<pre>';
     echo $sText;
     echo '</pre>';
     exit;
 }
Esempio n. 12
0
 /**
  * Валидация родительского сообщения
  *
  * @param string $sValue     Проверяемое значение
  * @param array  $aParams    Параметры
  *
  * @return bool|string
  */
 public function ValidatePid($sValue, $aParams)
 {
     if (!$sValue) {
         $this->setPid(null);
         return true;
     } elseif ($oParentWall = $this->GetPidWall()) {
         /**
          * Если отвечаем на сообщение нужной стены и оно корневое, то все ОК
          */
         if ($oParentWall->getWallUserId() == $this->getWallUserId() and !$oParentWall->getPid()) {
             return true;
         }
     }
     return E::ModuleLang()->Get('wall_add_pid_error');
 }
 protected function EventAdd()
 {
     $xResult = E::Module('PluginMagicrules\\Rule')->CheckRuleAction('create_topic', $this->oUserCurrent);
     if ($xResult === true) {
         return parent::EventAdd();
     } else {
         if (is_string($xResult)) {
             E::ModuleMessage()->AddErrorSingle($xResult, E::ModuleLang()->Get('attention'));
             return Router::Action('error');
         } else {
             E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('plugin.magicrules.check_rule_action_error'), E::ModuleLang()->Get('attention'));
             return Router::Action('error');
         }
     }
 }
 /**
  * Добавление записи на стену
  */
 public function EventWallAdd()
 {
     // * Устанавливаем формат Ajax ответа
     E::ModuleViewer()->SetResponseAjax('json');
     // * Пользователь авторизован?
     if (!E::IsUser()) {
         return parent::EventNotFound();
     }
     $xResult = E::Module('PluginMagicrules\\Rule')->CheckRuleAction('create_wall', E::User());
     if ($xResult === true) {
         return parent::EventWallAdd();
     } else {
         E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('plugin.magicrules.check_rule_action_error'), E::ModuleLang()->Get('attention'));
         return Router::Action('error');
     }
 }
 /**
  * Запуск валидации
  *
  * @param mixed $sValue    Данные для валидации
  *
  * @return bool|string
  */
 public function validate($sValue)
 {
     if (is_array($sValue)) {
         return $this->getMessage(E::ModuleLang()->Get('validate_regexp_invalid_pattern', null, false), 'msg');
     }
     if ($this->allowEmpty && $this->isEmpty($sValue)) {
         return true;
     }
     if ($this->pattern === null) {
         return $this->getMessage(E::ModuleLang()->Get('validate_regexp_invalid_pattern', null, false), 'msg');
     }
     if (!$this->not && !preg_match($this->pattern, $sValue) || $this->not && preg_match($this->pattern, $sValue)) {
         return $this->getMessage(E::ModuleLang()->Get('validate_regexp_not_valid', null, false), 'msg');
     }
     return true;
 }
Esempio n. 16
0
 public function EventEsTheme()
 {
     $this->sMainMenuItem = 'tools';
     E::ModuleViewer()->Assign('sPageTitle', E::ModuleLang()->Get('plugin.estheme.admin_title'));
     E::ModuleViewer()->Assign('sMainMenuItem', 'tools');
     E::ModuleViewer()->AddHtmlTitle(E::ModuleLang()->Get('plugin.estheme.admin_title'));
     $this->SetTemplateAction('tools/estheme');
     $aProcessData = $this->PluginEstheme_Estheme_GetProcessData();
     if (getRequest('submit_estheme')) {
         $aCompiledData = $this->_processConfig($aProcessData, TRUE);
         $this->PluginEstheme_Estheme_CompileTheme($aCompiledData);
         return FALSE;
     }
     $this->_processConfig($aProcessData, FALSE);
     return FALSE;
 }
Esempio n. 17
0
/**
 * Модификатор declension: склонение существительных
 *
 * @param int    $count
 * @param string $forms
 * @param string $language
 *
 * @return string
 */
function smarty_modifier_declension($count, $forms, $language = '')
{
    if (!$language) {
        $language = E::ModuleLang()->GetLang();
    }
    $count = abs($count);
    // Выделяем отдельные словоформы
    $forms = explode(';', $forms);
    $fn = 'smarty_modifier_declension_' . $language;
    if (function_exists($fn)) {
        // Есть персональная функция для текущего языка
        return $fn($forms, $count);
    } else {
        // Действуем по образу и подобию английского языка
        return smarty_modifier_declension_english($forms, $count);
    }
}
Esempio n. 18
0
 /**
  * Обработка хука инициализации экшенов
  */
 public function InitAction()
 {
     // * Проверяем наличие директории install
     if (is_dir(rtrim(Config::Get('path.root.dir'), '/') . '/install') && (!isset($_SERVER['HTTP_APP_ENV']) || $_SERVER['HTTP_APP_ENV'] != 'test')) {
         E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('install_directory_exists'));
         R::Action('error');
     }
     // * Проверка на закрытый режим
     $oUserCurrent = E::ModuleUser()->GetUserCurrent();
     if (!$oUserCurrent && Config::Get('general.close.mode')) {
         $aEnabledActions = F::Str2Array(Config::Get('general.close.actions'));
         if (!in_array(R::GetAction(), $aEnabledActions)) {
             return R::Action('login');
         }
     }
     return null;
 }
 public function EventSandbox()
 {
     // * Меню
     $this->sMenuSubItemSelect = 'sandbox';
     // * Передан ли номер страницы
     $iPage = $this->GetParamEventMatch(0, 2) ? $this->GetParamEventMatch(0, 2) : 1;
     // * Получаем список топиков
     $aResult = E::ModuleTopic()->GetTopicsNewAll($iPage, Config::Get('module.topic.per_page'));
     $aTopics = $aResult['collection'];
     // * Вызов хуков
     E::ModuleHook()->Run('topics_list_show', array('aTopics' => $aTopics));
     // * Формируем постраничность
     $aPaging = E::ModuleViewer()->MakePaging($aResult['count'], $iPage, Config::Get('module.topic.per_page'), Config::Get('pagination.pages.count'), R::GetPath('index/sandbox'));
     E::ModuleViewer()->AddHtmlTitle(E::ModuleLang()->Get('plugin.sandbox.menu_text') . ($iPage > 1 ? ' (' . $iPage . ')' : ''));
     // * Загружаем переменные в шаблон
     E::ModuleViewer()->Assign('aTopics', $aTopics);
     E::ModuleViewer()->Assign('aPaging', $aPaging);
     // * Устанавливаем шаблон вывода
     $this->SetTemplateAction('index');
 }
Esempio n. 20
0
 /**
  * Выводим список комментариев
  *
  */
 protected function EventComments()
 {
     // * Передан ли номер страницы
     $iPage = $this->GetEventMatch(2) ? $this->GetEventMatch(2) : 1;
     // * Исключаем из выборки идентификаторы закрытых блогов (target_parent_id)
     $aCloseBlogs = $this->oUserCurrent ? E::ModuleBlog()->GetInaccessibleBlogsByUser($this->oUserCurrent) : E::ModuleBlog()->GetInaccessibleBlogsByUser();
     // * Получаем список комментов
     $aResult = E::ModuleComment()->GetCommentsAll('topic', $iPage, Config::Get('module.comment.per_page'), array(), $aCloseBlogs);
     $aComments = $aResult['collection'];
     // * Формируем постраничность
     $aPaging = E::ModuleViewer()->MakePaging($aResult['count'], $iPage, Config::Get('module.comment.per_page'), Config::Get('pagination.pages.count'), R::GetPath('comments'));
     // * Загружаем переменные в шаблон
     E::ModuleViewer()->Assign('aPaging', $aPaging);
     E::ModuleViewer()->Assign('aComments', $aComments);
     // * Устанавливаем title страницы
     E::ModuleViewer()->AddHtmlTitle(E::ModuleLang()->Get('comments_all'));
     E::ModuleViewer()->SetHtmlRssAlternate(R::GetPath('rss') . 'allcomments/', E::ModuleLang()->Get('comments_all'));
     // * Устанавливаем шаблон вывода
     $this->SetTemplateAction('index');
 }
Esempio n. 21
0
 /**
  * Вывод ошибки
  *
  */
 protected function EventError()
 {
     /**
      * Если евент равен одной из ошибок из $aHttpErrors, то шлем браузеру специфичный header
      * Например, для 404 в хидере будет послан браузеру заголовок HTTP/1.1 404 Not Found
      */
     if (array_key_exists($this->sCurrentEvent, $this->aHttpErrors)) {
         E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('system_error_' . $this->sCurrentEvent), $this->sCurrentEvent);
         $aHttpError = $this->aHttpErrors[$this->sCurrentEvent];
         if (isset($aHttpError['header'])) {
             $sProtocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1';
             header("{$sProtocol} {$aHttpError['header']}");
         }
     }
     /**
      * Устанавливаем title страницы
      */
     E::ModuleViewer()->AddHtmlTitle(E::ModuleLang()->Get('error'));
     $this->SetTemplateAction('index');
 }
 /**
  * @return string|void
  */
 protected function EventVoteUser()
 {
     // * Пользователь авторизован?
     if (!E::IsUser()) {
         E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('need_authorization'), E::ModuleLang()->Get('error'));
         return;
     }
     $xResult = E::Module('PluginMagicrules\\Rule')->CheckRuleAction('vote_user', E::User(), array('vote_value' => (int) $this->getPost('value')));
     if (true === $xResult) {
         return parent::EventVoteUser();
     } else {
         if (is_string($xResult)) {
             E::ModuleMessage()->AddErrorSingle($xResult, E::ModuleLang()->Get('attention'));
             return Router::Action('error');
         } else {
             E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('plugin.magicrules.check_rule_action_error'), E::ModuleLang()->Get('attention'));
             return Router::Action('error');
         }
     }
 }
 protected function checkBlogFields($oBlog = null)
 {
     $bOk = parent::checkBlogFields($oBlog);
     if (!F::isPost('submit_blog_add')) {
         //  Проверяем есть ли подзаголовок блога
         $iMin = C::Get('plugin.blogsubtitle.min_subtitle_len');
         $iMax = C::Get('plugin.blogsubtitle.max_subtitle_len');
         $sSubtitle = F::GetRequestStr('blog_subtitle');
         if (!$sSubtitle && $iMin) {
             E::ModuleMessage()->AddError(E::ModuleLang()->Get('plugin.blogsubtitle.blog_create_subtitle_error', array('min' => $iMin, 'max' => $iMax)), E::ModuleLang()->Get('error'));
             $bOk = false;
         } elseif ($iMax) {
             if (!F::CheckVal($sSubtitle, 'text', $iMin, $iMax)) {
                 E::ModuleMessage()->AddError(E::ModuleLang()->Get('plugin.blogsubtitle.blog_create_subtitle_error', array('min' => $iMin, 'max' => $iMax)), E::ModuleLang()->Get('error'));
                 $bOk = false;
             }
         }
     }
     return $bOk;
 }
Esempio n. 24
0
/**
 * Загружает список языковых текстовок в шаблон
 *
 * @param  $params
 * @param  $smarty
 *
 * @return array|null;
 */
function smarty_function_lang_load($params, &$smarty)
{
    if (!array_key_exists('name', $params)) {
        trigger_error("lang_load: missing 'name' parameter", E_USER_WARNING);
        return;
    }
    $aLangName = explode(',', $params['name']);
    $aLangMsg = array();
    foreach ($aLangName as $sName) {
        $aLangMsg[$sName] = E::ModuleLang()->Get(trim($sName), array(), false);
    }
    if (!isset($params['json']) || $params['json'] !== false) {
        $aLangMsg = F::jsonEncode($aLangMsg);
    }
    if (!empty($params['assign'])) {
        $smarty->assign($params['assign'], $aLangMsg);
    } else {
        return $aLangMsg;
    }
}
Esempio n. 25
0
 /**
  * Запуск валидации
  *
  * @param mixed $sValue    Данные для валидации
  *
  * @return bool|string
  */
 public function validate($sValue)
 {
     if (is_array($sValue)) {
         return $this->getMessage(E::ModuleLang()->Get('validate_url_not_valid', null, false), 'msg');
     }
     if ($this->allowEmpty && $this->isEmpty($sValue)) {
         return true;
     }
     if (($sValue = $this->validateValue($sValue)) !== false) {
         /**
          * Если проверка от сущности, то возвращаем обновленное значение
          */
         if ($this->oEntityCurrent) {
             $this->setValueOfCurrentEntity($this->sFieldCurrent, $sValue);
         }
     } else {
         return $this->getMessage(E::ModuleLang()->Get('validate_url_not_valid', null, false), 'msg');
     }
     return true;
 }
Esempio n. 26
0
 protected function _getPropLangText($sLangKey, $sPropKey, $sDefault, $sLang = null)
 {
     $sValue = null;
     if ($sPropKey) {
         if ($sLang) {
             $sPropKey .= '_' . $sLang;
         }
         // Пытаемся получить значение <key>_<lang> (типа name_ru)
         $sValue = $this->getProp($sPropKey, null);
     }
     if (is_null($sValue)) {
         $sValue = E::ModuleLang()->Get(str_replace('%%type_code%%', $this->getTypeCode(), $sLangKey));
         if (!$sValue) {
             $sValue = $sDefault;
         }
         if ($sValue && $sPropKey) {
             $this->setProp($sPropKey, $sValue);
         }
     }
     return $sValue;
 }
 /**
  * Список черновиков пользователя
  */
 protected function EventCreatedDrafts()
 {
     if (!$this->CheckUserProfile()) {
         return parent::EventNotFound();
     }
     if (!E::IsAdmin()) {
         return parent::EventNotFound();
     }
     $this->sMenuSubItemSelect = 'draft';
     /**
      * Передан ли номер страницы
      */
     $iPage = $this->GetParamEventMatch(2, 2) ? $this->GetParamEventMatch(2, 2) : 1;
     /**
      * Получаем список топиков
      */
     $aResult = E::ModuleTopic()->GetDraftsPersonalByUser($this->oUserProfile->getId(), $iPage, Config::Get('module.topic.per_page'));
     $aTopics = $aResult['collection'];
     /**
      * Вызов хуков
      */
     E::ModuleHook()->Run('topics_list_show', array('aTopics' => $aTopics));
     /**
      * Формируем постраничность
      */
     $aPaging = E::ModuleViewer()->MakePaging($aResult['count'], $iPage, Config::Get('module.topic.per_page'), Config::Get('pagination.pages.count'), $this->oUserProfile->getUserUrl() . 'created/draft');
     /**
      * Загружаем переменные в шаблон
      */
     E::ModuleViewer()->Assign('aPaging', $aPaging);
     E::ModuleViewer()->Assign('aTopics', $aTopics);
     E::ModuleViewer()->AddHtmlTitle(E::ModuleLang()->Get('user_menu_publication') . ' ' . $this->oUserProfile->getLogin());
     E::ModuleViewer()->AddHtmlTitle(E::ModuleLang()->Get('user_menu_publication_blog'));
     E::ModuleViewer()->SetHtmlRssAlternate(Router::GetPath('rss') . 'personal_blog/' . $this->oUserProfile->getLogin() . '/', $this->oUserProfile->getLogin());
     /**
      * Устанавливаем шаблон вывода
      */
     $this->SetTemplateAction('created_topics');
 }
Esempio n. 28
0
 /**
  * @return bool
  */
 protected function CheckSeopackFields()
 {
     E::ModuleSecurity()->ValidateSendForm();
     $bOk = true;
     if (F::isPost('title') && !F::CheckVal(F::GetRequest('title', null, 'post'), 'text', 0, 1000)) {
         E::ModuleMessage()->AddError(E::ModuleLang()->Get('plugin.seopack.title_error'), E::ModuleLang()->Get('error'));
         $bOk = false;
     }
     if (F::isPost('description') && !F::CheckVal(F::GetRequest('description', null, 'post'), 'text', 0, 1000)) {
         E::ModuleMessage()->AddError(E::ModuleLang()->Get('plugin.seopack.description_error'), E::ModuleLang()->Get('error'));
         $bOk = false;
     }
     if (F::isPost('keywords') && !F::CheckVal(F::GetRequest('keywords', null, 'post'), 'text', 0, 1000)) {
         E::ModuleMessage()->AddError(E::ModuleLang()->Get('plugin.seopack.keywords_error'), E::ModuleLang()->Get('error'));
         $bOk = false;
     }
     if (!F::CheckVal(F::GetRequest('url', null, 'post'), 'text', 0, 255)) {
         E::ModuleMessage()->AddError(E::ModuleLang()->Get('plugin.seopack.url_error'), E::ModuleLang()->Get('error'));
         $bOk = false;
     }
     return $bOk;
 }
Esempio n. 29
0
 /**
  * Отображение топиков
  *
  */
 protected function EventTags()
 {
     // * Gets tag from URL
     $sTag = F::UrlDecode(R::Url('event'), true);
     // * Check page number
     $iPage = $this->GetParamEventMatch(0, 2) ? $this->GetParamEventMatch(0, 2) : 1;
     // * Gets topics list
     $aResult = E::ModuleTopic()->GetTopicsByTag($sTag, $iPage, Config::Get('module.topic.per_page'));
     $aTopics = $aResult['collection'];
     // * Calls hooks
     E::ModuleHook()->Run('topics_list_show', array('aTopics' => $aTopics));
     // * Makes pages
     $aPaging = E::ModuleViewer()->MakePaging($aResult['count'], $iPage, Config::Get('module.topic.per_page'), Config::Get('pagination.pages.count'), R::GetPath('tag') . htmlspecialchars($sTag));
     // * Loads variables to template
     E::ModuleViewer()->Assign('aPaging', $aPaging);
     E::ModuleViewer()->Assign('aTopics', $aTopics);
     E::ModuleViewer()->Assign('sTag', $sTag);
     E::ModuleViewer()->AddHtmlTitle(E::ModuleLang()->Get('tag_title'));
     E::ModuleViewer()->AddHtmlTitle($sTag);
     E::ModuleViewer()->SetHtmlRssAlternate(R::GetPath('rss') . 'tag/' . $sTag . '/', $sTag);
     // * Sets template for display
     $this->SetTemplateAction('index');
 }
 /**
  * Запуск валидации
  *
  * @param mixed $sValue    Данные для валидации
  *
  * @return bool|string
  */
 public function validate($sValue)
 {
     if (is_array($sValue)) {
         return $this->getMessage(E::ModuleLang()->Get('validate_date_format_invalid', null, false), 'msg');
     }
     if ($this->allowEmpty && $this->isEmpty($sValue)) {
         return true;
     }
     F::IncludeLib('DateTime/DateTimeParser.php');
     $aFormats = is_string($this->format) ? array($this->format) : $this->format;
     $bValid = false;
     foreach ($aFormats as $sFormat) {
         $iTimestamp = DateTimeParser::parse($sValue, $sFormat, array('month' => 1, 'day' => 1, 'hour' => 0, 'minute' => 0, 'second' => 0));
         if ($iTimestamp !== false) {
             $bValid = true;
             break;
         }
     }
     if (!$bValid) {
         return $this->getMessage(E::ModuleLang()->Get('validate_date_format_invalid', null, false), 'msg');
     }
     return true;
 }