コード例 #1
0
 public function getJsForFrontend()
 {
     if (Settings::getSetting("frontend", "protect_email_addresses", false)) {
         ResourceIncluder::defaultIncluder()->addResource('e-mail-defuscate.js');
     }
     return null;
 }
コード例 #2
0
ファイル: PagesAdminModule.php プロジェクト: rapila/cms-base
 public function __construct()
 {
     try {
         $this->oRootPage = PagePeer::getRootPage();
     } catch (Exception $e) {
         $this->oRootPage = self::initializeRootPage();
     }
     $this->oTreeWidget = new TreeWidgetModule();
     $this->oTreeWidget->setDelegate($this);
     $this->oTreeWidget->setSetting('init_dnd', true);
     $oInitialPage = null;
     if (Manager::hasNextPathItem()) {
         $oInitialPage = PageQuery::create()->findPk(Manager::usePath());
         if ($oInitialPage !== null) {
             Session::getSession()->setAttribute('persistent_page_id', $oInitialPage->getId());
         }
     } else {
         if (Session::getSession()->hasAttribute('persistent_page_id')) {
             $oInitialPage = PageQuery::create()->findPk(Session::getSession()->getAttribute('persistent_page_id'));
         }
     }
     if ($oInitialPage === null) {
         $oInitialPage = $this->oRootPage;
     }
     $this->addResourceParameter(ResourceIncluder::RESOURCE_TYPE_JS, 'tree_session', $this->oTreeWidget->getSessionKey());
     $this->addResourceParameter(ResourceIncluder::RESOURCE_TYPE_JS, 'initial_page_id', $oInitialPage->getId());
     $this->addResourceParameter(ResourceIncluder::RESOURCE_TYPE_JS, 'initial_page_tree_left', $oInitialPage->getTreeLeft());
     $oResourceIncluder = ResourceIncluder::defaultIncluder();
     $oResourceIncluder->addResource('admin/template.css', null, null, array(), ResourceIncluder::PRIORITY_NORMAL, null, true);
 }
コード例 #3
0
 public static function includeAvailableResources($mModule, $bEndDependenciesOnJS = false, $oResourceIncluder = null, $aParameters = null)
 {
     if ($aParameters === null) {
         $aParameters = array_fill_keys(self::$RESOURCE_TYPES, array());
     }
     $sModuleName = null;
     $sModuleType = null;
     if ($mModule instanceof Module) {
         $sModuleName = $mModule->getModuleName();
         $sModuleType = $mModule->getType();
     } else {
         $sModuleName = $mModule::getNameByClassName($mModule);
         $sModuleType = $mModule::getType();
     }
     if ($oResourceIncluder === null) {
         $oResourceIncluder = ResourceIncluder::defaultIncluder();
     }
     foreach (self::$RESOURCE_TYPES as $sResourceType) {
         $sResourceLink = self::getAvailableResource($sModuleName, $sModuleType, $sResourceType, @$aParameters[$sResourceType]);
         if ($sResourceLink !== null) {
             if ($sResourceType === ResourceIncluder::RESOURCE_TYPE_JS && $bEndDependenciesOnJS) {
                 $oResourceIncluder->addResourceEndingDependency($sResourceLink, $sResourceType);
             } else {
                 $oResourceIncluder->addResource($sResourceLink, $sResourceType);
             }
         }
     }
 }
コード例 #4
0
 public static function includeResources($oResourceIncluder = null)
 {
     if ($oResourceIncluder == null) {
         $oResourceIncluder = ResourceIncluder::defaultIncluder();
     }
     $oResourceIncluder->addResource('widget/html5-formdata/formdata.js');
     self::includeWidgetResources(false, $oResourceIncluder);
 }
コード例 #5
0
ファイル: TreeWidgetModule.php プロジェクト: rapila/cms-base
 public static function includeResources($oResourceIncluder = null)
 {
     if ($oResourceIncluder == null) {
         $oResourceIncluder = ResourceIncluder::defaultIncluder();
     }
     $oResourceIncluder->addResource('widget/jsTree/jquery.jstree.js');
     $oResourceIncluder->addResource('widget/jsTree/jquery.jstree.tree_widget_plugin.js');
     self::includeWidgetResources(false, $oResourceIncluder);
 }
コード例 #6
0
 public static function includeResources($oResourceIncluder = null)
 {
     if ($oResourceIncluder === null) {
         $oResourceIncluder = ResourceIncluder::defaultIncluder();
     }
     $oResourceIncluder->addResource('widget/popover/jquery.popover.js');
     $oResourceIncluder->addResource(array(DIRNAME_WEB, 'js', 'widget', 'popover', 'jquery.popover.css'));
     self::includeWidgetResources(false, $oResourceIncluder);
 }
コード例 #7
0
 public function renderFile()
 {
     $oCache = new Cache(implode('/', Manager::getUsedPath()), 'versioned');
     header("Content-Type: text/javascript;charset=utf-8");
     if ($oCache->entryExists()) {
         $oCache->sendCacheControlHeaders();
         $oCache->passContents();
         exit;
     }
     $oIncluder = new ResourceIncluder();
     // Don’t use SSL for downloads
     // Don’t include dependencies either
     $oIncluder->addJavaScriptLibrary($this->aLibraryName, $this->aVersion, $this->bUseCompression, false, false, ResourceIncluder::PRIORITY_NORMAL, false);
     $sContents = self::getResourceIncluderContents($oIncluder);
     $oCache->setContents($sContents);
     $oCache->sendCacheControlHeaders();
     print $sContents;
 }
コード例 #8
0
 public static function includeResources($oResourceIncluder = null)
 {
     if ($oResourceIncluder === null) {
         $oResourceIncluder = ResourceIncluder::defaultIncluder();
     }
     $oResourceIncluder->startDependencies();
     ImagePickerWidgetModule::includeResources($oResourceIncluder);
     self::includeWidgetResources(true, $oResourceIncluder);
 }
コード例 #9
0
 public static function includeResources($oResourceIncluder = null)
 {
     if ($oResourceIncluder === null) {
         $oResourceIncluder = ResourceIncluder::defaultIncluder();
     }
     $oResourceIncluder->startDependencies();
     self::includeWidgetResources(true, $oResourceIncluder);
     $oCkEditor = ResourceFinder::findResourceObject(array('web', 'js', 'widget', 'ckeditor'));
     $oResourceIncluder->addCustomJs('CKEDITOR_BASEPATH = "' . $oCkEditor->getFrontendPath() . '/";');
     $oResourceIncluder->addResource('widget/ckeditor/ckeditor.js');
 }
コード例 #10
0
 public static function getRecaptchaCode($sId = '')
 {
     $oTemplate = self::constructTemplateForModuleAndType(self::$MODULE_TYPE, 'form', 'recaptcha');
     $oTemplate->replaceIdentifier('key', Settings::getSetting('frontend', 're_captcha_public_key', '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'));
     $sAPI = 'https://www.google.com/recaptcha/api.js?';
     $oOutput = new XHTMLOutput();
     if ($oOutput->getContentType() === 'application/xhtml+xml') {
         // Use fallback version because users don’t want to wait for timeout when document.write isn’t working.
         $sAPI .= '&fallback=true';
     }
     ResourceIncluder::defaultIncluder()->addResource($sAPI, ResourceIncluder::RESOURCE_TYPE_JS);
     return $oTemplate;
 }
コード例 #11
0
ファイル: AdminManager.php プロジェクト: rapila/cms-base
 public function __construct()
 {
     parent::__construct();
     SanityCheck::basicCheck();
     $this->sModuleName = Manager::usePath();
     $this->oResourceIncluder = ResourceIncluder::defaultIncluder();
     if (isset($_REQUEST[self::CONTENT_LANGUAGE_SESSION_KEY])) {
         self::setContentLanguage($_REQUEST[self::CONTENT_LANGUAGE_SESSION_KEY]);
     }
     if (Session::getSession()->isAuthenticated() && Session::getSession()->getUser()->getIsBackendLoginEnabled()) {
         $oUser = Session::getSession()->getUser();
         Session::getSession()->setLanguage(Session::getSession()->getUser()->getLanguageId());
         if (isset($_REQUEST['preview']) || !$oUser->getIsAdminLoginEnabled()) {
             LinkUtil::redirect(LinkUtil::link(@$_REQUEST['preview'], 'PreviewManager'));
         }
     }
 }
コード例 #12
0
 public function display(Template $oTemplate, $bIsPreview = false)
 {
     if ($bIsPreview) {
         $this->bIsPreview = true;
     }
     $this->setFilters();
     $this->fillAuxilliaryContainers($oTemplate);
     if (Settings::getSetting("frontend", "protect_email_addresses", false)) {
         ResourceIncluder::defaultIncluder()->addResource('e-mail-defuscate.js');
     }
     if (!$oTemplate->hasIdentifier('container', $this->sContainer)) {
         return;
     }
     $sMethod = "overview_{$this->sOverviewMode}";
     if ($this->oNavigationItem instanceof VirtualNavigationItem) {
         $sMethod = substr($this->oNavigationItem->getType(), strlen('journal-'));
         if ($this->oNavigationItem->getData() instanceof JournalEntry) {
             $this->oEntry = $this->oNavigationItem->getData();
         }
     }
     // whenever there is no detail requested, store current navigation item for return_to_list_view link
     if ($this->oEntry === null) {
         Session::getSession()->setAttribute(self::SESSION_LAST_OVERVIEW_ITEM_LINK, $this->oNavigationItem->getLink());
     }
     $sMethod = StringUtil::camelize("display_{$sMethod}");
     return $this->{$sMethod}($oTemplate);
 }
コード例 #13
0
 public function writeResourceIncludes($oTemplateIdentifier)
 {
     $oResourceIncluder = null;
     if ($oTemplateIdentifier->getValue() !== null) {
         $oResourceIncluder = ResourceIncluder::namedIncluder($oTemplateIdentifier->getValue());
     } else {
         if ($oTemplateIdentifier->hasParameter('name')) {
             // Fall back to 'name' param for backwards compatiblity
             $oResourceIncluder = ResourceIncluder::namedIncluder($oTemplateIdentifier->getParameter('name'));
         } else {
             $oResourceIncluder = ResourceIncluder::defaultIncluder();
         }
     }
     $bConsolidate = null;
     if ($oTemplateIdentifier->hasParameter('consolidate')) {
         $bConsolidate = $oTemplateIdentifier->getParameter('consolidate');
         if ($bConsolidate === 'false') {
             $bConsolidate = false;
         } else {
             if ($bConsolidate !== 'internal') {
                 $bConsolidate = true;
             }
         }
     }
     return $oResourceIncluder->getIncludes(!$oTemplateIdentifier->hasParameter('noNewlines'), $bConsolidate);
 }
コード例 #14
0
ファイル: Navigation.php プロジェクト: rapila/cms-base
 /**
  * @param main template
  * description:
  * - @see config.yml section language_chooser
  * - use parameter replaced in method
  * @return Template The rendered language chooser
  */
 public static function getLanguageChooser($oMainTemplate)
 {
     $oTemplate = new Template(TemplateIdentifier::constructIdentifier('languages'), null, true);
     $oLanguageTemplate = new Template(Settings::getSetting("language_chooser", 'template', 'language'), array(DIRNAME_TEMPLATES, DIRNAME_NAVIGATION));
     $sLinkSeparator = Settings::getSetting("language_chooser", 'link_separator', ' | ');
     $oLanguageActiveTemplate = null;
     $bShowActiveLanguage = Settings::getSetting("language_chooser", 'show_active_language', false);
     $bIsPreview = Manager::getCurrentManager() instanceof PreviewManager;
     if ($bShowActiveLanguage) {
         if (Settings::getSetting("language_chooser", 'template_active', false) !== false) {
             $oLanguageActiveTemplate = new Template(Settings::getSetting("language_chooser", 'template_active', 'language_active'), array(DIRNAME_TEMPLATES, DIRNAME_NAVIGATION));
         } else {
             $oLanguageActiveTemplate = clone $oLanguageTemplate;
         }
     }
     // Find request variables
     $aParameters = array_diff_assoc($_REQUEST, $_COOKIE);
     unset($aParameters['path']);
     unset($aParameters['content_language']);
     // Check whether manager needs language to be included
     $bCurrentPathIncludesLanguage = call_user_func(array(Manager::getManagerClassNormalized(null), 'shouldIncludeLanguageInLink'));
     $aRequestPath = explode("/", Manager::getRequestedPath());
     $aLanguages = LanguageQuery::create()->filterByIsActive(true)->exclude($bShowActiveLanguage ? false : ($bIsPreview ? 'edit' : 'current'))->orderBySort()->find();
     foreach ($aLanguages as $i => $oLanguage) {
         $oLangTemplate = null;
         $oPageString = null;
         if ($oLanguage->getId() === Session::language()) {
             $oLangTemplate = $oLanguageActiveTemplate;
             $oLangTemplate->replaceIdentifier('class', 'active');
         } else {
             $oPageString = PageStringQuery::create()->filterByPage(FrontendManager::$CURRENT_PAGE)->filterByLanguageId($oLanguage->getId())->filterByIsInactive(false)->findOne();
             if ($oPageString === null) {
                 continue;
             }
             $oLangTemplate = clone $oLanguageTemplate;
         }
         // If language is included, replace it by language id and set include_language param to false
         if ($bCurrentPathIncludesLanguage) {
             $aRequestPath[0] = $oLanguage->getPathPrefix();
             $sLink = LinkUtil::link($aRequestPath, null, $aParameters, false);
         } else {
             $sLink = LinkUtil::link($aRequestPath, null, array_merge($aParameters, array('content_language' => $oLanguage->getId())));
         }
         $oLangTemplate->replaceIdentifier('link', $sLink);
         // Add alternate language links
         if ($oPageString) {
             ResourceIncluder::metaIncluder()->addCustomResource(array('template' => 'link', 'rel' => 'alternate', 'lang' => $oLanguage->getId(), 'location' => $sLink, 'title' => $oPageString->getPageTitle()));
         }
         $oLangTemplate->replaceIdentifier('id', $oLanguage->getId());
         $oLangTemplate->replaceIdentifier('name', $oLanguage->getLanguageName($oLanguage->getId()));
         $oLangTemplate->replaceIdentifier('name_in_current_lang', $oLanguage->getLanguageName());
         $oTemplate->replaceIdentifierMultiple('languages', $oLangTemplate, null, Template::NO_NEWLINE);
         if ($i + 1 < count($aLanguages)) {
             $oTemplate->replaceIdentifierMultiple('languages', $sLinkSeparator, null, Template::NO_HTML_ESCAPE | Template::NO_NEWLINE);
         }
     }
     return $oTemplate;
 }
コード例 #15
0
ファイル: ResourceIncluder.php プロジェクト: rapila/cms-base
 private function ieConditionalTemplate()
 {
     if (self::$IE_CONDITIONAL === null) {
         self::$IE_CONDITIONAL = new Template(self::IE_CONDITIONAL, null, true);
     }
     return clone self::$IE_CONDITIONAL;
 }
コード例 #16
0
ファイル: calculate-sri.php プロジェクト: rapila/cms-base
function getResourceContents($mLocation, $sResourceType = null)
{
    $oIncluder = new ResourceIncluder();
    $oIncluder->addResource($mLocation, $sResourceType);
    return LocalJsLibraryFileModule::getResourceIncluderContents($oIncluder);
}
コード例 #17
0
ファイル: FrontendManager.php プロジェクト: rapila/cms-base
 public function fillAutofill()
 {
     $bIsPreview = $this->isPreview();
     $this->oTemplate->replaceIdentifierCallback("autofill", function ($oTemplateIdentifier, $iFlags) use($bIsPreview) {
         $oModule = FrontendModule::getModuleInstance($oTemplateIdentifier->getValue(), $oTemplateIdentifier->getParameter('data'));
         $mResult = $oModule->cachedFrontend($bIsPreview);
         if (($sCss = $oModule->getCssForFrontend()) !== null) {
             ResourceIncluder::defaultIncluder()->addCustomCss($sCss);
         }
         if (($sJs = $oModule->getJsForFrontend()) !== null) {
             ResourceIncluder::defaultIncluder()->addCustomJs($sJs);
         }
         return $mResult;
     }, null, Template::NO_HTML_ESCAPE);
 }
コード例 #18
0
    public function testWriteNamedResourceIncludes()
    {
        $sTemplateText = <<<EOT
{{writeResourceIncludes;consolidate=false;name=myIncluder}}
EOT;
        $oTemplate = new Template($sTemplateText, null, true);
        $oIncluder = ResourceIncluder::namedIncluder('myIncluder');
        $oIncluder->clearIncludedResources();
        $oIncluder->addResource('admin/accept.png', null, null, array('template' => 'icons'));
        $oIncluder->addResource(array('web', 'js', 'widget', 'ckeditor', 'skins', 'moono', 'editor.css'));
        $oIncluder->addJavaScriptLibrary('jqueryui', 1);
        $oIncluder->addResource('admin/admin-ui.css');
        $oIncluder->addResource('widget/ckeditor/ckeditor.js');
        $this->assertSame('<link rel="icon" href="' . MAIN_DIR_FE . DIRNAME_BASE . '/web/images/admin/accept.png" />' . "\n" . '<link rel="stylesheet" media="all" href="' . MAIN_DIR_FE . DIRNAME_BASE . '/web/js/widget/ckeditor/skins/moono/editor.css" />' . "\n" . '<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>' . "\n" . '<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>' . "\n" . '<link rel="stylesheet" media="all" href="' . MAIN_DIR_FE . DIRNAME_BASE . '/web/css/admin/admin-ui.css" />' . "\n" . '<script type="text/javascript" src="' . MAIN_DIR_FE . DIRNAME_BASE . '/web/js/widget/ckeditor/ckeditor.js"></script>' . "\n", $oTemplate->render());
    }
コード例 #19
0
 public function onPageHasBeenSet($oPage, $bIsNotFound, $oNavigationItem)
 {
     if ($bIsNotFound || !$oPage->isOfType('journal')) {
         return;
     }
     // If is feed then render feed
     if ($oNavigationItem instanceof VirtualNavigationItem && $oNavigationItem->getType() === 'journal-feed') {
         $oFeed = new JournalFileModule(false, $oPage, $oNavigationItem->getData());
         $oFeed->renderFile();
         exit;
     } else {
         if ($oNavigationItem instanceof VirtualNavigationItem && $oNavigationItem->getType() === 'journal-add_comment' && Manager::isPost()) {
             $oEntry = $oNavigationItem->getData();
             if (!$oEntry->commentsEnabled()) {
                 LinkUtil::redirect(LinkUtil::link($oEntry->getLink()));
             }
             $this->handleNewJournalComment($oPage, $oEntry);
         }
     }
     //Add the feed include
     ResourceIncluder::defaultIncluder()->addCustomResource(array('template' => 'feed', 'location' => LinkUtil::link($oPage->getLinkArray('feed'))));
 }
コード例 #20
0
 private function cleanupInsertableParts()
 {
     if (isset($this->aModuleSettings['insertable_parts'])) {
         foreach ($this->aModuleSettings['insertable_parts'] as &$aPartSpec) {
             if (isset($aPartSpec['tooltip_string_key'])) {
                 $aPartSpec['tooltip'] = TranslationPeer::getString($aPartSpec['tooltip_string_key']);
                 unset($aPartSpec['tooltip_string_key']);
             }
             if (!isset($aPartSpec['template'])) {
                 continue;
             }
             if (isset($aPartSpec['icon'])) {
                 $oIncluder = new ResourceIncluder();
                 $oIncluder->addResource($aPartSpec['icon'], null, null, array('template' => 'location_only'));
                 $aPartSpec['icon'] = $oIncluder->getIncludes(false, false)->render();
             }
             $oTemplate = new Template($aPartSpec['template']);
             $aPartSpec['content'] = $oTemplate->render();
             unset($aPartSpec['template']);
         }
     }
 }
コード例 #21
0
 public function adminGetContainers()
 {
     $oTemplate = $this->oPage->getTemplate();
     foreach ($oTemplate->identifiersMatching('container', Template::$ANY_VALUE) as $oIdentifier) {
         $oInheritedFrom = null;
         $sContainerName = $oIdentifier->getValue();
         if (BooleanParser::booleanForString($oIdentifier->getParameter('inherit'))) {
             $oInheritedFrom = $this->oPage;
             $iInheritedObjectCount = 0;
             while ($iInheritedObjectCount === 0 && ($oInheritedFrom = $oInheritedFrom->getParent()) !== null) {
                 $iInheritedObjectCount = $oInheritedFrom->countObjectsForContainer($sContainerName);
             }
         }
         $sInheritedFrom = $oInheritedFrom ? $oInheritedFrom->getName() : '';
         $aTagParams = array('class' => 'template-container template-container-' . $sContainerName, 'data-container-name' => $sContainerName, 'data-container-string' => TranslationPeer::getString('container_name.' . $sContainerName, null, $sContainerName), 'data-inherited-from' => $sInheritedFrom);
         $oContainerTag = TagWriter::quickTag('ol', $aTagParams);
         $mInnerTemplate = new Template(TemplateIdentifier::constructIdentifier('content'), null, true);
         //Replace container info
         //…name
         $mInnerTemplate->replaceIdentifierMultiple('content', TagWriter::quickTag('div', array('class' => 'template-container-description'), TranslationPeer::getString('wns.page.template_container', null, null, array('container' => TranslationPeer::getString('template_container.' . $sContainerName, null, $sContainerName)), true)));
         //…additional info
         $mInnerTemplate->replaceIdentifierMultiple('content', TagWriter::quickTag('div', array('class' => 'template-container-info')));
         //…tag
         $mInnerTemplate->replaceIdentifierMultiple('content', $oContainerTag);
         //Replace actual container
         $oTemplate->replaceIdentifier($oIdentifier, $mInnerTemplate);
     }
     $bUseParsedCss = Settings::getSetting('admin', 'use_parsed_css_in_config', true);
     $oStyle = null;
     if ($bUseParsedCss) {
         $sTemplateName = $this->oPage->getTemplateNameUsed() . Template::$SUFFIX;
         $sCacheKey = 'parsed-css-' . $sTemplateName;
         $oCssCache = new Cache($sCacheKey, DIRNAME_PRELOAD);
         $sCssContents = "";
         if (!$oCssCache->entryExists() || $oCssCache->isOutdated(ResourceFinder::create(array(DIRNAME_TEMPLATES, $sTemplateName)))) {
             $oIncluder = new ResourceIncluder();
             foreach ($oTemplate->identifiersMatching('addResourceInclude', Template::$ANY_VALUE) as $oIdentifier) {
                 $oIncluder->addResourceFromTemplateIdentifier($oIdentifier);
             }
             foreach ($oIncluder->getAllIncludedResources() as $sIdentifier => $aResource) {
                 if ($aResource['resource_type'] === ResourceIncluder::RESOURCE_TYPE_CSS && !isset($aResource['ie_condition']) && !isset($aResource['frontend_specific'])) {
                     if (isset($aResource['media'])) {
                         $sCssContents .= "@media {$aResource['media']} {";
                     }
                     if (isset($aResource['file_resource'])) {
                         $sCssContents .= file_get_contents($aResource['file_resource']->getFullPath());
                     } else {
                         // Absolute link, requires fopen wrappers
                         $sCssContents .= file_get_contents($aResource['location']);
                     }
                     if (isset($aResource['media'])) {
                         $sCssContents .= "}";
                     }
                 }
             }
             $oParser = new Sabberworm\CSS\Parser($sCssContents, Sabberworm\CSS\Settings::create()->withDefaultCharset(Settings::getSetting("encoding", "browser", "utf-8")));
             $oCss = $oParser->parse();
             $this->cleanupCSS($oCss);
             $sCssContents = Template::htmlEncode($oCss->render(Sabberworm\CSS\OutputFormat::createCompact()));
             $oCssCache->setContents($sCssContents);
         } else {
             $sCssContents = $oCssCache->getContentsAsString();
         }
         $oStyle = new HtmlTag('style');
         $oStyle->addParameters(array('scoped' => 'scoped'));
         $oStyle->appendChild($sCssContents);
     }
     $sTemplate = $oTemplate->render();
     $sTemplate = substr($sTemplate, strpos($sTemplate, '<body') + 5);
     $sTemplate = substr($sTemplate, strpos($sTemplate, '>') + 1);
     $sTemplate = substr($sTemplate, 0, strpos($sTemplate, '</body'));
     $oParser = new TagParser("<body>{$sTemplate}</body>");
     $oTag = $oParser->getTag();
     $this->cleanupContainerStructure($oTag);
     if ($bUseParsedCss) {
         $oTag->appendChild($oStyle);
     }
     $sResult = $oTag->__toString();
     $sResult = substr($sResult, strpos($sResult, '<body>') + 6);
     $sResult = substr($sResult, 0, strrpos($sResult, '</body>'));
     return array('html' => $sResult, 'css_parsed' => $bUseParsedCss);
 }
コード例 #22
0
 private function getJSON(&$aRequest)
 {
     if ($this->sAction === 'destroy') {
         foreach ($aRequest['session_key'] as $sSessionKey) {
             Session::getSession()->setArrayAttributeValueForKey(WidgetModule::WIDGET_SESSION_KEY, $sSessionKey, null);
         }
         return;
     }
     $sWidgetClass = WidgetModule::getClassNameByName($this->sWidgetType);
     $bIsPersistent = $sWidgetClass::isPersistent();
     if (!$bIsPersistent) {
         // Close session early on readonly calls
         Session::close();
     }
     if ($this->sAction == 'widgetInformation') {
         $aInformation = array();
         $sWidgetClass::includeResources();
         $aInformation['resources'] = ResourceIncluder::defaultIncluder()->getIncludes()->render();
         $aInformation['methods'] = $sWidgetClass::getCustomMethods();
         $aInformation['is_singleton'] = $sWidgetClass::isSingleton();
         $aInformation['is_persistent'] = $bIsPersistent;
         return $aInformation;
     }
     if ($this->sAction == 'staticMethodCall') {
         $this->checkPermissions($sWidgetClass);
         $sMethodName = isset($aRequest['method']) ? $aRequest['method'] : Manager::usePath();
         if (!method_exists($sWidgetClass, $sMethodName)) {
             throw new LocalizedException('wns.file.widget_json.method_does_not_exist', array('method' => $sMethodName, 'widget' => $sWidgetClass));
         }
         return array("result" => call_user_func_array(array($sWidgetClass, $sMethodName), isset($aRequest['method_parameters']) ? $aRequest['method_parameters'] : array()));
     }
     $aInstanceArgs = array(@$aRequest['session_key']);
     if (isset($aRequest['instance_args'])) {
         $aInstanceArgs = $aRequest['instance_args'];
     }
     $aNewArgs = array_merge(array($this->sWidgetType), $aInstanceArgs);
     $oWidget = call_user_func_array(array('WidgetModule', 'getWidget'), $aNewArgs);
     if ($this->sAction === 'instanciateWidget') {
         $this->checkPermissions($sWidgetClass);
         $aInformation = array();
         $aInformation['session_id'] = $oWidget->getSessionKey();
         $oWidgetContents = $oWidget->doWidget();
         if ($oWidgetContents instanceof Template) {
             $oWidgetContents = $oWidgetContents->render();
         }
         $aInformation['content'] = $oWidgetContents;
         $aInformation['is_new'] = $oWidget->isNew();
         $aInformation['initial_settings'] = $oWidget->allSettings();
         return $aInformation;
     }
     if ($this->sAction === 'methodCall') {
         $this->checkPermissions($sWidgetClass);
         $sMethodName = isset($aRequest['method']) ? $aRequest['method'] : Manager::usePath();
         if (!method_exists($oWidget, $sMethodName)) {
             throw new LocalizedException('wns.file.widget_json.method_does_not_exist', array('method' => $sMethodName, 'widget' => $oWidget->getName()));
         }
         return array("result" => call_user_func_array(array($oWidget, $sMethodName), isset($aRequest['method_parameters']) ? $aRequest['method_parameters'] : array()));
     }
 }
コード例 #23
0
ファイル: PreviewManager.php プロジェクト: rapila/cms-base
 private function addNamespacedCss($mLocation)
 {
     array_unshift($mLocation, 'namespaced_preview_css');
     $oResourceIncluder = ResourceIncluder::defaultIncluder();
     $oResourceIncluder->addResource(LinkUtil::link($mLocation, 'FileManager'), ResourceIncluder::RESOURCE_TYPE_CSS);
 }