Switch from using htmlarea to using xinha. Clean up the use of the editor plugin

This commit is contained in:
Chris Morgan
2005-09-30 02:48:33 +00:00
committed by WineHQ
parent 9242a68c4a
commit 0aa7f26249
8 changed files with 239 additions and 89 deletions

View File

@@ -39,11 +39,8 @@ if($_REQUEST['sub'] == "Submit")
}
else if($_REQUEST['sub'] == 'Preview' OR empty($_REQUEST['submit']))
{
?>
<link rel="stylesheet" href="./application.css" type="text/css">
<!-- load HTMLArea -->
<script type="text/javascript" src="../htmlarea/htmlarea_loader.js"></script>
<?php
HtmlAreaLoaderScript(array("editor"));
apidb_header("Add Application Note");
echo "<form method=post action='addAppNote.php'>\n";

View File

@@ -128,11 +128,7 @@ if ($_REQUEST['sub'])
{
$x = new TableVE("view");
apidb_header("Admin App Queue");
?>
<link rel="stylesheet" href="./application.css" type="text/css">
<!-- load HTMLArea -->
<script type="text/javascript" src="../htmlarea/htmlarea_loader.js"></script>
<?php
echo '<form name="qform" action="adminAppQueue.php" method="post" enctype="multipart/form-data">',"\n";
echo '<input type="hidden" name="sub" value="add">',"\n";
@@ -140,6 +136,8 @@ if ($_REQUEST['sub'])
if (!$oApp) //app version
{
HtmlAreaLoaderScript(array("editor"));
echo html_frame_start("Potential duplicate versions in the database","90%","",0);
$oApp = new Application($oVersion->iAppId);
display_versions($oApp->iAppId, $oApp->aVersionsIds);
@@ -181,7 +179,9 @@ if ($_REQUEST['sub'])
echo '<input name="sub" type=submit value="Reject" class="button"></td></tr>',"\n";
echo '</table></form>',"\n";
} else // application
{
{
HtmlAreaLoaderScript(array("editor", "editor2"));
echo html_frame_start("Potential duplicate applications in the database","90%","",0);
perform_search_and_output_results($oApp->sName);
echo html_frame_end("&nbsp;");
@@ -274,7 +274,7 @@ if ($_REQUEST['sub'])
// application desc
echo '<tr valign=top><td class=color0><b>Application Description</b></td>',"\n";
echo '<td><p style="width:700px"><textarea cols="80" rows="20" name="applicationDescription">'.stripslashes($oApp->sDescription).'</textarea></p></td></tr>',"\n";
echo '<td><p style="width:700px"><textarea id="editor" cols="80" rows="20" name="applicationDescription">'.stripslashes($oApp->sDescription).'</textarea></p></td></tr>',"\n";
// version name
echo '<tr valign=top><td class="color0"><b>Version name</b></td>',"\n";
@@ -282,7 +282,7 @@ if ($_REQUEST['sub'])
// version description
echo '<tr valign=top><td class=color0><b>Version Description</b></td>',"\n";
echo '<td><p style="width:700px"><textarea cols="80" rows="20" id="editor" name="versionDescription">'.stripslashes($oVersion->sDescription).'</textarea></p></td></tr>',"\n";
echo '<td><p style="width:700px"><textarea cols="80" rows="20" id="editor2" name="versionDescription">'.stripslashes($oVersion->sDescription).'</textarea></p></td></tr>',"\n";
echo '<tr valign=top><td class="color0"><b>email Text</b></td>',"\n";

View File

@@ -30,11 +30,8 @@ if(isset($_REQUEST['submit']))
else
// Show the form for editing the Application Family
{
?>
<link rel="stylesheet" href="./application.css" type="text/css">
<!-- load HTMLArea -->
<script type="text/javascript" src="../htmlarea/htmlarea_loader.js"></script>
<?php
HtmlAreaLoaderScript(array("editor"));
$family = new TableVE("edit");
$result = query_appdb("SELECT * from appFamily WHERE appId = '{$_REQUEST['appId']}'");

View File

@@ -45,11 +45,9 @@ else
$_REQUEST['appId'] = $oNote->iAppId;
$_REQUEST['versionId'] = $oNote->iVersionId;
}
?>
<link rel="stylesheet" href="./application.css" type="text/css">
<!-- load HTMLArea -->
<script type="text/javascript" src="../htmlarea/htmlarea_loader.js"></script>
<?php
HtmlAreaLoaderScript(array("editor"));
// show form
apidb_header("Edit Application Note");

View File

@@ -25,11 +25,9 @@ if(isset($_REQUEST['submit']))
redirect(apidb_fullurl("appview.php?versionId=".$_REQUEST['versionId']));
} else /* or display the webform for making changes */
{
?>
<link rel="stylesheet" href="./application.css" type="text/css">
<!-- load HTMLArea -->
<script type="text/javascript" src="../htmlarea/htmlarea_loader.js"></script>
<?php
HtmlAreaLoaderScript(array("editor")); /* load the appropriate htmlarea controls */
$oVersion = new Version($_REQUEST['versionId']);
apidb_header("Edit Application Version");

View File

@@ -66,12 +66,6 @@ if ($_REQUEST['sub'])
{
$x = new TableVE("view");
apidb_header("Admin Rejected App Queue");
?>
<link rel="stylesheet" href="./application.css" type="text/css">
<!-- load HTMLArea -->
<script type="text/javascript" src="../htmlarea/htmlarea_loader.js"></script>
<?php
echo '<form name="qform" action="'.$_SERVER['PHP_SELF'].'" method="post" enctype="multipart/form-data">',"\n";
echo '<input type="hidden" name="sub" value="ReQueue">',"\n";
@@ -80,6 +74,8 @@ if ($_REQUEST['sub'])
if (!$oApp) //app version
{
HtmlAreaLoaderScript(array("editor"));
echo html_frame_start("Potential duplicate versions in the database","90%","",0);
$oApp = new Application($oVersion->iAppId);
display_versions($oApp->iAppId, $oApp->aVersionsIds);
@@ -120,6 +116,8 @@ if ($_REQUEST['sub'])
echo '</table></form>',"\n";
} else // application
{
HtmlAreaLoaderScript(array("editor"));
echo html_frame_start("Potential duplicate applications in the database","90%","",0);
perform_search_and_output_results($oApp->sName);
echo html_frame_end("&nbsp;");
@@ -198,7 +196,7 @@ if ($_REQUEST['sub'])
// application desc
echo '<tr valign=top><td class=color0><b>Application Description</b></td>',"\n";
echo '<td><p style="width:700px"><textarea cols="80" rows="20" name="applicationDescription">'.stripslashes($oApp->sDescription).'</textarea></p></td></tr>',"\n";
echo '<td><p style="width:700px"><textarea cols="80" rows="20" id="editor" name="applicationDescription">'.stripslashes($oApp->sDescription).'</textarea></p></td></tr>',"\n";
// version name
echo '<tr valign=top><td class="color0"><b>Version name</b></td>',"\n";
@@ -206,7 +204,7 @@ if ($_REQUEST['sub'])
// version description
echo '<tr valign=top><td class=color0><b>Version Description</b></td>',"\n";
echo '<td><p style="width:700px"><textarea cols="80" rows="20" id="editor" name="versionDescription">'.$oVersion->sDescription.'</textarea></p></td></tr>',"\n";
echo '<td><p style="width:700px"><textarea cols="80" rows="20" id="editor2" name="versionDescription">'.$oVersion->sDescription.'</textarea></p></td></tr>',"\n";
echo '<tr valign=top><td class="color0"><b>email Text</b></td>',"\n";

View File

@@ -12,7 +12,7 @@ require(BASE."include/application.php");
* Templates
* FIXME: put templates in config file or somewhere else.
*/
//$sAppDescription = "<p>Enter description here</p>";
$sAppDescription = "<p>Enter a description of the application here</p>";
$sVersionDescription = "<p>This is a template; enter version-specific description here</p>
<p>
<span class=\"title\">Wine compatibility</span><br />
@@ -85,9 +85,7 @@ if (isset($_REQUEST['appName']))
if($vendorName) $_REQUEST['vendorId']="";
$oApplication = new Application();
// FIXME When two htmlarea will be able to live on the same page
// without problems under gecko, remove the <p></p> around appDescrion
$oApplication->create($_REQUEST['appName'], "<p>".$_REQUEST['appDescription']."</p>", $_REQUEST['keywords']." *** ".$_REQUEST['vendorName'], $_REQUEST['webpage'], $_REQUEST['vendorId'], $_REQUEST['catId']);
$oApplication->create($_REQUEST['appName'], $_REQUEST['appDescription'], $_REQUEST['keywords']." *** ".$_REQUEST['vendorName'], $_REQUEST['webpage'], $_REQUEST['vendorId'], $_REQUEST['catId']);
$oVersion = new Version();
$oVersion->create($_REQUEST['versionName'], $_REQUEST['versionDescription'], null, null, $oApplication->iAppId);
redirect(apidb_fullurl("index.php"));
@@ -116,52 +114,10 @@ elseif (isset($_REQUEST['versionName']) && is_numeric($_REQUEST['appId']))
*/
if (isset($_REQUEST['apptype']))
{
// header
apidb_header("Submit Application");
// header
apidb_header("Submit Application");
//FIXME: use absolute path in htmlarea_loader.js to avoid code duplication here
?>
<!-- load HTMLArea -->
<script type="text/javascript">
_editor_url = "./htmlarea/";
_editor_lang = "en";
function initDocument() {
config = new HTMLArea.Config();
config.toolbar = [
[ "bold", "italic", "underline", "strikethrough", "separator",
"copy", "cut", "paste", "space", "undo", "redo", "separator",
"justifyleft", "justifycenter", "justifyright", "justifyfull", "separator",
"orderedlist", "unorderedlist", "outdent", "indent", "separator",
"forecolor", "hilitecolor", "separator",
"inserthorizontalrule", "createlink", "inserttable" ]
];
config.width = 700;
config.pageStyle = "@import url(./application.css);";
// FIXME: when both editors and stylesheets are used, sometimes one of the editor is readonly under gecko
// var editor = new HTMLArea("editor",config);
// editor.registerPlugin(DynamicCSS);
<?php
// if($_REQUEST['apptype'] == 1) // we have two editors, one for application and one for version.
//{
?>
var editor2 = new HTMLArea("editor2",config);
editor2.generate();
editor2.registerPlugin(DynamicCSS);
<?php
//}
?>
// FIXME: when both editors and stylesheets are used, sometimes one of the editor is readonly under gecko
// editor.generate();
}
onload = function() {
HTMLArea.loadPlugin("DynamicCSS");
HTMLArea.init();
HTMLArea.onload = initDocument;
}
</script>
<script type="text/javascript" src="./htmlarea/htmlarea.js"></script>
<?php
HtmlAreaLoaderScript(array("editor", "editor2"));
// show add to queue form
echo '<form name="newApp" action="appsubmit.php" method="post">'."\n";
@@ -169,7 +125,7 @@ onload = function() {
echo "database. The application will be reviewed by the AppDB Administrator\n";
echo "and you will be notified via email if this application will be added to\n";
echo "the database.</p>\n";
echo "<p>Before continuing please check that you have:\n";
echo "<p><h2>Before continuing please check that you have:</h2>\n";
echo "<ul>\n";
if ($_REQUEST['apptype'] == 1)
{
@@ -179,15 +135,18 @@ onload = function() {
echo " and click on 'Submit new version'</li>\n";
}
echo " <li>Entered a valid version for this application. This is the application\n";
echo " version, NOT the wine version(which goes in the testing results section of the template</li>\n";
echo " version, NOT the wine version(which goes in the testing results section of the template)</li>\n";
echo " <li>Tested this application under Wine. There are tens of thousands of applications\n";
echo " for windows, we don't need placeholder entries in the database. Please enter as complete \n";
echo " as possible testing results in the version template provided below</li>\n";
echo "</ul></p>";
echo "<p>Please don't forget to mention which Wine version you used, how well it worked\n";
echo "and if any workaround were needed. Having app descriptions just sponsoring the app\n";
echo "(Yes, some vendor want to use the appdb for this) or saying \"I haven't tried this app with Wine\" ";
echo "(Yes, some vendors want to use the appdb for this) or saying \"I haven't tried this app with Wine\" ";
echo "won't help Wine development or Wine users.</p>\n";
echo "<b><span style=\"color:red\">Please only submit applications/versions that you have tested.\n";
echo "Submissions without testing information or not using the provided template will be rejected.\n";
echo "If you can't see the in-browser editors below please try Firefox, Mozilla or Opera browsers.\n</span></b>";
echo "<p>After your application has been added you'll be able to submit screenshots for it, post";
echo " messages in its forums or become a maintainer to help others trying to run the application.</p>";
if(!empty($errors))
@@ -228,7 +187,11 @@ onload = function() {
echo '<td><input size="80%" type="text" name="keywords" value="'.$_REQUEST['keywords'].'"></td></tr>',"\n";
echo '<tr valign=top><td class="color0"><b>Application Description</b></td>',"\n";
echo '<td><p><textarea cols="80" rows="20" name="appDescription">';
if(trim(strip_tags($_REQUEST['appDescription']))=="")
{
$_REQUEST['appDescription'] = $sAppDescription;
}
echo '<td><p><textarea cols="80" rows="20" id="editor" name="appDescription">';
echo $_REQUEST['appDescription'].'</textarea></p></td></tr>',"\n";
}

View File

@@ -769,4 +769,203 @@ function display_page_range($currentPage=1, $pageRange=1, $totalPages=1, $linkur
}
// Expand a path like /something/somedirectory/../ to /something
// from http://us2.php.net/realpath
function SimplifyPath($path) {
$dirs = explode('/',$path);
for($i=0; $i<count($dirs);$i++) {
if($dirs[$i]=="." || $dirs[$i]=="") {
array_splice($dirs,$i,1);
$i--;
}
if($dirs[$i]=="..") {
$cnt = count($dirs);
$dirs=Simplify($dirs, $i);
$i-= $cnt-count($dirs);
}
}
return implode('/',$dirs);
}
function Simplify($dirs, $idx) {
if($idx==0) return $dirs;
if($dirs[$idx-1]=="..") Simplify($dirs, $idx-1);
else array_splice($dirs,$idx-1,2);
return $dirs;
}
// End of snippet of code copied from php.net
// Use the directory of PHP_SELF and BASE and the relative path
// to get a simplified path to an appdb directory or file
// Used for the Xinha _editor_url because some plugins like SpellChecker
// won't work with relative paths like ../xinha
function GetSimplifiedPath($relative)
{
return "/".SimplifyPath(dirname($_SERVER[PHP_SELF])."/".BASE.$relative);
}
function HtmlAreaLoaderScript($aTextareas)
{
echo '
<script type="text/javascript">';
// You must set _editor_url to the URL (including trailing slash) where
// where xinha is installed, it's highly recommended to use an absolute URL
// eg: _editor_url = "/path/to/xinha/";
// You may try a relative URL if you wish]
// eg: _editor_url = "../";
// in this example we do a little regular expression to find the absolute path.
// NOTE: we use GetSimplifiedPath() because we cannot use a relative path and have
// all of the plugins work correctly. Specifically the SpellChecker plugin
// requires a absolute url path to the xinha directory
echo '
_editor_url = "'.GetSimplifiedPath("xinha/").'", \'\';
_editor_lang = "en"; // And the language we need to use in the editor.
</script>';
echo '
<!-- Load up the actual editor core -->
<script type="text/javascript" src="'.BASE.'xinha/htmlarea.js"></script>
<script type="text/javascript">
xinha_editors = null;
xinha_init = null;
xinha_config = null;
xinha_plugins = null;
// This contains the names of textareas we will make into Xinha editors
xinha_init = xinha_init ? xinha_init : function()
{';
/** STEP 1 ***************************************************************
* First, what are the plugins you will be using in the editors on this
* page. List all the plugins you will need, even if not all the editors
* will use all the plugins.
************************************************************************/
echo '
xinha_plugins = xinha_plugins ? xinha_plugins :
[
\'CharacterMap\',
\'CharCounter\',
\'ContextMenu\',
\'FullScreen\',
\'ListType\',
\'SpellChecker\',
\'Stylist\',
\'SuperClean\',
\'TableOperations\',
\'DynamicCSS\',
\'FindReplace\'
];
// THIS BIT OF JAVASCRIPT LOADS THE PLUGINS, NO TOUCHING :)
if(!HTMLArea.loadPlugins(xinha_plugins, xinha_init)) return;';
/** STEP 2 ***************************************************************
* Now, what are the names of the textareas you will be turning into
* editors?
************************************************************************/
// NOTE: we generate the editor names here so we can easily have any number of htmlarea editors
// and can reuse all of this code
echo '
xinha_editors = xinha_editors ? xinha_editors :
[';
$firstEntry = true;
foreach($aTextareas as $key=>$value)
{
if($firstEntry)
{
echo "'$value'";
$firstEntry = false;
} else
{
echo ", '$value'";
}
}
echo '
];';
/** STEP 3 ***************************************************************
* We create a default configuration to be used by all the editors.
* If you wish to configure some of the editors differently this will be
* done in step 5.
*
* If you want to modify the default config you might do something like this.
*
* xinha_config = new HTMLArea.Config();
* xinha_config.width = \'640px\';
* xinha_config.height = \'420px\';
*
*************************************************************************/
echo '
xinha_config = new HTMLArea.Config();
xinha_config.toolbar = [
["popupeditor"],
["separator","fontsize","bold","italic","underline","strikethrough"],
["separator","forecolor","hilitecolor","textindicator"],
["separator","subscript","superscript"],
["linebreak","separator","justifyleft","justifycenter","justifyright","justifyfull"],
["separator","insertorderedlist","insertunorderedlist","outdent","indent"],
["separator","inserthorizontalrule","createlink","inserttable"],
["separator","undo","redo","selectall"], (HTMLArea.is_gecko ? [] : ["cut","copy","paste","overwrite","saveas"]),
["separator","killword","removeformat","toggleborders","lefttoright", "righttoleft","separator","htmlmode","about"]
];
xinha_config.pageStyle = "@import url('.BASE."application.css".');";
';
/** STEP 4 ***************************************************************
* We first create editors for the textareas.
*
* You can do this in two ways, either
*
* xinha_editors = HTMLArea.makeEditors(xinha_editors, xinha_config, xinha_plugins);
*
* if you want all the editor objects to use the same set of plugins, OR;
*
* xinha_editors = HTMLArea.makeEditors(xinha_editors, xinha_config);
* xinha_editors['myTextArea'].registerPlugins(['Stylist','FullScreen']);
* xinha_editors['anotherOne'].registerPlugins(['CSS','SuperClean']);
*
* if you want to use a different set of plugins for one or more of the
* editors.
************************************************************************/
echo '
xinha_editors = HTMLArea.makeEditors(xinha_editors, xinha_config, xinha_plugins);';
/** STEP 5 ***************************************************************
* If you want to change the configuration variables of any of the
* editors, this is the place to do that, for example you might want to
* change the width and height of one of the editors, like this...
*
* xinha_editors.myTextArea.config.width = '640px';
* xinha_editors.myTextArea.config.height = '480px';
*
************************************************************************/
/** STEP 6 ***************************************************************
* Finally we "start" the editors, this turns the textareas into
* Xinha editors.
************************************************************************/
echo '
HTMLArea.startEditors(xinha_editors);
}
window.onload = xinha_init;
</SCRIPT>
';
}
?>