本文整理汇总了PHP中Vars::getSettings方法的典型用法代码示例。如果您正苦于以下问题:PHP Vars::getSettings方法的具体用法?PHP Vars::getSettings怎么用?PHP Vars::getSettings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vars
的用法示例。
在下文中一共展示了Vars::getSettings方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAllAssets
static function getAllAssets($which_end)
{
// if cached already, return it
if (isset(self::$assets)) {
return self::$assets;
}
// otherwise, get it from settings
$settings = Vars::getSettings();
$assets = array();
$i = 0;
$indexes = array();
foreach ($settings['assets'][$which_end] as $type => $asset_group) {
foreach ($asset_group as $asset_key => $asset_attributes) {
$asset = new Asset();
$asset->type = $type;
$asset->path = $asset_attributes['path'];
$asset->source = $asset_attributes['source'];
$asset->position = $asset_attributes['position'];
$asset->weight = $asset_attributes['weight'];
$asset->key = $asset_key;
$assets[$i] = $asset;
$indexes[$i] = $asset->weight;
$i++;
}
}
asort($indexes);
$rtn = array();
foreach ($indexes as $key => $val) {
$rtn[] = $assets[$key];
}
return $rtn;
}
示例2: getThumbnailUrl
public function getThumbnailUrl()
{
if ($this->getThumbnail()) {
return get_sub_root() . "/files/avatars/" . $this->getThumbnail();
}
$settings = Vars::getSettings();
return get_sub_root() . "/files/avatars/" . $settings['profile']['avatar_default'];
}
示例3: delete
public function delete()
{
$settings = Vars::getSettings();
// we delete avatar image first
if ($this->getThumbnail() != $settings['profile']['avatar_default']) {
@unlink(AVATAR_DIR . '/' . $this->getThumbnail());
}
parent::delete();
}
示例4: getArticles
public function getArticles($page = 1, $category = null, $unread = null)
{
global $mysqli;
$user_account_table = 'user_' . $this->getId() . '_account';
$user_category_table = 'user_' . $this->getId() . '_category';
$user_read_table = 'user_' . $this->getId() . '_read';
// where
$where = array();
if ($category) {
$where[] = " ua.category_id={$category} ";
}
if (sizeof($where)) {
$where = " WHERE " . implode(' AND ', $where) . " ";
if ($unread == 1) {
$where .= " AND ur.article_id IS NULL ";
}
} else {
$where = '';
if ($unread == 1) {
$where = " WHERE ur.article_id IS NULL";
}
}
// join
$join = "";
if ($unread == 1) {
$join = " LEFT JOIN {$user_read_table} as ur ON ur.article_id=wa.id ";
}
// limit
$limit = "";
if ($page) {
$settings = Vars::getSettings();
$limit = " LIMIT " . ($page - 1) * $settings['articles_per_page'] . ", " . $settings['articles_per_page'];
}
// order by
$order_by = ' ORDER BY wa.published_at DESC ';
///// final query
$query = "SELECT wa.*, ua.id AS user_wechat_account_id FROM wechat_article as wa JOIN {$user_account_table} as ua ON ua.account_id=wa.account_id {$join} {$where} {$order_by} {$limit}";
//_debug($query);
$result = $mysqli->query($query);
$rtn = array();
while ($result && ($b = $result->fetch_object())) {
$obj = new WechatArticle();
DBObject::importQueryResultToDbObject($b, $obj);
$obj->user_wechat_account_id = $b->user_wechat_account_id;
$rtn[] = $obj;
}
return $rtn;
}
示例5: sendTicketToClient
function sendTicketToClient($subject, $msg, array $attachements, $to)
{
$settings = Vars::getSettings();
$username = $settings['mail']['ticket']['username'];
$password = $settings['mail']['ticket']['password'];
if (strpos($username, '@') == false) {
$username = decrypt($username);
$password = decrypt($password);
}
load_library_phpmailer();
$mail = new PHPMailer(true);
try {
// $mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
$mail->Mailer = $settings['mail']['ticket']['mailer'];
$mail->SMTPAuth = true;
// enable SMTP authentication
$mail->CharSet = 'UTF-8';
$mail->SMTPSecure = $settings['mail']['ticket']['SMTPSecure'];
// sets the prefix to the servier
$mail->Host = $settings['mail']['ticket']['host'];
// sets GMAIL as the SMTP server
$mail->Port = $settings['mail']['ticket']['port'];
// set the SMTP port for the GMAIL server
$mail->Username = $username;
// GMAIL username
$mail->Password = $password;
// GMAIL password
$mail->AddReplyTo($settings['mail']['ticket']['from']);
$mail->AddAddress($to);
$mail->SetFrom($settings['mail']['ticket']['from'], $settings['sitename']);
$mail->Subject = $subject;
$mail->MsgHTML($msg);
foreach ($attachements as $ticket) {
$mail->addAttachment($ticket);
}
$mail->Send();
} catch (phpmailerException $e) {
$log = new Log('mail', Log::ERROR, 'Failed to send email: ' . $e->errorMessage());
$log->save();
return false;
} catch (Exception $e) {
$log = new Log('mail', Log::ERROR, 'Failed to send email: ' . $e->getMessage());
$log->save();
return false;
}
return true;
}
示例6: forward
/**
* Forward page
*
* @param type $no_cache
*/
static function forward($destination, $http_response_code = false, $no_cache = false)
{
$settings = Vars::getSettings();
$response_code = is_int($http_response_code) ? $http_response_code : 302;
if ($no_cache) {
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
}
if (preg_match('/^http/', $destination)) {
header('Location: ' . $destination, true, $response_code);
} else {
// i18n $destination if its not i18ned
if (isset($settings['i18n']) && $settings['i18n'] == 1 && strpos($destination, get_language() . '/') !== 0) {
$destination = get_language() . "/{$destination}";
}
header('Location: /' . get_sub_root() . $destination, true, $response_code);
}
exit;
}
示例7: array
<?php
require_once 'bootstrap.php';
$settings = Vars::getSettings();
/** rounting **/
$relative_uri;
if ($settings['i18n']) {
$relative_uri = get_request_uri_relative();
} else {
$relative_uri = str_replace(get_sub_root(), '', get_request_uri());
}
//_debug($settings['routing']);
// try to match a route
foreach ($settings['routing'] as $route) {
$path = $route['path'];
$isSecure = $route['isSecure'];
$controller = $route['controller'];
$i18n = $route['i18n'];
// _debug($relative_uri);
$vars = array();
$user = User::getInstance();
if (preg_match('/' . $path . '/', $relative_uri, $vars)) {
// redirect to lang url if lang code is not here
if ($i18n && $settings['i18n']) {
HTML::redirectToI18nUrl();
}
if ($isSecure && !$user->isLogin()) {
dispatch('core/login');
} else {
dispatch($controller, $vars);
}
示例8: importFixture
static function importFixture()
{
$settings = Vars::getSettings();
// import user fixture from "role.yml"
if (User::tableExist() && isset($settings['users'])) {
foreach ($settings['users'] as $user) {
$u = new User();
$u->setEmail($user['email']);
$u->setName($user['name']);
$u->setPassword($user['password']);
$u->setSalt($user['salt']);
$roles = array();
foreach ($user['role'] as $role) {
$roles[] = $role;
}
$u->setRole(implode(',', $roles));
$u->save();
}
}
}
示例9: uri
/**
* print out an uri
*/
function uri($uri, $i18n = true)
{
$settings = Vars::getSettings();
$rtn = "/" . get_sub_root();
if (isset($settings['i18n']) && $settings['i18n'] && $i18n) {
$rtn .= get_language() . '/';
}
$rtn .= $uri;
return $rtn;
}
示例10: renderSettingsInJson
/**
* return $settings in json format
*/
static function renderSettingsInJson(array $include)
{
$settings = Vars::getSettings();
$rtn = array();
foreach ($include as $key => $value) {
if (is_int($key) && isset($settings[$value])) {
$rtn[$key] = $settings[$value];
} else {
$rtn[$key] = $value;
}
}
return json_encode($rtn);
}