📄 cms_site.class.inc
字号:
function print_back($attributes) { $template_name = isset ($attributes['template']) ? $attributes['template'] : ''; $class = isset ($attributes['class']) ? $attributes['class'] : ''; $text = isset ($attributes['text']) ? $attributes['text'] : ''; $print_rootfolders = isset ($attributes['print_rootfolders']) ? $attributes['print_rootfolders'] : 'true'; $back = ''; $template = $this->get_template_item_by_name($this->language['template_id'], $template_name); $folder = $this->get_folder($this->folder_id); if ($folder['parent_id'] != 0 && ($print_rootfolders == 'true' || $folder['parent_id'] != $this->site['root_folder_id'])) { $back = '<a class="'.$class.'" href="'.$this->create_url($folder['parent_id']).'">'.$text.'</a>'; if ($template) { $template_content = $this->parse_template($template['content']); $back = str_replace($this->get_tag('content', $template_content), $back, $template_content); } } return $back; } function print_rootfolders($attributes) { $template_name = isset ($attributes['template']) ? $attributes['template'] : ''; $item_template_name = isset ($attributes['item_template']) ? $attributes['item_template'] : ''; $active_item_template_name = isset ($attributes['active_item_template']) ? $attributes['active_item_template'] : $item_template_name; $class = isset ($attributes['class']) ? $attributes['class'] : ''; $active_class = isset ($attributes['active_class']) ? $attributes['active_class'] : $class; $folders = ''; $active_item_template = $this->get_template_item_by_name($this->language['template_id'], $active_item_template_name); $passive_item_template = $this->get_template_item_by_name($this->language['template_id'], $item_template_name); $template = $this->get_template_item_by_name($this->language['template_id'], $template_name); $count = $this->get_visible_folders($this->site['root_folder_id']); if ($count > 0) { while ($this->next_record()) { $item_template = ($this->f('id') == $this->folder_id) ? $active_item_template : $passive_item_template; $_class = ($this->f('id') == $this->folder_id) ? $active_class : $class; if ($item_template) { $item_template_content = $this->parse_template($item_template['content']); $folders .= str_replace($this->get_tag('content', $item_template_content), '<a title="'.$this->f('name').'" class="'.$_class.'" href="'.$this->create_url($this->f('id')).'">'.$this->f('name').'</a>', $item_template_content); } else { $folders .= '<a title="'.$this->f('name').'" class="'.$_class.'" href="'.$this->create_url($this->f('id')).'">'.$this->f('name').'</a>'; } } if ($template) { $template_content = $this->parse_template($template['content']); $folders = str_replace($this->get_tag('content', $template_content), $folders, $template_content); } } return $folders; } function print_folderlist($attributes) { global $GO_CONFIG, $GO_MODULES; $path = isset ($attributes['path']) ? $attributes['path'] : ''; $id = isset ($attributes['id']) ? $attributes['id'] : ''; $folders = ''; if ($resolved_path = $this->resolve_url($path, $this->language['root_folder_id'])) { $count = $this->get_visible_folders($resolved_path['folder_id']); if ($count > 0) { $folders .= '<ul id="'.$id.'">'; while ($this->next_record()) { if ($this->f('id') == $this->folder_id) { $folders .= '<li><strong><a title="'.$this->f('name').'" href="'.$this->create_url($this->f('id')).'">'.$this->f('name').'</a></strong>'; $cms = new cms(); $folder_count = $cms->get_visible_folders($this->f('id')); if ($folder_count > 0) { $folders .= '<ul>'; while ($cms->next_record()) { $folders .= '<li><a title="'.$this->f('name').'" href="'.$this->create_url($cms->f('id')).'">'.$cms->f('name').'</a></li>'; } } $file_count = $cms->get_files($this->folder_id, 'priority', 'ASC'); if ($file_count > 1) { $browser = detect_browser(); $cms_module = $GO_MODULES->get_module('cms'); if ($folder_count == 0) { $folders .= '<ul>'; } if ($browser['name'] == 'MSIE') { $target = '_blank'; } else { $target = '_self'; } while ($cms->next_record()) { if ($this->file_id == $cms->f('id')) { $folders .= '<li><strong>'; } else { $folders .= '<li>'; } $extension = $cms->f('extension'); if ($this->publish_static || eregi('htm', $cms->f('extension'))) { $folders .= '<a href="'.$this->create_url($this->folder_id, $cms->f('id')).'">'.strip_extension($cms->f('name')).'</a>'; } else { $folders .= '<a target="'.$target.'" href="'.$cms_module['url'].'download.php?site_id='.$this->site['id'].'&file_id='.$cms->f('id').'">'.strip_extension($cms->f('name')).'</a>'; } if ($this->file_id == $cms->f('id')) { $folders .= '</strong></li>'; } else { $folders .= '</li>'; } } if ($folder_count > 0 || $file_count > 0) { $folders .= '</ul>'; } $folders .= '</li>'; } } else { $folders .= '<li><a href="'.$this->create_url($this->f('id')).'">'.$this->f('name').'</a></li>'; } } $folders .= '</ul>'; } return $folders; } } function print_files($attributes) { global $GO_CONFIG, $extension, $GO_MODULES; $template_name = isset ($attributes['template']) ? $attributes['template'] : ''; $item_template_name = isset ($attributes['item_template']) ? $attributes['item_template'] : ''; $active_item_template_name = isset ($attributes['active_item_template']) ? $attributes['active_item_template'] : $item_template_name; $class = isset ($attributes['class']) ? $attributes['class'] : ''; $active_class = isset ($attributes['active_class']) ? $attributes['active_class'] : $class; $print_single = isset ($attributes['print_single']) ? $attributes['print_single'] : 'true'; $cms_module = $GO_MODULES->get_module('cms'); $files = ''; $template = $this->get_template_item_by_name($this->language['template_id'], $template_name); $item_template_passive = $this->get_template_item_by_name($this->language['template_id'], $item_template_name); $item_template_active = $this->get_template_item_by_name($this->language['template_id'], $active_item_template_name); $count = $this->get_files($this->folder_id, 'priority', 'ASC'); $browser = detect_browser(); if ($browser['name'] == 'MSIE') { $target = '_blank'; } else { $target = '_self'; } if ($count > 1 || ($count == 1 && $print_single == 'true')) { while ($this->next_record()) { $extension = $this->f('extension'); $item_template = ($this->file_id == $this->f('id')) ? $item_template_active : $item_template_passive; $_class = ($this->file_id == $this->f('id')) ? $active_class : $class; $name = strip_extension($this->f('name')); $title = $this->f('title') == '' ? $name : $this->f('title'); if ($this->publish_static || eregi('htm', $this->f('extension'))) { $content = '<a title="'.$title.'" class="'.$_class.'" href="'.$this->create_url($this->folder_id, $this->f('id')).'">'.$name.'</a>'; } else { $content = '<a title="'.$title.'" target="'.$target.'" class="'.$_class.'" href="'.$cms_module['url'].'download.php?site_id='.$this->site['id'].'&file_id='.$this->f('id').'">'.$name.'</a>'; } if ($item_template) { $item_template_content = $this->parse_template($item_template['content']); $files .= str_replace($this->get_tag('content', $item_template_content), $content, $item_template_content); } else { $files .= $content; } } if ($template) { $template_content = $this->parse_template($template['content']); $files = str_replace($this->get_tag('content', $template_content), $files, $template_content); } } return $files; } function print_items($attributes) { global $GO_CONFIG, $extension, $GO_MODULES; $template_name = isset ($attributes['template']) ? $attributes['template'] : ''; $item_template_name = isset ($attributes['item_template']) ? $attributes['item_template'] : ''; $active_item_template_name = isset ($attributes['active_item_template']) ? $attributes['active_item_template'] : $item_template_name; $class = isset ($attributes['class']) ? $attributes['class'] : ''; $active_class = isset ($attributes['active_class']) ? $attributes['active_class'] : $class; $print_root_only = isset ($attributes['print_root_only']) ? $attributes['print_root_only'] : 'false'; $print_root = isset ($attributes['print_root']) ? $attributes['print_root'] : 'true'; $menu = isset ($attributes['menu']) ? $attributes['menu'] : ''; $cms_module = $GO_MODULES->get_module('cms'); $return = ''; $template = $this->get_template_item_by_name($this->language['template_id'], $template_name); $item_template_passive = $this->get_template_item_by_name($this->language['template_id'], $item_template_name); $item_template_active = $this->get_template_item_by_name($this->language['template_id'], $active_item_template_name); if ($print_root_only == 'false') { if ($print_root == 'false' && $this->folder_id == $this->language['root_folder_id']) { return ''; } $items = $this->get_items($this->folder_id, true); } else { $items = $this->get_items($this->language['root_folder_id'], true); } $count = count($items); while ($item = array_shift($items)) { if (isset ($item['extension'])) { $extension = $item['extension']; $item_template = ($this->file_id == $item['id']) ? $item_template_active : $item_template_passive; $_class = ($this->file_id == $item['id']) ? $active_class : $class; $name = strip_extension($item['name']); $title = $item['title'] == '' ? $name : $item['title']; if ($this->publish_static || eregi('htm', $extension)) { $content = '<a title="'.$title.'" class="'.$_class.'" href="'.$this->create_url($item['folder_id'], $item['id']).'">'.$name.'</a>'; } else { $content = '<a title="'.$title.'" target="_blank" class="'.$_class.'" href="'.$cms_module['url'].'download.php?site_id='.$this->site['id'].'&file_id='.$item['id'].'">'.$name.'</a>'; } if ($item_template) { $item_template_content = $this->parse_template($item_template['content']); $return .= str_replace($this->get_tag('content', $item_template_content), $content, $item_template_content); } else { $return .= $content; } } else { $extension = ''; $item_template = ($this->folder_id == $item['id']) ? $item_template_active : $item_template_passive; $_class = ($this->folder_id == $item['id']) ? $active_class : $class; if ($menu != '') { $menu_id = 'goMenuID_'.$item['id']; $menu_object = 'goMenu_'.$item['id']; $link = '<div id="'.$menu_id.'"></div>'; $link .= $this->generate_menu_object($item, $menu_object); $link .= '<script type="text/javascript">cmDraw("'.$menu_id.'", '.$menu_object.' , "hbr", cm'.$menu.', "'.$menu.'");</script>'; } else { $link = '<a class="'.$_class.'" href="'.$this->create_url($item['id']).'" title="'.$item['name'].'">'.$item['name'].'</a>'; } if ($item_template) { $item_template_content = $this->parse_template($item_template['content']); $return .= str_replace($this->get_tag('content', $item_template_content), $link, $item_template_content); } else { $return .= $link; } } } if ($template) { $template_content = $this->parse_template($template['content']); $return = str_replace($this->get_tag('content', $template_content), $return, $template_content); } return $return; } function generate_menu_object($folder, $menu_name) { return "\n<script type=\"text/javascript\">\n".'var '.$menu_name." = \n[".$this->_generate_menu_object($folder)."\n];</script>"; } function _generate_menu_object($folder, $indent = "\t") { $menu = ",\n".$indent; if (!isset ($folder['extension'])) { $menu .= '["", "'.addslashes($folder['name']).'", "'.$this->create_url($folder['id']).'", "_self", "'.$folder['name'].'"'; $items = $this->get_items($folder['id']); while ($item = array_shift($items)) { $menu .= ",".$this->_generate_menu_object($item, $indent."\t"); } } else { $menu .= '["", "'.addslashes($folder['name']).'", "'.$this->create_url($folder['folder_id'], $folder['id']).'", "_self", "'.$folder['name'].'"'; } return $menu.']'; } function print_login($attributes) { global $GO_CONFIG, $cms_login; $template_name = isset ($attributes['template']) ? $attributes['template'] : ''; $class = isset ($attributes['class']) ? $attributes['class'] : ''; $text = isset ($attributes['text']) ? $attributes['text'] : $cms_login; $template = $this->get_template_item_by_name($this->language['template_id'], $template_name); $login = '<a class="'.$class.'" href="javascript:popup(\''.$GO_CONFIG->full_url.'\');">'.$text.'</a>'; if ($template) { $template_content = $this->parse_template($template['content']); $login = str_replace($this->get_tag('content', $template_content), $login, $template_content); } return $login; } function print_document($attributes) { global $GO_CONFIG, $GO_MODULES; $path = isset ($attributes['path']) ? $attributes['path'] : ''; if ($resolved_path = $this->resolve_url($path, $this->site['id'])) { if ($resolved_path['file_id'] > 0) { $file = $this->get_file($resolved_path['file_id']); $content = $this->parse_template($file['content']); $content = str_replace($cms_module['full_url'].'view.php', $_SERVER['PHP_SELF'], $content); return $content; } else { return "<p><b>Error: Could not resolve file from '$path'</b></p>"; } } else { return "<p><b>Error: Could not resolve url to '$path'</b></p>"; } }function get_tag($tag, $content) { $start_pos = strpos($content, '<'.$tag); if ($start_pos !== false) { $content_length = strlen($content); $tag_length = 0; $char = $content[$start_pos + $tag_length]; $tag = $char; while ($char != '>' && ($start_pos + $tag_length) < $content_length) { $tag_length ++; $char = $content[$start_pos + $tag_length]; $tag .= $char; } return $tag; } return false; } function get_attributes($tag) { $attributes = array (); $in_value = false; $in_name = false; $name = ''; $value = ''; $length = strlen($tag); for ($i = 0; $i < $length; $i ++) { $char = $tag[$i]; switch ($char) { case '"' : if ($in_value) { $in_value = false; $attributes[trim($name)] = trim($value); $name = ''; $value = ''; } else { $in_value = true; } break; case ' ' : if (!$in_value) { $in_name = true; } else { $value .= $char; } break; case '=' : $in_name = false; break; default : if ($in_name) { $name .= $char; } if ($in_value) { $value .= $char; } break; } } return $attributes; } function parse_template($content) { for ($i = 0; $i < count($this->tags); $i ++) { while ($tag = $this->get_tag($this->tags[$i], $content)) { $function = 'print_'.$this->tags[$i]; $attributes = $this->get_attributes($tag); $content = str_replace($tag, $this-> $function ($attributes), $content); } } return $content; }}?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -