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 : ''); }
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); }
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); }
/** * @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)); }
public function getTheme() { return Main::app()->getConfig('THEME'); }
public function getAvailableCurrencies() { return Main::app()->getConfig('CURRENCIES'); }