/** * List access client tree. * * @param array $clients * @param Zend_Db_Table_Rowset_Abstract $accessClients * @return string */ public static function listClientsRecursively($clients, $accessClients) { $html = ''; if (!$clients || !count($clients)) { return $html; } $html .= '<ul class="accessTree">'; foreach ($clients as $_client) { if (Manager_Resource_Access::getInstance()->clientInAccess($_client['id'], $accessClients->toArray())) { $_checked = true; } else { $_checked = false; } $_clientHtml = '<li rel="' . $_client['id'] . '">'; $_clientHtml .= '<input type="checkbox"' . ($_checked ? ' checked="checked"' : '') . ' />'; $_clientHtml .= $_client['name']; if (isset($_client['children']) && count($_client['children'])) { $_clientHtml .= self::listClientsRecursively($_client['children'], $accessClients); } $_clientHtml .= '</li>'; $html .= $_clientHtml; } $html .= '</ul>'; return $html; }
/** * Construct Table object from a Zend_Db_Table_Rowset * * @param Zend_Db_Table_Rowset_Abstract $rowset * @param string $tableName */ public function __construct(Zend_Db_Table_Rowset_Abstract $rowset, $tableName = null) { if($tableName == null) { $table = $rowset->getTable(); if($table !== null) { $tableName = $table->info('name'); } else { require_once "Zend/Test/PHPUnit/Db/Exception.php"; throw new Zend_Test_PHPUnit_Db_Exception( 'No table name was given to Rowset Table and table name cannot be infered from the table, '. 'because the rowset is disconnected from database.' ); } } $this->data = $rowset->toArray(); $columns = array(); if(isset($this->data[0]) > 0) { $columns = array_keys($this->data[0]); } else if($rowset->getTable() != null) { $columns = $rowset->getTable()->info('cols'); } $this->tableName = $tableName; $this->tableMetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($this->tableName, $columns); }
/** * Returns all junction table data as an array. * * Updates the $_data property with current row object values. * * @return array */ public function junctionRowsetToArray() { return $this->_junctionRowset->toArray(); }