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


PHP Strings::webalize方法代码示例

本文整理汇总了PHP中Nette\Utils\Strings::webalize方法的典型用法代码示例。如果您正苦于以下问题:PHP Strings::webalize方法的具体用法?PHP Strings::webalize怎么用?PHP Strings::webalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nette\Utils\Strings的用法示例。


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

示例1: preUpload

 /**
  * @ORM\PreFlush()
  */
 public function preUpload()
 {
     if ($this->file) {
         if ($this->file instanceof FileUpload) {
             $basename = $this->file->getSanitizedName();
             $basename = $this->suggestName($this->getFilePath(), $basename);
             $this->setName($basename);
         } else {
             $basename = trim(Strings::webalize($this->file->getBasename(), '.', FALSE), '.-');
             $basename = $this->suggestName(dirname($this->file->getPathname()), $basename);
             $this->setName($basename);
         }
         if ($this->_oldPath && $this->_oldPath !== $this->path) {
             @unlink($this->getFilePathBy($this->_oldProtected, $this->_oldPath));
         }
         if ($this->file instanceof FileUpload) {
             $this->file->move($this->getFilePath());
         } else {
             copy($this->file->getPathname(), $this->getFilePath());
         }
         return $this->file = NULL;
     }
     if (($this->_oldPath || $this->_oldProtected !== NULL) && ($this->_oldPath != $this->path || $this->_oldProtected != $this->protected)) {
         $oldFilePath = $this->getFilePathBy($this->_oldProtected !== NULL ? $this->_oldProtected : $this->protected, $this->_oldPath ?: $this->path);
         if (file_exists($oldFilePath)) {
             rename($oldFilePath, $this->getFilePath());
         }
     }
 }
开发者ID:svobodni,项目名称:web,代码行数:32,代码来源:FileEntity.php

示例2: insert

 /**
  * @param $data
  */
 public function insert($data, $code = NULL)
 {
     $this->cleanData($data);
     if (isset($data['map_coords'])) {
         $coords = Geolocation::getCoordsFromText($data['map_coords']);
         $data['lat'] = $coords[0];
         $data['lon'] = $coords[1];
     }
     $to_code = isset($data['locality_nickname']) ? $data['name'] . " " . $data['locality_nickname'] : $data['name'];
     $data['code'] = $code ? $code : \Nette\Utils\Strings::webalize($to_code);
     $data['stroller'] = isset($data['stroller']) ? 1 : 0;
     $data['visible'] = isset($data['visible']) ? 1 : 0;
     $data['show_in_catalogue'] = isset($data['show_in_catalogue']) ? 1 : 0;
     $data['show_in_calendar'] = isset($data['show_in_calendar']) ? 1 : 0;
     $data['created'] = new \DibiDateTime(time());
     $cats = $data['categories'];
     $res = dibi::select('code')->from('subject')->where('code = %s', $data['code'])->fetch();
     if ($res) {
         throw new \Exception("Duplicate entry '" . $data['code'] . "' for key 'code'", 1062);
         return false;
     }
     unset($data['categories']);
     dibi::begin();
     dibi::query('INSERT INTO [subject]', $data);
     $id = dibi::insertId();
     dibi::query('DELETE FROM [subject_x_category] WHERE [subject_id]=%i', $id);
     foreach ($cats as $k => $n) {
         dibi::query('INSERT INTO [subject_x_category] SET [subject_id]=%i', $id, ', [category_id]=%i', $n);
     }
     if (isset($data["user_id"])) {
         dibi::query('INSERT INTO [subject_x_user] SET [subject_id]=%i', $id, ', [user_id]=%i', $data["user_id"]);
     }
     dibi::commit();
     return $id;
 }
开发者ID:soundake,项目名称:pd,代码行数:38,代码来源:ModelSubjects.php

示例3: renderDefault

 public function renderDefault($id, $nazev)
 {
     $clanek = $this->clanky->get($this->id);
     if (empty($clanek) || empty($clanek['id'])) {
         throw new \Nette\Application\BadRequestException();
     }
     $this->template->skupina = $this->clanky->getSouvisejici($id);
     $web_nazev = Nette\Utils\Strings::webalize($clanek['titulek']);
     if ($nazev != $web_nazev) {
         // throw new \Nette\Application\BadRequestException();
         $this->redirect("this", array("id" => $clanek['id'], "nazev" => $web_nazev));
     }
     $this->clanky->precteno($this->id);
     $this->template->clanek = $clanek;
     $this->template->title = $clanek['titulek'];
     $this->template->komentare = $this->komentare->getForClanek($this->id);
     $hodnoceni = $this->clanky->getHodnoceni($this->id);
     if (empty($hodnoceni['plus'])) {
         $hodnoceni['plus'] = 0;
     }
     if (empty($hodnoceni['minus'])) {
         $hodnoceni['minus'] = 0;
     }
     $this->template->hodnoceni = $hodnoceni;
     $this->template->moje_hodnoceni = $this->clanky->getHodnoceniByIp($this->id, $_SERVER['REMOTE_ADDR']);
 }
开发者ID:stanley89,项目名称:piratskelisty,代码行数:26,代码来源:ClanekPresenter.php

示例4: addAutoloadConfig

 /**
  * @param string $path
  * @param string $find
  * @param int $depth
  */
 public function addAutoloadConfig($path, $find = 'config.neon', $depth = -1)
 {
     // Development
     if (!$this->cacheConfig && $this->isDevelopment()) {
         foreach (Finder::find($find)->from($path)->limitDepth($depth) as $file) {
             $this->addConfig((string) $file);
         }
         return;
     }
     // Production
     $directory = $this->parameters['tempDir'] . '/cache/configs';
     $cachePath = $directory . '/' . Strings::webalize(str_replace(dirname($this->parameters['appDir']), '', $path)) . '.neon';
     if (file_exists($cachePath)) {
         $this->addConfig($cachePath);
         return;
     }
     $encoder = new Encoder();
     $decoder = new Decoder();
     @mkdir($directory);
     $content = [];
     foreach (Finder::find($find)->from($path)->limitDepth($depth) as $file) {
         $content = Helpers::merge($content, $decoder->decode(file_get_contents($file)));
     }
     file_put_contents($cachePath, $encoder->encode($content));
     $this->addConfig($cachePath);
 }
开发者ID:ThunboltCMS,项目名称:configuration,代码行数:31,代码来源:Configuration.php

示例5: setUrl

 public function setUrl($url = null)
 {
     if (!$url) {
         $url = Strings::webalize($this->id . " " . $this->title);
     }
     $this->setString("url", $url, 1, self::MAX_URL_LENGTH);
 }
开发者ID:jaromir92,项目名称:Sportwin,代码行数:7,代码来源:Article.php

示例6: startup

 protected function startup()
 {
     parent::startup();
     $this->position = time();
     $this->route->setLocalUrl(Strings::webalize(Strings::random()));
     $this->getRoute()->setPublished(TRUE);
 }
开发者ID:svobodni,项目名称:web,代码行数:7,代码来源:AbstractItemEntity.php

示例7: __construct

 /**
  * @param string $name
  * @param Language $language
  */
 public function __construct($name, Language $language)
 {
     $this->name = $name;
     $this->language = $language;
     $this->slug = Strings::webalize($name);
     $this->scenarios = new ArrayCollection();
 }
开发者ID:stekycz,项目名称:dwarf-search,代码行数:11,代码来源:Character.php

示例8: startup

 public function startup()
 {
     parent::startup();
     $this->dir = new DirEntity();
     $this->dir->setInvisible(TRUE);
     $this->dir->setName(Strings::webalize(get_class($this)) . Strings::random());
 }
开发者ID:svobodni,项目名称:web,代码行数:7,代码来源:AbstractImageEntity.php

示例9: addGallery

 /**
  * Vytvoreni nove galerie
  * @param type $values - name,editor_id,public[bool],start_public,stop_public
  * 
  * @return type 
  */
 public function addGallery($files, $galleryName, $conf = NULL)
 {
     if (!is_array($conf)) {
         $params = $this->context->getParameters();
         $driveConfigPath = $params['projectDir'] . '/config/drive.neon';
         if (!is_file($driveConfigPath)) {
             $driveConfigPath = __DIR__ . '/examples/gal.neon';
         }
         $conf = \Nette\Utils\Neon::decode(file_get_contents($driveConfigPath));
         $conf = $conf['gallery'];
     }
     $this->setStorage('gallery');
     $userId = 0;
     if ($this->presenter) {
         $userId = $this->presenter->user->isLoggedIn() ? $this->presenter->user->getId() : 0;
     }
     $galPath = isset($conf['path']) && !empty($conf['path']) ? Strings::webalize($conf['path']) : '';
     $id = $this->createGallery($galleryName, $userId, $galPath, serialize($conf));
     $galleryFolder = $this->relativePath;
     $this->mkDir($this->getFullPath(TRUE) . '/thumbs', FALSE, TRUE);
     $this->mkDir($this->getFullPath(TRUE) . '/originals', FALSE, TRUE);
     $this->_addFilesToGallery($galleryFolder, $files, $userId, $id, $conf);
     if (isset($conf['preserveOriginals']) && !$conf['preserveOriginals']) {
         $this->setPath($galleryFolder);
         $this->rmDir($this->getFullPath(TRUE) . '/originals/');
     }
     return $id;
 }
开发者ID:jurasm2,项目名称:bubo,代码行数:34,代码来源:Drive.php

示例10: handleUploadReciever

 public function handleUploadReciever()
 {
     $uploader = new \App\Pictures\UploadHandler();
     $uploader->allowedExtensions = ['jpeg', 'jpg', 'png', 'gif'];
     $uploader->chunksFolder = __DIR__ . '/../../www/chunks';
     $name = Nette\Utils\Strings::webalize($uploader->getName(), '.');
     //TODO: picture optimalization (?)
     $result = $uploader->handleUpload(__DIR__ . '/../../www/uploads', $name);
     try {
         $picture = $this->pictures->findOneBy(['uuid' => $uploader->getUuid()]);
         if (!$picture) {
             //FIXME: toto není optimální (zejména kvůli rychlosti)
             $picture = new Picture();
         }
         $picture->uuid = $uploader->getUuid();
         $picture->name = $name;
         $picture->created = new \DateTime('now');
         $this->pictures->save($picture);
     } catch (\Exception $exc) {
         $uploader->handleDelete(__DIR__ . '/../../www/uploads');
         $this->sendResponse(new Nette\Application\Responses\JsonResponse(['error' => $exc->getMessage()]));
     }
     //TODO: napřed předat do šablony nová data
     $this->redrawControl('pictures');
     $this->sendResponse(new Nette\Application\Responses\JsonResponse($result));
 }
开发者ID:mrtnzlml,项目名称:zlml.cz,代码行数:26,代码来源:PicturesPresenter.php

示例11: create

 public function create(Product $product, FileUpload $fileUpload)
 {
     switch ($fileUpload->getContentType()) {
         case 'image/jpeg':
             $suffix = 'jpg';
             break;
         case 'image/png':
             $suffix = 'png';
             break;
         case 'image/gif':
             $suffix = 'gif';
             break;
         default:
             throw new EntityInvalidArgumentException(sprintf('File is of an unknown type %s.', $fileUpload->getContentType()));
     }
     $baseName = sprintf('%s-%%s.%s', Strings::webalize($product->getName()), $suffix);
     do {
         $fileName = sprintf($baseName, Random::generate(5, '0-9a-zA-Z'));
         $path = sprintf('%s/%s', $this->imagesDir, $fileName);
     } while (file_exists($path));
     $fileUpload->move($path);
     $image = new ProductImage($product, $fileName);
     $this->createEntity($image);
     $product->addImage($image);
     return $image;
 }
开发者ID:shophp,项目名称:shophp,代码行数:26,代码来源:ProductImageService.php

示例12: uploadImgFormSucceeded

 /**
  * @param $form
  * @param $values
  */
 public function uploadImgFormSucceeded($form, $values)
 {
     $values = $form->getValues();
     foreach ($values->img as $img) {
         // ActiveRow
         if ($img->isOk()) {
             $row = $this->imagesRepository->findAll()->insert(array('users_id' => $this->user->id, 'title' => $photoName = Strings::webalize($img->getName(), '.'), 'origin' => 'noSet', 'created_at' => new \DateTime()));
             $photo = Image::fromFile($img);
             $photoID = $row->getPrimary();
             $photoX = $photo->height;
             $photoY = $photo->width;
             $path = __DIR__ . '/../../../web/images/' . $photoID;
             //mkdir('/var/www/m/' . $photoID, 0755, true);
             //mkdir('/var/www/skeleton/web/images/aaannn', 0755, true);
             if ($photoX > 102 or $photoY > 768) {
                 $photo->resize(1024, 768, Image::SHRINK_ONLY);
             }
             mkdir($path, 0755, TRUE);
             $photo->save($path . '/' . $photoName);
             //$photoXGA = $photo->resize(1024, 768, Image::SHRINK_ONLY);
             //$photoSVGA->resize(800, 600, Image::SHRINK_ONLY);
             //$photoSVGA->resize(800, 600, Image::SHRINK_ONLY);
             //$imgName = $img->name;
             $this->flashMessage($this->translator->translate('ui.your-image-has-been-sent'), 'alert alert-success');
         }
     }
 }
开发者ID:buffus,项目名称:skeleton,代码行数:31,代码来源:UploadImgPresenter.php

示例13: actionFiles

 /**
  * @param $id
  *
  * @return AssetsLoader\Application\FileResponse|Application\Responses\TextResponse
  */
 public function actionFiles($id)
 {
     if (NULL === ($item = $this->fileCache->getItem(Utils\Strings::webalize($id)))) {
         return new Application\Responses\TextResponse('');
     }
     return new AssetsLoader\Application\FileResponse($item[Caching\FileCache::CONTENT]);
 }
开发者ID:ales-zrak,项目名称:assets-loader,代码行数:12,代码来源:Presenter.php

示例14: getLogger

 private function getLogger($channel)
 {
     $l = $this->logger;
     if (isset($channel)) {
         $l = $l->channel(Strings::webalize($channel));
     }
     return $l;
 }
开发者ID:blitzik,项目名称:vycetky-doctrine,代码行数:8,代码来源:MonologSubscriber.php

示例15: prepareSafeName

 /**
  * Funkce pro připravení bezpečného jména pro atributy, data fields atd.
  * @param $string
  * @return string
  */
 public static function prepareSafeName($string)
 {
     $string = str_replace('-', '_', Strings::webalize($string, true));
     while (strpos($string, '__') > 0) {
         $string = str_replace('__', '_', $string);
     }
     return trim($string, '_');
 }
开发者ID:kizi,项目名称:easyminer-easyminercenter,代码行数:13,代码来源:StringsHelper.php


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