public function postEdit($id)
 {
     if (!$this->checkRoute()) {
         return Redirect::route('index');
     }
     $title = 'Edit A Modpack Creator - ' . $this->site_name;
     $creator = Creator::find($id);
     $input = Input::only('name', 'deck', 'website', 'donate_link', 'bio', 'slug');
     $messages = ['unique' => 'The modpack creator already exists in the database.', 'url' => 'The :attribute field is not a valid URL.'];
     $validator = Validator::make($input, ['name' => 'required|unique:creators,name,' . $creator->id, 'website' => 'url', 'donate_link' => 'url'], $messages);
     if ($validator->fails()) {
         return Redirect::action('CreatorController@getAdd')->withErrors($validator)->withInput();
     }
     $creator->name = $input['name'];
     $creator->deck = $input['deck'];
     $creator->website = $input['website'];
     $creator->donate_link = $input['donate_link'];
     $creator->bio = $input['bio'];
     if ($input['slug'] == '' || $input['slug'] == $creator->slug) {
         $slug = Str::slug($input['name']);
     } else {
         $slug = $input['slug'];
     }
     $creator->slug = $slug;
     $creator->last_ip = Request::getClientIp();
     $success = $creator->save();
     if ($success) {
         return View::make('creators.edit', ['title' => $title, 'creator' => $creator, 'success' => true]);
     }
     return Redirect::action('CreatorController@getEdit', [$id])->withErrors(['message' => 'Unable to edit modpack creator.'])->withInput();
 }
Esempio n. 2
0
 public function run()
 {
     $faker = Faker\Factory::create();
     foreach (range(1, 12) as $index) {
         $username = $faker->userName;
         Creator::create(['name' => $username, 'deck' => $faker->sentence(12), 'website' => $faker->url, 'donate_link' => $faker->url, 'bio' => $faker->paragraph(5), 'slug' => Str::slug($username), 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     }
 }
 public function run()
 {
     $faker = Faker\Factory::create();
     $modpackIds = Modpack::lists('id');
     $creatorssId = Creator::lists('id');
     foreach (range(1, 15) as $index) {
         DB::table('creator_modpack')->insert(['creator_id' => $faker->randomElement($creatorssId), 'modpack_id' => $faker->randomElement($modpackIds), 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     }
 }
Esempio n. 4
0
 public function __construct()
 {
     $this->istok = DBHelper::getIstok(Connection::getConnection());
     $this->obj = Creator::getObject($this->istok["name"]);
     $this->columneNames = $this->istok["colnames"];
     $this->data = $this->istok["colvalues"];
     //print_r($this->istok);
     //$this->test();
     //print_r($this->obj); echo PHP_EOL;
     //print_r($this->columneNames);echo PHP_EOL;
     //print_r($this->data);echo PHP_EOL;
 }
Esempio n. 5
0
 /**
  * Update creator seamlessly
  * @param  integer $input
  * @return boolean or integer       
  */
 public function updateCreator($input, $id)
 {
     try {
         $creator = \Creator::where('userId', $id)->first();
         $creator->name = isset($input['name']) ? $input['name'] : '';
         $creator->type = isset($input['type']) ? $input['type'] : '';
         $creator->administrativeLevel = isset($input['administrativeLevel']) ? $input['administrativeLevel'] : '';
         $creator->region = isset($input['region']) ? $input['region'] : '';
         $creator->fields = isset($input['fields']) ? $input['fields'] : '';
         $creator->siteUrl = isset($input['siteUrl']) ? $input['siteUrl'] : '';
         $creator->save();
     } catch (Exception $e) {
         return false;
     }
     return true;
 }
 /**
  * @Route("/configs/{config}/domains/{domain}/messages",
  *            name="jms_translation_create_message",
  *            defaults = {"id" = null},
  *            options = {"i18n" = false})
  * @Method("POST")
  */
 public function createMessageAction(Request $request, $config, $domain)
 {
     $id = $request->query->get('id');
     $locales = $request->request->get('locales');
     foreach ($locales as $locale) {
         $configuration = $this->configFactory->getConfig($config, $locale);
         $files = FileUtils::findTranslationFiles($configuration->getTranslationsDir());
         if (!isset($files[$domain][$locale])) {
             throw new RuntimeException(sprintf('There is no translation file for domain "%s" and locale %s.', $domain, $locale));
         }
         // TODO: This needs more refactoring, the only sane way I see right now is to replace
         //       the loaders of the translation component as these currently simply discard
         //       the extra information that is contained in these files
         list($format, $file) = $files[$domain][$locale];
         $this->creator->createTranslation($file, $format, $domain, $locale, $id);
     }
     return new Response();
 }
Esempio n. 7
0
 public function __construct()
 {
     // Get contact points
     $creator = Flight::get('creator');
     $contactPoints = $creator->fetch()->contactPoints;
     $orQueryAry = array();
     if ($contactPoints) {
         foreach ($contactPoints as $point) {
             $q = ListItem::query();
             $q->equalTo('objectId', $point->getObjectId());
             $orQueryAry[] = $q;
         }
         $orQuery = ParseQuery::orQueries($orQueryAry);
         $orQuery->includeKey('itemType');
         $contactList = $orQuery->find();
         foreach ($contactList as $c) {
             $contact[$c->itemType->value]['name'] = $c->itemType->value;
             $contact[$c->itemType->value]['link'] = Creator::contactPointLink($c);
         }
     }
     $this->contact = $contact;
 }
    $prepare["package"]["number"] = $_POST["package_number"];
    $prepare["pdf"] = array();
    $prepare["pdf"]["beginx"] = intval($_POST["pdf_beginx"]);
    $prepare["pdf"]["beginy"] = intval($_POST["pdf_beginy"]);
    $prepare["pdf"]["format"] = $_POST["pdf_papersize"];
    $prepare["pdf"]["prefix"] = $_POST["pdf_filename_prefix"];
    $prepare["mode"] = $_POST["mode"];
    $encoded = json_encode($prepare);
    // 2. Either return the JSON or Generate the PDF
    if (isset($_POST["create_json_only"]) && $_POST["create_json_only"] == "1") {
        global $output_json;
        $output_json = $prepare;
        $service->render("view/main.php");
        die;
    } else {
        $c = new Creator();
        if ($c->createFromJson($encoded)) {
            if (empty($c->getErrors())) {
                $c->flush();
                die;
            }
        }
        global $errors;
        $errors = array_merge_recursive($errors, $c->getErrors());
        $service->render("view/main.php");
        die;
    }
});
$klein->respond('POST', '/[*]', function ($request, $response, $service, $app) {
    return json_encode(new GCError("Error: Invalid call."));
});
Esempio n. 9
0
 /**
  * API Method inserts a new Creator record and render response as JSON
  */
 public function Create()
 {
     try {
         $json = json_decode(RequestUtil::GetBody());
         if (!$json) {
             throw new Exception('The request body does not contain valid JSON');
         }
         $creator = new Creator($this->Phreezer);
         // TODO: any fields that should not be inserted by the user should be commented out
         // this is an auto-increment.  uncomment if updating is allowed
         // $creator->Idcreator = $this->SafeGetVal($json, 'idcreator');
         $creator->Institution = $this->SafeGetVal($json, 'institution');
         $creator->Type = $this->SafeGetVal($json, 'type');
         $creator->Name = $this->SafeGetVal($json, 'name');
         $creator->Notes = $this->SafeGetVal($json, 'notes');
         $creator->Birthdate = $this->SafeGetVal($json, 'birthdate');
         $creator->Deathdate = $this->SafeGetVal($json, 'deathdate');
         $creator->Nationality = $this->SafeGetVal($json, 'nationality');
         $creator->Maincontact = $this->SafeGetVal($json, 'maincontact');
         $creator->Validate();
         $errors = $creator->GetValidationErrors();
         if (count($errors) > 0) {
             $this->RenderErrorJSON('Please check the form for errors', $errors);
         } else {
             $creator->Save();
             $this->RenderJSON($creator, $this->JSONPCallback(), true, $this->SimpleObjectParams());
         }
     } catch (Exception $ex) {
         $this->RenderExceptionJSON($ex);
     }
 }
Esempio n. 10
0
 /**
  * @param $name string константа класса Creator
  * @return Button|Checkbox|Combobox|InputImage|Link|Listbox|null|OrderList|Table|Textarea|TextField|TextNode возвращает элемента управления
  */
 public static function getObject($name)
 {
     $obj = new Creator($name);
     return $obj->createObject();
 }
Esempio n. 11
0
 /**
  * @covers Geissler\Converter\Standard\RIS\Creator::create
  * @covers Geissler\Converter\Standard\RIS\Creator::retrieve
  */
 public function testRetrieve()
 {
     $this->assertFalse($this->object->create(new \Geissler\Converter\Model\Entries()));
     $this->assertFalse($this->object->retrieve());
 }
Esempio n. 12
0
    public function shipFrom() : string
    {
        return "from Spain";
    }
}
class DefaultProduct implements IProduct
{
    public function shipFrom() : string
    {
        return "not available";
    }
}
class Creator
{
    public function factoryMethod(int $month)
    {
        if ($month > 4 && $month <= 11) {
            return new ProductA();
        } else {
            if ($month == 1 || $month == 2 || $month == 12) {
                return new ProductB();
            }
        }
        return new DefaultProduct();
    }
}
$creator = new Creator();
for ($i = 1; $i <= 12; ++$i) {
    $product = $creator->factoryMethod($i);
    echo 'Avokados ', $product->shipFrom();
}