protected function getApplicationCustomParamater($paramKey)
    {
        $paramValue = $this->applicationLocalized->getCustomParameter($paramKey);

        if (empty($paramValue) && $this->applicationObject) {
            $paramValue = $this->applicationObject->getCustomParameter($paramKey);
        }

        return $paramValue;
    }
    /**
     * @param ApplicationFacet[]
     * @return FacetBase[]
     */
    public function buildFacetList($rawFacetList)
    {
        $facets = array();

        if ( is_array($rawFacetList) )
        {
            $applicationIdentifier = $this->applicationObject()->attribute('identifier');

            FacetFieldTagLanguage::$applicationIdentifier = $applicationIdentifier;
            FacetFieldTag::$applicationIdentifier = $applicationIdentifier;
            FacetPublishedSince::$applicationIdentifier = $applicationIdentifier;

            foreach ($rawFacetList as $rawFacet)
            {
                $usableFacet = FacetFactory::factory($rawFacet);

                if ( $usableFacet instanceof FacetBase )
                {
                    $facets[] = $usableFacet;

                    if ( $usableFacet instanceof FacetFieldTagLanguage )
                        $usableFacet->defaultValues = ApplicationLocalized::getTagFromLanguage( $this->applicationLocalized()->getPublisherLanguages() );
                }
            }
        }
        return $facets;
    }
    /**
     * @return ApplicationLocalized|null
     */
    private function getApplicationlocalized()
    {
        $condition = array(
            "id" => $this->attribute("channel_application_localized_id")
        );

        return ApplicationLocalized::fetchObject(ApplicationLocalized::definition(), null, $condition);
    }
    /**
     * Returns the URL Alias to an App
     *
     * The URL will be prefixed with the BaseUrl from site.ini.
     *
     * @return string URL
     **/
    protected function appUrlAlias()
    {
        $ini     = eZINI::instance();
        $baseUrl = $ini->variable( 'SiteAccessSettings', 'BaseUrl' );
        $url     = $baseUrl . $this->applicationLocalized->attribute( 'url_alias' );
        $url     = str_replace( "//", "/", $url );

        return $url;
    }
    /**
     * @return PermissionHandlerBase
     * @param ApplicationLocalized $applicationLocalized
     * @param ApplicationObject $applicationObject
     */
    public static function create(ApplicationLocalized $applicationLocalized, ApplicationObject $applicationObject)
    {
        $permissionHandlerIdentifier = $applicationLocalized->getCustomParameter('PermissionHandler');

        if (empty($permissionHandlerIdentifier))
        {
            $permissionHandlerIdentifier = $applicationObject->getCustomParameter('PermissionHandler');
        }

        if (empty($permissionHandlerIdentifier))
        {
            $permissionHandlerIdentifier = self::DEFAULT_PERMISSION_HANDLER;
        }

        /* @var $permissionHandler PermissionHandlerBase */
        $permissionHandler = new $permissionHandlerIdentifier();
        $permissionHandler->setApplicationObject($applicationObject);
        $permissionHandler->setApplicationLocalized($applicationLocalized);

        return $permissionHandler;
    }
    /**
     * @param string clusterIdentifier
     * @param array $applicationIds
     * @return string
     */
    protected function bulidUpdateXml( $clusterIdentifier, $applicationIds = array() )
    {
        $xml = '<add>';

        $sql  = $this->getSql( $clusterIdentifier );
        if ( !empty( $applicationIds ) )
        {
            $sql .= sprintf( " AND a.id IN ('%s')", implode( "','" , $applicationIds ) );
        }

        $applications = MMDB::instance()->arrayQuery( $sql );
        foreach( $applications as $row )
        {
            $application = new ApplicationLocalized( $row );

            $cacheApp = CacheApplicationTool::buildLocalizedApplicationByLocalizedId($application->id);
            
            if( !($cacheApp instanceof ApplicationLocalized) )
            {
                continue;
            }     
            $xml .= '<doc>';
            $this->addField( $xml, self::META_INSTALLATION_ID_MS_KEY, self::META_INSTALLATION_ID_MS_VAL );
            $this->addField( $xml, 'meta_guid_ms', md5( $application->application_id ) . "-{$application->cluster_identifier}" );
            $this->addField( $xml, 'identifier_s', $row['application_identifier'] );
            $this->addField( $xml, 'name_s', htmlspecialchars( $application->name ) );
            $this->addField( $xml, 'cluster_identifier_s', $application->cluster_identifier );

            $headlineKeywords = $this->prepareHeadlineKeywords($application->headline);

            foreach ($headlineKeywords as $headlineKeyword) {
                $this->addField( $xml, self::HEADLINE_KEYWORD, self::prepareKeywordString( $headlineKeyword ) );
            }


            $keywords = $application->getKeywords();
            if ( is_array( $keywords ) )
            {
                foreach ( $keywords as $keyword )
                {
                    $this->addField( $xml, self::META_APPLICATION_KEYWORD, self::prepareKeywordString( $keyword ) );
                }
            }
            $xml .= '</doc>';
        }

        $xml .= '</add>';
        return $xml;
    }
    /**
     * 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);
        }
    }
    /**
     * @return bool
     */
    public function htmlBuildResult()
    {
        parent::htmlBuildResult();

        $applicationIds = CountryApplicationLibrary::fetchAuthorizedApplicationIds();

        foreach( $applicationIds as $k => $v )
        {
            if(!$v)
                unset($applicationIds[$k]);
        }

        $applicationIds                  = array_values($applicationIds);
        $applications                    = ApplicationLocalized::fetchApplicationList( array('id' => array($applicationIds)) );
        $applicationWebtrendsIdentifiers = array();

        foreach( $applications as $k => $app )
        {
            /* @var $app ApplicationObject */
            $applicationWebtrendsParams = $app->applicationLocalized()->webtrendsParams();

            if( trim($applicationWebtrendsParams['cg_n']) != '' )
                $applicationWebtrendsIdentifiers[strval($app->attribute('id'))] = $applicationWebtrendsParams['cg_n'];
        }

        $this->tpl()->setVariable( 'apps_wb_labels', $applicationWebtrendsIdentifiers );

        /* @var $app ApplicationLocalized */
        foreach( CacheApplicationTool::clusterApplications() as $app )
        {
            if( $app->applicationObject->identifier == 'merck-connect' )
            {
                $this->tpl()->setVariable( 'merck_connect_results', true );
                break;
            }
        }

        return true;
    }
Пример #9
0
    public static function exportConfig($clusterIdentifier)
    {
        $db = MMDB::instance();
        $cli = eZCLI::instance();
        $config = array();

        $cli->output($clusterIdentifier);

        // GENERAL ABOUT CLUSTER
        $localized["view"] = ezpI18n::tr("merck", "NO VIEW");
        $localized["views"] = ezpI18n::tr("merck", "VIEWS");
        $localized["rating"] = ezpI18n::tr("merck", "NO RATING");
        $localized["ratings"] = ezpI18n::tr("merck", "RATING");
        $localized["dateForm"] = str_replace('%', '', eZINI::instance("date.ini")->variable($clusterIdentifier, 'DateFormat'));
        $localized["altDescription"] = ezpI18n::tr("seo", "ACTUALITIES");
        $config["localized"] = $localized;

        ClusterTool::setCurrentCluster($clusterIdentifier);
        // About application
        foreach($db->arrayQuery(sprintf("SELECT DISTINCT(application_identifier) FROM mm_seo WHERE cluster_identifier = '%s'", $clusterIdentifier)) as $row)
        {
            $applicationIdentifier = $row["application_identifier"];
            $filters = array();
            $config[$applicationIdentifier] = array();

            $appLocalized = ApplicationLocalized::getLocalizedApplicationByIdentifier($applicationIdentifier, $clusterIdentifier);
            $appUrl = $appLocalized->attribute('url');
            /** @var ContentListBase $app */
            $app = ApplicationFactory::fetchByUri( '/'.$appUrl );

            $isContentApplication = ( $app instanceof ContentListBase);
            if ( !$isContentApplication )
            {
                continue;
            }

            // CREATE FILTER
            $solrFilter = $app->getResultHandler()->solrFilter();
            $solrFacetsFiler = $app->getResultHandler()->solrFacetsFilter();
            if( $solrFilter )
                $filters[] = $solrFilter;
            if( $solrFacetsFiler )
                $filters[] = $solrFacetsFiler;

            $filters = implode(' AND ', $filters);
            $config[$applicationIdentifier]["filters"] = $filters;

            // CREATE MAPPING PUBLISHERS
            $publishers = array();
            foreach($app->applicationLocalized()->publisherFolders as $publisherFolder)
            {
                $publishers[$publisherFolder->attribute("path")] = $publisherFolder->getTranslation()->attribute("name");
            }
            $config[$applicationIdentifier]["publishers"] = $publishers;

            // CREATE CONFIGURATION TAGLINE
            $features = $app->resultHandler->features;
            $config[$applicationIdentifier]["tagline"] = $features["line"];
        }

        return $config;
    }
    /**
     * @param ApplicationLocalized $localizedApp
     * @return string
     */
    public static function createExternalApplicationCookieKey( $localizedApp )
    {
        $cookieKey = array( $localizedApp->attribute('headline') );
        if( $publisherNodeId = $localizedApp->publisherNodeIds() )
        {
            $cookieKey[] = $publisherNodeId[0];
        }

        return md5(serialize( $cookieKey ));
    }
    /**
     * @param string $applicationIdentifier
     * @return ApplicationLocalized
     */
    public static function buildLocalizedApplicationByIdentifier($applicationIdentifier)
    {
        $applicationName = CacheApplicationTool::getValue('applicationNameByIdentifier', $applicationIdentifier);

        if ( is_null($applicationName) )
        {
            $localizedApplication = ApplicationLocalized::getLocalizedApplicationByIdentifier($applicationIdentifier);

            if ( $localizedApplication instanceof ApplicationLocalized )
            {
                self::buildCache($localizedApplication);

                return $localizedApplication;
            }
            else
            {
                return null;
            }
        }
        else
        {
            return self::buildLocalizedApplication($applicationName);
        }
    }
Пример #12
0
    /**
     * @return array
     */
    public static function getApplicationLists()
    {
        $userAppList = AppBarControl::instance()->applicationIds();
        $orderedAppList = $userAppList;
        $apps = array();

        sort($orderedAppList);

        $rawApps = ApplicationLocalized::fetchApplicationList(array('id' => array($orderedAppList)));

        foreach ( $rawApps as $k => $app )
        {
            $force = false;
            if(SolrSafeOperatorHelper::featureIsActive('LearningNeedsAssessment') && $app->identifier == 'learning-needs-assessment')
            {
                $force = true;
            }

            if ( $app->attribute('application_library') || $force )
            {
                /* @var $app ApplicationLocalized */
                $apps['#' . $app->attribute('id')] = $app;
            }
            else
            {
                unset($userAppList[array_search($app->attribute('id'), $userAppList)]);
                $userAppList = array_values($userAppList);

                unset($orderedAppList[array_search($app->attribute('id'), $orderedAppList)]);
                $orderedAppList = array_values($orderedAppList);
            }
        }

        // we check if some apps were deleted in the meantime
        if ( self::user() )
        {
            $applistToUpdate = false;

            foreach ( $userAppList as $k => $id )
            {
                if ( !isset($apps['#' . $id]) )
                {
                    // we remove the application from the app bar only if it is not available for the anonymous
                    // display rights are handled at application level
                    if ( !in_array($id, CountryApplicationLibrary::fetchAuthorizedApplicationIds(true)) )
                    {
                        unset($userAppList[$k]);
                        $applistToUpdate = true;
                    }
                    else
                    {
                        $apps['#' . $id] = CacheApplicationTool::buildLocalizedApplicationByApplication($id);
                    }
                }
            }
            if ( $applistToUpdate )
            {
                $userAppList = array_values($userAppList);
                $user = MMUsers::getCurrentUserObject();
                $orderedAppList = $userAppList;

                sort($orderedAppList);

                $user->setApplicationList($userAppList);
            }
        }

        return array(
            'app_list' => self::user() ? $orderedAppList : $userAppList,
            'apps'     => $apps
        );
    }
/**
 * Adds an application folder to the publisher folder if it's not yet added
 * @param mixed $applicationId
 * @param mixed $publisherFolderId
 * @param eZCLI $cli
 */
function alignApplicationWithPublisherFolder( $applicationId, $publisherFolderId, eZCLI $cli )
{
    $application = $applicationId;
    $publisherFolder = $publisherFolderId;
    if (! $application instanceof ApplicationLocalized )
    {
        $application = ApplicationLocalized::getLocalizedApplicationById( $applicationId, false );
    }
    if ( $application == null )
    {
        throw new Exception( "Application localized with id {$applicationId} does not exist." );
    }

    if (! $publisherFolder instanceof MMSynchPublisherFolder )
    {
        $publisherFolder = MMSynchPublisherFolder::fetch( $publisherFolderId );
    }
    if ( $publisherFolder == null )
    {
        throw new Exception( "Publisher folder with id {$publisherFolderId} does not exist." );
    }

    $remoteId = 'application_folder-' . $application->cluster_identifier . '-' . $application->applicationObject->identifier;
    $applicationFolderObject = eZContentObject::fetchByRemoteID( $remoteId );
    if ( $applicationFolderObject == null )
    {
        throw new Exception( "Application folder object with remote id {$remoteId} doesn't exist" );
    }

    $applicationFolderId = $applicationFolderObject->attribute( 'id' );
    //use getContent with true to create problems
    $path = $publisherFolder->getContent( )->fields->path->toString();
    if ( $path )
    {
        $contentobject = $publisherFolder->getContent()->getRawContentObject();

        $languages = $contentobject->availableLanguages();

        foreach ( $languages as $language )
        {
            $dataMap = $contentobject->dataMap();
            $contentObjectAttributeTargetCS = $dataMap['target_cs'];
            $objectIds = explode( '-', $contentObjectAttributeTargetCS->toString() );

            if ( !in_array( $applicationFolderId, $objectIds ) )
            {
                $objectIds[] = $applicationFolderId;
                $contentObjectAttributeTargetCS->fromString( implode( '-', $objectIds ) );
                $contentObjectAttributeTargetCS->store();
            } 
            else
            {
                $cli->notice( "Ommiting application folder with path {$remoteId}" );
            }
        }
    }
}
    /**
     * @param array $conditions
     * @return ApplicationObject[]
     */
    public static function fetchApplicationList ( $conditions = array() )
    {
        if( is_null(self::$_applicationList ) )
        {
            $appIds = parent::fetchObjectList(ApplicationObject::definition(), null, $conditions, null, null, false );
            $apps   = array();

            foreach( $appIds as $appId )
            {
                $appLocalized = CacheApplicationTool::buildLocalizedApplicationByApplication($appId['id']);

                if ( $appLocalized instanceof ApplicationLocalized && $appLocalized->applicationObject instanceof ApplicationObject )
                    $apps[] = $appLocalized->applicationObject;
            }
            self::$_applicationList = $apps;
        }

        return self::$_applicationList;
    }
 /**
  * @return integer
  */
 protected function getMetaPathId()
 {
     return reset($this->application->publisherNodeIds());
     //return end($this->application->applicationNode()->pathArray());
 }
Пример #16
0
$function = $Params['function'];
$position = $Params['position'];

// INITIAL CHECKS
if ($function != 'install')
{
    echo "Unsuported operation detected. Only install is allowed, '{$operation}' given";
    eZExecution::cleanExit();
}
if ($position < 0)
{
    echo "Position must be > 1";
    eZExecution::cleanExit();
}

$application = ApplicationLocalized::getLocalizedApplicationByIdentifier($applicationIdentifier);
if ($application == null || $application instanceof ApplicationLocalized === false)
{
    header('Location: /error_40x');
    eZExecution::cleanExit();
}

$user = MMUsers::getCurrentUserObject();
if ($user === false)
{
    $siteIni = eZINI::instance( 'site.ini' );
    $loginUrl = preg_replace('#^https?//[^/]+#', '', $siteIni->variable('SiteSettings', 'LoginPage'));

    $redirectUrl = $loginUrl . '?context='. urlencode("/service/app/{$applicationIdentifier}/{$function}/{$position}");

    header('Location: ' . $redirectUrl);
        $bigFilename = eZDir::path(array($newBannerDir, 'banner_large.png'));
        $smallFilename = eZDir::path(array($newBannerDir, 'banner_small.png'));
        
        // Move banners
        $oldLargeBanner = eZDir::path(array($oldBannersDir, 'large.png'));
        if (file_exists($oldLargeBanner)) {
            moveIfNeeded($oldLargeBanner, $bigFilename);
        }
        
        $oldSmallBanner = eZDir::path(array($oldBannersDir, 'small.png'));
        if (file_exists($oldSmallBanner)) {
            moveIfNeeded($oldSmallBanner, $smallFilename);
        }
        
        // Fallback on image set in database and located in ezoscar extension
        $localApplication = ApplicationLocalized::getLocalizedApplicationByIdentifier($appIdentifier, $clusterIdentifier);
        if (!$localApplication instanceof ApplicationLocalized) {
            continue;
        }
        
        $db = eZDb::instance();
        $sql = 'SELECT banner_small_filename, banner_big_filename FROM mm_application_banner WHERE application_localized_id = %s;';
        $banners = $db->arrayQuery(sprintf($sql, $localApplication->attribute('id')));

        foreach($banners as $banner) {
            $oldLargeBanner = ltrim($banner, '/');
            $oldSmallBanner = ltrim($banner, '/');

            if ($oldLargeBanner) {
                moveIfNeeded($oldLargeBanner, $bigFilename);
            }
    /**
     * @param int $parent
     * @param int $id
     * @return ApplicationObject
     */
    public static function fetchByParent($parent, $id = null)
    {
        $cond = array('parent_id' => $parent);
        $isLoggedUser = MMUsers::getCurrentUserObject();

        if( !$isLoggedUser )
        {
            $restricted = array(
                'restriction_level' => array(
                    array(
                            self::RESTRICTION_LEVEL_PUBLIC,
                            self::RESTRICTION_LEVEL_RESTRICTED
                    )
                )
            );
        }
        else
        {
            $restricted = array(
                'id' => array(
                    CountryApplicationLibrary::fetchAuthorizedApplicationIds()
                )
            );
        }

        $cond        = array_merge($cond, $restricted);
        $relatedApps = ApplicationLocalized::fetchApplicationList ( $cond );

        if( $id )
        {
            for( $i=0; $i<count($relatedApps); $i++ )
            {
                if( $relatedApps[$i]->id == $id )
                {
                    unset($relatedApps[$i]);
                    break;
                }
            }
        }

        $wantedChildApps = array();
        $i = 0;
        foreach ($relatedApps as $relatedApp)
        {
            $passAppToView = true;
            $appLocalized = $relatedApp->applicationLocalized();
            if ( $appLocalized instanceof ApplicationLocalized && !$isLoggedUser)
            {
                if ( !in_array( $appLocalized->restrictionLevel(), $restricted['restriction_level'][0] ) )
                {
                    $passAppToView = false;
                }
            }

            if ( $passAppToView )
            {
                $wantedChildApps[$i] = $relatedApp;
                $i++;
            }
        }

        return $wantedChildApps;
    }