Item PHP Class Code Examples

This page contains top rated real world PHP examples of class Item extracted from open source projects. You can rate examples to help us improve the quality of examples

Example #1
Show file File: MondeDiploBridge.php Project: Nomane/rss-bridge
0
 public function collectData(array $param)
 {
     $link = 'http://www.monde-diplomatique.fr';
     $html = file_get_html($link) or $this->returnError('Could not request MondeDiplo. for : ' . $link, 404);
     foreach ($html->find('div.laune') as $element) {
         $item = new Item();
         $item->uri = 'http://www.monde-diplomatique.fr' . $element->find('a', 0)->href;
         $item->title = $element->find('h3', 0)->plaintext;
         $item->content = $element->find('div.dates_auteurs', 0)->plaintext . '<br>' . strstr($element->find('div', 0)->plaintext, $element->find('div.dates_auteurs', 0)->plaintext, true);
         $this->items[] = $item;
     }
     $liste = $html->find('div.listes', 0);
     // First list
     foreach ($liste->find('li') as $e) {
         $item = new Item();
         $item->uri = 'http://www.monde-diplomatique.fr' . $e->find('a', 0)->href;
         $item->title = $e->find('a', 0)->plaintext;
         $item->content = $e->find('div.dates_auteurs', 0)->plaintext;
         $this->items[] = $item;
     }
     foreach ($html->find('div.liste ul li') as $element) {
         if ($element->getAttribute('class') != 'intrapub') {
             $item = new Item();
             $item->uri = 'http://www.monde-diplomatique.fr' . $element->find('a', 0)->href;
             $item->title = $element->find('h3', 0)->plaintext;
             $item->content = $element->find('div.dates_auteurs', 0)->plaintext . ' <br> ' . $element->find('div.intro', 0)->plaintext;
             $this->items[] = $item;
         }
     }
 }
Example #2
Show file File: CourrierInternationalBridge.php Project: Nomane/rss-bridge
0
 public function collectData(array $param)
 {
     function fetchArticle($link)
     {
         $page = file_get_html($link);
         $contenu = $page->find(".article-text")[0];
         return strip_tags($contenu);
     }
     $html = '';
     $html = file_get_html('http://www.courrierinternational.com/article') or $this->returnError('Error.', 500);
     $element = $html->find(".type-normal");
     $article_count = 1;
     foreach ($element as $article) {
         $item = new \Item();
         $item->uri = "http://www.courrierinternational.com" . $article->find("a")[0]->getAttribute("href");
         $item->content = fetchArticle("http://www.courrierinternational.com" . $article->find("a")[0]->getAttribute("href"));
         $item->title = strip_tags($article->find("h2")[0]);
         $dateTime = date_parse($article->find("time")[0]);
         $item->timestamp = mktime($dateTime['hour'], $dateTime['minute'], $dateTime['second'], $dateTime['month'], $dateTime['day'], $dateTime['year']);
         $this->items[] = $item;
         $article_count++;
         if ($article_count > 5) {
             break;
         }
     }
 }
Example #3
Show file File: PlayerInventory.php Project: mattiasaxelsson/PocketMine-MP
0
 public function setItem($index, Item $item)
 {
     if ($index < 0 or $index >= $this->size) {
         return false;
     } elseif ($item->getId() === 0 or $item->getCount() <= 0) {
         return $this->clear($index);
     }
     if ($index >= $this->getSize()) {
         //Armor change
         Server::getInstance()->getPluginManager()->callEvent($ev = new EntityArmorChangeEvent($this->getHolder(), $this->getItem($index), $item, $index));
         if ($ev->isCancelled() and $this->getHolder() instanceof Human) {
             $this->sendArmorSlot($index, $this->getViewers());
             return false;
         }
         $item = $ev->getNewItem();
     } else {
         Server::getInstance()->getPluginManager()->callEvent($ev = new EntityInventoryChangeEvent($this->getHolder(), $this->getItem($index), $item, $index));
         if ($ev->isCancelled()) {
             $this->sendSlot($index, $this->getViewers());
             return false;
         }
         $item = $ev->getNewItem();
     }
     $old = $this->getItem($index);
     $this->slots[$index] = clone $item;
     $this->onSlotChange($index, $old);
     return true;
 }
Example #4
Show file File: Block.php Project: 1455931078/Genisys
0
 /**
  * Returns the seconds that this block takes to be broken using an specific Item
  *
  * @param Item $item
  *
  * @return float
  */
 public function getBreakTime(Item $item)
 {
     $base = $this->getHardness() * 1.5;
     if ($this->canBeBrokenWith($item)) {
         if ($this->getToolType() === Tool::TYPE_SHEARS and $item->isShears()) {
             $base /= 15;
         } elseif ($this->getToolType() === Tool::TYPE_PICKAXE and ($tier = $item->isPickaxe()) !== false or $this->getToolType() === Tool::TYPE_AXE and ($tier = $item->isAxe()) !== false or $this->getToolType() === Tool::TYPE_SHOVEL and ($tier = $item->isShovel()) !== false) {
             switch ($tier) {
                 case Tool::TIER_WOODEN:
                     $base /= 2;
                     break;
                 case Tool::TIER_STONE:
                     $base /= 4;
                     break;
                 case Tool::TIER_IRON:
                     $base /= 6;
                     break;
                 case Tool::TIER_DIAMOND:
                     $base /= 8;
                     break;
                 case Tool::TIER_GOLD:
                     $base /= 12;
                     break;
             }
         }
     } else {
         $base *= 3.33;
     }
     if ($item->isSword()) {
         $base *= 0.5;
     }
     return $base;
 }
Example #5
Show file File: CommonDreamsBridge.php Project: Nomane/rss-bridge
0
 public function collectData(array $param)
 {
     function CommonDreamsUrl($string)
     {
         $html2 = explode(" ", $string);
         $string = $html2[2] . "/node/" . $html2[0];
         return $string;
     }
     function CommonDreamsExtractContent($url)
     {
         $html3 = file_get_html($url);
         $text = $html3->find('div[class=field--type-text-with-summary]', 0)->innertext;
         $html3->clear();
         unset($html3);
         return $text;
     }
     $html = file_get_html('http://www.commondreams.org/rss.xml') or $this->returnError('Could not request CommonDreams.', 404);
     $limit = 0;
     foreach ($html->find('item') as $element) {
         if ($limit < 4) {
             $item = new \Item();
             $item->title = $element->find('title', 0)->innertext;
             $item->uri = CommonDreamsUrl($element->find('guid', 0)->innertext);
             $item->timestamp = strtotime($element->find('pubDate', 0)->plaintext);
             $item->content = CommonDreamsExtractContent($item->uri);
             $this->items[] = $item;
             $limit++;
         }
     }
 }
Example #6
Show file File: ManagerController.php Project: FinBoWa/silverstripe-cacheinclude-manager
0
 /**
  * @param \SS_HTTPRequest $request
  * @return \SS_HTTPResponse
  */
 protected function cacheGET(SS_HTTPRequest $request)
 {
     $statusCode = 200;
     $name = $request->param('ID');
     $key = $request->param('OtherID');
     $cacheTransformer = new Transformers\CacheTransformer();
     $this->response->addHeader('Content-Type', 'application/json');
     if ($name) {
         try {
             if ($key) {
                 $resource = new Item($this->cacheModel->getByKey($name, $key), $cacheTransformer);
             } else {
                 $resource = new Collection($this->cacheModel->get($name), $cacheTransformer);
             }
         } catch (\InvalidArgumentException $e) {
             $statusCode = 400;
             $resource = $this->getSuccessResource(false);
         }
     } else {
         $resource = new Collection($this->cacheModel->getAll(), $cacheTransformer);
     }
     $this->response->setStatusCode($statusCode);
     $this->response->setBody($this->resourceToJson($resource));
     return $this->response;
 }
Example #7
Show file File: NumeramaBridge.php Project: Nomane/rss-bridge
0
 public function collectData(array $param)
 {
     function NumeramaStripCDATA($string)
     {
         $string = str_replace('<![CDATA[', '', $string);
         $string = str_replace(']]>', '', $string);
         return $string;
     }
     function NumeramaExtractContent($url)
     {
         $html2 = file_get_html($url);
         $text = $html2->find('section[class=related-article]', 0)->innertext = '';
         // remove related articles block
         $text = '<img alt="" style="max-width:300px;" src="' . $html2->find('meta[property=og:image]', 0)->getAttribute('content') . '">';
         // add post picture
         $text = $text . $html2->find('article[class=post-content]', 0)->innertext;
         // extract the post
         return $text;
     }
     $html = file_get_html('http://www.numerama.com/feed/') or $this->returnError('Could not request Numerama.', 404);
     $limit = 0;
     foreach ($html->find('item') as $element) {
         if ($limit < 5) {
             $item = new \Item();
             $item->title = html_entity_decode(NumeramaStripCDATA($element->find('title', 0)->innertext));
             $item->author = NumeramaStripCDATA($element->find('dc:creator', 0)->innertext);
             $item->uri = NumeramaStripCDATA($element->find('guid', 0)->plaintext);
             $item->timestamp = strtotime($element->find('pubDate', 0)->plaintext);
             $item->content = NumeramaExtractContent($item->uri);
             $this->items[] = $item;
             $limit++;
         }
     }
 }
Example #8
Show file File: SakugabooruBridge.php Project: snroki/rss-bridge
0
 public function collectData(array $param)
 {
     $page = 1;
     $tags = '';
     if (isset($param['p'])) {
         $page = (int) preg_replace("/[^0-9]/", '', $param['p']);
     }
     if (isset($param['t'])) {
         $tags = urlencode($param['t']);
     }
     $html = file_get_html("http://sakuga.yshi.org/post?page={$page}&tags={$tags}") or $this->returnError('Could not request Sakugabooru.', 404);
     $input_json = explode('Post.register(', $html);
     foreach ($input_json as $element) {
         $data[] = preg_replace('/}\\)(.*)/', '}', $element);
     }
     unset($data[0]);
     foreach ($data as $datai) {
         $json = json_decode($datai, TRUE);
         $item = new \Item();
         $item->uri = 'http://sakuga.yshi.org/post/show/' . $json['id'];
         $item->postid = $json['id'];
         $item->timestamp = $json['created_at'];
         $item->imageUri = $json['file_url'];
         $item->thumbnailUri = $json['preview_url'];
         $item->title = 'Sakugabooru | ' . $json['id'];
         $item->content = '<a href="' . $item->imageUri . '"><img src="' . $item->thumbnailUri . '" /></a><br>Tags: ' . $json['tags'];
         $this->items[] = $item;
     }
 }
Example #9
Show file File: DauphineLibereBridge.php Project: Nomane/rss-bridge
0
 public function collectData(array $param)
 {
     function ExtractContent($url)
     {
         $html2 = file_get_html($url);
         $text = $html2->find('div.column', 0)->innertext;
         $text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
         return $text;
     }
     if (isset($param['u'])) {
         /* user timeline mode */
         $this->request = $param['u'];
         $html = file_get_html('http://www.ledauphine.com/' . $this->request . '/rss') or $this->returnError('Could not request DauphineLibere.', 404);
     } else {
         $html = file_get_html('http://www.ledauphine.com/rss') or $this->returnError('Could not request DauphineLibere.', 404);
     }
     $limit = 0;
     foreach ($html->find('item') as $element) {
         if ($limit < 10) {
             $item = new \Item();
             $item->title = $element->find('title', 0)->innertext;
             $item->uri = $element->find('guid', 0)->plaintext;
             $item->timestamp = strtotime($element->find('pubDate', 0)->plaintext);
             $item->content = ExtractContent($item->uri);
             $this->items[] = $item;
             $limit++;
         }
     }
 }
Example #10
Show file File: AuthItemForm.php Project: tqsq2005/dotplant2
0
 public function updateItem()
 {
     $item = new Item();
     $item->name = $this->name;
     $item->type = $this->type;
     $item->description = $this->description;
     $item->ruleName = trim($this->ruleName) ? trim($this->ruleName) : null;
     Yii::$app->getAuthManager()->update($this->oldname, $item);
     $children = Yii::$app->getAuthManager()->getChildren($item->name);
     foreach ($children as $value) {
         $key = array_search($value->name, $this->children);
         if ($key === false) {
             Yii::$app->getAuthManager()->removeChild($item, $value);
         } else {
             unset($this->children[$key]);
         }
     }
     foreach ($this->children as $value) {
         try {
             Yii::$app->getAuthManager()->addChild($item, new Item(['name' => $value]));
         } catch (\Exception $ex) {
             $this->errorMessage .= Yii::t('app', "Item <strong>{value}</strong> is not assigned:", ['value' => $value]) . " " . $ex->getMessage() . "<br />";
         }
     }
     return $item;
 }
Example #11
Show file File: PackageTest.php Project: Lc5/FirstFit
0
 public function testAddItem()
 {
     $itemOne = new Item(1, 2, 3, 50);
     $itemTwo = new Item(4, 5, 6, 60);
     $this->package->addItem($itemOne)->addItem($itemTwo);
     $this->assertEquals([$itemOne, $itemTwo], $this->package->getItems());
 }
Example #12
Show file File: ItemsController.php Project: noikiy/posco-laravel-server
0
 /**
  * Display a listing of items
  *
  * @return Response
  */
 public function index()
 {
     $items = Item::all();
     $categories = Category::all();
     $item = new Item();
     return View::make('items.index', compact('items', 'categories', 'item'));
 }
Example #13
Show file File: GroupsTreeListView.php Project: youprofit/Zurmo
0
 protected function resolveUserCountForItem(Item $item)
 {
     if ($item->name == Group::EVERYONE_GROUP_NAME) {
         return User::getCount();
     }
     return $item->{$this->getModelRelationNameForUserCount()}->count();
 }
Example #14
Show file File: PackageDistributorTest.php Project: dermo666/shippingCostExercise
0
 public function testEvenlyDistibutedAlgoCalculateDoesFindBestPackageForItem()
 {
     $packages = [];
     for ($i = 0; $i < 2; $i++) {
         $packages[] = new Package(250);
     }
     $item1 = new Item(['Item 1', 245, 200]);
     $item2 = new Item(['Item 2', 245, 200]);
     $item3 = new Item(['Item 3', 10, 200]);
     $dist = new PackageDistributor(PackageDistributor::ALGO_EVENLY_DISTRIBUTED);
     $packages[0]->addItem($item1);
     $packages[1]->addItem($item2);
     $result = $dist->findBestPackageForItem($item3, $packages);
     $this->assertEquals(-1, $result);
 }
Example #15
Show file File: OrderPersonController.php Project: piiskop/pstk
0
 /**
  * This function builds common examples how to insert, update, delete and
  * display the data of order persons.
  *
  * @access public
  * @author kalmer:piiskop
  * @uses \shiporder\OrderPerson
  */
 public static function buildRawExamples()
 {
     // Order persons
     require_once 'OrderPerson.php';
     echo ' 8: Initial data: <pre>';
     var_dump(\shiporder\OrderPerson::getListOfTypeOrderPerson(array('forAutocompletion' => false)));
     echo '</pre>';
     // Inserting an order person
     $newOrderPerson = new \shiporder\OrderPerson();
     $newOrderPerson->setEmail('lilian.tikk03@gmail.com');
     $newOrderPerson->setFirstName('lilian');
     $newOrderPerson->setLastName('tikk');
     $newOrderPerson->insert();
     echo ' 10: After insertion: <pre>';
     var_dump(\shiporder\OrderPerson::getListOfTypeOrderPerson(array('forAutocompletion' => false)));
     echo '</pre>';
     // Querying full data of an order person
     $orderPerson = new \shiporder\OrderPerson();
     $orderPerson->setIdOrdePerson(3);
     $orderPerson->setCompleteOrderPerson();
     echo ' 20: Order person #3: <pre>';
     var_dump($orderPerson);
     echo '</pre>';
     // Updating data of an order person
     $orderPerson->setAddress('Pärnu, Pärnu');
     $orderPerson->update();
     echo ' 24: After updating the order person #3: <pre>';
     var_dump(\shiporder\OrderPerson::getListOfTypeOrderPerson(array('forAutocompletion' => false)));
     echo '</pre>';
     // Deleting the order person #2
     $orderPerson = new \shiporder\OrderPerson();
     $orderPerson->setIdOrdePerson(2);
     $orderPerson->delete();
     echo ' 43: After deleting the order person #2: <pre>';
     var_dump(\shiporder\OrderPerson::getListOfTypeOrderPerson(array('forAutocompletion' => false)));
     echo '</pre>';
     // Items
     require_once dirname(__FILE__) . '/Item.php';
     $item = new \shiporder\Item();
     $item->setIdItem(1);
     $item->setName('õun');
     $item->setPrice(1.0);
     $item->setAmount(20.0);
     $item->insertItem($item);
     $item = new \shiporder\Item();
     $item->setIdItem(2);
     $item->setName('pirn');
     $item->setPrice(2.0);
     $item->setAmount(10.0);
     $item->insertItem($item);
     $items = $item->getItems();
     var_dump($items);
 }
Example #16
Show file File: InstallController.php Project: Brother-Simon/easyii-shop
0
 public function insertArticles()
 {
     if (article\models\Category::find()->count()) {
         return '`<b>' . article\models\Category::tableName() . '</b>` table is not empty, skipping...';
     }
     $this->db->createCommand('TRUNCATE TABLE `' . article\models\Category::tableName() . '`')->query();
     $root1 = new article\models\Category(['title' => 'Articles category 1', 'order_num' => 2]);
     $root1->makeRoot();
     $this->attachSeo($root1, 'Articles category 1 H1', 'Extended category 1 title');
     $root2 = new article\models\Category(['title' => 'Articles category 2', 'order_num' => 1]);
     $root2->makeRoot();
     $subcat1 = new article\models\Category(['title' => 'Subcategory 1', 'order_num' => 1]);
     $subcat1->appendTo($root2);
     $this->attachSeo($subcat1, 'Subcategory 1 H1', 'Extended subcategory 1 title');
     $subcat2 = new article\models\Category(['title' => 'Subcategory 1', 'order_num' => 1]);
     $subcat2->appendTo($root2);
     $this->attachSeo($subcat2, 'Subcategory 2 H1', 'Extended subcategory 2 title');
     if (article\models\Item::find()->count()) {
         return '`<b>' . article\models\Item::tableName() . '</b>` table is not empty, skipping...';
     }
     $this->db->createCommand('TRUNCATE TABLE `' . article\models\Item::tableName() . '`')->query();
     $time = time();
     $article1 = new article\models\Item(['category_id' => $root1->primaryKey, 'title' => 'First article title', 'image' => '/uploads/article/article-1.jpg', 'short' => 'At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt molliti', 'text' => '<p><strong>Sed ut perspiciatis</strong>, unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt, explicabo. nemo enim ipsam voluptatem, quia voluptas sit, aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos, qui ratione voluptatem sequi nesciunt, neque porro quisquam est, qui dolorem ipsum, quia dolor sit, amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt, ut labore et dolore magnam aliquam quaerat voluptatem.&nbsp;</p><ul><li>item 1</li><li>item 2</li><li>item 3</li></ul><p>ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? quis autem vel eum iure reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla pariatur?</p>', 'tagNames' => 'php, css, bootstrap', 'time' => $time]);
     $article1->save();
     $this->attachPhotos($article1, ['/uploads/photos/article-1-1.jpg', '/uploads/photos/article-1-2.jpg', '/uploads/photos/article-1-3.jpg', '/uploads/photos/news-1-4.jpg']);
     $this->attachSeo($article1, 'First article H1');
     $article2 = new article\models\Item(['category_id' => $root1->primaryKey, 'title' => 'Second article title', 'image' => '/uploads/article/article-2.jpg', 'short' => 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip', 'text' => '<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p><ol> <li>Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. </li><li>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</li></ol>', 'tagNames' => 'yii2, jquery, ajax', 'time' => $time - 86400]);
     $article2->save();
     $this->attachSeo($article2, 'Second article H1');
     $article3 = new article\models\Item(['category_id' => $root1->primaryKey, 'title' => 'Third article title', 'image' => '/uploads/article/article-3.jpg', 'short' => 'At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt molliti', 'text' => '<p>At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.</p>', 'time' => $time - 86400 * 2]);
     $article3->save();
     $this->attachSeo($article3, 'Third article H1');
     return 'Articles data inserted.';
 }
Example #17
Show file File: InstallController.php Project: Brother-Simon/easyii-shop
0
 public function insertCatalog()
 {
     if (catalog\models\Category::find()->count()) {
         return '`<b>' . catalog\models\Category::tableName() . '</b>` table is not empty, skipping...';
     }
     $this->db->createCommand('TRUNCATE TABLE `' . catalog\models\Category::tableName() . '`')->query();
     $fields = [['name' => 'brand', 'title' => 'Brand', 'type' => 'select', 'options' => ['Samsung', 'Apple', 'Nokia']], ['name' => 'storage', 'title' => 'Storage', 'type' => 'string', 'options' => ''], ['name' => 'touchscreen', 'title' => 'Touchscreen', 'type' => 'boolean', 'options' => ''], ['name' => 'cpu', 'title' => 'CPU cores', 'type' => 'select', 'options' => ['1', '2', '4', '8']], ['name' => 'features', 'title' => 'Features', 'type' => 'checkbox', 'options' => ['Wi-fi', '4G', 'GPS']], ['name' => 'color', 'title' => 'Color', 'type' => 'checkbox', 'options' => ['White', 'Black', 'Red', 'Blue']]];
     $root = new catalog\models\Category(['title' => 'Gadgets', 'fields' => $fields]);
     $root->makeRoot();
     $cat1 = new catalog\models\Category(['title' => 'Smartphones', 'fields' => $fields]);
     $cat1->appendTo($root);
     $this->attachSeo($cat1, 'Smartphones H1', 'Extended smartphones title');
     $cat2 = new catalog\models\Category(['title' => 'Tablets', 'fields' => $fields]);
     $cat2->appendTo($root);
     $this->attachSeo($cat2, 'Tablets H1', 'Extended tablets title');
     if (catalog\models\Item::find()->count()) {
         return '`<b>' . catalog\models\Item::tableName() . '</b>` table is not empty, skipping...';
     }
     $time = time();
     $item1 = new catalog\models\Item(['category_id' => $cat1->primaryKey, 'title' => 'Nokia 3310', 'description' => '<h3>The legend</h3><p>The Nokia 3310 is a GSMmobile phone announced on September 1, 2000, and released in the fourth quarter of the year, replacing the popular Nokia 3210. The phone sold extremely well, being one of the most successful phones with 126 million units sold worldwide.&nbsp;The phone has since received a cult status and is still widely acclaimed today.</p><p>The 3310 was developed at the Copenhagen Nokia site in Denmark. It is a compact and sturdy phone featuring an 84 × 48 pixel pure monochrome display. It has a lighter 115 g battery variant which has fewer features; for example the 133 g battery version has the start-up image of two hands touching while the 115 g version does not. It is a slightly rounded rectangular unit that is typically held in the palm of a hand, with the buttons operated with the thumb. The blue button is the main button for selecting options, with "C" button as a "back" or "undo" button. Up and down buttons are used for navigation purposes. The on/off/profile button is a stiff black button located on the top of the phone.</p>', 'available' => 5, 'discount' => 0, 'price' => 100, 'data' => ['brand' => 'Nokia', 'storage' => '1', 'touchscreen' => '0', 'cpu' => 1, 'color' => ['White', 'Red', 'Blue']], 'image' => '/uploads/catalog/3310.jpg', 'time' => $time]);
     $item1->save();
     $this->attachPhotos($item1, ['/uploads/photos/3310-1.jpg', '/uploads/photos/3310-2.jpg']);
     $this->attachSeo($item1, 'Nokia 3310');
     $item2 = new catalog\models\Item(['category_id' => $cat1->primaryKey, 'title' => 'Galaxy S6', 'description' => '<h3>Next is beautifully crafted</h3><p>With their slim, seamless, full metal and glass construction, the sleek, ultra thin edged Galaxy S6 and unique, dual curved Galaxy S6 edge are crafted from the finest materials.</p><p>And while they may be the thinnest smartphones we`ve ever created, when it comes to cutting-edge technology and flagship Galaxy experience, these 5.1" QHD Super AMOLED smartphones are certainly no lightweights.</p>', 'available' => 1, 'discount' => 10, 'price' => 1000, 'data' => ['brand' => 'Samsung', 'storage' => '32', 'touchscreen' => '1', 'cpu' => 8, 'features' => ['Wi-fi', 'GPS']], 'image' => '/uploads/catalog/galaxy.jpg', 'time' => $time - 86400]);
     $item2->save();
     $this->attachPhotos($item2, ['/uploads/photos/galaxy-1.jpg', '/uploads/photos/galaxy-2.jpg', '/uploads/photos/galaxy-3.jpg', '/uploads/photos/galaxy-4.jpg']);
     $this->attachSeo($item2, 'Samsung Galaxy S6');
     $item3 = new catalog\models\Item(['category_id' => $cat1->primaryKey, 'title' => 'Iphone 6', 'description' => '<h3>Next is beautifully crafted</h3><p>With their slim, seamless, full metal and glass construction, the sleek, ultra thin edged Galaxy S6 and unique, dual curved Galaxy S6 edge are crafted from the finest materials.</p><p>And while they may be the thinnest smartphones we`ve ever created, when it comes to cutting-edge technology and flagship Galaxy experience, these 5.1" QHD Super AMOLED smartphones are certainly no lightweights.</p>', 'available' => 0, 'discount' => 10, 'price' => 1100, 'data' => ['brand' => 'Apple', 'storage' => '64', 'touchscreen' => '1', 'cpu' => 4, 'features' => ['Wi-fi', '4G', 'GPS']], 'image' => '/uploads/catalog/iphone.jpg', 'time' => $time - 86400 * 2]);
     $item3->save();
     $this->attachPhotos($item3, ['/uploads/photos/iphone-1.jpg', '/uploads/photos/iphone-2.jpg', '/uploads/photos/iphone-3.jpg', '/uploads/photos/iphone-4.jpg']);
     $this->attachSeo($item3, 'Apple Iphone 6');
     return 'Catalog data inserted.';
 }
Example #18
Show file File: SortableTest.php Project: esserj/DoctrineExtensions
0
 /**
  * @test
  */
 public function shouldInsertInbetween()
 {
     $this->markTestIncomplete('Currently it is not supported to change the position of a record and insert a new one in front of it in one step.');
     $item1 = new Item();
     $item1->setName("Item1");
     $this->em->persist($item1);
     $item3 = new Item();
     $item3->setName("Item3");
     $this->em->persist($item3);
     $this->em->flush();
     // update $item3's position
     $item3->setPosition(2);
     // and insert a further item between $item1 and $item3
     $item2 = new Item();
     $item2->setName("Item2");
     $item2->setPosition(1);
     $this->em->persist($item2);
     $this->em->flush();
     $repo = $this->em->getRepository(self::ITEM);
     $items = $repo->findBy(array(), array('position' => 'asc'));
     $this->assertEquals("Item1", $items[0]->getName());
     $this->assertEquals(0, $items[0]->getPosition());
     $this->assertEquals("Item2", $items[1]->getName());
     $this->assertEquals(1, $items[1]->getPosition());
     $this->assertEquals("Item3", $items[2]->getName());
     $this->assertEquals(2, $items[2]->getPosition());
 }
Example #19
Show file File: MalikiBridge.php Project: Nomane/rss-bridge
0
 public function collectData(array $param)
 {
     $html = file_get_html('http://www.maliki.com/') or $this->returnError('Could not request Maliki.', 404);
     $count = 0;
     $latest = 1;
     $latest_title = "";
     $latest = $html->find('div.conteneur_page a', 1)->href;
     $latest_title = $html->find('div.conteneur_page img', 0)->title;
     function MalikiExtractContent($url)
     {
         $html2 = file_get_html($url);
         $text = 'http://www.maliki.com/' . $html2->find('img', 0)->src;
         $text = '<img alt="" src="' . $text . '"/><br>' . $html2->find('div.imageetnews', 0)->plaintext;
         return $text;
     }
     $item = new \Item();
     $item->uri = 'http://www.maliki.com/' . $latest;
     $item->title = $latest_title;
     $item->timestamp = time();
     $item->content = MalikiExtractContent($item->uri);
     $this->items[] = $item;
     foreach ($html->find('div.boite_strip') as $element) {
         if (!empty($element->find('a', 0)->href) and $count < 3) {
             $item = new \Item();
             $item->uri = 'http://www.maliki.com/' . $element->find('a', 0)->href;
             $item->title = $element->find('img', 0)->title;
             $item->timestamp = strtotime(str_replace('/', '-', $element->find('span.stylepetit', 0)->innertext));
             $item->content = MalikiExtractContent($item->uri);
             $this->items[] = $item;
             $count++;
         }
     }
 }
Example #20
Show file File: MspabooruBridge.php Project: snroki/rss-bridge
0
 public function collectData(array $param)
 {
     $page = 0;
     $tags = '';
     if (isset($param['p'])) {
         $page = (int) preg_replace("/[^0-9]/", '', $param['p']);
         $page = $page - 1;
         $page = $page * 50;
     }
     if (isset($param['t'])) {
         $tags = urlencode($param['t']);
     }
     $html = file_get_html("http://mspabooru.com/index.php?page=post&s=list&tags={$tags}&pid={$page}") or $this->returnError('Could not request Mspabooru.', 404);
     foreach ($html->find('div[class=content] span') as $element) {
         $item = new \Item();
         $item->uri = 'http://mspabooru.com/' . $element->find('a', 0)->href;
         $item->postid = (int) preg_replace("/[^0-9]/", '', $element->getAttribute('id'));
         $item->timestamp = time();
         $item->thumbnailUri = $element->find('img', 0)->src;
         $item->tags = $element->find('img', 0)->getAttribute('alt');
         $item->title = 'Mspabooru | ' . $item->postid;
         $item->content = '<a href="' . $item->uri . '"><img src="' . $item->thumbnailUri . '" /></a><br>Tags: ' . $item->tags;
         $this->items[] = $item;
     }
 }