本文整理汇总了PHP中unknown::assign方法的典型用法代码示例。如果您正苦于以下问题:PHP unknown::assign方法的具体用法?PHP unknown::assign怎么用?PHP unknown::assign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unknown
的用法示例。
在下文中一共展示了unknown::assign方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_math
/**
* Smarty {math} function plugin
*
* Type: function<br>
* Name: math<br>
* Purpose: handle math computations in template<br>
*
* @link http://smarty.php.net/manual/en/language.function.math.php {math}
* (Smarty online manual)
* @param array
* @param Smarty
* @param unknown $params
* @param unknown $smarty (reference)
* @return string
*/
function smarty_function_math($params, &$smarty)
{
// be sure equation parameter is present
if (empty($params['equation'])) {
$smarty->trigger_error("math: missing equation parameter");
return;
}
$equation = $params['equation'];
// make sure parenthesis are balanced
if (substr_count($equation, "(") != substr_count($equation, ")")) {
$smarty->trigger_error("math: unbalanced parenthesis");
return;
}
// match all vars in equation, make sure all are passed
preg_match_all("!\\!(0x)([a-zA-Z][a-zA-Z0-9_]*)!", $equation, $match);
$allowed_funcs = array('int', 'abs', 'ceil', 'cos', 'exp', 'floor', 'log', 'log10', 'max', 'min', 'pi', 'pow', 'rand', 'round', 'sin', 'sqrt', 'srand', 'tan');
foreach ($match[2] as $curr_var) {
if (!in_array($curr_var, array_keys($params)) && !in_array($curr_var, $allowed_funcs)) {
$smarty->trigger_error("math: parameter {$curr_var} not passed as argument");
return;
}
}
foreach ($params as $key => $val) {
if ($key != "equation" && $key != "format" && $key != "assign") {
// make sure value is not empty
if (strlen($val) == 0) {
$smarty->trigger_error("math: parameter {$key} is empty");
return;
}
if (!is_numeric($val)) {
$smarty->trigger_error("math: parameter {$key}: is not numeric");
return;
}
$equation = preg_replace("/\\b{$key}\\b/", $val, $equation);
}
}
eval("\$smarty_math_result = " . $equation . ";");
if (empty($params['format'])) {
if (empty($params['assign'])) {
return $smarty_math_result;
} else {
$smarty->assign($params['assign'], $smarty_math_result);
}
} else {
if (empty($params['assign'])) {
printf($params['format'], $smarty_math_result);
} else {
$smarty->assign($params['assign'], sprintf($params['format'], $smarty_math_result));
}
}
}
示例2: smarty_function_assign_debug_info
/**
* Smarty {assign_debug_info} function plugin
*
* Type: function<br>
* Name: assign_debug_info<br>
* Purpose: assign debug info to the template<br>
* {@link Smarty::$_tpl_vars} and {@link Smarty::$_smarty_debug_info}
*
* @param Smarty
* @param unknown $params
* @param unknown $smarty (reference)
*/
function smarty_function_assign_debug_info($params, &$smarty)
{
$assigned_vars = $smarty->_tpl_vars;
ksort($assigned_vars);
if (@is_array($smarty->_config[0])) {
$config_vars = $smarty->_config[0];
ksort($config_vars);
$smarty->assign("_debug_config_keys", array_keys($config_vars));
$smarty->assign("_debug_config_vals", array_values($config_vars));
}
$included_templates = $smarty->_smarty_debug_info;
$smarty->assign("_debug_keys", array_keys($assigned_vars));
$smarty->assign("_debug_vals", array_values($assigned_vars));
$smarty->assign("_debug_tpls", $included_templates);
}
示例3: admin_plugin_rss_run
/**
*
*
* @param unknown $bBlog (reference)
*/
function admin_plugin_rss_run(&$bBlog)
{
$pole = "";
for ($i = 1; $i < 10; $i++) {
if (isset($_POST['sending']) && $_POST['sending'] == "true") {
$id = $_POST[id . $i];
$ch = $_POST[ch . $i];
$update_query = "UPDATE " . T_RSS . " SET `url` = '" . $id . "',`input_charset` = '" . $ch . "' WHERE `id` = '" . $i . "' LIMIT 1 ;";
$bBlog->query($update_query);
}
$query = "select * from " . T_RSS . " where id=" . $i . ";";
$row = $bBlog->get_row($query);
$rssurl = $row->url;
$w1250 = "";
if ($row->input_charset == "W1250") {
$w1250 = " selected";
}
$utf8 = "";
if ($row->input_charset == "UTF8") {
$utf8 = " selected";
}
if ($i / 2 == floor($i / 2)) {
$class = 'high';
} else {
$class = 'low';
}
$pole .= '<tr class="' . $class . '"><td>' . $i . '</td><td><input type="text" name="id' . $i . '" size="20" value="' . $rssurl . '" class="text" /></td><td><select name="ch' . $i . '">';
$pole .= '<option>I88592</option>';
$pole .= '<option' . $w1250 . '>W1250</option>';
$pole .= '<option' . $utf8 . '>UTF8</option>';
$pole .= '</select></td></tr>';
}
$bBlog->assign('pole', $pole);
}
示例4: smarty_function_debug
/**
* Smarty {debug} function plugin
*
* Type: function<br>
* Name: debug<br>
* Date: July 1, 2002<br>
* Purpose: popup debug window
*
* @link http://smarty.php.net/manual/en/language.function.debug.php {debug}
* (Smarty online manual)
* @author Monte Ohrt <monte@ispi.net>
* @version 1.0
* @param array
* @param Smarty
* @param unknown $params
* @param unknown $smarty (reference)
* @return string output from {@link Smarty::_generate_debug_output()}
*/
function smarty_function_debug($params, &$smarty)
{
if ($params['output']) {
$smarty->assign('_smarty_debug_output', $params['output']);
}
require_once SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.display_debug_console.php';
return smarty_core_display_debug_console(null, $smarty);
}
示例5: smarty_function_assign
/**
* Smarty {assign} function plugin
*
* Type: function<br>
* Name: assign<br>
* Purpose: assign a value to a template variable
*
* @link http://smarty.php.net/manual/en/language.custom.functions.php#LANGUAGE.FUNCTION.ASSIGN {assign}
* (Smarty online manual)
* @param array Format: array('var' => variable name, 'value' => value to assign)
* @param Smarty
* @param unknown $params
* @param unknown $smarty (reference)
*/
function smarty_function_assign($params, &$smarty)
{
extract($params);
if (empty($var)) {
$smarty->trigger_error("assign: missing 'var' parameter");
return;
}
if (!in_array('value', array_keys($params))) {
$smarty->trigger_error("assign: missing 'value' parameter");
return;
}
$smarty->assign($var, $value);
}
示例6: smarty_function_getcontent
/**
*
*
* @param unknown $params
* @param unknown $bBlog (reference)
*/
function smarty_function_getcontent($params, &$bBlog)
{
// Retrieving data
$bBlog->get_sections();
$sections = $bBlog->sections;
foreach ($sections as $object) {
$new[$object->sectionid] = $object;
}
$sections = $new;
$current_section = $bBlog->get_template_vars("sectionid");
// Return
$bBlog->assign("content", $sections[$current_section]->content);
}
示例7: smarty_function_getcomments
/**
*
*
* @param unknown $params
* @param unknown $bBlog (reference)
*/
function smarty_function_getcomments($params, &$bBlog)
{
$assign = "comments";
$postid = $bBlog->show_post;
$replyto = $_REQUEST['replyto'];
extract($params);
// first, assign the hidden fields
$commentformhiddenfields = '<input type="hidden" name="do" value="submitcomment" />';
$commentformhiddenfields .= '<input type="hidden" name="comment_postid" value="' . $postid . '" />';
if (is_numeric($replyto)) {
$commentformhiddenfields .= '<a name="commentform"></a><input type="hidden" name="replytos" value="' . $replyto . '" />';
}
$bBlog->assign("commentformhiddenfields", $commentformhiddenfields);
$bBlog->assign("commentformaction", $bBlog->_get_entry_permalink($postid));
// are we posting a comment ?
if ($_POST['do'] == 'submitcomment' && is_numeric($_POST['comment_postid'])) {
// we are indeed!
if (is_numeric($_POST['replytos'])) {
$rt = $_POST['replytos'];
} else {
$rt = false;
}
$bBlog->new_comment($_POST['comment_postid'], $rt);
}
// get the comments.
/* start loop and get posts*/
$rt = false;
if (is_numeric($_GET['replyto'])) {
$rt = $_GET['replyto'];
$cs = $bBlog->get_comment($postid, $rt);
} else {
$cs = $bBlog->get_comments($postid, FALSE);
}
/* assign loop variable */
$bBlog->assign($assign, $cs);
}
示例8: admin_plugin_rssfeedmaker_run
/**
*
*
* @param unknown $bBlog (reference)
*/
function admin_plugin_rssfeedmaker_run(&$bBlog)
{
if (isset($_POST['sub']) && $_POST['sub'] == 'y') {
$url = BLOGURL . 'rss.php?';
if ($_POST['version'] == 2) {
$url .= 'ver=2';
} elseif ($_POST['version'] == 'atom03') {
$url .= 'ver=atom03';
} else {
$url .= 'ver=0.92';
}
if (is_numeric($_POST['num'])) {
$url .= '&num=' . $_POST['num'];
}
if ($_POST['sectionid'] > 0) {
$url .= '&sectionid=' . $_POST['sectionid'];
}
if (is_numeric($_POST['year'])) {
$url .= '&year=' . $_POST['year'];
}
if (is_numeric($_POST['month'])) {
$url .= '&year=' . $_POST['day'];
}
if (is_numeric($_POST['day'])) {
$url .= '&year=' . $_POST['day'];
}
$bBlog->assign('results', TRUE);
$bBlog->assign('feedurl', $url);
}
$sections = $bBlog->get_sections();
$sectionlist = '';
foreach ($sections as $section) {
$sectionlist .= "<option value='{$section->sectionid}'>{$section->nicename}</option>";
}
$bBlog->assign('sectionlist', $sectionlist);
}
示例9: smarty_function_counter
/**
* Smarty {counter} function plugin
*
* Type: function<br>
* Name: counter<br>
* Purpose: print out a counter value
*
* @link http://smarty.php.net/manual/en/language.function.counter.php {counter}
* (Smarty online manual)
* @param array parameters
* @param Smarty
* @param unknown $params
* @param unknown $smarty (reference)
* @return string|null
*/
function smarty_function_counter($params, &$smarty)
{
static $counters = array();
extract($params);
if (!isset($name)) {
if (isset($id)) {
$name = $id;
} else {
$name = "default";
}
}
if (!isset($counters[$name])) {
$counters[$name] = array('start' => 1, 'skip' => 1, 'direction' => 'up', 'count' => 1);
}
$counter =& $counters[$name];
if (isset($start)) {
$counter['start'] = $counter['count'] = $start;
}
if (!empty($assign)) {
$counter['assign'] = $assign;
}
if (isset($counter['assign'])) {
$smarty->assign($counter['assign'], $counter['count']);
}
if (isset($print)) {
$print = (bool) $print;
} else {
$print = empty($counter['assign']);
}
if ($print) {
$retval = $counter['count'];
} else {
$retval = null;
}
if (isset($skip)) {
$counter['skip'] = $skip;
}
if (isset($direction)) {
$counter['direction'] = $direction;
}
if ($counter['direction'] == "down") {
$counter['count'] -= $counter['skip'];
} else {
$counter['count'] += $counter['skip'];
}
return $retval;
}
示例10: smarty_function_getarchives
/**
*
*
* @param unknown $params
* @param unknown $bBlog (reference)
* @return unknown
*/
function smarty_function_getarchives($params, &$bBlog)
{
$ar = array();
$opt = $params;
unset($opt['assign']);
// If "assign" is not set... we'll establish a default.
if ($params['assign'] == '') {
$params['assign'] = 'archives';
}
$ar = $bBlog->get_archives($opt);
// No posts.
if (!is_array($ar)) {
return '';
}
$bBlog->assign($params['assign'], $ar);
return '';
}
示例11: smarty_block_textformat
/**
* Smarty {textformat}{/textformat} block plugin
*
* Type: block function<br>
* Name: textformat<br>
* Purpose: format text a certain way with preset styles
* or custom wrap/indent settings<br>
*
* @link http://smarty.php.net/manual/en/language.function.textformat.php {textformat}
* (Smarty online manual)
* @param array
* <pre>
* Params: style: string (email)
* indent: integer (0)
* wrap: integer (80)
* wrap_char string ("\n")
* indent_char: string (" ")
* wrap_boundary: boolean (true)
* </pre>
* @param string contents of the block
* @param Smarty clever simulation of a method
* @param unknown $params
* @param unknown $content
* @param unknown $smarty (reference)
* @return string string $content re-formatted
*/
function smarty_block_textformat($params, $content, &$smarty)
{
$style = null;
$indent = 0;
$indent_first = 0;
$indent_char = ' ';
$wrap = 80;
$wrap_char = "\n";
$wrap_cut = false;
$assign = null;
if ($content == null) {
return true;
}
extract($params);
if ($style == 'email') {
$wrap = 72;
}
// split into paragraphs
$paragraphs = preg_split('![\\r\\n][\\r\\n]!', $content);
$output = '';
foreach ($paragraphs as $paragraph) {
if ($paragraph == '') {
continue;
}
// convert mult. spaces & special chars to single space
$paragraph = preg_replace(array('!\\s+!', '!(^\\s+)|(\\s+$)!'), array(' ', ''), $paragraph);
// indent first line
if ($indent_first > 0) {
$paragraph = str_repeat($indent_char, $indent_first) . $paragraph;
}
// wordwrap sentences
$paragraph = wordwrap($paragraph, $wrap - $indent, $wrap_char, $wrap_cut);
// indent lines
if ($indent > 0) {
$paragraph = preg_replace('!^!m', str_repeat($indent_char, $indent), $paragraph);
}
$output .= $paragraph . $wrap_char . $wrap_char;
}
if ($assign != null) {
$smarty->assign($assign, $output);
} else {
return $output;
}
}
示例12: smarty_function_eval
/**
* Smarty {eval} function plugin
*
* Type: function<br>
* Name: eval<br>
* Purpose: evaluate a template variable as a template<br>
*
* @link http://smarty.php.net/manual/en/language.function.eval.php {eval}
* (Smarty online manual)
* @param array
* @param Smarty
* @param unknown $params
* @param unknown $smarty (reference)
* @return unknown
*/
function smarty_function_eval($params, &$smarty)
{
if (!isset($params['var'])) {
$smarty->trigger_error("eval: missing 'var' parameter");
return;
}
if ($params['var'] == '') {
return;
}
$smarty->_compile_source('evaluated template', $params['var'], $_var_compiled);
ob_start();
$smarty->_eval('?>' . $_var_compiled);
$_contents = ob_get_contents();
ob_end_clean();
if (!empty($params['assign'])) {
$smarty->assign($params['assign'], $_contents);
} else {
return $_contents;
}
}
示例13: smarty_function_getpost
/**
*
*
* @param unknown $params
* @param unknown $bBlog (reference)
* @return unknown
*/
function smarty_function_getpost($params, &$bBlog)
{
$ar = array();
// If "assign" is not set... we'll establish a default.
if ($params['assign'] == '') {
$params['assign'] = 'post';
}
if ($params['postid'] == '') {
$bBlog->trigger_error('postid is a required parameter');
return '';
}
$q = $bBlog->make_post_query(array("postid" => $params['postid']));
$ar['posts'] = $bBlog->get_posts($q);
// No posts.
if (!is_array($ar['posts'])) {
return false;
}
$ar['posts'][0]['newday'] = 'yes';
$ar['posts'][0]['newmonth'] = 'yes';
$bBlog->assign($params['assign'], $ar['posts'][0]);
return '';
}
示例14: smarty_function_getposts
/**
*
*
* @param unknown $params
* @param unknown $bBlog (reference)
* @return unknown
*/
function smarty_function_getposts($params, &$bBlog)
{
$ar = array();
$opt = array();
if (is_numeric($params['postid']) && $params['postid'] > 0) {
$postid = $params['postid'];
} else {
$postid = FALSE;
}
// If "assign" is not set... we'll establish a default.
if ($params['assign'] == '') {
if ($postid) {
$params['assign'] = 'post';
} else {
$params['assign'] = 'posts';
}
}
if ($postid) {
//we've been given a post id so we'll just get it and get outta here.
$q = $bBlog->make_post_query(array("postid" => $params['postid']));
$ar['posts'] = $bBlog->get_posts($q);
// No post.
if (!is_array($ar['posts'])) {
return false;
}
$ar['posts'][0]['newday'] = 'yes';
$ar['posts'][0]['newmonth'] = 'yes';
$bBlog->assign($params['assign'], $ar['posts'][0]);
return '';
// so if postid is given this is the last line processed
}
// If "archive" is set, order them ASCENDING by posttime.
if ($params['archive']) {
$opt['order'] = " ORDER BY posttime ";
}
// If num is set, we'll only get that many results in return
if (is_numeric($params['num'])) {
$opt['num'] = $params['num'];
}
// If skip is set, we'll skip that many results
if (is_numeric($params['skip'])) {
$opt['skip'] = $params['skip'];
}
if ($params['section'] != '') {
$opt['sectionid'] = $bBlog->sect_by_name[$params['section']];
}
if ($bBlog->show_section) {
$opt['sectionid'] = $bBlog->show_section;
}
if (is_numeric($params['year'])) {
if (strlen($params['year']) != 4) {
$bBlog->trigger_error('getposts: year parameter requires a 4 digit month');
return '';
}
$opt['year'] = $params['year'];
}
if (is_numeric($params['month'])) {
if (strlen($params['month']) != 2) {
$bBlog->trigger_error('getposts: month parameter requires a 2 digit month');
return '';
}
$opt['month'] = $params['month'];
}
if (is_numeric($params['day'])) {
if (strlen($params['day']) != 2) {
$bBlog->trigger_error('getposts: day parameter requires a 2 digit day');
return '';
}
$opt['day'] = $params['day'];
}
if (is_numeric($params['hour'])) {
if (strlen($params['hour']) != 2) {
$bBlog->trigger_error('getposts: hour parameter requires a 2 digit hour');
return '';
}
$opt['hour'] = $params['hour'];
}
if (is_numeric($params['minute'])) {
if (strlen($params['minute']) != 2) {
$bBlog->trigger_error('getposts: minute parameter requires a 2 digit minute');
return '';
}
$opt['minute'] = $params['minute'];
}
if (is_numeric($params['second'])) {
if (strlen($params['second']) != 2) {
$bBlog->trigger_error('getposts: second parameter requires a 2 digit second');
return '';
}
$opt['second'] = $params['second'];
}
$opt['home'] = $params['home'];
$q = $bBlog->make_post_query($opt);
//.........这里部分代码省略.........
示例15: admin_plugin_links_run
/**
*
*
* @param unknown $bBlog (reference)
*/
function admin_plugin_links_run(&$bBlog)
{
if (isset($_GET['linkdo'])) {
$linkdo = $_GET['linkdo'];
} elseif (isset($_POST['linkdo'])) {
$linkdo = $_POST['linkdo'];
} else {
$linkdo = '';
}
switch ($linkdo) {
case "New":
// add new link
$maxposition = $bBlog->get_var("select position from " . T_LINKS . " order by position desc limit 0,1");
$position = $maxposition + 10;
$bBlog->query("insert into " . T_LINKS . "\n set nicename='" . my_addslashes($_POST['nicename']) . "',\n url='" . my_addslashes($_POST['url']) . "',\n category='" . my_addslashes($_POST['category']) . "',\n\t position='{$position}'");
break;
case "Delete":
// delete link
$bBlog->query("delete from " . T_LINKS . " where linkid=" . $_POST['linkid']);
break;
case "Save":
// update an existing link
$bBlog->query("update " . T_LINKS . "\n set nicename='" . my_addslashes($_POST['nicename']) . "',\n url='" . my_addslashes($_POST['url']) . "',\n category='" . my_addslashes($_POST['category']) . "'\n where linkid=" . $_POST['linkid']);
break;
case "Up":
$bBlog->query("update " . T_LINKS . " set position=position-15 where linkid=" . $_POST['linkid']);
reorder_links();
break;
case "Down":
$bBlog->query("update " . T_LINKS . " set position=position+15 where linkid=" . $_POST['linkid']);
reorder_links();
break;
default:
// show form
break;
}
if (isset($_GET['catdo'])) {
$catdo = $_GET['catdo'];
} elseif (isset($_POST['catdo'])) {
$catdo = $_POST['catdo'];
} else {
$catdo = '';
}
switch ($catdo) {
case "New":
// add new category
$bBlog->query("insert into " . T_CATEGORIES . "\n set name='" . my_addslashes($_POST['name']) . "'");
break;
case "Delete":
// delete category
// have to remove all references to the category in the links
$bBlog->query("update " . T_LINKS . "\n set linkid=0 where linkid=" . $_POST['categoryid']);
// delete the category
$bBlog->query("delete from " . T_CATEGORIES . " where categoryid=" . $_POST['categoryid']);
break;
case "Save":
// update an existing category
$bBlog->query("update " . T_CATEGORIES . "\n set name='" . my_addslashes($_POST['name']) . "'\n where categoryid=" . $_POST['categoryid']);
break;
default:
// show form
break;
}
$bBlog->assign('ecategories', $bBlog->get_results("select * from " . T_CATEGORIES));
$bBlog->assign('elinks', $bBlog->get_results("select * from " . T_LINKS . " order by position"));
}