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


PHP Utils::get_params方法代码示例

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


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

示例1: __construct

 /**
  * constructor __construct
  * Constructor for the QueryRecord class.
  * @param array an associative array of initial field values.
  */
 public function __construct($paramarray = array())
 {
     $params = Utils::get_params($paramarray);
     if (count($params)) {
         // Defaults
         $this->fields = array_merge($this->fields, $params);
         // mark any passed params as loaded when creating this object
         $this->properties_loaded = array_merge($this->properties_loaded, array_combine(array_keys($params), array_fill(0, count($params), true)));
     }
 }
开发者ID:wwxgitcat,项目名称:habari,代码行数:15,代码来源:queryrecord.php

示例2: get

 /**
  * Return a single requested tag.
  *
  * <code>
  * $tag= Tag::get( array( 'tag_slug' => 'wooga' ) );
  * </code>
  *
  * @param array $paramarray An associated array of parameters, or a querystring
  * @return Tag The first tag that matched the given criteria
  **/
 static function get($paramarray = array())
 {
     // Defaults
     $defaults = array('where' => array(), 'fetch_fn' => 'get_row');
     foreach ($defaults['where'] as $index => $where) {
         $defaults['where'][$index] = array_merge(Controller::get_handler()->handler_vars, $where, Utils::get_params($paramarray));
     }
     // make sure we get at most one result
     $defaults['limit'] = 1;
     return Tags::get($defaults);
 }
开发者ID:anupom,项目名称:my-blog,代码行数:21,代码来源:tag.php

示例3: __construct

 /**
  * Constructor for the CronJob class.
  *
  * @see QueryRecord::__construct()
  * @param array $paramarray an associative array or querystring of initial field values
  */
 public function __construct($paramarray = array())
 {
     $this->now = HabariDateTime::date_create();
     // Defaults
     $this->fields = array_merge(self::default_fields(), $this->fields);
     // maybe serialize the callback
     $paramarray = Utils::get_params($paramarray);
     if (isset($paramarray['callback']) && (is_array($paramarray['callback']) || is_object($paramarray['callback']))) {
         $paramarray['callback'] = serialize($paramarray['callback']);
     }
     parent::__construct($paramarray);
     $this->exclude_fields('cron_id');
 }
开发者ID:ringmaster,项目名称:system,代码行数:19,代码来源:cronjob.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 $paramarry An associated array of parameters, or a querystring
     * @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 = '';
        // Put incoming parameters into the local scope
        $paramarray = Utils::get_params($paramarray);
        $select_fields = LogEntry::default_fields();
        if (!isset($paramarray['return_data'])) {
            unset($select_fields['data']);
        }
        foreach ($select_fields as $field => $value) {
            $select .= '' == $select ? "{log}.{$field}" : ", {log}.{$field}";
        }
        // Default parameters.
        $orderby = 'ORDER BY timestamp DESC, id DESC';
        $limit = Options::get('pagination');
        // Get any full-query parameters
        $possible = array('orderby', 'fetch_fn', 'count', 'month_cts', 'nolimit', 'index', 'limit', 'offset');
        foreach ($possible as $varname) {
            if (isset($paramarray[$varname])) {
                ${$varname} = $paramarray[$varname];
            }
        }
        foreach ($paramarray as $key => $value) {
            if ('orderby' == $key) {
                $orderby = ' ORDER BY ' . $value;
                continue;
            }
        }
        // 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());
        }
        $wheres = array();
        $join = '';
        if (isset($paramarray['where']) && is_string($paramarray['where'])) {
            $wheres[] = $paramarray['where'];
        } else {
            foreach ($wheresets as $paramset) {
                // Safety mechanism to prevent empty queries
                $where = array('1=1');
                $paramset = array_merge((array) $paramarray, (array) $paramset);
                if (isset($paramset['id']) && is_numeric($paramset['id'])) {
                    $where[] = "id= ?";
                    $params[] = $paramset['id'];
                }
                if (isset($paramset['user_id'])) {
                    $where[] = "user_id= ?";
                    $params[] = $paramset['user_id'];
                }
                if (isset($paramset['severity']) && 'any' != LogEntry::severity_name($paramset['severity'])) {
                    $where[] = "severity_id= ?";
                    $params[] = LogEntry::severity($paramset['severity']);
                }
                if (isset($paramset['type_id'])) {
                    if (is_array($paramset['type_id'])) {
                        $types = array_filter($paramset['type_id'], 'is_numeric');
                        if (count($types)) {
                            $where[] = 'type_id IN (' . implode(',', $types) . ')';
                        }
                    } else {
                        $where[] = 'type_id = ?';
                        $params[] = $paramset['type_id'];
                    }
                }
                if (isset($paramset['module'])) {
                    if (!is_array($paramset['module'])) {
                        $paramset['module'] = array($paramset['module']);
                    }
                    $where[] = 'type_id IN ( SELECT DISTINCT id FROM {log_types} WHERE module IN ( ' . implode(', ', array_fill(0, count($paramset['module']), '?')) . ' ) )';
                    $params = array_merge($params, $paramset['module']);
                }
                if (isset($paramset['type'])) {
                    if (!is_array($paramset['type'])) {
                        $paramset['type'] = array($paramset['type']);
                    }
                    $where[] = 'type_id IN ( SELECT DISTINCT id FROM {log_types} WHERE type IN ( ' . implode(', ', array_fill(0, count($paramset['type']), '?')) . ' ) )';
                    $params = array_merge($params, $paramset['type']);
                }
                if (isset($paramset['ip'])) {
                    $where[] = 'ip = ?';
                    $params[] = $paramset['ip'];
                }
                /* do searching */
                if (isset($paramset['criteria'])) {
                    preg_match_all('/(?<=")(\\w[^"]*)(?=")|([:\\w]+)/u', $paramset['criteria'], $matches);
                    foreach ($matches[0] as $word) {
                        if (preg_match('%^id:(\\d+)$%i', $word, $special_crit)) {
                            $where[] .= '(id = ?)';
//.........这里部分代码省略.........
开发者ID:wwxgitcat,项目名称:habari,代码行数:101,代码来源:eventlog.php

示例5: __construct

 /**
  * constructor __construct
  * Constructor for the QueryRecord class.
  * @param array an associative array of initial field values.
  **/
 public function __construct($paramarray = array())
 {
     $this->loaded = true;
     // Defaults
     $this->fields = array_merge($this->fields, Utils::get_params($paramarray));
 }
开发者ID:anupom,项目名称:my-blog,代码行数:11,代码来源:queryrecord.php

示例6: more

 /**
  * Returns a truncated version of post content when the post isn't being displayed on its own.
  * Posts are split either at the comment <!--more--> or at the specified maximums.
  * Use only after applying autop or other paragrpah styling methods.
  * Apply to posts using:
  * <code>Format::apply_with_hook_params( 'more', 'post_content_out' );</code>
  * @param string $content The post content
  * @param Post $post The Post object of the post
  * @param string $more_text The text to use in the "read more" link.
  * @param integer $max_words null or the maximum number of words to use before showing the more link
  * @param integer $max_paragraphs null or the maximum number of paragraphs to use before showing the more link
  * @param boolean $inside_last Should the link be placed inside the last element, or not? Default: true
  * @return string The post content, suitable for display
  */
 public static function more($content, $post, $properties = array())
 {
     // If the post requested is the post under consideration, always return the full post
     if ($post->slug == Controller::get_var('slug')) {
         return $content;
     } elseif (is_string($properties)) {
         $args = func_get_args();
         $more_text = $properties;
         $max_words = isset($args[3]) ? $args[3] : null;
         $max_paragraphs = isset($args[4]) ? $args[4] : null;
         $inside_last = isset($args[5]) ? $args[5] : true;
         $paramstring = "";
     } else {
         $paramstring = "";
         $paramarray = Utils::get_params($properties);
         $more_text = isset($paramarray['more_text']) ? $paramarray['more_text'] : 'Read More';
         $max_words = isset($paramarray['max_words']) ? $paramarray['max_words'] : null;
         $max_paragraphs = isset($paramarray['max_paragraphs']) ? $paramarray['max_paragraphs'] : null;
         $inside_last = isset($paramarray['inside_last']) ? $paramarray['inside_last'] : true;
         if (isset($paramarray['title:before']) || isset($paramarray['title']) || isset($paramarray['title:after'])) {
             $paramstring .= 'title="';
             if (isset($paramarray['title:before'])) {
                 $paramstring .= $paramarray['title:before'];
             }
             if (isset($paramarray['title'])) {
                 $paramstring .= $post->title;
             }
             if (isset($paramarray['title:after'])) {
                 $paramstring .= $paramarray['title:after'];
             }
             $paramstring .= '" ';
         }
         if (isset($paramarray['class'])) {
             $paramstring .= 'class="' . $paramarray['class'] . '" ';
         }
     }
     $link_text = '<a ' . $paramstring . ' href="' . $post->permalink . '">' . $more_text . '</a>';
     // if we want it inside the last element, make sure there's a space before the link
     if ($inside_last) {
         $link_text = ' ' . $link_text;
     }
     // check for a <!--more--> link, which sets exactly where we should split
     $matches = preg_split('/<!--\\s*more\\s*-->/isu', $content, 2, PREG_SPLIT_NO_EMPTY);
     if (count($matches) > 1) {
         $summary = reset($matches);
     } else {
         // otherwise, we need to summarize it automagically
         $max_words = empty($max_words) ? 9999999 : intval($max_words);
         $max_paragraphs = empty($max_paragraphs) ? 9999999 : intval($max_paragraphs);
         $summary = Format::summarize($content, $max_words, $max_paragraphs);
     }
     // if the summary is equal to the length of the content (or somehow greater??), there's no need to add a link, just return the content
     if (MultiByte::strlen($summary) >= MultiByte::strlen($content)) {
         return $content;
     } else {
         // make sure there's actually text to append before we waste our time
         if (strlen($more_text)) {
             // parse out the summary and stick in our linky goodness
             // tokenize the summary
             $ht = new HTMLTokenizer($summary);
             $summary_set = $ht->parse();
             // tokenize the link we're adding
             $ht = new HTMLTokenizer($link_text);
             $link_set = $ht->parse();
             // find out where to put the link by bumping the iterator to the last element
             $end = $summary_set->end();
             // and what index is that?
             $key = $summary_set->key();
             // if we want it inside the last element, we're good to go - if we want it outside, we need to add it as the *next* element
             if ($inside_last == false) {
                 $key++;
             }
             // if the element is a text node, there were no tags; probably not autop'ed yet, just add link as new line
             if ($end['type'] == HTMLTokenizer::NODE_TYPE_TEXT) {
                 $summary_set->insert($link_set, $key + 1);
             } else {
                 // inject it, whereever we decided it should go
                 $summary_set->insert($link_set, $key);
             }
             // and return a stringified version
             return (string) $summary_set;
         } else {
             // no text to append? just return the summary
             return $summary;
         }
     }
//.........这里部分代码省略.........
开发者ID:wwxgitcat,项目名称:habari,代码行数:101,代码来源:format.php

示例7: get

    /**
     * Returns a post or posts based on supplied parameters.
     * <b>THIS CLASS SHOULD CACHE QUERY RESULTS!</b>
     *
     * @param array $paramarry An associated array of parameters, or a querystring
     * @return array An array of Post objects, or a single post object, depending on request
     */
    public static function get($paramarray = array())
    {
        $join_params = array();
        $params = array();
        $fns = array('get_results', 'get_row', 'get_value');
        $select_ary = array();
        // Default fields to select, everything by default
        foreach (Post::default_fields() as $field => $value) {
            $select_ary[$field] = "{posts}.{$field} AS {$field}";
        }
        // Default parameters
        $orderby = 'pubdate DESC';
        // If $paramarray is a querystring, convert it to an array
        $paramarray = Utils::get_params($paramarray);
        // Define the WHERE sets to process and OR in the final SQL statement
        if (isset($paramarray['where']) && is_array($paramarray['where'])) {
            $wheresets = $paramarray['where'];
        } else {
            $wheresets = array(array());
        }
        /* Start building the WHERE clauses */
        $wheres = array();
        $joins = array();
        // If the request as a textual WHERE clause, skip the processing of the $wheresets since it's empty
        if (isset($paramarray['where']) && is_string($paramarray['where'])) {
            $wheres[] = $paramarray['where'];
        } else {
            foreach ($wheresets as $paramset) {
                // Safety mechanism to prevent empty queries
                $where = array();
                $paramset = array_merge((array) $paramarray, (array) $paramset);
                // $nots= preg_grep( '%^not:(\w+)$%iu', (array) $paramset );
                if (isset($paramset['id'])) {
                    if (is_array($paramset['id'])) {
                        array_walk($paramset['id'], create_function('&$a,$b', '$a = intval($a);'));
                        $where[] = "{posts}.id IN (" . implode(',', array_fill(0, count($paramset['id']), '?')) . ")";
                        $params = array_merge($params, $paramset['id']);
                    } else {
                        $where[] = "{posts}.id = ?";
                        $params[] = (int) $paramset['id'];
                    }
                }
                if (isset($paramset['not:id'])) {
                    if (is_array($paramset['not:id'])) {
                        array_walk($paramset['not:id'], create_function('&$a,$b', '$a = intval($a);'));
                        $where[] = "{posts}.id NOT IN (" . implode(',', array_fill(0, count($paramset['not:id']), '?')) . ")";
                        $params = array_merge($params, $paramset['not:id']);
                    } else {
                        $where[] = "{posts}.id != ?";
                        $params[] = (int) $paramset['not:id'];
                    }
                }
                if (isset($paramset['status']) && $paramset['status'] != 'any' && 0 !== $paramset['status']) {
                    if (is_array($paramset['status'])) {
                        // remove 'any' from the list if we have an array
                        $paramset['status'] = array_diff($paramset['status'], array('any'));
                        array_walk($paramset['status'], create_function('&$a,$b', '$a = Post::status($a);'));
                        $where[] = "{posts}.status IN (" . implode(',', array_fill(0, count($paramset['status']), '?')) . ")";
                        $params = array_merge($params, $paramset['status']);
                    } else {
                        $where[] = "{posts}.status = ?";
                        $params[] = (int) Post::status($paramset['status']);
                    }
                }
                if (isset($paramset['content_type']) && $paramset['content_type'] != 'any' && 0 !== $paramset['content_type']) {
                    if (is_array($paramset['content_type'])) {
                        // remove 'any' from the list if we have an array
                        $paramset['content_type'] = array_diff($paramset['content_type'], array('any'));
                        array_walk($paramset['content_type'], create_function('&$a,$b', '$a = Post::type($a);'));
                        $where[] = "{posts}.content_type IN (" . implode(',', array_fill(0, count($paramset['content_type']), '?')) . ")";
                        $params = array_merge($params, $paramset['content_type']);
                    } else {
                        $where[] = "{posts}.content_type = ?";
                        $params[] = (int) Post::type($paramset['content_type']);
                    }
                }
                if (isset($paramset['not:content_type'])) {
                    if (is_array($paramset['not:content_type'])) {
                        array_walk($paramset['not:content_type'], create_function('&$a,$b', '$a = Post::type($a);'));
                        $where[] = "{posts}.content_type NOT IN (" . implode(',', array_fill(0, count($paramset['not:content_type']), '?')) . ")";
                        $params = array_merge($params, $paramset['not:content_type']);
                    } else {
                        $where[] = "{posts}.content_type != ?";
                        $params[] = (int) Post::type($paramset['not:content_type']);
                    }
                }
                if (isset($paramset['slug'])) {
                    if (is_array($paramset['slug'])) {
                        $where[] = "{posts}.slug IN (" . implode(',', array_fill(0, count($paramset['slug']), '?')) . ")";
                        $params = array_merge($params, $paramset['slug']);
                    } else {
                        $where[] = "{posts}.slug = ?";
                        $params[] = (string) $paramset['slug'];
//.........这里部分代码省略.........
开发者ID:psaintlaurent,项目名称:Habari,代码行数:101,代码来源:posts.php

示例8: get

    /**
     * function get
     * Returns requested comments
     * @param array An associated array of parameters, or a querystring
     * @return array An array of Comment objects, one for each query result
     *
     * <code>
     * $comments = comments::get( array ( "author" => "skippy" ) );
     * $comments = comments::get( array ( "slug" => "first-post", "status" => "1", "orderby" => "date ASC" ) );
     * </code>
     *
     **/
    public static function get($paramarray = array())
    {
        $params = array();
        $fns = array('get_results', 'get_row', 'get_value');
        $select = '';
        // what to select -- by default, everything
        foreach (Comment::default_fields() as $field => $value) {
            $select .= '' == $select ? "{comments}.{$field}" : ", {comments}.{$field}";
        }
        // defaults
        $orderby = 'date DESC';
        $limit = Options::get('pagination');
        // Put incoming parameters into the local scope
        $paramarray = Utils::get_params($paramarray);
        // 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());
        }
        $wheres = array();
        $joins = array();
        if (isset($paramarray['where']) && is_string($paramarray['where'])) {
            $wheres[] = $paramarray['where'];
        } else {
            foreach ($wheresets as $paramset) {
                // safety mechanism to prevent empty queries
                $where = array('1=1');
                $paramset = array_merge((array) $paramarray, (array) $paramset);
                if (isset($paramset['id']) && (is_numeric($paramset['id']) || is_array($paramset['id']))) {
                    if (is_numeric($paramset['id'])) {
                        $where[] = "{comments}.id= ?";
                        $params[] = $paramset['id'];
                    } else {
                        if (is_array($paramset['id']) && !empty($paramset['id'])) {
                            $id_list = implode(',', $paramset['id']);
                            // Clean up the id list - remove all non-numeric or comma information
                            $id_list = preg_replace("/[^0-9,]/", "", $id_list);
                            // You're paranoid, ringmaster! :P
                            $limit = count($paramset['id']);
                            $where[] = '{comments}.id IN (' . addslashes($id_list) . ')';
                        }
                    }
                }
                if (isset($paramset['status']) && FALSE !== $paramset['status']) {
                    if (is_array($paramset['status'])) {
                        $paramset['status'] = array_diff($paramset['status'], array('any'));
                        array_walk($paramset['status'], create_function('&$a,$b', '$a = Comment::status( $a );'));
                        $where[] = "{comments}.status IN (" . Utils::placeholder_string(count($paramset['status'])) . ")";
                        $params = array_merge($params, $paramset['status']);
                    } else {
                        $where[] = "{comments}.status= ?";
                        $params[] = Comment::status($paramset['status']);
                    }
                }
                if (isset($paramset['type']) && FALSE !== $paramset['type']) {
                    if (is_array($paramset['type'])) {
                        $paramset['type'] = array_diff($paramset['type'], array('any'));
                        array_walk($paramset['type'], create_function('&$a,$b', '$a = Comment::type( $a );'));
                        $where[] = "type IN (" . Utils::placeholder_string(count($paramset['type'])) . ")";
                        $params = array_merge($params, $paramset['type']);
                    } else {
                        $where[] = "type= ?";
                        $params[] = Comment::type($paramset['type']);
                    }
                }
                if (isset($paramset['name'])) {
                    $where[] = "name= ?";
                    $params[] = $paramset['name'];
                }
                if (isset($paramset['email'])) {
                    $where[] = "email= ?";
                    $params[] = $paramset['email'];
                }
                if (isset($paramset['url'])) {
                    $where[] = "url= ?";
                    $params[] = $paramset['url'];
                }
                if (isset($paramset['post_id'])) {
                    $where[] = "{comments}.post_id= ?";
                    $params[] = $paramset['post_id'];
                }
                if (isset($paramset['ip'])) {
                    $where[] = "ip= ?";
                    $params[] = $paramset['ip'];
                }
                /* do searching */
                if (isset($paramset['post_author'])) {
//.........这里部分代码省略.........
开发者ID:psaintlaurent,项目名称:Habari,代码行数:101,代码来源:comments.php

示例9: get

	/**
	 * Returns a user or users based on supplied parameters.
	 * @todo This class should cache query results!
	 *
	 * @param array $paramarray An associated array of parameters, or a querystring
	 * @return array An array of User objects, or a single User object, depending on request
	 */
	public static function get( $paramarray = array() )
	{
		$params = array();
		$fns = array( 'get_results', 'get_row', 'get_value' );
		$select = '';
		// what to select -- by default, everything
		foreach ( User::default_fields() as $field => $value ) {
			$select .= ( '' == $select )
				? "{users}.$field"
				: ", {users}.$field";
		}
		// defaults
		$orderby = 'id ASC';
		$nolimit = true;

		// Put incoming parameters into the local scope
		$paramarray = Utils::get_params( $paramarray );

		// 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() );
		}

		$wheres = array();
		$join = '';
		if ( isset( $paramarray['where'] ) && is_string( $paramarray['where'] ) ) {
			$wheres[] = $paramarray['where'];
		}
		else {
			foreach ( $wheresets as $paramset ) {
				// safety mechanism to prevent empty queries
				$where = array();
				$paramset = array_merge( (array) $paramarray, (array) $paramset );

				$default_fields = User::default_fields();
				foreach ( User::default_fields() as $field => $scrap ) {
					if ( !isset( $paramset[$field] ) ) {
						continue;
					}
					switch ( $field ) {
						case 'id':
							if ( !is_numeric( $paramset[$field] ) ) {
								continue;
							}
						default:
							$where[] = "{$field} = ?";
							$params[] = $paramset[$field];
					}
				}

				if ( isset( $paramset['info'] ) && is_array( $paramset['info'] ) ) {
					$join .= 'INNER JOIN {userinfo} ON {users}.id = {userinfo}.user_id';
					foreach ( $paramset['info'] as $info_name => $info_value ) {
						$where[] = '{userinfo}.name = ? AND {userinfo}.value = ?';
						$params[] = $info_name;
						$params[] = $info_value;
					}
				}

				if ( isset( $paramset['criteria'] ) ) {
					if ( isset( $paramset['criteria_fields'] ) ) {
						// Support 'criteria_fields' => 'author,ip' rather than 'criteria_fields' => array( 'author', 'ip' )
						if ( !is_array( $paramset['criteria_fields'] ) && is_string( $paramset['criteria_fields'] ) ) {
							$paramset['criteria_fields'] = explode( ',', $paramset['criteria_fields'] );
						}
					}
					else {
						$paramset['criteria_fields'] = array( 'username' );
					}
					$paramset['criteria_fields'] = array_unique( $paramset['criteria_fields'] );

					// this regex matches any unicode letters (\p{L}) or numbers (\p{N}) inside a set of quotes (but strips the quotes) OR not in a set of quotes
					preg_match_all( '/(?<=")([\p{L}\p{N}]+[^"]*)(?=")|([\p{L}\p{N}]+)/u', $paramset['criteria'], $matches );
					$where_search = array();
					foreach ( $matches[0] as $word ) {
						foreach ( $paramset['criteria_fields'] as $criteria_field ) {
							$where_search[] .= "( LOWER( {users}.$criteria_field ) LIKE ? )";
							$params[] = '%' . MultiByte::strtolower( $word ) . '%';
						}
					}
					if ( count( $where_search ) > 0 ) {
						$where[] = '(' . implode( " \nOR\n ", $where_search ).')';
					}
				}

				if ( count( $where ) > 0 ) {
					$wheres[] = ' (' . implode( ' AND ', $where ) . ') ';
				}
			}
		}
//.........这里部分代码省略.........
开发者ID:rynodivino,项目名称:system,代码行数:101,代码来源:users.php

示例10: 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

示例11: get

	/**
	 * Returns a post or posts based on supplied parameters.
	 * @todo <b>THIS CLASS SHOULD CACHE QUERY RESULTS!</b>
	 *
	 * @param array $paramarray An associative array of parameters, or a querystring.
	 * The following keys are supported:
	 * - id => a post id or array of post ids
	 * - not:id => a post id or array of post ids to exclude
	 * - slug => a post slug or array of post slugs
	 * - not:slug => a post slug or array of post slugs to exclude
	 * - user_id => an author id or array of author ids
	 * - content_type => a post content type or array post content types
	 * - not:content_type => a post content type or array post content types to exclude
	 * - status => a post status, an array of post statuses, or 'any' for all statuses
	 * - year => a year of post publication
	 * - month => a month of post publication, ignored if year is not specified
	 * - day => a day of post publication, ignored if month and year are not specified
	 * - before => a timestamp to compare post publication dates
	 * - after => a timestamp to compare post publication dates
	 * - month_cts => return the number of posts published in each month
	 * - criteria => a literal search string to match post content
	 * - title => an exact case-insensitive match to a post title
	 * - title_search => a search string that acts only on the post title
	 * - has:info => a post info key or array of post info keys, which should be present
	 * - all:info => a post info key and value pair or array of post info key and value pairs, which should all be present and match
	 * - not:all:info => a post info key and value pair or array of post info key and value pairs, to exclude if all are present and match
	 * - any:info => a post info key and value pair or array of post info key and value pairs, any of which can match
	 * - not:any:info => a post info key and value pair or array of post info key and value pairs, to exclude if any are present and match
	 * - vocabulary => an array describing parameters related to vocabularies attached to posts. This can be one of two forms:
	 *   - object-based, in which an array of Term objects are passed
	 *     - any => posts associated with any of the terms are returned
	 *     - all => posts associated with all of the terms are returned
	 *     - not => posts associated with none of the terms are returned
	 *   - property-based, in which an array of vocabulary names and associated fields are passed
	 *     - vocabulary_name:term => a vocabulary name and term slug pair or array of vocabulary name and term slug pairs, any of which can be associated with the posts
	 *     - vocabulary_name:term_display => a vocabulary name and term display pair or array of vocabulary name and term display pairs, any of which can be associated with the posts
	 *     - vocabulary_name:not:term => a vocabulary name and term slug pair or array of vocabulary name and term slug pairs, none of which can be associated with the posts
	 *     - vocabulary_name:not:term_display => a vocabulary name and term display pair or array of vocabulary name and term display pairs, none of which can be associated with the posts
	 *     - vocabulary_name:all:term => a vocabulary name and term slug pair or array of vocabulary name and term slug pairs, all of which must be associated with the posts
	 *     - vocabulary_name:all:term_display => a vocabulary name and term display pair or array of vocabulary name and term display pairs, all of which must be associated with the posts
	 * - limit => the maximum number of posts to return, implicitly set for many queries
	 * - nolimit => do not implicitly set limit
	 * - offset => amount by which to offset returned posts, used in conjunction with limit
	 * - page => the 'page' of posts to return when paging, sets the appropriate offset
	 * - count => return the number of posts that would be returned by this request
	 * - orderby => how to order the returned posts
	 * - groupby => columns by which to group the returned posts, for aggregate functions
	 * - having => for selecting posts based on an aggregate function
	 * - where => manipulate the generated WHERE clause. Currently broken, see https://trac.habariproject.org/habari/ticket/1383
	 * - add_select => an array of clauses to be added to the generated SELECT clause.
	 * - fetch_fn => the function used to fetch data, one of 'get_results', 'get_row', 'get_value', 'get_query'
	 *
	 * Further description of parameters, including usage examples, can be found at
	 * http://wiki.habariproject.org/en/Dev:Retrieving_Posts
	 *
	 * @return array An array of Post objects, or a single post object, depending on request
	 */
	public static function get( $paramarray = array() )
	{
		static $presets;

		// If $paramarray is a string, use it as a Preset
		if(is_string($paramarray)) {
			$paramarray = array('preset' => $paramarray);
		}

		// If $paramarray is a querystring, convert it to an array
		$paramarray = Utils::get_params( $paramarray );

		// If a preset is defined, get the named array and merge it with the provided parameters,
		// allowing the additional $paramarray settings to override the preset
		if(isset($paramarray['preset'])) {
			if(!isset($presets)) {
				$presets = Plugins::filter('posts_get_all_presets', $presets, $paramarray['preset']);
			}
			if(isset($presets[$paramarray['preset']])) {
				$preset = Plugins::filter('posts_get_update_preset', $presets[$paramarray['preset']], $paramarray['preset'], $paramarray);
				$paramarray = array_merge($paramarray, $preset);
			}
		}

		// let plugins alter the param array before we use it. could be useful for modifying search results, etc.
		$paramarray = Plugins::filter( 'posts_get_paramarray', $paramarray );

		$join_params = array();
		$params = array();
		$fns = array( 'get_results', 'get_row', 'get_value', 'get_query' );
		$select_ary = array();

		// Default fields to select, everything by default
		foreach ( Post::default_fields() as $field => $value ) {
			$select_ary[$field] = "{posts}.$field AS $field";
			$select_distinct[$field] = "{posts}.$field";
		}

		// Default parameters
		$orderby = 'pubdate DESC';

		// Define the WHERE sets to process and OR in the final SQL statement
		if ( isset( $paramarray['where'] ) && is_array( $paramarray['where'] ) ) {
//.........这里部分代码省略.........
开发者ID:rynodivino,项目名称:system,代码行数:101,代码来源:posts.php

示例12: action_before_act_admin

 public function action_before_act_admin()
 {
     $user = User::identify();
     if (isset($user->info->limitaccess) && $user->info->limitaccess == 0) {
         return;
     }
     Plugins::register(array($this, 'kill_admin_user'), 'action', 'admin_theme_get_user');
     Plugins::register(array($this, 'kill_admin_user'), 'action', 'admin_theme_post_user');
     $menus = $this->get_menu();
     foreach ($menus as $mk => $m2) {
         if (!Options::get('limitaccess__' . $mk)) {
             $params = Utils::get_params($m2['url']);
             $page = $params['page'];
             unset($params['page']);
             $kill = true;
             foreach ($params as $k => $v) {
                 if (Controller::get_var($k) != $v) {
                     $kill = false;
                 }
             }
             if ($page == 'user') {
                 $kill = false;
             }
             if ($kill) {
                 Plugins::register(array($this, 'kill_admin'), 'action', 'admin_theme_post_' . $page);
                 Plugins::register(array($this, 'kill_admin'), 'action', 'admin_theme_get_' . $page);
             }
         }
     }
 }
开发者ID:habari-extras,项目名称:limitaccess,代码行数:30,代码来源:limitaccess.plugin.php

示例13: extract_args

 /**
  * Extract the possible arguments to use in the URL from the passed variable
  * @param mixed $args An array of values or a URLProperties object with properties to use in the construction of a URL
  * @param string $prefix
  * @return array Properties to use to construct  a URL
  */
 public static function extract_args($args, $prefix = '')
 {
     if (is_object($args)) {
         if ($args instanceof URLProperties) {
             $args = $args->get_url_args();
         } else {
             $args_ob = array();
             foreach ($args as $key => $value) {
                 $args_ob[$key] = $value;
             }
             $args = $args_ob;
         }
     } else {
         $args = Utils::get_params($args);
     }
     // can this be done with array_walk?
     if ($prefix && $args) {
         $args_out = array();
         foreach ($args as $key => $value) {
             $args_out[$prefix . $key] = $value;
         }
         $args = $args_out;
     }
     return $args;
 }
开发者ID:habari,项目名称:system,代码行数:31,代码来源:url.php

示例14: more

	/**
	 * Returns a truncated version of post content when the post isn't being displayed on its own.
	 * Posts are split either at the comment <!--more--> or at the specified maximums.
	 * Use only after applying autop or other paragrpah styling methods.
	 * Apply to posts using:
	 * <code>Format::apply_with_hook_params( 'more', 'post_content_out' );</code>
	 * @param string $content The post content
	 * @param Post $post The Post object of the post
	 * @param string $more_text The text to use in the "read more" link.
	 * @param integer $max_words null or the maximum number of words to use before showing the more link
	 * @param integer $max_paragraphs null or the maximum number of paragraphs to use before showing the more link
	 * @return string The post content, suitable for display
	 */
	public static function more( $content, $post, $properties = array() )
	{
		// If the post requested is the post under consideration, always return the full post
		if ( $post->slug == Controller::get_var( 'slug' ) ) {
			return $content;
		}
		elseif ( is_string( $properties ) ) {
			$args = func_get_args();
			$more_text = $properties;
			$max_words = ( isset( $args[3] ) ? $args[3] : null );
			$max_paragraphs = ( isset( $args[4] ) ? $args[4] : null );
			$paramstring = "";
		}
		else {
			$paramstring = "";
			$paramarray = Utils::get_params( $properties );

			$more_text = ( isset( $paramarray['more_text'] ) ? $paramarray['more_text'] : 'Read More' );
			$max_words = ( isset( $paramarray['max_words'] ) ? $paramarray['max_words'] : null );
			$max_paragraphs = ( isset( $paramarray['max_paragraphs'] ) ? $paramarray['max_paragraphs'] : null );

			if ( isset( $paramarray['title:before'] ) || isset( $paramarray['title'] ) || isset( $paramarray['title:after'] ) ) {
				$paramstring .= 'title="';

				if ( isset( $paramarray['title:before'] ) ) {
					$paramstring .= $paramarray['title:before'];
				}
				if ( isset( $paramarray['title'] ) ) {
					$paramstring .= $post->title;
				}
				if ( isset( $paramarray['title:after'] ) ) {
					$paramstring .= $paramarray['title:after'];
				}
				$paramstring .= '" ';
			}
			if ( isset( $paramarray['class'] ) ) {
				$paramstring .= 'class="' . $paramarray['class'] . '" ';
			}

		}
		$matches = preg_split( '/<!--\s*more\s*-->/isu', $content, 2, PREG_SPLIT_NO_EMPTY );
		if ( count( $matches ) > 1 ) {
			return ( $more_text != '' ) ? reset( $matches ) . ' <a ' . $paramstring . 'href="' . $post->permalink . '">' . $more_text . '</a>' : reset( $matches );
		}
		elseif ( isset( $max_words ) || isset( $max_paragraphs ) ) {
			$max_words = empty( $max_words ) ? 9999999 : intval( $max_words );
			$max_paragraphs = empty( $max_paragraphs ) ? 9999999 : intval( $max_paragraphs );
			$summary = Format::summarize( $content, $max_words, $max_paragraphs );
			if ( MultiByte::strlen( $summary ) >= MultiByte::strlen( $content ) ) {
				return $content;
			}
			else {
				if ( strlen( $more_text  ) ) {
					// Tokenize the summary and link
					$ht = new HTMLTokenizer( $summary );
					$summary_set = $ht->parse();
					$ht = new HTMLTokenizer( '<a ' . $paramstring . ' href="' . $post->permalink . '">' . $more_text . '</a>' );
					$link_set= $ht->parse();
					// Find out where to put the link
					$end = $summary_set->end();
					$key = $summary_set->key();
					// Inject the link
					$summary_set->insert( $link_set, $key );

					return (string)$summary_set;
				}
				else {
					return $summary;
				}
			}
		}

	return $content;
	}
开发者ID:rynodivino,项目名称:system,代码行数:87,代码来源:format.php

示例15: get

	/**
	 * Return a single requested log entry.
	 *
	 * <code>
	 * $log= LogEntry::get( array( 'id' => 5 ) );
	 * </code>
	 *
	 * @param array $paramarray An associated array of parameters, or a querystring
	 * @return object LogEntry The first log entry that matched the given criteria
	 */
	public static function get( $paramarray = array() )
	{
		// Default parameters.
		$defaults = array (
			'fetch_fn' => 'get_row',
		);
		$user = User::identify();
		if ( $user->loggedin ) {
			$defaults['where'][] = array(
				'user_id' => $user->id,
			);
		}
		foreach ( $defaults['where'] as $index => $where ) {
			$defaults['where'][$index] = array_merge( $where, Utils::get_params( $paramarray ) );
		}
		// Make sure we fetch only a single event. (LIMIT 1)
		$defaults['limit'] = 1;

		return EventLog::get( $defaults );
	}
开发者ID:rynodivino,项目名称:system,代码行数:30,代码来源:logentry.php


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