public function test_required_images() { $manager = new Pass_File_Manager($this->pass); $this->assertEquals(12, count($manager->required_images_readable())); $manager->generate_file('background.png', ''); $this->assertEquals(11, count($manager->required_images_readable())); }
public function test_manifest() { $manager = new Pass_File_Manager($this->pass); $manager->generate_file('pass.json', $this->pass->pass_json()); $manifest = $this->pass->manifest($manager->files()); $this->assertRegExp('/\\{.*"pass.json":".*\\}/', $manifest); }
public function view() { $manager = new Pass_File_Manager($this->pass); $pass = $this->pass; $this->echo_img = function ($name) use($manager, $pass) { if (file_exists($manager->file_path($name))) { echo \Fuel\Core\Html::img(\Fuel\Core\Uri::create('admin/pass/image/' . $pass->id . '/' . $name), array('alt' => str_replace('.png', '', $name))); } }; $image_names = array('icon.png', '*****@*****.**', 'logo.png', '*****@*****.**', 'background.png', '*****@*****.**', 'footer.png', '*****@*****.**', 'strip.png', '*****@*****.**', 'thumbnail.png', '*****@*****.**'); $this->images = array_map(function ($image_name) use($manager) { if (file_exists($manager->file_path($image_name))) { return array('name' => $image_name, 'sizes' => \Fuel\Core\Image::sizes($manager->file_path($image_name))); } else { return null; } }, array_filter($image_names, function ($image_name) use($manager) { if (file_exists($manager->file_path($image_name))) { return true; } else { return false; } })); $this->upload_image_selection = $manager->required_images_readable(); }
public function action_pkpass($id) { if ($pass = Model_Pass::find($id)) { $manager = new Pass_File_Manager($pass); if (file_exists($manager->pkpass_path())) { $pkpass = file_get_contents($manager->pkpass_path()); return Response::forge($pkpass, 200, array('Content-Type' => 'application/vnd.apple.pkpass')); } else { throw new \Fuel\Core\HttpNotFoundException(); } } else { throw new \Fuel\Core\HttpNotFoundException(); } }
public function generate($cert_password = '') { $manager = new Pass_File_Manager($this); $cert = new Certificate($manager->file_path('certificate.p12'), $cert_password); if (!$manager->generate_file('pass.json', $this->pass_json($cert->pass_type_identifier(), $cert->team_identifier()))) { return $manager->error; } if (!$manager->generate_file('manifest.json', $this->manifest($manager->files()))) { return $manager->error; } if (!($signature = $cert->signature($manager->file_path('manifest.json'), $manager->file_path('signature')))) { return $cert->error; } if (!$manager->generate_file('signature', $signature)) { return $manager->error; } if (!$manager->generate_zip()) { return $manager->error; } return null; }
<th>Action</th> <th></th> </tr> </thead> <tbody> <?php foreach ($passes as $pass) { ?> <tr> <td><?php echo $pass->name; ?> </td> <?php $manager = new Pass_File_Manager($pass); ?> <td><?php echo $manager->pkpass_url(); ?> </td> <td><?php if (file_exists($manager->pkpass_path())) { ?> <?php echo \Fuel\Core\Html::anchor(\Fuel\Core\Uri::create('admin/pass/pkpass/' . $pass->id), $pass->status()); ?> </td> <?php } else { ?>
<?php if (isset($pass)) { $manager = new Pass_File_Manager($pass); if (file_exists($manager->file_path('certificate.p12'))) { ?> <p>File uploaded.</p> <?php } ?> <?php echo Form::open(array('enctype' => 'multipart/form-data')); ?> <fieldset> <div class="clearfix"> <div class="input"> <?php echo \Fuel\Core\Form::file('certificate'); ?> </div> </div> <div class="actions"> <?php echo Form::submit('submit', 'Save', array('class' => 'btn btn-primary')); ?> </div> </fieldset> <?php echo Form::close();