repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
chillerlan/php-qrcode | src/Output/QRImage.php | QRImage.setPixel | protected function setPixel(int $x, int $y, array $rgb):void{
\imagefilledrectangle(
$this->image,
$x * $this->scale,
$y * $this->scale,
($x + 1) * $this->scale,
($y + 1) * $this->scale,
\imagecolorallocate($this->image, ...$rgb)
);
} | php | protected function setPixel(int $x, int $y, array $rgb):void{
\imagefilledrectangle(
$this->image,
$x * $this->scale,
$y * $this->scale,
($x + 1) * $this->scale,
($y + 1) * $this->scale,
\imagecolorallocate($this->image, ...$rgb)
);
} | [
"protected",
"function",
"setPixel",
"(",
"int",
"$",
"x",
",",
"int",
"$",
"y",
",",
"array",
"$",
"rgb",
")",
":",
"void",
"{",
"\\",
"imagefilledrectangle",
"(",
"$",
"this",
"->",
"image",
",",
"$",
"x",
"*",
"$",
"this",
"->",
"scale",
",",
... | @param int $x
@param int $y
@param array $rgb
@return void | [
"@param",
"int",
"$x",
"@param",
"int",
"$y",
"@param",
"array",
"$rgb"
] | train | https://github.com/chillerlan/php-qrcode/blob/35d28ee6437c16219b2b93c912d3998de0c90fe6/src/Output/QRImage.php#L104-L113 |
chillerlan/php-qrcode | src/Output/QRImage.php | QRImage.dumpImage | protected function dumpImage(string $file = null):string{
$file = $file ?? $this->options->cachefile;
\ob_start();
try{
\call_user_func([$this, $this->outputMode ?? $this->defaultMode]);
}
// not going to cover edge cases
// @codeCoverageIgnoreStart
catch(\Exception $e){
throw new QRCodeOutputException($e->getMessage());
}
// @codeCoverageIgnoreEnd
$imageData = \ob_get_contents();
\imagedestroy($this->image);
\ob_end_clean();
if($file !== null){
$this->saveToFile($imageData, $file);
}
return $imageData;
} | php | protected function dumpImage(string $file = null):string{
$file = $file ?? $this->options->cachefile;
\ob_start();
try{
\call_user_func([$this, $this->outputMode ?? $this->defaultMode]);
}
// not going to cover edge cases
// @codeCoverageIgnoreStart
catch(\Exception $e){
throw new QRCodeOutputException($e->getMessage());
}
// @codeCoverageIgnoreEnd
$imageData = \ob_get_contents();
\imagedestroy($this->image);
\ob_end_clean();
if($file !== null){
$this->saveToFile($imageData, $file);
}
return $imageData;
} | [
"protected",
"function",
"dumpImage",
"(",
"string",
"$",
"file",
"=",
"null",
")",
":",
"string",
"{",
"$",
"file",
"=",
"$",
"file",
"??",
"$",
"this",
"->",
"options",
"->",
"cachefile",
";",
"\\",
"ob_start",
"(",
")",
";",
"try",
"{",
"\\",
"c... | @param string|null $file
@return string
@throws \chillerlan\QRCode\Output\QRCodeOutputException | [
"@param",
"string|null",
"$file"
] | train | https://github.com/chillerlan/php-qrcode/blob/35d28ee6437c16219b2b93c912d3998de0c90fe6/src/Output/QRImage.php#L122-L147 |
chillerlan/php-qrcode | src/Output/QROutputAbstract.php | QROutputAbstract.saveToFile | protected function saveToFile(string $data, string $file):bool{
if(!\is_writable(\dirname($file))){
throw new QRCodeOutputException('Could not write data to cache file: '.$file);
}
return (bool)\file_put_contents($file, $data);
} | php | protected function saveToFile(string $data, string $file):bool{
if(!\is_writable(\dirname($file))){
throw new QRCodeOutputException('Could not write data to cache file: '.$file);
}
return (bool)\file_put_contents($file, $data);
} | [
"protected",
"function",
"saveToFile",
"(",
"string",
"$",
"data",
",",
"string",
"$",
"file",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"\\",
"is_writable",
"(",
"\\",
"dirname",
"(",
"$",
"file",
")",
")",
")",
"{",
"throw",
"new",
"QRCodeOutputExceptio... | @see file_put_contents()
@param string $data
@param string $file
@return bool
@throws \chillerlan\QRCode\Output\QRCodeOutputException | [
"@see",
"file_put_contents",
"()"
] | train | https://github.com/chillerlan/php-qrcode/blob/35d28ee6437c16219b2b93c912d3998de0c90fe6/src/Output/QROutputAbstract.php#L101-L108 |
chillerlan/php-qrcode | src/Output/QROutputAbstract.php | QROutputAbstract.dump | public function dump(string $file = null){
$data = \call_user_func([$this, $this->outputMode ?? $this->defaultMode]);
$file = $file ?? $this->options->cachefile;
if($file !== null){
$this->saveToFile($data, $file);
}
return $data;
} | php | public function dump(string $file = null){
$data = \call_user_func([$this, $this->outputMode ?? $this->defaultMode]);
$file = $file ?? $this->options->cachefile;
if($file !== null){
$this->saveToFile($data, $file);
}
return $data;
} | [
"public",
"function",
"dump",
"(",
"string",
"$",
"file",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"\\",
"call_user_func",
"(",
"[",
"$",
"this",
",",
"$",
"this",
"->",
"outputMode",
"??",
"$",
"this",
"->",
"defaultMode",
"]",
")",
";",
"$",
"fil... | @param string|null $file
@return string|mixed | [
"@param",
"string|null",
"$file"
] | train | https://github.com/chillerlan/php-qrcode/blob/35d28ee6437c16219b2b93c912d3998de0c90fe6/src/Output/QROutputAbstract.php#L115-L124 |
chillerlan/php-qrcode | src/Data/Kanji.php | Kanji.write | protected function write(string $data):void{
$len = \strlen($data);
for($i = 0; $i + 1 < $len; $i += 2){
$c = ((0xff & \ord($data[$i])) << 8) | (0xff & \ord($data[$i + 1]));
if(0x8140 <= $c && $c <= 0x9FFC){
$c -= 0x8140;
}
elseif(0xE040 <= $c && $c <= 0xEBBF){
$c -= 0xC140;
}
else{
throw new QRCodeDataException('illegal char at '.($i + 1).' ['.$c.']');
}
$this->bitBuffer->put((($c >> 8) & 0xff) * 0xC0 + ($c & 0xff), 13);
}
if($i < $len){
throw new QRCodeDataException('illegal char at '.($i + 1));
}
} | php | protected function write(string $data):void{
$len = \strlen($data);
for($i = 0; $i + 1 < $len; $i += 2){
$c = ((0xff & \ord($data[$i])) << 8) | (0xff & \ord($data[$i + 1]));
if(0x8140 <= $c && $c <= 0x9FFC){
$c -= 0x8140;
}
elseif(0xE040 <= $c && $c <= 0xEBBF){
$c -= 0xC140;
}
else{
throw new QRCodeDataException('illegal char at '.($i + 1).' ['.$c.']');
}
$this->bitBuffer->put((($c >> 8) & 0xff) * 0xC0 + ($c & 0xff), 13);
}
if($i < $len){
throw new QRCodeDataException('illegal char at '.($i + 1));
}
} | [
"protected",
"function",
"write",
"(",
"string",
"$",
"data",
")",
":",
"void",
"{",
"$",
"len",
"=",
"\\",
"strlen",
"(",
"$",
"data",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"+",
"1",
"<",
"$",
"len",
";",
"$",
"i",
"+=",... | @param string $data
@return void
@throws \chillerlan\QRCode\Data\QRCodeDataException | [
"@param",
"string",
"$data"
] | train | https://github.com/chillerlan/php-qrcode/blob/35d28ee6437c16219b2b93c912d3998de0c90fe6/src/Data/Kanji.php#L45-L69 |
chillerlan/php-qrcode | src/Data/Number.php | Number.parseInt | protected function parseInt(string $string):int{
$num = 0;
$len = strlen($string);
for($i = 0; $i < $len; $i++){
$c = \ord($string[$i]);
if(!in_array($string[$i], $this::NUMBER_CHAR_MAP, true)){
throw new QRCodeDataException('illegal char: "'.$string[$i].'" ['.$c.']');
}
$c = $c - \ord('0');
$num = $num * 10 + $c;
}
return $num;
} | php | protected function parseInt(string $string):int{
$num = 0;
$len = strlen($string);
for($i = 0; $i < $len; $i++){
$c = \ord($string[$i]);
if(!in_array($string[$i], $this::NUMBER_CHAR_MAP, true)){
throw new QRCodeDataException('illegal char: "'.$string[$i].'" ['.$c.']');
}
$c = $c - \ord('0');
$num = $num * 10 + $c;
}
return $num;
} | [
"protected",
"function",
"parseInt",
"(",
"string",
"$",
"string",
")",
":",
"int",
"{",
"$",
"num",
"=",
"0",
";",
"$",
"len",
"=",
"strlen",
"(",
"$",
"string",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"len",
";",
... | @param string $string
@return int
@throws \chillerlan\QRCode\Data\QRCodeDataException | [
"@param",
"string",
"$string"
] | train | https://github.com/chillerlan/php-qrcode/blob/35d28ee6437c16219b2b93c912d3998de0c90fe6/src/Data/Number.php#L64-L81 |
chillerlan/php-qrcode | src/Data/AlphaNum.php | AlphaNum.getCharCode | protected function getCharCode(string $chr):int{
$i = \array_search($chr, $this::ALPHANUM_CHAR_MAP);
if($i !== false){
return $i;
}
throw new QRCodeDataException('illegal char: "'.$chr.'" ['.\ord($chr).']');
} | php | protected function getCharCode(string $chr):int{
$i = \array_search($chr, $this::ALPHANUM_CHAR_MAP);
if($i !== false){
return $i;
}
throw new QRCodeDataException('illegal char: "'.$chr.'" ['.\ord($chr).']');
} | [
"protected",
"function",
"getCharCode",
"(",
"string",
"$",
"chr",
")",
":",
"int",
"{",
"$",
"i",
"=",
"\\",
"array_search",
"(",
"$",
"chr",
",",
"$",
"this",
"::",
"ALPHANUM_CHAR_MAP",
")",
";",
"if",
"(",
"$",
"i",
"!==",
"false",
")",
"{",
"re... | @param string $chr
@return int
@throws \chillerlan\QRCode\Data\QRCodeDataException | [
"@param",
"string",
"$chr"
] | train | https://github.com/chillerlan/php-qrcode/blob/35d28ee6437c16219b2b93c912d3998de0c90fe6/src/Data/AlphaNum.php#L53-L61 |
chillerlan/php-qrcode | src/Helpers/BitBuffer.php | BitBuffer.put | public function put(int $num, int $length):BitBuffer{
for($i = 0; $i < $length; $i++){
$this->putBit(($num >> ($length - $i - 1))&1 === 1);
}
return $this;
} | php | public function put(int $num, int $length):BitBuffer{
for($i = 0; $i < $length; $i++){
$this->putBit(($num >> ($length - $i - 1))&1 === 1);
}
return $this;
} | [
"public",
"function",
"put",
"(",
"int",
"$",
"num",
",",
"int",
"$",
"length",
")",
":",
"BitBuffer",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"length",
";",
"$",
"i",
"++",
")",
"{",
"$",
"this",
"->",
"putBit",
"(",
... | @param int $num
@param int $length
@return \chillerlan\QRCode\Helpers\BitBuffer | [
"@param",
"int",
"$num",
"@param",
"int",
"$length"
] | train | https://github.com/chillerlan/php-qrcode/blob/35d28ee6437c16219b2b93c912d3998de0c90fe6/src/Helpers/BitBuffer.php#L43-L50 |
chillerlan/php-qrcode | src/Helpers/BitBuffer.php | BitBuffer.putBit | public function putBit(bool $bit):BitBuffer{
$bufIndex = \floor($this->length / 8);
if(\count($this->buffer) <= $bufIndex){
$this->buffer[] = 0;
}
if($bit === true){
$this->buffer[(int)$bufIndex] |= (0x80 >> ($this->length % 8));
}
$this->length++;
return $this;
} | php | public function putBit(bool $bit):BitBuffer{
$bufIndex = \floor($this->length / 8);
if(\count($this->buffer) <= $bufIndex){
$this->buffer[] = 0;
}
if($bit === true){
$this->buffer[(int)$bufIndex] |= (0x80 >> ($this->length % 8));
}
$this->length++;
return $this;
} | [
"public",
"function",
"putBit",
"(",
"bool",
"$",
"bit",
")",
":",
"BitBuffer",
"{",
"$",
"bufIndex",
"=",
"\\",
"floor",
"(",
"$",
"this",
"->",
"length",
"/",
"8",
")",
";",
"if",
"(",
"\\",
"count",
"(",
"$",
"this",
"->",
"buffer",
")",
"<=",... | @param bool $bit
@return \chillerlan\QRCode\Helpers\BitBuffer | [
"@param",
"bool",
"$bit"
] | train | https://github.com/chillerlan/php-qrcode/blob/35d28ee6437c16219b2b93c912d3998de0c90fe6/src/Helpers/BitBuffer.php#L57-L71 |
chillerlan/php-qrcode | src/QRCode.php | QRCode.render | public function render(string $data, string $file = null){
return $this->initOutputInterface($data)->dump($file);
} | php | public function render(string $data, string $file = null){
return $this->initOutputInterface($data)->dump($file);
} | [
"public",
"function",
"render",
"(",
"string",
"$",
"data",
",",
"string",
"$",
"file",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"initOutputInterface",
"(",
"$",
"data",
")",
"->",
"dump",
"(",
"$",
"file",
")",
";",
"}"
] | Renders a QR Code for the given $data and QROptions
@param string $data
@param string|null $file
@return mixed | [
"Renders",
"a",
"QR",
"Code",
"for",
"the",
"given",
"$data",
"and",
"QROptions"
] | train | https://github.com/chillerlan/php-qrcode/blob/35d28ee6437c16219b2b93c912d3998de0c90fe6/src/QRCode.php#L137-L139 |
chillerlan/php-qrcode | src/QRCode.php | QRCode.getMatrix | public function getMatrix(string $data):QRMatrix{
if(empty($data)){
throw new QRCodeDataException('QRCode::getMatrix() No data given.');
}
$this->dataInterface = $this->initDataInterface($data);
$maskPattern = $this->options->maskPattern === $this::MASK_PATTERN_AUTO
? $this->getBestMaskPattern()
: $this->options->maskPattern;
$matrix = $this->dataInterface->initMatrix($maskPattern);
if((bool)$this->options->addQuietzone){
$matrix->setQuietZone($this->options->quietzoneSize);
}
return $matrix;
} | php | public function getMatrix(string $data):QRMatrix{
if(empty($data)){
throw new QRCodeDataException('QRCode::getMatrix() No data given.');
}
$this->dataInterface = $this->initDataInterface($data);
$maskPattern = $this->options->maskPattern === $this::MASK_PATTERN_AUTO
? $this->getBestMaskPattern()
: $this->options->maskPattern;
$matrix = $this->dataInterface->initMatrix($maskPattern);
if((bool)$this->options->addQuietzone){
$matrix->setQuietZone($this->options->quietzoneSize);
}
return $matrix;
} | [
"public",
"function",
"getMatrix",
"(",
"string",
"$",
"data",
")",
":",
"QRMatrix",
"{",
"if",
"(",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"throw",
"new",
"QRCodeDataException",
"(",
"'QRCode::getMatrix() No data given.'",
")",
";",
"}",
"$",
"this",
"... | Returns a QRMatrix object for the given $data and current QROptions
@param string $data
@return \chillerlan\QRCode\Data\QRMatrix
@throws \chillerlan\QRCode\Data\QRCodeDataException | [
"Returns",
"a",
"QRMatrix",
"object",
"for",
"the",
"given",
"$data",
"and",
"current",
"QROptions"
] | train | https://github.com/chillerlan/php-qrcode/blob/35d28ee6437c16219b2b93c912d3998de0c90fe6/src/QRCode.php#L149-L168 |
chillerlan/php-qrcode | src/QRCode.php | QRCode.getBestMaskPattern | protected function getBestMaskPattern():int{
$penalties = [];
for($pattern = 0; $pattern < 8; $pattern++){
$tester = new MaskPatternTester($this->dataInterface->initMatrix($pattern, true));
$penalties[$pattern] = $tester->testPattern();
}
return \array_search(\min($penalties), $penalties, true);
} | php | protected function getBestMaskPattern():int{
$penalties = [];
for($pattern = 0; $pattern < 8; $pattern++){
$tester = new MaskPatternTester($this->dataInterface->initMatrix($pattern, true));
$penalties[$pattern] = $tester->testPattern();
}
return \array_search(\min($penalties), $penalties, true);
} | [
"protected",
"function",
"getBestMaskPattern",
"(",
")",
":",
"int",
"{",
"$",
"penalties",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"pattern",
"=",
"0",
";",
"$",
"pattern",
"<",
"8",
";",
"$",
"pattern",
"++",
")",
"{",
"$",
"tester",
"=",
"new",
"... | shoves a QRMatrix through the MaskPatternTester to find the lowest penalty mask pattern
@see \chillerlan\QRCode\Data\MaskPatternTester
@return int | [
"shoves",
"a",
"QRMatrix",
"through",
"the",
"MaskPatternTester",
"to",
"find",
"the",
"lowest",
"penalty",
"mask",
"pattern"
] | train | https://github.com/chillerlan/php-qrcode/blob/35d28ee6437c16219b2b93c912d3998de0c90fe6/src/QRCode.php#L177-L187 |
chillerlan/php-qrcode | src/QRCode.php | QRCode.initDataInterface | public function initDataInterface(string $data):QRDataInterface{
foreach(['Number', 'AlphaNum', 'Kanji', 'Byte'] as $mode){
$dataInterface = __NAMESPACE__.'\\Data\\'.$mode;
if(\call_user_func_array([$this, 'is'.$mode], [$data]) && \class_exists($dataInterface)){
return new $dataInterface($this->options, $data);
}
}
throw new QRCodeDataException('invalid data type'); // @codeCoverageIgnore
} | php | public function initDataInterface(string $data):QRDataInterface{
foreach(['Number', 'AlphaNum', 'Kanji', 'Byte'] as $mode){
$dataInterface = __NAMESPACE__.'\\Data\\'.$mode;
if(\call_user_func_array([$this, 'is'.$mode], [$data]) && \class_exists($dataInterface)){
return new $dataInterface($this->options, $data);
}
}
throw new QRCodeDataException('invalid data type'); // @codeCoverageIgnore
} | [
"public",
"function",
"initDataInterface",
"(",
"string",
"$",
"data",
")",
":",
"QRDataInterface",
"{",
"foreach",
"(",
"[",
"'Number'",
",",
"'AlphaNum'",
",",
"'Kanji'",
",",
"'Byte'",
"]",
"as",
"$",
"mode",
")",
"{",
"$",
"dataInterface",
"=",
"__NAME... | returns a fresh QRDataInterface for the given $data
@param string $data
@return \chillerlan\QRCode\Data\QRDataInterface
@throws \chillerlan\QRCode\Data\QRCodeDataException | [
"returns",
"a",
"fresh",
"QRDataInterface",
"for",
"the",
"given",
"$data"
] | train | https://github.com/chillerlan/php-qrcode/blob/35d28ee6437c16219b2b93c912d3998de0c90fe6/src/QRCode.php#L197-L209 |
chillerlan/php-qrcode | src/QRCode.php | QRCode.initOutputInterface | protected function initOutputInterface(string $data):QROutputInterface{
if($this->options->outputType === $this::OUTPUT_CUSTOM && \class_exists($this->options->outputInterface)){
return new $this->options->outputInterface($this->options, $this->getMatrix($data));
}
foreach($this::OUTPUT_MODES as $outputInterface => $modes){
if(in_array($this->options->outputType, $modes, true) && \class_exists($outputInterface)){
return new $outputInterface($this->options, $this->getMatrix($data));
}
}
throw new QRCodeOutputException('invalid output type');
} | php | protected function initOutputInterface(string $data):QROutputInterface{
if($this->options->outputType === $this::OUTPUT_CUSTOM && \class_exists($this->options->outputInterface)){
return new $this->options->outputInterface($this->options, $this->getMatrix($data));
}
foreach($this::OUTPUT_MODES as $outputInterface => $modes){
if(in_array($this->options->outputType, $modes, true) && \class_exists($outputInterface)){
return new $outputInterface($this->options, $this->getMatrix($data));
}
}
throw new QRCodeOutputException('invalid output type');
} | [
"protected",
"function",
"initOutputInterface",
"(",
"string",
"$",
"data",
")",
":",
"QROutputInterface",
"{",
"if",
"(",
"$",
"this",
"->",
"options",
"->",
"outputType",
"===",
"$",
"this",
"::",
"OUTPUT_CUSTOM",
"&&",
"\\",
"class_exists",
"(",
"$",
"thi... | returns a fresh (built-in) QROutputInterface
@param string $data
@return \chillerlan\QRCode\Output\QROutputInterface
@throws \chillerlan\QRCode\Output\QRCodeOutputException | [
"returns",
"a",
"fresh",
"(",
"built",
"-",
"in",
")",
"QROutputInterface"
] | train | https://github.com/chillerlan/php-qrcode/blob/35d28ee6437c16219b2b93c912d3998de0c90fe6/src/QRCode.php#L219-L234 |
chillerlan/php-qrcode | src/QRCode.php | QRCode.checkString | protected function checkString(string $string, array $charmap):bool{
$len = \strlen($string);
for($i = 0; $i < $len; $i++){
if(!\in_array($string[$i], $charmap, true)){
return false;
}
}
return true;
} | php | protected function checkString(string $string, array $charmap):bool{
$len = \strlen($string);
for($i = 0; $i < $len; $i++){
if(!\in_array($string[$i], $charmap, true)){
return false;
}
}
return true;
} | [
"protected",
"function",
"checkString",
"(",
"string",
"$",
"string",
",",
"array",
"$",
"charmap",
")",
":",
"bool",
"{",
"$",
"len",
"=",
"\\",
"strlen",
"(",
"$",
"string",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"... | checks is a given $string matches the characters of a given $charmap, returns false on the first invalid occurence.
@param string $string
@param array $charmap
@return bool | [
"checks",
"is",
"a",
"given",
"$string",
"matches",
"the",
"characters",
"of",
"a",
"given",
"$charmap",
"returns",
"false",
"on",
"the",
"first",
"invalid",
"occurence",
"."
] | train | https://github.com/chillerlan/php-qrcode/blob/35d28ee6437c16219b2b93c912d3998de0c90fe6/src/QRCode.php#L266-L276 |
chillerlan/php-qrcode | src/QRCode.php | QRCode.isKanji | public function isKanji(string $string):bool{
$i = 0;
$len = \strlen($string);
while($i + 1 < $len){
$c = ((0xff&\ord($string[$i])) << 8)|(0xff&\ord($string[$i + 1]));
if(!($c >= 0x8140 && $c <= 0x9FFC) && !($c >= 0xE040 && $c <= 0xEBBF)){
return false;
}
$i += 2;
}
return $i >= $len;
} | php | public function isKanji(string $string):bool{
$i = 0;
$len = \strlen($string);
while($i + 1 < $len){
$c = ((0xff&\ord($string[$i])) << 8)|(0xff&\ord($string[$i + 1]));
if(!($c >= 0x8140 && $c <= 0x9FFC) && !($c >= 0xE040 && $c <= 0xEBBF)){
return false;
}
$i += 2;
}
return $i >= $len;
} | [
"public",
"function",
"isKanji",
"(",
"string",
"$",
"string",
")",
":",
"bool",
"{",
"$",
"i",
"=",
"0",
";",
"$",
"len",
"=",
"\\",
"strlen",
"(",
"$",
"string",
")",
";",
"while",
"(",
"$",
"i",
"+",
"1",
"<",
"$",
"len",
")",
"{",
"$",
... | checks if a string qualifies as Kanji
@param string $string
@return bool | [
"checks",
"if",
"a",
"string",
"qualifies",
"as",
"Kanji"
] | train | https://github.com/chillerlan/php-qrcode/blob/35d28ee6437c16219b2b93c912d3998de0c90fe6/src/QRCode.php#L285-L300 |
chillerlan/php-qrcode | src/Helpers/Polynomial.php | Polynomial.setNum | public function setNum(array $num, int $shift = null):Polynomial{
$offset = 0;
$numCount = \count($num);
while($offset < $numCount && $num[$offset] === 0){
$offset++;
}
$this->num = \array_fill(0, $numCount - $offset + ($shift ?? 0), 0);
for($i = 0; $i < $numCount - $offset; $i++){
$this->num[$i] = $num[$i + $offset];
}
return $this;
} | php | public function setNum(array $num, int $shift = null):Polynomial{
$offset = 0;
$numCount = \count($num);
while($offset < $numCount && $num[$offset] === 0){
$offset++;
}
$this->num = \array_fill(0, $numCount - $offset + ($shift ?? 0), 0);
for($i = 0; $i < $numCount - $offset; $i++){
$this->num[$i] = $num[$i + $offset];
}
return $this;
} | [
"public",
"function",
"setNum",
"(",
"array",
"$",
"num",
",",
"int",
"$",
"shift",
"=",
"null",
")",
":",
"Polynomial",
"{",
"$",
"offset",
"=",
"0",
";",
"$",
"numCount",
"=",
"\\",
"count",
"(",
"$",
"num",
")",
";",
"while",
"(",
"$",
"offset... | @param array $num
@param int|null $shift
@return \chillerlan\QRCode\Helpers\Polynomial | [
"@param",
"array",
"$num",
"@param",
"int|null",
"$shift"
] | train | https://github.com/chillerlan/php-qrcode/blob/35d28ee6437c16219b2b93c912d3998de0c90fe6/src/Helpers/Polynomial.php#L88-L103 |
chillerlan/php-qrcode | src/Helpers/Polynomial.php | Polynomial.multiply | public function multiply(array $e):Polynomial{
$n = \array_fill(0, \count($this->num) + \count($e) - 1, 0);
foreach($this->num as $i => $vi){
$vi = $this->glog($vi);
foreach($e as $j => $vj){
$n[$i + $j] ^= $this->gexp($vi + $this->glog($vj));
}
}
$this->setNum($n);
return $this;
} | php | public function multiply(array $e):Polynomial{
$n = \array_fill(0, \count($this->num) + \count($e) - 1, 0);
foreach($this->num as $i => $vi){
$vi = $this->glog($vi);
foreach($e as $j => $vj){
$n[$i + $j] ^= $this->gexp($vi + $this->glog($vj));
}
}
$this->setNum($n);
return $this;
} | [
"public",
"function",
"multiply",
"(",
"array",
"$",
"e",
")",
":",
"Polynomial",
"{",
"$",
"n",
"=",
"\\",
"array_fill",
"(",
"0",
",",
"\\",
"count",
"(",
"$",
"this",
"->",
"num",
")",
"+",
"\\",
"count",
"(",
"$",
"e",
")",
"-",
"1",
",",
... | @param array $e
@return \chillerlan\QRCode\Helpers\Polynomial | [
"@param",
"array",
"$e"
] | train | https://github.com/chillerlan/php-qrcode/blob/35d28ee6437c16219b2b93c912d3998de0c90fe6/src/Helpers/Polynomial.php#L110-L125 |
chillerlan/php-qrcode | src/Helpers/Polynomial.php | Polynomial.mod | public function mod(array $e):Polynomial{
$n = $this->num;
if(\count($n) - \count($e) < 0){
return $this;
}
$ratio = $this->glog($n[0]) - $this->glog($e[0]);
foreach($e as $i => $v){
$n[$i] ^= $this->gexp($this->glog($v) + $ratio);
}
$this->setNum($n)->mod($e);
return $this;
} | php | public function mod(array $e):Polynomial{
$n = $this->num;
if(\count($n) - \count($e) < 0){
return $this;
}
$ratio = $this->glog($n[0]) - $this->glog($e[0]);
foreach($e as $i => $v){
$n[$i] ^= $this->gexp($this->glog($v) + $ratio);
}
$this->setNum($n)->mod($e);
return $this;
} | [
"public",
"function",
"mod",
"(",
"array",
"$",
"e",
")",
":",
"Polynomial",
"{",
"$",
"n",
"=",
"$",
"this",
"->",
"num",
";",
"if",
"(",
"\\",
"count",
"(",
"$",
"n",
")",
"-",
"\\",
"count",
"(",
"$",
"e",
")",
"<",
"0",
")",
"{",
"retur... | @param array $e
@return \chillerlan\QRCode\Helpers\Polynomial | [
"@param",
"array",
"$e"
] | train | https://github.com/chillerlan/php-qrcode/blob/35d28ee6437c16219b2b93c912d3998de0c90fe6/src/Helpers/Polynomial.php#L132-L148 |
chillerlan/php-qrcode | src/Helpers/Polynomial.php | Polynomial.glog | public function glog(int $n):int{
if($n < 1){
throw new QRCodeException('log('.$n.')');
}
return Polynomial::table[$n][1];
} | php | public function glog(int $n):int{
if($n < 1){
throw new QRCodeException('log('.$n.')');
}
return Polynomial::table[$n][1];
} | [
"public",
"function",
"glog",
"(",
"int",
"$",
"n",
")",
":",
"int",
"{",
"if",
"(",
"$",
"n",
"<",
"1",
")",
"{",
"throw",
"new",
"QRCodeException",
"(",
"'log('",
".",
"$",
"n",
".",
"')'",
")",
";",
"}",
"return",
"Polynomial",
"::",
"table",
... | @param int $n
@return int
@throws \chillerlan\QRCode\QRCodeException | [
"@param",
"int",
"$n"
] | train | https://github.com/chillerlan/php-qrcode/blob/35d28ee6437c16219b2b93c912d3998de0c90fe6/src/Helpers/Polynomial.php#L156-L163 |
chillerlan/php-qrcode | src/Helpers/Polynomial.php | Polynomial.gexp | public function gexp(int $n):int{
if($n < 0){
$n += 255;
}
elseif($n >= 256){
$n -= 255;
}
return Polynomial::table[$n][0];
} | php | public function gexp(int $n):int{
if($n < 0){
$n += 255;
}
elseif($n >= 256){
$n -= 255;
}
return Polynomial::table[$n][0];
} | [
"public",
"function",
"gexp",
"(",
"int",
"$",
"n",
")",
":",
"int",
"{",
"if",
"(",
"$",
"n",
"<",
"0",
")",
"{",
"$",
"n",
"+=",
"255",
";",
"}",
"elseif",
"(",
"$",
"n",
">=",
"256",
")",
"{",
"$",
"n",
"-=",
"255",
";",
"}",
"return",... | @param int $n
@return int | [
"@param",
"int",
"$n"
] | train | https://github.com/chillerlan/php-qrcode/blob/35d28ee6437c16219b2b93c912d3998de0c90fe6/src/Helpers/Polynomial.php#L170-L180 |
voku/HtmlMin | src/voku/helper/HtmlMin.php | HtmlMin.notifyObserversAboutDomElementBeforeMinification | private function notifyObserversAboutDomElementBeforeMinification(SimpleHtmlDom $domElement)
{
foreach ($this->domLoopObservers as $observer) {
$observer->domElementBeforeMinification($domElement, $this);
}
} | php | private function notifyObserversAboutDomElementBeforeMinification(SimpleHtmlDom $domElement)
{
foreach ($this->domLoopObservers as $observer) {
$observer->domElementBeforeMinification($domElement, $this);
}
} | [
"private",
"function",
"notifyObserversAboutDomElementBeforeMinification",
"(",
"SimpleHtmlDom",
"$",
"domElement",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"domLoopObservers",
"as",
"$",
"observer",
")",
"{",
"$",
"observer",
"->",
"domElementBeforeMinification",
... | @param $domElement SimpleHtmlDom
@return void | [
"@param",
"$domElement",
"SimpleHtmlDom"
] | train | https://github.com/voku/HtmlMin/blob/d3e0c2b62ba1b35bf4ed6f28d9e9f210f53287d3/src/voku/helper/HtmlMin.php#L276-L281 |
voku/HtmlMin | src/voku/helper/HtmlMin.php | HtmlMin.domNodeClosingTagOptional | private function domNodeClosingTagOptional(\DOMNode $node): bool
{
$tag_name = $node->nodeName;
$nextSibling = $this->getNextSiblingOfTypeDOMElement($node);
// https://html.spec.whatwg.org/multipage/syntax.html#syntax-tag-omission
// Implemented:
//
// A <p> element's end tag may be omitted if the p element is immediately followed by an address, article, aside, blockquote, details, div, dl, fieldset, figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr, main, menu, nav, ol, p, pre, section, table, or ul element, or if there is no more content in the parent element and the parent element is an HTML element that is not an a, audio, del, ins, map, noscript, or video element, or an autonomous custom element.
// An <li> element's end tag may be omitted if the li element is immediately followed by another li element or if there is no more content in the parent element.
// A <td> element's end tag may be omitted if the td element is immediately followed by a td or th element, or if there is no more content in the parent element.
// An <option> element's end tag may be omitted if the option element is immediately followed by another option element, or if it is immediately followed by an optgroup element, or if there is no more content in the parent element.
// A <tr> element's end tag may be omitted if the tr element is immediately followed by another tr element, or if there is no more content in the parent element.
// A <th> element's end tag may be omitted if the th element is immediately followed by a td or th element, or if there is no more content in the parent element.
// A <dt> element's end tag may be omitted if the dt element is immediately followed by another dt element or a dd element.
// A <dd> element's end tag may be omitted if the dd element is immediately followed by another dd element or a dt element, or if there is no more content in the parent element.
// An <rp> element's end tag may be omitted if the rp element is immediately followed by an rt or rp element, or if there is no more content in the parent element.
// TODO:
//
// <html> may be omitted if first thing inside is not comment
// <head> may be omitted if first thing inside is an element
// <body> may be omitted if first thing inside is not space, comment, <meta>, <link>, <script>, <style> or <template>
// <colgroup> may be omitted if first thing inside is <col>
// <tbody> may be omitted if first thing inside is <tr>
// An <optgroup> element's end tag may be omitted if the optgroup element is immediately followed by another optgroup element, or if there is no more content in the parent element.
// A <colgroup> element's start tag may be omitted if the first thing inside the colgroup element is a col element, and if the element is not immediately preceded by another colgroup element whose end tag has been omitted. (It can't be omitted if the element is empty.)
// A <colgroup> element's end tag may be omitted if the colgroup element is not immediately followed by ASCII whitespace or a comment.
// A <caption> element's end tag may be omitted if the caption element is not immediately followed by ASCII whitespace or a comment.
// A <thead> element's end tag may be omitted if the thead element is immediately followed by a tbody or tfoot element.
// A <tbody> element's start tag may be omitted if the first thing inside the tbody element is a tr element, and if the element is not immediately preceded by a tbody, thead, or tfoot element whose end tag has been omitted. (It can't be omitted if the element is empty.)
// A <tbody> element's end tag may be omitted if the tbody element is immediately followed by a tbody or tfoot element, or if there is no more content in the parent element.
// A <tfoot> element's end tag may be omitted if there is no more content in the parent element.
//
// <-- However, a start tag must never be omitted if it has any attributes.
return \in_array($tag_name, self::$optional_end_tags, true)
||
(
$tag_name === 'li'
&&
(
$nextSibling === null
||
(
$nextSibling instanceof \DOMElement
&&
$nextSibling->tagName === 'li'
)
)
)
||
(
(
$tag_name === 'rp'
)
&&
(
$nextSibling === null
||
(
$nextSibling instanceof \DOMElement
&&
(
$nextSibling->tagName === 'rp'
||
$nextSibling->tagName === 'rt'
)
)
)
)
||
(
$tag_name === 'tr'
&&
(
$nextSibling === null
||
(
$nextSibling instanceof \DOMElement
&&
$nextSibling->tagName === 'tr'
)
)
)
||
(
(
$tag_name === 'td'
||
$tag_name === 'th'
)
&&
(
$nextSibling === null
||
(
$nextSibling instanceof \DOMElement
&&
(
$nextSibling->tagName === 'td'
||
$nextSibling->tagName === 'th'
)
)
)
)
||
(
(
$tag_name === 'dd'
||
$tag_name === 'dt'
)
&&
(
(
$nextSibling === null
&&
$tag_name === 'dd'
)
||
(
$nextSibling instanceof \DOMElement
&&
(
$nextSibling->tagName === 'dd'
||
$nextSibling->tagName === 'dt'
)
)
)
)
||
(
$tag_name === 'option'
&&
(
$nextSibling === null
||
(
$nextSibling instanceof \DOMElement
&&
(
$nextSibling->tagName === 'option'
||
$nextSibling->tagName === 'optgroup'
)
)
)
)
||
(
$tag_name === 'p'
&&
(
(
$nextSibling === null
&&
(
$node->parentNode !== null
&&
!\in_array(
$node->parentNode->nodeName,
[
'a',
'audio',
'del',
'ins',
'map',
'noscript',
'video',
],
true
)
)
)
||
(
$nextSibling instanceof \DOMElement
&&
\in_array(
$nextSibling->tagName,
[
'address',
'article',
'aside',
'blockquote',
'dir',
'div',
'dl',
'fieldset',
'footer',
'form',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'header',
'hgroup',
'hr',
'menu',
'nav',
'ol',
'p',
'pre',
'section',
'table',
'ul',
],
true
)
)
)
);
} | php | private function domNodeClosingTagOptional(\DOMNode $node): bool
{
$tag_name = $node->nodeName;
$nextSibling = $this->getNextSiblingOfTypeDOMElement($node);
// https://html.spec.whatwg.org/multipage/syntax.html#syntax-tag-omission
// Implemented:
//
// A <p> element's end tag may be omitted if the p element is immediately followed by an address, article, aside, blockquote, details, div, dl, fieldset, figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr, main, menu, nav, ol, p, pre, section, table, or ul element, or if there is no more content in the parent element and the parent element is an HTML element that is not an a, audio, del, ins, map, noscript, or video element, or an autonomous custom element.
// An <li> element's end tag may be omitted if the li element is immediately followed by another li element or if there is no more content in the parent element.
// A <td> element's end tag may be omitted if the td element is immediately followed by a td or th element, or if there is no more content in the parent element.
// An <option> element's end tag may be omitted if the option element is immediately followed by another option element, or if it is immediately followed by an optgroup element, or if there is no more content in the parent element.
// A <tr> element's end tag may be omitted if the tr element is immediately followed by another tr element, or if there is no more content in the parent element.
// A <th> element's end tag may be omitted if the th element is immediately followed by a td or th element, or if there is no more content in the parent element.
// A <dt> element's end tag may be omitted if the dt element is immediately followed by another dt element or a dd element.
// A <dd> element's end tag may be omitted if the dd element is immediately followed by another dd element or a dt element, or if there is no more content in the parent element.
// An <rp> element's end tag may be omitted if the rp element is immediately followed by an rt or rp element, or if there is no more content in the parent element.
// TODO:
//
// <html> may be omitted if first thing inside is not comment
// <head> may be omitted if first thing inside is an element
// <body> may be omitted if first thing inside is not space, comment, <meta>, <link>, <script>, <style> or <template>
// <colgroup> may be omitted if first thing inside is <col>
// <tbody> may be omitted if first thing inside is <tr>
// An <optgroup> element's end tag may be omitted if the optgroup element is immediately followed by another optgroup element, or if there is no more content in the parent element.
// A <colgroup> element's start tag may be omitted if the first thing inside the colgroup element is a col element, and if the element is not immediately preceded by another colgroup element whose end tag has been omitted. (It can't be omitted if the element is empty.)
// A <colgroup> element's end tag may be omitted if the colgroup element is not immediately followed by ASCII whitespace or a comment.
// A <caption> element's end tag may be omitted if the caption element is not immediately followed by ASCII whitespace or a comment.
// A <thead> element's end tag may be omitted if the thead element is immediately followed by a tbody or tfoot element.
// A <tbody> element's start tag may be omitted if the first thing inside the tbody element is a tr element, and if the element is not immediately preceded by a tbody, thead, or tfoot element whose end tag has been omitted. (It can't be omitted if the element is empty.)
// A <tbody> element's end tag may be omitted if the tbody element is immediately followed by a tbody or tfoot element, or if there is no more content in the parent element.
// A <tfoot> element's end tag may be omitted if there is no more content in the parent element.
//
// <-- However, a start tag must never be omitted if it has any attributes.
return \in_array($tag_name, self::$optional_end_tags, true)
||
(
$tag_name === 'li'
&&
(
$nextSibling === null
||
(
$nextSibling instanceof \DOMElement
&&
$nextSibling->tagName === 'li'
)
)
)
||
(
(
$tag_name === 'rp'
)
&&
(
$nextSibling === null
||
(
$nextSibling instanceof \DOMElement
&&
(
$nextSibling->tagName === 'rp'
||
$nextSibling->tagName === 'rt'
)
)
)
)
||
(
$tag_name === 'tr'
&&
(
$nextSibling === null
||
(
$nextSibling instanceof \DOMElement
&&
$nextSibling->tagName === 'tr'
)
)
)
||
(
(
$tag_name === 'td'
||
$tag_name === 'th'
)
&&
(
$nextSibling === null
||
(
$nextSibling instanceof \DOMElement
&&
(
$nextSibling->tagName === 'td'
||
$nextSibling->tagName === 'th'
)
)
)
)
||
(
(
$tag_name === 'dd'
||
$tag_name === 'dt'
)
&&
(
(
$nextSibling === null
&&
$tag_name === 'dd'
)
||
(
$nextSibling instanceof \DOMElement
&&
(
$nextSibling->tagName === 'dd'
||
$nextSibling->tagName === 'dt'
)
)
)
)
||
(
$tag_name === 'option'
&&
(
$nextSibling === null
||
(
$nextSibling instanceof \DOMElement
&&
(
$nextSibling->tagName === 'option'
||
$nextSibling->tagName === 'optgroup'
)
)
)
)
||
(
$tag_name === 'p'
&&
(
(
$nextSibling === null
&&
(
$node->parentNode !== null
&&
!\in_array(
$node->parentNode->nodeName,
[
'a',
'audio',
'del',
'ins',
'map',
'noscript',
'video',
],
true
)
)
)
||
(
$nextSibling instanceof \DOMElement
&&
\in_array(
$nextSibling->tagName,
[
'address',
'article',
'aside',
'blockquote',
'dir',
'div',
'dl',
'fieldset',
'footer',
'form',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'header',
'hgroup',
'hr',
'menu',
'nav',
'ol',
'p',
'pre',
'section',
'table',
'ul',
],
true
)
)
)
);
} | [
"private",
"function",
"domNodeClosingTagOptional",
"(",
"\\",
"DOMNode",
"$",
"node",
")",
":",
"bool",
"{",
"$",
"tag_name",
"=",
"$",
"node",
"->",
"nodeName",
";",
"$",
"nextSibling",
"=",
"$",
"this",
"->",
"getNextSiblingOfTypeDOMElement",
"(",
"$",
"n... | @param \DOMNode $node
@return bool | [
"@param",
"\\",
"DOMNode",
"$node"
] | train | https://github.com/voku/HtmlMin/blob/d3e0c2b62ba1b35bf4ed6f28d9e9f210f53287d3/src/voku/helper/HtmlMin.php#L712-L930 |
voku/HtmlMin | src/voku/helper/HtmlMin.php | HtmlMin.getNextSiblingOfTypeDOMElement | protected function getNextSiblingOfTypeDOMElement(\DOMNode $node)
{
do {
$node = $node->nextSibling;
} while (!($node === null || $node instanceof \DOMElement));
return $node;
} | php | protected function getNextSiblingOfTypeDOMElement(\DOMNode $node)
{
do {
$node = $node->nextSibling;
} while (!($node === null || $node instanceof \DOMElement));
return $node;
} | [
"protected",
"function",
"getNextSiblingOfTypeDOMElement",
"(",
"\\",
"DOMNode",
"$",
"node",
")",
"{",
"do",
"{",
"$",
"node",
"=",
"$",
"node",
"->",
"nextSibling",
";",
"}",
"while",
"(",
"!",
"(",
"$",
"node",
"===",
"null",
"||",
"$",
"node",
"ins... | @param \DOMNode $node
@return \DOMNode|null | [
"@param",
"\\",
"DOMNode",
"$node"
] | train | https://github.com/voku/HtmlMin/blob/d3e0c2b62ba1b35bf4ed6f28d9e9f210f53287d3/src/voku/helper/HtmlMin.php#L1025-L1032 |
voku/HtmlMin | src/voku/helper/HtmlMin.php | HtmlMin.isConditionalComment | private function isConditionalComment($comment): bool
{
if (\preg_match('/^\[if [^\]]+\]/', $comment)) {
return true;
}
if (\preg_match('/\[endif\]$/', $comment)) {
return true;
}
return false;
} | php | private function isConditionalComment($comment): bool
{
if (\preg_match('/^\[if [^\]]+\]/', $comment)) {
return true;
}
if (\preg_match('/\[endif\]$/', $comment)) {
return true;
}
return false;
} | [
"private",
"function",
"isConditionalComment",
"(",
"$",
"comment",
")",
":",
"bool",
"{",
"if",
"(",
"\\",
"preg_match",
"(",
"'/^\\[if [^\\]]+\\]/'",
",",
"$",
"comment",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"\\",
"preg_match",
"(",
"'... | Check if the current string is an conditional comment.
INFO: since IE >= 10 conditional comment are not working anymore
<!--[if expression]> HTML <![endif]-->
<![if expression]> HTML <![endif]>
@param string $comment
@return bool | [
"Check",
"if",
"the",
"current",
"string",
"is",
"an",
"conditional",
"comment",
"."
] | train | https://github.com/voku/HtmlMin/blob/d3e0c2b62ba1b35bf4ed6f28d9e9f210f53287d3/src/voku/helper/HtmlMin.php#L1046-L1057 |
voku/HtmlMin | src/voku/helper/HtmlMin.php | HtmlMin.minify | public function minify($html, $decodeUtf8Specials = false): string
{
$html = (string) $html;
if (!isset($html[0])) {
return '';
}
$html = \trim($html);
if (!$html) {
return '';
}
// init
static $CACHE_SELF_CLOSING_TAGS = null;
if ($CACHE_SELF_CLOSING_TAGS === null) {
$CACHE_SELF_CLOSING_TAGS = \implode('|', self::$selfClosingTags);
}
// reset
$this->protectedChildNodes = [];
// save old content
$origHtml = $html;
$origHtmlLength = \strlen($html);
// -------------------------------------------------------------------------
// Minify the HTML via "HtmlDomParser"
// -------------------------------------------------------------------------
if ($this->doOptimizeViaHtmlDomParser) {
$html = $this->minifyHtmlDom($html, $decodeUtf8Specials);
}
// -------------------------------------------------------------------------
// Trim whitespace from html-string. [protected html is still protected]
// -------------------------------------------------------------------------
// Remove extra white-space(s) between HTML attribute(s)
$html = (string) \preg_replace_callback(
'#<([^/\s<>!]+)(?:\s+([^<>]*?)\s*|\s*)(/?)>#',
function ($matches) {
return '<' . $matches[1] . (string) \preg_replace('#([^\s=]+)(\=([\'"]?)(.*?)\3)?(\s+|$)#s', ' $1$2', $matches[2]) . $matches[3] . '>';
},
$html
);
if ($this->doRemoveSpacesBetweenTags) {
// Remove spaces that are between > and <
$html = (string) \preg_replace('/(>) (<)/', '>$2', $html);
}
// -------------------------------------------------------------------------
// Restore protected HTML-code.
// -------------------------------------------------------------------------
$html = (string) \preg_replace_callback(
'/<(?<element>' . $this->protectedChildNodesHelper . ')(?<attributes> [^>]*)?>(?<value>.*?)<\/' . $this->protectedChildNodesHelper . '>/',
[$this, 'restoreProtectedHtml'],
$html
);
// -------------------------------------------------------------------------
// Restore protected HTML-entities.
// -------------------------------------------------------------------------
if ($this->doOptimizeViaHtmlDomParser) {
$html = HtmlDomParser::putReplacedBackToPreserveHtmlEntities($html);
}
// ------------------------------------
// Final clean-up
// ------------------------------------
$html = \str_replace(
[
'html>' . "\n",
"\n" . '<html',
'html/>' . "\n",
"\n" . '</html',
'head>' . "\n",
"\n" . '<head',
'head/>' . "\n",
"\n" . '</head',
],
[
'html>',
'<html',
'html/>',
'</html',
'head>',
'<head',
'head/>',
'</head',
],
$html
);
// self closing tags, don't need a trailing slash ...
$replace = [];
$replacement = [];
foreach (self::$selfClosingTags as $selfClosingTag) {
$replace[] = '<' . $selfClosingTag . '/>';
$replacement[] = '<' . $selfClosingTag . '>';
$replace[] = '<' . $selfClosingTag . ' />';
$replacement[] = '<' . $selfClosingTag . '>';
}
$html = \str_replace(
$replace,
$replacement,
$html
);
$html = (string) \preg_replace('#<\b(' . $CACHE_SELF_CLOSING_TAGS . ')([^>]*+)><\/\b\1>#', '<\\1\\2>', $html);
// ------------------------------------
// check if compression worked
// ------------------------------------
if ($origHtmlLength < \strlen($html)) {
$html = $origHtml;
}
return $html;
} | php | public function minify($html, $decodeUtf8Specials = false): string
{
$html = (string) $html;
if (!isset($html[0])) {
return '';
}
$html = \trim($html);
if (!$html) {
return '';
}
// init
static $CACHE_SELF_CLOSING_TAGS = null;
if ($CACHE_SELF_CLOSING_TAGS === null) {
$CACHE_SELF_CLOSING_TAGS = \implode('|', self::$selfClosingTags);
}
// reset
$this->protectedChildNodes = [];
// save old content
$origHtml = $html;
$origHtmlLength = \strlen($html);
// -------------------------------------------------------------------------
// Minify the HTML via "HtmlDomParser"
// -------------------------------------------------------------------------
if ($this->doOptimizeViaHtmlDomParser) {
$html = $this->minifyHtmlDom($html, $decodeUtf8Specials);
}
// -------------------------------------------------------------------------
// Trim whitespace from html-string. [protected html is still protected]
// -------------------------------------------------------------------------
// Remove extra white-space(s) between HTML attribute(s)
$html = (string) \preg_replace_callback(
'#<([^/\s<>!]+)(?:\s+([^<>]*?)\s*|\s*)(/?)>#',
function ($matches) {
return '<' . $matches[1] . (string) \preg_replace('#([^\s=]+)(\=([\'"]?)(.*?)\3)?(\s+|$)#s', ' $1$2', $matches[2]) . $matches[3] . '>';
},
$html
);
if ($this->doRemoveSpacesBetweenTags) {
// Remove spaces that are between > and <
$html = (string) \preg_replace('/(>) (<)/', '>$2', $html);
}
// -------------------------------------------------------------------------
// Restore protected HTML-code.
// -------------------------------------------------------------------------
$html = (string) \preg_replace_callback(
'/<(?<element>' . $this->protectedChildNodesHelper . ')(?<attributes> [^>]*)?>(?<value>.*?)<\/' . $this->protectedChildNodesHelper . '>/',
[$this, 'restoreProtectedHtml'],
$html
);
// -------------------------------------------------------------------------
// Restore protected HTML-entities.
// -------------------------------------------------------------------------
if ($this->doOptimizeViaHtmlDomParser) {
$html = HtmlDomParser::putReplacedBackToPreserveHtmlEntities($html);
}
// ------------------------------------
// Final clean-up
// ------------------------------------
$html = \str_replace(
[
'html>' . "\n",
"\n" . '<html',
'html/>' . "\n",
"\n" . '</html',
'head>' . "\n",
"\n" . '<head',
'head/>' . "\n",
"\n" . '</head',
],
[
'html>',
'<html',
'html/>',
'</html',
'head>',
'<head',
'head/>',
'</head',
],
$html
);
// self closing tags, don't need a trailing slash ...
$replace = [];
$replacement = [];
foreach (self::$selfClosingTags as $selfClosingTag) {
$replace[] = '<' . $selfClosingTag . '/>';
$replacement[] = '<' . $selfClosingTag . '>';
$replace[] = '<' . $selfClosingTag . ' />';
$replacement[] = '<' . $selfClosingTag . '>';
}
$html = \str_replace(
$replace,
$replacement,
$html
);
$html = (string) \preg_replace('#<\b(' . $CACHE_SELF_CLOSING_TAGS . ')([^>]*+)><\/\b\1>#', '<\\1\\2>', $html);
// ------------------------------------
// check if compression worked
// ------------------------------------
if ($origHtmlLength < \strlen($html)) {
$html = $origHtml;
}
return $html;
} | [
"public",
"function",
"minify",
"(",
"$",
"html",
",",
"$",
"decodeUtf8Specials",
"=",
"false",
")",
":",
"string",
"{",
"$",
"html",
"=",
"(",
"string",
")",
"$",
"html",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"html",
"[",
"0",
"]",
")",
")",
... | @param string $html
@param bool $decodeUtf8Specials <p>Use this only in special cases, e.g. for PHP 5.3</p>
@return string | [
"@param",
"string",
"$html",
"@param",
"bool",
"$decodeUtf8Specials",
"<p",
">",
"Use",
"this",
"only",
"in",
"special",
"cases",
"e",
".",
"g",
".",
"for",
"PHP",
"5",
".",
"3<",
"/",
"p",
">"
] | train | https://github.com/voku/HtmlMin/blob/d3e0c2b62ba1b35bf4ed6f28d9e9f210f53287d3/src/voku/helper/HtmlMin.php#L1065-L1188 |
voku/HtmlMin | src/voku/helper/HtmlMin.php | HtmlMin.minifyHtmlDom | private function minifyHtmlDom($html, $decodeUtf8Specials): string
{
// init dom
$dom = new HtmlDomParser();
/** @noinspection UnusedFunctionResultInspection */
$dom->useKeepBrokenHtml($this->keepBrokenHtml);
$dom->getDocument()->preserveWhiteSpace = false; // remove redundant white space
$dom->getDocument()->formatOutput = false; // do not formats output with indentation
// load dom
/** @noinspection UnusedFunctionResultInspection */
$dom->loadHtml($html);
$this->withDocType = (\stripos(\ltrim($html), '<!DOCTYPE') === 0);
foreach ($dom->find('*') as $element) {
$this->notifyObserversAboutDomElementBeforeMinification($element);
}
// -------------------------------------------------------------------------
// Protect HTML tags and conditional comments.
// -------------------------------------------------------------------------
$dom = $this->protectTags($dom);
// -------------------------------------------------------------------------
// Remove default HTML comments. [protected html is still protected]
// -------------------------------------------------------------------------
if ($this->doRemoveComments) {
$dom = $this->removeComments($dom);
}
// -------------------------------------------------------------------------
// Sum-Up extra whitespace from the Dom. [protected html is still protected]
// -------------------------------------------------------------------------
if ($this->doSumUpWhitespace) {
$dom = $this->sumUpWhitespace($dom);
}
foreach ($dom->find('*') as $element) {
// -------------------------------------------------------------------------
// Remove whitespace around tags. [protected html is still protected]
// -------------------------------------------------------------------------
if ($this->doRemoveWhitespaceAroundTags) {
$this->removeWhitespaceAroundTags($element);
}
$this->notifyObserversAboutDomElementAfterMinification($element);
}
// -------------------------------------------------------------------------
// Convert the Dom into a string.
// -------------------------------------------------------------------------
return $dom->fixHtmlOutput(
$this->domNodeToString($dom->getDocument()),
$decodeUtf8Specials
);
} | php | private function minifyHtmlDom($html, $decodeUtf8Specials): string
{
// init dom
$dom = new HtmlDomParser();
/** @noinspection UnusedFunctionResultInspection */
$dom->useKeepBrokenHtml($this->keepBrokenHtml);
$dom->getDocument()->preserveWhiteSpace = false; // remove redundant white space
$dom->getDocument()->formatOutput = false; // do not formats output with indentation
// load dom
/** @noinspection UnusedFunctionResultInspection */
$dom->loadHtml($html);
$this->withDocType = (\stripos(\ltrim($html), '<!DOCTYPE') === 0);
foreach ($dom->find('*') as $element) {
$this->notifyObserversAboutDomElementBeforeMinification($element);
}
// -------------------------------------------------------------------------
// Protect HTML tags and conditional comments.
// -------------------------------------------------------------------------
$dom = $this->protectTags($dom);
// -------------------------------------------------------------------------
// Remove default HTML comments. [protected html is still protected]
// -------------------------------------------------------------------------
if ($this->doRemoveComments) {
$dom = $this->removeComments($dom);
}
// -------------------------------------------------------------------------
// Sum-Up extra whitespace from the Dom. [protected html is still protected]
// -------------------------------------------------------------------------
if ($this->doSumUpWhitespace) {
$dom = $this->sumUpWhitespace($dom);
}
foreach ($dom->find('*') as $element) {
// -------------------------------------------------------------------------
// Remove whitespace around tags. [protected html is still protected]
// -------------------------------------------------------------------------
if ($this->doRemoveWhitespaceAroundTags) {
$this->removeWhitespaceAroundTags($element);
}
$this->notifyObserversAboutDomElementAfterMinification($element);
}
// -------------------------------------------------------------------------
// Convert the Dom into a string.
// -------------------------------------------------------------------------
return $dom->fixHtmlOutput(
$this->domNodeToString($dom->getDocument()),
$decodeUtf8Specials
);
} | [
"private",
"function",
"minifyHtmlDom",
"(",
"$",
"html",
",",
"$",
"decodeUtf8Specials",
")",
":",
"string",
"{",
"// init dom",
"$",
"dom",
"=",
"new",
"HtmlDomParser",
"(",
")",
";",
"/** @noinspection UnusedFunctionResultInspection */",
"$",
"dom",
"->",
"useK... | @param $html
@param $decodeUtf8Specials
@return string | [
"@param",
"$html",
"@param",
"$decodeUtf8Specials"
] | train | https://github.com/voku/HtmlMin/blob/d3e0c2b62ba1b35bf4ed6f28d9e9f210f53287d3/src/voku/helper/HtmlMin.php#L1196-L1259 |
voku/HtmlMin | src/voku/helper/HtmlMin.php | HtmlMin.protectTags | private function protectTags(HtmlDomParser $dom): HtmlDomParser
{
// init
$counter = 0;
foreach ($dom->find('script, style') as $element) {
// skip external links
if ($element->tag === 'script' || $element->tag === 'style') {
$attributes = $element->getAllAttributes();
if (isset($attributes['src'])) {
continue;
}
}
$this->protectedChildNodes[$counter] = $element->text();
$element->getNode()->nodeValue = '<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $counter . '"></' . $this->protectedChildNodesHelper . '>';
++$counter;
}
foreach ($dom->find('code, nocompress') as $element) {
if ($element->isRemoved()) {
continue;
}
$this->protectedChildNodes[$counter] = $element->parentNode()->innerHtml();
$element->getNode()->parentNode->nodeValue = '<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $counter . '"></' . $this->protectedChildNodesHelper . '>';
++$counter;
}
foreach ($dom->find('//comment()') as $element) {
$text = $element->text();
// skip normal comments
if (!$this->isConditionalComment($text)) {
continue;
}
$this->protectedChildNodes[$counter] = '<!--' . $text . '-->';
/* @var $node \DOMComment */
$node = $element->getNode();
$child = new \DOMText('<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $counter . '"></' . $this->protectedChildNodesHelper . '>');
/** @noinspection UnusedFunctionResultInspection */
$element->getNode()->parentNode->replaceChild($child, $node);
++$counter;
}
return $dom;
} | php | private function protectTags(HtmlDomParser $dom): HtmlDomParser
{
// init
$counter = 0;
foreach ($dom->find('script, style') as $element) {
// skip external links
if ($element->tag === 'script' || $element->tag === 'style') {
$attributes = $element->getAllAttributes();
if (isset($attributes['src'])) {
continue;
}
}
$this->protectedChildNodes[$counter] = $element->text();
$element->getNode()->nodeValue = '<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $counter . '"></' . $this->protectedChildNodesHelper . '>';
++$counter;
}
foreach ($dom->find('code, nocompress') as $element) {
if ($element->isRemoved()) {
continue;
}
$this->protectedChildNodes[$counter] = $element->parentNode()->innerHtml();
$element->getNode()->parentNode->nodeValue = '<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $counter . '"></' . $this->protectedChildNodesHelper . '>';
++$counter;
}
foreach ($dom->find('//comment()') as $element) {
$text = $element->text();
// skip normal comments
if (!$this->isConditionalComment($text)) {
continue;
}
$this->protectedChildNodes[$counter] = '<!--' . $text . '-->';
/* @var $node \DOMComment */
$node = $element->getNode();
$child = new \DOMText('<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $counter . '"></' . $this->protectedChildNodesHelper . '>');
/** @noinspection UnusedFunctionResultInspection */
$element->getNode()->parentNode->replaceChild($child, $node);
++$counter;
}
return $dom;
} | [
"private",
"function",
"protectTags",
"(",
"HtmlDomParser",
"$",
"dom",
")",
":",
"HtmlDomParser",
"{",
"// init",
"$",
"counter",
"=",
"0",
";",
"foreach",
"(",
"$",
"dom",
"->",
"find",
"(",
"'script, style'",
")",
"as",
"$",
"element",
")",
"{",
"// s... | Prevent changes of inline "styles" and "scripts".
@param HtmlDomParser $dom
@return HtmlDomParser | [
"Prevent",
"changes",
"of",
"inline",
"styles",
"and",
"scripts",
"."
] | train | https://github.com/voku/HtmlMin/blob/d3e0c2b62ba1b35bf4ed6f28d9e9f210f53287d3/src/voku/helper/HtmlMin.php#L1268-L1320 |
voku/HtmlMin | src/voku/helper/HtmlMin.php | HtmlMin.removeComments | private function removeComments(HtmlDomParser $dom): HtmlDomParser
{
foreach ($dom->find('//comment()') as $commentWrapper) {
$comment = $commentWrapper->getNode();
$val = $comment->nodeValue;
if (\strpos($val, '[') === false) {
/** @noinspection UnusedFunctionResultInspection */
$comment->parentNode->removeChild($comment);
}
}
$dom->getDocument()->normalizeDocument();
return $dom;
} | php | private function removeComments(HtmlDomParser $dom): HtmlDomParser
{
foreach ($dom->find('//comment()') as $commentWrapper) {
$comment = $commentWrapper->getNode();
$val = $comment->nodeValue;
if (\strpos($val, '[') === false) {
/** @noinspection UnusedFunctionResultInspection */
$comment->parentNode->removeChild($comment);
}
}
$dom->getDocument()->normalizeDocument();
return $dom;
} | [
"private",
"function",
"removeComments",
"(",
"HtmlDomParser",
"$",
"dom",
")",
":",
"HtmlDomParser",
"{",
"foreach",
"(",
"$",
"dom",
"->",
"find",
"(",
"'//comment()'",
")",
"as",
"$",
"commentWrapper",
")",
"{",
"$",
"comment",
"=",
"$",
"commentWrapper",... | Remove comments in the dom.
@param HtmlDomParser $dom
@return HtmlDomParser | [
"Remove",
"comments",
"in",
"the",
"dom",
"."
] | train | https://github.com/voku/HtmlMin/blob/d3e0c2b62ba1b35bf4ed6f28d9e9f210f53287d3/src/voku/helper/HtmlMin.php#L1329-L1343 |
voku/HtmlMin | src/voku/helper/HtmlMin.php | HtmlMin.removeWhitespaceAroundTags | private function removeWhitespaceAroundTags(SimpleHtmlDom $element)
{
if (isset(self::$trimWhitespaceFromTags[$element->tag])) {
$node = $element->getNode();
/** @var \DOMNode[] $candidates */
$candidates = [];
if ($node->childNodes->length > 0) {
$candidates[] = $node->firstChild;
$candidates[] = $node->lastChild;
$candidates[] = $node->previousSibling;
$candidates[] = $node->nextSibling;
}
foreach ($candidates as &$candidate) {
if ($candidate === null) {
continue;
}
if ($candidate->nodeType === \XML_TEXT_NODE) {
$candidate->nodeValue = \preg_replace(self::$regExSpace, ' ', $candidate->nodeValue);
}
}
}
} | php | private function removeWhitespaceAroundTags(SimpleHtmlDom $element)
{
if (isset(self::$trimWhitespaceFromTags[$element->tag])) {
$node = $element->getNode();
/** @var \DOMNode[] $candidates */
$candidates = [];
if ($node->childNodes->length > 0) {
$candidates[] = $node->firstChild;
$candidates[] = $node->lastChild;
$candidates[] = $node->previousSibling;
$candidates[] = $node->nextSibling;
}
foreach ($candidates as &$candidate) {
if ($candidate === null) {
continue;
}
if ($candidate->nodeType === \XML_TEXT_NODE) {
$candidate->nodeValue = \preg_replace(self::$regExSpace, ' ', $candidate->nodeValue);
}
}
}
} | [
"private",
"function",
"removeWhitespaceAroundTags",
"(",
"SimpleHtmlDom",
"$",
"element",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"trimWhitespaceFromTags",
"[",
"$",
"element",
"->",
"tag",
"]",
")",
")",
"{",
"$",
"node",
"=",
"$",
"element... | Trim tags in the dom.
@param SimpleHtmlDom $element
@return void | [
"Trim",
"tags",
"in",
"the",
"dom",
"."
] | train | https://github.com/voku/HtmlMin/blob/d3e0c2b62ba1b35bf4ed6f28d9e9f210f53287d3/src/voku/helper/HtmlMin.php#L1352-L1376 |
voku/HtmlMin | src/voku/helper/HtmlMin.php | HtmlMin.restoreProtectedHtml | private function restoreProtectedHtml($matches): string
{
\preg_match('/.*"(?<id>\d*)"/', $matches['attributes'], $matchesInner);
$html = '';
if (isset($this->protectedChildNodes[$matchesInner['id']])) {
$html .= $this->protectedChildNodes[$matchesInner['id']];
}
return $html;
} | php | private function restoreProtectedHtml($matches): string
{
\preg_match('/.*"(?<id>\d*)"/', $matches['attributes'], $matchesInner);
$html = '';
if (isset($this->protectedChildNodes[$matchesInner['id']])) {
$html .= $this->protectedChildNodes[$matchesInner['id']];
}
return $html;
} | [
"private",
"function",
"restoreProtectedHtml",
"(",
"$",
"matches",
")",
":",
"string",
"{",
"\\",
"preg_match",
"(",
"'/.*\"(?<id>\\d*)\"/'",
",",
"$",
"matches",
"[",
"'attributes'",
"]",
",",
"$",
"matchesInner",
")",
";",
"$",
"html",
"=",
"''",
";",
"... | Callback function for preg_replace_callback use.
@param array $matches PREG matches
@return string | [
"Callback",
"function",
"for",
"preg_replace_callback",
"use",
"."
] | train | https://github.com/voku/HtmlMin/blob/d3e0c2b62ba1b35bf4ed6f28d9e9f210f53287d3/src/voku/helper/HtmlMin.php#L1385-L1395 |
voku/HtmlMin | src/voku/helper/HtmlMin.php | HtmlMin.sumUpWhitespace | private function sumUpWhitespace(HtmlDomParser $dom): HtmlDomParser
{
$text_nodes = $dom->find('//text()');
foreach ($text_nodes as $text_node_wrapper) {
/* @var $text_node \DOMNode */
$text_node = $text_node_wrapper->getNode();
$xp = $text_node->getNodePath();
$doSkip = false;
foreach (self::$skipTagsForRemoveWhitespace as $pattern) {
if (\strpos($xp, "/${pattern}") !== false) {
$doSkip = true;
break;
}
}
if ($doSkip) {
continue;
}
$text_node->nodeValue = \preg_replace(self::$regExSpace, ' ', $text_node->nodeValue);
}
$dom->getDocument()->normalizeDocument();
return $dom;
} | php | private function sumUpWhitespace(HtmlDomParser $dom): HtmlDomParser
{
$text_nodes = $dom->find('//text()');
foreach ($text_nodes as $text_node_wrapper) {
/* @var $text_node \DOMNode */
$text_node = $text_node_wrapper->getNode();
$xp = $text_node->getNodePath();
$doSkip = false;
foreach (self::$skipTagsForRemoveWhitespace as $pattern) {
if (\strpos($xp, "/${pattern}") !== false) {
$doSkip = true;
break;
}
}
if ($doSkip) {
continue;
}
$text_node->nodeValue = \preg_replace(self::$regExSpace, ' ', $text_node->nodeValue);
}
$dom->getDocument()->normalizeDocument();
return $dom;
} | [
"private",
"function",
"sumUpWhitespace",
"(",
"HtmlDomParser",
"$",
"dom",
")",
":",
"HtmlDomParser",
"{",
"$",
"text_nodes",
"=",
"$",
"dom",
"->",
"find",
"(",
"'//text()'",
")",
";",
"foreach",
"(",
"$",
"text_nodes",
"as",
"$",
"text_node_wrapper",
")",... | Sum-up extra whitespace from dom-nodes.
@param HtmlDomParser $dom
@return HtmlDomParser | [
"Sum",
"-",
"up",
"extra",
"whitespace",
"from",
"dom",
"-",
"nodes",
"."
] | train | https://github.com/voku/HtmlMin/blob/d3e0c2b62ba1b35bf4ed6f28d9e9f210f53287d3/src/voku/helper/HtmlMin.php#L1416-L1442 |
voku/HtmlMin | src/voku/helper/HtmlMinDomObserverOptimizeAttributes.php | HtmlMinDomObserverOptimizeAttributes.domElementAfterMinification | public function domElementAfterMinification(SimpleHtmlDom $element, HtmlMin $htmlMin)
{
$attributes = $element->getAllAttributes();
if ($attributes === null) {
return;
}
$attrs = [];
foreach ((array) $attributes as $attrName => $attrValue) {
// -------------------------------------------------------------------------
// Remove optional "http:"-prefix from attributes.
// -------------------------------------------------------------------------
if ($htmlMin->isDoRemoveHttpPrefixFromAttributes()) {
if (
($attrName === 'href' || $attrName === 'src' || $attrName === 'action')
&&
!(isset($attributes['rel']) && $attributes['rel'] === 'external')
&&
!(isset($attributes['target']) && $attributes['target'] === '_blank')
) {
$attrValue = \str_replace('http://', '//', $attrValue);
}
}
if ($this->removeAttributeHelper($element->tag, $attrName, $attrValue, $attributes, $htmlMin)) {
$element->{$attrName} = null;
continue;
}
// -------------------------------------------------------------------------
// Sort css-class-names, for better gzip results.
// -------------------------------------------------------------------------
if ($htmlMin->isDoSortCssClassNames()) {
$attrValue = $this->sortCssClassNames($attrName, $attrValue);
}
if ($htmlMin->isDoSortHtmlAttributes()) {
$attrs[$attrName] = $attrValue;
$element->{$attrName} = null;
}
}
// -------------------------------------------------------------------------
// Sort html-attributes, for better gzip results.
// -------------------------------------------------------------------------
if ($htmlMin->isDoSortHtmlAttributes()) {
\ksort($attrs);
foreach ($attrs as $attrName => $attrValue) {
$attrValue = HtmlDomParser::replaceToPreserveHtmlEntities($attrValue);
$element->setAttribute($attrName, $attrValue, true);
}
}
} | php | public function domElementAfterMinification(SimpleHtmlDom $element, HtmlMin $htmlMin)
{
$attributes = $element->getAllAttributes();
if ($attributes === null) {
return;
}
$attrs = [];
foreach ((array) $attributes as $attrName => $attrValue) {
// -------------------------------------------------------------------------
// Remove optional "http:"-prefix from attributes.
// -------------------------------------------------------------------------
if ($htmlMin->isDoRemoveHttpPrefixFromAttributes()) {
if (
($attrName === 'href' || $attrName === 'src' || $attrName === 'action')
&&
!(isset($attributes['rel']) && $attributes['rel'] === 'external')
&&
!(isset($attributes['target']) && $attributes['target'] === '_blank')
) {
$attrValue = \str_replace('http://', '//', $attrValue);
}
}
if ($this->removeAttributeHelper($element->tag, $attrName, $attrValue, $attributes, $htmlMin)) {
$element->{$attrName} = null;
continue;
}
// -------------------------------------------------------------------------
// Sort css-class-names, for better gzip results.
// -------------------------------------------------------------------------
if ($htmlMin->isDoSortCssClassNames()) {
$attrValue = $this->sortCssClassNames($attrName, $attrValue);
}
if ($htmlMin->isDoSortHtmlAttributes()) {
$attrs[$attrName] = $attrValue;
$element->{$attrName} = null;
}
}
// -------------------------------------------------------------------------
// Sort html-attributes, for better gzip results.
// -------------------------------------------------------------------------
if ($htmlMin->isDoSortHtmlAttributes()) {
\ksort($attrs);
foreach ($attrs as $attrName => $attrValue) {
$attrValue = HtmlDomParser::replaceToPreserveHtmlEntities($attrValue);
$element->setAttribute($attrName, $attrValue, true);
}
}
} | [
"public",
"function",
"domElementAfterMinification",
"(",
"SimpleHtmlDom",
"$",
"element",
",",
"HtmlMin",
"$",
"htmlMin",
")",
"{",
"$",
"attributes",
"=",
"$",
"element",
"->",
"getAllAttributes",
"(",
")",
";",
"if",
"(",
"$",
"attributes",
"===",
"null",
... | Receive dom elements after the minification.
@param SimpleHtmlDom $element
@param HtmlMin $htmlMin | [
"Receive",
"dom",
"elements",
"after",
"the",
"minification",
"."
] | train | https://github.com/voku/HtmlMin/blob/d3e0c2b62ba1b35bf4ed6f28d9e9f210f53287d3/src/voku/helper/HtmlMinDomObserverOptimizeAttributes.php#L46-L103 |
voku/HtmlMin | src/voku/helper/HtmlMinDomObserverOptimizeAttributes.php | HtmlMinDomObserverOptimizeAttributes.removeAttributeHelper | private function removeAttributeHelper($tag, $attrName, $attrValue, $allAttr, HtmlMin $htmlMin): bool
{
// remove defaults
if ($htmlMin->isDoRemoveDefaultAttributes()) {
if ($tag === 'script' && $attrName === 'language' && $attrValue === 'javascript') {
return true;
}
if ($tag === 'form' && $attrName === 'method' && $attrValue === 'get') {
return true;
}
if ($tag === 'input' && $attrName === 'type' && $attrValue === 'text') {
return true;
}
if ($tag === 'area' && $attrName === 'shape' && $attrValue === 'rect') {
return true;
}
}
// remove deprecated charset-attribute (the browser will use the charset from the HTTP-Header, anyway)
if ($htmlMin->isDoRemoveDeprecatedScriptCharsetAttribute()) {
if ($tag === 'script' && $attrName === 'charset' && !isset($allAttr['src'])) {
return true;
}
}
// remove deprecated anchor-jump
if ($htmlMin->isDoRemoveDeprecatedAnchorName()) {
if ($tag === 'a' && $attrName === 'name' && isset($allAttr['id']) && $allAttr['id'] === $attrValue) {
return true;
}
}
// remove "type=text/css" for css links
if ($htmlMin->isDoRemoveDeprecatedTypeFromStylesheetLink()) {
if ($tag === 'link' && $attrName === 'type' && $attrValue === 'text/css' && isset($allAttr['rel']) && $allAttr['rel'] === 'stylesheet') {
return true;
}
}
// remove deprecated script-mime-types
if ($htmlMin->isDoRemoveDeprecatedTypeFromScriptTag()) {
if ($tag === 'script' && $attrName === 'type' && isset($allAttr['src'], self::$executableScriptsMimeTypes[$attrValue])) {
return true;
}
}
// remove 'value=""' from <input type="text">
if ($htmlMin->isDoRemoveValueFromEmptyInput()) {
if ($tag === 'input' && $attrName === 'value' && $attrValue === '' && isset($allAttr['type']) && $allAttr['type'] === 'text') {
return true;
}
}
// remove some empty attributes
if ($htmlMin->isDoRemoveEmptyAttributes()) {
if (\trim($attrValue) === '' && \preg_match('/^(?:class|id|style|title|lang|dir|on(?:focus|blur|change|click|dblclick|mouse(?:down|up|over|move|out)|key(?:press|down|up)))$/', $attrName)) {
return true;
}
}
return false;
} | php | private function removeAttributeHelper($tag, $attrName, $attrValue, $allAttr, HtmlMin $htmlMin): bool
{
// remove defaults
if ($htmlMin->isDoRemoveDefaultAttributes()) {
if ($tag === 'script' && $attrName === 'language' && $attrValue === 'javascript') {
return true;
}
if ($tag === 'form' && $attrName === 'method' && $attrValue === 'get') {
return true;
}
if ($tag === 'input' && $attrName === 'type' && $attrValue === 'text') {
return true;
}
if ($tag === 'area' && $attrName === 'shape' && $attrValue === 'rect') {
return true;
}
}
// remove deprecated charset-attribute (the browser will use the charset from the HTTP-Header, anyway)
if ($htmlMin->isDoRemoveDeprecatedScriptCharsetAttribute()) {
if ($tag === 'script' && $attrName === 'charset' && !isset($allAttr['src'])) {
return true;
}
}
// remove deprecated anchor-jump
if ($htmlMin->isDoRemoveDeprecatedAnchorName()) {
if ($tag === 'a' && $attrName === 'name' && isset($allAttr['id']) && $allAttr['id'] === $attrValue) {
return true;
}
}
// remove "type=text/css" for css links
if ($htmlMin->isDoRemoveDeprecatedTypeFromStylesheetLink()) {
if ($tag === 'link' && $attrName === 'type' && $attrValue === 'text/css' && isset($allAttr['rel']) && $allAttr['rel'] === 'stylesheet') {
return true;
}
}
// remove deprecated script-mime-types
if ($htmlMin->isDoRemoveDeprecatedTypeFromScriptTag()) {
if ($tag === 'script' && $attrName === 'type' && isset($allAttr['src'], self::$executableScriptsMimeTypes[$attrValue])) {
return true;
}
}
// remove 'value=""' from <input type="text">
if ($htmlMin->isDoRemoveValueFromEmptyInput()) {
if ($tag === 'input' && $attrName === 'value' && $attrValue === '' && isset($allAttr['type']) && $allAttr['type'] === 'text') {
return true;
}
}
// remove some empty attributes
if ($htmlMin->isDoRemoveEmptyAttributes()) {
if (\trim($attrValue) === '' && \preg_match('/^(?:class|id|style|title|lang|dir|on(?:focus|blur|change|click|dblclick|mouse(?:down|up|over|move|out)|key(?:press|down|up)))$/', $attrName)) {
return true;
}
}
return false;
} | [
"private",
"function",
"removeAttributeHelper",
"(",
"$",
"tag",
",",
"$",
"attrName",
",",
"$",
"attrValue",
",",
"$",
"allAttr",
",",
"HtmlMin",
"$",
"htmlMin",
")",
":",
"bool",
"{",
"// remove defaults",
"if",
"(",
"$",
"htmlMin",
"->",
"isDoRemoveDefaul... | Check if the attribute can be removed.
@param string $tag
@param string $attrName
@param string $attrValue
@param array $allAttr
@param HtmlMin $htmlMin
@return bool | [
"Check",
"if",
"the",
"attribute",
"can",
"be",
"removed",
"."
] | train | https://github.com/voku/HtmlMin/blob/d3e0c2b62ba1b35bf4ed6f28d9e9f210f53287d3/src/voku/helper/HtmlMinDomObserverOptimizeAttributes.php#L117-L181 |
voku/HtmlMin | src/voku/helper/HtmlMinDomObserverOptimizeAttributes.php | HtmlMinDomObserverOptimizeAttributes.sortCssClassNames | private function sortCssClassNames($attrName, $attrValue): string
{
if ($attrName !== 'class' || !$attrValue) {
return $attrValue;
}
$classes = \array_unique(
\explode(' ', $attrValue)
);
\sort($classes);
$attrValue = '';
foreach ($classes as $class) {
if (!$class) {
continue;
}
$attrValue .= \trim($class) . ' ';
}
return \trim($attrValue);
} | php | private function sortCssClassNames($attrName, $attrValue): string
{
if ($attrName !== 'class' || !$attrValue) {
return $attrValue;
}
$classes = \array_unique(
\explode(' ', $attrValue)
);
\sort($classes);
$attrValue = '';
foreach ($classes as $class) {
if (!$class) {
continue;
}
$attrValue .= \trim($class) . ' ';
}
return \trim($attrValue);
} | [
"private",
"function",
"sortCssClassNames",
"(",
"$",
"attrName",
",",
"$",
"attrValue",
")",
":",
"string",
"{",
"if",
"(",
"$",
"attrName",
"!==",
"'class'",
"||",
"!",
"$",
"attrValue",
")",
"{",
"return",
"$",
"attrValue",
";",
"}",
"$",
"classes",
... | @param $attrName
@param $attrValue
@return string | [
"@param",
"$attrName",
"@param",
"$attrValue"
] | train | https://github.com/voku/HtmlMin/blob/d3e0c2b62ba1b35bf4ed6f28d9e9f210f53287d3/src/voku/helper/HtmlMinDomObserverOptimizeAttributes.php#L190-L211 |
php-fig/link-util | src/EvolvableLinkProviderTrait.php | EvolvableLinkProviderTrait.withLink | public function withLink(LinkInterface $link)
{
$that = clone($this);
$splosh = spl_object_hash($link);
if (!array_key_exists($splosh, $that->links)) {
$that->links[$splosh] = $link;
}
return $that;
} | php | public function withLink(LinkInterface $link)
{
$that = clone($this);
$splosh = spl_object_hash($link);
if (!array_key_exists($splosh, $that->links)) {
$that->links[$splosh] = $link;
}
return $that;
} | [
"public",
"function",
"withLink",
"(",
"LinkInterface",
"$",
"link",
")",
"{",
"$",
"that",
"=",
"clone",
"(",
"$",
"this",
")",
";",
"$",
"splosh",
"=",
"spl_object_hash",
"(",
"$",
"link",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"sp... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-fig/link-util/blob/1a07821801a148be4add11ab0603e4af55a72fac/src/EvolvableLinkProviderTrait.php#L20-L28 |
php-fig/link-util | src/EvolvableLinkProviderTrait.php | EvolvableLinkProviderTrait.withoutLink | public function withoutLink(LinkInterface $link)
{
$that = clone($this);
$splosh = spl_object_hash($link);
unset($that->links[$splosh]);
return $that;
} | php | public function withoutLink(LinkInterface $link)
{
$that = clone($this);
$splosh = spl_object_hash($link);
unset($that->links[$splosh]);
return $that;
} | [
"public",
"function",
"withoutLink",
"(",
"LinkInterface",
"$",
"link",
")",
"{",
"$",
"that",
"=",
"clone",
"(",
"$",
"this",
")",
";",
"$",
"splosh",
"=",
"spl_object_hash",
"(",
"$",
"link",
")",
";",
"unset",
"(",
"$",
"that",
"->",
"links",
"[",... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-fig/link-util/blob/1a07821801a148be4add11ab0603e4af55a72fac/src/EvolvableLinkProviderTrait.php#L33-L39 |
php-fig/link-util | src/LinkProviderTrait.php | LinkProviderTrait.getLinksByRel | public function getLinksByRel($rel)
{
$filter = function (LinkInterface $link) use ($rel) {
return in_array($rel, $link->getRels());
};
return array_filter($this->links, $filter);
} | php | public function getLinksByRel($rel)
{
$filter = function (LinkInterface $link) use ($rel) {
return in_array($rel, $link->getRels());
};
return array_filter($this->links, $filter);
} | [
"public",
"function",
"getLinksByRel",
"(",
"$",
"rel",
")",
"{",
"$",
"filter",
"=",
"function",
"(",
"LinkInterface",
"$",
"link",
")",
"use",
"(",
"$",
"rel",
")",
"{",
"return",
"in_array",
"(",
"$",
"rel",
",",
"$",
"link",
"->",
"getRels",
"(",... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-fig/link-util/blob/1a07821801a148be4add11ab0603e4af55a72fac/src/LinkProviderTrait.php#L37-L43 |
php-fig/link-util | src/EvolvableLinkTrait.php | EvolvableLinkTrait.withHref | public function withHref($href)
{
/** @var EvolvableLinkInterface $that */
$that = clone($this);
$that->href = $href;
$that->templated = ($this->hrefIsTemplated($href));
return $that;
} | php | public function withHref($href)
{
/** @var EvolvableLinkInterface $that */
$that = clone($this);
$that->href = $href;
$that->templated = ($this->hrefIsTemplated($href));
return $that;
} | [
"public",
"function",
"withHref",
"(",
"$",
"href",
")",
"{",
"/** @var EvolvableLinkInterface $that */",
"$",
"that",
"=",
"clone",
"(",
"$",
"this",
")",
";",
"$",
"that",
"->",
"href",
"=",
"$",
"href",
";",
"$",
"that",
"->",
"templated",
"=",
"(",
... | {@inheritdoc}
@return EvolvableLinkInterface | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/php-fig/link-util/blob/1a07821801a148be4add11ab0603e4af55a72fac/src/EvolvableLinkTrait.php#L22-L31 |
php-fig/link-util | src/EvolvableLinkTrait.php | EvolvableLinkTrait.withAttribute | public function withAttribute($attribute, $value)
{
/** @var EvolvableLinkInterface $that */
$that = clone($this);
$that->attributes[$attribute] = $value;
return $that;
} | php | public function withAttribute($attribute, $value)
{
/** @var EvolvableLinkInterface $that */
$that = clone($this);
$that->attributes[$attribute] = $value;
return $that;
} | [
"public",
"function",
"withAttribute",
"(",
"$",
"attribute",
",",
"$",
"value",
")",
"{",
"/** @var EvolvableLinkInterface $that */",
"$",
"that",
"=",
"clone",
"(",
"$",
"this",
")",
";",
"$",
"that",
"->",
"attributes",
"[",
"$",
"attribute",
"]",
"=",
... | {@inheritdoc}
@return EvolvableLinkInterface | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/php-fig/link-util/blob/1a07821801a148be4add11ab0603e4af55a72fac/src/EvolvableLinkTrait.php#L64-L70 |
marcelxyz/php-XmlDigitalSignature | src/XmlDigitalSignature.php | XmlDigitalSignature.setCryptoAlgorithm | public function setCryptoAlgorithm($algo)
{
if (!array_key_exists($algo, $this->digestSignatureAlgoMapping))
{
trigger_error('The chosen crypto algorithm does not appear to be predefined', E_USER_WARNING);
}
else if (!array_key_exists($this->digestMethod, $this->digestSignatureAlgoMapping[$algo]))
{
trigger_error('The chosen crypto algorithm does not support the chosen digest method', E_USER_WARNING);
}
else
{
$this->cryptoAlgorithm = $algo;
}
return $this;
} | php | public function setCryptoAlgorithm($algo)
{
if (!array_key_exists($algo, $this->digestSignatureAlgoMapping))
{
trigger_error('The chosen crypto algorithm does not appear to be predefined', E_USER_WARNING);
}
else if (!array_key_exists($this->digestMethod, $this->digestSignatureAlgoMapping[$algo]))
{
trigger_error('The chosen crypto algorithm does not support the chosen digest method', E_USER_WARNING);
}
else
{
$this->cryptoAlgorithm = $algo;
}
return $this;
} | [
"public",
"function",
"setCryptoAlgorithm",
"(",
"$",
"algo",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"algo",
",",
"$",
"this",
"->",
"digestSignatureAlgoMapping",
")",
")",
"{",
"trigger_error",
"(",
"'The chosen crypto algorithm does not appear to ... | Sets the cryptography algorithm used to generate the private key.
@param int $algo Algorithm type (class const)
@return XmlDigitalSignature | [
"Sets",
"the",
"cryptography",
"algorithm",
"used",
"to",
"generate",
"the",
"private",
"key",
"."
] | train | https://github.com/marcelxyz/php-XmlDigitalSignature/blob/80a1778d00c318c33ec7e9bb8feeb0f2ca845b5a/src/XmlDigitalSignature.php#L230-L246 |
marcelxyz/php-XmlDigitalSignature | src/XmlDigitalSignature.php | XmlDigitalSignature.setNodeNsPrefix | public function setNodeNsPrefix($prefix)
{
if (is_string($prefix) && strlen($prefix))
{
$this->nodeNsPrefix = rtrim($prefix, ':') . ':';
}
else
{
$this->nodeNsPrefix = '';
}
return $this;
} | php | public function setNodeNsPrefix($prefix)
{
if (is_string($prefix) && strlen($prefix))
{
$this->nodeNsPrefix = rtrim($prefix, ':') . ':';
}
else
{
$this->nodeNsPrefix = '';
}
return $this;
} | [
"public",
"function",
"setNodeNsPrefix",
"(",
"$",
"prefix",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"prefix",
")",
"&&",
"strlen",
"(",
"$",
"prefix",
")",
")",
"{",
"$",
"this",
"->",
"nodeNsPrefix",
"=",
"rtrim",
"(",
"$",
"prefix",
",",
"':'"... | Sets the namespace prefix for each generated node name.
For example, to create an XML tree with node names of
type <foo:element/>, simply pass the value 'foo' to this method.
@param string $prefix The namespace prefix
@return XmlDigitalSignature | [
"Sets",
"the",
"namespace",
"prefix",
"for",
"each",
"generated",
"node",
"name",
".",
"For",
"example",
"to",
"create",
"an",
"XML",
"tree",
"with",
"node",
"names",
"of",
"type",
"<foo",
":",
"element",
"/",
">",
"simply",
"pass",
"the",
"value",
"foo"... | train | https://github.com/marcelxyz/php-XmlDigitalSignature/blob/80a1778d00c318c33ec7e9bb8feeb0f2ca845b5a/src/XmlDigitalSignature.php#L256-L268 |
marcelxyz/php-XmlDigitalSignature | src/XmlDigitalSignature.php | XmlDigitalSignature.setCanonicalMethod | public function setCanonicalMethod($method)
{
if (array_key_exists($method, $this->c14nOptionMapping))
{
$this->canonicalMethod = $method;
}
else
{
trigger_error(sprintf('The chosen canonical method (%s) is not supported', $method), E_USER_WARNING);
}
return $this;
} | php | public function setCanonicalMethod($method)
{
if (array_key_exists($method, $this->c14nOptionMapping))
{
$this->canonicalMethod = $method;
}
else
{
trigger_error(sprintf('The chosen canonical method (%s) is not supported', $method), E_USER_WARNING);
}
return $this;
} | [
"public",
"function",
"setCanonicalMethod",
"(",
"$",
"method",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"method",
",",
"$",
"this",
"->",
"c14nOptionMapping",
")",
")",
"{",
"$",
"this",
"->",
"canonicalMethod",
"=",
"$",
"method",
";",
"}",
"... | Sets the canonical method used to canonicalize the document
@param string $method Canonicalization method (class const)
@return XmlDigitalSignature | [
"Sets",
"the",
"canonical",
"method",
"used",
"to",
"canonicalize",
"the",
"document"
] | train | https://github.com/marcelxyz/php-XmlDigitalSignature/blob/80a1778d00c318c33ec7e9bb8feeb0f2ca845b5a/src/XmlDigitalSignature.php#L287-L299 |
marcelxyz/php-XmlDigitalSignature | src/XmlDigitalSignature.php | XmlDigitalSignature.setDigestMethod | public function setDigestMethod($method)
{
if (array_key_exists($method, $this->openSSLAlgoMapping) &&
array_key_exists($method, $this->digestMethodUriMapping))
{
$this->digestMethod = $method;
}
else
{
trigger_error(sprintf('The chosen digest method (%s) is not supported', $method), E_USER_WARNING);
}
$this->checkDigestSupport();
return $this;
} | php | public function setDigestMethod($method)
{
if (array_key_exists($method, $this->openSSLAlgoMapping) &&
array_key_exists($method, $this->digestMethodUriMapping))
{
$this->digestMethod = $method;
}
else
{
trigger_error(sprintf('The chosen digest method (%s) is not supported', $method), E_USER_WARNING);
}
$this->checkDigestSupport();
return $this;
} | [
"public",
"function",
"setDigestMethod",
"(",
"$",
"method",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"method",
",",
"$",
"this",
"->",
"openSSLAlgoMapping",
")",
"&&",
"array_key_exists",
"(",
"$",
"method",
",",
"$",
"this",
"->",
"digestMethodUr... | Sets the digest method (hashing algo) used to calculate the digest of the document
@param string $method Digest method (class const)
@return XmlDigitalSignature | [
"Sets",
"the",
"digest",
"method",
"(",
"hashing",
"algo",
")",
"used",
"to",
"calculate",
"the",
"digest",
"of",
"the",
"document"
] | train | https://github.com/marcelxyz/php-XmlDigitalSignature/blob/80a1778d00c318c33ec7e9bb8feeb0f2ca845b5a/src/XmlDigitalSignature.php#L307-L322 |
marcelxyz/php-XmlDigitalSignature | src/XmlDigitalSignature.php | XmlDigitalSignature.loadPrivateKey | public function loadPrivateKey($key, $passphrase = null, $isFile = true)
{
return $this->loadKey($key, $isFile, true, $passphrase);
} | php | public function loadPrivateKey($key, $passphrase = null, $isFile = true)
{
return $this->loadKey($key, $isFile, true, $passphrase);
} | [
"public",
"function",
"loadPrivateKey",
"(",
"$",
"key",
",",
"$",
"passphrase",
"=",
"null",
",",
"$",
"isFile",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"loadKey",
"(",
"$",
"key",
",",
"$",
"isFile",
",",
"true",
",",
"$",
"passphrase",... | Loads a PEM formatted private key.
@param string $key The private key in PEM format or a path to the key (see openssl_pkey_get_private)
@param string $passphrase Password to the key file (if there is one)
@param bool $isFile Whether the key is a path to a file
@return bool True if the key was successfully loaded, false otherwise
@throws \UnexpectedValueException Thrown if the key cannot be loaded | [
"Loads",
"a",
"PEM",
"formatted",
"private",
"key",
"."
] | train | https://github.com/marcelxyz/php-XmlDigitalSignature/blob/80a1778d00c318c33ec7e9bb8feeb0f2ca845b5a/src/XmlDigitalSignature.php#L343-L346 |
marcelxyz/php-XmlDigitalSignature | src/XmlDigitalSignature.php | XmlDigitalSignature.loadKey | protected function loadKey($key, $isFile, $isPrivate = false, $passphrase = null)
{
// load the key from the file, if that's what they say
if (true === $isFile)
{
try
{
$key = $this->loadFile($key);
}
catch (\UnexpectedValueException $e)
{
// up, up and away!
throw $e;
}
}
// handle the key based on whether it's public or private
if (true === $isPrivate)
{
$privKey = openssl_pkey_get_private($key, $passphrase);
if (false === $privKey)
{
throw new \UnexpectedValueException('Unable to load the private key');
}
$this->privateKey = $privKey;
}
// good ol' public key
else
{
$pubKey = openssl_pkey_get_public($key);
if (false === $pubKey)
{
throw new \UnexpectedValueException('Unable to load the public key');
}
$this->publicKey = $pubKey;
}
return true;
} | php | protected function loadKey($key, $isFile, $isPrivate = false, $passphrase = null)
{
// load the key from the file, if that's what they say
if (true === $isFile)
{
try
{
$key = $this->loadFile($key);
}
catch (\UnexpectedValueException $e)
{
// up, up and away!
throw $e;
}
}
// handle the key based on whether it's public or private
if (true === $isPrivate)
{
$privKey = openssl_pkey_get_private($key, $passphrase);
if (false === $privKey)
{
throw new \UnexpectedValueException('Unable to load the private key');
}
$this->privateKey = $privKey;
}
// good ol' public key
else
{
$pubKey = openssl_pkey_get_public($key);
if (false === $pubKey)
{
throw new \UnexpectedValueException('Unable to load the public key');
}
$this->publicKey = $pubKey;
}
return true;
} | [
"protected",
"function",
"loadKey",
"(",
"$",
"key",
",",
"$",
"isFile",
",",
"$",
"isPrivate",
"=",
"false",
",",
"$",
"passphrase",
"=",
"null",
")",
"{",
"// load the key from the file, if that's what they say",
"if",
"(",
"true",
"===",
"$",
"isFile",
")",... | Loads a public/private key into memory.
@param string $key Either the path to the key, or the key as a string
@param bool $isFile Whether the first arg is a path that needs to be opened
@param bool $isPrivate Whether the key is private
@param string $passphrase If the key is private and has a passphrase, this is the place to give it
@throws \UnexpectedValueException Thrown if the key cannot be read, or if OpenSSL does not like it
@return bool True if the key is successfully loaded, false otherwise | [
"Loads",
"a",
"public",
"/",
"private",
"key",
"into",
"memory",
"."
] | train | https://github.com/marcelxyz/php-XmlDigitalSignature/blob/80a1778d00c318c33ec7e9bb8feeb0f2ca845b5a/src/XmlDigitalSignature.php#L370-L412 |
marcelxyz/php-XmlDigitalSignature | src/XmlDigitalSignature.php | XmlDigitalSignature.loadFile | protected function loadFile($filePath)
{
if (!file_exists($filePath) || !is_readable($filePath))
{
throw new \UnexpectedValueException(sprintf('Unable to open the "%s" file', $filePath));
}
$key = @file_get_contents($filePath);
if (!is_string($key) || 0 === strlen($key))
{
throw new \UnexpectedValueException(sprintf('File "%s" appears to be empty', $filePath));
}
return $key;
} | php | protected function loadFile($filePath)
{
if (!file_exists($filePath) || !is_readable($filePath))
{
throw new \UnexpectedValueException(sprintf('Unable to open the "%s" file', $filePath));
}
$key = @file_get_contents($filePath);
if (!is_string($key) || 0 === strlen($key))
{
throw new \UnexpectedValueException(sprintf('File "%s" appears to be empty', $filePath));
}
return $key;
} | [
"protected",
"function",
"loadFile",
"(",
"$",
"filePath",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filePath",
")",
"||",
"!",
"is_readable",
"(",
"$",
"filePath",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"sprintf",
... | Loads a key from a specified file location.
@param string $filePath Location of the key to be loaded
@throws \UnexpectedValueException Thrown if the file cannot be loaded or is empty
@return string|bool False on failure, the key as a string otherwise | [
"Loads",
"a",
"key",
"from",
"a",
"specified",
"file",
"location",
"."
] | train | https://github.com/marcelxyz/php-XmlDigitalSignature/blob/80a1778d00c318c33ec7e9bb8feeb0f2ca845b5a/src/XmlDigitalSignature.php#L421-L436 |
marcelxyz/php-XmlDigitalSignature | src/XmlDigitalSignature.php | XmlDigitalSignature.loadPublicXmlKey | public function loadPublicXmlKey($publicKey, $isFile = true, $objectId = null)
{
if (true === $isFile)
{
try
{
$publicKey = $this->loadFile($publicKey);
}
catch (\UnexpectedValueException $e)
{
throw $e;
}
}
$keyNode = null;
// if the key is a string, assume that it's valid XML markup and load it into a dom docuemnt
if (is_string($publicKey) && strlen($publicKey))
{
$keyNode = new \DOMDocument;
if (!@$keyNode->loadXML($publicKey))
{
throw new \UnexpectedValueException('The provided public XML key does not appear to be well structured XML');
}
}
// DOM nodes are sexy as fuck
else if (is_object($publicKey) && $publicKey instanceof DOMDocument)
{
$keyNode = $publicKey;
}
// woops, a bad key was provided :(
else
{
throw new \UnexpectedValueException('Unsupported XML public key provided');
}
// add the key to the DOM
return $this->appendXmlPublicKey($keyNode, $objectId);
} | php | public function loadPublicXmlKey($publicKey, $isFile = true, $objectId = null)
{
if (true === $isFile)
{
try
{
$publicKey = $this->loadFile($publicKey);
}
catch (\UnexpectedValueException $e)
{
throw $e;
}
}
$keyNode = null;
// if the key is a string, assume that it's valid XML markup and load it into a dom docuemnt
if (is_string($publicKey) && strlen($publicKey))
{
$keyNode = new \DOMDocument;
if (!@$keyNode->loadXML($publicKey))
{
throw new \UnexpectedValueException('The provided public XML key does not appear to be well structured XML');
}
}
// DOM nodes are sexy as fuck
else if (is_object($publicKey) && $publicKey instanceof DOMDocument)
{
$keyNode = $publicKey;
}
// woops, a bad key was provided :(
else
{
throw new \UnexpectedValueException('Unsupported XML public key provided');
}
// add the key to the DOM
return $this->appendXmlPublicKey($keyNode, $objectId);
} | [
"public",
"function",
"loadPublicXmlKey",
"(",
"$",
"publicKey",
",",
"$",
"isFile",
"=",
"true",
",",
"$",
"objectId",
"=",
"null",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"isFile",
")",
"{",
"try",
"{",
"$",
"publicKey",
"=",
"$",
"this",
"->",
... | Loads a public key in an XML format.
The first argument provided to this function can be a path to the key (the second arg must be set to true).
Otherwise, you may pass the actual XML string as the first argument (set the second argument to false).
The third argument is needed to create a reference between the created <KeyValue/> element and its <Reference/>.
@param DOMDocument|string $publicKey The DOMDocument containing the key, or a path to the key's location, or the key as a string
@param string $isFile If set to true, the key will be loaded from the given path
@param string $objectId ID attribute of the key (used to create a reference between the key and its <Reference/> node)
@throws \UnexpectedValueException Thrown when the provided key is in an unsupported format
@return bool True if the key was successfully loaded, false otherwise | [
"Loads",
"a",
"public",
"key",
"in",
"an",
"XML",
"format",
"."
] | train | https://github.com/marcelxyz/php-XmlDigitalSignature/blob/80a1778d00c318c33ec7e9bb8feeb0f2ca845b5a/src/XmlDigitalSignature.php#L451-L490 |
marcelxyz/php-XmlDigitalSignature | src/XmlDigitalSignature.php | XmlDigitalSignature.appendXmlPublicKey | protected function appendXmlPublicKey(\DOMDocument $keyDoc, $objectId)
{
// create the document structure if necessary
if (is_null($this->doc))
{
$this->createXmlStructure();
}
// local the node to which the key will be appended
$keyValue = $this->doc->getElementsByTagName($this->nodeNsPrefix . 'KeyValue')->item(0);
if (is_null($keyValue))
{
throw new \UnexpectedValueException('Unabled to locate the KeyValue node');
}
// we have to add the proper namespace prefixes to all of the nodes in the public key DOM
$publicKeyNode = $this->doc->createElement($this->nodeNsPrefix . $keyDoc->firstChild->nodeName);
$keyValue->appendChild($publicKeyNode);
foreach ($keyDoc->firstChild->childNodes as $node)
{
$newNode = $this->doc->createElement($this->nodeNsPrefix . $node->nodeName, $node->nodeValue);
$publicKeyNode->appendChild($newNode);
}
// add the id attribute, if its provided
if (is_string($objectId) && strlen($objectId))
{
$keyValue->parentNode->setAttribute('Id', $objectId);
}
return true;
} | php | protected function appendXmlPublicKey(\DOMDocument $keyDoc, $objectId)
{
// create the document structure if necessary
if (is_null($this->doc))
{
$this->createXmlStructure();
}
// local the node to which the key will be appended
$keyValue = $this->doc->getElementsByTagName($this->nodeNsPrefix . 'KeyValue')->item(0);
if (is_null($keyValue))
{
throw new \UnexpectedValueException('Unabled to locate the KeyValue node');
}
// we have to add the proper namespace prefixes to all of the nodes in the public key DOM
$publicKeyNode = $this->doc->createElement($this->nodeNsPrefix . $keyDoc->firstChild->nodeName);
$keyValue->appendChild($publicKeyNode);
foreach ($keyDoc->firstChild->childNodes as $node)
{
$newNode = $this->doc->createElement($this->nodeNsPrefix . $node->nodeName, $node->nodeValue);
$publicKeyNode->appendChild($newNode);
}
// add the id attribute, if its provided
if (is_string($objectId) && strlen($objectId))
{
$keyValue->parentNode->setAttribute('Id', $objectId);
}
return true;
} | [
"protected",
"function",
"appendXmlPublicKey",
"(",
"\\",
"DOMDocument",
"$",
"keyDoc",
",",
"$",
"objectId",
")",
"{",
"// create the document structure if necessary",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"doc",
")",
")",
"{",
"$",
"this",
"->",
"cre... | Appends the public XML key to the DOM document.
@param \DOMDocument $keyDoc The DOM document containing the public key information
@param string $objectId ID attribute of the key
@throws \UnexpectedValueException If the XML tree is not intact
@return bool True if the key was successfully appended, false otherwise | [
"Appends",
"the",
"public",
"XML",
"key",
"to",
"the",
"DOM",
"document",
"."
] | train | https://github.com/marcelxyz/php-XmlDigitalSignature/blob/80a1778d00c318c33ec7e9bb8feeb0f2ca845b5a/src/XmlDigitalSignature.php#L500-L532 |
marcelxyz/php-XmlDigitalSignature | src/XmlDigitalSignature.php | XmlDigitalSignature.addReference | public function addReference(\DOMNode $node, $uri = null)
{
if (is_null($this->doc))
{
$this->createXmlStructure();
}
// references are appended to the SignedInfo node
$signedInfo = $this->doc->getElementsByTagName($this->nodeNsPrefix . 'SignedInfo')->item(0);
$reference = $this->doc->createElement($this->nodeNsPrefix . 'Reference');
$signedInfo->appendChild($reference);
if (is_string($uri) && strlen($uri))
{
// if the URI is a simple string (i.e. it's an ID that's a reference to an object in the DOM)
// prepend it with a hash
// otherwise (if the uri is URL-like), do nothing
if (!filter_var($uri, FILTER_VALIDATE_URL))
{
$uri = '#' . $uri;
}
$reference->setAttribute('URI', $uri);
}
// specify the digest (hashing) algorithm used
$digestMethod = $this->doc->createElement($this->nodeNsPrefix . 'DigestMethod');
$digestMethod->setAttribute('Algorithm', $this->digestMethodUriMapping[$this->digestMethod]);
$reference->appendChild($digestMethod);
// first we must try to canonicalize the element(s)
try
{
$c14nData = $this->canonicalize($node);
}
catch (\UnexpectedValueException $e)
{
throw $e;
}
// references are stored as digests, so we must do that as well
$referenceDigest = $this->calculateDigest($c14nData);
$digestValue = $this->doc->createElement($this->nodeNsPrefix . 'DigestValue', $referenceDigest);
$reference->appendChild($digestValue);
return true;
} | php | public function addReference(\DOMNode $node, $uri = null)
{
if (is_null($this->doc))
{
$this->createXmlStructure();
}
// references are appended to the SignedInfo node
$signedInfo = $this->doc->getElementsByTagName($this->nodeNsPrefix . 'SignedInfo')->item(0);
$reference = $this->doc->createElement($this->nodeNsPrefix . 'Reference');
$signedInfo->appendChild($reference);
if (is_string($uri) && strlen($uri))
{
// if the URI is a simple string (i.e. it's an ID that's a reference to an object in the DOM)
// prepend it with a hash
// otherwise (if the uri is URL-like), do nothing
if (!filter_var($uri, FILTER_VALIDATE_URL))
{
$uri = '#' . $uri;
}
$reference->setAttribute('URI', $uri);
}
// specify the digest (hashing) algorithm used
$digestMethod = $this->doc->createElement($this->nodeNsPrefix . 'DigestMethod');
$digestMethod->setAttribute('Algorithm', $this->digestMethodUriMapping[$this->digestMethod]);
$reference->appendChild($digestMethod);
// first we must try to canonicalize the element(s)
try
{
$c14nData = $this->canonicalize($node);
}
catch (\UnexpectedValueException $e)
{
throw $e;
}
// references are stored as digests, so we must do that as well
$referenceDigest = $this->calculateDigest($c14nData);
$digestValue = $this->doc->createElement($this->nodeNsPrefix . 'DigestValue', $referenceDigest);
$reference->appendChild($digestValue);
return true;
} | [
"public",
"function",
"addReference",
"(",
"\\",
"DOMNode",
"$",
"node",
",",
"$",
"uri",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"doc",
")",
")",
"{",
"$",
"this",
"->",
"createXmlStructure",
"(",
")",
";",
"}",
"// re... | Appends a reference to the XML document of the provided node,
by canonicalizing it first and then digesting (hashing) it.
The actual digest is appended to the DOM.
@param \DOMNode $node The node that is to be referenced
@param string $uri Reference URI attribute
@return bool | [
"Appends",
"a",
"reference",
"to",
"the",
"XML",
"document",
"of",
"the",
"provided",
"node",
"by",
"canonicalizing",
"it",
"first",
"and",
"then",
"digesting",
"(",
"hashing",
")",
"it",
".",
"The",
"actual",
"digest",
"is",
"appended",
"to",
"the",
"DOM"... | train | https://github.com/marcelxyz/php-XmlDigitalSignature/blob/80a1778d00c318c33ec7e9bb8feeb0f2ca845b5a/src/XmlDigitalSignature.php#L543-L591 |
marcelxyz/php-XmlDigitalSignature | src/XmlDigitalSignature.php | XmlDigitalSignature.sign | public function sign()
{
// the document must be set up
if (is_null($this->doc))
{
return new \UnexpectedValueException('No document structure to sign');
}
// find the SignedInfo element, which is what we will actually sign
$signedInfo = $this->doc->getElementsByTagName($this->nodeNsPrefix . 'SignedInfo')->item(0);
if (is_null($signedInfo))
{
throw new \UnexpectedValueException('Unabled to locate the SignedInfo node');
}
// canonicalize the SignedInfo element for signing
$c14nSignedInfo = $this->canonicalize($signedInfo);
// make sure that we know which OpenSSL algo type to use
if (!array_key_exists($this->digestMethod, $this->openSSLAlgoMapping))
{
throw new \UnexpectedValueException('No OpenSSL algorithm has been defined for digest of type ' . $this->digestMethod);
}
// sign the SignedInfo element using the private key
if (!openssl_sign($c14nSignedInfo, $signature, $this->privateKey, $this->openSSLAlgoMapping[$this->digestMethod]))
{
throw new \UnexpectedValueException('Unable to sign the document. Error: ' . openssl_error_string());
}
$signature = base64_encode($signature);
// find the signature value node, to which we will append the base64 encoded signature
$signatureNode = $this->doc->getElementsByTagName($this->nodeNsPrefix . 'SignatureValue')->item(0);
if (is_null($signatureNode))
{
throw new \UnexpectedValueException('Unabled to locate the SingatureValue node');
}
$signatureNode->appendChild($this->doc->createTextNode($signature));
return true;
} | php | public function sign()
{
// the document must be set up
if (is_null($this->doc))
{
return new \UnexpectedValueException('No document structure to sign');
}
// find the SignedInfo element, which is what we will actually sign
$signedInfo = $this->doc->getElementsByTagName($this->nodeNsPrefix . 'SignedInfo')->item(0);
if (is_null($signedInfo))
{
throw new \UnexpectedValueException('Unabled to locate the SignedInfo node');
}
// canonicalize the SignedInfo element for signing
$c14nSignedInfo = $this->canonicalize($signedInfo);
// make sure that we know which OpenSSL algo type to use
if (!array_key_exists($this->digestMethod, $this->openSSLAlgoMapping))
{
throw new \UnexpectedValueException('No OpenSSL algorithm has been defined for digest of type ' . $this->digestMethod);
}
// sign the SignedInfo element using the private key
if (!openssl_sign($c14nSignedInfo, $signature, $this->privateKey, $this->openSSLAlgoMapping[$this->digestMethod]))
{
throw new \UnexpectedValueException('Unable to sign the document. Error: ' . openssl_error_string());
}
$signature = base64_encode($signature);
// find the signature value node, to which we will append the base64 encoded signature
$signatureNode = $this->doc->getElementsByTagName($this->nodeNsPrefix . 'SignatureValue')->item(0);
if (is_null($signatureNode))
{
throw new \UnexpectedValueException('Unabled to locate the SingatureValue node');
}
$signatureNode->appendChild($this->doc->createTextNode($signature));
return true;
} | [
"public",
"function",
"sign",
"(",
")",
"{",
"// the document must be set up",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"doc",
")",
")",
"{",
"return",
"new",
"\\",
"UnexpectedValueException",
"(",
"'No document structure to sign'",
")",
";",
"}",
"// find ... | Signs the XML document with an XML digital signature
@throws \UnexpectedValueException If the XML tree is not intact or if there is no OpenSSL mapping set
@return bool True if the document was successfully signed, false otherwise | [
"Signs",
"the",
"XML",
"document",
"with",
"an",
"XML",
"digital",
"signature"
] | train | https://github.com/marcelxyz/php-XmlDigitalSignature/blob/80a1778d00c318c33ec7e9bb8feeb0f2ca845b5a/src/XmlDigitalSignature.php#L599-L641 |
marcelxyz/php-XmlDigitalSignature | src/XmlDigitalSignature.php | XmlDigitalSignature.verify | public function verify()
{
if (is_null($this->publicKey))
{
trigger_error('Cannot verify XML digital signature without public key', E_USER_WARNING);
return false;
}
// find the SignedInfo element which was signed
$signedInfo = $this->doc->getElementsByTagName($this->nodeNsPrefix . 'SignedInfo')->item(0);
if (is_null($signedInfo))
{
throw new \UnexpectedValueException('Unable to locate the SignedInfo node');
}
// canonicalize the SignedInfo element for signature checking
$c14nSignedInfo = $this->canonicalize($signedInfo);
// find the signature value to verify
$signatureValue = $this->doc->getElementsByTagName($this->nodeNsPrefix . 'SignatureValue')->item(0);
if (is_null($signatureValue))
{
throw new \UnexpectedValueException('Unable to locate the SignatureValue node');
}
$signature = base64_decode($signatureValue->nodeValue);
return 1 === openssl_verify($c14nSignedInfo, $signature, $this->publicKey, $this->openSSLAlgoMapping[$this->digestMethod]);
} | php | public function verify()
{
if (is_null($this->publicKey))
{
trigger_error('Cannot verify XML digital signature without public key', E_USER_WARNING);
return false;
}
// find the SignedInfo element which was signed
$signedInfo = $this->doc->getElementsByTagName($this->nodeNsPrefix . 'SignedInfo')->item(0);
if (is_null($signedInfo))
{
throw new \UnexpectedValueException('Unable to locate the SignedInfo node');
}
// canonicalize the SignedInfo element for signature checking
$c14nSignedInfo = $this->canonicalize($signedInfo);
// find the signature value to verify
$signatureValue = $this->doc->getElementsByTagName($this->nodeNsPrefix . 'SignatureValue')->item(0);
if (is_null($signatureValue))
{
throw new \UnexpectedValueException('Unable to locate the SignatureValue node');
}
$signature = base64_decode($signatureValue->nodeValue);
return 1 === openssl_verify($c14nSignedInfo, $signature, $this->publicKey, $this->openSSLAlgoMapping[$this->digestMethod]);
} | [
"public",
"function",
"verify",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"publicKey",
")",
")",
"{",
"trigger_error",
"(",
"'Cannot verify XML digital signature without public key'",
",",
"E_USER_WARNING",
")",
";",
"return",
"false",
";",
"}... | Verifies the XML digital signature
@throws \UnexpectedValueException If the XML tree is not intact
@return bool Verification result | [
"Verifies",
"the",
"XML",
"digital",
"signature"
] | train | https://github.com/marcelxyz/php-XmlDigitalSignature/blob/80a1778d00c318c33ec7e9bb8feeb0f2ca845b5a/src/XmlDigitalSignature.php#L649-L677 |
marcelxyz/php-XmlDigitalSignature | src/XmlDigitalSignature.php | XmlDigitalSignature.createXmlStructure | protected function createXmlStructure()
{
$this->doc = new \DOMDocument('1.0', 'UTF-8');
$this->doc->xmlStandalone = $this->standalone;
// Signature node
$signature = $this->doc->createElementNS(self::XML_DSIG_NS, $this->nodeNsPrefix . 'Signature');
$this->doc->appendChild($signature);
// SignedInfo node
$signedInfo = $this->doc->createElement($this->nodeNsPrefix . 'SignedInfo');
$signature->appendChild($signedInfo);
// canonicalization method node
$c14nMethod = $this->doc->createElement($this->nodeNsPrefix . 'CanonicalizationMethod');
$c14nMethod->setAttribute('Algorithm', $this->canonicalMethod);
$signedInfo->appendChild($c14nMethod);
// specify the hash algorithm used
$sigMethod = $this->doc->createElement($this->nodeNsPrefix . 'SignatureMethod');
$sigMethod->setAttribute('Algorithm', $this->chooseSignatureMethod());
$signedInfo->appendChild($sigMethod);
// create the node that will hold the signature
$sigValue = $this->doc->createElement($this->nodeNsPrefix . 'SignatureValue');
$signature->appendChild($sigValue);
// the KeyInfo and KeyValue nodes will contain information about the public key
$keyInfo = $this->doc->createElement($this->nodeNsPrefix . 'KeyInfo');
$signature->appendChild($keyInfo);
$keyValue = $this->doc->createElement($this->nodeNsPrefix . 'KeyValue');
$keyInfo->appendChild($keyValue);
} | php | protected function createXmlStructure()
{
$this->doc = new \DOMDocument('1.0', 'UTF-8');
$this->doc->xmlStandalone = $this->standalone;
// Signature node
$signature = $this->doc->createElementNS(self::XML_DSIG_NS, $this->nodeNsPrefix . 'Signature');
$this->doc->appendChild($signature);
// SignedInfo node
$signedInfo = $this->doc->createElement($this->nodeNsPrefix . 'SignedInfo');
$signature->appendChild($signedInfo);
// canonicalization method node
$c14nMethod = $this->doc->createElement($this->nodeNsPrefix . 'CanonicalizationMethod');
$c14nMethod->setAttribute('Algorithm', $this->canonicalMethod);
$signedInfo->appendChild($c14nMethod);
// specify the hash algorithm used
$sigMethod = $this->doc->createElement($this->nodeNsPrefix . 'SignatureMethod');
$sigMethod->setAttribute('Algorithm', $this->chooseSignatureMethod());
$signedInfo->appendChild($sigMethod);
// create the node that will hold the signature
$sigValue = $this->doc->createElement($this->nodeNsPrefix . 'SignatureValue');
$signature->appendChild($sigValue);
// the KeyInfo and KeyValue nodes will contain information about the public key
$keyInfo = $this->doc->createElement($this->nodeNsPrefix . 'KeyInfo');
$signature->appendChild($keyInfo);
$keyValue = $this->doc->createElement($this->nodeNsPrefix . 'KeyValue');
$keyInfo->appendChild($keyValue);
} | [
"protected",
"function",
"createXmlStructure",
"(",
")",
"{",
"$",
"this",
"->",
"doc",
"=",
"new",
"\\",
"DOMDocument",
"(",
"'1.0'",
",",
"'UTF-8'",
")",
";",
"$",
"this",
"->",
"doc",
"->",
"xmlStandalone",
"=",
"$",
"this",
"->",
"standalone",
";",
... | Prepares the XML skeleton structure for the signature
return void | [
"Prepares",
"the",
"XML",
"skeleton",
"structure",
"for",
"the",
"signature"
] | train | https://github.com/marcelxyz/php-XmlDigitalSignature/blob/80a1778d00c318c33ec7e9bb8feeb0f2ca845b5a/src/XmlDigitalSignature.php#L684-L717 |
marcelxyz/php-XmlDigitalSignature | src/XmlDigitalSignature.php | XmlDigitalSignature.canonicalize | protected function canonicalize(\DOMNode $object)
{
$options = $this->c14nOptionMapping[$this->canonicalMethod];
// canonicalize the provided data with the preset options
$c14nData = $object->C14N($options['exclusive'], $options['withComments']);
if (is_string($c14nData) && strlen($c14nData))
{
return $c14nData;
}
throw new \UnexpectedValueException('Unable to canonicalize the provided DOM document');
} | php | protected function canonicalize(\DOMNode $object)
{
$options = $this->c14nOptionMapping[$this->canonicalMethod];
// canonicalize the provided data with the preset options
$c14nData = $object->C14N($options['exclusive'], $options['withComments']);
if (is_string($c14nData) && strlen($c14nData))
{
return $c14nData;
}
throw new \UnexpectedValueException('Unable to canonicalize the provided DOM document');
} | [
"protected",
"function",
"canonicalize",
"(",
"\\",
"DOMNode",
"$",
"object",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"c14nOptionMapping",
"[",
"$",
"this",
"->",
"canonicalMethod",
"]",
";",
"// canonicalize the provided data with the preset options",
"$"... | Canonicalizes a DOM document or a single DOM node
@param \DOMNode $data Node(s) to be canonicalized
@throws \UnexpectedValueException If the canonicalization process failed
@return string|bool Canonicalized node(s), or false on failure | [
"Canonicalizes",
"a",
"DOM",
"document",
"or",
"a",
"single",
"DOM",
"node"
] | train | https://github.com/marcelxyz/php-XmlDigitalSignature/blob/80a1778d00c318c33ec7e9bb8feeb0f2ca845b5a/src/XmlDigitalSignature.php#L737-L750 |
marcelxyz/php-XmlDigitalSignature | src/XmlDigitalSignature.php | XmlDigitalSignature.addObject | public function addObject($data, $objectId = null, $digestObject = false)
{
if (is_null($this->doc))
{
$this->createXmlStructure();
}
if (is_string($data) && strlen($data))
{
$data = $this->doc->createTextNode($data);
}
else if (!is_object($data) || !$data instanceof \DOMNode)
{
throw new \UnexpectedValueException(sprintf('Digested data must be a non-empty string or DOMNode, %s was given', gettype($data)));
}
// if the object is meant to be digested, do so
if (true === $digestObject)
{
$digestedData = $this->calculateDigest($this->canonicalize($data));
$data = $this->doc->createTextNode($digestedData);
}
else
{
$data = $this->doc->importNode($data, true);
}
// add the object to the dom
$object = $this->doc->createElement($this->nodeNsPrefix . 'Object');
$object->appendChild($data);
$this->doc->getElementsByTagName('Signature')->item(0)->appendchild($object);
// objects must have an id attribute which will
// correspond to the reference URI attribute
if (!is_string($objectId) || !strlen($objectId) || is_numeric($objectId[0]))
{
// generate a random ID
$objectId = rtrim(base64_encode(mt_rand()), '=');
}
// if the ID was provided, add it
$object->setAttribute('Id', $objectId);
// objects also need to be digested and stored as references
// so that they can be signed later
$this->addReference($object, $objectId);
return true;
} | php | public function addObject($data, $objectId = null, $digestObject = false)
{
if (is_null($this->doc))
{
$this->createXmlStructure();
}
if (is_string($data) && strlen($data))
{
$data = $this->doc->createTextNode($data);
}
else if (!is_object($data) || !$data instanceof \DOMNode)
{
throw new \UnexpectedValueException(sprintf('Digested data must be a non-empty string or DOMNode, %s was given', gettype($data)));
}
// if the object is meant to be digested, do so
if (true === $digestObject)
{
$digestedData = $this->calculateDigest($this->canonicalize($data));
$data = $this->doc->createTextNode($digestedData);
}
else
{
$data = $this->doc->importNode($data, true);
}
// add the object to the dom
$object = $this->doc->createElement($this->nodeNsPrefix . 'Object');
$object->appendChild($data);
$this->doc->getElementsByTagName('Signature')->item(0)->appendchild($object);
// objects must have an id attribute which will
// correspond to the reference URI attribute
if (!is_string($objectId) || !strlen($objectId) || is_numeric($objectId[0]))
{
// generate a random ID
$objectId = rtrim(base64_encode(mt_rand()), '=');
}
// if the ID was provided, add it
$object->setAttribute('Id', $objectId);
// objects also need to be digested and stored as references
// so that they can be signed later
$this->addReference($object, $objectId);
return true;
} | [
"public",
"function",
"addObject",
"(",
"$",
"data",
",",
"$",
"objectId",
"=",
"null",
",",
"$",
"digestObject",
"=",
"false",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"doc",
")",
")",
"{",
"$",
"this",
"->",
"createXmlStructure",
"("... | Appends an object to the signed XML documents
@param DOMNode|string $data Data to add to the object node
@param string $objectId ID attribute of the object
@param bool $digestObject Whether the object data should be digested
@throws \UnexpectedValueException If the canonicalization process failed | [
"Appends",
"an",
"object",
"to",
"the",
"signed",
"XML",
"documents"
] | train | https://github.com/marcelxyz/php-XmlDigitalSignature/blob/80a1778d00c318c33ec7e9bb8feeb0f2ca845b5a/src/XmlDigitalSignature.php#L760-L808 |
marcelxyz/php-XmlDigitalSignature | src/XmlDigitalSignature.php | XmlDigitalSignature.calculateDigest | protected function calculateDigest($data)
{
$this->checkDigestSupport();
return base64_encode(hash($this->digestMethod, $data, true));
} | php | protected function calculateDigest($data)
{
$this->checkDigestSupport();
return base64_encode(hash($this->digestMethod, $data, true));
} | [
"protected",
"function",
"calculateDigest",
"(",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"checkDigestSupport",
"(",
")",
";",
"return",
"base64_encode",
"(",
"hash",
"(",
"$",
"this",
"->",
"digestMethod",
",",
"$",
"data",
",",
"true",
")",
")",
";",
... | Calculates the digest (hash) of a given input value, based on the chosen hashing algorithm.
@param string $data Data to the hashed
@return string Digested string encoded in base64 | [
"Calculates",
"the",
"digest",
"(",
"hash",
")",
"of",
"a",
"given",
"input",
"value",
"based",
"on",
"the",
"chosen",
"hashing",
"algorithm",
"."
] | train | https://github.com/marcelxyz/php-XmlDigitalSignature/blob/80a1778d00c318c33ec7e9bb8feeb0f2ca845b5a/src/XmlDigitalSignature.php#L816-L821 |
marcelxyz/php-XmlDigitalSignature | src/XmlDigitalSignature.php | XmlDigitalSignature.checkDigestSupport | protected function checkDigestSupport()
{
// ensure that the selected digest method is supported by the current PHP version
if (!in_array($this->digestMethod, hash_algos()))
{
trigger_error(sprintf('This installation of PHP does not support the %s hashing algorithm', $this->digestMethod), E_USER_ERROR);
}
} | php | protected function checkDigestSupport()
{
// ensure that the selected digest method is supported by the current PHP version
if (!in_array($this->digestMethod, hash_algos()))
{
trigger_error(sprintf('This installation of PHP does not support the %s hashing algorithm', $this->digestMethod), E_USER_ERROR);
}
} | [
"protected",
"function",
"checkDigestSupport",
"(",
")",
"{",
"// ensure that the selected digest method is supported by the current PHP version",
"if",
"(",
"!",
"in_array",
"(",
"$",
"this",
"->",
"digestMethod",
",",
"hash_algos",
"(",
")",
")",
")",
"{",
"trigger_er... | Ensures that the current installation of PHP supports the selected digest method.
If it does not, a fatal error is triggered.
@return void | [
"Ensures",
"that",
"the",
"current",
"installation",
"of",
"PHP",
"supports",
"the",
"selected",
"digest",
"method",
".",
"If",
"it",
"does",
"not",
"a",
"fatal",
"error",
"is",
"triggered",
"."
] | train | https://github.com/marcelxyz/php-XmlDigitalSignature/blob/80a1778d00c318c33ec7e9bb8feeb0f2ca845b5a/src/XmlDigitalSignature.php#L829-L836 |
reportico-web/reportico | src/ReporticoApp.php | ReporticoApp.getInstance | public static function getInstance()
{
if (true === is_null(self::$_instance)) {
self::$_instance = new self();
self::$_instance->variables = [];
self::$_instance->system_errors = [];
self::$_instance->system_debug = [];
self::$_instance->variables["config"] = [];
}
return self::$_instance;
} | php | public static function getInstance()
{
if (true === is_null(self::$_instance)) {
self::$_instance = new self();
self::$_instance->variables = [];
self::$_instance->system_errors = [];
self::$_instance->system_debug = [];
self::$_instance->variables["config"] = [];
}
return self::$_instance;
} | [
"public",
"static",
"function",
"getInstance",
"(",
")",
"{",
"if",
"(",
"true",
"===",
"is_null",
"(",
"self",
"::",
"$",
"_instance",
")",
")",
"{",
"self",
"::",
"$",
"_instance",
"=",
"new",
"self",
"(",
")",
";",
"self",
"::",
"$",
"_instance",
... | Get the instance of the class
@return SingletonClass | [
"Get",
"the",
"instance",
"of",
"the",
"class"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoApp.php#L46-L57 |
reportico-web/reportico | src/ReporticoApp.php | ReporticoApp.getConfigVariable | private function getConfigVariable($var, $default = null)
{
if (preg_match("/^SW_/", $var)) {
$var = strtolower(preg_replace("/SW_/", "", $var));
}
if (isset($this->variables["config"][$var])) {
return $this->variables["config"][$var];
} else {
if (defined("SW_" . strtoupper($var))) {
return constant("SW_" . strtoupper($var));
}
}
return $default;
} | php | private function getConfigVariable($var, $default = null)
{
if (preg_match("/^SW_/", $var)) {
$var = strtolower(preg_replace("/SW_/", "", $var));
}
if (isset($this->variables["config"][$var])) {
return $this->variables["config"][$var];
} else {
if (defined("SW_" . strtoupper($var))) {
return constant("SW_" . strtoupper($var));
}
}
return $default;
} | [
"private",
"function",
"getConfigVariable",
"(",
"$",
"var",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"preg_match",
"(",
"\"/^SW_/\"",
",",
"$",
"var",
")",
")",
"{",
"$",
"var",
"=",
"strtolower",
"(",
"preg_replace",
"(",
"\"/SW_/\"",
"... | Return the value of a config variable
If the config variable doesn't exist, a default value is returned
@param mixed $var Variable name
@param mixed $default Default value
@return mixed Variable value | [
"Return",
"the",
"value",
"of",
"a",
"config",
"variable"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoApp.php#L70-L87 |
reportico-web/reportico | src/ReporticoApp.php | ReporticoApp.isSetConfigVariable | private function isSetConfigVariable($var)
{
if (preg_match("/^SW_/", $var)) {
$var = strtolower(preg_replace("/SW_/", "", $var));
}
if (defined("SW_" . strtoupper($var))) {
return true;
}
if (isset($this->variables["config"][$var])) {
return true;
} else {
return false;
}
} | php | private function isSetConfigVariable($var)
{
if (preg_match("/^SW_/", $var)) {
$var = strtolower(preg_replace("/SW_/", "", $var));
}
if (defined("SW_" . strtoupper($var))) {
return true;
}
if (isset($this->variables["config"][$var])) {
return true;
} else {
return false;
}
} | [
"private",
"function",
"isSetConfigVariable",
"(",
"$",
"var",
")",
"{",
"if",
"(",
"preg_match",
"(",
"\"/^SW_/\"",
",",
"$",
"var",
")",
")",
"{",
"$",
"var",
"=",
"strtolower",
"(",
"preg_replace",
"(",
"\"/SW_/\"",
",",
"\"\"",
",",
"$",
"var",
")"... | Check if a config variable is defined
@param mixed $var Config variable name
@return bool | [
"Check",
"if",
"a",
"config",
"variable",
"is",
"defined"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoApp.php#L96-L110 |
reportico-web/reportico | src/ReporticoApp.php | ReporticoApp.checkForDefaultConfig | public static function checkForDefaultConfig($in_code, $in_val)
{
$out_val = $in_val;
echo "try $in_code, $in_val<BR>";
if (!$in_val) {
$out_val = $in_val;
if (ReporticoApp::isSetConfig($in_code)) {
$out_val = ReporticoApp::getConfig($in_code);
} else if (ReporticoApp::isSetConfig("pdf_" . $in_code)) {
$out_val = ReporticoApp::getConfig("pdf_" . $in_code);
} else if (ReporticoApp::isSetConfig("chart_" . $in_code)) {
$out_val = ReporticoApp::getConfig("chart_" . $in_code);
} else if (ReporticoApp::isSetConfig("DEFAULT_" . $in_code)) {
$out_val = ReporticoApp::getConfig("DEFAULT_" . $in_code);
}
} else
if (substr($in_val, 0, 1) == ReporticoApp::DEFAULT_INDICATOR) {
$out_val = substr($in_val, 1);
if (ReporticoApp::isSetConfig($in_code)) {
$out_val = ReporticoApp::getConfig($in_code);
} else if (ReporticoApp::isSetConfig("pdf_" . $in_code)) {
$out_val = ReporticoApp::getConfig("pdf_" . $in_code);
} else if (ReporticoApp::isSetConfig("chart_" . $in_code)) {
$out_val = ReporticoApp::getConfig("chart_" . $in_code);
} else if (ReporticoApp::isSetConfig("DEFAULT_" . $in_code)) {
$out_val = ReporticoApp::getConfig("DEFAULT_" . $in_code);
}
}
return $out_val;
} | php | public static function checkForDefaultConfig($in_code, $in_val)
{
$out_val = $in_val;
echo "try $in_code, $in_val<BR>";
if (!$in_val) {
$out_val = $in_val;
if (ReporticoApp::isSetConfig($in_code)) {
$out_val = ReporticoApp::getConfig($in_code);
} else if (ReporticoApp::isSetConfig("pdf_" . $in_code)) {
$out_val = ReporticoApp::getConfig("pdf_" . $in_code);
} else if (ReporticoApp::isSetConfig("chart_" . $in_code)) {
$out_val = ReporticoApp::getConfig("chart_" . $in_code);
} else if (ReporticoApp::isSetConfig("DEFAULT_" . $in_code)) {
$out_val = ReporticoApp::getConfig("DEFAULT_" . $in_code);
}
} else
if (substr($in_val, 0, 1) == ReporticoApp::DEFAULT_INDICATOR) {
$out_val = substr($in_val, 1);
if (ReporticoApp::isSetConfig($in_code)) {
$out_val = ReporticoApp::getConfig($in_code);
} else if (ReporticoApp::isSetConfig("pdf_" . $in_code)) {
$out_val = ReporticoApp::getConfig("pdf_" . $in_code);
} else if (ReporticoApp::isSetConfig("chart_" . $in_code)) {
$out_val = ReporticoApp::getConfig("chart_" . $in_code);
} else if (ReporticoApp::isSetConfig("DEFAULT_" . $in_code)) {
$out_val = ReporticoApp::getConfig("DEFAULT_" . $in_code);
}
}
return $out_val;
} | [
"public",
"static",
"function",
"checkForDefaultConfig",
"(",
"$",
"in_code",
",",
"$",
"in_val",
")",
"{",
"$",
"out_val",
"=",
"$",
"in_val",
";",
"echo",
"\"try $in_code, $in_val<BR>\"",
";",
"if",
"(",
"!",
"$",
"in_val",
")",
"{",
"$",
"out_val",
"=",... | error handler function | [
"error",
"handler",
"function"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoApp.php#L281-L312 |
reportico-web/reportico | src/ReporticoApp.php | ReporticoApp.handleDebug | static function handleDebug($dbgstr, $in_level)
{
if ( ReporticoApp::get("debug_mode") >= $in_level )
{
$debug = &self::getSystemDebug();
$debug[] = array (
"dbgstr" => $dbgstr,
"dbgarea" => ReporticoApp::get("code_area")
);
}
} | php | static function handleDebug($dbgstr, $in_level)
{
if ( ReporticoApp::get("debug_mode") >= $in_level )
{
$debug = &self::getSystemDebug();
$debug[] = array (
"dbgstr" => $dbgstr,
"dbgarea" => ReporticoApp::get("code_area")
);
}
} | [
"static",
"function",
"handleDebug",
"(",
"$",
"dbgstr",
",",
"$",
"in_level",
")",
"{",
"if",
"(",
"ReporticoApp",
"::",
"get",
"(",
"\"debug_mode\"",
")",
">=",
"$",
"in_level",
")",
"{",
"$",
"debug",
"=",
"&",
"self",
"::",
"getSystemDebug",
"(",
"... | Debug Message Handler | [
"Debug",
"Message",
"Handler"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoApp.php#L315-L325 |
reportico-web/reportico | src/ReporticoApp.php | ReporticoApp.handleError | static function handleError($errstr, $type = E_USER_ERROR)
{
self::set("errors", true);
trigger_error($errstr, $type);
} | php | static function handleError($errstr, $type = E_USER_ERROR)
{
self::set("errors", true);
trigger_error($errstr, $type);
} | [
"static",
"function",
"handleError",
"(",
"$",
"errstr",
",",
"$",
"type",
"=",
"E_USER_ERROR",
")",
"{",
"self",
"::",
"set",
"(",
"\"errors\"",
",",
"true",
")",
";",
"trigger_error",
"(",
"$",
"errstr",
",",
"$",
"type",
")",
";",
"}"
] | User Error Handler | [
"User",
"Error",
"Handler"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoApp.php#L328-L333 |
reportico-web/reportico | src/ReporticoApp.php | ReporticoApp.ErrorHandler | static function ErrorHandler($errno, $errstr, $errfile, $errline)
{
switch ($errno) {
case E_ERROR:
$errtype = ReporticoLang::translate("Error");
break;
case E_NOTICE:
$errtype = ReporticoLang::translate("Notice");
break;
case E_USER_ERROR:
$errtype = ReporticoLang::translate("Error");
break;
case E_USER_WARNING:
$errtype = ReporticoLang::translate("");
break;
case E_USER_NOTICE:
$errtype = ReporticoLang::translate("");
break;
case E_WARNING:
$errtype = ReporticoLang::translate("");
break;
default:
$errtype = ReporticoLang::translate("Fatal Error");
}
// If request parameter errorsInModal is set then popup first user error
// back to client and exit. This is to popup errors when probles in saving reports
if ( ReporticoUtility::getRequestItem("errorsInModal") && $errno == E_USER_ERROR ) {
header("HTTP/1.0 404 Not Found", true);
echo $errstr;
die;
}
// Avoid adding duplicate errors
$errors = &self::getSystemErrors();
$ct = 0;
foreach ( self::getSystemErrors() as $k => $val) {
if ($val["errstr"] == $errstr) {
$errors[$k]["errct"] = $ct+1;
return;
}
}
$errors[] =
array(
"errno" => $errno,
"errstr" => $errstr,
"errfile" => $errfile,
"errline" => $errline,
"errtype" => $errtype,
"errarea" => self::get("code_area"),
"errsource" => self::get("code_source"),
"errct" => 1,
);
//echo "<PRE>";
//var_dump($errors);
//echo "</PRE>";
self::set("error_status", 1);
} | php | static function ErrorHandler($errno, $errstr, $errfile, $errline)
{
switch ($errno) {
case E_ERROR:
$errtype = ReporticoLang::translate("Error");
break;
case E_NOTICE:
$errtype = ReporticoLang::translate("Notice");
break;
case E_USER_ERROR:
$errtype = ReporticoLang::translate("Error");
break;
case E_USER_WARNING:
$errtype = ReporticoLang::translate("");
break;
case E_USER_NOTICE:
$errtype = ReporticoLang::translate("");
break;
case E_WARNING:
$errtype = ReporticoLang::translate("");
break;
default:
$errtype = ReporticoLang::translate("Fatal Error");
}
// If request parameter errorsInModal is set then popup first user error
// back to client and exit. This is to popup errors when probles in saving reports
if ( ReporticoUtility::getRequestItem("errorsInModal") && $errno == E_USER_ERROR ) {
header("HTTP/1.0 404 Not Found", true);
echo $errstr;
die;
}
// Avoid adding duplicate errors
$errors = &self::getSystemErrors();
$ct = 0;
foreach ( self::getSystemErrors() as $k => $val) {
if ($val["errstr"] == $errstr) {
$errors[$k]["errct"] = $ct+1;
return;
}
}
$errors[] =
array(
"errno" => $errno,
"errstr" => $errstr,
"errfile" => $errfile,
"errline" => $errline,
"errtype" => $errtype,
"errarea" => self::get("code_area"),
"errsource" => self::get("code_source"),
"errct" => 1,
);
//echo "<PRE>";
//var_dump($errors);
//echo "</PRE>";
self::set("error_status", 1);
} | [
"static",
"function",
"ErrorHandler",
"(",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"errfile",
",",
"$",
"errline",
")",
"{",
"switch",
"(",
"$",
"errno",
")",
"{",
"case",
"E_ERROR",
":",
"$",
"errtype",
"=",
"ReporticoLang",
"::",
"translate",
"("... | error handler function | [
"error",
"handler",
"function"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoApp.php#L345-L411 |
reportico-web/reportico | src/XmlReader.php | XmlReader.handleUserEntry | public function handleUserEntry()
{
$sessionClass = ReporticoSession();
// First look for a parameter beginning "submit_". This will identify
// What the user wanted to do.
$hide_area = false;
$show_area = false;
$maintain_sql = false;
$xmlsavefile = false;
$xmldeletefile = false;
if (($k = $this->getMatchingPostItem("/^submit_/"))) {
// Strip off "_submit"
preg_match("/^submit_(.*)/", $k, $match);
// Now we should be left with a field element and an action
// Lets strip the two
$match1 = preg_split('/_/', $match[0]);
$fld = $match1[1];
$action = $match1[2];
switch ($action) {
case "ADD":
// We have chosen to set a block of data so pass through Request set and see which
// fields belong to this set and take appropriate action
$this->addMaintainFields($fld);
$show_area = $fld;
break;
case "DELETE":
// We have chosen to set a block of data so pass through Request set and see which
// fields belong to this set and take appropriate action
$this->deleteMaintainFields($fld);
$show_area = $fld;
break;
case "MOVEUP":
// We have chosen to set a block of data so pass through Request set and see which
// fields belong to this set and take appropriate action
$this->moveupMaintainFields($fld);
$show_area = $fld;
break;
case "MOVEDOWN":
// We have chosen to set a block of data so pass through Request set and see which
// fields belong to this set and take appropriate action
$this->movedownMaintainFields($fld);
$show_area = $fld;
break;
case "SET":
// We have chosen to set a block of data so pass through Request set and see which
// fields belong to this set and take appropriate action
$this->updateMaintainFields($fld);
$show_area = $fld;
break;
case "REPORTLINK":
case "REPORTLINKITEM":
// Link in an item from another report
$this->linkInReportFields("link", $fld, $action);
$show_area = $fld;
break;
case "REPORTIMPORT":
case "REPORTIMPORTITEM":
// Link in an item from another report
$this->linkInReportFields("import", $fld, $action);
$show_area = $fld;
break;
case "SAVE":
$xmlsavefile = $this->query->xmloutfile;
if (!$xmlsavefile) {
trigger_error(ReporticoLang::templateXlate("UNABLE_TO_SAVE") . ReporticoLang::templateXlate("SPECIFYXML"), E_USER_ERROR);
}
break;
case "PREPARESAVE":
$xmlsavefile = $this->query->xmloutfile;
$sessionClass::setReporticoSessionParam("execute_mode", "PREPARE");
if (!$xmlsavefile) {
header("HTTP/1.0 404 Not Found", true);
echo '<div class="reportico-error-box">' . ReporticoLang::templateXlate("UNABLE_TO_SAVE") . ReporticoLang::templateXlate("SPECIFYXML") . "</div>";
die;
}
break;
case "DELETEREPORT":
$xmldeletefile = $this->query->xmloutfile;
break;
case "HIDE":
$hide_area = $fld;
break;
case "SHOW":
$show_area = $fld;
break;
case "SQL":
$show_area = $fld;
if ($fld == "mainquerqury") {
// Main Query SQL Generation.
$sql = stripslashes($_REQUEST["mainquerqury_SQL"]);
$maintain_sql = $sql;
if ($this->query->loginCheck()) {
$p = new SqlParser($sql);
if ($p->parse()) {
$p->importIntoQuery($qr);
if ($this->query->datasource->connect()) {
$p->testQuery($this->query, $sql);
}
}
}
} else {
// It's a lookup
if (preg_match("/mainquercrit(.*)qury/", $fld, $match1)) {
$lookup = (int) $match1[1];
$lookup_char = $match1[1];
// Access the relevant crtieria item ..
$qc = false;
$ak = array_keys($this->query->lookup_queries);
if (array_key_exists($lookup, $ak)) {
$q = $this->query->lookup_queries[$ak[$lookup]]->lookup_query;
} else {
$q = new Reportico();
}
// Parse the entered SQL
$sqlparm = $fld . "_SQL";
$sql = $_REQUEST[$sqlparm];
$q->maintain_sql = $sql;
$q = new Reportico();
$p = new SqlParser($sql);
if ($p->parse()) {
if ($p->testQuery($this->query, $sql)) {
$p->importIntoQuery($q);
$this->query->setCriteriaLookup($ak[$lookup], $q, "WHAT", "NOW");
}
}
}
}
break;
}
}
// Now work out what the maintainance screen should be showing by analysing
// whether user pressed a SHOW button a HIDE button or keeps a maintenance item
// show by presence of a shown value
if (!$show_area) {
// User has not pressed SHOW_ button - this would have been picked up in previous submit
// So look for longest shown item - this will allow us to draw the maintenace screen with
// the correct item maximised
foreach ($_REQUEST as $k => $req) {
if (preg_match("/^shown_(.*)/", $k, $match)) {
$containee = "/^" . $hide_area . "/";
$container = $match[1];
if (!preg_match($containee, $container)) {
if (strlen($match[1]) > strlen($show_area)) {
$show_area = $match[1];
}
}
}
}
}
if (!$show_area) {
$show_area = "mainquer";
}
$xmlout = new XmlWriter($this->query);
$xmlout->prepareXmlData();
// If Save option has been used then write data to the named file and
// use this file as the defalt input for future queries
if ($xmlsavefile) {
if ($this->query->allow_maintain != "SAFE" && $this->query->allow_maintain != "DEMO" && ReporticoApp::getConfig('allow_maintain')) {
$xmlout->writeFile($xmlsavefile);
$sessionClass::setReporticoSessionParam("xmlin", $xmlsavefile);
$sessionClass::unsetReporticoSessionParam("xmlintext");
} else {
trigger_error(ReporticoLang::templateXlate("SAFENOSAVE"), E_USER_ERROR);
}
}
// If Delete Report option has been used then remove the file
// use this file as the defalt input for future queries
if ($xmldeletefile) {
if ($this->query->allow_maintain != "SAFE" && $this->query->allow_maintain != "DEMO" && ReporticoApp::getConfig('allow_maintain')) {
$xmlout->removeFile($xmldeletefile);
$sessionClass::setReporticoSessionParam("xmlin", false);
$sessionClass::unsetReporticoSessionParam("xmlintext");
} else {
trigger_error(ReporticoLang::templateXlate("SAFENODEL"), E_USER_ERROR);
}
}
$xml = $xmlout->getXmldata();
if ($this->query->top_level_query) {
$this->query->xmlintext = $xml;
}
$this->query->xmlin = new XmlReader($this->query, false, $xml);
$this->query->xmlin->show_area = $show_area;
$this->query->maintain_sql = false;
} | php | public function handleUserEntry()
{
$sessionClass = ReporticoSession();
// First look for a parameter beginning "submit_". This will identify
// What the user wanted to do.
$hide_area = false;
$show_area = false;
$maintain_sql = false;
$xmlsavefile = false;
$xmldeletefile = false;
if (($k = $this->getMatchingPostItem("/^submit_/"))) {
// Strip off "_submit"
preg_match("/^submit_(.*)/", $k, $match);
// Now we should be left with a field element and an action
// Lets strip the two
$match1 = preg_split('/_/', $match[0]);
$fld = $match1[1];
$action = $match1[2];
switch ($action) {
case "ADD":
// We have chosen to set a block of data so pass through Request set and see which
// fields belong to this set and take appropriate action
$this->addMaintainFields($fld);
$show_area = $fld;
break;
case "DELETE":
// We have chosen to set a block of data so pass through Request set and see which
// fields belong to this set and take appropriate action
$this->deleteMaintainFields($fld);
$show_area = $fld;
break;
case "MOVEUP":
// We have chosen to set a block of data so pass through Request set and see which
// fields belong to this set and take appropriate action
$this->moveupMaintainFields($fld);
$show_area = $fld;
break;
case "MOVEDOWN":
// We have chosen to set a block of data so pass through Request set and see which
// fields belong to this set and take appropriate action
$this->movedownMaintainFields($fld);
$show_area = $fld;
break;
case "SET":
// We have chosen to set a block of data so pass through Request set and see which
// fields belong to this set and take appropriate action
$this->updateMaintainFields($fld);
$show_area = $fld;
break;
case "REPORTLINK":
case "REPORTLINKITEM":
// Link in an item from another report
$this->linkInReportFields("link", $fld, $action);
$show_area = $fld;
break;
case "REPORTIMPORT":
case "REPORTIMPORTITEM":
// Link in an item from another report
$this->linkInReportFields("import", $fld, $action);
$show_area = $fld;
break;
case "SAVE":
$xmlsavefile = $this->query->xmloutfile;
if (!$xmlsavefile) {
trigger_error(ReporticoLang::templateXlate("UNABLE_TO_SAVE") . ReporticoLang::templateXlate("SPECIFYXML"), E_USER_ERROR);
}
break;
case "PREPARESAVE":
$xmlsavefile = $this->query->xmloutfile;
$sessionClass::setReporticoSessionParam("execute_mode", "PREPARE");
if (!$xmlsavefile) {
header("HTTP/1.0 404 Not Found", true);
echo '<div class="reportico-error-box">' . ReporticoLang::templateXlate("UNABLE_TO_SAVE") . ReporticoLang::templateXlate("SPECIFYXML") . "</div>";
die;
}
break;
case "DELETEREPORT":
$xmldeletefile = $this->query->xmloutfile;
break;
case "HIDE":
$hide_area = $fld;
break;
case "SHOW":
$show_area = $fld;
break;
case "SQL":
$show_area = $fld;
if ($fld == "mainquerqury") {
// Main Query SQL Generation.
$sql = stripslashes($_REQUEST["mainquerqury_SQL"]);
$maintain_sql = $sql;
if ($this->query->loginCheck()) {
$p = new SqlParser($sql);
if ($p->parse()) {
$p->importIntoQuery($qr);
if ($this->query->datasource->connect()) {
$p->testQuery($this->query, $sql);
}
}
}
} else {
// It's a lookup
if (preg_match("/mainquercrit(.*)qury/", $fld, $match1)) {
$lookup = (int) $match1[1];
$lookup_char = $match1[1];
// Access the relevant crtieria item ..
$qc = false;
$ak = array_keys($this->query->lookup_queries);
if (array_key_exists($lookup, $ak)) {
$q = $this->query->lookup_queries[$ak[$lookup]]->lookup_query;
} else {
$q = new Reportico();
}
// Parse the entered SQL
$sqlparm = $fld . "_SQL";
$sql = $_REQUEST[$sqlparm];
$q->maintain_sql = $sql;
$q = new Reportico();
$p = new SqlParser($sql);
if ($p->parse()) {
if ($p->testQuery($this->query, $sql)) {
$p->importIntoQuery($q);
$this->query->setCriteriaLookup($ak[$lookup], $q, "WHAT", "NOW");
}
}
}
}
break;
}
}
// Now work out what the maintainance screen should be showing by analysing
// whether user pressed a SHOW button a HIDE button or keeps a maintenance item
// show by presence of a shown value
if (!$show_area) {
// User has not pressed SHOW_ button - this would have been picked up in previous submit
// So look for longest shown item - this will allow us to draw the maintenace screen with
// the correct item maximised
foreach ($_REQUEST as $k => $req) {
if (preg_match("/^shown_(.*)/", $k, $match)) {
$containee = "/^" . $hide_area . "/";
$container = $match[1];
if (!preg_match($containee, $container)) {
if (strlen($match[1]) > strlen($show_area)) {
$show_area = $match[1];
}
}
}
}
}
if (!$show_area) {
$show_area = "mainquer";
}
$xmlout = new XmlWriter($this->query);
$xmlout->prepareXmlData();
// If Save option has been used then write data to the named file and
// use this file as the defalt input for future queries
if ($xmlsavefile) {
if ($this->query->allow_maintain != "SAFE" && $this->query->allow_maintain != "DEMO" && ReporticoApp::getConfig('allow_maintain')) {
$xmlout->writeFile($xmlsavefile);
$sessionClass::setReporticoSessionParam("xmlin", $xmlsavefile);
$sessionClass::unsetReporticoSessionParam("xmlintext");
} else {
trigger_error(ReporticoLang::templateXlate("SAFENOSAVE"), E_USER_ERROR);
}
}
// If Delete Report option has been used then remove the file
// use this file as the defalt input for future queries
if ($xmldeletefile) {
if ($this->query->allow_maintain != "SAFE" && $this->query->allow_maintain != "DEMO" && ReporticoApp::getConfig('allow_maintain')) {
$xmlout->removeFile($xmldeletefile);
$sessionClass::setReporticoSessionParam("xmlin", false);
$sessionClass::unsetReporticoSessionParam("xmlintext");
} else {
trigger_error(ReporticoLang::templateXlate("SAFENODEL"), E_USER_ERROR);
}
}
$xml = $xmlout->getXmldata();
if ($this->query->top_level_query) {
$this->query->xmlintext = $xml;
}
$this->query->xmlin = new XmlReader($this->query, false, $xml);
$this->query->xmlin->show_area = $show_area;
$this->query->maintain_sql = false;
} | [
"public",
"function",
"handleUserEntry",
"(",
")",
"{",
"$",
"sessionClass",
"=",
"ReporticoSession",
"(",
")",
";",
"// First look for a parameter beginning \"submit_\". This will identify",
"// What the user wanted to do.",
"$",
"hide_area",
"=",
"false",
";",
"$",
"show_... | Processes the HTML get/post paramters passed through on the maintain screen | [
"Processes",
"the",
"HTML",
"get",
"/",
"post",
"paramters",
"passed",
"through",
"on",
"the",
"maintain",
"screen"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/XmlReader.php#L2047-L2266 |
reportico-web/reportico | src/XmlReader.php | XmlReader.& | public function &draw_add_button($in_tag, $in_value = false)
{
$text = "";
$text .= '<TD>';
$text .= '<input class="' . $this->query->getBootstrapStyle('design_ok') . 'reportico-maintain-button reportico-submit" type="submit" name="submit_' . $in_tag . '_ADD" value="' . ReporticoLang::templateXlate("ADD") . '">';
$text .= '</TD>';
// Show Import/Link options
// We allow import and linking to reports for criteria items
// We import only for main query assignments
$importtype = false;
switch ($in_tag) {
case "mainquercrit":$importtype = "LINKANDIMPORT";
break;
case "mainquerassg":$importtype = "IMPORT";
break;
case "mainqueroutppghd":$importtype = "IMPORT";
break;
case "mainqueroutppgft":$importtype = "IMPORT";
break;
default;
$importtype = false;
}
if ($importtype) {
$text .= $this->draw_report_link_panel($importtype, $in_tag, $in_value, $this->query->reportlink_report);
}
return $text;
} | php | public function &draw_add_button($in_tag, $in_value = false)
{
$text = "";
$text .= '<TD>';
$text .= '<input class="' . $this->query->getBootstrapStyle('design_ok') . 'reportico-maintain-button reportico-submit" type="submit" name="submit_' . $in_tag . '_ADD" value="' . ReporticoLang::templateXlate("ADD") . '">';
$text .= '</TD>';
// Show Import/Link options
// We allow import and linking to reports for criteria items
// We import only for main query assignments
$importtype = false;
switch ($in_tag) {
case "mainquercrit":$importtype = "LINKANDIMPORT";
break;
case "mainquerassg":$importtype = "IMPORT";
break;
case "mainqueroutppghd":$importtype = "IMPORT";
break;
case "mainqueroutppgft":$importtype = "IMPORT";
break;
default;
$importtype = false;
}
if ($importtype) {
$text .= $this->draw_report_link_panel($importtype, $in_tag, $in_value, $this->query->reportlink_report);
}
return $text;
} | [
"public",
"function",
"&",
"draw_add_button",
"(",
"$",
"in_tag",
",",
"$",
"in_value",
"=",
"false",
")",
"{",
"$",
"text",
"=",
"\"\"",
";",
"$",
"text",
".=",
"'<TD>'",
";",
"$",
"text",
".=",
"'<input class=\"'",
".",
"$",
"this",
"->",
"query",
... | of the show_area parameter which was derived from the HTTP Request Data | [
"of",
"the",
"show_area",
"parameter",
"which",
"was",
"derived",
"from",
"the",
"HTTP",
"Request",
"Data"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/XmlReader.php#L2270-L2299 |
reportico-web/reportico | src/XmlReader.php | XmlReader.& | public function &draw_report_link_panel($link_or_import, $tag, $label, $preselectedvalue = false)
{
$text = '<TD class="reportico-maintain-set-field" style="text-align: right; color: #eeeeee; background-color: #000000;" colspan="1">';
$type = "TEXTFIELD";
$translateoptions = false;
$striptag = preg_replace("/ .*/", "", $tag);
$showtag = preg_replace("/ /", "_", $tag);
$subtitle = "";
if (preg_match("/ /", $tag)) {
$subtitle = preg_replace("/.* /", " ", $tag);
}
if (array_key_exists($striptag, $this->field_display)) {
$arval = $this->field_display[$striptag];
if (array_key_exists("Title", $arval)) {
$title = $arval["Title"] . $subtitle;
}
if (array_key_exists("Type", $arval)) {
$type = $arval["Type"];
}
if (array_key_exists("XlateOptions", $arval)) {
$translateoptions = $arval["XlateOptions"];
}
if (array_key_exists("EditMode", $arval)) {
$edit_mode = $arval["EditMode"];
}
if (array_key_exists("Values", $arval)) {
$tagvals = $arval["Values"];
}
}
$default = ReporticoApp::getDefaultConfig($striptag, ".");
$helppage = "importlink";
if ($helppage) {
if ($this->query->url_path_to_assets) {
$helpimg = $this->query->url_path_to_assets . "/images/help.png";
$text .= '<a target="_blank" href="' . $this->helpPath($helppage, $striptag) . '">';
$text .= '<img class="reportico-maintain-help-image" alt="tab" src="' . $helpimg . '">';
$text .= '</a> ';
} else {
$helpimg = ReporticoUtility::findBestUrlInIncludePath("images/help.png");
$dr = ReporticoUtility::getReporticoUrlPath();
$text .= '<a target="_blank" href="' . $this->helpPath($helppage, $striptag) . '">';
$text .= '<img class="reportico-maintain-help-image" alt="tab" src="' . $dr . $helpimg . '">';
$text .= '</a> ';
}
}
// Show options options to import or link
$listarr = array();
if ($link_or_import == "IMPORT" || $link_or_import == "LINKANDIMPORT") {
$listarr["import"] = ReporticoLang::templateXlate("IMPORTREPORT");
}
if ($link_or_import == "LINK" || $link_or_import == "LINKANDIMPORT") {
$listarr["linkto"] = ReporticoLang::templateXlate("MAKELINKTOREPORT");
}
$text .= $this->drawArrayDropdown("linkorimport_" . $this->id, $listarr, $this->query->reportlink_or_import, false, false, true);
$text .= '</a> ';
// Draw report names we can link to
$text .= $this->drawSelectFileList($this->query->reports_path, "/.*\.xml/", false, $preselectedvalue, true, false, "reportlink");
$text .= '<input class="' . $this->query->getBootstrapStyle('design_ok') . 'reportico-maintain-button reportico-submit" style="margin-right: 20px" type="submit" name="submit_' . $this->id . '_REPORTLINK" value="' . ReporticoLang::templateXlate("OK") . '">';
if ($this->query->reportlink_report) {
// Draw report criteria items we can link to
$q = ReporticoUtility::loadExistingReport($this->query->reportlink_report, $this->query->projects_folder);
if (!$q) {
trigger_error(ReporticoLang::templateXlate("NOOPENLINK") . $this->query->reportlink_report, E_USER_NOTICE);
} else if (!$q->lookup_queries || count($q->lookup_queries) == 0) {
trigger_error(ReporticoLang::templateXlate("NOCRITLINK") . $this->query->reportlink_report, E_USER_NOTICE);
} else {
if ($link_or_import == "LINK") {
$text .= ReporticoLang::templateXlate("MAKELINKTOREPORTITEM");
} else {
$text .= ReporticoLang::templateXlate("IMPORTREPORT");
}
$text .= " ";
$listarr = array();
$listarr["ALLITEMS"] = ReporticoLang::templateXlate("ALLITEMS");
if ($tag == "mainquercrit") {
$lq = $q->lookup_queries;
foreach ($lq as $k => $v) {
$listarr[$v->query_name] = $v->query_name;
}
} else if ($tag == "mainquerassg") {
$lq = $q->assignment;
foreach ($lq as $k => $v) {
if (strlen($v->expression) > 30) {
$listarr[$k] = $v->query_name . " = " . substr($v->expression, 0, 30) . "...";
} else {
$listarr[$k] = $v->query_name . " = " . $v->expression;
}
}
} else if ($tag == "mainqueroutppghd") {
$lq = $q->pageHeaders;
foreach ($lq as $k => $v) {
if (strlen($v->text) > 30) {
$listarr[$k] = $k . " = " . substr($v->text, 0, 30) . "...";
} else {
$listarr[$k] = $k . " = " . $v->text;
}
}
} else if ($tag == "mainqueroutppgft") {
$lq = $q->pageFooters;
foreach ($lq as $k => $v) {
if (strlen($v->text) > 30) {
$listarr[$k] = $k . " = " . substr($v->text, 0, 30) . "...";
} else {
$listarr[$k] = $k . " = " . $v->text;
}
}
}
$text .= $this->drawArrayDropdown("reportlinkitem_" . $this->id, $listarr, false, false, false, true);
$text .= '<input class="' . $this->query->getBootstrapStyle('design_ok') . 'reportico-maintain-button reportico-submit" style="margin-right: 20px" type="submit" name="submit_' . $this->id . '_REPORTLINKITEM" value="' . ReporticoLang::templateXlate("OK") . '">';
}
}
$text .= '</TD>';
//$text .= '</TR>';
return $text;
} | php | public function &draw_report_link_panel($link_or_import, $tag, $label, $preselectedvalue = false)
{
$text = '<TD class="reportico-maintain-set-field" style="text-align: right; color: #eeeeee; background-color: #000000;" colspan="1">';
$type = "TEXTFIELD";
$translateoptions = false;
$striptag = preg_replace("/ .*/", "", $tag);
$showtag = preg_replace("/ /", "_", $tag);
$subtitle = "";
if (preg_match("/ /", $tag)) {
$subtitle = preg_replace("/.* /", " ", $tag);
}
if (array_key_exists($striptag, $this->field_display)) {
$arval = $this->field_display[$striptag];
if (array_key_exists("Title", $arval)) {
$title = $arval["Title"] . $subtitle;
}
if (array_key_exists("Type", $arval)) {
$type = $arval["Type"];
}
if (array_key_exists("XlateOptions", $arval)) {
$translateoptions = $arval["XlateOptions"];
}
if (array_key_exists("EditMode", $arval)) {
$edit_mode = $arval["EditMode"];
}
if (array_key_exists("Values", $arval)) {
$tagvals = $arval["Values"];
}
}
$default = ReporticoApp::getDefaultConfig($striptag, ".");
$helppage = "importlink";
if ($helppage) {
if ($this->query->url_path_to_assets) {
$helpimg = $this->query->url_path_to_assets . "/images/help.png";
$text .= '<a target="_blank" href="' . $this->helpPath($helppage, $striptag) . '">';
$text .= '<img class="reportico-maintain-help-image" alt="tab" src="' . $helpimg . '">';
$text .= '</a> ';
} else {
$helpimg = ReporticoUtility::findBestUrlInIncludePath("images/help.png");
$dr = ReporticoUtility::getReporticoUrlPath();
$text .= '<a target="_blank" href="' . $this->helpPath($helppage, $striptag) . '">';
$text .= '<img class="reportico-maintain-help-image" alt="tab" src="' . $dr . $helpimg . '">';
$text .= '</a> ';
}
}
// Show options options to import or link
$listarr = array();
if ($link_or_import == "IMPORT" || $link_or_import == "LINKANDIMPORT") {
$listarr["import"] = ReporticoLang::templateXlate("IMPORTREPORT");
}
if ($link_or_import == "LINK" || $link_or_import == "LINKANDIMPORT") {
$listarr["linkto"] = ReporticoLang::templateXlate("MAKELINKTOREPORT");
}
$text .= $this->drawArrayDropdown("linkorimport_" . $this->id, $listarr, $this->query->reportlink_or_import, false, false, true);
$text .= '</a> ';
// Draw report names we can link to
$text .= $this->drawSelectFileList($this->query->reports_path, "/.*\.xml/", false, $preselectedvalue, true, false, "reportlink");
$text .= '<input class="' . $this->query->getBootstrapStyle('design_ok') . 'reportico-maintain-button reportico-submit" style="margin-right: 20px" type="submit" name="submit_' . $this->id . '_REPORTLINK" value="' . ReporticoLang::templateXlate("OK") . '">';
if ($this->query->reportlink_report) {
// Draw report criteria items we can link to
$q = ReporticoUtility::loadExistingReport($this->query->reportlink_report, $this->query->projects_folder);
if (!$q) {
trigger_error(ReporticoLang::templateXlate("NOOPENLINK") . $this->query->reportlink_report, E_USER_NOTICE);
} else if (!$q->lookup_queries || count($q->lookup_queries) == 0) {
trigger_error(ReporticoLang::templateXlate("NOCRITLINK") . $this->query->reportlink_report, E_USER_NOTICE);
} else {
if ($link_or_import == "LINK") {
$text .= ReporticoLang::templateXlate("MAKELINKTOREPORTITEM");
} else {
$text .= ReporticoLang::templateXlate("IMPORTREPORT");
}
$text .= " ";
$listarr = array();
$listarr["ALLITEMS"] = ReporticoLang::templateXlate("ALLITEMS");
if ($tag == "mainquercrit") {
$lq = $q->lookup_queries;
foreach ($lq as $k => $v) {
$listarr[$v->query_name] = $v->query_name;
}
} else if ($tag == "mainquerassg") {
$lq = $q->assignment;
foreach ($lq as $k => $v) {
if (strlen($v->expression) > 30) {
$listarr[$k] = $v->query_name . " = " . substr($v->expression, 0, 30) . "...";
} else {
$listarr[$k] = $v->query_name . " = " . $v->expression;
}
}
} else if ($tag == "mainqueroutppghd") {
$lq = $q->pageHeaders;
foreach ($lq as $k => $v) {
if (strlen($v->text) > 30) {
$listarr[$k] = $k . " = " . substr($v->text, 0, 30) . "...";
} else {
$listarr[$k] = $k . " = " . $v->text;
}
}
} else if ($tag == "mainqueroutppgft") {
$lq = $q->pageFooters;
foreach ($lq as $k => $v) {
if (strlen($v->text) > 30) {
$listarr[$k] = $k . " = " . substr($v->text, 0, 30) . "...";
} else {
$listarr[$k] = $k . " = " . $v->text;
}
}
}
$text .= $this->drawArrayDropdown("reportlinkitem_" . $this->id, $listarr, false, false, false, true);
$text .= '<input class="' . $this->query->getBootstrapStyle('design_ok') . 'reportico-maintain-button reportico-submit" style="margin-right: 20px" type="submit" name="submit_' . $this->id . '_REPORTLINKITEM" value="' . ReporticoLang::templateXlate("OK") . '">';
}
}
$text .= '</TD>';
//$text .= '</TR>';
return $text;
} | [
"public",
"function",
"&",
"draw_report_link_panel",
"(",
"$",
"link_or_import",
",",
"$",
"tag",
",",
"$",
"label",
",",
"$",
"preselectedvalue",
"=",
"false",
")",
"{",
"$",
"text",
"=",
"'<TD class=\"reportico-maintain-set-field\" style=\"text-align: right; color: #e... | and subsequent elements from that report | [
"and",
"subsequent",
"elements",
"from",
"that",
"report"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/XmlReader.php#L2313-L2450 |
reportico-web/reportico | src/XmlReader.php | XmlReader.helpPath | public function helpPath($section, $field = false)
{
$fieldtag = $field;
if (isset($this->field_display["$field"]) && isset($this->field_display["$field"]["DocId"])) {
$fieldtag = $this->field_display["$field"]["DocId"];
}
$path = $this->query->url_doc_site . "/" . $this->query->doc_version . "/" . "doku.php?id=";
if (isset($this->field_display["$field"]) && isset($this->field_display["$field"]["DocSection"])) {
$path .= $this->field_display["$field"]["DocSection"];
} else if ($section) {
$path .= $this->getHelpLink($section);
}
if ($fieldtag) {
$path .= "#$fieldtag";
}
return $path;
} | php | public function helpPath($section, $field = false)
{
$fieldtag = $field;
if (isset($this->field_display["$field"]) && isset($this->field_display["$field"]["DocId"])) {
$fieldtag = $this->field_display["$field"]["DocId"];
}
$path = $this->query->url_doc_site . "/" . $this->query->doc_version . "/" . "doku.php?id=";
if (isset($this->field_display["$field"]) && isset($this->field_display["$field"]["DocSection"])) {
$path .= $this->field_display["$field"]["DocSection"];
} else if ($section) {
$path .= $this->getHelpLink($section);
}
if ($fieldtag) {
$path .= "#$fieldtag";
}
return $path;
} | [
"public",
"function",
"helpPath",
"(",
"$",
"section",
",",
"$",
"field",
"=",
"false",
")",
"{",
"$",
"fieldtag",
"=",
"$",
"field",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"field_display",
"[",
"\"$field\"",
"]",
")",
"&&",
"isset",
"(",
... | Generate link to help for specific field | [
"Generate",
"link",
"to",
"help",
"for",
"specific",
"field"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/XmlReader.php#L2453-L2473 |
reportico-web/reportico | src/XmlReader.php | XmlReader.drawSelectFileList | public function drawSelectFileList($path, $filematch, $showtag, $preselectedvalue, $addblank, $translateoptions, $fieldtype = "set")
{
$keys = array();
$keys[] = "";
if ($showtag) {
$showtag = "_" . $showtag;
}
if (is_dir($this->query->reports_path)) {
$testpath = $this->query->reports_path;
} else {
$testpath = ReporticoUtility::findBestLocationInIncludePath($this->query->reports_path);
}
if (is_dir($testpath)) {
if ($dh = opendir($testpath)) {
while (($file = readdir($dh)) !== false) {
if (preg_match($filematch, $file)) {
$keys[] = $file;
}
}
closedir($dh);
}
} else {
trigger_error(ReporticoLang::templateXlate("NOOPENDIR") . $this->query->reports_path, E_USER_NOTICE);
}
$text = $this->drawArrayDropdown($fieldtype . "_" . $this->id . $showtag, $keys, $preselectedvalue, true, false);
return $text;
} | php | public function drawSelectFileList($path, $filematch, $showtag, $preselectedvalue, $addblank, $translateoptions, $fieldtype = "set")
{
$keys = array();
$keys[] = "";
if ($showtag) {
$showtag = "_" . $showtag;
}
if (is_dir($this->query->reports_path)) {
$testpath = $this->query->reports_path;
} else {
$testpath = ReporticoUtility::findBestLocationInIncludePath($this->query->reports_path);
}
if (is_dir($testpath)) {
if ($dh = opendir($testpath)) {
while (($file = readdir($dh)) !== false) {
if (preg_match($filematch, $file)) {
$keys[] = $file;
}
}
closedir($dh);
}
} else {
trigger_error(ReporticoLang::templateXlate("NOOPENDIR") . $this->query->reports_path, E_USER_NOTICE);
}
$text = $this->drawArrayDropdown($fieldtype . "_" . $this->id . $showtag, $keys, $preselectedvalue, true, false);
return $text;
} | [
"public",
"function",
"drawSelectFileList",
"(",
"$",
"path",
",",
"$",
"filematch",
",",
"$",
"showtag",
",",
"$",
"preselectedvalue",
",",
"$",
"addblank",
",",
"$",
"translateoptions",
",",
"$",
"fieldtype",
"=",
"\"set\"",
")",
"{",
"$",
"keys",
"=",
... | Creates select list box from a directory file list | [
"Creates",
"select",
"list",
"box",
"from",
"a",
"directory",
"file",
"list"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/XmlReader.php#L2476-L2507 |
reportico-web/reportico | src/XmlReader.php | XmlReader.& | public function &draw_select_box($in_tag, $in_array, $in_value = false)
{
$text = "";
$text .= '<select class="' . $this->query->getBootstrapStyle('design_dropdown') . 'reportico-prepare-drop-select" name="execute_mode">';
$text .= '<OPTION selected label="MAINTAIN" value="MAINTAIN">Maintain</OPTION>';
$text .= '<OPTION label="PREPARE" value="PREPARE">Prepare</OPTION>';
$text .= '</SELECT>';
return $text;
} | php | public function &draw_select_box($in_tag, $in_array, $in_value = false)
{
$text = "";
$text .= '<select class="' . $this->query->getBootstrapStyle('design_dropdown') . 'reportico-prepare-drop-select" name="execute_mode">';
$text .= '<OPTION selected label="MAINTAIN" value="MAINTAIN">Maintain</OPTION>';
$text .= '<OPTION label="PREPARE" value="PREPARE">Prepare</OPTION>';
$text .= '</SELECT>';
return $text;
} | [
"public",
"function",
"&",
"draw_select_box",
"(",
"$",
"in_tag",
",",
"$",
"in_array",
",",
"$",
"in_value",
"=",
"false",
")",
"{",
"$",
"text",
"=",
"\"\"",
";",
"$",
"text",
".=",
"'<select class=\"'",
".",
"$",
"this",
"->",
"query",
"->",
"getBoo... | of the show_area parameter which was derived from the HTTP Request Data | [
"of",
"the",
"show_area",
"parameter",
"which",
"was",
"derived",
"from",
"the",
"HTTP",
"Request",
"Data"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/XmlReader.php#L2533-L2541 |
reportico-web/reportico | src/XmlReader.php | XmlReader.& | public function &draw_show_hide_vtab_button($in_tag, $in_value = false,
$in_moveup = false, $in_movedown = false, $in_delete = true) {
$text = "";
if (!$this->isShowing($in_tag)) {
$text .= '<LI class="reportico-maintain-verttab-menu-cell-unsel">';
$text .= '<a class="" name="submit_' . $in_tag . "_SHOW" . '" >';
$text .= '<input class="reportico-maintain-verttab-menu-but-unsel reportico-submit" type="submit" name="submit_' . $in_tag . "_SHOW" . '" value="' . $in_value . '">';
if ($in_delete) {
$text .= $this->draw_delete_button($in_tag);
}
if ($in_moveup) {
$text .= $this->draw_moveup_button($in_tag);
}
if ($in_movedown) {
$text .= $this->draw_movedown_button($in_tag);
}
$text .= '</a>';
$text .= '</LI>';
} else {
$text .= '<LI class="active reportico-maintain-verttab-menu-cell-sel">';
$text .= '<a class="" name="submit_' . $in_tag . "_SHOW" . '" >';
$text .= '<input class="reportico-maintain-verttab-menu-but-sel reportico-submit" type="submit" name="submit_' . $in_tag . "_SHOW" . '" value="' . $in_value . '">';
if ($in_delete) {
$text .= $this->draw_delete_button($in_tag);
}
if ($in_moveup) {
$text .= $this->draw_moveup_button($in_tag);
}
if ($in_movedown) {
$text .= $this->draw_movedown_button($in_tag);
}
$text .= '</a>';
$text .= '</LI>';
}
return $text;
} | php | public function &draw_show_hide_vtab_button($in_tag, $in_value = false,
$in_moveup = false, $in_movedown = false, $in_delete = true) {
$text = "";
if (!$this->isShowing($in_tag)) {
$text .= '<LI class="reportico-maintain-verttab-menu-cell-unsel">';
$text .= '<a class="" name="submit_' . $in_tag . "_SHOW" . '" >';
$text .= '<input class="reportico-maintain-verttab-menu-but-unsel reportico-submit" type="submit" name="submit_' . $in_tag . "_SHOW" . '" value="' . $in_value . '">';
if ($in_delete) {
$text .= $this->draw_delete_button($in_tag);
}
if ($in_moveup) {
$text .= $this->draw_moveup_button($in_tag);
}
if ($in_movedown) {
$text .= $this->draw_movedown_button($in_tag);
}
$text .= '</a>';
$text .= '</LI>';
} else {
$text .= '<LI class="active reportico-maintain-verttab-menu-cell-sel">';
$text .= '<a class="" name="submit_' . $in_tag . "_SHOW" . '" >';
$text .= '<input class="reportico-maintain-verttab-menu-but-sel reportico-submit" type="submit" name="submit_' . $in_tag . "_SHOW" . '" value="' . $in_value . '">';
if ($in_delete) {
$text .= $this->draw_delete_button($in_tag);
}
if ($in_moveup) {
$text .= $this->draw_moveup_button($in_tag);
}
if ($in_movedown) {
$text .= $this->draw_movedown_button($in_tag);
}
$text .= '</a>';
$text .= '</LI>';
}
return $text;
} | [
"public",
"function",
"&",
"draw_show_hide_vtab_button",
"(",
"$",
"in_tag",
",",
"$",
"in_value",
"=",
"false",
",",
"$",
"in_moveup",
"=",
"false",
",",
"$",
"in_movedown",
"=",
"false",
",",
"$",
"in_delete",
"=",
"true",
")",
"{",
"$",
"text",
"=",
... | Draws a tab menu item within a horizontal tab menu | [
"Draws",
"a",
"tab",
"menu",
"item",
"within",
"a",
"horizontal",
"tab",
"menu"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/XmlReader.php#L2544-L2586 |
reportico-web/reportico | src/XmlReader.php | XmlReader.& | public function &draw_show_hide_tab_button($in_tag, $in_value = false)
{
$text = "";
$in_value = ReporticoLang::templateXlate($in_value);
// Only draw horizontal tab buttons if not mini maintain or they are relevant to tag
if ($partialMaintain = ReporticoUtility::getRequestItem("partialMaintain", false)) {
if (preg_match("/_ANY$/", $partialMaintain)) {
$match1 = preg_replace("/_ANY/", "", $partialMaintain);
$match2 = substr($in_tag, 0, strlen($match1));
if ($match1 != $match2 || $match1 == $in_tag ) {
return $text;
}
} else {
return $text;
}
}
if (!$this->isShowing($in_tag)) {
$text .= '<LI class="reportico-maintain-tab-menu-cell-unsel">';
$text .= '<a class="reportico-maintain-tab-menu-bu1t-unsel reportico-submit" name="submit_' . $in_tag . "_SHOW" . '" >';
$text .= '<input class="reportico-maintain-tab-menu-but-unsel reportico-submit" type="submit" name="submit_' . $in_tag . "_SHOW" . '" value="' . $in_value . '">';
$text .= '</a>';
$text .= '</LI>';
} else {
$text .= '<LI class="active reportico-maintain-tab-menu-cell-sel">';
$text .= '<a class="reportico-maintain-tab-menu-bu1t-unsel reportico-submit" name="submit_' . $in_tag . "_SHOW" . '" >';
$text .= '<input class="reportico-maintain-tab-menu-but-sel reportico-submit" type="submit" name="submit_' . $in_tag . "_SHOW" . '" value="' . $in_value . '">';
$text .= '</a>';
$text .= '</LI>';
}
return $text;
} | php | public function &draw_show_hide_tab_button($in_tag, $in_value = false)
{
$text = "";
$in_value = ReporticoLang::templateXlate($in_value);
// Only draw horizontal tab buttons if not mini maintain or they are relevant to tag
if ($partialMaintain = ReporticoUtility::getRequestItem("partialMaintain", false)) {
if (preg_match("/_ANY$/", $partialMaintain)) {
$match1 = preg_replace("/_ANY/", "", $partialMaintain);
$match2 = substr($in_tag, 0, strlen($match1));
if ($match1 != $match2 || $match1 == $in_tag ) {
return $text;
}
} else {
return $text;
}
}
if (!$this->isShowing($in_tag)) {
$text .= '<LI class="reportico-maintain-tab-menu-cell-unsel">';
$text .= '<a class="reportico-maintain-tab-menu-bu1t-unsel reportico-submit" name="submit_' . $in_tag . "_SHOW" . '" >';
$text .= '<input class="reportico-maintain-tab-menu-but-unsel reportico-submit" type="submit" name="submit_' . $in_tag . "_SHOW" . '" value="' . $in_value . '">';
$text .= '</a>';
$text .= '</LI>';
} else {
$text .= '<LI class="active reportico-maintain-tab-menu-cell-sel">';
$text .= '<a class="reportico-maintain-tab-menu-bu1t-unsel reportico-submit" name="submit_' . $in_tag . "_SHOW" . '" >';
$text .= '<input class="reportico-maintain-tab-menu-but-sel reportico-submit" type="submit" name="submit_' . $in_tag . "_SHOW" . '" value="' . $in_value . '">';
$text .= '</a>';
$text .= '</LI>';
}
return $text;
} | [
"public",
"function",
"&",
"draw_show_hide_tab_button",
"(",
"$",
"in_tag",
",",
"$",
"in_value",
"=",
"false",
")",
"{",
"$",
"text",
"=",
"\"\"",
";",
"$",
"in_value",
"=",
"ReporticoLang",
"::",
"templateXlate",
"(",
"$",
"in_value",
")",
";",
"// Only ... | Draws a tab menu item within a horizontal tab menu | [
"Draws",
"a",
"tab",
"menu",
"item",
"within",
"a",
"horizontal",
"tab",
"menu"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/XmlReader.php#L2589-L2625 |
reportico-web/reportico | src/XmlReader.php | XmlReader.& | public function &draw_show_hide_button($in_tag, $in_value = false)
{
$text = "";
if (!$this->isShowing($in_tag)) {
$text .= '<TD>';
//$text .= '<input class="reportico-maintain-tab-menu-but-unsel reportico-submit" type="submit" name="submit_'.$in_tag."_SHOW".'" value="'.$in_value.'">';
$text .= '<input size="1" style="visibility:hidden" class"reportico-submit" type="submit" name="unshown_' . $in_tag . '" value="">';
$text .= '</TD>';
} else {
$text .= '<TD>';
//$text .= '<input class="reportico-maintain-tab-menu-but-sel" type="submit" name="submit_'.$in_tag."_SHOW".'" value="'.$in_value.'">';
$text .= '<input size="1" style="visibility:hidden" class"reportico-submit" type="submit" name="shown_' . $in_tag . '" value="">';
$text .= '</TD>';
}
return $text;
} | php | public function &draw_show_hide_button($in_tag, $in_value = false)
{
$text = "";
if (!$this->isShowing($in_tag)) {
$text .= '<TD>';
//$text .= '<input class="reportico-maintain-tab-menu-but-unsel reportico-submit" type="submit" name="submit_'.$in_tag."_SHOW".'" value="'.$in_value.'">';
$text .= '<input size="1" style="visibility:hidden" class"reportico-submit" type="submit" name="unshown_' . $in_tag . '" value="">';
$text .= '</TD>';
} else {
$text .= '<TD>';
//$text .= '<input class="reportico-maintain-tab-menu-but-sel" type="submit" name="submit_'.$in_tag."_SHOW".'" value="'.$in_value.'">';
$text .= '<input size="1" style="visibility:hidden" class"reportico-submit" type="submit" name="shown_' . $in_tag . '" value="">';
$text .= '</TD>';
}
return $text;
} | [
"public",
"function",
"&",
"draw_show_hide_button",
"(",
"$",
"in_tag",
",",
"$",
"in_value",
"=",
"false",
")",
"{",
"$",
"text",
"=",
"\"\"",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isShowing",
"(",
"$",
"in_tag",
")",
")",
"{",
"$",
"text",
".=... | of the show_area parameter which was derived from the HTTP Request Data | [
"of",
"the",
"show_area",
"parameter",
"which",
"was",
"derived",
"from",
"the",
"HTTP",
"Request",
"Data"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/XmlReader.php#L2629-L2646 |
reportico-web/reportico | src/XmlReader.php | XmlReader.isShowing | public function isShowing($in_tag)
{
$container = $this->show_area;
$containee = $in_tag;
$ret = false;
$match = "/^" . $containee . "/";
if (preg_match($match, $container)) {
$ret = true;
}
$match = "/qcol....form$/";
if (!$ret && preg_match($match, $containee)) {
$ret = true;
}
$match = "/pghd....form$/";
if (!$ret && preg_match($match, $containee)) {
$ret = true;
}
$match = "/pgft....form$/";
if (!$ret && preg_match($match, $containee)) {
$ret = true;
}
$match = "/grph...._/";
if (!$ret && preg_match($match, $containee)) {
$ret = true;
}
return $ret;
} | php | public function isShowing($in_tag)
{
$container = $this->show_area;
$containee = $in_tag;
$ret = false;
$match = "/^" . $containee . "/";
if (preg_match($match, $container)) {
$ret = true;
}
$match = "/qcol....form$/";
if (!$ret && preg_match($match, $containee)) {
$ret = true;
}
$match = "/pghd....form$/";
if (!$ret && preg_match($match, $containee)) {
$ret = true;
}
$match = "/pgft....form$/";
if (!$ret && preg_match($match, $containee)) {
$ret = true;
}
$match = "/grph...._/";
if (!$ret && preg_match($match, $containee)) {
$ret = true;
}
return $ret;
} | [
"public",
"function",
"isShowing",
"(",
"$",
"in_tag",
")",
"{",
"$",
"container",
"=",
"$",
"this",
"->",
"show_area",
";",
"$",
"containee",
"=",
"$",
"in_tag",
";",
"$",
"ret",
"=",
"false",
";",
"$",
"match",
"=",
"\"/^\"",
".",
"$",
"containee",... | id ends in qcolXXXXXform then its true as well | [
"id",
"ends",
"in",
"qcolXXXXXform",
"then",
"its",
"true",
"as",
"well"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/XmlReader.php#L2653-L2684 |
reportico-web/reportico | src/XmlReader.php | XmlReader.isShowingFull | public function isShowingFull($in_tag)
{
$match = "/qcol....$/";
if (preg_match($match, $in_tag)) {
return true;
}
$match = "/qcol....form$/";
if (preg_match($match, $in_tag)) {
return true;
}
$match = "/pghd....form$/";
if (preg_match($match, $in_tag)) {
return true;
}
$match = "/pghd....$/";
if (preg_match($match, $in_tag)) {
return true;
}
$match = "/pgft....form$/";
if (preg_match($match, $in_tag)) {
return true;
}
$match = "/pgft....$/";
if (preg_match($match, $in_tag)) {
return true;
}
$match = "/grps...._/";
if (preg_match($match, $in_tag)) {
return true;
}
if ($in_tag . "detl" == $this->show_area) {
return true;
}
if ($in_tag == $this->show_area) {
return true;
}
return false;
} | php | public function isShowingFull($in_tag)
{
$match = "/qcol....$/";
if (preg_match($match, $in_tag)) {
return true;
}
$match = "/qcol....form$/";
if (preg_match($match, $in_tag)) {
return true;
}
$match = "/pghd....form$/";
if (preg_match($match, $in_tag)) {
return true;
}
$match = "/pghd....$/";
if (preg_match($match, $in_tag)) {
return true;
}
$match = "/pgft....form$/";
if (preg_match($match, $in_tag)) {
return true;
}
$match = "/pgft....$/";
if (preg_match($match, $in_tag)) {
return true;
}
$match = "/grps...._/";
if (preg_match($match, $in_tag)) {
return true;
}
if ($in_tag . "detl" == $this->show_area) {
return true;
}
if ($in_tag == $this->show_area) {
return true;
}
return false;
} | [
"public",
"function",
"isShowingFull",
"(",
"$",
"in_tag",
")",
"{",
"$",
"match",
"=",
"\"/qcol....$/\"",
";",
"if",
"(",
"preg_match",
"(",
"$",
"match",
",",
"$",
"in_tag",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"match",
"=",
"\"/qcol....fo... | of the show_area parameter which was derived from the HTTP Request Data | [
"of",
"the",
"show_area",
"parameter",
"which",
"was",
"derived",
"from",
"the",
"HTTP",
"Request",
"Data"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/XmlReader.php#L2688-L2734 |
reportico-web/reportico | src/XmlReader.php | XmlReader.& | public function &assignment_aggregates($in_parent)
{
$text = "";
$tagct = 1;
$tmpid = $this->id;
$this->id = $in_parent;
$text .= '<TR><TD> </TD></TD>';
$blocktype = "assignTypeImageUrl";
$text .= '<TR><TD class="reportico-maintain-set-field"><a class="reportico-toggle" id="' . $blocktype . '" href="javascript:toggleLine(\'' . $blocktype . '\')">+</a><b>' . ReporticoLang::templateXlate("OUTPUTIMAGE") . '</b></TD></TR>';
$text .= $this->display_maintain_field("AssignImageUrl", false, $tagct, true, false, $blocktype);
$tagct++;
$tagct = 1;
$tmpid = $this->id;
$this->id = $in_parent;
$blocktype = "assignTypeHyper";
$text .= '<TR><TD class="reportico-maintain-set-field"><a class="reportico-toggle" id="' . $blocktype . '" href="javascript:toggleLine(\'' . $blocktype . '\')">+</a><b>' . ReporticoLang::templateXlate("OUTPUTHYPERLINK") . '</b></TD></TR>';
$text .= $this->display_maintain_field("AssignHyperlinkLabel", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignHyperlinkUrl", false, $tagct, true, false, $blocktype);
$tagct++;
$tagct = 1;
$tmpid = $this->id;
$this->id = $in_parent;
$blocktype = "assignTypeStyle";
$text .= '<TR><TD class="reportico-maintain-set-field"><a class="reportico-toggle" id="' . $blocktype . '" href="javascript:toggleLine(\'' . $blocktype . '\')">+</a><b>' . ReporticoLang::templateXlate("OUTPUTSTYLESWIZARD") . '</b></TD></TR>';
$text .= $this->display_maintain_field("AssignStyleLocType", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignStyleFgColor", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignStyleBgColor", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignStyleBorderStyle", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignStyleBorderSize", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignStyleBorderColor", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignStyleMargin", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignStylePadding", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignStyleWidth", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignStyleFontName", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignStyleFontSize", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignStyleFontStyle", false, $tagct, true, false, $blocktype);
$tagct++;
$tagct = 1;
$tmpid = $this->id;
$this->id = $in_parent;
$blocktype = "assignTypeAgg";
$text .= '<TR><TD class="reportico-maintain-set-field"><a class="reportico-toggle" id="' . $blocktype . '" href="javascript:toggleLine(\'' . $blocktype . '\')">+</a><b>' . ReporticoLang::templateXlate("AGGREGATESWIZARD") . '</b></TD></TR>';
$text .= $this->display_maintain_field("AssignAggType", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignAggCol", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignAggGroup", false, $tagct, true, false, $blocktype);
$tagct++;
$tagct = 1;
$blocktype = "assignTypeDbg";
$text .= '<TR><TD class="reportico-maintain-set-field"><a class="reportico-toggle" id="' . $blocktype . '" href="javascript:toggleLine(\'' . $blocktype . '\')">+</a><b>' . ReporticoLang::templateXlate("DATABASEGRAPHICWIZARD") . '</b></TD></TR>';
$text .= $this->display_maintain_field("AssignGraphicBlobCol", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignGraphicBlobTab", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignGraphicBlobMatch", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignGraphicWidth", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignGraphicReportCol", false, $tagct, true, false, $blocktype);
$tagct++;
$tagct = 1;
$blocktype = "assignTypeDrill";
$text .= '<TR><TD> </TD></TD>';
$text .= '<TR><TD class="reportico-maintain-set-field"><a class="reportico-toggle" id="' . $blocktype . '" href="javascript:toggleLine(\'' . $blocktype . '\')">-</a><b>' . ReporticoLang::templateXlate("DRILLDOWNWIZARD") . '</b></TD></TR>';
$text .= $this->display_maintain_field("DrilldownReport", $this->query->drilldown_report, $tagct, true, false, $blocktype, true);
$tagct++;
if ($this->query->drilldown_report) {
$q = new Reportico();
$q->projects_folder = $this->query->projects_folder;
$q->reports_path = $q->projects_folder . "/" . ReporticoApp::getConfig("project");
$reader = new XmlReader($q, $this->query->drilldown_report, false);
$reader->xml2query();
foreach ($q->lookup_queries as $k => $v) {
$text .= $this->display_maintain_field("DrilldownColumn" . " " . $v->query_name, false, $tagct, false, ReporticoLang::templateXlate("DRILLDOWNCOLUMN") . " " . $v->query_name, $blocktype, true);
}
unset($q);
}
$this->id = $tmpid;
return $text;
} | php | public function &assignment_aggregates($in_parent)
{
$text = "";
$tagct = 1;
$tmpid = $this->id;
$this->id = $in_parent;
$text .= '<TR><TD> </TD></TD>';
$blocktype = "assignTypeImageUrl";
$text .= '<TR><TD class="reportico-maintain-set-field"><a class="reportico-toggle" id="' . $blocktype . '" href="javascript:toggleLine(\'' . $blocktype . '\')">+</a><b>' . ReporticoLang::templateXlate("OUTPUTIMAGE") . '</b></TD></TR>';
$text .= $this->display_maintain_field("AssignImageUrl", false, $tagct, true, false, $blocktype);
$tagct++;
$tagct = 1;
$tmpid = $this->id;
$this->id = $in_parent;
$blocktype = "assignTypeHyper";
$text .= '<TR><TD class="reportico-maintain-set-field"><a class="reportico-toggle" id="' . $blocktype . '" href="javascript:toggleLine(\'' . $blocktype . '\')">+</a><b>' . ReporticoLang::templateXlate("OUTPUTHYPERLINK") . '</b></TD></TR>';
$text .= $this->display_maintain_field("AssignHyperlinkLabel", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignHyperlinkUrl", false, $tagct, true, false, $blocktype);
$tagct++;
$tagct = 1;
$tmpid = $this->id;
$this->id = $in_parent;
$blocktype = "assignTypeStyle";
$text .= '<TR><TD class="reportico-maintain-set-field"><a class="reportico-toggle" id="' . $blocktype . '" href="javascript:toggleLine(\'' . $blocktype . '\')">+</a><b>' . ReporticoLang::templateXlate("OUTPUTSTYLESWIZARD") . '</b></TD></TR>';
$text .= $this->display_maintain_field("AssignStyleLocType", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignStyleFgColor", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignStyleBgColor", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignStyleBorderStyle", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignStyleBorderSize", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignStyleBorderColor", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignStyleMargin", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignStylePadding", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignStyleWidth", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignStyleFontName", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignStyleFontSize", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignStyleFontStyle", false, $tagct, true, false, $blocktype);
$tagct++;
$tagct = 1;
$tmpid = $this->id;
$this->id = $in_parent;
$blocktype = "assignTypeAgg";
$text .= '<TR><TD class="reportico-maintain-set-field"><a class="reportico-toggle" id="' . $blocktype . '" href="javascript:toggleLine(\'' . $blocktype . '\')">+</a><b>' . ReporticoLang::templateXlate("AGGREGATESWIZARD") . '</b></TD></TR>';
$text .= $this->display_maintain_field("AssignAggType", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignAggCol", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignAggGroup", false, $tagct, true, false, $blocktype);
$tagct++;
$tagct = 1;
$blocktype = "assignTypeDbg";
$text .= '<TR><TD class="reportico-maintain-set-field"><a class="reportico-toggle" id="' . $blocktype . '" href="javascript:toggleLine(\'' . $blocktype . '\')">+</a><b>' . ReporticoLang::templateXlate("DATABASEGRAPHICWIZARD") . '</b></TD></TR>';
$text .= $this->display_maintain_field("AssignGraphicBlobCol", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignGraphicBlobTab", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignGraphicBlobMatch", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignGraphicWidth", false, $tagct, true, false, $blocktype);
$tagct++;
$text .= $this->display_maintain_field("AssignGraphicReportCol", false, $tagct, true, false, $blocktype);
$tagct++;
$tagct = 1;
$blocktype = "assignTypeDrill";
$text .= '<TR><TD> </TD></TD>';
$text .= '<TR><TD class="reportico-maintain-set-field"><a class="reportico-toggle" id="' . $blocktype . '" href="javascript:toggleLine(\'' . $blocktype . '\')">-</a><b>' . ReporticoLang::templateXlate("DRILLDOWNWIZARD") . '</b></TD></TR>';
$text .= $this->display_maintain_field("DrilldownReport", $this->query->drilldown_report, $tagct, true, false, $blocktype, true);
$tagct++;
if ($this->query->drilldown_report) {
$q = new Reportico();
$q->projects_folder = $this->query->projects_folder;
$q->reports_path = $q->projects_folder . "/" . ReporticoApp::getConfig("project");
$reader = new XmlReader($q, $this->query->drilldown_report, false);
$reader->xml2query();
foreach ($q->lookup_queries as $k => $v) {
$text .= $this->display_maintain_field("DrilldownColumn" . " " . $v->query_name, false, $tagct, false, ReporticoLang::templateXlate("DRILLDOWNCOLUMN") . " " . $v->query_name, $blocktype, true);
}
unset($q);
}
$this->id = $tmpid;
return $text;
} | [
"public",
"function",
"&",
"assignment_aggregates",
"(",
"$",
"in_parent",
")",
"{",
"$",
"text",
"=",
"\"\"",
";",
"$",
"tagct",
"=",
"1",
";",
"$",
"tmpid",
"=",
"$",
"this",
"->",
"id",
";",
"$",
"this",
"->",
"id",
"=",
"$",
"in_parent",
";",
... | /*
function & pdf_styles_wizard($in_parent, $type)
{
$text = "";
$tagct = 1;
$tmpid = $this->id;
$this->id = $in_parent;
$blocktype = "assignTypeStyle";
$text .= '<TR><TD class="reportico-maintain-set-field"><a class="reportico-toggle" id="'.$blocktype.'" href="javascript:toggleLine(\''.$blocktype.'\')">+</a><b>'.ReporticoLang::templateXlate("OUTPUTSTYLESWIZARD").'</b></TD></TR>';
$val = false;
Extract existing styles into wizard elements
$styles = array(
"color" => false,
"background-color" => false,
"border-style" => false,
"border-width" => false,
"border-color" => false,
"margin" => false,
"padding" => false,
"width" => false,
"font-family" => false,
"font-size" => false,
"font-style" => false,
"background-image" => false,
);
if ( $this->wizard_linked_to )
{
if (preg_match("/{STYLE[ ,]*([^}].*)}/", $this->wizard_linked_to , $matches))
{
if ( isset($matches[1]))
{
$stylearr = explode(";",$matches[1]);
foreach ($stylearr as $v )
{
$element = explode(":",$v);
if ( $element && isset($element[1]))
{
$styles[$element[0]] = trim($element[1]);
}
}
}
}
}
if ( $styles["border-style"] )
{
if ( $styles["border-style"] == "noone" ) $styles["border-style"] = "NONE";
if ( $styles["border-style"] == "solid" ) $styles["border-style"] = "SOLIDLINE";
if ( $styles["border-style"] == "dotted" ) $styles["border-style"] = "DOTTED";
if ( $styles["border-style"] == "dashed" ) $styles["border-style"] = "DASHED";
}
if ( $styles["font-style"] )
{
if ( $styles["font-style"] == "noone" ) $styles["border-style"] = "NONE";
}
$text .= $this->display_maintain_field("${type}StyleFgColor", $styles["color"], $tagct, true, false, $blocktype); $tagct++;
$text .= $this->display_maintain_field("${type}StyleBgColor", $styles["background-color"], $tagct, true, false, $blocktype); $tagct++;
$text .= $this->display_maintain_field("${type}StyleBorderStyle", $styles["border-style"], $tagct, true, false, $blocktype); $tagct++;
$text .= $this->display_maintain_field("${type}StyleBorderSize", $styles["border-width"], $tagct, true, false, $blocktype); $tagct++;
$text .= $this->display_maintain_field("${type}StyleBorderColor", $styles["border-color"], $tagct, true, false, $blocktype); $tagct++;
$text .= $this->display_maintain_field("${type}StyleMargin", $styles["margin"], $tagct, true, false, $blocktype); $tagct++;
$text .= $this->display_maintain_field("${type}StylePadding", $styles["padding"], $tagct, true, false, $blocktype); $tagct++;
$text .= $this->display_maintain_field("${type}StyleWidth", $styles["width"], $tagct, true, false, $blocktype); $tagct++;
$text .= $this->display_maintain_field("${type}StyleFontName", $styles["font-family"], $tagct, true, false, $blocktype); $tagct++;
$text .= $this->display_maintain_field("${type}StyleFontSize", $styles["font-size"], $tagct, true, false, $blocktype); $tagct++;
$text .= $this->display_maintain_field("${type}StyleFontStyle", $styles["font-style"], $tagct, true, false, $blocktype); $tagct++;
if ( $type == "PageHeader" || $type == "PageFooter" || $type == "GroupHeader" || $type == "GroupTrailer" )
{
$text .= $this->display_maintain_field("${type}StyleBackgroundImage", $styles["background-image"], $tagct, true, false, $blocktype); $tagct++;
}
$tagct = 1;
$blocktype = "assignTypeDbg";
$text .= '<TR><TD class="reportico-maintain-set-field"><a class="reportico-toggle" id="'.$blocktype.'" href="javascript:toggleLine(\''.$blocktype.'\')">+</a><b>'.ReporticoLang::templateXlate("DATABASEGRAPHICWIZARD").'</b></TD></TR>';
$text .= $this->display_maintain_field("AssignGraphicBlobCol", false, $tagct, true, false, $blocktype); $tagct++;
$text .= $this->display_maintain_field("AssignGraphicBlobTab", false, $tagct, true, false, $blocktype); $tagct++;
$text .= $this->display_maintain_field("AssignGraphicBlobMatch", false, $tagct, true, false, $blocktype); $tagct++;
$text .= $this->display_maintain_field("AssignGraphicWidth", false, $tagct, true, false, $blocktype); $tagct++;
$text .= $this->display_maintain_field("AssignGraphicReportCol", false, $tagct, true, false, $blocktype); $tagct++;
$this->id = $tmpid;
return $text;
} | [
"/",
"*",
"function",
"&",
"pdf_styles_wizard",
"(",
"$in_parent",
"$type",
")",
"{",
"$text",
"=",
";"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/XmlReader.php#L4492-L4594 |
reportico-web/reportico | src/XmlReader.php | XmlReader.& | public function &panel_key_to_html_row($id, &$ar, $labtext, $labindex)
{
$text = "";
$text .= '<TR>';
foreach ($ar as $key => $val) {
$text .= '<TD>';
$padstring = $id . str_pad($key, 4, "0", STR_PAD_LEFT);
if ($labindex == "_key") {
$text .= $this->draw_show_hide_button($padstring, $labtext . " " . $key);
} else {
$text .= $this->draw_show_hide_button($padstring, $labtext . " " . $val[$labindex]);
}
$text .= $this->draw_delete_button($padstring);
$text .= '</TD>';
}
$text .= '</TR>';
return $text;
} | php | public function &panel_key_to_html_row($id, &$ar, $labtext, $labindex)
{
$text = "";
$text .= '<TR>';
foreach ($ar as $key => $val) {
$text .= '<TD>';
$padstring = $id . str_pad($key, 4, "0", STR_PAD_LEFT);
if ($labindex == "_key") {
$text .= $this->draw_show_hide_button($padstring, $labtext . " " . $key);
} else {
$text .= $this->draw_show_hide_button($padstring, $labtext . " " . $val[$labindex]);
}
$text .= $this->draw_delete_button($padstring);
$text .= '</TD>';
}
$text .= '</TR>';
return $text;
} | [
"public",
"function",
"&",
"panel_key_to_html_row",
"(",
"$",
"id",
",",
"&",
"$",
"ar",
",",
"$",
"labtext",
",",
"$",
"labindex",
")",
"{",
"$",
"text",
"=",
"\"\"",
";",
"$",
"text",
".=",
"'<TR>'",
";",
"foreach",
"(",
"$",
"ar",
"as",
"$",
"... | Functon: panel_key_to_html_row
Generates a horizontal menu of buttons for a set of panel items
E.g. draws Format..Query Details..Assignments etc | [
"Functon",
":",
"panel_key_to_html_row"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/XmlReader.php#L4603-L4623 |
reportico-web/reportico | src/XmlReader.php | XmlReader.& | public function &panel_key_to_html($id, &$ar, $paneltype, $labindex,
$draw_move_buttons = false, $draw_delete_button = true) {
$text = "";
$text .= '<TD valign="top" class="reportico-maintain-mid-section">';
$text .= '<DIV class="side-nav-container affix-top">';
$text .= '<UL class="' . $this->query->getBootstrapStyle('vtabs') . 'reportico-maintain-mid-sectionTable">';
$defaulttext = ReporticoLang::templateXlate($paneltype);
$ct = 0;
foreach ($ar as $key => $val) {
$drawup = false;
$drawdown = false;
if ($draw_move_buttons) {
if ($ct > 0) {
$drawup = true;
}
if ($ct < count($ar) - 1) {
$drawdown = true;
}
}
$padstring = $id . str_pad($key, 4, "0", STR_PAD_LEFT);
// Choose button label to reflect a numeric or named element
if ($labindex == "_key") {
$labtext = $defaulttext . " " . $key;
} else {
$labtext = $defaulttext . " " . $val[$labindex];
}
// For assignments the button can be a column assignment or a style assignment .. choose the appropriate
// label
if ($paneltype == "ASSIGNMENT") {
if (preg_match("/applyStyle *\([ \"']*CELL/", $val["Expression"])) {
$labtext = ReporticoLang::templateXlate("CELLSTYLE") . " " . $val[$labindex];
} else if (preg_match("/applyStyle *\([ \"']*ROW/", $val["Expression"])) {
$labtext = ReporticoLang::templateXlate("ROWSTYLE");
} else if (preg_match("/applyStyle *\([ \"']*PAGE/", $val["Expression"])) {
$labtext = ReporticoLang::templateXlate("PAGESTYLE");
} else if (preg_match("/applyStyle *\([ \"']*BODY/", $val["Expression"])) {
$labtext = ReporticoLang::templateXlate("REPORTBODYSTYLE");
} else if (preg_match("/applyStyle *\([ \"']*ALLCELLS/", $val["Expression"])) {
$labtext = ReporticoLang::templateXlate("ALLCELLSSTYLE");
} else if (preg_match("/applyStyle *\([ \"']*COLUMNHEADERS/", $val["Expression"])) {
$labtext = ReporticoLang::templateXlate("COLUMNHEADERSTYLE");
} else if (preg_match("/applyStyle *\([ \"']*GROUPHEADERLABEL/", $val["Expression"])) {
$labtext = ReporticoLang::templateXlate("GRPHEADERLABELSTYLE");
} else if (preg_match("/applyStyle *\([ \"']*GROUPHEADERVALUE/", $val["Expression"])) {
$labtext = ReporticoLang::templateXlate("GRPHEADERVALUESTYLE");
} else if (preg_match("/applyStyle *\([ \"']*GROUPTRAILER/", $val["Expression"])) {
$labtext = ReporticoLang::templateXlate("GROUPTRAILERSTYLE");
}
}
$text .= $this->draw_show_hide_vtab_button($padstring, $labtext, $drawup, $drawdown, $draw_delete_button);
$ct++;
}
//$text .= '<TR><TD> </TD></TR>';
$text .= '</UL>';
$text .= '</DIV>';
$text .= '</TD>';
return $text;
} | php | public function &panel_key_to_html($id, &$ar, $paneltype, $labindex,
$draw_move_buttons = false, $draw_delete_button = true) {
$text = "";
$text .= '<TD valign="top" class="reportico-maintain-mid-section">';
$text .= '<DIV class="side-nav-container affix-top">';
$text .= '<UL class="' . $this->query->getBootstrapStyle('vtabs') . 'reportico-maintain-mid-sectionTable">';
$defaulttext = ReporticoLang::templateXlate($paneltype);
$ct = 0;
foreach ($ar as $key => $val) {
$drawup = false;
$drawdown = false;
if ($draw_move_buttons) {
if ($ct > 0) {
$drawup = true;
}
if ($ct < count($ar) - 1) {
$drawdown = true;
}
}
$padstring = $id . str_pad($key, 4, "0", STR_PAD_LEFT);
// Choose button label to reflect a numeric or named element
if ($labindex == "_key") {
$labtext = $defaulttext . " " . $key;
} else {
$labtext = $defaulttext . " " . $val[$labindex];
}
// For assignments the button can be a column assignment or a style assignment .. choose the appropriate
// label
if ($paneltype == "ASSIGNMENT") {
if (preg_match("/applyStyle *\([ \"']*CELL/", $val["Expression"])) {
$labtext = ReporticoLang::templateXlate("CELLSTYLE") . " " . $val[$labindex];
} else if (preg_match("/applyStyle *\([ \"']*ROW/", $val["Expression"])) {
$labtext = ReporticoLang::templateXlate("ROWSTYLE");
} else if (preg_match("/applyStyle *\([ \"']*PAGE/", $val["Expression"])) {
$labtext = ReporticoLang::templateXlate("PAGESTYLE");
} else if (preg_match("/applyStyle *\([ \"']*BODY/", $val["Expression"])) {
$labtext = ReporticoLang::templateXlate("REPORTBODYSTYLE");
} else if (preg_match("/applyStyle *\([ \"']*ALLCELLS/", $val["Expression"])) {
$labtext = ReporticoLang::templateXlate("ALLCELLSSTYLE");
} else if (preg_match("/applyStyle *\([ \"']*COLUMNHEADERS/", $val["Expression"])) {
$labtext = ReporticoLang::templateXlate("COLUMNHEADERSTYLE");
} else if (preg_match("/applyStyle *\([ \"']*GROUPHEADERLABEL/", $val["Expression"])) {
$labtext = ReporticoLang::templateXlate("GRPHEADERLABELSTYLE");
} else if (preg_match("/applyStyle *\([ \"']*GROUPHEADERVALUE/", $val["Expression"])) {
$labtext = ReporticoLang::templateXlate("GRPHEADERVALUESTYLE");
} else if (preg_match("/applyStyle *\([ \"']*GROUPTRAILER/", $val["Expression"])) {
$labtext = ReporticoLang::templateXlate("GROUPTRAILERSTYLE");
}
}
$text .= $this->draw_show_hide_vtab_button($padstring, $labtext, $drawup, $drawdown, $draw_delete_button);
$ct++;
}
//$text .= '<TR><TD> </TD></TR>';
$text .= '</UL>';
$text .= '</DIV>';
$text .= '</TD>';
return $text;
} | [
"public",
"function",
"&",
"panel_key_to_html",
"(",
"$",
"id",
",",
"&",
"$",
"ar",
",",
"$",
"paneltype",
",",
"$",
"labindex",
",",
"$",
"draw_move_buttons",
"=",
"false",
",",
"$",
"draw_delete_button",
"=",
"true",
")",
"{",
"$",
"text",
"=",
"\"\... | Functon: panel_key_to_html
Generates a vertical menu of buttons for a set of panel items
E.g. draws assignment and criteria buttons in left hand panel | [
"Functon",
":",
"panel_key_to_html"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/XmlReader.php#L4632-L4698 |
reportico-web/reportico | src/XmlReader.php | XmlReader.xml2query | public function xml2query()
{
if (array_key_exists("CogModule", $this->data)) {
$q = &$this->data["CogModule"];
} else {
$q = &$this->data["Report"];
}
$criteria_links = array();
// Generate Output Information...
$ds = false;
if (!$q) {
return;
}
foreach ($q as $cogquery) {
// Set Query Attributes
foreach ($cogquery["Format"] as $att => $val) {
$this->query->setAttribute($att, $val);
}
// Set DataSource
if (isset($cogquery["Datasource"])) {
foreach ($cogquery["Datasource"] as $att => $val) {
//if ( $att == "SourceType" )
//$this->query->source_type = $val;
if ($att == "SourceConnection") {
// No longer relevant - connections are not supplied in xml files
}
}
}
// Set Query Columns
if (!($ef = &$this->getArrayElement($cogquery, "EntryForm"))) {
$this->ErrorMsg = "No EntryForm tag within Format";
return false;
}
if (!($qu = &$this->getArrayElement($ef, "Query"))) {
$this->ErrorMsg = "No Query tag within EntryForm";
return false;
}
$this->query->table_text = $this->getArrayElement($qu, "TableSql");
$this->query->where_text = $this->getArrayElement($qu, "WhereSql");
$this->query->group_text = $this->getArrayElement($qu, "GroupSql");
$this->query->rowselection = $this->getArrayElement($qu, "RowSelection");
$has_cols = true;
if (($qc = &$this->getArrayElement($qu, "SQL"))) {
$this->query->sql_raw = $this->getArrayElement($qc, "SQLRaw");
}
if (!($qc = &$this->getArrayElement($qu, "QueryColumns"))) {
$this->ErrorMsg = "No QueryColumns tag within Query";
$has_cols = false;
}
// Generate QueryColumn for each column found
if ($has_cols) {
foreach ($qc as $col) {
$in_query = true;
if (!$col["ColumnName"]) {
$in_query = false;
}
$this->query->createCriteriaColumn
(
$col["Name"],
$col["TableName"],
$col["ColumnName"],
$col["ColumnType"],
$col["ColumnLength"],
"###.##",
$in_query
);
// Set any Attributes
if (($fm = &$this->getArrayElement($col, "Format"))) {
foreach ($fm as $att => $val) {
$this->query->setColumnAttribute($col["Name"], $att, $val);
}
}
}
// Generate Order By List
if (($oc = &$this->getArrayElement($qu, "OrderColumns"))) {
// Generate QueryColumn for each column found
foreach ($oc as $col) {
if (!$col["Name"]) {
return;
}
$this->query->createQueryColumn
(
$col["Name"],
$col["OrderType"]
);
}
}
// Generate Query Assignments
if (($as = &$this->getArrayElement($ef, "Assignments"))) {
foreach ($as as $col) {
if (array_key_exists("AssignName", $col)) {
$this->query->addAssignment($col["AssignName"], $col["Expression"], $col["Condition"]);
} else {
$this->query->addAssignment($col["Name"], $col["Expression"], $col["Condition"]);
}
}
}
}
// Generate Query Assignments
if (($pq = &$this->getArrayElement($qu, "PreSQLS"))) {
foreach ($pq as $col) {
$this->query->addPreSql($col["SQLText"]);
}
}
// Generate Output Information...
if (($op = &$this->getArrayElement($ef, "Output"))) {
// Generate Page Headers
if (($ph = $this->getArrayElement($op, "PageHeaders"))) {
foreach ($ph as $k => $phi) {
$this->query->createPageHeader($k, $phi["LineNumber"], $phi["HeaderText"]);
if (($fm = &$this->getArrayElement($phi, "Format"))) {
foreach ($fm as $att => $val) {
$this->query->setPageHeaderAttribute($k, $att, $val);
}
}
}
}
// Generate Page Footers
if (($ph = $this->getArrayElement($op, "PageFooters"))) {
foreach ($ph as $k => $phi) {
$this->query->createPageFooter($k, $phi["LineNumber"], $phi["FooterText"]);
if (($fm = &$this->getArrayElement($phi, "Format"))) {
foreach ($fm as $att => $val) {
$this->query->setPageFooterAttribute($k, $att, $val);
}
}
}
}
// Generate Display Orders
if ($has_cols && ($ph = $this->getArrayElement($op, "DisplayOrders"))) {
foreach ($ph as $k => $phi) {
$this->query->setColumnOrder($phi["ColumnName"], $phi["OrderNumber"]);
}
}
if ($has_cols && ($ph = $this->getArrayElement($op, "Groups"))) {
foreach ($ph as $k => $phi) {
if (array_key_exists("GroupName", $phi)) {
$gpname = $phi["GroupName"];
} else {
$gpname = $phi["Name"];
}
$grn = $this->query->createGroup($gpname);
if (array_key_exists("BeforeGroupHeader", $phi)) {
$grn->setAttribute("before_header", $phi["BeforeGroupHeader"]);
$grn->setAttribute("after_header", $phi["AfterGroupHeader"]);
$grn->setAttribute("before_trailer", $phi["BeforeGroupTrailer"]);
$grn->setAttribute("after_trailer", $phi["AfterGroupTrailer"]);
$grn->setFormat("before_header", $phi["BeforeGroupHeader"]);
$grn->setFormat("after_header", $phi["AfterGroupHeader"]);
$grn->setFormat("before_trailer", $phi["BeforeGroupTrailer"]);
$grn->setFormat("after_trailer", $phi["AfterGroupTrailer"]);
}
if (($gp = &$this->getArrayElement($phi, "GroupHeaders"))) {
foreach ($gp as $att => $val) {
if (!isset($val["GroupHeaderCustom"])) {
$val["GroupHeaderCustom"] = false;
}
if (!isset($val["ShowInHTML"])) {
$val["ShowInHTML"] = "yes";
}
if (!isset($val["ShowInPDF"])) {
$val["ShowInPDF"] = "yes";
}
$this->query->createGroupHeader($gpname, $val["GroupHeaderColumn"], $val["GroupHeaderCustom"], $val["ShowInHTML"], $val["ShowInPDF"]);
}
}
if (($gp = &$this->getArrayElement($phi, "GroupTrailers"))) {
foreach ($gp as $att => $val) {
if (!isset($val["GroupTrailerCustom"])) {
$val["GroupTrailerCustom"] = false;
}
if (!isset($val["ShowInHTML"])) {
$val["ShowInHTML"] = "yes";
}
if (!isset($val["ShowInPDF"])) {
$val["ShowInPDF"] = "yes";
}
$this->query->createGroupTrailer($gpname, $val["GroupTrailerDisplayColumn"],
$val["GroupTrailerValueColumn"],
$val["GroupTrailerCustom"], $val["ShowInHTML"], $val["ShowInPDF"]);
}
}
}
}
// Generate Graphs
if ($has_cols && ($gph = $this->getArrayElement($op, "Graphs"))) {
foreach ($gph as $k => $gphi) {
$ka = array_keys($gphi);
$gph = &$this->query->createGraph();
$gph->setGraphColumn($gphi["GraphColumn"]);
$gph->setTitle($gphi["Title"]);
$gph->setXtitle($gphi["XTitle"]);
$gph->setXlabelColumn($gphi["XLabelColumn"]);
$gph->setYtitle($gphi["YTitle"]);
//$gph->setYlabelColumn($gphi["YLabelColumn"]);
//////HERE!!!
if (array_key_exists("GraphWidth", $gphi)) {
$gph->setWidth($gphi["GraphWidth"]);
$gph->setHeight($gphi["GraphHeight"]);
$gph->setWidthPdf($gphi["GraphWidthPDF"]);
$gph->setHeightPdf($gphi["GraphHeightPDF"]);
} else {
$gph->setWidth($gphi["Width"]);
$gph->setHeight($gphi["Height"]);
}
if (array_key_exists("GraphColor", $gphi)) {
$gph->setGraphColor($gphi["GraphColor"]);
$gph->setGrid($gphi["GridPosition"],
$gphi["XGridDisplay"], $gphi["XGridColor"],
$gphi["YGridDisplay"], $gphi["YGridColor"]
);
$gph->setTitleFont($gphi["TitleFont"], $gphi["TitleFontStyle"],
$gphi["TitleFontSize"], $gphi["TitleColor"]);
$gph->setXtitleFont($gphi["XTitleFont"], $gphi["XTitleFontStyle"],
$gphi["XTitleFontSize"], $gphi["XTitleColor"]);
$gph->setYtitleFont($gphi["YTitleFont"], $gphi["YTitleFontStyle"],
$gphi["YTitleFontSize"], $gphi["YTitleColor"]);
$gph->setXaxis($gphi["XTickInterval"], $gphi["XTickLabelInterval"], $gphi["XAxisColor"]);
$gph->setYaxis($gphi["YTickInterval"], $gphi["YTickLabelInterval"], $gphi["YAxisColor"]);
$gph->setXaxisFont($gphi["XAxisFont"], $gphi["XAxisFontStyle"],
$gphi["XAxisFontSize"], $gphi["XAxisFontColor"]);
$gph->setYaxisFont($gphi["YAxisFont"], $gphi["YAxisFontStyle"],
$gphi["YAxisFontSize"], $gphi["YAxisFontColor"]);
$gph->setMarginColor($gphi["MarginColor"]);
$gph->setMargins($gphi["MarginLeft"], $gphi["MarginRight"],
$gphi["MarginTop"], $gphi["MarginBottom"]);
}
foreach ($gphi["Plots"] as $pltk => $pltv) {
$pl = &$gph->createPlot($pltv["PlotColumn"]);
$pl["type"] = $pltv["PlotType"];
$pl["fillcolor"] = $pltv["FillColor"];
$pl["linecolor"] = $pltv["LineColor"];
$pl["legend"] = $pltv["Legend"];
}
}
}
} // Output
// Check for Criteria Items ...
if (($crt = &$this->getArrayElement($ef, "Criteria"))) {
foreach ($crt as $ci) {
$critnm = $this->getArrayElement($ci, "Name");
$crittb = $this->getArrayElement($ci, "QueryTableName");
$critcl = $this->getArrayElement($ci, "QueryColumnName");
$linked_report = $this->getArrayElement($ci, "LinkToReport");
$linked_report_item = $this->getArrayElement($ci, "LinkToReportItem");
// If we are not designing a report then
// replace a linked criteria with the criteria
// item it links to from another report
if ($linked_report && $this->query->execute_mode != "MAINTAIN") {
$q = new Reportico();
$q->reports_path = $q->projects_folder . "/" . ReporticoApp::getConfig("project");
$reader = new XmlReader($q, $linked_report, false);
$reader->xml2query();
foreach ($q->lookup_queries as $k => $v) {
$found = false;
foreach ($this->query->columns as $querycol) {
if ($querycol->query_name == $v->query_name) {
$found = true;
}
}
$qu = new Reportico();
if ($linked_report_item == $v->query_name) {
$this->query->lookup_queries[$v->query_name] = $v;
}
}
continue;
}
if ($crittb) {
$critcl = $crittb . "." . $critcl;
$crittb = "";
}
$crittp = $this->getArrayElement($ci, "CriteriaType");
$critlt = $this->getArrayElement($ci, "CriteriaList");
$crituse = $this->getArrayElement($ci, "Use");
$critds = $this->getArrayElement($ci, "CriteriaDisplay");
$critexp = $this->getArrayElement($ci, "ExpandDisplay");
$critmatch = $this->getArrayElement($ci, "MatchColumn");
$critdefault = $this->getArrayElement($ci, "CriteriaDefaults");
$crithelp = $this->getArrayElement($ci, "CriteriaHelp");
$crittitle = $this->getArrayElement($ci, "Title");
$crit_required = $this->getArrayElement($ci, "CriteriaRequired");
$crit_hidden = $this->getArrayElement($ci, "CriteriaHidden");
$crit_display_group = $this->getArrayElement($ci, "CriteriaDisplayGroup");
$crit_lookup_return = $this->getArrayElement($ci, "ReturnColumn");
$crit_lookup_display = $this->getArrayElement($ci, "DisplayColumn");
$crit_criteria_display = $this->getArrayElement($ci, "OverviewColumn");
if ($crittp == "ANYCHAR") {
$crittp = "TEXTFIELD";
}
if ($critds == "ANYCHAR") {
$critds = "TEXTFIELD";
}
if ($critexp == "ANYCHAR") {
$critexp = "TEXTFIELD";
}
// Generate criteria lookup info unless its a link to a criteria in a nother report
if (!$linked_report && !($ciq = &$this->getArrayElement($ci, "Query"))) {
continue;
}
$critquery = new Reportico();
// Generate Criteria Query Columns
if (!$linked_report && ($ciqc = &$this->getArrayElement($ciq, "QueryColumns"))) {
foreach ($ciqc as $ccol) {
$in_query = true;
if (!$ccol["ColumnName"]) {
$in_query = false;
}
$critquery->createCriteriaColumn
(
$ccol["Name"],
$ccol["TableName"],
$ccol["ColumnName"],
$ccol["ColumnType"],
$ccol["ColumnLength"],
"###.##",
$in_query
);
}
}
// Generate Order By List
if (!$linked_report && ($coc = &$this->getArrayElement($ciq, "OrderColumns"))) {
// Generate QueryColumn for each column found
foreach ($coc as $col) {
$critquery->createOrderColumn
(
$col["Name"],
$col["OrderType"]
);
}
}
if (!$linked_report && ($as = &$this->getArrayElement($ciq, "Assignments"))) {
foreach ($as as $ast) {
if (array_key_exists("AssignName", $ast)) {
$critquery->addAssignment($ast["AssignName"], $ast["Expression"], $ast["Condition"]);
} else {
$critquery->addAssignment($ast["Name"], $ast["Expression"], $ast["Condition"]);
}
}
}
// Generate Criteria Links In Array for later use
if (!$linked_report && ($cl = &$this->getArrayElement($ci, "CriteriaLinks"))) {
foreach ($cl as $clitem) {
$criteria_links[] = array(
"LinkFrom" => $clitem["LinkFrom"],
"LinkTo" => $clitem["LinkTo"],
"LinkClause" => $clitem["LinkClause"],
);
}
}
// Set Query SQL Text
if (!$linked_report) {
$critquery->table_text = $this->getArrayElement($ciq, "TableSql");
$critquery->where_text = $this->getArrayElement($ciq, "WhereSql");
$critquery->group_text = $this->getArrayElement($ciq, "GroupSql");
$critquery->sql_raw = $this->getArrayElement($ciq, "SQLRaw");
$critquery->rowselection = $this->getArrayElement($ciq, "RowSelection");
}
$critquery->setLookupReturn($crit_lookup_return);
$critquery->setLookupDisplay($crit_lookup_display, $crit_criteria_display);
$critquery->setLookupExpandMatch($critmatch);
$this->query->setCriteriaLookup($critnm, $critquery, $crittb, $critcl);
$this->query->setCriteriaInput($critnm, $crittp, $critds, $critexp, $crituse);
$this->query->setCriteriaLinkReport($critnm, $linked_report, $linked_report_item);
//echo "SET $critnm $crit_required<BR>";
$this->query->setCriteriaDefaults($critnm, $critdefault);
$this->query->setCriteriaList($critnm, $critlt);
//var_dump($crit_required);
$this->query->setCriteriaRequired($critnm, $crit_required);
$this->query->setCriteriaHidden($critnm, $crit_hidden);
$this->query->setCriteriaDisplayGroup($critnm, $crit_display_group);
//$this->query->setCriteriaHelp($critnm, $crithelp);
$this->query->setCriteriaAttribute($critnm, "column_title", $crittitle);
$this->query->setCriteriaHelp($critnm, $crithelp);
} // End Criteria Item
// Set up any Criteria Links
foreach ($criteria_links as $cl) {
$this->query->set_criteria_link($cl["LinkFrom"], $cl["LinkTo"], $cl["LinkClause"]);
}
}
}
} | php | public function xml2query()
{
if (array_key_exists("CogModule", $this->data)) {
$q = &$this->data["CogModule"];
} else {
$q = &$this->data["Report"];
}
$criteria_links = array();
// Generate Output Information...
$ds = false;
if (!$q) {
return;
}
foreach ($q as $cogquery) {
// Set Query Attributes
foreach ($cogquery["Format"] as $att => $val) {
$this->query->setAttribute($att, $val);
}
// Set DataSource
if (isset($cogquery["Datasource"])) {
foreach ($cogquery["Datasource"] as $att => $val) {
//if ( $att == "SourceType" )
//$this->query->source_type = $val;
if ($att == "SourceConnection") {
// No longer relevant - connections are not supplied in xml files
}
}
}
// Set Query Columns
if (!($ef = &$this->getArrayElement($cogquery, "EntryForm"))) {
$this->ErrorMsg = "No EntryForm tag within Format";
return false;
}
if (!($qu = &$this->getArrayElement($ef, "Query"))) {
$this->ErrorMsg = "No Query tag within EntryForm";
return false;
}
$this->query->table_text = $this->getArrayElement($qu, "TableSql");
$this->query->where_text = $this->getArrayElement($qu, "WhereSql");
$this->query->group_text = $this->getArrayElement($qu, "GroupSql");
$this->query->rowselection = $this->getArrayElement($qu, "RowSelection");
$has_cols = true;
if (($qc = &$this->getArrayElement($qu, "SQL"))) {
$this->query->sql_raw = $this->getArrayElement($qc, "SQLRaw");
}
if (!($qc = &$this->getArrayElement($qu, "QueryColumns"))) {
$this->ErrorMsg = "No QueryColumns tag within Query";
$has_cols = false;
}
// Generate QueryColumn for each column found
if ($has_cols) {
foreach ($qc as $col) {
$in_query = true;
if (!$col["ColumnName"]) {
$in_query = false;
}
$this->query->createCriteriaColumn
(
$col["Name"],
$col["TableName"],
$col["ColumnName"],
$col["ColumnType"],
$col["ColumnLength"],
"###.##",
$in_query
);
// Set any Attributes
if (($fm = &$this->getArrayElement($col, "Format"))) {
foreach ($fm as $att => $val) {
$this->query->setColumnAttribute($col["Name"], $att, $val);
}
}
}
// Generate Order By List
if (($oc = &$this->getArrayElement($qu, "OrderColumns"))) {
// Generate QueryColumn for each column found
foreach ($oc as $col) {
if (!$col["Name"]) {
return;
}
$this->query->createQueryColumn
(
$col["Name"],
$col["OrderType"]
);
}
}
// Generate Query Assignments
if (($as = &$this->getArrayElement($ef, "Assignments"))) {
foreach ($as as $col) {
if (array_key_exists("AssignName", $col)) {
$this->query->addAssignment($col["AssignName"], $col["Expression"], $col["Condition"]);
} else {
$this->query->addAssignment($col["Name"], $col["Expression"], $col["Condition"]);
}
}
}
}
// Generate Query Assignments
if (($pq = &$this->getArrayElement($qu, "PreSQLS"))) {
foreach ($pq as $col) {
$this->query->addPreSql($col["SQLText"]);
}
}
// Generate Output Information...
if (($op = &$this->getArrayElement($ef, "Output"))) {
// Generate Page Headers
if (($ph = $this->getArrayElement($op, "PageHeaders"))) {
foreach ($ph as $k => $phi) {
$this->query->createPageHeader($k, $phi["LineNumber"], $phi["HeaderText"]);
if (($fm = &$this->getArrayElement($phi, "Format"))) {
foreach ($fm as $att => $val) {
$this->query->setPageHeaderAttribute($k, $att, $val);
}
}
}
}
// Generate Page Footers
if (($ph = $this->getArrayElement($op, "PageFooters"))) {
foreach ($ph as $k => $phi) {
$this->query->createPageFooter($k, $phi["LineNumber"], $phi["FooterText"]);
if (($fm = &$this->getArrayElement($phi, "Format"))) {
foreach ($fm as $att => $val) {
$this->query->setPageFooterAttribute($k, $att, $val);
}
}
}
}
// Generate Display Orders
if ($has_cols && ($ph = $this->getArrayElement($op, "DisplayOrders"))) {
foreach ($ph as $k => $phi) {
$this->query->setColumnOrder($phi["ColumnName"], $phi["OrderNumber"]);
}
}
if ($has_cols && ($ph = $this->getArrayElement($op, "Groups"))) {
foreach ($ph as $k => $phi) {
if (array_key_exists("GroupName", $phi)) {
$gpname = $phi["GroupName"];
} else {
$gpname = $phi["Name"];
}
$grn = $this->query->createGroup($gpname);
if (array_key_exists("BeforeGroupHeader", $phi)) {
$grn->setAttribute("before_header", $phi["BeforeGroupHeader"]);
$grn->setAttribute("after_header", $phi["AfterGroupHeader"]);
$grn->setAttribute("before_trailer", $phi["BeforeGroupTrailer"]);
$grn->setAttribute("after_trailer", $phi["AfterGroupTrailer"]);
$grn->setFormat("before_header", $phi["BeforeGroupHeader"]);
$grn->setFormat("after_header", $phi["AfterGroupHeader"]);
$grn->setFormat("before_trailer", $phi["BeforeGroupTrailer"]);
$grn->setFormat("after_trailer", $phi["AfterGroupTrailer"]);
}
if (($gp = &$this->getArrayElement($phi, "GroupHeaders"))) {
foreach ($gp as $att => $val) {
if (!isset($val["GroupHeaderCustom"])) {
$val["GroupHeaderCustom"] = false;
}
if (!isset($val["ShowInHTML"])) {
$val["ShowInHTML"] = "yes";
}
if (!isset($val["ShowInPDF"])) {
$val["ShowInPDF"] = "yes";
}
$this->query->createGroupHeader($gpname, $val["GroupHeaderColumn"], $val["GroupHeaderCustom"], $val["ShowInHTML"], $val["ShowInPDF"]);
}
}
if (($gp = &$this->getArrayElement($phi, "GroupTrailers"))) {
foreach ($gp as $att => $val) {
if (!isset($val["GroupTrailerCustom"])) {
$val["GroupTrailerCustom"] = false;
}
if (!isset($val["ShowInHTML"])) {
$val["ShowInHTML"] = "yes";
}
if (!isset($val["ShowInPDF"])) {
$val["ShowInPDF"] = "yes";
}
$this->query->createGroupTrailer($gpname, $val["GroupTrailerDisplayColumn"],
$val["GroupTrailerValueColumn"],
$val["GroupTrailerCustom"], $val["ShowInHTML"], $val["ShowInPDF"]);
}
}
}
}
// Generate Graphs
if ($has_cols && ($gph = $this->getArrayElement($op, "Graphs"))) {
foreach ($gph as $k => $gphi) {
$ka = array_keys($gphi);
$gph = &$this->query->createGraph();
$gph->setGraphColumn($gphi["GraphColumn"]);
$gph->setTitle($gphi["Title"]);
$gph->setXtitle($gphi["XTitle"]);
$gph->setXlabelColumn($gphi["XLabelColumn"]);
$gph->setYtitle($gphi["YTitle"]);
//$gph->setYlabelColumn($gphi["YLabelColumn"]);
//////HERE!!!
if (array_key_exists("GraphWidth", $gphi)) {
$gph->setWidth($gphi["GraphWidth"]);
$gph->setHeight($gphi["GraphHeight"]);
$gph->setWidthPdf($gphi["GraphWidthPDF"]);
$gph->setHeightPdf($gphi["GraphHeightPDF"]);
} else {
$gph->setWidth($gphi["Width"]);
$gph->setHeight($gphi["Height"]);
}
if (array_key_exists("GraphColor", $gphi)) {
$gph->setGraphColor($gphi["GraphColor"]);
$gph->setGrid($gphi["GridPosition"],
$gphi["XGridDisplay"], $gphi["XGridColor"],
$gphi["YGridDisplay"], $gphi["YGridColor"]
);
$gph->setTitleFont($gphi["TitleFont"], $gphi["TitleFontStyle"],
$gphi["TitleFontSize"], $gphi["TitleColor"]);
$gph->setXtitleFont($gphi["XTitleFont"], $gphi["XTitleFontStyle"],
$gphi["XTitleFontSize"], $gphi["XTitleColor"]);
$gph->setYtitleFont($gphi["YTitleFont"], $gphi["YTitleFontStyle"],
$gphi["YTitleFontSize"], $gphi["YTitleColor"]);
$gph->setXaxis($gphi["XTickInterval"], $gphi["XTickLabelInterval"], $gphi["XAxisColor"]);
$gph->setYaxis($gphi["YTickInterval"], $gphi["YTickLabelInterval"], $gphi["YAxisColor"]);
$gph->setXaxisFont($gphi["XAxisFont"], $gphi["XAxisFontStyle"],
$gphi["XAxisFontSize"], $gphi["XAxisFontColor"]);
$gph->setYaxisFont($gphi["YAxisFont"], $gphi["YAxisFontStyle"],
$gphi["YAxisFontSize"], $gphi["YAxisFontColor"]);
$gph->setMarginColor($gphi["MarginColor"]);
$gph->setMargins($gphi["MarginLeft"], $gphi["MarginRight"],
$gphi["MarginTop"], $gphi["MarginBottom"]);
}
foreach ($gphi["Plots"] as $pltk => $pltv) {
$pl = &$gph->createPlot($pltv["PlotColumn"]);
$pl["type"] = $pltv["PlotType"];
$pl["fillcolor"] = $pltv["FillColor"];
$pl["linecolor"] = $pltv["LineColor"];
$pl["legend"] = $pltv["Legend"];
}
}
}
} // Output
// Check for Criteria Items ...
if (($crt = &$this->getArrayElement($ef, "Criteria"))) {
foreach ($crt as $ci) {
$critnm = $this->getArrayElement($ci, "Name");
$crittb = $this->getArrayElement($ci, "QueryTableName");
$critcl = $this->getArrayElement($ci, "QueryColumnName");
$linked_report = $this->getArrayElement($ci, "LinkToReport");
$linked_report_item = $this->getArrayElement($ci, "LinkToReportItem");
// If we are not designing a report then
// replace a linked criteria with the criteria
// item it links to from another report
if ($linked_report && $this->query->execute_mode != "MAINTAIN") {
$q = new Reportico();
$q->reports_path = $q->projects_folder . "/" . ReporticoApp::getConfig("project");
$reader = new XmlReader($q, $linked_report, false);
$reader->xml2query();
foreach ($q->lookup_queries as $k => $v) {
$found = false;
foreach ($this->query->columns as $querycol) {
if ($querycol->query_name == $v->query_name) {
$found = true;
}
}
$qu = new Reportico();
if ($linked_report_item == $v->query_name) {
$this->query->lookup_queries[$v->query_name] = $v;
}
}
continue;
}
if ($crittb) {
$critcl = $crittb . "." . $critcl;
$crittb = "";
}
$crittp = $this->getArrayElement($ci, "CriteriaType");
$critlt = $this->getArrayElement($ci, "CriteriaList");
$crituse = $this->getArrayElement($ci, "Use");
$critds = $this->getArrayElement($ci, "CriteriaDisplay");
$critexp = $this->getArrayElement($ci, "ExpandDisplay");
$critmatch = $this->getArrayElement($ci, "MatchColumn");
$critdefault = $this->getArrayElement($ci, "CriteriaDefaults");
$crithelp = $this->getArrayElement($ci, "CriteriaHelp");
$crittitle = $this->getArrayElement($ci, "Title");
$crit_required = $this->getArrayElement($ci, "CriteriaRequired");
$crit_hidden = $this->getArrayElement($ci, "CriteriaHidden");
$crit_display_group = $this->getArrayElement($ci, "CriteriaDisplayGroup");
$crit_lookup_return = $this->getArrayElement($ci, "ReturnColumn");
$crit_lookup_display = $this->getArrayElement($ci, "DisplayColumn");
$crit_criteria_display = $this->getArrayElement($ci, "OverviewColumn");
if ($crittp == "ANYCHAR") {
$crittp = "TEXTFIELD";
}
if ($critds == "ANYCHAR") {
$critds = "TEXTFIELD";
}
if ($critexp == "ANYCHAR") {
$critexp = "TEXTFIELD";
}
// Generate criteria lookup info unless its a link to a criteria in a nother report
if (!$linked_report && !($ciq = &$this->getArrayElement($ci, "Query"))) {
continue;
}
$critquery = new Reportico();
// Generate Criteria Query Columns
if (!$linked_report && ($ciqc = &$this->getArrayElement($ciq, "QueryColumns"))) {
foreach ($ciqc as $ccol) {
$in_query = true;
if (!$ccol["ColumnName"]) {
$in_query = false;
}
$critquery->createCriteriaColumn
(
$ccol["Name"],
$ccol["TableName"],
$ccol["ColumnName"],
$ccol["ColumnType"],
$ccol["ColumnLength"],
"###.##",
$in_query
);
}
}
// Generate Order By List
if (!$linked_report && ($coc = &$this->getArrayElement($ciq, "OrderColumns"))) {
// Generate QueryColumn for each column found
foreach ($coc as $col) {
$critquery->createOrderColumn
(
$col["Name"],
$col["OrderType"]
);
}
}
if (!$linked_report && ($as = &$this->getArrayElement($ciq, "Assignments"))) {
foreach ($as as $ast) {
if (array_key_exists("AssignName", $ast)) {
$critquery->addAssignment($ast["AssignName"], $ast["Expression"], $ast["Condition"]);
} else {
$critquery->addAssignment($ast["Name"], $ast["Expression"], $ast["Condition"]);
}
}
}
// Generate Criteria Links In Array for later use
if (!$linked_report && ($cl = &$this->getArrayElement($ci, "CriteriaLinks"))) {
foreach ($cl as $clitem) {
$criteria_links[] = array(
"LinkFrom" => $clitem["LinkFrom"],
"LinkTo" => $clitem["LinkTo"],
"LinkClause" => $clitem["LinkClause"],
);
}
}
// Set Query SQL Text
if (!$linked_report) {
$critquery->table_text = $this->getArrayElement($ciq, "TableSql");
$critquery->where_text = $this->getArrayElement($ciq, "WhereSql");
$critquery->group_text = $this->getArrayElement($ciq, "GroupSql");
$critquery->sql_raw = $this->getArrayElement($ciq, "SQLRaw");
$critquery->rowselection = $this->getArrayElement($ciq, "RowSelection");
}
$critquery->setLookupReturn($crit_lookup_return);
$critquery->setLookupDisplay($crit_lookup_display, $crit_criteria_display);
$critquery->setLookupExpandMatch($critmatch);
$this->query->setCriteriaLookup($critnm, $critquery, $crittb, $critcl);
$this->query->setCriteriaInput($critnm, $crittp, $critds, $critexp, $crituse);
$this->query->setCriteriaLinkReport($critnm, $linked_report, $linked_report_item);
//echo "SET $critnm $crit_required<BR>";
$this->query->setCriteriaDefaults($critnm, $critdefault);
$this->query->setCriteriaList($critnm, $critlt);
//var_dump($crit_required);
$this->query->setCriteriaRequired($critnm, $crit_required);
$this->query->setCriteriaHidden($critnm, $crit_hidden);
$this->query->setCriteriaDisplayGroup($critnm, $crit_display_group);
//$this->query->setCriteriaHelp($critnm, $crithelp);
$this->query->setCriteriaAttribute($critnm, "column_title", $crittitle);
$this->query->setCriteriaHelp($critnm, $crithelp);
} // End Criteria Item
// Set up any Criteria Links
foreach ($criteria_links as $cl) {
$this->query->set_criteria_link($cl["LinkFrom"], $cl["LinkTo"], $cl["LinkClause"]);
}
}
}
} | [
"public",
"function",
"xml2query",
"(",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"\"CogModule\"",
",",
"$",
"this",
"->",
"data",
")",
")",
"{",
"$",
"q",
"=",
"&",
"$",
"this",
"->",
"data",
"[",
"\"CogModule\"",
"]",
";",
"}",
"else",
"{",
"... | Functon: xml2query
Analyses XML report definition and builds Reportico report instance from it | [
"Functon",
":",
"xml2query"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/XmlReader.php#L4706-L5150 |
reportico-web/reportico | src/ReportHtml2pdf.php | ReportHtml2pdf.formatColumnHeader | public function formatColumnHeader(&$column_item) //HTML
{
$sessionClass = ReporticoSession();
if ($this->body_display != "show") {
return;
}
if (!$sessionClass::getReporticoSessionParam("target_show_detail")) {
return;
}
if (!$this->showColumnHeader($column_item)) {
return;
}
// Create sensible column header label from column name
$padstring = ReporticoUtility::columnNameToLabel($column_item->query_name);
$padstring = $column_item->deriveAttribute("column_title", $padstring);
$padstring = ReporticoLang::translate($padstring);
$colstyles = array();
$cw = $column_item->deriveAttribute("ColumnWidthHTML", false);
$just = $column_item->deriveAttribute("justify", false);
if ($cw) {
$colstyles["width"] = $cw;
}
if ($just) {
$colstyles["text-align"] = $just;
}
$this->jar["pages"][$this->page_count]["headers"][] = [
"styles" => $this->getStyleTags($colstyles, $this->query->output_header_styles),
"content" => $padstring
];
} | php | public function formatColumnHeader(&$column_item) //HTML
{
$sessionClass = ReporticoSession();
if ($this->body_display != "show") {
return;
}
if (!$sessionClass::getReporticoSessionParam("target_show_detail")) {
return;
}
if (!$this->showColumnHeader($column_item)) {
return;
}
// Create sensible column header label from column name
$padstring = ReporticoUtility::columnNameToLabel($column_item->query_name);
$padstring = $column_item->deriveAttribute("column_title", $padstring);
$padstring = ReporticoLang::translate($padstring);
$colstyles = array();
$cw = $column_item->deriveAttribute("ColumnWidthHTML", false);
$just = $column_item->deriveAttribute("justify", false);
if ($cw) {
$colstyles["width"] = $cw;
}
if ($just) {
$colstyles["text-align"] = $just;
}
$this->jar["pages"][$this->page_count]["headers"][] = [
"styles" => $this->getStyleTags($colstyles, $this->query->output_header_styles),
"content" => $padstring
];
} | [
"public",
"function",
"formatColumnHeader",
"(",
"&",
"$",
"column_item",
")",
"//HTML",
"{",
"$",
"sessionClass",
"=",
"ReporticoSession",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"body_display",
"!=",
"\"show\"",
")",
"{",
"return",
";",
"}",
"if",
... | @brief Sets column header
@param $column_item | [
"@brief",
"Sets",
"column",
"header"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReportHtml2pdf.php#L130-L167 |
reportico-web/reportico | src/SqlParser.php | SqlParser.parse | public function parse($warn_empty_aliases = true)
{
$err = false;
$this->sql_raw = $this->sql;
// First extract every element of of the sql which begins with SELECT ..... FROM
$matches = array();
preg_match_all("/.*SELECT\s*(.*)\sFROM\s.*/isU", $this->sql, $matches, PREG_OFFSET_CAPTURE);
$sql = &$this->sql;
// Find the main query SELECT column list which may be hidden among other many selects in
// a the users statement. The trick is to find the columns belonging to a select that
// is not preceded by a "(" indicating a sub select.
$col = "";
$selpos = -1;
$frompos = -1;
$ptr = 0;
$brackets = 0;
$doublequotes = 0;
while ($ptr < strlen($sql)) {
$bit = substr($sql, $ptr, 1);
$bit4 = substr($sql, $ptr, 4);
$bit6 = substr($sql, $ptr, 6);
$bit7 = substr($sql, $ptr, 7);
$inc = 1;
if ($bit == "\"" && $doublequotes == 0) {
$doublequotes++;
} else if ($bit == "\"") {
$doublequotes--;
} else if ($bit == "(") {
$brackets++;
} else if ($bit == ")") {
$brackets--;
} else if (preg_match("/SELECT\s/i", $bit7)) {
if ($brackets == 0 && $doublequotes == 0) {
$selpos = $ptr + 7;
$inc = 7;
}
} else if (preg_match("/\sFROM\s/i", $bit6)) {
if ($selpos > -1 && $brackets == 0 && $doublequotes == 0) {
$frompos = $ptr;
$inc = 5;
break;
}
}
$ptr += $inc;
}
$columnoffset = $frompos;
// Find the main query SELECT column list which may be hidden among other many selects in
// a the users statement. The trick is to find the columns belonging to a select that
// is not preceded by a "(" indicating a sub select.
if ($selpos == -1 || $frompos == -1) {
trigger_error("no SELECT clause specified. Query must contain a 'SELECT'", E_USER_ERROR);
} else {
$col = substr($sql, $selpos, $frompos - $selpos);
if ($col) {
$this->parseColumnList($this->sql_raw, $col, $selpos, $warn_empty_aliases);
// Now find the location where the WHERE is or where it would be if there isnt one
$wherematch = array();
if (preg_match("/.*(\[\s*WHERE\s+.*)/siU", $sql, $wherematch, PREG_OFFSET_CAPTURE, $this->columnoffset)) {
$this->haswhere = false;
$this->whereoffset = $wherematch[1][1];
} else if (preg_match("/.*\s+WHERE(\s+.*)/siU", $sql, $wherematch, PREG_OFFSET_CAPTURE, $this->columnoffset)) {
$this->haswhere = true;
$this->whereoffset = $wherematch[1][1];
} else if (preg_match("/.*(\s+GROUP BY\s+.*)/siU", $sql, $wherematch, PREG_OFFSET_CAPTURE, $this->columnoffset)) {
$this->whereoffset = $wherematch[1][1];
} else if (preg_match("/.*(\s+GROUP BY\s+.*)/siU", $sql, $wherematch, PREG_OFFSET_CAPTURE, $this->columnoffset)) {
$this->whereoffset = $wherematch[1][1];
} else if (preg_match("/.*(\s+GROUP BY\s+.*)/siU", $sql, $wherematch, PREG_OFFSET_CAPTURE, $this->columnoffset)) {
$this->whereoffset = $wherematch[1][1];
} else if (preg_match("/.*(\s+HAVING\s+.*)/siU", $sql, $wherematch, PREG_OFFSET_CAPTURE, $this->columnoffset)) {
$this->whereoffset = $wherematch[1][1];
} else if (preg_match("/.*(\s+ORDER BY\s+.*)/siU", $sql, $wherematch, PREG_OFFSET_CAPTURE, $this->columnoffset)) {
$this->whereoffset = $wherematch[1][1];
} else if (preg_match("/.*(\s+LIMIT\s+.*)/siU", $sql, $wherematch, PREG_OFFSET_CAPTURE, $this->columnoffset)) {
$this->whereoffset = $wherematch[1][1];
} else if (preg_match("/.*(\s+PROCEDURE\s+.*)/siU", $sql, $wherematch, PREG_OFFSET_CAPTURE, $this->columnoffset)) {
$this->whereoffset = $wherematch[1][1];
} else {
$this->whereoffset = strlen($sql);
}
}
}
$upd_match = "/^\s*UPDATE\s*(.*)/is";
$del_match = "/^\s*DELETE\s*(.*)/is";
if (preg_match($upd_match, $sql, $cpt)) {
trigger_error("Update statements are not allowed in designer queries", E_USER_ERROR);
$sel_type = "UPDATE";
$this->sql_raw = "#" . $this->sql_raw;
$this->whereoffset = 0;
}
if (preg_match($del_match, $sql, $cpt)) {
trigger_error("Delete statements are not allowed designer queries", E_USER_ERROR);
$sel_type = "DELETE";
$this->sql_raw = "#" . $this->sql_raw;
$this->whereoffset = 0;
}
return $this->whereoffset;
} | php | public function parse($warn_empty_aliases = true)
{
$err = false;
$this->sql_raw = $this->sql;
// First extract every element of of the sql which begins with SELECT ..... FROM
$matches = array();
preg_match_all("/.*SELECT\s*(.*)\sFROM\s.*/isU", $this->sql, $matches, PREG_OFFSET_CAPTURE);
$sql = &$this->sql;
// Find the main query SELECT column list which may be hidden among other many selects in
// a the users statement. The trick is to find the columns belonging to a select that
// is not preceded by a "(" indicating a sub select.
$col = "";
$selpos = -1;
$frompos = -1;
$ptr = 0;
$brackets = 0;
$doublequotes = 0;
while ($ptr < strlen($sql)) {
$bit = substr($sql, $ptr, 1);
$bit4 = substr($sql, $ptr, 4);
$bit6 = substr($sql, $ptr, 6);
$bit7 = substr($sql, $ptr, 7);
$inc = 1;
if ($bit == "\"" && $doublequotes == 0) {
$doublequotes++;
} else if ($bit == "\"") {
$doublequotes--;
} else if ($bit == "(") {
$brackets++;
} else if ($bit == ")") {
$brackets--;
} else if (preg_match("/SELECT\s/i", $bit7)) {
if ($brackets == 0 && $doublequotes == 0) {
$selpos = $ptr + 7;
$inc = 7;
}
} else if (preg_match("/\sFROM\s/i", $bit6)) {
if ($selpos > -1 && $brackets == 0 && $doublequotes == 0) {
$frompos = $ptr;
$inc = 5;
break;
}
}
$ptr += $inc;
}
$columnoffset = $frompos;
// Find the main query SELECT column list which may be hidden among other many selects in
// a the users statement. The trick is to find the columns belonging to a select that
// is not preceded by a "(" indicating a sub select.
if ($selpos == -1 || $frompos == -1) {
trigger_error("no SELECT clause specified. Query must contain a 'SELECT'", E_USER_ERROR);
} else {
$col = substr($sql, $selpos, $frompos - $selpos);
if ($col) {
$this->parseColumnList($this->sql_raw, $col, $selpos, $warn_empty_aliases);
// Now find the location where the WHERE is or where it would be if there isnt one
$wherematch = array();
if (preg_match("/.*(\[\s*WHERE\s+.*)/siU", $sql, $wherematch, PREG_OFFSET_CAPTURE, $this->columnoffset)) {
$this->haswhere = false;
$this->whereoffset = $wherematch[1][1];
} else if (preg_match("/.*\s+WHERE(\s+.*)/siU", $sql, $wherematch, PREG_OFFSET_CAPTURE, $this->columnoffset)) {
$this->haswhere = true;
$this->whereoffset = $wherematch[1][1];
} else if (preg_match("/.*(\s+GROUP BY\s+.*)/siU", $sql, $wherematch, PREG_OFFSET_CAPTURE, $this->columnoffset)) {
$this->whereoffset = $wherematch[1][1];
} else if (preg_match("/.*(\s+GROUP BY\s+.*)/siU", $sql, $wherematch, PREG_OFFSET_CAPTURE, $this->columnoffset)) {
$this->whereoffset = $wherematch[1][1];
} else if (preg_match("/.*(\s+GROUP BY\s+.*)/siU", $sql, $wherematch, PREG_OFFSET_CAPTURE, $this->columnoffset)) {
$this->whereoffset = $wherematch[1][1];
} else if (preg_match("/.*(\s+HAVING\s+.*)/siU", $sql, $wherematch, PREG_OFFSET_CAPTURE, $this->columnoffset)) {
$this->whereoffset = $wherematch[1][1];
} else if (preg_match("/.*(\s+ORDER BY\s+.*)/siU", $sql, $wherematch, PREG_OFFSET_CAPTURE, $this->columnoffset)) {
$this->whereoffset = $wherematch[1][1];
} else if (preg_match("/.*(\s+LIMIT\s+.*)/siU", $sql, $wherematch, PREG_OFFSET_CAPTURE, $this->columnoffset)) {
$this->whereoffset = $wherematch[1][1];
} else if (preg_match("/.*(\s+PROCEDURE\s+.*)/siU", $sql, $wherematch, PREG_OFFSET_CAPTURE, $this->columnoffset)) {
$this->whereoffset = $wherematch[1][1];
} else {
$this->whereoffset = strlen($sql);
}
}
}
$upd_match = "/^\s*UPDATE\s*(.*)/is";
$del_match = "/^\s*DELETE\s*(.*)/is";
if (preg_match($upd_match, $sql, $cpt)) {
trigger_error("Update statements are not allowed in designer queries", E_USER_ERROR);
$sel_type = "UPDATE";
$this->sql_raw = "#" . $this->sql_raw;
$this->whereoffset = 0;
}
if (preg_match($del_match, $sql, $cpt)) {
trigger_error("Delete statements are not allowed designer queries", E_USER_ERROR);
$sel_type = "DELETE";
$this->sql_raw = "#" . $this->sql_raw;
$this->whereoffset = 0;
}
return $this->whereoffset;
} | [
"public",
"function",
"parse",
"(",
"$",
"warn_empty_aliases",
"=",
"true",
")",
"{",
"$",
"err",
"=",
"false",
";",
"$",
"this",
"->",
"sql_raw",
"=",
"$",
"this",
"->",
"sql",
";",
"// First extract every element of of the sql which begins with SELECT ..... FROM",... | ** | [
"**"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/SqlParser.php#L197-L308 |
reportico-web/reportico | src/SqlParser.php | SqlParser.parseColumnList | public function parseColumnList(&$original_sql, $in_string, $offset_in_original_sql, $warn_empty_aliases)
{
$tmpsql = $original_sql;
$rolling_new_alias_offset = $offset_in_original_sql;
$collist = $this->tokeniseColumns($in_string);
foreach ($collist as $k => $colitem) {
$auto_gen_alias = false;
if (!$this->parseColumn($k + 1, trim($colitem), $auto_gen_alias, $warn_empty_aliases)) {
return false;
}
$rolling_new_alias_offset += strlen($colitem);
if ($auto_gen_alias) {
$tmpsql = substr($tmpsql, 0, $rolling_new_alias_offset) .
" $auto_gen_alias" . substr($tmpsql, $rolling_new_alias_offset);
$rolling_new_alias_offset += strlen($auto_gen_alias) + 1;
}
$rolling_new_alias_offset += 1;
}
$original_sql = $tmpsql;
return true;
} | php | public function parseColumnList(&$original_sql, $in_string, $offset_in_original_sql, $warn_empty_aliases)
{
$tmpsql = $original_sql;
$rolling_new_alias_offset = $offset_in_original_sql;
$collist = $this->tokeniseColumns($in_string);
foreach ($collist as $k => $colitem) {
$auto_gen_alias = false;
if (!$this->parseColumn($k + 1, trim($colitem), $auto_gen_alias, $warn_empty_aliases)) {
return false;
}
$rolling_new_alias_offset += strlen($colitem);
if ($auto_gen_alias) {
$tmpsql = substr($tmpsql, 0, $rolling_new_alias_offset) .
" $auto_gen_alias" . substr($tmpsql, $rolling_new_alias_offset);
$rolling_new_alias_offset += strlen($auto_gen_alias) + 1;
}
$rolling_new_alias_offset += 1;
}
$original_sql = $tmpsql;
return true;
} | [
"public",
"function",
"parseColumnList",
"(",
"&",
"$",
"original_sql",
",",
"$",
"in_string",
",",
"$",
"offset_in_original_sql",
",",
"$",
"warn_empty_aliases",
")",
"{",
"$",
"tmpsql",
"=",
"$",
"original_sql",
";",
"$",
"rolling_new_alias_offset",
"=",
"$",
... | ---------------------------------------------------------------------------- | [
"----------------------------------------------------------------------------"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/SqlParser.php#L410-L434 |
reportico-web/reportico | src/SqlParser.php | SqlParser.parseColumn | public function parseColumn($in_colno, $in_string, &$auto_gen_alias, $warn_empty_aliases)
{
$err = false;
$colalias = "";
$colname = "";
$coltable = "";
$colexp = "";
// Check for an alias ( any final word which is preceded by any non
// numeric or expression character
// Split out the last two elements
if (preg_match("/(.+\))([^\s]*)\s*\$/s", $in_string, $out_match)) {
if (preg_match("/^[[:alpha:]]\w+$/s", $out_match[2])) {
$colalias = $out_match[2];
$colname = $out_match[1];
$colexp = $colname;
} else {
if (preg_match("/[^0-9A-Za-z_\r\n\t .]/", $in_string)) {
$colalias = "column" . $in_colno;
$auto_gen_alias = $colalias;
if ($warn_empty_aliases) {
ReporticoApp::handleDebug("Expression <b>($in_string)</b> is unnamed and will be given the name <b>$colalias</b>. You might like to provide your own column alias for this expression.", 0);
}
}
$colname = $in_string;
$colexp = $in_string;
}
} else
if (preg_match("/(.+)\s+(.*)\s*\$/s", $in_string, $out_match)) {
if (preg_match("/^[[:alpha:]]\w+$/s", $out_match[2])) {
$colalias = $out_match[2];
$colname = $out_match[1];
$colexp = $colname;
} else
if (preg_match("/^[a-zA-Z]$/s", $out_match[2])) {
$colalias = $out_match[2];
$colname = $out_match[1];
$colexp = $colname;
} else {
if (preg_match("/[^0-9A-Za-z_\r\n\t .]/", $in_string)) {
$colalias = "column" . $in_colno;
$auto_gen_alias = $colalias;
if ($warn_empty_aliases) {
ReporticoApp::handleDebug("Expression <b>($in_string)</b> is unnamed and will be given the name <b>$colalias</b>. You might like to provide your own column alias for this expression.", 0);
}
}
$colname = $in_string;
$colexp = $in_string;
}
} else {
// Single column value only so assume no alias
if (preg_match("/[^0-9A-Za-z_\r\n\t .]/", $in_string)) {
$colalias = "column" . $in_colno;
$auto_gen_alias = $colalias;
if ($warn_empty_aliases) {
ReporticoApp::handleDebug("Expression <b>($in_string)</b> is unnamed and will be given the name <b>$colalias</b>. You might like to provide your own column alias for this expression.", 0);
}
}
$colname = $in_string;
$colexp = $in_string;
}
// Now with what's left of the column try to ascertain a table name
// and column part
if (preg_match("/^(\w+)\.(\w+)$/", $colname, $out_match)) {
$coltable = $out_match[1];
$colname = $out_match[2];
}
$this->columns[] = array(
"name" => $colname,
"table" => $coltable,
"alias" => $colalias,
"expression" => $colexp,
)
;
return true;
} | php | public function parseColumn($in_colno, $in_string, &$auto_gen_alias, $warn_empty_aliases)
{
$err = false;
$colalias = "";
$colname = "";
$coltable = "";
$colexp = "";
// Check for an alias ( any final word which is preceded by any non
// numeric or expression character
// Split out the last two elements
if (preg_match("/(.+\))([^\s]*)\s*\$/s", $in_string, $out_match)) {
if (preg_match("/^[[:alpha:]]\w+$/s", $out_match[2])) {
$colalias = $out_match[2];
$colname = $out_match[1];
$colexp = $colname;
} else {
if (preg_match("/[^0-9A-Za-z_\r\n\t .]/", $in_string)) {
$colalias = "column" . $in_colno;
$auto_gen_alias = $colalias;
if ($warn_empty_aliases) {
ReporticoApp::handleDebug("Expression <b>($in_string)</b> is unnamed and will be given the name <b>$colalias</b>. You might like to provide your own column alias for this expression.", 0);
}
}
$colname = $in_string;
$colexp = $in_string;
}
} else
if (preg_match("/(.+)\s+(.*)\s*\$/s", $in_string, $out_match)) {
if (preg_match("/^[[:alpha:]]\w+$/s", $out_match[2])) {
$colalias = $out_match[2];
$colname = $out_match[1];
$colexp = $colname;
} else
if (preg_match("/^[a-zA-Z]$/s", $out_match[2])) {
$colalias = $out_match[2];
$colname = $out_match[1];
$colexp = $colname;
} else {
if (preg_match("/[^0-9A-Za-z_\r\n\t .]/", $in_string)) {
$colalias = "column" . $in_colno;
$auto_gen_alias = $colalias;
if ($warn_empty_aliases) {
ReporticoApp::handleDebug("Expression <b>($in_string)</b> is unnamed and will be given the name <b>$colalias</b>. You might like to provide your own column alias for this expression.", 0);
}
}
$colname = $in_string;
$colexp = $in_string;
}
} else {
// Single column value only so assume no alias
if (preg_match("/[^0-9A-Za-z_\r\n\t .]/", $in_string)) {
$colalias = "column" . $in_colno;
$auto_gen_alias = $colalias;
if ($warn_empty_aliases) {
ReporticoApp::handleDebug("Expression <b>($in_string)</b> is unnamed and will be given the name <b>$colalias</b>. You might like to provide your own column alias for this expression.", 0);
}
}
$colname = $in_string;
$colexp = $in_string;
}
// Now with what's left of the column try to ascertain a table name
// and column part
if (preg_match("/^(\w+)\.(\w+)$/", $colname, $out_match)) {
$coltable = $out_match[1];
$colname = $out_match[2];
}
$this->columns[] = array(
"name" => $colname,
"table" => $coltable,
"alias" => $colalias,
"expression" => $colexp,
)
;
return true;
} | [
"public",
"function",
"parseColumn",
"(",
"$",
"in_colno",
",",
"$",
"in_string",
",",
"&",
"$",
"auto_gen_alias",
",",
"$",
"warn_empty_aliases",
")",
"{",
"$",
"err",
"=",
"false",
";",
"$",
"colalias",
"=",
"\"\"",
";",
"$",
"colname",
"=",
"\"\"",
... | ---------------------------------------------------------------------------- | [
"----------------------------------------------------------------------------"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/SqlParser.php#L442-L525 |
reportico-web/reportico | src/ReporticoUtility.php | ReporticoUtility.findFileToInclude | static function findFileToInclude($file_path, &$new_file_path, &$rel_to_include = "")
{
// First look in path of current file
static $_path_array = null;
if (__DIR__) {
$selfdir = dirname(__DIR__);
$new_file_path = $selfdir . "/" . $file_path;
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler", 0);
if (@file_exists($new_file_path) || is_dir($new_file_path)) {
$new_file_path = $selfdir . "/" . $file_path;
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");
return true;
}
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");
}
// else look in incude path
if (!isset($_path_array)) {
$_ini_include_path = get_include_path();
if (defined("__DIR __")) {
$selfdir = dirname(__DIR__);
} else {
$selfdir = dirname(dirname(__FILE__));
}
if (strstr($_ini_include_path, ';')) {
$_ini_include_path = $selfdir . ";" . $_ini_include_path;
$_path_array = explode(';', $_ini_include_path);
} else {
$_ini_include_path = $selfdir . ":" . $_ini_include_path;
$_path_array = explode(':', $_ini_include_path);
}
}
// Turn off Error handling for the following to avoid open_basedir errors
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler", 0);
foreach ($_path_array as $_include_path) {
if (@file_exists($_include_path . "/" . $file_path)) {
$new_file_path = $_include_path . "/" . $file_path;
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");
return true;
}
}
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");
$new_file_path = $file_path;
return false;
} | php | static function findFileToInclude($file_path, &$new_file_path, &$rel_to_include = "")
{
// First look in path of current file
static $_path_array = null;
if (__DIR__) {
$selfdir = dirname(__DIR__);
$new_file_path = $selfdir . "/" . $file_path;
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler", 0);
if (@file_exists($new_file_path) || is_dir($new_file_path)) {
$new_file_path = $selfdir . "/" . $file_path;
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");
return true;
}
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");
}
// else look in incude path
if (!isset($_path_array)) {
$_ini_include_path = get_include_path();
if (defined("__DIR __")) {
$selfdir = dirname(__DIR__);
} else {
$selfdir = dirname(dirname(__FILE__));
}
if (strstr($_ini_include_path, ';')) {
$_ini_include_path = $selfdir . ";" . $_ini_include_path;
$_path_array = explode(';', $_ini_include_path);
} else {
$_ini_include_path = $selfdir . ":" . $_ini_include_path;
$_path_array = explode(':', $_ini_include_path);
}
}
// Turn off Error handling for the following to avoid open_basedir errors
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler", 0);
foreach ($_path_array as $_include_path) {
if (@file_exists($_include_path . "/" . $file_path)) {
$new_file_path = $_include_path . "/" . $file_path;
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");
return true;
}
}
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");
$new_file_path = $file_path;
return false;
} | [
"static",
"function",
"findFileToInclude",
"(",
"$",
"file_path",
",",
"&",
"$",
"new_file_path",
",",
"&",
"$",
"rel_to_include",
"=",
"\"\"",
")",
"{",
"// First look in path of current file",
"static",
"$",
"_path_array",
"=",
"null",
";",
"if",
"(",
"__DIR__... | Look for a file in the include path, or the path of the current source file | [
"Look",
"for",
"a",
"file",
"in",
"the",
"include",
"path",
"or",
"the",
"path",
"of",
"the",
"current",
"source",
"file"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoUtility.php#L152-L199 |
reportico-web/reportico | src/ReporticoUtility.php | ReporticoUtility.PathExecutable | static function PathExecutable($in_path)
{
$perms = fileperms($in_path);
if (!is_dir($in_path)) {
return false;
}
if (!strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' && is_executable($in_path)) {
return false;
}
if (!is_writeable($in_path)) {
return false;
}
return true;
} | php | static function PathExecutable($in_path)
{
$perms = fileperms($in_path);
if (!is_dir($in_path)) {
return false;
}
if (!strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' && is_executable($in_path)) {
return false;
}
if (!is_writeable($in_path)) {
return false;
}
return true;
} | [
"static",
"function",
"PathExecutable",
"(",
"$",
"in_path",
")",
"{",
"$",
"perms",
"=",
"fileperms",
"(",
"$",
"in_path",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"in_path",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"strtou... | Is path executable and writeable? | [
"Is",
"path",
"executable",
"and",
"writeable?"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoUtility.php#L202-L219 |
reportico-web/reportico | src/ReporticoUtility.php | ReporticoUtility.findBestUrlInIncludePath | static function findBestUrlInIncludePath($path)
{
$newpath = $path;
$reltoinclude;
//if ( !is_file ( $newpath ) && !is_dir ( $newpath ) )
//{
$found = self::findFileToInclude($newpath, $newpath, $reltoinclude);
$newpath = self::getRelativePath(str_replace("/", "\\", realpath($newpath)), dirname(__DIR__));
if (!$found) {
return false;
}
//}
return $newpath;
} | php | static function findBestUrlInIncludePath($path)
{
$newpath = $path;
$reltoinclude;
//if ( !is_file ( $newpath ) && !is_dir ( $newpath ) )
//{
$found = self::findFileToInclude($newpath, $newpath, $reltoinclude);
$newpath = self::getRelativePath(str_replace("/", "\\", realpath($newpath)), dirname(__DIR__));
if (!$found) {
return false;
}
//}
return $newpath;
} | [
"static",
"function",
"findBestUrlInIncludePath",
"(",
"$",
"path",
")",
"{",
"$",
"newpath",
"=",
"$",
"path",
";",
"$",
"reltoinclude",
";",
"//if ( !is_file ( $newpath ) && !is_dir ( $newpath ) )",
"//{",
"$",
"found",
"=",
"self",
"::",
"findFileToInclude",
"(",... | of a file path | [
"of",
"a",
"file",
"path"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoUtility.php#L223-L237 |
reportico-web/reportico | src/ReporticoUtility.php | ReporticoUtility.buildForwardUrlGetParams | static function buildForwardUrlGetParams($path, $forward_url_get_params, $remainder)
{
$urlpath = findBestLocationInIncludePath($path);
if ($forward_url_get_params || $remainder) {
$urlpath .= "?";
}
if ($forward_url_get_params) {
$urlpath .= $forward_url_get_params;
}
if ($remainder) {
$urlpath .= "&";
}
if ($remainder) {
$urlpath .= $remainder;
}
return $urlpath;
} | php | static function buildForwardUrlGetParams($path, $forward_url_get_params, $remainder)
{
$urlpath = findBestLocationInIncludePath($path);
if ($forward_url_get_params || $remainder) {
$urlpath .= "?";
}
if ($forward_url_get_params) {
$urlpath .= $forward_url_get_params;
}
if ($remainder) {
$urlpath .= "&";
}
if ($remainder) {
$urlpath .= $remainder;
}
return $urlpath;
} | [
"static",
"function",
"buildForwardUrlGetParams",
"(",
"$",
"path",
",",
"$",
"forward_url_get_params",
",",
"$",
"remainder",
")",
"{",
"$",
"urlpath",
"=",
"findBestLocationInIncludePath",
"(",
"$",
"path",
")",
";",
"if",
"(",
"$",
"forward_url_get_params",
"... | 2 - extra GET parameters | [
"2",
"-",
"extra",
"GET",
"parameters"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoUtility.php#L264-L285 |
reportico-web/reportico | src/ReporticoUtility.php | ReporticoUtility.getReporticoUrlPath | static function getReporticoUrlPath()
{
$sessionClass = ReporticoSession();
//$found = ReporticoUtility::findFileToInclude($newpath, $newpath, $reltoinclude);
$newpath = __DIR__;
$newpath = ReporticoUtility::getRelativePath(str_replace("/", "\\", realpath($newpath)), dirname(realpath($_SERVER["SCRIPT_FILENAME"])));
$above = dirname($_SERVER["SCRIPT_NAME"]);
if ($above == "/") {
$above = "";
}
$url_path = $above . "/" . $sessionClass::sessionRequestItem('reporticourl', dirname($newpath));
// If reportico source files are installed in root directory or in some other
// scenarios such as an invalid linkbaseurl parameter the dirname of the
// the reportico files returns just a slash (backslash on windows) so
// return a true path
if ($url_path == "/" || $url_path == "\\") {
$url_path = "/";
} else {
$url_path = $url_path . "/";
}
return $url_path;
} | php | static function getReporticoUrlPath()
{
$sessionClass = ReporticoSession();
//$found = ReporticoUtility::findFileToInclude($newpath, $newpath, $reltoinclude);
$newpath = __DIR__;
$newpath = ReporticoUtility::getRelativePath(str_replace("/", "\\", realpath($newpath)), dirname(realpath($_SERVER["SCRIPT_FILENAME"])));
$above = dirname($_SERVER["SCRIPT_NAME"]);
if ($above == "/") {
$above = "";
}
$url_path = $above . "/" . $sessionClass::sessionRequestItem('reporticourl', dirname($newpath));
// If reportico source files are installed in root directory or in some other
// scenarios such as an invalid linkbaseurl parameter the dirname of the
// the reportico files returns just a slash (backslash on windows) so
// return a true path
if ($url_path == "/" || $url_path == "\\") {
$url_path = "/";
} else {
$url_path = $url_path . "/";
}
return $url_path;
} | [
"static",
"function",
"getReporticoUrlPath",
"(",
")",
"{",
"$",
"sessionClass",
"=",
"ReporticoSession",
"(",
")",
";",
"//$found = ReporticoUtility::findFileToInclude($newpath, $newpath, $reltoinclude);",
"$",
"newpath",
"=",
"__DIR__",
";",
"$",
"newpath",
"=",
"Report... | This can be used to then find reportico images, links, runners etc | [
"This",
"can",
"be",
"used",
"to",
"then",
"find",
"reportico",
"images",
"links",
"runners",
"etc"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoUtility.php#L290-L315 |
reportico-web/reportico | src/ReporticoUtility.php | ReporticoUtility.getRelativePath | static function getRelativePath($path, $compareTo)
{
// On some windows machines the SCRIPT_FILENAME may be lower or upper case
// compared to the target path which could be lower, upper or a mixture
// so convert every thing lower for the comparison
// Work out if it's Windows by looking for a back slash or a leading
// driver specifier eg "C:"
if (preg_match("/\\\/", $compareTo) || preg_match("/^[A-Za-z]:/", $compareTo)) {
$compareTo = strtolower($compareTo);
$path = strtolower($path);
}
// Convert Windows paths with "\" delimiters to forward delimiters
$path = preg_replace("+\\\+", "/", $path);
$compareTo = preg_replace("+\\\+", "/", $compareTo);
// clean arguments by removing trailing and prefixing slashes
if (substr($path, -1) == '/') {
$path = substr($path, 0, -1);
}
if (substr($path, 0, 1) == '/') {
$path = substr($path, 1);
}
if (substr($compareTo, -1) == '/') {
$compareTo = substr($compareTo, 0, -1);
}
if (substr($compareTo, 0, 1) == '/') {
$compareTo = substr($compareTo, 1);
}
// simple case: $compareTo is in $path
if (strpos($path, $compareTo) === 0) {
$offset = strlen($compareTo) + 1;
return substr($path, $offset);
}
$relative = array();
$pathParts = explode('/', $path);
$compareToParts = explode('/', $compareTo);
foreach ($compareToParts as $index => $part) {
if (isset($pathParts[$index]) && $pathParts[$index] == $part) {
continue;
}
$relative[] = '..';
}
foreach ($pathParts as $index => $part) {
if (isset($compareToParts[$index]) && $compareToParts[$index] == $part) {
continue;
}
$relative[] = $part;
}
return implode('/', $relative);
} | php | static function getRelativePath($path, $compareTo)
{
// On some windows machines the SCRIPT_FILENAME may be lower or upper case
// compared to the target path which could be lower, upper or a mixture
// so convert every thing lower for the comparison
// Work out if it's Windows by looking for a back slash or a leading
// driver specifier eg "C:"
if (preg_match("/\\\/", $compareTo) || preg_match("/^[A-Za-z]:/", $compareTo)) {
$compareTo = strtolower($compareTo);
$path = strtolower($path);
}
// Convert Windows paths with "\" delimiters to forward delimiters
$path = preg_replace("+\\\+", "/", $path);
$compareTo = preg_replace("+\\\+", "/", $compareTo);
// clean arguments by removing trailing and prefixing slashes
if (substr($path, -1) == '/') {
$path = substr($path, 0, -1);
}
if (substr($path, 0, 1) == '/') {
$path = substr($path, 1);
}
if (substr($compareTo, -1) == '/') {
$compareTo = substr($compareTo, 0, -1);
}
if (substr($compareTo, 0, 1) == '/') {
$compareTo = substr($compareTo, 1);
}
// simple case: $compareTo is in $path
if (strpos($path, $compareTo) === 0) {
$offset = strlen($compareTo) + 1;
return substr($path, $offset);
}
$relative = array();
$pathParts = explode('/', $path);
$compareToParts = explode('/', $compareTo);
foreach ($compareToParts as $index => $part) {
if (isset($pathParts[$index]) && $pathParts[$index] == $part) {
continue;
}
$relative[] = '..';
}
foreach ($pathParts as $index => $part) {
if (isset($compareToParts[$index]) && $compareToParts[$index] == $part) {
continue;
}
$relative[] = $part;
}
return implode('/', $relative);
} | [
"static",
"function",
"getRelativePath",
"(",
"$",
"path",
",",
"$",
"compareTo",
")",
"{",
"// On some windows machines the SCRIPT_FILENAME may be lower or upper case",
"// compared to the target path which could be lower, upper or a mixture",
"// so convert every thing lower for the comp... | of the calling script so we can get the relative location | [
"of",
"the",
"calling",
"script",
"so",
"we",
"can",
"get",
"the",
"relative",
"location"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoUtility.php#L319-L379 |
reportico-web/reportico | src/ReporticoUtility.php | ReporticoUtility.htmltorgbPchart | static function htmltorgbPchart($color)
{
if (is_array($color)) {
return $color;
}
if ($color[0] == '#') {
$color = substr($color, 1);
}
if (strlen($color) == 6) {
list($r, $g, $b) = array($color[0] . $color[1],
$color[2] . $color[3],
$color[4] . $color[5]);
} elseif (strlen($color) == 3) {
list($r, $g, $b) = array($color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2]);
} else {
return array("R" => 0, "G" => 0, "B" => 0);
}
$r = hexdec($r);
$g = hexdec($g);
$b = hexdec($b);
return array("R" => $r, "G" => $g, "B" => $b);
} | php | static function htmltorgbPchart($color)
{
if (is_array($color)) {
return $color;
}
if ($color[0] == '#') {
$color = substr($color, 1);
}
if (strlen($color) == 6) {
list($r, $g, $b) = array($color[0] . $color[1],
$color[2] . $color[3],
$color[4] . $color[5]);
} elseif (strlen($color) == 3) {
list($r, $g, $b) = array($color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2]);
} else {
return array("R" => 0, "G" => 0, "B" => 0);
}
$r = hexdec($r);
$g = hexdec($g);
$b = hexdec($b);
return array("R" => $r, "G" => $g, "B" => $b);
} | [
"static",
"function",
"htmltorgbPchart",
"(",
"$",
"color",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"color",
")",
")",
"{",
"return",
"$",
"color",
";",
"}",
"if",
"(",
"$",
"color",
"[",
"0",
"]",
"==",
"'#'",
")",
"{",
"$",
"color",
"=",
"... | Converts a string in HTML color format #rrggbb to an RGB array for use in pChart | [
"Converts",
"a",
"string",
"in",
"HTML",
"color",
"format",
"#rrggbb",
"to",
"an",
"RGB",
"array",
"for",
"use",
"in",
"pChart"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoUtility.php#L383-L408 |
reportico-web/reportico | src/ReporticoUtility.php | ReporticoUtility.& | static function &loadExistingReport($reportfile, $projects_folder = "projects")
{
$q = new Reportico();
$q->reports_path = $projects_folder . "/" . ReporticoApp::getconfig("project");
$q->projects_folder = $projects_folder;
$reader = new XmlReader ($q, $reportfile, false);
$reader->xml2query();
return $q;
} | php | static function &loadExistingReport($reportfile, $projects_folder = "projects")
{
$q = new Reportico();
$q->reports_path = $projects_folder . "/" . ReporticoApp::getconfig("project");
$q->projects_folder = $projects_folder;
$reader = new XmlReader ($q, $reportfile, false);
$reader->xml2query();
return $q;
} | [
"static",
"function",
"&",
"loadExistingReport",
"(",
"$",
"reportfile",
",",
"$",
"projects_folder",
"=",
"\"projects\"",
")",
"{",
"$",
"q",
"=",
"new",
"Reportico",
"(",
")",
";",
"$",
"q",
"->",
"reports_path",
"=",
"$",
"projects_folder",
".",
"\"/\""... | @brief Loads an existing report in to a reportico class instance
@param $reportfile
@param string $projects_folder
@return Reportico | [
"@brief",
"Loads",
"an",
"existing",
"report",
"in",
"to",
"a",
"reportico",
"class",
"instance"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoUtility.php#L446-L456 |
reportico-web/reportico | src/ReporticoUtility.php | ReporticoUtility.columnNameToLabel | static function columnNameToLabel($columnname)
{
$retstring = str_replace("_", " ", $columnname);
if (!function_exists("mb_strtolower")) {
$retstring = ucwords(strtolower($retstring));
} else {
$retstring = ucwords(mb_strtolower($retstring, ReporticoLocale::outputCharsetToPhpCharset(ReporticoApp::getConfig("output_encoding"))));
}
return $retstring;
} | php | static function columnNameToLabel($columnname)
{
$retstring = str_replace("_", " ", $columnname);
if (!function_exists("mb_strtolower")) {
$retstring = ucwords(strtolower($retstring));
} else {
$retstring = ucwords(mb_strtolower($retstring, ReporticoLocale::outputCharsetToPhpCharset(ReporticoApp::getConfig("output_encoding"))));
}
return $retstring;
} | [
"static",
"function",
"columnNameToLabel",
"(",
"$",
"columnname",
")",
"{",
"$",
"retstring",
"=",
"str_replace",
"(",
"\"_\"",
",",
"\" \"",
",",
"$",
"columnname",
")",
";",
"if",
"(",
"!",
"function_exists",
"(",
"\"mb_strtolower\"",
")",
")",
"{",
"$"... | initial letter of each word | [
"initial",
"letter",
"of",
"each",
"word"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoUtility.php#L461-L471 |
reportico-web/reportico | src/Assignment.php | Assignment.reporticoLookupStringToPhp | public function reporticoLookupStringToPhp($in_string)
{
$out_string = preg_replace('/{([^}]*)}/',
'\"".$this->lookup_queries[\'\1\']->column_value."\"',
$in_string);
$cmd = '$out_string = "' . $out_string . '";';
// echo "==$cmd===";
eval($cmd);
return $out_string;
} | php | public function reporticoLookupStringToPhp($in_string)
{
$out_string = preg_replace('/{([^}]*)}/',
'\"".$this->lookup_queries[\'\1\']->column_value."\"',
$in_string);
$cmd = '$out_string = "' . $out_string . '";';
// echo "==$cmd===";
eval($cmd);
return $out_string;
} | [
"public",
"function",
"reporticoLookupStringToPhp",
"(",
"$",
"in_string",
")",
"{",
"$",
"out_string",
"=",
"preg_replace",
"(",
"'/{([^}]*)}/'",
",",
"'\\\"\".$this->lookup_queries[\\'\\1\\']->column_value.\"\\\"'",
",",
"$",
"in_string",
")",
";",
"$",
"cmd",
"=",
... | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/Assignment.php#L35-L45 |
reportico-web/reportico | src/Assignment.php | Assignment.reporticoMetaSqlCriteria | public static function reporticoMetaSqlCriteria(&$in_query, $in_string, $prev_col_value = false, $no_warnings = false, $execute_mode = "EXECUTE")
{
$sessionClass = ReporticoSession();
// Replace user parameters with values
$external_param1 = $sessionClass::getReporticoSessionParam("external_param1");
$external_param2 = $sessionClass::getReporticoSessionParam("external_param2");
$external_param3 = $sessionClass::getReporticoSessionParam("external_param3");
$external_user = $sessionClass::getReporticoSessionParam("external_user");
if ($external_param1) {
$in_string = preg_replace("/{EXTERNAL_PARAM1}/", "'" . $external_param1 . "'", $in_string);
}
if ($external_param2) {
$in_string = preg_replace("/{EXTERNAL_PARAM2}/", "'" . $external_param2 . "'", $in_string);
}
if ($external_param3) {
$in_string = preg_replace("/{EXTERNAL_PARAM3}/", "'" . $external_param3 . "'", $in_string);
}
if ($external_user) {
$in_string = preg_replace("/{FRAMEWORK_USER}/", "'" . $external_user . "'", $in_string);
}
if ($external_user) {
$in_string = preg_replace("/{USER}/", "'" . $external_user . "'", $in_string);
}
// Support for limesurvey prefix
if (isset($in_query->user_parameters["lime_"])) {
$in_string = preg_replace("/{lime_}/", $in_query->user_parameters["lime_"], $in_string);
$in_string = preg_replace("/{prefix}/", $in_query->user_parameters["lime_"], $in_string);
}
// Replace External parameters specified by {USER_PARAM,xxxxx}
if (preg_match_all("/{USER_PARAM,([^}]*)}/", $in_string, $matches)) {
foreach ($matches[0] as $k => $v) {
$param = $matches[1][$k];
if (isset($in_query->user_parameters[$param])) {
$in_string = preg_replace("/{USER_PARAM,$param}/", $in_query->user_parameters[$param], $in_string);
} else {
trigger_error("User parameter $param, specified but not provided to reportico", E_USER_ERROR);
}
}
}
$looping = true;
$out_string = $in_string;
$ct = 0;
while ($looping) {
$ct++;
if ($ct > 100) {
if (!$no_warnings) {
echo "Problem with SQL cannot resolve Criteria Items<br>";
}
break;
}
$regpat = "/{([^}]*)/";
if (preg_match($regpat, $out_string, $matches)) {
$crit = $matches[1];
$first = substr($crit, 0, 1);
$critexp = $crit;
if ($first == "=") {
$crit = substr($crit, 1);
$critexp = $crit;
$clause = "";
$label = "";
if (array_key_exists($crit, $in_query->lookup_queries)) {
$clause = $in_query->lookup_queries[$crit]->criteriaSummaryText($label, $clause);
} else if ($cl = ReporticoUtility::getQueryColumn($crit, $this->query->columns)) {
if ($prev_col_value) {
$clause = $cl->old_column_value;
} else {
$clause = $cl->column_value;
}
} else {
ReporticoApp::handleError("Un1known Criteria Item $crit in Query $in_string");
return $in_string;
}
} else {
$eltype = "VALUE";
$showquotes = true;
$surrounder = false;
if (preg_match("/([!])(.*)/", $crit, $critel)) {
$surrounder = $critel[1];
$crit = $critel[2];
}
if (preg_match("/(.*),(.*),(.*)/", $crit, $critel)) {
$crit = $critel[1];
$eltype = $critel[2];
if ($critel[3] == "false") {
$showquotes = false;
}
}
if (preg_match("/(.*);(.*);(.*)/", $crit, $critel)) {
$crit = $critel[1];
$eltype = $critel[2];
if ($critel[3] == "false") {
$showquotes = false;
}
}
if (preg_match("/(.*),(.*)/", $crit, $critel)) {
$crit = $critel[1];
if ($critel[2] == "false") {
$showquotes = false;
} else {
$eltype = $critel[2];
}
}
if ($surrounder == "!") {
$showquotes = false;
}
if (array_key_exists($crit, $in_query->lookup_queries)) {
switch ($eltype) {
case "FULL":
$clause = $in_query->lookup_queries[$crit]->getCriteriaClause(true, true, true, false, false, $showquotes);
break;
case "RANGE1":
$clause = $in_query->lookup_queries[$crit]->getCriteriaClause(false, false, false, true, false, $showquotes);
break;
case "RANGE2":
$clause = $in_query->lookup_queries[$crit]->getCriteriaClause(false, false, false, false, true, $showquotes);
break;
case "VALUE":
default:
$clause = $in_query->lookup_queries[$crit]->getCriteriaClause(false, false, true, false, false, $showquotes);
}
if ($execute_mode == "MAINTAIN" && !$clause) {
$clause = "'DUMMY'";
}
} else if ($cl = ReporticoUtility::getQueryColumn($crit, $in_query->columns)) {
if ($prev_col_value) {
$clause = $cl->old_column_value;
} else {
$clause = $cl->column_value;
}
}
//else if ( strtoupper($crit) == "REPORT_TITLE" )
//{
//$clause = "go";
//}
else {
if ( !$no_warnings )
echo "Unknown Criteria Item $crit in Query $in_string";
//ReporticoApp::handleError( "Unknown Criteria Item $crit in Query $in_string");
return $in_string;
}
}
if (!$clause) {
$out_string = preg_replace("/\[[^[]*\{$critexp\}[^[]*\]/", '', $out_string);
} else {
$out_string = preg_replace("/\{=*$critexp\}/",
$clause,
$out_string);
$out_string = preg_replace("/\[\([^[]*\)\]/", "\1", $out_string);
}
} else {
$looping = false;
}
}
$out_string = preg_replace("/\[\[/", "<STARTBRACKET>", $out_string);
$out_string = preg_replace("/\]\]/", "<ENDBRACKET>", $out_string);
$out_string = preg_replace("/\[/", "", $out_string);
$out_string = preg_replace("/\]/", "", $out_string);
$out_string = preg_replace("/<STARTBRACKET>/", "[", $out_string);
$out_string = preg_replace("/<ENDBRACKET>/", "]", $out_string);
// echo "<br>Meta clause: $out_string<BR>";
//$out_string = addcslashes($out_string, "\"");
//$cmd = trim('$out_string = "'.$out_string.'";');
//echo $out_string;
//if ( $cmd )
//eval($cmd);
return $out_string;
} | php | public static function reporticoMetaSqlCriteria(&$in_query, $in_string, $prev_col_value = false, $no_warnings = false, $execute_mode = "EXECUTE")
{
$sessionClass = ReporticoSession();
// Replace user parameters with values
$external_param1 = $sessionClass::getReporticoSessionParam("external_param1");
$external_param2 = $sessionClass::getReporticoSessionParam("external_param2");
$external_param3 = $sessionClass::getReporticoSessionParam("external_param3");
$external_user = $sessionClass::getReporticoSessionParam("external_user");
if ($external_param1) {
$in_string = preg_replace("/{EXTERNAL_PARAM1}/", "'" . $external_param1 . "'", $in_string);
}
if ($external_param2) {
$in_string = preg_replace("/{EXTERNAL_PARAM2}/", "'" . $external_param2 . "'", $in_string);
}
if ($external_param3) {
$in_string = preg_replace("/{EXTERNAL_PARAM3}/", "'" . $external_param3 . "'", $in_string);
}
if ($external_user) {
$in_string = preg_replace("/{FRAMEWORK_USER}/", "'" . $external_user . "'", $in_string);
}
if ($external_user) {
$in_string = preg_replace("/{USER}/", "'" . $external_user . "'", $in_string);
}
// Support for limesurvey prefix
if (isset($in_query->user_parameters["lime_"])) {
$in_string = preg_replace("/{lime_}/", $in_query->user_parameters["lime_"], $in_string);
$in_string = preg_replace("/{prefix}/", $in_query->user_parameters["lime_"], $in_string);
}
// Replace External parameters specified by {USER_PARAM,xxxxx}
if (preg_match_all("/{USER_PARAM,([^}]*)}/", $in_string, $matches)) {
foreach ($matches[0] as $k => $v) {
$param = $matches[1][$k];
if (isset($in_query->user_parameters[$param])) {
$in_string = preg_replace("/{USER_PARAM,$param}/", $in_query->user_parameters[$param], $in_string);
} else {
trigger_error("User parameter $param, specified but not provided to reportico", E_USER_ERROR);
}
}
}
$looping = true;
$out_string = $in_string;
$ct = 0;
while ($looping) {
$ct++;
if ($ct > 100) {
if (!$no_warnings) {
echo "Problem with SQL cannot resolve Criteria Items<br>";
}
break;
}
$regpat = "/{([^}]*)/";
if (preg_match($regpat, $out_string, $matches)) {
$crit = $matches[1];
$first = substr($crit, 0, 1);
$critexp = $crit;
if ($first == "=") {
$crit = substr($crit, 1);
$critexp = $crit;
$clause = "";
$label = "";
if (array_key_exists($crit, $in_query->lookup_queries)) {
$clause = $in_query->lookup_queries[$crit]->criteriaSummaryText($label, $clause);
} else if ($cl = ReporticoUtility::getQueryColumn($crit, $this->query->columns)) {
if ($prev_col_value) {
$clause = $cl->old_column_value;
} else {
$clause = $cl->column_value;
}
} else {
ReporticoApp::handleError("Un1known Criteria Item $crit in Query $in_string");
return $in_string;
}
} else {
$eltype = "VALUE";
$showquotes = true;
$surrounder = false;
if (preg_match("/([!])(.*)/", $crit, $critel)) {
$surrounder = $critel[1];
$crit = $critel[2];
}
if (preg_match("/(.*),(.*),(.*)/", $crit, $critel)) {
$crit = $critel[1];
$eltype = $critel[2];
if ($critel[3] == "false") {
$showquotes = false;
}
}
if (preg_match("/(.*);(.*);(.*)/", $crit, $critel)) {
$crit = $critel[1];
$eltype = $critel[2];
if ($critel[3] == "false") {
$showquotes = false;
}
}
if (preg_match("/(.*),(.*)/", $crit, $critel)) {
$crit = $critel[1];
if ($critel[2] == "false") {
$showquotes = false;
} else {
$eltype = $critel[2];
}
}
if ($surrounder == "!") {
$showquotes = false;
}
if (array_key_exists($crit, $in_query->lookup_queries)) {
switch ($eltype) {
case "FULL":
$clause = $in_query->lookup_queries[$crit]->getCriteriaClause(true, true, true, false, false, $showquotes);
break;
case "RANGE1":
$clause = $in_query->lookup_queries[$crit]->getCriteriaClause(false, false, false, true, false, $showquotes);
break;
case "RANGE2":
$clause = $in_query->lookup_queries[$crit]->getCriteriaClause(false, false, false, false, true, $showquotes);
break;
case "VALUE":
default:
$clause = $in_query->lookup_queries[$crit]->getCriteriaClause(false, false, true, false, false, $showquotes);
}
if ($execute_mode == "MAINTAIN" && !$clause) {
$clause = "'DUMMY'";
}
} else if ($cl = ReporticoUtility::getQueryColumn($crit, $in_query->columns)) {
if ($prev_col_value) {
$clause = $cl->old_column_value;
} else {
$clause = $cl->column_value;
}
}
//else if ( strtoupper($crit) == "REPORT_TITLE" )
//{
//$clause = "go";
//}
else {
if ( !$no_warnings )
echo "Unknown Criteria Item $crit in Query $in_string";
//ReporticoApp::handleError( "Unknown Criteria Item $crit in Query $in_string");
return $in_string;
}
}
if (!$clause) {
$out_string = preg_replace("/\[[^[]*\{$critexp\}[^[]*\]/", '', $out_string);
} else {
$out_string = preg_replace("/\{=*$critexp\}/",
$clause,
$out_string);
$out_string = preg_replace("/\[\([^[]*\)\]/", "\1", $out_string);
}
} else {
$looping = false;
}
}
$out_string = preg_replace("/\[\[/", "<STARTBRACKET>", $out_string);
$out_string = preg_replace("/\]\]/", "<ENDBRACKET>", $out_string);
$out_string = preg_replace("/\[/", "", $out_string);
$out_string = preg_replace("/\]/", "", $out_string);
$out_string = preg_replace("/<STARTBRACKET>/", "[", $out_string);
$out_string = preg_replace("/<ENDBRACKET>/", "]", $out_string);
// echo "<br>Meta clause: $out_string<BR>";
//$out_string = addcslashes($out_string, "\"");
//$cmd = trim('$out_string = "'.$out_string.'";');
//echo $out_string;
//if ( $cmd )
//eval($cmd);
return $out_string;
} | [
"public",
"static",
"function",
"reporticoMetaSqlCriteria",
"(",
"&",
"$",
"in_query",
",",
"$",
"in_string",
",",
"$",
"prev_col_value",
"=",
"false",
",",
"$",
"no_warnings",
"=",
"false",
",",
"$",
"execute_mode",
"=",
"\"EXECUTE\"",
")",
"{",
"$",
"sessi... | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/Assignment.php#L50-L241 |
reportico-web/reportico | src/Assignment.php | Assignment.reporticoStringToPhp | public function reporticoStringToPhp($in_string)
{
// first change '(colval)' parameters
$out_string = $in_string;
$out_string = preg_replace('/{TARGET_STYLE}/',
'$this->target_style',
$out_string);
$out_string = preg_replace('/{TARGET_FORMAT}/',
'$this->target_format',
$out_string);
$out_string = preg_replace('/old\({([^}]*)},{([^}]*)}\)/',
'$this->old("\1")',
$out_string);
$out_string = preg_replace('/old\({([^}]*)}\)/',
'$this->old("\1")',
$out_string);
$out_string = preg_replace('/max\({([^}]*)},{([^}]*)}\)/',
'$this->max("\1","\2")',
$out_string);
$out_string = preg_replace('/max\({([^}]*)}\)/',
'$this->max("\1")',
$out_string);
$out_string = preg_replace('/min\({([^}]*)},{([^}]*)}\)/',
'$this->min("\1","\2")',
$out_string);
$out_string = preg_replace('/min\({([^}]*)}\)/',
'$this->min("\1")',
$out_string);
$out_string = preg_replace('/avg\({([^}]*)},{([^}]*)}\)/',
'$this->avg("\1","\2")',
$out_string);
$out_string = preg_replace('/avg\({([^}]*)}\)/',
'$this->avg("\1")',
$out_string);
$out_string = preg_replace('/sum\({([^}]*)},{([^}]*)}\)/',
'$this->sum("\1","\2")',
$out_string);
$out_string = preg_replace('/sum\({([^}]*)}\)/',
'$this->sum("\1")',
$out_string);
$out_string = preg_replace('/imagequery\(/',
'$this->imagequery(',
$out_string);
$out_string = preg_replace('/reset\({([^}]*)}\)/',
'$this->reset("\1")',
$out_string);
$out_string = preg_replace('/changed\({([^}]*)}\)/',
'$this->changed("\1")',
$out_string);
$out_string = preg_replace('/groupsum\({([^}]*)},{([^}]*)},{([^}]*)}\)/',
'$this->groupsum("\1","\2", "\3")',
$out_string);
//$out_string = preg_replace('/count\(\)/',
//'$this->query_count',
//$out_string);
$out_string = preg_replace('/lineno\({([^}]*)}\)/',
'$this->lineno("\1")',
$out_string);
if (preg_match('/skipline\(\)/', $out_string)) {
$this->non_assignment_operation = true;
$out_string = preg_replace('/skipline\(\)/',
'$this->skipline()',
$out_string);
}
// Backward compatibility for previous apply_style
if (preg_match('/apply_style\(.*\)/', $out_string)) {
$this->non_assignment_operation = true;
$out_string = preg_replace('/apply_style\(/',
'$this->applyStyle("' . $this->query_name . "\",", $out_string);
}
else
if (preg_match('/applyStyle\(.*\)/', $out_string)) {
$this->non_assignment_operation = true;
$out_string = preg_replace('/applyStyle\(/',
'$this->applyStyle("' . $this->query_name . "\",", $out_string);
}
if (preg_match('/embed_image\(.*\)/', $out_string)) {
$this->non_assignment_operation = true;
$out_string = preg_replace('/embed_image\(/',
'$this->embedImage("' . $this->query_name . "\",", $out_string);
}
if (preg_match('/embed_hyperlink\(.*\)/', $out_string)) {
$this->non_assignment_operation = true;
$out_string = preg_replace('/embed_hyperlink\(/',
'$this->embedHyperlink("' . $this->query_name . "\",", $out_string);
}
$out_string = preg_replace('/lineno\(\)/',
'$this->lineno()',
$out_string);
$out_string = preg_replace('/count\({([^}]*)}\)/',
'$this->lineno("\1")',
$out_string);
$out_string = preg_replace('/count\(\)/',
'$this->lineno()',
$out_string);
$out_string = preg_replace('/{([^}]*)}/',
//'$this->columns[\'\1\']->column_value',
'$this->getQueryColumnValue(\'\1\', $this->columns)',
$out_string);
return $out_string;
} | php | public function reporticoStringToPhp($in_string)
{
// first change '(colval)' parameters
$out_string = $in_string;
$out_string = preg_replace('/{TARGET_STYLE}/',
'$this->target_style',
$out_string);
$out_string = preg_replace('/{TARGET_FORMAT}/',
'$this->target_format',
$out_string);
$out_string = preg_replace('/old\({([^}]*)},{([^}]*)}\)/',
'$this->old("\1")',
$out_string);
$out_string = preg_replace('/old\({([^}]*)}\)/',
'$this->old("\1")',
$out_string);
$out_string = preg_replace('/max\({([^}]*)},{([^}]*)}\)/',
'$this->max("\1","\2")',
$out_string);
$out_string = preg_replace('/max\({([^}]*)}\)/',
'$this->max("\1")',
$out_string);
$out_string = preg_replace('/min\({([^}]*)},{([^}]*)}\)/',
'$this->min("\1","\2")',
$out_string);
$out_string = preg_replace('/min\({([^}]*)}\)/',
'$this->min("\1")',
$out_string);
$out_string = preg_replace('/avg\({([^}]*)},{([^}]*)}\)/',
'$this->avg("\1","\2")',
$out_string);
$out_string = preg_replace('/avg\({([^}]*)}\)/',
'$this->avg("\1")',
$out_string);
$out_string = preg_replace('/sum\({([^}]*)},{([^}]*)}\)/',
'$this->sum("\1","\2")',
$out_string);
$out_string = preg_replace('/sum\({([^}]*)}\)/',
'$this->sum("\1")',
$out_string);
$out_string = preg_replace('/imagequery\(/',
'$this->imagequery(',
$out_string);
$out_string = preg_replace('/reset\({([^}]*)}\)/',
'$this->reset("\1")',
$out_string);
$out_string = preg_replace('/changed\({([^}]*)}\)/',
'$this->changed("\1")',
$out_string);
$out_string = preg_replace('/groupsum\({([^}]*)},{([^}]*)},{([^}]*)}\)/',
'$this->groupsum("\1","\2", "\3")',
$out_string);
//$out_string = preg_replace('/count\(\)/',
//'$this->query_count',
//$out_string);
$out_string = preg_replace('/lineno\({([^}]*)}\)/',
'$this->lineno("\1")',
$out_string);
if (preg_match('/skipline\(\)/', $out_string)) {
$this->non_assignment_operation = true;
$out_string = preg_replace('/skipline\(\)/',
'$this->skipline()',
$out_string);
}
// Backward compatibility for previous apply_style
if (preg_match('/apply_style\(.*\)/', $out_string)) {
$this->non_assignment_operation = true;
$out_string = preg_replace('/apply_style\(/',
'$this->applyStyle("' . $this->query_name . "\",", $out_string);
}
else
if (preg_match('/applyStyle\(.*\)/', $out_string)) {
$this->non_assignment_operation = true;
$out_string = preg_replace('/applyStyle\(/',
'$this->applyStyle("' . $this->query_name . "\",", $out_string);
}
if (preg_match('/embed_image\(.*\)/', $out_string)) {
$this->non_assignment_operation = true;
$out_string = preg_replace('/embed_image\(/',
'$this->embedImage("' . $this->query_name . "\",", $out_string);
}
if (preg_match('/embed_hyperlink\(.*\)/', $out_string)) {
$this->non_assignment_operation = true;
$out_string = preg_replace('/embed_hyperlink\(/',
'$this->embedHyperlink("' . $this->query_name . "\",", $out_string);
}
$out_string = preg_replace('/lineno\(\)/',
'$this->lineno()',
$out_string);
$out_string = preg_replace('/count\({([^}]*)}\)/',
'$this->lineno("\1")',
$out_string);
$out_string = preg_replace('/count\(\)/',
'$this->lineno()',
$out_string);
$out_string = preg_replace('/{([^}]*)}/',
//'$this->columns[\'\1\']->column_value',
'$this->getQueryColumnValue(\'\1\', $this->columns)',
$out_string);
return $out_string;
} | [
"public",
"function",
"reporticoStringToPhp",
"(",
"$",
"in_string",
")",
"{",
"// first change '(colval)' parameters",
"$",
"out_string",
"=",
"$",
"in_string",
";",
"$",
"out_string",
"=",
"preg_replace",
"(",
"'/{TARGET_STYLE}/'",
",",
"'$this->target_style'",
",",
... | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/Assignment.php#L246-L372 |
reportico-web/reportico | src/ReporticoDataSource.php | ReporticoDataSource.getEncodingForDbDriver | public function getEncodingForDbDriver($in_db_driver, $in_encoding)
{
$out_encoding = $in_encoding;
if (!$in_encoding || $in_encoding == "None") {
return false;
}
// Get MySQL DB encoding value to use in "SET NAMES" SQL Command
if ($in_db_driver == "pdo_mysql") {
switch ($in_encoding) {
case "LATIN1":$out_encoding = 'latin1';
break;
case "GBK":$out_encoding = 'gbk';
break;
case "GBK2312":$out_encoding = 'gbk2312';
break;
case "UTF8":$out_encoding = 'utf8';
break;
case "LATIN1":$out_encoding = 'latin1';
break;
case "LATIN2":$out_encoding = 'latin2';
break;
case "LATIN5":$out_encoding = 'latin5';
break;
case "LATIN7":$out_encoding = 'latin7';
break;
case "EUC_JP":$out_encoding = 'ujis';
break;
case "EUC_KR":$out_encoding = 'euckr';
break;
case "GBK":$out_encoding = 'gbk';
break;
case "ISO_8859_7":$out_encoding = 'greek';
break;
case "ISO_8859_8":$out_encoding = 'hebrew';
break;
case "WIN1250":$out_encoding = 'cp1250';
break;
case "WIN1251":$out_encoding = 'cp1251';
break;
case "WIN1256":$out_encoding = 'cp1256';
break;
case "WIN1257":$out_encoding = 'cp1257';
break;
case "BIG5":$out_encoding = 'big5';
break;
case "EUCJPMS":$out_encoding = 'eucjpms';
break;
case "BINARY":$out_encoding = 'binary';
break;
case "CP850":$out_encoding = 'cp850';
break;
case "ARMSCII8":$out_encoding = 'armscii8';
break;
case "ASCII":$out_encoding = 'ascii';
break;
case "CP852":$out_encoding = 'cp852';
break;
case "CP866":$out_encoding = 'cp866';
break;
case "DEC8":$out_encoding = 'dec8';
break;
case "GB2312":$out_encoding = 'gb2312';
break;
case "GEOSTD8":$out_encoding = 'geostd8';
break;
case "HP8":$out_encoding = 'hp8';
break;
case "KEYBCS2":$out_encoding = 'keybcs2';
break;
case "KOI8U":$out_encoding = 'koi8u';
break;
case "MACCE":$out_encoding = 'macce';
break;
case "MACROMAN":$out_encoding = 'macroman';
break;
case "SWE7":$out_encoding = 'swe7';
break;
case "TIS620":$out_encoding = 'tis620';
break;
case "UCS2":$out_encoding = 'ucs2';
break;
default:$out_encoding = $in_encoding;
}
}
// Get PostgreSQL DB encoding value to use in "SET NAMES" SQL Command
if ($in_db_driver == "pdo_pgsql") {
switch ($in_encoding) {
case "UTF8":
case "LATIN1":
case "LATIN2":
case "LATIN3":
case "LATIN4":
case "LATIN5":
case "LATIN6":
case "LATIN7":
case "LATIN8":
case "LATIN9":
case "LATIN10":
case "EUC_CN":
case "EUC_JP":
case "EUC_KR":
case "EUC_TW":
case "GB18030":
case "GBK":
case "ISO_8859_5":
case "ISO_8859_6":
case "ISO_8859_7":
case "ISO_8859_8":
case "JOHAB":
case "KOI8":
case "MULE_INTERNAL":
case "SJIS":
case "SQL_ASCII":
case "UHC":
case "WIN866":
case "WIN874":
case "WIN1250":
case "WIN1251":
case "WIN1252":
case "WIN1253":
case "WIN1254":
case "WIN1255":
case "WIN1256":
case "WIN1257":
case "WIN1258":
case "BIG5":
$out_encoding = $in_encoding;
default:$out_encoding = false;
}
}
if ($in_db_driver == "pdo_mssql") {
switch ($in_encoding) {
case "UTF8":$out_encoding = 'UTF-8';
break;
default:$out_encoding = false;
}
}
return $out_encoding;
} | php | public function getEncodingForDbDriver($in_db_driver, $in_encoding)
{
$out_encoding = $in_encoding;
if (!$in_encoding || $in_encoding == "None") {
return false;
}
// Get MySQL DB encoding value to use in "SET NAMES" SQL Command
if ($in_db_driver == "pdo_mysql") {
switch ($in_encoding) {
case "LATIN1":$out_encoding = 'latin1';
break;
case "GBK":$out_encoding = 'gbk';
break;
case "GBK2312":$out_encoding = 'gbk2312';
break;
case "UTF8":$out_encoding = 'utf8';
break;
case "LATIN1":$out_encoding = 'latin1';
break;
case "LATIN2":$out_encoding = 'latin2';
break;
case "LATIN5":$out_encoding = 'latin5';
break;
case "LATIN7":$out_encoding = 'latin7';
break;
case "EUC_JP":$out_encoding = 'ujis';
break;
case "EUC_KR":$out_encoding = 'euckr';
break;
case "GBK":$out_encoding = 'gbk';
break;
case "ISO_8859_7":$out_encoding = 'greek';
break;
case "ISO_8859_8":$out_encoding = 'hebrew';
break;
case "WIN1250":$out_encoding = 'cp1250';
break;
case "WIN1251":$out_encoding = 'cp1251';
break;
case "WIN1256":$out_encoding = 'cp1256';
break;
case "WIN1257":$out_encoding = 'cp1257';
break;
case "BIG5":$out_encoding = 'big5';
break;
case "EUCJPMS":$out_encoding = 'eucjpms';
break;
case "BINARY":$out_encoding = 'binary';
break;
case "CP850":$out_encoding = 'cp850';
break;
case "ARMSCII8":$out_encoding = 'armscii8';
break;
case "ASCII":$out_encoding = 'ascii';
break;
case "CP852":$out_encoding = 'cp852';
break;
case "CP866":$out_encoding = 'cp866';
break;
case "DEC8":$out_encoding = 'dec8';
break;
case "GB2312":$out_encoding = 'gb2312';
break;
case "GEOSTD8":$out_encoding = 'geostd8';
break;
case "HP8":$out_encoding = 'hp8';
break;
case "KEYBCS2":$out_encoding = 'keybcs2';
break;
case "KOI8U":$out_encoding = 'koi8u';
break;
case "MACCE":$out_encoding = 'macce';
break;
case "MACROMAN":$out_encoding = 'macroman';
break;
case "SWE7":$out_encoding = 'swe7';
break;
case "TIS620":$out_encoding = 'tis620';
break;
case "UCS2":$out_encoding = 'ucs2';
break;
default:$out_encoding = $in_encoding;
}
}
// Get PostgreSQL DB encoding value to use in "SET NAMES" SQL Command
if ($in_db_driver == "pdo_pgsql") {
switch ($in_encoding) {
case "UTF8":
case "LATIN1":
case "LATIN2":
case "LATIN3":
case "LATIN4":
case "LATIN5":
case "LATIN6":
case "LATIN7":
case "LATIN8":
case "LATIN9":
case "LATIN10":
case "EUC_CN":
case "EUC_JP":
case "EUC_KR":
case "EUC_TW":
case "GB18030":
case "GBK":
case "ISO_8859_5":
case "ISO_8859_6":
case "ISO_8859_7":
case "ISO_8859_8":
case "JOHAB":
case "KOI8":
case "MULE_INTERNAL":
case "SJIS":
case "SQL_ASCII":
case "UHC":
case "WIN866":
case "WIN874":
case "WIN1250":
case "WIN1251":
case "WIN1252":
case "WIN1253":
case "WIN1254":
case "WIN1255":
case "WIN1256":
case "WIN1257":
case "WIN1258":
case "BIG5":
$out_encoding = $in_encoding;
default:$out_encoding = false;
}
}
if ($in_db_driver == "pdo_mssql") {
switch ($in_encoding) {
case "UTF8":$out_encoding = 'UTF-8';
break;
default:$out_encoding = false;
}
}
return $out_encoding;
} | [
"public",
"function",
"getEncodingForDbDriver",
"(",
"$",
"in_db_driver",
",",
"$",
"in_encoding",
")",
"{",
"$",
"out_encoding",
"=",
"$",
"in_encoding",
";",
"if",
"(",
"!",
"$",
"in_encoding",
"||",
"$",
"in_encoding",
"==",
"\"None\"",
")",
"{",
"return"... | Gets database specific represenation of encoding value based on project encoding | [
"Gets",
"database",
"specific",
"represenation",
"of",
"encoding",
"value",
"based",
"on",
"project",
"encoding"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoDataSource.php#L87-L229 |
reportico-web/reportico | src/ReporticoDataSource.php | ReporticoDataSource.pdoDriverExists | public function pdoDriverExists($in_driver)
{
$drivers = PDO::getAvailableDrivers();
$found = false;
foreach ($drivers as $v) {
if ($v == $in_driver) {
$found = true;
break;
}
}
return $found;
} | php | public function pdoDriverExists($in_driver)
{
$drivers = PDO::getAvailableDrivers();
$found = false;
foreach ($drivers as $v) {
if ($v == $in_driver) {
$found = true;
break;
}
}
return $found;
} | [
"public",
"function",
"pdoDriverExists",
"(",
"$",
"in_driver",
")",
"{",
"$",
"drivers",
"=",
"PDO",
"::",
"getAvailableDrivers",
"(",
")",
";",
"$",
"found",
"=",
"false",
";",
"foreach",
"(",
"$",
"drivers",
"as",
"$",
"v",
")",
"{",
"if",
"(",
"$... | Checks if request pdo driver exists | [
"Checks",
"if",
"request",
"pdo",
"driver",
"exists"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoDataSource.php#L290-L301 |
reportico-web/reportico | src/ReportFPDF.php | ReportFPDF.setDefaultStyles | public function setDefaultStyles()
{
Report::setDefaultStyles();
// Default column headers to underlined if not specified
if (!$this->query->output_header_styles) {
$this->query->output_header_styles["border-style"] = "solid";
$this->query->output_header_styles["border-width"] = "0 0 1 0";
$this->query->output_header_styles["border-color"] = array(0, 0, 0);
}
if (!$this->query->output_before_form_row_styles) {
$this->query->output_before_form_row_styles["border-style"] = "solid";
$this->query->output_before_form_row_styles["border-width"] = "0 0 0 0";
$this->query->output_before_form_row_styles["border-color"] = array(0, 0, 0);
}
if (!$this->query->output_after_form_row_styles) {
$this->query->output_after_form_row_styles["border-style"] = "solid";
$this->query->output_after_form_row_styles["border-width"] = "1 0 0 0";
$this->query->output_after_form_row_styles["border-color"] = array(0, 0, 0);
}
if (!$this->query->output_group_trailer_styles) {
$this->query->output_group_trailer_styles["border-style"] = "solid";
$this->query->output_group_trailer_styles["border-width"] = "1 0 1 0";
$this->query->output_group_trailer_styles["border-color"] = array(0, 0, 0);
}
// Turn off page header and body background as its too complicated for now
if (isset($this->query->output_reportbody_styles["background-color"])) {
unset($this->query->output_reportbody_styles["background-color"]);
}
if (isset($this->query->output_page_styles["background-color"])) {
unset($this->query->output_page_styles["background-color"]);
}
} | php | public function setDefaultStyles()
{
Report::setDefaultStyles();
// Default column headers to underlined if not specified
if (!$this->query->output_header_styles) {
$this->query->output_header_styles["border-style"] = "solid";
$this->query->output_header_styles["border-width"] = "0 0 1 0";
$this->query->output_header_styles["border-color"] = array(0, 0, 0);
}
if (!$this->query->output_before_form_row_styles) {
$this->query->output_before_form_row_styles["border-style"] = "solid";
$this->query->output_before_form_row_styles["border-width"] = "0 0 0 0";
$this->query->output_before_form_row_styles["border-color"] = array(0, 0, 0);
}
if (!$this->query->output_after_form_row_styles) {
$this->query->output_after_form_row_styles["border-style"] = "solid";
$this->query->output_after_form_row_styles["border-width"] = "1 0 0 0";
$this->query->output_after_form_row_styles["border-color"] = array(0, 0, 0);
}
if (!$this->query->output_group_trailer_styles) {
$this->query->output_group_trailer_styles["border-style"] = "solid";
$this->query->output_group_trailer_styles["border-width"] = "1 0 1 0";
$this->query->output_group_trailer_styles["border-color"] = array(0, 0, 0);
}
// Turn off page header and body background as its too complicated for now
if (isset($this->query->output_reportbody_styles["background-color"])) {
unset($this->query->output_reportbody_styles["background-color"]);
}
if (isset($this->query->output_page_styles["background-color"])) {
unset($this->query->output_page_styles["background-color"]);
}
} | [
"public",
"function",
"setDefaultStyles",
"(",
")",
"{",
"Report",
"::",
"setDefaultStyles",
"(",
")",
";",
"// Default column headers to underlined if not specified",
"if",
"(",
"!",
"$",
"this",
"->",
"query",
"->",
"output_header_styles",
")",
"{",
"$",
"this",
... | For each line reset styles to default values | [
"For",
"each",
"line",
"reset",
"styles",
"to",
"default",
"values"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReportFPDF.php#L96-L134 |
reportico-web/reportico | src/ReportFPDF.php | ReportFPDF.drawCellContainer | public function drawCellContainer($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $valign = "T")
{
// Add padding
$padding = end($this->stylestack["padding"]);
$toppad = $padding[0];
$bottompad = $padding[2];
// Add border and bg color
$fill = end($this->stylestack["isfilling"]);
$borderwidth = end($this->stylestack["border-width"]);
$border = end($this->stylestack["border-style"]);
if ($border != "none") {
$border = 1;
} else {
$borderwidth = "false";
}
// Store current position so we can jump back after cell draw
$x = $this->document->GetX();
$y = $this->document->GetY();
$this->document->MultiCell($w, $this->max_line_height, "", $borderwidth, false, $fill);
$cell_height = $this->document->GetY() - $y;
// Jump back
$this->setPosition($x, $y);
} | php | public function drawCellContainer($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $valign = "T")
{
// Add padding
$padding = end($this->stylestack["padding"]);
$toppad = $padding[0];
$bottompad = $padding[2];
// Add border and bg color
$fill = end($this->stylestack["isfilling"]);
$borderwidth = end($this->stylestack["border-width"]);
$border = end($this->stylestack["border-style"]);
if ($border != "none") {
$border = 1;
} else {
$borderwidth = "false";
}
// Store current position so we can jump back after cell draw
$x = $this->document->GetX();
$y = $this->document->GetY();
$this->document->MultiCell($w, $this->max_line_height, "", $borderwidth, false, $fill);
$cell_height = $this->document->GetY() - $y;
// Jump back
$this->setPosition($x, $y);
} | [
"public",
"function",
"drawCellContainer",
"(",
"$",
"w",
",",
"$",
"h",
"=",
"0",
",",
"$",
"txt",
"=",
"''",
",",
"$",
"border",
"=",
"0",
",",
"$",
"ln",
"=",
"0",
",",
"$",
"align",
"=",
"''",
",",
"$",
"valign",
"=",
"\"T\"",
")",
"{",
... | Cell with horizontal scaling if text is too wide | [
"Cell",
"with",
"horizontal",
"scaling",
"if",
"text",
"is",
"too",
"wide"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReportFPDF.php#L544-L569 |
reportico-web/reportico | src/ReportFPDF.php | ReportFPDF.drawCell | public function drawCell($w, $h = 0, $txt = '', $implied_styles = "PBF", $ln = 0, $align = '', $valign = "T", $link = '')
{
// If a cell contains a line break like a "<BR>" then convert it to new line
$txt = preg_replace("/<BR>/i", "\n", $txt);
// Calculate cell height as string width divided by width
$str_width = $this->document->GetStringWidth($txt);
$numlines = ceil($this->document->GetStringWidth($txt) / ($w - 1));
$numlines = $this->document->NbLines($w, $txt);
$cellheight = ceil($numlines * $h);
if ($this->draw_mode == "CALCULATE") {
if ($cellheight > $this->calculated_line_height) {
$this->calculated_line_height = $cellheight;
}
}
// Add padding
$toppad = 0;
$bottompad = 0;
if (strstr($implied_styles, "P")) {
$padding = end($this->stylestack["padding"]);
$toppad = $padding[0];
$bottompad = $padding[2];
}
$fill = false;
if (strstr($implied_styles, "F")) {
// Add border and bg color
$fill = end($this->stylestack["isfilling"]);
}
$borderwidth = false;
if (strstr($implied_styles, "B")) {
$borderwidth = end($this->stylestack["border-width"]);
$border = end($this->stylestack["border-style"]);
if ($border != "none") {
$border = 1;
} else {
$borderwidth = "false";
}
}
// Store current position so we can jump back after cell draw
$y = $this->document->GetY();
// To cater for multiline values, jump to bottom of line + padding -
// cell height
if ($valign == "T") {
$jumpy = $toppad;
} else if ($valign == "B") {
$jumpy = $toppad + $this->calculated_line_height - $cellheight;
} else if ($valign == "C") {
$jumpy = (($toppad + $this->calculated_line_height + $bottompad) - $cellheight) / 2;
}
if ($this->draw_mode == "CALCULATE") {
$fill_line_height = $toppad + $this->calculated_line_height + $bottompad;
if ($this->max_line_height < $fill_line_height) {
$this->max_line_height = $fill_line_height;
}
return;
}
if ($toppad) {
$tmpborder = "";
if (preg_match("/T/", $borderwidth)) {
$tmpborder = preg_replace("/B/", "", $borderwidth);
$borderwidth = preg_replace("/T/", "", $borderwidth);
}
$prevx = $this->document->GetX();
$this->document->MultiCell($w, $toppad, "", $tmpborder, $align, $fill, $link);
$this->setPosition($prevx, false);
}
if ($bottompad) {
$tmpborder = "";
if (preg_match("/B/", $borderwidth)) {
$tmpborder = preg_replace("/T/", "", $borderwidth);
$borderwidth = preg_replace("/B/", "", $borderwidth);
}
$prevx = $this->document->GetX();
$this->document->MultiCell($w, $h + $bottompad, "", $tmpborder, $align, $fill, $link);
$this->setPosition($prevx, false);
}
$this->setPosition(false, $y + $jumpy);
// Link in a PDF must include a full URL contain http:// element
// drilldown link of web url can be relative .. so prepend required elements
if ($link) {
if (!preg_match("/^http:\/\//", $link) && !preg_match("/^\//", $link)) {
$link = "http://" . $_SERVER["HTTP_HOST"] . dirname($this->query->url_path_to_reportico_runner) . "/" . $link;
}
if (preg_match("/^\//", $link)) {
$link = ReporticoApp::getConfig("http_urlhost"). "/" . $link;
}
}
$this->document->MultiCell($w, $h, $txt, $borderwidth, $align, $fill, $link);
$cell_height = $this->document->GetY() - $y;
if ($cell_height > $this->current_line_height) {
$this->current_line_height = $cell_height;
}
// Jump back
$this->setPosition(false, $y);
} | php | public function drawCell($w, $h = 0, $txt = '', $implied_styles = "PBF", $ln = 0, $align = '', $valign = "T", $link = '')
{
// If a cell contains a line break like a "<BR>" then convert it to new line
$txt = preg_replace("/<BR>/i", "\n", $txt);
// Calculate cell height as string width divided by width
$str_width = $this->document->GetStringWidth($txt);
$numlines = ceil($this->document->GetStringWidth($txt) / ($w - 1));
$numlines = $this->document->NbLines($w, $txt);
$cellheight = ceil($numlines * $h);
if ($this->draw_mode == "CALCULATE") {
if ($cellheight > $this->calculated_line_height) {
$this->calculated_line_height = $cellheight;
}
}
// Add padding
$toppad = 0;
$bottompad = 0;
if (strstr($implied_styles, "P")) {
$padding = end($this->stylestack["padding"]);
$toppad = $padding[0];
$bottompad = $padding[2];
}
$fill = false;
if (strstr($implied_styles, "F")) {
// Add border and bg color
$fill = end($this->stylestack["isfilling"]);
}
$borderwidth = false;
if (strstr($implied_styles, "B")) {
$borderwidth = end($this->stylestack["border-width"]);
$border = end($this->stylestack["border-style"]);
if ($border != "none") {
$border = 1;
} else {
$borderwidth = "false";
}
}
// Store current position so we can jump back after cell draw
$y = $this->document->GetY();
// To cater for multiline values, jump to bottom of line + padding -
// cell height
if ($valign == "T") {
$jumpy = $toppad;
} else if ($valign == "B") {
$jumpy = $toppad + $this->calculated_line_height - $cellheight;
} else if ($valign == "C") {
$jumpy = (($toppad + $this->calculated_line_height + $bottompad) - $cellheight) / 2;
}
if ($this->draw_mode == "CALCULATE") {
$fill_line_height = $toppad + $this->calculated_line_height + $bottompad;
if ($this->max_line_height < $fill_line_height) {
$this->max_line_height = $fill_line_height;
}
return;
}
if ($toppad) {
$tmpborder = "";
if (preg_match("/T/", $borderwidth)) {
$tmpborder = preg_replace("/B/", "", $borderwidth);
$borderwidth = preg_replace("/T/", "", $borderwidth);
}
$prevx = $this->document->GetX();
$this->document->MultiCell($w, $toppad, "", $tmpborder, $align, $fill, $link);
$this->setPosition($prevx, false);
}
if ($bottompad) {
$tmpborder = "";
if (preg_match("/B/", $borderwidth)) {
$tmpborder = preg_replace("/T/", "", $borderwidth);
$borderwidth = preg_replace("/B/", "", $borderwidth);
}
$prevx = $this->document->GetX();
$this->document->MultiCell($w, $h + $bottompad, "", $tmpborder, $align, $fill, $link);
$this->setPosition($prevx, false);
}
$this->setPosition(false, $y + $jumpy);
// Link in a PDF must include a full URL contain http:// element
// drilldown link of web url can be relative .. so prepend required elements
if ($link) {
if (!preg_match("/^http:\/\//", $link) && !preg_match("/^\//", $link)) {
$link = "http://" . $_SERVER["HTTP_HOST"] . dirname($this->query->url_path_to_reportico_runner) . "/" . $link;
}
if (preg_match("/^\//", $link)) {
$link = ReporticoApp::getConfig("http_urlhost"). "/" . $link;
}
}
$this->document->MultiCell($w, $h, $txt, $borderwidth, $align, $fill, $link);
$cell_height = $this->document->GetY() - $y;
if ($cell_height > $this->current_line_height) {
$this->current_line_height = $cell_height;
}
// Jump back
$this->setPosition(false, $y);
} | [
"public",
"function",
"drawCell",
"(",
"$",
"w",
",",
"$",
"h",
"=",
"0",
",",
"$",
"txt",
"=",
"''",
",",
"$",
"implied_styles",
"=",
"\"PBF\"",
",",
"$",
"ln",
"=",
"0",
",",
"$",
"align",
"=",
"''",
",",
"$",
"valign",
"=",
"\"T\"",
",",
"... | Cell with horizontal scaling if text is too wide | [
"Cell",
"with",
"horizontal",
"scaling",
"if",
"text",
"is",
"too",
"wide"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReportFPDF.php#L572-L685 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.