本文整理汇总了PHP中View::assign方法的典型用法代码示例。如果您正苦于以下问题:PHP View::assign方法的具体用法?PHP View::assign怎么用?PHP View::assign使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类View
的用法示例。
在下文中一共展示了View::assign方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionOne
public function actionOne()
{
$id = isset($_GET['id']) ? $_GET['id'] : 1;
$view = new View();
$page = new PageController();
$view->assign('item', News::getOne($id));
$view->assign('links', $page->createLink($this->ctrl));
$view->display($this->view_one);
}
示例2: messageAction
/**
* Messages Example
* @return null
*/
public function messageAction()
{
$View = new View('examples/message');
$View->assign('_title_', _('Message Examples'));
$View->assign('_message_', "Ejemplo de como abrir un mensaje desde el controlador");
$View->display();
}
示例3: multipageAction
/**
* multiple page thingy
* @return null
*/
public function multipageAction()
{
$Request = Request::getInstance();
$template = $Request->template;
$pages = array('intro' => 'Introducción', 'mvc' => 'Model View Controller', 'layer' => 'Good Cake, Bad Cake', 'diagram_simplified' => 'Diagrama', 'diagram' => 'Diagrama Extendido', 'credits' => 'Creditos');
$links = '<p>';
foreach ($pages as $page => $name) {
$links .= "<a href=\"" . BASE_URL . "/index/multipage/?template={$page}\">{$name}</a> ";
}
$links .= "</p>";
$View = new View("index/{$template}");
$View->assign('_title_', $pages[$template]);
$View->assign('links', $links);
$View->display();
}
示例4: index
function index()
{
$chart_pie = $chart_line = null;
//love easy
$this->load_library("Charts");
$data = array(array('OSX', 10), array('Win', 3), array('Unix', 7));
$this->Charts->set_data($data);
//$chart_pie = $this->Charts->draw_pie();
$this->Charts->load_csv(WEBSITE_DIR . "assign_execution_time.csv");
$chart_line = $this->Charts->draw_line();
$tpl = new View();
$tpl->assign("chart_pie", $chart_pie);
$tpl->assign("chart_line", $chart_line);
$tpl->draw("charts/charts");
}
示例5: display
public function display()
{
$view = new View();
$view->setTemplate('header');
$view->assign('title', 'openmuseum');
return $view->loadTemplate();
}
示例6: hookModuleOutputBottom
/**
* hook: module_output_bottom
* Show comments and comments form
*
* @param array $msc
* @param int $contentType
* @param string $sector
* @param string $title
* @return mixed
*/
public function hookModuleOutputBottom(array $mcs, $contentType, $sector, $title)
{
if ($sector == 'SC' && $contentType & Zula_ControllerBase::_OT_CONTENT_DYNAMIC && !($contentType & Zula_ControllerBase::_OT_CONFIG)) {
$requestPath = $this->_router->getRequestPath(Router::_TRIM_ALL);
$view = new View('display/linear.html', 'comments');
$view->assign(array('TITLE' => $title));
$view->assignHtml(array('COMMENTS' => $this->_model('comments', 'comments')->get($requestPath)));
if ($this->_acl->check('comments_post')) {
/**
* Store the hash path as a valid comment path, then build the
* form view and output both views
*/
$hashPath = zula_hash($requestPath);
$_SESSION['mod']['comments'][$hashPath] = array('path' => $requestPath, 'siteType' => $this->_router->getSiteType());
$form = new View('form.html', 'comments');
$form->assign(array('comments' => array('hash' => $hashPath, 'name' => $this->_session->getUser('username'), 'website' => null, 'body' => null)));
// Antispam/Captcha
$antispam = new Antispam();
$form->assignHtml(array('CSRF' => $this->_input->createToken(true), 'ANTISPAM' => $antispam->create()));
return $view->getOutput() . $form->getOutput();
} else {
return $view->getOutput();
}
}
}
示例7: indexAction
/**
* indexAction
*
* Index action of main controller forum module
*
* @return null
*/
public function indexAction()
{
// assign data into view
\View::assign(array('title' => \View::$language->forum_main_title, 'h1' => \View::$language->forum_main_title, 'forumsTree' => helpers\ForumsTreeHelper::getTree()));
// set output layout
\View::setLayout('forum-main.phtml');
}
示例8: action_index
/**
* 首页
*+----------------------------
* http://yourdomain/index.php/
*/
public function action_index()
{
//实例化一个视图对象
$view = new View('index.php');
$view->assign('title', 'hello world')->render();
//绑定变量并渲染视图
}
示例9: Index
public static function Index(View $page) {
$dir = $page->getParameter('directory');
if (!$dir) {
$page->error = View::ERROR_BADREQUEST;
return;
}
////// Security checks...
// Usage of '..' is explicitly denied, as it can escape the filesystem.
if (strpos($dir, '../') !== false) {
$page->error = View::ERROR_BADREQUEST;
return;
}
// Directory must contain at least one directory in.
// And it also must start with public/
if (!preg_match('/^public\/[a-z0-9]+/', $dir)) {
$page->error = View::ERROR_BADREQUEST;
return;
}
// Now I can finally start the actual logic.
$d = Core::Directory($dir);
if (!$d->isReadable()) {
$page->error = View::ERROR_NOTFOUND;
return;
}
$page->assign('files', $d->ls());
}
示例10: assign
/**
* Assign a variable to the template.
*
* @param string|array $tpl_var
* @param mixed $value
* @return \Smarty_Internal_Data
*/
public function assign($tpl_var, $value)
{
if ($tpl_var != 'modules') {
$this->addToDebug($tpl_var, $value, 'assigns');
}
return $this->view->assign($tpl_var, $value);
}
示例11: display
public function display()
{
$view = new View();
$view->setTemplate('navBar');
$view->assign('active', $this->active);
return $view->loadTemplate();
}
示例12: main
public function main()
{
//Create a new view and pass it our template
$view = new View(strtolower($this->viewfile));
//Assign Page Variable
$view->assign('var1', 'About page variable.');
}
示例13: testCss
/**
* CSSの読み込みタグを出力する
*/
public function testCss()
{
// ノーマル
ob_start();
$this->BcBaser->css('admin/import');
$result = ob_get_clean();
$expected = '<link rel="stylesheet" type="text/css" href="/css/admin/import.css" />';
$this->assertEqual($result, $expected);
// 拡張子あり
ob_start();
$this->BcBaser->css('admin/import.css');
$result = ob_get_clean();
$expected = '<link rel="stylesheet" type="text/css" href="/css/admin/import.css" />';
$this->assertEqual($result, $expected);
// インラインオフ(array)
$this->BcBaser->css('admin/import.css', array('inline' => false));
$expected = '<link rel="stylesheet" type="text/css" href="/css/admin/import.css" />';
$result = $this->_View->Blocks->get('css');
$this->assertEqual($result, $expected);
$this->_View->Blocks->end();
// インラインオフ(boolean)
$this->BcBaser->css('admin/import.css', false);
$expected = '<link rel="stylesheet" type="text/css" href="/css/admin/import.css" />';
$this->_View->assign('css', '');
$this->assertEqual($result, $expected);
}
示例14: actionOne
public function actionOne()
{
$id = $_GET['id'];
$item = News::getOne($id);
$view = new View();
$view->assign('item', $item);
$view->display('news/one.php');
}
示例15: testCallMethodOnView
public function testCallMethodOnView()
{
View::useLib('Mock');
$view = new View();
$view->assign('chuck', 'norris');
$this->assertEqual(1, count(MockView::$var));
$this->assertEqual('norris', MockView::$var['chuck']);
}