コード例 #1
0
 public function load_resources($dir = NULL)
 {
     if ($dir === NULL) {
         $dir = $this->dir;
     }
     if (!$this->is_state_loading()) {
         // Load only once
         return;
     }
     try {
         // Look in directory for resources
         if (!is_dir($dir)) {
             CrayonLog::syslog('The resource directory is missing, should be at \'' . $dir . '\'.');
         } else {
             if (($handle = @opendir($dir)) != FALSE) {
                 // Loop over directory contents
                 while (($file = readdir($handle)) !== FALSE) {
                     if ($file != "." && $file != "..") {
                         // Check if $file is directory, remove extension when checking for existence.
                         if (!is_dir($dir . $file)) {
                             $file = CrayonUtil::path_rem_ext($file);
                         }
                         if ($this->exists($file)) {
                             $this->add_resource($this->resource_instance($file));
                         }
                     }
                 }
                 closedir($handle);
             }
         }
     } catch (Exception $e) {
         CrayonLog::syslog('An error occured when trying to load resources: ' . $e->getFile() . $e->getLine());
     }
 }