Changeset 595
- Timestamp:
- 09/28/07 15:38:45 (1 year ago)
- Files:
-
- branches/1.0beta3.x/lib/jelix/controllers/jControllerDaoCrud.class.php (modified) (11 diffs)
- branches/1.0beta3.x/lib/jelix/controllers/jControllerDaoCrud.class.php (modified) (11 diffs)
- trunk/lib/jelix/controllers/jControllerDaoCrud.class.php (modified) (11 diffs)
- trunk/lib/jelix/controllers/jControllerDaoCrud.class.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.0beta3.x/lib/jelix/controllers/jControllerDaoCrud.class.php
r594 r595 113 113 114 114 /** 115 * you can do your own datas check of a form. Called only if the $form->check() is ok. 115 * you can do your own datas check of a form by overloading this method. 116 * You can also do some other things. It is called only if the $form->check() is ok. 117 * and before the save of the datas. 116 118 * @param jFormsBase $form the current form 119 * @param boolean $calltype true for an update, false for a create 117 120 * @return boolean true if it is ok. 118 121 */ 119 protected function _checkDatas($form ){122 protected function _checkDatas($form, $calltype){ 120 123 return true; 121 124 } … … 152 155 $tpl->assign('recordCount',$dao->countAll()); 153 156 $tpl->assign('offsetParameterName',$this->offsetParameterName); 157 158 $this->_index($rep, $tpl); 159 154 160 $rep->body->assign($this->templateAssign, $tpl->fetch($this->listTemplate)); 155 161 156 162 return $rep; 163 } 164 165 /** 166 * overload this method if you wan to do additionnal things on the response and on the list template 167 * during the index action. 168 * @param jHtmlResponse $resp the response 169 * @param jtpl $tpl the template to display the record list 170 */ 171 protected function _index($resp, $tpl) { 172 157 173 } 158 174 … … 172 188 $tpl->assign('submitAction', $this->_getAction('savecreate')); 173 189 $tpl->assign('listAction' , $this->_getAction('index')); 190 $this->_create($rep, $tpl); 174 191 $rep->body->assign($this->templateAssign, $tpl->fetch($this->editTemplate)); 175 192 return $rep; 193 194 } 195 196 /** 197 * overload this method if you wan to do additionnal things on the response and on the edit template 198 * during the create action. 199 * @param jHtmlResponse $resp the response 200 * @param jtpl $tpl the template to display the edit form 201 */ 202 protected function _create($resp, $tpl) { 176 203 177 204 } … … 188 215 } 189 216 190 if($form->check() && $this->_checkDatas($form )){217 if($form->check() && $this->_checkDatas($form, false)){ 191 218 $id = $form->saveToDao($this->dao, null, $this->dbProfil); 192 219 $form->saveAllFiles($this->uploadsDirectory); 193 220 $rep->action = $this->_getAction('view'); 221 $this->_afterCreate($form, $id); 194 222 jForms::destroy($this->form); 195 223 $rep->params['id'] = $id; … … 200 228 } 201 229 } 230 231 /** 232 * overload this method if you wan to do additionnal things after the creation of 233 * a record 234 * @param jFormsBase $form the form object 235 * @param mixed $id the new id of the inserted record 236 */ 237 protected function _afterCreate($form, $id) { 238 239 } 240 202 241 203 242 /** … … 248 287 $tpl->assign('listAction' , $this->_getAction('index')); 249 288 $tpl->assign('viewAction' , $this->_getAction('view')); 289 $this->_editUpdate($rep, $tpl); 250 290 $rep->body->assign($this->templateAssign, $tpl->fetch($this->editTemplate)); 251 291 return $rep; 292 } 293 294 /** 295 * overload this method if you wan to do additionnal things on the response and on the edit template 296 * during the editupdate action. 297 * @param jHtmlResponse $resp the response 298 * @param jtpl $tpl the template to display the edit form 299 */ 300 protected function _editUpdate($resp, $tpl) { 301 252 302 } 253 303 … … 264 314 } 265 315 266 if($form->check() && $this->_checkDatas($form )){316 if($form->check() && $this->_checkDatas($form, true)){ 267 317 $id = $form->saveToDao($this->dao, null, $this->dbProfil); 268 318 $form->saveAllFiles($this->uploadsDirectory); 319 $this->_afterUpdate($form, $id); 269 320 $rep->action = $this->_getAction('view'); 270 321 jForms::destroy($this->form, $id); … … 274 325 $rep->params['id'] = $id; 275 326 return $rep; 327 } 328 329 /** 330 * overload this method if you wan to do additionnal things after the update of 331 * a record 332 * @param jFormsBase $form the form object 333 * @param mixed $id the new id of the updated record 334 */ 335 protected function _afterUpdate($form, $id) { 336 276 337 } 277 338 … … 299 360 $tpl->assign('deleteAction' , $this->_getAction('delete')); 300 361 $tpl->assign('listAction' , $this->_getAction('index')); 362 $this->_view($rep,$tpl); 301 363 $rep->body->assign($this->templateAssign, $tpl->fetch($this->viewTemplate)); 302 364 return $rep; 365 } 366 367 /** 368 * overload this method if you want to do additionnal things on the response and on the view template 369 * during the view action. 370 * @param jHtmlResponse $resp the response 371 * @param jtpl $tpl the template to display the form content 372 */ 373 protected function _view($resp, $tpl) { 374 303 375 } 304 376 … … 308 380 function delete(){ 309 381 $id = $this->param('id'); 310 if( $id !== null ){382 if( $id !== null && $this->_delete($id) ){ 311 383 $dao = jDao::get($this->dao, $this->dbProfil); 312 384 $dao->delete($id); … … 316 388 return $rep; 317 389 } 390 391 /** 392 * overload this method if you want to do additionnal things before the deletion of a record 393 * @param mixed $id the new id of the record 394 * @return boolean true if the record can be deleted 395 */ 396 protected function _delete($id) { 397 return true; 398 } 399 318 400 } 319 401 branches/1.0beta3.x/lib/jelix/controllers/jControllerDaoCrud.class.php
r594 r595 113 113 114 114 /** 115 * you can do your own datas check of a form. Called only if the $form->check() is ok. 115 * you can do your own datas check of a form by overloading this method. 116 * You can also do some other things. It is called only if the $form->check() is ok. 117 * and before the save of the datas. 116 118 * @param jFormsBase $form the current form 119 * @param boolean $calltype true for an update, false for a create 117 120 * @return boolean true if it is ok. 118 121 */ 119 protected function _checkDatas($form ){122 protected function _checkDatas($form, $calltype){ 120 123 return true; 121 124 } … … 152 155 $tpl->assign('recordCount',$dao->countAll()); 153 156 $tpl->assign('offsetParameterName',$this->offsetParameterName); 157 158 $this->_index($rep, $tpl); 159 154 160 $rep->body->assign($this->templateAssign, $tpl->fetch($this->listTemplate)); 155 161 156 162 return $rep; 163 } 164 165 /** 166 * overload this method if you wan to do additionnal things on the response and on the list template 167 * during the index action. 168 * @param jHtmlResponse $resp the response 169 * @param jtpl $tpl the template to display the record list 170 */ 171 protected function _index($resp, $tpl) { 172 157 173 } 158 174 … … 172 188 $tpl->assign('submitAction', $this->_getAction('savecreate')); 173 189 $tpl->assign('listAction' , $this->_getAction('index')); 190 $this->_create($rep, $tpl); 174 191 $rep->body->assign($this->templateAssign, $tpl->fetch($this->editTemplate)); 175 192 return $rep; 193 194 } 195 196 /** 197 * overload this method if you wan to do additionnal things on the response and on the edit template 198 * during the create action. 199 * @param jHtmlResponse $resp the response 200 * @param jtpl $tpl the template to display the edit form 201 */ 202 protected function _create($resp, $tpl) { 176 203 177 204 } … … 188 215 } 189 216 190 if($form->check() && $this->_checkDatas($form )){217 if($form->check() && $this->_checkDatas($form, false)){ 191 218 $id = $form->saveToDao($this->dao, null, $this->dbProfil); 192 219 $form->saveAllFiles($this->uploadsDirectory); 193 220 $rep->action = $this->_getAction('view'); 221 $this->_afterCreate($form, $id); 194 222 jForms::destroy($this->form); 195 223 $rep->params['id'] = $id; … … 200 228 } 201 229 } 230 231 /** 232 * overload this method if you wan to do additionnal things after the creation of 233 * a record 234 * @param jFormsBase $form the form object 235 * @param mixed $id the new id of the inserted record 236 */ 237 protected function _afterCreate($form, $id) { 238 239 } 240 202 241 203 242 /** … … 248 287 $tpl->assign('listAction' , $this->_getAction('index')); 249 288 $tpl->assign('viewAction' , $this->_getAction('view')); 289 $this->_editUpdate($rep, $tpl); 250 290 $rep->body->assign($this->templateAssign, $tpl->fetch($this->editTemplate)); 251 291 return $rep; 292 } 293 294 /** 295 * overload this method if you wan to do additionnal things on the response and on the edit template 296 * during the editupdate action. 297 * @param jHtmlResponse $resp the response 298 * @param jtpl $tpl the template to display the edit form 299 */ 300 protected function _editUpdate($resp, $tpl) { 301 252 302 } 253 303 … … 264 314 } 265 315 266 if($form->check() && $this->_checkDatas($form )){316 if($form->check() && $this->_checkDatas($form, true)){ 267 317 $id = $form->saveToDao($this->dao, null, $this->dbProfil); 268 318 $form->saveAllFiles($this->uploadsDirectory); 319 $this->_afterUpdate($form, $id); 269 320 $rep->action = $this->_getAction('view'); 270 321 jForms::destroy($this->form, $id); … … 274 325 $rep->params['id'] = $id; 275 326 return $rep; 327 } 328 329 /** 330 * overload this method if you wan to do additionnal things after the update of 331 * a record 332 * @param jFormsBase $form the form object 333 * @param mixed $id the new id of the updated record 334 */ 335 protected function _afterUpdate($form, $id) { 336 276 337 } 277 338 … … 299 360 $tpl->assign('deleteAction' , $this->_getAction('delete')); 300 361 $tpl->assign('listAction' , $this->_getAction('index')); 362 $this->_view($rep,$tpl); 301 363 $rep->body->assign($this->templateAssign, $tpl->fetch($this->viewTemplate)); 302 364 return $rep; 365 } 366 367 /** 368 * overload this method if you want to do additionnal things on the response and on the view template 369 * during the view action. 370 * @param jHtmlResponse $resp the response 371 * @param jtpl $tpl the template to display the form content 372 */ 373 protected function _view($resp, $tpl) { 374 303 375 } 304 376 … … 308 380 function delete(){ 309 381 $id = $this->param('id'); 310 if( $id !== null ){382 if( $id !== null && $this->_delete($id) ){ 311 383 $dao = jDao::get($this->dao, $this->dbProfil); 312 384 $dao->delete($id); … … 316 388 return $rep; 317 389 } 390 391 /** 392 * overload this method if you want to do additionnal things before the deletion of a record 393 * @param mixed $id the new id of the record 394 * @return boolean true if the record can be deleted 395 */ 396 protected function _delete($id) { 397 return true; 398 } 399 318 400 } 319 401 trunk/lib/jelix/controllers/jControllerDaoCrud.class.php
r594 r595 113 113 114 114 /** 115 * you can do your own datas check of a form. Called only if the $form->check() is ok. 115 * you can do your own datas check of a form by overloading this method. 116 * You can also do some other things. It is called only if the $form->check() is ok. 117 * and before the save of the datas. 116 118 * @param jFormsBase $form the current form 119 * @param boolean $calltype true for an update, false for a create 117 120 * @return boolean true if it is ok. 118 121 */ 119 protected function _checkDatas($form ){122 protected function _checkDatas($form, $calltype){ 120 123 return true; 121 124 } … … 152 155 $tpl->assign('recordCount',$dao->countAll()); 153 156 $tpl->assign('offsetParameterName',$this->offsetParameterName); 157 158 $this->_index($rep, $tpl); 159 154 160 $rep->body->assign($this->templateAssign, $tpl->fetch($this->listTemplate)); 155 161 156 162 return $rep; 163 } 164 165 /** 166 * overload this method if you wan to do additionnal things on the response and on the list template 167 * during the index action. 168 * @param jHtmlResponse $resp the response 169 * @param jtpl $tpl the template to display the record list 170 */ 171 protected function _index($resp, $tpl) { 172 157 173 } 158 174 … … 172 188 $tpl->assign('submitAction', $this->_getAction('savecreate')); 173 189 $tpl->assign('listAction' , $this->_getAction('index')); 190 $this->_create($rep, $tpl); 174 191 $rep->body->assign($this->templateAssign, $tpl->fetch($this->editTemplate)); 175 192 return $rep; 193 194 } 195 196 /** 197 * overload this method if you wan to do additionnal things on the response and on the edit template 198 * during the create action. 199 * @param jHtmlResponse $resp the response 200 * @param jtpl $tpl the template to display the edit form 201 */ 202 protected function _create($resp, $tpl) { 176 203 177 204 } … … 188 215 } 189 216 190 if($form->check() && $this->_checkDatas($form )){217 if($form->check() && $this->_checkDatas($form, false)){ 191 218 $id = $form->saveToDao($this->dao, null, $this->dbProfil); 192 219 $form->saveAllFiles($this->uploadsDirectory); 193 220 $rep->action = $this->_getAction('view'); 221 $this->_afterCreate($form, $id); 194 222 jForms::destroy($this->form); 195 223 $rep->params['id'] = $id; … … 200 228 } 201 229 } 230 231 /** 232 * overload this method if you wan to do additionnal things after the creation of 233 * a record 234 * @param jFormsBase $form the form object 235 * @param mixed $id the new id of the inserted record 236 */ 237 protected function _afterCreate($form, $id) { 238 239 } 240 202 241 203 242 /** … … 248 287 $tpl->assign('listAction' , $this->_getAction('index')); 249 288 $tpl->assign('viewAction' , $this->_getAction('view')); 289 $this->_editUpdate($rep, $tpl); 250 290 $rep->body->assign($this->templateAssign, $tpl->fetch($this->editTemplate)); 251 291 return $rep; 292 } 293 294 /** 295 * overload this method if you wan to do additionnal things on the response and on the edit template 296 * during the editupdate action. 297 * @param jHtmlResponse $resp the response 298 * @param jtpl $tpl the template to display the edit form 299 */ 300 protected function _editUpdate($resp, $tpl) { 301 252 302 } 253 303 … … 264 314 } 265 315 266 if($form->check() && $this->_checkDatas($form )){316 if($form->check() && $this->_checkDatas($form, true)){ 267 317 $id = $form->saveToDao($this->dao, null, $this->dbProfil); 268 318 $form->saveAllFiles($this->uploadsDirectory); 319 $this->_afterUpdate($form, $id); 269 320 $rep->action = $this->_getAction('view'); 270 321 jForms::destroy($this->form, $id); … … 274 325 $rep->params['id'] = $id; 275 326 return $rep; 327 } 328 329 /** 330 * overload this method if you wan to do additionnal things after the update of 331 * a record 332 * @param jFormsBase $form the form object 333 * @param mixed $id the new id of the updated record 334 */ 335 protected function _afterUpdate($form, $id) { 336 276 337 } 277 338 … … 299 360 $tpl->assign('deleteAction' , $this->_getAction('delete')); 300 361 $tpl->assign('listAction' , $this->_getAction('index')); 362 $this->_view($rep,$tpl); 301 363 $rep->body->assign($this->templateAssign, $tpl->fetch($this->viewTemplate)); 302 364 return $rep; 365 } 366 367 /** 368 * overload this method if you want to do additionnal things on the response and on the view template 369 * during the view action. 370 * @param jHtmlResponse $resp the response 371 * @param jtpl $tpl the template to display the form content 372 */ 373 protected function _view($resp, $tpl) { 374 303 375 } 304 376 … … 308 380 function delete(){ 309 381 $id = $this->param('id'); 310 if( $id !== null ){382 if( $id !== null && $this->_delete($id) ){ 311 383 $dao = jDao::get($this->dao, $this->dbProfil); 312 384 $dao->delete($id); … … 316 388 return $rep; 317 389 } 390 391 /** 392 * overload this method if you want to do additionnal things before the deletion of a record 393 * @param mixed $id the new id of the record 394 * @return boolean true if the record can be deleted 395 */ 396 protected function _delete($id) { 397 return true; 398 } 399 318 400 } 319 401 trunk/lib/jelix/controllers/jControllerDaoCrud.class.php
r594 r595 113 113 114 114 /** 115 * you can do your own datas check of a form. Called only if the $form->check() is ok. 115 * you can do your own datas check of a form by overloading this method. 116 * You can also do some other things. It is called only if the $form->check() is ok. 117 * and before the save of the datas. 116 118 * @param jFormsBase $form the current form 119 * @param boolean $calltype true for an update, false for a create 117 120 * @return boolean true if it is ok. 118 121 */ 119 protected function _checkDatas($form ){122 protected function _checkDatas($form, $calltype){ 120 123 return true; 121 124 } … … 152 155 $tpl->assign('recordCount',$dao->countAll()); 153 156 $tpl->assign('offsetParameterName',$this->offsetParameterName); 157 158 $this->_index($rep, $tpl); 159 154 160 $rep->body->assign($this->templateAssign, $tpl->fetch($this->listTemplate)); 155 161 156 162 return $rep; 163 } 164 165 /** 166 * overload this method if you wan to do additionnal things on the response and on the list template 167 * during the index action. 168 * @param jHtmlResponse $resp the response 169 * @param jtpl $tpl the template to display the record list 170 */ 171 protected function _index($resp, $tpl) { 172 157 173 } 158 174 … … 172 188 $tpl->assign('submitAction', $this->_getAction('savecreate')); 173 189 $tpl->assign('listAction' , $this->_getAction('index')); 190 $this->_create($rep, $tpl); 174 191 $rep->body->assign($this->templateAssign, $tpl->fetch($this->editTemplate)); 175 192 return $rep; 193 194 } 195 196 /** 197 * overload this method if you wan to do additionnal things on the response and on the edit template 198 * during the create action. 199 * @param jHtmlResponse $resp the response 200 * @param jtpl $tpl the template to display the edit form 201 */ 202 protected function _create($resp, $tpl) { 176 203 177 204 } … … 188 215 } 189 216 190 if($form->check() && $this->_checkDatas($form )){217 if($form->check() && $this->_checkDatas($form, false)){ 191 218 $id = $form->saveToDao($this->dao, null, $this->dbProfil); 192 219 $form->saveAllFiles($this->uploadsDirectory); 193 220 $rep->action = $this->_getAction('view'); 221 $this->_afterCreate($form, $id); 194 222 jForms::destroy($this->form); 195 223 $rep->params['id'] = $id; … … 200 228 } 201 229 } 230 231 /** 232 * overload this method if you wan to do additionnal things after the creation of 233 * a record 234 * @param jFormsBase $form the form object 235 * @param mixed $id the new id of the inserted record 236 */ 237 protected function _afterCreate($form, $id) { 238 239 } 240 202 241 203 242 /** … … 248 287 $tpl->assign('listAction' , $this->_getAction('index')); 249 288 $tpl->assign('viewAction' , $this->_getAction('view')); 289 $this->_editUpdate($rep, $tpl); 250 290 $rep->body->assign($this->templateAssign, $tpl->fetch($this->editTemplate)); 251 291 return $rep; 292 } 293 294 /** 295 * overload this method if you wan to do additionnal things on the response and on the edit template 296 * during the editupdate action. 297 * @param jHtmlResponse $resp the response 298 * @param jtpl $tpl the template to display the edit form 299 */ 300 protected function _editUpdate($resp, $tpl) { 301 252 302 } 253 303 … … 264 314 } 265 315 266 if($form->check() && $this->_checkDatas($form )){316 if($form->check() && $this->_checkDatas($form, true)){ 267 317 $id = $form->saveToDao($this->dao, null, $this->dbProfil); 268 318 $form->saveAllFiles($this->uploadsDirectory); 319 $this->_afterUpdate($form, $id); 269 320 $rep->action = $this->_getAction('view'); 270 321 jForms::destroy($this->form, $id); … … 274 325 $rep->params['id'] = $id; 275 326 return $rep; 327 } 328 329 /** 330 * overload this method if you wan to do additionnal things after the update of 331 * a record 332 * @param jFormsBase $form the form object 333 * @param mixed $id the new id of the updated record 334 */ 335 protected function _afterUpdate($form, $id) { 336 276 337 } 277 338 … … 299 360 $tpl->assign('deleteAction' , $this->_getAction('delete')); 300 361 $tpl->assign('listAction' , $this->_getAction('index')); 362 $this->_view($rep,$tpl); 301 363 $rep->body->assign($this->templateAssign, $tpl->fetch($this->viewTemplate)); 302 364 return $rep; 365 } 366 367 /** 368 * overload this method if you want to do additionnal things on the response and on the view template 369 * during the view action. 370 * @param jHtmlResponse $resp the response 371 * @param jtpl $tpl the template to display the form content 372 */ 373 protected function _view($resp, $tpl) { 374 303 375 } 304 376 … … 308 380 function delete(){ 309 381 $id = $this->param('id'); 310 if( $id !== null ){382 if( $id !== null && $this->_delete($id) ){ 311 383 $dao = jDao::get($this->dao, $this->dbProfil); 312 384 $dao->delete($id); … … 316 388 return $rep; 317 389 } 390 391 /** 392 * overload this method if you want to do additionnal things before the deletion of a record 393 * @param mixed $id the new id of the record 394 * @return boolean true if the record can be deleted 395 */ 396 protected function _delete($id) { 397 return true; 398 } 399 318 400 } 319 401
