コード例 #1
0
 /**
  * Loads the experiment from AppEngine.
  *
  * @param int $id   the ID of the experiment we want to retrieve.
  * @param int $type the type of the experiment we want to retrieve.
  *
  * @return NelioABExperiment the experiment whose ID is `$id` and whose type is `$type`.
  *                           Note that the result will be an instance of
  *                           a concrete subclass of `NelioABExperiment`.
  *
  * @throws Exception `EXPERIMENT_ID_NOT_FOUND`
  *                   This exception is thrown if the experiment was not
  *                   found in AppEngine.
  *
  * @see NelioABExperiment::load
  *
  * @since 3.4.0
  */
 private static function load_experiment_by_id($id, $type)
 {
     require_once NELIOAB_MODELS_DIR . '/goals/goals-manager.php';
     /** @var NelioABExperiment $exp */
     switch ($type) {
         case NelioABExperiment::POST_ALT_EXP:
         case NelioABExperiment::PAGE_ALT_EXP:
         case NelioABExperiment::PAGE_OR_POST_ALT_EXP:
         case NelioABExperiment::CPT_ALT_EXP:
             $exp = NelioABPostAlternativeExperiment::load($id);
             break;
         case NelioABExperiment::HEADLINE_ALT_EXP:
             $exp = NelioABHeadlineAlternativeExperiment::load($id);
             break;
         case NelioABExperiment::WC_PRODUCT_SUMMARY_ALT_EXP:
             $exp = NelioABProductSummaryAlternativeExperiment::load($id);
             break;
         case NelioABExperiment::THEME_ALT_EXP:
             $exp = NelioABThemeAlternativeExperiment::load($id);
             break;
         case NelioABExperiment::CSS_ALT_EXP:
             $exp = NelioABCssAlternativeExperiment::load($id);
             break;
         case NelioABExperiment::WIDGET_ALT_EXP:
             $exp = NelioABWidgetAlternativeExperiment::load($id);
             break;
         case NelioABExperiment::MENU_ALT_EXP:
             $exp = NelioABMenuAlternativeExperiment::load($id);
             break;
         case NelioABExperiment::HEATMAP_EXP:
             $exp = NelioABHeatmapExperiment::load($id);
             break;
         default:
             $err = NelioABErrCodes::EXPERIMENT_ID_NOT_FOUND;
             throw new Exception(NelioABErrCodes::to_string($err), $err);
     }
     $exp->mark_as_fully_loaded();
     return $exp;
 }
 public function build_experiment_from_post_data()
 {
     $exp = new NelioABHeatmapExperiment($_POST['exp_id']);
     $exp->set_name(stripslashes($_POST['exp_name']));
     $exp->set_description(stripslashes($_POST['exp_descr']));
     $exp->set_post_id(stripslashes($_POST['exp_post_id']));
     global $nelioab_admin_controller;
     $nelioab_admin_controller->data = $exp;
 }
コード例 #3
0
 public static function load($id)
 {
     $json_data = NelioABBackend::remote_get(NELIOAB_BACKEND_URL . '/exp/hm/' . $id);
     $json_data = json_decode($json_data['body']);
     $exp = new NelioABHeatmapExperiment($json_data->key->id);
     $exp->set_type_using_text($json_data->kind);
     $exp->set_name($json_data->name);
     $exp->set_post_id($json_data->post);
     if (isset($json_data->description)) {
         $exp->set_description($json_data->description);
     }
     $exp->set_status($json_data->status);
     $exp->set_finalization_mode($json_data->finalizationMode);
     if (isset($json_data->finalizationModeValue)) {
         $exp->set_finalization_value($json_data->finalizationModeValue);
     }
     if (isset($json_data->goals)) {
         NelioABExperiment::load_goals_from_json($exp, $json_data->goals);
     }
     return $exp;
 }