本文整理汇总了PHP中View::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP View::fetch方法的具体用法?PHP View::fetch怎么用?PHP View::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类View
的用法示例。
在下文中一共展示了View::fetch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDisplayFor
public function testDisplayFor()
{
$View = new View();
$View->Session = $this->getMock('SessionHelper', array('read'));
$View->request = $this->getMock('CakeRequest', array('_readInput'));
$View->request->addParams(array('models' => array('Article' => array()), 'controller' => 'articles', 'action' => 'view'));
$Ratings = $this->getMock('RatingsHelper', array('getRandomId'), array($View));
$Ratings->Session = $View->Session;
$Ratings->setModels(array('Article' => 'Content.Article'));
$Ratings->expects($this->once())->method('getRandomId')->will($this->returnValue(666));
$data = array('Article' => array('id' => 1), 'RatingSummary' => array('total_rating' => 3.5, 'total_votes' => 42));
$result_html = $Ratings->display_for($data);
$result_script = $View->fetch('script_execute');
$expected = array('tag' => 'div', 'attributes' => array('class' => 'rating'), 'child' => array('tag' => 'div', 'id' => 'rating-666', 'attributes' => array('class' => 'rateit bigstars')), 'children' => array('count' => 2));
$this->assertTag($expected, $result_html);
$expected = array('tag' => 'span', 'id' => 'message-666', 'attributes' => array('class' => 'rating-message'));
$this->assertTag($expected, $result_html);
$expected = array('tag' => 'span', 'id' => 'values-666', 'attributes' => array('class' => 'rating-values'), 'child' => array('tag' => 'span', 'content' => '3.50', 'attributes' => array('class' => 'rating')), 'children' => array('count' => 2, 'only' => array('tag' => 'span')));
$this->assertTag($expected, $result_html);
$expected = array('tag' => 'span', 'content' => '42', 'attributes' => array('class' => 'votes'));
$this->assertTag($expected, $result_html);
$this->assertRegExp('/\\$\\(\'#rating-666\'\\).rateit\\({/', $result_script);
$this->assertRegExp('/readonly: false/', $result_script);
$this->assertRegExp('/\\$\\(\'#rating-666\'\\).rateit\\(\'value\', 3.5\\);/', $result_script);
$this->assertRegExp('#url: \'/feedback/ratings/add/Content.Article/1\'#', $result_script);
$this->assertRegExp('/foreign_model: \'Article\',/', $result_script);
}
示例2: testJsNonInline
/**
* JSの読み込みタグを出力する(インラインオフ)
*
* @return void
*/
public function testJsNonInline()
{
// インラインオフ(boolean)
$this->BcBaser->js('admin/function', false);
$expected = '<script type="text/javascript" src="/js/admin/function.js"></script>';
$result = $this->_View->fetch('script');
$this->assertEquals($expected, $result);
}
示例3: fetch
protected function fetch($tpl = '', $data = [])
{
$tpl = $tpl ?: $this->router['tpl'];
if (method_exists($this, '__DisplayPre')) {
$this->__DisplayPre();
}
//hook
return $this->_view->fetch($tpl, $data);
}
示例4: fetch
/**
* Returns the HTML of a smarty template or false if was impossible to fetch.
*
* @param string $template
* @return boolean
*/
public function fetch($template)
{
try {
$template = $this->getTemplate($template);
$this->assignCommonVars();
return $this->view->fetch($template);
} catch (Exception_Configuration $e) {
return false;
}
}
示例5: fieldsDisplay
public function fieldsDisplay($rid = 0)
{
//要嵌入规则编辑页的自定义内容,这里 $rid 为对应的规则编号,新增时为 0
$contents = [];
if ($rid) {
//编辑时读取原数据
$contents = Db::table('reply_basic')->where('rid', $rid)->get();
}
View::with('contents', json_encode($contents ?: []));
return View::fetch($this->template . '/fieldsDisplay.html');
}
示例6: render
public function render($template, $_vars = array(), $fetch = false)
{
$view = new View($template);
$this->addVars($_vars);
foreach ($this->vars as $key => $var) {
$view->assign($key, $var);
}
if ($fetch === true) {
return $view->fetch($view->getTemplate());
}
$view->display($view->getTemplate());
return true;
}
示例7: testJs
/**
* JSの読み込みタグを出力する
*/
public function testJs()
{
// ノーマル
ob_start();
$this->BcBaser->js('admin/startup');
$result = ob_get_clean();
$expected = '<script type="text/javascript" src="/js/admin/startup.js"></script>';
$this->assertEqual($result, $expected);
// 拡張子あり
ob_start();
$this->BcBaser->js('admin/startup.js');
$result = ob_get_clean();
$expected = '<script type="text/javascript" src="/js/admin/startup.js"></script>';
$this->assertEqual($result, $expected);
// インラインオフ(boolean)
$this->BcBaser->js('admin/function', false);
$expected = '<script type="text/javascript" src="/js/admin/function.js"></script>';
$result = $this->_View->fetch('script');
$this->assertEqual($result, $expected);
}
示例8: _extend
public function _extend($attr, $content, &$view)
{
if (strchr($attr['file'], '.blade')) {
$obj = new View();
return $obj->fetch($attr['file']);
}
}
示例9: elseif
$message = $MessageController->gameResult($cards);
$sMainContentView = $CardsView->getCards($cards, $message);
} elseif (isset($_POST['stand'])) {
$previousRound = $_SESSION['cards'];
$previousRound['user_id'] = $_POST['userId'];
$cards = $CardsController->stand($previousRound);
$message = $MessageController->gameResult($cards);
$sMainContentView = $CardsView->getCards($cards, $message);
}
}
break;
case 'buyChips':
break;
case 'home':
$homeView = new View();
$sMainContentView = $homeView->fetch('home.tpl');
default:
break;
}
/*
* Menu
*/
$MenuCtrl = new MenuController();
$active = $route[0];
$sMenuView = $MenuCtrl->getMenu($active);
/*
* NavMap
*/
$sNavMapView = $MenuCtrl->getNavMap($active);
/*
* Display the page
示例10: raw
/**
* set raw script or styles
* @param null $content
*/
public static function raw($content = null)
{
if (!is_null($content)) {
/**
* get fullpath
*/
$fullPath = Config::basePath('http/web/tpl/raw/');
$fullPath .= str_replace('::', '/', $content);
$fullPath .= '.tpl';
/**
* fetch template
*/
self::$raw[] = \View::fetch($fullPath);
}
}
示例11: display
/**
* 显示模板
* @param null $tpl
* @param null $params
* @param null $layout
*/
protected function display($tpl = null, $params = null, $layout = null)
{
is_array($tpl) && (list($tpl, $params, $layout) = array(null, $tpl, $params));
strpos($tpl, '/') || ($tpl = CTRL_NAME . '/' . ($tpl ?: ACTION_NAME));
$this->_theme && ($tpl = $this->_theme . '/' . $tpl);
// 主题
$params = $params ? array_merge($this->_p, $params) : $this->_p;
// 如果存在布局参数,则将模板数据写到content参数中,然后通过布局输出
if ($layout) {
$params['content'] = View::fetch($tpl, $params, PATH_APP_VIEW);
$tpl = $this->_theme ? $this->_theme . '/' . $layout : $layout;
// 主题
}
View::render($tpl, $params);
}
示例12: testStatisticsChart
/**
* Test statistics chart
*
* @param array $statistics
* @param string $result
* @param array $settings
* @dataProvider statisticsChartProvider
*/
public function testStatisticsChart(array $statistics, $result, array $settings)
{
$this->skipUnless(CakePlugin::loaded('GoogleChart'), 'Please install imsamurai/cakephp-google-chart for this test');
$View = new View();
$Helper = new TaskHelper($View, $settings);
$this->assertStringMatchesFormat($result, $Helper->statistics($statistics) . $View->fetch('script'));
}
示例13: get
public static function get($template, $variables = null)
{
$view = new View($template);
if ($variables) {
foreach ($variables as $key => $value) {
$view->{$key} = $value;
}
}
return $view->fetch();
}
示例14: showCorrectView
public function showCorrectView(View $view)
{
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) and strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === "xmlhttprequest") {
echo $view->fetch();
exit;
} else {
return $view->fetch();
}
}
示例15: contain
/**
* 包含一个子模板
* @param $tpl
* @param array $vars
* @return string
*/
function contain($tpl, $vars = array())
{
if ($tpl[0] == '/' && defined('VIEW_ROOT')) {
$tpl = VIEW_ROOT . $tpl;
} else {
$tpl = __DIR__ . $tpl;
}
$view = new View();
$view->set($vars);
$view->set('block', $this->blocks);
return $view->fetch($tpl);
}