本文整理汇总了PHP中eZContentLanguage类的典型用法代码示例。如果您正苦于以下问题:PHP eZContentLanguage类的具体用法?PHP eZContentLanguage怎么用?PHP eZContentLanguage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eZContentLanguage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFetchByContentObjectIDList
/**
* Test FetchByContentObjectList
*/
public function testFetchByContentObjectIDList()
{
$language = eZContentLanguage::fetchByLocale('eng-GB');
$languageID = $language->attribute('id');
$time = time();
$comment1 = array('contentobject_id' => 15, 'language_id' => $languageID, 'created' => $time, 'modified' => $time, 'text' => 'comment1', 'user_id' => 15);
$comment2 = array('contentobject_id' => 15, 'language_id' => $languageID, 'created' => $time + 1, 'modified' => $time + 1, 'text' => 'comment2', 'user_id' => 15);
$comment3 = array('contentobject_id' => 15, 'language_id' => $languageID, 'created' => $time + 2, 'modified' => $time + 2, 'text' => 'comment3', 'user_id' => 15);
$comment4 = array('contentobject_id' => 14, 'language_id' => $languageID, 'created' => $time + 3, 'modified' => $time + 3, 'text' => 'comment4', 'user_id' => 14);
$comment = ezcomComment::create($comment1);
$comment->store();
$comment = ezcomComment::create($comment2);
$comment->store();
$comment = ezcomComment::create($comment3);
$comment->store();
$comment = ezcomComment::create($comment4);
$comment->store();
// test null contentobject id and user id
$result = ezcomComment::fetchByContentObjectIDList(null, 15, 'eng-GB', null, array('modified' => 'desc'), 0);
$this->assertEquals('comment3', $result[0]->attribute('text'));
$this->assertEquals('comment1', $result[2]->attribute('text'));
// test null contentobject id array and empty user_id
$result = ezcomComment::fetchByContentObjectIDList(null, null, 'eng-GB', null, array('modified' => 'desc'), 0);
$this->assertEquals('comment1', $result[3]->attribute('text'));
// test one contentobject id array
$result = ezcomComment::fetchByContentObjectIDList(array(14), null, 'eng-GB', null, array('modified' => 'desc'), 0);
$this->assertEquals('comment4', $result[0]->attribute('text'));
// test many contentobjects array and sort
$result = ezcomComment::fetchByContentObjectIDList(array(14, 15), null, 'eng-GB', null, array('modified' => 'asc'), 0);
$this->assertEquals('comment3', $result[2]->attribute('text'));
// test length with all null
$result = ezcomComment::fetchByContentObjectIDList(null, null, null, null, null, null, 3);
$this->assertEquals(3, count($result));
}
示例2: fetchUrlAlias
public function fetchUrlAlias($nodeId = null, $path = null, $locale)
{
if (!$nodeId && !$path) {
return array('result' => false);
}
if (empty($locale) || !is_string($locale)) {
return array('result' => false);
}
if (is_numeric($nodeId)) {
$destinationElement = eZURLAliasML::fetchByAction('eznode', $nodeId, $locale, false);
} else {
if (is_string($path)) {
$nodeId = eZURLAliasML::fetchNodeIDByPath($path);
$destinationElement = eZURLAliasML::fetchByAction('eznode', $nodeId, $locale, false);
}
}
if (empty($destinationElement) || !isset($destinationElement[0]) && !$destinationElement[0] instanceof eZURLAliasML) {
// Either no translation exists for $locale or $path was not pointing to a node
return array('result' => false);
}
$currentLanguageCodes = eZContentLanguage::prioritizedLanguageCodes();
array_unshift($currentLanguageCodes, $locale);
$currentLanguageCodes = array_unique($currentLanguageCodes);
$urlAlias = $destinationElement[0]->getPath($locale, $currentLanguageCodes);
return array('result' => $urlAlias);
}
示例3: setUp
public function setUp()
{
parent::setUp();
$this->xxx = eZContentLanguage::addLanguage('xxx-XX', 'XXXX');
ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'SiteLanguageList', array('xxx-XX', 'eng-GB'));
eZContentLanguage::clearPrioritizedLanguages();
}
示例4: validNodes
/**
* Return valid items for block with given $blockID
*
* @static
* @param string $blockID
* @param bool $asObject
* @return array(eZContentObjectTreeNode)
*/
static function validNodes($blockID, $asObject = true)
{
if (isset($GLOBALS['eZFlowPool']) === false) {
$GLOBALS['eZFlowPool'] = array();
}
if (isset($GLOBALS['eZFlowPool'][$blockID])) {
return $GLOBALS['eZFlowPool'][$blockID];
}
$visibilitySQL = "";
if (eZINI::instance('site.ini')->variable('SiteAccessSettings', 'ShowHiddenNodes') !== 'true') {
$visibilitySQL = "AND ezcontentobject_tree.is_invisible = 0 ";
}
$db = eZDB::instance();
$validNodes = $db->arrayQuery("SELECT ezm_pool.node_id\n FROM ezm_pool, ezcontentobject_tree, ezcontentobject\n WHERE ezm_pool.block_id='{$blockID}'\n AND ezm_pool.ts_visible>0\n AND ezm_pool.ts_hidden=0\n AND ezcontentobject_tree.node_id = ezm_pool.node_id\n AND ezcontentobject.id = ezm_pool.object_id\n AND " . eZContentLanguage::languagesSQLFilter('ezcontentobject') . "\n {$visibilitySQL}\n ORDER BY ezm_pool.priority DESC");
if ($asObject && !empty($validNodes)) {
$validNodesObjects = array();
foreach ($validNodes as $node) {
$validNodeObject = eZContentObjectTreeNode::fetch($node['node_id']);
if ($validNodeObject instanceof eZContentObjectTreeNode && $validNodeObject->canRead()) {
$validNodesObjects[] = $validNodeObject;
}
}
$GLOBALS['eZFlowPool'][$blockID] = $validNodesObjects;
return $validNodesObjects;
} else {
return $validNodes;
}
}
示例5: modify
function modify($tpl, $operatorName, $operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters)
{
$parentNodeID = $namedParameters['parent_node_id'];
switch ($operatorName) {
case 'ezkeywordlist':
include_once 'lib/ezdb/classes/ezdb.php';
$db = eZDB::instance();
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\n ezcontentobject_tree.contentobject_version = ezcontentobject_name.content_version AND ";
$languageFilter = " AND " . eZContentLanguage::languagesSQLFilter('ezcontentobject');
$versionNameJoins .= eZContentLanguage::sqlFilter('ezcontentobject_name', 'ezcontentobject');
$quotedClassIdentifiers = array();
foreach ((array) $namedParameters['class_identifier'] as $classIdentifier) {
$quotedClassIdentifiers[] = "'" . $db->escapeString($classIdentifier) . "'";
}
$rs = $db->arrayQuery("SELECT DISTINCT ezkeyword.keyword\n FROM ezkeyword_attribute_link,\n ezkeyword,\n ezcontentobject,\n ezcontentobject_name,\n ezcontentobject_attribute,\n ezcontentobject_tree,\n ezcontentclass\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_tree.contentobject_id = ezcontentobject_attribute.contentobject_id\n AND ezkeyword.class_id = ezcontentclass.id\n AND " . $db->generateSQLINStatement($quotedClassIdentifiers, 'ezcontentclass.identifier') . "\n {$pathString}\n {$parentNodeIDSQL} " . ($namedParameters['depth'] > 0 ? "AND ezcontentobject_tree.depth=" . (int) $namedParameters['depth'] : '') . "\n {$showInvisibleNodesCond}\n {$sqlPermissionChecking['where']}\n {$languageFilter}\n {$versionNameJoins}\n ORDER BY ezkeyword.keyword ASC");
$operatorValue = $rs;
break;
}
}
示例6: testIssue13497
/**
* Test for regression #13497:
* attribute operator throws a PHP fatal error on a node without parent in a displayable language
*
* Situation:
* - siteaccess with one language (fre-FR) and ShowUntranslatedObjects disabled
* - parent content node in another language (eng-GB) with always available disabled
* - content node in the siteaccess' language (fre-FR)
* - fetch this fre-FR node from anywhere, and call attribute() on it
*
* Result:
* - Fatal error: Call to a member function attribute() on a non-object in
* kernel/classes/ezcontentobjecttreenode.php on line 4225
*
* Explanation: the error actually comes from the can_remove_location attribute
**/
public function testIssue13497()
{
// Create a folder in english only
$folder = new ezpObject("folder", 2, 14, 1, 'eng-GB');
$folder->setAlwaysAvailableLanguageID(false);
$folder->name = "Parent for " . __FUNCTION__;
$folder->publish();
$locale = eZLocale::instance('fre-FR');
$translation = eZContentLanguage::addLanguage($locale->localeCode(), $locale->internationalLanguageName());
// Create an article in french only, as a subitem of the previously created folder
$article = new ezpObject("article", $folder->attribute('main_node_id'), 14, 1, 'fre-FR');
$article->title = "Object for " . __FUNCTION__;
$article->short_description = "Description of test for " . __FUNCTION__;
$article->publish();
$articleNodeID = $article->attribute('main_node_id');
// INi changes: set language to french only, untranslatedobjects disabled
ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'ContentObjectLocale', 'fre-FR');
ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'SiteLanguageList', array('fre-FR'));
ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'ShowUntranslatedObjects', 'disabled');
eZContentLanguage::expireCache();
// This should crash
eZContentObjectTreeNode::fetch($articleNodeID)->attribute('can_remove_location');
ezpINIHelper::restoreINISettings();
// re-expire cache for further tests
eZContentLanguage::expireCache();
}
示例7: testMapLanguage
/**
* Test that fetching the language listing, works after languages
* have been altered in database, and then later refetched.
*
* @link http://issues.ez.no/15484
*/
public function testMapLanguage()
{
$db = eZDB::instance();
eZContentLanguage::addLanguage('nno-NO', 'Nynorsk');
$localeToChangeInto = 'dan-DK';
$languageNameToChangeInto = 'Danish';
$langObject = eZContentLanguage::fetchByLocale('nno-NO');
$langId = (int) $langObject->attribute('id');
$updateSql = <<<END
UPDATE ezcontent_language
SET
locale='{$localeToChangeInto}',
name='{$languageNameToChangeInto}'
WHERE
id={$langId}
END;
$db->query($updateSql);
eZContentLanguage::expireCache();
$newLangObject = eZContentLanguage::fetchByLocale($localeToChangeInto);
if (!$newLangObject instanceof eZContentLanguage) {
self::fail("Language object not returned. Old version provided by cache?");
}
$newLangId = (int) $newLangObject->attribute('id');
self::assertEquals($langId, $newLangId, "New language not mapped to existing language");
}
示例8: testIssue19174
/**
* Regression test for issue {@see #19174 http://issues.ez.no/19174}
*/
public function testIssue19174()
{
$bkpLanguages = eZContentLanguage::prioritizedLanguageCodes();
// add a secondary language
$locale = eZLocale::instance('fre-FR');
$translation = eZContentLanguage::addLanguage($locale->localeCode(), $locale->internationalLanguageName());
// create related objects
$relatedObjectsIds = array($this->createObjectForRelation(), $this->createObjectForRelation(), $this->createObjectForRelation(), $this->createObjectForRelation());
$xmlTextEn = "<embed href=\"ezobject://{$relatedObjectsIds[0]}\" /><link href=\"ezobject://{$relatedObjectsIds[1]}\">link</link>";
$xmlTextFr = "<embed href=\"ezobject://{$relatedObjectsIds[2]}\" /><link href=\"ezobject://{$relatedObjectsIds[3]}\">link</link>";
// Create an article in eng-GB, and embed related object one in the intro
$article = new ezpObject('article', 2, 14, 1, 'eng-GB');
$article->title = __METHOD__ . ' eng-GB';
$article->intro = $xmlTextEn;
$articleId = $article->publish();
// Workaround as setting folder->name directly doesn't produce the expected result
$article->addTranslation('fre-FR', array('title' => __METHOD__ . ' fre-FR', 'intro' => $xmlTextFr));
$relatedObjects = eZContentObject::fetch($articleId)->relatedObjects(false, false, 0, false, array('AllRelations' => eZContentObject::RELATION_LINK | eZContentObject::RELATION_EMBED));
self::assertEquals(4, count($relatedObjects));
$expectedRelations = array_flip($relatedObjectsIds);
foreach ($relatedObjects as $relatedObject) {
if (isset($expectedRelations[$relatedObject->ID])) {
unset($expectedRelations[$relatedObject->ID]);
}
}
self::assertEquals(0, count($expectedRelations));
$article->remove();
$translation->removeThis();
eZContentLanguage::setPrioritizedLanguages($bkpLanguages);
}
示例9: sqlAppendFilter
static function sqlAppendFilter($languageTable = 'ezcontentclass')
{
$def = eZContentClassName::definition();
$languageListTable = $def['name'];
$sqlFilter = array('nameField' => ", {$languageListTable}.name", 'from' => ", {$languageListTable}", 'where' => "AND {$languageTable}.id = {$languageListTable}.contentclass_id AND\n {$languageTable}.version = {$languageListTable}.contentclass_version AND " . eZContentLanguage::sqlFilter($languageListTable, $languageTable), 'orderBy' => "{$languageListTable}.name");
return $sqlFilter;
}
示例10: addUrlALias
/**
* Code taken from content/urlalias module
*/
static function addUrlALias($node, $aliasText, $languageId, $aliasRedirects = false, $parentIsRoot = false)
{
$infoCode = 'no-errors';
$language = eZContentLanguage::fetch($languageId);
if (!$language) {
$infoCode = "error-invalid-language";
$infoData['language'] = $languageCode;
} else {
$parentID = 0;
$linkID = 0;
$filter = new eZURLAliasQuery();
$filter->actions = array('eznode:' . $node->attribute('node_id'));
$filter->type = 'name';
$filter->limit = false;
$existingElements = $filter->fetchAll();
// TODO: add error handling when $existingElements is empty
if (count($existingElements) > 0) {
$parentID = (int) $existingElements[0]->attribute('parent');
$linkID = (int) $existingElements[0]->attribute('id');
}
if ($parentIsRoot) {
$parentID = 0;
// Start from the top
}
$mask = $language->attribute('id');
$obj = $node->object();
$alwaysMask = $obj->attribute('language_mask') & 1;
$mask |= $alwaysMask;
$origAliasText = $aliasText;
$result = eZURLAliasML::storePath($aliasText, 'eznode:' . $node->attribute('node_id'), $language, $linkID, $alwaysMask, $parentID, true, false, false, $aliasRedirects);
if ($result['status'] === eZURLAliasML::LINK_ALREADY_TAKEN) {
$lastElements = eZURLAliasML::fetchByPath($result['path']);
if (count($lastElements) > 0) {
$lastElement = $lastElements[0];
$infoCode = "feedback-alias-exists";
$infoData['new_alias'] = $aliasText;
$infoData['url'] = $lastElement->attribute('path');
$infoData['action_url'] = $lastElement->actionURL();
//$aliasText = $origAliasText;
}
} else {
if ($result['status'] === true) {
$aliasText = $result['path'];
if (strcmp($aliasText, $origAliasText) != 0) {
$infoCode = "feedback-alias-cleanup";
$infoData['orig_alias'] = $origAliasText;
$infoData['new_alias'] = $aliasText;
} else {
$infoData['new_alias'] = $aliasText;
}
if ($infoCode == 'no-errors') {
$infoCode = "feedback-alias-created";
}
//$aliasText = false;
}
}
}
return array('infoCode' => $infoCode, 'infoData' => $infoData);
}
示例11: tearDown
public function tearDown()
{
$this->folder->remove();
$this->article->remove();
eZPendingActions::removeByAction('index_object');
$this->nodeIds = array();
$this->objectIds = array();
$anonymousUser = eZUser::fetchByName('anonymous');
eZUser::setCurrentlyLoggedInUser($anonymousUser, $anonymousUser->attribute('contentobject_id'));
eZContentLanguage::expireCache();
parent::tearDown();
}
示例12: createSqlParts
function createSqlParts($params)
{
$sqlJoins = '';
if (isset($params['locales'])) {
$language_mask = 0;
$locales = eZContentLanguage::fetchList();
foreach ($locales as $locale) {
if (in_array($locale->attribute('locale'), $params['locales'])) {
$language_mask |= $locale->attribute('id');
}
}
if ($language_mask) {
$sqlJoins = " ezcontentobject.language_mask & {$language_mask} AND ";
}
}
return array('tables' => '', 'joins' => $sqlJoins, 'columns' => '');
}
示例13: attribute
function attribute($attr)
{
switch ($attr) {
case 'sections':
$sections = eZSection::fetchList(false);
foreach ($sections as $key => $section) {
$sections[$key]['Name'] = $section['name'];
$sections[$key]['value'] = $section['id'];
}
return $sections;
break;
case 'languages':
return eZContentLanguage::fetchList();
break;
}
return eZWorkflowEventType::attribute($attr);
}
示例14: modify
function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters)
{
$ret = '';
switch ($operatorName) {
case 'get_url_alias_by_lang':
$node = eZContentObjectTreeNode::fetch($namedParameters['node_id'], $namedParameters['lang_code']);
$originalPrioritizedLanguages = eZContentLanguage::prioritizedLanguageCodes();
eZContentLanguage::setPrioritizedLanguages(array($namedParameters['lang_code']));
$urlAlias = '';
if (is_object($node)) {
$urlAlias = '/' . $node->urlAlias();
}
eZContentLanguage::setPrioritizedLanguages($originalPrioritizedLanguages);
$ret = $urlAlias;
break;
}
$operatorValue = $ret;
}
示例15: __construct
public function __construct($theClass = '', $name = '')
{
parent::__construct($theClass, $name);
if (!self::$script instanceof eZScript) {
self::$script = eZScript::instance(array('description' => "eZ Publish Test Runner\n\nsets up an eZ Publish testing environment\n", 'use-session' => false, 'use-modules' => true, 'use-extensions' => true));
// Override INI override folder from settings/override to
// tests/settings to not read local override settings
$ini = eZINI::instance();
$ini->setOverrideDirs(array(array('tests/settings', true)), 'override');
$ini->loadCache();
// Be sure to have clean content language data
eZContentLanguage::expireCache();
self::$script->startup();
self::$script->initialize();
// Avoids Fatal error: eZ Publish did not finish its request if die() is used.
eZExecution::setCleanExit();
}
}