/** * @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' ); }
/** * @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; }
function processOptions($options) { if ($options['clusterIdentifier'] == null) { throw new Exception("No clusters given. Should pass argument clusterIdentifier with value 'all' if all clusters are requested"); } $allClusters = ClusterTool::getAllClusters(); if ($options['clusterIdentifier'] == 'all') { $clusters = $allClusters; } else { $clusters = explode(',', $options['clusterIdentifier']); $clusters = array_filter($clusters, function($v) use ($allClusters) { return in_array($v, $allClusters); }); } $exclude = isset($options['exclude']) ? filter_var($options['exclude'], FILTER_VALIDATE_BOOLEAN) : false; if ($exclude) { $clusters = array_diff($allClusters, $clusters); } $parsedOptions = array( 'clusters' => $clusters, 'exclude' => $exclude, ); return $parsedOptions; }
/** * 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' ); }
/** * @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 ) ); }
function parseOptions(array $options) { $parsedOptions = array(); $parsedOptions['clusterIdentifier'] = isset($options['clusterIdentifier']) ? explode(',', $options['clusterIdentifier']) : ClusterTool::globCluster(); $parsedOptions['path'] = isset($options['path']) ? $options['path'] : DEFAULT_BANNER_PATH; $parsedOptions['convertPath'] = isset($options['convertPath']) ? $options['convertPath'] : eZINI::instance('image.ini')->variable('ImageMagick', 'ExecutablePath'); return $parsedOptions; }
/** * @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'] ) . "¶ms=" . urlencode( $encryptedParams ); return $redirectURL; } }
/** * @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; }
/** * @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; }
/** * @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' ); }
function parseOptions(array $options) { $parsedOptions = array(); $existingClusters = ClusterTool::globCluster(); if (empty($options['clusterIdentifier'])) { $parsedOptions['clusters'] = $existingClusters; } else { $clusterList = explode(',', $options['clusterIdentifier']); $clusterList = array_intersect($clusterList, $existingClusters); $parsedOptions['clusters'] = $clusterList; } return $parsedOptions; }
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); }
/** * @param int $applicationTypeId * @return ApplicationTemplate */ public static function getApplicationTemplate( $applicationTypeId ) { $conditionList = ClusterTool::clusterOverride( array('application_type_id' => $applicationTypeId ) ); foreach ( $conditionList as $condition ) { $applicationTemplate = self::fetchObject( self::definition(), null, $condition ); if ( $applicationTemplate instanceof self ) { return $applicationTemplate; } } return null; }
/** * @param int $applicationId * @return ApplicationStaticConfiguration */ static public function getStaticConfiguration( $applicationId ) { $conditionList = ClusterTool::clusterOverride( array('application_id' => $applicationId) ); foreach ( $conditionList as $condition ) { $staticConfiguration = self::fetchObject( self::definition(), null, $condition ); if ( $staticConfiguration instanceof self ) { return $staticConfiguration; } } return null; }
/** * @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; }
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'], ); }
/** * @param int $applicationId * @return ExternalLinkHandler */ public static function getExternalConfiguration( $applicationId ) { $conditionList = ClusterTool::clusterOverride( array('application_id' => $applicationId) ); foreach ( $conditionList as $condition ) { $externalConfiguration = self::fetchObject( self::definition(), null, $condition ); if ( $externalConfiguration instanceof self ) { $externalConfiguration->buildExternalLinkHandler(); return $externalConfiguration; } } return null; }
/** * @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; }
/** * @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; } }
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 ) ); }
/** * @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; }
/** * @param string $text * @return string */ public function generateAndSaveImage( $text = null ) { if ( is_null( $text ) ) { ClusterTool::setCurrentCluster( $this->clusterIdentifier ); $text = ezpI18n::tr( $this->context, $this->source ); } $temp_file = sys_get_temp_dir() . "/misc" . uniqid() . '.png'; $convertExecutablePath = eZINI::instance( 'image.ini' )->variable( 'ImageMagick', 'ExecutablePath' ); $convertExecutable = eZINI::instance( 'image.ini' )->variable( 'ImageMagick', 'Executable' ); $cmd = "-background transparent -fill lightgray -font './extension/ezoscar/design/oscar/font/arial.ttf' -pointsize 11 label:{$text}"; exec( "$convertExecutablePath/$convertExecutable $cmd $temp_file" ); $imageFile = file_get_contents( $temp_file ); $this->fileUtils->storeContents( $imageFile ); unlink( $temp_file ); return $imageFile; }
/** * @return array[] */ static function getMapping() { if ( !empty($_mapping) ) { return self::$_mapping; } $mapping = CacheTool::dailyValue('userSpeMapping'); if ( $mapping === false || is_null($mapping) ) { $conditionList = ClusterTool::clusterOverride( array( 'is_available' => '1' ) ); foreach ($conditionList as $condition) { $mapping = self::fetchObjectList(self::definition(), null, $condition, false); if ( is_array($mapping) && count($mapping) > 0 ) { break; } } $mapping = self::flattenMapping($mapping); self::$_mapping = $mapping; CacheTool::dailyValue('userSpeMapping', $mapping); } else { self::$_mapping = $mapping; } return $mapping; }
<?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(); } }
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; }
/** * 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; } ); }
/** * @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; } }
/** * @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 ); }
/** * @param string$clusterIdentifier * @param bool $backupExisting * @param bool $includeTimestamp * @return array * @throws Exception */ public function generateSpriteForCluster($clusterIdentifier, $backupExisting = true, $includeTimestamp = true) { $outputFile = $this->buildFilePath($this->outputPath, array($clusterIdentifier)); $timestampOutputFile = $this->generateFileName($outputFile, $includeTimestamp); $generatedSpriteName = substr($timestampOutputFile, strrpos($timestampOutputFile, '/') + 1); ClusterTool::setCurrentCluster( $clusterIdentifier ); $lessPath = "extension/{$clusterIdentifier}/design/oscar/stylesheets/"; $icoSprite = "/ico_sprite.png"; $offsetStep = 95; $crop = $offsetStep * 2; $mobileStep = 83; $spriteConvertOptions = " -crop x{$crop}+0+0 "; $globalConvertOptions = " -append -quality 80%"; $applicationList = CacheApplicationTool::clusterApplications(); $cssList = array(); $icoList = array(); foreach( $applicationList as $application ) { $icoCss = 'ico_'.SolrSafeOperatorHelper::getAppIdentifierForIcon( $application->applicationObject->identifier ); $icoFile = StaticData::clusterFilePath( $clusterIdentifier, 'apps/'.$application->applicationObject->identifier.$icoSprite, true, true ); if ( ! file_exists( $icoFile ) ) { $icoFile = StaticData::clusterFilePath( 'default', 'apps/'.$application->applicationObject->identifier.$icoSprite, true, true ); } if ( file_exists( $icoFile ) && ! in_array( $icoCss, $cssList ) ) { $cssList[] = $icoCss; $icoList[] = $icoFile; } } if (empty($icoList)) { throw new \Exception("No icons found for cluster {$clusterIdentifier}", 0); } if ($backupExisting && file_exists($outputFile)) { rename($outputFile, $outputFile . '.bak'); } $convertBinPath = $this->convertBinPath; $cmd = 'export PATH=$PATH:' . $convertBinPath . '; convert ' . implode( $spriteConvertOptions, $icoList ) . "{$spriteConvertOptions} {$globalConvertOptions} {$outputFile}"; $cmdStatus = 0; $cmdOutput = array(); exec($cmd, $cmdOutput, $cmdStatus); if ($cmdStatus != 0) { return array( 'errorCode' => $cmdStatus, 'generateSpriteCommand' => $cmd, 'error' => implode('\n', $cmdOutput), ); } $css = " #app-catalog a.app-bar-access-app-library .poster{ background-image: none !important; } #app-catalog a .poster, #hide-app a .poster, .item-apps .batch .wrap > a .poster, .item-related-app .batch .wrap > a .poster{ background-image:url(/esibuild/static/{$clusterIdentifier}/{$generatedSpriteName}); background-repeat: no-repeat; } "; $cssMobile = " #app-catalog a.app-bar-access-app-library .poster{ background-image: none !important; } #app-catalog a .poster, #hide-app a .poster, .item-apps .batch .wrap > a .poster, .item-related-app .batch .wrap > a .poster{ background-image:url(/esibuild/static/{$clusterIdentifier}/{$generatedSpriteName}); background-repeat: no-repeat; background-size: {$mobileStep}px auto !important; } "; $offset = 0; $offsetMobile = 0; foreach( $cssList as $key => $cssStyle ) { $css .= " #app-catalog a .poster.$cssStyle, #hide-app a .poster.$cssStyle, .item-apps .batch .wrap > a .poster.$cssStyle, .item-related-app .batch .wrap > a .poster.$cssStyle{ background-position: 0 -{$offset}px !important; } "; $cssMobile .= " #app-catalog a .poster.$cssStyle, #hide-app a .poster.$cssStyle, .item-apps .batch .wrap > a .poster.$cssStyle{ background-position: 0 -{$offsetMobile}px !important; } "; $offset += $offsetStep; $offsetMobile += $mobileStep; $css .= " #app-catalog a:hover .poster.$cssStyle, #app-catalog a:active .poster.$cssStyle, #app-catalog a.active .poster.$cssStyle, #hide-app a:active .poster.$cssStyle, #hide-app a.active .poster.$cssStyle, .item-apps .batch:hover .wrap > a .poster.$cssStyle, .item-related-app .batch:hover .wrap > a .poster.$cssStyle{ background-position: 0 -{$offset}px !important; } "; $cssMobile .= " #app-catalog a:hover .poster.$cssStyle, #app-catalog a:active .poster.$cssStyle, #app-catalog a.active .poster.$cssStyle, #hide-app a:active .poster.$cssStyle, #hide-app a.active .poster.$cssStyle, .item-apps .batch:hover .wrap > a .poster.$cssStyle, .item-related-app .batch:hover .wrap > a .poster.$cssStyle{ background-position: 0 -{$offsetMobile}px !important; } "; $offset += $offsetStep; $offsetMobile += $mobileStep; } if ( ! file_exists( $lessPath ) ) { mkdir( $lessPath, 0755 ); } if ( is_dir( $lessPath ) ) { $lessFile = $lessPath."mod.icosprite.less"; file_put_contents( $lessFile, $css ); $lessFileMobile = $lessPath."mod.icosprite.mobile.less"; file_put_contents( $lessFileMobile, $cssMobile ); eZCache::clearByID( array('ezjscore-packer'), 'template-block' ); } return array( 'errorCode' => 0, 'generateSpriteCommand' => $cmd ); }