当前位置: 首页>>代码示例>>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;未经允许,请勿转载。