|
eZ Publish
[4.0]
|
00001 #!/usr/bin/env php 00002 <?php 00003 // 00004 // Created on: <24-Apr-2007 09:53:50 bjorn> 00005 // 00006 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00007 // SOFTWARE NAME: eZ Publish 00008 // SOFTWARE RELEASE: 4.0.x 00009 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS 00010 // SOFTWARE LICENSE: GNU General Public License v2.0 00011 // NOTICE: > 00012 // This program is free software; you can redistribute it and/or 00013 // modify it under the terms of version 2.0 of the GNU General 00014 // Public License as published by the Free Software Foundation. 00015 // 00016 // This program is distributed in the hope that it will be useful, 00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 // GNU General Public License for more details. 00020 // 00021 // You should have received a copy of version 2.0 of the GNU General 00022 // Public License along with this program; if not, write to the Free 00023 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00024 // MA 02110-1301, USA. 00025 // 00026 // 00027 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00028 // 00029 00030 /*! 00031 \file ezconvert2isbn13.php 00032 \class eZISBN10To13Converter ezconvert2isbn13.php 00033 \brief Converts ISBN-10 numbers to ISBN-13. 00034 00035 The script should be runned by command line with example: 00036 00037 php bin/php/ezconvert2isbn13.php --all-classes 00038 00039 Depending on the parameter, the script will search through contentobjects and convert 00040 ezisbn values in content attributes from ISBN-10 to ISBN-13. The script will also set the hyphen on the correct 00041 place as well. You should set the class attribute to ISBN-13 in the contentclass before running 00042 this script or add the flag --force as a parameter when you're running the script. 00043 00044 When --force is used, the is ISBN-13 will also be updated to ISBN-13 at the 00045 contentclass level. 00046 00047 Example: 00048 --class-id=2 Will Go through all ezisbn attributes in the class with id 2 and convert everyone which is a 00049 ISBN-10 value. 00050 --attribute-id=12 will check if this is an ISBN datatype and convert all ISBN-13 values in the 00051 attribute with id 12. 00052 --all-classes Does not have any argument, and converts all contentobject attributes that is set to ISBN-13. 00053 00054 --force or -f will work in addition to all the options above and set the class attribute to ISBN-13, even if it was 00055 ISBN-10 before. 00056 */ 00057 00058 set_time_limit( 0 ); 00059 00060 //include_once( 'lib/ezutils/classes/ezcli.php' ); 00061 //include_once( 'lib/ezdb/classes/ezdb.php' ); 00062 00063 //include_once( 'kernel/classes/ezscript.php' ); 00064 //include_once( 'kernel/classes/ezcontentclass.php' ); 00065 //include_once( 'kernel/classes/ezcontentclassattribute.php' ); 00066 //include_once( 'kernel/classes/ezcontentobject.php' ); 00067 //include_once( 'kernel/classes/ezcontentobjectattribute.php' ); 00068 00069 //include_once( 'kernel/classes/datatypes/ezisbn/ezisbntype.php' ); 00070 //include_once( 'kernel/classes/datatypes/ezisbn/ezisbn13.php' ); 00071 00072 require 'autoload.php'; 00073 00074 $cli = eZCLI::instance(); 00075 $script = eZScript::instance( array( 'description' => ( "eZ Publish ISBN-10 to ISBN-13 converter\n\n" . 00076 "Converts an ISBN-10 number to ISBN-13\n" ), 00077 'use-session' => false, 00078 'use-modules' => true, 00079 'use-extensions' => true ) ); 00080 00081 $script->startup(); 00082 00083 $options = $script->getOptions( "[class-id:][attribute-id:][all-classes][f|force]", 00084 "", 00085 array( 'class-id' => 'The class id for the ISBN attribute.', 00086 'attribute-id' => 'The attribute id for the ISBN attribute which should be converted.', 00087 'all-classes' => 'Will convert all ISBN attributes in all content classes.', 00088 'f' => 'Short alias for force.', 00089 'force' => 'Will convert all attributes even if the class is set to ISBN.' ) ); 00090 $script->initialize(); 00091 00092 $classID = $options['class-id']; 00093 $attributeID = $options['attribute-id']; 00094 $allClasses = $options['all-classes']; 00095 $force = $options['force']; 00096 00097 $params = array( 'force' => $force ); 00098 $converter = new eZISBN10To13Converter( $script, $cli, $params ); 00099 00100 $found = false; 00101 if ( $allClasses === true ) 00102 { 00103 $allClassesStatus = $converter->addAllClasses(); 00104 $found = true; 00105 } 00106 else 00107 { 00108 if ( is_numeric( $classID ) ) 00109 { 00110 $classStatus = $converter->addClass( $classID ); 00111 $found = true; 00112 } 00113 00114 if ( is_numeric( $attributeID ) ) 00115 { 00116 $attributeStatus = $converter->addAttribute( $attributeID ); 00117 $found = true; 00118 } 00119 } 00120 00121 if ( $found == true ) 00122 { 00123 if ( $converter->attributeCount() > 0 ) 00124 { 00125 $converter->execute(); 00126 } 00127 else 00128 { 00129 $cli->output( 'Did not find any ISBN attributes.' ); 00130 } 00131 } 00132 else 00133 { 00134 $script->showHelp(); 00135 } 00136 00137 $script->shutdown(); 00138 00139 ?>