예제 #1
0
 /**
  * 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));
 }
    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
0
        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.');
            }
        }
    }
    $section->setAttribute('identifier', $sectionIdentifier);
    $section->setAttribute('navigation_part_identifier', $http->postVariable('NavigationPartIdentifier'));
    if ($http->hasPostVariable('Locale')) {
        $section->setAttribute('locale', $http->postVariable('Locale'));
    }
    if ($errorMessage === '') {
        $section->store();
        eZContentCacheManager::clearContentCacheIfNeededBySectionID($section->attribute('id'));
        $Module->redirectTo($Module->functionURI('list'));
        return;
    } else {
        $tpl->setVariable('error_message', $errorMessage);
    }
}
if ($http->hasPostVariable('CancelButton')) {
    $Module->redirectTo($Module->functionURI('list'));
}
$tpl->setVariable("section", $section);
$Result = array();
$Result['content'] = $tpl->fetch("design:section/edit.tpl");
$Result['path'] = array(array('url' => 'section/list', 'text' => ezpI18n::tr('kernel/section', 'Sections')), array('url' => false, 'text' => $section instanceof eZSection ? $section->attribute('name') : $section['name']));
 /**
  * Create Section element.
  *
  * @param DOMDocument Owner DOMDocument
  * @param eZSection eZSection object
  *
  * @return DOMElement Section DOMElement, example:
  *
  *     <Section ID="2" name="News" />
  */
 protected function createSectionDOMElement(DOMDocument $domDocument, eZSection $section)
 {
     $sectionElement = $domDocument->createElement('Section');
     // Set attributes
     $sectionElement->setAttribute('ID', $section->attribute('id'));
     $sectionElement->setAttribute('name', $section->attribute('name'));
     return $sectionElement;
 }
예제 #5
0
            $errorMessage = ezpI18n::tr('design/admin/section/edit', 'Identifier should consist of letters, numbers or \'_\' with letter prefix.');
        } else {
            $conditions = array('identifier' => $sectionIdentifier, 'id' => array('!=', !empty($SectionID) ? $SectionID : 0));
            $existingSection = eZSection::fetchFilteredList($conditions);
            if (count($existingSection) > 0) {
                $errorMessage = ezpI18n::tr('design/admin/section/edit', 'The identifier has been used in another section.');
            }
        }
    }
    $section->setAttribute('identifier', $sectionIdentifier);
    $section->setAttribute('navigation_part_identifier', $http->postVariable('NavigationPartIdentifier'));
    if ($http->hasPostVariable('Locale')) {
        $section->setAttribute('locale', $http->postVariable('Locale'));
    }
    if ($errorMessage === '') {
        $section->store();
        eZContentCacheManager::clearContentCacheIfNeededBySectionID($section->attribute('id'));
        ezpEvent::getInstance()->notify('content/section/cache', array($section->attribute('id')));
        $Module->redirectTo($Module->functionURI('list'));
        return;
    } else {
        $tpl->setVariable('error_message', $errorMessage);
    }
}
if ($http->hasPostVariable('CancelButton')) {
    $Module->redirectTo($Module->functionURI('list'));
}
$tpl->setVariable("section", $section);
$Result = array();
$Result['content'] = $tpl->fetch("design:section/edit.tpl");
$Result['path'] = array(array('url' => 'section/list', 'text' => ezpI18n::tr('kernel/section', 'Sections')), array('url' => false, 'text' => $section instanceof eZSection ? $section->attribute('name') : $section['name']));