Changeset 545
- Timestamp:
- 11/04/08 20:58:41 (15 years ago)
- google:author:
- appears
- Location:
- plugins/contribute
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/contribute/TODO
r540 r545 1 * régler le problème avec la valeur cat_id vide2 * insérer les coordonnées des auteurs en s'inspirant du plugin planet3 1 * insérer la barre d'édition riche 4 * améliorer l'affichage du widget5 * afficher nom complet des utilisateurs dans l'administration6 * filtrer les utilisateurs qui ont des droits sur le blog ? -
plugins/contribute/_admin.php
r540 r545 27 27 array('contributeAdmin','adminBlogPreferencesForm')); 28 28 29 $core->addBehavior('adminPostFormSidebar', 30 array('contributeAdmin','adminPostFormSidebar')); 31 29 32 $core->addBehavior('initWidgets',array('contributeAdmin','initWidgets')); 30 33 … … 49 52 (!empty($_POST['contribute_user']) ? $_POST['contribute_user'] : ''), 50 53 'string', 'user'); 51 # inspirated fromlightbox/admin.php54 # inspirated by lightbox/admin.php 52 55 $settings->setNameSpace('system'); 53 56 } … … 66 69 while ($rs->fetch()) 67 70 { 68 // $users[$rs->user_id] = $rs->user_displayname; 69 $users[$rs->user_id.(($rs->user_id == $core->auth->userID()) 71 $name = $rs->user_id.' '. 72 ((strlen($rs->user_displayname) > 1) ? 73 '('.$rs->user_displayname.') ' : ''). 74 $rs->user_firstname.' '.$rs->user_name; 75 76 $users[$name.(($rs->user_id == $core->auth->userID()) 70 77 ? ' ('.__('me').')' : '')] = $rs->user_id; 71 78 } … … 75 82 : $core->auth->userID()); 76 83 84 $posts = array(); 85 $rs = $core->blog->getPosts(); 86 87 while ($rs->fetch()) 88 { 89 $posts[html::escapeHTML($rs->post_title)] = $rs->post_id; 90 } 91 92 $post = $core->blog->settings->contribute_default_post; 93 77 94 echo '<fieldset>'. 78 '<legend>'. __('Contribute').'</legend>'.95 '<legend>'.('Contribute').'</legend>'. 79 96 '<p>'. 80 97 form::checkbox('contribute_active',1, 81 98 $core->blog->settings->contribute_active). 82 99 '<label class="classic" for="contribute_active">'. 83 sprintf(__('Enable %s'), __('Contribute')).100 sprintf(__('Enable %s'),('Contribute')). 84 101 '</label>'. 85 102 '</p>'. 86 103 '<p class="form-note">'. 87 104 sprintf(__('%s allow visitors to contribute to your blog.'), 88 __('Contribute')).105 ('Contribute')). 89 106 '</p>'. 90 107 '<p>'. … … 94 111 '</label> '. 95 112 '</p>'. 113 '<p>'. 114 '<label for="contribute_default_post">'. 115 __('Default post:'). 116 form::combo('contribute_default_post',$posts,$post). 117 '</label> '. 118 '</p>'. 119 '<p class="form-note">'. 120 __('Create a new post and select it here.').' '. 121 sprintf(__('The post can be %s or %s.'),__('pending'),__('unpublished')). 122 '</p>'. 123 '<p>'. 124 sprintf(__('URL of the %s page:'),('Contribute')). 125 '<br />'. 126 '<code>'.$core->blog->url.$core->url->getBase('contribute').'</code>'. 127 '<br />'. 128 '<a href="'.$core->blog->url.$core->url->getBase('contribute').'">'.sprintf(__('View the %s page'), 129 ('Contribute')).'</a>'. 130 '</p>'. 96 131 '</fieldset>'; 97 132 } 98 133 134 /** 135 adminPostFormSidebar behavior 136 @param settings <b>object</b> Settings 137 */ 138 public static function adminPostFormSidebar(&$post) 139 { 140 $meta = new dcMeta($GLOBALS['core']); 141 142 $author = ($post) ? $meta->getMetaStr($post->post_meta,'contribute_author') : ''; 143 $site = ($post) ? $meta->getMetaStr($post->post_meta,'contribute_site') : ''; 144 145 if (!empty($author)) 146 { 147 echo 148 '<div id="planet-infos">'.'<h3>'.('Contribute').'</h3>'. 149 '<p>'.sprintf(__('Post submitted by %s.'),'<a href="'.$site.'">'.$author.'</a>').'</p>'. 150 '</div>'; 151 } 152 } 153 99 154 /** 100 155 widget … … 105 160 $w->create('contribute',__('Contribute'),array('contributeWidget','show')); 106 161 107 $w->contribute->setting('title',__('Title:'),__('Contribute'),'text'); 108 162 $w->contribute->setting('title',__('Title:').' ('.__('optional').')', 163 __('Contribute'),'text'); 164 165 $w->contribute->setting('text',__('Text:').' ('.__('optional').')', 166 __('Write a post for this blog'),'text'); 167 109 168 $w->contribute->setting('homeonly',__('Home page only'),false,'check'); 110 169 } -
plugins/contribute/_define.php
r540 r545 26 26 /* Description*/ "Allow visitors to contribute to your blog", 27 27 /* Author */ "Moe (http://gniark.net/)", 28 /* Version */ '0. 1',28 /* Version */ '0.2', 29 29 /* Permissions */ 'admin,contentadmin' 30 30 ); -
plugins/contribute/_public.php
r540 r545 22 22 if (!defined('DC_RC_PATH')) { return; } 23 23 24 25 # load locales for the blog language 26 l10n::set(dirname(__FILE__).'/locales/'.$core->blog->settings->lang.'/public'); 24 $core->addBehavior('coreBlogGetPosts',array('contributeBehaviors','coreBlogGetPosts')); 27 25 28 26 /** … … 40 38 global $core; 41 39 42 if (!$core->blog->settings-> noname_active) {self::p404();}40 if (!$core->blog->settings->contribute_active) {self::p404();} 43 41 44 42 # start session … … 49 47 50 48 $_ctx->contribute = new ArrayObject(); 51 $_ctx->contribute->message = $_ctx->contribute->error ='';49 $_ctx->contribute->message = ''; 52 50 $_ctx->contribute->preview = false; 53 51 $_ctx->contribute->form = true; … … 55 53 $_ctx->comment_preview = new ArrayObject(); 56 54 $_ctx->comment_preview['name'] = __('Anonymous'); 57 $_ctx->comment_preview['mail'] = $_ctx->comment_preview['site'] = ''; 58 59 60 try 61 { 62 # this may be dangerous 63 $_ctx->posts = $core->blog->getPosts(array('post_id' => -1)); 64 65 $post =& $_ctx->posts; 66 67 $post->post_dt = date('Y-m-d H:i:00'); 68 $post->post_title = ((isset($_POST['post_title'])) ? $_POST['post_title'] : ''); 69 $post->cat_id = ((isset($_POST['cat_id'])) ? $_POST['cat_id'] : ''); 70 71 if (($post->cat_id != '') && (!preg_match('/^[0-9]+$/',$post->cat_id))) 55 $_ctx->comment_preview['site'] = ''; 56 57 if ((isset($_GET['message'])) && ($_GET['message'] == 'ok')) 58 { 59 $_ctx->contribute->message = __('The post has been saved.').' '. 60 __('It needs to be approved by the administrator to appear on the blog.'); 61 $_ctx->contribute->preview = false; 62 $_ctx->contribute->form = false; 63 } 64 else 65 { 66 try 72 67 { 73 $_ctx->contribute->error = __('Invalid cat_id'); 74 } 75 $post->post_excerpt_xhtml = ((isset($_POST['post_excerpt'])) ? $core->wikiTransform($_POST['post_excerpt']) : ''); 76 $post->post_excerpt_wiki = ((isset($_POST['post_excerpt'])) ? $_POST['post_excerpt'] : ''); 77 $post->post_content_xhtml = ((isset($_POST['post_content'])) ? $core->wikiTransform($_POST['post_content']) : ''); 78 $post->post_content_wiki = ((isset($_POST['post_content'])) ? $_POST['post_content'] : ''); 79 80 if (isset($_POST['preview'])) 81 { 82 if (!isset($_POST['post_title']) || empty($_POST['post_title'])) 83 { 84 $_ctx->contribute->error = __('No entry title'); 85 } elseif (!isset($_POST['post_content']) || empty($_POST['post_content'])) 86 { 87 $_ctx->contribute->error = __('No entry content'); 68 # get default post 69 $_ctx->posts = $core->auth->sudo(array($core->blog,'getPosts'), 70 array('post_id' => $core->blog->settings->contribute_default_post)); 71 72 # modify $_ctx->posts for preview 73 $post =& $_ctx->posts; 74 75 $post->post_excerpt_wiki = $post->post_excerpt; 76 $post->post_content_wiki = $post->post_content; 77 $post->post_dt = dt::str('%Y-%m-%d %T',null, 78 $core->blog->settings->blog_timezone); 79 80 if (isset($_POST['post_title'])) 81 { 82 $post->post_title = $_POST['post_title']; 83 } 84 if (isset($_POST['cat_id'])) 85 { 86 $post->cat_id = $_POST['cat_id']; 87 } 88 89 # excerpt and content 90 if (isset($_POST['post_excerpt'])) 91 { 92 $post->post_excerpt_xhtml = 93 $core->wikiTransform($_POST['post_excerpt']); 94 } 95 if (isset($_POST['post_excerpt'])) 96 { 97 $post->post_excerpt_wiki = $_POST['post_excerpt']; 98 } 99 if (isset($_POST['post_content'])) 100 { 101 $post->post_content_xhtml = 102 $core->wikiTransform($_POST['post_content']); 103 } 104 if (isset($_POST['post_content'])) 105 { 106 $post->post_content_wiki = $_POST['post_content']; 107 } 108 109 if (($post->cat_id != '') && (!preg_match('/^[0-9]+$/',$post->cat_id))) 110 { 111 $_ctx->form_error = __('Invalid cat_id'); 112 } 113 114 $post_title = $post->post_title; 115 $post_content = $post->post_content; 116 if (empty($post_title)) 117 { 118 $_ctx->form_error = __('No entry title'); 119 } elseif (empty($post_content)) 120 { 121 $_ctx->form_error = __('No entry content'); 88 122 } else { 89 123 $_ctx->contribute->preview = true; 90 $_ctx->contribute->message = __('This is a preview. Save it when the post is ready to be published.'); 91 } 92 93 $_ctx->comment_preview['name'] = ((isset($_POST['c_name'])) ? $_POST['c_name'] : ''); 94 $_ctx->comment_preview['mail'] = ((isset($_POST['c_mail'])) ? $_POST['c_mail'] : ''); 95 $_ctx->comment_preview['site'] = ((isset($_POST['c_site'])) ? $_POST['c_site'] : ''); 96 97 } elseif (isset($_POST['add'])) { 98 $core->auth->checkUser($core->blog->settings->noname_user); 99 100 $cur = $core->con->openCursor($core->prefix.'post'); 101 102 $cur->user_id = $core->auth->userID(); 103 $cur->cat_id = $post->cat_id; 104 $cur->post_dt = date('Y-m-d H:i:00'); 105 $cur->post_format = 'wiki'; 106 $cur->post_status = -2; 107 $cur->post_title = $post->post_title; 108 $cur->post_excerpt = $post->post_excerpt_wiki; 109 $cur->post_content = $post->post_content_wiki; 110 111 # --BEHAVIOR-- adminBeforePostCreate 112 $core->callBehavior('adminBeforePostCreate',$cur); 113 114 $return_id = $core->blog->addPost($cur); 115 116 # --BEHAVIOR-- adminAfterPostCreate 117 $core->callBehavior('adminAfterPostCreate',$cur,$return_id); 118 119 if (is_int($return_id)) 120 { 121 $_ctx->contribute->message = __('The post has been saved. It needs to be approved by the administrator to appear on the blog.'); 122 $_ctx->contribute->preview = false; 123 $_ctx->contribute->form = false; 124 $_ctx->contribute->message =__('This is a preview.'). 125 __(' Save it when the post is ready to be published.'); 126 } 127 128 if (isset($_POST['c_name'])) 129 { 130 $_ctx->comment_preview['name'] = $post->user_displayname = $_POST['c_name']; 131 132 } 133 if (isset($_POST['c_site'])) 134 { 135 $_ctx->comment_preview['site'] = $post->user_url = $_POST['c_site']; 136 } 137 138 if (isset($_POST['add'])) 139 { 140 $core->auth->checkUser($core->blog->settings->contribute_user); 141 142 $cur = $core->con->openCursor($core->prefix.'post'); 143 144 $cur->user_id = $core->auth->userID(); 145 $cur->cat_id = $post->cat_id; 146 if (empty($post->cat_id)) 147 { 148 $cur->cat_id = NULL; 149 } 150 $cur->post_dt = $post->post_dt; 151 $cur->post_format = 'wiki'; 152 $cur->post_status = -2; 153 $cur->post_title = $post->post_title; 154 $cur->post_excerpt = $post->post_excerpt_wiki; 155 $cur->post_content = $post->post_content_wiki; 156 $cur->post_lang = $core->auth->getInfo('user_lang'); 157 $cur->post_open_comment = (integer) $core->blog->settings->allow_comments; 158 $cur->post_open_tb = (integer) $core->blog->settings->allow_trackbacks; 159 160 # --BEHAVIOR-- adminBeforePostCreate 161 $core->callBehavior('adminBeforePostCreate',$cur); 162 163 $post_id = $core->blog->addPost($cur); 164 165 # --BEHAVIOR-- adminAfterPostCreate 166 $core->callBehavior('adminAfterPostCreate',$cur,$post_id); 167 168 # inspirated by planet/insert_feeds.php 169 $meta = new dcMeta($core); 170 171 $meta->setPostMeta($post_id,'contribute_author', 172 $_ctx->comment_preview['name']); 173 $meta->setPostMeta($post_id,'contribute_site', 174 $_ctx->comment_preview['site']); 175 176 if (is_int($post_id)) 177 { 178 $separator = '?'; 179 if ($core->blog->settings->url_scan == 'query_string') 180 {$separator = '&';} 181 182 http::redirect($core->blog->url.$core->url->getBase('contribute'). 183 $separator.'message=ok'); 184 } 124 185 } 125 186 } 126 }127 catch (Exception $e)128 {129 $_ctx->contribute->error = $e->getMessage();187 catch (Exception $e) 188 { 189 $_ctx->form_error = $e->getMessage(); 190 } 130 191 } 131 192 … … 133 194 dirname(__FILE__).'/default-templates/'); 134 195 135 self::serveDocument('contribute.html','text/html' ,false,false/* // debug mode */);196 self::serveDocument('contribute.html','text/html'); 136 197 } 137 198 } … … 140 201 $core->tpl->addBlock('ContributeIfMessage',array('contributeTpl','ifMessage')); 141 202 $core->tpl->addValue('ContributeMessage',array('contributeTpl','message')); 142 143 # error144 $core->tpl->addBlock('ContributeIfError',array('contributeTpl','ifError'));145 $core->tpl->addValue('ContributeError',array('contributeTpl','error'));146 203 147 204 $core->tpl->addBlock('ContributePreview',array('contributeTpl','preview')); … … 186 243 187 244 /** 188 if there is an error189 @param attr <b>array</b> Attribute190 @param content <b>string</b> Content191 @return <b>string</b> PHP block192 */193 public static function ifError($attr,$content)194 {195 return196 "<?php if (\$_ctx->contribute->error != '') : ?>"."\n".197 $content.198 "<?php endif; ?>";199 }200 201 /**202 display an error203 @param attr <b>array</b> Attribute204 @return <b>string</b> PHP block205 */206 public static function error($attr)207 {208 $f = $GLOBALS['core']->tpl->getFilters($attr);209 210 return("<?php if (\$_ctx->contribute->error != '') :"."\n".211 'echo('.sprintf($f,'$_ctx->contribute->error').');'.212 "endif; ?>");213 }214 215 /**216 245 display preview 217 246 @param attr <b>array</b> Attribute … … 269 298 return('<?php echo($_ctx->categories->cat_id); ?>'); 270 299 } 271 272 300 } 273 301 … … 293 321 # output 294 322 $header = (strlen($w->title) > 0) 295 ? '<h2><a href="'.$core->blog->url.$core->url->getBase('contribute'). 296 '">'.html::escapeHTML($w->title).'</a></h2>' : null; 297 298 return '<div class="dlmanager">'.$header.'</div>'; 299 } 300 } 301 323 ? '<h2>'.html::escapeHTML($w->title).'</h2>' : null; 324 $text = (strlen($w->text) > 0) 325 ? '<p class="text"><a href="'.$core->blog->url.$core->url->getBase('contribute'). 326 '">'.html::escapeHTML($w->text).'</a></p>' : null; 327 328 return '<div class="dlmanager">'.$header.$text.'</div>'; 329 } 330 } 331 332 /** 333 @ingroup Contribute 334 @brief Behaviors 335 @see planet/insert_feeds.php 336 */ 337 class contributeBehaviors 338 { 339 public static function coreBlogGetPosts(&$rs) 340 { 341 $rs->extend('rsExtContributePosts'); 342 } 343 } 344 345 class rsExtContributePosts extends rsExtPost 346 { 347 public static function contributeInfo(&$rs,$info) 348 { 349 return dcMeta::getMetaRecord($rs->core,$rs->post_meta,'contribute_'.$info)->meta_id; 350 } 351 352 public static function getAuthorLink(&$rs) 353 { 354 $author = $rs->contributeInfo('author'); 355 $site = $rs->contributeInfo('site'); 356 357 # default display 358 if (empty($author)) 359 { 360 return(parent::getAuthorLink($rs)); 361 } 362 else 363 { 364 $str = $author; 365 if (!empty($site)) 366 { 367 $str = '<a href="'.$site.'">'.$str.'</a> ('.__('contributor').')'; 368 } 369 return $str; 370 } 371 } 372 373 public static function getAuthorCN(&$rs) 374 { 375 $author = $rs->contributeInfo('author'); 376 if (empty($author)) 377 { 378 # default display 379 return(parent::getAuthorCN($rs)); 380 } else { 381 return $author; 382 } 383 } 384 } 302 385 ?> -
plugins/contribute/default-templates/contribute.html
r540 r545 54 54 </tpl:ContributeIfMessage> 55 55 56 <tpl:ContributeIfError> 57 <div class="error"> 58 {{tpl:ContributeError}} 59 </div> 60 </tpl:ContributeIfError> 61 56 <tpl:SysIfFormError> 57 <div class="error">{{tpl:SysFormError}}</div> 58 </tpl:SysIfFormError> 59 62 60 <tpl:ContributePreview> 63 61 <div class="post"> … … 130 128 </p> 131 129 132 <p class="field"><label for="c_mail">{{tpl:lang Email address}}133 ({{tpl:lang optional}}) :</label>134 <input name="c_mail" id="c_mail" type="text" size="30" maxlength="255"135 value="{{tpl:CommentPreviewEmail encode_html="1"}}" />136 </p>137 138 130 <p class="field"><label for="c_site">{{tpl:lang Website}} 139 131 ({{tpl:lang optional}}) :</label> -
plugins/contribute/locales/fr/main.po
r540 r545 1 1 msgid "" 2 2 msgstr "" 3 "Project-Id-Version: NoName\n"3 "Project-Id-Version: Contribute\n" 4 4 "Report-Msgid-Bugs-To: \n" 5 "POT-Creation-Date: 2008-1 0-31 02:20+0100\n"6 "PO-Revision-Date: 2008-1 0-31 02:21+0100\n"5 "POT-Creation-Date: 2008-11-04 16:59+0100\n" 6 "PO-Revision-Date: 2008-11-04 16:59+0100\n" 7 7 "Last-Translator: Moe <poedit@gniark.net>\n" 8 8 "Language-Team: Moe <poedit@gniark.net>\n" … … 17 17 "X-Poedit-SearchPath-0: .\n" 18 18 19 #: _admin.php:70 19 #: _public.php:54 20 msgid "Anonymous" 21 msgstr "Anonyme" 22 23 #: _public.php:59 24 msgid "The post has been saved." 25 msgstr "Le billet a été sauvegardé." 26 27 #: _public.php:60 28 msgid "It needs to be approved by the administrator to appear on the blog." 29 msgstr "Il faut qu'il soit approuvé par un administrateur pour apparaître sur le blog." 30 31 #: _public.php:111 32 msgid "Invalid cat_id" 33 msgstr "cat_id invalide" 34 35 #: _public.php:118 36 msgid "No entry title" 37 msgstr "Pas de titre de billet" 38 39 #: _public.php:121 40 msgid "No entry content" 41 msgstr "Pas de contenu de billet" 42 43 #: _public.php:124 44 msgid "This is a preview." 45 msgstr "Ceci est un aperçu." 46 47 #: _public.php:125 48 msgid " Save it when the post is ready to be published." 49 msgstr "Enregistrez-le quand le billet est prêt à être publié." 50 51 #: _public.php:399 52 msgid "contributor" 53 msgstr "contributeur" 54 55 #: _admin.php:77 20 56 msgid "me" 21 57 msgstr "moi" 22 58 23 #: _admin.php:78 24 #: _admin.php:83 25 #: _admin.php:88 26 #: _admin.php:105 27 #: _admin.php:107 28 msgid "Contribute" 29 msgstr "Contribuer" 30 31 #: _admin.php:83 59 #: _admin.php:100 32 60 #, php-format 33 61 msgid "Enable %s" 34 62 msgstr "Activer %s" 35 63 36 #: _admin.php: 8764 #: _admin.php:104 37 65 #, php-format 38 66 msgid "%s allow visitors to contribute to your blog." 39 67 msgstr "%s permet aux visiteurs de contribuer à votre blog." 40 68 41 #: _admin.php: 9269 #: _admin.php:109 42 70 msgid "Owner of the posts:" 43 msgstr "Propriétaire des billets 71 msgstr "Propriétaire des billets :" 44 72 45 #: _admin.php:107 73 #: _admin.php:115 74 msgid "Default post:" 75 msgstr "Billet par défaut :" 76 77 #: _admin.php:120 78 msgid "Create a new post and select it here." 79 msgstr "Créez un nouveau billet et sélectionnez-le ici." 80 81 #: _admin.php:121 82 #, php-format 83 msgid "The post can be %s or %s." 84 msgstr "Le billet peut être %s ou %s." 85 86 #: _admin.php:121 87 msgid "pending" 88 msgstr "" 89 90 #: _admin.php:121 91 msgid "unpublished" 92 msgstr "" 93 94 #: _admin.php:124 95 #, php-format 96 msgid "URL of the %s page:" 97 msgstr "URL de la page %s :" 98 99 #: _admin.php:128 100 #, php-format 101 msgid "View the %s page" 102 msgstr "Voir la page %s" 103 104 #: _admin.php:149 105 #, php-format 106 msgid "by %s" 107 msgstr "par %s" 108 109 #: _admin.php:160 110 #: _admin.php:163 111 msgid "Contribute" 112 msgstr "Contribuer" 113 114 #: _admin.php:162 46 115 msgid "Title:" 47 116 msgstr "Titre :" 48 117 49 #: _admin.php:109 118 #: _admin.php:162 119 #: _admin.php:165 120 msgid "optional" 121 msgstr "" 122 123 #: _admin.php:165 124 msgid "Text:" 125 msgstr "" 126 127 #: _admin.php:166 128 msgid "Write a post for this blog" 129 msgstr "Écrire un billet pour ce blog" 130 131 #: _admin.php:168 50 132 msgid "Home page only" 51 133 msgstr "" 52 53 #: _public.php:5654 msgid "Anonymous"55 msgstr "Anonyme"56 57 #: _public.php:7358 msgid "Invalid cat_id"59 msgstr "cat_id invalide"60 61 #: _public.php:8462 msgid "No entry title"63 msgstr "Pas de titre de billet"64 65 #: _public.php:8766 msgid "No entry content"67 msgstr "Pas de contenu de billet"68 69 #: _public.php:9070 msgid "This is a preview. Save it when the post is ready to be published."71 msgstr "Ceci est un aperçu. Sauvegardez-le quand le billet est prêt à être publié."72 73 #: _public.php:12174 msgid "The post has been saved. It needs to be approved by the administrator to appear on the blog."75 msgstr "Le billet a été sauvegardé. Il faut qu'il soit approuvé par un administrateur pour apparaître sur le blog."76 134 77 135 #: public_l10n.php:2 … … 82 140 msgid "Category" 83 141 msgstr "Catégorie" 142
Note: See TracChangeset
for help on using the changeset viewer.