本文整理汇总了PHP中theme::uses方法的典型用法代码示例。如果您正苦于以下问题:PHP theme::uses方法的具体用法?PHP theme::uses怎么用?PHP theme::uses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类theme
的用法示例。
在下文中一共展示了theme::uses方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: page
/**
* page
*
* @param boolean $realpath
* @return base_view_object_interface | string
*/
public function page($view = null, $data = array())
{
$themeName = $params['theme'] ? $params['theme'] : kernel::single('site_theme_base')->get_default('wap');
$theme = theme::uses($themeName);
$layout = $this->layout;
if (!$layout) {
$layoutFlag = !is_null($this->layoutFlag) ? $this->layoutFlag : 'defalut';
$tmplObj = kernel::single('site_theme_tmpl');
$layout = $tmplObj->get_default($this->layoutFlag, $themeName);
$layout = $layout ? $layout : (($tmpl_default = $tmplObj->get_default('default', $themeName)) ? $tmpl_default : 'default.html');
}
$theme->layout($layout);
if (!is_null($view)) {
$theme->of($view, $data);
}
return $theme->render();
}
示例2: preview
public function preview()
{
$themeName = input::get('theme');
$layout = input::get('file');
/** 清空widgets数据缓存 **/
if ($_SESSION['WIDGET_TMP_DATA'][$themeName . '/' . $file]) {
$_SESSION['WIDGET_TMP_DATA'][$themeName . '/' . $file] = array();
}
if ($_SESSION['WIDGET_TMP_DATA'][$themeName . '/block/header.html']) {
$_SESSION['WIDGET_TMP_DATA'][$themeName . '/block/header.html'] = array();
}
if ($_SESSION['WIDGET_TMP_DATA'][$themeName . '/block/footer.html']) {
$_SESSION['WIDGET_TMP_DATA'][$themeName . '/block/footer.html'] = array();
}
header('Content-Type: text/html; charset=utf-8');
kernel::single('base_session')->close();
$compiler = view::getEngine()->getCompiler();
$compiler->loadCompileHelper(kernel::single('site_theme_complier'));
$compiler->loadViewHelper(kernel::single('site_theme_helper'));
$theme = theme::uses($themeName)->preview();
return $theme->layout($layout)->render();
}
示例3: editor
public function editor($widgets, $widgets_app, $widgets_theme, $theme, $values = false)
{
$return = array();
$widgets_config = $this->widgets_config($widgets, $widgets_app, $widgets_theme);
$widgets_dir = $widgets_config['dir'];
$setting = $this->widgets_info($widgets, $widgets_app, $widgets_theme);
is_array($values) or $values = array();
$values = array_merge($setting, $values);
if (!empty($setting['template'])) {
if (!is_array($setting['template'])) {
$setting['template'] = array($setting['template'] => 'DEFAULT');
}
$return['tpls'][$file] = $setting['template'];
} else {
if ($widgets == 'html') {
$widgets = 'usercustom';
if (!$values['usercustom']) {
$values['usercustom'] = $values['html'];
}
}
if ($handle = opendir($widgets_dir)) {
while (false !== ($file = readdir($handle))) {
if (substr($file, 0, 1) != '_' && strtolower(substr($file, -5)) == '.html' && file_exists($widgets_dir . '/' . $file)) {
$return['tpls'][$file] = $file;
}
}
closedir($handle);
} else {
return false;
}
}
$cur_theme = $theme;
try {
$isFind = true;
theme::uses($theme);
$configPath = theme::getThemeNamespace('widgets/' . $widgets . '/_config.html');
view::getFinder()->find($configPath);
} catch (\InvalidArgumentException $e) {
$isFind = false;
}
if ($isFind) {
$sFunc = $widgets_config['crun'];
$sFuncFile = $widgets_config['cfg'];
if (file_exists($sFuncFile)) {
include_once $sFuncFile;
if (function_exists($sFunc)) {
$pagedata['data'] = $sFunc($widgets_config['app']);
}
}
$pagedata['setting'] =& $values;
//$compile_code = $smarty->fetch_admin_widget($widgets_dir.'/_config.html',$widgets_app);
$compile_code = view::make($configPath, $pagedata)->render();
if ($compile_code) {
$compile_code = ecos_cactus('site', 'theme_widget_prefix_content', $compile_code, $widgets_config['url']);
}
$return['html'] = $compile_code;
}
return $return;
}
示例4: __site_parse_widget_instance
public function __site_parse_widget_instance($widget, &$wg_compiler, $type)
{
static $a = 0;
$a++;
$output = '';
$widgets_config = kernel::single('site_theme_widget')->widgets_config($widget['widgets_type'], $widget['app'], $widget['theme']);
// widget 目录路径
$widget_dir = $widgets_config['dir'];
// widget 标识唯一来源
$widget_flag = $widgets_config['flag'];
// widget 函数名
$widget_run = $widgets_config['run'];
// widget url地址
$widgets_url = $widgets_config['url'];
// widget 处理函数所在文件完整路径
$func_file = $widgets_config['func'];
// widget 模板文件完整路径
$tpl = $widget_dir . '/' . $widget['tpl'];
//如果不存在模板, 则返回空
if (!file_exists($tpl)) {
return '';
}
$params = is_array($widget['params']) ? $widget['params'] : array();
$output .= '$__widgets_setting = ' . var_export($params, 1) . ';';
static $_widgets = array();
if (file_exists($func_file)) {
if (!isset($_widgets[$tpl])) {
$output .= 'require(\'' . $func_file . '\');';
$_widgets[$tpl] = true;
}
//todo:最简单的方式取一下数据,否则缓存控制器无法得知widgets_instance会影响到缓存
$output .= 'if(function_exists("' . $widget_run . '")) $__widgets_data = ' . $widget_run . '($__widgets_setting);';
}
$output .= sprintf('$__widgets_id = \'%s\';', $widget['widgets_id']);
$pattern_from = array('/(\'|\\")(images\\/)/is', '/((?:background|src|href)\\s*=\\s*["|\'])(?:\\.\\/|\\.\\.\\/)?(images\\/.*?["|\'])/is', '/((?:background|background-image):\\s*?url\\()(?:\\.\\/|\\.\\.\\/)?(images\\/)/is');
$pattern_to = array("\$1" . $widgets_url . '/' . "\$2", "\$1" . $widgets_url . '/' . "\$2", "\$1" . $widgets_url . '/' . "\$2");
$content = preg_replace($pattern_from, $pattern_to, $content);
theme::uses($widgets['theme']);
$path = theme::getThemeNamespace('widgets/' . $widget['widgets_type'] . '/' . $widget['tpl']);
$output .= sprintf('ob_start(); echo view::make(\'%s\', array(\'data\' => $__widgets_data, \'setting\' => $__widgets_setting, \'widgets_id\' => $__widgets_id))->render();', $path);
$output .= '$body = str_replace(\'%THEME%\',$__THEME_URL,ob_get_contents());ob_end_clean();';
$output .= 'echo $body;unset($body);';
return $output;
}