本文整理汇总了PHP中Smarty::get_template_vars方法的典型用法代码示例。如果您正苦于以下问题:PHP Smarty::get_template_vars方法的具体用法?PHP Smarty::get_template_vars怎么用?PHP Smarty::get_template_vars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Smarty
的用法示例。
在下文中一共展示了Smarty::get_template_vars方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_object_tasks
/**
* Render object tasks section
*
* Parameters:
*
* - object - Selected project object
*
* @param array $params
* @param Smarty $smarty
* @return string
*/
function smarty_function_object_tasks($params, &$smarty)
{
$object = array_var($params, 'object');
if (!instance_of($object, 'ProjectObject')) {
return new InvalidParamError('object', $object, '$object is expected to be an instance of ProjectObject class', true);
}
// if
$open_tasks = $object->getOpenTasks();
if (is_foreachable($open_tasks)) {
foreach ($open_tasks as $open_task) {
ProjectObjectViews::log($open_task, $smarty->get_template_vars('logged_user'));
}
// foreach
}
// if
$completed_tasks = $object->getCompletedTasks(COMPLETED_TASKS_PER_OBJECT);
if (is_foreachable($completed_tasks)) {
foreach ($completed_tasks as $completed_task) {
ProjectObjectViews::log($completed_task, $smarty->get_template_vars('logged_user'));
}
// foreach
}
// if
$smarty->assign(array('_object_tasks_object' => $object, '_object_tasks_open' => $open_tasks, '_object_tasks_can_reorder' => (int) $object->canEdit($smarty->get_template_vars('logged_user')), '_object_tasks_completed' => $completed_tasks, '_object_tasks_completed_remaining' => $object->countCompletedTasks() - COMPLETED_TASKS_PER_OBJECT, '_object_tasks_skip_wrapper' => array_var($params, 'skip_wrapper', false), '_object_tasks_skip_head' => array_var($params, 'skip_head', false), '_object_tasks_force_show' => array_var($params, 'force_show', true)));
return $smarty->fetch(get_template_path('_object_tasks', 'tasks', RESOURCES_MODULE));
}
示例2: action
/**
* Fuehrt die einzelnen Methoden aus, abhaengig vom parameter
*
* @param array $parameters POST, GET und COOKIE-Variablen
*/
public function action($gpc)
{
//Daten initialisieren
$this->_gpc = $gpc;
$this->_nav_id = $this->_smarty->get_template_vars('local_link');
$this->_view();
return true;
}
示例3: get_template_vars
/**
* Returns an array containing template variables
*
* @param string $name
* @return array
*/
public function get_template_vars($name = null)
{
if ($this->_smarty instanceof Smarty) {
return $this->_smarty->get_template_vars($name);
} else {
if (!empty($this->_smartyMethods['assign'])) {
$method = $this->_smartyMethods['assign'];
$assigned = array();
for ($a = 0; $a < count($method); $a++) {
if (count($method[$a]) > 1) {
$assigned[$method[$a][0]] = $method[$a][1];
} elseif (is_array($method[$a][0])) {
while (list($key, $val) = each($method[$a][0])) {
$assigned[$key] = $val;
}
}
}
if (null === $name) {
return $assigned;
} elseif (isset($assigned[$name])) {
return $assigned[$name];
}
}
}
return null;
}
示例4: smarty_function_object_comments_all
/**
* List object comments
*
* Parameters:
*
* - object - Parent object. It needs to be an instance of ProjectObject class
* - comments - List of comments. It is optional. If it is missing comments
* will be loaded by calling getCommetns() method of parent object
*
* @param array $params
* @param Smarty $smarty
* @return string
*/
function smarty_function_object_comments_all($params, &$smarty)
{
$object = array_var($params, 'object');
if (!instance_of($object, 'ProjectObject')) {
return new InvalidParamError('object', $object, '$object is expected to be an instance of ProjectObject class', true);
}
// if
$logged_user = $smarty->get_template_vars('logged_user');
if (!instance_of($logged_user, 'User')) {
return '';
}
// if
$visiblity = $logged_user->getVisibility();
// if ($object->canView($logged_user) && $object->getVisibility() == VISIBILITY_PRIVATE) {
if ($object->canView($logged_user)) {
$visiblity = VISIBILITY_PRIVATE;
}
$comments = $object->getComments($visiblity);
if (is_foreachable($comments)) {
foreach ($comments as $comment) {
ProjectObjectViews::log($comment, $logged_user);
//BOF:task_1260
$comment->set_action_request_n_fyi_flag($logged_user);
//EOF:task_1260
}
// foreach
}
// if
$count_from = 0;
$smarty->assign(array('_object_comments_object' => $object, '_object_comments_count_from' => $count_from, '_object_comments_comments' => $comments, '_total_comments' => sizeof($comments)));
return $smarty->fetch(get_template_path('_object_comments_all', 'comments', RESOURCES_MODULE));
}
示例5: _checkmail_send
/**
* Schickt das Kontrollmail an den Sender, um sicherzugehen, dass die Sender-Adresse wirklich existiert
*
* @param int $mod_navID Nav-ID des Moduls
*/
private function _checkmail_send($mod_navID)
{
$mail_vars = $this->_config_textes['Mail'];
/* nav_id angegeben? */
if (!key_exists('nav_id', $this->_gpc['GET'])) {
throw new CMSException(array('mail' => 'param_navid'), EXCEPTION_MODULE_CODE, "", array('mail' => 'param_missing'));
}
/* darf modul mit nav_id mail senden? */
if ($this->_get_tabledata($mod_navID) == false) {
throw new CMSException(array('mail' => 'modul_no_mail'), EXCEPTION_MODULE_CODE, array('mail' => 'no_support'));
}
if ($this->_check_mailtable() == false) {
throw new CMSException(array('mail' => 'no_matching_table1'), EXCEPTION_MODULE_CODE, array('mail' => 'no_matching_table2'));
}
if (isset($this->_gpc['POST']['btn_send']) && $this->_gpc['POST']['btn_send'] == 'Senden') {
/*Formular wurde gesendet */
//Formular-Kontrolle
if ($this->_gpc['POST']['entry_id'] != $this->_gpc['GET']['entry_id']) {
throw new CMSException(array('mail' => 'wrong_form'), EXCEPTION_MODULE_CODE, array('mail' => 'data_collaps'));
}
//Benutzung einfacher Variablen
$title = $this->_gpc['POST']['title'];
$content = $this->_gpc['POST']['content'];
$name = $this->_gpc['POST']['name'];
$email = $this->_gpc['POST']['email'];
$entry_id = $this->_gpc['POST']['entry_id'];
/* Formular kontrollieren */
$answer = array();
$success = $this->_check_form($answer);
if ($success == true) {
/*Mail schicken*/
$navigation_id = $this->_smarty->get_template_vars('local_link');
$this->_mysql->query("SELECT `{$this->mail_tbl['column_name']}`, `{$this->mail_tbl['column_email']}` FROM `{$this->mail_tbl['table']}` WHERE `{$this->mail_tbl['column_ID']}` = '{$entry_id}'");
$mail_reciver = $this->_mysql->fetcharray('assoc');
$mail_reciver_name = $mail_reciver[$this->mail_tbl['column_name']];
$mail_reciver_email = $mail_reciver[$this->mail_tbl['column_email']];
$mail = new Mailsend();
$mailsend_controll = $mail->mail_send_link($this->_mysql, $mail_reciver_name, $mail_reciver_email, $name, $email, $title, $content);
if ($mailsend_controll == true) {
/* Erfolgreich gespeichert */
$this->_send_feedback($mail_vars['saved_title'], $mail_vars['saved_content'], "?nav_id={$navigation_id}", $mail_vars['send_link']);
} else {
/* Fehler bei der Speicherung */
$this->_send_feedback($mail_vars['failer_save_title'], $mail_vars['failer_save_content'], "?nav_id={$navigation_id}", $mail_vars['send_link']);
}
} else {
/* Fehler im Formular */
$this->_send_entryform(false, $answer);
}
} else {
/* Kein Formular abgeschickt */
//Captcha zurücksetzen
if (key_exists('captcha_revoke', $this->_gpc['POST'])) {
$first_form = false;
} else {
$first_form = true;
}
$this->_send_entryform($first_form);
}
}
示例6: _comment
/**
* Kommentarfunktion dieser Klasse
*
*/
private function _comment()
{
$gbook_vars = $this->_configvars['Gbook'];
$this->_initCaptcha();
if (isset($this->_gpc['POST']['btn_send']) && $this->_gpc['POST']['btn_send'] == 'Senden') {
/*Formular wurde gesendet */
/* Formular kontrollieren */
$answer = array();
$success = $this->_check_form($answer, array('title'));
if ($success == true) {
/*Eintrag machen*/
$navigation_id = $this->_smarty->get_template_vars('local_link');
foreach ($answer as $key => $value) {
$answer[$key] = stripslashes($value);
}
$answer['time'] = "NOW()";
$this->_msbox->commentEntry((int) $this->_gpc['GET']['ref_ID'], $answer);
$this->_send_feedback($gbook_vars['allright_title'], $gbook_vars['allright_content'], "?nav_id={$navigation_id}", $gbook_vars['allright_link']);
} else {
/* Fehler im Formular */
$this->_send_entryform(false, implode("<br />\n", $answer), true);
}
} else {
/* Kein Formular abgeschickt */
//Captcha zurücksetzen
if (key_exists('captcha_revoke', $this->_gpc['POST'])) {
$first_form = false;
} else {
$first_form = true;
}
$this->_send_entryform($first_form, null, true);
}
}
示例7: smarty_function_select_team
/**
* Render select team control
*
* Params:
*
* - project - Project instance that need to be used
* - active_only - Return only active milestones, true by default
*
* @param array $params
* @param Smarty $smarty
* @return string
*/
function smarty_function_select_team($params, &$smarty)
{
$project = array_var($params, 'project');
if (!instance_of($project, 'Project')) {
return new InvalidParamError('project', $project, '$project value is expected to be an instance of Project class', true);
}
// if
unset($params['project']);
$value = null;
if (isset($params['value'])) {
$value = $params['value'];
unset($params['value']);
}
// if
$options = array();
$logged_user = $smarty->get_template_vars('logged_user');
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
mysql_select_db(DB_NAME);
$query = "select a.id, a.name from healingcrystals_projects a inner join healingcrystals_project_users b on (a.id=b.project_id and b.user_id='" . $logged_user->getId() . "') where a.status='active' and a.completed_on is null and b.role_id<>'9' order by a.name";
$result = mysql_query($query, $link);
while ($info = mysql_fetch_assoc($result)) {
if ($info['id'] == $project->getId()) {
$option_attributes = array('selected' => true);
$options[] = option_tag(lang($info['name']), $info['id'], $option_attributes);
} else {
$options[] = option_tag(lang($info['name']), $info['id']);
}
}
mysql_close($link);
return select_box($options, $params);
}
示例8: smarty_resource_view_source
/**
* smarty_resource_view_source
*
* The first function, source() is supposed to retrieve the resource.
* Its second parameter $tpl_source is a variable passed by reference
* where the result should be stored. The function is supposed to
* return TRUE if it was able to successfully retrieve the resource
* and FALSE otherwise.
*
* @param string $tpl_name
* @param string $tpl_source reference
* @param object $smarty reference
* @uses Package::buildPath()
* @return void
*/
function smarty_resource_view_source($tplName, &$tplSource, Smarty &$smarty)
{
$templateVars = $smarty->get_template_vars();
$currentModule = $templateVars['__ZF__']['module'];
$currentController = $templateVars['__ZF__']['controller'];
$resourcePath = null;
if ("login" !== strtolower($currentController) && "static" !== strtolower($currentController) && "admin" !== strtolower($currentModule)) {
$client = $smarty->get_registered_object('client');
if (($path = Package::buildPath($smarty->template_dir, 'clients', $client->identifier, 'modules', $currentModule, $currentController, $tplName)) && is_readable($path)) {
$resourcePath = $path;
} elseif (($path = Package::buildPath($smarty->template_dir, 'clients', $client->identifier, 'modules', $currentModule, 'default', $tplName)) && is_readable($path)) {
$resourcePath = $path;
} elseif (($path = Package::buildPath($smarty->template_dir, 'clients', $client->identifier, 'modules', $currentModule, $tplName)) && is_readable($path)) {
$resourcePath = $path;
} elseif (($path = Package::buildPath($smarty->template_dir, 'clients', $client->identifier, 'modules', $tplName)) && is_readable($path)) {
$resourcePath = $path;
} elseif (($path = Package::buildPath($smarty->template_dir, 'clients', $client->identifier, $tplName)) && is_readable($path)) {
$resourcePath = $path;
}
}
if (!$resourcePath) {
if (($path = Package::buildPath($smarty->template_dir, 'modules', $currentModule, $currentController, $tplName)) && is_readable($path)) {
$resourcePath = $path;
} elseif (($path = Package::buildPath($smarty->template_dir, 'modules', $currentModule, 'default', $tplName)) && is_readable($path)) {
$resourcePath = $path;
} elseif (($path = Package::buildPath($smarty->template_dir, 'modules', $currentModule, $tplName)) && is_readable($path)) {
$resourcePath = $path;
} elseif (($path = Package::buildPath($smarty->template_dir, 'modules', $tplName)) && is_readable($path)) {
$resourcePath = $path;
} elseif (($path = Package::buildPath($smarty->template_dir, $tplName)) && is_readable($path)) {
$resourcePath = $path;
} else {
return false;
}
}
if ('admin' == $currentModule && isset($resourcePath)) {
if ($tpl = $smarty->_read_file($resourcePath)) {
$tplSource = $tpl;
}
return true;
}
if ($resourcePath) {
if ($tpl = $smarty->_read_file($resourcePath)) {
$tplSource = $tpl;
}
// $tplSource = $path;
/*
$smarty->_smarty_include(
array(
'smarty_include_tpl_file' => $path,
'smarty_include_vars' => array()
)
);
die('we got to here');
*/
return true;
}
return false;
}
示例9: getSfData
/**
* Escapes smarty stored vars for sfData
*
* @param sfSmartyView $view
* @param integer $escaping
* @return sfOutputEscaper
*/
private function getSfData($view, $escaping = ESC_RAW)
{
$current_sf_data = self::$smarty->get_template_vars('sf_data');
if (!empty($current_sf_data) && $view->getAttribute('sf_type') == 'partial') {
if (isset($current_sf_data['sf_content'])) {
$view->getAttributeHolder()->set('sf_content', $current_sf_data['sf_content']);
}
}
return sfOutputEscaper::escape($escaping, $view->getAttributeHolder()->getAll());
}
示例10: smarty_function_with_successive_milestones
/**
* with_successive_milestones helper
*
* @param array $params
* @param Smarty $smarty
* @return string
*/
function smarty_function_with_successive_milestones($params, &$smarty)
{
static $counter = 1;
$name = array_var($params, 'name');
if (empty($name)) {
return new InvalidParamError('name', $name, '$name value is required', true);
}
// if
$milestone = array_var($params, 'milestone');
if (!instance_of($milestone, 'Milestone')) {
return new InvalidParamError('milestone', $milestone, '$milestone value is expected to be an instance of Milestone class', true);
}
// if
$id = array_var($params, 'id');
if (empty($id)) {
$id = 'with_successive_milestones_' . $counter;
$counter++;
}
// if
$value = array_var($params, 'value');
$action = array_var($value, 'action', 'dont_move');
$milestones = array_var($value, 'milestones');
if (!is_array($milestones)) {
$milestones = array();
}
// if
$logged_user = $smarty->get_template_vars('logged_user');
$successive_milestones = Milestones::findSuccessiveByMilestone($milestone, STATE_VISIBLE, $logged_user->getVisibility());
if (!is_foreachable($successive_milestones)) {
return '<p class="details">' . lang('This milestone does not have any successive milestones') . '</p>';
}
// if
$result = "<div class=\"with_successive_milestones\">\n<div class=\"options\">\n";
$options = array('dont_move' => lang("Don't change anything"), 'move_all' => lang('Adjust all successive milestone by the same number of days'), 'move_selected' => lang('Adjust only selected successive milestones by the same number of days'));
foreach ($options as $k => $v) {
$radio = radio_field($name . '[action]', $k == $action, array('value' => $k, 'id' => $id . '_' . $k));
$label = label_tag($v, $id . '_' . $k, false, array('class' => 'inline'), '');
$result .= '<span class="block">' . $radio . ' ' . $label . "</span>\n";
}
// if
$result .= "</div>\n<div class=\"successive_milestones\">";
foreach ($successive_milestones as $successive_milestone) {
$input_attributes = array('name' => $name . '[milestones][]', 'id' => $id . '_milestones_' . $successive_milestone->getId(), 'type' => 'checkbox', 'value' => $successive_milestone->getId(), 'class' => 'auto');
if (in_array($successive_milestone->getId(), $milestones)) {
$input_attributes['checked'] = true;
}
// if
$input = open_html_tag('input', $input_attributes, true);
$label = label_tag($successive_milestone->getName(), $id . '_milestones_' . $successive_milestone->getId(), false, array('class' => 'inline'), '');
$result .= '<span class="block">' . $input . ' ' . $label . "</span>\n";
}
// foreach
$result .= "</div>\n</div>\n";
return $result;
}
示例11: smarty_fill_form_values
/**
* Smarty {fill_form_values}...{/fill_form_values} extension.
* Fills in form fields between the tags based on values in Smarty template
* variables, and shows form errors stored in the template variable
* "formErrors".
*
* @param array $params Params from smarty template (unused)
* @param string $content HTML to filter (it's {...}THIS STUFF{/...}
* @param Smarty $smarty
* @return string $content with form vars set properly.
*/
function smarty_fill_form_values($params, $content, &$smarty)
{
if ($content === null) {
return "";
}
$vars = $smarty->get_template_vars();
$errors = array();
if (array_key_exists('formErrors', $vars)) {
$errors = $vars['formErrors'];
}
return fillInFormValues($content, $vars, $errors);
}
示例12: smarty_function_subview
/**
* Smarty function to display a subview
* @param array $params
* @param Smarty $smarty
* @return string the HTML of a assigned subview
*/
function smarty_function_subview($params, &$smarty)
{
if (empty($params['name'])) {
throw new Exception('No name parameter provided for the subview');
}
$name = $params['name'];
$views = $smarty->get_template_vars('_views');
if (!isset($views[$name]['html'])) {
return;
}
return $views[$name]['html'];
}
示例13: smarty_function_menu
/**
* Render main menu
*
* @param array $params
* @param Smarty $smarty
* @return string
*/
function smarty_function_menu($params, &$smarty)
{
require SYSTEM_MODULE_PATH . '/models/menu/Menu.class.php';
require SYSTEM_MODULE_PATH . '/models/menu/MenuGroup.class.php';
require SYSTEM_MODULE_PATH . '/models/menu/MenuItem.class.php';
$logged_user = $smarty->get_template_vars('logged_user');
//BOF:task_1260
$active_project = $smarty->get_template_vars('active_project');
//EOF:task_1260
$menu = new Menu();
//BOF:task_1260
/*
//EOF:task_1260
event_trigger('on_build_menu', array(&$menu, &$logged_user));
//BOF:task_1260
*/
event_trigger('on_build_menu', array(&$menu, &$logged_user, &$active_project));
//EOF:task_1260
$smarty->assign('_menu', $menu);
return $smarty->fetch(get_template_path('_menu', null, SYSTEM_MODULE));
}
示例14: smarty_block_wrap
/**
* Wrap form field into a DIV
*
* Properties:
*
* - field - field name
* - errors - errors container (ValidationErrors instance)
* - show_errors - show errors list inside of field wrapper
*
* @param array $params
* @param string $content
* @param Smarty $smarty
* @param boolean $repeat
* @return null
*/
function smarty_block_wrap($params, $content, &$smarty, &$repeat)
{
$field = array_var($params, 'field');
if (empty($field)) {
return new InvalidParamError('field', $field, "'field' property is required for 'wrap_field' helper", true);
}
// if
$classes = array();
if (isset($params['class'])) {
$classes = explode(' ', $params['class']);
unset($params['class']);
}
// if
if (!in_array('ctrlHolder', $classes)) {
$classes[] = 'ctrlHolder';
}
// if
$error_messages = null;
if (isset($params['errors'])) {
$errors = $params['errors'];
} else {
$errors = $smarty->get_template_vars('errors');
}
// if
if (instance_of($errors, 'ValidationErrors')) {
if ($errors->hasError($field)) {
$classes[] = 'error';
$error_messages = $errors->getFieldErrors($field);
}
// if
}
// if
$show_errors = array_var($params, 'show_errors', true);
$listed_errors = '';
if (is_foreachable($error_messages) && $show_errors) {
require_once $smarty->_get_plugin_filepath('function', 'field_errors');
$listed_errors = smarty_function_field_errors(array('field' => $field, 'errors' => $errors), $smarty);
}
// if
$aid = array_var($params, 'aid');
if ($aid) {
$aid = '<p class="aid">' . clean(lang($aid)) . '</p>';
}
// if
// Unset helper properties, we need this for attributes
unset($params['field']);
unset($params['errors']);
unset($params['show_errors']);
unset($params['aid']);
$params['class'] = implode(' ', $classes);
return open_html_tag('div', $params) . "\n{$listed_errors}\n" . $content . $aid . "\n</div>";
}
示例15: smarty_function_select_project_group
/**
* Select project group helper
*
* Params:
*
* - value - ID of selected group
* - optional - boolean
* - can_create_new - Should this select box offer option to create a new
* company from within the list
*
* @param array $params
* @param Smarty $smarty
* @return string
*/
function smarty_function_select_project_group($params, &$smarty)
{
static $ids = array();
$optional = array_var($params, 'optional', true, true);
$value = array_var($params, 'value', null, true);
$can_create_new = array_var($params, 'can_create_new', true, true);
$id = array_var($params, 'id', null, true);
if (empty($id)) {
$counter = 1;
do {
$id = "select_project_group_dropdown_{$counter}";
$counter++;
} while (in_array($id, $ids));
}
// if
$ids[] = $id;
$params['id'] = $id;
$groups = ProjectGroups::findAll($smarty->get_template_vars('logged_user'), true);
if ($optional) {
$options = array(option_tag(lang('-- None --'), ''), option_tag('', ''));
} else {
$options = array();
}
// if
if (is_foreachable($groups)) {
foreach ($groups as $group) {
$option_attributes = array('class' => 'object_option');
if ($value == $group->getId()) {
$option_attributes['selected'] = true;
}
// if
$options[] = option_tag($group->getName(), $group->getId(), $option_attributes);
}
// foreach
}
// if
if ($can_create_new) {
$params['add_object_url'] = assemble_url('project_groups_quick_add');
$params['object_name'] = 'project_group';
$params['add_object_message'] = lang('Please insert new project group name');
$logged_user = get_logged_user();
if (instance_of($logged_user, 'User') && ProjectGroup::canAdd($logged_user)) {
$options[] = option_tag('', '');
$options[] = option_tag(lang('New Project Group...'), '', array('class' => 'new_object_option'));
}
// if
}
// if
return select_box($options, $params) . '<script type="text/javascript">$("#' . $id . '").new_object_from_select();</script>';
}