public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Entry::create([]);
     }
 }
 public function saveEntryAction()
 {
     $inputs = Input::only(array('title', 'content'));
     $inputs["user_id"] = Auth::user()->id;
     $inputs["entry_at"] = new DateTime();
     $entry = Entry::create($inputs);
     return Redirect::route('blog/list');
 }
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 150) as $index) {
         $title = $faker->sentence(rand(4, 6));
         $date = Carbon::now()->subDays(rand(1, 20));
         Entry::create(['id' => $index, 'title' => $title, 'content' => $faker->text(), 'slug' => Str::slug($title), 'author_id' => rand(1, 10), 'created_at' => $date, 'updated_at' => $date]);
     }
 }
Пример #4
0
 function create()
 {
     Auth::checkLoggedIn();
     $course = Course::fromId(Input::get('courseid'));
     if (!$course->canEdit(Auth::getUser())) {
         throw new Exception('You are not allowed to create an entry in this course.');
     }
     $entry = Entry::create(Auth::getUser(), $course, Input::get('title'), Input::get('description'));
     if (Input::exists('due_at')) {
         $entry->setDueTime(Input::get('due_at'));
     }
     if (Input::exists('display_at')) {
         $entry->setDisplayTime(Input::get('display_at'));
     }
     if (Input::exists('visible')) {
         $entry->setVisible(Input::getBoolean('visible'));
     }
     View::renderJson($entry->getContext(Auth::getUser()));
 }
 public function run()
 {
     DB::table('entries')->delete();
     copy('app/database/seeds/pictures/1.jpg', 'app/database/seeds/pictures/1b.jpg');
     copy('app/database/seeds/pictures/2.jpg', 'app/database/seeds/pictures/2b.jpg');
     copy('app/database/seeds/pictures/3.jpg', 'app/database/seeds/pictures/3b.jpg');
     copy('app/database/seeds/pictures/4.jpg', 'app/database/seeds/pictures/4b.jpg');
     copy('app/database/seeds/pictures/5.jpg', 'app/database/seeds/pictures/5b.jpg');
     copy('app/database/seeds/pictures/6.jpg', 'app/database/seeds/pictures/6b.jpg');
     copy('app/database/seeds/pictures/7.jpg', 'app/database/seeds/pictures/7b.jpg');
     copy('app/database/seeds/pictures/8.jpg', 'app/database/seeds/pictures/8b.jpg');
     Entry::create(['title' => 'Ta mère', 'content' => "Ta mère est une société montoise qui n'a pas froid aux yeux. C'est pour ça qu'on la met ici.", 'author_name' => 'François Stephany', 'author_email' => '*****@*****.**', 'kind' => 'article', 'url' => 'http://tamere.eu', 'picture' => 'app/database/seeds/pictures/1b.jpg']);
     Entry::create(['title' => 'Ta soeur', 'content' => "Et ta soeur ? Disent-ils tous ! Et ils ont bien raison !", 'author_name' => 'Aurélien Malisart', 'author_email' => '*****@*****.**', 'kind' => 'article', 'url' => 'http://www.tasoeur.biz', 'picture' => 'app/database/seeds/pictures/2b.jpg']);
     Entry::create(['title' => 'Un événement', 'content' => "Super pechakucha créatif à Mons avec l'aide de CreativeMons et des Rendez-vous des pixelsfestival!", 'author_name' => 'Romain Carlier', 'author_email' => '*****@*****.**', 'kind' => 'event', 'start_date' => "2014-08-02", 'end_date' => "2014-08-02", 'url' => 'http://www.pechakucha.org/cities/mons', 'picture' => 'app/database/seeds/pictures/3b.jpg']);
     Entry::create(['title' => 'Ton frère', 'content' => "Frère Jacques, frère Jacques, dormez-vous ? Dormez-vous ? Sonnez les matines, sonnez les matines, ding dang dong", 'author_name' => 'Michaël Hoste', 'author_email' => '*****@*****.**', 'kind' => 'article', 'url' => 'http://desencyclopedie.wikia.com/wiki/Ton_fr%C3%A8re', 'picture' => 'app/database/seeds/pictures/4b.jpg']);
     Entry::create(['title' => 'Pechakucha', 'content' => "En japonais ça veut dire un truc comme 'blabla' (d'après Ruben mais personne n'a jamais vérifié)", 'author_name' => 'Ruben Casad', 'author_email' => '*****@*****.**', 'kind' => 'article', 'url' => 'http://www.pechakucha.org/', 'picture' => 'app/database/seeds/pictures/5b.jpg']);
     Entry::create(['title' => 'Barbecues 101', 'content' => "Organisés par Meaweb, l'invitation aux barbecues est lancée contractuellement maximum 3 heures à l'avance pour bien prendre tout le monde par surprise.", 'author_name' => 'Simon', 'author_email' => '*****@*****.**', 'kind' => 'event', 'start_date' => "2014-08-02", 'end_date' => "2014-08-02", 'url' => 'https://twitter.com/Meaweb', 'picture' => 'app/database/seeds/pictures/6b.jpg']);
     Entry::create(['title' => 'Cafés numériques', 'content' => "Beaucoup de bières et parfois une petite conférence sur du numérique. Donc rien à voir avec du café.", 'author_name' => 'Antoine', 'author_email' => '*****@*****.**', 'kind' => 'event', 'start_date' => "2014-08-02", 'end_date' => "2014-08-02", 'url' => 'https://twitter.com/Meaweb', 'picture' => 'app/database/seeds/pictures/7b.jpg']);
     Entry::create(['title' => 'Rendez-vous du pixel', 'content' => "Tous les pixels s'y donnent rendez-vous, et ils sont beaucoup !", 'author_name' => 'Romain', 'author_email' => '*****@*****.**', 'kind' => 'event', 'start_date' => "2014-08-02", 'end_date' => "2014-08-02", 'url' => 'http://www.pixelsfestival.be/', 'picture' => 'app/database/seeds/pictures/8b.jpg']);
 }
Пример #6
0
$discipline = Discipline::by_id($_GET['discipline_id']);
$tournament = $discipline->get_tournament();
$season = $tournament->get_season();
$player = null;
$player_club = null;
$partner = null;
$partner_club = null;
if (!empty($_POST['player'])) {
    $player = $season->get_player_by_input($_POST['player']);
    if (!empty($_POST['player_club'])) {
        $player_club = $season->get_club_by_input($_POST['player_club']);
    }
}
if (!empty($_POST['partner'])) {
    $partner = $season->get_player_by_input($_POST['partner']);
    if (!empty($_POST['partner_club'])) {
        $partner_club = $season->get_club_by_input($_POST['partner_club']);
    }
}
$email = isset($_POST['email']) ? $_POST['email'] : null;
$seeding = isset($_POST['seeding']) ? $_POST['seeding'] : null;
$memo = isset($_POST['memo']) ? $_POST['memo'] : null;
try {
    $discipline->check_entry($player, $partner);
} catch (utils\InvalidEntryException $iee) {
    render_ajax_error('Meldung kann nicht angenommen werden: ' . $iee->getMessage());
    exit;
}
$entry = Entry::create($discipline, $player, $player_club, $partner, $partner_club, $email, $seeding, $memo);
$entry->save();
render_ajax('d/' . $discipline->id . '/', ['entry' => $entry]);
Пример #7
0
        } else {
            // Creating a new Entry
            // Validate values
            if (!isset($_REQUEST['author_id'])) {
                header("HTTP/1.0 400 Bad Request");
                print "Missing Author ID";
                exit;
            }
            $title = trim($_REQUEST['entry']);
            if ($title == "") {
                header("HTTP/1.0 400 Bad Request");
                print "Empty Entry";
                exit;
            }
            // Create new Entry via ORM
            $new_entry = Entry::create($author_id, $entry);
            // Report if failed
            if ($new_entry == null) {
                header("HTTP/1.0 500 Server Error");
                print "Server couldn't create new entry.";
                exit;
            }
            //Generate JSON encoding of new Entrys
            header("Content-type: application/json");
            print $new_entry->getJSON();
            exit;
        }
    }
}
// If here, none of the above applied and URL could
// not be interpreted with respect to RESTful conventions.
Пример #8
0
 /**
  * Fetch single feed
  * @param Feed feed
  */
 public function fetch(Feed $feed)
 {
     $this->verbose('Fetching: ' . $feed->url);
     // Check HTTPS capability
     if ($feed->https == null) {
         $this->checkHttpsCapability($feed);
     }
     // Execute HTTP Request
     $request = $this->makeRequest($feed->url);
     if ($request['info']['http_code'] != 200) {
         $feed->error = '[ERROR HTTP CODE ' . $request['info']['http_code'] . ']';
         $feed->fetch_interval = 60;
         $feed->fetched();
         $feed->save();
         $this->verbose('Error Fetching: ' . $feed->url);
         return;
         // skip
     }
     if (empty($request['html'])) {
         $feed->error = '[ERROR SERVER RETURN EMPTY CONTENT]';
         $feed->fetch_interval = 60;
         $feed->fetched();
         $feed->save();
         $this->verbose('Error Fetching: ' . $feed->url);
         return;
         // skip
     }
     // Parsing feed
     $simplepie = new SimplePie();
     // $simplepie->set_cache_location( __DIR__ . '/cache/simplepie/' );
     $simplepie->set_raw_data($request['html']);
     $success = $simplepie->init();
     if ($success === false) {
         $feed->error = '[ERROR PARSING FEED]';
         $feed->fetch_interval = 60;
         $feed->fetched();
         $feed->save();
         $this->verbose('Error parsing: ' . $feed->url);
         return;
         // skip
     }
     $feed->title = $simplepie->get_title();
     $feed->link = $simplepie->get_link();
     $items = $simplepie->get_items();
     $new_entries_counter = 0;
     foreach ($items as $item) {
         $entry = Entry::create();
         $entry->hash = $item->get_id(true);
         $entry->feed_id = $feed->id;
         if (!$entry->exists()) {
             $entry->title = $item->get_title();
             $entry->permalink = htmlspecialchars_decode($item->get_permalink());
             $entry->content = $item->get_content();
             $entry->date = $item->get_date('Y-m-d H:i:s');
             if ($entry->date == null) {
                 $entry->date = date('Y-m-d H:i:s');
             }
             $categories = $item->get_categories();
             if (!empty($categories)) {
                 $entry_categories = array();
                 foreach ($categories as $category) {
                     $entry_categories[] = $category->get_label();
                 }
                 if (!empty($categories)) {
                     $entry->categories = implode(',', $entry_categories);
                 }
             }
             unset($categories, $entry_categories);
             $entry->save();
             $new_entries_counter++;
         }
     }
     // Activity detection
     if ($new_entries_counter > 0) {
         $feed->fetch_interval = 3;
     } else {
         if ($feed->fetch_interval * 1.5 <= 20) {
             $feed->fetch_interval = round($feed->fetch_interval * 1.5);
         }
     }
     $feed->error = null;
     $feed->fetched();
     $feed->save();
     $this->getFavicon($feed);
 }
 public function ajax_add_entry()
 {
     $response = array('success' => 0, 'error' => 'Something went wrong. Please try again.');
     if (wp_verify_nonce($_POST['entry_nonce'], 'entry-nonce')) {
         $miles = strlen(trim($_POST['miles'])) > 0 && is_numeric($_POST['miles']) ? abs(trim($_POST['miles'])) : 1;
         $location = new Location();
         if ($_POST['location_id'] > 0) {
             $location->id = $_POST['location_id'];
             $location->read();
             if (!$location->user_id == get_current_user_id()) {
                 $location->id = 0;
             }
         }
         if ($location->id == 0) {
             $location->user_id = get_current_user_id();
             $location->title = strlen(trim($_POST['title'])) > 0 ? trim($_POST['title']) : 'New Location';
             $location->miles = $miles;
             $location_id = Location::checkTitle($location->user_id, $location->title);
             if ($location_id > 0) {
                 $location->id = $location_id;
                 $location->update();
             } else {
                 $location->create();
             }
         }
         $entry = new Entry();
         $entry->user_id = get_current_user_id();
         $entry->entry_date = $_POST['year'] . '-' . $_POST['month'] . '-' . $_POST['day'];
         $entry->mode = $_POST['mode'];
         $entry->miles = $miles;
         $entry->location = $location;
         $entry->create();
         if ($entry->id > 0) {
             $response['success'] = 1;
             $response['id'] = $entry->id;
             $response['title'] = $entry->location->title;
             $response['miles'] = number_format($entry->miles, 2);
             $response['day'] = $_POST['day'];
         }
     }
     header('Content-Type: application/json');
     echo json_encode($response);
     exit;
 }
Пример #10
0
 /**
  * Creates an invoice and related items
  */
 public function create()
 {
     $post = Http::getParameter('POST');
     if (count($this->validate()) > 0) {
         throw new Exception('Invalid data entered', 400);
     }
     // create invoice
     if ($this->id == 'new') {
         $this->id = null;
     }
     $this->status = 'Drafted';
     $id = parent::create();
     // create entries
     $this->entries = array();
     foreach ($post['Invoice']['Entry'] as $entry) {
         $Entry = new Entry();
         $Entry->__bind($entry);
         $Entry->invoice_id = $id;
         $Entry->billed = Entry::__getDateTimeFromString($Entry->billed);
         if (!array_key_exists('total', $entry)) {
             $Entry->total = round($entry['quantity'] * $entry['amount_per'], 2);
         }
         $Entry->create();
         $this->entries[] = $Entry;
     }
     // create discounts
     $this->discounts = array();
     foreach ($post['Invoice']['Discount'] as $discount) {
         $Discount = new Discount();
         $Discount->__bind($discount);
         $Discount->invoice_id = $id;
         $Discount->create();
         $this->discounts[] = $Discount;
     }
     // update total
     $this->update_total();
     // update cache, see libraries/misc.php
     delete_cache_entry('invoices', $id);
     // return
     return $id;
 }
Пример #11
0
		<ul>
		    <li>id = <?php 
        print $e->getID();
        ?>
</li>
		    <li>author = <?php 
        print $e->getAuthor();
        ?>
</li>
		    <li>body = <?php 
        print $e->getBody();
        ?>
</li>
		</ul>
		<?php 
    }
}
?>
		<h2>Creating</h2>
		<?php 
$e = Entry::create(1, $input);
?>
		<blockquote>
		<?php 
renderEntry($e);
?>
		</blockquote>
	</body>
</html>