Exemplo n.º 1
0
 /**
  * Render the Zend_Db_Table_Row_Abstract in a table
  *
  * @param Zend_Db_Table_Row_Abstract $row
  * @param array $options
  * @return string
  */
 public function viewRow(Zend_Db_Table_Row_Abstract $row, array $options = array())
 {
     $table = $row->getTable();
     $rowData = $row->toArray();
     $ucFirst = isset($options['ucfirst']) ? (bool) $options['ucfirst'] : true;
     $showEmpty = isset($options['showEmpty']) ? (bool) $options['showEmpty'] : false;
     $tableClass = isset($options['class']) ? $options['class'] : 'ZVHViewRowTable';
     $columns = isset($options['columns']) ? (array) $options['columns'] : null;
     $xhtml = '<table class="' . $tableClass . '">';
     if (isset($options['header'])) {
         $xhtml .= '<thead>';
         $xhtml .= '    <tr><td colspan="2">' . $options['header'] . '</td></tr>';
         $xhtml .= '</thead>';
     }
     $xhtml .= '<tbody>';
     foreach ($rowData as $key => $value) {
         if (!$table->isIdentity($key) && ($columns == null || $columns != null && in_array($key, $columns)) && (!empty($value) || empty($value) && $showEmpty)) {
             $xhtml .= '<tr>';
             $xhtml .= '    <td><strong>' . ($ucFirst ? ucfirst($key) : $key) . '</strong></td>';
             $xhtml .= '    <td>' . $value . '</td>';
             $xhtml .= '</tr>';
         }
     }
     $xhtml .= '</tbody></table>';
     return $xhtml;
 }
Exemplo n.º 2
0
 /**
  * Main entry point for this form controller
  * you must implement the form.phtml for it to work
  * correctly
  */
 public function indexAction()
 {
     $this->entity = $this->onBind();
     if (!$this->entity instanceof Zend_Db_Table_Row_Abstract) {
         throw new Gecko_Exception('A entity instance of Zend_Db_Table_Row_Abstract is required');
     }
     $Form = $this->getForm();
     $Form->populate($this->entity->toArray());
     $this->afterPopulate();
     $Request = $this->getRequest();
     if ($Request->isPost()) {
         if ($this->getForm()->isValid($Request->getPost())) {
             $this->onSubmit();
             $this->onSuccess();
         } else {
             $this->onFormInvalid();
         }
     }
     $this->view->form = $this->getForm();
 }
Exemplo n.º 3
0
 public static function rewrite(Zend_Db_Table_Row_Abstract $Row, array $Rewrite = null)
 {
     $Array = $Row->toArray();
     $ArrayRet = array();
     foreach ($Array as $Key => $Value) {
         if (isset($Rewrite[$Key])) {
             $ArrayRet[$Rewrite[$Key]] = $Value;
         } else {
             $ArrayRet[$Key] = $Value;
         }
     }
     return $ArrayRet;
 }
Exemplo n.º 4
0
 /**
  * Render the Zend_Db_Table_Row_Abstract in a table
  *
  * @param Zend_Db_Table_Row_Abstract $row
  * @return string
  */
 public function viewRow(Zend_Db_Table_Row_Abstract $row, $header = null, $columns = null)
 {
     $table = $row->getTable();
     $rowData = $row->toArray();
     $xhtml = '<table class="ZVHViewRowTable">';
     if ($header) {
         $xhtml .= '<thead>';
         $xhtml .= sprintf('<tr><td colspan="2">%s</td></tr>', $header);
         $xhtml .= '</thead>';
     }
     $xhtml .= '<tbody>';
     foreach ($rowData as $key => $value) {
         if (!$table->isIdentity($key) && ($columns != null && in_array($key, $columns))) {
             $xhtml .= '<tr>';
             $xhtml .= sprintf('<td><strong>%s</strong></td>', $key);
             $xhtml .= sprintf('<td>%s</td>', $value);
             $xhtml .= '</tr>';
         }
     }
     $xhtml .= '</tbody></table>';
     return $xhtml;
 }
Exemplo n.º 5
0
 /**
  * Returns the column/value data as an array.
  * Modified to include related and virtual rowsets
  * @return array
  */
 public function toArray()
 {
     $data = parent::toArray();
     foreach (array('_related', '_virtual') as $prop) {
         foreach ($this->{$prop} as $key => $val) {
             if ($val instanceof Zend_Db_Table_Row_Abstract || $val instanceof Zend_Db_Table_Rowset_Abstract) {
                 $data[$key] = $val->toArray();
             } else {
                 $data[$key] = $val;
             }
         }
     }
     return $data;
 }
Exemplo n.º 6
0
                           'tabela' => $this->getTable()->info('name'),

                           'registro' => $this->__get('id'),

                           'campo' => $fieldLang,

                           'lang_id' => $lang->id,

                           'valor' => $valueLang

                       ))

                       ->save()

                   ;

                   $fieldsUpdated[] = $fieldLang;

               }

               $where = array(

                   'tabela = ?' => $this->getTable()->info('name'),

                   'registro = ?' => $this->__get('id'),
Exemplo n.º 7
0
 /**
  * @param array $args
  * @return array
  */
 public function toArray(array $args = [])
 {
     if (empty($args)) {
         return parent::toArray();
     }
     $result = [];
     foreach ($args as $v) {
         $result[$v] = $this->_data[$v];
     }
     return $result;
 }
Exemplo n.º 8
0
 /**
  * Convert row to module entity
  * 
  * @param Zend_Db_Table_Row_Abstract $row
  * @param Application_Model_Module $module
  */
 private function _rowToModule(Zend_Db_Table_Row_Abstract $row, Application_Model_Module $module)
 {
     $module->setOptions($row->toArray());
     $module->set_settings($this->_getJsonData($row->settings))->set_data($this->_getJsonData($row->data));
 }