本文整理汇总了PHP中Config::read方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::read方法的具体用法?PHP Config::read怎么用?PHP Config::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Config
的用法示例。
在下文中一共展示了Config::read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testWrite
/**
* @covers Config::write
* @todo Implement testWrite().
*/
public function testWrite()
{
$config = array('app_key' => 'appkeyvalue', 'user_key' => 'userkeyvalue');
$this->object->setConfig($config);
echo getcwd();
$this->object->setFileName('data/testOutputFile.ini');
$this->object->write();
$this->assertEquals($config, $this->object->read());
unlink($this->object->getFileName());
}
示例2: getContent
protected function getContent()
{
// Inicializa assistente de formulário
$form = new Form("myDetail");
$dataArr['ajax'] = ["type" => Config::read('form.hidden'), "data" => (object) ["value" => true]];
$dataArr['name'] = ["type" => Config::read('form.input'), "data" => (object) ["text" => Text::read('form.name'), "length" => 50]];
$dataArr['surname'] = ["type" => Config::read('form.input'), "data" => (object) ["text" => Text::read('form.surname'), "length" => 50]];
$dataArr['sex'] = ["type" => Config::read('form.radio'), "data" => (object) ["text" => Text::read('form.sex'), "value" => [(object) ["id" => 1, "text" => Text::read('form.man')], (object) ["id" => 2, "text" => Text::read('form.woman')]], "checked" => 1]];
$dataArr['email'] = ["type" => Config::read('form.input'), "data" => (object) ["text" => Text::read('form.email'), "length" => 50]];
$dataArr['password'] = ["type" => Config::read('form.password'), "data" => (object) ["text" => Text::read('form.password'), "length" => 20]];
$dataArr['news'] = ["type" => Config::read('form.checkbox'), "data" => (object) ["text" => Text::read('form.newsletter'), "checked" => true]];
$dataArr['btnSave'] = ["type" => Config::read('form.submit'), "data" => (object) ["text" => Text::read('form.save'), "class" => "success btn-lg"]];
$accountForm = $form->createForm($dataArr);
unset($dataArr);
ob_start();
?>
<div class="container">
<div class="row cadastro">
<div class="col-md-4 col-md-offset-4">
<?php
echo $accountForm;
?>
</div>
</div>
</div>
<?php
return ob_get_clean();
}
示例3: create
/**
* Create a new template object
* @return object
*/
public static function create()
{
// Try/catch statement
try {
// Required Smarty libraries
require_once dirname(__DIR__) . '/smarty/libs/Smarty.class.php';
// Optional - load custom security features
//require_once(__DIR__.'/smartysecuritycustom.inc.php');
// Smarty v3.1 or newer
$smarty = new Smarty();
$smarty->setTemplateDir(Config::read('smarty|templateDirectory'));
$smarty->setCompileDir(Config::read('smarty|compileDirectory'));
$smarty->setCacheDir(Config::read('smarty|cacheDirectory'));
// Optional - override configs
//$smarty->setConfigDir(Config::read('smarty|configDirectory'));
// Optional - override plugins
//$smarty->setPluginsDir(Config::read('smarty|pluginsDirectory'));
$smarty->setCacheLifetime(Config::read('smarty|cacheLifetime'));
// Disable caching
$smarty->force_compile = true;
$smarty->compile_check = true;
$smarty->setCaching(Smarty::CACHING_OFF);
// Optional - enable security restrictions
//$smarty->enableSecurity('SmartySecurityCustom');
// Return Smarty object
return $smarty;
} catch (Exception $e) {
Log::error("Error while loading template engine");
// Exception error
return false;
}
}
示例4: find
/**
* Find cafés nearby
*
* @param array $get The original $_GET array
* @return array
* @throws \Exception
* @author Jesper Skytte Hansen <jesper@edulab.dk>
*/
public static function find($get)
{
if (!isset($get['lat']) || !isset($get['lng'])) {
return self::format('', 'MissingParams');
}
// Convert to floats
$lat = floatval($get['lat']);
$lng = floatval($get['lng']);
// Set query parameters
$query = array('location' => $lat . ',' . $lng, 'language' => 'da', 'rankby' => 'distance', 'sensor' => 'true', 'types' => 'cafe', 'key' => Config::read('Keys.GoogleApi'));
// Create call url
$url = 'https://maps.googleapis.com/maps/api/place/search/json?' . http_build_query($query);
$url = str_replace('%2C', ',', $url);
// Send request to google
$d = self::curl($url);
// Json decode string
$d = json_decode($d, true);
switch ($d['status']) {
case 'OK':
return self::format(array('latitude' => $lat, 'longitude' => $lng, 'results' => $d['results']));
break;
case 'ZERO_RESULTS':
return self::format(array('latitude' => $lat, 'longitude' => $lng, 'results' => []));
break;
}
return self::format('', 'UnknownApiResponse');
}
示例5: read
/**
* Método que se utiliza para leer un .ini
* @param type $file Nombre del archivo (sin el .ini);
* @param type $source
*/
public static function read($file, $source = '', $force = FALSE)
{
$tmp = $file;
$file = Config::read($file, $force);
foreach ($file as $seccion => $filas) {
foreach ($filas as $variable => $valor) {
if ($valor == '1') {
$file[$seccion][$variable] = 'On';
} else {
if (empty($valor)) {
$file[$seccion][$variable] = $tmp == 'databases' ? NULL : 'Off';
}
}
}
}
if ($source) {
if (is_array($source)) {
$key = @array_shift(array_keys($source));
$var = $source[$key];
return isset($file[$key][$var]) ? $file[$key][$var] : NULL;
} else {
return isset($file[$source]) ? $file[$source] : NULL;
}
}
return $file;
}
示例6: __construct
public function __construct($params = "")
{
/**
* Carrega os routes do sistema
*/
$this->routes = Config::read("routes");
//pr( $this->routes );
/**
* URL
*
* Verifica URL e decifra que controller
* e action deve ser aberto.
*/
$this->translateUrl();
/**
* AJUSTA CONEXÃO SE EXISTIR
*/
$this->conn = empty($params["conn"]) ? NULL : $params["conn"];
/**
* Verifica tabelas
*/
if ($this->conn) {
$this->checkTables(array('conn' => $this->conn));
}
}
示例7: selectForDetail
public function selectForDetail($id)
{
$this->mapping->fields['id'] = 'productID';
$this->mapping->fields['name'] = 'productName';
$this->mapping->fields['text'] = 'productDescription';
$this->mapping->fields['price'] = 'REPLACE( CAST( TRUNCATE(productPrice,2) AS CHAR), ".", "," )';
$this->mapping->fields['discount'] = 'REPLACE( CAST( TRUNCATE(productDiscount,2) AS CHAR), ".", "," )';
$this->mapping->fields['status'] = 'productStatus';
$this->mapping->fields['album'] = 'albumID';
$this->mapping->fields['type'] = '(SELECT typeTitle' . ' FROM products_types AS textTable' . ' WHERE textTable.typeID = ' . $this->mapping->table . '.typeID)';
$this->mapping->fields['subtype'] = '(SELECT typeTitle' . ' FROM products_types AS textTable' . ' WHERE textTable.typeID = ' . $this->mapping->table . '.subTypeID)';
$this->mapping->fields['brand'] = '(SELECT brandTitle' . ' FROM products_brands AS textTable' . ' WHERE textTable.brandID = ' . $this->mapping->table . '.brandID)';
$this->mapping->fields['account'] = 'accountID';
$this->mapping->fields['accName'] = '(SELECT accountFirstName' . ' FROM accounts AS textTable' . ' WHERE textTable.accountID = ' . $this->mapping->table . '.accountID)';
$this->mapping->criterias['id'] = new stdclass();
$this->mapping->criterias['id']->field = 'productID';
$this->mapping->criterias['id']->operator = '=';
$this->mapping->criterias['id']->value = $id;
$data = $this->detail($id);
if ($data) {
// Recupera fotos a partir do album
if ($this->photoModel) {
$data->photos = $this->photoModel->selectAlbum($data->album);
}
// Converte o código do status para texto
$data->statusText = Text::read('product.status')[array_search($data->status, Config::read('product.status'))];
} else {
//exit($this->getMessage());
}
return $data;
}
示例8: getContent
protected function getContent()
{
// Inicializa assistente de formul‡rio
$form = new Form("myDetail");
$dataArr['ajax'] = ["type" => Config::read('form.hidden'), "data" => (object) ["value" => true]];
$dataArr['name'] = ["type" => Config::read('form.input'), "data" => (object) ["text" => Text::read('form.name'), "length" => 100]];
$dataArr['email'] = ["type" => Config::read('form.input'), "data" => (object) ["text" => Text::read('form.email'), "length" => 50]];
$dataArr['message'] = ["type" => Config::read('form.textarea'), "data" => (object) ["text" => Text::read('form.message')]];
$dataArr['btnSend'] = ["type" => Config::read('form.submit'), "data" => (object) ["text" => Text::read('form.send'), "class" => "success btn-lg"]];
$messageForm = $form->createForm($dataArr);
unset($dataArr);
ob_start();
?>
<div class="container">
<div class="row cadastro">
<div class="col-md-4 col-md-offset-4">
<?php
echo $messageForm;
?>
</div>
</div>
</div>
<?php
return ob_get_clean();
}
示例9: create
/**
* Create a new template object
* @return object
*/
public static function create()
{
// Try/catch statement
try {
// Smarty installation
$configDir = Config::read('smarty');
// Required Smarty libraries
require_once $configDir . '/libs/Smarty.class.php';
// Smarty v3.1 or newer
$smarty = new Smarty();
$smarty->setTemplateDir(Config::read('pwd') . '/templates/' . Config::read('template'));
$smarty->setCompileDir($configDir . '/templates_c');
$smarty->setCacheDir($configDir . '/cache');
// Disable caching
$smarty->force_compile = true;
$smarty->compile_check = true;
$smarty->setCaching(Smarty::CACHING_OFF);
// Return Smarty object
return $smarty;
} catch (Exception $e) {
Log::error("Error while loading template engine");
// Exception error
return false;
}
}
示例10: runApp
public function runApp()
{
$run_info = URLParser\URLParser::getPeices();
# Include it and call it, really basic
include APP_PATH . DS . 'controllers' . DS . $run_info['controller'] . '_controller.php';
$controller_name = ucwords($run_info['controller']) . 'Controller';
$this->controller = new $controller_name();
# Load up the database includes if there is one specified
if (Config::read('DATABASE_CONNECTOR') !== '') {
include LITEFRAME_PATH . DS . 'lib' . DS . 'php-activerecord' . DS . 'ActiveRecord.php';
$connections = Config::read('DATABASE_CONNECTIONS');
$default_connection = Config::read('DATABASE_CONNECTOR');
$model_path = APP_PATH . DS . 'models';
# must issue a "use" statement in your closure if passing variables
\ActiveRecord\Config::initialize(function ($cfg) use($connections, $default_connection, $model_path) {
$cfg->set_model_directory($model_path);
$cfg->set_connections($connections);
# default connection is now production
$cfg->set_default_connection($default_connection);
});
}
call_user_func_array(array($this->controller, 'init'), array());
ob_start();
call_user_func_array(array($this->controller, $run_info['function']), $run_info['args']);
$content_for_layout = ob_get_clean();
ob_end_clean();
$title_for_layout = $this->controller->title;
# Finally output with a global layout
if ($this->controller->layout !== '') {
include APP_PATH . DS . 'layouts' . DS . $this->controller->layout . '.tpl';
} else {
include LITEFRAME_PATH . DS . 'layouts' . DS . 'default.tpl';
}
}
示例11: htm
/**
* Generador de Reportes
*
* @category Kumbia
* @package Report
* @copyright Copyright (c) 2005-2007 Andres Felipe Gutierrez (andresfelipe at vagoogle.net)
* @license http://www.kumbia.org/license.txt GNU/GPL
*
*/
function htm($result, $sumArray, $title, $weighArray, $headerArray)
{
$config = Config::read('config');
$active_app = Router::get_application();
$file = md5(uniqid());
$content = "\n<html>\n <head>\n <title>REPORTE DE " . strtoupper($title) . "</title>\n </head>\n <body bgcolor='white'>\n <div style='font-size:20px;font-family:Verdana;color:#000000'>" . strtoupper($config->{$active_app}->name) . "</div>\n\n <div style='font-size:18px;font-family:Verdana;color:#000000'>REPORTE DE " . strtoupper($title) . "</div>\n\n <div style='font-size:18px;font-family:Verdana;color:#000000'>" . date("Y-m-d") . "</div>\n\n <br/>\n <table cellspacing='0' border=1 style='border:1px solid #969696'>\n ";
$content .= "<tr bgcolor='#F2F2F2'>\n";
for ($i = 0; $i <= count($headerArray) - 1; $i++) {
$content .= "<th style='font-family:Verdana;font-size:12px'>" . $headerArray[$i] . "</th>\n";
}
$content .= "</tr>\n";
$l = 5;
foreach ($result as $row) {
$content .= "<tr bgcolor='white'>\n";
for ($i = 0; $i <= count($row) - 1; $i++) {
if (is_numeric($row[$i])) {
$content .= "<td style='font-family:Verdana;font-size:12px' align='center'>{$row[$i]}</td>";
} else {
$content .= "<td style='font-family:Verdana;font-size:12px'>{$row[$i]} </td>";
}
}
$content .= "</tr>\n";
$l++;
}
file_put_contents("public/temp/{$file}.html", $content);
if (isset($raw_output)) {
print "<script type='text/javascript'> window.open('" . KUMBIA_PATH . "temp/" . $file . ".html', null); </script>";
} else {
Generator::forms_print("<script type='text/javascript'> window.open('" . KUMBIA_PATH . "temp/" . $file . ".html', null); </script>");
}
}
示例12: setPHP
/**
* @param string|null $version
*/
public function setPHP($version = null)
{
$phpVersions = $this->config->read('php_commands');
if (is_array($phpVersions) && in_array($version, array_keys($phpVersions))) {
$this->php = $phpVersions[$version];
}
}
示例13: site_include
function site_include($Filename)
{
if (Config::read('site.includenone')) {
} else {
include $Filename;
}
}
示例14: getContent
protected function getContent()
{
ob_start();
?>
<div class="jumbotron text-center">
<h1>
<span class="glyphicon glyphicon-time"></span>
<?php
echo Text::read('message.login.session.inactive');
?>
</h1>
<h2>
<a class="btn btn-lg btn-info" href="<?php
echo Config::read('page.url.login');
?>
">
<span class="glyphicon glyphicon-home"></span>
<?php
echo Text::read('message.login.session.return');
?>
</a>
</h2>
</div>
<?php
return ob_get_clean();
}
示例15: __construct
private function __construct()
{
$this->dbType = Config::read('db.type');
switch ($this->dbType) {
case 'mysql':
$dsn = "mysql:host=" . Config::read('db.host') . ";port=" . Config::read('db.port') . ";dbname=" . Config::read('db.basename');
$username = Config::read('db.user');
$password = Config::read('db.password');
$options = array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES " . Config::read('db.charset'));
break;
case 'sqlite':
$dsn = "sqlite:" . Config::read('db.basename');
$options = array(PDO::ATTR_PERSISTENT => true);
break;
case 'sqlite2':
$dsn = "sqlite2:" . Config::read('db.basename');
$options = array(PDO::ATTR_PERSISTENT => true);
break;
case 'pgsql':
$dsn = "pgsql:host=" . Config::read('db.host') . ";port=" . Config::read('db.port') . ";dbname=" . Config::read('db.basename') . ";user=" . Config::read('db.user') . ";password=" . Config::read('db.password');
break;
}
try {
if ($this->dbType == 'pgsql') {
$this->dbh = new PDO($dsn);
} elseif ($this->dbType == 'sqlite') {
$this->dbh = new PDO($dsn, NULL, NULL, $options);
} elseif ($this->dbType == 'mysql') {
$this->dbh = new PDO($dsn, $username, $password, $options);
}
} catch (PDOException $e) {
print 'Error!: ' . $e->getMessage() . '<br/>';
die;
}
}