本文整理汇总了PHP中item类的典型用法代码示例。如果您正苦于以下问题:PHP item类的具体用法?PHP item怎么用?PHP item使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了item类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: adicionarItem
public function adicionarItem($quantidadeItem, $valorItem)
{
$item = new item();
$item->setQuantidade($quantidadeItem);
$item->setValor($valorItem);
$this->itens[] = $item;
}
示例2: onActivate
public function onActivate(item $item, Player $player = null)
{
$tile = $this->getLevel()->getTile($this);
if ($tile instanceof FlowerPotTile) {
if ($tile->getFlowerPotItem() === item::AIR) {
switch ($item->getId()) {
case item::TALL_GRASS:
if ($item->getDamage() === 1) {
break;
}
case item::SAPLING:
case item::DEAD_BUSH:
case item::DANDELION:
case item::RED_FLOWER:
case item::BROWN_MUSHROOM:
case item::RED_MUSHROOM:
case item::CACTUS:
$tile->setFlowerPotData($item->getId(), $item->getDamage());
if ($player->isSurvival()) {
$item->count--;
}
return true;
break;
}
}
}
return false;
}
示例3: show_overdue
function show_overdue($template_name)
{
global $db;
global $TPL;
$current_user =& singleton("current_user");
$db = new db_alloc();
$temp = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
$today = date("Y", $temp) . "-" . date("m", $temp) . "-" . date("d", $temp);
$q = prepare("SELECT itemName,itemType,item.itemID,dateBorrowed,dateToBeReturned,loan.personID \n FROM loan,item \n WHERE dateToBeReturned < '%s' \n\t\t\t\t\t AND dateReturned = '0000-00-00' \n\t\t\t\t\t AND item.itemID = loan.itemID\n ", $today);
if (!have_entity_perm("loan", PERM_READ, $current_user, false)) {
$q .= prepare("AND loan.personID = %d", $current_user->get_id());
}
$db->query($q);
while ($db->next_record()) {
$i++;
$item = new item();
$loan = new loan();
$item->read_db_record($db);
$loan->read_db_record($db);
$item->set_values();
$loan->set_values();
$person = new person();
$person->set_id($loan->get_value("personID"));
$person->select();
$TPL["person"] = $person->get_name();
$TPL["overdue"] = "<a href=\"" . $TPL["url_alloc_item"] . "itemID=" . $item->get_id() . "&return=true\">Overdue!</a>";
include_template($template_name);
}
}
示例4: addItem
/**
* Adds item to the business table.
*/
public function addItem()
{
$item = new item();
$item->createItem($this->input->post(NULL, TRUE));
$bname = $this->session->userdata('bname');
$item->bname = $bname;
if ($this->db->insert('chkitem', $item)) {
$items = $this->item->getItems($bname);
echo $this->load->view('templates/item_table', array('items' => $items));
}
}
示例5: load
public function load()
{
$db = db::obtain();
$items = array();
$items_info = $db->fetch_array_pdo('SELECT * FROM ' . db::real_tablename('items'));
foreach ($items_info as $item_info) {
$item = new item();
$item->set_array($item_info);
$items[$item_info['id']] = $item;
}
return $items;
}
示例6: getItems
/**
* Ruft Liste von Text-Sperren ab
* @return array
*/
public function getItems()
{
$list = $this->dbcon->fetch($this->dbcon->select($this->table), true);
$res = array();
foreach ($list as $item) {
$wbItem = new item();
if ($wbItem->createFromDbObject($item)) {
$res[$wbItem->getId()] = $wbItem;
}
}
return $res;
}
示例7: show_items
function show_items($template_name)
{
global $TPL;
global $db;
global $db2;
$current_user =& singleton("current_user");
$today = date("Y") . "-" . date("m") . "-" . date("d");
$dbUsername = new db_alloc();
$db = new db_alloc();
$db2 = new db_alloc();
$db->query("select * from item order by itemName");
while ($db->next_record()) {
$i++;
$item = new item();
$item->read_db_record($db);
$db2->query("select * from loan where itemID=" . $item->get_id() . " and dateReturned='0000-00-00'");
$db2->next_record();
$loan = new loan();
$loan->read_db_record($db2);
$item->set_values();
// you need to have this repeated here for the a href bit below.
if ($loan->get_value("dateReturned") == "0000-00-00") {
if ($loan->have_perm(PERM_READ_WRITE)) {
// if item is overdue
if ($loan->get_value("dateToBeReturned") < $today) {
$ret = "Return Now!";
} else {
$ret = "Return";
}
$TPL["itemAction"] = "<td><a href=\"" . $TPL["url_alloc_item"] . "itemID=" . $TPL["itemID"] . "&return=true\">{$ret}</a></td>";
} else {
// if you don't have permission to borrow or return item.
$TPL["itemAction"] = "<td> </td>";
}
$TPL["status"] = "Due " . $loan->get_value("dateToBeReturned");
$dbUsername->query("select username from person where personID=" . $loan->get_value("personID"));
$dbUsername->next_record();
$TPL["person"] = "from " . $dbUsername->f("username");
} else {
// if the item is available
$TPL["status"] = "Available";
$TPL["person"] = "";
$TPL["itemAction"] = "<td><a href=\"" . $TPL["url_alloc_item"] . "itemID=" . $TPL["itemID"] . "&borrow=true\">Borrow</a></td>";
$TPL["dueBack"] = "";
}
$loan->set_values();
$item->set_values();
include_template($template_name);
}
}
示例8: add_photo
public function add_photo($id)
{
$album = ORM::factory("item", $id);
access::required("view", $album);
access::required("add", $album);
access::verify_csrf();
$file_validation = new Validation($_FILES);
$file_validation->add_rules("Filedata", "upload::valid", "upload::type[gif,jpg,png,flv,mp4]");
if ($file_validation->validate()) {
// SimpleUploader.swf does not yet call /start directly, so simulate it here for now.
if (!batch::in_progress()) {
batch::start();
}
$temp_filename = upload::save("Filedata");
try {
$name = substr(basename($temp_filename), 10);
// Skip unique identifier Kohana adds
$title = item::convert_filename_to_title($name);
$path_info = pathinfo($temp_filename);
if (array_key_exists("extension", $path_info) && in_array(strtolower($path_info["extension"]), array("flv", "mp4"))) {
$movie = movie::create($album, $temp_filename, $name, $title);
log::success("content", t("Added a movie"), html::anchor("movies/{$movie->id}", t("view movie")));
} else {
$photo = photo::create($album, $temp_filename, $name, $title);
log::success("content", t("Added a photo"), html::anchor("photos/{$photo->id}", t("view photo")));
}
} catch (Exception $e) {
unlink($temp_filename);
throw $e;
}
unlink($temp_filename);
}
print "File Received";
}
示例9: index
public function index()
{
if (isset($_GET['cw'])) {
setcookie('cw_agree', '1', time() + 60 * 60 * 24, '/');
url::redirect(item::root()->abs_url());
}
}
示例10: createFile
public function createFile($name, $data = null)
{
try {
access::required("view", $this->item);
access::required("add", $this->item);
} catch (Kohana_404_Exception $e) {
throw new Sabre_DAV_Exception_Forbidden("Access denied");
}
if (substr($name, 0, 1) == ".") {
return true;
}
try {
$tempfile = tempnam(TMPPATH, "dav");
$target = fopen($tempfile, "wb");
stream_copy_to_stream($data, $target);
fclose($target);
$item = ORM::factory("item");
$item->name = $name;
$item->title = item::convert_filename_to_title($item->name);
$item->description = "";
$item->parent_id = $this->item->id;
$item->set_data_file($tempfile);
$item->type = "photo";
$item->save();
} catch (Exception $e) {
unlink($tempfile);
throw $e;
}
}
示例11: random
public function random($item_id)
{
$item = ORM::factory("item", $item_id);
access::required("view", $item);
item::set_display_context_callback("Albums_Controller::get_display_context");
url::redirect($item->abs_url());
}
示例12: user_created
/**
* Create an album for the newly created user and give him view and edit permissions.
*/
static function user_created($user)
{
// Create a group with the same name, if necessary
$group_name = "auto: {$user->name}";
$group = identity::lookup_group_by_name($group_name);
if (!$group) {
$group = identity::create_group($group_name);
identity::add_user_to_group($user, $group);
}
// Create an album for the user, if it doesn't exist
$album = ORM::factory("item")->where("parent_id", "=", item::root()->id)->where("name", "=", $user->name)->find();
if (!$album->loaded()) {
$album->type = "album";
$album->name = $user->name;
$album->title = "{$user->name}'s album";
$album->parent_id = item::root()->id;
$album->sort_column = "weight";
$album->sort_order = "asc";
$album->save();
access::allow($group, "view", item::root());
access::allow($group, "view_full", $album);
access::allow($group, "edit", $album);
access::allow($group, "add", $album);
}
}
示例13: get_test
public function get_test()
{
$tag = tag::add(item::root(), "tag1")->reload();
$request = new stdClass();
$request->url = rest::url("tag", $tag);
$this->assert_equal_array(array("url" => rest::url("tag", $tag), "entity" => $tag->as_array(), "relationships" => array("items" => array("url" => rest::url("tag_items", $tag), "members" => array(rest::url("tag_item", $tag, item::root()))))), tag_rest::get($request));
}
示例14: site_menu
static function site_menu($menu, $theme)
{
if ($theme->page_type != "login") {
$menu->append(Menu::factory("link")->id("home")->label(t("Home"))->url(item::root()->url()));
$item = $theme->item();
$can_edit = $item && access::can("edit", $item);
$can_add = $item && access::can("add", $item);
if ($can_add) {
$menu->append($add_menu = Menu::factory("submenu")->id("add_menu")->label(t("Add")));
$add_menu->append(Menu::factory("dialog")->id("add_photos_item")->label(t("Add photos"))->url(url::site("simple_uploader/app/{$item->id}")));
if ($item->is_album()) {
$add_menu->append(Menu::factory("dialog")->id("add_album_item")->label(t("Add an album"))->url(url::site("form/add/albums/{$item->id}?type=album")));
}
}
$menu->append($options_menu = Menu::factory("submenu")->id("options_menu")->label(t("Photo options")));
if ($item && ($can_edit || $can_add)) {
if ($can_edit) {
$options_menu->append(Menu::factory("dialog")->id("edit_item")->label($item->is_album() ? t("Edit album") : t("Edit photo"))->url(url::site("form/edit/{$item->type}s/{$item->id}")));
}
if ($item->is_album()) {
$options_menu->label(t("Album options"));
if ($can_edit) {
$options_menu->append(Menu::factory("dialog")->id("edit_permissions")->label(t("Edit permissions"))->url(url::site("permissions/browse/{$item->id}")));
}
}
}
if (user::active()->admin) {
$menu->append($admin_menu = Menu::factory("submenu")->id("admin_menu")->label(t("Admin")));
gallery::admin_menu($admin_menu, $theme);
module::event("admin_menu", $admin_menu, $theme);
}
module::event("site_menu", $menu, $theme);
}
}
示例15: get
static function get($block_id, $theme)
{
$block = "";
switch ($block_id) {
case "random_image":
// The random_query approach is flawed and doesn't always return a
// result when there actually is one. Retry a *few* times.
// @todo Consider another fallback if further optimizations are necessary.
$image_count = module::get_var("image_block", "image_count");
$items = array();
for ($i = 0; $i < $image_count; $i++) {
$attempts = 0;
$item = null;
do {
$item = item::random_query()->where("type", "!=", "album")->find_all(1)->current();
} while (!$item && $attempts++ < 3);
if ($item) {
$items[] = $item;
}
}
if ($items) {
$block = new Block();
$block->css_id = "g-image-block";
$block->title = t2("Random image", "Random images", $image_count);
$block->content = new View("image_block_block.html");
$block->content->items = $items;
}
break;
}
return $block;
}