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


PHP Helper::pick方法代码示例

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


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

示例1: id

 /**
  * 随机生成一个 18 位身份证。
  * @link http://baike.baidu.com/view/1697.htm#4 [<description>]
  * @link http://zhidao.baidu.com/question/1954561.html [<description>]
  * @return [type] [description]
  */
 public static function id()
 {
     $addressId = Helper::pick(array_keys(\Mock\Dictionary\Address::getDictionay()));
     $sum = 0;
     $rank = array("7", "9", "10", "5", "8", "4", "2", "1", "6", "3", "7", "9", "10", "5", "8", "4", "2");
     $last = array("1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2");
     $id = $addressId . Date::date('Ymd') . Basic::string('number', 3);
     for ($i = 0; $i < strlen($id); $i++) {
         $sum += $id[$i] * $rank[$i];
     }
     $id .= $last[$sum % 11];
     return $id;
 }
开发者ID:pythias,项目名称:mock,代码行数:19,代码来源:Misc.php

示例2: require_password

 public function require_password()
 {
     $password_list = trim($this->fetchParam('allowed', '', null, false, false));
     $passwords = explode('|', $password_list);
     $password_url = $this->fetch('password_url', null, null, false, false);
     $no_access_url = $this->fetch('no_access_url', '/', null, false, false);
     $return_variable = $this->fetch('return_variable', 'return', null, false, false);
     // no passwords set? this is OK
     if (!$password_list) {
         return;
     }
     // determine form URL
     $form_url = Helper::pick($password_url, $no_access_url);
     if (!$this->tasks->hasPassword(URL::getCurrent(), $passwords)) {
         URL::redirect(URL::appendGetVariable($form_url, $return_variable, URL::getCurrent()), 302);
         exit;
     }
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:18,代码来源:pi.protect.php

示例3: register_form

 public function register_form()
 {
     if (Auth::isLoggedIn()) {
         // logged in
         return false;
     }
     $attr_string = '';
     $site_root = Config::getSiteRoot();
     $return = $this->fetchParam('return', $site_root, null, false, false);
     $allow_request_return = $this->fetchParam('allow_request_return', false, null, true, false);
     $attr = $this->fetchParam('attr', false);
     $auto_login = (int) $this->fetchParam('auto_login', true, null, true, false);
     // grab request return
     $get_return = filter_input(INPUT_GET, 'return', FILTER_SANITIZE_URL);
     $post_return = filter_input(INPUT_POST, 'return', FILTER_SANITIZE_URL);
     $request_return = Helper::pick($post_return, $get_return);
     // if we're letting return values to be set in URL and one exists, grab it
     if ($allow_request_return && $request_return) {
         $return = $request_return;
     }
     // get old values
     $old_values = $this->flash->get('register_old_values', array());
     array_walk_recursive($old_values, function (&$item, $key) {
         $item = htmlspecialchars($item);
     });
     // set up any data to be parsed into content
     $data = array('error' => $this->flash->get('register_error', ''), 'success' => $this->flash->get('register_success', ''), 'field_errors' => $this->flash->get('register_field_errors', array()), 'old_values' => $old_values);
     // set up attributes
     if ($attr) {
         $attributes_array = Helper::explodeOptions($attr, true);
         foreach ($attributes_array as $key => $value) {
             $attr_string .= ' ' . $key . '="' . $value . '"';
         }
     }
     // set up form HTML
     $html = '<form method="post" action="' . Path::tidy($site_root . "/TRIGGER/member/register") . '" ' . $attr_string . '>';
     $html .= '<input type="hidden" name="return" value="' . $return . '">';
     $html .= '<input type="hidden" name="token" value="' . $this->tokens->create() . '">';
     $html .= '<input type="hidden" name="auto_login" value="' . $auto_login . '">';
     $html .= Parse::template($this->content, $data);
     $html .= '</form>';
     // return that HTML
     return $html;
 }
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:44,代码来源:pi.member.php

示例4: transform

 /**
  * Render content via a given $content_type
  *
  * @param string  $content  Content to render
  * @param mixed  $content_type  Content type to use (overrides configured content_type)
  * @return string
  */
 public static function transform($content, $content_type = NULL)
 {
     $content_type = Helper::pick($content_type, Config::getContentType());
     // render HTML from the given $content_type
     switch (strtolower($content_type)) {
         case "markdown":
         case "md":
             $content = Markdown($content);
             break;
         case "text":
         case "txt":
             $content = nl2br(strip_tags($content));
             break;
         case "textile":
             $textile = new Textile();
             $content = $textile->TextileThis($content);
     }
     if (Config::get('_enable_smartypants', TRUE) == TRUE) {
         $content = SmartyPants($content, 2);
     }
     return trim($content);
 }
开发者ID:nob,项目名称:joi,代码行数:29,代码来源:content.php

示例5: transform

 /**
  * Render content via a given $content_type
  *
  * @param string  $content  Content to render
  * @param mixed  $content_type  Content type to use (overrides configured content_type)
  * @return string
  */
 public static function transform($content, $content_type = NULL)
 {
     $content_type = Helper::pick($content_type, Config::getContentType());
     // render HTML from the given $content_type
     switch (strtolower($content_type)) {
         case "markdown":
         case "md":
             $content = Parse::markdown($content);
             break;
         case "text":
         case "txt":
             $content = nl2br(strip_tags($content));
             break;
         case "textile":
             $content = Parse::textile($content);
     }
     if (Config::get('enable_smartypants', TRUE) === TRUE) {
         $content = Parse::smartypants($content);
     } elseif (Config::get('enable_smartypants', TRUE) === 'typographer') {
         $content = Parse::smartypants($content, TRUE);
     }
     return trim($content);
 }
开发者ID:Bferreira5,项目名称:Theme-Example,代码行数:30,代码来源:content.php

示例6: sort

 /**
  * Sorts the current content by $field and $direction
  *
  * @param string  $field  Field to sort on
  * @param string  $direction  Direction to sort
  * @return void
  */
 public function sort($field = "order_key", $direction = null)
 {
     $hash = Debug::markStart('content', 'sorting');
     // no content, abort
     if (!count($this->content)) {
         return;
     }
     // sort by random, short-circuit
     if ($field == "random") {
         shuffle($this->content);
         return;
     }
     // sort by field
     usort($this->content, function ($item_1, $item_2) use($field) {
         // grab values, translating some user-facing names into internal ones
         switch ($field) {
             case "order_key":
                 $value_1 = $item_1['_order_key'];
                 $value_2 = $item_2['_order_key'];
                 break;
             case "number":
                 $value_1 = $item_1['_order_key'];
                 $value_2 = $item_2['_order_key'];
                 break;
             case "datestamp":
                 $value_1 = $item_1['datestamp'];
                 $value_2 = $item_2['datestamp'];
                 break;
             case "date":
                 $value_1 = $item_1['datestamp'];
                 $value_2 = $item_2['datestamp'];
                 break;
             case "folder":
                 $value_1 = $item_1['_folder'];
                 $value_2 = $item_2['_folder'];
                 break;
             case "distance":
                 $value_1 = $item_1['distance_km'];
                 $value_2 = $item_2['distance_km'];
                 break;
                 // not a special case, grab the field values if they exist
             // not a special case, grab the field values if they exist
             default:
                 $value_1 = isset($item_1[$field]) ? $item_1[$field] : null;
                 $value_2 = isset($item_2[$field]) ? $item_2[$field] : null;
                 break;
         }
         // compare the two values
         // ----------------------------------------------------------------
         return Helper::compareValues($value_1, $value_2);
     });
     // apply sort direction
     if (is_null($direction)) {
         reset($this->content);
         $sample = $this->content[key($this->content)];
         // if we're sorting by order_key and it's date-based order, default sorting is 'desc'
         if ($field == "order_key" && $sample['_order_key'] && $sample['datestamp']) {
             $direction = "desc";
         } else {
             $direction = "asc";
         }
     }
     // do we need to flip the order?
     if (Helper::pick($direction, "asc") == "desc") {
         $this->content = array_reverse($this->content);
     }
     Debug::markEnd($hash);
 }
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:75,代码来源:contentset.php

示例7: Statamic_Logwriter

$config['log_enabled'] = TRUE;
$config['log.level'] = Log::convert_log_level($config['_log_level']);
$config['whoops.editor'] = 'sublime';
$config['log.writer'] = new Statamic_Logwriter(array('path' => $config['_log_file_path'], 'file_prefix' => $config['_log_file_prefix']));
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Many users are upgrading to PHP 5.3 for the first time. I know.
| We've gone ahead set the default timezone that will be used by the PHP
| date and date-time functions. This prevents some potentially
| frustrating errors for novice developers.
|
*/
date_default_timezone_set(Helper::pick($config['_timezone'], @date_default_timezone_get(), "UTC"));
/*
|--------------------------------------------------------------------------
| Slim Initialization
|--------------------------------------------------------------------------
|
| Time to get an instance of Slim fired up. We're passing the $config
| array, which contains a bit more data than necessary, but helps keep
| everything simple.
|
*/
// mark milestone for debug panel
Debug::markMilestone('bootstrapped');
$app = new \Slim\Slim(array_merge($config, array('view' => new Statamic_View())));
// mark milestone for debug panel
Debug::markMilestone('app created');
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:31,代码来源:start.php

示例8: sort

 /**
  * Sort
  *
  * @param string  $field  Field to sort by
  * @param string  $direction  Direction to sort
  * @return void
  */
 public function sort($field = "name", $direction = NULL)
 {
     if ($field == "random") {
         shuffle($this->data);
         return;
     }
     usort($this->data, function ($item_1, $item_2) use($field) {
         $value_1 = isset($item_1[$field]) ? $item_1[$field] : NULL;
         $value_2 = isset($item_2[$field]) ? $item_2[$field] : NULL;
         return Helper::compareValues($value_1, $value_2);
     });
     // do we need to flip the order?
     if (Helper::pick($direction, "asc") == "desc") {
         $this->data = array_reverse($this->data);
     }
 }
开发者ID:nob,项目名称:joi,代码行数:23,代码来源:taxonomyset.php

示例9: fetch

 /**
  * Attempts to fetch a given $key's value from (in order): user-passed parameters, config file, default value
  *
  * @param string  $key  Key of value to retrieve
  * @param mixed  $default  Default value if no value is found
  * @param string  $validity_check  Allows a boolean callback function to validate parameter
  * @param boolean  $is_boolean  Indicates parameter is boolean
  * @param boolean  $force_lower  Force the parameter's value to be lowercase?
  * @return mixed
  */
 protected function fetch($key, $default = NULL, $validity_check = NULL, $is_boolean = FALSE, $force_lower = TRUE)
 {
     return Helper::pick($this->fetchParam($key, NULL, $validity_check, $is_boolean, $force_lower), $this->fetchConfig($key, NULL, $validity_check, $is_boolean, $force_lower), $default);
 }
开发者ID:nob,项目名称:joi,代码行数:14,代码来源:plugin.php

示例10: getTaxonomyName

 /**
  * Returns the stored name for a $taxonomy and $taxonomy_slug if exists in cache
  * 
  * @param string  $taxonomy  Taxonomy to use
  * @param string  $taxonomy_slug  Taxonomy slug to look up
  * @return string
  */
 public static function getTaxonomyName($taxonomy, $taxonomy_slug)
 {
     return Helper::pick(ContentService::getTaxonomyName($taxonomy, $taxonomy_slug), $taxonomy_slug);
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:11,代码来源:taxonomy.php

示例11: date_default_timezone_set

<?php

/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Many users are upgrading to PHP 5.3 for the first time. I know.
| We've gone ahead set the default timezone that will be used by the PHP
| date and date-time functions. This prevents some potentially
| frustrating errors for novice developers.
|
*/
date_default_timezone_set(Helper::pick($config['_timezone'], 'UTC'));
/*
|--------------------------------------------------------------------------
| Slim Initialization
|--------------------------------------------------------------------------
|
| Time to get an instance of Slim fired up. We're passing the $config
| array, which contains a bit more data than necessary, but helps keep
| everything simple.
|
*/
$admin_app = new \Slim\Slim(array_merge($config, array('view' => new Statamic_View())));
$admin_app->config = $config;
/*
|--------------------------------------------------------------------------
| Cookies for the Monster
|--------------------------------------------------------------------------
|
开发者ID:nob,项目名称:joi,代码行数:31,代码来源:start.php

示例12: getLayouts

 /**
  * Returns a list of layouts for a given $theme, or current theme if no $theme passed
  *
  * @param mixed  $theme  Theme to list layouts from, or current if none is passed
  * @return array
  */
 public static function getLayouts($theme = NULL)
 {
     $layouts = array();
     $list = glob("_themes/" . Helper::pick($theme, Config::getTheme()) . "/layouts/*");
     if ($list) {
         foreach ($list as $name) {
             $start = strrpos($name, "/") + 1;
             $end = strrpos($name, ".");
             $layouts[] = substr($name, $start, $end - $start);
         }
     }
     return $layouts;
 }
开发者ID:nob,项目名称:joi,代码行数:19,代码来源:theme.php

示例13: merge_configs

 /**
  * Merge all configs
  * @param string  $destination Paramter for destination YAML file to attempt to load.
  * @param string  $return_type Set the return type
  * @return array
  */
 public function merge_configs($destination = null, $respons_type = 'json')
 {
     // Set environment
     $this->env = $env = FILECLERK_ENV;
     // Error(s) holder
     $errors = false;
     // Check for a destination config
     $destination = is_null($destination) ? Request::get('destination') : $destination;
     // A complete list of all possible config variables
     $config = array('aws_access_key' => null, 'aws_secret_key' => null, 'custom_domain' => null, 'bucket' => null, 'directory' => null, 'permissions' => CannedAcl::PUBLIC_READ, 'content_types' => false);
     // Requried config values
     $required_config = array('aws_access_key', 'aws_secret_key');
     // Destination config values that even if null should override master config.
     $allow_override = array('custom_domain', 'directory', 'content_types');
     // Destination config array
     $destination_config = array();
     // Check that the destination config file exists
     if (!is_null($destination) || $destination !== 0 || $destination) {
         // Set the full path for the destination file
         $destination_file = FILECLERK_DESTINATION_PATH . ltrim($destination) . '.yaml';
         if (File::exists($destination_file)) {
             $destination_config = YAML::parseFile($destination_file);
             foreach ($destination_config as $key => $value) {
                 if (!in_array($key, $allow_override) && (empty($value) || is_null($value))) {
                     unset($destination_config[$key]);
                 }
             }
         } else {
             $this->log->error("Could not use destination `" . $destination . "`, YAML file does not exist.");
         }
     }
     // load global config
     $addon_config = Helper::pick($this->getConfig(), array());
     // merge config variables in order
     $config = array_merge($config, $addon_config, $destination_config);
     // Handle content types
     // If it's a string, need to cast to an array
     if (is_string($config['content_types'])) {
         switch ($config['content_types']) {
             // If empty string, set to false
             case '':
             case null:
                 $config['content_types'] = false;
                 break;
                 // If there is a value, push to an array
             // If there is a value, push to an array
             default:
                 $config['content_types'] = array($config['content_types']);
                 break;
         }
     }
     // Convert permissions to the corresponding Canned ACL constant.
     switch (strtolower(trim($config['permissions']))) {
         case 'private':
             $config['permissions'] = CannedAcl::PRIVATE_ACCESS;
             break;
         case 'public-read':
             $config['permissions'] = CannedAcl::PUBLIC_READ;
             break;
         case 'public-read-write':
             $config['permissions'] = CannedAcl::PUBLIC_READ_WRITE;
             break;
         case 'authenticated-read':
             $config['permissions'] = CannedAcl::AUTHENTICATED_READ;
             break;
         default:
             $config['permissions'] = CannedAcl::PUBLIC_READ;
             break;
     }
     // Check that required configs are set
     foreach ($required_config as $key) {
         if (!isset($config[$key]) || $config[$key] == '') {
             $errors[] = array('error' => "<pre>{$key}</pre> is a required File Clerk config value.");
         }
     }
     // If errors, set in config for checking later
     if ($errors) {
         $config['errors'] = $errors;
     }
     // Create our S3 client
     //self::load_s3();
     return $config;
 }
开发者ID:omadahealth,项目名称:Statamic-File-Clerk,代码行数:89,代码来源:tasks.fileclerk.php

示例14: getResourceURI

 /**
  * Retrieves the resource URI for this request
  *
  * @param mixed  $default  Default value to use if not set
  * @return string
  */
 public static function getResourceURI($default = NULL)
 {
     return Helper::pick(URL::sanitize(\Slim\Slim::getInstance()->request()->getResourceUri()), $default);
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:10,代码来源:request.php

示例15: format

 /**
  * Formats a given $date (automatically resolving timestamps) to a given $format
  *
  * @param string  $format  Format to use (based on PHP's date formatting)
  * @param mixed  $date  Date string or timestamp (if blank, now)
  * @return mixed
  */
 public static function format($format, $date = NULL)
 {
     return date($format, self::resolve(Helper::pick($date, time())));
 }
开发者ID:Synergy23,项目名称:RealEstate,代码行数:11,代码来源:date.php


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