Dotclear

source: admin/search.php @ 3182:adf3c934173f

Revision 3182:adf3c934173f, 4.6 KB checked in by franck <carnet.franck.paul@…>, 9 years ago (diff)

Disable submit button unless at least one item selected whenever is possible, closes #1600

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

Sites map