コード例 #1
0
ファイル: Edit.php プロジェクト: Bouhnosaure/Typesetter
 /**
  * Insert new content into a layout
  *
  */
 public function AddContent()
 {
     global $langmessage;
     //for ajax responses
     $this->page->ajaxReplace = array();
     if (!isset($_REQUEST['where'])) {
         message($langmessage['OOPS']);
         return false;
     }
     //prep destination
     if (!$this->GetValues($_REQUEST['where'], $to_container, $to_gpOutCmd)) {
         return false;
     }
     $handlers = $this->GetAllHandlers();
     $this->PrepContainerHandlers($handlers, $to_container, $to_gpOutCmd);
     //figure out what we're inserting
     $addtype =& $_REQUEST['addtype'];
     switch ($_REQUEST['addtype']) {
         case 'new_extra':
             $extra_name = $this->NewExtraArea();
             if ($extra_name === false) {
                 message($langmessage['OOPS'] . '(2)');
                 return false;
             }
             $insert = 'Extra:' . $extra_name;
             break;
         case 'custom_menu':
             $insert = $this->NewCustomMenu();
             break;
         case 'preset_menu':
             $insert = $this->NewPresetMenu();
             break;
         default:
             $insert = $_REQUEST['insert'];
             break;
     }
     if (!$insert) {
         message($langmessage['OOPS'] . ' (Nothing to insert)');
         return false;
     }
     //new info
     $new_gpOutInfo = \gp\tool\Output::GetgpOutInfo($insert);
     if (!$new_gpOutInfo) {
         message($langmessage['OOPS'] . ' (Nothing to insert)');
         return false;
     }
     $new_gpOutCmd = rtrim($new_gpOutInfo['key'] . ':' . $new_gpOutInfo['arg'], ':');
     if (!$this->AddToContainer($handlers[$to_container], $to_gpOutCmd, $new_gpOutCmd, false)) {
         return false;
     }
     $this->SaveHandlersNew($handlers);
     return true;
 }