/**
  * @param Parser $parser
  * @param string $date
  * @param string $defaultPref
  *
  * @return string
  */
 static function formatDate($parser, $date, $defaultPref = null)
 {
     $lang = $parser->getFunctionLang();
     $df = DateFormatter::getInstance($lang);
     $date = trim($date);
     $pref = $parser->getOptions()->getDateFormat();
     // Specify a different default date format other than the the normal default
     // if the user has 'default' for their setting
     if ($pref == 'default' && $defaultPref) {
         $pref = $defaultPref;
     }
     $date = $df->reformat($pref, $date, array('match-whole'));
     return $date;
 }
 /**
  * @param Parser $parser
  * @param string $text
  * @return string
  */
 public static function bidi($parser, $text = '')
 {
     return $parser->getFunctionLang()->embedBidi($text);
 }
 /**
  * Return the size of the given page, or 0 if it's nonexistent.  This is an
  * expensive parser function and can't be called too many times per page.
  *
  * @param Parser $parser
  * @param string $page Name of page to check (Default: empty string)
  * @param string $raw Should number be human readable with commas or just number
  * @return string
  */
 public static function pagesize($parser, $page = '', $raw = null)
 {
     $title = Title::newFromText($page);
     if (!is_object($title)) {
         return self::formatRaw(0, $raw, $parser->getFunctionLang());
     }
     // fetch revision from cache/database and return the value
     $rev = self::getCachedRevisionObject($parser, $title);
     $length = $rev ? $rev->getSize() : 0;
     if ($length === null) {
         // We've had bugs where rev_len was not being recorded for empty pages, see T135414
         $length = 0;
     }
     return self::formatRaw($length, $raw, $parser->getFunctionLang());
 }
 /**
  * @param Parser $parser
  * @param string $text
  * @return string
  */
 public static function plural($parser, $text = '')
 {
     $forms = array_slice(func_get_args(), 2);
     $text = $parser->getFunctionLang()->parseFormattedNumber($text);
     settype($text, ctype_digit($text) ? 'int' : 'float');
     return $parser->getFunctionLang()->convertPlural($text, $forms);
 }