Пример #1
0
  function mkdir($dir, $perm=0777, $parents=true)
  {
    if(is_dir($dir))
      return;

    $dir = Fs :: normalizePath($dir);

    if(!$parents)
    {
      Fs :: _doMkdir($dir, $perm);
      return;
    }

    $separator = Fs :: separator();

    $path_elements = Fs :: explodePath($dir);

    if(count($path_elements) == 0)
      return;

    $index = Fs :: _getFirstExistingPathIndex($path_elements, $separator);

    if($index === false)
    {
      return throw_error(new IOException('cant find first existent path', array('dir' => $dir)));
    }

    $offset_path = '';
    for($i=0; $i < $index; $i++)
    {
      $offset_path .= $path_elements[$i] . $separator;
    }

    for($i=$index; $i < count($path_elements); $i++)
    {
      $offset_path .= $path_elements[$i] . $separator;
      Fs :: _doMkdir($offset_path, $perm);
    }
  }
Пример #2
0
  function testExplodeRelativePath()
  {
    $path = Fs :: explodePath('tmp\../tmp/wow////hey/');

    $this->assertEqual(sizeof($path), 3);

    $this->assertEqual($path[0], 'tmp');
    $this->assertEqual($path[1], 'wow');
    $this->assertEqual($path[2], 'hey');

    $path = Fs :: explodePath('tmp\../tmp/wow////hey'); // no trailing slash

    $this->assertEqual(sizeof($path), 3);

    $this->assertEqual($path[0], 'tmp');
    $this->assertEqual($path[1], 'wow');
    $this->assertEqual($path[2], 'hey');
  }
  protected function _generateDebugEditorLinkHtml($code, $file_path)
  {
    if(!defined('WS_SCRIPT_WRITTEN'))
    {

      $code->writeHtml('	<SCRIPT LANGUAGE="JScript">
                          function run_template_editor(path)
                          {
                            WS = new ActiveXObject("WScript.shell");
                            WS.exec("uedit32.exe " + path);
                          }
                          </SCRIPT>');

      define('WS_SCRIPT_WRITTEN', true);
    }

    if(Fs :: isPathRelative($file_path))
    {
      $items = Fs :: explodePath($_SERVER['PATH_TRANSLATED']);
      array_pop($items);

      $file_path = Fs :: path($items) . Fs :: separator() . $file_path;
    }

    $file_path = addslashes(Fs :: cleanPath($file_path));
    $code->writeHtml("<a href='#'><img onclick='runTemplateEditor(\"{$file_path}\");' src='/shared/images/i.gif' alt='{$file_path}' title='{$file_path}' border='0'></a>");
  }