original_string: public static function get_template_directories_for_component($component, $themename = '') {
          global $CFG, $PAGE;
  
          // Default the param.
          if ($themename == '') {
              $themename = $PAGE->theme->name;
          }
  
          // Clean params for safety.
          $component = clean_param($component, PARAM_COMPONENT);
          $themename = clean_param($themename, PARAM_COMPONENT);
  
          // Validate the component.
          $dirs = array();
          $compdirectory = core_component::get_component_directory($component);
          if (!$compdirectory) {
              throw new coding_exception("Component was not valid: " . s($component));
          }
  
          // Find the parent themes.
          $parents = array();
          if ($themename === $PAGE->theme->name) {
              $parents = $PAGE->theme->parents;
          } else {
              $themeconfig = theme_config::load($themename);
              $parents = $themeconfig->parents;
          }
  
          // First check the theme.
          $dirs[] = $CFG->dirroot . '/theme/' . $themename . '/templates/' . $component . '/';
          if (isset($CFG->themedir)) {
              $dirs[] = $CFG->themedir . '/' . $themename . '/templates/' . $component . '/';
          }
          // Now check the parent themes.
          // Search each of the parent themes second.
          foreach ($parents as $parent) {
              $dirs[] = $CFG->dirroot . '/theme/' . $parent . '/templates/' . $component . '/';
              if (isset($CFG->themedir)) {
                  $dirs[] = $CFG->themedir . '/' . $parent . '/templates/' . $component . '/';
              }
          }
  
          $dirs[] = $compdirectory . '/templates/';
  
          return $dirs;
      }
code: public static function get_template_directories_for_component($component, $themename = '') {
          global $CFG, $PAGE;
  
          // Default the param.
          if ($themename == '') {
              $themename = $PAGE->theme->name;
          }
  
          // Clean params for safety.
          $component = clean_param($component, PARAM_COMPONENT);
          $themename = clean_param($themename, PARAM_COMPONENT);
  
          // Validate the component.
          $dirs = array();
          $compdirectory = core_component::get_component_directory($component);
          if (!$compdirectory) {
              throw new coding_exception("Component was not valid: " . s($component));
          }
  
          // Find the parent themes.
          $parents = array();
          if ($themename === $PAGE->theme->name) {
              $parents = $PAGE->theme->parents;
          } else {
              $themeconfig = theme_config::load($themename);
              $parents = $themeconfig->parents;
          }
  
          // First check the theme.
          $dirs[] = $CFG->dirroot . '/theme/' . $themename . '/templates/' . $component . '/';
          if (isset($CFG->themedir)) {
              $dirs[] = $CFG->themedir . '/' . $themename . '/templates/' . $component . '/';
          }
          // Now check the parent themes.
          // Search each of the parent themes second.
          foreach ($parents as $parent) {
              $dirs[] = $CFG->dirroot . '/theme/' . $parent . '/templates/' . $component . '/';
              if (isset($CFG->themedir)) {
                  $dirs[] = $CFG->themedir . '/' . $parent . '/templates/' . $component . '/';
              }
          }
  
          $dirs[] = $compdirectory . '/templates/';
  
          return $dirs;
      }
code_tokens: public static function get_template_directories_for_component ( $ component , $ themename = '' ) { global $ CFG , $ PAGE ; // Default the param. if ( $ themename == '' ) { $ themename = $ PAGE -> theme -> name ; } // Clean params for safety. $ component = clean_param ( $ component , PARAM_COMPONENT ) ; $ themename = clean_param ( $ themename , PARAM_COMPONENT ) ; // Validate the component. $ dirs = array ( ) ; $ compdirectory = core_component :: get_component_directory ( $ component ) ; if ( ! $ compdirectory ) { throw new coding_exception ( "Component was not valid: " . s ( $ component ) ) ; } // Find the parent themes. $ parents = array ( ) ; if ( $ themename === $ PAGE -> theme -> name ) { $ parents = $ PAGE -> theme -> parents ; } else { $ themeconfig = theme_config :: load ( $ themename ) ; $ parents = $ themeconfig -> parents ; } // First check the theme. $ dirs [ ] = $ CFG -> dirroot . '/theme/' . $ themename . '/templates/' . $ component . '/' ; if ( isset ( $ CFG -> themedir ) ) { $ dirs [ ] = $ CFG -> themedir . '/' . $ themename . '/templates/' . $ component . '/' ; } // Now check the parent themes. // Search each of the parent themes second. foreach ( $ parents as $ parent ) { $ dirs [ ] = $ CFG -> dirroot . '/theme/' . $ parent . '/templates/' . $ component . '/' ; if ( isset ( $ CFG -> themedir ) ) { $ dirs [ ] = $ CFG -> themedir . '/' . $ parent . '/templates/' . $ component . '/' ; } } $ dirs [ ] = $ compdirectory . '/templates/' ; return $ dirs ; }
docstring: Helper function for getting a list of valid template directories for a specific component.
  
  @param string $component The component to search
  @param string $themename The current theme name
  @return string[] List of valid directories for templates for this compoonent. Directories are not checked for existence.
docstring_tokens: Helper function for getting a list of valid template directories for a specific component .