public function execute($filterChain) { $context = $this->getContext(); $request = $context->getRequest(); if (jfPortableDevice::isPortableDevice()) { $layout = isset(self::$_layout) ? self::$_layout : $this->getParameter('layout'); $context->getActionStack()->getFirstEntry()->getActionInstance()->setLayout($layout); if (class_exists('sfWidgetFormSchema')) { // compatibility with symfony 1.0 sfWidgetFormSchema::setDefaultFormFormatterName($this->getParameter('defaultFormFormatterName', 'jfPD')); } jfPortableDevice::setPageAttribute('data-url', $request->getUri()); } $filterChain->execute(); if (jfPortableDevice::isPortableDevice()) { if (jfPortableDevice::getConfig('lazyLoadImages')) { $response = $context->getResponse(); $content = $response->getContent(); $content = preg_replace('/(<img.*)(src=)([\'|\\"].*>)/', '$1data-jfPD-src=$3', $content); $response->setContent($content); } if (jfPortableDevice::isNativeApp()) { sfConfig::set('sf_web_debug', false); } } }
public function executeIncludeAssetsForApp() { $request = sfContext::getInstance()->getRequest(); //symfony 1.0 compatibility $response = sfContext::getInstance()->getResponse(); $this->isNativeApp = jfPortableDevice::isNativeApp(); $this->removeAllStylesheetsFromResponse(); $includeStylesheets = jfPortableDevice::getConfig('includeStylesheetsForApp'); foreach ($includeStylesheets as $assetResource) { list($filename, $position) = $this->extractFilenameAndPositionForAssetResource($assetResource); $response->addStylesheet($filename, $position); } $this->removeAllJavascriptsFromResponse(); $includeJavascripts = jfPortableDevice::getConfig('includeJavascriptsForApp'); foreach ($includeJavascripts as $assetResource) { list($filename, $position) = $this->extractFilenameAndPositionForAssetResource($assetResource); $response->addJavascript($filename, $position); } if ($this->isNativeApp) { $this->buildSettings = jfPortableDevice::getConfig('buildSettings'); $this->prepareAssetsForNativeApp($request, $response, $this->buildSettings); } }
<?php if (jfPortableDevice::getConfig('displayLinkToClassicTheme') && !jfPortableDevice::isNativeApp()) { $url = $sf_data->getRaw('sf_request')->getUri(); $url = jfPortableDevice::cleanUrl($url, true); $url = htmlspecialchars($url); echo link_to(__('Switch to classic theme', null, 'jfPortableDevice'), $url, array('data-ajax' => 'false', 'class' => 'jfPD_classicTheme')); } ?> <div data-role="footer" class="jfPD_footer"<?php if (jfPortableDevice::getConfig('fixedFooter')) { ?> data-position="fixed" data-tap-toggle="false"<?php } if (jfPortableDevice::getConfig('jQueryUIThemeFooter')) { ?> data-theme="<?php echo jfPortableDevice::getConfig('jQueryUIThemeFooter'); ?> "<?php } ?> > <?php include_partial('jfPortableDevice/tabBar'); ?> </div>
public function executeInitialize() { $request = sfContext::getInstance()->getRequest(); //symfony 1.0 compatibility $this->config = json_encode($this->getJsConfig($request)); if (jfPortableDevice::isNativeApp()) { jfPortableDevice::setPageAttribute('data-dom-cache', 'true'); } }
$pageAttributesAsString .= ' ' . $key . '="' . $value . '"'; } ?> <div <?php echo $pageAttributesAsString; ?> class="<?php if (has_slot('jfPD_bodyCssClass')) { ?> <?php include_slot('jfPD_bodyCssClass'); } ?> "> <?php if (!jfPortableDevice::isNativeApp() || !$initialRequest) { ?> <?php include_slot('page_assets'); ?> <?php include_partial('jfPortableDevice/header'); ?> <div data-role="content" > <?php echo $sf_content; ?> </div> <?php include_partial('jfPortableDevice/footer'); ?>
<script> <?php if (jfPortableDevice::isNativeApp() && !$sf_request->isXmlHttpRequest()) { ?> jfPD.appType = 'native'; <?php } ?> jfPD.init(<?php echo $sf_data->getRaw('config'); ?> ); </script>
public function executeManifest() { $request = sfContext::getInstance()->getRequest(); //symfony 1.0 compatibility $context = $this->getContext(); if (method_exists($context, 'getConfiguration') && method_exists($context->getConfiguration(), 'loadHelpers')) { $context->getConfiguration()->loadHelpers('Url'); } else { if (method_exists('sfLoader', 'loadHelpers')) { sfLoader::loadHelpers('Url'); //compatibility with symfony 1.0: } } sfConfig::set('sf_web_debug', false); $this->setLayout(false); $this->getResponse()->setContentType('text/cache-manifest'); $this->files = array(); if (!jfPortableDevice::isNativeApp()) { //$this->files[] = url_for('@jfPortableDevice_redirect'); $this->files[] = jfPortableDevice::extendUrl(url_for(jfPortableDevice::getConfig('startUrl'))); $this->files = $this->getCacheManifestFilesForConfig(jfPortableDevice::getConfig('includeJavascriptsForApp'), 'javascript_path', $this->files); $this->files = $this->getCacheManifestFilesForConfig(jfPortableDevice::getConfig('includeStylesheetsForApp'), 'stylesheet_path', $this->files); $this->files = $this->getCacheManifestFilesForDirectory(sfConfig::get('sf_web_dir') . jfPortableDevice::getConfig('jfPDTheme'), $this->files); } }