1
astuni
Help with Spaw plz.
  • 2004/6/20 15:08

  • astuni

  • Just popping in

  • Posts: 22

  • Since: 2004/6/7 4


Hello, i've succesfully inserted Spaw in most textareas of my site\modules, but i need help doing something more.
I want a way to enable spaw only if user browser is MSIE otherwise it displays normal textarea field...

Since i use Xfsection, i saw that it use a trick based on an if statement...
if (!strstr($HTTP_SERVER_VARS["HTTP_USER_AGENT"], "MSIE")) $wfsConfig['wysiwygeditor'] = '0';

        if (
$wfsConfig['wysiwygeditor'] == '1') {  
        
//html_editor('maintext');
        
$sw = new SPAW_Wysiwyg'maintext'$this->maintext'en''full''default''98%''550px' );
           
$sw -> show();
        
$smiliepath $wfsConfig['smiliepath'];
        
$smilie_array XoopsLists::getimgListAsArray(XOOPS_ROOT_PATH."/".$smiliepath);

        echo 
"<br /><div style='text-align: left;'><b>" ._AM_SMILIE."</b><br />";
        echo 
"<table><tr><td align='top' valign='left'>";
        echo 
"<div><script type='text/javascript'>
        <!--
            function showbutton() {
                   document.all."
.$textareaname."_mysmile.src = '".$xoopsConfig['xoops_url']."/$smiliepath/' + document.all.".$textareaname."_smiley.value;
            }


the problem here is that if the browser is MSIE it enables wysiwyg editor in $wfsConfig, otherwise is disabled...thats the trick, now since in "NEWS" module, for instance, i dont have any "$wfsConfig" is there a way to make that code like "universal" :)?

//If admin - show admin form
//TODO: Change to "If submit privilege"
if ($approveprivilege) {
    
//Show topic image?
    
$sform->addElement(new XoopsFormRadioYN(_AM_TOPICDISPLAY'topicdisplay'$topicdisplay));
    
//Select image position
    
$posselect = new XoopsFormSelect(_AM_TOPICALIGN'topicalign'$topicalign);
    
$posselect->addOption('R'_AM_RIGHT);
    
$posselect->addOption('L'_AM_LEFT);
    
$sform->addElement($posselect);
    
//Publish in home?
    //TODO: Check that pubinhome is 0 = no and 1 = yes (currently vice versa)
    
$sform->addElement(new XoopsFormRadioYN(_AM_PUBINHOME'ihome'$ihome_NO_YES));
}

[
b]ob_start();
$sw = new SPAW_Wysiwyg'hometext'$hometext'en''full''default''99%''600px' );
$sw -> show();
$sform -> addElement( new XoopsFormLabel_NW_THESCOOPob_get_contents() ) );
ob_end_clean();
//Extra info
//If admin -> if submit privilege
if ($approveprivilege) {
   
ob_start();
$sw = new SPAW_Wysiwyg'bodytext'$bodytext'en''full''default''99%''600px' );
$sw -> show();
$sform -> addElement( new XoopsFormLabel_AM_EXTEXTob_get_contents() ) );
ob_end_clean();
}[/
b]


this is where i've put the spaw lines in modules/news/include/storyform.inc.php
and this is latest news module version...

help me getting this into an if statment with browser check php guru's

cheers Astuni
Long life to XOOPS!

2
Catzwolf
Re: Help with Spaw plz.
  • 2004/6/20 15:57

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


Are you using the spaw module? If you are I would suggest taking a look at WF-Sections v2.01 or WF-Channel v1.6 for how this has been done.




3
chapi
Re: Help with Spaw plz.
  • 2004/6/20 16:44

  • chapi

  • Theme Designer

  • Posts: 611

  • Since: 2002/1/22


This function checks, if the user has MSIE 5.5 or higher.

// checks browser compatibility with the control
  
function checkBrowser() {
    global 
$HTTP_SERVER_VARS;
    
$browser $HTTP_SERVER_VARS['HTTP_USER_AGENT'];
    
// check if msie
    
if (eregi("MSIE[^;]*",$browser,$msie)) {
      
// get version 
      
if (eregi("[0-9]+.[0-9]+",$msie[0],$version)) {
        
// check version
        
if ((float)$version[0]>=5.5) {
          
// finally check if it's not opera impersonating ie
          
if (!eregi("opera",$browser)) {
            return 
true;
          }
        }
      }
    }
    return 
false;
  }


Include this in your script and call it like the following:

if (checkBrowser()) {
// use spaw
} else {
// do anything else
}

4
astuni
Re: Help with Spaw plz.
  • 2004/6/21 8:20

  • astuni

  • Just popping in

  • Posts: 22

  • Since: 2004/6/7 4


Thank you chapi, it worked well, cool the feature that checks for IE Version and if its not opera acting like it...

@wfsection: maybe you could insert that function in wfsection 2.01 and Wfchannel 1.6 cos now it seems to check only if its MSIE and not its version, also, acting that way, every opera browser set to identify as IE will get the wysiwyg...not working...

This is wfchannel/admin/index.php code around line 133
if (!$xoopsModuleConfig['usespaw'] || !strstr($_SERVER["HTTP_USER_AGENT"], "MSIE"))
    {
        
$sform->addElement(new XoopsFormDhtmlTextArea(_AM_CHANA _AM_WORDCOUNT $total_words'page'$page1560), false);
    } 
    else
    {
        
ob_start();
        
$sw = new SPAW_Wysiwyg('page'$page'en''full''default''99%''600px');
        
$sw->show();
        
$sform->addElement(new XoopsFormLabel(_AM_CHANA _AM_WORDCOUNT $total_words ob_get_contents(), 1));
        
ob_end_clean();
    }


i would change it using that function like this starting from line 133:
// checks browser compatibility with the control
  
function checkBrowser() {
    global 
$HTTP_SERVER_VARS;
    
$browser $HTTP_SERVER_VARS['HTTP_USER_AGENT'];
    
// check if msie
    
if (eregi("MSIE[^;]*",$browser,$msie)) {
      
// get version 
      
if (eregi("[0-9]+.[0-9]+",$msie[0],$version)) {
        
// check version
        
if ((float)$version[0]>=5.5) {
          
// finally check if it's not opera impersonating ie
          
if (!eregi("opera",$browser)) {
            return 
true;
          }
        }
      }
    }
    return 
false;
  }

 if (!
$xoopsModuleConfig['usespaw'] || checkBrowser())
    {
        
ob_start();
        
$sw = new SPAW_Wysiwyg('page'$page'en''full''default''99%''600px');
        
$sw->show();
        
$sform->addElement(new XoopsFormLabel(_AM_CHANA _AM_WORDCOUNT $total_words ob_get_contents(), 1));
        
ob_end_clean();
    } 
    else
    {
        
$sform->addElement(new XoopsFormDhtmlTextArea(_AM_CHANA _AM_WORDCOUNT $total_words'page'$page1560), false);
        
    }

that was for wfchannel 1.6

Thanx to both for infos.
Cya
Astuni

5
astuni
Re: Help with Spaw plz.
  • 2004/6/21 8:23

  • astuni

  • Just popping in

  • Posts: 22

  • Since: 2004/6/7 4


Also i would like to have a better bug free version of wfsections 2.01 cos this one gives me a lot of troubles regarding blank pages on category creation and many others that have been already reported, i will wait for a real stable bug free version before switch.

Thank you anyway and keep up the good work, and sorry for double post
Cya
Astuni

Login

Who's Online

206 user(s) are online (123 user(s) are browsing Support Forums)


Members: 0


Guests: 206


more...

Donat-O-Meter

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

Latest GitHub Commits