function test_parse_options()
 {
     $args = array('str=hoge', 'bool');
     $parse = sonots::parse_options($args);
     $truth = array('str' => 'hoge', 'bool' => TRUE);
     $this->assertEqual($parse, $truth);
     $conf_options = array('str' => 'foobar', 'bool' => FALSE);
     // default
     $args = array('bool', 'unknown=hoge');
     $parse = sonots::parse_options($args, $conf_options);
     $truth = array('str' => 'foobar', 'bool' => TRUE);
     // unknown is not set
     $this->assertEqual($parse, $truth);
 }
/**
 * Get TITLE: line or the first headline of a page
 *
 * Usage:
 * - &get_title(page,[option])
 * Option
 * - firsthead Get the first headline instead of title
 *
 * @package    plugin
 * @license    http://www.gnu.org/licenses/gpl.html GPL v2
 * @author     sonots
 * @link       http://lsx.sourceforge.jp/?Plugin%2Fget_title.inc.php
 * @version    $Id: get_title.inc.php,v 2.0 2008-07-30 16:28:39Z sonots $
 */
function plugin_get_title_inline()
{
    $args = func_get_args();
    array_pop($args);
    $page = array_shift($args);
    $conf_options = array('firsthead' => false);
    $options = sonots::parse_options($args, $conf_options);
    if ($options['firsthead']) {
        $str = PluginSonotsMetapage::firsthead($page);
    } else {
        $str = PluginSonotsMetapage::title($page);
    }
    if (is_null($str)) {
        $str = $page;
    }
    $str = strip_htmltag(make_link($str));
    return $str;
}
 function convert()
 {
     $args = func_get_args();
     $options = $this->conf_options;
     $options = sonots::parse_options($args, $options);
     // check_options
     if ($options['limit'] === "0") {
         $options['limit'] = NULL;
     }
     if ($options['cloud'] === 'off' || $options['cloud'] === 'false') {
         $options['cloud'] = FALSE;
     }
     //print_r($options);
     $plugin_tag = new PluginSonotsTag();
     if ($options['cloud']) {
         $html = $plugin_tag->display_tagcloud($options['limit'], $options['related']);
     } else {
         $html = $plugin_tag->display_taglist($options['limit'], $options['related']);
     }
     return $html;
 }
Esempio n. 4
0
 /**
  * Convert Includeline to Headline
  *
  * @return PluginSonotsHeadline
  */
 function headline($usecache = true)
 {
     $linenum = $this->linenum;
     $depth = 0;
     $options = sonots::parse_options($this->args, array('titlestr' => 'title'));
     $string = PluginSonotsMetapage::linkstr($this->page, $options['titlestr'], $usecache);
     $anchor = sonots::make_pageanchor($this->page);
     return new PluginSonotsHeadline($this->page, $linenum, $depth, $string, $anchor);
 }