[ Index ]
 

Code source de eZ Publish 3.9.0

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

title

Body

[fermer]

/kernel/rss/ -> edit_export.php (source)

   1  <?php
   2  //
   3  // eZSetup - init part initialization
   4  //
   5  // Created on: <18-Sep-2003 14:49:54 kk>
   6  //
   7  // SOFTWARE NAME: eZ publish
   8  // SOFTWARE RELEASE: 3.9.0
   9  // BUILD VERSION: 17785
  10  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
  11  // SOFTWARE LICENSE: GNU General Public License v2.0
  12  // NOTICE: >
  13  //   This program is free software; you can redistribute it and/or
  14  //   modify it under the terms of version 2.0  of the GNU General
  15  //   Public License as published by the Free Software Foundation.
  16  //
  17  //   This program is distributed in the hope that it will be useful,
  18  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  19  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20  //   GNU General Public License for more details.
  21  //
  22  //   You should have received a copy of version 2.0 of the GNU General
  23  //   Public License along with this program; if not, write to the Free
  24  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  25  //   MA 02110-1301, USA.
  26  //
  27  //
  28  
  29  $Module =& $Params["Module"];
  30  
  31  include_once ( 'kernel/rss/edit_functions.php' );
  32  include_once ( 'kernel/common/template.php' );
  33  include_once ( 'kernel/classes/ezrssexport.php' );
  34  include_once ( 'kernel/classes/ezrssexportitem.php' );
  35  include_once ( 'lib/ezutils/classes/ezhttppersistence.php' );
  36  
  37  $http =& eZHTTPTool::instance();
  38  
  39  $validated = false;
  40  if ( isset( $Params['RSSExportID'] ) )
  41      $RSSExportID = $Params['RSSExportID'];
  42  else
  43      $RSSExportID = false;
  44  
  45  if ( $http->hasPostVariable( 'RSSExport_ID' ) )
  46      $RSSExportID = $http->postVariable( 'RSSExport_ID' );
  47  
  48  if ( $Module->isCurrentAction( 'Store' ) )
  49  {
  50      if( $_POST['active'] == "on" and strlen( trim( $_POST['Access_URL'] ) ) == 0 )
  51      {
  52           eZRSSEditFunction::storeRSSExport( $Module, $http );
  53           $validated = true;
  54      }
  55      else
  56      {
  57          return eZRSSEditFunction::storeRSSExport( $Module, $http, true );
  58      }
  59  }
  60  else if ( $Module->isCurrentAction( 'UpdateItem' ) )
  61  {
  62      eZRSSEditFunction::storeRSSExport( $Module, $http );
  63  }
  64  else if ( $Module->isCurrentAction( 'AddItem' ) )
  65  {
  66      $rssExportItem = eZRSSExportItem::create( $RSSExportID );
  67      $rssExportItem->store();
  68      eZRSSEditFunction::storeRSSExport( $Module, $http );
  69  }
  70  else if ( $Module->isCurrentAction( 'Cancel' ) )
  71  {
  72      $rssExport = eZRSSExport::fetch( $RSSExportID, true, EZ_RSSEXPORT_STATUS_DRAFT );
  73      $rssExport->remove();
  74      return $Module->redirectTo( '/rss/list' );
  75  }
  76  else if ( $Module->isCurrentAction( 'BrowseImage' ) )
  77  {
  78      eZRSSEditFunction::storeRSSExport( $Module, $http );
  79      include_once ( 'kernel/classes/ezcontentbrowse.php' );
  80      eZContentBrowse::browse( array( 'action_name' => 'RSSExportImageBrowse',
  81                                      'description_template' => 'design:rss/browse_image.tpl',
  82                                      'from_page' => '/rss/edit_export/'. $RSSExportID .'/0/ImageSource' ),
  83                               $Module );
  84  }
  85  else if ( $Module->isCurrentAction( 'RemoveImage' ) )
  86  {
  87      $rssExport =& eZRSSExport::fetch( $RSSExportID, true, EZ_RSSEXPORT_STATUS_DRAFT );
  88      $rssExport->setAttribute( 'image_id', 0 );
  89      $rssExport->store();
  90  }
  91  
  92  
  93  if ( $http->hasPostVariable( 'Item_Count' ) )
  94  {
  95  
  96      $db =& eZDB::instance();
  97      $db->begin();
  98      for ( $itemCount = 0; $itemCount < $http->postVariable( 'Item_Count' ); $itemCount++ )
  99      {
 100          if ( $http->hasPostVariable( 'SourceBrowse_'.$itemCount ) )
 101          {
 102              eZRSSEditFunction::storeRSSExport( $Module, $http );
 103              include_once ( 'kernel/classes/ezcontentbrowse.php' );
 104              eZContentBrowse::browse( array( 'action_name' => 'RSSObjectBrowse',
 105                                              'description_template' => 'design:rss/browse_source.tpl',
 106                                              'from_page' => '/rss/edit_export/'. $RSSExportID .'/'. $http->postVariable( 'Item_ID_'.$itemCount ) .'/NodeSource' ),
 107                                       $Module );
 108              break;
 109          }
 110  
 111          // remove selected source (if any)
 112          if ( $http->hasPostVariable( 'RemoveSource_'.$itemCount ) )
 113          {
 114              $itemID = $http->postVariable( 'Item_ID_'.$itemCount );
 115              if ( ( $rssExportItem = eZRSSExportItem::fetch( $itemID, true, EZ_RSSEXPORT_STATUS_DRAFT ) ) )
 116              {
 117                  // remove the draft version
 118                  $rssExportItem->remove();
 119                  // remove the published version
 120                  $rssExportItem->setAttribute( 'status', EZ_RSSEXPORT_STATUS_VALID );
 121                  $rssExportItem->remove();
 122                  eZRSSEditFunction::storeRSSExport( $Module, $http );
 123              }
 124  
 125              break;
 126          }
 127      }
 128      $db->commit();
 129  }
 130  
 131  if ( is_numeric( $RSSExportID ) )
 132  {
 133      $rssExportID = $RSSExportID;
 134      $rssExport = eZRSSExport::fetch( $RSSExportID, true, EZ_RSSEXPORT_STATUS_DRAFT );
 135  
 136      if ( $rssExport )
 137      {
 138          include_once ( 'lib/ezlocale/classes/ezdatetime.php' );
 139          $user =& eZUser::currentUser();
 140          $contentIni =& eZIni::instance( 'content.ini' );
 141          $timeOut = $contentIni->variable( 'RSSExportSettings', 'DraftTimeout' );
 142          if ( $rssExport->attribute( 'modifier_id' ) != $user->attribute( 'contentobject_id' ) &&
 143               $rssExport->attribute( 'modified' ) + $timeOut > time() )
 144          {
 145              // locked editing
 146              $tpl =& templateInit();
 147  
 148              $tpl->setVariable( 'rss_export', $rssExport );
 149              $tpl->setVariable( 'rss_export_id', $rssExportID );
 150              $tpl->setVariable( 'lock_timeout', $timeOut );
 151  
 152              $Result = array();
 153              $Result['content'] =& $tpl->fetch( 'design:rss/edit_export_denied.tpl' );
 154              $Result['path'] = array( array( 'url' => false,
 155                                              'text' => ezi18n( 'kernel/rss', 'Really Simple Syndication' ) ) );
 156              return $Result;
 157          }
 158          else if ( $timeOut > 0 && $rssExport->attribute( 'modified' ) + $timeOut < time() )
 159          {
 160              $rssExport->remove();
 161              $rssExport = false;
 162          }
 163      }
 164      if ( !$rssExport )
 165      {
 166          $rssExport = eZRSSExport::fetch( $RSSExportID, true, EZ_RSSEXPORT_STATUS_VALID );
 167          if ( $rssExport )
 168          {
 169              $db =& eZDB::instance();
 170              $db->begin();
 171              $rssItems = $rssExport->fetchItems();
 172              $rssExport->setAttribute( 'status', EZ_RSSEXPORT_STATUS_DRAFT );
 173              $rssExport->store();
 174              foreach( array_keys( $rssItems ) as $key )
 175              {
 176                  $rssItem =& $rssItems[$key];
 177                  $rssItem->setAttribute( 'status', EZ_RSSEXPORT_STATUS_DRAFT );
 178                  $rssItem->store();
 179              }
 180              $db->commit();
 181          }
 182          else
 183          {
 184              return $Module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' );
 185          }
 186      }
 187  
 188      include_once ( 'kernel/classes/ezcontentbrowse.php' );
 189  
 190      switch ( $Params['BrowseType'] )
 191      {
 192          case 'NodeSource':
 193          {
 194              $nodeIDArray = $http->hasPostVariable( 'SelectedNodeIDArray' ) ? $http->postVariable( 'SelectedNodeIDArray' ) : null;
 195              if ( isset( $nodeIDArray ) && !$http->hasPostVariable( 'BrowseCancelButton' ) )
 196              {
 197                  $rssExportItem = eZRSSExportItem::fetch( $Params['RSSExportItemID'], true, EZ_RSSEXPORT_STATUS_DRAFT );
 198                  $rssExportItem->setAttribute( 'source_node_id', $nodeIDArray[0] );
 199                  $rssExportItem->store();
 200              }
 201          } break;
 202  
 203          case 'ImageSource':
 204          {
 205              $imageNodeIDArray = $http->hasPostVariable( 'SelectedNodeIDArray' ) ? $http->postVariable( 'SelectedNodeIDArray' ) : null;
 206              if ( isset( $imageNodeIDArray ) && !$http->hasPostVariable( 'BrowseCancelButton' ) )
 207              {
 208                  $rssExport->setAttribute( 'image_id', $imageNodeIDArray[0] );
 209              }
 210          } break;
 211      }
 212  }
 213  else // New RSSExport
 214  {
 215      include_once ( "kernel/classes/datatypes/ezuser/ezuser.php" );
 216      $user =& eZUser::currentUser();
 217      $user_id = $user->attribute( "contentobject_id" );
 218  
 219  
 220      $db =& eZDB::instance();
 221      $db->begin();
 222  
 223      // Create default rssExport object to use
 224      $rssExport = eZRSSExport::create( $user_id );
 225      $rssExport->store();
 226      $rssExportID = $rssExport->attribute( 'id' );
 227  
 228      // Create One empty export item
 229      $rssExportItem = eZRSSExportItem::create( $rssExportID );
 230      $rssExportItem->store();
 231  
 232      $db->commit();
 233  }
 234  
 235  $tpl =& templateInit();
 236  
 237  // Populate site access list
 238  $config =& eZINI::instance( 'site.ini' );
 239  
 240  $rssVersionArray = $config->variable( 'RSSSettings', 'AvailableVersionList' );
 241  $rssDefaultVersion = $config->variable( 'RSSSettings', 'DefaultVersion' );
 242  $numberOfObjectsArray = $config->variable( 'RSSSettings', 'NumberOfObjectsList' );
 243  $numberOfObjectsDefault = $config->variable( 'RSSSettings', 'NumberOfObjectsDefault' );
 244  
 245  // Get Classes and class attributes
 246  $classArray = eZContentClass::fetchList();
 247  
 248  $tpl->setVariable( 'rss_version_array', $rssVersionArray );
 249  $tpl->setVariable( 'rss_version_default', $rssDefaultVersion );
 250  $tpl->setVariable( 'number_of_objects_array', $numberOfObjectsArray );
 251  $tpl->setVariable( 'number_of_objects_default', $numberOfObjectsDefault );
 252  
 253  $tpl->setVariable( 'rss_class_array', $classArray );
 254  $tpl->setVariable( 'rss_export', $rssExport );
 255  $tpl->setVariable( 'rss_export_id', $rssExportID );
 256  
 257  $tpl->setVariable( 'validaton', $validated );
 258  $Result = array();
 259  $Result['content'] =& $tpl->fetch( "design:rss/edit_export.tpl" );
 260  $Result['path'] = array( array( 'url' => false,
 261                                  'text' => ezi18n( 'kernel/rss', 'Really Simple Syndication' ) ) );
 262  
 263  
 264  ?>


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