Dotclear

source: admin/trackbacks.php @ 1334:bbbe0735f18b

Revision 1334:bbbe0735f18b, 3.9 KB checked in by franck <carnet.franck.paul@…>, 12 years ago (diff)

New dcPage::breadcrumb function, better way to use it, to be continued by me…

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
7# Licensed under the GPL version 2.0 license.
8# See LICENSE file or
9# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10#
11# -- END LICENSE BLOCK -----------------------------------------
12
13require dirname(__FILE__).'/../inc/admin/prepend.php';
14
15dcPage::check('usage,contentadmin');
16
17# Check if post exists and is online
18$id = !empty($_REQUEST['id']) ? (integer) $_REQUEST['id'] : null;
19
20$post = null;
21$tb_excerpt = $tb_urls = '';
22$auto_link = '';
23$can_view_page = true;
24
25# Check if post exists
26if ($id !== null)
27{
28     $params['post_id'] = $id;
29     $params['post_status'] = 1;
30     $post = $core->blog->getPosts($params);
31     
32     if ($post->isEmpty()) {
33          $core->error->add(__('This entry does not exist or is not published'));
34          $can_view_page = false;
35     } else {
36          $TB = new dcTrackback($core);
37          $tb_excerpt = $post->post_excerpt_xhtml.' '.$post->post_content_xhtml;
38          $post_title = $post->post_title;
39          $post_url = $post->getURL();
40     }
41}
42else
43{
44     $core->error->add(__('This entry does not exist.'));
45     $can_view_page = false;
46}
47
48# Change excerpt
49if (!empty($_POST['tb_excerpt'])) {
50     $tb_excerpt = $_POST['tb_excerpt'];
51}
52
53# Sanitize excerpt
54$tb_excerpt = html::clean($tb_excerpt);
55$tb_excerpt = html::decodeEntities($tb_excerpt);
56$tb_excerpt = text::cutString(html::escapeHTML($tb_excerpt),255);
57$tb_excerpt = preg_replace('/\s+/ms',' ',$tb_excerpt);
58
59# Send pings
60if ($post && !$post->isEmpty() && !empty($_POST['tb_urls']))
61{
62     $tb_urls = $_POST['tb_urls'];
63     $tb_urls = str_replace("\r",'',$tb_urls);
64     
65     $post_title = html::escapeHTML(trim(html::clean($post_title)));
66     
67     foreach (explode("\n",$tb_urls) as $tb_url)
68     {
69          try {
70               $TB->ping($tb_url,$id,$post_title,$tb_excerpt,$post_url);
71          } catch (Exception $e) {
72               $core->error->add($e->getMessage());
73          }
74     }
75     
76     if (!$core->error->flag()) {
77          http::redirect('trackbacks.php?id='.$id.'&sent=1');
78     }
79}
80
81$page_title = __('Ping blogs');
82
83/* DISPLAY
84-------------------------------------------------------- */
85dcPage::open($page_title,dcPage::jsLoad('js/_trackbacks.js'));
86
87# Exit if we cannot view page
88if (!$can_view_page) {
89     dcPage::close();
90     exit;
91}
92
93if (!empty($_GET['sent'])) {
94     dcPage::message(__('All pings sent.'));
95}
96
97dcPage::breadcrumb(
98     array(
99          html::escapeHTML($core->blog->name) => '',
100          '<span class="page-title">'.$page_title.'</span>' => ''
101     ));
102
103echo '<p><a class="back" href="'.$core->getPostAdminURL($post->post_type,$id).'">'.
104     sprintf(__('Back to "%s"'),html::escapeHTML($post->post_title)).'</a></p>';
105
106echo
107'<h3 id="entry-preview-title">'.
108html::escapeHTML($post->post_title).'</h3>'.
109'<div class="frame-shrink" id="entry-preview">'.
110($post->post_excerpt_xhtml ? $post->post_excerpt_xhtml.'<hr />' : '').
111$post->post_content_xhtml.
112'</div>';
113
114if (!empty($_GET['auto'])) {
115     flush();
116     $tb_urls = implode("\n",$TB->discover($post->post_excerpt_xhtml.' '.$post->post_content_xhtml));
117} else {
118     $auto_link = '<strong><a class="button" href="trackbacks.php?id='.$id.'&amp;auto=1">'.
119     __('Auto discover ping URLs').'</a></strong>';
120}
121
122echo
123'<h3>'.__('Ping blogs').'</h3>'.
124'<form action="trackbacks.php" id="trackback-form" method="post">'.
125'<p><label for="tb_urls" class="area">'.__('URLs to ping:').
126form::textarea('tb_urls',60,5,$tb_urls).
127'</label></p>'.
128
129'<p><label for="tb_excerpt" class="area">'.__('Send excerpt:').
130form::textarea('tb_excerpt',60,3,$tb_excerpt).'</label></p>'.
131
132'<p>'.form::hidden('id',$id).
133$core->formNonce().
134'<input type="submit" value="'.__('Ping blogs').'" />&nbsp;&nbsp;'.
135$auto_link.'</p>'.
136'</form>';
137
138$pings = $TB->getPostPings($id);
139
140if (!$pings->isEmpty())
141{
142     echo '<h3>'.__('Previously sent pings').'</h3>';
143     
144     echo '<ul class="nice">';
145     while ($pings->fetch()) {
146          echo
147          '<li>'.dt::dt2str(__('%Y-%m-%d %H:%M'),$pings->ping_dt).' - '.
148          $pings->ping_url.'</li>';
149     }
150     echo '</ul>';
151}
152
153dcPage::close();
154?>
Note: See TracBrowser for help on using the repository browser.

Sites map