当前位置: 首页>>代码示例>>PHP>>正文


PHP URLify类代码示例

本文整理汇总了PHP中URLify的典型用法代码示例。如果您正苦于以下问题:PHP URLify类的具体用法?PHP URLify怎么用?PHP URLify使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了URLify类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: publishToPage

 public function publishToPage(Page $c, $data, $controls)
 {
     $slug = array_filter($controls, function ($item) {
         if ($item instanceof UrlSlugCorePageProperty) {
             return true;
         }
         return false;
     });
     $this->addPageTypeComposerControlRequestValue('cName', $data['name']);
     if (!count($slug) && $c->isPageDraft()) {
         $txt = new \URLify();
         $this->addPageTypeComposerControlRequestValue('cHandle', $txt->filter($data['name']));
     }
     parent::publishToPage($c, $data, $controls);
 }
开发者ID:ceko,项目名称:concrete5-1,代码行数:15,代码来源:NameCorePageProperty.php

示例2: filter

 public function filter($value)
 {
     URLify::$remove_list = array();
     $value = URLify::filter($value, 60, 'de');
     $value = str_replace('-', '_', $value);
     return $value;
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:7,代码来源:Ascii.php

示例3: upload

 /**
  * {@inheritdoc}
  */
 public function upload($fp, $dst, $name, $tmpname)
 {
     $this->setConnectorFromPlugin();
     // upload file by elfinder.
     $result = parent::upload($fp, $dst, $name, $tmpname);
     $name = $result['name'];
     $filtered = \URLify::filter($result['name'], 80);
     if (strcmp($name, $filtered) != 0) {
         /*$arg = array('target' => $file['hash'], 'name' => $filtered);
           $elFinder->exec('rename', $arg);*/
         $this->rename($result['hash'], $filtered);
     }
     $realPath = $this->realpath($result['hash']);
     if (!empty($realPath)) {
         // Getting file info
         //$info = $elFinder->exec('file', array('target' => $file['hash']));
         /** @var elFinderVolumeLocalFileSystem $volume */
         //$volume = $info['volume'];
         //$root = $volume->root();
         //var/www/chamilogits/data/courses/NEWONE/document
         $realPathRoot = $this->getCourseDocumentSysPath();
         // Removing course path
         $realPath = str_replace($realPathRoot, '/', $realPath);
         \FileManager::add_document($this->connector->course, $realPath, 'file', intval($result['size']), $result['name']);
     }
     return $result;
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:30,代码来源:CourseDriver.php

示例4: execute

 public function execute(Stdio $stdio, array $params = [])
 {
     if (strpos($params['source'], 'data/') !== 0) {
         throw new \DomainException('The source must be in the data directory.');
     }
     if (strpos($params['target'], 'data/') !== 0) {
         throw new \DomainException('The target must be in the data directory.');
     }
     $params['source'] = substr($params['source'], strlen('data/'));
     $params['target'] = substr($params['target'], strlen('data/'));
     $match = preg_match('/^(?:.*?\\/)?([0-9]{4}-[0-9]{2}-[0-9]{2}\\.|[0-9]+\\.|)([^\\/]*)$/', $params['source'], $matches);
     $matches[1] = trim($matches[1], '.');
     if ($params['--date']) {
         $matches[1] = (new \DateTime())->format('Y-m-d');
     }
     if ($params['--title']) {
         $matches[2] = \URLify::filter($params['--title']);
     }
     $file = trim($params['target'], '/') . '/';
     $file .= $params['--date'] ? $matches[1] . '.' : '';
     $file .= $matches[2];
     $this->hooks->call('before.move');
     $this->data->move($params['source'], $file);
     if ($params['--title']) {
         $data = $this->data->read($file);
         $data['title'] = $params['--title'];
         $this->data->write($file, $data);
     }
     $stdio->outln('<<magenta>>' . $params['source'] . ' moved to ' . $file . '<<reset>>');
     $this->hooks->call('after.move');
     return Status::SUCCESS;
 }
开发者ID:erickmerchant,项目名称:wright,代码行数:32,代码来源:MoveCommand.php

示例5: setFile

 public function setFile($title, $fieldName)
 {
     $storage = new \Upload\Storage\FileSystem(self::PATH_ORIGINALS);
     $this->file = new \Upload\File($fieldName, $storage);
     $filename = \URLify::filter($title);
     $this->file->setName($filename . '-' . uniqid());
     $this->file->addValidations([new \Upload\Validation\Mimetype(['image/png', 'image/jpg', 'image/jpeg', 'image/gif']), new \Upload\Validation\Size('5M')]);
 }
开发者ID:supercluster,项目名称:catalog,代码行数:8,代码来源:UploaderService.php

示例6: __construct

 /**
  * LogFile constructor.
  *
  * @param string $name
  * @param string $clientSlug
  * @param array  $args
  */
 public function __construct($name, $clientSlug, $args)
 {
     setlocale(LC_ALL, 'en_US.UTF8');
     $this->name = $name;
     $this->slug = \URLify::filter($name);
     $this->collectionSlug = \URLify::filter($clientSlug);
     $this->args = $args;
     $this->lines = new ArrayCollection();
     $this->loggers = new ArrayCollection();
 }
开发者ID:syonix,项目名称:log-viewer-lib,代码行数:17,代码来源:LogFile.php

示例7: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     if (Yii::$app->request->isPost) {
         if (isset($_POST['filename'])) {
             $this->fileName = \URLify::filter(pathinfo($_POST['filename'], PATHINFO_FILENAME), 255, "", true) . '_' . uniqid() . '.' . pathinfo($_POST['filename'], PATHINFO_EXTENSION);
             $upload_dir = $this->uploadDir;
             $upload_file = $this->fileName;
             $uploader = new FileUpload('uploadfile');
             $uploader->newFileName = $this->fileName;
             $uploader->sizeLimit = $this->fileSizeLimit;
             // Handle the upload
             $result = $uploader->handleUpload($upload_dir);
             unset($_POST['filename']);
             if (!$result) {
                 $upload_result = json_encode(array('success' => false, 'msg' => $uploader->getErrorMsg()));
             } else {
                 if ($this->isImage($upload_dir . $upload_file)) {
                     //
                     $image_name = $upload_dir . $upload_file;
                     // resize with calculate aspect ratio
                     list($image_width, $image_height, $type, $attr) = getimagesize($image_name);
                     $ratio = $image_width / $image_height;
                     if ($ratio > 1) {
                         $target_width = $this->resize_max_width;
                         $target_height = $this->resize_max_width / $ratio;
                     } else {
                         $target_width = $this->resize_max_height * $ratio;
                         $target_height = $this->resize_max_height;
                     }
                     // resize image if original dimension is bigger from max size
                     if ($target_width < $this->resize_max_width || $target_height < $this->resize_max_height) {
                         Image::thumbnail($image_name, $target_width, $target_height, ManipulatorInterface::THUMBNAIL_INSET)->save($image_name);
                     }
                     // apply watermark
                     if ($this->watermark) {
                         Image::watermark($image_name, $this->watermark)->save($image_name);
                     }
                 }
                 // thumbnails create
                 if ($this->thumbnail && $this->isImage($image_name) && ($this->thumbnail_width > 0 && $this->thumbnail_height > 0)) {
                     Image::thumbnail($image_name, $this->thumbnail_width, $this->thumbnail_height)->save($upload_dir . 'thumbs/' . $upload_file);
                 }
                 $upload_result = ['success' => true, 'filelink' => $upload_file];
             }
             Yii::$app->response->format = Response::FORMAT_JSON;
             return $upload_result;
         }
     } else {
         throw new BadRequestHttpException(Yii::t('upload', 'ONLY_POST_REQUEST'));
     }
 }
开发者ID:plathir,项目名称:yii2-smart-upload,代码行数:54,代码来源:FileUploadAction.php

示例8: filter

 /**
  * @param string $value
  * @return string
  */
 public function filter($value)
 {
     $transliterated = \URLify::transliterate($value);
     if ($this->replaceSpacesWithDashes) {
         $filter = new SeparatorToSeparator(' ', '_');
         $transliterated = $filter->filter($transliterated);
     } else {
         if ($this->replaceSpacesWithSeparator) {
             $filter = new SeparatorToSeparator(' ', $this->separator);
             $transliterated = $filter->filter($transliterated);
         }
     }
     return $transliterated;
 }
开发者ID:spalax,项目名称:zf2-libs,代码行数:18,代码来源:Transliterate.php

示例9: actionNovo

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionNovo()
 {
     $model = new Depoimento();
     $professor = Professor::model()->findByPk($_POST['Depoimento']['id_professor']);
     if (!empty($_POST['Depoimento'])) {
         if (empty($_POST['Depoimento']['nome'])) {
             unset($_POST['Depoimento']['nome']);
         }
         $model->attributes = $_POST['Depoimento'];
         $model->id_disciplina = empty($_POST['Depoimento']['id_disciplina']) ? null : $_POST['Depoimento']['id_disciplina'];
         if ($model->save()) {
             Yii::app()->user->setFlash('success', "Seu depoimento foi enviado com sucesso e está aguardando aprovação.");
             $this->redirect(Yii::app()->baseUrl . '/professor/' . $model->id_professor . '/' . URLify::filter($professor->nome));
         }
     }
 }
开发者ID:andrewinston,项目名称:professoresdaect,代码行数:20,代码来源:DepoimentoController.php

示例10: asciify

 /** Takes text and converts it to an ASCII-only string (characters with code between 32 and 127, plus \t, \n and \r).
  * @param string $text The text to be converted.
  * @param string $locale='' The locale for the string. If not specified we consider the current locale.
  * @return string
  */
 public function asciify($text, $locale = '')
 {
     if (!strlen($locale)) {
         $locale = \Localization::activeLocale();
     }
     $language = substr($locale, 0, strcspn($locale, '_'));
     $text = \URLify::downcode($text, $language);
     if (preg_match('/[^\\t\\r\\n\\x20-\\x7e]/', $text)) {
         if (function_exists('iconv')) {
             $t = @iconv(APP_CHARSET, 'US-ASCII//IGNORE//TRANSLIT', $text);
             if (is_string($t)) {
                 $text = $t;
             }
         }
         $text = preg_replace('/[^\\t\\r\\n\\x20-\\x7e]/', '', $text);
     }
     return $text;
 }
开发者ID:meixelsberger,项目名称:concrete5-5.7.0,代码行数:23,代码来源:Text.php

示例11: new_channel_init

function new_channel_init(&$a)
{
    $cmd = argc() > 1 ? argv(1) : '';
    if ($cmd === 'autofill.json') {
        require_once 'library/urlify/URLify.php';
        $result = array('error' => false, 'message' => '');
        $n = trim($_REQUEST['name']);
        $x = strtolower(URLify::transliterate($n));
        $test = array();
        // first name
        if (strpos($x, ' ')) {
            $test[] = legal_webbie(substr($x, 0, strpos($x, ' ')));
        }
        if ($test[0]) {
            // first name plus first initial of last
            $test[] = strpos($x, ' ') ? $test[0] . legal_webbie(trim(substr($x, strpos($x, ' '), 2))) : '';
            // first name plus random number
            $test[] = $test[0] . mt_rand(1000, 9999);
        }
        // fullname
        $test[] = legal_webbie($x);
        // fullname plus random number
        $test[] = legal_webbie($x) . mt_rand(1000, 9999);
        json_return_and_die(check_webbie($test));
    }
    if ($cmd === 'checkaddr.json') {
        require_once 'library/urlify/URLify.php';
        $result = array('error' => false, 'message' => '');
        $n = trim($_REQUEST['nick']);
        $x = strtolower(URLify::transliterate($n));
        $test = array();
        $n = legal_webbie($x);
        if (strlen($n)) {
            $test[] = $n;
            $test[] = $n . mt_rand(1000, 9999);
        }
        for ($y = 0; $y < 100; $y++) {
            $test[] = 'id' . mt_rand(1000, 9999);
        }
        json_return_and_die(check_webbie($test));
    }
}
开发者ID:Gillesq,项目名称:hubzilla,代码行数:42,代码来源:new_channel.php

示例12: execute

 public function execute(Stdio $stdio, array $params = [])
 {
     if (strpos($params['target'], 'data/') !== 0) {
         throw new \DomainException('The target must be in the data directory.');
     }
     $params['target'] = substr($params['target'], strlen('data/'));
     if (!empty($params['--related'])) {
         foreach ($params['--related'] as $key => $related) {
             if (strpos($related, 'data/') !== 0) {
                 throw new \DomainException('Each --related must be in the data directory.');
             }
             $params['--related'][$key] = substr(dirname($related), strlen('data/')) . '/' . pathinfo($related, PATHINFO_FILENAME);
         }
     }
     $data = [];
     foreach (['title', 'summary', '--related'] as $param_key) {
         if (!empty($params[$param_key])) {
             $data[trim($param_key, '-')] = $params[$param_key];
         }
     }
     $file = '';
     if ($params['target']) {
         $file = trim($params['target'], '/') . '/';
     }
     if ($params['--date']) {
         $file .= (new \DateTime())->format('Y-m-d') . '.';
     }
     $file .= \URLify::filter($data['title']);
     $file .= $params['--ext'] ? $params['--ext'] : '.md';
     $file = trim($file, '/');
     $this->hooks->call('before.make');
     $this->data->write($file, $data);
     $stdio->outln('<<magenta>>' . $file . ' published on ' . (new \DateTime())->format('Y-m-d') . '<<reset>>');
     $this->hooks->call('after.make');
     return Status::SUCCESS;
 }
开发者ID:erickmerchant,项目名称:wright,代码行数:36,代码来源:MakeCommand.php

示例13: item_post

function item_post(&$a)
{
    // This will change. Figure out who the observer is and whether or not
    // they have permission to post here. Else ignore the post.
    if (!local_channel() && !remote_channel() && !x($_REQUEST, 'commenter')) {
        return;
    }
    require_once 'include/security.php';
    $uid = local_channel();
    $channel = null;
    $observer = null;
    /**
     * Is this a reply to something?
     */
    $parent = x($_REQUEST, 'parent') ? intval($_REQUEST['parent']) : 0;
    $parent_mid = x($_REQUEST, 'parent_mid') ? trim($_REQUEST['parent_mid']) : '';
    $remote_xchan = x($_REQUEST, 'remote_xchan') ? trim($_REQUEST['remote_xchan']) : false;
    $r = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($remote_xchan));
    if ($r) {
        $remote_observer = $r[0];
    } else {
        $remote_xchan = $remote_observer = false;
    }
    $profile_uid = x($_REQUEST, 'profile_uid') ? intval($_REQUEST['profile_uid']) : 0;
    require_once 'include/identity.php';
    $sys = get_sys_channel();
    if ($sys && $profile_uid && $sys['channel_id'] == $profile_uid && is_site_admin()) {
        $uid = intval($sys['channel_id']);
        $channel = $sys;
        $observer = $sys;
    }
    if (x($_REQUEST, 'dropitems')) {
        require_once 'include/items.php';
        $arr_drop = explode(',', $_REQUEST['dropitems']);
        drop_items($arr_drop);
        $json = array('success' => 1);
        echo json_encode($json);
        killme();
    }
    call_hooks('post_local_start', $_REQUEST);
    //	 logger('postvars ' . print_r($_REQUEST,true), LOGGER_DATA);
    $api_source = x($_REQUEST, 'api_source') && $_REQUEST['api_source'] ? true : false;
    $consensus = intval($_REQUEST['consensus']);
    // 'origin' (if non-zero) indicates that this network is where the message originated,
    // for the purpose of relaying comments to other conversation members.
    // If using the API from a device (leaf node) you must set origin to 1 (default) or leave unset.
    // If the API is used from another network with its own distribution
    // and deliveries, you may wish to set origin to 0 or false and allow the other
    // network to relay comments.
    // If you are unsure, it is prudent (and important) to leave it unset.
    $origin = $api_source && array_key_exists('origin', $_REQUEST) ? intval($_REQUEST['origin']) : 1;
    // To represent message-ids on other networks - this will create an item_id record
    $namespace = $api_source && array_key_exists('namespace', $_REQUEST) ? strip_tags($_REQUEST['namespace']) : '';
    $remote_id = $api_source && array_key_exists('remote_id', $_REQUEST) ? strip_tags($_REQUEST['remote_id']) : '';
    $owner_hash = null;
    $message_id = x($_REQUEST, 'message_id') && $api_source ? strip_tags($_REQUEST['message_id']) : '';
    $created = x($_REQUEST, 'created') ? datetime_convert('UTC', 'UTC', $_REQUEST['created']) : datetime_convert();
    $post_id = x($_REQUEST, 'post_id') ? intval($_REQUEST['post_id']) : 0;
    $app = x($_REQUEST, 'source') ? strip_tags($_REQUEST['source']) : '';
    $return_path = x($_REQUEST, 'return') ? $_REQUEST['return'] : '';
    $preview = x($_REQUEST, 'preview') ? intval($_REQUEST['preview']) : 0;
    $categories = x($_REQUEST, 'category') ? escape_tags($_REQUEST['category']) : '';
    $webpage = x($_REQUEST, 'webpage') ? intval($_REQUEST['webpage']) : 0;
    $pagetitle = x($_REQUEST, 'pagetitle') ? escape_tags(urlencode($_REQUEST['pagetitle'])) : '';
    $layout_mid = x($_REQUEST, 'layout_mid') ? escape_tags($_REQUEST['layout_mid']) : '';
    $plink = x($_REQUEST, 'permalink') ? escape_tags($_REQUEST['permalink']) : '';
    $obj_type = x($_REQUEST, 'obj_type') ? escape_tags($_REQUEST['obj_type']) : ACTIVITY_OBJ_NOTE;
    // allow API to bulk load a bunch of imported items with sending out a bunch of posts.
    $nopush = x($_REQUEST, 'nopush') ? intval($_REQUEST['nopush']) : 0;
    /*
     * Check service class limits
     */
    if ($uid && !x($_REQUEST, 'parent') && !x($_REQUEST, 'post_id')) {
        $ret = item_check_service_class($uid, $_REQUEST['webpage'] == ITEM_WEBPAGE ? true : false);
        if (!$ret['success']) {
            notice(t($ret['message']) . EOL);
            if (x($_REQUEST, 'return')) {
                goaway($a->get_baseurl() . "/" . $return_path);
            }
            killme();
        }
    }
    if ($pagetitle) {
        require_once 'library/urlify/URLify.php';
        $pagetitle = strtolower(URLify::transliterate($pagetitle));
    }
    $item_flags = $item_restrict = 0;
    $route = '';
    $parent_item = null;
    $parent_contact = null;
    $thr_parent = '';
    $parid = 0;
    $r = false;
    if ($parent || $parent_mid) {
        if (!x($_REQUEST, 'type')) {
            $_REQUEST['type'] = 'net-comment';
        }
        if ($obj_type == ACTIVITY_OBJ_POST) {
            $obj_type = ACTIVITY_OBJ_COMMENT;
        }
//.........这里部分代码省略.........
开发者ID:einervonvielen,项目名称:redmatrix,代码行数:101,代码来源:item.php

示例14: purify_username

 /**
  * Modifies a given username accordingly to the specification for valid characters and length.
  * @param $username string                The input username.
  * @param bool $strict (optional)        When this flag is TRUE, the result is guaranteed for full compliance, otherwise compliance may be partial. The default value is FALSE.
  * @param string $encoding (optional)    The character encoding for the input names. If it is omitted, the platform character set will be used by default.
  * @return string                        The resulting purified username.
  */
 public static function purify_username($username, $strict = false, $encoding = null)
 {
     if ($strict) {
         // 1. Conversion of unacceptable letters (latinian letters with accents for example) into ASCII letters in order they not to be totally removed.
         // 2. Applying the strict purifier.
         // 3. Length limitation.
         $return = api_get_setting('login_is_email') == 'true' ? substr(preg_replace(USERNAME_PURIFIER_MAIL, '', $username), 0, USERNAME_MAX_LENGTH) : substr(preg_replace(USERNAME_PURIFIER, '', $username), 0, USERNAME_MAX_LENGTH);
         $return = URLify::transliterate($return);
         return $return;
     }
     // 1. Applying the shallow purifier.
     // 2. Length limitation.
     return substr(preg_replace(USERNAME_PURIFIER_SHALLOW, '', $username), 0, USERNAME_MAX_LENGTH);
 }
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:21,代码来源:usermanager.lib.php

示例15: transliterate

 /**
  * Converts UTF8 into Latin
  *
  * @param $value
  *
  * @return mixed
  */
 public static function transliterate($value)
 {
     return \URLify::transliterate($value);
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:11,代码来源:InputHelper.php


注:本文中的URLify类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。