本文整理汇总了PHP中CSS::get_handler方法的典型用法代码示例。如果您正苦于以下问题:PHP CSS::get_handler方法的具体用法?PHP CSS::get_handler怎么用?PHP CSS::get_handler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSS
的用法示例。
在下文中一共展示了CSS::get_handler方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _fix_tag_display
function _fix_tag_display($default_display, &$state, &$pipeline)
{
// In some cases 'display' CSS property should be ignored for element-generated boxes
// Here we will use the $default_display stored above
// Note that "display: none" should _never_ be changed
//
$handler =& CSS::get_handler(CSS_DISPLAY);
if ($handler->get($state->getState()) === "none") {
return;
}
switch ($default_display) {
case 'table-cell':
// TD will always have 'display: table-cell'
$handler->css('table-cell', $pipeline);
break;
case '-button':
// INPUT buttons will always have 'display: -button' (in latter case if display = 'block', we'll use a wrapper box)
$css_state =& $pipeline->getCurrentCSSState();
if ($handler->get($css_state->getState()) === 'block') {
$need_block_wrapper = true;
}
$handler->css('-button', $pipeline);
break;
}
}
示例2: parse
function parse($value)
{
if ($value == 'inherit') {
return CSS_PROPERTY_INHERIT;
}
// Remove spaces between color values in rgb() color definition; this will allow us to tread
// this declaration as a single value
$value = preg_replace("/\\s*,\\s*/", ",", $value);
// Remove spaces before and after parens in rgb color definition
$value = preg_replace("/rgb\\s*\\(\\s*(.*?)\\s*\\)/", 'rgb(\\1)', $value);
$subvalues = explode(" ", $value);
$border = CSS::getDefaultValue(CSS_BORDER);
foreach ($subvalues as $subvalue) {
$subvalue = trim(strtolower($subvalue));
switch (CSSBorder::detect_border_value_type($subvalue)) {
case BORDER_VALUE_COLOR:
$color_handler = CSS::get_handler(CSS_BORDER_COLOR);
$border_color = $color_handler->parse($subvalue);
$color_handler->setValue($border, $border_color);
break;
case BORDER_VALUE_WIDTH:
$width_handler = CSS::get_handler(CSS_BORDER_WIDTH);
$border_width = $width_handler->parse($subvalue);
$width_handler->setValue($border, $border_width);
break;
case BORDER_VALUE_STYLE:
$style_handler = CSS::get_handler(CSS_BORDER_STYLE);
$border_style = $style_handler->parse($subvalue);
$style_handler->setValue($border, $border_style);
break;
}
}
return $border;
}
示例3: apply
function apply(&$root, &$state, &$pipeline)
{
$local_css = array();
if (isset($this->tag_filtered[strtolower($root->tagname())])) {
$local_css = $this->tag_filtered[strtolower($root->tagname())];
}
if (isset($this->tag_filtered['*'])) {
$local_css = array_merge($local_css, $this->tag_filtered['*']);
}
$applicable = array();
foreach ($local_css as $rule) {
if ($rule->match($root)) {
$applicable[] = $rule;
}
}
usort($applicable, 'cmp_rule_objs');
foreach ($applicable as $rule) {
switch ($rule->get_pseudoelement()) {
case SELECTOR_PSEUDOELEMENT_BEFORE:
$handler =& CSS::get_handler(CSS_HTML2PS_PSEUDOELEMENTS);
$handler->replace($handler->get($state->getState()) | CSS_HTML2PS_PSEUDOELEMENTS_BEFORE, $state);
break;
case SELECTOR_PSEUDOELEMENT_AFTER:
$handler =& CSS::get_handler(CSS_HTML2PS_PSEUDOELEMENTS);
$handler->replace($handler->get($state->getState()) | CSS_HTML2PS_PSEUDOELEMENTS_AFTER, $state);
break;
default:
$rule->apply($root, $state, $pipeline);
break;
}
}
}
示例4: parse
function parse($value)
{
if ($value == 'inherit') {
return CSS_PROPERTY_INHERIT;
}
$width_handler = CSS::get_handler(CSS_BORDER_WIDTH);
$width = $width_handler->parse_value($value);
return $width;
}
示例5: array
/**
* Optimization: this function is called very often,
* so even a slight overhead for CSS::get_handler call
* accumulates in a significiant processing delay.
*/
function &getCSSProperty($code)
{
static $cache = array();
if (!isset($cache[$code])) {
$cache[$code] =& CSS::get_handler($code);
}
$value =& $cache[$code]->get($this->_css);
return $value;
}
示例6: apply
function apply(&$state)
{
$properties = $this->getPropertiesRaw();
foreach ($properties as $property) {
$key = $property->getCode();
$value = $property->getValue();
$handler =& CSS::get_handler($key);
$handler->replace($value, $state);
}
}
示例7: TableBox
function &create(&$root, &$pipeline)
{
$box =& new TableBox();
$box->readCSS($pipeline->getCurrentCSSState());
// This row should not inherit any table specific properties!
// 'overflow' for example
//
$css_state =& $pipeline->getCurrentCSSState();
$css_state->pushDefaultState();
$row =& new TableRowBox($root);
$row->readCSS($css_state);
$box->add_child($row);
$css_state->popState();
// Setup cellspacing / cellpadding values
if ($box->getCSSProperty(CSS_BORDER_COLLAPSE) == BORDER_COLLAPSE) {
$handler =& CSS::get_handler(CSS_PADDING);
$box->setCSSProperty(CSS_PADDING, $handler->default_value());
}
// Set text-align to 'left'; all browsers I've ever seen prevent inheriting of
// 'text-align' property by the tables.
// Say, in the following example the text inside the table cell will be aligned left,
// instead of inheriting 'center' value.
//
// <div style="text-align: center; background-color: green;">
// <table width="100" bgcolor="red">
// <tr><td>TEST
// </table>
// </div>
$handler =& CSS::get_handler(CSS_TEXT_ALIGN);
$handler->css('left', $pipeline);
// Parse table contents
$child = $root->first_child();
$col_index = 0;
while ($child) {
if ($child->node_type() === XML_ELEMENT_NODE) {
if ($child->tagname() === 'colgroup') {
// COLGROUP tags do not generate boxes; they contain information on the columns
//
$col_index = $box->parse_colgroup_tag($child, $col_index);
} else {
$child_box =& create_pdf_box($child, $pipeline);
$box->add_child($child_box);
}
}
$child = $child->next_sibling();
}
$box->normalize($pipeline);
$box->normalize_cwc();
$box->normalize_rhc();
$box->normalize_parent();
return $box;
}
示例8: CSSPropertyDeclaration
function &create($code, $value, $pipeline)
{
$handler =& CSS::get_handler($code);
if (is_null($handler)) {
$null = null;
return $null;
}
$declaration =& new CSSPropertyDeclaration();
$declaration->_code = $code;
if (preg_match("/^(.*)!\\s*important\\s*\$/", $value, $matches)) {
$value = $matches[1];
$declaration->_important = true;
} else {
$declaration->_important = false;
}
$declaration->_value = $handler->parse($value, $pipeline);
return $declaration;
}
示例9: _fix_display_position_float
function &create_pdf_pseudoelement($root, $pe_type, &$pipeline)
{
// Store initial values to CSS stack
$css_state =& $pipeline->get_current_css_state();
$css_state->pushDefaultState();
// Initially generated boxes do not require block wrappers
// Block wrappers are required in following cases:
// - float property is specified for non-block box which cannot be directly converted to block box
// (a button, for example)
// - display set to block for such box
$need_block_wrapper = false;
$css =& $pipeline->get_current_css();
$css->apply_pseudoelement($pe_type, $root, $css_state, $pipeline);
// Now, if no content found, just return
//
$content_obj = $css_state->get_property(CSS_CONTENT);
if ($content_obj === CSS_PROPERTY_INHERIT) {
$content_obj = $css_state->getInheritedProperty(CSS_CONTENT);
}
$content = $content_obj->render($pipeline->get_counters());
if ($content === '') {
$css_state->popState();
$dummy = null;
return $dummy;
}
// CSS 2.1:
// 9.7 Relationships between 'display', 'position', and 'float'
// The three properties that affect box generation and layout
// 'display', 'position', and 'float' interact as follows:
// 1. If 'display' has the value 'none', then 'position' and 'float' do not apply.
// In this case, the element generates no box.
// 2. Otherwise, if 'position' has the value 'absolute' or 'fixed', the box is absolutely positioned,
// the computed value of 'float' is 'none', and display is set according to the table below.
// The position of the box will be determined by the 'top', 'right', 'bottom' and 'left' properties and
// the box's containing block.
$position_handler =& CSS::get_handler(CSS_POSITION);
$float_handler =& CSS::get_handler(CSS_FLOAT);
$position = $position_handler->get($css_state->getState());
if ($position === CSS_PROPERTY_INHERIT) {
$position = $css_state->getInheritedProperty(CSS_POSITION);
}
if ($position === POSITION_ABSOLUTE || $position === POSITION_FIXED) {
$float_handler->replace(FLOAT_NONE);
$need_block_wrapper |= _fix_display_position_float($css_state);
}
// 3. Otherwise, if 'float' has a value other than 'none', the box is floated and 'display' is set
// according to the table below.
$float = $float_handler->get($css_state->getState());
if ($float != FLOAT_NONE) {
$need_block_wrapper |= _fix_display_position_float($css_state);
}
// 4. Otherwise, if the element is the root element, 'display' is set according to the table below.
// 5. Otherwise, the remaining 'display' property values apply as specified. (see _fix_display_position_float)
// Note that pseudoelements may get only standard display values
$display_handler =& CSS::get_handler(CSS_DISPLAY);
$display = $display_handler->get($css_state->getState());
switch ($display) {
case 'block':
$box =& BlockBox::create_from_text($content, $pipeline);
break;
case 'inline':
$ws_handler =& CSS::get_handler(CSS_WHITE_SPACE);
$box =& InlineBox::create_from_text($content, $ws_handler->get($css_state->getState()), $pipeline);
break;
default:
die('Unsupported "display" value: ' . $display_handler->get($css_state->getState()));
}
// Check if this box needs a block wrapper (for example, floating button)
// Note that to keep float/position information, we clear the CSS stack only
// AFTER the wrapper box have been created; BUT we should clear the following CSS properties
// to avoid the fake wrapper box actually affect the layout:
// - margin
// - border
// - padding
// - background
//
if ($need_block_wrapper) {
$handler =& CSS::get_handler(CSS_MARGIN);
$handler->css("0", $pipeline);
pop_border();
push_border(default_border());
pop_padding();
push_padding(default_padding());
$handler =& CSS::get_handler(CSS_BACKGROUND);
$handler->css('transparent', $pipeline);
// Create "clean" block box
$wrapper =& new BlockBox();
$wrapper->readCSS($pipeline->get_current_css_state());
$wrapper->add_child($box);
$css_state->popState();
return $wrapper;
} else {
$css_state->popState();
return $box;
}
}
示例10: _getCSSDefaults
function _getCSSDefaults($selector)
{
$text_align_handler =& CSS::get_handler(CSS_TEXT_ALIGN);
$vertical_align_handler =& CSS::get_handler(CSS_VERTICAL_ALIGN);
switch ($selector) {
case CSS_MARGIN_BOX_SELECTOR_TOP:
return 'text-align: left; vertical-align: middle';
case CSS_MARGIN_BOX_SELECTOR_TOP_LEFT_CORNER:
return 'text-align: right; vertical-align: middle';
case CSS_MARGIN_BOX_SELECTOR_TOP_LEFT:
return 'text-align: left; vertical-align: middle';
case CSS_MARGIN_BOX_SELECTOR_TOP_CENTER:
return 'text-align: center; vertical-align: middle';
case CSS_MARGIN_BOX_SELECTOR_TOP_RIGHT:
return 'text-align: right; vertical-align: middle';
case CSS_MARGIN_BOX_SELECTOR_TOP_RIGHT_CORNER:
return 'text-align: left; vertical-align: middle';
case CSS_MARGIN_BOX_SELECTOR_BOTTOM:
return 'text-align: left; vertical-align: middle';
case CSS_MARGIN_BOX_SELECTOR_BOTTOM_LEFT_CORNER:
return 'text-align: right; vertical-align: middle';
case CSS_MARGIN_BOX_SELECTOR_BOTTOM_LEFT:
return 'text-align: left; vertical-align: middle';
case CSS_MARGIN_BOX_SELECTOR_BOTTOM_CENTER:
return 'text-align: center; vertical-align: middle';
case CSS_MARGIN_BOX_SELECTOR_BOTTOM_RIGHT:
return 'text-align: right; vertical-align: middle';
case CSS_MARGIN_BOX_SELECTOR_BOTTOM_RIGHT_CORNER:
return 'text-align: left; vertical-align: middle';
case CSS_MARGIN_BOX_SELECTOR_LEFT_TOP:
return 'text-align: center; vertical-align: top';
case CSS_MARGIN_BOX_SELECTOR_LEFT_MIDDLE:
return 'text-align: center; vertical-align: middle';
case CSS_MARGIN_BOX_SELECTOR_LEFT_BOTTOM:
return 'text-align: center; vertical-align: bottom';
case CSS_MARGIN_BOX_SELECTOR_RIGHT_TOP:
return 'text-align: center; vertical-align: top';
case CSS_MARGIN_BOX_SELECTOR_RIGHT_MIDDLE:
return 'text-align: center; vertical-align: middle';
case CSS_MARGIN_BOX_SELECTOR_RIGHT_BOTTOM:
return 'text-align: center; vertical-align: bottom';
}
}
示例11: import_declaration
function import_declaration($declaration)
{
$syntax_property = $declaration->get_property();
$code = CSS::name2code($syntax_property->get_name());
if (is_null($code)) {
return null;
}
$handler = CSS::get_handler($code);
$property = new CSSPropertyDeclaration();
$property->set_code($code);
$expr = $declaration->get_expr();
$property->set_value($handler->parse($expr->to_string(), $this->get_pipeline(), $expr));
$property->set_important($declaration->get_important());
return $property;
}
示例12: set_property
/**
* see get_property for optimization description
*/
function set_property($code, $value)
{
$this->set_propertyDefault($code, $value);
static $cache = array();
if (!isset($cache[$code])) {
$cache[$code] =& CSS::get_handler($code);
}
$cache[$code]->clearDefaultFlags($this);
}
示例13: applicable
function applicable($css_state)
{
$handler =& CSS::get_handler(CSS_DISPLAY);
$display = $handler->get($css_state->getState());
return $display === 'table-cell' || $display === 'table-row' || is_inline_element($display);
}
示例14: alpha
function alpha(&$psdata, $src_img, &$size_x, &$size_y, &$image, &$mask)
{
// Generate an unique image id
$id = $this->generate_id();
// Determine image size
$size_x = imagesx($src_img);
$size_y = imagesy($src_img);
// write stread header to the postscript file
$psdata->write("/image-{$id}-init { image-{$id}-data 0 setfileposition } def\n");
$psdata->write("/image-{$id}-data currentfile << /Filter /ASCIIHexDecode >> /ReusableStreamDecode filter\n");
// initialize line length counter
$ctr = 0;
// Save visible background color
$handler =& CSS::get_handler(CSS_BACKGROUND_COLOR);
$bg = $handler->get_visible_background_color();
for ($y = 0; $y < $size_y; $y++) {
for ($x = 0; $x < $size_x; $x++) {
// Check color/alpha of current pixels
$colors = imagecolorsforindex($src_img, imagecolorat($src_img, $x, $y));
$a = $colors['alpha'];
$r = $colors['red'];
$g = $colors['green'];
$b = $colors['blue'];
// Calculate approximate color
$r = (int) ($r + ($bg[0] - $r) * $a / 127);
$g = (int) ($g + ($bg[1] - $g) * $a / 127);
$b = (int) ($b + ($bg[2] - $b) * $a / 127);
// Save image pixel to the stream data
$psdata->write(sprintf("%02X%02X%02X", $r, $g, $b));
// Increate the line length counter; check if stream line needs to be terminated
$ctr += 6;
if ($ctr > MAX_LINE_LENGTH) {
$psdata->write("\n");
$ctr = 0;
}
}
}
// terminate the stream data
$psdata->write(">\ndef\n");
// return image and mask data references
$image = "image-{$id}-data";
$mask = "";
return $id;
}
示例15: alpha
function alpha($psdata, $src_img, &$size_x, &$size_y, &$image, &$mask)
{
$id = $this->generate_id();
$size_x = imagesx($src_img);
$size_y = imagesy($src_img);
$ps_image_data = "";
$ps_mask_data = 0xff;
$ctr = 1;
$row = 1;
for ($y = 0; $y < $size_y; $y++) {
for ($x = 0; $x < $size_x; $x++) {
// Mask pixel
$colors = imagecolorsforindex($src_img, imagecolorat($src_img, $x, $y));
$a = $colors['alpha'];
$r = $colors['red'];
$g = $colors['green'];
$b = $colors['blue'];
$handler =& CSS::get_handler(CSS_BACKGROUND_COLOR);
$bg = $handler->get_visible_background_color();
$r = (int) ($r + ($bg[0] - $r) * $a / 127);
$g = (int) ($g + ($bg[1] - $g) * $a / 127);
$b = (int) ($b + ($bg[2] - $b) * $a / 127);
$ps_image_data .= sprintf("\\%03o\\%03o\\%03o", $r, $g, $b);
// Write mask and image rows
$ctr++;
if ($ctr > MAX_IMAGE_ROW_LEN || $x + 1 == $size_x) {
$row_next = $size_x - $x - 1 + $size_x * ($size_y - $y - 1) == 0 ? 1 : $row + 1;
$psdata->write("/row-{$id}-{$row} { /image-{$id}-data { row-{$id}-{$row_next} } def ({$ps_image_data}) } def\n");
$ps_image_data = "";
$ctr = 1;
$row += 1;
}
}
}
if ($ps_image_data) {
$psdata->write("/row-{$id}-{$row} { /image-{$id}-data { row-{$id}-{$row_next} } def ({$ps_image_data}) } def\n");
}
$psdata->write("/image-{$id}-data { row-{$id}-1 } def\n");
$psdata->write("/image-{$id}-init { } def\n");
// return image and mask data references
$image = "{image-{$id}-data}";
$mask = "";
return $id;
}