function modify($tpl, $operatorName, $operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters)
 {
     switch ($operatorName) {
         case 'metadata':
             if (isset($namedParameters['node_id'])) {
                 $node = eZContentObjectTreeNode::fetch($namedParameters['node_id']);
                 if ($node instanceof eZContentObjectTreeNode) {
                     $operatorValue = xrowMetaDataFunctions::fetchByObject($node->attribute('object'));
                 } else {
                     $operatorValue = false;
                 }
             } else {
                 $operatorValue = false;
             }
             break;
     }
 }
Exemplo n.º 2
0
         $prio = 1;
     } else {
         $prio = null;
     }
     $url = $rootNode->attribute('url_alias');
     eZURI::transformURI($url, true, 'full');
     $sitemap->add($url, $modified, null, $prio);
 }
 if (isset($bar)) {
     $bar->advance();
 }
 // Adding tree
 foreach ($nodeArray as $subTreeNode) {
     eZContentLanguage::expireCache();
     $object = $subTreeNode->object();
     $meta = xrowMetaDataFunctions::fetchByObject($object);
     $modified = $subTreeNode->attribute('modified_subnode');
     if ($meta and $meta->googlemap != '0') {
         $url = $subTreeNode->attribute('url_alias');
         eZURI::transformURI($url, true, 'full');
         $sitemap->add($url, $modified, $meta->change, $meta->priority);
     } elseif ($meta === false) {
         $url = $subTreeNode->attribute('url_alias');
         eZURI::transformURI($url, true, 'full');
         if ($addPrio) {
             $rootDepth = $rootNode->attribute('depth');
             $prio = 1 - ($subTreeNode->attribute('depth') - $rootDepth) / 10;
             if ($prio <= 0) {
                 $prio = null;
             }
         } else {
 public static function createMFSitemap()
 {
     eZDebug::writeDebug("Generating Standard Sitemap with images ...", __METHOD__);
     $cli = $GLOBALS['cli'];
     global $cli, $isQuiet;
     if (!$isQuiet) {
         $cli->output("Generating Sitemap for Siteaccess " . $GLOBALS['eZCurrentAccess']['name'] . " \n");
     }
     $ini = eZINI::instance('site.ini');
     $googlesitemapsINI = eZINI::instance('xrowsitemap.ini');
     // Get the Sitemap's root node
     $contentINI = eZINI::instance('content.ini');
     $rootNode = eZContentObjectTreeNode::fetch($contentINI->variable('NodeSettings', 'RootNode'));
     if (!$rootNode instanceof eZContentObjectTreeNode) {
         $cli->output("Invalid RootNode for Siteaccess " . $GLOBALS['eZCurrentAccess']['name'] . " \n");
         continue;
     }
     // Settings variables
     if ($googlesitemapsINI->hasVariable('MFSitemapSettings', 'ClassFilterType') and $googlesitemapsINI->hasVariable('MFSitemapSettings', 'ClassFilterArray')) {
         $params2 = array('ClassFilterType' => $googlesitemapsINI->variable('MFSitemapSettings', 'ClassFilterType'), 'ClassFilterArray' => $googlesitemapsINI->variable('MFSitemapSettings', 'ClassFilterArray'));
     }
     $max = 49997;
     // max. amount of links in 1 sitemap
     $limit = 50;
     // Fetch the content tree
     $params = array('SortBy' => array(array('depth', true), array('published', false)));
     if (isset($params2)) {
         $params = array_merge($params, $params2);
     }
     $subtreeCount = eZContentObjectTreeNode::subTreeCountByNodeID($params, $rootNode->NodeID);
     if ($subtreeCount == 1) {
         $cli->output("No Items found under node #" . $contentINI->variable('NodeSettings', 'RootNode') . ".");
     }
     if (!$isQuiet) {
         $amount = $subtreeCount + 1;
         // +1 is root node
         $cli->output("Adding {$amount} nodes to the sitemap.");
         $output = new ezcConsoleOutput();
         $bar = new ezcConsoleProgressbar($output, $amount);
     }
     $addPrio = false;
     if ($googlesitemapsINI->hasVariable('MFSitemapSettings', 'AddPriorityToSubtree') and $googlesitemapsINI->variable('MFSitemapSettings', 'AddPriorityToSubtree') == 'true') {
         $addPrio = true;
     }
     $sitemap = new xrowSitemap();
     // Generate Sitemap
     /** START Adding the root node **/
     $object = $rootNode->object();
     $meta = xrowMetaDataFunctions::fetchByObject($object);
     $extensions = array();
     $extensions[] = new xrowSitemapItemModified($rootNode->attribute('modified_subnode'));
     $url = $rootNode->attribute('url_alias');
     eZURI::transformURI($url, true);
     if ($ini->variable('SiteAccessSettings', 'RemoveSiteAccessIfDefaultAccess') == 'enabled') {
         $url = 'http://' . xrowSitemapTools::domain() . $url;
     } else {
         $url = 'http://' . xrowSitemapTools::domain() . '/' . $GLOBALS['eZCurrentAccess']['name'] . $url;
     }
     if ($meta and $meta->googlemap != '0') {
         $extensions[] = new xrowSitemapItemFrequency($meta->change);
         $extensions[] = new xrowSitemapItemPriority($meta->priority);
         $sitemap->add($url, $extensions);
     } elseif ($meta === false and $googlesitemapsINI->variable('Settings', 'AlwaysAdd') == 'enabled') {
         if ($addPrio) {
             $extensions[] = new xrowSitemapItemPriority('1');
         }
         $sitemap->add($url, $extensions);
     }
     if (isset($bar)) {
         $bar->advance();
     }
     /** END Adding the root node **/
     $max = min($max, $subtreeCount);
     $params['Limit'] = min($max, $limit);
     $params['Offset'] = 0;
     while ($params['Offset'] < $max) {
         $nodeArray = eZContentObjectTreeNode::subTreeByNodeID($params, $rootNode->NodeID);
         foreach ($nodeArray as $subTreeNode) {
             eZContentLanguage::expireCache();
             $object = $subTreeNode->object();
             $images = array();
             $meta = xrowMetaDataFunctions::fetchByObject($object);
             $extensions = array();
             $extensions[] = new xrowSitemapItemModified($subTreeNode->attribute('modified_subnode'));
             $url = $subTreeNode->attribute('url_alias');
             eZURI::transformURI($url, true);
             if ($ini->variable('SiteAccessSettings', 'RemoveSiteAccessIfDefaultAccess') == 'enabled') {
                 $url = 'http://' . xrowSitemapTools::domain() . $url;
             } else {
                 $url = 'http://' . xrowSitemapTools::domain() . '/' . $GLOBALS['eZCurrentAccess']['name'] . $url;
             }
             if ($meta and $meta->googlemap != '0') {
                 $extensions[] = new xrowSitemapItemFrequency($meta->change);
                 $extensions[] = new xrowSitemapItemPriority($meta->priority);
             } elseif ($meta === false and $googlesitemapsINI->variable('Settings', 'AlwaysAdd') == 'enabled') {
                 if ($addPrio) {
                     $rootDepth = $rootNode->attribute('depth');
                     $prio = 1 - ($subTreeNode->attribute('depth') - $rootDepth) / 10;
                     if ($prio > 0) {
                         $extensions[] = new xrowSitemapItemPriority($prio);
                     }
                 }
             }
             $images = self::getSitemapImageItems($object);
             $sitemap->add($url, array_merge($extensions, $images));
             if (isset($bar)) {
                 $bar->advance();
             }
         }
         eZContentObject::clearCache();
         $params['Offset'] += $params['Limit'];
     }
     // write XML Sitemap to file
     $dir = eZSys::storageDirectory() . '/sitemap/' . xrowSitemapTools::domain();
     if (!is_dir($dir)) {
         mkdir($dir, 0777, true);
     }
     $filename = $dir . '/' . xrowSitemap::BASENAME . '_standard_' . $GLOBALS['eZCurrentAccess']['name'] . '.' . xrowSitemap::SUFFIX;
     $sitemap->save($filename);
     if (!$isQuiet) {
         $cli->output("\n");
         $cli->output("Sitemap {$filename} for siteaccess " . $GLOBALS['eZCurrentAccess']['name'] . " has been generated.\n");
     }
 }
 function modify($tpl, $operatorName, $operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters)
 {
     $ini = eZINI::instance('xrowmetadata.ini');
     $page_limit = $ini->variable('EditorInputSettings', 'MaxPageLimit');
     $uri = eZURI::instance(eZSys::requestURI());
     $viewParameters = $uri->UserParameters();
     if (count($viewParameters) == 0) {
         $page_offset = 0;
     } else {
         $page_offset = $viewParameters['offset'];
     }
     switch ($operatorName) {
         case 'metadata':
             if (isset($namedParameters['node_id'])) {
                 $node = eZContentObjectTreeNode::fetch($namedParameters['node_id']);
                 if ($node instanceof eZContentObjectTreeNode) {
                     $cur_parent = $node->fetchParent();
                     $obj_name = $node->getName();
                     $obj_count = $node->subTreeCount(array('IgnoreVisibility' => true));
                     $localbusiness_count = $node->subTreeCount(array('IgnoreVisibility' => true, 'ClassFilterType' => 'include', 'ClassFilterArray' => array('localbusiness')));
                     $path_array_temp = array_reverse(explode('/', $node->pathWithNames()));
                     $obj_path = implode(' | ', $path_array_temp);
                     $obj_parentname = $cur_parent->Name;
                     $page_count = ceil($localbusiness_count / $page_limit);
                     $page_nr = $page_offset / $page_limit + 1;
                     $page_count_value = ezpI18n::tr('kernel/classes/datatypes', 'page') . " " . $page_nr . "/" . $page_count;
                     $operatorValue = xrowMetaDataFunctions::fetchByObject($node->attribute('object'));
                     if ($operatorValue !== false) {
                         if (isset($operatorValue->title)) {
                             $search_title = $operatorValue->title;
                             $placeholder_title_array = self::getPlaceholders($search_title);
                             if (count($placeholder_title_array) !== 0) {
                                 foreach ($placeholder_title_array as $placeholder_title) {
                                     switch ($placeholder_title) {
                                         case "count":
                                             $meta_title = str_replace("[count]", $obj_count, $search_title);
                                             continue;
                                         case "name":
                                             $meta_title = str_replace("[name]", $obj_name, $search_title);
                                             continue;
                                         case "path":
                                             $meta_title = str_replace("[path]", $obj_path, $search_title);
                                             continue;
                                         case "parentname":
                                             $meta_title = str_replace("[parentname]", $obj_parentname, $search_title);
                                             continue;
                                         case "count:localbusiness":
                                             $meta_title = str_replace("[count:localbusiness]", $localbusiness_count, $search_title);
                                             continue;
                                         case "pagecount":
                                             $meta_title = str_replace("[pagecount]", $page_count_value, $search_title);
                                             continue;
                                     }
                                     $search_title = $meta_title;
                                 }
                                 $operatorValue->title = $search_title;
                                 unset($search_title);
                             }
                         }
                         if (isset($operatorValue->description)) {
                             $search_description = $operatorValue->description;
                             $placeholder_title_description = self::getPlaceholders($search_description);
                             if (count($placeholder_title_description) !== 0) {
                                 foreach ($placeholder_title_description as $placeholder_description) {
                                     switch ($placeholder_description) {
                                         case "count":
                                             $meta_description = str_replace("[count]", $obj_count, $search_description);
                                             continue;
                                         case "name":
                                             $meta_description = str_replace("[name]", $obj_name, $search_description);
                                             continue;
                                         case "path":
                                             $meta_description = str_replace("[path]", $obj_path, $search_description);
                                             continue;
                                         case "parentname":
                                             $meta_description = str_replace("[parentname]", $obj_parentname, $search_description);
                                             continue;
                                         case "count:localbusiness":
                                             $meta_description = str_replace("[count:localbusiness]", $localbusiness_count, $search_description);
                                             continue;
                                         case "pagecount":
                                             $meta_description = str_replace("[pagecount]", $page_count_value, $search_description);
                                             continue;
                                     }
                                     $search_description = $meta_description;
                                 }
                                 $operatorValue->description = $search_description;
                                 unset($search_description);
                             }
                         }
                     }
                 } else {
                     $operatorValue = false;
                 }
             } else {
                 $operatorValue = false;
             }
             break;
     }
 }
Exemplo n.º 5
0
 public static function createMobileSitemap()
 {
     eZDebug::writeDebug("Generating mobile sitemap ...", __METHOD__);
     $cli = eZCLI::instance();
     if (!$isQuiet) {
         $cli->output("Generating mobile sitemap for siteaccess " . $GLOBALS['eZCurrentAccess']['name'] . " \n");
     }
     $ini = eZINI::instance('site.ini');
     $xrowsitemapINI = eZINI::instance('xrowsitemap.ini');
     // Get the Sitemap's root node
     $rootNode = self::rootNode();
     // Settings variables
     if ($xrowsitemapINI->hasVariable('MobileSitemapSettings', 'ClassFilterType') and $xrowsitemapINI->hasVariable('MobileSitemapSettings', 'ClassFilterArray')) {
         $params2 = array('ClassFilterType' => $xrowsitemapINI->variable('MobileSitemapSettings', 'ClassFilterType'), 'ClassFilterArray' => $xrowsitemapINI->variable('MobileSitemapSettings', 'ClassFilterArray'));
     }
     $max = self::MAX_PER_FILE;
     $limit = 50;
     // Fetch the content tree
     $params = array('SortBy' => array(array('depth', true), array('published', true)));
     if (isset($params2)) {
         $params = array_merge($params, $params2);
     }
     $subtreeCount = eZContentObjectTreeNode::subTreeCountByNodeID($params, $rootNode->NodeID);
     if ($subtreeCount == 1) {
         $cli->output("No Items found under RootNode {$rootNode->NodeID}.");
     }
     if (!$isQuiet) {
         $amount = $subtreeCount + 1;
         // +1 is root node
         $cli->output("Adding {$amount} nodes to the sitemap for RootNode {$rootNode->NodeID}.");
         $output = new ezcConsoleOutput();
         $bar = new ezcConsoleProgressbar($output, $amount);
     }
     $addPrio = false;
     if ($xrowsitemapINI->hasVariable('Settings', 'AddPriorityToSubtree') and $xrowsitemapINI->variable('Settings', 'AddPriorityToSubtree') == 'true') {
         $addPrio = true;
     }
     $sitemap = new xrowMobileSitemap();
     // Generate Sitemap
     /** START Adding the root node **/
     $object = $rootNode->object();
     $meta = xrowMetaDataFunctions::fetchByObject($object);
     $extensions = array();
     $extensions[] = new xrowSitemapItemModified($rootNode->attribute('modified_subnode'));
     $url = $rootNode->attribute('url_alias');
     eZURI::transformURI($url);
     if ($xrowsitemapINI->hasVariable('SitemapSettings', 'MobileDomainName') && $xrowsitemapINI->hasVariable('SitemapSettings', 'MobileDomainName') != '') {
         $mobileDomain = $xrowsitemapINI->variable('SitemapSettings', 'MobileDomainName');
     } else {
         $mobileDomain = self::domain();
     }
     $url = 'http://' . $mobileDomain . $url;
     if ($meta and $meta->sitemap_use != '0') {
         $extensions[] = new xrowSitemapItemFrequency($meta->change);
         $extensions[] = new xrowSitemapItemPriority($meta->priority);
         $sitemap->add($url, $extensions);
     } elseif ($meta === false and $xrowsitemapINI->variable('Settings', 'AlwaysAdd') == 'enabled') {
         if ($addPrio) {
             $extensions[] = new xrowSitemapItemPriority('1');
         }
         $sitemap->add($url, $extensions);
     }
     if (isset($bar)) {
         $bar->advance();
     }
     /** END Adding the root node **/
     $max = min($max, $subtreeCount);
     $params['Limit'] = min($max, $limit);
     $params['Offset'] = 0;
     while ($params['Offset'] < $max) {
         $nodeArray = eZContentObjectTreeNode::subTreeByNodeID($params, $rootNode->NodeID);
         foreach ($nodeArray as $subTreeNode) {
             eZContentLanguage::expireCache();
             $meta = xrowMetaDataFunctions::fetchByNode($subTreeNode);
             $extensions = array();
             $extensions[] = new xrowSitemapItemModified($subTreeNode->attribute('modified_subnode'));
             $url = $subTreeNode->attribute('url_alias');
             eZURI::transformURI($url);
             $url = 'http://' . $mobileDomain . $url;
             if ($meta and $meta->sitemap_use != '0') {
                 $extensions[] = new xrowSitemapItemFrequency($meta->change);
                 $extensions[] = new xrowSitemapItemPriority($meta->priority);
                 $sitemap->add($url, $extensions);
             } elseif ($meta === false and $xrowsitemapINI->variable('Settings', 'AlwaysAdd') == 'enabled') {
                 if ($addPrio) {
                     $rootDepth = $rootNode->attribute('depth');
                     $prio = 1 - ($subTreeNode->attribute('depth') - $rootDepth) / 10;
                     if ($prio > 0) {
                         $extensions[] = new xrowSitemapItemPriority($prio);
                     }
                 }
                 $sitemap->add($url, $extensions);
             }
             if (isset($bar)) {
                 $bar->advance();
             }
         }
         eZContentObject::clearCache();
         $params['Offset'] += $params['Limit'];
     }
     // write XML Sitemap to file
     $dir = eZSys::storageDirectory() . '/sitemap/' . self::domain();
     if (!is_dir($dir)) {
         mkdir($dir, 0777, true);
     }
     $filename = $dir . '/' . xrowSitemap::BASENAME . '_' . self::FILETYP_MOBILE . '_' . $GLOBALS['eZCurrentAccess']['name'] . '.' . xrowSitemap::SUFFIX;
     $sitemap->save($filename);
     /**
              * @TODO How will this work with cluster?
             if ( function_exists( 'gzencode' ) and $xrowsitemapINI->variable( 'MobileSitemapSettings', 'Gzip' ) == 'enabled' )
             {
                 $content = file_get_contents( $filename );
                 $content = gzencode( $content );
                 file_put_contents( $filename . '.gz', $content );
                 unlink( $filename );
                 $filename .= '.gz';
             }
              **/
     if (!$isQuiet) {
         $cli->output("\n");
         $cli->output("Mobile sitemap {$filename} for siteaccess " . $GLOBALS['eZCurrentAccess']['name'] . " has been generated.\n");
     }
 }