本文整理汇总了PHP中eZSection::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP eZSection::setAttribute方法的具体用法?PHP eZSection::setAttribute怎么用?PHP eZSection::setAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZSection
的用法示例。
在下文中一共展示了eZSection::setAttribute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFetchByIdentifier
/**
* test fetchByIdentifier function
*/
public function testFetchByIdentifier()
{
global $eZContentSectionObjectCache;
$section = new eZSection(array());
$section->setAttribute('name', 'Test Section');
$section->setAttribute('identifier', 'test_section');
$section->store();
$sectionID = $section->attribute('id');
// assert that if the cache is set after fetching
$section2 = eZSection::fetchByIdentifier('test_section');
$this->assertEquals($sectionID, $section2->attribute('id'));
// assert that object is cached
$this->assertNotNull($eZContentSectionObjectCache['test_section']);
$this->assertNotNull($eZContentSectionObjectCache[$sectionID]);
// assert that the two object refer to same object
$this->assertSame($eZContentSectionObjectCache[$sectionID], $section2);
$this->assertSame(eZSection::fetch($sectionID), $section2);
// fetchByID and fetchByIdentifier, assert that the result is the same
$section3 = new eZSection(array());
$section3->setAttribute('name', 'Test Section3');
$section3->setAttribute('identifier', 'test_section3');
$section3->store();
$objectByID = eZSection::fetch($section3->attribute('id'));
$objectByIdentifier = eZSection::fetchByIdentifier('test_section3');
$this->assertSame($objectByID, $objectByIdentifier);
$arrayByIdentifier = eZSection::fetch($section3->attribute('id'), false);
$this->assertTrue(is_array($arrayByIdentifier));
}
示例2: execute
function execute( $xmlNode )
{
// ezcontentnavigationpart
$sectionName = $xmlNode->getAttribute( 'sectionName' );
$sectionIdentifier = $xmlNode->getAttribute( 'sectionIdentifier' );
$navigationPart = $xmlNode->getAttribute( 'navigationPart' );
$referenceID = $xmlNode->getAttribute( 'referenceID' );
if( $sectionIdentifier )
{
$sectionID = eZSection::fetchByIdentifier( $sectionIdentifier );
}
if( !$sectionID )
{
$sectionID = $this->sectionIDbyName( $sectionName );
}
if( $sectionID )
{
$this->writeMessage( "\tSection '$sectionName' already exists." , 'notice' );
}
else
{
$section = new eZSection( array() );
$section->setAttribute( 'name', $sectionName );
$section->setAttribute( 'identifier', $sectionIdentifier );
$section->setAttribute( 'navigation_part_identifier', $navigationPart );
$section->store();
$sectionID = $section->attribute( 'id' );
}
$refArray = array();
if ( $referenceID )
{
$refArray[$referenceID] = $sectionID;
}
$this->addReference( $refArray );
}
示例3: array
$SectionID = $Params["SectionID"];
$Module = $Params['Module'];
$tpl = eZTemplate::factory();
if ($SectionID == 0) {
$section = array('id' => 0, 'name' => ezpI18n::tr('kernel/section', 'New section'), 'navigation_part_identifier' => 'ezcontentnavigationpart');
} else {
$section = eZSection::fetch($SectionID);
if ($section === null) {
return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
}
if ($http->hasPostVariable("StoreButton")) {
if ($SectionID == 0) {
$section = new eZSection(array());
}
$section->setAttribute('name', $http->postVariable('Name'));
$sectionIdentifier = trim($http->postVariable('SectionIdentifier'));
$errorMessage = '';
if ($sectionIdentifier === '') {
$errorMessage = ezpI18n::tr('design/admin/section/edit', 'Identifier can not be empty');
} else {
if (preg_match('/(^[^A-Za-z])|\\W/', $sectionIdentifier)) {
$errorMessage = ezpI18n::tr('design/admin/section/edit', 'Identifier should consist of letters, numbers or \'_\' with letter prefix.');
} else {
$conditions = array('identifier' => $sectionIdentifier, 'id' => array('!=', $SectionID));
$existingSection = eZSection::fetchFilteredList($conditions);
if (count($existingSection) > 0) {
$errorMessage = ezpI18n::tr('design/admin/section/edit', 'The identifier has been used in another section.');
}
}
}
示例4: createContentSection
function createContentSection( $params )
{
$section = false;
$sectionName = $params['name'];
$navigationPart = $params['navigation_part_identifier'];
$section = new eZSection( array() );
$section->setAttribute( 'name', $sectionName );
$section->setAttribute( 'navigation_part_identifier', $navigationPart );
$section->store();
return $section;
}