本文整理汇总了PHP中eZContentObjectTreeNode::classAttributeIDByIdentifier方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObjectTreeNode::classAttributeIDByIdentifier方法的具体用法?PHP eZContentObjectTreeNode::classAttributeIDByIdentifier怎么用?PHP eZContentObjectTreeNode::classAttributeIDByIdentifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentObjectTreeNode
的用法示例。
在下文中一共展示了eZContentObjectTreeNode::classAttributeIDByIdentifier方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildSortSQL
function buildSortSQL($sortArray)
{
$sortCount = 0;
$sortList = false;
if (isset($sortArray) and is_array($sortArray) and count($sortArray) > 0) {
$sortList = $sortArray;
if (count($sortList) > 1 and !is_array($sortList[0])) {
$sortList = array($sortList);
}
}
$attributeJoinCount = 0;
$attributeFromSQL = "";
$attributeWereSQL = "";
$selectSQL = '';
if ($sortList !== false) {
$sortingFields = '';
foreach ($sortList as $sortBy) {
if (is_array($sortBy) and count($sortBy) > 0) {
if ($sortCount > 0) {
$sortingFields .= ', ';
}
$sortField = $sortBy[0];
switch ($sortField) {
case 'path':
$sortingFields .= 'path_string';
break;
case 'published':
$sortingFields .= 'ezcontentobject.published';
break;
case 'modified':
$sortingFields .= 'ezcontentobject.modified';
break;
case 'section':
$sortingFields .= 'ezcontentobject.section_id';
break;
case 'depth':
$sortingFields .= 'depth';
break;
case 'class_identifier':
$sortingFields .= 'ezcontentclass.identifier';
$selectSQL .= ', ezcontentclass.identifier';
break;
case 'class_name':
$classNameFilter = eZContentClassName::sqlFilter();
$selectSQL .= ", " . $classNameFilter['nameField'] . " AS class_name";
$sortingFields .= "class_name";
$attributeFromSQL .= " INNER JOIN {$classNameFilter['from']} ON ({$classNameFilter['where']})";
break;
case 'priority':
$sortingFields .= 'ezcontentobject_tree.priority';
break;
case 'name':
$sortingFields .= 'ezcontentobject_name.name';
break;
case 'attribute':
$sortClassID = $sortBy[2];
// Look up datatype for sorting
if (!is_numeric($sortClassID)) {
$sortClassID = eZContentObjectTreeNode::classAttributeIDByIdentifier($sortClassID);
}
$sortDataType = $sortClassID === false ? false : eZContentObjectTreeNode::sortKeyByClassAttributeID($sortClassID);
$sortKey = false;
if ($sortDataType == 'string') {
$sortKey = 'sort_key_string';
} else {
$sortKey = 'sort_key_int';
}
$sortingFields .= "a{$attributeJoinCount}.{$sortKey}";
$attributeFromSQL .= " INNER JOIN ezcontentobject_attribute as a{$attributeJoinCount} ON (a{$attributeJoinCount}.contentobject_id = ezcontentobject.id AND a{$attributeJoinCount}.version = ezcontentobject_name.content_version)";
$attributeWereSQL .= " AND a{$attributeJoinCount}.contentclassattribute_id = {$sortClassID}";
$selectSQL .= ", a{$attributeJoinCount}.{$sortKey}";
$attributeJoinCount++;
break;
default:
eZDebug::writeWarning('Unknown sort field: ' . $sortField, __METHOD__);
continue;
}
$sortOrder = true;
// true is ascending
if (isset($sortBy[1])) {
$sortOrder = $sortBy[1];
}
$sortingFields .= $sortOrder ? " ASC" : " DESC";
++$sortCount;
}
}
}
// Should we sort?
if ($sortCount == 0) {
$sortingFields = " ezcontentobject.published ASC";
}
return array('sortingFields' => $sortingFields, 'selectSQL' => $selectSQL, 'fromSQL' => $attributeFromSQL, 'whereSQL' => $attributeWereSQL);
}
示例2: array
$script = eZScript::instance($scriptSettings);
$script->startup();
$config = '[preview]';
$argumentConfig = '[ATTRIBUTE_ID]';
$optionHelp = array('preview' => 'show a preview, do not really make changes');
$arguments = false;
$useStandardOptions = true;
$options = $script->getOptions($config, $argumentConfig, $optionHelp, $arguments, $useStandardOptions);
$script->initialize();
if (count($options['arguments']) != 1) {
$script->shutdown(1, 'wrong argument count');
}
$preview = $options['preview'] !== null;
$attributeID = $options['arguments'][0];
if (!is_numeric($attributeID)) {
$attributeID = eZContentObjectTreeNode::classAttributeIDByIdentifier($attributeID);
if ($attributeID === false) {
$script->shutdown(2, 'unknown attribute identifier');
}
}
$classAttribute = eZContentClassAttribute::fetch($attributeID);
if (!is_object($classAttribute)) {
$script->shutdown(3, 'could not find a class attribute with the specified ID');
}
$enum = $classAttribute->attribute('content');
// both datatypes use data_int1 for the multiple flag, so the following code is not necessary
/*
$isMultiple = $enum->attribute( 'enum_ismultiple' );
$classAttribute->setAttribute( 'data_int1', $isMultiple );
*/
//var_dump( $enum );
示例3: createAttributeFilterSQLStrings
//.........这里部分代码省略.........
}
continue 2;
break;
case 'depth':
$filterField = 'depth';
break;
case 'class_identifier':
$filterField = 'ezcontentclass.identifier';
break;
case 'class_name':
$classNameFilter = eZContentClassName::sqlFilter();
$filterField = $classNameFilter['nameField'];
$filterSQL['from'] .= " INNER JOIN {$classNameFilter['from']} ON ({$classNameFilter['where']})";
break;
case 'priority':
$filterField = 'ezcontentobject_tree.priority';
break;
case 'name':
$filterField = 'ezcontentobject_name.name';
break;
case 'owner':
$filterField = 'ezcontentobject.owner_id';
break;
case 'visibility':
$filterValue = $filterValue == '1' ? 0 : 1;
$filterField = 'ezcontentobject_tree.is_invisible';
break;
default:
$useAttributeFilter = true;
break;
}
if ($useAttributeFilter) {
if (!is_numeric($filterAttributeID)) {
$filterAttributeID = eZContentObjectTreeNode::classAttributeIDByIdentifier($filterAttributeID);
}
if ($filterAttributeID === false) {
$isFilterValid = false;
if ($filterJoinType === 'AND') {
// go out
$invalidAttributesFiltersCount = $totalAttributesFiltersCount;
break;
}
++$invalidAttributesFiltersCount;
} else {
// Check datatype for filtering
$filterDataType = eZContentObjectTreeNode::sortKeyByClassAttributeID($filterAttributeID);
if ($filterDataType === false) {
$isFilterValid = false;
if ($filterJoinType === 'AND') {
// go out
$invalidAttributesFiltersCount = $totalAttributesFiltersCount;
break;
}
// check next filter
++$invalidAttributesFiltersCount;
} else {
$sortKey = false;
if ($filterDataType == 'string') {
$sortKey = 'sort_key_string';
} else {
$sortKey = 'sort_key_int';
}
$filterField = "a{$filterCount}.{$sortKey}";
// Use the same joins as we do when sorting,
// if more attributes are filtered by we will append them
if ($filterCount >= $sortingInfo['attributeJoinCount']) {
示例4: fetchReverseRelatedObjectsCount
public static function fetchReverseRelatedObjectsCount($objectID, $attributeID, $allRelations, $ignoreVisibility)
{
if (!is_numeric($objectID)) {
eZDebug::writeError("\$objectID is missing or invalid", __METHOD__);
return false;
}
$object = eZContentObject::fetch($objectID);
if (!$object instanceof eZContentObject) {
eZDebug::writeError("An error occured fetching object #{$objectID}", __METHOD__);
return false;
}
$params = array();
if (isset($ignoreVisibility)) {
$params['IgnoreVisibility'] = $ignoreVisibility;
}
if (!$attributeID) {
$attributeID = 0;
}
if (isset($allRelations)) {
if ($attributeID && !$allRelations) {
$params['AllRelations'] = eZContentFunctionCollection::contentobjectRelationTypeMask(array('attribute'));
} elseif ($allRelations === true) {
$attributeID = false;
} else {
$params['AllRelations'] = eZContentFunctionCollection::contentobjectRelationTypeMask($allRelations);
}
}
if ($attributeID && !is_numeric($attributeID) && !is_bool($attributeID)) {
$attributeID = eZContentObjectTreeNode::classAttributeIDByIdentifier($attributeID);
if (!$attributeID) {
eZDebug::writeError("Can't get class attribute ID by identifier");
return false;
}
}
return array('result' => $object->reverseRelatedObjectCount(false, $attributeID, $params));
}
示例5: getFieldName
/**
* Get solr field name, from base name. The base name may either be a
* meta-data name, or an eZ Publish content class attribute, specified by
* <class identifier>/<attribute identifier>[/<option>]
*
* @param string $baseName Base field name.
* @param boolean $includingClassID conditions the structure of the answer. See return value explanation.
* @param $context is introduced in ez find 2.2 to allow for more optimal sorting, faceting, filtering
*
* @return mixed Internal base name. Returns null if no valid base name was provided.
* If $includingClassID is true, an associative array will be returned, as shown below :
* <code>
* array( 'fieldName' => 'attr_title_t',
* 'contentClassId' => 16 );
* </code>
*/
static function getFieldName( $baseName, $includingClassID = false, $context = 'search' )
{
// If the base name is a meta field, get the correct field name.
if ( eZSolr::hasMetaAttributeType( $baseName, $context ) )
{
return eZSolr::getMetaFieldName( $baseName, $context );
}
else
{
// Get class and attribute identifiers + optional option.
$subattribute = null;
$fieldDef = explode( '/', $baseName );
// Check if content class attribute ID is provided.
if ( is_numeric( $fieldDef[0] ) )
{
if ( count( $fieldDef ) == 1 )
{
$contentClassAttributeID = $fieldDef[0];
}
else if ( count( $fieldDef ) == 2 )
{
list( $contentClassAttributeID, $subattribute ) = $fieldDef;
}
}
else
{
switch( count( $fieldDef ) )
{
case 1:
{
// Return fieldname as is.
return $baseName;
} break;
case 2:
{
// Field def contains class indentifier and class attribute identifier.
list( $classIdentifier, $attributeIdentifier ) = $fieldDef;
} break;
case 3:
{
// Field def contains class indentifier, class attribute identifier and optional specification.
list( $classIdentifier, $attributeIdentifier, $subattribute ) = $fieldDef;
} break;
}
$contentClassAttributeID = eZContentObjectTreeNode::classAttributeIDByIdentifier( $classIdentifier . '/' . $attributeIdentifier );
}
if ( !$contentClassAttributeID )
{
eZDebug::writeNotice( 'Could not get content class from base name: ' . $baseName, __METHOD__ );
return null;
}
$contentClassAttribute = eZContentClassAttribute::fetch( $contentClassAttributeID );
$fieldName = ezfSolrDocumentFieldBase::getFieldName( $contentClassAttribute, $subattribute, $context );
if ( $includingClassID )
{
return array( 'fieldName' => $fieldName,
'contentClassId' => $contentClassAttribute->attribute( 'contentclass_id' ) );
}
else
return $fieldName;
}
}
示例6: geoLocation
public static function geoLocation($params)
{
$return = array();
$latAttributeID = is_numeric($params['attributes']['lat']) === false ? eZContentObjectTreeNode::classAttributeIDByIdentifier($params['attributes']['lat']) : $params['attributes']['lat'];
$lngAttributeID = is_numeric($params['attributes']['lon']) === false ? eZContentObjectTreeNode::classAttributeIDByIdentifier($params['attributes']['lon']) : $params['attributes']['lon'];
if ($latAttributeID !== false && $lngAttributeID !== false) {
$params['lat'] = (double) $params['lat'];
$params['lon'] = (double) $params['lon'];
$latTable = 'lat' . $params['index'];
$lngTable = 'lng' . $params['index'];
$tables = ', ezcontentobject_attribute as ' . $latTable . ', ezcontentobject_attribute as ' . $lngTable;
$locationField = 'data_float';
if (isset($params['location_db_field'])) {
$locationField = $params['location_db_field'];
}
$distanceField = '( ( ACOS( SIN( ' . $latTable . '.' . $locationField . ' * PI() / 180 ) * SIN( ' . $params['lat'] . ' * PI() / 180 ) + COS( ' . $latTable . '.' . $locationField . ' * PI() / 180 ) * COS( ' . $params['lat'] . ' * PI() / 180 ) * COS( ( ' . $lngTable . '.' . $locationField . ' - ' . $params['lon'] . ' ) * PI() / 180 ) ) * 180 / PI() ) * 60 * 1.1515 )';
if (isset($params['distance_measure']) === false || $params['distance_measure'] == 'km') {
$distanceField .= ' * 1.609344';
}
$joins = $latTable . '.contentobject_id = ezcontentobject.id
AND ' . $latTable . '.version = ezcontentobject.current_version
AND ' . $latTable . '.contentclassattribute_id = ' . $latAttributeID . '
AND ' . $lngTable . '.contentobject_id = ezcontentobject.id
AND ' . $lngTable . '.version = ezcontentobject.current_version
AND ' . $lngTable . '.contentclassattribute_id = ' . $lngAttributeID . '
AND ';
if (isset($params['distance'])) {
$joins .= $distanceField . ' < ' . $params['distance'] . ' AND ';
}
$columns = false;
if (isset($params['sort_field'])) {
$columns = ', ' . $distanceField . ' AS ' . $params['sort_field'];
}
$return = array('tables' => $tables, 'joins' => $joins, 'columns' => $columns);
}
return $return;
}
示例7: array
$filepath = $bc->getFullPath();
$filesize = null;
$tracking = false;
break;
case 'file':
case 'pdf':
// we need to check if the pdf is valid
if( isset($dataMap['expiration_duration'])
&& $dataMap['expiration_duration']->hasContent()
&& $dataMap['expiration_duration']->content() > 0 )
{
// we've got an expirable PDF,
// we need to get the parent article(s)
$expirationDuration = $dataMap['expiration_duration']->content();
$relatedArticles = array();
$relatedObjects = $node->object()->reverseRelatedObjectList(false, eZContentObjectTreeNode::classAttributeIDByIdentifier('download_ressource') );
if(!isset($articleId) && count($relatedObjects) > 1)
{
/* @var $Module eZModule */
header('HTTP/1.1 403 Forbidden');
echo "<h1>Forbidden access</h1>\n";
eZExecution::cleanExit();
}
if(isset($articleId))
{
$article = eZContentObjectTreenode::fetch($articleId);
if($article)
{
$dataMap = $article->dataMap();
示例8: getFileApplicationCanRead
/**
* @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;
}
}
示例9: CreateSqlParts
function CreateSqlParts($params)
{
$db =& eZDB::instance();
$tables = array();
$joins = array();
// foreach filtered attribute, we add a join the relation table and filter
// on the attribute ID + object ID
foreach ($params as $param) {
if (!is_array($param)) {
continue;
}
if (!is_numeric($param[0])) {
$classAttributeId = eZContentObjectTreeNode::classAttributeIDByIdentifier($param[0]);
} else {
$classAttributeId = $param[0];
}
// multiple objects ids
if (is_array($param[1])) {
// Patch from Grégory BECUE
// http://ez.no/developer/forum/developer/fetch_and_filter_on_object_relations/re_fetch_and_filter_on_object_relations__2
// Handle 'or' parameters
if ($param[2] == 'or') {
$cpt = 0;
$chaineCritere = "(";
foreach ($param[1] as $objectId) {
if (is_numeric($objectId)) {
if ($cpt == 0) {
$tableName = 'eor_link_' . $objectId;
$tables[] = 'ezcontentobject_link ' . $tableName;
$joins[] = $tableName . '.from_contentobject_id = ezcontentobject.id';
$joins[] = $tableName . '.from_contentobject_version = ezcontentobject.current_version';
$joins[] = $tableName . '.contentclassattribute_id = ' . $classAttributeId;
$chaineCritere .= $tableName . '.to_contentobject_id = ' . $objectId;
} else {
$chaineCritere .= ' or ' . $tableName . '.to_contentobject_id = ' . $objectId;
}
}
$cpt++;
}
$joins[] = $chaineCritere . ")";
} else {
foreach ($param[1] as $objectId) {
if (is_numeric($objectId)) {
$tableName = 'eor_link_' . $objectId;
$tables[] = 'ezcontentobject_link ' . $tableName;
$joins[] = $tableName . '.from_contentobject_id = ezcontentobject.id';
$joins[] = $tableName . '.from_contentobject_version = ezcontentobject.current_version';
$joins[] = $tableName . '.contentclassattribute_id = ' . $classAttributeId;
$joins[] = $tableName . '.to_contentobject_id = ' . $objectId;
}
}
}
} else {
$objectId = $param[1];
$tableName = 'eor_link_' . $objectId;
$tables[] = 'ezcontentobject_link ' . $tableName;
$joins[] = $tableName . '.from_contentobject_id = ezcontentobject.id';
$joins[] = $tableName . '.from_contentobject_version = ezcontentobject.current_version';
$joins[] = $tableName . '.contentclassattribute_id = ' . $classAttributeId;
$joins[] = $tableName . '.to_contentobject_id = ' . $objectId;
}
}
if (!count($tables) or !count($joins)) {
$tables = $joins = '';
} else {
$tables = "\n, " . implode("\n, ", $tables);
$joins = implode(" AND\n ", $joins) . " AND\n ";
}
return array('tables' => $tables, 'joins' => $joins);
}