Beispiel #1
0
/**
 * Preprocess edit form data
 *
 * @author   Andreas Gohr <*****@*****.**>
 *
 * @triggers HTML_EDITFORM_OUTPUT
 */
function html_edit()
{
    global $ID;
    global $REV;
    global $DATE;
    global $PRE;
    global $SUF;
    global $INFO;
    global $SUM;
    global $lang;
    global $conf;
    global $TEXT;
    global $RANGE;
    if (isset($_REQUEST['changecheck'])) {
        $check = $_REQUEST['changecheck'];
    } elseif (!$INFO['exists']) {
        // $TEXT has been loaded from page template
        $check = md5('');
    } else {
        $check = md5($TEXT);
    }
    $mod = md5($TEXT) !== $check;
    $wr = $INFO['writable'] && !$INFO['locked'];
    $include = 'edit';
    if ($wr) {
        if ($REV) {
            $include = 'editrev';
        }
    } else {
        // check pseudo action 'source'
        if (!actionOK('source')) {
            msg('Command disabled: source', -1);
            return;
        }
        $include = 'read';
    }
    global $license;
    $form = new Doku_Form(array('id' => '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);
    $data = array('form' => $form, 'wr' => $wr, 'media_manager' => true, 'target' => isset($_REQUEST['target']) && $wr && $RANGE !== '' ? $_REQUEST['target'] : 'section', 'intro_locale' => $include);
    if ($data['target'] !== 'section') {
        // Only emit event if page is writable, section edit data is valid and
        // edit target is not section.
        trigger_event('HTML_EDIT_FORMSELECTION', $data, 'html_edit_form', true);
    } else {
        html_edit_form($data);
    }
    if (isset($data['intro_locale'])) {
        echo p_locale_xhtml($data['intro_locale']);
    }
    $form->addHidden('target', $data['target']);
    $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 ($wr && $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']['extern']) {
            $out .= ' target="' . $conf['target']['extern'] . '"';
        }
        $out .= '>' . $license[$conf['license']]['name'] . '</a>';
        $form->addElement($out);
        $form->addElement(form_makeCloseTag('div'));
    }
    if ($wr) {
        // sets changed to true when previewed
        echo '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--' . NL;
        echo 'textChanged = ' . ($mod ? 'true' : 'false');
        echo '//--><!]]></script>' . NL;
    }
    ?>
    <div style="width:99%;">

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

    </div>
    <?php 
    html_form('edit', $form);
    print '</div>' . NL;
}
Beispiel #2
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
 * @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 
}
/**
 * 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;
}
Beispiel #4
0
/**
 * Display the default edit form
 *
 * Is the default action for HTML_EDIT_FORMSELECTION.
 *
 * @triggers HTML_EDITFORM_OUTPUT
 */
function html_edit_form($param)
{
    extract($param);
    global $conf;
    global $license;
    global $lang;
    global $REV;
    global $DATE;
    global $PRE;
    global $SUF;
    global $INFO;
    global $SUM;
    global $ID;
    ?>
            <?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>
            <?php 
    }
    ?>
        <div style="width:99%;">

        <div class="toolbar">
        <div id="draft__status"><?php 
    if (!empty($INFO['draft'])) {
        echo $lang['draftdate'] . ' ' . 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>

        </div>
        <?php 
    $form = new Doku_Form(array('id' => '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 ($wr && $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 (isset($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;
}