/** * @see eZContentObjectEditHandler::publish() * @param int $contentObjectID * @param eZContentObjectVersion $contentObjectVersion */ function publish( $contentObjectID, $contentObjectVersion ) { $contentObject = eZContentObject::fetch( $contentObjectID ); if( $contentObject instanceof eZContentObject ) { switch($contentObject->ClassIdentifier) { case 'article': { ObjectVisibilityManager::updateGlobalLimitation($contentObject); /* @type $mainNode eZContentObjectTreeNode */ /* @type $clustersToHide array */ $db = eZDB::instance(); $mainNode = $contentObject->mainNode(); $clustersToHide = eZINI::instance( 'merck.ini' )->variable( 'PublishSettings', 'clustersToHide' ); $publisherNodeId = PublisherFolderTool::getPublisherNodeIdFromArticleNode($mainNode); $publisherInfo = PublisherFolderTool::getNodeIdToPathMapping($publisherNodeId); $publisherClusters = PublisherFolderTool::getClustersFromPath($publisherInfo['path']); $inserted = false; foreach( $clustersToHide as $clusterToHide ) { if( in_array($clusterToHide, $publisherClusters) ) { if ( !$inserted ) { $db->query( sprintf( "INSERT INTO ezpending_actions (action, created, param) VALUES ('check_node_visibility', %d, '%s' )", time(), $contentObject->mainNodeID() )); $inserted = true; } ObjectVisibilityManager::updateClusterLimitation($contentObjectID, $clusterToHide, true); } } } break; } } }
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 string $sectionRemote * @param int|eZContentObjectTreeNode $chapterNode * @param int|eZContentObjectTreeNode $topicNode * @param string $linkType * @return array */ public static function fetchUnifiedUrl( $sectionRemote, $chapterNode, $topicNode, $linkType ) { $error = false; if ( !in_array($linkType, array('section', 'chapter', 'topic')) ) { $error = true; } else { if ( is_numeric($chapterNode) && $chapterNode ) $chapterNode = eZContentObjectTreeNode::fetch($chapterNode); if ( is_numeric($topicNode) && $topicNode ) $topicNode = eZContentObjectTreeNode::fetch($topicNode); switch ( true ) { case ( $topicNode instanceof eZContentObjectTreeNode ): $chapterNode = $topicNode->fetchParent(); case ( $chapterNode instanceof eZContentObjectTreeNode ): if ( !$sectionRemote ) { /* @type $chapterDM eZContentObjectAttribute[] */ $chapterDM = $chapterNode->dataMap(); if ( isset($chapterDM['serialized_taxonomies']) ) { $chapterSerial = $chapterDM['serialized_taxonomies']->content(); if ( isset($chapterSerial['section']) && count($chapterSerial['section']) > 0 ) $sectionRemote = $chapterSerial['section'][0]; } } case ( $sectionRemote != "" ): $sectionUrl = false; $section = self::fetchSection('remote', $sectionRemote); if ( $section['result'] ) { $sectionUrl = '/' . $section['result']['url']; } else { $error = true; } break; default: $error = true; break; } } if ( !$error ) { /* @type $sectionUrl string */ $applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByIdentifier(MerckManualShowcase::mainApplicationIdentifier()); $publisherFolderNodeId = MerckManualShowcase::rootNodeId(); $publisherFolderNode = eZContentObjectTreeNode::fetch($publisherFolderNodeId); $publisherFolderInfo = PublisherFolderTool::getNodeIdToPathMapping( $publisherFolderNodeId ); $publisherFolderId = $publisherFolderInfo['pfid']; // Link in about page $AboutChapterNodeID = MerckManualAbout::rootNodeId(); if ( $topicNode && in_array($AboutChapterNodeID, $topicNode->pathArray()) ) { $topicUrl = end(explode('/', $topicNode->attribute('url_alias'))); return array('result' => CacheApplicationTool::buildLocalizedApplicationByIdentifier(MerckManualAbout::mainApplicationIdentifier())->url . '/' . $topicUrl); } $url = null; $applicationObject = $applicationLocalized->applicationObject(); $forceExternalLink = $applicationObject->hasExternalLinkHandler(); switch ( $linkType ) { case 'topic': if ( !( $topicNode instanceof eZContentObjectTreeNode ) ) { $error = true; break; } $urlParts = explode('/', $topicNode->attribute('url_alias')); $urlParts = array_slice($urlParts, $publisherFolderNode->attribute('depth') - $topicNode->attribute('depth')); $url = $applicationLocalized->applicationUrl($forceExternalLink) . '/' . $publisherFolderId . $sectionUrl . '/' . implode('/', $urlParts); break; case 'chapter': if ( !( $chapterNode instanceof eZContentObjectTreeNode ) ) { $error = true; break; } $urlParts = explode('/', $chapterNode->attribute('url_alias')); $urlParts = array_slice($urlParts, $publisherFolderNode->attribute('depth') - $chapterNode->attribute('depth')); $url = $applicationLocalized->applicationUrl( $forceExternalLink ) . '/' . $publisherFolderId . $sectionUrl . '/' . implode('/', $urlParts); break; case 'section': $url = $applicationLocalized->applicationUrl() . '/' . $publisherFolderId . $sectionUrl; break; default: $url = ''; $error = true; break; } } return array('result' => !$error ? $url : null); }
/** * @param PublisherFolder $publisherFolder * @return int */ public static function getPublisherFolderNodeId ( $publisherFolder ) { $mapping = PublisherFolderTool::getNodeIdToPathMapping(); foreach( $mapping as $nodeId => $info ) { if ( $publisherFolder->attribute('path') == $info['path'] ) return $nodeId; } return false; }