Dotclear

source: plugins/dcRevisions/inc/class.dc.revisions.behaviors.php @ 338:2d7dcf33cd6f

Revision 338:2d7dcf33cd6f, 1.9 KB checked in by sacha, 14 years ago (diff)

Added dcRevisions plugin

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ----------------------------------
3# This file is part of dcRevisions, a plugin for Dotclear.
4#
5# Copyright (c) 2010 Tomtom and contributors
6# http://blog.zenstyle.fr/
7#
8# Licensed under the GPL version 2.0 license.
9# A copy of this license is available in LICENSE file or at
10# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
11# -- END LICENSE BLOCK ------------------------------------
12
13class dcRevisionsBehaviors
14{
15     public static function adminPostForm($post)
16     {
17          global $core;
18         
19          $id = isset($post) && !$post->isEmpty() ? $post->post_id : null;
20          $page = isset($_GET['page']) ? $_GET['page'] : 1;
21          $url = sprintf('post.php?id=%1$s&amp;patch=%2$s',$id,'%s');
22         
23          $params = array(
24               'post_id' => $id
25          );
26         
27          $rs = $core->blog->revisions->getRevisions($params);
28         
29          if (is_null($id)) {
30               $rs = staticRecord::newFromArray(array());
31               $rs->core = $core;
32          }
33         
34          $list = new dcRevisionsList($rs);
35         
36          echo '<div class="area" id="revisions-area"><label>'.__('Revisions:').'</label>'.
37          $list->display($url).
38          '</div>';
39     }
40     
41     public static function adminPostHeaders()
42     {
43          return
44          '<script type="text/javascript">'."\n".
45          "//<![CDATA[\n".
46          dcPage::jsVar('dotclear.msg.excerpt',__('Excerpt')).
47          dcPage::jsVar('dotclear.msg.content',__('Content')).
48          dcPage::jsVar('dotclear.msg.current',__('Current')).
49          dcPage::jsVar('dotclear.msg.confirm_apply_patch',__('Are you sure to want apply this patch on this entry?')).
50          "\n//]]>\n".
51          "</script>\n".
52          '<script type="text/javascript" src="index.php?pf=dcRevisions/js/_revision.js"></script>'."\n".
53          '<link rel="stylesheet" type="text/css" href="index.php?pf=dcRevisions/style.css" />';
54     }
55     
56     public static function adminBeforeUpdate($cur,$post_id)
57     {
58          global $core;
59         
60          try {
61               $core->blog->revisions->addRevision($cur,$post_id);
62          } catch (Exception $e) {
63               $core->error->add($e->getMessage());
64          }
65     }
66}
67
68?>
Note: See TracBrowser for help on using the repository browser.

Sites map