本文整理汇总了PHP中eZSection类的典型用法代码示例。如果您正苦于以下问题:PHP eZSection类的具体用法?PHP eZSection怎么用?PHP eZSection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eZSection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sectionEditActionCheck
function sectionEditActionCheck( $module, $class, $object, $version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage )
{
if ( $module->isCurrentAction( 'SectionEdit' ) )
{
$http = eZHTTPTool::instance();
if ( $http->hasPostVariable( 'SelectedSectionId' ) )
{
$selectedSectionID = (int) $http->postVariable( 'SelectedSectionId' );
$selectedSection = eZSection::fetch( $selectedSectionID );
if ( is_object( $selectedSection ) )
{
$currentUser = eZUser::currentUser();
if ( $currentUser->canAssignSectionToObject( $selectedSectionID, $object ) )
{
$db = eZDB::instance();
$db->begin();
$assignedNodes = $object->attribute( 'assigned_nodes' );
if ( count( $assignedNodes ) > 0 )
{
foreach ( $assignedNodes as $node )
{
if ( eZOperationHandler::operationIsAvailable( 'content_updatesection' ) )
{
$operationResult = eZOperationHandler::execute( 'content',
'updatesection',
array( 'node_id' => $node->attribute( 'node_id' ),
'selected_section_id' => $selectedSectionID ),
null,
true );
}
else
{
eZContentOperationCollection::updateSection( $node->attribute( 'node_id' ), $selectedSectionID );
}
}
}
else
{
// If there are no assigned nodes we should update db for the current object.
$objectID = $object->attribute( 'id' );
$db->query( "UPDATE ezcontentobject SET section_id='$selectedSectionID' WHERE id = '$objectID'" );
$db->query( "UPDATE ezsearch_object_word_link SET section_id='$selectedSectionID' WHERE contentobject_id = '$objectID'" );
}
$object->expireAllViewCache();
$db->commit();
}
else
{
eZDebug::writeError( "You do not have permissions to assign the section <" . $selectedSection->attribute( 'name' ) .
"> to the object <" . $object->attribute( 'name' ) . ">." );
}
$module->redirectToView( 'edit', array( $object->attribute( 'id' ), $editVersion, $editLanguage, $fromLanguage ) );
}
}
}
}
示例2: section_list
private function section_list()
{
$sectionObjects = eZSection::fetchList();
$results = array();
$results[] = array("Id", "NavigationPartIdentifier", "Count", "Name");
foreach ($sectionObjects as $section) {
$count = eZSectionFunctionCollection::fetchObjectListCount($section->ID);
$count = $count["result"];
$results[] = array($section->ID, $section->NavigationPartIdentifier, $count, $section->Name);
}
eep::printTable($results, "all sections");
}
示例3: 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));
}
示例4: sectionIDbyName
private function sectionIDbyName( $name )
{
$sectionID = false;
$sectionList = eZSection::fetchFilteredList( array( 'name' => $name ), false, false, true );
if( is_array( $sectionList ) && count( $sectionList ) > 0 )
{
$section = $sectionList[0];
if( is_object( $section ) )
{
$sectionID = $section->attribute( 'id' );
}
}
return $sectionID;
}
示例5: 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);
}
示例6: sectionEditActionCheck
function sectionEditActionCheck($module, $class, $object, $version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage)
{
if (!$module->isCurrentAction('SectionEdit')) {
return;
}
$http = eZHTTPTool::instance();
if (!$http->hasPostVariable('SelectedSectionId')) {
return;
}
$selectedSection = eZSection::fetch((int) $http->postVariable('SelectedSectionId'));
if (!$selectedSection instanceof eZSection) {
return;
}
$selectedSection->applyTo($object);
eZContentCacheManager::clearContentCacheIfNeeded($object->attribute('id'));
$module->redirectToView('edit', array($object->attribute('id'), $editVersion, $editLanguage, $fromLanguage));
}
示例7: attribute
function attribute($attr)
{
switch ($attr) {
case 'sections':
#include_once( 'kernel/classes/ezsection.php' );
$sections = eZSection::fetchList(false);
foreach (array_keys($sections) as $key) {
$section = $sections[$key];
$section['Name'] = $section['name'];
$section['value'] = $section['id'];
}
return $sections;
break;
}
$eventValue = eZWorkflowEventType::attribute($attr);
return $eventValue;
}
示例8: array
//
$http = eZHTTPTool::instance();
$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.');
}
示例9: foreach
if ($http->hasSessionVariable('SectionIDArray')) {
$sectionIDArray = $http->sessionVariable('SectionIDArray');
$db = eZDB::instance();
$db->begin();
foreach ($sectionIDArray as $sectionID) {
$section = eZSection::fetch($sectionID);
if (is_object($section) and $section->canBeRemoved()) {
// Clear content cache if needed
eZContentCacheManager::clearContentCacheIfNeededBySectionID($sectionID);
$section->remove();
}
}
$db->commit();
}
} else {
return $Module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel');
}
}
$viewParameters = array('offset' => $offset);
$sectionArray = eZSection::fetchByOffset($offset, $limit);
$sectionCount = eZSection::sectionCount();
$currentUser = eZUser::currentUser();
$allowedAssignSectionList = $currentUser->canAssignSectionList();
$tpl->setVariable("limit", $limit);
$tpl->setVariable('section_array', $sectionArray);
$tpl->setVariable('section_count', $sectionCount);
$tpl->setVariable('view_parameters', $viewParameters);
$tpl->setVariable('allowed_assign_sections', $allowedAssignSectionList);
$Result = array();
$Result['content'] = $tpl->fetch("design:section/list.tpl");
$Result['path'] = array(array('url' => false, 'text' => ezpI18n::tr('kernel/section', 'Sections')));
示例10: array
* @version 2012.6
* @package kernel
* @subpackage content
*/
$tpl = eZTemplate::factory();
$module = $Params['Module'];
$http = eZHTTPTool::instance();
$pContentObjectId = $Params['ContentObjectID'];
$pVersion = $Params['version'];
$tpl->setVariable('contentObjectId', $pContentObjectId);
$tpl->setVariable('version', $pVersion);
$virtualNodeID = 0;
$contentObject = eZContentObject::fetch($pContentObjectId);
$contentObjectVersion = $contentObject->version($pVersion);
$nodeAssignments = $contentObjectVersion->attribute('node_assignments');
$contentClass = eZContentClass::fetch($contentObject->attribute('contentclass_id'));
$section = eZSection::fetch($contentObject->attribute('section_id'));
$navigationPartIdentifier = $section->attribute('navigation_part_identifier');
$res = eZTemplateDesignResource::instance();
$designKeys = array(array('object', $contentObject->attribute('id')), array('node', $virtualNodeID), array('remote_id', $contentObject->attribute('remote_id')), array('class', $contentClass->attribute('id')), array('class_identifier', $contentClass->attribute('identifier')), array('class_group', $contentObject->attribute('match_ingroup_id_list')), array('state', $contentObject->attribute('state_id_array')), array('state_identifier', $contentObject->attribute('state_identifier_array')), array('section', $contentObject->attribute('section_id')), array('section_identifier', $section->attribute('identifier')));
$res->setKeys($designKeys);
if ($http->hasSessionVariable('RedirectURIAfterPublish')) {
$tpl->setVariable('redirect_uri', $http->sessionVariable('RedirectURIAfterPublish'));
}
$tpl->setVariable('content_object', $contentObject);
$tpl->setVariable('content_object_version', $contentObjectVersion);
$tpl->setVariable('content_class', $contentClass);
$Result['path'] = array(array('text' => ezpI18n::tr('kernel/content', 'Content'), 'url' => false), array('text' => ezpI18n::tr('kernel/content', 'Publishing queue'), 'url' => false), array('text' => $contentObject->attribute('name'), 'url' => false));
$Result['content'] = $tpl->fetch('design:content/queued.tpl');
$Result['navigation_part'] = $navigationPartIdentifier;
return $Result;
示例11: array
}
$contentObjectID = $http->postVariable('ContentObjectID', 1);
$hideRemoveConfirm = false;
if ($http->hasPostVariable('HideRemoveConfirmation')) {
$hideRemoveConfirm = $http->postVariable('HideRemoveConfirmation') ? true : false;
}
if ($contentNodeID != null) {
$http->setSessionVariable('CurrentViewMode', $viewMode);
$http->setSessionVariable('ContentNodeID', $parentNodeID);
$http->setSessionVariable('HideRemoveConfirmation', $hideRemoveConfirm);
$http->setSessionVariable('DeleteIDArray', array($contentNodeID));
$http->setSessionVariable('RedirectURIAfterRemove', $http->postVariable('RedirectURIAfterRemove', false));
$http->setSessionVariable('RedirectIfCancel', $http->postVariable('RedirectIfCancel', false));
$object = eZContentObject::fetchByNodeID($contentNodeID);
if ($object instanceof eZContentObject) {
$section = eZSection::fetch($object->attribute('section_id'));
}
if (isset($section) && $section) {
$navigationPartIdentifier = $section->attribute('navigation_part_identifier');
} else {
$navigationPartIdentifier = null;
}
if ($navigationPartIdentifier and $navigationPartIdentifier == 'ezusernavigationpart') {
$module->redirectTo($module->functionURI('removeuserobject') . '/');
} elseif ($navigationPartIdentifier and $navigationPartIdentifier == 'ezmedianavigationpart') {
$module->redirectTo($module->functionURI('removemediaobject') . '/');
} else {
$module->redirectTo($module->functionURI('removeobject') . '/');
}
} else {
$module->redirectToView('view', array($viewMode, $parentNodeID));
示例12: checkRelationActions
function checkRelationActions($module, $class, $object, $version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage)
{
$http = eZHTTPTool::instance();
if ($module->isCurrentAction('BrowseForObjects')) {
$objectID = $object->attribute('id');
$assignedNodes = $object->attribute('assigned_nodes');
$assignedNodesIDs = array();
foreach ($assignedNodes as $node) {
$assignedNodesIDs = $node->attribute('node_id');
}
unset($assignedNodes);
eZContentBrowse::browse(array('action_name' => 'AddRelatedObject', 'description_template' => 'design:content/browse_related.tpl', 'content' => array('object_id' => $objectID, 'object_version' => $editVersion, 'object_language' => $editLanguage), 'keys' => array('class' => $class->attribute('id'), 'class_id' => $class->attribute('identifier'), 'classgroup' => $class->attribute('ingroup_id_list'), 'section' => $object->attribute('section_id')), 'ignore_nodes_select' => $assignedNodesIDs, 'from_page' => $module->redirectionURI('content', 'edit', array($objectID, $editVersion, $editLanguage, $fromLanguage))), $module);
return eZModule::HOOK_STATUS_CANCEL_RUN;
}
if ($module->isCurrentAction('UploadFileRelation')) {
$objectID = $object->attribute('id');
$section = eZSection::fetch($object->attribute('section_id'));
$navigationPart = false;
if ($section) {
$navigationPart = $section->attribute('navigation_part_identifier');
}
$location = false;
if ($module->hasActionParameter('UploadRelationLocation')) {
$location = $module->actionParameter('UploadRelationLocation');
}
// We only do direct uploading if we have the uploaded HTTP file
// if not we need to go to the content/upload page.
if (eZHTTPFile::canFetch('UploadRelationFile')) {
$upload = new eZContentUpload();
if ($upload->handleUpload($result, 'UploadRelationFile', $location, false)) {
$relatedObjectID = $result['contentobject_id'];
if ($relatedObjectID) {
$db = eZDB::instance();
$db->begin();
$object->addContentObjectRelation($relatedObjectID, $editVersion);
$db->commit();
}
}
} else {
eZContentUpload::upload(array('action_name' => 'RelatedObjectUpload', 'description_template' => 'design:content/upload_related.tpl', 'navigation_part_identifier' => $navigationPart, 'content' => array('object_id' => $objectID, 'object_version' => $editVersion, 'object_language' => $editLanguage), 'keys' => array('class' => $class->attribute('id'), 'class_id' => $class->attribute('identifier'), 'classgroup' => $class->attribute('ingroup_id_list'), 'section' => $object->attribute('section_id')), 'result_action_name' => 'UploadedFileRelation', 'ui_context' => 'edit', 'result_module' => array('content', 'edit', array($objectID, $editVersion, $editLanguage, $fromLanguage))), $module);
return eZModule::HOOK_STATUS_CANCEL_RUN;
}
}
if ($module->isCurrentAction('DeleteRelation')) {
$objectID = $object->attribute('id');
if ($http->hasPostVariable('DeleteRelationIDArray')) {
$relationObjectIDs = $http->postVariable('DeleteRelationIDArray');
} else {
$relationObjectIDs = array();
}
$db = eZDB::instance();
$db->begin();
foreach ($relationObjectIDs as $relationObjectID) {
$object->removeContentObjectRelation($relationObjectID, $editVersion);
}
$db->commit();
}
if ($module->isCurrentAction('NewObject')) {
if ($http->hasPostVariable('ClassID')) {
if ($http->hasPostVariable('SectionID')) {
$sectionID = $http->postVariable('SectionID');
} else {
$sectionID = 0;
/* Will be changed later */
}
$contentClassID = $http->postVariable('ClassID');
$class = eZContentClass::fetch($contentClassID);
$db = eZDB::instance();
$db->begin();
$relatedContentObject = $class->instantiate(false, $sectionID);
$db->commit();
$newObjectID = $relatedContentObject->attribute('id');
$relatedContentVersion = $relatedContentObject->attribute('current');
if ($relatedContentObject->attribute('can_edit')) {
$db = eZDB::instance();
$db->begin();
$assignmentHandler = new eZContentObjectAssignmentHandler($relatedContentObject, $relatedContentVersion);
$sectionID = (int) $assignmentHandler->setupAssignments(array('group-name' => 'RelationAssignmentSettings', 'default-variable-name' => 'DefaultAssignment', 'specific-variable-name' => 'ClassSpecificAssignment', 'section-id-wanted' => true, 'fallback-node-id' => $object->attribute('main_node_id')));
$http->setSessionVariable('ParentObject', array($object->attribute('id'), $editVersion, $editLanguage));
$http->setSessionVariable('NewObjectID', $newObjectID);
/* Change section ID to the same one as the main node placement */
$db->query("UPDATE ezcontentobject SET section_id = {$sectionID} WHERE id = {$newObjectID}");
$db->commit();
$module->redirectToView('edit', array($relatedContentObject->attribute('id'), $relatedContentObject->attribute('current_version'), false));
} else {
$db = eZDB::instance();
$db->begin();
$relatedContentObject->purge();
$db->commit();
}
return;
}
}
}
示例13: array
* @version 2013.11
* @package update
*/
require 'autoload.php';
$script = eZScript::instance(array('description' => 'eZ Publish section identifier update script. ' . 'This script will update existing sections with missing identifiers.', 'use-session' => false, 'use-modules' => false, 'use-extensions' => true));
$script->startup();
$options = $script->getOptions('', '', array('-q' => 'Quiet mode'));
$script->initialize();
$cli = eZCLI::instance();
$trans = eZCharTransform::instance();
// Fetch 50 items per iteration
$limit = 50;
$offset = 0;
do {
// Fetch items with empty identifier
$rows = eZSection::fetchFilteredList(null, $offset, $limit);
if (!$rows) {
break;
}
foreach ($rows as $row) {
if ($row->attribute('identifier') == '') {
// Create a new section identifier with NAME_ID pattern
$name = $row->attribute('name');
$identifier = $trans->transformByGroup($name, 'identifier') . '_' . $row->attribute('id');
// Set new section identifier and store it
$row->setAttribute('identifier', $identifier);
$row->store();
$cli->output("Setting identifier '{$identifier}' for section '{$name}'");
}
}
$offset += $limit;
示例14: assignSectionToSubTree
static function assignSectionToSubTree($nodeID, $sectionID, $oldSectionID = false)
{
$db = eZDB::instance();
$node = eZContentObjectTreeNode::fetch($nodeID);
$nodePath = $node->attribute('path_string');
$sectionID = (int) $sectionID;
$pathString = " path_string like '{$nodePath}%' AND ";
// fetch the object id's which needs to be updated
$objectIDArray = $db->arrayQuery("SELECT\n ezcontentobject.id\n FROM\n ezcontentobject_tree, ezcontentobject\n WHERE\n {$pathString}\n ezcontentobject_tree.contentobject_id=ezcontentobject.id AND\n ezcontentobject_tree.main_node_id=ezcontentobject_tree.node_id");
if (count($objectIDArray) == 0) {
return;
}
// Who assigns which section at which node should be logged.
$section = eZSection::fetch($sectionID);
$object = $node->object();
eZAudit::writeAudit('section-assign', array('Section ID' => $sectionID, 'Section name' => $section->attribute('name'), 'Node ID' => $nodeID, 'Content object ID' => $object->attribute('id'), 'Content object name' => $object->attribute('name'), 'Comment' => 'Assigned a section to the current node and all child objects: eZContentObjectTreeNode::assignSectionToSubTree()'));
$objectSimpleIDArray = array();
foreach ($objectIDArray as $objectID) {
$objectSimpleIDArray[] = $objectID['id'];
}
$filterPart = '';
if ($oldSectionID !== false) {
$oldSectionID = (int) $oldSectionID;
$filterPart = " section_id = '{$oldSectionID}' and ";
}
$db->begin();
foreach (array_chunk($objectSimpleIDArray, 100) as $pagedObjectIDs) {
$db->query("UPDATE ezcontentobject SET section_id='{$sectionID}' WHERE {$filterPart} " . $db->generateSQLINStatement($pagedObjectIDs, 'id', false, true, 'int'));
eZSearch::updateObjectsSection($pagedObjectIDs, $sectionID);
}
$db->commit();
// clear caches for updated objects
eZContentObject::clearCache($objectSimpleIDArray);
}
示例15: createSectionDOMElement
/**
* 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;
}