本文整理汇总了PHP中Item类的典型用法代码示例。如果您正苦于以下问题:PHP Item类的具体用法?PHP Item怎么用?PHP Item使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Item类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: output
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: renderComments
/**
* 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: addChild
public function addChild($title)
{
$child = new Item($title);
$child->setParent($this);
$this->children[] = $child;
return $child;
}
示例4: testGetTypeDir
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: testGetCreationTime
/**
* 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: setItem
/**
* @param Item $item
*
* @return Type
*/
public function setItem(Item $item)
{
if ($this->item !== $item) {
$this->item = $item->setType($this);
}
return $this;
}
示例7: load
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: details
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: fromJson
public static function fromJson($json)
{
$r = new Item();
$r->setId($json->id);
$r->setSku($json->sku);
return $r;
}
示例10: __construct
/**
* 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: AddItem
/**
* 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: test_getItemsByOrderId
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]));
}
示例13: save_new_item_to_wardrobe
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: push
/**
* 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: withItem
public function withItem(Item $item)
{
$instance = clone $this;
$items = $instance->getProperty('Item', []);
$items[] = $item->withPckId($this->getProperty('PckId'));
return $instance->withProperty('Item', $items);
}