1
playsome
replace FCKeditor with xoopsformdhtmltextarea in tad faq?
  • 2011/5/22 19:27

  • playsome

  • Not too shy to talk

  • Posts: 197

  • Since: 2009/4/15


Hello all,

I am trying to figure out how i would replace fckeditor which is the default editor of the module tad faq, the reason is I am trying to alter tad faq into a module for displaying code snippets for a site im working on and I want to be able to use xcode so i can have the syntax highlighting.

I have a rough understanding ob oo programming (java) but I cant figure out how to instantiate a new dhtmltextarea object, in the orginal code of tad_faq/admin/add.php it looks like only one parameter (content) was being passed when instantiating the new fck editor object but am i correct in saying that there should be at least 2 parameters for xoopsformdhtmltextarea ?

here is the code of tad_faq/admin/add.php:

//  ------------------------------------------------------------------------ //
// ¥»¼Ò²Õ¥Ñ tad »s§@
// »s§@¤é´Á¡G2008-07-02
// $Id: function.php,v 1.1 2008/05/14 01:22:08 tad Exp $
// ------------------------------------------------------------------------- //

/*-----------¤Þ¤JÀÉ®×°Ï--------------*/
include "../../../include/cp_header.php";
include 
"../function.php";
include_once 
XOOPS_ROOT_PATH."/Frameworks/art/functions.php";
include_once 
XOOPS_ROOT_PATH."/Frameworks/art/functions.admin.php";

/*-----------function°Ï--------------*/

//¤ÀÃþ¿ï³æ
function get_faq_cate_opt($the_fcsn=""){
    global 
$xoopsDB;
    
$opt="";
    
$sql "select fcsn,title from ".$xoopsDB->prefix("tad_faq_cate")." order by sort";
    
$result $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'],3mysql_error());
    while(list(
$fcsn,$title)=$xoopsDB->fetchRow($result)){
      
$selected=($the_fcsn==$fcsn)?"selected":"";
      
$opt.="$fcsn$selected>$title";
    }
    return 
$opt;
}


//tad_faq_content½s¿èªí³æ
function tad_faq_content_form($fqsn=""){
    global 
$xoopsDB;

    
//§ì¨ú¹w³]­È
    
if(!empty($fqsn)){
        
$DBV=get_tad_faq_content($fqsn);
    }else{
        
$DBV=array();
    }

    
//¹w³]­È³]©w

    
$fqsn=(!isset($DBV['fqsn']))?"":$DBV['fqsn'];
    
$fcsn=(!isset($DBV['fcsn']))?"":$DBV['fcsn'];
    
$title=(!isset($DBV['title']))?"":$DBV['title'];
    
$sort=(!isset($DBV['sort']))?"":$DBV['sort'];
    
$uid=(!isset($DBV['uid']))?"":$DBV['uid'];
    
$post_date=(!isset($DBV['post_date']))?"":$DBV['post_date'];
    
$content=(!isset($DBV['content']))?"":$DBV['content'];
    
$enable=(!isset($DBV['enable']))?"1":$DBV['enable'];
    
    
$faq_cate_opt=get_faq_cate_opt($fcsn);

    include(
XOOPS_ROOT_PATH."/modules/tad_faq/class/fckeditor/fckeditor.php") ;
    
$oFCKeditor = new FCKeditor('content') ;
    
$oFCKeditor->BasePath    XOOPS_URL."/modules/tad_faq/class/fckeditor/" ;
    
$oFCKeditor->Config['AutoDetectLanguage']=false;
    
$oFCKeditor->Config['DefaultLanguage']        = 'en' ;
    
$oFCKeditor->ToolbarSet ='my';
    
$oFCKeditor->Width '515' ;
    
$oFCKeditor->Height '250' ;
    
$oFCKeditor->Value =$content;
    
$editor=$oFCKeditor->CreateHtml() ;


    
$op=(empty($fqsn))?"insert_tad_faq_content":"update_tad_faq_content";
    
//$op="replace_tad_faq_content";
    
$main="
  {$_SERVER['PHP_SELF']}' method='post' id='myForm' enctype='multipart/form-data'>
  

    {$fqsn}'>
    "
._MA_TADFAQ_CATE_MENU."
    
    
$faq_cate_opt
    
    "
._MA_TADFAQ_FAQ_TITLE."
    {$title}' style='width:100%;'>
    "
._MA_TADFAQ_CONTENT."
    
$editor
    "
._MA_TADFAQ_ENABLE."
    
    .chk($enable,'1').">"._MA_TADFAQ_FAQ_ENABLE."
    .chk($enable,'0').">"._MA_TADFAQ_FAQ_UNABLE."
    
  
  {$op}'>
  ._MA_SAVE."'>
  
  "
;

    
$main=div_3d(_MA_TADFAQ_ADD_CONTENT,$main);

    return 
$main;
}

//·s¼W¸ê®Æ¨ìtad_faq_content¤¤
function insert_tad_faq_content(){
    global 
$xoopsDB,$xoopsUser;
    
    
$uid=($xoopsUser)?$xoopsUser->getVar('uid'):"";
    
$sort=get_max_faq_sort($_POST['fcsn']);
    
    
$sql "insert into ".$xoopsDB->prefix("tad_faq_content")." (`fcsn`,`title`,`sort`,`uid`,`post_date`,`content`,`enable`) values('{$_POST['fcsn']}','{$_POST['title']}','{$sort}','{$uid}',now(),'{$_POST['content']}','{$_POST['enable']}')";
    
$xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'],3mysql_error());
    
//¨ú±o³Ì«á·s¼W¸ê®Æªº¬y¤ô½s¸¹
    
$fqsn=$xoopsDB->getInsertId();
    return 
$fqsn;
}


//¥H¬y¤ô¸¹¨ú±o¬Yµ§tad_faq_content¸ê®Æ
function get_tad_faq_content($fqsn=""){
    global 
$xoopsDB;
    if(empty(
$fqsn))return;
    
$sql "select * from ".$xoopsDB->prefix("tad_faq_content")." where fqsn='$fqsn'";
    
$result $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'],3mysql_error());
    
$data=$xoopsDB->fetchArray($result);
    return 
$data;
}

//§ó·stad_faq_content¬Y¤@µ§¸ê®Æ
function update_tad_faq_content($fqsn=""){
    global 
$xoopsDB;
    
    
$sql "update ".$xoopsDB->prefix("tad_faq_content")." set  `fcsn` = '{$_POST['fcsn']}', `title` = '{$_POST['title']}', `post_date` = now(), `content` = '{$_POST['content']}', `enable` = '{$_POST['enable']}' where fqsn='$fqsn'";
    
$xoopsDB->queryF($sql) or redirect_header($_SERVER['PHP_SELF'],3mysql_error());
    return 
$fqsn;
}

//¦Û°Ê¨ú±o·s±Æ§Ç
function get_max_faq_sort($fcsn=""){
    global 
$xoopsDB,$xoopsModule;
    
$sql "select max(sort) from ".$xoopsDB->prefix("tad_faq_content")." where fcsn='{$fcsn}'";
    
$result $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'],3mysql_error());
    list(
$sort)=$xoopsDB->fetchRow($result);
    return ++
$sort;
}


/*-----------°õ¦æ°Ê§@§PÂ_°Ï----------*/
$op = (!isset($_REQUEST['op']))? "main":$_REQUEST['op'];

switch(
$op){

    
//·s¼W¸ê®Æ
    
case "insert_tad_faq_content":
    
insert_tad_faq_content();
    
header("location: index.php");
    break;

    
//¿é¤Jªí®æ
    
case "tad_faq_content_form";
    
$main=tad_faq_content_form($_GET['fqsn']);
    break;

    
//§ó·s¸ê®Æ
    
case "update_tad_faq_content";
    
update_tad_faq_content($_POST['fqsn']);
    
header("location: index.php");
    break;
    
    
//¹w³]°Ê§@
    
default:
    
$main=tad_faq_content_form($_GET['fqsn']);
    break;
}

/*-----------¨q¥Xµ²ªG°Ï--------------*/
xoops_cp_header();
echo 
"";
loadModuleAdminMenu(1);
echo 
$main;
xoops_cp_footer();

?>


I have tried instantiating a new XoopsFormDhtmlTextArea object and passing the parameter 'content' but it seems to be not enough parameters and i am now well and trully stumped.

Any help would be appreciated.

Cheers.

2
playsome
Re: replace FCKeditor with xoopsformdhtmltextarea in tad faq?
  • 2011/5/24 0:27

  • playsome

  • Not too shy to talk

  • Posts: 197

  • Since: 2009/4/15


HI, can someone post a tutorial on how to add dhtml text areas, even say to a custom module so I can see how its done, sadly im not getting very far.

This is what ive got so far

include (XOOPS_ROOT_PATH."/class/xoopsform/formdhtmltextarea.php");
    
$snForm = new XoopsFormDhtmlTextArea('content',5,50);
    
$snForm->render();


then to display the form

td class='col'>$snFormtd>tr>


needless to say the form does not load.

it was my understanding that calling the render method of the class would, well render the form, thats where im stuck i dont know what else is required to get the form to display. am I calling the method correctly? with ->


Another option to get syntax highlighting:

I downloaded syntax highlighter form alexgorbatchev.com included all the files as required in index_tpl


<
script type="text/javascript" src="<{xoAppUrl /modules/tad_faq/sh/shCore.js}>">script>

<
script type="text/javascript" src="<{xoAppUrl /modules/tad_faq/sh/brushes/shBrushJava.js}>">script>
<
script type="text/javascript" src="<{xoAppUrl /modules/tad_faq/sh/brushes/shBrushJScript.js}>">script>
<
script type="text/javascript" src="<{xoAppUrl /modules/tad_faq/sh/brushes/shBrushPhp.js}>">script>
<
script type="text/javascript" src="<{xoAppUrl /modules/tad_faq/sh/brushes/shBrushCss.js}>">script>
<
script type="text/javascript" src="<{xoAppUrl /modules/tad_faq/sh/brushes/shBrushAS3.js}>">script>

<
link href="<{xoAppUrl /modules/tad_faq/sh/shCore.css}>" type="text/css" rel="stylesheet" />
<
link href="<{xoAppUrl /modules/tad_faq/sh/shThemeDefault.css}>" type="text/css" rel="stylesheet" />
<
script type="text/javascript">
    
SyntaxHighlighter.all()
script>
<{
$toolbar}>
<{
$css}>
<{
$content}>


tried adding some javascript into fck editor using script method as explained on syntaxhihglighter site but the syntax highlighter does not show up the code just shows as text, when putting the javascript into fckeditor 'view source' nothing shows up at all.

anyone got any ideas?

thanks


Login

Who's Online

132 user(s) are online (84 user(s) are browsing Support Forums)


Members: 0


Guests: 132


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Dec 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits