Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //////////////////////////////////////////////////////////////////////////cps_controller.php
- function edit_sites ($id) {
- if (!empty($id)){
- $this->Site->id = $id;
- if (empty($this->data)) {
- $this->data = $this->Site->read();
- $this->data['cps'] = $this->data['Site'];
- } else {
- $this->data = array('Site' => $this->data['cp']);
- $this->data['Site']['update'] = time ();
- $user = $this->Session->read('User');
- $this->data['Site']['user_id'] = $user['User']['id'];
- if ($this->Site->save($this->data)) {
- $this->Session->setFlash('Die Seite wurde gespeichert.');
- $this->redirect(array('controller' => 'cps', 'action' => 'index'));
- }
- }
- } else {
- $this->Session->setFlash('Es wurde eine ungültige ID übergeben.');
- $this->redirect(array('controller' => 'cps', 'action' => 'index'));
- }
- }
- ////////////////////////////////////////////////////////////////////////////edit_site.ctp
- <?php
- print $this->Form->create('cps');
- print $this->Form->input('titel');
- print $cksource->ckeditor('text',array('escape' => 'false'));
- print $this->Form->submit('Speichern');
- ?>
- ///////////////////////////////////////////cksource.php
- <?php
- class CksourceHelper extends FormHelper {
- var $helpers = array('Html');
- function ckeditor($fieldName, $options = array()) {
- //CakePHP 1.2.4.8284
- $options = $this->_initInputField($fieldName, $options);
- //If you have probelms, try adding a second underscore to _initInputField. I haven't tested this, but some commenters say it works.
- //$options = $this->__initInputField($fieldName, $options);
- $value = null;
- $config = null;
- $events = null;
- if (array_key_exists('value', $options)) {
- $value = $options['value'];
- if (!array_key_exists('escape', $options) || $options['escape'] !== false) {
- $value = h($value);
- }
- unset($options['value']);
- }
- if (array_key_exists('config', $options)) {
- $config = $options['config'];
- unset($options['config']);
- }
- if (array_key_exists('events', $options)) {
- $events = $options['events'];
- unset($options['events']);
- }
- require_once WWW_ROOT.DS.'js'.DS.'ckeditor'.DS.'ckeditor.php';
- $CKEditor = new CKEditor();
- $CKEditor->basePath = $this->webroot.'js/ckeditor/';
- return $CKEditor->editor($options['name'], $value, $config, $events);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement