]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-16029 Added $extralocations in the function print_error; merged from MOODLE_19_STABLE
authorskodak <skodak>
Mon, 1 Sep 2008 15:31:09 +0000 (15:31 +0000)
committerskodak <skodak>
Mon, 1 Sep 2008 15:31:09 +0000 (15:31 +0000)
lib/deprecatedlib.php
lib/setuplib.php
lib/weblib.php

index a0d3062ab9f85d6d5f6f4edbdfafc173ba591311..c6db193133583c809e0d7f86c7f21563bb8ec8e7 100644 (file)
@@ -573,7 +573,7 @@ function error($message, $link='') {
         throw new moodle_exception('notlocalisederrormessage', 'error', $link, $message);
     }
 
-    _print_normal_error('notlocalisederrormessage', 'error', $message, $link, debug_backtrace(), null, true); // show debug warning
+    _print_normal_error('notlocalisederrormessage', 'error', $message, $link, debug_backtrace(), null, null, true); // show debug warning
 }
 
 
index 73bb67abcdf071d081e39d865af19a8ea3050b37..289b5589444d71fcd8f8c9cfbd1fbcf70898c312 100644 (file)
@@ -18,6 +18,7 @@ class moodle_exception extends Exception {
     public $a;
     public $link;
     public $debuginfo;
+    public $extralocations;
 
     /**
      * Constructor
@@ -26,19 +27,25 @@ class moodle_exception extends Exception {
      * @param string $link The url where the user will be prompted to continue. If no url is provided the user will be directed to the site index page.
      * @param object $a Extra words and phrases that might be required in the error string
      * @param string $debuginfo optional debugging information
+     * @param array $extralocations An array of strings with other locations to look for string files
      */
-    function __construct($errorcode, $module='', $link='', $a=NULL, $debuginfo=null) {
-        if (empty($module) || $module == 'moodle' || $module == 'core') {
+    function __construct($errorcode, $module='error', $link='', $a=NULL, $debuginfo=null, $extralocations=null) {
+        if (empty($module) || $module === 'moodle' || $module === 'core') {
             $module = 'error';
         }
 
-        $this->errorcode = $errorcode;
-        $this->module    = $module;
-        $this->link      = $link;
-        $this->a         = $a;
-        $this->debuginfo = $debuginfo;
-
-        $message = get_string($errorcode, $module, $a);
+        $this->errorcode      = $errorcode;
+        $this->module         = $module;
+        $this->link           = $link;
+        $this->a              = $a;
+        $this->debuginfo      = $debuginfo;
+        $this->extralocations = $extralocations;
+
+        $message = get_string($errorcode, $module, $a, $extralocations);
+        if ($module === 'error' and strpos($message, '[[') === 0) {
+            //search in moodle file if error specified - needed for backwards compatibility
+            $message = get_string($errorcode, 'moodle', $a, $extralocations);
+        }
 
         parent::__construct($message, 0);
     }
@@ -53,7 +60,7 @@ function default_exception_handler($ex) {
     array_unshift($backtrace, $place);
 
     if ($ex instanceof moodle_exception) {
-        _print_normal_error($ex->errorcode, $ex->module, $ex->a, $ex->link, $backtrace, $ex->debuginfo);
+        _print_normal_error($ex->errorcode, $ex->module, $ex->a, $ex->link, $backtrace, $ex->debuginfo, $ex->extralocations);
     } else {
         _print_normal_error('generalexceptionmessage', 'error', $ex->getMessage(), '', $backtrace);
     }
index 0f6ca41bdd0200044b56ee573545d8c6db9748ec..97b62182b97890e8ed7d80f5d002c9ee0e0dfdfd 100644 (file)
@@ -5546,9 +5546,10 @@ function print_scale_menu_helpbutton($courseid, $scale, $return=false) {
  * @param string $module name of module
  * @param string $link The url where the user will be prompted to continue. If no url is provided the user will be directed to the site index page.
  * @param object $a Extra words and phrases that might be required in the error string
+ * @param array $extralocations An array of strings with other locations to look for string files
  * @return terminates script, does not return!
  */
-function print_error($errorcode, $module='error', $link='', $a=NULL) {
+function print_error($errorcode, $module='error', $link='', $a=NULL, $extralocations=NULL) {
     global $CFG, $UNITTEST;
 
     // If unittest running, throw exception instead
@@ -5564,16 +5565,16 @@ function print_error($errorcode, $module='error', $link='', $a=NULL) {
 
     if (!isset($CFG->theme) or !isset($CFG->stylesheets)) {
         // error found before setup.php finished
-        _print_early_error($errorcode, $module, $a);
+        _print_early_error($errorcode, $module, $a, $extralocations);
     } else {
-        _print_normal_error($errorcode, $module, $a, $link, debug_backtrace());
+        _print_normal_error($errorcode, $module, $a, $link, debug_backtrace(), null, $extralocations);
     }
 }
 
 /**
  * Internal function - do not use directly!!
  */
-function _print_normal_error($errorcode, $module, $a, $link, $backtrace, $debuginfo=null, $showerrordebugwarning=false) {
+function _print_normal_error($errorcode, $module, $a, $link, $backtrace, $debuginfo=null, $extralocations=null, $showerrordebugwarning=false) {
     global $CFG, $SESSION, $THEME, $DB;
 
     if ($DB) {
@@ -5587,10 +5588,10 @@ function _print_normal_error($errorcode, $module, $a, $link, $backtrace, $debugi
         $modulelink = $module;
     }
 
-    $message = get_string($errorcode, $module, $a);
+    $message = get_string($errorcode, $module, $a, $extralocations);
     if ($module === 'error' and strpos($message, '[[') === 0) {
         //search in moodle file if error specified - needed for backwards compatibility
-        $message = get_string($errorcode, 'moodle', $a);
+        $message = get_string($errorcode, 'moodle', $a, $extralocations);
     }
 
     if (defined('FULLME') && FULLME == 'cron') {
@@ -5667,11 +5668,11 @@ function _print_normal_error($errorcode, $module, $a, $link, $backtrace, $debugi
  * Internal function - do not use directly!!
  * This function is used if fatal error occures before the themes are fully initialised (eg. in lib/setup.php)
  */
-function _print_early_error($errorcode, $module, $a) {
-    $message = get_string($errorcode, $module, $a);
+function _print_early_error($errorcode, $module, $a, $extralocations=NULL) {
+    $message = get_string($errorcode, $module, $a, $extralocations);
     if ($module === 'error' and strpos($message, '[[') === 0) {
         //search in moodle file if error specified - needed for backwards compatibility
-        $message = get_string($errorcode, 'moodle', $a);
+        $message = get_string($errorcode, 'moodle', $a, $extralocations);
     }
     $message = clean_text($message);