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


PHP String::webalize方法代码示例

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


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

示例1: testWebalize

 /**
  * webalize test.
  * @return void
  */
 public function testWebalize()
 {
     $this->assertEquals("zlutoucky-kun-oooo", String::webalize("&ŽLUŤOUČKÝ KŮŇ öőôo!"));
     // &ŽLUŤOUČKÝ KŮŇ öőôo!
     $this->assertEquals("ZLUTOUCKY-KUN-oooo", String::webalize("&ŽLUŤOUČKÝ KŮŇ öőôo!", NULL, FALSE));
     // &ŽLUŤOUČKÝ KŮŇ öőôo!
     $this->assertEquals("1-4-!", String::webalize("¼!", '!'));
 }
开发者ID:vrana,项目名称:nette,代码行数:12,代码来源:NetteStringTest.php

示例2: _save

 public function _save($values)
 {
     $values['parent'] = (int) $values['parent'];
     $values['slug'] = String::webalize($values['title']);
     $position = (int) db::select('max(position)')->from(':table:')->where('parent = %i', $values['parent'])->fetchSingle();
     $values['position'] = $position + 1;
     db::insert(':table:', $values)->execute();
     return array('id' => db::getInsertId(), 'title' => $values['title'], 'parent_id' => $values['parent'], 'position' => $values['position']);
 }
开发者ID:bazo,项目名称:Mokuji,代码行数:9,代码来源:AdminCategoriesModel.php

示例3: handleFilename

 /**
  * treats filename for potentionally dangerous characters ensuring safe saving to filesystem
  * enables '.' except the very first and very last character for security reasons
  * @param string
  * @return string
  * @throws InvalidFilenameException
  */
 public static function handleFilename($filename)
 {
     $filename = String::webalize($filename, '.');
     //	check if '.' is the very first or very last character - should be enough to check that
     if (strpos($filename, '.') == 0 or strrpos($filename, '.') == strlen($filename) - 1) {
         //        	throw new InvalidFilenameException('Zadajte platný názov súboru! Nie sú povolené bodky na začiatku ani na konci názvu súboru.');
         throw new InvalidFilenameException('Enter valid filename! Dots are not allowed at the very start nor the very end of filename.');
     }
     return $filename;
 }
开发者ID:radypala,项目名称:maga-website,代码行数:17,代码来源:FileModel.php

示例4: _save

 public function _save($values)
 {
     $values['slug'] = String::webalize($values['title']);
     if (isset($values['link'])) {
         if ($values['link'] > 0) {
             $link = array();
             $slug = $values['slug'];
             if ($values['category'] > 0) {
                 $cat_model = new Admin_CategoriesModel();
                 $cat = $cat_model->getById((int) $values['category']);
                 $slug = $cat->slug . '/' . $slug;
             }
             $link['title'] = $values['title'];
             $link['url'] = $slug;
             $link['parent'] = 0;
             $link['level'] = 1;
             $link['menu_id'] = (int) $values['link'];
             $link_model = new Admin_MenuItemsModel();
             $link_model->create($link);
             //refresh table alias
             $this->__after_startup();
         }
         unset($values['link']);
     }
     $values['content_type'] = 'page';
     if (!isset($values['publish_time'])) {
         $values['publish_time'] = time();
     }
     $values['publish_time'] = db::datetime($values['publish_time']);
     if (isset($values['homepage'])) {
         if ($values['homepage'] == 1) {
             $update = array('homepage' => 0);
             db::update(':table:', $update)->execute();
         }
     }
     db::insert(':table:', $values)->execute();
     return db::getInsertId();
 }
开发者ID:bazo,项目名称:Mokuji,代码行数:38,代码来源:AdminPagesModel.php

示例5: onNewPictureSubmit

 public function onNewPictureSubmit(Form $form)
 {
     if (!$form->isValid()) {
         return;
     }
     $file = $form['file']->getValue();
     // save thumbnail
     try {
         $image = $file->getImage();
     } catch (Exception $e) {
         $form->addError(__('Uploaded file has to be an image.'));
         return;
     }
     if ($image->getWidth() > $image->getHeight()) {
         $image->resize(NULL, 60);
     } else {
         $image->resize(60, NULL);
     }
     $image->crop(intval(($image->getWidth() - 60) / 2), intval(($image->getHeight() - 60) / 2), 60, 60);
     $thumbnail_filename = sha1(microtime()) . '.png';
     $image->save(Environment::expand('%mediaDir%/' . $thumbnail_filename));
     unset($image);
     // save big picture
     $big_filename = String::webalize($form['rename']->getValue());
     $need_resave = TRUE;
     if (empty($big_filename)) {
         $big_filename = $file->getName();
     }
     if (($pos = strrpos($big_filename, '.')) !== FALSE) {
         $ext = substr($big_filename, $pos);
         $before_ext = substr($big_filename, 0, $pos);
         if (strtolower($ext) !== '.png') {
             $big_filename = $before_ext . '.png';
         } else {
             $need_resave = FALSE;
         }
     } else {
         $big_filename .= '.png';
     }
     if ($need_resave) {
         $image = $file->getImage();
         $image->save(Environment::expand('%mediaDir%/' . $big_filename));
     } else {
         $file->move(Environment::expand('%mediaDir%/' . $big_filename));
     }
     $image = $file->getImage();
     $image->resize(300, 300, Image::ENLARGE);
     $image->save(Environment::expand('%mediaDir%/' . $big_filename));
     // save to db
     if (!mapper::pictures()->insertOne($big_filename, $thumbnail_filename, $form['description']->getValue())) {
         $form->addError(__('Cannot save image data into the database, try again.'));
     } else {
         adminlog::log(__('Added picture "%s"'), $big_filename);
         $this->redirect('pictures');
         $this->terminate();
     }
 }
开发者ID:jakubkulhan,项目名称:shopaholic,代码行数:57,代码来源:ContentPresenter.php

示例6: actionRename

 /**
  * Rename file or directory
  * @param string folder
  * @param string old item name
  * @param string new item name
  */
 public function actionRename($folder, $oldname, $newname)
 {
     $oldpath = $this->getFolderPath($folder) . "/" . $oldname;
     $newpath = $this->getFolderPath($folder) . "/" . String::webalize($newname, ".");
     if (!file_exists($oldpath)) {
         $this->sendError("File does not exist.");
     }
     if (rename($oldpath, $newpath)) {
         $this->terminate(new JsonResponse(array("deleted" => true)));
     } else {
         $this->sendError("Unable to rename file.");
     }
 }
开发者ID:regiss,项目名称:texyla-s-Nete1-PhP-5.2,代码行数:19,代码来源:TexylaPresenter.php

示例7: deletePage

 public function deletePage($params, $dialog)
 {
     $title = $params;
     $webalized_title = String::webalize($title);
     try {
         $this->model('pages')->delete($title);
         $this->model('menuItems')->deleteRelated($webalized_title);
         $this['page']->redraw('Pages');
         $this->flash('Page ' . $title . ' deleted!');
         if (!$this->isAjax()) {
             $this->redirect('Pages:');
         }
     } catch (DibiDriverException $e) {
         $this->flash($e->getMessage());
     }
 }
开发者ID:bazo,项目名称:Mokuji,代码行数:16,代码来源:AdminPagesPresenter.php

示例8: onImportFormSubmit

 public function onImportFormSubmit(Form $form)
 {
     if (!$form->isValid()) {
         return;
     }
     if (!($handle = @fopen('safe://' . $form['file']->getValue()->getTemporaryFile(), 'r'))) {
         $form->addError(__('Cannot read file.'));
         return;
     }
     adminlog::log(__('Attempt to import products'));
     // provision
     $provision = intval($form['provision']->getValue());
     // read file
     $import = array();
     $codes = array();
     while (($_ = fgetcsv($handle)) !== FALSE) {
         $product = array();
         list($product['code'], $product['manufacturer'], $product['name'], $product['category'], , , $product['price']) = $_;
         $product['price'] = intval(round($product['price'] / (100 - $provision) * 100));
         $import[$product['code']] = $product;
         $codes[] = $product['code'];
     }
     fclose($handle);
     $updated = 0;
     // update in db
     foreach (mapper::products()->findByCodes($codes) as $product) {
         $values = array('id' => $product->getId(), 'price' => $import[$product->getCode()]['price']);
         mapper::products()->updateOne($values);
         unset($import[$product->getCode()]);
         $updated++;
     }
     adminlog::log(__('Updated %d products'), $updated);
     // update only?
     if ($form['update_only']->getValue()) {
         adminlog::log(__('Import successful'));
         $this->redirect('this');
         $this->terminate();
         return;
     }
     // manufacturers & categories
     $manufacturers = array();
     $categories = array();
     foreach ($import as $k => $_) {
         $m_key = String::webalize($_['manufacturer']);
         $manufacturers[$m_key] = $_['manufacturer'];
         $import[$k]['manufacturer'] = $m_key;
         $c_key = String::webalize($_['category']);
         $categories[$c_key] = $_['category'];
         $import[$k]['category'] = $c_key;
     }
     $manufacturers_added = 0;
     foreach ($manufacturers as $nice_name => $name) {
         if (($_ = mapper::manufacturers()->findByNiceName($nice_name)) === NULL) {
             mapper::manufacturers()->insertOne(array('nice_name' => $nice_name, 'name' => $name));
             $manufacturers[$nice_name] = mapper::manufacturers()->findByNiceName($nice_name)->getId();
             $manufacturers_added++;
         } else {
             $manufacturers[$nice_name] = $_->getId();
         }
         $manufacturers[$nice_name] = intval($manufacturers[$nice_name]);
     }
     adminlog::log(__('Added %d new manufacturers'), $manufacturers_added);
     $categories_added = 0;
     foreach ($categories as $nice_name => $name) {
         if (($_ = mapper::categories()->findByNiceName($nice_name)) === NULL) {
             mapper::categories()->addOne(array('nice_name' => $nice_name, 'name' => $name));
             $categories[$nice_name] = mapper::categories()->findByNiceName($nice_name)->getId();
             $categories_added++;
         } else {
             $categories[$nice_name] = $_->getId();
         }
         $categories[$nice_name] = intval($categories[$nice_name]);
     }
     adminlog::log(__('Added %d new categories'), $categories_added);
     // other
     $other = array();
     if ($form['availability_id']->getValue() != 0) {
         $other['availability_id'] = intval($form['availability_id']->getValue());
     }
     $products_added = 0;
     // insert products
     foreach ($import as $_) {
         $_['manufacturer_id'] = $manufacturers[$_['manufacturer']];
         unset($_['manufacturer']);
         $_['category_id'] = $categories[$_['category']];
         unset($_['category']);
         $_['nice_name'] = String::webalize($_['name']);
         $_ = array_merge($_, $other);
         mapper::products()->insertOne($_);
         $products_added++;
     }
     adminlog::log(__('Added %d new products'), $products_added);
     adminlog::log(__('Import successful'));
     // all done
     $this->redirect('this');
     $this->terminate();
 }
开发者ID:jakubkulhan,项目名称:shopaholic,代码行数:97,代码来源:ImportPresenter.php

示例9: getTags

 public function getTags($args)
 {
     $pageId = (int) $args[0];
     $username = $args[1];
     $password = $args[2];
     $user = $this->login($username, $password);
     if (!$user) {
         return $this->error;
     }
     $tags = $this->model('tags')->getAll();
     $array = array();
     foreach ($tags as $tag) {
         $struct = array();
         $struct['tag_id'] = (int) $tag->tag_id;
         $struct['name'] = (string) $tag->tag_name;
         $struct['count'] = 1;
         $struct['slug'] = String::webalize($struct['name']);
         $struct['html_url'] = '';
         $struct['rss_url'] = '';
         $array[] = $struct;
     }
     return $array;
 }
开发者ID:bazo,项目名称:Mokuji,代码行数:23,代码来源:AdminPublishPresenter.php

示例10: nullUnikatnySubor

 public function nullUnikatnySubor()
 {
     return String::webalize($this->nazov);
 }
开发者ID:Edke,项目名称:PerfORM,代码行数:4,代码来源:PerfORMDezen.php

示例11: retype

 /**
  * Retype value of field to string
  * @param mixed $value
  * @return string
  */
 public function retype($value)
 {
     return is_null($value) ? null : String::webalize($value);
 }
开发者ID:Edke,项目名称:PerfORM,代码行数:9,代码来源:SlugField.php

示例12: nullKod

 public function nullKod()
 {
     return String::webalize($this->nazov);
 }
开发者ID:Edke,项目名称:PerfORM,代码行数:4,代码来源:PerfORMVyrobca.php


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