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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 74722 - (show annotations)
Thu Sep 18 10:41:37 2008 UTC (11 years, 4 months ago) by jfiat
File size: 3636 byte(s)
fixed uuid query
1 <?php
2
3
4 /*
5 * Helpers
6 */
7
8 function var_dump_r(&$ref, $pre=TRUE) {
9 ob_start(); var_dump($ref); $a=htmlspecialchars(ob_get_contents(),ENT_QUOTES); ob_end_clean();
10 if ($pre) {
11 return "<pre>DUMP=".$a . '</pre>';
12 } else {
13 return 'DUMP='.$a;
14 }
15 }
16 function var_dump_global($refname) {
17 global $$refname;
18 ob_start(); var_dump($$refname); $a=htmlspecialchars(ob_get_contents(),ENT_QUOTES); ob_end_clean();
19 return "DUMP[".$refname."]=".$a;
20 }
21
22 function isedoc_mkdir($a_dir) {
23 if (!file_check_directory($a_dir)) {
24 //drupal_set_message("create directory: $a_dir", 'status');
25 mkdir($a_dir, 0775, TRUE);
26 }
27 }
28
29 function isedoc_rm_recursive($filepath) {
30 if (is_dir($filepath) && !is_link($filepath))
31 {
32 if ($dh = opendir($filepath))
33 {
34 while (($sf = readdir($dh)) !== false)
35 {
36 if ($sf == '.' || $sf == '..')
37 {
38 continue;
39 }
40 if (!isedoc_rm_recursive($filepath.'/'.$sf))
41 {
42 throw new Exception($filepath.'/'.$sf.' could not be deleted.');
43 }
44 }
45 closedir($dh);
46 }
47 return rmdir($filepath);
48 }
49 return unlink($filepath);
50 }
51
52 /**
53 * Returns an array of all books.
54 *
55 * This list may be used for generating a list of all the books, or for building
56 * the options for a form select.
57 */
58
59 function book_doc_page_exists($a_title) {
60 //$res = db_query("SELECT nid FROM {node} WHERE LOWER(title) = LOWER('%s') AND type IN ()", $a_title);
61 //$res = db_query("SELECT nid FROM {node} WHERE LOWER(title) = LOWER('%s') AND type = 'doc' ", $a_title);
62 $res = db_query("SELECT nid FROM {node} WHERE type = 'doc' AND LOWER(title) = LOWER('%s') ", $a_title);
63 if ($res === FALSE) {
64 return FALSE;
65 } else {
66 $v = db_fetch_object($res);
67 return $v->nid;
68 }
69 }
70
71 function isedoc_pages_referencing($a_title) {
72 $l_body_filter = 'REGEXP \'[[.[.]][[.[.]][:blank:]*'.strtolower($a_title).'[:blank:]*([[.|.]]|[[.].]][[.].]])\'';
73 //$l_body_filter = 'LIKE LOWER(\'%[['.$a_title.'%\')';
74 $sql = "SELECT n.nid, n.title FROM {node} n INNER JOIN {node_revisions} r ON n.nid = r.nid WHERE LOWER(r.body) $l_body_filter ;";
75 $res = db_query($sql);
76 $result = array();
77 if ($res === FALSE) {
78 return FALSE;
79 } else {
80 while ($r = db_fetch_array($res)) {
81 $result[$r['nid']] = $r;
82 }
83 return $result;
84 }
85 }
86
87 function isedoc_book_get_books() {
88 static $all_books;
89
90 if (!isset($all_books)) {
91 $all_books = array();
92 $result = db_query("SELECT DISTINCT(bid) FROM {book}");
93 $nids = array();
94 while ($book = db_fetch_array($result)) {
95 $nids[] = $book['bid'];
96 }
97 if ($nids) {
98 $result2 = db_query(db_rewrite_sql("SELECT n.type, n.title, b.*, ml.* FROM {book} b INNER JOIN {node} n on b.nid = n.nid INNER JOIN {menu_links} ml ON b.mlid = ml.mlid WHERE n.nid IN (". implode(',', $nids) .") AND n.status = 1 ORDER BY ml.weight, ml.link_title"));
99 while ($link = db_fetch_array($result2)) {
100 $link['href'] = $link['link_path'];
101 $link['options'] = unserialize($link['options']);
102 $all_books[$link['bid']] = $link;
103 }
104 }
105 }
106 return $all_books;
107 }
108
109 function isedoc_node_ids_by_uuid($uuid) {
110 $sql = "SELECT nid, vid FROM {content_type_".'doc'."} WHERE LOWER(field_uuid_value) = LOWER('%s')";
111 $res = db_query($sql, $uuid);
112 if ($res === FALSE) {
113 return FALSE;
114 } else {
115 $nids = array();
116 while ($v = db_fetch_array($res)) {
117 $nid = $v['nid'];
118 $vid = $v['vid'];
119 //drupal_set_message("nid=$nid; v=$vid");
120 $nids[$nid] = $vid;
121 }
122 return $nids;
123 }
124 }
125
126 ?>

Properties

Name Value
svn:eol-style native

  ViewVC Help
Powered by ViewVC 1.1.23