예제 #1
0
 /**
  * Gets the HTML code.
  *
  * @param EcrTable $table A EcrTable object
  * @param string $indent Indentation string
  *
  * @return string HTML
  */
 public function getCode(EcrTable $table, $indent = '')
 {
     $a = array();
     foreach ($table->getFields() as $field) {
         $inputType = 'text';
         $this->field = $field;
         if ($field->inputType) {
             if (method_exists($this, 'type' . $field->inputType)) {
                 $inputType = $field->inputType;
             } else {
                 JFactory::getApplication()->enqueueMessage('Unknown inputType: ' . $field->inputType, 'error');
             }
         }
         if ($inputType == 'hidden') {
             $a[] = $this->{'type' . $inputType}() . NL;
             continue;
         }
         $a[] = '<tr>';
         $a[] = '    <td width="100" align="right" class="key">';
         $a[] = '        <label for="label_' . $field->name . '">' . "<?php echo JText::_('" . $field->label . "'); ?>" . '</label>';
         $a[] = '    </td>';
         $a[] = '    <td>';
         $a[] = $this->{'type' . $inputType}();
         $a[] = '    </td>';
         $a[] = '</tr>';
     }
     //foreach
     $ret = $indent . implode(NL . $indent, $a) . NL;
     return $ret;
 }
예제 #2
0
 /**
  * Gets the HTML code.
  *
  * @param EcrTable $table A EcrTable object
  * @param string $indent Indentation string
  *
  * @return string HTML
  */
 public function getCode(EcrTable $table, $indent = '')
 {
     $a = array();
     foreach ($table->getFields() as $field) {
         if (!$field->display) {
             continue;
         }
         $inputType = 'text';
         $this->field = $field;
         if ($field->inputType) {
             if (method_exists($this, 'type' . $field->inputType)) {
                 $inputType = $field->inputType;
             } else {
                 JFactory::getApplication()->enqueueMessage('Unknown inputType: ' . $field->inputType, 'error');
             }
         }
         if ($inputType == 'xxxhidden') {
             $a[] = $this->{'type' . $inputType}() . NL;
             continue;
         }
         $a[] = '<field name="' . $field->name . '" type="' . $inputType . '"';
         if ($inputType != 'hidden') {
             $a[] = 'label="' . $field->label . '"';
             $a[] = 'description="' . $field->comment . '"';
             if ($field->extension) {
                 $a[] = 'extension="' . $field->extension . '"';
             }
         }
         $a[] = '/>';
     }
     //foreach
     $ret = $indent . implode(NL . $indent, $a) . NL;
     return $ret;
 }
예제 #3
0
 /**
  * Get the AutoCode to insert.
  *
  * @param EcrTable $table A EcrTable object
  * @param string $indent The string to indent with
  *
  * @return string
  */
 public function getCode(EcrTable $table, $indent = '')
 {
     $ret = '';
     $fields = array();
     $aliases = '';
     $relations = '';
     $fields = '';
     $charCode = 98;
     // b
     foreach ($table->getFields() as $field) {
         if (!$field->display) {
             continue;
         }
         $fields[] = 'a.' . $field->name;
     }
     //foreach
     $fields = implode(', ', $fields);
     if (count($table->getRelations())) {
         foreach ($table->getRelations() as $relation) {
             $relations .= $indent . ".' " . $relation->type . ' #__' . $relation->onTable . ' AS ' . chr($charCode) . ' ON ' . chr($charCode) . '.' . $relation->onField . ' = a.' . $relation->field . "'";
             if (count($relation->aliases)) {
                 foreach ($relation->aliases as $alias) {
                     $aliases .= ', ' . chr($charCode) . '.' . $alias->aliasField . ' AS ' . $alias->alias;
                 }
                 //foreach
             }
             $charCode++;
         }
         //foreach
         $relations .= NL;
     }
     $ret .= $indent . '$query = \' SELECT ' . $fields . $aliases . "'" . NL . $indent . '.\' FROM #__' . $table->name . ' AS a \'' . NL . $relations . ';';
     $ret .= NL;
     return $ret;
 }
예제 #4
0
 /**
  * Gets the HTML code.
  *
  * @param EcrTable $table A EcrTable object
  *
  * @return string HTML
  */
 public function getCode(EcrTable $table)
 {
     $ret = '';
     foreach ($table->getFields() as $field) {
         $ret .= EcrTableHelper::formatTableVar($field->name, $field->type, array($field->label));
         $ret .= NL;
     }
     //foreach
     return $ret;
 }
예제 #5
0
 /**
  * Gets the HTML code.
  *
  * @param EcrTable $table A EcrTable object
  * @param string $indent Indentation string
  *
  * @return string HTML
  */
 public function getCode(EcrTable $table, $indent = '')
 {
     $ret = '';
     $started = false;
     foreach ($table->getFields() as $field) {
         $ret .= $started ? $indent . ', ' : $indent . '  ';
         $started = true;
         $ret .= EcrTableHelper::formatSqlField($field);
         $ret .= NL;
     }
     //foreach
     return $ret;
 }
예제 #6
0
 /**
  * Gets the HTML code.
  *
  * @param EcrTable $table A EcrTable object
  * @param string $indent Indentation string
  *
  * @return string HTML
  */
 public function getCode(EcrTable $table, $indent = '')
 {
     $ret = '';
     foreach ($table->getFields() as $field) {
         if (!$field->display) {
             continue;
         }
         $ret .= $indent . '<div class="title">' . $field->label . '</div>' . NL;
         $ret .= $indent . '<div class="cell"><?php echo $row->' . $field->name . '; ?></div>' . NL;
     }
     //foreach
     return $ret;
 }
예제 #7
0
 /**
  * Gets the HTML code.
  *
  * @param EcrTable $table A EcrTable object
  * @param string $indent Indentation string
  *
  * @return string HTML
  */
 public function getCode(EcrTable $table, $indent = '')
 {
     $ret = '';
     foreach ($table->getFields() as $field) {
         if (!$field->display || $field->display === 'off') {
             continue;
         }
         $ret .= $indent . '<td>' . NL;
         $ret .= $indent . '    <?php echo $row->' . $field->name . '; ?>' . NL;
         $ret .= $indent . '</td>' . NL;
     }
     //foreach
     return $ret;
 }
예제 #8
0
 /**
  * Gets the HTML code.
  *
  * @param EcrTable $table A EcrTable object
  * @param string $indent Indentation string
  *
  * @return string HTML
  */
 public function getCode(EcrTable $table, $indent = '')
 {
     $ret = '';
     foreach ($table->getFields() as $field) {
         if (!$field->display || $field->display === 'off') {
             continue;
         }
         $width = $field->width ? ' width="' . $field->width . '"' : '';
         $ret .= $indent . '<th' . $width . '>' . NL;
         $ret .= $indent . '    <?php echo JText::_(\'' . $field->label . '\'); ?>' . NL;
         $ret .= $indent . '</th>' . NL;
     }
     //foreach
     return $ret;
 }
예제 #9
0
 /**
  * Gets the HTML code.
  *
  * @param EcrTable $table A EcrTable object
  * @param string $indent Indentation string
  *
  * @return string HTML
  */
 public function getCode(EcrTable $table, $indent = '')
 {
     $ret = '';
     foreach ($table->getFields() as $field) {
         if (!$field->display) {
             continue;
         }
         $width = $field->width ? ' width="' . $field->width . '"' : '';
         $ret .= $indent . '<td' . $width . ' height="20" class="sectiontableheader' . '<?php echo $this->escape($this->params->get(\'pageclass_sfx\')); ?>">' . NL;
         $ret .= $indent . '    <?php echo JHTML::_(\'grid.sort\', \'' . $field->label . '\', \'' . $field->name . '\', $this->lists[\'order_Dir\'], $this->lists[\'order\']); ?>' . NL;
         $ret .= $indent . '</td>' . NL;
     }
     //foreach
     return $ret;
 }
예제 #10
0
 /**
  * Get the AutoCode to insert.
  *
  * @param EcrTable $table A EcrTable object
  * @param string $indent The string to indent with
  *
  * @return string
  */
 public function getCode(EcrTable $table, $indent = '')
 {
     $ret = '';
     $fields = array();
     $aliases = '';
     $relations = '';
     $fields = '';
     $charCode = 98;
     // b
     foreach ($table->getFields() as $field) {
         if (!$field->display) {
             continue;
         }
         $fields[] = 'a.' . $field->name;
     }
     //foreach
     $fields = implode(', ', $fields);
     if (count($table->getRelations())) {
         foreach ($table->getRelations() as $relation) {
             $rType = str_replace(' ', '', strtolower($relation->type));
             $relations .= $indent . '$query->' . $rType . '(\' #__' . $relation->onTable . ' AS ' . chr($charCode) . ' ON ' . chr($charCode) . '.' . $relation->onField . ' = a.' . $relation->field . '\');';
             if (count($relation->aliases)) {
                 foreach ($relation->aliases as $alias) {
                     $aliases .= ', ' . chr($charCode) . '.' . $alias->aliasField . ' AS ' . $alias->alias;
                 }
                 //foreach
             }
             $charCode++;
         }
         //foreach
         $relations .= NL;
     }
     $ret .= $indent . '$query->from(\'#__' . $table->name . ' AS a \');' . NL;
     $ret .= $relations;
     $ret .= $indent . '$query->select(\'' . $fields . $aliases . '\');' . NL;
     return $ret;
 }
예제 #11
0
    /**
     * Get the CREATE string for a table.
     *
     * @param EcrTable $table The table
     *
     * @return string
     */
    public static function getTableCreate(EcrTable $table)
    {
        $db = JFactory::getDBO();
        $dbName = JFactory::getApplication()->getCfg('db');
        $tName = $db->getPrefix() . $table->name;
        $s = '';
        $s .= 'CREATE TABLE IF NOT EXISTS `#__' . $table->name . '` (' . NL;
        $pri = '';
        $started = false;
        $indent = '';
        $db->setQuery('SHOW CREATE TABLE ' . $tName);
        $engineQuery = 'SELECT ENGINE
 FROM information_schema.TABLES
 WHERE TABLE_SCHEMA = \'' . $dbName . '\'
 AND TABLE_NAME = \'' . $tName . '\'';
        $db->setQuery($engineQuery);
        $engine = $db->loadResult();
        echo 'A' . $engine;
        /*
        //        $engineQuery = ' SHOW TABLE STATUS LIKE `'.$tName.'`
        // FROM information_schema.TABLES
        // WHERE TABLE_SCHEMA = \''.$dbName.'\'
        // AND TABLE_NAME = \''.$tName.'\'';
        //        $db->setQuery($engineQuery);
        //
        //        $engine = $db->loadResult();
        //        echo 'B'.$engine;
        */
        foreach ($table->getFields() as $field) {
            if ($field->key == 'PRI') {
                $pri = $field->name;
            }
            $s .= $started ? $indent . ', ' : $indent . '  ';
            $started = true;
            $s .= EcrTableHelper::formatSqlField($field);
            $s .= NL;
        }
        //foreach
        if ($pri) {
            $s .= ', PRIMARY KEY (`' . $pri . '`)';
        }
        //-- #       $s .= ') ENGINE='.$engine.' DEFAULT CHARSET='.
        return $s;
    }