コード例 #1
0
 protected function smartyOutputContent($content)
 {
     $this->context->cookie->write();
     $js_tag = 'js_def';
     $this->context->smarty->assign($js_tag, $js_tag);
     if (is_array($content)) {
         foreach ($content as $tpl) {
             $html = $this->context->smarty->fetch($tpl);
         }
     } else {
         $html = $this->context->smarty->fetch($content);
     }
     $html = trim($html);
     if ($this->controller_type == 'front' && !empty($html) && $this->getLayout()) {
         $live_edit_content = '';
         if (!$this->useMobileTheme() && $this->checkLiveEditAccess()) {
             $live_edit_content = $this->getLiveEditFooter();
         }
         $dom_available = extension_loaded('dom') ? true : false;
         $defer = (bool) Configuration::get('PS_JS_DEFER');
         if ($defer && $dom_available) {
             $html = Media::deferInlineScripts($html);
         }
         $html = trim(str_replace(array('</body>', '</html>'), '', $html)) . "\n";
         $this->context->smarty->assign(array($js_tag => Media::getJsDef(), 'js_files' => $defer ? array_unique($this->js_files) : array(), 'js_inline' => $defer && $dom_available ? Media::getInlineScript() : array()));
         $javascript = $this->context->smarty->fetch(_PS_ALL_THEMES_DIR_ . 'javascript.tpl');
         echo ($defer ? $html . $javascript : str_replace($js_tag, $javascript, $html)) . $live_edit_content . (!isset($this->ajax) || !$this->ajax ? '</body></html>' : '');
     } else {
         echo $html;
     }
 }
コード例 #2
0
ファイル: Controller.php プロジェクト: gks-stage/prestashop
 protected function smartyOutputContent($content)
 {
     $this->context->cookie->write();
     if (is_array($content)) {
         foreach ($content as $tpl) {
             $html = $this->context->smarty->fetch($tpl);
         }
     } else {
         $html = $this->context->smarty->fetch($content);
     }
     $html = trim($html);
     if ($this->controller_type == 'front' && !empty($html)) {
         $dom_available = extension_loaded('dom') ? true : false;
         if ($dom_available) {
             $html = Media::deferInlineScripts($html);
         }
         $html = trim(str_replace(array('</body>', '</html>'), '', $html)) . "\n";
         $this->context->smarty->assign(array('js_def' => Media::getJsDef(), 'js_files' => array_unique($this->js_files), 'js_inline' => $dom_available ? Media::getInlineScript() : array()));
         $javascript = $this->context->smarty->fetch(_PS_ALL_THEMES_DIR_ . 'javascript.tpl');
         echo $html . $javascript . "\t</body>\n</html>";
     } else {
         echo $html;
     }
 }
コード例 #3
0
ファイル: AdminController.php プロジェクト: ramzzes52/Uni3
 public function display()
 {
     $this->context->smarty->assign(array('display_header' => $this->display_header, 'display_footer' => $this->display_footer, 'js_def' => Media::getJsDef()));
     // Use page title from meta_title if it has been set else from the breadcrumbs array
     if (!$this->meta_title) {
         $this->meta_title = strip_tags(is_array($this->toolbar_title) ? implode(' ' . Configuration::get('PS_NAVIGATION_PIPE') . ' ', $this->toolbar_title) : $this->toolbar_title);
     }
     $this->context->smarty->assign('meta_title', $this->meta_title);
     $template_dirs = $this->context->smarty->getTemplateDir();
     // Check if header/footer have been overriden
     $dir = $this->context->smarty->getTemplateDir(0) . 'controllers' . DIRECTORY_SEPARATOR . trim($this->override_folder, '\\/') . DIRECTORY_SEPARATOR;
     $module_list_dir = $this->context->smarty->getTemplateDir(0) . 'helpers' . DIRECTORY_SEPARATOR . 'modules_list' . DIRECTORY_SEPARATOR;
     $header_tpl = file_exists($dir . 'header.tpl') ? $dir . 'header.tpl' : 'header.tpl';
     $page_header_toolbar = file_exists($dir . 'page_header_toolbar.tpl') ? $dir . 'page_header_toolbar.tpl' : 'page_header_toolbar.tpl';
     $footer_tpl = file_exists($dir . 'footer.tpl') ? $dir . 'footer.tpl' : 'footer.tpl';
     $modal_module_list = file_exists($module_list_dir . 'modal.tpl') ? $module_list_dir . 'modal.tpl' : 'modal.tpl';
     $tpl_action = $this->tpl_folder . $this->display . '.tpl';
     // Check if action template has been overriden
     foreach ($template_dirs as $template_dir) {
         if (file_exists($template_dir . DIRECTORY_SEPARATOR . $tpl_action) && $this->display != 'view' && $this->display != 'options') {
             if (method_exists($this, $this->display . Tools::toCamelCase($this->className))) {
                 $this->{$this->display . Tools::toCamelCase($this->className)}();
             }
             $this->context->smarty->assign('content', $this->context->smarty->fetch($tpl_action));
             break;
         }
     }
     if (!$this->ajax) {
         $template = $this->createTemplate($this->template);
         $page = $template->fetch();
     } else {
         $page = $this->content;
     }
     if ($conf = Tools::getValue('conf')) {
         $this->context->smarty->assign('conf', $this->json ? Tools::jsonEncode($this->_conf[(int) $conf]) : $this->_conf[(int) $conf]);
     }
     foreach (array('errors', 'warnings', 'informations', 'confirmations') as $type) {
         if (!is_array($this->{$type})) {
             $this->{$type} = (array) $this->{$type};
         }
         $this->context->smarty->assign($type, $this->json ? Tools::jsonEncode(array_unique($this->{$type})) : array_unique($this->{$type}));
     }
     if ($this->show_page_header_toolbar && !$this->lite_display) {
         $this->context->smarty->assign(array('page_header_toolbar' => $this->context->smarty->fetch($page_header_toolbar), 'modal_module_list' => $this->context->smarty->fetch($modal_module_list)));
     }
     $this->context->smarty->assign(array('page' => $this->json ? Tools::jsonEncode($page) : $page, 'header' => $this->context->smarty->fetch($header_tpl), 'footer' => $this->context->smarty->fetch($footer_tpl)));
     $this->smartyOutputContent($this->layout);
 }
コード例 #4
0
ファイル: Controller.php プロジェクト: M03G/PrestaShop
 /**
  * Renders controller templates and generates page content
  *
  * @param array|string $content Template file(s) to be rendered
  * @throws Exception
  * @throws SmartyException
  */
 protected function smartyOutputContent($content)
 {
     $this->context->cookie->write();
     $html = '';
     $js_tag = 'js_def';
     $this->context->smarty->assign($js_tag, $js_tag);
     if (is_array($content)) {
         foreach ($content as $tpl) {
             $html .= $this->context->smarty->fetch($tpl, null, $this->getLayout());
         }
     } else {
         $html = $this->context->smarty->fetch($content, null, $this->getLayout());
     }
     if ($this->controller_type === 'modulefront') {
         // Modules do not know about the layout system,
         // let's inject their output inside the front-end layout.
         $this->context->smarty->assign('content', $html);
         $html = $this->context->smarty->fetch('wrapper.tpl');
     }
     $html = trim($html);
     if (in_array($this->controller_type, array('front', 'modulefront')) && !empty($html) && $this->getLayout()) {
         $dom_available = extension_loaded('dom') ? true : false;
         $defer = (bool) Configuration::get('PS_JS_DEFER');
         if ($defer && $dom_available) {
             $html = Media::deferInlineScripts($html);
         }
         $html = trim(str_replace(array('</body>', '</html>'), '', $html)) . "\n";
         $this->context->smarty->assign(array($js_tag => Media::getJsDef(), 'js_files' => $defer ? array_unique($this->js_files) : array(), 'js_inline' => $defer && $dom_available ? Media::getInlineScript() : array()));
         $javascript = $this->context->smarty->fetch(_PS_ALL_THEMES_DIR_ . 'javascript.tpl');
         if ($defer) {
             echo $html . $javascript . (empty($this->ajax) ? '</body></html>' : '');
         } else {
             echo preg_replace('/(?<!\\$)' . $js_tag . '/', $javascript, $html) . (empty($this->ajax) ? '</body></html>' : '');
         }
     } else {
         echo $html;
     }
 }