[ Index ]
 

Code source de eZ Publish 3.9.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/kernel/class/ -> view.php (source)

   1  <?php
   2  //
   3  // Created on: <18-Nov-2003 10:00:08 amos>
   4  //
   5  // SOFTWARE NAME: eZ publish
   6  // SOFTWARE RELEASE: 3.9.0
   7  // BUILD VERSION: 17785
   8  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
   9  // SOFTWARE LICENSE: GNU General Public License v2.0
  10  // NOTICE: >
  11  //   This program is free software; you can redistribute it and/or
  12  //   modify it under the terms of version 2.0  of the GNU General
  13  //   Public License as published by the Free Software Foundation.
  14  //
  15  //   This program is distributed in the hope that it will be useful,
  16  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  17  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18  //   GNU General Public License for more details.
  19  //
  20  //   You should have received a copy of version 2.0 of the GNU General
  21  //   Public License along with this program; if not, write to the Free
  22  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  23  //   MA 02110-1301, USA.
  24  //
  25  //
  26  
  27  include_once ( "kernel/classes/ezcontentclass.php" );
  28  include_once ( "kernel/classes/ezcontentclassattribute.php" );
  29  include_once ( "kernel/classes/ezcontentclassclassgroup.php" );
  30  
  31  $Module =& $Params['Module'];
  32  $LanguageCode = $Params['Language'];
  33  $http =& eZHttpTool::instance();
  34  $ClassID = null;
  35  $validation = array( 'processed' => false,
  36                       'groups' => array() );
  37  
  38  if ( isset( $Params["ClassID"] ) )
  39      $ClassID = $Params["ClassID"];
  40  $ClassVersion = null;
  41  
  42  if ( !is_numeric( $ClassID ) )
  43      return $Module->handleError( EZ_ERROR_KERNEL_NOT_FOUND, 'kernel' );
  44  
  45  $class = eZContentClass::fetch( $ClassID, true, EZ_CLASS_VERSION_STATUS_DEFINED );
  46  
  47  if ( !$class )
  48      return $Module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' );
  49  
  50  if ( !$LanguageCode)
  51      $LanguageCode = $class->attribute( 'top_priority_language_locale' );
  52  
  53  if ( $http->hasPostVariable( 'AddGroupButton' ) && $http->hasPostVariable( 'ContentClass_group' ) )
  54  {
  55      include_once ( "kernel/class/ezclassfunctions.php" );
  56      eZClassFunctions::addGroup( $ClassID, $ClassVersion, $http->postVariable( 'ContentClass_group' ) );
  57  }
  58  
  59  if ( $http->hasPostVariable( 'RemoveGroupButton' ) && $http->hasPostVariable( 'group_id_checked' ) )
  60  {
  61      include_once ( "kernel/class/ezclassfunctions.php" );
  62      if ( !eZClassFunctions::removeGroup( $ClassID, $ClassVersion, $http->postVariable( 'group_id_checked' ) ) )
  63      {
  64          $validation['groups'][] = array( 'text' => ezi18n( 'kernel/class', 'You have to have at least one group that the class belongs to!' ) );
  65          $validation['processed'] = true;
  66      }
  67  }
  68  else if ( $http->hasPostVariable( 'SetSorting' ) &&
  69            $http->hasPostVariable( 'ContentClass_default_sorting_exists' ) )
  70  {
  71      $db =& eZDB::instance();
  72      $db->begin();
  73      if ( $http->hasPostVariable( 'ContentClass_default_sorting_field' ) )
  74      {
  75          $sortingField = $http->postVariable( 'ContentClass_default_sorting_field' );
  76          $class->setAttribute( 'sort_field', $sortingField );
  77      }
  78      if ( $http->hasPostVariable( 'ContentClass_default_sorting_order' ) )
  79      {
  80          $sortingOrder = $http->postVariable( 'ContentClass_default_sorting_order' );
  81          $class->setAttribute( 'sort_order', $sortingOrder );
  82      }
  83      $class->store();
  84      $db->commit();
  85  }
  86  
  87  $attributes =& $class->fetchAttributes();
  88  include_once ( "kernel/classes/ezdatatype.php" );
  89  $datatypes =& eZDataType::registeredDataTypes();
  90  
  91  $mainGroupID = false;
  92  $mainGroupName = false;
  93  $groupList =& $class->fetchGroupList();
  94  if ( count( $groupList ) > 0 )
  95  {
  96      $mainGroupID = $groupList[0]->attribute( 'group_id' );
  97      $mainGroupName = $groupList[0]->attribute( 'group_name' );
  98  }
  99  
 100  $Module->setTitle( "Edit class " . $class->attribute( "name" ) );
 101  
 102  include_once ( "kernel/common/template.php" );
 103  $tpl =& templateInit();
 104  
 105  $res =& eZTemplateDesignResource::instance();
 106  $res->setKeys( array( array( 'class', $class->attribute( "id" ) ),
 107                        array( 'class_identifier', $class->attribute( 'identifier' ) ) ) );
 108  
 109  $tpl->setVariable( 'module', $Module );
 110  $tpl->setVariable( 'language_code', $LanguageCode );
 111  $tpl->setVariable( 'class', $class );
 112  $tpl->setVariable( 'attributes', $attributes );
 113  $tpl->setVariable( 'datatypes', $datatypes );
 114  $tpl->setVariable( 'validation', $validation );
 115  
 116  $Result = array();
 117  $Result['content'] =& $tpl->fetch( 'design:class/view.tpl' );
 118  $Result['path'] = array( array( 'url' => '/class/grouplist/',
 119                                  'text' => ezi18n( 'kernel/class', 'Classes' ) ) );
 120  if ( $mainGroupID !== false )
 121  {
 122      $Result['path'][] = array( 'url' => '/class/classlist/' . $mainGroupID,
 123                                 'text' => $mainGroupName );
 124  }
 125  $Result['path'][] = array( 'url' => false,
 126                             'text' => $class->attribute( 'name' ) );
 127  
 128  ?>


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7