Software engineer, technical program manager, tech lead, privacy domain expert, nerd.
alkemann / cakephp-assets Goto Github PK
View Code? Open in Web Editor NEWA home for the cakephp assets managed the development of.
A home for the cakephp assets managed the development of.
I originally asked this on Stack Overflow, but it's gotten no responses.
http://stackoverflow.com/questions/8362015/cakephp-ordered-behavior-with-multiple-foreign-keys
My Item model has foreign keys section_id and category_id. An Item can be a child of either a Section xor a Category. Whichever the Item is not a child of has a foreign_key value of 0. Is there any way the ordered behavior can accomodate this model and allow me to reorder Items under whichever parent the Items are attached?
It seems that by default cake does not load behaviors for related models, which makes creating versioning of a related model that is not HABTM difficult.
It seems that following some of the HABTM logic, one could do the same loop to serialize the hasMany arrays and save them in the shadow table.
1 field per relationship and the behavior could be updated to expect those.
Is this valid, or non-relevant, as there is a better way of doing it? I'll be more than happy to fork the file and prompt for a pull request with my changes.
If you edit an object and change the foreign key which is being used in the Ordered behavior, bad things can happen.
Even if you don't fix it, I think it's important to mention that your behavior does not handle situations where the foreign key might be changed.
OS: Debian Lenny
Apache: apache2-mpm-prefork 2.2.9-10+lenny6
PHP: 5.2.6.dfsg.1-1+lenny3
Logable: 2.2
CakePHP: 1.2.5
When I set up my AppModel and AppController (see http://bin.cakephp.org/saved/53146) to use Logable and attempt to save a model, I get a segfault in Apache.
Looking at a stack trace in xdebug, I see this pattern repeated:
Model->save( ) ../products_controller.php:70
BehaviorCollection->trigger( ) ../model.php:1274
ModelBehavior->dispatchMethod( ) ../behavior.php:456
LogableBehavior->afterSave( ) ../behavior.php:162
LogableBehavior->_saveLog( ) ../logable.php:428
It would be appreciated if you stick to CakePHP's naming conventions. The current fields id
and version_id
have to be reconsidered.
id
sould be: primary key, a simple "counter" -> auto increment
new field: MODEL_id
is the relation to MODEL since the Revision model $belongsTo MODEL.
Mainly for beginners it would be much easier because they learn to use anothermodel_id
to link to anothermodel with belongsTo/hasMany
Hi all,
Great helper but i'm experiencing problem when trying to render a chart in IE8...
No problems on other Web Navigators (Safari, Opera, Firefox, Google Chrome).
I've got 4 charts to display.
In my ses_controller.php i generate datas :
set('ctrl_conf', $this->Se->getCountCtrl('ctrlconf', $annee_en_cours, $mois));
$this->set('ctrl_elec', $this->Se->getCountCtrl('ctrlelec', $annee_en_cours, $mois));
$this->set('ctrl_fonc', $this->Se->getCountCtrl('ctrlfonc', $annee_en_cours, $mois));
$this->set('ctrl_final', $this->Se->getCountCtrl('ctrlfinal', $annee_en_cours, $mois));
$this->set('ctrl_conf_precedente', $this->Se->getCountCtrl('ctrlconf', $annee_precedente, $mois));
$this->set('ctrl_elec_precedente', $this->Se->getCountCtrl('ctrlelec', $annee_precedente, $mois));
$this->set('ctrl_fonc_precedente', $this->Se->getCountCtrl('ctrlfonc', $annee_precedente, $mois));
$this->set('ctrl_final_precedente', $this->Se->getCountCtrl('ctrlfinal', $annee_precedente, $mois));
$this->set('ctrl_conf_se', $this->Se->getDetailCtrl('ctrlconf', $annee_en_cours, $mois));
$this->set('ctrl_elec_se', $this->Se->getDetailCtrl('ctrlelec', $annee_en_cours, $mois));
$this->set('ctrl_fonc_se', $this->Se->getDetailCtrl('ctrlfonc', $annee_en_cours, $mois));
$this->set('ctrl_final_se', $this->Se->getDetailCtrl('ctrlfinal', $annee_en_cours, $mois));
$this->set('annee_en_cours', $annee_en_cours);
$this->set('annee_precedente', $annee_precedente);
?>
In my main view :
Contr么les Configurations
begin(array('prototype'=>true));
// Construction des labels en x
$months[0] = "Jan";
$months[1] = "Fev";
$months[2] = "Mar";
$months[3] = "Avr";
$months[4] = "Mai";
$months[5] = "Jui";
$months[6] = "Jui";
$months[7] = "Aou";
$months[8] = "Sep";
$months[9] = "Oct";
$months[10] = "Nov";
$months[11] = "Dec";
for($i=0; $i
element('ses/stats_ctrl', array(
'graphDivId' => 'ctrlConf',
'detailDivId' => 'detail_ctrl_conf',
'data_x' => $data_x,
'ctrl_annee_en_cours' => $ctrl_conf,
'ctrl_annee_precedente' => $ctrl_conf_precedente,
'ctrl_detail' => $ctrl_conf_se
));
?>
Contr么les Electriques
element('ses/stats_ctrl', array(
'graphDivId' => 'ctrlElec',
'detailDivId' => 'detail_ctrl_elec',
'data_x' => $data_x,
'ctrl_annee_en_cours' => $ctrl_elec,
'ctrl_annee_precedente' => $ctrl_elec_precedente,
'ctrl_detail' => $ctrl_elec_se
));
?>
Contr么les Fonctionnels
element('ses/stats_ctrl', array(
'graphDivId' => 'ctrlFonc',
'detailDivId' => 'detail_ctrl_fonc',
'data_x' => $data_x,
'ctrl_annee_en_cours' => $ctrl_fonc,
'ctrl_annee_precedente' => $ctrl_fonc_precedente,
'ctrl_detail' => $ctrl_fonc_se
));
?>
Contr么les Finaux
element('ses/stats_ctrl', array(
'graphDivId' => 'ctrlFinal',
'detailDivId' => 'detail_ctrl_final',
'data_x' => $data_x,
'ctrl_annee_en_cours' => $ctrl_final,
'ctrl_annee_precedente' => $ctrl_final_precedente,
'ctrl_detail' => $ctrl_final_se
));
?>
?>
in my stats_ctrl element :
" align="center">
setData($ctrl_annee_en_cours, '{n}', false, 'stuff'.$graphDivId, 'data'.$graphDivId);
$flashChart->axis('y',array('range' => array(0, max($ctrl_annee_en_cours)+1, 1)));
$flashChart->axis('x',array('labels' => $data_x), array('vertical' => false ));
echo $flashChart->chart('bar_glass', array(), 'stuff'.$graphDivId, 'data'.$graphDivId);
echo $flashChart->render(425, 200, 'data'.$graphDivId, $graphDivId);
?>
?>
It renders perfectly in Chrome, Safari or other but not in IE7 or 8 !!
AnyOne has got an idea ?
Hi , Have used this tool in our project which is using cake php V 2.9.1.Now we are upgrading the project to cake php V 3.5.5. Is this plugin available for cake php 3.x version?
Hi,
FlashChartHelper is a nice work, but I have problem with json I guess.
In swf embed I've got:
Open Flash Chart
JSON Parse Error [Syntax Error]
Error at character 0, line 1:
0:
I read a lot about that error in the Internet, but I haven't found nothing could help.
I hoped that in your git repo will find working version, unfortunately same error.
Did someone who had this error find some solution?
In view I have examples from your docs:
echo $flashChart->begin();
$flashChart->setData(array(1,2,4,8));
echo $flashChart->chart();
echo $flashChart->render();
I've tried begin with prototype etc.
I'm using cakephp 1.3
There is a small issue in the logable behaviour which causes SQL warning;
Line 343 should read:
$this->old = $Model->find('first',array('conditions'=>array($Model->alias.'.'.$Model->primaryKey => $Model->id),'recursive'=>-1));
basically the $Model->alias.'.' was added before $Model->primaryKey which was the root cause of a SQL issue.
Hi there,
I am using your Revision behavior and love it but just ran into an issue with SQL errors concerning a 'del' statement.
Someone pointed out that this is caused by an outdated del() statement in line 878. Replacing it with delete() as shown below fixes the problem:
$Model->ShadowModel->delete($oldest[$Model->alias][$Model->ShadowModel->primaryKey]);
HTH,
Bravo
When the behavior to AppModel, this applies to Log model itslef causing an infinite loop by the afterSave()
change line: http://github.com/alkemann/CakePHP-Assets/blob/master/models/behaviors/logable.php#L503
to:
$this->Log->save(null, array('validate'=>false, 'callbacks' => false));
A declarative, efficient, and flexible JavaScript library for building user interfaces.
馃枛 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 馃搳馃搱馃帀
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google 鉂わ笍 Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.