From fd00a4ca9f877fa1b922de82b72617fd7ef6a469 Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Wed, 17 Oct 2018 13:19:03 +0200 Subject: [PATCH 1/6] Working on file uploader --- src/Configuration/Config.php | 5 +- src/Configuration/PathResolver.php | 12 +- src/Content/MediaFactory.php | 56 +++ src/Controller/Async/Uploader.php | 65 +++ src/Controller/Bolt/EditRecordController.php | 7 +- src/Media/Item.php | 60 +++ src/Media/RequestHandler.php | 477 +++++++++++++++++++ templates/finder/_files.twig | 2 +- templates/finder/_uploader.twig | 40 ++ templates/finder/finder.twig | 10 +- 10 files changed, 723 insertions(+), 11 deletions(-) create mode 100644 src/Controller/Async/Uploader.php create mode 100644 src/Media/Item.php create mode 100644 src/Media/RequestHandler.php create mode 100644 templates/finder/_uploader.twig diff --git a/src/Configuration/Config.php b/src/Configuration/Config.php index f6a26cff..0b5bde2c 100644 --- a/src/Configuration/Config.php +++ b/src/Configuration/Config.php @@ -93,11 +93,12 @@ class Config /** * @param string $path - * @param bool $absolute + * @param bool $absolute + * @param mixed $additional * * @return string */ - public function getPath(string $path, bool $absolute = true, string $additional = ''): string + public function getPath(string $path, bool $absolute = true, $additional = null): string { return $this->pathResolver->resolve($path, $absolute, $additional); } diff --git a/src/Configuration/PathResolver.php b/src/Configuration/PathResolver.php index 233b8f7e..9657dfd6 100644 --- a/src/Configuration/PathResolver.php +++ b/src/Configuration/PathResolver.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Bolt\Configuration; +use Exception; use Tightenco\Collect\Support\Collection; use Webmozart\PathUtil\Path; @@ -92,12 +93,13 @@ class PathResolver * - `foo/bar` - A relative path that will be resolved against the root path. * - `/tmp` - An absolute path will be returned as is. * - * @param string $path the path - * @param bool $absolute if the path is relative, resolve it against the root path + * @param string $path the path + * @param bool $absolute if the path is relative, resolve it against the root path + * @param mixed $additional * * @return string */ - public function resolve(string $path, bool $absolute = true, string $additional = ''): string + public function resolve(string $path, bool $absolute = true, $additional = null): string { if (isset($this->paths[$path])) { $path = $this->paths[$path]; @@ -129,8 +131,8 @@ class PathResolver $path = Path::makeAbsolute($path, $this->paths['root']); } - if ($additional !== '') { - $path .= '/' . $additional; + if (!empty($additional)) { + $path .= DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, (array) $additional); } // Make sure we don't have lingering unneeded dir-seperators diff --git a/src/Content/MediaFactory.php b/src/Content/MediaFactory.php index 035d43e3..4b5d7426 100644 --- a/src/Content/MediaFactory.php +++ b/src/Content/MediaFactory.php @@ -7,14 +7,19 @@ declare(strict_types=1); namespace Bolt\Content; +use Bolt\Common\Json; use Bolt\Configuration\Config; use Bolt\Entity\Media; +use Bolt\Media\Item; use Bolt\Repository\MediaRepository; use Carbon\Carbon; +use Cocur\Slugify\Slugify; use Faker\Factory; use PHPExif\Reader\Reader; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Finder\SplFileInfo; +use Webmozart\PathUtil\Path; class MediaFactory { @@ -116,4 +121,55 @@ class MediaFactory return $user; } + + /** + * @param Item $item + * @param $params + * @return Media + */ + public function createFromUpload(Item $item, $params): Media + { + if (Json::test($params)) { + $params = Json::parse($params); + $addedPath = $params['path']; + $area = $params['area']; + } else { + $addedPath = ''; + $area = 'files'; + } + + $targetFilename = $addedPath . DIRECTORY_SEPARATOR . $this->sanitiseFilename($item->getName()); + + $source = $this->config->getPath('cache', true, ['uploads', $item->getId(), $item->getName()]); + $target = $this->config->getPath($area, true, $targetFilename); + + $relPath = Path::getDirectory($targetFilename); + $relName = Path::getFilename($targetFilename); + + // Move the file over + $fileSystem = new Filesystem(); + $fileSystem->rename($source, $target, true); + + $file = new SplFileInfo($target, $relPath, $relName); + + $media = $this->createOrUpdateMedia($file, $area); + + return $media; + } + + /** + * @param string $filename + * @return string + */ + private function sanitiseFilename(string $filename): string + { + $extensionSlug = new Slugify(['regexp' => '/([^a-z0-9]|-)+/']); + $filenameSlug = new Slugify(['lowercase' => false]); + + $extension = $extensionSlug->slugify(Path::getExtension($filename)); + $filename = $filenameSlug->slugify(Path::getFilenameWithoutExtension($filename)); + + return $filename . '.' . $extension; + } + } diff --git a/src/Controller/Async/Uploader.php b/src/Controller/Async/Uploader.php new file mode 100644 index 00000000..5e39d115 --- /dev/null +++ b/src/Controller/Async/Uploader.php @@ -0,0 +1,65 @@ +mediaFactory = $mediaFactory; + $this->requestHandler = $requestHandler; + $this->manager = $manager; + } + + /** + * + * @Route("/async/upload", name="bolt_upload_post", methods={"POST"}) + * + */ + public function upload(Request $request) + { + // Get submitted field data item, will always be one item in case of async upload + $items = $this->requestHandler->loadFilesByField('filepond'); + + // If no items, exit + if (count($items) === 0) { + // Something went wrong, most likely a field name mismatch + http_response_code(400); + return; + } + + $params = $request->request->get('filepond', []); + + foreach($items as $item) { + $media = $this->mediaFactory->createFromUpload($item, current($params)); + dump($media); + + $this->manager->persist($media); + $this->manager->flush(); + } + + // Returns plain text content + header('Content-Type: text/plain'); + + // Remove item from array Response contains uploaded file server id + echo array_shift($items)->getId(); + + return new Response("Finis!"); + } +} \ No newline at end of file diff --git a/src/Controller/Bolt/EditRecordController.php b/src/Controller/Bolt/EditRecordController.php index d791cee4..eebcda2c 100644 --- a/src/Controller/Bolt/EditRecordController.php +++ b/src/Controller/Bolt/EditRecordController.php @@ -37,11 +37,14 @@ class EditRecordController extends BaseController /** * @Route("/edit/{id}", name="bolt_edit_record", methods={"GET"}) * - * @param string $id - * @param Request $request + * @param string $id + * @param Request $request * @param Content|null $content * * @return Response + * @throws \Twig_Error_Loader + * @throws \Twig_Error_Runtime + * @throws \Twig_Error_Syntax */ public function edit(string $id, Request $request, Content $content = null): Response { diff --git a/src/Media/Item.php b/src/Media/Item.php new file mode 100644 index 00000000..75c8021a --- /dev/null +++ b/src/Media/Item.php @@ -0,0 +1,60 @@ +id = isset($id) ? $id : md5( uniqid(self::$item_counter++, true) ); + $this->file = $file; + $this->name = $file['name']; + } + + public function rename($name, $extension = null) { + $info = pathinfo($this->name); + $this->name = $name . '.' . ( isset($extension) ? $extension : $info['extension'] ); + } + + public function getId() { + return $this->id; + } + + public function getFilename() { + return $this->file['tmp_name']; + } + + public function getName() { + return basename($this->name); + } + + public function getNameWithoutExtension() { + $info = pathinfo($this->name); + return $info['filename']; + } + + public function getExtension() { + $info = pathinfo($this->name); + return $info['extension']; + } + + public function getSize() { + return $this->file['size']; + } + + public function getType() { + return $this->file['mime']; + } +} + diff --git a/src/Media/RequestHandler.php b/src/Media/RequestHandler.php new file mode 100644 index 00000000..885402a7 --- /dev/null +++ b/src/Media/RequestHandler.php @@ -0,0 +1,477 @@ +config = $config; + + $this->tmp_dir = $this->config->getPath('cache', true, ['uploads']); + } + + + /** + * @param $str + * @return bool + */ + public function isFileId($str) { + return preg_match($this->file_id_format, $str); + } + + /** + * @param $str + * @return bool + */ + public function isURL($str) { + return filter_var($str, FILTER_VALIDATE_URL); + } + + /** + * Catch all exceptions so we can return a 500 error when the server bugs out + */ + public function catchExceptions() { + set_exception_handler('FilePond\RequestHandler::handleException'); + } + + public function handleException($ex) { + + // write to error log so we can still find out what's up + error_log('Uncaught exception in class="' . get_class($ex) . '" message="' . $ex->getMessage() . '" line="' . $ex->getLine() . '"'); + + // clean up buffer + ob_end_clean(); + + // server error mode go! + http_response_code(500); + } + + private function createItem($file, $id = null) { + return new Item($file, $id); + } + + /** + * @param $fieldName + * @return array + */ + public function loadFilesByField($fieldName) { + + // See if files are posted as JSON string (each file being base64 encoded) + $base64Items = $this->loadBase64FormattedFiles($fieldName); + + // retrieves posted file objects + $fileItems = $this->loadFileObjects($fieldName); + + // retrieves files already on server + $tmpItems = $this->loadFilesFromTemp($fieldName); + + // save newly received files to temp files folder (tmp items already are in that folder) + $this->saveAsTempFiles(array_merge($base64Items, $fileItems)); + + // return items + return array_merge($base64Items, $fileItems, $tmpItems); + } + + private function loadFileObjects($fieldName) { + + $items = []; + + if ( !isset($_FILES[$fieldName]) ) { + return $items; + } + + $FILE = $_FILES[$fieldName]; + + if (is_array($FILE['tmp_name'])) { + + foreach( $FILE['tmp_name'] as $index => $tmpName ) { + + array_push( $items, $this->createItem( array( + 'tmp_name' => $FILE['tmp_name'][$index], + 'name' => $FILE['name'][$index], + 'size' => $FILE['size'][$index], + 'error' => $FILE['error'][$index], + 'type' => $FILE['type'][$index] + )) ); + + } + + } + else { + array_push( $items, $this->createItem($FILE) ); + } + + return $items; + } + + private function loadBase64FormattedFiles($fieldName) { + + /* + // format: + { + "id": "iuhv2cpsu", + "name": "picture.jpg", + "type": "image/jpeg", + "size": 20636, + "metadata" : {...} + "data": "/9j/4AAQSkZJRgABAQEASABIAA..." + } + */ + + $items = []; + + if ( !isset($_POST[$fieldName] ) ) { + return $items; + } + + // Handle posted files array + $values = $_POST[$fieldName]; + + // Turn values in array if is submitted as single value + if (!is_array($values)) { + $values = isset($values) ? array($values) : array(); + } + + // If files are found, turn base64 strings into actual file objects + foreach ($values as $value) { + + // suppress error messages, we'll just investigate the object later + $obj = @json_decode($value); + + // skip values that failed to be decoded + if (!isset($obj)) { + continue; + } + + // test if this is a file object (matches the object described above) + if (!$this->isEncodedFile($obj)) { + continue; + } + + array_push($items, $this->createItem( $this->createTempFile($obj) ) ); + } + + return $items; + } + + private function isEncodedFile($obj) { + return isset($obj->id) && isset($obj->data) && isset($obj->name) && isset($obj->type) && isset($obj->size); + } + + private function loadFilesFromTemp($fieldName) { + + $items = []; + + if ( !isset($_POST[$fieldName] ) ) { + return $items; + } + + // Handle posted ids array + $values = $_POST[$fieldName]; + + // Turn values in array if is submitted as single value + if (!is_array($values)) { + $values = isset($values) ? array($values) : array(); + } + + // test if value is actually a file id + foreach ($values as $value) { + if ( $this->isFileId($value) ) { + array_push($items, $this->createItem($this->getTempFile($value), $value)); + } + } + + return $items; + + } + + public function save($items, $path = 'uploads' . DIRECTORY_SEPARATOR) { + + // is list of files + if ( is_array($items) ) { + $results = []; + foreach($items as $item) { + array_push($results, $this->saveFile($item, $path)); + } + return $results; + } + + // is single item + return $this->saveFile($items, $path); + } + + /** + * @param $file_id + * @return bool + */ + public function deleteTempFile($file_id) { + return $this->deleteTempDirectory($file_id); + } + + /** + * @param $url + * @return array|bool + */ + public function getRemoteURLData($url) + { + try { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + $content = curl_exec($ch); + if ($content === FALSE) { + throw new Exception(curl_error($ch), curl_errno($ch)); + } + + $type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); + $length = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD); + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); + + curl_close ($ch); + + $success = $code >= 200 && $code < 300; + + return array( + 'code' => $code, + 'content' => $content, + 'type' => $type, + 'length' => $length, + 'success' => $success + ); + + } + catch(Exception $e) { + return null; + } + } + + private function saveAsTempFiles($items) { + foreach($items as $item) { + $this->saveTempFile($item); + } + } + + private function saveTempFile($file) { + + // make sure path name is safe + $path = $this->getSecureTempPath() . $file->getId() . DIRECTORY_SEPARATOR; + + // Creates a secure temporary directory to store the files in + $this->createSecureDirectory($path); + + // get source and target values + $source = $file->getFilename(); + $target = $path . $file->getName(); + + // Move uploaded file to this new secure directory + $result = $this->moveFile($source, $target); + + // Was not saved + if ($result !== true) { return $result; } + + // Make sure file is secure + $this->setSecureFilePermissions($target); + + // temp file stored successfully + return true; + } + + public function getTempFile($fileId) { + + // select all files in directory except .htaccess + foreach(glob($this->getSecureTempPath() . $fileId . DIRECTORY_SEPARATOR . '*.*') as $file) { + + try { + + $handle = fopen($file, 'r'); + $content = fread($handle, filesize($file)); + fclose($handle); + + return array( + 'name' => basename($file), + 'content' => $content, + 'type' => mime_content_type($file), + 'length' => filesize($file) + ); + + } + catch(Exception $e) { + return null; + } + } + + return false; + } + + public function getFile($file, $path) { + + try { + + $filename = $path . DIRECTORY_SEPARATOR . $file; + $handle = fopen($filename, 'r'); + $content = fread($handle, filesize($filename)); + fclose($handle); + + return array( + 'name' => basename($filename), + 'content' => $content, + 'type' => mime_content_type($filename), + 'length' => filesize($filename) + ); + + } + catch(Exception $e) { + return null; + } + + } + + private function saveFile($item, $path) { + + // nope + if (!isset($item)) { + return false; + } + + // if is file id + if (is_string($item)) { + return $this->moveFileById($item, $path); + } + + // is file object + else { + return $this->moveFileById($item->getId(), $path, $item->getName()); + } + + } + + private function moveFileById($fileId, $path, $fileName = null) { + + // select all files in directory except .htaccess + foreach(glob($this->getSecureTempPath() . $fileId . DIRECTORY_SEPARATOR . '*.*') as $file) { + + $source = $file; + $target = $this->getSecurePath($path); + + $this->createDirectory($target); + + rename($source, $target . (isset($fileName) ? basename($fileName) : basename($file))); + } + + // remove directory + $this->deleteTempDirectory($fileId); + + // done! + return true; + } + + private function deleteTempDirectory($id) { + + @array_map('unlink', glob($this->getSecureTempPath() . $id . DIRECTORY_SEPARATOR . '{.,}*', GLOB_BRACE)); + + // remove temp directory + @rmdir($this->getSecureTempPath() . $id); + + } + + private function createTempFile($file) { + + $tmp = tmpfile(); + fwrite($tmp, base64_decode($file->data)); + $meta = stream_get_meta_data($tmp); + $filename = $meta['uri']; + + return array( + 'error' => 0, + 'size' => filesize($filename), + 'type' => $file->type, + 'name' => $file->name, + 'tmp_name' => $filename, + 'tmp' => $tmp + ); + + } + + private function moveFile($source, $target) { + + if (is_uploaded_file($source)) { + return move_uploaded_file($source, $target); + } + else { + $tmp = fopen($source, 'r'); + $result = file_put_contents( $target, fread($tmp, filesize($source) ) ); + fclose($tmp); + return $result; + } + + } + + private function getSecurePath($path) { + return pathinfo($path)['dirname'] . DIRECTORY_SEPARATOR . basename($path) . DIRECTORY_SEPARATOR; + } + + private function getSecureTempPath() { + return $this->getSecurePath($this->tmp_dir); + } + + private function setSecureFilePermissions($target) { + $stat = stat( dirname($target) ); + $perms = $stat['mode'] & 0000666; + @chmod($target, $perms); + } + + private function createDirectory($path) { + if (is_dir($path)) { + return false; + } + mkdir($path, 0755, true); + return true; + } + + private function createSecureDirectory($path) { + + // !! If directory already exists we assume security is handled !! + + // Test if directory already exists and correct + if ($this->createDirectory($path)) { + + // Add .htaccess file for security purposes + $content = '# Don\'t list directory contents +IndexIgnore * +# Disable script execution +AddHandler cgi-script .php .pl .jsp .asp .sh .cgi +Options -ExecCGI -Indexes'; + file_put_contents($path . '.htaccess', $content); + + } + + } + +} + + diff --git a/templates/finder/_files.twig b/templates/finder/_files.twig index 7a121979..0c5b4404 100644 --- a/templates/finder/_files.twig +++ b/templates/finder/_files.twig @@ -24,7 +24,7 @@ {% set dimensions = '' %} {% if extension in imageformats %} - {% set thumbnail = filename|thumbnail(100, 72) %} + {% set thumbnail = filename|thumbnail(width = 100, height = 72, area = area) %} {% set icon = 'fa-image' %} {% set link = path('bolt_media_new', {'area': area, 'file': filename}) %} diff --git a/templates/finder/_uploader.twig b/templates/finder/_uploader.twig new file mode 100644 index 00000000..89ad4d62 --- /dev/null +++ b/templates/finder/_uploader.twig @@ -0,0 +1,40 @@ + + + + + + + + + +
+
File uploader
+
+ +
+
+ + + diff --git a/templates/finder/finder.twig b/templates/finder/finder.twig index 98f06a2e..77c35489 100644 --- a/templates/finder/finder.twig +++ b/templates/finder/finder.twig @@ -18,13 +18,16 @@ {% block aside %} -
+
Meta information
+ {% include '@bolt/finder/_uploader.twig' %} + + {% endblock aside %} @@ -32,6 +35,11 @@ {{ parent() }} + {% endblock %} From 761467dcbba56d72063dd4b68ff1f15f14de2ad4 Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Wed, 17 Oct 2018 16:48:43 +0200 Subject: [PATCH 2/6] Bit of a sidetrack: Made JS for slug field work. --- templates/editcontent/fields/slug.twig | 13 +++-- templates/editcontent/javascripts/slug.twig | 64 +++++++++++++++++++++ 2 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 templates/editcontent/javascripts/slug.twig diff --git a/templates/editcontent/fields/slug.twig b/templates/editcontent/fields/slug.twig index f43cd015..b81630ff 100644 --- a/templates/editcontent/fields/slug.twig +++ b/templates/editcontent/fields/slug.twig @@ -7,18 +7,19 @@ {{ field.slugPrefix }}
-
- diff --git a/templates/editcontent/javascripts/slug.twig b/templates/editcontent/javascripts/slug.twig new file mode 100644 index 00000000..e0ab1508 --- /dev/null +++ b/templates/editcontent/javascripts/slug.twig @@ -0,0 +1,64 @@ +{% extends '@bolt/editcontent/javascripts/_base.twig' %} + +{% block javascripts %} + +{% endblock %} \ No newline at end of file From 0ba0c16b890144e79ec344f9b23d3a144088276f Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Wed, 17 Oct 2018 22:15:57 +0200 Subject: [PATCH 3/6] Working on uploaders. --- assets/js/bolt.js | 2 + assets/scss/_bootstrap-overrides.scss | 10 +++ config/bolt/contenttypes.yml | 67 +++++++++---------- src/Controller/Async/Uploader.php | 10 +-- templates/_base/layout.twig | 2 + templates/editcontent/fields/image.twig | 62 ++++++++++++++--- templates/editcontent/javascripts/image.twig | 35 ++++++++++ .../javascripts/image_include.twig | 5 ++ .../stylesheets/image_include.twig | 2 + 9 files changed, 144 insertions(+), 51 deletions(-) create mode 100644 templates/editcontent/javascripts/image.twig create mode 100644 templates/editcontent/javascripts/image_include.twig create mode 100644 templates/editcontent/stylesheets/image_include.twig diff --git a/assets/js/bolt.js b/assets/js/bolt.js index a3b1f447..bfdfeb04 100644 --- a/assets/js/bolt.js +++ b/assets/js/bolt.js @@ -43,4 +43,6 @@ $(document).ready(function() { // $(".ui.calendar").calendar({ // ampm: false // }); + + var lightbox = $('a.lightbox').simpleLightbox(); }); diff --git a/assets/scss/_bootstrap-overrides.scss b/assets/scss/_bootstrap-overrides.scss index 5ceaac53..3826e2ac 100644 --- a/assets/scss/_bootstrap-overrides.scss +++ b/assets/scss/_bootstrap-overrides.scss @@ -25,3 +25,13 @@ font-size: 0.9rem; } } + + +.sl-overlay { + background: #000; + opacity: 0.85; +} + +.sl-close { + color: #FFF; +} \ No newline at end of file diff --git a/config/bolt/contenttypes.yml b/config/bolt/contenttypes.yml index d1c574ce..253612bc 100644 --- a/config/bolt/contenttypes.yml +++ b/config/bolt/contenttypes.yml @@ -261,41 +261,40 @@ blocks: slug: type: slug uses: [ title ] - selectfield: - type: select - values: [ foo, bar, baz ] - selectfieldd: - type: select - values: - foo: "Fooo" - bar: Bario - baz: Bazz - multiselect: - type: select - values: [ A-tuin, Donatello, Rafael, Leonardo, Michelangelo, Koopa, Squirtle ] - multiple: false - postfix: "Select your favourite turtle(s)." - multiselect2: - type: select - values: [ A-tuin, Donatello, Rafael, Leonardo, Michelangelo, Koopa, Squirtle ] - multiple: true - required: true - postfix: "Select your favourite turtle(s)." - - -# content: -# type: html -# height: 150px -# contentlink: -# type: text -# label: Link -# placeholder: 'contenttype/slug or http://example.org/' -# postfix: "Use this to add a link for this Block. This could either be an 'internal' link like page/about, if you use a contenttype/slug combination. Otherwise use a proper URL, like `http://example.org`." -# image: -# type: image -# attrib: title -# extensions: [ gif, jpg, png ] +# selectfield: +# type: select +# values: [ foo, bar, baz ] +# selectfieldd: +# type: select +# values: +# foo: "Fooo" +# bar: Bario +# baz: Bazz +# multiselect: +# type: select +# values: [ A-tuin, Donatello, Rafael, Leonardo, Michelangelo, Koopa, Squirtle ] +# multiple: false +# postfix: "Select your favourite turtle(s)." +# +# multiselect2: +# type: select +# values: [ A-tuin, Donatello, Rafael, Leonardo, Michelangelo, Koopa, Squirtle ] +# multiple: true +# required: true +# postfix: "Select your favourite turtle(s)." + content: + type: html + height: 150px + contentlink: + type: text + label: Link + placeholder: 'contenttype/slug or http://example.org/' + postfix: "Use this to add a link for this Block. This could either be an 'internal' link like page/about, if you use a contenttype/slug combination. Otherwise use a proper URL, like `http://example.org`." + image: + type: image + attrib: title + extensions: [ gif, jpg, png ] show_on_dashboard: true viewless: true default_status: published diff --git a/src/Controller/Async/Uploader.php b/src/Controller/Async/Uploader.php index 5e39d115..f7de7401 100644 --- a/src/Controller/Async/Uploader.php +++ b/src/Controller/Async/Uploader.php @@ -48,18 +48,10 @@ class Uploader foreach($items as $item) { $media = $this->mediaFactory->createFromUpload($item, current($params)); - dump($media); - $this->manager->persist($media); $this->manager->flush(); } - // Returns plain text content - header('Content-Type: text/plain'); - - // Remove item from array Response contains uploaded file server id - echo array_shift($items)->getId(); - - return new Response("Finis!"); + return new Response($media->getPath() . $media->getFilename()); } } \ No newline at end of file diff --git a/templates/_base/layout.twig b/templates/_base/layout.twig index 2e187f49..31bf6f67 100644 --- a/templates/_base/layout.twig +++ b/templates/_base/layout.twig @@ -10,6 +10,7 @@ + {% endblock %} @@ -48,6 +49,7 @@ + {% endblock %} diff --git a/templates/editcontent/fields/image.twig b/templates/editcontent/fields/image.twig index 23763068..587fe450 100644 --- a/templates/editcontent/fields/image.twig +++ b/templates/editcontent/fields/image.twig @@ -3,13 +3,59 @@ {% block field %} -
- - +
+
+ +
+
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + + +
+
+ +
+
-
- - -
-
+ + {% endblock %} diff --git a/templates/editcontent/javascripts/image.twig b/templates/editcontent/javascripts/image.twig new file mode 100644 index 00000000..f354d590 --- /dev/null +++ b/templates/editcontent/javascripts/image.twig @@ -0,0 +1,35 @@ +{% extends '@bolt/editcontent/javascripts/_base.twig' %} + + +{% block javascripts %} + +{% endblock %} diff --git a/templates/editcontent/javascripts/image_include.twig b/templates/editcontent/javascripts/image_include.twig new file mode 100644 index 00000000..e9e59406 --- /dev/null +++ b/templates/editcontent/javascripts/image_include.twig @@ -0,0 +1,5 @@ + + + + + diff --git a/templates/editcontent/stylesheets/image_include.twig b/templates/editcontent/stylesheets/image_include.twig new file mode 100644 index 00000000..d92b4166 --- /dev/null +++ b/templates/editcontent/stylesheets/image_include.twig @@ -0,0 +1,2 @@ + + From a4ca721bdc2e2ed09f6b94595402bba89785d417 Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Wed, 17 Oct 2018 22:21:18 +0200 Subject: [PATCH 4/6] Tweaking lightbox --- templates/editcontent/fields/image.twig | 2 +- templates/finder/_files.twig | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/templates/editcontent/fields/image.twig b/templates/editcontent/fields/image.twig index 587fe450..eadf885c 100644 --- a/templates/editcontent/fields/image.twig +++ b/templates/editcontent/fields/image.twig @@ -36,7 +36,7 @@ diff --git a/templates/finder/_files.twig b/templates/finder/_files.twig index 0c5b4404..12b8651e 100644 --- a/templates/finder/_files.twig +++ b/templates/finder/_files.twig @@ -47,7 +47,9 @@ {%- if thumbnail -%} + + {%- else -%}   {%- endif -%} From 83cd457d355aaa332b550dec723a02af3162c30a Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Thu, 18 Oct 2018 14:46:21 +0200 Subject: [PATCH 5/6] First version of Filepond uploader --- public/assets/bolt.css | 2 +- public/assets/bolt.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/assets/bolt.css b/public/assets/bolt.css index 137277ca..0b079d31 100644 --- a/public/assets/bolt.css +++ b/public/assets/bolt.css @@ -1 +1 @@ -nav.flex-column{background-color:#345}nav.flex-column hr{border-top-width:0;border-bottom:1px solid hsla(0,0%,100%,.2);margin:0}nav.flex-column .logo{color:#fff;background:#345;text-align:center;margin:1rem}nav.flex-column .logo h2{font-size:36px}nav.flex-column .nav-item{color:#ddd!important;padding-top:.6rem;padding-bottom:.6rem;text-align:left}nav.flex-column .nav-item a{color:#ddd!important}nav.flex-column .nav-item .fa-stack{height:2.3em;margin-right:.5rem}nav.flex-column .nav-item .fa-stack i:last-child{color:#444}nav.flex-column .nav-item>i.dropdown.icon{margin-top:10px}nav.flex-column .nav-item.separator{padding:1rem 1rem .5rem;color:hsla(0,0%,78%,.5)!important}nav.flex-column .nav-item.separator .fas{padding:0 1.1rem 0 .65rem}nav.flex-column .nav-item.active,nav.flex-column .nav-item.current{background-color:#41647f!important;color:#fff!important}nav.flex-column .nav-item.active>a,nav.flex-column .nav-item.current>a{color:#fff!important}nav.flex-column .dropdown-menu{transform:translateX(140px)!important;padding-bottom:0}nav.flex-column .dropdown-menu a{padding:.25rem .75rem}nav.flex-column .dropdown-menu .btn-group{width:100%;background-color:#eee;border-top:1px solid #ddd;margin-top:.5rem;display:flex}nav.flex-column .dropdown-menu .btn{background-color:#eee;border:0;flex:1;padding:.5rem 0}nav.flex-column .dropdown-menu .btn:hover{background-color:#ccc;border:0}.nav.btn-toolbar{margin:.5rem 1rem 0 3rem}.nav.btn-toolbar .nav-item{flex-grow:0;margin-right:.6rem}.nav.btn-toolbar .nav-item.topbar-title{font-family:Source Sans Pro,serif;font-size:22px;color:#222;overflow:hidden;text-overflow:ellipsis;text-align:left;display:-webkit-box;-webkit-line-clamp:1;-webkit-box-orient:vertical;flex-grow:1}.nav.btn-toolbar .btn-light{background-color:#eee;border:1px solid #d8d8d8}.status-published{color:#7fa800}.status-held{color:#ca2300}.status-timed{color:#a80}.status-draft{color:#0569e2}.card ul{padding-left:1.2rem}body,html{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;font-size:13px;line-height:1.5;height:100%;margin:0;padding:0}@media only screen and (min-width:1025px){body,html{font-size:14px}}@media only screen and (min-width:1281px){body,html{font-size:15px}}body{background:#f7f7f7}h1,h2,h3,h4,h5,h6{font-family:Source Sans Pro,serif;font-weight:400}h1{font-weight:700;font-size:2.5rem}h2{font-size:2rem;line-height:4rem}h3{font-size:1.75rem}h4{font-size:1.5rem}h5{font-size:1.25rem}h6{font-size:1rem}.wrapper{display:grid;width:100vw;height:100vh;grid-template-areas:"topbar" "sidebar" "content" "sidebar2" "footer"}@media only screen and (min-width:600px){.wrapper{grid-template-areas:"sidebar topbar topbar" "sidebar content aside" "sidebar footer footer"}.wrapper,.wrapper.has-widecontent{grid-template-columns:12.6rem auto 21rem;grid-template-rows:3.6rem auto 2rem}.wrapper.has-widecontent{grid-template-areas:"sidebar topbar topbar" "sidebar content content" "sidebar footer footer"}}#sidebar{grid-area:sidebar;background-color:#345;border-right:1px solid #233}header{grid-area:topbar;background-color:#fff;border-bottom:1px solid #ddd}#content,#vuecontent,#widecontent{grid-area:content;padding:2rem 3rem}#widecontent+aside{display:none}footer{grid-area:footer}aside{grid-area:aside;padding:2rem 2rem 2rem 0}.ui.basic.table{background-color:#fff!important}.ui.basic.table th{background-color:#f8f8f8}.ui.basic.table td{padding:.7em .4em}#editcontent input.large{font-size:140%;height:auto}#editcontent input[readonly]{background-color:#f2f2f2;color:#888}#editcontent .input-group-append .btn{font-weight:400;font-size:.9rem}.imageholder{width:100%;border-radius:5px;border:1px solid #ddd;background-color:#fff}.imageholder img{max-width:100%;display:block;margin:auto;border-radius:4px}.selectize-input>*{font-size:1rem;line-height:1.5rem}.clip-overflow{display:block;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis;max-height:4.5rem}td.listing-excerpt{color:#333}td.listing-meta{font-size:.9rem;line-height:1.5rem}td.listing-meta span{color:#666;display:inline-block;white-space:nowrap}td.listing-thumb img{display:block;width:6.25rem;height:4.5rem}td.listing-actions{white-space:nowrap}td.listing-actions .btn-light{background-color:#e0e0e0;border:1px solid #d8d8d8;color:#444}td.listing-actions .show>.btn-light.dropdown-toggle{background-color:#ccc;border:1px solid #b8b8b8;color:#444}.selectize-dropdown-content,.selectize-input{font-size:1rem} \ No newline at end of file +nav.flex-column{background-color:#345}nav.flex-column hr{border-top-width:0;border-bottom:1px solid hsla(0,0%,100%,.2);margin:0}nav.flex-column .logo{color:#fff;background:#345;text-align:center;margin:1rem}nav.flex-column .logo h2{font-size:36px}nav.flex-column .nav-item{color:#ddd!important;padding-top:.6rem;padding-bottom:.6rem;text-align:left}nav.flex-column .nav-item a{color:#ddd!important}nav.flex-column .nav-item .fa-stack{height:2.3em;margin-right:.5rem}nav.flex-column .nav-item .fa-stack i:last-child{color:#444}nav.flex-column .nav-item>i.dropdown.icon{margin-top:10px}nav.flex-column .nav-item.separator{padding:1rem 1rem .5rem;color:hsla(0,0%,78%,.5)!important}nav.flex-column .nav-item.separator .fas{padding:0 1.1rem 0 .65rem}nav.flex-column .nav-item.active,nav.flex-column .nav-item.current{background-color:#41647f!important;color:#fff!important}nav.flex-column .nav-item.active>a,nav.flex-column .nav-item.current>a{color:#fff!important}nav.flex-column .dropdown-menu{transform:translateX(140px)!important;padding-bottom:0}nav.flex-column .dropdown-menu a{padding:.25rem .75rem}nav.flex-column .dropdown-menu .btn-group{width:100%;background-color:#eee;border-top:1px solid #ddd;margin-top:.5rem;display:flex}nav.flex-column .dropdown-menu .btn{background-color:#eee;border:0;flex:1;padding:.5rem 0}nav.flex-column .dropdown-menu .btn:hover{background-color:#ccc;border:0}.nav.btn-toolbar{margin:.5rem 1rem 0 3rem}.nav.btn-toolbar .nav-item{flex-grow:0;margin-right:.6rem}.nav.btn-toolbar .nav-item.topbar-title{font-family:Source Sans Pro,serif;font-size:22px;color:#222;overflow:hidden;text-overflow:ellipsis;text-align:left;display:-webkit-box;-webkit-line-clamp:1;-webkit-box-orient:vertical;flex-grow:1}.nav.btn-toolbar .btn-light{background-color:#eee;border:1px solid #d8d8d8}.status-published{color:#7fa800}.status-held{color:#ca2300}.status-timed{color:#a80}.status-draft{color:#0569e2}.card ul{padding-left:1.2rem}body,html{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;font-size:13px;line-height:1.5;height:100%;margin:0;padding:0}@media only screen and (min-width:1025px){body,html{font-size:14px}}@media only screen and (min-width:1281px){body,html{font-size:15px}}body{background:#f7f7f7}h1,h2,h3,h4,h5,h6{font-family:Source Sans Pro,serif;font-weight:400}h1{font-weight:700;font-size:2.5rem}h2{font-size:2rem;line-height:4rem}h3{font-size:1.75rem}h4{font-size:1.5rem}h5{font-size:1.25rem}h6{font-size:1rem}.wrapper{display:grid;width:100vw;height:100vh;grid-template-areas:"topbar" "sidebar" "content" "sidebar2" "footer"}@media only screen and (min-width:600px){.wrapper{grid-template-areas:"sidebar topbar topbar" "sidebar content aside" "sidebar footer footer"}.wrapper,.wrapper.has-widecontent{grid-template-columns:12.6rem auto 21rem;grid-template-rows:3.6rem auto 2rem}.wrapper.has-widecontent{grid-template-areas:"sidebar topbar topbar" "sidebar content content" "sidebar footer footer"}}#sidebar{grid-area:sidebar;background-color:#345;border-right:1px solid #233}header{grid-area:topbar;background-color:#fff;border-bottom:1px solid #ddd}#content,#vuecontent,#widecontent{grid-area:content;padding:2rem 3rem}#widecontent+aside{display:none}footer{grid-area:footer}aside{grid-area:aside;padding:2rem 2rem 2rem 0}.ui.basic.table{background-color:#fff!important}.ui.basic.table th{background-color:#f8f8f8}.ui.basic.table td{padding:.7em .4em}#editcontent input.large{font-size:140%;height:auto}#editcontent input[readonly]{background-color:#f2f2f2;color:#888}#editcontent .input-group-append .btn{font-weight:400;font-size:.9rem}.sl-overlay{background:#000;opacity:.85}.sl-close{color:#fff}.imageholder{width:100%;border-radius:5px;border:1px solid #ddd;background-color:#fff}.imageholder img{max-width:100%;display:block;margin:auto;border-radius:4px}.selectize-input>*{font-size:1rem;line-height:1.5rem}.clip-overflow{display:block;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis;max-height:4.5rem}td.listing-excerpt{color:#333}td.listing-meta{font-size:.9rem;line-height:1.5rem}td.listing-meta span{color:#666;display:inline-block;white-space:nowrap}td.listing-thumb img{display:block;width:6.25rem;height:4.5rem}td.listing-actions{white-space:nowrap}td.listing-actions .btn-light{background-color:#e0e0e0;border:1px solid #d8d8d8;color:#444}td.listing-actions .show>.btn-light.dropdown-toggle{background-color:#ccc;border:1px solid #b8b8b8;color:#444}.selectize-dropdown-content,.selectize-input{font-size:1rem} \ No newline at end of file diff --git a/public/assets/bolt.js b/public/assets/bolt.js index c37036b9..d97d42e9 100644 --- a/public/assets/bolt.js +++ b/public/assets/bolt.js @@ -1,4 +1,4 @@ -!function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/assets/",t(t.s="2qrm")}({"/ocq":function(e,t,n){"use strict";function r(e,t){}function o(e){return Object.prototype.toString.call(e).indexOf("Error")>-1}function i(e,t){switch(typeof t){case"undefined":return;case"object":return t;case"function":return t(e);case"boolean":return t?e.params:void 0}}function a(e,t){for(var n in t)e[n]=t[n];return e}function s(e,t,n){void 0===t&&(t={});var r,o=n||u;try{r=o(e||"")}catch(e){r={}}for(var i in t)r[i]=t[i];return r}function u(e){var t={};return(e=e.trim().replace(/^(\?|#|&)/,""))?(e.split("&").forEach(function(e){var n=e.replace(/\+/g," ").split("="),r=He(n.shift()),o=n.length>0?He(n.join("=")):null;void 0===t[r]?t[r]=o:Array.isArray(t[r])?t[r].push(o):t[r]=[t[r],o]}),t):t}function c(e){var t=e?Object.keys(e).map(function(t){var n=e[t];if(void 0===n)return"";if(null===n)return qe(t);if(Array.isArray(n)){var r=[];return n.forEach(function(e){void 0!==e&&(null===e?r.push(qe(t)):r.push(qe(t)+"="+qe(e)))}),r.join("&")}return qe(t)+"="+qe(n)}).filter(function(e){return e.length>0}).join("&"):null;return t?"?"+t:""}function l(e,t,n,r){var o=r&&r.options.stringifyQuery,i=t.query||{};try{i=f(i)}catch(e){}var a={name:t.name||e&&e.name,meta:e&&e.meta||{},path:t.path||"/",hash:t.hash||"",query:i,params:t.params||{},fullPath:d(t,o),matched:e?p(e):[]};return n&&(a.redirectedFrom=d(n,o)),Object.freeze(a)}function f(e){if(Array.isArray(e))return e.map(f);if(e&&"object"==typeof e){var t={};for(var n in e)t[n]=f(e[n]);return t}return e}function p(e){for(var t=[];e;)t.unshift(e),e=e.parent;return t}function d(e,t){var n=e.path,r=e.query;void 0===r&&(r={});var o=e.hash;void 0===o&&(o="");var i=t||c;return(n||"/")+i(r)+o}function h(e,t){return t===Be?e===t:!!t&&(e.path&&t.path?e.path.replace(Fe,"")===t.path.replace(Fe,"")&&e.hash===t.hash&&v(e.query,t.query):!(!e.name||!t.name)&&(e.name===t.name&&e.hash===t.hash&&v(e.query,t.query)&&v(e.params,t.params)))}function v(e,t){if(void 0===e&&(e={}),void 0===t&&(t={}),!e||!t)return e===t;var n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(function(n){var r=e[n],o=t[n];return"object"==typeof r&&"object"==typeof o?v(r,o):String(r)===String(o)})}function m(e,t){return 0===e.path.replace(Fe,"/").indexOf(t.path.replace(Fe,"/"))&&(!t.hash||e.hash===t.hash)&&y(e.query,t.query)}function y(e,t){for(var n in t)if(!(n in e))return!1;return!0}function g(e){if(!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey||e.defaultPrevented||void 0!==e.button&&0!==e.button)){if(e.currentTarget&&e.currentTarget.getAttribute){if(/\b_blank\b/i.test(e.currentTarget.getAttribute("target")))return}return e.preventDefault&&e.preventDefault(),!0}}function b(e){if(e)for(var t,n=0;n=0&&(t=e.slice(r),e=e.slice(0,r));var o=e.indexOf("?");return o>=0&&(n=e.slice(o+1),e=e.slice(0,o)),{path:e,query:n,hash:t}}function C(e){return e.replace(/\/\//g,"/")}function T(e,t){for(var n,r=[],o=0,i=0,a="",s=t&&t.delimiter||"/";null!=(n=Ze.exec(e));){var u=n[0],c=n[1],l=n.index;if(a+=e.slice(i,l),i=l+u.length,c)a+=c[1];else{var f=e[i],p=n[2],d=n[3],h=n[4],v=n[5],m=n[6],y=n[7];a&&(r.push(a),a="");var g=null!=p&&null!=f&&f!==p,b="+"===m||"*"===m,x="?"===m||"*"===m,w=n[2]||s,_=h||v;r.push({name:d||o++,prefix:p||"",delimiter:w,optional:x,repeat:b,partial:g,asterisk:!!y,pattern:_?O(_):y?".*":"[^"+$(w)+"]+?"})}}return i-1&&(o.params[p]=n.params[p]);if(s)return o.path=M(s.path,o.params,'named route "'+i+'"'),a(s,o,r)}else if(o.path){o.params={};for(var d=0;d=e.length?n():e[o]?t(e[o],function(){r(o+1)}):r(o+1)};r(0)}function le(e){return function(t,n,r){var i=!1,a=0,s=null;fe(e,function(e,t,n,u){if("function"==typeof e&&void 0===e.cid){i=!0,a++;var c,l=he(function(t){de(t)&&(t=t.default),e.resolved="function"==typeof t?t:De.extend(t),n.components[u]=t,--a<=0&&r()}),f=he(function(e){var t="Failed to resolve async component "+u+": "+e;s||(s=o(e)?e:new Error(t),r(s))});try{c=e(l,f)}catch(e){f(e)}if(c)if("function"==typeof c.then)c.then(l,f);else{var p=c.component;p&&"function"==typeof p.then&&p.then(l,f)}}}),i||r()}}function fe(e,t){return pe(e.map(function(e){return Object.keys(e.components).map(function(n){return t(e.components[n],e.instances[n],e,n)})}))}function pe(e){return Array.prototype.concat.apply([],e)}function de(e){return e.__esModule||it&&"Module"===e[Symbol.toStringTag]}function he(e){var t=!1;return function(){for(var n=[],r=arguments.length;r--;)n[r]=arguments[r];if(!t)return t=!0,e.apply(this,n)}}function ve(e){if(!e)if(Ve){var t=document.querySelector("base");e=t&&t.getAttribute("href")||"/",e=e.replace(/^https?:\/\/[^\/]+/,"")}else e="/";return"/"!==e.charAt(0)&&(e="/"+e),e.replace(/\/$/,"")}function me(e,t){var n,r=Math.max(e.length,t.length);for(n=0;n=0?t.slice(0,n):t)+"#"+e}function Oe(e){nt?se($e(e)):window.location.hash=e}function je(e){nt?ue($e(e)):window.location.replace($e(e))}function Ne(e,t){return e.push(t),function(){var n=e.indexOf(t);n>-1&&e.splice(n,1)}}function Le(e,t,n){var r="hash"===n?"#"+t:t;return e?C(e+"/"+r):r}var De,Re={name:"router-view",functional:!0,props:{name:{type:String,default:"default"}},render:function(e,t){var n=t.props,r=t.children,o=t.parent,s=t.data;s.routerView=!0;for(var u=o.$createElement,c=n.name,l=o.$route,f=o._routerViewCache||(o._routerViewCache={}),p=0,d=!1;o&&o._routerRoot!==o;)o.$vnode&&o.$vnode.data.routerView&&p++,o._inactive&&(d=!0),o=o.$parent;if(s.routerViewDepth=p,d)return u(f[c],s,r);var h=l.matched[p];if(!h)return f[c]=null,u();var v=f[c]=h.components[c];s.registerRouteInstance=function(e,t){var n=h.instances[c];(t&&n!==e||!t&&n===e)&&(h.instances[c]=t)},(s.hook||(s.hook={})).prepatch=function(e,t){h.instances[c]=t.componentInstance};var m=s.props=i(l,h.props&&h.props[c]);if(m){m=s.props=a({},m);var y=s.attrs=s.attrs||{};for(var g in m)v.props&&g in v.props||(y[g]=m[g],delete m[g])}return u(v,s,r)}},Pe=/[!'()*]/g,Ie=function(e){return"%"+e.charCodeAt(0).toString(16)},Me=/%2C/g,qe=function(e){return encodeURIComponent(e).replace(Pe,Ie).replace(Me,",")},He=decodeURIComponent,Fe=/\/?$/,Be=l(null,{path:"/"}),Ue=[String,Object],We=[String,Array],ze={name:"router-link",props:{to:{type:Ue,required:!0},tag:{type:String,default:"a"},exact:Boolean,append:Boolean,replace:Boolean,activeClass:String,exactActiveClass:String,event:{type:We,default:"click"}},render:function(e){var t=this,n=this.$router,r=this.$route,o=n.resolve(this.to,r,this.append),i=o.location,a=o.route,s=o.href,u={},c=n.options.linkActiveClass,f=n.options.linkExactActiveClass,p=null==c?"router-link-active":c,d=null==f?"router-link-exact-active":f,v=null==this.activeClass?p:this.activeClass,y=null==this.exactActiveClass?d:this.exactActiveClass,x=i.path?l(null,i,null,n):a;u[y]=h(r,x),u[v]=this.exact?u[y]:m(r,x);var w=function(e){g(e)&&(t.replace?n.replace(i):n.push(i))},_={click:g};Array.isArray(this.event)?this.event.forEach(function(e){_[e]=w}):_[this.event]=w;var C={class:u};if("a"===this.tag)C.on=_,C.attrs={href:s};else{var T=b(this.$slots.default);if(T){T.isStatic=!1;var k=De.util.extend;(T.data=k({},T.data)).on=_;(T.data.attrs=k({},T.data.attrs)).href=s}else C.on=_}return e(this.tag,C,this.$slots.default)}},Ve="undefined"!=typeof window,Ge=Array.isArray||function(e){return"[object Array]"==Object.prototype.toString.call(e)},Xe=I,Je=T,Ke=k,Ye=E,Qe=P,Ze=new RegExp(["(\\\\.)","([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))"].join("|"),"g");Xe.parse=Je,Xe.compile=Ke,Xe.tokensToFunction=Ye,Xe.tokensToRegExp=Qe;var et=Object.create(null),tt=Object.create(null),nt=Ve&&function(){var e=window.navigator.userAgent;return(-1===e.indexOf("Android 2.")&&-1===e.indexOf("Android 4.0")||-1===e.indexOf("Mobile Safari")||-1!==e.indexOf("Chrome")||-1!==e.indexOf("Windows Phone"))&&(window.history&&"pushState"in window.history)}(),rt=Ve&&window.performance&&window.performance.now?window.performance:Date,ot=oe(),it="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag,at=function(e,t){this.router=e,this.base=ve(t),this.current=Be,this.pending=null,this.ready=!1,this.readyCbs=[],this.readyErrorCbs=[],this.errorCbs=[]};at.prototype.listen=function(e){this.cb=e},at.prototype.onReady=function(e,t){this.ready?e():(this.readyCbs.push(e),t&&this.readyErrorCbs.push(t))},at.prototype.onError=function(e){this.errorCbs.push(e)},at.prototype.transitionTo=function(e,t,n){var r=this,o=this.router.match(e,this.current);this.confirmTransition(o,function(){r.updateRoute(o),t&&t(o),r.ensureURL(),r.ready||(r.ready=!0,r.readyCbs.forEach(function(e){e(o)}))},function(e){n&&n(e),e&&!r.ready&&(r.ready=!0,r.readyErrorCbs.forEach(function(t){t(e)}))})},at.prototype.confirmTransition=function(e,t,n){var i=this,a=this.current,s=function(e){o(e)&&(i.errorCbs.length?i.errorCbs.forEach(function(t){t(e)}):(r(!1,"uncaught error during route navigation:"),console.error(e))),n&&n(e)};if(h(e,a)&&e.matched.length===a.matched.length)return this.ensureURL(),s();var u=me(this.current.matched,e.matched),c=u.updated,l=u.deactivated,f=u.activated,p=[].concat(be(l),this.router.beforeHooks,xe(c),f.map(function(e){return e.beforeEnter}),le(f));this.pending=e;var d=function(t,n){if(i.pending!==e)return s();try{t(e,a,function(e){!1===e||o(e)?(i.ensureURL(!0),s(e)):"string"==typeof e||"object"==typeof e&&("string"==typeof e.path||"string"==typeof e.name)?(s(),"object"==typeof e&&e.replace?i.replace(e):i.push(e)):n(e)})}catch(e){s(e)}};ce(p,d,function(){var n=[];ce(_e(f,n,function(){return i.current===e}).concat(i.router.resolveHooks),d,function(){if(i.pending!==e)return s();i.pending=null,t(e),i.router.app&&i.router.app.$nextTick(function(){n.forEach(function(e){e()})})})})},at.prototype.updateRoute=function(e){var t=this.current;this.current=e,this.cb&&this.cb(e),this.router.afterHooks.forEach(function(n){n&&n(e,t)})};var st=function(e){function t(t,n){var r=this;e.call(this,t,n);var o=t.options.scrollBehavior;o&&X();var i=ke(this.base);window.addEventListener("popstate",function(e){var n=r.current,a=ke(r.base);r.current===Be&&a===i||r.transitionTo(a,function(e){o&&J(t,e,n,!0)})})}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.go=function(e){window.history.go(e)},t.prototype.push=function(e,t,n){var r=this,o=this,i=o.current;this.transitionTo(e,function(e){se(C(r.base+e.fullPath)),J(r.router,e,i,!1),t&&t(e)},n)},t.prototype.replace=function(e,t,n){var r=this,o=this,i=o.current;this.transitionTo(e,function(e){ue(C(r.base+e.fullPath)),J(r.router,e,i,!1),t&&t(e)},n)},t.prototype.ensureURL=function(e){if(ke(this.base)!==this.current.fullPath){var t=C(this.base+this.current.fullPath);e?se(t):ue(t)}},t.prototype.getCurrentLocation=function(){return ke(this.base)},t}(at),ut=function(e){function t(t,n,r){e.call(this,t,n),r&&Ae(this.base)||Se()}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.setupListeners=function(){var e=this,t=this.router,n=t.options.scrollBehavior,r=nt&&n;r&&X(),window.addEventListener(nt?"popstate":"hashchange",function(){var t=e.current;Se()&&e.transitionTo(Ee(),function(n){r&&J(e.router,n,t,!0),nt||je(n.fullPath)})})},t.prototype.push=function(e,t,n){var r=this,o=this,i=o.current;this.transitionTo(e,function(e){Oe(e.fullPath),J(r.router,e,i,!1),t&&t(e)},n)},t.prototype.replace=function(e,t,n){var r=this,o=this,i=o.current;this.transitionTo(e,function(e){je(e.fullPath),J(r.router,e,i,!1),t&&t(e)},n)},t.prototype.go=function(e){window.history.go(e)},t.prototype.ensureURL=function(e){var t=this.current.fullPath;Ee()!==t&&(e?Oe(t):je(t))},t.prototype.getCurrentLocation=function(){return Ee()},t}(at),ct=function(e){function t(t,n){e.call(this,t,n),this.stack=[],this.index=-1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.push=function(e,t,n){var r=this;this.transitionTo(e,function(e){r.stack=r.stack.slice(0,r.index+1).concat(e),r.index++,t&&t(e)},n)},t.prototype.replace=function(e,t,n){var r=this;this.transitionTo(e,function(e){r.stack=r.stack.slice(0,r.index).concat(e),t&&t(e)},n)},t.prototype.go=function(e){var t=this,n=this.index+e;if(!(n<0||n>=this.stack.length)){var r=this.stack[n];this.confirmTransition(r,function(){t.index=n,t.updateRoute(r)})}},t.prototype.getCurrentLocation=function(){var e=this.stack[this.stack.length-1];return e?e.fullPath:"/"},t.prototype.ensureURL=function(){},t}(at),lt=function(e){void 0===e&&(e={}),this.app=null,this.apps=[],this.options=e,this.beforeHooks=[],this.resolveHooks=[],this.afterHooks=[],this.matcher=z(e.routes||[],this);var t=e.mode||"hash";switch(this.fallback="history"===t&&!nt&&!1!==e.fallback,this.fallback&&(t="hash"),Ve||(t="abstract"),this.mode=t,t){case"history":this.history=new st(this,e.base);break;case"hash":this.history=new ut(this,e.base,this.fallback);break;case"abstract":this.history=new ct(this,e.base)}},ft={currentRoute:{configurable:!0}};lt.prototype.match=function(e,t,n){return this.matcher.match(e,t,n)},ft.currentRoute.get=function(){return this.history&&this.history.current},lt.prototype.init=function(e){var t=this;if(this.apps.push(e),!this.app){this.app=e;var n=this.history;if(n instanceof st)n.transitionTo(n.getCurrentLocation());else if(n instanceof ut){var r=function(){n.setupListeners()};n.transitionTo(n.getCurrentLocation(),r,r)}n.listen(function(e){t.apps.forEach(function(t){t._route=e})})}},lt.prototype.beforeEach=function(e){return Ne(this.beforeHooks,e)},lt.prototype.beforeResolve=function(e){return Ne(this.resolveHooks,e)},lt.prototype.afterEach=function(e){return Ne(this.afterHooks,e)},lt.prototype.onReady=function(e,t){this.history.onReady(e,t)},lt.prototype.onError=function(e){this.history.onError(e)},lt.prototype.push=function(e,t,n){this.history.push(e,t,n)},lt.prototype.replace=function(e,t,n){this.history.replace(e,t,n)},lt.prototype.go=function(e){this.history.go(e)},lt.prototype.back=function(){this.go(-1)},lt.prototype.forward=function(){this.go(1)},lt.prototype.getMatchedComponents=function(e){var t=e?e.matched?e:this.resolve(e).route:this.currentRoute;return t?[].concat.apply([],t.matched.map(function(e){return Object.keys(e.components).map(function(t){return e.components[t]})})):[]},lt.prototype.resolve=function(e,t,n){var r=U(e,t||this.history.current,n,this),o=this.match(r,t),i=o.redirectedFrom||o.fullPath;return{location:r,route:o,href:Le(this.history.base,i,this.mode),normalizedTo:r,resolved:o}},lt.prototype.addRoutes=function(e){this.matcher.addRoutes(e),this.history.current!==Be&&this.history.transitionTo(this.history.getCurrentLocation())},Object.defineProperties(lt.prototype,ft),lt.install=x,lt.version="3.0.1",Ve&&window.Vue&&window.Vue.use(lt),t.a=lt},"0WHz":function(e,t){},"162o":function(e,t,n){(function(e){function r(e,t){this._id=e,this._clearFn=t}var o=void 0!==e&&e||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;t.setTimeout=function(){return new r(i.call(setTimeout,o,arguments),clearTimeout)},t.setInterval=function(){return new r(i.call(setInterval,o,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},r.prototype.unref=r.prototype.ref=function(){},r.prototype.close=function(){this._clearFn.call(o,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},n("mypn"),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(t,n("DuR2"))},"21It":function(e,t,n){"use strict";var r=n("FtD3");e.exports=function(e,t,n){var o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(r("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},"21vO":function(e,t,n){"use strict";var r=n("C97N");t.a={name:"context",props:["type","limit"],components:{},data:function(){return{message:"",loading:!0,records:[]}},created:function(){var e=this;this.records=r.a.getRecords(this.type),r.a.fetchRecords(this.type).then(function(t){e.records=t}).catch(function(e){return console.log(e)}).finally(function(){e.loading=!1})}}},"2qrm":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){var t=n("7+uW"),r=n("PMO0"),o=n("gdD7"),i=n("2wqZ"),a=n("zU0/"),s=n("rLFe"),u=n("K5ga"),c=n("0WHz");n.n(c);t.a.component("sidebar",o.a),t.a.component("topbar",i.default),t.a.component("dashboardnews",a.a),t.a.component("app",u.a),t.a.component("dashboardcontentlist",s.a);var l=n("7t+N");e.$=e.jQuery=l,new t.a({el:"header",router:r.a}),new t.a({el:"#sidebar",router:r.a}),new t.a({el:"#vuecontent",router:r.a}),new t.a({el:"dashboardnews"}),l(document).ready(function(){})}.call(t,n("DuR2"))},"2wqZ":function(e,t,n){"use strict";function r(e){u||n("AJjC")}var o=n("AE6B"),i=n.n(o),a=n("zKrp"),s=n("XyMi"),u=!1,c=r,l=Object(s.a)(i.a,a.a,a.b,!1,c,null,null);l.options.__file="assets/js/Components/Topbar.vue",t.default=l.exports},5850:function(e,t){},"5VQ+":function(e,t,n){"use strict";var r=n("cGG2");e.exports=function(e,t){r.forEach(e,function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])})}},"7+uW":function(e,t,n){"use strict";(function(e,n){function r(e){return void 0===e||null===e}function o(e){return void 0!==e&&null!==e}function i(e){return!0===e}function a(e){return!1===e}function s(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e||"boolean"==typeof e}function u(e){return null!==e&&"object"==typeof e}function c(e){return"[object Object]"===ui.call(e)}function l(e){return"[object RegExp]"===ui.call(e)}function f(e){var t=parseFloat(String(e));return t>=0&&Math.floor(t)===t&&isFinite(e)}function p(e){return null==e?"":"object"==typeof e?JSON.stringify(e,null,2):String(e)}function d(e){var t=parseFloat(e);return isNaN(t)?e:t}function h(e,t){for(var n=Object.create(null),r=e.split(","),o=0;o-1)return e.splice(n,1)}}function m(e,t){return fi.call(e,t)}function y(e){var t=Object.create(null);return function(n){return t[n]||(t[n]=e(n))}}function g(e,t){function n(n){var r=arguments.length;return r?r>1?e.apply(t,arguments):e.call(t,n):e.call(t)}return n._length=e.length,n}function b(e,t){return e.bind(t)}function x(e,t){t=t||0;for(var n=e.length-t,r=new Array(n);n--;)r[n]=e[n+t];return r}function w(e,t){for(var n in t)e[n]=t[n];return e}function _(e){for(var t={},n=0;n-1)if(i&&!m(o,"default"))a=!1;else if(""===a||a===mi(e)){var u=ne(String,o.type);(u<0||s0&&(a=be(a,(t||"")+"_"+n),ge(a[0])&&ge(c)&&(l[u]=L(c.text+a[0].text),a.shift()),l.push.apply(l,a)):s(a)?ge(c)?l[u]=L(c.text+a):""!==a&&l.push(L(a)):ge(a)&&ge(c)?l[u]=L(c.text+a.text):(i(e._isVList)&&o(a.tag)&&r(a.key)&&o(t)&&(a.key="__vlist"+t+"_"+n+"__"),l.push(a)));return l}function xe(e,t){return(e.__esModule||Fi&&"Module"===e[Symbol.toStringTag])&&(e=e.default),u(e)?t.extend(e):e}function we(e,t,n,r,o){var i=Xi();return i.asyncFactory=e,i.asyncMeta={data:t,context:n,children:r,tag:o},i}function _e(e,t,n){if(i(e.error)&&o(e.errorComp))return e.errorComp;if(o(e.resolved))return e.resolved;if(i(e.loading)&&o(e.loadingComp))return e.loadingComp;if(!o(e.contexts)){var a=e.contexts=[n],s=!0,c=function(){for(var e=0,t=a.length;eba&&ha[n].id>e.id;)n--;ha.splice(n+1,0,e)}else ha.push(e);ya||(ya=!0,ue(He))}}function ze(e,t,n){_a.get=function(){return this[t][n]},_a.set=function(e){this[t][n]=e},Object.defineProperty(e,n,_a)}function Ve(e){e._watchers=[];var t=e.$options;t.props&&Ge(e,t.props),t.methods&&Ze(e,t.methods),t.data?Xe(e):M(e._data={},!0),t.computed&&Ke(e,t.computed),t.watch&&t.watch!==Di&&et(e,t.watch)}function Ge(e,t){var n=e.$options.propsData||{},r=e._props={},o=e.$options._propKeys=[];!e.$parent||R(!1);for(var i in t)!function(i){o.push(i);var a=Q(i,t,n,e);q(r,i,a),i in e||ze(e,"_props",i)}(i);R(!0)}function Xe(e){var t=e.$options.data;t=e._data="function"==typeof t?Je(t,e):t||{},c(t)||(t={});for(var n=Object.keys(t),r=e.$options.props,o=(e.$options.methods,n.length);o--;){var i=n[o];r&&m(r,i)||S(i)||ze(e,"_data",i)}M(t,!0)}function Je(e,t){j();try{return e.call(t,t)}catch(e){return re(e,t,"data()"),{}}finally{N()}}function Ke(e,t){var n=e._computedWatchers=Object.create(null),r=qi();for(var o in t){var i=t[o],a="function"==typeof i?i:i.get;r||(n[o]=new wa(e,a||C,C,Ca)),o in e||Ye(e,o,i)}}function Ye(e,t,n){var r=!qi();"function"==typeof n?(_a.get=r?Qe(t):n,_a.set=C):(_a.get=n.get?r&&!1!==n.cache?Qe(t):n.get:C,_a.set=n.set?n.set:C),Object.defineProperty(e,t,_a)}function Qe(e){return function(){var t=this._computedWatchers&&this._computedWatchers[e];if(t)return t.dirty&&t.evaluate(),Wi.target&&t.depend(),t.value}}function Ze(e,t){e.$options.props;for(var n in t)e[n]=null==t[n]?C:yi(t[n],e)}function et(e,t){for(var n in t){var r=t[n];if(Array.isArray(r))for(var o=0;o=0||n.indexOf(e[o])<0)&&r.push(e[o]);return r}return e}function Dt(e){this._init(e)}function Rt(e){e.use=function(e){var t=this._installedPlugins||(this._installedPlugins=[]);if(t.indexOf(e)>-1)return this;var n=x(arguments,1);return n.unshift(this),"function"==typeof e.install?e.install.apply(e,n):"function"==typeof e&&e.apply(null,n),t.push(e),this}}function Pt(e){e.mixin=function(e){return this.options=K(this.options,e),this}}function It(e){e.cid=0;var t=1;e.extend=function(e){e=e||{};var n=this,r=n.cid,o=e._Ctor||(e._Ctor={});if(o[r])return o[r];var i=e.name||n.options.name,a=function(e){this._init(e)};return a.prototype=Object.create(n.prototype),a.prototype.constructor=a,a.cid=t++,a.options=K(n.options,e),a.super=n,a.options.props&&Mt(a),a.options.computed&&qt(a),a.extend=n.extend,a.mixin=n.mixin,a.use=n.use,wi.forEach(function(e){a[e]=n[e]}),i&&(a.options.components[i]=a),a.superOptions=n.options,a.extendOptions=e,a.sealedOptions=w({},a.options),o[r]=a,a}}function Mt(e){var t=e.options.props;for(var n in t)ze(e.prototype,"_props",n)}function qt(e){var t=e.options.computed;for(var n in t)Ye(e.prototype,n,t[n])}function Ht(e){wi.forEach(function(t){e[t]=function(e,n){return n?("component"===t&&c(n)&&(n.name=n.name||e,n=this.options._base.extend(n)),"directive"===t&&"function"==typeof n&&(n={bind:n,update:n}),this.options[t+"s"][e]=n,n):this.options[t+"s"][e]}})}function Ft(e){return e&&(e.Ctor.options.name||e.tag)}function Bt(e,t){return Array.isArray(e)?e.indexOf(t)>-1:"string"==typeof e?e.split(",").indexOf(t)>-1:!!l(e)&&e.test(t)}function Ut(e,t){var n=e.cache,r=e.keys,o=e._vnode;for(var i in n){var a=n[i];if(a){var s=Ft(a.componentOptions);s&&!t(s)&&Wt(n,i,r,o)}}}function Wt(e,t,n,r){var o=e[t];!o||r&&o.tag===r.tag||o.componentInstance.$destroy(),e[t]=null,v(n,t)}function zt(e){for(var t=e.data,n=e,r=e;o(r.componentInstance);)(r=r.componentInstance._vnode)&&r.data&&(t=Vt(r.data,t));for(;o(n=n.parent);)n&&n.data&&(t=Vt(t,n.data));return Gt(t.staticClass,t.class)}function Vt(e,t){return{staticClass:Xt(e.staticClass,t.staticClass),class:o(e.class)?[e.class,t.class]:t.class}}function Gt(e,t){return o(e)||o(t)?Xt(e,Jt(t)):""}function Xt(e,t){return e?t?e+" "+t:e:t||""}function Jt(e){return Array.isArray(e)?Kt(e):u(e)?Yt(e):"string"==typeof e?e:""}function Kt(e){for(var t,n="",r=0,i=e.length;r-1?ts[e]=t.constructor===window.HTMLUnknownElement||t.constructor===window.HTMLElement:ts[e]=/HTMLUnknownElement/.test(t.toString())}function en(e){if("string"==typeof e){var t=document.querySelector(e);return t||document.createElement("div")}return e}function tn(e,t){var n=document.createElement(e);return"select"!==e?n:(t.data&&t.data.attrs&&void 0!==t.data.attrs.multiple&&n.setAttribute("multiple","multiple"),n)}function nn(e,t){return document.createElementNS(Ka[e],t)}function rn(e){return document.createTextNode(e)}function on(e){return document.createComment(e)}function an(e,t,n){e.insertBefore(t,n)}function sn(e,t){e.removeChild(t)}function un(e,t){e.appendChild(t)}function cn(e){return e.parentNode}function ln(e){return e.nextSibling}function fn(e){return e.tagName}function pn(e,t){e.textContent=t}function dn(e,t){e.setAttribute(t,"")}function hn(e,t){var n=e.data.ref;if(o(n)){var r=e.context,i=e.componentInstance||e.elm,a=r.$refs;t?Array.isArray(a[n])?v(a[n],i):a[n]===i&&(a[n]=void 0):e.data.refInFor?Array.isArray(a[n])?a[n].indexOf(i)<0&&a[n].push(i):a[n]=[i]:a[n]=i}}function vn(e,t){return e.key===t.key&&(e.tag===t.tag&&e.isComment===t.isComment&&o(e.data)===o(t.data)&&mn(e,t)||i(e.isAsyncPlaceholder)&&e.asyncFactory===t.asyncFactory&&r(t.asyncFactory.error))}function mn(e,t){if("input"!==e.tag)return!0;var n,r=o(n=e.data)&&o(n=n.attrs)&&n.type,i=o(n=t.data)&&o(n=n.attrs)&&n.type;return r===i||ns(r)&&ns(i)}function yn(e,t,n){var r,i,a={};for(r=t;r<=n;++r)i=e[r].key,o(i)&&(a[i]=r);return a}function gn(e,t){(e.data.directives||t.data.directives)&&bn(e,t)}function bn(e,t){var n,r,o,i=e===is,a=t===is,s=xn(e.data.directives,e.context),u=xn(t.data.directives,t.context),c=[],l=[];for(n in u)r=s[n],o=u[n],r?(o.oldValue=r.value,_n(o,"update",t,e),o.def&&o.def.componentUpdated&&l.push(o)):(_n(o,"bind",t,e),o.def&&o.def.inserted&&c.push(o));if(c.length){var f=function(){for(var n=0;n-1?kn(e,t,n):za(t)?Ja(n)?e.removeAttribute(t):(n="allowfullscreen"===t&&"EMBED"===e.tagName?"true":t,e.setAttribute(t,n)):Wa(t)?e.setAttribute(t,Ja(n)||"false"===n?"false":"true"):Ga(t)?Ja(n)?e.removeAttributeNS(Va,Xa(t)):e.setAttributeNS(Va,t,n):kn(e,t,n)}function kn(e,t,n){if(Ja(n))e.removeAttribute(t);else{if(Oi&&!ji&&"TEXTAREA"===e.tagName&&"placeholder"===t&&!e.__ieph){var r=function(t){t.stopImmediatePropagation(),e.removeEventListener("input",r)};e.addEventListener("input",r),e.__ieph=!0}e.setAttribute(t,n)}}function An(e,t){var n=t.elm,i=t.data,a=e.data;if(!(r(i.staticClass)&&r(i.class)&&(r(a)||r(a.staticClass)&&r(a.class)))){var s=zt(t),u=n._transitionClasses;o(u)&&(s=Xt(s,Jt(u))),s!==n._prevClass&&(n.setAttribute("class",s),n._prevClass=s)}}function Sn(e){function t(){(a||(a=[])).push(e.slice(h,o).trim()),h=o+1}var n,r,o,i,a,s=!1,u=!1,c=!1,l=!1,f=0,p=0,d=0,h=0;for(o=0;o=0&&" "===(m=e.charAt(v));v--);m&&ps.test(m)||(l=!0)}}else void 0===i?(h=o+1,i=e.slice(0,o).trim()):t();if(void 0===i?i=e.slice(0,o).trim():0!==h&&t(),a)for(o=0;o-1?{exp:e.slice(0,Ra),key:'"'+e.slice(Ra+1)+'"'}:{exp:e,key:null};for(La=e,Ra=Pa=Ia=0;!Bn();)Da=Fn(),Un(Da)?zn(Da):91===Da&&Wn(Da);return{exp:e.slice(0,Pa),key:e.slice(Pa+1,Ia)}}function Fn(){return La.charCodeAt(++Ra)}function Bn(){return Ra>=Na}function Un(e){return 34===e||39===e}function Wn(e){var t=1;for(Pa=Ra;!Bn();)if(e=Fn(),Un(e))zn(e);else if(91===e&&t++,93===e&&t--,0===t){Ia=Ra;break}}function zn(e){for(var t=e;!Bn()&&(e=Fn())!==t;);}function Vn(e,t,n){Ma=n;var r=t.value,o=t.modifiers,i=e.tag,a=e.attrsMap.type;if(e.component)return Mn(e,r,o),!1;if("select"===i)Jn(e,r,o);else if("input"===i&&"checkbox"===a)Gn(e,r,o);else if("input"===i&&"radio"===a)Xn(e,r,o);else if("input"===i||"textarea"===i)Kn(e,r,o);else if(!Ci.isReservedTag(i))return Mn(e,r,o),!1;return!0}function Gn(e,t,n){var r=n&&n.number,o=Pn(e,"value")||"null",i=Pn(e,"true-value")||"true",a=Pn(e,"false-value")||"false";jn(e,"checked","Array.isArray("+t+")?_i("+t+","+o+")>-1"+("true"===i?":("+t+")":":_q("+t+","+i+")")),Rn(e,"change","var $$a="+t+",$$el=$event.target,$$c=$$el.checked?("+i+"):("+a+");if(Array.isArray($$a)){var $$v="+(r?"_n("+o+")":o)+",$$i=_i($$a,$$v);if($$el.checked){$$i<0&&("+qn(t,"$$a.concat([$$v])")+")}else{$$i>-1&&("+qn(t,"$$a.slice(0,$$i).concat($$a.slice($$i+1))")+")}}else{"+qn(t,"$$c")+"}",null,!0)}function Xn(e,t,n){var r=n&&n.number,o=Pn(e,"value")||"null";o=r?"_n("+o+")":o,jn(e,"checked","_q("+t+","+o+")"),Rn(e,"change",qn(t,o),null,!0)}function Jn(e,t,n){var r=n&&n.number,o='Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = "_value" in o ? o._value : o.value;return '+(r?"_n(val)":"val")+"})",i="var $$selectedVal = "+o+";";i=i+" "+qn(t,"$event.target.multiple ? $$selectedVal : $$selectedVal[0]"),Rn(e,"change",i,null,!0)}function Kn(e,t,n){var r=e.attrsMap.type,o=n||{},i=o.lazy,a=o.number,s=o.trim,u=!i&&"range"!==r,c=i?"change":"range"===r?ds:"input",l="$event.target.value";s&&(l="$event.target.value.trim()"),a&&(l="_n("+l+")");var f=qn(t,l);u&&(f="if($event.target.composing)return;"+f),jn(e,"value","("+t+")"),Rn(e,c,f,null,!0),(s||a)&&Rn(e,"blur","$forceUpdate()")}function Yn(e){if(o(e[ds])){var t=Oi?"change":"input";e[t]=[].concat(e[ds],e[t]||[]),delete e[ds]}o(e[hs])&&(e.change=[].concat(e[hs],e.change||[]),delete e[hs])}function Qn(e,t,n){var r=qa;return function o(){null!==e.apply(null,arguments)&&er(t,o,n,r)}}function Zn(e,t,n,r,o){t=se(t),n&&(t=Qn(t,e,r)),qa.addEventListener(e,t,Ri?{capture:r,passive:o}:r)}function er(e,t,n,r){(r||qa).removeEventListener(e,t._withTask||t,n)}function tr(e,t){if(!r(e.data.on)||!r(t.data.on)){var n=t.data.on||{},o=e.data.on||{};qa=t.elm,Yn(n),pe(n,o,Zn,er,t.context),qa=void 0}}function nr(e,t){if(!r(e.data.domProps)||!r(t.data.domProps)){var n,i,a=t.elm,s=e.data.domProps||{},u=t.data.domProps||{};o(u.__ob__)&&(u=t.data.domProps=w({},u));for(n in s)r(u[n])&&(a[n]="");for(n in u){if(i=u[n],"textContent"===n||"innerHTML"===n){if(t.children&&(t.children.length=0),i===s[n])continue;1===a.childNodes.length&&a.removeChild(a.childNodes[0])}if("value"===n){a._value=i;var c=r(i)?"":String(i);rr(a,c)&&(a.value=c)}else a[n]=i}}}function rr(e,t){return!e.composing&&("OPTION"===e.tagName||or(e,t)||ir(e,t))}function or(e,t){var n=!0;try{n=document.activeElement!==e}catch(e){}return n&&e.value!==t}function ir(e,t){var n=e.value,r=e._vModifiers;if(o(r)){if(r.lazy)return!1;if(r.number)return d(n)!==d(t);if(r.trim)return n.trim()!==t.trim()}return n!==t}function ar(e){var t=sr(e.style);return e.staticStyle?w(e.staticStyle,t):t}function sr(e){return Array.isArray(e)?_(e):"string"==typeof e?ys(e):e}function ur(e,t){var n,r={};if(t)for(var o=e;o.componentInstance;)(o=o.componentInstance._vnode)&&o.data&&(n=ar(o.data))&&w(r,n);(n=ar(e.data))&&w(r,n);for(var i=e;i=i.parent;)i.data&&(n=ar(i.data))&&w(r,n);return r}function cr(e,t){var n=t.data,i=e.data;if(!(r(n.staticStyle)&&r(n.style)&&r(i.staticStyle)&&r(i.style))){var a,s,u=t.elm,c=i.staticStyle,l=i.normalizedStyle||i.style||{},f=c||l,p=sr(t.data.style)||{};t.data.normalizedStyle=o(p.__ob__)?w({},p):p;var d=ur(t,!0);for(s in f)r(d[s])&&xs(u,s,"");for(s in d)(a=d[s])!==f[s]&&xs(u,s,null==a?"":a)}}function lr(e,t){if(t&&(t=t.trim()))if(e.classList)t.indexOf(" ")>-1?t.split(/\s+/).forEach(function(t){return e.classList.add(t)}):e.classList.add(t);else{var n=" "+(e.getAttribute("class")||"")+" ";n.indexOf(" "+t+" ")<0&&e.setAttribute("class",(n+t).trim())}}function fr(e,t){if(t&&(t=t.trim()))if(e.classList)t.indexOf(" ")>-1?t.split(/\s+/).forEach(function(t){return e.classList.remove(t)}):e.classList.remove(t),e.classList.length||e.removeAttribute("class");else{for(var n=" "+(e.getAttribute("class")||"")+" ",r=" "+t+" ";n.indexOf(r)>=0;)n=n.replace(r," ");n=n.trim(),n?e.setAttribute("class",n):e.removeAttribute("class")}}function pr(e){if(e){if("object"==typeof e){var t={};return!1!==e.css&&w(t,Ts(e.name||"v")),w(t,e),t}return"string"==typeof e?Ts(e):void 0}}function dr(e){Ns(function(){Ns(e)})}function hr(e,t){var n=e._transitionClasses||(e._transitionClasses=[]);n.indexOf(t)<0&&(n.push(t),lr(e,t))}function vr(e,t){e._transitionClasses&&v(e._transitionClasses,t),fr(e,t)}function mr(e,t,n){var r=yr(e,t),o=r.type,i=r.timeout,a=r.propCount;if(!o)return n();var s=o===As?$s:js,u=0,c=function(){e.removeEventListener(s,l),n()},l=function(t){t.target===e&&++u>=a&&c()};setTimeout(function(){u0&&(n=As,l=a,f=i.length):t===Ss?c>0&&(n=Ss,l=c,f=u.length):(l=Math.max(a,c),n=l>0?a>c?As:Ss:null,f=n?n===As?i.length:u.length:0),{type:n,timeout:l,propCount:f,hasTransform:n===As&&Ls.test(r[Es+"Property"])}}function gr(e,t){for(;e.length1}function Tr(e,t){!0!==t.data.show&&xr(t)}function kr(e,t,n){Ar(e,t,n),(Oi||Ni)&&setTimeout(function(){Ar(e,t,n)},0)}function Ar(e,t,n){var r=t.value,o=e.multiple;if(!o||Array.isArray(r)){for(var i,a,s=0,u=e.options.length;s-1,a.selected!==i&&(a.selected=i);else if(T(Er(a),r))return void(e.selectedIndex!==s&&(e.selectedIndex=s));o||(e.selectedIndex=-1)}}function Sr(e,t){return t.every(function(t){return!T(t,e)})}function Er(e){return"_value"in e?e._value:e.value}function $r(e){e.target.composing=!0}function Or(e){e.target.composing&&(e.target.composing=!1,jr(e.target,"input"))}function jr(e,t){var n=document.createEvent("HTMLEvents");n.initEvent(t,!0,!0),e.dispatchEvent(n)}function Nr(e){return!e.componentInstance||e.data&&e.data.transition?e:Nr(e.componentInstance._vnode)}function Lr(e){var t=e&&e.componentOptions;return t&&t.Ctor.options.abstract?Lr(Te(t.children)):e}function Dr(e){var t={},n=e.$options;for(var r in n.propsData)t[r]=e[r];var o=n._parentListeners;for(var i in o)t[di(i)]=o[i];return t}function Rr(e,t){if(/\d-keep-alive$/.test(t.tag))return e("keep-alive",{props:t.componentOptions.propsData})}function Pr(e){for(;e=e.parent;)if(e.data.transition)return!0}function Ir(e,t){return t.key===e.key&&t.tag===e.tag}function Mr(e){e.elm._moveCb&&e.elm._moveCb(),e.elm._enterCb&&e.elm._enterCb()}function qr(e){e.data.newPos=e.elm.getBoundingClientRect()}function Hr(e){var t=e.data.pos,n=e.data.newPos,r=t.left-n.left,o=t.top-n.top;if(r||o){e.data.moved=!0;var i=e.elm.style;i.transform=i.WebkitTransform="translate("+r+"px,"+o+"px)",i.transitionDuration="0s"}}function Fr(e,t){var n=t?Js(t):Gs;if(n.test(e)){for(var r,o,i,a=[],s=[],u=n.lastIndex=0;r=n.exec(e);){o=r.index,o>u&&(s.push(i=e.slice(u,o)),a.push(JSON.stringify(i)));var c=Sn(r[1].trim());a.push("_s("+c+")"),s.push({"@binding":c}),u=o+r[0].length}return u=0&&a[o].lowerCasedTag!==s;o--);else o=0;if(o>=0){for(var u=a.length-1;u>=o;u--)t.end&&t.end(a[u].tag,n,r);a.length=o,i=o&&a[o-1].tag}else"br"===s?t.start&&t.start(e,[],!0,n,r):"p"===s&&(t.start&&t.start(e,[],!1,n,r),t.end&&t.end(e,n,r))}for(var o,i,a=[],s=t.expectHTML,u=t.isUnaryTag||gi,c=t.canBeLeftOpenTag||gi,l=0;e;){if(o=e,i&&Cu(i)){var f=0,p=i.toLowerCase(),d=Tu[p]||(Tu[p]=new RegExp("([\\s\\S]*?)(]*>)","i")),h=e.replace(d,function(e,n,r){return f=r.length,Cu(p)||"noscript"===p||(n=n.replace(//g,"$1").replace(//g,"$1")),$u(p,n)&&(n=n.slice(1)),t.chars&&t.chars(n),""});l+=e.length-h.length,e=h,r(p,l-f,l)}else{var v=e.indexOf("<");if(0===v){if(cu.test(e)){var m=e.indexOf("--\x3e");if(m>=0){t.shouldKeepComment&&t.comment(e.substring(4,m)),n(m+3);continue}}if(lu.test(e)){var y=e.indexOf("]>");if(y>=0){n(y+2);continue}}var g=e.match(uu);if(g){n(g[0].length);continue}var b=e.match(su);if(b){var x=l;n(b[0].length),r(b[1],x,l);continue}var w=function(){var t=e.match(iu);if(t){var r={tagName:t[1],attrs:[],start:l};n(t[0].length);for(var o,i;!(o=e.match(au))&&(i=e.match(nu));)n(i[0].length),r.attrs.push(i);if(o)return r.unarySlash=o[1],n(o[0].length),r.end=l,r}}();if(w){!function(e){var n=e.tagName,o=e.unarySlash;s&&("p"===i&&tu(n)&&r(i),c(n)&&i===n&&r(n));for(var l=u(n)||!!o,f=e.attrs.length,p=new Array(f),d=0;d=0){for(C=e.slice(v);!(su.test(C)||iu.test(C)||cu.test(C)||lu.test(C)||(T=C.indexOf("<",1))<0);)v+=T,C=e.slice(v);_=e.substring(0,v),n(v)}v<0&&(_=e,e=""),t.chars&&_&&t.chars(_)}if(e===o){t.chars&&t.chars(e);break}}r()}function Xr(e,t,n){return{type:1,tag:e,attrsList:t,attrsMap:ho(t),parent:n,children:[]}}function Jr(e,t){function n(e){e.pre&&(s=!1),yu(e.tag)&&(u=!1);for(var n=0;n':'
',_u.innerHTML.indexOf(" ")>0}function ai(e){if(e.outerHTML)return e.outerHTML;var t=document.createElement("div");return t.appendChild(e.cloneNode(!0)),t.innerHTML}/*! +!function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/assets/",t(t.s="2qrm")}({"/ocq":function(e,t,n){"use strict";function r(e,t){}function o(e){return Object.prototype.toString.call(e).indexOf("Error")>-1}function i(e,t){switch(typeof t){case"undefined":return;case"object":return t;case"function":return t(e);case"boolean":return t?e.params:void 0}}function a(e,t){for(var n in t)e[n]=t[n];return e}function s(e,t,n){void 0===t&&(t={});var r,o=n||u;try{r=o(e||"")}catch(e){r={}}for(var i in t)r[i]=t[i];return r}function u(e){var t={};return(e=e.trim().replace(/^(\?|#|&)/,""))?(e.split("&").forEach(function(e){var n=e.replace(/\+/g," ").split("="),r=He(n.shift()),o=n.length>0?He(n.join("=")):null;void 0===t[r]?t[r]=o:Array.isArray(t[r])?t[r].push(o):t[r]=[t[r],o]}),t):t}function c(e){var t=e?Object.keys(e).map(function(t){var n=e[t];if(void 0===n)return"";if(null===n)return qe(t);if(Array.isArray(n)){var r=[];return n.forEach(function(e){void 0!==e&&(null===e?r.push(qe(t)):r.push(qe(t)+"="+qe(e)))}),r.join("&")}return qe(t)+"="+qe(n)}).filter(function(e){return e.length>0}).join("&"):null;return t?"?"+t:""}function l(e,t,n,r){var o=r&&r.options.stringifyQuery,i=t.query||{};try{i=f(i)}catch(e){}var a={name:t.name||e&&e.name,meta:e&&e.meta||{},path:t.path||"/",hash:t.hash||"",query:i,params:t.params||{},fullPath:d(t,o),matched:e?p(e):[]};return n&&(a.redirectedFrom=d(n,o)),Object.freeze(a)}function f(e){if(Array.isArray(e))return e.map(f);if(e&&"object"==typeof e){var t={};for(var n in e)t[n]=f(e[n]);return t}return e}function p(e){for(var t=[];e;)t.unshift(e),e=e.parent;return t}function d(e,t){var n=e.path,r=e.query;void 0===r&&(r={});var o=e.hash;void 0===o&&(o="");var i=t||c;return(n||"/")+i(r)+o}function h(e,t){return t===Be?e===t:!!t&&(e.path&&t.path?e.path.replace(Fe,"")===t.path.replace(Fe,"")&&e.hash===t.hash&&v(e.query,t.query):!(!e.name||!t.name)&&(e.name===t.name&&e.hash===t.hash&&v(e.query,t.query)&&v(e.params,t.params)))}function v(e,t){if(void 0===e&&(e={}),void 0===t&&(t={}),!e||!t)return e===t;var n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(function(n){var r=e[n],o=t[n];return"object"==typeof r&&"object"==typeof o?v(r,o):String(r)===String(o)})}function m(e,t){return 0===e.path.replace(Fe,"/").indexOf(t.path.replace(Fe,"/"))&&(!t.hash||e.hash===t.hash)&&y(e.query,t.query)}function y(e,t){for(var n in t)if(!(n in e))return!1;return!0}function g(e){if(!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey||e.defaultPrevented||void 0!==e.button&&0!==e.button)){if(e.currentTarget&&e.currentTarget.getAttribute){if(/\b_blank\b/i.test(e.currentTarget.getAttribute("target")))return}return e.preventDefault&&e.preventDefault(),!0}}function b(e){if(e)for(var t,n=0;n=0&&(t=e.slice(r),e=e.slice(0,r));var o=e.indexOf("?");return o>=0&&(n=e.slice(o+1),e=e.slice(0,o)),{path:e,query:n,hash:t}}function C(e){return e.replace(/\/\//g,"/")}function T(e,t){for(var n,r=[],o=0,i=0,a="",s=t&&t.delimiter||"/";null!=(n=Ze.exec(e));){var u=n[0],c=n[1],l=n.index;if(a+=e.slice(i,l),i=l+u.length,c)a+=c[1];else{var f=e[i],p=n[2],d=n[3],h=n[4],v=n[5],m=n[6],y=n[7];a&&(r.push(a),a="");var g=null!=p&&null!=f&&f!==p,b="+"===m||"*"===m,x="?"===m||"*"===m,w=n[2]||s,_=h||v;r.push({name:d||o++,prefix:p||"",delimiter:w,optional:x,repeat:b,partial:g,asterisk:!!y,pattern:_?O(_):y?".*":"[^"+$(w)+"]+?"})}}return i-1&&(o.params[p]=n.params[p]);if(s)return o.path=M(s.path,o.params,'named route "'+i+'"'),a(s,o,r)}else if(o.path){o.params={};for(var d=0;d=e.length?n():e[o]?t(e[o],function(){r(o+1)}):r(o+1)};r(0)}function le(e){return function(t,n,r){var i=!1,a=0,s=null;fe(e,function(e,t,n,u){if("function"==typeof e&&void 0===e.cid){i=!0,a++;var c,l=he(function(t){de(t)&&(t=t.default),e.resolved="function"==typeof t?t:De.extend(t),n.components[u]=t,--a<=0&&r()}),f=he(function(e){var t="Failed to resolve async component "+u+": "+e;s||(s=o(e)?e:new Error(t),r(s))});try{c=e(l,f)}catch(e){f(e)}if(c)if("function"==typeof c.then)c.then(l,f);else{var p=c.component;p&&"function"==typeof p.then&&p.then(l,f)}}}),i||r()}}function fe(e,t){return pe(e.map(function(e){return Object.keys(e.components).map(function(n){return t(e.components[n],e.instances[n],e,n)})}))}function pe(e){return Array.prototype.concat.apply([],e)}function de(e){return e.__esModule||it&&"Module"===e[Symbol.toStringTag]}function he(e){var t=!1;return function(){for(var n=[],r=arguments.length;r--;)n[r]=arguments[r];if(!t)return t=!0,e.apply(this,n)}}function ve(e){if(!e)if(Ve){var t=document.querySelector("base");e=t&&t.getAttribute("href")||"/",e=e.replace(/^https?:\/\/[^\/]+/,"")}else e="/";return"/"!==e.charAt(0)&&(e="/"+e),e.replace(/\/$/,"")}function me(e,t){var n,r=Math.max(e.length,t.length);for(n=0;n=0?t.slice(0,n):t)+"#"+e}function Oe(e){nt?se($e(e)):window.location.hash=e}function je(e){nt?ue($e(e)):window.location.replace($e(e))}function Ne(e,t){return e.push(t),function(){var n=e.indexOf(t);n>-1&&e.splice(n,1)}}function Le(e,t,n){var r="hash"===n?"#"+t:t;return e?C(e+"/"+r):r}var De,Re={name:"router-view",functional:!0,props:{name:{type:String,default:"default"}},render:function(e,t){var n=t.props,r=t.children,o=t.parent,s=t.data;s.routerView=!0;for(var u=o.$createElement,c=n.name,l=o.$route,f=o._routerViewCache||(o._routerViewCache={}),p=0,d=!1;o&&o._routerRoot!==o;)o.$vnode&&o.$vnode.data.routerView&&p++,o._inactive&&(d=!0),o=o.$parent;if(s.routerViewDepth=p,d)return u(f[c],s,r);var h=l.matched[p];if(!h)return f[c]=null,u();var v=f[c]=h.components[c];s.registerRouteInstance=function(e,t){var n=h.instances[c];(t&&n!==e||!t&&n===e)&&(h.instances[c]=t)},(s.hook||(s.hook={})).prepatch=function(e,t){h.instances[c]=t.componentInstance};var m=s.props=i(l,h.props&&h.props[c]);if(m){m=s.props=a({},m);var y=s.attrs=s.attrs||{};for(var g in m)v.props&&g in v.props||(y[g]=m[g],delete m[g])}return u(v,s,r)}},Pe=/[!'()*]/g,Ie=function(e){return"%"+e.charCodeAt(0).toString(16)},Me=/%2C/g,qe=function(e){return encodeURIComponent(e).replace(Pe,Ie).replace(Me,",")},He=decodeURIComponent,Fe=/\/?$/,Be=l(null,{path:"/"}),Ue=[String,Object],We=[String,Array],ze={name:"router-link",props:{to:{type:Ue,required:!0},tag:{type:String,default:"a"},exact:Boolean,append:Boolean,replace:Boolean,activeClass:String,exactActiveClass:String,event:{type:We,default:"click"}},render:function(e){var t=this,n=this.$router,r=this.$route,o=n.resolve(this.to,r,this.append),i=o.location,a=o.route,s=o.href,u={},c=n.options.linkActiveClass,f=n.options.linkExactActiveClass,p=null==c?"router-link-active":c,d=null==f?"router-link-exact-active":f,v=null==this.activeClass?p:this.activeClass,y=null==this.exactActiveClass?d:this.exactActiveClass,x=i.path?l(null,i,null,n):a;u[y]=h(r,x),u[v]=this.exact?u[y]:m(r,x);var w=function(e){g(e)&&(t.replace?n.replace(i):n.push(i))},_={click:g};Array.isArray(this.event)?this.event.forEach(function(e){_[e]=w}):_[this.event]=w;var C={class:u};if("a"===this.tag)C.on=_,C.attrs={href:s};else{var T=b(this.$slots.default);if(T){T.isStatic=!1;var k=De.util.extend;(T.data=k({},T.data)).on=_;(T.data.attrs=k({},T.data.attrs)).href=s}else C.on=_}return e(this.tag,C,this.$slots.default)}},Ve="undefined"!=typeof window,Ge=Array.isArray||function(e){return"[object Array]"==Object.prototype.toString.call(e)},Xe=I,Je=T,Ke=k,Ye=E,Qe=P,Ze=new RegExp(["(\\\\.)","([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))"].join("|"),"g");Xe.parse=Je,Xe.compile=Ke,Xe.tokensToFunction=Ye,Xe.tokensToRegExp=Qe;var et=Object.create(null),tt=Object.create(null),nt=Ve&&function(){var e=window.navigator.userAgent;return(-1===e.indexOf("Android 2.")&&-1===e.indexOf("Android 4.0")||-1===e.indexOf("Mobile Safari")||-1!==e.indexOf("Chrome")||-1!==e.indexOf("Windows Phone"))&&(window.history&&"pushState"in window.history)}(),rt=Ve&&window.performance&&window.performance.now?window.performance:Date,ot=oe(),it="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag,at=function(e,t){this.router=e,this.base=ve(t),this.current=Be,this.pending=null,this.ready=!1,this.readyCbs=[],this.readyErrorCbs=[],this.errorCbs=[]};at.prototype.listen=function(e){this.cb=e},at.prototype.onReady=function(e,t){this.ready?e():(this.readyCbs.push(e),t&&this.readyErrorCbs.push(t))},at.prototype.onError=function(e){this.errorCbs.push(e)},at.prototype.transitionTo=function(e,t,n){var r=this,o=this.router.match(e,this.current);this.confirmTransition(o,function(){r.updateRoute(o),t&&t(o),r.ensureURL(),r.ready||(r.ready=!0,r.readyCbs.forEach(function(e){e(o)}))},function(e){n&&n(e),e&&!r.ready&&(r.ready=!0,r.readyErrorCbs.forEach(function(t){t(e)}))})},at.prototype.confirmTransition=function(e,t,n){var i=this,a=this.current,s=function(e){o(e)&&(i.errorCbs.length?i.errorCbs.forEach(function(t){t(e)}):(r(!1,"uncaught error during route navigation:"),console.error(e))),n&&n(e)};if(h(e,a)&&e.matched.length===a.matched.length)return this.ensureURL(),s();var u=me(this.current.matched,e.matched),c=u.updated,l=u.deactivated,f=u.activated,p=[].concat(be(l),this.router.beforeHooks,xe(c),f.map(function(e){return e.beforeEnter}),le(f));this.pending=e;var d=function(t,n){if(i.pending!==e)return s();try{t(e,a,function(e){!1===e||o(e)?(i.ensureURL(!0),s(e)):"string"==typeof e||"object"==typeof e&&("string"==typeof e.path||"string"==typeof e.name)?(s(),"object"==typeof e&&e.replace?i.replace(e):i.push(e)):n(e)})}catch(e){s(e)}};ce(p,d,function(){var n=[];ce(_e(f,n,function(){return i.current===e}).concat(i.router.resolveHooks),d,function(){if(i.pending!==e)return s();i.pending=null,t(e),i.router.app&&i.router.app.$nextTick(function(){n.forEach(function(e){e()})})})})},at.prototype.updateRoute=function(e){var t=this.current;this.current=e,this.cb&&this.cb(e),this.router.afterHooks.forEach(function(n){n&&n(e,t)})};var st=function(e){function t(t,n){var r=this;e.call(this,t,n);var o=t.options.scrollBehavior;o&&X();var i=ke(this.base);window.addEventListener("popstate",function(e){var n=r.current,a=ke(r.base);r.current===Be&&a===i||r.transitionTo(a,function(e){o&&J(t,e,n,!0)})})}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.go=function(e){window.history.go(e)},t.prototype.push=function(e,t,n){var r=this,o=this,i=o.current;this.transitionTo(e,function(e){se(C(r.base+e.fullPath)),J(r.router,e,i,!1),t&&t(e)},n)},t.prototype.replace=function(e,t,n){var r=this,o=this,i=o.current;this.transitionTo(e,function(e){ue(C(r.base+e.fullPath)),J(r.router,e,i,!1),t&&t(e)},n)},t.prototype.ensureURL=function(e){if(ke(this.base)!==this.current.fullPath){var t=C(this.base+this.current.fullPath);e?se(t):ue(t)}},t.prototype.getCurrentLocation=function(){return ke(this.base)},t}(at),ut=function(e){function t(t,n,r){e.call(this,t,n),r&&Ae(this.base)||Se()}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.setupListeners=function(){var e=this,t=this.router,n=t.options.scrollBehavior,r=nt&&n;r&&X(),window.addEventListener(nt?"popstate":"hashchange",function(){var t=e.current;Se()&&e.transitionTo(Ee(),function(n){r&&J(e.router,n,t,!0),nt||je(n.fullPath)})})},t.prototype.push=function(e,t,n){var r=this,o=this,i=o.current;this.transitionTo(e,function(e){Oe(e.fullPath),J(r.router,e,i,!1),t&&t(e)},n)},t.prototype.replace=function(e,t,n){var r=this,o=this,i=o.current;this.transitionTo(e,function(e){je(e.fullPath),J(r.router,e,i,!1),t&&t(e)},n)},t.prototype.go=function(e){window.history.go(e)},t.prototype.ensureURL=function(e){var t=this.current.fullPath;Ee()!==t&&(e?Oe(t):je(t))},t.prototype.getCurrentLocation=function(){return Ee()},t}(at),ct=function(e){function t(t,n){e.call(this,t,n),this.stack=[],this.index=-1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.push=function(e,t,n){var r=this;this.transitionTo(e,function(e){r.stack=r.stack.slice(0,r.index+1).concat(e),r.index++,t&&t(e)},n)},t.prototype.replace=function(e,t,n){var r=this;this.transitionTo(e,function(e){r.stack=r.stack.slice(0,r.index).concat(e),t&&t(e)},n)},t.prototype.go=function(e){var t=this,n=this.index+e;if(!(n<0||n>=this.stack.length)){var r=this.stack[n];this.confirmTransition(r,function(){t.index=n,t.updateRoute(r)})}},t.prototype.getCurrentLocation=function(){var e=this.stack[this.stack.length-1];return e?e.fullPath:"/"},t.prototype.ensureURL=function(){},t}(at),lt=function(e){void 0===e&&(e={}),this.app=null,this.apps=[],this.options=e,this.beforeHooks=[],this.resolveHooks=[],this.afterHooks=[],this.matcher=z(e.routes||[],this);var t=e.mode||"hash";switch(this.fallback="history"===t&&!nt&&!1!==e.fallback,this.fallback&&(t="hash"),Ve||(t="abstract"),this.mode=t,t){case"history":this.history=new st(this,e.base);break;case"hash":this.history=new ut(this,e.base,this.fallback);break;case"abstract":this.history=new ct(this,e.base)}},ft={currentRoute:{configurable:!0}};lt.prototype.match=function(e,t,n){return this.matcher.match(e,t,n)},ft.currentRoute.get=function(){return this.history&&this.history.current},lt.prototype.init=function(e){var t=this;if(this.apps.push(e),!this.app){this.app=e;var n=this.history;if(n instanceof st)n.transitionTo(n.getCurrentLocation());else if(n instanceof ut){var r=function(){n.setupListeners()};n.transitionTo(n.getCurrentLocation(),r,r)}n.listen(function(e){t.apps.forEach(function(t){t._route=e})})}},lt.prototype.beforeEach=function(e){return Ne(this.beforeHooks,e)},lt.prototype.beforeResolve=function(e){return Ne(this.resolveHooks,e)},lt.prototype.afterEach=function(e){return Ne(this.afterHooks,e)},lt.prototype.onReady=function(e,t){this.history.onReady(e,t)},lt.prototype.onError=function(e){this.history.onError(e)},lt.prototype.push=function(e,t,n){this.history.push(e,t,n)},lt.prototype.replace=function(e,t,n){this.history.replace(e,t,n)},lt.prototype.go=function(e){this.history.go(e)},lt.prototype.back=function(){this.go(-1)},lt.prototype.forward=function(){this.go(1)},lt.prototype.getMatchedComponents=function(e){var t=e?e.matched?e:this.resolve(e).route:this.currentRoute;return t?[].concat.apply([],t.matched.map(function(e){return Object.keys(e.components).map(function(t){return e.components[t]})})):[]},lt.prototype.resolve=function(e,t,n){var r=U(e,t||this.history.current,n,this),o=this.match(r,t),i=o.redirectedFrom||o.fullPath;return{location:r,route:o,href:Le(this.history.base,i,this.mode),normalizedTo:r,resolved:o}},lt.prototype.addRoutes=function(e){this.matcher.addRoutes(e),this.history.current!==Be&&this.history.transitionTo(this.history.getCurrentLocation())},Object.defineProperties(lt.prototype,ft),lt.install=x,lt.version="3.0.1",Ve&&window.Vue&&window.Vue.use(lt),t.a=lt},"0WHz":function(e,t){},"162o":function(e,t,n){(function(e){function r(e,t){this._id=e,this._clearFn=t}var o=void 0!==e&&e||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;t.setTimeout=function(){return new r(i.call(setTimeout,o,arguments),clearTimeout)},t.setInterval=function(){return new r(i.call(setInterval,o,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},r.prototype.unref=r.prototype.ref=function(){},r.prototype.close=function(){this._clearFn.call(o,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},n("mypn"),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(t,n("DuR2"))},"21It":function(e,t,n){"use strict";var r=n("FtD3");e.exports=function(e,t,n){var o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(r("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},"21vO":function(e,t,n){"use strict";var r=n("C97N");t.a={name:"context",props:["type","limit"],components:{},data:function(){return{message:"",loading:!0,records:[]}},created:function(){var e=this;this.records=r.a.getRecords(this.type),r.a.fetchRecords(this.type).then(function(t){e.records=t}).catch(function(e){return console.log(e)}).finally(function(){e.loading=!1})}}},"2qrm":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){var t=n("7+uW"),r=n("PMO0"),o=n("gdD7"),i=n("2wqZ"),a=n("zU0/"),s=n("rLFe"),u=n("K5ga"),c=n("0WHz");n.n(c);t.a.component("sidebar",o.a),t.a.component("topbar",i.default),t.a.component("dashboardnews",a.a),t.a.component("app",u.a),t.a.component("dashboardcontentlist",s.a);var l=n("7t+N");e.$=e.jQuery=l,new t.a({el:"header",router:r.a}),new t.a({el:"#sidebar",router:r.a}),new t.a({el:"#vuecontent",router:r.a}),new t.a({el:"dashboardnews"}),l(document).ready(function(){l("a.lightbox").simpleLightbox()})}.call(t,n("DuR2"))},"2wqZ":function(e,t,n){"use strict";function r(e){u||n("AJjC")}var o=n("AE6B"),i=n.n(o),a=n("zKrp"),s=n("XyMi"),u=!1,c=r,l=Object(s.a)(i.a,a.a,a.b,!1,c,null,null);l.options.__file="assets/js/Components/Topbar.vue",t.default=l.exports},5850:function(e,t){},"5VQ+":function(e,t,n){"use strict";var r=n("cGG2");e.exports=function(e,t){r.forEach(e,function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])})}},"7+uW":function(e,t,n){"use strict";(function(e,n){function r(e){return void 0===e||null===e}function o(e){return void 0!==e&&null!==e}function i(e){return!0===e}function a(e){return!1===e}function s(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e||"boolean"==typeof e}function u(e){return null!==e&&"object"==typeof e}function c(e){return"[object Object]"===ui.call(e)}function l(e){return"[object RegExp]"===ui.call(e)}function f(e){var t=parseFloat(String(e));return t>=0&&Math.floor(t)===t&&isFinite(e)}function p(e){return null==e?"":"object"==typeof e?JSON.stringify(e,null,2):String(e)}function d(e){var t=parseFloat(e);return isNaN(t)?e:t}function h(e,t){for(var n=Object.create(null),r=e.split(","),o=0;o-1)return e.splice(n,1)}}function m(e,t){return fi.call(e,t)}function y(e){var t=Object.create(null);return function(n){return t[n]||(t[n]=e(n))}}function g(e,t){function n(n){var r=arguments.length;return r?r>1?e.apply(t,arguments):e.call(t,n):e.call(t)}return n._length=e.length,n}function b(e,t){return e.bind(t)}function x(e,t){t=t||0;for(var n=e.length-t,r=new Array(n);n--;)r[n]=e[n+t];return r}function w(e,t){for(var n in t)e[n]=t[n];return e}function _(e){for(var t={},n=0;n-1)if(i&&!m(o,"default"))a=!1;else if(""===a||a===mi(e)){var u=ne(String,o.type);(u<0||s0&&(a=be(a,(t||"")+"_"+n),ge(a[0])&&ge(c)&&(l[u]=L(c.text+a[0].text),a.shift()),l.push.apply(l,a)):s(a)?ge(c)?l[u]=L(c.text+a):""!==a&&l.push(L(a)):ge(a)&&ge(c)?l[u]=L(c.text+a.text):(i(e._isVList)&&o(a.tag)&&r(a.key)&&o(t)&&(a.key="__vlist"+t+"_"+n+"__"),l.push(a)));return l}function xe(e,t){return(e.__esModule||Fi&&"Module"===e[Symbol.toStringTag])&&(e=e.default),u(e)?t.extend(e):e}function we(e,t,n,r,o){var i=Xi();return i.asyncFactory=e,i.asyncMeta={data:t,context:n,children:r,tag:o},i}function _e(e,t,n){if(i(e.error)&&o(e.errorComp))return e.errorComp;if(o(e.resolved))return e.resolved;if(i(e.loading)&&o(e.loadingComp))return e.loadingComp;if(!o(e.contexts)){var a=e.contexts=[n],s=!0,c=function(){for(var e=0,t=a.length;eba&&ha[n].id>e.id;)n--;ha.splice(n+1,0,e)}else ha.push(e);ya||(ya=!0,ue(He))}}function ze(e,t,n){_a.get=function(){return this[t][n]},_a.set=function(e){this[t][n]=e},Object.defineProperty(e,n,_a)}function Ve(e){e._watchers=[];var t=e.$options;t.props&&Ge(e,t.props),t.methods&&Ze(e,t.methods),t.data?Xe(e):M(e._data={},!0),t.computed&&Ke(e,t.computed),t.watch&&t.watch!==Di&&et(e,t.watch)}function Ge(e,t){var n=e.$options.propsData||{},r=e._props={},o=e.$options._propKeys=[];!e.$parent||R(!1);for(var i in t)!function(i){o.push(i);var a=Q(i,t,n,e);q(r,i,a),i in e||ze(e,"_props",i)}(i);R(!0)}function Xe(e){var t=e.$options.data;t=e._data="function"==typeof t?Je(t,e):t||{},c(t)||(t={});for(var n=Object.keys(t),r=e.$options.props,o=(e.$options.methods,n.length);o--;){var i=n[o];r&&m(r,i)||S(i)||ze(e,"_data",i)}M(t,!0)}function Je(e,t){j();try{return e.call(t,t)}catch(e){return re(e,t,"data()"),{}}finally{N()}}function Ke(e,t){var n=e._computedWatchers=Object.create(null),r=qi();for(var o in t){var i=t[o],a="function"==typeof i?i:i.get;r||(n[o]=new wa(e,a||C,C,Ca)),o in e||Ye(e,o,i)}}function Ye(e,t,n){var r=!qi();"function"==typeof n?(_a.get=r?Qe(t):n,_a.set=C):(_a.get=n.get?r&&!1!==n.cache?Qe(t):n.get:C,_a.set=n.set?n.set:C),Object.defineProperty(e,t,_a)}function Qe(e){return function(){var t=this._computedWatchers&&this._computedWatchers[e];if(t)return t.dirty&&t.evaluate(),Wi.target&&t.depend(),t.value}}function Ze(e,t){e.$options.props;for(var n in t)e[n]=null==t[n]?C:yi(t[n],e)}function et(e,t){for(var n in t){var r=t[n];if(Array.isArray(r))for(var o=0;o=0||n.indexOf(e[o])<0)&&r.push(e[o]);return r}return e}function Dt(e){this._init(e)}function Rt(e){e.use=function(e){var t=this._installedPlugins||(this._installedPlugins=[]);if(t.indexOf(e)>-1)return this;var n=x(arguments,1);return n.unshift(this),"function"==typeof e.install?e.install.apply(e,n):"function"==typeof e&&e.apply(null,n),t.push(e),this}}function Pt(e){e.mixin=function(e){return this.options=K(this.options,e),this}}function It(e){e.cid=0;var t=1;e.extend=function(e){e=e||{};var n=this,r=n.cid,o=e._Ctor||(e._Ctor={});if(o[r])return o[r];var i=e.name||n.options.name,a=function(e){this._init(e)};return a.prototype=Object.create(n.prototype),a.prototype.constructor=a,a.cid=t++,a.options=K(n.options,e),a.super=n,a.options.props&&Mt(a),a.options.computed&&qt(a),a.extend=n.extend,a.mixin=n.mixin,a.use=n.use,wi.forEach(function(e){a[e]=n[e]}),i&&(a.options.components[i]=a),a.superOptions=n.options,a.extendOptions=e,a.sealedOptions=w({},a.options),o[r]=a,a}}function Mt(e){var t=e.options.props;for(var n in t)ze(e.prototype,"_props",n)}function qt(e){var t=e.options.computed;for(var n in t)Ye(e.prototype,n,t[n])}function Ht(e){wi.forEach(function(t){e[t]=function(e,n){return n?("component"===t&&c(n)&&(n.name=n.name||e,n=this.options._base.extend(n)),"directive"===t&&"function"==typeof n&&(n={bind:n,update:n}),this.options[t+"s"][e]=n,n):this.options[t+"s"][e]}})}function Ft(e){return e&&(e.Ctor.options.name||e.tag)}function Bt(e,t){return Array.isArray(e)?e.indexOf(t)>-1:"string"==typeof e?e.split(",").indexOf(t)>-1:!!l(e)&&e.test(t)}function Ut(e,t){var n=e.cache,r=e.keys,o=e._vnode;for(var i in n){var a=n[i];if(a){var s=Ft(a.componentOptions);s&&!t(s)&&Wt(n,i,r,o)}}}function Wt(e,t,n,r){var o=e[t];!o||r&&o.tag===r.tag||o.componentInstance.$destroy(),e[t]=null,v(n,t)}function zt(e){for(var t=e.data,n=e,r=e;o(r.componentInstance);)(r=r.componentInstance._vnode)&&r.data&&(t=Vt(r.data,t));for(;o(n=n.parent);)n&&n.data&&(t=Vt(t,n.data));return Gt(t.staticClass,t.class)}function Vt(e,t){return{staticClass:Xt(e.staticClass,t.staticClass),class:o(e.class)?[e.class,t.class]:t.class}}function Gt(e,t){return o(e)||o(t)?Xt(e,Jt(t)):""}function Xt(e,t){return e?t?e+" "+t:e:t||""}function Jt(e){return Array.isArray(e)?Kt(e):u(e)?Yt(e):"string"==typeof e?e:""}function Kt(e){for(var t,n="",r=0,i=e.length;r-1?ts[e]=t.constructor===window.HTMLUnknownElement||t.constructor===window.HTMLElement:ts[e]=/HTMLUnknownElement/.test(t.toString())}function en(e){if("string"==typeof e){var t=document.querySelector(e);return t||document.createElement("div")}return e}function tn(e,t){var n=document.createElement(e);return"select"!==e?n:(t.data&&t.data.attrs&&void 0!==t.data.attrs.multiple&&n.setAttribute("multiple","multiple"),n)}function nn(e,t){return document.createElementNS(Ka[e],t)}function rn(e){return document.createTextNode(e)}function on(e){return document.createComment(e)}function an(e,t,n){e.insertBefore(t,n)}function sn(e,t){e.removeChild(t)}function un(e,t){e.appendChild(t)}function cn(e){return e.parentNode}function ln(e){return e.nextSibling}function fn(e){return e.tagName}function pn(e,t){e.textContent=t}function dn(e,t){e.setAttribute(t,"")}function hn(e,t){var n=e.data.ref;if(o(n)){var r=e.context,i=e.componentInstance||e.elm,a=r.$refs;t?Array.isArray(a[n])?v(a[n],i):a[n]===i&&(a[n]=void 0):e.data.refInFor?Array.isArray(a[n])?a[n].indexOf(i)<0&&a[n].push(i):a[n]=[i]:a[n]=i}}function vn(e,t){return e.key===t.key&&(e.tag===t.tag&&e.isComment===t.isComment&&o(e.data)===o(t.data)&&mn(e,t)||i(e.isAsyncPlaceholder)&&e.asyncFactory===t.asyncFactory&&r(t.asyncFactory.error))}function mn(e,t){if("input"!==e.tag)return!0;var n,r=o(n=e.data)&&o(n=n.attrs)&&n.type,i=o(n=t.data)&&o(n=n.attrs)&&n.type;return r===i||ns(r)&&ns(i)}function yn(e,t,n){var r,i,a={};for(r=t;r<=n;++r)i=e[r].key,o(i)&&(a[i]=r);return a}function gn(e,t){(e.data.directives||t.data.directives)&&bn(e,t)}function bn(e,t){var n,r,o,i=e===is,a=t===is,s=xn(e.data.directives,e.context),u=xn(t.data.directives,t.context),c=[],l=[];for(n in u)r=s[n],o=u[n],r?(o.oldValue=r.value,_n(o,"update",t,e),o.def&&o.def.componentUpdated&&l.push(o)):(_n(o,"bind",t,e),o.def&&o.def.inserted&&c.push(o));if(c.length){var f=function(){for(var n=0;n-1?kn(e,t,n):za(t)?Ja(n)?e.removeAttribute(t):(n="allowfullscreen"===t&&"EMBED"===e.tagName?"true":t,e.setAttribute(t,n)):Wa(t)?e.setAttribute(t,Ja(n)||"false"===n?"false":"true"):Ga(t)?Ja(n)?e.removeAttributeNS(Va,Xa(t)):e.setAttributeNS(Va,t,n):kn(e,t,n)}function kn(e,t,n){if(Ja(n))e.removeAttribute(t);else{if(Oi&&!ji&&"TEXTAREA"===e.tagName&&"placeholder"===t&&!e.__ieph){var r=function(t){t.stopImmediatePropagation(),e.removeEventListener("input",r)};e.addEventListener("input",r),e.__ieph=!0}e.setAttribute(t,n)}}function An(e,t){var n=t.elm,i=t.data,a=e.data;if(!(r(i.staticClass)&&r(i.class)&&(r(a)||r(a.staticClass)&&r(a.class)))){var s=zt(t),u=n._transitionClasses;o(u)&&(s=Xt(s,Jt(u))),s!==n._prevClass&&(n.setAttribute("class",s),n._prevClass=s)}}function Sn(e){function t(){(a||(a=[])).push(e.slice(h,o).trim()),h=o+1}var n,r,o,i,a,s=!1,u=!1,c=!1,l=!1,f=0,p=0,d=0,h=0;for(o=0;o=0&&" "===(m=e.charAt(v));v--);m&&ps.test(m)||(l=!0)}}else void 0===i?(h=o+1,i=e.slice(0,o).trim()):t();if(void 0===i?i=e.slice(0,o).trim():0!==h&&t(),a)for(o=0;o-1?{exp:e.slice(0,Ra),key:'"'+e.slice(Ra+1)+'"'}:{exp:e,key:null};for(La=e,Ra=Pa=Ia=0;!Bn();)Da=Fn(),Un(Da)?zn(Da):91===Da&&Wn(Da);return{exp:e.slice(0,Pa),key:e.slice(Pa+1,Ia)}}function Fn(){return La.charCodeAt(++Ra)}function Bn(){return Ra>=Na}function Un(e){return 34===e||39===e}function Wn(e){var t=1;for(Pa=Ra;!Bn();)if(e=Fn(),Un(e))zn(e);else if(91===e&&t++,93===e&&t--,0===t){Ia=Ra;break}}function zn(e){for(var t=e;!Bn()&&(e=Fn())!==t;);}function Vn(e,t,n){Ma=n;var r=t.value,o=t.modifiers,i=e.tag,a=e.attrsMap.type;if(e.component)return Mn(e,r,o),!1;if("select"===i)Jn(e,r,o);else if("input"===i&&"checkbox"===a)Gn(e,r,o);else if("input"===i&&"radio"===a)Xn(e,r,o);else if("input"===i||"textarea"===i)Kn(e,r,o);else if(!Ci.isReservedTag(i))return Mn(e,r,o),!1;return!0}function Gn(e,t,n){var r=n&&n.number,o=Pn(e,"value")||"null",i=Pn(e,"true-value")||"true",a=Pn(e,"false-value")||"false";jn(e,"checked","Array.isArray("+t+")?_i("+t+","+o+")>-1"+("true"===i?":("+t+")":":_q("+t+","+i+")")),Rn(e,"change","var $$a="+t+",$$el=$event.target,$$c=$$el.checked?("+i+"):("+a+");if(Array.isArray($$a)){var $$v="+(r?"_n("+o+")":o)+",$$i=_i($$a,$$v);if($$el.checked){$$i<0&&("+qn(t,"$$a.concat([$$v])")+")}else{$$i>-1&&("+qn(t,"$$a.slice(0,$$i).concat($$a.slice($$i+1))")+")}}else{"+qn(t,"$$c")+"}",null,!0)}function Xn(e,t,n){var r=n&&n.number,o=Pn(e,"value")||"null";o=r?"_n("+o+")":o,jn(e,"checked","_q("+t+","+o+")"),Rn(e,"change",qn(t,o),null,!0)}function Jn(e,t,n){var r=n&&n.number,o='Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = "_value" in o ? o._value : o.value;return '+(r?"_n(val)":"val")+"})",i="var $$selectedVal = "+o+";";i=i+" "+qn(t,"$event.target.multiple ? $$selectedVal : $$selectedVal[0]"),Rn(e,"change",i,null,!0)}function Kn(e,t,n){var r=e.attrsMap.type,o=n||{},i=o.lazy,a=o.number,s=o.trim,u=!i&&"range"!==r,c=i?"change":"range"===r?ds:"input",l="$event.target.value";s&&(l="$event.target.value.trim()"),a&&(l="_n("+l+")");var f=qn(t,l);u&&(f="if($event.target.composing)return;"+f),jn(e,"value","("+t+")"),Rn(e,c,f,null,!0),(s||a)&&Rn(e,"blur","$forceUpdate()")}function Yn(e){if(o(e[ds])){var t=Oi?"change":"input";e[t]=[].concat(e[ds],e[t]||[]),delete e[ds]}o(e[hs])&&(e.change=[].concat(e[hs],e.change||[]),delete e[hs])}function Qn(e,t,n){var r=qa;return function o(){null!==e.apply(null,arguments)&&er(t,o,n,r)}}function Zn(e,t,n,r,o){t=se(t),n&&(t=Qn(t,e,r)),qa.addEventListener(e,t,Ri?{capture:r,passive:o}:r)}function er(e,t,n,r){(r||qa).removeEventListener(e,t._withTask||t,n)}function tr(e,t){if(!r(e.data.on)||!r(t.data.on)){var n=t.data.on||{},o=e.data.on||{};qa=t.elm,Yn(n),pe(n,o,Zn,er,t.context),qa=void 0}}function nr(e,t){if(!r(e.data.domProps)||!r(t.data.domProps)){var n,i,a=t.elm,s=e.data.domProps||{},u=t.data.domProps||{};o(u.__ob__)&&(u=t.data.domProps=w({},u));for(n in s)r(u[n])&&(a[n]="");for(n in u){if(i=u[n],"textContent"===n||"innerHTML"===n){if(t.children&&(t.children.length=0),i===s[n])continue;1===a.childNodes.length&&a.removeChild(a.childNodes[0])}if("value"===n){a._value=i;var c=r(i)?"":String(i);rr(a,c)&&(a.value=c)}else a[n]=i}}}function rr(e,t){return!e.composing&&("OPTION"===e.tagName||or(e,t)||ir(e,t))}function or(e,t){var n=!0;try{n=document.activeElement!==e}catch(e){}return n&&e.value!==t}function ir(e,t){var n=e.value,r=e._vModifiers;if(o(r)){if(r.lazy)return!1;if(r.number)return d(n)!==d(t);if(r.trim)return n.trim()!==t.trim()}return n!==t}function ar(e){var t=sr(e.style);return e.staticStyle?w(e.staticStyle,t):t}function sr(e){return Array.isArray(e)?_(e):"string"==typeof e?ys(e):e}function ur(e,t){var n,r={};if(t)for(var o=e;o.componentInstance;)(o=o.componentInstance._vnode)&&o.data&&(n=ar(o.data))&&w(r,n);(n=ar(e.data))&&w(r,n);for(var i=e;i=i.parent;)i.data&&(n=ar(i.data))&&w(r,n);return r}function cr(e,t){var n=t.data,i=e.data;if(!(r(n.staticStyle)&&r(n.style)&&r(i.staticStyle)&&r(i.style))){var a,s,u=t.elm,c=i.staticStyle,l=i.normalizedStyle||i.style||{},f=c||l,p=sr(t.data.style)||{};t.data.normalizedStyle=o(p.__ob__)?w({},p):p;var d=ur(t,!0);for(s in f)r(d[s])&&xs(u,s,"");for(s in d)(a=d[s])!==f[s]&&xs(u,s,null==a?"":a)}}function lr(e,t){if(t&&(t=t.trim()))if(e.classList)t.indexOf(" ")>-1?t.split(/\s+/).forEach(function(t){return e.classList.add(t)}):e.classList.add(t);else{var n=" "+(e.getAttribute("class")||"")+" ";n.indexOf(" "+t+" ")<0&&e.setAttribute("class",(n+t).trim())}}function fr(e,t){if(t&&(t=t.trim()))if(e.classList)t.indexOf(" ")>-1?t.split(/\s+/).forEach(function(t){return e.classList.remove(t)}):e.classList.remove(t),e.classList.length||e.removeAttribute("class");else{for(var n=" "+(e.getAttribute("class")||"")+" ",r=" "+t+" ";n.indexOf(r)>=0;)n=n.replace(r," ");n=n.trim(),n?e.setAttribute("class",n):e.removeAttribute("class")}}function pr(e){if(e){if("object"==typeof e){var t={};return!1!==e.css&&w(t,Ts(e.name||"v")),w(t,e),t}return"string"==typeof e?Ts(e):void 0}}function dr(e){Ns(function(){Ns(e)})}function hr(e,t){var n=e._transitionClasses||(e._transitionClasses=[]);n.indexOf(t)<0&&(n.push(t),lr(e,t))}function vr(e,t){e._transitionClasses&&v(e._transitionClasses,t),fr(e,t)}function mr(e,t,n){var r=yr(e,t),o=r.type,i=r.timeout,a=r.propCount;if(!o)return n();var s=o===As?$s:js,u=0,c=function(){e.removeEventListener(s,l),n()},l=function(t){t.target===e&&++u>=a&&c()};setTimeout(function(){u0&&(n=As,l=a,f=i.length):t===Ss?c>0&&(n=Ss,l=c,f=u.length):(l=Math.max(a,c),n=l>0?a>c?As:Ss:null,f=n?n===As?i.length:u.length:0),{type:n,timeout:l,propCount:f,hasTransform:n===As&&Ls.test(r[Es+"Property"])}}function gr(e,t){for(;e.length1}function Tr(e,t){!0!==t.data.show&&xr(t)}function kr(e,t,n){Ar(e,t,n),(Oi||Ni)&&setTimeout(function(){Ar(e,t,n)},0)}function Ar(e,t,n){var r=t.value,o=e.multiple;if(!o||Array.isArray(r)){for(var i,a,s=0,u=e.options.length;s-1,a.selected!==i&&(a.selected=i);else if(T(Er(a),r))return void(e.selectedIndex!==s&&(e.selectedIndex=s));o||(e.selectedIndex=-1)}}function Sr(e,t){return t.every(function(t){return!T(t,e)})}function Er(e){return"_value"in e?e._value:e.value}function $r(e){e.target.composing=!0}function Or(e){e.target.composing&&(e.target.composing=!1,jr(e.target,"input"))}function jr(e,t){var n=document.createEvent("HTMLEvents");n.initEvent(t,!0,!0),e.dispatchEvent(n)}function Nr(e){return!e.componentInstance||e.data&&e.data.transition?e:Nr(e.componentInstance._vnode)}function Lr(e){var t=e&&e.componentOptions;return t&&t.Ctor.options.abstract?Lr(Te(t.children)):e}function Dr(e){var t={},n=e.$options;for(var r in n.propsData)t[r]=e[r];var o=n._parentListeners;for(var i in o)t[di(i)]=o[i];return t}function Rr(e,t){if(/\d-keep-alive$/.test(t.tag))return e("keep-alive",{props:t.componentOptions.propsData})}function Pr(e){for(;e=e.parent;)if(e.data.transition)return!0}function Ir(e,t){return t.key===e.key&&t.tag===e.tag}function Mr(e){e.elm._moveCb&&e.elm._moveCb(),e.elm._enterCb&&e.elm._enterCb()}function qr(e){e.data.newPos=e.elm.getBoundingClientRect()}function Hr(e){var t=e.data.pos,n=e.data.newPos,r=t.left-n.left,o=t.top-n.top;if(r||o){e.data.moved=!0;var i=e.elm.style;i.transform=i.WebkitTransform="translate("+r+"px,"+o+"px)",i.transitionDuration="0s"}}function Fr(e,t){var n=t?Js(t):Gs;if(n.test(e)){for(var r,o,i,a=[],s=[],u=n.lastIndex=0;r=n.exec(e);){o=r.index,o>u&&(s.push(i=e.slice(u,o)),a.push(JSON.stringify(i)));var c=Sn(r[1].trim());a.push("_s("+c+")"),s.push({"@binding":c}),u=o+r[0].length}return u=0&&a[o].lowerCasedTag!==s;o--);else o=0;if(o>=0){for(var u=a.length-1;u>=o;u--)t.end&&t.end(a[u].tag,n,r);a.length=o,i=o&&a[o-1].tag}else"br"===s?t.start&&t.start(e,[],!0,n,r):"p"===s&&(t.start&&t.start(e,[],!1,n,r),t.end&&t.end(e,n,r))}for(var o,i,a=[],s=t.expectHTML,u=t.isUnaryTag||gi,c=t.canBeLeftOpenTag||gi,l=0;e;){if(o=e,i&&Cu(i)){var f=0,p=i.toLowerCase(),d=Tu[p]||(Tu[p]=new RegExp("([\\s\\S]*?)(]*>)","i")),h=e.replace(d,function(e,n,r){return f=r.length,Cu(p)||"noscript"===p||(n=n.replace(//g,"$1").replace(//g,"$1")),$u(p,n)&&(n=n.slice(1)),t.chars&&t.chars(n),""});l+=e.length-h.length,e=h,r(p,l-f,l)}else{var v=e.indexOf("<");if(0===v){if(cu.test(e)){var m=e.indexOf("--\x3e");if(m>=0){t.shouldKeepComment&&t.comment(e.substring(4,m)),n(m+3);continue}}if(lu.test(e)){var y=e.indexOf("]>");if(y>=0){n(y+2);continue}}var g=e.match(uu);if(g){n(g[0].length);continue}var b=e.match(su);if(b){var x=l;n(b[0].length),r(b[1],x,l);continue}var w=function(){var t=e.match(iu);if(t){var r={tagName:t[1],attrs:[],start:l};n(t[0].length);for(var o,i;!(o=e.match(au))&&(i=e.match(nu));)n(i[0].length),r.attrs.push(i);if(o)return r.unarySlash=o[1],n(o[0].length),r.end=l,r}}();if(w){!function(e){var n=e.tagName,o=e.unarySlash;s&&("p"===i&&tu(n)&&r(i),c(n)&&i===n&&r(n));for(var l=u(n)||!!o,f=e.attrs.length,p=new Array(f),d=0;d=0){for(C=e.slice(v);!(su.test(C)||iu.test(C)||cu.test(C)||lu.test(C)||(T=C.indexOf("<",1))<0);)v+=T,C=e.slice(v);_=e.substring(0,v),n(v)}v<0&&(_=e,e=""),t.chars&&_&&t.chars(_)}if(e===o){t.chars&&t.chars(e);break}}r()}function Xr(e,t,n){return{type:1,tag:e,attrsList:t,attrsMap:ho(t),parent:n,children:[]}}function Jr(e,t){function n(e){e.pre&&(s=!1),yu(e.tag)&&(u=!1);for(var n=0;n':'
',_u.innerHTML.indexOf(" ")>0}function ai(e){if(e.outerHTML)return e.outerHTML;var t=document.createElement("div");return t.appendChild(e.cloneNode(!0)),t.innerHTML}/*! * Vue.js v2.5.17 * (c) 2014-2018 Evan You * Released under the MIT License. From ee04ffcec52131705e0c553f5a0afc83f03a28cd Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Thu, 18 Oct 2018 14:47:41 +0200 Subject: [PATCH 6/6] CS Fixes --- src/Configuration/Config.php | 4 +- src/Configuration/PathResolver.php | 8 +- src/Content/MediaFactory.php | 5 +- src/Controller/Async/Uploader.php | 11 +- src/Controller/Bolt/EditRecordController.php | 7 +- src/Media/Item.php | 43 ++-- src/Media/RequestHandler.php | 258 +++++++++---------- 7 files changed, 171 insertions(+), 165 deletions(-) diff --git a/src/Configuration/Config.php b/src/Configuration/Config.php index 0b5bde2c..829968fe 100644 --- a/src/Configuration/Config.php +++ b/src/Configuration/Config.php @@ -93,8 +93,8 @@ class Config /** * @param string $path - * @param bool $absolute - * @param mixed $additional + * @param bool $absolute + * @param mixed $additional * * @return string */ diff --git a/src/Configuration/PathResolver.php b/src/Configuration/PathResolver.php index 9657dfd6..a2338f21 100644 --- a/src/Configuration/PathResolver.php +++ b/src/Configuration/PathResolver.php @@ -93,9 +93,9 @@ class PathResolver * - `foo/bar` - A relative path that will be resolved against the root path. * - `/tmp` - An absolute path will be returned as is. * - * @param string $path the path - * @param bool $absolute if the path is relative, resolve it against the root path - * @param mixed $additional + * @param string $path the path + * @param bool $absolute if the path is relative, resolve it against the root path + * @param mixed $additional * * @return string */ @@ -132,7 +132,7 @@ class PathResolver } if (!empty($additional)) { - $path .= DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, (array) $additional); + $path .= \DIRECTORY_SEPARATOR . implode(\DIRECTORY_SEPARATOR, (array) $additional); } // Make sure we don't have lingering unneeded dir-seperators diff --git a/src/Content/MediaFactory.php b/src/Content/MediaFactory.php index 4b5d7426..c2cf44da 100644 --- a/src/Content/MediaFactory.php +++ b/src/Content/MediaFactory.php @@ -125,6 +125,7 @@ class MediaFactory /** * @param Item $item * @param $params + * * @return Media */ public function createFromUpload(Item $item, $params): Media @@ -138,7 +139,7 @@ class MediaFactory $area = 'files'; } - $targetFilename = $addedPath . DIRECTORY_SEPARATOR . $this->sanitiseFilename($item->getName()); + $targetFilename = $addedPath . \DIRECTORY_SEPARATOR . $this->sanitiseFilename($item->getName()); $source = $this->config->getPath('cache', true, ['uploads', $item->getId(), $item->getName()]); $target = $this->config->getPath($area, true, $targetFilename); @@ -159,6 +160,7 @@ class MediaFactory /** * @param string $filename + * * @return string */ private function sanitiseFilename(string $filename): string @@ -171,5 +173,4 @@ class MediaFactory return $filename . '.' . $extension; } - } diff --git a/src/Controller/Async/Uploader.php b/src/Controller/Async/Uploader.php index f7de7401..0adc659b 100644 --- a/src/Controller/Async/Uploader.php +++ b/src/Controller/Async/Uploader.php @@ -1,5 +1,7 @@ request->get('filepond', []); - foreach($items as $item) { + foreach ($items as $item) { $media = $this->mediaFactory->createFromUpload($item, current($params)); $this->manager->persist($media); $this->manager->flush(); @@ -54,4 +55,4 @@ class Uploader return new Response($media->getPath() . $media->getFilename()); } -} \ No newline at end of file +} diff --git a/src/Controller/Bolt/EditRecordController.php b/src/Controller/Bolt/EditRecordController.php index eebcda2c..394dbaa2 100644 --- a/src/Controller/Bolt/EditRecordController.php +++ b/src/Controller/Bolt/EditRecordController.php @@ -37,14 +37,15 @@ class EditRecordController extends BaseController /** * @Route("/edit/{id}", name="bolt_edit_record", methods={"GET"}) * - * @param string $id - * @param Request $request + * @param string $id + * @param Request $request * @param Content|null $content * - * @return Response * @throws \Twig_Error_Loader * @throws \Twig_Error_Runtime * @throws \Twig_Error_Syntax + * + * @return Response */ public function edit(string $id, Request $request, Content $content = null): Response { diff --git a/src/Media/Item.php b/src/Media/Item.php index 75c8021a..34183bd1 100644 --- a/src/Media/Item.php +++ b/src/Media/Item.php @@ -1,13 +1,14 @@ id = isset($id) ? $id : md5( uniqid(self::$item_counter++, true) ); + public function __construct($file, $id = null) + { + $this->id = isset($id) ? $id : md5(uniqid(self::$item_counter++, true)); $this->file = $file; $this->name = $file['name']; } - public function rename($name, $extension = null) { + public function rename($name, $extension = null) + { $info = pathinfo($this->name); - $this->name = $name . '.' . ( isset($extension) ? $extension : $info['extension'] ); + $this->name = $name . '.' . (isset($extension) ? $extension : $info['extension']); } - public function getId() { + public function getId() + { return $this->id; } - public function getFilename() { + public function getFilename() + { return $this->file['tmp_name']; } - public function getName() { + public function getName() + { return basename($this->name); } - public function getNameWithoutExtension() { + public function getNameWithoutExtension() + { $info = pathinfo($this->name); + return $info['filename']; } - public function getExtension() { + public function getExtension() + { $info = pathinfo($this->name); + return $info['extension']; } - public function getSize() { + public function getSize() + { return $this->file['size']; } - public function getType() { + public function getType() + { return $this->file['mime']; } } - diff --git a/src/Media/RequestHandler.php b/src/Media/RequestHandler.php index 885402a7..007659dd 100644 --- a/src/Media/RequestHandler.php +++ b/src/Media/RequestHandler.php @@ -1,11 +1,13 @@ tmp_dir = $this->config->getPath('cache', true, ['uploads']); } - /** * @param $str + * * @return bool */ - public function isFileId($str) { + public function isFileId($str) + { return preg_match($this->file_id_format, $str); } /** * @param $str + * * @return bool */ - public function isURL($str) { + public function isURL($str) + { return filter_var($str, FILTER_VALIDATE_URL); } /** - * Catch all exceptions so we can return a 500 error when the server bugs out + * Catch all exceptions so we can return a 500 error when the server bugs out. */ - public function catchExceptions() { + public function catchExceptions() + { set_exception_handler('FilePond\RequestHandler::handleException'); } - public function handleException($ex) { - + public function handleException($ex) + { // write to error log so we can still find out what's up error_log('Uncaught exception in class="' . get_class($ex) . '" message="' . $ex->getMessage() . '" line="' . $ex->getLine() . '"'); - + // clean up buffer ob_end_clean(); @@ -70,66 +76,63 @@ class RequestHandler http_response_code(500); } - private function createItem($file, $id = null) { + private function createItem($file, $id = null) + { return new Item($file, $id); } /** * @param $fieldName + * * @return array */ - public function loadFilesByField($fieldName) { - + public function loadFilesByField($fieldName) + { // See if files are posted as JSON string (each file being base64 encoded) $base64Items = $this->loadBase64FormattedFiles($fieldName); - + // retrieves posted file objects $fileItems = $this->loadFileObjects($fieldName); - + // retrieves files already on server $tmpItems = $this->loadFilesFromTemp($fieldName); - + // save newly received files to temp files folder (tmp items already are in that folder) $this->saveAsTempFiles(array_merge($base64Items, $fileItems)); - + // return items return array_merge($base64Items, $fileItems, $tmpItems); } - private function loadFileObjects($fieldName) { - + private function loadFileObjects($fieldName) + { $items = []; - if ( !isset($_FILES[$fieldName]) ) { + if (!isset($_FILES[$fieldName])) { return $items; } - + $FILE = $_FILES[$fieldName]; if (is_array($FILE['tmp_name'])) { - - foreach( $FILE['tmp_name'] as $index => $tmpName ) { - - array_push( $items, $this->createItem( array( + foreach ($FILE['tmp_name'] as $index => $tmpName) { + array_push($items, $this->createItem([ 'tmp_name' => $FILE['tmp_name'][$index], 'name' => $FILE['name'][$index], 'size' => $FILE['size'][$index], 'error' => $FILE['error'][$index], - 'type' => $FILE['type'][$index] - )) ); - + 'type' => $FILE['type'][$index], + ])); } - - } - else { - array_push( $items, $this->createItem($FILE) ); + } else { + array_push($items, $this->createItem($FILE)); } return $items; } - private function loadBase64FormattedFiles($fieldName) { - + private function loadBase64FormattedFiles($fieldName) + { /* // format: { @@ -144,7 +147,7 @@ class RequestHandler $items = []; - if ( !isset($_POST[$fieldName] ) ) { + if (!isset($_POST[$fieldName])) { return $items; } @@ -153,12 +156,11 @@ class RequestHandler // Turn values in array if is submitted as single value if (!is_array($values)) { - $values = isset($values) ? array($values) : array(); + $values = isset($values) ? [$values] : []; } // If files are found, turn base64 strings into actual file objects foreach ($values as $value) { - // suppress error messages, we'll just investigate the object later $obj = @json_decode($value); @@ -172,21 +174,22 @@ class RequestHandler continue; } - array_push($items, $this->createItem( $this->createTempFile($obj) ) ); + array_push($items, $this->createItem($this->createTempFile($obj))); } - + return $items; } - private function isEncodedFile($obj) { + private function isEncodedFile($obj) + { return isset($obj->id) && isset($obj->data) && isset($obj->name) && isset($obj->type) && isset($obj->size); } - private function loadFilesFromTemp($fieldName) { - + private function loadFilesFromTemp($fieldName) + { $items = []; - if ( !isset($_POST[$fieldName] ) ) { + if (!isset($_POST[$fieldName])) { return $items; } @@ -195,28 +198,28 @@ class RequestHandler // Turn values in array if is submitted as single value if (!is_array($values)) { - $values = isset($values) ? array($values) : array(); + $values = isset($values) ? [$values] : []; } // test if value is actually a file id foreach ($values as $value) { - if ( $this->isFileId($value) ) { + if ($this->isFileId($value)) { array_push($items, $this->createItem($this->getTempFile($value), $value)); } } - - return $items; + return $items; } - public function save($items, $path = 'uploads' . DIRECTORY_SEPARATOR) { - + public function save($items, $path = 'uploads' . \DIRECTORY_SEPARATOR) + { // is list of files - if ( is_array($items) ) { + if (is_array($items)) { $results = []; - foreach($items as $item) { + foreach ($items as $item) { array_push($results, $this->saveFile($item, $path)); } + return $results; } @@ -226,14 +229,17 @@ class RequestHandler /** * @param $file_id + * * @return bool */ - public function deleteTempFile($file_id) { + public function deleteTempFile($file_id) + { return $this->deleteTempDirectory($file_id); } /** * @param $url + * * @return array|bool */ public function getRemoteURLData($url) @@ -244,7 +250,7 @@ class RequestHandler curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $content = curl_exec($ch); - if ($content === FALSE) { + if ($content === false) { throw new Exception(curl_error($ch), curl_errno($ch)); } @@ -252,34 +258,33 @@ class RequestHandler $length = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); - curl_close ($ch); + curl_close($ch); $success = $code >= 200 && $code < 300; - return array( + return [ 'code' => $code, 'content' => $content, 'type' => $type, 'length' => $length, - 'success' => $success - ); - - } - catch(Exception $e) { + 'success' => $success, + ]; + } catch (Exception $e) { return null; } } - private function saveAsTempFiles($items) { - foreach($items as $item) { + private function saveAsTempFiles($items) + { + foreach ($items as $item) { $this->saveTempFile($item); } } - private function saveTempFile($file) { - + private function saveTempFile($file) + { // make sure path name is safe - $path = $this->getSecureTempPath() . $file->getId() . DIRECTORY_SEPARATOR; + $path = $this->getSecureTempPath() . $file->getId() . \DIRECTORY_SEPARATOR; // Creates a secure temporary directory to store the files in $this->createSecureDirectory($path); @@ -292,7 +297,9 @@ class RequestHandler $result = $this->moveFile($source, $target); // Was not saved - if ($result !== true) { return $result; } + if ($result !== true) { + return $result; + } // Make sure file is secure $this->setSecureFilePermissions($target); @@ -301,26 +308,22 @@ class RequestHandler return true; } - public function getTempFile($fileId) { - + public function getTempFile($fileId) + { // select all files in directory except .htaccess - foreach(glob($this->getSecureTempPath() . $fileId . DIRECTORY_SEPARATOR . '*.*') as $file) { - + foreach (glob($this->getSecureTempPath() . $fileId . \DIRECTORY_SEPARATOR . '*.*') as $file) { try { - - $handle = fopen($file, 'r'); + $handle = fopen($file, 'rb'); $content = fread($handle, filesize($file)); fclose($handle); - - return array( + + return [ 'name' => basename($file), 'content' => $content, 'type' => mime_content_type($file), - 'length' => filesize($file) - ); - - } - catch(Exception $e) { + 'length' => filesize($file), + ]; + } catch (Exception $e) { return null; } } @@ -328,31 +331,27 @@ class RequestHandler return false; } - public function getFile($file, $path) { - + public function getFile($file, $path) + { try { - - $filename = $path . DIRECTORY_SEPARATOR . $file; - $handle = fopen($filename, 'r'); + $filename = $path . \DIRECTORY_SEPARATOR . $file; + $handle = fopen($filename, 'rb'); $content = fread($handle, filesize($filename)); fclose($handle); - - return array( + + return [ 'name' => basename($filename), 'content' => $content, 'type' => mime_content_type($filename), - 'length' => filesize($filename) - ); - - } - catch(Exception $e) { + 'length' => filesize($filename), + ]; + } catch (Exception $e) { return null; } - } - private function saveFile($item, $path) { - + private function saveFile($item, $path) + { // nope if (!isset($item)) { return false; @@ -364,17 +363,14 @@ class RequestHandler } // is file object - else { - return $this->moveFileById($item->getId(), $path, $item->getName()); - } + return $this->moveFileById($item->getId(), $path, $item->getName()); } - private function moveFileById($fileId, $path, $fileName = null) { - + private function moveFileById($fileId, $path, $fileName = null) + { // select all files in directory except .htaccess - foreach(glob($this->getSecureTempPath() . $fileId . DIRECTORY_SEPARATOR . '*.*') as $file) { - + foreach (glob($this->getSecureTempPath() . $fileId . \DIRECTORY_SEPARATOR . '*.*') as $file) { $source = $file; $target = $this->getSecurePath($path); @@ -390,76 +386,77 @@ class RequestHandler return true; } - private function deleteTempDirectory($id) { - - @array_map('unlink', glob($this->getSecureTempPath() . $id . DIRECTORY_SEPARATOR . '{.,}*', GLOB_BRACE)); + private function deleteTempDirectory($id) + { + @array_map('unlink', glob($this->getSecureTempPath() . $id . \DIRECTORY_SEPARATOR . '{.,}*', GLOB_BRACE)); // remove temp directory @rmdir($this->getSecureTempPath() . $id); - } - private function createTempFile($file) { - + private function createTempFile($file) + { $tmp = tmpfile(); - fwrite($tmp, base64_decode($file->data)); + fwrite($tmp, base64_decode($file->data, true)); $meta = stream_get_meta_data($tmp); $filename = $meta['uri']; - return array( + return [ 'error' => 0, 'size' => filesize($filename), 'type' => $file->type, 'name' => $file->name, 'tmp_name' => $filename, - 'tmp' => $tmp - ); - + 'tmp' => $tmp, + ]; } - private function moveFile($source, $target) { - + private function moveFile($source, $target) + { if (is_uploaded_file($source)) { return move_uploaded_file($source, $target); } - else { - $tmp = fopen($source, 'r'); - $result = file_put_contents( $target, fread($tmp, filesize($source) ) ); - fclose($tmp); - return $result; - } + $tmp = fopen($source, 'rb'); + $result = file_put_contents($target, fread($tmp, filesize($source))); + fclose($tmp); + + return $result; } - private function getSecurePath($path) { - return pathinfo($path)['dirname'] . DIRECTORY_SEPARATOR . basename($path) . DIRECTORY_SEPARATOR; + private function getSecurePath($path) + { + return pathinfo($path)['dirname'] . \DIRECTORY_SEPARATOR . basename($path) . \DIRECTORY_SEPARATOR; } - private function getSecureTempPath() { + private function getSecureTempPath() + { return $this->getSecurePath($this->tmp_dir); } - private function setSecureFilePermissions($target) { - $stat = stat( dirname($target) ); + private function setSecureFilePermissions($target) + { + $stat = stat(dirname($target)); $perms = $stat['mode'] & 0000666; @chmod($target, $perms); } - private function createDirectory($path) { + private function createDirectory($path) + { if (is_dir($path)) { return false; } mkdir($path, 0755, true); + return true; } - private function createSecureDirectory($path) { - + private function createSecureDirectory($path) + { // !! If directory already exists we assume security is handled !! // Test if directory already exists and correct if ($this->createDirectory($path)) { - // Add .htaccess file for security purposes $content = '# Don\'t list directory contents IndexIgnore * @@ -467,11 +464,6 @@ IndexIgnore * AddHandler cgi-script .php .pl .jsp .asp .sh .cgi Options -ExecCGI -Indexes'; file_put_contents($path . '.htaccess', $content); - } - } - } - -