Dotclear

source: plugins/meuh/_admin.php @ 2223

Revision 2223, 1.7 KB checked in by bruno, 14 years ago (diff)

New plugin : meuh 0.2

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ----------------------------------
3#
4# This file is part of MEUH,
5# a plugin for DotClear2.
6#
7# Copyright (c) 2010 Bruno Hondelatte and contributors
8#
9# Licensed under the GPL version 2.0 license.
10# See LICENSE file or
11# http://www.gnu.org/licenses/gpl-2.0.txt
12#
13# -- END LICENSE BLOCK ------------------------------------
14if (!defined('DC_RC_PATH')) { return; }
15
16require(dirname(__FILE__).'/class.meuh.php');
17
18# $core->addBehavior('adminAfterPostCreate',array('meuhAdminBehaviors','sanitizeMeuh'));
19$core->addBehavior('adminBeforePostUpdate',array('meuhAdminBehaviors','checkPostUrl'));
20$core->addBehavior('adminPostFormSidebar',array('meuhAdminBehaviors','history'));
21
22class meuhAdminBehaviors 
23{
24     public static function checkPostUrl($cur,$post_id) {
25          $core=$GLOBALS['core'];
26          $dcMeuh = new dcMeuh($core);
27          $rs = $core->blog->getPosts(array('post_id' => $post_id));
28          if ($rs->isEmpty())
29               return;
30          if ($cur->post_url != "" && $rs->post_url !== $cur->post_url) {
31               $dcMeuh->addAlias($rs->post_type, $cur->post_url, $rs->post_url);
32               $dcMeuh->renamePostUrl ($rs->post_type,$rs->post_url,$cur->post_url);
33          }
34     }
35
36     public static function history($post)
37     {
38          $core=$GLOBALS['core'];
39          $dcMeuh = new dcMeuh($core);
40          $rs = $dcMeuh->getAliases($post->post_url);
41          if ($rs->isEmpty())
42               return;
43          echo
44          '<h3><label for="post_url_hist">'.__('URL History:').'</label></h3><ul class="metaList">';
45          while ($rs->fetch()) {
46               echo '<li>'.$rs->meuh_url.
47                    '&nbsp;<a href="plugin.php?p=meuh&amp;m=remove&amp;post_url='.$post->post_url.
48                    '&amp;post_type=post'.
49                    '&amp;meuh_url='.$rs->meuh_url.
50                    '&amp;xd_check='.$core->getNonce().
51                    '" title="'.__("Remove").'" class="metaRemove">[x]</a>'.
52                    '</li>';
53          }
54          echo '</ul>';
55         
56     }
57
58}
59?>
Note: See TracBrowser for help on using the repository browser.

Sites map