diff options
author | Gerrit Uitslag <klapinklapin@gmail.com> | 2014-09-28 15:36:21 +0200 |
---|---|---|
committer | Gerrit Uitslag <klapinklapin@gmail.com> | 2014-09-28 15:36:21 +0200 |
commit | 0c1b02bead38d5a58032a1c88cf3ca53bbc4a4d9 (patch) | |
tree | b9cb574a1964f28dda648795010a5be056b80618 /lib/plugins/extension/helper | |
parent | 618191d008b98cb421694c541145c863d7b300ce (diff) | |
parent | da9572711f54d13ce3c5506971154b0bc359723f (diff) | |
download | rpg-0c1b02bead38d5a58032a1c88cf3ca53bbc4a4d9.tar.gz rpg-0c1b02bead38d5a58032a1c88cf3ca53bbc4a4d9.tar.bz2 |
Merge remote-tracking branch 'origin/master' into FS#2697searchpagereadonly
Conflicts:
inc/lang/hr/searchpage.txt
inc/lang/ko/searchpage.txt
Diffstat (limited to 'lib/plugins/extension/helper')
-rw-r--r-- | lib/plugins/extension/helper/extension.php | 48 | ||||
-rw-r--r-- | lib/plugins/extension/helper/list.php | 23 | ||||
-rw-r--r-- | lib/plugins/extension/helper/repository.php | 10 |
3 files changed, 58 insertions, 23 deletions
diff --git a/lib/plugins/extension/helper/extension.php b/lib/plugins/extension/helper/extension.php index 7958cd2da..2aca0e218 100644 --- a/lib/plugins/extension/helper/extension.php +++ b/lib/plugins/extension/helper/extension.php @@ -57,6 +57,8 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin { if(substr($id, 0 , 9) == 'template:'){ $this->base = substr($id, 9); $this->is_template = true; + } else { + $this->is_template = false; } $this->localInfo = array(); @@ -290,7 +292,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin { */ public function getUpdateDate() { if (!empty($this->managerData['updated'])) return $this->managerData['updated']; - return false; + return $this->getInstallDate(); } /** @@ -575,6 +577,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin { try { $installed = $this->installArchive("$tmp/upload.archive", true, $basename); + $this->updateManagerData('', $installed); // purge cache $this->purgeCache(); }catch (Exception $e){ @@ -594,12 +597,10 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin { try { $path = $this->download($url); $installed = $this->installArchive($path, true); + $this->updateManagerData($url, $installed); - // purge caches - foreach($installed as $ext => $info){ - $this->setExtension($ext); - $this->purgeCache(); - } + // purge cache + $this->purgeCache(); }catch (Exception $e){ throw $e; } @@ -613,8 +614,10 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin { * @return array The list of installed extensions */ public function installOrUpdate() { - $path = $this->download($this->getDownloadURL()); + $url = $this->getDownloadURL(); + $path = $this->download($url); $installed = $this->installArchive($path, $this->isInstalled(), $this->getBase()); + $this->updateManagerData($url, $installed); // refresh extension information if (!isset($installed[$this->getID()])) { @@ -729,6 +732,37 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin { } /** + * Save the given URL and current datetime in the manager.dat file of all installed extensions + * + * @param string $url Where the extension was downloaded from. (empty for manual installs via upload) + * @param array $installed Optional list of installed plugins + */ + protected function updateManagerData($url = '', $installed = null) { + $origID = $this->getID(); + + if(is_null($installed)) { + $installed = array($origID); + } + + foreach($installed as $ext => $info) { + if($this->getID() != $ext) $this->setExtension($ext); + if($url) { + $this->managerData['downloadurl'] = $url; + } elseif(isset($this->managerData['downloadurl'])) { + unset($this->managerData['downloadurl']); + } + if(isset($this->managerData['installed'])) { + $this->managerData['updated'] = date('r'); + } else { + $this->managerData['installed'] = date('r'); + } + $this->writeManagerData(); + } + + if($this->getID() != $origID) $this->setExtension($origID); + } + + /** * Read the manager.dat file */ protected function readManagerData() { diff --git a/lib/plugins/extension/helper/list.php b/lib/plugins/extension/helper/list.php index 01a5c516a..9b1988d84 100644 --- a/lib/plugins/extension/helper/list.php +++ b/lib/plugins/extension/helper/list.php @@ -188,10 +188,17 @@ class helper_plugin_extension_list extends DokuWiki_Plugin { * @return string The HTML code */ function make_screenshot(helper_plugin_extension_extension $extension) { - if($extension->getScreenshotURL()) { + $screen = $extension->getScreenshotURL(); + $thumb = $extension->getThumbnailURL(); + + if($screen) { + // use protocol independent URLs for images coming from us #595 + $screen = str_replace('http://www.dokuwiki.org', '//www.dokuwiki.org', $screen); + $thumb = str_replace('http://www.dokuwiki.org', '//www.dokuwiki.org', $thumb); + $title = sprintf($this->getLang('screenshot'), hsc($extension->getDisplayName())); - $img = '<a href="'.hsc($extension->getScreenshotURL()).'" target="_blank" class="extension_screenshot">'. - '<img alt="'.$title.'" width="120" height="70" src="'.hsc($extension->getThumbnailURL()).'" />'. + $img = '<a href="'.hsc($screen).'" target="_blank" class="extension_screenshot">'. + '<img alt="'.$title.'" width="120" height="70" src="'.hsc($thumb).'" />'. '</a>'; } elseif($extension->isTemplate()) { $img = '<img alt="" width="120" height="70" src="'.DOKU_BASE.'lib/plugins/extension/images/template.png" />'; @@ -380,7 +387,8 @@ class helper_plugin_extension_list extends DokuWiki_Plugin { $return .= '<dd>'; $return .= hsc($extension->getInstalledVersion()); $return .= '</dd>'; - } else { + } + if (!$extension->isBundled()) { $return .= '<dt>'.$this->getLang('install_date').'</dt>'; $return .= '<dd>'; $return .= ($extension->getUpdateDate() ? hsc($extension->getUpdateDate()) : $this->getLang('unknown')); @@ -394,13 +402,6 @@ class helper_plugin_extension_list extends DokuWiki_Plugin { $return .= '</dd>'; } - if($extension->getInstallDate()) { - $return .= '<dt>'.$this->getLang('installed').'</dt>'; - $return .= '<dd>'; - $return .= hsc($extension->getInstallDate()); - $return .= '</dd>'; - } - $return .= '<dt>'.$this->getLang('provides').'</dt>'; $return .= '<dd><bdi>'; $return .= ($extension->getTypes() ? hsc(implode(', ', $extension->getTypes())) : $default); diff --git a/lib/plugins/extension/helper/repository.php b/lib/plugins/extension/helper/repository.php index 1f603a866..6ffe89eb7 100644 --- a/lib/plugins/extension/helper/repository.php +++ b/lib/plugins/extension/helper/repository.php @@ -31,7 +31,7 @@ class helper_plugin_extension_repository extends DokuWiki_Plugin { $request_data = array('fmt' => 'php'); $request_needed = false; foreach ($list as $name) { - $cache = new cache('##extension_manager##'.$name, 'repo'); + $cache = new cache('##extension_manager##'.$name, '.repo'); $result = null; if (!isset($this->loaded_extensions[$name]) && $this->hasAccess() && !$cache->useCache(array('age' => 3600 * 24))) { $this->loaded_extensions[$name] = true; @@ -46,7 +46,7 @@ class helper_plugin_extension_repository extends DokuWiki_Plugin { if ($data !== false) { $extensions = unserialize($data); foreach ($extensions as $extension) { - $cache = new cache('##extension_manager##'.$extension['plugin'], 'repo'); + $cache = new cache('##extension_manager##'.$extension['plugin'], '.repo'); $cache->storeCache(serialize($extension)); } } else { @@ -63,7 +63,7 @@ class helper_plugin_extension_repository extends DokuWiki_Plugin { */ public function hasAccess() { if ($this->has_access === null) { - $cache = new cache('##extension_manager###hasAccess', 'repo'); + $cache = new cache('##extension_manager###hasAccess', '.repo'); $result = null; if (!$cache->useCache(array('age' => 3600 * 24, 'purge'=>1))) { $httpclient = new DokuHTTPClient(); @@ -90,7 +90,7 @@ class helper_plugin_extension_repository extends DokuWiki_Plugin { * @return array The data or null if nothing was found (possibly no repository access) */ public function getData($name) { - $cache = new cache('##extension_manager##'.$name, 'repo'); + $cache = new cache('##extension_manager##'.$name, '.repo'); $result = null; if (!isset($this->loaded_extensions[$name]) && $this->hasAccess() && !$cache->useCache(array('age' => 3600 * 24))) { $this->loaded_extensions[$name] = true; @@ -130,7 +130,7 @@ class helper_plugin_extension_repository extends DokuWiki_Plugin { // store cache info for each extension foreach($result as $ext){ $name = $ext['plugin']; - $cache = new cache('##extension_manager##'.$name, 'repo'); + $cache = new cache('##extension_manager##'.$name, '.repo'); $cache->storeCache(serialize($ext)); $ids[] = $name; } |