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


PHP Q::interpolate方法代码示例

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


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

示例1: __construct

 /**
  * Represents a complex exception thrown in Q. It may contain more details.
  * @class Q_Exception
  * @constructor
  * @extends Exception
  * @param {array} [$params=array()] Array of parameters for the exception. 
  *  Used in the exception message, etc.
  *  To access them later, call $e->params()
  *  You can also provide a string here, which will
  *  then be the exception message.
  * @param {array} [$inputFields=array()] Array of names of input fields to which the exception applies.
  * @param {array} [$code=null] Optionally pass the error code here to override the default
  */
 function __construct($params = array(), $inputFields = array(), $code = null, $file = null, $line = null, $trace = null, $traceAsString = null)
 {
     if (is_string($inputFields)) {
         $inputFields = array($inputFields);
     }
     $this->inputFields = $inputFields;
     if (isset($file)) {
         $this->file = $file;
     }
     if (isset($line)) {
         $this->line = $line;
     }
     if (isset($trace)) {
         $this->trace = $trace;
     }
     if (isset($traceAsString)) {
         $this->traceAsString = $traceAsString;
     }
     if (is_string($params)) {
         parent::__construct($params, isset($code) ? $code : 1);
         return;
     }
     $this->params = is_array($params) ? $params : array();
     $className = get_class($this);
     $message = isset(self::$messages[$className]) ? Q::interpolate(self::$messages[$className], $this->params) : $className;
     $code = isset($code) ? $code : (isset(self::$codes[$className]) ? self::$codes[$className] : 1);
     parent::__construct($message, $code);
 }
开发者ID:dmitriz,项目名称:Platform,代码行数:41,代码来源:Exception.php

示例2: iconUrl

 /**
  * Get the url of a user's icon
  * @param {string} [$icon] The contents of a user row's icon field
  * @param {string} [$basename=""] The last part after the slash, such as "50.png"
  * @return {string} The stream's icon url
  */
 static function iconUrl($icon, $basename = null)
 {
     if (empty($icon)) {
         return null;
     }
     $url = Q::interpolate($icon, array('baseUrl' => Q_Request::baseUrl()));
     $url = Q_Valid::url($url) ? $url : "plugins/Users/img/icons/{$url}";
     if ($basename) {
         $url .= "/{$basename}";
     }
     return Q_Html::themedUrl($url);
 }
开发者ID:AndreyTepaykin,项目名称:Platform,代码行数:18,代码来源:Users.php

示例3: iconUrl

 /**
  * Get the url of the stream's icon
  * @param {string} [$basename=""] The last part after the slash, such as "50.png"
  * @return {string} The stream's icon url
  */
 function iconUrl($basename = null)
 {
     if (empty($this->icon)) {
         return null;
     }
     $url = Q::interpolate($this->icon, array('baseUrl' => Q_Request::baseUrl()));
     $url = Q_Valid::url($url) ? $url : "plugins/Streams/img/icons/{$url}";
     if ($basename) {
         if (strpos($basename, '.') === false) {
             $basename = "{$basename}.png";
         }
         $url .= "/{$basename}";
     }
     return Q_Html::themedUrl($url);
 }
开发者ID:dmitriz,项目名称:Platform,代码行数:20,代码来源:Stream.php

示例4: Users_before_Q_Utils_canWriteToPath

function Users_before_Q_Utils_canWriteToPath($params, &$result)
{
    extract($params);
    /**
     * @var $path
     * @var $throwIfNotWritable
     * @var $mkdirIfMissing
     */
    // The Users plugin requires that a user be logged in before uploading a file,
    // and only in the proper directories.
    $user = Users::loggedInUser($throwIfNotWritable);
    if (!$user) {
        return false;
    }
    $app = Q_Config::expect('Q', 'app');
    $subpaths = Q_Config::get('Users', 'paths', 'uploads', array('files/{{app}}/uploads/Users/{{userId}}' => true));
    $paths = array();
    $path = str_replace(array("/", "\\"), DS, $path);
    foreach ($subpaths as $subpath => $can_write) {
        if (!$can_write) {
            continue;
        }
        $subpath = Q::interpolate($subpath, array('userId' => Q_Utils::splitId($user->id), 'app' => $app));
        if ($subpath and ($subpath[0] !== '/' or $subpath[0] !== DS)) {
            $subpath = DS . $subpath;
        }
        $last_char = substr($subpath, -1);
        if ($subpath and $last_char !== '/' and $last_char !== DS) {
            $subpath .= DS;
        }
        $paths[] = APP_DIR . $subpath;
        foreach (Q_Config::get('Q', 'plugins', array()) as $plugin) {
            $c = strtoupper($plugin) . '_PLUGIN_DIR';
            if (defined($c)) {
                $paths[] = constant($c) . $subpath;
            }
        }
        $paths[] = Q_DIR . $subpath;
    }
    if (strpos($path, "../") === false and strpos($path, ".." . DS) === false) {
        foreach ($paths as $p) {
            $p = str_replace(array("/", "\\"), DS, $p);
            $len = strlen($p);
            if (strncmp($path, $p, $len) === 0) {
                // we can write to this path
                if ($mkdirIfMissing and !file_exists($path)) {
                    $mode = is_integer($mkdirIfMissing) ? $mkdirIfMissing : 0777;
                    $mask = umask(Q_Config::get('Q', 'internal', 'umask', 00));
                    if (!@mkdir($path, $mode, true)) {
                        throw new Q_Exception_FilePermissions(array('action' => 'create', 'filename' => $path, 'recommendation' => ' Please set your files directory to be writable.'));
                    }
                    umask($mask);
                    $dir3 = $path;
                    do {
                        chmod($dir3, $mode);
                        $dir3 = dirname($dir3);
                    } while ($dir3 and $dir3 != $p and $dir3 . DS != $p);
                }
                $result = true;
                return;
            }
        }
    }
    if ($throwIfNotWritable) {
        throw new Q_Exception_CantWriteToPath();
    }
    $result = false;
}
开发者ID:AndreyTepaykin,项目名称:Platform,代码行数:68,代码来源:Q_Utils_canWriteToPath.php

示例5: invitationsPath

 static function invitationsPath($invitingUserId)
 {
     $app = Q_Config::expect('Q', 'app');
     $subpath = Q_Config::get('Streams', 'invites', 'subpath', '{{app}}/uploads/Streams/invitations');
     return APP_FILES_DIR . DS . Q::interpolate($subpath, compact('app')) . DS . $invitingUserId;
 }
开发者ID:atirjavid,项目名称:Platform,代码行数:6,代码来源:Streams.php

示例6: termsLabel

 static function termsLabel($for = 'register')
 {
     $terms_uri = Q_Config::get('Users', $for, 'terms', 'uri', null);
     $terms_label = Q_Config::get('Users', $for, 'terms', 'label', null);
     $terms_title = Q_Config::get('Users', $for, 'terms', 'title', null);
     if (!$terms_uri or !$terms_title or !$terms_label) {
         return null;
     }
     $terms_link = Q_Html::a(Q::interpolate($terms_uri, array('baseUrl' => Q_Request::baseUrl())), array('target' => '_blank'), $terms_title);
     return Q::interpolate($terms_label, array('link' => $terms_link));
 }
开发者ID:atirjavid,项目名称:Platform,代码行数:11,代码来源:Users.php

示例7: nodeUrl

 /**
  * Returns base url for socket.io connection
  * @method nodeUrl
  * @static
  * @throws {Q_Exception_MissingConfig} If node host or port are not defined
  */
 static function nodeUrl()
 {
     $url = Q_Config::get('Q', 'node', 'url', null);
     if (isset($url)) {
         return Q::interpolate($url, array('baseUrl' => Q_Request::baseUrl()));
     }
     $host = Q_Config::get('Q', 'node', 'host', null);
     $port = Q_Config::get('Q', 'node', 'port', null);
     if (!isset($port) || !isset($host)) {
         return null;
     }
     $https = Q_Config::get('Q', 'node', 'https', false);
     $s = $https ? 's' : '';
     return "http{$s}://{$host}:{$port}";
 }
开发者ID:AndreyTepaykin,项目名称:Platform,代码行数:21,代码来源:Utils.php

示例8: nonce

 /**
  * Use this for validating the nonce
  * @method nonce
  * @static
  * @param {boolean} [$throwIfInvalid=false] If true, throws an exception if the nonce is invalid.
  * @param {boolean} [$missingIsValid=false] If true, returns true if request body is missing nonce.
  * @throws {Q_Exception_FailedValidation}
  */
 static function nonce($throwIfInvalid = false, $missingIsValid = false)
 {
     if (!isset($_SESSION['Q']['nonce'])) {
         return true;
     }
     $snf = Q_Config::get('Q', 'session', 'nonceField', 'nonce');
     $sn = Q_Request::special($snf, null);
     if ($missingIsValid and !isset($sn)) {
         return true;
     }
     $gp = array_merge($_GET, $_POST);
     $rn = Q_Request::special($snf, null, $gp);
     if (!isset($sn) or $_SESSION['Q']['nonce'] != $rn) {
         if (!$throwIfInvalid) {
             return false;
         }
         $sameDomain = true;
         $baseUrl = Q_Request::baseUrl();
         $message = Q_Config::get('Q', 'session', 'nonceMessages', 'sameDomain', null);
         if (!empty($_SERVER['HTTP_REFERER'])) {
             $host1 = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
             $host2 = parse_url($baseUrl, PHP_URL_HOST);
             if ($host1 !== $host2) {
                 $message = Q_Config::get('Q', 'session', 'nonceMessages', 'otherDomain', null);
             }
         }
         $message = Q::interpolate($message, compact('baseUrl'));
         $field = 'nonce';
         throw new Q_Exception_FailedValidation(compact('message', 'field'), 'Q.nonce');
     }
     return true;
 }
开发者ID:AndreyTepaykin,项目名称:Platform,代码行数:40,代码来源:Valid.php

示例9: iconUrl

 /**
  * Get the url of the user's icon
  * @param {string} [$basename=""] The last part after the slash, such as "50.png"
  * @return {string} The stream's icon url
  */
 function iconUrl($basename = null)
 {
     $replacements = array('userId' => Q_Utils::splitId($this->id));
     return Users::iconUrl(isset($this->icon) ? Q::interpolate($this->icon, $replacements) : 'default', $basename);
 }
开发者ID:AndreyTepaykin,项目名称:Platform,代码行数:10,代码来源:User.php


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