Example #1
0
 /**
  * A very powerful function, this is basically used to refer to a file that
  * resides somewhere in the /System/ server directory that can be imported
  * via any HTTP method such as HTML, Javascript, CSS etc etc etc.
  * 
  * e.g.
  * echo '<script type="text/javascript" src="'.new File('C:\www\root\System\Templates\MyTemplate\scripts\test.js')->getAsHTTPPath().'"></script>';
  * 
  * Yes, it's that easy.
  */
 public function getAsHTTPPath()
 {
     //First, confirm $this is within the system dir.
     $my_path = $this->getPath();
     $main_path = File::getDocumentRoot()->getPath();
     //if(!startsWith($my_path, File::getDocumentRoot()->getPath())) throw new Exception('File must be in the System Directory'); TODO: Fix
     //Now we need to first remove the main dir
     $my_path = str_replace($main_path, '', $my_path);
     //Now Escape HTTP slashes
     $my_path = str_replace('\\', '/', $my_path);
     //And return with the '/System/' dir
     return $my_path;
 }