1.1.x Testsuite and Session
Hello everybody, what I'm trying to achieve is to insert a testunit of the authentication procedure already implemented and running. So I would not like to change the code. The procedure access a MembersController::signin() that if has $this-data set then do all the required operation for testing the UID/PASS correctness and the set the suitable session paramters. These session parameters are tested within all the application for signed user test and used with ACL for giving the right permissions. What I though was to do a MembersControllerTestCase::testAuthentication() (for example) and inside this call something like $this-object-Session-destroy(); $this-object-requestAction(/members/signin); $this-assertFalse($this-object-Session-check(PARAM)); $data = array(); $data[Member] $this-object-data = $data; //this should execute the authentication procedure $this-object-requestAction(/members/signin); $this-assertTrue($this-object-Session-check(PARAM)); obviously this is not working or I wouldn't have been here asking :) I'm browsing a bit api and google. Does someone has an idea on how reach the goal? I've also tried setting a local SessionComponent with loadComponent(Session); $this-Session = new SessionComponent(); but it seems that the session I'm using in the testsuite is not the same of the one used in the requestAction or something else. Thanks a lot Davide -- Live life like you're gonna die. Because you're gonna. William Shatner --~--~-~--~~~---~--~~ 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: Alias?
Davide wrote: unfortunly Router::connect() seems not to work for me. Cake 1.1.18. It's simply ignored. But you gave me a hint and using $Route-connect(...) I can achieve my goal. However I have to add a $Route-connect() for each action and it's not beautiful and subject to errors. I'm thinking in a workaround solution. I will post it here. Worked a bit on it, but it took too much time for achieving a good solution so I finally opted for mapping each action in routes.php and managing the alias in the view action. So finally here is the code[1]. Now I'm asking myself about the utility of AppError if it's disabled in a production environment. Can someone answer me maybe with a scenario? Thanks a lot. Bye Davide 1. //routes.php ... $Route-connect(/projects/, array(controller=projects,action=index)); $Route-connect(/projects/add/, array(controller=projects,action=add)); $Route-connect(/projects/delete/, array(controller=projects,action=delete)); $Route-connect(... ... $Route-connect(/projects/view/, array(controller=projects,action=view)); $Route-connect(/projects/:alias, array(controller=projects,action=view)); //app/controllers/projects_controller.php ... function view($id=null){ $data = null; if(empty($this-params[alias]) is_null($id)){ $this-cakeError(error404,array($this-params[url])); }else{ if(!is_null($id)){ $data = $this-Project-findById($id); }else{ $data = $this-Project-findByAlias($this-params[alias]); } ... -- Live life like you're gonna die. Because you're gonna. William Shatner --~--~-~--~~~---~--~~ 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: Alias?
Joel Perras wrote: ... For that, use: (app/config/routes.php) Router::connect('/projects/:name', array('action'='view', 'name'=null)); ... Thanks Joel, unfortunly Router::connect() seems not to work for me. Cake 1.1.18. It's simply ignored. But you gave me a hint and using $Route-connect(...) I can achieve my goal. However I have to add a $Route-connect() for each action and it's not beautiful and subject to errors. I'm thinking in a workaround solution. I will post it here. Thanks for the hint. Davide -- Live life like you're gonna die. Because you're gonna. William Shatner --~--~-~--~~~---~--~~ 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: Alias?
I wrote a code (at the bottom) that in case of missingAction will search in the database and if found then render the proper view. Everything works fine except when I turn DEBUG=0 (production setup). Now cake always render the 404 without entering the AppError::missingAction(). How can I do? Following the code. Bye and thanks Davide /* * app/error.php */ class AppError extends ErrorHandler{ function missingAction($params){ switch($params[className]){ case ProjectsController: loadModel(Project); $model = new Project(); $data = $model-findByAlias($params[action]); if(is_null($data) || empty($data)){ parent::missingAction($params); }else{ $this-controller-webroot = $params[webroot]; $this-controller-set(content_for_layout,$this-requestAction(/projects/view/.$data[Project][id], array(return))); $this-controller-pageTitle = $data[Project][name]; $this-controller-viewPath = layouts; $this-controller-render(ajax); } break; default: parent::missingAction($params); break; } } } -- Live life like you're gonna die. Because you're gonna. William Shatner --~--~-~--~~~---~--~~ 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: Ajax::observeField
Chris Hartjes wrote: D'oh -- that stuff I posted is Cake 1.2 specific. I don't use Cake 1.1 at all, so can't help you there. Ok Chris but you gave me a hint. So searching in the core code (session.php) I saw three points where Session.checkAgent is present. The only way I found (puttin some debug messages) for setting this parameter was putting the Configure::write inside the bootstrap.php, cause inside the core.php it seems to be ignored, or maybe the core.php is read after the session.php; I've not got deeper the question. I've also tried to put it to false editing the core libs/configure.php the only Session.checkAgent (line 340) but it seems to be ignored or to be not enough for the problem. Finally, I've solved, after restoring the old situation, making the CAKE_SECURITY=medium in the app core.php (it was high before). Now everything is working out right. Thanks a lot Bye Davide -- Live life like you're gonna die. Because you're gonna. William Shatner --~--~-~--~~~---~--~~ 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: Undefined variable: html
williamn wrote: Notice: Undefined variable: html in D:\xampp\htdocs\sirusananda\app \views\layouts\default.thtml on line 17 Fatal error: Call to a member function css() on a non-object in D: \xampp\htdocs\sirusananda\app\views\layouts\default.thtml on line 17 But when I switch back, those error messages just disappear. Strange, generally this error appear when the HtmlHelper is not defined in the helpers array of the controller. Is it defined? var helpers = array(html,...); -- Live life like you're gonna die. Because you're gonna. William Shatner --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Ajax::observeField
Hello everybody I'm trying to use the method in subject with no result. CakePHP 1.1.18. The PHP code in thtml is: ... echo $html-input(Project/name,array(maxlength=50,class=)); ... echo $ajax-observeField( ProjectName, array( update=web, url=/projects/webAlias/ ) )? ... the rendered code (html) is the following ... input name=data[Project][name] maxlength=50 class= value= type=text id=ProjectName / ... script type=text/javascript new Form.Element.Observer('ProjectName', 2, function(element, value) { new Ajax.Updater('web','/projects/webAlias/', { asynchronous:true, evalScripts:true, parameters:Form.Element.serialize('ProjectName'), requestHeaders:['X-Update', 'web']} ) } ) /script everything works except that it's returned to me that is missing argument 1 for the controller action. Maybe I'm missing some parameter to the observeField function. Bye Davide -- Live life like you're gonna die. Because you're gonna. William Shatner --~--~-~--~~~---~--~~ 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: Getting the HTTP host ?
Neveldo wrote: ... Or must I simply use $_SERVER['HTTP_HOST'] ? Don't know, I always use the $_SERVER variable. Bye Davide -- Live life like you're gonna die. Because you're gonna. William Shatner --~--~-~--~~~---~--~~ 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: Ajax::observeField
Davide wrote: ... everything works except that it's returned to me that is missing argument 1 for the controller action. Solved at moment making the function argument as optional and testing for the existence of $this-data[Project][name] thank and bye davide -- Live life like you're gonna die. Because you're gonna. William Shatner --~--~-~--~~~---~--~~ 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 ajax
mkaelkael wrote: ... listlevel.thtml is a views and in the same directory than the index.thml Don't know if it's right to refer directly to a thtml file, but try remove the initial slash from /listlevel.. so linking to listlevel... Bye Davide -- Live life like you're gonna die. Because you're gonna. William Shatner --~--~-~--~~~---~--~~ 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: Ajax::observeField
A strange thing regarding this topic. I can't understand where's the problem. Everytime I call the method with the observeField, all my Session data is lost and so I'm disconnected. It's the first time I'm using Ajax+AjaxHelper+Cake, so I could do something wrong. When I remove the observeField call, everything is fine. Here is the code of the methods: ?php // app/controllers/projects_controller.php class ProjectsController extends AppController { ... function beforeFilter(){ parent::beforeFilter(); array_push($this-helpers,ajax); } ... function webAlias(){ if(isset($this-data[Project][name])){ $this-layout = ajax; $this-autoRender = false; echo $this-_webAlias($this-data[Project][name]); } } } ? ?php /* * /app/app_controller.php */ class AppController extends Controller { ... function beforeFilter(){ parent::beforeFilter(); $aro = ALL; if($this-Session-check(ID)){ $aro = $this-Session-read(ARO); } if(isset($this-params[controller]) isset($this-params[action])){ if($this-checkAccess($this-params[controller],$this-params[action],$aro)){ }else{ $this-redirect(/pages/denied); exit; } } } /** * return a web alias starting from a provied string * * @param $string the provided string to be parsed * @return the translated string */ function _webAlias($string){ $ret = trim(strtolower($string)); $ret = preg_replace(/[ ]/,-,$ret); $ret = preg_replace(/^[-]+/,,$ret); $ret = preg_replace(/[-]+\$/,,$ret); $ret = preg_replace(/[^a-z0-9-]/,,$ret); return $ret; } ... } ? -- Live life like you're gonna die. Because you're gonna. William Shatner --~--~-~--~~~---~--~~ 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: Ajax::observeField
Chris Hartjes wrote: You might have to change some stuff in your config/core.php file. Look for Session.checkAgent Often you have do Configure::write('Session.checkAgent', false); to preserve sessions when using Ajax Session.checkAgent is not defined in my core.php. I tried defining it define(Session.checkAgent,false); and call the Configure::write function webAlias(){ if(isset($this-data[Project][name])){ Configure::write('Session.checkAgent', false); $this-layout = ajax; $this-autoRender = false; echo $this-_webAlias($this-data[Project][name]); } } But none of them worked. Some other ideas? Cake version 1.1.18. -- Live life like you're gonna die. Because you're gonna. William Shatner --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Alias?
Good morning, I have a ProjectsController that works fine with the usual add/edit/view/index. I can successfully view a project with /projects/view/$id. Each project has also a unique name, and I would like to refer to each project even with a url like /projects/$name. I thought about extending the AppError on the missingAction and do the required operations (code in the footer of the mail). requestAction retrieve successfully the project detail with the right thtml but no layout is rendered. How can I render the correct page without doing a redirect? Another question: is it possible to specify a different ErrorHandler for a controller? So it could be possible to avoid ugly switch. Something like setting the errorHandler variable inside the controller. Thanks a lot Davide ?php /* * app/error.php */ class AppError extends ErrorHandler{ function missingAction($params){ switch($params[className]){ case ProjectsController: loadModel(Project); $model = new Project(); $data = $model-findByName($params[action]); echo $this-requestAction(/projects/view/.$data[Project][id], array(return)); break; default: parent::missingAction($params); break; } } } ? -- Live life like you're gonna die. Because you're gonna. William Shatner --~--~-~--~~~---~--~~ 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: Alias?
Davide wrote: ... How can I render the correct page without doing a redirect? At the moment I've solved in this way. Don't know if it's the right way but it's working. Thanks a lot Bye Davide ?php /* * app/error.php */ class AppError extends ErrorHandler{ function missingAction($params){ switch($params[className]){ case ProjectsController: loadModel(Project); $model = new Project(); $data = $model-findByName($params[action]); if(is_null($data) || empty($data)){ parent::missingAction($params); }else{ $this-controller-webroot = $params[webroot]; $this-controller-set(content_for_layout,$this-requestAction(/projects/view/.$data[Project][id], array(return))); $this-controller-pageTitle = $data[Project][name]; $this-controller-viewPath = layouts; $this-controller-render(ajax); } break; default: parent::missingAction($params); break; } } } ? -- Live life like you're gonna die. Because you're gonna. William Shatner --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Testsuite and 1.1
Hello everybody, I'm trying to use the CakePHP TestSuite[1] and everything seems to work except some little things: The CSS has been changed from cake.default.css to cake.generic.css fixed on line 189 of /app/tests/test.php. When accessing http://app/tests, if I include the final slash in the url everything works out fine. If I omit it, the url of the links instead of being something line http://app/tests/casesapp=true is http://app/casesapp=true. I'm working for finding where to fix this last, however, I would like to know if the project is still active and I can report any bugs or not. Thanks and bye Davide PS: I'm using 1.1.18 1. http://cakeforge.org/projects/testsuite/ -- Live life like you're gonna die. Because you're gonna. William Shatner --~--~-~--~~~---~--~~ 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: session problems with cake 1.18 and CAKE_SECURITY=high?
Martin Schapendonk wrote: CAKE_SECURITY set to high also means that Cake checks the referer and drops the session if it believes it is being tampered with. I have the same problem but from 1.1.18 to 1.1.19. In 1.1.18 everything works out well, in 1.1.19 not. In the authentication procedure I login in a controller setting some session variables, then redirect to another controller. In this last all checks of session variables are empty. I've also tried with security HIGH, MEDIUM and LOW but none of them works. When I get back to 1.1.18 everything is ok. Bye and thanks Davide -- Live life like you're gonna die. Because you're gonna. William Shatner --~--~-~--~~~---~--~~ 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: session problems with cake 1.18 and CAKE_SECURITY=high?
Martin Schapendonk wrote: On 1/8/08, Davide wrote: I've also tried with security HIGH, MEDIUM and LOW but none of them works. When I get back to 1.1.18 everything is ok. This may be trivial, but the setting is case sensitive. Did you try high, medium and low as well? Yes, I did. I just uppercased them in the sentence for highlighting. :) -- Live life like you're gonna die. Because you're gonna. William Shatner --~--~-~--~~~---~--~~ 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: New To Cake PHP
Gourab singha wrote: I am new To Cake PHP .It is very difficult to me that communicate Module,Controller,View To Each Other,Please Send me a simple coded Sorry, I have no time to post code samples and so on, but sometime ago, I posted on the blog[1] the resources I used for learning this framework. Maybe something now it's deprecated. HTH Bye Davide 1. http://edivad.wordpress.com/2007/04/06/learning-cakephp/ -- Live life like you're gonna die. Because you're gonna. William Shatner --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Helper? Ajax? Which better?
Sorry for possible double post, but I've posted it more than an hour ago and still didn't received back from the list. Good morning. I have to load the latest 5 news inside a div of an homepage. I thought about making a function NewsController::last5() which could be something like the following $this-data = $this-News-findAll(null,null,News.created desc,5,1); $this-set(data,$this-data); Now, I should have to load it in a div inside the homepage (/pages/home.thtml). I thought about using an helper that load the data using the previous function and render a div. How can I better reach this result? Using an Helper? Using Ajax? And how for both of them? Thanks in advance Davide -- Live life like you're gonna die. Because you're gonna. William Shatner -- Live life like you're gonna die. Because you're gonna. William Shatner --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Helper? Ajax? Which better?
Good morning. I have to load the latest 5 news inside a div of an homepage. I thought about making a function NewsController::last5() which could be something like the following $this-data = $this-News-findAll(null,null,News.created desc,5,1); $this-set(data,$this-data); Now, I should have to load it in a div inside the homepage (/pages/home.thtml). I thought about using an helper that load the data using the previous function and render a div. How can I better reach this result? Using an Helper? Using Ajax? And how for both of them? Thanks in advance Davide -- Live life like you're gonna die. Because you're gonna. William Shatner --~--~-~--~~~---~--~~ 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: Need a helpful tutorial
Reine wrote: ... http://www.ibm.com/developerworks/search/searchResults.jsp?searchType=1searchSite=dWsearchScope=dWquery=cakephpSearch.x=0Search.y=0Search=Search On Jun 7, 11:39 am, Lifo [EMAIL PROTECTED] wrote: Dear group member I am new in CakePHP. So i need a free Cake PHP tutorial. Please give me any tutorial or link. Thanks for yours help. I've summed up[1] some references for learning CakePHP on my blog. Bye Davide 1. http://edivad.wordpress.com/2007/04/06/learning-cakephp/ --~--~-~--~~~---~--~~ 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: Understanding validator regex
Floyd wrote: I don't understand: - Why is used a double escape \\ bar instead of a single bar \ I think bacause with a single slash in a string you mean that you want to escape the following character. So \\ stands for escape \ character. - What is the meaning of A(?: at start of regex - Why there is a / at start -What is the meaning of \\z/i at final of regex All of those because (always I think) because the preg_match() function is used for re checking. So a perl like syntax should be used. Bye Davide --~--~-~--~~~---~--~~ 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: Does cake cache plugins
Davide wrote: It comes in my mind: Luke, use the source... But if someone else has an answer that can avoid me the source :) I was looking in the source and I found that at line 117 of cake/libs/view/helpers/cache.php[1] there's an If statement If I comment the testing (leaving the code inside the block) the things works fine. In fact for the plugin the $cache variable is always not passed while for a controller that I used for testing is passed as true. Where can I search for the calling of that function? I missed my self inside the code :) Thanks Davide 1. http://api.cakephp.org/view_2helpers_2cache_8php-source.html#l00117 --~--~-~--~~~---~--~~ 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: Does cake cache plugins
I got it! The problems was in the plugin. It force to use no layout and this make no cache. I've added /app/plugins/rss/views/layouts/rss.thtml with this simple code ?php echo $content_for_layout; ? and then in /app/plugins/rss/controllers/rss_controller.php I've substituted line 86 from $this-layout = ''; to $this-layout = 'rss'; Now cache is caching. However now there's what I think to be a little bug in cache component. If I have to cache a stream like ?xml version=1.0 encoding=ISO-8859-1? !-- generator=FeedCreator 1.7.2-ppt ([EMAIL PROTECTED]) -- rss version=2.0 channel titleLocalhost:... it will be generated a file like 01 !--cachetime:1180623951--?php if (!class_exists('AppController')) { ... } ??xml version=1.0 encoding=ISO-8859-1? 41 !-- generator=FeedCreator 1.7.2-ppt ([EMAIL PROTECTED]) -- rss version=2.0 channel titleLocalhost:... and as you see at line 41 the ?xml will generate an error in server that interpret ? as a php starting statement. Which would be the best way to solve this? However I'm still investigating. Thanks in advance Davide --~--~-~--~~~---~--~~ 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: Does cake cache plugins
Davide wrote: ... Which would be the best way to solve this? However I'm still investigating. A quick solution to be tested. I've tested a bit but need to be tested more: in cake/libs/views/helpers/cache.php 260 ?' ;//. $content; 261 $content = preg_replace(/((\\?)|(\\?))/, 262 ?php echo '$1';?,$content); 263 $file.=$content; Tomorrow I'm gonna check it harder. Bye Davide --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Does cake cache plugins
Hello everybody. I'm trying the rss plugins[1] and it works great. However, in order to save server resources, I'm trying to cache the view. I've toggled debug to 3 in order to see if it's caching and I've putted CACHE_CHECK=true in config and then I tried to treat plugin controller as a normal controller with the following result class RssController extends RssAppController { var $name = 'Rss'; var $helpers = array('Time', Cache); var $uses = ''; var $model = null; var $cacheAction = +1 hour; However, watching at the generated rss appened there's always the executed query (with different time of execution). So the question is: am I wrong with somethig or cake doesn't support cache for plugins? Thanks a lot Davide 1. http://bakery.cakephp.org/articles/view/automagic-rss-feed-generator-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: Does cake cache plugins
Chris Hartjes wrote: As far as I know (I know I will be corrected if I am wrong) caching will only occur if you have debug set to 0. Maybe right but there's no mention of that in the manual. If true, how can I check for cache working? Thanks Davide --~--~-~--~~~---~--~~ 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: Does cake cache plugins
Samuel DeVore wrote: request the page once... (see if it shows up in the caches/view folder in temp I thought that too and no page in app/tmp/cache/views. It comes in my mind: Luke, use the source... But if someone else has an answer that can avoid me the source :) Thanks Davide signature.asc Description: OpenPGP digital signature
Re: Why cake save to 0 value if you are editing a model ?
Chris Hartjes wrote: Perhaps I'm wrong, but last I checked you can't set an integer to NULL...the default for an integer would be zero, wouldn't it? on MySQL 4.1.14-nt (Windows XP) CREATE TABLE `xyz` ( `field1` int(11) default NULL, `field2` int(11) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 mysql insert into xyz (field2) value (1); Query OK, 1 row affected (0.00 sec) mysql select * from xyz; +++ | field1 | field2 | +++ | NULL | 1 | +++ 1 row in set (0.00 sec) I had the doubt too :) Bye Davide --~--~-~--~~~---~--~~ 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: Error while uploading files
Samuel DeVore wrote: http://us2.php.net/manual/en/features.file-upload.errors.php By the link you provided it's noticed that the error is raised because there's no set for the ini variable upload_tmp_dir. I've tried something like the following (I hoped) but didn't work, and I can even understand why. Do you know a way to solve it, or should I have to contact the administrators in order to set the variable? Thank a lot Davide function beforeFilter(){ parent::beforeFilter(); //Configure::write(debug,1); $tmp_dir = ini_get(upload_tmp_dir); if($tmp_dir==){ ini_set(upload_tmp_dir,ROOT . DS . APP_DIR . DS . tmp); } $this-log($tmp_dir,LOG_DEBUG); $this-log(ROOT . DS . APP_DIR . DS . tmp ,LOG_DEBUG); } --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Error while uploading files
I've developed a simple file upload. Everything in development and test environment goes fine but not in production environment. The procedure is the simple move_uploaded_file() plus some operations on database. It failed to upload and In logs I got the following 2007-04-19 16:12:35 [UploadsController-add()] Error: Array ( [Upload] = Array ( [id] = [file] = Array ( [name] = Volantino03062006.pdf [type] = [tmp_name] = [error] = 6 [size] = 0 ) ) ) Where can I get a translations of error field? I've done a search but without success. Thanks a lot Davide --~--~-~--~~~---~--~~ 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: Problem with Model::afterSave() callback
Davide wrote: ... I'm trying to use the afterSave callback in order to update a field of a just inserted record. I have this code[1]. If I didn't comment the saveField() statement, the browser (FireFox) will complain saying[2]. ... Finally after some logging I found what it is. It's a sort of loopback. If in afterSave I try to update a field, the lifecycle (before, save, after) restart. This until the pages goes to timeout. So actually it's not possible to update a record in the afterSave loopback. In order to solve it, I've moved the saveField() in the controller method after the if($this-Model-save()). Is this a framework bug/feature? Is this an application design mistake? With application I mean my application, not the framework. Will make it sense to be able to specify for example a parameter to the afterSave callback in order to tell to the framework to skip the natuaral save lifecycle? Thanks a lot Bye Davide --~--~-~--~~~---~--~~ 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: Problem with Model::afterSave() callback
GreyCells wrote: Why not just build the path when selecting the record? (afterFind() will do). You do not have to duplicate the record's id in the path column. I thought about an additional field, 'cause if I build the path in the afterFind(), I would have to cycle the recordset in order to add the path and then in the view I will have to cycle again the data collection in order to present it. I could even build the path in the view but I would like to reduce at minimum the data manipulation in this part of application. If you must work around the framework lifecycle, then direct $model- execute('UPDATE blah, blah') calls will work. Hmmm i forgot this method :) Thank bye Davide --~--~-~--~~~---~--~~ 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: (HtmlHelper::submit) Deprecated: Use FormHelper::submit instead | switch off?
Schubidu wrote: I changed ?php echo $html-submit('Save') ? to ?php echo $form-submit('Save') ? but it doesnt works. Did you include the form helper in your controller? $helpers = array(...,form,...); What error it gives to you? Bye Davide --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Problem with Model::afterSave() callback
Hello everybody. I'm trying to use the afterSave callback in order to update a field of a just inserted record. I have this code[1]. If I didn't comment the saveField() statement, the browser (FireFox) will complain saying[2]. What could it be? Thanks a lot Davide 1. //controller function add(){ if(isset($this-data)){ if($this-Upload-save($this-data)){ $this-flash(ok,/uploads); return 0; }else{ $this-flash(KO,/uploads); return -1; } } $this-render(add-edit); return 0; } //model function beforeSave(){ parent::beforeSave(); if(isset($this-data)){ $this-data[Upload][name] = $this-data[Upload][file][name]; $this-data[Upload][ctype] = $this-data[Upload][file][type]; } return true; } /** * sets some values after saved */ function afterSave(){ parent::afterSave(); $id = $this-getLastInsertID(); $this-set(id,$id); $this-saveField(path,/uploads/view/ . $id); } 2. /// The connection was reset The connection to the server was reset while the page was loading. * The site could be temporarily unavailable or too busy. Try again in a few moments. * If you are unable to load any pages, check your computer's network connection. * If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web. --~--~-~--~~~---~--~~ 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: Cache?
jonatha wrote: I have had the same problem on an hosted server. My solution was to disable caching on webserver via meta headers. Can you please post how you did it? Thanks a lot Davide --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Cache?
I've released a site based on CakePHP. I've tested it with the 1.1.13 and 1.1.14 but the same problem seems to remain. I'm using Firefox as web browsers. I forestall that I don't think it's a cake problem but I prefer to hear different advices. On development and test environments (WinXP, php 4.4.0, Apache/2.0.54) I have no problems, after login, edit and everything else, it will be presented to me the right results. Both environments are on my pc, the same of the developing. In production environment (Debian, php 5.2.0-8, Apache/2.2.3), often as response I get the previous page. For example, after login I will be redirected to a page and a greeting message with setFlash() is presented. It happens that often I will be redirected to the page but the message doesn't appear. A simple refresh and I see the message. What do you think I could check? Thanks a lot Davide --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Included library
Good morning. I've released a site with cakephp. The structure is the canonical cake one www/ site/ app/ cake/ ... when I access the site it directly point to the site directory so I got url like http://site.domain.org/controller/param1/... Actually when I require a page, every component, or other required files are searched by the basic.php. I've noticed that it seems to search for every cake file in the php ini libs directory and finally in the site directory. This cause me the following error. Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/usr/share/pear/cake/libs/controller/components/acl.php) is not within the allowed path(s): (/var/www/theSite:/usr/share/php/) in /home/www/theSite/cake/basics.php on line 1013 Beside the eventual server configuration error that I'm checking with the admin, I would like to know if I missed some configuration. I've actually solved the problem putting the @ before the file_exists() call. Thank a lot and Bye Davide --~--~-~--~~~---~--~~ 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: R: Included library
[EMAIL PROTECTED] wrote: is better to modify app/config/core.php and set define('DEBUG', 0); Yes, I know that this will hide me the warning and notice, but actually I'm in beta and I need the debug in order to trace some situations, even the configurations problems like that :) Thanks Davide --~--~-~--~~~---~--~~ 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: For every model every database table also?
Louie Miranda wrote: is it possible to only have a page ex? on the controller about_controller.php and just add a static page on views about.thtml without creating a new table for abouts? just use routing for that. I've not a framework by my hands now and I don't remember the syntax but the logic is redirect all request of about controller to pages controller on the action display and the page about. Bye Davide --~--~-~--~~~---~--~~ 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: cakephp tutorial
Daniel Hofstetter said: There is no book available yet, but try the manual (http:// manual.cakephp.org) or try this :) http://groups.google.com/group/cake-php/browse_thread/thread/a967f1218a43ff5c/eb422cd8f6b691fd#eb422cd8f6b691fd --~--~-~--~~~---~--~~ 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: testsuite, some examples.
Davide said: Davide said: The main problem is that I don't know how to use the testsuite, so I ... Actually I've solved in this way[1] and seems to work. I would like to know if this is the right way to proceed or there's a better way to do that: something more automatic. ... ok, here it is a way to make it working. I still don't know if it's the right way to do things but it seems to works right. Following the code of the tests and of the controller. If someone has any other ideas or know how to use the suite, he/she is welcome :) Thanks a lot Bye Davide ?php /* * app/test/app/controllers/posts_controller.test.php */ class PostsControllerTest extends UnitTestCase{ var $posts = null; function PostsControllerTest($label=false){ parent::UnitTestCase($label); loadController(posts); loadModel(post); $this-posts = new PostsController(); $this-posts-Post = new Post(); } function testIndex(){ $this-posts-index(); //do we get something? $this-assertTrue(is_array($this-posts-data)); } function testAdd(){ //trying to view the page $this-assertTrue($this-posts-add()); //try insert a right post $this-posts-data[Post][title] = UnitTest; $this-posts-data[Post][body] = UnitTest; $this-assertTrue($this-posts-add()); //try insert a wrong post (should hang up) $this-posts-data[Post][title] = ; $this-posts-data[Post][body] = ; $this-assertFalse($this-posts-add()); } } ? ?php /* * app/controllers/posts_controller.php */ class PostsController extends AppController{ var $name = 'Posts'; function index(){ $this-set('data',$this-Post-findAll()); } function add(){ $ret = false; if(empty($this-data)){ $ret = true; }else{ if($this-Post-save($this-data)){ $this-flash(Your post has been saved,/posts); $ret = true; }else{ $this-set('data',$this-data); $this-validateErrors($this-Post); } } return $ret; } ... } ? --~--~-~--~~~---~--~~ 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: testsuite, some examples.
Davide said: The main problem is that I don't know how to use the testsuite, so I don't know if I have to manually load each component (controller and model) or it should be handled manually by the suite. Actually I've solved in this way[1] and seems to work. I would like to know if this is the right way to proceed or there's a better way to do that: something more automatic. Any developer of the testsuite? :) Bye Davide 1. ?php /* * app/test/app/controllers/posts_controller.test.php */ class PostsControllerTest extends UnitTestCase{ var $posts = null; function PostsControllerTest($label=false){ parent::UnitTestCase($label); loadController(posts); loadModel(post); $this-posts = new PostsController(); $this-posts-Post = new Post(); } function testIndex(){ $this-posts-index(); } } ? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
testsuite, some examples.
Hello everybody. I'm trying my first test suite with cake and I have downloaded the testsuite from cakeforge (1.0.0.5) and using it on the 1.1.12.4205 version of CakePHP. I'm trying to understand how to create a SimpleTest, even following the documentation in the app/vendors/simpletest/docs/ path. I'm using this[1] code and get the error Fatal error: Call to a member function on a non-object in ...app\controllers\posts_controller.php on line 6. The method is missing is the set() method. The PostsController is a simple controller I use for some testing, so the method is very simple[2]. Surely I'm missing something. Can please someone post an example 'cause google cache is not worthwhile for the wiki and there's no more tutorial on line. Thanks Davide [1]?php /* * app/test/app/controllers/posts_controller.test.php */ require_once(APP . /controllers/posts_controller.php); class PostsControllerTest extends UnitTestCase{ function testIndex(){ $posts = new PostsController(); print_r($posts); $posts-index(); } } ? [2]class PostsController extends AppController{ var $name = 'Posts'; function index(){ $this-set('data',$this-Post-findAll()); } ... } --~--~-~--~~~---~--~~ 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: Please Help me
Chris Hawes said: http://manual.cakephp.org/chapter/installing http://manual.cakephp.org/appendix/blog_tutorial http://api.cakephp.org/ You could also try this tutorial; it's divided in 5 parts https://www6.software.ibm.com/developerworks/education/os-php-cake1/os-php-cake1-a4.pdf https://www6.software.ibm.com/developerworks/education/os-php-cake2/os-php-cake2-a4.pdf http://www-128.ibm.com/developerworks/library/os-php-cake3/index.html https://www6.software.ibm.com/developerworks/education/os-php-cake4/os-php-cake4-a4.pdf http://www-128.ibm.com/developerworks/library/os-php-cake5/index.html Bye Davide --~--~-~--~~~---~--~~ 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: testsuite, some examples.
Daniel Hofstetter said: You may try to use loadController('posts'); instead of require_once. Unfortunately it's not working. I'm getting the same error. The actual code is here[1] Thanks Davide [1] ?php /* * app/test/app/controllers/posts_controller.test.php */ //require_once(APP . /controllers/posts_controller.php); class PostsControllerTest extends UnitTestCase{ function testIndex(){ loadController(posts); $posts = new PostsController(); print_r($posts); $posts-index(); } } ? --~--~-~--~~~---~--~~ 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: testsuite, some examples.
AD7six said: but the error is probably here: $data =$this-Post-findAll(); and not here: $this-set('data',$data); You are right. I was investigating and the problem is in the Post. It _seems_ not to be initialized. I've tried something like $this-set(data,null); and worked fine. Does that function work via the browser, if so how does the test suite load models..? It should be triggered by the controller constructor. Any possibility that cake is trying to show you an error message (any clues in the $post array)? The Posts controller works fine. If I call /posts/index I get a page with sql statements[1]. The main problem is that I don't know how to use the testsuite, so I don't know if I have to manually load each component (controller and model) or it should be handled manually by the suite. However here[2] is the print_r($posts). Bye and thanks Davide 1. SELECT `Post`.`id`, `Post`.`user_id`, `Post`.`title`, `Post`.`body`, `Post`.`created`, `Post`.`modified`, `Post`.`status` FROM `posts` AS `Post` WHERE 1 = 1 2. postscontroller Object ( [_log] = [name] = Posts [here] = [webroot] = [action] = [uses] = [helpers] = Array ( [0] = Html ) [params] = Array ( ) [data] = Array ( ) [viewPath] = posts [viewVars] = Array ( ) [pageTitle] = [modelNames] = Array ( ) [base] = [layout] = default [autoRender] = 1 [autoLayout] = 1 [components] = Array ( [0] = Locale ) [view] = View [ext] = .thtml [__viewClass] = [output] = [plugin] = [cacheAction] = [persistModel] = [beforeFilter] = [webservices] = [modelClass] = Post [modelKey] = post ) --~--~-~--~~~---~--~~ 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: having empty entry in selecttag selected
[EMAIL PROTECTED] wrote: ... Basically I copied the function selectTag and named it to myselectTag. The only thing I had to do is to change the following line and mark it as selected: if ($showEmpty == true) { $select[] = sprintf($this-tags['selectempty'],'selected'); } I've not followed the thread so I could say something wrong or useless. Why didn't you extend the HtmlHelper class directly and then reimplement only the required method? So in all of your application, you have only to include your helper and will have all the htmlHelper functionality plus yours. Bye Davide -- By the power of Greyskull... signature.asc Description: OpenPGP digital signature
Helpers and Components
Sometime ago, I developed my own helpers for formatting date. Everything is ok, but now I need those function even in the controller level. So I thought about components. Everything is still fine. Now I wouldn't like to duplicate the code, I would like something like using the components code from the helpers. Something like class MyHelper... function dumb(param1, param2){ return $this-controller-MyComponent-dumb(param1, param2); } ... It seems not to working, so I ask. Which should be the best way for obtaining this feature? Maybe a static library referenced with the vendors()? Bye Davide -- By the power of Greyskull... signature.asc Description: OpenPGP digital signature
Re: Helpers and Components
leo.cacheux wrote: You forgot to call view in the helper : class MyHelper... function dumb(param1, param2){ return $this-view-controller-MyComponent-dumb(param1, param2); } Cool, it works! Now the question is: is this the better way to implement the feature? Otherwise, what do you advise? Thanks and Bye Davide -- By the power of Greyskull... signature.asc Description: OpenPGP digital signature
Re: find specific data in table
[EMAIL PROTECTED] wrote: Hi there, I have a table users, in which 2 persons have the name moore. How could I list those two sets of data in cakePHP? I'm looking for something equivalent to: SELECT * FROM users WHERE name=moore; I don't think I understood you right, but if so, maybe you are looking for something like this in your controller method $this-User-findAll(array(name=moore)); Bye Davide -- By the power of Greyskull... signature.asc Description: OpenPGP digital signature
Re: validates bug ?
davide wrote: ... with the pattern /^[a-z0-9\_\-$/i. Sorry, I forgot the at least 3 chars. :) /^[a-z0-9\_\-]{3,}$/i Bye Davide -- By the power of Greyskull... signature.asc Description: OpenPGP digital signature
Trimming posted data
Good morning. Cake 1.1.8.3544, php 4.4.0 and apache 2.0.54 (Win32). I've always used this steps for trimming the posted data, but actually it doesn't seems to work anymore. In the app/app_model.php I've added this function function beforeValidate(){ parent::beforeValidate(); //trimming whole data if(isset($this-data[$this-name])){ $buff = $this-data[$this-name]; foreach($buff as $index=$elem){ if(is_string($elem)) $buff[$index] = trim($elem); } $this-data[$this-name] = $buff; } return true; } that as you can see, step through the posted data and trim them if are strings. So, when they pass to validation, if I have a VALID_NOT_EMPTY field, and the user inputed only spaces, cake automatically raise an error. A sample model is something like this function add(){ ... if(isset($this-data)){ if($this-Treasury-save($this-data)){ ... This method always worked but now, with 1.1.8 I was testing it and saw that it wont work. So putting some logs I saw that in the model::invalidFields() function at line 1308[1] made a test. Just before this line, the $data variable holds the originally posted data (not trimmed), and $this-data holds the trimmed ones. The $data is not empty, so the validation is finally made on the not trimmed data. How can I do to set also the $data variable? I've tried something like function beforeValidate(){ parent::beforeValidate(); //trimming whole data if(isset($this-data[$this-name])){ $buff = $this-data[$this-name]; foreach($buff as $index=$elem){ if(is_string($elem)) $buff[$index] = trim($elem); } $this-data[$this-name] = $buff; $data = $this-data; } return true; } but it doesn't work. Maybe I miss something. Sorry for the long post. Thanks and bye Davide 1. http://api.cakephp.org/model__php4_8php-source.html#l01308 -- By the power of Greyskull... signature.asc Description: OpenPGP digital signature
VALID_AMOUNT
Maybe this is already passed on the list, but if so I mess it. I use this regular expression to validate amounts in my application. define(VALID_AMOUNT,/^(-?[0-9]+)(\.[0-9]{2})?$/); Allows numbers, with optional 2 decimal digits and may be also a negative number. If someone would like it, he can take it and if someone want to include it in the cake framework (maybe an improved form), can do it. HTH Bye Davide -- By the power of Greyskull... signature.asc Description: OpenPGP digital signature
Re: Changing parentship in ACL
davide wrote: ... Watching at the AclNode code, I saw that in the setParent() method, at line 152 (more or less) there is this code: if ($parent_id != null $newParent['lft'] = $object['lft'] $newParent['rght'] = $object['rght']) { return false; } ... I have commented this[1] if and everything seems to work fine. Someone more inside the ACL can enlight me. Does anybody things I should have to open a bug ticket? Bye and thanks Davide 1. http://api.cakephp.org/aclnode_8php-source.html#l00139 -- By the power of Greyskull... signature.asc Description: OpenPGP digital signature
Re: Changing parentship in ACL
AD7six wrote: I think it is simply a question of complexity as to why that isn´t included. Probably best to attach your comment/fix to this: https://trac.cakephp.org/ticket/1235 I was just looking at those ticket and thinking about improving with comments :) But before you do...Does your removed-if-fix work fine in that it doesn´t generate sql/cake errors or does it work fine in that the end result is a valid tree? I think the result is likely to be a corrupted tree looking at the rest of the setParent code. I've made some tests and it seems to keep the right tree. Notice that I said it seems. I'm not very ACL proof and for me everything is ok but I prefer to refer me to someone more ACL-Friend than me. Although it is more SQL work I would say it would be better to make it an orphan, and /then/ set the parent to be the one that you want. That way the lft and rght fields will have the correct values for everything under the original parent. I've tried to delete the the node and then to create again and setting the new parent, but when I do that, it's also deleted all the aros_acos I gave to that user. I've tried something like $this-Aro-recursive = 0; before deleting but then I noticed that inside the delete() method there's no check against the recursivity[1]. Bye and thanks Davide 1. http://api.cakephp.org/aclnode_8php-source.html#l00101 -- By the power of Greyskull... signature.asc Description: OpenPGP digital signature
Re: Changing parentship in ACL
AD7six wrote: Are there any missing or duplicate numbers in the lft rght fields after the demotion. If the same number appears in either field, the tree has been corrupted; if there is a gap it has been corrupted. It doesn't seems so. However I've left this approach as the one described by nate (the great :)) in the ticket. set the parent to null (or anything not under the current parent) and then set the parent to the node that you want. Assuming that you are looking for a working solution rather than hacking/fixing the core to get it perfect. Yes as I was saying just some lines aboves, here is the solutions if($this-Aro-setParent(null,$alias)){ if($this-Aro-setParent($group,$alias)){ //yo baby! }else{ //manage error } }else{ //manage error } Thanks a lot Bye Davide -- By the power of Greyskull... signature.asc Description: OpenPGP digital signature
Re: tmp Warning
dkni wrote: ok i will thx u maybe you have extracted the zip using winzip. Winzip by default (i don't know if it's settable) didn't extract empty folders contained in the zip archive. If so, try for example winrar or a porting of tar for windows :). However as Pape said, it should be enough to create a writable tmp folder by hand. Bye Davide -- By the power of Greyskull... signature.asc Description: OpenPGP digital signature
Re: tmp Warning
dkni wrote: I am using Fedora now. I have no idea how to do that. Do what? Extract the archive or create/give access to tmp directory? Bye Davide -- By the power of Greyskull... signature.asc Description: OpenPGP digital signature
Re: How can I add admin directory under cakephp framework?
Larry E. Masters aka PhpNut wrote: http://cakephp.org/screencasts/view/5 Is there a way to have the screen cast in a downloadable version? For example in a zipped format. The content filtering of the company I work for, block every type of video/audio and I can't see the casts. Thanks and bye Davide -- By the power of Greyskull... signature.asc Description: OpenPGP digital signature
Wrong $html-checkbox() value
I've noticed that if I specify an array of htmlAttributes for the $html-checkbox, the value attribute is not rendered anymore. I have to specify it by hand in the array. Otherwise, i I don't use the htmlAttributes array, everything is rendered right. Here some usage example: ?=$html-checkbox(Member/inlist,null,array(checked=checked,value=1))? will render input type=hidden name=data[Member][inlist] value=0 id=MemberInlist_ / input type=checkbox name=data[Member][inlist] checked=checked value=1 id=MemberInlist / * ?=$html-checkbox(Member/inlist,null,array(checked=checked))? will render input type=hidden name=data[Member][inlist] value=0 id=MemberInlist_ / input type=checkbox name=data[Member][inlist] checked=checked id=MemberInlist / * ?=$html-checkbox(Member/inlist)? will render input type=hidden name=data[Member][inlist] value=0 id=MemberInlist_ / input type=checkbox name=data[Member][inlist] id=MemberInlist value=1 / Cake version: 1.1.6.3264 php version: 4.4.0 apache version: 2.0.54 I've searched in the track but I didn't find this problems? Do you have this behaviour too? Do you think this is a right behaviour? Do I have to open a ticket? Thanks in advance Davide -- By the power of Greyskull... signature.asc Description: OpenPGP digital signature
Re: Wrong $html-checkbox() value
Chowsapal wrote: Try $html-checkbox('Member/inlist', null, array('value' = 1, 'checked' = $members['Member']['inlist'])) The value = 1 just indicates what value you want to use for true. The problem is that when I don't specify attributes, the checkbox automatically render the value=1. Instead, when I specify even only one attribute, the value attribute is not rendered anymore. I have to specify by my hand. I don't know if this is a bug, or if it's wanted that the helpers works in this way. However, If I specify the value everything is fine. Bye D. signature.asc Description: OpenPGP digital signature
Re: About tabels relations in my models
Tener wrote: I have 3 tables: users: id | username | password groups: id | groupname user_groups: id | user_id | group_id How to set members declarations (is that the proper-english-name for objects/classes variables?) of 3 models to make everything works perfectly? I'm writing without a sample code by my hand, so I can make mistakes. From the table you are showing it seems to be a hasAndBelongsToMany relationship. A user can have many groups and a group can have many users. So create the tables as the following users: id, username, pass groups: id, groupname groups_users: group_id, user_id From the cake naming conventions, the relation table name should be a composite name of the two related table ordered by name. Then it should be time for model class User extends AppModel var $name = User; var $hasAndBelongsToMany = Group; class Group extends AppModel var $name = Group; var $hasAndBelongsToMany = User; HTH bye Davide signature.asc Description: OpenPGP digital signature
Re: HeadHelper problem
davide wrote: Maybe I mess something but I can't get what. I want to add a custom css to a view. Even if I added to controller, layout and view, I can't get the css link in the rendered page. See the bottom for code snippets. Sorry guys, I'm very stupid. I was editing the wrong view... no words about it :) thanks and bye D. signature.asc Description: OpenPGP digital signature
HABTM searches
Good afternoon. I have 4 tables: users, states, profiles and profiles_users (model extract at the end) I would like to extract all users that has a particular profile. Searching thought the list archive I found[1] the solution $this-User-Profile-findById(4); This works pretty fine but it doesn't sort the records and doesn't retrieve the State detail of the user. I would like to achieve the same result as of this query select a.surname as surname, a.name as name, c.dx as state, d.dx as profile from users as a join profiles_users as b on (b.user_id=a.id) join profiles as d on (b.profile_id = d.id) left join states as c on (a.state_id = c.id) where b.profile_id = 4 and d.dt_end_val = current_date order by a.surname, a.name; is there some cake-way for doing this or should I have to use the findBySQL? Thanks in advance Bye Davide 1. http://groups.google.com/group/cake-php/browse_thread/thread/50dd8e4461e34a81/8dbf01196906aaec /* * app/models/user.php */ class User extends AppModel{ var $name=User; var $belongsTo = array(State); var $hasAndBelongsToMany = array(Profile = array( conditions = Profile.dt_end_val = CURRENT_DATE, order = Profile.dx ) ); /* * app/models/state.php */ class State extends AppModel{ var $name = State; var $displayField = dx; var $hasMany = array(User=array(limit=5)); /* * app/models/profile.php */ class Profile extends AppModel{ var $name=Profile; var $displayField = dx; var $hasAndBelongsToMany = array(User); signature.asc Description: OpenPGP digital signature
Re: Application bootstrap.php
AD7six wrote: ... Personally, I use the following (potentially flawed) upgrade approach backup app/config folder, replace the cake folder, replace the app/config folder replace the app/* folders overwrite the app/config folder with the backup (so that my version of the config files exist, but don´t miss any new files should there be any). Ok, you make upgrade as I do. For me it's a must to backup every evening and before any upgrade. :) regards Davide signature.asc Description: OpenPGP digital signature
Re: Trim on $this-params['data']
eveloper wrote: Thanks for your reply Grant. I noticed that cleanArray does not do trimming for white spaces at the beginning and at the end of the string. The Sanitize does not trim the params, just clean them in order to prevent, for example, sql exploit. Follows a strip of code I use to trim the whole form data. function beforeValidate(){ ... //trimming whole data $data = $this-data[YourModelHere]; foreach($data as $index=$elem){ if(is_string($elem)) $data[$index] = trim($elem); } $this-data[YourModelHere] = $data; ... return true; } HTH, bye Davide signature.asc Description: OpenPGP digital signature
Re: $this-Model-findAll() with a model over 5000 records.
Maybe you can even use pagination[1] :) HTH bye Davide 1. http://wiki.cakephp.org/tutorials:pagination signature.asc Description: OpenPGP digital signature
Re: CakePHP 1.1.4.3083
Larry E. Masters aka PhpNut wrote: ... CakeForge[3] when its a little more complete. Hopefully some people will be interested in contributing with some translations once we get it onto CakeForge. As of this writing, we are one ticket away from 1000. We ... First of all: great job! :) Then I'm here, concerning my life/job engagements, for translating it in Italian. What should/can I do? Bye D. signature.asc Description: OpenPGP digital signature
Re: CakePHP 1.1.4.3083
I've downloaded this[1] version and testing it in a fresh environment but I get the following error message: Fatal error: Call to a member function on a non-object in H:\www\cake-new\cake\libs\view\templates\layouts\default.thtml on line 57 XAMPP for windows 1.4.16 (Apache/2.0.54 (Win32) mod_autoindex_color mod_ssl/2.0.54 OpenSSL/0.9.8 PHP/4.4.0) Regards Davide 1. http://cakeforge.org/frs/download.php/204/cake_1.1.4.3083.tar.gz signature.asc Description: OpenPGP digital signature
Re: CakePHP 1.1.4.3083
Larry E. Masters aka PhpNut wrote: This fixed package should correct your errors http://cakeforge.org/frs/?group_id=23release_id=105 It works fine. :) Thanks. Davide signature.asc Description: OpenPGP digital signature
Re: extends a class that extends AppModel
RosSoft wrote: Why you're extending AppController to CustomController in all your controllers? (Same question for Models) If you want to do so, it's as easy as copy the files cake/app_controller.php and cake/app_model.php to app/app_controller.php and app/app_model.php. Then you can modify these files and all your controllers/models will inherit them. Be sure to put the files under app/ (NO app/controllers/app_controller and NO app/models/app_model.php) I saw that everybody use this method in documentation on wiki, but I prefer to keep the sources intact use the extends to add/modify objects behavior. Thanks Bye Davide signature.asc Description: OpenPGP digital signature
Re: extends a class that extends AppModel
Felix Geisendörfer wrote: Use require_once instead of require and you should be fine. Unfortunately no. I go the same error. Fatal error: Cannot redeclare class custommodel in H:\www\multi-cake\casting\models\custom_model.php on line 2 What else? Thanks and bye D. // //modules/custom_model.php ?php class CustomModel extends AppModel{ } ? // //modules/user.php ?php require_once(custom_model.php); class User extends CustomModel{ var $name=User; //... } ? signature.asc Description: OpenPGP digital signature
Re: extends a class that extends AppModel
nate wrote: David, first of all, the AppModel and AppController that ship with Cake will always be empty files. They're meant to provide the user (you) with a base class that all of your models/controllers can inherit from. Oh yes. Sorry, my fault (as usual). I was looking inside the model_php4.php and I never saw that the class there is _Model_ and not _AppModel_. Ok, it's easy as drink a glass of water (as almost all in cake) :) Thanks a lot for the help Bye signature.asc Description: OpenPGP digital signature
Re: Strange beforeValidate() behaviour
davide wrote: I'm getting a strange behaviour using the beforeValidate() callback. The goal is to trim the required (VALID_NOT_EMPTY) fields before passing the the cake validation. It's strange 'cause it seems that if I put all correct data I get the $this-data variable full of datas, otherwise if I leave a field that doesn't pass the validation, in the beforeValidate() I get an empty $this-data. Finally I made it works. I've updated the model_php4.php library in the validates method as following /** * Returns true if all fields pass validation, otherwise false. * * @param array $data POST data * @return boolean True if there are no errors */ function validates($data = null) { if ($data == null) { $data = $this-data; }else{ //I've added this line. $this-data = $data; //I've added this line. } //I've added this line. $errors = $this-invalidFields($data); return count($errors) == 0; } Should I have to open a ticket or did I use it in the wrong way? Thanks and bye Davide signature.asc Description: OpenPGP digital signature
Some errors with scaffolding
Hello people. I'm trying to scaffold a table like this mysql desc expenses; +--+---+--+-++---+ | Field| Type | Null | Key | Default| Extra | +--+---+--+-++---+ | id | mediumint(8) unsigned | | PRI | NULL | auto_increment | | dt | date | | | 1900-01-01 | | | dx | varchar(250) | YES | | NULL | | | amount | decimal(8,2) | | | 0.00 | | created | datetime | YES | | NULL | | modified | datetime | YES | | NULL | +--+---+--+-++---+ on windows 2000, apache 2.0.55, mysql 4.1.18-nt and cake_1.0.1.2708. When I try to insert a new record, apache goes to crash with a memory could not be read, but this could be another problem. So to bypass this, I tried to add via mysql a record and retrieve it. When I list the table, I get in the action column these errors -- Notice: Undefined property: primaryKey in H:\www\multi-cake\cake\libs\view\templates\scaffolds\list.thtml on line 113 Notice: Undefined index: in H:\www\multi-cake\cake\libs\view\templates\scaffolds\list.thtml on line 113 View Notice: Undefined property: primaryKey in H:\www\multi-cake\cake\libs\view\templates\scaffolds\list.thtml on line 114 Notice: Undefined index: in H:\www\multi-cake\cake\libs\view\templates\scaffolds\list.thtml on line 114 Edit Notice: Undefined property: primaryKey in H:\www\multi-cake\cake\libs\view\templates\scaffolds\list.thtml on line 115 Notice: Undefined index: in H:\www\multi-cake\cake\libs\view\templates\scaffolds\list.thtml on line 115 Delete -- and when I try the view I get an empty data page (only labels and buttons) and a warning on top of page -- Warning: array_search(): Wrong datatype for second argument in H:\www\multi-cake\cake\libs\controller\controller.php on line 702 -- maybe I wrong something with the table. Can someone help me? Thanks a lot. Davide signature.asc Description: OpenPGP digital signature
News rss
I was searching for a feed service about the news on cake[1]. Thanks and bye Davide 1. http://cakeforge.org/news/?group_id=23 signature.asc Description: OpenPGP digital signature