php Tygh-Settings类(方法)实例源码

下面列出了php Tygh-Settings 类(方法)源码代码实例,从而了解它的用法。

作者:ambient-loung    项目:sit   
fn_em_delete_subscribers((array) $_REQUEST['subscriber_id']);
        }
        $suffix = '.manage';
    }
    if ($mode == 'sync') {
        EmailSync::instance()->sync();
        $suffix = '.manage';
    }
    if ($mode == 'import') {
        EmailSync::instance()->import();
        $suffix = '.manage';
    }
    return array(CONTROLLER_STATUS_OK, 'em_subscribers' . $suffix);
}
if ($mode == 'manage') {
    list($subscribers, $search) = fn_em_get_subscribers($_REQUEST, Registry::get('settings.Appearance.admin_elements_per_page'));
    // Get settings
    $em_settings = array();
    foreach (fn_em_get_managable_settings() as $option) {
        $option_data = Settings::instance()->getSettingDataByName($option);
        $em_settings[$option_data['object_id']] = $option_data;
    }
    Tygh::$app['view']->assign('em_settings', $em_settings);
    Tygh::$app['view']->assign('em_support', EmailSync::instance()->supports());
    Tygh::$app['view']->assign('subscribers', $subscribers);
    Tygh::$app['view']->assign('search', $search);
}
function fn_em_get_managable_settings()
{
    return array('em_show_on_checkout', 'em_checkout_enabled', 'em_double_opt_in', 'em_welcome_letter');
}

作者:askza    项目:ask-za   
/**
 * Common functions
 */
function fn_yandex_metrika_sync_goals()
{
    $oauth_token = Settings::instance()->getValue('auth_token', 'rus_yandex_metrika');
    $counter_number = Settings::instance()->getValue('counter_number', 'rus_yandex_metrika');
    if (empty($oauth_token) || empty($counter_number)) {
        return false;
    }
    $goals_scheme = fn_get_schema('rus_yandex_metrika', 'goals');
    $selected_goals = Settings::instance()->getValue('collect_stats_for_goals', 'rus_yandex_metrika');
    $client = new RestClient('https://api-metrika.yandex.ru/');
    $ext_goals = array();
    $res = $client->get("/counter/{$counter_number}/goals.json", array('oauth_token' => $oauth_token));
    if (!empty($res['goals'])) {
        foreach ($res['goals'] as $goal) {
            $ext_goals[$goal['name']] = $goal;
        }
    }
    foreach ($goals_scheme as $goal_name => $goal) {
        $ext_goal_name = '[auto] ' . $goal['name'];
        if (!empty($ext_goals[$ext_goal_name])) {
            if (empty($selected_goals[$goal_name]) || $selected_goals[$goal_name] == 'N') {
                $client->delete("/counter/{$counter_number}/goal/" . $ext_goals[$ext_goal_name]['id'] . "?oauth_token={$oauth_token}");
            }
        } else {
            if (!empty($selected_goals[$goal_name]) && $selected_goals[$goal_name] == 'Y') {
                $goal['name'] = $ext_goal_name;
                $client->post("/counter/{$counter_number}/goals?oauth_token={$oauth_token}", array('goal' => $goal));
            }
        }
    }
    return true;
}

作者:askza    项目:ultimat   
/**
 * Gets Google Analytics tracking code
 *
 * @param mixed $company_id Company identifier to get code for
 * @return string Google Analytics tracking code
 */
function fn_google_analytics_get_tracking_code($company_id = null)
{
    if (!fn_allowed_for('ULTIMATE')) {
        $company_id = null;
    }
    return Settings::instance()->getValue('tracking_code', 'google_analytics', $company_id);
}

作者:ambient-loung    项目:sit   
function fn_mp_update_settings($mp_settings, $company_id = null)
{
    if (!($setting_id = Settings::instance()->getId('maps_provider_', ''))) {
        $setting_id = Settings::instance()->update(array('name' => 'maps_provider_', 'section_id' => 0, 'section_tab_id' => 0, 'type' => 'A', 'position' => 0, 'is_global' => 'N', 'handler' => ''));
    }
    Settings::instance()->updateValueById($setting_id, serialize($mp_settings), $company_id);
}

作者:retargetin    项目:CsCar   
function fn_retargeting_get_domain_api_key($company_id = null)
{
    if (!fn_allowed_for('ULTIMATE')) {
        $company_id = null;
    }
    return Settings::instance()->getValue('retargeting_domain_api', 'google_analytics');
}

作者:heg-arc-n    项目:cscar   
protected function updateCompanySettings($params, $company_id)
 {
     $settings = array();
     foreach ($this->setting_names as $setting_name) {
         if (isset($params[$setting_name])) {
             Settings::instance()->updateValue($setting_name, $params[$setting_name], '', false, $company_id);
         }
     }
 }

作者:askza    项目:ultimat   
function fn_get_paypal_settings($lang_code = DESCR_SL)
{
    $pp_settings = Settings::instance()->getValues('paypal', 'ADDON');
    if (!empty($pp_settings['general']['pp_statuses'])) {
        $pp_settings['general']['pp_statuses'] = unserialize($pp_settings['general']['pp_statuses']);
    }
    $pp_settings['general']['main_pair'] = fn_get_image_pairs(fn_paypal_get_logo_id(), 'paypal_logo', 'M', false, true, $lang_code);
    return $pp_settings['general'];
}

作者:heg-arc-n    项目:cscar   
function fn_settings_actions_addons_hidpi(&$new_value, $old_value)
{
    Storage::instance('images')->deleteDir('thumbnails');
    if ($new_value == 'A') {
        $formats = fn_check_gd_formats();
        // Set thumbnail generation format to png to improve quality
        if (!empty($formats['png'])) {
            Settings::instance()->updateValue('convert_to', 'png', 'Thumbnails');
        }
    }
}

作者:heg-arc-n    项目:cscar   
function fn_settings_variants_addons_hybrid_auth_icons_pack()
{
    $available_icons_packs = array();
    $theme_name = Settings::instance()->getValue('theme_name', '');
    $icons_dir = fn_get_theme_path('[themes]/', 'C') . $theme_name . '/media/images/addons/hybrid_auth/icons/';
    $icons_packs = fn_get_dir_contents($icons_dir);
    foreach ($icons_packs as $id => $icons_packs_name) {
        $available_icons_packs[$icons_packs_name] = $icons_packs_name;
    }
    return $available_icons_packs;
}

作者:ambient-loung    项目:sit   
function fn_rus_ruble_install()
{
    $currencies = Registry::get('currencies');
    if (empty($currencies)) {
        $currencies = fn_get_currencies_list(array(), 'A', CART_LANGUAGE);
        Registry::set('currencies', $currencies);
    }
    $magic_key = fn_rus_ruble_gen_magic_key();
    Settings::instance()->updateValue('cron_key', $magic_key, 'rus_ruble');
    RusCurrency::process_sbrf_currencies(CURRENCY_RUB);
}

作者:ambient-loung    项目:sit   
function fn_settings_actions_addons_hidpi(&$new_value, $old_value)
{
    Storage::instance('images')->deleteDir('thumbnails');
    if ($new_value == 'A') {
        $formats = fn_get_supported_image_format_variants();
        // Set thumbnail generation format to png to improve quality
        if (!empty($formats['png'])) {
            Settings::instance()->updateValue('convert_to', 'png', 'Thumbnails');
            fn_set_notification('W', __('warning'), __('addons.hidpi.thumbnail_format_changed', array('[settings_url]' => fn_url('settings.manage?section_id=Thumbnails'))));
        }
    }
}

作者:ambient-loung    项目:sit   
function fn_mp_get_settings($company_id = null)
{
    static $cache;
    if (empty($cache['settings_' . $company_id])) {
        $settings = Settings::instance()->getValue('maps_provider_', '', $company_id);
        $settings = unserialize($settings);
        if (empty($settings)) {
            $settings = array();
        }
        $cache['settings_' . $company_id] = $settings;
    }
    return $cache['settings_' . $company_id];
}

作者:ambient-loung    项目:sit   
public function auth($code)
 {
     $client = new RestClient('https://oauth.yandex.ru/', Registry::get('addons.yandex_market.ym_application_id'), Registry::get('addons.yandex_market.ym_application_password'), 'basic', array(), '');
     try {
         $res = $client->post('token', array('grant_type' => 'authorization_code', 'code' => $code));
         $result = json_decode($res, true);
         if (!empty($result['access_token'])) {
             Settings::instance()->updateValue('ym_auth_token', $result['access_token'], 'yandex_market');
         }
     } catch (Pest_Exception $e) {
         throw $e;
     }
 }

作者:OneataBogda    项目:lead_coriola   
public function getDefault($theme_name = '')
 {
     $condition = '';
     if (empty($theme_name)) {
         $theme_name = Settings::instance()->getValue('theme_name', '');
     }
     if (fn_allowed_for('ULTIMATE')) {
         $condition = $this->getCompanyCondition('?:bm_layouts.company_id');
     }
     $condition .= db_quote(" AND is_default = 1 AND theme_name = ?s", $theme_name);
     $layout = db_get_row("SELECT * FROM ?:bm_layouts WHERE 1 ?p", $condition);
     return $layout;
 }

作者:askza    项目:ultimat   
/**
  * Gets CDN object instance
  *
  * @return Cdn CDN object instance
  */
 public static function instance()
 {
     if (empty(self::$_instance)) {
         $backend = Registry::get('config.cdn_backend');
         if (empty($backend)) {
             throw new DeveloperException('CDN: undefined CDN backend');
         }
         $options = Settings::instance()->getValue('cdn', '');
         $options = !empty($options) ? unserialize($options) : array();
         $class = '\\Tygh\\Backend\\Cdn\\' . ucfirst($backend);
         self::$_instance = new $class($options);
     }
     return self::$_instance;
 }

作者:ambient-loung    项目:sit   
public function update($id, $params)
 {
     $data = array();
     $status = Response::STATUS_BAD_REQUEST;
     if (!empty($id) && array_key_exists('value', $params)) {
         $company_id = $this->safeGet($params, 'company_id', null);
         $result = CartSettings::instance()->updateValueById($id, $params['value'], $company_id);
         if ($result) {
             $status = Response::STATUS_OK;
             $data = array('setting_id' => $id);
         }
     }
     return array('status' => $status, 'data' => $data);
 }

作者:askza    项目:ultimat   
/**
 * Check if secure connection is available
 */
function fn_settings_actions_security_secure_admin(&$new_value, $old_value)
{
    if ($new_value !== 'N') {
        $suffix = '';
        if (fn_allowed_for('ULTIMATE')) {
            $suffix = '&company_id=' . Registry::get('runtime.company_id');
        }
        $admin_url = fn_url('index.index?check_https=Y' . $suffix, 'A', 'https');
        $content = Http::get($admin_url);
        if (empty($content) || $content != 'OK') {
            // Disable https
            Settings::instance()->updateValue('secure_admin', 'N', 'Security');
            $new_value = 'N';
            fn_set_notification('W', __('warning'), __('warning_https_disabled'));
        }
    }
}

作者:askza    项目:ultimat   
/**
  * Get store auth key
  *
  * @return string store key
  */
 public static function getStoreKey()
 {
     $key = Registry::get('settings.store_key');
     $host_path = Registry::get('config.http_host') . Registry::get('config.http_path');
     if (!empty($key)) {
         list($token, $host) = explode(';', $key);
         if ($host != $host_path) {
             unset($key);
         }
     }
     if (empty($key)) {
         // Generate new value
         $key = fn_crc32(microtime());
         $key .= ';' . $host_path;
         Settings::instance()->updateValue('store_key', $key);
     }
     return $key;
 }

作者:ambient-loung    项目:sit   
/**
 * Check if secure connection is available
 */
function fn_settings_actions_security_secure_admin(&$new_value, $old_value)
{
    if ($new_value !== 'N') {
        $suffix = '';
        if (fn_allowed_for('ULTIMATE')) {
            $suffix = '&company_id=' . Registry::get('runtime.company_id');
        }
        $admin_url = fn_url('index.index?check_https=Y' . $suffix, 'A', 'https');
        $content = Http::get($admin_url);
        if (empty($content) || $content != 'OK') {
            // Disable https
            Settings::instance()->updateValue('secure_admin', 'N', 'Security');
            $new_value = 'N';
            $error = Http::getErrorFields();
            $error_warning = __('warning_https_is_disabled', array('[href]' => Registry::get('config.resources.kb_https_failed_url')));
            $error_warning .= fn_settings_actions_build_detailed_error_message($error);
            fn_set_notification('W', __('warning'), $error_warning);
        }
    }
}

作者:ambient-loung    项目:sit   
public function getDefault($theme_name = '')
 {
     $condition = '';
     if (empty($theme_name)) {
         $theme_name = Settings::instance()->getValue('theme_name', '');
     }
     if (fn_allowed_for('ULTIMATE')) {
         $condition = $this->getCompanyCondition('?:bm_layouts.company_id');
     }
     $condition .= db_quote(" AND is_default = 1 AND theme_name = ?s", $theme_name);
     /**
      * Modifies the way to get default layout
      *
      * @param object  $this Layout object
      * @param string  $theme_name theme name
      * @param string  $condition part of SQL condition
      */
     fn_set_hook('layout_get_default', $this, $theme_name, $condition);
     $layout = db_get_row("SELECT * FROM ?:bm_layouts WHERE 1 ?p", $condition);
     return $layout;
 }


问题


面经


文章

微信
公众号

扫码关注公众号