/** * Loads template engine * * @return bool|Fenom */ public function getFenom() { if (!$this->fenom) { try { if (!class_exists('Fenom')) { require dirname(dirname(__FILE__)) . '/fenom/Fenom.php'; Fenom::registerAutoload(); } $cache = MODX_CORE_PATH . 'cache/'; if (!file_exists($cache)) { mkdir($cache); } $this->fenom = Fenom::factory($cache, $cache); if (!$this->modx->getOption('pdotools_fenom_php', null, false)) { $this->fenom->removeAccessor('php'); } if ($options = $this->modx->getOption('pdotools_fenom_options')) { if (is_numeric($options) || ($options = $this->modx->fromJSON($options))) { $this->fenom->setOptions($options); } } } catch (Exception $e) { $this->modx->log(xPDO::LOG_LEVEL_ERROR, $e->getMessage()); return false; } } return $this->fenom; }
/** * Loads template engine * * @return bool|Fenom */ public function getFenom() { if (!$this->fenom) { try { if (!class_exists('Fenom')) { require dirname(dirname(__FILE__)) . '/fenom/Fenom.php'; require dirname(dirname(__FILE__)) . '/fenom/Fenom/ProviderInterface.php'; require dirname(dirname(__FILE__)) . '/fenom/Providers/ModChunk.php'; require dirname(dirname(__FILE__)) . '/fenom/Providers/ModTemplate.php'; Fenom::registerAutoload(); } $cache = MODX_CORE_PATH . 'cache/'; if (!file_exists($cache)) { mkdir($cache); } $this->fenom = Fenom::factory(new modChunkProvider($this), $cache); $this->fenom->addProvider('template', new modTemplateProvider($this)); $default_options = array('force_compile' => true, 'disable_cache' => true, 'force_include' => true); if ($options = $this->modx->fromJSON($this->modx->getOption('pdotools_fenom_options'))) { $options = array_merge($options, $default_options); } else { $options = $default_options; } $this->fenom->setOptions($options); if (!$this->modx->getOption('pdotools_fenom_php', null, false)) { $this->fenom->removeAccessor('php'); } } catch (Exception $e) { $this->modx->log(xPDO::LOG_LEVEL_ERROR, $e->getMessage()); return false; } } return $this->fenom; }
/** * @param RepositoryFactory $repositoryFactory * @param UserCurrent $user * @param int $needUserRole Минимальная роль, которой доступна страница (из констант Maradik\User\UserRoles) * @param string $templateNotFound * @param string $templateAccessDeny */ protected function __construct(RepositoryFactory $repositoryFactory, UserCurrent $user, $needUserRole, $templateNotFound, $templateAccessDeny) { if (empty($templateNotFound) || empty($templateAccessDeny)) { throw new \InvalidArgumentException('Некорректные названия шаблонов $templateNotFound, $templateAccessDeny'); } $this->repositoryFactory = $repositoryFactory; $this->user = $user; $this->needUserRole = $needUserRole; $this->templateNotFound = $templateNotFound; $this->templateAccessDeny = $templateAccessDeny; $this->addSupportedMethod('GET', 'base_get'); $this->addSupportedMethod('POST', 'base_post'); global $templates_s, $system_s; //TODO Переделать на аргументы конструктора $this->templateEngine = \Fenom::factory($templates_s['templates_path'], $templates_s['compiled_path']); if ($system_s['dev_server']) { $this->templateEngine->setOptions(\Fenom::FORCE_COMPILE); } }
/** * Loads template engine * * @return bool|Fenom */ public function getFenom() { if (!$this->fenom) { try { if (!class_exists('Fenom')) { require dirname(dirname(__FILE__)) . '/fenom/Fenom.php'; require dirname(dirname(__FILE__)) . '/fenom/Fenom/ProviderInterface.php'; require dirname(dirname(__FILE__)) . '/fenom/Providers/ModChunk.php'; require dirname(dirname(__FILE__)) . '/fenom/Providers/ModTemplate.php'; Fenom::registerAutoload(); } $cache = MODX_CORE_PATH . 'cache/'; if (!file_exists($cache)) { mkdir($cache); } $this->fenom = Fenom::factory(new modChunkProvider($this), $cache); $this->fenom->addProvider('template', new modTemplateProvider($this)); $default_options = array('force_compile' => true, 'disable_cache' => true, 'force_include' => true); if (!$this->modx->getOption('pdotools_fenom_php', null, false)) { $this->fenom->removeAccessor('php'); $default_options['disable_native_funcs'] = true; } if ($options = $this->modx->fromJSON($this->modx->getOption('pdotools_fenom_options'))) { $options = array_merge($options, $default_options); } else { $options = $default_options; } $this->fenom->setOptions($options); // Add modifiers if (!empty($this->config['fenomModifiers'])) { $modifiers = is_string($this->config['fenomModifiers']) ? explode(',', $this->config['fenomModifiers']) : $this->config['fenomModifiers']; $modx = $this->modx; foreach ($modifiers as $snippet) { $snippet = trim(strtolower($snippet)); if (!empty($snippet)) { $this->fenom->addModifier($snippet, function ($input, $options = '') use($snippet, $modx) { $result = $modx->runSnippet($snippet, array('input' => $input, 'options' => $options)); return !empty($result) ? $result : $input; }); } } } } catch (Exception $e) { $this->modx->log(xPDO::LOG_LEVEL_ERROR, $e->getMessage()); return false; } } return $this->fenom; }
/** * Loads template engine * * @return bool|Fenom */ public function getFenom() { if (!$this->fenom) { try { if (!class_exists('Fenom')) { require dirname(dirname(__FILE__)) . '/fenom/Fenom.php'; Fenom::registerAutoload(); } $cache = MODX_CORE_PATH . 'cache/'; if (!file_exists($cache)) { mkdir($cache); } $this->fenom = Fenom::factory($cache, $cache); if (!$this->modx->getOption('pdotools_fenom_php', null, false)) { $this->fenom->removeAccessor('php'); } if ($options = $this->modx->getOption('pdotools_fenom_options')) { if (is_numeric($options) || ($options = $this->modx->fromJSON($options))) { $this->fenom->setOptions($options); } } // Add line function for lexicons $this->fenom->addFunction('lexicon', function (array $params) { global $modx; $pdo = $modx->getService('pdoTools'); return $pdo->fenomFunction('lexicon', $params); }); // Add line function for making urls $this->fenom->addFunction('url', function (array $params) { global $modx; $pdo = $modx->getService('pdoTools'); return $pdo->fenomFunction('url', $params); }); } catch (Exception $e) { $this->modx->log(xPDO::LOG_LEVEL_ERROR, $e->getMessage()); return false; } } return $this->fenom; }
<?php require_once 'core.php'; use Fenom\Provider; $fenom = new Fenom(new Provider('../ucp/themes')); $fenom->setCompileDir('../cache'); if (defined('DEBUG')) { $fenom->setOptions(Fenom::AUTO_RELOAD); } if (isset($_GET['lang'])) { $currentLanguage = $_GET['lang']; setcookie('lang', $currentLanguage); } else { if (isset($_COOKIE['lang'])) { $currentLanguage = $_COOKIE['lang']; } else { $currentLanguage = configgetvalue('system', 'main', NULL, 'ucpLocale'); } } loadLocale('ucp', $currentLanguage); $ipRequest = " WHERE iplist LIKE '%\"" . $_SERVER['REMOTE_ADDR'] . "\"%'"; function formatCash($sum) { $currency = configgetvalue('system', 'main', NULL, 'currency'); return sprintf(_ngettext("%s {$currency}", "%s {$currency}", $sum), $sum); } class User { private $data = array(); private $valid = false; private $table = false;