/**
  * Run the action from the command line to load data.
  * @param array $args
  * @param array $request_remainder
  */
 protected function actionCommandLine($args, $request_remainder)
 {
     $cli = new I2CE_CLI();
     $cli->addUsage("--csv=FILENAME: The CSV file to upload.\n");
     $cli->addUsage("--id=person|XXXX: The person ID of the parent form.\n");
     $cli->processArgs();
     if (!$cli->hasValue('csv') || !$cli->hasValue('id')) {
         $cli->usage();
         return;
     }
     $this->person = $this->factory->createContainer($cli->getValue('id'));
     if (!$this->person instanceof iHRIS_Person) {
         echo "Invalid id passed to education upload page.\n";
         return false;
     }
     $this->person->populate();
     $file = $cli->getValue('csv');
     if (!file_exists($file) || ($upload = fopen($file, "r")) === false) {
         echo "Could not read: " . $file . "\n";
         return;
     }
     $this->files['education'] = array();
     $this->files['education']['file'] = $upload;
     $this->files['education']['header'] = true;
     if ($this->validate()) {
         if ($this->save()) {
             echo "The CSV file was imported.\n";
         } else {
             echo "Unable to load file.\n";
         }
     } else {
         echo "There was invalid data in the file.\n";
     }
 }
 /**
  * The business method if this page is called from the commmand line
  * @param array $request_remainder the remainder of the request after the page specfication.  
  * @param array $args the array of unix style command line arguments 
  */
 protected function actionCommandLine($args, $request_remainder)
 {
     $config = I2CE::getConfig();
     if (!$config->is_parent("/modules/forms/forms")) {
         I2CE::raiseError("No Forms", E_USER_ERROR);
     }
     $config = I2CE::getConfig();
     $module = $config->config->site->module;
     if (!$module) {
         I2CE::raiseError("No site module");
     }
     $formConfig = $config->modules->forms->forms;
     $this->locale = I2CE::getRuntimeVariable('locale', false);
     if (!$this->locale) {
         $this->locale = I2CE_Locales::DEFAULT_LOCALE;
     }
     $this->locale = I2CE_Locales::ensureSelectableLocale($this->locale);
     I2CE_Locales::setPreferredLocale($this->locale);
     $forms = I2CE::getRuntimeVariable('forms', false);
     if ($forms) {
         $forms = explode(',', $forms);
     } else {
         $forms = $formConfig->getKeys('/modules/forms/forms');
         $cli = new I2CE_CLI();
         $forms = $cli->chooseMenuValues("Select Forms:", $forms);
     }
     if ($skipforms = I2CE::getRuntimeVariable('skipforms', false)) {
         $skipforms = explode('#', $skipforms);
         $t_forms = array();
         foreach ($forms as $form) {
             foreach ($skipforms as $skipform) {
                 if (preg_match('/' . $skipform . '/', $form)) {
                     continue 2;
                 }
             }
             $t_forms[] = $form;
         }
         $forms = $t_forms;
     }
     sort($forms, SORT_STRING);
     switch ($this->page) {
         case 'wiki':
             $this->wiki($forms);
             break;
         case 'dot':
             $this->dot($forms);
             break;
         case 'text':
         default:
             $this->text($forms);
             break;
     }
 }