⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 style.cls.php

📁 国外很不错的一个开源OA系统Group-Office
💻 PHP
📖 第 1 页 / 共 3 页
字号:
      $b = 0x80;      break;    case "fuchsia":      $r = 0xff;      $b = 0xff;      break;    case "white":      $r = $g = $b = 0xff;      break;    case "lime":      $g = 0xff;      break;    case "green":      $g = 0x80;      break;    case "navy":      $b = 0x80;      break;    case "blue":      $b = 0xff;      break;    case "aqua":      $g = 0xff;      $b = 0xff;      break;    case "teal":      $g = 0x80;      $b = 0x80;      break;    case "black":      break;    case "sliver":      $r = $g = $b = 0xc0;      break;    case "gray":    case "grey":      $r = $g = $b = 0x80;      break;    case "transparent":      return "transparent";          default:      if ( mb_strlen($colour) == 4 && $colour{0} == "#" ) {        // #rgb format        $r = hexdec($colour{1} . $colour{1});        $g = hexdec($colour{2} . $colour{2});        $b = hexdec($colour{3} . $colour{3});      } else if ( mb_strlen($colour) == 7 && $colour{0} == "#" ) {        // #rrggbb format        $r = hexdec(mb_substr($colour, 1, 2));        $g = hexdec(mb_substr($colour, 3, 2));        $b = hexdec(mb_substr($colour, 5, 2));      } else if ( mb_strpos($colour, "rgb") !== false ) {        // rgb( r,g,b ) format        $i = mb_strpos($colour, "(");        $j = mb_strpos($colour, ")");                // Bad colour value        if ($i === false || $j === false)          return null;        $triplet = explode(",", mb_substr($colour, $i+1, $j-$i-1));        if (count($triplet) != 3)          return null;                foreach (array_keys($triplet) as $c) {          $triplet[$c] = trim($triplet[$c]);                    if ( $triplet[$c]{mb_strlen($triplet[$c]) - 1} == "%" )             $triplet[$c] = round($triplet[$c] * 0.255);        }        list($r, $g, $b) = $triplet;      } else {        // Who knows?        return null;      }            // Clip to 0 - 1      $r = $r < 0 ? 0 : ($r > 255 ? 255 : $r);      $g = $g < 0 ? 0 : ($g > 255 ? 255 : $g);      $b = $b < 0 ? 0 : ($b > 255 ? 255 : $b);      break;          }        // Form array    $arr = array(0 => $r / 0xff, 1 => $g / 0xff, 2 => $b / 0xff,                 "r"=>$r / 0xff, "g"=>$g / 0xff, "b"=>$b / 0xff,                 "hex" => sprintf("#%02X%02X%02X", $r, $g, $b));    return $arr;        }    /**   * Alias for {@link Style::munge_colour()}   *   * @param string $color   * @return array   */  function munge_color($color) { return $this->munge_colour($color); }      /**   * PHP5 overloaded setter   *   * This function along with {@link Style::__get()} permit a user of the   * Style class to access any (CSS) property using the following syntax:   * <code>   *  Style->margin_top = "1em";   *  echo (Style->margin_top);   * </code>   *   * __set() automatically calls the provided set function, if one exists,   * otherwise it sets the property directly.  Typically, __set() is not   * called directly from outside of this class.   *   * @param string $prop  the property to set   * @param mixed  $val   the value of the property   *    */  function __set($prop, $val) {    global $_dompdf_warnings;    $prop = str_replace("-", "_", $prop);    $this->_prop_cache[$prop] = null;        if ( !isset(self::$_defaults[$prop]) ) {      $_dompdf_warnings[] = "'$prop' is not a valid CSS2 property.";      return;    }        if ( $prop !== "content" && is_string($val) && mb_strpos($val, "url") === false ) {      $val = mb_strtolower(trim(str_replace(array("\n", "\t"), array(" "), $val)));      $val = preg_replace("/([0-9]+) (pt|px|pc|em|ex|in|cm|mm|%)/S", "\\1\\2", $val);    }        $method = "set_$prop";    if ( method_exists($this, $method) )      $this->$method($val);    else       $this->_props[$prop] = $val;      }  /**   * PHP5 overloaded getter   *   * Along with {@link Style::__set()} __get() provides access to all CSS   * properties directly.  Typically __get() is not called directly outside   * of this class.   *   * @param string $prop   * @return mixed   */  function __get($prop) {        if ( !isset(self::$_defaults[$prop]) )       throw new DOMPDF_Exception("'$prop' is not a valid CSS2 property.");    if ( isset($this->_prop_cache[$prop]) )      return $this->_prop_cache[$prop];        $method = "get_$prop";    // Fall back on defaults if property is not set    if ( !isset($this->_props[$prop]) )      $this->_props[$prop] = self::$_defaults[$prop];    if ( method_exists($this, $method) )      return $this->_prop_cache[$prop] = $this->$method();    return $this->_prop_cache[$prop] = $this->_props[$prop];  }  /**   * Getter for the 'font-family' CSS property.   *   * Uses the {@link Font_Metrics} class to resolve the font family into an   * actual font file.   *   * @link http://www.w3.org/TR/CSS21/fonts.html#propdef-font-family   * @return string   */  function get_font_family() {    // Select the appropriate font.  First determine the subtype, then check    // the specified font-families for a candidate.    // Resolve font-weight    $weight = $this->__get("font_weight");        if ( is_numeric($weight) ) {      if ( $weight < 700 )        $weight = "normal";      else        $weight = "bold";    } else if ( $weight == "bold" || $weight == "bolder" ) {      $weight = "bold";    } else {      $weight = "normal";    }    // Resolve font-style    $font_style = $this->__get("font_style");    if ( $weight == "bold" && $font_style == "italic" )      $subtype = "bold_italic";    else if ( $weight == "bold" && $font_style != "italic" )      $subtype = "bold";    else if ( $weight != "bold" && $font_style == "italic" )      $subtype = "italic";    else      $subtype = "normal";        // Resolve the font family    $families = explode(",", $this->_props["font_family"]);    reset($families);    $font = null;    while ( current($families) ) {      list(,$family) = each($families);      $font = Font_Metrics::get_font($family, $subtype);      if ( $font )        return $font;    }    throw new DOMPDF_Exception("Unable to find a suitable font replacement for: '" . $this->_props["font_family"] ."'");      }  /**   * Returns the resolved font size, in points   *   * @link http://www.w3.org/TR/CSS21/fonts.html#propdef-font-size      * @return float   */  function get_font_size() {    if ( $this->__font_size_calculated )      return $this->_props["font_size"];        if ( !isset($this->_props["font_size"]) )      $fs = self::$_defaults["font_size"];    else       $fs = $this->_props["font_size"];        if ( !isset($this->_parent_font_size) )      $this->_parent_font_size = self::$default_font_size;        switch ($fs) {          case "xx-small":      $fs = 3/5 * $this->_parent_font_size;      break;    case "x-small":      $fs = 3/4 * $this->_parent_font_size;      break;    case "smaller":    case "small":      $fs = 8/9 * $this->_parent_font_size;      break;    case "medium":      $fs = $this->_parent_font_size;      break;    case "larger":    case "large":      $fs = 6/5 * $this->_parent_font_size;      break;    case "x-large":      $fs = 3/2 * $this->_parent_font_size;      break;    case "xx-large":      $fs = 2/1 * $this->_parent_font_size;      break;    default:      break;    }    // Ensure relative sizes resolve to something    if ( ($i = mb_strpos($fs, "em")) !== false )       $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size;    else if ( ($i = mb_strpos($fs, "ex")) !== false )       $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size;    else      $fs = $this->length_in_pt($fs);    $this->_props["font_size"] = $fs;        $this->__font_size_calculated = true;    return $this->_props["font_size"];  }  /**   * @link http://www.w3.org/TR/CSS21/text.html#propdef-word-spacing   * @return float   */  function get_word_spacing() {    if ( $this->_props["word_spacing"] === "normal" )      return 0;    return $this->_props["word_spacing"];  }  /**   * @link http://www.w3.org/TR/CSS21/visudet.html#propdef-line-height   * @return float   */  function get_line_height() {    if ( $this->_props["line_height"] === "normal" )      return self::$default_line_height * $this->get_font_size();    if ( is_numeric($this->_props["line_height"]) )       return $this->length_in_pt( $this->_props["line_height"] . "%", $this->get_font_size());        return $this->length_in_pt( $this->_props["line_height"], $this->get_font_size() );  }  /**   * Returns the colour as an array   *   * The array has the following format:   * <code>array(r,g,b, "r" => r, "g" => g, "b" => b, "hex" => "#rrggbb")</code>   *   * @link http://www.w3.org/TR/CSS21/colors.html#propdef-color   * @return array   */  function get_color() {    return $this->munge_color( $this->_props["color"] );  }  /**   * Returns the background colour as an array   *   * The returned array has the same format as {@link Style::get_color()}   *   * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-color   * @return array   */  function get_background_color() {    return $this->munge_color( $this->_props["background_color"] );  }    /**   * Returns the background position as an array   *   * The returned array has the following format:   * <code>array(x,y, "x" => x, "y" => y)</code>   *   * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-position   * @return array   */  function get_background_position() {        $tmp = explode(" ", $this->_props["background_position"]);    switch ($tmp[0]) {    case "left":      $x = "0%";      break;    case "right":      $x = "100%";      break;    case "top":      $y = "0%";      break;    case "bottom":      $y = "100%";      break;    case "center":      $x = "50%";      $y = "50%";      break;    default:      $x = $tmp[0];      break;    }    if ( isset($tmp[1]) ) {      switch ($tmp[1]) {      case "left":        $x = "0%";        break;              case "right":        $x = "100%";        break;              case "top":        $y = "0%";        break;              case "bottom":        $y = "100%";        break;              case "center":        if ( $tmp[0] == "left" || $tmp[0] == "right" || $tmp[0] == "center" )          $y = "50%";        else          $x = "50%";        break;              default:        $y = $tmp[1];        break;      }    } else {      $y = "50%";    }    if ( !isset($x) )      $x = "0%";    if ( !isset($y) )      $y = "0%";    return array( 0 => $x, "x" => $x,                  1 => $y, "y" => $y );  }                     /**#@+   * Returns the border colour as an array   *   * See {@link Style::get_color()}   *   * @link http://www.w3.org/TR/CSS21/box.html#border-color-properties   * @return array   */  function get_border_top_color() {    if ( $this->_props["border_top_color"] === "" )      $this->_props["border_top_color"] = $this->__get("color");        return $this->munge_color($this->_props["border_top_color"]);  }  function get_border_right_color() {    if ( $this->_props["border_right_color"] === "" )      $this->_props["border_right_color"] = $this->__get("color");    return $this->munge_color($this->_props["border_right_color"]);  }  function get_border_bottom_color() {    if ( $this->_props["border_bottom_color"] === "" )      $this->_props["border_bottom_color"] = $this->__get("color");    return $this->munge_color($this->_props["border_bottom_color"]);;  }  function get_border_left_color() {    if ( $this->_props["border_left_color"] === "" )      $this->_props["border_left_color"] = $this->__get("color");    return $this->munge_color($this->_props["border_left_color"]);  }    /**#@-*/ /**#@+   * Returns the border width, as it is currently stored   *   * @link http://www.w3.org/TR/CSS21/box.html#border-width-properties   * @return float|string      */  function get_border_top_width() {    $style = $this->__get("border_top_style");    return $style !== "none" && $style !== "hidden" ? $this->length_in_pt($this->_props["border_top_width"]) : 0;  }    function get_border_right_width() {    $style = $this->__get("border_right_style");        return $style !== "none" && $style !== "hidden" ? $this->length_in_pt($this->_props["border_right_width"]) : 0;  }  function get_border_bottom_width() {    $style = $this->__get("border_bottom_style");    return $style !== "none" && $style !== "hidden" ? $this->length_in_pt($this->_props["border_bottom_width"]) : 0;  }  function get_border_left_width() {    $style = $this->__get("border_left_style");    return $style !== "none" && $style !== "hidden" ? $this->length_in_pt($this->_props["border_left_width"]) : 0;  }  /**#@-*/  /**   * Return an array of all border properties.   *   * The returned array has the following structure:   * <code>   * array("top" => array("width" => [border-width],   *                      "style" => [border-style],   *                      "color" => [border-color (array)]),   *       "bottom" ... )   * </code>   *   * @return array   */  function get_border_properties() {    return array("top" => array("width" => $this->__get("border_top_width"),                                "style" => $this->__get("border_top_style"),                                "color" => $this->__get("border_top_color")),

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -