Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.55 KB | None | 0 0
  1. //////////////////////////////////////////////////////////////////////////cps_controller.php
  2.  
  3. function edit_sites ($id) {
  4.         if (!empty($id)){
  5.             $this->Site->id = $id;
  6.             if (empty($this->data)) {
  7.                 $this->data = $this->Site->read();
  8.                 $this->data['cps'] = $this->data['Site'];
  9.             } else {
  10.                 $this->data = array('Site' => $this->data['cp']);
  11.                 $this->data['Site']['update'] = time ();
  12.                 $user = $this->Session->read('User');
  13.                 $this->data['Site']['user_id'] = $user['User']['id'];
  14.                 if ($this->Site->save($this->data)) {
  15.                     $this->Session->setFlash('Die Seite wurde gespeichert.');
  16.                     $this->redirect(array('controller' => 'cps', 'action' => 'index'));
  17.                 }
  18.             }
  19.         } else {
  20.             $this->Session->setFlash('Es wurde eine ungültige ID übergeben.');
  21.             $this->redirect(array('controller' => 'cps', 'action' => 'index'));
  22.         }
  23.     }
  24.  
  25.  
  26.  
  27.  
  28.  
  29. ////////////////////////////////////////////////////////////////////////////edit_site.ctp
  30.  
  31.  
  32. <?php
  33.  
  34. print $this->Form->create('cps');
  35. print $this->Form->input('titel');
  36. print $cksource->ckeditor('text',array('escape' => 'false'));
  37. print $this->Form->submit('Speichern');
  38.  
  39.  
  40.  
  41. ?>
  42.  
  43.  
  44.  
  45. ///////////////////////////////////////////cksource.php
  46.  
  47. <?php
  48. class CksourceHelper extends FormHelper {
  49.  
  50.     var $helpers = array('Html');
  51.  
  52.     function ckeditor($fieldName, $options = array()) {
  53.         //CakePHP 1.2.4.8284
  54.         $options = $this->_initInputField($fieldName, $options);
  55.         //If you have probelms, try adding a second underscore to _initInputField.  I haven't tested this, but some commenters say it works.
  56.         //$options = $this->__initInputField($fieldName, $options);
  57.         $value = null;
  58.         $config = null;
  59.         $events = null;
  60.  
  61.         if (array_key_exists('value', $options)) {
  62.             $value = $options['value'];
  63.             if (!array_key_exists('escape', $options) || $options['escape'] !== false) {
  64.                 $value = h($value);
  65.             }
  66.             unset($options['value']);
  67.         }
  68.         if (array_key_exists('config', $options)) {
  69.             $config = $options['config'];
  70.             unset($options['config']);
  71.         }
  72.         if (array_key_exists('events', $options)) {
  73.             $events = $options['events'];
  74.             unset($options['events']);
  75.         }
  76.  
  77.         require_once WWW_ROOT.DS.'js'.DS.'ckeditor'.DS.'ckeditor.php';
  78.         $CKEditor = new CKEditor();
  79.         $CKEditor->basePath = $this->webroot.'js/ckeditor/';
  80.  
  81.         return $CKEditor->editor($options['name'], $value, $config, $events);
  82.     }
  83. }
  84. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement