コード例 #1
0
 /**
  * Returns string with rendered content
  *
  * @return string
  */
 public function render()
 {
     $tpl = eZTemplate::factory();
     $ini = eZINI::instance('rest.ini');
     $nodeViewData = eZNodeviewfunctions::generateNodeViewData($tpl, $this->content->main_node, $this->content->main_node->attribute('object'), $this->content->activeLanguage, 'rest', 0);
     $tpl->setVariable('module_result', $nodeViewData);
     $routingInfos = $this->controller->getRouter()->getRoutingInformation();
     $templateName = $ini->variable($routingInfos->controllerClass . '_' . $routingInfos->action . '_OutputSettings', 'Template');
     return $tpl->fetch('design:' . $templateName);
 }
コード例 #2
0
ファイル: timeline.php プロジェクト: heliopsis/ezflow
    return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
if (isset($Params['LanguageCode'])) {
    $languageCode = $Params['LanguageCode'];
} else {
    $locale = eZLocale::instance();
    $languageCode = $locale->localeCode();
}
$node = eZContentObjectTreeNode::fetch($nodeID, $languageCode);
if (!$node) {
    return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
$tpl = eZTemplate::factory();
$ini = eZINI::instance();
$contentObject = $node->attribute('object');
$nodeResult = eZNodeviewfunctions::generateNodeViewData($tpl, $node, $contentObject, $languageCode, 'full', 0);
// Generate a unique cache key for use in cache-blocks in pagelayout.tpl.
// This should be looked as a temporary fix as ideally all cache-blocks
// should be disabled by this view.
$cacheKey = "timeline-" + time();
$nodeResult["title_path"] = array(array("text" => "Timeline Preview"), array("text" => $node->attribute('name')));
$httpCharset = eZTextCodec::httpCharset();
$locale = eZLocale::instance();
$languageCode = $locale->httpLocaleCode();
$nodeResult['content_info']['persistent_variable']['extra_template_list'] = array('timeline.tpl');
$nodeResult['content_info']['persistent_variable']['pagestyle_css_classes'] = array('yui-skin-sam', 'yui-skin-ezflow');
$site = array('title' => $ini->variable('SiteSettings', 'SiteName'), 'design' => $ini->variable('DesignSettings', 'SiteDesign'), 'uri' => eZURI::instance(eZSys::requestURI()), 'http_equiv' => array('Content-Type' => 'text/html; charset=' . $httpCharset, 'Content-language' => $languageCode));
$currentUser = eZUser::currentUser();
$tpl->setVariable("current_user", $currentUser);
$tpl->setVariable('ui_context', "");
$uri = eZURI::instance(eZSys::requestURI());
コード例 #3
0
    if ( $viewCacheEnabled )
    {
        $cacheFileArray = eZNodeviewfunctions::generateViewCacheFile(
            eZUser::currentUser(),
            $NodeID,
            $Offset,
            $layout,
            $LanguageCode,
            $ViewMode,
            $viewParameters,
            false
        );

        return eZClusterFileHandler::instance( $cacheFileArray['cache_path'] )
            ->processCache(
                array( 'eZNodeviewfunctions', 'contentViewRetrieve' ),
                array( 'eZNodeviewfunctions', 'contentViewGenerate' ),
                null,
                null,
                $args
            );
    }

    $data = eZNodeviewfunctions::contentViewGenerate( false, $args ); // the false parameter will disable generation of the 'binarydata' entry
    return $data['content']; // Return the $Result array
}

// Looking for some view-cache code?
// Try the eZNodeviewfunctions class for enlightenment.
?>
コード例 #4
0
ファイル: view.php プロジェクト: rmiguel/ezpublish
                    $Result['content'] = $resultContent;
                }
            }
            break;
        case eZModuleOperationInfo::STATUS_CANCELLED:
            $Result = array();
            $Result['content'] = "Content view cancelled<br/>";
            break;
    }
    return $Result;
} else {
    $localVars = array("cacheFileArray", "NodeID", "Module", "tpl", "LanguageCode", "ViewMode", "Offset", "ini", "cacheFileArray", "viewParameters", "collectionAttributes", "validation");
    if ($viewCacheEnabled) {
        $user = eZUser::currentUser();
        $cacheFileArray = eZNodeviewfunctions::generateViewCacheFile($user, $NodeID, $Offset, $layout, $LanguageCode, $ViewMode, $viewParameters, false);
        $cacheFilePath = $cacheFileArray['cache_path'];
        $cacheFile = eZClusterFileHandler::instance($cacheFilePath);
        $args = compact($localVars);
        $Result = $cacheFile->processCache(array('eZNodeviewfunctions', 'contentViewRetrieve'), array('eZNodeviewfunctions', 'contentViewGenerate'), null, null, $args);
        return $Result;
    } else {
        $cacheFileArray = array('cache_dir' => false, 'cache_path' => false);
        $args = compact($localVars);
        $data = eZNodeviewfunctions::contentViewGenerate(false, $args);
        // the false parameter will disable generation of the 'binarydata' entry
        return $data['content'];
        // Return the $Result array
    }
}
// Looking for some view-cache code?
// Try the eZNodeviewfunctions class for enlightenment.
コード例 #5
0
 static function generateObjectViewCache($objectID)
 {
     // Generate the view cache
     $ini = eZINI::instance();
     $object = eZContentObject::fetch($objectID);
     $user = eZUser::currentUser();
     eZDebug::accumulatorStart('generate_cache', '', 'Generating view cache');
     if ($ini->variable('ContentSettings', 'PreViewCache') == 'enabled') {
         $preCacheSiteaccessArray = $ini->variable('ContentSettings', 'PreCacheSiteaccessArray');
         $currentSiteAccess = $GLOBALS['eZCurrentAccess'];
         // This is the default view parameters for content/view
         $viewParameters = array('offset' => false, 'year' => false, 'month' => false, 'day' => false, 'namefilter' => false);
         if (is_array($preCacheSiteaccessArray) && count($preCacheSiteaccessArray) > 0) {
             foreach ($preCacheSiteaccessArray as $changeToSiteAccess) {
                 $newSiteAccess = $currentSiteAccess;
                 $newSiteAccess['name'] = $changeToSiteAccess;
                 unset($newSiteAccess['uri_part']);
                 //eZSiteAccess::load() will take care of setting correct one
                 eZSiteAccess::load($newSiteAccess);
                 $tpl = eZTemplate::factory();
                 // Get the sitedesign and cached view preferences for this siteaccess
                 $siteini = eZINI::instance('site.ini');
                 $cachedViewPreferences = $siteini->variable('ContentSettings', 'CachedViewPreferences');
                 $language = false;
                 // Needs to be specified if you want to generate the cache for a specific language
                 $viewMode = 'full';
                 $assignedNodes = $object->assignedNodes();
                 foreach ($assignedNodes as $node) {
                     // We want to generate the cache for the specified user
                     $previewCacheUsers = $ini->variable('ContentSettings', 'PreviewCacheUsers');
                     foreach ($previewCacheUsers as $previewCacheUserID) {
                         // If the text is 'anon' we need to fetch the Anonymous user ID.
                         if ($previewCacheUserID === 'anonymous') {
                             $previewCacheUserID = $siteini->variable("UserSettings", "AnonymousUserID");
                             $previewCacheUser = eZUser::fetch($previewCacheUserID);
                         } else {
                             if ($previewCacheUserID === 'current') {
                                 $previewCacheUser = $user;
                             } else {
                                 $previewCacheUser = eZUser::fetch($previewCacheUserID);
                             }
                         }
                         if (!$previewCacheUser) {
                             continue;
                         }
                         // Before we generate the view cache we must change the currently logged in user to $previewCacheUser
                         // If not the templates might read in wrong personalized data (preferences etc.)
                         eZUser::setCurrentlyLoggedInUser($previewCacheUser, $previewCacheUser->attribute('contentobject_id'), eZUser::NO_SESSION_REGENERATE);
                         // Cache the current node
                         $cacheFileArray = eZNodeviewfunctions::generateViewCacheFile($previewCacheUser, $node->attribute('node_id'), false, false, $language, $viewMode, $viewParameters, $cachedViewPreferences);
                         $tmpRes = eZNodeviewfunctions::generateNodeView($tpl, $node, $node->attribute('object'), $language, $viewMode, false, $cacheFileArray['cache_dir'], $cacheFileArray['cache_path'], true, $viewParameters);
                         // Cache the parent node
                         $parentNode = $node->attribute('parent');
                         $objectID = $parentNode->attribute('contentobject_id');
                         // if parent objectID is null or is 0 we should not create cache.
                         if ($objectID) {
                             $cacheFileArray = eZNodeviewfunctions::generateViewCacheFile($previewCacheUser, $parentNode->attribute('node_id'), 0, false, $language, $viewMode, $viewParameters, $cachedViewPreferences);
                             $tmpRes = eZNodeviewfunctions::generateNodeView($tpl, $parentNode, $parentNode->attribute('object'), $language, $viewMode, 0, $cacheFileArray['cache_dir'], $cacheFileArray['cache_path'], true, $viewParameters);
                         }
                     }
                 }
             }
             // Restore the old user as the current one
             eZUser::setCurrentlyLoggedInUser($user, $user->attribute('contentobject_id'), eZUser::NO_SESSION_REGENERATE);
             // restore siteaccess
             eZSiteAccess::load($currentSiteAccess);
         }
     }
     if ($ini->variable('ContentSettings', 'StaticCache') == 'enabled') {
         $nodes = array();
         $ini = eZINI::instance();
         $useURLAlias =& $GLOBALS['eZContentObjectTreeNodeUseURLAlias'];
         $pathPrefix = $ini->variable('SiteAccessSettings', 'PathPrefix');
         // get staticCacheHandler instance
         $optionArray = array('iniFile' => 'site.ini', 'iniSection' => 'ContentSettings', 'iniVariable' => 'StaticCacheHandler');
         $options = new ezpExtensionOptions($optionArray);
         $staticCacheHandler = eZExtension::getHandlerClass($options);
         if (!isset($useURLAlias)) {
             $useURLAlias = $ini->variable('URLTranslator', 'Translation') == 'enabled';
         }
         eZContentCacheManager::nodeListForObject($object, true, self::CLEAR_DEFAULT, $nodes, $handledObjectList);
         // If no nodes returns it means that ClearCacheMethod = self::CLEAR_NO_CACHE
         if (count($nodes)) {
             foreach ($nodes as $nodeID) {
                 if ($useURLAlias) {
                     $oNode = eZContentObjectTreeNode::fetch($nodeID, false, true);
                     if (!isset($oNode)) {
                         continue;
                     }
                     $urlAlias = $oNode->urlAlias();
                     if ($pathPrefix != '') {
                         $tempAlias = substr($pathPrefix, strlen($pathPrefix) - 1) == '/' ? $urlAlias . '/' : $urlAlias;
                         if (strncmp($tempAlias, $pathPrefix, strlen($tempAlias)) == 0) {
                             $urlAlias = substr($tempAlias, strlen($pathPrefix));
                         }
                     }
                 } else {
                     $urlAlias = 'content/view/full/' . $nodeID;
                 }
                 $staticCacheHandler->cacheURL('/' . $urlAlias, $nodeID);
             }
             $staticCacheHandler->generateAlwaysUpdatedCache();
         }
     }
     eZDebug::accumulatorStop('generate_cache');
 }
コード例 #6
0
    static function contentViewGenerate( $file, $args )
    {
        extract( $args );
        $node = eZContentObjectTreeNode::fetch( $NodeID );

        if ( !is_object( $node ) )
        {
            if ( !eZDB::instance()->isConnected())
            {
                return  array( 'content' => $Module->handleError( eZError::KERNEL_NO_DB_CONNECTION, 'kernel' ),
                               'store'   => false );

            }
            else
            {
                return  array( 'content' => $Module->handleError( eZError::KERNEL_NOT_AVAILABLE, 'kernel' ),
                               'store'   => false );
            }
        }

        $object = $node->attribute( 'object' );

        if ( !is_object( $object ) )
        {
            return  array( 'content' => $Module->handleError( eZError::KERNEL_NOT_AVAILABLE, 'kernel' ),
                           'store'   => false );
        }

        if ( !$object instanceof eZContentObject )
        {
            return  array( 'content' => $Module->handleError( eZError::KERNEL_NOT_AVAILABLE, 'kernel' ),
                           'store'   => false );
        }
        if ( $node === null )
        {
            return  array( 'content' => $Module->handleError( eZError::KERNEL_NOT_AVAILABLE, 'kernel' ),
                           'store'   => false );
        }

        if ( $object === null )
        {
            return  array( 'content' => $Module->handleError( eZError::KERNEL_ACCESS_DENIED, 'kernel' ),
                           'store'   => false );
        }

        if ( $node->attribute( 'is_invisible' ) && !eZContentObjectTreeNode::showInvisibleNodes() )
        {
            return array( 'content' => $Module->handleError( eZError::KERNEL_ACCESS_DENIED, 'kernel' ),
                          'store'   => false );
        }

        if ( !$node->canRead() )
        {
            return array( 'content' => $Module->handleError( eZError::KERNEL_ACCESS_DENIED,
                                                             'kernel',
                                                             array( 'AccessList' => $node->checkAccess( 'read', false, false, true ) ) ),
                          'store'   => false );
        }

        $Result = eZNodeviewfunctions::generateNodeViewData( $tpl, $node, $object,
                                                              $LanguageCode, $ViewMode, $Offset,
                                                              $viewParameters, $collectionAttributes,
                                                              $validation );

        // 'store' depends on noCache: if $noCache is set, this means that retrieve
        // returned it, and the noCache fake cache file is already stored
        // and should not be stored again
        $retval = array( 'content' => $Result,
                         'scope'   => 'viewcache',
                         'store'   => !( isset( $noCache ) and $noCache ) );
        if ( $file !== false && $retval['store'] )
            $retval['binarydata'] = serialize( $Result );
        return $retval;
    }
コード例 #7
0
eZSiteAccess::load($access);
eZDebug::checkDebugByUser();
// Change content object default language
$GLOBALS['eZContentObjectDefaultLanguage'] = $LanguageCode;
eZTranslatorManager::resetTranslations();
ezpI18n::reset();
eZContentObject::clearCache();
eZContentLanguage::expireCache();
$Module->setTitle('View ' . $class->attribute('name') . ' - ' . $contentObject->attribute('name'));
$ini = eZINI::instance();
$res = eZTemplateDesignResource::instance();
$res->setDesignSetting($ini->variable('DesignSettings', 'SiteDesign'), 'site');
$res->setOverrideAccess($siteAccess);
$tpl = eZTemplate::factory();
if ($http->hasSessionVariable('LastAccessesVersionURI')) {
    $tpl->setVariable('redirect_uri', $http->sessionVariable('LastAccessesVersionURI'));
}
$designKeys = array(array('object', $contentObject->attribute('id')), array('node', $virtualNodeID), array('remote_id', $contentObject->attribute('remote_id')), array('class', $class->attribute('id')), array('class_identifier', $class->attribute('identifier')), array('viewmode', 'full'));
// View mode
if ($assignment) {
    $designKeys[] = array('parent_node', $assignment->attribute('parent_node'));
    if ($parentNodeObject instanceof eZContentObjectTreeNode) {
        $designKeys[] = array('depth', $parentNodeObject->attribute('depth') + 1);
    }
}
$res->setKeys($designKeys);
unset($contentObject);
$contentObject = $node->attribute('object');
$Result = eZNodeviewfunctions::generateNodeViewData($tpl, $node, $contentObject, $LanguageCode, 'full', 0, $viewParameters);
$Result['requested_uri_string'] = $requestedURIString;
$Result['ui_context'] = 'view';
コード例 #8
0
 function customObjectAttributeHTTPAction($http, $action, $contentObjectAttribute, $parameters)
 {
     switch ($action) {
         case "send_preview":
             $module = $parameters['module'];
             var_dump($module->obj);
             //viewData() );
             var_dump($obj);
             /*
                       $classAttribute = $contentObjectAttribute->contentClassAttribute();
                       var_dump($http);
                       var_dump($action);
                       var_dump($contentObjectAttribute);
                       var_dump
                       //$classAttribute = $contentObjectAttribute->contentClassAttribute();
                       //$module = $classAttribute->currentModule();
                       $module = $parameters['module'];
                       //var_dump($module);
                       
                       //var_dump($parameters);
                       $ObjectVersion = 26;
                       $ObjectID = 99;
                       $contentObject = ezContentObjectVersion::fetchVersion(  $ObjectVersion ,$ObjectID);
                       
                       $tpl =& templateInit();
                       $tpl->setVariable('object', $contentObject);
                       //$tpl->setVariable('newsletter', $newsletter);
                       $tpl->fetch( 'design:eznewsletter/newsletter_preview.tpl' );
             */
             /*
                     $cacheFileArray = array( 'cache_dir' => false, 'cache_path' => false );
                     $NodeID = 101;
                     
             //$Module = $Params['Module'];
             $tpl = templateInit();
             $LanguageCode = $Params['Language'];
             $ViewMode = "full";
             $Offset = $Params['Offset'];
             //$ini = eZINI::instance();
             $Year = $Params['Year'];
             $Month = $Params['Month'];
             $Day = $Params['Day'];
             $viewParameters = array( 'offset' => $Offset,
                                            'year' => $Year,
                                            'month' => $Month,
                                            'day' => $Day,
                                            'namefilter' => false );
             $viewParameters = array_merge( $viewParameters, $UserParameters );
             $collectionAttributes = false;
                   if ( isset( $Params['CollectionAttributes'] ) )
                     $collectionAttributes = $Params['CollectionAttributes'];
                   
                   $validation = array( 'processed' => false, 'attributes' => array() );
             
                   if ( isset( $Params['AttributeValidation'] ) )
                     $validation = $Params['AttributeValidation'];
                     
                   $localVars = array( "cacheFileArray", "NodeID",  "Module", "tpl",
                                           "LanguageCode",  "ViewMode", "Offset", "ini",
                                           "cacheFileArray", "viewParameters", "collectionAttributes",
                                           "validation" );
             
             
              
             
                     $args = compact( $localVars );
             
                     // the false parameter will disable generation of the 'binarydata' entry
                     $data = eZNodeviewfunctions::contentViewGenerate( false, $args ); 
             */
             $tpl = templateInit();
             $EditVersion = 26;
             $pathIdentificationString = "";
             $ObjectID = 99;
             $parentNodeID = 2;
             $virtualNodeID = null;
             $pathString = "";
             $depth = 2;
             $objectName = "OMG";
             $node = new eZContentObjectTreeNode();
             $node->setAttribute('contentobject_version', $EditVersion);
             $node->setAttribute('path_identification_string', $pathIdentificationString);
             $node->setAttribute('contentobject_id', $ObjectID);
             $node->setAttribute('parent_node_id', $parentNodeID);
             $node->setAttribute('main_node_id', $virtualNodeID);
             $node->setAttribute('path_string', $pathString);
             $node->setAttribute('depth', $depth);
             $node->setAttribute('node_id', $virtualNodeID);
             //$node->setAttribute( 'sort_field', $class->attribute( 'sort_field' ) );
             //$node->setAttribute( 'sort_order', $class->attribute( 'sort_order' ) );
             $node->setName($objectName);
             $node->setContentObject($contentObject);
             $contentObject = null;
             $LanguageCode = null;
             $viewParameters = array();
             $contentObject = eZContentObject::fetch($ObjectID);
             $Result = eZNodeviewfunctions::generateNodeViewData($tpl, $node, $contentObject, $LanguageCode, 'full', 0);
             var_dump($Result);
             //var_dump( $module->run("versionview") );
             $contentObjectAttribute->setValidationError(ezi18n('kernel/classes/datatypes', 'The email address is not valid.'));
     }
 }
コード例 #9
0
 static function contentViewGenerate($file, $args)
 {
     extract($args);
     $node = eZContentObjectTreeNode::fetch($NodeID);
     if (!is_object($node)) {
         return array('content' => $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel'), 'store' => false);
     }
     $object = $node->attribute('object');
     if (!is_object($object)) {
         return array('content' => $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel'), 'store' => false);
     }
     if (!$object instanceof eZContentObject) {
         return array('content' => $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel'), 'store' => false);
     }
     if ($node === null) {
         return array('content' => $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel'), 'store' => false);
     }
     if ($object === null) {
         return array('content' => $Module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel'), 'store' => false);
     }
     // HACK! Ignore showInvisibleNodes policy for the 'detail' view mode in ez_sbase. We do policy
     // checking in the template.
     if ($ViewMode != 'detail') {
         if ($node->attribute('is_invisible') && !eZContentObjectTreeNode::showInvisibleNodes()) {
             return array('content' => $Module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel'), 'store' => false);
         }
     }
     if (!$object->canRead()) {
         return array('content' => $Module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel', array('AccessList' => $object->accessList('read'))), 'store' => false);
     }
     $Result = eZNodeviewfunctions::generateNodeViewData($tpl, $node, $object, $LanguageCode, $ViewMode, $Offset, $viewParameters, $collectionAttributes, $validation);
     // 'store' depends on noCache: if $noCache is set, this means that retrieve
     // returned it, and the noCache fake cache file is already stored
     // and should not be stored again
     $retval = array('content' => $Result, 'scope' => 'viewcache', 'store' => !(isset($noCache) and $noCache));
     if ($file !== false && $retval['store']) {
         $retval['binarydata'] = serialize($Result);
     }
     return $retval;
 }