コード例 #1
0
ファイル: savecontent.php プロジェクト: roverrobot/projects
 protected function update($content)
 {
     global $ID;
     if (!$this->file) {
         return FALSE;
     }
     $pos = $this->file->pos();
     $from = $pos['pos'];
     $to = $from + $pos['length'];
     list($pre, $code, $suf) = rawWikiSlices("{$from}-{$to}", $ID);
     return $pre . $content . $suf;
 }
コード例 #2
0
ファイル: example.php プロジェクト: roverrobot/components
 protected function call($params)
 {
     $id = cleanID($params['id']);
     if (!file_exists(wikiFN($id))) {
         // return an error and exit;
         $this->error(404);
     }
     $range = $params['range'];
     if (!isset($range['from']) || !isset($range['to'])) {
         // an error with a specific message, and exit
         $this->error(400, "range must have a from proterty and a to property");
     }
     // return the slice
     return rawWikiSlices($range['from'] . '-' . $range['to'], $id)[1];
 }
コード例 #3
0
ファイル: set_maker.php プロジェクト: roverrobot/projects
 protected function update($maker)
 {
     global $ID;
     if (!$this->file) {
         return FALSE;
     }
     $entertag = $this->file->entertag();
     $from = $entertag['pos'];
     $to = $from + $entertag['length'];
     list($pre, $enter, $suf) = rawWikiSlices("{$from}-{$to}", $ID);
     $enter .= '</' . $this->file->type() . '-file>';
     $dom = DOMDocument::loadXML($enter);
     if ($dom === FALSE) {
         return FALSE;
     }
     $dom->documentElement->setAttribute('maker', $maker);
     $enter = $dom->saveXML($dom->documentElement);
     $enter = substr($enter, 0, -2) . '>';
     return $pre . $enter . $suf;
 }
コード例 #4
0
/**
 * This displays the edit form (lots of logic included)
 *
 * @fixme    this is a huge lump of code and should be modularized
 * @triggers HTML_PAGE_FROMTEMPLATE
 * @triggers HTML_EDITFORM_INJECTION
 * @author   Andreas Gohr <*****@*****.**>
 */
function html_edit($text = null, $include = 'edit')
{
    //FIXME: include needed?
    global $ID;
    global $REV;
    global $DATE;
    global $RANGE;
    global $PRE;
    global $SUF;
    global $INFO;
    global $SUM;
    global $lang;
    global $conf;
    global $license;
    //set summary default
    if (!$SUM) {
        if ($REV) {
            $SUM = $lang['restored'];
        } elseif (!$INFO['exists']) {
            $SUM = $lang['created'];
        }
    }
    //no text? Load it!
    if (!isset($text)) {
        $pr = false;
        //no preview mode
        if ($INFO['exists']) {
            if ($RANGE) {
                list($PRE, $text, $SUF) = rawWikiSlices($RANGE, $ID, $REV);
            } else {
                $text = rawWiki($ID, $REV);
            }
            $check = md5($text);
            $mod = false;
        } else {
            //try to load a pagetemplate
            $data = array($ID);
            $text = trigger_event('HTML_PAGE_FROMTEMPLATE', $data, 'pageTemplate', true);
            $check = md5('');
            $mod = $text !== '';
        }
    } else {
        $pr = true;
        //preview mode
        if (isset($_REQUEST['changecheck'])) {
            $check = $_REQUEST['changecheck'];
            $mod = md5($text) !== $check;
        } else {
            // Why? Assume default text is unmodified.
            $check = md5($text);
            $mod = false;
        }
    }
    $wr = $INFO['writable'] && !$INFO['locked'];
    if ($wr) {
        if ($REV) {
            print p_locale_xhtml('editrev');
        }
        print p_locale_xhtml($include);
    } else {
        // check pseudo action 'source'
        if (!actionOK('source')) {
            msg('Command disabled: source', -1);
            return;
        }
        print p_locale_xhtml('read');
    }
    if (!$DATE) {
        $DATE = $INFO['lastmod'];
    }
    ?>
  <div style="width:99%;">

   <div class="toolbar">
      <div id="draft__status"><?php 
    if (!empty($INFO['draft'])) {
        echo $lang['draftdate'] . ' ' . strftime($conf['dformat']);
    }
    ?>
</div>
      <div id="tool__bar"><?php 
    if ($wr) {
        ?>
<a href="<?php 
        echo DOKU_BASE;
        ?>
lib/exe/mediamanager.php?ns=<?php 
        echo $INFO['namespace'];
        ?>
"
      target="_blank"><?php 
        echo $lang['mediaselect'];
        ?>
</a><?php 
    }
    ?>
</div>

      <?php 
    if ($wr) {
        ?>
      <script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--
        <?php 
        /* sets changed to true when previewed */
        ?>
        textChanged = <?php 
        $mod ? print 'true' : (print 'false');
        ?>
;
      //--><!]]></script>
      <span id="spell__action"></span>
      <div id="spell__suggest"></div>
      <?php 
    }
    ?>
   </div>
   <div id="spell__result"></div>
<?php 
    $form = new Doku_Form('dw__editform');
    $form->addHidden('id', $ID);
    $form->addHidden('rev', $REV);
    $form->addHidden('date', $DATE);
    $form->addHidden('prefix', $PRE);
    $form->addHidden('suffix', $SUF);
    $form->addHidden('changecheck', $check);
    $attr = array('tabindex' => '1');
    if (!$wr) {
        $attr['readonly'] = 'readonly';
    }
    $form->addElement(form_makeWikiText($text, $attr));
    $form->addElement(form_makeOpenTag('div', array('id' => 'wiki__editbar')));
    $form->addElement(form_makeOpenTag('div', array('id' => 'size__ctl')));
    $form->addElement(form_makeCloseTag('div'));
    if ($wr) {
        $form->addElement(form_makeOpenTag('div', array('class' => 'editButtons')));
        $form->addElement(form_makeButton('submit', 'save', $lang['btn_save'], array('id' => 'edbtn__save', 'accesskey' => 's', 'tabindex' => '4')));
        $form->addElement(form_makeButton('submit', 'preview', $lang['btn_preview'], array('id' => 'edbtn__preview', 'accesskey' => 'p', 'tabindex' => '5')));
        $form->addElement(form_makeButton('submit', 'draftdel', $lang['btn_cancel'], array('tabindex' => '6')));
        $form->addElement(form_makeCloseTag('div'));
        $form->addElement(form_makeOpenTag('div', array('class' => 'summary')));
        $form->addElement(form_makeTextField('summary', $SUM, $lang['summary'], 'edit__summary', 'nowrap', array('size' => '50', 'tabindex' => '2')));
        $elem = html_minoredit();
        if ($elem) {
            $form->addElement($elem);
        }
        $form->addElement(form_makeCloseTag('div'));
    }
    $form->addElement(form_makeCloseTag('div'));
    if ($conf['license']) {
        $form->addElement(form_makeOpenTag('div', array('class' => 'license')));
        $out = $lang['licenseok'];
        $out .= '<a href="' . $license[$conf['license']]['url'] . '" rel="license" class="urlextern"';
        if ($conf['target']['external']) {
            $out .= ' target="' . $conf['target']['external'] . '"';
        }
        $out .= '> ' . $license[$conf['license']]['name'] . '</a>';
        $form->addElement($out);
        $form->addElement(form_makeCloseTag('div'));
    }
    html_form('edit', $form);
    print '</div>' . NL;
}
コード例 #5
0
ファイル: actions.php プロジェクト: stretchyboy/dokuwiki
/**
 * Handle 'edit', 'preview', 'recover'
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function act_edit($act)
{
    global $ID;
    global $INFO;
    global $TEXT;
    global $RANGE;
    global $PRE;
    global $SUF;
    global $REV;
    global $SUM;
    global $lang;
    global $DATE;
    if (!isset($TEXT)) {
        if ($INFO['exists']) {
            if ($RANGE) {
                list($PRE, $TEXT, $SUF) = rawWikiSlices($RANGE, $ID, $REV);
            } else {
                $TEXT = rawWiki($ID, $REV);
            }
        } else {
            $TEXT = pageTemplate($ID);
        }
    }
    //set summary default
    if (!$SUM) {
        if ($REV) {
            $SUM = $lang['restored'];
        } elseif (!$INFO['exists']) {
            $SUM = $lang['created'];
        }
    }
    // Use the date of the newest revision, not of the revision we edit
    // This is used for conflict detection
    if (!$DATE) {
        $DATE = $INFO['meta']['date']['modified'];
    }
    //check if locked by anyone - if not lock for my self
    $lockedby = checklock($ID);
    if ($lockedby) {
        return 'locked';
    }
    lock($ID);
    return $act;
}
コード例 #6
0
ファイル: edit.php プロジェクト: a-gundy/ckgedit
    /**
     * function _preprocess
     * @author  Myron Turner <*****@*****.**>
     */
    function _preprocess()
    {
        global $ID;
        global $REV;
        global $DATE;
        global $RANGE;
        global $PRE;
        global $SUF;
        global $INFO;
        global $SUM;
        global $lang;
        global $conf;
        global $ckgedit_lang;
        //set summary default
        if (!$SUM) {
            if ($REV) {
                $SUM = $lang['restored'];
            } elseif (!$INFO['exists']) {
                $SUM = $lang['created'];
            }
        }
        if ($INFO['exists']) {
            if ($RANGE) {
                list($PRE, $text, $SUF) = rawWikiSlices($RANGE, $ID, $REV);
            } else {
                $text = rawWiki($ID, $REV);
            }
        } else {
            //try to load a pagetemplate
            $text = pageTemplate($ID);
            //Check for text from template event handler
            if (!$text && $this->page_from_template) {
                $text = $this->page_from_template;
            }
        }
        $text = preg_replace_callback('/(~~NOCACHE~~|~~NOTOC~~|\\{\\{rss>http:\\/\\/.*?\\}\\})/ms', create_function('$matches', '$matches[0] = str_replace("{{rss>http://", "{ { rss>Feed:",  $matches[0]);
               $matches[0] = str_replace("~", "~ ",  $matches[0]);
               return $matches[0];'), $text);
        if ($this->getConf('smiley_hack')) {
            $new_addr = $_SERVER['SERVER_NAME'] . DOKU_BASE;
            $text = preg_replace("#(?<=http://)(.*?)(?=lib/plugins/ckgedit/ckeditor/plugins/smiley/images)#s", $new_addr, $text);
        }
        $text = preg_replace_callback('/\\[\\[\\w+>.*?\\]\\]/ms', create_function('$matches', 'return str_replace("/", "__IWIKI_FSLASH__" ,$matches[0]);'), $text);
        global $useComplexTables;
        if ($this->getConf('complex_tables') || strrpos($text, '~~COMPLEX_TABLES~~') !== false) {
            $useComplexTables = true;
        } else {
            $useComplexTables = false;
        }
        if (strpos($text, '%%') !== false) {
            $text = preg_replace_callback("/<(nowiki|code|file)>(.*?)<\\/(nowiki|code|file)/ms", function ($matches) {
                $matches[0] = str_replace('%%', 'DBLPERCENT', $matches[0]);
                return $matches[0];
            }, $text);
            $text = preg_replace_callback("/(?<!nowiki>)%%(.*?)%%/ms", function ($matches) {
                return '<nowiki>' . $matches[1] . '</nowiki>';
            }, $text);
            $text = str_replace('DBLPERCENT', '%%', $text);
        }
        $pos = strpos($text, '<');
        if ($pos !== false) {
            $text = preg_replace_callback('/(<nowiki>)(.*?)(<\\/nowiki>)/ms', create_function('$matches', '$needles =  array("[","]", "/",  ".", "*", "_","\'","<",">","%", "{", "}", "\\\\","(");
                  $replacements = array("&#91;","&#93;","&#47;", "&#46;", "&#42;", "&#95;", "&#39;", "&#60;","&#62;","&#37;", "&#123;","&#125;", "&#92;","&#40;"); 
                  $matches[2] = str_replace($needles, $replacements, $matches[2]);
                  return  $matches[1] . $matches[2] . $matches[3];'), $text);
            $text = preg_replace_callback('/<(code|file)(.*?)(>)(.*?)(<\\/\\1>)/ms', create_function('$matches', ' //file_put_contents("geshi.txt", print_r($matches,true));
                 if(preg_match("/(^\\s*geshi:\\s*(\\w+)(\\s+\\w+\\.\\w+)*\\s*)$/m",$matches[0],$gmatch)){
                      $gmatch[0] = preg_replace("/\\s*geshi:\\s+/","",$gmatch[0]);                    
                      $matches[1] .= " " . trim($gmatch[0]);                       
                      //file_put_contents("gmatch.txt", print_r($gmatch,true));
                      $c=1;
                      $matches[4] = str_replace($gmatch[1],"",$matches[4],$c);
                  }
                 if(preg_match("/\\w+/",$matches[2])) {
                   $matches[4] = str_replace("CHEVRONescC", ">>",$matches[4]);
                   $matches[4] = str_replace("CHEVRONescO", "<<",$matches[4]);
                   $matches[4] = preg_replace("/<(?!\\s)/ms", "__GESHI_OPEN__", $matches[4]); 
                  }
                  else {
                  if( preg_match("/MULTI/",$matches[0])) {
                     $open = "< ";
                     $close = " >";
                  }
                  else {  
                     $open = "&lt;";
                     $close = "&gt;";
                  }
                  $matches[4] = preg_replace("/<(?!\\s)/ms", $open, $matches[4]); 
                  $matches[4] = preg_replace("/(?<!\\s)>/ms", $close, $matches[4]);                    
                  }
                  $matches[4] = str_replace("\\"", "__GESHI_QUOT__", $matches[4]);     
                  return "<" . $matches[1] . $matches[2] . $matches[3] . $matches[4] . $matches[5];'), $text);
            /* \n_ckgedit_NPBBR_\n: the final \n prevents this from iterfering with next in line markups
                  -- in particular tables which require a new line and margin left 
                 this may leave an empty paragraph in the xhtml, which is removed below 
               */
            $text = preg_replace('/<\\/(code|file)>(\\s*)(?=[^\\w])(\\s*)/m', "</\$1>\n_ckgedit_NPBBR_\n\$2", $text);
            $text = preg_replace_callback('/~~START_HTML_BLOCK~~.*?CLOSE_HTML_BLOCK/ms', create_function('$matches', '$matches[0] = str_replace("_ckgedit_NPBBR_","",$matches[0]);
                 return $matches[0];'), $text);
            $text = preg_replace_callback('/(\\|\\s*)(<code>|<file>)(.*?)(<\\/code>|<\\/file>)\\n_ckgedit_NPBBR_(?=.*?\\|)/ms', create_function('$matches', '$matches[2] = preg_replace("/<code>/ms", "TPRE_CODE", $matches[2]); 
                  $matches[2] = preg_replace("/<file>/ms", "TPRE_FILE", $matches[2]);    
                  $matches[4] = "TPRE_CLOSE";                    
                  $matches[3] = preg_replace("/^\\n+/", "TC_NL",$matches[3]);  
                  $matches[3] = preg_replace("/\\n/ms", "TC_NL",$matches[3]);                                   
                  return $matches[1] . $matches[2] .  trim($matches[3]) .   $matches[4];'), $text);
            $text = preg_replace('/TPRE_CLOSE\\s+/ms', "TPRE_CLOSE", $text);
            $text = preg_replace('/<(?!code|file|del|sup|sub|\\/\\/|\\s|\\/del|\\/code|\\/file|\\/sup|\\/sub)/ms', "&lt;", $text);
            $text = str_replace('%%&lt;', '&#37;&#37;&#60;', $text);
        }
        if ($this->getConf('duplicate_notes')) {
            $text = preg_replace_callback('/\\(\\((.*?)\\)\\)/ms', create_function('$matches', 'static $count = 0;
				   $count++;
				   $ins = "FNoteINSert" . $count;
                   $needles =  array("[","]", "/",  ".", "*", "_","\'","<",">","%", "{", "}", "\\\\","(");
                   $replacements = array("&#91;","&#93;","&#47;", "&#46;", "&#42;", "&#95;", "&#39;", "&#60;","&#62;","&#37;", "&#123;","&#125;", "&#92;","&#40;"); 
                   $matches[1] = str_replace($needles, $replacements, $matches[1]);                    
              	   return "(($ins" . $matches[1] . "))" ;'), $text);
        }
        $text = preg_replace('/^\\>/ms', "_QUOT_", $text);
        // dw quotes
        $text = str_replace('>>', 'CHEVRONescC', $text);
        $text = str_replace('<<', 'CHEVRONescO', $text);
        $text = preg_replace('/(={3,}.*?)(\\{\\{.*?\\}\\})(.*?={3,})/', "\$1\$3\n\$2", $text);
        $email_regex = '/\\/\\/\\<\\/\\/(.*?@.*?)>/';
        $text = preg_replace($email_regex, "<\$1>", $text);
        $text = preg_replace('/{{(.*)\\.swf(\\s*)}}/ms', "__SWF__\$1.swf\$2__FWS__", $text);
        $this->xhtml = $this->_render_xhtml($text);
        $this->xhtml = str_replace("__IWIKI_FSLASH__", "&frasl;", $this->xhtml);
        if ($this->getConf('duplicate_notes')) {
            $this->xhtml = preg_replace("/FNoteINSert\\d+/ms", "", $this->xhtml);
        }
        $this->xhtml = str_replace("__GESHI_QUOT__", '&#34;', $this->xhtml);
        $this->xhtml = str_replace("__GESHI_OPEN__", "&#60; ", $this->xhtml);
        $this->xhtml = str_replace('CHEVRONescC', '>>', $this->xhtml);
        $this->xhtml = str_replace('CHEVRONescO', '<<', $this->xhtml);
        $this->xhtml = preg_replace('/_QUOT_/ms', '>', $this->xhtml);
        // dw quotes
        if ($pos !== false) {
            $this->xhtml = preg_replace_callback('/(TPRE_CODE|TPRE_FILE)(.*?)(TPRE_CLOSE)/ms', create_function('$matches', '$matches[1] = preg_replace("/TPRE_CODE/","<pre class=\'code\'>\\n", $matches[1]);  
                    $matches[1] = preg_replace("/TPRE_FILE/","<pre class=\'file\'>\\n", $matches[1]);  
                    $matches[2] = preg_replace("/TC_NL/ms", "\\n", $matches[2]);  
                    $matches[3] = "</pre>";                    
                    return $matches[1] . $matches[2] . $matches[3];'), $this->xhtml);
        }
        $this->xhtml = preg_replace_callback('/~~START_HTML_BLOCK~~[\\n\\s]*(.*?)CLOSE_HTML_BLOCK/ms', create_function('$matches', '$matches[1] = str_replace("&amp;","&",$matches[1]);
         $matches[1] =  html_entity_decode($matches[1],ENT_QUOTES, "UTF-8");
             $matches[1] = preg_replace("/<\\/?code.*?>/", "",$matches[1]);
         $matches[1] = preg_replace("/^\\s*<\\/p>/","",$matches[1]);
         $tmp = explode("\\n", $matches[1]);
         for($n=0; $n<7; $n++) {
               if( (preg_match("/(<p>\\s*)*(&nbsp;|\\s+)<\\/p>/",$tmp[$n])) || (preg_match("/^\\s+$/",$tmp[$n]))) {
                unset($tmp[$n]);
             }
          }
         return "~~START_HTML_BLOCK~~" . implode("\\n",$tmp) . "CLOSE_HTML_BLOCK"; '), $this->xhtml);
        $this->xhtml = preg_replace_callback('/(<pre)(.*?)(>)(.*?)(<\\/pre>)/ms', create_function('$matches', '$matches[4] = preg_replace("/(\\||\\^)[ ]+(\\||\\^)/ms","$1 &nbsp; $2" , $matches[4]);                    
                  return  $matches[1] . $matches[2] . $matches[3] . $matches[4] . $matches[5];'), $this->xhtml);
        $this->xhtml = preg_replace_callback('/~~MULTI_PLUGIN_OPEN~~(.*?)~~MULTI_PLUGIN_CLOSE~~/ms', create_function('$matches', 'return str_replace("&lt;", "< ",$matches[0]);'), $this->xhtml);
        $cname = getCacheName($INFO['client'] . $ID, '.draft.fckl');
        if (file_exists($cname)) {
            $cdata = unserialize(io_readFile($cname, false));
            $cdata['text'] = urldecode($cdata['text']);
            preg_match_all("/<\\/(.*?)\\>/", $cdata['text'], $matches);
            /* exclude drafts saved from preview mode */
            if (!in_array('code', $matches[1]) && !in_array('file', $matches[1]) && !in_array('nowiki', $matches[1])) {
                $this->draft_text = $cdata['text'];
                $this->draft_found = true;
                msg($this->getLang('draft_msg'));
            }
            unlink($cname);
        }
        return true;
    }
コード例 #7
0
ファイル: actions.php プロジェクト: rexin/dokuwiki
/**
 * Handle 'edit', 'preview', 'recover'
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function act_edit($act)
{
    global $ID;
    global $INFO;
    global $TEXT;
    global $RANGE;
    global $PRE;
    global $SUF;
    global $REV;
    global $SUM;
    global $lang;
    global $DATE;
    if (!isset($TEXT)) {
        if ($INFO['exists']) {
            if ($RANGE) {
                list($PRE, $TEXT, $SUF) = rawWikiSlices($RANGE, $ID, $REV);
            } else {
                $TEXT = rawWiki($ID, $REV);
            }
        } else {
            $TEXT = pageTemplate($ID);
        }
    }
    //set summary default
    if (!$SUM) {
        if ($REV) {
            $SUM = sprintf($lang['restored'], dformat($REV));
        } elseif (!$INFO['exists']) {
            $SUM = $lang['created'];
        }
    }
    // Use the date of the newest revision, not of the revision we edit
    // This is used for conflict detection
    if (!$DATE) {
        $DATE = @filemtime(wikiFN($ID));
    }
    //check if locked by anyone - if not lock for my self
    //do not lock when the user can't edit anyway
    if ($INFO['writable']) {
        $lockedby = checklock($ID);
        if ($lockedby) {
            return 'locked';
        }
        lock($ID);
    }
    return $act;
}
コード例 #8
0
ファイル: html.php プロジェクト: canneverbe/flyspray
/**
 * This displays the edit form (lots of logic included)
 *
 * @fixme    this is a huge lump of code and should be modularized
 * @triggers HTML_PAGE_FROMTEMPLATE
 * @author   Andreas Gohr <*****@*****.**>
 */
function html_edit($text = null, $include = 'edit')
{
    //FIXME: include needed?
    global $ID;
    global $REV;
    global $DATE;
    global $RANGE;
    global $PRE;
    global $SUF;
    global $INFO;
    global $SUM;
    global $lang;
    global $conf;
    //set summary default
    if (!$SUM) {
        if ($REV) {
            $SUM = $lang['restored'];
        } elseif (!$INFO['exists']) {
            $SUM = $lang['created'];
        }
    }
    //no text? Load it!
    if (!isset($text)) {
        $pr = false;
        //no preview mode
        if ($INFO['exists']) {
            if ($RANGE) {
                list($PRE, $text, $SUF) = rawWikiSlices($RANGE, $ID, $REV);
            } else {
                $text = rawWiki($ID, $REV);
            }
        } else {
            //try to load a pagetemplate
            $data = array($ID);
            $text = trigger_event('HTML_PAGE_FROMTEMPLATE', $data, 'pageTemplate', true);
        }
    } else {
        $pr = true;
        //preview mode
    }
    $wr = $INFO['writable'];
    if ($wr) {
        if ($REV) {
            print p_locale_xhtml('editrev');
        }
        print p_locale_xhtml($include);
        $ro = false;
    } else {
        // check pseudo action 'source'
        if (!actionOK('source')) {
            msg('Command disabled: source', -1);
            return;
        }
        print p_locale_xhtml('read');
        $ro = 'readonly="readonly"';
    }
    if (!$DATE) {
        $DATE = $INFO['lastmod'];
    }
    ?>
  <div style="width:99%;">

   <div class="toolbar">
      <div id="draft__status"><?php 
    if (!empty($INFO['draft'])) {
        echo $lang['draftdate'] . ' ' . date($conf['dformat']);
    }
    ?>
</div>
      <div id="tool__bar"><?php 
    if (!$ro) {
        ?>
<a href="<?php 
        echo DOKU_BASE;
        ?>
lib/exe/mediamanager.php?ns=<?php 
        echo $INFO['namespace'];
        ?>
"
      target="_blank"><?php 
        echo $lang['mediaselect'];
        ?>
</a><?php 
    }
    ?>
</div>

      <?php 
    if ($wr) {
        ?>
      <script type="text/javascript" charset="utf-8">
        <?php 
        /* sets changed to true when previewed */
        ?>
        textChanged = <?php 
        $pr ? print 'true' : (print 'false');
        ?>
;
      </script>
      <span id="spell__action"></span>
      <div id="spell__suggest"></div>
      <?php 
    }
    ?>
   </div>
   <div id="spell__result"></div>


   <form id="dw__editform" method="post" action="<?php 
    echo script();
    ?>
" accept-charset="<?php 
    echo $lang['encoding'];
    ?>
"><div class="no">
      <input type="hidden" name="id"   value="<?php 
    echo $ID;
    ?>
" />
      <input type="hidden" name="rev"  value="<?php 
    echo $REV;
    ?>
" />
      <input type="hidden" name="date" value="<?php 
    echo $DATE;
    ?>
" />
      <input type="hidden" name="prefix" value="<?php 
    echo formText($PRE);
    ?>
" />
      <input type="hidden" name="suffix" value="<?php 
    echo formText($SUF);
    ?>
" />
    </div>

    <textarea name="wikitext" id="wiki__text" <?php 
    echo $ro;
    ?>
 cols="80" rows="10" class="edit" tabindex="1"><?php 
    echo "\n" . formText($text);
    ?>
</textarea>

    <div id="wiki__editbar">
      <div id="size__ctl"></div>
      <?php 
    if ($wr) {
        ?>
         <div class="editButtons">
            <input class="button" id="edbtn__save" type="submit" name="do[save]" value="<?php 
        echo $lang['btn_save'];
        ?>
" accesskey="s" title="<?php 
        echo $lang['btn_save'];
        ?>
 [ALT+S]" tabindex="4" />
            <input class="button" id="edbtn__preview" type="submit" name="do[preview]" value="<?php 
        echo $lang['btn_preview'];
        ?>
" accesskey="p" title="<?php 
        echo $lang['btn_preview'];
        ?>
 [ALT+P]" tabindex="5" />
            <input class="button" type="submit" name="do[draftdel]" value="<?php 
        echo $lang['btn_cancel'];
        ?>
" tabindex="6" />
         </div>
      <?php 
    }
    ?>
      <?php 
    if ($wr) {
        ?>
        <div class="summary">
           <label for="edit__summary" class="nowrap"><?php 
        echo $lang['summary'];
        ?>
:</label>
           <input type="text" class="edit" name="summary" id="edit__summary" size="50" value="<?php 
        echo formText($SUM);
        ?>
" tabindex="2" />
           <?php 
        html_minoredit();
        ?>
        </div>
      <?php 
    }
    ?>
    </div>
  </form>
  </div>
<?php 
}
コード例 #9
0
ファイル: action.php プロジェクト: omusico/isle-web-framework
 /**
  * an action has been called
  *
  */
 function filter(&$event, $param)
 {
     global $ACT;
     global $ID;
     global $TEXT;
     global $PRE;
     $perm = auth_quickaclcheck($ID);
     if ($event->data == 'manage_files') {
         $event->preventDefault();
         return;
     }
     $project = Project::project();
     if ($project == NULL) {
         return;
     }
     switch ($event->data) {
         case 'change_use':
             if ($perm <= AUTH_READ) {
                 msg('You do not have permission to change this file', -1);
                 $event->data = 'show';
             } else {
                 $range = $_REQUEST['range'];
                 $name = $_REQUEST['use'];
                 $slices = rawWikiSlices($range, $ID);
                 $TEXT = $slices[0] . '<use name="' . $name . '"/>' . $slices[2];
             }
             $event->data = 'save';
             break;
         case 'create':
             if ($perm < AUTH_CREATE) {
                 msg('You do not have permission to create a file', -1);
                 if ($perm < AUTH_READ) {
                     $event->data = 'show';
                     break;
                 }
                 $event->data = 'manage_files';
                 $event->preventDefault();
                 break;
             }
             $text = $this->wikitext($_REQUEST['Type']);
             $name = $_REQUEST['File_name'];
             $ID = $project->name() . ':' . $name;
             if ($text == NULL) {
                 return;
             }
             $TEXT = $text;
             $event->data = 'save';
             break;
         case 'remake':
             if ($perm <= AUTH_READ) {
                 msg('You do not have permission to change this file', -1);
                 if ($perm < AUTH_READ) {
                     $event->data = 'show';
                     break;
                 }
                 $event->data = 'manage_files';
                 $event->preventDefault();
             } else {
                 set_media_file_revision_limit($this->getConf('media file revision limit'));
                 global $ID;
                 $id = $_REQUEST['id'];
                 if (getNS($name)) {
                     $ID = $id;
                 }
                 $id = noNS($id);
                 $project->remake(array($id));
                 $ID = $project->id($id);
                 $event->data = 'show';
             }
             $event->preventDefault();
             break;
         case "create_subproject":
             if ($perm < AUTH_CREATE) {
                 msg('You do not have permission to create a subproject');
                 if ($perm < AUTH_READ) {
                     $event->data = 'show';
                     break;
                 }
             } else {
                 $name = $_REQUEST['Project_name'];
                 $project = Project::project($project->name() . ':' . $name, true);
                 $ID = $project->name() . ':' . $name . ':manage_files';
             }
             $event->data = 'manage_files';
             $event->preventDefault();
             break;
         case 'clean':
             if ($perm <= AUTH_READ) {
                 msg('You do not have permission to clean this project', -1);
                 if ($perm < AUTH_READ) {
                     $event->data = 'show';
                     break;
                 }
             } else {
                 $recursive = $_REQUEST['Recursive'];
                 if (!$project->clean($recursive)) {
                     msg('Other users are updating the project. Please clean later.');
                 }
             }
             $event->data = 'manage_files';
             $event->preventDefault();
             break;
         case 'rebuild':
             $event->preventDefault();
             if ($perm <= AUTH_READ) {
                 msg('You do not have permission to rebuild this project', -1);
                 if ($perm < AUTH_READ) {
                     $event->data = 'show';
                     break;
                 }
             } else {
                 if ($project == NULL) {
                     $project = Project::project(NULL, true);
                 }
                 if (!$project->rebuild()) {
                     msg('Other users are updating the project. Please rebuild later.');
                 }
             }
             $event->data = 'manage_files';
             $event->preventDefault();
             break;
         case 'media':
             $file_id = $_REQUEST['image'];
             if (!$file_id) {
                 return;
             }
             $project = Project::project(getNS($file_id));
             if ($project === NULL) {
                 return;
             }
             $file = $project->path() . noNS($file_id);
             if (file_exists($file)) {
                 $event->preventDefault();
                 send_redirect(ml($file_id));
                 break;
             }
             return;
         case 'remove_tag':
             $tag = $_REQUEST['tag'];
             if ($perm < AUTH_EDIT) {
                 msg("You do not have permission to edit this file", -1);
                 $event->data = 'show';
                 $event->preventDefault();
                 break;
             }
             $range = $_REQUEST['range'];
             $slices = rawWikiSlices($range, $ID);
             if (substr(strtoupper($slices[1]), 0, strlen($tag) + 1) != '<' . strtoupper($tag)) {
                 msg("Missing the {$tag} tag?", -1);
                 $event->data = 'show';
                 $event->preventDefault();
                 break;
             }
             $text = $slices[0] . $slices[2];
             saveWikiText($ID, $slices[0] . $slices[2], "Remove {$tag}", FALSE);
             $event->data = 'show';
             break;
         case 'add_tag':
             if ($perm < AUTH_EDIT) {
                 msg("You do not have permission to edit this file", -1);
                 $event->data = 'show';
                 $event->preventDefault();
                 break;
             }
             $tag = $_REQUEST['tag'];
             if (isset($_REQUEST['name'])) {
                 $name = $_REQUEST['name'];
                 $name = "name=\"{$name}\"";
             } else {
                 $name = '';
             }
             $text = rawWiki($ID) . "<{$tag} {$name}";
             if (strtoupper($tag) == 'USE') {
                 $text .= '/>';
             } else {
                 $text = "></{$tag}>";
             }
             saveWikiText($ID, $text, "Add {$tag}", FALSE);
             $event->data = 'show';
             break;
         default:
             return;
     }
     $ACT = $event->data;
 }
コード例 #10
0
ファイル: edit.php プロジェクト: omusico/isle-web-framework
    /**
     * function _preprocess
     * @author  Myron Turner <*****@*****.**>
     */
    function _preprocess()
    {
        global $ID;
        global $REV;
        global $DATE;
        global $RANGE;
        global $PRE;
        global $SUF;
        global $INFO;
        global $SUM;
        global $lang;
        global $conf;
        global $fckg_lang;
        //set summary default
        if (!$SUM) {
            if ($REV) {
                $SUM = $lang['restored'];
            } elseif (!$INFO['exists']) {
                $SUM = $lang['created'];
            }
        }
        if ($INFO['exists']) {
            if ($RANGE) {
                list($PRE, $text, $SUF) = rawWikiSlices($RANGE, $ID, $REV);
            } else {
                $text = rawWiki($ID, $REV);
            }
        } else {
            //try to load a pagetemplate
            $text = pageTemplate($ID);
            //Check for text from template event handler
            if (!$text && $this->page_from_template) {
                $text = $this->page_from_template;
            }
        }
        if ($this->getConf('smiley_hack')) {
            $new_addr = $_SERVER['SERVER_NAME'] . DOKU_BASE;
            $text = preg_replace("#(?<=http://)(.*?)(?=lib/plugins/fckg/fckeditor/editor/images/smiley/msn)#s", $new_addr, $text);
        }
        $text = preg_replace_callback('/\\[\\[\\w+>.*?\\]\\]/ms', create_function('$matches', 'return str_replace("/", "__IWIKI_FSLASH__" ,$matches[0]);'), $text);
        global $useComplexTables;
        if ($this->getConf('complex_tables') || strrpos($text, '~~COMPLEX_TABLES~~') !== false) {
            $useComplexTables = true;
        } else {
            $useComplexTables = false;
        }
        if (strpos($text, '%%') !== false) {
            $text = preg_replace_callback('/(<nowiki>)*(\\s*)%%\\s*([^%]+)\\s*%%(<\\/nowiki>)*(\\s*)/ms', create_function('$matches', 'if(preg_match("/<nowiki>/",$matches[1])) {
                   $matches[1] .= "%%";
                }
                else  $matches[1] = "<nowiki>";
                if(preg_match("/<\\/nowiki>/",$matches[4])) {
                   $matches[4] = "%%</nowiki>";
                }
                else $matches[4] = "</nowiki>";  
                return   $matches[1] .  $matches[2] .  $matches[3] . $matches[4] . $matches[5];'), $text);
        }
        /* convert html tags to entities in indented code blocks*/
        $text = preg_replace_callback('/(\\n  )((?![\\*\\-]).*?)(\\n)(?!\\s)/ms', create_function('$matches', '$matches[0] = preg_replace("/(\\[\\[\\w+)>/ms","$1__IWIKI__",$matches[0]);
            $matches[0] = preg_replace("/<(?!\\s)/ms", "&lt;", $matches[0]); 
            $matches[0] = preg_replace("/(?<!\\s)>/ms", "&gt;", $matches[0]);    
            $matches[0] = preg_replace("/__IWIKI__/ms", ">", $matches[0]);    
            return $matches[0];  '), $text);
        $pos = strpos($text, '<');
        if ($pos !== false) {
            $text = preg_replace_callback('/(<nowiki>)(.*?)(<\\/nowiki>)/ms', create_function('$matches', '$needles =  array("[","]", "/",  ".", "*", "_","\'","<",">","%", "{", "}", "\\\\");
                  $replacements = array("&#91;","&#93;","&#47;", "&#46;", "&#42;", "&#95;", "&#39;", "&#60;","&#62;","&#37;", "&#123;","&#125;", "&#92;"); 
                  $matches[2] = str_replace($needles, $replacements, $matches[2]);
                  return  $matches[1] . $matches[2] . $matches[3];'), $text);
            $text = preg_replace_callback('/<(code|file)(.*?)(>)(.*?)(<\\/\\1>)/ms', create_function('$matches', 'if(preg_match("/\\w+/",$matches[2])) {
                   $matches[4] = str_replace("CHEVRONescC", ">>",$matches[4]);
                   $matches[4] = str_replace("CHEVRONescO", "<<",$matches[4]);
                   $matches[4] = preg_replace("/<(?!\\s)/ms", "__GESHI_OPEN__", $matches[4]); 
                  }
                  else {
                  if( preg_match("/MULTI/",$matches[0])) {
                     $open = "< ";
                     $close = " >";
                  }
                  else {  
                     $open = "&lt;";
                     $close = "&gt;";
                  }
                  $matches[4] = preg_replace("/<(?!\\s)/ms", $open, $matches[4]); 
                  $matches[4] = preg_replace("/(?<!\\s)>/ms", $close, $matches[4]);                    
                  }
                  $matches[4] = str_replace("\\"", "__GESHI_QUOT__", $matches[4]);     
                  return "<" . $matches[1] . $matches[2] . $matches[3] . $matches[4] . $matches[5];'), $text);
            /* \n_fckg_NPBBR_\n: the final \n prevents this from iterfering with next in line markups
                  -- in particular tables which require a new line and margin left 
                 this may leave an empty paragraph in the xhtml, which is removed below 
               */
            $text = preg_replace('/<\\/(code|file)>(\\s*)(?=[^\\w])(\\s*)/m', "</\$1>\n_fckg_NPBBR_\n\$2", $text);
            $text = preg_replace_callback('/(\\|\\s*)(<code>|<file>)(.*?)(<\\/code>|<\\/file>)\\n_fckg_NPBBR_(?=.*?\\|)/ms', create_function('$matches', '$matches[2] = preg_replace("/<code>/ms", "TPRE_CODE", $matches[2]); 
                  $matches[2] = preg_replace("/<file>/ms", "TPRE_FILE", $matches[2]);    
                  $matches[4] = "TPRE_CLOSE";                    
                  $matches[3] = preg_replace("/^\\n+/", "TC_NL",$matches[3]);  
                  $matches[3] = preg_replace("/\\n/ms", "TC_NL",$matches[3]);                                   
                  return $matches[1] . $matches[2] .  trim($matches[3]) .   $matches[4];'), $text);
            $text = preg_replace('/TPRE_CLOSE\\s+/ms', "TPRE_CLOSE", $text);
            $text = preg_replace('/<(?!code|file|plugin|del|sup|sub|\\/\\/|\\s|\\/del|\\/code|\\/file|\\/plugin|\\/sup|\\/sub)/ms', "//<//", $text);
            $text = str_replace('%%//<//', '&#37;&#37;&#60;', $text);
            $text = preg_replace_callback('/<plugin(.*?)(?=<\\/plugin>)/ms', create_function('$matches', 'return str_replace("//","", $matches[0]);'), $text);
            $text = str_replace('</plugin>', '</plugin> ', $text);
        }
        if ($this->getConf('duplicate_notes')) {
            $text = preg_replace_callback('/\\(\\(/ms', create_function('$matches', 'static $count = 0;
				   $count++;
				   $ins = "FNoteINSert" . $count;
				   return "(($ins";'), $text);
        }
        $text = str_replace('>>', 'CHEVRONescC', $text);
        $text = str_replace('<<', 'CHEVRONescO', $text);
        $text = preg_replace('/(={3,}.*?)(\\{\\{.*?\\}\\})(.*?={3,})/', "\$1\$3\n\$2", $text);
        $email_regex = '/\\/\\/\\<\\/\\/(.*?@.*?)>/';
        $text = preg_replace($email_regex, "<\$1>", $text);
        $text = preg_replace('/{{(.*)\\.swf(\\s*)}}/ms', "SWF\$1.swf\$2FWS", $text);
        $this->xhtml = $this->_render_xhtml($text);
        $this->xhtml = str_replace("__IWIKI_FSLASH__", "&frasl;", $this->xhtml);
        if ($this->getConf('duplicate_notes')) {
            $this->xhtml = preg_replace("/FNoteINSert\\d+/ms", "", $this->xhtml);
        }
        $this->xhtml = str_replace("__GESHI_QUOT__", '&#34;', $this->xhtml);
        $this->xhtml = str_replace("__GESHI_OPEN__", "&#60; ", $this->xhtml);
        $this->xhtml = str_replace('CHEVRONescC', '>>', $this->xhtml);
        $this->xhtml = str_replace('CHEVRONescO', '<<', $this->xhtml);
        if ($pos !== false) {
            $this->xhtml = preg_replace_callback('/(TPRE_CODE|TPRE_FILE)(.*?)(TPRE_CLOSE)/ms', create_function('$matches', '$matches[1] = preg_replace("/TPRE_CODE/","<pre class=\'code\'>\\n", $matches[1]);  
                    $matches[1] = preg_replace("/TPRE_FILE/","<pre class=\'file\'>\\n", $matches[1]);  
                    $matches[2] = preg_replace("/TC_NL/ms", "\\n", $matches[2]);  
                    $matches[3] = "</pre>";                    
                    return $matches[1] . $matches[2] . $matches[3];'), $this->xhtml);
        }
        $this->xhtml = preg_replace_callback('/(<pre)(.*?)(>)(.*?)(<\\/pre>)/ms', create_function('$matches', '$matches[4] = preg_replace("/(\\||\\^)[ ]+(\\||\\^)/ms","$1 &nbsp; $2" , $matches[4]);                    
                  return  $matches[1] . $matches[2] . $matches[3] . $matches[4] . $matches[5];'), $this->xhtml);
        $cname = getCacheName($INFO['client'] . $ID, '.draft.fckl');
        if (file_exists($cname)) {
            $cdata = unserialize(io_readFile($cname, false));
            $cdata['text'] = urldecode($cdata['text']);
            preg_match_all("/<\\/(.*?)\\>/", $cdata['text'], $matches);
            /* exclude drafts saved from preview mode */
            if (!in_array('code', $matches[1]) && !in_array('file', $matches[1]) && !in_array('nowiki', $matches[1])) {
                $this->draft_text = $cdata['text'];
                $this->draft_found = true;
                msg($fckg_lang['draft_msg']);
            }
            unlink($cname);
        }
        return true;
    }
コード例 #11
0
ファイル: html.php プロジェクト: JeromeS/dokuwiki
/**
 * Preprocess edit form data
 *
 * @triggers HTML_PAGE_FROMTEMPLATE
 * @author   Andreas Gohr <*****@*****.**>
 */
function html_edit($text = null, $include = 'edit')
{
    //FIXME: include needed?
    global $ID;
    global $REV;
    global $DATE;
    global $RANGE;
    global $PRE;
    global $SUF;
    global $INFO;
    global $SUM;
    global $lang;
    global $conf;
    //set summary default
    if (!$SUM) {
        if ($REV) {
            $SUM = $lang['restored'];
        } elseif (!$INFO['exists']) {
            $SUM = $lang['created'];
        }
    }
    //no text? Load it!
    if (!isset($text)) {
        $pr = false;
        //no preview mode
        if ($INFO['exists']) {
            if ($RANGE) {
                list($PRE, $text, $SUF) = rawWikiSlices($RANGE, $ID, $REV);
            } else {
                $text = rawWiki($ID, $REV);
            }
            $check = md5($text);
            $mod = false;
        } else {
            //try to load a pagetemplate
            $data = array($ID);
            $text = trigger_event('HTML_PAGE_FROMTEMPLATE', $data, 'pageTemplate', true);
            $check = md5('');
            $mod = $text !== '';
        }
    } else {
        $pr = true;
        //preview mode
        if (isset($_REQUEST['changecheck'])) {
            $check = $_REQUEST['changecheck'];
            $mod = md5($text) !== $check;
        } else {
            // Why? Assume default text is unmodified.
            $check = md5($text);
            $mod = false;
        }
    }
    $wr = $INFO['writable'] && !$INFO['locked'];
    if ($wr) {
        if ($REV) {
            print p_locale_xhtml('editrev');
        }
        print p_locale_xhtml($include);
    } else {
        // check pseudo action 'source'
        if (!actionOK('source')) {
            msg('Command disabled: source', -1);
            return;
        }
        print p_locale_xhtml('read');
    }
    if (!$DATE) {
        $DATE = $INFO['lastmod'];
    }
    $data = compact('wr', 'text', 'mod', 'check');
    trigger_event('HTML_EDIT_FORMSELECTION', $data, 'html_edit_form', true);
}