本文整理汇总了PHP中View类的典型用法代码示例。如果您正苦于以下问题:PHP View类的具体用法?PHP View怎么用?PHP View使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了View类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index($room_id)
{
$room = $this->Room->getRoomById($room_id);
$this->set('room', $room);
if (!empty($room)) {
$last_update = time();
$idafter = 0;
$messages = $this->Message->getMessages($room_id);
if (!empty($messages)) {
$messages = array_reverse($messages);
$idafter = $messages[count($messages) - 1]['Message']['message_id'];
}
// Render message list
$view = new View($this, false);
$view->layout = false;
$view->set(compact('messages', $messages));
$view->viewPath = 'Message';
$message_list = $view->render('message_list');
$this->set('message_list', $message_list);
$this->set('idafter', $idafter);
$this->set('last_update', $last_update);
$this->set('title', $room['Room']['name']);
} else {
$this->set('title', 'Room not found!');
}
}
示例2: get_form_xml
/**
* generate xml for a form from a table
*
* @param object $setup
* @return string
* @author Andy Bennett
*/
function get_form_xml($setup)
{
$file_name = $setup->form_name;
$dir = DATAPATH . '/xml/forms/';
$path = $dir . $file_name . '.xml';
if (file_exists($path)) {
return file_get_contents($path);
}
if (!isset($setup->model) || !is_object($setup->model)) {
$config = Kohana::config('controls.controllers');
$name = Kohana::instance()->uri->segment(1);
if (!isset($config->{$name})) {
throw new Exception("No controller set up");
}
$this->set_table($config->{$name}['table']);
} else {
$this->set_table($setup->model->get_table());
$name = $setup->form_name;
}
$field_data = $this->db->field_data($this->table);
// print_r($field_data);
$view = new View('xml/form');
$view->field_data = $field_data;
$view->name = Kohana::instance()->uri->segment(1);
$view->action = Kohana::instance()->uri->segment(2);
$data = $view->render();
if (file_exists($dir)) {
file_put_contents($path, $data);
}
return $data;
}
示例3: __construct
public function __construct($id = false)
{
parent::__construct();
$this->add("products");
$this->name = "form_slider";
$this->enctype = "multipart/form-data";
$this->action = URL::current();
$this->products = ProductDB::getAdminShow();
if (!$id) {
$this->text("title", "Название:");
$this->textarea("description", "Описание:");
$this->submit("insert_slider", "Сохранить");
} else {
$this->add("img");
$this->add("product_id");
$this->hidden("id", $id);
$obj = new SliderDB();
$obj->load($id);
$this->text("title", "Название:", $obj->title);
$img = ProductDB::getCellOnID($obj->product_id, "img");
$view = new View(Config::DIR_TMPL);
$this->img = $view->render("img", array("src" => Config::DIR_IMG_PRODUCT . $img), true);
$this->textarea("description", "Описание:", $obj->description);
$this->submit("update_slider", "Сохранить");
$this->product_id = $obj->product_id;
}
}
示例4: index
public function index($feedtype = 'rss2')
{
if (!Kohana::config('settings.allow_feed')) {
throw new Kohana_404_Exception();
}
if ($feedtype != 'atom' and $feedtype != 'rss2') {
throw new Kohana_404_Exception();
}
// How Many Items Should We Retrieve?
$limit = (isset($_GET['l']) and !empty($_GET['l']) and (int) $_GET['l'] <= 200) ? (int) $_GET['l'] : 20;
// Start at which page?
$page = (isset($_GET['p']) and !empty($_GET['p']) and (int) $_GET['p'] >= 1) ? (int) $_GET['p'] : 1;
$page_position = $page == 1 ? 0 : $page * $limit;
// Query position
$site_url = url::base();
// Cache the Feed with subdomain in the cache name if mhi is set
$subdomain = '';
if (substr_count($_SERVER["HTTP_HOST"], '.') > 1 and Kohana::config('config.enable_mhi') == TRUE) {
$subdomain = substr($_SERVER["HTTP_HOST"], 0, strpos($_SERVER["HTTP_HOST"], '.'));
}
$cache = Cache::instance();
$feed_items = $cache->get($subdomain . '_feed_' . $limit . '_' . $page);
if ($feed_items == NULL) {
// Cache is Empty so Re-Cache
$incidents = ORM::factory('incident')->where('incident_active', '1')->orderby('incident_date', 'desc')->limit($limit, $page_position)->find_all();
$items = array();
foreach ($incidents as $incident) {
$categories = array();
foreach ($incident->category as $category) {
$categories[] = (string) $category->category_title;
}
$item = array();
$item['id'] = $incident->id;
$item['title'] = $incident->incident_title;
$item['link'] = $site_url . 'reports/view/' . $incident->id;
$item['description'] = $incident->incident_description;
$item['date'] = $incident->incident_date;
$item['categories'] = $categories;
if ($incident->location_id != 0 and $incident->location->longitude and $incident->location->latitude) {
$item['point'] = array($incident->location->latitude, $incident->location->longitude);
$items[] = $item;
}
}
$cache->set($subdomain . '_feed_' . $limit . '_' . $page, $items, array('feed'), 3600);
// 1 Hour
$feed_items = $items;
}
$feedpath = $feedtype == 'atom' ? 'feed/atom/' : 'feed/';
header('Content-Type: application/' . ($feedtype == 'atom' ? 'atom' : 'rss') . '+xml; charset=utf-8');
$view = new View('feed/' . $feedtype);
$view->feed_title = Kohana::config('settings.site_name');
$view->site_url = $site_url;
$view->georss = 1;
// this adds georss namespace in the feed
$view->feed_url = $site_url . $feedpath;
$view->feed_date = gmdate("D, d M Y H:i:s T", time());
$view->feed_description = Kohana::lang('ui_admin.incident_feed') . ' ' . Kohana::config('settings.site_name');
$view->items = $feed_items;
$view->render(TRUE);
}
示例5: envoyer
/**
* Methode : page envoyer le mailing
*/
public function envoyer()
{
if ($_POST) {
$texte = $this->input->post('texte');
$format = $this->input->post('format');
$sujet = $this->input->post('sujet');
$format = $format == 1 ? TRUE : FALSE;
$users = $this->user->select();
$nbr_envois = 0;
foreach ($users as $user) {
if ($format) {
$view = new View('mailing/template');
$view->name = ucfirst(mb_strtolower($user->username));
$view->content = $texte;
$message = $view->render();
} else {
$message = $texte;
}
if (email::send($user->email, Kohana::config('email.from'), $sujet, $message, $format)) {
$nbr_envois++;
}
}
return url::redirect('mailing?msg=' . urlencode(Kohana::lang('mailing.send_valide', number_format($nbr_envois))));
} else {
return parent::redirect_erreur('mailing');
}
}
示例6: addedAction
protected function addedAction($title, $content)
{
ArticlesModel::add($title, $content);
$view = new View();
$view->item = $single_article;
$view->display('NewAddedArticle.php');
}
示例7: indexAction
public function indexAction()
{
$view = new View("DJView");
$view->setViewPath(APPLICATION_PATH . DIRECTORY_SEPARATOR . "views");
$view->setAttribute("beatModel", $this->beatModel);
return $view;
}
示例8: _send_reset
private function _send_reset($form)
{
$user_name = $form->reset->inputs["name"]->value;
$user = user::lookup_by_name($user_name);
if ($user && !empty($user->email)) {
$user->hash = random::hash();
$user->save();
$message = new View("reset_password.html");
$message->confirm_url = url::abs_site("password/do_reset?key={$user->hash}");
$message->user = $user;
Sendmail::factory()->to($user->email)->subject(t("Password Reset Request"))->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=UTF-8")->message($message->render())->send();
log::success("user", t("Password reset email sent for user %name", array("name" => $user->name)));
} else {
if (!$user) {
// Don't include the username here until you're sure that it's XSS safe
log::warning("user", t("Password reset email requested for user %user_name, which does not exist.", array("user_name" => $user_name)));
} else {
log::warning("user", t("Password reset failed for %user_name (has no email address on record).", array("user_name" => $user->name)));
}
}
// Always pretend that an email has been sent to avoid leaking
// information on what user names are actually real.
message::success(t("Password reset email sent"));
json::reply(array("result" => "success"));
}
示例9: actionShowLesson
public function actionShowLesson()
{
$auth = Auth::checkAuth();
$view = new View();
$view->auth = $auth;
if (!isset($_GET['id'])) {
header("Location: /learns/");
}
if ($auth) {
$user = Auth::getUser();
$id = $_GET['id'];
$lesson = Lessons::getLesson($id);
$course = Courses::getCourse($lesson->course_id);
$lesson_prew = Lessons::getLessonByNumber($lesson->lesson_number - 1, $lesson->course_id);
$lesson_next = Lessons::getLessonByNumber($lesson->lesson_number + 1, $lesson->course_id);
$view->user_login = $user->user_login;
$view->user_group = $user->user_group;
$view->lesson = $lesson;
$view->course = $course;
$view->lesson_prew = $lesson_prew;
$view->lesson_next = $lesson_next;
$view->display('header.php');
$view->display('lessons/lesson_view.php');
$view->display('footer.php');
} else {
header("Location: /learns/");
}
}
示例10: index
/**
* index method
*/
public function index()
{
if ($this->param['method'] == 'POST') {
$result = null;
switch ($this->param['action']) {
case 'create':
$result = $this->transaction('create', $_POST);
break;
case 'modify':
$result = $this->transaction('modify', $_POST);
break;
case 'remove':
$result = $this->transaction('remove', $_POST);
break;
case 'sort':
$result = $this->transaction('sort', $_POST);
break;
}
if ($result) {
Module::afterAction($result);
}
Goose::end();
} else {
require_once __GOOSE_PWD__ . $this->path . 'view.class.php';
$view = new View($this);
$view->render();
}
}
示例11: create
/**
* Generates a model for a given schema
*
* @usage ./metal model/create --database=default --schema=public --table=user --related
* @switch database The name of the database in the conf file
* @switch schema The name of the schema, default is 'public'
* @switch table The name of the table to generate the model for
* @switch related Boolean determines if any related models should be generated.
*/
public function create()
{
$db = Database::Get($this->request->input->database);
$schemaName = $this->request->input->schema ? $this->request->input->schema : 'public';
$schema = $db->table($schemaName, $this->request->input->table, $this->request->input->related);
$rel_classname = '';
$names = explode('_', $this->request->input->table);
foreach ($names as $n) {
$rel_classname .= ucfirst($n);
}
$view = new View('index.html', $this, PATH_SYS . 'shell/view/model/');
$model = $view->render(array('classname' => $rel_classname, 'schema' => $schema, 'database' => $this->request->input->database));
$path = PATH_APP . 'model/' . $schemaName;
if (!file_exists($path)) {
mkdir($path);
}
file_put_contents($path . '/' . $schema->tablename . EXT, $model);
foreach ($schema->related as $table) {
$rel_classname = '';
$names = explode('_', $table->tablename);
foreach ($names as $n) {
$rel_classname .= ucfirst($n);
}
$model = $view->render(array('classname' => $rel_classname, 'schema' => $table, 'database' => $this->request->input->database));
$path = PATH_APP . 'model/' . $table->schema;
if (!file_exists($path)) {
mkdir($path);
}
file_put_contents($path . '/' . $table->tablename . EXT, $model);
}
die;
}
示例12: template
/**
* Demonstrates how to use views inside of views.
*/
function template()
{
$data = array('title' => 'View-in-View Example', 'content' => 'This is my view-in-view page content.', 'copyright' => '© 2007 Kohana Team');
$view = new View('viewinview/container', $data);
$view->header = new View('viewinview/header', $data);
$view->render(TRUE);
}
示例13: _add_report_filter_ui
/**
* This little guy will add the UI to the /reports page so we can switch between AND and OR
*/
public function _add_report_filter_ui()
{
$operator = $this->_get_logical_operator();
$view = new View('adminmap/report_filter_ui');
$view->operator = $operator;
$view->render(true);
}
示例14: items
function items($name = '', $payload = '')
{
// Protect this handler
if (!$this->authorized()) {
redirect('auth/login');
}
$data['profile_items'] = array();
$data['name'] = 'No item';
if ($name) {
$name = rawurldecode($name);
$profile_item_obj = new Profile_model();
$data['profile_name'] = $name;
if ($payload) {
$payload = rawurldecode($payload);
$items = $profile_item_obj->retrieve_many('payload_name = ? GROUP BY serial_number', array($payload));
$data['name'] = $payload;
} else {
$items = $profile_item_obj->retrieve_many('profile_name = ? GROUP BY serial_number', array($name));
$data['name'] = $name;
}
foreach ($items as $item) {
$machine = new Machine_model($item->serial_number);
$instance['serial'] = $item->serial_number;
$instance['hostname'] = $machine->computer_name;
$instance['payload'] = $item->profile_name;
$data['profile_items'][] = $instance;
}
}
$obj = new View();
$obj->view('profile/profileitem_detail', $data);
}
示例15: build
function build()
{
$result='';
$rendered='';
$resultfilter = new $this->filter_class();
$resultfilter->controller = $this->controller;
$resultfilter->datasource = $this->datasource;
foreach($this->controller->appmeta->filter as $field => $filter) {
if ($filter->hidden != 'true') {
$resultfilter->clear();
$resultfilter->field = $field;
$resultfilter->datasource = $this->datasource;
$resultfilter->init();
$rendered .= $resultfilter->build();
}
}
if (!empty($this->container_template))
{
$view=new View($this->container_template,$this->controller);
$result=$view->render(array('meta'=>$this->controller->appmeta, 'control' => $this, 'content' => $rendered));
}
else
{
$result=$rendered;
}
return $result;
}