本文整理汇总了PHP中Application::getConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::getConfig方法的具体用法?PHP Application::getConfig怎么用?PHP Application::getConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Application
的用法示例。
在下文中一共展示了Application::getConfig方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getKey
/**
* Get the key for hashing
*
* @return string
*/
private static function getKey()
{
if (static::$key === null) {
static::$key = Application::getConfig('application', 'key');
}
return static::$key;
}
示例2: hostName
/**
* Get the host name of request or null
*
* @return string
*/
public static function hostName()
{
if (isset($_SERVER['HTTP_HOST'])) {
return $_SERVER['HTTP_HOST'];
} else {
$siteUrl = Application::getConfig('application', 'site_url');
return substr($siteUrl, strpos($siteUrl, '//') + 2);
}
}
示例3: connect
/**
* Connects to MySQL instance with Config params
*
* @throws \Kernel\Exception\DatabaseException When connection is failed
*/
private function connect()
{
$config = \Application::getConfig();
if (!($this->_connection = mysql_connect($config['db_host'], $config['db_user'], $config['db_pass']))) {
throw new DatabaseException('Could not connect to MySQL server');
}
if (!mysql_select_db($config['db_name'])) {
throw new DatabaseException(sprintf('Database "%s" was not found', $config['db_name']));
}
}
示例4: __
function __($var = null)
{
$languange = new Language();
Application::setConfig();
$id_lang = Application::getConfig('id_lang');
$base = Application::getConfig('base_url');
$lang = $this->getISO($id_lang);
$filename = "application/core/language/" . $lang . ".php";
if (file_exists($filename)) {
include $filename;
}
$var = strtolower($var);
if (!empty($_LANGADM[$var])) {
return $_LANGADM[$var];
} else {
return $var;
}
}
示例5: safeQuery
public function safeQuery($sql, $params, $cacheKey = null)
{
if (Application::getConfig("enableCache") != false) {
if ($cacheKey == null) {
$cacheKey = md5($sql . implode("-", $params));
}
$results = $this->cache->get($cacheKey);
if ($results != null) {
return $results;
} else {
$results = $this->db->rawQuery($sql, $params);
$this->cache->set($cacheKey, $results);
return $results;
}
} else {
$results = $this->db->rawQuery($sql, $params);
return $results;
}
}
示例6: mailQueueProcessAction
public function mailQueueProcessAction()
{
include 'libs/class.phpmailer.php';
include 'libs/class.smtp.php';
$config = Application::getConfig()['mail'];
$items = Model_MailQueue::getUnprocessedItem();
$processedIds = array();
foreach ($items as $item) {
$mail = new phpMailer();
$mail->XMailer = 'Foxmail 6.1';
//$mail->SMTPDebug = 3;
$mail->isSmtp(true);
$mail->SMTPAuth = true;
$mail->SMTPSecure = $config['smtp_secure'];
$mail->Host = $config['smtp_host'];
$mail->Port = $config['smtp_port'];
$mail->Username = $config['smtp_user'];
$mail->Password = $config['smtp_password'];
$mail->From = $config['smtp_user'];
$mail->FromName = 'RCR Notify';
$mail->CharSet = 'UTF-8';
$mail->isHtml();
$recipients = explode(',', $item['to']);
foreach ($recipients as $r) {
$mail->addAddress(trim($r));
}
$mail->Subject = $item['subject'];
$mail->Body = $item['message'];
if ($mail->send()) {
$processedIds[] = $item['id'];
} else {
echo $mail->ErrorInfo;
}
}
Model_MailQueue::setItemAsProcessedBatch($processedIds);
}
示例7: init
/**
* Initialize the session handler and session itself
*
* @throws Exception
*/
private static function init()
{
if (!static::$initialized) {
static::$initialized = true;
$config = Application::getConfig('session');
if ($config === null) {
throw new Exception('Missing config file for sessions');
}
session_set_cookie_params($config['cookie_life'], $config['cookie_path'], $config['cookie_domain'], $config['cookie_secure']);
session_name($config['session_name']);
if (isset($config['driver'])) {
if (in_array($config['driver'], array('\\Koldy\\Session\\Driver\\File', '\\Koldy\\Session\\Driver\\Db')) && PHP_VERSION_ID < 50400) {
throw new Exception('PHP 5.4 or greater is reqired to use this session driver: ' . $config['driver']);
}
$driverClass = $config['driver'];
$handler = new $driverClass(isset($config['options']) ? $config['options'] : array());
if (!$handler instanceof \SessionHandlerInterface) {
throw new Exception('Your session driver doesn\'t implement the \\SessionHandlerInterface');
}
session_set_save_handler($handler);
}
session_start();
}
}
示例8: editAction
/**
* Updates post
*
* @param int $id
*
* @return string
*/
public function editAction($id)
{
if (!$this->getUser()) {
$this->redirect('/', 'Please, login first!');
}
$model = new Post();
$date = new \DateTime();
$date->setTimezone(new \DateTimeZone(\Application::getConfig('timezone')));
$model->set('title', Request::get('title'))->set('content', Request::get('content'))->set('id', $id)->set('updated_at', $date->format('Y-m-d H:i:s'));
if ($model->isValid()) {
try {
$model->update();
$this->redirect('/', 'The data has been saved successfully');
} catch (DatabaseException $e) {
array_push($errors, $e->getMessage());
}
} else {
$post = $model->getFieldsObject();
return $this->_renderView('form.html', array('post' => $post, 'errors' => $model->getErrors(), 'action' => '/posts/' . $id . '/edit'));
}
}
示例9: isEnabled
/**
* You can check if configure mail driver is enabled or not.
*
* @param string $driver [optional] will use default if not set
* @return boolean
*/
public static function isEnabled($driver = null)
{
self::init();
if ($driver === null) {
$driver = self::$defaultDriver;
}
$config = Application::getConfig('mail');
if (!isset($config[$driver])) {
Log::error("Mail driver '{$driver}' is not defined in config");
Application::error(500, "Mail driver '{$driver}' is not defined in config");
}
return $config[$driver]['enabled'];
}
示例10: htmlspecialchars_decode
<?php
$date = new \DateTime();
$date->setTimestamp(strtotime($post->updated_at));
$date->setTimezone(new \DateTimeZone(Application::getConfig('timezone')));
?>
<div class="row">
<h1><?php
echo $post->title;
?>
</h1>
<p class="small"><?php
echo $date->format('F j, Y H:i:s');
?>
</p>
<?php
echo htmlspecialchars_decode($post->content);
?>
</div>
示例11: bookingAction
public function bookingAction()
{
$this->view->activeMenu = 'booking';
$this->view->vehicleTypes = (new Model_VehicleType())->fetchPagedList(1, 999999)['rows'];
if (!$this->_request->isPost()) {
return;
}
$arp = new AjaxResponse();
$arp->setStatus(AjaxResponse::STATUS_FAILED);
$availableParams = array('forwho', 'city', 'contact-name', 'contact-email', 'contact-phone', 'passenger-names', 'passenger-phone', 'passenger-num', 'when', 'pickup-address', 'dropoff-address', 'vehicle', 'payment-method', 'notes');
$via = $this->_getParam('via-address', array());
$viaToSave = array();
if (is_array($via)) {
foreach ($via as $k => $v) {
if (!empty(trim($v))) {
$viaToSave[] = trim($v);
}
}
}
$via = json_encode($viaToSave);
$sn = Model_Order::generateSn();
$order = new Model_Order();
$order->set('sn', $sn);
$order->set('user_id', $this->user->get('id'));
foreach ($availableParams as $paramName) {
$value = trim($this->getParam($paramName, ''));
$colName = str_replace('-', '_', $paramName);
$order->set($colName, $value);
}
$order->set('via', $via);
$order->set('created_time', time());
$order->save();
//Mail it.
$time = date('Y-m-d H:i', $order->get('created_time'));
$mailBody = <<<EOT
<!DOCTYPE html>
<html lang="en">
<head>
\t<meta charset="UTF-8">
\t<title>新订单</title>
</head>
<body>
<style>
dt {
\tfont-weight:bold;
\tfont-size:12px;
}
dd {
\tfont-size:14px;
}
</style>
<h2>新订单:{$order->get('sn')}</h2>
<dl>
<dt>下单时间</dt><dd>{$time}</dd>
<dt>下单人</dt><dd>{$order->get('contact_name')}</dd>
<dt>乘客</dt><dd>{$order->get('passenger_names')}</dd>
<dt>时间</dt><dd>{$order->get('when')}</dd>
<dt>城市</dt><dd>{$order->get('city')}</dd>
<dt>起始地</dt><dd>{$order->get('pickup_address')}</dd>
<dt>终点</dt><dd>{$order->get('dropoff_address')}</dd>
</dl>
<p><a href="http://www.carrentalsbeijing.com/private-car-management/order-detail?sn={$order->get('sn')}" target="_blank">查看订单详情</a></p>
✉
</body>
</html>
EOT;
$mailSubject = "新订单 {$order->get('passenger_names')}从{$order->get('pickup_address')}到{$order->get('dropoff_address')}";
$mailRecipients = Application::getConfig()['order_mail_recipients'];
$mailQueue = new Model_MailQueue();
$mailQueue->set('to', $mailRecipients);
$mailQueue->set('subject', $mailSubject);
$mailQueue->set('message', $mailBody);
$mailQueue->set('created_time', time());
$mailQueue->save();
$arp->setStatus(AjaxResponse::STATUS_OK);
$arp->setMessage($sn);
$this->json($arp);
}
示例12: _getCurrentDate
/**
* @return \DateTime
*/
private function _getCurrentDate()
{
$date = new \DateTime();
$date->setTimezone(new \DateTimeZone(\Application::getConfig('timezone')));
return $date;
}
示例13: hasDriver
/**
* Does given driver exists (this will also return true if driver is disabled)
*
* @param string $driver
* @return boolean
* @link http://koldy.net/docs/cache#engines
*/
public static function hasDriver($driver)
{
return Application::getConfig('cache', $driver) !== null;
}
示例14: current
/**
* Get the complete current URL with domain and protocol and request URI
*
* @return null|string will return NULL in CLI environment
*/
public static function current()
{
if (!isset($_SERVER['REQUEST_URI'])) {
return null;
}
return Application::getConfig('application', 'site_url') . $_SERVER['REQUEST_URI'];
}
示例15: Application
<?php
/**
* Created by Boomerang
* Project: CMS(Site)
* Date: 05 Month 2013 Year
* Site created on PHP,MySQL
*/
/*include '../../constants.php';
include '../../libraries/application/loader.php';
loader::init();*/
$baseurl = Url::getBase();
$app = new Application();
$config = $app->getConfig();
$template = $config->template;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Главная</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="<?php
echo $baseurl;
?>
/templates/<?php
echo $template;
?>
/css/main.css"/>