4591
ghia
Re: Formulaire Select Box problem
  • 2008/7/12 10:19

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


I found out that the things for this particular form element of Formulaire get wrong encoded in the database:
ele_value in table prefix_form is:
a:3:{i:0;s:1:"1";i:1;s:1:"1";i:2;s:5:"Array";}

and should be (selection of three options)
a:3:{i:0;i:1;i:1;i:0;i:2;a:3:{s:8:"Option 1";i:1;s:8:"Option 2";i:0;s:8:"Option 3";i:0;}}

Got it from the SQL for the example form with fresh install.
This renders OK in the form (user to fill in), edit form (admin) and edit element (admin).
So the problem lies probably in the gathering of the data from the form and storing these in the database.

This is the html for the form.

<form name='form_ele' id='form_ele' action='elements.php?id=15' method='POST'  onsubmit="return xoopsFormValidate_form_ele();">
<
input type='hidden' name='skipValidationJS' id='skipValidationJS' value='0' />
<
input type='hidden' name='op' id='op' value='save' />
<
input type='hidden' name='ele_type' id='ele_type' value='select' />
<
input type='hidden' name='ele_id' id='ele_id' value='144' />
<
table width='100%' class='outer' cellspacing='1'><tr><th colspan='2'>Edit form elementddd</th></tr><tr valign='top' align='left'><td class='head'>Caption's name *</td><td class='even'><input type='text' name='ele_caption' id='ele_caption' size='50' maxlength='255' value='ddd' /></td></tr><tr valign='top' align='left'><td class='head'>Size *</td><td class='even'><input type='text' name='ele_value[0]' id='ele_value[0]' size='3' maxlength='2' value='1' /></td></tr><tr valign='top' align='left'><td class='head'>Allow multiple selections</td><td class='even'><input type='radio' id='ele_value[1]0' name='ele_value[1]' value='1' />Ja

<input type='
radio' id='ele_value[1]1' name='ele_value[1]' value='0' checked='checked' />Nee
</td></tr><tr valign='
top' align='left'><td class='head'>Options<br /><br /><span style="font-weight: normal;">Tick the check boxes for selecting default values<br />Only the first checked is used if multiple selection is not allowed</span></td><td class='even'><input type='checkbox' id='checked[0]0' name='checked[0]' value='1' checked='checked' /> 

&nbsp;<input type='
text' name='ele_value[2][0]' id='ele_value[2][0]' size='40' maxlength='255' value='Option 1' />

<br /><input type='
checkbox' id='checked[1]0' name='checked[1]' value='1' /> 

&nbsp;<input type='
text' name='ele_value[2][1]' id='ele_value[2][1]' size='40' maxlength='255' value='Option 2' />

<br /><input type='
checkbox' id='checked[2]0' name='checked[2]' value='1' /> 

&nbsp;<input type='
text' name='ele_value[2][2]' id='ele_value[2][2]' size='40' maxlength='255' value='Option 3' />

<br />Add <input type='
text' name='addopt' id='addopt' size='3' maxlength='2' value='' /> options
&nbsp;<input type='
submit' class='formButton' name='submit'  id='submit' value='Add' />

</td></tr><tr valign='
top' align='left'><td class='head'>Required</td><td class='even'><input type='checkbox' id='ele_req0' name='ele_req' value='1' /> 
</td></tr><tr valign='
top' align='left'><td class='head'>Display</td><td class='even'><input type='checkbox' id='ele_display0' name='ele_display' value='1' checked='checked' /> 
</td></tr><tr valign='
top' align='left'><td class='head'>Order</td><td class='even'><input type='text' name='ele_order' id='ele_order' size='3' maxlength='2' value='0' /></td></tr><tr valign='top' align='left'><td class='head'></td><td class='even'><input type='submit' class='formButton' name='submit'  id='submit' value='Save' />
&nbsp;<input type='
button' class='formButton' name='cancel'  id='cancel' value='Niet doen'onclick="javascript:history.go(-1);" />
</td></tr><tr class='
foot'><td colspan='2'>* = Vereist</td></tr></table>
</form>


I found this remarks on naming and giving an id to the fields. I do not know if this is relevant or not.

The code for processing this form is in formulaire/admin/elements.php .

<?php

include_once("admin_header.php");

if ( 
file_exists("../language/".$xoopsConfig['language']."/modinfo.php") ) {
    include 
"../language/".$xoopsConfig['language']."/modinfo.php";

else {
    include 
"../language/english/modinfo.php";
}

if(!isset(
$_POST['id'])){
    
$id = isset ($_GET['id']) ? $_GET['id'] : '';
}else {
    
$id $_POST['id'];
}
if(!isset(
$_POST['ele_id'])){
    
$ele_id = isset ($_GET['ele_id']) ? $_GET['ele_id'] : '';
}else {
    
$ele_id $_POST['ele_id'];
}
if(!isset(
$_POST['ele_type'])){
    
$ele_type = isset ($_GET['ele_type']) ? $_GET['ele_type'] : '';
}else {
    
$ele_type $_POST['ele_type'];
}

if(!isset(
$clone)){ $clone="";}
if(!isset(
$req)){ $req="";}
if(!isset(
$text)){ $text="";}
if(!isset(
$_POST['submit'])){ $_POST['submit']="";}

$sql=sprintf("SELECT desc_form FROM ".$xoopsDB->prefix("form_id")." WHERE id_form='%s'",$id);
$res $xoopsDB->query($sql) or die('Erreur SQL !<br />'.$requete.'<br />'.$xoopsDB->error());

if (
$res) {
  while ( 
$row $xoopsDB->fetchRow($res)) {
    
$title $row[0];
  }
}

if( !empty(
$_POST) ){
    foreach( 
$_POST as $k => $v ){
        ${
$k} = $v;
    }
}elseif( !empty(
$_GET) ){
    foreach( 
$_GET as $k => $v ){
        ${
$k} = $v;
    }
}

$ele_id = !empty($ele_id) ? intval($ele_id) : 0;
$myts =& MyTextSanitizer::getInstance();

if (isset(
$_POST))
{
    foreach (
$_POST as $k => $v)
    {
        $
$k $v;
    } 


if (isset(
$_GET))
{
    foreach (
$_GET as $k => $v)
    {
        $
$k $v;
    } 
}

if( 
$_POST['submit'] == _AM_ELE_ADD_OPT_SUBMIT && intval($_POST['addopt']) > ){
    
$op 'edit';
}

    if (
$ele_type == "text")
    {    
$name _AM_ELE_TEXT;
    } elseif  (
$ele_type == "textarea")
    {    
$name _AM_ELE_TAREA;
    } elseif  (
$ele_type == "areamodif")
    {    
$name _AM_ELE_MODIF;
    } elseif  (
$ele_type == "select")
    {    
$name _AM_ELE_SELECT;
    } elseif  (
$ele_type == "checkbox")
    {    
$name _AM_ELE_CHECK;
    } elseif  (
$ele_type == "radio")
    {    
$name _AM_ELE_RADIO;
    } elseif  (
$ele_type == "yn")
    {    
$name _AM_ELE_YN;
    } elseif  (
$ele_type == "date")
    {    
$name _AM_ELE_DATE;
    } elseif  (
$ele_type == "sep")
    {    
$name _AM_ELE_SEP;
    } elseif  (
$ele_type == "upload")
    {    
$name _AM_ELE_UPLOAD;
    } elseif  (
$ele_type == "mail")
    {    
$name _AM_ELE_MAIL;
    } elseif  (
$ele_type == "mailunique")
    {    
$name _AM_ELE_MAIL;
    }

switch(
$op){
    case 
'edit':
// snipped
    
break;
    case 
'delete':
// snipped
    
break;
    case 
'save':
        if( !empty(
$ele_id) ){
            
$element =& $formulaire_mgr->get($ele_id);
        }else{
            
$element =& $formulaire_mgr->create();
        }
        
$element->setVar('ele_caption'$ele_caption);
        
$req = !empty($ele_req) ? 0;
        
$element->setVar('ele_req'$req);
        
$order = empty($ele_order) ? intval($ele_order);
        
$element->setVar('ele_order'$order);
        
$display = !empty($ele_display) ? 0;
        
$element->setVar('ele_display'$display);
        
$element->setVar('ele_type'$ele_type);

if (isset(
$_POST))
{
    foreach (
$_POST as $k => $v)
    {
        $
$k $v;
    } 


if (isset(
$_GET))
{
    foreach (
$_GET as $k => $v)
    {
        $
$k $v;
    } 
}

        switch(
$ele_type){
            case 
'text':
                
$value = array();
                
$value[] = !empty($ele_value[0]) ? intval($ele_value[0]) : $xoopsModuleConfig['t_width'];
                
$value[] = !empty($ele_value[1]) ? intval($ele_value[1]) : $xoopsModuleConfig['t_max'];
                
$value[] = $ele_value[2];
            break;
            case 
'textarea':
// snipped
            
break;
            case 
'areamodif':
// snipped
            
break;
            case 
'checkbox':
                
$value = array();
                while( 
$v each($ele_value) ){
                    if( !empty(
$v['value']) ){
                        if( 
$checked[$v['key']] == ){
                            
$check 1;
                        }else{
                            
$check 0;
                        }
                        
$value[$v['value']] = $check;
                    }
                }
            break;
            case 
'mail':
// snipped
            
break;
            case 
'mailunique':
// snipped
            
break;
            case 
'radio':
// snipped
            
break;
            case 
'yn':
// snipped
            
break;
            case 
'date':
                
$value = array();
                
$value[] = $ele_value;
            break;
            case 
'sep':
// snipped
            
break;
            case 
'select':
                
$value = array();
                
$value[0] = $ele_value[0]>intval($ele_value[0]) : 1;
                
$value[1] = !empty($ele_value[1]) ? 0;
                
$v2 = array();
                
$multi_flag 1;
                while( 
$v each($ele_value[2]) ){
                    if( !empty(
$v['value']) ){
                        if( 
$value[1] == || $multi_flag ){
                            if( 
$checked[$v['key']] == ){
                                
$check 1;
                                
$multi_flag 0;
                            }else{
                                
$check 0;
                            }
                        }else{
                            
$check 0;
                        }
                        
$v2[$v['value']] = $check;
                    }
                }
                
$value[2] = $v2;
            break;
            case 
'upload':
// snipped
            
break;
        }
        
$element->setVar('ele_value'$value);
        
$element->setVar('id_form'$id);
        if( !
$formulaire_mgr->insert($element) ){
            
xoops_cp_header();
            echo 
$element->getHtmlErrors();
        }else{
        
$url "index.php?id=$id";
        
Header("Location: $url");
        }
    break;

}
include 
'footer.php';
xoops_cp_footer();


function 
addOption($id1$id2$text$type='check'$checked=null){
// snipped
}

function 
addOptionsTray(){
// snipped
}
?>


I believe maybe the code is addressed to PHP4 and as I found out some constructs with arrays seems no longer to work in PHP5.
I am working with PHP 5.2.4 .
Is this code suffering from that problem? If yes, how should it be fixed, so it stays compatible with PHP4 and PHP5?

I have a programming background, but I am not deep enough in PHP to understand these finesses. (However the possibility remains that the cause of the problem is in a totaly different corner.)

Regards, Gerard.



4592
ghia
Re: Trying to add avatars to viewforum.php
  • 2008/7/12 9:21

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Do you mean on a page like this or this? (Specify URL if not).
That is standard not provided.
If you want it to show, you must probably add it to the template and in php looking it up an adding it to the template var. Example in viewtopic.



4593
ghia
Re: Formulaire Select Box problem
  • 2008/7/11 8:26

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Strange, I retested here and I observe the same problem.
I had used it once, but decided than that is was easier for users to select (with 2 - 4 selections) from radiobuttons.
I will try to look into it.



4594
ghia
Re: Changing the Banner
  • 2008/7/11 0:15

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Easy is when you maintain the colour scheme and sizes of the graphics. Use a graphical editor like the Gimp to adapt the graphic files (jpg). Leave the colours at the borders the same and change only the center part. If you change colours, do this alike for all graphics. If you change dimensions, do alike for all graphics. (It's kind of Jigsaw puzzle.) But in the latter case, you will probably need to change the css file of your theme as well to have corresponding dimensions.
Upload the changed graphics to your site.

(Start always by checking to have original copies, for disaster recovery!)



4595
ghia
Re: TinyMCE debug error
  • 2008/7/10 23:53

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


You probably have a problem with your settings for the CSS-file. You are using the TinyEditor module?

For TinyMCE you need to place xoops_editor.css in every modules/xxxxx map of the modules where the tinymce editor is to be used.



4596
ghia
Re: Formulaire Select Box problem
  • 2008/7/10 23:13

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Here it works XOOPS V2.2.6 and Formulaire 3.33 (I recommend upgrading your software to this level) with patches from here and here (French).

Is this disappearing in Admin (setup of a form) or in user mode (fill in)? Can you tell more about the functions used and actions taken, which leads to the faulty result?



4597
ghia
Re: Attempted upgrade FUBAR'd site. Anyway to recover data?
  • 2008/7/9 23:28

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Quote:
I have a copy of the MySQL database after the failed upgrade.
You shoud have a backup of BEFORE the upgrade!

If your site provides phpMyAdmin, you can do it with the export (out of the old DB) and import to the new fresh database. Verify the differences of the fields in the required tables between original and target and adapt the SQL-scripts. You find also inspiration in the update.php and readme files from the final and intermediate versions.
BTW what was the original version?



4598
ghia
Re: Newbbex + SecurityImage. Can you Help me ?
  • 2008/7/6 14:23

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Here are instructions for Newbb. I think you can adapt them easily (Redirection links!).
See also the general installation instructions.



4599
ghia
Re: Banner management
  • 2008/7/3 21:48

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


You can use my snippet to add the banner.
Copy and insert the five lines after the line with "Display center blocks if any".
Maybe it's an older version.



4600
ghia
Re: Banner management
  • 2008/7/3 20:06

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Quote:
I'm also using geometric_red, as opposed to the default theme.

The <{$xoops_banner}> tag does not appear to be in the theme.html file of geometric_red.

That's odd.
Here it's included:
<!-- End left blocks loop -->
          <
br /> <br />          </td>
        <
td id="centercolumn"
          <!-- 
Display center blocks if any -->
          <
table width="100%"  cellspacing="0" cellpadding="0">
            <
tr>
              <
td class="banner"><{$xoops_banner}></td>
            </
tr>
          </
table>
          <{if 
$xoops_showcblock == 1}> <table class="cbl" cellspacing="0">
            <
tr
              <
td id="centerCcolumn" colspan="2"
                <!-- 
Start center-center blocks loop -->

and functioning.




TopTop
« 1 ... 457 458 459 (460) 461 »



Login

Who's Online

303 user(s) are online (180 user(s) are browsing Support Forums)


Members: 0


Guests: 303


more...

Donat-O-Meter

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

Latest GitHub Commits