Passed
Push — 1.10.x ( aae6b1...e5a590 )
by Yannick
131:05 queued 81:36
created
main/inc/lib/pear/Pager/Common.php 1 patch
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -1,40 +1,40 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3 3
 /**
4
- * Contains the Pager_Common class
5
- *
6
- * PHP versions 4 and 5
7
- *
8
- * LICENSE: Redistribution and use in source and binary forms, with or without
9
- * modification, are permitted provided that the following conditions are met:
10
- * 1. Redistributions of source code must retain the above copyright
11
- *    notice, this list of conditions and the following disclaimer.
12
- * 2. Redistributions in binary form must reproduce the above copyright
13
- *    notice, this list of conditions and the following disclaimer in the
14
- *    documentation and/or other materials provided with the distribution.
15
- * 3. The name of the author may not be used to endorse or promote products
16
- *    derived from this software without specific prior written permission.
17
- *
18
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
19
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21
- * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
22
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
- *
29
- * @category  HTML
30
- * @package   Pager
31
- * @author    Lorenzo Alberton <[email protected]>
32
- * @author    Richard Heyes <[email protected]>
33
- * @copyright 2003-2007 Lorenzo Alberton, Richard Heyes
34
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
35
- * @version   CVS: $Id: Common.php,v 1.82 2008/05/31 12:44:55 quipo Exp $
36
- * @link      http://pear.php.net/package/Pager
37
- */
4
+     * Contains the Pager_Common class
5
+     *
6
+     * PHP versions 4 and 5
7
+     *
8
+     * LICENSE: Redistribution and use in source and binary forms, with or without
9
+     * modification, are permitted provided that the following conditions are met:
10
+     * 1. Redistributions of source code must retain the above copyright
11
+     *    notice, this list of conditions and the following disclaimer.
12
+     * 2. Redistributions in binary form must reproduce the above copyright
13
+     *    notice, this list of conditions and the following disclaimer in the
14
+     *    documentation and/or other materials provided with the distribution.
15
+     * 3. The name of the author may not be used to endorse or promote products
16
+     *    derived from this software without specific prior written permission.
17
+     *
18
+     * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
19
+     * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20
+     * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21
+     * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
22
+     * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
+     * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
+     * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
+     * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27
+     * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+     *
29
+     * @category  HTML
30
+     * @package   Pager
31
+     * @author    Lorenzo Alberton <[email protected]>
32
+     * @author    Richard Heyes <[email protected]>
33
+     * @copyright 2003-2007 Lorenzo Alberton, Richard Heyes
34
+     * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
35
+     * @version   CVS: $Id: Common.php,v 1.82 2008/05/31 12:44:55 quipo Exp $
36
+     * @link      http://pear.php.net/package/Pager
37
+     */
38 38
 
39 39
 /**
40 40
  * Two constants used to guess the path- and file-name of the page
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
 }
60 60
 //
61 61
 /**
62
- * Error codes
63
- */
62
+     * Error codes
63
+     */
64 64
 define('PAGER_OK',                         0);
65 65
 define('ERROR_PAGER',                     -1);
66 66
 define('ERROR_PAGER_INVALID',             -2);
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
             return array(
627 627
                         max(($this->_perPage * ($pageID - 1)) + 1, 1),
628 628
                         min($this->_totalItems, $this->_perPage * $pageID)
629
-                   );
629
+                    );
630 630
         }
631 631
         return array(0, 0);
632 632
     }
@@ -848,16 +848,16 @@  discard block
 block discarded – undo
848 848
                 $onclick = str_replace('%d', $this->_linkData[$this->_urlVar], $this->_onclick);
849 849
             }
850 850
             return sprintf('<a href="%s"%s%s%s%s title="%s">%s</a>',
851
-                           // Modified by Ivan Tcholakov, 17-OCT-2008.
852
-                           //htmlentities($this->_url . $href, ENT_COMPAT, 'UTF-8'),
853
-                           api_htmlentities($this->_url . $href),
854
-                           //
855
-                           empty($this->_classString) ? '' : ' '.$this->_classString,
856
-                           empty($this->_attributes)  ? '' : ' '.$this->_attributes,
857
-                           empty($this->_accesskey)   ? '' : ' accesskey="'.$this->_linkData[$this->_urlVar].'"',
858
-                           empty($onclick)            ? '' : ' onclick="'.$onclick.'"',
859
-                           $altText,
860
-                           $linkText
851
+                            // Modified by Ivan Tcholakov, 17-OCT-2008.
852
+                            //htmlentities($this->_url . $href, ENT_COMPAT, 'UTF-8'),
853
+                            api_htmlentities($this->_url . $href),
854
+                            //
855
+                            empty($this->_classString) ? '' : ' '.$this->_classString,
856
+                            empty($this->_attributes)  ? '' : ' '.$this->_attributes,
857
+                            empty($this->_accesskey)   ? '' : ' accesskey="'.$this->_linkData[$this->_urlVar].'"',
858
+                            empty($onclick)            ? '' : ' onclick="'.$onclick.'"',
859
+                            $altText,
860
+                            $linkText
861 861
             );
862 862
         } elseif ($this->_httpMethod == 'POST') {
863 863
             $href = $this->_url;
@@ -865,12 +865,12 @@  discard block
 block discarded – undo
865 865
                 $href .= '?' . $this->_http_build_query_wrapper($_GET);
866 866
             }
867 867
             return sprintf("<a href='javascript:void(0)' onclick='%s'%s%s%s title='%s'>%s</a>",
868
-                           $this->_generateFormOnClick($href, $this->_linkData),
869
-                           empty($this->_classString) ? '' : ' '.$this->_classString,
870
-                           empty($this->_attributes)  ? '' : ' '.$this->_attributes,
871
-                           empty($this->_accesskey)   ? '' : ' accesskey=\''.$this->_linkData[$this->_urlVar].'\'',
872
-                           $altText,
873
-                           $linkText
868
+                            $this->_generateFormOnClick($href, $this->_linkData),
869
+                            empty($this->_classString) ? '' : ' '.$this->_classString,
870
+                            empty($this->_attributes)  ? '' : ' '.$this->_attributes,
871
+                            empty($this->_accesskey)   ? '' : ' accesskey=\''.$this->_linkData[$this->_urlVar].'\'',
872
+                            $altText,
873
+                            $linkText
874 874
             );
875 875
         }
876 876
         return '';
@@ -1120,10 +1120,10 @@  discard block
 block discarded – undo
1120 1120
         if ($this->_currentPage > 1) {
1121 1121
             $this->_linkData[$this->_urlVar] = $this->getPreviousPageID();
1122 1122
             $back = $this->_renderLink($this->_altPrev, $this->_prevImg)
1123
-                  . $this->_spacesBefore . $this->_spacesAfter;
1123
+                    . $this->_spacesBefore . $this->_spacesAfter;
1124 1124
         } else if ($this->_prevImgEmpty !== null && $this->_totalPages > 1) {
1125 1125
             $back = $this->_prevImgEmpty
1126
-                  . $this->_spacesBefore . $this->_spacesAfter;
1126
+                    . $this->_spacesBefore . $this->_spacesAfter;
1127 1127
         }
1128 1128
         return $back;
1129 1129
     }
@@ -1171,12 +1171,12 @@  discard block
 block discarded – undo
1171 1171
         if ($this->_currentPage < $this->_totalPages) {
1172 1172
             $this->_linkData[$this->_urlVar] = $this->getNextPageID();
1173 1173
             $next = $this->_spacesAfter
1174
-                  . $this->_renderLink($this->_altNext, $this->_nextImg)
1175
-                  . $this->_spacesBefore . $this->_spacesAfter;
1174
+                    . $this->_renderLink($this->_altNext, $this->_nextImg)
1175
+                    . $this->_spacesBefore . $this->_spacesAfter;
1176 1176
         } else if ($this->_nextImgEmpty !== null && $this->_totalPages > 1) {
1177 1177
             $next = $this->_spacesAfter
1178
-                  . $this->_nextImgEmpty
1179
-                  . $this->_spacesBefore . $this->_spacesAfter;
1178
+                    . $this->_nextImgEmpty
1179
+                    . $this->_spacesBefore . $this->_spacesAfter;
1180 1180
         }
1181 1181
         return $next;
1182 1182
     }
@@ -1632,7 +1632,7 @@  discard block
 block discarded – undo
1632 1632
         }
1633 1633
 
1634 1634
         if (!empty($_SESSION[$this->_sessionVar]) && $this->_useSessions) {
1635
-             $this->_perPage = $_SESSION[$this->_sessionVar];
1635
+                $this->_perPage = $_SESSION[$this->_sessionVar];
1636 1636
         }
1637 1637
 
1638 1638
         if ($this->_closeSession) {
@@ -1713,7 +1713,7 @@  discard block
 block discarded – undo
1713 1713
                 ERROR_PAGER_INVALID             => 'invalid',
1714 1714
                 ERROR_PAGER_INVALID_PLACEHOLDER => 'invalid format - use "%d" as placeholder.',
1715 1715
                 ERROR_PAGER_INVALID_USAGE       => 'if $options[\'append\'] is set to false, '
1716
-                                                  .' $options[\'fileName\'] MUST contain the "%d" placeholder.',
1716
+                                                    .' $options[\'fileName\'] MUST contain the "%d" placeholder.',
1717 1717
                 ERROR_PAGER_NOT_IMPLEMENTED     => 'not implemented'
1718 1718
             );
1719 1719
         }
Please login to merge, or discard this patch.
main/inc/lib/pear/Pager/Sliding.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -234,8 +234,8 @@  discard block
 block discarded – undo
234 234
                     $this->range[$i] = false;
235 235
                     $this->_linkData[$this->_urlVar] = $i;
236 236
                     $links .= $this->_renderLink(str_replace('%d', $i, $this->_altPage), $i)
237
-                           . $this->_spacesBefore
238
-                           . ($print_separator_flag ? $this->_separator.$this->_spacesAfter : '');
237
+                            . $this->_spacesBefore
238
+                            . ($print_separator_flag ? $this->_separator.$this->_spacesAfter : '');
239 239
                 }
240 240
             }
241 241
 
@@ -268,8 +268,8 @@  discard block
 block discarded – undo
268 268
                     $this->range[$i] = false;
269 269
                     $this->_linkData[$this->_urlVar] = $i;
270 270
                     $links .= $this->_renderLink(str_replace('%d', $i, $this->_altPage), $i)
271
-                      . $this->_spacesBefore
272
-                      . ($print_separator_flag ? $this->_separator.$this->_spacesAfter : '');
271
+                        . $this->_spacesBefore
272
+                        . ($print_separator_flag ? $this->_separator.$this->_spacesAfter : '');
273 273
                 }
274 274
             }
275 275
 
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
                     $links .= $this->_curPageSpanPre . $i . $this->_curPageSpanPost;
286 286
                 }
287 287
                 $links .= $this->_spacesBefore
288
-                       . (($i != $this->_totalPages) ? $this->_separator.$this->_spacesAfter : '');
288
+                        . (($i != $this->_totalPages) ? $this->_separator.$this->_spacesAfter : '');
289 289
             }
290 290
         }
291 291
         return $links;
Please login to merge, or discard this patch.
main/inc/lib/pear/Pager/Jumping.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -250,7 +250,7 @@
 block discarded – undo
250 250
                 $links .= $this->_curPageSpanPre . $i . $this->_curPageSpanPost;
251 251
             }
252 252
             $links .= $this->_spacesBefore
253
-                   . (($i != $this->_totalPages) ? $this->_separator.$this->_spacesAfter : '');
253
+                    . (($i != $this->_totalPages) ? $this->_separator.$this->_spacesAfter : '');
254 254
         }
255 255
         return $links;
256 256
     }
Please login to merge, or discard this patch.
main/inc/lib/pear/Pager/Pager.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -148,8 +148,8 @@
 block discarded – undo
148 148
             eval('$this = Pager::factory($options);');
149 149
         } else { //php5 is case sensitive
150 150
             $msg = 'Pager constructor is deprecated.'
151
-                  .' You must use the "Pager::factory($params)" method'
152
-                  .' instead of "new Pager($params)"';
151
+                    .' You must use the "Pager::factory($params)" method'
152
+                    .' instead of "new Pager($params)"';
153 153
             trigger_error($msg, E_USER_ERROR);
154 154
         }
155 155
     }
Please login to merge, or discard this patch.
main/inc/lib/dashboard.lib.php 1 patch
Indentation   +255 added lines, -255 removed lines patch added patch discarded remove patch
@@ -249,282 +249,282 @@
 block discarded – undo
249 249
         return $affected_rows;
250 250
     }
251 251
 
252
-	/**
253
-	 * Get all plugins path inside dashboard directory
254
-	 * @return array name plugins directories
255
-	 */
256
-	public static function getPossibleDashboardPluginsPath()
252
+    /**
253
+     * Get all plugins path inside dashboard directory
254
+     * @return array name plugins directories
255
+     */
256
+    public static function getPossibleDashboardPluginsPath()
257 257
     {
258
-		// get all plugins path inside plugin directory
259
-		/* We scan the plugin directory. Each folder is a potential plugin. */
260
-		$possiblePlugins = array();
261
-		$dashboard_pluginpath = api_get_path(SYS_PLUGIN_PATH).'dashboard/';
262
-		$handle = @opendir($dashboard_pluginpath);
263
-		while (false !== ($file = readdir($handle))) {
264
-			if ($file <> '.' AND $file <> '..' AND is_dir($dashboard_pluginpath.$file)) {
265
-				$possiblePlugins[] = $file;
266
-			}
267
-		}
268
-		@closedir($handle);
269
-
270
-		return $possiblePlugins;
271
-	}
272
-
273
-	/**
274
-	 * Get all blocks data without plugin directory
275
-	 * @return array Block data
276
-	 */
277
-	public static function get_block_data_without_plugin()
258
+        // get all plugins path inside plugin directory
259
+        /* We scan the plugin directory. Each folder is a potential plugin. */
260
+        $possiblePlugins = array();
261
+        $dashboard_pluginpath = api_get_path(SYS_PLUGIN_PATH).'dashboard/';
262
+        $handle = @opendir($dashboard_pluginpath);
263
+        while (false !== ($file = readdir($handle))) {
264
+            if ($file <> '.' AND $file <> '..' AND is_dir($dashboard_pluginpath.$file)) {
265
+                $possiblePlugins[] = $file;
266
+            }
267
+        }
268
+        @closedir($handle);
269
+
270
+        return $possiblePlugins;
271
+    }
272
+
273
+    /**
274
+     * Get all blocks data without plugin directory
275
+     * @return array Block data
276
+     */
277
+    public static function get_block_data_without_plugin()
278 278
     {
279
-		$tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK);
280
-		$possibleplugins = self::getPossibleDashboardPluginsPath();
281
-
282
-		// We check if plugin exists inside directory for updating active field
283
-		$sql = "SELECT * FROM $tbl_block";
284
-		$rs = Database::query($sql);
285
-		if (Database::num_rows($rs) > 0){
286
-			while ($row = Database::fetch_array($rs)) {
287
-				$path = $row['path'];
288
-				if (!in_array($row['path'],$possibleplugins)) {
289
-					$active = 0;
290
-				} else {
291
-					$active = 1;
292
-				}
293
-				// update active
294
-				$upd = "UPDATE $tbl_block SET active = '$active'
279
+        $tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK);
280
+        $possibleplugins = self::getPossibleDashboardPluginsPath();
281
+
282
+        // We check if plugin exists inside directory for updating active field
283
+        $sql = "SELECT * FROM $tbl_block";
284
+        $rs = Database::query($sql);
285
+        if (Database::num_rows($rs) > 0){
286
+            while ($row = Database::fetch_array($rs)) {
287
+                $path = $row['path'];
288
+                if (!in_array($row['path'],$possibleplugins)) {
289
+                    $active = 0;
290
+                } else {
291
+                    $active = 1;
292
+                }
293
+                // update active
294
+                $upd = "UPDATE $tbl_block SET active = '$active'
295 295
 				        WHERE path = '".$row['path']."'";
296
-				Database::query($upd);
297
-			}
298
-		}
299
-
300
-		// get disabled block data
301
-		$block_data = array();
302
-		$sql = "SELECT * FROM $tbl_block WHERE active = 0";
303
-		$rs_block = Database::query($sql);
304
-		if (Database::num_rows($rs_block) > 0) {
305
-			while ($row_block = Database::fetch_array($rs_block)) {
306
-				$block_data[] = $row_block;
307
-			}
308
-		}
309
-
310
-		return $block_data;
311
-
312
-	}
313
-
314
-	/**
315
-	 * get data about enabled dashboard block (stored insise block table)
316
-	 * @param  string	plugin path
317
-	 * @return array 	data
318
-	 */
319
-	public static function get_enabled_dashboard_blocks($path = '')
296
+                Database::query($upd);
297
+            }
298
+        }
299
+
300
+        // get disabled block data
301
+        $block_data = array();
302
+        $sql = "SELECT * FROM $tbl_block WHERE active = 0";
303
+        $rs_block = Database::query($sql);
304
+        if (Database::num_rows($rs_block) > 0) {
305
+            while ($row_block = Database::fetch_array($rs_block)) {
306
+                $block_data[] = $row_block;
307
+            }
308
+        }
309
+
310
+        return $block_data;
311
+
312
+    }
313
+
314
+    /**
315
+     * get data about enabled dashboard block (stored insise block table)
316
+     * @param  string	plugin path
317
+     * @return array 	data
318
+     */
319
+    public static function get_enabled_dashboard_blocks($path = '')
320 320
     {
321
-		$tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK);
322
-		$condition_path = '';
323
-		if (!empty($path)) {
324
-			$path = Database::escape_string($path);
325
-			$condition_path = ' AND path = "'.$path.'" ';
326
-		}
327
-
328
-		$sql = "SELECT * FROM $tbl_block WHERE active = 1 $condition_path ";
329
-		$rs  = Database::query($sql);
330
-		$block_data = array();
331
-		if (Database::num_rows($rs) > 0) {
332
-			while ($row = Database::fetch_array($rs)) {
333
-				$block_data[$row['path']] = $row;
334
-			}
335
-		}
336
-		return $block_data;
337
-	}
338
-
339
-	/**
340
-	 * display user dashboard list
341
-	 * @param int  User id
342
-	 * @return void
343
-	 */
344
-	public static function display_user_dashboard_list($user_id)
321
+        $tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK);
322
+        $condition_path = '';
323
+        if (!empty($path)) {
324
+            $path = Database::escape_string($path);
325
+            $condition_path = ' AND path = "'.$path.'" ';
326
+        }
327
+
328
+        $sql = "SELECT * FROM $tbl_block WHERE active = 1 $condition_path ";
329
+        $rs  = Database::query($sql);
330
+        $block_data = array();
331
+        if (Database::num_rows($rs) > 0) {
332
+            while ($row = Database::fetch_array($rs)) {
333
+                $block_data[$row['path']] = $row;
334
+            }
335
+        }
336
+        return $block_data;
337
+    }
338
+
339
+    /**
340
+     * display user dashboard list
341
+     * @param int  User id
342
+     * @return void
343
+     */
344
+    public static function display_user_dashboard_list($user_id)
345 345
     {
346
-		$enabled_dashboard_plugins = self::get_enabled_dashboard_blocks();
347
-		$user_block_data = self::get_user_block_data($user_id);
348
-
349
-		if (count($enabled_dashboard_plugins) > 0) {
350
-			echo '<div style="margin-top:20px">';
351
-			echo '<div><strong>'.get_lang('SelectBlockForDisplayingInsideBlocksDashboardView').'</strong></div><br />';
352
-			echo '<form name="dashboard_list" method="post" action="index.php?action=store_user_block">';
353
-			echo '<table class="data_table">';
354
-			echo '<tr>';
355
-			echo '<th width="5%">';
356
-			echo get_lang('Enabled');
357
-			echo '</th>';
358
-			echo '<th width="30%">';
359
-			echo get_lang('Name');
360
-			echo '</th>';
361
-			echo '<th width="40%">';
362
-			echo get_lang('Description');
363
-			echo '</th>';
364
-			echo '<th>';
365
-			echo get_lang('ColumnPosition');
366
-			echo '</th>';
367
-			echo '</tr>';
368
-
369
-			// We display all enabled plugins and the checkboxes
370
-			foreach ($enabled_dashboard_plugins as $block) {
371
-
372
-				$path = $block['path'];
373
-				$controller_class = $block['controller'];
374
-				$filename_controller = $path.'.class.php';
375
-				$dashboard_plugin_path = api_get_path(SYS_PLUGIN_PATH).'dashboard/'.$path.'/';
376
-				require_once $dashboard_plugin_path.$filename_controller;
377
-				if (class_exists($controller_class)) {
378
-					$obj_block = new $controller_class($user_id);
379
-
380
-					// check if user is allowed to see the block
381
-					if (method_exists($obj_block, 'is_block_visible_for_user')) {
382
-						$is_block_visible_for_user = $obj_block->is_block_visible_for_user($user_id);
383
-						if (!$is_block_visible_for_user) continue;
384
-					}
385
-
386
-					echo '<tr>';
387
-					// checkboxes
388
-					self::display_user_dashboard_list_checkboxes($user_id, $block['id']);
389
-					echo '<td>'.$block['name'].'</td>';
390
-					echo '<td>'.$block['description'].'</td>';
391
-					echo '<td>
346
+        $enabled_dashboard_plugins = self::get_enabled_dashboard_blocks();
347
+        $user_block_data = self::get_user_block_data($user_id);
348
+
349
+        if (count($enabled_dashboard_plugins) > 0) {
350
+            echo '<div style="margin-top:20px">';
351
+            echo '<div><strong>'.get_lang('SelectBlockForDisplayingInsideBlocksDashboardView').'</strong></div><br />';
352
+            echo '<form name="dashboard_list" method="post" action="index.php?action=store_user_block">';
353
+            echo '<table class="data_table">';
354
+            echo '<tr>';
355
+            echo '<th width="5%">';
356
+            echo get_lang('Enabled');
357
+            echo '</th>';
358
+            echo '<th width="30%">';
359
+            echo get_lang('Name');
360
+            echo '</th>';
361
+            echo '<th width="40%">';
362
+            echo get_lang('Description');
363
+            echo '</th>';
364
+            echo '<th>';
365
+            echo get_lang('ColumnPosition');
366
+            echo '</th>';
367
+            echo '</tr>';
368
+
369
+            // We display all enabled plugins and the checkboxes
370
+            foreach ($enabled_dashboard_plugins as $block) {
371
+
372
+                $path = $block['path'];
373
+                $controller_class = $block['controller'];
374
+                $filename_controller = $path.'.class.php';
375
+                $dashboard_plugin_path = api_get_path(SYS_PLUGIN_PATH).'dashboard/'.$path.'/';
376
+                require_once $dashboard_plugin_path.$filename_controller;
377
+                if (class_exists($controller_class)) {
378
+                    $obj_block = new $controller_class($user_id);
379
+
380
+                    // check if user is allowed to see the block
381
+                    if (method_exists($obj_block, 'is_block_visible_for_user')) {
382
+                        $is_block_visible_for_user = $obj_block->is_block_visible_for_user($user_id);
383
+                        if (!$is_block_visible_for_user) continue;
384
+                    }
385
+
386
+                    echo '<tr>';
387
+                    // checkboxes
388
+                    self::display_user_dashboard_list_checkboxes($user_id, $block['id']);
389
+                    echo '<td>'.$block['name'].'</td>';
390
+                    echo '<td>'.$block['description'].'</td>';
391
+                    echo '<td>
392 392
                             <select class="selectpicker show-tick form-control" name="columns['.$block['id'].']">
393 393
                             <option value="1" '.(isset($user_block_data[$block['id']]) && $user_block_data[$block['id']]['column']==1?'selected':'').' >1</option>
394 394
                             <option value="2" '.(isset($user_block_data[$block['id']]) && $user_block_data[$block['id']]['column']==2?'selected':'').' >2</option>
395 395
                             </select>
396 396
                           </td>';
397
-					echo '</tr>';
398
-				} else {
399
-					echo Display::tag('tr',  Display::tag('td', get_lang('Error').' '.$controller_class, array('colspan'=>'3')));
400
-				}
401
-			}
402
-
403
-			echo '</table>';
404
-			echo '<div class="row"><div class="col-md-12">';
405
-			echo '<button class="btn btn-default" type="submit" name="submit_dashboard_list" value="'.get_lang('EnableDashboardBlock').'"><em class="fa fa-check-square"></em> '.
397
+                    echo '</tr>';
398
+                } else {
399
+                    echo Display::tag('tr',  Display::tag('td', get_lang('Error').' '.$controller_class, array('colspan'=>'3')));
400
+                }
401
+            }
402
+
403
+            echo '</table>';
404
+            echo '<div class="row"><div class="col-md-12">';
405
+            echo '<button class="btn btn-default" type="submit" name="submit_dashboard_list" value="'.get_lang('EnableDashboardBlock').'"><em class="fa fa-check-square"></em> '.
406 406
                 get_lang('EnableDashboardBlock').'</button></form>';
407
-			echo '</div></div>';
408
-		} else {
409
-			echo '<div style="margin-top:20px">'.get_lang('ThereAreNoEnabledDashboardPlugins').'</div>';
410
-			if (api_is_platform_admin()) {
411
-				echo '<a class="btn btn-default" href="'.api_get_path(WEB_CODE_PATH).'admin/settings.php?category=Plugins">'.
407
+            echo '</div></div>';
408
+        } else {
409
+            echo '<div style="margin-top:20px">'.get_lang('ThereAreNoEnabledDashboardPlugins').'</div>';
410
+            if (api_is_platform_admin()) {
411
+                echo '<a class="btn btn-default" href="'.api_get_path(WEB_CODE_PATH).'admin/settings.php?category=Plugins">'.
412 412
                     get_lang('ConfigureDashboardPlugin').'</a>';
413
-			}
414
-		}
415
-	}
416
-
417
-	/**
418
-	 * display checkboxes for user dashboard list
419
-	 * @param int 	User id
420
-	 * @param int	Block id
421
-	 * @return void
422
-	 */
423
-	public static function display_user_dashboard_list_checkboxes($user_id, $block_id) {
424
-
425
-		$user_id = intval($user_id);
426
-		$user_block_data = self::get_user_block_data($user_id);
427
-		$enabled_blocks_id = array_keys($user_block_data);
428
-
429
-		$checked = '';
430
-		if (in_array($block_id, $enabled_blocks_id)) {
431
-			$checked = "checked";
432
-		}
433
-
434
-		echo "<td align=\"center\">";
435
-		echo '<input type="checkbox" name="enabled_blocks['.$block_id.']" value="true" '.$checked.'/>';
436
-		echo "</td>";
437
-	}
438
-
439
-	/**
440
-	 * This function store enabled blocks id with its column position (block_id1:colum;block_id2:colum; ...) inside extra user fields
441
-	 * @param int User id
442
-	 * @param array selected blocks
443
-	 * @param array columns position
444
-	 * @return bool
445
-	 */
446
-	public static function store_user_blocks($user_id, $enabled_blocks, $columns) {
447
-		$selected_blocks_id  = array();
448
-		if (is_array($enabled_blocks) && count($enabled_blocks) > 0) {
449
-			$selected_blocks_id = array_keys($enabled_blocks);
450
-		}
451
-
452
-		// build data for storing inside extra user field
453
-		$fname = 'dashboard';
454
-		$fvalue = array();
455
-		foreach ($selected_blocks_id as $block_id) {
456
-			$fvalue[] = $block_id.':'.$columns[$block_id];
457
-		}
413
+            }
414
+        }
415
+    }
416
+
417
+    /**
418
+     * display checkboxes for user dashboard list
419
+     * @param int 	User id
420
+     * @param int	Block id
421
+     * @return void
422
+     */
423
+    public static function display_user_dashboard_list_checkboxes($user_id, $block_id) {
424
+
425
+        $user_id = intval($user_id);
426
+        $user_block_data = self::get_user_block_data($user_id);
427
+        $enabled_blocks_id = array_keys($user_block_data);
428
+
429
+        $checked = '';
430
+        if (in_array($block_id, $enabled_blocks_id)) {
431
+            $checked = "checked";
432
+        }
433
+
434
+        echo "<td align=\"center\">";
435
+        echo '<input type="checkbox" name="enabled_blocks['.$block_id.']" value="true" '.$checked.'/>';
436
+        echo "</td>";
437
+    }
438
+
439
+    /**
440
+     * This function store enabled blocks id with its column position (block_id1:colum;block_id2:colum; ...) inside extra user fields
441
+     * @param int User id
442
+     * @param array selected blocks
443
+     * @param array columns position
444
+     * @return bool
445
+     */
446
+    public static function store_user_blocks($user_id, $enabled_blocks, $columns) {
447
+        $selected_blocks_id  = array();
448
+        if (is_array($enabled_blocks) && count($enabled_blocks) > 0) {
449
+            $selected_blocks_id = array_keys($enabled_blocks);
450
+        }
451
+
452
+        // build data for storing inside extra user field
453
+        $fname = 'dashboard';
454
+        $fvalue = array();
455
+        foreach ($selected_blocks_id as $block_id) {
456
+            $fvalue[] = $block_id.':'.$columns[$block_id];
457
+        }
458 458
         $upd_extra_field = UserManager::update_extra_field_value(
459 459
             $user_id,
460 460
             $fname,
461 461
             $fvalue
462 462
         );
463 463
 
464
-		return $upd_extra_field;
464
+        return $upd_extra_field;
465 465
 
466
-	}
466
+    }
467 467
 
468
-	/**
469
-	 * This function get user block data (block id with its number of column) from extra user data
470
-	 * @param int  		User id
471
-	 * @return array  	data (block_id,column)
472
-	 */
473
-	public static function get_user_block_data($user_id)
468
+    /**
469
+     * This function get user block data (block id with its number of column) from extra user data
470
+     * @param int  		User id
471
+     * @return array  	data (block_id,column)
472
+     */
473
+    public static function get_user_block_data($user_id)
474 474
     {
475
-		$user_id = intval($user_id);
476
-		$field_variable = 'dashboard';
477
-		$extra_user_data = UserManager::get_extra_user_data_by_field($user_id, $field_variable);
478
-		$extra_user_data = explode(';',$extra_user_data[$field_variable]);
479
-		$data = array();
480
-		foreach ($extra_user_data as $extra) {
481
-			$split_extra = explode(':',$extra);
482
-			if (!empty($split_extra)) {
483
-				$block_id = $split_extra[0];
484
-				$column = isset($split_extra[1]) ? $split_extra[1] : null;
485
-				$data[$block_id] = array('block_id' => $block_id, 'column' => $column);
486
-			}
487
-		}
488
-
489
-		return $data;
490
-	}
491
-
492
-	/**
493
-	 * This function update extra user blocks data after closing a dashboard block
494
-	 * @param int 		User id
495
-	 * @param string	plugin path
496
-	 * @return bool
497
-	 */
498
-	public static function close_user_block($user_id, $path)
475
+        $user_id = intval($user_id);
476
+        $field_variable = 'dashboard';
477
+        $extra_user_data = UserManager::get_extra_user_data_by_field($user_id, $field_variable);
478
+        $extra_user_data = explode(';',$extra_user_data[$field_variable]);
479
+        $data = array();
480
+        foreach ($extra_user_data as $extra) {
481
+            $split_extra = explode(':',$extra);
482
+            if (!empty($split_extra)) {
483
+                $block_id = $split_extra[0];
484
+                $column = isset($split_extra[1]) ? $split_extra[1] : null;
485
+                $data[$block_id] = array('block_id' => $block_id, 'column' => $column);
486
+            }
487
+        }
488
+
489
+        return $data;
490
+    }
491
+
492
+    /**
493
+     * This function update extra user blocks data after closing a dashboard block
494
+     * @param int 		User id
495
+     * @param string	plugin path
496
+     * @return bool
497
+     */
498
+    public static function close_user_block($user_id, $path)
499 499
     {
500
-		$enabled_dashboard_blocks = self::get_enabled_dashboard_blocks($path);
501
-		$user_block_data = self::get_user_block_data($user_id);
502
-
503
-		foreach ($enabled_dashboard_blocks as $enabled_block) {
504
-			unset($user_block_data[$enabled_block['id']]);
505
-		}
506
-
507
-		// get columns and blocks id for updating extra user data
508
-		$columns = array();
509
-		$user_blocks_id = array();
510
-		foreach ($user_block_data as $data) {
511
-			$user_blocks_id[$data['block_id']] = true;
512
-			$columns[$data['block_id']] = $data['column'];
513
-		}
514
-
515
-		// update extra user blocks data
516
-		$upd_extra_field = self::store_user_blocks($user_id, $user_blocks_id, $columns);
517
-
518
-		return $upd_extra_field;
519
-	}
520
-
521
-	/**
522
-	 * get links for styles from dashboard plugins
523
-	 * @return string   links
524
-	 */
525
-	public static function get_links_for_styles_from_dashboard_plugins() {
526
-
527
-		return '<link rel="stylesheet" href="'.api_get_path(WEB_PLUGIN_PATH).'dashboard/css/default.css" type="text/css" />'.PHP_EOL;
528
-	}
500
+        $enabled_dashboard_blocks = self::get_enabled_dashboard_blocks($path);
501
+        $user_block_data = self::get_user_block_data($user_id);
502
+
503
+        foreach ($enabled_dashboard_blocks as $enabled_block) {
504
+            unset($user_block_data[$enabled_block['id']]);
505
+        }
506
+
507
+        // get columns and blocks id for updating extra user data
508
+        $columns = array();
509
+        $user_blocks_id = array();
510
+        foreach ($user_block_data as $data) {
511
+            $user_blocks_id[$data['block_id']] = true;
512
+            $columns[$data['block_id']] = $data['column'];
513
+        }
514
+
515
+        // update extra user blocks data
516
+        $upd_extra_field = self::store_user_blocks($user_id, $user_blocks_id, $columns);
517
+
518
+        return $upd_extra_field;
519
+    }
520
+
521
+    /**
522
+     * get links for styles from dashboard plugins
523
+     * @return string   links
524
+     */
525
+    public static function get_links_for_styles_from_dashboard_plugins() {
526
+
527
+        return '<link rel="stylesheet" href="'.api_get_path(WEB_PLUGIN_PATH).'dashboard/css/default.css" type="text/css" />'.PHP_EOL;
528
+    }
529 529
 
530 530
 }
Please login to merge, or discard this patch.
main/inc/lib/event_email_template.class.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
     /**
13 13
      * Constructor
14 14
      */
15
-	public function __construct()
15
+    public function __construct()
16 16
     {
17 17
         $this->table =  Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE);
18
-	}
18
+    }
19 19
 
20 20
     public function get_all($where_conditions = array())
21 21
     {
@@ -29,19 +29,19 @@  discard block
 block discarded – undo
29 29
     /**
30 30
      * Displays the title + grid
31 31
      */
32
-	public function display()
32
+    public function display()
33 33
     {
34
-		// action links
35
-		$content = Display::actions(array(
34
+        // action links
35
+        $content = Display::actions(array(
36 36
                 array(
37 37
                     'url' => 'event_type.php' ,
38 38
                     'content' => Display::return_icon('new_document.png', get_lang('Add'), array(), ICON_SIZE_MEDIUM)
39
-                 )
39
+                    )
40 40
             )
41 41
         );
42 42
         $content .= Display::grid_html('event_email_template');
43 43
         return $content;
44
-	}
44
+    }
45 45
 
46 46
     public function get_status_list()
47 47
     {
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
                 'Height' => '250',
83 83
             )
84 84
         );
85
-	    $status_list = $this->get_status_list();
85
+        $status_list = $this->get_status_list();
86 86
         $form->addElement('select', 'status', get_lang('Status'), $status_list);
87 87
         if ($action == 'edit') {
88 88
             $form->addElement('text', 'created_at', get_lang('CreatedAt'));
@@ -99,17 +99,17 @@  discard block
 block discarded – undo
99 99
         $defaults = $this->get($id);
100 100
 
101 101
         if (!empty($defaults['created_at'])) {
102
-        	$defaults['created_at'] = api_convert_and_format_date($defaults['created_at']);
102
+            $defaults['created_at'] = api_convert_and_format_date($defaults['created_at']);
103 103
         }
104 104
         if (!empty($defaults['updated_at'])) {
105
-        	$defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']);
105
+            $defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']);
106 106
         }
107 107
         $form->setDefaults($defaults);
108 108
 
109 109
         // Setting the rules
110 110
         $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
111 111
 
112
-		return $form;
112
+        return $form;
113 113
     }
114 114
 
115 115
     public function get_count()
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/www/examples.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -3,17 +3,17 @@  discard block
 block discarded – undo
3 3
 require_once("../dompdf_config.inc.php");
4 4
 if ( isset( $_POST["html"] ) ) {
5 5
 
6
-  if ( get_magic_quotes_gpc() )
6
+    if ( get_magic_quotes_gpc() )
7 7
     $_POST["html"] = stripslashes($_POST["html"]);
8 8
   
9
-  $dompdf = new DOMPDF();
10
-  $dompdf->load_html($_POST["html"]);
11
-  $dompdf->set_paper($_POST["paper"], $_POST["orientation"]);
12
-  $dompdf->render();
9
+    $dompdf = new DOMPDF();
10
+    $dompdf->load_html($_POST["html"]);
11
+    $dompdf->set_paper($_POST["paper"], $_POST["orientation"]);
12
+    $dompdf->render();
13 13
 
14
-  $dompdf->stream("dompdf_out.pdf");
14
+    $dompdf->stream("dompdf_out.pdf");
15 15
 
16
-  exit(0);
16
+    exit(0);
17 17
 }
18 18
 
19 19
 ?>
@@ -42,18 +42,18 @@  discard block
 block discarded – undo
42 42
 $dompdf = dirname(dirname($_SERVER["PHP_SELF"]));
43 43
 //echo '<li>['.$dompdf.']</li>';
44 44
 if ( $dompdf == '/' || $dompdf == '\\') {
45
-  $dompdf = '';
45
+    $dompdf = '';
46 46
 }
47 47
 //echo '<li>['.$dompdf.']</li>';
48 48
 $dompdf .= "/dompdf.php?base_path=" . rawurlencode("www/test/");
49 49
 //echo '<li>['.$dompdf.']</li>';
50 50
 foreach ( $test_files as $file ) {
51
-  $file = basename($file);
52
-  $arrow = "images/arrow_0" . rand(1, 6) . ".gif";  
53
-  echo "<li style=\"list-style-image: url('$arrow');\">\n";
54
-  echo $file;
55
-  echo " [<a class=\"button\" target=\"blank\" href=\"test/$file\">HTML</a>] [<a class=\"button\" href=\"$dompdf&input_file=" . rawurlencode("$file") .  "\">PDF</a>]\n";
56
-  echo "</li>\n";
51
+    $file = basename($file);
52
+    $arrow = "images/arrow_0" . rand(1, 6) . ".gif";  
53
+    echo "<li style=\"list-style-image: url('$arrow');\">\n";
54
+    echo $file;
55
+    echo " [<a class=\"button\" target=\"blank\" href=\"test/$file\">HTML</a>] [<a class=\"button\" href=\"$dompdf&input_file=" . rawurlencode("$file") .  "\">PDF</a>]\n";
56
+    echo "</li>\n";
57 57
 }
58 58
 ?>
59 59
 </ul>
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 <select name="paper">
70 70
 <?php
71 71
 foreach ( array_keys(CPDF_Adapter::$PAPER_SIZES) as $size )
72
-  echo "<option ". ($size == "letter" ? "selected " : "" ) . "value=\"$size\">$size</option>\n";
72
+    echo "<option ". ($size == "letter" ? "selected " : "" ) . "value=\"$size\">$size</option>\n";
73 73
 ?>
74 74
 </select>
75 75
 <select name="orientation">
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/www/head.inc 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 function li_arrow() {
3
-  return '<li style="list-style-image: url(\'images/arrow_0' . rand(1,6) . '.gif\');">';  
3
+    return '<li style="list-style-image: url(\'images/arrow_0' . rand(1,6) . '.gif\');">';  
4 4
 }
5 5
 function li_star() {
6
-  return '<li style="list-style-image: url(\'images/star_0' . rand(1,5) . '.gif\');">';  
6
+    return '<li style="list-style-image: url(\'images/star_0' . rand(1,5) . '.gif\');">';  
7 7
 }
8 8
 ?>
9 9
 <?php echo '<?' . 'xml version="1.0" encoding="iso-8859-1"?' . '>'; ?>
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/image_cache.cls.php 1 patch
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -1,54 +1,54 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * DOMPDF - PHP5 HTML to PDF renderer
4
- *
5
- * File: $RCSfile: image_cache.cls.php,v $
6
- * Created on: 2004-08-08
7
- *
8
- * Copyright (c) 2004 - Benj Carson <[email protected]>
9
- *
10
- * This library is free software; you can redistribute it and/or
11
- * modify it under the terms of the GNU Lesser General Public
12
- * License as published by the Free Software Foundation; either
13
- * version 2.1 of the License, or (at your option) any later version.
14
- *
15
- * This library is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18
- * Lesser General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU Lesser General Public License
21
- * along with this library in the file LICENSE.LGPL; if not, write to the
22
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23
- * 02111-1307 USA
24
- *
25
- * Alternatively, you may distribute this software under the terms of the
26
- * PHP License, version 3.0 or later.  A copy of this license should have
27
- * been distributed with this file in the file LICENSE.PHP .  If this is not
28
- * the case, you can obtain a copy at http://www.php.net/license/3_0.txt.
29
- *
30
- * The latest version of DOMPDF might be available at:
31
- * http://www.dompdf.com/
32
- *
33
- * @link http://www.dompdf.com/
34
- * @copyright 2004 Benj Carson
35
- * @author Benj Carson <[email protected]>
36
- * @contributor Helmut Tischer <[email protected]>
37
- * @package dompdf
38
- *
39
- * Changes
40
- * @contributor Helmut Tischer <[email protected]>
41
- * @version 0.5.1.htischer.20090507
42
- * - On getting type of images don't require any file endings
43
- *   and don't strip off url parameters,
44
- *   to allowing dynamically generated sites with image id
45
- *   in url parameters and not at end of url or missing file extension
46
- * @contributor Helmut Tischer <[email protected]>
47
- * @version dompdf_trunk_with_helmut_mods.20090524
48
- * - Made debug messages more individually configurable
49
- * @version 20090622
50
- * - don't cache broken image, but refer to original broken image replacement
51
- */
3
+     * DOMPDF - PHP5 HTML to PDF renderer
4
+     *
5
+     * File: $RCSfile: image_cache.cls.php,v $
6
+     * Created on: 2004-08-08
7
+     *
8
+     * Copyright (c) 2004 - Benj Carson <[email protected]>
9
+     *
10
+     * This library is free software; you can redistribute it and/or
11
+     * modify it under the terms of the GNU Lesser General Public
12
+     * License as published by the Free Software Foundation; either
13
+     * version 2.1 of the License, or (at your option) any later version.
14
+     *
15
+     * This library is distributed in the hope that it will be useful,
16
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18
+     * Lesser General Public License for more details.
19
+     *
20
+     * You should have received a copy of the GNU Lesser General Public License
21
+     * along with this library in the file LICENSE.LGPL; if not, write to the
22
+     * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23
+     * 02111-1307 USA
24
+     *
25
+     * Alternatively, you may distribute this software under the terms of the
26
+     * PHP License, version 3.0 or later.  A copy of this license should have
27
+     * been distributed with this file in the file LICENSE.PHP .  If this is not
28
+     * the case, you can obtain a copy at http://www.php.net/license/3_0.txt.
29
+     *
30
+     * The latest version of DOMPDF might be available at:
31
+     * http://www.dompdf.com/
32
+     *
33
+     * @link http://www.dompdf.com/
34
+     * @copyright 2004 Benj Carson
35
+     * @author Benj Carson <[email protected]>
36
+     * @contributor Helmut Tischer <[email protected]>
37
+     * @package dompdf
38
+     *
39
+     * Changes
40
+     * @contributor Helmut Tischer <[email protected]>
41
+     * @version 0.5.1.htischer.20090507
42
+     * - On getting type of images don't require any file endings
43
+     *   and don't strip off url parameters,
44
+     *   to allowing dynamically generated sites with image id
45
+     *   in url parameters and not at end of url or missing file extension
46
+     * @contributor Helmut Tischer <[email protected]>
47
+     * @version dompdf_trunk_with_helmut_mods.20090524
48
+     * - Made debug messages more individually configurable
49
+     * @version 20090622
50
+     * - don't cache broken image, but refer to original broken image replacement
51
+     */
52 52
 
53 53
 /* $Id: image_cache.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
54 54
 
@@ -61,25 +61,25 @@  discard block
 block discarded – undo
61 61
  */
62 62
 class Image_Cache {
63 63
 
64
-  /**
65
-   * Array of downloaded images.  Cached so that identical images are
66
-   * not needlessly downloaded.
67
-   *
68
-   * @var array
69
-   */
70
-  static protected $_cache = array();
71
-
72
-
73
-  /**
74
-   * Resolve and fetch an image for use.
75
-   *
76
-   * @param string $url        The url of the image
77
-   * @param string $proto      Default protocol if none specified in $url
78
-   * @param string $host       Default host if none specified in $url
79
-   * @param string $base_path  Default path if none specified in $url
80
-   * @return array             An array with two elements: The local path to the image and the image extension
81
-   */
82
-  static function resolve_url($url, $proto, $host, $base_path) {
64
+    /**
65
+     * Array of downloaded images.  Cached so that identical images are
66
+     * not needlessly downloaded.
67
+     *
68
+     * @var array
69
+     */
70
+    static protected $_cache = array();
71
+
72
+
73
+    /**
74
+     * Resolve and fetch an image for use.
75
+     *
76
+     * @param string $url        The url of the image
77
+     * @param string $proto      Default protocol if none specified in $url
78
+     * @param string $host       Default host if none specified in $url
79
+     * @param string $base_path  Default path if none specified in $url
80
+     * @return array             An array with two elements: The local path to the image and the image extension
81
+     */
82
+    static function resolve_url($url, $proto, $host, $base_path) {
83 83
     global $_dompdf_warnings;
84 84
 
85 85
     $parsed_url = explode_url($url);
@@ -94,23 +94,23 @@  discard block
 block discarded – undo
94 94
     $remote = $remote || ($parsed_url['protocol'] != "");
95 95
 
96 96
     if ( !DOMPDF_ENABLE_REMOTE && $remote ) {
97
-      $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png";
98
-      $ext = "png";
97
+        $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png";
98
+        $ext = "png";
99 99
 
100
-      //debugpng
101
-      if ($DEBUGPNG) $full_url_dbg = '(blockedremote)';
100
+        //debugpng
101
+        if ($DEBUGPNG) $full_url_dbg = '(blockedremote)';
102 102
 
103 103
     } else if ( DOMPDF_ENABLE_REMOTE && $remote ) {
104
-      // Download remote files to a temporary directory
105
-      $full_url = build_url($proto, $host, $base_path, $url);
104
+        // Download remote files to a temporary directory
105
+        $full_url = build_url($proto, $host, $base_path, $url);
106 106
 
107
-      if ( isset(self::$_cache[$full_url]) ) {
107
+        if ( isset(self::$_cache[$full_url]) ) {
108 108
         list($resolved_url,$ext) = self::$_cache[$full_url];
109 109
 
110 110
         //debugpng
111 111
         if ($DEBUGPNG) $full_url_dbg = $full_url.'(cache)';
112 112
 
113
-      } else {
113
+        } else {
114 114
 
115 115
         $resolved_url = tempnam(DOMPDF_TEMP_DIR, "ca_dompdf_img_");
116 116
         //debugpng
@@ -121,21 +121,21 @@  discard block
 block discarded – undo
121 121
         restore_error_handler();
122 122
 
123 123
         if ( strlen($image) == 0 ) {
124
-          //target image not found
125
-          $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png";
126
-          $ext = "png";
124
+            //target image not found
125
+            $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png";
126
+            $ext = "png";
127 127
 
128
-          //debugpng
129
-          if ($DEBUGPNG) $full_url_dbg = $full_url.'(missing)';
128
+            //debugpng
129
+            if ($DEBUGPNG) $full_url_dbg = $full_url.'(missing)';
130 130
 
131 131
         } else {
132 132
 
133 133
         file_put_contents($resolved_url, $image);
134 134
 
135
-		//e.g. fetch.php?media=url.jpg&cache=1
136
-		//- Image file name might be one of the dynamic parts of the url, don't strip off!
137
-		//  if ( preg_match("/.*\.(\w+)/",$url,$match) ) $ext = $match[1];
138
-		//- a remote url does not need to have a file extension at all
135
+        //e.g. fetch.php?media=url.jpg&cache=1
136
+        //- Image file name might be one of the dynamic parts of the url, don't strip off!
137
+        //  if ( preg_match("/.*\.(\w+)/",$url,$match) ) $ext = $match[1];
138
+        //- a remote url does not need to have a file extension at all
139 139
         //- local cached file does not have a matching file extension
140 140
         //Therefore get image type from the content
141 141
 
@@ -146,33 +146,33 @@  discard block
 block discarded – undo
146 146
         $imagetypes = array('','gif','jpeg','png','swf');
147 147
         $ext = $imagetypes[$imagedim[2]];
148 148
         if ( rename($resolved_url,$resolved_url.'.'.$ext) ) {
149
-          $resolved_url .= '.'.$ext;
149
+            $resolved_url .= '.'.$ext;
150 150
         }
151 151
  
152
- 		//Don't put replacement image into cache - otherwise it will be deleted on cache cleanup.
153
- 		//Only execute on successfull caching of remote image.
152
+            //Don't put replacement image into cache - otherwise it will be deleted on cache cleanup.
153
+            //Only execute on successfull caching of remote image.
154 154
         self::$_cache[$full_url] = array($resolved_url,$ext);
155 155
 
156 156
         } else {
157
-          //target image is not valid.
158
-          unlink($resolved_url);
157
+            //target image is not valid.
158
+            unlink($resolved_url);
159 159
           
160
-          $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png";
161
-          $ext = "png";
160
+            $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png";
161
+            $ext = "png";
162 162
         }
163 163
         }
164 164
 
165
-      }
165
+        }
166 166
 
167 167
     } else {
168 168
 
169
-      $resolved_url = build_url($proto, $host, $base_path, $url);
170
-      if ($DEBUGPNG) print 'build_url('.$proto.','.$host.','.$base_path.','.$url.')('.$resolved_url.')';
169
+        $resolved_url = build_url($proto, $host, $base_path, $url);
170
+        if ($DEBUGPNG) print 'build_url('.$proto.','.$host.','.$base_path.','.$url.')('.$resolved_url.')';
171 171
 
172
-      if ( !preg_match("/.*\.(\w+)/",$url,$match) ) {
172
+        if ( !preg_match("/.*\.(\w+)/",$url,$match) ) {
173 173
         //debugpng
174 174
         if ($DEBUGPNG) print '[resolve_url exception '.$url.']';
175
-          throw new DOMPDF_Exception("Unknown image type: $url.");
175
+            throw new DOMPDF_Exception("Unknown image type: $url.");
176 176
         }
177 177
 
178 178
         $ext = $match[1];
@@ -184,35 +184,35 @@  discard block
 block discarded – undo
184 184
 
185 185
     if ( !is_readable($resolved_url) || !filesize($resolved_url) ) {
186 186
 
187
-      //debugpng
188
-      if ($DEBUGPNG) $full_url_dbg .= '(nocache'.$resolved_url.')';
187
+        //debugpng
188
+        if ($DEBUGPNG) $full_url_dbg .= '(nocache'.$resolved_url.')';
189 189
 
190
-      $_dompdf_warnings[] = "File " .$resolved_url . " is not readable or is an empty file.\n";
191
-      $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png";
192
-      $ext = "png";
190
+        $_dompdf_warnings[] = "File " .$resolved_url . " is not readable or is an empty file.\n";
191
+        $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png";
192
+        $ext = "png";
193 193
     }
194 194
 
195 195
     //debugpng
196 196
     if ($DEBUGPNG) print '[resolve_url '.$url.'|'.$full_url_dbg.'|'.$resolved_url.'|'.$ext.']';
197 197
 
198 198
     return array($resolved_url, $ext);
199
-  }
199
+    }
200 200
 
201
-  /**
202
-   * Unlink all cached images (i.e. temporary images either downloaded
203
-   * or converted)
204
-   */
205
-  static function clear() {
201
+    /**
202
+     * Unlink all cached images (i.e. temporary images either downloaded
203
+     * or converted)
204
+     */
205
+    static function clear() {
206 206
     if ( count(self::$_cache) ) {
207
-      while ($entry = array_shift(self::$_cache)) {
207
+        while ($entry = array_shift(self::$_cache)) {
208 208
         list($file, $ext) = $entry;
209 209
         //debugpng
210 210
         if (DEBUGPNG) print '[clear unlink '.$file.']';
211 211
         if (!DEBUGKEEPTEMP)
212
-          //XXX: Should we have some kind of fallback or warning if unlink() fails?
213
-          unlink($file);
214
-      }
212
+            //XXX: Should we have some kind of fallback or warning if unlink() fails?
213
+            unlink($file);
214
+        }
215
+    }
215 216
     }
216
-  }
217 217
 
218 218
 }
Please login to merge, or discard this patch.