本文整理汇总了PHP中Token::setValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Token::setValue方法的具体用法?PHP Token::setValue怎么用?PHP Token::setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Token
的用法示例。
在下文中一共展示了Token::setValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: readToken
/**
* Reads the next token from the INI file
*
* @throws IOException On error
* @return Token
*/
function readToken()
{
if ($this->file === null) {
throw new BuildException("No File set for IniFileTokenReader");
}
static $tokens = null;
if ($tokens === null) {
$tokens = array();
$arr = parse_ini_file($this->file->getAbsolutePath(), true);
if ($this->section === null) {
foreach ($arr as $sec_name => $values) {
foreach ($arr[$sec_name] as $key => $value) {
$tok = new Token();
$tok->setKey($key);
$tok->setValue($value);
$tokens[] = $tok;
}
}
} else {
if (isset($arr[$this->section])) {
foreach ($arr[$this->section] as $key => $value) {
$tok = new Token();
$tok->setKey($key);
$tok->setValue($value);
$tokens[] = $tok;
}
}
}
}
if (count($tokens) > 0) {
return array_pop($tokens);
} else {
return null;
}
}
示例2: getToken
/**
* Return an opaque, url-safe token representing this mosaic
* @access public
*/
function getToken()
{
$token = new Token();
$token->setValue("x", $this->map_x);
$token->setValue("y", $this->map_y);
$token->setValue("w", $this->image_w);
$token->setValue("h", $this->image_h);
$token->setValue("s", $this->pixels_per_km);
if (!empty($this->type_or_user)) {
$token->setValue("t", $this->type_or_user);
}
if (isset($this->reference_index)) {
$token->setValue("r", $this->reference_index);
}
if ($this->palette) {
$token->setValue("p", $this->palette);
}
return $token->getToken();
}
示例3: _initialize
/**
* Initializes tokens and loads the replacee-replacer hashtable.
* This method is only called when this filter is used through
* a <filterreader> tag in build file.
*/
private function _initialize()
{
$params = $this->getParameters();
if ($params !== null) {
for ($i = 0; $i < count($params); $i++) {
if ($params[$i] !== null) {
$type = $params[$i]->getType();
if ($type === "tokenchar") {
$name = $params[$i]->getName();
if ($name === "begintoken") {
$this->_beginToken = substr($params[$i]->getValue(), 0, 1);
} else {
if ($name === "endtoken") {
$this->_endToken = substr($params[$i]->getValue(), 0, 1);
}
}
} else {
if ($type === "token") {
$name = $params[$i]->getName();
$value = $params[$i]->getValue();
$tok = new Token();
$tok->setKey($name);
$tok->setValue($value);
array_push($this->_tokens, $tok);
} else {
if ($type === "tokensource") {
// Store data from nested tags in local array
$arr = array();
$subparams = $params[$i]->getParams();
$count = count($subparams);
for ($i = 0; $i < $count; $i++) {
$arr[$subparams[$i]->getName()] = $subparams[$i]->getValue();
}
// Create TokenSource
$tokensource = new TokenSource();
if (isset($arr["classname"])) {
$tokensource->setClassname($arr["classname"]);
}
// Copy other parameters 1:1 to freshly created TokenSource
foreach ($arr as $key => $value) {
if (strtolower($key) === "classname") {
continue;
}
$param = $tokensource->createParam();
$param->setName($key);
$param->setValue($value);
}
$this->_tokensources[] = $tokensource;
}
}
}
}
}
}
}
示例4: processSection
/**
* Process an individual section
*
* @param array $section
*/
protected function processSection(array $section)
{
foreach ($section as $key => $value) {
$tok = new Token();
$tok->setKey($key);
$tok->setValue($value);
$this->tokens[] = $tok;
}
}
示例5: getToken
/**
* Return an opaque, url-safe token representing this mosaic
* @access public
*/
function getToken()
{
$token = new Token();
$token->setValue("x", $this->map_x);
$token->setValue("y", $this->map_y);
$token->setValue("w", $this->image_w);
$token->setValue("h", $this->image_h);
$token->setValue("s", $this->pixels_per_km);
$token->setValue("f", $this->mosaic_factor);
if ($this->palette) {
$token->setValue("p", $this->palette);
}
if (!empty($this->type_or_user)) {
$token->setValue("t", $this->type_or_user);
}
return $token->getToken();
}
示例6: elseif
$smarty->assign_by_ref('dirs', $dirs);
} elseif ($step == 3) {
list($usec, $sec) = explode(' ', microtime());
$endtime = (double) $usec + (double) $sec;
$timetaken = $endtime - $STARTTIME;
if ($timetaken > 15) {
//mysql might of closed the connection in the meantime
unset($square->db);
//so get a new one...
$square->_getDB();
}
//find a possible place within 25km
$smarty->assign('place', $square->findNearestPlace(25000));
if (!empty($_REQUEST['grid_reference'])) {
$token = new Token();
$token->setValue("g", !empty($_REQUEST['grid_reference']) ? $_REQUEST['grid_reference'] : $square->grid_reference);
$token->setValue("p", $_REQUEST['photographer_gridref']);
$token->setValue("v", $_REQUEST['view_direction']);
$smarty->assign('reopenmaptoken', $token->getToken());
$smarty->assign_by_ref('square', $square);
}
if ($_REQUEST['imagetaken'] && $_REQUEST['imagetaken'] != '0000-00-00') {
$smarty->assign('imagetaken', stripslashes($_REQUEST['imagetaken']));
} elseif ($smarty->get_template_vars('imagetaken')) {
//already set
} elseif (isset($uploadmanager->exifdate)) {
$smarty->assign('imagetaken', $uploadmanager->exifdate);
//$smarty->assign('imagetakenmessage', ' ('.$uploadmanager->exifdate.' stated in exif header)');
} else {
$smarty->assign('imagetaken', '--');
}
示例7: ImageList
$sql = "select gi.*,grid_reference,user.realname,imagecount {$sql_columns}\nfrom \n\tgridimage as gi\n\tinner join gridsquare as gs\n\t\tusing(gridsquare_id)\n\t{$sql_from}\n\tleft join gridsquare_moderation_lock as l\n\t\ton(gi.gridsquare_id=l.gridsquare_id and lock_obtained > date_sub(NOW(),INTERVAL 1 HOUR) )\n\tinner join user\n\t\ton(gi.user_id=user.user_id)\nwhere\n\t{$sql_where}\n\t{$sql_where2}\ngroup by gridimage_id\norder by\n\t{$sql_order}\nlimit {$limit}";
//implied: and user_id != {$USER->user_id}
// -> because squares with users images are locked
#############################
# fetch the list of images...
$images = new ImageList();
$c = $images->_getImagesBySql($sql);
$realname = array();
foreach ($images->images as $i => $image) {
$token = new Token();
$fix6fig = 0;
if ($image->use6fig && ($image->natgrlen > 6 || $image->viewpoint_grlen > 6)) {
$fix6fig = 1;
$images->images[$i]->use6fig = 0;
}
$token->setValue("g", $images->images[$i]->getSubjectGridref(true));
if ($image->viewpoint_eastings) {
//note $image DOESNT work non php4, must use $images->images[$i]
//move the photographer into the center to match the same done for the subject
$correction = $images->images[$i]->viewpoint_grlen > 4 ? 0 : 500;
$images->images[$i]->distance = sprintf("%0.2f", sqrt(pow($images->images[$i]->grid_square->nateastings - $images->images[$i]->viewpoint_eastings - $correction, 2) + pow($images->images[$i]->grid_square->natnorthings - $images->images[$i]->viewpoint_northings - $correction, 2)) / 1000);
if (intval($images->images[$i]->grid_square->nateastings / 1000) != intval($images->images[$i]->viewpoint_eastings / 1000) || intval($images->images[$i]->grid_square->natnorthings / 1000) != intval($images->images[$i]->viewpoint_northings / 1000)) {
$images->images[$i]->different_square_true = true;
}
if ($images->images[$i]->different_square_true && $images->images[$i]->subject_gridref_precision == 1000) {
$images->images[$i]->distance -= 0.5;
}
if ($images->images[$i]->different_square_true && $images->images[$i]->distance > 0.1) {
$images->images[$i]->different_square = true;
}
$token->setValue("p", $images->images[$i]->getPhotographerGridref(true));
示例8: smarty_block_highlight
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
require_once 'geograph/global.inc.php';
init_session();
$smarty = new GeographPage();
$USER->mustHavePerm("basic");
$template = 'admin_mykey.tpl';
$cacheid = '';
function smarty_block_highlight($params, $content, &$smarty, &$repeat)
{
return highlight_string(str_replace("\r", '', $content), true);
}
$smarty->register_block('highlight', 'smarty_block_highlight');
$db = NewADOConnection($GLOBALS['DSN']);
if (!$db) {
die('Database connection failed');
}
if (!empty($_GET['apikey'])) {
//load the info for editing the record
if ($_GET['apikey'] != '-new-') {
$arr = $db->GetRow("select *,INET_NTOA(ip) as ip_text from apikeys where enabled = 1 and apikey = " . $db->Quote($_GET['apikey']));
$smarty->assign($arr);
$token = new Token();
$token->setValue("i", $arr['id']);
$smarty->assign('access', $token->getToken());
$smarty->assign('shared', md5($CONF['token_secret'] . $arr['apikey']));
}
}
$smarty->display($template, $cacheid);
示例9: intval
if (!isset($dataarray['orderby'])) {
$dataarray['orderby'] = '';
}
$orderby = $dataarray['orderby'];
if ($dataarray['reverse_order_ind']) {
$orderby = preg_replace('/(,|$)/', ' desc$1', $orderby);
}
$sql .= ",orderby = " . $db->Quote($orderby);
if (!empty($dataarray['breakby'])) {
$sql .= ",breakby = " . $db->Quote($dataarray['breakby']);
}
$sql .= " WHERE id = " . intval($i);
$ok = $db->Execute($sql);
if ($ok) {
$token = new Token();
$token->setValue("i", $i);
$smarty->assign('token', $token->getToken());
$smarty->display('search_refine.tpl');
exit;
}
}
$display = $engine->getDisplayclass();
if (isset($_GET['displayclass']) && preg_match('/^\\w+$/', $_GET['displayclass'])) {
$display = $_GET['displayclass'];
if ($USER->registered && $USER->user_id == $engine->criteria->user_id && $_GET['displayclass'] != 'search' && $_GET['displayclass'] != 'searchtext') {
$engine->setDisplayclass($_GET['displayclass']);
} else {
//don't store search override permently
$engine->temp_displayclass = $display;
}
}
示例10: array
$pair = $db->getRow("\r\n\t\t\tSELECT p.compare_pair_id,gridimage_id1,gridimage_id2\r\n\t\t\tFROM compare_pair p\r\n\t\t\tWHERE compare_pair_id = ?", array($token->getValue("p")));
}
} else {
if ($USER->user_id) {
$where = "user_id = ?";
$a = array($USER->user_id);
} else {
$where = "user_id = 0 and `ipaddr` = INET_ATON(?) AND `ua` = ?";
$a = array(getRemoteIP(), $_SERVER['HTTP_USER_AGENT']);
}
$pair = $db->getRow("\r\n\t\tSELECT p.compare_pair_id,gridimage_id1,gridimage_id2\r\n\t\tFROM compare_pair p\r\n\t\tLEFT JOIN compare_done d ON (p.compare_pair_id = d.compare_pair_id AND {$where})\r\n\t\tWHERE status != 'rejected' AND d.compare_pair_id IS NULL", $a);
}
if (!empty($pair['compare_pair_id'])) {
$smarty->assign('pair_id', $pair['compare_pair_id']);
$token = new Token();
$token->setValue("p", $pair['compare_pair_id']);
$smarty->assign('token', $token->getToken());
require_once 'geograph/conversions.class.php';
$conv = new Conversions();
$image1 = new GridImage($pair['gridimage_id1']);
if ($image1->moderation_status != 'rejected') {
$rastermap1 = new RasterMap($image1->grid_square);
if ($image1->view_direction > -1) {
$smarty->assign('view_direction1', $image1->view_direction % 90 == 0 ? strtoupper(heading_string($image1->view_direction)) : ucwords(heading_string($image1->view_direction)));
}
list($lat, $long) = $conv->gridsquare_to_wgs84($image1->grid_square);
$smarty->assign('lat1', $lat);
$smarty->assign('long1', $long);
list($latdm, $longdm) = $conv->wgs84_to_friendly($lat, $long);
$smarty->assign('latdm1', $latdm);
$smarty->assign('longdm1', $longdm);
示例11: getToken
/**
* Return an opaque, url-safe token representing this map
* @access public
*/
function getToken()
{
$token = new Token();
$token->setValue("e", floor($this->nateastings / $this->divisor[$this->service]));
$token->setValue("n", floor($this->natnorthings / $this->divisor[$this->service]));
$token->setValue("s", $this->service);
if ($this->epoch != 'latest') {
$token->setValue("r", $this->epoch);
}
return $token->getToken();
}
示例12: loadItems
/**
* load all change items
* @access public
*/
function loadItems()
{
$db =& $this->_getDB();
if ($this->isValid()) {
$this->changes = $db->GetAll("select * from gridimage_ticket_item where gridimage_ticket_id={$this->gridimage_ticket_id}");
if (count($this->changes)) {
$token = new Token();
foreach ($this->changes as $i => $row) {
if (!empty($row['newvalue']) && $row['newvalue'] != -1) {
switch ($row['field']) {
case 'grid_reference':
$token->setValue("g", $row['newvalue']);
break;
case 'photographer_gridref':
$token->setValue("p", $row['newvalue']);
break;
case 'view_direction':
$token->setValue("v", $row['newvalue']);
break;
}
}
}
$count = count($token->data);
if ($count > 0 && !($count == 1 && $token->hasValue('v'))) {
$this->reopenmaptoken = $token->getToken();
}
}
}
}
示例13: buildSymbolToken
protected function buildSymbolToken(Token $token, Character $char)
{
$token->setType(TokenType::SYMBOL);
$token->setValue($char->getValue());
switch ($char->getValue()) {
// case ';':
// break;
case '(':
case ')':
break;
case '=':
case '!':
case '>':
case '<':
case '+':
case '-':
case '/':
case '*':
$prevchar = $char->getValue();
$char = $this->getCharacter();
if ($char->isEOL()) {
throw new SyntaxException($char->getLine(), $char->getColumn(), 'Broken expression "' . $prevchar . $char->getValue() . '"', __FILE__, __LINE__);
} elseif ($prevchar == '/' && $char->getValue() == '/') {
$token->setValue($prevchar . $char->getValue());
} elseif ($char->getValue() == '=') {
$token->setValue($prevchar . $char->getValue());
} elseif ($prevchar == '+' && $char->getValue() == '+') {
$token->setValue($prevchar . $char->getValue());
} elseif ($prevchar == '-' && $char->getValue() == '-') {
$token->setValue($prevchar . $char->getValue());
} else {
$this->ungetCharacter();
}
break;
case '&':
case '|':
$prevchar = $char->getValue();
$char = $this->getCharacter();
if ($char->isEOL()) {
throw new SyntaxException($char->getLine(), $char->getColumn(), 'Invalid expression "' . $prevchar . '"', __FILE__, __LINE__);
} elseif ($prevchar == $char->getValue()) {
$token->setValue($prevchar . $token->getValue());
} else {
$this->ungetCharacter();
}
break;
default:
break;
}
return $token;
}
示例14: inEmptyRequestInt
$l = inEmptyRequestInt('l', 0);
if (isset($_REQUEST['t'])) {
$ok = false;
$token = new Token();
if ($token->parse($_REQUEST['t'])) {
if ($token->hasValue("i")) {
$i = $token->getValue("i");
}
if ($token->hasValue("p")) {
$_GET['page'] = $token->getValue("p");
}
}
}
if (isset($_REQUEST['debug']) && $USER->hasPerm("admin")) {
$token = new Token();
$token->setValue("i", $i);
if (!empty($_GET['page'])) {
$token->setValue("p", $_GET['page']);
}
print $token->getToken();
}
if (isset($_GET['l']) && isset($_SESSION['gameToken'])) {
unset($_SESSION['gameToken']);
}
$game = new Game();
if (isset($_REQUEST['token'])) {
$game->setToken($_REQUEST['token']);
} elseif (isset($_SESSION['gameToken'])) {
$game->setToken($_SESSION['gameToken']);
}
if (isset($_REQUEST['debug']) && $USER->hasPerm("admin") && $game->i) {
示例15: ImageList
$imagelist = new ImageList();
$sql = "select gi.*,grid_reference " . "from gridimage as gi " . "inner join gridsquare as gs using(gridsquare_id) " . "where moderation_status != 'rejected' " . "and gi.user_id={$USER->user_id} " . ($max_gridimage_id ? " and gridimage_id < {$max_gridimage_id} " : '') . "order by gridimage_id desc limit 20";
$imagelist->_getImagesBySql($sql);
if (count($imagelist->images)) {
foreach ($imagelist->images as $i => $image) {
$imagelist->images[$i]->imagetakenString = getFormattedDate($image->imagetaken);
}
$smarty->assign_by_ref('images', $imagelist->images);
$first = $imagelist->images[0];
$smarty->assign('criteria', $first->submitted);
$last = $imagelist->images[count($imagelist->images) - 1];
$max_gridimage_id = $last->gridimage_id;
$count++;
if ($count < 10 && count($imagelist->images) == 20) {
$token = new Token();
$token->setValue("id", intval($max_gridimage_id));
$token->setValue("c", intval($count));
$smarty->assign('next', $token->getToken());
}
}
if ($max_gridimage_id && isset($_SERVER['HTTP_REFERER'])) {
$ref = @parse_url($_SERVER['HTTP_REFERER']);
if (!empty($ref['query'])) {
$ref_query = array();
parse_str($ref['query'], $ref_query);
if (!empty($ref_query['next'])) {
$smarty->assign('prev', $ref_query['next']);
}
} elseif ($ref['path'] == '/submissions.php') {
$smarty->assign('prev', 1);
}