replace spaces with tabs, use const and linkTo instead of static path

This commit is contained in:
Bartek Przybylski 2012-06-06 23:23:23 +02:00
parent 276aefba81
commit c932f93a40
1 changed files with 133 additions and 136 deletions

View File

@ -5,16 +5,13 @@ namespace OC\Pictures;
require_once('lib/base.php');
require_once('managers.php');
const TILE_PROPORTION_HORIZONTAL = 0;
const TILE_PROPORTION_VERTICAL = 0;
const GET_THUMBNAIL_PATH = '?app=gallery&getfile=ajax/thumbnail.php&filepath=';
const TAG = 'Pictures';
const IMAGE_WIDTH = 150;
class TileBase {
public function getWidth() { return false; }
public function getHeight() { return 150; }
public function getHeight() { return IMAGE_WIDTH; }
public function getOnHoverAction() { return false; }
@ -65,7 +62,7 @@ class TilesLine {
for ($i = 0; $i < count($this->tiles_array); $i++) {
$img_w = $this->tiles_array[$i]->getWidth();
$extra = '';
if ($img_w != 150) $extra = ' style="width:'.$img_w.'px"';
if ($img_w != IMAGE_WIDTH) $extra = ' style="width:'.$img_w.'px"';
$r .= '<div class="gallery_div" '.$extra.' onmouseover="'.$this->tiles_array[$i]->getOnHoverAction().'" onmouseout="'.$this->tiles_array[$i]->getOnOutAction().'" onclick="'.$this->tiles_array[$i]->getOnClickAction().'">'.$this->tiles_array[$i]->get().'</div>';
}
@ -98,11 +95,11 @@ class TileSingle extends TileBase {
public function get($extra = '') {
// !HACK! file path needs to be encoded twice because files app decode twice url, so any special chars like + or & in filename
// !HACK! will result in failing of opening them
return '<a rel="images" href="?app=files&getfile=download.php?file='.urlencode(urlencode($this->getPath())).'"><img rel="images" src="'.GET_THUMBNAIL_PATH.urlencode($this->getPath()).'" '.$extra.'></a>';
return '<a rel="images" href="'.\OCP\Util::linkTo('files', 'download.php').'?file='.urlencode(urlencode($this->getPath())).'"><img rel="images" src="'.\OCP\Util::linkTo('gallery', 'ajax/thumbnail.php').'&filepath='.urlencode($this->getPath()).'" '.$extra.'></a>';
}
public function getMiniatureSrc() {
return GET_THUMBNAIL_PATH.urlencode($this->getPath());
return \OCP\Util::linkTo('gallery', 'ajax/thumbnail.php').'&filepath='.urlencode($this->getPath());
}
public function getPath() {