Re: How to modify a field in afterFind()

2008-12-17 Thread Matt Huggins

Your solution worked flawlessly!  I ended up making two small
changes.  First, I changed your references for 'id' to $this-
>primaryKey so that it can work with any model.  Second, I put the
afterFind/_afterFind into app_model.php so that it will call the
doAfterFind of any model that implements it, as per the following:

class AppModel extends Model {
/**
 * sigh... $primary doesn't work as designed in CakePHP RC2 :(
 * this hack will manually go through and tear shit up
 */
public function afterFind($results, $primary = false) {
if (method_exists($this, 'doAfterFind')) {
if ($primary) {
foreach ($results as $key => $val) {
if (isset($val[$this->alias])) {
$results[$key][$this->alias] = 
$this->doAfterFind
($results[$key][$this->alias]);
}
}
} else {
if (isset($results[$this->primaryKey])) {
$results = $this->doAfterFind($results);
} else {
foreach ($results as $key => $val) {
if (isset($val[$this->alias])) {
if 
(isset($val[$this->alias][$this->primaryKey]))
{

$results[$key][$this->alias] = $this->doAfterFind
($results[$key][$this->alias]);
} else {
foreach 
($results[$key][$this->alias] as $key2
=> $val2) {

$results[$key][$this->alias][$key2] = $this-
>doAfterFind($results[$key][$this->alias][$key2]);
}
}
}
}
}
}
}
return $results;
}
}

On Dec 17, 5:36 am, "martin.westin...@gmail.com"
 wrote:
> Hi Matt,
> I ended up creating a special set of functions for this.
>
> afterFind() calls _afterFind()
> _afterFind() locates the data and calls doAfterFind()
>
> This works for what I use afterFind for.
> I will only have one place to edit if the data-structires change or I
> find I have missed something.
> It makes my models a lot more readable.
>
> The relevant code if you should find it useful:
>
> in SomeModel:
>
> // this just calls the "real" afterFind
> function afterFind($data, $primary) {
>     return $this->_afterFind($data, $primary);
>
> }
>
> // receives data as a flat array of fields, no Modelname or anything.
> // run from _afterFind splits datetime-field sendat into senddate and
> sendtime
> function doAfterFind($data) {
>
>     if ( !isset($data['senddate']) ) {
>         $timestamp = strtotime($data['sendat']);
>         $data['senddate'] = date('Y-m-d', $timestamp);
>         $data['sendtime'] = date('H', $timestamp);
>     }
>
>     return $data;
>
> }
>
> // AppModel::_afterFind()
> function _afterFind($data, $primary) {
>
>     if ( $primary ) {
>
>         foreach ( $data as $key => $val ) {
>             if ( isset($val[$this->alias]) ) {
>                 $data[$key][$this->alias] = $this->doAfterFind( $data
> [$key][$this->alias] );
>             }
>         }
>
>     } else {
>
>         if ( isset($data['id']) ) {
>             $data = $this->doAfterFind( $data );
>         } else {
>
>             foreach ( $data as $key => $val ) {
>                 if ( isset($val[$this->alias]) ) {
>                     if ( isset($val[$this->alias]['id']) ) {
>                         $data[$key][$this->alias] = $this->doAfterFind
> ( $data[$key][$this->alias] );
>                     } else {
>                         foreach ( $data[$key][$this->alias] as $key2
> => $val2 ) {
>                             $data[$key][$this->alias][$key2] = 
> $this->doAfterFind( $data[$key][$this->alias][$key2] );
>
>                         }
>                     }
>                 }
>             }
>         }
>
>     }
>     return $data;
>
> }
>
> On Dec 17,

Re: How to modify a field in afterFind()

2008-12-17 Thread Matt Huggins

Thanks for sharing, I'll definitely try this out!  I really hope they
fix this before 1.2 is considered a final release.  The documentation
is completely wrong otherwise.

On Dec 17, 5:36 am, "martin.westin...@gmail.com"
 wrote:
> Hi Matt,
> I ended up creating a special set of functions for this.
>
> afterFind() calls _afterFind()
> _afterFind() locates the data and calls doAfterFind()
>
> This works for what I use afterFind for.
> I will only have one place to edit if the data-structires change or I
> find I have missed something.
> It makes my models a lot more readable.
>
> The relevant code if you should find it useful:
>
> in SomeModel:
>
> // this just calls the "real" afterFind
> function afterFind($data, $primary) {
>     return $this->_afterFind($data, $primary);
>
> }
>
> // receives data as a flat array of fields, no Modelname or anything.
> // run from _afterFind splits datetime-field sendat into senddate and
> sendtime
> function doAfterFind($data) {
>
>     if ( !isset($data['senddate']) ) {
>         $timestamp = strtotime($data['sendat']);
>         $data['senddate'] = date('Y-m-d', $timestamp);
>         $data['sendtime'] = date('H', $timestamp);
>     }
>
>     return $data;
>
> }
>
> // AppModel::_afterFind()
> function _afterFind($data, $primary) {
>
>     if ( $primary ) {
>
>         foreach ( $data as $key => $val ) {
>             if ( isset($val[$this->alias]) ) {
>                 $data[$key][$this->alias] = $this->doAfterFind( $data
> [$key][$this->alias] );
>             }
>         }
>
>     } else {
>
>         if ( isset($data['id']) ) {
>             $data = $this->doAfterFind( $data );
>         } else {
>
>             foreach ( $data as $key => $val ) {
>                 if ( isset($val[$this->alias]) ) {
>                     if ( isset($val[$this->alias]['id']) ) {
>                         $data[$key][$this->alias] = $this->doAfterFind
> ( $data[$key][$this->alias] );
>                     } else {
>                         foreach ( $data[$key][$this->alias] as $key2
> => $val2 ) {
>                             $data[$key][$this->alias][$key2] = 
> $this->doAfterFind( $data[$key][$this->alias][$key2] );
>
>                         }
>                     }
>                 }
>             }
>         }
>
>     }
>     return $data;
>
> }
>
> On Dec 17, 12:55 am, Matt Huggins  wrote:
>
> > I'm having the same issue, and I have yet to find a solution.  The
> > Cake documentation is wrong and/or the implementation is incorrect.
>
> > On Oct 23, 1:58 am, "martin.westin...@gmail.com"
>
> >  wrote:
> > > I compiled a list of the variations I have encountered in different
> > > associations. I have not checked how behaviors are called.
>
> > > When primary is set this is the structure I get just as in the
> > > Cookbook:
> > > array(
> > >     '0' => array(
> > >         'Model' => array(
> > >             'id' => 1
> > >         )
> > >     )
> > > )
>
> > > When primary is not set I get a subset of these for each association:
>
> > > hasOne
> > > array(
> > >     'id' => 1
> > > )
>
> > > habtm
> > > array(
> > >     '0' => array(
> > >         'id' => 1
> > >     )
> > > )
>
> > > hasOne, hasMany, belongsTo
> > > array(
> > >     '0' => array(
> > >         'Model' => array(
> > >             'id' => 1
> > >         )
> > >     )
> > > )
>
> > > habtm, hasMany
> > > array(
> > >     '0' => array(
> > >         'Model' => array(
> > >             '0' => array(
> > >                 'id' => 1
> > >             )
> > >         )
> > >     )
> > > )
>
> > > This makes the number of ifs and fors quite many in order the catch
> > > them all. And since more than one is sometimes called for the same
> > > record in the same request, you also have to check is you have already
> > > manipulated your data. At least if you do something "destructive" to
> > > it like encryption/decryption or serialization.
>
> > > My orignal question still stands

Re: How to modify a field in afterFind()

2008-12-16 Thread Matt Huggins

I'm having the same issue, and I have yet to find a solution.  The
Cake documentation is wrong and/or the implementation is incorrect.

On Oct 23, 1:58 am, "martin.westin...@gmail.com"
 wrote:
> I compiled a list of the variations I have encountered in different
> associations. I have not checked how behaviors are called.
>
> When primary is set this is the structure I get just as in the
> Cookbook:
> array(
>     '0' => array(
>         'Model' => array(
>             'id' => 1
>         )
>     )
> )
>
> When primary is not set I get a subset of these for each association:
>
> hasOne
> array(
>     'id' => 1
> )
>
> habtm
> array(
>     '0' => array(
>         'id' => 1
>     )
> )
>
> hasOne, hasMany, belongsTo
> array(
>     '0' => array(
>         'Model' => array(
>             'id' => 1
>         )
>     )
> )
>
> habtm, hasMany
> array(
>     '0' => array(
>         'Model' => array(
>             '0' => array(
>                 'id' => 1
>             )
>         )
>     )
> )
>
> This makes the number of ifs and fors quite many in order the catch
> them all. And since more than one is sometimes called for the same
> record in the same request, you also have to check is you have already
> manipulated your data. At least if you do something "destructive" to
> it like encryption/decryption or serialization.
>
> My orignal question still stands. What is the best way to write an
> afterFind in order to: 1. not miss converting data in some queries 2.
> not double-convert the data ?
>
> regards,
> /Martin
>
> On Oct 22, 5:16 pm, "martin.westin...@gmail.com"
>
>  wrote:
> > Hi,
> > I thought I'd ask this here. (see why below)
> > How do I write afterFind() to modify a field.
>
> > For example just something simple like this (just an example):
>
> > function afterFind($data) {
> >     foreach ($data as $key => $val) {
> >         if ( isset($val[$this->alias]['name']) ) {
> >             $data[$key][$this->alias]['name2'] = $val[$this->alias]
> > ['name'];
> >         }
> >     }
> >     debug($data);
> >     return $data;
>
> > }
>
> > What I want to know is how to pick out the field from the passed data
> > array. There are so many different ways the data is formatted that I
> > end up with a quite messy series of for's and if's and I still don't
> > fell 100% sure I got them all. I feel there must be some sure-fire way
> > to write these.
>
> > The Cookbook is not complete compared to what I 
> > get.http://book.cakephp.org/view/681/afterFind
>
> > The API does not mention much about this.
>
> > I did not find any test in the core that helped me.
>
> > I did not find anything on Google that dealt with anything but basic
> > "primary" data.
>
> > I noticed that sometimes afterFind() is called more than once with
> > different data-structure each time. I asked about that 
> > here:http://groups.google.com/group/cake-php/browse_thread/thread/c83e5f40...
>
> > I'd love some clarification of this callback. Thans in advance.
> > /Martin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Access a controller inside another controller?

2008-07-02 Thread Matt Huggins

Check out admin routing.  Here are a few links to help get you
started.

Read about the "Routing.admin" configuration variable here:
http://manual.cakephp.org/view/44/cakephp-core-configuration-var

Read about the section on "prefix routing" here:
http://manual.cakephp.org/view/46/routes-configuration

Read a semi-dated but still pretty useful tutorial on admin routing
here:
http://www.jamesfairhurst.co.uk/posts/view/creating_an_admin_section_with_cakephp

On Jul 2, 7:21 pm, Rodrigo <[EMAIL PROTECTED]> wrote:
> Hi
> I'm new to cakephp and I've some newbie questions.
> I'm creating a cms for my own website.
>
> I have the admin controller located at site.com/admin, there I have
> many functions like add users, upload images, etc.
> I was using the admin_controller for each of that function but I think
> it will be better if I use a controller for each function. It's ok so
> far but, I want to access these functions in, for example, site.com/
> admin/upload or site.com/admin/edit/userName.
> However I can only access those functions by going to site.com/upload
> or site.com/edit/userName, I can't access through /admin/ because it's
> not part of admin_controller. My question is, is it possible to access
> these controllers by /admin/ ? How?
>
> Thanks,
> Rodrigo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



Re: CakePHP memory usage: what is going on here???

2008-07-01 Thread Matt Huggins

It doesn't look like it.  I referenced HtmlHelper and FormHelper in
both my app_controller and its inheriting controller.  Once I removed
these references, nothing seemed to change with regards to the 9MB
leap from __construct to beforeFilter.  I'll go through and see if
something similar is happening with my $uses and $components arrays
though, just in case.

On Jul 1, 6:45 pm, floob <[EMAIL PROTECTED]> wrote:
> By any chance, does your AppController reference a Helper that doesn't
> exist?  (https://trac.cakephp.org/ticket/5010)  That would explain it.
>
> On Tue, Jul 1, 2008 at 4:37 PM, Matt Huggins <[EMAIL PROTECTED]> wrote:
>
> > I started getting "Fatal error: Allowed memory size of..." errors
> > while developing my CakePHP app.  In order to find out what's going on
> > and where all the memory is going, I started placing some
> > memory_get_usage() calls in my code.  It seems like somewhere between
> > my controller's construct method and beforeFilter() callback, almost
> > 9MB of memory are being used by CakePHP.  Here's the code I'm using to
> > test:
>
> > function __construct() {
> >echo 'Memory Usage (construct): ' .
> > number_format(memory_get_usage(), 0, '.', ',') . " bytes\n";
> >parent::__construct();
> >echo 'Memory Usage (construct): ' .
> > number_format(memory_get_usage(), 0, '.', ',') . " bytes\n";
> > }
>
> > function beforeFilter() {
> >echo 'Memory Usage (beforeFilter): ' .
> > number_format(memory_get_usage(), 0, '.', ',') . " bytes\n";
> >// other code here
> > }
>
> > And here's the resultant output prior to the error popping up mid-
> > processing:
>
> > Memory Usage (construct): 5,567,008 bytes
> > Memory Usage (construct): 5,594,008 bytes
> > Memory Usage (beforeFilter): 14,153,232 bytes
>
> > What I'm wondering is why does CakePHP need so much space in memory?
> > Could I possibly be doing something wrong such that this is
> > happening?  I don't suspect my app_controller.php containing any
> > issues considering the minute change between the two
> > memory_get_usage() calls within __construct().
>
> > Any input is greatly appreciated, as this has quickly ground my
> > development efforts to a halt.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



CakePHP memory usage: what is going on here???

2008-07-01 Thread Matt Huggins

I started getting "Fatal error: Allowed memory size of..." errors
while developing my CakePHP app.  In order to find out what's going on
and where all the memory is going, I started placing some
memory_get_usage() calls in my code.  It seems like somewhere between
my controller's construct method and beforeFilter() callback, almost
9MB of memory are being used by CakePHP.  Here's the code I'm using to
test:

function __construct() {
echo 'Memory Usage (construct): ' .
number_format(memory_get_usage(), 0, '.', ',') . " bytes\n";
parent::__construct();
echo 'Memory Usage (construct): ' .
number_format(memory_get_usage(), 0, '.', ',') . " bytes\n";
}

function beforeFilter() {
echo 'Memory Usage (beforeFilter): ' .
number_format(memory_get_usage(), 0, '.', ',') . " bytes\n";
// other code here
}

And here's the resultant output prior to the error popping up mid-
processing:

Memory Usage (construct): 5,567,008 bytes
Memory Usage (construct): 5,594,008 bytes
Memory Usage (beforeFilter): 14,153,232 bytes

What I'm wondering is why does CakePHP need so much space in memory?
Could I possibly be doing something wrong such that this is
happening?  I don't suspect my app_controller.php containing any
issues considering the minute change between the two
memory_get_usage() calls within __construct().

Any input is greatly appreciated, as this has quickly ground my
development efforts to a halt.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



Fatal Error: Memory exhausted

2008-06-26 Thread Matt Huggins

I'm getting a fatal error regarding my memory being exhausted when
performing a very basic CakePHP operation.  I'm not sure why I'm
getting it or what I can do to fix it.  Hopefully someone else can see
what's wrong with my code since I seem to be missing something.

Here's what I'm doing in my view:

element('blog-posts', array('cache'=>'+1 hour'));?>

And here's what my blog-posts.ctp elements file looks like:

requestAction('/members/getBlogPosts');?>

No articles have been posted recently.


 $title):?>





Here is my function "getBlogPosts" that is being called.  Note that I
still get the same error even with the bulk of my code commented out.

function getBlogPosts() {
uses('Xml');
//$feed = $this->_xmltoArray(new XML(WEB_ROOT.'/blog/rss'));
//$posts = (empty($feed) || empty($feed['rss']['channel']['item'])) ?
null : array_combine(
//  Set::extract($feed, '/rss/channel/item/link/#text'),
//  Set::extract($feed, '/rss/channel/item/title/#text')
//);
//return $posts;
return null;
}

I'm not sure what the problem is in my code, and it's driving me
crazy!  Anyone see anything out of the norm here?  If not, I'll have
to look through prior code to see if it's something else taking up all
the memory.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



Bug in core? ContainableBehavior causing excessive SELECT's

2008-06-16 Thread Matt Huggins

I'm developing a site in which users create profiles ("Profile"
model).  These profiles have a significant number of 'belongsTo'
bindings.  When I create a standard find('first') call on the model,
it performs a single SELECT statement to retrieve the model data and
each associated belongsTo model data.  However, when I create a
find('first') call that makes use of the ContainableBehavior, it makes
the same call as in the first case with an additional (seemingly
unnecessary) SELECT for every belongsTo relationship in the provided
list.

-

Here is an example of the the simple find('first'):

$profile = $this->Profile->find('first', array(
'conditions' => array(
'Profile.id'  => $id,
'Profile.visible' => 'Y',
),
));

-

And the resulting *single* SQL statement from this call:

SELECT `Profile`.`id`, `Profile`.`member_id`, `Profile`.`geocode_id`,
`Profile`.`gender_id`, `Profile`.`photo_id`, `Profile`.`birthdate`,
`Profile`.`name`, `Profile`.`headline`, `Profile`.`description`,
`Profile`.`marital_status_id`, `Profile`.`have_children`,
`Profile`.`want_children`, `Profile`.`hair_color_id`,
`Profile`.`height`, `Profile`.`physique_id`, `Profile`.`ethnicity_id`,
`Profile`.`religion_id`, `Profile`.`politics_id`, `Profile`.`smokes`,
`Profile`.`drinks`, `Profile`.`drugs`, `Profile`.`visible`,
`Profile`.`created`, `Profile`.`updated`, `Member`.`id`,
`Member`.`username`, `Member`.`password`, `Member`.`email`,
`Member`.`active`, `Member`.`created`, `Member`.`updated`,
`Geocode`.`id`, `Geocode`.`latitude`, `Geocode`.`longitude`,
`Geocode`.`city`, `Geocode`.`state`, `Geocode`.`zipcode`,
`Geocode`.`country_id`, `Gender`.`id`, `Gender`.`name`,
`Gender`.`order`, `ProfilePhoto`.`id`, `ProfilePhoto`.`profile_id`,
`ProfilePhoto`.`filename_big`, `ProfilePhoto`.`filename_thumb`,
`ProfilePhoto`.`created`, `MaritalStatus`.`id`,
`MaritalStatus`.`name`, `MaritalStatus`.`order`, `HairColor`.`id`,
`HairColor`.`name`, `HairColor`.`order`, `Physique`.`id`,
`Physique`.`name`, `Physique`.`order`, `Ethnicity`.`id`,
`Ethnicity`.`name`, `Ethnicity`.`order`, `Religion`.`id`,
`Religion`.`name`, `Religion`.`order`, `Politics`.`id`,
`Politics`.`name`, `Politics`.`order`, `Smokes`.`id`, `Smokes`.`name`,
`Smokes`.`order`, `Drinks`.`id`, `Drinks`.`name`, `Drinks`.`order`,
`Drugs`.`id`, `Drugs`.`name`, `Drugs`.`order` FROM `profiles` AS
`Profile` LEFT JOIN `members` AS `Member` ON (`Profile`.`member_id` =
`Member`.`id`) LEFT JOIN `geocodes` AS `Geocode` ON
(`Profile`.`geocode_id` = `Geocode`.`id`) LEFT JOIN `genders` AS
`Gender` ON (`Profile`.`gender_id` = `Gender`.`id`) LEFT JOIN `photos`
AS `ProfilePhoto` ON (`Profile`.`photo_id` = `ProfilePhoto`.`id`) LEFT
JOIN `marital_statuses` AS `MaritalStatus` ON
(`Profile`.`marital_status_id` = `MaritalStatus`.`id`) LEFT JOIN
`hair_colors` AS `HairColor` ON (`Profile`.`hair_color_id` =
`HairColor`.`id`) LEFT JOIN `physiques` AS `Physique` ON
(`Profile`.`physique_id` = `Physique`.`id`) LEFT JOIN `ethnicities` AS
`Ethnicity` ON (`Profile`.`ethnicity_id` = `Ethnicity`.`id`) LEFT JOIN
`religions` AS `Religion` ON (`Profile`.`religion_id` =
`Religion`.`id`) LEFT JOIN `politics` AS `Politics` ON
(`Profile`.`politics_id` = `Politics`.`id`) LEFT JOIN
`frequency_types` AS `Smokes` ON (`Profile`.`smokes` = `Smokes`.`id`)
LEFT JOIN `frequency_types` AS `Drinks` ON (`Profile`.`drinks` =
`Drinks`.`id`) LEFT JOIN `frequency_types` AS `Drugs` ON
(`Profile`.`drugs` = `Drugs`.`id`) WHERE `Profile`.`id` = 2 AND
`Profile`.`visible` = 'Y' LIMIT 1

-

Now here is an example of the find('first') call that uses
Containable:

$profile = $this->Profile->find('first', array(
'contain'=> array('Geocode', 'Geocode.Country', 'Gender.name',
'Physique.name', 'HairColor.name', 'Ethnicity.name',
'MaritalStatus.name', 'Religion.name', 'Politics.name',
'Seeking.name', 'EncounterType.name', 'Interest.name', 'Photo',
'ProfilePhoto'),
'conditions' => array(
'Profile.id'  => $id,
'Profile.visible' => 'Y',
),
));

-

And here is the resulting *multiple* SQL SELECT dump that using
Containable generates:

SELECT `Profile`.`id`, `Profile`.`member_id`, `Profile`.`geocode_id`,
`Profile`.`gender_id`, `Profile`.`photo_id`, `Profile`.`birthdate`,
`Profile`.`name`, `Profile`.`headline`, `Profile`.`description`,
`Profile`.`marital_status_id`, `Profile`.`have_children`,
`Profile`.`want_children`, `Profile`.`hair_color_id`,
`Profile`.`height`, `Profile`.`physique_id`, `Profile`.`ethnicity_id`,
`Profile`.`religion_id`, `Profile`.`politics_id`, `Profile`.`smokes`,
`Profile`.`drinks`, `Profile`.`drugs`, `Profile`.`visible`,
`Profile`.`created`, `Profile`.`updated`, `Geocode`.`id`,
`Geocode`.`latitude`, `Geocode`.`longitude`, `Geocode`.`city`,
`Geocode`.`state`, `Geocode`.`zipcode`, `Geocode`.`country_id`,
`Gender`.`name`, `ProfilePhoto`.`id`, `ProfilePhoto`.`profile_id`,
`ProfilePhoto`.`filename_big`, `ProfilePhoto`.`filename_thumb

Re: How to change the argument separator for named params?

2008-06-16 Thread Matt Huggins

And here's the ticket/fix: https://trac.cakephp.org/ticket/4923

I'm glad I'm not crazy, but now I lost like 3 days of work...now to
make up for lost time!


On Jun 16, 4:34 am, Matt Huggins <[EMAIL PROTECTED]> wrote:
> Okay, I've been going insane over this, and it turns out there's a bug
> in the core.  I'm uploading a patch to trac now.
>
> On Jun 16, 1:26 am, AD7six <[EMAIL PROTECTED]> wrote:
>
> > On Jun 16, 1:57 am, Matt Huggins <[EMAIL PROTECTED]> wrote:
>
> > > For giggles, I also tried the following in my app_controller.php, and
> > > it didn't make a difference:
>
> > Anything you try in the app controller is too late.
>
> > Edit 
> > that:https://trac.cakephp.org/browser/branches/1.2.x.x/cake/libs/router.ph...
> > By calling 
> > this:https://trac.cakephp.org/browser/branches/1.2.x.x/cake/libs/router.ph...
> > in your routes file.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



Re: How to change the argument separator for named params?

2008-06-16 Thread Matt Huggins

Okay, I've been going insane over this, and it turns out there's a bug
in the core.  I'm uploading a patch to trac now.

On Jun 16, 1:26 am, AD7six <[EMAIL PROTECTED]> wrote:
> On Jun 16, 1:57 am, Matt Huggins <[EMAIL PROTECTED]> wrote:
>
> > For giggles, I also tried the following in my app_controller.php, and
> > it didn't make a difference:
>
> Anything you try in the app controller is too late.
>
> Edit 
> that:https://trac.cakephp.org/browser/branches/1.2.x.x/cake/libs/router.ph...
> By calling 
> this:https://trac.cakephp.org/browser/branches/1.2.x.x/cake/libs/router.ph...
> in your routes file.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



Re: How to change the argument separator for named params?

2008-06-15 Thread Matt Huggins

For giggles, I also tried the following in my app_controller.php, and
it didn't make a difference:

function __construct() {
Router::setRequestInfo(array(
Router::parse($this->here),
array('argSeparator' => ';'),
));
parent::__construct();
}

Please help, my project is going to be delayed if I can't get past
this. :(


On Jun 15, 6:50 pm, Matt Huggins <[EMAIL PROTECTED]> wrote:
> I still can't manage to change the named parameter argument separator
> from a colon to a semicolon.  Here are the things I've tried doing,
> which look like they fall in line with the documentation I've come
> across.
>
> app_controller.php:
> class AppController extends Controller {
>         var $argSeparator = ';';
>
> }
>
> config/routes.php:
> Router::connectNamed(true, array('argSeparator'=>';'));
> Router::connectNamed(false, array('argSeparator'=>';'));
>
> Any time I use pagination though, the links always come out looking
> likehttp://example.com/users/view/page:2(note the colon, no
> semicolon).  I really could use some more insight from someone who
> knows how to do this if possible.  Nothing I'm trying is working. :'(
>
> On Jun 14, 10:06 pm, Matt Huggins <[EMAIL PROTECTED]> wrote:
>
> > @Marcin - I searched all over for argSeperator (and argSeparator, I
> > guess whoever coded the feature can't spell though :P ).  I found a
> > bunch of articles saying to set a variable $argSeperator in
> > app_controller.php to another character to make it work, but it didn't
> > work for me.
>
> > @Nate - I already came across Router::connectNamed, but I couldn't
> > figure out how to make it work.  Do I put calls to that in config/
> > routes.php?  I tried that, but it didn't work, not even when I
> > included array('separator'=>';') as the second function parameter.  I
> > must be doing something wrong, but I couldn't find any documentation
> > that properly showed how to set the separator for named params. :(
>
> > On Jun 13, 12:50 pm, Nate <[EMAIL PROTECTED]> wrote:
>
> > > Try the API documentation for Router::connectNamed()
>
> > > On Jun 13, 1:34 pm, Matt Huggins <[EMAIL PROTECTED]> wrote:
>
> > > > Really?  No one knows how to do this?
>
> > > > On Jun 12, 4:39 pm, Matt Huggins <[EMAIL PROTECTED]> wrote:
>
> > > > > Does anyone know how to change the argument separator for named
> > > > > parameters in CakePHP 1.2?  I keep finding posts where people say to
> > > > > set the value of $argSeperator (or $argSeparator) in
> > > > > app_controller.php, but this doesn't change anything for me.  I also
> > > > > stumbled across Router::connectNamed with the option to set the
> > > > > 'separator' key/value, but I'm not sure if this will do what I want.
> > > > > If it is what I need, then I'm either trying to use it incorrectly or
> > > > > in the wrong spot in my code altogether.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



Re: How to change the argument separator for named params?

2008-06-15 Thread Matt Huggins

I still can't manage to change the named parameter argument separator
from a colon to a semicolon.  Here are the things I've tried doing,
which look like they fall in line with the documentation I've come
across.

app_controller.php:
class AppController extends Controller {
var $argSeparator = ';';
}

config/routes.php:
Router::connectNamed(true, array('argSeparator'=>';'));
Router::connectNamed(false, array('argSeparator'=>';'));

Any time I use pagination though, the links always come out looking
like http://example.com/users/view/page:2 (note the colon, no
semicolon).  I really could use some more insight from someone who
knows how to do this if possible.  Nothing I'm trying is working. :'(


On Jun 14, 10:06 pm, Matt Huggins <[EMAIL PROTECTED]> wrote:
> @Marcin - I searched all over for argSeperator (and argSeparator, I
> guess whoever coded the feature can't spell though :P ).  I found a
> bunch of articles saying to set a variable $argSeperator in
> app_controller.php to another character to make it work, but it didn't
> work for me.
>
> @Nate - I already came across Router::connectNamed, but I couldn't
> figure out how to make it work.  Do I put calls to that in config/
> routes.php?  I tried that, but it didn't work, not even when I
> included array('separator'=>';') as the second function parameter.  I
> must be doing something wrong, but I couldn't find any documentation
> that properly showed how to set the separator for named params. :(
>
> On Jun 13, 12:50 pm, Nate <[EMAIL PROTECTED]> wrote:
>
> > Try the API documentation for Router::connectNamed()
>
> > On Jun 13, 1:34 pm, Matt Huggins <[EMAIL PROTECTED]> wrote:
>
> > > Really?  No one knows how to do this?
>
> > > On Jun 12, 4:39 pm, Matt Huggins <[EMAIL PROTECTED]> wrote:
>
> > > > Does anyone know how to change the argument separator for named
> > > > parameters in CakePHP 1.2?  I keep finding posts where people say to
> > > > set the value of $argSeperator (or $argSeparator) in
> > > > app_controller.php, but this doesn't change anything for me.  I also
> > > > stumbled across Router::connectNamed with the option to set the
> > > > 'separator' key/value, but I'm not sure if this will do what I want.
> > > > If it is what I need, then I'm either trying to use it incorrectly or
> > > > in the wrong spot in my code altogether.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



Re: How to change the argument separator for named params?

2008-06-14 Thread Matt Huggins

@Marcin - I searched all over for argSeperator (and argSeparator, I
guess whoever coded the feature can't spell though :P ).  I found a
bunch of articles saying to set a variable $argSeperator in
app_controller.php to another character to make it work, but it didn't
work for me.

@Nate - I already came across Router::connectNamed, but I couldn't
figure out how to make it work.  Do I put calls to that in config/
routes.php?  I tried that, but it didn't work, not even when I
included array('separator'=>';') as the second function parameter.  I
must be doing something wrong, but I couldn't find any documentation
that properly showed how to set the separator for named params. :(

On Jun 13, 12:50 pm, Nate <[EMAIL PROTECTED]> wrote:
> Try the API documentation for Router::connectNamed()
>
> On Jun 13, 1:34 pm, Matt Huggins <[EMAIL PROTECTED]> wrote:
>
> > Really?  No one knows how to do this?
>
> > On Jun 12, 4:39 pm, Matt Huggins <[EMAIL PROTECTED]> wrote:
>
> > > Does anyone know how to change the argument separator for named
> > > parameters in CakePHP 1.2?  I keep finding posts where people say to
> > > set the value of $argSeperator (or $argSeparator) in
> > > app_controller.php, but this doesn't change anything for me.  I also
> > > stumbled across Router::connectNamed with the option to set the
> > > 'separator' key/value, but I'm not sure if this will do what I want.
> > > If it is what I need, then I'm either trying to use it incorrectly or
> > > in the wrong spot in my code altogether.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



Re: How to change the argument separator for named params?

2008-06-13 Thread Matt Huggins

Really?  No one knows how to do this?

On Jun 12, 4:39 pm, Matt Huggins <[EMAIL PROTECTED]> wrote:
> Does anyone know how to change the argument separator for named
> parameters in CakePHP 1.2?  I keep finding posts where people say to
> set the value of $argSeperator (or $argSeparator) in
> app_controller.php, but this doesn't change anything for me.  I also
> stumbled across Router::connectNamed with the option to set the
> 'separator' key/value, but I'm not sure if this will do what I want.
> If it is what I need, then I'm either trying to use it incorrectly or
> in the wrong spot in my code altogether.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



How to change the argument separator for named params?

2008-06-12 Thread Matt Huggins

Does anyone know how to change the argument separator for named
parameters in CakePHP 1.2?  I keep finding posts where people say to
set the value of $argSeperator (or $argSeparator) in
app_controller.php, but this doesn't change anything for me.  I also
stumbled across Router::connectNamed with the option to set the
'separator' key/value, but I'm not sure if this will do what I want.
If it is what I need, then I'm either trying to use it incorrectly or
in the wrong spot in my code altogether.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



Re: Keep current password

2008-06-06 Thread Matt Huggins

As an addendum, you could also do what I did in my current project to
ensure that only certain fields DO validate when saving a model.  This
would allow you to use the method I included in my last post
(specifying the fields you wish to save) while also allowing
validation to work.  Take a look at this method I created within
app_model.php that gets inherited by all models within the app:

http://groups.google.com/group/cake-php/msg/dd21b207447b6206

On Jun 6, 3:49 pm, Matt Huggins <[EMAIL PROTECTED]> wrote:
> You could specify which fields to save, including all the fields you
> need to update, and excluding the password field.  However, you won't
> be able to validate the model if you do this since password will
> always be invalid.
>
> if ($this->User->save($this->data, false, array('username', 'email')))
> {
>     // ...
>
> }
>
> On Jun 6, 3:42 pm, benjam <[EMAIL PROTECTED]> wrote:
>
> > If you'll notice in my controller method, that's exactly what I do,
> > but because it's already hashed, it's not empty, it's a hash of an
> > empty string.
>
> > I need to find a way to delete it before it gets hashed.  And it gets
> > hashed before the data gets to the method.  So I need to find a way to
> > delete it even before that.
>
> > On Jun 6, 2:38 pm, "Chris Hartjes" <[EMAIL PROTECTED]> wrote:
>
> > > On Fri, Jun 6, 2008 at 4:33 PM, benjam <[EMAIL PROTECTED]> wrote:
> > > > I was wondering if there was a way to prevent it from hashing the
> > > > password if there is no password entered?
>
> > > Well, before you save the data when you're editing, you could unset
> > > the password field.
>
> > > i.e. unset($this->data['User']['password']
>
> > > Totally untested.  Hope that helps.
>
> > > --
> > > Chris Hartjes
> > > Internet Loudmouth
> > > Motto for 2008: "Moving from herding elephants to handling snakes..."
> > > @TheKeyBoard:http://www.littlehart.net/atthekeyboard
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



Re: Keep current password

2008-06-06 Thread Matt Huggins

You could specify which fields to save, including all the fields you
need to update, and excluding the password field.  However, you won't
be able to validate the model if you do this since password will
always be invalid.

if ($this->User->save($this->data, false, array('username', 'email')))
{
// ...
}

On Jun 6, 3:42 pm, benjam <[EMAIL PROTECTED]> wrote:
> If you'll notice in my controller method, that's exactly what I do,
> but because it's already hashed, it's not empty, it's a hash of an
> empty string.
>
> I need to find a way to delete it before it gets hashed.  And it gets
> hashed before the data gets to the method.  So I need to find a way to
> delete it even before that.
>
> On Jun 6, 2:38 pm, "Chris Hartjes" <[EMAIL PROTECTED]> wrote:
>
> > On Fri, Jun 6, 2008 at 4:33 PM, benjam <[EMAIL PROTECTED]> wrote:
> > > I was wondering if there was a way to prevent it from hashing the
> > > password if there is no password entered?
>
> > Well, before you save the data when you're editing, you could unset
> > the password field.
>
> > i.e. unset($this->data['User']['password']
>
> > Totally untested.  Hope that helps.
>
> > --
> > Chris Hartjes
> > Internet Loudmouth
> > Motto for 2008: "Moving from herding elephants to handling snakes..."
> > @TheKeyBoard:http://www.littlehart.net/atthekeyboard
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



Re: Accessing plugin functions from app controller?

2008-06-03 Thread Matt Huggins

No one else was able to help on this, but I managed to figure out how
to do this.  Here's my solution in case anyone else has the same
question.

First, within whichever controller I wanted to access my plugin, I
simply added "PluginName.ModelName" to my $uses array.
Then, within my code, I could call $this->ModelName->method();

Pretty simple. :)


On May 27, 12:26 pm, Matt Huggins <[EMAIL PROTECTED]> wrote:
> I'm building my first ever CakePHP plugin (1.2), and I can't find any
> help on how to access plugin functions from within a controller that
> resides within my application.  I've found that it can be done using
> requestAction, but I do not wish to access my plugin's controller
> actions in this way if it can be avoided.
>
> Here's how I have things set up to make my intentions clearer:
>
> - My plugin has a User model, which has functions like register,
> login, etc.
>
> - My plugin has a Users controller, which has functions like
> _register, _login, etc.  These actions are private and cannot be
> accessed directly from the web by a user, which is perfect.
>
> - My application has a separate Members controller.  When a member
> registers via the Members controller, I would like to either call the
> plugin's _register function within the Users controller *OR* the
> register function within the User model.  Attempting to use
> requestAction does not work with the Users controller because
> _register and _login are considered private.
>
> If anyone has any insight on how to accomplish what I'm doing, I would
> greatly appreciate your help.  Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



Accessing plugin functions from app controller?

2008-05-27 Thread Matt Huggins

I'm building my first ever CakePHP plugin (1.2), and I can't find any
help on how to access plugin functions from within a controller that
resides within my application.  I've found that it can be done using
requestAction, but I do not wish to access my plugin's controller
actions in this way if it can be avoided.

Here's how I have things set up to make my intentions clearer:

- My plugin has a User model, which has functions like register,
login, etc.

- My plugin has a Users controller, which has functions like
_register, _login, etc.  These actions are private and cannot be
accessed directly from the web by a user, which is perfect.

- My application has a separate Members controller.  When a member
registers via the Members controller, I would like to either call the
plugin's _register function within the Users controller *OR* the
register function within the User model.  Attempting to use
requestAction does not work with the Users controller because
_register and _login are considered private.

If anyone has any insight on how to accomplish what I'm doing, I would
greatly appreciate your help.  Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



Re: Including images within plugins?

2008-05-22 Thread Matt Huggins

Hmm,  I created "main.css" within /app/plugins/myplugin/vendors/css.
Within "index.ctp", which is located within the associated
controller's view for the plugin, I call the css() method of the HTML
helper as per the following:

css('main', 'stylesheet', array('media'=>'all'), false); ?
>

Instead of attempting to load /myplugin/css/main.css, the function
loads /css/main.css.  Any idea how I can resolve this?  Thanks! :)


On May 22, 9:00 am, "b logica" <[EMAIL PROTECTED]> wrote:
> If your forum images are displayed using only your CSS (ie.
> background-image) then you're good to go. Just put store them within
> an images dir inside the CSS dir and set all the URLs without any
> leading slash and they'll be fetched from there.
>
> In fact, you'd be half way toward making the forum more easily skinnable.
>
> On Thu, May 22, 2008 at 3:15 AM, Dr. Tarique Sani <[EMAIL PROTECTED]> wrote:
>
> > On Thu, May 22, 2008 at 12:41 PM, Matt Huggins <[EMAIL PROTECTED]>
> > wrote:
>
> >> Is it possible to provide images (and other files, such as CSS
> >> stylesheets) with a plugin, such that they are accessible via a URL in
> >> HTML (such as an IMG tag)?  I'm working on a forum plugin, and I'd
> >> like it to be as easy to distribute as possible.  Since I use some
> >> forum-specific images and stylesheets, I'd like to package these up in
> >> the plugin, but I'm not sure if it's possible.
>
> > Images - not possible
>
> > CSS and JS - put in the vendor of plugin
>
> > Tarique
>
> > --
> > =
> > Cheesecake-Photoblog:http://cheesecake-photoblog.org
> > PHP for E-Biz:http://sanisoft.com
> > =
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



Including images within plugins?

2008-05-22 Thread Matt Huggins

Is it possible to provide images (and other files, such as CSS
stylesheets) with a plugin, such that they are accessible via a URL in
HTML (such as an IMG tag)?  I'm working on a forum plugin, and I'd
like it to be as easy to distribute as possible.  Since I use some
forum-specific images and stylesheets, I'd like to package these up in
the plugin, but I'm not sure if it's possible.

Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



Re: CakePHP Forum Software?

2008-05-20 Thread Matt Huggins

I tried.  There's one project that's intended to help integrate phpBB
with CakePHP, but it's outdated.  Then there are 2 forum projects from
last year that only had a couple updates and have no files available
for download.

On May 20, 5:21 pm, "Samuel DeVore" <[EMAIL PROTECTED]> wrote:
> you might look in cakeforge.org
>
>
>
> On Tue, May 20, 2008 at 3:18 PM, Matt Huggins <[EMAIL PROTECTED]> wrote:
>
> > I've tried to get a few known forums (phpBB, SMF, etc.) to integrate
> > into my custom CakePHP CMS, but I'm having so much difficulty.  I was
> > trying to see if anyone has made a forum coded in CakePHP that I can
> > plug into my app, but of course a Google search for "cakephp forum"
> > results in forums discussing CakePHP.
>
> > With that said, I'm looking for one of two things, whichever someone
> > can help me with:
>
> > 1. Help me find some code that works for integrating common PHP
> > bulletin board software (such as phpBB) into CakePHP, or
>
> > 2. Point me to a CakePHP coded forum that I can plug into my
> > application.
>
> > Thanks!
>
> --
> --
> (the old fart) the advice is free, the lack of crankiness will cost you
>
> - its a fine line between a real question and an idiot
>
> http://blog.samdevore.com/archives/2007/03/05/when-open-source-bugs-me/http://blog.samdevore.com/cakephp-pages/my-cake-wont-bake/http://blog.samdevore.com/cakephp-pages/i-cant-bake/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



CakePHP Forum Software?

2008-05-20 Thread Matt Huggins

I've tried to get a few known forums (phpBB, SMF, etc.) to integrate
into my custom CakePHP CMS, but I'm having so much difficulty.  I was
trying to see if anyone has made a forum coded in CakePHP that I can
plug into my app, but of course a Google search for "cakephp forum"
results in forums discussing CakePHP.

With that said, I'm looking for one of two things, whichever someone
can help me with:

1. Help me find some code that works for integrating common PHP
bulletin board software (such as phpBB) into CakePHP, or

2. Point me to a CakePHP coded forum that I can plug into my
application.

Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



Re: General purpose page / design issues

2008-05-20 Thread Matt Huggins

I've been using CakePHP for almost 2 years now, and I still don't know
what the best way to do this is.  The way I do it is I end up creating
an added action in one of my controllers, and I change the routing for
the homepage to point there.  I'd really like to know of a better
approach to this, as I haven't found any good real-world example.

On May 20, 2:17 pm, W Marsh <[EMAIL PROTECTED]> wrote:
> Hi.
>
> If you look at most web sites you will see that their index pages are
> generally a mish-mash of different functionality. For example, they
> might give a summary of recent blog posts coupled with other
> statistics, all relating from various models in the system.
>
> How does this fit into the model-view-controller mentality?
> Controllers and models tend to be focused on one specific piece of
> functionality in the examples I've seen. There are no good examples of
> real world usage.
>
> I should point out this is a design/best practices question. I know
> HOW to make an index/general purpose page work, but I would like to
> hear some wisdom on how to do it in the CakePHP spirit.
>
> Thanks.
>
>   - Wayne
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



Re: Vendor issue: Duplicate class name

2008-05-20 Thread Matt Huggins

Ugh, I'm screwed if there's nothing I can do about this now. :/

On May 20, 1:51 pm, jonknee <[EMAIL PROTECTED]> wrote:
> On May 20, 3:36 am, Matt Huggins <[EMAIL PROTECTED]> wrote:
>
> > I'm trying to import a vendor class, but the class I'm importing in
> > turn references another 3rd party class named "cache". Since there is
> > already a CakePHP class named "Cache", I get an error message stating
> > "Fatal Error: Cannot redeclare class cache in [filename]".
>
> > Does anyone have any clue how I can work around this? I don't want to
> > rename the vendor class since I'll need to perform future upgrades to
> > the class, not to mention that the class name is referenced throughout
> > much of the 3rd party code. I have no idea where to go from here.
> > Please help!
>
> This is why namespaces are being introduced into PHP (originally as
> part of 6, but backported to 5.3)
>
> http://us2.php.net/manual/en/language.namespaces.php
>
> Unfortunately that's not going to help you now. You may be stuck
> renaming manually (well at least with a regex).
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



Re: Problem with HABTM not getting related data

2008-05-20 Thread Matt Huggins

You need to modelize your HABTM table.  Hopefully this link will help
you out.

http://cricava.com/blogs/index.php?blog=6&title=modelizing_habtm_join_tables_in_cakephp_&more=1&c=1&tb=1&pb=1


On May 20, 3:04 am, Reza Muhammad <[EMAIL PROTECTED]> wrote:
> Hi guys.
>
> I just tried to setup a HABTM relationship between "Model" and  
> "Parts".  In my "Model" model.   I already created tables called  
> 'models', 'parts', and 'models_parts'.
>
> Here's what I have in my models:
>
> - model.php
>
> class Model extends AppModel {
>
>         var $name = 'Model';
>         var $useTable = 'models';
>         var $validate = array(
>                 'name' => array(
>                         'rule' => VALID_NOT_EMPTY,
>                         'required' => true,
>                         'message' => 'Model name must only contains letters 
> and numbers'
>                 )
>         );
>         //The Associations below have been created with all possible keys,  
> those that are not needed can be removed
>         var $hasAndBelongsToMany = array(
>                 'Part' => array('className' => 'Part',
>                         'joinTable' => 'models_parts',
>                         'foreignKey' => 'model_id',
>                         'associationForeignKey' => 'part_id',
>                         'unique' => true,
>                         'conditions' => '',
>                         'fields' => '',
>                         'order' => '',
>                         'limit' => '',
>                         'offset' => '',
>                         'finderQuery' => '',
>                         'deleteQuery' => '',
>                         'insertQuery' => ''
>                 )
>         );
>
> }
>
> - part.php
>
> class Part extends AppModel {
>
>         var $name = 'Part';
>         var $useTable = 'parts';
>
>         //The Associations below have been created with all possible keys,  
> those that are not needed can be removed
>
>         var $hasAndBelongsToMany = array(
>                         'Model' => array('className' => 'Model',
>                                                 'joinTable' => 'models_parts',
>                                                 'foreignKey' => 'part_id',
>                                                 'associationForeignKey' => 
> 'model_id',
>                                                 'unique' => true,
>                                                 'conditions' => '',
>                                                 'fields' => '',
>                                                 'order' => '',
>                                                 'limit' => '',
>                                                 'offset' => '',
>                                                 'finderQuery' => '',
>                                                 'deleteQuery' => '',
>                                                 'insertQuery' => ''
>                         )
>         );
>
> }
>
> Now, the problem is, When I run find() from Parts Controller, I can  
> get the data from table models_parts (So, I can tell which parts  
> belongs to which models).  However, I also want to be able to get data  
> from table models_parts when I run find() from Models Controller.
>
> I have set both of these controllers to use recursive = 2 ($this->Part-
>  >recursive = 2, and $this->Model->recursive=2), yet it only works  
> from Parts, not the model.
>
> Should I be creating a ModelPart model too?
>
> Please help me out, thank you :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



View this page "CakePHP Unofficial Resources"

2008-05-20 Thread Matt Huggins

Added a link to Facebook application development with CakePHP

Click on 
http://groups.google.com/group/cake-php/web/cakephp-unofficial-resources
- or copy & paste it into your browser's address bar if that doesn't
work.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



Re: Validating only specific fields within a model?

2008-05-20 Thread Matt Huggins

Thanks jonknee, I didn't even consider the 'on' key in my validation
rules.  I'll have to go back to this and see if that solution works
better than the modification I made to app_model.php that I posted
above. :)

On May 19, 10:40 pm, jonknee <[EMAIL PROTECTED]> wrote:
> > Does anyone have any insight on how to go about validating specific
> > fields in a model for special circumstances like this?  Thanks!
>
> We had a discussion that got into this topic recently:
>
> http://groups.google.com/group/cake-php/browse_thread/thread/dc119a9b...
>
> There are a few ways to go, the easiest in your case is probably using
> the 'on' key in your validation rules. You could also fetch the user's
> data, modify it with the new password and then attempt to save the
> whole thing back.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



Re: Validating only specific fields within a model?

2008-05-20 Thread Matt Huggins

Yes, that's basically what is happening.  Even when using saveField
(with the validate parameter set to true), which only saves a single
field of a model, the entire model is validated based upon whatever
field names are specified in the model's $validate variable.

On May 19, 10:39 pm, "David C. Zentgraf" <[EMAIL PROTECTED]> wrote:
> I haven't come across any problems with the validations yet...
> Are you saying that it attempts to validate fields which aren't  
> present in your input data and fails on them?
>
> On 20 May 2008, at 12:34, Matt Huggins wrote:
>
>
>
> > I originally thought the same thing as you David.  It seems
> > instinctive that only the fields being saved should be validated.
> > However, looking into the model.php file of the core shows that ALL
> > fields are in fact being validated, even if only one or several fields
> > are being updated.
>
> > Specifically, the following if-condition stands out within the save()
> > function.  Note how it doesn't validate some fields; instead it
> > validates all fields.  This is confirmed by verifying the
> > functionality of the validates() function as well, which in turn calls
> > invalidFields() without specifying specific fields for validation.
>
> > if ($options['validate'] && !$this->validates()) {
> >    $this->whitelist = $_whitelist;
> >    return false;
> > }
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



Vendor issue: Duplicate class name

2008-05-20 Thread Matt Huggins

I'm trying to import a vendor class, but the class I'm importing in
turn references another 3rd party class named "cache". Since there is
already a CakePHP class named "Cache", I get an error message stating
"Fatal Error: Cannot redeclare class cache in [filename]".

Does anyone have any clue how I can work around this? I don't want to
rename the vendor class since I'll need to perform future upgrades to
the class, not to mention that the class name is referenced throughout
much of the 3rd party code. I have no idea where to go from here.
Please help!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



Re: Validating only specific fields within a model?

2008-05-19 Thread Matt Huggins

I originally thought the same thing as you David.  It seems
instinctive that only the fields being saved should be validated.
However, looking into the model.php file of the core shows that ALL
fields are in fact being validated, even if only one or several fields
are being updated.

Specifically, the following if-condition stands out within the save()
function.  Note how it doesn't validate some fields; instead it
validates all fields.  This is confirmed by verifying the
functionality of the validates() function as well, which in turn calls
invalidFields() without specifying specific fields for validation.

if ($options['validate'] && !$this->validates()) {
$this->whitelist = $_whitelist;
return false;
}
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



Re: Validating only specific fields within a model?

2008-05-19 Thread Matt Huggins

Alright, well I solved my own problem.  It might not be the most
efficient method, but given that I didn't find anything within CakePHP
to handle this, I think it's pretty good.  In case anyone else is
looking for how to do it, here's what I did.  Within app_model.php,
simply create the following function:

/**
 * Name: validates()
 * Desc: Allow only specified fields to be validated for a model.
 */
function validates($fieldList = null) {
// If no fields are specified, then simply use the standard
validation method.
if ($fieldList === null) {
return parent::validates();
} else {
// If a single value is passed as a string, convert it to an 
array.
if (!is_array($fieldList)) {
$fieldList = array($fieldList);
}

// If the validation array is not set for the model, then there 
is
nothing to check.
if (!isset($this->validate) || empty($this->validate)) {
return true;
} else {
// Create a placeholder for the original validation 
array, then
filter out
// any fields that do not require validation.  Perform 
the
validation, then
// restore the original validation array for the model.
$validate = $this->validate;
$this->validate = array_intersect_key($this->validate,
array_flip($fieldList));
$result = parent::validates();
$this->validate = $validate;

return $result;
}
}
}

Now, when you want to validate specific fields, just pass an array of
field names to the validates() function.

$this->Member->set($this->data);
$result = $this->Member->validates(array('password', 'password2'));
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



Validating only specific fields within a model?

2008-05-19 Thread Matt Huggins

In CakePHP 1.2, is there a way to validate only some specific fields
within a model?

I have a "Member" model is set up to validate several fields under
normal conditions, such as "username", "password", "email", etc.  I'm
trying to make a "change password" form for users of my application.
Since I'll only be saving the "password" field of the model, I only
want to validate the "password" & "password2" (validate password)
fields that are entered by the user.  Unfortunately, the model class's
validate() function does not take any parameters, meaning that the
entire model is validated despite only updating a single field value
via saveField().

Does anyone have any insight on how to go about validating specific
fields in a model for special circumstances like this?  Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~--~~~~--~~--~--~---



Default form data

2008-01-22 Thread Matt Huggins

I'm currently using CakePHP 1.2 beta.  I already know that you can do
something like the following in order to provide a default INPUT
value:

$form->input('User.name', array('type'=>'text', 'value'=>'Beavis'));

The problem is that I only want this default value to display when the
page is first being loaded (i.e.: during a GET that is not the result
of a form submission).  Currently, when the user submits the form
submits, I want the page to display the second time with whatever
value the user entered (i.e.: Controller::$data['User']['name']).
Currently, the value "Beavis" is always put into the textbox, even
after the form is submitted with a different value.

How can I display a default value when a form IS NOT submitted, and
the user's value when a form IS submitted.

--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---