Example #1
0
 /**
  * Returns the given date in the appropriate timezone.
  *
  * @param string|int     $timestamp a unix timestamp or a string date.
  * @param boolean|string $tz        the timezone to use.
  *                       If none is specified, WordPress' default timezone
  *                       will be used.
  *
  * @return string the given date in the appropriate timezone.
  *
  * @see self::format_unix_timestamp
  *
  * @since 1.0.10
  */
 public static function format_date($timestamp, $tz = false)
 {
     $aux = $timestamp;
     if (!is_int($aux)) {
         $aux = strtotime($timestamp);
     }
     return NelioABFormatter::format_unix_timestamp($aux, $tz);
 }
        protected function print_experiment_information($exp, $descr, $res)
        {
            ?>
			<div id="exp-info-header">
				<?php 
            echo $this->get_experiment_icon($exp);
            ?>
				<span class="exp-title"><?php 
            echo $exp->get_name();
            ?>
</span>
			</div>

			<?php 
            $startDate = NelioABFormatter::format_date($exp->get_start_date());
            $end = $exp->get_end_date();
            if (empty($end)) {
                $running = __('Started on', 'nelioab') . ' ' . $startDate;
            } else {
                $endDate = NelioABFormatter::format_date($end);
                $running = $startDate . '&mdash;' . $endDate;
            }
            if ($res == null && $exp->get_status() == NelioABExperiment::STATUS_FINISHED) {
                $duration = NelioABFormatter::get_timelapse($exp->get_start_date(), $exp->get_end_date());
            } else {
                if ($res == null) {
                    $duration = __('Not available', 'nelioab');
                } else {
                    $duration = NelioABFormatter::get_timelapse($exp->get_start_date(), $res->get_last_update());
                }
            }
            ?>

			<div id="exp-info-running-time">
				<span class="exp-info-header"><?php 
            _e('Duration', 'nelioab');
            ?>
</span>
				<span class="exp-info-duration"><?php 
            echo $duration;
            ?>
</span>
				<span class="exp-info-running-values"><?php 
            echo $running;
            ?>
</span>
			</div>

			<?php 
            $end_mode = __('The experiment can only be stopped manually', 'nelioab');
            if ($exp->get_status() == NelioABExperiment::STATUS_RUNNING && NelioABAccountSettings::get_subscription_plan() >= NelioABAccountSettings::ENTERPRISE_SUBSCRIPTION_PLAN) {
                switch ($exp->get_finalization_mode()) {
                    case NelioABExperiment::FINALIZATION_MANUAL:
                        $end_mode = __('The experiment can only be stopped manually', 'nelioab');
                        break;
                    case NelioABExperiment::FINALIZATION_AFTER_DATE:
                        $raw_fin_value = $exp->get_finalization_value();
                        $fin_value = __('24 hours', 'nelioab');
                        if ($raw_fin_value >= 2) {
                            $fin_value = __('48 hours', 'nelioab');
                        }
                        if ($raw_fin_value >= 5) {
                            $fin_value = __('5 days', 'nelioab');
                        }
                        if ($raw_fin_value >= 7) {
                            $fin_value = __('1 week', 'nelioab');
                        }
                        if ($raw_fin_value >= 14) {
                            $fin_value = __('2 weeks', 'nelioab');
                        }
                        if ($raw_fin_value >= 30) {
                            $fin_value = __('1 month', 'nelioab');
                        }
                        if ($raw_fin_value >= 60) {
                            $fin_value = __('2 months', 'nelioab');
                        }
                        $end_mode = sprintf(__('The experiment will be automatically stopped %s after it was started.', 'nelioab'), $fin_value);
                        break;
                    case NelioABExperiment::FINALIZATION_AFTER_VIEWS:
                        $end_mode = sprintf(__('The experiment will be automatically stopped when the tested page (along with its alternatives) has been seen over %s times.', 'nelioab'), $exp->get_finalization_value());
                        break;
                    case NelioABExperiment::FINALIZATION_AFTER_CONFIDENCE:
                        $end_mode = sprintf(__('The experiment will be automatically stopped when confidence reaches %s%%.', 'nelioab'), $exp->get_finalization_value());
                        break;
                }
            }
            ?>

			<div id="exp-info-end-mode">
				<span><?php 
            _e('Finalization Mode', 'nelioab');
            ?>
</span>
				<span class="exp-end-mode"><?php 
            echo $end_mode;
            ?>
</span>
			</div>

			<?php 
            if (empty($descr)) {
                $descr = __('No description provided', 'nelioab');
            }
            ?>

			<div id="exp-info-descr">
				<span><?php 
            _e('Description', 'nelioab');
            ?>
</span>
				<span><?php 
            echo $descr;
            ?>
</span>
			</div>

		<?php 
        }
 public function column_relevant_date($exp)
 {
     include_once NELIOAB_UTILS_DIR . '/formatter.php';
     $date = '<span style="display:none;">%s</span><span title="%s">%s</span>';
     switch ($exp->get_status()) {
         case NelioABExperiment::STATUS_FINISHED:
             $res = sprintf($date, strtotime($exp->get_end_date()), __('Finalization Date', 'nelioab'), NelioABFormatter::format_date($exp->get_end_date()));
             break;
         case NelioABExperiment::STATUS_RUNNING:
             $res = sprintf($date, strtotime($exp->get_start_date()), __('Start Date', 'nelioab'), NelioABFormatter::format_date($exp->get_start_date()));
             break;
         case NelioABExperiment::STATUS_SCHEDULED:
             $res = sprintf($date, strtotime($exp->get_start_date()), __('Scheduled Date', 'nelioab'), NelioABFormatter::format_date($exp->get_start_date()));
             break;
         default:
             $res = sprintf($date, strtotime($exp->get_creation_date()), __('Creation Date', 'nelioab'), NelioABFormatter::format_date($exp->get_creation_date()));
             break;
     }
     return $res;
 }