Пример #1
0
 /**
  * Returns alternative test value for current A/B-test context
  *
  * @param string $type Test type.
  * @param string $value Test original value.
  * @return string|null
  */
 public static function getAlternative($type, $value)
 {
     $result = null;
     if ($context = Helper::getContext()) {
         foreach ($context['data']['list'] as $item) {
             if ($item['type'] == $type && $item['old_value'] == $value) {
                 $result = $item['new_value'];
                 break;
             }
         }
     }
     return $result;
 }
Пример #2
0
 /**
  * Adds A/B-test related buttons to Control Panel
  * 
  * @return void
  */
 public static function onPanelCreate()
 {
     global $USER, $APPLICATION;
     if ($USER->canDoOperation('view_other_settings')) {
         if ($context = Helper::getContext()) {
             $baseUri = \CHTTP::urlDeleteParams($APPLICATION->getCurPage(), array('abtest_mode'));
             $groupAUri = \CHTTP::urlAddParams($baseUri, array('abtest_mode' => intval($context['abtest']) . '|A'));
             $groupBUri = \CHTTP::urlAddParams($baseUri, array('abtest_mode' => intval($context['abtest']) . '|B'));
             $resetUri = \CHTTP::urlAddParams($baseUri, array('abtest_mode' => 'reset'));
             $APPLICATION->addPanelButton(array('ID' => 'abtest_options', 'SRC' => $context['section'] == 'B' ? '/bitrix/images/abtest/ab-icon-b.png' : '/bitrix/images/abtest/ab-icon-a.png', 'TEXT' => str_replace('#ID#', intval($context['abtest']), Localization\Loc::getMessage('ABTEST_PANEL_MENU_BTN')), 'TYPE' => 'BIG', 'MAIN_SORT' => 900, 'SORT' => 10, 'MENU' => array(array('ACTION' => "jsUtils.Redirect([], '" . \CUtil::jsEscape($groupAUri) . "'); ", 'TEXT' => Localization\Loc::getMessage('ABTEST_PANEL_MENU_MODE_A'), 'CHECKED' => $context['section'] == 'A' ? true : false), array('ACTION' => "jsUtils.Redirect([], '" . \CUtil::jsEscape($groupBUri) . "'); ", 'TEXT' => Localization\Loc::getMessage('ABTEST_PANEL_MENU_MODE_B'), 'CHECKED' => $context['section'] == 'B' ? true : false), array('ACTION' => "jsUtils.Redirect([], '" . \CUtil::jsEscape($resetUri) . "'); ", 'TEXT' => Localization\Loc::getMessage('ABTEST_PANEL_MENU_RESET')))));
         }
     }
 }