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


PHP Utils::single_array方法代码示例

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


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

示例1: action_ajax_auto_tags

	/**
	 * Respond to Javascript callbacks
	 * The name of this method is action_ajax_ followed by what you passed to the context parameter above.
	 */
	public function action_ajax_auto_tags( $handler )
	{
		$selected = array();
		if( isset( $handler->handler_vars['selected'] ) ) {
			$selected = Utils::single_array( $handler->handler_vars['selected'] );
		}
		if( isset( $handler->handler_vars['term'] ) && MultiByte::strlen( $handler->handler_vars['term'] ) ) {
			$search = $handler->handler_vars['term'] . '%';
			$tags = new Terms( DB::get_results( "SELECT * FROM {terms} WHERE vocabulary_id = :vid and LOWER(term_display) LIKE LOWER(:crit) ORDER BY term_display ASC", array( 'vid' => Tags::vocabulary()->id, 'crit' => $search ), 'Term' ) );
		}
		else {
			$tags = Tags::vocabulary()->get_tree( 'term_display ASC' );
		}

		$resp = array();
		foreach ( $tags as $tag ) {
			$resp[] = MultiByte::strpos( $tag->term_display, ',' ) === false ? $tag->term_display : $tag->tag_text_searchable;
		}

		if( count( $selected ) ) {
			$resp = array_diff($resp, $selected );
		}
		// Send the response
//		$ar = new AjaxResponse();
//		$ar->data = $resp;
//		$ar->out();
		echo json_encode( $resp );
	}
开发者ID:rick-c,项目名称:TagsAutocomplete,代码行数:32,代码来源:tagautocomplete.plugin.php

示例2: match

 /**
  * Match the stub against this rule
  * Also sets internal structures based on a successful match
  * @param string $stub The URL stub to match against
  * @return boolean True if this rule matches the stub, false if not
  */
 public function match($stub)
 {
     if (preg_match($this->parse_regex, $stub, $pattern_matches) > 0) {
         $this->entire_match = array_shift($pattern_matches);
         // The entire matched string is returned at index 0
         $named_args = $this->named_args;
         // Direct call shows a PHP notice
         $result = true;
         if (is_string($this->parameters) && ($parameters = unserialize($this->parameters)) || is_array($this->parameters) && ($parameters = $this->parameters)) {
             $this->named_arg_values = array_merge($this->named_arg_values, $parameters);
         }
         foreach ($named_args as $keys) {
             foreach ($keys as $key) {
                 if (!empty($pattern_matches[$key])) {
                     $this->named_arg_values[$key] = urldecode(str_replace('%252F', '%2F', $pattern_matches[$key]));
                 }
             }
         }
         if (preg_match('/^\\{\\$(\\w+)\\}$/u', $this->action, $matches) > 0) {
             $this->action = $this->named_arg_values[$matches[1]];
         }
         if (isset($parameters['require_match'])) {
             $result = call_user_func($parameters['require_match'], $this, $stub, $parameters);
         }
         if ($result && isset($parameters['require_permission'])) {
             foreach ($parameters['require_permission'] as $token => $access) {
                 $access = Utils::single_array($access);
                 foreach ($access as $mask) {
                     if (is_bool($mask) && User::identify()->can($token)) {
                         $result = true;
                         break;
                     } elseif (User::identify()->can($token, $mask)) {
                         $result = true;
                         break 2;
                     }
                 }
             }
         }
         return $result;
     }
     return false;
 }
开发者ID:habari,项目名称:system,代码行数:48,代码来源:rewriterule.php

示例3: access_allowed


//.........这里部分代码省略.........
         case 'ajax_tags':
             $require_any = array('manage_tags' => true);
             break;
         case 'options':
             $require_any = array('manage_options' => true);
             break;
         case 'themes':
             $require_any = array('manage_themes' => true, 'manage_theme_config' => true);
             break;
         case 'activate_theme':
             $require_any = array('manage_themes' => true);
             break;
         case 'preview_theme':
             $require_any = array('manage_themes' => true);
             break;
         case 'plugins':
             $require_any = array('manage_plugins' => true, 'manage_plugins_config' => true);
             break;
         case 'plugin_toggle':
             $require_any = array('manage_plugins' => true);
             break;
         case 'import':
             $require_any = array('manage_import' => true);
             break;
         case 'users':
         case 'ajax_update_users':
         case 'ajax_users':
             $require_any = array('manage_users' => true);
             break;
         case 'user':
             $require_any = array('manage_users' => true, 'manage_self' => true);
             break;
         case 'groups':
         case 'group':
         case 'ajax_update_groups':
         case 'ajax_groups':
             $require_any = array('manage_groups' => true);
             break;
         case 'logs':
         case 'ajax_delete_logs':
         case 'ajax_logs':
             $require_any = array('manage_logs' => true);
             break;
         case 'publish':
         case 'ajax_media':
         case 'ajax_media_panel':
             $type = Post::type_name($type);
             $require_any = array('post_any' => array(ACL::get_bitmask('create'), ACL::get_bitmask('edit')), 'post_' . $type => array(ACL::get_bitmask('create'), ACL::get_bitmask('edit')), 'own_posts' => array(ACL::get_bitmask('create'), ACL::get_bitmask('edit')));
             break;
         case 'delete_post':
             $type = Post::type_name($type);
             $require_any = array('post_any' => ACL::get_bitmask('delete'), 'post_' . $type => ACL::get_bitmask('delete'), 'own_posts' => ACL::get_bitmask('delete'));
             break;
         case 'posts':
         case 'ajax_posts':
         case 'ajax_delete_entries':
         case 'ajax_update_entries':
             $require_any = array('post_any' => array(ACL::get_bitmask('delete'), ACL::get_bitmask('edit')), 'own_posts' => array(ACL::get_bitmask('delete'), ACL::get_bitmask('edit')));
             foreach (Post::list_active_post_types() as $type => $type_id) {
                 $require_any['post_' . $type] = array(ACL::get_bitmask('delete'), ACL::get_bitmask('edit'));
             }
             break;
         case 'sysinfo':
             $require_any = array('super_user' => true);
             break;
         case 'dashboard':
         case 'ajax_dashboard':
             $result = true;
             break;
         case 'ajax_add_block':
             $result = true;
             break;
         case 'ajax_delete_block':
             $result = true;
             break;
         case 'configure_block':
             $result = true;
             break;
         case 'ajax_save_areas':
             $result = true;
             break;
         default:
             break;
     }
     $require_any = Plugins::filter('admin_access_tokens', $require_any, $page, $type);
     foreach ($require_any as $token => $access) {
         $access = Utils::single_array($access);
         foreach ($access as $mask) {
             if (is_bool($mask) && $user->can($token)) {
                 $result = true;
                 break;
             } elseif ($user->can($token, $mask)) {
                 $result = true;
                 break 2;
             }
         }
     }
     $result = Plugins::filter('admin_access', $result, $page, $type);
     return $result;
 }
开发者ID:psaintlaurent,项目名称:Habari,代码行数:101,代码来源:adminhandler.php

示例4: get

 /**
  * Returns a LogEntry or EventLog array based on supplied parameters.
  * By default,fetch as many entries as pagination allows and order them in a descending fashion based on timestamp.
  *
  * @todo Cache query results.
  * @param array $paramarray An associated array of parameters, or a querystring
  * The following keys are supported:
  * - id => an entry id or array of post ids
  * - user_id => id of the logged in user for which to return entries
  * - severity => severity level for which to return entries
  * - type_id => the numeric id or array of ids for the type of entries for which which to return entries
  * - module => a name or array of names of modules for which to return entries
  * - type => a single type name or array of type names for which to return entries
  * - ip => the IP number for which to return entries
  * - criteria => a literal search string to match entry message content or a special search
  * - day => a day of entry creation, ignored if month and year are not specified
  * - month => a month of entry creation, ignored if year isn't specified
  * - year => a year of entry creation
  * - orderby => how to order the returned entries
  * - fetch_fn => the function used to fetch data, one of 'get_results', 'get_row', 'get_value'
  * - count => return the number of entries that would be returned by this request
  * - month_cts => return the number of entries created in each month
  * - nolimit => do not implicitly set limit
  * - limit => the maximum number of entries to return, implicitly set for many queries
  * - index => 
  * - offset => amount by which to offset returned entries, used in conjunction with limit
  * - where => manipulate the generated WHERE clause
  * - return_data => set to return the data associated with the entry
  * 
  * @return array An array of LogEntry objects, or a single LogEntry object, depending on request
  */
 public static function get($paramarray = array())
 {
     $params = array();
     $fns = array('get_results', 'get_row', 'get_value');
     $select_ary = array();
     $select_distinct = array();
     // Put incoming parameters into the local scope
     $paramarray = Utils::get_params($paramarray);
     if ($paramarray instanceof \ArrayIterator) {
         $paramarray = $paramarray->getArrayCopy();
     }
     $select_fields = LogEntry::default_fields();
     if (!isset($paramarray['return_data'])) {
         unset($select_fields['data']);
     }
     foreach ($select_fields as $field => $value) {
         if (preg_match('/(?:(?P<table>[\\w\\{\\}]+)\\.)?(?P<field>\\w+)(?:(?:\\s+as\\s+)(?P<alias>\\w+))?/i', $field, $fielddata)) {
             if (empty($fielddata['table'])) {
                 $fielddata['table'] = '{log}';
             }
             if (empty($fielddata['alias'])) {
                 $fielddata['alias'] = $fielddata['field'];
             }
         }
         $select_ary[$fielddata['alias']] = "{$fielddata['table']}.{$fielddata['field']} AS {$fielddata['alias']}";
         $select_distinct[$fielddata['alias']] = "{$fielddata['table']}.{$fielddata['field']}";
     }
     // Transact on possible multiple sets of where information that is to be OR'ed
     if (isset($paramarray['where']) && is_array($paramarray['where'])) {
         $wheresets = $paramarray['where'];
     } else {
         $wheresets = array(array());
     }
     $query = Query::create('{log}');
     $query->select($select_ary);
     if (isset($paramarray['where']) && is_string($paramarray['where'])) {
         $query->where()->add($paramarray['where']);
     }
     foreach ($wheresets as $paramset) {
         $where = new QueryWhere();
         $paramset = array_merge((array) $paramarray, (array) $paramset);
         if (isset($paramset['id'])) {
             $where->in('{log}.id', $paramset['id'], 'log_id', 'intval');
         }
         if (isset($paramset['user_id'])) {
             $where->in('{log}.user_id', $paramset['user_id'], 'log_user_id', 'intval');
         }
         if (isset($paramset['severity']) && 'any' != LogEntry::severity_name($paramset['severity'])) {
             $where->in('{log}.severity_id', $paramset['severity'], 'log_severity_id', function ($a) {
                 return LogEntry::severity($a);
             });
         }
         if (isset($paramset['type_id'])) {
             $where->in('{log}.type_id', $paramset['type_id'], 'log_type_id', 'intval');
         }
         if (isset($paramset['module'])) {
             $paramset['module'] = Utils::single_array($paramset['module']);
             $qry = Query::create('{log_types}');
             $qry->select('{log_types}.id')->distinct();
             $qry->where()->in('{log_types}.module', $paramset['module'], 'log_subquery_module');
             $where->in('{log}.type_id', $qry, 'log_module');
         }
         if (isset($paramset['type'])) {
             $paramset['type'] = Utils::single_array($paramset['type']);
             $qry = Query::create('{log_types}');
             $qry->select('{log_types}.id')->distinct();
             $qry->where()->in('{log_types}.type', $paramset['type'], 'log_subquery_type');
             $where->in('{log}.type_id', $qry, 'log_type');
         }
//.........这里部分代码省略.........
开发者ID:habari,项目名称:system,代码行数:101,代码来源:eventlog.php

示例5: theme_body_class

 /**
  * A theme function for outputting CSS classes based on the requested content
  * @param Theme $theme A Theme object instance
  * @param mixed $args Additional classes that should be added to the ones generated
  * @return string The resultant classes
  */
 function theme_body_class($theme, $args = array())
 {
     $body_class = array();
     foreach (get_object_vars($this->request) as $key => $value) {
         if ($value) {
             $body_class[$key] = $key;
         }
     }
     $body_class = array_unique(array_merge($body_class, Stack::get_named_stack('body_class'), Utils::single_array($args)));
     $body_class = Plugins::filter('body_class', $body_class, $theme);
     return implode(' ', $body_class);
 }
开发者ID:habari,项目名称:system,代码行数:18,代码来源:theme.php

示例6: get

 /**
  * Produce a form with the contained fields.
  *
  * @param boolean $process_for_success Set to true to display the form as it would look if the submission succeeded, but do not execute success methods.
  * @return string HTML form generated from all controls assigned to this form
  */
 public function get($use_theme = null, $process_for_success = true)
 {
     $forvalidation = false;
     Plugins::act('modify_form_' . Utils::slugify($this->formtype, '_'), $this);
     Plugins::act('modify_form', $this);
     if (isset($use_theme)) {
         $theme = $use_theme;
     } else {
         $theme = $this->get_theme($forvalidation, $this);
     }
     $theme->start_buffer();
     $theme->success = false;
     $this->success = false;
     $this->submitted = false;
     $this->properties['id'] = isset($this->properties['id']) ? $this->properties['id'] : Utils::slugify($this->name);
     // Should we be validating?
     if (isset($_POST['FormUI']) && $_POST['FormUI'] == $this->salted_name()) {
         $this->submitted = true;
         $validate = $this->validate();
         if (count($validate) == 0) {
             if ($process_for_success) {
                 $result = $this->success();
                 if ($result) {
                     return $result;
                 }
             }
             $theme->success = true;
             $this->success = true;
             $theme->message = $this->options['success_message'];
         } else {
             $forvalidation = true;
             if (!isset($_SESSION['forms'][$this->salted_name()]['url'])) {
                 $_SESSION['forms'][$this->salted_name()]['url'] = Site::get_url('habari', true) . Controller::get_stub() . '#' . $this->properties['id'];
             }
         }
     } else {
         $_SESSION['forms'][$this->salted_name()]['url'] = Site::get_url('habari', true) . Controller::get_stub() . '#' . $this->properties['id'];
     }
     if (isset($_SESSION['forms'][$this->salted_name()]['error_data'])) {
         foreach ($_SESSION['forms'][$this->salted_name()]['error_data'] as $key => $value) {
             $_POST[$key] = $value;
         }
         unset($_SESSION['forms'][$this->salted_name()]['error_data']);
         $forvalidation = true;
     }
     $out = '';
     $theme->controls = $this->output_controls($forvalidation);
     $theme->form = $this;
     foreach ($this->properties as $prop => $value) {
         $theme->{$prop} = $value;
     }
     $theme->class = Utils::single_array($this->class);
     $this->action = $this->options['form_action'];
     $theme->salted_name = $this->salted_name();
     $theme->pre_out = $this->pre_out_controls();
     $out = $this->prefix . $theme->display_fallback($this->options['template'], 'fetch') . $this->postfix;
     $theme->end_buffer();
     return $out;
 }
开发者ID:wwxgitcat,项目名称:habari,代码行数:65,代码来源:formui.php

示例7: revoke

	/**
	 * Remove one or more permissions from a group
	 * @param mixed a permission ID, name, or array of the same
	 */
	public function revoke( $tokens )
	{
		$tokens = Utils::single_array( $tokens );
		$tokens = array_map( array( 'ACL', 'token_id' ), $tokens );

		foreach ( $tokens as $token ) {
			ACL::revoke_group_token( $this->id, $token );
		}
	}
开发者ID:rynodivino,项目名称:system,代码行数:13,代码来源:usergroup.php

示例8: filter_atom_get_collection_content_type

 /**
  * Add links to the main atom feed
  */
 public function filter_atom_get_collection_content_type($content_type)
 {
     $content_type = Utils::single_array($content_type);
     $content_type[] = Post::type('link');
     return $content_type;
 }
开发者ID:habari-extras,项目名称:linkblog,代码行数:9,代码来源:linkblog.plugin.php

示例9: get_value_out

 /**
  * Return the property value that is associated with the first present property from an array list
  * This version only searches the list of the class' $properties array, because __get() on this objcet returns named FormControls instances
  * @param array $tag_fields A list of potential fields to try
  * @return bool|string False if no value found, string of the property value found
  */
 public function get_value_out($tag_fields)
 {
     $properties = array_merge($this->properties, get_object_vars($this));
     $value_out = false;
     foreach (Utils::single_array($tag_fields) as $tag_field) {
         if (isset($properties[$tag_field])) {
             $value_out = $properties[$tag_field];
             break;
         }
     }
     return $value_out;
 }
开发者ID:habari,项目名称:system,代码行数:18,代码来源:formcontainer.php

示例10: set_select

 /**
  * Sets fields for the SELECT statement
  * @param array|string $fields A field or list of fields to set as the fields to select, replaces existing selected fields
  * @return Query Returns $this for fluid interface
  */
 public function set_select($fields)
 {
     $this->fields = Utils::single_array($fields);
     return $this;
 }
开发者ID:habari,项目名称:system,代码行数:10,代码来源:query.php

示例11: queue_dirs

 /**
  * Search directories for templates to use
  * Templates are always taken from the first directory they're found in.
  * To override this behavior, the template must be specifically added via ->add_template()
  * @see add_template
  * @param string|array $dirs A directory to look for templates in
  */
 public function queue_dirs($dirs)
 {
     $dirs = Utils::single_array($dirs);
     $alltemplates = array();
     // If multiple directories are passed, the earlier ones should override the later ones
     $dirs = array_reverse($dirs);
     foreach ($dirs as $dir) {
         $templates = Utils::glob(Utils::end_in_slash($dir) . '*.*');
         $alltemplates = array_merge($alltemplates, $templates);
     }
     // Convert the template files into template names and produce a map from name => file
     $available_templates = array_map('basename', $alltemplates, array_fill(1, count($alltemplates), '.php'));
     $template_map = array_combine($available_templates, $alltemplates);
     $this->template_map = array_merge($this->template_map, $template_map);
     // Workaround for the 404 template key being merged into the 0 integer index
     unset($this->template_map[0]);
     if (isset($template_map[404])) {
         $this->template_map['404'] = $template_map[404];
     }
     // The templates in the list should be uniquely identified
     array_unique($available_templates);
     // Filter the templates that are available
     $available_templates = Plugins::filter('available_templates', $available_templates, __CLASS__);
     $this->available_templates = array_merge($available_templates, $this->available_templates);
 }
开发者ID:habari,项目名称:system,代码行数:32,代码来源:rawphpengine.php

示例12: theme_content

 /**
  * Display an object using a template designed for the type of object it is
  * The $object is assigned into the theme using the $content template variable
  *
  * @param Theme $theme The theme used to display the object
  * @param object $object An object to display
  * @param string $context The context in which the object will be displayed	 
  * @return
  */
 public function theme_content($theme, $object, $context = null)
 {
     $fallback = array();
     $content_types = array();
     if ($object instanceof IsContent) {
         $content_types = Utils::single_array($object->content_type());
     }
     $content_types[] = 'content';
     $content_types = array_flip($content_types);
     if (isset($context)) {
         foreach ($content_types as $type => $type_id) {
             $content_type = $context . $object->content_type();
             $fallback[] = strtolower($context . '.' . $type);
         }
         $fallback[] = strtolower($context);
     }
     foreach ($content_types as $type => $type_id) {
         $fallback[] = strtolower($type);
     }
     $this->content = $object;
     return $this->display_fallback($fallback, 'fetch');
 }
开发者ID:anupom,项目名称:my-blog,代码行数:31,代码来源:theme.php

示例13: filter_template_user_filters

	/**
	 * Add the 'events' type to the list of templates that we can use.
	 **/
	public function filter_template_user_filters($filters) {
		if(isset($filters['content_type'])) {
			$filters['content_type']= Utils::single_array( $filters['content_type'] );
			$filters['content_type'][]= Post::type('product');
		}
		return $filters;
	}
开发者ID:nerdfiles,项目名称:habari_boilerplate,代码行数:10,代码来源:contenttypeproduct.plugin.php

示例14: filter_posts_get_update_preset

 public function filter_posts_get_update_preset($preset_parameters, $presetname, $paramarray)
 {
     switch ($presetname) {
         case 'home':
             $content_type = isset($preset_parameters['content_type']) ? Utils::single_array($preset_parameters['content_type']) : array();
             $content_type[] = 'tweet';
             $preset_parameters['content_type'] = $content_type;
             break;
     }
     return $preset_parameters;
 }
开发者ID:ringmaster,项目名称:habari-test-plugin,代码行数:11,代码来源:test.plugin.php

示例15: revoke

 /**
  * Remove permissions to one or more tokens from a user
  * @param mixed a token ID, name, or array of the same
  **/
 public function revoke($tokens)
 {
     $tokens = Utils::single_array($tokens);
     // get token IDs
     $tokens = array_map(array('ACL', 'token_id'), $tokens);
     foreach ($tokens as $token) {
         ACL::revoke_user_permission($this->id, $token);
         EventLog::log(_t('User %1$s: Permission to %2$s revoked.', array($this->username, ACL::token_name($token))), 'notice', 'user', 'habari');
     }
 }
开发者ID:anupom,项目名称:my-blog,代码行数:14,代码来源:user.php


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