/////////////////////////////////////////////////
// PukiWiki - Yet another WikiWikiWeb clone.
//
-// $Id: html.php,v 1.13 2004/11/07 13:09:37 henoheno Exp $
+// $Id: html.php,v 1.14 2004/11/20 04:32:49 henoheno Exp $
//
// ËÜʸ¤ò½ÐÎÏ
return $id;
}
+
+// Separate a page-name(or URL or null string) and an anchor
+// (last one standing) without sharp
+function anchor_explode($page, $strict_editable = FALSE)
+{
+ $pos = strrpos($page, '#');
+ if ($pos === FALSE) return array($page, '', FALSE);
+
+ // Ignore the last sharp letter
+ if ($pos + 1 == strlen($page)) {
+ $pos = strpos(substr($page, $pos + 1), '#');
+ if ($pos === FALSE) return array($page, '', FALSE);
+ }
+
+ $s_page = substr($page, 0, $pos);
+ $anchor = substr($page, $pos + 1);
+
+ if($strict_editable === TRUE && preg_match('/^[a-z][a-f0-9]{7}$/', $anchor)) {
+ return array ($s_page, $anchor, TRUE); // Seems fixed-anchor
+ } else {
+ return array ($s_page, $anchor, FALSE);
+ }
+}
?>
/////////////////////////////////////////////////
// PukiWiki - Yet another WikiWikiWeb clone.
//
-// $Id: edit.inc.php,v 1.19 2004/10/11 02:05:12 henoheno Exp $
+// $Id: edit.inc.php,v 1.20 2004/11/20 04:32:49 henoheno Exp $
//
// Edit plugin
return array('msg'=>$_title_preview, 'body'=>$body);
}
+// Inline: Show edit (or unfreeze text) link
+function plugin_edit_inline()
+{
+ static $usage = '&edit(pagename#anchor[[,noicon],nolabel])[{label}];';
+
+ global $script, $vars;
+ global $_symbol_paraedit, $fixed_heading_anchor_edit;
+
+ // Arguments
+ $args = func_get_args();
+ $s_label = array_pop($args); // {label}
+ $page = array_shift($args);
+ if($page == NULL) $page = '';
+ $_noicon = $_nolabel = FALSE;
+ foreach($args as $arg){
+ switch($arg){
+ case '': break;
+ case 'noicon': $_noicon = TRUE; break;
+ case 'nolabel': $_nolabel = TRUE; break;
+ default: return $usage;
+ }
+ }
+
+ // Separate a page-name and a fixed anchor
+ list($s_page, $id, $editable) = anchor_explode($page, TRUE);
+ // Default: This one
+ if ($s_page == '') $s_page = isset($vars['page']) ? $vars['page'] : '';
+ // $s_page fixed
+ $isfreeze = is_freeze($s_page);
+
+ // Paragraph edit or not
+ $short = htmlspecialchars('Edit');
+ if ($fixed_heading_anchor_edit && $editable === TRUE) {
+ $title = htmlspecialchars(sprintf('Edit %s', $page));
+ $id = rawurlencode($id);
+ $icon = '<img src="' . IMAGE_DIR . 'paraedit.png' .
+ '" width="9" height="9" alt="' .
+ $short . '" title="' . $title . '" /> ';
+ $class = 'anchor_super';
+ } else {
+ $title = htmlspecialchars(sprintf('Edit %s', $s_page));
+ $id = '';
+ $icon = '<img src="' . IMAGE_DIR . 'edit.png' .
+ '" width="20" height="20" alt="' .
+ $short . '" title="' . $title . '" />';
+ $class = '';
+ }
+ if ($_noicon || $isfreeze) $icon = ''; // No more icon
+ if ($_nolabel) {
+ if (!$_noicon) {
+ $s_label = ''; // No label with an icon
+ } else {
+ $s_label = $short; // Short label without an icon
+ }
+ } else {
+ if ($s_label == '') $s_label = $title; // Rich label with an icon
+ }
+
+ // Anchor tag
+ if ($isfreeze) {
+ $title = htmlspecialchars(sprintf('Unfreeze %s', $page));
+ $url = $script . '?cmd=unfreeze&page=' . rawurlencode($s_page);
+ } else {
+ if ($id != '') {
+ $s_id = '&id=' . $id;
+ } else {
+ $s_id = '';
+ }
+ $url = $script . '?cmd=edit&page=' . rawurlencode($s_page) . $s_id;
+ }
+ $atag = '<a class="' . $class . '" href="' . $url . '" title="' . $title . '">';
+ static $atags = '</a>';
+
+ if (is_page($s_page)) {
+ // Normal edit link
+ return $atag . $icon . $s_label . $atags;
+ } else {
+ // Dangling edit link
+ return $atag . $icon . $atags . '<span class="noexists">' .
+ $s_label . $atag . '?' . $atags . '</span>';
+ }
+}
+
// Write, add, or insert new comment
function plugin_edit_write()
{