コード例 #1
0
 /**
  * Validate form fields
  * 
  * List all fields in the selected table and
  * show validate options for each field
  * 
  * @since 1.0
  * @access private
  * @return void
  */
 private function validateFields()
 {
     $this->readFields($this->choosedLayer);
     $this->loadValidationTypes();
     $table = $this->tables[$this->choosedLayer];
     foreach ($table['Fields'] as $key => $field) {
         ConsoleIgniter::line();
         ConsoleIgniter::write('Field: ' . $field['Field'] . ' Type: ' . $field['Type']);
         ConsoleIgniter::line();
         $validate = '';
         while ($validate === '') {
             $validate = ConsoleIgniter::writeQuestion('Choose a number', $this->validationTypes, 0, false, true, true);
             if (strstr($validate, ',') !== false) {
                 if (!preg_match('/^([23456789]{1}[\\d]*,|[01]{1}[\\d]+,)+([23456789]{1}[\\d]*|[01]{1}[\\d]+)$/', $validate)) {
                     ConsoleIgniter::write('The numbers 1 and 2 cannot be part of multiple rules.');
                     $validate = '';
                 }
             }
         }
         // This field don't need to be validated
         if ($validate != 0) {
             $this->setValidationField($this->tables[$this->choosedLayer]['Fields'][$key], $validate);
             $this->tables[$this->choosedLayer]['Validate'] = true;
         }
     }
     if (isset($this->tables[$this->choosedLayer]['Validate'])) {
         $this->getHumanNames();
     }
 }
コード例 #2
0
ファイル: CrudIgniter.php プロジェクト: joelviseu/CrudIgniter
 /**
  * Write the CrudIgniter welcome message
  * 
  * @since 1.0
  * @access public
  * @return void
  */
 public function welcome()
 {
     ConsoleIgniter::write('');
     ConsoleIgniter::write('****************************************************************');
     ConsoleIgniter::write('************************* CRUD IGNITER *************************');
     ConsoleIgniter::write('*********************** IGNITE YOUR CRUD ***********************');
     ConsoleIgniter::write('****************************************************************');
     ConsoleIgniter::line();
     ConsoleIgniter::write('');
 }
コード例 #3
0
 /**
  * Create the project's database configurations file
  * 
  * @since 1.0
  * @access private
  * @return void
  */
 private function createDbConfig()
 {
     //--------------------------------------------------------------------
     // DEFINE THE DATABASE CONFIGURATION
     //--------------------------------------------------------------------
     $db = array();
     $driverTypes = array('mysql');
     $db['dbdriver'] = $driverTypes[ConsoleIgniter::writeQuestion('What is the database driver?', $driverTypes, 0)];
     $db['hostname'] = ConsoleIgniter::writeQuestion('What is the host of the database server?', null, 'localhost');
     $db['username'] = ConsoleIgniter::writeQuestion('What is the database username?', null, 'root');
     $db['password'] = ConsoleIgniter::writeQuestion('What is the database password?', null, null, true);
     $db['database'] = ConsoleIgniter::writeQuestion('What is the name of the database?', null, 'code_igniter');
     //--------------------------------------------------------------------
     // SHOW THE DATABASE CONFIGURATION
     //--------------------------------------------------------------------
     ConsoleIgniter::write('');
     ConsoleIgniter::line();
     ConsoleIgniter::write('The following database configuration will be created.');
     ConsoleIgniter::line();
     ConsoleIgniter::write('Driver		: ' . $db['dbdriver']);
     ConsoleIgniter::write('Host			: ' . $db['hostname']);
     ConsoleIgniter::write('Username		: '******'username']);
     ConsoleIgniter::write('Password		: '******'password']);
     ConsoleIgniter::write('Database		: ' . $db['database']);
     ConsoleIgniter::line();
     $confirm = ConsoleIgniter::writeQuestion('The information above is correct?', array('y', 'n'), 0);
     if ($confirm != 0) {
         ConsoleIgniter::bye();
     }
     //--------------------------------------------------------------------
     // SAVE THE DATABASE CONFIGURATION
     //--------------------------------------------------------------------
     if (!file_exists(TEMPLATES_PATH . DS . 'db.php')) {
         ConsoleIgniter::write('ERROR!');
         ConsoleIgniter::write('Template: "' . TEMPLATES_PATH . DS . 'db.php" not found!');
         ConsoleIgniter::bye();
     }
     ob_start();
     require TEMPLATES_PATH . DS . 'db.php';
     $template = ob_get_clean();
     $template = "<?php\n" . $template;
     file_put_contents(PROJECTS_PATH . DS . self::$name . DS . 'db.php', $template);
     ConsoleIgniter::write('Database configuration was successfully created.');
 }