本文整理汇总了PHP中Smarty::assign方法的典型用法代码示例。如果您正苦于以下问题:PHP Smarty::assign方法的具体用法?PHP Smarty::assign怎么用?PHP Smarty::assign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Smarty
的用法示例。
在下文中一共展示了Smarty::assign方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ShowSearchForm
function ShowSearchForm(VirgoAPI $api, Smarty $smarty, $lng)
{
$smarty->assign("ShowSearchForm", true);
$smarty->assign("provinces", $api->GetInvestmentsProvinces($lng));
$smarty->assign("categories", $api->GetInvestmentsCategories($lng));
$smarty->assign("post", $_POST);
}
示例2: generateSql
public function generateSql()
{
$namespace = \Zule\Tools\Config::zc()->framework->application_namespace;
$system = 'Zule';
$tables = $this->settings->getTables();
foreach ($tables as $table) {
$s = new \Smarty();
$tableName = $table->getName();
// generate model
$s->assign('model_name', $_POST["class_{$tableName}"]);
$s->assign('namespace', $namespace);
$s->assign('system', $system);
$s->assign('class_name', $_POST["class_{$tableName}"]);
$s->assign('extend_path', '\\Zule\\Models\\Model');
$s->assign('impl_date', date('Y-m-d H:i:s'));
$s->assign('use_unsafe_setters', 0);
$s->assign('table_name', $tableName);
$columns = $table->getColumns();
$s->assign('columns', $columns);
$s->assign('primary_key', $table->getPrimaryKey());
$gen = new Generator("../models/" . $_POST["class_{$tableName}"] . '.php');
$gen->generate($s, 'model_sql');
$gen = new Generator("../models/Data/" . $_POST["class_{$tableName}"] . '.php');
$gen->generate($s, 'gateway_sql');
}
}
示例3: invokeHandler
public function invokeHandler(Smarty $viewModel, $header, $f, $page, User $user)
{
$header->meta(array('keywords' => 'Home Meta Keywords', 'description' => 'Home Meta Description'));
$header->title('RUDRAX');
$header->import('bootstrap', 'utils', 'product_login', 'utils_tunnel');
$cahce = new RxCache();
$page->data->assign('myDataKey', $cahce->get('mykey'));
$cahce->set('mykey', $cahce->get('mykey') + 1);
if (isset($_REQUEST['uname'])) {
$username = $_POST['uname'];
$password = $_POST['pass'];
$user->auth($username, $password);
}
//Console::log($this->user->getToken(),$username,$password);
if ($user->isValid()) {
$viewModel->assign('token', $user->getToken());
$viewModel->assign('profile', $user->getProfile());
$viewModel->assign("Name", "Fred Irving Johnathan Bradley Peppergill", true);
$viewModel->assign("FirstName", array("John", "Mary", "James", "Henry"));
$viewModel->assign("LastName", array("Doe", "Smith", "Johnson", "Case"));
$viewModel->assign("Class", array(array("A", "B", "C", "D"), array("E", "F", "G", "H"), array("I", "J", "K", "L"), array("M", "N", "O", "P")));
$viewModel->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"), array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));
$viewModel->assign("option_values", array("NY", "NE", "KS", "IA", "OK", "TX"));
$viewModel->assign("option_output", array("New York", "Nebraska", "Kansas", "Iowa", "Oklahoma", "Texas"));
$viewModel->assign("option_selected", "NE");
return "home/home";
} else {
return "sample/login";
}
}
示例4: doResult
function doResult($objAction, $arrResultParams, $arrData = array(), $objEngine = null)
{
require_once SMATY_LIB . 'Smarty.class.php';
$smarty = new Smarty();
//����smartyʵ�����$smarty
$smarty->template_dir = DISK_ROOT . TEMPLATE_DIR;
//����ģ��Ŀ¼
$smarty->compile_dir = DISK_ROOT . COMPILE_DIR;
//���ñ���Ŀ¼
$smarty->cache_dir = DISK_ROOT . CACHE_DIR;
//����Ŀ¼
$smarty->cache_lifetime = CACHE_LIFETIME;
//����ʱ��
$smarty->caching = CACHING;
//���淽ʽ
$smarty->left_delimiter = LEFT_DELIMITER;
$smarty->right_delimiter = RIGHT_DELIMITER;
$arrFunction = get_class_methods($objAction);
$arrPageInfoData = $objAction->getPageInfo();
foreach ($arrPageInfoData as $key => $value) {
$smarty->assign($key, $value);
}
$smarty->assign("basePath", DISK_ROOT);
$smarty->assign("host", HOST);
$tplPath = $arrResultParams['value'];
$tplPath = strval($tplPath);
$smarty->display($tplPath);
}
示例5: execute
/**
* @return Smarty
* @throws CreateReportFileFailedException
*/
public function execute()
{
// Unique Session ID for matching the storage filenames
// of the report and CSS. Allows for later retrieval.
// For our purposes, this is random enough (not cryptographically secure, though).
// We aren't trying to hide any IDs, just trying to avoid collisions.
$sessionID = uniqid(rand(), true);
// Validate and read file
$uploadReader = new CSSFileUploadReader();
$fileContents = $uploadReader->readFile();
// Parse file / generate report and write.
$cssFileParser = new CSSFileParser();
$reportPayload = $cssFileParser->generateReport($fileContents);
$reportEncoded = json_encode($reportPayload);
// Persist. For now, using Amazon since Heroku doesn't have a persistent filesystem.
$persistenceHelper = new ReportAndCSSPersistence($sessionID);
$reportURL = $persistenceHelper->persistCSSReport($reportEncoded);
$cssFilePath = $_FILES['cssfile']['tmp_name'];
$cssURL = $persistenceHelper->persistUploadedCSSFile($cssFilePath);
// Assign smarty, return.
$smarty = new Smarty();
$smarty->assign('reportURL', $reportURL);
$smarty->assign('cssURL', $cssURL);
$smarty->assign('reportPayload', $reportPayload);
$smarty->assign('sessionID', $sessionID);
return $smarty;
}
示例6: Smarty
function _renderForm(&$page)
{
$pageName = $page->getAttribute('name');
$tabPreview = array_slice($page->controller->_tabs, -2, 1);
// setup a template object
$tpl = new Smarty();
$tpl->template_dir = './templates';
$tpl->compile_dir = './templates_c';
// on preview tab, add progress bar javascript and stylesheet
if ($pageName == $tabPreview[0][0]) {
$bar = $page->controller->createProgressBar();
$tpl->assign(array('qf_style' => $bar->getStyle(), 'qf_script' => $bar->getScript()));
$barElement = $page->getElement('progressBar');
$barElement->setText($bar->toHtml());
}
$renderer = new HTML_QuickForm_Renderer_Array(true);
$page->accept($renderer);
$tpl->assign('form', $renderer->toArray());
// capture the array stucture
// (only for showing in sample template)
ob_start();
print_r($renderer->toArray());
$tpl->assign('dynamic_array', ob_get_contents());
ob_end_clean();
$tpl->display('smarty-dynamic.tpl');
}
示例7: save
function save($send_confirmation_email = false)
{
$db = DB::connect(DB_CONNECTION_STRING);
//Check if it exists, the do an update or insert
$exists = false;
if ($this->user_id != 0) {
$sql = "select user_id from user where user_id = " . $this->user_id;
$results = $db->query($sql);
if (sizeof($results) != 0) {
$exists = true;
}
}
if (!$exists) {
$this->add();
} else {
$this->update();
}
//Send email
if ($send_confirmation_email == true) {
$smarty = new Smarty();
$smarty->force_compile = true;
$smarty->compile_dir = SMARTY_COMPILE_DIRECTORY;
$smarty->assign("email", $this->email);
$smarty->assign("postcode", clean_postcode($this->postcode));
$smarty->assign("url", BASE_URL . "/confirmed.php?cid=" . $this->confirm_id);
//Get the email text
$email_text = $smarty->fetch('confirm_email_text.tpl');
//Send the email
send_text_email($this->email, EMAIL_FROM_NAME, EMAIL_FROM_ADDRESS, "Please confirm your planning alert", $email_text);
}
}
示例8: smarty_function_mobile_access_paginator
/**
* Render pagination block
*
* Parameters:
*
* - page - current_page
* - total_pages - total pages
* - route - route for URL assembly
*
* @param array $params
* @param Smarty $smarty
* @return string
*/
function smarty_function_mobile_access_paginator($params, &$smarty)
{
$url_params = '';
if (is_foreachable($params)) {
foreach ($params as $k => $v) {
if (strpos($k, 'url_param_') !== false && $v) {
$url_params .= '&' . substr($k, 10) . '=' . $v;
}
// if
}
// foreach
}
// if
$paginator = array_var($params, 'paginator', new Pager());
$paginator_url = array_var($params, 'url', ROOT_URL);
$paginator_anchor = array_var($params, 'anchor', '');
$smarty->assign(array("_mobile_access_paginator_url" => $paginator_url, "_mobile_access_paginator" => $paginator, '_mobile_access_paginator_anchor' => $paginator_anchor, "_mobile_access_paginator_url_params" => $url_params));
$paginator_url = strpos($paginator_url, '?') === false ? $paginator_url . '?' : $paginator_url . '&';
if (!$paginator->isFirst()) {
$smarty->assign('_mobile_access_paginator_prev_url', $paginator_url . 'page=' . ($paginator->getCurrentPage() - 1) . $url_params . $paginator_anchor);
}
// if
if (!$paginator->isLast()) {
$smarty->assign('_mobile_access_paginator_next_url', $paginator_url . 'page=' . ($paginator->getCurrentPage() + 1) . $url_params . $paginator_anchor);
}
// if
return $smarty->fetch(get_template_path('_paginator', null, MOBILE_ACCESS_MODULE));
}
示例9: _run
/**
* fetch a template, echos the result,
*
* @see Zend_View_Abstract::render()
* @param string $name the template
* @return void
*/
protected function _run()
{
$this->strictVars(true);
//assign variables to the template engine
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if ('_' != substr($key, 0, 1)) {
$this->_smarty->assign($key, $value);
}
}
//why 'this'?
//to emulate standard zend view functionality
//doesn't mess up smarty in any way
$this->_smarty->assign_by_ref('this', $this);
//smarty needs a template_dir, and can only use templates,
//found in that directory, so we have to strip it from the
// filename
//This checks the default application/smarty/template directory
// as well as the module views/scripts directory to find the
// template
$paths = $this->getScriptPaths();
$arg = func_get_arg(0);
foreach ($paths as $path) {
if (0 === strpos($arg, $path)) {
if ($file = substr($arg, strlen($path))) {
$this->_smarty->template_dir = $path;
break;
}
}
}
//process the template (and filter the output)
echo $this->_smarty->fetch($file);
}
示例10: admin_joinus
function admin_joinus()
{
global $db, $countries;
$tpl = new smarty();
$db->query('SELECT tname, `joinID`, `name`, b.username, b.email, b.icq, b.msn, `age`, b.country, `teamID`, `comment`, `IP`, `datum`, `closed`, `closedby`, a.username as closedby_username FROM ' . DB_PRE . 'ecp_joinus as b LEFT JOIN ' . DB_PRE . 'ecp_teams ON (teamID = tID) LEFT JOIN ' . DB_PRE . 'ecp_user as a ON (ID=closedby) ORDER BY closed ASC, datum ASC');
$joinus = array();
while ($row = $db->fetch_assoc()) {
$row['datum'] = date(SHORT_DATE, $row['datum']);
if ($row['joinID'] == (int) @$_GET['id']) {
$spe = $row;
}
$joinus[] = $row;
}
if (@$spe) {
ob_start();
$tpl1 = new Smarty();
foreach ($spe as $key => $value) {
$tpl1->assign($key, $value);
}
$tpl1->assign('countryname', $countries[$spe['country']]);
$tpl1->assign('id', $row['joinID']);
$tpl1->display(DESIGN . '/tpl/admin/joinus_view.html');
$tpl->assign('details', ob_get_contents());
ob_end_clean();
}
$tpl->assign('joinus', $joinus);
ob_start();
$tpl->display(DESIGN . '/tpl/admin/joinus.html');
$content = ob_get_contents();
ob_end_clean();
main_content(JOINUS, $content, '', 1);
}
示例11: display
public function display()
{
//Smarty engine/Smarty 引擎
require ROOT . '/pf_core/smarty/libs/Smarty.class.php';
$smarty = new Smarty();
$table_fields = $this->initSqlFields();
$smarty->assign('table_fields', $table_fields);
$data_list = $this->loadData();
foreach ($data_list as $k => $v) {
if ($data_list[$k]['products_image']) {
$data_list[$k]['products_image'] = '<img width="50" height="50" src="http://pandoraf.com/applications/pandoraf/templates/imgServer/thumb/list_grid/' . $v['products_image'] . '"/>';
}
}
$smarty->assign('data_list', $data_list);
if (0) {
$contents = $smarty->fetch($this->data_tpl);
$result = array();
$result['page'] = 1;
$result['total_page'] = 2;
$result['contents'] = $contents;
echo json_encode($result);
return;
}
$smarty->display('web/table.html');
exit;
}
示例12: render
function render($props, $message = NULL)
{
$smarty = new \Smarty();
$smarty->assign($this->tpl, $props);
$smarty->assign('message', $message);
$smarty->display($this->tpl . '.tpl');
}
示例13: render
public function render(array $data, $template)
{
foreach ($data as $name => $param) {
$this->_engine->assign($name, $param);
}
return $this->_engine->fetch($template);
}
示例14: injectToolbar
/**
* adds the toolbar to the html dom before closing body tag
*
* @access public
* @static
* @param \Smarty $oView
* @return void
*/
public static function injectToolbar(\Smarty $oView)
{
$sToolBarVarName = 'sToolBar_' . uniqid();
$sInfoToolSmarty = '{$' . $sToolBarVarName . '}';
// add toolbar template var to layout
$aToolbar = \MVC\Registry::get('aToolbar');
$oView->assign('aToolbar', $aToolbar);
$oView->assign($sToolBarVarName, $oView->loadTemplateAsString(realpath(__DIR__ . '/../') . '/templates/infoTool.tpl'));
// disable regular view output
\MVC\View::$_bEchoOut = FALSE;
// inject toolbar var to regular string output via DOM
INJECT:
$oDom = new \DOMDocument(null, null);
// prevent error messages occuring by using DOM
// @see http://stackoverflow.com/a/6090728/2487859
libxml_use_internal_errors(true);
// DOMDocument::loadHTML will treat your string as being in ISO-8859-1 unless you tell it otherwise.
// @see http://stackoverflow.com/a/8218649/2487859
$oDom->loadHTML(mb_convert_encoding($aToolbar['sRendered'], 'HTML-ENTITIES', 'UTF-8'));
libxml_clear_errors();
// add toolbar tag as a placeholder before body closing tag
$oNode = $oDom->createElement($sToolBarVarName);
$oBody = $oDom->getElementsByTagName('body');
foreach ($oBody as $oItem) {
$oItem->appendChild($oNode);
}
$sHtml = $oDom->saveHTML();
// render the toolbar
$sInfoToolRendered = $oView->fetch('string:' . $sInfoToolSmarty);
// replace toolbar tag placeholder with rendered toolbar
$sHtml = str_replace('<' . $sToolBarVarName . '></' . $sToolBarVarName . '>', $sInfoToolRendered, $sHtml);
// new output, now including toolbar
echo $sHtml;
}
示例15: handle
function handle()
{
if (isset($_GET['behav'])) {
if ($_GET['behav'] == 'uploadimg') {
$name = uniqid() . '.jpg';
move_uploaded_file($_FILES["pic"]["tmp_name"], './jae/' . $name);
upoadTmpFile('./jae/' . $name);
$tmp = array();
$tmp['url'] = getTmpFileUrl($name);
$tmp['id'] = $name;
echo json_encode($tmp);
exit;
}
}
$smarty = new Smarty();
$smarty->assign('logined', isLogined());
$smarty->display('libs/view/head.ctp');
if (isset($_POST['bookname'])) {
$name = explode('.', $_FILES["file"]["name"]);
$name = $name[count($name) - 1];
if ($name == 'mobi') {
$id = $this->doUpload();
header("location:index.php?action=detail&bid={$id}");
//$smarty->assign('type','success');
//$smarty->assign('message','上传成功');
} else {
$smarty->assign('type', 'error');
$smarty->assign('message', '上传失败,文件类型错误');
}
//$smarty->display('libs/view/alert.ctp');
}
$smarty->display('libs/view/upload.ctp');
$smarty->display('libs/view/tail.ctp');
}