本文整理汇总了PHP中Main::app方法的典型用法代码示例。如果您正苦于以下问题:PHP Main::app方法的具体用法?PHP Main::app怎么用?PHP Main::app使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Main
的用法示例。
在下文中一共展示了Main::app方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUrl
public function getUrl($path, $params = array())
{
if ($params === null) {
$params = array();
}
// Delegate path autocomplete to current controller
$path = Main::app()->getCurrentController()->autocompleteUrlPath($path);
$paramString = '';
$sysParams = array();
foreach ($params as $k => $v) {
if (strpos($k, '_') === 0) {
$sysParams[$k] = $v;
} else {
$paramString .= urlencode($k) . '/' . urlencode($v);
}
}
$query = '';
if (isset($sysParams['_query'])) {
if ($sysParams['_query'] === '*') {
$query = \Base::instance()->get('QUERY');
} elseif (is_array($sysParams['_query'])) {
$separator = isset($query['_query_arg_separator']) ? $query['_query_arg_separator'] : ini_get('arg_separator.output');
$encType = isset($query['_query_enc_type']) ? $query['_query_enc_type'] : PHP_QUERY_RFC1738;
$query = http_build_query($sysParams['_query'], '', $separator, $encType);
}
}
return $this->getBaseUrl($sysParams) . trim($path . '/' . $paramString, '/ ') . ($query ? '?' . $query : '');
}
示例2: logException
public function logException(\Exception $e, $file = null)
{
if (!$file) {
$file .= Main::app()->getConfig('EXCEPTION_LOG');
}
$message = $e->getCode() . ': ' . $e->getMessage() . "\n" . $e->getTraceAsString();
self::_log($message, LOG_ERR, $file, false);
}
示例3: __construct
public function __construct($name)
{
if (!self::$_session) {
self::$_cacheInstance = new \Cache(Main::app()->getConfig('SESSIONS'));
self::$_session = new \Session(null, null, self::$_cacheInstance);
}
$this->_name = $name;
$this->_data =& \Base::instance()->ref('SESSION.' . $name);
}
示例4: getOrderLinkUrl
/**
* @param array $currentOrder [order => dir]
* @param array $newOrder [order => dir]
* @param string $gridPath
* @param array $params
*/
public function getOrderLinkUrl(array $currentOrder, array $newOrder, $gridPath = null, $params = array())
{
$orderParam = isset($params['order_param']) ? $params['order_param'] : 'order';
$dirParam = isset($params['dir_param']) ? $params['dir_param'] : 'dir';
if ($gridPath === null) {
$gridPath = '*/*/*';
}
$currentOrderKey = key($currentOrder);
$currentOrderDir = current($currentOrder);
$newOrderKey = key($newOrder);
$newOrderDir = current($newOrder);
if ($newOrderDir === null) {
if ($currentOrderKey == $newOrderKey) {
$newOrderDir = $currentOrderDir == SORT_ASC ? SORT_DESC : SORT_ASC;
} else {
$newOrderDir = $currentOrderDir;
}
}
$controller = Main::app()->getCurrentController();
$query = $controller->getRequestQuery();
$query[$orderParam] = $newOrderKey;
$query[$dirParam] = $newOrderDir;
return Url::instance()->getUrl($gridPath, array('_query' => $query));
}
示例5: getTheme
public function getTheme()
{
return Main::app()->getConfig('THEME');
}
示例6: getAvailableCurrencies
public function getAvailableCurrencies()
{
return Main::app()->getConfig('CURRENCIES');
}