本文整理汇总了PHP中eZDataType类的典型用法代码示例。如果您正苦于以下问题:PHP eZDataType类的具体用法?PHP eZDataType怎么用?PHP eZDataType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eZDataType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: unserializeContentClassAttribute
$options = $domRoot->getElementsByTagName('options')->item(0);
$dom = $attributeParametersNode->ownerDocument;
$importedOptionsNode = $dom->importNode($options, true);
$attributeParametersNode->appendChild($importedOptionsNode);
$isMultiSelectNode = $dom->createElement('is-multiselect');
$isMultiSelectNode->appendChild($dom->createTextNode($isMultipleSelection));
$attributeParametersNode->appendChild($isMultiSelectNode);
}
function unserializeContentClassAttribute($classAttribute, $attributeNode, $attributeParametersNode)
{
$options = $attributeParametersNode->getElementsByTagName('options')->item(0);
$doc = new DOMDocument('1.0', 'utf-8');
$root = $doc->createElement('ezselection');
$doc->appendChild($root);
$importedOptions = $doc->importNode($options, true);
$root->appendChild($importedOptions);
$xml = $doc->saveXML();
$classAttribute->setAttribute('data_text5', $xml);
if ($attributeParametersNode->getElementsByTagName('is-multiselect')->item(0)->textContent == 0) {
$classAttribute->setAttribute('data_int1', 0);
} else {
$classAttribute->setAttribute('data_int1', 1);
}
}
function supportsBatchInitializeObjectAttribute()
{
return true;
}
}
eZDataType::register(eZSelectionType::DATA_TYPE_STRING, "eZSelectionType");
示例4: substr
$content->setAttribute('alternative_text', substr($string, $delimiterPos + 1));
}
$content->store($objectAttribute);
return true;
}
function supportsBatchInitializeObjectAttribute()
{
return true;
}
/**
* Iterates over images referenced in data_text, and adds eZImageFile references
* @param eZContentObjectAttribute $objectAttribute
*/
function postStore($objectAttribute)
{
$objectAttributeId = $objectAttribute->attribute("id");
if (($doc = simplexml_load_string($objectAttribute->attribute("data_text"))) === false) {
return;
}
// Creates ezimagefile entries
foreach ($doc->xpath("//*/@url") as $url) {
$url = (string) $url;
if ($url === "") {
continue;
}
eZImageFile::appendFilepath($objectAttributeId, $url, true);
}
}
}
eZDataType::register(eZImageType::DATA_TYPE_STRING, "eZImageType");
示例5: serializeContentClassAttribute
function serializeContentClassAttribute($classAttribute, $attributeNode, $attributeParametersNode)
{
$defaultValue = $classAttribute->attribute('data_text1');
$dom = $attributeParametersNode->ownerDocument;
$defaultValueNode = $dom->createElement('default-value');
$defaultValueNode->appendChild($dom->createTextNode($defaultValue));
$attributeParametersNode->appendChild($defaultValueNode);
}
function unserializeContentClassAttribute($classAttribute, $attributeNode, $attributeParametersNode)
{
$defaultValue = $attributeParametersNode->getElementsByTagName('default-value')->item(0)->textContent;
$classAttribute->setAttribute('data_text1', $defaultValue);
}
function serializeContentObjectAttribute($package, $objectAttribute)
{
$node = $this->createContentObjectAttributeDOMNode($objectAttribute);
$dom = new DOMDocument('1.0', 'utf-8');
$success = $dom->loadXML($objectAttribute->attribute('data_text'));
$importedRoot = $node->ownerDocument->importNode($dom->documentElement, true);
$node->appendChild($importedRoot);
return $node;
}
function unserializeContentObjectAttribute($package, $objectAttribute, $attributeNode)
{
$rootNode = $attributeNode->getElementsByTagName('ezmultioption')->item(0);
$xmlString = $rootNode ? $rootNode->ownerDocument->saveXML($rootNode) : '';
$objectAttribute->setAttribute('data_text', $xmlString);
}
}
eZDataType::register(eZMultiOptionType::DATA_TYPE_STRING, "eZMultiOptionType");
示例6: objectDisplayInformation
/**
* Sets grouped_input to true for edit view of the datatype
*
* @param eZContentObjectAttribute $objectAttribute
* @param array|bool $mergeInfo
*
* @return array
*/
public function objectDisplayInformation($objectAttribute, $mergeInfo = false)
{
return eZDataType::objectDisplayInformation($objectAttribute, array('edit' => array('grouped_input' => true)));
}
示例7: __construct
/**
* Constructor
*/
public function __construct()
{
parent::eZDataType(self::DATA_TYPE_STRING, 'AC Color picker');
}
示例8: contentActionList
break;
case 'current-date':
$classAttribute->setAttribute(self::BIRTHDAY_DEFAULT, self::BIRTHDAY_DEFAULT_CURRENT_DATE);
break;
}
}
/*!
\return the collect information action if enabled
*/
function contentActionList($classAttribute)
{
if ($classAttribute->attribute('is_information_collector') == true) {
return array(array('name' => 'Send', 'action' => 'ActionCollectInformation'));
} else {
return array();
}
}
function isIndexable()
{
return true;
}
/*!
\reimp
*/
function isInformationCollector()
{
return true;
}
}
eZDataType::register(eZBirthdayType::DATA_TYPE_STRING, "ezbirthdaytype");
示例9: __construct
public function __construct()
{
parent::eZDataType(self::DATA_TYPE_STRING, ezpi18n::tr('ezdisqus/datatype', 'Disqus comments'));
}
示例10: customObjectAttributeHTTPAction
function customObjectAttributeHTTPAction($http, $action, $contentObjectAttribute, $parameters)
{
$contentobjectID = false;
if (eZDataType::fetchActionValue($action, 'new_class', $classID) or $action == 'new_class') {
if ($action == 'new_class') {
$base = $parameters['base_name'];
$classVariableName = $base . '_new_class';
if ($http->hasPostVariable($classVariableName)) {
$classVariable = $http->postVariable($classVariableName);
$classID = $classVariable[$contentObjectAttribute->attribute('id')];
$class = eZContentClass::fetch($classID);
} else {
return false;
}
} else {
$class = eZContentClass::fetch($classID);
}
if ($class) {
$classAttribute = $contentObjectAttribute->attribute('contentclass_attribute');
$class_content = $classAttribute->content();
$content = $contentObjectAttribute->content();
$priority = 0;
for ($i = 0; $i < count($content['relation_list']); ++$i) {
if ($content['relation_list'][$i]['priority'] > $priority) {
$priority = $content['relation_list'][$i]['priority'];
}
}
$base = $parameters['base_name'];
$nodePlacement = false;
$nodePlacementName = $base . '_object_initial_node_placement';
if ($http->hasPostVariable($nodePlacementName)) {
$nodePlacementMap = $http->postVariable($nodePlacementName);
if (isset($nodePlacementMap[$contentObjectAttribute->attribute('id')])) {
$nodePlacement = $nodePlacementMap[$contentObjectAttribute->attribute('id')];
}
}
$relationItem = $this->createInstance($class, $priority + 1, $contentObjectAttribute, $nodePlacement);
if ($class_content['default_placement']) {
$relationItem['parent_node_id'] = $class_content['default_placement']['node_id'];
}
$content['relation_list'][] = $relationItem;
$hasAttributeInput = false;
$attributeInputVariable = $base . '_has_attribute_input';
if ($http->hasPostVariable($attributeInputVariable)) {
$attributeInputMap = $http->postVariable($attributeInputVariable);
if (isset($attributeInputMap[$contentObjectAttribute->attribute('id')])) {
$hasAttributeInput = $attributeInputMap[$contentObjectAttribute->attribute('id')];
}
}
if ($hasAttributeInput) {
$object = $relationItem['object'];
$attributes = $object->contentObjectAttributes();
foreach ($attributes as $attribute) {
$attributeBase = $base . '_ezorl_init_class_' . $object->attribute('contentclass_id') . '_attr_' . $attribute->attribute('contentclassattribute_id');
$oldAttributeID = $attribute->attribute('id');
$attribute->setAttribute('id', false);
if ($attribute->fetchInput($http, $attributeBase)) {
$attribute->setAttribute('id', $oldAttributeID);
$attribute->store();
}
}
}
$contentObjectAttribute->setContent($content);
$contentObjectAttribute->store();
} else {
eZDebug::writeError("Unknown class ID {$classID}, cannot instantiate object", __METHOD__);
}
} else {
if (eZDataType::fetchActionValue($action, 'edit_objects', $contentobjectID) or $action == 'edit_objects' or $action == 'remove_objects') {
$base = $parameters['base_name'];
$selectionBase = $base . '_selection';
$selections = array();
$http = eZHTTPTool::instance();
if ($http->hasPostVariable($selectionBase)) {
$selectionMap = $http->postVariable($selectionBase);
$selections = $selectionMap[$contentObjectAttribute->attribute('id')];
}
if ($contentobjectID !== false) {
$selections[] = $contentobjectID;
}
if ($action == 'edit_objects' or eZDataType::fetchActionValue($action, 'edit_objects', $contentobjectID)) {
$content = $contentObjectAttribute->content();
foreach ($content['relation_list'] as $key => $relationItem) {
if (!$relationItem['is_modified'] and in_array($relationItem['contentobject_id'], $selections)) {
$object = eZContentObject::fetch($relationItem['contentobject_id']);
if ($object->attribute('can_edit')) {
$content['relation_list'][$key]['is_modified'] = true;
$translationSourceBase = $base . '_translation_source_' . $contentObjectAttribute->attribute('id') . '_' . $relationItem['contentobject_id'];
$languageFrom = false;
if ($http->hasPostVariable($translationSourceBase) && $http->postVariable($translationSourceBase) !== '') {
$languageFrom = $http->postVariable($translationSourceBase);
}
$version = $object->createNewVersionIn($contentObjectAttribute->attribute('language_code'), $languageFrom);
$content['relation_list'][$key]['contentobject_version'] = $version->attribute('version');
}
}
}
$contentObjectAttribute->setContent($content);
$contentObjectAttribute->store();
} else {
//.........这里部分代码省略.........
示例11: 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';
//.........这里部分代码省略.........
示例12: title
$contentObjectAttribute->setAttribute('data_int', $category->attribute('id'));
return true;
}
}
return false;
}
/*!
Returns the integer value.
*/
function title($contentObjectAttribute, $name = null)
{
$categoryID = $contentObjectAttribute->attribute("data_int");
$category = $categoryID > 0 ? eZProductCategory::fetch($categoryID) : false;
return is_object($category) ? $category->attribute('name') : '';
}
function diff($old, $new, $options = null)
{
return null;
}
function supportsBatchInitializeObjectAttribute()
{
return true;
}
function batchInitializeObjectAttributeData($classAttribute)
{
$default = 0;
return array('data_int' => $default, 'sort_key_int' => $default);
}
}
eZDataType::register(eZProductCategoryType::DATA_TYPE_STRING, "eZProductCategoryType");
示例13: initializePackage
//.........这里部分代码省略.........
if ($result) {
$schemaArray = array_merge($schemaArray, $dataArray);
$schemaArray['type'] = strtolower($db->databaseName());
$schemaArray['instance'] = $db;
$result = true;
$dbSchema = eZDbSchema::instance($schemaArray);
if (!$dbSchema) {
$resultArray['errors'][] = array('code' => 'EZSW-003', 'text' => "Failed loading " . $db->databaseName() . " schema handler");
$result = false;
}
if ($result) {
$result = true;
// This will insert the schema, then the data and
// run any sequence value correction SQL if required
$params = array('schema' => true, 'data' => true);
if ($db->databaseName() == 'mysql') {
$engines = $db->arrayQuery('SHOW ENGINES');
foreach ($engines as $engine) {
if ($engine['Engine'] == 'InnoDB' && in_array($engine['Support'], array('YES', 'DEFAULT'))) {
$params['table_type'] = 'innodb';
break;
}
}
}
if (!$dbSchema->insertSchema($params)) {
$resultArray['errors'][] = array('code' => 'EZSW-004', 'text' => "Failed inserting data to " . $db->databaseName() . "\n" . $db->errorMessage());
$result = false;
}
}
}
}
if ($result) {
// Inserting data from the dba-data files of the datatypes
eZDataType::loadAndRegisterAllTypes();
$registeredDataTypes = eZDataType::registeredDataTypes();
foreach ($registeredDataTypes as $dataType) {
if (!$dataType->importDBDataFromDBAFile()) {
$resultArray['errors'][] = array('code' => 'EZSW-002', 'text' => "Failed importing datatype related data into database: \n" . 'datatype - ' . $dataType->DataTypeString . ", \n" . 'dba-data file - ' . $dataType->getDBAFilePath());
}
}
}
}
if (!$result) {
return false;
}
// Database initialization done
// Prepare languages
$primaryLanguageLocaleCode = $primaryLanguage->localeCode();
$primaryLanguageName = $primaryLanguage->languageName();
$prioritizedLanguages = array_merge(array($primaryLanguageLocaleCode), $extraLanguageCodes);
$installParameters = array('path' => '.');
$installParameters['ini'] = array();
$siteINIChanges = array();
$url = $siteType['url'];
if (preg_match("#^[a-zA-Z0-9]+://(.*)\$#", $url, $matches)) {
$url = $matches[1];
}
$siteINIChanges['SiteAccessSettings'] = array('RelatedSiteAccessList' => $accessMap['accesses']);
$siteINIChanges['ContentSettings'] = array('TranslationList' => implode(';', $extraLanguageCodes));
$siteINIChanges['SiteSettings'] = array('SiteName' => $siteType['title'], 'SiteURL' => $url);
$siteINIChanges['DatabaseSettings'] = array('DatabaseImplementation' => $dbDriver, 'Server' => $dbServer, 'Port' => $dbPort, 'Database' => $dbName, 'User' => $dbUser, 'Password' => $dbPwd, 'Charset' => false);
$siteINIChanges['FileSettings'] = array('VarDir' => 'var/' . $siteType['identifier']);
if (trim($dbSocket) != '') {
$siteINIChanges['DatabaseSettings']['Socket'] = $dbSocket;
} else {
$siteINIChanges['DatabaseSettings']['Socket'] = 'disabled';
示例14: objectDisplayInformation
function objectDisplayInformation($objectAttribute, $mergeInfo = false)
{
$classAttribute = $objectAttribute->contentClassAttribute();
$isOption = $classAttribute->attribute('data_int2');
$editGrouped = $isOption == false;
$info = array('edit' => array('grouped_input' => $editGrouped), 'collection' => array('grouped_input' => $editGrouped));
return eZDataType::objectDisplayInformation($objectAttribute, $info);
}
示例15: hasObjectAttributeContent
return $contentObjectAttribute->attribute("data_int");
}
function hasObjectAttributeContent($contentObjectAttribute)
{
return true;
}
function serializeContentClassAttribute($classAttribute, $attributeNode, $attributeParametersNode)
{
$defaultValue = $classAttribute->attribute('data_int3');
$dom = $attributeParametersNode->ownerDocument;
$defaultValueNode = $dom->createElement('default-value');
$defaultValueNode->setAttribute('is-set', $defaultValue ? 'true' : 'false');
$attributeParametersNode->appendChild($defaultValueNode);
}
function unserializeContentClassAttribute($classAttribute, $attributeNode, $attributeParametersNode)
{
$defaultValue = strtolower($attributeParametersNode->getElementsByTagName('default-value')->item(0)->getAttribute('is-set')) == 'true';
$classAttribute->setAttribute('data_int3', $defaultValue);
}
function supportsBatchInitializeObjectAttribute()
{
return true;
}
function batchInitializeObjectAttributeData($classAttribute)
{
$default = $classAttribute->attribute("data_int3");
return array('data_int' => $default, 'sort_key_int' => $default);
}
}
eZDataType::register(eZBooleanType::DATA_TYPE_STRING, "eZBooleanType");