本文整理汇总了PHP中Flight::view方法的典型用法代码示例。如果您正苦于以下问题:PHP Flight::view方法的具体用法?PHP Flight::view怎么用?PHP Flight::view使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Flight
的用法示例。
在下文中一共展示了Flight::view方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: error_reporting
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once 'flight/flight/Flight.php';
require_once 'ipsp-php/autoload.php';
Flight::set('flight.views.path', 'templates');
Flight::set('layout', 'layout/default');
Flight::set('appname', 'IPSP PHP Examples');
Flight::set('apptitle', 'Api');
Flight::register('ipsp', 'Ipsp_Api', array(new Ipsp_Client(1000, 'test', 'api.oplata.com')));
Flight::map('output', function ($content = NULL) {
Flight::view()->set('ipsp', Flight::ipsp());
Flight::render($content, array(), 'content');
Flight::render(Flight::get('layout'));
});
Flight::route('/', function () {
Flight::output('pages/frontpage');
});
Flight::route('/page/@page(/@order_id)', function ($page = 'notfound', $order_id = NULL) {
Flight::view()->set('order_id', $order_id);
Flight::output(sprintf('pages/%s', $page));
});
Flight::route('/modal/@page', function ($page = 'notfound') {
Flight::view()->set('ipsp', Flight::ipsp());
Flight::render(sprintf('modal/%s', $page));
});
Flight::route('/api/checkout', function () {
$data = Flight::request()->data;
});
Flight::start();
示例2: __construct
/**
* Constructor
*/
public function __construct($install)
{
parent::__construct($install);
if (F::has('pageinfos')) {
F::view()->assign(array('pageinfos' => Files::getPageInfos(F::get('pageinfos')['cat'], F::get('pageinfos')['page'])));
}
}
示例3: checkAdmin
/**
* check if user is logged in as admin
*/
private function checkAdmin()
{
$admin = false;
if (isset($_SESSION['admin'])) {
F::set('admin', 1);
$admin = true;
}
F::view()->assign(array('admin' => $admin));
}
示例4: testDefaultComponents
function testDefaultComponents()
{
$request = Flight::request();
$response = Flight::response();
$router = Flight::router();
$view = Flight::view();
$this->assertEquals('flight\\net\\Request', get_class($request));
$this->assertEquals('flight\\net\\Response', get_class($response));
$this->assertEquals('flight\\net\\Router', get_class($router));
$this->assertEquals('flight\\template\\View', get_class($view));
}
示例5: bootstrap
/**
* bootstrap
* for framework bootstrap.
*/
public static function bootstrap()
{
//route
require APP_PATH . '/routes.php';
//set timezone
$timezone = env('APP_TIMEZONE', 'Asia/Shanghai');
date_default_timezone_set($timezone);
//filters
if (get_magic_quotes_gpc()) {
$_GET = self::stripslashesDeep($_GET);
$_POST = self::stripslashesDeep($_POST);
$_COOKIE = self::stripslashesDeep($_COOKIE);
}
$_REQUEST = array_merge($_GET, $_POST, $_COOKIE);
/*--
Flight maps start
--*/
//log
Flight::map('log', [__CLASS__, 'log']);
//db : database
Flight::map('db', [__CLASS__, 'db']);
//model
Flight::map('model', [__CLASS__, 'getModel']);
//cache
Flight::map('cache', [__CLASS__, 'cache']);
//get controller
Flight::map('controller', [__CLASS__, 'getController']);
//halt response
Flight::map("halt", array(__CLASS__, "halt"));
//404 error
Flight::map('notFound', function () {
//Flight::log()->error(Flight::request()->ip.': '.Flight::request()->method.' '.Flight::request()->url.' not Found !');
Flight::log()->error('404 NOT FOUND !', json_decode(json_encode(Flight::request()), true));
return self::halt(Flight::view()->fetch('404'), '404');
});
/*
Flight::map('error', function(Exception $ex){
// Handle error
Flight::log()->error('500 Error : '.$ex->getTraceAsString());
echo $ex->getTraceAsString();
});
*/
/*--
Flight maps end
--*/
}
示例6: debug
/**
* ===============================================
* debug
* ===============================================
*/
function debug($var)
{
# serialize()
$serial = serialize($var);
# print_r()
$print_r = print_r($var, true);
# var_dump()
ob_start();
var_dump($var);
$var_dump = ob_get_clean();
ob_end_clean();
# var_export()
$var_export = var_export($var, true);
\Flight::view()->assign(array('serial' => $serial, 'print_r' => $print_r, 'var_dump' => $var_dump, 'var_export' => $var_export));
\Flight::render('debug.html');
exit;
}
示例7: if
<h2><?if($item->title) : ?><?php
echo $item->title;
?>
<? else : ?>Untitled<?endif?></h2>
<div class="col-md-5 col-xs-12">
<? if($item->imageUrl()) : ?>
<div class="imageWrap center-block row">
<img src="<?php
echo $item->imageUrl();
?>
" class="mainImage img-responsive">
</div>
<?endif?>
</div>
<div class="col-md-6 col-xs-12">
<? Flight::view()->render('frontend/imageBox', array('item' => $item)) ?>
<? Flight::view()->render('frontend/template/listing', array('item' => $item)) ?>
</div>
<?endif?>
<div class="clearfix"></div>
<script>
+function ($) {
$(document).ready(function(){
$('.entry-title').css('display',"none");
});
}(jQuery);
</script>
示例8: getFeaturedCollection
/**
* Create a short code to load a real time list of items from ArtMoi
* @param $args
* @return mixed
*/
public function getFeaturedCollection($args)
{
// Detect devices
$isMobile = false;
if (wp_is_mobile()) {
$isMobile = true;
}
wp_reset_postdata();
wp_enqueue_script('items', plugins_url('ArtMoiWP/scripts/collection.js'));
$this->artmoiwp_creationpage = get_option('artmoiwp_creationpage');
global $post;
$postId = $post->ID;
// the post ID in edit , not published
$artmoi = Flight::artmoi();
$controller = 'collection';
$action = $args['collection'];
$response = $artmoi->call($controller, $action);
$templateType = get_post_meta($postId, 'templateType', true);
if (!$templateType) {
$templateType = 'collection';
update_post_meta($postId, 'templateType', "collection");
}
$items = $response->itemResults();
Flight::render('frontend/modal', array('items' => $items, 'creationPostId' => $this->artmoiwp_creationpage, 'isMobile' => $isMobile), 'modal');
$output = Flight::view()->fetch('frontend/template/' . $templateType, array('items' => $items));
return $output;
}
示例9: render
public function render(Page $page)
{
return Flight::view()->display($page->getTemplate(), $page->getTemplateData());
}
示例10: elseif
} elseif (is_file($path . '/../config.php')) {
require_once $path . '/../config.php';
} else {
echo "Invalid config file.";
die;
}
// Register classes with Flight
Flight::register('artmoiController', 'ArtMoi_Controller');
Flight::register('artmoiRequest', 'ArtMoi_Request');
Flight::register('artmoiResponse', 'ArtMoi_Response');
Flight::register('artmoiContact', 'ArtMoi_Controller_Contact');
// 404 Error page
Flight::map('notFound', function () {
Flight::view()->set('errorCode', "404");
Flight::view()->set('message', "Sorry! 404 Page not Found");
Flight::view()->set('pageTitle', "404 Page not Found");
Flight::render('404');
});
// Contact Page
Flight::route('/contact', function () {
// TODO:: We will need to include the form validation as optional because anyone downloading this project will need to obtain thier own license...
$js = array("https://v1.artmoi.me/vendor/formvalidation/dist/js/formValidation.min.js", "https://v1.artmoi.me/vendor/formvalidation/dist/js/framework/bootstrap.min.js", "//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.min.js", "/scripts/contact.js");
$css = array("https://v1.artmoi.me/vendor/formvalidation/dist/css/formValidation.min.css", "//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/css/select2.min.css");
$contact = Flight::artmoiContact()->action_contactPoints();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (MANDRILL_API_KEY != null) {
Flight::artmoiContact()->action_mandrill();
} else {
Flight::artmoiContact()->action_sendMail();
}
}
示例11: array
// Add the debug extension
});
/**
* Initiate ActiveRecord
*/
ActiveRecord\Config::initialize(function ($cfg) {
$cfg->set_model_directory('./models');
$cfg->set_connections(array('development' => 'mysql://root:root@localhost/test'));
$cfg->set_default_connection('development');
});
/**
* Add /controllers to the include-path
*/
Flight::path(dirname(__FILE__) . '/controllers');
Flight::route('/', array('IndexController', 'index'));
Flight::route('/test', function () {
echo "hello!";
});
Flight::route('/test-user', function () {
$user = new User();
$user->firstname = 'Marcus';
$user->surname = 'Olsson';
$user->email = 'trash@dumpster.com';
$user->save();
print_r(User::last());
});
Flight::route('/hello', function () {
$data = array('name' => Flight::request()->query->name);
Flight::view()->display('template.html', $data);
});
Flight::start();
示例12: index
/**
* index
* 统计方法
*
* @var string
*/
public static function index()
{
// 验证登录态
self::__verify_user_auth();
// 获取参数
$id = Flight::request()->query->id;
$orderby = Flight::request()->query->orderby;
$order = Flight::request()->query->order;
// 获取配置
$conf = Util::get_conf_data();
// 没有要展示的统计默认展示第一个
if (!$id && is_array($conf)) {
$tmp_conf = $conf;
$first_conf = array_shift($tmp_conf);
$id = $first_conf['id'];
Flight::view()->set('stats_id', $id);
}
// 根据语句处理拼接要是统计的数据
$render_data = array();
foreach ($conf as $k => $data) {
if ($data['id'] == $id) {
// 根据参数整理sql语句
$orderby_sql = '';
if ($orderby && $data['field_names'][$orderby]) {
if (!in_array($order, array('DESC', 'ASC'))) {
$order = 'DESC';
}
$orderby_sql = ' ORDER BY ' . $orderby . ' ' . $order;
}
$links = $data['links'];
// 根据参数拼接limit
$limit_sql = '';
$date = array();
if ($data['time_range']) {
switch ($data['time_range']) {
case 'last_month_date':
$limit_sql = ' LIMIT 0,31';
$date = self::__last_day($data['time_range']);
break;
default:
break;
}
}
// 拼接sql并且进行查询
$sqls = $data['sqls'];
$sql = $data['sql'];
$params = array();
$db = Flight::$data['database_service_name']();
// 拼接sql获取数据
$rebuilt_rows = array();
if ($sqls) {
foreach ($sqls as $sql_value) {
$rows_data[] = self::__get_rows($db, $sql_value['sql'], $sql_value['query_string'], $limit_sql, $orderby_sql);
}
} else {
$rebuilt_rows = self::__get_rows($db, $sql, $data['query_string'], $limit_sql, $orderby_sql);
}
// 获取要显示的字段
$field_names = $data['field_names'];
// 处理数据集合
if ($rows_data) {
$same_field = $data['same_field'];
// 将统一的字段是按照最近30天还是最近7天附上值
foreach ($date as $date_value) {
$rebuilt_rows[$date_value] = array();
}
// 整理rows进行合并
foreach ($rows_data as $row) {
// 判断是否有row
if ($row) {
foreach ($row as $value) {
// 判断时间内是否有我最近30天的数据
if (in_array($value[$same_field], $date)) {
$rebuilt_rows[$value[$same_field]] = array_merge($value, $rebuilt_rows[$value[$same_field]]);
}
}
}
}
// 再整理一下rows_data数据
foreach ($rebuilt_rows as $key => $rebuilt_row) {
foreach ($field_names as $field_name_key => $field_name) {
if ($field_name_key == $same_field) {
$rebuilt_rows[$key][$same_field] = $key;
} else {
if (!$rebuilt_row[$field_name_key]) {
$rebuilt_rows[$key][$field_name_key] = 0;
}
}
}
}
}
// 拼接统计数据
if ($data['charts'] && $rebuilt_rows) {
$chart_data = array();
//.........这里部分代码省略.........
示例13: array_walk_recursive
// Including values from config.yml
$config = Spyc::YAMLLoad(__DIR__ . '/../app/config/config.yml');
// Flight
array_walk_recursive($config['flight'], function ($value, $key) {
Flight::set($key, eval('return ' . $value . ';'));
});
// Registering Smarty as template engine
Flight::register('view', 'Smarty', array(), function ($smarty) {
$smarty->template_dir = Flight::get('flight.views.path') . '/';
$smarty->compile_dir = __DIR__ . '/../app/cache/smarty_compile/';
$smarty->config_dir = __DIR__ . '/../app/config/smarty/';
$smarty->cache_dir = __DIR__ . '/../app/cache/smarty_cache/';
});
Flight::map('render', function ($template, $data) {
Flight::view()->assign($data);
Flight::view()->display($template);
});
//personnalizing errors
Flight::map('notFound', function () {
if (file_exists(Flight::get('flight.views.path') . '/Errors/404.tpl')) {
Flight::render('Errors/404.tpl', array());
} else {
Flight::_notFound();
}
});
Flight::map('error', function (\Exception $e) {
$code = http_response_code();
if ($code == 200) {
$code = 500;
}
if (file_exists(Flight::get('flight.views.path') . '/Errors/' . $code . '.tpl')) {
示例14: error_reporting
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING & ~E_DEPRECATED & ~E_STRICT);
session_start();
require dirname(dirname(dirname(__FILE__))) . '/vendor/autoload.php';
define('APPS_PATH', dirname(dirname(__FILE__)));
define('TEMP_PATH', APPS_PATH . '/temp');
define('CONF_PATH', APPS_PATH . '/conf');
define('VIEWS_PATH', APPS_PATH . '/views');
define('PLUGINS_PATH', APPS_PATH . '/plugins');
// config
// Flight::register('db', 'PDO', array('mysql:host=www.jiangjianyong.cn;dbname=happy_days','root','pass'));
Flight::register('view', 'Smarty', array(), function ($smarty) {
$smarty->setTemplateDir(VIEWS_PATH);
$smarty->setConfigDir(CONF_PATH);
$smarty->setCompileDir(TEMP_PATH . '/runtime/templates_c/');
$smarty->setCacheDir(TEMP_PATH . '/runtime/cache/');
$smarty->addPluginsDir(PLUGINS_PATH . '/views');
});
Flight::set('flight.log_errors', true);
// map
/**
AppID(应用ID)wxe35b746417e44c20
AppSecret(应用密钥)dd5a5838ab842d0be3d2a51a1798b9cb 隐藏 重置
*/
Flight::map('config', function ($item = null) {
return 100;
});
Flight::route('/', function () {
Flight::view()->assign('name', 'Bob');
Flight::view()->display('index.html');
});
Flight::start();
示例15: shortcode_menu_date
/**
* // Create Short Code for displaying an date Menu
* @param $atts
* @return mixed
*/
public function shortcode_menu_date($atts)
{
wp_reset_postdata();
global $post;
$link = get_permalink($post->ID);
$atts = shortcode_atts(array('range_start' => '1990', 'range_end' => '2015', 'groupby' => 0), $atts, 'am_menu_date');
$dates = array();
if ($atts['groupby']) {
$groupby = $atts['groupby'];
$start = $atts['range_start'];
$end = $atts['range_end'];
$last = $start;
while ($last <= $end) {
$set_start = $last;
$set_end = $last + $groupby;
if ($set_end > $end) {
$set_end = $end;
}
$dates[] = $set_start . ' - ' . $set_end;
$last = $set_end + 1;
}
} else {
$dates = range($atts['range_start'], $atts['range_end']);
}
return Flight::view()->render('frontend/menu/date', array('dates' => $dates, 'link' => $link));
}