📄 cms_site.class.inc
字号:
$page = $this->generate_header($file['title'], $file['keywords'], $file['description']); switch ($this->task) { case 'multipage_display' : $content = ''; if ($this->file_id > 0) { if ($print_title == 'true') { $content = '<h1 class="'.$title_class.'">'.$file['title'].'</h1>'; } $content .= $file['content']; } $template = $this->get_template_item_by_name($this->language['template_id'], $template); if ($template) { $template_content = $this->parse_template($template['content']); } else { $template_content = false; } $multipage = $this->build_multipage($this->folder_id, $max_length, $template, $class, true, $title_class, $read_more_class, $read_more_text, $hide_hot_items); if ($template_content) { $multipage = str_replace($this->get_tag('content', $template_content), $multipage, $template_content); } $content .= $multipage; if (!$this->publish_static) { $content = str_replace($cms_module['full_url'].'view.php', $_SERVER['PHP_SELF'], $content); } if (isset ($content_tag)) { $page .= str_replace($content_tag, $content, $main_template_content); } else { $page .= $content; } break; default : if ($this->file_id > 0) { $content = ''; if ($print_title == 'true') { $content = '<h1 class="'.$title_class.'">'.$file['title'].'</h1>'; } $content .= $file['content']; if (!$this->publish_static) { $content = str_replace($cms_module['full_url'].'view.php', $_SERVER['PHP_SELF'], $content); } if (isset ($main_template_content)) { $page .= str_replace($this->get_tag('content', $main_template_content), $content, $main_template_content); } else { $page .= $content; } } else { //get the language file require_once ($GO_LANGUAGE->get_language_file('cms')); if (isset ($main_template_content)) { $page .= str_replace($this->get_tag('content', $main_template_content), $cms_empty, $main_template_content); } else { $page .= $cms_empty; } } break; } $page .= $this->generate_footer(); if ($this->publish_static) { for ($i = 0; $i < count($this->template_file_replacements); $i ++) { $page = str_replace($this->template_file_replacements[$i]['dynamic'], $this->template_file_replacements[$i]['static'], $page); } } return $page; } function build_multipage($folder_id, $max_length, $template_name, $class, $print_title, $title_class, $read_more_class, $read_more_text, $hide_hot_items, $hot_items = false) { $template = $this->get_template_item_by_name($this->language['template_id'], $template_name); if ($template) { $template_content = $this->parse_template($template['content']); } else { $template_content = false; } $show = $this->file_id > 0 ? false : true; $multipage = ''; if ($folder = $this->get_folder($folder_id)) { if ($hot_items) { $this->get_hot_items($folder_id); } else { $this->get_files($folder_id); } while ($this->next_record()) { if ((($show && ($hide_hot_items == 'false' || $this->f('hot_item') != '1')) || $hot_items) && eregi('htm', $this->f('extension'))) { $multipage_item = '<div class="'.$class.'">'; if ($print_title == 'true') { $title = $this->f('title') != '' ? $this->f('title') : strip_extension($this->f('name')); $multipage_item .= '<h1 class="'.$title_class.'">'.$title.'</h1>'; } if ($max_length > 0) { $stripped_content = $this->strip_for_multipage($this->f('content')); $content = cut_string($stripped_content, $max_length); $multipage_item .= $content; if (strlen($this->f('content')) != strlen($content)) { $multipage_item .= '<br /><div style="text-align:right;"><a class="'.$read_more_class.'" href="'.$this->create_url($this->f('folder_id'), $this->f('id')).'">'.$read_more_text.'</a></div>'; } } $multipage_item .= '</div>'; if ($template_content) { $multipage .= str_replace($this->get_tag('content', $template_content), $multipage_item, $template_content); } else { $multipage .= $multipage_item; } } if ($this->file_id == $this->f('id')) { $show = true; } } return $this->build_multipage_recursive($folder_id, $max_length, $template_content, $class, $print_title, $title_class, $read_more_class, $read_more_text, $hide_hot_items, $hot_items, $multipage); } else { return false; } } function build_multipage_recursive($folder_id, $max_length, $template_content, $class, $print_title, $title_class, $read_more_class, $read_more_text, $hide_hot_items, $hot_items = false, $multipage = '') { $cms_site = new cms_site(); if ($this->get_folders($folder_id)) { while ($this->next_record()) { if ($this->f('disabled') != '1') { if ($hot_items) { $cms_site->get_hot_items($this->f('id')); } else { $cms_site->get_files($this->f('id')); } while ($cms_site->next_record()) { if ((($this->file_id != $cms_site->f('id') && ($hide_hot_items == 'false' || $cms_site->f('hot_item') != '1')) || $hot_items) && eregi('htm', $cms_site->f('extension'))) { $multipage_item = '<div class="'.$class.'">'; if ($print_title == 'true') { $title = $cms_site->f('title') != '' ? $cms_site->f('title') : strip_extension($cms_site->f('name')); $multipage_item .= '<h1 class="'.$title_class.'" >'.$title.'</h1>'; } if ($max_length > 0) { $stripped_content = $this->strip_for_multipage($cms_site->f('content')); $content = cut_string($stripped_content, $max_length); $multipage_item .= $content; if (strlen($cms_site->f('content')) != strlen($content)) { $multipage_item .= '<br /><div style="text-align:right;"><a class="'.$read_more_class.'" href="'.$this->create_url($cms_site->f('folder_id'), $cms_site->f('id')).'">'.$read_more_text.'</a></div>'; } } $multipage_item .= '</div>'; if ($template_content) { $multipage .= str_replace($this->get_tag('content', $template_content), $multipage_item, $template_content); } else { $multipage .= $multipage_item; } } if (!$hot_items) { break; } } $multipage .= $cms_site->build_multipage_recursive($this->f('id'), $max_length, $template_content, $class, $print_title, $title_class, $read_more_class, $read_more_text, $hide_hot_items, $hot_items); } } } return $multipage; } function print_hot_items($attributes) { $class = isset ($attributes['class']) ? $attributes['class'] : ''; $max_length = isset ($attributes['max_length']) ? $attributes['max_length'] : '0'; $print_title = isset ($attributes['print_title']) ? $attributes['print_title'] : 'true'; $title_class = isset ($attributes['title_class']) ? $attributes['title_class'] : ''; $read_more_class = isset ($attributes['read_more_class']) ? $attributes['read_more_class'] : ''; $read_more_text = isset ($attributes['read_more_text']) ? $attributes['read_more_text'] : 'Read more'; $template_name = isset ($attributes['template']) ? $attributes['template'] : ''; $item_template = isset ($attributes['item_template']) ? $attributes['item_template'] : ''; $print_root_only = isset ($attributes['print_root_only']) ? $attributes['print_root_only'] : 'false'; $template = $this->get_template_item_by_name($this->language['template_id'], $template_name); if ($template) { $template_content = $this->parse_template($template['content']); } else { $template_content = false; } if ($print_root_only == 'true' && $this->folder_id != $this->language['root_folder_id']) { return ''; } else { $multipage = $this->build_multipage($this->language['root_folder_id'], $max_length, $item_template, $class, $print_title, $title_class, $read_more_class, $read_more_text, false, true); if ($template_content) { $multipage = str_replace($this->get_tag('content', $template_content), $multipage, $template_content); } return $multipage; } } function create_url($folder_id, $file_id = 0) { $cms_site = new cms_site($this->site['id']); if ($this->publish_static) { $url = ''; if ($file_id == 0 && $folder_id > 0) { $cms_site->get_files($folder_id, 'priority', 'ASC'); while ($cms_site->next_record()) { if (eregi('htm', $cms_site->f('extension'))) { $file_id = $cms_site->f('id'); break; } } } if ($file_id > 0) { $file = $cms_site->get_file($file_id); $folder_id = $file['folder_id']; if ($folder_id != $this->site['root_folder_id']) { $url = urlencode(urlencode($file['name'])); } else { $url = 'index.html'; } } if ($folder_id > 0 && $folder_id != $this->site['root_folder_id']) { while ($folder_id != $this->site['root_folder_id']) { $folder = $cms_site->get_folder($folder_id); $url = urlencode(urlencode($folder['name'])).'/'.$url; $folder_id = $folder['parent_id']; } } return $this->publish_url.$url; } else { return $_SERVER['PHP_SELF'].'?folder_id='.$folder_id.'&file_id='.$file_id; } } function print_icon() { global $extension, $GO_CONFIG; return '<img border="0" align="absmiddle" src="'.get_filetype_image($extension).'" />'; } function print_home($attributes) { $text = isset ($attributes['text']) ? $attributes['text'] : ''; $template_name = isset ($attributes['template']) ? $attributes['template'] : ''; $active_template_name = isset ($attributes['active_template']) ? $attributes['active_template'] : $template_name; $class = isset ($attributes['class']) ? $attributes['class'] : ''; $active_class = isset ($attributes['active_class']) ? $attributes['active_class'] : $class; $print_at_home = isset ($attributes['print_at_home']) ? $attributes['print_at_home'] : 'true'; if ($this->folder_id == $this->language['root_folder_id'] ) { if($print_at_home != 'true') { return ''; } $template = $this->get_template_item_by_name($this->language['template_id'], $active_template_name); $class = $active_class ; } else { $template = $this->get_template_item_by_name($this->language['template_id'], $template_name); } $home = '<a class="'.$class.'" href="'.$_SERVER['PHP_SELF'].'?folder_id='.$this->language['root_folder_id'].'">'.$text.'</a>'; if ($template) { $template_content = $this->parse_template($template['content']); $home = str_replace($this->get_tag('content', $template_content), $home, $template_content); } return $home; } function print_path($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; $path = ''; $id = $this->folder_id; $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); $folder = $this->get_folder($id); while ($folder['parent_id'] != 0) { $item_template = ($this->folder_id == $id) ? $item_template_active : $item_template_passive; $_class = ($this->folder_id == $id) ? $active_class : $class; if ($item_template) { $item_template_content = $this->parse_template($item_template['content']); $path = str_replace($this->get_tag('content', $item_template_content), '<a class="'.$class.'" href="'.$this->create_url($folder['id']).'">'.$folder['name'].'</a>', $item_template_content).$path; } else { $path = '<a class="'.$_class.'" href="'.$this->create_url($folder['id']).'">'.$folder['name'].'</a>'.$path; } $id = $folder['parent_id']; $folder = $this->get_folder($id); } if ($template) { $template_content = $this->parse_template($template['content']); $path = str_replace($this->get_tag('content', $template_content), $path, $template_content); } return $path; } function print_active_doc($attributes) { global $extension; $template_name = isset ($attributes['template']) ? $attributes['template'] : ''; $class = isset ($attributes['class']) ? $attributes['class'] : ''; $current_file = ''; if (isset ($this->file_id) && $file = $this->get_file($this->file_id)) { $extension = get_extension($file['name']); $title = ($file['title'] == '') ? strip_extension($file['name']) : $file['title']; if ($template = $this->get_template_item_by_name($this->language['template_id'], $template_name)) { $current_file = $this->parse_template($template['content']); } $current_file = str_replace($this->get_tag('content', $current_file), '<span class="'.$class.'">'.$title.'</span>', $current_file); } return $current_file; } function print_languages($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; $print_text = isset ($attributes['print_text']) ? $attributes['print_text'] : 'true'; $print_image = isset ($attributes['print_image']) ? $attributes['print_image'] : 'true'; $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); $sections = ''; $count = $this->get_languages($this->site['id']); if ($count > 0) { while ($this->next_record()) { $item_template = ($this->f('id') == $this->language['id']) ? $active_item_template : $passive_item_template; $_class = ($this->f('id') == $this->folder_id) ? $active_class : $class; $link = '<a title="'.$this->f('name').'" class="'.$_class.'" href="'.$_SERVER['PHP_SELF'].'?language_id='.$this->f('id').'&folder_id='.$this->f('root_folder_id').'">'; if ($print_image == 'true' && $this->f('image_url') != '') { $link .= '<img src="'.$this->f('image_url').'" class="'.$_class.'" />'; } if ($print_text == 'true') { $link .= $this->f('name'); } $link .= '</a>'; if ($item_template) { $item_template_content = $this->parse_template($item_template['content']); $sections .= str_replace($this->get_tag('content', $item_template_content), $link, $item_template_content); } else { $sections .= $link; } } if ($template) { $template_content = $this->parse_template($template['content']); $sections = str_replace($this->get_tag('content', $template_content), $sections, $template_content); } } return $sections; } function print_folders($attributes) { $template_name = isset ($attributes['template']) ? $attributes['template'] : ''; $item_template_name = isset ($attributes['item_template']) ? $attributes['item_template'] : ''; $class = isset ($attributes['class']) ? $attributes['class'] : ''; $print_rootfolders = isset ($attributes['print_rootfolders']) ? $attributes['print_rootfolders'] : 'true'; $folders = ''; $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); if ($print_rootfolders == 'true' || $this->folder_id != $this->site['root_folder_id']) { $count = $this->get_visible_folders($this->folder_id); if ($count > 0) { while ($this->next_record()) { if ($item_template) { $item_template_content = $this->parse_template($item_template['content']); $folders .= str_replace($this->get_tag('content', $item_template_content), '<a class="'.$class.'" href="'.$this->create_url($this->f('id')).'" title="'.$this->f('name').'">'.$this->f('name').'</a>', $item_template_content); } else { $folders .= '<a class="'.$class.'" title="'.$this->f('name').'" 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; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -