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


PHP Wire::getFuel方法代码示例

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


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

示例1: __

/**
 * Perform a language translation
 * 
 * @param string $text Text for translation. 
 * @param string $textdomain Textdomain for the text, may be class name, filename, or something made up by you. If ommitted, a debug backtrace will attempt to determine it automatically.
 * @param string $context Name of context - DO NOT USE with this function for translation as it won't be parsed for translation. Use only with the _x() function, which will be parsed. 
 * @return string Translated text or original text if translation not available.
 *
 *
 */
function __($text, $textdomain = null, $context = '')
{
    if (!Wire::getFuel('languages')) {
        return $text;
    }
    if (!($language = Wire::getFuel('user')->language)) {
        return $text;
    }
    if (!$language->id) {
        return $text;
    }
    if (is_null($textdomain)) {
        $traces = @debug_backtrace(defined('DEBUG_BACKTRACE_IGNORE_ARGS') ? DEBUG_BACKTRACE_IGNORE_ARGS : false);
        if (isset($traces[0]) && $traces[0]['file'] != __FILE__) {
            $textdomain = $traces[0]['file'];
        } else {
            if (isset($traces[1]) && $traces[1]['file'] != __FILE__) {
                $textdomain = $traces[1]['file'];
            }
        }
        if (is_null($textdomain)) {
            $textdomain = 'site';
        }
    }
    return htmlspecialchars($language->translator()->getTranslation($textdomain, $text, $context), ENT_QUOTES, 'UTF-8');
}
开发者ID:rzelnik,项目名称:ProcessWire,代码行数:36,代码来源:LanguageFunctions.php

示例2: fuel

/**
 * Return all Fuel, or specified ProcessWire API variable, or NULL if it doesn't exist.
 *
 * Same as Wire::getFuel($name) and Wire::getAllFuel();
 * When a $name is specified, this function is identical to the wire() function.
 * Both functions exist more for consistent naming depending on usage. 
 *
 * @param string $name If ommitted, returns a Fuel object with references to all the fuel.
 * @return mixed Fuel value if available, NULL if not. 
 *
 */
function fuel($name = '')
{
    if (!$name) {
        return Wire::getAllFuel();
    }
    return Wire::getFuel($name);
}
开发者ID:ryancramerdesign,项目名称:ProcessWire-2.0,代码行数:18,代码来源:Functions.php

示例3: __

/**
 * Perform a language translation
 *
 * If no context provided then a global context is assumed
 *
 */
function __($context, $text = null)
{
    if (is_null($text)) {
        $text = $context;
        $context = null;
    }
    if (!Wire::getFuel('languages')) {
        return $text;
    }
    if (!($language = Wire::getFuel('user')->language)) {
        return $text;
    }
    return $language->translator()->getTranslation($context, $text);
}
开发者ID:nicolasleon,项目名称:P21,代码行数:20,代码来源:Functions.php

示例4: save

 /**
  * Save the template to database
  *
  * @return $this|bool Returns Template if successful, or false if not
  *
  */
 public function save()
 {
     $result = Wire::getFuel('templates')->save($this);
     return $result ? $this : false;
 }
开发者ID:gusdecool,项目名称:bunga-wire,代码行数:11,代码来源:Template.php

示例5: _getDot

 /**
  * Get a property via dot syntax: field.subfield (static)
  *
  * Static version for internal core use. Use the non-static getDot() instead.
  *
  * @param string $key 
  * @param Wire $from The instance you want to pull the value from
  * @return null|mixed Returns value if found or null if not
  *
  */
 public static function _getDot($key, Wire $from)
 {
     $key = trim($key, '.');
     if (strpos($key, '.')) {
         // dot present
         $keys = explode('.', $key);
         // convert to array
         $key = array_shift($keys);
         // get first item
     } else {
         // dot not present
         $keys = array();
     }
     if (Wire::getFuel($key) !== null) {
         return null;
     }
     // don't allow API vars to be retrieved this way
     if ($from instanceof WireData) {
         $value = $from->get($key);
     } else {
         if ($from instanceof WireArray) {
             $value = $from->getProperty($key);
         } else {
             $value = $from->{$key};
         }
     }
     if (!count($keys)) {
         return $value;
     }
     // final value
     if (is_object($value)) {
         if (count($keys) > 1) {
             $keys = implode('.', $keys);
             // convert back to string
             if ($value instanceof WireData) {
                 $value = $value->getDot($keys);
             } else {
                 $value = self::_getDot($keys, $value);
             }
         } else {
             $key = array_shift($keys);
             // just one key left, like 'title'
             if ($value instanceof WireData) {
                 $value = $value->get($key);
             } else {
                 if ($value instanceof WireArray) {
                     if ($key == 'count') {
                         $value = count($value);
                     } else {
                         $a = array();
                         foreach ($value as $v) {
                             $a[] = $v->get($key);
                         }
                         $value = $a;
                     }
                 }
             }
         }
     } else {
         // there is a dot property remaining and nothing to send it to
         $value = null;
     }
     return $value;
 }
开发者ID:gusdecool,项目名称:bunga-wire,代码行数:74,代码来源:WireData.php

示例6: load

 /**
  * Load's ProcessWire using the supplied Config and populates all API fuel
  *
  * $param Config $config
  *
  */
 public function load(Config $config)
 {
     Wire::setFuel('notices', new Notices());
     Wire::setFuel('sanitizer', new Sanitizer());
     if ($config->dbSocket) {
         $db = new Database($config->dbHost, $config->dbUser, $config->dbPass, $config->dbName, $config->dbPort, $config->dbSocket);
     } else {
         $db = new Database($config->dbHost, $config->dbUser, $config->dbPass, $config->dbName, $config->dbPort);
     }
     Wire::setFuel('db', $db);
     if ($config->dbCharset) {
         $db->set_charset($config->dbCharset);
     } else {
         if ($config->dbSetNamesUTF8) {
             $db->query("SET NAMES 'utf8'");
         }
     }
     $modules = new Modules($config->paths->modules, $config->paths->siteModules);
     $fieldtypes = new Fieldtypes();
     $fields = new Fields();
     $fieldgroups = new Fieldgroups();
     $templates = new Templates($fieldgroups, $config->paths->templates);
     Wire::setFuel('modules', $modules);
     Wire::setFuel('fieldtypes', $fieldtypes);
     Wire::setFuel('fields', $fields);
     Wire::setFuel('fieldgroups', $fieldgroups);
     Wire::setFuel('templates', $templates);
     Wire::setFuel('permissions', new Permissions());
     Wire::setFuel('roles', new Roles());
     Wire::setFuel('pages', new Pages(), true);
     Wire::setFuel('pagesRoles', new PagesRoles());
     Wire::setFuel('users', new Users());
     Wire::setFuel('user', Wire::getFuel('users')->getCurrentUser());
     Wire::setFuel('session', new Session());
     Wire::setFuel('input', new WireInput());
     $fieldtypes->init();
     $fields->init();
     $fieldgroups->init();
     $templates->init();
     $modules->init();
 }
开发者ID:ryancramerdesign,项目名称:ProcessWire-2.0,代码行数:47,代码来源:ProcessWire.php

示例7: ProcessWireClassLoader

/**
 * Handles dynamic loading of classes as registered with spl_autoload_register
 *
 */
function ProcessWireClassLoader($className)
{
    if ($className[0] == 'W' && $className != 'Wire' && strpos($className, 'Wire') === 0) {
        $className = substr($className, 4);
    }
    $file = PROCESSWIRE_CORE_PATH . "{$className}.php";
    if (is_file($file)) {
        require $file;
    } else {
        if ($modules = Wire::getFuel('modules')) {
            $modules->includeModule($className);
        }
    }
    // else die($className);
}
开发者ID:nightsh,项目名称:ProcessWire,代码行数:19,代码来源:ProcessWire.php


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