From: <var...@us...> - 2021-06-28 13:42:16
|
Revision: 10331 http://sourceforge.net/p/phpwiki/code/10331 Author: vargenau Date: 2021-06-28 13:42:18 +0000 (Mon, 28 Jun 2021) Log Message: ----------- lib/plugin/text2png.php: no debug by default Modified Paths: -------------- trunk/lib/plugin/text2png.php Modified: trunk/lib/plugin/text2png.php =================================================================== --- trunk/lib/plugin/text2png.php 2021-06-28 12:16:29 UTC (rev 10330) +++ trunk/lib/plugin/text2png.php 2021-06-28 13:42:18 UTC (rev 10331) @@ -44,8 +44,7 @@ * See <http://www.php.net/manual/pl/ref.image.php> for more info. */ -if (!defined('text2png_debug')) - define('text2png_debug', DEBUG & _DEBUG_VERBOSE); +// define('text2png_debug', DEBUG & _DEBUG_VERBOSE); class WikiPlugin_text2png extends WikiPlugin This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2021-06-28 13:44:51
|
Revision: 10332 http://sourceforge.net/p/phpwiki/code/10332 Author: vargenau Date: 2021-06-28 13:44:54 +0000 (Mon, 28 Jun 2021) Log Message: ----------- lib/plugin/text2png.php: no need for language subdirectory Modified Paths: -------------- trunk/lib/plugin/text2png.php Modified: trunk/lib/plugin/text2png.php =================================================================== --- trunk/lib/plugin/text2png.php 2021-06-28 13:42:18 UTC (rev 10331) +++ trunk/lib/plugin/text2png.php 2021-06-28 13:44:54 UTC (rev 10332) @@ -125,13 +125,8 @@ * user's locale preferences. */ - if ($l == "C") { - $l = "en"; //english=C - } else { - $l = urlencode($l); // who on earth forgot his? - } $basedir = "text2png-image"; - $filepath = getUploadFilePath() . "$basedir/$l"; + $filepath = getUploadFilePath() . "$basedir"; if ($_force or !file_exists($filepath . $filename)) { if (!file_exists($filepath)) { $oldumask = umask(0); @@ -220,7 +215,7 @@ $filepath . $filename)); } } - $url = getUploadDataPath() . "$basedir/" . urlencode($l) . "/" . urlencode($filename); + $url = getUploadDataPath() . "$basedir/" . urlencode($filename); $html->pushContent(HTML::img(array('src' => $url, 'alt' => $text, 'title' => '"' . $text . '"' . _(" produced by ") . $this->getName()))); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2021-06-28 14:45:45
|
Revision: 10335 http://sourceforge.net/p/phpwiki/code/10335 Author: vargenau Date: 2021-06-28 14:45:46 +0000 (Mon, 28 Jun 2021) Log Message: ----------- lib/plugin/text2png.php: better error handling Modified Paths: -------------- trunk/lib/plugin/text2png.php Modified: trunk/lib/plugin/text2png.php =================================================================== --- trunk/lib/plugin/text2png.php 2021-06-28 14:17:34 UTC (rev 10334) +++ trunk/lib/plugin/text2png.php 2021-06-28 14:45:46 UTC (rev 10335) @@ -84,10 +84,11 @@ } else { // we don't have png and/or gd. $error_html = _("Sorry, this version of PHP cannot create PNG image files."); - $link = "https://www.php.net/manual/pl/ref.image.php"; - $error_html .= sprintf(_("See %s"), $link) . "."; - trigger_error($error_html); - return HTML::p($error_html); + $error_html .= " "; + $error_html .= _("See") . _(": "); + $link = HTML::a(array('href' => "https://www.php.net/manual/en/ref.image.php"), + "https://www.php.net/manual/en/ref.image.php") ; + return HTML::span(array('class' => 'error'), $error_html, $link); } } @@ -147,7 +148,8 @@ if (defined('TTFONT')) $ttfont = TTFONT; elseif (PHP_OS == "Darwin") // Mac OS X - $ttfont = "/System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/fonts/LucidaSansRegular.ttf"; elseif (isWindows()) { + $ttfont = "/System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/fonts/LucidaSansRegular.ttf"; + elseif (isWindows()) { $ttfont = $_ENV['windir'] . '\Fonts\Arial.ttf'; } else { $ttfont = 'luximr'; // This is the only what sourceforge offered. @@ -161,15 +163,22 @@ // get ready to draw $s = imagettfbbox($fontsize, 0, $ttfont, $text); - $im = @imagecreate(abs($s[4]) + 20, abs($s[7]) + 10); + if ($s === false) { + $error_html = _("PHP was unable to create a new GD image stream. Read 'lib/plugin/text2png.php' for details."); + $error_html .= " "; + $error_html .= _("See") . _(": "); + $link = HTML::a(array('href' => "https://www.php.net/manual/en/function.imagecreate.php"), + "https://www.php.net/manual/en/function.imagecreate.php") ; + return HTML::span(array('class' => 'error'), $error_html, $link); + } + $im = imagecreate(abs($s[4]) + 20, abs($s[7]) + 10); if (empty($im)) { $error_html = _("PHP was unable to create a new GD image stream. Read 'lib/plugin/text2png.php' for details."); - // FIXME: Error manager does not transform URLs passed - // through it. - $link = "https://www.php.net/manual/en/function.imagecreate.php"; - $error_html .= sprintf(_("See %s"), $link) . "."; - trigger_error($error_html); - return HTML::p($error_html); + $error_html .= " "; + $error_html .= _("See") . _(": "); + $link = HTML::a(array('href' => "https://www.php.net/manual/en/function.imagecreate.php"), + "https://www.php.net/manual/en/function.imagecreate.php") ; + return HTML::span(array('class' => 'error'), $error_html, $link); } $rgb = $this->hexcolor($backcolor, array(255, 255, 255)); $bg_color = imagecolorallocate($im, $rgb[0], $rgb[1], $rgb[2]); @@ -220,8 +229,9 @@ 'alt' => $text, 'title' => '"' . $text . '"' . _(" produced by ") . $this->getName()))); } else { - trigger_error(sprintf(_("couldn't open file “%s” for writing"), - $filepath . $filename)); + return HTML::span(array('class' => 'error'), + sprintf(_("couldn't open file “%s” for writing"), + $filepath . $filename)); } return $html; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2021-06-28 15:17:32
|
Revision: 10336 http://sourceforge.net/p/phpwiki/code/10336 Author: vargenau Date: 2021-06-28 15:17:30 +0000 (Mon, 28 Jun 2021) Log Message: ----------- lib/plugin/text2png.php: factor code Modified Paths: -------------- trunk/lib/plugin/text2png.php Modified: trunk/lib/plugin/text2png.php =================================================================== --- trunk/lib/plugin/text2png.php 2021-06-28 14:45:46 UTC (rev 10335) +++ trunk/lib/plugin/text2png.php 2021-06-28 15:17:30 UTC (rev 10336) @@ -86,8 +86,8 @@ $error_html = _("Sorry, this version of PHP cannot create PNG image files."); $error_html .= " "; $error_html .= _("See") . _(": "); - $link = HTML::a(array('href' => "https://www.php.net/manual/en/ref.image.php"), - "https://www.php.net/manual/en/ref.image.php") ; + $url = "https://www.php.net/manual/en/ref.image.php"; + $link = HTML::a(array('href' => $url), $url); return HTML::span(array('class' => 'error'), $error_html, $link); } } @@ -162,22 +162,19 @@ */ // get ready to draw + + $error_html = _("PHP was unable to create a new GD image stream. Read 'lib/plugin/text2png.php' for details."); + $error_html .= " "; + $error_html .= _("See") . _(": "); + $url = "https://www.php.net/manual/en/function.imagecreate.php"; + $link = HTML::a(array('href' => $url), $url); + $s = imagettfbbox($fontsize, 0, $ttfont, $text); if ($s === false) { - $error_html = _("PHP was unable to create a new GD image stream. Read 'lib/plugin/text2png.php' for details."); - $error_html .= " "; - $error_html .= _("See") . _(": "); - $link = HTML::a(array('href' => "https://www.php.net/manual/en/function.imagecreate.php"), - "https://www.php.net/manual/en/function.imagecreate.php") ; return HTML::span(array('class' => 'error'), $error_html, $link); } $im = imagecreate(abs($s[4]) + 20, abs($s[7]) + 10); if (empty($im)) { - $error_html = _("PHP was unable to create a new GD image stream. Read 'lib/plugin/text2png.php' for details."); - $error_html .= " "; - $error_html .= _("See") . _(": "); - $link = HTML::a(array('href' => "https://www.php.net/manual/en/function.imagecreate.php"), - "https://www.php.net/manual/en/function.imagecreate.php") ; return HTML::span(array('class' => 'error'), $error_html, $link); } $rgb = $this->hexcolor($backcolor, array(255, 255, 255)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |