public function init() { $resources = new Model_Resources(); $resources->form_values['only_childs'] = 1; $result2 = $resources->getResources('resource_name', 'ASC'); $this->_list["page_name"][''] = "Select"; if ($result2) { foreach ($result2 as $row2) { $resource = $row2->getResourceName(); $arr_resources = explode("/", $resource); $second_name = !empty($arr_resources[1]) ? ucfirst($arr_resources[1]) . " - " : ""; $this->_list["page_name"][$row2->getPkId()] = ucfirst($arr_resources[0]) . " - " . $second_name . $row2->getDescription(); } } foreach ($this->_fields as $col => $name) { switch ($col) { case "description": $this->addElement("textarea", $col, array("attribs" => array("class" => "form-control", "rows" => "4"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array())); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); break; default: break; } if (in_array($col, array_keys($this->_list))) { $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => true, "required" => false, "registerInArrayValidator" => false, "multiOptions" => $this->_list[$col], "validators" => array())); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); } if (in_array($col, array_keys($this->_radio))) { $this->addElement("radio", $col, array("attribs" => array(), "allowEmpty" => true, 'separator' => '', "filters" => array("StringTrim", "StripTags"), "validators" => array(), "multiOptions" => $this->_radio[$col])); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag")->removeDecorator("<br>"); } } }
public function indexAction() { $form = new Form_Iadmin_ResourceSearch(); $form_add = new Form_Iadmin_Resources(); $params = array(); $resources = new Model_Resources(); if ($this->_request->isPost()) { if ($form->isValid($this->_request->getPost())) { $resource_name = $form->getValue('resource_name'); $resource_type = $form->getValue('resource_type'); if (!empty($resource_name)) { $params['resourceName'] = $resource_name; } if (!empty($resource_type)) { $params['resourceType'] = $resource_type; } } } else { $resource_name = $this->_getParam('resource_name'); $resource_type = $this->_getParam('resource_type'); if (!empty($resource_name)) { $params['resourceName'] = $resource_name; $form->resource_name->setValue($resource_name); } if (!empty($resource_type)) { $params['resourceType'] = $resource_type; $form->resource_type->setValue($resource_type); } } $sort = $this->_getParam("sort", "asc"); $order = $this->_getParam("order", "resource_name"); $resources->form_values = $params; $result = $resources->getResources($order, $sort); //Paginate the contest results $paginator = Zend_Paginator::factory($result); $page = $this->_getParam("page", 1); $counter = $this->_getParam("counter", 10); $paginator->setCurrentPageNumber((int) $page); $paginator->setItemCountPerPage((int) $counter); $this->view->form = $form; $this->view->form_add = $form_add; $this->view->paginator = $paginator; $this->view->sort = $sort; $this->view->order = $order; $this->view->counter = $counter; $this->view->pagination_params = $params; }
public function init() { $em = Zend_Registry::get("doctrine"); $result = $em->getRepository("ResourceTypes")->findAll(); $this->_list["resource_type"][''] = "Select"; foreach ($result as $rs) { $this->_list["resource_type"][$rs->getPkId()] = $rs->getResourceType(); } $resources = new Model_Resources(); $result2 = $resources->getResources('resource_name', 'ASC'); $this->_list["parent_id"][''] = "Select"; if ($result2) { foreach ($result2 as $row2) { $resource = $row2->getResourceName(); $arr_resources = explode("/", $resource); $second_name = !empty($arr_resources[1]) ? ucfirst($arr_resources[1]) . " - " : ""; $this->_list["parent_id"][$row2->getPkId()] = ucfirst($arr_resources[0]) . " - " . $second_name . $row2->getDescription(); } } for ($a = 1; $a <= 20; $a++) { $this->_list["rank"][$a] = $a; } for ($b = 1; $b <= 10; $b++) { $this->_list["level"][$b] = $b; } foreach ($this->_fields as $col => $name) { switch ($col) { case "resource_name": case "description": case "page_title": case "meta_title": $this->addElement("text", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array())); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); break; case "meta_desc": $this->addElement("textarea", $col, array("attribs" => array("class" => "form-control", "rows" => "4"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array())); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); break; default: break; } if (in_array($col, array_keys($this->_list))) { $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => true, "required" => false, "registerInArrayValidator" => false, "multiOptions" => $this->_list[$col], "validators" => array())); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); } } }