diff options
Diffstat (limited to 'vendor/jbroadway')
-rw-r--r-- | vendor/jbroadway/urlify/.github/workflows/ci.yml | 41 | ||||
-rw-r--r-- | vendor/jbroadway/urlify/INSTALL | 13 | ||||
-rw-r--r-- | vendor/jbroadway/urlify/LICENSE | 27 | ||||
-rw-r--r-- | vendor/jbroadway/urlify/README.md | 108 | ||||
-rw-r--r-- | vendor/jbroadway/urlify/URLify.php | 591 | ||||
-rw-r--r-- | vendor/jbroadway/urlify/composer.json | 31 | ||||
-rw-r--r-- | vendor/jbroadway/urlify/scripts/downcode.php | 25 | ||||
-rw-r--r-- | vendor/jbroadway/urlify/scripts/filter.php | 25 | ||||
-rw-r--r-- | vendor/jbroadway/urlify/scripts/transliterate.php | 25 |
9 files changed, 886 insertions, 0 deletions
diff --git a/vendor/jbroadway/urlify/.github/workflows/ci.yml b/vendor/jbroadway/urlify/.github/workflows/ci.yml new file mode 100644 index 000000000..869334f57 --- /dev/null +++ b/vendor/jbroadway/urlify/.github/workflows/ci.yml @@ -0,0 +1,41 @@ +name: "Continuous Integration" + +on: + - push + - pull_request + +env: + COMPOSER_FLAGS: "--no-interaction --prefer-dist" + +jobs: + tests: + name: "CI" + + runs-on: ubuntu-latest + + strategy: + matrix: + php-version: + - "7.2" + - "7.3" + - "7.4" + - "8.0" + + dependencies: [highest] + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + + - name: "Setup PHP" + uses: "shivammathur/setup-php@v2" + with: + coverage: "none" + php-version: "${{ matrix.php-version }}" + + - name: "Install dependencies" + run: | + composer update ${{ env.COMPOSER_FLAGS }} + + - name: "Run tests" + run: "composer exec phpunit -- --verbose" diff --git a/vendor/jbroadway/urlify/INSTALL b/vendor/jbroadway/urlify/INSTALL new file mode 100644 index 000000000..92e1bb013 --- /dev/null +++ b/vendor/jbroadway/urlify/INSTALL @@ -0,0 +1,13 @@ +To install URLify, you can add it as a dependency by downloading Composer, the PHP package manager. + +`$ curl -s http://getcomposer.org/installer | php` + +Then run this command to install Composer: + +`$ php composer.phar install` + +For more details, see https://getcomposer.org/ + +Then run this command to install the URLify library: + +`$ composer require jbroadway/urlify` diff --git a/vendor/jbroadway/urlify/LICENSE b/vendor/jbroadway/urlify/LICENSE new file mode 100644 index 000000000..5f4f225dd --- /dev/null +++ b/vendor/jbroadway/urlify/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) Django Software Foundation and individual contributors. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. Neither the name of Django nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/jbroadway/urlify/README.md b/vendor/jbroadway/urlify/README.md new file mode 100644 index 000000000..0dcfab189 --- /dev/null +++ b/vendor/jbroadway/urlify/README.md @@ -0,0 +1,108 @@ +# URLify for PHP + +![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/jbroadway/urlify/Continuous%20Integration/master) +![Packagist License](https://img.shields.io/packagist/l/jbroadway/urlify) +![Packagist Version](https://img.shields.io/packagist/v/jbroadway/urlify) +![Packagist PHP Version Support](https://img.shields.io/packagist/php-v/jbroadway/urlify) +![Packagist Downloads](https://img.shields.io/packagist/dt/jbroadway/urlify) + +A fast PHP slug generator and transliteration library, started as a PHP port of +[URLify.js](https://github.com/django/django/blob/master/django/contrib/admin/static/admin/js/urlify.js) +from the Django project. + +Handles symbols from latin languages, Arabic, Azerbaijani, Bulgarian, Burmese, Croatian, Czech, Danish, Esperanto, +Estonian, Finnish, French, Switzerland (French), Austrian (French), Georgian, German, Switzerland (German), +Austrian (German), Greek, Hindi, Kazakh, Latvian, Lithuanian, Norwegian, Persian, Polish, Romanian, Russian, Swedish, +Serbian, Slovak, Turkish, Ukrainian and Vietnamese, and many other via `ASCII::to_transliterate()`. + +Symbols it cannot transliterate it can omit or replace with a specified character. + +## Installation + +Install the latest version with: + +```bash +$ composer require jbroadway/urlify +``` + +## Usage + +First, include Composer's autoloader: + +```php +require_once 'vendor/autoload.php'; +``` + +To generate slugs for URLs: + +```php +<?php + +echo URLify::slug (' J\'étudie le français '); +// "jetudie-le-francais" + +echo URLify::slug ('Lo siento, no hablo español.'); +// "lo-siento-no-hablo-espanol" +``` + +To generate slugs for file names: + +```php +<?php + +echo URLify::filter ('фото.jpg', 60, "", true); +// "foto.jpg" +``` + +To simply transliterate characters: + +```php +<?php + +echo URLify::downcode ('J\'étudie le français'); +// "J'etudie le francais" + +echo URLify::downcode ('Lo siento, no hablo español.'); +// "Lo siento, no hablo espanol." + +/* Or use transliterate() alias: */ + +echo URLify::transliterate ('Lo siento, no hablo español.'); +// "Lo siento, no hablo espanol." +``` + +To extend the character list: + +```php +<?php + +URLify::add_chars ([ + '¿' => '?', '®' => '(r)', '¼' => '1/4', + '½' => '1/2', '¾' => '3/4', '¶' => 'P' +]); + +echo URLify::downcode ('¿ ® ¼ ¼ ¾ ¶'); +// "? (r) 1/2 1/2 3/4 P" +``` + +To extend the list of words to remove: + +```php +<?php + +URLify::remove_words (['remove', 'these', 'too']); +``` + +To prioritize a certain language map: + +```php +<?php + +echo URLify::filter ('Ägypten und Österreich besitzen wie üblich ein Übermaß an ähnlich öligen Attachés', 60, 'de'); +// "aegypten-und-oesterreich-besitzen-wie-ueblich-ein-uebermass-aehnlich-oeligen-attaches" + +echo URLify::filter ('Cağaloğlu, çalıştığı, müjde, lazım, mahkûm', 60, 'tr'); +// "cagaloglu-calistigi-mujde-lazim-mahkum" +``` + +Please note that the "ü" is transliterated to "ue" in the first case, whereas it results in a simple "u" in the latter. diff --git a/vendor/jbroadway/urlify/URLify.php b/vendor/jbroadway/urlify/URLify.php new file mode 100644 index 000000000..be46bd83a --- /dev/null +++ b/vendor/jbroadway/urlify/URLify.php @@ -0,0 +1,591 @@ +<?php + +/** + * A fast PHP slug generator and transliteration library, started as a PHP port of URLify.js + * from the Django project + fallback via "Portable ASCII". + * + * - https://github.com/django/django/blob/master/django/contrib/admin/static/admin/js/urlify.js + * - https://github.com/voku/portable-ascii + * + * Handles symbols from latin languages, Arabic, Azerbaijani, Bulgarian, Burmese, Croatian, Czech, Danish, Esperanto, + * Estonian, Finnish, French, Switzerland (French), Austrian (French), Georgian, German, Switzerland (German), + * Austrian (German), Greek, Hindi, Kazakh, Latvian, Lithuanian, Norwegian, Persian, Polish, Romanian, Russian, Swedish, + * Serbian, Slovak, Turkish, Ukrainian and Vietnamese ... and many other via "ASCII::to_transliterate()". + */ +class URLify +{ + /** + * The language-mapping array. + * + * ISO 639-1 codes: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes + * + * @var array[] + */ + public static $maps = []; + + /** + * List of words to remove from URLs. + * + * @var array[] + */ + public static $remove_list = []; + + /** + * An array of strings that will convert into the separator-char - used by "URLify::filter()". + * + * @var string[] + */ + private static $arrayToSeparator = []; + + /** + * Add new strings the will be replaced with the separator. + * + * @param array $array <p>An array of things that should replaced by the separator.</p> + * @param bool $merge <p>Keep the previous (default) array-to-separator array.</p> + * + * @return void + * + * @psalm-param string[] $array + */ + public static function add_array_to_separator(array $array, bool $merge = true) + { + if ($merge === true) { + self::$arrayToSeparator = \array_unique( + \array_merge( + self::$arrayToSeparator, + $array + ) + ); + } else { + self::$arrayToSeparator = $array; + } + } + + /** + * Add new characters to the list. `$map` should be a hash. + * + * @param array $map + * @param string|null $language + * + * @return void + * + * @psalm-param array<string, string> $map + */ + public static function add_chars(array $map, string $language = null) + { + $language_key = $language ?? \uniqid('urlify', true); + + if (isset(self::$maps[$language_key])) { + self::$maps[$language_key] = \array_merge($map, self::$maps[$language_key]); + } else { + self::$maps[$language_key] = $map; + } + } + + /** + * @return void + */ + public static function reset_chars() + { + self::$maps = []; + } + + /** + * Transliterates characters to their ASCII equivalents. + * $language specifies a priority for a specific language. + * The latter is useful if languages have different rules for the same character. + * + * @param string $string <p>The input string.</p> + * @param string $language <p>Your primary language.</p> + * @param string $unknown <p>Character use if character unknown. (default is ?).</p> + * + * @return string + */ + public static function downcode( + string $string, + string $language = 'en', + string $unknown = '' + ): string { + $string = self::expandString($string, $language); + + foreach (self::$maps as $mapsInner) { + foreach ($mapsInner as $orig => $replace) { + $string = \str_replace($orig, $replace, $string); + } + } + + $string = \voku\helper\ASCII::to_ascii( + $string, + $language, + false, + true + ); + + return \voku\helper\ASCII::to_transliterate( + $string, + $unknown, + false + ); + } + + /** + * Convert a String to URL slug. Wraps <strong>filter()</strong> with a simpler + * set of defaults for typical usage in generating blog post slugs. + * + * @param string $string <p>The text you want to convert.</p> + * @param int $maxLength <p>Max. length of the output string, set to "0" (zero) to + * disable it</p> + * @param string $separator <p>Define a new separator for the words.</p> + * @param string $language <p>The language you want to convert to.</p> + */ + public static function slug( + string $string, + int $maxLength = 200, + string $separator = '-', + string $language = 'en' + ): string { + return self::filter ($string, $maxLength, $language, false, false, true, $separator); + } + + /** + * Convert a String to URL. + * + * e.g.: "Petty<br>theft" to "Petty-theft" + * + * @param string $string <p>The text you want to convert.</p> + * @param int $maxLength <p>Max. length of the output string, set to "0" (zero) to + * disable it</p> + * @param string $language <p>The language you want to convert to.</p> + * @param bool $fileName <p> + * Keep the "." from the extension e.g.: "imaäe.jpg" => + * "image.jpg" + * </p> + * @param bool $removeWords <p> + * Remove some "words" from the string.<br /> + * Info: Set extra words via <strong>remove_words()</strong>. + * </p> + * @param bool $strToLower <p>Use <strong>strtolower()</strong> at the end.</p> + * @param bool|string $separator <p>Define a new separator for the words.</p> + * + * @return string + */ + public static function filter( + string $string, + int $maxLength = 200, + string $language = 'en', + bool $fileName = false, + bool $removeWords = false, + bool $strToLower = true, + $separator = '-' + ): string { + if ($string === '') { + return ''; + } + + // fallback + if ($language === '') { + $language = 'en'; + } + + // separator-fallback + if ($separator === false) { + $separator = '_'; + } + if ($separator === true || $separator === '') { + $separator = '-'; + } + + // escaped separator + $separatorEscaped = \preg_quote($separator, '/'); + + // use defaults, if there are no values + if (self::$arrayToSeparator === []) { + self::reset_array_to_separator(); + } + + // remove apostrophes which are not used as quotes around a string + if (\strpos($string, "'") !== false) { + $stringTmp = \preg_replace("/(\w)'(\w)/u", '${1}${2}', $string); + if ($stringTmp !== null) { + $string = (string) $stringTmp; + } + } + + // replace with $separator + $string = (string) \preg_replace( + self::$arrayToSeparator, + $separator, + $string + ); + + // remove all other html-tags + if ( + \strpos($string, '<') !== false + || + \strpos($string, '>') !== false + ) { + $string = \strip_tags($string); + } + + // use special language replacer + $string = self::downcode($string, $language); + + // replace with $separator, again + $string = (string) \preg_replace( + self::$arrayToSeparator, + $separator, + $string + ); + + // remove all these words from the string before urlifying + $removeWordsSearch = '//'; + if ($removeWords === true) { + $removeList = self::get_remove_list($language); + if ($removeList !== []) { + $removeWordsSearch = '/\b(?:' . \implode('|', $removeList) . ')\b/ui'; + } + } + + // keep the "." from e.g.: a file-extension? + if ($fileName) { + $removePatternAddOn = '.'; + } else { + $removePatternAddOn = ''; + } + + $string = (string) \preg_replace( + [ + // 1) remove un-needed chars + '/[^' . $separatorEscaped . $removePatternAddOn . '\-a-zA-Z0-9\s]/u', + // 2) convert spaces to $separator + '/[\s]+/u', + // 3) remove some extras words + $removeWordsSearch, + // 4) remove double $separator's + '/[' . ($separatorEscaped ?: ' ') . ']+/u', + // 5) remove $separator at the end + '/[' . ($separatorEscaped ?: ' ') . ']+$/u', + ], + [ + '', + $separator, + '', + $separator, + '', + ], + $string + ); + + // "substr" only if "$length" is set + if ( + $maxLength + && + $maxLength > 0 + && + \strlen($string) > $maxLength + ) { + $string = (string) \substr(\trim($string, $separator), 0, $maxLength); + } + + // convert to lowercase + if ($strToLower === true) { + $string = \strtolower($string); + } + + // trim "$separator" from beginning and end of the string + return \trim($string, $separator); + } + + /** + * Append words to the remove list. Accepts either single words or an array of words. + * + * @param string|string[] $words + * @param string $language + * @param bool $merge <p>Keep the previous (default) remove-words array.</p> + * + * @return void + */ + public static function remove_words($words, string $language = 'en', bool $merge = true) + { + if (\is_array($words) === false) { + $words = [$words]; + } + + foreach ($words as $removeWordKey => $removeWord) { + $words[$removeWordKey] = \preg_quote($removeWord, '/'); + } + + if ($merge === true) { + self::$remove_list[$language] = \array_unique( + \array_merge( + self::get_remove_list($language), + $words + ) + ); + } else { + self::$remove_list[$language] = $words; + } + } + + /** + * Reset the internal "self::$arrayToSeparator" to the default values. + * + * @return void + */ + public static function reset_array_to_separator() + { + self::$arrayToSeparator = [ + '/"|&|<|>|–|—/i', // ", &, <, >, –, — + '/⁻|-|—|_|"|`|´|\'/', + "#/\r\n|\r|\n|<br.*/?>#isU", + ]; + } + + /** + * reset the word-remove-array + * + * @param string $language + * + * @return void + */ + public static function reset_remove_list(string $language = 'en') + { + if ($language === '') { + return; + } + + $language_orig = $language; + $language = self::get_language_for_reset_remove_list($language); + if ($language === '') { + return; + } + + $stopWords = new \voku\helper\StopWords(); + + try { + self::$remove_list[$language_orig] = $stopWords->getStopWordsFromLanguage($language); + } catch (\voku\helper\StopWordsLanguageNotExists $e) { + self::$remove_list[$language_orig] = []; + } + } + + /** + * Alias of `URLify::downcode()`. + * + * @param string $string + * @param string $language + * + * @return string + */ + public static function transliterate(string $string, string $language = 'en'): string + { + return self::downcode($string, $language); + } + + /** + * Expands the given string replacing some special parts for words. + * e.g. "lorem@ipsum.com" is replaced by "lorem at ipsum dot com". + * + * Most of these transformations have been inspired by the pelle/slugger + * project, distributed under the Eclipse Public License. + * Copyright 2012 Pelle Braendgaard + * + * @param string $string The string to expand + * @param string $language + * + * @return string The result of expanding the string + */ + protected static function expandString(string $string, string $language = 'en'): string + { + $string = self::expandCurrencies($string, $language); + + return self::expandSymbols($string, $language); + } + + /** + * @param string $language + * + * @return string + */ + private static function get_language_for_reset_remove_list(string $language) + { + if ($language === '') { + return ''; + } + + if ( + \strpos($language, '_') === false + && + \strpos($language, '-') === false + ) { + $language = \strtolower($language); + } else { + $regex = '/(?<first>[a-z]{2}).*/i'; + $language = \strtolower((string) \preg_replace($regex, '$1', $language)); + } + + return $language; + } + + /** + * Expands the numeric currencies in euros, dollars, pounds + * and yens that the given string may include. + * + * @param string $string + * @param string $language + * + * @return string + */ + private static function expandCurrencies(string $string, string $language = 'en') + { + if ( + \strpos($string, '€') === false + && + \strpos($string, '$') === false + && + \strpos($string, '£') === false + && + \strpos($string, '¥') === false + ) { + return $string; + } + + if ($language === 'de') { + return (string) \preg_replace( + [ + '/(?:\s|^)(\d+)(?: )*€(?:\s|$)/', + '/(?:\s|^)\$(?: )*(\d+)(?:\s|$)/', + '/(?:\s|^)£(?: )*(\d+)(?:\s|$)/', + '/(?:\s|^)¥(?: )*(\d+)(?:\s|$)/', + '/(?:\s|^)(\d+)[.|,](\d+)(?: )*€(?:\s|$)/', + '/(?:\s|^)\$(?: )*(\d+)[.|,](\d+)(?:\s|$)/', + '/(?:\s|^)£(?: )*(\d+)[.|,](\d+)(?:\s|$)/', + ], + [ + ' \1 Euro ', + ' \1 Dollar ', + ' \1 Pound ', + ' \1 Yen ', + ' \1 Euro \2 Cent ', + ' \1 Dollar \2 Cent ', + ' \1 Pound \2 Pence ', + ], + $string + ); + } + + return (string) \preg_replace( + [ + '/(?:\s|^)1(?: )*€(?:\s|$)/', + '/(?:\s|^)(\d+)(?: )*€(?:\s|$)/', + '/(?:\s|^)\$(?: )*1(?:\s|$)/', + '/(?:\s|^)\$(?: )*(\d+)(?:\s|$)/', + '/(?:\s|^)£(?: )*1(?:\s|$)/', + '/(?:\s|^)£(?: )*(\d+)(?:\s|$)/', + '/(?:\s|^)¥(?: )*(\d+)(?:\s|$)/', + '/(?:\s|^)1[.|,](\d+)(?: )*€(?:\s|$)/', + '/(?:\s|^)(\d+)[.|,](\d+)(?: )*€(?:\s|$)/', + '/(?:\s|^)1[.|,](\d+)(?: )*$(?:\s|$)/', + '/(?:\s|^)\$(?: )*(\d+)[.|,](\d+)(?:\s|$)/', + '/(?:\s|^)1[.|,](\d+)(?: )*£(?:\s|$)/', + '/(?:\s|^)£(?: )*(\d+)[.|,](\d+)(?:\s|$)/', + ], + [ + ' 1 Euro ', + ' \1 Euros ', + ' 1 Dollar ', + ' \1 Dollars ', + ' 1 Pound ', + ' \1 Pounds ', + ' \1 Yen ', + ' 1 Euros \1 Cents ', + ' \1 Euros \2 Cents ', + ' 1 Dollars \1 Cents ', + ' \1 Dollars \2 Cents ', + ' 1 Pounds \1 Pence ', + ' \1 Pounds \2 Pence ', + ], + $string + ); + } + + /** + * Expands the special symbols that the given string may include, such as '@', '.', '#' and '%'. + * + * @param string $string + * @param string $language + * + * @return string + */ + private static function expandSymbols(string $string, string $language = 'en') + { + if ( + \strpos($string, '©') === false + && + \strpos($string, '®') === false + && + \strpos($string, '@') === false + && + \strpos($string, '&') === false + && + \strpos($string, '%') === false + && + \strpos($string, '=') === false + ) { + return $string; + } + + $maps = \voku\helper\ASCII::charsArray(true); + + return (string) \preg_replace( + [ + '/\s*©\s*/', + '/\s*®\s*/', + '/\s*@\s*/', + '/\s*&\s*/', + '/\s*%\s*/', + '/(\s*=\s*)/', + ], + [ + $maps['latin_symbols']['©'], + $maps['latin_symbols']['®'], + $maps['latin_symbols']['@'], + $maps[$language]['&'] ?? '&', + $maps[$language]['%'] ?? '%', + $maps[$language]['='] ?? '=', + ], + $string + ); + } + + /** + * return the "self::$remove_list[$language]" array + * + * @param string $language + * + * @return array<mixed> + */ + private static function get_remove_list(string $language = 'en') + { + // check for language + if ($language === '') { + return []; + } + + // set remove-array + if (!isset(self::$remove_list[$language])) { + self::reset_remove_list($language); + } + + // check for array + if ( + !isset(self::$remove_list[$language]) + || + empty(self::$remove_list[$language]) + ) { + return []; + } + + return self::$remove_list[$language]; + } +} diff --git a/vendor/jbroadway/urlify/composer.json b/vendor/jbroadway/urlify/composer.json new file mode 100644 index 000000000..d24b8a2d9 --- /dev/null +++ b/vendor/jbroadway/urlify/composer.json @@ -0,0 +1,31 @@ +{ + "name": "jbroadway/urlify", + "type": "library", + "description": "A fast PHP slug generator and transliteration library that converts non-ascii characters for use in URLs.", + "keywords": ["urlify","transliterate","translit","transliteration","url","encode","downcode","slug","slugify","slugs","link","iconv","blogging","blogs","unicode","ascii","seo"], + "homepage": "https://github.com/jbroadway/urlify", + "license": "BSD-3-Clause-Clear", + "authors": [ + { + "name": "Johnny Broadway", + "email": "johnny@johnnybroadway.com", + "homepage": "http://www.johnnybroadway.com/" + } + ], + "require": { + "php": ">=7.2", + "voku/portable-ascii": "^1.4", + "voku/stop-words": "^2.0" + }, + "require-dev": { + "phpunit/phpunit": "^8.5" + }, + "autoload": { + "psr-0": { "URLify": "" } + }, + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + } +} diff --git a/vendor/jbroadway/urlify/scripts/downcode.php b/vendor/jbroadway/urlify/scripts/downcode.php new file mode 100644 index 000000000..018e7d4fa --- /dev/null +++ b/vendor/jbroadway/urlify/scripts/downcode.php @@ -0,0 +1,25 @@ +<?php + +// +// Downcode the provided argument or stdin if the argument was not present +// + +require_once \dirname(__DIR__) . '/vendor/autoload.php'; +require_once \dirname(__DIR__) . '/URLify.php'; + +// Print usage and exit if arguments are invalid +if ($argc < 1 || $argc > 2) { + die('Usage (argument): php ' . \basename(__FILE__) . " \"<text to downcode>\"\nUsage (pipe): <Arbitrary command> | php " . \basename(__FILE__) . "\n"); +} + +// Process the provided argument +$piped = false; +if ($argc === 2) { + $s = $argv[1]; +// Or read from stdin if the argument wasn't present +} else { + $piped = true; + $s = \file_get_contents('php://stdin'); +} + +echo URLify::downcode($s) . ($piped ? "\n" : ''); diff --git a/vendor/jbroadway/urlify/scripts/filter.php b/vendor/jbroadway/urlify/scripts/filter.php new file mode 100644 index 000000000..d20c31594 --- /dev/null +++ b/vendor/jbroadway/urlify/scripts/filter.php @@ -0,0 +1,25 @@ +<?php + +// +// Filter the provided argument or stdin if the argument was not present +// + +require_once \dirname(__DIR__) . '/vendor/autoload.php'; +require_once \dirname(__DIR__) . '/URLify.php'; + +// Print usage and exit if arguments are invalid +if ($argc < 1 || $argc > 2) { + die('Usage (argument): php ' . \basename(__FILE__) . " \"<text to filter>\"\nUsage (pipe): <Arbitrary command> | php " . \basename(__FILE__) . "\n"); +} + +// Process the provided argument +$piped = false; +if ($argc === 2) { + $s = $argv[1]; +// Or read from stdin if the argument wasn't present +} else { + $piped = true; + $s = \file_get_contents('php://stdin'); +} + +echo URLify::filter($s) . ($piped ? "\n" : ''); diff --git a/vendor/jbroadway/urlify/scripts/transliterate.php b/vendor/jbroadway/urlify/scripts/transliterate.php new file mode 100644 index 000000000..1970b506c --- /dev/null +++ b/vendor/jbroadway/urlify/scripts/transliterate.php @@ -0,0 +1,25 @@ +<?php + +// +// Transliterate the provided argument or stdin if the argument was not present +// + +require_once \dirname(__DIR__) . '/vendor/autoload.php'; +require_once \dirname(__DIR__) . '/URLify.php'; + +// Print usage and exit if arguments are invalid +if ($argc < 1 || $argc > 2) { + die('Usage (argument): php ' . \basename(__FILE__) . " \"<text to transliterate>\"\nUsage (pipe): <Arbitrary command> | php " . \basename(__FILE__) . "\n"); +} + +// Process the provided argument +$piped = false; +if ($argc === 2) { + $s = $argv[1]; +// Or read from stdin if the argument wasn't present +} else { + $piped = true; + $s = \file_get_contents('php://stdin'); +} + +echo URLify::transliterate($s) . ($piped ? "\n" : ''); |