Example #1
0
 public static function getInstance()
 {
     if (!isset(self::$instance))
     {
         self::$instance = new ImageConverter();
     }
     return self::$instance;
 }
Example #2
0
 /**
  * 画像を端末の解像度に合わせて変換する
  * output buffering 用コールバック関数
  *
  * @param string 入力
  * @return string 出力
  */
 function handler($buffer)
 {
     // 端末情報を取得する
     $carrier = SC_MobileUserAgent::getCarrier();
     $model = SC_MobileUserAgent::getModel();
     // 携帯電話の場合のみ処理を行う
     if ($carrier !== FALSE) {
         // HTML中のIMGタグを取得する
         $pattern = '/<img\\s+[^<>]*src=[\'"]?([^>"\'\\s]+)[\'"]?\\s*\\/?/i';
         $result = preg_match_all($pattern, $buffer, $images);
         // 端末の情報を取得する
         $fp = fopen(MOBILE_IMAGE_INC_PATH . "/mobile_image_map_{$carrier}.csv", "r");
         while (($data = fgetcsv($fp, 1000, ",")) !== FALSE) {
             if ($data[1] == $model || $data[1] == '*') {
                 $cacheSize = $data[2];
                 $imageFileSize = $data[7];
                 $imageType = $data[6];
                 $imageWidth = $data[5];
                 $imageHeight = $data[4];
                 break;
             }
         }
         fclose($fp);
         // docomoとsoftbankの場合は画像ファイル一つに利用可能なサイズの上限を計算する
         // auはHTMLのbyte数上限に画像ファイルサイズが含まれないのでimageFileSizeのまま。
         if ($carrier == "docomo" or $carrier == "softbank") {
             if ($result != false && $result > 0) {
                 // 計算式:(利用端末で表示可能なcacheサイズ - HTMLのバイト数 - 変換後の画像名のバイト数(目安値) ) / HTML中の画像数
                 $temp_imagefilesize = ($cacheSize - strlen($buffer) - 140 * $result) / $result;
             } else {
                 // 計算式:(利用端末で表示可能なcacheサイズ - HTMLのバイト数 )
                 $temp_imagefilesize = $cacheSize - strlen($buffer);
             }
             // 計算結果が端末の表示可能ファイルサイズ上限より小さい場合は計算結果の値を有効にする
             if ($temp_imagefilesize < $imageFileSize) {
                 $imageFileSize = $temp_imagefilesize;
             }
         }
         // 画像変換の情報をセットする
         $imageConverter = new ImageConverter();
         $imageConverter->setOutputDir(MOBILE_IMAGE_DIR);
         $imageConverter->setImageType($imageType);
         $imageConverter->setImageWidth($imageWidth);
         $imageConverter->setImageHeight($imageHeight);
         $imageConverter->setFileSize($imageFileSize);
         // HTML中のIMGタグを変換後のファイルパスに置換する
         foreach ($images[1] as $key => $value) {
             $converted = $imageConverter->execute(preg_replace('|^' . URL_DIR . '|', HTML_PATH, $value));
             if (isset($converted['outputImageName'])) {
                 $buffer = str_replace($value, MOBILE_IMAGE_URL . '/' . $converted['outputImageName'], $buffer);
             } else {
                 $buffer = str_replace($images[0][$key], '<!--No image-->', $buffer);
             }
         }
     }
     return $buffer;
 }
 function insertImage()
 {
     $type = get_extension($this->IMG);
     if ($type == 'gif') {
         $img = new ImageConverter($this->IMG, "png");
         $url = $img->getURL();
     } elseif ($type == 'bmp') {
         $img = new ImageConverter($this->IMG, "jpg");
         $url = $img->getURL();
     } else {
         $url = $this->IMG;
     }
     $nfo = @getimagesize($url);
     if ($nfo[0] > 0 && $nfo[1] > 0) {
         $x = $this->GetX();
         $y = $this->GetY();
         $sizex = $this->px2mm($nfo[0]);
         $sizey = $this->px2mm($nfo[1]);
         if ($sizey > $this->maximgheight) {
             $this->maximgheight = $sizey;
         }
         $pixel = $this->px2mm(1, 72);
         $this->Image($url, $x + $pixel, $y, $sizex, $sizey, '', $this->IMG);
         $this->SetXY($x + $pixel + $sizex, $y);
     }
 }
 /**
  * 画像を端末の解像度に合わせて変換する
  * output buffering 用コールバック関数
  *
  * @param string 入力
  * @return string 出力
  */
 public static function handler($buffer)
 {
     // 端末情報を取得する
     $carrier = SC_MobileUserAgent_Ex::getCarrier();
     $model = SC_MobileUserAgent_Ex::getModel();
     // 携帯電話の場合のみ処理を行う
     if ($carrier !== FALSE) {
         // HTML中のIMGタグを取得する
         $images = array();
         $pattern = '/<img\\s+[^<>]*src=[\'"]?([^>"\'\\s]+)[\'"]?[^>]*>/i';
         $result = preg_match_all($pattern, $buffer, $images);
         // 端末の情報を取得する
         $fp = fopen(MOBILE_IMAGE_INC_REALDIR . "mobile_image_map_{$carrier}.csv", 'r');
         // 取得できない場合は, 入力内容をそのまま返す
         if ($fp === false) {
             return $buffer;
         }
         while (($data = fgetcsv($fp, 1000, ',')) !== FALSE) {
             if ($data[1] == $model || $data[1] == '*') {
                 $cacheSize = $data[2];
                 $imageFileSize = $data[7];
                 $imageType = $data[6];
                 $imageWidth = $data[5];
                 $imageHeight = $data[4];
                 break;
             }
         }
         fclose($fp);
         // docomoとsoftbankの場合は画像ファイル一つに利用可能なサイズの上限を計算する
         // auはHTMLのbyte数上限に画像ファイルサイズが含まれないのでimageFileSizeのまま。
         if ($carrier == 'docomo' or $carrier == 'softbank') {
             if ($result != false && $result > 0) {
                 // 計算式:(利用端末で表示可能なcacheサイズ - HTMLのバイト数 - 変換後の画像名のバイト数(目安値)) / HTML中の画像数
                 $temp_imagefilesize = ($cacheSize - strlen($buffer) - 140 * $result) / $result;
             } else {
                 // 計算式:(利用端末で表示可能なcacheサイズ - HTMLのバイト数)
                 $temp_imagefilesize = $cacheSize - strlen($buffer);
             }
             // 計算結果が端末の表示可能ファイルサイズ上限より小さい場合は計算結果の値を有効にする
             if ($temp_imagefilesize < $imageFileSize) {
                 $imageFileSize = $temp_imagefilesize;
             }
         }
         // 画像変換の情報をセットする
         $imageConverter = new ImageConverter();
         $imageConverter->setOutputDir(MOBILE_IMAGE_REALDIR);
         $imageConverter->setImageType($imageType);
         $imageConverter->setImageWidth($imageWidth);
         $imageConverter->setImageHeight($imageHeight);
         $imageConverter->setFileSize($imageFileSize);
         // HTML中のIMGタグを変換後のファイルパスに置換する
         foreach ($images[1] as $key => $path) {
             // resize_image.phpは除外
             if (stripos($path, ROOT_URLPATH . 'resize_image.php') !== FALSE) {
                 continue;
             }
             $realpath = html_entity_decode($path, ENT_QUOTES);
             $realpath = substr_replace($realpath, HTML_REALDIR, 0, strlen(ROOT_URLPATH));
             $converted = $imageConverter->execute($realpath);
             if (isset($converted['outputImageName'])) {
                 $buffer = str_replace($path, MOBILE_IMAGE_URLPATH . $converted['outputImageName'], $buffer);
             } else {
                 $buffer = str_replace($images[0][$key], '<!--No image-->', $buffer);
             }
         }
     }
     return $buffer;
 }
Example #5
0
 /**
  * Convert this image using a given converter
  *
  * @param   img.convert.ImageConverter converter
  * @return  bool
  * @throws  lang.IllegalArgumentException if converter is not a img.convert.ImageConverter
  */
 public function convertTo(ImageConverter $converter)
 {
     return $converter->convert($this);
 }
    /**
     * mainpage with an overview over all files and a form to select 3 files for an upload
     * @access private
     */
    function _homePage()
    {
        $path = GetPostOrGet('path');
        if (substr($path, -1, 1) == '/') {
            $path = substr($path, 0, -1);
        }
        $pathPart = explode('/', $path);
        array_pop($pathPart);
        $uppath = implode('/', $pathPart);
        $pathLen = strlen($path);
        $out = "\t\t\t<fieldset>\n\t \t\t\t<legend>" . $this->_Translation->GetTranslation('upload') . "</legend>\n\t\t\t\t<form enctype=\"multipart/form-data\" action=\"admin.php?page=files\" method=\"post\">\n\t\t\t\t\t<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"1600000\" />\n\t\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"upload\" />\n\t\t\t\t\t<input type=\"hidden\" name=\"path\" value=\"" . $path . "\" />\n\t\t\t\t\t<div class=\"row\">\n\t\t\t\t\t\t<label>\n\t\t\t\t\t\t\t<strong>" . $this->_Translation->GetTranslation('file') . " 1:</strong>\n\t\t\t\t\t\t</label>\n\t\t\t\t\t\t<input name=\"uploadfile0\" type=\"file\" />\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"row\">\n\t\t\t\t\t\t<label>\n\t\t\t\t\t\t\t<strong>" . $this->_Translation->GetTranslation('file') . " 2:</strong>\n\t\t\t\t\t\t</label>\n\t\t\t\t\t\t<input name=\"uploadfile1\" type=\"file\" />\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"row\">\n\t\t\t\t\t\t<label>\n\t\t\t\t\t\t\t<strong>" . $this->_Translation->GetTranslation('file') . " 3:</strong>\n\t\t\t\t\t\t</label>\n\t\t\t\t\t\t<input name=\"uploadfile2\" type=\"file\" />\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"row\">\n\t\t\t\t\t\t<input type=\"submit\" class=\"button\" value=\"" . $this->_Translation->GetTranslation('upload_files') . "\"/>\n\t\t\t\t\t</div>\n\t\t\t\t</form>\n\t\t\t\t<div class=\"row\">\n\t\t\t\t\t<a href=\"admin.php?page=files&amp;action=check_new_files\" class=\"button\">" . $this->_Translation->GetTranslation('check_for_changes') . "</a>\n\t\t\t\t</div>\n\t\t\t</fieldset>\n\t\t\t<fieldset>\n\t \t\t\t<legend>" . $this->_Translation->GetTranslation('create_directory') . "</legend>\n\t\t\t\t<form action=\"admin.php?page=files\" method=\"post\">\n\t\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"new_dir\" />\n\t\t\t\t\t<input type=\"hidden\" name=\"path\" value=\"" . $path . "\" />\n\t\t\t\t\t<div class=\"row\">\n\t\t\t\t\t\t<label>\n\t\t\t\t\t\t\t<strong>" . $this->_Translation->GetTranslation('directory') . " </strong>\n\t\t\t\t\t\t</label>\n\t\t\t\t\t\t<input name=\"dirname\" type=\"text\" />\n\t\t\t\t\t</div>\n\t\t\t\t\t\n\t\t\t\t\t<div class=\"row\">\n\t\t\t\t\t\t<input type=\"submit\" class=\"button\" value=\"" . $this->_Translation->GetTranslation('create_directory') . "\"/>\n\t\t\t\t\t</div>\n\t\t\t\t</form>\n\t\t\t</fieldset>\t<h3>Pfad: /" . $path . "</h3>";
        if ($pathLen > 0) {
            $out .= "\n\t\t\t\t<div class=\"row\">\n\t\t\t\t\t<a href=\"admin.php?page=files&amp;path=" . $uppath . "\" class=\"button\">" . $this->_Translation->GetTranslation('directory_up') . "</a>\n\t\t\t\t</div>";
        }
        $out .= "\n\t\t\t<table id=\"files\" class=\"text_table full_width\">\n\t\t\t\t<thead>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th>\n\t\t\t\t\t\t\t" . $this->_Translation->GetTranslation('preview') . "\n\t\t\t\t\t\t</th>\n\t\t\t\t\t\t<th>\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;order=filename#files\" title=\"" . @sprintf($this->_Translation->GetTranslation('sort_ascending_by_%name%'), $this->_Translation->GetTranslation('filename')) . "\"><img alt=\"[" . @sprintf($this->_Translation->GetTranslation('sort_ascending_by_%name%'), $this->_Translation->GetTranslation('filename')) . "]\" src=\"img/up.png\"/></a>\n\t\t\t\t\t\t\t" . $this->_Translation->GetTranslation('filename') . "\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;order=filename&amp;desc=1#files\" title=\"" . @sprintf($this->_Translation->GetTranslation('sort_descending_by_%name%'), $this->_Translation->GetTranslation('filename')) . "\"><img alt=\"[" . @sprintf($this->_Translation->GetTranslation('sort_descending_by_%name%'), $this->_Translation->GetTranslation('filename')) . "]\" src=\"img/down.png\"/></a>\n\t\t\t\t\t\t</th>\n\t\t\t\t\t\t<th class=\"small_width\">\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;order=filesize#files\" title=\"" . sprintf($this->_Translation->GetTranslation('sort_ascending_by_%name%'), $this->_Translation->GetTranslation('filesize')) . "\"><img alt=\"[" . sprintf($this->_Translation->GetTranslation('sort_ascending_by_%name%'), $this->_Translation->GetTranslation('filesize')) . "]\" src=\"img/up.png\"/></a>\n\t\t\t\t\t\t\t" . $this->_Translation->GetTranslation('filesize') . "\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;order=filesize&amp;desc=1#files\" title=\"" . sprintf($this->_Translation->GetTranslation('sort_descending_by_%name%'), $this->_Translation->GetTranslation('filesize')) . "\"><img alt=\"[" . sprintf($this->_Translation->GetTranslation('sort_descending_by_%name%'), $this->_Translation->GetTranslation('filesize')) . "]\" src=\"img/down.png\"/></a>\n\t\t\t\t\t\t</th>\n\t\t\t\t\t\t<th class=\"table_date_width_plus\">\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;order=filedate#files\" title=\"" . sprintf($this->_Translation->GetTranslation('sort_ascending_by_%name%'), $this->_Translation->GetTranslation('date')) . "\"><img alt=\"[" . sprintf($this->_Translation->GetTranslation('sort_ascending_by_%name%'), $this->_Translation->GetTranslation('date')) . "]\" src=\"img/up.png\"/></a>\n\t\t\t\t\t\t\t" . $this->_Translation->GetTranslation('uploaded_on') . "\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;order=filedate&amp;desc=1#files\" title=\"" . sprintf($this->_Translation->GetTranslation('sort_descending_by_%name%'), $this->_Translation->GetTranslation('date')) . "\"><img alt=\"[" . sprintf($this->_Translation->GetTranslation('sort_descending_by_%name%'), $this->_Translation->GetTranslation('date')) . "]\" src=\"img/down.png\"/></a>\n\t\t\t\t\t\t</th>\n\t\t\t\t\t\t<th class=\"small_width\">\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;order=filetype#files\" title=\"" . sprintf($this->_Translation->GetTranslation('sort_ascending_by_%name%'), $this->_Translation->GetTranslation('filetype')) . "\"><img alt=\"[" . sprintf($this->_Translation->GetTranslation('sort_ascending_by_%name%'), $this->_Translation->GetTranslation('filetype')) . "]\" src=\"img/up.png\"/></a>\n\t\t\t\t\t\t\t" . $this->_Translation->GetTranslation('filetype') . "\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;order=filetype&amp;desc=1#files\" title=\"" . sprintf($this->_Translation->GetTranslation('sort_descending_by_%name%'), $this->_Translation->GetTranslation('filetype')) . "\"><img alt=\"[" . sprintf($this->_Translation->GetTranslation('sort_descending_by_%name%'), $this->_Translation->GetTranslation('filetype')) . "]\" src=\"img/down.png\"/></a>\n\t\t\t\t\t\t</th>\n\t\t\t\t\t\t<th class=\"table_mini_width\">\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;order=filedownloads#files\" title=\"" . sprintf($this->_Translation->GetTranslation('sort_ascending_by_%name%'), $this->_Translation->GetTranslation('downloads')) . "\"><img alt=\"[" . sprintf($this->_Translation->GetTranslation('sort_ascending_by_%name%'), $this->_Translation->GetTranslation('downloads')) . "]\" src=\"img/up.png\"/></a>\n\t\t\t\t\t\t\t<abbr title=\"" . $this->_Translation->GetTranslation('downloads') . "\">" . $this->_Translation->GetTranslation('downl') . "</abbr>\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;order=filedownloads&amp;desc=1#files\" title=\"" . sprintf($this->_Translation->GetTranslation('sort_descending_by_%name%'), $this->_Translation->GetTranslation('downloads')) . "\"><img alt=\"[" . sprintf($this->_Translation->GetTranslation('sort_descending_by_%name%'), $this->_Translation->GetTranslation('downloads')) . "]\" src=\"img/down.png\"/></a>\n\t\t\t\t\t\t</th>\n\t\t\t\t\t\t<th class=\"actions\">" . $this->_Translation->GetTranslation('actions') . "</th>\n\t\t\t\t\t</tr>\n\t\t\t\t</thead>\n\t\t\t\t\r\n";
        $dateDayFormat = $this->_Config->Get('date_day_format', 'd.m.Y');
        $dateTimeFormat = $this->_Config->Get('date_time_format', 'H:i:s');
        $dateFormat = $dateDayFormat . ' ' . $dateTimeFormat;
        $thumbnailfolder = $this->_Config->Get('thumbnailfolder', 'data/thumbnails/');
        $files = new Files($this->_SqlConnection, $this->_User);
        $order = FILES_NAME;
        $ascending = true;
        $orderByGet = GetPostOrGet('order');
        $desc = GetPostOrGet('desc');
        switch ($orderByGet) {
            case 'filesize':
                $order = FILES_SIZE;
                break;
            case 'filedate':
                $order = FILES_DATE;
                break;
            case 'filetype':
                $order = FILES_TYPE;
                break;
            case 'filedownloads':
                $order = FILES_DOWNLOADS;
                break;
            case 'filename':
            default:
                $order = FILES_NAME;
                break;
        }
        // descending or ascending?
        if ($desc == 1) {
            $ascending = false;
        }
        // get all files from the database/ which are registered in the database
        $filesArrayTmp = $files->FillArray($order, $ascending);
        //print str_replace('  ','&nbsp;&nbsp;',nl2br(print_r($fileArray, true)));
        //die();
        $filesCount = count($filesArrayTmp);
        $filesArray = array();
        for ($i = 0; $i < $filesCount; $i++) {
            $fileArray = $filesArrayTmp[$i];
            if (substr($fileArray['FILE_NAME'], 0, $pathLen) == $path && strlen($fileArray['FILE_NAME']) > $pathLen && !strpos($fileArray['FILE_NAME'], '/', $pathLen + 1)) {
                $fileArray['FILE_SIZE'] = kbormb($fileArray['FILE_SIZE']);
                $fileArray['FILE_DATE'] = date($dateFormat, $fileArray['FILE_DATE']);
                $fileArray['FILE_DOWNLOAD_FILE'] = sprintf($this->_Translation->GetTranslation('download_file_%file%'), $fileArray['FILE_NAME']);
                $fileArray['FILE_DELETE_FILE'] = sprintf($this->_Translation->GetTranslation('delete_file_%file%'), $fileArray['FILE_NAME']);
                $fileArray['FILE_MOVE_FILE'] = sprintf($this->_Translation->GetTranslation('move_file_%file%'), $fileArray['FILE_NAME']);
                $preview = '';
                if (strpos($fileArray['FILE_TYPE'], 'image/') === 0) {
                    $image = new ImageConverter($fileArray['FILE_PATH']);
                    // max: 100px;
                    $maximum = 100;
                    $size = $image->CalcSizeByMax($maximum);
                    $imageUrl = $image->SaveResizedTo($size[0], $size[1], $thumbnailfolder, $size[0] . 'x' . $size[1] . '_');
                    if (file_exists($imageUrl)) {
                        $preview = "<img alt=\"{$fileArray['FILE_NAME']}\" src=\"" . generateUrl($imageUrl) . "\" />";
                    }
                }
                $fileArray['FILE_PREVIEW'] = $preview;
                if ($pathLen > 0) {
                    $fileArray['FILE_NAME'] = substr($fileArray['FILE_NAME'], $pathLen + 1);
                }
                if ($fileArray['FILE_TYPE'] == 'dir') {
                    $det = $pathLen > 0 ? '/' : '';
                    $fileArray['FILE_NAME'] = '<a href="admin.php?page=files&amp;path=' . $path . $det . $fileArray['FILE_NAME'] . '">' . $fileArray['FILE_NAME'] . '</a>';
                }
                $fileArray['FILE_ACTION'] = '';
                if ($fileArray['FILE_TYPE'] != 'dir') {
                    $file_id = $fileArray['FILE_ID'];
                    $fileArray['FILE_ACTION'] .= '<a href="download.php?file_id=' . $file_id . '" ><img src="img/download.png" alt="[' . $fileArray['FILE_DOWNLOAD_FILE'] . ']" title="' . $fileArray['FILE_DOWNLOAD_FILE'] . '"/></a>';
                    $fileArray['FILE_ACTION'] .= '<a href="admin.php?page=files&amp;action=move&amp;file_id=' . $file_id . '" ><img src="img/restore.png" alt="[' . $fileArray['FILE_MOVE_FILE'] . ']" title="' . $fileArray['FILE_MOVE_FILE'] . '"/></a>';
                }
                $filesArray[] = $fileArray;
            }
        }
        $this->_ComaLate->SetReplacement('FILES', $filesArray);
        $this->_ComaLate->SetReplacement('SIZE_COUNT', kbormb($files->SizeCount));
        $this->_ComaLate->SetReplacement('LANG_ALTOGETHER', $this->_Translation->GetTranslation('altogether'));
        $out .= '<FILES:loop>
					<tr>
						<td>{FILE_PREVIEW}</td>
						<td>{FILE_NAME}</td>
						<td>{FILE_SIZE}</td>
						<td>{FILE_DATE}</td>
						<td>{FILE_TYPE}</td>
						<td>{FILE_DOWNLOADS}</td>
						<td>{FILE_ACTION}
						<a href="admin.php?page=files&amp;action=delete&amp;file_id={FILE_ID}" ><img src="img/del.png" alt="[{FILE_DELETE_FILE}]" title="{FILE_DELETE_FILE}" /></a></td>
					</tr>
					</FILES>
				</table>
				{LANG_ALTOGETHER} {SIZE_COUNT}';
        return $out;
    }
 /**
  * @access private
  * @return sring
  */
 function _setImage($article_id)
 {
     if (!is_numeric($article_id)) {
         return $this->_homePage();
     }
     $sql = "SELECT *\r\n\t\t\t\tFROM " . DB_PREFIX . "articles\r\n\t\t\t\tWHERE article_id={$article_id}";
     $article_result = $this->_SqlConnection->SqlQuery($sql);
     if ($article = mysql_fetch_object($article_result)) {
         $out = '';
         $sql = "SELECT file_path\r\n\t\t\t\t\tFROM " . DB_PREFIX . "files\r\n\t\t\t\t\tWHERE file_type LIKE 'image/%'\r\n\t\t\t\t\tORDER BY file_name ASC";
         $images_result = $this->_SqlConnection->SqlQuery($sql);
         $imgmax = 100;
         $imgmax2 = 100;
         $thumbnailfolder = 'data/thumbnails/';
         $out .= "<form action=\"admin.php\" method=\"post\"><div class=\"imagesblock\">\r\n\t\t\t\t<input type=\"hidden\" name=\"page\" value=\"module_articles\"/>\r\n\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"saveImage\"/>\r\n\t\t\t\t<input type=\"hidden\" name=\"article_id\" value=\"{$article_id}\"/>";
         while ($imageData = mysql_fetch_object($images_result)) {
             $imageUrl = $imageData->file_path;
             if (file_exists($imageUrl)) {
                 $image = new ImageConverter($imageUrl);
                 $size = $image->CalcSizeByMax($imgmax);
                 $resizedFileName = $thumbnailfolder . '/' . $size[0] . 'x' . $size[1] . '_' . basename($imageUrl);
                 if (!file_exists($resizedFileName)) {
                     $resizedFileName = $image->SaveResizedTo($size[0], $size[1], $thumbnailfolder, $size[0] . 'x' . $size[1] . '_');
                 }
                 if (file_exists($resizedFileName) && $resizedFileName !== false) {
                     $margin_top = round(($imgmax - $size[1]) / 2);
                     $margin_bottom = $imgmax - $size[1] - $margin_top;
                     $out .= "<div class=\"imageblock\">\r\n\t\t\t\t\t\t\t<a href=\"" . generateUrl($resizedFileName) . "\">\r\n\t\t\t\t\t\t\t<img style=\"margin-top:" . $margin_top . "px;margin-bottom:" . $margin_bottom . "px;width:" . $size[0] . "px;height:" . $size[1] . "px;\" src=\"" . generateUrl($resizedFileName) . "\" alt=\"" . basename($imageData->file_path) . "\" /></a><br />\r\n\t\t\t\t\t\t<input type=\"radio\" name=\"image_path\" " . ($article->article_image == $imageData->file_path ? 'checked="checked" ' : '') . " value=\"" . $imageData->file_path . "\"/></div>";
                 }
             }
         }
         $out .= "</div><input type=\"submit\" value=\"" . $this->_Translation->GetTranslation('apply') . "\" class=\"button\"/><a href=\"admin.php?page=module_articles&amp;action=edit&amp;article_id={$article_id}\" class=\"button\">" . $this->_Translation->GetTranslation('back') . "</a></form>";
         return $out;
     }
 }
 /**
  * FormHandler::_handleUploads()
  *
  * Private: method to handle the uploads and image convertions
  *
  * @return void
  * @access public
  * @author Teye Heimans
  */
 function _handleUploads()
 {
     // upload the uploaded files
     foreach ($this->_upload as $name) {
         $this->_fields[$name][1]->doUpload();
     }
     // walk all convert actions for the upload fields
     foreach ($this->_convert as $field => $convertions) {
         // walk all convertions for this field
         foreach ($convertions as $action => $data) {
             // check if the field is an upload field and that there is a file uploaded
             if (in_array($field, $this->_upload)) {
                 // is the file uploaded ?
                 if ($this->_fields[$field][1]->isUploaded()) {
                     // get the file which is uploaded
                     $file = $this->_fields[$field][1]->getSavePath() . $this->_fields[$field][1]->getValue();
                     // check if the file exitst
                     if (!file_exists($file)) {
                         trigger_error("Error! Could not find uploaded file {$file}!", E_USER_WARNING);
                         unset($file);
                         continue;
                     }
                 } else {
                     // go to the next field
                     continue 2;
                 }
             } else {
                 if (file_exists($field)) {
                     $file = $field;
                     // unknown field or file!
                 } else {
                     trigger_error('Could not find field or file to convert: ' . $field, E_USER_WARNING);
                     continue;
                 }
             }
             // do the convert actions with the image (when the uploaded file is a jpg or png!)
             if (isset($file) && in_array(strtolower(substr($file, -4)), array('.jpg', '.png', 'jpeg', '.gif'))) {
                 // create a new image converter
                 $img = new ImageConverter($file);
                 // stop when a error occoured
                 if ($img->getError()) {
                     trigger_error($img->getError(), E_USER_WARNING);
                     unset($img);
                     continue;
                 }
                 // walk each data (there can be more of the save convertions on the save file!)
                 foreach ($data as $info) {
                     // check if an error occured
                     if ($img->getError()) {
                         // stop converting and notice the user
                         trigger_error($img->getError(), E_USER_WARNING);
                         break;
                     }
                     switch ($action) {
                         // merge the uploaded file with a merge image
                         case 'merge':
                             list($stamp, $align, $valign, $transparant) = $info;
                             $img->doMerge($stamp, $align, $valign, $transparant);
                             break;
                             // resize the uploaded file
                         // resize the uploaded file
                         case 'resize':
                             list($destination, $maxX, $maxY, $quality, $proportions) = $info;
                             if (empty($destination)) {
                                 $destination = $file;
                             }
                             $img->setQuality($quality);
                             $img->setConstrainProportions($proportions);
                             $img->doResize($destination, $maxX, $maxY);
                             break;
                     }
                 }
                 unset($img);
             }
             unset($file);
         }
     }
 }
 /**
  *
  * Returns a Binary string representing the PBI file.
  * @param $showtimeId
  * @return null|string binary string
  */
 public function getRawQrCode($showtimeId)
 {
     $cached = $this->checkCache($showtimeId);
     if ($cached) {
         return file_get_contents($cached);
     }
     $filename = $this->getPNGQrCode($showtimeId);
     if ($filename) {
         $converter = new \ImageConverter($filename);
         $cacheFile = $this->cacheName($showtimeId);
         if ($converter->convertToPbi($cacheFile)) {
             return file_get_contents($cacheFile);
         }
     }
     return null;
 }
    function _EditPageOverview($PageID)
    {
        if (!is_numeric($PageID)) {
            return false;
        }
        $this->_ComaLate->SetReplacement('LANG_TITLE', $this->_Translation->GetTranslation('title'));
        $this->_ComaLate->SetReplacement('LANG_EDIT_GALLERY', $this->_Translation->GetTranslation('edit_gallery'));
        $this->_ComaLate->SetReplacement('LANG_TITLE_INFO', $this->_Translation->GetTranslation('the_title_is_someting_like_a_headline_of_the_page'));
        $this->_ComaLate->SetReplacement('LANG_APPLY', $this->_Translation->GetTranslation('apply'));
        $this->_ComaLate->SetReplacement('LANG_BACK', $this->_Translation->GetTranslation('back'));
        $this->_ComaLate->SetReplacement('LANG_REGENERATE_THUMBNAILS', $this->_Translation->GetTranslation('regenerate_thumbnails'));
        $this->_ComaLate->SetReplacement('LANG_ADD_IMAGES', $this->_Translation->GetTranslation('add_images'));
        $this->_ComaLate->SetReplacement('LANG_GALLERY', $this->_Translation->GetTranslation('gallery'));
        $this->_ComaLate->SetReplacement('LANG_IMAGE', $this->_Translation->GetTranslation('image'));
        $this->_ComaLate->SetReplacement('PAGE_ID', $PageID);
        $this->_ComaLate->SetReplacement('LANG_MOVE_UP', $this->_Translation->GetTranslation('move_up'));
        $this->_ComaLate->SetReplacement('LANG_MOVE_DOWN', $this->_Translation->GetTranslation('move_down'));
        $this->_ComaLate->SetReplacement('LANG_EDIT', $this->_Translation->GetTranslation('edit'));
        $this->_ComaLate->SetReplacement('LANG_DELETE', $this->_Translation->GetTranslation('delete'));
        // Load the images of the gallery with file-information
        $sql = 'SELECT gallery.gallery_file_id, gallery.gallery_image, gallery.gallery_description, gallery.gallery_image_thumbnail, page.page_title
					FROM (
						(' . DB_PREFIX . 'pages page
						LEFT JOIN ' . DB_PREFIX . 'pages_gallery gallery_page
						ON page.page_id = gallery_page.page_id)
					LEFT JOIN ' . DB_PREFIX . 'gallery gallery
					ON gallery_page.gallery_id =gallery.gallery_id)
					WHERE page.page_id=' . $PageID . '
					ORDER BY gallery.gallery_orderid';
        $imagesResult = $this->_SqlConnection->SqlQuery($sql);
        $images = array();
        $imgmax = 100;
        $imageID = 0;
        $title = '';
        $thumbnailfolder = $this->_Config->Get('thumbnailfolder', 'data/thumbnails/');
        while ($image = mysql_fetch_object($imagesResult)) {
            if ($title == '') {
                $title = $image->page_title;
            }
            $imageResizer = new ImageConverter($image->gallery_image);
            $sizes = $imageResizer->CalcSizeByMax($imgmax);
            $gif = '';
            if (substr($image->gallery_image, -4) == '.gif') {
                $gif = '.png';
            }
            $prefix = $sizes[0] . 'x' . $sizes[1] . '_';
            $fileName = $imageUrl = $thumbnailfolder . '/' . $prefix . basename($image->gallery_image . $gif);
            if (!file_exists($fileName)) {
                $fileName = $imageResizer->SaveResizedTo($sizes[0], $sizes[1], $thumbnailfolder, $prefix);
            }
            $marginTop = round(($imgmax - $sizes[1]) / 2);
            $marginBottom = $imgmax - $sizes[1] - $marginTop;
            if (file_exists($fileName)) {
                $images[] = array('IMAGE_TITLE' => $image->gallery_description, 'IMAGE_MARGIN_TOP' => $marginTop, 'IMAGE_MARGIN_BOTTOM' => $marginBottom, 'IMAGE_ID' => $imageID++, 'IMAGE_WIDTH' => $sizes[0], 'IMAGE_HEIGHT' => $sizes[1], 'IMAGE_SRC' => generateUrl($fileName), 'IMAGE_FILE_ID' => $image->gallery_file_id);
            }
        }
        $this->_ComaLate->SetReplacement('IMAGES', $images);
        $this->_ComaLate->SetReplacement('PAGE_TITLE', $title);
        $template = '<fieldset>
 					<legend>{LANG_EDIT_GALLERY}</legend>
 					<form action="{ADMIN_FORM_URL}" method="post">
						<input type="hidden" name="{ADMIN_FORM_PAGE}" value="pagestructure" />
						<input type="hidden" name="action" value="editPage" />
						<input type="hidden" name="action2" value="saveTitle" />
						<input type="hidden" name="pageID" value="{PAGE_ID}" />
						<div class="row">
 							<label class="row" for="pageTitle">
 								<strong>{LANG_TITLE}:</strong>
 								<span class="info">{LANG_TITLE_INFO}</span>
 							</label>
 							<input type="text" name="pageTitle" id="pageTitle" value="{PAGE_TITLE}" />
 						</div>
 						<div class="row">
							<input type="submit" value="{LANG_APPLY}" class="button" />
						</div>
					</form>
					<div class="row">
						<a href="{ADMIN_LINK_URL}page=pagestructure&amp;action=editPage&amp;action2=addNewImageDialog&amp;pageID={PAGE_ID}" class="button">{LANG_ADD_IMAGES}</a>
						<a href="{ADMIN_LINK_URL}page=pagestructure&amp;action=editPage&amp;action2=regenerateThumbnails&amp;pageID={PAGE_ID}" class="button">{LANG_REGENERATE_THUMBNAILS}</a>
						<a href="{ADMIN_LINK_URL}page=pagestructure" class="button">{LANG_BACK}</a>
					</div>
					<div class="row">
 					
 					<IMAGES:loop>
					<div class="imageblock">
						<a href="index.php?page={PAGE_ID}&amp;imageID={IMAGE_ID}">
							<img style="margin-top:{IMAGE_MARGIN_TOP}px;margin-bottom:{IMAGE_MARGIN_BOTTOM}px;width:{IMAGE_WIDTH}px;height:{IMAGE_HEIGHT}px;" src="{IMAGE_SRC}" alt="{LANG_IMAGE}: {IMAGE_TITLE}" title="{IMAGE_TITLE}" />
						</a>
						<div class="actions">
						<a href="{ADMIN_LINK_URL}page=pagestructure&amp;action=editPage&amp;pageID={PAGE_ID}&amp;action2=moveImageUp&amp;imageID={IMAGE_FILE_ID}"><img src="./img/up.png" alt="{LANG_MOVE_UP}" title="{LANG_MOVE_UP}"/></a>
						<a href="{ADMIN_LINK_URL}page=pagestructure&amp;action=editPage&amp;pageID={PAGE_ID}&amp;action2=editImage&amp;imageID={IMAGE_FILE_ID}"><img src="./img/edit.png" alt="{LANG_EDIT}" title="{LANG_EDIT}"/></a>
						<a href="{ADMIN_LINK_URL}page=pagestructure&amp;action=editPage&amp;pageID={PAGE_ID}&amp;action2=removeImage&amp;imageID={IMAGE_FILE_ID}"><img src="./img/del.png" alt="{LANG_DELETE}" title="{LANG_DELETE}"/></a>
						<a href="{ADMIN_LINK_URL}page=pagestructure&amp;action=editPage&amp;pageID={PAGE_ID}&amp;action2=moveImageDown&amp;imageID={IMAGE_FILE_ID}"><img src="./img/down.png" alt="{LANG_MOVE_DOWN}" title="{LANG_MOVE_DOWN}"/></a>
						</div>
					</div>
					</IMAGES>
					</div>
 					
 					</fieldset>';
        return $template;
    }
    function LoadImagePage($PageID, $ImageID)
    {
        if (!is_numeric($PageID) || !is_numeric($ImageID)) {
            return false;
        }
        $sql = 'SELECT gallery.gallery_description, gallery.gallery_image, page.page_title
					FROM (
						(' . DB_PREFIX . 'pages page
						LEFT JOIN ' . DB_PREFIX . 'pages_gallery gallery_page
						ON page.page_id = gallery_page.page_id)
					LEFT JOIN ' . DB_PREFIX . 'gallery gallery
					ON gallery_page.gallery_id =gallery.gallery_id)
					WHERE page.page_id=' . $PageID . '
					ORDER BY gallery.gallery_orderid
					LIMIT ' . $ImageID . ',2';
        // we have to check if there is a second one;
        $imageResult = $this->_SqlConnection->SqlQuery($sql);
        if ($image = mysql_fetch_object($imageResult)) {
            $this->_ComaLate->SetReplacement('LANG_IMAGE_OF', $this->_Translation->GetTranslation('image_of'));
            $this->_ComaLate->SetReplacement('LANG_IMAGE', $this->_Translation->GetTranslation('image'));
            $this->_ComaLate->SetReplacement('PAGE_ID', $PageID);
            $this->_ComaLate->SetReplacement('LANG_UP', $this->_Translation->GetTranslation('up'));
            $this->_ComaLate->SetReplacement('PAGE_TITLE', $image->page_title);
            $this->_ComaLate->SetReplacement('IMAGE_DESCRIPTION', $image->gallery_description);
            if ($ImageID > 0) {
                $this->_ComaLate->SetReplacement('LAST_IMAGE_ID', $ImageID - 1);
                $this->_ComaLate->SetReplacement('LANG_PREVIOUS', $this->_Translation->GetTranslation('previous_image'));
                $this->_ComaLate->SetCondition('imageBack');
            }
            $thumbnailFoler = $this->_Config->Get('thumbnailfolder', 'data/thumbnails/');
            $imageReszier = new ImageConverter($image->gallery_image);
            $sizes = $imageReszier->CalcSizeByMax(600);
            $imageUrl = $image->gallery_image;
            if ($sizes[0] < $imageReszier->Size[0] && $sizes[1] < $imageReszier->Size[1]) {
                $imageUrl = $imageReszier->SaveResizedTo($sizes[0], $sizes[1], $thumbnailFoler, $sizes[0] . 'x' . $sizes[1] . '_');
            }
            $imageSrc = generateUrl($imageUrl);
            if (file_exists($imageUrl)) {
                $sizes = getimagesize($imageUrl);
                $this->_ComaLate->SetReplacement('IMAGE_WIDTH', $sizes[0]);
                $this->_ComaLate->SetReplacement('IMAGE_HEIGHT', $sizes[1]);
                $this->_ComaLate->SetReplacement('IMAGE_WIDTH+4', $sizes[0] + 4);
                $this->_ComaLate->SetReplacement('IMAGE_SRC', $imageSrc);
            }
        } else {
            return false;
        }
        if ($image = mysql_fetch_object($imageResult)) {
            $this->_ComaLate->SetReplacement('NEXT_IMAGE_ID', $ImageID + 1);
            $this->_ComaLate->SetReplacement('LANG_NEXT', $this->_Translation->GetTranslation('next_image'));
            $this->_ComaLate->SetCondition('imageNext');
        }
        $this->HTML = '<h2>{LANG_IMAGE_OF} {PAGE_TITLE}</h2>
			<div class="imagebox">
				<div class="imagelinks">
					<imageBack:condition><a class="imagemove" href="index.php?page={PAGE_ID}&amp;imageID={LAST_IMAGE_ID}"><img alt="{LANG_PREVIOUS}" title="{LANG_PREVIOUS}" src="img/previous.png" /></a></imageBack>
					<a class="imagemove" href="index.php?page={PAGE_ID}"><img alt="{LANG_UP}" title="{LANG_UP}" src="img/up.png" /></a>
					<imageNext:condition><a class="imagemove" href="index.php?page={PAGE_ID}&amp;imageID={NEXT_IMAGE_ID}" ><img alt="{LANG_NEXT}" title="{LANG_NEXT}" src="img/next.png" /></a></imageNext>
				</div>
				<div class="gallery_image_detail">
				<div class="thumb tcenter">
						<div style="width:{IMAGE_WIDTH+4}px">
							<img width="{IMAGE_WIDTH}" height="{IMAGE_HEIGHT}" src="{IMAGE_SRC}" title="{IMAGE_DESCRIPTION}" alt="{LANG_IMAGE}: {IMAGE_DESCRIPTION}" />
							<div class="description" title="{IMAGE_DESCRIPTION}">{IMAGE_DESCRIPTION}</div>
						</div>
					</div></div>
				<div class="imagelinks">
					<imageBack:condition><a class="imagemove" href="index.php?page={PAGE_ID}&amp;imageID={LAST_IMAGE_ID}"><img alt="{LANG_PREVIOUS}" title="{LANG_PREVIOUS}" src="img/previous.png" /></a></imageBack>
					<a class="imagemove" href="index.php?page={PAGE_ID}"><img alt="{LANG_UP}" title="{LANG_UP}" src="img/up.png" /></a>
					<imageNext:condition><a class="imagemove" href="index.php?page={PAGE_ID}&amp;imageID={NEXT_IMAGE_ID}" ><img alt="{LANG_NEXT}" title="{LANG_NEXT}" src="img/next.png" /></a></imageNext>
				</div>
					</div>';
        if ($ImageID >= 0) {
            $this->HTML .= '';
        }
    }
Example #12
0
 public function getPreviewImageUrl($maxWidth = 1000, $maxHeight = 1000)
 {
     $prefix = 'pi_' . $maxWidth . "x" . $maxHeight;
     // already generated
     if (is_file($this->getPath($prefix))) {
         return $this->getUrl($prefix);
     }
     if ($this->getMimeBaseType() != "image") {
         return "";
     }
     if (!is_file($this->getPath())) {
         return "";
     }
     $imageInfo = getimagesize($this->getPath());
     // Check if we got any dimensions
     if (!isset($imageInfo[0]) || !isset($imageInfo[1])) {
         return "";
     }
     // Check if image type is supported
     if ($imageInfo[2] != IMAGETYPE_PNG && $imageInfo[2] != IMAGETYPE_JPEG && $imageInfo[2] != IMAGETYPE_GIF) {
         return "";
     }
     ImageConverter::Resize($this->getPath(), $this->getPath($prefix), array('mode' => 'max', 'width' => $maxWidth, 'height' => $maxHeight));
     return $this->getUrl($prefix);
 }
 /**
  * @access private
  * @return string
  */
 function _InlineMenuHomePage($PageID)
 {
     $image = 'Noch kein Bild gesetzt';
     $thumbPath = $this->_PageStructure->GetInlineMenuData($PageID, 'imageThumb');
     $imagePath = $this->_PageStructure->GetInlineMenuData($PageID, 'image');
     $imageTitle = $this->_PageStructure->GetInlineMenuData($PageID, 'imageTitle');
     if (file_exists($thumbPath)) {
         $image = "<img alt=\"{$imageTitle}\" src=\"" . generateUrl($thumbPath) . "\"/>";
     } else {
         if (file_exists($imagePath)) {
             // maximum width
             $imgmax2 = 200;
             // if it isn't "wide" enough
             $imgmax3 = 350;
             $inlinemenuFolder = 'data/thumbnails/';
             $imageResizer = new ImageConverter($imagePath);
             $sizes = array();
             // it is "wide" enough??
             if ($imageResizer->Size[0] > $imgmax2) {
                 $sizes = $imageResizer->CalcSizeByMaxWidth($imgmax2);
             } else {
                 if ($imageResizer->Size[1] > $imgmax3) {
                     $sizes = $imageResizer->CalcSizeByMax($imgmax2);
                 }
             }
             $thumbnail = $imagePath;
             // is there something to resize?
             if (count($sizes) == 2) {
                 $thumbnail = $imageResizer->SaveResizedTo($sizes[0], $sizes[1], $inlinemenuFolder, $sizes[0] . 'x' . $sizes[1] . '_');
             }
             if ($thumbnail !== false) {
                 $image = "<img alt=\"{$imageTitle}\" src=\"" . generateUrl($thumbnail) . "\"/>";
             }
         }
     }
     $out = "\r\n\t\t\t\t<fieldset>\r\n\t\t\t\t\t<legend>" . $this->_Translation->GetTranslation('inlinemenu') . "</legend>\r\n\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t\t<label class=\"row\">\r\n\t\t\t\t\t\t\t" . $this->_Translation->GetTranslation('inlinemenu_image') . ":\r\n\t\t\t\t\t\t\t<span class=\"info\">Das ist der Pfad zu dem Bild, das dem Zusatzmen&uuml; zugeordnet wird, es kann der Einfachheit halber aus den bereits hochgeladenen Bildern ausgew&auml;hlt werden.</span>\r\n\t\t\t\t\t\t</label>\r\n\t\t\t\t\t\t{$image}\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t<a href=\"{$this->LinkUrl}page=pagestructure&amp;action=pageInlineMenu&amp;pageID={$PageID}&amp;action2=selectImage\" class=\"button\">Bild ausw&auml;hlen/ver&auml;ndern</a>\r\n\t\t\t\t\t" . (file_exists($thumbPath) ? "<a href=\"{$this->LinkUrl}page=pagestructure&amp;action=pageInlineMenu&amp;pageID={$PageID}&amp;action2=removeImage\" class=\"button\">Bild entfernen</a>" : '') . "\r\n\t\t\t\t</div>\r\n\t\t\t\t<form action=\"{$this->FormUrl}\" method=\"post\">\r\n\t\t\t\t<input type=\"hidden\" name=\"{$this->FormPage}\" value=\"pagestructure\" />\r\n\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"pageInlineMenu\" />\r\n\t\t\t\t<input type=\"hidden\" name=\"pageID\" value=\"{$PageID}\" />\r\n\t\t\t\t<input type=\"hidden\" name=\"action2\" value=\"setImageTitle\" />\r\n\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t<label for=\"inlinemenuThumbTitle\"class=\"row\">\r\n\t\t\t\t\t\tBildunterschrift:\r\n\t\t\t\t\t\t<span class=\"info\">Die Bildunterschrift kann das Bild noch ein wenig erl&auml;utern.</span>\r\n\t\t\t\t\t</label>\r\n\t\t\t\t\t<input id=\"inlinemenuThumbTitle\" name=\"imageTitle\" type=\"text\" value=\"{$imageTitle}\" />\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t<input type=\"submit\" class=\"button\" value=\"" . $this->_Translation->GetTranslation('save') . "\" />\r\n\t\t\t\t</div>\r\n\t\t\t\t</form>";
     $sql = "SELECT *\r\n\t\t\t\tFROM " . DB_PREFIX . "inlinemenu_entries\r\n\t\t\t\tWHERE inlineentry_page_id = {$PageID}\r\n\t\t\t\tORDER BY inlineentry_sortid ASC";
     $entries_result = $this->_SqlConnection->SqlQuery($sql);
     $out .= "<h3 id=\"entries\">Eintr&auml;ge</h3>\r\n\t\t\t\t<div class=\"row\"><table class=\"text_table full_width\">\r\n\t\t\t\t\t<thead><tr><th>Text</th><th class=\"small_width\">Typ</th><th class=\"actions\">Aktion</th></tr></thead>";
     while ($entry = mysql_fetch_object($entries_result)) {
         $typeImage = '';
         switch ($entry->inlineentry_type) {
             case 'download':
                 $typeImage = "<img alt=\"\" src=\"img/download.png\"/>Download";
                 break;
             case 'link':
                 $typeImage = "<img alt=\"\" src=\"img/extern.png\"/>Externer-Link";
                 break;
             case 'intern':
                 $typeImage = "<img alt=\"\" src=\"img/view.png\"/>Interner-Link";
                 break;
             default:
                 $typeImage = "Text";
                 break;
         }
         $out .= "<tr>\r\n\t\t\t\t\t<td>" . nl2br($entry->inlineentry_text) . "</td>\r\n\t\t\t\t\t<td>" . $typeImage . "</td>\r\n\t\t\t\t\t<td>\r\n\t\t\t\t\t\t<a href=\"{$this->LinkUrl}page=pagestructure&amp;action=pageInlineMenu&amp;pageID={$PageID}&amp;entrySortID={$entry->inlineentry_sortid}&amp;action2=moveEntryUp#entries\"><img src=\"./img/up.png\" alt=\"" . $this->_Translation->GetTranslation('move_up') . "\" title=\"" . $this->_Translation->GetTranslation('move_up') . "\" /></a>\r\n\t\t\t\t\t\t<a href=\"{$this->LinkUrl}page=pagestructure&amp;action=pageInlineMenu&amp;pageID={$PageID}&amp;entrySortID={$entry->inlineentry_sortid}&amp;action2=moveEntryDown#entries\"><img src=\"./img/down.png\" alt=\"" . $this->_Translation->GetTranslation('move_down') . "\" title=\"" . $this->_Translation->GetTranslation('move_down') . "\" /></a>\r\n\t\t\t\t\t\t<a href=\"{$this->LinkUrl}page=pagestructure&amp;action=pageInlineMenu&amp;pageID={$PageID}&amp;entryID={$entry->inlineentry_id}&amp;action2=editEntry\"><img src=\"./img/edit.png\" alt=\"" . $this->_Translation->GetTranslation('edit') . "\" title=\"" . $this->_Translation->GetTranslation('edit') . "\" /></a>\r\n\t\t\t\t\t\t<a href=\"{$this->LinkUrl}page=pagestructure&amp;action=pageInlineMenu&amp;pageID={$PageID}&amp;entryID={$entry->inlineentry_id}&amp;action2=removeEntry\"><img src=\"./img/del.png\" alt=\"" . $this->_Translation->GetTranslation('delete') . "\" title=\"" . $this->_Translation->GetTranslation('delete') . "\" /></a>\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t</td>\r\n\t\t\t\t\t</tr>";
     }
     $out .= "</table>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div class=\"row\"><a href=\"{$this->LinkUrl}page=pagestructure&amp;action=pageInlineMenu&amp;pageID={$PageID}&amp;action2=addNewEntryDialog\" class=\"button\">Einen Eintrag hinzuf&uuml;gen</a></div>\r\n\t\t\t\t\t</fieldset>";
     return $out;
 }
    function _OverviewPage()
    {
        $sql = "SELECT *\r\n\t\t\t\tFROM " . DB_PREFIX . "articles\r\n\t\t\t\tORDER BY article_date DESC";
        $articlesResult = $this->_SqlConnection->SqlQuery($sql);
        $imgMax = 120;
        $thumbnailFolder = $this->_Config->Get('thumbnailfolder', 'data/thumbnails/');
        $dateFormat = $this->_Config->Get('articles_date_format', 'd.m.Y');
        $dateFormat .= ' ' . $this->_Config->Get('articles_time_format', 'H:i:s');
        $showAuthor = $this->_Config->Get('articles_display_author', 1);
        $articlesArray = array();
        while ($article = mysql_fetch_object($articlesResult)) {
            $thumbnail = '';
            if ($article->article_image != '') {
                if (file_exists($article->article_image)) {
                    $image = new ImageConverter($article->article_image);
                    $size = $image->Size;
                    if ($size[0] > $imgMax && $size[1] > $imgMax) {
                        $size = $image->CalcSizeByMax($imgMax);
                    }
                    $resizedFileName = $thumbnailFolder . $size[0] . 'x' . $size[1] . '_' . basename($article->article_image);
                    if (!file_exists($resizedFileName)) {
                        $image->SaveResizedTo($size[0], $size[1], $thumbnailFolder, $size[0] . 'x' . $size[1] . '_');
                    }
                    if (file_exists($resizedFileName)) {
                        $thumbnail = '<img class="article_image" title="' . $article->article_title . '" alt="' . $article->article_title . '" src="' . generateUrl($resizedFileName) . '" />';
                    }
                }
            }
            $author = '';
            if ($showAuthor) {
                $author = $this->_ComaLib->GetUserByID($article->article_creator);
            }
            $articlesArray[] = array('ARTICLE_ID' => $article->article_id, 'ARTICLE_TITLE' => $article->article_title, 'ARTICLE_THUMBNAIL' => $thumbnail, 'ARTICLE_DESCRIPTION' => nl2br($article->article_description), 'ARTICLE_DATE' => date($dateFormat, $article->article_date), 'ARTICLE_AUTHOR' => $author);
        }
        $articlesTitle = $this->_Config->Get('articles_title', '');
        if ($articlesTitle != '') {
            $articlesTitle = '<h2>' . $articlesTitle . '</h2>';
        }
        $this->_ComaLate->SetReplacement('ARTICLES_BIG_TITLE', $articlesTitle);
        $this->_ComaLate->SetReplacement('ARTICLESOVERVIEW', $articlesArray);
        $articleOverviewString = '{ARTICLES_BIG_TITLE}
 			<ol class="articles_overview">
 			<ARTICLESOVERVIEW:loop>
 				<li><h2>{ARTICLE_TITLE}</h2>
 				<div class="article_date">{ARTICLE_DATE}</div>
 				<div>{ARTICLE_THUMBNAIL}
 					<div class="article_description">{ARTICLE_DESCRIPTION}</div>
 					<div class="article_link"><a href="special.php?page=module&amp;moduleName=articles&amp;action=show&amp;articleId={ARTICLE_ID}">Den Artikel &quot;{ARTICLE_TITLE}&quot; weiterlesen...</a></div>
 				</div>
 				<div class="article_author">{ARTICLE_AUTHOR}</div>
 				</li>
 			</ARTICLESOVERVIEW>
 			</ol>';
        return $articleOverviewString;
    }
Example #15
0
 public function getPreviewImageUrl($maxWidth = 1000, $maxHeight = 1000)
 {
     $prefix = 'pi_' . $maxWidth . "x" . $maxHeight;
     $originalFilename = $this->getPath() . DIRECTORY_SEPARATOR . $this->getFilename();
     $previewFilename = $this->getPath() . DIRECTORY_SEPARATOR . $this->getFilename($prefix);
     // already generated
     if (is_file($previewFilename)) {
         return $this->getUrl($prefix);
     }
     // Check file exists & has valid mime type
     if ($this->getMimeBaseType() != "image" || !is_file($originalFilename)) {
         return "";
     }
     $imageInfo = @getimagesize($originalFilename);
     // Check if we got any dimensions - invalid image
     if (!isset($imageInfo[0]) || !isset($imageInfo[1])) {
         return "";
     }
     // Check if image type is supported
     if ($imageInfo[2] != IMAGETYPE_PNG && $imageInfo[2] != IMAGETYPE_JPEG && $imageInfo[2] != IMAGETYPE_GIF) {
         return "";
     }
     ImageConverter::Resize($originalFilename, $previewFilename, array('mode' => 'max', 'width' => $maxWidth, 'height' => $maxHeight));
     return $this->getUrl($prefix);
 }
 function MakeImage($Image)
 {
     #[size] {[int_x]X[int_y],[int_maxsize], w[int_maxwidth], thumb=>w180, original=>[orig_x]X[orig_y], big=>800}
     #[format] {box, box_only, picture}
     #[Url]|[Title] => [Url]|box|thumb|[Title]
     #[Url]|[size]|[Title] = [Url]|box|[size]|[Title]
     #[Url]|[display]|[size]|[Title]
     // TODO: get the connection throug the parameters, not as a global
     global $sqlConnection;
     // Defaults
     $ImageAlign = IMG_ALIGN_NORMAL;
     $imageDisplay = IMG_DISPLAY_BOX;
     $imageSize = 'w180';
     $imageWidth = 180;
     $imageHeight = 180;
     $imageTitle = '';
     $imageUrl = '';
     $leftSpace = false;
     $rightSpace = false;
     if (substr($Image, 0, 1) == ' ') {
         $leftSpace = true;
     }
     if (substr($Image, -1, 1) == ' ') {
         $rightSpace = true;
     }
     if ($leftSpace && $rightSpace) {
         $ImageAlign = IMG_ALIGN_CENTER;
     } else {
         if ($leftSpace) {
             $ImageAlign = IMG_ALIGN_LEFT;
         } else {
             if ($rightSpace) {
                 $ImageAlign = IMG_ALIGN_RIGHT;
             }
         }
     }
     // remove spaces at the begin and end of the string
     $Image = preg_replace("~^\\ *(.+?)\\ *\$~", '$1', $Image);
     // Split into all Parameters
     $parameters = explode('|', $Image);
     // set the path to the local media dir
     $imageUrl = preg_replace("~^\\media:\\ *(.+?)\$~", 'data/upload/' . '$1', $parameters[0]);
     $imageTitle = $parameters[0];
     //remove first entry (we don't have to check it)
     unset($parameters[0]);
     // go through each parameter
     foreach ($parameters as $key => $value) {
         // extract the image layout
         if (preg_match('~^(' . IMG_DISPLAY_BOX_ONLY . '|' . IMG_DISPLAY_BOX . '|' . IMG_DISPLAY_PICTURE . ')$~', $value)) {
             $imageDisplay = $value;
         } else {
             if (preg_match('~^(thumb|original|big|[0-9]+[Xx][0-9]+|[0-9]+|\\w[0-9]+)$~', $value)) {
                 $imageSize = $value;
             } else {
                 // its the Title of the picture (it is the last unused parameter)
                 $imageTitle = $value;
             }
         }
     }
     // TODO:
     // check if the image isn't saved "local", if it is, download it!
     // extern_{$filename}_timestamp.png
     // if the file doesn't exists under the given path, try to find it in the database
     if (!file_exists($imageUrl)) {
         $sql = "SELECT file_path\n\t\t\t\t\t\tFROM " . DB_PREFIX . "files\n\t\t\t\t\t\tWHERE LOWER(file_path) = '" . strtolower($imageUrl) . "'\n\t\t\t\t\t\t\tOR LOWER(file_name) = '" . strtolower(basename($imageUrl)) . "'\n\t\t\t\t\t\tLIMIT 1";
         $result = $sqlConnection->SqlQuery($sql);
         if ($fileData = mysql_fetch_object($result)) {
             $imageUrl = $fileData->file_path;
         }
         // check if the file from the database really exists
         if (!file_exists($imageUrl)) {
             return "<strong>Bild (&quot;<em>{$imageUrl}</em>&quot;) nicht gefunden.</strong>";
         }
     }
     // Resize the image
     $image = new ImageConverter($imageUrl);
     // convert the 'name-sizes' to 'pixel-sizes'
     if ($imageSize == 'thumb') {
         $imageSize = 'w180';
     } else {
         if ($imageSize == 'big') {
             $imageSize = '800';
         } else {
             if ($imageSize == 'original') {
                 // took the original sizes
                 $imageWidth = $image->Size[0];
                 $imageHeight = $image->Size[1];
             }
         }
     }
     // 'width-format''
     if (preg_match('~^w[0-9]+$~', $imageSize)) {
         $imageWidth = substr($imageSize, 1);
         // calculate the proporitonal height
         $imageHeight = round($image->Size[1] / $image->Size[0] * $imageWidth, 0);
     } else {
         if (preg_match('~^[0-9]+$~', $imageSize)) {
             // look for the longer side and resize it to te given size,
             // short the other side proportional to the longer side
             $imageWidth = $image->Size[0] > $image->Size[1] ? round($imageSize, 0) : round($image->Size[0] / ($image->Size[1] / $imageSize), 0);
             $imageHeight = $image->Size[1] > $image->Size[0] ? round($imageSize, 0) : round($image->Size[1] / ($image->Size[0] / $imageSize), 0);
         } else {
             if (preg_match('~^([0-9]+)[Xx]([0-9]+)$~', $imageSize, $maches)) {
                 // took the given sizes
                 $imageWidth = $maches[1] < $image->Size[0] ? $maches[1] : $image->Size[0];
                 $imageHeight = $maches[2] < $image->Size[1] ? $maches[2] : $image->Size[1];
             }
         }
     }
     $originalUrl = encodeUri($imageUrl);
     // str_replace(' ', '%20', basename($imageUrl));
     // TODO: don't use the global
     global $config;
     // check if the image exists already
     $thumbnailfolder = $config->Get('thumbnailfolder', 'data/thumbnails/');
     if (file_exists($thumbnailfolder . '/' . $imageWidth . 'x' . $imageHeight . '_' . basename($imageUrl))) {
         $imageUrl = $thumbnailfolder . '/' . $imageWidth . 'x' . $imageHeight . '_' . basename($imageUrl);
     } else {
         if ($image->Size[0] >= $imageWidth && $image->Size[1] > $imageHeight || $image->Size[0] > $imageWidth && $image->Size[1] >= $imageHeight) {
             $imageUrl = $image->SaveResizedTo($imageWidth, $imageHeight, $thumbnailfolder, $imageWidth . 'x' . $imageHeight . '_');
             if ($imageUrl === false) {
                 return "Not enough memory available!(resize your image!)";
             }
         } else {
             $imageWidth = $image->Size[0];
             $imageHeight = $image->Size[1];
         }
     }
     if ($imageDisplay == IMG_DISPLAY_BOX) {
         $imageString = "</p>\n\n<div class=\"thumb t" . $ImageAlign . "\">\n\t\t\t\t\t\t<div style=\"width:" . ($imageWidth + 4) . "px\">\n\t\t\t\t\t\t\t<img width=\"{$imageWidth}\" height=\"{$imageHeight}\" src=\"{$imageUrl}\" title=\"{$imageTitle}\" alt=\"{$imageTitle}\" />\n\t\t\t\t\t\t\t<div class=\"description\" title=\"{$imageTitle}\"><div class=\"magnify\"><a href=\"special.php?page=image&amp;file={$originalUrl}\" title=\"vergr&ouml;&szlig;ern\"><img src=\"img/magnify.png\" title=\"vergr&ouml;&szlig;ern\" alt=\"vergr&ouml;&szlig;ern\"/></a></div>{$imageTitle}</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div><p>\n";
     } else {
         if ($imageDisplay == IMG_DISPLAY_BOX_ONLY) {
             $imageString = "</p>\n\n<div class=\"thumb tbox t" . $ImageAlign . "\">\n\t\t\t\t\t\t<div style=\"width:" . ($imageWidth + 4) . "px\">\n\t\t\t\t\t\t\t<img width=\"{$imageWidth}\" height=\"{$imageHeight}\" src=\"{$imageUrl}\" title=\"{$imageTitle}\" alt=\"{$imageTitle}\" />\n\t\t\t\t\t\t\t<div class=\"magnify\"><a href=\"special.php?page=image&amp;file={$originalUrl}\" title=\"vergr&ouml;&szlig;ern\"><img src=\"img/magnify.png\" title=\"vergr&ouml;&szlig;ern\" alt=\"vergr&ouml;&szlig;ern\"/></a></div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n<p>";
         } else {
             if ($imageDisplay == IMG_DISPLAY_PICTURE) {
                 $imageString = "</p>\n\n<div class=\"thumb tbox t" . $ImageAlign . "\">\n\t\t\t\t\t<img width=\"{$imageWidth}\" height=\"{$imageHeight}\" src=\"{$imageUrl}\" title=\"{$imageTitle}\" alt=\"{$imageTitle}\" />\n\t\t\t\t\t</div><p>";
             }
         }
     }
     return "{$imageString}";
 }
Example #17
0
 /**
  * Sets a new profile image by given temp file
  *
  * @param CUploadedFile $file
  */
 public function setNew($file)
 {
     $this->delete();
     ImageConverter::TransformToJpeg($file->getTempName(), $this->getPath('_org'));
     ImageConverter::Resize($this->getPath('_org'), $this->getPath('_org'), array('width' => 850, 'mode' => 'max'));
     ImageConverter::Resize($this->getPath('_org'), $this->getPath(''), array('width' => $this->width, 'height' => $this->height));
 }
Example #18
0
 /**
  * Sets a new logo image by given temp file
  *
  * @param CUploadedFile $file
  */
 public function setNew(CUploadedFile $file)
 {
     $this->delete();
     move_uploaded_file($file->getTempName(), $this->getPath());
     ImageConverter::Resize($this->getPath(), $this->getPath(), array('height' => $this->height, 'width' => 0, 'mode' => 'max', 'transparent' => $file->getExtensionName() == 'png' && ImageConverter::checkTransparent($this->getPath())));
 }
Example #19
0
 /**
  * Sets a new profile image by given temp file
  *
  * @param mixed $file CUploadedFile or file path
  */
 public function setNew($file)
 {
     if ($file instanceof CUploadedFile) {
         $file = $file->getTempName();
     }
     $this->delete();
     ImageConverter::TransformToJpeg($file, $this->getPath('_org'));
     ImageConverter::Resize($this->getPath('_org'), $this->getPath('_org'), array('width' => 400, 'mode' => 'max'));
     ImageConverter::Resize($this->getPath('_org'), $this->getPath(''), array('width' => $this->width, 'height' => $this->height));
 }