本文整理汇总了PHP中Haanga::configure方法的典型用法代码示例。如果您正苦于以下问题:PHP Haanga::configure方法的具体用法?PHP Haanga::configure怎么用?PHP Haanga::configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Haanga
的用法示例。
在下文中一共展示了Haanga::configure方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadkernel
function loadkernel()
{
Haanga::configure(array('template_dir' => '', 'cache_dir' => _CACHE_));
kernel::$haanga_var = array();
$this->sql = new SQL();
$this->session = new Session($this);
}
示例2: __construct
function __construct($css_files = array(), $js_files = array())
{
Haanga::configure(array('template_dir' => TEMPLATE_DIR, 'cache_dir' => CACHE_DIR . 'skinner/'));
$this->preloaded_css_files = $css_files;
$this->preloaded_js_files = $js_files;
// Check if there's a overlay to show
if (isset($_SESSION['overlay'])) {
$this->vars['overlay'] = $_SESSION['overlay'];
unset($_SESSION['overlay']);
}
}
示例3: render
public function render()
{
$config = array('template_dir' => $this->getTemplateDir(), 'cache_dir' => $this->getCacheDir(), 'debug' => $this->debug, 'compiler' => array('allow_exec' => true));
if ($this->cache && is_callable('xcache_isset')) {
/* don't check for changes in the template for the next 5 min */
$config['check_ttl'] = 300;
$config['check_get'] = 'xcache_get';
$config['check_set'] = 'xcache_set';
}
\Haanga::configure($config);
\Haanga::Load($this->getTpl(), $this->data);
}
示例4: match
public function match($uri)
{
global $conf;
global $localUri;
global $uri;
global $acceptContentType;
global $endpoints;
global $lodspk;
global $results;
global $firstResults;
require_once $conf['home'] . 'classes/MetaDb.php';
$metaDb = new MetaDb($conf['metadata']['db']['location']);
$pair = Queries::getMetadata($localUri, $acceptContentType, $metaDb);
if ($pair == NULL) {
// Original URI is not in metadata
if (Queries::uriExist($uri, $endpoints['local'])) {
$page = Queries::createPage($uri, $localUri, $acceptContentType, $metaDb);
if ($page == NULL) {
HTTPStatus::send500("Can't write sqlite database.");
}
HTTPStatus::send303($page, $acceptContentType);
exit(0);
} else {
return false;
}
}
list($res, $page, $format) = $pair;
$uri = $res;
$queries = $this->getQueries();
$e = $endpoints['local'];
require_once $conf['home'] . 'lib/Haanga/lib/Haanga.php';
Haanga::configure(array('cache_dir' => $conf['home'] . 'cache/', 'autoescape' => FALSE));
$vars = compact('uri', 'lodspk', 'models', 'first');
foreach ($queries as $l => $v) {
$q = Utils::addPrefixes(file_get_contents($v));
$fnc = Haanga::compile($q);
$query = $fnc($vars, TRUE);
$aux = $e->query($query, Utils::getResultsType($query));
if ($aux["boolean"] === true) {
$pair[] = $l;
return $pair;
}
}
return false;
}
示例5: showView
public static function showView($lodspkData, $data, $view)
{
global $conf;
global $uri;
global $lodspk;
global $extension;
//$lodspk = $conf['view']['standard'];
$lodspk = $lodspkData;
if (isset($lodspkData['params'])) {
$lodspk['this']['params'] = $lodspkData['params'];
}
if (isset($lodspk['queryTimes'])) {
$lodspk['queryTimes'] = Convert::array_to_object($lodspk['queryTimes']);
}
require_once $conf['home'] . 'lib/Haanga/lib/Haanga.php';
$viewAux = explode("/", $view);
$viewFile = array_pop($viewAux);
//$viewFile = $view;
$viewPath = join("/", $viewAux);
Haanga::configure(array('template_dir' => $viewPath, 'cache_dir' => $conf['home'] . 'cache/'));
$rdf = null;
if (array_key_exists('rdf', $data)) {
$rdf = $data['rdf'];
unset($data['rdf']);
} else {
}
$models = $data;
Convert::getPaths($models, "");
$first = $lodspk['firstResults'];
unset($lodspk['firstResults']);
//unset($lodspk);
$vars = compact('uri', 'lodspk', 'conf', 'models', 'rdf', 'first');
if ($conf['debug']) {
//Logging::log(var_export($vars, true));
}
if (is_string($data)) {
echo $data;
} elseif (is_file($view)) {
try {
Haanga::Load($viewFile, $vars);
} catch (Exception $e) {
echo '<pre>';
echo $e->getMessage() . "' in " . $e->getFile() . ":" . $e->getLine() . "\nStack trace:\n" . $e->getTraceAsString();
echo '</pre>';
}
} elseif ($view == null) {
$fnc = Haanga::compile('{{models|safe}}');
$fnc($vars, TRUE);
} else {
echo $conf['home'] . $viewPath . " " . $viewFile;
$fnc = Haanga::compile($view);
$fnc($vars, TRUE);
}
}
示例6: haanga_bootstrap
}
function haanga_bootstrap()
{
/* bootstrap function, load our custom tags/filter */
require mnminclude . 'haanga_mnm.php';
}
/* Load template engine here */
$config = array('template_dir' => mnmpath . '/' . $globals['haanga_templates'], 'autoload' => TRUE, 'bootstrap' => 'haanga_bootstrap', 'compiler' => array('if_empty' => FALSE, 'autoescape' => FALSE, 'strip_whitespace' => TRUE, 'allow_exec' => TRUE, 'global' => array('globals', 'current_user')), 'use_hash_filename' => FALSE);
// Allow full or relative pathname for the cache (i.e. /var/tmp or cache)
if ($globals['haanga_cache'][0] == '/') {
$config['cache_dir'] = $globals['haanga_cache'] . '/Haanga/' . $_SERVER['SERVER_NAME'];
} else {
$config['cache_dir'] = mnmpath . '/' . $globals['haanga_cache'] . '/Haanga/' . $_SERVER['SERVER_NAME'];
}
require mnminclude . 'Haanga.php';
Haanga::configure($config);
function __($text)
{
return htmlentities($text, ENT_QUOTES, 'UTF-8', false);
}
function _e($text)
{
echo htmlentities($text, ENT_QUOTES, 'UTF-8', false);
}
function shutdown()
{
global $globals, $current_user, $db;
close_connection();
if (is_object($db) && $db->connected) {
Link::store_clicks();
// It will check cache and increment link clicks counter
示例7: __construct
/**
* Configure Haanga environment
*/
public function __construct($haangaDir, $templatesDir, $compiledDir)
{
require_once $haangaDir . '/lib/Haanga.php';
Haanga::configure(array('template_dir' => $templatesDir, 'cache_dir' => $compiledDir));
}
示例8: Memcache
require classes_dir . 'memcache.php';
$memcache = new Memcache();
$memcache->enabled = $config['memcache']['enabled'];
$memcache->server = $config['memcache']['server'];
$memcache->port = $config['memcache']['port'];
$memcache->prefix = $config['memcache']['prefix'] ? $config['memcache']['prefix'] : 'fearqdb';
$memcache->debug = $config['memcache']['debug'];
$memcache->init();
/* encoding */
if ($db->type == 'mysql') {
$db->query(sprintf('SET NAMES utf8 COLLATE %s', $settings->collate));
}
mb_internal_encoding('utf8');
// initialize Haanga
require include_dir . 'Haanga.php';
Haanga::configure(array('template_dir' => 'templates/', 'cache_dir' => 'templates/compiled/', 'compiler' => array('global' => array('settings', 'session'), 'strip_whitespace' => true, 'allow_exec' => false, 'autoescape' => false)));
// initialize the html engine
require classes_dir . 'html.php';
$html = new HTML();
// initiailze session
require classes_dir . 'session.php';
$session = new Session();
$session->init();
// initialize push engine
require classes_dir . 'push.php';
$push = new Push();
$push->init();
// configure gettext's locale
putenv('LC_ALL=' . $settings->locale);
setlocale(LC_ALL, $settings->locale);
bindtextdomain('messages', './locale');
示例9: _not_found
public function _not_found()
{
if (!$this->_haanga_loaded) {
$this->_load_haanga();
$this->_haanga_loaded = TRUE;
}
header('HTTP/1.0 404 Not Found');
$config = $this->e->haanga;
$config['template_dir'] = APP_ERROR_TEMPLATES_PATH;
Haanga::configure($config);
Haanga::Load('404.html', array('resource' => $_SERVER['REQUEST_URI']));
}
示例10: buildCrudApi
/**
* Build Rest Crud Api
*/
public function buildCrudApi()
{
/**
* load configuration from /engine/config/rest-config.ini and
* load database schemda from /engine/config/schema.xml
*/
$this->loadConfig();
$this->loadDbXmlSchema();
self::out('Output folder: ', 'info', false);
echo $this->basePath . "services/rest/crud";
if (!is_dir($this->basePath . "services/rest/crud/")) {
G::mk_dir($this->basePath . "services/rest/crud/");
echo ' (created)';
}
echo "\n\n";
if (!is_writable($this->basePath . "services/rest/crud/")) {
throw new Exception(fprintf("Runtime Error: Output folder '%s' is not writable.", $this->basePath . "services/rest/crud/"));
}
Haanga::configure(array('template_dir' => dirname(__FILE__) . '/templates/', 'cache_dir' => sys_get_temp_dir() . '/haanga_cache/', 'compiler' => array('compiler' => array('if_empty' => false, 'autoescape' => true, 'strip_whitespace' => true, 'allow_exec' => true))));
//new feature adding columns types as commentary.
$infoExtra = array();
foreach ($this->dbInfo as $tablename => $columns) {
$maxArray = count($columns['columns']);
for ($ptr = 0; $ptr < $maxArray; $ptr++) {
$columnName = $columns['columns'][$ptr];
$type = $columns['type'];
$typeName = $type['name'][$ptr];
$typelength = $type['Length'][$ptr];
$infoExtra[$tablename][] = "Column: " . $columnName . " of type " . $typeName . ($typelength != '0' ? "[" . $typelength . "]" : "");
}
}
$c = 0;
//foreach ($this->config['_tables'] as $table => $conf) {
foreach ($this->config['_tables'] as $table => $conf) {
$classname = self::camelize($table, 'class');
$allowedMethods = explode(' ', $conf['ALLOW_METHODS']);
$methods = '';
// Getting data for every method.
foreach ($allowedMethods as $method) {
// validation for a valid method
if (!in_array($method, array('GET', 'POST', 'PUT', 'DELETE'))) {
throw new Exception("Invalid method '{$method}'.");
}
$method = strtoupper($method);
$exposedColumns = array();
$params = array();
$paramsStr = array();
$primaryKeys = array();
// get columns to expose
if (array_key_exists('EXPOSE_COLUMNS_' . $method, $conf)) {
if ($conf['EXPOSE_COLUMNS_' . $method] == '*') {
$exposedColumns = $this->dbInfo[$table]['columns'];
} else {
$exposedColumns = explode(' ', $conf['EXPOSE_COLUMNS_' . $method]);
// validation for valid columns
$tableColumns = $this->dbInfo[$table]['columns'];
foreach ($exposedColumns as $column) {
if (!in_array($column, $tableColumns)) {
throw new Exception("Invalid column '{$column}' for table {$table}, it does not exist!.");
}
}
// validate that all required columns are in exposed columns array
if ($method == 'POST') {
// intersect required columns with exposed columns
// to verify is all required columns are exposed
$intersect = array_intersect($this->dbInfo[$table]['required_columns'], $exposedColumns);
// the diff should be empty
$diff = array_diff($this->dbInfo[$table]['required_columns'], $intersect);
if (!empty($diff)) {
throw new Exception(sprintf("Error: All required columns for table '%s' must be exposed for POST method.\n" . "PLease add all required columns on rule 'EXPOSE_COLUMNS_POST' or select all " . "with '*' selector.\n\n" . "Missing (%s) required fields for [%s] table:\n" . implode("\n", $diff), $table, count($diff), $table));
}
}
}
}
switch ($method) {
case 'GET':
foreach ($this->dbInfo[$table]['pKeys'] as $i => $pk) {
$paramsStr[$i] = "\$" . self::camelize($pk) . '=null';
$params[$i] = self::camelize($pk);
}
break;
case 'PUT':
foreach ($exposedColumns as $i => $column) {
$paramsStr[$i] = "\$" . self::camelize($column);
if (!in_array($column, $this->dbInfo[$table]['pKeys'])) {
$params[$i] = self::camelize($column);
}
}
break;
case 'POST':
foreach ($exposedColumns as $i => $column) {
$paramsStr[$i] = "\$" . self::camelize($column);
$params[$i] = self::camelize($column);
}
break;
}
$paramsStr = implode(', ', $paramsStr);
//.........这里部分代码省略.........