Пример #1
0
 /**
  * Processes the POST data from the previous state.
  * @param AdminState $st The next state to be populated with the POST data
  * from the previous state.
  */
 private function processPost($st)
 {
     $state = $st;
     if (isset($_POST['Uninstall'])) {
         $this->uninstall();
         $state->render();
     } else {
         if (isset($_POST["Next"])) {
             if ($_POST["Next"] == "Delete") {
                 LongTailFramework::setConfig($_POST[LONGTAIL_KEY . "config"]);
                 LongTailFramework::deleteConfig();
                 $configs = LongTailFramework::getConfigs();
                 if ($configs && count($configs) >= 2 && $_POST[LONGTAIL_KEY . "config"] == get_option($_POST[LONGTAIL_KEY . "default"])) {
                     update_option(LONGTAIL_KEY . "default", $configs[1]);
                 } else {
                     if (!$configs || count($configs) == 1) {
                         update_option(LONGTAIL_KEY . "default", "Out-of-the-Box");
                     }
                 }
                 $state = new PlayerState($_POST[LONGTAIL_KEY . "config"]);
                 $del_player = $_POST[LONGTAIL_KEY . "config"];
                 $this->feedback_message("The '{$del_player}' Player was successfully deleted.");
                 $state->render();
             } else {
                 if ($_POST["Next"] == "Create Custom Player") {
                     $_POST[LONGTAIL_KEY . "new_player"] = "Custom Player";
                 }
                 $state->getNextState()->render();
             }
         } else {
             if (isset($_POST["Previous"])) {
                 $state->getPreviousState()->render();
             } else {
                 if (isset($_POST["Cancel"])) {
                     $state->getCancelState()->render();
                 } else {
                     if (isset($_POST["Save"])) {
                         $config = $_POST[LONGTAIL_KEY . "config"];
                         LongTailFramework::setConfig($config);
                         $save_values = $this->processSubmit();
                         $success = LongTailFramework::saveConfig($this->convertToXML($save_values), esc_html($_POST[LONGTAIL_KEY . "new_player"]));
                         $configs = LongTailFramework::getConfigs();
                         if ($configs && count($configs) == 2) {
                             update_option(LONGTAIL_KEY . "default", $_POST[LONGTAIL_KEY . "config"] ? $_POST[LONGTAIL_KEY . "config"] : $_POST[LONGTAIL_KEY . "new_player"]);
                             update_option(LONGTAIL_KEY . "ootb", false);
                         }
                         $save_player = $_POST[LONGTAIL_KEY . "new_player"] ? $_POST[LONGTAIL_KEY . "new_player"] : $config;
                         if ($success) {
                             $this->feedback_message("The '{$save_player}' Player was successfully saved.");
                         } else {
                             $this->error_message("The '{$save_player}' failed to save.  Please make sure the " . LongTailFramework::getConfigPath() . " exists and is writable.  " . JW_FILE_PERMISSIONS);
                         }
                         $state->getSaveState()->render();
                     } else {
                         if (isset($_POST[LONGTAIL_KEY . "default"])) {
                             update_option(LONGTAIL_KEY . "default", $_POST[LONGTAIL_KEY . "default"]);
                         }
                         if (isset($_POST[LONGTAIL_KEY . "show_archive"])) {
                             update_option(LONGTAIL_KEY . "show_archive", true);
                         } else {
                             if (!empty($_POST)) {
                                 update_option(LONGTAIL_KEY . "show_archive", false);
                             }
                         }
                         LongTailFramework::setConfig($_POST[LONGTAIL_KEY . "config"]);
                         $state->render();
                     }
                 }
             }
         }
     }
 }
Пример #2
0
 /**
  * Processes the POST data from the previous state.
  * @param AdminState $st The next state to be populated with the POST data
  * from the previous state.
  * @param $form
  * @param $form_state
  *
  */
 private function processPost($st, &$form, &$form_state)
 {
     $state = $st;
     if (isset($_POST["Next"])) {
         if ($_POST["Next"] == "Delete") {
             LongTailFramework::setConfig($form_state["storage"][LONGTAIL_KEY . "config"]);
             LongTailFramework::deleteConfig();
             $configs = LongTailFramework::getConfigs();
             if ($configs && count($configs) >= 2 && $_POST[LONGTAIL_KEY . "config"] == variable_get($form_state["storage"][LONGTAIL_KEY . "default"], "")) {
                 variable_set(LONGTAIL_KEY . "default", $configs[1]);
             } else {
                 if (!$configs || count($configs) == 1) {
                     variable_set(LONGTAIL_KEY . "default", "Out-of-the-Box");
                 }
             }
             $state = new PlayerState($form_state["storage"][LONGTAIL_KEY . "config"]);
             $del_player = $form_state["storage"][LONGTAIL_KEY . "config"];
             drupal_set_message("The '{$del_player}' Player was successfully deleted.");
             $state->render($form, $form_state);
         } else {
             if ($_POST["Next"] == "Create Custom Player") {
                 $form_state["storage"][LONGTAIL_KEY . "new_player"] = "Custom Player";
             }
             $state->getNextState()->render($form, $form_state);
         }
     } else {
         if (isset($_POST["Previous"])) {
             $state->getPreviousState()->render($form, $form_state);
         } else {
             if (isset($_POST["Cancel"])) {
                 unset($form_state["storage"]);
                 $state->getCancelState()->render($form, $form_state);
             } else {
                 if (isset($_POST["Save"]) && isset($form_state["storage"])) {
                     $config = $form_state["storage"][LONGTAIL_KEY . "config"];
                     $save_player = $form_state["storage"][LONGTAIL_KEY . "new_player"] ? $form_state["storage"][LONGTAIL_KEY . "new_player"] : $config;
                     LongTailFramework::setConfig($config);
                     $save_values = $this->processSubmit($form_state);
                     $success = LongTailFramework::saveConfig($this->convertToXML($save_values), check_plain($save_player));
                     $configs = LongTailFramework::getConfigs();
                     if ($configs && count($configs) == 2) {
                         variable_set(LONGTAIL_KEY . "ootb", false);
                     }
                     if ($success) {
                         drupal_set_message(t("The '{$save_player}' Player was successfully saved."));
                     } else {
                         drupal_set_message(t("The '{$save_player}' failed to save.  Please make sure the " . JWPLAYER_FILES_DIR . "/configs/ directory exists and is writable."), "error");
                     }
                     unset($form_state["storage"]);
                     $state->getSaveState()->render($form, $form_state);
                 } else {
                     if (isset($form_state["storage"][LONGTAIL_KEY . "default"])) {
                         variable_set(LONGTAIL_KEY . "default", $form_state["storage"][LONGTAIL_KEY . "default"]);
                     }
                     LongTailFramework::setConfig($form_state["storage"][LONGTAIL_KEY . "config"]);
                     $state->render($form, $form_state);
                 }
             }
         }
     }
 }