Bonjour


J'ai un problème à la création de mon éditeur programmaticalement. Mon javascript s’exécute correctement sauf sur la fin dans le dojo.ready. Bref, je n'ai pas d'éditeur qui apparaît.


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
function edit(){
// fonction de sauvegarde perso
    dojo.declare("mySavePlugin",
    				[dojox.editor.plugins.Save],
    				{
            			save: function(content)
            			{
	        	            // on défini le div dans lequel s'affiche le contenu
            				// il est défini plus bas.
	        				//var contentNode = dojo.byId("courseContent");
 
    						// on cré une fenetre
    						var dialog = new dijit.Dialog
    						(
    						  {
    						      title: "Sauvegarde",
    						      content: "<div id='dialognode'><div>",
    						      style: "width: 300px",
    						      id: "dialog",
    						      class: "tundra"
    						  }
    						);
 
    						dojo.body().appendChild(dialog.domNode);
 
    						//showing the course form
    						dialog.domNode.appendChild(courseForm);
    						//changing hidden fields
    						dojo.ready(function(){
        						dojo.byId('course_content').value = content;
        						dojo.byId('course_category_id').value = 1;
        						//dojo.byId('course_id').value = 2;
    						});
 
 
    						dialog.startup();
    					    //alert(dialog.content);
    					    dialog.show();
 
    						//dialog.hide();
			                //postwith("edit", content);
 
			                this.inherited(arguments);
			            }
    				}
    			);
 
    //application de la sauvegarde perso
    dojo.subscribe(dijit._scopeName + ".Editor.getPlugin",
    				null,
    				function(o)
    				{
    					if (o.plugin)
    					{
    						return;
    					}
    					var name = o.args.name.toLowerCase();
 
    					if (name === "mysave")
    					{
    						o.plugin = new mySavePlugin(
    						{
    							url: ("url" in o.args) ? o.args.url : "",
    							logResults: ("logResults" in o.args) ? o.args.logResults : true
    						});
    					}
    				}
    			);
 
    //Now we can parse the page since we defined our save plugin above.
    dojo.parser.parse();
 
    //hidding the form
	var contentNode = document.getElementById("content");
	var courseForm = document.getElementById("course_form");
	contentNode.removeChild(courseForm);
 
 
    //creation du textarea
//	var textarea = document.createElement("div");
//    contentNode.appendChild(textarea);
	//var dojoEditor = document.getElementById("dojoEditor");
 
 
  	//creation et parametrage de l'editeur
	dojo.ready(  
		      function() {    
		    		var textarea = document.createElement("div");
		    	    contentNode.appendChild(textarea);
 
		    	  var myEditor = new dijit.Editor(
		    				  {
		    					  id: "textarea",
		    					  class: "tundra",
		    					  height: '500px',
		    					  width: '300px',
		    					  plugins: ['undo','redo','|',
		    					            'cut','copy','paste','selectAll','|',
		    					            'bold','italic','underline','strikethrough','subscript','superscript','|',
		    					            'indent', 'outdent', 'justifyLeft', 'justifyCenter', 'justifyRight','justifyFull','|',
		    					            'delete','removeFormat','||'],
		    					  extraPlugins: ['toggleDir','|',
		    					                 'createLink','unlink','insertImage',{name: 'uploadImage'},'|',
		    					                 {name: 'fontName', plainText: true}, {name: 'fontSize', plainText: true}, {name: 'formatBlock', plainText: true},'|',								                 
//		    							                 'foreColor', 'hiliteColor','|',
		    					                 {name: 'fullscreen', zIndex: 900},'|',
		    					                 'viewSource','|',
		    					                 'print','|',
		    					                 {name: 'newpage', content: 'This is some <b>custom</b> content!'},'|',
//		    							                 {name: 'prettyprint', indentBy: 3, lineLength: 80, entityMap: [['<', 'lt'],['>', 'gt']], dojox.html.entities.html.concat(dojox.html.entities.latin, xhtml: true {name: 'prettyprint'},'|',
		    					                 'preview','|',
		    					                 {name: 'mySave', url: '/course/edit'},'|',
		    					                 {name: 'normalizeindentoutdent', indentBy: 3, indentUnits: "em"},'|',
		    					                 'insertEntity','|',
		    					                 'breadcrumb','|']
		    				  }
		    				  , textarea
		    			   );
		      }    
		   ); 
 
 
}
NB : j'utilise le ZF (php) et avant une modification minime du contrôler, j'avais effectivement un éditeur qui s'affichait mais je n'arrive pas à le réafficher. Voilà le code du contrôler =>

Code php : 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
public function editAction(){
    	$this->view->actionName ="edit";
    	$form = new Default_Form_Course();
    	//if the course is posted
    	if ($this->getRequest()->isPost()){
        	if ($form->isValid($_POST)) {
        		$courses = new Default_Model_DbTable_Course();
			$row = $courses->createRow();
        		//required :
        		//$row->course_id = $form->getSubForm('course_subform')->getValue('course_id');
        		//retrieving new course id
        		if ($form->getSubForm('course_subform')->getValue('course_id') == 0){
       				$sql = 'SELECT max(course_id) FROM course';  
				$query = $courses->getAdapter()->query($sql);
				$result = $query->fetchAll();
				$row->course_id = $result[0]['max(course_id)'] + 1;
        		}
        		$row->category_id = $form->getSubForm('course_subform')->getValue('course_category_id');
        		//$row->course_revision = $form->getSubForm('course_subform')->getValue('course_revision');
        		$row->course_revision = 1;
        		$row->course_date = $form->getSubForm('course_subform')->getValue('course_date');
        		//$row->course_type = $form->getSubForm('course_subform')->getValue('course_type');
        		$row->course_type = 'default';
        		//retrieving user_id
        		$auth 	 = Zend_Auth::getInstance();
        		$user_id = $auth->getStorage()->read()->user_id;
        		$row->user_id = $user_id;
        		//others fields
        		$row->course_name = $form->getSubForm('course_subform')->getValue('course_name');
        		$row->course_about = $form->getSubForm('course_subform')->getValue('course_about');
        		$row->course_update_type = $form->getSubForm('course_subform')->getValue('course_update_type');
        		$row->course_update_comment = $form->getSubForm('course_subform')->getValue('course_update_comment');
        		$row->course_content = $form->getSubForm('course_subform')->getValue('course_content');
        		$row->save();
        		$this->_redirect('/course/index/');
        	} 
        	else {
//                	Zend_Debug::dump($_POST);
//                	exit();
        		$form->populate($_POST);
        	}
        }
        $this->view->courseForm = $form;
        // dojo editor specific css
    	$this->view->headLink()->appendStylesheet($this->view->baseUrl() . '/dojox/editor/plugins/resources/css/Save.css');
    	$this->view->headLink()->appendStylesheet($this->view->baseUrl() . '/dojox/editor/plugins/resources/css/Preview.css');	 
    	$this->view->headLink()->appendStylesheet($this->view->baseUrl() . '/dojox/editor/plugins/resources/css/FindReplace.css');
    	$this->view->headLink()->appendStylesheet($this->view->baseUrl() . '/dojox/editor/plugins/resources/css/InsertEntity.css');  	 
    	$this->view->headLink()->appendStylesheet($this->view->baseUrl() . '/dojox/editor/plugins/resources/css/Breadcrumb.css');
         //dojo module to include
         $this->view->dojo()->requireModule("dijit.form.DateTextBox")
         	->requireModule("dojo.parser")
         	->requireModule("dijit.Editor")
		->requireModule("dijit._editor.plugins.ToggleDir")
         	->requireModule("dijit._editor.plugins.FontChoice")
         	->requireModule("dijit._editor.plugins.LinkDialog")
         	->requireModule("dijit._editor.plugins.AlwaysShowToolbar")
//         	->requireModule("dijit.editor._plugins.TextColor")
		->requireModule("dijit._editor.plugins.FullScreen")
		->requireModule("dijit._editor.plugins.ViewSource")
		->requireModule("dijit._editor.plugins.Print")
		->requireModule("dijit._editor.plugins.NewPage")
//		->requireModule("dojox.editor.plugins.PrettyPrint")
		->requireModule("dojox.editor.plugins.Preview")
		->requireModule("dojox.editor.plugins.Save")
		->requireModule("dojox.editor.plugins.ToolbarLineBreak")
		->requireModule("dojox.editor.plugins.FindReplace")
		->requireModule("dojox.editor.plugins.InsertEntity")
		->requireModule("dojox.editor.plugins.NormalizeIndentOutdent")
		->requireModule("dojox.editor.plugins.Breadcrumb")
		->requireModule("dojox.editor.plugins.UploadImage")
		->requireModule("dijit.Dialog")
         	->requireModule("dojo.NodeList-fx")
         //custom code
		->addLayer($this->view->baseUrl() . '/js/edit.js')
		//javascript run at initialisation
		->addJavascript('dojo.addOnLoad(function(){edit();});');
    }

Merci à ceux qui voudront bien m'aider.