diff --git a/classes/MarketImage.class.php b/classes/MarketImage.class.php index 7fb8eae85c81b6725959b37d41bb5159fdcb1df8..b97d32b7164e11a4b896e74b283204290989ec05 100644 --- a/classes/MarketImage.class.php +++ b/classes/MarketImage.class.php @@ -1,7 +1,7 @@ <?php -class MarketImage extends SimpleORMap { - +class MarketImage extends SimpleORMap +{ static public function findByPlugin_id($plugin_id) { return self::findBySQL("plugin_id = ? ORDER BY position ASC, mkdate ASC", array($plugin_id)); } @@ -20,8 +20,19 @@ class MarketImage extends SimpleORMap { parent::configure($config); } - public function getURL() { - return URLHelper::getURL("plugins.php/pluginmarket/presenting/image/".$this->getId(), array(), true); + public function getURL($absolute_url = false) + { + if ($absolute_url) { + $old_base = URLHelper::setBaseURL($GLOBALS['ABSOLUTE_URI_STUDIP']); + } + + $url = URLHelper::getURL("plugins.php/pluginmarket/presenting/image/".$this->getId(), array(), true); + + if ($absolute_url) { + URLHelper::setBaseURL($old_base); + } + + return $url; } public function delete() { diff --git a/classes/MarketPlugin.class.php b/classes/MarketPlugin.class.php index c54945a3df2c083255a118d1b737d0f5ddbaa125..e5399a8eb7de96c349113bece4ad9e5523466261 100644 --- a/classes/MarketPlugin.class.php +++ b/classes/MarketPlugin.class.php @@ -66,9 +66,10 @@ class MarketPlugin extends SimpleORMap { return $GLOBALS['perm']->have_perm("root", $user_id); } - public function getLogoURL() { + public function getLogoURL($absolute_url = false) + { $firstimage = $this->images->first(); - return $firstimage ? $firstimage->getURL() : Assets::image_path("icons/blue/plugin.svg"); + return $firstimage ? $firstimage->getURL($absolute_url) : Assets::image_path("icons/blue/plugin.svg"); } public function setTags($tags) { diff --git a/controllers/approving.php b/controllers/approving.php index 3732a7005cc7712d53afc781d878fdaccbefffa0..d0cfa3685e414c911a842a36cecbc08971715682 100644 --- a/controllers/approving.php +++ b/controllers/approving.php @@ -1,7 +1,8 @@ <?php -require_once 'app/controllers/plugin_controller.php'; +require_once 'market_controller.php'; -class ApprovingController extends PluginController { +class ApprovingController extends MarketController +{ function before_filter(&$action, &$args) { diff --git a/controllers/extern.php b/controllers/extern.php index dc03f3bc78be088903836d1a093bf4b66399af7c..1c8dcb499921b9a158c2bb39c4fc9649d5c2d0c4 100644 --- a/controllers/extern.php +++ b/controllers/extern.php @@ -1,16 +1,23 @@ <?php -require_once 'app/controllers/plugin_controller.php'; +require_once 'market_controller.php'; -class ExternController extends PluginController +class ExternController extends MarketController { - public function xml_action() { - $this->plugins = MarketPlugin::findBySQL("publiclyvisible = 1 AND approved = 1 ORDER BY name ASC"); - URLHelper::setBaseUrl($GLOBALS['ABSOLUTE_URI_STUDIP']); + public function before_filter(&$action, &$args) + { + parent::before_filter($action, $args); + $this->set_layout(null); + } + + public function xml_action() + { + $this->plugins = MarketPlugin::findBySQL("publiclyvisible = 1 AND approved = 1 ORDER BY name ASC"); $this->response->add_header('Content-Type', "text/xml"); } - public function find_releases_action() { + public function find_releases_action() + { $output = array(); $studipversion = Request::get("studipversion"); $plugins = MarketPlugin::findByPluginclassname(Request::get("classname")); @@ -22,9 +29,9 @@ class ExternController extends PluginController if ((!$release['studip_min_version'] || version_compare($studipversion, $release['studip_min_version'], ">=")) && (!$release['studip_max_version'] || version_compare($studipversion, $release['studip_max_version'], "<="))) { $output['releases'][] = array( - 'version' => $release['version'], - 'html_url' => PluginEngine::getURL($this->plugin, array(), "presenting/details/".$plugin->getId()), - 'download_url' => PluginEngine::getURL($this->plugin, array(), "presenting/download/".$release->getId()) + 'version' => $release['version'], + 'html_url' => $this->url_for('presenting/details/' . $plugin->getId()), + 'download_url' => $this->url_for('presenting/download/' . $release->getId()), ); } } diff --git a/controllers/market_controller.php b/controllers/market_controller.php new file mode 100644 index 0000000000000000000000000000000000000000..96e24847a8df33a263c1115f5ccb8f11aac4e445 --- /dev/null +++ b/controllers/market_controller.php @@ -0,0 +1,17 @@ +<?php +require_once 'app/controllers/plugin_controller.php'; + +class MarketController extends PluginController +{ + public function absolute_url_for($to) + { + $old_base = URLHelper::setBaseURL($GLOBALS['ABSOLUTE_URI_STUDIP']); + + $args = func_get_args(); + $url = call_user_func_array(array($this, 'url_for'), $args); + + URLHelper::setBaseURL($old_base); + + return $url; + } +} diff --git a/controllers/myplugins.php b/controllers/myplugins.php index 728f8f79267dfbbc2d2719d16f597c7801bcb058..611f55a49e94e9a6bbe5f8e6a6cfee260a84d4b8 100644 --- a/controllers/myplugins.php +++ b/controllers/myplugins.php @@ -1,8 +1,8 @@ <?php -require_once 'app/controllers/plugin_controller.php'; - -class MypluginsController extends PluginController { +require_once 'market_controller.php'; +class MypluginsController extends MarketController +{ function before_filter(&$action, &$args) { parent::before_filter($action, $args); diff --git a/controllers/presenting.php b/controllers/presenting.php index 9b56c8a60e119b78ef43217da5b65a1e6b827032..b6e3aec63a0d31376ba876fec6697e8db3c65b3a 100644 --- a/controllers/presenting.php +++ b/controllers/presenting.php @@ -1,8 +1,8 @@ <?php -require_once 'app/controllers/plugin_controller.php'; - -class PresentingController extends PluginController { +require_once 'market_controller.php'; +class PresentingController extends MarketController +{ protected $last_pluginmarket_visit = null; function before_filter(&$action, &$args) diff --git a/controllers/update.php b/controllers/update.php index 4fea6fa6713a09ef128199947b8ae401b065e69d..3810a7b6dd9d0d8b2de74347e64bb5f3d421dd2b 100644 --- a/controllers/update.php +++ b/controllers/update.php @@ -1,9 +1,10 @@ <?php -require_once 'app/controllers/plugin_controller.php'; +require_once 'market_controller.php'; -class UpdateController extends PluginController { - - public function release_action($release_id) { +class UpdateController extends MarketController +{ + public function release_action($release_id) + { $release = new MarketRelease($release_id); if ($release->isNew()) { throw new Exception("Unknown release."); @@ -20,5 +21,4 @@ class UpdateController extends PluginController { $this->render_text("Insecure request."); } } - } \ No newline at end of file diff --git a/views/extern/xml.php b/views/extern/xml.php index 298077a86f2c631c312454b16d514418ff94cde2..929045b49adb6c335ae8b39cbf1b736c7c5d5052 100644 --- a/views/extern/xml.php +++ b/views/extern/xml.php @@ -6,13 +6,13 @@ homepage="<?= htmlReady(studip_utf8encode($marketplugin['url'])) ?>" short_description="<?= htmlReady(studip_utf8encode($marketplugin['short_description'])) ?>" description="<?= htmlReady(studip_utf8encode($marketplugin['description'])) ?>" - image="<?= htmlReady(studip_utf8encode($marketplugin->getLogoURL())) ?>"> + image="<?= htmlReady(studip_utf8encode($marketplugin->getLogoURL(true))) ?>"> <? foreach ($marketplugin->releases as $release) : ?> <release version="<?= htmlReady(studip_utf8encode($release['version'])) ?>" studipMinVersion="<?= htmlReady(studip_utf8encode($release['studip_min_version'])) ?>" studipMaxVersion="<?= htmlReady(studip_utf8encode($release['studip_min_version'])) ?>" - url="<?= htmlReady(studip_utf8encode($controller->url_for('presenting/download/' . $release->getId()))) ?>" + url="<?= htmlReady(studip_utf8encode($controller->absolute_url_for('presenting/download/' . $release->getId()))) ?>" /> <? endforeach ?> </plugin> diff --git a/views/myplugins/_edit_release.php b/views/myplugins/_edit_release.php index e12b257decc89da7ab7d0710299dcc46901e4b3c..adc967c4b758b39a495814dc680f38bc1beebe67 100644 --- a/views/myplugins/_edit_release.php +++ b/views/myplugins/_edit_release.php @@ -51,7 +51,7 @@ <? if (!$release->isNew()) : ?> <p class="info"> <?= _("Webhook-URL zum Einf�gen in github oder gitlab:") ?> - <input type="text" readonly style="border: thin solid #cccccc; background-color: #eeeeee; width:100%;" value="<?= $GLOBALS['ABSOLUTE_URI_STUDIP']."plugins.php/pluginmarket/update/release/".$release->getId().'?s='.$release->getSecurityHash() ?>"> + <input type="text" readonly style="border: thin solid #cccccc; background-color: #eeeeee; width:100%;" value="<?= $controller->absolute_url_for('update/release/' . $release->getId(), array('s' => $release->getSecurityHash())) ?>"> </p> <? if ($domain_warning) : ?> <p class="info"><?= htmlReady($domain_warning) ?></p> diff --git a/views/presenting/follow_release.php b/views/presenting/follow_release.php index 76add3f01e9ebb2ae6d0cc1182090ea54f057ee3..565ed67ef72748686961ec8adc94ad8a38bc20ab 100644 --- a/views/presenting/follow_release.php +++ b/views/presenting/follow_release.php @@ -9,7 +9,7 @@ <legend><?= _("Konfigurieren Sie Ihr Stud.IP") ?></legend> <label> <?= _("Download-URL - geben Sie diese URL in Ihrem Stud.IP in der Pluginverwaltung ein") ?> - <input type="text" readonly value="<?= $GLOBALS['ABSOLUTE_URI_STUDIP'] . $controller->url_for('presenting/download/' . $release->getId()) ?>"> + <input type="text" readonly value="<?= $controller->absolute_url_for('presenting/download/' . $release->getId()) ?>"> </label> </fieldset> <fieldset>