/** * Switches automatically between a node and solrdata * * @param eZContentObjectTreeNode|string[] $node * @return string */ static function getApplicationName($node) { if ( $node instanceof eZContentObjectTreeNode ) return NodeTool::getApplicationFromNode($node); elseif ( is_array($node) && isset($node['app_identifiers'][0]) ) return $node['app_identifiers'][0]; else return ''; }
/** * @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; }
public function contentBuildResult() { $oldSkipPage = SolrSafeOperatorHelper::getCustomParameter($this->applicationObject->identifier, 'SkipExitPage', 'application'); $skipPage = $oldSkipPage || !$this->exitStrategy(); $this->pushResult('user' , self::user()); $this->pushResult('country', LocaleTool::countryISO3166Code()); if ( $skipPage ) { $_REQUEST['proceed'] = 'proceed'; $_COOKIE[$this->cookieKey()] = '1'; if ( ContextTool::instance()->isMobile() ) $_REQUEST['r'] = 1; } if( isset($_REQUEST['proceed']) && isset($_COOKIE[$this->cookieKey()]) && filter_var($_COOKIE[$this->cookieKey()], FILTER_VALIDATE_INT)) { // proceed to iframe view $this->iframeBuildResult( ); } elseif( isset($_REQUEST['proceed']) ) { // proceed requested but no cookie, we ask again and force redirect to make sure we the proper layout header('Location: '.ContextTool::instance()->domain().$this->applicationLocalized()->applicationUrl()); eZExecution::cleanExit(); } else { // normal exit page vie $isMobile = ContextTool::instance()->isMobile(); $urlToRedirect = isset($_REQUEST['r']) ? trim($_REQUEST['r']) : null; if ($this->isExitApplication() && $this->displayIframe()) { $serverUrl = ContextTool::instance()->domain(); $params = array( 'r' => urlencode($urlToRedirect), 'exit_strategy' => 0, 'display_iframe' => $this->displayIframe(), 'new_window' => $this->newWindow() ); $urlToRedirect = $serverUrl . '/external/exit/?' . http_build_query($params); $this->pushResult('decode_url', false); $this->pushResult('server_url', $serverUrl); } if($isMobile){ if($this->applicationObject()->externalLinkHandler()) { $externalUrl = $this->applicationObject()->externalLinkHandler()->getNodeUrl( $this->node ); $urlToRedirect = isset($externalUrl) ? $externalUrl : $urlToRedirect ; if(SolrSafeOperatorHelper::getCustomParameter($this->applicationObject->identifier, 'usePostMethod', 'application' )){ $url = $this->applicationObject()->externalLinkHandler()->getNodeUrl( $this->node ); $url = $this->getDeeplink( $url ); if ($url == null && isset($_REQUEST['r'])) { $url = urldecode($_REQUEST['r']); } $url = in_array('arg', array_keys($this->_params['UserParameters'])) ? $url . $this->_params['UserParameters']['arg'] : $url; $this->pushResult('postParams', $url); } } else { $urlToRedirect = '/bad_config'; } } $this->pushResult('back_url', ContextTool::instance()->backUrl()); $this->pushResult('url', $urlToRedirect); $this->pushResult('deeplink', urlencode( $this->getDeeplink() )); // Because we are passing boolean parameters to final URL, we need to make isset check. if ( $this->isDeeplinkApplication() || $this->isExitApplication() ) { if ( isset( $_GET['display_iframe'] ) ) { $this->pushResult('display_iframe', $this->displayIframe()); } if ( isset( $_GET['new_window'] ) ) { $this->pushResult('new_window', $this->newWindow()); } if ( isset( $_GET['exit_strategy'] ) ) { $this->pushResult('exit_strategy', $this->exitStrategy()); } } } if($this->node && $this->node->attribute('url_alias') != "") { $this->pushResult('article_url', end(explode("/", $this->node->attribute('url_alias')))); /* @type $pfDM eZContentObjectAttribute[] */ $pf = NodeTool::getPublisherNodeFromNode( $this->node ); $pfDM = $pf->DataMap(); $pfID = PublisherFolderTool::getPathToIDMapping( $pfDM['path']->content() ); $this->pushResult( 'pfid', $pfID['pfid'] . '/' ); } $oldOpenInNewWindow = SolrSafeOperatorHelper::getCustomParameter($this->applicationObject()->identifier, 'openInNewWindow', 'application'); $openInNewWindow = $this->newWindow() || $oldOpenInNewWindow; $this->pushResult('application', $this->applicationObject); $this->pushResult('open_in_new_window', $openInNewWindow); $this->pushResult('cookie_key', $this->cookieKey()); $this->pushResult('node', $this->node); if( SolrSafeOperatorHelper::featureIsActive( 'GoogleAnalytics' ) ) { $this->pushResult( 'gtm_variables', $this->getGTMTags( $this->node ) ); if( $this->node ) { $publisherNodeId = PublisherFolderTool::getPublisherNodeIdFromArticleNode($this->node); if ($publisherNodeId) { $publisherInfos = PublisherFolderTool::getNodeIdToPathMapping( $publisherNodeId ); $publisherPath = $publisherInfos['path']; $this->pushResult( 'publisher', $this->applicationLocalized()->getPublisherFolderFromPath( $publisherPath ) ); } } } }
/** * @param eZContentObjectTreeNode $node * @return string */ public static function getApplicationIdentifierFromNode ( $node ) { return NodeTool::getApplicationFromNode($node); }
/** * @param $courseId * @return array */ protected static function fetchNodeAndAppFromCourseId( $courseId ) { $nodeList = eZFunctionHandler::execute( 'content', 'tree', array( 'parent_node_id' => 2, 'attribute_filter' => array( array( 'article/publisher_internal_id', '=', $courseId ) ), 'class_filter_type' => 'include', 'class_filter_array' => array( 'article' ), 'main_node_only' => false, ) ); foreach ( $nodeList as $node ) { $application = NodeTool::getApplicationFromNode($node); if ( $application ) { $isCertificate = SolrSafeOperatorHelper::getCustomParameter( $application, 'HasCertificates', 'application' ); if ( $isCertificate ) { eZContentObject::clearCache(); return array( 'application' => $application, 'node' => $node, ); } } } eZContentObject::clearCache(); return false; }
$articleContentObject = $relatedArticles[0]; } else { if( $pdfContentObject->reverseRelatedObjectCount( false, false ) > 0 ) { $reverseRelatedObjectlist = $pdfContentObject->reverseRelatedObjectList( false, false ); $articleContentObject = $reverseRelatedObjectlist[0]; } } if( $articleContentObject instanceof eZContentObject ) { /* @type $articleNode eZContentObjectTreeNode */ $articleNode = $articleContentObject->mainNode(); $application = NodeTool::getApplicationFromNode($articleNode); $publisherFolderInfo = PublisherFolderTool::getPublisherFolderPathFromArticleNode($articleNode, true); $publisherFolderPath = $publisherFolderInfo['path']; $publisherFolderTranslation = PublisherFolderTool::getPublisherFolderTranslationFromPublisherFolder($publisherFolderInfo['pfid']); if( isset($publisherFolderTranslation['name']) ) { $publisherFolderTranslatioName = $publisherFolderTranslation['name']; } $articleObjecId = $articleContentObject->ID; } } //Insert into tracking table MMTrackingPdf::addTrack($clusterIdentifier, $userId, $application, $pdfId, $articleObjecId, $date, $publisherFolderPath, $publisherFolderTranslatioName); } }
/** * @param ApplicationDefault $contentApp * @return array */ private function oldPromoPage( $contentApp ) { $promoLoginUri = eZINI::instance()->variable('SiteSettings', 'PromoLoginPage'); $promoLoginPath = preg_replace('#^https?://[^/]+/#', '/', $promoLoginUri); if( (bool)self::user() && !self::user()->toUValidated() && $this->iniMerck()->hasVariable( 'LoginSettings', 'ToUCheck' ) && $this->iniMerck()->variable( 'LoginSettings', 'ToUCheck') != 'disabled' ){ $promoLoginUri = eZINI::instance()->variable('SiteSettings', 'ToUAgreementPage'); $promoLoginPath = preg_replace('#^https?://[^/]+/#', '/', $promoLoginUri); } $patterns = array( '#^(?:https?://[^/]+)?/esibuild/main_view/app_content#', '#\?key=[^&]+#' ); $context = ContextTool::instance()->domain().preg_replace($patterns, array( '', '' ), $_SERVER['REQUEST_URI'] ); // for externals, we need to redirect to the promologin page if( !isset($_GET['key'] ) && $this->applicationObject()->hasExternalLinkHandler() ) { $context = preg_replace( '#^(https?://[^/]+/)#', '\1external/', $context ); header( 'Location: '.ContextTool::instance()->domain().$promoLoginUri.'?context='.urlencode($context) ); eZExecution::cleanExit(); } if(strpos($promoLoginPath, '/page') !== 0) $promoLoginPath = '/page'.$promoLoginPath; $app = ApplicationFactory::fetchByUri( $promoLoginPath ); if( empty( $app->node ) ) { if( in_array( ContextTool::instance()->environment(), array(ContextTool::ENVIRONMENT_PROD, ContextTool::ENVIRONMENT_STAGING) ) ) { openlog( 'Missing Promo page', LOG_PID, LOG_LOCAL6 ); syslog( LOG_CRIT, 'Error message' ); closelog(); } else { $out = 'Promo page can not be loaded for the cluster: '.ClusterTool::clusterIdentifier(); eZDebug::writeError( $out, 'Missing Promo page' ); } } $app->buildResult(); $app->pushResult('context', urlencode( $context )); $this->tpl()->setVariable('staticnode', $contentApp->node); if( SolrSafeOperatorHelper::featureIsActive( 'GoogleAnalytics' ) ) { $this->tpl()->setVariable( 'gtm_variables', $this->getGTMTags( $contentApp->node ) ); if( $contentApp->node ) { $publisherNode = NodeTool::getPublisherNodeFromNode($contentApp->node); if ($publisherNode) { /* @type eZContentObjectAttribute[] $publisherDM */ $publisherDM = $publisherNode->dataMap(); $publisherPath = $publisherDM['path']->content(); $this->tpl()->setVariable( 'publisher', $this->applicationLocalized()->getPublisherFolderFromPath( $publisherPath ) ); } } } return $app->getHtmlResult(); }
/** * @param $node eZContentObjectTreeNode * @return bool */ public static function getFileApplicationCanRead(&$node) { $relatedObjects = $node->object()->reverseRelatedObjectList(false, eZContentObjectTreeNode::classAttributeIDByIdentifier('download_ressource') ); try { if(count($relatedObjects) == 0) throw new Exception('No article related to this object'); /** @var eZContentObject $articleObject */ /** @var eZContentObjectTreeNode $articleNode */ $articleObject = $relatedObjects[0]; $articleNode = $articleObject->mainNode(); $applicationIdentifier = NodeTool::getApplicationFromNode($articleNode); /** @var ApplicationDefault $application */ $application = ApplicationFactory::fetchByUri($applicationIdentifier); if(!$application->canRead()) { throw new Exception('Can\'t read'); } return true; } catch (Exception $e) { return false; } }
/** * @param int $courseId * @return array */ static protected function fetchNodeAndAppFromCourseId( $courseId ) { $nodeList = eZFunctionHandler::execute( 'content', 'tree', array( 'parent_node_id' => 2, 'attribute_filter' => array( array( 'article/publisher_internal_id', '=', $courseId ) ), 'class_filter_type' => 'include', 'class_filter_array' => array( 'article' ), 'main_node_only' => false, ) ); foreach( array_keys($nodeList) as $key ) { $node = $nodeList[$key]; $application = NodeTool::getApplicationFromNode ( $node ); if( $application ) { eZContentObject::clearCache(); return array( 'application' => $application, 'node' => $node, ); } unset($nodeList[$key]); eZContentObject::clearCache(); } eZContentObject::clearCache(); return false; }