示例#1
0
文件: Post.php 项目: relisher/chyrp
 /**
  * Function: groups
  * Lists the groups who can view the post if the post's status is specific to certain groups.
  */
 public function groups()
 {
     if ($this->no_results) {
         return false;
     }
     preg_match_all("/\\{([0-9]+)\\}/", $this->status, $groups, PREG_PATTERN_ORDER);
     if (empty($groups[1])) {
         return false;
     }
     $names = array();
     foreach ($groups[1] as $group_id) {
         $group = new Group($group_id);
         $names[] = $group->name;
     }
     return list_notate($names);
 }
示例#2
0
文件: tags.php 项目: vito/chyrp-site
 public function main_tag($main)
 {
     if (!isset($_GET['name'])) {
         return $main->resort(array("pages/tag", "pages/index"), array("reason" => "no_tag_specified"), __("No Tag", "tags"));
     }
     $sql = SQL::current();
     $tags = explode(" ", $_GET['name']);
     $likes = array();
     foreach ($tags as $name) {
         $likes[] = self::yaml_match($name);
     }
     $attributes = $sql->select("post_attributes", array("value", "post_id"), array("name" => "tags", "value like all" => $likes));
     $ids = array();
     foreach ($attributes->fetchAll() as $index => $row) {
         foreach ($tags as &$tag) {
             $search = array_search($tag, YAML::load($row["value"]));
             $tag = $search ? $search : $tag;
         }
         $ids[] = $row["post_id"];
     }
     $tag = list_notate($tags, true);
     if (empty($ids)) {
         return $main->resort(array("pages/tag", "pages/index"), array("reason" => "tag_not_found"), __("Invalid Tag", "tags"));
     }
     $posts = new Paginator(Post::find(array("placeholders" => true, "where" => array("id" => $ids))), Config::current()->posts_per_page);
     if (empty($posts)) {
         return false;
     }
     $main->display(array("pages/tag", "pages/index"), array("posts" => $posts, "tag" => $tag, "tags" => $tags), _f("Posts tagged with %s", array($tag), "tags"));
 }