コード例 #1
0
 /**
  *	Call parser function like {{#counter: Counter name | type = Counter type | set = 5 }}
  *
  **/
 public static function renderCounter(&$parser, $frame, $args)
 {
     self::$frame = $frame;
     $list = self::extractListOptions($args);
     if ($list['type'] === 'numeral') {
         return self::getNumeralValue($list);
     }
     if ($list['type'] === 'alpha') {
         return self::getAlphaValue($list);
     }
     if ($list['type'] === 'roman') {
         return self::getRomanValue($list);
     }
 }
コード例 #2
0
 /**
  *	Call parser function like {{#counter: Counter name | type = Counter type | set = 5 }}
  *
  **/
 public static function renderCounter(&$parser, $frame, $args)
 {
     self::$frame = $frame;
     $list = self::extractListOptions($args);
     // This if-statement determines if we're using standard or outline format
     // self::$lists[ $name ][ 'count' ] is the display for the counter.
     // The name sucks, but is here for now due to historical naming.
     if (!isset($list['format']) || $list['format'] == 'standard') {
         $sublist = $list['levels'][$list['level'] - 1];
         $listformat = array_intersect($list, array_flip(array('full level prefix', 'prefix', 'suffix')));
         $list = array_merge($listformat, $sublist);
         if ($list['type'] === 'numeral') {
             return self::getNumeralValue($list);
         }
         if ($list['type'] === 'alpha') {
             return self::getAlphaValue($list);
         }
         if ($list['type'] === 'roman') {
             return self::getRomanValue($list);
         }
     } else {
         $ret = htmlspecialchars($list['full level prefix'] . $list['prefix']);
         $defaultfmt = array('full level prefix' => '', 'prefix' => '', 'suffix' => '');
         for ($i = 0; $i < $list['level']; $i++) {
             $curList = array_merge($defaultfmt, $list['levels'][$i]);
             if ($i) {
                 $ret .= htmlspecialchars($list['glue']);
             }
             if ($curList['type'] === 'numeral') {
                 $ret .= self::getNumeralValue($curList);
             } elseif ($curList['type'] === 'alpha') {
                 $ret .= self::getAlphaValue($curList);
             } else {
                 if ($curList['type'] === 'roman') {
                     $ret .= self::getRomanValue($curList);
                 }
             }
         }
         return $ret . htmlspecialchars($list['suffix']);
     }
 }