TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   Gallery problem (http://www.talkphp.com/advanced-php-programming/3590-gallery-problem.html)

Tanax 11-11-2008 03:33 PM

Gallery problem
 
Hi!

I've hit a problem:

php Code:
public function uploadImage($szInputName)
    {
       
        $this->form_inputName = $szInputName;
       
        // If the neccessary stuff has been set
        if(isset(parent::$path) && isset($this->user))
        {
            //I'm doing some stuff here..
           
        }
       
        else throw new Exception('Everything is not set yet.');
       
    }

php Code:
include('Gallery.php');
    include('Upload.php');
   
    $allowed = array(
   
        'jpeg',
        'gif',
        'png'
   
    );
   
    try
    {
       
        $gallery = new Gallery(NULL, 'images/');
        $gallery->setAllowedTypes($allowed);
        $gallery->setLimitFileType('no');
        $gallery->setThumbSize(400, 600);
        $gallery->setMaxFileSize(100000);
       
        $upload = new Upload(2);
        $upload->uploadImage('filename');
       
    }
   
    catch(Exception $error)
    {
       
        echo $error->getMessage();
       
    }

Gives me:
Code:

Everything is not set yet.
Which means that either path is not set, or the user id is not set.

And you can see that I've set both userid:
PHP Code:

$upload = new Upload(2); 

and the path:
PHP Code:

$gallery = new Gallery(NULL'images/'); 

So I'm thinking that perhaps this is wrong:
PHP Code:

parent::$path 

Is that an incorrect way of doing it?
Haven't worked much with parents and stuff..

The path variable in the gallery class(which the upload class extends) is set to protected.

Any ideas why this error is thrown?

Tanax 11-11-2008 04:08 PM

Actually, I already figured it out.

It's because $upload is a completely new object of the gallery.. hmm.. so everything I set with the $gallery is not kept to the $upload ..

So anyone have any idea how to solve this nicely? Cause I would really like to have a seperate class for the uploads and have the gallery as a core.

Should I make the "core" static?

Tanax 11-13-2008 07:09 PM

Hehe, nevermind. I solved this xD :-)


All times are GMT. The time now is 06:52 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0