Inheritance: extends BaseItem
示例#1
0
 function output($message = null, $allowHtml = false, $addslashes = false)
 {
     $message = preg_replace('/\\%name\\%/', $this->Session->read('Game.Character.name'), $message);
     $message = preg_replace('/\\%class\\%/', $this->Session->read('Game.Type.name'), $message);
     $message = preg_replace('/\\%hisher\\%/', 'his', $message);
     if ($allowHtml != true) {
         $message = htmlspecialchars($message);
     }
     /* Items */
     preg_match_all('/\\[item\\](.*?)\\[\\/item\\]/', $message, $items);
     if (isset($items[1]) && !empty($items[1])) {
         // Laat de makers het niet zien...
         App::import('Model', 'Item');
         $Item = new Item();
         $Item->contain();
         $items = $Item->find('all', array('fields' => array('Item.id', 'Item.name', 'Item.quality'), 'conditions' => array('Item.name' => $items[1])));
         foreach ($items as $item) {
             $message = str_replace('[item]' . $item['Item']['name'] . '[/item]', '<span class="item_' . $item['Item']['quality'] . '" onmouseover="showMouseInfo(url + \'items/view/' . addslashes($item['Item']['name']) . '\');" onmouseout="hideMouseInfo();">[' . addslashes($item['Item']['name']) . ']</span>', $message);
         }
     }
     // Quests
     preg_match_all('/\\[quest\\](.*?)\\[\\/quest\\]/', $message, $quests);
     if (isset($quests[1]) && !empty($quests[1])) {
         foreach ($quests[1] as $quest) {
             $message = str_replace('[quest]' . $quest . '[/quest]', '<span class="quest" onmouseover="showMouseInfo(url + \'quests/view/' . $quest . '\');" onmouseout="hideMouseInfo();">' . htmlspecialchars($quest) . '</span>', $message);
         }
     }
     if ($addslashes === true) {
         $message = addslashes($message);
     }
     return $message;
 }
示例#2
0
 /**
  * Render comments and respond form html.
  *
  * @param AppView $view The view the comments are rendered on
  * @param Item $item The item whos comments are rendered
  *
  * @return string The html output
  *
  * @since 2.0
  */
 public function renderComments($view, $item)
 {
     if ($item->getApplication()->isCommentsEnabled()) {
         // get application params
         $params = $this->app->parameter->create($item->getApplication()->getParams()->get('global.comments.'));
         if ($params->get('twitter_enable') && !function_exists('curl_init')) {
             $this->app->error->raiseWarning(500, JText::_('To use Twitter, CURL needs to be enabled in your php settings.'));
             $params->set('twitter_enable', false);
         }
         // get active author
         $active_author = $this->activeAuthor();
         // get comment content from session
         $content = $this->app->system->session->get('com_zoo.comment.content');
         $params->set('content', $content);
         // get comments and build tree
         $comments = $item->getCommentTree(Comment::STATE_APPROVED);
         // build captcha
         $captcha = false;
         if ($plugin = $params->get('captcha', false) and (!$params->get('captcha_guest_only', 0) or !$this->app->user->get()->id)) {
             $captcha = JCaptcha::getInstance($plugin);
         }
         if ($item->isCommentsEnabled() || count($comments) - 1) {
             // create comments html
             return $view->partial('comments', compact('item', 'active_author', 'comments', 'params', 'captcha'));
         }
     }
     return null;
 }
示例#3
0
文件: Item.php 项目: doostan/menu
 public function addChild($title)
 {
     $child = new Item($title);
     $child->setParent($this);
     $this->children[] = $child;
     return $child;
 }
示例#4
0
 public function testGetTypeDir()
 {
     $storage = $this->getMock('Newscoop\\Storage', array('isDir'), array(''));
     $storage->expects($this->once())->method('isDir')->with($this->equalTo('item'))->will($this->returnValue(TRUE));
     $item = new Item('item', $storage);
     $this->assertEquals('dir', $item->getType());
 }
示例#5
0
文件: ItemTest.php 项目: BD-ES/Q
 /**
  * Test right the execution of an item callback.
  *
  * @covers ::__construct
  * @covers ::getCreationTime
  * @return void
  */
 public function testGetCreationTime()
 {
     $item = new Item(function ($string) {
         return strtolower($string);
     }, 'HoLa MuNdo');
     $this->assertNotNull($item->getCreationTime());
 }
示例#6
0
 /**
  * @param Item $item
  *
  * @return Type
  */
 public function setItem(Item $item)
 {
     if ($this->item !== $item) {
         $this->item = $item->setType($this);
     }
     return $this;
 }
 public static function load($name, $options = array())
 {
     $db = Settings::getProtected('db');
     $auth = Settings::getProtected('auth');
     $auth->forceAuthentication();
     $username = $auth->getUsername();
     if (array_key_exists('include-removed', $options) && $options['include-removed'] == true) {
         $includeRemoved = true;
     } else {
         $includeRemoved = false;
     }
     $items = array();
     $results = $db->loadQueue($name, $includeRemoved);
     if (strpos($name, 'proof') != false) {
         $type = 'proof';
     } else {
         if (strpos($name, 'review') != false) {
             $type = 'review';
         }
     }
     foreach ($results as $result) {
         $itemID = $result['item_id'];
         $projectID = $result['project_id'];
         $item = new Item($db);
         $item->loadWithProjectID($itemID, $projectID, $username, $type);
         array_push($items, $item);
     }
     return $items;
 }
示例#8
0
 function details()
 {
     global $smarty;
     $item = new dogma($this->typeID);
     if (!$item->isValid()) {
         $this->page->setTitle('Error');
         return 'This ID is not a valid dogma ID.';
     }
     $this->page->setTitle('Item details - ' . $item->get('typeName'));
     $this->page->addHeader('<meta name="robots" content="noindex, nofollow" />');
     $smarty->assignByRef('item', $item);
     if ($item->get('itt_cat') == 6) {
         //we have a ship, so get it from the db
         $ship = Ship::getByID($item->get('typeID'));
         $smarty->assign('shipImage', $ship->getImage(64));
         $smarty->assign('armour', array('armorHP', 'armorEmDamageResonance', 'armorExplosiveDamageResonance', 'armorKineticDamageResonance', 'armorThermalDamageResonance'));
         $smarty->assign('shield', array('shieldCapacity', 'shieldRechargeRate', 'shieldEmDamageResonance', 'shieldExplosiveDamageResonance', 'shieldKineticDamageResonance', 'shieldThermalDamageResonance'));
         $smarty->assign('propulsion', array('maxVelocity', 'agility', 'droneCapacity', 'capacitorCapacity', 'rechargeRate'));
         $smarty->assign('fitting', array('hiSlots', 'medSlots', 'lowSlots', 'rigSlots', 'upgradeCapacity', 'droneBandwidth', 'launcherSlotsLeft', 'turretSlotsLeft', 'powerOutput', 'cpuOutput'));
         $smarty->assign('targetting', array('maxTargetRange', 'scanResolution', 'maxLockedTargets', 'scanRadarStrength', 'scanLadarStrength', 'scanMagnetometricStrength', 'scanGravimetricStrength', 'signatureRadius'));
         $smarty->assign('miscellaneous', array('techLevel', 'propulsionFusionStrength', 'propulsionIonStrength', 'propulsionMagpulseStrength', 'propulsionPlasmaStrength'));
         $html = $smarty->fetch(get_tpl('invtype_ship'));
     } else {
         $i = new Item($this->typeID);
         $smarty->assign('itemImage', $i->getIcon(64, false));
         $smarty->assign('akey', session::isAdmin() ? session::makeKey() : false);
         $html = $smarty->fetch(get_tpl('invtype_item'));
     }
     return $html;
 }
示例#9
0
 public static function fromJson($json)
 {
     $r = new Item();
     $r->setId($json->id);
     $r->setSku($json->sku);
     return $r;
 }
示例#10
0
 /**
  * Constructor
  * @param Element|String $element
  * @param Item           $item
  * @param array          $options
  */
 function __construct($element, Item $item = null, $options = array())
 {
     // get Zoo app
     $this->app = App::getInstance('zoo');
     // set inner vars
     if (isset($options['elementId'])) {
         $this->_identifier = $options['elementId'];
         $this->_item = $item;
         $this->_element = $this->_item->getElement($this->_identifier);
     } else {
         if (is_object($element)) {
             $this->_element = $element;
             $this->_item = $element->getItem();
             $this->_identifier = $element->identifier;
         } else {
             $this->_identifier = $element;
         }
     }
     // set repeatable flag
     if (is_object($this->_element) && is_subclass_of($this->_element, 'ElementRepeatable')) {
         $this->_isRepeatable = true;
     }
     // set Item object
     if (!$this->_item && $item) {
         $this->_item = $item;
     }
     // get current value for export)
     if ($this->_item && $this->_identifier && isset($this->_item->elements[$this->_identifier])) {
         $this->_value = $this->_item->elements[$this->_identifier];
     }
     $this->_config = JBModelConfig::model();
     $this->_exportParams = $this->_config->getGroup('export.items', array());
     $this->_importParams = $this->_config->getGroup('import.items', array());
     $this->_lastImportParams = $this->_config->getGroup('import.last.items', array());
 }
示例#11
0
 /**
  * Adds an item
  * @param Item $rssItem The rss item
  * @param bool $useCDATA Wrap description with CDATA
  */
 private function AddItem(Item $rssItem, $useCDATA = true)
 {
     $itemEl = $this->domDoc->createElement("item");
     if ($rssItem->Title != null) {
         $this->AppendTextChild($itemEl, "title", $rssItem->Title);
     }
     if ($rssItem->Link != null) {
         $this->AppendTextChild($itemEl, "link", $rssItem->Link);
     }
     if ($rssItem->Description != null) {
         if ($useCDATA) {
             $this->AppendCDATAChild($itemEl, "description", $rssItem->Description);
         } else {
             $this->AppendTextChild($itemEl, "description", $rssItem->Description);
         }
     }
     if ($rssItem->GetPubDate() != null) {
         $this->AppendTextChild($itemEl, "pubDate", $rssItem->GetPubDate()->ToString(\DATE_RSS));
     }
     if ($rssItem->Author != null) {
         $this->AppendTextChild($itemEl, "author", $rssItem->Author);
     }
     if ($rssItem->Comments != null) {
         $this->AppendTextChild($itemEl, "comments", $rssItem->Comments);
     }
     if ($rssItem->Guid != null) {
         $this->AppendTextChild($itemEl, "guid", $rssItem->Guid);
     }
     //objects
     $this->AddCategory($itemEl, $rssItem->GetCategory());
     $this->AddSource($itemEl, $rssItem->GetSource());
     $this->AddEnclosure($itemEl, $rssItem->GetEnclosure());
     $this->channel->appendChild($itemEl);
 }
示例#12
0
 public function test_getItemsByOrderId()
 {
     /** === Test Data === */
     $ORDER_ID = 32;
     $ITEM_ID = 64;
     $TBL_ORDER = 'sale order item';
     $TBL_PV_ITEM = 'pv item';
     /** === Setup Mocks === */
     // $tblOrder = [$asOrder => $this->_resource->getTableName(Cfg::ENTITY_MAGE_SALES_ORDER_ITEM)];
     $this->mResource->shouldReceive('getTableName')->once()->andReturn($TBL_ORDER);
     // $tblPvItem = [$asPvItem => $this->_resource->getTableName(Entity::ENTITY_NAME)];
     $this->mResource->shouldReceive('getTableName')->once()->andReturn($TBL_PV_ITEM);
     // $query = $conn->select();
     $mQuery = $this->_mockDbSelect();
     $this->mConn->shouldReceive('select')->once()->andReturn($mQuery);
     // $query->from($tblOrder, $cols);
     $mQuery->shouldReceive('from')->once();
     // $query->joinLeft($tblPvItem, $on, $cols);
     $mQuery->shouldReceive('joinLeft')->once();
     // $query->where($where);
     $mQuery->shouldReceive('where')->once();
     // $rows = $conn->fetchAll($query);
     $mRow = [];
     $mRows = [$mRow];
     $this->mConn->shouldReceive('fetchAll')->once()->andReturn($mRows);
     // $item = $this->_manObj->create(Entity::class, $row);
     $mItem = $this->_mock(\Praxigento\Pv\Data\Entity\Sale\Item::class);
     $this->mManObj->shouldReceive('create')->once()->with(\Praxigento\Pv\Data\Entity\Sale\Item::class, $mRow)->andReturn($mItem);
     // $result[$item->getSaleItemId()] = $item;
     $mItem->shouldReceive('getSaleItemId')->once()->andReturn($ITEM_ID);
     /** === Call and asserts  === */
     $res = $this->obj->getItemsByOrderId($ORDER_ID);
     $this->assertTrue(is_array($res));
     $this->assertTrue(isset($res[$ITEM_ID]));
 }
 public static function save_new_item_to_wardrobe()
 {
     self::check_logged_in();
     $params = $_POST;
     // Alustetaan uusi Item-luokan olion käyttäjän syöttämillä arvoilla
     // Tallennetaan erikseen attribuutit muuttujaan..
     $attributes = array('type' => $params['type'], 'brand' => $params['brand'], 'color' => $params['color'], 'color_2nd' => $params['color_2nd'], 'material' => $params['material'], 'image' => $params['image']);
     //..ja luodaan olio attributestaulukon avulla
     $item = new Item($attributes);
     // kutsutaan item:in metodia errors, joka tarkistaa olivatko
     // attribuutit valideja
     $errors = $item->errors();
     if (count($errors) == 0) {
         // Validi item, tallennetaan
         // Kutsutaan alustamamme olion save metodia, joka tallentaa olion tietokantaan
         $item->save();
         //tallennetaan mys käyttäjän vaatekaappiin
         Wardrobe::add_item_for_person($item->item_id, $_SESSION['user']);
         // Ohjataan käyttäjä lisäyksen jälkeen vaatteen esittelysivulle
         Redirect::to('/wardrobe/wardrobe.html', array('message' => 'Item added to your wardrobe!'));
     } else {
         // Invalidi syöte
         // Luodaan uusi näkymä johon välitetään syötetyt arvot
         View::make('wardrobe/new_item.html', array('errors' => $errors, 'attributes' => $attributes));
     }
 }
示例#14
0
 /**
  * Push menu item
  * @param $identifier
  * @param Item $item
  */
 public function push($identifier, Item $item)
 {
     if (!$item->getTemplate()) {
         $item->setTemplate($this->menus[$identifier]->getTemplate() . '-item');
     }
     $this->menus[$identifier]->push($item);
 }
示例#15
0
 public function withItem(Item $item)
 {
     $instance = clone $this;
     $items = $instance->getProperty('Item', []);
     $items[] = $item->withPckId($this->getProperty('PckId'));
     return $instance->withProperty('Item', $items);
 }
示例#16
0
 /**
  * @brief Fetch a feed from remote
  * @param url remote url of the feed
  * @returns an instance of OC_News_Feed
  */
 public static function fetch($url)
 {
     $spfeed = new \SimplePie_Core();
     $spfeed->set_feed_url($url);
     $spfeed->enable_cache(false);
     if (!$spfeed->init()) {
         return null;
     }
     //temporary try-catch to bypass SimplePie bugs
     try {
         $spfeed->handle_content_type();
         $title = $spfeed->get_title();
         $items = array();
         if ($spitems = $spfeed->get_items()) {
             foreach ($spitems as $spitem) {
                 $itemUrl = $spitem->get_permalink();
                 $itemTitle = $spitem->get_title();
                 $itemGUID = $spitem->get_id();
                 $itemBody = $spitem->get_content();
                 $item = new Item($itemUrl, $itemTitle, $itemGUID, $itemBody);
                 $spAuthor = $spitem->get_author();
                 if ($spAuthor !== null) {
                     $item->setAuthor($spAuthor->get_name());
                 }
                 //date in Item is stored in UNIX timestamp format
                 $itemDate = $spitem->get_date('U');
                 $item->setDate($itemDate);
                 // associated media file, for podcasts
                 $itemEnclosure = $spitem->get_enclosure();
                 if ($itemEnclosure !== null) {
                     $enclosureType = $itemEnclosure->get_type();
                     $enclosureLink = $itemEnclosure->get_link();
                     if (stripos($enclosureType, "audio/") !== FALSE) {
                         $enclosure = new Item_Enclosure();
                         $enclosure->setMimeType($enclosureType);
                         $enclosure->setLink($enclosureLink);
                         $item->setEnclosure($enclosure);
                     }
                 }
                 $items[] = $item;
             }
         }
         $feed = new Feed($url, $title, $items);
         $favicon = $spfeed->get_image_url();
         if ($favicon !== null && self::checkFavicon($favicon)) {
             // use favicon from feed
             $feed->setFavicon($favicon);
         } else {
             // try really hard to find a favicon
             $webFavicon = self::discoverFavicon($url);
             if ($webFavicon !== null) {
                 $feed->setFavicon($webFavicon);
             }
         }
         return $feed;
     } catch (Exception $e) {
         return null;
     }
 }
示例#17
0
 /**
  * Check whether Item can be added
  * 
  * @param Item $item
  * 
  * @return boolean
  */
 public function canAddItem(Item $item)
 {
     if ($this->getTotalPrice() + $item->getPrice() > $this->maxPricePerPackage) {
         return false;
     } else {
         return true;
     }
 }
示例#18
0
 public function getDrops(Item $item, Player $player)
 {
     if ($item->isPickaxe() >= 4) {
         return array(array(DIAMOND_BLOCK, 0, 1));
     } else {
         return array();
     }
 }
示例#19
0
 public function getDrops(Item $item, Player $player)
 {
     if ($item->isPickaxe() >= 1) {
         return array(array(COBBLESTONE, 0, 1));
     } else {
         return array();
     }
 }
示例#20
0
 /**
  * @param string $class
  * @param Item $parent
  */
 public function __construct($class, Item $parent = null)
 {
     $this->class = $class;
     $this->parent = $parent;
     if ($parent) {
         $parent->addChild($this);
     }
 }
示例#21
0
 public function getDrops(Item $item, Player $player)
 {
     if ($item->isPickaxe() >= 1) {
         return array(array(STONE_BRICKS, $this->meta & 0x3, 1));
     } else {
         return array();
     }
 }
示例#22
0
 public function getDrops(Item $item, Player $player)
 {
     if ($item->isPickaxe() >= 4) {
         return array(array(GOLD_ORE, 0, 1));
     } else {
         return array();
     }
 }
示例#23
0
 public function getDrops(Item $item, Player $player)
 {
     if ($item->isPickaxe() >= 1) {
         return array(array(NETHER_BRICKS, 0, 1));
     } else {
         return array();
     }
 }
示例#24
0
 public static function findItems($id)
 {
     $items = new Item();
     $subquery = $items->_db->select();
     $subquery->from('line_items', 'item_id');
     $subquery->where('user_id = ?', $id);
     return $items->fetchAll('id IN (' . $subquery . ')');
 }
示例#25
0
function get_items()
{
    global $smarty, $fpdo;
    $oItem = new Item($fpdo);
    $items_results = $oItem->getAll();
    $smarty->assign('items', $items_results);
    $smarty->display('showitems.tpl');
}
示例#26
0
 public function getDrops(Item $item, Player $player)
 {
     if ($item->isPickaxe() >= 5) {
         return array(array(OBSIDIAN, 0, 1));
     } else {
         return array();
     }
 }
 public function getDrops(Item $item, Player $player)
 {
     if ($item->isPickaxe() >= 4) {
         return array(array(REDSTONE_DUST, 0, mt_rand(4, 5)));
     } else {
         return array();
     }
 }
示例#28
0
 public function getDrops(Item $item, Player $player)
 {
     if ($item->isPickaxe() >= 1) {
         return array(array(IRON_DOOR, 0, 1));
     } else {
         return array();
     }
 }
示例#29
0
 public function getDrops(Item $item, Player $player)
 {
     if ($item->isPickaxe() >= 1) {
         return array(array(SLAB, $this->meta & 0x7, 2));
     } else {
         return array();
     }
 }
示例#30
0
 public function getDrops(Item $item, Player $player)
 {
     if ($item->isPickaxe() >= 3) {
         return array(array(DYE, 4, mt_rand(4, 8)));
     } else {
         return array();
     }
 }