コード例 #1
0
 public function configure()
 {
     $form = new FormUI('selectivep');
     $options = array_flip(Post::list_active_post_types());
     unset($options[0]);
     $options = array_combine(array_map(function ($a) {
         return 'P-' . $a;
     }, $options), array_map(function ($a) {
         return 'Post Type: ' . $a;
     }, $options));
     $comment_options = array_combine(Comment::list_comment_types(), Comment::list_comment_types());
     $comment_options = array_combine(array_map(function ($a) {
         return 'C-' . $a;
     }, $comment_options), array_map(function ($a) {
         return 'Comment Type: ' . $a;
     }, $comment_options));
     $options = array_merge($options, $comment_options);
     //$options['comment'] = 'Any Comment';
     $form->append(new FormControlStatic('prompt', 'Select the types that should have autop applied to their content:'));
     $form->append(new FormControlCheckboxes('post_types', 'selectivep_types', 'Post types that should autop', $options));
     $form->append(new FormControlSubmit('save', 'Save'));
     return $form;
 }
コード例 #2
0
ファイル: comments.php プロジェクト: psaintlaurent/Habari
 /**
  * Parses a search string for status, type, author, and tag keywords. Returns
  * an associative array which can be passed to Comments::get(). If multiple
  * authors, statuses, or types are specified, we assume an implicit OR
  * such that (e.g.) any author that matches would be returned.
  *
  * @param string $search_string The search string
  * @return array An associative array which can be passed to Comments::get()
  */
 public static function search_to_get($search_string)
 {
     $keywords = array('author' => 1, 'status' => 1, 'type' => 1);
     // Comments::list_comment_statuses and list_comment_types return associative arrays with key/values
     // in the opposite order of the equivalent functions in Posts. Maybe we should change this?
     // In any case, we need to flip them for our purposes
     $statuses = array_flip(Comment::list_comment_statuses());
     $types = array_flip(Comment::list_comment_types());
     $arguments = array('name' => array(), 'status' => array(), 'type' => array());
     $criteria = '';
     $tokens = explode(' ', $search_string);
     foreach ($tokens as $token) {
         // check for a keyword:value pair
         if (preg_match('/^\\w+:\\S+$/u', $token)) {
             list($keyword, $value) = explode(':', $token);
             $keyword = strtolower($keyword);
             $value = MultiByte::strtolower($value);
             switch ($keyword) {
                 case 'author':
                     $arguments['name'][] = $value;
                     break;
                 case 'status':
                     if (isset($statuses[$value])) {
                         $arguments['status'][] = (int) $statuses[$value];
                     }
                     break;
                 case 'type':
                     if (isset($types[$value])) {
                         $arguments['type'][] = (int) $types[$value];
                     }
                     break;
             }
         } else {
             $criteria .= $token . ' ';
         }
     }
     // flatten keys that have single-element or no-element arrays
     foreach ($arguments as $key => $arg) {
         switch (count($arg)) {
             case 0:
                 unset($arguments[$key]);
                 break;
             case 1:
                 $arguments[$key] = $arg[0];
                 break;
         }
     }
     if ($criteria != '') {
         $arguments['criteria'] = $criteria;
     }
     return $arguments;
 }
コード例 #3
0
ファイル: comment.php プロジェクト: habari/system
 /**
  * Obtain the friendly name of a comment type, or null
  * @param string|integer A comment type number, or name
  * @return string A string of the comment type, or emptystring
  */
 public static function type_name($type)
 {
     $types = Comment::list_comment_types();
     if (is_numeric($type) && isset($types[$type])) {
         return $types[$type];
     }
     $types = array_flip($types);
     if (isset($types[$type])) {
         return $type;
     }
     return '';
 }
コード例 #4
0
	/**
	 * Handles the submission of the comment moderation form.
	 * @todo Separate delete from "delete until purge"
	 */
	public function post_comments()
	{
		// Get special search statuses
		$statuses = Comment::list_comment_statuses();
		$labels = array_map(
			create_function( '$a', 'return MultiByte::ucfirst(Plugins::filter("comment_status_display", $a));' ),
			$statuses
			);
		$terms = array_map(
			create_function( '$a', 'return "status:{$a}";' ),
			$statuses
			);
		$statuses = array_combine( $terms, $labels );

		// Get special search types
		$types = Comment::list_comment_types();
		$labels = array_map(
			create_function( '$a', 'return MultiByte::ucfirst(Plugins::filter("comment_type_display", $a, "singular")) ;' ),
			$types
		);
		$terms = array_map(
			create_function( '$a', 'return "type:{$a}";' ),
			$types
		);
		$types = array_combine( $terms, $labels );

		$this->theme->special_searches = array_merge( $statuses, $types );

		$this->fetch_comments();
		$this->display( 'comments' );
	}
コード例 #5
0
ファイル: adminhandler.php プロジェクト: psaintlaurent/Habari
 /**
  * Handles the submission of the comment moderation form.
  * @todo Separate delete from "delete until purge"
  */
 public function post_comments()
 {
     // Get special search statuses
     $statuses = Comment::list_comment_statuses();
     $statuses = array_combine($statuses, array_map(create_function('$a', 'return "status:{$a}";'), $statuses));
     // Get special search types
     $types = Comment::list_comment_types();
     $types = array_combine($types, array_map(create_function('$a', 'return "type:{$a}";'), $types));
     $this->theme->special_searches = array_merge($statuses, $types);
     $this->fetch_comments();
     $this->display('comments');
 }
コード例 #6
0
ファイル: comments.php プロジェクト: habari/system
 /**
  * Parses a search string for status, type, author, and tag keywords. Returns
  * an associative array which can be passed to Comments::get(). If multiple
  * authors, statuses, or types are specified, we assume an implicit OR
  * such that (e.g.) any author that matches would be returned.
  *
  * @param string $search_string The search string
  * @return array An associative array which can be passed to Comments::get()
  */
 public static function search_to_get($search_string)
 {
     $statuses = array_flip(Comment::list_comment_statuses());
     $types = array_flip(Comment::list_comment_types());
     $arguments = array('name' => array(), 'status' => array(), 'type' => array());
     $criteria = '';
     $tokens = explode(' ', $search_string);
     foreach ($tokens as $token) {
         // check for a keyword:value pair
         if (preg_match('/^\\w+:\\S+$/u', $token)) {
             list($keyword, $value) = explode(':', $token);
             $keyword = strtolower($keyword);
             $value = MultiByte::strtolower($value);
             switch ($keyword) {
                 case 'author':
                     $arguments['name'][] = $value;
                     break;
                 case 'status':
                     if (isset($statuses[$value])) {
                         $arguments['status'][] = (int) $statuses[$value];
                     }
                     break;
                 case 'type':
                     if (isset($types[$value])) {
                         $arguments['type'][] = (int) $types[$value];
                     }
                     break;
             }
         } else {
             $criteria .= $token . ' ';
         }
     }
     // flatten keys that have single-element or no-element arrays
     foreach ($arguments as $key => $arg) {
         switch (count($arg)) {
             case 0:
                 unset($arguments[$key]);
                 break;
             case 1:
                 $arguments[$key] = $arg[0];
                 break;
         }
     }
     if ($criteria != '') {
         $arguments['criteria'] = $criteria;
     }
     return $arguments;
 }
コード例 #7
0
 /**
  * Handles the submission of the comment moderation form.
  * @todo Separate delete from "delete until purge"
  */
 public function post_comments()
 {
     // Get special search statuses
     $statuses = Comment::list_comment_statuses();
     $labels = array_map(function ($a) {
         return MultiByte::ucfirst(Plugins::filter("comment_status_display", $a));
     }, $statuses);
     $terms = array_map(function ($a) {
         return "status:{$a}";
     }, $statuses);
     $statuses = array_combine($terms, $labels);
     // Get special search types
     $types = Comment::list_comment_types();
     $labels = array_map(function ($a) {
         return MultiByte::ucfirst(Plugins::filter("comment_type_display", $a, "singular"));
     }, $types);
     $terms = array_map(function ($a) {
         return "type:{$a}";
     }, $types);
     $types = array_combine($terms, $labels);
     $this->theme->special_searches = array_merge($statuses, $types);
     $this->fetch_comments();
     // Create the form for the search and manage dropbutton. I bet we can save some code when combining this with the other manage pages.
     $form = new FormUI('manage');
     //$search = FormControlFacet::create('search');
     //$form->append($search);
     $aggregate = FormControlAggregate::create('selected_items')->set_selector('.comment_checkbox')->label('None Selected');
     $form->append($aggregate);
     $page_actions = FormControlDropbutton::create('page_actions');
     $page_actions->append(FormControlSubmit::create('delete')->set_caption(_t('Delete Selected'))->set_properties(array('onclick' => 'itemManage.update(\'delete\');return false;', 'title' => _t('Delete Selected'))));
     Plugins::act('comments_manage_actions', $page_actions);
     $form->append($page_actions);
     Stack::add('admin_header_javascript', 'manage-js');
     $this->theme->form = $form;
     $this->display('comments');
 }