本文整理汇总了PHP中StringHelper类的典型用法代码示例。如果您正苦于以下问题:PHP StringHelper类的具体用法?PHP StringHelper怎么用?PHP StringHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StringHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkOut
public function checkOut(Request $request)
{
$address = \StringHelper::filterString($request->input('address'));
$name = \StringHelper::filterString($request->input('name'));
$content = \StringHelper::filterString($request->input('comments'));
$phone = \StringHelper::filterString($request->input('phone'));
$count = Cart::count();
if ($phone != "" && $name != "" && $content != "" && $count > 0) {
$order = new Order();
$order->order_name = $name;
$order->status = 1;
$order->active = 1;
$order->order_comment = $content;
$order->order_address = $address;
$order->order_phone = $phone;
$order->save();
$cart = Cart::content();
foreach ($cart as $item) {
$order_detail = new OrderDetail();
$order_detail->dish_id = $item->id;
$order_detail->dish_number = $item->qty;
$order_detail->order_id = $order->id;
$order_detail->save();
}
Cart::destroy();
return Redirect::to(url('menu'))->with('message', 'Order Success !. You can continue buy now !');
} else {
return Redirect::to(url('checkout'))->with('message', 'Order Fail !. Something Wrong !');
}
}
示例2: getUrlUploadMultiImages
public static function getUrlUploadMultiImages($obj, $user_id)
{
$url_arr = array();
$min_size = 1024 * 1000 * 700;
$max_size = 1024 * 1000 * 1000 * 3.5;
foreach ($obj["tmp_name"] as $key => $tmp_name) {
$ext_arr = array('png', 'jpg', 'jpeg', 'bmp');
$name = StringHelper::filterString($obj['name'][$key]);
$storeFolder = Yii::getPathOfAlias('webroot') . '/images/' . date('Y-m-d', time()) . '/' . $user_id . '/';
$pathUrl = 'images/' . date('Y-m-d', time()) . '/' . $user_id . '/' . time() . $name;
if (!file_exists($storeFolder)) {
mkdir($storeFolder, 0777, true);
}
$tempFile = $obj['tmp_name'][$key];
$targetFile = $storeFolder . time() . $name;
$ext = strtolower(pathinfo($name, PATHINFO_EXTENSION));
$size = $obj['name']['size'];
if (in_array($ext, $ext_arr)) {
if ($size >= $min_size && $size <= $max_size) {
if (move_uploaded_file($tempFile, $targetFile)) {
array_push($url_arr, $pathUrl);
} else {
return NULL;
}
} else {
return NULL;
}
} else {
return NULL;
}
}
return $url_arr;
}
示例3: _makeHandle
/**
* Make handle from source name.
*
* @param $name
*
* @return string
*/
private function _makeHandle($name, $sourceId)
{
// Remove HTML tags
$handle = preg_replace('/<(.*?)>/', '', $name);
$handle = preg_replace('/<[\'"‘’“”\\[\\]\\(\\)\\{\\}:]>/', '', $handle);
$handle = StringHelper::toLowerCase($handle);
$handle = StringHelper::asciiString($handle);
$handle = preg_replace('/^[^a-z]+/', '', $handle);
// In case it was an all non-ASCII handle, have a default.
if (!$handle) {
$handle = 'source' . $sourceId;
}
$handleParts = preg_split('/[^a-z0-9]+/', $handle);
$handle = '';
foreach ($handleParts as $index => &$part) {
if ($index) {
$part = ucfirst($part);
}
$handle .= $part;
}
$appendix = '';
while (true) {
$taken = craft()->db->createCommand()->select('handle')->from('assetsources')->where('handle = :handle', array(':handle' => $handle . $appendix))->queryScalar();
if ($taken) {
$appendix = (int) $appendix + 1;
} else {
break;
}
}
return $handle . $appendix;
}
示例4: actionInsertPostCeleb
public function actionInsertPostCeleb()
{
$this->pageTitile = 'Thêm bài viết người nổi tiếng';
$request = Yii::app()->request;
try {
$post_content = StringHelper::filterString($request->getPost('post_content'));
$celeb_id = StringHelper::filterString($request->getPost('celeb_id'));
$location = StringHelper::filterString($request->getPost('location'));
$cats = $request->getPost('cats');
if (count($_FILES['images']['tmp_name']) > 1) {
$url_arr = UploadHelper::getUrlUploadMultiImages($_FILES['images'], $celeb_id . 'celeb');
} else {
$url_arr = UploadHelper::getUrlUploadMultiImages($_FILES['images'], $celeb_id . 'celeb');
}
// $album = StringHelper::filterString($request->getPost('album'));
$album = NULL;
$res = Posts::model()->addPostCeleb($celeb_id, $post_content, $location, $url_arr, $album, $cats);
if ($res != FALSE) {
Yii::app()->user->setFlash('success', 'Thêm bài viết thành công');
} else {
Yii::app()->user->setFlash('error', 'Có lỗi xảy ra');
}
$this->redirect(Yii::app()->createUrl('celebrity/addPost'));
} catch (Exception $ex) {
var_dump($ex->getMessage());
}
}
示例5: generateHandle
public static function generateHandle($sourceVal)
{
// Remove HTML tags
$handle = preg_replace('/<(.*?)>/', '', $sourceVal);
// Remove inner-word punctuation
$handle = preg_replace('/[\'"‘’“”\\[\\]\\(\\)\\{\\}:]/', '', $handle);
// Make it lowercase
$handle = strtolower($handle);
// Convert extended ASCII characters to basic ASCII
$handle = StringHelper::asciiString($handle);
// Handle must start with a letter
$handle = preg_replace('/^[^a-z]+/', '', $handle);
// Get the "words"
$words = array_filter(preg_split('/[^a-z0-9]+/', $handle));
$handle = '';
// Make it camelCase
for ($i = 0; $i < count($words); $i++) {
if ($i == 0) {
$handle .= $words[$i];
} else {
$handle .= strtoupper($words[$i][0]) . substr($words[$i], 1);
}
}
return $handle;
}
示例6: dispatch
function dispatch()
{
global $ModuleDir, $ClassDir, $template, $DefaultModule, $DefaultPage, $timer;
$this->path_info = ltrim(getenv("PATH_INFO"), "/");
$this->setDefualtModule($DefaultModule);
$this->setDefualtPage($DefaultPage);
$module_name = $this->getModuleName() ? $this->getModuleName() : $this->getDefualtModule();
$page_name = $this->getPageName() ? $this->getPageName() : $this->getDefualtPage();
$action_name = $this->getActionName() ? $this->getActionName() : $this->default_action;
include_once $ClassDir . "StringHelper.class.php";
$page_class_name = StringHelper::CamelCaseFromUnderscore($page_name);
$include_file = $ModuleDir . $module_name . DIRECTORY_SEPARATOR . $page_class_name . ".class.php";
if (file_exists($include_file)) {
include_once $include_file;
$TempObj = new $page_class_name();
$Action = "execute" . ucfirst($action_name);
$TempObj->{$Action}();
}
// printf("module %s/ page %s/ action %s/ ",$module_name,$page_name,$action_name);
// $template->setFile(array (
// "TAB" => "tab.html",
// ));
// $template->setBlock("TAB", "tab");
$this->parseTemplateLang(true);
$template->parse("OUT", array("LAOUT"));
$template->p("OUT");
if (defined('APF_DEBUG') && APF_DEBUG == true) {
$timer->stop();
$timer->display();
}
}
示例7: actionUpdateVersion
public function actionUpdateVersion()
{
$this->retVal = new stdClass();
$request = Yii::app()->request;
if ($request->isPostRequest && isset($_POST)) {
try {
$app_ver = StringHelper::filterString($request->getPost('app_ver'));
$db_ver = StringHelper::filterString($request->getPost('db_ver'));
$model = AppDbVer::model()->findByAttributes(array('id' => 1));
$model->app_ver = $app_ver;
$model->db_ver = $db_ver;
if ($model->save(FALSE)) {
$this->retVal->status = 1;
$this->retVal->message = "Success";
} else {
$this->retVal->status = 0;
$this->retVal->message = "Fail";
}
$this->retVal->data = "";
} catch (exception $e) {
$this->retVal->message = $e->getMessage();
}
echo CJSON::encode($this->retVal);
Yii::app()->end();
}
}
示例8: bookTable
/**
* Show the application dashboard to the user.
*
* @return Response
*/
public function bookTable(Request $request)
{
$email = \StringHelper::filterString($request->input('email'));
$name = \StringHelper::filterString($request->input('name'));
$phone = \StringHelper::filterString($request->input('phone'));
$number = \StringHelper::filterString($request->input('number'));
$month = \StringHelper::filterString($request->input('month'));
$day = \StringHelper::filterString($request->input('day'));
$hour = \StringHelper::filterString($request->input('hour'));
$min = \StringHelper::filterString($request->input('min'));
$a_p = \StringHelper::filterString($request->input('a-p'));
$content = \StringHelper::filterString($request->input('comments'));
if ($email != "" && $name != "" && $phone != "" && $number != "" && $month != "" && $day != "") {
$book_table = new BookTable();
$book_table->name = $name;
$book_table->email = $email;
$book_table->phone = $phone;
$book_table->number = $number;
$book_table->comments = $content;
$book_table->active = 1;
$book_table->status = 1;
$book_table->date = $day . "-" . $month . " " . $hour . ":" . $min . " " . $a_p;
$book_table->save();
}
return Redirect::back()->with('message', 'Success');
}
示例9: actionViewDocument
public function actionViewDocument()
{
if (isset($_GET['doc_id'])) {
$doc_id = StringHelper::filterString($_GET['doc_id']);
$detail_doc = Doc::model()->findAll(array("select" => "*", "condition" => "doc_id = :doc_id", "params" => array(':doc_id' => $doc_id)));
$spCriteria = new CDbCriteria();
$spCriteria->select = "*";
$spCriteria->condition = "doc_id = :doc_id";
$spCriteria->params = array(':doc_id' => $doc_id);
$subject_doc = SubjectDoc::model()->find($spCriteria);
$spjCriteria = new CDbCriteria();
$spjCriteria->select = "*";
$spjCriteria->condition = "subject_id = :subject_id";
$spjCriteria->params = array(':subject_id' => $subject_doc->subject_id);
$subject = Subject::model()->find($spjCriteria);
$related_doc = Doc::model()->findAll(array("select" => "*", "limit" => "3", "order" => "RAND()"));
foreach ($detail_doc as $detail) {
$title = $detail->doc_name . " | Bluebee - UET";
$this->pageTitle = $title;
if ($detail->doc_type == 3) {
$image = Yii::app()->getBaseUrl(true) . $detail->doc_url;
} else {
$image = $detail->doc_url;
}
$des = $detail->doc_description;
Yii::app()->clientScript->registerMetaTag($title, null, null, array('property' => 'og:title'));
Yii::app()->clientScript->registerMetaTag($image, null, null, array('property' => 'og:image'));
Yii::app()->clientScript->registerMetaTag(500, null, null, array('property' => 'og:image:width'));
Yii::app()->clientScript->registerMetaTag(500, null, null, array('property' => 'og:image:height'));
Yii::app()->clientScript->registerMetaTag("website", null, null, array('property' => 'og:type'));
Yii::app()->clientScript->registerMetaTag($des, null, null, array('property' => 'og:description'));
}
$this->render('viewDocument', array('detail_doc' => $detail_doc, 'related_doc' => $related_doc, 'subject' => $subject));
}
}
示例10: read
/**
* Returns stream only including
* lines from the original stream which don't start with any of the
* specified comment prefixes.
*
* @param null $len
* @return mixed the resulting stream, or -1
* if the end of the resulting stream has been reached.
*
*/
public function read($len = null)
{
if (!$this->getInitialized()) {
$this->_initialize();
$this->setInitialized(true);
}
$buffer = $this->in->read($len);
if ($buffer === -1) {
return -1;
}
$lines = explode("\n", $buffer);
$filtered = array();
$commentsSize = count($this->_comments);
foreach ($lines as $line) {
for ($i = 0; $i < $commentsSize; $i++) {
$comment = $this->_comments[$i]->getValue();
if (StringHelper::startsWith($comment, ltrim($line))) {
$line = null;
break;
}
}
if ($line !== null) {
$filtered[] = $line;
}
}
$filtered_buffer = implode("\n", $filtered);
return $filtered_buffer;
}
示例11: main
function main()
{
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (array_key_exists('content', $_POST)) {
// define password bytes
$passwordBytes = Configuration::$aesPasswordBytes;
// decode
$content = $_POST['content'];
$decodedContent = base64_decode($content);
// decrypt
$decryptedContent = EncryptionHelper::decryptMessage($decodedContent, $passwordBytes);
$decryptedContent = StringHelper::untilLastOccurence($decryptedContent, '}');
// json decode
$highscoreData = json_decode($decryptedContent);
// store
$config = ConfidentialConfiguration::getDatabaseConfiguration();
$highscore = new Highscore($config->databaseHost, $config->databaseUserName, $config->databaseUserPassword, $config->databaseName);
$highscore->insert($highscoreData);
die(ResponseHelper::serializeResponse('Success', 'Success'));
} else {
die(ResponseHelper::serializeResponse('Error', 'The request must contain a POST parameter'));
}
} else {
die(ResponseHelper::serializeResponse('Error', 'Not a POST request, sorry'));
}
}
示例12: __construct
public function __construct() {
parent::__construct();
$this->fractionDigits = StringHelper::trim($this->numberFormatter->getAttribute(NumberFormatter::FRACTION_DIGITS));
if ($this->fractionDigits === FALSE) {
throw new IllegalStateException(t('Cannot detect OS fraction digits'));
}
}
示例13: getInstance
public static function getInstance()
{
if (self::$objInstance == null) {
self::$objInstance = new StringHelper();
}
return self::$objInstance;
}
示例14: setPassword
public function setPassword($pass1, $pass2 = false, $emptyIsOk = false)
{
if ($pass1 || $emptyIsOk) {
// a pass has been set
if ($pass2 !== false && $pass1 != $pass2) {
// a confirmation has been set but is different
$this->_error['password'] = 'user_pass_mismatch';
return false;
}
$this->set('salt', StringHelper::genRandom(8, 'abcdefghijklmnopqrstuvwxyz' . 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'));
if ($pass1) {
$arr = explode(',', $this->_properties[$key]);
$class = array_shift($arr);
if (VarPss::checkValid($pass1, $arr)) {
$this->setRawPassword($pass1, $this->get('salt'));
} else {
$this->_error['password'] = 'user_pass_length';
return false;
}
} else {
$this->data['password'] = '';
}
return true;
} else {
if (!$emptyIsOk) {
$this->_error['password'] = 'user_pass_empty';
return false;
}
return true;
}
}
示例15: init
/**
* Initializes the console app by creating the command runner.
*
* @return null
*/
public function init()
{
// Set default timezone to UTC
date_default_timezone_set('UTC');
// Import all the built-in components
foreach ($this->componentAliases as $alias) {
Craft::import($alias);
}
// Attach our Craft app behavior.
$this->attachBehavior('AppBehavior', new AppBehavior());
// Initialize Cache and LogRouter right away (order is important)
$this->getComponent('cache');
$this->getComponent('log');
// So we can try to translate Yii framework strings
$this->coreMessages->attachEventHandler('onMissingTranslation', array('Craft\\LocalizationHelper', 'findMissingTranslation'));
// Set our own custom runtime path.
$this->setRuntimePath(craft()->path->getRuntimePath());
// Attach our own custom Logger
Craft::setLogger(new Logger());
// No need for these.
craft()->log->removeRoute('WebLogRoute');
craft()->log->removeRoute('ProfileLogRoute');
// Load the plugins
craft()->plugins->loadPlugins();
// Validate some basics on the database configuration file.
craft()->validateDbConfigFile();
// Call parent::init before the plugin console command logic so craft()->commandRunner will be available to us.
parent::init();
foreach (craft()->plugins->getPlugins() as $plugin) {
$commandsPath = craft()->path->getPluginsPath() . StringHelper::toLowerCase($plugin->getClassHandle()) . '/consolecommands/';
if (IOHelper::folderExists($commandsPath)) {
craft()->commandRunner->addCommands(rtrim($commandsPath, '/'));
}
}
}