Dotclear

source: plugins/pings/index.php @ 3725:b47f38c701ee

Revision 3725:b47f38c701ee, 3.7 KB checked in by franck <carnet.franck.paul@…>, 8 years ago (diff)

Use specialized input fields (color, email, url, number, …) where is relevant

RevLine 
[0]1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
[1179]6# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
[0]7# Licensed under the GPL version 2.0 license.
8# See LICENSE file or
9# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10#
11# -- END LICENSE BLOCK -----------------------------------------
[3725]12if (!defined('DC_CONTEXT_ADMIN')) {return;}
[0]13
14dcPage::checkSuper();
15
16try
17{
[3725]18    $pings_uris = $core->blog->settings->pings->pings_uris;
19    if (!$pings_uris) {
20        $pings_uris = array();
21    }
[2566]22
[3725]23    if (isset($_POST['pings_srv_name'])) {
24        $pings_srv_name = is_array($_POST['pings_srv_name']) ? $_POST['pings_srv_name'] : array();
25        $pings_srv_uri  = is_array($_POST['pings_srv_uri']) ? $_POST['pings_srv_uri'] : array();
26        $pings_uris     = array();
[2566]27
[3725]28        foreach ($pings_srv_name as $k => $v) {
29            if (trim($v) && trim($pings_srv_uri[$k])) {
30                $pings_uris[trim($v)] = trim($pings_srv_uri[$k]);
31            }
32        }
[2566]33
[3725]34        $core->blog->settings->addNamespace('pings');
35        // Settings for all blogs
36        $core->blog->settings->pings->put('pings_active', !empty($_POST['pings_active']), null, null, true, true);
37        $core->blog->settings->pings->put('pings_uris', $pings_uris, null, null, true, true);
38        // Settings for current blog only
39        $core->blog->settings->pings->put('pings_auto', !empty($_POST['pings_auto']), null, null, true, false);
[3428]40
[3725]41        dcPage::addSuccessNotice(__('Settings have been successfully updated.'));
42        http::redirect($p_url);
43    }
44} catch (Exception $e) {
45    $core->error->add($e->getMessage());
[0]46}
47?>
48<html>
49<head>
50  <title><?php echo __('Pings'); ?></title>
51</head>
52
53<body>
54<?php
[1339]55
[1358]56echo dcPage::breadcrumb(
[3725]57    array(
58        __('Plugins')             => '',
59        __('Pings configuration') => ''
60    ));
[0]61
62echo
[3725]63'<form action="' . $p_url . '" method="post">' .
64'<p><label for="pings_active" class="classic">' . form::checkbox('pings_active', 1, $core->blog->settings->pings->pings_active) .
65__('Activate pings extension') . '</label></p>';
[0]66
[124]67$i = 0;
[3725]68foreach ($pings_uris as $n => $u) {
69    echo
70    '<p><label for="pings_srv_name-' . $i . '" class="classic">' . __('Service name:') . '</label> ' .
71    form::field(array('pings_srv_name[]', 'pings_srv_name-' . $i), 20, 128, html::escapeHTML($n)) . ' ' .
72    '<label for="pings_srv_uri-' . $i . '" class="classic">' . __('Service URI:') . '</label> ' .
73    form::url(array('pings_srv_uri[]', 'pings_srv_uri-' . $i), array(
74        'size'    => 40,
75        'default' => html::escapeHTML($u)
76    ));
[2566]77
[3725]78    if (!empty($_GET['test'])) {
79        try {
80            pingsAPI::doPings($u, 'Example site', 'http://example.com');
81            echo ' <img src="images/check-on.png" alt="OK" />';
82        } catch (Exception $e) {
83            echo ' <img src="images/check-off.png" alt="' . __('Error') . '" /> ' . $e->getMessage();
84        }
85    }
[2566]86
[3725]87    echo '</p>';
88    $i++;
[0]89}
90
91echo
[3725]92'<p><label for="pings_srv_name2" class="classic">' . __('Service name:') . '</label> ' .
93form::field(array('pings_srv_name[]', 'pings_srv_name2'), 20, 128) . ' ' .
94'<label for="pings_srv_uri2" class="classic">' . __('Service URI:') . '</label> ' .
95form::url(array('pings_srv_uri[]', 'pings_srv_uri2'), 40) .
96'</p>' .
[0]97
[3725]98'<p><label for="pings_auto" class="classic">' . form::checkbox('pings_auto', 1, $core->blog->settings->pings->pings_auto) .
99__('Auto pings all services on first publication of entry (current blog only)') . '</label></p>' .
[3428]100
[3725]101'<p><input type="submit" value="' . __('Save') . '" />' .
102$core->formNonce() . '</p>' .
103    '</form>';
[0]104
[3725]105echo '<p><a class="button" href="' . $p_url . '&amp;test=1">' . __('Test ping services') . '</a></p>';
[0]106?>
[2322]107
[3725]108<?php dcPage::helpBlock('pings');?>
[2322]109
[0]110</body>
[2566]111</html>
Note: See TracBrowser for help on using the repository browser.

Sites map