See how to render this class

  1. <?php
  2. /**
  3.  * Report controller
  4.  *
  5.  * @author Mark Nielsen
  6.  * @version $Id$
  7.  * @package blocks/helloworld
  8.  */
  9.  
  10. defined('MOODLE_INTERNAL'or die('Direct access to this script is forbidden.');
  11.  
  12. class block_helloworld_controller_report extends mr_controller_block {
  13.     /**
  14.      * Default screen
  15.      */
  16.     public function view_action({
  17.         global $CFG$COURSE;
  18.  
  19.         #### DEMO CODE ####
  20.         require_once($CFG->dirroot.'/blocks/helloworld/report/users.php');
  21.  
  22.         $report new blocks_helloworld_report_users($this->url$COURSE->id);
  23.         $output $this->mroutput->render($report);
  24.  
  25.         // Alternative syntax...
  26.         // $output = $this->mroutput->render(
  27.         //     new blocks_helloworld_report_users($this->url, $COURSE->id)
  28.         // );
  29.         #### DEMO CODE ####
  30.  
  31.         return $this->output->heading('Demo of mr_report_abstract').
  32.                $this->helper->highlight(__CLASS____FUNCTION__true).
  33.                $output;
  34.     }
  35.  
  36.     /**
  37.      * Report JSON endpoint
  38.      */
  39.     public function autocomplete_action({
  40.         global $DB;
  41.  
  42.         $query required_param('query'PARAM_TEXT);
  43.  
  44.         $json new stdClass;
  45.         $json->results $DB->get_records_select('user''username LIKE ?'array("%$query%")'username''id, username AS text');
  46.         $json->results array_values($json->results)// Makes proper JSON
  47.         echo json_encode($json);
  48.         die;
  49.     }
  50. }

Documentation generated on Thu, 28 Jun 2012 16:33:45 -0700 by phpDocumentor 1.4.3