2010-06-14 04:23:23 +09:00
|
|
|
<?php
|
2020-06-08 18:25:01 +09:00
|
|
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
|
|
|
//
|
|
|
|
// GNU social is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// GNU social is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2010-06-14 04:23:23 +09:00
|
|
|
/**
|
|
|
|
* Sitemap administration panel
|
|
|
|
*
|
|
|
|
* @category Sitemap
|
2020-06-08 18:25:01 +09:00
|
|
|
* @package GNUsocial
|
2010-06-14 04:23:23 +09:00
|
|
|
* @author Evan Prodromou <evan@status.net>
|
|
|
|
* @copyright 2010 StatusNet, Inc.
|
2020-06-08 18:25:01 +09:00
|
|
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
2010-06-14 04:23:23 +09:00
|
|
|
*/
|
|
|
|
|
2020-06-08 18:25:01 +09:00
|
|
|
defined('GNUSOCIAL') || die();
|
2010-06-14 04:23:23 +09:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Administer sitemap settings
|
|
|
|
*
|
2020-06-08 18:25:01 +09:00
|
|
|
* @category Sitemap
|
|
|
|
* @package GNUsocial
|
|
|
|
* @author Evan Prodromou <evan@status.net>
|
|
|
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
2010-06-14 04:23:23 +09:00
|
|
|
*/
|
|
|
|
class SitemapadminpanelAction extends AdminPanelAction
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Returns the page title
|
|
|
|
*
|
|
|
|
* @return string page title
|
|
|
|
*/
|
2020-06-08 18:25:01 +09:00
|
|
|
public function title()
|
2010-06-14 04:23:23 +09:00
|
|
|
{
|
2010-10-04 06:54:57 +09:00
|
|
|
// TRANS: Title for sitemap.
|
|
|
|
return _m('Sitemap');
|
2010-06-14 04:23:23 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Instructions for using this form.
|
|
|
|
*
|
|
|
|
* @return string instructions
|
|
|
|
*/
|
2020-06-08 18:25:01 +09:00
|
|
|
public function getInstructions()
|
2010-06-14 04:23:23 +09:00
|
|
|
{
|
2010-10-04 06:54:57 +09:00
|
|
|
// TRANS: Instructions for sitemap.
|
|
|
|
return _m('Sitemap settings for this StatusNet site');
|
2010-06-14 04:23:23 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the site admin panel form
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2020-06-08 18:25:01 +09:00
|
|
|
public function showForm()
|
2010-06-14 04:23:23 +09:00
|
|
|
{
|
|
|
|
$form = new SitemapAdminPanelForm($this);
|
|
|
|
$form->show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save settings from the form
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2020-06-08 18:25:01 +09:00
|
|
|
public function saveSettings()
|
2010-06-14 04:23:23 +09:00
|
|
|
{
|
2016-03-20 22:06:58 +09:00
|
|
|
static $settings = array('sitemap' => array('yahookey', 'bingkey'));
|
2010-06-14 04:23:23 +09:00
|
|
|
|
|
|
|
$values = array();
|
|
|
|
|
|
|
|
foreach ($settings as $section => $parts) {
|
|
|
|
foreach ($parts as $setting) {
|
|
|
|
$values[$section][$setting] = $this->trimmed($setting);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// This throws an exception on validation errors
|
|
|
|
$this->validate($values);
|
|
|
|
|
|
|
|
// assert(all values are valid);
|
|
|
|
|
|
|
|
$config = new Config();
|
|
|
|
|
2020-06-08 18:25:01 +09:00
|
|
|
$config->query('START TRANSACTION');
|
2010-06-14 04:23:23 +09:00
|
|
|
|
|
|
|
foreach ($settings as $section => $parts) {
|
|
|
|
foreach ($parts as $setting) {
|
|
|
|
Config::save($section, $setting, $values[$section][$setting]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$config->query('COMMIT');
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-06-08 18:25:01 +09:00
|
|
|
public function validate(&$values)
|
2010-06-14 04:23:23 +09:00
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Form for the sitemap admin panel
|
|
|
|
*/
|
|
|
|
class SitemapAdminPanelForm extends AdminForm
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* ID of the form
|
|
|
|
*
|
|
|
|
* @return int ID of the form
|
|
|
|
*/
|
2020-06-08 18:25:01 +09:00
|
|
|
public function id()
|
2010-06-14 04:23:23 +09:00
|
|
|
{
|
|
|
|
return 'form_sitemap_admin_panel';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* class of the form
|
|
|
|
*
|
|
|
|
* @return string class of the form
|
|
|
|
*/
|
2020-06-08 18:25:01 +09:00
|
|
|
public function formClass()
|
2010-06-14 04:23:23 +09:00
|
|
|
{
|
|
|
|
return 'form_sitemap';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Action of the form
|
|
|
|
*
|
|
|
|
* @return string URL of the action
|
|
|
|
*/
|
2020-06-08 18:25:01 +09:00
|
|
|
public function action()
|
2010-06-14 04:23:23 +09:00
|
|
|
{
|
|
|
|
return common_local_url('sitemapadminpanel');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Data elements of the form
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2020-06-08 18:25:01 +09:00
|
|
|
public function formData()
|
2010-06-14 04:23:23 +09:00
|
|
|
{
|
|
|
|
$this->out->elementStart('ul', 'form_data');
|
|
|
|
$this->li();
|
2020-06-08 18:25:01 +09:00
|
|
|
$this->input(
|
|
|
|
'yahookey',
|
|
|
|
// TRANS: Field label.
|
|
|
|
_m('Yahoo key'),
|
|
|
|
// TRANS: Title for field label.
|
|
|
|
_m('Yahoo! Site Explorer verification key.'),
|
|
|
|
'sitemap'
|
|
|
|
);
|
2010-06-14 04:23:23 +09:00
|
|
|
$this->unli();
|
|
|
|
$this->li();
|
2020-06-08 18:25:01 +09:00
|
|
|
$this->input(
|
|
|
|
'bingkey',
|
|
|
|
// TRANS: Field label.
|
|
|
|
_m('Bing key'),
|
|
|
|
// TRANS: Title for field label.
|
|
|
|
_m('Bing Webmaster Tools verification key.'),
|
|
|
|
'sitemap'
|
|
|
|
);
|
2010-06-14 04:23:23 +09:00
|
|
|
$this->unli();
|
|
|
|
$this->out->elementEnd('ul');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Action elements
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2020-06-08 18:25:01 +09:00
|
|
|
public function formActions()
|
2010-06-14 04:23:23 +09:00
|
|
|
{
|
2020-06-08 18:25:01 +09:00
|
|
|
$this->out->submit(
|
|
|
|
'submit',
|
|
|
|
// TRANS: Submit button text to save sitemap settings.
|
|
|
|
_m('BUTTON', 'Save'),
|
|
|
|
'submit',
|
|
|
|
null,
|
|
|
|
// TRANS: Submit button title to save sitemap settings.
|
|
|
|
_m('Save sitemap settings.')
|
|
|
|
);
|
2010-06-14 04:23:23 +09:00
|
|
|
}
|
|
|
|
}
|