/**
  * Output an edit form and process its input
  */
 function method_edit()
 {
     $this->foowd->track('foowd_text_plain->method_edit');
     include_once INPUT_DIR . 'input.form.php';
     include_once INPUT_DIR . 'input.textbox.php';
     include_once INPUT_DIR . 'input.textarea.php';
     include_once INPUT_DIR . 'input.checkbox.php';
     $editForm = new input_form('editForm', NULL, 'POST', FORM_DEFAULT_SUBMIT, NULL);
     $editForm->addSubmitButton('preview', FORM_DEFAULT_PREVIEW);
     $editCollision = new input_hiddenbox('editCollision', REGEX_DATETIME, time());
     $editForm->addObject($editCollision);
     $editArea = new input_textarea('editArea', NULL, $this->body, NULL);
     $editForm->addObject($editArea);
     // If author is same as last author and not anonymous,
     // ask if they want to make a new version, or just save changes to existing version
     $noNewVersion = new input_checkbox('noNewVersion', $editForm, TRUE, _("Save this as the previous version?"));
     if (isset($this->foowd->user->objectid) && $this->updatorid == $this->foowd->user->objectid) {
         $editForm->addObject($noNewVersion);
     }
     $this->foowd->template->assign_by_ref('form', $editForm);
     if ($editForm->submitted()) {
         // Edit will increment version if requested ($newVersion->checked),
         // And will store revised body in the object if no edit collision
         $result = $this->edit($editArea->value, !$noNewVersion->checked, $editCollision->value);
         switch ($result) {
             case 1:
                 $_SESSION['ok'] = OBJECT_UPDATE_OK;
                 $url = getURI(array('classid' => $this->classid, 'objectid' => $this->objectid), FALSE);
                 $this->save();
                 $this->foowd->loc_forward($url);
                 break;
             case 2:
                 $this->foowd->template->assign('failure', OBJECT_UPDATE_COLLISION);
                 break;
             default:
                 $this->foowd->template->assign('failure', OBJECT_UPDATE_FAILED);
                 break;
         }
     } elseif ($editForm->otherSubmitted('preview')) {
         $this->foowd->template->assign('preview', $this->processContent($editArea->value));
     }
     $this->foowd->track();
 }
 /**
  * Output an edit form and process its input
  */
 function method_edit()
 {
     $this->foowd->track('smdoc_news->method_edit');
     include_once INPUT_DIR . 'input.form.php';
     include_once INPUT_DIR . 'input.textbox.php';
     include_once INPUT_DIR . 'input.textarea.php';
     $editForm = new input_form('editForm', NULL, 'POST', FORM_DEFAULT_SUBMIT, NULL);
     $editForm->addSubmitButton('preview', FORM_DEFAULT_PREVIEW);
     $editTitle = new input_textbox('editTitle', REGEX_TITLE, $this->title, 'Title', TRUE);
     $editForm->addObject($editTitle);
     $editCollision = new input_hiddenbox('editCollision', REGEX_DATETIME, time());
     $editForm->addObject($editCollision);
     $editSummary = new input_textarea('editSummary', NULL, $this->summary, 'Summary', 255);
     $editForm->addObject($editSummary);
     $editArea = new input_textarea('editArea', NULL, $this->body, 'Extended', 2048);
     $editForm->addObject($editArea);
     $this->addCategories($editForm);
     $this->foowd->template->assign_by_ref('form', $editForm);
     if ($editForm->submitted()) {
         // No versioning for news items.
         $this->set('summary', $editSummary->value);
         $result = $this->edit($editArea->value, FALSE, $editCollision->value);
         switch ($result) {
             case 1:
                 $_SESSION['ok'] = OBJECT_UPDATE_OK;
                 $url['classid'] = $this->classid;
                 $url['objectid'] = $this->objectid;
                 $this->save();
                 $this->foowd->loc_forward(getURI($url));
                 break;
             case 2:
                 $this->foowd->template->assign('failure', OBJECT_UPDATE_COLLISION);
                 break;
             default:
                 $this->foowd->template->assign('failure', OBJECT_UPDATE_FAILED);
                 break;
         }
     } elseif ($editForm->otherSubmitted('preview')) {
         $this->foowd->template->assign('preview', $this->processContent($editArea->value));
     }
     $this->foowd->track();
 }
示例#3
0
 /**
  * Display the empty workspace form and process its input.
  */
 function method_empty()
 {
     $this->foowd->track('foowd_workspace->method_empty');
     include_once INPUT_DIR . 'input.form.php';
     include_once INPUT_DIR . 'input.dropdown.php';
     $objectForm = new input_form('objectForm', NULL, SQ_POST, _("Move Objects"), NULL);
     $objectForm->addSubmitButton('deleteObjects', _("Delete Objects"));
     $return =& $this->getEmptyObjects();
     $items =& $return['items'];
     $objects =& $return['objects'];
     $objectSelect = new input_dropdown('objectSelect', NULL, $items, _("Select Objects") . ':', 10, TRUE);
     $result = $this->emptyWorkspace($objects, $objectSelect->value, $objectForm->submitted(), $objectForm->otherSubmitted('deleteObjects'));
     switch ($result) {
         case 0:
             // moved successfully
             $this->foowd->template->assign('success', TRUE);
             $this->foowd->template->assign('code', 0);
             $this->foowd->template->assign('objectid', $this->objectid);
             break;
         case 1:
             // deleted successfully
             $this->foowd->template->assign('success', TRUE);
             $this->foowd->template->assign('code', 1);
             $this->foowd->template->assign('objectid', $this->objectid);
             break;
         case 2:
             // nothing selected
             $this->foowd->template->assign('success', FALSE);
             $this->foowd->template->assign('error', 2);
             break;
         case 3:
             // display object list form
             if ($items) {
                 $objectForm->addObject($objectSelect);
                 $this->foowd->template->assign_by_ref('form', $objectForm);
             } else {
                 $this->foowd->template->assign('success', FALSE);
                 $this->foowd->template->assign('error', 3);
             }
             break;
     }
     $this->foowd->track();
 }