Example #1
0
 /**
  * After save callback
  * 
  */
 public function afterSave($created)
 {
     // then write the js file here.
     if ($this->_jsFile($this->data['WebpageJs']['name'], $this->data['WebpageJs']['content'])) {
         // then write it to settings for easy retrieval by the default layout
         if ($this->_updateSettings()) {
             return true;
         } else {
             throw new Exception(__('webpages', 'Javascript settings update failed'));
         }
     } else {
         throw new Exception(__('webpages', 'Javascript file write failed'));
     }
     return parent::afterSave($created);
 }
Example #2
0
 /**
  * After save callback
  * 
  */
 public function afterSave($created)
 {
     // then write the css file here.
     if ($this->_cssFile($this->data['WebpageCss']['name'], $this->data['WebpageCss']['content'])) {
         // then write it to settings for easy retrieval by the default layout
         if ($this->_updateSettings()) {
             return true;
         } else {
             throw new Exception(__('Css file save failed'));
         }
     } else {
         // roll back, there was a problem
         throw new Exception(__('Css file write failed.'));
     }
     return parent::afterSave($created);
 }
Example #3
0
 /**
  * After Save
  *
  * @param boolean $created
  * @return boolean
  * @access public
  */
 public function afterSave($created, $options = array())
 {
     $id = $this->id;
     // we do some saving between now and the end so we need to restate $this->id;
     $this->_saveTemplateSettings();
     //        if ($this->data['Webpage']['type'] == 'template') {
     //            // template settings are special
     //            $this->_syncTemplateSettings($this->id, $this->data);
     //        }
     if ($created && !empty($this->data['WebpageMenuItem']['parent_id'])) {
         App::uses('WebpageMenuItem', 'Webpages.Model');
         $WebpageMenuItem = new WebpageMenuItem();
         $WebpageMenuItem->create();
         if (!$WebpageMenuItem->save($this->data)) {
             throw new Exception(__('Problem adding menu item for this page.'));
         }
     }
     $this->id = $id;
     return parent::afterSave($created, $options);
 }