| 1 | <?php |
|---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
|---|
| 3 | # |
|---|
| 4 | # This file is part of Dotclear 2. |
|---|
| 5 | # |
|---|
| 6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
|---|
| 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 ----------------------------------------- |
|---|
| 12 | if (!defined('DC_CONTEXT_ADMIN')) { return; } |
|---|
| 13 | |
|---|
| 14 | $_menu['Blog']->addItem(__('Pings'), |
|---|
| 15 | $core->adminurl->get('admin.plugin.pings'), |
|---|
| 16 | dcPage::getPF('pings/icon.png'), |
|---|
| 17 | preg_match('/'.preg_quote($core->adminurl->get('admin.plugin.pings')).'/',$_SERVER['REQUEST_URI']), |
|---|
| 18 | $core->auth->isSuperAdmin()); |
|---|
| 19 | |
|---|
| 20 | $__autoload['pingsAPI'] = dirname(__FILE__).'/lib.pings.php'; |
|---|
| 21 | $__autoload['pingsBehaviors'] = dirname(__FILE__).'/lib.pings.php'; |
|---|
| 22 | |
|---|
| 23 | # Create settings if they don't exist |
|---|
| 24 | if (!array_key_exists('pings',$core->blog->settings->dumpNamespaces())) |
|---|
| 25 | { |
|---|
| 26 | $default_pings_uris = array( |
|---|
| 27 | 'Ping-o-Matic!' => 'http://rpc.pingomatic.com/', |
|---|
| 28 | 'Google Blog Search' => 'http://blogsearch.google.com/ping/RPC2' |
|---|
| 29 | ); |
|---|
| 30 | |
|---|
| 31 | $core->blog->settings->addNamespace('pings'); |
|---|
| 32 | $core->blog->settings->pings->put('pings_active',1,'boolean','Activate pings plugin',true,true); |
|---|
| 33 | $core->blog->settings->pings->put('pings_uris',$default_pings_uris,'array','Pings services URIs',true,true); |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | $core->addBehavior('adminPostHeaders',array('pingsBehaviors','pingJS')); |
|---|
| 37 | $core->addBehavior('adminPostFormItems',array('pingsBehaviors','pingsFormItems')); |
|---|
| 38 | $core->addBehavior('adminAfterPostCreate',array('pingsBehaviors','doPings')); |
|---|
| 39 | $core->addBehavior('adminAfterPostUpdate',array('pingsBehaviors','doPings')); |
|---|
| 40 | |
|---|
| 41 | $core->addBehavior('adminDashboardFavorites','pingDashboardFavorites'); |
|---|
| 42 | |
|---|
| 43 | function pingDashboardFavorites($core,$favs) |
|---|
| 44 | { |
|---|
| 45 | $favs->register('pings', array( |
|---|
| 46 | 'title' => __('Pings'), |
|---|
| 47 | 'url' => $core->adminurl->get('admin.plugin.pings'), |
|---|
| 48 | 'small-icon' => dcPage::getPF('pings/icon.png'), |
|---|
| 49 | 'large-icon' => dcPage::getPF('pings/icon-big.png'), |
|---|
| 50 | )); |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | $core->addBehavior('adminPageHelpBlock', 'pingsPageHelpBlock'); |
|---|
| 54 | |
|---|
| 55 | function pingsPageHelpBlock($blocks) |
|---|
| 56 | { |
|---|
| 57 | $found = false; |
|---|
| 58 | foreach($blocks as $block) { |
|---|
| 59 | if ($block == 'core_post') { |
|---|
| 60 | $found = true; |
|---|
| 61 | break; |
|---|
| 62 | } |
|---|
| 63 | } |
|---|
| 64 | if (!$found) { |
|---|
| 65 | return null; |
|---|
| 66 | } |
|---|
| 67 | $blocks[] = 'pings_post'; |
|---|
| 68 | } |
|---|