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


PHP Fuel类代码示例

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


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

示例1: load

	public static function load($file, $group = null)
	{
		$lang = array();

		// Use the current language, failing that use the fallback language
		foreach (array(\Config::get('language'), static::$fallback) as $language)
		{
			if ($path = \Fuel::find_file('lang/'.$language, $file, '.php', true))
			{
				$lang = array();
				foreach ($path as $p)
				{
					$lang = $lang + \Fuel::load($p);
				}
				break;
			}
		}

		if ($group === null)
		{
			static::$lines = static::$lines + $lang;
		}
		else
		{
			if ( ! isset(static::$lines[$group]))
			{
				static::$lines[$group] = array();
			}
			static::$lines[$group] = static::$lines[$group] + $lang;
		}
	}
开发者ID:nasumi,项目名称:fuel,代码行数:31,代码来源:lang.php

示例2: wire

 /**
  * Get or inject a ProcessWire API variable
  *
  * 1. As a getter (option 1):
  * ==========================
  * Usage: $this->wire('name'); // name is an API variable name
  * If 'name' does not exist, a WireException will be thrown.
  * Specify '*' or 'all' for name to retrieve all API vars (as a Fuel object)
  *
  * 2. As a getter (option 2):
  * ==========================
  * Usage: $this->wire()->name; // name is an API variable name
  * Null will be returned if API var does not exist (no Exception thrown).
  *
  * 3. As a setter:
  * ===============
  * $this->wire('name', $value);
  * $this->wire('name', $value, true); // lock the API variable so nothing else can overwrite it
  * $this->wire()->set('name', $value);
  * $this->wire()->set('name', $value, true); // lock the API variable so nothing else can overwrite it
  *
  * 4. As a dependency injector (PW 3.0 only)
  * =========================================
  * $this->wire(new Page());
  * When creating a new object, this makes it inject the current PW instance into that object.
  *
  * @param string|object $name Name of API variable to retrieve, set, or omit to retrieve the master ProcessWire object
  * @param null|mixed $value Value to set if using this as a setter, otherwise omit.
  * @param bool $lock When using as a setter, specify true if you want to lock the value from future changes (default=false)
  * @return ProcessWire|Wire|Session|Page|Pages|Modules|User|Users|Roles|Permissions|Templates|Fields|Fieldtypes|Sanitizer|Config|Notices|WireDatabasePDO|WireInput|string|mixed
  * @throws WireException
  *
  *
  */
 public function wire($name = '', $value = null, $lock = false)
 {
     if (is_null(self::$fuel)) {
         self::$fuel = new Fuel();
     }
     if ($value !== null) {
         // setting a fuel value
         return self::$fuel->set($name, $value, $lock);
     }
     if (empty($name)) {
         // return ProcessWire instance
         return self::$fuel->wire;
     } else {
         if ($name === '*' || $name === 'all') {
             // return Fuel instance
             return self::$fuel;
         }
     }
     /* TBA PW3
     		if(is_object($name)) {
     			// injecting ProcessWire instance to object
     			if($name instanceof Wire) return $name->setWire($this->_wire); // inject fuel, PW 3.0 
     			throw new WireException("Expected Wire instance");
     		}
     		*/
     // get API variable
     $value = self::$fuel->{$name};
     return $value;
 }
开发者ID:ryancramerdesign,项目名称:ProcessWire,代码行数:63,代码来源:Wire.php

示例3: inspect

    /**
     * Quick and nice way to output a mixed variable to the browser
     *
     * @static
     * @access	public
     * @return	string
     */
    public static function inspect()
    {
        $backtrace = debug_backtrace();
        // If being called from within, show the file above in the backtrack
        if (strpos($backtrace[0]['file'], 'core/classes/debug.php') !== FALSE) {
            $callee = $backtrace[1];
            $label = \Inflector::humanize($backtrace[1]['function']);
        } else {
            $callee = $backtrace[0];
            $label = 'Debug';
        }
        $arguments = func_get_args();
        $total_arguments = count($arguments);
        $callee['file'] = \Fuel::clean_path($callee['file']);
        if (!static::$js_displayed) {
            echo <<<JS
<script type="text/javascript">function fuel_debug_toggle(a){if(document.getElementById){if(document.getElementById(a).style.display=="none"){document.getElementById(a).style.display="block"}else{document.getElementById(a).style.display="none"}}else{if(document.layers){if(document.id.display=="none"){document.id.display="block"}else{document.id.display="none"}}else{if(document.all.id.style.display=="none"){document.all.id.style.display="block"}else{document.all.id.style.display="none"}}}};</script>
JS;
            static::$js_displayed = true;
        }
        echo '<div style="font-size: 13px;background: #EEE !important; border:1px solid #666; color: #000 !important; padding:10px;">';
        echo '<h1 style="border-bottom: 1px solid #CCC; padding: 0 0 5px 0; margin: 0 0 5px 0; font: bold 120% sans-serif;">' . $callee['file'] . ' @ line: ' . $callee['line'] . '</h1>';
        echo '<pre style="overflow:auto;font-size:100%;">';
        $i = 0;
        foreach ($arguments as $argument) {
            echo '<strong>' . $label . ' #' . ++$i . ' of ' . $total_arguments . '</strong>:<br />';
            echo static::format('...', $argument);
            echo '<br />';
        }
        echo "</pre>";
        echo "</div>";
    }
开发者ID:quickpacket,项目名称:noclayer,代码行数:39,代码来源:debug.php

示例4: get

 /**
  * Gets a dot-notated key from an array, with a default value if it does
  * not exist.
  *
  * @param   array   $array    The search array
  * @param   mixed   $key      The dot-notated key or array of keys
  * @param   string  $default  The default value
  * @return  mixed
  */
 public static function get($array, $key, $default = null)
 {
     if (!is_array($array) and !$array instanceof \ArrayAccess) {
         throw new \InvalidArgumentException('First parameter must be an array or ArrayAccess object.');
     }
     if (is_null($key)) {
         return $array;
     }
     if (is_array($key)) {
         $return = array();
         foreach ($key as $k) {
             $return[$k] = static::get($array, $k, $default);
         }
         return $return;
     }
     foreach (explode('.', $key) as $key_part) {
         if (($array instanceof \ArrayAccess and isset($array[$key_part])) === false) {
             if (!is_array($array) or !array_key_exists($key_part, $array)) {
                 return \Fuel::value($default);
             }
         }
         $array = $array[$key_part];
     }
     return $array;
 }
开发者ID:quickpacket,项目名称:noclayer,代码行数:34,代码来源:arr.php

示例5: save

    public static function save($file, $config)
    {
        if (!is_array($config)) {
            if (!isset(static::$items[$config])) {
                return false;
            }
            $config = static::$items[$config];
        }
        $content = <<<CONF
<?php
/**
 * Fuel
 *
 * Fuel is a fast, lightweight, community driven PHP5 framework.
 *
 * @package\t\tFuel
 * @version\t\t1.0
 * @author\t\tFuel Development Team
 * @license\t\tMIT License
 * @copyright\t2011 Fuel Development Team
 * @link\t\thttp://fuelphp.com
 */


CONF;
        $content .= 'return ' . str_replace('  ', "\t", var_export($config, true)) . ';';
        $content .= <<<CONF


/* End of file {$file}.php */
CONF;
        $path = \Fuel::find_file('config', $file, '.php') or $path[0] = APPPATH . 'config' . DS . $file . '.php';
        $path = pathinfo($path[0]);
        return File::update($path['dirname'], $path['basename'], $content);
    }
开发者ID:bryanheo,项目名称:FuelPHP-Auth-AJAX,代码行数:35,代码来源:config.php

示例6: run

 public static function run($task, $args)
 {
     // Make sure something is set
     if ($task === null or $task === 'help') {
         static::help();
         return;
     }
     // Just call and run() or did they have a specific method in mind?
     list($task, $method) = array_pad(explode(':', $task), 2, 'run');
     $task = ucfirst(strtolower($task));
     // Find the task
     if (!($file = \Fuel::find_file('tasks', $task))) {
         throw new Exception(sprintf('Task "%s" does not exist.', $task));
         return;
     }
     require $file;
     $task = '\\Fuel\\Tasks\\' . $task;
     $new_task = new $task();
     // The help option hs been called, so call help instead
     if (\Cli::option('help') && is_callable(array($new_task, 'help'))) {
         $method = 'help';
     }
     if ($return = call_user_func_array(array($new_task, $method), $args)) {
         \Cli::write($return);
     }
 }
开发者ID:huglester,项目名称:fuel-uploadify,代码行数:26,代码来源:refine.php

示例7: config

    public static function config($args, $build = true)
    {
        $args = self::_clear_args($args);
        $file = strtolower(array_shift($args));
        $config = array();
        // load the config
        if ($paths = \Finder::search('config', $file, '.php', true)) {
            // Reverse the file list so that we load the core configs first and
            // the app can override anything.
            $paths = array_reverse($paths);
            foreach ($paths as $path) {
                $config = \Fuel::load($path) + $config;
            }
        }
        unset($path);
        // We always pass in fields to a config, so lets sort them out here.
        foreach ($args as $conf) {
            // Each paramater for a config is seperated by the : character
            $parts = explode(":", $conf);
            // We must have the 'name:value' if nothing else!
            if (count($parts) >= 2) {
                $config[$parts[0]] = $parts[1];
            }
        }
        $overwrite = \Cli::option('o') or \Cli::option('overwrite');
        $content = <<<CONF
<?php
/**
 * Fuel is a fast, lightweight, community driven PHP5 framework.
 *
 * @package\t\tFuel
 * @version\t\t1.0
 * @author\t\tFuel Development Team
 * @license\t\tMIT License
 * @copyright\t2011 Fuel Development Team
 * @link\t\thttp://fuelphp.com
 */


CONF;
        $content .= 'return ' . str_replace('  ', "\t", var_export($config, true)) . ';';
        $content .= <<<CONF


/* End of file {$file}.php */
CONF;
        $path = APPPATH . 'config' . DS . $file . '.php';
        if (!$overwrite and is_file($path)) {
            throw new Exception("APPPATH/config/{$file}.php already exist, please use -overwrite option to force update");
        }
        $path = pathinfo($path);
        try {
            \File::update($path['dirname'], $path['basename'], $content);
            \Cli::write("Created config: APPPATH/config/{$file}.php", 'green');
        } catch (\InvalidPathException $e) {
            throw new Exception("Invalid basepath, cannot update at " . APPPATH . "config" . DS . "{$file}.php");
        } catch (\FileAccessException $e) {
            throw new Exception(APPPATH . "config" . DS . $file . ".php could not be written.");
        }
    }
开发者ID:reganhimself,项目名称:KeeleProgrammers,代码行数:60,代码来源:generate.php

示例8: init

 public static function init($args)
 {
     try {
         if (!isset($args[1])) {
             static::help();
             return;
         }
         switch ($args[1]) {
             case 'g':
             case 'generate':
                 switch ($args[2]) {
                     case 'controller':
                     case 'model':
                     case 'view':
                     case 'views':
                     case 'migration':
                         call_user_func('Oil\\Generate::' . $args[2], array_slice($args, 3));
                         break;
                     case 'scaffold':
                         call_user_func('Oil\\Scaffold::generate', array_slice($args, 3));
                         break;
                     default:
                         Generate::help();
                 }
                 break;
             case 'c':
             case 'console':
                 new Console();
             case 'r':
             case 'refine':
                 $task = isset($args[2]) ? $args[2] : null;
                 call_user_func('Oil\\Refine::run', $task, array_slice($args, 3));
                 break;
             case 'p':
             case 'package':
                 switch ($args[2]) {
                     case 'install':
                     case 'uninstall':
                         call_user_func_array('Oil\\Package::' . $args[2], array_slice($args, 3));
                         break;
                     default:
                         Package::help();
                 }
                 break;
             case '-v':
             case '--version':
                 \Cli::write('Fuel: ' . \Fuel::VERSION);
                 break;
             case 'test':
                 \Fuel::add_package('octane');
                 call_user_func('\\Fuel\\Octane\\Tests::run_' . $args[2], array_slice($args, 3));
                 break;
             default:
                 static::help();
         }
     } catch (Exception $e) {
         \Cli::write(\Cli::color('Error: ' . $e->getMessage(), 'light_red'));
         \Cli::beep();
     }
 }
开发者ID:netspencer,项目名称:fuel,代码行数:60,代码来源:cli.php

示例9: option

 /**
  * Returns the option with the given name.	You can also give the option
  * number.
  *
  * Named options must be in the following formats:
  * php index.php user -v --v -name=John --name=John
  *
  * @param	string|int	$name	the name of the option (int if unnamed)
  * @return	string
  */
 public static function option($name, $default = null)
 {
     if (!isset(static::$args[$name])) {
         return \Fuel::value($default);
     }
     return static::$args[$name];
 }
开发者ID:quickpacket,项目名称:noclayer,代码行数:17,代码来源:cli.php

示例10: get

 /**
  * Get stencil data.
  *
  * @return  mixed   returns the array or string on success or false on failure
  */
 public static function get($stencil_name, $key = null)
 {
     $stencil_path = STENCILSPATH . $stencil_name . DS . 'config.php';
     if (!File::file_exists($stencil_path)) {
         return false;
     }
     if (!($stencil_data = \Fuel::load($stencil_path))) {
         return false;
     }
     // return value if key found
     if (isset($key)) {
         if (isset($stencil_data[$key])) {
             return $stencil_data[$key];
         } else {
             return false;
         }
     }
     // build inflections replacement array
     $tbl_singular = Table::get('crud.TBL_SINGULAR');
     $tbl_plural = Table::get('crud.TBL_PLURAL');
     if ($tbl_prefix = Table::get('crud.TBL_PREFIX')) {
         $pfx_path = str_replace('_', DS, $tbl_prefix);
         $tbl_singular = str_replace($tbl_prefix, $pfx_path, $tbl_singular);
         $tbl_plural = str_replace($tbl_prefix, $pfx_path, $tbl_plural);
     }
     $inflections = array(':SINGULAR' => $tbl_singular, ':PLURAL' => $tbl_plural);
     // make the replacements
     foreach ($stencil_data['files'] as $key => $value) {
         $stencil_data['files'][$key]['output_path'] = str_replace(array_keys($inflections), array_values($inflections), $value['output_path']);
     }
     return $stencil_data;
 }
开发者ID:niceboy120,项目名称:crude,代码行数:37,代码来源:stencil.php

示例11: load

 /**
  * Loads the given package.  If a path is not given, then PKGPATH is used.
  * It also accepts an array of packages as the first parameter.
  *
  * @param   string|array  $package  The package name or array of packages.
  * @param   string|null   $path     The path to the package
  * @return  bool  True on success
  * @throws  PackageNotFoundException
  */
 public static function load($package, $path = null)
 {
     if (is_array($package)) {
         foreach ($package as $pkg) {
             $path = null;
             if (is_array($pkg)) {
                 list($pkg, $path) = $pkg;
             }
             static::load($pkg, $path);
         }
         return false;
     }
     if (static::loaded($package)) {
         return;
     }
     // Load it from PKGPATH if no path was given.
     if ($path === null) {
         $path = PKGPATH . $package . DS;
     }
     if (!is_dir($path)) {
         throw new \PackageNotFoundException("Package '{$package}' could not be found at '" . \Fuel::clean_path($path) . "'");
     }
     \Finder::instance()->add_path($path, 1);
     \Fuel::load($path . 'bootstrap.php');
     static::$packages[$package] = $path;
     return true;
 }
开发者ID:quickpacket,项目名称:noclayer,代码行数:36,代码来源:package.php

示例12: run

	public static function run($task, $args)
	{
		// Just call and run() or did they have a specific method in mind?
		list($task, $method)=array_pad(explode(':', $task), 2, 'run');

		$task = ucfirst(strtolower($task));

		if ( ! $file = \Fuel::find_file('tasks', $task))
		{
			throw new \Exception('Well that didnt work...');
			return;
		}

		require $file;

		$task = '\\Fuel\\Tasks\\'.$task;

		$new_task = new $task;

		// The help option hs been called, so call help instead
		if (\Cli::option('help') && is_callable(array($new_task, 'help')))
		{
			$method = 'help';
		}

		if ($return = call_user_func_array(array($new_task, $method), $args))
		{
			\Cli::write($return);
		}
	}
开发者ID:nasumi,项目名称:fuel,代码行数:30,代码来源:refine.php

示例13: load

 /**
  * Loads the given package.
  * If a path is not given, if will search through
  * the defined package_paths. If not defined, then PKGPATH is used.
  * It also accepts an array of packages as the first parameter.
  *
  * @param string|array $package
  *        	The package name or array of packages.
  * @param string|null $path
  *        	The path to the package
  * @return bool True on success
  * @throws PackageNotFoundException
  */
 public static function load($package, $path = null)
 {
     if (is_array($package)) {
         foreach ($package as $pkg => $path) {
             if (is_numeric($pkg)) {
                 $pkg = $path;
                 $path = null;
             }
             static::load($pkg, $path);
         }
         return false;
     }
     if (static::loaded($package)) {
         return;
     }
     // if no path is given, try to locate the package
     if ($path === null) {
         $paths = \Config::get('package_paths', array());
         empty($paths) and $paths = array(PKGPATH);
         if (!empty($paths)) {
             foreach ($paths as $modpath) {
                 if (is_dir($path = $modpath . strtolower($package) . DS)) {
                     break;
                 }
             }
         }
     }
     if (!is_dir($path)) {
         throw new \PackageNotFoundException("Package '{$package}' could not be found at '" . \Fuel::clean_path($path) . "'");
     }
     \Finder::instance()->add_path($path, 1);
     \Fuel::load($path . 'bootstrap.php');
     static::$packages[$package] = $path;
     return true;
 }
开发者ID:vienbk91,项目名称:fuelphp17,代码行数:48,代码来源:package.php

示例14: forge

 /**
  * {@inheritdoc}
  */
 public static function forge($instance = 'default', array $handlers = array())
 {
     $logger = new Monolog\Logger($instance);
     $handlers = \Arr::merge(\Config::get('logger.' . $instance, array()), $handlers);
     foreach ($handlers as $handler) {
         $handler = \Fuel::value($handler);
         $logger->pushHandler($handler);
     }
     return static::newInstance($instance, $logger);
 }
开发者ID:indigophp,项目名称:fuel-core,代码行数:13,代码来源:Logger.php

示例15: to

 /**
  * passes the data to the template and returns the result
  *
  * @param 	string 	$template_file	the template file used to structure the data
  * @return 	array	the restructured data
  */
 public function to($template)
 {
     $template_folder = \Config::get('structure.templates_folder');
     $template_path = \Fuel::find_file($template_folder, $template);
     if (!$template_path) {
         throw new \Fuel_Exception('The requested template could not be found: ' . \Fuel::clean_path($file));
     }
     $data = static::capture($template_path, $this->_data);
     return static::capture($template_path, $this->_data);
 }
开发者ID:JaapRood,项目名称:fuel-structure,代码行数:16,代码来源:structure.php


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