/** * Метод для обработки хуков шаблнов * * @param $aParams * * @return string */ public function FetchTemplate($aParams) { if (isset($aParams['template'])) { return E::ModuleViewer()->Fetch($aParams['template']); } return ''; }
public function InjectProfileLink() { $sTemplatePath = Plugin::GetTemplatePath(__CLASS__) . 'inject_profile_link.tpl'; if (E::ModuleViewer()->TemplateExists($sTemplatePath)) { return E::ModuleViewer()->Fetch($sTemplatePath); } }
protected function EventAjaxSet() { if (!F::isPost('url')) { return false; } if (!$this->CheckSeopackFields()) { return false; } $sUrl = E::ModuleSeopack()->ClearUrl(F::GetRequest('url')); if (!($oSeopack = E::ModuleSeopack()->GetSeopackByUrl($sUrl))) { $oSeopack = Engine::GetEntity('PluginSeopack_ModuleSeopack_EntitySeopack'); $oSeopack->setUrl($sUrl); } if (F::GetRequest('title_auto') && F::GetRequest('description_auto') && F::GetRequest('keywords_auto')) { $oSeopack->Delete(); E::ModuleMessage()->AddNotice(E::ModuleLang()->Get('plugin.seopack.seopack_edit_submit_save_ok')); return; } $oSeopack->setTitle(F::GetRequest('title_auto') ? null : strip_tags(F::GetRequest('title'))); $oSeopack->setDescription(F::GetRequest('description_auto') ? null : strip_tags(F::GetRequest('description'))); $oSeopack->setKeywords(F::GetRequest('keywords_auto') ? null : strip_tags(F::GetRequest('keywords'))); if ($oSeopack->Save()) { if ($oSeopack->getTitle()) { E::ModuleViewer()->AssignAjax('title', $oSeopack->getTitle()); } E::ModuleMessage()->AddNotice(E::ModuleLang()->Get('plugin.seopack.seopack_edit_submit_save_ok')); } return; }
/** * Запуск обработки */ public function Exec() { // Статистика кто, где и т.п. $aPeopleStats = E::ModuleUser()->GetStatUsers(); // Загружаем переменные в шаблон E::ModuleViewer()->Assign('aPeopleStats', $aPeopleStats); }
/** * Plugin for Smarty * Display widget group * * @param array $aParams * @param Smarty_Internal_Template $oSmartyTemplate * * @return string */ function smarty_function_wgroup_show($aParams, $oSmartyTemplate) { if (isset($aParams['name'])) { if (!isset($aParams['group'])) { $aParams['group'] = $aParams['name']; } elseif (!isset($aParams['widget'])) { $aParams['widget'] = $aParams['name']; } } if (!isset($aParams['group'])) { $sError = 'Parameter "group" does not define in {wgroup_show ...} function'; if ($oSmartyTemplate->template_resource) { $sError .= ' (template: ' . $oSmartyTemplate->template_resource . ')'; } trigger_error($sError, E_USER_WARNING); return null; } $sWidgetGroup = $aParams['group']; $aWidgets = E::ModuleViewer()->GetWidgets(); $sResult = ''; if (isset($aWidgets[$sWidgetGroup])) { if (!function_exists('smarty_function_widget')) { F::IncludeFile('function.widget.php'); } foreach ($aWidgets[$sWidgetGroup] as $oWidget) { $sResult .= smarty_function_widget(array('object' => $oWidget), $oSmartyTemplate); } } return $sResult; }
/** * Выполняется при завершении работы экшена * */ public function EventShutdown() { /** * Загружаем в шаблон необходимые переменные */ E::ModuleViewer()->Assign('sMenuHeadItemSelect', $this->sMenuHeadItemSelect); }
public function __construct($aParam = null) { parent::__construct($aParam); if ($sName = $this->GetName()) { // задается идентификатор виджета $this->_checkId(); } if (is_null($this->GetPriority())) { $this->SetPriority(0); } if ($this->GetId()) { $aCfgData = Config::Get('widget.' . $this->GetId() . '.config'); if ($aCfgData) { $aCfgData = F::Array_Merge($this->getAllProps(), $aCfgData); $this->setProps($aCfgData); } } if ($sName && is_null($this->getType())) { $aTypeData = E::ModuleViewer()->DefineWidgetType($sName, $this->GetDir(), $this->GetPluginId()); if (isset($aTypeData['type'])) { $this->setType($aTypeData['type']); if ($aTypeData['type'] == 'template' && !empty($aTypeData['name'])) { $this->setTemplate($aTypeData['name']); $this->setName($aTypeData['name']); } /* LS-compatible */ if (!$this->getParam('plugin') && $this->getPluginId()) { $this->setParam('plugin', $this->getPluginId()); } } } }
public function SetSecurityKey() { $sCode = parent::SetSecurityKey(); // LS-compatible E::ModuleViewer()->Assign('LIVESTREET_SECURITY_KEY', $sCode); return $sCode; }
public function EventShutdown() { parent::EventShutdown(); if ($this->oCurrentBlog) { $iCountSandboxBlogNew = E::ModuleTopic()->GetCountTopicsSandboxNew(array('blog_id' => $this->oCurrentBlog->getId())); E::ModuleViewer()->Assign('iCountSandboxBlogNew', $iCountSandboxBlogNew); } }
public function Init() { E::ModuleViewer()->AppendStyle(Plugin::GetTemplateDir(__CLASS__) . "assets/css/style.css"); // Добавление своего CSS E::ModuleViewer()->AppendScript(Plugin::GetTemplateDir(__CLASS__) . "assets/js/script.js"); // Добавление своего JS //E::ModuleViewer()->AddMenu('blog',Plugin::GetTemplateDir(__CLASS__).'menu.blog.tpl'); // например, задаем свой вид меню }
/** * Инициализация плагина */ public function Init() { $this->Viewer_Assign("sTemplatePathEstheme", Plugin::GetTemplatePath(__CLASS__)); E::ModuleViewer()->AppendStyle(Plugin::GetTemplateDir(__CLASS__) . "assets/css/style.min.css"); E::ModuleViewer()->AppendScript(Plugin::GetTemplateDir(__CLASS__) . "assets/js/develop/jquery.color.js"); E::ModuleViewer()->AppendScript(Plugin::GetTemplateDir(__CLASS__) . "assets/js/develop/colorPicker.js"); E::ModuleViewer()->AppendScript(Plugin::GetTemplateDir(__CLASS__) . "assets/js/develop/esTheme.js"); }
protected function EventEditField() { $xResult = parent::EventEditField(); if (empty($_REQUEST['submit_field'])) { $oField = E::ModuleViewer()->getTemplateVars('oField'); $_REQUEST['field_unique_name'] = $oField->getFieldUniqueName(); } return $xResult; }
/** * Запуск обработки */ public function Exec() { // * Получаем список блогов if ($aResult = E::ModuleBlog()->GetBlogsRating(1, Config::Get('widgets.blogs.params.limit'))) { $aVars = array('aBlogs' => $aResult['collection']); // * Формируем результат в виде шаблона и возвращаем $sTextResult = E::ModuleViewer()->FetchWidget('blogs_top.tpl', $aVars); E::ModuleViewer()->Assign('sBlogsTop', $sTextResult); } }
/** * Запуск обработки */ public function Exec() { // * Получаем комментарии if ($aComments = E::ModuleComment()->GetCommentsOnline('topic', Config::Get('widgets.stream.params.limit'))) { $aVars = array('aComments' => $aComments); // * Формируем результат в виде шаблона и возвращаем $sTextResult = $this->Fetch('stream_comment.tpl', $aVars); E::ModuleViewer()->Assign('sStreamComments', $sTextResult); } }
/** * При завершении работы модуля передаем списки сообщений в шаблоны Smarty * */ public function Shutdown() { /** * Добавляем в сессию те сообщения, которые были отмечены для сессионного использования */ E::ModuleSession()->Set('message_notice_session', $this->GetNoticeSession()); E::ModuleSession()->Set('message_error_session', $this->GetErrorSession()); E::ModuleViewer()->Assign('aMsgNotice', $this->GetNotice()); E::ModuleViewer()->Assign('aMsgError', $this->GetError()); }
/** * Plugin for Smarty * Returns URL for skin asset file * * @param array $aParams * @param Smarty_Internal_Template $oSmartyTemplate * * @return string */ function smarty_function_asset($aParams, $oSmartyTemplate) { if (empty($aParams['skin']) && empty($aParams['file'])) { trigger_error('Asset: missing "file" parameter', E_USER_WARNING); return ''; } if (isset($aParams['file'])) { if (stripos($aParams['file'], 'http://') === 0 || stripos($aParams['file'], 'https://') === 0 || stripos($aParams['file'], 'http://') === 0) { $sUrl = $aParams['file']; } else { $sSkin = !empty($aParams['skin']) ? $aParams['skin'] : E::ModuleViewer()->GetConfigSkin(); // File name has full local path if (F::File_LocalDir($aParams['file'])) { $sFile = $aParams['file']; } else { // Need URL to asset file if (isset($aParams['theme'])) { if (is_bool($aParams['theme'])) { $sTheme = E::ModuleViewer()->GetConfigTheme(); } else { $sTheme = $aParams['theme']; } } else { $sTheme = ''; } if ($sTheme) { $sTheme = 'themes/' . $sTheme . '/'; } if (isset($aParams['plugin'])) { $sFile = Plugin::GetTemplateFile($aParams['plugin'], $aParams['file']); } else { $sFile = Config::Get('path.skins.dir') . '/' . $sSkin . '/' . $sTheme . $aParams['file']; } } if (isset($aParams['prepare'])) { $sAssetName = empty($aParams['asset']) ? $sFile : $aParams['asset']; // Грязноватый хак, но иначе нам не получить ссылку $aFileData = array($sFile => array('name' => md5($sFile), 'prepare' => true)); /** @var ModuleViewerAsset $oLocalViewerAsset */ $oLocalViewerAsset = new ModuleViewerAsset(); $oLocalViewerAsset->AddFiles(F::File_GetExtension($sFile, true), $aFileData, $sAssetName); $oLocalViewerAsset->Prepare(); //$sUrl = $oLocalViewerAsset->AssetFileUrl(F::File_NormPath($sFile)); $aLinks = $oLocalViewerAsset->GetPreparedAssetLinks(); $sUrl = reset($aLinks); } else { $sUrl = E::ModuleViewerAsset()->File2Link($sFile, 'skin/' . $sSkin . '/'); } } } else { // Need URL to asset dir $sUrl = E::ModuleViewer()->GetAssetUrl() . 'skin/' . $aParams['skin'] . '/'; } return $sUrl; }
/** * Запуск обработки */ public function Exec() { /** * пользователь авторизован? */ if ($oUserCurrent = E::ModuleUser()->GetUserCurrent()) { // * Получаем и прогружаем необходимые переменные в шаблон $aTypesList = E::ModuleStream()->GetTypesList($oUserCurrent->getId()); E::ModuleViewer()->Assign('aStreamTypesList', $aTypesList ? $aTypesList : array()); } }
public function TplTopicShowEnd($aParams) { if ((!isset($aParams['bTopicList']) || !$aParams['bTopicList']) && isset($aParams['topic']) || isset($aParams['oTopic'])) { if (isset($aParams['topic'])) { E::ModuleViewer()->Assign('oTopic', $aParams['topic']); } E::ModuleViewer()->Assign('aWidgetParams', Config::Get('plugin.similartopics.widget_showtopic')); return E::ModuleViewer()->Fetch(Plugin::GetTemplateDir(__CLASS__) . 'tpls/widgets/widget.similartopics_bottom.tpl'); } return null; }
/** * Assign messages to template variables and save special messages to session * (they will be shown in the next page) * */ public function Shutdown() { // Save messages in session if ($aMessages = $this->GetNoticeSession()) { E::ModuleSession()->Set('message_notice_session', $aMessages); } if ($aMessages = $this->GetErrorSession()) { E::ModuleSession()->Set('message_error_session', $aMessages); } E::ModuleViewer()->Assign('aMsgNotice', $this->GetNotice()); E::ModuleViewer()->Assign('aMsgError', $this->GetError()); }
/** * Выполняется при завершении работы экшена */ public function EventShutdown() { parent::EventShutdown(); if (!$this->oUserProfile) { return; } /** * Загружаем в шаблон необходимые переменные */ $iCountDraftUser = E::ModuleTopic()->GetCountDraftsPersonalByUser($this->oUserProfile->getId()); E::ModuleViewer()->Assign('iCountDraftUser', $iCountDraftUser); }
/** * Запуск обработки */ public function Exec() { // * пользователь авторизован? if ($oUserCurrent = E::ModuleUser()->GetUserCurrent()) { // * Получаем и прогружаем необходимые переменные в шаблон $aUserSubscribes = E::ModuleStream()->GetUserSubscribes($oUserCurrent->getId()); E::ModuleViewer()->Assign('aStreamSubscribedUsers', $aUserSubscribes ? $aUserSubscribes : array()); // issue#449, список друзей пользователя не передавался в шаблон $aStreamFriends = E::ModuleUser()->GetUsersFriend($oUserCurrent->getId()); E::ModuleViewer()->Assign('aStreamFriends', $aStreamFriends['collection']); } }
/** * Plugin for Smarty * Returns URL for skin asset file * * @param array $aParams * @param Smarty_Internal_Template $oSmartyTemplate * * @return string */ function smarty_function_asset($aParams, $oSmartyTemplate) { if (empty($aParams['skin']) && empty($aParams['file'])) { trigger_error('Asset: missing "file" parametr', E_USER_WARNING); return ''; } if (isset($aParams['file'])) { if (stripos($aParams['file'], 'http://') === 0 || stripos($aParams['file'], 'https://') === 0 || stripos($aParams['file'], 'http://') === 0) { $sUrl = $aParams['file']; } else { if (F::File_LocalDir($aParams['file'])) { $sFile = $aParams['file']; } else { // Need URL to asset file if (empty($aParams['skin'])) { $sSkin = E::ModuleViewer()->GetConfigSkin(); } else { $sSkin = $aParams['skin']; } if (isset($aParams['theme'])) { if (is_bool($aParams['theme'])) { $sTheme = E::ModuleViewer()->GetConfigTheme(); } else { $sTheme = $aParams['theme']; } } else { $sTheme = ''; } if ($sTheme) { $sTheme = 'themes/' . $sTheme . '/'; } if (isset($aParams['plugin'])) { $sFile = Plugin::GetTemplateFile($aParams['plugin'], $aParams['file']); } else { $sFile = Config::Get('path.skins.dir') . '/' . $sSkin . '/' . $sTheme . $aParams['file']; } } if (isset($aParams['prepare'])) { /** @var ModuleViewerAsset $oLocalViewerAsset */ $oLocalViewerAsset = new ModuleViewerAsset(); $oLocalViewerAsset->AddFiles(F::File_GetExtension($sFile, true), array($sFile)); $oLocalViewerAsset->Prepare(); $sUrl = $oLocalViewerAsset->AssetFileUrl(F::File_NormPath($sFile)); } else { $sUrl = E::ModuleViewerAsset()->File2Link($sFile, 'skin/' . $sSkin . '/'); } } } else { // Need URL to asset dir $sUrl = E::ModuleViewer()->GetAssetUrl() . 'skin/' . $aParams['skin'] . '/'; } return $sUrl; }
/** * Запуск обработки */ public function Exec() { /** * пользователь авторизован? */ if ($oUserCurrent = E::ModuleUser()->GetUserCurrent()) { // * Получаем и прогружаем необходимые переменные в шаблон $aFriends = E::ModuleUser()->GetUsersFriend($oUserCurrent->getId()); if ($aFriends) { E::ModuleViewer()->Assign('aStreamFriends', $aFriends['collection']); } } }
/** * Запуск обработки */ public function Exec() { // * пользователь авторизован? if ($oUserCurrent = E::ModuleUser()->GetUserCurrent()) { // * Получаем и прогружаем необходимые переменные в шаблон $aTypesList = E::ModuleStream()->GetTypesList($oUserCurrent->getId()); $aUserSubscribes = E::ModuleStream()->GetUserSubscribes($oUserCurrent->getId()); $aFriends = E::ModuleUser()->GetUsersFriend($oUserCurrent->getId()); E::ModuleViewer()->Assign('aStreamTypesList', $aTypesList); E::ModuleViewer()->Assign('aStreamSubscribedUsers', $aUserSubscribes); E::ModuleViewer()->Assign('aStreamFriends', $aFriends['collection']); } }
/** * Обработка получения последних топиков * Используется в блоке "Прямой эфир" * */ protected function EventStreamTopicSandbox() { $aVars = array(); $aFilter = E::ModuleTopic()->GetNamedFilter('default', array('accessible' => true, 'sandbox' => true)); $aTopics = E::ModuleTopic()->GetTopicsByFilter($aFilter, 1, Config::Get('widgets.stream.params.limit')); if ($aTopics) { $aVars['aTopics'] = $aTopics['collection']; // LS-compatibility $aVars['oTopics'] = $aTopics['collection']; } $sTextResult = E::ModuleViewer()->FetchWidget('stream_topic.tpl', $aVars); E::ModuleViewer()->AssignAjax('sText', $sTextResult); }
/** * Запуск обработки */ public function Exec() { /** * Получаем страны */ $aCountries = E::ModuleGeo()->GetGroupCountriesByTargetType('user', 20); /** * Формируем облако тегов */ E::ModuleTools()->MakeCloud($aCountries); /** * Выводим в шаблон */ E::ModuleViewer()->Assign('aCountryList', $aCountries); }
/** * Запуск обработки */ public function Exec() { /** * Пользователь авторизован? */ if ($oUserCurrent = E::ModuleUser()->GetUserCurrent()) { /** * Получаем необходимые переменные и передаем в шаблон */ $aUserSubscribes = E::ModuleUserfeed()->GetUserSubscribes($oUserCurrent->getId()); $aFriends = E::ModuleUser()->GetUsersFriend($oUserCurrent->getId()); E::ModuleViewer()->Assign('aUserfeedSubscribedUsers', $aUserSubscribes['users']); E::ModuleViewer()->Assign('aUserfeedFriends', $aFriends['collection']); } }
public function EventEsTheme() { if (!E::User() || !C::Get('plugin.estheme.use_client')) { return R::Action('error'); } $aProcessData = $this->PluginEstheme_Estheme_GetProcessData(); if (getRequest('submit_estheme')) { $sCSSDownloadPath = F::File_Dir2Url(C::Get('plugin.estheme.path_for_download') . E::UserId() . '/theme.custom.css'); $aCompiledData = $this->_processConfig($aProcessData, TRUE); $this->PluginEstheme_Estheme_CompileTheme($aCompiledData, TRUE); } else { $sCSSDownloadPath = FALSE; $this->_processConfig($aProcessData, FALSE); } E::ModuleViewer()->Assign('sCSSDownloadPath', $sCSSDownloadPath); }
/** * Добавление записи на стену */ 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'); } }
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; }