1
0
mirror of https://github.com/e107inc/e107.git synced 2025-06-02 00:45:03 +02:00

Clean up of old preset_class code and tinymce fixes.

This commit is contained in:
CaMer0n 2012-08-12 00:24:02 +00:00
parent 7ef1ea179a
commit c4c8cbdc53
17 changed files with 89 additions and 158 deletions

View File

@ -56,7 +56,6 @@ $frm = new e_form;
$download = new download;
require_once("auth.php");
$pst->save_preset(); // unique name(s) for the presets - comma separated.
/*
One form example (no arrays needed)

View File

@ -252,7 +252,7 @@ echo "<!-- *JS* -->\n";
// Wysiwyg JS support on or off.
// your code should run off e_WYSIWYG
if (varset($pref['wysiwyg'], FALSE) && check_class($pref['post_html']))
if (varset($pref['wysiwyg'], FALSE) ) // posts bbcode by default.
{
define("e_WYSIWYG", TRUE);
}
@ -291,23 +291,6 @@ if (is_readable(e_FILE.'user.js') && filesize(e_FILE.'user.js'))
echo "<script type='text/javascript' src='".e_FILE_ABS."user.js'></script>\n";
}
// XXX - This shouldn't be here as well
if ((strpos(e_SELF, 'fileinspector.php') === FALSE) && getperms("0"))
{
echo "<script type='text/javascript'>
<!--
function savepreset(ps,pid){
if(confirm('".e107::getParser()->toJS(LAN_PRESET_CONFIRMSAVE)."'))
{
document.getElementById(ps).action='".e_SELF."?savepreset.'+pid;
document.getElementById(ps).submit();
}
}
//-->
</script>\n";
}
// [JSManager] Load JS Includes - Zone 3 - before e_meta and headerjs()
e107::getJs()->renderJs('header', 3);

View File

@ -645,30 +645,12 @@ class media_admin_ui extends e_admin_ui
$this->updateSettings();
}
// filepicker stuff.
if($this->getQuery('mode') == 'dialog')//TODO Check this actually does something, as it was changed to 'action'.
{
if(!ADMIN){ exit; }
$cat = $_GET['for'];
if(!isset($this->cats[$cat]))
{
return;
}
$this->listQry = "SELECT m.*,u.user_id,u.user_name FROM #core_media AS m LEFT JOIN #user AS u ON m.media_author = u.user_id WHERE media_category = '".$cat."' "; // without any Order or Limit.
unset($this->fields['checkboxes']);
$this->fields['options']['type'] = 'method';
$this->fields['media_category']['nolist'] = true;
$this->fields['media_userclass']['nolist'] = true;
$this->fields['media_dimensions']['nolist'] = true;
$this->fields['media_description']['nolist'] = true;
$this->fields['media_type']['nolist'] = true;
foreach($this->fields as $k=>$v)
{
$this->fields[$k]['filter'] = false;
}
}
@ -736,26 +718,39 @@ class media_admin_ui extends e_admin_ui
{
$cat = $this->getQuery('for');
$file = (substr($cat,-5) == "_file") ? TRUE : FALSE;
$mes = e107::getMessage();
$mes->addDebug("For:".$cat);
if($file)
{
$cat = $_GET['for'];
if(!isset($this->cats[$cat]))
{
return;
}
echo $this->getUI()->getList();
return;
$this->listQry = "SELECT m.*,u.user_id,u.user_name FROM #core_media AS m LEFT JOIN #user AS u ON m.media_author = u.user_id WHERE m.media_category = '".$cat."' "; // without any Order or Limit.
unset($this->fields['checkboxes']);
$this->fields['options']['type'] = 'method';
$this->fields['media_category']['nolist'] = true;
$this->fields['media_userclass']['nolist'] = true;
$this->fields['media_dimensions']['nolist'] = true;
$this->fields['media_description']['nolist'] = true;
$this->fields['media_type']['nolist'] = true;
foreach($this->fields as $k=>$v)
{
$this->fields[$k]['filter'] = false;
}
echo $this->mediaSelectUpload('file');
}
else
{
echo $this->mediaSelectUpload();
}
// $this->getModel()->setAction('create');
// $this->getUI()->getController()->getRequest()->setAction('create');
//$this->setAction('create');;
if($_POST['etrigger_submit'])
{
// $data = $this->beforeCreate($_POST);
// e107::getDb()->db_Insert('core_media',$data); // Replace with Generic (needs parm sent)
}
echo $this->imageSelectUpload();
}
@ -774,7 +769,7 @@ class media_admin_ui extends e_admin_ui
}
function imageSelectUpload()
function mediaSelectUpload($type='image')
{
$frm = e107::getForm();
$bbcodeMode = ($this->getQuery('bbcode')=='img') ? 'bbcode=img' : FALSE;
@ -806,7 +801,14 @@ class media_admin_ui extends e_admin_ui
$tag = ($bbcodeMode) ? "" : $this->getQuery('tagid');
$text .= e107::getMedia()->mediaSelect($this->getQuery('for'),$this->getQuery('tagid'),$bbcodeMode); // eg. news, news-thumbnail
if($type == 'file')
{
$text .= $this->getUI()->getList(); //FIXME NOT WORKING!
}
else
{
$text .= e107::getMedia()->mediaSelect($this->getQuery('for'),$this->getQuery('tagid'),$bbcodeMode); // eg. news, news-thumbnail
}
$text .= "
</td></tr>

View File

@ -125,7 +125,7 @@ CREATE TABLE core (
CREATE TABLE core_media (
media_id int(10) unsigned NOT NULL auto_increment,
media_type varchar(15) NOT NULL default '',
media_type varchar(50) NOT NULL default '',
media_name varchar(255) NOT NULL default '',
media_caption varchar(255) NOT NULL default '',
media_description varchar(255) NOT NULL default '',

View File

@ -25,14 +25,8 @@ include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE);
$e_sub_cat = 'wmessage';
require_once(e_HANDLER."preset_class.php");
$pst = new e_preset;
$pst->form = "wmform";
$pst->page = "wmessage.php?create";
$pst->id = "admin_wmessage";
require_once("auth.php");
$pst->save_preset(); // save and render result
require_once("auth.php");
require_once(e_HANDLER.'form_handler.php');
require_once(e_HANDLER.'userclass_class.php');
require_once(e_HANDLER."ren_help.php");
@ -161,15 +155,6 @@ if ($action == "create" || $action == "edit")
$row = $sql->db_Fetch();
}
if ($sub_action != 'edit')
{
$preset = $pst->read_preset("admin_wmessage");
if (is_array($preset))
{
extract($preset);
}
}
$text = "
<div style='text-align:center'>
<form method='post' action='".e_SELF."' id='wmform'>

View File

@ -277,8 +277,10 @@ class e_file
}
$tmp = stat($path_to_file);
if($tmp)
{
$finfo['fsize'] = $tmp['size'];
$finfo['modified'] = $tmp['mtime'];
}
@ -286,6 +288,7 @@ class e_file
// associative array elements: dirname, basename, extension, filename
$finfo['pathinfo'] = pathinfo($path_to_file);
$finfo['mime'] = vartrue($finfo['mime'],'application/'.$finfo['pathinfo']['extension']);
return $finfo;
}

View File

@ -410,7 +410,8 @@ class e_form
$label = "<span id='{$name_id}_prev' >".basename($default_label)."</span>";
$ret .= $this->mediaUrl($cat, $label,$name_id,"mode=dialog&action=list");
// $ret .= $this->mediaUrl($cat, $label,$name_id,"mode=dialog&action=list");
$ret .= $this->mediaUrl($cat, $label,$name_id,"mode=main&action=dialog");
$ret .= "<input type='hidden' name='{$name}' id='{$name_id}' value='{$default}' style='width:400px' />";
return $ret;

View File

@ -621,7 +621,8 @@ class e_media
if(!vartrue($this->mimePaths[$pmime]))
{
$mes->add("Couldn't detect mime-type($mime). Upload failed.", E_MESSAGE_ERROR);
$this->log("Couldn't detect mime-type ($mime).");
$mes->add("Couldn't detect mime-type ($mime). Upload failed.", E_MESSAGE_ERROR);
return FALSE;
}
@ -631,6 +632,7 @@ class e_media
{
if(!mkdir($dir, 0755))
{
$this->log("Couldn't create folder ($dir).");
$mes->add("Couldn't create folder ($dir).", E_MESSAGE_ERROR);
return FALSE;
};
@ -650,13 +652,16 @@ class e_media
if(!is_readable($path))
{
$mes->addError("Couldn't read file: {$path}");
$this->log("Couldn't read file: {$path}");
return FALSE;
}
$info = e107::getFile()->get_file_info($path);
$info = e107::getFile()->get_file_info($path,true);
$this->log("File info for $path : ".print_r($info,true));
return array(
'media_type' => $info['mime'],
'media_type' => vartrue($info['mime']),
'media_datestamp' => time(),
'media_url' => e107::getParser()->createConstants($path, 'rel'),
'media_size' => filesize($path),
@ -667,6 +672,13 @@ class e_media
);
}
@ -691,7 +703,7 @@ class e_media
if(!file_exists($oldpath))
{
$this->log("Couldn't find the file: ".$oldpath);
$this->log("Line: ".__LINE__." Couldn't find the file: ".$oldpath);
$mes->add("Couldn't find the file: ".$oldpath, E_MESSAGE_ERROR);
return;
}
@ -699,10 +711,9 @@ class e_media
$img_data = $this->mediaData($oldpath); // Basic File Info only
if(!$typePath = $this->getPath($img_data['media_type']))
{
$this->log("Couldn't generated path from file info:".$oldpath);
$mes->addError("Couldn't generated path from file info:".$oldpath);
{
$this->log("Line: ".__LINE__." Couldn't generate path from file info:".$oldpath);
$mes->addError("Couldn't generate path from file info:".$oldpath);
return FALSE;
}

View File

@ -149,7 +149,7 @@ else
$oc = "";
}
$texta .= "
<textarea class='e-wysiwyg tbox chatbox' id='cmessage' name='cmessage' cols='20' rows='5' style='".($cb_width ? "width:".$cb_width.";" : '')." overflow: auto' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'></textarea>
<textarea class='tbox chatbox' id='cmessage' name='cmessage' cols='20' rows='5' style='".($cb_width ? "width:".$cb_width.";" : '')." overflow: auto' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'></textarea>
<br />
<input class='button' type='submit' id='chat_submit' name='chat_submit' value='".CHATBOX_L4."' {$oc}/>
<input class='button' type='reset' name='reset' value='".CHATBOX_L5."' />";

View File

@ -56,19 +56,11 @@ $pst->id = array("admin_downloads","admin_dl_cat");
$download = new download();
// $adminDownload = new adminDownload();
$pst->save_preset(); // unique name(s) for the presets - comma separated.
new plugin_download_admin();
require_once(e_ADMIN."auth.php");
/*
One form example (no arrays needed)
$pst->form = "myform"; // form id of the form that will have it's values saved.
$pst->page = "download.php?create"; // display preset options on which page.
$pst->save_preset("admin_downloads"); // unique name for the preset
*/
/*
$rs = new form;

View File

@ -579,8 +579,6 @@ $columnInfo = array(
$download_status[0] = DOWLAN_122;
$download_status[1] = DOWLAN_123;
$download_status[2] = DOWLAN_124;
$preset = $pst->read_preset("admin_downloads"); // read preset values into array
extract($preset);
if (!$sql->db_Select("download_category"))
{

View File

@ -26,6 +26,17 @@ if(e_WYSIWYG || strpos(e_SELF,"tinymce/admin_config.php") )
e107::js('tinymce','tiny_mce_popup.js','jquery');
}
if(ADMIN)
{
define("SWITCH_TO_BB","$('#'+id).after('<div><a href=\"#\" id=\"' + id + '\" class=\"e-wysiwyg-toggle\">Switch to BBCODE</a></div>');");
}
else
{
define("SWITCH_TO_BB","");
}
// print_a($_POST);
// <div><a href='#' class='e-wysiwyg-switch' onclick=\"tinyMCE.execCommand('mceToggleEditor',false,'".$tinyMceID."');expandit('".$toggleID."');\">Toggle WYSIWYG</a></div>
e107::js('inline',"
@ -34,17 +45,12 @@ if(e_WYSIWYG || strpos(e_SELF,"tinymce/admin_config.php") )
$('.e-wysiwyg').each(function() {
var id = $(this).attr('id'); // 'e-wysiwyg';
$('#'+id).after('<div><a href=\"#\" id=\"' + id + '\" class=\"e-wysiwyg-toggle\">Switch to BBCODE</a></div>');
".SWITCH_TO_BB."
// alert(id);
$('#bbcode-panel-'+id+'--preview').hide();
});
// jQuery.e-tab-add = function()
// {
// alert('added tab');
// }
// When new tab is added - convert textarea to TinyMce.
$('.e-tabs-add').on('click',function(){
@ -55,7 +61,7 @@ if(e_WYSIWYG || strpos(e_SELF,"tinymce/admin_config.php") )
var ct = parseInt($('#e-tab-count').val());
var id = idt + '-' + ct;
$('#bbcode-panel-'+id+'--preview').hide();
$('#'+id).after('<div><a href=\"#\" id=\"' + id + '\" class=\"e-wysiwyg-toggle\">Switch to BBCODE</a></div>');
".SWITCH_TO_BB."
tinyMCE.execCommand('mceAddControl', false, id);
});
@ -93,23 +99,6 @@ if(e_WYSIWYG || strpos(e_SELF,"tinymce/admin_config.php") )
","jquery");
e107::css('inline',".e-wysiwyg { width:100% }","jquery");
// require_once(e_PLUGIN."tinymce/wysiwyg.php");
if(deftrue('TINYMCE_CONFIG'))
{
// $wy = new wysiwyg(TINYMCE_CONFIG);
}
else
{
// $wy = new wysiwyg();
}
if(!strpos(e_SELF,e_ADMIN_ABS."image.php"))
{
// $wy -> render();
}
}

View File

@ -17,7 +17,7 @@ if($_POST['mode'] == 'tohtml')
{
$content = $tp->toDB($_POST['content']);
e107::getBB()->setClass($_SESSION['media_category']);
echo $tp->toHtml($content, true, 'wysiwyg');
echo $tp->toHtml($content, true);
e107::getBB()->clearClass();
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<tinymce>
<tinymce_name>Simple Users</tinymce_name>
<tinymce_userclass>252</tinymce_userclass>
<tinymce_plugins>e107bbcode,emoticons,jqueryinlinepopups</tinymce_plugins>
<tinymce_buttons1>bold, italic, underline, undo, redo, link, unlink, image, forecolor, bullist, numlist, outdent, indent, emoticons</tinymce_buttons1>
<tinymce_name>Main Admin</tinymce_name>
<tinymce_plugins>advhr,advlink,autosave,contextmenu,directionality,e107bbcode,emoticons,ibrowser,paste,table,visualchars,wordcount,xhtmlxtras,youtube</tinymce_plugins>
<tinymce_buttons1>link, unlink, bold, italic, underline, undo, redo,formatselect,justifyleft,justifycenter,justifyright,justifyfull, |, ibrowser, forecolor, removeformat, table, bullist, numlist, outdent, indent, cleanup, emoticons, youtube</tinymce_buttons1>
<extended_valid_elements>object[*],embed[*]</extended_valid_elements>
</tinymce>

View File

@ -29,16 +29,8 @@ class wysiwyg
{
$this->getConfig($config);
$pref = e107::getConfig();
/*
if(strstr(varset($_SERVER["HTTP_ACCEPT_ENCODING"],""), "gzip") && (ini_get("zlib.output_compression") == false) && file_exists(e_PLUGIN."tinymce/tiny_mce_gzip.php"))
{
@ -198,32 +190,7 @@ class wysiwyg
$newConfig[] = "\t\t ".$key." : ".$val;
}
// foreach($this->config as $key=>$val)
// {
// if($val != 'true' && $val !='false')
// {
// $val = "'".$val."'";
// }
// $text .= "\t\t ".$key." : '".$val."',\n";
// }
$text .= implode(",\n",$newConfig);
/*
if($tinyMcePrefs['customjs'])
{
$text .= "\n,
// Start Custom TinyMce JS -----
".$pref['tinymce']['customjs']."
// End Custom TinyMce JS ---
";
}
*/
$text .= "
});
@ -265,7 +232,7 @@ class wysiwyg
$this->config = array(
'language' => $this->tinymce_lang(),
'mode' => 'textareas',
'mode' => 'specific_textareas',
'editor_selector' => 'e-wysiwyg',
'editor_deselector' => 'e-wysiwyg-off',
'theme' => 'advanced',
@ -300,7 +267,7 @@ class wysiwyg
'debug' => 'false',
'force_br_newlines' => 'true',
'media_strict' => 'false',
'width' => '85%',
'width' => vartrue($config['width'],'100%'),
// 'height' => '90%', // higher causes padding at the top?
// 'forced_root_block' => '',
'convert_newlines_to_brs' => 'true', // will break [list] if set to true

View File

@ -137,7 +137,7 @@ echo "<title>".(defined('e_PAGETITLE') ? e_PAGETITLE.' - ' : (defined('PAGE_NAME
// Wysiwyg JS support on or off.
if (varset($pref['wysiwyg'],FALSE) && check_class($pref['post_html']))
if (varset($pref['wysiwyg'],FALSE))
{
define("e_WYSIWYG",TRUE);
}

View File

@ -209,7 +209,8 @@ $text .= "
<tr>
<td style='width:20%' class='forumheader3'>".LAN_135."</td>
<td style='width:80%' class='forumheader3'>
<textarea class='e-wysiwyg tbox' id='submitnews_item' name='submitnews_item' cols='80' style='max-width:95%' {$insertjs}>".$tp->toHTML($_POST['submitnews_item'],TRUE,'USER_BODY')."</textarea><br />";
<textarea class='e-wysiwyg tbox' id='submitnews_item' name='submitnews_item' cols='80' style='max-width:95%' {$insertjs}>".$tp->toForm($_POST['submitnews_item'],TRUE,'USER_BODY')."</textarea><br />";
// toHTML is dangerous.
if (!e_WYSIWYG)
{