public function run() { if (!class_exists('CwLoadDataPage')) { include dirname(__FILE__) . '/CwLoadDataPage.php'; } $obj = new CwLoadDataPage(); $yesterday = strtotime('yesterday'); $year = date('Y', $yesterday); $month = date('n', $yesterday); $day = date('j', $yesterday); $plugin_settings = $this->config->get('PLUGIN_SETTINGS'); $archive = $this->config->get('ARCHIVE_DB'); $con = FannieDB::get($plugin_settings['WarehouseDatabase']); foreach ($obj->getModels() as $class) { $obj = new $class($con); $obj->refresh_data($archive, $month, $year, $day); } }
$obj = new CwLoadDataPage(); if (php_sapi_name() != 'cli') { $obj->draw_page(); } else { function print_cli_help() { echo "Usage: php CwReloadDataPage.php [-a || -m <model file>]\n"; echo "\t[ -d <year-month-day] || [-s <start month> <start year> [-e <end month> <end year>]]\n"; echo "Specify a single date or a range of months.\n"; } $start = array(); $end = array(); $day = array(); $file = False; $all = False; $models = $obj->getModels(); for ($i = 1; $i < count($argv); $i++) { switch ($argv[$i]) { case '-s': case '--start': if (!isset($argv[$i + 1])) { print_cli_help(); echo "Missing start month\n"; return 1; } elseif (!isset($argv[$i + 2])) { print_cli_help(); echo "Missing start year\n"; return 1; } $start = array($argv[$i + 1], $argv[$i + 2]); $i += 2;