本文整理汇总了PHP中eZContentObjectTreeNode::classIDByIdentifier方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObjectTreeNode::classIDByIdentifier方法的具体用法?PHP eZContentObjectTreeNode::classIDByIdentifier怎么用?PHP eZContentObjectTreeNode::classIDByIdentifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentObjectTreeNode
的用法示例。
在下文中一共展示了eZContentObjectTreeNode::classIDByIdentifier方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setItemDefaults
/**
* Set RSSExportItem defaults based on site.ini [RSSSettings] settings
*
* @param eZRSSExportItem $rssExportItem
* @return bool True if changes where made
*/
static function setItemDefaults(eZRSSExportItem $rssExportItem)
{
$nodeId = $rssExportItem->attribute('source_node_id');
$node = $nodeId ? eZContentObjectTreeNode::fetch($nodeId) : null;
if (!$node instanceof eZContentObjectTreeNode) {
return false;
}
$config = eZINI::instance('site.ini');
$nodeClassIdentifier = $node->attribute('class_identifier');
$defaultFeedItemClasses = $config->variable('RSSSettings', 'DefaultFeedItemClasses');
if (!isset($defaultFeedItemClasses[$nodeClassIdentifier])) {
return false;
}
$feedItemClasses = explode(';', $defaultFeedItemClasses[$nodeClassIdentifier]);
$iniSection = 'RSSSettings_' . $feedItemClasses[0];
if (!$config->hasVariable($iniSection, 'FeedObjectAttributeMap')) {
return false;
}
$feedObjectAttributeMap = $config->variable($iniSection, 'FeedObjectAttributeMap');
$subNodesMap = $config->hasVariable($iniSection, 'Subnodes') ? $config->variable($iniSection, 'Subnodes') : array();
$rssExportItem->setAttribute('class_id', eZContentObjectTreeNode::classIDByIdentifier($feedItemClasses[0]));
$rssExportItem->setAttribute('title', $feedObjectAttributeMap['title']);
if (isset($feedObjectAttributeMap['description'])) {
$rssExportItem->setAttribute('description', $feedObjectAttributeMap['description']);
}
if (isset($feedObjectAttributeMap['category'])) {
$rssExportItem->setAttribute('category', $feedObjectAttributeMap['category']);
}
if (isset($feedObjectAttributeMap['enclosure'])) {
$rssExportItem->setAttribute('enclosure', $feedObjectAttributeMap['enclosure']);
}
$rssExportItem->setAttribute('subnodes', isset($subNodesMap[$nodeClassIdentifier]) && $subNodesMap[$nodeClassIdentifier] === 'true');
$rssExportItem->store();
}
示例2: createFeedForNode
/**
* Creates a RSS/ATOM Feed export for a node
*
* @param int $nodeID Node ID
*
* @since 4.3
*/
public static function createFeedForNode($nodeID)
{
$hasExport = eZRSSFunctionCollection::hasExportByNode($nodeID);
if (isset($hasExport['result']) && $hasExport['result']) {
eZDebug::writeError('There is already a rss/atom export feed for this node: ' . $nodeID, __METHOD__);
return array('status' => false);
}
$node = eZContentObjectTreeNode::fetch($nodeID);
$currentClassIdentifier = $node->attribute('class_identifier');
$config = eZINI::instance('site.ini');
$feedItemClasses = $config->variable('RSSSettings', 'DefaultFeedItemClasses');
if (!$feedItemClasses || !isset($feedItemClasses[$currentClassIdentifier])) {
eZDebug::writeError("EnableRSS: content class {$currentClassIdentifier} is not defined in site.ini[RSSSettings]DefaultFeedItemClasses[<class_id>].", __METHOD__);
return array('status' => false);
}
$object = $node->object();
$objectID = $object->attribute('id');
$currentUserID = eZUser::currentUserID();
$rssExportItems = array();
$db = eZDB::instance();
$db->begin();
$rssExport = eZRSSExport::create($currentUserID);
$rssExport->setAttribute('access_url', 'rss_feed_' . $nodeID);
$rssExport->setAttribute('node_id', $nodeID);
$rssExport->setAttribute('main_node_only', '1');
$rssExport->setAttribute('number_of_objects', $config->variable('RSSSettings', 'NumberOfObjectsDefault'));
$rssExport->setAttribute('rss_version', $config->variable('RSSSettings', 'DefaultVersion'));
$rssExport->setAttribute('status', eZRSSExport::STATUS_VALID);
$rssExport->setAttribute('title', $object->name());
$rssExport->store();
$rssExportID = $rssExport->attribute('id');
foreach (explode(';', $feedItemClasses[$currentClassIdentifier]) as $classIdentifier) {
$iniSection = 'RSSSettings_' . $classIdentifier;
if ($config->hasVariable($iniSection, 'FeedObjectAttributeMap')) {
$feedObjectAttributeMap = $config->variable($iniSection, 'FeedObjectAttributeMap');
$subNodesMap = $config->hasVariable($iniSection, 'Subnodes') ? $config->variable($iniSection, 'Subnodes') : array();
$rssExportItem = eZRSSExportItem::create($rssExportID);
$rssExportItem->setAttribute('class_id', eZContentObjectTreeNode::classIDByIdentifier($classIdentifier));
$rssExportItem->setAttribute('title', $feedObjectAttributeMap['title']);
if (isset($feedObjectAttributeMap['description'])) {
$rssExportItem->setAttribute('description', $feedObjectAttributeMap['description']);
}
if (isset($feedObjectAttributeMap['category'])) {
$rssExportItem->setAttribute('category', $feedObjectAttributeMap['category']);
}
if (isset($feedObjectAttributeMap['enclosure'])) {
$rssExportItem->setAttribute('enclosure', $feedObjectAttributeMap['enclosure']);
}
$rssExportItem->setAttribute('source_node_id', $nodeID);
$rssExportItem->setAttribute('status', eZRSSExport::STATUS_VALID);
$rssExportItem->setAttribute('subnodes', isset($subNodesMap[$currentClassIdentifier]) && $subNodesMap[$currentClassIdentifier] === 'true');
$rssExportItem->store();
} else {
eZDebug::writeError("site.ini[{$iniSection}]Source[] setting is not defined.", __METHOD__);
}
}
$db->commit();
eZContentCacheManager::clearContentCacheIfNeeded($objectID);
return array('status' => true);
}
示例3: modify
function modify($tpl, $operatorName, $operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters)
{
switch ($operatorName) {
case 'eztagcloud':
$tags = array();
$tagCloud = array();
$parentNodeID = 0;
$classIdentifier = '';
$classIdentifierSQL = '';
$pathString = '';
$parentNodeIDSQL = '';
$dbParams = array();
$params = $namedParameters['params'];
$orderBySql = 'ORDER BY ezkeyword.keyword ASC';
if (isset($params['class_identifier'])) {
$classIdentifier = $params['class_identifier'];
}
if (isset($params['parent_node_id'])) {
$parentNodeID = $params['parent_node_id'];
}
if (isset($params['limit'])) {
$dbParams['limit'] = $params['limit'];
}
if (isset($params['offset'])) {
$dbParams['offset'] = $params['offset'];
}
if (isset($params['sort_by']) && is_array($params['sort_by']) && count($params['sort_by'])) {
$orderBySql = 'ORDER BY ';
$orderArr = is_string($params['sort_by'][0]) ? array($params['sort_by']) : $params['sort_by'];
foreach ($orderArr as $key => $order) {
if ($key !== 0) {
$orderBySql .= ', ';
}
$direction = isset($order[1]) ? $order[1] : false;
switch ($order[0]) {
case 'keyword':
$orderBySql .= 'ezkeyword.keyword ' . ($direction ? 'ASC' : 'DESC');
break;
case 'count':
$orderBySql .= 'keyword_count ' . ($direction ? 'ASC' : 'DESC');
break;
}
}
}
$db = eZDB::instance();
if ($classIdentifier) {
$classID = eZContentObjectTreeNode::classIDByIdentifier($classIdentifier);
$classIdentifierSQL = "AND ezcontentobject.contentclass_id = '" . $classID . "'";
}
if ($parentNodeID) {
$node = eZContentObjectTreeNode::fetch($parentNodeID);
if ($node) {
$pathString = "AND ezcontentobject_tree.path_string like '" . $node->attribute('path_string') . "%'";
}
$parentNodeIDSQL = 'AND ezcontentobject_tree.node_id != ' . (int) $parentNodeID;
}
$showInvisibleNodesCond = eZContentObjectTreeNode::createShowInvisibleSQLString(true, false);
$limitation = false;
$limitationList = eZContentObjectTreeNode::getLimitationList($limitation);
$sqlPermissionChecking = eZContentObjectTreeNode::createPermissionCheckingSQL($limitationList);
$languageFilter = 'AND ' . eZContentLanguage::languagesSQLFilter('ezcontentobject');
$languageFilter .= 'AND ' . eZContentLanguage::languagesSQLFilter('ezcontentobject_attribute', 'language_id');
$rs = $db->arrayQuery("SELECT ezkeyword.keyword, count(ezkeyword.keyword) AS keyword_count\n FROM ezkeyword_attribute_link\n LEFT JOIN ezcontentobject_attribute\n ON ezkeyword_attribute_link.objectattribute_id = ezcontentobject_attribute.id\n LEFT JOIN ezcontentobject\n ON ezcontentobject_attribute.contentobject_id = ezcontentobject.id\n LEFT JOIN ezcontentobject_tree\n ON ezcontentobject_attribute.contentobject_id = ezcontentobject_tree.contentobject_id\n LEFT JOIN ezkeyword\n ON ezkeyword.id = ezkeyword_attribute_link.keyword_id\n {$sqlPermissionChecking['from']}\n WHERE\n ezcontentobject.status = " . eZContentObject::STATUS_PUBLISHED . "\n AND ezcontentobject_attribute.version = ezcontentobject.current_version\n AND ezcontentobject_tree.main_node_id = ezcontentobject_tree.node_id\n {$pathString}\n {$parentNodeIDSQL}\n {$classIdentifierSQL}\n {$showInvisibleNodesCond}\n {$sqlPermissionChecking['where']}\n {$languageFilter}\n GROUP BY ezkeyword.id, ezkeyword.keyword\n {$orderBySql}", $dbParams);
foreach ($rs as $row) {
$tags[$row['keyword']] = $row['keyword_count'];
}
// To be able to combine count sorting with keyword sorting
// without being limited by sql LIMIT result clipping
if (isset($params['post_sort_by'])) {
if ($params['post_sort_by'] === 'keyword') {
ksort($tags, SORT_LOCALE_STRING);
} else {
if ($params['post_sort_by'] === 'keyword_reverse') {
krsort($tags, SORT_LOCALE_STRING);
} else {
if ($params['post_sort_by'] === 'count') {
asort($tags, SORT_NUMERIC);
} else {
if ($params['post_sort_by'] === 'count_reverse') {
arsort($tags, SORT_NUMERIC);
}
}
}
}
}
$maxFontSize = 200;
$minFontSize = 100;
$maxCount = 0;
$minCount = 0;
if (count($tags) != 0) {
$maxCount = max(array_values($tags));
$minCount = min(array_values($tags));
}
$spread = $maxCount - $minCount;
if ($spread == 0) {
$spread = 1;
}
$step = ($maxFontSize - $minFontSize) / $spread;
foreach ($tags as $key => $value) {
$size = $minFontSize + ($value - $minCount) * $step;
//.........这里部分代码省略.........
示例4: modify
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'], $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');
$pageDepth = isset($moduleResult['path']) ? count($moduleResult['path']) : 0;
$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'] = $pageDepth;
$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 = '';
}
// Get custom template_look object. false|eZContentObject (set as parameter from caller)
if (isset($parameters['template_look'])) {
$pageData['template_look'] = $parameters['template_look'];
} else {
// Get template_look eZContentObject
if (!isset($parameters['template_look_class'])) {
$parameters['template_look_class'] = 'template_look';
}
$templateLookClassID = eZContentObjectTreeNode::classIDByIdentifier($parameters['template_look_class']);
$templateLookObjectList = eZContentObject::fetchFilteredList(array('contentclass_id' => $templateLookClassID), 0, 1);
if ($templateLookObjectList) {
$pageData['template_look'] = $templateLookObjectList[0];
//.........这里部分代码省略.........
示例5: tagCloud
/**
* Returns the tag cloud for specified parameters using eZ Publish database
*
* @param array $params
*
* @return array
*/
private function tagCloud($params)
{
$parentNodeID = 0;
$classIdentifier = '';
$classIdentifierSQL = '';
$pathString = '';
$parentNodeIDSQL = '';
$dbParams = array();
$orderBySql = 'ORDER BY eztags.keyword ASC';
if (isset($params['class_identifier'])) {
$classIdentifier = $params['class_identifier'];
}
if (isset($params['parent_node_id'])) {
$parentNodeID = $params['parent_node_id'];
}
if (isset($params['limit'])) {
$dbParams['limit'] = $params['limit'];
}
if (isset($params['offset'])) {
$dbParams['offset'] = $params['offset'];
}
if (isset($params['sort_by']) && is_array($params['sort_by']) && !empty($params['sort_by'])) {
$orderBySql = 'ORDER BY ';
$orderArr = is_string($params['sort_by'][0]) ? array($params['sort_by']) : $params['sort_by'];
foreach ($orderArr as $key => $order) {
if ($key !== 0) {
$orderBySql .= ', ';
}
$direction = isset($order[1]) ? $order[1] : false;
switch ($order[0]) {
case 'keyword':
$orderBySql .= 'eztags.keyword ' . ($direction ? 'ASC' : 'DESC');
break;
case 'count':
$orderBySql .= 'keyword_count ' . ($direction ? 'ASC' : 'DESC');
break;
}
}
}
$db = eZDB::instance();
if ($classIdentifier) {
$classID = eZContentObjectTreeNode::classIDByIdentifier($classIdentifier);
$classIdentifierSQL = "AND ezcontentobject.contentclass_id = '" . $classID . "'";
}
if ($parentNodeID) {
$node = eZContentObjectTreeNode::fetch($parentNodeID);
if ($node) {
$pathString = "AND ezcontentobject_tree.path_string like '" . $node->attribute('path_string') . "%'";
}
$parentNodeIDSQL = "AND ezcontentobject_tree.node_id != " . (int) $parentNodeID;
}
$showInvisibleNodesCond = eZContentObjectTreeNode::createShowInvisibleSQLString(true, false);
$limitation = false;
$limitationList = eZContentObjectTreeNode::getLimitationList($limitation);
$sqlPermissionChecking = eZContentObjectTreeNode::createPermissionCheckingSQL($limitationList);
$languageFilter = 'AND ' . eZContentLanguage::languagesSQLFilter('ezcontentobject');
$languageFilter .= 'AND ' . eZContentLanguage::languagesSQLFilter('ezcontentobject_attribute', 'language_id');
$rs = $db->arrayQuery("SELECT eztags.id, eztags.keyword, COUNT(DISTINCT ezcontentobject.id) AS keyword_count\n FROM eztags_attribute_link\n LEFT JOIN ezcontentobject_attribute\n ON eztags_attribute_link.objectattribute_id = ezcontentobject_attribute.id\n AND eztags_attribute_link.objectattribute_version = ezcontentobject_attribute.version\n LEFT JOIN ezcontentobject\n ON ezcontentobject_attribute.contentobject_id = ezcontentobject.id\n LEFT JOIN ezcontentobject_tree\n ON ezcontentobject_attribute.contentobject_id = ezcontentobject_tree.contentobject_id\n LEFT JOIN eztags\n ON eztags.id = eztags_attribute_link.keyword_id\n LEFT JOIN eztags_keyword\n ON eztags.id = eztags_keyword.keyword_id\n {$sqlPermissionChecking['from']}\n WHERE " . eZContentLanguage::languagesSQLFilter('eztags') . "\n AND " . eZContentLanguage::sqlFilter('eztags_keyword', 'eztags') . "\n AND ezcontentobject.status = " . eZContentObject::STATUS_PUBLISHED . "\n AND ezcontentobject_attribute.version = ezcontentobject.current_version\n AND ezcontentobject_tree.main_node_id = ezcontentobject_tree.node_id\n {$pathString}\n {$parentNodeIDSQL}\n {$classIdentifierSQL}\n {$showInvisibleNodesCond}\n {$sqlPermissionChecking['where']}\n {$languageFilter}\n GROUP BY eztags.id, eztags.keyword\n {$orderBySql}", $dbParams);
$tagsCountList = array();
foreach ($rs as $row) {
$tagsCountList[$row['id']] = $row['keyword_count'];
}
/** @var eZTagsObject[] $tagObjects */
$tagObjects = eZTagsObject::fetchList(array('id' => array(array_keys($tagsCountList))));
if (!is_array($tagObjects) || empty($tagObjects)) {
return array();
}
$tagSortArray = array();
$tagKeywords = array();
$tagCounts = array();
foreach ($tagObjects as $tag) {
$tagKeyword = $tag->attribute('keyword');
$tagCount = $tagsCountList[$tag->attribute('id')];
$tagSortArray[] = array('keyword' => $tagKeyword, 'count' => $tagCount, 'tag' => $tag);
$tagKeywords[] = $tagKeyword;
$tagCounts[] = $tagCount;
}
if (isset($params['post_sort_by'])) {
if ($params['post_sort_by'] === 'keyword') {
array_multisort($tagKeywords, SORT_ASC, SORT_LOCALE_STRING, $tagSortArray);
} else {
if ($params['post_sort_by'] === 'keyword_reverse') {
array_multisort($tagKeywords, SORT_DESC, SORT_LOCALE_STRING, $tagSortArray);
} else {
if ($params['post_sort_by'] === 'count') {
array_multisort($tagCounts, SORT_ASC, SORT_NUMERIC, $tagSortArray);
} else {
if ($params['post_sort_by'] === 'count_reverse') {
array_multisort($tagCounts, SORT_DESC, SORT_NUMERIC, $tagSortArray);
}
}
}
}
//.........这里部分代码省略.........
示例6: modify
function modify($tpl, $operatorName, $operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters)
{
switch ($operatorName) {
case 'eztagcloud':
/*
$tags = array();
$tagCloud = array();
$parentNodeID = 0;
$classID = '';
$classIdentifier = '';
$classIdentifierSQL = '';
$pathString = '';
$parentNodeIDSQL = '';
if ( isset( $namedParameters['params']['class_identifier'] ) )
$classIdentifier = $namedParameters['params']['class_identifier'];
if ( isset( $namedParameters['params']['parent_node_id'] ) )
$parentNodeID = $namedParameters['params']['parent_node_id'];
if ( isset( $namedParameters['params']['limit'] ) )
$tagCloudLimit = $namedParameters['params']['limit'];
else
$tagCloudLimit = 25;
include_once( 'lib/ezdb/classes/ezdb.php' );
$db = eZDB::instance();
if( $classIdentifier )
{
$classID = eZContentObjectTreeNode::classIDByIdentifier( $classIdentifier );
$classIdentifierSQL = "AND ezcontentobject.contentclass_id = $classID";
}
if( $parentNodeID )
{
$node = eZContentObjectTreeNode::fetch( $parentNodeID );
if ( $node )
$pathString = "AND ezcontentobject_tree.path_string like '" . $node->attribute( 'path_string' ) . "%'";
$parentNodeIDSQL = "AND ezcontentobject_tree.node_id != " . (int)$parentNodeID;
}
$showInvisibleNodesCond = eZContentObjectTreeNode::createShowInvisibleSQLString( true, false );
$limitation = false;
$limitationList = eZContentObjectTreeNode::getLimitationList( $limitation );
$sqlPermissionChecking = eZContentObjectTreeNode::createPermissionCheckingSQL( $limitationList );
$versionNameJoins = " AND ezcontentobject_tree.contentobject_id = ezcontentobject_name.contentobject_id AND
ezcontentobject_tree.contentobject_version = ezcontentobject_name.content_version AND ";
$languageFilter = " AND " . eZContentLanguage::languagesSQLFilter( 'ezcontentobject' );
$versionNameJoins .= eZContentLanguage::sqlFilter( 'ezcontentobject_name', 'ezcontentobject' );
$rs = $db->arrayQuery( "SELECT DISTINCT ezkeyword.keyword
FROM ezkeyword,
ezkeyword_attribute_link,
ezcontentobject,
ezcontentobject_name,
ezcontentobject_attribute,
ezcontentobject_tree
$sqlPermissionChecking[from]
WHERE ezkeyword.id = ezkeyword_attribute_link.keyword_id
AND ezkeyword_attribute_link.objectattribute_id = ezcontentobject_attribute.id
AND ezcontentobject_attribute.contentobject_id = ezcontentobject_tree.contentobject_id
AND ezcontentobject.status = '".eZContentObject::STATUS_PUBLISHED."'
AND ezcontentobject_attribute.version = ezcontentobject.current_version
AND ezcontentobject_tree.main_node_id = ezcontentobject_tree.node_id
$pathString
$parentNodeIDSQL
$classIdentifierSQL
$showInvisibleNodesCond
$sqlPermissionChecking[where]
$languageFilter
$versionNameJoins
ORDER BY ezkeyword.keyword ASC" );
include_once ('lib/ezutils/classes/ezfunctionhandler.php');
foreach( $rs as $row )
{
$tags[$row['keyword']] = eZFunctionHandler::execute( 'content', 'keyword_count', array( 'alphabet' => $row['keyword'],
'strict_matching' => true,
'classid' => $classID ) );
}
$maxFontSize = 180;
$minFontSize = 90;
$maxCount = 0;
$minCount = 0;
if( count( $tags ) != 0 )
{
$maxCount = max( array_values( $tags ) );
$minCount = min( array_values($tags ) );
}
$spread = $maxCount - $minCount;
if ( $spread == 0 )
$spread = 1;
//.........这里部分代码省略.........
示例7: modify
function modify($tpl, $operatorName, $operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters)
{
switch ($operatorName) {
case 'eztagcloud':
$tags = array();
$tagCloud = array();
$parentNodeID = 0;
$classIdentifier = '';
$classIdentifierSQL = '';
$pathString = '';
$parentNodeIDSQL = '';
$dbParams = array();
$params = $namedParameters['params'];
$orderBySql = 'ORDER BY ezkeyword.keyword ASC';
if (isset($params['class_identifier'])) {
$classIdentifier = $params['class_identifier'];
}
if (isset($params['parent_node_id'])) {
$parentNodeID = $params['parent_node_id'];
}
if (isset($params['limit'])) {
$dbParams['limit'] = $params['limit'];
}
if (isset($params['offset'])) {
$dbParams['offset'] = $params['offset'];
}
if (isset($params['sort_by']) && is_array($params['sort_by']) && count($params['sort_by'])) {
$orderBySql = 'ORDER BY ';
$orderArr = is_string($params['sort_by'][0]) ? array($params['sort_by']) : $params['sort_by'];
foreach ($orderArr as $key => $order) {
if ($key !== 0) {
$orderBySql .= ', ';
}
$direction = isset($order[1]) ? $order[1] : false;
switch ($order[0]) {
case 'keyword':
$orderBySql .= 'ezkeyword.keyword ' . ($direction ? 'ASC' : 'DESC');
break;
case 'count':
$orderBySql .= 'keyword_count ' . ($direction ? 'ASC' : 'DESC');
break;
}
}
}
$db = eZDB::instance();
if ($classIdentifier) {
$classID = eZContentObjectTreeNode::classIDByIdentifier($classIdentifier);
$classIdentifierSQL = "AND ezcontentobject.contentclass_id = '" . $classID . "'";
}
if ($parentNodeID) {
$node = eZContentObjectTreeNode::fetch($parentNodeID);
if ($node) {
$pathString = "AND ezcontentobject_tree.path_string like '" . $node->attribute('path_string') . "%'";
}
$parentNodeIDSQL = 'AND ezcontentobject_tree.node_id != ' . (int) $parentNodeID;
}
$showInvisibleNodesCond = eZContentObjectTreeNode::createShowInvisibleSQLString(true, false);
$limitation = false;
$limitationList = eZContentObjectTreeNode::getLimitationList($limitation);
$sqlPermissionChecking = eZContentObjectTreeNode::createPermissionCheckingSQL($limitationList);
$languageFilter = 'AND ' . eZContentLanguage::languagesSQLFilter('ezcontentobject');
$rs = $db->arrayQuery("SELECT ezkeyword.keyword, count(*) as keyword_count\n FROM ezkeyword,\n ezkeyword_attribute_link,\n ezcontentobject,\n ezcontentobject_attribute,\n ezcontentobject_tree\n {$sqlPermissionChecking['from']}\n WHERE ezkeyword.id = ezkeyword_attribute_link.keyword_id\n AND ezkeyword_attribute_link.objectattribute_id = ezcontentobject_attribute.id\n AND ezcontentobject_attribute.contentobject_id = ezcontentobject_tree.contentobject_id\n AND ezcontentobject_attribute.contentobject_id = ezcontentobject.id\n AND ezcontentobject.status = " . eZContentObject::STATUS_PUBLISHED . "\n AND ezcontentobject_attribute.version = ezcontentobject.current_version\n AND ezcontentobject_tree.main_node_id = ezcontentobject_tree.node_id\n {$pathString}\n {$parentNodeIDSQL}\n {$classIdentifierSQL}\n {$showInvisibleNodesCond}\n {$sqlPermissionChecking['where']}\n {$languageFilter}\n GROUP BY ezkeyword.id, ezkeyword.keyword\n {$orderBySql}", $dbParams);
foreach ($rs as $row) {
$tags[$row['keyword']] = $row['keyword_count'];
}
$maxFontSize = 200;
$minFontSize = 100;
$maxCount = 0;
$minCount = 0;
if (count($tags) != 0) {
$maxCount = max(array_values($tags));
$minCount = min(array_values($tags));
}
$spread = $maxCount - $minCount;
if ($spread == 0) {
$spread = 1;
}
$step = ($maxFontSize - $minFontSize) / $spread;
// stevo - combine lower/upper case
$realTags = array();
$realkey = '';
foreach ($tags as $key => $value) {
$key = strtolower($key);
if (isset($realTags[$key])) {
$realTags[$key] += $value;
} else {
$realTags[$key] = $value;
}
}
// stevo - add minimum tag count option
$min = isset($params['min']) ? $params['min'] : 0;
//$minCount -= $min;
foreach ($realTags as $key => $value) {
if ($value > $min) {
$size = $minFontSize + ($value - $minCount) * $step;
$tagCloud[] = array('font_size' => $size, 'count' => $value, 'tag' => $key);
}
}
require_once 'kernel/common/template.php';
$tpl = templateInit();
//.........这里部分代码省略.........