/** * Block Plugin Main Function */ function convert() { sonots::init_myerror(); do { // try global $vars, $defaultpage; $args = func_get_args(); $line = csv_implode(',', $args); $options = PluginSonotsOption::parse_option_line($line); list($options, $unknowns) = PluginSonotsOption::evaluate_options($options, $this->conf_options); $current = isset($vars['page']) ? $vars['page'] : $defaultpage; $page = isset($options['page']) ? $options['page'] : $current; $page = PluginContentsx::check_page($page, $current); $options = PluginContentsx::check_options($page, $current, $options, $unknowns); if (sonots::mycatch()) { break; } $html = PluginContentsx::display_toc($page, $options); if ($html != '') { $html = '<table border="0" class="toc"><tbody>' . "\n" . '<tr><td class="toctitle">' . "\n" . '<span>' . _('Table of Contents') . "</span>\n" . "</td></tr>\n" . '<tr><td class="toclist">' . "\n" . $html . "</td></tr>\n" . "</tbody></table>\n"; } return $html; } while (false); if (sonots::mycatch()) { // catch return '<p>#contentsx(): ' . sonots::mycatch() . '</p>'; } }
/** * Block Plugin Main Function */ function convert() { sonots::init_myerror(); do { // try $args = func_get_args(); $argline = csv_implode(',', $args); $argoptions = PluginSonotsOption::parse_option_line($argline); list($options, $unknowns) = PluginSonotsOption::evaluate_options($argoptions, $this->conf_options); $options = $this->check_options($options, $unknowns, $this->conf_options); if (sonots::mycatch()) { break; } if (isset($options['tag'])) { $plugin_tag = new PluginSonotsTag(); $pages = $plugin_tag->get_taggedpages($options['tag']); } elseif (isset($options['prefix'])) { $pages = sonots::get_existpages($options['prefix']); } else { $pages = get_existpages(); } $pagelist = $this->pagelist($pages, $options, $argoptions); $navipages = $this->get_navipages($pagelist, $options); $html = $this->display_navi($navipages, $options['look'], $options['border'], $this->conf['printcss']); return $html; } while (false); if (sonots::mycatch()) { // catch return '<p>#' . $this->plugin . '(): ' . sonots::mycatch() . '</p>'; } }
/** * Block Plugin Main Function */ function convert() { sonots::init_myerror(); do { // try $args = func_get_args(); $argline = csv_implode(',', $args); $argoptions = PluginSonotsOption::parse_option_line($argline); list($options, $unknowns) = PluginSonotsOption::evaluate_options($argoptions, $this->conf_options); $options = $this->check_options($options, $unknowns, $this->conf_options); if (sonots::mycatch()) { break; } if (isset($options['tag'])) { $plugin_tag = new PluginSonotsTag(); $pages = $plugin_tag->get_taggedpages($options['tag']); $html = $this->pagelist($pages, $options, $argoptions); } else { $plugin_tag = new PluginSonotsTag(); if (isset($options['related'])) { $tags = $plugin_tag->get_related_tags($options['related']); } else { $tags = $plugin_tag->get_existtags(); } $html = $this->tagpagelist($tags, $options, $argoptions); } return $html; } while (false); if (sonots::mycatch()) { // catch return '<p>#' . $this->plugin . '(): ' . sonots::mycatch() . '</p>'; } }
/** * Block Plugin Main Function */ function convert() { sonots::init_myerror(); do { // try $args = func_get_args(); $argline = csv_implode(',', $args); $argoptions = PluginSonotsOption::parse_option_line($argline); list($options, $unknowns) = PluginSonotsOption::evaluate_options($argoptions, $this->conf_options); $options = $this->check_options($options, $unknowns, $this->conf_options); if (sonots::mycatch()) { break; } $pages = get_existpages(); $html = $this->pagelist($pages, $options, $argoptions); if (empty($html)) { $html = '<p>' . _('No page found.') . '</p>'; } return $html; } while (false); if (sonots::mycatch()) { // catch return '<p>#' . $this->plugin . '(): ' . sonots::mycatch() . '</p>'; } }
/** * Convert Plugin Main Function */ function convert() { global $vars, $defaultpage; sonots::init_myerror(); do { // try $args = func_get_args(); $inclpage = array_shift($args); $current = isset($vars['page']) ? $vars['page'] : $defaultpage; $this->visited[$current] = TRUE; $inclpage = PluginIncludex::check_page($inclpage, $current, $this->visited); if (sonots::mycatch()) { break; } $this->visited[$inclpage] = TRUE; $argline = csv_implode(',', $args); $argoptions = PluginSonotsOption::parse_option_line($argline); list($options, $unknowns) = PluginSonotsOption::evaluate_options($argoptions, $this->conf_options); $options = PluginIncludex::check_options($options, $unknowns, $argoptions); if (sonots::mycatch()) { break; } $html = PluginIncludex::display_include($inclpage, $options, $this->syntax); return $html; } while (false); if (sonots::mycatch()) { // catch return '</p>#includex(): ' . sonots::mycatch() . '</p>'; } }
function plugin_gcounter_convert() { if (!exist_plugin_convert('counter')) { return '<p>gcounter(): counter plugin does not exist.</p>'; } if (plugin_gcounter_init_gcounter() === FALSE) { return '<p>gcounter(): failed to create gcounter log file.</p>'; } global $vars; $tmp = $vars['page']; $vars['page'] = PLUGIN_GCOUNTER_PAGE; $args = func_get_args(); $body = do_plugin_convert('counter', csv_implode(',', $args)); $vars['page'] = $tmp; return $body; }
function save_time() { $pages = $this->get_pages(); $contents = ""; if (!($fp = fopen($this->cachefile, "w"))) { return "<p><b>timestamp cache file, {$this->cachefile}, can not open. </b></p>"; } foreach ($pages as $page) { $mtime = filemtime(get_filename($page)); $contents .= csv_implode(',', array($page, $mtime)) . "\n"; } if (!fwrite($fp, $contents)) { return "<p><b>can not write to timestamp cache file, {$this->cachefile}. </b></p>"; } fclose($fp); return "<p><b>timestamp cache file, {$this->cachefile}, was created. </b></p>"; }
function write_cache($apage) { if ($this->options['cache'][1] == 'off') { return; } if (!is_page($apage)) { return; } $cache = $this->get_cache_filename($apage); if ($this->file_exists($cache) && !$this->is_writable($cache)) { $this->error = "Cache file, {$cache} is not writable. "; return; } $pages = array(); foreach ($this->visited as $page => $title) { $pages[] = csv_implode('=', array($page, $title)); } $contents = ''; $contents .= csv_implode(',', $pages) . "\n"; foreach ($this->metalines as $metaline) { $metas = array(); foreach ($metaline as $key => $val) { $metas[] = "{$key}={$val}"; } $contents .= csv_implode(',', $metas) . "\n"; } // file_put_contents($cache, $contents); // PHP5 if (!($fp = fopen($cache, "w"))) { $this->error = "Can not open {$cache}. "; return; } if (!fwrite($fp, $contents)) { $this->error = "Can not write to {$cache}. "; return; } fclose($fp); }
function get_ref_html($args, $div = TRUE) { global $xpwiki; mb_convert_variables($xpwiki->cont['SOURCE_ENCODING'], 'UTF-8', $args); if (!$div) { $retvar = $xpwiki->func->do_plugin_inline('ref', csv_implode(',', $args)); } else { $retvar = $xpwiki->func->do_plugin_convert('ref', csv_implode(',', $args)); } $retvar = mb_convert_encoding($retvar, 'UTF-8', $xpwiki->cont['SOURCE_ENCODING']); $retvar = trim(preg_replace('#</?a[^>]*?' . '>#is', '', $retvar)); return $retvar; }
/** * Recent Voted * * @param string $page voted page * @param string $pcmd convert or inline * @param integer $vote_id * @param integer $choice_id * @param array $votes * @return void */ function update_recent_voted($page, $pcmd, $vote_id, $choice_id, $votes) { $limit = max(0, $this->CONF['RECENT_LIMIT']); $time = UTIME; // RecentVoted $lines = get_source($this->CONF['RECENT_PAGE']); $anchor = $this->get_anchor($pcmd, $vote_id); $args = array(); foreach ($votes as $vote) { list($choice, $count) = $vote; $args[] = $choice . '[' . $count . ']'; } $arg = csv_implode(',', $args); list($choice, $count) = $votes[$choice_id]; $addline = '-' . format_date($time) . ' - [[' . $page . '#' . $vote_id . '>' . $page . '#' . $anchor . ']] ' . $choice . ' (' . $arg . ')' . "\n"; array_unshift($lines, $addline); $lines = array_splice($lines, 0, $limit); page_write($this->CONF['RECENT_PAGE'], implode('', $lines)); // recentvoted.dat (serialization) if (is_readable($this->CONF['RECENT_LOG'])) { $log_contents = file_get_contents($this->CONF['RECENT_LOG']); $logs = unserialize($log_contents); } else { $logs = array(); } $addlog = array($time, $page, $pcmd, $vote_id, $choice_id, $votes); array_unshift($logs, $addlog); $logs = array_splice($logs, 0, $limit); file_put_contents($this->CONF['RECENT_LOG'], serialize($logs)); }
function list_pages() { global $script; if (sizeof($this->metapages) == 0) { return; } /* HTML validate (without <ul><li style="list-type:none"><ul><li>, we have to do as <ul><li style="padding-left:16*2px;margin-left:16*2px"> as pukiwiki standard. I did not like it) <ul> <ul><li>1 <li>1</li> </li><li>1 <li>1 <ul><li>2 <ul> </li></ul></li><li>1 <li>2</li> </li><li>1 </ul> => <ul><li style="list-type:none"><ul><li>3 </li> </li></ul></li></ul></li></ul> <li>1</li> <li>1</li> <ul><li style="list-type:none"><ul> <li>3</li> </ul></li></ul> </li> </ul> */ $ul = $pdepth = 0; foreach ($this->metapages as $i => $metapage) { $page = $metapage['page']; $exist = $metapage['exist']; $depth = $metapage['listdepth']; $info = $metapage['info']; $link = $metapage['link']; if ($exist && $this->options['include'][1] != '') { $option = '"' . $page . '"'; if (!empty($this->options['include'][1])) { $option .= ',' . csv_implode(',', $this->options['include'][1]); } $html .= do_plugin_convert($this->conf['plugin_include'], $option); continue; } if ($depth > $pdepth) { $diff = $depth - $pdepth; $html .= str_repeat('<ul><li style="list-style:none">', $diff - 1); if ($depth == 1) { // or $first flag $html .= '<ul class="' . $this->plugin . '"><li>'; } else { $html .= '<ul><li>'; } $ul += $diff; } elseif ($depth == $pdepth) { $html .= '</li><li>'; } elseif ($depth < $pdepth) { $diff = $pdepth - $depth; $html .= str_repeat('</li></ul>', $diff); $html .= '</li><li>'; $ul -= $diff; } $pdepth = $depth; $html .= $link; if (isset($info) && $info != '') { $html .= '<span class="lsx_info">' . $info . '</span>' . "\n"; } if ($exist && $this->options['contents'][1] != '') { $args = $this->options['contents'][1]; $pagearg = 'page=' . $page; array_unshift($args, $pagearg); $contentsx = new PluginContentsx(); $html .= call_user_func(array($contentsx, 'body'), $args); } } $html .= str_repeat('</li></ul>', $ul); return $html; }
function write_cache($apage) { $qm = get_qm(); if ($this->options['cache'][1] == 'off') { return; } if (!is_page($apage)) { return; } $cache = CACHE_DIR . encode($apage) . ".{$this->plugin}"; if ($this->file_exists($cache) && !$this->is_writable($cache)) { $this->error = $qm->replace('plg_contentsx.err_cache_not_writable', $cache); return; } $pages = array(); foreach ($this->visited as $page => $title) { $pages[] = csv_implode('=', array($page, $title)); } $contents = ''; $contents .= csv_implode(',', $pages) . "\n"; foreach ($this->metalines as $metaline) { $metas = array(); foreach ($metaline as $key => $val) { $metas[] = "{$key}={$val}"; } $contents .= csv_implode(',', $metas) . "\n"; } // file_put_contents($cache, $contents); // PHP5 if (!($fp = fopen($cache, "w"))) { $this->error = $qm->replace('plg_contentsx.err_cache_cannot_open', $cache); return; } if (!fwrite($fp, $contents)) { $this->error = $qm->replace('plg_contentsx.err_cache_cannot_write', $cache); return; } fclose($fp); }
function write_updatelist($list) { $datfile = CACHE_DIR . 'updateplugin.dat'; $contents = ''; foreach ($list as $plugin => $info) { $metas = array(); foreach ($info as $key => $val) { $metas[] = "{$key}={$val}"; } $contents .= csv_implode(',', $metas) . "\n"; } return $this->file_put_contents($datfile, $contents); }