rezakho / ganon

Automatically exported from code.google.com/p/ganon
0 stars 0 forks source link

getChildrenByTag, getChildrenByID, getChildrenByClass, etc doesnt work #21

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi

These functions in ganon.php:

    function getChildrenByID($id, $recursive = true) {
        return getChildrenByAttribute('id', $id, 'equals', 'total', $recursive);
    }
    function getChildrenByClass($class, $recursive = true) {
        return getChildrenByAttribute('class', $id, 'equals', 'total', $recursive);
    }
    function getChildrenByName($name, $recursive = true) {
        return getChildrenByAttribute('name', $name, 'equals', 'total', $recursive);
    }

returns an error, because the call ( getChildrenByAttribute ) is not in the 
scope
of the class.

You must make the call as:

    function getChildrenByID($id, $recursive = true) {
        return $this->getChildrenByAttribute('id', $id, 'equals', 'total', $recursive);
    }
    function getChildrenByClass($class, $recursive = true) {
        return $this->getChildrenByAttribute('class', $id, 'equals', 'total', $recursive);
    }
    function getChildrenByName($name, $recursive = true) {
        return $this->getChildrenByAttribute('name', $name, 'equals', 'total', $recursive);
    }   

in order to work...

or... you can put off that function_create invention and do a normal select 
instead:

    function getChildrenByAttribute($attribute, $value, $mode = 'equals', $compare = 'total', $recursive = true) {
        return $this->select( sprintf('[%s="%s"]',$attribute,$value) );
    }
    function getChildrenByTag($tag, $compare = 'total', $recursive = true) {
    return $this->select( $tag );
    }
    function getChildrenByID($id, $recursive = true) {
        return $this->select( sprintf('[id="%s"]',$class) );
    }
    function getChildrenByClass($class, $recursive = true) {
    return $this->select( sprintf('[class="%s"]',$class) );
    }
    function getChildrenByName($name, $recursive = true) {
        return $this->select( sprintf('[name="%s"]',$class) );
    }

Original issue reported on code.google.com by Radika...@gmail.com on 20 Sep 2012 at 11:37

GoogleCodeExporter commented 8 years ago
Sorry it took so long, but thanks for reporting!

Original comment by niels....@gmail.com on 19 Oct 2012 at 5:28