kUtRL/inc/index.service.php

83 lines
2.5 KiB
PHP
Raw Normal View History

2021-08-25 23:06:22 +00:00
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
# This file is part of kUtRL, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2011 JC Denis and contributors
# jcdenis@gdwd.com
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------
# This file manage services of kUtRL (called from index.php)
2021-08-27 22:06:46 +00:00
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
2021-08-25 23:06:22 +00:00
# Save services settings
2021-08-27 22:06:46 +00:00
if ($action == 'saveservice') {
try {
foreach(kutrl::getServices($core) as $service_id => $service) {
2021-08-25 23:06:22 +00:00
$o = new $service($core);
$o->saveSettings();
}
$core->blog->triggerBlog();
2021-08-27 22:06:46 +00:00
http::redirect($p_url . '&part=service&section=' . $section . '&msg=' . $action);
} catch (Exception $e) {
2021-08-25 23:06:22 +00:00
$core->error->add($e->getMessage());
}
}
echo '
<html>
2021-08-27 22:06:46 +00:00
<head><title>kUtRL, ' . __('Links shortener') . '</title>' . $header .
dcPage::jsLoad('index.php?pf=kUtRL/js/service.js') .
"<script type=\"text/javascript\">\n//<![CDATA[\n" .
dcPage::jsVar('jcToolsBox.prototype.section', $section) .
"\n//]]>\n</script>\n" .
2021-08-25 23:06:22 +00:00
'</head>
<body>
2021-08-27 22:06:46 +00:00
<h2>kUtRL' .
' &rsaquo; <a href="' . $p_url . '&amp;part=links">' . __('Links') . '</a>' .
' &rsaquo; ' . __('Services') .
' - <a class="button" href="' . $p_url . '&amp;part=link">' . __('New link') . '</a>' .
'</h2>' . $msg . '
<form id="service-form" method="post" action="' . $p_url . '">';
2021-08-25 23:06:22 +00:00
2021-08-27 22:06:46 +00:00
foreach(kutrl::getServices($core) as $service_id => $service) {
2021-08-25 23:06:22 +00:00
$o = new $service($core);
2021-08-27 22:06:46 +00:00
echo '<fieldset id="setting-' . $service_id . '"><legend>' . $o->name . '</legend>';
2021-08-25 23:06:22 +00:00
2021-08-27 22:06:46 +00:00
if (!empty($msg)) {
echo '<p><em>' . (
2021-08-25 23:06:22 +00:00
$o->testService() ?
2021-08-27 22:06:46 +00:00
$img_green . ' ' . sprintf(__('%s API is well configured and runing.'), $o->name) :
$img_red . ' ' . sprintf(__('Failed to test %s API.'), $o->name)
) . '</em></p>';
2021-08-25 23:06:22 +00:00
//if ($o->error->flag()) {
echo $o->error->toHTML();
//}
}
2021-08-27 22:06:46 +00:00
if (!empty($o->home)) {
echo '<p><a title="' . __('homepage') . '" href="' . $o->home . '">' . sprintf(__('Learn more about %s.'), $o->name) . '</a></p>';
2021-08-25 23:06:22 +00:00
}
$o->settingsForm();
echo '</fieldset>';
}
echo '
<div class="clear">
2021-08-27 22:06:46 +00:00
<p><input type="submit" name="save" value="' . __('save') . '" />' .
$core->formNonce() .
form::hidden(['p'], 'kUtRL') .
form::hidden(['part'], 'service') .
form::hidden(['action'], 'saveservice') .
form::hidden(['section'], $section) . '
2021-08-25 23:06:22 +00:00
</p></div>
</form>';
dcPage::helpBlock('kUtRL');
2021-08-27 22:06:46 +00:00
echo $footer . '</body></html>';