/** * namespaceGet() - get all variables in a namespace * Deprecated: Use getIterator() in Zend_Session_Namespace. * * @param string $namespace * @return array */ public static function namespaceGet($namespace) { return parent::_namespaceGetAll($namespace); }
/** * __unset() - unset a variable in this object's namespace. * * @param string $name - programmatic name of a key, in a <key,value> pair in the current namespace * @return true */ public function __unset($name) { if ($name === '') { /** * @see Zend_Session_Exception */ require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception("The '{$name}' key must be a non-empty string"); } return parent::_namespaceUnset($this->_namespace, $name); }
/** * __unset() - unset a variable in this objects namespace. * * @param string $name - programmatic name of a key, in a <key,value> pair in the current namespace * @return true */ protected function __unset($name) { if ($name === '') { throw new Zend_Session_Exception("The '{$name}' key must be a non-empty string"); } return parent::_namespaceUnset($this->_namespace, $name); }
/** * Here we go.... * * @return string */ public function deploy() { if ($this->getSource() === null) { throw new Bvb_Grid_Exception('Please Specify your source'); } if ($this->getRequest()->isPost() && $this->getRequest()->getPost('postMassIds' . $this->getGridId())) { $this->_redirect($this->getUrl(array('zfmassedit', 'send_', 'gridAction_', 'massActionsAll_'))); die; } if ($this->_allowDelete == 1 || $this->_allowEdit == 1 || $this->_allowAdd == 1) { $this->setAjax(false); } $this->_view = $this->getView(); $this->_placePageAtRecord(); if (isset($this->_ctrlParams['_zfgid']) && $this->_ctrlParams['_zfgid'] != $this->getGridId()) { return; } parent::deploy(); $this->_applyConfigOptions(array()); $this->_processForm(); if (!$this->_temp['table'] instanceof Bvb_Grid_Template_Table) { $this->setTemplate('table', 'table', $this->_templateParams); } else { $this->setTemplate($this->_temp['table']->options['name'], 'table', $this->_templateParams); } $images = $this->_temp['table']->images($this->getImagesUrl()); if ($this->_allowDelete == 1 || $this->_allowEdit == 1 || is_array($this->_detailColumns)) { $pkUrl = $this->getSource()->getIdentifierColumns($this->_data['table']); $urlFinal = ''; $failPk = false; $pkUrl2 = $pkUrl; foreach ($pkUrl as $key => $value) { foreach ($this->getFields(true) as $field) { if ($field['field'] == $value) { unset($pkUrl2[$key]); break 2; } } // throw new Bvb_Grid_Exception("You don't have your primary key in your query. // So it's not possible to perform CRUD operations. // Change your select object to include your Primary Key: " . implode(';', $pkUrl2)); } foreach ($pkUrl as $value) { if (strpos($value, '.') !== false) { $urlFinal .= '{{' . substr($value, strpos($value, '.') + 1) . '}}-'; } else { $urlFinal .= '{{' . $value . '}}-'; } } $urlFinal = trim($urlFinal, '-'); } $removeParams = array('add', 'edit'); $url = $this->getUrl($removeParams); if ($this->_allowEdit == 1 && is_object($this->_crud) && $this->_crud->getBulkEdit() !== true) { $urlEdit = $url; $this->_actionsUrls['edit'] = "{$urlEdit}/edit" . $this->getGridId() . "/" . $urlFinal; if ($this->_crud->getEditColumn() !== false) { $this->addExtraColumn(array('position' => $this->getCrudColumnsPosition(), 'name' => 'E', 'decorator' => "<a href=\"" . $this->_actionsUrls['edit'] . "\" > " . $images['edit'] . "</a>", 'edit' => true, 'order' => -2)); } } if ($this->_allowDelete && is_object($this->_crud) && $this->_crud->getBulkDelete() !== true) { if ($this->_deleteConfirmationPage == true) { $this->_actionsUrls['delete'] = "{$url}/delete" . $this->getGridId() . "/{$urlFinal}" . "/detail" . $this->getGridId() . "/1"; if ($this->_crud->getDeleteColumn() !== false) { $this->addExtraColumn(array('position' => $this->getCrudColumnsPosition(), 'name' => 'D', 'class' => 'gridDeleteColumn', 'decorator' => "<a href=\"" . $this->_actionsUrls['delete'] . "\" > " . $images['delete'] . "</a>", 'delete' => true, 'order' => -3)); } } else { $this->_actionsUrls['delete'] = "{$url}/delete/" . $urlFinal; if ($this->_crud->getDeleteColumn() !== false) { $this->addExtraColumn(array('position' => $this->getCrudColumnsPosition(), 'name' => 'D', 'class' => 'gridDeleteColumn', 'decorator' => "<a href=\"#\" onclick=\"_" . $this->getGridId() . "confirmDel('" . $this->__('Are you sure?') . "','" . $this->_actionsUrls['delete'] . "');\" > " . $images['delete'] . "</a>", 'delete' => true, 'order' => -3)); } } } if (is_array($this->_detailColumns) && $this->_isDetail == false) { $removeParams = array('add', 'edit'); $url = $this->getUrl($removeParams); $this->_actionsUrls['detail'] = "{$url}/detail" . $this->getGridId() . "/" . $urlFinal; if ($this->_showDetailColumn === true) { $this->addExtraColumn(array('position' => $this->getCrudColumnsPosition(), 'name' => 'V', 'class' => 'gridDetailColumn', 'decorator' => "<a href=\"" . $this->_actionsUrls['detail'] . "\" >" . $images['detail'] . "</a>", 'detail' => true, 'order' => -1)); } } if ($this->_allowAdd == 0 && $this->_allowDelete == 0 && $this->_allowEdit == 0) { $this->_gridSession->unsetAll(); } if (!in_array('add' . $this->getGridId(), array_keys($this->getParams())) && !in_array('edit' . $this->getGridId(), array_keys($this->getParams()))) { if ($this->_gridSession->correct === null || $this->_gridSession->correct === 0) { $this->_gridSession->unsetAll(); } } if (strlen($this->_gridSession->message) > 0) { $this->_render['message'] = $this->_temp['table']->formMessage($this->_gridSession->messageOk, $this->_gridSession->message); $this->_renderDeploy['message'] = $this->_render['message']; } if ($this->getParam('edit') && $this->_allowEdit == 1 || $this->getParam('add') && $this->_allowAdd == 1 || $this->getInfo("doubleTables") == 1) { if ($this->_allowAdd == 1 || $this->_allowEdit == 1) { // Remove the unnecessary URL params $removeParams = array('filters', 'add'); $url = $this->getUrl($removeParams); $this->_orderFormElements(); $this->_renderDeploy['form'] = $this->_form->render(); $this->_render['form'] = $this->_form->render(); $this->_showsForm = true; } } $showsForm = $this->getWillShow(); if (isset($showsForm['form']) && $showsForm['form'] == 1 && $this->getInfo("doubleTables") == 1 || !isset($showsForm['form'])) { $this->_render['start'] = $this->_temp['table']->globalStart(); $this->_renderDeploy['start'] = $this->_render['start']; } if (!$this->getParam('edit') && !$this->getParam('add') || $this->getInfo("doubleTables") == 1) { if ($this->_isDetail == true || $this->_deleteConfirmationPage == true && $this->getParam('delete')) { $columnsTemp = $this->getSource()->fetchDetail($this->getIdentifierColumnsFromUrl()); $columns = array(); foreach ($this->_fields as $orderValue) { $columns[$orderValue] = $columnsTemp[$orderValue]; } $this->_render['detail'] = $this->_temp['table']->globalStart(); if (count($this->_detailColumns) > 0) { $columns = array_intersect_key($columns, array_flip($this->_detailColumns)); } foreach ($columns as $field => $options) { $this->updateColumn($field, array('hidden' => false)); } $result = array($columns); $result = parent::_buildGrid($result); $this->_render['detail'] .= $this->_temp['table']->startDetail($this->getDetailViewTitle()); foreach ($result[0] as $value) { if (!isset($value['field'])) { continue; } if ($value['type'] == 'extraField' && !in_array($value['field'], $this->_detailColumns)) { continue; } $field = $value['field']; if (isset($value['field']) && isset($this->_data['fields'][$value['field']]['title'])) { $field = $this->__($this->_data['fields'][$value['field']]['title']); } else { $field = $this->__(ucwords(str_replace('_', ' ', $field))); } $this->_render['detail'] .= $this->_temp['table']->detail($field, $value['value']); } if ($this->getParam('delete')) { $localCancel = $this->getUrl(array('detail', 'delete')); $localDelete = $this->getUrl(array('delete', 'detail')) . "/delete" . $this->getGridId() . "/" . str_replace("view", 'delete', $this->getParam('delete')); $buttonRemove = $this->getView()->formButton('delRecordGrid', $this->__('Remove Record'), array('onclick' => "window.location='{$localDelete}'")); $buttonCancel = $this->getView()->formButton('delRecordGrid', $this->__('Cancel'), array('onclick' => "window.location='{$localCancel}'")); $this->_render['detail'] .= $this->_temp['table']->detailDelete($buttonRemove . ' ' . $buttonCancel); } else { $this->_render['detail'] .= $this->_temp['table']->detailEnd($this->getUrl(array('detail')), $this->__($this->getDetailViewReturnLabel())); } $this->_render['detail'] .= $this->_temp['table']->globalEnd(); $this->_renderDeploy['detail'] = $this->_render['detail']; } else { $this->_buildGridRender(); } } else { $this->_render['start'] = $this->_temp['table']->globalStart(); $this->_buildGridRender(false); $this->_render['end'] = $this->_temp['table']->globalEnd(); } if (isset($showsForm['form']) && $showsForm['form'] == 1 && $this->getInfo("doubleTables") == 1 || !isset($showsForm['form'])) { $this->_render['end'] = $this->_temp['table']->globalEnd(); $this->_renderDeploy['end'] = $this->_render['end']; } //Build JS $this->_printScript(); $gridId = $this->getGridId(); if (strlen($gridId) == 0) { $gridId = 'grid'; } if ($this->getParam('gridmod') == 'ajax' && $this->getInfo("ajax") !== false || $this->getRequest()->isXmlHttpRequest()) { $layout = Zend_Layout::getMvcInstance(); if ($layout instanceof Zend_Layout) { $layout->disableLayout(); } $response = Zend_Controller_Front::getInstance()->getResponse(); $response->clearBody(); $response->setBody(implode($this->_renderDeploy))->sendHeaders()->sendResponse(); die; } if ($this->getInfo("ajax") !== false) { $gridId = $this->getInfo("ajax"); } $grid = "<div id='{$gridId}'>" . implode($this->_renderDeploy) . "</div>"; if ($this->_gridSession->correct == 1) { $this->_gridSession->unsetAll(); } $this->_deploymentContent = $grid; return $this; }
/** * Here we go.... * * @return string */ public function deploy() { if ($this->getSource() === null) { throw new Bvb_Grid_Exception('Please Specify your source'); } if ($this->_allowDelete == 1 || $this->_allowEdit == 1 || $this->_allowAdd == 1) { $this->setAjax(false); } $this->_view = $this->getView(); $this->_placePageAtRecord(); if (isset($this->_ctrlParams['_zfgid']) && $this->_ctrlParams['_zfgid'] != $this->getGridId()) { return; } parent::deploy(); $this->_applyConfigOptions(array()); $this->_processForm(); if (!$this->_temp['table'] instanceof Bvb_Grid_Template_Table) { $this->setTemplate('table', 'table', $this->_templateParams); } else { $this->setTemplate($this->_temp['table']->options['name'], 'table', $this->_templateParams); } $images = $this->_temp['table']->images($this->getImagesUrl()); if ($this->_allowDelete == 1 || $this->_allowEdit == 1 || is_array($this->_detailColumns) && $this->_isDetail == false) { $pkUrl = $this->getSource()->getIdentifierColumns($this->_data['table']); $urlFinal = ''; $failPk = false; $pkUrl2 = $pkUrl; foreach ($pkUrl as $key => $value) { foreach ($this->getFields(true) as $field) { if ($field['field'] == $value) { unset($pkUrl2[$key]); break 2; } } // throw new Bvb_Grid_Exception("You don't have your primary key in your query. // So it's not possible to perform CRUD operations. // Change your select object to include your Primary Key: " . implode(';', $pkUrl2)); } foreach ($pkUrl as $value) { if (strpos($value, '.') !== false) { $urlFinal .= $value . ':{{' . substr($value, strpos($value, '.') + 1) . '}}-'; } else { $urlFinal .= $value . ':{{' . $value . '}}-'; } } $urlFinal = trim($urlFinal, '-'); } $removeParams = array('add', 'edit', 'comm'); $url = $this->getUrl($removeParams); if ($this->_allowEdit == 1 && is_object($this->_crud) && $this->_crud->getBulkEdit() !== true) { if (!is_array($this->_extraFields)) { $this->_extraFields = array(); } if ($this->_allowEdit == 1 && $this->getInfo("ajax") !== false) { $urlEdit = $this->_baseUrl . '/' . str_replace("/gridmod" . $this->getGridId() . "/ajax", "", $url); } else { $urlEdit = $url; } $this->_actionsUrls['edit'] = "{$urlEdit}/edit" . $this->getGridId() . "/1/comm" . $this->getGridId() . "/" . "mode:edit;[" . $urlFinal . "]"; if ($this->_crud->getEditColumn() !== false) { array_unshift($this->_extraFields, array('position' => 'left', 'name' => 'E', 'decorator' => "<a href=\"" . $this->_actionsUrls['edit'] . "\" > " . $images['edit'] . "</a>", 'edit' => true)); } } if ($this->_allowDelete && is_object($this->_crud) && $this->_crud->getBulkDelete() !== true) { if (!is_array($this->_extraFields)) { $this->_extraFields = array(); } if ($this->_deleteConfirmationPage == true) { $this->_actionsUrls['delete'] = "{$url}/comm" . $this->getGridId() . "/" . "mode:view;[" . $urlFinal . "]/gridDetail" . $this->getGridId() . "/1/gridRemove" . $this->getGridId() . "/1"; if ($this->_crud->getDeleteColumn() !== false) { array_unshift($this->_extraFields, array('position' => 'left', 'name' => 'D', 'decorator' => "<a href=\"" . $this->_actionsUrls['delete'] . "\" > " . $images['delete'] . "</a>", 'delete' => true)); } } else { $this->_actionsUrls['delete'] = "{$url}/comm" . $this->getGridId() . "/" . "mode:delete;[" . $urlFinal . "]"; if ($this->_crud->getDeleteColumn() !== false) { array_unshift($this->_extraFields, array('position' => 'left', 'name' => 'D', 'decorator' => "<a href=\"#\" onclick=\"_" . $this->getGridId() . "confirmDel('" . $this->__('Are you sure?') . "','" . $this->_actionsUrls['delete'] . "');\" > " . $images['delete'] . "</a>", 'delete' => true)); } } } if (is_array($this->_detailColumns) && $this->_isDetail == false) { if (!is_array($this->_extraFields)) { $this->_extraFields = array(); } $removeParams = array('add', 'edit', 'comm'); $url = $this->getUrl($removeParams, false); $this->_actionsUrls['detail'] = "{$url}/gridDetail" . $this->getGridId() . "/1/comm" . $this->getGridId(); $this->_actionsUrls['detail'] .= "/" . "mode:view;[" . $urlFinal . "]/"; if ($this->_showDetailColumn === true) { array_unshift($this->_extraFields, array('position' => 'left', 'name' => 'V', 'decorator' => "<a href=\"" . $this->_actionsUrls['detail'] . "\" >" . $images['detail'] . "</a>", 'detail' => true)); } } if ($this->_allowAdd == 0 && $this->_allowDelete == 0 && $this->_allowEdit == 0) { $this->_gridSession->unsetAll(); } if (!in_array('add' . $this->getGridId(), array_keys($this->getAllParams())) && !in_array('edit' . $this->getGridId(), array_keys($this->getAllParams()))) { if ($this->_gridSession->correct === null || $this->_gridSession->correct === 0) { $this->_gridSession->unsetAll(); } } if (strlen($this->_gridSession->message) > 0) { $this->_render['message'] = str_replace("{{value}}", $this->_gridSession->message, $this->_temp['table']->formMessage($this->_gridSession->messageOk)); $this->_renderDeploy['message'] = $this->_render['message']; } if ($this->getParam('edit') == 1 && $this->_allowEdit == 1 || $this->getParam('add') == 1 && $this->_allowAdd == 1 || $this->getInfo("doubleTables") == 1) { if ($this->_allowAdd == 1 || $this->_allowEdit == 1) { // Remove the unnecessary URL params $removeParams = array('filters', 'add'); $url = $this->getUrl($removeParams); $this->_orderFormElements(); $this->_renderDeploy['form'] = $this->_form->render(); $this->_render['form'] = $this->_form->render(); $this->_showsForm = true; } } $showsForm = $this->willShow(); if (isset($showsForm['form']) && $showsForm['form'] == 1 && $this->getInfo("doubleTables") == 1 || !isset($showsForm['form'])) { $this->_render['start'] = $this->_temp['table']->globalStart(); $this->_renderDeploy['start'] = $this->_render['start']; } if ((!$this->getParam('edit') || $this->getParam('edit') != 1) && (!$this->getParam('add') || $this->getParam('add') != 1) || $this->getInfo("doubleTables") == 1) { if ($this->_isDetail == true || $this->_deleteConfirmationPage == true && $this->getParam('gridRemove') == 1) { $columns = parent::_buildGrid(); $this->_willShow['detail'] = true; $this->_willShow['detailId'] = $this->getIdentifierColumnsFromUrl(); $this->_render['detail'] = $this->_temp['table']->globalStart(); foreach ($columns[0] as $value) { if (!isset($value['field'])) { continue; } if (isset($this->_data['fields'][$value['field']]['title'])) { $value['field'] = $this->__($this->_data['fields'][$value['field']]['title']); } else { $value['field'] = $this->__(ucwords(str_replace('_', ' ', $value['field']))); } $this->_render['detail'] .= str_replace(array('{{field}}', '{{value}}'), array($value['field'], $value['value']), $this->_temp['table']->detail()); } if ($this->getParam('gridRemove') == 1) { $localCancel = $this->getUrl(array('comm', 'gridDetail', 'gridRemove')); $localDelete = $this->getUrl(array('gridRemove', 'gridDetail', 'comm')) . "/comm" . $this->getGridId() . "/" . str_replace("view", 'delete', $this->getParam('comm')); $buttonRemove = $this->getView()->formButton('delRecordGrid', $this->__('Remove Record'), array('onclick' => "window.location='{$localDelete}'")); $buttonCancel = $this->getView()->formButton('delRecordGrid', $this->__('Cancel'), array('onclick' => "window.location='{$localCancel}'")); $this->_render['detail'] .= str_replace('{{button}}', $buttonRemove . ' ' . $buttonCancel, $this->_temp['table']->detailDelete()); } else { $this->_render['detail'] .= str_replace(array('{{url}}', '{{return}}'), array($this->getUrl(array('gridDetail', 'comm'), false), $this->__('Return')), $this->_temp['table']->detailEnd()); } $this->_render['detail'] .= $this->_temp['table']->globalEnd(); $this->_renderDeploy['detail'] = $this->_render['detail']; } else { $this->_willShow['grid'] = true; $this->_buildGridRender(); } $this->_showsGrid = true; } else { $this->_render['start'] = $this->_temp['table']->globalStart(); $this->_buildGridRender(false); $this->_render['end'] = $this->_temp['table']->globalEnd(); } if (isset($showsForm['form']) && $showsForm['form'] == 1 && $this->getInfo("doubleTables") == 1 || !isset($showsForm['form'])) { $this->_render['end'] = $this->_temp['table']->globalEnd(); $this->_renderDeploy['end'] = $this->_render['end']; } //Build JS $this->_printScript(); $gridId = $this->getGridId(); if ($this->getParam('gridmod') == 'ajax' && $this->getInfo("ajax") !== false) { $layout = Zend_Layout::getMvcInstance(); if ($layout instanceof Zend_Layout) { $layout->disableLayout(); } $response = Zend_Controller_Front::getInstance()->getResponse(); $response->clearBody(); $response->setBody(implode($this->_renderDeploy)); $response->sendResponse(); die; } if ($this->getInfo("ajax") !== false) { $gridId = $this->getInfo("ajax"); } $grid = "<div id='{$gridId}'>" . implode($this->_renderDeploy) . "</div>"; if ($this->_gridSession->correct == 1) { $this->_gridSession->unsetAll(); } $this->_deploymentContent = $grid; return $this; }