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


PHP String::safeString方法代码示例

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


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

示例1: getHtmlOption

 /**
  * Gets the HTML of a option
  * @param string $key name of the option
  * @param string $value value for the option
  * @param boolean $isSelected flag to see if this option is selected
  * @return string
  */
 protected function getHtmlOption($key, $value, $isSelected)
 {
     $idSuffix = ucfirst(String::safeString($key));
     $id = $this->getId() . $idSuffix;
     $html = '<input' . $this->getAttributeHtml('type', $this->isMultiple() ? 'checkbox' : 'radio') . $this->getNameHtml() . $this->getAttributeHtml('value', $key) . ($isSelected ? $this->getAttributeHtml('checked', 'checked') : '') . $this->getAttributeHtml('id', $id) . $this->getClassHtml() . $this->getAttributesHtml() . ' />';
     if (!$value) {
         return $html;
     }
     $html .= '<label';
     if ($id) {
         $html .= $this->getAttributeHtml('for', $id);
     }
     $html .= '>' . $value . '</label>';
     return $html;
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:22,代码来源:OptionField.php

示例2: getOptionHtml

 /**
  * Gets the HTML for a specific option in this field
  * @param string $option key of the option
  * @return string
  * @throws zibo\ZiboException when no options set for this field
  * @throws zibo\ZiboException when the provided option could not be found
  */
 public function getOptionHtml($option)
 {
     $html = '';
     if (!$this->options) {
         throw new ZiboException('No options set');
     }
     if (!isset($this->options[$option])) {
         throw new ZiboException($option . ' is not in the option list');
     }
     $idSuffix = ucfirst(String::safeString($option));
     $id = $this->getId() . $idSuffix;
     $value = $this->options[$option];
     $isSelected = false;
     $selected = null;
     $this->processValue($option, $value, $isSelected, $selected);
     return $this->getSubmitHtml($id, $value, $option);
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:24,代码来源:SubmitField.php

示例3: validate

 /**
  * Validates the data and generates the slug for the data
  * @param mixed $data The data object of the model
  * @return null
  * @throws zibo\library\validation\exception\ValidationException when the data is not valid
  */
 public function validate($data)
 {
     $slugString = $this->getSlugString($data);
     if ($slugString) {
         $slug = $baseSlug = String::safeString($slugString);
         $index = 1;
         do {
             $query = $this->createQuery();
             $query->addCondition('{slug} = %1%', $slug);
             if ($data->id) {
                 $query->addCondition('{id} <> %1%', $data->id);
             }
             if ($query->count()) {
                 $slug = $baseSlug . '-' . $index;
                 $index++;
             } else {
                 break;
             }
         } while (true);
         $data->slug = $slug;
     }
     parent::validate($data);
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:29,代码来源:SlugModel.php

示例4: testSafeString

 /**
  * @dataProvider providerSafeString
  */
 public function testSafeString($expected, $value)
 {
     $locale = setlocale(LC_ALL, 'en_IE.utf8', 'en_IE', 'en');
     $result = String::safeString($value);
     $this->assertEquals($expected, $result);
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:9,代码来源:StringTest.php

示例5: renameAction

 /**
  * Action to rename a file or directory
  *
  * Every argument to this method is a part of the rename path. eg.
  * $fb->renameAction('application', 'data', 'test.txt') would rename to application/data/test.txt
  * @return null
  */
 public function renameAction()
 {
     $pieces = func_get_args();
     $file = $this->getFileFromPieces($pieces, false);
     if (!$file) {
         $this->response->setStatusCode(Response::STATUS_CODE_NOT_FOUND);
     } else {
         $absoluteFile = new File($this->fileBrowser->getRoot(), $file);
         if (!$absoluteFile->exists()) {
             $this->addError(self::TRANSLATION_ERROR_EXIST_NOT, array('path' => $file));
             $this->response->setStatusCode(Response::STATUS_CODE_NOT_FOUND);
         }
     }
     if ($this->response->getStatusCode() == Response::STATUS_CODE_NOT_FOUND) {
         $this->response->setView(new BaseView());
         return;
     }
     $basePath = $this->request->getBasePath();
     $parent = $absoluteFile->getParent();
     $redirectUrl = $basePath . '/' . self::ACTION_PATH . '/' . $this->fileBrowser->getPath($parent, false);
     $form = new RenameForm($basePath . '/' . self::ACTION_RENAME . '/' . $file, $file);
     if ($form->isSubmitted()) {
         if ($form->isCancelled()) {
             $this->response->setRedirect($redirectUrl);
             return;
         }
         try {
             $form->validate();
             $name = $form->getFileName();
             $name = String::safeString($name);
             $destination = new File($parent, $name);
             if ($destination->getAbsolutePath() != $absoluteFile->getPath() && $destination->exists()) {
                 $error = new ValidationError(self::TRANSLATION_ERROR_EXIST, '%path% exists already', array('path' => $this->fileBrowser->getPath($destination, false)));
                 $exception = new ValidationException();
                 $exception->addErrors(RenameForm::FIELD_NAME, array($error));
                 throw $exception;
             }
             $absoluteFile->move($destination);
             $this->addInformation(self::TRANSLATION_INFORMATION_RENAMED, array('old' => $file->getName(), 'new' => $name));
             $this->response->setRedirect($redirectUrl);
             return;
         } catch (ValidationException $exception) {
             $form->setValidationException($exception);
         } catch (Exception $exception) {
             Zibo::getInstance()->runEvent(Zibo::EVENT_LOG, $exception->getMessage(), $exception->getTraceAsString(), 1);
             $this->addError(self::TRANSLATION_ERROR, array('error' => $exception->getMessage()));
             $this->response->setStatusCode(Response::STATUS_CODE_SERVER_ERROR);
         }
     }
     if (!$absoluteFile->isWritable() || !$absoluteFile->getParent()->isWritable()) {
         $this->addWarning(self::TRANSLATION_ERROR_WRITABLE, array('path' => $file));
         $form->setIsDisabled(true, RenameForm::BUTTON_SUBMIT);
     }
     $view = new RenameView($form, $file);
     $view->setPageTitle(Module::TRANSLATION_FILE_BROWSER, true);
     $this->response->setView($view);
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:64,代码来源:FileBrowserController.php

示例6: smarty_modifier_safeString

function smarty_modifier_safeString($string)
{
    return String::safeString($string);
}
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:4,代码来源:modifier.safeString.php

示例7: uploadFile

 /**
  * Upload a file
  * @param array $file Array with file upload details from PHP
  * @return string path to the uploaded file
  */
 private function uploadFile($file)
 {
     if ($file['error'] == UPLOAD_ERR_NO_FILE) {
         $default = $this->getDefaultValue();
         if (empty($default)) {
             $default = parent::getRequestValue($this->getName() . self::SUFFIX_DEFAULT);
             if (empty($default)) {
                 $default = self::DEFAULT_VALUE;
             }
         }
         return $default;
     }
     $this->isUploadError($file);
     $this->uploadPath->create();
     $uploadFileName = String::safeString($file['name']);
     $uploadFile = new File($this->uploadPath, $uploadFileName);
     if (!$this->willOverwrite()) {
         $uploadFile = $uploadFile->getCopyFile();
     }
     if (!move_uploaded_file($file['tmp_name'], $uploadFile->getPath())) {
         throw new ZiboException('Could not move the uploaded file ' . $file['tmp_name'] . ' to ' . $uploadFile->getPath());
     }
     $uploadFile->setPermissions(0644);
     return $uploadFile->getPath();
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:30,代码来源:FileField.php

示例8: validate

 /**
  * Validate a node object
  * @return null
  * @throws zibo\library\validation\exception\ValidationException when the data is invalid
  *
  * @todo validate the route (unique)
  */
 public function validate($data)
 {
     if (!isset($data->route) || empty($data->route)) {
         return parent::validate($data);
     }
     $route = rtrim(ltrim($data->route, Request::QUERY_SEPARATOR), Request::QUERY_SEPARATOR);
     $tokens = explode(Request::QUERY_SEPARATOR, $route);
     foreach ($tokens as $index => $token) {
         $token = String::safeString($token);
         if (empty($token)) {
             unset($tokens[$index]);
         } else {
             $tokens[$index] = $token;
         }
     }
     $data->route = implode(Request::QUERY_SEPARATOR, $tokens);
     try {
         parent::validate($data);
         $exception = new ValidationException();
     } catch (ValidationException $e) {
         $exception = $e;
     }
     $query = $this->createQuery(0, $data->dataLocale, false);
     $query->setFields('{id}');
     $query->addCondition('{parent} LIKE %1% AND {route} = %2% AND {id} <> %3%', $data->getRootNodeId() . self::PATH_SEPARATOR . '%', $data->route, $data->id);
     $node = $query->queryFirst();
     if ($node) {
         $error = new ValidationError(self::VALIDATION_ROUTE_ERROR_CODE, self::VALIDATION_ROUTE_ERROR_MESSAGE, array('route' => $data->route, 'node' => $node->id));
         $exception->addErrors('route', array($error));
     }
     if ($exception->hasErrors()) {
         throw $exception;
     }
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:41,代码来源:NodeModel.php


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