Source for file picturecatalog.class.php

Documentation is available at picturecatalog.class.php


1 <?php
2 /**
3 * @author Jan H. Andersen <jha@ipwsystems.dk>
4 * @author Martin R. Larsen <mrl@ipwsystems.dk>
5 * @copyright {@link http://www.ipwsystems.dk/ IPW Systems a.s}
6 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
7 * @package METAjour
8 * @subpackage extension
9 * $Id: picturecatalog.class.php,v 1.1.1.1 2004/09/15 15:34:02 Administrator Exp $
10 */
11
12 require_once($system_path."extension/basicextension.class.php");
13
14 class ext_picturecatalog extends basicextension {
15
16 var $picture;
17 var $interval;
18
19 function files_in_dir($path) {
20 $files = 0;
21 if (file_exists("$path")) {
22 $dh = opendir("$path");
23 while(false !==($file = readdir($dh))) {
24 if ($file != "." && $file != ".." && !is_dir($file)) {
25 $files++;
26 }
27 }
28 }
29 return($files);
30 }
31
32 function ext_picturecatalog() {
33 $this->hasconfigset = false;
34 $this->basicextension();
35 $this->extname = 'picturecatalog';
36 $this->picture = $_REQUEST['picture'];
37 $this->interval = $_REQUEST['interval'];
38 }
39
40 function getstate() {
41 basicextension::getstate();
42 $this->interval = $_SESSION[$this->extname][$this->extconfigset]['interval'];
43 $this->picture = $_SESSION[$this->extname][$this->extconfigset]['picture'];
44 }
45
46 function savestate() {
47 basicextension::savestate();
48 $_SESSION[$this->extname][$this->extconfigset]['interval'] = $this->interval;
49 $_SESSION[$this->extname][$this->extconfigset]['picture'] = $this->picture;
50 }
51
52 function getdefaultconf() {
53 $this->extconfig["target"] = "_blank";
54 $this->extconfig["thumb_dir"] = "";
55 $this->extconfig["normal_dir"] = "";
56 $this->extconfig["format1_dir"] = "";
57 $this->extconfig["format2_dir"] = "";
58 $this->extconfig["format3_dir"] = "";
59 $this->extconfig["rows"] = 3;
60 $this->extconfig["cols"] = 3;
61 $this->extconfig["pageid_image"] = 0;
62 }
63
64 function getconfparams($params) {
65 if (isset($params['target'])) $this->extconfig['target'] = $params['target'];
66 if (isset($params['thumb_dir'])) $this->extconfig['thumb_dir'] = $params['thumb_dir'];
67 if (isset($params['normal_dir'])) $this->extconfig['normal_dir'] = $params['normal_dir'];
68 if (isset($params['format1_dir'])) $this->extconfig['format1_dir'] = $params['format1_dir'];
69 if (isset($params['format2_dir'])) $this->extconfig['format2_dir'] = $params['format2_dir'];
70 if (isset($params['format3_dir'])) $this->extconfig['format3_dir'] = $params['format3_dir'];
71 if (isset($params['rows'])) $this->extconfig['rows'] = $params['rows'];
72 if (isset($params['cols'])) $this->extconfig['cols'] = $params['cols'];
73 if (isset($params['pageid_image'])) $this->extconfig['pageid_image'] = $params['pageid_image'];
74 }
75
76 function _do() {
77 if ($this->extcmd == "image") {
78 $this->settemplatebyname('standard_picturecatalog_image');
79
80 if($this->interval == "") {
81 $this->interval = 1;
82 }
83
84 if ($this->extconfig["normal_dir"] != "") {
85 $imagepath = $this->viewer_path . 'img/' . $this->extconfig["normal_dir"]."/";
86
87 $current = "";
88 $previous = "";
89 $next = "";
90
91 if (file_exists("$imagepath")) {
92 $i = 0;
93 $dh = opendir("$imagepath");
94 while(false !=($file = readdir($dh))) {
95 if (($file != ".") && ($file != "..") && (!is_dir($imagepath.$file)) ) {
96 if ($current == $this->picture) {
97 $next = $file;
98 break;
99 } else {
100 $previous = $current;
101 $current = $file;
102 }
103 }
104 }
105 }
106
107 $size = getimagesize($imagepath . $this->picture);
108 if ($next != "") {
109 $this->extresult[0]["next_url"] = 'showpage.php?pageid=' . $this->extconfig["pageid_image"] . '&_extcf='.$this->extconfigset.'&_ext=picturecatalog&_cmd=image&interval=' . $this->interval . '&picture=' . $next;
110 }
111 if ($previous != "") {
112 $this->extresult[0]["previous_url"] = 'showpage.php?pageid=' . $this->extconfig["pageid_image"] . '&_extcf='.$this->extconfigset.'&_ext=picturecatalog&_cmd=image&interval=' . $this->interval . '&picture=' . $previous;
113 }
114 $this->extresult[0]["thumb_url"] = $this->viewer_url . 'img/' . $this->extconfig["thumb_dir"] ."/". $this->picture;
115 $this->extresult[0]["normal_url"] = $this->viewer_url . 'img/' . $this->extconfig["normal_dir"] ."/". $this->picture;
116 $this->extresult[0]["format1_url"] = $this->viewer_url . 'img/' . $this->extconfig["format1_dir"] ."/". $this->picture;
117 $this->extresult[0]["format2_url"] = $this->viewer_url . 'img/' . $this->extconfig["format2_dir"] ."/". $this->picture;
118 $this->extresult[0]["format3_url"] = $this->viewer_url . 'img/' . $this->extconfig["format3_dir"] ."/". $this->picture;
119 $this->extresult[0]["filename"] = $this->picture;
120 $this->extresult[0]["back_url"] = 'showpage.php?interval=' . $this->interval . '&pageid=' . $_REQUEST['pageid'] . '&_extcf=' .$this->extconfigset. '&_ext=picturecatalog';
121 $this->extresult[0]["size"] = $size[3];
122 }
123
124 } else {
125 $this->settemplatebyname('standard_picturecatalog');
126
127 if ($this->extconfig["normal_dir"] != "") {
128 if($this->interval == "") {
129 $this->interval = 1;
130 }
131
132 $pics_page = $this->extconfig["rows"] * $this->extconfig["cols"];
133 $image_path = $this->viewer_path."img/".$this->extconfig["thumb_dir"]."/";
134 $files = $this->files_in_dir($image_path);
135 $numpages = ceil($files / $pics_page);
136 $count = 0;
137 $tr_count = 0;
138 $pageindex = "<center>";
139 $thumbindex = "";
140 $i = 1;
141 if($numpages > 1) {
142 for($i >= 1; $i <= $numpages; $i++) {
143 if($i == $this->interval) {
144 $pageindex .= '<a href=showpage.php?interval=' . $i . '&pageid=' . $_REQUEST['pageid'] . '&_extcf=' .$this->extconfigset. '&_ext=picturecatalog>[' . $i . ']</a>&nbsp;';
145 } else {
146 $pageindex .= '<a href=showpage.php?interval=' . $i . '&pageid=' . $_REQUEST['pageid'] . '&_extcf=' .$this->extconfigset. '&_ext=picturecatalog>' . $i . '</a>&nbsp;';
147 }
148 }
149 }
150
151 $thumbindex = '<br clear="all"><br clear="all">';
152 $thumbindex .= '<table bgcolor="#8b8b8b" width="100%" border="1" bordercolor="#3e3e3e" cellspacing="0" cellpadding="5"><tr>';
153
154 if (file_exists("$image_path")) {
155 $i = 0;
156 $dh = opendir("$image_path");
157 while(false !==($file = readdir($dh))) {
158 if ($file != "." && $file != ".." && !is_dir($file)) {
159 if($count >= ($this->interval * $pics_page - $pics_page) and $count < ($this->interval * $pics_page)) {
160 if($tr_count == $this->extconfig["cols"]) {
161 $thumbindex .= '</tr><tr>'; $tr_count = 0;
162 }
163 $tr_count++;
164 $picturefile = $image_path . $file;
165 $size = getimagesize($picturefile);
166 $this->extresult[$i]["thumb_url"] = $this->viewer_url . 'img/' . $this->extconfig["thumb_dir"] ."/". $file;
167 $this->extresult[$i]["normal_url"] = $this->viewer_url . 'img/' . $this->extconfig["normal_dir"] ."/". $file;
168 $this->extresult[$i]["format1_url"] = $this->viewer_url . 'img/' . $this->extconfig["format1_dir"] ."/". $file;
169 $this->extresult[$i]["format2_url"] = $this->viewer_url . 'img/' . $this->extconfig["format2_dir"] ."/". $file;
170 $this->extresult[$i]["format3_url"] = $this->viewer_url . 'img/' . $this->extconfig["format3_dir"] ."/". $file;
171 $this->extresult[$i]["filename"] = $file;
172 $this->extresult[$i]["size"] = $size[3];
173 if(file_exists($picturefile)) {
174 $thumbindex .= '<td align="center" valign="middle" bgcolor="#e8e8e8"><a href="showpage.php?pageid=' . $this->extconfig["pageid_image"] . '&_extcf='.$this->extconfigset.'&_ext=picturecatalog&_cmd=image&interval=' . $this->interval . '&picture=' . $file .'" target='.$this->extconfig["target"].'><img border="0" src="'.$this->viewer_url . 'img/' . $this->extconfig["thumb_dir"] . '/' . $file.'" '.$size[3].'></a></td>';
175 }
176 else {
177 $thumbindex .= '<td align="center" valign="middle" bgcolor="#e8e8e8"><a href="showpage.php?pageid=' . $this->extconfig["pageid_image"] . '&_extcf='.$this->extconfigset.'&_ext=picturecatalog&_cmd=mode=image&interval=' . $this->interval . '&picture=' . $file .'">'. $file .'</a></td>';
178 }
179 }
180 $count++;
181 }
182 $i++;
183 }
184 }
185 $thumbindex .= '</tr></table>';
186 $thumbindex .= '</center>';
187
188 $this->extresult[0]["thumbindex"] = $thumbindex;
189 $this->extresult[0]["pageindex"] = $pageindex;
190 }
191 }
192 }
193 }
194 ?>

Documentation generated on Thu, 9 Jun 2005 06:52:59 +0200 by phpDocumentor 1.2.3