Esempio n. 1
0
    /**
     * @return array
     */
    public static function selectionList()
    {
        $userSelections = array();

        $selections = MMSelections::fetchUserSelection(null, null, false);

        /* @type $selection MMSelections */
        while ( list(, $selection) = each($selections) )
        {
            $object = eZContentObject::fetchByRemoteID($selection->attribute('remote_id'));
            if ( $object instanceof eZContentObject )
            {
                $node = $object->mainNode();
                /* @type $dataMap eZContentObjectAttribute[] */
                $dataMap = $node->dataMap();

                // Get first promo_image
                $image = false;
                if ( isset($dataMap['promo_image']) && $dataMap['promo_image']->hasContent() )
                {
                    $content = $dataMap['promo_image']->content();
                    $relationList = $content['relation_list'];
                    if ( isset($relationList[0]['node_id']) )
                    {
                        /* @type $imageDataMap eZContentObjectAttribute[] */
                        $imageNode = eZContentObjectTreeNode::fetch($relationList[0]['node_id']);
                        $imageDataMap = $imageNode->dataMap();
                        if ( isset($imageDataMap['file']) && $imageDataMap['file']->hasContent() )
                        {
                            /* @type $imageFileContent eZImageAliasHandler */
                            $imageFileContent = $imageDataMap['file']->content();
                            $imageFileAlias = $imageFileContent->imageAlias('original');
                            $image = $imageFileAlias['url'];
                        }
                    }
                }

                $applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByIdentifier($selection->attribute('application'));
                $applicationObject = $applicationLocalized->applicationObject();

                $userSelections[] = array(
                    'headline'        => $node->getName(),
                    'nodeId'          => $selection->attribute('node_id'),
                    'date'            => date(DATE_ATOM, $selection->attribute('add_date')),
                    'application'     => $applicationObject->attribute('id'),
                    'applicationName' => $applicationLocalized->attribute("name"),
                    'description'     => $selection->attribute('description'),
                    'image'           => '/' . $image,
                    'url'             => NodeOperatorHelper::getUrlNode($selection->attribute('application'), $node)
                );
            }
        }

        return array(
            'selection' => $userSelections,
            'count'     => MMSelections::countTotalFromUserSelection()
        );
    }
    /**
     * @return int
     */
    protected function startCourse()
    {
        $nodeId = ( isset( $_POST['nid'] ) && filter_var($_POST['nid'], FILTER_VALIDATE_INT) ) ? $_POST['nid'] : null;

        if( is_null($nodeId) )
            return null;

        $node = eZContentObjectTreeNode::fetch($nodeId);

        if( !$node )
            return null;

        /* @type $dataMap eZContentObjectAttribute[] */
        $dataMap        = $node->dataMap();
        $description    = '';

        if( $dataMap['promo_description']->hasContent() )
        {
            $description = $dataMap['promo_description']->content();
        }

        $application    = $this->applicationObject()->attribute( 'identifier' );
        $applicationId  = $this->applicationObject()->attribute( 'id' );
        $url            = NodeOperatorHelper::getUrlNode( $application, $node );

        return MMSelections::addToMySelection( $node->object()->remoteID(), ClusterTool::clusterIdentifier(), $description, $url, $applicationId );
    }
 /**
  * @param eZTemplate $tpl
  * @param string $operatorName
  * @param array $operatorParameters
  * @param string $rootNamespace
  * @param string $currentNamespace
  * @param mixed $operatorValue
  * @param array $namedParameters
  */
 function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters)
 {
     switch ($operatorName)
     {
         case 'getUrlNode':
             $operatorValue = NodeOperatorHelper::getUrlNode(
                 $namedParameters['applicationName'],
                 $namedParameters['node']
             );
             break;
         case 'getMediaContent':
             $operatorValue = NodeOperatorHelper::getMediaContent($namedParameters['node']);
             break;
         case 'getPictosMedia':
             $operatorValue = NodeOperatorHelper::getPictosMedia(
                 $namedParameters['node'],
                 $namedParameters['with_media_duration']
             );
             break;
         case 'getMediaDuration':
             $operatorValue = NodeOperatorHelper::getMediaDuration($namedParameters['media_object_id']);
             break;
         case 'getOverridePath':
             $operatorValue = NodeOperatorHelper::getOverridePath(
                 $namedParameters['node'],
                 $namedParameters['path']
             );
             break;
         case 'getApplicationIdentifierFromNode':
             $operatorValue = NodeOperatorHelper::getApplicationIdentifierFromNode($namedParameters['node']);
             break;
         case 'getPublisherFolder':
             $operatorValue = NodeOperatorHelper::getPublisherFolder(
                 $namedParameters['node'],
                 $namedParameters['application'],
                 $namedParameters['is_solr_data']
             );
             break;
         case 'sortNodesByMainPriority':
             $operatorValue = NodeOperatorHelper::sortNodesByMainPriority($namedParameters['nodes']);
             break;
         case 'hasImageArticle':
             $operatorValue = NodeOperatorHelper::hasImageArticle(
                 $namedParameters['node'],
                 $namedParameters['media_case']
             );
             break;
         case 'getCurrentNodeLanguage':
             $operatorValue = NodeOperatorHelper::getCurrentNodeLanguage($namedParameters['node']);
             break;
         case 'getMediaCount':
             $operatorValue = NodeOperatorHelper::getMediaCount($namedParameters['node']);
             break;
         case 'getPublisherNodeIdFromArticleNode':
             $operatorValue = NodeOperatorHelper::getPublisherNodeIdFromArticleNode(
                 $namedParameters['article_node']
             );
             break;
         case 'getRemoteComuniti':
             $operatorValue = NodeOperatorHelper::getRemoteComuniti(
                 $namedParameters['object_id'],
                 $namedParameters['remote_id']
             );
             break;
         case 'isHierarchyNode':
             $operatorValue = NodeOperatorHelper::isHierarchyNode(
                 $namedParameters['node']
             );
             break;
     }
 }