From 49803ff07989528c8a9ac82034d19ea5c65311d4 Mon Sep 17 00:00:00 2001 From: LuisParada7 <146735108+LuisParada7@users.noreply.github.com> Date: Thu, 21 Mar 2024 08:28:25 -0500 Subject: [PATCH] Resolved line length violation and applied HTML formatting --- ....php_1aebe46520eef162b4cba4939fddea61.html | 154 +- ....php_77fc09509f01f7aaccd03f7ab250b7f8.html | 131 +- ....php_2098f8b10dac8279189fb64e0cf19b58.html | 182 ++- ....php_b7f1b3ef628801cb4d798615e6f51528.html | 502 +++++- ....php_d07b4f4487b0e7d8be5b9565de1680c1.html | 1431 ++++++++++++++--- ....php_df94f9c9f06a3bd8592f0a887db91e47.html | 194 ++- ....php_b33cb6a0be974c2a717c7551e2cb3392.html | 147 +- ....php_130fbc642e5778bc139412ebb569c3be.html | 510 ++++-- ....php_2d255e8d018617d4ffe86fe10e326331.html | 555 +++++-- ....php_69f093d72103b85451a8ad3f71467993.html | 540 ++++++- ....php_9809169f01018eeb3cf9d2f74794d0d5.html | 121 +- ....php_b26ad4e1eaa1277b115e31683118039b.html | 1274 ++++++++++++--- ....php_c1a862a8922f2c4590de2cdacca66e16.html | 262 ++- ....php_a164674c6c86cad0df598a0c1a4c5e7d.html | 375 ++++- ....php_f389601b3e05a1419f1535326d57dad1.html | 410 ++++- ....php_d3d1ad1ba515d5bb293bcdd3739c3ad0.html | 331 +++- ....php_a4df7da15f0287015b6305b4c2b86e1b.html | 395 ++++- ....php_907d127b4229faab06ab733be81f51f8.html | 282 +++- 18 files changed, 6401 insertions(+), 1395 deletions(-) diff --git a/docs/__examplesource/exsource__Sites_joule2-maint_blocks_helloworld_settings.php_1aebe46520eef162b4cba4939fddea61.html b/docs/__examplesource/exsource__Sites_joule2-maint_blocks_helloworld_settings.php_1aebe46520eef162b4cba4939fddea61.html index cefff006..b31b4470 100644 --- a/docs/__examplesource/exsource__Sites_joule2-maint_blocks_helloworld_settings.php_1aebe46520eef162b4cba4939fddea61.html +++ b/docs/__examplesource/exsource__Sites_joule2-maint_blocks_helloworld_settings.php_1aebe46520eef162b4cba4939fddea61.html @@ -1,38 +1,124 @@ - - - - - See how to save global config to work with this method - - - -

See how to save global config to work with this method

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Global Settings Example
  6. -
  7.  *
  8. -
  9.  * @author Mark Nielsen
  10. -
  11.  * @version $Id$
  12. -
  13.  * @package blocks/helloworld
  14. -
  15.  ***/
  16. -
  17.  
  18. -
  19. defined('MOODLE_INTERNAL'or die('Direct access to this script is forbidden.');
  20. -
  21.  
  22. -
  23. $configs   array();
  24. -
  25. $configs[new admin_setting_configtext('textexample'get_string('textexample''block_helloworld')get_string('textexampledesc''block_helloworld')'Hello World!');
  26. -
  27.  
  28. -
  29. // Define the config plugin so it is saved to
  30. -
  31. // the config_plugin table then add to the settings page
  32. -
  33. foreach ($configs as $config{
  34. -
  35.     $config->plugin 'blocks/helloworld';
  36. -
  37.     $settings->add($config);
  38. -
  39. }
  40. -
-
+ + + + + + See how to save global config to work with this method + + + + +

See how to save global config to work with this method

+
+
+
    +
  1. +
    <?php
    +
  2. +
  3. +
    /**
    +
  4. +
  5. +
     * Global Settings Example +
    +
  6. +
  7. +
     *
    +
  8. +
  9. +
     * @author Mark Nielsen +
    +
  10. +
  11. +
     * @version $Id$
    +
  12. +
  13. +
     * @package blocks/helloworld +
    +
  14. +
  15. +
     ***/
    +
  16. +
  17. +
     
    +
  18. +
  19. +
    defined('MOODLE_INTERNAL'or die('Direct access to this script is forbidden.');
    +
  20. +
  21. +
     
    +
  22. +
  23. +
    $configs   array();
    +
  24. +
  25. +
    $configs[new admin_setting_configtext('textexample'get_string('textexample''block_helloworld')get_string('textexampledesc''block_helloworld')'Hello World!');
    +
  26. +
  27. +
     
    +
  28. +
  29. +
    // Define the config plugin so it is saved to +
    +
  30. +
  31. +
    // the config_plugin table then add to the settings page +
    +
  32. +
  33. +
    foreach ($configs as $config{
    +
  34. +
  35. +
        $config->plugin 'blocks/helloworld';
    +
  36. +
  37. +
        $settings->add($config);
    +
  38. +
  39. +
    }
    +
  40. +
+
+

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

- + + \ No newline at end of file diff --git a/docs/__examplesource/exsource_e2-maint_blocks_helloworld_lib_server_response.php_77fc09509f01f7aaccd03f7ab250b7f8.html b/docs/__examplesource/exsource_e2-maint_blocks_helloworld_lib_server_response.php_77fc09509f01f7aaccd03f7ab250b7f8.html index fa1fba64..a695844b 100644 --- a/docs/__examplesource/exsource_e2-maint_blocks_helloworld_lib_server_response.php_77fc09509f01f7aaccd03f7ab250b7f8.html +++ b/docs/__examplesource/exsource_e2-maint_blocks_helloworld_lib_server_response.php_77fc09509f01f7aaccd03f7ab250b7f8.html @@ -1,36 +1,103 @@ - - - - - Example class definition - - - -

Example class definition

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Web Service Responses
  6. -
  7.  *
  8. -
  9.  * @package blocks/helloworld
  10. -
  11.  * @author Mark Nielsen
  12. -
  13.  */
  14. -
  15. class blocks_helloworld_lib_server_response extends mr_server_response_abstract {
  16. -
  17.     /**
  18. -
  19.      * Response for service: test
  20. -
  21.      *
  22. -
  23.      * @param string $say Tell the service what to say
  24. -
  25.      * @return string 
  26. -
  27.      */
  28. -
  29.     public function test($say{
  30. -
  31.         return $this->standard($say);
  32. -
  33.     }
  34. -
  35. }
  36. -
-
+ + + + + + Example class definition + + + + +

Example class definition

+
+
+
    +
  1. +
    <?php
    +
  2. +
  3. +
    /**
    +
  4. +
  5. +
     * Web Service Responses +
    +
  6. +
  7. +
     *
    +
  8. +
  9. +
     * @package blocks/helloworld +
    +
  10. +
  11. +
     * @author Mark Nielsen +
    +
  12. +
  13. +
     */
    +
  14. +
  15. +
    class blocks_helloworld_lib_server_response extends mr_server_response_abstract {
    +
  16. +
  17. +
        /**
    +
  18. +
  19. +
         * Response for service: test +
    +
  20. +
  21. +
         *
    +
  22. +
  23. +
         * @param string $say Tell the service what to say
    +
  24. +
  25. +
         * @return string  +
    +
  26. +
  27. +
         */
    +
  28. +
  29. +
        public function test($say{
    +
  30. +
  31. +
            return $this->standard($say);
    +
  32. +
  33. +
        }
    +
  34. +
  35. +
    }
    +
  36. +
+
+

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

- + + \ No newline at end of file diff --git a/docs/__examplesource/exsource_es_joule2-maint_blocks_helloworld_helper_world.php_2098f8b10dac8279189fb64e0cf19b58.html b/docs/__examplesource/exsource_es_joule2-maint_blocks_helloworld_helper_world.php_2098f8b10dac8279189fb64e0cf19b58.html index 355f2061..5894f3ba 100644 --- a/docs/__examplesource/exsource_es_joule2-maint_blocks_helloworld_helper_world.php_2098f8b10dac8279189fb64e0cf19b58.html +++ b/docs/__examplesource/exsource_es_joule2-maint_blocks_helloworld_helper_world.php_2098f8b10dac8279189fb64e0cf19b58.html @@ -1,47 +1,143 @@ - - - - - See a helper implemented in a plugin - - - -

See a helper implemented in a plugin

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * World Helper
  6. -
  7.  *
  8. -
  9.  * @author Mark Nielsen
  10. -
  11.  * @package blocks/helloworld
  12. -
  13.  ***/
  14. -
  15.  
  16. -
  17. defined('MOODLE_INTERNAL'or die('Direct access to this script is forbidden.');
  18. -
  19.  
  20. -
  21. class blocks_helloworld_helper_world extends mr_helper_abstract {
  22. -
  23.     /**
  24. -
  25.      * Direct call to world helper
  26. -
  27.      *
  28. -
  29.      * @return string 
  30. -
  31.      */
  32. -
  33.     public function direct({
  34. -
  35.         return 'Hello direct()!';
  36. -
  37.     }
  38. -
  39.  
  40. -
  41.     /**
  42. -
  43.      * Say Hello
  44. -
  45.      *
  46. -
  47.      * @return string 
  48. -
  49.      */
  50. -
  51.     public function say_hello({
  52. -
  53.         return 'Hello World!';
  54. -
  55.     }
  56. -
  57. }
  58. -
-
+ + + + + + See a helper implemented in a plugin + + + + +

See a helper implemented in a plugin

+
+
+
    +
  1. +
    <?php
    +
  2. +
  3. +
    /**
    +
  4. +
  5. +
     * World Helper
    +
  6. +
  7. +
     *
    +
  8. +
  9. +
     * @author Mark Nielsen +
    +
  10. +
  11. +
     * @package blocks/helloworld +
    +
  12. +
  13. +
     ***/
    +
  14. +
  15. +
     
    +
  16. +
  17. +
    defined('MOODLE_INTERNAL'or die('Direct access to this script is forbidden.');
    +
  18. +
  19. +
     
    +
  20. +
  21. +
    class blocks_helloworld_helper_world extends mr_helper_abstract {
    +
  22. +
  23. +
        /**
    +
  24. +
  25. +
         * Direct call to world helper +
    +
  26. +
  27. +
         *
    +
  28. +
  29. +
         * @return string  +
    +
  30. +
  31. +
         */
    +
  32. +
  33. +
        public function direct({ +
    +
  34. +
  35. +
            return 'Hello direct()!';
    +
  36. +
  37. +
        }
    +
  38. +
  39. +
     
    +
  40. +
  41. +
        /**
    +
  42. +
  43. +
         * Say Hello
    +
  44. +
  45. +
         *
    +
  46. +
  47. +
         * @return string  +
    +
  48. +
  49. +
         */
    +
  50. +
  51. +
        public function say_hello({ +
    +
  52. +
  53. +
            return 'Hello World!';
    +
  54. +
  55. +
        }
    +
  56. +
  57. +
    }
    +
  58. +
+
+

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

- + + \ No newline at end of file diff --git a/docs/__examplesource/exsource_es_joule2-maint_blocks_helloworld_report_users.php_b7f1b3ef628801cb4d798615e6f51528.html b/docs/__examplesource/exsource_es_joule2-maint_blocks_helloworld_report_users.php_b7f1b3ef628801cb4d798615e6f51528.html index 5d5713c2..e7b0de85 100644 --- a/docs/__examplesource/exsource_es_joule2-maint_blocks_helloworld_report_users.php_b7f1b3ef628801cb4d798615e6f51528.html +++ b/docs/__examplesource/exsource_es_joule2-maint_blocks_helloworld_report_users.php_b7f1b3ef628801cb4d798615e6f51528.html @@ -1,91 +1,419 @@ - - - - - See how to extend this class - - - -

See how to extend this class

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * A report for viewing user accounts
  6. -
  7.  *
  8. -
  9.  * @package blocks/helloworld
  10. -
  11.  * @author Mark Nielsen
  12. -
  13.  */
  14. -
  15. class blocks_helloworld_report_users extends mr_report_abstract {
  16. -
  17.     /**
  18. -
  19.      * Report's init routine
  20. -
  21.      *
  22. -
  23.      * @return void 
  24. -
  25.      */
  26. -
  27.     public function init({
  28. -
  29.         $this->config->set(array(
  30. -
  31.             'export' => '**',
  32. -
  33.             'perpage' => true,
  34. -
  35.             'ajax'    => true,
  36. -
  37.             'perpageopts' => array('all'151050),
  38. -
  39.         ));
  40. -
  41.     }
  42. -
  43.  
  44. -
  45.     /**
  46. -
  47.      * The component string, used for get_string() calls
  48. -
  49.      *
  50. -
  51.      * @return string 
  52. -
  53.      */
  54. -
  55.     public function get_component({
  56. -
  57.         return 'block_helloworld';
  58. -
  59.     }
  60. -
  61.  
  62. -
  63.     /**
  64. -
  65.      * Filter setup
  66. -
  67.      *
  68. -
  69.      * @return void 
  70. -
  71.      */
  72. -
  73.     public function filter_init({
  74. -
  75.         $url clone($this->url);
  76. -
  77.         $url->param('action''autocomplete');
  78. -
  79.  
  80. -
  81.         $this->filter new mr_html_filter($this->preferences$this->url);
  82. -
  83.         $this->filter->new_autocomplete('username'get_string('username')$url);
  84. -
  85.         $this->filter->new_autocompleteid('userid'get_string('usernamebyid''block_helloworld')$urlfalse'id');
  86. -
  87.     }
  88. -
  89.  
  90. -
  91.     /**
  92. -
  93.      * Table setup
  94. -
  95.      *
  96. -
  97.      * @return void 
  98. -
  99.      */
  100. -
  101.     public function table_init({
  102. -
  103.         $this->table new mr_html_table($this->preferences$this->url'username');
  104. -
  105.         $this->table->add_column('id'''array('display' => false))
  106. -
  107.                     ->add_column('username'get_string('username'))
  108. -
  109.                     ->add_column('firstname'get_string('firstname'))
  110. -
  111.                     ->add_column('lastname'get_string('lastname'))
  112. -
  113.                     ->add_column('email'get_string('email'))
  114. -
  115.                     ->add_column('lastaccess'get_string('lastaccess'))
  116. -
  117.                     ->add_format('lastaccess''date')
  118. -
  119.                     ->add_format(array('username''firstname''lastname''email')'string');
  120. -
  121.     }
  122. -
  123.  
  124. -
  125.     /**
  126. -
  127.      * Report SQL
  128. -
  129.      */
  130. -
  131.     public function get_sql($fields$filtersql$filterparams{
  132. -
  133.         $sql "SELECT $fields
  134. -
  135.                   FROM {user}
  136. -
  137.                  WHERE $filtersql";
  138. -
  139.  
  140. -
  141.         return array($sql$filterparams);
  142. -
  143.     }
  144. -
  145. }
  146. -
-
+ + + + + + See how to extend this class + + + + +

See how to extend this class

+
+
+
    +
  1. +
    <?php
    +
  2. +
  3. +
    /**
    +
  4. +
  5. +
     * A report for viewing user accounts +
    +
  6. +
  7. +
     *
    +
  8. +
  9. +
     * @package blocks/helloworld +
    +
  10. +
  11. +
     * @author Mark Nielsen +
    +
  12. +
  13. +
     */
    +
  14. +
  15. +
    class blocks_helloworld_report_users extends mr_report_abstract {
    +
  16. +
  17. +
        /**
    +
  18. +
  19. +
         * Report's init routine +
    +
  20. +
  21. +
         *
    +
  22. +
  23. +
         * @return void  +
    +
  24. +
  25. +
         */
    +
  26. +
  27. +
        public function init({ +
    +
  28. +
  29. +
            $this->config->set(array(
    +
  30. +
  31. +
                'export' => '**',
    +
  32. +
  33. +
                'perpage' => true,
    +
  34. +
  35. +
                'ajax'    => true,
    +
  36. +
  37. +
                'perpageopts' => array('all'151050),
    +
  38. +
  39. +
            ));
    +
  40. +
  41. +
        }
    +
  42. +
  43. +
     
    +
  44. +
  45. +
        /**
    +
  46. +
  47. +
         * The component string, +  used for get_string() calls +
    +
  48. +
  49. +
         *
    +
  50. +
  51. +
         * @return string  +
    +
  52. +
  53. +
         */
    +
  54. +
  55. +
        public function get_component({ +
    +
  56. +
  57. +
            return 'block_helloworld';
    +
  58. +
  59. +
        }
    +
  60. +
  61. +
     
    +
  62. +
  63. +
        /**
    +
  64. +
  65. +
         * Filter setup
    +
  66. +
  67. +
         *
    +
  68. +
  69. +
         * @return void  +
    +
  70. +
  71. +
         */
    +
  72. +
  73. +
        public function filter_init({ +
    +
  74. +
  75. +
            $url clone($this->url);
    +
  76. +
  77. +
            $url->param('action''autocomplete');
    +
  78. +
  79. +
     
    +
  80. +
  81. +
            $this->filter new mr_html_filter($this->preferences$this->url);
    +
  82. +
  83. +
            $this->filter->new_autocomplete('username'get_string('username')$url);
    +
  84. +
  85. +
            $this->filter->new_autocompleteid('userid'get_string('usernamebyid''block_helloworld')$urlfalse'id');
    +
  86. +
  87. +
        }
    +
  88. +
  89. +
     
    +
  90. +
  91. +
        /**
    +
  92. +
  93. +
         * Table setup
    +
  94. +
  95. +
         *
    +
  96. +
  97. +
         * @return void  +
    +
  98. +
  99. +
         */
    +
  100. +
  101. +
        public function table_init({ +
    +
  102. +
  103. +
            $this->table new mr_html_table($this->preferences$this->url'username');
    +
  104. +
  105. +
            $this->table->add_column('id'''array('display' => false))
    +
  106. +
  107. +
    +                     ->add_column('username'get_string('username'))
    +
  108. +
  109. +
    +                     ->add_column('firstname'get_string('firstname'))
    +
  110. +
  111. +
    +                     ->add_column('lastname'get_string('lastname'))
    +
  112. +
  113. +
    +                     ->add_column('email'get_string('email')) +
    +
  114. +
  115. +
    +                     ->add_column('lastaccess'get_string('lastaccess'))
    +
  116. +
  117. +
    +                     ->add_format('lastaccess''date')
    +
  118. +
  119. +
    +                     ->add_format(array('username''firstname''lastname''email')'string'); +
    +
  120. +
  121. +
        }
    +
  122. +
  123. +
     
    +
  124. +
  125. +
        /**
    +
  126. +
  127. +
         * Report SQL
    +
  128. +
  129. +
         */
    +
  130. +
  131. +
        public function get_sql($fields$filtersql$filterparams{
    +
  132. +
  133. +
            $sql "SELECT $fields
    +
  134. +
  135. +
                   +     FROM {user} +
    +
  136. +
  137. +
                   +    WHERE $filtersql";
    +
  138. +
  139. +
     
    +
  140. +
  141. +
            return array($sql$filterparams);
    +
  142. +
  143. +
        }
    +
  144. +
  145. +
    }
    +
  146. +
+
+

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

- + + \ No newline at end of file diff --git a/docs/__examplesource/exsource_le2-maint_blocks_helloworld_controller_default.php_d07b4f4487b0e7d8be5b9565de1680c1.html b/docs/__examplesource/exsource_le2-maint_blocks_helloworld_controller_default.php_d07b4f4487b0e7d8be5b9565de1680c1.html index d0048362..d6cac7cd 100644 --- a/docs/__examplesource/exsource_le2-maint_blocks_helloworld_controller_default.php_d07b4f4487b0e7d8be5b9565de1680c1.html +++ b/docs/__examplesource/exsource_le2-maint_blocks_helloworld_controller_default.php_d07b4f4487b0e7d8be5b9565de1680c1.html @@ -1,227 +1,1212 @@ - - - - - See more examples - - - -

See more examples

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Default controller
  6. -
  7.  *
  8. -
  9.  * @author Mark Nielsen
  10. -
  11.  * @version $Id$
  12. -
  13.  * @package blocks/helloworld
  14. -
  15.  */
  16. -
  17.  
  18. -
  19. defined('MOODLE_INTERNAL'or die('Direct access to this script is forbidden.');
  20. -
  21.  
  22. -
  23. class block_helloworld_controller_default extends mr_controller_block {
  24. -
  25.  
  26. -
  27.     /**
  28. -
  29.      * Do common setup routines or use to change defaults
  30. -
  31.      */
  32. -
  33.     public function init({
  34. -
  35.         // Example, change default for tab
  36. -
  37.         // $this->tabs->set($this->action);
  38. -
  39.     }
  40. -
  41.  
  42. -
  43.     /**
  44. -
  45.      * Require capability for viewing this controller
  46. -
  47.      */
  48. -
  49.     public function require_capability({
  50. -
  51.         /* Example implementation
  52. -
  53.         switch ($this->action) {
  54. -
  55.             case 'view':
  56. -
  57.                 require_capability(...);
  58. -
  59.                 break;
  60. -
  61.             case 'foo':
  62. -
  63.                 require_capability(...);
  64. -
  65.                 break;
  66. -
  67.             default:
  68. -
  69.                 require_capability(...);
  70. -
  71.         }
  72. -
  73.         */
  74. -
  75.  
  76. -
  77.         // Require admin for our admin action
  78. -
  79.         switch ($this->action{
  80. -
  81.             case 'admin':
  82. -
  83.                 require_capability('moodle/site:config'$this->get_context());
  84. -
  85.                 break;
  86. -
  87.         }
  88. -
  89.     }
  90. -
  91.  
  92. -
  93.     /**
  94. -
  95.      * Define tabs for all controllers
  96. -
  97.      *
  98. -
  99.      * Demo mr_tabs
  100. -
  101.      */
  102. -
  103.     public static function add_tabs($controller&$tabs{
  104. -
  105.         // This is the NEW and prefered way to setup tabs.
  106. -
  107.         // Only implement add_tabs in the default controller
  108. -
  109.         // and then use the new mr_tabs methods toptab() and
  110. -
  111.         // subtab() to create the tab structure.
  112. -
  113.         $tabs->toptab('default')
  114. -
  115.              ->subtab('view')
  116. -
  117.              ->subtab('admin'array('action' => 'admin')has_capability('moodle/site:config'$controller->get_context())) // Visible to admins
  118. -
  119.              ->toptab('html'array('action' => 'html'))
  120. -
  121.              ->toptab('db'array('controller' => 'db'))
  122. -
  123.              ->subtab('view'array('controller' => 'db'))
  124. -
  125.              ->subtab('record'array('controller' => 'db''action' => 'record'))
  126. -
  127.              ->subtab('queue'array('controller' => 'db''action' => 'queue'))
  128. -
  129.              ->toptab('plugin'array('controller' => 'plugin'))
  130. -
  131.              ->toptab('cache'array('controller' => 'cache'))
  132. -
  133.              ->toptab('filter'array('controller' => 'filter'))
  134. -
  135.              ->toptab('table'array('controller' => 'table'))
  136. -
  137.              ->toptab('report'array('controller' => 'report'))
  138. -
  139.              ->toptab('server'array('controller' => 'server'))
  140. -
  141.              ->toptab('model'array('controller' => 'model'));
  142. -
  143.     }
  144. -
  145.  
  146. -
  147.     /**
  148. -
  149.      * Default screen
  150. -
  151.      *
  152. -
  153.      * Demo of the buffer helper
  154. -
  155.      * Demo of mr_html_tag and tag helper
  156. -
  157.      */
  158. -
  159.     public function view_action({
  160. -
  161.         // Note, you can get an instance of mr_html_tag like so:
  162. -
  163.         $tag $this->helper->tag();
  164. -
  165.  
  166. -
  167.         // Advanced usage of mr_html_tag, calls are explained below
  168. -
  169.         return $this->helper->tag->div()->class('centerpara')->close(  // Passing tag contents through close() instead of the opening call: div().  This increases readability.  I can also pass as many params as I want.
  170. -
  171.             $this->helper->tag->p(  // Below, I can pass as many params as I want, all will be added to the contents of this <p> tag
  172. -
  173.                 $this->helper->world->say_hello(),
  174. -
  175.                 $this->helper->tag->p('Global config:'),  // Don't need to call close(), EG: "$this->helper->tag->p('Global config:')->close()" because the tag will be casted to a string and mr_html_tag implements __toString()
  176. -
  177.                 $this->helper->buffer('print_object'$this->config)
  178. -
  179.             )// Same here, don't need to call close()
  180. -
  181.             $this->output->single_button($this->url->out(falsearray('action' => 'saygood'))'Say good'),
  182. -
  183.             $this->output->single_button($this->url->out(falsearray('action' => 'saybad'))'Say bad')
  184. -
  185.         );
  186. -
  187.     }
  188. -
  189.  
  190. -
  191.     /**
  192. -
  193.      * Example of setting a positive message and then going back to originating screen
  194. -
  195.      *
  196. -
  197.      * Demo of mr_notify
  198. -
  199.      */
  200. -
  201.     public function saygood_action({
  202. -
  203.         $this->notify->good('good');
  204. -
  205.         redirect($this->url);
  206. -
  207.     }
  208. -
  209.  
  210. -
  211.     /**
  212. -
  213.      * Example of setting a negative message and then going back to originating screen
  214. -
  215.      *
  216. -
  217.      * Demo of mr_notify
  218. -
  219.      */
  220. -
  221.     public function saybad_action({
  222. -
  223.         $this->notify->bad('bad');
  224. -
  225.         redirect($this->url);
  226. -
  227.     }
  228. -
  229.  
  230. -
  231.     /**
  232. -
  233.      * Admin only, restricted access by $this->require_capability()
  234. -
  235.      */
  236. -
  237.     public function admin_action({
  238. -
  239.         return 'admin only';
  240. -
  241.     }
  242. -
  243.  
  244. -
  245.     /**
  246. -
  247.      * HTML demo
  248. -
  249.      *
  250. -
  251.      * Demo of mr_html_tag
  252. -
  253.      * Demo of tag helper
  254. -
  255.      */
  256. -
  257.     public function html_action({
  258. -
  259.         $this->tabs->set('html');
  260. -
  261.         $this->print_header();
  262. -
  263.  
  264. -
  265.         echo $this->output->heading('Demo of mr_html_tag');
  266. -
  267.         $this->helper->highlight(__CLASS____FUNCTION__);
  268. -
  269.         echo $this->output->box_start('generalbox boxaligncenter boxwidthnormal');
  270. -
  271.  
  272. -
  273.         #### DEMO CODE ####
  274. -
  275.         // New instance
  276. -
  277.         $tag new mr_html_tag();
  278. -
  279.         // Create html with the mr_html_tag instance
  280. -
  281.         $html $tag->a('Click me!')
  282. -
  283.                     ->title('This " should be encoded')
  284. -
  285.                     ->href('http://google.com')
  286. -
  287.                     ->close();
  288. -
  289.         $this->helper->dump($html1);
  290. -
  291.  
  292. -
  293.         // Create html with the mr_html_tag::open()
  294. -
  295.         $html mr_html_tag::open()->a('Click me!')
  296. -
  297.                                    ->title('This " should be encoded')
  298. -
  299.                                    ->href('http://google.com')
  300. -
  301.                                    ->close();
  302. -
  303.         $this->helper->dump($html2);
  304. -
  305.  
  306. -
  307.         // Create html with the helper
  308. -
  309.         $html $this->helper->tag->a('Click me!')
  310. -
  311.                              ->title('This " should be encoded')
  312. -
  313.                              ->href('http://google.com')
  314. -
  315.                              ->close();
  316. -
  317.         $this->helper->dump($html3);
  318. -
  319.  
  320. -
  321.         // Example of using the other special methods
  322. -
  323.         $link $tag->a('Click me!')
  324. -
  325.                     ->title('This " should be encoded')
  326. -
  327.                     ->href('http://google.com')
  328. -
  329.                     ->class('foo');
  330. -
  331.  
  332. -
  333.         // Modify attributes (Note, you can do these in bluk
  334. -
  335.         // with add_attributes(), append_attributes(), prepend_attributes()
  336. -
  337.         // and remove_attributes())
  338. -
  339.         $link->prepend_class('bar')
  340. -
  341.              ->append_class('baz')
  342. -
  343.              ->remove_title();
  344. -
  345.         $this->helper->dump($link->get_class()4);
  346. -
  347.  
  348. -
  349.         // When $link is casted to a string, it will automatically render to HTML
  350. -
  351.         $this->helper->dump((string) $link5);
  352. -
  353.  
  354. -
  355.         // You can bulk add/modify attributes as well
  356. -
  357.  
  358. -
  359.         // Example of making a tag with no content
  360. -
  361.         $html $tag->input()
  362. -
  363.                     ->type('submit')
  364. -
  365.                     ->value(get_string('savechanges'))
  366. -
  367.                     ->close();
  368. -
  369.         $this->helper->dump($html6);
  370. -
  371.  
  372. -
  373.         // You can pass tag content to either the first call or to close()
  374. -
  375.         $html $tag->div('This is ')
  376. -
  377.                     ->class('generalbox')
  378. -
  379.                     ->close('cool!');
  380. -
  381.         $this->helper->dump($html7);
  382. -
  383.  
  384. -
  385.         // Advanced usage
  386. -
  387.         // Taking advantage of mr_html_tag::__toString to avoid calling close()
  388. -
  389.         // Taking advantage of passing multiple tag content strings
  390. -
  391.         $html $tag->div()->class('generalbox')->close(
  392. -
  393.             $tag->p(
  394. -
  395.                 'Hello all!',
  396. -
  397.                 $tag->strong('This is cool and stuffs')
  398. -
  399.             ),
  400. -
  401.             $tag->span('Dingo')->class('centerpara')
  402. -
  403.         );
  404. -
  405.         $this->helper->dump($html8);
  406. -
  407.         #### DEMO CODE ####
  408. -
  409.  
  410. -
  411.         $this->output->box_end();
  412. -
  413.         $this->print_footer();
  414. -
  415.     }
  416. -
  417. }
  418. -
-
+ + + + + + See more examples + + + + +

See more examples

+
+
+
    +
  1. +
    <?php
    +
  2. +
  3. +
    /**
    +
  4. +
  5. +
     * Default controller
    +
  6. +
  7. +
     *
    +
  8. +
  9. +
     * @author Mark Nielsen +
    +
  10. +
  11. +
     * @version $Id$
    +
  12. +
  13. +
     * @package blocks/helloworld +
    +
  14. +
  15. +
     */
    +
  16. +
  17. +
     
    +
  18. +
  19. +
    defined('MOODLE_INTERNAL'or die('Direct access to this script is forbidden.');
    +
  20. +
  21. +
     
    +
  22. +
  23. +
    class block_helloworld_controller_default extends mr_controller_block {
    +
  24. +
  25. +
     
    +
  26. +
  27. +
        /**
    +
  28. +
  29. +
         * Do common setup routines  + or use to change defaults +
    +
  30. +
  31. +
         */
    +
  32. +
  33. +
        public function init({ +
    +
  34. +
  35. +
            // Example, change default for tab
    +
  36. +
  37. +
            // $this->tabs->set($this->action);
    +
  38. +
  39. +
        }
    +
  40. +
  41. +
     
    +
  42. +
  43. +
        /**
    +
  44. +
  45. +
         * Require capability for  + viewing this controller +
    +
  46. +
  47. +
         */
    +
  48. +
  49. +
        public function require_capability({ +
    +
  50. +
  51. +
            /* Example implementation
    +
  52. +
  53. +
            switch ($this->action) { +
    +
  54. +
  55. +
                case 'view': +
    +
  56. +
  57. +
                     + require_capability(...); +
    +
  58. +
  59. +
                     + break; +
    +
  60. +
  61. +
                case 'foo': +
    +
  62. +
  63. +
                     + require_capability(...); +
    +
  64. +
  65. +
                     + break; +
    +
  66. +
  67. +
                default: +
    +
  68. +
  69. +
                     + require_capability(...); +
    +
  70. +
  71. +
            }
    +
  72. +
  73. +
            */
    +
  74. +
  75. +
     
    +
  76. +
  77. +
            // Require admin for our admin action +
    +
  78. +
  79. +
            switch ($this->action{
    +
  80. +
  81. +
                case 'admin':
    +
  82. +
  83. +
    +                 require_capability('moodle/site:config'$this->get_context());
    +
  84. +
  85. +
    +                 break;
    +
  86. +
  87. +
            } +
    +
  88. +
  89. +
        }
    +
  90. +
  91. +
     
    +
  92. +
  93. +
        /**
    +
  94. +
  95. +
         * Define tabs for all controllers +
    +
  96. +
  97. +
         *
    +
  98. +
  99. +
         * Demo mr_tabs
    +
  100. +
  101. +
         */
    +
  102. +
  103. +
        public static function add_tabs($controller&$tabs{
    +
  104. +
  105. +
            // This is the NEW and prefered way to setup tabs. +
    +
  106. +
  107. +
            // Only implement add_tabs in the default controller +
    +
  108. +
  109. +
            // and then use the new mr_tabs methods toptab() and +
    +
  110. +
  111. +
            // subtab() to create the tab structure. +
    +
  112. +
  113. +
            $tabs->toptab('default')
    +
  114. +
  115. +
    +              ->subtab('view') +
    +
  116. +
  117. +
    +              ->subtab('admin'array('action' => 'admin')has_capability('moodle/site:config'$controller->get_context())) // Visible to admins
    +
  118. +
  119. +
    +              ->toptab('html'array('action' => 'html'))
    +
  120. +
  121. +
    +              ->toptab('db'array('controller' => 'db'))
    +
  122. +
  123. +
    +              ->subtab('view'array('controller' => 'db'))
    +
  124. +
  125. +
    +              ->subtab('record'array('controller' => 'db''action' => 'record'))
    +
  126. +
  127. +
    +              ->subtab('queue'array('controller' => 'db''action' => 'queue'))
    +
  128. +
  129. +
    +              ->toptab('plugin'array('controller' => 'plugin'))
    +
  130. +
  131. +
    +              ->toptab('cache'array('controller' => 'cache'))
    +
  132. +
  133. +
    +              ->toptab('filter'array('controller' => 'filter'))
    +
  134. +
  135. +
    +              ->toptab('table'array('controller' => 'table'))
    +
  136. +
  137. +
    +              ->toptab('report'array('controller' => 'report'))
    +
  138. +
  139. +
    +              ->toptab('server'array('controller' => 'server'))
    +
  140. +
  141. +
    +              ->toptab('model'array('controller' => 'model')); +
    +
  142. +
  143. +
        }
    +
  144. +
  145. +
     
    +
  146. +
  147. +
        /**
    +
  148. +
  149. +
         * Default screen
    +
  150. +
  151. +
         *
    +
  152. +
  153. +
         * Demo of the buffer helper +
    +
  154. +
  155. +
         * Demo of mr_html_tag and tag helper +
    +
  156. +
  157. +
         */
    +
  158. +
  159. +
        public function view_action({ +
    +
  160. +
  161. +
            // Note, you can get an instance  + of mr_html_tag like so: +
    +
  162. +
  163. +
            $tag $this->helper->tag();
    +
  164. +
  165. +
     
    +
  166. +
  167. +
            // Advanced usage of mr_html_tag, calls are explained below +
    +
  168. +
  169. +
            return $this->helper->tag->div()->class('centerpara')->close(  // Passing tag contents through close() instead of the  + opening call: div().  This increases readability.  I can also  + pass as  + many params as I want. +
    +
  170. +
  171. +
                $this->helper->tag->p(  // Below, I can pass as many params as I want,  + all will  + be added to the contents of this <p> tag +
    +
  172. +
  173. +
    +                 $this->helper->world->say_hello(),
    +
  174. +
  175. +
    +                 $this->helper->tag->p('Global config:'),  // Don't need to call close(), EG: "$this->helper->tag-> + p('Global config:')->close()" because the tag will be casted to  + a string and mr_html_tag implements __toString() +
    +
  176. +
  177. +
    +                 $this->helper->buffer('print_object'$this->config)
    +
  178. +
  179. +
                )// Same here, don't need to call close() +
    +
  180. +
  181. +
                $this->output->single_button($this->url->out(falsearray('action' => 'saygood'))'Say good'),
    +
  182. +
  183. +
                $this->output->single_button($this->url->out(falsearray('action' => 'saybad'))'Say bad')
    +
  184. +
  185. +
            );
    +
  186. +
  187. +
        }
    +
  188. +
  189. +
     
    +
  190. +
  191. +
        /**
    +
  192. +
  193. +
         * Example of setting a positive  + message and then going back to originating screen +
    +
  194. +
  195. +
         *
    +
  196. +
  197. +
         * Demo of mr_notify +
    +
  198. +
  199. +
         */
    +
  200. +
  201. +
        public function saygood_action({ +
    +
  202. +
  203. +
            $this->notify->good('good'); +
    +
  204. +
  205. +
            redirect($this->url);
    +
  206. +
  207. +
        }
    +
  208. +
  209. +
     
    +
  210. +
  211. +
        /**
    +
  212. +
  213. +
         * Example of setting a negative message  + and then going back to originating screen +
    +
  214. +
  215. +
         *
    +
  216. +
  217. +
         * Demo of mr_notify +
    +
  218. +
  219. +
         */
    +
  220. +
  221. +
        public function saybad_action({ +
    +
  222. +
  223. +
            $this->notify->bad('bad'); +
    +
  224. +
  225. +
            redirect($this->url);
    +
  226. +
  227. +
        }
    +
  228. +
  229. +
     
    +
  230. +
  231. +
        /**
    +
  232. +
  233. +
         * Admin only, restricted access by  + $this->require_capability() +
    +
  234. +
  235. +
         */
    +
  236. +
  237. +
        public function admin_action({ +
    +
  238. +
  239. +
            return 'admin only';
    +
  240. +
  241. +
        }
    +
  242. +
  243. +
     
    +
  244. +
  245. +
        /**
    +
  246. +
  247. +
         * HTML demo
    +
  248. +
  249. +
         *
    +
  250. +
  251. +
         * Demo of mr_html_tag +
    +
  252. +
  253. +
         * Demo of tag helper +
    +
  254. +
  255. +
         */
    +
  256. +
  257. +
        public function html_action({ +
    +
  258. +
  259. +
            $this->tabs->set('html'); +
    +
  260. +
  261. +
            $this->print_header();
    +
  262. +
  263. +
     
    +
  264. +
  265. +
            echo $this->output->heading('Demo of mr_html_tag');
    +
  266. +
  267. +
            $this->helper->highlight(__CLASS____FUNCTION__);
    +
  268. +
  269. +
            echo $this->output->box_start('generalbox boxaligncenter boxwidthnormal');
    +
  270. +
  271. +
     
    +
  272. +
  273. +
            #### DEMO CODE ####
    +
  274. +
  275. +
            // New instance
    +
  276. +
  277. +
            $tag new mr_html_tag();
    +
  278. +
  279. +
            // Create html with the mr_html_tag instance +
    +
  280. +
  281. +
            $html $tag->a('Click me!')
    +
  282. +
  283. +
    +                     ->title('This " should be encoded')
    +
  284. +
  285. +
    +                     ->href('http://google.com')
    +
  286. +
  287. +
    +                     ->close();
    +
  288. +
  289. +
            $this->helper->dump($html1);
    +
  290. +
  291. +
     
    +
  292. +
  293. +
            // Create html with the mr_html_tag::open() +
    +
  294. +
  295. +
            $html mr_html_tag::open()->a('Click me!')
    +
  296. +
  297. +
    +                      +                ->title('This " should be encoded')
    +
  298. +
  299. +
    +                      +                ->href('http://google.com')
    +
  300. +
  301. +
    +                      +                ->close();
    +
  302. +
  303. +
            $this->helper->dump($html2);
    +
  304. +
  305. +
     
    +
  306. +
  307. +
            // Create html with the helper
    +
  308. +
  309. +
            $html $this->helper->tag->a('Click me!')
    +
  310. +
  311. +
    +                      +          ->title('This " should be encoded')
    +
  312. +
  313. +
    +                      +          ->href('http://google.com')
    +
  314. +
  315. +
    +                      +          ->close();
    +
  316. +
  317. +
            $this->helper->dump($html3);
    +
  318. +
  319. +
     
    +
  320. +
  321. +
            // Example of using the other special methods +
    +
  322. +
  323. +
            $link $tag->a('Click me!')
    +
  324. +
  325. +
    +                     ->title('This " should be encoded')
    +
  326. +
  327. +
    +                     ->href('http://google.com')
    +
  328. +
  329. +
    +                     ->class('foo');
    +
  330. +
  331. +
     
    +
  332. +
  333. +
            // Modify attributes (Note, you can do these in bluk +
    +
  334. +
  335. +
            // with add_attributes(), append_attributes(), prepend_attributes() +
    +
  336. +
  337. +
            // and remove_attributes())
    +
  338. +
  339. +
            $link->prepend_class('bar')
    +
  340. +
  341. +
    +              ->append_class('baz') +
    +
  342. +
  343. +
    +              ->remove_title();
    +
  344. +
  345. +
            $this->helper->dump($link->get_class()4);
    +
  346. +
  347. +
     
    +
  348. +
  349. +
            // When $link is casted to a string, it will  + automatically render to HTML +
    +
  350. +
  351. +
            $this->helper->dump((string) $link5);
    +
  352. +
  353. +
     
    +
  354. +
  355. +
            // You can bulk add/modify attributes as well +
    +
  356. +
  357. +
     
    +
  358. +
  359. +
            // Example of making a tag with no content +
    +
  360. +
  361. +
            $html $tag->input()
    +
  362. +
  363. +
    +                     ->type('submit') +
    +
  364. +
  365. +
    +                     ->value(get_string('savechanges'))
    +
  366. +
  367. +
    +                     ->close();
    +
  368. +
  369. +
            $this->helper->dump($html6);
    +
  370. +
  371. +
     
    +
  372. +
  373. +
            // You can pass tag content to either the first  + call or to close() +
    +
  374. +
  375. +
            $html $tag->div('This is ')
    +
  376. +
  377. +
    +                     ->class('generalbox')
    +
  378. +
  379. +
    +                     ->close('cool!');
    +
  380. +
  381. +
            $this->helper->dump($html7);
    +
  382. +
  383. +
     
    +
  384. +
  385. +
            // Advanced usage
    +
  386. +
  387. +
            // Taking advantage of mr_html_tag::__toString to  + avoid calling close() +
    +
  388. +
  389. +
            // Taking advantage of passing multiple tag content strings +
    +
  390. +
  391. +
            $html $tag->div()->class('generalbox')->close(
    +
  392. +
  393. +
                $tag->p(
    +
  394. +
  395. +
    +                 'Hello all!',
    +
  396. +
  397. +
    +                 $tag->strong('This is cool and stuffs')
    +
  398. +
  399. +
                ),
    +
  400. +
  401. +
                $tag->span('Dingo')->class('centerpara')
    +
  402. +
  403. +
            );
    +
  404. +
  405. +
            $this->helper->dump($html8);
    +
  406. +
  407. +
            #### DEMO CODE ####
    +
  408. +
  409. +
     
    +
  410. +
  411. +
            $this->output->box_end();
    +
  412. +
  413. +
            $this->print_footer();
    +
  414. +
  415. +
        }
    +
  416. +
  417. +
    }
    +
  418. +
+
+

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

- + + \ No newline at end of file diff --git a/docs/__examplesource/exsource_le2-maint_blocks_helloworld_lib_server_service.php_df94f9c9f06a3bd8592f0a887db91e47.html b/docs/__examplesource/exsource_le2-maint_blocks_helloworld_lib_server_service.php_df94f9c9f06a3bd8592f0a887db91e47.html index 606fc915..dbdeb5aa 100644 --- a/docs/__examplesource/exsource_le2-maint_blocks_helloworld_lib_server_service.php_df94f9c9f06a3bd8592f0a887db91e47.html +++ b/docs/__examplesource/exsource_le2-maint_blocks_helloworld_lib_server_service.php_df94f9c9f06a3bd8592f0a887db91e47.html @@ -1,47 +1,155 @@ - - - - - Example class definition - - - -

Example class definition

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Available Web Services
  6. -
  7.  *
  8. -
  9.  * @package blocks/helloworld
  10. -
  11.  * @author Mark Nielsen
  12. -
  13.  */
  14. -
  15. class blocks_helloworld_lib_server_service extends mr_server_service_abstract {
  16. -
  17.     /**
  18. -
  19.      * Constructor hook: this is a great place to call mr_on
  20. -
  21.      *
  22. -
  23.      * @return void 
  24. -
  25.      */
  26. -
  27.     protected function init({
  28. -
  29.         if (!mr_on('helloworld''block')) {
  30. -
  31.             throw new Exception('Block is not enabled: blocks/helloworld');
  32. -
  33.         }
  34. -
  35.     }
  36. -
  37.  
  38. -
  39.     /**
  40. -
  41.      * Test Service
  42. -
  43.      *
  44. -
  45.      * @param string $say Tell the service what to say
  46. -
  47.      * @return string 
  48. -
  49.      */
  50. -
  51.     public function test($say{
  52. -
  53.         return $this->response->test($say);
  54. -
  55.     }
  56. -
  57. }
  58. -
-
+ + + + + + Example class definition + + + + +

Example class definition

+
+
+
    +
  1. +
    <?php
    +
  2. +
  3. +
    /**
    +
  4. +
  5. +
     * Available Web Services +
    +
  6. +
  7. +
     *
    +
  8. +
  9. +
     * @package blocks/helloworld +
    +
  10. +
  11. +
     * @author Mark Nielsen +
    +
  12. +
  13. +
     */
    +
  14. +
  15. +
    class blocks_helloworld_lib_server_service extends mr_server_service_abstract {
    +
  16. +
  17. +
        /**
    +
  18. +
  19. +
         * Constructor hook: this  + is a great place to call mr_on +
    +
  20. +
  21. +
         *
    +
  22. +
  23. +
         * @return void  +
    +
  24. +
  25. +
         */
    +
  26. +
  27. +
        protected function init({ +
    +
  28. +
  29. +
            if (!mr_on('helloworld''block')) {
    +
  30. +
  31. +
    +             throw new Exception('Block is not enabled: blocks/helloworld');
    +
  32. +
  33. +
            } +
    +
  34. +
  35. +
        }
    +
  36. +
  37. +
     
    +
  38. +
  39. +
        /**
    +
  40. +
  41. +
         * Test Service
    +
  42. +
  43. +
         *
    +
  44. +
  45. +
         * @param string $say Tell the service what to say
    +
  46. +
  47. +
         * @return string  +
    +
  48. +
  49. +
         */
    +
  50. +
  51. +
        public function test($say{
    +
  52. +
  53. +
            return $this->response->test($say);
    +
  54. +
  55. +
        }
    +
  56. +
  57. +
    }
    +
  58. +
+
+

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

- + + \ No newline at end of file diff --git a/docs/__examplesource/exsource_mark_Sites_joule2-maint_blocks_helloworld_view.php_b33cb6a0be974c2a717c7551e2cb3392.html b/docs/__examplesource/exsource_mark_Sites_joule2-maint_blocks_helloworld_view.php_b33cb6a0be974c2a717c7551e2cb3392.html index 3008c4cb..545ea88b 100644 --- a/docs/__examplesource/exsource_mark_Sites_joule2-maint_blocks_helloworld_view.php_b33cb6a0be974c2a717c7551e2cb3392.html +++ b/docs/__examplesource/exsource_mark_Sites_joule2-maint_blocks_helloworld_view.php_b33cb6a0be974c2a717c7551e2cb3392.html @@ -1,39 +1,116 @@ - - - - - See how to use this file - - - -

See how to use this file

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * View renderer
  6. -
  7.  *
  8. -
  9.  * @author Mark Nielsen
  10. -
  11.  * @version $Id$
  12. -
  13.  * @package blocks/helloworld
  14. -
  15.  */
  16. -
  17.  
  18. -
  19. require_once('../../config.php');
  20. -
  21.  
  22. -
  23. // By including mr/bootstrap.php, all mr
  24. -
  25. // classes become available to us.  So now
  26. -
  27. // we can call mr_controller without explicitly
  28. -
  29. // including its class file.
  30. -
  31. // Use mr_bootstrap::shutdown(); to turn off
  32. -
  33. // class autoloading (basically the opposite of
  34. -
  35. // mr_bootstrap::startup();)
  36. -
  37. require($CFG->dirroot.'/local/mr/bootstrap.php');
  38. -
  39.  
  40. -
  41. mr_controller::render('blocks/helloworld''blockname''block_helloworld');
  42. -
-
+ + + + + + See how to use this file + + + + +

See how to use this file

+
+
+
    +
  1. +
    <?php
    +
  2. +
  3. +
    /**
    +
  4. +
  5. +
     * View renderer
    +
  6. +
  7. +
     *
    +
  8. +
  9. +
     * @author Mark Nielsen +
    +
  10. +
  11. +
     * @version $Id$
    +
  12. +
  13. +
     * @package blocks/helloworld +
    +
  14. +
  15. +
     */
    +
  16. +
  17. +
     
    +
  18. +
  19. +
    require_once('../../config.php');
    +
  20. +
  21. +
     
    +
  22. +
  23. +
    // By including mr/bootstrap.php, all mr +
    +
  24. +
  25. +
    // classes become available to us.  So now +
    +
  26. +
  27. +
    // we can call mr_controller without explicitly +
    +
  28. +
  29. +
    // including its class file. +
    +
  30. +
  31. +
    // Use mr_bootstrap::shutdown(); to turn off +
    +
  32. +
  33. +
    // class autoloading (basically the opposite of +
    +
  34. +
  35. +
    // mr_bootstrap::startup();)
    +
  36. +
  37. +
    require($CFG->dirroot.'/local/mr/bootstrap.php');
    +
  38. +
  39. +
     
    +
  40. +
  41. +
    mr_controller::render('blocks/helloworld''blockname''block_helloworld');
    +
  42. +
+
+

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

- + + \ No newline at end of file diff --git a/docs/__examplesource/exsource_oule2-maint_blocks_helloworld_controller_cache.php_130fbc642e5778bc139412ebb569c3be.html b/docs/__examplesource/exsource_oule2-maint_blocks_helloworld_controller_cache.php_130fbc642e5778bc139412ebb569c3be.html index 9915af85..0a91dd3b 100644 --- a/docs/__examplesource/exsource_oule2-maint_blocks_helloworld_controller_cache.php_130fbc642e5778bc139412ebb569c3be.html +++ b/docs/__examplesource/exsource_oule2-maint_blocks_helloworld_controller_cache.php_130fbc642e5778bc139412ebb569c3be.html @@ -1,95 +1,423 @@ - - - - - See the cache in action - - - -

See the cache in action

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Cache controller
  6. -
  7.  *
  8. -
  9.  * @author Mark Nielsen
  10. -
  11.  * @version $Id$
  12. -
  13.  * @package blocks/helloworld
  14. -
  15.  */
  16. -
  17.  
  18. -
  19. defined('MOODLE_INTERNAL'or die('Direct access to this script is forbidden.');
  20. -
  21.  
  22. -
  23. class block_helloworld_controller_cache extends mr_controller_block {
  24. -
  25.     /**
  26. -
  27.      * Default screen
  28. -
  29.      *
  30. -
  31.      * Demo of cache
  32. -
  33.      */
  34. -
  35.     public function view_action({
  36. -
  37.         $this->print_header();
  38. -
  39.         echo $this->output->heading('Demo of mr_cache');
  40. -
  41.         $this->helper->highlight(__CLASS____FUNCTION__);
  42. -
  43.         echo $this->output->box_start('generalbox boxaligncenter boxwidthnormal');
  44. -
  45.  
  46. -
  47.         #### DEMO CODE ####
  48. -
  49.         // Note: you can make your very own instance of mr_cache!
  50. -
  51.         // $this->helper->cache is EXACTLY the same as:
  52. -
  53.         // $cache = new mr_cache('blocks_helloworld_');
  54. -
  55.  
  56. -
  57.         // Try to load cache ID = time_string from cache
  58. -
  59.         if (!$string $this->helper->cache->load('time_string')) {
  60. -
  61.             // Failed to get from cache, create a new string to cache
  62. -
  63.             $string 'Last cache: '.userdate(time()'%A, %d %B %Y, %r');
  64. -
  65.  
  66. -
  67.             // Save the string to cache using cache ID = time_string
  68. -
  69.             $this->helper->cache($string'time_string');
  70. -
  71.  
  72. -
  73.             // Note: the above line is EXACTLY the same as:
  74. -
  75.             // $this->helper->cache->save($string, 'time_string');
  76. -
  77.         }
  78. -
  79.         $this->helper->dump($string'Currently cached value');
  80. -
  81.  
  82. -
  83.         // See if a cached ID exists or not
  84. -
  85.         if (!$this->helper->cache->test('time_string')) {
  86. -
  87.             // In this case, if we get here, its bad, cache isn't working
  88. -
  89.             $this->notify->add_string('cache doesnt exist');
  90. -
  91.         }
  92. -
  93.  
  94. -
  95.         // EXAMPLE:
  96. -
  97.         // Slightly different code when storing data that fails to pass is_string()
  98. -
  99.         // Data like this, gets serialized, need to tell load method to unserialize it like so
  100. -
  101.         // if (!$array = $this->helper->cache->load('array_example', true)) {  // ADDED: true
  102. -
  103.         //     $array = array('foo', 'bar', $string);
  104. -
  105.         //
  106. -
  107.         //     // Save as we normally do, mr_cache will automatically serialize $array
  108. -
  109.         //     $this->helper->cache($array, 'array_example');
  110. -
  111.         // }
  112. -
  113.         // print_object($array);
  114. -
  115.         #### DEMO CODE ####
  116. -
  117.  
  118. -
  119.         echo $this->output->single_button($this->url->out(falsearray('action' => 'delete'))'Delete cache');
  120. -
  121.         echo $this->output->box_end();
  122. -
  123.         $this->print_footer();
  124. -
  125.     }
  126. -
  127.  
  128. -
  129.     /**
  130. -
  131.      * Delete cached item
  132. -
  133.      *
  134. -
  135.      * Demo of cache
  136. -
  137.      */
  138. -
  139.     public function delete_action({
  140. -
  141.         // Remove the cached item
  142. -
  143.         $this->helper->cache->remove('time_string');
  144. -
  145.  
  146. -
  147.         $this->notify->add_string('cache reset'mr_notify::GOOD);
  148. -
  149.         redirect($this->url);
  150. -
  151.     }
  152. -
  153. }
  154. -
-
+ + + + + + See the cache in action + + + + +

See the cache in action

+
+
+
    +
  1. +
    <?php
    +
  2. +
  3. +
    /**
    +
  4. +
  5. +
     * Cache controller
    +
  6. +
  7. +
     *
    +
  8. +
  9. +
     * @author Mark Nielsen +
    +
  10. +
  11. +
     * @version $Id$
    +
  12. +
  13. +
     * @package blocks/helloworld +
    +
  14. +
  15. +
     */
    +
  16. +
  17. +
     
    +
  18. +
  19. +
    defined('MOODLE_INTERNAL'or die('Direct access to this script is forbidden.');
    +
  20. +
  21. +
     
    +
  22. +
  23. +
    class block_helloworld_controller_cache extends mr_controller_block {
    +
  24. +
  25. +
        /**
    +
  26. +
  27. +
         * Default screen
    +
  28. +
  29. +
         *
    +
  30. +
  31. +
         * Demo of cache
    +
  32. +
  33. +
         */
    +
  34. +
  35. +
        public function view_action({ +
    +
  36. +
  37. +
            $this->print_header();
    +
  38. +
  39. +
            echo $this->output->heading('Demo of mr_cache');
    +
  40. +
  41. +
            $this->helper->highlight(__CLASS____FUNCTION__);
    +
  42. +
  43. +
            echo $this->output->box_start('generalbox boxaligncenter boxwidthnormal');
    +
  44. +
  45. +
     
    +
  46. +
  47. +
            #### DEMO CODE ####
    +
  48. +
  49. +
            // Note: you can make your very  + own instance of mr_cache! +
    +
  50. +
  51. +
            // $this->helper->cache is EXACTLY the same as: +
    +
  52. +
  53. +
            // $cache = new mr_cache('blocks_helloworld_'); +
    +
  54. +
  55. +
     
    +
  56. +
  57. +
            // Try to load cache ID = time_string from cache +
    +
  58. +
  59. +
            if (!$string $this->helper->cache->load('time_string')) {
    +
  60. +
  61. +
                // Failed to get from cache, create a new string  + to cache +
    +
  62. +
  63. +
                $string 'Last cache: '.userdate(time()'%A, %d %B %Y, %r');
    +
  64. +
  65. +
     
    +
  66. +
  67. +
                // Save the string to cache using cache  + ID = time_string +
    +
  68. +
  69. +
                $this->helper->cache($string'time_string');
    +
  70. +
  71. +
     
    +
  72. +
  73. +
                // Note: the above line is EXACTLY the same as: +
    +
  74. +
  75. +
                // $this->helper->cache->save($string, 'time_string'); +
    +
  76. +
  77. +
            } +
    +
  78. +
  79. +
            $this->helper->dump($string'Currently cached value');
    +
  80. +
  81. +
     
    +
  82. +
  83. +
            // See if a cached ID exists or not +
    +
  84. +
  85. +
            if (!$this->helper->cache->test('time_string')) {
    +
  86. +
  87. +
                // In this case, if we get here, its  + bad, cache isn't working +
    +
  88. +
  89. +
                $this->notify->add_string('cache doesnt exist');
    +
  90. +
  91. +
            } +
    +
  92. +
  93. +
     
    +
  94. +
  95. +
            // EXAMPLE:
    +
  96. +
  97. +
            // Slightly different code when storing data  + that fails to pass is_string() +
    +
  98. +
  99. +
            // Data like this, gets serialized, need to tell  + load method to unserialize it like so +
    +
  100. +
  101. +
            // if (!$array = $this->helper->cache-> + load('array_example', true))  + {  // ADDED: true +
    +
  102. +
  103. +
            //     $array = array('foo', 'bar', $string); +
    +
  104. +
  105. +
            //
    +
  106. +
  107. +
            //     // Save as we normally do, mr_cache  + will automatically serialize $array +
    +
  108. +
  109. +
            //     $this->helper->cache($array, 'array_example'); +
    +
  110. +
  111. +
            // }
    +
  112. +
  113. +
            // print_object($array);
    +
  114. +
  115. +
            #### DEMO CODE ####
    +
  116. +
  117. +
     
    +
  118. +
  119. +
            echo $this->output->single_button($this->url->out(falsearray('action' => 'delete'))'Delete cache');
    +
  120. +
  121. +
            echo $this->output->box_end();
    +
  122. +
  123. +
            $this->print_footer();
    +
  124. +
  125. +
        }
    +
  126. +
  127. +
     
    +
  128. +
  129. +
        /**
    +
  130. +
  131. +
         * Delete cached item +
    +
  132. +
  133. +
         *
    +
  134. +
  135. +
         * Demo of cache
    +
  136. +
  137. +
         */
    +
  138. +
  139. +
        public function delete_action({ +
    +
  140. +
  141. +
            // Remove the cached item
    +
  142. +
  143. +
            $this->helper->cache->remove('time_string');
    +
  144. +
  145. +
     
    +
  146. +
  147. +
            $this->notify->add_string('cache reset'mr_notify::GOOD);
    +
  148. +
  149. +
            redirect($this->url);
    +
  150. +
  151. +
        }
    +
  152. +
  153. +
    }
    +
  154. +
+
+

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

- + + \ No newline at end of file diff --git a/docs/__examplesource/exsource_oule2-maint_blocks_helloworld_controller_model.php_2d255e8d018617d4ffe86fe10e326331.html b/docs/__examplesource/exsource_oule2-maint_blocks_helloworld_controller_model.php_2d255e8d018617d4ffe86fe10e326331.html index 2fccf57b..1766a8d6 100644 --- a/docs/__examplesource/exsource_oule2-maint_blocks_helloworld_controller_model.php_2d255e8d018617d4ffe86fe10e326331.html +++ b/docs/__examplesource/exsource_oule2-maint_blocks_helloworld_controller_model.php_2d255e8d018617d4ffe86fe10e326331.html @@ -1,99 +1,464 @@ - - - - - See this class in action - - - -

See this class in action

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Model controller
  6. -
  7.  *
  8. -
  9.  * @author Mark Nielsen
  10. -
  11.  * @package block_helloworld
  12. -
  13.  */
  14. -
  15.  
  16. -
  17. defined('MOODLE_INTERNAL'or die('Direct access to this script is forbidden.');
  18. -
  19.  
  20. -
  21. class block_helloworld_controller_model extends mr_controller_block {
  22. -
  23.     /**
  24. -
  25.      * Default screen
  26. -
  27.      *
  28. -
  29.      * Demo of mr_model_record_abstract
  30. -
  31.      * Demo of mr_repository_abstract
  32. -
  33.      */
  34. -
  35.     public function view_action({
  36. -
  37.         global $CFG;
  38. -
  39.  
  40. -
  41.         require_once($CFG->dirroot.'/blocks/helloworld/repository/helloworld.php');
  42. -
  43.  
  44. -
  45.         $output '';
  46. -
  47.  
  48. -
  49.         #### DEMO CODE ####
  50. -
  51.         // Our repository
  52. -
  53.         $repo new block_helloworld_repository_helloworld();
  54. -
  55.  
  56. -
  57.         // Create a new instance of our model, set some properties
  58. -
  59.         $bat new block_helloworld_model_helloworld();
  60. -
  61.         $bat->set_name('Fred')->set_foo('foo')->set_bar('bar');
  62. -
  63.  
  64. -
  65.         // Save it, repository figures out its an insert based on id property
  66. -
  67.         $repo->save($bat);
  68. -
  69.  
  70. -
  71.         $output .= $this->helper->dump($bat'$bat after insert (id is now set for us)'true);
  72. -
  73.  
  74. -
  75.         // ...later we can get $bat
  76. -
  77.         $model $repo->get(array('id' => $bat->get_id()));
  78. -
  79.  
  80. -
  81.         $output .= $this->helper->dump($model'Result of $repo->get(...)'true);
  82. -
  83.  
  84. -
  85.         // Because of the @method in our repository class's PHPDoc,
  86. -
  87.         // our ID can auto-complete on our $model, try it out!
  88. -
  89.         $name $model->get_name();
  90. -
  91.  
  92. -
  93.         $output .= $this->helper->dump($name'Result of $model->get_name()'true);
  94. -
  95.  
  96. -
  97.         // Now we can delete Fred!
  98. -
  99.         $repo->delete($model);
  100. -
  101.  
  102. -
  103.         $output .= $this->helper->dump($model'$model after delete (id is now set to null)'true);
  104. -
  105.  
  106. -
  107.         // Let's try iterating over a mr_repository_recordset!
  108. -
  109.  
  110. -
  111.         // Make some records...
  112. -
  113.         $repo->save(new block_helloworld_model_helloworld(array('name' => 'Tom')))
  114. -
  115.              ->save(new block_helloworld_model_helloworld(array('name' => 'Martin')))
  116. -
  117.              ->save(new block_helloworld_model_helloworld(array('name' => 'Kris')));
  118. -
  119.  
  120. -
  121.  
  122. -
  123.         // Our repository mapper can return a special record set, mr_repository_recordset, that returns
  124. -
  125.         // instances of our models when we iterate over it
  126. -
  127.         $rs $repo->get_recordset();
  128. -
  129.         foreach ($rs as $instance{
  130. -
  131.             // This PHPDoc tells our IDE that $instance is an instance of block_helloworld_model_helloworld
  132. -
  133.             /** @var $instance block_helloworld_model_helloworld */
  134. -
  135.             $instance->get_name()// Try it out!
  136. -
  137.  
  138. -
  139.             $output .= $this->helper->dump($instance'$instance dump in foreach loop'true);
  140. -
  141.  
  142. -
  143.             $repo->delete($instance);
  144. -
  145.         }
  146. -
  147.         $rs->close();  // Don't forget to close, just like usual!
  148. -
  149.         #### DEMO CODE ####
  150. -
  151.  
  152. -
  153.         return $this->output->heading('Demo of mr_model_record_abstract and mr_repository_abstract').
  154. -
  155.                $this->helper->highlight(__CLASS____FUNCTION__true).
  156. -
  157.                $this->output->box($output'generalbox boxaligncenter boxwidthnormal');
  158. -
  159.     }
  160. -
  161. }
  162. -
-
+ + + + + + See this class in action + + + + +

See this class in action

+
+
+
    +
  1. +
    <?php
    +
  2. +
  3. +
    /**
    +
  4. +
  5. +
     * Model controller
    +
  6. +
  7. +
     *
    +
  8. +
  9. +
     * @author Mark Nielsen +
    +
  10. +
  11. +
     * @package block_helloworld +
    +
  12. +
  13. +
     */
    +
  14. +
  15. +
     
    +
  16. +
  17. +
    defined('MOODLE_INTERNAL'or die('Direct access to this script is forbidden.');
    +
  18. +
  19. +
     
    +
  20. +
  21. +
    class block_helloworld_controller_model extends mr_controller_block {
    +
  22. +
  23. +
        /**
    +
  24. +
  25. +
         * Default screen
    +
  26. +
  27. +
         *
    +
  28. +
  29. +
         * Demo of mr_model_record_abstract +
    +
  30. +
  31. +
         * Demo of mr_repository_abstract +
    +
  32. +
  33. +
         */
    +
  34. +
  35. +
        public function view_action({ +
    +
  36. +
  37. +
            global $CFG;
    +
  38. +
  39. +
     
    +
  40. +
  41. +
            require_once($CFG->dirroot.'/blocks/helloworld/repository/helloworld.php');
    +
  42. +
  43. +
     
    +
  44. +
  45. +
            $output '';
    +
  46. +
  47. +
     
    +
  48. +
  49. +
            #### DEMO CODE ####
    +
  50. +
  51. +
            // Our repository
    +
  52. +
  53. +
            $repo new block_helloworld_repository_helloworld();
    +
  54. +
  55. +
     
    +
  56. +
  57. +
            // Create a new instance of our model,  + set some properties +
    +
  58. +
  59. +
            $bat new block_helloworld_model_helloworld();
    +
  60. +
  61. +
            $bat->set_name('Fred')->set_foo('foo')->set_bar('bar'); +
    +
  62. +
  63. +
     
    +
  64. +
  65. +
            // Save it, repository figures out its an insert  + based on id property +
    +
  66. +
  67. +
            $repo->save($bat); +
    +
  68. +
  69. +
     
    +
  70. +
  71. +
            $output .= $this->helper->dump($bat'$bat after insert (id is now set for us)'true);
    +
  72. +
  73. +
     
    +
  74. +
  75. +
            // ...later we can get $bat
    +
  76. +
  77. +
            $model $repo->get(array('id' => $bat->get_id()));
    +
  78. +
  79. +
     
    +
  80. +
  81. +
            $output .= $this->helper->dump($model'Result of $repo->get(...)'true);
    +
  82. +
  83. +
     
    +
  84. +
  85. +
            // Because of the @method in our  + repository class's PHPDoc, +
    +
  86. +
  87. +
            // our ID can auto-complete on our  + $model, try it out! +
    +
  88. +
  89. +
            $name $model->get_name();
    +
  90. +
  91. +
     
    +
  92. +
  93. +
            $output .= $this->helper->dump($name'Result of $model->get_name()'true);
    +
  94. +
  95. +
     
    +
  96. +
  97. +
            // Now we can delete Fred!
    +
  98. +
  99. +
            $repo->delete($model); +
    +
  100. +
  101. +
     
    +
  102. +
  103. +
            $output .= $this->helper->dump($model'$model after delete (id is now set to null)'true);
    +
  104. +
  105. +
     
    +
  106. +
  107. +
            // Let's try iterating over a mr_repository_recordset! +
    +
  108. +
  109. +
     
    +
  110. +
  111. +
            // Make some records...
    +
  112. +
  113. +
            $repo->save(new block_helloworld_model_helloworld(array('name' => 'Tom')))
    +
  114. +
  115. +
    +              ->save(new block_helloworld_model_helloworld(array('name' => 'Martin')))
    +
  116. +
  117. +
    +              ->save(new block_helloworld_model_helloworld(array('name' => 'Kris')));
    +
  118. +
  119. +
     
    +
  120. +
  121. +
     
    +
  122. +
  123. +
            // Our repository mapper can return a special  + record set, mr_repository_recordset, that returns +
    +
  124. +
  125. +
            // instances of our models when we iterate over it +
    +
  126. +
  127. +
            $rs $repo->get_recordset();
    +
  128. +
  129. +
            foreach ($rs as $instance{
    +
  130. +
  131. +
                // This PHPDoc tells our IDE that $instance  + is an instance of block_helloworld_model_helloworld +
    +
  132. +
  133. +
    +             /** @var $instance  + block_helloworld_model_helloworld */ +
    +
  134. +
  135. +
                $instance->get_name()// Try it out!
    +
  136. +
  137. +
     
    +
  138. +
  139. +
                $output .= $this->helper->dump($instance'$instance dump in foreach loop'true);
    +
  140. +
  141. +
     
    +
  142. +
  143. +
                $repo->delete($instance); +
    +
  144. +
  145. +
            } +
    +
  146. +
  147. +
            $rs->close();  // Don't forget to close, just like usual! +
    +
  148. +
  149. +
            #### DEMO CODE ####
    +
  150. +
  151. +
     
    +
  152. +
  153. +
            return $this->output->heading('Demo of mr_model_record_abstract and mr_repository_abstract').
    +
  154. +
  155. +
    +                $this->helper->highlight(__CLASS____FUNCTION__true).
    +
  156. +
  157. +
    +                $this->output->box($output'generalbox boxaligncenter boxwidthnormal');
    +
  158. +
  159. +
        }
    +
  160. +
  161. +
    }
    +
  162. +
+
+

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

- + + \ No newline at end of file diff --git a/docs/__examplesource/exsource_oule2-maint_blocks_helloworld_controller_table.php_69f093d72103b85451a8ad3f71467993.html b/docs/__examplesource/exsource_oule2-maint_blocks_helloworld_controller_table.php_69f093d72103b85451a8ad3f71467993.html index 55c40014..7bc3edbd 100644 --- a/docs/__examplesource/exsource_oule2-maint_blocks_helloworld_controller_table.php_69f093d72103b85451a8ad3f71467993.html +++ b/docs/__examplesource/exsource_oule2-maint_blocks_helloworld_controller_table.php_69f093d72103b85451a8ad3f71467993.html @@ -1,92 +1,456 @@ - - - - - See how to use this class - - - -

See how to use this class

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Table controller
  6. -
  7.  *
  8. -
  9.  * @author Mark Nielsen
  10. -
  11.  * @version $Id$
  12. -
  13.  * @package blocks/helloworld
  14. -
  15.  */
  16. -
  17.  
  18. -
  19. defined('MOODLE_INTERNAL'or die('Direct access to this script is forbidden.');
  20. -
  21.  
  22. -
  23. class block_helloworld_controller_table extends mr_controller_block {
  24. -
  25.     /**
  26. -
  27.      * Default screen
  28. -
  29.      *
  30. -
  31.      * Demo of mr_html_table, mr_html_paging, mr_file_export and mr_preferences
  32. -
  33.      */
  34. -
  35.     public function view_action({
  36. -
  37.         global $DB$COURSE;
  38. -
  39.  
  40. -
  41.         #### DEMO CODE ####
  42. -
  43.         // Table stores sorting info in mr_preferences
  44. -
  45.         // Paging store perpage info in mr_preferences
  46. -
  47.         $preferences new mr_preferences($COURSE->id'blocks/helloworld');
  48. -
  49.  
  50. -
  51.         // Setup the paging bar
  52. -
  53.         $paging new mr_html_paging($preferences$this->url);
  54. -
  55.         $paging->set_total($DB->count_records('user'));
  56. -
  57.         $paging->set_perpageopts(array('all'1550100));
  58. -
  59.  
  60. -
  61.         // Setup a new table
  62. -
  63.         $table new mr_html_table($preferences$this->url'username');
  64. -
  65.  
  66. -
  67.         // Add columns and column formatting
  68. -
  69.         $table->add_column('username'get_string('username'))
  70. -
  71.               ->add_column('firstname'get_string('firstname'))
  72. -
  73.               ->add_column('lastname'get_string('lastname'))
  74. -
  75.               ->add_column('email'get_string('email'))
  76. -
  77.               ->add_column('lastaccess'get_string('lastaccess'))
  78. -
  79.               ->add_format('lastaccess''date')
  80. -
  81.               ->add_format(array('username''firstname''lastname''email')'string');
  82. -
  83.  
  84. -
  85.         // Export handler - autodetects if we are exporting
  86. -
  87.         $export new mr_file_export('**'false$this->url);
  88. -
  89.  
  90. -
  91.         // When exporting, sets the limitfrom and limitnum appropriately
  92. -
  93.         $paging->set_export($export);
  94. -
  95.  
  96. -
  97.         // When exporting, send column headers to the export
  98. -
  99.         // And then route all rows to the export as well
  100. -
  101.         $table->set_export($export);
  102. -
  103.  
  104. -
  105.         // Fetch rows to add to the table
  106. -
  107.         $rows $DB->get_records('user'NULL$table->get_sql_sort()$table->get_sql_select(),
  108. -
  109.                                  $paging->get_limitfrom()$paging->get_limitnum());
  110. -
  111.  
  112. -
  113.         foreach ($rows as $row{
  114. -
  115.             $table->add_row($row);
  116. -
  117.         }
  118. -
  119.         // If exporting, sends file, if not, does nothing
  120. -
  121.         $export->send();
  122. -
  123.  
  124. -
  125.         // Render the result
  126. -
  127.         $output  $this->mroutput->render($paging);
  128. -
  129.         $output .= $this->mroutput->render($table);
  130. -
  131.         $output .= $this->mroutput->render($paging);
  132. -
  133.         $output .= $this->mroutput->render($export);
  134. -
  135.         #### DEMO CODE ####
  136. -
  137.  
  138. -
  139.         return $this->output->heading('Demo of mr_table_*').
  140. -
  141.                $this->helper->highlight(__CLASS____FUNCTION__true).
  142. -
  143.                $this->output->box($output'generalbox boxaligncenter boxwidthnormal');
  144. -
  145.     }
  146. -
  147. }
  148. -
-
+ + + + + + See how to use this class + + + + +

See how to use this class

+
+
+
    +
  1. +
    <?php
    +
  2. +
  3. +
    /**
    +
  4. +
  5. +
     * Table controller
    +
  6. +
  7. +
     *
    +
  8. +
  9. +
     * @author Mark Nielsen +
    +
  10. +
  11. +
     * @version $Id$
    +
  12. +
  13. +
     * @package blocks/helloworld +
    +
  14. +
  15. +
     */
    +
  16. +
  17. +
     
    +
  18. +
  19. +
    defined('MOODLE_INTERNAL'or die('Direct access to this script is forbidden.');
    +
  20. +
  21. +
     
    +
  22. +
  23. +
    class block_helloworld_controller_table extends mr_controller_block {
    +
  24. +
  25. +
        /**
    +
  26. +
  27. +
         * Default screen
    +
  28. +
  29. +
         *
    +
  30. +
  31. +
         * Demo of mr_html_table,  + mr_html_paging, mr_file_export and mr_preferences +
    +
  32. +
  33. +
         */
    +
  34. +
  35. +
        public function view_action({ +
    +
  36. +
  37. +
            global $DB$COURSE;
    +
  38. +
  39. +
     
    +
  40. +
  41. +
            #### DEMO CODE ####
    +
  42. +
  43. +
            // Table stores sorting info in mr_preferences +
    +
  44. +
  45. +
            // Paging store perpage info in mr_preferences +
    +
  46. +
  47. +
            $preferences new mr_preferences($COURSE->id'blocks/helloworld');
    +
  48. +
  49. +
     
    +
  50. +
  51. +
            // Setup the paging bar
    +
  52. +
  53. +
            $paging new mr_html_paging($preferences$this->url);
    +
  54. +
  55. +
            $paging->set_total($DB->count_records('user')); +
    +
  56. +
  57. +
            $paging->set_perpageopts(array('all'1550100)); +
    +
  58. +
  59. +
     
    +
  60. +
  61. +
            // Setup a new table
    +
  62. +
  63. +
            $table new mr_html_table($preferences$this->url'username');
    +
  64. +
  65. +
     
    +
  66. +
  67. +
            // Add columns and column formatting
    +
  68. +
  69. +
            $table->add_column('username'get_string('username'))
    +
  70. +
  71. +
    +               ->add_column('firstname'get_string('firstname'))
    +
  72. +
  73. +
    +               ->add_column('lastname'get_string('lastname'))
    +
  74. +
  75. +
    +               ->add_column('email'get_string('email')) +
    +
  76. +
  77. +
    +               ->add_column('lastaccess'get_string('lastaccess'))
    +
  78. +
  79. +
    +               ->add_format('lastaccess''date')
    +
  80. +
  81. +
    +               ->add_format(array('username''firstname''lastname''email')'string'); +
    +
  82. +
  83. +
     
    +
  84. +
  85. +
            // Export handler - autodetects if we are exporting +
    +
  86. +
  87. +
            $export new mr_file_export('**'false$this->url);
    +
  88. +
  89. +
     
    +
  90. +
  91. +
            // When exporting, sets the limitfrom  + and limitnum appropriately +
    +
  92. +
  93. +
            $paging->set_export($export); +
    +
  94. +
  95. +
     
    +
  96. +
  97. +
            // When exporting, send column headers to the export +
    +
  98. +
  99. +
            // And then route all rows to the export as well +
    +
  100. +
  101. +
            $table->set_export($export); +
    +
  102. +
  103. +
     
    +
  104. +
  105. +
            // Fetch rows to add to the table +
    +
  106. +
  107. +
            $rows $DB->get_records('user'NULL$table->get_sql_sort()$table->get_sql_select(),
    +
  108. +
  109. +
    +                   +                 $paging->get_limitfrom()$paging->get_limitnum());
    +
  110. +
  111. +
     
    +
  112. +
  113. +
            foreach ($rows as $row{
    +
  114. +
  115. +
                $table->add_row($row); +
    +
  116. +
  117. +
            } +
    +
  118. +
  119. +
            // If exporting, sends file, if not, does nothing +
    +
  120. +
  121. +
            $export->send();
    +
  122. +
  123. +
     
    +
  124. +
  125. +
            // Render the result
    +
  126. +
  127. +
            $output  $this->mroutput->render($paging);
    +
  128. +
  129. +
            $output .= $this->mroutput->render($table);
    +
  130. +
  131. +
            $output .= $this->mroutput->render($paging);
    +
  132. +
  133. +
            $output .= $this->mroutput->render($export);
    +
  134. +
  135. +
            #### DEMO CODE ####
    +
  136. +
  137. +
     
    +
  138. +
  139. +
            return $this->output->heading('Demo of mr_table_*').
    +
  140. +
  141. +
    +                $this->helper->highlight(__CLASS____FUNCTION__true).
    +
  142. +
  143. +
    +                $this->output->box($output'generalbox boxaligncenter boxwidthnormal');
    +
  144. +
  145. +
        }
    +
  146. +
  147. +
    }
    +
  148. +
+
+

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

- + + \ No newline at end of file diff --git a/docs/__examplesource/exsource_oule2-maint_blocks_helloworld_plugin_one_class.php_9809169f01018eeb3cf9d2f74794d0d5.html b/docs/__examplesource/exsource_oule2-maint_blocks_helloworld_plugin_one_class.php_9809169f01018eeb3cf9d2f74794d0d5.html index 7b4b8282..273237be 100644 --- a/docs/__examplesource/exsource_oule2-maint_blocks_helloworld_plugin_one_class.php_9809169f01018eeb3cf9d2f74794d0d5.html +++ b/docs/__examplesource/exsource_oule2-maint_blocks_helloworld_plugin_one_class.php_9809169f01018eeb3cf9d2f74794d0d5.html @@ -1,34 +1,95 @@ - - - - - Plugin class, extending base plugin class - - - -

Plugin class, extending base plugin class

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Plugin: One
  6. -
  7.  *
  8. -
  9.  * @author Mark Nielsen
  10. -
  11.  */
  12. -
  13.  
  14. -
  15. defined('MOODLE_INTERNAL'or die('Direct access to this script is forbidden.');
  16. -
  17.  
  18. -
  19. require_once($CFG->dirroot.'/blocks/helloworld/plugin/base/class.php');
  20. -
  21.  
  22. -
  23. class block_helloworld_plugin_one_class extends block_helloworld_plugin_base_class {
  24. -
  25.     public function abstract_method({
  26. -
  27.         return 'block_helloworld_plugin_one_class';
  28. -
  29.     }
  30. -
  31. }
  32. -
-
+ + + + + + Plugin class, extending base plugin class + + + + +

Plugin class, extending base plugin class

+
+
+
    +
  1. +
    <?php
    +
  2. +
  3. +
    /**
    +
  4. +
  5. +
     * Plugin: One
    +
  6. +
  7. +
     *
    +
  8. +
  9. +
     * @author Mark Nielsen +
    +
  10. +
  11. +
     */
    +
  12. +
  13. +
     
    +
  14. +
  15. +
    defined('MOODLE_INTERNAL'or die('Direct access to this script is forbidden.');
    +
  16. +
  17. +
     
    +
  18. +
  19. +
    require_once($CFG->dirroot.'/blocks/helloworld/plugin/base/class.php');
    +
  20. +
  21. +
     
    +
  22. +
  23. +
    class block_helloworld_plugin_one_class extends block_helloworld_plugin_base_class { +
    +
  24. +
  25. +
        public function abstract_method({ +
    +
  26. +
  27. +
            return 'block_helloworld_plugin_one_class'; +
    +
  28. +
  29. +
        }
    +
  30. +
  31. +
    }
    +
  32. +
+
+

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

- + + \ No newline at end of file diff --git a/docs/__examplesource/exsource_s_joule2-maint_blocks_helloworld_controller_db.php_b26ad4e1eaa1277b115e31683118039b.html b/docs/__examplesource/exsource_s_joule2-maint_blocks_helloworld_controller_db.php_b26ad4e1eaa1277b115e31683118039b.html index ba929713..000afd59 100644 --- a/docs/__examplesource/exsource_s_joule2-maint_blocks_helloworld_controller_db.php_b26ad4e1eaa1277b115e31683118039b.html +++ b/docs/__examplesource/exsource_s_joule2-maint_blocks_helloworld_controller_db.php_b26ad4e1eaa1277b115e31683118039b.html @@ -1,210 +1,1072 @@ - - - - - See this class in action - - - -

See this class in action

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * db controller
  6. -
  7.  *
  8. -
  9.  * @author Mark Nielsen
  10. -
  11.  * @version $Id$
  12. -
  13.  * @package blocks/helloworld
  14. -
  15.  */
  16. -
  17.  
  18. -
  19. defined('MOODLE_INTERNAL'or die('Direct access to this script is forbidden.');
  20. -
  21.  
  22. -
  23. class block_helloworld_controller_db extends mr_controller_block {
  24. -
  25.     /**
  26. -
  27.      * Default screen
  28. -
  29.      *
  30. -
  31.      * Demo of mr_db_table
  32. -
  33.      */
  34. -
  35.     public function view_action({
  36. -
  37.         $this->print_header();
  38. -
  39.  
  40. -
  41.         echo $this->output->heading('Demo of mr_db_table');
  42. -
  43.         $this->helper->highlight(__CLASS____FUNCTION__);
  44. -
  45.         echo $this->output->box_start('generalbox boxaligncenter boxwidthnormal');
  46. -
  47.  
  48. -
  49.         #### DEMO CODE ####
  50. -
  51.         // Create a new instance for table 'block_helloworld'
  52. -
  53.         $table new mr_db_table('block_helloworld');
  54. -
  55.  
  56. -
  57.         // Get table columns
  58. -
  59.         $result $table->get_columns();
  60. -
  61.         $this->helper->dump($result'get_columns result');
  62. -
  63.  
  64. -
  65.         // Get detailed column information
  66. -
  67.         $result $table->get_metacolumns();
  68. -
  69.         $this->helper->dump($result'get_metacolumns result');
  70. -
  71.  
  72. -
  73.         // Check for existing column
  74. -
  75.         $result $table->column_exists('foo');
  76. -
  77.         $this->helper->dump($result'column_exists result');
  78. -
  79.  
  80. -
  81.         // Check non-existent column
  82. -
  83.         $result $table->column_exists('baz');
  84. -
  85.         $this->helper->dump($result'column_exists result');
  86. -
  87.  
  88. -
  89.         // Generates a mr_db_record setup for this table
  90. -
  91.         $result $table->record();
  92. -
  93.         $this->helper->dump($result'record result');
  94. -
  95.  
  96. -
  97.         // Form handling example:
  98. -
  99.         // } else if ($data = $mform->get_data()) {
  100. -
  101.         //     $table = new mr_db_table('tablename');
  102. -
  103.         //     $table->save($data);
  104. -
  105.         //     redirect(...);
  106. -
  107.         // }
  108. -
  109.  
  110. -
  111.         // $table has access to a lot of lib/dmllib.php methods
  112. -
  113.         // The following routes the call to $DB->get_records()
  114. -
  115.         $result $table->get_records();
  116. -
  117.         $this->helper->dump($result'get_records result');
  118. -
  119.         #### DEMO CODE ####
  120. -
  121.  
  122. -
  123.         echo $this->output->box_end();
  124. -
  125.         $this->print_footer();
  126. -
  127.     }
  128. -
  129.  
  130. -
  131.     /**
  132. -
  133.      * Demo of mr_db_record
  134. -
  135.      */
  136. -
  137.     public function record_action({
  138. -
  139.         global $DB;
  140. -
  141.  
  142. -
  143.         $this->print_header();
  144. -
  145.  
  146. -
  147.         echo $this->output->heading('Demo of mr_db_record');
  148. -
  149.         $this->helper->highlight(__CLASS____FUNCTION__);
  150. -
  151.         echo $this->output->box_start('generalbox boxaligncenter boxwidthnormal');
  152. -
  153.  
  154. -
  155.         #### DEMO CODE ####
  156. -
  157.         // Create a new record
  158. -
  159.         $record new mr_db_record('block_helloworld');
  160. -
  161.  
  162. -
  163.         echo $this->output->heading('Insert demo');
  164. -
  165.  
  166. -
  167.         // Example: direct access
  168. -
  169.         $record new mr_db_record('block_helloworld');
  170. -
  171.         $record->name "It's";
  172. -
  173.         $record->foo  'a';
  174. -
  175.         $record->bar  'boy';
  176. -
  177.         $this->helper->dump($record'It\'s a boy result');  // Data is set
  178. -
  179.  
  180. -
  181.         // Example: Use set() and save()
  182. -
  183.         $record new mr_db_record('block_helloworld');
  184. -
  185.         $data array(
  186. -
  187.             'name' => "It's",
  188. -
  189.             'foo'  => 'a',
  190. -
  191.             'bar'  => 'boy',
  192. -
  193.             'ding' => 'pow'// This will be ignored by set() because it's an nonexistent field
  194. -
  195.         );
  196. -
  197.         $record->set($data)->save();
  198. -
  199.         $this->helper->dump($record'saved record result');  // id will be set
  200. -
  201.  
  202. -
  203.         // You can iterate a record! Woaaaaah!
  204. -
  205.         echo $this->output->heading('Iteration demo');
  206. -
  207.         foreach ($record as $key => $value{
  208. -
  209.             print_object("$key = $value");
  210. -
  211.         }
  212. -
  213.  
  214. -
  215.         // You can count!
  216. -
  217.         echo $this->output->heading('Count demo');
  218. -
  219.         $this->helper->dump(count($record)'count result');
  220. -
  221.  
  222. -
  223.         // You can access it like an array!
  224. -
  225.         echo $this->output->heading('Array access demo');
  226. -
  227.         $this->helper->dump($record['name']'array access result');
  228. -
  229.  
  230. -
  231.         // Example: working with an existing record
  232. -
  233.         $default $DB->get_record('block_helloworld'array('id' => $record->id));
  234. -
  235.         $record  new mr_db_record('block_helloworld'$default);
  236. -
  237.         // Do something to change the record otherwise save() will not do anything (which is good!)
  238. -
  239.         $record->name 'Dingo';
  240. -
  241.         $record->save();
  242. -
  243.  
  244. -
  245.         $result $DB->get_record('block_helloworld'array('id' => $record->id));
  246. -
  247.         $this->helper->dump($result'save result name = \'Dingo\'');
  248. -
  249.  
  250. -
  251.         // Example: delete a record
  252. -
  253.         $default $DB->get_record('block_helloworld'array('id' => $record->id));
  254. -
  255.         $record  new mr_db_record('block_helloworld'$default);
  256. -
  257.         $oldid   $record->id;
  258. -
  259.         // Something happens and now you have to delete...
  260. -
  261.         $record->delete();
  262. -
  263.  
  264. -
  265.         // Let's see what's in the record now (should be empty)
  266. -
  267.         $this->helper->dump($record'how record looks after delete()');
  268. -
  269.  
  270. -
  271.         // See if the record really was deleted
  272. -
  273.         $result $DB->get_record('block_helloworld'array('id' => $oldid));
  274. -
  275.         $this->helper->dump($result'record no longer exists');
  276. -
  277.         #### DEMO CODE ####
  278. -
  279.  
  280. -
  281.         echo $this->output->box_end();
  282. -
  283.         $this->print_footer();
  284. -
  285.     }
  286. -
  287.  
  288. -
  289.     /**
  290. -
  291.      * Demo of mr_db_queue
  292. -
  293.      */
  294. -
  295.     public function queue_action({
  296. -
  297.         global $DB;
  298. -
  299.  
  300. -
  301.         $this->print_header();
  302. -
  303.  
  304. -
  305.         echo $this->output->heading('Demo of mr_db_queue');
  306. -
  307.         $this->helper->highlight(__CLASS____FUNCTION__);
  308. -
  309.         echo $this->output->box_start('generalbox boxaligncenter boxwidthnormal');
  310. -
  311.  
  312. -
  313.         #### DEMO CODE ####
  314. -
  315.         // Setup a new queue
  316. -
  317.         $queue new mr_db_queue();
  318. -
  319.  
  320. -
  321.         // Load up the queue with inserts and deletes
  322. -
  323.         for ($i 0$i 5$i++{
  324. -
  325.             $record new mr_db_record('block_helloworld');
  326. -
  327.             $data array(
  328. -
  329.                 'name' => "It's",  // DO NOT SLASH IT!
  330. -
  331.                 'foo'  => 'a',
  332. -
  333.                 'bar'  => 'boy',
  334. -
  335.             );
  336. -
  337.             $record->set($data);
  338. -
  339.             $queue->add($record)// Could also add an array of records!
  340. -
  341.         }
  342. -
  343.         if ($records $DB->get_records('block_helloworld')) {
  344. -
  345.             foreach ($records as $record{
  346. -
  347.                 $record new mr_db_record('block_helloworld'$record);
  348. -
  349.                 $record->queue_delete();
  350. -
  351.                 $queue->add($record);
  352. -
  353.             }
  354. -
  355.         }
  356. -
  357.         // Show whats in the queue
  358. -
  359.         $this->helper->dump($queue'The loaded queue');
  360. -
  361.  
  362. -
  363.         // Flush the queue, should do everything in 2 transactions
  364. -
  365.         $queue->flush();
  366. -
  367.  
  368. -
  369.         // Show whats in the queue after flush
  370. -
  371.         $this->helper->dump($queue'The flushed queue');
  372. -
  373.         #### DEMO CODE ####
  374. -
  375.  
  376. -
  377.         echo $this->output->box_end();
  378. -
  379.         $this->print_footer();
  380. -
  381.     }
  382. -
  383. }
  384. -
-
+ + + + + + See this class in action + + + + +

See this class in action

+
+
+
    +
  1. +
    <?php
    +
  2. +
  3. +
    /**
    +
  4. +
  5. +
     * db controller
    +
  6. +
  7. +
     *
    +
  8. +
  9. +
     * @author Mark Nielsen +
    +
  10. +
  11. +
     * @version $Id$
    +
  12. +
  13. +
     * @package blocks/helloworld +
    +
  14. +
  15. +
     */
    +
  16. +
  17. +
     
    +
  18. +
  19. +
    defined('MOODLE_INTERNAL'or die('Direct access to this script is forbidden.');
    +
  20. +
  21. +
     
    +
  22. +
  23. +
    class block_helloworld_controller_db extends mr_controller_block {
    +
  24. +
  25. +
        /**
    +
  26. +
  27. +
         * Default screen
    +
  28. +
  29. +
         *
    +
  30. +
  31. +
         * Demo of mr_db_table +
    +
  32. +
  33. +
         */
    +
  34. +
  35. +
        public function view_action({ +
    +
  36. +
  37. +
            $this->print_header();
    +
  38. +
  39. +
     
    +
  40. +
  41. +
            echo $this->output->heading('Demo of mr_db_table');
    +
  42. +
  43. +
            $this->helper->highlight(__CLASS____FUNCTION__);
    +
  44. +
  45. +
            echo $this->output->box_start('generalbox boxaligncenter boxwidthnormal');
    +
  46. +
  47. +
     
    +
  48. +
  49. +
            #### DEMO CODE ####
    +
  50. +
  51. +
            // Create a new instance for table 'block_helloworld' +
    +
  52. +
  53. +
            $table new mr_db_table('block_helloworld');
    +
  54. +
  55. +
     
    +
  56. +
  57. +
            // Get table columns
    +
  58. +
  59. +
            $result $table->get_columns();
    +
  60. +
  61. +
            $this->helper->dump($result'get_columns result');
    +
  62. +
  63. +
     
    +
  64. +
  65. +
            // Get detailed column information
    +
  66. +
  67. +
            $result $table->get_metacolumns();
    +
  68. +
  69. +
            $this->helper->dump($result'get_metacolumns result');
    +
  70. +
  71. +
     
    +
  72. +
  73. +
            // Check for existing column
    +
  74. +
  75. +
            $result $table->column_exists('foo');
    +
  76. +
  77. +
            $this->helper->dump($result'column_exists result');
    +
  78. +
  79. +
     
    +
  80. +
  81. +
            // Check non-existent column
    +
  82. +
  83. +
            $result $table->column_exists('baz');
    +
  84. +
  85. +
            $this->helper->dump($result'column_exists result');
    +
  86. +
  87. +
     
    +
  88. +
  89. +
            // Generates a mr_db_record setup for this table +
    +
  90. +
  91. +
            $result $table->record();
    +
  92. +
  93. +
            $this->helper->dump($result'record result');
    +
  94. +
  95. +
     
    +
  96. +
  97. +
            // Form handling example:
    +
  98. +
  99. +
            // } else if ($data = $mform->get_data()) { +
    +
  100. +
  101. +
            //     $table = new mr_db_table('tablename'); +
    +
  102. +
  103. +
            //     $table->save($data);
    +
  104. +
  105. +
            //     redirect(...);
    +
  106. +
  107. +
            // }
    +
  108. +
  109. +
     
    +
  110. +
  111. +
            // $table has access to a lot of lib/dmllib.php methods +
    +
  112. +
  113. +
            // The following routes the call to $DB->get_records() +
    +
  114. +
  115. +
            $result $table->get_records();
    +
  116. +
  117. +
            $this->helper->dump($result'get_records result');
    +
  118. +
  119. +
            #### DEMO CODE ####
    +
  120. +
  121. +
     
    +
  122. +
  123. +
            echo $this->output->box_end();
    +
  124. +
  125. +
            $this->print_footer();
    +
  126. +
  127. +
        }
    +
  128. +
  129. +
     
    +
  130. +
  131. +
        /**
    +
  132. +
  133. +
         * Demo of mr_db_record +
    +
  134. +
  135. +
         */
    +
  136. +
  137. +
        public function record_action({ +
    +
  138. +
  139. +
            global $DB;
    +
  140. +
  141. +
     
    +
  142. +
  143. +
            $this->print_header();
    +
  144. +
  145. +
     
    +
  146. +
  147. +
            echo $this->output->heading('Demo of mr_db_record');
    +
  148. +
  149. +
            $this->helper->highlight(__CLASS____FUNCTION__);
    +
  150. +
  151. +
            echo $this->output->box_start('generalbox boxaligncenter boxwidthnormal');
    +
  152. +
  153. +
     
    +
  154. +
  155. +
            #### DEMO CODE ####
    +
  156. +
  157. +
            // Create a new record
    +
  158. +
  159. +
            $record new mr_db_record('block_helloworld');
    +
  160. +
  161. +
     
    +
  162. +
  163. +
            echo $this->output->heading('Insert demo');
    +
  164. +
  165. +
     
    +
  166. +
  167. +
            // Example: direct access
    +
  168. +
  169. +
            $record new mr_db_record('block_helloworld');
    +
  170. +
  171. +
            $record->name "It's";
    +
  172. +
  173. +
            $record->foo  'a';
    +
  174. +
  175. +
            $record->bar  'boy';
    +
  176. +
  177. +
            $this->helper->dump($record'It\'s a boy result');  // Data is set
    +
  178. +
  179. +
     
    +
  180. +
  181. +
            // Example: Use set() and save()
    +
  182. +
  183. +
            $record new mr_db_record('block_helloworld');
    +
  184. +
  185. +
            $data array(
    +
  186. +
  187. +
                'name' => "It's",
    +
  188. +
  189. +
                'foo'  => 'a',
    +
  190. +
  191. +
                'bar'  => 'boy',
    +
  192. +
  193. +
                'ding' => 'pow'// This will be ignored by set() because  + it's an nonexistent field +
    +
  194. +
  195. +
            );
    +
  196. +
  197. +
            $record->set($data)->save();
    +
  198. +
  199. +
            $this->helper->dump($record'saved record result');  // id will be set
    +
  200. +
  201. +
     
    +
  202. +
  203. +
            // You can iterate a record! Woaaaaah! +
    +
  204. +
  205. +
            echo $this->output->heading('Iteration demo');
    +
  206. +
  207. +
            foreach ($record as $key => $value{
    +
  208. +
  209. +
                print_object("$key = $value"); +
    +
  210. +
  211. +
            } +
    +
  212. +
  213. +
     
    +
  214. +
  215. +
            // You can count!
    +
  216. +
  217. +
            echo $this->output->heading('Count demo');
    +
  218. +
  219. +
            $this->helper->dump(count($record)'count result');
    +
  220. +
  221. +
     
    +
  222. +
  223. +
            // You can access it like an array! +
    +
  224. +
  225. +
            echo $this->output->heading('Array access demo');
    +
  226. +
  227. +
            $this->helper->dump($record['name']'array access result');
    +
  228. +
  229. +
     
    +
  230. +
  231. +
            // Example: working with an existing record +
    +
  232. +
  233. +
            $default $DB->get_record('block_helloworld'array('id' => $record->id));
    +
  234. +
  235. +
            $record  new mr_db_record('block_helloworld'$default);
    +
  236. +
  237. +
            // Do something to change the record otherwise  + save() will not do anything (which is good!) +
    +
  238. +
  239. +
            $record->name 'Dingo';
    +
  240. +
  241. +
            $record->save();
    +
  242. +
  243. +
     
    +
  244. +
  245. +
            $result $DB->get_record('block_helloworld'array('id' => $record->id));
    +
  246. +
  247. +
            $this->helper->dump($result'save result name = \'Dingo\'');
    +
  248. +
  249. +
     
    +
  250. +
  251. +
            // Example: delete a record
    +
  252. +
  253. +
            $default $DB->get_record('block_helloworld'array('id' => $record->id));
    +
  254. +
  255. +
            $record  new mr_db_record('block_helloworld'$default);
    +
  256. +
  257. +
            $oldid   $record->id;
    +
  258. +
  259. +
            // Something happens and now you have to delete... +
    +
  260. +
  261. +
            $record->delete();
    +
  262. +
  263. +
     
    +
  264. +
  265. +
            // Let's see what's in the  + record now (should be empty) +
    +
  266. +
  267. +
            $this->helper->dump($record'how record looks after delete()');
    +
  268. +
  269. +
     
    +
  270. +
  271. +
            // See if the record really was deleted +
    +
  272. +
  273. +
            $result $DB->get_record('block_helloworld'array('id' => $oldid)); +
    +
  274. +
  275. +
            $this->helper->dump($result'record no longer exists');
    +
  276. +
  277. +
            #### DEMO CODE ####
    +
  278. +
  279. +
     
    +
  280. +
  281. +
            echo $this->output->box_end();
    +
  282. +
  283. +
            $this->print_footer();
    +
  284. +
  285. +
        }
    +
  286. +
  287. +
     
    +
  288. +
  289. +
        /**
    +
  290. +
  291. +
         * Demo of mr_db_queue +
    +
  292. +
  293. +
         */
    +
  294. +
  295. +
        public function queue_action({ +
    +
  296. +
  297. +
            global $DB;
    +
  298. +
  299. +
     
    +
  300. +
  301. +
            $this->print_header();
    +
  302. +
  303. +
     
    +
  304. +
  305. +
            echo $this->output->heading('Demo of mr_db_queue');
    +
  306. +
  307. +
            $this->helper->highlight(__CLASS____FUNCTION__);
    +
  308. +
  309. +
            echo $this->output->box_start('generalbox boxaligncenter boxwidthnormal');
    +
  310. +
  311. +
     
    +
  312. +
  313. +
            #### DEMO CODE ####
    +
  314. +
  315. +
            // Setup a new queue
    +
  316. +
  317. +
            $queue new mr_db_queue();
    +
  318. +
  319. +
     
    +
  320. +
  321. +
            // Load up the queue with inserts and deletes +
    +
  322. +
  323. +
            for ($i 0$i 5$i++{
    +
  324. +
  325. +
                $record new mr_db_record('block_helloworld');
    +
  326. +
  327. +
                $data array(
    +
  328. +
  329. +
    +                 'name' => "It's",  // DO NOT SLASH IT!
    +
  330. +
  331. +
    +                 'foo'  => 'a',
    +
  332. +
  333. +
    +                 'bar'  => 'boy',
    +
  334. +
  335. +
                );
    +
  336. +
  337. +
                $record->set($data); +
    +
  338. +
  339. +
                $queue->add($record)// Could also add an array of records! +
    +
  340. +
  341. +
            } +
    +
  342. +
  343. +
            if ($records $DB->get_records('block_helloworld')) {
    +
  344. +
  345. +
                foreach ($records as $record{
    +
  346. +
  347. +
    +                 $record new mr_db_record('block_helloworld'$record);
    +
  348. +
  349. +
    +                 $record->queue_delete();
    +
  350. +
  351. +
    +                 $queue->add($record); +
    +
  352. +
  353. +
                }
    +
  354. +
  355. +
            } +
    +
  356. +
  357. +
            // Show whats in the queue
    +
  358. +
  359. +
            $this->helper->dump($queue'The loaded queue');
    +
  360. +
  361. +
     
    +
  362. +
  363. +
            // Flush the queue, should do everything  + in 2 transactions +
    +
  364. +
  365. +
            $queue->flush();
    +
  366. +
  367. +
     
    +
  368. +
  369. +
            // Show whats in the queue after flush +
    +
  370. +
  371. +
            $this->helper->dump($queue'The flushed queue');
    +
  372. +
  373. +
            #### DEMO CODE ####
    +
  374. +
  375. +
     
    +
  376. +
  377. +
            echo $this->output->box_end();
    +
  378. +
  379. +
            $this->print_footer();
    +
  380. +
  381. +
        }
    +
  382. +
  383. +
    }
    +
  384. +
+
+

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

- + + \ No newline at end of file diff --git a/docs/__examplesource/exsource_tes_joule2-maint_blocks_helloworld_webservices.php_c1a862a8922f2c4590de2cdacca66e16.html b/docs/__examplesource/exsource_tes_joule2-maint_blocks_helloworld_webservices.php_c1a862a8922f2c4590de2cdacca66e16.html index e7c6e3b1..37544dc4 100644 --- a/docs/__examplesource/exsource_tes_joule2-maint_blocks_helloworld_webservices.php_c1a862a8922f2c4590de2cdacca66e16.html +++ b/docs/__examplesource/exsource_tes_joule2-maint_blocks_helloworld_webservices.php_c1a862a8922f2c4590de2cdacca66e16.html @@ -1,54 +1,216 @@ - - - - - Example server usage - - - -

Example server usage

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Example Web Services
  6. -
  7.  *
  8. -
  9.  * Example structure for a more complex web service
  10. -
  11.  * that can support multiple endpoints and service types:
  12. -
  13.  *      /path/to/plugin/
  14. -
  15.  *                  webservices/
  16. -
  17.  *                      TYPE/                (EG: rest)
  18. -
  19.  *                          ENDPOINTNAME.php (EG: user.php)
  20. -
  21.  *                  model/
  22. -
  23.  *                      response/            (Store response classes here)
  24. -
  25.  *                      service/             (Store service classes here)
  26. -
  27.  *
  28. -
  29.  * @author Mark Nielsen
  30. -
  31.  * @package blocks/helloworld
  32. -
  33.  ***/
  34. -
  35.  
  36. -
  37. define('NO_DEBUG_DISPLAY'true);
  38. -
  39. define('NO_MOODLE_COOKIES'true);
  40. -
  41.  
  42. -
  43. require_once('../../config.php');
  44. -
  45. require($CFG->dirroot.'/local/mr/bootstrap.php');
  46. -
  47. require($CFG->dirroot.'/blocks/helloworld/lib/server/service.php');
  48. -
  49. require($CFG->dirroot.'/blocks/helloworld/lib/server/response.php');
  50. -
  51.  
  52. -
  53. // Server validation (Mix and match)
  54. -
  55. $validator new Zend_Validate();
  56. -
  57. $validator->addValidator(new mr_server_validate_secure())
  58. -
  59.           ->addValidator(new mr_server_validate_method())
  60. -
  61.           ->addValidator(new mr_server_validate_ip('127.0.0.1'))
  62. -
  63.           ->addValidator(new mr_server_validate_token('tokenvalue'))
  64. -
  65.           ->addValidator(new mr_server_validate_login());
  66. -
  67.  
  68. -
  69. $server new mr_server_rest('blocks_helloworld_lib_server_service''blocks_helloworld_lib_server_response'$validator);
  70. -
  71. $server->handle();
  72. -
-
+ + + + + + Example server usage + + + + +

Example server usage

+
+
+
    +
  1. +
    <?php
    +
  2. +
  3. +
    /**
    +
  4. +
  5. +
     * Example Web Services
    +
  6. +
  7. +
     *
    +
  8. +
  9. +
     * Example structure for a more complex web service +
    +
  10. +
  11. +
     * that can support multiple endpoints and service types: +
    +
  12. +
  13. +
     *      /path/to/plugin/
    +
  14. +
  15. +
     *              +      webservices/ +
    +
  16. +
  17. +
     *                  +      TYPE/                +  (EG: rest) +
    +
  18. +
  19. +
     *                  +          ENDPOINTNAME.php (EG: user.php) +
    +
  20. +
  21. +
     *                  +  model/ +
    +
  22. +
  23. +
     *                  +      response/             + (Store response classes here) +
    +
  24. +
  25. +
     *                  +      service/              + (Store service classes here) +
    +
  26. +
  27. +
     *
    +
  28. +
  29. +
     * @author Mark Nielsen +
    +
  30. +
  31. +
     * @package blocks/helloworld +
    +
  32. +
  33. +
     ***/
    +
  34. +
  35. +
     
    +
  36. +
  37. +
    define('NO_DEBUG_DISPLAY'true);
    +
  38. +
  39. +
    define('NO_MOODLE_COOKIES'true);
    +
  40. +
  41. +
     
    +
  42. +
  43. +
    require_once('../../config.php');
    +
  44. +
  45. +
    require($CFG->dirroot.'/local/mr/bootstrap.php');
    +
  46. +
  47. +
    require($CFG->dirroot.'/blocks/helloworld/lib/server/service.php');
    +
  48. +
  49. +
    require($CFG->dirroot.'/blocks/helloworld/lib/server/response.php');
    +
  50. +
  51. +
     
    +
  52. +
  53. +
    // Server validation (Mix and match)
    +
  54. +
  55. +
    $validator new Zend_Validate();
    +
  56. +
  57. +
    $validator->addValidator(new mr_server_validate_secure())
    +
  58. +
  59. +
              ->addValidator(new mr_server_validate_method())
    +
  60. +
  61. +
              ->addValidator(new mr_server_validate_ip('127.0.0.1'))
    +
  62. +
  63. +
              ->addValidator(new mr_server_validate_token('tokenvalue'))
    +
  64. +
  65. +
              ->addValidator(new mr_server_validate_login());
    +
  66. +
  67. +
     
    +
  68. +
  69. +
    $server new mr_server_rest('blocks_helloworld_lib_server_service''blocks_helloworld_lib_server_response'$validator);
    +
  70. +
  71. +
    $server->handle();
    +
  72. +
+
+

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

- + + \ No newline at end of file diff --git a/docs/__examplesource/exsource_ule2-maint_blocks_helloworld_controller_filter.php_a164674c6c86cad0df598a0c1a4c5e7d.html b/docs/__examplesource/exsource_ule2-maint_blocks_helloworld_controller_filter.php_a164674c6c86cad0df598a0c1a4c5e7d.html index 347b02ce..056956d8 100644 --- a/docs/__examplesource/exsource_ule2-maint_blocks_helloworld_controller_filter.php_a164674c6c86cad0df598a0c1a4c5e7d.html +++ b/docs/__examplesource/exsource_ule2-maint_blocks_helloworld_controller_filter.php_a164674c6c86cad0df598a0c1a4c5e7d.html @@ -1,71 +1,312 @@ - - - - - See how to use this class - - - -

See how to use this class

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Filter controller
  6. -
  7.  *
  8. -
  9.  * @author Mark Nielsen
  10. -
  11.  * @version $Id$
  12. -
  13.  * @package blocks/helloworld
  14. -
  15.  */
  16. -
  17.  
  18. -
  19. defined('MOODLE_INTERNAL'or die('Direct access to this script is forbidden.');
  20. -
  21.  
  22. -
  23. class block_helloworld_controller_filter extends mr_controller_block {
  24. -
  25.     /**
  26. -
  27.      * Default screen
  28. -
  29.      *
  30. -
  31.      * Demo of mr_filter et al
  32. -
  33.      */
  34. -
  35.     public function view_action({
  36. -
  37.         global $COURSE;
  38. -
  39.  
  40. -
  41.         #### DEMO CODE ####
  42. -
  43.         // Filter values are stored here
  44. -
  45.         $preferences new mr_preferences($COURSE->id'blocks/helloworld');
  46. -
  47.  
  48. -
  49.         // Create the filter "manager"
  50. -
  51.         $filter new mr_html_filter($preferences$this->url);
  52. -
  53.  
  54. -
  55.         // Add a filter
  56. -
  57.         $filter->add(new mr_html_filter_text('foo''Foo'));
  58. -
  59.  
  60. -
  61.         // Add the same filter, shortcut way
  62. -
  63.         $filter->new_text('bar''Bar');
  64. -
  65.  
  66. -
  67.         // You can chain these too (with add() as well)
  68. -
  69.         $filter->new_select('baz''Baz'array('0' => 'No''1' => 'Yes'))
  70. -
  71.                ->new_daterange('bat''Bat');
  72. -
  73.  
  74. -
  75.         // Render the filter: This should be done before the print_header() - may redirect
  76. -
  77.         $output $this->mroutput->render($filter);
  78. -
  79.  
  80. -
  81.         // Generate SQL based on filter values
  82. -
  83.         $output .= $this->helper->dump($filter->sql()'Filter SQL'true);
  84. -
  85.  
  86. -
  87.         // Access filter values through preferences
  88. -
  89.         $output .= $this->helper->dump($preferences->get('foo''NOT SET')'Preference foo'true);
  90. -
  91.         $output .= $this->helper->dump($preferences->get('bar''NOT SET')'Preference bar'true);
  92. -
  93.         #### DEMO CODE ####
  94. -
  95.  
  96. -
  97.         return $this->output->heading('Demo of mr_filter_*').
  98. -
  99.                $this->helper->highlight(__CLASS____FUNCTION__true).
  100. -
  101.                $this->output->box($output'generalbox boxaligncenter boxwidthnormal');
  102. -
  103.     }
  104. -
  105. }
  106. -
-
+ + + + + + See how to use this class + + + + +

See how to use this class

+
+
+
    +
  1. +
    <?php
    +
  2. +
  3. +
    /**
    +
  4. +
  5. +
     * Filter controller
    +
  6. +
  7. +
     *
    +
  8. +
  9. +
     * @author Mark Nielsen +
    +
  10. +
  11. +
     * @version $Id$
    +
  12. +
  13. +
     * @package blocks/helloworld +
    +
  14. +
  15. +
     */
    +
  16. +
  17. +
     
    +
  18. +
  19. +
    defined('MOODLE_INTERNAL'or die('Direct access to this script is forbidden.');
    +
  20. +
  21. +
     
    +
  22. +
  23. +
    class block_helloworld_controller_filter extends mr_controller_block {
    +
  24. +
  25. +
        /**
    +
  26. +
  27. +
         * Default screen
    +
  28. +
  29. +
         *
    +
  30. +
  31. +
         * Demo of mr_filter et al +
    +
  32. +
  33. +
         */
    +
  34. +
  35. +
        public function view_action({ +
    +
  36. +
  37. +
            global $COURSE;
    +
  38. +
  39. +
     
    +
  40. +
  41. +
            #### DEMO CODE ####
    +
  42. +
  43. +
            // Filter values are stored here
    +
  44. +
  45. +
            $preferences new mr_preferences($COURSE->id'blocks/helloworld');
    +
  46. +
  47. +
     
    +
  48. +
  49. +
            // Create the filter "manager"
    +
  50. +
  51. +
            $filter new mr_html_filter($preferences$this->url);
    +
  52. +
  53. +
     
    +
  54. +
  55. +
            // Add a filter
    +
  56. +
  57. +
            $filter->add(new mr_html_filter_text('foo''Foo'));
    +
  58. +
  59. +
     
    +
  60. +
  61. +
            // Add the same filter, shortcut way +
    +
  62. +
  63. +
            $filter->new_text('bar''Bar'); +
    +
  64. +
  65. +
     
    +
  66. +
  67. +
            // You can chain these too (with add() as well) +
    +
  68. +
  69. +
            $filter->new_select('baz''Baz'array('0' => 'No''1' => 'Yes'))
    +
  70. +
  71. +
    +                ->new_daterange('bat''Bat');
    +
  72. +
  73. +
     
    +
  74. +
  75. +
            // Render the filter: This should be done  + before the print_header() - may redirect +
    +
  76. +
  77. +
            $output $this->mroutput->render($filter);
    +
  78. +
  79. +
     
    +
  80. +
  81. +
            // Generate SQL based on filter values +
    +
  82. +
  83. +
            $output .= $this->helper->dump($filter->sql()'Filter SQL'true);
    +
  84. +
  85. +
     
    +
  86. +
  87. +
            // Access filter values through preferences +
    +
  88. +
  89. +
            $output .= $this->helper->dump($preferences->get('foo''NOT SET')'Preference foo'true);
    +
  90. +
  91. +
            $output .= $this->helper->dump($preferences->get('bar''NOT SET')'Preference bar'true);
    +
  92. +
  93. +
            #### DEMO CODE ####
    +
  94. +
  95. +
     
    +
  96. +
  97. +
            return $this->output->heading('Demo of mr_filter_*').
    +
  98. +
  99. +
    +                $this->helper->highlight(__CLASS____FUNCTION__true).
    +
  100. +
  101. +
    +                $this->output->box($output'generalbox boxaligncenter boxwidthnormal');
    +
  102. +
  103. +
        }
    +
  104. +
  105. +
    }
    +
  106. +
+
+

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

- + + \ No newline at end of file diff --git a/docs/__examplesource/exsource_ule2-maint_blocks_helloworld_controller_plugin.php_f389601b3e05a1419f1535326d57dad1.html b/docs/__examplesource/exsource_ule2-maint_blocks_helloworld_controller_plugin.php_f389601b3e05a1419f1535326d57dad1.html index 95a52e5e..7224853b 100644 --- a/docs/__examplesource/exsource_ule2-maint_blocks_helloworld_controller_plugin.php_f389601b3e05a1419f1535326d57dad1.html +++ b/docs/__examplesource/exsource_ule2-maint_blocks_helloworld_controller_plugin.php_f389601b3e05a1419f1535326d57dad1.html @@ -1,77 +1,341 @@ - - - - - example - - - -

example

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Plugin controller
  6. -
  7.  *
  8. -
  9.  * @author Mark Nielsen
  10. -
  11.  * @version $Id$
  12. -
  13.  * @package blocks/helloworld
  14. -
  15.  */
  16. -
  17.  
  18. -
  19. defined('MOODLE_INTERNAL'or die('Direct access to this script is forbidden.');
  20. -
  21.  
  22. -
  23. class block_helloworld_controller_plugin extends mr_controller_block {
  24. -
  25.     /**
  26. -
  27.      * Default screen
  28. -
  29.      *
  30. -
  31.      * Demo of plugins
  32. -
  33.      */
  34. -
  35.     public function view_action({
  36. -
  37.         $this->print_header();
  38. -
  39.  
  40. -
  41.         echo $this->output->heading('Demo of mr_plugin and mr_helper_load');
  42. -
  43.         $this->helper->highlight(__CLASS____FUNCTION__);
  44. -
  45.         echo $this->output->box_start('generalbox boxaligncenter boxwidthnormal');
  46. -
  47.  
  48. -
  49.         #### DEMO CODE ####
  50. -
  51.         // Load all top-level plugins
  52. -
  53.         $result $this->helper->load->plugin();
  54. -
  55.         $this->helper->dump($result'load->plugin() result');
  56. -
  57.  
  58. -
  59.         // Load plugin 'one'
  60. -
  61.         $result $this->helper->load->plugin('one');
  62. -
  63.         $this->helper->dump($result'load->plugin(\'one\') result');
  64. -
  65.  
  66. -
  67.         // Inside of blocks/helloworld/plugin/one are more plugins which
  68. -
  69.         // resemble the Multiple plugin type layout.
  70. -
  71.  
  72. -
  73.         // All sub-plugins of plugin one
  74. -
  75.         $result $this->helper->load->plugin('one/*');
  76. -
  77.         $this->helper->dump($result'load->plugin(\'one/*\') result');
  78. -
  79.  
  80. -
  81.         // Load plugin 'one/aa'
  82. -
  83.         $result $this->helper->load->plugin('one/aa');
  84. -
  85.         $this->helper->dump($result'load->plugin(\'one/aa\') result');
  86. -
  87.  
  88. -
  89.         echo $this->output->heading('Example call to plugin methods:');
  90. -
  91.  
  92. -
  93.         foreach ($this->helper->load->plugin(as $name => $plugin{
  94. -
  95.             echo $this->output->heading("For plugin $name:");
  96. -
  97.             print_object('name(): '.$plugin->name());
  98. -
  99.             print_object('type(): '.$plugin->type());
  100. -
  101.             print_object('parent_method(): '.$plugin->parent_method());
  102. -
  103.             print_object('abstract_method(): '.$plugin->abstract_method());
  104. -
  105.         }
  106. -
  107.         #### DEMO CODE ####
  108. -
  109.  
  110. -
  111.         echo $this->output->box_end();
  112. -
  113.         $this->print_footer();
  114. -
  115.     }
  116. -
  117. }
  118. -
-
+ + + + + + example + + + + +

example

+
+
+
    +
  1. +
    <?php
    +
  2. +
  3. +
    /**
    +
  4. +
  5. +
     * Plugin controller
    +
  6. +
  7. +
     *
    +
  8. +
  9. +
     * @author Mark Nielsen +
    +
  10. +
  11. +
     * @version $Id$
    +
  12. +
  13. +
     * @package blocks/helloworld +
    +
  14. +
  15. +
     */
    +
  16. +
  17. +
     
    +
  18. +
  19. +
    defined('MOODLE_INTERNAL'or die('Direct access to this script is forbidden.');
    +
  20. +
  21. +
     
    +
  22. +
  23. +
    class block_helloworld_controller_plugin extends mr_controller_block {
    +
  24. +
  25. +
        /**
    +
  26. +
  27. +
         * Default screen
    +
  28. +
  29. +
         *
    +
  30. +
  31. +
         * Demo of plugins
    +
  32. +
  33. +
         */
    +
  34. +
  35. +
        public function view_action({ +
    +
  36. +
  37. +
            $this->print_header();
    +
  38. +
  39. +
     
    +
  40. +
  41. +
            echo $this->output->heading('Demo of mr_plugin and mr_helper_load');
    +
  42. +
  43. +
            $this->helper->highlight(__CLASS____FUNCTION__);
    +
  44. +
  45. +
            echo $this->output->box_start('generalbox boxaligncenter boxwidthnormal');
    +
  46. +
  47. +
     
    +
  48. +
  49. +
            #### DEMO CODE ####
    +
  50. +
  51. +
            // Load all top-level plugins
    +
  52. +
  53. +
            $result $this->helper->load->plugin();
    +
  54. +
  55. +
            $this->helper->dump($result'load->plugin() result');
    +
  56. +
  57. +
     
    +
  58. +
  59. +
            // Load plugin 'one'
    +
  60. +
  61. +
            $result $this->helper->load->plugin('one');
    +
  62. +
  63. +
            $this->helper->dump($result'load->plugin(\'one\') result');
    +
  64. +
  65. +
     
    +
  66. +
  67. +
            // Inside of blocks/helloworld/plugin/one are more plugins which +
    +
  68. +
  69. +
            // resemble the Multiple plugin type layout. +
    +
  70. +
  71. +
     
    +
  72. +
  73. +
            // All sub-plugins of plugin one
    +
  74. +
  75. +
            $result $this->helper->load->plugin('one/*');
    +
  76. +
  77. +
            $this->helper->dump($result'load->plugin(\'one/*\') result');
    +
  78. +
  79. +
     
    +
  80. +
  81. +
            // Load plugin 'one/aa'
    +
  82. +
  83. +
            $result $this->helper->load->plugin('one/aa');
    +
  84. +
  85. +
            $this->helper->dump($result'load->plugin(\'one/aa\') result');
    +
  86. +
  87. +
     
    +
  88. +
  89. +
            echo $this->output->heading('Example call to plugin methods:');
    +
  90. +
  91. +
     
    +
  92. +
  93. +
            foreach ($this->helper->load->plugin(as $name => $plugin{
    +
  94. +
  95. +
    +             echo $this->output->heading("For plugin $name:");
    +
  96. +
  97. +
                print_object('name(): '.$plugin->name());
    +
  98. +
  99. +
                print_object('type(): '.$plugin->type());
    +
  100. +
  101. +
                print_object('parent_method(): '.$plugin->parent_method());
    +
  102. +
  103. +
                print_object('abstract_method(): '.$plugin->abstract_method());
    +
  104. +
  105. +
            } +
    +
  106. +
  107. +
            #### DEMO CODE ####
    +
  108. +
  109. +
     
    +
  110. +
  111. +
            echo $this->output->box_end();
    +
  112. +
  113. +
            $this->print_footer();
    +
  114. +
  115. +
        }
    +
  116. +
  117. +
    }
    +
  118. +
+
+

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

- + + \ No newline at end of file diff --git a/docs/__examplesource/exsource_ule2-maint_blocks_helloworld_controller_report.php_d3d1ad1ba515d5bb293bcdd3739c3ad0.html b/docs/__examplesource/exsource_ule2-maint_blocks_helloworld_controller_report.php_d3d1ad1ba515d5bb293bcdd3739c3ad0.html index d6a16f61..ce9339b0 100644 --- a/docs/__examplesource/exsource_ule2-maint_blocks_helloworld_controller_report.php_d3d1ad1ba515d5bb293bcdd3739c3ad0.html +++ b/docs/__examplesource/exsource_ule2-maint_blocks_helloworld_controller_report.php_d3d1ad1ba515d5bb293bcdd3739c3ad0.html @@ -1,68 +1,271 @@ - - - - - See how to render this class - - - -

See how to render this class

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Report controller
  6. -
  7.  *
  8. -
  9.  * @author Mark Nielsen
  10. -
  11.  * @version $Id$
  12. -
  13.  * @package blocks/helloworld
  14. -
  15.  */
  16. -
  17.  
  18. -
  19. defined('MOODLE_INTERNAL'or die('Direct access to this script is forbidden.');
  20. -
  21.  
  22. -
  23. class block_helloworld_controller_report extends mr_controller_block {
  24. -
  25.     /**
  26. -
  27.      * Default screen
  28. -
  29.      */
  30. -
  31.     public function view_action({
  32. -
  33.         global $CFG$COURSE;
  34. -
  35.  
  36. -
  37.         #### DEMO CODE ####
  38. -
  39.         require_once($CFG->dirroot.'/blocks/helloworld/report/users.php');
  40. -
  41.  
  42. -
  43.         $report new blocks_helloworld_report_users($this->url$COURSE->id);
  44. -
  45.         $output $this->mroutput->render($report);
  46. -
  47.  
  48. -
  49.         // Alternative syntax...
  50. -
  51.         // $output = $this->mroutput->render(
  52. -
  53.         //     new blocks_helloworld_report_users($this->url, $COURSE->id)
  54. -
  55.         // );
  56. -
  57.         #### DEMO CODE ####
  58. -
  59.  
  60. -
  61.         return $this->output->heading('Demo of mr_report_abstract').
  62. -
  63.                $this->helper->highlight(__CLASS____FUNCTION__true).
  64. -
  65.                $output;
  66. -
  67.     }
  68. -
  69.  
  70. -
  71.     /**
  72. -
  73.      * Report JSON endpoint
  74. -
  75.      */
  76. -
  77.     public function autocomplete_action({
  78. -
  79.         global $DB;
  80. -
  81.  
  82. -
  83.         $query required_param('query'PARAM_TEXT);
  84. -
  85.  
  86. -
  87.         $json new stdClass;
  88. -
  89.         $json->results $DB->get_records_select('user''username LIKE ?'array("%$query%")'username''id, username AS text');
  90. -
  91.         $json->results array_values($json->results)// Makes proper JSON
  92. -
  93.         echo json_encode($json);
  94. -
  95.         die;
  96. -
  97.     }
  98. -
  99. }
  100. -
-
+ + + + + + See how to render this class + + + + +

See how to render this class

+
+
+
    +
  1. +
    <?php
    +
  2. +
  3. +
    /**
    +
  4. +
  5. +
     * Report controller
    +
  6. +
  7. +
     *
    +
  8. +
  9. +
     * @author Mark Nielsen +
    +
  10. +
  11. +
     * @version $Id$
    +
  12. +
  13. +
     * @package blocks/helloworld +
    +
  14. +
  15. +
     */
    +
  16. +
  17. +
     
    +
  18. +
  19. +
    defined('MOODLE_INTERNAL'or die('Direct access to this script is forbidden.');
    +
  20. +
  21. +
     
    +
  22. +
  23. +
    class block_helloworld_controller_report extends mr_controller_block {
    +
  24. +
  25. +
        /**
    +
  26. +
  27. +
         * Default screen
    +
  28. +
  29. +
         */
    +
  30. +
  31. +
        public function view_action({ +
    +
  32. +
  33. +
            global $CFG$COURSE;
    +
  34. +
  35. +
     
    +
  36. +
  37. +
            #### DEMO CODE ####
    +
  38. +
  39. +
            require_once($CFG->dirroot.'/blocks/helloworld/report/users.php');
    +
  40. +
  41. +
     
    +
  42. +
  43. +
            $report new blocks_helloworld_report_users($this->url$COURSE->id);
    +
  44. +
  45. +
            $output $this->mroutput->render($report);
    +
  46. +
  47. +
     
    +
  48. +
  49. +
            // Alternative syntax...
    +
  50. +
  51. +
            // $output = $this->mroutput->render(
    +
  52. +
  53. +
            //     new blocks_helloworld_report_users + ($this->url, $COURSE->id) +
    +
  54. +
  55. +
            // );
    +
  56. +
  57. +
            #### DEMO CODE ####
    +
  58. +
  59. +
     
    +
  60. +
  61. +
            return $this->output->heading('Demo of mr_report_abstract'). +
    +
  62. +
  63. +
    +                $this->helper->highlight(__CLASS____FUNCTION__true).
    +
  64. +
  65. +
    +                $output;
    +
  66. +
  67. +
        }
    +
  68. +
  69. +
     
    +
  70. +
  71. +
        /**
    +
  72. +
  73. +
         * Report JSON endpoint +
    +
  74. +
  75. +
         */
    +
  76. +
  77. +
        public function autocomplete_action({ +
    +
  78. +
  79. +
            global $DB;
    +
  80. +
  81. +
     
    +
  82. +
  83. +
            $query required_param('query'PARAM_TEXT);
    +
  84. +
  85. +
     
    +
  86. +
  87. +
            $json new stdClass;
    +
  88. +
  89. +
            $json->results $DB->get_records_select('user''username LIKE ?'array("%$query%")'username''id, username AS text');
    +
  90. +
  91. +
            $json->results array_values($json->results)// Makes proper JSON
    +
  92. +
  93. +
            echo json_encode($json); +
    +
  94. +
  95. +
            die;
    +
  96. +
  97. +
        }
    +
  98. +
  99. +
    }
    +
  100. +
+
+

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

- + + \ No newline at end of file diff --git a/docs/__examplesource/exsource_ule2-maint_blocks_helloworld_controller_server.php_a4df7da15f0287015b6305b4c2b86e1b.html b/docs/__examplesource/exsource_ule2-maint_blocks_helloworld_controller_server.php_a4df7da15f0287015b6305b4c2b86e1b.html index 707616c4..e75cc3d1 100644 --- a/docs/__examplesource/exsource_ule2-maint_blocks_helloworld_controller_server.php_a4df7da15f0287015b6305b4c2b86e1b.html +++ b/docs/__examplesource/exsource_ule2-maint_blocks_helloworld_controller_server.php_a4df7da15f0287015b6305b4c2b86e1b.html @@ -1,75 +1,328 @@ - - - - - Example client - - - -

Example client

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Server controller
  6. -
  7.  *
  8. -
  9.  * @author Mark Nielsen
  10. -
  11.  * @version $Id$
  12. -
  13.  * @package blocks/helloworld
  14. -
  15.  */
  16. -
  17.  
  18. -
  19. defined('MOODLE_INTERNAL'or die('Direct access to this script is forbidden.');
  20. -
  21.  
  22. -
  23. class block_helloworld_controller_server extends mr_controller_block {
  24. -
  25.     /**
  26. -
  27.      * Default screen
  28. -
  29.      *
  30. -
  31.      * Demo of mr_server_rest
  32. -
  33.      */
  34. -
  35.     public function view_action({
  36. -
  37.         global $CFG$DB;
  38. -
  39.  
  40. -
  41.         if (!$DB->record_exists('user'array('username' => 'administrator'))) {
  42. -
  43.             $this->notify->add_string('For the service to work correctly, please create a user with username/password = administrator');
  44. -
  45.         }
  46. -
  47.  
  48. -
  49.         #### DEMO CODE ####
  50. -
  51.         // Setup Zend
  52. -
  53.         mr_bootstrap::zend();
  54. -
  55.         require_once 'Zend/Rest/Client.php';
  56. -
  57.  
  58. -
  59.         // Lame-o
  60. -
  61.         $https str_replace('http''https'$CFG->wwwroot);
  62. -
  63.  
  64. -
  65.         // Create a new HTTP client
  66. -
  67.         $client  new Zend_Http_Client($https.'/blocks/helloworld/webservices.php');
  68. -
  69.  
  70. -
  71.         // Set the post parameters that we want
  72. -
  73.         $client->setParameterPost(array(
  74. -
  75.             'token'      => 'tokenvalue',      // Part of security requirements, pass a token
  76. -
  77.             'wsusername' => 'administrator',   // Part of security requirements, pass username
  78. -
  79.             'wspassword' => 'administrator',   // Part of security requirements, pass password
  80. -
  81.             'method'     => 'test',            // The service method to execute
  82. -
  83.             'say'        => 'Hello World!',    // The service parameter name
  84. -
  85.         ));
  86. -
  87.         // Send the request
  88. -
  89.         $response $client->request('POST');
  90. -
  91.         $request  $client->getLastRequest();
  92. -
  93.  
  94. -
  95.         // Dump the values
  96. -
  97.         $output  $this->helper->dump($request'The sent request'true);
  98. -
  99.         $output .= $this->helper->dump($response->getBody()'The returned response'true);
  100. -
  101.         #### DEMO CODE ####
  102. -
  103.  
  104. -
  105.         return $this->output->heading('Demo of mr_server_rest').
  106. -
  107.                $this->helper->highlight(__CLASS____FUNCTION__true).
  108. -
  109.                $this->output->box($output'generalbox boxaligncenter boxwidthnormal');
  110. -
  111.     }
  112. -
  113. }
  114. -
-
+ + + + + + Example client + + + + +

Example client

+
+
+
    +
  1. +
    <?php
    +
  2. +
  3. +
    /**
    +
  4. +
  5. +
     * Server controller
    +
  6. +
  7. +
     *
    +
  8. +
  9. +
     * @author Mark Nielsen +
    +
  10. +
  11. +
     * @version $Id$
    +
  12. +
  13. +
     * @package blocks/helloworld +
    +
  14. +
  15. +
     */
    +
  16. +
  17. +
     
    +
  18. +
  19. +
    defined('MOODLE_INTERNAL'or die('Direct access to this script is forbidden.');
    +
  20. +
  21. +
     
    +
  22. +
  23. +
    class block_helloworld_controller_server extends mr_controller_block {
    +
  24. +
  25. +
        /**
    +
  26. +
  27. +
         * Default screen
    +
  28. +
  29. +
         *
    +
  30. +
  31. +
         * Demo of mr_server_rest +
    +
  32. +
  33. +
         */
    +
  34. +
  35. +
        public function view_action({ +
    +
  36. +
  37. +
            global $CFG$DB; +
    +
  38. +
  39. +
     
    +
  40. +
  41. +
            if (!$DB->record_exists('user'array('username' => 'administrator'))) {
    +
  42. +
  43. +
                $this->notify->add_string('For the service to work correctly, please  + create a user with username/password = administrator');
    +
  44. +
  45. +
            } +
    +
  46. +
  47. +
     
    +
  48. +
  49. +
            #### DEMO CODE ####
    +
  50. +
  51. +
            // Setup Zend
    +
  52. +
  53. +
            mr_bootstrap::zend();
    +
  54. +
  55. +
            require_once 'Zend/Rest/Client.php';
    +
  56. +
  57. +
     
    +
  58. +
  59. +
            // Lame-o
    +
  60. +
  61. +
            $https str_replace('http''https'$CFG->wwwroot); +
    +
  62. +
  63. +
     
    +
  64. +
  65. +
            // Create a new HTTP client
    +
  66. +
  67. +
            $client  new Zend_Http_Client($https.'/blocks/helloworld/webservices.php');
    +
  68. +
  69. +
     
    +
  70. +
  71. +
            // Set the post parameters that we want +
    +
  72. +
  73. +
            $client->setParameterPost(array(
    +
  74. +
  75. +
                'token'      => 'tokenvalue',      // Part of security requirements, pass a token +
    +
  76. +
  77. +
                'wsusername' => 'administrator',   // Part of security requirements, pass username +
    +
  78. +
  79. +
                'wspassword' => 'administrator',   // Part of security requirements, pass password +
    +
  80. +
  81. +
                'method'     => 'test',            // The service method to execute
    +
  82. +
  83. +
                'say'        => 'Hello World!',    // The service parameter name
    +
  84. +
  85. +
            ));
    +
  86. +
  87. +
            // Send the request
    +
  88. +
  89. +
            $response $client->request('POST');
    +
  90. +
  91. +
            $request  $client->getLastRequest();
    +
  92. +
  93. +
     
    +
  94. +
  95. +
            // Dump the values
    +
  96. +
  97. +
            $output  $this->helper->dump($request'The sent request'true);
    +
  98. +
  99. +
            $output .= $this->helper->dump($response->getBody()'The returned response'true);
    +
  100. +
  101. +
            #### DEMO CODE ####
    +
  102. +
  103. +
     
    +
  104. +
  105. +
            return $this->output->heading('Demo of mr_server_rest').
    +
  106. +
  107. +
    +                $this->helper->highlight(__CLASS____FUNCTION__true).
    +
  108. +
  109. +
    +                $this->output->box($output'generalbox boxaligncenter boxwidthnormal');
    +
  110. +
  111. +
        }
    +
  112. +
  113. +
    }
    +
  114. +
+
+

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

- + + \ No newline at end of file diff --git a/docs/__examplesource/exsource_ule2-maint_blocks_helloworld_plugin_base_class.php_907d127b4229faab06ab733be81f51f8.html b/docs/__examplesource/exsource_ule2-maint_blocks_helloworld_plugin_base_class.php_907d127b4229faab06ab733be81f51f8.html index 7d5ec022..5f6dc917 100644 --- a/docs/__examplesource/exsource_ule2-maint_blocks_helloworld_plugin_base_class.php_907d127b4229faab06ab733be81f51f8.html +++ b/docs/__examplesource/exsource_ule2-maint_blocks_helloworld_plugin_base_class.php_907d127b4229faab06ab733be81f51f8.html @@ -1,67 +1,223 @@ - - - - - Base plugin class - - - -

Base plugin class

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Base plugin class
  6. -
  7.  *
  8. -
  9.  * @author Mark Nielsen
  10. -
  11.  */
  12. -
  13.  
  14. -
  15. defined('MOODLE_INTERNAL'or die('Direct access to this script is forbidden.');
  16. -
  17.  
  18. -
  19. require($CFG->dirroot.'/local/mr/bootstrap.php');
  20. -
  21.  
  22. -
  23. abstract class block_helloworld_plugin_base_class extends mr_plugin {
  24. -
  25.     /**
  26. -
  27.      * Helper
  28. -
  29.      *
  30. -
  31.      * @var mr_helper 
  32. -
  33.      */
  34. -
  35.     protected $helper;
  36. -
  37.  
  38. -
  39.     /**
  40. -
  41.      * Commonly you want to make helper readily available
  42. -
  43.      */
  44. -
  45.     public function __construct({
  46. -
  47.         $this->helper new mr_helper('blocks/helloworld');
  48. -
  49.     }
  50. -
  51.  
  52. -
  53.     /**
  54. -
  55.      * Implement abstract method of mr_plugin
  56. -
  57.      */
  58. -
  59.     public function get_component({
  60. -
  61.         return 'block_helloworld';
  62. -
  63.     }
  64. -
  65.  
  66. -
  67.     /**
  68. -
  69.      * Custom abstract method
  70. -
  71.      *
  72. -
  73.      * @return string 
  74. -
  75.      */
  76. -
  77.     abstract public function abstract_method();
  78. -
  79.  
  80. -
  81.     /**
  82. -
  83.      * Parent method
  84. -
  85.      *
  86. -
  87.      * @return string 
  88. -
  89.      */
  90. -
  91.     public function parent_method({
  92. -
  93.         return 'Parent method called';
  94. -
  95.     }
  96. -
  97. }
  98. -
-
+ + + + + + Base plugin class + + + + +

Base plugin class

+
+
+
    +
  1. +
    <?php
    +
  2. +
  3. +
    /**
    +
  4. +
  5. +
     * Base plugin class
    +
  6. +
  7. +
     *
    +
  8. +
  9. +
     * @author Mark Nielsen +
    +
  10. +
  11. +
     */
    +
  12. +
  13. +
     
    +
  14. +
  15. +
    defined('MOODLE_INTERNAL'or die('Direct access to this script is forbidden.');
    +
  16. +
  17. +
     
    +
  18. +
  19. +
    require($CFG->dirroot.'/local/mr/bootstrap.php');
    +
  20. +
  21. +
     
    +
  22. +
  23. +
    abstract class block_helloworld_plugin_base_class extends mr_plugin {
    +
  24. +
  25. +
        /**
    +
  26. +
  27. +
         * Helper
    +
  28. +
  29. +
         *
    +
  30. +
  31. +
         * @var mr_helper  +
    +
  32. +
  33. +
         */
    +
  34. +
  35. +
        protected $helper;
    +
  36. +
  37. +
     
    +
  38. +
  39. +
        /**
    +
  40. +
  41. +
         * Commonly you want  + to make helper readily available +
    +
  42. +
  43. +
         */
    +
  44. +
  45. +
        public function __construct({ +
    +
  46. +
  47. +
            $this->helper new mr_helper('blocks/helloworld');
    +
  48. +
  49. +
        }
    +
  50. +
  51. +
     
    +
  52. +
  53. +
        /**
    +
  54. +
  55. +
         * Implement abstract method of mr_plugin +
    +
  56. +
  57. +
         */
    +
  58. +
  59. +
        public function get_component({ +
    +
  60. +
  61. +
            return 'block_helloworld';
    +
  62. +
  63. +
        }
    +
  64. +
  65. +
     
    +
  66. +
  67. +
        /**
    +
  68. +
  69. +
         * Custom abstract method +
    +
  70. +
  71. +
         *
    +
  72. +
  73. +
         * @return string  +
    +
  74. +
  75. +
         */
    +
  76. +
  77. +
        abstract public function abstract_method();
    +
  78. +
  79. +
     
    +
  80. +
  81. +
        /**
    +
  82. +
  83. +
         * Parent method
    +
  84. +
  85. +
         *
    +
  86. +
  87. +
         * @return string  +
    +
  88. +
  89. +
         */
    +
  90. +
  91. +
        public function parent_method({ +
    +
  92. +
  93. +
            return 'Parent method called';
    +
  94. +
  95. +
        }
    +
  96. +
  97. +
    }
    +
  98. +
+
+

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

- + + \ No newline at end of file