original_string: protected function get_successor($type, $reference) {
  
          switch ($type) {
              case 'text':
              case 'html':
                  $name = 'page';
                  break;
              case 'directory':
                  $name = 'folder';
                  break;
              case 'ims':
                  $name = 'imscp';
                  break;
              case 'file':
                  // if starts with $@FILEPHP@$ then it is URL link to a local course file
                  // to be migrated to the new resource module
                  if (strpos($reference, '$@FILEPHP@$') === 0) {
                      $name = null;
                      break;
                  }
                  // if http:// https:// ftp:// OR starts with slash need to be converted to URL
                  if (strpos($reference, '://') or strpos($reference, '/') === 0) {
                      $name = 'url';
                  } else {
                      $name = null;
                  }
                  break;
              default:
                  throw new moodle1_convert_exception('unknown_resource_successor', $type);
          }
  
          if (is_null($name)) {
              return null;
          }
  
          if (!isset($this->successors[$name])) {
              $this->log('preparing resource successor handler', backup::LOG_DEBUG, $name);
              $class = 'moodle1_mod_'.$name.'_handler';
              $this->successors[$name] = new $class($this->converter, 'mod', $name);
  
              // add the successor into the modlist stash
              $modnames = $this->converter->get_stash('modnameslist');
              $modnames[] = $name;
              $modnames = array_unique($modnames); // should not be needed but just in case
              $this->converter->set_stash('modnameslist', $modnames);
  
              // add the successor's modinfo stash
              $modinfo = $this->converter->get_stash('modinfo_resource');
              $modinfo['name'] = $name;
              $modinfo['instances'] = array();
              $this->converter->set_stash('modinfo_'.$name, $modinfo);
          }
  
          return $this->successors[$name];
       }
code: protected function get_successor($type, $reference) {
  
          switch ($type) {
              case 'text':
              case 'html':
                  $name = 'page';
                  break;
              case 'directory':
                  $name = 'folder';
                  break;
              case 'ims':
                  $name = 'imscp';
                  break;
              case 'file':
                  // if starts with $@FILEPHP@$ then it is URL link to a local course file
                  // to be migrated to the new resource module
                  if (strpos($reference, '$@FILEPHP@$') === 0) {
                      $name = null;
                      break;
                  }
                  // if http:// https:// ftp:// OR starts with slash need to be converted to URL
                  if (strpos($reference, '://') or strpos($reference, '/') === 0) {
                      $name = 'url';
                  } else {
                      $name = null;
                  }
                  break;
              default:
                  throw new moodle1_convert_exception('unknown_resource_successor', $type);
          }
  
          if (is_null($name)) {
              return null;
          }
  
          if (!isset($this->successors[$name])) {
              $this->log('preparing resource successor handler', backup::LOG_DEBUG, $name);
              $class = 'moodle1_mod_'.$name.'_handler';
              $this->successors[$name] = new $class($this->converter, 'mod', $name);
  
              // add the successor into the modlist stash
              $modnames = $this->converter->get_stash('modnameslist');
              $modnames[] = $name;
              $modnames = array_unique($modnames); // should not be needed but just in case
              $this->converter->set_stash('modnameslist', $modnames);
  
              // add the successor's modinfo stash
              $modinfo = $this->converter->get_stash('modinfo_resource');
              $modinfo['name'] = $name;
              $modinfo['instances'] = array();
              $this->converter->set_stash('modinfo_'.$name, $modinfo);
          }
  
          return $this->successors[$name];
       }
code_tokens: protected function get_successor ( $ type , $ reference ) { switch ( $ type ) { case 'text' : case 'html' : $ name = 'page' ; break ; case 'directory' : $ name = 'folder' ; break ; case 'ims' : $ name = 'imscp' ; break ; case 'file' : // if starts with $@FILEPHP@$ then it is URL link to a local course file // to be migrated to the new resource module if ( strpos ( $ reference , '$@FILEPHP@$' ) === 0 ) { $ name = null ; break ; } // if http:// https:// ftp:// OR starts with slash need to be converted to URL if ( strpos ( $ reference , '://' ) or strpos ( $ reference , '/' ) === 0 ) { $ name = 'url' ; } else { $ name = null ; } break ; default : throw new moodle1_convert_exception ( 'unknown_resource_successor' , $ type ) ; } if ( is_null ( $ name ) ) { return null ; } if ( ! isset ( $ this -> successors [ $ name ] ) ) { $ this -> log ( 'preparing resource successor handler' , backup :: LOG_DEBUG , $ name ) ; $ class = 'moodle1_mod_' . $ name . '_handler' ; $ this -> successors [ $ name ] = new $ class ( $ this -> converter , 'mod' , $ name ) ; // add the successor into the modlist stash $ modnames = $ this -> converter -> get_stash ( 'modnameslist' ) ; $ modnames [ ] = $ name ; $ modnames = array_unique ( $ modnames ) ; // should not be needed but just in case $ this -> converter -> set_stash ( 'modnameslist' , $ modnames ) ; // add the successor's modinfo stash $ modinfo = $ this -> converter -> get_stash ( 'modinfo_resource' ) ; $ modinfo [ 'name' ] = $ name ; $ modinfo [ 'instances' ] = array ( ) ; $ this -> converter -> set_stash ( 'modinfo_' . $ name , $ modinfo ) ; } return $ this -> successors [ $ name ] ; }
docstring: Returns the handler of the new 2.0 mod type according the given type of the legacy 1.9 resource
  
  @param string $type the value of the 'type' field in 1.9 resource
  @param string $reference a file path. Necessary to differentiate files from web URLs
  @throws moodle1_convert_exception for the unknown types
  @return null|moodle1_mod_handler the instance of the handler, or null if the type does not have a successor
docstring_tokens: Returns the handler of the new 2 . 0 mod type according the given type of the legacy 1 . 9 resource