Example #1
0
/**
 * Generate wiki editor html code
 * @param int wikiId ID of the Wiki
 * @param string title page title
 * @param string content page content
 * @param string script callback script url
 * @param boolean showWikiToolbar use Wiki toolbar if true
 * @param boolean forcePreview force preview before saving
 *      (ie disable save button)
 * @return string HTML code of the wiki editor
 */
function claro_disp_wiki_editor($wikiId, $title, $versionId, $content, $changelog = '', $script = null, $showWikiToolBar = true, $forcePreview = true)
{
    global $langPreview, $langCancel, $langSave, $langWikiMainPage, $langNote, $course_code;
    // create script
    $script = is_null($script) ? $_SERVER['SCRIPT_NAME'] . "?course={$course_code}" : $script;
    $script = add_request_variable_to_url($script, "title", rawurlencode($title));
    // set display title
    $localtitle = $title === '__MainPage__' ? $langWikiMainPage : $title;
    $out = "\n            <h1>{$localtitle}</h1>\n            <br>\n            <div class='form-wrapper'>\n            <form class='form-horizontal' role='form' method='POST' action='{$script}' name='editform' id='editform'>";
    if ($showWikiToolBar === true) {
        $wikiarea = new Wiki2xhtmlArea($content, 'wiki_content', 80, 15, null);
        $out .= "<div class='form-group'><div class='col-xs-12'>" . $wikiarea->toHTML() . "</div></div>";
    } else {
        // Does it ever gets in here?
        $out .= "<label>Texte :</label><br>\n                <textarea class='form-control' name='wiki_content' id='wiki_content'vcols='80' rows='15' wrap='virtual'>\n                    " . q($content) . "\n                </textarea>";
    }
    //notes
    $out .= "<div class='form-group'>\n                <label for='changelog' class='col-sm-2 control-label'>{$langNote}:</label>\n                <div class='col-sm-10'>    \n                    <input class='form-control' type='text'  id='changelog' value='" . q($changelog) . "' name='changelog' size='70' maxlength='200' wrap='virtual'>\n                </div>        \n            </div>";
    //end notes
    $out .= '<div style="padding:10px;">' . "\n";
    $out .= '<input type="hidden" name="wikiId" value="' . $wikiId . '" />' . "\n";
    $out .= '<input type="hidden" name="versionId" value="' . $versionId . '" />' . "\n";
    $out .= '<input class="btn btn-primary" type="submit" name="action[preview]" value="' . $langPreview . '" />' . "\n";
    if (!$forcePreview) {
        $out .= '<input class="btn btn-primary" type="submit" name="action[save]" value="' . $langSave . '" />' . "\n";
    }
    $location = add_request_variable_to_url($script, "wikiId", $wikiId);
    $location = add_request_variable_to_url($location, "action", "show");
    $out .= "   <a class='btn btn-default' href='{$location}'>{$langCancel}</a>\n            </div>\n        </form>\n    </div>";
    return $out;
}
Example #2
0
/**
 * Generate wiki editor html code
 * @param int wikiId ID of the Wiki
 * @param string title page title
 * @param string content page content
 * @param string script callback script url
 * @param boolean showWikiToolbar use Wiki toolbar if true
 * @param boolean forcePreview force preview before saving
 *      (ie disable save button)
 * @return string HTML code of the wiki editor
 */
function claro_disp_wiki_editor($wikiId, $title, $versionId, $content, $script = null, $showWikiToolBar = true, $forcePreview = true)
{
    // create script
    $script = is_null($script) ? Url::Contextualize($_SERVER['PHP_SELF']) : $script;
    $script = add_request_variable_to_url($script, "title", rawurlencode($title));
    // set display title
    $localtitle = $title === '__MainPage__' ? get_lang("Main page") : $title;
    // display title
    $out = '<div class="wikiTitle">' . "\n";
    $out .= '<h1>' . $localtitle . '</h1>' . "\n";
    $out .= '</div>' . "\n";
    // display editor
    $out .= '<form method="post" action="' . claro_htmlspecialchars($script) . '"' . ' name="editform" id="editform">' . "\n";
    if ($showWikiToolBar === true) {
        $wikiarea = new Wiki2xhtmlArea($content, 'content', 80, 15, null);
        $out .= $wikiarea->toHTML();
    } else {
        $out .= '<label>Texte :</label><br />' . "\n";
        $out .= '<textarea name="content" id="content"' . ' cols="80" rows="15" >';
        $out .= $content;
        $out .= '</textarea>' . "\n";
    }
    $out .= '<div style="padding:10px;">' . "\n";
    $out .= '<input type="hidden" name="wikiId" value="' . $wikiId . '" />' . "\n";
    $out .= '<input type="hidden" name="versionId" value="' . $versionId . '" />' . "\n";
    $out .= claro_form_relay_context() . "\n";
    $out .= '<input type="submit" name="action[preview]" value="' . get_lang("Preview") . '" />' . "\n";
    if (!$forcePreview) {
        $out .= '<input type="submit" name="action[save]" value="' . get_lang("Save") . '" />' . "\n";
    }
    $location = add_request_variable_to_url($script, "wikiId", $wikiId);
    $location = add_request_variable_to_url($location, "action", "show");
    $out .= claro_html_button(claro_htmlspecialchars($location), get_lang("Cancel"));
    $out .= '</div>' . "\n";
    $out .= "</form>\n";
    return $out;
}