Dotclear

source: plugins/contribute/_admin.php @ 1633

Revision 1633, 4.5 KB checked in by kozlika, 14 years ago (diff)

typo

Line 
1<?php
2# ***** BEGIN LICENSE BLOCK *****
3#
4# This file is part of Contribute.
5# Copyright 2008,2009 Moe (http://gniark.net/)
6#
7# Contribute is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 3 of the License, or
10# (at your option) any later version.
11#
12# Contribute is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19#
20# Icon (icon.png) is from Silk Icons : http://www.famfamfam.com/lab/icons/silk/
21#
22# ***** END LICENSE BLOCK *****
23
24if (!defined('DC_CONTEXT_ADMIN')) {return;}
25
26$_menu['Plugins']->addItem(__('Contribute'),
27     'plugin.php?p=contribute',
28     'index.php?pf=contribute/icon.png',
29     preg_match('/plugin.php\?p=contribute(&.*)?$/',$_SERVER['REQUEST_URI']),
30     $core->auth->check('admin',$core->blog->id));
31
32$core->addBehavior('adminPostFormSidebar',
33     array('contributeAdmin','adminPostFormSidebar'));
34
35$core->addBehavior('adminBeforePostUpdate',
36     array('contributeAdmin','adminBeforePostUpdate'));
37
38/**
39@ingroup Contribute
40@brief Admin
41*/
42class contributeAdmin
43{
44     /**
45     adminBeforePostUpdate behavior
46     @param    cur  <b>cursor</b>  Cursor
47     @param    post_id   <b>integer</b> Post ID
48     */
49     public static function adminBeforePostUpdate($cur,$post_id)
50     {
51          $meta = new dcMeta($GLOBALS['core']);
52         
53          try
54          {
55               if (isset($_POST['contribute_author']))
56               {
57                    $meta->delPostMeta($post_id,'contribute_author');
58                    $meta->setPostMeta($post_id,'contribute_author',
59                         $_POST['contribute_author']);
60               }
61               
62               if (isset($_POST['contribute_mail']))
63               {
64                    $meta->delPostMeta($post_id,'contribute_mail');
65                    $meta->setPostMeta($post_id,'contribute_mail',
66                         $_POST['contribute_mail']);
67               }
68               
69               if (isset($_POST['contribute_site']))
70               {
71                    $meta->delPostMeta($post_id,'contribute_site');
72                    $meta->setPostMeta($post_id,'contribute_site',
73                         $_POST['contribute_site']);
74               }   
75          }
76          catch (Exception $e)
77          {
78               $core->error->add($e->getMessage());
79          }
80         
81          if (isset($_POST['contribute_delete_author'])
82               && ($_POST['contribute_delete_author'] == '1'))
83          {
84               try
85               {
86                    $meta->delPostMeta($post_id,'contribute_author');
87                    $meta->delPostMeta($post_id,'contribute_mail');
88                    $meta->delPostMeta($post_id,'contribute_site');
89               }
90               catch (Exception $e)
91               {
92                    $core->error->add($e->getMessage());
93               }
94          }
95     }
96     
97     /**
98     adminPostFormSidebar behavior
99     @param    post <b>cursor</b>  Post
100     */
101     public static function adminPostFormSidebar(&$post)
102     {   
103          $meta = new dcMeta($GLOBALS['core']);
104         
105          $author = ($post) ? $meta->getMetaStr($post->post_meta,'contribute_author') : '';
106          $mail = ($post) ? $meta->getMetaStr($post->post_meta,'contribute_mail') : '';
107          $site = ($post) ? $meta->getMetaStr($post->post_meta,'contribute_site') : '';
108         
109          $str = '';
110         
111          if (!empty($author))
112          {         
113               $str .= '<p>'.
114               '<label class="classic" for="contribute_author">'.
115               __('Author:').
116               form::field('contribute_author',10,255,html::escapeHTML($author),'maximal').
117               '</label>'.
118               '</p>';
119               
120               $str .= '<p>'.
121               '<label class="classic" for="contribute_mail">'.
122               __('Email:').
123               form::field('contribute_mail',10,255,html::escapeHTML($mail),'maximal').
124               '</label>';
125               
126               # mailto: link
127               if ((!empty($mail)) && (text::isEmail($mail)))
128               {
129                    $str .= '<br />'.'<a href="mailto:'.html::escapeHTML($mail).'">'.
130                         __('Send an e-mail').'</a>';
131               }
132               
133               $str .= '</p>';
134               
135               $str .= '<p>'.
136               '<label class="classic" for="contribute_site">'.
137               __('Web site:').
138               form::field('contribute_site',10,255,html::escapeHTML($site),'maximal').
139               '</label>';
140               
141               # display a link to the site
142               # prevent malformed URLs
143               # inspired by /dotclear/inc/clearbricks/net.http/class.net.http.php
144               if (!empty($site))
145               {
146                    $parsed_url = @parse_url($site);
147                    if (($parsed_url !== false) && isset($parsed_url['host']))
148                    {
149                         $str .= '<br />'.'[<a href="'.html::escapeHTML($site).'"'.
150                              ' title="'.html::escapeHTML($site).'">'.
151                              html::escapeHTML($parsed_url['host']).'</a>]';
152                    }
153               }
154               
155               $str .= '</p>';
156               
157               echo
158               '<div id="planet-infos">'.'<h3>'.('Contribute').'</h3>'.
159               $str.
160               '<p>'.
161               '<label class="classic" for="contribute_delete_author">'.
162               form::checkbox('contribute_delete_author',1).
163               __('Delete this author').
164               '</label>'.
165               '</p>'.
166               '</div>';
167          }
168     }
169}
170
171?>
Note: See TracBrowser for help on using the repository browser.

Sites map