Dotclear

source: plugins/entryCSS/_admin.php @ 1683

Revision 1683, 1.9 KB checked in by kozlika, 14 years ago (diff)

Typo, suppression de lignes vides en fin de fichiers .php, ajout du ?> manquant.

  • Property svn:executable set to *
Line 
1<?php
2# -- BEGIN LICENSE BLOCK ----------------------------------
3# This file is part of entryCSS, a plugin for Dotclear.
4#
5# Copyright (c) 2009 - annso
6# contact@as-i-am.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
13if (!defined('DC_CONTEXT_ADMIN')) { return; }
14
15$core->addBehavior('adminPostForm', array('adminEntryCSS','cssForm'));
16$core->addBehavior('adminPageForm', array('adminEntryCSS','cssForm'));
17
18$core->addBehavior('adminAfterPageCreate',array('adminEntryCSS','setCSS'));
19$core->addBehavior('adminAfterPageUpdate',array('adminEntryCSS','setCSS'));
20$core->addBehavior('adminAfterPostCreate',array('adminEntryCSS','setCSS'));
21$core->addBehavior('adminAfterPostUpdate',array('adminEntryCSS','setCSS'));
22
23
24# BEHAVIORS
25class adminEntryCSS
26{
27     //print_r($post);
28     public static function cssForm(&$post)
29     {
30          global $core;
31         
32          $params = new ArrayObject();
33         
34          if (!empty($_REQUEST['id'])) {
35               $params['post_id'] = $_REQUEST['id'];
36               $params['columns'] = array('post_css');
37               if (preg_match('/plugin.php\?p=pages(&.*)?$/',$_SERVER['REQUEST_URI'])) {
38                    $params['post_type'] = 'page';
39               }
40               $post = $core->blog->getPosts($params);
41               $value = $post->post_css;
42          } else {
43               $value = '';
44          }
45         
46          $res = '';
47          $res .= '<p class="area"><label for="entry_css"><strong>'.__('CSS :').'</strong></label>';
48          $res .= form::textarea('entry_css',50,5,$value);
49          $res .= '</p>';
50         
51          if (preg_match('/plugin.php\?p=pages(&.*)?$/',$_SERVER['REQUEST_URI'])) {
52               return $res;
53          } else {
54               echo $res;
55          }
56     }
57     
58     public static function setCSS(&$cur,&$post_id)
59     {
60          if (!empty($_POST['entry_css'])) {
61               $cur = $GLOBALS['core']->con->openCursor($GLOBALS['core']->prefix.'post');
62               $cur->post_css = $_POST['entry_css'];
63               $cur->update('WHERE post_id = '.$post_id.';');
64          }
65     }
66}
67?>
Note: See TracBrowser for help on using the repository browser.

Sites map