本文整理汇总了PHP中getItemByID函数的典型用法代码示例。如果您正苦于以下问题:PHP getItemByID函数的具体用法?PHP getItemByID怎么用?PHP getItemByID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getItemByID函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buy
/**
* Command for current user to purchase a quantity of a specific item
*
* @param quantity int The quantity of the item to purchase
* @param item string The identity of the item to purchase
* @return Array
*/
public function buy()
{
$in_quantity = in('quantity');
$in_item = in('item');
$gold = get_gold($this->sessionData['char_id']);
$current_item_cost = 0;
$no_funny_business = false;
// Pull the item info from the database
$item_costs = $this->itemForSaleCosts();
$item = getItemByID(item_id_from_display_name($in_item));
$quantity = whichever(positive_int($in_quantity), 1);
$item_text = null;
if ($item instanceof Item) {
$item_text = $quantity > 1 ? $item->getPluralName() : $item->getName();
$purchaseOrder = new PurchaseOrder();
// Determine the quantity from input or as a fallback, default of 1.
$purchaseOrder->quantity = $quantity;
$purchaseOrder->item = $item;
$potential_cost = isset($item_costs[$purchaseOrder->item->identity()]['item_cost']) ? $item_costs[$purchaseOrder->item->identity()]['item_cost'] : null;
$current_item_cost = first_value($potential_cost, 0);
$current_item_cost = $current_item_cost * $purchaseOrder->quantity;
if (!$this->sessionData['char_id'] || !$purchaseOrder->item || $purchaseOrder->quantity < 1) {
$no_funny_business = true;
} else {
if ($gold >= $current_item_cost) {
// Has enough gold.
try {
add_item($this->sessionData['char_id'], $purchaseOrder->item->identity(), $purchaseOrder->quantity);
subtract_gold($this->sessionData['char_id'], $current_item_cost);
} catch (\Exception $e) {
$invalid_item = $e->getMessage();
error_log('Invalid Item attempted :' . $invalid_item);
$no_funny_business = true;
}
}
}
} else {
$no_funny_business = true;
}
$parts = array('current_item_cost' => $current_item_cost, 'quantity' => $quantity, 'item_text' => $item_text, 'no_funny_business' => $no_funny_business, 'view_part' => 'buy');
return $this->render($parts);
}
示例2: trim
if (!$logged) {
$errormessage .= 'Please login first.';
} else {
$buy_id = (int) $_POST['buy_id'];
$buy_name = trim($_POST['buy_name']);
$buy_from = trim($_POST['buy_from']);
if (empty($buy_from)) {
$buy_from = 'Anonymous';
}
if (empty($buy_id)) {
$errormessage .= 'Please <a href="?subtopic=shopsystem">select item</a> first.';
} else {
if (!check_name($buy_from)) {
$errormessage .= 'Invalid nick ("from player") format. Please <a href="?subtopic=shopsystem&action=select_player&buy_id=' . $buy_id . '">select other name</a> or contact with administrator.';
} else {
$buy_offer = getItemByID($buy_id);
if (isset($buy_offer['id'])) {
if ($user_premium_points >= $buy_offer['points']) {
if (check_name($buy_name)) {
$buy_player = new Player();
$buy_player->find($buy_name);
if ($buy_player->isLoaded()) {
$buy_player_account = $buy_player->getAccount();
if ($_SESSION['viewed_confirmation_page'] == 'yes' && $_POST['buy_confirmed'] == 'yes') {
if ($buy_offer['type'] == 'item') {
$sql = 'INSERT INTO ' . $SQL->tableName('z_ots_comunication') . ' (' . $SQL->fieldName('id') . ',' . $SQL->fieldName('name') . ',' . $SQL->fieldName('type') . ',' . $SQL->fieldName('action') . ',' . $SQL->fieldName('param1') . ',' . $SQL->fieldName('param2') . ',' . $SQL->fieldName('param3') . ',' . $SQL->fieldName('param4') . ',' . $SQL->fieldName('param5') . ',' . $SQL->fieldName('param6') . ',' . $SQL->fieldName('param7') . ',' . $SQL->fieldName('delete_it') . ') VALUES (NULL, ' . $SQL->quote($buy_player->getName()) . ', ' . $SQL->quote('login') . ', ' . $SQL->quote('give_item') . ', ' . $SQL->quote($buy_offer['item_id']) . ', ' . $SQL->quote($buy_offer['item_count']) . ', ' . $SQL->quote('') . ', ' . $SQL->quote('') . ', ' . $SQL->quote('item') . ', ' . $SQL->quote($buy_offer['name']) . ', ' . $SQL->quote($buy_offer['id']) . ', ' . $SQL->quote(1) . ');';
$SQL->query($sql);
$save_transaction = 'INSERT INTO ' . $SQL->tableName('z_shop_history_item') . ' (' . $SQL->fieldName('id') . ',' . $SQL->fieldName('to_name') . ',' . $SQL->fieldName('to_account') . ',' . $SQL->fieldName('from_nick') . ',' . $SQL->fieldName('from_account') . ',' . $SQL->fieldName('price') . ',' . $SQL->fieldName('offer_id') . ',' . $SQL->fieldName('trans_state') . ',' . $SQL->fieldName('trans_start') . ',' . $SQL->fieldName('trans_real') . ') VALUES (' . $SQL->lastInsertId() . ', ' . $SQL->quote($buy_player->getName()) . ', ' . $SQL->quote($buy_player_account->getId()) . ', ' . $SQL->quote($buy_from) . ', ' . $SQL->quote($account_logged->getId()) . ', ' . $SQL->quote($buy_offer['points']) . ', ' . $SQL->quote($buy_offer['name']) . ', ' . $SQL->quote('wait') . ', ' . $SQL->quote(time()) . ', ' . $SQL->quote(0) . ');';
$SQL->query($save_transaction);
$account_logged->setCustomField('premium_points', $user_premium_points - $buy_offer['points']);
$user_premium_points = $user_premium_points - $buy_offer['points'];
示例3: __construct
//.........这里部分代码省略.........
$this->channel_title = html_encode($this->channel_title . ' ' . getBare($albumname));
$this->imagesize = $this->getImageSize();
require_once SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/image_album_statistics.php';
break;
case 'news':
//Zenpage News
if (!getOption('externalFeed_articles')) {
self::feed404();
}
$titleappendix = gettext(' (Latest news)');
switch ($this->sortorder) {
case 'popular':
$titleappendix = gettext(' (Most popular news)');
break;
case 'mostrated':
$titleappendix = gettext(' (Most rated news)');
break;
case 'toprated':
$titleappendix = gettext(' (Top rated news)');
break;
case 'random':
$titleappendix = gettext(' (Random news)');
break;
}
$this->channel_title = html_encode($this->channel_title . $this->cattitle . $titleappendix);
$this->imagesize = $this->getImageSize();
$this->itemnumber = getOption("externalFeed_zenpage_items");
// # of Items displayed on the feed
require_once SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/image_album_statistics.php';
require_once SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/zenpage/zenpage-template-functions.php';
break;
case 'pages':
//Zenpage News
if (!getOption('externalFeed_pages')) {
self::feed404();
}
switch ($this->sortorder) {
case 'popular':
$titleappendix = gettext(' (Most popular pages)');
break;
case 'mostrated':
$titleappendix = gettext(' (Most rated pages)');
break;
case 'toprated':
$titleappendix = gettext(' (Top rated pages)');
break;
case 'random':
$titleappendix = gettext(' (Random pages)');
break;
default:
$titleappendix = gettext(' (Latest pages)');
break;
}
$this->channel_title = html_encode($this->channel_title . $titleappendix);
require_once SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/zenpage/zenpage-template-functions.php';
break;
case 'comments':
//Comments
if (!getOption('externalFeed_comments')) {
self::feed404();
}
if ($this->id) {
switch ($this->commentfeedtype) {
case 'album':
$table = 'albums';
break;
case 'image':
$table = 'images';
break;
case 'news':
$table = 'news';
break;
case 'page':
$table = 'pages';
break;
default:
self::feed404();
break;
}
$this->itemobj = getItemByID($table, $this->id);
if ($this->itemobj) {
$title = ' - ' . $this->itemobj->getTitle();
} else {
self::feed404();
}
} else {
$this->itemobj = NULL;
$title = NULL;
}
$this->channel_title = html_encode($this->channel_title . $title . gettext(' (latest comments)'));
if (extensionEnabled('zenpage')) {
require_once SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/zenpage/zenpage-template-functions.php';
}
break;
case 'null':
//we just want the class instantiated
return;
}
$this->feeditems = $this->getitems();
}
示例4: getItemByID
/**
* Gets an item object by id
*
* @param string $table database table to search
* @param int $id id of the item to get
* @return mixed
*/
function getItemByID($table, $id)
{
if ($result = query_single_row('SELECT * FROM ' . prefix($table) . ' WHERE id =' . (int) $id)) {
switch ($table) {
case 'images':
if ($alb = getItemByID('albums', $result['albumid'])) {
return newImage($alb, $result['filename'], true);
}
break;
case 'albums':
return newAlbum($result['folder'], false, true);
case 'news':
return new ZenpageNews($result['titlelink']);
case 'pages':
return new ZenpagePage($result['titlelink']);
case 'news_categories':
return new ZenpageCategory($result['titlelink']);
}
}
return NULL;
}
示例5: __construct
//.........这里部分代码省略.........
$titleappendix = gettext(' (Latest news and albums)');
break;
case 'withimages':
case 'withimages_mtime':
case 'withimages_publishdate':
$titleappendix = gettext(' (Latest news and images)');
break;
default:
switch ($this->sortorder) {
case 'popular':
$titleappendix = gettext(' (Most popular news)');
break;
case 'mostrated':
$titleappendix = gettext(' (Most rated news)');
break;
case 'toprated':
$titleappendix = gettext(' (Top rated news)');
break;
case 'random':
$titleappendix = gettext(' (Random news)');
break;
}
break;
}
$this->channel_title = html_encode($this->channel_title . $this->cattitle . $titleappendix);
$this->imagesize = $this->getImageSize();
$this->itemnumber = getOption("RSS_zenpage_items");
// # of Items displayed on the feed
require_once SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/image_album_statistics.php';
require_once SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/zenpage/zenpage-template-functions.php';
break;
case 'pages':
//Zenpage News RSS
if (!getOption('RSS_pages')) {
self::feed404();
}
switch ($this->sortorder) {
case 'popular':
$titleappendix = gettext(' (Most popular pages)');
break;
case 'mostrated':
$titleappendix = gettext(' (Most rated pages)');
break;
case 'toprated':
$titleappendix = gettext(' (Top rated pages)');
break;
case 'random':
$titleappendix = gettext(' (Random pages)');
break;
default:
$titleappendix = gettext(' (Latest pages)');
break;
}
$this->channel_title = html_encode($this->channel_title . $titleappendix);
require_once SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/zenpage/zenpage-template-functions.php';
break;
case 'comments':
//Comments RSS
if (!getOption('RSS_comments')) {
self::feed404();
}
if ($this->id) {
switch ($this->commentfeedtype) {
case 'album':
$table = 'albums';
break;
case 'image':
$table = 'images';
break;
case 'news':
$table = 'news';
break;
case 'page':
$table = 'pages';
break;
default:
self::feed404();
break;
}
$this->itemobj = getItemByID($table, $this->id);
if ($this->itemobj) {
$title = ' - ' . $this->itemobj->getTitle();
} else {
self::feed404();
}
} else {
$this->itemobj = NULL;
$title = NULL;
}
$this->channel_title = html_encode($this->channel_title . $title . gettext(' (latest comments)'));
if (extensionEnabled('zenpage')) {
require_once SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/zenpage/zenpage-template-functions.php';
}
break;
case 'null':
//we just want the class instantiated
return;
}
$this->feeditems = $this->getitems();
}
示例6: gettext
$link = '<a href = "' . $obj->getLink() . '#zp_comment_id_' . $id . '">[' . gettext("article") . '] ' . $obj->getTitle() . "</a> ";
}
}
break;
case "pages":
// ZENPAGE: if plugin is installed
if (extensionEnabled('zenpage')) {
$obj = getItemByID('pages', $comment['ownerid']);
if ($obj) {
$link = "<a href=\"" . $obj->getLink() . '#zp_comment_id_' . $id . '">[' . gettext("page") . '] ' . $obj->getTitle() . "</a>";
}
}
break;
default:
// all the image types
$obj = getItemByID('images', $comment['ownerid']);
if ($obj) {
$link = "<a href=\"" . $obj->getLink() . '#zp_comment_id_' . $id . '">[' . gettext('image') . '] ' . $obj->getTitle() . "</a>";
}
break;
}
$date = myts_date('%m/%d/%Y %I:%M %p', $comment['date']);
$website = $comment['website'];
$fullcomment = sanitize($comment['comment'], 2);
$shortcomment = truncate_string(getBare($fullcomment), 123);
$inmoderation = $comment['inmoderation'];
$private = $comment['private'];
$anon = $comment['anon'];
?>
<tr class="newstr">
<td><?php
示例7: useItem
/**
* Use an item on a target
* @note /use/ is aliased to useItem externally because use is a php reserved keyword
*/
public function useItem($give = false, $self_use = false)
{
// Formats are:
// http://nw.local/item/self_use/amanita/
// http://nw.local/item/use/shuriken/10/
// http://nw.local/item/give/shuriken/10/
// http://nw.local/item/use/shuriken/156001/
$slugs = $this->parse_slugs($give, $self_use);
// Pull the parsed slugs
$link_back = $slugs['link_back'];
$selfTarget = $slugs['selfTarget'];
$item_in = $slugs['item_in'];
// Item identifier, either it's id or internal name
$in_target = $slugs['in_target'];
$give = $slugs['give'];
$target = $in_target;
if (positive_int($in_target)) {
$target_id = positive_int($target);
} else {
$target_id = get_char_id($target);
}
$give = in_array($give, array('on', 'Give'));
$player = new Player(self_char_id());
$victim_alive = true;
$using_item = true;
$item_used = true;
$stealthLost = false;
$error = false;
$suicide = false;
$kill = false;
$repeat = false;
$ending_turns = null;
$turns_change = null;
$turns_to_take = null;
$gold_mod = NULL;
$result = NULL;
$targetResult = NULL;
// result message to send to target of item use
$targetName = '';
$targetHealth = '';
$bountyMessage = '';
$resultMessage = '';
$alternateResultMessage = '';
if ($item_in == (int) $item_in && is_numeric($item_in)) {
// Can be cast to an id.
$item = $item_obj = getItemByID($item_in);
} elseif (is_string($item_in)) {
$item = $item_obj = $this->getItemByIdentity($item_in);
} else {
$item = null;
}
if (!is_object($item)) {
return new RedirectResponse(WEB_ROOT . 'inventory?error=noitem');
} else {
$item_count = $this->itemCount($player->id(), $item);
// Check whether use on self is occurring.
$self_use = $selfTarget || $target_id === $player->id();
if ($self_use) {
$target = $player->name();
$targetObj = $player;
} else {
if ($target_id) {
$targetObj = new Player($target_id);
$target = $targetObj->name();
}
}
$starting_turns = $player->turns;
$username_turns = $starting_turns;
$username_level = $player->level;
if ($targetObj instanceof Player && $targetObj->id()) {
$targets_turns = $targetObj->turns;
$targets_level = $targetObj->level;
$target_hp = $targetObj->health;
} else {
$targets_turns = $targets_level = $target_hp = null;
}
$max_power_increase = 10;
$level_difference = $targets_level - $username_level;
$level_check = $username_level - $targets_level;
$near_level_power_increase = $this->nearLevelPowerIncrease($level_difference, $max_power_increase);
// Sets the page to link back to.
if ($target_id && ($link_back == "" || $link_back == 'player') && $target_id != $player->id()) {
$return_to = 'player';
} else {
$return_to = 'inventory';
}
// Exceptions to the rules, using effects.
if ($item->hasEffect('wound')) {
// Minor damage by default items.
$item->setTargetDamage(rand(1, $item->getMaxDamage()));
// DEFAULT, overwritable.
// e.g. Shuriken slices, for some reason.
if ($item->hasEffect('slice')) {
// Minor slicing damage.
$item->setTargetDamage(rand(1, max(9, $player->getStrength() - 4)) + $near_level_power_increase);
}
//.........这里部分代码省略.........
示例8: listDBUses
function listDBUses($pattern)
{
$lookfor = array('images', 'albums', 'news', 'pages');
$found = array();
foreach ($lookfor as $table) {
echo '<br /><strong>' . sprintf(gettext('%s table'), $table) . '</strong>';
$output = false;
$sql = 'SELECT * FROM ' . prefix($table) . ' WHERE `codeblock` <> "" and `codeblock` IS NOT NULL and `codeblock`!="a:0:{}"';
$result = query($sql);
while ($row = db_fetch_assoc($result)) {
$codeblocks = getSerializedArray($row['codeblock']);
foreach ($codeblocks as $key => $codeblock) {
switch ($table) {
case 'news':
case 'pages':
$what = $row['titlelink'] . '::' . $key;
break;
case 'images':
$album = getItemByID('albums', $row['albumid']);
$what = $album->name . ':' . $row['filename'] . '::' . $key;
break;
case 'albums':
$what = $row['folder'] . '::' . $key;
break;
}
if (formatList($what, $codeblock, $pattern)) {
$output = true;
}
}
}
if ($output) {
echo '</ul>';
} else {
?>
<p class="messagebox"><?php
echo gettext('No calls on deprecated functions were found.');
?>
</p>
<?php
}
}
return $output;
}
示例9: recordMissing
function recordMissing($table, $row, $image)
{
global $missingImages;
$obj = getItemByID($table, $row['id']);
$missingImages[] = '<a href="' . $obj->getLink() . '">' . $obj->getTitle() . '</a> (' . html_encode($image) . ')<br />';
}
示例10: OR
if (isset($result['EXIFGPSLatitude'])) {
$where .= ' OR (`GPSLatitude` IS NULL AND NOT `EXIFGPSLatitude` IS NULL)';
} else {
if (isset($result['EXIFGPSLongitude'])) {
$where .= ' OR (`GPSLongitude` IS NULL AND NOT `EXIFGPSLongitude` IS NULL)';
} else {
if (isset($result['EXIFGPSAltitude'])) {
$where .= ' OR (`GPSAltitude` IS NULL AND NOT `EXIFGPSAltitude` IS NULL)';
}
}
}
if (!empty($where)) {
$sql = 'SELECT `id` FROM ' . prefix('images') . ' WHERE ' . $where;
$result = query($sql);
while ($row = db_fetch_assoc($result)) {
$img = getItemByID('images', $row['id']);
foreach (array('EXIFGPSLatitude', 'EXIFGPSLongitude') as $source) {
$data = $img->get($source);
if (!empty($data)) {
if (in_array(strtoupper($img->get($source . 'Ref')), array('S', 'W'))) {
$data = -$data;
}
$img->set(substr($source, 4), $data);
}
}
$alt = $img->get('EXIFGPSAltitude');
if (!empty($alt)) {
if ($img->get('EXIFGPSAltitudeRef') == '-') {
$alt = -$alt;
}
$img->set('GPSAltitude', $alt);
示例11: garbageCollect
//.........这里部分代码省略.........
if ($albumids) {
while ($row = db_fetch_assoc($albumids)) {
$idsofalbums[] = $row['id'];
}
db_free_result($albumids);
}
$imageAlbums = query("SELECT DISTINCT `albumid` FROM " . prefix('images'));
/* albumids of all the images */
$albumidsofimages = array();
if ($imageAlbums) {
while ($row = db_fetch_assoc($imageAlbums)) {
$albumidsofimages[] = $row['albumid'];
}
db_free_result($imageAlbums);
}
$orphans = array_diff($albumidsofimages, $idsofalbums);
/* albumids of images with no album */
if (count($orphans) > 0) {
/* delete dead images from the DB */
$sql = "DELETE FROM " . prefix('images') . " WHERE ";
foreach ($orphans as $id) {
if (is_null($id)) {
$sql .= "`albumid` is NULL OR ";
} else {
$sql .= " `albumid`='" . $id . "' OR ";
}
}
$sql = substr($sql, 0, -4);
query($sql);
// Then go into existing albums recursively to clean them... very invasive.
foreach ($this->getAlbums(0) as $folder) {
$album = newAlbum($folder);
if (!$album->isDynamic()) {
if (is_null($album->getDateTime())) {
// see if we can get one from an image
$images = $album->getImages(0, 0);
if (count($images) > 0) {
$image = newImage($album, array_shift($images));
$album->setDateTime($image->getDateTime());
$album->save();
}
}
$album->garbageCollect(true);
}
zp_apply_filter('album_refresh', $album);
}
}
}
/* Look for image records where the file no longer exists. While at it, check for images with IPTC data to update the DB */
$start = array_sum(explode(" ", microtime()));
// protect against too much processing.
if (!empty($restart)) {
$restartwhere = ' WHERE `id`>' . $restart . ' AND `mtime`=0';
} else {
$restartwhere = ' WHERE `mtime`=0';
}
define('RECORD_LIMIT', 5);
$sql = 'SELECT * FROM ' . prefix('images') . $restartwhere . ' ORDER BY `id` LIMIT ' . (RECORD_LIMIT + 2);
$images = query($sql);
if ($images) {
$c = 0;
while ($image = db_fetch_assoc($images)) {
$albumobj = getItemByID('albums', $image['albumid']);
if ($albumobj->exists && file_exists($imageName = internalToFilesystem(ALBUM_FOLDER_SERVERPATH . $albumobj->name . '/' . $image['filename']))) {
if ($image['mtime'] != ($mtime = filemtime($imageName))) {
// file has changed since we last saw it
$imageobj = newImage($albumobj, $image['filename']);
$imageobj->set('mtime', $mtime);
$imageobj->updateMetaData();
// prime the EXIF/IPTC fields
$imageobj->updateDimensions();
// update the width/height & account for rotation
$imageobj->save();
zp_apply_filter('image_refresh', $imageobj);
}
} else {
$sql = 'DELETE FROM ' . prefix('images') . ' WHERE `id`="' . $image['id'] . '";';
$result = query($sql);
$sql = 'DELETE FROM ' . prefix('comments') . ' WHERE `type` IN (' . zp_image_types('"') . ') AND `ownerid` ="' . $image['id'] . '";';
$result = query($sql);
}
if (++$c >= RECORD_LIMIT) {
return $image['id'];
// avoide excessive processing
}
}
db_free_result($images);
}
// cleanup the tables
$resource = db_show('tables');
if ($resource) {
while ($row = db_fetch_assoc($resource)) {
$tbl = array_shift($row);
query('OPTIMIZE TABLE `' . $tbl . '`');
}
db_free_result($resource);
}
}
return false;
}
示例12: getItemByID
$ending_turns = null;
$turns_change = null;
$turns_to_take = null;
$gold_mod = NULL;
$result = NULL;
$targetResult = NULL;
// result message to send to target of item use
$targetName = '';
$targetHealth = '';
$targetHealthPercent = '';
$bountyMessage = '';
$resultMessage = '';
$alternateResultMessage = '';
if ($item_in == (int) $item_in && is_numeric($item_in)) {
// Can be cast to an id.
$item = $item_obj = getItemByID($item_in);
} elseif (is_string($item_in)) {
$item = $item_obj = getItemByIdentity($item_in);
} else {
$item = null;
}
if (!is_object($item)) {
error_log('Invalid item identifier (' . (is_string($item_in) ? $item_in : 'non-string') . ') sent to page from ' . (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '(no referrer)') . '.');
redirect(WEB_ROOT . 'inventory.php?error=noitem');
}
$item_count = item_count($user_id, $item);
// Check whether use on self is occurring.
$self_use = $selfTarget || $target_id === $user_id;
if ($self_use) {
$target = $username;
$targetObj = $player;
示例13: json_encode
$handle = $link->prepare('SELECT '.$table_item.'.ID, '.$table_item.'.UUID, '.$table_item.'.Code, Description, ItemTypeID, Price, UnitID, QuantityOnHand, UseCombination FROM '.$table_item.' LEFT JOIN '.$table_inventoryOnHand.' ON '.$table_inventoryOnHand.'.ItemID = '.$table_item.'.ID WHERE code = :code');
$handle->bindParam(':code', $code);
}
$handle->execute();
if($product = $handle->fetchObject()){
if($bBarcode){
$product->barcode = $code;
}
echo json_encode($product);
}
else echo json_encode(false);*/
$itemBarcode = getItemBarcode($link, $code);
$item = null;
if ($itemBarcode) {
$item = getItemByID($link, $itemBarcode->ItemID);
//$bBarcode = true;
} else {
$item = getItemByCode($link, $code);
}
if ($item) {
//if($bBarcode){
if ($itemBarcode) {
$item->barcode = $code;
if ($itemBarcode->unitID) {
$item->UnitID = $itemBarcode->unitID;
}
if ($itemBarcode->itemCombinationID) {
$combinationInfo = getCombinationInfo($link, $item->ID, $itemBarcode->itemCombinationID);
if ($combinationInfo) {
$quantityOnHand = getQuantityOnHand($link, $item->ID, $itemBarcode->itemCombinationID);
示例14: printLatestComments
/**
* Prints latest comments for images, albums, news and pages
*
* @param see getLatestComments
*
*/
function printLatestComments($number, $shorten = '123', $type = "all", $item = NULL, $ulid = 'showlatestcomments')
{
$comments = getLatestComments($number, $type, $item);
echo '<ul id="' . $ulid . $item . "\">\n";
foreach ($comments as $comment) {
if ($comment['anon'] === "0") {
$author = " " . gettext("by") . " " . $comment['name'];
} else {
$author = "";
}
$shortcomment = shortenContent($comment['comment'], $shorten, '');
$website = $comment['website'];
$date = $comment['date'];
switch ($comment['type']) {
case 'albums':
$album = getItemByID('albums', $comment['ownerid']);
if ($album) {
echo '<li><a href="' . $album->getLink() . '" class="commentmeta">' . $album->getTitle() . $author . "</a><br />\n";
echo '<span class="commentbody">' . $shortcomment . '</span></li>';
}
break;
case 'images':
$image = getItemByID('images', $comment['ownerid']);
if ($image) {
echo '<li><a href="' . $image->getLink() . '" class="commentmeta">' . $image->album->gettitle() . ': ' . $image->getTitle() . $author . "</a><br />\n";
echo '<span class="commentbody">' . $shortcomment . '</span></li>';
}
break;
case 'news':
$news = getItemByID('news', $comment['ownerid']);
if ($news) {
echo '<li><a href="' . $news->getLink() . '" class="commentmeta">' . gettext('Article') . ':' . $news->getTitle() . $author . "</a><br />\n";
echo '<span class="commentbody">' . $shortcomment . '</span></li>';
}
break;
case 'pages':
$page = getItemByID('news', $comment['ownerid']);
if ($page) {
echo '<li><a href="' . $page->getLink() . '" class="commentmeta">' . gettext('Article') . ':' . $page->getTitle() . $author . "</a><br />\n";
echo '<span class="commentbody">' . $shortcomment . '</span></li>';
}
break;
}
}
echo "</ul>\n";
}
示例15: getPages
/**
* Gets all pages or published ones.
*
* NOTE: Since this function only returns titlelinks for use with the object model it does not exclude pages that are password protected
*
* @param bool $published TRUE for published or FALSE for all pages including un-published
* @param bool $toplevel TRUE for only the toplevel pages
* @param int $number number of pages to get (NULL by default for all)
* @param string $sorttype NULL for the standard order as sorted on the backend, "title", "date", "id", "popular", "mostrated", "toprated", "random"
* @param string $sortdirection false for ascenting, true for descending
* @return array
*/
function getPages($published = NULL, $toplevel = false, $number = NULL, $sorttype = NULL, $sortdirection = NULL)
{
global $_zp_loggedin;
if (is_null($sortdirection)) {
$sortdirection = $this->getSortDirection('pages');
}
if (is_null($sorttype)) {
$sorttype = $this->getSortType('pages');
if (empty($sorttype)) {
$sorttype = 'date';
}
}
if (is_null($published)) {
$published = !zp_loggedin();
$all = zp_loggedin(MANAGE_ALL_PAGES_RIGHTS | VIEW_UNPUBLISHED_PAGE_RIGHTS);
} else {
$all = !$published;
}
$published = $published && !zp_loggedin(ZENPAGE_PAGES_RIGHTS);
$now = date('Y-m-d H:i:s');
$gettop = '';
if ($published) {
if ($toplevel) {
$gettop = " AND parentid IS NULL";
}
$show = " WHERE `show` = 1 AND date <= '" . $now . "'" . $gettop;
} else {
if ($toplevel) {
$gettop = " WHERE parentid IS NULL";
}
$show = $gettop;
}
if ($sortdirection) {
$sortdir = ' DESC';
} else {
$sortdir = ' ASC';
}
switch ($sorttype) {
default:
$sortorder = $sorttype;
break;
case 'popular':
$sortorder = 'hitcounter';
break;
case 'mostrated':
$sortorder = 'total_votes';
break;
case 'toprated':
if (empty($sortdir)) {
$sortdir = ' DESC';
}
$sortorder = '(total_value/total_votes) ' . $sortdir . ', total_value';
break;
case 'random':
$sortorder = 'RAND()';
$sortdir = '';
break;
}
$all_pages = array();
// Disabled cache var for now because it does not return un-publishded and published if logged on index.php somehow if logged in.
$result = query('SELECT * FROM ' . prefix('pages') . $show . ' ORDER by `' . $sortorder . '`' . $sortdir);
if ($result) {
while ($row = db_fetch_assoc($result)) {
if ($all || $row['show']) {
$all_pages[] = $row;
} else {
if ($_zp_loggedin) {
$page = newPage($row['titlelink']);
if ($page->subRights()) {
$all_pages[] = $row;
} else {
$parentid = $page->getParentID();
if ($parentid) {
$parent = getItemByID('pages', $parentid);
if ($parent->subRights() & MANAGED_OBJECT_RIGHTS_VIEW) {
$all_pages[] = $row;
}
}
}
}
}
if ($number && count($result) >= $number) {
break;
}
}
db_free_result($result);
}
return $all_pages;
//.........这里部分代码省略.........