コード例 #1
0
    /**
     * @param $token
     * @return bool
     */
    public static function isUserTokenValid($token)
    {
        //get secret seed and add date (20140703)
        $secretSeed = self::getFormSecretSeed();

        //get user id (anonymous or current logged user)
        $userId = MMUsers::getCurrentUserId() != -1 ? MMUsers::getCurrentUserId() : MMUsers::getAnonymousUserId();

        //cluster identifier
        $clusterIdentifier = ClusterTool::clusterIdentifier();

        if(sha1($secretSeed . date('Ymd') . $userId . $clusterIdentifier) == $token)
        {
            return true;
        }
        //yesterday date
        else if(sha1($secretSeed . date('Ymd', time() - 60 * 60 * 24) . $userId . $clusterIdentifier) == $token)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
 public function additionalSolrFilters()
 {
     return array(
     		sprintf('-attr_exclude_from_search_%s_b:1', ClusterTool::clusterIdentifier()),
     		'-attr_hide_in_search_b:true'
     );
 }
コード例 #3
0
    /**
     * @return bool
     */
    private static function loadConfiguration()
    {
        if( !empty( self::$fields ) )
        {
            return false;
        }

        $db = MMDB::instance();

        $clusterIdentifier = ClusterTool::clusterIdentifier();

        $query = 'SELECT f.business_name, f.attribute_type, l.default_value,
                  CASE WHEN l.control_type_identifier IS NULL THEN f.control_type_identifier ELSE l.control_type_identifier END AS control_type_identifier,
                  CASE WHEN l.control_type_value IS NULL THEN f.control_type_value ELSE l.control_type_value END AS control_type_value
                  FROM uump_field AS f INNER JOIN uump_localized_field AS l ON l.field_id = f.id AND l.cluster_identifier = "%s"
                  ORDER BY f.business_name';
        $results = $db->arrayQuery( sprintf( $query, $clusterIdentifier ) );

        foreach( $results as $result )
        {
            self::$fields[$result['business_name']] = array(
                'control_type_identifier' => $result['control_type_identifier'],
                'control_type_value'      => $result['control_type_value'],
                'attribute_type'          => $result['attribute_type'],
                'default_value'           => $result['default_value']
            );
        }

        return true;
    }
コード例 #4
0
 /**
  * Renders the block (returns HTML)
  *
  * @return string HTML
  **/
 public function render()
 {
     $tpl = eZTemplate::factory();
     $tpl->setVariable( 'name', $this->name );
     $tpl->setVariable( 'banners', $this->fetchBanners() );
     $tpl->setVariable( 'cluster_identifier', ClusterTool::clusterIdentifier() );
     return $tpl->fetch( 'design:presenters/block/channel.tpl' );
 }
コード例 #5
0
 /**
  * @param string $clusterIdentifier
  * @return SystemLocale[]
  */
 static public function fetchByClusterIdentifier( $clusterIdentifier = null )
 {
     return self::fetchObjectList(
         self::definition(),
         null,
         array( 'cluster_identifier' => is_null( $clusterIdentifier ) ? ClusterTool::clusterIdentifier() : $clusterIdentifier )
     );
 }
コード例 #6
0
    /**
     * @return string
     */
    protected function validateToU()
    {
        if( !self::user() )
            return false;

        self::user()->toUValidated(true);

        $context = ContextTool::instance()->backUrl();
        $context = isset( $_POST['context'] ) ? $_POST['context'] : '/';

        // @todo: update ESB by sending validation status
        $esbResult = new ESBResult();
        $userService = ESBFactory::getUserService();

        if(SolrSafeOperatorHelper::featureIsActive('UUMP'))
        {
            
            $result = $userService->read(self::user()->attribute('uuid'));
            ServiceLoginUUMP::populateESBResult($esbResult, $result);
        }
        else
        {
            $result = ServiceLogin::readCall(self::user()->attribute('uuid'), $esbResult);
            ServiceLogin::populateESBResult($esbResult, $result);
        }

        $esbResult->userName = self::user()->attribute('uuid');
        $esbResult->termsOfUse = 'Y';
        $esbResult->privacyPolicy = 'Y';

        if( SolrSafeOperatorHelper::featureIsActive('UUMP') || (ClusterTool::clusterIdentifier() == "cluster_at") )
        {
            $esbResult->termsOfUse = '1';
            $esbResult->privacyPolicy = '1';
        }
        $esbResult->countryOfRegistration = self::user()->attribute( 'country' );

        $userService->write($esbResult->toServiceAgreementTicket());

        // if the ESB call fails, we still validate the user input to let him access the content
        $esbResult->forceToUValidated = true;
        $esbResult->sessionID = $_COOKIE[self::iniMerck()->variable('TIBCOCookieSettings', 'TIBCOCookieName')];

        $loginResult = MMUserLogin::esbLogin( self::user()->attribute('uuid'), $esbResult, false, $context );
        if ( $loginResult )
        {
            // Stringify params
            $strParams = json_encode( $loginResult['params'] );

            // Encrypts params
            $encryptedParams = MMUserLogin::encryptText( $strParams );
            // Redirect to PHP-ESI
            $redirectURL = ContextTool::instance()->domain()."/loginActions.php?context=" . urlencode( $loginResult['destUrl'] ) . "&params=" . urlencode( $encryptedParams );
        
            return $redirectURL;
        }
    }
コード例 #7
0
    /**
     * @param string $name
     * @param mixed $value
     * @param string $cacheFileName
     * @return mixed|null
     */
    public static function dailyValue( $name, $value = null, $cacheFileName = null )
    {
        if ( $value === null && isset($memoryCache[$name]) && $cacheFileName === null )
        {
            return self::$memoryCache[$name];
        }
        else
        {
            if (is_null($cacheFileName))
            {
                $cacheFileName = self::DAILY_CACHE_FILE . '_' . ClusterTool::clusterIdentifier();
            }

            $cache = new eZPHPCreator(
                eZSys::cacheDirectory(),
                $cacheFileName . '.php',
                '',
                array()
            );

            $expiryTime = time() - 24 * 3600;

            // reading
            if ($cache->canRestore($expiryTime))
            {
                $values = $cache->restore(array('cacheTable' => 'cacheTable'));

                if (is_null($value))
                {
                    if (isset($values['cacheTable'][$name]))
                    {
                        return $values['cacheTable'][$name];
                    }
                    else
                    {
                        return null;
                    }
                }
            }
            else
            {
                $values = array('cacheTable' => array());
            }

            $values['cacheTable'][$name] = $value;
            if ( $cacheFileName == self::DAILY_CACHE_FILE . '_' . ClusterTool::clusterIdentifier() )
                self::$memoryCache = $values['cacheTable'];

            // writing
            $cache->addVariable('cacheTable', $values['cacheTable']);
            $cache->store(true);
            $cache->close();
        }

        return null;
    }
コード例 #8
0
    /**
     * @return TouPpPopin
     */
    public static function fetchByClusterIdentifier()
    {
        $conditions = array(
            "cluster_identifier" => ClusterTool::clusterIdentifier(),
        );

        $results = self::fetchObjectList(self::definition(), null, $conditions, null, 1);

        return !is_null($results) ? array_pop($results) : null;
    }
コード例 #9
0
 /**
  * @return array
  */
 public static function getFetchParams()
 {
     return array(
         'indent'       => 'on',
         'q'            => '',
         'start'        => 0,
         'rows'         => 10,
         'fl'           => 'meta_node_id_si, attr_view_counter_'.ClusterTool::clusterIdentifier().'_i, attr_content_rating_'.ClusterTool::clusterIdentifier().'_f',
         'qt'           => 'ezpublish',
         'explainOther' => '',
         'hl.fl'        => '',
         'sort'         => 'attr_online_date_dt desc, attr_headline_lc_s asc'
     );
 }
コード例 #10
0
    public function htmlBuildListResult()
    {
        $this->resultHandler->parseRequestParams();

        $this->pushResult('cluster_identifier', ClusterTool::clusterIdentifier());
        $this->pushResult('class_identifiers' , $this->resultHandler->contentClassIdentifiers);
        $this->pushResult('is_logged_in'      , (bool)$this->user());
        $this->pushResult('tou_validated'     , ($this->user() && $this->user()->toUValidated()));
        $this->pushResult('num_found'         , 0);
        $this->pushResult('sort_list'         , $this->resultHandler->sortList);
        $this->pushResult('facets'            , $this->getFacetsAsArray());

        if ( $this->applicationObject && !empty($this->applicationObject->configurationContentService) )
            $this->pushResult('content_service_configuration', $this->applicationObject->configurationContentService);
    }
コード例 #11
0
    /**
     * @param $solrResponse
     * @return array
     */
    protected function formatSolrResponseAttributes($solrResponse)
    {
        $formatedResult = array();
        foreach($solrResponse as $item)
        {
            $formatedResult[] = array(
                'headline'      =>        $item['attr_headline_t'],
                'description'   =>        $item['attr_promo_description_t'],
                'url'           =>        $item['attr_'.ClusterTool::clusterIdentifier().'_url_s'],
                'category'      =>        $item['attr_category_t'],
                'date'          =>        $item['attr_date_dt'],
            );
        }

        return $formatedResult;
    }
コード例 #12
0
 public function reset()
 {
     $this->_logData = array(
         'guid'       => uniqid(),
         'cluster'    => \ClusterTool::clusterIdentifier(),
         'dateGMT'    => gmdate('Y-m-d H:i:s'),
         'dateLocal'  => date('Y-m-d H:i:s'),
         'action'     => null,
         'step'       => null,
         'uuid'       => null,
         'esb_status' => null,
         'msg'        => null,
         'referer'    => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '',
         'ip'         => \eZSys::clientIP(),
         'method'     => $_SERVER['REQUEST_METHOD'],
     );
 }
コード例 #13
0
    /**
     * @param string $clusterIdentifier
     * @param string $applicationIdentifier
     * @param string $bannerType
     * @return string
     */
    public static function getStaticPath( $clusterIdentifier, $applicationIdentifier, $bannerType )
    {
        if ( $clusterIdentifier !== ClusterTool::clusterIdentifier() )
        {
            ClusterTool::setCurrentCluster($clusterIdentifier);
        }
        $applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByIdentifier( $applicationIdentifier );
        if ( !($applicationLocalized instanceof ApplicationLocalized) )
        {
            return null;
        }
        $bannerArray = $applicationLocalized->getBanners();
        if( isset( $bannerArray[$bannerType] ) && !empty( $bannerArray[$bannerType] ) )
        {
            return preg_replace( '#/extension#', 'extension/', $bannerArray[$bannerType] );
        }

        return null;
    }
コード例 #14
0
    /**
     * @param string $query
     * @param int $limit
     * @return array
     */
    public static function search( $query, $limit = 3 )
    {
        if ( !empty( $query ) )
        {
            $params = array(
                'qf' => self::META_APPLICATION_KEYWORD . ' ' . self::HEADLINE_KEYWORD,
                'qt' => 'ezpublish',
                'start' => 0,
                'rows' => $limit,
                'q' => '"' . StringTool::removeAccents( strtolower( $query ) ) . '"',
                'fq' => 'cluster_identifier_s:' . ClusterTool::clusterIdentifier() . ' AND ' . self::META_INSTALLATION_ID_MS_KEY . ':' . self::META_INSTALLATION_ID_MS_VAL,
                'fl' => '*,score',
                'sort' => 'name_s asc'
            );

            $result = SolrTool::rawSearch( $params, 'php', false );
            return $result;
        }
    }
コード例 #15
0
    public function __construct()
    {
        // Guzzle RESTclient
        $this->builder = ServiceBuilder::factory(__DIR__ . '/../../classes/service/descriptor.php');


        $this->client = $this->builder['ldap'];

        // Logger
        $filter = new ezcLogFilter();
        $filter->severity = ezcLog::ERROR | ezcLog::INFO | ezcLog::WARNING;
        $this->logger = ezcLog::getInstance();
        $logFileName = "ws.log";
        if ( SolrSafeOperatorHelper::clusterIni('WebService', 'CountrySpecificLogs', 'merck.ini') == 'enabled' )
        {
            $clusterId = ClusterTool::clusterIdentifier();
            $logFileName = "ws_{$clusterId}.log";
        }
        $this->logger->getMapper()->appendRule(new ezcLogFilterRule( $filter, new ezcLogUnixFileWriter( "var/log/", $logFileName, 157286400, 3 ), true ) );
    }
コード例 #16
0
    /**
     * @param int $lowestGlobalRanking
     * @param int $applicationId
     * @param bool $localQuiz
     * @return QuizPendingRankingUpdate
     */
    static function add( $lowestGlobalRanking, $applicationId, $localQuiz )
    {
        $clusterIdentifier = ($localQuiz) ? ClusterTool::clusterIdentifier() : '';
        $qpru = self::fetchObject( self::definition(), null, array(
            'cluster_identifier' => $clusterIdentifier,
            'application_id'     => $applicationId
        ) );
        if( !$qpru )
            $qpru = new self();
        else {
            if( (int)$qpru->attribute( 'lowest_global_ranking' ) > $lowestGlobalRanking )
                return false;
        }
        $qpru->setAttribute( 'lowest_global_ranking', $lowestGlobalRanking );
        $qpru->setAttribute( 'cluster_identifier', $clusterIdentifier );
        $qpru->setAttribute( 'application_id', $applicationId );
        $qpru->store();

        return $qpru;
    }
コード例 #17
0
    /**
     * @param $definitionId
     * @return FeatureLocalized
     */
    public static function getLocalizedFeatureByDefinitionId( $definitionId )
    {
        $conditions = array(
            'feature_definition_id' => $definitionId,
            'cluster_identifier'    => ClusterTool::clusterIdentifier(),
        );

        return self::fetchObject (
            self::definition(),
            null,
            $conditions
        );
    }
 /**
  * @return string
  */
 protected function facetSolrIdFieldName()
 {
     return 'attr_custom_layer_sublayer_natom_' . ClusterTool::clusterIdentifier() . '_s';
 }
コード例 #19
0
    public static function getPublisherArticleUrl($publisher, $articleId)
    {
        $fields = array(
            'apps' => 'subattr_local_application___source_mixed____s',
            'url'  => 'attr_'.ClusterTool::clusterIdentifier().'_url_s',
            'publisher_path' => 'subattr_publisher_folder___source_id____s',
        );

        $fq = array(
            "subattr_publisher_folder___source_id____s: \"{$publisher}\"",
            "attr_publisher_internal_id_s: \"{$articleId}\"",
        );

        $params = array(
            'indent'        => 'on',
            'q'             => '',
            'start'         => 0,
            'rows'          => 1,
            'fq'            => implode(' AND ', $fq),
            'fl'            => implode(',', array_values($fields)),
            'qt'            => 'ezpublish',
            'explainOther'  => '',
            'hl.fl'         => '',
        );

        $raw = SolrTool::rawSearch($params);
        if ($raw['response']['numFound'] == 0)
        {
            return null;
        }
        $row = $raw['response']['docs'][0];

        $solrApplicationIndexes = $row[$fields['apps']];
        $solrApplicationIdentifiers = array();
        $solrApplicationNames = array();

        foreach( $solrApplicationIndexes as $applicationIndex )
        {
            list ( $cluster, /* unused */, $applicationId ) = explode( '##', $applicationIndex );

            if ( $cluster == ClusterTool::clusterIdentifier() )
            {
                $app = CacheApplicationTool::buildLocalizedApplicationByApplication( $applicationId );

                if ( !($app instanceof ApplicationLocalized) )
                    continue;

                $solrApplicationNames[] = $app->attribute('name');
                $solrApplicationIdentifiers[] = $app->applicationObject()->attribute('identifier');
            }
        }

        if (empty($solrApplicationIdentifiers))
        {
            return;
        }
        $applicationIdentifier = $solrApplicationIdentifiers[0];
        $application = CacheApplicationTool::buildLocalizedApplicationByIdentifier( $applicationIdentifier );
        $applicationObject = $application->applicationObject();
        $applicationType = $applicationObject->applicationType()->attribute('type_identifier');
        $publisherPath = $row[$fields['publisher_path']][0];
        $publisherInfo = PublisherFolderTool::getPathToIDMapping($publisherPath);
        $publisherFolderId = $publisherInfo['pfid'];

        $url = isset( $row[$fields['url']] ) ? $row[$fields['url']] : null;

        $url = ($applicationType == 'first-child')
            ? $application->attribute('url_alias')
            : $application->attribute('url_alias') . '/' . $publisherFolderId . '/' . $url;

        return $url;
    }
コード例 #20
0
 /**
  * @return string
  */
 protected function facetSolrIdFieldName()
 {
     return 'attr_custom_section_chapter_' . ClusterTool::clusterIdentifier() . '_s';
 }
コード例 #21
0
    /**
     * @param bool $forAnonmyous
     * @param null $processedUserCustomerType
     * @return int[]
     */
    public static function fetchAuthorizedApplicationIds( $forAnonmyous = false, $processedUserCustomerType = null )
    {
        if( !$forAnonmyous && !is_null(self::$_authorizedApplications) )
            return self::$_authorizedApplications;
        $db = MMDB::instance();

        $customerType   = null;
        $mainSpeciality = null;

        $whereString = sprintf(
            "     cluster_identifier='%s' 
              AND environment & %d",
            $db->escapeString(ClusterTool::clusterIdentifier()),
            ContextTool::instance()->environment()
        );
        
        $user = $forAnonmyous ? false : MMUsers::getCurrentUserObject();

        if( $user )
        {
            /* @var $user MMUsers */
            $user = MMUsers::getCurrentUserObject();

            $customerType   = $user->attribute('customer_type');
            $mainSpeciality = $user->attribute('main_speciality');

            if( $user->hasAttribute('prefered_language'))
            {
                $language = $user->attribute('prefered_language');

                $whereString.= sprintf(
                    " AND ( language = '%s' OR language IS NULL OR language = '0' )",
                    $db->escapeString($language)
                );
            }

            if( $user->hasAttribute('country'))
            {
                $country = $user->attribute('country');

                $whereString.= sprintf(
                    " AND ( country = '%s' OR country IS NULL OR country = '0' )",
                    $db->escapeString($country)
                );
            }
        }

        if (!$customerType && $processedUserCustomerType) {
            $customerType = $processedUserCustomerType;
        }
        $whereString .= is_null($customerType)
            ? ' AND customer_type IS NULL '
            : sprintf( " AND ( customer_type IS NULL OR customer_type = '0' OR customer_type='%s') ", $db->escapeString($customerType) );
        $whereString .= is_null($mainSpeciality)
            ? ' AND main_speciality IS NULL '
            : sprintf( " AND ( main_speciality IS NULL OR main_speciality = '0' OR main_speciality='%s') ", $db->escapeString($mainSpeciality) );

        $sql = "SELECT *
            FROM mm_country_application_library
            WHERE
            ".$whereString."
            ORDER BY country DESC, language DESC, customer_type DESC, main_speciality DESC";

        $lastProfile    = null;
        $excludedApps   = array();
        $applicationIds = array();

        foreach( $db->arrayQuery($sql) as $row )
        {
            $profile = serialize( array($row['customer_type'], $row['main_speciality']) );
            if( !is_null($lastProfile) && $profile != $lastProfile )
                break;

            $lastProfile = $profile;

            if( $user && $user->hasAttribute('state') && !is_null($user->attribute('state')) && $row['state'] === $user->attribute('state') )
            {
                $excludedApps[] = (int)$row['application_id'];
                continue;
            }

            $applicationIds[] = (int) $row['application_id'];
        }

        if( !empty($excludedApps) )
        {
            foreach ( $applicationIds as $k => $appId )
            {
                if( in_array($appId, $excludedApps ) )
                    unset( $applicationIds[$k] );
            }
            $applicationIds = array_values($applicationIds);
        }
        
        if(SolrSafeOperatorHelper::featureIsActive('LearningNeedsAssessment'))
        {
            $applicationIds[] = ApplicationObject::fetchByIdentifier('learning-needs-assessment')->attribute('id');
        }

        $applicationIds = array_unique( $applicationIds );

        if( !$forAnonmyous )
            self::$_authorizedApplications = $applicationIds;

        return $applicationIds;
    }
コード例 #22
0
    /**
     * @param int $quizId
     * @param int $applicationId
     * @return array
     */
    static function getQuizData( $quizId, $applicationId, $isLocalQuiz = true )
    {
        $quizData = self::fetchOneBy( array( 'quiz_id' => $quizId, 'application_id' => $applicationId ) );
        if( !$quizData )
        {
            // We don't have the quiz meta for the requested quiz, we try to create it (happens only once)
            $object =& eZContentObject::fetch( $quizId );
            if( !$object )
                return null;
            /* @type $dm eZContentObjectAttribute[] */
            $dm = $object->DataMap();
            $mc = $dm['media_content']->content();
            if( isset( $mc['relation_list'][0]['node_id'] ) )
            {
                $quiz =& eZContentObjectTreeNode::fetch( $mc['relation_list'][0]['node_id'] );
                /* @type $quizDM eZContentObjectAttribute[] */
                $quizDM = $quiz->DataMap();
                self::add( $quizId, ClusterTool::clusterIdentifier(), $applicationId, (int)$quizDM['points']->content(), (int)$quizDM['correct_reply']->content() );
                $quizData = self::fetchOneBy( array( 'quiz_id' => $quizId, 'application_id' => $applicationId ) );
            } else {
                return null;
            }
        }
        $currentMMUser = MMUsers::getCurrentUserObject();
        $currentUserResponse = false;
        $nbCorrect     = (int)$quizData->attribute( 'nb_correct' );
        $nbWrong       = (int)$quizData->attribute( 'nb_wrong' );
        if ( $currentMMUser )
        {
            $responseFetchParams = array(
                'quiz_id' => $quizId,
                'uuid' => $currentMMUser->attribute( 'uuid' ),
                'application_id' => $applicationId
            );
            if (!$isLocalQuiz)
            {
                $responseFetchParams['cluster_identifier'] = null;
            }
            $currentUserResponse = QuizReply::fetchOneBy( $responseFetchParams );
        }

        if( $currentUserResponse )
        {
            $currentUserResponded = true;
            $answerWasCorrect = (bool)$currentUserResponse->attribute( 'is_correct' );
        }
        else
        {
            $currentUserResponded = false;
            $answerWasCorrect = false;
        }
        $speRepliesResult = array( 'total' => 0, 'correct' => 0, 'wrong' => 0 );
        $userSpecialtyTranslations = FacetFilteringTool::getTaxoTranslationWithIDs( 'user_specialty' );
        if ( $currentMMUser )
        {
            $userSpecialtyId = $userSpecialtyTranslations[$currentMMUser->attribute( 'user_speciality' )]['id'];
            $speReplies = QuizReply::fetchBySpecialtyInScoring( $currentMMUser->attribute( 'uuid' ), $quizId, $applicationId, $userSpecialtyId );
            if( $speReplies )
            {
                $speRepliesResult['total'] = count( $speReplies );
                foreach( $speReplies as $reply )
                {
                    if( $reply['is_correct'] == 1 )
                        $speRepliesResult['correct']++;
                    else
                        $speRepliesResult['wrong']++;
                }
            }
        }
        $response = array(
            'points'                 => (int)$quizData->attribute( 'points' ),
            'correct_answer'         => (int)$quizData->attribute( 'correct_answer' ),
            'global_answers'         => array( 'total' => ( $nbCorrect + $nbWrong ), 'correct' => $nbCorrect, 'wrong' => $nbWrong ),
            'specialty_answers'      => $speRepliesResult,
            'current_user_responded' => $currentUserResponded,
            'answer_was_correct'     => $answerWasCorrect
        );
        if( $currentUserResponded )
        {
            /* @type $quizArticleDM eZContentObjectAttribute[] */
            $quizArticleDM   = eZContentObject::fetch( $quizId )->DataMap();
            $mediaContent    = $quizArticleDM["media_content"]->content();
            $quizDM          = eZContentObjectTreeNode::fetch( $mediaContent['relation_list'][0]['node_id'] )->DataMap();
            $outputHandler   = new eZXHTMLXMLOutput( $quizDM['commented_answer']->DataText, false );
            $commentedAnswer = $outputHandler->outputText();
            $response['commented_answer'] = $commentedAnswer;
        }
        return $response;
    }
コード例 #23
0
    static public function getTaxonomyTranslationsByCategory($category)
    {
        $clusterIdentifier = ClusterTool::clusterIdentifier();

        $query = "SELECT t.code AS code, tt.label AS label
        FROM mm_taxonomy_translation tt
        JOIN mm_taxonomy t ON t.id = tt.taxonomy_id
        JOIN mm_taxonomy_category tc ON tc.id = t.taxonomy_category_id
        WHERE tc.identifier = '%s' AND tt.cluster_identifier = '%s'";

        $db = MMDB::instance();
        $results = $db->arrayQuery( sprintf($query, $category, $clusterIdentifier ));

        $result = array();

        foreach ($results as $row)
        {
            $result[$row['code']] = $row['label'];
        }

        return $result;
    }
コード例 #24
0
    /**
     * @param string $categoryIdentifier
     * @param string $searchValue
     * @param string $sorts
     * @param int $limit
     * @return array
     */
    static public function fetchReferentialByIdentifierForAutoComplete( $categoryIdentifier, $searchValue, $sorts='asc', $limit=null )
    {
        $category = ReferentialCategory::fetchByIdentifier( $categoryIdentifier );

        if ( $category instanceof ReferentialCategory )
        {
            $db = MMDB::instance();
            $sql = "SELECT DISTINCT label FROM mm_referential_value WHERE cluster_identifier='".ClusterTool::clusterIdentifier()."' AND referential_category_id='".$category->attribute( 'id' )."' AND label LIKE '".$searchValue."%' ORDER BY label ".$sorts." LIMIT ".$limit;
            $query = $db->arrayQuery($sql);

            $result = array();
            foreach ( $query as $value )
            {
                $result[]=$value['label'];
            }          
            return $result;
        }
    }
コード例 #25
0
    /**
     * @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 );
    }
コード例 #26
0
ファイル: seo.php プロジェクト: sushilbshinde/ezpublish-study
<?php

/* @type $Params string[] */

$clusterIdentifier     = ClusterTool::clusterIdentifier();
$page                  = $Params['Page'];
$speciality            = $Params['Speciality'];
$applicationidentifier = $Params['ApplicationIdentifier'];
$result = "";

if ( isset($applicationidentifier) && isset($page) && $page >= 1 && isset($speciality) )
{
    $keywords = Seo::fetchKeywords($applicationidentifier, $speciality, $page);
    $count    = Seo::fetchKeywordsCount($applicationidentifier, $speciality);

    $tpl = eZTemplate::factory();
    $tpl->setVariable('rows', $keywords);
    $tpl->setVariable('count', $count);
    $tpl->setVariable('application_name', $applicationidentifier);
    $tpl->setVariable('speciality', $speciality);
    $tpl->setVariable('page', $page);

    $result = $tpl->fetch('design:esibuild/app_content/seo/keywords_list.tpl');
}

echo $result;

flush();
eZExecution::cleanExit();
コード例 #27
0
    /**
     * i18n operator works like : source|context([argument1, argument2 ...])
     * Arguments are optional and are comma separated
     *
     * @return Callable[]
     *
     * Examples :
     *
     * Simple without argument:
     * {{# i18n }}
     *   MORE|merck()
     * {{/ i18n }}
     *
     * Or with argument:
     * {{# i18n }}
     *   %nb RESULTS|merck(3)
     * {{/ i18n }}
     */
    private static function getHelpers($application = null)
    {
        return array(
            'i18n' => function($text) {
                preg_match("#(?<source>[^\|]+)\|(?<context>[^(]+)\((?<params>[^\)]+)?\)#", $text, $m);
                if($m && $m["source"] && $m["context"])
                {
                    $arguments = array();
                    if($m["params"])
                    {
                        $params = explode(",", $m["params"]);
                        preg_match_all("#(?<arguments>%\w+)#", $m["source"], $mParams);
                        if($mParams && $mParams["arguments"])
                        {
                            for($i = 0; $i < count($mParams["arguments"]); $i++)
                            {
                                $arguments[$mParams["arguments"][$i]] = $params[$i];
                            }
                        }
                    }

                    return ezpI18n::tr($m["context"], $m["source"], null, $arguments);
                }
                return $text;
            },
            'taxonomies_filter' => function($text) use ($application) {
                $filterTaxonomies = $application->getCustomParameter('TaxonomiesFilter');

                $html = '';
                foreach($filterTaxonomies as $category)
                {
                    $taxonomies = FacetFilteringTool::getTaxonomyTranslationsByCategory($category);
                    $tpl = eZTemplate::factory();

                    $tpl->setVariable('taxonomies', $taxonomies);
                    $tpl->setVariable('category', $category);
                    $html .= $tpl->fetch( 'design:esibuild/app_content/channel/filter.tpl' );
                }
                return $html;
            },
            'editors_choice_content' => function($text) use ($application) {
                $taxonomyCategory = $application->getCustomParameter('EditorsChoiceFilter');
                $taxonomyValue = $application->getCustomParameter('EditorsChoiceValue');
                $limit = $application->getCustomParameter('EditorsChoiceLimit');
                $html = '';
                $language = eZINI::instance('site.ini')->variable('RegionalSettings', 'ContentObjectLocale');

                $fields = array(
                    'node_id'              => 'meta_node_id_si',
                    'object_id'            => 'meta_id_si',
                    'language'             => 'meta_language_code_ms',
                    'url'                  => 'attr_'.ClusterTool::clusterIdentifier().'_url_s',
                    'headline'             => 'attr_headline_s',
                    'promo_description'    => 'attr_promo_description_t',
                    'rating'               => 'attr_content_rating_'.ClusterTool::clusterIdentifier().'_f',
                    'views'                => 'attr_view_counter_'.ClusterTool::clusterIdentifier().'_i',
                    'app_identifiers'      => 'subattr_parent_application___identifier____s',
                    'apps'                 => 'subattr_local_application___source_mixed____s',
                    'app_id'               => 'subattr_local_application___source_id____s',
                    'online_date'          => 'attr_online_date_dt',
                    'score'                => 'score',
                    'publisher_path'       => 'subattr_publisher_folder___source_id____s',
                    'has_image'            => 'attr_has_image_'.ClusterTool::clusterIdentifier().'_bst',
                    'media_types'          => 'attr_media_content_types_'.ClusterTool::clusterIdentifier().'_bst',
                    'internal_id'          => 'attr_publisher_internal_id_s',
                    'link_url'             => 'attr_media_content_link_'.ClusterTool::clusterIdentifier().'____ms'
                );
                $filters = array(
                    "subattr_{$taxonomyCategory[0]}___source_id____s: \"{$taxonomyValue[0]}\"",
                    "meta_language_code_ms: \"{$language}\""
                );
                    
                $params = array(
                    'indent'        => 'on',
                    'q'             => '*:*',
                    'fq'            => implode(' AND ' , $filters),
                    'start'         => '0',
                    'rows'          => $limit,
                    'fl'            => implode(',',$fields),
                    'qt'            => 'ezpublish',
                    'explainOther'  => '',
                    'hl.fl'         => '',
                    'sort'          => "attr_online_date_dt desc",
                );
                
                $result = SolrTool::rawSearch($params);
                foreach ($result[response][docs] as $key => $value) {
                    
                    $result[response][docs][$key]['headline'] = $value['attr_headline_s'];
                    $result[response][docs][$key]['node_id'] = $value['meta_node_id_si'];
                    $result[response][docs][$key]['object_id'] = $value['meta_id_si'];
                    $result[response][docs][$key]['language'] = $value['meta_language_code_ms'];
                    $result[response][docs][$key]['promo_description'] = $value['attr_promo_description_t'];
                    
                    $app = CacheApplicationTool::buildLocalizedApplicationByApplication( $value['subattr_local_application___source_id____s'][0] );
                    $applicationObject = $app->applicationObject();
                    $applicationType   = $applicationObject->applicationType()->attribute('type_identifier');
                    $result[response][docs][$key]['application_name'] = $app->attribute('url_alias');
                    
                    $publisherPath = $value['subattr_publisher_folder___source_id____s'][0];
                    $publisher = PublisherFolder::getPublisherFromPath($publisherPath);
                    $publisherFolderId = $publisher->getTranslation()->attribute('publisher_folder_id');
                    $publisherName = $publisher->getTranslation()->attribute('name');
                    $result[response][docs][$key]['publisher_name'] = $publisherName;
                                  
                    $url = $value['attr_'.ClusterTool::clusterIdentifier().'_url_s'];
                    $url = ($applicationType == 'first-child')
                        ? $app->attribute('url_alias')
                        : $app->attribute('url_alias') . '/' . $publisherFolderId . '/' . $url;
                    $result[response][docs][$key]['url'] = $url;
                    $result[response][docs][$key]['online_date'] = solrTool::getDateFromSolr($value['attr_online_date_dt']);
                    $result[response][docs][$key]['publisher_name'] = $publisherName;
                    
                    $result[response][docs][$key]['has_image'] = json_decode( base64_decode($value['attr_has_image_'.ClusterTool::clusterIdentifier().'_bst']), true );
                    $mediaCase = ImageArticleTool::NEWS_APPLICATION_CASE;
                    $hasImage = $result[response][docs][$key]['has_image'][$mediaCase];
                    if ($hasImage) {
                        $result[response][docs][$key]["dt_url"] = SolrSafeOperatorHelper::getImageArticleUrl($mediaCase, $result[response][docs][$key]['object_id'], $result[response][docs][$key]['language'], 'dt_full');
                        $result[response][docs][$key]["mb_url"] = SolrSafeOperatorHelper::getImageArticleUrl($mediaCase, $result[response][docs][$key]['object_id'], $result[response][docs][$key]['language'], 'm_full');
                    }

                }
                
                $tpl = eZTemplate::factory();
                $tpl->setVariable('editorsChoice', $result);
                $html .= $tpl->fetch( 'design:esibuild/app_content/channel/editors_choice.tpl' );
                
                return $html;
            }
        );
    }
コード例 #28
0
 protected function searchInFront()
 {
     $filters = array(
         '(attr_archive_date_dt:"1970-01-01T01:00:00Z" OR attr_archive_date_dt:[NOW TO *])',
         'meta_class_identifier_ms:article',
         'meta_installation_id_ms:' . eZSolr::installationID(),
         'attr_is_invisible_' . ClusterTool::clusterIdentifier() . '_b:false'
     );
     $results = SolrTool::rawSearch( array(
         'indent'       => 'on',
         'q'            => $this->keyword,
         'fq'           => implode( ' AND ', $filters ),
         'start'        => 0,
         'rows'         => 10,
         'fl'           => 'attr_headline_s',
         'qt'           => 'ezpublish',
         'explainOther' => '',
         'hl.fl'        => '',
         'sort'         => "score desc"
     ) );
     if( $results['response']['numFound'] > 0 )
     {
         foreach( $results['response']['docs'] as $doc )
         {
             if( trim( $doc['attr_headline_s'] ) == $this->keyword )
             {
                 $this->article->setAttribute( 'date_front', time() );
                 if( !is_null( $this->article->attribute( 'date_newsletter' ) ) )
                 {
                     $this->article->setAttribute( 'new_relic_report', 1 );
                     $this->reportToNewRelic( $this->newRelicMetricName, 0 );
                 }
                 $this->article->store();
                 break;
             }
         }
     }
 }
コード例 #29
0
<?php

/* @type $Params string[] */

$clusterIdentifier      = isset( $Params['ClusterIdentifier'] ) ? $Params['ClusterIdentifier'] : ClusterTool::clusterIdentifier();
$applicationIdentifier  = $Params['ApplicationIdentifier'];
$staticDir              = StaticData::directory();
$clusterShort           = substr( $clusterIdentifier, 8 );

$filesToCheck = array(
    StaticData::clusterFilePath( $clusterIdentifier, 'apps/' . $applicationIdentifier . '/appstore_cover.jpg' ),
    StaticData::clusterFilePath( $clusterIdentifier, 'apps/' . $applicationIdentifier . '/appstore_cover.png' ),
    'extension/ezoscar/design/oscar/images/' . $clusterShort . '/apps/' . $applicationIdentifier . '/appstore_cover.jpg',
    'extension/ezoscar/design/oscar/images/' . $clusterShort . '/apps/' . $applicationIdentifier . '/appstore_cover.png',
    'extension/ezoscar/design/oscar/images/common/apps/' . $applicationIdentifier . '/appstore_cover.jpg',
    'extension/ezoscar/design/oscar/images/common/apps/' . $applicationIdentifier . '/appstore_cover.png'
);

foreach ( $filesToCheck as $file )
{
    if ( file_exists( $file ) )
    {
        $image = file_get_contents( $file );
        $fileUtils = eZClusterFileHandler::instance( $file );
        $fileUtils->storeContents( $image );
        header( 'Content-Type: image/jpg' );
        header( 'Content-Length: ' . $fileUtils->size() );
        $fileUtils->passthrough();
        eZExecution::cleanExit();
    }
}
コード例 #30
0
                        $displayConsents = false;
                    }
                }
            }
        }
    }
    // To be updated to be manageable via Back Office feature
    $isConsentOptOut = in_array( ClusterTool::clusterIdentifier(), array() );

    $displayToUPPAndOptInsBlockTitle = in_array( ClusterTool::clusterIdentifier(), array( 'cluster_france' ) );
    
    $visitorCountry = SolrSafeOperatorHelper::getLocaleBySystemCode( 'ga_visitor_country' );
    if( $visitorCountry == 'not provided' || !isset($visitorCountry) || is_null($visitorCountry) || empty($visitorCountry)){
        
        $dt = new DateTime("Europe/Warsaw");
        $msg = 'Missing ga_visitor_country for '.ClusterTool::clusterIdentifier().' at '.$dt->format('Y-m-d H:i:s');
        ezLog::write($msg, 'toupp_visitor_country.log');
    }

    echo json_encode( array(
        'userProfile'      => $userProfile,
        'displayConsents'  => $displayConsents,
        'useDedicatedPage' => (ContextTool::instance()->isMobile() ? SolrSafeOperatorHelper::feature( 'ToUPPPopin', 'useDedicatedPageMobile' ) : SolrSafeOperatorHelper::feature( 'ToUPPPopin', 'useDedicatedPage' )),
        'visitorCountry'   => SolrSafeOperatorHelper::getLocaleBySystemCode( 'ga_visitor_country' ),
        'staticPages'      => array(
            'ToU' => is_null( $touPage ) ? null : $touPage->attribute( 'core_content' ),
            'PP'  => is_null( $ppPage ) ? null : $ppPage->attribute( 'core_content' )
        ),
        'features'         => array(
            'currentToUConsentVersion'        => $currentToUConsentVersion,
            'currentPPConsentVersion'         => $currentPPConsentVersion,