Ejemplo n.º 1
0
<?php

# init
error_reporting(E_ALL | E_STRICT);
define('MAGENTO_ROOT', './');
$_mage_file = MAGENTO_ROOT . '/app/Mage.php';
require_once $_mage_file;
Mage::app();
date_default_timezone_set('Asia/Hong_Kong');
require_once './vendor/autoload.php';
use Ulrichsg\Getopt;
$getopt = new Getopt(array(array(null, 'store', Getopt::REQUIRED_ARGUMENT, 'Store ID'), array(null, 'csv', Getopt::OPTIONAL_ARGUMENT, 'Update File'), array(null, 'help', Getopt::OPTIONAL_ARGUMENT, 'Help')));
$getopt->parse();
$_store_id = $getopt->getOption('store');
if (isset($_store_id) === false) {
    $getopt->showHelp();
    die;
}
$_show_help = $getopt->getOption('help');
if (isset($_show_help) === true) {
    $_root_id = Mage::app()->getStore($_store_id)->getRootCategoryId();
    $_category = Mage::getModel('catalog/category')->setStoreId($_store_id)->load($_root_id);
    $_data = $_category->getData();
    echo 'Available Fileds: ' . PHP_EOL;
    foreach ($_data as $_key => $_value) {
        echo $_key . PHP_EOL;
    }
    $getopt->showHelp();
    die;
}
$_csv = $getopt->getOption('csv');
Ejemplo n.º 2
0
 * @author Max Späth <*****@*****.**>
 */
require_once "lib/gamefieldcontroller.php";
require_once "lib/gamefield.php";
include_once "lib/external/vendor/autoload.php";
foreach (glob('lib/output/*.php') as $file) {
    include $file;
}
foreach (glob('lib/input/*.php') as $file) {
    include $file;
}
use Ulrichsg\Getopt;
$options = new Getopt(array(array('i', 'input', Getopt::REQUIRED_ARGUMENT, 'Specifys how the start gamefield should be read, "txt" for reading from txt file'), array('f', 'filepath', Getopt::OPTIONAL_ARGUMENT, 'Path to txt file(only required if txt is choosen as input'), array('o', 'output', Getopt::REQUIRED_ARGUMENT, '"console" for console output, "png" for output as png file, "gif" for output as .gif file.'), array('c', 'numCycles', Getopt::REQUIRED_ARGUMENT, 'Number of rounds the game should play 1-*'), array('h', 'help', Getopt::NO_ARGUMENT)));
$options->parse();
if ($options->getOption("help")) {
    $options->showHelp();
} else {
    if ($options->getOption('input')) {
        $config = array();
        if ($options->getOption("filepath")) {
            $config['filePath'] = $options->getOption('filepath');
        }
        $inputClass = $options->getOption("input") . "Input";
        $input = new $inputClass($config);
        $outputClass = $options->getOption("output") . "Output";
        if ($options->getOption("numCycles")) {
            $numCycles = $options->getOption('numCycles');
            if ($options->getOption("output")) {
                $gameFieldController = new GameFieldController($input->getGameField());
                $output = new $outputClass();
                $output->output($gameFieldController, $numCycles);