/**
     * @param string $path
     * @param string $quote
     * @param bool $skipSlash
     * @return string
     */
    public static function staticFile($path, $quote, $skipSlash)
    {
        $ini = eZINI::instance();
        $imgDecHash = 0;
        if ( $ini->variable( 'DesignSettings', 'DynamicImageSuffix' ) == 'enabled' )
        {
            $cluster = ClusterTool::clusterIdentifier();
            $filePath = StaticData::clusterFilePath($cluster, $path);
            if ( ! empty( $filePath ) )
            {
                $imgHash = sha1_file( $filePath );
                $imgDecHash = hexdec( substr( $imgHash, 0, 7 ) );
            }
        }
        $path = StaticData::externalUrl(ClusterTool::clusterIdentifier(), $path);

        $path = (!$skipSlash ? '/' : '') . ltrim($path, '/');

        if ( ! empty( $imgDecHash ) )
        {
            $path =  preg_replace( '/^(.*)\.([^.]+)$/i', '$1.'.$imgDecHash.'.$2', $path );
        }

        if (! $skipSlash )
        {
            $serverURL = eZURI::serverShardingURL( $path );
            $path = $serverURL.$path;
        }

        if ($quote == 'double')
            $path = sprintf('"%s"', $path);
        elseif ($quote == "single")
            $path = sprintf("'%s'", $path);

        return $path;
    }
Exemplo n.º 2
0
    /**
     * @param ChannelBlockConfiguration[] $configurations
     * @param ChannelBlock $block
     * @return array
     */
    public function getBlockHtml($configurations, ChannelBlock $block, $taxonomyFilters = array())
    {
        // list of all applications with application informations and all articles
        $articles = array();

        $variables = array(
            "title" => $block->attribute("title")
        );
        $variables["show_title"] = !$block->attribute("hide_title");

        if($block->attribute("illustration_image"))
        {
            $variables["illustration_image"] = StaticData::externalUrl(ClusterTool::clusterIdentifier(), $block->attribute("illustration_image"));
        }

        $mustacheEngine = MustacheTool::getEngine("__CHANNEL_", false, $this);

        $dynamicContent = $this->manageDynamicContent($block, $variables);

        if(!$configurations)
        {
            return $this->manageStaticContent($block, $mustacheEngine, $variables, $dynamicContent);
        }

        // Retrieve all articles for the block (all articles from all applications)
        $applicationLocalized = null;
        /** @var ChannelBlockConfiguration $configuration */
        foreach($configurations as $configuration)
        {
            $applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByLocalizedId($configuration->attribute("application_localized_id"));

            if(is_null($applicationLocalized))
                continue;

            /** @var ContentListBase $app */
            $app = ApplicationFactory::fetchByUri( $applicationLocalized->applicationUrl() );

            // retrieve default filters
            $this->addParamsConfiguration($app, $configuration);

            $categoryFiltered = $configuration->attribute('category_filtered');
            // add taxonomy in fl

            if (!empty($taxonomyFilters) && $categoryFiltered) {
                $app->getResultHandler()->setExternalFilters($taxonomyFilters);
            }

            $app->getResultHandler()->additionnalTaxonomyFields = $this->addMappingTaxonomies();
            // isFull to true, for get all articles and not call additionalSolrFilters and limit on date -> see MMJamaNetworkListSolrQueryHandler
            $app->isFull = true;

            $solrResult = $app->getResultHandler()->contentResultMain(false, true);
            if($solrResult["response"]["numFound"])
            {
                $solrReturn = $app->getResultHandler()->articleResult($solrResult, array());
                if($solrReturn["article_informations"] && $solrReturn["article_informations"]["articles_solrdata"])
                {
                    $newArticles = $this->constructArticles($solrReturn["article_informations"]["articles_solrdata"], $app->getResultHandler()->additionnalTaxonomyFields, $configuration->getChannelBlock());
                    $articles = array_merge($articles, $newArticles);
                }
            }
        }

        // construct url for link "more" and reorder/limit if we have several application
        $more = null;
        if(count($configurations) == 1 && $solrResult["response"]["numFound"] == 0 && $block->getTemplate())
        {
            return false;
        }
        elseif(count($configurations) == 1 && ($solrResult["response"]["numFound"] > $this->getLimit($block)))
        {
            $variables["has_more"] = true;
            $more = $this->getLinkMore($configurations[0], $block);
        }
        else
        {
            if(count($articles) == 0)
                return false;

            // if we have several articles from several applications we have to reorder them no matter the application
            $this->reorderArticles($articles, $block->attribute("sorting_method"));
            $articles = $this->limitArticles($articles, $block);
        }

        $articlesColumns = $this->splitArticles($articles, $block);
        // if there is no columns, we fill articles variable instead of articles
        if(empty($articlesColumns))
            $variables["articles"] = $articles;
        else
            $variables["columns"] = $articlesColumns;

        $variables["nb_columns"] = $this->getColumns($block);

        return array(
            "more"      => $more,
            "content"   => $mustacheEngine->render($block->getTemplate(), $variables),
            'isStatic'  => false
        );
    }
    /**
     * Push to the view variable about channel : channel headline, channel full url, channel part url (i.e: (channel)/131) and the icon
     */
    public function pushChannelResult()
    {
        if ($this->channel instanceof ApplicationLocalized) {
            $channelConfiguration = $this->channel->getChannelConfiguration();
            
            if ($this->channel->attribute("headline")) {
                $this->pushResult("channel_headline", $this->channel->attribute("headline"));
                $this->pushResult("channel_url", $this->channel->applicationUrl());
            }

            $this->pushResult('channel_id', $this->channel->application_id);

            $this->pushResult("channel_icon", StaticData::externalUrl(ClusterTool::clusterIdentifier(), $channelConfiguration->attribute("icon")));
            $this->pushResult("channel_color", $channelConfiguration->attribute("color"));

            if($this->channelBlockId){
                $this->pushResult("channel_part_url", "/(channel)/" . $this->channelBlockId);
            }

            $this->pushResult("channel_identifier", $this->channel->applicationObject()->identifier);
        }
    }
Exemplo n.º 4
0
    /**
     * @return array
     */
    public static function applicationList()
    {
        # Hotfix #23450 note-8
        if ( !isset($_COOKIE['remember_me']) )
        {
            $cookieExpiration = time() + eZINI::instance('merck.ini')->variable('TIBCOCookieSettings', 'TIBCOCookieExpiration');
            $uuid = MMUsers::getCurrentUserId();
            setcookie('remember_me', MMUserLogin::encryptText(json_encode($uuid)), $cookieExpiration, '/', CookieTool::getCookieDomain());
        }

        $out = array('applicationList' => array());
        $host = 'http://' . self::host();

        if ( isset($_POST['application']) )
        {
            $applicationIdList = array((int) $_POST['application']);
        }
        else
        {
            $applicationIdList = AppBarControl::instance()->applicationIds();
        }

        foreach ( $applicationIdList as $applicationId )
        {
            if ( !is_numeric($applicationId) )
            {
                continue;
            }
            $applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByApplication($applicationId);
            $application = ($applicationLocalized) ? $applicationLocalized->applicationObject() : null;

            if ( $applicationLocalized )
            {
                $application = $applicationLocalized->applicationObject();
            }

            if ( isset($application) )
            {
                $applicationType = $application->applicationType();

                $icons = array(
                    'icon' => array(
                        'path' => '',
                        'md5' => '',
                        'file' => 'ico.png',
                    ),
                    'icon_hd' => array(
                        'path' => '',
                        'md5' => '',
                        'file' => 'ico_notext_hd.png',
                    ),
                    'icon_active' => array(
                        'path' => '',
                        'md5' => '',
                        'file' => 'ico_notext_active.png',
                    ),
                    'icon_active_hd' => array(
                        'path' => '',
                        'md5' => '',
                        'file' => 'ico_notext_active_hd.png'
                    ),
                );

                foreach($icons as $key => $iconData)
                {
                    $path = sprintf('apps/%s/%s', $application->attribute('identifier'), $iconData['file']);
                    $fullPath = StaticData::clusterFilePath(ClusterTool::clusterIdentifier(), $path);
                    if ($fullPath)
                    {
                        $icons[$key]['path'] = StaticData::externalUrl(ClusterTool::clusterIdentifier(), $path);
                        $icons[$key]['md5'] = md5_file($fullPath);
                    }
                }

                $path = '/' . $applicationLocalized->attribute('url');
                $url = $host . $path;
                if ( $application->isPureExternal() )
                {
                    $url = $applicationLocalized->attribute("external_url");
                }

                $outApplicationListArray = array(
                    'id'         => $applicationId,
                    'identifier' => $application->attribute('identifier'),
                    'name'       => $applicationLocalized->attribute('name'),
                    'headline'   => $applicationLocalized->attribute('headline'),
                    'type'       => $applicationType->attribute('internal_type'),
                    'url'        => $url,
                    'path'       => $path,
                    'javascript' => self::getJavascript($application->attribute('identifier'), 'application'));

                foreach($icons as $key => $icon)
                {
                    $outApplicationListArray[$key] = array(
                        '100' => array('path' => $icon['path'], $icon['md5']),
                    );
                }
                $out['applicationList'][] = $outApplicationListArray;
            }
        }
        return $out;
    }
    /**
     * @param ChannelConfiguration $channelConfiguration
     * @return string
     */
    public function getNewImage(ChannelConfiguration $channelConfiguration)
    {
        if($this->attribute("new"))
        {
            return StaticData::externalUrl(ClusterTool::clusterIdentifier(), $this->attribute("new"));
        }

        if(!$channelConfiguration->attribute("new"))
        {
            return null;
        }

        return StaticData::externalUrl(ClusterTool::clusterIdentifier(), $channelConfiguration->attribute("new"));
    }