/[eiffelstudio]/trunk/Documentation/tools/web/trunk/drupal/sites/all/modules/isedoc/isedoc.report.inc
ViewVC logotype

Contents of /trunk/Documentation/tools/web/trunk/drupal/sites/all/modules/isedoc/isedoc.report.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 74842 - (show annotations)
Fri Sep 26 13:05:31 2008 UTC (11 years, 4 months ago) by jfiat
File size: 5464 byte(s)
change path for report query
1 <?php
2
3 require_once ("isedoc.lib.inc");
4
5 function isedoc_report($a_type='doc', $target,$a_op='') {
6 $output = '';
7 drupal_add_css(drupal_get_path('module', 'system') .'/system.css');
8 drupal_add_js('misc/collapse.js');
9
10 $op = $a_op;
11 if ($op == '') {
12 $op = 'all';
13 }
14 if (user_access('admin isedoc') or user_access('query isedoc')) {
15 $books = array();
16 $all_books = book_get_books();
17 switch ($target) {
18 case 'all':
19 foreach($all_books as $b) {
20 $books[] = $b['bid'];
21 }
22 break;
23 default:
24 $bn = strtolower($target);
25 foreach($all_books as $b) {
26 if (isedoc_book_title_to_book_name_id($b['title']) == $bn) {
27 $books[] = $b['bid'];
28 }
29 }
30 break;
31 }
32 if (count($books) > 0) {
33 foreach($books as $bid){
34 $output .= isedoc_report_on_book($bid,$op);
35 }
36 if ($op) {
37 $output .= "Report $target ($op): completed.";
38 } else {
39 $output .= "Report $target: completed.";
40 }
41 $output .= "<br/>".l(t("Report other books"), "isedoc/report/$a_type/_")."<br/>";
42 } else {
43 $output .= "<ul>";
44 $output .= "<li><strong>".l(t("Report all the books"), "isedoc/report/$a_type/all")."</strong></li>";
45 foreach($all_books as $b) {
46 $bn = isedoc_book_title_to_book_name_id($b['title']);
47 $output .= "<li>".l(t("Report only: ").$bn, "isedoc/report/$a_type/$bn")."</li>";
48 }
49 $output .= "</ul>";
50 }
51 } else {
52 //drupal_access_denied();
53 $output .= "Report $target: access denied.";
54 }
55 return $output;
56 }
57
58 function isedoc_book_title_to_book_name_id($a_title) {
59 if (module_exists('pathauto')) {
60 module_load_include('inc', 'pathauto', 'pathauto');
61 $l_url = pathauto_cleanstring($a_title);
62 } else {
63 $l_url = $a_title;
64 }
65 return strtolower($l_url);
66 }
67
68 function isedoc_report_on_book($a_bookid,$a_op) {
69 $output = '';
70 $node =& node_load(array('nid' => $a_bookid), NULL, FALSE);
71 if ($node) {
72 if (isset($node->book)) {
73 list($l_unused, $l_book_name_id) = explode('/', $node->path);
74 $l_book_short_path = "book/$l_book_name_id";
75 $tree = book_menu_subtree_data($node->book);
76 $output .= '<fieldset class="collapsible">';
77 $output .= '<legend><a href="#">';
78 $output .= "Report on book $a_bookid: $l_book_short_path";
79 $output .= '</a></legend>';
80 $output .= '<div class="fieldset-wrapper">';
81 $o .= isedoc_report_on_book_traverse(&$tree, $l_book_short_path,$a_op);
82 if ($o == '') {
83 $o = t("Nothing special to report.");
84 }
85 $output .= $o;
86 $output .= '</div>';
87 $output .= '</fieldset>';
88 }
89 }
90 return $output;
91 }
92
93 function isedoc_report_on_book_traverse(&$a_tree, $a_book_short_path, $a_op) {
94 $output = '';
95 foreach($a_tree as $data) {
96 $o = '';
97 $l_log = '';
98 if ($node = node_load($data['link']['nid'], FALSE)) {
99 $o .= isedoc_report_on_node(&$node,$a_book_short_path, $a_op);
100 }
101 $c = '';
102 if ($data['below']) {
103 $c = isedoc_report_on_book_traverse(&$data['below'], $a_book_short_path,$a_op);
104 }
105 $output .= $o.$c;
106 }
107 return $output;
108 }
109
110 function isedoc_report_on_node(&$node, $a_book_short_path, $a_op='all') {
111 $output = "<strong>" . l($node->title, $node->path) . "</strong>";
112 $node_bid = $node->book['bid'];
113 $out = '';
114 if ($a_op == 'all' or $a_op == 'uuid') {
115 if (is_callable(array($node, 'field_uuid'), TRUE)) {
116 $l_uuid = $node->field_uuid[0]['value'];
117 if (!$l_uuid) {
118 $out .= "<li>".$node->title . ": missing uuid"."</li>";
119 }
120 }
121 }
122 if ($a_op == 'all' or $a_op == 'wikilinks') {
123 $pat = '/\[\[\s*([a-zA-Z0-9:_ -]+)\s*(\||\]\])/';
124 $lnk_count = 0;
125 preg_match_all($pat, $node->body, $matches, PREG_PATTERN_ORDER);
126 if (count($matches[1]) > 0) {
127 $o = '';
128 foreach($matches[1] as $mk => $n_title) {
129 if (strlen($n_title) > 6 and strtolower(substr($n_title,0,6)) == "image:") {
130 $t = NULL;
131 } else {
132 $lnk_count += 1;
133 $nids = isedoc_node_ids_by_title($n_title,'doc');
134 if ($nids) {
135 $nb = count($nids);
136 if ($nb > 0 ) {
137 $t = '';
138 foreach($nids as $n_nid) {
139 $n = node_load($n_nid);
140 $tt = '';
141 if ($n) {
142 $bid = $n->book['bid'];
143 if ($bid != $node_bid) {
144 $bn = isedoc_book_name($bid);
145 $tt .= " from other book <strong>".l($bn,"node/$bid")."</strong>";
146 } elseif ($nb > 1) {
147 $tt .= " same book";
148 }
149 if (defined('STATUS_TRASH') and $n->status == STATUS_TRASH) {
150 $tt .= ' <span class="error">TRASHED</span>';
151 }
152 } else {
153 $tt .= " unable to load";
154 }
155 if ($tt != '') {
156 $tt = l("node/$n_nid", "node/$n_nid") . ": $tt";
157 if ($nb > 1) {
158 $tt = "<li>$tt</li>";
159 }
160 $t .= $tt;
161 }
162 }
163 if ($t == '') {
164 //$t = "$n_title: <strong>$nb page(s)</strong>";
165 } else {
166 if ($nb > 1) {
167 $t = "$n_title: <strong>$nb page(s)</strong><ul>$t</ul>";
168 } else {
169 $t = "$n_title: $t";
170 }
171 }
172 }
173 } else {
174 $t = "$n_title: <strong>missing node</strong>";
175 }
176 }
177 if ($t != '') {
178 $o .= "<li>$t</li>";
179 }
180 }
181 }
182 if ($o != '') {
183 $out .= $o;
184 }
185 }
186
187 if ($lnk_count === FALSE) {
188 } else {
189 $output .= " <em>($lnk_count link";
190 if ($lnk_count > 1) {
191 $output .= "s";
192 }
193 $output .= ")</em>";
194 }
195 if ($out == '') {
196 $output = '';
197 } else {
198 $output .= "<ul style=\"margin: 0 0 5px 0; border-bottom: dotted 1px #ccc;\">$out</ul>\n";
199 }
200 return $output;
201 }
202
203 ?>

  ViewVC Help
Powered by ViewVC 1.1.23