/** * The main method to be called from the controller */ public function execute() { try { $result = $this->run(); display_json(ErrCode::OK, $result); } catch (CofException $e) { display_json($e->getCode(), $e->getResult(), $e->getMessage()); } }
/** * Users API - DO NOT LEAVE THIS ACTIVE IN A PRODUCTION ENVIRONMENT !!! - for demo purposes only */ public function users() { // load the users model and admin language file $this->load->model('users_model'); $this->lang->load('admin'); // get user data $users = $this->users_model->get_all(); $results['data'] = NULL; if ($users) { // build usable array foreach ($users['results'] as $user) { $results['data'][$user['id']] = array('name' => $user['first_name'] . " " . $user['last_name'], 'email' => $user['email'], 'status' => $user['status'] ? lang('admin input active') : lang('admin input inactive')); } $results['total'] = $users['total']; } else { $results['error'] = lang('core error no_results'); } // display results using the JSON formatter helper display_json($results); exit; }
/** * Marks email message as read * * @param int $id * @return boolean */ public function read($id) { if ($id) { $read = $this->contact_model->read($id, $this->user['id']); if ($read) { $results['success'] = lang('contact msg updated'); } else { $results['error'] = lang('contact error update_failed'); } } else { $results['error'] = lang('contact error update_failed'); } display_json($results); exit; }
function display($item, $display_type) { // We might be able to redirect if ($display_type == DISPLAY_REDIRECT) { $can_redirect = false; // DOI if (isset($item->doi)) { $can_redirect = true; header("Location: " . "http://dx.doi.org/" . $item->doi); exit(0); } if (!$can_redirect) { // Can't redirect $display_type = DISPLAY_HTML; } } switch ($display_type) { case DISPLAY_JSON: display_json($item); break; case DISPLAY_BIBJSON: display_bibjson($item); break; case DISPLAY_RDF: display_rdf($item); break; case DISPLAY_CITE: display_cite($item); break; case DISPLAY_ITAXON: display_publication_itaxon($item); break; case DISPLAY_RIS: header("Content-type: text/plain; charset=utf-8\n\n"); $ris = ''; $ris .= "TY - JOUR\n"; $ris .= "TI - " . $item->atitle . "\n"; if (isset($item->title)) { $ris .= "JF - " . $item->title . "\n"; } if (isset($item->issn)) { $ris .= "SN - " . $item->issn . "\n"; } if (isset($item->volume)) { $ris .= "VL - " . $item->volume . "\n"; } if (isset($item->issue)) { $ris .= "IS - " . $item->issue . "\n"; } if (isset($item->spage)) { $ris .= "SP - " . $item->spage . "\n"; } if (isset($item->epage)) { $ris .= "EP - " . $item->epage . "\n"; } if (isset($item->year)) { $ris .= "Y1 - " . $item->year . "///\n"; } if (isset($item->doi)) { $ris .= "DO - " . $item->doi . "\n"; } if (isset($item->url)) { $ris .= "UR - " . $item->url . "\n"; } if (isset($item->pmid)) { $ris .= "UR - http://www.ncbi.nlm.nih.gov/pubmed/" . $item->pmid . "\n"; } if (isset($item->hdl)) { $ris .= "UR - http://hdl.handle.net/" . $item->hdl . "\n"; } if (isset($item->pdf)) { $ris .= "L1 - " . $item->pdf . "\n"; } if (isset($item->abstract)) { $ris .= "N2 - " . $item->abstract . "\n"; } $ris .= "ER - \n\n"; echo $ris; break; case DISPLAY_HTML: default: display_html($item); break; } }