11
hervet
Re: Editors in 2.4.0 beta
  • 2009/8/28 12:30

  • hervet

  • Friend of XOOPS

  • Posts: 2267

  • Since: 2003/11/4


Quote:

trabis wrote:
Fix for news module:
Edit news/include/functions.php and make this change:

Isn't there a better way to do it ?
I'm not going to make a new version of this code each time a new version of XOOPS is released.
It's time to make something definitive AND running ...

This point is becoming more than boring.
The way to use editors is changing every time, please stop this, fix one or two editors (a simple textaread AND an html area) and stop this slaughter.

Modifying code of running module to adapt to a BETA version is not the best idea too.



12
hervet
Re: Ajax calls directly from Jquery
  • 2009/8/22 11:35

  • hervet

  • Friend of XOOPS

  • Posts: 2267

  • Since: 2003/11/4


A good reading:
http://net.tutsplus.com/tutorials/javascript-ajax/5-ways-to-make-ajax-calls-with-jquery/



13
hervet
Re: Could 'preference' navigation be improved when configuring modules ?
  • 2009/8/21 8:58

  • hervet

  • Friend of XOOPS

  • Posts: 2267

  • Since: 2003/11/4


In my point of view, the MVC should be global to XOOPS and not only "reserved" to modules.
This will "solved" many things like URL rewriting...



14
hervet
Re: Ajax calls directly from Jquery
  • 2009/8/21 8:51

  • hervet

  • Friend of XOOPS

  • Posts: 2267

  • Since: 2003/11/4


I'm not in your code (nor in your head) butI can give you some advices of how I use to do.

Put your "general" code in a .js file, call it, then from your Php script, pass some parameters to it like this (you create some kind of "dynamic" javascript code):
<script type="text/javascrip">
var 
myvar 'hello';
</
script>


then in your Js file, you simply use the var "myvar".
Is this what you need ?

If you are in Ajax, you can also pass some parameters to your Php script with several different maners.

Create an hidden field, use it as a container, set it's content dinamycally and push its value to your Php script.



15
hervet
Re: Ajax calls directly from Jquery
  • 2009/8/20 17:55

  • hervet

  • Friend of XOOPS

  • Posts: 2267

  • Since: 2003/11/4


Quote:

frankblack wrote:
Why? XOOPS debug conflicting with jquery? Or other reason?

From your Php script, everything you display is part of the answer to the client (that's its return), so if you have activated the inline debug mode, it's part of the answer to the client.

That's why I found your debug mode using Firebug excellent



16
hervet
Re: Ajax calls directly from Jquery
  • 2009/8/20 16:05

  • hervet

  • Friend of XOOPS

  • Posts: 2267

  • Since: 2003/11/4


Quote:

kaotik wrote:
Hervet: I see your passing parameters through $.load() which is exactly the one I haven't tested

It depends of the cases

Quote:

I've just been reading about $.live() and it's very usefull for when you have new events through ajax and want to bind actions to them.

Yes I'm also using it, it is present in my code :
jQuery('img.btnremove').live("click", function() {

It's been a disapointment for me when I decided to use jQuery because with Prototype it's automatic, you don't have to bind your events.
But now it's a core function of the last jQuery version (and not aplugin anymore).

Quote:

I like your function "jQuery('img.btnremove')", very handy to provide an alert window "are you sure" then perform an action.

That's why it is used for

Quote:

What do you think of Jquery?

I've been using Prototype for 2 years but decided to leave it for jQuery, much more plugins, much more updates and more handy to use, but Prototype has some interesting functions for arrays in Javascript

Quote:

Are you incorporating more javascript into your modules thanks to it?

Yes sure !
I never understood why xajax was used when you see the ease of use of AJAX in jQuery or in Prototype.

Quote:

I always saw you as a PHP master, now I see you are expanding your realm

Nowadays you don't have the choice, you use Javascript or your die
I've been subjugated by the code of jQuery.
John Resig is surely one of the best developper in the world.


Quote:

@hervet: I would also like to see your index.php to see how you catch ajax

You will soon see it in the next version of Olédrion (september)

If you want a reference to a good reading :
http://www.jsmag.com/
and it is not expensive.
Concerning jQuery, if you have a bit of money, I recommend you those two books:
http://www.packtpub.com/learning-jquery-1.3/book
http://www.packtpub.com/user-interface-library-for-jquery/book


Here is the part in charge of the Ajax response in the Php script:
if(!isset($xoopsUser) || !is_object($xoopsUser)) {
            exit;
        }
        if(!
oledrion_utils::isAdmin()) {
            exit;
        }
        
error_reporting(0);
        @
$xoopsLogger->activated false;
        
$attribute_id = isset($_POST['attribute_id']) ? intval($_POST['attribute_id']) : 0;
        
$content $class '';
        
$attribute null;
        
$counter 0;
        
$options = array();
        
$delete _OLEDRION_DELETE;
        
$span 4;

        if(!isset(
$_SESSION['oledrion_attribute'])) {
            if(
$attribute_id == 0) {    // Création, rajouter une zone
                
$attribute $oledrion_handlers->h_oledrion_attributes->create(true);
            } else {
                
$attribute $oledrion_handlers->h_oledrion_attributes->get($attribute_id);
                if(!
is_object($attribute)) {
                    return 
null;
                }
            }
        } else {
            
$attribute unserialize($_SESSION['oledrion_attribute']);
        }

        if(isset(
$_POST['formcontent'])) {    // Traitement du contenu actuel
            
$data = array();
            
parse_str(utf8_decode(urldecode($_POST['formcontent'])), $data);
            
$optionsCount = isset($data['optionsCount']) ? intval($data['optionsCount']) : 0;
            for(
$i 0$i $optionsCount$i++) {
                
$name $value $price $stock '';
                
$name = isset($data['name'.$i]) ? $data['name'.$i] : '';
                
$value  = isset($data['value'.$i]) ? $data['value'.$i] : '';
                
$price  = isset($data['price'.$i]) ? $data['price'.$i] : '';
                
$stock  = isset($data['stock'.$i]) ? $data['stock'.$i] : '';
                
$attribute->setOptionValue($i$name$value$price$stock);
            }
            if(isset(
$data['default'])) {
                
$defaultIndex intval($data['default']);
                
$defaultValue = isset($data['value'.$defaultIndex]) ? $data['value'.$defaultIndex] : '';
                
$attribute->setVar('attribute_default_value'$defaultValue);
                unset(
$defaultValue);
            }
        }

        if(isset(
$_POST['subaction'])) {
            switch(
xoops_trim(strtolower($_POST['subaction']))) {
                case 
'delete':    // Suppression d'une option de l'attribut
                    
$option = isset($_POST['option']) ? intval($_POST['option']) : false;
                    if(
$option !== false) {
                        
$attribute->deleteOption($option);
                    }
                    break;

                case 
'add':    // Ajout d'une option vide (à la fin)
                    
$attribute->addEmptyOption();
                    break;

                case 
'up':    // Déplacement d'une option vers le haut
                    
$option = isset($_POST['option']) ? intval($_POST['option']) : false;
                    if(
$option !== false) {
                        
$attribute->moveOptionUp($option);
                    }
                    break;

                case 
'down':    // Déplacement d'une option vers le haut
                    
$option = isset($_POST['option']) ? intval($_POST['option']) : false;
                    if(
$option !== false) {
                        
$attribute->moveOptionDown($option);
                    }
                    break;
            }
        }
        
$_SESSION['oledrion_attribute'] = serialize($attribute);

        
$content .= "<table border='0'>n";
        
$content .= "<tr>n";
        
$content .= "<th align='center'>"._AM_OLEDRION_ATTRIBUTE_DEFAULT_VALUE."</th><th align='center'>"._AM_OLEDRION_ATTRIBUTE_TITLE."</th><th align='center'>"._AM_OLEDRION_ATTRIBUTE_VALUE."</th>";
        if(
oledrion_utils::getModuleOption('use_price')) {
            
$content .="<th align='center'>"._AM_OLEDRION_ATTRIBUTE_PRICE."</th>";
            
$span++;
        }
        if(
oledrion_utils::getModuleOption('attributes_stocks')) {
            
$content .="<th align='center'>"._AM_OLEDRION_ATTRIBUTE_STOCK."</th>";
            
$span++;
        }
        
$content .="<th align='center'>"._AM_OLEDRION_ACTION."</th>n";
        
$content .= "</tr>n";

        
$up _AM_OLEDRION_ATTRIBUTE_MOVE_UP;
        
$down _AM_OLEDRION_ATTRIBUTE_MOVE_DOWN;
        
$defaultValue xoops_trim($attribute->getVar('attribute_default_value''e'));

        
$options $attribute->getAttributeOptions('e');
        
$optionsCount count($options);

        if(
$optionsCount 0) {
            foreach(
$options as $option) {
                
$class = ($class == 'even') ? 'odd' 'even';
                
$content .="<tr class='".$class."'>n";
                
$checked '';
                if(
$option['value'] == $defaultValue) {
                    
$checked "checked = 'checked' ";
                }
                
$content .= "<td align='center'><input type='radio' name='default' id='default' value='$counter$checked/></td>n";
                
$content .= "<td align='center'><input type='text' name='name$counter' id='names$counter' size='15' maxlength='255' value='".$option['name']."' /></td>n";
                
$content .= "<td align='center'><input type='text' name='value$counter' id='value$counter' size='15' maxlength='255' value='".$option['value']."' /></td>n";
                if(
oledrion_utils::getModuleOption('use_price')) {
                    
$content .= "<td align='center'><input type='text' name='price$counter' id='price$counter' size='15' maxlength='10' value='".$option['price']."' /></td>n";
                }
                if(
oledrion_utils::getModuleOption('attributes_stocks')) {
                    
$content .= "<td align='center'><input type='text' name='stock$counter' id='stock$counter' size='15' maxlength='10' value='".$option['stock']."' /></td>n";
                }
                
// Les actions
                
$content .= "<td align='center'>";
                
// Suppression
                
$content .= "<img class='btnremove' alt='$delete' title='$delete' style='border: 0; cursor:pointer;' name='btnremove-$counter' id='btnremove-$counter' src='".OLEDRION_IMAGES_URL."smalldelete.png' />";
                if(
$counter 0) {    // Up
                    
$content .= "<img class='btnUp' alt='$up' title='$up' style='border: 0; cursor:pointer;' name='btnUp-$counter' id='btnUp-$counter' src='".OLEDRION_IMAGES_URL."smallup.png' />";
                } else {
                    
$content .= "<img src='".OLEDRION_IMAGES_URL."blankholder.png' />";
                }
                if(
$counter $optionsCount 1) {    // Down
                    
$content .= "<img class='btnDown' alt='$down' title='$down' style='border: 0; cursor:pointer;' name='btnDown-$counter' id='btnDown-$counter' src='".OLEDRION_IMAGES_URL."smalldown.png' />";
                } else {
                    
$content .= "<img src='".OLEDRION_IMAGES_URL."blankholder.png' />";
                }
                
$content .= "</td>n";
                
$content .= "</tr>n";
                
$counter++;
            }
        }
        
$class = ($class == 'even') ? 'odd' 'even';
        
$content .="<tr class='".$class."'>n";
        
$content .= "<td colspan='$span' align='center'><input type='button'' name='bntAdd'' id='bntAdd' value='"._AM_OLEDRION_ATTRIBUTE_ADD_OPTION."' /></td>n";
        
$content .= "</tr>n";

        
$content .= "</table>n";
        
$content .= "<input type='hidden' name='optionsCount' id='optionsCount' value='$counter' />n";
        echo 
utf8_encode($content);
        exit;

But without its context, it will not give you too much things ...

note, this part is important:
error_reporting(0);
 @
$xoopsLogger->activated false;



17
hervet
Re: Ajax calls directly from Jquery
  • 2009/8/20 12:56

  • hervet

  • Friend of XOOPS

  • Posts: 2267

  • Since: 2003/11/4


This is an example from the futur version of Olédrion:
jQuery().ready(function() {
    var 
attribute_id_Value jQuery('#attribute_id').val();
    
jQuery('#ajaxOptions').load('index.php', {op'attributes'action'ajaxoptions'attribute_idattribute_id_Value});

    
jQuery('img.btnremove').live("click", function() {
        if(
confirm(confirmDelete)) {
            var 
optionId jQuery(this).attr('id').replace('btnremove-','');
            var 
formContent jQuery("#frmattributes").serialize();
            
jQuery('#ajaxOptions').load('index.php', {op'attributes'action'ajaxoptions'subaction'delete'optionoptionIdattribute_idattribute_id_ValueformcontentformContent});
        }
    });

    
jQuery('img.btnUp').live("click", function() {
        var 
optionId jQuery(this).attr('id').replace('btnUp-','');
        var 
formContent jQuery("#frmattributes").serialize();
        
jQuery('#ajaxOptions').load('index.php', {op'attributes'action'ajaxoptions'subaction'up'optionoptionIdattribute_idattribute_id_ValueformcontentformContent});
    });

    
jQuery('#attribute_type').change(function() {
        
attributeParameters();
    });
    
attributeParameters();

    
jQuery('img.btnDown').live("click", function() {
        var 
optionId jQuery(this).attr('id').replace('btnDown-','');
        var 
formContent jQuery("#frmattributes").serialize();
        
jQuery('#ajaxOptions').load('index.php', {op'attributes'action'ajaxoptions'subaction'down'optionoptionIdattribute_idattribute_id_ValueformcontentformContent});
    });

    
jQuery('#bntAdd').live("click", function() {
        var 
formContent jQuery("#frmattributes").serialize();
        
jQuery('#ajaxOptions').load('index.php', {op'attributes'action'ajaxoptions'subaction'add'attribute_idattribute_id_ValueformcontentformContent});
 });
});



18
hervet
Re: Ajax calls directly from Jquery
  • 2009/8/20 9:54

  • hervet

  • Friend of XOOPS

  • Posts: 2267

  • Since: 2003/11/4


Also, sometimes, don't forget that data need to be returned encoded in utf8 (from Php of course)



19
hervet
Re: Could 'preference' navigation be improved when configuring modules ?
  • 2009/8/20 9:44

  • hervet

  • Friend of XOOPS

  • Posts: 2267

  • Since: 2003/11/4


Quote:

trabis wrote:

First we need to:
- Finish this 2.4 bug hunter
- Move our focus to 2.5 (go php5 movement), build a XOOPS module framework 'XMF'. XMF will be a module itself and it will provide alternative libraries. XMF will be an interface between modules and core.
Build comments, notification, imagemanager modules using XMF.
Implement a hooking system(observer pattern) so modules using XMF can extend other modules using XMF with plugins (listen and respond to events such as: onUserDelete, onModuleInstall, onSearch, etc).
- 2.5.5 : Make new system module with XMF (the hooking system will be heavily used here)
- 2.5.9: Have every possible module using XMF
- 2.6 : Move XMF to core
- 2.7 : Feature request go here :)

I agree except on one point, either you make your 'XMF' a module either you make it part of the core but not first a module then a core "feature".
This will only drive to problems.

You must measure the PROS and CONS.
CONS:
If it's a module, we will have problems because you will need the correct version for your module

PROS:
If it's a module, you are not dependant of the core's version...

What else PROS and CONS ?




20
hervet
Re: Does everyone have to make a buck on twitter blocks
  • 2009/8/20 8:59

  • hervet

  • Friend of XOOPS

  • Posts: 2267

  • Since: 2003/11/4


May be the easiest :
http://twitter.com/goodies/widget_profile




TopTop
« 1 (2) 3 4 5 ... 139 »



Login

Who's Online

328 user(s) are online (194 user(s) are browsing Support Forums)


Members: 0


Guests: 328


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