Remove file not used now

This commit is contained in:
Michael RICOIS 2015-01-13 13:16:27 +00:00
parent be0c4cea80
commit 4e3f3b6a52

View File

@ -1,123 +0,0 @@
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
// Define application environment
define('APPLICATION_ENV', 'production');
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
/** Zend_Application */
//require_once 'Zend/Application.php';
//Use classmap autoloader - useful with opcode and realpath cache
require_once 'Zend/Loader/AutoloaderFactory.php';
require_once 'Zend/Loader/ClassMapAutoloader.php';
Zend_Loader_AutoloaderFactory::factory(array(
'Zend_Loader_ClassMapAutoloader' => array(
__DIR__ . '/../../library/Zend/autoload_classmap.php',
__DIR__ . '/../../library/Application/autoload_classmap.php',
__DIR__ . '/../../library/Scores/autoload_classmap.php',
__DIR__ . '/../../application/autoload_classmap.php',
),
'Zend_Loader_StandardAutoloader' => array(
'prefixes' => array(
'Zend' => __DIR__ . '/../../library/Zend',
'Application' => __DIR__ . '/../../library/Application',
'Scores' => __DIR__ . '/../../library/Scores',
),
'fallback_autoloader' => true
)
));
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
try {
$opts = new Zend_Console_Getopt(
//Options
array(
'help|?' => "Aide.",
'key-s' => "Genere le cache des valeurs pour un element",
'minmax' => "",
'table' => "",
'overwrite' => "Ecraser le fichier",
)
);
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
echo $e->getUsageMessage();
exit;
}
//Usage
if(isset($opts->help))
{
echo $opts->getUsageMessage();
exit;
}
$config = new Zend_Config($application->getOptions());
try {
$db = Zend_Db::factory($config->profil->db->metier);
} catch ( Exception $e ) {
exit ( $e->getMessage() );
}
Zend_Db_Table::setDefaultAdapter($db);
$fields = new Scores_Ciblage_FieldList();
$list = $fields->getItemsStruct();
foreach ( $list as $key => $item ) {
if ( $opts->key!=null && $opts->key != $key) continue;
if ( $opts->table && array_key_exists('sql', $item) ) {
$file = APPLICATION_PATH . '/../library/Scores/Table/'.$key.'.php';
if ( $opts->overwrite && file_exists($file) ) {
unlink($file);
}
if ( !file_exists($file) ) {
echo "Create cache for ".$key." => ".$file;
$values = $fields->getItemValues($key);
file_put_contents($file, "<?php\n");
file_put_contents($file, "return array(\n", FILE_APPEND);
foreach ( $values as $k => $v ) {
file_put_contents($file, "\t'".$k."' => \"".$v."\",\n", FILE_APPEND);
}
file_put_contents($file, ");", FILE_APPEND);
echo " - OK\n";
}
} elseif ( $opts->minmax && array_key_exists('minmax', $item) ) {
$file = APPLICATION_PATH . '/../library/Scores/Table/'.$key.'.php';
if ( file_exists($file) ) unlink($file);
if ( $opts->overwrite && file_exists($file) ) {
unlink($file);
}
if ( !file_exists($file) ) {
echo "Create cache for ".$key." => ".$file;
$values = $fields->getItemValues($key);
file_put_contents($file, "<?php\n");
file_put_contents($file, "return array(\n", FILE_APPEND);
file_put_contents($file, "\t'min'=> ".$values['min'].",\n", FILE_APPEND);
file_put_contents($file, "\t'max'=> ".$values['max'].",\n", FILE_APPEND);
file_put_contents($file, ");", FILE_APPEND);
echo " - OK\n";
}
}
}