Ejemplo n.º 1
0
 /**
  * Edit a type
  *
  * @return  void
  */
 public function editTask($row = null)
 {
     Request::setVar('hidemainmenu', 1);
     $this->view->config = $this->config;
     if (!is_object($row)) {
         // Incoming
         $id = Request::getVar('id', array(0));
         if (is_array($id)) {
             $id = !empty($id) ? $id[0] : 0;
         }
         $sponsor = new Sponsor($this->database);
         $row = $sponsor->getSponsor($id);
     }
     $this->view->sponsor = $row;
     // Set any errors
     foreach ($this->getErrors() as $error) {
         \Notify::error($error);
     }
     // Output the HTML
     $this->view->setLayout('edit')->display();
 }
Ejemplo n.º 2
0
 /**
  * Edit a citation
  *
  * @return	void
  */
 public function editTask()
 {
     //stop menu from working?
     Request::setVar('hidemainmenu', 1);
     //get request vars - expecting an array id[]=4232
     $id = Request::getVar('id', array());
     if (is_array($id)) {
         $id = !empty($id) ? $id[0] : 0;
     }
     //get all citations sponsors
     $cs = new Sponsor($this->database);
     $this->view->sponsors = $cs->getSponsor();
     //get all citation types
     $ct = new Type($this->database);
     $this->view->types = $ct->getType();
     //empty citation object
     $this->view->row = new Citation($this->database);
     //if we have an id load that citation data
     if (isset($id) && $id != '' && $id != 0) {
         // Load the citation object
         $this->view->row->load($id);
         // Get the associations
         $assoc = new Association($this->database);
         $this->view->assocs = $assoc->getRecords(array('cid' => $id));
         //get sponsors for citation
         $this->view->row_sponsors = $cs->getCitationSponsor($this->view->row->id);
         //get the citations tags
         $this->view->tags = Format::citationTags($this->view->row, \App::get('db'), false);
         //get the badges
         $this->view->badges = Format::citationBadges($this->view->row, \App::get('db'), false);
         //parse citation params
         $this->view->params = new Registry($this->view->row->params);
     } else {
         //set the creator
         $this->view->row->uid = User::get('id');
         // It's new - no associations to get
         $this->view->assocs = array();
         //array of sponsors - empty
         $this->view->row_sponsors = array();
         //empty tags and badges arrays
         $this->view->tags = array();
         $this->view->badges = array();
         //empty params object
         $this->view->params = new Registry('');
     }
     //are we padding back the citation data
     if (isset($this->row)) {
         $this->view->row = $this->row;
     }
     //are we passing back the tags from edit
     if ($this->tags != '') {
         $this->tags = explode(',', $this->tags);
         foreach ($this->tags as $tag) {
             $this->view->tags[]['raw_tag'] = $tag;
         }
     }
     //are we passing back the tags from edit
     if ($this->badges != '') {
         $this->badges = explode(',', $this->badges);
         foreach ($this->badges as $badge) {
             $this->view->badges[]['raw_tag'] = $badge;
         }
     }
     // Set any errors
     if ($this->getError()) {
         $this->view->setError($this->getError());
     }
     //set vars for view
     $this->view->config = $this->config;
     // Output the HTML
     $this->view->setLayout('edit')->display();
 }