* * @param string $name The name of the cookie. * @param string $value The value of the cookie. * @param int|string $expire The days of the cookie expires. * @param string $path The path on the server in which the cookie will be available on. * @param string $domain The domain that the cookie is available. * @param bool|string $secure Indicates that the cookie should only be transmitted over a secure HTTPS connection. */ public function setCookie($name, $value, $expire = 0, $path = '/', $domain = '', $secure = false) { if (PHP_SAPI == "cli") { printf(__METHOD__ . " invokation not available in cli mode\n"); return; } if ($value === null) $value = ""; $_COOKIE[$name] = $value; if ($expire > 0) { $expire = time() + $expire * 24 * 3600; } setcookie($name, $value, $expire, $path, $domain, $secure); } /** * Sends AJAX response with information about exception. * * @parma mixed $Exception Specifies the exception object or message. * @param $exception * @param boolean $html Determines whether the response should be in HTML format. * @param boolean $focus Determines whether the focusing Java Script code must be added to a response. * This parameter will work only if Exception is a Phpr_ValidationException class. */ public function ajaxReportException($exception, $html = false, $focus = false) { if (PHP_SAPI == "cli") { printf(__METHOD__ . " invokation not available in cli mode\n"); return; } // Prepare the message $message = is_object($exception) ? $exception->getMessage() : $exception; if (Phpr::$request->isDebugRequest()) {
$cart = self::create(); $cart->cart_id = $cartId; } } // если включена опция автопересчёта корзины if (Phpr::$config->get('SHOP_AUTORECALCULATE_CART', false)) { $cart->recalculateCart(); } return $cart; } // если корзина не найдена, то создаём новую do { $cartId = self::generateCartId(); } while (!self::checkIdAccessibility($cartId)); $cart = self::create(); $cart->cart_id = $cartId; Phpr::$response->setCookie(self::cookieName, $cartId, 90); return $cart; } /** * @internal * @param $id * @return bool */ private static function checkIdAccessibility($id) { return Db_DbHelper::scalar("select count(*) from shop_carts where cart_id = ?", $id) == 0; } /** * {@inheritdoc} * * @param string $context */ public function define_columns($context = null)
$viewData = [ 'withQuantity' => !!$withQuantity, 'initialQuantity' => $initialQuantity, 'item' => $item, 'type' => $type, 'idPrefix' => self::getIdFor($item) ]; $controller->renderPartial($controller->getViewsDir() . "shop/_add_to_cart.htm", $viewData); } public static function getIdFor(Db_ActiveRecord $item) { $type = $item instanceof Catalog_Sku ? 'sku' : 'product'; return "atc-{$type}-{$item->id}"; } public static function renderMiniCart(Core_FrontendController $controller, ?Shop_Cart $cart = null) { if (!$cart) { $cart = Shop_Cart::getCart(); } $controller->renderPartial($controller->getViewsDir() . "shop/_mini_cart.htm", [ "cart" => $cart ]); } /* * Если магазин открыт, то возвращается пустая строка * Если магазин закрыт, то возвращается текст, который необходимо отобразить на сайте */ public static function isTheShopOpen() { if (Phpr::$config->get('SHOP_ENABLE_WORK_TIME', false)) { $nonWorkingDays = explode(',', Admin_ModuleSettings::get_module_parameter("shop", "non_working_days")); if (in_array(date('d-m-Y'), array_map(function ($date) { return str_replace(" ", "", $date); }, $nonWorkingDays))) { return Admin_ModuleSettings::get_module_parameter("shop", "non_working_days_text"); } $workTime = str_replace(" ", "", Admin_ModuleSettings::get_module_parameter("shop", "work_time_" . date('N')));
?> <?php if ($items !== null): ?> <ul> <?php foreach ($items as $idx => $item): ?> <?php /** @var Admin_MenuItem $item */ ?> <?php if ($item->is_hidden_in_menu) continue; ?> <?php if ( $item->is_current() ): ?> <li class="active"><a class="active" href="<?= $item->get_url() ?>"><?= $item->title ?></a></li> <?php else: ?> <li><a href="<?= $item->get_url() ?>"><?= $item->title ?></a></li> <?php endif; ?> <?php if ( $list_children ) : ?> <?php $sub_items = $item->list_children('sort_order'); ?> <?php if ( $sub_items->count ) $this->renderLayout('_dynamic_menu', array('items' => $sub_items)); ?> <?php endif; ?> <?php endforeach; ?> </ul> <div class="cart left"><?php Shop_Helper::renderMiniCart($this); ?></div> <?php endif; ?>
} $dirPath = $this->layoutsPath; if ($this->enableThemes && ($theme = Phpr::$config->get('FRONTEND_THEME'))) { $dirPath .= '/' . $theme; } if (strpos($layout, '/') === false) { $layoutPath = $dirPath . '/' . $layout . ".htm"; } else { $layoutPath = $layout; } if (!file_exists($layoutPath)) { throw new Phpr_SystemException("The layout file \"{$layoutPath}\" does not exist"); } /** @noinspection PhpIncludeInspection */ include $layoutPath; } public function renderWidget($name, array $params = []) { $widget = Phpr_WidgetFactory::getWidget($name); if ($widget) { $widget->setParams($params); $widget->render(); } else { echo "Widget {$name} doesn't exists or is not valid widget"; } } /** * Returns a name of event handler with added action name. * Use it when you have multiple event handers on different pages (actions). * You may use this method in Java Script "sendForm" method call as a handler name. * * @param string $eventName Specifies an event name * @return string
<?= $header_address->get_filtered_text() ?> </div> <div class="phone-mail left desk"> <div class="telephone"> <img src="/resources/images/icons/phone.svg" alt="Телефон"> <?= $header_tel->get_filtered_text() ?> </div> <div class="mail"> <img src="/resources/images/icons/mail.svg" alt="Телефон"> <?= $header_mail->get_filtered_text() ?> </div> </div> </div> </header> <nav class="top-bar menu-bar"> <section class="top-bar-section header-bar"> <?php $this->renderLayout('_dynamic_menu') ?> </section> </nav>
<!DOCTYPE html> <html> <head> <?php $this->renderLayout('_head') ?> </head> <body> <?php $this->renderLayout('_for_old_browsers') ?> <div id="layout" class="clearfix"> <?php $this->renderLayout('_header') ?> <div class="content-wrapper"> <div class="sidebar"> <span class="burger-head"><img width="28" height="23" src="/resources/images/icons/burger-icon.png" alt=""/></span> <div class="head-index-phone clearfix"> <span class="index-phone"><?=Admin_TextBlock::get('header_tel_mobile', 'Header-mobile: Телефон', 'text', '+7 (4242) 77-35-00')->get_filtered_text()?></span> <div class="index-basket"> <?php Shop_Helper::renderMiniCart($this); ?> </div> </div> <?php $this->renderLayout("_sidebar"); ?> </div> <div class="main"> <div class=""> <?= Phpr_View::block('view') ?> </div> </div> </div> <div class="collapse-block index-mobile"> <div class="contacts"> <?php $footer_address = Admin_TextBlock::get('footer_address', 'Footer: Адрес') ?> <?= $footer_address->get_filtered_text() ?> </div> </div> <div class="copyrights"> <?php $this->renderLayout('_copyrights') ?>
* @param boolean $suppressLayout Determines whether the view must be loaded without layout. * @param boolean $suppressDefault Indicates whether the default action view must be suppressed. */ public function loadView($view, $suppressLayout = false, $suppressDefault = false) { // If there is no layout provided, just render the view if ($this->layout == '' || $suppressLayout) { $this->renderPartial($view, null, false); return; } // Catch the layout blocks Phpr_View::beginBlock("OutsideBlock"); $this->renderPartial($view, null, false); Phpr_View::endBlock(); Phpr_View::appendBlock('view', Phpr_View::getBlock('OutsideBlock')); // Render the layout $this->renderLayout(); if ($suppressDefault) { $this->suppressView(); } } /** * Finds and executed a handler for an event triggered by client. * * @param string $actionName Specifies the action name. * @param array $parameters A list of the action parameters. * @return boolean Determines whether the event was handled. */ protected function dispatchEvents($actionName, $parameters) { $handlerName = null; if (isset($_SERVER['HTTP_UFO_AJAX_HANDLER'])) { $handlerName = $_SERVER['HTTP_UFO_AJAX_HANDLER']; }
} } catch (Exception $ex) { } if ($block && !$block->is_page()) $block = null; if ($block) { $this->beforeRenderStaticBlock($block); Admin_SeoPlugin::apply($block); $this->viewData['title'] = Phpr::$config->get('ENABLE_TYPOGRAPHIC') ? $block->title_no_typo : $block->title; $this->viewData['block'] = $block; $this->viewData['body_class'] = Phpr::$config->get('STATICPAGE_CLASS', 'inner'); $this->layout = Phpr::$config->get('STATICPAGE_LAYOUT', 'default'); if ($block->template && is_file($this->getViewsDir() . "/application/" . $block->template . ".htm")) { $this->staticView = $block->template; } $this->loadView($this->staticView, false, true); } else { if (PHP_SAPI != "cli") { Phpr::$response->setHttpStatus(Phpr_Response::httpNotFound); } $this->layout = Phpr::$config->get('404_LAYOUT', 'default'); $this->viewData['title'] = 'Страница не найдена'; $this->loadView('on404', false, true); } } protected function beforeRenderStaticBlock($block) { } /** * Get uploaded file * * @param int $id file id * @return void
} if (preg_match("/^" . $this->_eventPostPrefix . "\{(?P<handler>" . $actionName . "_on[a-zA-Z_0-9]*)\}$/i", $handlerName, $matches)) { $this->_execEventHandler($matches["handler"], $parameters, $actionName); return true; } return false; } /** * This method is used by the PHP Road internally. * Invokes the controller action or event handler and loads corresponding view. * * @param string $methodName Specifies a method name to execute. * @param array $parameters A list of the action parameters. */ public function executeAction($methodName, $parameters) { // Execute the action call_user_func_array([&$this, $methodName], $parameters); // Load the view if (!$this->_suppressView) { $this->loadView($methodName); } } /** * This method is used by the PHP Road internally by the RequestAction method. * Invokes the controller action or event handler and loads corresponding view. * * @param string $methodName Specifies a method name to execute. * @param array $parameters A list of the action parameters. * @return mixed */ public function executeEnternalAction($methodName, $parameters) { $result = $this->$methodName($parameters); if (!$this->_suppressView) {
Phpr::$response->redirect(Phpr::$config->get("404_REDIRECT_TARGET", "/not-found/") . "?u=" . Phpr::$request->getCurrentUri()); } /** * Execute action * * @param string $methodName * @param mixed $parameters * @return void * @todo remove obsolete Phpr::$cache */ public function executeAction($methodName, $parameters) { $this->action_parameters = $parameters; $post = Phpr::$request->getRequestType() == Phpr_Request::POST; // (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST'); $cacheable = isset($this->cacheableActions[$methodName]) || in_array($methodName, $this->cacheableActions); if (!Phpr::$cache || !$cacheable) { parent::executeAction($methodName, $parameters); return; } if ($cacheable) { $cacheKey = $this->get_page_cache_key($methodName, $parameters); if (!$post) { $data = Phpr::$cache->get($cacheKey); if ($data) { echo $data; return; } } ob_start(); parent::executeAction($methodName, $parameters); $data = ob_get_clean(); $dependency = null; if (isset($this->cacheableActions[$methodName]['dependency'])) {
} return PATH_APP . "/views/" . $themePath; } /** * This method is used by the PHP Road internally. * Dispatches events, invokes the controller action or event handler and loads a corresponding view. * * @param string $actionName Specifies the action name. * @param array $parameters A list of the action parameters. */ public function _run($actionName, $parameters) { if (Phpr::$request->isAjaxRequest()) { $this->suppressView(); } // If no event was handled, execute the action requested in URI if (!$this->dispatchEvents($actionName, $parameters)) { $this->executeAction($actionName, $parameters); } } /** * Loads a view with the name specified. Applies layout if its name is provided by the controller. * The view file must be situated in the views directory, and has the extension "htm". * * @param string $view Specifies the view name, without extension: "archive". * @param boolean $suppressLayout Determines whether the view must be loaded without layout. * @param boolean $suppressDefault Indicates whether the default action view must be suppressed. */ public function loadView($view, $suppressLayout = false, $suppressDefault = false) { // If there is no layout provided, just render the view if ($this->layout == '' || $suppressLayout) { $this->renderPartial($view, null, false); return; } // Catch the layout blocks
} elseif (Phpr::$sqlLogger != null) { $viewData = [ "logger" => Phpr::$sqlLogger ]; $obj->renderPartial(PATH_SYSTEM . '/modules/db/views/logger_partial.htm', $viewData, true, true); } } } /** * Opens the "Page not found" page. * By default this method opens a page provided by the PHP Road. * You may supply the application 404 page by creating the On404() action in the Application Controller. */ public function open404() { // Try to execute the application controller On404 action. $controller = Phpr::$classLoader->loadController(self::controllerApplication); if ($controller != null && $controller->_actionExists(self::actionOn404Action)) { $controller->_run(self::actionOn404Action, array()); //exit; } else { // Output the default 404 message. include PATH_SYSTEM . "/errorpages/404.htm"; Phpr::destroyApp(); } } /** * Opens the Error Page. * By default this method opens a page provided by the PHP Road. * You may supply the application error page by creating the OnException($Exception) action in the Application Controller. * * @deprecated * @param Exception $exception */ public function openErrorPage($exception) { // do nothing }
return; } if (!($controller && strlen($controller))) { $this->open404(); return; } $obj = Phpr::$classLoader->loadController($controller, $folder); if (!$obj) { $this->open404(); return; } if ($action == $controller) $action = 'index'; if ($obj) { if ($obj->canCheckAnAction() && !$obj->_actionExists($action)) { $this->open404(); return; } ob_start(); $obj->_run($action, $parameters); if (Phpr::$request->isAjaxRequest()) { $content = ""; while (ob_get_level()) $content .= ob_get_clean(); $this->sendJson(array( 'response' => $content )); } elseif (Phpr::$sqlLogger != null) { $viewData = [ "logger" => Phpr::$sqlLogger ]; $obj->renderPartial(PATH_SYSTEM . '/modules/db/views/logger_partial.htm', $viewData, true, true); } } }
if (Phpr::$config->get('DEV_MODE', 'test') == 'test') { Phpr::$config->set('DEV_MODE', false); } } $pluginList = Phpr::$config->get('PLUGINS', array()); foreach ($pluginList as $className => $config) { if (!class_exists($className)) { throw new Phpr_SystemException('Класс ' . $className . ' не найден.'); } $interfaces = class_implements($className); if (!in_array('Admin_ICmsPlugin', $interfaces)) { throw new Phpr_SystemException('Класс плагина ' . $className . ' должен реализовывать интерфейс Admin_ICmsPlugin.'); } new $className($config); } if (!isset($Phpr_InitOnly) || !$Phpr_InitOnly) { Phpr::$response->open(Phpr::$request->getCurrentUri(true)); }
$bootstrapPath = __FILE__; /** * Specify the application directory root * * Leave this variable blank if application root directory matches the site root directory. * Otherwise specify an absolute path to the application root, for example: * $applicationRoot = realpath( dirname($bootstrapPath)."/../app" ); * */ $applicationRoot = ""; /* * Include the PHP Road library * * You may need to specify a full path to the phproad.php script, * in case if the PHP Road root directory is not specified in the PHP includes path. * */ include(dirname(__FILE__) . "/phproad/system/phproad.php"); if (Phpr::$request->isDebugRequest()) { echo sprintf("<!-- %.06fsec, %.02fMb -->", microtime(true) - $start, memory_get_peak_usage() / 1024 / 1024); }