Beispiel #1
0
 protected function _saveFile($tmpName, $name)
 {
     $ext = '.dat';
     if ($dotpos = strrpos($name, ".")) {
         $ext = strtolower(substr($name, $dotpos));
     }
     $fileName = false;
     if (!is_file($tmpName)) {
         return false;
     }
     //var_dump($this->_options);
     //var_dump($this->getControlSet()->getOptions());
     ///echo kanon::getBasePath().' ';
     //echo $this->_getPath().' ';
     $path = realpath(kanon::getBasePath() . '/' . $this->_getPath());
     if ($pk = $this->getItemPrimaryKey()) {
         $fileName = $path . '/' . $this->_filesPrefix . $pk . $ext;
     } else {
         return false;
     }
     if ($fileName == '') {
         $fileName = $this->_tempnam($path, $this->_filesPrefix, $ext);
     }
     if ($fileName) {
         //echo $fileName;
         //exit;
         if (copy($tmpName, $fileName)) {
             return basename($fileName);
         }
     }
     return false;
 }
 public function getPath()
 {
     if ($this->_path !== null) {
         return $this->_path;
     }
     return kanon::getBasePath() . '/' . (isset($this->_options['path']) ? $this->_options['path'] : '');
 }
Beispiel #3
0
 protected function _load()
 {
     if ($this->_isLoaded) {
         return;
     }
     static $types = array('model', 'modelProperty', 'controller', 'controlSet', 'control');
     $modulePath = kanon::getBasePath() . '/modules/' . $this->_name;
     if (is_file($modulePath . '/module.php') && is_php($modulePath . '/module.php')) {
         include $modulePath . '/module.php';
         $this->_autoload = $autoload;
         foreach ($this->_autoload as $class => $filename) {
             $classFilename = $modulePath . '/' . $filename;
             if (is_file($classFilename) && is_php($classFilename)) {
                 require_once $classFilename;
                 $type = '';
                 $r = new ReflectionClass($class);
                 foreach ($types as $checkType) {
                     if ($r->isSubclassOf($checkType)) {
                         $type = $checkType;
                     }
                 }
                 $this->_classes[$type][$class] = $filename;
             }
         }
     }
     $this->_isLoaded = true;
 }
Beispiel #4
0
 public static function run($applicationClass)
 {
     $app = self::getInstance($applicationClass);
     $app->setBasePath(kanon::getBasePath());
     $baseUrl = kanon::getBaseUri();
     //echo $baseUrl;
     $app->setBaseUri($baseUrl);
     $app->run();
 }
 public function moduleView($moduleName, $filename, $parameters, $uri = null)
 {
     $this->_view(kanon::getBasePath() . '/modules/' . $moduleName . '/views/' . $filename, $parameters, $uri);
 }
 /**
  * Formats a file path.
  *
  * @param  string  $file   An absolute file path
  * @param  integer $line   The line number
  * @param  string  $format The output format (txt or html)
  * @param  string  $text   Use this text for the link rather than the file path
  *
  * @return string
  */
 protected static function formatFile($file, $line, $format = 'html', $text = null)
 {
     if (null === $text) {
         $text = $file;
     }
     $linkFormat = 'rcp:%f';
     //?%l?0-0//C:\workspace\
     if ('html' === $format && $file && $line && $linkFormat) {
         $localFilename = str_replace(kanon::getBasePath(), '', $file);
         $text = $localFilename;
         $link = strtr($linkFormat, array('%f' => $localFilename, '%l' => $line));
         //$link = 'data:link/php;base64,'.base64_encode($localFilename);
         $text = sprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>', $link, $text);
     }
     return $text;
 }