當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Phalcon\Text類代碼示例

本文整理匯總了PHP中Phalcon\Text的典型用法代碼示例。如果您正苦於以下問題:PHP Text類的具體用法?PHP Text怎麽用?PHP Text使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Text類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: registerAction

 public function registerAction()
 {
     return $this->handleRequest(function () {
         $req = new Request();
         if ($req->isPost()) {
             $post = json_decode($req->getRawBody());
             $a = $this->getUserDocument();
             $user = new $a();
             $user->salt = Text::random(Text::RANDOM_ALNUM);
             $user->password = $this->hash($post->password, $user->salt);
             unset($post->password);
             $post = (array) $post;
             foreach ($post as $key => $value) {
                 $user->{$key} = $value;
             }
             $user->save();
             $this->session->set('user', $user);
         } else {
             if ($req->isOptions()) {
                 return '';
             }
         }
         return $this->jsonOutput($user);
     });
 }
開發者ID:serus22,項目名稱:phalconz,代碼行數:25,代碼來源:AuthController.php

示例2: build

 /**
  * Generate view
  */
 public function build()
 {
     $action = Text::uncamelize($this->_options['action']);
     $viewName = explode('-', str_replace('_', '-', Text::uncamelize($this->_options['name'])));
     if (count($viewName) > 1) {
         array_pop($viewName);
     }
     $viewName = implode('-', $viewName);
     $viewDir = $this->_options['directory'] . DIRECTORY_SEPARATOR . $viewName;
     $viewPath = $viewDir . DIRECTORY_SEPARATOR . $action . '.volt';
     $code = "<?php\n" . Tools::getCopyright() . "\n?>\n";
     $code = str_replace("\t", "    ", $code);
     if (!file_exists($viewPath) || $this->_options['force'] == true) {
         if (!is_dir($viewDir)) {
             mkdir($viewDir, 0777, true);
             chmod($viewDir, 0777);
         }
         if (!@file_put_contents($viewPath, $code)) {
             throw new \Exception("Unable to write to '{$viewPath}'");
         }
         chmod($viewPath, 0777);
     } else {
         throw new \Exception("The View '{$action}' already exists");
     }
     return $viewName;
 }
開發者ID:magnxpyr,項目名稱:phalcon-webtools,代碼行數:29,代碼來源:View.php

示例3: eager

 public function eager($model, $field = null, $localKey = null, $foreignKey = '_id')
 {
     if ($field == null || $localKey == null) {
         $className = strtolower((new \ReflectionClass($model))->getShortName());
         if (Text::endsWith($className, 's')) {
             $className = substr($className, 0, -1);
         }
     }
     if ($field == null) {
         $field = $className;
     }
     if ($localKey == null) {
         $localKey = $className . '_id';
     }
     $keys = [];
     foreach ($this->array as $item) {
         if (!in_array($item->{$localKey}, $keys)) {
             $keys[] = $item->{$localKey};
         }
     }
     $result = $model::init()->find([$foreignKey => ['$in' => $keys]])->keyBy('_id');
     foreach ($this->array as $item) {
         $item->setRelation($field, $result[(string) $item->{$localKey}]);
     }
     return $this;
 }
開發者ID:DenchikBY,項目名稱:Phalcon-MongoDB-ODM,代碼行數:26,代碼來源:Collection.php

示例4: __invoke

 public function __invoke($uri, $query = null, $configKey = 'default')
 {
     if ($query) {
         if (true === is_array($query)) {
             $query = implode(',', $query);
         }
         if (false !== ($pos = strrpos($uri, '.'))) {
             $uri = explode('/', $uri);
             $fileName = array_pop($uri);
             $nameArray = explode('.', $fileName);
             $nameExt = array_pop($nameArray);
             $nameFinal = array_pop($nameArray);
             $nameFinal .= ',' . $query;
             array_push($nameArray, $nameFinal, $nameExt);
             $fileName = implode('.', $nameArray);
             array_push($uri, $fileName);
             $uri = implode('/', $uri);
         }
     }
     if (\Phalcon\Text::startsWith($uri, 'http://', false) || \Phalcon\Text::startsWith($uri, 'https://', false)) {
         return str_replace('http://api.wallstreetcn.com/', 'http://thumbnail.wallstreetcn.com/thumb/', $uri);
     }
     $config = self::getDI()->getConfig();
     if (isset($config->thumbnail->{$configKey}->baseUri) && ($baseUrl = $config->thumbnail->{$configKey}->baseUri)) {
         return $baseUrl . $uri;
     }
     return $uri;
 }
開發者ID:skybird,項目名稱:phalcon,代碼行數:28,代碼來源:WscnThumb.php

示例5: beforeValidationOnCreate

 public function beforeValidationOnCreate()
 {
     $this->createdAt = time();
     if (!$this->slug) {
         $this->slug = \Phalcon\Text::random(\Phalcon\Text::RANDOM_ALNUM, 8);
     }
 }
開發者ID:skybird,項目名稱:phalcon,代碼行數:7,代碼來源:Category.php

示例6: getMenuOptions

 /**
  * Return menu options
  *
  * @return array
  */
 public function getMenuOptions()
 {
     $this->_limitParamValue = 100;
     $rows = $this->getColumnData();
     $acl = $this->_di->get('acl');
     $viewer = $this->_di->get('viewer');
     $options = [];
     foreach ($rows as $row) {
         $option = [];
         $option['id'] = $row['id'];
         $option['text'] = $row['title'];
         if ($row['module'] && $row['controller']) {
             if (!$acl->isAllowed($viewer->getRole(), \Engine\Acl\Dispatcher::ACL_ADMIN_MODULE, \Engine\Acl\Dispatcher::ACL_ADMIN_CONTROLLER, '*') && !$acl->isAllowed($viewer->getRole(), \Engine\Acl\Dispatcher::ACL_ADMIN_MODULE, \Engine\Acl\Dispatcher::ACL_ADMIN_CONTROLLER, 'read')) {
                 if (!$acl->isAllowed($viewer->getRole(), $row['module'], $row['controller'], 'read')) {
                     continue;
                 }
             }
             $option['controller'] = \Phalcon\Text::camelize($row['module']) . ".controller." . \Phalcon\Text::camelize($row['controller']);
             $option['moduleName'] = \Phalcon\Text::camelize($row['module']);
             $option['controllerName'] = \Phalcon\Text::camelize($row['controller']);
             $option['leaf'] = true;
             $option['cls'] = 'window-list-item';
             $option['iconCls'] = 'window-list-item-icon';
         }
         $option['qtip'] = $row['description'];
         $options[] = $option;
     }
     return $options;
 }
開發者ID:relson,項目名稱:phalcon_extjs,代碼行數:34,代碼來源:Item.php

示例7: __get

 public function __get($name)
 {
     if ($this->getDI()->has($name)) {
         return parent::__get($name);
     }
     return $this->{lcfirst(\Phalcon\Text::camelize("get_{$name}"))}();
 }
開發者ID:skullab,項目名稱:area51,代碼行數:7,代碼來源:Ui.php

示例8: resetAction

 public function resetAction()
 {
     $connection = new \Phalcon\Db\Adapter\Pdo\Mysql($this->config->database->toArray());
     $tables = $connection->listTables();
     foreach ($tables as $table) {
         $tablename = \Phalcon\Text::camelize($table);
         $fd = fopen("{$this->config->application->formsDir}/{$tablename}Form.php", "w");
         fwrite($fd, "<?php" . self::NL . self::NL);
         // Begin class
         fwrite($fd, "class {$tablename}Form {" . self::NL);
         $columns = $connection->describeColumns($table);
         foreach ($columns as $column) {
             if ($column instanceof \Phalcon\Db\Column) {
                 // Escape if column is primary
                 if ($column->isPrimary()) {
                     continue;
                 }
                 // Begin method
                 $columnname = \Phalcon\Text::camelize($column->getName());
                 fwrite($fd, self::TAB . "private function _{$columnname}() {" . self::NL);
                 // Write element
                 $columntype_base = $this->_getBaseType($column->getType());
                 $columntype = $this->_getType($columntype_base, $column);
                 fwrite($fd, self::TAB . self::TAB . "\$element = new \\Phalcon\\Forms\\Element\\{$columntype}(\"{$columnname}\");" . self::NL);
                 fwrite($fd, self::TAB . self::TAB . "\$element->setLabel(\"{$columnname}\");" . self::NL);
                 // Add empty selection for select fields
                 if ($columntype == "Select") {
                     fwrite($fd, self::TAB . self::TAB . "\$element->setOptions([]);" . self::NL);
                 }
                 // Add validator on text fields
                 if ($columntype == "Text" && $column->getSize() > 0) {
                     fwrite($fd, self::TAB . self::TAB . "\$element->addValidator(new \\Phalcon\\Validation\\Validator\\StringLength([" . self::NL);
                     fwrite($fd, self::TAB . self::TAB . self::TAB . "\"max\" => {$column->getSize()}" . self::NL);
                     fwrite($fd, self::TAB . self::TAB . "]));" . self::NL);
                 }
                 // End method
                 fwrite($fd, self::TAB . self::TAB . "return \$element;" . self::NL);
                 fwrite($fd, self::TAB . "}" . self::NL);
             }
         }
         // Final method : construction of the form
         fwrite($fd, self::TAB . "public function setFields() {" . self::NL);
         foreach ($columns as $column) {
             if ($column instanceof \Phalcon\Db\Column) {
                 if ($column->isPrimary()) {
                     continue;
                 }
                 $columnname = \Phalcon\Text::camelize($column->getName());
                 fwrite($fd, self::TAB . self::TAB . "\$this->add(\$this->_{$columnname}());" . self::NL);
             }
         }
         fwrite($fd, self::TAB . "}" . self::NL);
         // End class
         fwrite($fd, "}" . self::NL . self::NL);
         fclose($fd);
     }
     $this->view->disable();
     echo "done!";
     return FALSE;
 }
開發者ID:Zheness,項目名稱:phalconFormGenerator,代碼行數:60,代碼來源:IndexController.php

示例9: env

 /**
  * Gets the value of an environment variable. Supports boolean, empty and null.
  *
  * @param  string $key
  * @param  mixed $default
  * @return mixed
  */
 function env($key, $default = null)
 {
     $value = getenv($key);
     if ($value === false) {
         return value($default);
     }
     switch (strtolower($value)) {
         case 'true':
         case '(true)':
             return true;
         case 'false':
         case '(false)':
             return false;
         case 'empty':
         case '(empty)':
             return '';
         case 'null':
         case '(null)':
             return;
     }
     if (Text::startsWith($value, '"') && Text::endsWith($value, '"')) {
         return substr($value, 1, -1);
     }
     return $value;
 }
開發者ID:xueron,項目名稱:pails,代碼行數:32,代碼來源:helper.php

示例10: dumpModulesFromVendor

 /**
  * Extract Vegas modules from composer vegas-cmf vendors.
  *
  * @param $modulesList
  * @return mixed
  */
 private function dumpModulesFromVendor(array &$modulesList)
 {
     if (!file_exists(APP_ROOT . '/composer.json')) {
         return $modulesList;
     }
     $fileContent = file_get_contents(APP_ROOT . DIRECTORY_SEPARATOR . 'composer.json');
     $json = json_decode($fileContent, true);
     $vendorDir = realpath(APP_ROOT . (isset($json['config']['vendor-dir']) ? DIRECTORY_SEPARATOR . $json['config']['vendor-dir'] : DIRECTORY_SEPARATOR . 'vendor'));
     $vendorDir .= DIRECTORY_SEPARATOR . 'vegas-cmf';
     $directoryIterator = new \DirectoryIterator($vendorDir);
     foreach ($directoryIterator as $libDir) {
         if ($libDir->isDot()) {
             continue;
         }
         //creates path to Module.php file
         $moduleSettingsFile = implode(DIRECTORY_SEPARATOR, [$vendorDir, $libDir, 'module', self::MODULE_SETTINGS_FILE]);
         if (!file_exists($moduleSettingsFile)) {
             continue;
         }
         $baseName = Text::camelize($libDir->getBasename());
         if (!isset($modulesList[$baseName])) {
             $modulesList[$baseName] = ['className' => $baseName . '\\' . pathinfo(self::MODULE_SETTINGS_FILE, PATHINFO_FILENAME), 'path' => $moduleSettingsFile];
         }
     }
     return $modulesList;
 }
開發者ID:szytko,項目名稱:core,代碼行數:32,代碼來源:Loader.php

示例11: translate

 public function translate($idElement, $key, $default)
 {
     $this->message = "";
     if (Text::startsWith($this->language, "en", true)) {
         return $default;
     }
     $trans = $this->translations->filter(function ($object) use($idElement, $key) {
         if (Text::startsWith($this->language, $object->getLang(), true) && $object->getIdElement() == $idElement && $object->getName() == $key) {
             return $object;
         }
     });
     if (is_array($trans)) {
         if (sizeof($trans) > 0) {
             $trans = $trans[0];
         } else {
             $this->message = $this->translate(1, "translate.info", "");
             return $default;
         }
     }
     if (is_a($trans, "Translation")) {
         return $trans->getText();
     } else {
         $this->message = $this->translate(1, "translate.info", "");
         return $default;
     }
 }
開發者ID:jcheron,項目名稱:phalcon-jquery-website,代碼行數:26,代碼來源:TranslateEngine.php

示例12: getSource

 public function getSource()
 {
     $nowClassName = get_class($this);
     $trueClassName = str_replace(__NAMESPACE__ . '\\', '', $nowClassName);
     $trueClassName = Text::uncamelize($trueClassName);
     return DB_PREFIX . strtolower($trueClassName);
 }
開發者ID:ylh990835774,項目名稱:phalcon_ydjc,代碼行數:7,代碼來源:BaseModel.php

示例13: pageAction

 public function pageAction()
 {
     $pageSlug = $this->getUriParameter('pageSlug');
     $pageTitle = \Phalcon\Text::camelize($pageSlug);
     $this->tag->setTitle($pageTitle);
     $this->view->pick('pages/' . $pageSlug);
 }
開發者ID:rajeshmsaaryan01,項目名稱:website,代碼行數:7,代碼來源:PagesController.php

示例14: resolve

 /**
  * {@inheritdoc}
  */
 public function resolve(&$value)
 {
     if (is_string($value) && strlen($value) > 0) {
         $value = \Phalcon\Text::upper($value);
     }
     return $value;
 }
開發者ID:arius86,項目名稱:core,代碼行數:10,代碼來源:Uppercase.php

示例15: initialize

 public function initialize()
 {
     foreach (self::$routes as $route => $controller) {
         $name = str_replace('_', '-', Text::uncamelize($controller));
         $this->add($route, $controller)->setName($name);
     }
 }
開發者ID:dubhunter,項目名稱:hunter-light,代碼行數:7,代碼來源:AppRouter.php


注:本文中的Phalcon\Text類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。