Re: Can i get $webroot for a vendor library?

2006-06-29 Thread Logan

Really useful dima. Thanks. What i really want to do with Image is to
represent an image as an object. Like this:

?php
   vendor('image');
   $thumb = new Image('productos/thumbs/1.jpg');
   $big = new Image('productos/big/1.jpg');

if ($thumb-exists()) {
   echo 'a href=?php echo $big-getFullPath()?
onclick=window.open(this.href,'','width=?php echo
$big-width?,height=?php echo $big-height?')
   echo $thumb-toHtml(array('border' = 0));
   echo '/a';
}

?

Now as a component is no useful because i can only have one instance of
the object (i think).
I saw the File class perfect for this purpose. So i extend it.
This class is for cake only. No plans for using elsewhere.
If work ill cleanit up i little bit and uploaded. Maybe somebody likes.
Thanks for your help ;)
Also pardon my english


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Can i get $webroot for a vendor library?

2006-06-25 Thread RosSoft

A good way to have a component in a view:

class ImageComponent extends Object
{
 function startup($controller) {
  $this-controller = $controller;
  $this-controller-set('image', $this);
}
function hello() { return hi!; }
}

it will be available in views: echo $image-hello();


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Can i get $webroot for a vendor library?

2006-06-25 Thread Logan

Great Tip RosSoft, ginstrom. Thanks! One more thing. The Image library
extends File
but the components extends Object. I know i could use the File class by
agregation but i wanted to inherit the File methods in Image. Any tips
about that?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Can i get $webroot for a vendor library?

2006-06-25 Thread Logan

Sorry. I Just realize that FIle extends Object. So ill guess ill turn
Image class into a 
component. ;) Thank you All!!


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Can i get $webroot for a vendor library?

2006-06-24 Thread Logan

I found out a way by importing the $Dispatcher.

function _construct($src = null) {
global $Dispatcher;
$this-webroot = $Dispatcher-webroot;
}

Any other clean way for our public? ;)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Can i get $webroot for a vendor library?

2006-06-24 Thread gwoo

Any particular reason not to use Components?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Can i get $webroot for a vendor library?

2006-06-24 Thread Logan

Because i need to used in the view and/or the controller. Probably i'm
missing something. 
I'm kind of new to MVC.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Can i get $webroot for a vendor library?

2006-06-24 Thread ginstrom

Logan wrote:
 Because i need to used in the view and/or the controller. Probably i'm
 missing something.
 I'm kind of new to MVC.

If I'm not mistaken, you can access components from the view (just not
helpers from the controller).

If you are serving an image generated on the fly, you could also set a
null layout and simply have the component output the headers, create
the image, and read() it or whatever, then call exit.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---