Dotclear

source: admin/search.php @ 2720:bc400ebfc2e9

Revision 2720:bc400ebfc2e9, 4.6 KB checked in by Dsls, 11 years ago (diff)

One step further towards php hardcoded links annihilation in admin sources, more to come...

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
7# Licensed under the GPL version 2.0 license.
8# See LICENSE file or
9# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10#
11# -- END LICENSE BLOCK -----------------------------------------
12
13require dirname(__FILE__).'/../inc/admin/prepend.php';
14
15dcPage::check('usage,contentadmin');
16
17$q = !empty($_REQUEST['q']) ? $_REQUEST['q'] : (!empty($_REQUEST['qx']) ? $_REQUEST['qx'] : null);
18$qtype = !empty($_REQUEST['qtype']) ? $_REQUEST['qtype'] : 'p';
19if ($qtype != 'c' && $qtype != 'p') {
20     $qtype = 'p';
21}
22
23$starting_scripts = '';
24
25$page = !empty($_GET['page']) ? max(1,(integer) $_GET['page']) : 1;
26$nb_per_page =  30;
27
28
29if ($q)
30{
31     $params = array();
32
33     # Get posts
34     if ($qtype == 'p')
35     {
36          $starting_scripts .= dcPage::jsLoad('js/_posts_list.js');
37
38          $params['search'] = $q;
39          $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page);
40          $params['no_content'] = true;
41          $params['order'] = 'post_dt DESC';
42
43          try {
44               $posts = $core->blog->getPosts($params);
45               $counter = $core->blog->getPosts($params,true);
46               $post_list = new adminPostList($core,$posts,$counter->f(0));
47          } catch (Exception $e) {
48               $core->error->add($e->getMessage());
49          }
50     }
51     # Get comments
52     elseif ($qtype == 'c')
53     {
54          $starting_scripts .= dcPage::jsLoad('js/_comments.js');
55
56          $params['search'] = $q;
57          $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page);
58          $params['no_content'] = true;
59          $params['order'] = 'comment_dt DESC';
60
61          try {
62               $comments = $core->blog->getComments($params);
63               $counter = $core->blog->getComments($params,true);
64               $comment_list = new adminCommentList($core,$comments,$counter->f(0));
65          } catch (Exception $e) {
66               $core->error->add($e->getMessage());
67          }
68     }
69}
70
71if ($qtype == 'p') {
72     $posts_actions_page = new dcPostsActionsPage($core,$core->adminurl->get("admin.search"),array('q'=>$q,'qtype'=>$qtype));
73
74     if ($posts_actions_page->process()) {
75          return;
76     }
77} else {
78     $comments_actions_page = new dcCommentsActionsPage($core,$core->adminurl->get("admin.search"),array('q'=>$q,'qtype'=>$qtype));
79
80     if ($comments_actions_page->process()) {
81          return;
82     }
83}
84
85dcPage::open(__('Search'),$starting_scripts,
86     dcPage::breadcrumb(
87          array(
88               html::escapeHTML($core->blog->name) => '',
89               __('Search') => ''
90          ))
91);
92
93echo
94'<form action="'.$core->adminurl->get("admin.search").'" method="get">'.
95'<div class="fieldset"><h3>'.__('Search options').'</h3>'.
96'<p><label for="q">'.__('Query:').' </label>'.form::field('q',30,255,html::escapeHTML($q)).'</p>'.
97'<p><label for="qtype1" class="classic">'.form::radio(array('qtype','qtype1'),'p',$qtype == 'p').' '.__('Search in entries').'</label> '.
98'<label for="qtype2" class="classic">'.form::radio(array('qtype','qtype2'),'c',$qtype == 'c').' '.__('Search in comments').'</label></p>'.
99'<p><input type="submit" value="'.__('Search').'" /></p>'.
100'</div>'.
101'</form>';
102
103if ($q && !$core->error->flag())
104{
105     $redir = html::escapeHTML($_SERVER['REQUEST_URI']);
106
107     # Show posts
108     if ($qtype == 'p')
109     {
110
111          if ($counter->f(0) > 0) {
112               printf('<h3>'.
113               ($counter->f(0) == 1 ? __('%d entry found') : __('%d entries found')).
114               '</h3>',$counter->f(0));
115          }
116
117          $post_list->display($page,$nb_per_page,
118          '<form action="'.$core->adminurl->get("admin.search").'" method="post" id="form-entries">'.
119
120          '%s'.
121
122          '<div class="two-cols">'.
123          '<p class="col checkboxes-helpers"></p>'.
124
125          '<p class="col right"><label for="action1" class="classic">'.__('Selected entries action:').'</label> '.
126          form::combo(array('action','action1'),$posts_actions_page->getCombo()).
127          '<input type="submit" value="'.__('ok').'" /></p>'.
128          $core->formNonce().
129          $posts_actions_page->getHiddenFields().
130          '</div>'.
131          '</form>'
132          );
133     }
134     # Show posts
135     elseif ($qtype == 'c')
136     {
137          # Actions combo box
138
139          if ($counter->f(0) > 0) {
140               printf('<h3>'.
141               ($counter->f(0) == 1 ? __('%d comment found') : __('%d comments found')).
142               '</h3>',$counter->f(0));
143          }
144
145          $comment_list->display($page,$nb_per_page,
146          '<form action="'.$core->adminurl->get("admin.search").'" method="post" id="form-comments">'.
147
148          '%s'.
149
150          '<div class="two-cols">'.
151          '<p class="col checkboxes-helpers"></p>'.
152
153          '<p class="col right"><label for="action2" class="classic">'.__('Selected comments action:').'</label> '.
154          form::combo(array('action','action2'),$comments_actions_page->getCombo()).
155          '<input type="submit" value="'.__('ok').'" /></p>'.
156          $core->formNonce().
157          $comments_actions_page->getHiddenFields().
158          '</div>'.
159          '</form>'
160          );
161     }
162}
163
164dcPage::helpBlock('core_search');
165dcPage::close();
Note: See TracBrowser for help on using the repository browser.

Sites map