Example #1
0
 /**
  * @see EquipmentInterface::create()
  * @param integer $type_id
  * @param integer $owner_id
  * @return integer
  * @throws EquipmentCreateFailedException
  * @throws EquipmentCreateAsItemException
  * @throws EquipmentCreateIDMissingException
  */
 public function create($type_id, $owner_id)
 {
     global $transaction;
     if (is_numeric($type_id) and is_numeric($owner_id)) {
         $transaction_id = $transaction->begin();
         try {
             if (($equipment_id = $this->equipment->create($type_id, $owner_id)) == null) {
                 throw new EquipmentCreateFailedException();
             }
             $this->item_id = parent::create();
             $equipment_is_item = new EquipmentIsItem_Access(null);
             if ($equipment_is_item->create($equipment_id, $this->item_id) == false) {
                 throw new EquipmentCreateAsItemException();
             }
         } catch (BaseException $e) {
             if ($transaction_id != null) {
                 $transaction->rollback($transaction_id);
             }
             throw $e;
         }
         if ($transaction_id != null) {
             $transaction->commit($transaction_id);
         }
         self::__construct($equipment_id);
         return $equipment_id;
     } else {
         throw new EquipmentCreateIDMissingException();
     }
 }
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 50) as $index) {
         Item::create(['name' => $faker->text(10), 'description' => $faker->text(200), 'price' => $faker->randomFloat(2, 0, 100), 'item_category_id' => $faker->randomElement([1, 2, 3, 4, 5])]);
     }
 }
 public function run()
 {
     // Barracks Items
     $barracks = Map::where('location_name', 'barracks')->firstOrFail();
     Item::create(['name' => 'sword', 'map_id' => $barracks->id]);
     Item::create(['name' => 'armor', 'map_id' => $barracks->id]);
     Item::create(['name' => 'key', 'map_id' => $barracks->id]);
     // Southwest Tower Item
     $southWestTower = Map::where('location_name', 'southwest_tower_outer')->firstOrFail();
     Item::create(['name' => 'lantern', 'map_id' => $southWestTower->id]);
     // Kitchen Items
     $kitchen = Map::where('location_name', 'kitchen')->firstOrFail();
     Item::create(['name' => 'apple', 'map_id' => $kitchen->id]);
     Item::create(['name' => 'bread', 'map_id' => $kitchen->id]);
     // Reception Room Item
     $receptionRoom = Map::where('location_name', 'reception_room')->firstOrFail();
     Item::create(['name' => 'wine', 'map_id' => $receptionRoom->id]);
     // Wizard Tower Items
     $wizardTower = Map::where('location_name', 'wizard_tower')->firstOrFail();
     Item::create(['name' => 'potion_invisibility', 'map_id' => $wizardTower->id]);
     Item::create(['name' => 'potion_strength', 'map_id' => $wizardTower->id]);
     Item::create(['name' => 'potion_regeneration', 'map_id' => $wizardTower->id]);
     // Dressing Room Item
     $dressingRoom = Map::where('location_name', 'dressing_room')->firstOrFail();
     Item::create(['name' => 'gown', 'map_id' => $dressingRoom->id]);
     // Study Item
     $study = Map::where('location_name', 'study')->firstOrFail();
     Item::create(['name' => 'note', 'map_id' => $study->id]);
     // King Chamber Item
     $kingChamber = Map::where('location_name', 'king_chamber')->firstOrFail();
     Item::create(['name' => 'crown', 'map_id' => $kingChamber->id]);
 }
 public function run()
 {
     DB::table('items')->delete();
     for ($i = 1; $i <= 100; $i++) {
         Item::create(array('title' => 'item test ' . $i));
     }
 }
Example #5
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Item::create([]);
     }
 }
Example #6
0
 public function run()
 {
     $title = array('ピカチュウ', 'カイリュウ', 'ヤドラン', 'ピジョン', 'コダック', 'コラッタ', 'ズバット', 'ギャロップ');
     $now = date('Y-m-d H:i:s');
     $type = 'video';
     foreach ($title as $t) {
         Item::create(array('category_id' => mt_rand(1, 29), 'user_id' => mt_rand(1, 4), 'title' => $t, 'content' => "{$t} の content やで", 'type' => $type, 'created_at' => $now, 'updated_at' => $now));
     }
 }
 /**
  * Store a newly created item in storage.
  *
  * @return Response
  */
 public function store()
 {
     if (Input::has('clearForm')) {
         return Redirect::route('items.index');
     }
     if (Input::get('selectedItem')) {
         $targetID = Input::get('selectedItem');
         $item = Item::find($targetID);
         $shops = Shop::all();
         $categories = Category::all();
         return View::make('items.index', compact('item', 'categories', 'shops'));
     }
     $validator = Validator::make($data = Input::all(), Item::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     /* Item */
     if (Input::has('createItem')) {
         $id = DB::table('BTSMAS')->count();
         $id++;
         $file = $id . '.png';
         if (move_uploaded_file($_FILES['upload']['tmp_name'], $file)) {
             echo $file;
         } else {
             echo "error";
         }
         $data['contents'] = file_get_contents($file);
         unlink($file);
         Item::create($data);
         $message = "登録しました。";
     }
     if (Input::has('deleteItem')) {
         $id = Input::get('idItem');
         Item::destroy($id);
         $message = "削除しました。";
     }
     if (Input::has('updateItem')) {
         $id = Input::get('idItem');
         $item = Item::find($id);
         $item->title = Input::get('title');
         $item->price = Input::get('price');
         $item->genka = Input::get('genka');
         $item->Bumon = Input::get('Bumon');
         $item->Kosu = Input::get('Kosu');
         if (file_exists($_FILES['upload']['tmp_name'])) {
             $file = $id . '.png';
             move_uploaded_file($_FILES['upload']['tmp_name'], $file);
             $item->contents = file_get_contents($file);
             unlink($file);
         }
         $item->save();
         $message = "更新しました。";
     }
     return Redirect::route('items.index')->with('message', $message);
 }
Example #8
0
 public static function sync($params)
 {
     $item = Item::find_by_subject($params["type"], $params["id"]);
     if (empty($item)) {
         // create
         Item::create($params);
     } else {
         // sync
         $item->update($params);
     }
 }
Example #9
0
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        Eloquent::unguard();
        DB::table('companies')->delete();
        DB::table('items')->delete();
        DB::table('categories')->delete();
        $territory = Territory::where('name', 'Stockholms län')->where('county', '01')->first();
        $company1 = Company::create(array('id' => 1, 'name' => '北欧工作室', 'description' => 'chenyipingsheng: 如何设计api,应该先按模块拆分原则进行初步划分。(4) api返回数据文章中所说的对null的看法...
app后端设计(10)--数据增量更新
chenyipingsheng: 文章中update_time的时间粒度选择的是分钟,如果某个时间段内新增的条数/分钟,超过了单页si...', 'territory_id' => $territory->id, 'url' => 'http://www.google.com', 'address' => '啊发扩大浪费大斗进发觉啦地方', 'established_year' => '2011'));
        $company2 = Company::create(array('id' => 2, 'name' => '阿呆姆斯工作室', 'description' => 'chenyipingsheng: 如何设计api,应该先按模块拆分原则进行初步划分。(4) api返回数据文章中所说的对null的看法...
app后端设计(10)--数据增量更新
chenyipingsheng: 文章中update_time的时间粒度选择的是分钟,如果某个时间段内新增的条数/分钟,超过了单页si...', 'territory_id' => $territory->id, 'url' => 'http://www.google.com', 'address' => '饿我热哦我iooewpp', 'established_year' => '2013'));
        $item1 = Item::create(array('id' => 1, 'company_id' => 1, 'name' => 'Kayala投资项目', 'description' => '做了3年app相关的系统架构,api设计,先后在3个创业公司中工作,经历过手机网页端,android客户端,iphone客户端,现就职于app云后端平台bmob(想了解bmob点击这里)。其中的乐与苦,得与失,仰首问天有谁知?我觉得是时候来个总结,把相关的技术和心得记录下来。', 'territory_id' => $territory->id, 'url' => 'http://www.google.com', 'min_investment' => 20000000));
        $item2 = Item::create(array('id' => 2, 'company_id' => 1, 'name' => '棕熊城堡出售', 'description' => '做了3年app相关的系统架构,api设计,先后在3个创业公司中工作,经历过手机网页端,android客户端,iphone客户端,现就职于app云后端平台bmob(想了解bmob点击这里)。其中的乐与苦,得与失,仰首问天有谁知?我觉得是时候来个总结,把相关的技术和心得记录下来。', 'territory_id' => $territory->id, 'url' => 'http://www.google.com', 'min_investment' => 30000000, 'max_investment' => 30000000));
        $item3 = Item::create(array('id' => 3, 'company_id' => 2, 'name' => '布鲁艾尔空气净化器', 'description' => '做了3年app相关的系统架构,api设计,先后在3个创业公司中工作,经历过手机网页端,android客户端,iphone客户端,现就职于app云后端平台bmob(想了解bmob点击这里)。其中的乐与苦,得与失,仰首问天有谁知?我觉得是时候来个总结,把相关的技术和心得记录下来。', 'territory_id' => $territory->id, 'url' => 'http://www.google.com', 'min_investment' => 10000000, 'max_investment' => 10000000));
        $item4 = Item::create(array('id' => 4, 'company_id' => 2, 'name' => 'volvo公司转让', 'description' => '做了3年app相关的系统架构,api设计,先后在3个创业公司中工作,经历过手机网页端,android客户端,iphone客户端,现就职于app云后端平台bmob(想了解bmob点击这里)。其中的乐与苦,得与失,仰首问天有谁知?我觉得是时候来个总结,把相关的技术和心得记录下来。', 'territory_id' => $territory->id, 'url' => 'http://www.google.com', 'min_investment' => 250000000, 'max_investment' => 250000000));
        Category::create(array('id' => 1, 'name' => '融资项目'));
        Category::create(array('id' => 2, 'name' => '房产出售'));
        Category::create(array('id' => 3, 'name' => '产品推广'));
        Category::create(array('id' => 4, 'name' => '公司转让'));
        Category::create(array('id' => 5, 'name' => '技术出售'));
        Category::create(array('id' => 6, 'name' => '文化, 媒体, 旅游'));
        CompanyCategory::create(array('id' => 1, 'company_id' => 1, 'category_id' => 6));
        CompanyCategory::create(array('id' => 2, 'company_id' => 2, 'category_id' => 6));
        ItemCategory::create(array('id' => 1, 'item_id' => 1, 'category_id' => 1));
        ItemCategory::create(array('id' => 2, 'item_id' => 1, 'category_id' => 2));
        ItemCategory::create(array('id' => 3, 'item_id' => 2, 'category_id' => 2));
        ItemCategory::create(array('id' => 4, 'item_id' => 3, 'category_id' => 4));
        ItemCategory::create(array('id' => 5, 'item_id' => 3, 'category_id' => 5));
        ItemCategory::create(array('id' => 6, 'item_id' => 3, 'category_id' => 6));
        ItemCategory::create(array('id' => 7, 'item_id' => 4, 'category_id' => 3));
        ItemCategory::create(array('id' => 8, 'item_id' => 4, 'category_id' => 5));
        Tag::create(array('id' => 1, 'name' => '回报率高'));
        Tag::create(array('id' => 2, 'name' => '绿色环保'));
        Tag::create(array('id' => 3, 'name' => '市场巨大'));
        Tag::create(array('id' => 4, 'name' => '用途广'));
        Tag::create(array('id' => 5, 'name' => '历史悠久'));
        Tag::create(array('id' => 6, 'name' => '可自雇'));
        Tag::create(array('id' => 7, 'name' => 'PM2.5'));
        ItemTag::create(array('id' => 1, 'tag_id' => 1, 'item_id' => 1));
        ItemTag::create(array('id' => 2, 'tag_id' => 2, 'item_id' => 1));
        ItemTag::create(array('id' => 3, 'tag_id' => 3, 'item_id' => 1));
        ItemTag::create(array('id' => 4, 'tag_id' => 2, 'item_id' => 2));
        ItemTag::create(array('id' => 5, 'tag_id' => 3, 'item_id' => 2));
        ItemTag::create(array('id' => 6, 'tag_id' => 4, 'item_id' => 2));
        ItemTag::create(array('id' => 7, 'tag_id' => 5, 'item_id' => 3));
        ItemTag::create(array('id' => 8, 'tag_id' => 6, 'item_id' => 3));
        ItemTag::create(array('id' => 9, 'tag_id' => 7, 'item_id' => 3));
        ItemTag::create(array('id' => 10, 'tag_id' => 3, 'item_id' => 4));
        ItemTag::create(array('id' => 11, 'tag_id' => 6, 'item_id' => 4));
    }
Example #10
0
 public function run()
 {
     DB::table('items')->delete();
     $set = Set::find(1);
     $item1 = Item::create(array('item_id' => 1, 'name' => 'ATH-M50x Professional Monitor Headphones', 'creator' => 1, 'image_url' => 'https://d2qmzng4l690lq.cloudfront.net/resizer/450x450/v/VDWZ23_20140202_100823_2E9CC3160EB4DE7586.png'));
     $item1->sets()->attach(1);
     sleep(1);
     $item2 = Item::create(array('item_id' => 2, 'name' => 'FiiO E17 USB DAC Headphone Amplifier', 'creator' => 1, 'image_url' => 'https://d2qmzng4l690lq.cloudfront.net/resizer/450x450/v/2FNXFT_20130816_132147_OPWOOEWLU125PK8HXM.png'));
     $item2->sets()->attach(1);
     sleep(1);
     $item3 = Item::create(array('item_id' => 3, 'name' => 'iBasso DX50 Digital Audio Player', 'creator' => 1, 'image_url' => 'https://d2qmzng4l690lq.cloudfront.net/resizer/450x450/v/EJ6QKT_20140530_194403_0F8FDF5FA221AAC02E.png'));
     $item3->sets()->attach(1);
 }
Example #11
0
 public static function add(GatheringDataSourceConfiguration $configuration, $post)
 {
     $gathering = $configuration->getGatheringObject();
     try {
         // we wrap this in a try because it MIGHT fail if it's a duplicate
         $item = parent::create($gathering, $configuration->getGatheringDataSourceObject(), $post->get_date('Y-m-d H:i:s'), $post->get_title(), $post->get_link());
     } catch (Exception $e) {
     }
     if (is_object($item)) {
         $item->assignFeatureAssignments($post);
         $item->setAutomaticGatheringItemTemplate();
         return $item;
     }
 }
 public function postAdd()
 {
     $params = Input::all();
     $item = Item::create(array('name' => $params['title'], 'item_code' => '', 'updated' => time(), 'created' => time()));
     foreach ($params['items'] as $param) {
         // レビューの抽出
         if ($param['itemFrom'] == 'rakuten') {
             Review::getReviews($param['itemCode'], $item->id);
         } else {
             Review::getAmazonReview($param['itemCode'], $item->id);
         }
     }
     $response = array('status' => 'ok', 'id' => $item->id);
     return json_encode($response);
 }
Example #13
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 100; $i++) {
         $type = $faker->numberBetween(1, 3);
         switch ($type) {
             case 1:
                 $name = ucfirst($faker->word);
                 break;
             case 2:
             case 3:
                 $name = ucwords(implode(' ', $faker->words(3)));
                 break;
         }
         $item = Item::create(['user_id' => $faker->numberBetween(1, 2), 'type_id' => $type, 'product_id' => $faker->numberBetween(1, 3), 'name' => $name, 'desc' => $faker->paragraph(10), 'slug' => '']);
         // Create a new meta model
         $metadata = new ItemMetadata();
         $metadata->fill(['item_id' => $item->id, 'installation' => implode("\r\n\r\n", $faker->paragraphs(3)), 'history' => $faker->paragraph])->save();
         // Determine how many times we're looping through ratings
         $ratingsLoop = $faker->numberBetween(1, 10);
         for ($j = 1; $j < $ratingsLoop; $j++) {
             ItemRating::create(['user_id' => $faker->numberBetween(1, 50), 'item_id' => $item->id, 'rating' => $faker->numberBetween(1, 5)]);
         }
         // Update the total rating
         $item->updateRating();
         // Determine how many times we're looping through comments
         $commentsLoop = $faker->numberBetween(1, 10);
         for ($c = 1; $c < $commentsLoop; $c++) {
             Comment::create(['user_id' => $faker->numberBetween(1, 50), 'item_id' => $item->id, 'content' => $faker->paragraph]);
         }
         // Determine how many times we're looping through files
         $filesLoop = $faker->numberBetween(1, 10);
         for ($f = 1; $f < $filesLoop; $f++) {
             $version = $faker->randomFloat(1, 1, 9);
             $filename = "{$item->user->username}/{$item->slug}-{$version}.zip";
             ItemFile::create(['item_id' => $item->id, 'filename' => $filename, 'version' => $version, 'size' => $faker->numberBetween(1, 999999)]);
         }
         $item->update(['version' => $version]);
         // Determine how many times we're looping through orders
         $ordersLoop = $faker->numberBetween(0, 100);
         for ($o = 1; $o < $ordersLoop; $o++) {
             Order::create(['user_id' => $faker->numberBetween(1, 50), 'item_id' => $item->id, 'file_id' => $faker->numberBetween(1, 400)]);
         }
     }
 }
Example #14
0
 public function add()
 {
     $this->load->library('jdf');
     $this->load->helper('form');
     $this->load->library('form_validation');
     $this->load->library("session");
     if ($this->form_validation->run('item/add') === FALSE) {
         $this->load->view("templates/errorForm.php", array("fields" => array('rating', 'isDone', 'task', 'date', 'endTime', 'startTime')));
     } else {
         $item = new Item();
         $task = new Task();
         $user = new User($this->session->getStudentId());
         if ($this->input->post("isDone") == 1) {
             $state = ITEM_STATE_DONE;
         } else {
             $state = ITEM_STATE_UNDONE;
         }
         $task->where("user_id", $this->session->getStudentId());
         $task->where("id", $this->input->post("task"));
         $start = makeTime($this->input->post("date"), $this->input->post("startTime"));
         $end = makeTime($this->input->post("date"), $this->input->post("endTime"));
         try {
             $task->get();
             $item->create($start, $end, $this->input->post("description"), $state, $this->input->post("rating"))->save($user, $task);
             $this->load->view("item/item_created.php", array("item" => $this->setFormat(array($item))));
         } catch (Item_Overlap_With_Other_Item $e) {
             $this->load->view("item/item_error.php");
             Item_Error::Item_Overlap_With_Other_Item();
         } catch (Item_Create_With_Zero_Duration $e) {
             $this->load->view("item/item_error.php");
             Item_Error::Item_Create_With_Zero_Duration();
         } catch (Item_Feedback_Wrong $e) {
             $this->load->view("item/item_error.php");
             Item_Error::Item_Feedback_Wrong();
         } catch (Item_Start_Greater_Than_End_Exception $e) {
             $this->load->view("item/item_error.php");
             Item_Error::Item_Start_Greater_Than_End_Exception();
         } catch (Task_Not_Found $e) {
             $this->load->view("task/task_error.php");
         }
     }
 }
Example #15
0
 public static function add(GatheringDataSourceConfiguration $configuration, $tweet)
 {
     $gathering = $configuration->getGatheringObject();
     try {
         // we wrap this in a try because it MIGHT fail if it's a duplicate
         $item = parent::create($gathering, $configuration->getGatheringDataSourceObject(), date('Y-m-d H:i:s', strtotime($tweet->created_at)), $tweet->text, $tweet->id);
     } catch (Exception $e) {
     }
     if (is_object($item)) {
         $item->assignFeatureAssignments($tweet);
         if (count($tweet->entities->media) > 0 && $tweet->entities->media[0]->type == 'photo') {
             $item->setAutomaticGatheringItemTemplate();
         } else {
             $type = GatheringItemTemplateType::getByHandle('tile');
             $template = GatheringItemTemplate::getByHandle('tweet');
             $item->setGatheringItemTemplate($type, $template);
         }
         return $item;
     }
 }
Example #16
0
 function create_items()
 {
     if ($_POST) {
         unset($_POST['send']);
         $_POST['inactive'] = 0;
         $_POST = array_map('htmlspecialchars', $_POST);
         $item = Item::create($_POST);
         if (!$item) {
             $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_create_item_error'));
         } else {
             $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_create_item_success'));
         }
         redirect('items');
     } else {
         $this->theme_view = 'modal';
         $this->view_data['title'] = $this->lang->line('application_create_item');
         $this->view_data['form_action'] = 'items/create_items';
         $this->content_view = 'invoices/_items';
     }
 }
Example #17
0
 /**
  * Store a newly created item in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Item::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $data['short_name'] = '';
     if (Input::hasFile('image')) {
         //large
         Image::make(Input::file('image'))->save(public_path() . '/uploads/product/origin.' . $data['code'] . ".jpg");
         Image::make(Input::file('image'))->resize(1000, 1000)->save(public_path() . '/uploads/product/large.' . $data['code'] . ".jpg");
         Image::make(Input::file('image'))->resize(250, 250)->save(public_path() . '/uploads/product/medium.' . $data['code'] . ".jpg");
         Image::make(Input::file('image'))->resize(120, 120)->save(public_path() . '/uploads/product/small.' . $data['code'] . ".jpg");
         $data['image'] = '/uploads/product/medium.' . $data['code'] . ".jpg";
     } else {
         $data['image'] = '';
     }
     $data['attribute'] = '';
     Item::create($data);
     return Redirect::route('admin.items.index');
 }
Example #18
0
 function create_items()
 {
     if ($_POST) {
         $config['upload_path'] = self::UPLOAD_PATH;
         $config['encrypt_name'] = TRUE;
         $config['allowed_types'] = '*';
         $this->load->library('upload', $config);
         if (!$this->upload->do_upload()) {
             $error = $this->upload->display_errors('', ' ');
             $this->session->set_flashdata('message', 'error:' . $error);
             redirect('items');
         } else {
             $data = array('upload_data' => $this->upload->data());
             $_POST['photo'] = $data['upload_data']['file_name'];
             $_POST['photo_type'] = $data['upload_data']['file_type'];
             $_POST['photo_original_name'] = $data['upload_data']['orig_name'];
         }
         unset($_POST['send']);
         unset($_POST['userfile']);
         unset($_POST['file-name']);
         unset($_POST['files']);
         $_POST = array_map('htmlspecialchars', $_POST);
         $item = Item::create($_POST);
         if (!$item) {
             $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_create_item_error'));
         } else {
             $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_create_item_success'));
         }
         redirect('items');
     } else {
         $this->theme_view = 'modal';
         $this->view_data['title'] = $this->lang->line('application_create_item');
         $this->view_data['form_action'] = 'items/create_items';
         $this->content_view = 'invoices/_items';
     }
 }
 function test_uncompleted_after_completed()
 {
     $item = new Item();
     $item->create(time() + 1000, time() + 10000, "this item created for testing goal  completed", ITEM_STATE_DONE_WAIT_FOR_FEEDBACK)->save($this->user, $this->task);
     $this->goal->create(100, strtotime("-1 week"), strtotime("+1 week"))->save($this->task);
     $item->delete();
     $this->goal->get($this->goal->getId());
     $this->_assert_equals($this->goal->getAchieveTime(), null);
     $item->delete();
 }
Example #20
0
 function testSetNewOrder()
 {
     $Item = new Item();
     $Item->create();
     $Item->setNewOrder();
     $this->assertNull($Item->Behaviors->Sequence->newOrder);
     $Item->data['Item']['order'] = 1;
     $Item->setNewOrder();
     $this->assertEqual($Item->Behaviors->Sequence->newOrder, 1);
 }
Example #21
0
 private static function addSystemCommands()
 {
     $cmds = array('delete cache' => 'Delete GitHub Cache', 'logout' => 'Log out this workflow', 'update' => 'Update this Alfred workflow');
     if (Workflow::getConfig('autoupdate', true)) {
         $cmds['deactivate autoupdate'] = 'Deactivate auto updating this Alfred Workflow';
     } else {
         $cmds['activate autoupdate'] = 'Activate auto updating this Alfred Workflow';
     }
     if (self::$enterprise) {
         $cmds['enterprise reset'] = 'Reset the GitHub Enterprise URL';
     }
     foreach ($cmds as $cmd => $desc) {
         Workflow::addItem(Item::create()->title('> ' . $cmd)->subtitle($desc)->icon($cmd)->arg('> ' . str_replace(' ', '-', $cmd)));
     }
     $cmds = array('help' => 'readme', 'changelog' => 'changelog');
     foreach ($cmds as $cmd => $file) {
         Workflow::addItem(Item::create()->title('> ' . $cmd)->subtitle('View the ' . $file)->icon('file')->arg('https://github.com/gharlan/alfred-github-workflow/blob/master/' . strtoupper($file) . '.md'));
     }
 }
Example #22
0
 /**
  * Iterator get current element, generates a new object for the current item on acces.
  *
  * @return \luya\admin\file\Item
  */
 public function current()
 {
     return Item::create(current($this->data));
 }
Example #23
0
 function item($id = FALSE)
 {
     if ($_POST) {
         unset($_POST['send']);
         $_POST = array_map('htmlspecialchars', $_POST);
         $id = $_POST['invoice_id'];
         $invoice = Invoice::find($id);
         $item_type = 'regular';
         if ($invoice->invoice_type == $this->invoice_shipment_type) {
             $item_type = 'shipping';
         }
         $is_new_item = false;
         if (isset($_POST['new_item']) && htmlspecialchars($_POST['new_item']) == "1") {
             $is_new_item = true;
             $filename = $savename = $type = '';
             if ($invoice->invoice_type != $this->invoice_shipment_type) {
                 $config['upload_path'] = self::ITEM_UPLOAD_PATH;
                 $config['encrypt_name'] = TRUE;
                 $config['allowed_types'] = '*';
                 $this->load->library('upload', $config);
                 if (!$this->upload->do_upload()) {
                     $error = $this->upload->display_errors('', ' ');
                     $this->session->set_flashdata('message', 'error:' . $error);
                     redirect('estimates/view/' . $id);
                 } else {
                     $data = array('upload_data' => $this->upload->data());
                     $filename = $data['upload_data']['orig_name'];
                     $savename = $data['upload_data']['file_name'];
                     $type = $data['upload_data']['file_type'];
                 }
             }
             unset($_POST['send']);
             unset($_POST['userfile']);
             unset($_POST['new_item']);
             unset($_POST['file-name']);
             unset($_POST['files']);
             $item_name = $item_description = $_POST['name'];
             $cost = $original_cost = $_POST['value'];
             $sku = $_POST['sku'];
             $inactive = $_POST['inactive'];
             $item_data = array('photo' => $savename, 'photo_type' => $type, 'photo_original_name' => $filename, 'type' => $item_type, 'name' => $item_name, 'value' => $original_cost, 'description' => $item_description, 'sku' => $sku, 'inactive' => $inactive);
             $item = Item::create($item_data);
             $item_id = $_POST['item_id'] = $item->id;
         } else {
             unset($_POST['send']);
             unset($_POST['userfile']);
             unset($_POST['file-name']);
             unset($_POST['files']);
             unset($_POST['new_item']);
             unset($_POST['name']);
             unset($_POST['sku']);
             unset($_POST['inactive']);
             $_POST = array_map('htmlspecialchars', $_POST);
             if ($_POST['item_id'] == "-" || $_POST['item_id'] == "0") {
                 $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_add_item_error'));
                 redirect('estimates/view/' . $id);
             }
             $item_id = $_POST['item_id'];
             $item_details = Item::find($item_id);
             $item_name = $item_details->name;
             $item_description = $item_details->description;
             $cost = empty($_POST['value']) ? $item_details->value : $_POST['value'];
             $original_cost = $item_details->value;
             $savename = $item_details->photo;
             $type = $item_details->photo_type;
             $filename = $item_details->photo_original_name;
             $sku = $item_details->sku;
             $item_type = $item_details->type;
             $inactive = $item_details->inactive;
         }
         $estimate_item_exist = InvoiceHasItem::count(array('conditions' => array('invoice_id=? AND item_id=?', $id, $item_id)));
         if ($estimate_item_exist) {
             $estimate_item = false;
             $error = $this->lang->line('messages_project_save_item_exist');
             $this->session->set_flashdata('message', 'error:' . $error);
             redirect('estimates/view/' . $id);
         } else {
             $invoice_item_data = array('invoice_id' => $id, 'item_id' => $item_id, 'project_item_id' => '0', 'photo' => $savename, 'photo_type' => $type, 'photo_original_name' => $filename, 'name' => $item_name, 'amount' => $_POST['amount'], 'description' => $item_description, 'sku' => $sku, 'value' => $cost, 'type' => $item_type, 'original_cost' => $original_cost, 'shipping_item' => $invoice->invoice_type == 'Shipment' ? '1' : '0');
             $estimate_item = InvoiceHasItem::create($invoice_item_data);
         }
         if (!$estimate_item) {
             $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_add_item_error'));
         } else {
             $this->projectlib->updateInvoiceTotal($invoice);
             $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_add_item_success'));
         }
         redirect('estimates/view/' . $_POST['invoice_id']);
     } else {
         $this->view_data['estimate'] = Invoice::find($id);
         $this->view_data['estimate_type'] = $this->view_data['estimate']->invoice_type;
         $this->view_data['items'] = Item::find('all', array('conditions' => array('inactive=?', '0')));
         $this->theme_view = 'modal';
         $this->view_data['title'] = $this->lang->line('application_add_item');
         $this->view_data['form_action'] = 'estimates/item';
         $this->content_view = 'estimates/_item';
     }
 }
    echo "You must be logged in to upload inspiration.";
    die;
}
$id = isset($_POST['id']) ? $_POST['id'] : null;
$name = isset($_POST['name']) ? $_POST['name'] : null;
$description = isset($_POST['description']) ? $_POST['description'] : null;
//Gets array of display
$count = 0;
$zero = false;
$label = $_POST['label'];
if (!$id) {
    $file = isset($_FILES['file']) ? $_FILES['file'] : null;
    $fileUploader = new FileUploader($file, $name, $description);
    $fileId = $fileUploader->uploadFile();
    $item = new Item($name, $description, true);
    $id = $item->create();
} else {
    $item = new Item($name, $description, true, $id);
    $item->update();
}
//Gets array of tags
$tags = $_POST['tags'];
//Gets array of categories
$categories = $_POST['categories'];
$db = new Database();
$db->connect();
//CATEGORIES
$db->select("category_connector", "category_id", null, "item_id=" . $id);
$existingCategories = array_column($db->getResult(), 'category_id');
//GET ALL Grandparent Cats
$db->select("categories", "id", null, "parent_id = 0");
Example #25
0
$page->display('items/add_item.tpl');


$type_id = $name = $location = null;
if(isset($_POST['type_id'])){
    $type_id = $_POST['type_id'];
}
if(isset($_POST['name'])){
    $name = $_POST['name'];
}
if(isset($_POST['location'])){
    $location = $_POST['location'];
}
if($type_id != null && $name != null && $location != null){
    $new_item_id = Item::create($db->escape_string($name), $type_id, $user_id);
    Item::set_location_by_id($new_item_id, $db->escape_string($location));

    if(isset($_POST['attributes'])){
        $attributes = $_POST['attributes'];
        foreach($attributes as $attribute){
            $attribute_id = (int)$attribute['id'];
            $value = $db->escape_string($attribute['value']);
//echo "ID: $attribute_id V: $value";

            $new_attribute = new Attribute($new_item_id, $attribute_id);
            $new_attribute->set_value($value);
        }
    }
    redirect_to_url("/items/item.php?id=$new_item_id");
Example #26
0
 /**
  * Store a newly created resource in storage.
  * POST /items
  *
  * @return Response
  */
 public function store()
 {
     return Item::create(Input::all());
 }
 public function test_get_a_week()
 {
     $currentWeek = jdate("W", time(), "", "Asia/Tehran", "en");
     $currentYear = jdate("Y");
     $twoWeekAgo = strtotime("-2 week");
     $weekAgo = strtotime("-1 week");
     $current = time() + 30;
     // chone ke momkene moghe get kardan state taghir kone man dige inja 30 sanie balatar zadam ke az in jahat moshekl pish nayad!
     $twoWeekLater = strtotime("+2 week");
     $weekLater = strtotime("+1 week");
     $oneHour = 3600;
     $tempItem = new Item();
     $itemTwoWeekAge = new Item();
     $itemTwoWeekAge->create($twoWeekAgo, $twoWeekAgo + $oneHour, "2 hafte gozashte", ITEM_STATE_DONE, 3)->save($this->user, $this->task);
     $itemOneWeekAge = new Item();
     $itemOneWeekAge->create($weekAgo, $weekAgo + $oneHour, "1 hafte gozashte", ITEM_STATE_UNDONE)->save($this->user, $this->task);
     $itemCurrentWeek = new Item();
     $itemCurrentWeek->create($current, $current + $oneHour, "hamin hafte", ITEM_STATE_INCOMING)->save($this->user, $this->task);
     $itemOneWeekLater = new Item();
     $itemOneWeekLater->create($weekLater, $weekLater + $oneHour, "1 hafte bad", ITEM_STATE_UNDONE)->save($this->user, $this->task);
     $itemTwoWeekLater = new Item();
     $itemTwoWeekLater->create($twoWeekLater, $twoWeekLater + $oneHour, "2 hafte bad", ITEM_STATE_UNDONE)->save($this->user, $this->task);
     $this->_assert_true($itemTwoWeekAge->__toString() == $tempItem->getByWeek($currentYear, $currentWeek - 2, $this->user)->__toString());
     $this->_assert_true($itemOneWeekAge->__toString() == $tempItem->getByWeek($currentYear, $currentWeek - 1, $this->user)->__toString());
     $this->_assert_true($itemCurrentWeek->__toString() == $tempItem->getByWeek($currentYear, $currentWeek, $this->user)->__toString());
     $this->_assert_true($itemOneWeekLater->__toString() == $tempItem->getByWeek($currentYear, $currentWeek + 1, $this->user)->__toString());
     $this->_assert_true($itemTwoWeekLater->__toString() == $tempItem->getByWeek($currentYear, $currentWeek + 2, $this->user)->__toString());
     $itemTwoWeekAge->delete();
     $itemOneWeekAge->delete();
     $itemCurrentWeek->delete();
     $itemOneWeekLater->delete();
     $itemTwoWeekLater->delete();
 }
Example #28
0
 private static function addSystemCommands()
 {
     $cmds = array('delete cache' => 'Delete GitHub Cache', 'logout' => 'Log out this workflow', 'update' => 'Update this Alfred workflow');
     if (Workflow::getConfig('autoupdate', true)) {
         $cmds['deactivate autoupdate'] = 'Deactivate auto updating this Alfred Workflow';
     } else {
         $cmds['activate autoupdate'] = 'Activate auto updating this Alfred Workflow';
     }
     foreach ($cmds as $cmd => $desc) {
         Workflow::addItem(Item::create()->prefix('gh ')->title('> ' . $cmd)->subtitle($desc)->icon($cmd)->arg('> ' . str_replace(' ', '-', $cmd)));
     }
 }
 public function testEasyRelation()
 {
     // Has Many
     $user = User::create(array('name' => 'John Doe'));
     $item = Item::create(array('type' => 'knife'));
     $user->items()->save($item);
     $user = User::find($user->_id);
     $items = $user->items;
     $this->assertEquals(1, count($items));
     $this->assertInstanceOf('Item', $items[0]);
     $this->assertEquals($user->_id, $items[0]->user_id);
     // Has one
     $user = User::create(array('name' => 'John Doe'));
     $role = Role::create(array('type' => 'admin'));
     $user->role()->save($role);
     $user = User::find($user->_id);
     $role = $user->role;
     $this->assertInstanceOf('Role', $role);
     $this->assertEquals('admin', $role->type);
     $this->assertEquals($user->_id, $role->user_id);
 }
 public function testDates()
 {
     $birthday = new DateTime('1980/1/1');
     $user = User::create(array('name' => 'John Doe', 'birthday' => $birthday));
     $this->assertInstanceOf('Carbon\\Carbon', $user->birthday);
     $check = User::find($user->_id);
     $this->assertInstanceOf('Carbon\\Carbon', $check->birthday);
     $this->assertEquals($user->birthday, $check->birthday);
     $user = User::where('birthday', '>', new DateTime('1975/1/1'))->first();
     $this->assertEquals('John Doe', $user->name);
     // test custom date format for json output
     $json = $user->toArray();
     $this->assertEquals((string) $user->birthday, $json['birthday']);
     $this->assertEquals((string) $user->created_at, $json['created_at']);
     // test default date format for json output
     $item = Item::create(array('name' => 'sword'));
     $json = $item->toArray();
     $this->assertEquals($item->created_at->format('Y-m-d H:i:s'), $json['created_at']);
     $user = User::create(array('name' => 'Jane Doe', 'birthday' => time()));
     $this->assertInstanceOf('Carbon\\Carbon', $user->birthday);
     $user = User::create(array('name' => 'Jane Doe', 'birthday' => 'Monday 8th of August 2005 03:12:46 PM'));
     $this->assertInstanceOf('Carbon\\Carbon', $user->birthday);
     $user = User::create(array('name' => 'Jane Doe', 'birthday' => '2005-08-08'));
     $this->assertInstanceOf('Carbon\\Carbon', $user->birthday);
     $user = User::create(array('name' => 'Jane Doe', 'entry' => array('date' => '2005-08-08')));
     $this->assertInstanceOf('Carbon\\Carbon', $user->getAttribute('entry.date'));
     $user->setAttribute('entry.date', new DateTime());
     $this->assertInstanceOf('Carbon\\Carbon', $user->getAttribute('entry.date'));
 }