示例#1
0
 public function actionSave($class, $timestamp)
 {
     FormField::$inEditor = true;
     $class = FormBuilder::classPath($class);
     $session = Yii::app()->session['FormBuilder_' . $class];
     $file = file(Yii::getPathOfAlias($class) . ".php", FILE_IGNORE_NEW_LINES);
     $changed = false;
     if ($timestamp != @$session['timestamp']) {
         $changed = true;
     }
     if (!$changed) {
         foreach ($file as $k => $f) {
             if (trim($file[$k]) != trim(@$session['file'][$k])) {
                 $changed = true;
             }
         }
     }
     if (!$changed) {
         $postdata = file_get_contents("php://input");
         $post = CJSON::decode($postdata);
         $session = Yii::app()->session['FormBuilder_' . $class];
         $fb = FormBuilder::load($class);
         if (isset($post['fields'])) {
             if (is_subclass_of($fb->model, 'FormField')) {
                 Yii::app()->cache->delete('toolbarData');
                 Yii::app()->cache->delete('toolbarHtml');
             }
             //save posted fields
             if (!$fb->setFields($post['fields'])) {
                 echo "FAILED: PERMISSION DENIED";
             }
         } else {
             if (isset($post['form'])) {
                 if (is_array($post['form']['layout']['data'])) {
                     ## save menutree to menutree file
                     foreach ($post['form']['layout']['data'] as $d) {
                         if (@$d['type'] == "menu" && !!@$d['file']) {
                             $menuOptions = MenuTree::getOptions($d['file']);
                             $menuOptions['layout'] = $d;
                             MenuTree::writeOptions($d['file'], $menuOptions);
                         }
                     }
                 }
                 //save posted form
                 if (!$fb->setForm($post['form'])) {
                     echo "FAILED: PERMISSION DENIED";
                 }
             }
         }
     } else {
         echo "FAILED";
     }
 }
示例#2
0
 public function actionGetMode($path)
 {
     $options = MenuTree::getOptions($path);
     echo $options['mode'];
 }