Calling Model Functions from a Library

Posted by Abs on Stack Overflow See other posts from Stack Overflow or by Abs
Published on 2010-03-28T15:11:58Z Indexed on 2010/03/29 2:13 UTC
Read the original article Hit count: 424

Filed under:
|
|
|

Hello all,

I have turned a normal PHP class into a library so I can use it in Codeigniter as a library. I can load it and call the functions I need in that class. Here is that class to help with the question.

However, there are quite a few points where I have to call functions in my class. These functions reside in the model that instantiated my class. How can I do this as currently normal calls don't work. Here is my code:


class Controlpanel_model extends Model {

    var $category = '';
    var $dataa = 'a';

    function Controlpanel_model(){      

        parent::Model();

    }

    function import_browser_bookmarks(){

        $this->load->library('BookmarkParser');
        /*
        *In this function call to the class I pass 
        * what model functions exist that it should call
        * You can view how this done by clicking the link above and looking at line 383
        */
        $this->bookmarkparser->parseNetscape("./bookmarks.html", 0, 'myURL', 'myFolder'); 
        return $this->dataa;

    }

    function myURL($data, $depth, $no) { 

        $category = $this->category;
        $this->dataa .= 'Tag = '.$category.'<br />'.'URL = '.$data["url"].'<br />'.'Title = '.$data["descr"].'<br />'.'<br /><br />';
    } 

    function myFolder($data, $depth, $no) {

        $this->category = $data["name"];

    }   

}

Thanks all for any help.

© Stack Overflow or respective owner

Related posts about php

Related posts about classes