Example #1
0
 function _saveSections()
 {
     require_once 'AMP/Content/Section.inc.php';
     $section_count = 1;
     $form =& $this->get_form();
     while (isset($this->_request_vars[$this->_get_section_fieldname($section_count)]) && $this->_request_vars[$this->_get_section_fieldname($section_count)]) {
         $name = $this->_request_vars[$this->_get_section_fieldname($section_count)];
         $text = $this->_request_vars[$this->_get_section_fieldname($section_count, 'text')];
         $section = new Section(AMP_Registry::getDbcon());
         $section->setName($name);
         $section->setBlurb($text);
         $section->setParent();
         $section->setListType();
         if (!($result = $section->save())) {
             ++$section_count;
             continue;
         }
         $section->publish();
         $section->reorder($section_count);
         $form->setValues(array($this->_get_section_fieldname($section_count) => '', $this->_get_section_fieldname($section_count, 'text') => ''));
         $this->message(sprintf(AMP_TEXT_DATA_SAVE_SUCCESS, $section->getName()));
         ++$section_count;
     }
 }
Example #2
0
 function _checkNewSection($data, $fieldname)
 {
     if (!(isset($data['new_section_name']) && $data['new_section_name'])) {
         if (!isset($data[$fieldname])) {
             return false;
         }
         return $data[$fieldname];
     }
     require_once 'AMP/Content/Section.inc.php';
     $section = new Section(AMP_Registry::getDbcon());
     $section->setDefaults();
     $section->setName($data['new_section_name']);
     $section->setParent($data['new_section_parent']);
     if (!($result = $section->save())) {
         return $data[$fieldname];
     }
     $section->publish();
     $flash =& AMP_System_Flash::instance();
     $flash->add_message(sprintf(AMP_TEXT_DATA_SAVE_SUCCESS, $section->getName()));
     return $section->id;
 }