本文整理汇总了PHP中eZDataType::create方法的典型用法代码示例。如果您正苦于以下问题:PHP eZDataType::create方法的具体用法?PHP eZDataType::create怎么用?PHP eZDataType::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZDataType
的用法示例。
在下文中一共展示了eZDataType::create方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: solrMetaDataExists
private function solrMetaDataExists( $contentObjectID=0, $attributeIdentifier='', $subattr='' )
{
try
{
$contentObject = eZContentObject::fetch( $contentObjectID );
$dataMap = $contentObject->dataMap();
if ( array_key_exists( $attributeIdentifier, $dataMap ) )
{
$contentObjectAttribute = $dataMap[$attributeIdentifier];
$eZType = eZDataType::create( solrMetaDataType::DATA_TYPE_STRING );
$value = $eZType->getValue( $contentObjectAttribute->ID, $subattr );
return ( ! empty( $value ) );
}
else
{
eZDebug::writeError( 'Object '.$contentObjectID.' has no attribute '.$attributeIdentifier, 'solrMetaDataExists Error' );
}
return false;
}
catch ( Exception $e )
{
eZDebug::writeError( $e, 'solrMetaDataExists Exception' );
return false;
}
}
示例2: getData
/**
* @see ezfSolrDocumentFieldBase::getData()
*/
public function getData()
{
$returnArray = parent::getData();
$contentClassAttributeIdentifier = $this->ContentObjectAttribute->ContentClassAttributeIdentifier;
$eZType = eZDataType::create( $this->ContentObjectAttribute->DataTypeString );
$attributeContent = $eZType->getValues( $this->ContentObjectAttribute->ID );
foreach( $attributeContent as $key => $value )
{
if ( $value > 0 )
{
$suffix = self::getPostFix( $contentClassAttributeIdentifier );
$attribute = 'attr_'.$contentClassAttributeIdentifier.'_'.$key.$suffix;
$returnArray[$attribute] = $value;
}
}
return $returnArray;
}
示例3: array
function &generateOverrideSettingsArray( $siteAccessArray, $minimalTemplateSet )
{
$datatypeHash = array();
$simpleMatchList = array();
$regexpMatchList = array();
foreach ( $siteAccessArray as $siteAccess )
{
$overrideINI = eZINI::instance( 'override.ini', 'settings', null, null, true );
$overrideINI->prependOverrideDir( "siteaccess/$siteAccess", false, 'siteaccess' );
$overrideINI->loadCache();
$matchBlock = false;
$blockMatchArray = array();
foreach( array_keys( $this->NodeObjectArray ) as $nodeID )
{
// Extract some information that will be used
unset( $contentNode, $contentObject, $contentClass );
$contentNode = $this->NodeObjectArray[$nodeID];
$contentObject = $contentNode->attribute( 'object' );
$contentClass = $contentObject->attribute( 'content_class' );
$attributeList = $contentClass->fetchAttributes( false, false, false );
$datatypeList = array();
foreach ( $attributeList as $attribute )
{
$datatypeList[] = $attribute['data_type_string'];
if ( !isset( $datatypeHash[$attribute['data_type_string']] ) )
{
$datatype = eZDataType::create( $attribute['data_type_string'] );
$datatypeHash[$attribute['data_type_string']] = $datatype;
if ( !method_exists( $datatype, 'templateList' ) )
continue;
$templateList = $datatype->templateList();
if ( $templateList === false )
continue;
foreach ( $templateList as $templateMatch )
{
if ( is_string( $templateMatch ) )
{
$simpleMatchList[] = $templateMatch;
}
else if ( is_array( $templateMatch ) )
{
if ( $templateMatch[0] == 'regexp' )
{
$regexpMatchList[] = $templateMatch[1];
}
}
}
}
}
$datatypeText = implode( '|', array_unique( $datatypeList ) );
foreach( array_keys( $overrideINI->groups() ) as $blockName )
{
if ( isset( $blockMatchArray[$blockName] ) )
{
continue;
}
$blockData = $overrideINI->group( $blockName );
$sourceName = $blockData['Source'];
$matchSettings = false;
if ( isset( $blockData['Match'] ) )
$matchSettings = $blockData['Match'];
$matchValue = array();
$validMatch = true;
$hasMatchType = false;
if ( $matchSettings )
{
foreach( array_keys( $matchSettings ) as $matchType )
{
switch( $matchType )
{
case 'object':
{
$hasMatchType = true;
if ( $contentNode->attribute( 'contentobject_id' ) != $matchSettings[$matchType] )
{
$validMatch = false;
}
else
{
$matchValue[$this->OverrideObjectRemoteID] = $contentObject->attribute( 'remote_id' );
}
} break;
case 'node':
{
$hasMatchType = true;
if ( $nodeID != $matchSettings[$matchType] )
{
$validMatch = false;
}
else
{
$matchValue[$this->OverrideNodeRemoteID] = $contentNode->attribute( 'remote_id' );
}
} break;
//.........这里部分代码省略.........
示例4: createSortingSQLStrings
/**
* Creates an array with sorting SQL strings to be appended to a query
*
* @param array|bool $sortList
* @param string $treeTableName
* @param bool $allowCustomColumns
* @return array
*/
static function createSortingSQLStrings($sortList, $treeTableName = 'ezcontentobject_tree', $allowCustomColumns = false)
{
$sortingInfo = array('sortCount' => 0, 'sortingFields' => " path_string ASC", 'attributeJoinCount' => 0, 'attributeFromSQL' => "", 'attributeTargetSQL' => "", 'attributeWhereSQL' => "");
if ($sortList and is_array($sortList) and count($sortList) > 0) {
if (count($sortList) > 1 and !is_array($sortList[0])) {
$sortList = array($sortList);
}
$sortingFields = '';
$sortCount = 0;
$attributeJoinCount = 0;
$stateJoinCount = 0;
$attributeFromSQL = "";
$attributeWhereSQL = "";
$datatypeSortingTargetSQL = "";
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 'path_string':
$sortingFields .= 'path_identification_string';
break;
case 'published':
$sortingFields .= 'ezcontentobject.published';
break;
case 'modified':
$sortingFields .= 'ezcontentobject.modified';
break;
case 'modified_subnode':
$sortingFields .= 'modified_subnode';
break;
case 'section':
$sortingFields .= 'ezcontentobject.section_id';
break;
case 'node_id':
$sortingFields .= $treeTableName . '.node_id';
break;
case 'contentobject_id':
$sortingFields .= 'ezcontentobject.id';
break;
case 'depth':
$sortingFields .= 'depth';
break;
case 'class_identifier':
$sortingFields .= 'ezcontentclass.identifier';
break;
case 'class_name':
$classNameFilter = eZContentClassName::sqlFilter();
$sortingFields .= 'contentclass_name';
$datatypeSortingTargetSQL .= ", {$classNameFilter['nameField']} AS contentclass_name";
$attributeFromSQL .= " INNER JOIN {$classNameFilter['from']} ON ({$classNameFilter['where']})";
break;
case 'priority':
$sortingFields .= $treeTableName . '.priority';
break;
case 'name':
$sortingFields .= 'ezcontentobject_name.name';
break;
case 'attribute':
$classAttributeID = $sortBy[2];
if (!is_numeric($classAttributeID)) {
$classAttributeID = eZContentObjectTreeNode::classAttributeIDByIdentifier($classAttributeID);
}
$contentAttributeTableAlias = "a{$attributeJoinCount}";
$datatypeFromSQL = "ezcontentobject_attribute {$contentAttributeTableAlias}";
$datatypeWhereSQL = "\n {$contentAttributeTableAlias}.contentobject_id = ezcontentobject.id AND\n {$contentAttributeTableAlias}.contentclassattribute_id = {$classAttributeID} AND\n {$contentAttributeTableAlias}.version = ezcontentobject.current_version AND";
$datatypeWhereSQL .= eZContentLanguage::sqlFilter($contentAttributeTableAlias, 'ezcontentobject');
$dataType = eZDataType::create(eZContentObjectTreeNode::dataTypeByClassAttributeID($classAttributeID));
if (is_object($dataType) && $dataType->customSorting()) {
$params = array();
$params['contentobject_attr_id'] = "{$contentAttributeTableAlias}.id";
$params['contentobject_attr_version'] = "{$contentAttributeTableAlias}.version";
$params['table_alias_suffix'] = "{$attributeJoinCount}";
$sql = $dataType->customSortingSQL($params);
$datatypeFromSQL .= " INNER JOIN {$sql['from']} ON ({$sql['where']})";
$datatypeSortingFieldSQL = $sql['sorting_field'];
$datatypeSortingTargetSQL .= ', ' . $sql['sorting_field'];
} else {
// Look up datatype for standard sorting
$sortKeyType = eZContentObjectTreeNode::sortKeyByClassAttributeID($classAttributeID);
switch ($sortKeyType) {
case 'string':
$sortKey = 'sort_key_string';
break;
case 'int':
default:
$sortKey = 'sort_key_int';
//.........这里部分代码省略.........
示例5: cachedInfo
static function cachedInfo()
{
eZExpiryHandler::registerShutdownFunction();
$info = array();
$db = eZDB::instance();
$dbName = md5( $db->DB );
$cacheDir = eZSys::cacheDirectory();
$phpCache = new eZPHPCreator( "$cacheDir", "sortkey_$dbName.php", '', array( 'clustering' => 'sortkey' ) );
$handler = eZExpiryHandler::instance();
$expiryTime = 0;
if ( $handler->hasTimestamp( 'sort-key-cache' ) )
{
$expiryTime = $handler->timestamp( 'sort-key-cache' );
}
if ( $phpCache->canRestore( $expiryTime ) )
{
$info = $phpCache->restore( array( 'sortkey_type_array' => 'sortKeyTypeArray',
'attribute_type_array' => 'attributeTypeArray' ) );
}
else
{
// Fetch all datatypes and id's used
$query = "SELECT id, data_type_string FROM ezcontentclass_attribute";
$attributeArray = $db->arrayQuery( $query );
$attributeTypeArray = array();
$sortKeyTypeArray = array();
foreach ( $attributeArray as $attribute )
{
$attributeTypeArray[$attribute['id']] = $attribute['data_type_string'];
$sortKeyTypeArray[$attribute['data_type_string']] = 0;
}
// Fetch datatype for every unique datatype
foreach ( array_keys( $sortKeyTypeArray ) as $key )
{
unset( $dataType );
$dataType = eZDataType::create( $key );
if( is_object( $dataType ) )
$sortKeyTypeArray[$key] = $dataType->sortKeyType();
}
unset( $dataType );
// Store identifier list to cache file
$phpCache->addVariable( 'sortKeyTypeArray', $sortKeyTypeArray );
$phpCache->addVariable( 'attributeTypeArray', $attributeTypeArray );
$phpCache->store();
$info['sortkey_type_array'] = $sortKeyTypeArray;
$info['attribute_type_array'] = $attributeTypeArray;
}
return $info;
}
示例6: setDataMapInfos
/**
* @param $dataMap : le tableau associatif des attributs d'un objet eZ (tableau d'objets de classe eZContentObjectAttribute)
* @param $attributes : un tableau associatif des attributs à initialiser \
* (clé : attribute_id ; valeur : chaine de caractères utilisé comme paramètre de la méthode 'eZDataType::fromString()')
*
* @return void
*
*/
private static function setDataMapInfos( $dataMap, $attributes )
{
foreach ( $attributes as $key=>$value )
{
if ( isset( $dataMap[strtolower($key)] ) )
{
$contentObjectAttribute = $dataMap[strtolower( $key )];
switch ( $contentObjectAttribute->DataTypeString )
{
case 'ezkeyword':
// cas particulier ezkeyword : contournement bug sur le datatype dans le cas où les mots clés sont vides
$keyword = new eZKeyword();
if ( empty( $value ) )
{
$keyword->setKeywordArray( array() );
}
else
{
$keyword->initializeKeyword( $value );
}
$contentObjectAttribute->setContent( $keyword );
break;
default:
$eZType = eZDataType::create( $contentObjectAttribute->DataTypeString );
$eZType->fromString( $contentObjectAttribute,$value );
break;
}
$contentObjectAttribute->store();
}
}
}