当前位置: 首页>>代码示例>>PHP>>正文


PHP Kohana::debug_path方法代码示例

本文整理汇总了PHP中Kohana::debug_path方法的典型用法代码示例。如果您正苦于以下问题:PHP Kohana::debug_path方法的具体用法?PHP Kohana::debug_path怎么用?PHP Kohana::debug_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Kohana的用法示例。


在下文中一共展示了Kohana::debug_path方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save

 /**
  * Save an uploaded file to a new location. If no filename is provided,
  * the original filename will be used, with a unique prefix added.
  *
  * This method should be used after validating the $_FILES array:
  *
  *     if ($array->check())
  *     {
  *         // Upload is valid, save it
  *         Upload::save($_FILES['file']);
  *     }
  *
  * @param   array    uploaded file data
  * @param   string   new filename
  * @param   string   new directory
  * @param   integer  chmod mask
  * @return  string   on success, full path to new file
  * @return  FALSE    on failure
  */
 public static function save(array $file, $filename = NULL, $directory = NULL, $chmod = 0644)
 {
     if (!isset($file['tmp_name']) or !is_uploaded_file($file['tmp_name'])) {
         // Ignore corrupted uploads
         return FALSE;
     }
     if ($filename === NULL) {
         // Use the default filename, with a timestamp pre-pended
         $filename = uniqid() . $file['name'];
     }
     if (Upload::$remove_spaces === TRUE) {
         // Remove spaces from the filename
         $filename = preg_replace('/\\s+/', '_', $filename);
     }
     if ($directory === NULL) {
         // Use the pre-configured upload directory
         $directory = Upload::$default_directory;
     }
     if (!is_dir($directory) or !is_writable(realpath($directory))) {
         throw new Kohana_Exception('Directory :dir must be writable', array(':dir' => Kohana::debug_path($directory)));
     }
     // Make the filename into a complete path
     $filename = realpath($directory) . DIRECTORY_SEPARATOR . $filename;
     if (move_uploaded_file($file['tmp_name'], $filename)) {
         if ($chmod !== FALSE) {
             // Set permissions on filename
             chmod($filename, $chmod);
         }
         // Return new file path
         return $filename;
     }
     return FALSE;
 }
开发者ID:azuya,项目名称:Wi3,代码行数:52,代码来源:upload.php

示例2: __construct

 public function __construct($directory)
 {
     if (!is_dir($directory) or !is_writable($directory)) {
         throw new Kohana_Exception('Directory :dir must be writable', array(':dir' => Kohana::debug_path($directory)));
     }
     // Determine the directory path
     $this->_directory = realpath($directory) . DIRECTORY_SEPARATOR;
 }
开发者ID:Burgestrand,项目名称:koxtend,代码行数:8,代码来源:exception.php

示例3: __construct

 /**
  * Creates a new file logger.
  *
  * @param   string  log directory
  * @param   array   list of excluded types
  * @return  void
  */
 public function __construct($directory, array $config = NULL)
 {
     if (!is_dir($directory) or !is_writable($directory)) {
         throw new Kohana_Exception('Directory :dir must be writable', array(':dir' => Kohana::debug_path($directory)));
     }
     // Determine the directory path
     $this->_directory = realpath($directory) . DIRECTORY_SEPARATOR;
     $firephp = FirePHP_Profiler::instance();
     if (isset($config)) {
         $firephp->set_config($config);
     }
     $this->_format = $firephp->get_config('log.file.format', 'time --- type: body');
     $this->_excluded = $firephp->get_config('log.file.exclude');
 }
开发者ID:hkilter,项目名称:OpenSupplyChains,代码行数:21,代码来源:file.php

示例4: download

 /**
  * Download a file to a new location. If no filename is provided,
  * the original filename will be used, with a unique prefix added.
  *
  * @param   string   remote url
  * @param   string   new filename
  * @param   string   new directory
  * @param   integer  chmod mask
  * @return  array    on success, upload style file array
  * @return  false    on failure
  */
 public static function download($url, $filename = NULL, $directory = NULL, $chmod = 0644)
 {
     if (!Valid::url($url)) {
         return false;
     }
     // If no filename given, use remote filename with uniqid
     $original_filename = basename(parse_url($url, PHP_URL_PATH));
     if ($filename === null) {
         $filename = uniqid() . $original_filename;
     }
     // Remove spaces from the filename
     if (Upload::$remove_spaces === true) {
         $filename = preg_replace('/\\s+/', '_', $filename);
     }
     // Use the pre-configured upload directory if not given
     if ($directory === null) {
         $directory = Upload::$default_directory;
     }
     if (!is_dir($directory) || !is_writable(realpath($directory))) {
         throw new Kohana_Exception('Directory :dir must be writable', array(':dir' => Kohana::debug_path($directory)));
     }
     // Make the filename into a complete path
     $filename = realpath($directory) . DIRECTORY_SEPARATOR . $filename;
     // Download file
     try {
         // Dummy escape to get rid of spaces to awoid 400 Bad Request
         $url = str_replace(' ', '%20', $url);
         $fh = fopen($filename, 'w');
         Remote::get($url, null, array(CURLOPT_RETURNTRANSFER => true, CURLOPT_FILE => $fh));
         $size = Arr::get(fstat($fh), 'size', 0);
         fclose($fh);
         // Set permissions
         if ($chmod !== false) {
             chmod($filename, $chmod);
         }
         // Build file array
         $finfo = finfo_open(FILEINFO_MIME_TYPE);
         $mime = finfo_file($finfo, $filename);
         finfo_close($finfo);
         return array('error' => UPLOAD_ERR_OK, 'name' => $original_filename, 'type' => $mime, 'tmp_name' => $filename, 'size' => $size);
     } catch (Kohana_Exception $e) {
         return false;
     }
 }
开发者ID:anqh,项目名称:core,代码行数:55,代码来源:remote.php

示例5: generate

 public function generate($filename)
 {
     // Progress controller file
     $files = explode('/', $filename);
     $files_count = count($files);
     // Progress controller directory
     $directory = NULL;
     if ($files_count > 1) {
         // progress controller name
         for ($i = 0; $i < $files_count; $i++) {
             if ($i != $files_count - 1) {
                 $directory .= $files[$i] . DIRECTORY_SEPARATOR;
             }
         }
         $filename = $files[$files_count - 1];
     }
     // Set the name of the controller path
     $directory = $this->config->apppath . Terminal::VIEWPATH . $directory;
     if (!is_dir($directory)) {
         // Create the yearly directory
         mkdir($directory, 0777, TRUE);
         // Set permissions (must be manually set to fix umask issues)
         chmod($directory, 0777);
     }
     // Set the name of the log file
     $filename = $directory . $filename . EXT;
     if (!file_exists($filename)) {
         // Create the controller file
         file_put_contents($filename, Kohana::FILE_SECURITY . PHP_EOL);
         // Allow anyone to write to controller files
         chmod($filename, 0666);
         $result = Terminal::color('create', 'green');
     } else {
         $result = Terminal::color('exist', 'blue');
     }
     $result = '    ' . $result . '  ' . Kohana::debug_path($filename);
     echo $result . PHP_EOL;
 }
开发者ID:jaroslawziolkowski,项目名称:kohana-cli,代码行数:38,代码来源:view.php

示例6: testDebugPath

 /**
  * Tests Kohana::debug_path()
  *
  * @test
  * @dataProvider provider_debug_path
  * @covers Kohana::debug_path
  * @param boolean $path     Input for Kohana::debug_path
  * @param boolean $expected Output for Kohana::debug_path
  */
 public function testDebugPath($path, $expected)
 {
     $this->assertEquals($expected, Kohana::debug_path($path));
 }
开发者ID:Tidwell,项目名称:HMXSongs-PHP-API,代码行数:13,代码来源:CoreTest.php

示例7: exception_handler

 /**
  * Inline exception handler, displays the error message, source of the
  * exception, and the stack trace of the error.
  *
  * @param   object   exception object
  * @return  boolean
  */
 public static function exception_handler(Exception $e)
 {
     try {
         // Get the exception information
         $type = get_class($e);
         $code = $e->getCode();
         $message = $e->getMessage();
         $file = $e->getFile();
         $line = $e->getLine();
         // Set the text version of the exception
         $text = "{$type} [ {$code} ]: {$message} " . self::debug_path($file) . " [ {$line} ]";
         // Add this exception to the log
         self::$log->add(Kohana::ERROR, $text);
         if (Kohana::$is_cli) {
             // Just display the text of the exception
             echo "\n{$text}\n";
             return TRUE;
         }
         // Get the exception backtrace
         $trace = $e->getTrace();
         if ($e instanceof ErrorException and version_compare(PHP_VERSION, '5.3', '<')) {
             // Work around for a bug in ErrorException::getTrace() that exists in
             // all PHP 5.2 versions. @see http://bugs.php.net/bug.php?id=45895
             for ($i = count($trace) - 1; $i > 0; --$i) {
                 if (isset($trace[$i - 1]['args'])) {
                     // Re-position the args
                     $trace[$i]['args'] = $trace[$i - 1]['args'];
                     // Remove the args
                     unset($trace[$i - 1]['args']);
                 }
             }
         }
         // Get the source of the error
         $source = self::debug_source($file, $line);
         // Generate a new error id
         $error_id = uniqid();
         // Start an output buffer
         ob_start();
         // Include the exception HTML
         include self::find_file('views', 'kohana/error');
         // Display the contents of the output buffer
         echo ob_get_clean();
         return TRUE;
     } catch (Exception $e) {
         // Clean the output buffer if one exists
         ob_get_level() and ob_clean();
         // This can happen when the kohana error view has a PHP error
         echo $e->getMessage(), ' [ ', Kohana::debug_path($e->getFile()), ', ', $e->getLine(), ' ]';
         // Exit with an error status
         exit(1);
     }
 }
开发者ID:ukd1,项目名称:kohana,代码行数:59,代码来源:kohana.php

示例8: generate

 public function generate($filename, $extends = NULL)
 {
     // Progress controller file
     $files = explode('/', $filename);
     $files_count = count($files);
     // Progress controller directory
     $model = array('Model');
     $directory = NULL;
     if ($files_count > 1) {
         // progress controller name
         for ($i = 0; $i < $files_count; $i++) {
             $model[] = $this->_format_name($files[$i]);
             if ($i != $files_count - 1) {
                 $directory .= $files[$i] . DIRECTORY_SEPARATOR;
             }
         }
         $filename = $files[$files_count - 1];
     } else {
         $model[] = $this->_format_name($filename);
     }
     // Set the name of controller file
     $model = implode('_', $model);
     // Set controller extends
     if ($extends) {
         $parent = strtolower($extends);
         switch ($parent) {
             case 'orm':
                 $parent = strtoupper($parent);
             default:
                 $parent = ucfirst($parent);
         }
         $extends = $parent;
     } else {
         $extends = 'Model';
     }
     // Set the name of the controller path
     $directory = $this->config->apppath . Terminal::MODELPATH . $directory;
     if (!is_dir($directory)) {
         // Create the yearly directory
         mkdir($directory, 0777, TRUE);
         // Set permissions (must be manually set to fix umask issues)
         chmod($directory, 0777);
     }
     // Set the name of the log file
     $filename = $directory . $filename . EXT;
     if (!file_exists($filename)) {
         // Create the controller file
         file_put_contents($filename, Kohana::FILE_SECURITY . PHP_EOL);
         // Allow anyone to write to controller files
         chmod($filename, 0666);
         // Continute to write
         file_put_contents($filename, PHP_EOL . 'class ' . ucfirst($model) . ' extends ' . $extends . ' {', FILE_APPEND);
         file_put_contents($filename, PHP_EOL . PHP_EOL . '}' . PHP_EOL . PHP_EOL, FILE_APPEND);
         $result = Terminal::color('create', 'green');
     } else {
         $result = Terminal::color('exist', 'blue');
     }
     $result = '    ' . $result . '  ' . Kohana::debug_path($filename);
     echo $result . PHP_EOL;
 }
开发者ID:jaroslawziolkowski,项目名称:kohana-cli,代码行数:60,代码来源:model.php

示例9:

== content default from
<?php 
echo Kohana::debug_path(__FILE__);
开发者ID:samkeen,项目名称:spot,代码行数:3,代码来源:content_default.php

示例10: exception_text

 /**
  * Get a single line of text representing the exception:
  *
  * Error [ Code ]: Message ~ File [ Line ]
  *
  * @param   object  Exception
  * @return  string
  */
 public static function exception_text(Exception $e)
 {
     return sprintf('%s [ %s ]: %s ~ %s [ %d ]', get_class($e), $e->getCode(), strip_tags($e->getMessage()), Kohana::debug_path($e->getFile()), $e->getLine());
 }
开发者ID:ascseb,项目名称:core,代码行数:12,代码来源:core.php

示例11: __toString

 /**
  * Magic method, returns the output of render(). If any exceptions are
  * thrown, the exception output will be returned instead.
  *
  * @return  string
  */
 public function __toString()
 {
     try {
         return $this->render();
     } catch (Exception $e) {
         return (string) $e->getMessage() . ' in ' . Kohana::debug_path($e->getFile()) . ' [ ' . $e->getLine() . ' ]';
     }
 }
开发者ID:ukd1,项目名称:kohana,代码行数:14,代码来源:view.php

示例12: get_info

 /**
  * Get and return file info
  *
  * @param   string	path to file
  * @throws  Kohana_Exception
  * @return  object  file info
  */
 protected function get_info($file)
 {
     try {
         // Get the real path to the file
         $file = realpath($file);
         // Get the image information
         $info = getimagesize($file);
     } catch (Exception $e) {
         // Ignore all errors while reading the image
     }
     if (empty($file) or empty($info)) {
         throw new Kohana_Exception('Not an image or invalid image: :file', array(':file' => Kohana::debug_path($file)));
     }
     $return = new stdClass();
     $return->file = $file;
     $return->width = $info[0];
     $return->height = $info[1];
     $return->type = $info[2];
     $return->mime = image_type_to_mime_type($return->type);
     return $return;
 }
开发者ID:2bj,项目名称:kohana-imagemagick-driver,代码行数:28,代码来源:imagemagick.php

示例13: elseif

					<?php 
            } elseif ($result instanceof Exception) {
                ?>

						<td class="k-error">
							<strong><?php 
                echo __('Error');
                ?>
</strong><br/>
							<p><?php 
                echo $result->getMessage();
                ?>
</p>
							<div><?php 
                echo Kohana::debug_path($result->getFile());
                ?>
 [ <?php 
                echo $result->getLine();
                ?>
 ]</div>
							<pre class="source"><code><?php 
                echo Kohana::debug_source($result->getFile(), $result->getLine());
                ?>
</code></pre>
						</td>

					<?php 
            }
            ?>
开发者ID:banks,项目名称:unittest,代码行数:29,代码来源:html.php

示例14: _dump

 /**
  * Helper for Kohana::dump(), handles recursion in arrays and objects.
  *
  * @param   mixed    variable to dump
  * @param   integer  maximum length of strings
  * @param   integer  recursion level (internal)
  * @return  string
  */
 protected static function _dump(&$var, $length = 128, $level = 0)
 {
     if ($var === NULL) {
         return '<small>NULL</small>';
     } elseif (is_bool($var)) {
         return '<small>bool</small> ' . ($var ? 'TRUE' : 'FALSE');
     } elseif (is_float($var)) {
         return '<small>float</small> ' . $var;
     } elseif (is_resource($var)) {
         if (($type = get_resource_type($var)) === 'stream' and $meta = stream_get_meta_data($var)) {
             $meta = stream_get_meta_data($var);
             if (isset($meta['uri'])) {
                 $file = $meta['uri'];
                 if (function_exists('stream_is_local')) {
                     // Only exists on PHP >= 5.2.4
                     if (stream_is_local($file)) {
                         $file = Kohana::debug_path($file);
                     }
                 }
                 return '<small>resource</small><span>(' . $type . ')</span> ' . htmlspecialchars($file, ENT_NOQUOTES, Kohana::$charset);
             }
         } else {
             return '<small>resource</small><span>(' . $type . ')</span>';
         }
     } elseif (is_string($var)) {
         if (UTF8::strlen($var) > $length) {
             // Encode the truncated string
             $str = htmlspecialchars(UTF8::substr($var, 0, $length), ENT_NOQUOTES, Kohana::$charset) . '&nbsp;&hellip;';
         } else {
             // Encode the string
             $str = htmlspecialchars($var, ENT_NOQUOTES, Kohana::$charset);
         }
         return '<small>string</small><span>(' . strlen($var) . ')</span> "' . $str . '"';
     } elseif (is_array($var)) {
         $output = array();
         // Indentation for this variable
         $space = str_repeat($s = '    ', $level);
         static $marker;
         if ($marker === NULL) {
             // Make a unique marker
             $marker = uniqid("");
         }
         if (empty($var)) {
             // Do nothing
         } elseif (isset($var[$marker])) {
             $output[] = "(\n{$space}{$s}*RECURSION*\n{$space})";
         } elseif ($level < 5) {
             $output[] = "<span>(";
             $var[$marker] = TRUE;
             foreach ($var as $key => &$val) {
                 if ($key === $marker) {
                     continue;
                 }
                 if (!is_int($key)) {
                     $key = '"' . htmlspecialchars($key, ENT_NOQUOTES, self::$charset) . '"';
                 }
                 $output[] = "{$space}{$s}{$key} => " . Kohana::_dump($val, $length, $level + 1);
             }
             unset($var[$marker]);
             $output[] = "{$space})</span>";
         } else {
             // Depth too great
             $output[] = "(\n{$space}{$s}...\n{$space})";
         }
         return '<small>array</small><span>(' . count($var) . ')</span> ' . implode("\n", $output);
     } elseif (is_object($var)) {
         // Copy the object as an array
         $array = (array) $var;
         $output = array();
         // Indentation for this variable
         $space = str_repeat($s = '    ', $level);
         $hash = spl_object_hash($var);
         // Objects that are being dumped
         static $objects = array();
         if (empty($var)) {
             // Do nothing
         } elseif (isset($objects[$hash])) {
             $output[] = "{\n{$space}{$s}*RECURSION*\n{$space}}";
         } elseif ($level < 10) {
             $output[] = "<code>{";
             $objects[$hash] = TRUE;
             foreach ($array as $key => &$val) {
                 if ($key[0] === "") {
                     // Determine if the access is protected or protected
                     $access = '<small>' . ($key[1] === '*' ? 'protected' : 'private') . '</small>';
                     // Remove the access level from the variable name
                     $key = substr($key, strrpos($key, "") + 1);
                 } else {
                     $access = '<small>public</small>';
                 }
                 $output[] = "{$space}{$s}{$access} {$key} => " . Kohana::_dump($val, $length, $level + 1);
             }
//.........这里部分代码省略.........
开发者ID:abdul-baten,项目名称:hbcms,代码行数:101,代码来源:core.php

示例15: if

<?php echo $doc->description ?>

<?php if ($doc->tags): ?>
<dl class="tags">
<?php foreach ($doc->tags as $name => $set): ?>
<dt><?php echo $name ?></dt>
<?php foreach ($set as $tag): ?>
<dd><?php echo $tag ?></dd>
<?php endforeach ?>
<?php endforeach ?>
</dl>
<?php endif; ?>

<p class="note">
<?php if ($path = $doc->class->getFilename()): ?>
Class declared in <tt><?php echo Kohana::debug_path($path) ?></tt> on line <?php echo $doc->class->getStartLine() ?>.
<?php else: ?>
Class is not declared in a file, it is probably an internal <?php echo html::anchor('http://php.net/manual/class.'.strtolower($doc->class->name).'.php', 'PHP class') ?>.
<?php endif ?>
</p>

<div class="toc">
	<div class="constants">
		<h3><?php echo __('Constants'); ?></h3>
		<ul>
		<?php if ($doc->constants): ?>
		<?php foreach ($doc->constants as $name => $value): ?>
			<li><a href="#constant:<?php echo $name ?>"><?php echo $name ?></a></li>
		<?php endforeach ?>
		<?php else: ?>
			<li><em><?php echo __('None'); ?></em></li>
开发者ID:nevermlnd,项目名称:cv,代码行数:31,代码来源:class.php


注:本文中的Kohana::debug_path方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。