コード例 #1
0
ファイル: content.php プロジェクト: CG77/ezpublish-legacy
 /**
  * Instanciates an ezpContent from an eZContentObjectTreeNode
  * @param eZContentObjectTreeNode $node
  * @return ezpContent
  */
 public static function fromNode(eZContentObjectTreeNode $node, $checkAccess = true)
 {
     $object = $node->object();
     if ($checkAccess && !$object->attribute('can_read')) {
         throw new ezpContentAccessDeniedException($object->attribute('id'));
     }
     $content = new ezpContent();
     $content->fields = ezpContentFieldSet::fromContentObject($object);
     $content->object = $object;
     $content->locations = ezpContentLocation::fromNode($node);
     return $content;
 }
コード例 #2
0
 /**
  * @param eZContentObjectTreeNode $a
  * @param eZContentObjectTreeNode $b
  * @return int
  */
 public static function sortByPrority(eZContentObjectTreeNode $a, eZContentObjectTreeNode $b)
 {
     $ma = $a->isMain() ? $a : $a->object()->mainNode();
     $mb = $b->isMain() ? $b : $b->object()->mainNode();
     
     if ( $ma->object()->mainNode()->attribute('priority') == $mb->attribute('priority') )
     {
         return 0;
     }
     return ( $ma->attribute('priority') > $mb->attribute('priority') ) ? 1 : -1;
 }
コード例 #3
0
 /**
  * Initializes an object from a node
  * @param eZContentObjectTreeNode $node
  *
  * @return SQLIContent
  */
 public static function fromNode(eZContentObjectTreeNode $node)
 {
     $object = $node->object();
     $content = self::fromContentObject($object);
     $content->locations->addLocation(SQLILocation::fromNode($node));
     return $content;
 }
コード例 #4
0
/**
 * create HTML eZ Publish object
 * @param eZContentObjectTreeNode $parentNode
 * @param SimpleXMLElement $_item
 */
function createHTMLObject($parentNode, $_item)
{
    try
    {
        //get actual user
        $user = eZUser::currentUser();

        //object parameters
        $params                      = array();
        $params ['class_identifier'] = 'html';
        $params['creator_id']        = $user->attribute('contentobject_id');
        $params['parent_node_id']    = $parentNode->attribute('node_id');
        $params['section_id']        = $parentNode->object()->attribute('section_id');

        //set template attributes
        include_once('kernel/common/template.php');
        $htmlTpl = eZTemplate::factory();
        $htmlTpl->setVariable('title', $_item->title);
        $htmlTpl->setVariable('link', '/congressos-e-eventos?deeplink=' . urlencode($_item->link));
        $htmlTpl->setVariable('description', $_item->description);
        $htmlTpl->setVariable('category', $_item->category);
        $text = $htmlTpl->fetch('design:html/cronview.tpl');

        //attributes to insert
        $attributesData          = array();
        $attributesData['title'] = $_item->title;
        $attributesData['text']  = $text;

        $params['attributes'] = $attributesData;

        //object creation
        eZContentFunctions::createAndPublishObject($params);
    }
    catch (Exception $e)
    {
        $cli = eZCLI::instance();
        $cli->output($e->getMessage());
    }
}
コード例 #5
0
    /**
     * @param eZContentObjectTreeNode $node
     * @return array
     */
    public function getGTMTags( $node )
    {
        if( !($node instanceof eZContentObjectTreeNode) )
            return array();

        /* @type eZContentObjectAttribute[] $dataMap */
        $dataMap = $node->dataMap();
        /* @type eZContentObjectAttribute[] $englishDM */
        $englishDM = $node->object()->fetchDataMap( false, 'eng-GB' );
        $gtmVariables = array();
        
        if ($englishDM['headline'] || $dataMap['headline'])
        {
            $headline = count( $englishDM ) > 0 ? $englishDM['headline']->content() : $dataMap['headline']->content();
            $gtmVariables['contentName'] = addslashes(preg_replace("/[\\n\\r]+/"," ",$headline));
        }
        
        $remoteId = $node->object()->remoteID();
        $clusterIdentifier = ClusterTool::clusterIdentifier();
        
        if($remoteId && $clusterIdentifier)
        {
            $rating = SolrSafeOperatorHelper::getRatings( $remoteId, $clusterIdentifier );
            if ($rating)
            {
                $gtmVariables['contentScore'] = $rating;
            }
        }
        
        if($dataMap['tags'] && $dataMap['tags']->content())
        {
            $gtmVariables['tags'] = implode(",", explode("|", $dataMap['tags']->content()));
        }
        
        if($this->channel){
            
            $gtmVariables['sponsorName'] = '';
            $gtmVariables['sponsorPage'] = false;
            
            $sponsorName = $this->channel->attribute("sponsor");
            
            if ($sponsorName)
            {
                $gtmVariables['sponsorName'] = $sponsorName;
                $gtmVariables['sponsorPage'] = true;
            }
            
            $promoTaxonomy = $this->applicationLocalized()->getCustomParameter( 'PromoTaxonomy' );
            $promoTaxonomy = $promoTaxonomy ? $promoTaxonomy : $this->applicationObject()->getCustomParameter( 'PromoTaxonomy' );
            
            if($promoTaxonomy){
                $taxonomies = $dataMap['serialized_taxonomies']->content();
                
                if(is_array($taxonomies) && count($taxonomies[$promoTaxonomy]) > 0)
                {
                    $contentAreaTags = '';
                    foreach($taxonomies[$promoTaxonomy] as $taxonomy)
                    {
                         $contentAreaTags .= SolrSafeOperatorHelper::translateTaxonomy($taxonomy).",";
                    }
                    $gtmVariables['contentAreaTags'] = $contentAreaTags;
                }
            }
        }

        return $gtmVariables;
    }
コード例 #6
0
 function addVideo(eZContentObjectTreeNode $node)
 {
     $ini = eZINI::instance('xrowsitemap.ini');
     $video = new xrowSitemapItemVideo();
     $video->title = $node->attribute('name');
     $video->categories = array($node->attribute('parent')->attribute('name'));
     $object = $node->object();
     $video->view_count = eZViewCounter::fetch($node->attribute('node_id'))->Count;
     $video->publication_date = new DateTime('@' . $object->attribute('published'));
     $dm = $node->attribute('data_map');
     foreach ($dm as $attribute) {
         switch ($attribute->DataTypeString) {
             case 'xrowmetadata':
                 if ($attribute->hasContent()) {
                     $keywordattribute = $attribute->content();
                     $video->tags = array_merge($video->tags, $keywordattribute->keywords);
                 }
                 break;
             case 'ezkeyword':
                 if ($attribute->hasContent()) {
                     $keywordattribute = $attribute->content();
                     $video->tags = array_merge($video->tags, $keywordattribute->KeywordArray);
                 }
                 break;
             case 'ezimage':
                 if ($attribute->hasContent()) {
                     $imagedata = $attribute->content();
                     if ($ini->hasVariable('SitemapSettings', 'ImageAlias')) {
                         $aliasdata = $imagedata->attribute($ini->variable('SitemapSettings', 'ImageAlias'));
                         $video->thumbnail_loc = 'http://' . xrowSitemapTools::domain() . '/' . $aliasdata['url'];
                     } else {
                         $aliasdata = $imagedata->attribute('original');
                         $video->thumbnail_loc = 'http://' . xrowSitemapTools::domain() . '/' . $aliasdata['url'];
                     }
                 }
                 break;
             case 'ezmedia':
                 if ($attribute->hasContent()) {
                     $content = $attribute->content();
                     $uri = "content/download/" . $attribute->attribute('contentobject_id') . '/' . $content->attribute('contentobject_attribute_id') . '/' . $content->attribute('original_filename');
                     $video->content_loc = 'http://' . xrowSitemapTools::domain() . '/' . $uri;
                 }
                 break;
             case 'xrowvideo':
                 if ($attribute->hasContent()) {
                     $content = $attribute->content();
                     $uri = "content/download/" . $content["media"]->attribute->ContentObjectID . '/' . $content["media"]->attribute->ID . '/' . $content["binary"]->OriginalFilename;
                     $video->content_loc = 'http://' . xrowSitemapTools::domain() . '/' . $uri;
                     $video->duration = (int) $content["video"]["duration"];
                 }
                 break;
         }
         switch ($attribute->ContentClassAttributeIdentifier) {
             case 'description':
                 if ($attribute->hasContent()) {
                     $content = $attribute->content();
                     $descriptions = substr(strip_tags($content->ContentObjectAttribute->DataText), 0, 2048);
                     $video->description = $descriptions;
                 }
                 break;
         }
     }
     return $video;
 }
コード例 #7
0
    /**
     * 
     * @param eZContentObjectTreeNode $publisherFolderNode
     * @return string
     */
    public static function getPublisherFolderPath ( $publisherFolderNode )
    {
        $publisherFolderObject = $publisherFolderNode->object();
        $matchPath = array();

        if ( !preg_match('#^publisher_folder-(.*)$#', $publisherFolderObject->attribute('remote_id'), $matchPath) )
            return null;
        
        return $matchPath[1];
    }
コード例 #8
0
    /**
     * @param eZSolrDoc[] $docList
     * @param eZContentObjectTreeNode $node
     * @param $publisherFolderRelations
     */
    protected function processSpecificMerckManual(&$docList, $node, $dataMap, $publisherFolderRelations)
    {
        /* @var eZContentObjectAttribute[] $datamapDefault */
        $datamapDefault             = $dataMap;
        $taxonomiesAttribute        = $datamapDefault['serialized_taxonomies'];
        $merckManualClusters        = array();

        foreach ( $publisherFolderRelations['clusters'] as $cluster => $applications )
            foreach ( $applications as $application )
                if( $application == MerckManualShowcase::mainApplicationIdentifier() )
                    $merckManualClusters[] = $cluster;

        if( $taxonomiesAttribute instanceof eZContentObjectAttribute && $taxonomiesAttribute->hasContent() )
        {
            $taxonomies = $taxonomiesAttribute->content();

            if( isset( $taxonomies['section']) )
            {
                $sections = $taxonomies['section'];

                foreach( $docList as $languageCode => $doc )
                {
                    $datamap = $node->object()->fetchDataMap(false, $languageCode);

                    if( !$datamap )
                        $datamap = $datamapDefault;

                    $customSectionChaptersParts = array(
                        $sections[0],
                        $node->attribute( 'node_id' ),
                        $datamap['headline']->content()
                    );

                    foreach( $merckManualClusters as $cluster )
                    {
                        $doc->addField('attr_custom_section_chapter_' . $cluster . '_s', implode('##', $customSectionChaptersParts));
                    }
                }
                $this->addValueToDoc( $docList, 'subattr_section___source_id____s', $sections, true, true );
            }
        }
        elseif ( !($taxonomiesAttribute instanceof eZContentObjectAttribute) )
        {
            eZLog::write( "Indexation : Article with nodeId {$node->NodeID} doesn't have serialized_taxonomies attribute", 'error.log' );
        }
    }