[ 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_functions.php (source)

   1  <?php
   2  //
   3  // Created on: <19-Sep-2002 15:40:08 kk>
   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/ezrssexport.php' );
  28  include_once ( 'kernel/classes/ezrssexportitem.php' );
  29  include_once ( 'kernel/classes/ezrssimport.php' );
  30  include_once ( 'lib/ezutils/classes/ezhttppersistence.php' );
  31  
  32  class eZRSSEditFunction
  33  {
  34      /*!
  35       Store RSSExport
  36  
  37       \static
  38       \param Module
  39       \param HTTP
  40       \param publish ( true/false )
  41      */
  42      function storeRSSExport( &$Module, &$http, $publish = false )
  43      {
  44          // VS-DBFILE
  45  
  46          /* Kill the RSS cache */
  47          $config =& eZINI::instance( 'site.ini' );
  48          $cacheDir = eZSys::cacheDirectory();
  49          $cacheFilePath = $cacheDir . '/rss/' . md5( $http->postVariable( 'Access_URL' ) ) . '.xml';
  50          require_once ( 'kernel/classes/ezclusterfilehandler.php' );
  51          $cacheFile = eZClusterFileHandler::instance( $cacheFilePath );
  52          if ( $cacheFile->exists() )
  53          {
  54              // VS-DBFILE : FIXME: optimize not to use recursive delete.
  55              $cacheFile->delete();
  56          }
  57  
  58          $db =& eZDB::instance();
  59          $db->begin();
  60          /* Create the new RSS feed */
  61          for ( $itemCount = 0; $itemCount < $http->postVariable( 'Item_Count' ); $itemCount++ )
  62          {
  63              $rssExportItem = eZRSSExportItem::fetch( $http->postVariable( 'Item_ID_'.$itemCount ), true, EZ_RSSEXPORT_STATUS_DRAFT );
  64              if( $rssExportItem == null )
  65              {
  66                  continue;
  67              }
  68  
  69              // RSS is supposed to feed certain objects from the subnodes
  70              if ( $http->hasPostVariable( 'Item_Subnodes_'.$itemCount ) )
  71              {
  72                  $rssExportItem->setAttribute( 'subnodes', 1 );
  73              }
  74              else // Do not include subnodes
  75              {
  76                  $rssExportItem->setAttribute( 'subnodes', 0 );
  77              }
  78  
  79              $rssExportItem->setAttribute( 'class_id', $http->postVariable( 'Item_Class_'.$itemCount ) );
  80              $rssExportItem->setAttribute( 'title', $http->postVariable( 'Item_Class_Attribute_Title_'.$itemCount ) );
  81              $rssExportItem->setAttribute( 'description', $http->postVariable( 'Item_Class_Attribute_Description_'.$itemCount ) );
  82              if( $publish )
  83              {
  84                  $rssExportItem->setAttribute( 'status', 1 );
  85                  $rssExportItem->store();
  86                  // delete drafts
  87                  $rssExportItem->setAttribute( 'status', 0 );
  88                  $rssExportItem->remove();
  89              }
  90              else
  91              {
  92                  $rssExportItem->store();
  93              }
  94          }
  95          $rssExport = eZRSSExport::fetch( $http->postVariable( 'RSSExport_ID' ), true, EZ_RSSEXPORT_STATUS_DRAFT );
  96          $rssExport->setAttribute( 'title', $http->postVariable( 'title' ) );
  97          $rssExport->setAttribute( 'url', $http->postVariable( 'url' ) );
  98          // $rssExport->setAttribute( 'site_access', $http->postVariable( 'SiteAccess' ) );
  99          $rssExport->setAttribute( 'description', $http->postVariable( 'Description' ) );
 100          $rssExport->setAttribute( 'rss_version', $http->postVariable( 'RSSVersion' ) );
 101          $rssExport->setAttribute( 'number_of_objects', $http->postVariable( 'NumberOfObjects' ) );
 102          $rssExport->setAttribute( 'image_id', $http->postVariable( 'RSSImageID' ) );
 103          if ( $http->hasPostVariable( 'active' ) )
 104          {
 105              $rssExport->setAttribute( 'active', 1 );
 106          }
 107          else
 108          {
 109              $rssExport->setAttribute( 'active', 0 );
 110          }
 111          $rssExport->setAttribute( 'access_url', str_replace( array( '/', '?', '&', '>', '<' ), '',  $http->postVariable( 'Access_URL' ) ) );
 112          if ( $http->hasPostVariable( 'MainNodeOnly' ) )
 113          {
 114              $rssExport->setAttribute( 'main_node_only', 1 );
 115          }
 116          else
 117          {
 118              $rssExport->setAttribute( 'main_node_only', 0 );
 119          }
 120  
 121          if ( $publish )
 122          {
 123              $rssExport->store( true );
 124              // remove draft
 125              $rssExport->remove();
 126              $db->commit();
 127              return $Module->redirectTo( '/rss/list' );
 128          }
 129          else
 130          {
 131              $rssExport->store();
 132          }
 133          $db->commit();
 134      }
 135  }
 136  ?>


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