[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 #!/usr/bin/env php 2 <?php 3 // 4 // Created on: <19-Dec-2003 14:34:55 amos> 5 // 6 // SOFTWARE NAME: eZ publish 7 // SOFTWARE RELEASE: 3.9.0 8 // BUILD VERSION: 17785 9 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 10 // SOFTWARE LICENSE: GNU General Public License v2.0 11 // NOTICE: > 12 // This program is free software; you can redistribute it and/or 13 // modify it under the terms of version 2.0 of the GNU General 14 // Public License as published by the Free Software Foundation. 15 // 16 // This program is distributed in the hope that it will be useful, 17 // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 // GNU General Public License for more details. 20 // 21 // You should have received a copy of version 2.0 of the GNU General 22 // Public License along with this program; if not, write to the Free 23 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 24 // MA 02110-1301, USA. 25 // 26 // 27 28 set_time_limit( 0 ); 29 30 include_once ( 'lib/ezutils/classes/ezcli.php' ); 31 include_once ( 'kernel/classes/ezscript.php' ); 32 33 $cli =& eZCLI::instance(); 34 $endl = $cli->endlineString(); 35 36 $script =& eZScript::instance( array( 'description' => ( "eZ publish database flattening.\n\n" . 37 "Will remove data that is not considered currently in use to minimize the amount of database data it consumes\n" . 38 "\n" . 39 "Possible values for NAME is:\n" . 40 "contentobject, contentclass, workflow, role or all (for all items)\n" . 41 "flatten.php -s admin contentobject"), 42 'use-session' => false, 43 'use-modules' => true, 44 'use-extensions' => true ) ); 45 46 $script->startup(); 47 48 $options = $script->getOptions( "[db-user:][db-password:][db-database:][db-type:|db-driver:][sql]", 49 "[name]", 50 array( 'db-host' => "Database host", 51 'db-user' => "Database user", 52 'db-password' => "Database password", 53 'db-database' => "Database name", 54 'db-driver' => "Database driver", 55 'db-type' => "Database driver, alias for --db-driver", 56 'sql' => "Display sql queries" 57 ) ); 58 $script->initialize(); 59 60 if ( count( $options['arguments'] ) < 1 ) 61 { 62 $cli->error( "Missing NAME value ( could be contentobject, contentclass, workflow, role or all )" ); 63 $script->shutdown( 1 ); 64 } 65 66 $dbUser = $options['db-user'] ? $options['db-user'] : false; 67 $dbPassword = $options['db-password'] ? $options['db-password'] : false; 68 $dbHost = $options['db-host'] ? $options['db-host'] : false; 69 $dbName = $options['db-database'] ? $options['db-database'] : false; 70 $dbImpl = $options['db-driver'] ? $options['db-driver'] : false; 71 $showSQL = $options['sql'] ? true : false; 72 $siteAccess = $options['siteaccess'] ? $options['siteaccess'] : false; 73 74 if ( $siteAccess ) 75 { 76 changeSiteAccessSetting( $siteaccess, $siteAccess ); 77 } 78 79 80 $flattenAllItems = false; 81 $flattenItems = array(); 82 $flatten = array( 'contentobject' => false, 83 'contentclass' => false, 84 'workflow' => false, 85 'role' => false ); 86 87 foreach ( $options['arguments'] as $arg ) 88 { 89 90 $item = strtolower( $arg ); 91 if ( $item == 'all' ) 92 $flattenAllItems = true; 93 else 94 $flattenItems[] = $item; 95 } 96 97 if ( $flattenAllItems ) 98 { 99 $names = array_keys( $flatten ); 100 foreach ( $names as $name ) 101 { 102 $flatten[$name] = true; 103 } 104 } 105 else 106 { 107 if ( count( $flattenItems ) == 0 ) 108 { 109 help(); 110 exit; 111 } 112 foreach ( $flattenItems as $name ) 113 { 114 $flatten[$name] = true; 115 } 116 } 117 118 function changeSiteAccessSetting( &$siteaccess, $optionData ) 119 { 120 global $isQuiet; 121 $cli =& eZCLI::instance(); 122 if ( file_exists( 'settings/siteaccess/' . $optionData ) ) 123 { 124 $siteaccess = $optionData; 125 if ( !$isQuiet ) 126 $cli->notice( "Using siteaccess $siteaccess for flattening" ); 127 } 128 else 129 { 130 if ( !$isQuiet ) 131 $cli->notice( "Siteaccess $optionData does not exist, using default siteaccess" ); 132 } 133 } 134 135 $db =& eZDB::instance(); 136 137 if ( $dbHost or $dbName or $dbUser or $dbImpl ) 138 { 139 $params = array(); 140 if ( $dbHost !== false ) 141 $params['server'] = $dbHost; 142 if ( $dbUser !== false ) 143 { 144 $params['user'] = $dbUser; 145 $params['password'] = ''; 146 } 147 if ( $dbPassword !== false ) 148 $params['password'] = $dbPassword; 149 if ( $dbName !== false ) 150 $params['database'] = $dbName; 151 $db =& eZDB::instance( $dbImpl, $params, true ); 152 eZDB::setInstance( $db ); 153 } 154 155 $db->setIsSQLOutputEnabled( $showSQL ); 156 157 include_once ( 'kernel/classes/ezpersistentobject.php' ); 158 159 if ( $flatten['contentobject'] ) 160 { 161 include_once ( 'kernel/classes/ezcontentobject.php' ); 162 $cli->output( "Removing non-published content object versions" ); 163 eZContentObjectVersion::removeVersions(); 164 } 165 166 if ( $flatten['contentclass'] ) 167 { 168 include_once ( 'kernel/classes/ezcontentclass.php' ); 169 $cli->output( "Removing temporary content classes" ); 170 eZContentClass::removeTemporary(); 171 } 172 173 if ( $flatten['workflow'] ) 174 { 175 include_once ( 'kernel/classes/ezworkflow.php' ); 176 $cli->output( "Removing temporary workflows" ); 177 eZWorkflow::removeTemporary(); 178 } 179 180 if ( $flatten['role'] ) 181 { 182 include_once ( 'kernel/classes/ezrole.php' ); 183 $cli->output( "Removing temporary roles" ); 184 eZRole::removeTemporary(); 185 } 186 187 188 $script->shutdown(); 189 190 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |