[ Index ]
 

Code source de eZ Publish 3.9.0

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

title

Body

[fermer]

/update/common/scripts/ -> updaterssimport.php (source)

   1  <?php
   2  //
   3  // Definition of Updaterssimport class
   4  //
   5  // Created on: <01-Dec-2005 10:59:24 hovik>
   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  /*! \file updaterssimport.php
  30  */
  31  
  32  set_time_limit( 0 );
  33  
  34  include_once ( 'lib/ezutils/classes/ezcli.php' );
  35  include_once ( 'kernel/classes/ezscript.php' );
  36  include_once ( 'kernel/classes/ezrssimport.php' );
  37  
  38  $cli =& eZCLI::instance();
  39  $endl = $cli->endlineString();
  40  
  41  $script =& eZScript::instance( array( 'description' => ( "Update RSS import settings.\n\n" .
  42                                                           "Goes through all RSS imports and upgrades them." .
  43                                                           "\n" .
  44                                                           "updaterssimport.php"),
  45                                        'use-session' => true,
  46                                        'use-modules' => true,
  47                                        'use-extensions' => true ) );
  48  
  49  $script->startup();
  50  
  51  $options = $script->getOptions( "[db-host:][db-user:][db-password:][db-database:][db-type:|db-driver:][sql]",
  52                                  "",
  53                                  array( 'db-host' => "Database host",
  54                                         'db-user' => "Database user",
  55                                         'db-password' => "Database password",
  56                                         'db-database' => "Database name",
  57                                         'db-driver' => "Database driver",
  58                                         'db-type' => "Database driver, alias for --db-driver",
  59                                         'sql' => "Display sql queries" ) );
  60  $script->initialize();
  61  
  62  $dbUser = $options['db-user'] ? $options['db-user'] : false;
  63  $dbPassword = $options['db-password'] ? $options['db-password'] : false;
  64  $dbHost = $options['db-host'] ? $options['db-host'] : false;
  65  $dbName = $options['db-database'] ? $options['db-database'] : false;
  66  $dbImpl = $options['db-driver'] ? $options['db-driver'] : false;
  67  $showSQL = $options['sql'] ? true : false;
  68  $siteAccess = $options['siteaccess'] ? $options['siteaccess'] : false;
  69  
  70  if ( $siteAccess )
  71  {
  72      changeSiteAccessSetting( $siteaccess, $siteAccess );
  73  }
  74  
  75  function changeSiteAccessSetting( &$siteaccess, $optionData )
  76  {
  77      global $isQuiet;
  78      $cli =& eZCLI::instance();
  79      if ( file_exists( 'settings/siteaccess/' . $optionData ) )
  80      {
  81          $siteaccess = $optionData;
  82          if ( !$isQuiet )
  83              $cli->notice( "Using siteaccess $siteaccess for rss import update" );
  84      }
  85      else
  86      {
  87          if ( !$isQuiet )
  88              $cli->notice( "Siteaccess $optionData does not exist, using default siteaccess" );
  89      }
  90  }
  91  
  92  print( "Starting object re-indexing\n" );
  93  
  94  include_once ( 'lib/ezutils/classes/ezexecution.php' );
  95  include_once ( "lib/ezutils/classes/ezdebug.php" );
  96  
  97  include_once ( 'kernel/classes/ezcontentobjecttreenode.php' );
  98  
  99  $db =& eZDB::instance();
 100  
 101  if ( $dbHost or $dbName or $dbUser or $dbImpl )
 102  {
 103      $params = array();
 104      if ( $dbHost !== false )
 105          $params['server'] = $dbHost;
 106      if ( $dbUser !== false )
 107      {
 108          $params['user'] = $dbUser;
 109          $params['password'] = '';
 110      }
 111      if ( $dbPassword !== false )
 112          $params['password'] = $dbPassword;
 113      if ( $dbName !== false )
 114          $params['database'] = $dbName;
 115      $db =& eZDB::instance( $dbImpl, $params, true );
 116      eZDB::setInstance( $db );
 117  }
 118  
 119  $db->setIsSQLOutputEnabled( $showSQL );
 120  
 121  foreach( eZRSSImport::fetchList( true, false ) as $rssImport )
 122  {
 123      if ( $rssImport->attribute( 'import_description' ) != '' )
 124      {
 125          continue;
 126      }
 127  
 128      $classAttributeDescription = array();
 129  
 130      $classAttributeList = eZContentClassAttribute::fetchListByClassID( $rssImport->attribute( 'class_id' ) );
 131      foreach( $classAttributeList as $classAttribute )
 132      {
 133          if ( $classAttribute->attribute( 'identifier' ) == $rssImport->attribute( 'class_title' ) )
 134          {
 135              $classAttributeDescription[$classAttribute->attribute( 'id' )] = 'item - elements - title';
 136          }
 137  
 138          if ( $classAttribute->attribute( 'identifier' ) == $rssImport->attribute( 'class_url' ) )
 139          {
 140              $classAttributeDescription[$classAttribute->attribute( 'id' )] = 'item - elements - link';
 141          }
 142  
 143          if ( $classAttribute->attribute( 'identifier' ) == $rssImport->attribute( 'class_description' ) )
 144          {
 145              $classAttributeDescription[$classAttribute->attribute( 'id' )] = 'item - elements - description';
 146          }
 147      }
 148  
 149      $importDescription = array( 'rss_version' => $rssImport->getRSSVersion( $rssImport->attribute( 'url' ) ),
 150                                  'object_attributes' => array(),
 151                                  'class_attributes' => $classAttributeDescription );
 152  
 153      $rssImport->setImportDescription( $importDescription );
 154  
 155      $rssImport->store();
 156  }
 157  
 158  print( $endl . "done" . $endl );
 159  
 160  $script->shutdown();
 161  
 162  ?>


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