コード例 #1
0
 function install( $package, $installType, $parameters,
                   $name, $os, $filename, $subdirectory,
                   $content, &$installParameters,
                   &$installData )
 {
     $collectionName = $parameters['collection'];
     $installVariables = array();
     if ( isset( $installParameters['variables'] ) )
         $installVariables = $installParameters['variables'];
     $iniFileVariables = false;
     if ( isset( $installParameters['ini'] ) )
         $iniFileVariables = $installParameters['ini'];
     $fileList = $package->fileList( $collectionName );
     if ( $fileList )
     {
         foreach ( $fileList as $fileItem )
         {
             $newFilePath = false;
             if ( $fileItem['type'] == 'thumbnail' )
             {
             }
             else
             {
                 $filePath = $package->fileItemPath( $fileItem, $collectionName );
                 if ( is_dir( $filePath ) )
                 {
                     $newFilePath = $package->fileStorePath( $fileItem, $collectionName, $installParameters['path'], $installVariables );
                     eZDir::mkdir( $newFilePath, false, true );
                 }
                 else
                 {
                     $newFilePath = $package->fileStorePath( $fileItem, $collectionName, $installParameters['path'], $installVariables );
                     if ( preg_match( "#^(.+)/[^/]+$#", $newFilePath, $matches ) )
                     {
                         eZDir::mkdir( $matches[1], false, true );
                     }
                     eZFileHandler::copy( $filePath, $newFilePath );
                 }
             }
             if ( $fileItem['type'] == 'ini' and $iniFileVariables and $newFilePath )
             {
                 $fileRole = $fileItem['role'];
                 $fileRoleValue = $fileItem['role-value'];
                 $fileVariableName = $fileItem['variable-name'];
                 $fileName = $fileItem['name'];
                 if ( $fileVariableName and
                      isset( $installParameters['variables'][$fileVariableName] ) )
                     $fileRoleValue = $installParameters['variables'][$fileVariableName];
                 if ( isset( $iniFileVariables[$fileRole][$fileRoleValue][$fileName] ) )
                 {
                     $variables = $iniFileVariables[$fileRole][$fileRoleValue][$fileName];
                     $ini = eZINI::fetchFromFile( $newFilePath );
                     $ini->setVariables( $variables );
                     $ini->save( false, false, false, false, false );
                 }
             }
         }
     }
     return true;
 }
コード例 #2
0
    protected function getFeedLanguage($clusterIdentifier)
    {
        $clusterSiteIni = eZINI::fetchFromFile( "extension/{$clusterIdentifier}/settings/site.ini.append.php" );
        $clusterLanguages = $clusterSiteIni->variable( 'RegionalSettings', 'SiteLanguageList' );
        $clusterLanguage = $clusterLanguages[0];

        return $clusterLanguage;
    }
コード例 #3
0
 /**
  * Tries to load an ini value, including the settings from this extension even when it is not active.
  * Note: when not active, the settings of this extensions are loaded with lower precedence compared to same settings
  * from other extensions.
  *
  * @param string $fileName
  * @param string $blockName
  * @param string $varName
  * @param int $type
  * @return array|mixed|null
  */
 static function getIniValue($fileName, $blockName, $varName, $type = self::TYPE_SCALAR)
 {
     if ($type == self::TYPE_SCALAR) {
         $value = null;
     } else {
         $value = array();
     }
     $ini = eZINI::instance($fileName);
     if (in_array('ggsysinfo', eZExtension::activeExtensions())) {
         return $ini->hasVariable($blockName, $varName) ? $ini->variable($blockName, $varName) : $value;
     } else {
         // load still what possible values are added from other extensions
         $value = $ini->hasVariable($blockName, $varName) ? $ini->variable($blockName, $varName) : $value;
         $ini = eZINI::fetchFromFile(__DIR__ . '/../settings/sysinfo.ini');
         if ($type == self::TYPE_SCALAR) {
             return array_merge($value, $ini->variable($blockName, $varName));
         } else {
             if ($value !== null) {
                 return $value;
             }
             return $ini->variable($blockName, $varName);
         }
     }
 }
コード例 #4
0
    /**
     * @see ezfSolrDocumentFieldBase::getData()
     * @return array
     */
    public function getData()
    {
        $data           = parent::getData();
        $content        = $this->ContentObjectAttribute->content();
        
        /* @var $content array */
        foreach ( array_merge( self::taxonomyAttribute(), array_keys($content) ) as $taxonomyIdentifier )
        {
            $taxonomyValues              = isset( $content[$taxonomyIdentifier] ) ? $content[$taxonomyIdentifier] : array(); 
            $subattrSourceIdValues       = array();
            $subattrSourceIdFieldName    = self::getCustomSubattributeFieldName(
                                                $taxonomyIdentifier,
                                                'source_id');
            
            foreach ( $taxonomyValues as $taxonomyValue )
            {
                if( preg_match( '#^symptom_.*$#', $taxonomyValue ) )
                {
                    $sourceKey                  = $taxonomyValue;
                    $subattrSourceIdValues[]    = $sourceKey;
                    
                    // we need a few more things for the symptoms
                    /* @type $node eZContentObjectTreeNode */
                    $contentObject = $this->ContentObjectAttribute->object();
                    $node          = $contentObject->mainNode();
                    $clusters      = NodeTool::getArticleClusters($node);

                    foreach( $clusters as $cluster )
                    {
                        ClusterTool::setCurrentCluster($cluster);

                        $ini = eZINI::fetchFromFile('extension/'.$cluster.'/settings/site.ini');
                        $node->setCurrentLanguage( $ini->variable('RegionalSettings', 'ContentObjectLocale') );

                        $applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByIdentifier( MerckManualShowcase::mainApplicationIdentifier() );
                        if ( !$applicationLocalized )
                            continue;

                        $customSymptomAttributeKey = 'attr_custom_symptom_'.$cluster.'_s';
                        $labelTranslations         = FacetFilteringTool::getTaxonomyTranslation( 'symptom' );
                        $label                     = $labelTranslations[$sourceKey];
                        $url                       = preg_replace( '#^[^/]+#', '', MerckManualFunctionCollection::getMerckManualNodeUrl( 'meck-manual-showcase', $node, $ini->variable('RegionalSettings', 'ContentObjectLocale') ) );

                        ClusterTool::resetCurrentCluster();

                        $customSymptomAttributeValueParts = array(
                            mb_strtolower(mb_substr(StringTool::removeAccents( StringTool::CJK2Pinyin($label) ), 0, 1)),
                            $label,
                            $url
                        );

                        $data[$customSymptomAttributeKey] = implode( '##', $customSymptomAttributeValueParts );
                    }
                }
                else if ( preg_match('#^222\.[0-9]+$#', $taxonomyValue ) )
                {
                    $sourceKey                  = $taxonomyValue;
                    $subattrSourceIdValues[]    = $sourceKey;

                    /* @type $node eZContentObjectTreeNode */
                    /* @type $dataMap eZContentObjectAttribute[] */
                    $contentObject                    = $this->ContentObjectAttribute->object();
                    $node                             = $contentObject->mainNode();
                    $clusters                         = NodeTool::getArticleClusters($node);
                    $customSymptomAttributeValueParts = array(
                        $content['layer_natom'][0],
                        $content['sub_layer_natom'][0],
                    );

                    foreach( $clusters as $cluster )
                    {
                        ClusterTool::setCurrentCluster($cluster);

                        $customSymptomAttributeKey        = 'attr_custom_layer_sublayer_natom_'.$cluster.'_s';
                        $data[$customSymptomAttributeKey] = implode( '##', $customSymptomAttributeValueParts );

                        ClusterTool::resetCurrentCluster();
                    }
                }
                else
                    $subattrSourceIdValues[] = trim( $taxonomyValue );
            }

            $data[$subattrSourceIdFieldName] = empty($subattrSourceIdValues) ? '' : $subattrSourceIdValues;
        }
        
        return $data;
    }
コード例 #5
0
    public function domain( $in = null )
    {
        if ( is_null( $in ) )
            return $this->_domain;

        if ( !isset($this->domains[$in]) )
            throw new \InvalidArgumentException( "No existing cluster give: ".$in );

        $this->_domain = $in;
        $this->_cluster = $this->domains[$in];

        \ClusterTool::setCurrentCluster( $this->_cluster );
        $this->_clusterMerckIni = \eZINI::fetchFromFile( 'extension/'.$this->_cluster.'/settings/merck.ini.append.php' );
        $this->_clusterSiteIni = \eZINI::fetchFromFile( 'extension/'.$this->_cluster.'/settings/site.ini.append.php' );
    }
コード例 #6
0
    /**
     * @return array
     */
    public function getResponseSolr()
    {
        $applicationDictionaryRows = $this->prepareConfig();

        $forbiddenWords = NodeVisibilityCheck::getForbiddenWordsArray( $this->_cluster_identifier );
        $queryTerm = count($forbiddenWords) ? implode(' ', $forbiddenWords) : '*:*';

        foreach ( $applicationDictionaryRows as $applicationDictionaryRow )
        {
            // Get application node_id
            $applicationId = $applicationDictionaryRow['application_id'];

            /** @var ApplicationLocalized[] $_localApplication */
            $this->_localApplications[$applicationId] = CacheApplicationTool::buildLocalizedApplicationByApplication( $applicationId );

            $appLocalizedIsProper = ( $this->_localApplications[$applicationId] instanceof ApplicationLocalized );

            if ( !$appLocalizedIsProper )
            {
                eZDebug::writeError( sprintf( 'Cannot fetch localized application %s for cluster %s', $applicationId, $this->_cluster_identifier ), __FILE__ . '::' . __LINE__ );
                continue;
            }

            /* @type $validLanguages array */
            $newsletterStyle = $applicationDictionaryRow['newsletter_style'];
            $clusterSiteIni  = eZINI::fetchFromFile( "extension/{$this->_cluster_identifier}/settings/site.ini.append.php" );
            $validLanguages  = $clusterSiteIni->variable( 'RegionalSettings', 'SiteLanguageList' );

            // Common
            $fq = array(
                'meta_class_identifier_ms:"article"',
                '(attr_archive_date_dt:"1970-01-01T01:00:00Z" OR attr_archive_date_dt:[NOW TO *])',
                'meta_installation_id_ms:'.eZSolr::installationID(),
                'attr_is_invisible_' . $this->_cluster_identifier . '_b:false',
                'meta_language_code_ms:(' . implode( ' OR ', $validLanguages ) . ')',
            );
            
            $taxonomyList = json_decode( $applicationDictionaryRow['taxonomy_filter'], true );

            if(count($taxonomyList) > 0){
                foreach ($taxonomyList as $row) {
                    foreach($row as $taxonomyCategory => $taxonomies){
                        $taxonomies = array_map(function($value) { return '"' . $value . '"'; }, $taxonomies);
                        $fq[] = "subattr_{$taxonomyCategory}___source_id____s: (" . implode(',', $taxonomies) . ')';
                    }
                }
            }

            // NO SDK
            $publisherNodeIds = $this->_localApplications[$applicationId]->publisherNodeIds();
            if(count($publisherNodeIds) == 1 )
            {
                $newsletterStyle = $applicationDictionaryRow['newsletter_style'];

                $fq = array_merge($fq, array(
                    'meta_path_si:' . $publisherNodeIds[0],
                ));
            }
            elseif (count($publisherNodeIds) > 1 )
            {
                $publisherFilter = implode(' OR ', $publisherNodeIds);
                $newsletterStyle = $applicationDictionaryRow['newsletter_style'];

                $fq = array_merge($fq, array(
                        "meta_path_si:($publisherFilter)",
                    ));
            }
            /**
             * SDK Specific treatment; dead code for now
             *
                if ( $this->_localApplications[$applicationId] instanceof SDKApplication )
                {
                    // SDK application
                    $fq = array_merge($fq, array(
                        'subattr_local_application___source_id____s:' . $applicationId,
                        'is_sdk_b:true AND is_newsletter_b:true'
                    ));
                }
             *
             */

            // Solr query parameters
            $rows = 100000;
            $queryParams = array(
                'indent' => 'on',
                'q' => $queryTerm,
                'start' => 0,
                'rows' => $rows,
                'fq' => $fq,
                'fl' => array(
                    'attr_has_image_' . $this->_cluster_identifier . '_bst',
                    'meta_remote_id_ms',
                    'meta_node_id_si',
                    'meta_main_node_id_si',
                    'attr_featured_content_b',
                    'attr_date_dt',
                    'meta_path_string_ms',
                    'meta_language_code_ms',
                    'attr_view_counter_' . $this->_cluster_identifier . '_i',
                    'subattr_speciality___source_id____s',
                    'subattr_customer_type___source_id____s',
                    'meta_current_version_si',
                    'attr_promo_description_t',
                    'attr_author_t',
                    'attr_source_t',
                    'attr_online_date_dt',
                    'attr_headline_s',
                    'subattr_publisher_folder___source_id____s',
                    'attr_promo_headline_s',
                    'attr_'.$this->_cluster_identifier.'_remote_s',
                    'attr_'.$this->_cluster_identifier.'_node_remote_s',
                    //'attr_media_content_image_'.$this->_cluster_identifier.'____ms',
                    //'attr_promo_image_'.$this->_cluster_identifier.'_s',
                    'is_sdk_b',
                    'meta_url_alias_ms',
                    'attr_promo_headline_t',
                    'subattr_publisher_folder___source_id____s',
                    'meta_id_si',
                    'attr_media_content_types_' . ClusterTool::clusterIdentifier() . '_bst',
                    'attr_' . ClusterTool::clusterIdentifier() . '_url_s',
                    'attr_core_content_t',
                    'subattr_download_ressource___expiration_date____dt',
                    'attr_node_remote_s',
                    'attr_media_content_quiz_replies_' . $this->_cluster_identifier . '____ms',
                    'attr_media_content_quiz_points_' . $this->_cluster_identifier . '_i',
                    'attr_media_content_quiz_question_' . $this->_cluster_identifier . '_ms',
                ),
                'qt' => '',
                'explainOther' => '',
                'hl.fl' => '',
                'sort' => $this->_configuration['sort']
            );
            $publisherFilters = $this->_localApplications[$applicationId]->getPublishersFilter();
            if ( $publisherFilters )
            {
                $queryParams['fq'][] = $publisherFilters;
            }

            if ( !empty($this->_customerType) )
            {
                $customerTypeCondition = implode(',', $this->stringArrayToFilterQueryParam($this->_customerType));
                $queryParams['fq'][] = sprintf( 'subattr_customer_type___source_id____s:(%s)', $customerTypeCondition );
            }
            if ( !empty($this->_specialty) )
            {
                $specialtyCondition = implode(',', $this->stringArrayToFilterQueryParam($this->_specialty));
                $queryParams['fq'][] = sprintf( 'subattr_speciality___source_id____s:(%s)', $specialtyCondition );
            }
            if ( $applicationDictionaryRow["publisher"] )
            {
                $queryParams['fq'][] = sprintf( 'subattr_publisher_folder___source_id____s:(%s)', $applicationDictionaryRow["publisher"] );
            }

            if ( $newsletterStyle == 'PICL' )
            {
                $queryParams['fq'][] = 'subattr_media_type___source_id____s:107.2';
            }

            //taxonomies
            $taxonomies = $this->getApplicationTaxonomies($applicationDictionaryRow['feed_id']);
            $firstCategory = reset(array_keys($taxonomies));
            $queryTaxonomies = '';
            foreach($taxonomies as $categorie=>$taxonomie)
            {
                if($categorie != $firstCategory)
                {
                    $queryTaxonomies .= ' AND ';
                }
                $queryTaxonomies .= 'subattr_' . $categorie . '___source_id____s:(' . $taxonomie . ')';
            }

            if($queryTaxonomies != '')
            {
                $queryParams['fq'][] = $queryTaxonomies;
            }

            $queryParamsFqFallback = $queryParams['fq'];
            $rowValueKey           = '';

            // different sort and filters by mechanism
            switch ($applicationDictionaryRow["mechanism"]) {
                case 1:
                    $rowValueKey = 'number_article_list';
                    $queryParams['sort'] = implode( ', ', $queryParams['sort'] );

                    //if begin/end date is set
                    if(!empty($this->_beginDate) && !empty($this->_endDate))
                    {
                        $queryParams['fq'][] = 'attr_online_date_dt:[' . $this->_beginDate . ' TO ' . $this->_endDate . ']';
                    }
                    else
                    {
                        $queryParams['fq'][] = sprintf( 'attr_online_date_dt:[NOW-%sDAY TO *]', $this->_configuration['days'] );
                    }
                    break;
                case 2:
                    $rowValueKey = 'number_article_random';
                    $oneHourRandom = floor(time() / 3600);
                    $queryParams['sort'] = 'attr_' . $oneHourRandom . '_random asc';
                    break;
                case 4:
                    $rowValueKey = 'number_article_last_x';
                    $queryParams['sort'] = "attr_online_date_dt desc";
                    $queryParams['fq'][] = 'attr_online_date_dt:[NOW-7DAY TO *]';

                    //if begin/end date is set
                    if(!empty($this->_beginDate) && !empty($this->_endDate))
                    {
                        $queryParams['fq'][] = 'attr_online_date_dt:[' . $this->_beginDate . ' TO ' . $this->_endDate . ']';
                    }
                    else
                    {
                        $queryParams['fq'][] = sprintf( 'attr_online_date_dt:[NOW-%sDAY TO *]', $this->_configuration['days'] );
                    }
                    break;
                case 5:
                    $rowValueKey = 'number_article_list';
                    if(!empty($this->_beginDate) && !empty($this->_endDate))
                    {
                        $queryParams['fq'][] = 'attr_online_date_dt:[' . $this->_beginDate . ' TO ' . $this->_endDate . ']';
                    }
                    $queryParams['sort'] = implode( ', ', $queryParams['sort'] );
                    if( $applicationDictionaryRow['number_article_ns'] )
                    {  
                        $queryParams['rows'] = (int)$applicationDictionaryRow['number_article_ns'];
                    }
                    else
                    {
                         $queryParams['rows'] = 100;
                    }
                    break;
            }

            if ( (int) $applicationDictionaryRow[$rowValueKey] >= 0 )
            {
                $queryParams['rows'] = (int) $applicationDictionaryRow[$rowValueKey];
            }

            $queryParams['fl'] = implode( ',', $queryParams['fl'] );
            $queryParams['fq'] = implode( ' AND ', $queryParams['fq'] );

            // main fetch solr
            $result = SolrTool::rawSearch( $queryParams, 'php', false );
            if ( !isset( $result['response']['docs'] ) )
            {
                eZDebug::writeError( 'Error from Solr for query : ' . $result['params']['fq'], __FILE__ . '::' . __LINE__ );
                if( php_sapi_name() != 'cli' )
                {
                    header( 'HTTP/1.x 500 Internal Server Error' );
                    eZExecution::cleanExit();
                }
            }
            if ( count($result['response']['docs']) == 0 && $applicationDictionaryRow['mechanism'] == 5)
            {
                $queryParams['fq'] = $queryParamsFqFallback;
                $queryParams['sort'] = array(
                    'attr_featured_content_b desc',
                    'attr_online_date_dt desc',
                );

                $queryParams['sort'] = implode( ', ', $queryParams['sort'] );

                //if begin/end date is set
                if(!empty($this->_beginDate) && !empty($this->_endDate))
                {
                    $queryParams['fq'][] = 'attr_online_date_dt:[' . $this->_beginDate . ' TO ' . $this->_endDate . ']';
                }
                $queryParams['fq'] = implode( ' AND ', $queryParams['fq'] );
                $result = SolrTool::rawSearch( $queryParams, 'php', false );
            }

            // if no result fallback for mechanism 3
            if ( count( $result['response']['docs'] ) == 0 && $applicationDictionaryRow["mechanism"] == 3 )
            {
                $queryParams['fq'] = $queryParamsFqFallback;
                $queryParams['fq'] = implode( ' AND ', $queryParams['fq'] );
                if ( (int) $applicationDictionaryRow['number_article_random'] >= 0 )
                {
                    $queryParams['rows'] = (int) $applicationDictionaryRow['number_article_random'];
                }
                else
                {
                    $queryParams['rows'] = $rows;
                }
                $oneHourRandom = floor(time() / 3600);
                $queryParams['sort'] = 'attr_' . $oneHourRandom . '_random asc';

                $result = SolrTool::rawSearch( $queryParams, 'php', false );
                if ( !isset( $result['response']['docs'] ) )
                {
                    eZDebug::writeError( 'Error from Solr for query : ' . $result['params']['fq'], __FILE__ . '::' . __LINE__ );
                    if( php_sapi_name() != 'cli' )
                    {
                        header( 'HTTP/1.x 500 Internal Server Error' );
                        eZExecution::cleanExit();
                    }
                }
            }

            $articles = $result['response']['docs'];

            // if mechanism 4, we need to have articles also from previous week
            if($applicationDictionaryRow["mechanism"] == 4)
            {
                $queryParams['fq'] = $queryParamsFqFallback;
                $queryParams['fq'][] = 'attr_online_date_dt:[NOW-14DAY TO NOW-7DAY]';
                $oneHourRandom = floor(time());
                $queryParams['sort'] = 'attr_' . $oneHourRandom . '_random asc';

                $queryParams['fq'] = implode( ' AND ', $queryParams['fq'] );
                $queryParams['rows'] = (int) $applicationDictionaryRow['number_article_random_y'];

                $resultRandom = SolrTool::rawSearch( $queryParams, 'php', false );
                if ( !isset( $resultRandom['response']['docs'] ) )
                {
                    eZDebug::writeError( 'Error from Solr for query : ' . $result['params']['fq'], __FILE__ . '::' . __LINE__ );
                    if( php_sapi_name() != 'cli' )
                    {
                        header( 'HTTP/1.x 500 Internal Server Error' );
                        eZExecution::cleanExit();
                    }
                }

                if(count($resultRandom['response']['docs'])) {
                    $articles = array_merge($articles, $resultRandom['response']['docs']);
                }
            }

            $this->_applicationsData[$applicationId][] = array(
                'articles'                    => $articles,
                'applicationDictionaryRow'    => $applicationDictionaryRow
            );
        }

        return $this->_applicationsData;
    }
コード例 #7
0
 /**
  * return all news objects since the date
  *
  * @param $date
  * @return mixed
  */
 private function getLastObjects($date)
 {
     $locales = array('eng-');
     foreach( glob('extension/cluster_*/settings/site.ini*') as $f )
     {
         $ini = eZINI::fetchFromFile( $f );
         foreach( $ini->variable('RegionalSettings', 'SiteLanguageList') as $locale )
         {
             if( !in_array(substr($locale, 0, 4), $locales) )
                 $locales[] = substr($locale, 0, 4);
         }
     }
     
     $filters = array(
         "meta_modified_dt:[$date TO NOW]",
         '('.implode(' OR ', SolrTool::solrLanguageFilter($locales)).')',
         'meta_class_identifier_ms:article',
         'meta_installation_id_ms:'.eZSolr::installationID()
     );
     
     $locale = 'eng';
     
     $continue = true;
     $offset = 0;
     while($continue)
     {
         $params = array(
             'indent'        => 'on',
             'start'         => $offset,
             'rows'          => 2000,
             'q'             => '',
             'fq'            => implode( ' AND ', $filters ),
             'fl'            => 'meta_id_si, meta_name_t, meta_modified_dt',
             'qt'            => 'ezpublish',
             'explainOther'  => '',
             'hl.fl'         => '',
             'sort'          => 'meta_modified_dt asc'
         );
 
         $raw        = SolrTool::rawSearch($params, 'php', false);
         
         $continue = count($raw['response']['docs']);
         $offset += 2000;
         
         foreach($raw['response']['docs'] as $result)
         {
             fputcsv( $this->csvFile(), array($result['meta_id_si'], str_replace( array("\n", "\r"), array(' ', ''), $result['meta_name_t'] )) );
             if(!isset($lastDate) || $result['meta_modified_dt'] > $lastDate)
             {
                 $lastDate = $result['meta_modified_dt'];
             }
         }
     }
     
     // security overlap to to avoid delayed indexing gap
     $overlap = eZINI::instance('merck.ini')->variable( 'AnalyticsExportSettings', 'LastDateOverlap' );
     $d = gmdate( 'Y-m-d\TH:i:s\Z', strtotime( $lastDate ) - $overlap );
     $this->saveNewLastDate($d);
     
     return $raw['response']['numFound'];
 }
コード例 #8
0
$nlTypes = array( 'news', 'education' );
if ( !in_array($nlType, $nlTypes) )
{
    $nlTypeAnswer = $cli->askQuestion( "Which newsletter type?", $nlTypes );
    $nlType = $nlTypes[$nlTypeAnswer];
}

$nlFrequencies = array( 'daily', 'weekly', 'monthly' );
if ( !in_array($nlFrequency, $nlFrequencies) )
{
    $nlFrequencyAnswer = $cli->askQuestion( "Which frequency", $nlFrequencies );
    $nlFrequency = $nlFrequencies[$nlFrequencyAnswer];
}

$ini = eZINI::fetchFromFile( "extension/$clusterIdentifier/settings/site.ini.append.php" );
$language = $ini->variable( 'RegionalSettings', 'ContentObjectLocale' );

$grepResults = array();
foreach ( array(
    'zgrep "/newsletter/rss/%s/%%28nlt%%29/%s/%%28frq%%29/%s" /home/site/logs/access.log.2.gz | grep "%s"',
    'zgrep "/newsletter/rss/%s/%%28nlt%%29/%s/%%28frq%%29/%s" /home/site/logs/access.log.1.gz | grep "%s"',
    'grep "/newsletter/rss/%s/%%28nlt%%29/%s/%%28frq%%29/%s" /home/site/logs/access.log | grep "%s"'
) as $pattern )
{
    $cmd = sprintf(
        $pattern,
        $language,
        $nlType,
        $nlFrequency,
        $domain
コード例 #9
0
ファイル: ezcopy.php プロジェクト: heliopsis/eZCopy
 function iniInstance($file, $basePath = false)
 {
     if (!$basePath) {
         $basePath = $this->getNewDistroPathName();
     }
     set_include_path(get_include_path() . PATH_SEPARATOR . $basePath);
     // include files in new distro for parsing ini files
     include_once $basePath . '/lib/ezutils/classes/ezdebug.php';
     include_once $basePath . '/lib/ezutils/classes/ezsys.php';
     include_once $basePath . '/lib/ezfile/classes/ezdir.php';
     include_once $basePath . '/lib/ezfile/classes/ezfile.php';
     include_once $basePath . '/lib/ezutils/classes/ezini.php';
     // initate INI files
     $useTextCodec = false;
     $ini = eZINI::fetchFromFile($basePath . $file, $useTextCodec);
     return $ini;
 }
コード例 #10
0
    /**
     * @param eZContentObjectTreenode $node
     * @param array $row
     * @return array
     */
    protected static function nodeHasForbiddenWords( &$node, &$row )
    {
        /* @type $clustersToHide array */
        $clustersToHide = eZINI::instance( 'merck.ini' )->variable( 'PublishSettings', 'clustersToHide' );
        $returnArray    = array();
        
        foreach ($clustersToHide as $cluster)
        {
            /* @type $languageList array */
            $clusterIni = eZINI::fetchFromFile( "./extension/$cluster/settings/site.ini" );
            $languageList = $clusterIni->variable('RegionalSettings', 'SiteLanguageList');
        
            foreach( $languageList as $locale )
            {
                /* @type $nodeDatamap eZContentObjectAttribute[] */
                $nodeDatamap = $node->object()->fetchDataMap(false, $locale);

                if( !$nodeDatamap )
                    continue;

                if( $nodeDatamap['forbidden_article']->attribute('data_int') == 1 )
                {
                    // node is marked from publisher as containing some forbidden words = we hide
                    $returnArray[$cluster] = array(
                        'toHide'   => true,
                        'toDelete' => true,
                        'comment'  => 'marked by publisher',
                    );
                    break;
                }
                
                $forbiddenWordsArray = self::getForbiddenWordsArray($cluster);

                if(empty($forbiddenWordsArray))
                {
                    $returnArray[$cluster] = array(
                        'toHide'   => false,
                        'toDelete' => true,
                        'comment'  => 'no forbidden words on cluster',
                    );
                    continue;
                }

                $lgExplode      = explode('-', $locale);
                $languageFilter = $lgExplode[0] . '-*';

                $params = array(
                            'indent'   => 'on',
                            'qt'       => 'standard',
                            'q'        => '*:*',
                            'start'    => 0,
                            'stop'     => 0,
                            'fq'       => implode(' AND ', array(
                                'meta_node_id_si:'.$node->attribute('node_id'),
                                'meta_language_code_ms:'.$languageFilter,
                                'meta_installation_id_ms:'.eZSolr::installationID()
                    )),
                );

                $isInSolrResult = SolrTool::rawSearch($params, 'php', false);

                if( !$isInSolrResult['response']['numFound'] )
                {
                    // the node is not in solr. We postpone its check
                    if( $row['created'] < time() - 3600 * 4 )
                    {
                        // the node was added more than 4 hours ago. It should be in solr. We ask for a reindex
                        eZSearch::addObject( $node->object() );

                        $returnArray[$cluster] = array(    
                            'toHide'   => true,
                            'toDelete' => false,
                            'comment'  => 'not indexed in solr yet',
                        );
                        break;
                    }

                    if( $row['created'] < time() - 3600 * 48 )
                    {
                        eZLog::write( sprintf( "%s\t Node %s still not in solr after 48h", date('Y-m-d H:i:s'), $node->attribute('node_id') ), 'updatevisibility.log' );
                        $returnArray[$cluster] = array(
                            'toHide'   => true,
                            'toDelete' => true,
                            'comment'  => 'node is taking too long to be indexed',
                        );
                        break;
                    }
                }

                $params['q'] = implode(' ', $forbiddenWordsArray);
                $solrResults = SolrTool::rawSearch($params, 'php', false);

                if( !$solrResults['response']['numFound'] )
                {
                    // content has forbidden words => we hide
                    $returnArray[$cluster] = array(
                        'toHide'   => true,
                        'toDelete' => true,
                        'comment'  => 'has forbidden words',
                    );
                    break;
                }            
            }

            if ( !isset($returnArray[$cluster]) )
            {
                $returnArray[$cluster] = array(
                    'toHide'   => false,
                    'toDelete' => true,
                    'comment'  => 'default case'
                );
            }
        }
        
        return $returnArray;
    }
コード例 #11
0
$script->startup();
$script->initialize();

$options = parseOptions($options);
$clusters = $options['clusters'];

if (empty($clusters))
{
    $script->shutdown(1, 'No clusters found');
}
foreach($clusters as $cluster)
{
    $cli->output("Generating translations for cluster {$cluster}");

    $iniFile = "extension/{$cluster}/settings/site.ini";
    $ini = eZINI::fetchFromFile($iniFile);
    $locale = $ini->variable( 'RegionalSettings', 'Locale' );
    if ( !$locale )
    {
        $cli->output("No locale value in site.ini for cluster {$cluster}");
        continue;
    }

    $jsOutputPath = "extension/{$cluster}/design/oscar/javascript/com.lang.js";
    $converter = new ConvertTsToJSON($jsOutputPath, null, $locale);
    $converter->process();
}

$script->shutdown();

コード例 #12
0
    public function render(array $localApplications, array $data, $clusterIdentifier, array $options = array())
    {
        $domainsInClusters = eZINI::instance( 'merck.ini' )->variable( 'DomainMappingSettings', 'ClusterDomains' );
        $domain = $domainsInClusters[$clusterIdentifier];

        $xml = new DOMDocument( '1.0', 'utf-8' );
        $rss = $xml->createElement( 'rss' );
        $rss->setAttribute( 'version', '2.0' );

        $clusterSiteIni = eZINI::fetchFromFile( "extension/{$clusterIdentifier}/settings/site.ini.append.php" );
        $clusterLanguages = $clusterSiteIni->variable( 'RegionalSettings', 'SiteLanguageList' );
        $clusterLanguage = $clusterLanguages[0];

        $rss->appendChild( $xml->createElement( 'language', $clusterLanguage ) );
        $channel = $xml->createElement( 'channel' );

        foreach ( $data as $applicationId => $appFeed )
        {
            foreach( $appFeed as $appArticles)
            {
                $docs = $appArticles['articles'];

                $linkToOverview = false;
                if (SolrSafeOperatorHelper::featureIsActive('newsletterConfig'))
                {
                    $appsLinkedToOverview = SolrSafeOperatorHelper::feature('newsletterConfig', 'applicationsLinkedToOverview');
                    $applicationIdentifier = $localApplications[$applicationId]->attribute('application_object')->attribute('identifier');
                    $linkToOverview = in_array($applicationIdentifier, $appsLinkedToOverview);
                }
                foreach ( $docs as $doc )
                {
                    $publisherPath = $doc['subattr_publisher_folder___source_id____s'][0];
                    $publisherId   = PublisherFolderTool::getPathToIDMapping($publisherPath);
                    $item = $xml->createElement( 'item' );
                    $item->appendChild( $xml->createElement( 'appid', $applicationId ) );

                    $specialities = $xml->createElement( 'specialties', implode( ',', $doc['subattr_speciality___source_id____s'] ) );
                    $item->appendChild( $specialities );

                    $customertypes = $xml->createElement( 'customertypes', implode( ',', $doc['subattr_customer_type___source_id____s'] ) );
                    $item->appendChild( $customertypes );

                    // Title
                    $xmlTitle = $this->escapeStr( $doc['attr_headline_s']);
                    $isEmptyHeadline = trim($doc['attr_promo_headline_t']) == "";

                    if($clusterIdentifier == 'cluster_pt' && !$isEmptyHeadline){
                        $xmlTitle = $this->escapeStr( $doc['attr_promo_headline_t']);
                    }
                    $title = self::createCDATAElement($xml, 'title', $xmlTitle) ;
                    $item->appendChild($title);

                    // Promo headline
                    $promoHeadline = self::createCDATAElement($xml, 'short_title', $doc['attr_promo_headline_t'] );
                    $item->appendChild( $promoHeadline );

                    // Link
                    $merckIni = eZINI::instance( 'merck.ini' );
                    $urlAdditionalValues = $merckIni->variable( 'RssUrlSettings', 'AdditionalValues' );


                    $urlApplication = $localApplications[$applicationId]->attribute('url_alias');
                    if(isset($doc["is_sdk_b"]) && $doc["is_sdk_b"])
                    {
                        $url = $urlApplication . '/' . $doc['meta_url_alias_ms'][0];
                    }
                    else
                    {
                        $url = $urlApplication . '/' . $publisherId['pfid'] . '/' . $doc['attr_' . $clusterIdentifier . '_url_s'];
                    }

                    if ( $linkToOverview )
                    {
                        $linkUrl = 'http://' . rtrim($domain, '/') . $urlApplication;
                        $link = $xml->createElement( 'link', $linkUrl );
                    }
                    else if ( isset( $urlAdditionalValues[$clusterIdentifier] ) )
                    {
                        $linkUrl = 'http://' . rtrim($domain, '/') . '/' . $urlAdditionalValues[$clusterIdentifier] . $url;
                        $link = $xml->createElement( 'link', $linkUrl  );
                    }
                    else
                    {
                        $linkUrl = 'http://' . rtrim($domain, '/') . $url;
                        $link = $xml->createElement( 'link', urlencode( $linkUrl ) );
                    }


                    $item->appendChild( $link );

                    // Author
                    $author = $xml->createElement( 'author', $doc["attr_author_t"] );
                    $item->appendChild( $author );

                    // Source
                    $text = false;
                    $publisherPath = $doc["subattr_publisher_folder___source_id____s"];
                    if($publisherPath && isset($publisherPath[0]))
                    {
                        /** @var PublisherFolder $publisher */
                        $publisher = PublisherFolder::getPublisherFromPath($publisherPath[0]);
                        if( $publisher && $publisher->getTranslation() )
                        {
                            $text = $publisher->getTranslation()->attribute( 'name' );
                        }
                    }
                    $source = $xml->createElement( 'source', $this->escapeStr( htmlspecialchars($text) ) );
                    $item->appendChild( $source );

                    // Description
                    $text = $this->escapeStr( $doc['attr_promo_description_t'] );
                    $text = ( empty( $text ) ? $this->escapeStr( $doc['attr_core_content_t'] ) : $text );

                    $description = self::createCDATAElement( $xml, 'description', $this->escapeStr( $text ) );
                    $item->appendChild( $description );

                    // Publishdate
                    $onlineDate = DateTime::createFromFormat("Y-m-d\TH:i:s\Z", $doc["attr_online_date_dt"])->format('Y-m-d H:i:s');
                    $date = $xml->createElement( 'publishdate', $onlineDate );
                    $item->appendChild( $date );

                    //creationDate
                    $creationDate = DateTime::createFromFormat("Y-m-d\TH:i:s\Z", $doc["attr_date_dt"])->format('Y-m-d H:i:s');
                    $creationDate = $xml->createElement( 'creationdate', $creationDate );
                    $item->appendChild( $creationDate );

                    $mediaContentTypes = json_decode(base64_decode($doc['attr_media_content_types_' . ClusterTool::clusterIdentifier() . '_bst']), true);
                    $hasImageArray = json_decode(base64_decode($doc['attr_has_image_' . $clusterIdentifier . '_bst']));

                    $images = array();
                    if ( $hasPromoImage = SolrSafeOperatorHelper::hasImageArticleFromSolr( array('has_image' => $hasImageArray), 2 ) )
                    {
                        $path = SolrSafeOperatorHelper::getImageArticleUrl(2,$doc['meta_id_si'], $doc['meta_language_code_ms'], 'dt_full');
                        $url = 'http://' . rtrim($domain, '/') . $path;
                        $images[] = $url;
                        $hasPromoImage = 2;
                    }

                    //media_content
                    if( !$hasPromoImage && (isset($mediaContentTypes['image']) || isset($mediaContentTypes['slide'])) )
                    {
                        $slideCount = isset($mediaContentTypes['image']) ? 1 : $mediaContentTypes['slide'];
                        $slideCount = $slideCount > 3 ? 3 : $slideCount;

                        if ( SolrSafeOperatorHelper::hasImageArticleFromSolr( array ( 'has_image' => $hasImageArray ), 0 ) )
                        {
                            for( $i=0; $i<$slideCount; $i++ )
                            {
                                $path = SolrSafeOperatorHelper::getImageArticleUrl(0,$doc['meta_id_si'], $doc['meta_language_code_ms'], 'dt_full', $imageNumber);
                                $url = 'http://' . rtrim($domain, '/') . $path;
                                $images[] = $url;
                            }
                        }
                    }
                    for( $i=0; $i < 3; $i++ )
                    {
                        $imageNumber = ( $i + 1 );
                        if ( $i >= count($images) )
                        {
                            $url = '';
                        }
                        else
                        {
                            $url = $images[$i];
                        }
                        $imageElement = $xml->createElement( 'image' . $imageNumber, $url );
                        $item->appendChild( $imageElement );
                    }

                    // Top
                    $item->appendChild( $xml->createElement( 'top', $doc['attr_featured_content_b'] == '1' ? 1 : 0 ) );

                    // Readcounter
                    $count = 0;
                    if ( isset( $doc['attr_view_counter_' . $clusterIdentifier . '_i'] ) )
                        $count = $doc['attr_view_counter_' . $clusterIdentifier . '_i'];
                    $item->appendChild( $xml->createElement( 'readcounter', $count ) );
                    
                    // Quizreplies
                    $quizReplies = $doc['attr_media_content_quiz_replies_' . $clusterIdentifier . '____ms'];
                    if( isset($quizReplies) && count($quizReplies) > 0 )
                    {
                        $repliesElement = $xml->createElement( 'quizreplies' );
                        for($i = 0; $i < count($quizReplies); $i++)
                        {
                            $repliesElement->appendChild( $xml->createElement( 'quizreply'.$i, $quizReplies[$i] ) );
                        }
                        $item->appendChild( $repliesElement );
                    }

                    $channel->appendChild( $item );

                    eZContentObject::clearCache();
                }
            }
        }

        $rss->appendChild( $channel );
        $xml->appendChild( $rss );

        $xml->formatOutput = true;

        return $xml->saveXML();
    }