本文整理汇总了PHP中eZContentObject::defaultLanguage方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObject::defaultLanguage方法的具体用法?PHP eZContentObject::defaultLanguage怎么用?PHP eZContentObject::defaultLanguage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentObject
的用法示例。
在下文中一共展示了eZContentObject::defaultLanguage方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: instantiate
function instantiate($userID = false, $sectionID = 0, $versionNumber = false, $languageCode = false, $versionStatus = eZContentObjectVersion::STATUS_INTERNAL_DRAFT)
{
$attributes = $this->fetchAttributes();
if ($userID === false) {
$user = eZUser::currentUser();
$userID = $user->attribute('contentobject_id');
}
if ($languageCode == false) {
$languageCode = eZContentObject::defaultLanguage();
}
$object = eZContentObject::create(ezpI18n::tr("kernel/contentclass", "New %1", null, array($this->name($languageCode))), $this->attribute("id"), $userID, $sectionID, 1, $languageCode);
if ($this->attribute('always_available')) {
$object->setAttribute('language_mask', (int) $object->attribute('language_mask') | 1);
}
$db = eZDB::instance();
$db->begin();
$object->store();
$object->assignDefaultStates();
$object->setName(ezpI18n::tr("kernel/contentclass", "New %1", null, array($this->name($languageCode))), false, $languageCode);
if (!$versionNumber) {
$version = $object->createInitialVersion($userID, $languageCode);
} else {
$version = eZContentObjectVersion::create($object->attribute("id"), $userID, $versionNumber, $languageCode);
}
if ($versionStatus !== false) {
$version->setAttribute('status', $versionStatus);
}
$version->store();
foreach ($attributes as $attribute) {
$attribute->instantiate($object->attribute('id'), $languageCode);
}
if (isset($user) && $user instanceof eZUser && $user->isAnonymous()) {
$createdObjectIDList = eZPreferences::value('ObjectCreationIDList');
if (!$createdObjectIDList) {
$createdObjectIDList = array($object->attribute('id'));
} else {
$createdObjectIDList = unserialize($createdObjectIDList);
$createdObjectIDList[] = $object->attribute('id');
}
eZPreferences::setValue('ObjectCreationIDList', serialize($createdObjectIDList));
}
$db->commit();
return $object;
}
示例2: createFolder
function createFolder( $parentNode, $target )
{
// Grab settings from the ini file:
$webdavINI = eZINI::instance( eZWebDAVContentServer::WEBDAV_INI_FILE );
$folderClassID = $webdavINI->variable( 'FolderSettings', 'FolderClass' );
$languageCode = eZContentObject::defaultLanguage();
$contentObject = eZContentObject::createWithNodeAssignment( $parentNode, $folderClassID, $languageCode );
if ( $contentObject )
{
$db = eZDB::instance();
$db->begin();
$version = $contentObject->version( 1 );
$version->setAttribute( 'status', eZContentObjectVersion::STATUS_DRAFT );
$version->store();
$contentObjectID = $contentObject->attribute( 'id' );
$contentObjectAttributes = $version->contentObjectAttributes();
$contentObjectAttributes[0]->setAttribute( 'data_text', basename( $target ) );
$contentObjectAttributes[0]->store();
$db->commit();
$operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObjectID,
'version' => 1 ) );
return eZWebDAVServer::OK_CREATED;
}
else
{
$this->appendLogEntry( "Not allowed", 'CS:createFolder' );
return eZWebDAVServer::FAILED_FORBIDDEN;
}
}
示例3: createFolder
/**
* Creates a new folder under the given $target path.
*
* @param eZContentObject $parentNode
* @param string $target Eg. 'Folder1'
* @return bool
*/
protected function createFolder($parentNode, $target)
{
// Grab settings from the ini file:
$webdavINI = eZINI::instance(self::WEBDAV_INI_FILE);
$folderClassID = $webdavINI->variable('FolderSettings', 'FolderClass');
$languageCode = eZContentObject::defaultLanguage();
$contentObject = eZContentObject::createWithNodeAssignment($parentNode, $folderClassID, $languageCode);
if ($contentObject) {
$db = eZDB::instance();
$db->begin();
$version = $contentObject->version(1);
$version->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT);
$version->store();
$contentObjectID = $contentObject->attribute('id');
$contentObjectAttributes = $version->contentObjectAttributes();
// @todo @as avoid using [0] (could be another index in some classes)
$contentObjectAttributes[0]->setAttribute('data_text', basename($target));
$contentObjectAttributes[0]->store();
$db->commit();
$operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $contentObjectID, 'version' => 1));
return true;
// @as self::OK_CREATED;
} else {
return false;
// @as self::FAILED_FORBIDDEN;
}
}
示例4: create
/**
* Creates a new content object instance and stores it.
*
* @param string $name
* @param int $contentclassID
* @param int $userID
* @param int $sectionID
* @param int $version
* @param string|bool $languageCode
* @return eZContentObject
*/
static function create( $name, $contentclassID, $userID, $sectionID = 1, $version = 1, $languageCode = false )
{
if ( $languageCode == false )
{
$languageCode = eZContentObject::defaultLanguage();
}
$languageID = eZContentLanguage::idByLocale( $languageCode );
$row = array(
"name" => $name,
"current_version" => $version,
'initial_language_id' => $languageID,
'language_mask' => $languageID,
"contentclass_id" => $contentclassID,
"permission_id" => 1,
"parent_id" => 0,
"main_node_id" => 0,
"owner_id" => $userID,
"section_id" => $sectionID,
'remote_id' => eZRemoteIdUtility::generate( 'object' ) );
return new eZContentObject( $row );
}
示例5: handleUpload
//.........这里部分代码省略.........
}
}
$fileAttribute = $this->findHTTPFileAttribute($dataMap, $fileAttribute);
if (!$fileAttribute) {
$result['errors'][] = array('description' => ezpI18n::tr('kernel/content/upload', 'No matching file attribute found, cannot create content object without this.'));
return false;
}
$nameAttribute = $uploadINI->variable($iniGroup, 'NameAttribute');
if (!$nameAttribute) {
$nameAttribute = $this->findStringAttribute($dataMap, $nameAttribute);
}
if (!$nameAttribute) {
$result['errors'][] = array('description' => ezpI18n::tr('kernel/content/upload', 'No matching name attribute found, cannot create content object without this.'));
return false;
}
$variables = array('original_filename' => $file->attribute('original_filename'), 'mime_type' => $mime);
$variables['original_filename_base'] = $mimeData['basename'];
$variables['original_filename_suffix'] = $mimeData['suffix'];
if (!$nameString) {
$namePattern = $uploadINI->variable($iniGroup, 'NamePattern');
$nameString = $this->processNamePattern($variables, $namePattern);
}
$db = eZDB::instance();
$db->begin();
// If we have an existing node we need to create
// a new version in it.
// If we don't we have to make a new object
if (is_object($existingNode)) {
if ($existingNode->canEdit() != '1') {
$result['status'] = eZContentUpload::STATUS_PERMISSION_DENIED;
$result['errors'][] = array('description' => ezpI18n::tr('kernel/content/upload', 'Permission denied'));
$db->commit();
return false;
}
$version = $object->createNewVersion(false, true, $localeCode);
unset($dataMap);
$dataMap = $version->dataMap();
$publishVersion = $version->attribute('version');
} else {
$object = $class->instantiateIn($localeCode);
unset($dataMap);
$dataMap = $object->dataMap();
$publishVersion = $object->attribute('current_version');
}
unset($dataMap);
$dataMap = $object->dataMap();
if ($localeCode === false) {
$localeCode = eZContentObject::defaultLanguage();
}
$status = $dataMap[$fileAttribute]->insertHTTPFile($object, $publishVersion, $localeCode, $file, $mimeData, $storeResult);
if ($status === null) {
$result['errors'][] = array('description' => ezpI18n::tr('kernel/content/upload', 'The attribute %class_identifier does not support HTTP file storage.', null, array('%class_identifier' => $classIdentifier)));
$db->commit();
return false;
} else {
if (!$status) {
$result['errors'] = array_merge($result['errors'], $storeResult['errors']);
$db->commit();
return false;
}
}
if ($storeResult['require_storage']) {
$dataMap[$fileAttribute]->store();
}
$status = $dataMap[$nameAttribute]->insertSimpleString($object, $publishVersion, $localeCode, $nameString, $storeResult);
if ($status === null) {
$result['errors'][] = array('description' => ezpI18n::tr('kernel/content/upload', 'The attribute %class_identifier does not support simple string storage.', null, array('%class_identifier' => $classIdentifier)));
$db->commit();
return false;
} else {
if (!$status) {
$result['errors'] = array_merge($result['errors'], $storeResult['errors']);
$db->commit();
return false;
}
}
if ($storeResult['require_storage']) {
$dataMap[$nameAttribute]->store();
}
if (is_array($parentNodes)) {
foreach ($parentNodes as $key => $parentNode) {
$object->createNodeAssignment($parentNode, $parentNode == $parentMainNode);
}
}
$object->setName($class->contentObjectName($object));
$object->store();
if ($publish) {
$tmpresult = $this->publishObject($result, $result['errors'], $result['notices'], $object, $publishVersion, $class, $parentNodes, $parentMainNode);
} else {
$tmpresult = $result;
$tmpresult['contentobject'] = $object;
$tmpresult['contentobject_id'] = $object->attribute('id');
$tmpresult['contentobject_version'] = $publishVersion;
$tmpresult['contentobject_main_node'] = false;
$tmpresult['contentobject_main_node_id'] = false;
$this->setResult(array('node_id' => 0, 'object_id' => $object->attribute('id'), 'object_version' => $publishVersion));
}
$db->commit();
return $tmpresult;
}
示例6: __construct
public function __construct(array $options = array())
{
// Define some default values
$this->properties = array('remote_id' => null, 'section_id' => 0, 'creator_id' => false, 'language' => eZContentObject::defaultLanguage(), 'class_identifier' => null);
parent::__construct($options);
}
示例7: create
static function create( $contentobjectID, $userID = false, $version = 1, $initialLanguageCode = false )
{
if ( $userID === false )
{
$user = eZUser::currentUser();
$userID = $user->attribute( 'contentobject_id' );
}
$time = time();
if ( $initialLanguageCode == false )
{
$initialLanguageCode = eZContentObject::defaultLanguage();
}
$initialLanguageID = eZContentLanguage::idByLocale( $initialLanguageCode );
$row = array(
"contentobject_id" => $contentobjectID,
'initial_language_id' => $initialLanguageID,
'language_mask' => $initialLanguageID,
"version" => $version,
"created" => $time,
"modified" => $time,
'creator_id' => $userID );
return new eZContentObjectVersion( $row );
}
示例8: fromContentObject
/**
* Initializes a content fieldset holder from eZContentObject
* @param eZContentObject $object
* @return SQLIContentFieldsetHolder
*/
public static function fromContentObject(eZContentObject $object)
{
eZDebug::accumulatorStart('fieldset_holder_create', 'sqlicontent');
$setHolder = new self();
$languages = $object->allLanguages();
$setHolder->contentObject = $object;
foreach ($languages as $lang) {
$locale = $lang->attribute('locale');
$set = SQLIContentFieldset::fromDataMap($object->fetchDataMap(false, $locale));
$set->setLanguage($locale);
$setHolder->fieldsets[$locale] = $set;
}
// Set default language
$setHolder->setActiveLanguage(eZContentObject::defaultLanguage());
// Init internal iterator
$setHolder->initIterator();
eZDebug::accumulatorStop('fieldset_holder_create');
return $setHolder;
}