/**
     * @param string[] $params
     * @param string $outputType
     * @param string $blockName
     * @param bool $applicationName
     */
    public function __construct ( $params, $outputType, $blockName, $applicationName = false )
    {
        parent::__construct( $params, $outputType, $blockName, $applicationName );

        if($applicationName)
            $this->_application = ApplicationFactory::fetchByUri( '/'.$applicationName );
    }
 /**
  * @since 2.3
  *
  * @return InMemoryPoolCache
  */
 public static function getInstance()
 {
     if (self::$instance === null) {
         self::$instance = new self(ApplicationFactory::getInstance()->newCacheFactory());
     }
     return self::$instance;
 }
 /**
  * @since 2.4
  */
 public static function disableSemantics()
 {
     $disabledSettings = array('smwgSemanticsEnabled' => false, 'smwgNamespacesWithSemanticLinks' => array(), 'smwgQEnabled' => false, 'smwgAutoRefreshOnPurge' => false, 'smwgAutoRefreshOnPageMove' => false, 'smwgFactboxCacheRefreshOnPurge' => false, 'smwgAdminRefreshStore' => false, 'smwgPageSpecialProperties' => array(), 'smwgEnableUpdateJobs' => false, 'smwgEnabledEditPageHelp' => false, 'smwgInlineErrors' => false);
     foreach ($disabledSettings as $key => $value) {
         ApplicationFactory::getInstance()->getSettings()->set($key, $value);
         $GLOBALS[$key] = $value;
     }
 }
 /**
  * @since 2.1
  *
  * @return PropertyRegistry
  */
 public static function getInstance()
 {
     if (self::$instance === null) {
         $propertyLabelFinder = new PropertyLabelFinder(ApplicationFactory::getInstance()->getStore(), $GLOBALS['smwgContLang']->getPropertyLabels());
         self::$instance = new self(DataTypeRegistry::getInstance(), $propertyLabelFinder, $GLOBALS['smwgContLang']->getPropertyAliases());
         self::$instance->registerPredefinedProperties($GLOBALS['smwgUseCategoryHierarchy']);
     }
     return self::$instance;
 }
 protected function createApplication(LoggerInterface $logger, $debug = true)
 {
     $configuration = array('root' => __DIR__, 'debug' => $debug, 'security.firewalls' => array('secured' => array('pattern' => '^/account$', '_controller' => function (Request $request, Response $response, Authentication $auth) {
         if (!$auth->check($request)) {
             return $response->redirect('/login');
         }
     }, 'response' => new Response(), 'auth' => new Authentication())));
     $dispatcher = new EventDispatcher();
     $frontendController = $this->createFrontendController($configuration, $this->logger);
     return ApplicationFactory::build($configuration, $dispatcher, $frontendController);
 }
    public function __construct( $params, $outputType, $blockName, $applicationName )
    {
        parent::__construct( $params, $outputType, $blockName, $applicationName );

        $parts = $params['Parameters'];
        array_shift($parts);
        $this->app = ApplicationFactory::fetchByUri( implode('/',$parts) );

        if ( $this->app->applicationName() == 'error' )
            unset($this->app);
    }
 /**
  * @since 2.1
  *
  * @return PropertyRegistry
  */
 public static function getInstance()
 {
     if (self::$instance !== null) {
         return self::$instance;
     }
     $propertyLabelFinder = ApplicationFactory::getInstance()->getPropertyLabelFinder();
     $extraneousLanguage = Localizer::getInstance()->getExtraneousLanguage();
     $propertyAliasFinder = new PropertyAliasFinder($extraneousLanguage->getPropertyAliases(), $extraneousLanguage->getCanonicalPropertyAliases());
     self::$instance = new self(DataTypeRegistry::getInstance(), $propertyLabelFinder, $propertyAliasFinder, $GLOBALS['smwgDataTypePropertyExemptionList']);
     self::$instance->registerPredefinedProperties($GLOBALS['smwgUseCategoryHierarchy']);
     return self::$instance;
 }
    /**
     * Creates a new instance
     *
     * @param int $appId Localized Application Id
     * @param int $nbArticles Number of articles
     * @param int $viewMode View mode to use
     * @param int $publisherId Id of Publisher
     * @param int $selectionType Selection type to use
     **/
    public function __construct( $appId, $nbArticles, $viewMode, $publisherId, $selectionType )
    {
        $this->applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByLocalizedId($appId);
        $this->applicationObject    = $this->applicationLocalized->applicationObject();
        $this->nbArticles           = $nbArticles;
        $this->viewMode             = $viewMode;
        $this->publisherId          = $publisherId;
        $this->selectionType        = $selectionType;
        $applicationName            = $this->applicationLocalized->attribute('url');

        if($applicationName)
            $this->_application = ApplicationFactory::fetchByUri( '/'.$applicationName );
    }
    /**
     * @return bool
     */
    public function htmlBuildResult()
    {
        $ela = array();

        foreach( CacheApplicationTool::clusterApplications() as $app )
        {
            if
            (
                $app->applicationObject->applicationType->attribute('type_identifier') == 'e-learning'
                && $app->getCustomParameter('HasLearningTracker')
                && ApplicationFactory::fetchByUri($app->attribute('url_alias'))->canRead()
            )
            {
                $ela[] = array(
                    'headline' => $app->headline,
                    'url'      => $app->applicationUrl(),
                );
            }
        }
        $this->pushResult( 'ela', $ela );
        $this->pushResult( 'content_service_configuration', $this->applicationObject->configurationContentService );
        $this->pushResult( 'is_mobile', ContextTool::instance()->isMobile() );
		$this->pushResult( 'isApplicationAllowedToUser', MMLimitedApplicationsAllowedUsers::hasCurrentUserAccessToApp(CacheApplicationTool::buildLocalizedApplicationByIdentifier('learning-needs-assessment')->application_id) );

        $uuid = $this->user()->attribute('uuid');
        $this->pushResult( 'userId', $uuid );

        //LNA Dashboard url
        $lmtBaseUrl = SolrSafeOperatorHelper::feature('LearningNeedsAssessment', 'LMTBaseUrl');
        $lmtPrefix = SolrSafeOperatorHelper::feature('LearningNeedsAssessment', 'LMTPrefix');
        $this->pushResult( 'dashboardUrl', $lmtBaseUrl . $lmtPrefix );

        $environment = new MMEnvironment();
        $this->pushResult( 'environment', $environment->env );
        
        $userData = CertificatesWebservice::readUserData();
        $this->pushResult( 'companyCode', $userData['CID'] );

        $countryPrefix = preg_replace( "~cluster|_~", "", ClusterTool::clusterIdentifier() );
        $this->pushResult( 'dashBoardCountryPrefix', strtolower( $countryPrefix ) . '_' );

        parent::htmlBuildResult();

        return true;
    }
    private function buildResultList()
    {
        $applications = array();
        $applicationIds = array();
        $applicationsByName = array();
        
        foreach( CountryApplicationLibrary::fetchAuthorizedApplicationIds() as $appId )
        {
            if( $appId == 0 )
                continue;
            
            $applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByApplication( $appId );
            
            if( !($applicationLocalized instanceof ApplicationLocalized) )
                continue;

            // Hack : Temporary patch to override in localized application the mm_application.parent_id
            if ( $applicationLocalized->getCustomParameter('DirectAccessDisable') === true )
                continue;

            if( (bool)$applicationLocalized->applicationObject->attribute('application_library') )
            {
                if($applicationLocalized->restrictionLevel() == ApplicationObject::RESTRICTION_LEVEL_LIMITED)
                {
                    if(MMLimitedApplicationsAllowedUsers::hasCurrentUserAccessToApp($applicationLocalized->application_id))
                    {
                        $applications[] = $applicationLocalized->applicationObject;
                        $applicationIds[] = $appId;
                    }
                }
                else
                {
                    $applications[] = $applicationLocalized->applicationObject;
                    $applicationIds[] = $appId;
                }
            }
        }
        
        /* @var $app ApplicationObject */
        foreach( $applications as $k => $app )
            $applicationsByName[$app->applicationLocalized()->attribute('headline')] = $app;
        uksort( $applicationsByName, function($a, $b){ return strnatcasecmp($a, $b); });

        // display all applications
        $this->pushResult('application_ids'     , $applicationIds);
        $this->pushResult('applications_by_name', $applicationsByName);

        // for anonymous users
        $ids = CountryAppsBar::fetchAppsBarApplicationIds();
        $applications_anonymous = array();
        foreach($ids as $id)
            $applications_anonymous[] = (string)$id;
        $this->pushResult('applications_anonymous', $applications_anonymous);

        // banners
        $banners        = array();
        $base           = $this->applicationLocalized()->applicationUrl().'/';
        
        /* @var $application ApplicationObject */
        /* @var $homepageApplication MMHomePage */
        $homepageApplication = ApplicationFactory::fetchByUri('/');
        foreach( $homepageApplication->getAppsToAdd() as $application )
        {
            $bannerFiles = $application->applicationLocalized()->getBanners();

            if (is_array($bannerFiles) && !is_null($bannerFiles['big']) && !is_null($bannerFiles['small']))
            {
                $banners[] = array(
                    'id'        => $this->applicationLocalized()->attribute('id'),
                    'img'       => SolrSafeOperatorHelper::bannerDecHash('/esibuild/banner/'.$application->attribute( 'identifier' ).'/big/'.ClusterTool::clusterIdentifier().'.png'),
                    'img_small' => SolrSafeOperatorHelper::bannerDecHash('/esibuild/banner/'.$application->attribute( 'identifier' ).'/small/'.ClusterTool::clusterIdentifier().'.png'),
                    'label'     => $application->applicationLocalized()->attribute('headline'),
                    'url'       => $base . $application->applicationLocalized()->attribute('url'),
                );
            }

            if( count($banners) >= self::BANNER_ITEMS_LIMIT )
                break;
        }

        $this->pushResult('banners', $banners);
    }
Esempio n. 11
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
        );
    }
Esempio n. 12
0
<?php

require_once __DIR__ . '/bootstrap.php';
use Minima\Provider\DatabaseProvider;
use Minima\Provider\LoggerProvider;
use Minima\Http\Request;
use Minima\FrontendController\FrontendController;
use Symfony\Component\EventDispatcher\EventDispatcher;
// Configuration
$configuration = array('root' => __DIR__);
// Stateful Components
$dispatcher = new EventDispatcher();
$database = DatabaseProvider::getConnection();
$frontendController = FrontendController::build($configuration);
// Add your routes here
// Build Application
$application = ApplicationFactory::build($configuration, $dispatcher, $frontendController);
// Handle the request
$request = Request::createFromGlobals();
$response = $application->handle($request);
$response->send();
 public function testCreateContainerBuilder()
 {
     $this->assertThat($this->object->createContainerBuilder(), $this->isInstanceOf('IContainerBuilder'));
 }
    /**
     * @param string $applicationIdentifier
     * @return array
     */
    public static function getInfosApp( $applicationIdentifier )
    {
        $applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByIdentifier($applicationIdentifier);

        /** @var $application ApplicationObject */
        $application = ( $applicationLocalized instanceof ApplicationLocalized )
            ? $applicationLocalized->applicationObject
            : null;

        if( !$application )
            return null;

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

        return array(
            'application'            => $application,
            'application_localized'  => $applicationLocalized,
            'solr_facet_filters'     => ( $app instanceof ContentListBase ) ? $app->getResultHandler()->solrFacetsFilter() : '',
            'solr_filters'           => ( $app instanceof ContentListBase ) ? $app->getResultHandler()->solrFilter() : ''
        );
    }
Esempio n. 15
0
<?php
	header( 'Cache-Control: no-cache, must-revalidate' );

	$globalSearchURi = CacheApplicationTool::buildLocalizedApplicationByIdentifier( 'global-search' )->attribute( 'url' );
	$globalSearch = ApplicationFactory::fetchByUri( $globalSearchURi );
	$globalSearch->initResultHandler();
	$resultHandler = $globalSearch->getResultHandler();

	$responseFormat = $Params['wt'];
	$keyword = trim( $Params['q'] );

	$filters = array();

	$filters[] = $resultHandler->publishersFilter();
	
	$additionalSolrFilters = $resultHandler->additionalSolrFilters();
	foreach($additionalSolrFilters as $a)
		$filters[] = $a;

    $params = array(
	    'indent'       => 'on',
	    'q'            => $keyword,
	    'fq'           => implode( ' AND ', $filters ),
	    'start'        => '',
	    'rows'         => '15',
	    'fl'           => 'attr_headline_s',
	    'qt'           => 'ezpublish',
	    'explainOther' => '',
	    'hl.fl'        => '',
	    'sort'         => 'score desc',
	);
    /**
     * @return array
     */
    public function getErrorContent()
    {
        $errorUri = '/error';
        $app      = ApplicationFactory::fetchByUri( $errorUri );

        $app->buildResult();

        return $app->getHtmlResult();
    }
Esempio n. 17
0
 /**
  * @since 1.9
  *
  * @param boolean $addJob
  */
 protected function notifyUpdateDispatcher($addJob = true)
 {
     if ($addJob && !$this->hasDiff) {
         ApplicationFactory::getInstance()->newJobFactory()->newUpdateDispatcherJob($this->semanticData->getSubject()->getTitle())->run();
         $this->hasDiff = true;
     }
 }
    /**
     * @param $node eZContentObjectTreeNode
     * @return bool
     */
    public static function getFileApplicationCanRead(&$node)
    {
        $relatedObjects = $node->object()->reverseRelatedObjectList(false, eZContentObjectTreeNode::classAttributeIDByIdentifier('download_ressource') );
        try
        {
            if(count($relatedObjects) == 0)
                throw new Exception('No article related to this object');

            /** @var eZContentObject $articleObject */
            /** @var eZContentObjectTreeNode $articleNode */
            $articleObject = $relatedObjects[0];
            $articleNode = $articleObject->mainNode();

            $applicationIdentifier = NodeTool::getApplicationFromNode($articleNode);

            /** @var ApplicationDefault $application */
            $application = ApplicationFactory::fetchByUri($applicationIdentifier);

            if(!$application->canRead())
            {
                throw new Exception('Can\'t read');
            }

            return true;
        }
        catch (Exception $e)
        {
            return false;
        }
    }
Esempio n. 19
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;
    }
 /**
  * @since 2.5
  *
  * @param string $text
  * @param string $languageCode
  *
  * @return DIProperty[]|[]
  */
 public function findPropertyListFromLabelByLanguageCode($text, $languageCode = '')
 {
     if ($text === '') {
         return array();
     }
     if ($languageCode === '') {
         $languageCode = Localizer::getInstance()->getContentLanguage()->getCode();
     }
     $dataValue = DataValueFactory::getInstance()->newDataValueByProperty(new DIProperty('_PPLB'));
     $dataValue->setUserValue($dataValue->getTextWithLanguageTag($text, $languageCode));
     $queryFactory = ApplicationFactory::getInstance()->getQueryFactory();
     $descriptionFactory = $queryFactory->newDescriptionFactory();
     $description = $descriptionFactory->newConjunction(array($descriptionFactory->newNamespaceDescription(SMW_NS_PROPERTY), $descriptionFactory->newFromDataValue($dataValue)));
     $propertyList = array();
     $queryResult = $this->store->getQueryResult($queryFactory->newQuery($description));
     if (!$queryResult instanceof \SMWQueryResult) {
         return $propertyList;
     }
     foreach ($queryResult->getResults() as $result) {
         $propertyList[] = DIProperty::newFromUserLabel($result->getDBKey());
     }
     return $propertyList;
 }