slt,
je fais un plugin sur les chemin upload et j'ai un PB
voici ma classdans mon fichier from
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137 class Nico { /** * Retou * * @return <type> */ public $image ; public $chemin ; public function __construct($chemin,$image) { $this->chemin= $chemin; $this->image = $image; } public function getUploadFileSrc() { if (!$image) { return null; } return $this->getUploadDirSrc().'/'.$image; } public function getUploadFileSrc2() { if (!$image) { return null; } return $this->getUploadDirSrc2().'/'.$image; } /** * Retourne le chemin relatif de la photo miniature */ public function getUploadFileSrcMini() { if (!$image) { return null; } return $this->getUploadDirSrc().'/mini_Upload/'.$image; } /** * Retourne le chemin absolu de la photo */ public function getUploadFilePath() { if (!$image) { return null; } return $this->getUploadDirPath().'/'.$image; } /** * Retourne le chemin absolu de la photo miniature */ public function getUploadFileMini() { if (!$image) { return null; } return $this->getUploadDirMini().'/'.$image; } /** * Retourne le chemin du dossier relatif */ public function getUploadDirSrc() { return '/uploads/'.$chemin; } public function getUploadDirSrc2() { return $chemin; } /** * Retourne le chemin du dossier absolu */ public function getUploadDirPath() { return sfConfig::get('sf_upload_dir').$chemin; } /** * Retourne le chemin du dossier miniature absolu */ public function getUploadDirMini() { return $this->getUploadDirPath().'/mini_Upload'; } /** * Effectué avant la sauvegarde */ public function preSave($event) { // $event->getInvoker permet de récupérer le dernier enregistrement (Doctrine_Record) // getModified(true) permet de récupérer les anciennes valeurs $modified = $event->getInvoker()->getModified( true ); // On regarde si le champ photo a été modifié if (isset($modified[$image])) { $old_path = $this->getUploadDirPath() . '/' . $modified[$image]; $old_mini = $this->getUploadDirMini().'/'. $modified[$image]; // Si le fichier existe, on le supprime if (file_exists($old_path)) { @unlink($old_path); } // Idem pour la miniature if (file_exists($old_mini)) { @unlink($old_mini); } } } public function postDelete($event) { // On supprime la photo si le fichier existe et la miniature if (file_exists($event->getInvoker()->getUploadFilePath())) { @unlink($event->getInvoker()->getUploadFilePath()); @unlink($event->getInvoker()->getUploadFileMini()); } } }
il me donne comme error ->
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 class CquesnelCollectionForm extends BaseCquesnelCollectionForm { public function configure() { $this->object = new Nico('essai', $this->getImg()); $this->setWidget('img', new sfWidgetFormInputFileEditable(array( 'label' => 'Photo', 'file_src' => $this->getObject()->getUploadFileSrcMini(), 'edit_mode' => !$this->isNew(), 'is_image' => $this->getObject()->getUploadFileSrc(), 'delete_label' => 'Supprimer', 'template' => '<div>%file%<br />%input%<br />%delete% %delete_label%</div>', )));}}la je cherche mais je vois pas.Error sfException Call to undefined method CquesnelCollectionForm::getImg.
merci de votre aide
Partager