Re: Conceptual hints on inheritance

2007-08-21 Thread nagarjuna

I am working on a similar project and decided to use a taxonomic_unit
as the basic element. I have one table taxonomic_units where all
levels get stored, as well as the hierarchical relations between them.
You should look into modified pre-order tree traversal (see
http://www.sitepoint.com/article/hierarchical-data-database ). Of
course each level will have different additional characteristics
besides just the taxonomic relationships, and I use separate tables to
store these characteristics (i.e. kingdom_characteristics,
phylum_characteristics, etc.). I have just one model and one
controller for the taxonomic units and in my controller I go the
relevant additonal table, extract the other details, and my views are
set up generically to display the info.

I am not sure if this is the most cake like approach, but it makes
maintenance easier even if the coding is a bit uglier (lots of switch
statements for example).

Hope that helps.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Updating translation .po files

2007-08-20 Thread nagarjuna

Hi,

I am setting up a site so that the admin (not me) can add new fields,
steps, etc. I want to set it up so that, when they add a new field,
they will input the translated name for the field as well, and behind
the scenes I will update the .po file automatically.  But I have no
idea how to go about this. Is it possible? Is there a better approach?

Thanks


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: integrate third party ajax library

2007-08-13 Thread nagarjuna

In another attempt at getting this up and running, I copied the
relevant code from the php file that was being called, and added a
method inside
my app_controller and created a view of the same name.  Here is my new
function:

function sc_select_ajax_handler( )
{
vendor('linkedSelect\top_script');
$this->log( "entered select handler" , LOG_DEBUG );
print_r( $_REQUEST );
$link_field_value = $_REQUEST['linkval'];
$table = $_REQUEST['table'];
$key = $_REQUEST['key'];
$text = $_REQUEST['text'];
$order = $_REQUEST['order'];
$extra_where = stripslashes($_REQUEST['extra_where']);
$select_prompt_text = $_REQUEST['select_prompt_text'];
$linkfld = $_REQUEST['linkfld'];

$cmd = "SELECT $key, $text FROM $table ";
$b_where_word_added=FALSE;
if( (!empty($linkfld)) && (!empty($link_field_value)) ) {
$b_where_word_added = TRUE;
$cmd .= " WHERE $linkfld= ";
if( is_string($link_field_value) )
$cmd .="'$link_field_value' ";
else
$cmd .="$link_field_value ";
}
if( !empty($extra_where ) ) {
if( $b_where_word_added )
$cmd .= " AND ";
else
$cmd .= " WHERE ";
$cmd .= " $extra_where ";
}
print_r( $cmd );
if( $order!='' )
$cmd .= " ORDER BY $order";
$rows = getRecords($cmd);
print_r( $rows );
$this->set( 'select_prompt_text', $select_prompt_text);
$this->set( 'rows', $rows );
if( count($rows)!=0 ) {
header("Content-Type: text/xml");//
print'';
print '';
print '';
print '0';
print ''.$select_prompt_text.'';
print '';
for($i=0;$i';
print ''.$rows[$i][0].'';
print ''.addslashes(htmlspecialchars($rows[$i]
[1])).'';
print '';
}
print '';
exit;
}
header("Content-Type: text/xml");
print'';
print '';
print '';
print '0';
print 'None';
print '';
print '';

$this->render();
}

The code executes fine, but the changes never show up on the page.  In
fact the next select box looses all of its options.  I tried moving
all the display code into the view, but had no luck with that either.

Any more suggestions are greatly appreciated.



--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: How to handle hasMany data entry

2007-08-06 Thread nagarjuna

Thanks for the advice.  Unfortunately this will not work for me
because it chokes on:

$this->Mark->invalidate('mark_number'.$i, "Mark already exists);

I have two types of marks for input (NewMarks and ExistingMarks), and
they are stored in the data matrix under $this->data['NewMarks'] not
under $this->data['Marks'].
So with the above statement, cake tries to look for the variable
data['Marks'] and invalidate it and I get the error message

Undefined property:  ObservationsController::$Mark [CORE\app
\controllers\observations_controller.php, line 134]

Is there any way to invalidate a field directly in the controller if
the field is not attached to any model field?
For example, is there anyway to access the form helper directly in the
controller a.la.
$this->form->error('NewMarks'.'mark_number'.$i, "Mark already
exists" );

The above won't work, but you get the idea.  By the way, I am using
the formHelper and validation from 1.2


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



How to handle hasMany data entry

2007-08-06 Thread nagarjuna

I have the following setup:  Class Observation hasMany Marks.
The Marks Class only has one relevant field: mark_number
I am working on the add form for my Observations, and the problem is
that I do not know in advance how many Marks a given observation will
have.  I initialize the form with one mark field called data['Marks']
['mark_number0'], and then if the user has multiple marks he can click
on a "add another mark" link which dynamically creates a new field
data['Marks']['mark_number1'] and so on.
So far so good.  My problem comes to dealing with data validation.
First, I need to check that each mark_number is unique and doesn't
already exist in the database and if not I need to invalidate the
field.  I would like to put the validation routine inside my Mark
model, but it only has a single field mark_number, and not
mark_number0, etc, so I cannot invalidate the appropriate field there.

I can code all of this by hand, but it is ugly and feels wrong as if I
am not taking advantage of all the cakey goodness.  What is the best
practice way to deal with this situation.

Thanks for any advice


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: How to find all categories where language_id is equal querystring?Please help

2007-08-06 Thread nagarjuna

How about:

$this->Category->findByLanguageId( $id );

Cheers


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: integrate third party ajax library

2007-08-03 Thread nagarjuna

Okay I modified the library source to redirect to my controller
(observations/add)

new Ajax.Request( 'cake/observations/add', { method:
'POST',parameters: pars, onComplete: onCompleteCallBack });

The debug log message is below.  Not really sure how to deal with this
(sorry, new to Cake and Ajax).  The url is weird. Should I redirect
the request from within my function (i.e. change the url to the
appropriate path i.e. cake/vendors/sc_select_ajax_handler.php or
something)? In which case I will need to do that in all of my
controllers that use this library (or I could add it to my
appController)?  Any help greatly appreciated.


2007-08-03 15:17:20 Debug: Array
(
[pass] => Array
(
)

[controller] => observations
[action] => add
[form] => Array
(
[linkval] => 1
[table] => taxonomic_units
[key] => id
[text] => name
[order] => name
[extra_where] => type='Phylum'
[select_prompt_text] => Please select a Phylum
[linkfld] => parent_id
[_] =>
[_method] => POST
)

[url] => Array
(
[url] => observations/add/cake/observations/add
)

[bare] => 1
[webservices] =>
[return] => 1
[requested] => 1
[plugin] =>
)



--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: integrate third party ajax library

2007-08-01 Thread nagarjuna

Thanks for the advice Chris.  I installed the firbug plugin and fixed
a coupld of problems.  I realize now that the main issue is that the
code in the library is trying to request an additional .php file that
is in the library's folder inside the /vendors folder.  The relevant
code is:

new Ajax.Request( sc_select_ajax_handler.php, { method: 'POST',
parameters: pars, onComplete: onCompleteCallBack });

When it does, I get the following error message:
You are seeing this error because the action
sc_select_ajax_handler.php

So I guess my question then really boils down to how to make this
request process correctly?  Do I need to map this .php file to a
controller action? Thanks for any help.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



integrate third party ajax library

2007-07-31 Thread nagarjuna

I need to use a lot of hierarchicaly linked list boxes in my project,
and I found a great 3rd party ajax library that does so here:
http://www.salix.gr/ajax_linked_selectboxes

I installed the library and I can get the demo running just fine.
Embedded in my app, everything displays properly but nothing updates
as it should.  I added javascript and Ajax helpers to the list of
helpers in my controller, and also added the RequestHandler
component.  Finally, I made sure to link prototype and scriptalicious
in my layout.

After perusing this tutorial:
http://www.littlehart.net/atthekeyboard/2006/09/26/tutorial-integrating-phpswf-charts-with-cakephp/

I am beginning to think that including the library is not as simple as
I had first thought.  Will I have to go into the libraries source code
and add Cake specific code?  Is it not just possible to drop the
library in and run with it?


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Help with project design

2007-07-30 Thread nagarjuna

Hello,

I am designing a database to hold scientific observations of animals
in the field. The database will be used for several different
projects.  The basic unit for all projects is the observation, and
observations across projects will store the same basic information
(and use the same logic), but projects may also need to store some
additional information.  My plan is to have one main observations
table/model/controller, and then additional project specific tables.
Each project then hasMany observations and each observation belongsTo
one project, and in the observation view I will then find the
appropriate project specific table and adjust my forms/displays
appropriately.

Any thoughts or critiques of this approach?

Secondly, I need to store a hierarchical species taxonomy (kingdom,
order, genus, etc) in the database and allow users to update it
(species classifications are changed frequently).  The logic and view
for each level is nearly identical, and I would like to avoid creating
separate models and controllers for each. The best approach for me
would be to dynamically change the table used by a model.  My search
suggests that this is not possible, but does anyone know for sure?  I
could also create a new class and inherit from it, but this would
still involve creating a separate model and controller file for each
level, which is less than ideal.  Any suggestions?

Thanks


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---