/** * 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; }
public function __construct(Zend_Db_Table_Row_Abstract $task) { if (!$task->getTable() instanceof Core_Model_DbTable_Tasks) { throw new Core_Model_Exception('Task must belong to the Core_Model_DbTable_Tasks table'); } $this->_task = $task; }
/** * Constructor * * @param Zend_Db_Table_Row_Abstract $task */ public function __construct(Zend_Db_Table_Row_Abstract $task) { if (!$task->getTable() instanceof Core_Model_DbTable_Tasks) { throw new Core_Model_Exception(sprintf('Task must belong to the ' . 'Core_Model_DbTable_Tasks table, ' . 'given %s', get_class($task->getTable()))); } $this->_task = $task; }
/** * * * @param Zend_Db_Table_Row_Abstract $row * @return void */ public function postSaveRow(Zend_Db_Table_Row_Abstract $photo) { if (false === $this->_extractExif || 'Photos' != get_class($photo->getTable())) { return; } $exif = $photo->getTable()->readExif($photo); $photo->getTable()->addExif($photo, $exif); }
/** * Implement this by setting $obj values (e.g. $obj->setId($row->Id) from a DB row * @param GD_Model_Project $obj * @param Zend_Db_Table_Row_Abstract $row */ protected function populateObjectFromRow(&$obj, Zend_Db_Table_Row_Abstract $row) { $obj->setId($row->id)->setName($row->name)->setSlug($row->slug)->setRepositoryTypesId($row->repository_types_id)->setRepositoryUrl($row->repository_url)->setDeploymentBranch($row->deployment_branch)->setSSHKeysId($row->ssh_keys_id); $pk_map = new GD_Model_SSHKeysMapper(); $public_key = new GD_Model_SSHKey(); $pk_map->populateObjectFromRow($public_key, $row->findParentRow('GD_Model_DbTable_SSHKeys')); $obj->setSSHKey($public_key); }
/** * Implement this by setting $obj values (e.g. $obj->setId($row->Id) from a DB row * @param GD_Model_Server $obj * @param Zend_Db_Table_Row_Abstract $row */ protected function populateObjectFromRow(&$obj, Zend_Db_Table_Row_Abstract $row) { $crypt = new GD_Crypt(); $decrypted_pwd = $crypt->doDecrypt($row->password); $obj->setId($row->id)->setName($row->name)->setHostname($row->hostname)->setConnectionTypesId($row->connection_types_id)->setPort($row->port)->setUsername($row->username)->setPassword($decrypted_pwd)->setRemotePath($row->remote_path)->setProjectsId($row->projects_id); $ct_map = new GD_Model_ConnectionTypesMapper(); $connection_type = new GD_Model_ConnectionType(); $ct_map->populateObjectFromRow($connection_type, $row->findParentRow('GD_Model_DbTable_ConnectionTypes')); $obj->setConnectionType($connection_type); }
/** * Implement this by setting $obj values (e.g. $obj->setId($row->Id) from a DB row * @param GD_Model_DeploymentFile $obj * @param Zend_Db_Table_Row_Abstract $row */ protected function populateObjectFromRow(&$obj, Zend_Db_Table_Row_Abstract $row) { $obj->setId($row->id)->setDeploymentsId($row->deployments_id)->setDeploymentFileActionsId($row->deployment_file_actions_id)->setDeploymentFileStatusesId($row->deployment_file_statuses_id)->setDetails($row->details); $dfa_map = new GD_Model_DeploymentFileActionsMapper(); $deployment_file_action = new GD_Model_DeploymentFileAction(); $dfa_map->populateObjectFromRow($deployment_file_action, $row->findParentRow('GD_Model_DbTable_DeploymentFileActions')); $obj->setDeploymentFileAction($deployment_file_action); $dfs_map = new GD_Model_DeploymentFileStatusesMapper(); $deployment_file_status = new GD_Model_DeploymentFileStatus(); $dfs_map->populateObjectFromRow($deployment_file_status, $row->findParentRow('GD_Model_DbTable_DeploymentFileStatuses')); $obj->setDeploymentFileStatus($deployment_file_status); }
/** * Implement this by setting $obj values (e.g. $obj->setId($row->Id) from a DB row * @param GD_Model_ConfigServer $obj * @param Zend_Db_Table_Row_Abstract $row */ protected function populateObjectFromRow(&$obj, Zend_Db_Table_Row_Abstract $row) { $obj->setId($row->id)->setServersId($row->servers_id)->setConfigsId($row->configs_id); $s_map = new GD_Model_ServersMapper(); $server = new GD_Model_Server(); $s_map->populateObjectFromRow($server, $row->findParentRow('GD_Model_DbTable_Servers')); $obj->setServer($server); $c_map = new GD_Model_ConfigsMapper(); $config = new GD_Model_Config(); $c_map->populateObjectFromRow($config, $row->findParentRow('GD_Model_DbTable_Configs')); $obj->setConfig($config); }
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; }
/** * Implement this by setting $obj values (e.g. $obj->setId($row->Id) from a DB row * @param GD_Model_Config $obj * @param Zend_Db_Table_Row_Abstract $row */ protected function populateObjectFromRow(&$obj, Zend_Db_Table_Row_Abstract $row) { $obj->setId($row->id)->setProjectsId($row->projects_id)->setDateAdded($row->date_added)->setAddedUsersId($row->added_users_id)->setDateUpdated($row->date_updated)->setUpdatedUsersId($row->updated_users_id)->setFilename($row->filename)->setContent($row->content); $p_map = new GD_Model_ProjectsMapper(); $project = new GD_Model_Project(); $p_map->populateObjectFromRow($project, $row->findParentRow('GD_Model_DbTable_Projects')); $obj->setProject($project); $u_map = new GD_Model_UsersMapper(); $added_user = new GD_Model_User(); $u_map->populateObjectFromRow($added_user, $row->findParentRow('GD_Model_DbTable_Users', 'GD_Model_DbTable_Users+Added')); $obj->setAddedUser($added_user); $updated_user = new GD_Model_User(); $u_map->populateObjectFromRow($updated_user, $row->findParentRow('GD_Model_DbTable_Users', 'GD_Model_DbTable_Users+Updated')); $obj->setUpdatedUser($updated_user); }
public function __get($var) { if ($var == 'id') { return $this->getId(); } return parent::__get($var); }
/** * Constructor. * * @param int $applicantId optional * @return void */ public function __construct(array $config = array(), $applicantId = null) { parent::__construct($config); if ($applicantId) { $this->id = $applicantId; } }
/** * Constructor. * * @param int $id optional * @return void */ public function __construct(array $config = array(), $id = null) { parent::__construct($config); if ($id) { $this->tqa_id = $id; } }
function __get($key) { if (method_exists($this, $key)) { return $this->{$key}(); } return parent::__get($key); }
/** * Constructor. * * @param int $testId optional * @return void */ public function __construct(array $config = array(), $testId = null) { parent::__construct($config); if ($testId) { $this->t_id = $testId; } }
public function findManyToManyRowset($matchTable, $intersectionTable, $callerRefRule = null, $matchRefRule = null, Zend_Db_Table_Select $select = null) { // Possível Informação de Chaves if (is_string($intersectionTable) && is_string($matchTable) && !isset($callerRefRule, $matchRefRule)) { $needle1 = $intersectionTable; $mapper1 = $this->getTable()->info(Zend_Db_Table::DEPENDENT_TABLES); // Busca por Chave como Referência if (array_key_exists($needle1, $mapper1)) { // Chave Encontrada // Construindo Tabela Intermediária $intersection = $this->_getTableFromString($mapper1[$needle1]); $needle2 = $matchTable; $mapper2 = $intersection->info(Zend_Db_Table::REFERENCE_MAP); // Busca por Chave como Referência if (array_key_exists($needle2, $mapper2)) { // Chave Encontrada // Transformando a Pesquisa $intersectionTable = $mapper1[$needle1]; // Tabela Real = Mapeamento $matchTable = $mapper2[$needle2]['refTableClass']; // Intersecção Real = Mapeamento } } } return parent::findManyToManyRowset($matchTable, $intersectionTable, $callerRefRule, $matchRefRule, $select); }
public function __set($columnName, $value) { try { return parent::__set($columnName, $value); } catch (Exception $e) { return $this->_setRelation(ucfirst($columnName), $value); } }
public function save() { // Checagem de Codificação MD5 if (!preg_match('/^[a-fA-F0-9]{32}$/', $this->password)) { $this->password = md5($this->password); } return parent::save(); }
public function setData($key, $value = null) { if (is_null($value) and is_array($key)) { return $this->mergeData($key); } parent::__set($key, $value); return $this; }
public function __construct($config = array()) { if (array_key_exists('data', $config)) { $config['data']['id'] = (int) $config['data']['id']; $config['data']['randomNumber'] = (int) $config['data']['randomNumber']; } parent::__construct($config); }
/** * Moves the record position one above * @param Zend_Db_Table_Row_Abstract $widget * @return boolean|Ambigous <mixed, multitype:> */ function moveUp(Zend_Db_Table_Row_Abstract $widget) { $ordering = $widget->ordering; if ($ordering < 1) { return false; } else { $select = $this->select()->order('ordering DESC')->where("ordering < ?", $ordering, Zend_Db::INT_TYPE)->where("position = ?", $widget->position); $previousItem = $this->fetchRow($select); if ($previousItem) { $previousPosition = $previousItem->ordering; $previousItem->ordering = $ordering; $previousItem->save(); $widget->ordering = $previousPosition; return $widget->save(); } } return false; }
/** * Returns permissions assigned to a specific role * @param Zend_Db_Table_Row_Abstract $resource * @param Zend_Db_Table_Row_Abstract $role * @return Ambigous <Zend_Db_Table_Row_Abstract, NULL, unknown> */ function getByResource(Zend_Db_Table_Row_Abstract $resource, Zend_Db_Table_Row_Abstract $role) { #var_dump($role); $select = $this->select()->setIntegrityCheck(false)->from(array('perm' => $this->_name), array('privilege', 'role_id'))->joinInner(array('rop' => Zend_Registry::get('tablePrefix') . 'acl_role'), 'perm.role_id = rop.id', 'rop.name')->where("role_id = ?", $role->id, Zend_Db::INT_TYPE)->where("resource_id = ?", $resource->id, Zend_Db::INT_TYPE)->limit(1); #echo $select->__toString().'<br>' $mdlRole = new Acl_Model_Role(); $select2 = $mdlRole->select()->order('priority DESC')->limit(1); if (is_null($this->fetchRow($select))) { $childRole = $role->findDependentRowset('Acl_Model_Role', null, $select2)->current(); if (!is_null($childRole)) { return $this->getByResource($resource, $childRole); } } /*else { return $this->fetchRow($select); }*/ return $this->fetchRow($select); }
/** * @param string|Zend_Db_Table_Abstract $matchTable * @param string|Zend_Db_Table_Abstract $intersectionTable * @param string OPTIONAL $callerRefRule * @param string OPTIONAL $matchRefRule * @param Zend_Db_Table_Select OPTIONAL $select * @return Zend_Db_Table_Rowset_Abstract Query result from $matchTable * @throws Zend_Db_Table_Row_Exception If $matchTable or $intersectionTable is not a table class or is not loadable. */ public function findManyToManyRowset($matchTable, $intersectionTable, $callerRefRule = null, $matchRefRule = null, Zend_Db_Table_Select $select = null) { if (is_string($matchTable)) { $matchTable = System_Locator_TableLocator::getInstance()->get($matchTable); } if (is_string($intersectionTable)) { $intersectionTable = System_Locator_TableLocator::getInstance()->get($intersectionTable); } return parent::findManyToManyRowset($matchTable, $intersectionTable, $callerRefRule, $matchRefRule, $select); }
/** * Implement this by setting $obj values (e.g. $obj->setId($row->Id) from a DB row * @param GD_Model_Deployment $obj * @param Zend_Db_Table_Row_Abstract $row */ protected function populateObjectFromRow(&$obj, Zend_Db_Table_Row_Abstract $row) { $obj->setId($row->id)->setUsersId($row->users_id)->setProjectsId($row->projects_id)->setWhen($row->when)->setServersId($row->servers_id)->setFromRevision($row->from_revision)->setToRevision($row->to_revision)->setComment($row->comment)->setDeploymentStatusesId($row->deployment_statuses_id); $u_map = new GD_Model_UsersMapper(); $user = new GD_Model_User(); $u_map->populateObjectFromRow($user, $row->findParentRow('GD_Model_DbTable_Users')); $obj->setUser($user); $p_map = new GD_Model_ProjectsMapper(); $project = new GD_Model_Project(); $p_map->populateObjectFromRow($project, $row->findParentRow('GD_Model_DbTable_Projects')); $obj->setProject($project); $s_map = new GD_Model_ServersMapper(); $server = new GD_Model_Server(); $s_map->populateObjectFromRow($server, $row->findParentRow('GD_Model_DbTable_Servers')); $obj->setServer($server); $ds_map = new GD_Model_DeploymentStatusesMapper(); $deployment_status = new GD_Model_DeploymentStatus(); $ds_map->populateObjectFromRow($deployment_status, $row->findParentRow('GD_Model_DbTable_DeploymentStatuses')); $obj->setDeploymentStatus($deployment_status); }
/** * Always perform filtering when the content of an object is fed from an input */ function setFromArray($input) { // Clean up foreach ($input as $key => $value) { if (is_string($value) and $this->_filterData) { $input[$key] = htmlSpecialChars($value, ENT_NOQUOTES); } } // OK, now call the parent function parent::setFromArray($input); }
/** * 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(); }
/** * Constructor * * @param Zend_Db_Table_Row_Abstract $row * @param string|Zend_Db_Table_Abstract $matchTableName * @param string|Zend_Db_Table_Abstract $junctionTableName * @param string $matchRefRule * @throws Zend_Db_Table_Rowset_Exception */ public function __construct(Zend_Db_Table_Row_Abstract $row, $matchTableName, $junctionTableName, $matchRefRule = null) { $this->_matchRowset = $row->findManyToManyRowset($matchTableName, $junctionTableName); $this->_junctionRowset = $row->findDependentRowset($junctionTableName); if (count($this->_matchRowset) != count($this->_junctionRowset)) { throw new Zend_Db_Table_Rowset_Exception('Mismatch in values returned in the matching rowset and the junction rowset'); } // set count $this->_count = count($this->_matchRowset); // prepare junction rowset index (to ensure order) $junctionData = $this->_junctionRowset->toArray(); // will get raw data, no iteration // get name of column to key off of /* @var $t Zend_Db_Table */ $junctionTable = new $junctionTableName(); $this->_referenceMap = $junctionTable->getReference($matchTableName, $matchRefRule); foreach ($junctionData as $index => $data) { $this->_junctionRowsetIndex[$index] = $data[$this->_referenceMap['columns'][0]]; // @todo: identify use case with compound key } }
public function __call($method, array $args) { if (!preg_match('~^(set|get)([A-Z_])(.*)$~', $method, $matches)) { return parent::__call($method, $args); } //$property = strtolower($matches[2]) . $matches[3]; $property = $matches[2] . $matches[3]; if ($matches[1] == 'set') { $this->__set($property, $args[0]); return $this; } return $this->__get($property); }
/** * 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; }
protected function _notifyObservers($event) { if (!empty(self::$_observers)) { foreach (array_keys(self::$_observers) as $observer) { call_user_func_array(array($observer, 'observeTableRow'), array($event, $this)); } } parent::_postInsert(); }