public function getAttributes($hostParentId = null) { $attr = new Ot_Model_DbTable_CustomAttribute(); $where = $attr->getAdapter()->quoteInto('hostKey = ?', $this->getKey()); $results = $attr->fetchAll($where, 'order')->toArray(); $attributes = array(); $ftr = new Ot_CustomAttribute_FieldTypeRegister(); $fieldTypes = $ftr->getFieldTypes(); foreach ($results as $r) { if (!isset($fieldTypes[$r['fieldTypeKey']])) { continue; } $r['fieldType'] = $fieldTypes[$r['fieldTypeKey']]; $r['var'] = $r['fieldType']->getVar(); $r['var']->setLabel($r['label'])->setDescription($r['description'])->setOptions(unserialize($r['options']))->setName($this->getKey() . $r['attributeId'])->setRequired($r['required']); $attributes[$this->getKey() . $r['attributeId']] = $r; } if (!is_null($hostParentId)) { $attrValModel = new Ot_Model_DbTable_CustomAttributeValue(); $where = $attrValModel->getAdapter()->quoteInto('hostKey = ?', $this->getKey()) . ' AND ' . $attrValModel->getAdapter()->quoteInto('hostParentId = ?', $hostParentId); $attrValues = $attrValModel->fetchAll($where); foreach ($attrValues as $a) { if (isset($attributes[$this->getKey() . $a->attributeId])) { $attributes[$this->getKey() . $a->attributeId]['var']->setRawValue($a->value); } } } return $attributes; }
/** * Shows all attributes associated with the selected node * */ public function detailsAction() { $this->view->acl = array('index' => $this->_helper->hasAccess('index'), 'add' => $this->_helper->hasAccess('add'), 'edit' => $this->_helper->hasAccess('edit'), 'delete' => $this->_helper->hasAccess('delete'), 'attributeDetails' => $this->_helper->hasAccess('attributeDetails')); $key = $this->_getParam('key', null); if (is_null($key)) { throw new Ot_Exception_Input('msg-error-objectNotFound'); } $cahr = new Ot_CustomAttribute_HostRegister(); $thisHost = $cahr->getHost($key); if (is_null($thisHost)) { throw new Ot_Exception_Data('msg-error-objectNotSetup'); } $ftr = new Ot_CustomAttribute_FieldTypeRegister(); $fieldTypes = $ftr->getFieldTypes(); $this->_helper->pageTitle('ot-custom-details:title', $thisHost->getName()); $this->view->headScript()->appendFile('//ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.min.js'); $this->view->assign(array('attributes' => $thisHost->getAttributes(), 'host' => $thisHost, 'fieldTypes' => $fieldTypes)); }