コード例 #1
0
  static function color_getColorData($page_title, $page_id = 0, $rev_id = 0)
  {
    $ctx = stream_context_create(
        array('http' => array(
          'timeout' => self::TRUST_TIMEOUT,
           ))
    );

    $MAX_TIMES_THROUGH = 2;
    $times_though=0;
    global $wgUser, $wgWikiTrustContentServerURL;
    $username = $wgUser->getName();

    $url = $wgWikiTrustContentServerURL
      . "?method=wikiorhtml"
      . "&revid=" . urlencode($rev_id)
      . "&pageid=" . urlencode($page_id)
      . "&title=" . urlencode($page_title)
      . "&time=" . urlencode(wfTimestampNow())
      . "&username="******":".__LINE__.": $url");

    $colored_raw = (file_get_contents($url, 0, $ctx));

    if (!$colored_raw)
      return '';

    $mode = substr($colored_raw, 0, 1);
    $colored_text = substr($colored_raw, 1);
   
    if (!$colored_text
        || $colored_raw == self::NOT_FOUND_TEXT_TOKEN
        || $colored_raw == "bad")
      {
        return '';
      }
   
    // Are we using HTML or WIKI
    if ($mode == WIKITRUST_HTML){
      // The HTML is all rendered -- we just display this.
      self::$html_rendered = true;
      return $colored_text;
    }
    // Pick off the median value first.
    $colored_data = explode(",", $colored_text, 2);
    $colored_new = $colored_data[1];
    self::$median = $colored_data[0] + 0;
    if (self::$median == 0)
        self::$median = self::TRUST_DEFAULT_MEDIAN;

    return $colored_new;
  }