function theme_widget_full_brandlist(&$setting) { $setting['allimg'] = ""; $setting['allurl'] = ""; if ($system->theme) { $theme_dir = kernel::get_themes_host_url() . '/' . theme::getThemeName(); } else { $theme_dir = kernel::get_themes_host_url() . '/' . app::get('site')->getConf('current_theme'); } if (!$setting['pic']) { foreach ($setting['img'] as $value) { $setting['allimg'] .= $rvalue . "|"; $setting['allurl'] .= urlencode($value["url"]) . "|"; } } else { foreach ($setting['pic'] as $key => $value) { if ($value['link']) { if ($value["url"]) { $value["linktarget"] = $value["url"]; } $setting['allimg'] .= $rvalue . "|"; $setting['allurl'] .= urlencode($value["linktarget"]) . "|"; $setting['pic'][$key]['link'] = str_replace('%THEME%', $theme_dir, $value['link']); } } } return $setting; }
/** * ShopEx licence * * @copyright Copyright (c) 2005-2010 ShopEx Technologies Inc. (http://www.shopex.cn) * @license http://ecos.shopex.cn/ ShopEx License */ function theme_widget_hb_pic_list(&$setting) { $setting['allimg'] = ""; $setting['allurl'] = ""; $theme_dir = kernel::get_themes_host_url() . '/' . theme::getThemeName(); if (!$setting['pic']) { foreach ($setting['img'] as $value) { $setting['allimg'] .= $rvalue . "|"; $setting['allurl'] .= urlencode($value["url"]) . "|"; } } else { foreach ($setting['pic'] as $key => $value) { if ($value['link']) { if ($value["url"]) { $value["linktarget"] = $value["url"]; } $setting['allimg'] .= $rvalue . "|"; $setting['allurl'] .= urlencode($value["linktarget"]) . "|"; $setting['pic'][$key]['link'] = str_replace('%THEME%', $theme_dir, $value['link']); } } } // var_dump($setting["pic"]); return $setting; }
function compile_widgets($attrs, &$compiler) { $current_file = theme::getCurrentLayoutOrPartial(); $current_file = substr($current_file, strpos($current_file, ':') + 1); $slot = intval(static::$_wgbar[$current_file]++); $allWidgetsGroup = static::$_cache[$current_file]; if (!isset($allWidgetsGroup)) { // preview模式, 并且SESSION中存在数据 if (theme::isPreview() && $_SESSION['WIDGET_TMP_DATA'][$current_file] && is_array($_SESSION['WIDGET_TMP_DATA'][$current_file])) { $widgets = (array) $_SESSION['WIDGET_TMP_DATA'][$current_file]; } else { $qb = app::get('site')->database()->createQueryBuilder(); $qb->select('*')->from('site_widgets_instance')->where('core_file=' . $qb->createPositionalParameter($current_file))->orderBy('widgets_order', 'asc'); $widgets = app::get('site')->model('widgets_instance')->tidy_data($qb->execute()->fetchAll()); } foreach ($widgets as $key => $widget) { if ($widget['core_id']) { $allWidgetsGroup['id'][$widget['core_id']][] = $widgets[$key]; } else { $allWidgetsGroup['slot'][$widget['core_slot']][] = $widgets[$key]; } } static::$_cache[$current_file] = $allWidgetsGroup; } if (isset($attrs['id'])) { $attrs['id'] = trim($attrs['id'], '\'"'); $widgets_group = $allWidgetsGroup['id'][$attrs['id']]; } else { $widgets_group = $allWidgetsGroup['slot'][$slot]; } /*--------------------- 获取全部widgets ------------------------------*/ if (is_array($widgets_group)) { $return = sprintf('$__THEME_URL = \'%s\';', kernel::get_themes_host_url() . '/' . theme::getThemeName()); $return .= 'unset($this->_vars);'; foreach ($widgets_group as $widget) { $return .= $this->__site_parse_widget_instance($widget, $compiler); } return $return . '$__widgets_setting=null;$__THEME_URL=null;$__widgets_id=null;$__widgets_data=null;'; } else { return ''; } }
private function fixThemeMedia($code) { //return $code; $from = array('/((?:background|src|href)\\s*=\\s*["|\'])(?:\\.\\/|\\.\\.\\/)?(images\\/.*?["|\'])/is', '/((?:background|background-image):\\s*?url\\()(?:\\.\\/|\\.\\.\\/)?(images\\/)/is'); $themeUrl = kernel::get_themes_host_url(); $to = array(sprintf('\\1%s\\2', $themeUrl . '/' . theme::getThemeName() . '/'), sprintf('\\1%s\\2', $themeUrl . '/' . theme::getThemeName() . '/')); // var_dump($to);exit; return preg_replace($from, $to, $code); }