Пример #1
0
 /**
  * Inline Plugin Main Function
  */
 function inline()
 {
     static $tagging = FALSE;
     if (func_num_args() == 0) {
         return 'tag(): no argument(s). ';
     }
     global $vars, $defaultpage;
     $page = isset($vars['page']) ? $vars['page'] : $defaultpage;
     $args = func_get_args();
     array_pop($args);
     // drop {}
     $tags = $args;
     $tags = sonots::trim_array($tags, true, true);
     $pkwk_tag = new PluginSonotsTag();
     if ($tagging) {
         // 2nd call
         $pkwk_tag->add_tags($page, $tags);
     } elseif (isset($vars['preview']) || isset($vars['realview']) || sonots::is_page_newer($page, PluginSonotsTag::get_tags_filename($page))) {
         $pkwk_tag->save_tags($page, $tags);
         $tagging = TRUE;
     }
     return $this->display_tagging($tags);
 }
Пример #2
0
 /**
  * trim elements of array
  *
  * PHP API Extension
  *
  * @access public
  * @static
  * @param array $array
  * @param boolean $recursive recursively
  * @param boolean $trimkey trim key too
  * @return array
  * @version $Id: v 1.0 2008-06-05 11:14:46 sonots $
  */
 function trim_array($array, $recursive = false, $trimkey = false)
 {
     $outarray = array();
     foreach ($array as $key => $val) {
         unset($array[$key]);
         // save memory
         if ($recursive && is_array($val)) {
             $val = sonots::trim_array($val, $recursive, $trimkey);
         } elseif (is_string($val)) {
             $val = trim($val);
         }
         if ($trimkey && is_string($key)) {
             $key = trim($key);
         }
         $outarray[$key] = $val;
     }
     return $outarray;
 }
Пример #3
0
 /**
  * Parse option line as followings:
  *
  * Rule)
  * <code>
  * , is used to separate options.
  * = is used to separate option key (name) and option value.
  * () is used if element is an array.
  * </code>
  *
  * Example)
  * <code>
  *  $line = 'prefix=Hoge/,num=1:5,contents=(num=1,depth=1),hoge';
  *  $options = PluginSonotsOption::parse_option_line($line);
  *  var_export(); 
  *  // array('prefix'=>'Hoge/','num'=>'1:5',
  *  // 'contents'=>array('num'=>'1','depth'=>'1'),'hoge'=>true);
  *  // () becomes an array()
  *  // Option which does not have "=[value]" is set to TRUE anyway. 
  * </code>
  *
  * parse_option_line is upper version of the simple 
  * sonots::parse_options($args).  parse_options does not support 
  * array arguments, but parse_option_line does. 
  * Except array arguments, both should be able to generate 
  * the same results. 
  *
  * FYI) Decoding is required especially when key/val values include
  * delimiter characters, '=', ',', '(', and ')'. Usually use true. 
  *
  * @access public
  * @static
  * @param string $line
  * @param boolean $trim trim option key/val
  * @param boolean $decode perform decode key/val
  * @return array array of options
  * @uses sonots::string_to_array
  * @uses numeric_to_boolean
  * @see glue_option_line
  * @see sonots::parse_options
  * @version $Id: v 1.5 2008-06-07 11:14:46 sonots $
  * @since   v 1.0
  */
 function parse_option_line($line, $trim = false, $decode = true)
 {
     $array = sonots::string_to_array($line, '=', ',', '(', ')', $decode);
     $options = PluginSonotsOption::numeric_to_boolean($array);
     if ($trim) {
         $options = sonots::trim_array($options, true, true);
     }
     return $options;
 }