public static function fetchObjectTreeCount($parentNodeID, $onlyTranslated, $language, $class_filter_type, $class_filter_array, $attributeFilter, $depth, $depthOperator, $ignoreVisibility, $limitation, $mainNodeOnly, $extendedAttributeFilter, $objectNameFilter) { $childrenCount = null; if (is_numeric($parentNodeID) or is_array($parentNodeID)) { $childrenCount = eZContentObjectTreeNode::subTreeCountByNodeID(array('Limitation' => $limitation, 'ClassFilterType' => $class_filter_type, 'ClassFilterArray' => $class_filter_array, 'AttributeFilter' => $attributeFilter, 'DepthOperator' => $depthOperator, 'Depth' => $depth, 'IgnoreVisibility' => $ignoreVisibility, 'OnlyTranslated' => $onlyTranslated, 'Language' => $language, 'ObjectNameFilter' => $objectNameFilter, 'ExtendedAttributeFilter' => $extendedAttributeFilter, 'MainNodeOnly' => $mainNodeOnly), $parentNodeID); } if ($childrenCount === null) { $result = array('error' => array('error_type' => 'kernel', 'error_code' => eZError::KERNEL_NOT_FOUND)); } else { $result = array('result' => $childrenCount); } return $result; }
/** * Returns node count using a given set of criteria * @param ezpContentCriteria $criteria * @return int */ public static function queryCount( ezpContentCriteria $criteria ) { $fetchParams = self::translateFetchParams( $criteria ); $count = eZContentObjectTreeNode::subTreeCountByNodeID( $fetchParams->params, $fetchParams->rootNodeId ); return $count; }
eZINI::instance()->setVariable('ContentSettings', 'PreViewCache', 'disabled'); eZINI::instance()->setVariable('SearchSettings', 'DelayedIndexing', 'enabled'); eZINI::instance('ezfind.ini')->setVariable('IndexOptions', 'OptimizeOnCommit', 'disabled'); $cli->notice("indexing disabled. Don't forget to reindex content."); } if ($dryRun) { $cli->notice("Don't worry, --dry-run mode activated."); } foreach ($deleteIDArray as $nodeID) { /** @var eZContentObjectTreeNode $node */ $node = eZContentObjectTreeNode::fetch($nodeID); if ($node === null) { $cli->error("\nSubtree remove Error!\nCannot find subtree with nodeID: '{$nodeID}'."); continue; } $count = (int) eZContentObjectTreeNode::subTreeCountByNodeID($params, $nodeID); $cli->notice("===== {$nodeID} : {$count} children to remove. " . $node->url()); $i = 0; do { /** @var eZContentObjectTreeNode[] $children */ $children = eZContentObjectTreeNode::subTreeByNodeID($params, $nodeID); foreach ($children as $child) { $i++; $child_node_id = $child->attribute('node_id'); if ($verbose) { $t = time(); $te = max($t - $start, 1); // temps écoulé. (1 min pour éviter les divisions par 0) $tm = $te / $i; // temps moyen. = temps déjà consomé divisé par le nombre de objet passé. FLoat. $r = $count - $i;
function subTreeCount($params = array()) { return eZContentObjectTreeNode::subTreeCountByNodeID($params, $this->attribute('node_id')); }
/** * Create Node element * * @param DOMDocument Owner DOMDocument * @param eZContentObject eZContentObject node. * * @return DOMElement Node DOMDocument. */ protected function createTreeNodeDOMElement(DOMDocument $domDocument, eZContentObjectTreeNode $node) { $nodeElement = $domDocument->createElement('Node'); // Set attributes. $nodeElement->setAttribute('nodeID', $node->attribute('node_id')); $nodeElement->setAttribute('parentID', $node->attribute('parent_node_id')); // Get child information. $conditions = array('Depth' => 1, 'DepthOperator' => 'eq'); $nodeElement->setAttribute('childCount', eZContentObjectTreeNode::subTreeCountByNodeID($conditions, $node->attribute('node_id'))); // Get child information for tree structure. $conditions['ClassFilterType'] = 'include'; $conditions['ClassFilterArray'] = eZINI::instance('contentstructuremenu.ini')->variable('TreeMenu', 'ShowClasses'); $nodeElement->setAttribute('childMenuCount', eZContentObjectTreeNode::subTreeCountByNodeID($conditions, $node->attribute('node_id'))); // Get access rights element. $nodeElement->appendChild($this->createAccessDOMElement($domDocument, $node)); // Get object element. $nodeElement->appendChild($this->createObjectDOMElement($domDocument, $node->attribute('object'))); return $nodeElement; }
function modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters ) { switch ( $operatorName ) { // note: these functions are not cache-block safe // as in: if called inside a cache-block then they will not be called when cache is used. case 'ezpagedata_set': case 'ezpagedata_append': { self::setPersistentVariable( $namedParameters['key'], $namedParameters['value'], $tpl, $operatorName === 'ezpagedata_append' ); }break; case 'ezpagedata': { $currentNodeId = 0; $pageData = array(); $parameters = $namedParameters['params']; // Get module_result for later use if ( $tpl->hasVariable('module_result') ) { $moduleResult = $tpl->variable('module_result'); } else { $moduleResult = array(); } if ( isset( $moduleResult['content_info'] ) ) { $contentInfo = $moduleResult['content_info']; } else { $contentInfo = array(); } // Get persistent_variable if ( isset( $contentInfo['persistent_variable'] ) && is_array( $contentInfo['persistent_variable'] ) ) { $pageData['persistent_variable'] = $contentInfo['persistent_variable']; } else { $pageData['persistent_variable'] = self::getPersistentVariable(); if ( $pageData['persistent_variable'] === null ) { $pageData['persistent_variable'] = array(); } } // Merge parameters with persistent_variable $parameters = array_merge( $parameters, $pageData['persistent_variable'] ); // Figgure out current node id if ( isset( $parameters['current_node_id'] ) ) { $currentNodeId = (int) $parameters['current_node_id']; // Allow parameters to set current path if ( isset( $parameters['set_current_node_path'] ) && $parameters['set_current_node_path'] ) { if ( $setPath = self::getNodePath( $currentNodeId ) ) { $moduleResult['path'] = $setPath['path']; $moduleResult['title_path'] = $setPath['title_path']; $tpl->setVariable( 'module_result', $moduleResult ); } else { eZDebug::writeWarning( "Could not fetch 'current_node_id'", 'eZPageData::getNodePath()' ); } } } else if ( $tpl->hasVariable('current_node_id') ) { $currentNodeId = (int) $tpl->variable('current_node_id'); } else if ( isset( $moduleResult['node_id'] ) ) { $currentNodeId = (int) $moduleResult['node_id']; } else if ( isset( $moduleResult['path'][count( $moduleResult['path'] ) - 1]['node_id'] ) ) { $currentNodeId = (int) $moduleResult['path'][count( $moduleResult['path'] ) - 1]['node_id']; } // Init variables and return values $ini = eZINI::instance( 'site.ini' ); $menuIni = eZINI::instance( 'menu.ini' ); $contentIni = eZINI::instance( 'content.ini' ); $uiContext = $tpl->variable('ui_context'); $uriString = $tpl->variable('uri_string'); $pageData['main_node_id'] = isset( $contentInfo['main_node_id'] ) ? $contentInfo['main_node_id'] : $currentNodeId; $pageData['show_path'] = 'path'; $pageData['website_toolbar'] = false; $pageData['node_id'] = $currentNodeId; $pageData['is_edit'] = false; $pageData['page_root_depth'] = 0; $pageData['page_depth'] = count( $moduleResult['path'] ); $pageData['root_node'] = (int) $contentIni->variable( 'NodeSettings', 'RootNode' ); $pageData['canonical_url'] = false; $pageData['canonical_language_url'] = false; // is_edit if not on user/edit and not on content/action when // you get info collector warning about missing attributes if ( $uiContext === 'edit' && strpos( $uriString, 'user/edit' ) === false && ( empty( $contentInfo ) || strpos( $uriString, 'content/action' ) === false ) ) { $pageData['is_edit'] = true; } if ( isset( $contentInfo['viewmode'] ) ) { $viewMode = $contentInfo['viewmode']; } else { $viewMode = ''; } // canonical url, to let search engines know about main location on content with multiple locations if ( isset( $parameters['canonical_url'] ) ) { $pageData['canonical_url'] = $parameters['canonical_url']; } elseif ( isset( $contentInfo['main_node_url_alias'] ) && $contentInfo['main_node_url_alias'] ) { $pageData['canonical_url'] = $contentInfo['main_node_url_alias']; } elseif ( isset( $contentInfo['current_language'] ) && $contentInfo['current_language'] !== $ini->variable( 'RegionalSettings', 'ContentObjectLocale' ) ) { $siteaccess = eZSiteAccess::saNameByLanguage( $contentInfo['current_language'] ); if ( $siteaccess !== null ) { $lang = eZContentLanguage::fetchByLocale( $ini->variable( 'RegionalSettings', 'ContentObjectLocale' ) ); if ( ( $contentInfo['language_mask'] & $lang->attribute('id') ) < 1 ) { $handlerOptions = new ezpExtensionOptions(); $handlerOptions->iniFile = 'site.ini'; $handlerOptions->iniSection = 'RegionalSettings'; $handlerOptions->iniVariable = 'LanguageSwitcherClass'; $handlerOptions->handlerParams = array( array( 'Parameters' => array( 'sa', $currentNodeId ), 'UserParameters' => array() ) ); $langSwitch = eZExtension::getHandlerClass( $handlerOptions ); $langSwitch->setDestinationSiteAccess( $siteaccess ); $langSwitch->process(); $pageData['canonical_language_url'] = $langSwitch->destinationUrl(); } } } /* RootNodeDepth is a setting for letting you have a very simple multisite, single database and singe siteaccess setup. The content of the menues will be the same on all system pages like user/login, content/edit and so on, and also when you surf bellow the defined page_root_depth. The sites will also share siteaccess and thus also the same ez publish design and templates. You can however custimize the design with css using the class on div#page html output: subtree_level_x_node_id_y class Note: It is recommended to turn it of by setting it to 0 for normal sites! Example having 2 or more 'sub-sites' with RootNodeDepth=2: root (menu shows sub sites as menu choices like it will on system pages) - sub site 1 (menu show content of this sub site) - sub site 2 (-- " --) - sub site 3 (-- " --) - sub site 4 (-- " --) - sub site 5 (-- " --) */ if ( $currentNodeId && isset( $moduleResult['path'][0]['node_id'] ) && $moduleResult['path'][0]['node_id'] == '2' && $ini->hasVariable( 'SiteSettings', 'RootNodeDepth' ) && $ini->variable( 'SiteSettings', 'RootNodeDepth' ) !== '0' ) { $pageData['page_root_depth'] = $ini->variable( 'SiteSettings', 'RootNodeDepth' ) -1; if ( isset( $moduleResult['path'][ $pageData['page_root_depth'] ]['node_id'] )) { $pageData['root_node'] = $moduleResult['path'][$pageData['page_root_depth'] ]['node_id']; } } // Get class identifier for easier access in tempaltes $pageData['class_identifier'] = ''; if ( isset( $contentInfo['class_identifier'] ) ) { $pageData['class_identifier'] = $contentInfo['class_identifier']; } // Use custom path template. bool|string ( default: path ) if ( isset( $parameters['show_path'] ) ) { $pageData['show_path'] = $parameters['show_path'] === true ? 'path' : $parameters['show_path']; } else if ( $viewMode === 'sitemap' || $viewMode === 'tagcloud' ) { $pageData['show_path'] = false; } // See if we should show website toolbar. bool ( default: false ) if ( isset( $parameters['website_toolbar'] ) ) { $pageData['website_toolbar'] = $parameters['website_toolbar']; } else if ( $viewMode === 'sitemap' || $viewMode === 'tagcloud' || strpos( $uriString, 'content/versionview' ) === 0 ) { $pageData['website_toolbar'] = false; } else if ( $tpl->hasVariable('current_user') ) { $currentUser = $tpl->variable('current_user'); $pageData['website_toolbar'] = ( $currentNodeId && $currentUser->attribute('is_logged_in') ); } // Init default menu settings $pageData['top_menu'] = $menuIni->variable('SelectedMenu', 'TopMenu'); $pageData['left_menu'] = $menuIni->variable('SelectedMenu', 'LeftMenu'); $pageData['current_menu'] = $menuIni->variable('SelectedMenu', 'CurrentMenu'); $pageData['extra_menu'] = 'extra_info'; $pageData['extra_menu_node_id'] = $currentNodeId; $pageData['extra_menu_subitems'] = 0; $pageData['extra_menu_class_list'] = array( 'infobox' ); // BC: Setting to hide left and extra menu by class identifier if ( $menuIni->hasVariable('MenuSettings', 'HideLeftMenuClasses') ) { $hideMenuClasses = in_array( $pageData['class_identifier'], $menuIni->variable('MenuSettings', 'HideLeftMenuClasses') ); } else { $hideMenuClasses = false; } // Use custom top menu template. bool|string ( default: from menu.ini[SelectedMenu]TopMenu ) if ( isset( $parameters['top_menu'] ) && $parameters['top_menu'] !== true ) { $pageData['top_menu'] = $parameters['top_menu']; } // Use custom left menu template. bool|string ( default: from menu.ini[SelectedMenu]LeftMenu ) if ( isset( $parameters['left_menu'] ) ) { if ( $parameters['left_menu'] !== true ) $pageData['left_menu'] = $parameters['left_menu']; } else if ( $hideMenuClasses ) { $pageData['left_menu'] = false; } // Use custom extra menu template. bool|string (default: extra_info) if ( isset( $parameters['extra_menu'] ) ) { if ( $parameters['extra_menu'] !== true ) $pageData['extra_menu'] = $parameters['extra_menu']; } else if ( $hideMenuClasses ) { $pageData['extra_menu'] = false; } // Use custom node id. int|array (default: current node id) if ( isset( $parameters['extra_menu_node_id'] ) ) { $pageData['extra_menu_node_id'] = $parameters['extra_menu_node_id']; } // Use custom extra menu identifier list. false|array (default: infobox) if ( isset( $parameters['extra_menu_class_list'] ) ) { $pageData['extra_menu_class_list'] = $parameters['extra_menu_class_list']; } else if ( $menuIni->hasVariable('MenuContentSettings', 'ExtraIdentifierList') ) { $pageData['extra_menu_class_list'] = $menuIni->variable('MenuContentSettings', 'ExtraIdentifierList'); } if ( $menuIni->variable( 'MenuSettings', 'AlwaysAvailable' ) === 'false' ) { // A set of cases where left/extra menu's are hidden unless set by parameters if ( $pageData['is_edit'] || strpos( $uriString, 'content/versionview' ) === 0 ) { if ( !isset( $parameters['left_menu'] ) ) $pageData['left_menu'] = false; if ( !isset( $parameters['extra_menu'] ) ) $pageData['extra_menu'] = false; } else if ( !$currentNodeId || $uiContext === 'browse' ) { if ( !isset( $parameters['left_menu'] ) ) $pageData['left_menu'] = false; if ( !isset( $parameters['extra_menu'] ) ) $pageData['extra_menu'] = false; } } // Count extra menu objects if all extra menu settings are present if ( isset( $parameters['extra_menu_subitems'] ) ) { $pageData['extra_menu_subitems'] = $parameters['extra_menu_subitems']; if ( !$pageData['extra_menu_subitems'] ) $pageData['extra_menu'] = false; } else if ( $pageData['extra_menu'] && $pageData['extra_menu_class_list'] && $pageData['extra_menu_node_id'] ) { if ( $menuIni->variable( 'MenuContentSettings', 'ExtraMenuSubitemsCheck' ) === 'enabled' ) { $pageData['extra_menu_subitems'] = eZContentObjectTreeNode::subTreeCountByNodeID( array( 'Depth' => 1, 'DepthOperator' => 'eq', 'ClassFilterType' => 'include', 'ClassFilterArray' => $pageData['extra_menu_class_list'] ), $pageData['extra_menu_node_id'] ); if ( !$pageData['extra_menu_subitems'] ) $pageData['extra_menu'] = false; } } // Init path parameters $pageData['path_array'] = array(); $pageData['path_id_array'] = array(); $pageData['path_normalized'] = ''; // Creating menu css classes for div#page $pageData['css_classes'] = ''; // Add section css class for div#page if ( isset( $moduleResult['section_id'] )) { $pageData['css_classes'] .= ' section_id_' . $moduleResult['section_id']; } // Generate relative path array as well full path id array and path css classes for div#page $path = ( isset( $moduleResult['path'] ) && is_array( $moduleResult['path'] ) ) ? $moduleResult['path'] : array(); foreach ( $path as $key => $item ) { if ( $key >= $pageData['page_root_depth']) { $pageData['path_array'][] = $item; } if ( isset( $item['node_id'] ) ) { $pageData['path_normalized'] .= ' subtree_level_' . $key . '_node_id_' . $item['node_id']; $pageData['path_id_array'][] = $item['node_id']; } } $pageData['css_classes'] .= $pageData['path_normalized']; if ( isset( $pageData['persistent_variable']['pagestyle_css_classes'] ) && is_array( $pageData['persistent_variable']['pagestyle_css_classes'] ) ) { $pageData['css_classes'] .= ' ' . implode( ' ', $pageData['persistent_variable']['pagestyle_css_classes'] ); } $pageData['inner_column_size'] = 8; if ( $pageData['left_menu'] && $pageData['extra_menu'] ) $pageData['inner_column_size'] = 6; if ( !$pageData['left_menu'] && !$pageData['extra_menu'] ) $pageData['inner_column_size'] = 12; $pageData['outer_column_size'] = 4; if ( $pageData['left_menu'] && $pageData['extra_menu'] ) $pageData['outer_column_size'] = 3; $operatorValue = $pageData; } break; } }
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"); } }
require 'autoload.php'; $cli = eZCLI::instance(); $script = eZScript::instance(array('description' => "Remove archived content object versions according to " . "[VersionManagement/DefaultVersionHistoryLimit and " . "[VersionManagement]/VersionHistoryClass settings", 'use-session' => false, 'use-modules' => true, 'use-extensions' => true)); $script->startup(); $options = $script->getOptions("[n]", "", array("n" => "Do not wait")); $script->initialize(); if (!isset($options['n'])) { $cli->warning("This cleanup script is going to remove archived versions according to the settings"); $cli->warning("content.ini/[VersionManagement]/DefaultVersionHistoryLimit and content.ini/[VersionManagement]/VersionHistoryClass"); $cli->warning(); $cli->warning("You have 10 seconds to break the script (press Ctrl-C)"); sleep(10); $cli->output(); } $subTreeParams = array('Limitation' => array(), 'MainNodeOnly' => true, 'LoadDataMap' => false, 'IgnoreVisibility' => true); $total = eZContentObjectTreeNode::subTreeCountByNodeID($subTreeParams, 1); $cli->output("{$total} objects to check... (In the progess bar, 'R' means that at least a version was removed)"); $script->setIterationData('R', '.'); $script->resetIteration($total); $subTreeParams['Offset'] = 0; $subTreeParams['Limit'] = 100; $db = eZDB::instance(); while (true) { $nodes = eZContentObjectTreeNode::subTreeByNodeID($subTreeParams, 1); if (empty($nodes)) { break; } foreach ($nodes as $node) { $object = $node->attribute('object'); $versionCount = $object->getVersionCount(); $versionLimit = eZContentClass::versionHistoryLimit($object->attribute('content_class'));
<?php $offset = 0; $limit = 30; $db = eZDB::instance(); $siteINI = eZINI::instance('site.ini'); $refINI = eZINI::instance('sitemap.ini'); $siteURL = $siteINI->variable('SiteSettings', 'SiteURL'); $ClassFilterArray = $refINI->variable('SitemapSettings', 'ClassFilterArray'); $ClassFilterType = $refINI->variable('SitemapSettings', 'ClassFilterType'); print_r($ClassFilterType); if ($ClassFilterType != 'include' && $ClassFilterType != 'exclude') { eZExecution::cleanExit(); } $params = array('ClassFilterType' => $ClassFilterType, 'ClassFilterArray' => $ClassFilterArray); $count = eZContentObjectTreeNode::subTreeCountByNodeID($params, 2); /* Clean de la base SQL */ $sql_truncate = "TRUNCATE TABLE `do_sitemap` "; $db->query($sql_truncate); $params['Limit'] = $limit; while ($offset < $count) { $params['Offset'] = $offset; $elements = eZContentObjectTreeNode::subTreeByNodeID($params, 2); foreach ($elements as $element) { $info = array(); $info['dosm_loc'] = $siteURL . '/' . $element->url(); $info['dosm_lastmod'] = date('Y-m-d', $element->object()->attribute('modified')); $info['dosm_changefreq'] = 'monthly'; $info['dosm_priority'] = '1'; $info['dosm_insertedDate'] = ''; $info['dosm_updatedDate'] = date('Y-m-d', $element->object()->attribute('published'));
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"); } }
$srcStopTime = microtime(); $startTime = @next(explode(" ", $srcStartTime)) + current(explode(" ", $srcStartTime)); $stopTime = @next(explode(" ", $srcStopTime)) + current(explode(" ", $srcStopTime)); $executionTime = round($stopTime - $startTime, 2); /** Alert the user to how long the script execution took place **/ $cli->output("\n\nThis script execution completed in " . $executionTime . " seconds" . ".\n"); } /** Login script to run as admin user This is required to see past content tree permissions, sections and other limitations **/ $currentuser = eZUser::currentUser(); $currentuser->logoutCurrent(); $user = eZUser::fetch($adminUserID); $user->loginCurrent(); /** Fetch total files count from content tree **/ $totalFileCountParams = array('ClassFilterType' => 'include', 'ClassFilterArray' => $classes, 'Depth' => 10, 'MainNodeOnly' => true, 'SortBy' => array('published', true), 'IgnoreVisibility' => true); /** Fetch total count for member content objects **/ $totalFileCount = eZContentObjectTreeNode::subTreeCountByNodeID($totalFileCountParams, $parentNodeID); /** Debug verbose output **/ if (!$totalFileCount) { $cli->error("No member objects found"); /** Call for display of execution time **/ executionTimeDisplay($srcStartTime, $cli); $script->shutdown(3); } $cli->warning("Total number of objects to be checked: " . $totalFileCount . "\n"); /** Setup script iteration details **/ $script->setIterationData('.', '.'); $script->resetIteration($totalFileCount); /** Iterate over nodes **/ while ($offset < $totalFileCount) { /** Fetch nodes under starting node in content tree **/ $subTreeParams = array('Limit' => $limit, 'Offset' => $offset, 'ClassFilterType' => 'include', 'ClassFilterArray' => $classes, 'SortBy' => array('modified', false), 'Depth' => 10, 'MainNodeOnly' => true, 'IgnoreVisibility' => true);
/** * Fetches and returns the current subtree node count * * @return int Total number of nodes in subtree */ protected function _count() { $params = $this->_fetchParams(); $count = eZContentObjectTreeNode::subTreeCountByNodeID( $params, $this->_node ); return (int) $count; }
private function fetchNodeInfoFromId($nodeId) { if (!eepValidate::validateContentNodeId($nodeId)) { throw new Exception("This is not a node id: [" . $nodeId . "]"); } $keepers = array("Name", "ContentObjectID", "MainNodeID", "ClassIdentifier", "PathIdentificationString", "PathString", "ParentNodeID", "CurrentLanguage", "ContentObjectVersion", "RemoteID", "IsHidden", "IsInvisible", "ContentObjectIsPublished"); // get the node $node = eZContentObjectTreeNode::fetch($nodeId); //var_dump($node); // extract the members we want $results[] = array("key", "value"); foreach ($keepers as $key) { $results[] = array($key, $node->{$key}); } // additional info $results[] = array("Reverse related count", eZContentObjectTreeNode::reverseRelatedCount(array($nodeId))); $params = array('Depth' => 1, 'DepthOperator' => 'eq', 'Limitation' => array()); $results[] = array("Children count", eZContentObjectTreeNode::subTreeCountByNodeID($params, $nodeId)); $results[] = array("URL Alias", $node->urlAlias()); // do output eep::printTable($results, "contentnode info [" . $nodeId . "]"); }