From 1ff2bc4f3c694b7c76df8e57056c51ca39a23a34 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 20 Jan 2015 18:07:24 +0100 Subject: config module structure completed. Many other fixes. Hidden pw field support. --- modules/sysconfig/addmodule_branding.inc.php | 41 +++++++++++++++++++--------- 1 file changed, 28 insertions(+), 13 deletions(-) (limited to 'modules/sysconfig/addmodule_branding.inc.php') diff --git a/modules/sysconfig/addmodule_branding.inc.php b/modules/sysconfig/addmodule_branding.inc.php index a6c16d9d..8bcc10a1 100644 --- a/modules/sysconfig/addmodule_branding.inc.php +++ b/modules/sysconfig/addmodule_branding.inc.php @@ -46,8 +46,10 @@ class Branding_ProcessFile extends AddModule_Base // URL - launch task that fetches the SVG file from it if (strpos($url, '://') === false) $url = "http://$url"; - if (!$this->downloadSvg($this->svgFile, $url)) + $title = false; + if (!$this->downloadSvg($this->svgFile, $url, $title)) Util::redirect('?do=SysConfig&action=addmodule&step=Branding_Start'); + Session::set('logo_name', $title); } chmod($this->svgFile, 0644); $this->tarFile = '/tmp/bwlp-' . time() . '-' . mt_rand() . '.tgz'; @@ -83,7 +85,7 @@ class Branding_ProcessFile extends AddModule_Base } /** - * Downlaod an svg file from the given url. This function has "wikipedia support", it tries to detect + * Download an svg file from the given url. This function has "wikipedia support", it tries to detect * URLs in wikipedia articles or thumbnails and then find the actual svg file. * * @param string $svgName file to download to @@ -91,8 +93,9 @@ class Branding_ProcessFile extends AddModule_Base * @return boolean true of download succeded, false on download error (also returns true if downloaded file doesn't * seem to be svg!) */ - private function downloadSvg($svgName, $url) + private function downloadSvg($svgName, $url, &$title) { + $title = false; // [wikipedia] Did someone paste a link to a thumbnail of the svg? Let's fix that... if (preg_match('#^(.*)/thumb/(.*\.svg)/.*\.svg#', $url, $out)) { $url = $out[1] . '/' . $out[2]; @@ -110,12 +113,14 @@ class Branding_ProcessFile extends AddModule_Base // [wikipedia] Try to be nice and detect links that might give a hint where the svg can be found if (preg_match_all('#href="([^"]*upload.wikimedia.org/[^"]*/[^"]*/[^"]*\.svg|[^"]+/[^"]+:[^"]+\.svg[^"]*)"#', $content, $out, PREG_PATTERN_ORDER)) { + if ($title === false && preg_match('#