id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
210,300 | barryvdh/laravel-debugbar | src/DataFormatter/SimpleFormatter.php | SimpleFormatter.exportValue | private function exportValue($value, $depth = 1, $deep = false)
{
if ($value instanceof \__PHP_Incomplete_Class) {
return sprintf('__PHP_Incomplete_Class(%s)', $this->getClassNameFromIncomplete($value));
}
if (is_object($value)) {
if ($value instanceof \DateTimeInterface) {
return sprintf('Object(%s) - %s', get_class($value), $value->format(\DateTime::ATOM));
}
return sprintf('Object(%s)', get_class($value));
}
if (is_array($value)) {
if (empty($value)) {
return '[]';
}
$indent = str_repeat(' ', $depth);
$a = array();
foreach ($value as $k => $v) {
if (is_array($v)) {
$deep = true;
}
$a[] = sprintf('%s => %s', $k, $this->exportValue($v, $depth + 1, $deep));
}
if ($deep) {
return sprintf("[\n%s%s\n%s]", $indent, implode(sprintf(", \n%s", $indent), $a), str_repeat(' ', $depth - 1));
}
$s = sprintf('[%s]', implode(', ', $a));
if (80 > strlen($s)) {
return $s;
}
return sprintf("[\n%s%s\n]", $indent, implode(sprintf(",\n%s", $indent), $a));
}
if (is_resource($value)) {
return sprintf('Resource(%s#%d)', get_resource_type($value), $value);
}
if (null === $value) {
return 'null';
}
if (false === $value) {
return 'false';
}
if (true === $value) {
return 'true';
}
return (string) $value;
} | php | private function exportValue($value, $depth = 1, $deep = false)
{
if ($value instanceof \__PHP_Incomplete_Class) {
return sprintf('__PHP_Incomplete_Class(%s)', $this->getClassNameFromIncomplete($value));
}
if (is_object($value)) {
if ($value instanceof \DateTimeInterface) {
return sprintf('Object(%s) - %s', get_class($value), $value->format(\DateTime::ATOM));
}
return sprintf('Object(%s)', get_class($value));
}
if (is_array($value)) {
if (empty($value)) {
return '[]';
}
$indent = str_repeat(' ', $depth);
$a = array();
foreach ($value as $k => $v) {
if (is_array($v)) {
$deep = true;
}
$a[] = sprintf('%s => %s', $k, $this->exportValue($v, $depth + 1, $deep));
}
if ($deep) {
return sprintf("[\n%s%s\n%s]", $indent, implode(sprintf(", \n%s", $indent), $a), str_repeat(' ', $depth - 1));
}
$s = sprintf('[%s]', implode(', ', $a));
if (80 > strlen($s)) {
return $s;
}
return sprintf("[\n%s%s\n]", $indent, implode(sprintf(",\n%s", $indent), $a));
}
if (is_resource($value)) {
return sprintf('Resource(%s#%d)', get_resource_type($value), $value);
}
if (null === $value) {
return 'null';
}
if (false === $value) {
return 'false';
}
if (true === $value) {
return 'true';
}
return (string) $value;
} | [
"private",
"function",
"exportValue",
"(",
"$",
"value",
",",
"$",
"depth",
"=",
"1",
",",
"$",
"deep",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"\\",
"__PHP_Incomplete_Class",
")",
"{",
"return",
"sprintf",
"(",
"'__PHP_Incomplete_Class(%s)'",
",",
"$",
"this",
"->",
"getClassNameFromIncomplete",
"(",
"$",
"value",
")",
")",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"\\",
"DateTimeInterface",
")",
"{",
"return",
"sprintf",
"(",
"'Object(%s) - %s'",
",",
"get_class",
"(",
"$",
"value",
")",
",",
"$",
"value",
"->",
"format",
"(",
"\\",
"DateTime",
"::",
"ATOM",
")",
")",
";",
"}",
"return",
"sprintf",
"(",
"'Object(%s)'",
",",
"get_class",
"(",
"$",
"value",
")",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"return",
"'[]'",
";",
"}",
"$",
"indent",
"=",
"str_repeat",
"(",
"' '",
",",
"$",
"depth",
")",
";",
"$",
"a",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"v",
")",
")",
"{",
"$",
"deep",
"=",
"true",
";",
"}",
"$",
"a",
"[",
"]",
"=",
"sprintf",
"(",
"'%s => %s'",
",",
"$",
"k",
",",
"$",
"this",
"->",
"exportValue",
"(",
"$",
"v",
",",
"$",
"depth",
"+",
"1",
",",
"$",
"deep",
")",
")",
";",
"}",
"if",
"(",
"$",
"deep",
")",
"{",
"return",
"sprintf",
"(",
"\"[\\n%s%s\\n%s]\"",
",",
"$",
"indent",
",",
"implode",
"(",
"sprintf",
"(",
"\", \\n%s\"",
",",
"$",
"indent",
")",
",",
"$",
"a",
")",
",",
"str_repeat",
"(",
"' '",
",",
"$",
"depth",
"-",
"1",
")",
")",
";",
"}",
"$",
"s",
"=",
"sprintf",
"(",
"'[%s]'",
",",
"implode",
"(",
"', '",
",",
"$",
"a",
")",
")",
";",
"if",
"(",
"80",
">",
"strlen",
"(",
"$",
"s",
")",
")",
"{",
"return",
"$",
"s",
";",
"}",
"return",
"sprintf",
"(",
"\"[\\n%s%s\\n]\"",
",",
"$",
"indent",
",",
"implode",
"(",
"sprintf",
"(",
"\",\\n%s\"",
",",
"$",
"indent",
")",
",",
"$",
"a",
")",
")",
";",
"}",
"if",
"(",
"is_resource",
"(",
"$",
"value",
")",
")",
"{",
"return",
"sprintf",
"(",
"'Resource(%s#%d)'",
",",
"get_resource_type",
"(",
"$",
"value",
")",
",",
"$",
"value",
")",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"value",
")",
"{",
"return",
"'null'",
";",
"}",
"if",
"(",
"false",
"===",
"$",
"value",
")",
"{",
"return",
"'false'",
";",
"}",
"if",
"(",
"true",
"===",
"$",
"value",
")",
"{",
"return",
"'true'",
";",
"}",
"return",
"(",
"string",
")",
"$",
"value",
";",
"}"
] | Converts a PHP value to a string.
@param mixed $value The PHP value
@param int $depth Only for internal usage
@param bool $deep Only for internal usage
@return string The string representation of the given value
@author Bernhard Schussek <bschussek@gmail.com> | [
"Converts",
"a",
"PHP",
"value",
"to",
"a",
"string",
"."
] | 2d195779ea4f809f69764a795e2ec371dbb76a96 | https://github.com/barryvdh/laravel-debugbar/blob/2d195779ea4f809f69764a795e2ec371dbb76a96/src/DataFormatter/SimpleFormatter.php#L33-L92 |
210,301 | barryvdh/laravel-debugbar | src/LaravelDebugbar.php | LaravelDebugbar.isEnabled | public function isEnabled()
{
if ($this->enabled === null) {
$config = $this->app['config'];
$configEnabled = value($config->get('debugbar.enabled'));
if ($configEnabled === null) {
$configEnabled = $config->get('app.debug');
}
$this->enabled = $configEnabled && !$this->app->runningInConsole() && !$this->app->environment('testing');
}
return $this->enabled;
} | php | public function isEnabled()
{
if ($this->enabled === null) {
$config = $this->app['config'];
$configEnabled = value($config->get('debugbar.enabled'));
if ($configEnabled === null) {
$configEnabled = $config->get('app.debug');
}
$this->enabled = $configEnabled && !$this->app->runningInConsole() && !$this->app->environment('testing');
}
return $this->enabled;
} | [
"public",
"function",
"isEnabled",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"enabled",
"===",
"null",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"app",
"[",
"'config'",
"]",
";",
"$",
"configEnabled",
"=",
"value",
"(",
"$",
"config",
"->",
"get",
"(",
"'debugbar.enabled'",
")",
")",
";",
"if",
"(",
"$",
"configEnabled",
"===",
"null",
")",
"{",
"$",
"configEnabled",
"=",
"$",
"config",
"->",
"get",
"(",
"'app.debug'",
")",
";",
"}",
"$",
"this",
"->",
"enabled",
"=",
"$",
"configEnabled",
"&&",
"!",
"$",
"this",
"->",
"app",
"->",
"runningInConsole",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"app",
"->",
"environment",
"(",
"'testing'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"enabled",
";",
"}"
] | Check if the Debugbar is enabled
@return boolean | [
"Check",
"if",
"the",
"Debugbar",
"is",
"enabled"
] | 2d195779ea4f809f69764a795e2ec371dbb76a96 | https://github.com/barryvdh/laravel-debugbar/blob/2d195779ea4f809f69764a795e2ec371dbb76a96/src/LaravelDebugbar.php#L751-L765 |
210,302 | barryvdh/laravel-debugbar | src/LaravelDebugbar.php | LaravelDebugbar.addMessage | public function addMessage($message, $label = 'info')
{
if ($this->hasCollector('messages')) {
/** @var \DebugBar\DataCollector\MessagesCollector $collector */
$collector = $this->getCollector('messages');
$collector->addMessage($message, $label);
}
} | php | public function addMessage($message, $label = 'info')
{
if ($this->hasCollector('messages')) {
/** @var \DebugBar\DataCollector\MessagesCollector $collector */
$collector = $this->getCollector('messages');
$collector->addMessage($message, $label);
}
} | [
"public",
"function",
"addMessage",
"(",
"$",
"message",
",",
"$",
"label",
"=",
"'info'",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasCollector",
"(",
"'messages'",
")",
")",
"{",
"/** @var \\DebugBar\\DataCollector\\MessagesCollector $collector */",
"$",
"collector",
"=",
"$",
"this",
"->",
"getCollector",
"(",
"'messages'",
")",
";",
"$",
"collector",
"->",
"addMessage",
"(",
"$",
"message",
",",
"$",
"label",
")",
";",
"}",
"}"
] | Adds a message to the MessagesCollector
A message can be anything from an object to a string
@param mixed $message
@param string $label | [
"Adds",
"a",
"message",
"to",
"the",
"MessagesCollector"
] | 2d195779ea4f809f69764a795e2ec371dbb76a96 | https://github.com/barryvdh/laravel-debugbar/blob/2d195779ea4f809f69764a795e2ec371dbb76a96/src/LaravelDebugbar.php#L974-L981 |
210,303 | barryvdh/laravel-debugbar | src/LaravelDebugbar.php | LaravelDebugbar.addServerTimingHeaders | protected function addServerTimingHeaders(Response $response)
{
if ($this->hasCollector('time')) {
$collector = $this->getCollector('time');
$headers = [];
foreach ($collector->collect()['measures'] as $k => $m) {
$headers[] = sprintf('%d=%F; "%s"', $k, $m['duration'] * 1000, str_replace('"', "'", $m['label']));
}
$response->headers->set('Server-Timing', $headers, false);
}
} | php | protected function addServerTimingHeaders(Response $response)
{
if ($this->hasCollector('time')) {
$collector = $this->getCollector('time');
$headers = [];
foreach ($collector->collect()['measures'] as $k => $m) {
$headers[] = sprintf('%d=%F; "%s"', $k, $m['duration'] * 1000, str_replace('"', "'", $m['label']));
}
$response->headers->set('Server-Timing', $headers, false);
}
} | [
"protected",
"function",
"addServerTimingHeaders",
"(",
"Response",
"$",
"response",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasCollector",
"(",
"'time'",
")",
")",
"{",
"$",
"collector",
"=",
"$",
"this",
"->",
"getCollector",
"(",
"'time'",
")",
";",
"$",
"headers",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"collector",
"->",
"collect",
"(",
")",
"[",
"'measures'",
"]",
"as",
"$",
"k",
"=>",
"$",
"m",
")",
"{",
"$",
"headers",
"[",
"]",
"=",
"sprintf",
"(",
"'%d=%F; \"%s\"'",
",",
"$",
"k",
",",
"$",
"m",
"[",
"'duration'",
"]",
"*",
"1000",
",",
"str_replace",
"(",
"'\"'",
",",
"\"'\"",
",",
"$",
"m",
"[",
"'label'",
"]",
")",
")",
";",
"}",
"$",
"response",
"->",
"headers",
"->",
"set",
"(",
"'Server-Timing'",
",",
"$",
"headers",
",",
"false",
")",
";",
"}",
"}"
] | Add Server-Timing headers for the TimeData collector
@see https://www.w3.org/TR/server-timing/
@param Response $response | [
"Add",
"Server",
"-",
"Timing",
"headers",
"for",
"the",
"TimeData",
"collector"
] | 2d195779ea4f809f69764a795e2ec371dbb76a96 | https://github.com/barryvdh/laravel-debugbar/blob/2d195779ea4f809f69764a795e2ec371dbb76a96/src/LaravelDebugbar.php#L1053-L1065 |
210,304 | barryvdh/laravel-debugbar | src/DataFormatter/QueryFormatter.php | QueryFormatter.escapeBindings | public function escapeBindings($bindings)
{
foreach ($bindings as &$binding) {
$binding = htmlentities($binding, ENT_QUOTES, 'UTF-8', false);
}
return $bindings;
} | php | public function escapeBindings($bindings)
{
foreach ($bindings as &$binding) {
$binding = htmlentities($binding, ENT_QUOTES, 'UTF-8', false);
}
return $bindings;
} | [
"public",
"function",
"escapeBindings",
"(",
"$",
"bindings",
")",
"{",
"foreach",
"(",
"$",
"bindings",
"as",
"&",
"$",
"binding",
")",
"{",
"$",
"binding",
"=",
"htmlentities",
"(",
"$",
"binding",
",",
"ENT_QUOTES",
",",
"'UTF-8'",
",",
"false",
")",
";",
"}",
"return",
"$",
"bindings",
";",
"}"
] | Make the bindings safe for outputting.
@param array $bindings
@return array | [
"Make",
"the",
"bindings",
"safe",
"for",
"outputting",
"."
] | 2d195779ea4f809f69764a795e2ec371dbb76a96 | https://github.com/barryvdh/laravel-debugbar/blob/2d195779ea4f809f69764a795e2ec371dbb76a96/src/DataFormatter/QueryFormatter.php#L44-L51 |
210,305 | barryvdh/laravel-debugbar | src/DataFormatter/QueryFormatter.php | QueryFormatter.formatSource | public function formatSource($source)
{
if (! is_object($source)) {
return '';
}
$parts = [];
if ($source->namespace) {
$parts['namespace'] = $source->namespace . '::';
}
$parts['name'] = $source->name;
$parts['line'] = ':' . $source->line;
return implode($parts);
} | php | public function formatSource($source)
{
if (! is_object($source)) {
return '';
}
$parts = [];
if ($source->namespace) {
$parts['namespace'] = $source->namespace . '::';
}
$parts['name'] = $source->name;
$parts['line'] = ':' . $source->line;
return implode($parts);
} | [
"public",
"function",
"formatSource",
"(",
"$",
"source",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"source",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"parts",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"source",
"->",
"namespace",
")",
"{",
"$",
"parts",
"[",
"'namespace'",
"]",
"=",
"$",
"source",
"->",
"namespace",
".",
"'::'",
";",
"}",
"$",
"parts",
"[",
"'name'",
"]",
"=",
"$",
"source",
"->",
"name",
";",
"$",
"parts",
"[",
"'line'",
"]",
"=",
"':'",
".",
"$",
"source",
"->",
"line",
";",
"return",
"implode",
"(",
"$",
"parts",
")",
";",
"}"
] | Format a source object.
@param object|null $source If the backtrace is disabled, the $source will be null.
@return string | [
"Format",
"a",
"source",
"object",
"."
] | 2d195779ea4f809f69764a795e2ec371dbb76a96 | https://github.com/barryvdh/laravel-debugbar/blob/2d195779ea4f809f69764a795e2ec371dbb76a96/src/DataFormatter/QueryFormatter.php#L59-L75 |
210,306 | barryvdh/laravel-debugbar | src/DataCollector/RouteCollector.php | RouteCollector.displayRoutes | protected function displayRoutes(array $routes)
{
$this->table->setHeaders($this->headers)->setRows($routes);
$this->table->render($this->getOutput());
} | php | protected function displayRoutes(array $routes)
{
$this->table->setHeaders($this->headers)->setRows($routes);
$this->table->render($this->getOutput());
} | [
"protected",
"function",
"displayRoutes",
"(",
"array",
"$",
"routes",
")",
"{",
"$",
"this",
"->",
"table",
"->",
"setHeaders",
"(",
"$",
"this",
"->",
"headers",
")",
"->",
"setRows",
"(",
"$",
"routes",
")",
";",
"$",
"this",
"->",
"table",
"->",
"render",
"(",
"$",
"this",
"->",
"getOutput",
"(",
")",
")",
";",
"}"
] | Display the route information on the console.
@param array $routes
@return void | [
"Display",
"the",
"route",
"information",
"on",
"the",
"console",
"."
] | 2d195779ea4f809f69764a795e2ec371dbb76a96 | https://github.com/barryvdh/laravel-debugbar/blob/2d195779ea4f809f69764a795e2ec371dbb76a96/src/DataCollector/RouteCollector.php#L135-L140 |
210,307 | barryvdh/laravel-debugbar | src/JavascriptRenderer.php | JavascriptRenderer.makeUriRelativeTo | protected function makeUriRelativeTo($uri, $root)
{
if (!$root) {
return $uri;
}
if (is_array($uri)) {
$uris = [];
foreach ($uri as $u) {
$uris[] = $this->makeUriRelativeTo($u, $root);
}
return $uris;
}
if (substr($uri, 0, 1) === '/' || preg_match('/^([a-zA-Z]+:\/\/|[a-zA-Z]:\/|[a-zA-Z]:\\\)/', $uri)) {
return $uri;
}
return rtrim($root, '/') . "/$uri";
} | php | protected function makeUriRelativeTo($uri, $root)
{
if (!$root) {
return $uri;
}
if (is_array($uri)) {
$uris = [];
foreach ($uri as $u) {
$uris[] = $this->makeUriRelativeTo($u, $root);
}
return $uris;
}
if (substr($uri, 0, 1) === '/' || preg_match('/^([a-zA-Z]+:\/\/|[a-zA-Z]:\/|[a-zA-Z]:\\\)/', $uri)) {
return $uri;
}
return rtrim($root, '/') . "/$uri";
} | [
"protected",
"function",
"makeUriRelativeTo",
"(",
"$",
"uri",
",",
"$",
"root",
")",
"{",
"if",
"(",
"!",
"$",
"root",
")",
"{",
"return",
"$",
"uri",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"uri",
")",
")",
"{",
"$",
"uris",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"uri",
"as",
"$",
"u",
")",
"{",
"$",
"uris",
"[",
"]",
"=",
"$",
"this",
"->",
"makeUriRelativeTo",
"(",
"$",
"u",
",",
"$",
"root",
")",
";",
"}",
"return",
"$",
"uris",
";",
"}",
"if",
"(",
"substr",
"(",
"$",
"uri",
",",
"0",
",",
"1",
")",
"===",
"'/'",
"||",
"preg_match",
"(",
"'/^([a-zA-Z]+:\\/\\/|[a-zA-Z]:\\/|[a-zA-Z]:\\\\\\)/'",
",",
"$",
"uri",
")",
")",
"{",
"return",
"$",
"uri",
";",
"}",
"return",
"rtrim",
"(",
"$",
"root",
",",
"'/'",
")",
".",
"\"/$uri\"",
";",
"}"
] | Makes a URI relative to another
@param string|array $uri
@param string $root
@return string | [
"Makes",
"a",
"URI",
"relative",
"to",
"another"
] | 2d195779ea4f809f69764a795e2ec371dbb76a96 | https://github.com/barryvdh/laravel-debugbar/blob/2d195779ea4f809f69764a795e2ec371dbb76a96/src/JavascriptRenderer.php#L123-L141 |
210,308 | dompdf/dompdf | src/FrameDecorator/Text.php | Text.get_margin_height | function get_margin_height()
{
// This function is called in add_frame_to_line() and is used to
// determine the line height, so we actually want to return the
// 'line-height' property, not the actual margin box
$style = $this->get_parent()->get_style();
$font = $style->font_family;
$size = $style->font_size;
/*
Helpers::pre_r('-----');
Helpers::pre_r($style->line_height);
Helpers::pre_r($style->font_size);
Helpers::pre_r($this->_dompdf->getFontMetrics()->getFontHeight($font, $size));
Helpers::pre_r(($style->line_height / $size) * $this->_dompdf->getFontMetrics()->getFontHeight($font, $size));
*/
return ($style->line_height / ($size > 0 ? $size : 1)) * $this->_dompdf->getFontMetrics()->getFontHeight($font, $size);
} | php | function get_margin_height()
{
// This function is called in add_frame_to_line() and is used to
// determine the line height, so we actually want to return the
// 'line-height' property, not the actual margin box
$style = $this->get_parent()->get_style();
$font = $style->font_family;
$size = $style->font_size;
/*
Helpers::pre_r('-----');
Helpers::pre_r($style->line_height);
Helpers::pre_r($style->font_size);
Helpers::pre_r($this->_dompdf->getFontMetrics()->getFontHeight($font, $size));
Helpers::pre_r(($style->line_height / $size) * $this->_dompdf->getFontMetrics()->getFontHeight($font, $size));
*/
return ($style->line_height / ($size > 0 ? $size : 1)) * $this->_dompdf->getFontMetrics()->getFontHeight($font, $size);
} | [
"function",
"get_margin_height",
"(",
")",
"{",
"// This function is called in add_frame_to_line() and is used to",
"// determine the line height, so we actually want to return the",
"// 'line-height' property, not the actual margin box",
"$",
"style",
"=",
"$",
"this",
"->",
"get_parent",
"(",
")",
"->",
"get_style",
"(",
")",
";",
"$",
"font",
"=",
"$",
"style",
"->",
"font_family",
";",
"$",
"size",
"=",
"$",
"style",
"->",
"font_size",
";",
"/*\n Helpers::pre_r('-----');\n Helpers::pre_r($style->line_height);\n Helpers::pre_r($style->font_size);\n Helpers::pre_r($this->_dompdf->getFontMetrics()->getFontHeight($font, $size));\n Helpers::pre_r(($style->line_height / $size) * $this->_dompdf->getFontMetrics()->getFontHeight($font, $size));\n */",
"return",
"(",
"$",
"style",
"->",
"line_height",
"/",
"(",
"$",
"size",
">",
"0",
"?",
"$",
"size",
":",
"1",
")",
")",
"*",
"$",
"this",
"->",
"_dompdf",
"->",
"getFontMetrics",
"(",
")",
"->",
"getFontHeight",
"(",
"$",
"font",
",",
"$",
"size",
")",
";",
"}"
] | Vertical margins & padding do not apply to text frames
http://www.w3.org/TR/CSS21/visudet.html#inline-non-replaced:
The vertical padding, border and margin of an inline, non-replaced box
start at the top and bottom of the content area, not the
'line-height'. But only the 'line-height' is used to calculate the
height of the line box.
@return float|int | [
"Vertical",
"margins",
"&",
"padding",
"do",
"not",
"apply",
"to",
"text",
"frames"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/FrameDecorator/Text.php#L96-L114 |
210,309 | dompdf/dompdf | src/FrameDecorator/Text.php | Text.recalculate_width | function recalculate_width()
{
$style = $this->get_style();
$text = $this->get_text();
$size = $style->font_size;
$font = $style->font_family;
$word_spacing = (float)$style->length_in_pt($style->word_spacing);
$char_spacing = (float)$style->length_in_pt($style->letter_spacing);
return $style->width = $this->_dompdf->getFontMetrics()->getTextWidth($text, $font, $size, $word_spacing, $char_spacing);
} | php | function recalculate_width()
{
$style = $this->get_style();
$text = $this->get_text();
$size = $style->font_size;
$font = $style->font_family;
$word_spacing = (float)$style->length_in_pt($style->word_spacing);
$char_spacing = (float)$style->length_in_pt($style->letter_spacing);
return $style->width = $this->_dompdf->getFontMetrics()->getTextWidth($text, $font, $size, $word_spacing, $char_spacing);
} | [
"function",
"recalculate_width",
"(",
")",
"{",
"$",
"style",
"=",
"$",
"this",
"->",
"get_style",
"(",
")",
";",
"$",
"text",
"=",
"$",
"this",
"->",
"get_text",
"(",
")",
";",
"$",
"size",
"=",
"$",
"style",
"->",
"font_size",
";",
"$",
"font",
"=",
"$",
"style",
"->",
"font_family",
";",
"$",
"word_spacing",
"=",
"(",
"float",
")",
"$",
"style",
"->",
"length_in_pt",
"(",
"$",
"style",
"->",
"word_spacing",
")",
";",
"$",
"char_spacing",
"=",
"(",
"float",
")",
"$",
"style",
"->",
"length_in_pt",
"(",
"$",
"style",
"->",
"letter_spacing",
")",
";",
"return",
"$",
"style",
"->",
"width",
"=",
"$",
"this",
"->",
"_dompdf",
"->",
"getFontMetrics",
"(",
")",
"->",
"getTextWidth",
"(",
"$",
"text",
",",
"$",
"font",
",",
"$",
"size",
",",
"$",
"word_spacing",
",",
"$",
"char_spacing",
")",
";",
"}"
] | Recalculate the text width
@return float | [
"Recalculate",
"the",
"text",
"width"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/FrameDecorator/Text.php#L146-L156 |
210,310 | dompdf/dompdf | src/FrameDecorator/Text.php | Text.split_text | function split_text($offset)
{
if ($offset == 0) {
return null;
}
$split = $this->_frame->get_node()->splitText($offset);
$deco = $this->copy($split);
$p = $this->get_parent();
$p->insert_child_after($deco, $this, false);
if ($p instanceof Inline) {
$p->split($deco);
}
return $deco;
} | php | function split_text($offset)
{
if ($offset == 0) {
return null;
}
$split = $this->_frame->get_node()->splitText($offset);
$deco = $this->copy($split);
$p = $this->get_parent();
$p->insert_child_after($deco, $this, false);
if ($p instanceof Inline) {
$p->split($deco);
}
return $deco;
} | [
"function",
"split_text",
"(",
"$",
"offset",
")",
"{",
"if",
"(",
"$",
"offset",
"==",
"0",
")",
"{",
"return",
"null",
";",
"}",
"$",
"split",
"=",
"$",
"this",
"->",
"_frame",
"->",
"get_node",
"(",
")",
"->",
"splitText",
"(",
"$",
"offset",
")",
";",
"$",
"deco",
"=",
"$",
"this",
"->",
"copy",
"(",
"$",
"split",
")",
";",
"$",
"p",
"=",
"$",
"this",
"->",
"get_parent",
"(",
")",
";",
"$",
"p",
"->",
"insert_child_after",
"(",
"$",
"deco",
",",
"$",
"this",
",",
"false",
")",
";",
"if",
"(",
"$",
"p",
"instanceof",
"Inline",
")",
"{",
"$",
"p",
"->",
"split",
"(",
"$",
"deco",
")",
";",
"}",
"return",
"$",
"deco",
";",
"}"
] | split the text in this frame at the offset specified. The remaining
text is added a sibling frame following this one and is returned.
@param $offset
@return Frame|null | [
"split",
"the",
"text",
"in",
"this",
"frame",
"at",
"the",
"offset",
"specified",
".",
"The",
"remaining",
"text",
"is",
"added",
"a",
"sibling",
"frame",
"following",
"this",
"one",
"and",
"is",
"returned",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/FrameDecorator/Text.php#L167-L185 |
210,311 | dompdf/dompdf | src/Dompdf.php | Dompdf.loadHtmlFile | public function loadHtmlFile($file)
{
$this->saveLocale();
if (!$this->protocol && !$this->baseHost && !$this->basePath) {
list($this->protocol, $this->baseHost, $this->basePath) = Helpers::explode_url($file);
}
$protocol = strtolower($this->protocol);
if ( !in_array($protocol, $this->allowedProtocols) ) {
throw new Exception("Permission denied on $file. The communication protocol is not supported.");
}
if (!$this->options->isRemoteEnabled() && ($protocol != "" && $protocol !== "file://")) {
throw new Exception("Remote file requested, but remote file download is disabled.");
}
if ($protocol == "" || $protocol === "file://") {
$realfile = realpath($file);
$chroot = realpath($this->options->getChroot());
if ($chroot && strpos($realfile, $chroot) !== 0) {
throw new Exception("Permission denied on $file. The file could not be found under the directory specified by Options::chroot.");
}
$ext = strtolower(pathinfo($realfile, PATHINFO_EXTENSION));
if (!in_array($ext, $this->allowedLocalFileExtensions)) {
throw new Exception("Permission denied on $file. This file extension is forbidden");
}
if (!$realfile) {
throw new Exception("File '$file' not found.");
}
$file = $realfile;
}
list($contents, $http_response_header) = Helpers::getFileContent($file, $this->httpContext);
$encoding = 'UTF-8';
// See http://the-stickman.com/web-development/php/getting-http-response-headers-when-using-file_get_contents/
if (isset($http_response_header)) {
foreach ($http_response_header as $_header) {
if (preg_match("@Content-Type:\s*[\w/]+;\s*?charset=([^\s]+)@i", $_header, $matches)) {
$encoding = strtoupper($matches[1]);
break;
}
}
}
$this->restoreLocale();
$this->loadHtml($contents, $encoding);
} | php | public function loadHtmlFile($file)
{
$this->saveLocale();
if (!$this->protocol && !$this->baseHost && !$this->basePath) {
list($this->protocol, $this->baseHost, $this->basePath) = Helpers::explode_url($file);
}
$protocol = strtolower($this->protocol);
if ( !in_array($protocol, $this->allowedProtocols) ) {
throw new Exception("Permission denied on $file. The communication protocol is not supported.");
}
if (!$this->options->isRemoteEnabled() && ($protocol != "" && $protocol !== "file://")) {
throw new Exception("Remote file requested, but remote file download is disabled.");
}
if ($protocol == "" || $protocol === "file://") {
$realfile = realpath($file);
$chroot = realpath($this->options->getChroot());
if ($chroot && strpos($realfile, $chroot) !== 0) {
throw new Exception("Permission denied on $file. The file could not be found under the directory specified by Options::chroot.");
}
$ext = strtolower(pathinfo($realfile, PATHINFO_EXTENSION));
if (!in_array($ext, $this->allowedLocalFileExtensions)) {
throw new Exception("Permission denied on $file. This file extension is forbidden");
}
if (!$realfile) {
throw new Exception("File '$file' not found.");
}
$file = $realfile;
}
list($contents, $http_response_header) = Helpers::getFileContent($file, $this->httpContext);
$encoding = 'UTF-8';
// See http://the-stickman.com/web-development/php/getting-http-response-headers-when-using-file_get_contents/
if (isset($http_response_header)) {
foreach ($http_response_header as $_header) {
if (preg_match("@Content-Type:\s*[\w/]+;\s*?charset=([^\s]+)@i", $_header, $matches)) {
$encoding = strtoupper($matches[1]);
break;
}
}
}
$this->restoreLocale();
$this->loadHtml($contents, $encoding);
} | [
"public",
"function",
"loadHtmlFile",
"(",
"$",
"file",
")",
"{",
"$",
"this",
"->",
"saveLocale",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"protocol",
"&&",
"!",
"$",
"this",
"->",
"baseHost",
"&&",
"!",
"$",
"this",
"->",
"basePath",
")",
"{",
"list",
"(",
"$",
"this",
"->",
"protocol",
",",
"$",
"this",
"->",
"baseHost",
",",
"$",
"this",
"->",
"basePath",
")",
"=",
"Helpers",
"::",
"explode_url",
"(",
"$",
"file",
")",
";",
"}",
"$",
"protocol",
"=",
"strtolower",
"(",
"$",
"this",
"->",
"protocol",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"protocol",
",",
"$",
"this",
"->",
"allowedProtocols",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Permission denied on $file. The communication protocol is not supported.\"",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"options",
"->",
"isRemoteEnabled",
"(",
")",
"&&",
"(",
"$",
"protocol",
"!=",
"\"\"",
"&&",
"$",
"protocol",
"!==",
"\"file://\"",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Remote file requested, but remote file download is disabled.\"",
")",
";",
"}",
"if",
"(",
"$",
"protocol",
"==",
"\"\"",
"||",
"$",
"protocol",
"===",
"\"file://\"",
")",
"{",
"$",
"realfile",
"=",
"realpath",
"(",
"$",
"file",
")",
";",
"$",
"chroot",
"=",
"realpath",
"(",
"$",
"this",
"->",
"options",
"->",
"getChroot",
"(",
")",
")",
";",
"if",
"(",
"$",
"chroot",
"&&",
"strpos",
"(",
"$",
"realfile",
",",
"$",
"chroot",
")",
"!==",
"0",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Permission denied on $file. The file could not be found under the directory specified by Options::chroot.\"",
")",
";",
"}",
"$",
"ext",
"=",
"strtolower",
"(",
"pathinfo",
"(",
"$",
"realfile",
",",
"PATHINFO_EXTENSION",
")",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"ext",
",",
"$",
"this",
"->",
"allowedLocalFileExtensions",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Permission denied on $file. This file extension is forbidden\"",
")",
";",
"}",
"if",
"(",
"!",
"$",
"realfile",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"File '$file' not found.\"",
")",
";",
"}",
"$",
"file",
"=",
"$",
"realfile",
";",
"}",
"list",
"(",
"$",
"contents",
",",
"$",
"http_response_header",
")",
"=",
"Helpers",
"::",
"getFileContent",
"(",
"$",
"file",
",",
"$",
"this",
"->",
"httpContext",
")",
";",
"$",
"encoding",
"=",
"'UTF-8'",
";",
"// See http://the-stickman.com/web-development/php/getting-http-response-headers-when-using-file_get_contents/",
"if",
"(",
"isset",
"(",
"$",
"http_response_header",
")",
")",
"{",
"foreach",
"(",
"$",
"http_response_header",
"as",
"$",
"_header",
")",
"{",
"if",
"(",
"preg_match",
"(",
"\"@Content-Type:\\s*[\\w/]+;\\s*?charset=([^\\s]+)@i\"",
",",
"$",
"_header",
",",
"$",
"matches",
")",
")",
"{",
"$",
"encoding",
"=",
"strtoupper",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"break",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"restoreLocale",
"(",
")",
";",
"$",
"this",
"->",
"loadHtml",
"(",
"$",
"contents",
",",
"$",
"encoding",
")",
";",
"}"
] | Loads an HTML file
Parse errors are stored in the global array _dompdf_warnings.
@param string $file a filename or url to load
@throws Exception | [
"Loads",
"an",
"HTML",
"file",
"Parse",
"errors",
"are",
"stored",
"in",
"the",
"global",
"array",
"_dompdf_warnings",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Dompdf.php#L349-L402 |
210,312 | dompdf/dompdf | src/Dompdf.php | Dompdf.add_info | public function add_info($label, $value)
{
$canvas = $this->getCanvas();
if (!is_null($canvas)) {
$canvas->add_info($label, $value);
}
} | php | public function add_info($label, $value)
{
$canvas = $this->getCanvas();
if (!is_null($canvas)) {
$canvas->add_info($label, $value);
}
} | [
"public",
"function",
"add_info",
"(",
"$",
"label",
",",
"$",
"value",
")",
"{",
"$",
"canvas",
"=",
"$",
"this",
"->",
"getCanvas",
"(",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"canvas",
")",
")",
"{",
"$",
"canvas",
"->",
"add_info",
"(",
"$",
"label",
",",
"$",
"value",
")",
";",
"}",
"}"
] | Add meta information to the PDF after rendering | [
"Add",
"meta",
"information",
"to",
"the",
"PDF",
"after",
"rendering"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Dompdf.php#L877-L883 |
210,313 | dompdf/dompdf | src/Dompdf.php | Dompdf.write_log | private function write_log()
{
$log_output_file = $this->getOptions()->getLogOutputFile();
if (!$log_output_file || !is_writable($log_output_file)) {
return;
}
$frames = Frame::$ID_COUNTER;
$memory = memory_get_peak_usage(true) / 1024;
$time = (microtime(true) - $this->startTime) * 1000;
$out = sprintf(
"<span style='color: #000' title='Frames'>%6d</span>" .
"<span style='color: #009' title='Memory'>%10.2f KB</span>" .
"<span style='color: #900' title='Time'>%10.2f ms</span>" .
"<span title='Quirksmode'> " .
($this->quirksmode ? "<span style='color: #d00'> ON</span>" : "<span style='color: #0d0'>OFF</span>") .
"</span><br />", $frames, $memory, $time);
$out .= ob_get_contents();
ob_clean();
file_put_contents($log_output_file, $out);
} | php | private function write_log()
{
$log_output_file = $this->getOptions()->getLogOutputFile();
if (!$log_output_file || !is_writable($log_output_file)) {
return;
}
$frames = Frame::$ID_COUNTER;
$memory = memory_get_peak_usage(true) / 1024;
$time = (microtime(true) - $this->startTime) * 1000;
$out = sprintf(
"<span style='color: #000' title='Frames'>%6d</span>" .
"<span style='color: #009' title='Memory'>%10.2f KB</span>" .
"<span style='color: #900' title='Time'>%10.2f ms</span>" .
"<span title='Quirksmode'> " .
($this->quirksmode ? "<span style='color: #d00'> ON</span>" : "<span style='color: #0d0'>OFF</span>") .
"</span><br />", $frames, $memory, $time);
$out .= ob_get_contents();
ob_clean();
file_put_contents($log_output_file, $out);
} | [
"private",
"function",
"write_log",
"(",
")",
"{",
"$",
"log_output_file",
"=",
"$",
"this",
"->",
"getOptions",
"(",
")",
"->",
"getLogOutputFile",
"(",
")",
";",
"if",
"(",
"!",
"$",
"log_output_file",
"||",
"!",
"is_writable",
"(",
"$",
"log_output_file",
")",
")",
"{",
"return",
";",
"}",
"$",
"frames",
"=",
"Frame",
"::",
"$",
"ID_COUNTER",
";",
"$",
"memory",
"=",
"memory_get_peak_usage",
"(",
"true",
")",
"/",
"1024",
";",
"$",
"time",
"=",
"(",
"microtime",
"(",
"true",
")",
"-",
"$",
"this",
"->",
"startTime",
")",
"*",
"1000",
";",
"$",
"out",
"=",
"sprintf",
"(",
"\"<span style='color: #000' title='Frames'>%6d</span>\"",
".",
"\"<span style='color: #009' title='Memory'>%10.2f KB</span>\"",
".",
"\"<span style='color: #900' title='Time'>%10.2f ms</span>\"",
".",
"\"<span title='Quirksmode'> \"",
".",
"(",
"$",
"this",
"->",
"quirksmode",
"?",
"\"<span style='color: #d00'> ON</span>\"",
":",
"\"<span style='color: #0d0'>OFF</span>\"",
")",
".",
"\"</span><br />\"",
",",
"$",
"frames",
",",
"$",
"memory",
",",
"$",
"time",
")",
";",
"$",
"out",
".=",
"ob_get_contents",
"(",
")",
";",
"ob_clean",
"(",
")",
";",
"file_put_contents",
"(",
"$",
"log_output_file",
",",
"$",
"out",
")",
";",
"}"
] | Writes the output buffer in the log file
@return void | [
"Writes",
"the",
"output",
"buffer",
"in",
"the",
"log",
"file"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Dompdf.php#L890-L913 |
210,314 | dompdf/dompdf | src/Dompdf.php | Dompdf.setPaper | public function setPaper($size, $orientation = "portrait")
{
$this->paperSize = $size;
$this->paperOrientation = $orientation;
return $this;
} | php | public function setPaper($size, $orientation = "portrait")
{
$this->paperSize = $size;
$this->paperOrientation = $orientation;
return $this;
} | [
"public",
"function",
"setPaper",
"(",
"$",
"size",
",",
"$",
"orientation",
"=",
"\"portrait\"",
")",
"{",
"$",
"this",
"->",
"paperSize",
"=",
"$",
"size",
";",
"$",
"this",
"->",
"paperOrientation",
"=",
"$",
"orientation",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the paper size & orientation
@param string|array $size 'letter', 'legal', 'A4', etc. {@link Dompdf\Adapter\CPDF::$PAPER_SIZES}
@param string $orientation 'portrait' or 'landscape'
@return $this | [
"Sets",
"the",
"paper",
"size",
"&",
"orientation"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Dompdf.php#L1042-L1047 |
210,315 | dompdf/dompdf | src/Dompdf.php | Dompdf.getPaperSize | public function getPaperSize($paperSize = null)
{
$size = $paperSize !== null ? $paperSize : $this->paperSize;
if (is_array($size)) {
return $size;
} else if (isset(Adapter\CPDF::$PAPER_SIZES[mb_strtolower($size)])) {
return Adapter\CPDF::$PAPER_SIZES[mb_strtolower($size)];
} else {
return Adapter\CPDF::$PAPER_SIZES["letter"];
}
} | php | public function getPaperSize($paperSize = null)
{
$size = $paperSize !== null ? $paperSize : $this->paperSize;
if (is_array($size)) {
return $size;
} else if (isset(Adapter\CPDF::$PAPER_SIZES[mb_strtolower($size)])) {
return Adapter\CPDF::$PAPER_SIZES[mb_strtolower($size)];
} else {
return Adapter\CPDF::$PAPER_SIZES["letter"];
}
} | [
"public",
"function",
"getPaperSize",
"(",
"$",
"paperSize",
"=",
"null",
")",
"{",
"$",
"size",
"=",
"$",
"paperSize",
"!==",
"null",
"?",
"$",
"paperSize",
":",
"$",
"this",
"->",
"paperSize",
";",
"if",
"(",
"is_array",
"(",
"$",
"size",
")",
")",
"{",
"return",
"$",
"size",
";",
"}",
"else",
"if",
"(",
"isset",
"(",
"Adapter",
"\\",
"CPDF",
"::",
"$",
"PAPER_SIZES",
"[",
"mb_strtolower",
"(",
"$",
"size",
")",
"]",
")",
")",
"{",
"return",
"Adapter",
"\\",
"CPDF",
"::",
"$",
"PAPER_SIZES",
"[",
"mb_strtolower",
"(",
"$",
"size",
")",
"]",
";",
"}",
"else",
"{",
"return",
"Adapter",
"\\",
"CPDF",
"::",
"$",
"PAPER_SIZES",
"[",
"\"letter\"",
"]",
";",
"}",
"}"
] | Gets the paper size
@param null|string|array $paperSize
@return int[] A four-element integer array | [
"Gets",
"the",
"paper",
"size"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Dompdf.php#L1055-L1065 |
210,316 | dompdf/dompdf | src/Dompdf.php | Dompdf.setDefaultView | public function setDefaultView($defaultView, $options)
{
$this->defaultView = $defaultView;
$this->defaultViewOptions = $options;
return $this;
} | php | public function setDefaultView($defaultView, $options)
{
$this->defaultView = $defaultView;
$this->defaultViewOptions = $options;
return $this;
} | [
"public",
"function",
"setDefaultView",
"(",
"$",
"defaultView",
",",
"$",
"options",
")",
"{",
"$",
"this",
"->",
"defaultView",
"=",
"$",
"defaultView",
";",
"$",
"this",
"->",
"defaultViewOptions",
"=",
"$",
"options",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the default view
@param string $defaultView The default document view
@param array $options The view's options
@return $this | [
"Sets",
"the",
"default",
"view"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Dompdf.php#L1248-L1253 |
210,317 | dompdf/dompdf | src/Dompdf.php | Dompdf.setCallbacks | public function setCallbacks($callbacks)
{
if (is_array($callbacks)) {
$this->callbacks = array();
foreach ($callbacks as $c) {
if (is_array($c) && isset($c['event']) && isset($c['f'])) {
$event = $c['event'];
$f = $c['f'];
if (is_callable($f) && is_string($event)) {
$this->callbacks[$event][] = $f;
}
}
}
}
} | php | public function setCallbacks($callbacks)
{
if (is_array($callbacks)) {
$this->callbacks = array();
foreach ($callbacks as $c) {
if (is_array($c) && isset($c['event']) && isset($c['f'])) {
$event = $c['event'];
$f = $c['f'];
if (is_callable($f) && is_string($event)) {
$this->callbacks[$event][] = $f;
}
}
}
}
} | [
"public",
"function",
"setCallbacks",
"(",
"$",
"callbacks",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"callbacks",
")",
")",
"{",
"$",
"this",
"->",
"callbacks",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"callbacks",
"as",
"$",
"c",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"c",
")",
"&&",
"isset",
"(",
"$",
"c",
"[",
"'event'",
"]",
")",
"&&",
"isset",
"(",
"$",
"c",
"[",
"'f'",
"]",
")",
")",
"{",
"$",
"event",
"=",
"$",
"c",
"[",
"'event'",
"]",
";",
"$",
"f",
"=",
"$",
"c",
"[",
"'f'",
"]",
";",
"if",
"(",
"is_callable",
"(",
"$",
"f",
")",
"&&",
"is_string",
"(",
"$",
"event",
")",
")",
"{",
"$",
"this",
"->",
"callbacks",
"[",
"$",
"event",
"]",
"[",
"]",
"=",
"$",
"f",
";",
"}",
"}",
"}",
"}",
"}"
] | Sets callbacks for events like rendering of pages and elements.
The callbacks array contains arrays with 'event' set to 'begin_page',
'end_page', 'begin_frame', or 'end_frame' and 'f' set to a function or
object plus method to be called.
The function 'f' must take an array as argument, which contains info
about the event.
@param array $callbacks the set of callbacks to set | [
"Sets",
"callbacks",
"for",
"events",
"like",
"rendering",
"of",
"pages",
"and",
"elements",
".",
"The",
"callbacks",
"array",
"contains",
"arrays",
"with",
"event",
"set",
"to",
"begin_page",
"end_page",
"begin_frame",
"or",
"end_frame",
"and",
"f",
"set",
"to",
"a",
"function",
"or",
"object",
"plus",
"method",
"to",
"be",
"called",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Dompdf.php#L1442-L1456 |
210,318 | dompdf/dompdf | src/FrameReflower/AbstractFrameReflower.php | AbstractFrameReflower._parse_quotes | protected function _parse_quotes()
{
// Matches quote types
$re = '/(\'[^\']*\')|(\"[^\"]*\")/';
$quotes = $this->_frame->get_style()->quotes;
// split on spaces, except within quotes
if (!preg_match_all($re, "$quotes", $matches, PREG_SET_ORDER)) {
return null;
}
$quotes_array = array();
foreach ($matches as $_quote) {
$quotes_array[] = $this->_parse_string($_quote[0], true);
}
if (empty($quotes_array)) {
$quotes_array = array('"', '"');
}
return array_chunk($quotes_array, 2);
} | php | protected function _parse_quotes()
{
// Matches quote types
$re = '/(\'[^\']*\')|(\"[^\"]*\")/';
$quotes = $this->_frame->get_style()->quotes;
// split on spaces, except within quotes
if (!preg_match_all($re, "$quotes", $matches, PREG_SET_ORDER)) {
return null;
}
$quotes_array = array();
foreach ($matches as $_quote) {
$quotes_array[] = $this->_parse_string($_quote[0], true);
}
if (empty($quotes_array)) {
$quotes_array = array('"', '"');
}
return array_chunk($quotes_array, 2);
} | [
"protected",
"function",
"_parse_quotes",
"(",
")",
"{",
"// Matches quote types",
"$",
"re",
"=",
"'/(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")/'",
";",
"$",
"quotes",
"=",
"$",
"this",
"->",
"_frame",
"->",
"get_style",
"(",
")",
"->",
"quotes",
";",
"// split on spaces, except within quotes",
"if",
"(",
"!",
"preg_match_all",
"(",
"$",
"re",
",",
"\"$quotes\"",
",",
"$",
"matches",
",",
"PREG_SET_ORDER",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"quotes_array",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"matches",
"as",
"$",
"_quote",
")",
"{",
"$",
"quotes_array",
"[",
"]",
"=",
"$",
"this",
"->",
"_parse_string",
"(",
"$",
"_quote",
"[",
"0",
"]",
",",
"true",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"quotes_array",
")",
")",
"{",
"$",
"quotes_array",
"=",
"array",
"(",
"'\"'",
",",
"'\"'",
")",
";",
"}",
"return",
"array_chunk",
"(",
"$",
"quotes_array",
",",
"2",
")",
";",
"}"
] | Parses a CSS "quotes" property
@return array|null An array of pairs of quotes | [
"Parses",
"a",
"CSS",
"quotes",
"property"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/FrameReflower/AbstractFrameReflower.php#L324-L346 |
210,319 | dompdf/dompdf | src/FrameReflower/Page.php | Page._check_callbacks | protected function _check_callbacks($event, $frame)
{
if (!isset($this->_callbacks)) {
$dompdf = $this->_frame->get_dompdf();
$this->_callbacks = $dompdf->get_callbacks();
$this->_canvas = $dompdf->get_canvas();
}
if (is_array($this->_callbacks) && isset($this->_callbacks[$event])) {
$info = array(
0 => $this->_canvas, "canvas" => $this->_canvas,
1 => $frame, "frame" => $frame,
);
$fs = $this->_callbacks[$event];
foreach ($fs as $f) {
if (is_callable($f)) {
if (is_array($f)) {
$f[0]->{$f[1]}($info);
} else {
$f($info);
}
}
}
}
} | php | protected function _check_callbacks($event, $frame)
{
if (!isset($this->_callbacks)) {
$dompdf = $this->_frame->get_dompdf();
$this->_callbacks = $dompdf->get_callbacks();
$this->_canvas = $dompdf->get_canvas();
}
if (is_array($this->_callbacks) && isset($this->_callbacks[$event])) {
$info = array(
0 => $this->_canvas, "canvas" => $this->_canvas,
1 => $frame, "frame" => $frame,
);
$fs = $this->_callbacks[$event];
foreach ($fs as $f) {
if (is_callable($f)) {
if (is_array($f)) {
$f[0]->{$f[1]}($info);
} else {
$f($info);
}
}
}
}
} | [
"protected",
"function",
"_check_callbacks",
"(",
"$",
"event",
",",
"$",
"frame",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_callbacks",
")",
")",
"{",
"$",
"dompdf",
"=",
"$",
"this",
"->",
"_frame",
"->",
"get_dompdf",
"(",
")",
";",
"$",
"this",
"->",
"_callbacks",
"=",
"$",
"dompdf",
"->",
"get_callbacks",
"(",
")",
";",
"$",
"this",
"->",
"_canvas",
"=",
"$",
"dompdf",
"->",
"get_canvas",
"(",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"_callbacks",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"_callbacks",
"[",
"$",
"event",
"]",
")",
")",
"{",
"$",
"info",
"=",
"array",
"(",
"0",
"=>",
"$",
"this",
"->",
"_canvas",
",",
"\"canvas\"",
"=>",
"$",
"this",
"->",
"_canvas",
",",
"1",
"=>",
"$",
"frame",
",",
"\"frame\"",
"=>",
"$",
"frame",
",",
")",
";",
"$",
"fs",
"=",
"$",
"this",
"->",
"_callbacks",
"[",
"$",
"event",
"]",
";",
"foreach",
"(",
"$",
"fs",
"as",
"$",
"f",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"f",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"f",
")",
")",
"{",
"$",
"f",
"[",
"0",
"]",
"->",
"{",
"$",
"f",
"[",
"1",
"]",
"}",
"(",
"$",
"info",
")",
";",
"}",
"else",
"{",
"$",
"f",
"(",
"$",
"info",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | Check for callbacks that need to be performed when a given event
gets triggered on a page
@param string $event the type of event
@param Frame $frame the frame that event is triggered on | [
"Check",
"for",
"callbacks",
"that",
"need",
"to",
"be",
"performed",
"when",
"a",
"given",
"event",
"gets",
"triggered",
"on",
"a",
"page"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/FrameReflower/Page.php#L180-L204 |
210,320 | dompdf/dompdf | lib/Cpdf.php | Cpdf.o_toUnicode | protected function o_toUnicode($id, $action)
{
switch ($action) {
case 'new':
$this->objects[$id] = array(
't' => 'toUnicode'
);
break;
case 'add':
break;
case 'out':
$ordering = '(UCS)';
$registry = '(Adobe)';
if ($this->encrypted) {
$this->encryptInit($id);
$ordering = $this->ARC4($ordering);
$registry = $this->ARC4($registry);
}
$stream = <<<EOT
/CIDInit /ProcSet findresource begin
12 dict begin
begincmap
/CIDSystemInfo
<</Registry $registry
/Ordering $ordering
/Supplement 0
>> def
/CMapName /Adobe-Identity-UCS def
/CMapType 2 def
1 begincodespacerange
<0000> <FFFF>
endcodespacerange
1 beginbfrange
<0000> <FFFF> <0000>
endbfrange
endcmap
CMapName currentdict /CMap defineresource pop
end
end
EOT;
$res = "\n$id 0 obj\n";
$res .= "<</Length " . mb_strlen($stream, '8bit') . " >>\n";
$res .= "stream\n" . $stream . "\nendstream" . "\nendobj";;
return $res;
}
return null;
} | php | protected function o_toUnicode($id, $action)
{
switch ($action) {
case 'new':
$this->objects[$id] = array(
't' => 'toUnicode'
);
break;
case 'add':
break;
case 'out':
$ordering = '(UCS)';
$registry = '(Adobe)';
if ($this->encrypted) {
$this->encryptInit($id);
$ordering = $this->ARC4($ordering);
$registry = $this->ARC4($registry);
}
$stream = <<<EOT
/CIDInit /ProcSet findresource begin
12 dict begin
begincmap
/CIDSystemInfo
<</Registry $registry
/Ordering $ordering
/Supplement 0
>> def
/CMapName /Adobe-Identity-UCS def
/CMapType 2 def
1 begincodespacerange
<0000> <FFFF>
endcodespacerange
1 beginbfrange
<0000> <FFFF> <0000>
endbfrange
endcmap
CMapName currentdict /CMap defineresource pop
end
end
EOT;
$res = "\n$id 0 obj\n";
$res .= "<</Length " . mb_strlen($stream, '8bit') . " >>\n";
$res .= "stream\n" . $stream . "\nendstream" . "\nendobj";;
return $res;
}
return null;
} | [
"protected",
"function",
"o_toUnicode",
"(",
"$",
"id",
",",
"$",
"action",
")",
"{",
"switch",
"(",
"$",
"action",
")",
"{",
"case",
"'new'",
":",
"$",
"this",
"->",
"objects",
"[",
"$",
"id",
"]",
"=",
"array",
"(",
"'t'",
"=>",
"'toUnicode'",
")",
";",
"break",
";",
"case",
"'add'",
":",
"break",
";",
"case",
"'out'",
":",
"$",
"ordering",
"=",
"'(UCS)'",
";",
"$",
"registry",
"=",
"'(Adobe)'",
";",
"if",
"(",
"$",
"this",
"->",
"encrypted",
")",
"{",
"$",
"this",
"->",
"encryptInit",
"(",
"$",
"id",
")",
";",
"$",
"ordering",
"=",
"$",
"this",
"->",
"ARC4",
"(",
"$",
"ordering",
")",
";",
"$",
"registry",
"=",
"$",
"this",
"->",
"ARC4",
"(",
"$",
"registry",
")",
";",
"}",
"$",
"stream",
"=",
" <<<EOT\n/CIDInit /ProcSet findresource begin\n12 dict begin\nbegincmap\n/CIDSystemInfo\n<</Registry $registry\n/Ordering $ordering\n/Supplement 0\n>> def\n/CMapName /Adobe-Identity-UCS def\n/CMapType 2 def\n1 begincodespacerange\n<0000> <FFFF>\nendcodespacerange\n1 beginbfrange\n<0000> <FFFF> <0000>\nendbfrange\nendcmap\nCMapName currentdict /CMap defineresource pop\nend\nend\nEOT",
";",
"$",
"res",
"=",
"\"\\n$id 0 obj\\n\"",
";",
"$",
"res",
".=",
"\"<</Length \"",
".",
"mb_strlen",
"(",
"$",
"stream",
",",
"'8bit'",
")",
".",
"\" >>\\n\"",
";",
"$",
"res",
".=",
"\"stream\\n\"",
".",
"$",
"stream",
".",
"\"\\nendstream\"",
".",
"\"\\nendobj\"",
";",
";",
"return",
"$",
"res",
";",
"}",
"return",
"null",
";",
"}"
] | A toUnicode section, needed for unicode fonts
@param $id
@param $action
@return null|string | [
"A",
"toUnicode",
"section",
"needed",
"for",
"unicode",
"fonts"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/Cpdf.php#L961-L1012 |
210,321 | dompdf/dompdf | lib/Cpdf.php | Cpdf.o_cidSystemInfo | protected function o_cidSystemInfo($id, $action)
{
switch ($action) {
case 'new':
$this->objects[$id] = array(
't' => 'cidSystemInfo'
);
break;
case 'add':
break;
case 'out':
$ordering = '(UCS)';
$registry = '(Adobe)';
if ($this->encrypted) {
$this->encryptInit($id);
$ordering = $this->ARC4($ordering);
$registry = $this->ARC4($registry);
}
$res = "\n$id 0 obj\n";
$res .= '<</Registry ' . $registry . "\n"; // A string identifying an issuer of character collections
$res .= '/Ordering ' . $ordering . "\n"; // A string that uniquely names a character collection issued by a specific registry
$res .= "/Supplement 0\n"; // The supplement number of the character collection.
$res .= ">>";
$res .= "\nendobj";;
return $res;
}
return null;
} | php | protected function o_cidSystemInfo($id, $action)
{
switch ($action) {
case 'new':
$this->objects[$id] = array(
't' => 'cidSystemInfo'
);
break;
case 'add':
break;
case 'out':
$ordering = '(UCS)';
$registry = '(Adobe)';
if ($this->encrypted) {
$this->encryptInit($id);
$ordering = $this->ARC4($ordering);
$registry = $this->ARC4($registry);
}
$res = "\n$id 0 obj\n";
$res .= '<</Registry ' . $registry . "\n"; // A string identifying an issuer of character collections
$res .= '/Ordering ' . $ordering . "\n"; // A string that uniquely names a character collection issued by a specific registry
$res .= "/Supplement 0\n"; // The supplement number of the character collection.
$res .= ">>";
$res .= "\nendobj";;
return $res;
}
return null;
} | [
"protected",
"function",
"o_cidSystemInfo",
"(",
"$",
"id",
",",
"$",
"action",
")",
"{",
"switch",
"(",
"$",
"action",
")",
"{",
"case",
"'new'",
":",
"$",
"this",
"->",
"objects",
"[",
"$",
"id",
"]",
"=",
"array",
"(",
"'t'",
"=>",
"'cidSystemInfo'",
")",
";",
"break",
";",
"case",
"'add'",
":",
"break",
";",
"case",
"'out'",
":",
"$",
"ordering",
"=",
"'(UCS)'",
";",
"$",
"registry",
"=",
"'(Adobe)'",
";",
"if",
"(",
"$",
"this",
"->",
"encrypted",
")",
"{",
"$",
"this",
"->",
"encryptInit",
"(",
"$",
"id",
")",
";",
"$",
"ordering",
"=",
"$",
"this",
"->",
"ARC4",
"(",
"$",
"ordering",
")",
";",
"$",
"registry",
"=",
"$",
"this",
"->",
"ARC4",
"(",
"$",
"registry",
")",
";",
"}",
"$",
"res",
"=",
"\"\\n$id 0 obj\\n\"",
";",
"$",
"res",
".=",
"'<</Registry '",
".",
"$",
"registry",
".",
"\"\\n\"",
";",
"// A string identifying an issuer of character collections",
"$",
"res",
".=",
"'/Ordering '",
".",
"$",
"ordering",
".",
"\"\\n\"",
";",
"// A string that uniquely names a character collection issued by a specific registry",
"$",
"res",
".=",
"\"/Supplement 0\\n\"",
";",
"// The supplement number of the character collection.",
"$",
"res",
".=",
"\">>\"",
";",
"$",
"res",
".=",
"\"\\nendobj\"",
";",
";",
"return",
"$",
"res",
";",
"}",
"return",
"null",
";",
"}"
] | CID system info section, needed for unicode fonts
@param $id
@param $action
@return null|string | [
"CID",
"system",
"info",
"section",
"needed",
"for",
"unicode",
"fonts"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/Cpdf.php#L1230-L1264 |
210,322 | dompdf/dompdf | lib/Cpdf.php | Cpdf.o_action | protected function o_action($id, $action, $options = '')
{
if ($action !== 'new') {
$o = &$this->objects[$id];
}
switch ($action) {
case 'new':
if (is_array($options)) {
$this->objects[$id] = array('t' => 'action', 'info' => $options, 'type' => $options['type']);
} else {
// then assume a URI action
$this->objects[$id] = array('t' => 'action', 'info' => $options, 'type' => 'URI');
}
break;
case 'out':
if ($this->encrypted) {
$this->encryptInit($id);
}
$res = "\n$id 0 obj\n<< /Type /Action";
switch ($o['type']) {
case 'ilink':
if (!isset($this->destinations[(string)$o['info']['label']])) {
break;
}
// there will be an 'label' setting, this is the name of the destination
$res .= "\n/S /GoTo\n/D " . $this->destinations[(string)$o['info']['label']] . " 0 R";
break;
case 'URI':
$res .= "\n/S /URI\n/URI (";
if ($this->encrypted) {
$res .= $this->filterText($this->ARC4($o['info']), false, false);
} else {
$res .= $this->filterText($o['info'], false, false);
}
$res .= ")";
break;
}
$res .= "\n>>\nendobj";
return $res;
}
return null;
} | php | protected function o_action($id, $action, $options = '')
{
if ($action !== 'new') {
$o = &$this->objects[$id];
}
switch ($action) {
case 'new':
if (is_array($options)) {
$this->objects[$id] = array('t' => 'action', 'info' => $options, 'type' => $options['type']);
} else {
// then assume a URI action
$this->objects[$id] = array('t' => 'action', 'info' => $options, 'type' => 'URI');
}
break;
case 'out':
if ($this->encrypted) {
$this->encryptInit($id);
}
$res = "\n$id 0 obj\n<< /Type /Action";
switch ($o['type']) {
case 'ilink':
if (!isset($this->destinations[(string)$o['info']['label']])) {
break;
}
// there will be an 'label' setting, this is the name of the destination
$res .= "\n/S /GoTo\n/D " . $this->destinations[(string)$o['info']['label']] . " 0 R";
break;
case 'URI':
$res .= "\n/S /URI\n/URI (";
if ($this->encrypted) {
$res .= $this->filterText($this->ARC4($o['info']), false, false);
} else {
$res .= $this->filterText($o['info'], false, false);
}
$res .= ")";
break;
}
$res .= "\n>>\nendobj";
return $res;
}
return null;
} | [
"protected",
"function",
"o_action",
"(",
"$",
"id",
",",
"$",
"action",
",",
"$",
"options",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"action",
"!==",
"'new'",
")",
"{",
"$",
"o",
"=",
"&",
"$",
"this",
"->",
"objects",
"[",
"$",
"id",
"]",
";",
"}",
"switch",
"(",
"$",
"action",
")",
"{",
"case",
"'new'",
":",
"if",
"(",
"is_array",
"(",
"$",
"options",
")",
")",
"{",
"$",
"this",
"->",
"objects",
"[",
"$",
"id",
"]",
"=",
"array",
"(",
"'t'",
"=>",
"'action'",
",",
"'info'",
"=>",
"$",
"options",
",",
"'type'",
"=>",
"$",
"options",
"[",
"'type'",
"]",
")",
";",
"}",
"else",
"{",
"// then assume a URI action",
"$",
"this",
"->",
"objects",
"[",
"$",
"id",
"]",
"=",
"array",
"(",
"'t'",
"=>",
"'action'",
",",
"'info'",
"=>",
"$",
"options",
",",
"'type'",
"=>",
"'URI'",
")",
";",
"}",
"break",
";",
"case",
"'out'",
":",
"if",
"(",
"$",
"this",
"->",
"encrypted",
")",
"{",
"$",
"this",
"->",
"encryptInit",
"(",
"$",
"id",
")",
";",
"}",
"$",
"res",
"=",
"\"\\n$id 0 obj\\n<< /Type /Action\"",
";",
"switch",
"(",
"$",
"o",
"[",
"'type'",
"]",
")",
"{",
"case",
"'ilink'",
":",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"destinations",
"[",
"(",
"string",
")",
"$",
"o",
"[",
"'info'",
"]",
"[",
"'label'",
"]",
"]",
")",
")",
"{",
"break",
";",
"}",
"// there will be an 'label' setting, this is the name of the destination",
"$",
"res",
".=",
"\"\\n/S /GoTo\\n/D \"",
".",
"$",
"this",
"->",
"destinations",
"[",
"(",
"string",
")",
"$",
"o",
"[",
"'info'",
"]",
"[",
"'label'",
"]",
"]",
".",
"\" 0 R\"",
";",
"break",
";",
"case",
"'URI'",
":",
"$",
"res",
".=",
"\"\\n/S /URI\\n/URI (\"",
";",
"if",
"(",
"$",
"this",
"->",
"encrypted",
")",
"{",
"$",
"res",
".=",
"$",
"this",
"->",
"filterText",
"(",
"$",
"this",
"->",
"ARC4",
"(",
"$",
"o",
"[",
"'info'",
"]",
")",
",",
"false",
",",
"false",
")",
";",
"}",
"else",
"{",
"$",
"res",
".=",
"$",
"this",
"->",
"filterText",
"(",
"$",
"o",
"[",
"'info'",
"]",
",",
"false",
",",
"false",
")",
";",
"}",
"$",
"res",
".=",
"\")\"",
";",
"break",
";",
"}",
"$",
"res",
".=",
"\"\\n>>\\nendobj\"",
";",
"return",
"$",
"res",
";",
"}",
"return",
"null",
";",
"}"
] | an action object, used to link to URLS initially
@param $id
@param $action
@param string $options
@return null|string | [
"an",
"action",
"object",
"used",
"to",
"link",
"to",
"URLS",
"initially"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/Cpdf.php#L1443-L1493 |
210,323 | dompdf/dompdf | lib/Cpdf.php | Cpdf.md5_16 | function md5_16($string)
{
$tmp = md5($string);
$out = '';
for ($i = 0; $i <= 30; $i = $i + 2) {
$out .= chr(hexdec(substr($tmp, $i, 2)));
}
return $out;
} | php | function md5_16($string)
{
$tmp = md5($string);
$out = '';
for ($i = 0; $i <= 30; $i = $i + 2) {
$out .= chr(hexdec(substr($tmp, $i, 2)));
}
return $out;
} | [
"function",
"md5_16",
"(",
"$",
"string",
")",
"{",
"$",
"tmp",
"=",
"md5",
"(",
"$",
"string",
")",
";",
"$",
"out",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<=",
"30",
";",
"$",
"i",
"=",
"$",
"i",
"+",
"2",
")",
"{",
"$",
"out",
".=",
"chr",
"(",
"hexdec",
"(",
"substr",
"(",
"$",
"tmp",
",",
"$",
"i",
",",
"2",
")",
")",
")",
";",
"}",
"return",
"$",
"out",
";",
"}"
] | calculate the 16 byte version of the 128 bit md5 digest of the string
@param $string
@return string | [
"calculate",
"the",
"16",
"byte",
"version",
"of",
"the",
"128",
"bit",
"md5",
"digest",
"of",
"the",
"string"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/Cpdf.php#L2115-L2124 |
210,324 | dompdf/dompdf | lib/Cpdf.php | Cpdf.encryptInit | function encryptInit($id)
{
$tmp = $this->encryptionKey;
$hex = dechex($id);
if (mb_strlen($hex, '8bit') < 6) {
$hex = substr('000000', 0, 6 - mb_strlen($hex, '8bit')) . $hex;
}
$tmp .= chr(hexdec(substr($hex, 4, 2)))
. chr(hexdec(substr($hex, 2, 2)))
. chr(hexdec(substr($hex, 0, 2)))
. chr(0)
. chr(0)
;
$key = $this->md5_16($tmp);
$this->ARC4_init(substr($key, 0, 10));
} | php | function encryptInit($id)
{
$tmp = $this->encryptionKey;
$hex = dechex($id);
if (mb_strlen($hex, '8bit') < 6) {
$hex = substr('000000', 0, 6 - mb_strlen($hex, '8bit')) . $hex;
}
$tmp .= chr(hexdec(substr($hex, 4, 2)))
. chr(hexdec(substr($hex, 2, 2)))
. chr(hexdec(substr($hex, 0, 2)))
. chr(0)
. chr(0)
;
$key = $this->md5_16($tmp);
$this->ARC4_init(substr($key, 0, 10));
} | [
"function",
"encryptInit",
"(",
"$",
"id",
")",
"{",
"$",
"tmp",
"=",
"$",
"this",
"->",
"encryptionKey",
";",
"$",
"hex",
"=",
"dechex",
"(",
"$",
"id",
")",
";",
"if",
"(",
"mb_strlen",
"(",
"$",
"hex",
",",
"'8bit'",
")",
"<",
"6",
")",
"{",
"$",
"hex",
"=",
"substr",
"(",
"'000000'",
",",
"0",
",",
"6",
"-",
"mb_strlen",
"(",
"$",
"hex",
",",
"'8bit'",
")",
")",
".",
"$",
"hex",
";",
"}",
"$",
"tmp",
".=",
"chr",
"(",
"hexdec",
"(",
"substr",
"(",
"$",
"hex",
",",
"4",
",",
"2",
")",
")",
")",
".",
"chr",
"(",
"hexdec",
"(",
"substr",
"(",
"$",
"hex",
",",
"2",
",",
"2",
")",
")",
")",
".",
"chr",
"(",
"hexdec",
"(",
"substr",
"(",
"$",
"hex",
",",
"0",
",",
"2",
")",
")",
")",
".",
"chr",
"(",
"0",
")",
".",
"chr",
"(",
"0",
")",
";",
"$",
"key",
"=",
"$",
"this",
"->",
"md5_16",
"(",
"$",
"tmp",
")",
";",
"$",
"this",
"->",
"ARC4_init",
"(",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"10",
")",
")",
";",
"}"
] | initialize the encryption for processing a particular object
@param $id | [
"initialize",
"the",
"encryption",
"for",
"processing",
"a",
"particular",
"object"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/Cpdf.php#L2131-L2146 |
210,325 | dompdf/dompdf | lib/Cpdf.php | Cpdf.ARC4_init | function ARC4_init($key = '')
{
$this->arc4 = '';
// setup the control array
if (mb_strlen($key, '8bit') == 0) {
return;
}
$k = '';
while (mb_strlen($k, '8bit') < 256) {
$k .= $key;
}
$k = substr($k, 0, 256);
for ($i = 0; $i < 256; $i++) {
$this->arc4 .= chr($i);
}
$j = 0;
for ($i = 0; $i < 256; $i++) {
$t = $this->arc4[$i];
$j = ($j + ord($t) + ord($k[$i])) % 256;
$this->arc4[$i] = $this->arc4[$j];
$this->arc4[$j] = $t;
}
} | php | function ARC4_init($key = '')
{
$this->arc4 = '';
// setup the control array
if (mb_strlen($key, '8bit') == 0) {
return;
}
$k = '';
while (mb_strlen($k, '8bit') < 256) {
$k .= $key;
}
$k = substr($k, 0, 256);
for ($i = 0; $i < 256; $i++) {
$this->arc4 .= chr($i);
}
$j = 0;
for ($i = 0; $i < 256; $i++) {
$t = $this->arc4[$i];
$j = ($j + ord($t) + ord($k[$i])) % 256;
$this->arc4[$i] = $this->arc4[$j];
$this->arc4[$j] = $t;
}
} | [
"function",
"ARC4_init",
"(",
"$",
"key",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"arc4",
"=",
"''",
";",
"// setup the control array",
"if",
"(",
"mb_strlen",
"(",
"$",
"key",
",",
"'8bit'",
")",
"==",
"0",
")",
"{",
"return",
";",
"}",
"$",
"k",
"=",
"''",
";",
"while",
"(",
"mb_strlen",
"(",
"$",
"k",
",",
"'8bit'",
")",
"<",
"256",
")",
"{",
"$",
"k",
".=",
"$",
"key",
";",
"}",
"$",
"k",
"=",
"substr",
"(",
"$",
"k",
",",
"0",
",",
"256",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"256",
";",
"$",
"i",
"++",
")",
"{",
"$",
"this",
"->",
"arc4",
".=",
"chr",
"(",
"$",
"i",
")",
";",
"}",
"$",
"j",
"=",
"0",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"256",
";",
"$",
"i",
"++",
")",
"{",
"$",
"t",
"=",
"$",
"this",
"->",
"arc4",
"[",
"$",
"i",
"]",
";",
"$",
"j",
"=",
"(",
"$",
"j",
"+",
"ord",
"(",
"$",
"t",
")",
"+",
"ord",
"(",
"$",
"k",
"[",
"$",
"i",
"]",
")",
")",
"%",
"256",
";",
"$",
"this",
"->",
"arc4",
"[",
"$",
"i",
"]",
"=",
"$",
"this",
"->",
"arc4",
"[",
"$",
"j",
"]",
";",
"$",
"this",
"->",
"arc4",
"[",
"$",
"j",
"]",
"=",
"$",
"t",
";",
"}",
"}"
] | initialize the ARC4 encryption
@param string $key | [
"initialize",
"the",
"ARC4",
"encryption"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/Cpdf.php#L2153-L2180 |
210,326 | dompdf/dompdf | lib/Cpdf.php | Cpdf.ARC4 | function ARC4($text)
{
$len = mb_strlen($text, '8bit');
$a = 0;
$b = 0;
$c = $this->arc4;
$out = '';
for ($i = 0; $i < $len; $i++) {
$a = ($a + 1) % 256;
$t = $c[$a];
$b = ($b + ord($t)) % 256;
$c[$a] = $c[$b];
$c[$b] = $t;
$k = ord($c[(ord($c[$a]) + ord($c[$b])) % 256]);
$out .= chr(ord($text[$i]) ^ $k);
}
return $out;
} | php | function ARC4($text)
{
$len = mb_strlen($text, '8bit');
$a = 0;
$b = 0;
$c = $this->arc4;
$out = '';
for ($i = 0; $i < $len; $i++) {
$a = ($a + 1) % 256;
$t = $c[$a];
$b = ($b + ord($t)) % 256;
$c[$a] = $c[$b];
$c[$b] = $t;
$k = ord($c[(ord($c[$a]) + ord($c[$b])) % 256]);
$out .= chr(ord($text[$i]) ^ $k);
}
return $out;
} | [
"function",
"ARC4",
"(",
"$",
"text",
")",
"{",
"$",
"len",
"=",
"mb_strlen",
"(",
"$",
"text",
",",
"'8bit'",
")",
";",
"$",
"a",
"=",
"0",
";",
"$",
"b",
"=",
"0",
";",
"$",
"c",
"=",
"$",
"this",
"->",
"arc4",
";",
"$",
"out",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"len",
";",
"$",
"i",
"++",
")",
"{",
"$",
"a",
"=",
"(",
"$",
"a",
"+",
"1",
")",
"%",
"256",
";",
"$",
"t",
"=",
"$",
"c",
"[",
"$",
"a",
"]",
";",
"$",
"b",
"=",
"(",
"$",
"b",
"+",
"ord",
"(",
"$",
"t",
")",
")",
"%",
"256",
";",
"$",
"c",
"[",
"$",
"a",
"]",
"=",
"$",
"c",
"[",
"$",
"b",
"]",
";",
"$",
"c",
"[",
"$",
"b",
"]",
"=",
"$",
"t",
";",
"$",
"k",
"=",
"ord",
"(",
"$",
"c",
"[",
"(",
"ord",
"(",
"$",
"c",
"[",
"$",
"a",
"]",
")",
"+",
"ord",
"(",
"$",
"c",
"[",
"$",
"b",
"]",
")",
")",
"%",
"256",
"]",
")",
";",
"$",
"out",
".=",
"chr",
"(",
"ord",
"(",
"$",
"text",
"[",
"$",
"i",
"]",
")",
"^",
"$",
"k",
")",
";",
"}",
"return",
"$",
"out",
";",
"}"
] | ARC4 encrypt a text string
@param $text
@return string | [
"ARC4",
"encrypt",
"a",
"text",
"string"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/Cpdf.php#L2188-L2206 |
210,327 | dompdf/dompdf | lib/Cpdf.php | Cpdf.addLink | function addLink($url, $x0, $y0, $x1, $y1)
{
$this->numObj++;
$info = array('type' => 'link', 'url' => $url, 'rect' => array($x0, $y0, $x1, $y1));
$this->o_annotation($this->numObj, 'new', $info);
} | php | function addLink($url, $x0, $y0, $x1, $y1)
{
$this->numObj++;
$info = array('type' => 'link', 'url' => $url, 'rect' => array($x0, $y0, $x1, $y1));
$this->o_annotation($this->numObj, 'new', $info);
} | [
"function",
"addLink",
"(",
"$",
"url",
",",
"$",
"x0",
",",
"$",
"y0",
",",
"$",
"x1",
",",
"$",
"y1",
")",
"{",
"$",
"this",
"->",
"numObj",
"++",
";",
"$",
"info",
"=",
"array",
"(",
"'type'",
"=>",
"'link'",
",",
"'url'",
"=>",
"$",
"url",
",",
"'rect'",
"=>",
"array",
"(",
"$",
"x0",
",",
"$",
"y0",
",",
"$",
"x1",
",",
"$",
"y1",
")",
")",
";",
"$",
"this",
"->",
"o_annotation",
"(",
"$",
"this",
"->",
"numObj",
",",
"'new'",
",",
"$",
"info",
")",
";",
"}"
] | add a link in the document to an external URL
@param $url
@param $x0
@param $y0
@param $x1
@param $y1 | [
"add",
"a",
"link",
"in",
"the",
"document",
"to",
"an",
"external",
"URL"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/Cpdf.php#L2221-L2226 |
210,328 | dompdf/dompdf | lib/Cpdf.php | Cpdf.setColor | function setColor($color, $force = false)
{
$new_color = array($color[0], $color[1], $color[2], isset($color[3]) ? $color[3] : null);
if (!$force && $this->currentColor == $new_color) {
return;
}
if (isset($new_color[3])) {
$this->currentColor = $new_color;
$this->addContent(vsprintf("\n%.3F %.3F %.3F %.3F k", $this->currentColor));
} else {
if (isset($new_color[2])) {
$this->currentColor = $new_color;
$this->addContent(vsprintf("\n%.3F %.3F %.3F rg", $this->currentColor));
}
}
} | php | function setColor($color, $force = false)
{
$new_color = array($color[0], $color[1], $color[2], isset($color[3]) ? $color[3] : null);
if (!$force && $this->currentColor == $new_color) {
return;
}
if (isset($new_color[3])) {
$this->currentColor = $new_color;
$this->addContent(vsprintf("\n%.3F %.3F %.3F %.3F k", $this->currentColor));
} else {
if (isset($new_color[2])) {
$this->currentColor = $new_color;
$this->addContent(vsprintf("\n%.3F %.3F %.3F rg", $this->currentColor));
}
}
} | [
"function",
"setColor",
"(",
"$",
"color",
",",
"$",
"force",
"=",
"false",
")",
"{",
"$",
"new_color",
"=",
"array",
"(",
"$",
"color",
"[",
"0",
"]",
",",
"$",
"color",
"[",
"1",
"]",
",",
"$",
"color",
"[",
"2",
"]",
",",
"isset",
"(",
"$",
"color",
"[",
"3",
"]",
")",
"?",
"$",
"color",
"[",
"3",
"]",
":",
"null",
")",
";",
"if",
"(",
"!",
"$",
"force",
"&&",
"$",
"this",
"->",
"currentColor",
"==",
"$",
"new_color",
")",
"{",
"return",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"new_color",
"[",
"3",
"]",
")",
")",
"{",
"$",
"this",
"->",
"currentColor",
"=",
"$",
"new_color",
";",
"$",
"this",
"->",
"addContent",
"(",
"vsprintf",
"(",
"\"\\n%.3F %.3F %.3F %.3F k\"",
",",
"$",
"this",
"->",
"currentColor",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"new_color",
"[",
"2",
"]",
")",
")",
"{",
"$",
"this",
"->",
"currentColor",
"=",
"$",
"new_color",
";",
"$",
"this",
"->",
"addContent",
"(",
"vsprintf",
"(",
"\"\\n%.3F %.3F %.3F rg\"",
",",
"$",
"this",
"->",
"currentColor",
")",
")",
";",
"}",
"}",
"}"
] | sets the color for fill operations
@param $color
@param bool $force | [
"sets",
"the",
"color",
"for",
"fill",
"operations"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/Cpdf.php#L3063-L3080 |
210,329 | dompdf/dompdf | lib/Cpdf.php | Cpdf.setStrokeColor | function setStrokeColor($color, $force = false)
{
$new_color = array($color[0], $color[1], $color[2], isset($color[3]) ? $color[3] : null);
if (!$force && $this->currentStrokeColor == $new_color) {
return;
}
if (isset($new_color[3])) {
$this->currentStrokeColor = $new_color;
$this->addContent(vsprintf("\n%.3F %.3F %.3F %.3F K", $this->currentStrokeColor));
} else {
if (isset($new_color[2])) {
$this->currentStrokeColor = $new_color;
$this->addContent(vsprintf("\n%.3F %.3F %.3F RG", $this->currentStrokeColor));
}
}
} | php | function setStrokeColor($color, $force = false)
{
$new_color = array($color[0], $color[1], $color[2], isset($color[3]) ? $color[3] : null);
if (!$force && $this->currentStrokeColor == $new_color) {
return;
}
if (isset($new_color[3])) {
$this->currentStrokeColor = $new_color;
$this->addContent(vsprintf("\n%.3F %.3F %.3F %.3F K", $this->currentStrokeColor));
} else {
if (isset($new_color[2])) {
$this->currentStrokeColor = $new_color;
$this->addContent(vsprintf("\n%.3F %.3F %.3F RG", $this->currentStrokeColor));
}
}
} | [
"function",
"setStrokeColor",
"(",
"$",
"color",
",",
"$",
"force",
"=",
"false",
")",
"{",
"$",
"new_color",
"=",
"array",
"(",
"$",
"color",
"[",
"0",
"]",
",",
"$",
"color",
"[",
"1",
"]",
",",
"$",
"color",
"[",
"2",
"]",
",",
"isset",
"(",
"$",
"color",
"[",
"3",
"]",
")",
"?",
"$",
"color",
"[",
"3",
"]",
":",
"null",
")",
";",
"if",
"(",
"!",
"$",
"force",
"&&",
"$",
"this",
"->",
"currentStrokeColor",
"==",
"$",
"new_color",
")",
"{",
"return",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"new_color",
"[",
"3",
"]",
")",
")",
"{",
"$",
"this",
"->",
"currentStrokeColor",
"=",
"$",
"new_color",
";",
"$",
"this",
"->",
"addContent",
"(",
"vsprintf",
"(",
"\"\\n%.3F %.3F %.3F %.3F K\"",
",",
"$",
"this",
"->",
"currentStrokeColor",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"new_color",
"[",
"2",
"]",
")",
")",
"{",
"$",
"this",
"->",
"currentStrokeColor",
"=",
"$",
"new_color",
";",
"$",
"this",
"->",
"addContent",
"(",
"vsprintf",
"(",
"\"\\n%.3F %.3F %.3F RG\"",
",",
"$",
"this",
"->",
"currentStrokeColor",
")",
")",
";",
"}",
"}",
"}"
] | sets the color for stroke operations
@param $color
@param bool $force | [
"sets",
"the",
"color",
"for",
"stroke",
"operations"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/Cpdf.php#L3102-L3119 |
210,330 | dompdf/dompdf | lib/Cpdf.php | Cpdf.filledRectangle | function filledRectangle($x1, $y1, $width, $height)
{
$this->addContent(sprintf("\n%.3F %.3F %.3F %.3F re f", $x1, $y1, $width, $height));
} | php | function filledRectangle($x1, $y1, $width, $height)
{
$this->addContent(sprintf("\n%.3F %.3F %.3F %.3F re f", $x1, $y1, $width, $height));
} | [
"function",
"filledRectangle",
"(",
"$",
"x1",
",",
"$",
"y1",
",",
"$",
"width",
",",
"$",
"height",
")",
"{",
"$",
"this",
"->",
"addContent",
"(",
"sprintf",
"(",
"\"\\n%.3F %.3F %.3F %.3F re f\"",
",",
"$",
"x1",
",",
"$",
"y1",
",",
"$",
"width",
",",
"$",
"height",
")",
")",
";",
"}"
] | a filled rectangle, note that it is the width and height of the rectangle which are the secondary parameters, not
the coordinates of the upper-right corner
@param $x1
@param $y1
@param $width
@param $height | [
"a",
"filled",
"rectangle",
"note",
"that",
"it",
"is",
"the",
"width",
"and",
"height",
"of",
"the",
"rectangle",
"which",
"are",
"the",
"secondary",
"parameters",
"not",
"the",
"coordinates",
"of",
"the",
"upper",
"-",
"right",
"corner"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/Cpdf.php#L3564-L3567 |
210,331 | dompdf/dompdf | lib/Cpdf.php | Cpdf.clippingRectangleRounded | function clippingRectangleRounded($x1, $y1, $w, $h, $rTL, $rTR, $rBR, $rBL)
{
$this->save();
// start: top edge, left end
$this->addContent(sprintf("\n%.3F %.3F m ", $x1, $y1 - $rTL + $h));
// line: bottom edge, left end
$this->addContent(sprintf("\n%.3F %.3F l ", $x1, $y1 + $rBL));
// curve: bottom-left corner
$this->ellipse($x1 + $rBL, $y1 + $rBL, $rBL, 0, 0, 8, 180, 270, false, false, false, true);
// line: right edge, bottom end
$this->addContent(sprintf("\n%.3F %.3F l ", $x1 + $w - $rBR, $y1));
// curve: bottom-right corner
$this->ellipse($x1 + $w - $rBR, $y1 + $rBR, $rBR, 0, 0, 8, 270, 360, false, false, false, true);
// line: right edge, top end
$this->addContent(sprintf("\n%.3F %.3F l ", $x1 + $w, $y1 + $h - $rTR));
// curve: bottom-right corner
$this->ellipse($x1 + $w - $rTR, $y1 + $h - $rTR, $rTR, 0, 0, 8, 0, 90, false, false, false, true);
// line: bottom edge, right end
$this->addContent(sprintf("\n%.3F %.3F l ", $x1 + $rTL, $y1 + $h));
// curve: top-right corner
$this->ellipse($x1 + $rTL, $y1 + $h - $rTL, $rTL, 0, 0, 8, 90, 180, false, false, false, true);
// line: top edge, left end
$this->addContent(sprintf("\n%.3F %.3F l ", $x1 + $rBL, $y1));
// Close & clip
$this->addContent(" W n");
} | php | function clippingRectangleRounded($x1, $y1, $w, $h, $rTL, $rTR, $rBR, $rBL)
{
$this->save();
// start: top edge, left end
$this->addContent(sprintf("\n%.3F %.3F m ", $x1, $y1 - $rTL + $h));
// line: bottom edge, left end
$this->addContent(sprintf("\n%.3F %.3F l ", $x1, $y1 + $rBL));
// curve: bottom-left corner
$this->ellipse($x1 + $rBL, $y1 + $rBL, $rBL, 0, 0, 8, 180, 270, false, false, false, true);
// line: right edge, bottom end
$this->addContent(sprintf("\n%.3F %.3F l ", $x1 + $w - $rBR, $y1));
// curve: bottom-right corner
$this->ellipse($x1 + $w - $rBR, $y1 + $rBR, $rBR, 0, 0, 8, 270, 360, false, false, false, true);
// line: right edge, top end
$this->addContent(sprintf("\n%.3F %.3F l ", $x1 + $w, $y1 + $h - $rTR));
// curve: bottom-right corner
$this->ellipse($x1 + $w - $rTR, $y1 + $h - $rTR, $rTR, 0, 0, 8, 0, 90, false, false, false, true);
// line: bottom edge, right end
$this->addContent(sprintf("\n%.3F %.3F l ", $x1 + $rTL, $y1 + $h));
// curve: top-right corner
$this->ellipse($x1 + $rTL, $y1 + $h - $rTL, $rTL, 0, 0, 8, 90, 180, false, false, false, true);
// line: top edge, left end
$this->addContent(sprintf("\n%.3F %.3F l ", $x1 + $rBL, $y1));
// Close & clip
$this->addContent(" W n");
} | [
"function",
"clippingRectangleRounded",
"(",
"$",
"x1",
",",
"$",
"y1",
",",
"$",
"w",
",",
"$",
"h",
",",
"$",
"rTL",
",",
"$",
"rTR",
",",
"$",
"rBR",
",",
"$",
"rBL",
")",
"{",
"$",
"this",
"->",
"save",
"(",
")",
";",
"// start: top edge, left end",
"$",
"this",
"->",
"addContent",
"(",
"sprintf",
"(",
"\"\\n%.3F %.3F m \"",
",",
"$",
"x1",
",",
"$",
"y1",
"-",
"$",
"rTL",
"+",
"$",
"h",
")",
")",
";",
"// line: bottom edge, left end",
"$",
"this",
"->",
"addContent",
"(",
"sprintf",
"(",
"\"\\n%.3F %.3F l \"",
",",
"$",
"x1",
",",
"$",
"y1",
"+",
"$",
"rBL",
")",
")",
";",
"// curve: bottom-left corner",
"$",
"this",
"->",
"ellipse",
"(",
"$",
"x1",
"+",
"$",
"rBL",
",",
"$",
"y1",
"+",
"$",
"rBL",
",",
"$",
"rBL",
",",
"0",
",",
"0",
",",
"8",
",",
"180",
",",
"270",
",",
"false",
",",
"false",
",",
"false",
",",
"true",
")",
";",
"// line: right edge, bottom end",
"$",
"this",
"->",
"addContent",
"(",
"sprintf",
"(",
"\"\\n%.3F %.3F l \"",
",",
"$",
"x1",
"+",
"$",
"w",
"-",
"$",
"rBR",
",",
"$",
"y1",
")",
")",
";",
"// curve: bottom-right corner",
"$",
"this",
"->",
"ellipse",
"(",
"$",
"x1",
"+",
"$",
"w",
"-",
"$",
"rBR",
",",
"$",
"y1",
"+",
"$",
"rBR",
",",
"$",
"rBR",
",",
"0",
",",
"0",
",",
"8",
",",
"270",
",",
"360",
",",
"false",
",",
"false",
",",
"false",
",",
"true",
")",
";",
"// line: right edge, top end",
"$",
"this",
"->",
"addContent",
"(",
"sprintf",
"(",
"\"\\n%.3F %.3F l \"",
",",
"$",
"x1",
"+",
"$",
"w",
",",
"$",
"y1",
"+",
"$",
"h",
"-",
"$",
"rTR",
")",
")",
";",
"// curve: bottom-right corner",
"$",
"this",
"->",
"ellipse",
"(",
"$",
"x1",
"+",
"$",
"w",
"-",
"$",
"rTR",
",",
"$",
"y1",
"+",
"$",
"h",
"-",
"$",
"rTR",
",",
"$",
"rTR",
",",
"0",
",",
"0",
",",
"8",
",",
"0",
",",
"90",
",",
"false",
",",
"false",
",",
"false",
",",
"true",
")",
";",
"// line: bottom edge, right end",
"$",
"this",
"->",
"addContent",
"(",
"sprintf",
"(",
"\"\\n%.3F %.3F l \"",
",",
"$",
"x1",
"+",
"$",
"rTL",
",",
"$",
"y1",
"+",
"$",
"h",
")",
")",
";",
"// curve: top-right corner",
"$",
"this",
"->",
"ellipse",
"(",
"$",
"x1",
"+",
"$",
"rTL",
",",
"$",
"y1",
"+",
"$",
"h",
"-",
"$",
"rTL",
",",
"$",
"rTL",
",",
"0",
",",
"0",
",",
"8",
",",
"90",
",",
"180",
",",
"false",
",",
"false",
",",
"false",
",",
"true",
")",
";",
"// line: top edge, left end",
"$",
"this",
"->",
"addContent",
"(",
"sprintf",
"(",
"\"\\n%.3F %.3F l \"",
",",
"$",
"x1",
"+",
"$",
"rBL",
",",
"$",
"y1",
")",
")",
";",
"// Close & clip",
"$",
"this",
"->",
"addContent",
"(",
"\" W n\"",
")",
";",
"}"
] | draw a clipping rounded rectangle, all the elements added after this will be clipped
@param $x1
@param $y1
@param $w
@param $h
@param $rTL
@param $rTR
@param $rBR
@param $rBL | [
"draw",
"a",
"clipping",
"rounded",
"rectangle",
"all",
"the",
"elements",
"added",
"after",
"this",
"will",
"be",
"clipped"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/Cpdf.php#L3660-L3696 |
210,332 | dompdf/dompdf | lib/Cpdf.php | Cpdf.newPage | function newPage($insert = 0, $id = 0, $pos = 'after')
{
// if there is a state saved, then go up the stack closing them
// then on the new page, re-open them with the right setings
if ($this->nStateStack) {
for ($i = $this->nStateStack; $i >= 1; $i--) {
$this->restoreState($i);
}
}
$this->numObj++;
if ($insert) {
// the id from the ezPdf class is the id of the contents of the page, not the page object itself
// query that object to find the parent
$rid = $this->objects[$id]['onPage'];
$opt = array('rid' => $rid, 'pos' => $pos);
$this->o_page($this->numObj, 'new', $opt);
} else {
$this->o_page($this->numObj, 'new');
}
// if there is a stack saved, then put that onto the page
if ($this->nStateStack) {
for ($i = 1; $i <= $this->nStateStack; $i++) {
$this->saveState($i);
}
}
// and if there has been a stroke or fill color set, then transfer them
if (isset($this->currentColor)) {
$this->setColor($this->currentColor, true);
}
if (isset($this->currentStrokeColor)) {
$this->setStrokeColor($this->currentStrokeColor, true);
}
// if there is a line style set, then put this in too
if (mb_strlen($this->currentLineStyle, '8bit')) {
$this->addContent("\n$this->currentLineStyle");
}
// the call to the o_page object set currentContents to the present page, so this can be returned as the page id
return $this->currentContents;
} | php | function newPage($insert = 0, $id = 0, $pos = 'after')
{
// if there is a state saved, then go up the stack closing them
// then on the new page, re-open them with the right setings
if ($this->nStateStack) {
for ($i = $this->nStateStack; $i >= 1; $i--) {
$this->restoreState($i);
}
}
$this->numObj++;
if ($insert) {
// the id from the ezPdf class is the id of the contents of the page, not the page object itself
// query that object to find the parent
$rid = $this->objects[$id]['onPage'];
$opt = array('rid' => $rid, 'pos' => $pos);
$this->o_page($this->numObj, 'new', $opt);
} else {
$this->o_page($this->numObj, 'new');
}
// if there is a stack saved, then put that onto the page
if ($this->nStateStack) {
for ($i = 1; $i <= $this->nStateStack; $i++) {
$this->saveState($i);
}
}
// and if there has been a stroke or fill color set, then transfer them
if (isset($this->currentColor)) {
$this->setColor($this->currentColor, true);
}
if (isset($this->currentStrokeColor)) {
$this->setStrokeColor($this->currentStrokeColor, true);
}
// if there is a line style set, then put this in too
if (mb_strlen($this->currentLineStyle, '8bit')) {
$this->addContent("\n$this->currentLineStyle");
}
// the call to the o_page object set currentContents to the present page, so this can be returned as the page id
return $this->currentContents;
} | [
"function",
"newPage",
"(",
"$",
"insert",
"=",
"0",
",",
"$",
"id",
"=",
"0",
",",
"$",
"pos",
"=",
"'after'",
")",
"{",
"// if there is a state saved, then go up the stack closing them",
"// then on the new page, re-open them with the right setings",
"if",
"(",
"$",
"this",
"->",
"nStateStack",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"$",
"this",
"->",
"nStateStack",
";",
"$",
"i",
">=",
"1",
";",
"$",
"i",
"--",
")",
"{",
"$",
"this",
"->",
"restoreState",
"(",
"$",
"i",
")",
";",
"}",
"}",
"$",
"this",
"->",
"numObj",
"++",
";",
"if",
"(",
"$",
"insert",
")",
"{",
"// the id from the ezPdf class is the id of the contents of the page, not the page object itself",
"// query that object to find the parent",
"$",
"rid",
"=",
"$",
"this",
"->",
"objects",
"[",
"$",
"id",
"]",
"[",
"'onPage'",
"]",
";",
"$",
"opt",
"=",
"array",
"(",
"'rid'",
"=>",
"$",
"rid",
",",
"'pos'",
"=>",
"$",
"pos",
")",
";",
"$",
"this",
"->",
"o_page",
"(",
"$",
"this",
"->",
"numObj",
",",
"'new'",
",",
"$",
"opt",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"o_page",
"(",
"$",
"this",
"->",
"numObj",
",",
"'new'",
")",
";",
"}",
"// if there is a stack saved, then put that onto the page",
"if",
"(",
"$",
"this",
"->",
"nStateStack",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<=",
"$",
"this",
"->",
"nStateStack",
";",
"$",
"i",
"++",
")",
"{",
"$",
"this",
"->",
"saveState",
"(",
"$",
"i",
")",
";",
"}",
"}",
"// and if there has been a stroke or fill color set, then transfer them",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"currentColor",
")",
")",
"{",
"$",
"this",
"->",
"setColor",
"(",
"$",
"this",
"->",
"currentColor",
",",
"true",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"currentStrokeColor",
")",
")",
"{",
"$",
"this",
"->",
"setStrokeColor",
"(",
"$",
"this",
"->",
"currentStrokeColor",
",",
"true",
")",
";",
"}",
"// if there is a line style set, then put this in too",
"if",
"(",
"mb_strlen",
"(",
"$",
"this",
"->",
"currentLineStyle",
",",
"'8bit'",
")",
")",
"{",
"$",
"this",
"->",
"addContent",
"(",
"\"\\n$this->currentLineStyle\"",
")",
";",
"}",
"// the call to the o_page object set currentContents to the present page, so this can be returned as the page id",
"return",
"$",
"this",
"->",
"currentContents",
";",
"}"
] | add a new page to the document
this also makes the new page the current active object
@param int $insert
@param int $id
@param string $pos
@return int | [
"add",
"a",
"new",
"page",
"to",
"the",
"document",
"this",
"also",
"makes",
"the",
"new",
"page",
"the",
"current",
"active",
"object"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/Cpdf.php#L3823-L3869 |
210,333 | dompdf/dompdf | lib/Cpdf.php | Cpdf.getFontDescender | function getFontDescender($size)
{
// note that this will most likely return a negative value
if (!$this->numFonts) {
$this->selectFont($this->defaultFont);
}
//$h = $this->fonts[$this->currentFont]['FontBBox'][1];
$h = $this->fonts[$this->currentFont]['Descender'];
return $size * $h / 1000;
} | php | function getFontDescender($size)
{
// note that this will most likely return a negative value
if (!$this->numFonts) {
$this->selectFont($this->defaultFont);
}
//$h = $this->fonts[$this->currentFont]['FontBBox'][1];
$h = $this->fonts[$this->currentFont]['Descender'];
return $size * $h / 1000;
} | [
"function",
"getFontDescender",
"(",
"$",
"size",
")",
"{",
"// note that this will most likely return a negative value",
"if",
"(",
"!",
"$",
"this",
"->",
"numFonts",
")",
"{",
"$",
"this",
"->",
"selectFont",
"(",
"$",
"this",
"->",
"defaultFont",
")",
";",
"}",
"//$h = $this->fonts[$this->currentFont]['FontBBox'][1];",
"$",
"h",
"=",
"$",
"this",
"->",
"fonts",
"[",
"$",
"this",
"->",
"currentFont",
"]",
"[",
"'Descender'",
"]",
";",
"return",
"$",
"size",
"*",
"$",
"h",
"/",
"1000",
";",
"}"
] | return the font descender, this will normally return a negative number
if you add this number to the baseline, you get the level of the bottom of the font
it is in the pdf user units
@param $size
@return float|int | [
"return",
"the",
"font",
"descender",
"this",
"will",
"normally",
"return",
"a",
"negative",
"number",
"if",
"you",
"add",
"this",
"number",
"to",
"the",
"baseline",
"you",
"get",
"the",
"level",
"of",
"the",
"bottom",
"of",
"the",
"font",
"it",
"is",
"in",
"the",
"pdf",
"user",
"units"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/Cpdf.php#L3978-L3989 |
210,334 | dompdf/dompdf | lib/html5lib/Parser.php | HTML5_Parser.parse | static public function parse($text, $builder = null) {
$tokenizer = new HTML5_Tokenizer($text, $builder);
$tokenizer->parse();
return $tokenizer->save();
} | php | static public function parse($text, $builder = null) {
$tokenizer = new HTML5_Tokenizer($text, $builder);
$tokenizer->parse();
return $tokenizer->save();
} | [
"static",
"public",
"function",
"parse",
"(",
"$",
"text",
",",
"$",
"builder",
"=",
"null",
")",
"{",
"$",
"tokenizer",
"=",
"new",
"HTML5_Tokenizer",
"(",
"$",
"text",
",",
"$",
"builder",
")",
";",
"$",
"tokenizer",
"->",
"parse",
"(",
")",
";",
"return",
"$",
"tokenizer",
"->",
"save",
"(",
")",
";",
"}"
] | Parses a full HTML document.
@param $text | HTML text to parse
@param $builder | Custom builder implementation
@return DOMDocument|DOMNodeList Parsed HTML as DOMDocument | [
"Parses",
"a",
"full",
"HTML",
"document",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/html5lib/Parser.php#L19-L23 |
210,335 | dompdf/dompdf | lib/html5lib/Parser.php | HTML5_Parser.parseFragment | static public function parseFragment($text, $context = null, $builder = null) {
$tokenizer = new HTML5_Tokenizer($text, $builder);
$tokenizer->parseFragment($context);
return $tokenizer->save();
} | php | static public function parseFragment($text, $context = null, $builder = null) {
$tokenizer = new HTML5_Tokenizer($text, $builder);
$tokenizer->parseFragment($context);
return $tokenizer->save();
} | [
"static",
"public",
"function",
"parseFragment",
"(",
"$",
"text",
",",
"$",
"context",
"=",
"null",
",",
"$",
"builder",
"=",
"null",
")",
"{",
"$",
"tokenizer",
"=",
"new",
"HTML5_Tokenizer",
"(",
"$",
"text",
",",
"$",
"builder",
")",
";",
"$",
"tokenizer",
"->",
"parseFragment",
"(",
"$",
"context",
")",
";",
"return",
"$",
"tokenizer",
"->",
"save",
"(",
")",
";",
"}"
] | Parses an HTML fragment.
@param $text | HTML text to parse
@param $context String name of context element to pretend parsing is in.
@param $builder | Custom builder implementation
@return DOMDocument|DOMNodeList Parsed HTML as DOMDocument | [
"Parses",
"an",
"HTML",
"fragment",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/html5lib/Parser.php#L32-L36 |
210,336 | dompdf/dompdf | lib/html5lib/TreeBuilder.php | HTML5_TreeBuilder.printStack | private function printStack() {
$names = array();
foreach ($this->stack as $i => $element) {
$names[] = $element->tagName;
}
echo " -> stack [" . implode(', ', $names) . "]\n";
} | php | private function printStack() {
$names = array();
foreach ($this->stack as $i => $element) {
$names[] = $element->tagName;
}
echo " -> stack [" . implode(', ', $names) . "]\n";
} | [
"private",
"function",
"printStack",
"(",
")",
"{",
"$",
"names",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"stack",
"as",
"$",
"i",
"=>",
"$",
"element",
")",
"{",
"$",
"names",
"[",
"]",
"=",
"$",
"element",
"->",
"tagName",
";",
"}",
"echo",
"\" -> stack [\"",
".",
"implode",
"(",
"', '",
",",
"$",
"names",
")",
".",
"\"]\\n\"",
";",
"}"
] | For debugging, prints the stack | [
"For",
"debugging",
"prints",
"the",
"stack"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/html5lib/TreeBuilder.php#L3733-L3739 |
210,337 | dompdf/dompdf | lib/html5lib/TreeBuilder.php | HTML5_TreeBuilder.printActiveFormattingElements | private function printActiveFormattingElements() {
if (!$this->a_formatting) {
return;
}
$names = array();
foreach ($this->a_formatting as $node) {
if ($node === self::MARKER) {
$names[] = 'MARKER';
} else {
$names[] = $node->tagName;
}
}
echo " -> active formatting [" . implode(', ', $names) . "]\n";
} | php | private function printActiveFormattingElements() {
if (!$this->a_formatting) {
return;
}
$names = array();
foreach ($this->a_formatting as $node) {
if ($node === self::MARKER) {
$names[] = 'MARKER';
} else {
$names[] = $node->tagName;
}
}
echo " -> active formatting [" . implode(', ', $names) . "]\n";
} | [
"private",
"function",
"printActiveFormattingElements",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"a_formatting",
")",
"{",
"return",
";",
"}",
"$",
"names",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"a_formatting",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"===",
"self",
"::",
"MARKER",
")",
"{",
"$",
"names",
"[",
"]",
"=",
"'MARKER'",
";",
"}",
"else",
"{",
"$",
"names",
"[",
"]",
"=",
"$",
"node",
"->",
"tagName",
";",
"}",
"}",
"echo",
"\" -> active formatting [\"",
".",
"implode",
"(",
"', '",
",",
"$",
"names",
")",
".",
"\"]\\n\"",
";",
"}"
] | For debugging, prints active formatting elements | [
"For",
"debugging",
"prints",
"active",
"formatting",
"elements"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/html5lib/TreeBuilder.php#L3744-L3757 |
210,338 | dompdf/dompdf | lib/html5lib/TreeBuilder.php | HTML5_TreeBuilder.setupContext | public function setupContext($context = null) {
$this->fragment = true;
if ($context) {
$context = $this->dom->createElementNS(self::NS_HTML, $context);
/* 4.1. Set the HTML parser's tokenization stage's content model
* flag according to the context element, as follows: */
switch ($context->tagName) {
case 'title': case 'textarea':
$this->content_model = HTML5_Tokenizer::RCDATA;
break;
case 'style': case 'script': case 'xmp': case 'iframe':
case 'noembed': case 'noframes':
$this->content_model = HTML5_Tokenizer::CDATA;
break;
case 'noscript':
// XSCRIPT: assuming scripting is enabled
$this->content_model = HTML5_Tokenizer::CDATA;
break;
case 'plaintext':
$this->content_model = HTML5_Tokenizer::PLAINTEXT;
break;
}
/* 4.2. Let root be a new html element with no attributes. */
$root = $this->dom->createElementNS(self::NS_HTML, 'html');
$this->root = $root;
/* 4.3 Append the element root to the Document node created above. */
$this->dom->appendChild($root);
/* 4.4 Set up the parser's stack of open elements so that it
* contains just the single element root. */
$this->stack = array($root);
/* 4.5 Reset the parser's insertion mode appropriately. */
$this->resetInsertionMode($context);
/* 4.6 Set the parser's form element pointer to the nearest node
* to the context element that is a form element (going straight up
* the ancestor chain, and including the element itself, if it is a
* form element), or, if there is no such form element, to null. */
$node = $context;
do {
if ($node->tagName === 'form') {
$this->form_pointer = $node;
break;
}
} while ($node = $node->parentNode);
}
} | php | public function setupContext($context = null) {
$this->fragment = true;
if ($context) {
$context = $this->dom->createElementNS(self::NS_HTML, $context);
/* 4.1. Set the HTML parser's tokenization stage's content model
* flag according to the context element, as follows: */
switch ($context->tagName) {
case 'title': case 'textarea':
$this->content_model = HTML5_Tokenizer::RCDATA;
break;
case 'style': case 'script': case 'xmp': case 'iframe':
case 'noembed': case 'noframes':
$this->content_model = HTML5_Tokenizer::CDATA;
break;
case 'noscript':
// XSCRIPT: assuming scripting is enabled
$this->content_model = HTML5_Tokenizer::CDATA;
break;
case 'plaintext':
$this->content_model = HTML5_Tokenizer::PLAINTEXT;
break;
}
/* 4.2. Let root be a new html element with no attributes. */
$root = $this->dom->createElementNS(self::NS_HTML, 'html');
$this->root = $root;
/* 4.3 Append the element root to the Document node created above. */
$this->dom->appendChild($root);
/* 4.4 Set up the parser's stack of open elements so that it
* contains just the single element root. */
$this->stack = array($root);
/* 4.5 Reset the parser's insertion mode appropriately. */
$this->resetInsertionMode($context);
/* 4.6 Set the parser's form element pointer to the nearest node
* to the context element that is a form element (going straight up
* the ancestor chain, and including the element itself, if it is a
* form element), or, if there is no such form element, to null. */
$node = $context;
do {
if ($node->tagName === 'form') {
$this->form_pointer = $node;
break;
}
} while ($node = $node->parentNode);
}
} | [
"public",
"function",
"setupContext",
"(",
"$",
"context",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"fragment",
"=",
"true",
";",
"if",
"(",
"$",
"context",
")",
"{",
"$",
"context",
"=",
"$",
"this",
"->",
"dom",
"->",
"createElementNS",
"(",
"self",
"::",
"NS_HTML",
",",
"$",
"context",
")",
";",
"/* 4.1. Set the HTML parser's tokenization stage's content model\n * flag according to the context element, as follows: */",
"switch",
"(",
"$",
"context",
"->",
"tagName",
")",
"{",
"case",
"'title'",
":",
"case",
"'textarea'",
":",
"$",
"this",
"->",
"content_model",
"=",
"HTML5_Tokenizer",
"::",
"RCDATA",
";",
"break",
";",
"case",
"'style'",
":",
"case",
"'script'",
":",
"case",
"'xmp'",
":",
"case",
"'iframe'",
":",
"case",
"'noembed'",
":",
"case",
"'noframes'",
":",
"$",
"this",
"->",
"content_model",
"=",
"HTML5_Tokenizer",
"::",
"CDATA",
";",
"break",
";",
"case",
"'noscript'",
":",
"// XSCRIPT: assuming scripting is enabled",
"$",
"this",
"->",
"content_model",
"=",
"HTML5_Tokenizer",
"::",
"CDATA",
";",
"break",
";",
"case",
"'plaintext'",
":",
"$",
"this",
"->",
"content_model",
"=",
"HTML5_Tokenizer",
"::",
"PLAINTEXT",
";",
"break",
";",
"}",
"/* 4.2. Let root be a new html element with no attributes. */",
"$",
"root",
"=",
"$",
"this",
"->",
"dom",
"->",
"createElementNS",
"(",
"self",
"::",
"NS_HTML",
",",
"'html'",
")",
";",
"$",
"this",
"->",
"root",
"=",
"$",
"root",
";",
"/* 4.3 Append the element root to the Document node created above. */",
"$",
"this",
"->",
"dom",
"->",
"appendChild",
"(",
"$",
"root",
")",
";",
"/* 4.4 Set up the parser's stack of open elements so that it\n * contains just the single element root. */",
"$",
"this",
"->",
"stack",
"=",
"array",
"(",
"$",
"root",
")",
";",
"/* 4.5 Reset the parser's insertion mode appropriately. */",
"$",
"this",
"->",
"resetInsertionMode",
"(",
"$",
"context",
")",
";",
"/* 4.6 Set the parser's form element pointer to the nearest node\n * to the context element that is a form element (going straight up\n * the ancestor chain, and including the element itself, if it is a\n * form element), or, if there is no such form element, to null. */",
"$",
"node",
"=",
"$",
"context",
";",
"do",
"{",
"if",
"(",
"$",
"node",
"->",
"tagName",
"===",
"'form'",
")",
"{",
"$",
"this",
"->",
"form_pointer",
"=",
"$",
"node",
";",
"break",
";",
"}",
"}",
"while",
"(",
"$",
"node",
"=",
"$",
"node",
"->",
"parentNode",
")",
";",
"}",
"}"
] | Sets up the tree constructor for building a fragment.
@param null $context | [
"Sets",
"up",
"the",
"tree",
"constructor",
"for",
"building",
"a",
"fragment",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/html5lib/TreeBuilder.php#L3771-L3815 |
210,339 | dompdf/dompdf | src/Adapter/PDFLib.php | PDFLib._close | protected function _close()
{
$this->_place_objects();
// Close all pages
$this->_pdf->suspend_page("");
for ($p = 1; $p <= $this->_page_count; $p++) {
$this->_pdf->resume_page("pagenumber=$p");
$this->_pdf->end_page_ext("");
}
$this->_pdf->end_document("");
} | php | protected function _close()
{
$this->_place_objects();
// Close all pages
$this->_pdf->suspend_page("");
for ($p = 1; $p <= $this->_page_count; $p++) {
$this->_pdf->resume_page("pagenumber=$p");
$this->_pdf->end_page_ext("");
}
$this->_pdf->end_document("");
} | [
"protected",
"function",
"_close",
"(",
")",
"{",
"$",
"this",
"->",
"_place_objects",
"(",
")",
";",
"// Close all pages",
"$",
"this",
"->",
"_pdf",
"->",
"suspend_page",
"(",
"\"\"",
")",
";",
"for",
"(",
"$",
"p",
"=",
"1",
";",
"$",
"p",
"<=",
"$",
"this",
"->",
"_page_count",
";",
"$",
"p",
"++",
")",
"{",
"$",
"this",
"->",
"_pdf",
"->",
"resume_page",
"(",
"\"pagenumber=$p\"",
")",
";",
"$",
"this",
"->",
"_pdf",
"->",
"end_page_ext",
"(",
"\"\"",
")",
";",
"}",
"$",
"this",
"->",
"_pdf",
"->",
"end_document",
"(",
"\"\"",
")",
";",
"}"
] | Close the pdf | [
"Close",
"the",
"pdf"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Adapter/PDFLib.php#L288-L300 |
210,340 | dompdf/dompdf | src/Adapter/PDFLib.php | PDFLib._set_gstate | public function _set_gstate($gstate_options)
{
if (($gstate = array_search($gstate_options, $this->_gstates)) === false) {
$gstate = $this->_pdf->create_gstate($gstate_options);
$this->_gstates[$gstate] = $gstate_options;
}
return $this->_pdf->set_gstate($gstate);
} | php | public function _set_gstate($gstate_options)
{
if (($gstate = array_search($gstate_options, $this->_gstates)) === false) {
$gstate = $this->_pdf->create_gstate($gstate_options);
$this->_gstates[$gstate] = $gstate_options;
}
return $this->_pdf->set_gstate($gstate);
} | [
"public",
"function",
"_set_gstate",
"(",
"$",
"gstate_options",
")",
"{",
"if",
"(",
"(",
"$",
"gstate",
"=",
"array_search",
"(",
"$",
"gstate_options",
",",
"$",
"this",
"->",
"_gstates",
")",
")",
"===",
"false",
")",
"{",
"$",
"gstate",
"=",
"$",
"this",
"->",
"_pdf",
"->",
"create_gstate",
"(",
"$",
"gstate_options",
")",
";",
"$",
"this",
"->",
"_gstates",
"[",
"$",
"gstate",
"]",
"=",
"$",
"gstate_options",
";",
"}",
"return",
"$",
"this",
"->",
"_pdf",
"->",
"set_gstate",
"(",
"$",
"gstate",
")",
";",
"}"
] | Sets the gstate
@param $gstate_options
@return int | [
"Sets",
"the",
"gstate"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Adapter/PDFLib.php#L707-L715 |
210,341 | dompdf/dompdf | src/Adapter/PDFLib.php | PDFLib.page_line | public function page_line($x1, $y1, $x2, $y2, $color, $width, $style = array())
{
$_t = 'line';
$this->_page_text[] = compact('_t', 'x1', 'y1', 'x2', 'y2', 'color', 'width', 'style');
} | php | public function page_line($x1, $y1, $x2, $y2, $color, $width, $style = array())
{
$_t = 'line';
$this->_page_text[] = compact('_t', 'x1', 'y1', 'x2', 'y2', 'color', 'width', 'style');
} | [
"public",
"function",
"page_line",
"(",
"$",
"x1",
",",
"$",
"y1",
",",
"$",
"x2",
",",
"$",
"y2",
",",
"$",
"color",
",",
"$",
"width",
",",
"$",
"style",
"=",
"array",
"(",
")",
")",
"{",
"$",
"_t",
"=",
"'line'",
";",
"$",
"this",
"->",
"_page_text",
"[",
"]",
"=",
"compact",
"(",
"'_t'",
",",
"'x1'",
",",
"'y1'",
",",
"'x2'",
",",
"'y2'",
",",
"'color'",
",",
"'width'",
",",
"'style'",
")",
";",
"}"
] | Draw line at the specified coordinates on every page.
See {@link Style::munge_color()} for the format of the colour array.
@param float $x1
@param float $y1
@param float $x2
@param float $y2
@param array $color
@param float $width
@param array $style optional | [
"Draw",
"line",
"at",
"the",
"specified",
"coordinates",
"on",
"every",
"page",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Adapter/PDFLib.php#L889-L893 |
210,342 | dompdf/dompdf | src/Frame/FrameTree.php | FrameTree.build_tree | public function build_tree()
{
$html = $this->_dom->getElementsByTagName("html")->item(0);
if (is_null($html)) {
$html = $this->_dom->firstChild;
}
if (is_null($html)) {
throw new Exception("Requested HTML document contains no data.");
}
$this->fix_tables();
$this->_root = $this->_build_tree_r($html);
} | php | public function build_tree()
{
$html = $this->_dom->getElementsByTagName("html")->item(0);
if (is_null($html)) {
$html = $this->_dom->firstChild;
}
if (is_null($html)) {
throw new Exception("Requested HTML document contains no data.");
}
$this->fix_tables();
$this->_root = $this->_build_tree_r($html);
} | [
"public",
"function",
"build_tree",
"(",
")",
"{",
"$",
"html",
"=",
"$",
"this",
"->",
"_dom",
"->",
"getElementsByTagName",
"(",
"\"html\"",
")",
"->",
"item",
"(",
"0",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"html",
")",
")",
"{",
"$",
"html",
"=",
"$",
"this",
"->",
"_dom",
"->",
"firstChild",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"html",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Requested HTML document contains no data.\"",
")",
";",
"}",
"$",
"this",
"->",
"fix_tables",
"(",
")",
";",
"$",
"this",
"->",
"_root",
"=",
"$",
"this",
"->",
"_build_tree_r",
"(",
"$",
"html",
")",
";",
"}"
] | Builds the tree | [
"Builds",
"the",
"tree"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Frame/FrameTree.php#L137-L151 |
210,343 | dompdf/dompdf | src/Frame/FrameTree.php | FrameTree._remove_node | protected function _remove_node(DOMNode $node, array &$children, $index)
{
$child = $children[$index];
$previousChild = $child->previousSibling;
$nextChild = $child->nextSibling;
$node->removeChild($child);
if (isset($previousChild, $nextChild)) {
if ($previousChild->nodeName === "#text" && $nextChild->nodeName === "#text") {
$previousChild->nodeValue .= $nextChild->nodeValue;
$this->_remove_node($node, $children, $index+1);
}
}
array_splice($children, $index, 1);
} | php | protected function _remove_node(DOMNode $node, array &$children, $index)
{
$child = $children[$index];
$previousChild = $child->previousSibling;
$nextChild = $child->nextSibling;
$node->removeChild($child);
if (isset($previousChild, $nextChild)) {
if ($previousChild->nodeName === "#text" && $nextChild->nodeName === "#text") {
$previousChild->nodeValue .= $nextChild->nodeValue;
$this->_remove_node($node, $children, $index+1);
}
}
array_splice($children, $index, 1);
} | [
"protected",
"function",
"_remove_node",
"(",
"DOMNode",
"$",
"node",
",",
"array",
"&",
"$",
"children",
",",
"$",
"index",
")",
"{",
"$",
"child",
"=",
"$",
"children",
"[",
"$",
"index",
"]",
";",
"$",
"previousChild",
"=",
"$",
"child",
"->",
"previousSibling",
";",
"$",
"nextChild",
"=",
"$",
"child",
"->",
"nextSibling",
";",
"$",
"node",
"->",
"removeChild",
"(",
"$",
"child",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"previousChild",
",",
"$",
"nextChild",
")",
")",
"{",
"if",
"(",
"$",
"previousChild",
"->",
"nodeName",
"===",
"\"#text\"",
"&&",
"$",
"nextChild",
"->",
"nodeName",
"===",
"\"#text\"",
")",
"{",
"$",
"previousChild",
"->",
"nodeValue",
".=",
"$",
"nextChild",
"->",
"nodeValue",
";",
"$",
"this",
"->",
"_remove_node",
"(",
"$",
"node",
",",
"$",
"children",
",",
"$",
"index",
"+",
"1",
")",
";",
"}",
"}",
"array_splice",
"(",
"$",
"children",
",",
"$",
"index",
",",
"1",
")",
";",
"}"
] | Remove a child from a node
Remove a child from a node. If the removed node results in two
adjacent #text nodes then combine them.
@param DOMNode $node the current DOMNode being considered
@param array $children an array of nodes that are the children of $node
@param int $index index from the $children array of the node to remove | [
"Remove",
"a",
"child",
"from",
"a",
"node"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Frame/FrameTree.php#L204-L217 |
210,344 | dompdf/dompdf | lib/html5lib/InputStream.php | HTML5_InputStream.charsUntil | public function charsUntil($bytes, $max = null) {
if ($this->char < $this->EOF) {
if ($max === 0 || $max) {
$len = strcspn($this->data, $bytes, $this->char, $max);
} else {
$len = strcspn($this->data, $bytes, $this->char);
}
$string = (string) substr($this->data, $this->char, $len);
$this->char += $len;
return $string;
} else {
return false;
}
} | php | public function charsUntil($bytes, $max = null) {
if ($this->char < $this->EOF) {
if ($max === 0 || $max) {
$len = strcspn($this->data, $bytes, $this->char, $max);
} else {
$len = strcspn($this->data, $bytes, $this->char);
}
$string = (string) substr($this->data, $this->char, $len);
$this->char += $len;
return $string;
} else {
return false;
}
} | [
"public",
"function",
"charsUntil",
"(",
"$",
"bytes",
",",
"$",
"max",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"char",
"<",
"$",
"this",
"->",
"EOF",
")",
"{",
"if",
"(",
"$",
"max",
"===",
"0",
"||",
"$",
"max",
")",
"{",
"$",
"len",
"=",
"strcspn",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"bytes",
",",
"$",
"this",
"->",
"char",
",",
"$",
"max",
")",
";",
"}",
"else",
"{",
"$",
"len",
"=",
"strcspn",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"bytes",
",",
"$",
"this",
"->",
"char",
")",
";",
"}",
"$",
"string",
"=",
"(",
"string",
")",
"substr",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"this",
"->",
"char",
",",
"$",
"len",
")",
";",
"$",
"this",
"->",
"char",
"+=",
"$",
"len",
";",
"return",
"$",
"string",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Matches as far as possible until we reach a certain set of bytes
and returns the matched substring.
@param $bytes | Bytes to match.
@param null $max
@return bool|string | [
"Matches",
"as",
"far",
"as",
"possible",
"until",
"we",
"reach",
"a",
"certain",
"set",
"of",
"bytes",
"and",
"returns",
"the",
"matched",
"substring",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/html5lib/InputStream.php#L253-L266 |
210,345 | dompdf/dompdf | lib/html5lib/InputStream.php | HTML5_InputStream.charsWhile | public function charsWhile($bytes, $max = null) {
if ($this->char < $this->EOF) {
if ($max === 0 || $max) {
$len = strspn($this->data, $bytes, $this->char, $max);
} else {
$len = strspn($this->data, $bytes, $this->char);
}
$string = (string) substr($this->data, $this->char, $len);
$this->char += $len;
return $string;
} else {
return false;
}
} | php | public function charsWhile($bytes, $max = null) {
if ($this->char < $this->EOF) {
if ($max === 0 || $max) {
$len = strspn($this->data, $bytes, $this->char, $max);
} else {
$len = strspn($this->data, $bytes, $this->char);
}
$string = (string) substr($this->data, $this->char, $len);
$this->char += $len;
return $string;
} else {
return false;
}
} | [
"public",
"function",
"charsWhile",
"(",
"$",
"bytes",
",",
"$",
"max",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"char",
"<",
"$",
"this",
"->",
"EOF",
")",
"{",
"if",
"(",
"$",
"max",
"===",
"0",
"||",
"$",
"max",
")",
"{",
"$",
"len",
"=",
"strspn",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"bytes",
",",
"$",
"this",
"->",
"char",
",",
"$",
"max",
")",
";",
"}",
"else",
"{",
"$",
"len",
"=",
"strspn",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"bytes",
",",
"$",
"this",
"->",
"char",
")",
";",
"}",
"$",
"string",
"=",
"(",
"string",
")",
"substr",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"this",
"->",
"char",
",",
"$",
"len",
")",
";",
"$",
"this",
"->",
"char",
"+=",
"$",
"len",
";",
"return",
"$",
"string",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Matches as far as possible with a certain set of bytes
and returns the matched substring.
@param $bytes | Bytes to match.
@param null $max
@return bool|string | [
"Matches",
"as",
"far",
"as",
"possible",
"with",
"a",
"certain",
"set",
"of",
"bytes",
"and",
"returns",
"the",
"matched",
"substring",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/html5lib/InputStream.php#L276-L289 |
210,346 | dompdf/dompdf | src/Cellmap.php | Cellmap.remove_row_group | public function remove_row_group(Frame $group)
{
$key = $group->get_id();
if (!isset($this->_frames[$key])) {
return; // Presumably this row has alredy been removed
}
$iter = $group->get_first_child();
while ($iter) {
$this->remove_row($iter);
$iter = $iter->get_next_sibling();
}
$this->_frames[$key] = null;
unset($this->_frames[$key]);
} | php | public function remove_row_group(Frame $group)
{
$key = $group->get_id();
if (!isset($this->_frames[$key])) {
return; // Presumably this row has alredy been removed
}
$iter = $group->get_first_child();
while ($iter) {
$this->remove_row($iter);
$iter = $iter->get_next_sibling();
}
$this->_frames[$key] = null;
unset($this->_frames[$key]);
} | [
"public",
"function",
"remove_row_group",
"(",
"Frame",
"$",
"group",
")",
"{",
"$",
"key",
"=",
"$",
"group",
"->",
"get_id",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_frames",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
";",
"// Presumably this row has alredy been removed",
"}",
"$",
"iter",
"=",
"$",
"group",
"->",
"get_first_child",
"(",
")",
";",
"while",
"(",
"$",
"iter",
")",
"{",
"$",
"this",
"->",
"remove_row",
"(",
"$",
"iter",
")",
";",
"$",
"iter",
"=",
"$",
"iter",
"->",
"get_next_sibling",
"(",
")",
";",
"}",
"$",
"this",
"->",
"_frames",
"[",
"$",
"key",
"]",
"=",
"null",
";",
"unset",
"(",
"$",
"this",
"->",
"_frames",
"[",
"$",
"key",
"]",
")",
";",
"}"
] | Remove a row group from the cellmap.
@param Frame $group The group to remove | [
"Remove",
"a",
"row",
"group",
"from",
"the",
"cellmap",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Cellmap.php#L774-L789 |
210,347 | dompdf/dompdf | src/Cellmap.php | Cellmap.update_row_group | public function update_row_group(Frame $group, Frame $last_row)
{
$g_key = $group->get_id();
$r_key = $last_row->get_id();
$r_rows = $this->_frames[$g_key]["rows"];
$this->_frames[$g_key]["rows"] = range($this->_frames[$g_key]["rows"][0], end($r_rows));
} | php | public function update_row_group(Frame $group, Frame $last_row)
{
$g_key = $group->get_id();
$r_key = $last_row->get_id();
$r_rows = $this->_frames[$g_key]["rows"];
$this->_frames[$g_key]["rows"] = range($this->_frames[$g_key]["rows"][0], end($r_rows));
} | [
"public",
"function",
"update_row_group",
"(",
"Frame",
"$",
"group",
",",
"Frame",
"$",
"last_row",
")",
"{",
"$",
"g_key",
"=",
"$",
"group",
"->",
"get_id",
"(",
")",
";",
"$",
"r_key",
"=",
"$",
"last_row",
"->",
"get_id",
"(",
")",
";",
"$",
"r_rows",
"=",
"$",
"this",
"->",
"_frames",
"[",
"$",
"g_key",
"]",
"[",
"\"rows\"",
"]",
";",
"$",
"this",
"->",
"_frames",
"[",
"$",
"g_key",
"]",
"[",
"\"rows\"",
"]",
"=",
"range",
"(",
"$",
"this",
"->",
"_frames",
"[",
"$",
"g_key",
"]",
"[",
"\"rows\"",
"]",
"[",
"0",
"]",
",",
"end",
"(",
"$",
"r_rows",
")",
")",
";",
"}"
] | Update a row group after rows have been removed
@param Frame $group The group to update
@param Frame $last_row The last row in the row group | [
"Update",
"a",
"row",
"group",
"after",
"rows",
"have",
"been",
"removed"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Cellmap.php#L797-L804 |
210,348 | dompdf/dompdf | src/Adapter/GD.php | GD.image | public function image($img_url, $x, $y, $w, $h, $resolution = "normal")
{
$img_type = Cache::detect_type($img_url, $this->get_dompdf()->getHttpContext());
if (!$img_type) {
return;
}
$func_name = "imagecreatefrom$img_type";
if (!function_exists($func_name)) {
if (!method_exists("Dompdf\Helpers", $func_name)) {
throw new \Exception("Function $func_name() not found. Cannot convert $img_type image: $img_url. Please install the image PHP extension.");
}
$func_name = "\\Dompdf\\Helpers::" . $func_name;
}
$src = @call_user_func($func_name, $img_url);
if (!$src) {
return; // Probably should add to $_dompdf_errors or whatever here
}
// Scale by the AA factor and DPI
$x = $this->_upscale($x);
$y = $this->_upscale($y);
$w = $this->_upscale($w);
$h = $this->_upscale($h);
$img_w = imagesx($src);
$img_h = imagesy($src);
imagecopyresampled($this->get_image(), $src, $x, $y, 0, 0, $w, $h, $img_w, $img_h);
} | php | public function image($img_url, $x, $y, $w, $h, $resolution = "normal")
{
$img_type = Cache::detect_type($img_url, $this->get_dompdf()->getHttpContext());
if (!$img_type) {
return;
}
$func_name = "imagecreatefrom$img_type";
if (!function_exists($func_name)) {
if (!method_exists("Dompdf\Helpers", $func_name)) {
throw new \Exception("Function $func_name() not found. Cannot convert $img_type image: $img_url. Please install the image PHP extension.");
}
$func_name = "\\Dompdf\\Helpers::" . $func_name;
}
$src = @call_user_func($func_name, $img_url);
if (!$src) {
return; // Probably should add to $_dompdf_errors or whatever here
}
// Scale by the AA factor and DPI
$x = $this->_upscale($x);
$y = $this->_upscale($y);
$w = $this->_upscale($w);
$h = $this->_upscale($h);
$img_w = imagesx($src);
$img_h = imagesy($src);
imagecopyresampled($this->get_image(), $src, $x, $y, 0, 0, $w, $h, $img_w, $img_h);
} | [
"public",
"function",
"image",
"(",
"$",
"img_url",
",",
"$",
"x",
",",
"$",
"y",
",",
"$",
"w",
",",
"$",
"h",
",",
"$",
"resolution",
"=",
"\"normal\"",
")",
"{",
"$",
"img_type",
"=",
"Cache",
"::",
"detect_type",
"(",
"$",
"img_url",
",",
"$",
"this",
"->",
"get_dompdf",
"(",
")",
"->",
"getHttpContext",
"(",
")",
")",
";",
"if",
"(",
"!",
"$",
"img_type",
")",
"{",
"return",
";",
"}",
"$",
"func_name",
"=",
"\"imagecreatefrom$img_type\"",
";",
"if",
"(",
"!",
"function_exists",
"(",
"$",
"func_name",
")",
")",
"{",
"if",
"(",
"!",
"method_exists",
"(",
"\"Dompdf\\Helpers\"",
",",
"$",
"func_name",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Function $func_name() not found. Cannot convert $img_type image: $img_url. Please install the image PHP extension.\"",
")",
";",
"}",
"$",
"func_name",
"=",
"\"\\\\Dompdf\\\\Helpers::\"",
".",
"$",
"func_name",
";",
"}",
"$",
"src",
"=",
"@",
"call_user_func",
"(",
"$",
"func_name",
",",
"$",
"img_url",
")",
";",
"if",
"(",
"!",
"$",
"src",
")",
"{",
"return",
";",
"// Probably should add to $_dompdf_errors or whatever here",
"}",
"// Scale by the AA factor and DPI",
"$",
"x",
"=",
"$",
"this",
"->",
"_upscale",
"(",
"$",
"x",
")",
";",
"$",
"y",
"=",
"$",
"this",
"->",
"_upscale",
"(",
"$",
"y",
")",
";",
"$",
"w",
"=",
"$",
"this",
"->",
"_upscale",
"(",
"$",
"w",
")",
";",
"$",
"h",
"=",
"$",
"this",
"->",
"_upscale",
"(",
"$",
"h",
")",
";",
"$",
"img_w",
"=",
"imagesx",
"(",
"$",
"src",
")",
";",
"$",
"img_h",
"=",
"imagesy",
"(",
"$",
"src",
")",
";",
"imagecopyresampled",
"(",
"$",
"this",
"->",
"get_image",
"(",
")",
",",
"$",
"src",
",",
"$",
"x",
",",
"$",
"y",
",",
"0",
",",
"0",
",",
"$",
"w",
",",
"$",
"h",
",",
"$",
"img_w",
",",
"$",
"img_h",
")",
";",
"}"
] | Add an image to the pdf.
The image is placed at the specified x and y coordinates with the
given width and height.
@param string $img_url the path to the image
@param float $x x position
@param float $y y position
@param int $w width (in pixels)
@param int $h height (in pixels)
@param string $resolution
@return void
@throws \Exception
@internal param string $img_type the type (e.g. extension) of the image | [
"Add",
"an",
"image",
"to",
"the",
"pdf",
".",
"The",
"image",
"is",
"placed",
"at",
"the",
"specified",
"x",
"and",
"y",
"coordinates",
"with",
"the",
"given",
"width",
"and",
"height",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Adapter/GD.php#L721-L753 |
210,349 | dompdf/dompdf | src/Adapter/GD.php | GD.stream | public function stream($filename, $options = array())
{
if (headers_sent()) {
die("Unable to stream image: headers already sent");
}
if (!isset($options["type"])) $options["type"] = "png";
if (!isset($options["Attachment"])) $options["Attachment"] = true;
$type = strtolower($options["type"]);
switch ($type) {
case "jpg":
case "jpeg":
$contentType = "image/jpeg";
$extension = ".jpg";
break;
case "png":
default:
$contentType = "image/png";
$extension = ".png";
break;
}
header("Cache-Control: private");
header("Content-Type: $contentType");
$filename = str_replace(array("\n", "'"), "", basename($filename, ".$type")) . $extension;
$attachment = $options["Attachment"] ? "attachment" : "inline";
header(Helpers::buildContentDispositionHeader($attachment, $filename));
$this->_output($options);
flush();
} | php | public function stream($filename, $options = array())
{
if (headers_sent()) {
die("Unable to stream image: headers already sent");
}
if (!isset($options["type"])) $options["type"] = "png";
if (!isset($options["Attachment"])) $options["Attachment"] = true;
$type = strtolower($options["type"]);
switch ($type) {
case "jpg":
case "jpeg":
$contentType = "image/jpeg";
$extension = ".jpg";
break;
case "png":
default:
$contentType = "image/png";
$extension = ".png";
break;
}
header("Cache-Control: private");
header("Content-Type: $contentType");
$filename = str_replace(array("\n", "'"), "", basename($filename, ".$type")) . $extension;
$attachment = $options["Attachment"] ? "attachment" : "inline";
header(Helpers::buildContentDispositionHeader($attachment, $filename));
$this->_output($options);
flush();
} | [
"public",
"function",
"stream",
"(",
"$",
"filename",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"headers_sent",
"(",
")",
")",
"{",
"die",
"(",
"\"Unable to stream image: headers already sent\"",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"\"type\"",
"]",
")",
")",
"$",
"options",
"[",
"\"type\"",
"]",
"=",
"\"png\"",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"\"Attachment\"",
"]",
")",
")",
"$",
"options",
"[",
"\"Attachment\"",
"]",
"=",
"true",
";",
"$",
"type",
"=",
"strtolower",
"(",
"$",
"options",
"[",
"\"type\"",
"]",
")",
";",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"\"jpg\"",
":",
"case",
"\"jpeg\"",
":",
"$",
"contentType",
"=",
"\"image/jpeg\"",
";",
"$",
"extension",
"=",
"\".jpg\"",
";",
"break",
";",
"case",
"\"png\"",
":",
"default",
":",
"$",
"contentType",
"=",
"\"image/png\"",
";",
"$",
"extension",
"=",
"\".png\"",
";",
"break",
";",
"}",
"header",
"(",
"\"Cache-Control: private\"",
")",
";",
"header",
"(",
"\"Content-Type: $contentType\"",
")",
";",
"$",
"filename",
"=",
"str_replace",
"(",
"array",
"(",
"\"\\n\"",
",",
"\"'\"",
")",
",",
"\"\"",
",",
"basename",
"(",
"$",
"filename",
",",
"\".$type\"",
")",
")",
".",
"$",
"extension",
";",
"$",
"attachment",
"=",
"$",
"options",
"[",
"\"Attachment\"",
"]",
"?",
"\"attachment\"",
":",
"\"inline\"",
";",
"header",
"(",
"Helpers",
"::",
"buildContentDispositionHeader",
"(",
"$",
"attachment",
",",
"$",
"filename",
")",
")",
";",
"$",
"this",
"->",
"_output",
"(",
"$",
"options",
")",
";",
"flush",
"(",
")",
";",
"}"
] | Streams the image to the client.
@param string $filename The filename to present to the client.
@param array $options Associative array: 'type' => jpeg|jpg|png; 'quality' => 0 - 100 (JPEG only);
'page' => Number of the page to output (defaults to the first); 'Attachment': 1 or 0 (default 1). | [
"Streams",
"the",
"image",
"to",
"the",
"client",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Adapter/GD.php#L993-L1025 |
210,350 | dompdf/dompdf | src/Adapter/GD.php | GD._output | private function _output($options = array())
{
if (!isset($options["type"])) $options["type"] = "png";
if (!isset($options["page"])) $options["page"] = 1;
$type = strtolower($options["type"]);
if (isset($this->_imgs[$options["page"] - 1])) {
$img = $this->_imgs[$options["page"] - 1];
} else {
$img = $this->_imgs[0];
}
// Perform any antialiasing
if ($this->_aa_factor != 1) {
$dst_w = $this->_actual_width / $this->_aa_factor;
$dst_h = $this->_actual_height / $this->_aa_factor;
$dst = imagecreatetruecolor($dst_w, $dst_h);
imagecopyresampled($dst, $img, 0, 0, 0, 0,
$dst_w, $dst_h,
$this->_actual_width, $this->_actual_height);
} else {
$dst = $img;
}
switch ($type) {
case "jpg":
case "jpeg":
if (!isset($options["quality"])) {
$options["quality"] = 75;
}
imagejpeg($dst, null, $options["quality"]);
break;
case "png":
default:
imagepng($dst);
break;
}
if ($this->_aa_factor != 1) {
imagedestroy($dst);
}
} | php | private function _output($options = array())
{
if (!isset($options["type"])) $options["type"] = "png";
if (!isset($options["page"])) $options["page"] = 1;
$type = strtolower($options["type"]);
if (isset($this->_imgs[$options["page"] - 1])) {
$img = $this->_imgs[$options["page"] - 1];
} else {
$img = $this->_imgs[0];
}
// Perform any antialiasing
if ($this->_aa_factor != 1) {
$dst_w = $this->_actual_width / $this->_aa_factor;
$dst_h = $this->_actual_height / $this->_aa_factor;
$dst = imagecreatetruecolor($dst_w, $dst_h);
imagecopyresampled($dst, $img, 0, 0, 0, 0,
$dst_w, $dst_h,
$this->_actual_width, $this->_actual_height);
} else {
$dst = $img;
}
switch ($type) {
case "jpg":
case "jpeg":
if (!isset($options["quality"])) {
$options["quality"] = 75;
}
imagejpeg($dst, null, $options["quality"]);
break;
case "png":
default:
imagepng($dst);
break;
}
if ($this->_aa_factor != 1) {
imagedestroy($dst);
}
} | [
"private",
"function",
"_output",
"(",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"\"type\"",
"]",
")",
")",
"$",
"options",
"[",
"\"type\"",
"]",
"=",
"\"png\"",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"\"page\"",
"]",
")",
")",
"$",
"options",
"[",
"\"page\"",
"]",
"=",
"1",
";",
"$",
"type",
"=",
"strtolower",
"(",
"$",
"options",
"[",
"\"type\"",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_imgs",
"[",
"$",
"options",
"[",
"\"page\"",
"]",
"-",
"1",
"]",
")",
")",
"{",
"$",
"img",
"=",
"$",
"this",
"->",
"_imgs",
"[",
"$",
"options",
"[",
"\"page\"",
"]",
"-",
"1",
"]",
";",
"}",
"else",
"{",
"$",
"img",
"=",
"$",
"this",
"->",
"_imgs",
"[",
"0",
"]",
";",
"}",
"// Perform any antialiasing",
"if",
"(",
"$",
"this",
"->",
"_aa_factor",
"!=",
"1",
")",
"{",
"$",
"dst_w",
"=",
"$",
"this",
"->",
"_actual_width",
"/",
"$",
"this",
"->",
"_aa_factor",
";",
"$",
"dst_h",
"=",
"$",
"this",
"->",
"_actual_height",
"/",
"$",
"this",
"->",
"_aa_factor",
";",
"$",
"dst",
"=",
"imagecreatetruecolor",
"(",
"$",
"dst_w",
",",
"$",
"dst_h",
")",
";",
"imagecopyresampled",
"(",
"$",
"dst",
",",
"$",
"img",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"$",
"dst_w",
",",
"$",
"dst_h",
",",
"$",
"this",
"->",
"_actual_width",
",",
"$",
"this",
"->",
"_actual_height",
")",
";",
"}",
"else",
"{",
"$",
"dst",
"=",
"$",
"img",
";",
"}",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"\"jpg\"",
":",
"case",
"\"jpeg\"",
":",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"\"quality\"",
"]",
")",
")",
"{",
"$",
"options",
"[",
"\"quality\"",
"]",
"=",
"75",
";",
"}",
"imagejpeg",
"(",
"$",
"dst",
",",
"null",
",",
"$",
"options",
"[",
"\"quality\"",
"]",
")",
";",
"break",
";",
"case",
"\"png\"",
":",
"default",
":",
"imagepng",
"(",
"$",
"dst",
")",
";",
"break",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"_aa_factor",
"!=",
"1",
")",
"{",
"imagedestroy",
"(",
"$",
"dst",
")",
";",
"}",
"}"
] | Outputs the image stream directly.
@param array $options Associative array: 'type' => jpeg|jpg|png; 'quality' => 0 - 100 (JPEG only);
'page' => Number of the page to output (defaults to the first). | [
"Outputs",
"the",
"image",
"stream",
"directly",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Adapter/GD.php#L1049-L1091 |
210,351 | dompdf/dompdf | src/Helpers.php | Helpers.dec2roman | public static function dec2roman($num)
{
static $ones = array("", "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix");
static $tens = array("", "x", "xx", "xxx", "xl", "l", "lx", "lxx", "lxxx", "xc");
static $hund = array("", "c", "cc", "ccc", "cd", "d", "dc", "dcc", "dccc", "cm");
static $thou = array("", "m", "mm", "mmm");
if (!is_numeric($num)) {
throw new Exception("dec2roman() requires a numeric argument.");
}
if ($num > 4000 || $num < 0) {
return "(out of range)";
}
$num = strrev((string)$num);
$ret = "";
switch (mb_strlen($num)) {
/** @noinspection PhpMissingBreakStatementInspection */
case 4:
$ret .= $thou[$num[3]];
/** @noinspection PhpMissingBreakStatementInspection */
case 3:
$ret .= $hund[$num[2]];
/** @noinspection PhpMissingBreakStatementInspection */
case 2:
$ret .= $tens[$num[1]];
/** @noinspection PhpMissingBreakStatementInspection */
case 1:
$ret .= $ones[$num[0]];
default:
break;
}
return $ret;
} | php | public static function dec2roman($num)
{
static $ones = array("", "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix");
static $tens = array("", "x", "xx", "xxx", "xl", "l", "lx", "lxx", "lxxx", "xc");
static $hund = array("", "c", "cc", "ccc", "cd", "d", "dc", "dcc", "dccc", "cm");
static $thou = array("", "m", "mm", "mmm");
if (!is_numeric($num)) {
throw new Exception("dec2roman() requires a numeric argument.");
}
if ($num > 4000 || $num < 0) {
return "(out of range)";
}
$num = strrev((string)$num);
$ret = "";
switch (mb_strlen($num)) {
/** @noinspection PhpMissingBreakStatementInspection */
case 4:
$ret .= $thou[$num[3]];
/** @noinspection PhpMissingBreakStatementInspection */
case 3:
$ret .= $hund[$num[2]];
/** @noinspection PhpMissingBreakStatementInspection */
case 2:
$ret .= $tens[$num[1]];
/** @noinspection PhpMissingBreakStatementInspection */
case 1:
$ret .= $ones[$num[0]];
default:
break;
}
return $ret;
} | [
"public",
"static",
"function",
"dec2roman",
"(",
"$",
"num",
")",
"{",
"static",
"$",
"ones",
"=",
"array",
"(",
"\"\"",
",",
"\"i\"",
",",
"\"ii\"",
",",
"\"iii\"",
",",
"\"iv\"",
",",
"\"v\"",
",",
"\"vi\"",
",",
"\"vii\"",
",",
"\"viii\"",
",",
"\"ix\"",
")",
";",
"static",
"$",
"tens",
"=",
"array",
"(",
"\"\"",
",",
"\"x\"",
",",
"\"xx\"",
",",
"\"xxx\"",
",",
"\"xl\"",
",",
"\"l\"",
",",
"\"lx\"",
",",
"\"lxx\"",
",",
"\"lxxx\"",
",",
"\"xc\"",
")",
";",
"static",
"$",
"hund",
"=",
"array",
"(",
"\"\"",
",",
"\"c\"",
",",
"\"cc\"",
",",
"\"ccc\"",
",",
"\"cd\"",
",",
"\"d\"",
",",
"\"dc\"",
",",
"\"dcc\"",
",",
"\"dccc\"",
",",
"\"cm\"",
")",
";",
"static",
"$",
"thou",
"=",
"array",
"(",
"\"\"",
",",
"\"m\"",
",",
"\"mm\"",
",",
"\"mmm\"",
")",
";",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"num",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"dec2roman() requires a numeric argument.\"",
")",
";",
"}",
"if",
"(",
"$",
"num",
">",
"4000",
"||",
"$",
"num",
"<",
"0",
")",
"{",
"return",
"\"(out of range)\"",
";",
"}",
"$",
"num",
"=",
"strrev",
"(",
"(",
"string",
")",
"$",
"num",
")",
";",
"$",
"ret",
"=",
"\"\"",
";",
"switch",
"(",
"mb_strlen",
"(",
"$",
"num",
")",
")",
"{",
"/** @noinspection PhpMissingBreakStatementInspection */",
"case",
"4",
":",
"$",
"ret",
".=",
"$",
"thou",
"[",
"$",
"num",
"[",
"3",
"]",
"]",
";",
"/** @noinspection PhpMissingBreakStatementInspection */",
"case",
"3",
":",
"$",
"ret",
".=",
"$",
"hund",
"[",
"$",
"num",
"[",
"2",
"]",
"]",
";",
"/** @noinspection PhpMissingBreakStatementInspection */",
"case",
"2",
":",
"$",
"ret",
".=",
"$",
"tens",
"[",
"$",
"num",
"[",
"1",
"]",
"]",
";",
"/** @noinspection PhpMissingBreakStatementInspection */",
"case",
"1",
":",
"$",
"ret",
".=",
"$",
"ones",
"[",
"$",
"num",
"[",
"0",
"]",
"]",
";",
"default",
":",
"break",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] | Converts decimal numbers to roman numerals
@param int $num
@throws Exception
@return string | [
"Converts",
"decimal",
"numbers",
"to",
"roman",
"numerals"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Helpers.php#L137-L174 |
210,352 | dompdf/dompdf | src/Helpers.php | Helpers.dompdf_debug | public static function dompdf_debug($type, $msg)
{
global $_DOMPDF_DEBUG_TYPES, $_dompdf_show_warnings, $_dompdf_debug;
if (isset($_DOMPDF_DEBUG_TYPES[$type]) && ($_dompdf_show_warnings || $_dompdf_debug)) {
$arr = debug_backtrace();
echo basename($arr[0]["file"]) . " (" . $arr[0]["line"] . "): " . $arr[1]["function"] . ": ";
Helpers::pre_r($msg);
}
} | php | public static function dompdf_debug($type, $msg)
{
global $_DOMPDF_DEBUG_TYPES, $_dompdf_show_warnings, $_dompdf_debug;
if (isset($_DOMPDF_DEBUG_TYPES[$type]) && ($_dompdf_show_warnings || $_dompdf_debug)) {
$arr = debug_backtrace();
echo basename($arr[0]["file"]) . " (" . $arr[0]["line"] . "): " . $arr[1]["function"] . ": ";
Helpers::pre_r($msg);
}
} | [
"public",
"static",
"function",
"dompdf_debug",
"(",
"$",
"type",
",",
"$",
"msg",
")",
"{",
"global",
"$",
"_DOMPDF_DEBUG_TYPES",
",",
"$",
"_dompdf_show_warnings",
",",
"$",
"_dompdf_debug",
";",
"if",
"(",
"isset",
"(",
"$",
"_DOMPDF_DEBUG_TYPES",
"[",
"$",
"type",
"]",
")",
"&&",
"(",
"$",
"_dompdf_show_warnings",
"||",
"$",
"_dompdf_debug",
")",
")",
"{",
"$",
"arr",
"=",
"debug_backtrace",
"(",
")",
";",
"echo",
"basename",
"(",
"$",
"arr",
"[",
"0",
"]",
"[",
"\"file\"",
"]",
")",
".",
"\" (\"",
".",
"$",
"arr",
"[",
"0",
"]",
"[",
"\"line\"",
"]",
".",
"\"): \"",
".",
"$",
"arr",
"[",
"1",
"]",
"[",
"\"function\"",
"]",
".",
"\": \"",
";",
"Helpers",
"::",
"pre_r",
"(",
"$",
"msg",
")",
";",
"}",
"}"
] | Print debug messages
@param string $type The type of debug messages to print
@param string $msg The message to show | [
"Print",
"debug",
"messages"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Helpers.php#L477-L486 |
210,353 | dompdf/dompdf | src/Helpers.php | Helpers.cmyk_to_rgb | public static function cmyk_to_rgb($c, $m = null, $y = null, $k = null)
{
if (is_array($c)) {
list($c, $m, $y, $k) = $c;
}
$c *= 255;
$m *= 255;
$y *= 255;
$k *= 255;
$r = (1 - round(2.55 * ($c + $k)));
$g = (1 - round(2.55 * ($m + $k)));
$b = (1 - round(2.55 * ($y + $k)));
if ($r < 0) {
$r = 0;
}
if ($g < 0) {
$g = 0;
}
if ($b < 0) {
$b = 0;
}
return array(
$r, $g, $b,
"r" => $r, "g" => $g, "b" => $b
);
} | php | public static function cmyk_to_rgb($c, $m = null, $y = null, $k = null)
{
if (is_array($c)) {
list($c, $m, $y, $k) = $c;
}
$c *= 255;
$m *= 255;
$y *= 255;
$k *= 255;
$r = (1 - round(2.55 * ($c + $k)));
$g = (1 - round(2.55 * ($m + $k)));
$b = (1 - round(2.55 * ($y + $k)));
if ($r < 0) {
$r = 0;
}
if ($g < 0) {
$g = 0;
}
if ($b < 0) {
$b = 0;
}
return array(
$r, $g, $b,
"r" => $r, "g" => $g, "b" => $b
);
} | [
"public",
"static",
"function",
"cmyk_to_rgb",
"(",
"$",
"c",
",",
"$",
"m",
"=",
"null",
",",
"$",
"y",
"=",
"null",
",",
"$",
"k",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"c",
")",
")",
"{",
"list",
"(",
"$",
"c",
",",
"$",
"m",
",",
"$",
"y",
",",
"$",
"k",
")",
"=",
"$",
"c",
";",
"}",
"$",
"c",
"*=",
"255",
";",
"$",
"m",
"*=",
"255",
";",
"$",
"y",
"*=",
"255",
";",
"$",
"k",
"*=",
"255",
";",
"$",
"r",
"=",
"(",
"1",
"-",
"round",
"(",
"2.55",
"*",
"(",
"$",
"c",
"+",
"$",
"k",
")",
")",
")",
";",
"$",
"g",
"=",
"(",
"1",
"-",
"round",
"(",
"2.55",
"*",
"(",
"$",
"m",
"+",
"$",
"k",
")",
")",
")",
";",
"$",
"b",
"=",
"(",
"1",
"-",
"round",
"(",
"2.55",
"*",
"(",
"$",
"y",
"+",
"$",
"k",
")",
")",
")",
";",
"if",
"(",
"$",
"r",
"<",
"0",
")",
"{",
"$",
"r",
"=",
"0",
";",
"}",
"if",
"(",
"$",
"g",
"<",
"0",
")",
"{",
"$",
"g",
"=",
"0",
";",
"}",
"if",
"(",
"$",
"b",
"<",
"0",
")",
"{",
"$",
"b",
"=",
"0",
";",
"}",
"return",
"array",
"(",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
",",
"\"r\"",
"=>",
"$",
"r",
",",
"\"g\"",
"=>",
"$",
"g",
",",
"\"b\"",
"=>",
"$",
"b",
")",
";",
"}"
] | Converts a CMYK color to RGB
@param float|float[] $c
@param float $m
@param float $y
@param float $k
@return float[] | [
"Converts",
"a",
"CMYK",
"color",
"to",
"RGB"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Helpers.php#L551-L580 |
210,354 | dompdf/dompdf | src/Helpers.php | Helpers.dompdf_getimagesize | public static function dompdf_getimagesize($filename, $context = null)
{
static $cache = array();
if (isset($cache[$filename])) {
return $cache[$filename];
}
list($width, $height, $type) = getimagesize($filename);
// Custom types
$types = array(
IMAGETYPE_JPEG => "jpeg",
IMAGETYPE_GIF => "gif",
IMAGETYPE_BMP => "bmp",
IMAGETYPE_PNG => "png",
);
$type = isset($types[$type]) ? $types[$type] : null;
if ($width == null || $height == null) {
list($data, $headers) = Helpers::getFileContent($filename, $context);
if (substr($data, 0, 2) === "BM") {
$meta = unpack('vtype/Vfilesize/Vreserved/Voffset/Vheadersize/Vwidth/Vheight', $data);
$width = (int)$meta['width'];
$height = (int)$meta['height'];
$type = "bmp";
}
else {
if (strpos($data, "<svg") !== false) {
$doc = new \Svg\Document();
$doc->loadFile($filename);
list($width, $height) = $doc->getDimensions();
$type = "svg";
}
}
}
return $cache[$filename] = array($width, $height, $type);
} | php | public static function dompdf_getimagesize($filename, $context = null)
{
static $cache = array();
if (isset($cache[$filename])) {
return $cache[$filename];
}
list($width, $height, $type) = getimagesize($filename);
// Custom types
$types = array(
IMAGETYPE_JPEG => "jpeg",
IMAGETYPE_GIF => "gif",
IMAGETYPE_BMP => "bmp",
IMAGETYPE_PNG => "png",
);
$type = isset($types[$type]) ? $types[$type] : null;
if ($width == null || $height == null) {
list($data, $headers) = Helpers::getFileContent($filename, $context);
if (substr($data, 0, 2) === "BM") {
$meta = unpack('vtype/Vfilesize/Vreserved/Voffset/Vheadersize/Vwidth/Vheight', $data);
$width = (int)$meta['width'];
$height = (int)$meta['height'];
$type = "bmp";
}
else {
if (strpos($data, "<svg") !== false) {
$doc = new \Svg\Document();
$doc->loadFile($filename);
list($width, $height) = $doc->getDimensions();
$type = "svg";
}
}
}
return $cache[$filename] = array($width, $height, $type);
} | [
"public",
"static",
"function",
"dompdf_getimagesize",
"(",
"$",
"filename",
",",
"$",
"context",
"=",
"null",
")",
"{",
"static",
"$",
"cache",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"cache",
"[",
"$",
"filename",
"]",
")",
")",
"{",
"return",
"$",
"cache",
"[",
"$",
"filename",
"]",
";",
"}",
"list",
"(",
"$",
"width",
",",
"$",
"height",
",",
"$",
"type",
")",
"=",
"getimagesize",
"(",
"$",
"filename",
")",
";",
"// Custom types",
"$",
"types",
"=",
"array",
"(",
"IMAGETYPE_JPEG",
"=>",
"\"jpeg\"",
",",
"IMAGETYPE_GIF",
"=>",
"\"gif\"",
",",
"IMAGETYPE_BMP",
"=>",
"\"bmp\"",
",",
"IMAGETYPE_PNG",
"=>",
"\"png\"",
",",
")",
";",
"$",
"type",
"=",
"isset",
"(",
"$",
"types",
"[",
"$",
"type",
"]",
")",
"?",
"$",
"types",
"[",
"$",
"type",
"]",
":",
"null",
";",
"if",
"(",
"$",
"width",
"==",
"null",
"||",
"$",
"height",
"==",
"null",
")",
"{",
"list",
"(",
"$",
"data",
",",
"$",
"headers",
")",
"=",
"Helpers",
"::",
"getFileContent",
"(",
"$",
"filename",
",",
"$",
"context",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"data",
",",
"0",
",",
"2",
")",
"===",
"\"BM\"",
")",
"{",
"$",
"meta",
"=",
"unpack",
"(",
"'vtype/Vfilesize/Vreserved/Voffset/Vheadersize/Vwidth/Vheight'",
",",
"$",
"data",
")",
";",
"$",
"width",
"=",
"(",
"int",
")",
"$",
"meta",
"[",
"'width'",
"]",
";",
"$",
"height",
"=",
"(",
"int",
")",
"$",
"meta",
"[",
"'height'",
"]",
";",
"$",
"type",
"=",
"\"bmp\"",
";",
"}",
"else",
"{",
"if",
"(",
"strpos",
"(",
"$",
"data",
",",
"\"<svg\"",
")",
"!==",
"false",
")",
"{",
"$",
"doc",
"=",
"new",
"\\",
"Svg",
"\\",
"Document",
"(",
")",
";",
"$",
"doc",
"->",
"loadFile",
"(",
"$",
"filename",
")",
";",
"list",
"(",
"$",
"width",
",",
"$",
"height",
")",
"=",
"$",
"doc",
"->",
"getDimensions",
"(",
")",
";",
"$",
"type",
"=",
"\"svg\"",
";",
"}",
"}",
"}",
"return",
"$",
"cache",
"[",
"$",
"filename",
"]",
"=",
"array",
"(",
"$",
"width",
",",
"$",
"height",
",",
"$",
"type",
")",
";",
"}"
] | getimagesize doesn't give a good size for 32bit BMP image v5
@param string $filename
@param resource $context
@return array The same format as getimagesize($filename) | [
"getimagesize",
"doesn",
"t",
"give",
"a",
"good",
"size",
"for",
"32bit",
"BMP",
"image",
"v5"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Helpers.php#L589-L631 |
210,355 | dompdf/dompdf | src/Adapter/CPDF.php | CPDF._set_stroke_color | protected function _set_stroke_color($color)
{
$this->_pdf->setStrokeColor($color);
$alpha = isset($color["alpha"]) ? $color["alpha"] : 1;
if ($this->_current_opacity != 1) {
$alpha *= $this->_current_opacity;
}
$this->_set_line_transparency("Normal", $alpha);
} | php | protected function _set_stroke_color($color)
{
$this->_pdf->setStrokeColor($color);
$alpha = isset($color["alpha"]) ? $color["alpha"] : 1;
if ($this->_current_opacity != 1) {
$alpha *= $this->_current_opacity;
}
$this->_set_line_transparency("Normal", $alpha);
} | [
"protected",
"function",
"_set_stroke_color",
"(",
"$",
"color",
")",
"{",
"$",
"this",
"->",
"_pdf",
"->",
"setStrokeColor",
"(",
"$",
"color",
")",
";",
"$",
"alpha",
"=",
"isset",
"(",
"$",
"color",
"[",
"\"alpha\"",
"]",
")",
"?",
"$",
"color",
"[",
"\"alpha\"",
"]",
":",
"1",
";",
"if",
"(",
"$",
"this",
"->",
"_current_opacity",
"!=",
"1",
")",
"{",
"$",
"alpha",
"*=",
"$",
"this",
"->",
"_current_opacity",
";",
"}",
"$",
"this",
"->",
"_set_line_transparency",
"(",
"\"Normal\"",
",",
"$",
"alpha",
")",
";",
"}"
] | Sets the stroke color
See {@link Style::set_color()} for the format of the color array.
@param array $color | [
"Sets",
"the",
"stroke",
"color"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Adapter/CPDF.php#L436-L444 |
210,356 | dompdf/dompdf | src/Adapter/CPDF.php | CPDF._convert_gif_bmp_to_png | protected function _convert_gif_bmp_to_png($image_url, $type)
{
$func_name = "imagecreatefrom$type";
if (!function_exists($func_name)) {
if (!method_exists("Dompdf\Helpers", $func_name)) {
throw new Exception("Function $func_name() not found. Cannot convert $type image: $image_url. Please install the image PHP extension.");
}
$func_name = "\\Dompdf\\Helpers::" . $func_name;
}
set_error_handler(array("\\Dompdf\\Helpers", "record_warnings"));
$im = call_user_func($func_name, $image_url);
if ($im) {
imageinterlace($im, false);
$tmp_dir = $this->_dompdf->getOptions()->getTempDir();
$tmp_name = @tempnam($tmp_dir, "{$type}dompdf_img_");
@unlink($tmp_name);
$filename = "$tmp_name.png";
$this->_image_cache[] = $filename;
imagepng($im, $filename);
imagedestroy($im);
} else {
$filename = Cache::$broken_image;
}
restore_error_handler();
return $filename;
} | php | protected function _convert_gif_bmp_to_png($image_url, $type)
{
$func_name = "imagecreatefrom$type";
if (!function_exists($func_name)) {
if (!method_exists("Dompdf\Helpers", $func_name)) {
throw new Exception("Function $func_name() not found. Cannot convert $type image: $image_url. Please install the image PHP extension.");
}
$func_name = "\\Dompdf\\Helpers::" . $func_name;
}
set_error_handler(array("\\Dompdf\\Helpers", "record_warnings"));
$im = call_user_func($func_name, $image_url);
if ($im) {
imageinterlace($im, false);
$tmp_dir = $this->_dompdf->getOptions()->getTempDir();
$tmp_name = @tempnam($tmp_dir, "{$type}dompdf_img_");
@unlink($tmp_name);
$filename = "$tmp_name.png";
$this->_image_cache[] = $filename;
imagepng($im, $filename);
imagedestroy($im);
} else {
$filename = Cache::$broken_image;
}
restore_error_handler();
return $filename;
} | [
"protected",
"function",
"_convert_gif_bmp_to_png",
"(",
"$",
"image_url",
",",
"$",
"type",
")",
"{",
"$",
"func_name",
"=",
"\"imagecreatefrom$type\"",
";",
"if",
"(",
"!",
"function_exists",
"(",
"$",
"func_name",
")",
")",
"{",
"if",
"(",
"!",
"method_exists",
"(",
"\"Dompdf\\Helpers\"",
",",
"$",
"func_name",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Function $func_name() not found. Cannot convert $type image: $image_url. Please install the image PHP extension.\"",
")",
";",
"}",
"$",
"func_name",
"=",
"\"\\\\Dompdf\\\\Helpers::\"",
".",
"$",
"func_name",
";",
"}",
"set_error_handler",
"(",
"array",
"(",
"\"\\\\Dompdf\\\\Helpers\"",
",",
"\"record_warnings\"",
")",
")",
";",
"$",
"im",
"=",
"call_user_func",
"(",
"$",
"func_name",
",",
"$",
"image_url",
")",
";",
"if",
"(",
"$",
"im",
")",
"{",
"imageinterlace",
"(",
"$",
"im",
",",
"false",
")",
";",
"$",
"tmp_dir",
"=",
"$",
"this",
"->",
"_dompdf",
"->",
"getOptions",
"(",
")",
"->",
"getTempDir",
"(",
")",
";",
"$",
"tmp_name",
"=",
"@",
"tempnam",
"(",
"$",
"tmp_dir",
",",
"\"{$type}dompdf_img_\"",
")",
";",
"@",
"unlink",
"(",
"$",
"tmp_name",
")",
";",
"$",
"filename",
"=",
"\"$tmp_name.png\"",
";",
"$",
"this",
"->",
"_image_cache",
"[",
"]",
"=",
"$",
"filename",
";",
"imagepng",
"(",
"$",
"im",
",",
"$",
"filename",
")",
";",
"imagedestroy",
"(",
"$",
"im",
")",
";",
"}",
"else",
"{",
"$",
"filename",
"=",
"Cache",
"::",
"$",
"broken_image",
";",
"}",
"restore_error_handler",
"(",
")",
";",
"return",
"$",
"filename",
";",
"}"
] | Convert a GIF or BMP image to a PNG image
@param string $image_url
@param integer $type
@throws Exception
@return string The url of the newly converted image | [
"Convert",
"a",
"GIF",
"or",
"BMP",
"image",
"to",
"a",
"PNG",
"image"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Adapter/CPDF.php#L612-L644 |
210,357 | dompdf/dompdf | src/FrameReflower/Block.php | Block._calculate_content_height | protected function _calculate_content_height()
{
$height = 0;
$lines = $this->_frame->get_line_boxes();
if (count($lines) > 0) {
$last_line = end($lines);
$content_box = $this->_frame->get_content_box();
$height = $last_line->y + $last_line->h - $content_box["y"];
}
return $height;
} | php | protected function _calculate_content_height()
{
$height = 0;
$lines = $this->_frame->get_line_boxes();
if (count($lines) > 0) {
$last_line = end($lines);
$content_box = $this->_frame->get_content_box();
$height = $last_line->y + $last_line->h - $content_box["y"];
}
return $height;
} | [
"protected",
"function",
"_calculate_content_height",
"(",
")",
"{",
"$",
"height",
"=",
"0",
";",
"$",
"lines",
"=",
"$",
"this",
"->",
"_frame",
"->",
"get_line_boxes",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"lines",
")",
">",
"0",
")",
"{",
"$",
"last_line",
"=",
"end",
"(",
"$",
"lines",
")",
";",
"$",
"content_box",
"=",
"$",
"this",
"->",
"_frame",
"->",
"get_content_box",
"(",
")",
";",
"$",
"height",
"=",
"$",
"last_line",
"->",
"y",
"+",
"$",
"last_line",
"->",
"h",
"-",
"$",
"content_box",
"[",
"\"y\"",
"]",
";",
"}",
"return",
"$",
"height",
";",
"}"
] | Determine the unrestricted height of content within the block
not by adding each line's height, but by getting the last line's position.
This because lines could have been pushed lower by a clearing element.
@return float | [
"Determine",
"the",
"unrestricted",
"height",
"of",
"content",
"within",
"the",
"block",
"not",
"by",
"adding",
"each",
"line",
"s",
"height",
"but",
"by",
"getting",
"the",
"last",
"line",
"s",
"position",
".",
"This",
"because",
"lines",
"could",
"have",
"been",
"pushed",
"lower",
"by",
"a",
"clearing",
"element",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/FrameReflower/Block.php#L236-L246 |
210,358 | dompdf/dompdf | src/Css/Stylesheet.php | Stylesheet.lookup | function lookup($key)
{
if (!isset($this->_styles[$key])) {
return null;
}
return $this->_styles[$key];
} | php | function lookup($key)
{
if (!isset($this->_styles[$key])) {
return null;
}
return $this->_styles[$key];
} | [
"function",
"lookup",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_styles",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"_styles",
"[",
"$",
"key",
"]",
";",
"}"
] | lookup a specific Style collection
lookup() returns the Style collection specified by $key, or null if the Style is
not found.
@param string $key the selector of the requested Style
@return Style
@Fixme _styles is a two dimensional array. It should produce wrong results | [
"lookup",
"a",
"specific",
"Style",
"collection"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Css/Stylesheet.php#L298-L305 |
210,359 | dompdf/dompdf | src/Css/Stylesheet.php | Stylesheet.load_css | function load_css(&$css, $origin = self::ORIG_AUTHOR)
{
if ($origin) {
$this->_current_origin = $origin;
}
$this->_parse_css($css);
} | php | function load_css(&$css, $origin = self::ORIG_AUTHOR)
{
if ($origin) {
$this->_current_origin = $origin;
}
$this->_parse_css($css);
} | [
"function",
"load_css",
"(",
"&",
"$",
"css",
",",
"$",
"origin",
"=",
"self",
"::",
"ORIG_AUTHOR",
")",
"{",
"if",
"(",
"$",
"origin",
")",
"{",
"$",
"this",
"->",
"_current_origin",
"=",
"$",
"origin",
";",
"}",
"$",
"this",
"->",
"_parse_css",
"(",
"$",
"css",
")",
";",
"}"
] | load and parse a CSS string
@param string $css
@param int $origin | [
"load",
"and",
"parse",
"a",
"CSS",
"string"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Css/Stylesheet.php#L324-L330 |
210,360 | dompdf/dompdf | src/Css/Stylesheet.php | Stylesheet.load_css_file | function load_css_file($file, $origin = self::ORIG_AUTHOR)
{
if ($origin) {
$this->_current_origin = $origin;
}
// Prevent circular references
if (isset($this->_loaded_files[$file])) {
return;
}
$this->_loaded_files[$file] = true;
if (strpos($file, "data:") === 0) {
$parsed = Helpers::parse_data_uri($file);
$css = $parsed["data"];
} else {
$parsed_url = Helpers::explode_url($file);
list($this->_protocol, $this->_base_host, $this->_base_path, $filename) = $parsed_url;
// Fix submitted by Nick Oostveen for aliased directory support:
if ($this->_protocol == "") {
$file = $this->_base_path . $filename;
} else {
$file = Helpers::build_url($this->_protocol, $this->_base_host, $this->_base_path, $filename);
}
list($css, $http_response_header) = Helpers::getFileContent($file, $this->_dompdf->getHttpContext());
$good_mime_type = true;
// See http://the-stickman.com/web-development/php/getting-http-response-headers-when-using-file_get_contents/
if (isset($http_response_header) && !$this->_dompdf->getQuirksmode()) {
foreach ($http_response_header as $_header) {
if (preg_match("@Content-Type:\s*([\w/]+)@i", $_header, $matches) &&
($matches[1] !== "text/css")
) {
$good_mime_type = false;
}
}
}
if (!$good_mime_type || $css == "") {
Helpers::record_warnings(E_USER_WARNING, "Unable to load css file $file", __FILE__, __LINE__);
return;
}
}
$this->_parse_css($css);
} | php | function load_css_file($file, $origin = self::ORIG_AUTHOR)
{
if ($origin) {
$this->_current_origin = $origin;
}
// Prevent circular references
if (isset($this->_loaded_files[$file])) {
return;
}
$this->_loaded_files[$file] = true;
if (strpos($file, "data:") === 0) {
$parsed = Helpers::parse_data_uri($file);
$css = $parsed["data"];
} else {
$parsed_url = Helpers::explode_url($file);
list($this->_protocol, $this->_base_host, $this->_base_path, $filename) = $parsed_url;
// Fix submitted by Nick Oostveen for aliased directory support:
if ($this->_protocol == "") {
$file = $this->_base_path . $filename;
} else {
$file = Helpers::build_url($this->_protocol, $this->_base_host, $this->_base_path, $filename);
}
list($css, $http_response_header) = Helpers::getFileContent($file, $this->_dompdf->getHttpContext());
$good_mime_type = true;
// See http://the-stickman.com/web-development/php/getting-http-response-headers-when-using-file_get_contents/
if (isset($http_response_header) && !$this->_dompdf->getQuirksmode()) {
foreach ($http_response_header as $_header) {
if (preg_match("@Content-Type:\s*([\w/]+)@i", $_header, $matches) &&
($matches[1] !== "text/css")
) {
$good_mime_type = false;
}
}
}
if (!$good_mime_type || $css == "") {
Helpers::record_warnings(E_USER_WARNING, "Unable to load css file $file", __FILE__, __LINE__);
return;
}
}
$this->_parse_css($css);
} | [
"function",
"load_css_file",
"(",
"$",
"file",
",",
"$",
"origin",
"=",
"self",
"::",
"ORIG_AUTHOR",
")",
"{",
"if",
"(",
"$",
"origin",
")",
"{",
"$",
"this",
"->",
"_current_origin",
"=",
"$",
"origin",
";",
"}",
"// Prevent circular references",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_loaded_files",
"[",
"$",
"file",
"]",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"_loaded_files",
"[",
"$",
"file",
"]",
"=",
"true",
";",
"if",
"(",
"strpos",
"(",
"$",
"file",
",",
"\"data:\"",
")",
"===",
"0",
")",
"{",
"$",
"parsed",
"=",
"Helpers",
"::",
"parse_data_uri",
"(",
"$",
"file",
")",
";",
"$",
"css",
"=",
"$",
"parsed",
"[",
"\"data\"",
"]",
";",
"}",
"else",
"{",
"$",
"parsed_url",
"=",
"Helpers",
"::",
"explode_url",
"(",
"$",
"file",
")",
";",
"list",
"(",
"$",
"this",
"->",
"_protocol",
",",
"$",
"this",
"->",
"_base_host",
",",
"$",
"this",
"->",
"_base_path",
",",
"$",
"filename",
")",
"=",
"$",
"parsed_url",
";",
"// Fix submitted by Nick Oostveen for aliased directory support:",
"if",
"(",
"$",
"this",
"->",
"_protocol",
"==",
"\"\"",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"_base_path",
".",
"$",
"filename",
";",
"}",
"else",
"{",
"$",
"file",
"=",
"Helpers",
"::",
"build_url",
"(",
"$",
"this",
"->",
"_protocol",
",",
"$",
"this",
"->",
"_base_host",
",",
"$",
"this",
"->",
"_base_path",
",",
"$",
"filename",
")",
";",
"}",
"list",
"(",
"$",
"css",
",",
"$",
"http_response_header",
")",
"=",
"Helpers",
"::",
"getFileContent",
"(",
"$",
"file",
",",
"$",
"this",
"->",
"_dompdf",
"->",
"getHttpContext",
"(",
")",
")",
";",
"$",
"good_mime_type",
"=",
"true",
";",
"// See http://the-stickman.com/web-development/php/getting-http-response-headers-when-using-file_get_contents/",
"if",
"(",
"isset",
"(",
"$",
"http_response_header",
")",
"&&",
"!",
"$",
"this",
"->",
"_dompdf",
"->",
"getQuirksmode",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"http_response_header",
"as",
"$",
"_header",
")",
"{",
"if",
"(",
"preg_match",
"(",
"\"@Content-Type:\\s*([\\w/]+)@i\"",
",",
"$",
"_header",
",",
"$",
"matches",
")",
"&&",
"(",
"$",
"matches",
"[",
"1",
"]",
"!==",
"\"text/css\"",
")",
")",
"{",
"$",
"good_mime_type",
"=",
"false",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"$",
"good_mime_type",
"||",
"$",
"css",
"==",
"\"\"",
")",
"{",
"Helpers",
"::",
"record_warnings",
"(",
"E_USER_WARNING",
",",
"\"Unable to load css file $file\"",
",",
"__FILE__",
",",
"__LINE__",
")",
";",
"return",
";",
"}",
"}",
"$",
"this",
"->",
"_parse_css",
"(",
"$",
"css",
")",
";",
"}"
] | load and parse a CSS file
@param string $file
@param int $origin | [
"load",
"and",
"parse",
"a",
"CSS",
"file"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Css/Stylesheet.php#L339-L389 |
210,361 | dompdf/dompdf | src/Css/Stylesheet.php | Stylesheet._parse_sections | private function _parse_sections($str, $media_queries = array())
{
// Pre-process: collapse all whitespace and strip whitespace around '>',
// '.', ':', '+', '#'
$patterns = array("/[\\s\n]+/", "/\\s+([>.:+#])\\s+/");
$replacements = array(" ", "\\1");
$str = preg_replace($patterns, $replacements, $str);
$DEBUGCSS = $this->_dompdf->getOptions()->getDebugCss();
$sections = explode("}", $str);
if ($DEBUGCSS) print '[_parse_sections';
foreach ($sections as $sect) {
$i = mb_strpos($sect, "{");
if ($i === false) { continue; }
//$selectors = explode(",", mb_substr($sect, 0, $i));
$selectors = preg_split("/,(?![^\(]*\))/", mb_substr($sect, 0, $i),0, PREG_SPLIT_NO_EMPTY);
if ($DEBUGCSS) print '[section';
$style = $this->_parse_properties(trim(mb_substr($sect, $i + 1)));
// Assign it to the selected elements
foreach ($selectors as $selector) {
$selector = trim($selector);
if ($selector == "") {
if ($DEBUGCSS) print '#empty#';
continue;
}
if ($DEBUGCSS) print '#' . $selector . '#';
//if ($DEBUGCSS) { if (strpos($selector,'p') !== false) print '!!!p!!!#'; }
//FIXME: tag the selector with a hash of the media query to separate it from non-conditional styles (?), xpath comments are probably not what we want to do here
if (count($media_queries) > 0) {
$style->set_media_queries($media_queries);
}
$this->add_style($selector, $style);
}
if ($DEBUGCSS) {
print 'section]';
}
}
if ($DEBUGCSS) {
print '_parse_sections]';
}
} | php | private function _parse_sections($str, $media_queries = array())
{
// Pre-process: collapse all whitespace and strip whitespace around '>',
// '.', ':', '+', '#'
$patterns = array("/[\\s\n]+/", "/\\s+([>.:+#])\\s+/");
$replacements = array(" ", "\\1");
$str = preg_replace($patterns, $replacements, $str);
$DEBUGCSS = $this->_dompdf->getOptions()->getDebugCss();
$sections = explode("}", $str);
if ($DEBUGCSS) print '[_parse_sections';
foreach ($sections as $sect) {
$i = mb_strpos($sect, "{");
if ($i === false) { continue; }
//$selectors = explode(",", mb_substr($sect, 0, $i));
$selectors = preg_split("/,(?![^\(]*\))/", mb_substr($sect, 0, $i),0, PREG_SPLIT_NO_EMPTY);
if ($DEBUGCSS) print '[section';
$style = $this->_parse_properties(trim(mb_substr($sect, $i + 1)));
// Assign it to the selected elements
foreach ($selectors as $selector) {
$selector = trim($selector);
if ($selector == "") {
if ($DEBUGCSS) print '#empty#';
continue;
}
if ($DEBUGCSS) print '#' . $selector . '#';
//if ($DEBUGCSS) { if (strpos($selector,'p') !== false) print '!!!p!!!#'; }
//FIXME: tag the selector with a hash of the media query to separate it from non-conditional styles (?), xpath comments are probably not what we want to do here
if (count($media_queries) > 0) {
$style->set_media_queries($media_queries);
}
$this->add_style($selector, $style);
}
if ($DEBUGCSS) {
print 'section]';
}
}
if ($DEBUGCSS) {
print '_parse_sections]';
}
} | [
"private",
"function",
"_parse_sections",
"(",
"$",
"str",
",",
"$",
"media_queries",
"=",
"array",
"(",
")",
")",
"{",
"// Pre-process: collapse all whitespace and strip whitespace around '>',",
"// '.', ':', '+', '#'",
"$",
"patterns",
"=",
"array",
"(",
"\"/[\\\\s\\n]+/\"",
",",
"\"/\\\\s+([>.:+#])\\\\s+/\"",
")",
";",
"$",
"replacements",
"=",
"array",
"(",
"\" \"",
",",
"\"\\\\1\"",
")",
";",
"$",
"str",
"=",
"preg_replace",
"(",
"$",
"patterns",
",",
"$",
"replacements",
",",
"$",
"str",
")",
";",
"$",
"DEBUGCSS",
"=",
"$",
"this",
"->",
"_dompdf",
"->",
"getOptions",
"(",
")",
"->",
"getDebugCss",
"(",
")",
";",
"$",
"sections",
"=",
"explode",
"(",
"\"}\"",
",",
"$",
"str",
")",
";",
"if",
"(",
"$",
"DEBUGCSS",
")",
"print",
"'[_parse_sections'",
";",
"foreach",
"(",
"$",
"sections",
"as",
"$",
"sect",
")",
"{",
"$",
"i",
"=",
"mb_strpos",
"(",
"$",
"sect",
",",
"\"{\"",
")",
";",
"if",
"(",
"$",
"i",
"===",
"false",
")",
"{",
"continue",
";",
"}",
"//$selectors = explode(\",\", mb_substr($sect, 0, $i));",
"$",
"selectors",
"=",
"preg_split",
"(",
"\"/,(?![^\\(]*\\))/\"",
",",
"mb_substr",
"(",
"$",
"sect",
",",
"0",
",",
"$",
"i",
")",
",",
"0",
",",
"PREG_SPLIT_NO_EMPTY",
")",
";",
"if",
"(",
"$",
"DEBUGCSS",
")",
"print",
"'[section'",
";",
"$",
"style",
"=",
"$",
"this",
"->",
"_parse_properties",
"(",
"trim",
"(",
"mb_substr",
"(",
"$",
"sect",
",",
"$",
"i",
"+",
"1",
")",
")",
")",
";",
"// Assign it to the selected elements",
"foreach",
"(",
"$",
"selectors",
"as",
"$",
"selector",
")",
"{",
"$",
"selector",
"=",
"trim",
"(",
"$",
"selector",
")",
";",
"if",
"(",
"$",
"selector",
"==",
"\"\"",
")",
"{",
"if",
"(",
"$",
"DEBUGCSS",
")",
"print",
"'#empty#'",
";",
"continue",
";",
"}",
"if",
"(",
"$",
"DEBUGCSS",
")",
"print",
"'#'",
".",
"$",
"selector",
".",
"'#'",
";",
"//if ($DEBUGCSS) { if (strpos($selector,'p') !== false) print '!!!p!!!#'; }",
"//FIXME: tag the selector with a hash of the media query to separate it from non-conditional styles (?), xpath comments are probably not what we want to do here",
"if",
"(",
"count",
"(",
"$",
"media_queries",
")",
">",
"0",
")",
"{",
"$",
"style",
"->",
"set_media_queries",
"(",
"$",
"media_queries",
")",
";",
"}",
"$",
"this",
"->",
"add_style",
"(",
"$",
"selector",
",",
"$",
"style",
")",
";",
"}",
"if",
"(",
"$",
"DEBUGCSS",
")",
"{",
"print",
"'section]'",
";",
"}",
"}",
"if",
"(",
"$",
"DEBUGCSS",
")",
"{",
"print",
"'_parse_sections]'",
";",
"}",
"}"
] | parse selector + rulesets
@param string $str CSS selectors and rulesets
@param array $media_queries | [
"parse",
"selector",
"+",
"rulesets"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Css/Stylesheet.php#L1636-L1684 |
210,362 | dompdf/dompdf | src/LineBox.php | LineBox.get_floats_inside | public function get_floats_inside(Page $root)
{
$floating_frames = $root->get_floating_frames();
if (count($floating_frames) == 0) {
return $floating_frames;
}
// Find nearest floating element
$p = $this->_block_frame;
while ($p->get_style()->float === "none") {
$parent = $p->get_parent();
if (!$parent) {
break;
}
$p = $parent;
}
if ($p == $root) {
return $floating_frames;
}
$parent = $p;
$childs = array();
foreach ($floating_frames as $_floating) {
$p = $_floating->get_parent();
while (($p = $p->get_parent()) && $p !== $parent);
if ($p) {
$childs[] = $p;
}
}
return $childs;
} | php | public function get_floats_inside(Page $root)
{
$floating_frames = $root->get_floating_frames();
if (count($floating_frames) == 0) {
return $floating_frames;
}
// Find nearest floating element
$p = $this->_block_frame;
while ($p->get_style()->float === "none") {
$parent = $p->get_parent();
if (!$parent) {
break;
}
$p = $parent;
}
if ($p == $root) {
return $floating_frames;
}
$parent = $p;
$childs = array();
foreach ($floating_frames as $_floating) {
$p = $_floating->get_parent();
while (($p = $p->get_parent()) && $p !== $parent);
if ($p) {
$childs[] = $p;
}
}
return $childs;
} | [
"public",
"function",
"get_floats_inside",
"(",
"Page",
"$",
"root",
")",
"{",
"$",
"floating_frames",
"=",
"$",
"root",
"->",
"get_floating_frames",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"floating_frames",
")",
"==",
"0",
")",
"{",
"return",
"$",
"floating_frames",
";",
"}",
"// Find nearest floating element",
"$",
"p",
"=",
"$",
"this",
"->",
"_block_frame",
";",
"while",
"(",
"$",
"p",
"->",
"get_style",
"(",
")",
"->",
"float",
"===",
"\"none\"",
")",
"{",
"$",
"parent",
"=",
"$",
"p",
"->",
"get_parent",
"(",
")",
";",
"if",
"(",
"!",
"$",
"parent",
")",
"{",
"break",
";",
"}",
"$",
"p",
"=",
"$",
"parent",
";",
"}",
"if",
"(",
"$",
"p",
"==",
"$",
"root",
")",
"{",
"return",
"$",
"floating_frames",
";",
"}",
"$",
"parent",
"=",
"$",
"p",
";",
"$",
"childs",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"floating_frames",
"as",
"$",
"_floating",
")",
"{",
"$",
"p",
"=",
"$",
"_floating",
"->",
"get_parent",
"(",
")",
";",
"while",
"(",
"(",
"$",
"p",
"=",
"$",
"p",
"->",
"get_parent",
"(",
")",
")",
"&&",
"$",
"p",
"!==",
"$",
"parent",
")",
";",
"if",
"(",
"$",
"p",
")",
"{",
"$",
"childs",
"[",
"]",
"=",
"$",
"p",
";",
"}",
"}",
"return",
"$",
"childs",
";",
"}"
] | Returns the floating elements inside the first floating parent
@param Page $root
@return Frame[] | [
"Returns",
"the",
"floating",
"elements",
"inside",
"the",
"first",
"floating",
"parent"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/LineBox.php#L101-L140 |
210,363 | dompdf/dompdf | src/LineBox.php | LineBox.recalculate_width | public function recalculate_width()
{
$width = 0;
foreach ($this->get_frames() as $frame) {
$width += $frame->calculate_auto_width();
}
return $this->w = $width;
} | php | public function recalculate_width()
{
$width = 0;
foreach ($this->get_frames() as $frame) {
$width += $frame->calculate_auto_width();
}
return $this->w = $width;
} | [
"public",
"function",
"recalculate_width",
"(",
")",
"{",
"$",
"width",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"get_frames",
"(",
")",
"as",
"$",
"frame",
")",
"{",
"$",
"width",
"+=",
"$",
"frame",
"->",
"calculate_auto_width",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"w",
"=",
"$",
"width",
";",
"}"
] | Recalculate LineBox width based on the contained frames total width.
@return float | [
"Recalculate",
"LineBox",
"width",
"based",
"on",
"the",
"contained",
"frames",
"total",
"width",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/LineBox.php#L266-L275 |
210,364 | dompdf/dompdf | src/Css/Style.php | Style.get_font_size | 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 ((string)$fs) {
case "xx-small":
case "x-small":
case "small":
case "medium":
case "large":
case "x-large":
case "xx-large":
$fs = self::$default_font_size * self::$font_size_keywords[$fs];
break;
case "smaller":
$fs = 8 / 9 * $this->_parent_font_size;
break;
case "larger":
$fs = 6 / 5 * $this->_parent_font_size;
break;
default:
break;
}
// Ensure relative sizes resolve to something
if (($i = mb_strpos($fs, "em")) !== false) {
$fs = (float)mb_substr($fs, 0, $i) * $this->_parent_font_size;
} else if (($i = mb_strpos($fs, "ex")) !== false) {
$fs = (float)mb_substr($fs, 0, $i) * $this->_parent_font_size;
} else {
$fs = (float)$this->length_in_pt($fs);
}
//see __set and __get, on all assignments clear cache!
$this->_prop_cache["font_size"] = null;
$this->_props["font_size"] = $fs;
$this->__font_size_calculated = true;
return $this->_props["font_size"];
} | php | 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 ((string)$fs) {
case "xx-small":
case "x-small":
case "small":
case "medium":
case "large":
case "x-large":
case "xx-large":
$fs = self::$default_font_size * self::$font_size_keywords[$fs];
break;
case "smaller":
$fs = 8 / 9 * $this->_parent_font_size;
break;
case "larger":
$fs = 6 / 5 * $this->_parent_font_size;
break;
default:
break;
}
// Ensure relative sizes resolve to something
if (($i = mb_strpos($fs, "em")) !== false) {
$fs = (float)mb_substr($fs, 0, $i) * $this->_parent_font_size;
} else if (($i = mb_strpos($fs, "ex")) !== false) {
$fs = (float)mb_substr($fs, 0, $i) * $this->_parent_font_size;
} else {
$fs = (float)$this->length_in_pt($fs);
}
//see __set and __get, on all assignments clear cache!
$this->_prop_cache["font_size"] = null;
$this->_props["font_size"] = $fs;
$this->__font_size_calculated = true;
return $this->_props["font_size"];
} | [
"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",
"(",
"(",
"string",
")",
"$",
"fs",
")",
"{",
"case",
"\"xx-small\"",
":",
"case",
"\"x-small\"",
":",
"case",
"\"small\"",
":",
"case",
"\"medium\"",
":",
"case",
"\"large\"",
":",
"case",
"\"x-large\"",
":",
"case",
"\"xx-large\"",
":",
"$",
"fs",
"=",
"self",
"::",
"$",
"default_font_size",
"*",
"self",
"::",
"$",
"font_size_keywords",
"[",
"$",
"fs",
"]",
";",
"break",
";",
"case",
"\"smaller\"",
":",
"$",
"fs",
"=",
"8",
"/",
"9",
"*",
"$",
"this",
"->",
"_parent_font_size",
";",
"break",
";",
"case",
"\"larger\"",
":",
"$",
"fs",
"=",
"6",
"/",
"5",
"*",
"$",
"this",
"->",
"_parent_font_size",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"// Ensure relative sizes resolve to something",
"if",
"(",
"(",
"$",
"i",
"=",
"mb_strpos",
"(",
"$",
"fs",
",",
"\"em\"",
")",
")",
"!==",
"false",
")",
"{",
"$",
"fs",
"=",
"(",
"float",
")",
"mb_substr",
"(",
"$",
"fs",
",",
"0",
",",
"$",
"i",
")",
"*",
"$",
"this",
"->",
"_parent_font_size",
";",
"}",
"else",
"if",
"(",
"(",
"$",
"i",
"=",
"mb_strpos",
"(",
"$",
"fs",
",",
"\"ex\"",
")",
")",
"!==",
"false",
")",
"{",
"$",
"fs",
"=",
"(",
"float",
")",
"mb_substr",
"(",
"$",
"fs",
",",
"0",
",",
"$",
"i",
")",
"*",
"$",
"this",
"->",
"_parent_font_size",
";",
"}",
"else",
"{",
"$",
"fs",
"=",
"(",
"float",
")",
"$",
"this",
"->",
"length_in_pt",
"(",
"$",
"fs",
")",
";",
"}",
"//see __set and __get, on all assignments clear cache!",
"$",
"this",
"->",
"_prop_cache",
"[",
"\"font_size\"",
"]",
"=",
"null",
";",
"$",
"this",
"->",
"_props",
"[",
"\"font_size\"",
"]",
"=",
"$",
"fs",
";",
"$",
"this",
"->",
"__font_size_calculated",
"=",
"true",
";",
"return",
"$",
"this",
"->",
"_props",
"[",
"\"font_size\"",
"]",
";",
"}"
] | Returns the resolved font size, in points
@link http://www.w3.org/TR/CSS21/fonts.html#propdef-font-size
@return float | [
"Returns",
"the",
"resolved",
"font",
"size",
"in",
"points"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Css/Style.php#L1007-L1062 |
210,365 | dompdf/dompdf | src/Css/Style.php | Style.get_background_position | 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,
);
} | php | 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,
);
} | [
"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 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 | [
"Returns",
"the",
"background",
"position",
"as",
"an",
"array"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Css/Style.php#L1148-L1225 |
210,366 | dompdf/dompdf | src/Css/Style.php | Style._get_border | protected function _get_border($side)
{
$color = $this->__get("border_" . $side . "_color");
return $this->__get("border_" . $side . "_width") . " " .
$this->__get("border_" . $side . "_style") . " " . $color["hex"];
} | php | protected function _get_border($side)
{
$color = $this->__get("border_" . $side . "_color");
return $this->__get("border_" . $side . "_width") . " " .
$this->__get("border_" . $side . "_style") . " " . $color["hex"];
} | [
"protected",
"function",
"_get_border",
"(",
"$",
"side",
")",
"{",
"$",
"color",
"=",
"$",
"this",
"->",
"__get",
"(",
"\"border_\"",
".",
"$",
"side",
".",
"\"_color\"",
")",
";",
"return",
"$",
"this",
"->",
"__get",
"(",
"\"border_\"",
".",
"$",
"side",
".",
"\"_width\"",
")",
".",
"\" \"",
".",
"$",
"this",
"->",
"__get",
"(",
"\"border_\"",
".",
"$",
"side",
".",
"\"_style\"",
")",
".",
"\" \"",
".",
"$",
"color",
"[",
"\"hex\"",
"]",
";",
"}"
] | Return a single border property
@param string $side
@return mixed | [
"Return",
"a",
"single",
"border",
"property"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Css/Style.php#L1422-L1428 |
210,367 | dompdf/dompdf | src/Css/Style.php | Style.get_outline_color | function get_outline_color()
{
if ($this->_props["outline_color"] === "") {
//see __set and __get, on all assignments clear cache!
$this->_prop_cache["outline_color"] = null;
$this->_props["outline_color"] = $this->__get("color");
}
return $this->munge_color($this->_props["outline_color"]);
} | php | function get_outline_color()
{
if ($this->_props["outline_color"] === "") {
//see __set and __get, on all assignments clear cache!
$this->_prop_cache["outline_color"] = null;
$this->_props["outline_color"] = $this->__get("color");
}
return $this->munge_color($this->_props["outline_color"]);
} | [
"function",
"get_outline_color",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_props",
"[",
"\"outline_color\"",
"]",
"===",
"\"\"",
")",
"{",
"//see __set and __get, on all assignments clear cache!",
"$",
"this",
"->",
"_prop_cache",
"[",
"\"outline_color\"",
"]",
"=",
"null",
";",
"$",
"this",
"->",
"_props",
"[",
"\"outline_color\"",
"]",
"=",
"$",
"this",
"->",
"__get",
"(",
"\"color\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"munge_color",
"(",
"$",
"this",
"->",
"_props",
"[",
"\"outline_color\"",
"]",
")",
";",
"}"
] | Returns the outline color as an array
See {@link Style::get_color()}
@link http://www.w3.org/TR/CSS21/box.html#border-color-properties
@return array | [
"Returns",
"the",
"outline",
"color",
"as",
"an",
"array"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Css/Style.php#L1524-L1533 |
210,368 | dompdf/dompdf | src/Css/Style.php | Style.get_border_spacing | function get_border_spacing()
{
$arr = explode(" ", $this->_props["border_spacing"]);
if (count($arr) == 1) {
$arr[1] = $arr[0];
}
return $arr;
} | php | function get_border_spacing()
{
$arr = explode(" ", $this->_props["border_spacing"]);
if (count($arr) == 1) {
$arr[1] = $arr[0];
}
return $arr;
} | [
"function",
"get_border_spacing",
"(",
")",
"{",
"$",
"arr",
"=",
"explode",
"(",
"\" \"",
",",
"$",
"this",
"->",
"_props",
"[",
"\"border_spacing\"",
"]",
")",
";",
"if",
"(",
"count",
"(",
"$",
"arr",
")",
"==",
"1",
")",
"{",
"$",
"arr",
"[",
"1",
"]",
"=",
"$",
"arr",
"[",
"0",
"]",
";",
"}",
"return",
"$",
"arr",
";",
"}"
] | Returns border spacing as an array
The array has the format (h_space,v_space)
@link http://www.w3.org/TR/CSS21/tables.html#propdef-border-spacing
@return array | [
"Returns",
"border",
"spacing",
"as",
"an",
"array"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Css/Style.php#L1573-L1580 |
210,369 | dompdf/dompdf | src/Css/Style.php | Style.set_background_color | function set_background_color($color)
{
$col = $this->munge_color($color);
if (is_null($col)) {
return;
//$col = self::$_defaults["background_color"];
}
//see __set and __get, on all assignments clear cache, not needed on direct set through __set
$this->_prop_cache["background_color"] = null;
$this->_props["background_color"] = is_array($col) ? $col["hex"] : $col;
} | php | function set_background_color($color)
{
$col = $this->munge_color($color);
if (is_null($col)) {
return;
//$col = self::$_defaults["background_color"];
}
//see __set and __get, on all assignments clear cache, not needed on direct set through __set
$this->_prop_cache["background_color"] = null;
$this->_props["background_color"] = is_array($col) ? $col["hex"] : $col;
} | [
"function",
"set_background_color",
"(",
"$",
"color",
")",
"{",
"$",
"col",
"=",
"$",
"this",
"->",
"munge_color",
"(",
"$",
"color",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"col",
")",
")",
"{",
"return",
";",
"//$col = self::$_defaults[\"background_color\"];",
"}",
"//see __set and __get, on all assignments clear cache, not needed on direct set through __set",
"$",
"this",
"->",
"_prop_cache",
"[",
"\"background_color\"",
"]",
"=",
"null",
";",
"$",
"this",
"->",
"_props",
"[",
"\"background_color\"",
"]",
"=",
"is_array",
"(",
"$",
"col",
")",
"?",
"$",
"col",
"[",
"\"hex\"",
"]",
":",
"$",
"col",
";",
"}"
] | Sets the background color
@link http://www.w3.org/TR/CSS21/colors.html#propdef-background-color
@param string $color | [
"Sets",
"the",
"background",
"color"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Css/Style.php#L1825-L1837 |
210,370 | dompdf/dompdf | src/Css/Style.php | Style.set_background_repeat | function set_background_repeat($val)
{
if (is_null($val)) {
$val = self::$_defaults["background_repeat"];
}
//see __set and __get, on all assignments clear cache, not needed on direct set through __set
$this->_prop_cache["background_repeat"] = null;
$this->_props["background_repeat"] = $val;
} | php | function set_background_repeat($val)
{
if (is_null($val)) {
$val = self::$_defaults["background_repeat"];
}
//see __set and __get, on all assignments clear cache, not needed on direct set through __set
$this->_prop_cache["background_repeat"] = null;
$this->_props["background_repeat"] = $val;
} | [
"function",
"set_background_repeat",
"(",
"$",
"val",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"val",
")",
")",
"{",
"$",
"val",
"=",
"self",
"::",
"$",
"_defaults",
"[",
"\"background_repeat\"",
"]",
";",
"}",
"//see __set and __get, on all assignments clear cache, not needed on direct set through __set",
"$",
"this",
"->",
"_prop_cache",
"[",
"\"background_repeat\"",
"]",
"=",
"null",
";",
"$",
"this",
"->",
"_props",
"[",
"\"background_repeat\"",
"]",
"=",
"$",
"val",
";",
"}"
] | Sets the background repeat
@link http://www.w3.org/TR/CSS21/colors.html#propdef-background-repeat
@param string $val | [
"Sets",
"the",
"background",
"repeat"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Css/Style.php#L1858-L1867 |
210,371 | dompdf/dompdf | src/Css/Style.php | Style.set_background | function set_background($val)
{
$val = trim($val);
$important = isset($this->_important_props["background"]);
if ($val === "none") {
$this->_set_style("background_image", "none", $important);
$this->_set_style("background_color", "transparent", $important);
} else {
$pos = array();
$tmp = preg_replace("/\s*\,\s*/", ",", $val); // when rgb() has spaces
$tmp = preg_split("/\s+/", $tmp);
foreach ($tmp as $attr) {
if (mb_substr($attr, 0, 3) === "url" || $attr === "none") {
$this->_set_style("background_image", $this->_image($attr), $important);
} elseif ($attr === "fixed" || $attr === "scroll") {
$this->_set_style("background_attachment", $attr, $important);
} elseif ($attr === "repeat" || $attr === "repeat-x" || $attr === "repeat-y" || $attr === "no-repeat") {
$this->_set_style("background_repeat", $attr, $important);
} elseif (($col = $this->munge_color($attr)) != null) {
$this->_set_style("background_color", is_array($col) ? $col["hex"] : $col, $important);
} else {
$pos[] = $attr;
}
}
if (count($pos)) {
$this->_set_style("background_position", implode(" ", $pos), $important);
}
}
//see __set and __get, on all assignments clear cache, not needed on direct set through __set
$this->_prop_cache["background"] = null;
$this->_props["background"] = $val;
} | php | function set_background($val)
{
$val = trim($val);
$important = isset($this->_important_props["background"]);
if ($val === "none") {
$this->_set_style("background_image", "none", $important);
$this->_set_style("background_color", "transparent", $important);
} else {
$pos = array();
$tmp = preg_replace("/\s*\,\s*/", ",", $val); // when rgb() has spaces
$tmp = preg_split("/\s+/", $tmp);
foreach ($tmp as $attr) {
if (mb_substr($attr, 0, 3) === "url" || $attr === "none") {
$this->_set_style("background_image", $this->_image($attr), $important);
} elseif ($attr === "fixed" || $attr === "scroll") {
$this->_set_style("background_attachment", $attr, $important);
} elseif ($attr === "repeat" || $attr === "repeat-x" || $attr === "repeat-y" || $attr === "no-repeat") {
$this->_set_style("background_repeat", $attr, $important);
} elseif (($col = $this->munge_color($attr)) != null) {
$this->_set_style("background_color", is_array($col) ? $col["hex"] : $col, $important);
} else {
$pos[] = $attr;
}
}
if (count($pos)) {
$this->_set_style("background_position", implode(" ", $pos), $important);
}
}
//see __set and __get, on all assignments clear cache, not needed on direct set through __set
$this->_prop_cache["background"] = null;
$this->_props["background"] = $val;
} | [
"function",
"set_background",
"(",
"$",
"val",
")",
"{",
"$",
"val",
"=",
"trim",
"(",
"$",
"val",
")",
";",
"$",
"important",
"=",
"isset",
"(",
"$",
"this",
"->",
"_important_props",
"[",
"\"background\"",
"]",
")",
";",
"if",
"(",
"$",
"val",
"===",
"\"none\"",
")",
"{",
"$",
"this",
"->",
"_set_style",
"(",
"\"background_image\"",
",",
"\"none\"",
",",
"$",
"important",
")",
";",
"$",
"this",
"->",
"_set_style",
"(",
"\"background_color\"",
",",
"\"transparent\"",
",",
"$",
"important",
")",
";",
"}",
"else",
"{",
"$",
"pos",
"=",
"array",
"(",
")",
";",
"$",
"tmp",
"=",
"preg_replace",
"(",
"\"/\\s*\\,\\s*/\"",
",",
"\",\"",
",",
"$",
"val",
")",
";",
"// when rgb() has spaces",
"$",
"tmp",
"=",
"preg_split",
"(",
"\"/\\s+/\"",
",",
"$",
"tmp",
")",
";",
"foreach",
"(",
"$",
"tmp",
"as",
"$",
"attr",
")",
"{",
"if",
"(",
"mb_substr",
"(",
"$",
"attr",
",",
"0",
",",
"3",
")",
"===",
"\"url\"",
"||",
"$",
"attr",
"===",
"\"none\"",
")",
"{",
"$",
"this",
"->",
"_set_style",
"(",
"\"background_image\"",
",",
"$",
"this",
"->",
"_image",
"(",
"$",
"attr",
")",
",",
"$",
"important",
")",
";",
"}",
"elseif",
"(",
"$",
"attr",
"===",
"\"fixed\"",
"||",
"$",
"attr",
"===",
"\"scroll\"",
")",
"{",
"$",
"this",
"->",
"_set_style",
"(",
"\"background_attachment\"",
",",
"$",
"attr",
",",
"$",
"important",
")",
";",
"}",
"elseif",
"(",
"$",
"attr",
"===",
"\"repeat\"",
"||",
"$",
"attr",
"===",
"\"repeat-x\"",
"||",
"$",
"attr",
"===",
"\"repeat-y\"",
"||",
"$",
"attr",
"===",
"\"no-repeat\"",
")",
"{",
"$",
"this",
"->",
"_set_style",
"(",
"\"background_repeat\"",
",",
"$",
"attr",
",",
"$",
"important",
")",
";",
"}",
"elseif",
"(",
"(",
"$",
"col",
"=",
"$",
"this",
"->",
"munge_color",
"(",
"$",
"attr",
")",
")",
"!=",
"null",
")",
"{",
"$",
"this",
"->",
"_set_style",
"(",
"\"background_color\"",
",",
"is_array",
"(",
"$",
"col",
")",
"?",
"$",
"col",
"[",
"\"hex\"",
"]",
":",
"$",
"col",
",",
"$",
"important",
")",
";",
"}",
"else",
"{",
"$",
"pos",
"[",
"]",
"=",
"$",
"attr",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"pos",
")",
")",
"{",
"$",
"this",
"->",
"_set_style",
"(",
"\"background_position\"",
",",
"implode",
"(",
"\" \"",
",",
"$",
"pos",
")",
",",
"$",
"important",
")",
";",
"}",
"}",
"//see __set and __get, on all assignments clear cache, not needed on direct set through __set",
"$",
"this",
"->",
"_prop_cache",
"[",
"\"background\"",
"]",
"=",
"null",
";",
"$",
"this",
"->",
"_props",
"[",
"\"background\"",
"]",
"=",
"$",
"val",
";",
"}"
] | Sets the background - combined options
@link http://www.w3.org/TR/CSS21/colors.html#propdef-background
@param string $val | [
"Sets",
"the",
"background",
"-",
"combined",
"options"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Css/Style.php#L1909-L1944 |
210,372 | dompdf/dompdf | src/Css/Style.php | Style.set_font_size | function set_font_size($size)
{
$this->__font_size_calculated = false;
//see __set and __get, on all assignments clear cache, not needed on direct set through __set
$this->_prop_cache["font_size"] = null;
$this->_props["font_size"] = $size;
} | php | function set_font_size($size)
{
$this->__font_size_calculated = false;
//see __set and __get, on all assignments clear cache, not needed on direct set through __set
$this->_prop_cache["font_size"] = null;
$this->_props["font_size"] = $size;
} | [
"function",
"set_font_size",
"(",
"$",
"size",
")",
"{",
"$",
"this",
"->",
"__font_size_calculated",
"=",
"false",
";",
"//see __set and __get, on all assignments clear cache, not needed on direct set through __set",
"$",
"this",
"->",
"_prop_cache",
"[",
"\"font_size\"",
"]",
"=",
"null",
";",
"$",
"this",
"->",
"_props",
"[",
"\"font_size\"",
"]",
"=",
"$",
"size",
";",
"}"
] | Sets the font size
$size can be any acceptable CSS size
@link http://www.w3.org/TR/CSS21/fonts.html#propdef-font-size
@param string|float $size | [
"Sets",
"the",
"font",
"size"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Css/Style.php#L1954-L1960 |
210,373 | dompdf/dompdf | src/Css/Style.php | Style.set_outline | function set_outline($val)
{
$important = isset($this->_important_props["outline"]);
$props = array(
"outline_style",
"outline_width",
"outline_color",
);
foreach ($props as $prop) {
$_val = self::$_defaults[$prop];
if (!isset($this->_important_props[$prop]) || $important) {
//see __set and __get, on all assignments clear cache!
$this->_prop_cache[$prop] = null;
if ($important) {
$this->_important_props[$prop] = true;
}
$this->_props[$prop] = $_val;
}
}
$val = preg_replace("/\s*\,\s*/", ",", $val); // when rgb() has spaces
$arr = explode(" ", $val);
foreach ($arr as $value) {
$value = trim($value);
if (in_array($value, self::$BORDER_STYLES)) {
$this->set_outline_style($value);
} else if (preg_match("/[.0-9]+(?:px|pt|pc|em|ex|%|in|mm|cm)|(?:thin|medium|thick)/", $value)) {
$this->set_outline_width($value);
} else {
// must be color
$this->set_outline_color($value);
}
}
//see __set and __get, on all assignments clear cache, not needed on direct set through __set
$this->_prop_cache["outline"] = null;
$this->_props["outline"] = $val;
} | php | function set_outline($val)
{
$important = isset($this->_important_props["outline"]);
$props = array(
"outline_style",
"outline_width",
"outline_color",
);
foreach ($props as $prop) {
$_val = self::$_defaults[$prop];
if (!isset($this->_important_props[$prop]) || $important) {
//see __set and __get, on all assignments clear cache!
$this->_prop_cache[$prop] = null;
if ($important) {
$this->_important_props[$prop] = true;
}
$this->_props[$prop] = $_val;
}
}
$val = preg_replace("/\s*\,\s*/", ",", $val); // when rgb() has spaces
$arr = explode(" ", $val);
foreach ($arr as $value) {
$value = trim($value);
if (in_array($value, self::$BORDER_STYLES)) {
$this->set_outline_style($value);
} else if (preg_match("/[.0-9]+(?:px|pt|pc|em|ex|%|in|mm|cm)|(?:thin|medium|thick)/", $value)) {
$this->set_outline_width($value);
} else {
// must be color
$this->set_outline_color($value);
}
}
//see __set and __get, on all assignments clear cache, not needed on direct set through __set
$this->_prop_cache["outline"] = null;
$this->_props["outline"] = $val;
} | [
"function",
"set_outline",
"(",
"$",
"val",
")",
"{",
"$",
"important",
"=",
"isset",
"(",
"$",
"this",
"->",
"_important_props",
"[",
"\"outline\"",
"]",
")",
";",
"$",
"props",
"=",
"array",
"(",
"\"outline_style\"",
",",
"\"outline_width\"",
",",
"\"outline_color\"",
",",
")",
";",
"foreach",
"(",
"$",
"props",
"as",
"$",
"prop",
")",
"{",
"$",
"_val",
"=",
"self",
"::",
"$",
"_defaults",
"[",
"$",
"prop",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_important_props",
"[",
"$",
"prop",
"]",
")",
"||",
"$",
"important",
")",
"{",
"//see __set and __get, on all assignments clear cache!",
"$",
"this",
"->",
"_prop_cache",
"[",
"$",
"prop",
"]",
"=",
"null",
";",
"if",
"(",
"$",
"important",
")",
"{",
"$",
"this",
"->",
"_important_props",
"[",
"$",
"prop",
"]",
"=",
"true",
";",
"}",
"$",
"this",
"->",
"_props",
"[",
"$",
"prop",
"]",
"=",
"$",
"_val",
";",
"}",
"}",
"$",
"val",
"=",
"preg_replace",
"(",
"\"/\\s*\\,\\s*/\"",
",",
"\",\"",
",",
"$",
"val",
")",
";",
"// when rgb() has spaces",
"$",
"arr",
"=",
"explode",
"(",
"\" \"",
",",
"$",
"val",
")",
";",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"trim",
"(",
"$",
"value",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"value",
",",
"self",
"::",
"$",
"BORDER_STYLES",
")",
")",
"{",
"$",
"this",
"->",
"set_outline_style",
"(",
"$",
"value",
")",
";",
"}",
"else",
"if",
"(",
"preg_match",
"(",
"\"/[.0-9]+(?:px|pt|pc|em|ex|%|in|mm|cm)|(?:thin|medium|thick)/\"",
",",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"set_outline_width",
"(",
"$",
"value",
")",
";",
"}",
"else",
"{",
"// must be color",
"$",
"this",
"->",
"set_outline_color",
"(",
"$",
"value",
")",
";",
"}",
"}",
"//see __set and __get, on all assignments clear cache, not needed on direct set through __set",
"$",
"this",
"->",
"_prop_cache",
"[",
"\"outline\"",
"]",
"=",
"null",
";",
"$",
"this",
"->",
"_props",
"[",
"\"outline\"",
"]",
"=",
"$",
"val",
";",
"}"
] | Sets the outline styles
@link http://www.w3.org/TR/CSS21/ui.html#dynamic-outlines
@param string $val | [
"Sets",
"the",
"outline",
"styles"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Css/Style.php#L2411-L2452 |
210,374 | dompdf/dompdf | src/Css/Style.php | Style.set_border_spacing | function set_border_spacing($val)
{
$arr = explode(" ", $val);
if (count($arr) == 1) {
$arr[1] = $arr[0];
}
//see __set and __get, on all assignments clear cache, not needed on direct set through __set
$this->_prop_cache["border_spacing"] = null;
$this->_props["border_spacing"] = "$arr[0] $arr[1]";
} | php | function set_border_spacing($val)
{
$arr = explode(" ", $val);
if (count($arr) == 1) {
$arr[1] = $arr[0];
}
//see __set and __get, on all assignments clear cache, not needed on direct set through __set
$this->_prop_cache["border_spacing"] = null;
$this->_props["border_spacing"] = "$arr[0] $arr[1]";
} | [
"function",
"set_border_spacing",
"(",
"$",
"val",
")",
"{",
"$",
"arr",
"=",
"explode",
"(",
"\" \"",
",",
"$",
"val",
")",
";",
"if",
"(",
"count",
"(",
"$",
"arr",
")",
"==",
"1",
")",
"{",
"$",
"arr",
"[",
"1",
"]",
"=",
"$",
"arr",
"[",
"0",
"]",
";",
"}",
"//see __set and __get, on all assignments clear cache, not needed on direct set through __set",
"$",
"this",
"->",
"_prop_cache",
"[",
"\"border_spacing\"",
"]",
"=",
"null",
";",
"$",
"this",
"->",
"_props",
"[",
"\"border_spacing\"",
"]",
"=",
"\"$arr[0] $arr[1]\"",
";",
"}"
] | Sets the border spacing
@link http://www.w3.org/TR/CSS21/box.html#border-properties
@param float $val | [
"Sets",
"the",
"border",
"spacing"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Css/Style.php#L2484-L2495 |
210,375 | dompdf/dompdf | src/Css/Style.php | Style.set_list_style_image | function set_list_style_image($val)
{
//see __set and __get, on all assignments clear cache, not needed on direct set through __set
$this->_prop_cache["list_style_image"] = null;
$this->_props["list_style_image"] = $this->_image($val);
} | php | function set_list_style_image($val)
{
//see __set and __get, on all assignments clear cache, not needed on direct set through __set
$this->_prop_cache["list_style_image"] = null;
$this->_props["list_style_image"] = $this->_image($val);
} | [
"function",
"set_list_style_image",
"(",
"$",
"val",
")",
"{",
"//see __set and __get, on all assignments clear cache, not needed on direct set through __set",
"$",
"this",
"->",
"_prop_cache",
"[",
"\"list_style_image\"",
"]",
"=",
"null",
";",
"$",
"this",
"->",
"_props",
"[",
"\"list_style_image\"",
"]",
"=",
"$",
"this",
"->",
"_image",
"(",
"$",
"val",
")",
";",
"}"
] | Sets the list style image
@link http://www.w3.org/TR/CSS21/generate.html#propdef-list-style-image
@param $val | [
"Sets",
"the",
"list",
"style",
"image"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Css/Style.php#L2503-L2508 |
210,376 | dompdf/dompdf | src/Css/Style.php | Style.get_transform_origin | function get_transform_origin() {
$values = preg_split("/\s+/", $this->_props['transform_origin']);
if (count($values) === 0) {
$values = preg_split("/\s+/", self::$_defaults["transform_origin"]);
}
$values = array_map(function($value) {
if (in_array($value, array("top", "left"))) {
return 0;
} else if (in_array($value, array("bottom", "right"))) {
return "100%";
} else {
return $value;
}
}, $values);
if (!isset($values[1])) {
$values[1] = $values[0];
}
return $values;
} | php | function get_transform_origin() {
$values = preg_split("/\s+/", $this->_props['transform_origin']);
if (count($values) === 0) {
$values = preg_split("/\s+/", self::$_defaults["transform_origin"]);
}
$values = array_map(function($value) {
if (in_array($value, array("top", "left"))) {
return 0;
} else if (in_array($value, array("bottom", "right"))) {
return "100%";
} else {
return $value;
}
}, $values);
if (!isset($values[1])) {
$values[1] = $values[0];
}
return $values;
} | [
"function",
"get_transform_origin",
"(",
")",
"{",
"$",
"values",
"=",
"preg_split",
"(",
"\"/\\s+/\"",
",",
"$",
"this",
"->",
"_props",
"[",
"'transform_origin'",
"]",
")",
";",
"if",
"(",
"count",
"(",
"$",
"values",
")",
"===",
"0",
")",
"{",
"$",
"values",
"=",
"preg_split",
"(",
"\"/\\s+/\"",
",",
"self",
"::",
"$",
"_defaults",
"[",
"\"transform_origin\"",
"]",
")",
";",
"}",
"$",
"values",
"=",
"array_map",
"(",
"function",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"value",
",",
"array",
"(",
"\"top\"",
",",
"\"left\"",
")",
")",
")",
"{",
"return",
"0",
";",
"}",
"else",
"if",
"(",
"in_array",
"(",
"$",
"value",
",",
"array",
"(",
"\"bottom\"",
",",
"\"right\"",
")",
")",
")",
"{",
"return",
"\"100%\"",
";",
"}",
"else",
"{",
"return",
"$",
"value",
";",
"}",
"}",
",",
"$",
"values",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"values",
"[",
"1",
"]",
")",
")",
"{",
"$",
"values",
"[",
"1",
"]",
"=",
"$",
"values",
"[",
"0",
"]",
";",
"}",
"return",
"$",
"values",
";",
"}"
] | Gets the CSS3 transform-origin property
@link http://www.w3.org/TR/css3-2d-transforms/#transform-origin
@return mixed[] | [
"Gets",
"the",
"CSS3",
"transform",
"-",
"origin",
"property"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Css/Style.php#L2778-L2800 |
210,377 | dompdf/dompdf | src/Frame.php | Frame.get_margin_height | public function get_margin_height()
{
$style = $this->_style;
return (float)$style->length_in_pt(array(
$style->height,
$style->margin_top,
$style->margin_bottom,
$style->border_top_width,
$style->border_bottom_width,
$style->padding_top,
$style->padding_bottom
), $this->_containing_block["h"]);
} | php | public function get_margin_height()
{
$style = $this->_style;
return (float)$style->length_in_pt(array(
$style->height,
$style->margin_top,
$style->margin_bottom,
$style->border_top_width,
$style->border_bottom_width,
$style->padding_top,
$style->padding_bottom
), $this->_containing_block["h"]);
} | [
"public",
"function",
"get_margin_height",
"(",
")",
"{",
"$",
"style",
"=",
"$",
"this",
"->",
"_style",
";",
"return",
"(",
"float",
")",
"$",
"style",
"->",
"length_in_pt",
"(",
"array",
"(",
"$",
"style",
"->",
"height",
",",
"$",
"style",
"->",
"margin_top",
",",
"$",
"style",
"->",
"margin_bottom",
",",
"$",
"style",
"->",
"border_top_width",
",",
"$",
"style",
"->",
"border_bottom_width",
",",
"$",
"style",
"->",
"padding_top",
",",
"$",
"style",
"->",
"padding_bottom",
")",
",",
"$",
"this",
"->",
"_containing_block",
"[",
"\"h\"",
"]",
")",
";",
"}"
] | Return the height of the margin box of the frame, in pt. Meaningless
unless the height has been calculated properly.
@return float | [
"Return",
"the",
"height",
"of",
"the",
"margin",
"box",
"of",
"the",
"frame",
"in",
"pt",
".",
"Meaningless",
"unless",
"the",
"height",
"has",
"been",
"calculated",
"properly",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Frame.php#L474-L487 |
210,378 | dompdf/dompdf | src/Frame.php | Frame.get_margin_width | public function get_margin_width()
{
$style = $this->_style;
return (float)$style->length_in_pt(array(
$style->width,
$style->margin_left,
$style->margin_right,
$style->border_left_width,
$style->border_right_width,
$style->padding_left,
$style->padding_right
), $this->_containing_block["w"]);
} | php | public function get_margin_width()
{
$style = $this->_style;
return (float)$style->length_in_pt(array(
$style->width,
$style->margin_left,
$style->margin_right,
$style->border_left_width,
$style->border_right_width,
$style->padding_left,
$style->padding_right
), $this->_containing_block["w"]);
} | [
"public",
"function",
"get_margin_width",
"(",
")",
"{",
"$",
"style",
"=",
"$",
"this",
"->",
"_style",
";",
"return",
"(",
"float",
")",
"$",
"style",
"->",
"length_in_pt",
"(",
"array",
"(",
"$",
"style",
"->",
"width",
",",
"$",
"style",
"->",
"margin_left",
",",
"$",
"style",
"->",
"margin_right",
",",
"$",
"style",
"->",
"border_left_width",
",",
"$",
"style",
"->",
"border_right_width",
",",
"$",
"style",
"->",
"padding_left",
",",
"$",
"style",
"->",
"padding_right",
")",
",",
"$",
"this",
"->",
"_containing_block",
"[",
"\"w\"",
"]",
")",
";",
"}"
] | Return the width of the margin box of the frame, in pt. Meaningless
unless the width has been calculated properly.
@return float | [
"Return",
"the",
"width",
"of",
"the",
"margin",
"box",
"of",
"the",
"frame",
"in",
"pt",
".",
"Meaningless",
"unless",
"the",
"width",
"has",
"been",
"calculated",
"properly",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Frame.php#L495-L508 |
210,379 | dompdf/dompdf | src/Frame.php | Frame.is_auto_height | public function is_auto_height()
{
$style = $this->_style;
return in_array(
"auto",
array(
$style->height,
$style->margin_top,
$style->margin_bottom,
$style->border_top_width,
$style->border_bottom_width,
$style->padding_top,
$style->padding_bottom,
$this->_containing_block["h"]
),
true
);
} | php | public function is_auto_height()
{
$style = $this->_style;
return in_array(
"auto",
array(
$style->height,
$style->margin_top,
$style->margin_bottom,
$style->border_top_width,
$style->border_bottom_width,
$style->padding_top,
$style->padding_bottom,
$this->_containing_block["h"]
),
true
);
} | [
"public",
"function",
"is_auto_height",
"(",
")",
"{",
"$",
"style",
"=",
"$",
"this",
"->",
"_style",
";",
"return",
"in_array",
"(",
"\"auto\"",
",",
"array",
"(",
"$",
"style",
"->",
"height",
",",
"$",
"style",
"->",
"margin_top",
",",
"$",
"style",
"->",
"margin_bottom",
",",
"$",
"style",
"->",
"border_top_width",
",",
"$",
"style",
"->",
"border_bottom_width",
",",
"$",
"style",
"->",
"padding_top",
",",
"$",
"style",
"->",
"padding_bottom",
",",
"$",
"this",
"->",
"_containing_block",
"[",
"\"h\"",
"]",
")",
",",
"true",
")",
";",
"}"
] | Indicates if the margin height is auto sized
@return bool | [
"Indicates",
"if",
"the",
"margin",
"height",
"is",
"auto",
"sized"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Frame.php#L764-L782 |
210,380 | dompdf/dompdf | src/Frame.php | Frame.is_auto_width | public function is_auto_width()
{
$style = $this->_style;
return in_array(
"auto",
array(
$style->width,
$style->margin_left,
$style->margin_right,
$style->border_left_width,
$style->border_right_width,
$style->padding_left,
$style->padding_right,
$this->_containing_block["w"]
),
true
);
} | php | public function is_auto_width()
{
$style = $this->_style;
return in_array(
"auto",
array(
$style->width,
$style->margin_left,
$style->margin_right,
$style->border_left_width,
$style->border_right_width,
$style->padding_left,
$style->padding_right,
$this->_containing_block["w"]
),
true
);
} | [
"public",
"function",
"is_auto_width",
"(",
")",
"{",
"$",
"style",
"=",
"$",
"this",
"->",
"_style",
";",
"return",
"in_array",
"(",
"\"auto\"",
",",
"array",
"(",
"$",
"style",
"->",
"width",
",",
"$",
"style",
"->",
"margin_left",
",",
"$",
"style",
"->",
"margin_right",
",",
"$",
"style",
"->",
"border_left_width",
",",
"$",
"style",
"->",
"border_right_width",
",",
"$",
"style",
"->",
"padding_left",
",",
"$",
"style",
"->",
"padding_right",
",",
"$",
"this",
"->",
"_containing_block",
"[",
"\"w\"",
"]",
")",
",",
"true",
")",
";",
"}"
] | Indicates if the margin width is auto sized
@return bool | [
"Indicates",
"if",
"the",
"margin",
"width",
"is",
"auto",
"sized"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Frame.php#L789-L807 |
210,381 | dompdf/dompdf | src/Frame.php | Frame.prepend_child | public function prepend_child(Frame $child, $update_node = true)
{
if ($update_node) {
$this->_node->insertBefore($child->_node, $this->_first_child ? $this->_first_child->_node : null);
}
// Remove the child from its parent
if ($child->_parent) {
$child->_parent->remove_child($child, false);
}
$child->_parent = $this;
$child->_prev_sibling = null;
// Handle the first child
if (!$this->_first_child) {
$this->_first_child = $child;
$this->_last_child = $child;
$child->_next_sibling = null;
} else {
$this->_first_child->_prev_sibling = $child;
$child->_next_sibling = $this->_first_child;
$this->_first_child = $child;
}
} | php | public function prepend_child(Frame $child, $update_node = true)
{
if ($update_node) {
$this->_node->insertBefore($child->_node, $this->_first_child ? $this->_first_child->_node : null);
}
// Remove the child from its parent
if ($child->_parent) {
$child->_parent->remove_child($child, false);
}
$child->_parent = $this;
$child->_prev_sibling = null;
// Handle the first child
if (!$this->_first_child) {
$this->_first_child = $child;
$this->_last_child = $child;
$child->_next_sibling = null;
} else {
$this->_first_child->_prev_sibling = $child;
$child->_next_sibling = $this->_first_child;
$this->_first_child = $child;
}
} | [
"public",
"function",
"prepend_child",
"(",
"Frame",
"$",
"child",
",",
"$",
"update_node",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"update_node",
")",
"{",
"$",
"this",
"->",
"_node",
"->",
"insertBefore",
"(",
"$",
"child",
"->",
"_node",
",",
"$",
"this",
"->",
"_first_child",
"?",
"$",
"this",
"->",
"_first_child",
"->",
"_node",
":",
"null",
")",
";",
"}",
"// Remove the child from its parent",
"if",
"(",
"$",
"child",
"->",
"_parent",
")",
"{",
"$",
"child",
"->",
"_parent",
"->",
"remove_child",
"(",
"$",
"child",
",",
"false",
")",
";",
"}",
"$",
"child",
"->",
"_parent",
"=",
"$",
"this",
";",
"$",
"child",
"->",
"_prev_sibling",
"=",
"null",
";",
"// Handle the first child",
"if",
"(",
"!",
"$",
"this",
"->",
"_first_child",
")",
"{",
"$",
"this",
"->",
"_first_child",
"=",
"$",
"child",
";",
"$",
"this",
"->",
"_last_child",
"=",
"$",
"child",
";",
"$",
"child",
"->",
"_next_sibling",
"=",
"null",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_first_child",
"->",
"_prev_sibling",
"=",
"$",
"child",
";",
"$",
"child",
"->",
"_next_sibling",
"=",
"$",
"this",
"->",
"_first_child",
";",
"$",
"this",
"->",
"_first_child",
"=",
"$",
"child",
";",
"}",
"}"
] | Inserts a new child at the beginning of the Frame
@param $child Frame The new Frame to insert
@param $update_node boolean Whether or not to update the DOM | [
"Inserts",
"a",
"new",
"child",
"at",
"the",
"beginning",
"of",
"the",
"Frame"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Frame.php#L921-L945 |
210,382 | dompdf/dompdf | src/FontMetrics.php | FontMetrics.saveFontFamilies | public function saveFontFamilies()
{
// replace the path to the DOMPDF font directories with the corresponding constants (allows for more portability)
$cacheData = sprintf("<?php return array (%s", PHP_EOL);
foreach ($this->fontLookup as $family => $variants) {
$cacheData .= sprintf(" '%s' => array(%s", addslashes($family), PHP_EOL);
foreach ($variants as $variant => $path) {
$path = sprintf("'%s'", $path);
$path = str_replace('\'' . $this->getOptions()->getFontDir() , '$fontDir . \'' , $path);
$path = str_replace('\'' . $this->getOptions()->getRootDir() , '$rootDir . \'' , $path);
$cacheData .= sprintf(" '%s' => %s,%s", $variant, $path, PHP_EOL);
}
$cacheData .= sprintf(" ),%s", PHP_EOL);
}
$cacheData .= ") ?>";
file_put_contents($this->getCacheFile(), $cacheData);
} | php | public function saveFontFamilies()
{
// replace the path to the DOMPDF font directories with the corresponding constants (allows for more portability)
$cacheData = sprintf("<?php return array (%s", PHP_EOL);
foreach ($this->fontLookup as $family => $variants) {
$cacheData .= sprintf(" '%s' => array(%s", addslashes($family), PHP_EOL);
foreach ($variants as $variant => $path) {
$path = sprintf("'%s'", $path);
$path = str_replace('\'' . $this->getOptions()->getFontDir() , '$fontDir . \'' , $path);
$path = str_replace('\'' . $this->getOptions()->getRootDir() , '$rootDir . \'' , $path);
$cacheData .= sprintf(" '%s' => %s,%s", $variant, $path, PHP_EOL);
}
$cacheData .= sprintf(" ),%s", PHP_EOL);
}
$cacheData .= ") ?>";
file_put_contents($this->getCacheFile(), $cacheData);
} | [
"public",
"function",
"saveFontFamilies",
"(",
")",
"{",
"// replace the path to the DOMPDF font directories with the corresponding constants (allows for more portability)",
"$",
"cacheData",
"=",
"sprintf",
"(",
"\"<?php return array (%s\"",
",",
"PHP_EOL",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"fontLookup",
"as",
"$",
"family",
"=>",
"$",
"variants",
")",
"{",
"$",
"cacheData",
".=",
"sprintf",
"(",
"\" '%s' => array(%s\"",
",",
"addslashes",
"(",
"$",
"family",
")",
",",
"PHP_EOL",
")",
";",
"foreach",
"(",
"$",
"variants",
"as",
"$",
"variant",
"=>",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"sprintf",
"(",
"\"'%s'\"",
",",
"$",
"path",
")",
";",
"$",
"path",
"=",
"str_replace",
"(",
"'\\''",
".",
"$",
"this",
"->",
"getOptions",
"(",
")",
"->",
"getFontDir",
"(",
")",
",",
"'$fontDir . \\''",
",",
"$",
"path",
")",
";",
"$",
"path",
"=",
"str_replace",
"(",
"'\\''",
".",
"$",
"this",
"->",
"getOptions",
"(",
")",
"->",
"getRootDir",
"(",
")",
",",
"'$rootDir . \\''",
",",
"$",
"path",
")",
";",
"$",
"cacheData",
".=",
"sprintf",
"(",
"\" '%s' => %s,%s\"",
",",
"$",
"variant",
",",
"$",
"path",
",",
"PHP_EOL",
")",
";",
"}",
"$",
"cacheData",
".=",
"sprintf",
"(",
"\" ),%s\"",
",",
"PHP_EOL",
")",
";",
"}",
"$",
"cacheData",
".=",
"\") ?>\"",
";",
"file_put_contents",
"(",
"$",
"this",
"->",
"getCacheFile",
"(",
")",
",",
"$",
"cacheData",
")",
";",
"}"
] | Saves the stored font family cache
The name and location of the cache file are determined by {@link
FontMetrics::CACHE_FILE}. This file should be writable by the
webserver process.
@see FontMetrics::loadFontFamilies() | [
"Saves",
"the",
"stored",
"font",
"family",
"cache"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/FontMetrics.php#L92-L108 |
210,383 | dompdf/dompdf | lib/html5lib/Data.php | HTML5_Data.getRealCodepoint | public static function getRealCodepoint($ref) {
if (!isset(self::$realCodepointTable[$ref])) {
return false;
} else {
return self::$realCodepointTable[$ref];
}
} | php | public static function getRealCodepoint($ref) {
if (!isset(self::$realCodepointTable[$ref])) {
return false;
} else {
return self::$realCodepointTable[$ref];
}
} | [
"public",
"static",
"function",
"getRealCodepoint",
"(",
"$",
"ref",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"realCodepointTable",
"[",
"$",
"ref",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"self",
"::",
"$",
"realCodepointTable",
"[",
"$",
"ref",
"]",
";",
"}",
"}"
] | Returns the "real" Unicode codepoint of a malformed character
reference. | [
"Returns",
"the",
"real",
"Unicode",
"codepoint",
"of",
"a",
"malformed",
"character",
"reference",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/html5lib/Data.php#L58-L64 |
210,384 | cakephp/cakephp | src/Http/Session/CacheSession.php | CacheSession.read | public function read($id)
{
$value = Cache::read($id, $this->_options['config']);
if (empty($value)) {
return '';
}
return $value;
} | php | public function read($id)
{
$value = Cache::read($id, $this->_options['config']);
if (empty($value)) {
return '';
}
return $value;
} | [
"public",
"function",
"read",
"(",
"$",
"id",
")",
"{",
"$",
"value",
"=",
"Cache",
"::",
"read",
"(",
"$",
"id",
",",
"$",
"this",
"->",
"_options",
"[",
"'config'",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"return",
"''",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Method used to read from a cache session.
@param string|int $id ID that uniquely identifies session in cache.
@return string Session data or empty string if it does not exist. | [
"Method",
"used",
"to",
"read",
"from",
"a",
"cache",
"session",
"."
] | 5f6c9d65dcbbfc093410d1dbbb207a17f4cde540 | https://github.com/cakephp/cakephp/blob/5f6c9d65dcbbfc093410d1dbbb207a17f4cde540/src/Http/Session/CacheSession.php#L83-L92 |
210,385 | cakephp/cakephp | src/Http/Session/CacheSession.php | CacheSession.write | public function write($id, $data)
{
if (!$id) {
return false;
}
return (bool)Cache::write($id, $data, $this->_options['config']);
} | php | public function write($id, $data)
{
if (!$id) {
return false;
}
return (bool)Cache::write($id, $data, $this->_options['config']);
} | [
"public",
"function",
"write",
"(",
"$",
"id",
",",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"$",
"id",
")",
"{",
"return",
"false",
";",
"}",
"return",
"(",
"bool",
")",
"Cache",
"::",
"write",
"(",
"$",
"id",
",",
"$",
"data",
",",
"$",
"this",
"->",
"_options",
"[",
"'config'",
"]",
")",
";",
"}"
] | Helper function called on write for cache sessions.
@param string|int $id ID that uniquely identifies session in cache.
@param mixed $data The data to be saved.
@return bool True for successful write, false otherwise. | [
"Helper",
"function",
"called",
"on",
"write",
"for",
"cache",
"sessions",
"."
] | 5f6c9d65dcbbfc093410d1dbbb207a17f4cde540 | https://github.com/cakephp/cakephp/blob/5f6c9d65dcbbfc093410d1dbbb207a17f4cde540/src/Http/Session/CacheSession.php#L101-L108 |
210,386 | cakephp/cakephp | src/ORM/Behavior/Translate/TranslateTrait.php | TranslateTrait.translation | public function translation($language)
{
if ($language === $this->get('_locale')) {
return $this;
}
$i18n = $this->get('_translations');
$created = false;
if (empty($i18n)) {
$i18n = [];
$created = true;
}
if ($created || empty($i18n[$language]) || !($i18n[$language] instanceof EntityInterface)) {
$className = get_class($this);
$i18n[$language] = new $className();
$created = true;
}
if ($created) {
$this->set('_translations', $i18n);
}
// Assume the user will modify any of the internal translations, helps with saving
$this->setDirty('_translations', true);
return $i18n[$language];
} | php | public function translation($language)
{
if ($language === $this->get('_locale')) {
return $this;
}
$i18n = $this->get('_translations');
$created = false;
if (empty($i18n)) {
$i18n = [];
$created = true;
}
if ($created || empty($i18n[$language]) || !($i18n[$language] instanceof EntityInterface)) {
$className = get_class($this);
$i18n[$language] = new $className();
$created = true;
}
if ($created) {
$this->set('_translations', $i18n);
}
// Assume the user will modify any of the internal translations, helps with saving
$this->setDirty('_translations', true);
return $i18n[$language];
} | [
"public",
"function",
"translation",
"(",
"$",
"language",
")",
"{",
"if",
"(",
"$",
"language",
"===",
"$",
"this",
"->",
"get",
"(",
"'_locale'",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"i18n",
"=",
"$",
"this",
"->",
"get",
"(",
"'_translations'",
")",
";",
"$",
"created",
"=",
"false",
";",
"if",
"(",
"empty",
"(",
"$",
"i18n",
")",
")",
"{",
"$",
"i18n",
"=",
"[",
"]",
";",
"$",
"created",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"created",
"||",
"empty",
"(",
"$",
"i18n",
"[",
"$",
"language",
"]",
")",
"||",
"!",
"(",
"$",
"i18n",
"[",
"$",
"language",
"]",
"instanceof",
"EntityInterface",
")",
")",
"{",
"$",
"className",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"$",
"i18n",
"[",
"$",
"language",
"]",
"=",
"new",
"$",
"className",
"(",
")",
";",
"$",
"created",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"created",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"'_translations'",
",",
"$",
"i18n",
")",
";",
"}",
"// Assume the user will modify any of the internal translations, helps with saving",
"$",
"this",
"->",
"setDirty",
"(",
"'_translations'",
",",
"true",
")",
";",
"return",
"$",
"i18n",
"[",
"$",
"language",
"]",
";",
"}"
] | Returns the entity containing the translated fields for this object and for
the specified language. If the translation for the passed language is not
present, a new empty entity will be created so that values can be added to
it.
@param string $language Language to return entity for.
@return $this|\Cake\Datasource\EntityInterface | [
"Returns",
"the",
"entity",
"containing",
"the",
"translated",
"fields",
"for",
"this",
"object",
"and",
"for",
"the",
"specified",
"language",
".",
"If",
"the",
"translation",
"for",
"the",
"passed",
"language",
"is",
"not",
"present",
"a",
"new",
"empty",
"entity",
"will",
"be",
"created",
"so",
"that",
"values",
"can",
"be",
"added",
"to",
"it",
"."
] | 5f6c9d65dcbbfc093410d1dbbb207a17f4cde540 | https://github.com/cakephp/cakephp/blob/5f6c9d65dcbbfc093410d1dbbb207a17f4cde540/src/ORM/Behavior/Translate/TranslateTrait.php#L35-L64 |
210,387 | cakephp/cakephp | src/Controller/Component/CsrfComponent.php | CsrfComponent._setCookie | protected function _setCookie(ServerRequest $request, Response $response)
{
$expiry = new Time($this->_config['expiry']);
$value = hash('sha512', Security::randomBytes(16), false);
$request = $request->withParam('_csrfToken', $value);
$cookie = new Cookie(
$this->_config['cookieName'],
$value,
$expiry,
$request->getAttribute('webroot'),
'',
(bool)$this->_config['secure'],
(bool)$this->_config['httpOnly']
);
$response = $response->withCookie($cookie);
return [$request, $response];
} | php | protected function _setCookie(ServerRequest $request, Response $response)
{
$expiry = new Time($this->_config['expiry']);
$value = hash('sha512', Security::randomBytes(16), false);
$request = $request->withParam('_csrfToken', $value);
$cookie = new Cookie(
$this->_config['cookieName'],
$value,
$expiry,
$request->getAttribute('webroot'),
'',
(bool)$this->_config['secure'],
(bool)$this->_config['httpOnly']
);
$response = $response->withCookie($cookie);
return [$request, $response];
} | [
"protected",
"function",
"_setCookie",
"(",
"ServerRequest",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"$",
"expiry",
"=",
"new",
"Time",
"(",
"$",
"this",
"->",
"_config",
"[",
"'expiry'",
"]",
")",
";",
"$",
"value",
"=",
"hash",
"(",
"'sha512'",
",",
"Security",
"::",
"randomBytes",
"(",
"16",
")",
",",
"false",
")",
";",
"$",
"request",
"=",
"$",
"request",
"->",
"withParam",
"(",
"'_csrfToken'",
",",
"$",
"value",
")",
";",
"$",
"cookie",
"=",
"new",
"Cookie",
"(",
"$",
"this",
"->",
"_config",
"[",
"'cookieName'",
"]",
",",
"$",
"value",
",",
"$",
"expiry",
",",
"$",
"request",
"->",
"getAttribute",
"(",
"'webroot'",
")",
",",
"''",
",",
"(",
"bool",
")",
"$",
"this",
"->",
"_config",
"[",
"'secure'",
"]",
",",
"(",
"bool",
")",
"$",
"this",
"->",
"_config",
"[",
"'httpOnly'",
"]",
")",
";",
"$",
"response",
"=",
"$",
"response",
"->",
"withCookie",
"(",
"$",
"cookie",
")",
";",
"return",
"[",
"$",
"request",
",",
"$",
"response",
"]",
";",
"}"
] | Set the cookie in the response.
Also sets the request->params['_csrfToken'] so the newly minted
token is available in the request data.
@param \Cake\Http\ServerRequest $request The request object.
@param \Cake\Http\Response $response The response object.
@return array An array of the modified request, response. | [
"Set",
"the",
"cookie",
"in",
"the",
"response",
"."
] | 5f6c9d65dcbbfc093410d1dbbb207a17f4cde540 | https://github.com/cakephp/cakephp/blob/5f6c9d65dcbbfc093410d1dbbb207a17f4cde540/src/Controller/Component/CsrfComponent.php#L146-L166 |
210,388 | cakephp/cakephp | src/Controller/Component/AuthComponent.php | AuthComponent.authCheck | public function authCheck(Event $event)
{
if ($this->_config['checkAuthIn'] !== $event->getName()) {
return null;
}
/** @var \Cake\Controller\Controller $controller */
$controller = $event->getSubject();
$action = strtolower($controller->getRequest()->getParam('action'));
if (!$controller->isAction($action)) {
return null;
}
$this->_setDefaults();
if ($this->_isAllowed($controller)) {
return null;
}
$isLoginAction = $this->_isLoginAction($controller);
if (!$this->_getUser()) {
if ($isLoginAction) {
return null;
}
$result = $this->_unauthenticated($controller);
if ($result instanceof Response) {
$event->stopPropagation();
}
return $result;
}
if ($isLoginAction ||
empty($this->_config['authorize']) ||
$this->isAuthorized($this->user())
) {
return null;
}
$event->stopPropagation();
return $this->_unauthorized($controller);
} | php | public function authCheck(Event $event)
{
if ($this->_config['checkAuthIn'] !== $event->getName()) {
return null;
}
/** @var \Cake\Controller\Controller $controller */
$controller = $event->getSubject();
$action = strtolower($controller->getRequest()->getParam('action'));
if (!$controller->isAction($action)) {
return null;
}
$this->_setDefaults();
if ($this->_isAllowed($controller)) {
return null;
}
$isLoginAction = $this->_isLoginAction($controller);
if (!$this->_getUser()) {
if ($isLoginAction) {
return null;
}
$result = $this->_unauthenticated($controller);
if ($result instanceof Response) {
$event->stopPropagation();
}
return $result;
}
if ($isLoginAction ||
empty($this->_config['authorize']) ||
$this->isAuthorized($this->user())
) {
return null;
}
$event->stopPropagation();
return $this->_unauthorized($controller);
} | [
"public",
"function",
"authCheck",
"(",
"Event",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_config",
"[",
"'checkAuthIn'",
"]",
"!==",
"$",
"event",
"->",
"getName",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"/** @var \\Cake\\Controller\\Controller $controller */",
"$",
"controller",
"=",
"$",
"event",
"->",
"getSubject",
"(",
")",
";",
"$",
"action",
"=",
"strtolower",
"(",
"$",
"controller",
"->",
"getRequest",
"(",
")",
"->",
"getParam",
"(",
"'action'",
")",
")",
";",
"if",
"(",
"!",
"$",
"controller",
"->",
"isAction",
"(",
"$",
"action",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"this",
"->",
"_setDefaults",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_isAllowed",
"(",
"$",
"controller",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"isLoginAction",
"=",
"$",
"this",
"->",
"_isLoginAction",
"(",
"$",
"controller",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"_getUser",
"(",
")",
")",
"{",
"if",
"(",
"$",
"isLoginAction",
")",
"{",
"return",
"null",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"_unauthenticated",
"(",
"$",
"controller",
")",
";",
"if",
"(",
"$",
"result",
"instanceof",
"Response",
")",
"{",
"$",
"event",
"->",
"stopPropagation",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}",
"if",
"(",
"$",
"isLoginAction",
"||",
"empty",
"(",
"$",
"this",
"->",
"_config",
"[",
"'authorize'",
"]",
")",
"||",
"$",
"this",
"->",
"isAuthorized",
"(",
"$",
"this",
"->",
"user",
"(",
")",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"event",
"->",
"stopPropagation",
"(",
")",
";",
"return",
"$",
"this",
"->",
"_unauthorized",
"(",
"$",
"controller",
")",
";",
"}"
] | Main execution method, handles initial authentication check and redirection
of invalid users.
The auth check is done when event name is same as the one configured in
`checkAuthIn` config.
@param \Cake\Event\Event $event Event instance.
@return \Cake\Http\Response|null
@throws \ReflectionException | [
"Main",
"execution",
"method",
"handles",
"initial",
"authentication",
"check",
"and",
"redirection",
"of",
"invalid",
"users",
"."
] | 5f6c9d65dcbbfc093410d1dbbb207a17f4cde540 | https://github.com/cakephp/cakephp/blob/5f6c9d65dcbbfc093410d1dbbb207a17f4cde540/src/Controller/Component/AuthComponent.php#L290-L334 |
210,389 | cakephp/cakephp | src/Controller/Component/AuthComponent.php | AuthComponent._isAllowed | protected function _isAllowed(Controller $controller)
{
$action = strtolower($controller->getRequest()->getParam('action'));
return in_array($action, array_map('strtolower', $this->allowedActions));
} | php | protected function _isAllowed(Controller $controller)
{
$action = strtolower($controller->getRequest()->getParam('action'));
return in_array($action, array_map('strtolower', $this->allowedActions));
} | [
"protected",
"function",
"_isAllowed",
"(",
"Controller",
"$",
"controller",
")",
"{",
"$",
"action",
"=",
"strtolower",
"(",
"$",
"controller",
"->",
"getRequest",
"(",
")",
"->",
"getParam",
"(",
"'action'",
")",
")",
";",
"return",
"in_array",
"(",
"$",
"action",
",",
"array_map",
"(",
"'strtolower'",
",",
"$",
"this",
"->",
"allowedActions",
")",
")",
";",
"}"
] | Checks whether current action is accessible without authentication.
@param \Cake\Controller\Controller $controller A reference to the instantiating
controller object
@return bool True if action is accessible without authentication else false | [
"Checks",
"whether",
"current",
"action",
"is",
"accessible",
"without",
"authentication",
"."
] | 5f6c9d65dcbbfc093410d1dbbb207a17f4cde540 | https://github.com/cakephp/cakephp/blob/5f6c9d65dcbbfc093410d1dbbb207a17f4cde540/src/Controller/Component/AuthComponent.php#L356-L361 |
210,390 | cakephp/cakephp | src/Controller/Component/AuthComponent.php | AuthComponent._loginActionRedirectUrl | protected function _loginActionRedirectUrl()
{
$urlToRedirectBackTo = $this->_getUrlToRedirectBackTo();
$loginAction = $this->_config['loginAction'];
if ($urlToRedirectBackTo === '/') {
return $loginAction;
}
if (is_array($loginAction)) {
$loginAction['?'][static::QUERY_STRING_REDIRECT] = $urlToRedirectBackTo;
} else {
$char = strpos($loginAction, '?') === false ? '?' : '&';
$loginAction .= $char . static::QUERY_STRING_REDIRECT . '=' . urlencode($urlToRedirectBackTo);
}
return $loginAction;
} | php | protected function _loginActionRedirectUrl()
{
$urlToRedirectBackTo = $this->_getUrlToRedirectBackTo();
$loginAction = $this->_config['loginAction'];
if ($urlToRedirectBackTo === '/') {
return $loginAction;
}
if (is_array($loginAction)) {
$loginAction['?'][static::QUERY_STRING_REDIRECT] = $urlToRedirectBackTo;
} else {
$char = strpos($loginAction, '?') === false ? '?' : '&';
$loginAction .= $char . static::QUERY_STRING_REDIRECT . '=' . urlencode($urlToRedirectBackTo);
}
return $loginAction;
} | [
"protected",
"function",
"_loginActionRedirectUrl",
"(",
")",
"{",
"$",
"urlToRedirectBackTo",
"=",
"$",
"this",
"->",
"_getUrlToRedirectBackTo",
"(",
")",
";",
"$",
"loginAction",
"=",
"$",
"this",
"->",
"_config",
"[",
"'loginAction'",
"]",
";",
"if",
"(",
"$",
"urlToRedirectBackTo",
"===",
"'/'",
")",
"{",
"return",
"$",
"loginAction",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"loginAction",
")",
")",
"{",
"$",
"loginAction",
"[",
"'?'",
"]",
"[",
"static",
"::",
"QUERY_STRING_REDIRECT",
"]",
"=",
"$",
"urlToRedirectBackTo",
";",
"}",
"else",
"{",
"$",
"char",
"=",
"strpos",
"(",
"$",
"loginAction",
",",
"'?'",
")",
"===",
"false",
"?",
"'?'",
":",
"'&'",
";",
"$",
"loginAction",
".=",
"$",
"char",
".",
"static",
"::",
"QUERY_STRING_REDIRECT",
".",
"'='",
".",
"urlencode",
"(",
"$",
"urlToRedirectBackTo",
")",
";",
"}",
"return",
"$",
"loginAction",
";",
"}"
] | Returns the URL of the login action to redirect to.
This includes the redirect query string if applicable.
@return array|string | [
"Returns",
"the",
"URL",
"of",
"the",
"login",
"action",
"to",
"redirect",
"to",
"."
] | 5f6c9d65dcbbfc093410d1dbbb207a17f4cde540 | https://github.com/cakephp/cakephp/blob/5f6c9d65dcbbfc093410d1dbbb207a17f4cde540/src/Controller/Component/AuthComponent.php#L416-L433 |
210,391 | cakephp/cakephp | src/Controller/Component/AuthComponent.php | AuthComponent._isLoginAction | protected function _isLoginAction(Controller $controller)
{
$uri = $controller->request->getUri();
$url = Router::normalize($uri->getPath());
$loginAction = Router::normalize($this->_config['loginAction']);
return $loginAction === $url;
} | php | protected function _isLoginAction(Controller $controller)
{
$uri = $controller->request->getUri();
$url = Router::normalize($uri->getPath());
$loginAction = Router::normalize($this->_config['loginAction']);
return $loginAction === $url;
} | [
"protected",
"function",
"_isLoginAction",
"(",
"Controller",
"$",
"controller",
")",
"{",
"$",
"uri",
"=",
"$",
"controller",
"->",
"request",
"->",
"getUri",
"(",
")",
";",
"$",
"url",
"=",
"Router",
"::",
"normalize",
"(",
"$",
"uri",
"->",
"getPath",
"(",
")",
")",
";",
"$",
"loginAction",
"=",
"Router",
"::",
"normalize",
"(",
"$",
"this",
"->",
"_config",
"[",
"'loginAction'",
"]",
")",
";",
"return",
"$",
"loginAction",
"===",
"$",
"url",
";",
"}"
] | Normalizes config `loginAction` and checks if current request URL is same as login action.
@param \Cake\Controller\Controller $controller A reference to the controller object.
@return bool True if current action is login action else false. | [
"Normalizes",
"config",
"loginAction",
"and",
"checks",
"if",
"current",
"request",
"URL",
"is",
"same",
"as",
"login",
"action",
"."
] | 5f6c9d65dcbbfc093410d1dbbb207a17f4cde540 | https://github.com/cakephp/cakephp/blob/5f6c9d65dcbbfc093410d1dbbb207a17f4cde540/src/Controller/Component/AuthComponent.php#L441-L448 |
210,392 | cakephp/cakephp | src/Controller/Component/AuthComponent.php | AuthComponent._unauthorized | protected function _unauthorized(Controller $controller)
{
if ($this->_config['unauthorizedRedirect'] === false) {
throw new ForbiddenException($this->_config['authError']);
}
$this->flash($this->_config['authError']);
if ($this->_config['unauthorizedRedirect'] === true) {
$default = '/';
if (!empty($this->_config['loginRedirect'])) {
$default = $this->_config['loginRedirect'];
}
if (is_array($default)) {
$default['_base'] = false;
}
$url = $controller->referer($default, true);
} else {
$url = $this->_config['unauthorizedRedirect'];
}
return $controller->redirect($url);
} | php | protected function _unauthorized(Controller $controller)
{
if ($this->_config['unauthorizedRedirect'] === false) {
throw new ForbiddenException($this->_config['authError']);
}
$this->flash($this->_config['authError']);
if ($this->_config['unauthorizedRedirect'] === true) {
$default = '/';
if (!empty($this->_config['loginRedirect'])) {
$default = $this->_config['loginRedirect'];
}
if (is_array($default)) {
$default['_base'] = false;
}
$url = $controller->referer($default, true);
} else {
$url = $this->_config['unauthorizedRedirect'];
}
return $controller->redirect($url);
} | [
"protected",
"function",
"_unauthorized",
"(",
"Controller",
"$",
"controller",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_config",
"[",
"'unauthorizedRedirect'",
"]",
"===",
"false",
")",
"{",
"throw",
"new",
"ForbiddenException",
"(",
"$",
"this",
"->",
"_config",
"[",
"'authError'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"flash",
"(",
"$",
"this",
"->",
"_config",
"[",
"'authError'",
"]",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_config",
"[",
"'unauthorizedRedirect'",
"]",
"===",
"true",
")",
"{",
"$",
"default",
"=",
"'/'",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_config",
"[",
"'loginRedirect'",
"]",
")",
")",
"{",
"$",
"default",
"=",
"$",
"this",
"->",
"_config",
"[",
"'loginRedirect'",
"]",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"default",
")",
")",
"{",
"$",
"default",
"[",
"'_base'",
"]",
"=",
"false",
";",
"}",
"$",
"url",
"=",
"$",
"controller",
"->",
"referer",
"(",
"$",
"default",
",",
"true",
")",
";",
"}",
"else",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"_config",
"[",
"'unauthorizedRedirect'",
"]",
";",
"}",
"return",
"$",
"controller",
"->",
"redirect",
"(",
"$",
"url",
")",
";",
"}"
] | Handle unauthorized access attempt
@param \Cake\Controller\Controller $controller A reference to the controller object
@return \Cake\Http\Response
@throws \Cake\Http\Exception\ForbiddenException | [
"Handle",
"unauthorized",
"access",
"attempt"
] | 5f6c9d65dcbbfc093410d1dbbb207a17f4cde540 | https://github.com/cakephp/cakephp/blob/5f6c9d65dcbbfc093410d1dbbb207a17f4cde540/src/Controller/Component/AuthComponent.php#L457-L478 |
210,393 | cakephp/cakephp | src/Controller/Component/AuthComponent.php | AuthComponent.isAuthorized | public function isAuthorized($user = null, ServerRequest $request = null)
{
if (empty($user) && !$this->user()) {
return false;
}
if (empty($user)) {
$user = $this->user();
}
if (empty($request)) {
$request = $this->getController()->getRequest();
}
if (empty($this->_authorizeObjects)) {
$this->constructAuthorize();
}
foreach ($this->_authorizeObjects as $authorizer) {
if ($authorizer->authorize($user, $request) === true) {
$this->_authorizationProvider = $authorizer;
return true;
}
}
return false;
} | php | public function isAuthorized($user = null, ServerRequest $request = null)
{
if (empty($user) && !$this->user()) {
return false;
}
if (empty($user)) {
$user = $this->user();
}
if (empty($request)) {
$request = $this->getController()->getRequest();
}
if (empty($this->_authorizeObjects)) {
$this->constructAuthorize();
}
foreach ($this->_authorizeObjects as $authorizer) {
if ($authorizer->authorize($user, $request) === true) {
$this->_authorizationProvider = $authorizer;
return true;
}
}
return false;
} | [
"public",
"function",
"isAuthorized",
"(",
"$",
"user",
"=",
"null",
",",
"ServerRequest",
"$",
"request",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"user",
")",
"&&",
"!",
"$",
"this",
"->",
"user",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"user",
")",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"user",
"(",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"request",
")",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"getController",
"(",
")",
"->",
"getRequest",
"(",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_authorizeObjects",
")",
")",
"{",
"$",
"this",
"->",
"constructAuthorize",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"_authorizeObjects",
"as",
"$",
"authorizer",
")",
"{",
"if",
"(",
"$",
"authorizer",
"->",
"authorize",
"(",
"$",
"user",
",",
"$",
"request",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"_authorizationProvider",
"=",
"$",
"authorizer",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Check if the provided user is authorized for the request.
Uses the configured Authorization adapters to check whether or not a user is authorized.
Each adapter will be checked in sequence, if any of them return true, then the user will
be authorized for the request.
@param array|\ArrayAccess|null $user The user to check the authorization of.
If empty the user fetched from storage will be used.
@param \Cake\Http\ServerRequest|null $request The request to authenticate for.
If empty, the current request will be used.
@return bool True if $user is authorized, otherwise false | [
"Check",
"if",
"the",
"provided",
"user",
"is",
"authorized",
"for",
"the",
"request",
"."
] | 5f6c9d65dcbbfc093410d1dbbb207a17f4cde540 | https://github.com/cakephp/cakephp/blob/5f6c9d65dcbbfc093410d1dbbb207a17f4cde540/src/Controller/Component/AuthComponent.php#L525-L548 |
210,394 | cakephp/cakephp | src/Controller/Component/AuthComponent.php | AuthComponent.constructAuthorize | public function constructAuthorize()
{
if (empty($this->_config['authorize'])) {
return null;
}
$this->_authorizeObjects = [];
$authorize = Hash::normalize((array)$this->_config['authorize']);
$global = [];
if (isset($authorize[AuthComponent::ALL])) {
$global = $authorize[AuthComponent::ALL];
unset($authorize[AuthComponent::ALL]);
}
foreach ($authorize as $alias => $config) {
if (!empty($config['className'])) {
$class = $config['className'];
unset($config['className']);
} else {
$class = $alias;
}
$className = App::className($class, 'Auth', 'Authorize');
if (!class_exists($className)) {
throw new Exception(sprintf('Authorization adapter "%s" was not found.', $class));
}
if (!method_exists($className, 'authorize')) {
throw new Exception('Authorization objects must implement an authorize() method.');
}
$config = (array)$config + $global;
$this->_authorizeObjects[$alias] = new $className($this->_registry, $config);
}
return $this->_authorizeObjects;
} | php | public function constructAuthorize()
{
if (empty($this->_config['authorize'])) {
return null;
}
$this->_authorizeObjects = [];
$authorize = Hash::normalize((array)$this->_config['authorize']);
$global = [];
if (isset($authorize[AuthComponent::ALL])) {
$global = $authorize[AuthComponent::ALL];
unset($authorize[AuthComponent::ALL]);
}
foreach ($authorize as $alias => $config) {
if (!empty($config['className'])) {
$class = $config['className'];
unset($config['className']);
} else {
$class = $alias;
}
$className = App::className($class, 'Auth', 'Authorize');
if (!class_exists($className)) {
throw new Exception(sprintf('Authorization adapter "%s" was not found.', $class));
}
if (!method_exists($className, 'authorize')) {
throw new Exception('Authorization objects must implement an authorize() method.');
}
$config = (array)$config + $global;
$this->_authorizeObjects[$alias] = new $className($this->_registry, $config);
}
return $this->_authorizeObjects;
} | [
"public",
"function",
"constructAuthorize",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_config",
"[",
"'authorize'",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"this",
"->",
"_authorizeObjects",
"=",
"[",
"]",
";",
"$",
"authorize",
"=",
"Hash",
"::",
"normalize",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"_config",
"[",
"'authorize'",
"]",
")",
";",
"$",
"global",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"authorize",
"[",
"AuthComponent",
"::",
"ALL",
"]",
")",
")",
"{",
"$",
"global",
"=",
"$",
"authorize",
"[",
"AuthComponent",
"::",
"ALL",
"]",
";",
"unset",
"(",
"$",
"authorize",
"[",
"AuthComponent",
"::",
"ALL",
"]",
")",
";",
"}",
"foreach",
"(",
"$",
"authorize",
"as",
"$",
"alias",
"=>",
"$",
"config",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"config",
"[",
"'className'",
"]",
")",
")",
"{",
"$",
"class",
"=",
"$",
"config",
"[",
"'className'",
"]",
";",
"unset",
"(",
"$",
"config",
"[",
"'className'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"class",
"=",
"$",
"alias",
";",
"}",
"$",
"className",
"=",
"App",
"::",
"className",
"(",
"$",
"class",
",",
"'Auth'",
",",
"'Authorize'",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"className",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"'Authorization adapter \"%s\" was not found.'",
",",
"$",
"class",
")",
")",
";",
"}",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"className",
",",
"'authorize'",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Authorization objects must implement an authorize() method.'",
")",
";",
"}",
"$",
"config",
"=",
"(",
"array",
")",
"$",
"config",
"+",
"$",
"global",
";",
"$",
"this",
"->",
"_authorizeObjects",
"[",
"$",
"alias",
"]",
"=",
"new",
"$",
"className",
"(",
"$",
"this",
"->",
"_registry",
",",
"$",
"config",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_authorizeObjects",
";",
"}"
] | Loads the authorization objects configured.
@return array|null The loaded authorization objects, or null when authorize is empty.
@throws \Cake\Core\Exception\Exception | [
"Loads",
"the",
"authorization",
"objects",
"configured",
"."
] | 5f6c9d65dcbbfc093410d1dbbb207a17f4cde540 | https://github.com/cakephp/cakephp/blob/5f6c9d65dcbbfc093410d1dbbb207a17f4cde540/src/Controller/Component/AuthComponent.php#L556-L587 |
210,395 | cakephp/cakephp | src/Controller/Component/AuthComponent.php | AuthComponent.getAuthorize | public function getAuthorize($alias)
{
if (empty($this->_authorizeObjects)) {
$this->constructAuthorize();
}
return isset($this->_authorizeObjects[$alias]) ? $this->_authorizeObjects[$alias] : null;
} | php | public function getAuthorize($alias)
{
if (empty($this->_authorizeObjects)) {
$this->constructAuthorize();
}
return isset($this->_authorizeObjects[$alias]) ? $this->_authorizeObjects[$alias] : null;
} | [
"public",
"function",
"getAuthorize",
"(",
"$",
"alias",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_authorizeObjects",
")",
")",
"{",
"$",
"this",
"->",
"constructAuthorize",
"(",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"_authorizeObjects",
"[",
"$",
"alias",
"]",
")",
"?",
"$",
"this",
"->",
"_authorizeObjects",
"[",
"$",
"alias",
"]",
":",
"null",
";",
"}"
] | Getter for authorize objects. Will return a particular authorize object.
@param string $alias Alias for the authorize object
@return \Cake\Auth\BaseAuthorize|null | [
"Getter",
"for",
"authorize",
"objects",
".",
"Will",
"return",
"a",
"particular",
"authorize",
"object",
"."
] | 5f6c9d65dcbbfc093410d1dbbb207a17f4cde540 | https://github.com/cakephp/cakephp/blob/5f6c9d65dcbbfc093410d1dbbb207a17f4cde540/src/Controller/Component/AuthComponent.php#L595-L602 |
210,396 | cakephp/cakephp | src/Controller/Component/AuthComponent.php | AuthComponent.allow | public function allow($actions = null)
{
if ($actions === null) {
$controller = $this->_registry->getController();
$this->allowedActions = get_class_methods($controller);
return;
}
$this->allowedActions = array_merge($this->allowedActions, (array)$actions);
} | php | public function allow($actions = null)
{
if ($actions === null) {
$controller = $this->_registry->getController();
$this->allowedActions = get_class_methods($controller);
return;
}
$this->allowedActions = array_merge($this->allowedActions, (array)$actions);
} | [
"public",
"function",
"allow",
"(",
"$",
"actions",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"actions",
"===",
"null",
")",
"{",
"$",
"controller",
"=",
"$",
"this",
"->",
"_registry",
"->",
"getController",
"(",
")",
";",
"$",
"this",
"->",
"allowedActions",
"=",
"get_class_methods",
"(",
"$",
"controller",
")",
";",
"return",
";",
"}",
"$",
"this",
"->",
"allowedActions",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"allowedActions",
",",
"(",
"array",
")",
"$",
"actions",
")",
";",
"}"
] | Takes a list of actions in the current controller for which authentication is not required, or
no parameters to allow all actions.
You can use allow with either an array or a simple string.
```
$this->Auth->allow('view');
$this->Auth->allow(['edit', 'add']);
```
or to allow all actions
```
$this->Auth->allow();
```
@param string|array|null $actions Controller action name or array of actions
@return void
@link https://book.cakephp.org/3.0/en/controllers/components/authentication.html#making-actions-public | [
"Takes",
"a",
"list",
"of",
"actions",
"in",
"the",
"current",
"controller",
"for",
"which",
"authentication",
"is",
"not",
"required",
"or",
"no",
"parameters",
"to",
"allow",
"all",
"actions",
"."
] | 5f6c9d65dcbbfc093410d1dbbb207a17f4cde540 | https://github.com/cakephp/cakephp/blob/5f6c9d65dcbbfc093410d1dbbb207a17f4cde540/src/Controller/Component/AuthComponent.php#L623-L632 |
210,397 | cakephp/cakephp | src/Controller/Component/AuthComponent.php | AuthComponent.user | public function user($key = null)
{
$user = $this->storage()->read();
if (!$user) {
return null;
}
if ($key === null) {
return $user;
}
return Hash::get($user, $key);
} | php | public function user($key = null)
{
$user = $this->storage()->read();
if (!$user) {
return null;
}
if ($key === null) {
return $user;
}
return Hash::get($user, $key);
} | [
"public",
"function",
"user",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"storage",
"(",
")",
"->",
"read",
"(",
")",
";",
"if",
"(",
"!",
"$",
"user",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"key",
"===",
"null",
")",
"{",
"return",
"$",
"user",
";",
"}",
"return",
"Hash",
"::",
"get",
"(",
"$",
"user",
",",
"$",
"key",
")",
";",
"}"
] | Get the current user from storage.
@param string|null $key Field to retrieve. Leave null to get entire User record.
@return mixed|null Either User record or null if no user is logged in, or retrieved field if key is specified.
@link https://book.cakephp.org/3.0/en/controllers/components/authentication.html#accessing-the-logged-in-user | [
"Get",
"the",
"current",
"user",
"from",
"storage",
"."
] | 5f6c9d65dcbbfc093410d1dbbb207a17f4cde540 | https://github.com/cakephp/cakephp/blob/5f6c9d65dcbbfc093410d1dbbb207a17f4cde540/src/Controller/Component/AuthComponent.php#L714-L726 |
210,398 | cakephp/cakephp | src/Controller/Component/AuthComponent.php | AuthComponent.redirectUrl | public function redirectUrl($url = null)
{
$redirectUrl = $this->getController()->getRequest()->getQuery(static::QUERY_STRING_REDIRECT);
if ($redirectUrl && (substr($redirectUrl, 0, 1) !== '/' || substr($redirectUrl, 0, 2) === '//')) {
$redirectUrl = null;
}
if ($url !== null) {
$redirectUrl = $url;
} elseif ($redirectUrl) {
if (Router::normalize($redirectUrl) === Router::normalize($this->_config['loginAction'])) {
$redirectUrl = $this->_config['loginRedirect'];
}
} elseif ($this->_config['loginRedirect']) {
$redirectUrl = $this->_config['loginRedirect'];
} else {
$redirectUrl = '/';
}
if (is_array($redirectUrl)) {
return Router::url($redirectUrl + ['_base' => false]);
}
return $redirectUrl;
} | php | public function redirectUrl($url = null)
{
$redirectUrl = $this->getController()->getRequest()->getQuery(static::QUERY_STRING_REDIRECT);
if ($redirectUrl && (substr($redirectUrl, 0, 1) !== '/' || substr($redirectUrl, 0, 2) === '//')) {
$redirectUrl = null;
}
if ($url !== null) {
$redirectUrl = $url;
} elseif ($redirectUrl) {
if (Router::normalize($redirectUrl) === Router::normalize($this->_config['loginAction'])) {
$redirectUrl = $this->_config['loginRedirect'];
}
} elseif ($this->_config['loginRedirect']) {
$redirectUrl = $this->_config['loginRedirect'];
} else {
$redirectUrl = '/';
}
if (is_array($redirectUrl)) {
return Router::url($redirectUrl + ['_base' => false]);
}
return $redirectUrl;
} | [
"public",
"function",
"redirectUrl",
"(",
"$",
"url",
"=",
"null",
")",
"{",
"$",
"redirectUrl",
"=",
"$",
"this",
"->",
"getController",
"(",
")",
"->",
"getRequest",
"(",
")",
"->",
"getQuery",
"(",
"static",
"::",
"QUERY_STRING_REDIRECT",
")",
";",
"if",
"(",
"$",
"redirectUrl",
"&&",
"(",
"substr",
"(",
"$",
"redirectUrl",
",",
"0",
",",
"1",
")",
"!==",
"'/'",
"||",
"substr",
"(",
"$",
"redirectUrl",
",",
"0",
",",
"2",
")",
"===",
"'//'",
")",
")",
"{",
"$",
"redirectUrl",
"=",
"null",
";",
"}",
"if",
"(",
"$",
"url",
"!==",
"null",
")",
"{",
"$",
"redirectUrl",
"=",
"$",
"url",
";",
"}",
"elseif",
"(",
"$",
"redirectUrl",
")",
"{",
"if",
"(",
"Router",
"::",
"normalize",
"(",
"$",
"redirectUrl",
")",
"===",
"Router",
"::",
"normalize",
"(",
"$",
"this",
"->",
"_config",
"[",
"'loginAction'",
"]",
")",
")",
"{",
"$",
"redirectUrl",
"=",
"$",
"this",
"->",
"_config",
"[",
"'loginRedirect'",
"]",
";",
"}",
"}",
"elseif",
"(",
"$",
"this",
"->",
"_config",
"[",
"'loginRedirect'",
"]",
")",
"{",
"$",
"redirectUrl",
"=",
"$",
"this",
"->",
"_config",
"[",
"'loginRedirect'",
"]",
";",
"}",
"else",
"{",
"$",
"redirectUrl",
"=",
"'/'",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"redirectUrl",
")",
")",
"{",
"return",
"Router",
"::",
"url",
"(",
"$",
"redirectUrl",
"+",
"[",
"'_base'",
"=>",
"false",
"]",
")",
";",
"}",
"return",
"$",
"redirectUrl",
";",
"}"
] | Get the URL a user should be redirected to upon login.
Pass a URL in to set the destination a user should be redirected to upon
logging in.
If no parameter is passed, gets the authentication redirect URL. The URL
returned is as per following rules:
- Returns the normalized redirect URL from storage if it is
present and for the same domain the current app is running on.
- If there is no URL returned from storage and there is a config
`loginRedirect`, the `loginRedirect` value is returned.
- If there is no session and no `loginRedirect`, / is returned.
@param string|array|null $url Optional URL to write as the login redirect URL.
@return string Redirect URL | [
"Get",
"the",
"URL",
"a",
"user",
"should",
"be",
"redirected",
"to",
"upon",
"login",
"."
] | 5f6c9d65dcbbfc093410d1dbbb207a17f4cde540 | https://github.com/cakephp/cakephp/blob/5f6c9d65dcbbfc093410d1dbbb207a17f4cde540/src/Controller/Component/AuthComponent.php#L782-L805 |
210,399 | cakephp/cakephp | src/Controller/Component/AuthComponent.php | AuthComponent.constructAuthenticate | public function constructAuthenticate()
{
if (empty($this->_config['authenticate'])) {
return null;
}
$this->_authenticateObjects = [];
$authenticate = Hash::normalize((array)$this->_config['authenticate']);
$global = [];
if (isset($authenticate[AuthComponent::ALL])) {
$global = $authenticate[AuthComponent::ALL];
unset($authenticate[AuthComponent::ALL]);
}
foreach ($authenticate as $alias => $config) {
if (!empty($config['className'])) {
$class = $config['className'];
unset($config['className']);
} else {
$class = $alias;
}
$className = App::className($class, 'Auth', 'Authenticate');
if (!class_exists($className)) {
throw new Exception(sprintf('Authentication adapter "%s" was not found.', $class));
}
if (!method_exists($className, 'authenticate')) {
throw new Exception('Authentication objects must implement an authenticate() method.');
}
$config = array_merge($global, (array)$config);
$this->_authenticateObjects[$alias] = new $className($this->_registry, $config);
$this->getEventManager()->on($this->_authenticateObjects[$alias]);
}
return $this->_authenticateObjects;
} | php | public function constructAuthenticate()
{
if (empty($this->_config['authenticate'])) {
return null;
}
$this->_authenticateObjects = [];
$authenticate = Hash::normalize((array)$this->_config['authenticate']);
$global = [];
if (isset($authenticate[AuthComponent::ALL])) {
$global = $authenticate[AuthComponent::ALL];
unset($authenticate[AuthComponent::ALL]);
}
foreach ($authenticate as $alias => $config) {
if (!empty($config['className'])) {
$class = $config['className'];
unset($config['className']);
} else {
$class = $alias;
}
$className = App::className($class, 'Auth', 'Authenticate');
if (!class_exists($className)) {
throw new Exception(sprintf('Authentication adapter "%s" was not found.', $class));
}
if (!method_exists($className, 'authenticate')) {
throw new Exception('Authentication objects must implement an authenticate() method.');
}
$config = array_merge($global, (array)$config);
$this->_authenticateObjects[$alias] = new $className($this->_registry, $config);
$this->getEventManager()->on($this->_authenticateObjects[$alias]);
}
return $this->_authenticateObjects;
} | [
"public",
"function",
"constructAuthenticate",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_config",
"[",
"'authenticate'",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"this",
"->",
"_authenticateObjects",
"=",
"[",
"]",
";",
"$",
"authenticate",
"=",
"Hash",
"::",
"normalize",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"_config",
"[",
"'authenticate'",
"]",
")",
";",
"$",
"global",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"authenticate",
"[",
"AuthComponent",
"::",
"ALL",
"]",
")",
")",
"{",
"$",
"global",
"=",
"$",
"authenticate",
"[",
"AuthComponent",
"::",
"ALL",
"]",
";",
"unset",
"(",
"$",
"authenticate",
"[",
"AuthComponent",
"::",
"ALL",
"]",
")",
";",
"}",
"foreach",
"(",
"$",
"authenticate",
"as",
"$",
"alias",
"=>",
"$",
"config",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"config",
"[",
"'className'",
"]",
")",
")",
"{",
"$",
"class",
"=",
"$",
"config",
"[",
"'className'",
"]",
";",
"unset",
"(",
"$",
"config",
"[",
"'className'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"class",
"=",
"$",
"alias",
";",
"}",
"$",
"className",
"=",
"App",
"::",
"className",
"(",
"$",
"class",
",",
"'Auth'",
",",
"'Authenticate'",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"className",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"'Authentication adapter \"%s\" was not found.'",
",",
"$",
"class",
")",
")",
";",
"}",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"className",
",",
"'authenticate'",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Authentication objects must implement an authenticate() method.'",
")",
";",
"}",
"$",
"config",
"=",
"array_merge",
"(",
"$",
"global",
",",
"(",
"array",
")",
"$",
"config",
")",
";",
"$",
"this",
"->",
"_authenticateObjects",
"[",
"$",
"alias",
"]",
"=",
"new",
"$",
"className",
"(",
"$",
"this",
"->",
"_registry",
",",
"$",
"config",
")",
";",
"$",
"this",
"->",
"getEventManager",
"(",
")",
"->",
"on",
"(",
"$",
"this",
"->",
"_authenticateObjects",
"[",
"$",
"alias",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_authenticateObjects",
";",
"}"
] | Loads the configured authentication objects.
@return array|null The loaded authorization objects, or null on empty authenticate value.
@throws \Cake\Core\Exception\Exception | [
"Loads",
"the",
"configured",
"authentication",
"objects",
"."
] | 5f6c9d65dcbbfc093410d1dbbb207a17f4cde540 | https://github.com/cakephp/cakephp/blob/5f6c9d65dcbbfc093410d1dbbb207a17f4cde540/src/Controller/Component/AuthComponent.php#L845-L877 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.