_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q250900 | IOFactory.createReader | validation | public static function createReader($readerType)
{
if (!isset(self::$readers[$readerType])) {
throw new Reader\Exception("No reader found for type $readerType");
}
// Instantiate reader
$className = self::$readers[$readerType];
$reader = new $className();
return $reader;
} | php | {
"resource": ""
} |
q250901 | IOFactory.identify | validation | public static function identify($pFilename)
{
$reader = self::createReaderForFile($pFilename);
$className = get_class($reader);
$classType = explode('\\', $className);
unset($reader);
return array_pop($classType);
} | php | {
"resource": ""
} |
q250902 | IOFactory.createReaderForFile | validation | public static function createReaderForFile($filename)
{
File::assertFile($filename);
// First, lucky guess by inspecting file extension
$guessedReader = self::getReaderTypeFromExtension($filename);
if ($guessedReader !== null) {
$reader = self::createReader($guessedReader);
// Let's see if we are lucky
if (isset($reader) && $reader->canRead($filename)) {
return $reader;
}
}
// If we reach here then "lucky guess" didn't give any result
// Try walking through all the options in self::$autoResolveClasses
foreach (self::$readers as $type => $class) {
// Ignore our original guess, we know that won't work
if ($type !== $guessedReader) {
$reader = self::createReader($type);
if ($reader->canRead($filename)) {
return $reader;
}
}
}
throw new Reader\Exception('Unable to identify a reader for this file');
} | php | {
"resource": ""
} |
q250903 | IOFactory.getReaderTypeFromExtension | validation | private static function getReaderTypeFromExtension($filename)
{
$pathinfo = pathinfo($filename);
if (!isset($pathinfo['extension'])) {
return null;
}
switch (strtolower($pathinfo['extension'])) {
case 'xlsx': // Excel (OfficeOpenXML) Spreadsheet
case 'xlsm': // Excel (OfficeOpenXML) Macro Spreadsheet (macros will be discarded)
case 'xltx': // Excel (OfficeOpenXML) Template
case 'xltm': // Excel (OfficeOpenXML) Macro Template (macros will be discarded)
return 'Xlsx';
case 'xls': // Excel (BIFF) Spreadsheet
case 'xlt': // Excel (BIFF) Template
return 'Xls';
case 'ods': // Open/Libre Offic Calc
case 'ots': // Open/Libre Offic Calc Template
return 'Ods';
case 'slk':
return 'Slk';
case 'xml': // Excel 2003 SpreadSheetML
return 'Xml';
case 'gnumeric':
return 'Gnumeric';
case 'htm':
case 'html':
return 'Html';
case 'csv':
// Do nothing
// We must not try to use CSV reader since it loads
// all files including Excel files etc.
return null;
default:
return null;
}
} | php | {
"resource": ""
} |
q250904 | IOFactory.registerWriter | validation | public static function registerWriter($writerType, $writerClass)
{
if (!is_a($writerClass, Writer\IWriter::class, true)) {
throw new Writer\Exception('Registered writers must implement ' . Writer\IWriter::class);
}
self::$writers[$writerType] = $writerClass;
} | php | {
"resource": ""
} |
q250905 | IOFactory.registerReader | validation | public static function registerReader($readerType, $readerClass)
{
if (!is_a($readerClass, Reader\IReader::class, true)) {
throw new Reader\Exception('Registered readers must implement ' . Reader\IReader::class);
}
self::$readers[$readerType] = $readerClass;
} | php | {
"resource": ""
} |
q250906 | Client.setHeader | validation | public function setHeader($header, $value)
{
if (strlen($header) < 1) {
throw new Exception('Header must be a string.');
}
$this->customHeaders[$header] = $value;
return $this;
} | php | {
"resource": ""
} |
q250907 | Style.writeFill | validation | private function writeFill(XMLWriter $objWriter, Fill $pFill)
{
// Check if this is a pattern type or gradient type
if ($pFill->getFillType() === Fill::FILL_GRADIENT_LINEAR ||
$pFill->getFillType() === Fill::FILL_GRADIENT_PATH) {
// Gradient fill
$this->writeGradientFill($objWriter, $pFill);
} elseif ($pFill->getFillType() !== null) {
// Pattern fill
$this->writePatternFill($objWriter, $pFill);
}
} | php | {
"resource": ""
} |
q250908 | Style.writeGradientFill | validation | private function writeGradientFill(XMLWriter $objWriter, Fill $pFill)
{
// fill
$objWriter->startElement('fill');
// gradientFill
$objWriter->startElement('gradientFill');
$objWriter->writeAttribute('type', $pFill->getFillType());
$objWriter->writeAttribute('degree', $pFill->getRotation());
// stop
$objWriter->startElement('stop');
$objWriter->writeAttribute('position', '0');
// color
$objWriter->startElement('color');
$objWriter->writeAttribute('rgb', $pFill->getStartColor()->getARGB());
$objWriter->endElement();
$objWriter->endElement();
// stop
$objWriter->startElement('stop');
$objWriter->writeAttribute('position', '1');
// color
$objWriter->startElement('color');
$objWriter->writeAttribute('rgb', $pFill->getEndColor()->getARGB());
$objWriter->endElement();
$objWriter->endElement();
$objWriter->endElement();
$objWriter->endElement();
} | php | {
"resource": ""
} |
q250909 | Style.writePatternFill | validation | private function writePatternFill(XMLWriter $objWriter, Fill $pFill)
{
// fill
$objWriter->startElement('fill');
// patternFill
$objWriter->startElement('patternFill');
$objWriter->writeAttribute('patternType', $pFill->getFillType());
if ($pFill->getFillType() !== Fill::FILL_NONE) {
// fgColor
if ($pFill->getStartColor()->getARGB()) {
$objWriter->startElement('fgColor');
$objWriter->writeAttribute('rgb', $pFill->getStartColor()->getARGB());
$objWriter->endElement();
}
}
if ($pFill->getFillType() !== Fill::FILL_NONE) {
// bgColor
if ($pFill->getEndColor()->getARGB()) {
$objWriter->startElement('bgColor');
$objWriter->writeAttribute('rgb', $pFill->getEndColor()->getARGB());
$objWriter->endElement();
}
}
$objWriter->endElement();
$objWriter->endElement();
} | php | {
"resource": ""
} |
q250910 | Style.writeFont | validation | private function writeFont(XMLWriter $objWriter, Font $pFont)
{
// font
$objWriter->startElement('font');
// Weird! The order of these elements actually makes a difference when opening Xlsx
// files in Excel2003 with the compatibility pack. It's not documented behaviour,
// and makes for a real WTF!
// Bold. We explicitly write this element also when false (like MS Office Excel 2007 does
// for conditional formatting). Otherwise it will apparently not be picked up in conditional
// formatting style dialog
if ($pFont->getBold() !== null) {
$objWriter->startElement('b');
$objWriter->writeAttribute('val', $pFont->getBold() ? '1' : '0');
$objWriter->endElement();
}
// Italic
if ($pFont->getItalic() !== null) {
$objWriter->startElement('i');
$objWriter->writeAttribute('val', $pFont->getItalic() ? '1' : '0');
$objWriter->endElement();
}
// Strikethrough
if ($pFont->getStrikethrough() !== null) {
$objWriter->startElement('strike');
$objWriter->writeAttribute('val', $pFont->getStrikethrough() ? '1' : '0');
$objWriter->endElement();
}
// Underline
if ($pFont->getUnderline() !== null) {
$objWriter->startElement('u');
$objWriter->writeAttribute('val', $pFont->getUnderline());
$objWriter->endElement();
}
// Superscript / subscript
if ($pFont->getSuperscript() === true || $pFont->getSubscript() === true) {
$objWriter->startElement('vertAlign');
if ($pFont->getSuperscript() === true) {
$objWriter->writeAttribute('val', 'superscript');
} elseif ($pFont->getSubscript() === true) {
$objWriter->writeAttribute('val', 'subscript');
}
$objWriter->endElement();
}
// Size
if ($pFont->getSize() !== null) {
$objWriter->startElement('sz');
$objWriter->writeAttribute('val', StringHelper::formatNumber($pFont->getSize()));
$objWriter->endElement();
}
// Foreground color
if ($pFont->getColor()->getARGB() !== null) {
$objWriter->startElement('color');
$objWriter->writeAttribute('rgb', $pFont->getColor()->getARGB());
$objWriter->endElement();
}
// Name
if ($pFont->getName() !== null) {
$objWriter->startElement('name');
$objWriter->writeAttribute('val', $pFont->getName());
$objWriter->endElement();
}
$objWriter->endElement();
} | php | {
"resource": ""
} |
q250911 | Style.writeBorder | validation | private function writeBorder(XMLWriter $objWriter, Borders $pBorders)
{
// Write border
$objWriter->startElement('border');
// Diagonal?
switch ($pBorders->getDiagonalDirection()) {
case Borders::DIAGONAL_UP:
$objWriter->writeAttribute('diagonalUp', 'true');
$objWriter->writeAttribute('diagonalDown', 'false');
break;
case Borders::DIAGONAL_DOWN:
$objWriter->writeAttribute('diagonalUp', 'false');
$objWriter->writeAttribute('diagonalDown', 'true');
break;
case Borders::DIAGONAL_BOTH:
$objWriter->writeAttribute('diagonalUp', 'true');
$objWriter->writeAttribute('diagonalDown', 'true');
break;
}
// BorderPr
$this->writeBorderPr($objWriter, 'left', $pBorders->getLeft());
$this->writeBorderPr($objWriter, 'right', $pBorders->getRight());
$this->writeBorderPr($objWriter, 'top', $pBorders->getTop());
$this->writeBorderPr($objWriter, 'bottom', $pBorders->getBottom());
$this->writeBorderPr($objWriter, 'diagonal', $pBorders->getDiagonal());
$objWriter->endElement();
} | php | {
"resource": ""
} |
q250912 | Style.writeCellStyleDxf | validation | private function writeCellStyleDxf(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style\Style $pStyle)
{
// dxf
$objWriter->startElement('dxf');
// font
$this->writeFont($objWriter, $pStyle->getFont());
// numFmt
$this->writeNumFmt($objWriter, $pStyle->getNumberFormat());
// fill
$this->writeFill($objWriter, $pStyle->getFill());
// alignment
$objWriter->startElement('alignment');
if ($pStyle->getAlignment()->getHorizontal() !== null) {
$objWriter->writeAttribute('horizontal', $pStyle->getAlignment()->getHorizontal());
}
if ($pStyle->getAlignment()->getVertical() !== null) {
$objWriter->writeAttribute('vertical', $pStyle->getAlignment()->getVertical());
}
if ($pStyle->getAlignment()->getTextRotation() !== null) {
$textRotation = 0;
if ($pStyle->getAlignment()->getTextRotation() >= 0) {
$textRotation = $pStyle->getAlignment()->getTextRotation();
} elseif ($pStyle->getAlignment()->getTextRotation() < 0) {
$textRotation = 90 - $pStyle->getAlignment()->getTextRotation();
}
$objWriter->writeAttribute('textRotation', $textRotation);
}
$objWriter->endElement();
// border
$this->writeBorder($objWriter, $pStyle->getBorders());
// protection
if (($pStyle->getProtection()->getLocked() !== null) || ($pStyle->getProtection()->getHidden() !== null)) {
if ($pStyle->getProtection()->getLocked() !== Protection::PROTECTION_INHERIT ||
$pStyle->getProtection()->getHidden() !== Protection::PROTECTION_INHERIT) {
$objWriter->startElement('protection');
if (($pStyle->getProtection()->getLocked() !== null) &&
($pStyle->getProtection()->getLocked() !== Protection::PROTECTION_INHERIT)) {
$objWriter->writeAttribute('locked', ($pStyle->getProtection()->getLocked() == Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
}
if (($pStyle->getProtection()->getHidden() !== null) &&
($pStyle->getProtection()->getHidden() !== Protection::PROTECTION_INHERIT)) {
$objWriter->writeAttribute('hidden', ($pStyle->getProtection()->getHidden() == Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
}
$objWriter->endElement();
}
}
$objWriter->endElement();
} | php | {
"resource": ""
} |
q250913 | Style.writeBorderPr | validation | private function writeBorderPr(XMLWriter $objWriter, $pName, Border $pBorder)
{
// Write BorderPr
if ($pBorder->getBorderStyle() != Border::BORDER_NONE) {
$objWriter->startElement($pName);
$objWriter->writeAttribute('style', $pBorder->getBorderStyle());
// color
$objWriter->startElement('color');
$objWriter->writeAttribute('rgb', $pBorder->getColor()->getARGB());
$objWriter->endElement();
$objWriter->endElement();
}
} | php | {
"resource": ""
} |
q250914 | Style.writeNumFmt | validation | private function writeNumFmt(XMLWriter $objWriter, NumberFormat $pNumberFormat, $pId = 0)
{
// Translate formatcode
$formatCode = $pNumberFormat->getFormatCode();
// numFmt
if ($formatCode !== null) {
$objWriter->startElement('numFmt');
$objWriter->writeAttribute('numFmtId', ($pId + 164));
$objWriter->writeAttribute('formatCode', $formatCode);
$objWriter->endElement();
}
} | php | {
"resource": ""
} |
q250915 | Style.allConditionalStyles | validation | public function allConditionalStyles(Spreadsheet $spreadsheet)
{
// Get an array of all styles
$aStyles = [];
$sheetCount = $spreadsheet->getSheetCount();
for ($i = 0; $i < $sheetCount; ++$i) {
foreach ($spreadsheet->getSheet($i)->getConditionalStylesCollection() as $conditionalStyles) {
foreach ($conditionalStyles as $conditionalStyle) {
$aStyles[] = $conditionalStyle;
}
}
}
return $aStyles;
} | php | {
"resource": ""
} |
q250916 | Style.allFills | validation | public function allFills(Spreadsheet $spreadsheet)
{
// Get an array of unique fills
$aFills = [];
// Two first fills are predefined
$fill0 = new Fill();
$fill0->setFillType(Fill::FILL_NONE);
$aFills[] = $fill0;
$fill1 = new Fill();
$fill1->setFillType(Fill::FILL_PATTERN_GRAY125);
$aFills[] = $fill1;
// The remaining fills
$aStyles = $this->allStyles($spreadsheet);
/** @var \PhpOffice\PhpSpreadsheet\Style\Style $style */
foreach ($aStyles as $style) {
if (!isset($aFills[$style->getFill()->getHashCode()])) {
$aFills[$style->getFill()->getHashCode()] = $style->getFill();
}
}
return $aFills;
} | php | {
"resource": ""
} |
q250917 | Style.allFonts | validation | public function allFonts(Spreadsheet $spreadsheet)
{
// Get an array of unique fonts
$aFonts = [];
$aStyles = $this->allStyles($spreadsheet);
/** @var \PhpOffice\PhpSpreadsheet\Style\Style $style */
foreach ($aStyles as $style) {
if (!isset($aFonts[$style->getFont()->getHashCode()])) {
$aFonts[$style->getFont()->getHashCode()] = $style->getFont();
}
}
return $aFonts;
} | php | {
"resource": ""
} |
q250918 | Style.allBorders | validation | public function allBorders(Spreadsheet $spreadsheet)
{
// Get an array of unique borders
$aBorders = [];
$aStyles = $this->allStyles($spreadsheet);
/** @var \PhpOffice\PhpSpreadsheet\Style\Style $style */
foreach ($aStyles as $style) {
if (!isset($aBorders[$style->getBorders()->getHashCode()])) {
$aBorders[$style->getBorders()->getHashCode()] = $style->getBorders();
}
}
return $aBorders;
} | php | {
"resource": ""
} |
q250919 | Style.allNumberFormats | validation | public function allNumberFormats(Spreadsheet $spreadsheet)
{
// Get an array of unique number formats
$aNumFmts = [];
$aStyles = $this->allStyles($spreadsheet);
/** @var \PhpOffice\PhpSpreadsheet\Style\Style $style */
foreach ($aStyles as $style) {
if ($style->getNumberFormat()->getBuiltInFormatCode() === false && !isset($aNumFmts[$style->getNumberFormat()->getHashCode()])) {
$aNumFmts[$style->getNumberFormat()->getHashCode()] = $style->getNumberFormat();
}
}
return $aNumFmts;
} | php | {
"resource": ""
} |
q250920 | Unsubscriber.fromXML | validation | function fromXML($xmlElement)
{
$this->contact = new ReportContact();
$this->contact->fromXML($xmlElement->contact);
if (isset($xmlElement->mailing_id)) $this->mailingId = $xmlElement->mailing_id;
if (isset($xmlElement->source)) $this->source = $xmlElement->source;
if (isset($xmlElement->timestamp)) $this->timestamp = $xmlElement->timestamp;
} | php | {
"resource": ""
} |
q250921 | ModelConfig.getColumnDisplayName | validation | public function getColumnDisplayName($columnName) {
return isset($this->columnDisplayNames[$columnName]) ? $this->columnDisplayNames[$columnName] : $columnName;
} | php | {
"resource": ""
} |
q250922 | Contacts.fromXML | validation | function fromXML($xmlElement)
{
if ($xmlElement->getName() == "contacts") {
foreach ($xmlElement->children() as $contactXml) {
$contact = new Contact();
$contact->fromXML($contactXml);
$this->contacts[] = $contact;
}
}
} | php | {
"resource": ""
} |
q250923 | Click.fromXML | validation | function fromXML($xmlElement)
{
$this->contact = new ReportContact();
$this->contact->fromXML($xmlElement->contact);
if (isset($xmlElement->mailing_id)) $this->mailingId = $xmlElement->mailing_id;
if (isset($xmlElement->timestamp)) $this->timestamp = $xmlElement->timestamp;
if (isset($xmlElement->link_id)) $this->linkId = $xmlElement->link_id;
if (isset($xmlElement->link_url)) $this->linkUrl = $xmlElement->link_url;
if (isset($xmlElement->link_tags)) {
$this->linkTags = array();
foreach ($xmlElement->link_tags->children() as $field) {
array_push($this->linkTags, $field[0]);
}
}
} | php | {
"resource": ""
} |
q250924 | AbstractResponse.getCountryName | validation | public function getCountryName($code)
{
$name = Intl::getRegionBundle()->getCountryName(strtoupper($code), $this->getRequest()->getLanguageCode() ? : 'en');
if($name) {
return $name;
}
return $code;
} | php | {
"resource": ""
} |
q250925 | MemorySharedManager.getStorage | validation | public function getStorage() {
if (null === $this->storage) {
$this->setStorage(new Storage\File(array('dir' => DATA_PATH)));
}
return $this->storage;
} | php | {
"resource": ""
} |
q250926 | MemorySharedManager.setStorage | validation | public function setStorage($storage, $options = null) {
if (!$storage instanceof Storage\StorageInterface) {
$storage = $this->getStoragePluginManager()->get($storage, $options);
}
$this->storage = $storage;
return $this;
} | php | {
"resource": ""
} |
q250927 | Collection.implode | validation | public function implode($value, $glue = null)
{
$new_collection = new Collection($this->toArray());
$first = $new_collection->first();
if (is_array($first) || is_object($first)) {
return implode($glue, $new_collection->pluck($value)->all());
}
return implode($value, $new_collection->all());
} | php | {
"resource": ""
} |
q250928 | Collection.jsonSerialize | validation | public function jsonSerialize()
{
return array_map(function ($value) {
if ($value instanceof JsonSerializable) {
return $value->jsonSerialize();
} elseif ($value instanceof JsonableInterface) {
return json_decode($value->toJson(), true);
} elseif ($value instanceof ArrayableInterface) {
return $value->toArray();
} else {
return $value;
}
}, $this->items);
} | php | {
"resource": ""
} |
q250929 | LUDecomposition.det | validation | public function det()
{
if ($this->m == $this->n) {
$d = $this->pivsign;
for ($j = 0; $j < $this->n; ++$j) {
$d *= $this->LU[$j][$j];
}
return $d;
}
throw new CalculationException(Matrix::MATRIX_DIMENSION_EXCEPTION);
} | php | {
"resource": ""
} |
q250930 | DataType.getDataType | validation | static function getDataType($value)
{
switch ($value) {
case "string":
return self::$STRING;
case "double":
return self::$DOUBLE;
case "float":
return self::$FLOAT;
case "integer":
return self::$INTEGER;
case "boolean":
return self::$BOOLEAN;
case "timestamp":
return self::$TIMESTAMP;
case "json":
return self::$JSON;
default:
return null;
}
} | php | {
"resource": ""
} |
q250931 | Katar.render | validation | public function render($file, $env = array()) {
$file = $this->views_path . '/' . $file;
if(!file_exists($file)) {
throw new \Exception("Could not compile $file, file not found");
}
// Cache compiled HTML
$cacheHash = md5($file . serialize($env));
$cache_file = $this->views_cache . "/$cacheHash.cache";
if( !$this->debug && (file_exists($cache_file)
&& filemtime($cache_file) > filemtime($file))) {
return file_get_contents($cache_file);
}
// If it's not cached, load compiled file and execute
$this->currFile = $file;
$hash = md5($file);
$this->compile($file);
$compiled_file = $this->views_cache . '/' . $hash;
// Set a custom error handler
set_error_handler(array($this, 'onTemplateError'));
require_once($compiled_file);
$output = call_user_func('katar_' . $hash, $env);
// Restore the handler as we leave Katar
restore_error_handler();
file_put_contents($cache_file, $output);
return $output;
} | php | {
"resource": ""
} |
q250932 | Katar.compile | validation | private function compile($file) {
if(!file_exists($file)) {
throw new \Exception("Could not compile $file, file not found");
}
if(!file_exists($this->views_cache) && !mkdir($this->views_cache)) {
throw new \Exception("Could no create cache directory." .
" Make sure you have write permissions.");
}
$hash = md5($file);
$compiled_file = $this->views_cache . '/' . $hash;
$compiled = null;
if( $this->debug || (!file_exists($compiled_file)
|| filemtime($compiled_file) < filemtime($file))) {
// get the katar source code and compile it
$source = file_get_contents($file);
$compiled = $this->compileString($source);
$compiled = "<?php\nfunction katar_" . $hash .
"(\$args) {\nextract(\$args);\n\$output = null;\n" . $compiled .
"\nreturn \$output;\n}\n";
file_put_contents($compiled_file, $compiled);
} else {
$compiled = file_get_contents($cache_file);
}
return $compiled;
} | php | {
"resource": ""
} |
q250933 | Katar.compileString | validation | private function compileString($str) {
$result = null;
try {
$result = $this->parser->compile($str);
} catch (\Exception $e) {
throw new SyntaxErrorException("Syntax error in $this->currFile: "
. $e->getMessage());
}
return $result;
} | php | {
"resource": ""
} |
q250934 | FormulaParser.getToken | validation | public function getToken($pId = 0)
{
if (isset($this->tokens[$pId])) {
return $this->tokens[$pId];
}
throw new Exception("Token with id $pId does not exist.");
} | php | {
"resource": ""
} |
q250935 | Html.canRead | validation | public function canRead($pFilename)
{
// Check if file exists
try {
$this->openFile($pFilename);
} catch (Exception $e) {
return false;
}
$beginning = $this->readBeginning();
$startWithTag = self::startsWithTag($beginning);
$containsTags = self::containsTags($beginning);
$endsWithTag = self::endsWithTag($this->readEnding());
fclose($this->fileHandle);
return $startWithTag && $containsTags && $endsWithTag;
} | php | {
"resource": ""
} |
q250936 | Html.applyInlineStyle | validation | private function applyInlineStyle(&$sheet, $row, $column, $attributeArray)
{
if (!isset($attributeArray['style'])) {
return;
}
$supported_styles = ['background-color', 'color'];
// add color styles (background & text) from dom element,currently support : td & th, using ONLY inline css style with RGB color
$styles = explode(';', $attributeArray['style']);
foreach ($styles as $st) {
$value = explode(':', $st);
if (empty(trim($value[0])) || !in_array(trim($value[0]), $supported_styles)) {
continue;
}
//check if has #, so we can get clean hex
if (substr(trim($value[1]), 0, 1) == '#') {
$style_color = substr(trim($value[1]), 1);
}
if (empty($style_color)) {
continue;
}
switch (trim($value[0])) {
case 'background-color':
$sheet->getStyle($column . $row)->applyFromArray(['fill' => ['fillType' => Fill::FILL_SOLID, 'color' => ['rgb' => "{$style_color}"]]]);
break;
case 'color':
$sheet->getStyle($column . $row)->applyFromArray(['font' => ['color' => ['rgb' => "$style_color}"]]]);
break;
}
}
} | php | {
"resource": ""
} |
q250937 | TransactionsService.createTransactions | validation | function createTransactions($transactions, $release = true, $ignoreInvalidEvents = false) {
$queryParameters = array(
'release' => ($release == true)?'true':'false',
'ignore_invalid_transactions' => ($ignoreInvalidEvents == true)?'true':'false'
);
$data = JSONSerializer::json_encode($transactions);
$result = $this->post("transactions", $data, $queryParameters, "application/json",
'com_maileon_api_transactions_ProcessingReports');
return $result;
} | php | {
"resource": ""
} |
q250938 | TransactionsService.findTransactionTypeByName | validation | function findTransactionTypeByName($type_name) {
//FIXME: more than 1000 transactions
$types = $this->getTransactionTypes(1, 1000)->getResult();
$type_name = mb_strtolower($type_name);
foreach($types as $type) {
if(strcmp(mb_strtolower($type->name), $type_name) == 0) {
return (int)$type->id;
}
}
return null;
} | php | {
"resource": ""
} |
q250939 | Client.html | validation | public function html($paragraphs = null)
{
$this->paragraphs = $paragraphs;
unset($this->params['plaintext']);
return $this->generate();
} | php | {
"resource": ""
} |
q250940 | Client.text | validation | public function text($paragraphs = null)
{
$this->paragraphs = $paragraphs;
$this->params['plaintext'] = true;
return $this->generate();
} | php | {
"resource": ""
} |
q250941 | Client.generate | validation | protected function generate()
{
$params = array_keys($this->params);
if ($this->paragraphs) {
$params[] = $this->paragraphs;
}
$url = self::API_URL . implode('/', $params);
return $this->conn->request($url);
} | php | {
"resource": ""
} |
q250942 | Workbook.addXfWriter | validation | public function addXfWriter(Style $style, $isStyleXf = false)
{
$xfWriter = new Xf($style);
$xfWriter->setIsStyleXf($isStyleXf);
// Add the font if not already added
$fontIndex = $this->addFont($style->getFont());
// Assign the font index to the xf record
$xfWriter->setFontIndex($fontIndex);
// Background colors, best to treat these after the font so black will come after white in custom palette
$xfWriter->setFgColor($this->addColor($style->getFill()->getStartColor()->getRGB()));
$xfWriter->setBgColor($this->addColor($style->getFill()->getEndColor()->getRGB()));
$xfWriter->setBottomColor($this->addColor($style->getBorders()->getBottom()->getColor()->getRGB()));
$xfWriter->setTopColor($this->addColor($style->getBorders()->getTop()->getColor()->getRGB()));
$xfWriter->setRightColor($this->addColor($style->getBorders()->getRight()->getColor()->getRGB()));
$xfWriter->setLeftColor($this->addColor($style->getBorders()->getLeft()->getColor()->getRGB()));
$xfWriter->setDiagColor($this->addColor($style->getBorders()->getDiagonal()->getColor()->getRGB()));
// Add the number format if it is not a built-in one and not already added
if ($style->getNumberFormat()->getBuiltInFormatCode() === false) {
$numberFormatHashCode = $style->getNumberFormat()->getHashCode();
if (isset($this->addedNumberFormats[$numberFormatHashCode])) {
$numberFormatIndex = $this->addedNumberFormats[$numberFormatHashCode];
} else {
$numberFormatIndex = 164 + count($this->numberFormats);
$this->numberFormats[$numberFormatIndex] = $style->getNumberFormat();
$this->addedNumberFormats[$numberFormatHashCode] = $numberFormatIndex;
}
} else {
$numberFormatIndex = (int) $style->getNumberFormat()->getBuiltInFormatCode();
}
// Assign the number format index to xf record
$xfWriter->setNumberFormatIndex($numberFormatIndex);
$this->xfWriters[] = $xfWriter;
$xfIndex = count($this->xfWriters) - 1;
return $xfIndex;
} | php | {
"resource": ""
} |
q250943 | Workbook.addFont | validation | public function addFont(\PhpOffice\PhpSpreadsheet\Style\Font $font)
{
$fontHashCode = $font->getHashCode();
if (isset($this->addedFonts[$fontHashCode])) {
$fontIndex = $this->addedFonts[$fontHashCode];
} else {
$countFonts = count($this->fontWriters);
$fontIndex = ($countFonts < 4) ? $countFonts : $countFonts + 1;
$fontWriter = new Font($font);
$fontWriter->setColorIndex($this->addColor($font->getColor()->getRGB()));
$this->fontWriters[] = $fontWriter;
$this->addedFonts[$fontHashCode] = $fontIndex;
}
return $fontIndex;
} | php | {
"resource": ""
} |
q250944 | Workbook.addColor | validation | private function addColor($rgb)
{
if (!isset($this->colors[$rgb])) {
$color =
[
hexdec(substr($rgb, 0, 2)),
hexdec(substr($rgb, 2, 2)),
hexdec(substr($rgb, 4)),
0,
];
$colorIndex = array_search($color, $this->palette);
if ($colorIndex) {
$this->colors[$rgb] = $colorIndex;
} else {
if (count($this->colors) == 0) {
$lastColor = 7;
} else {
$lastColor = end($this->colors);
}
if ($lastColor < 57) {
// then we add a custom color altering the palette
$colorIndex = $lastColor + 1;
$this->palette[$colorIndex] = $color;
$this->colors[$rgb] = $colorIndex;
} else {
// no room for more custom colors, just map to black
$colorIndex = 0;
}
}
} else {
// fetch already added custom color
$colorIndex = $this->colors[$rgb];
}
return $colorIndex;
} | php | {
"resource": ""
} |
q250945 | Workbook.writeWorkbook | validation | public function writeWorkbook(array $pWorksheetSizes)
{
$this->worksheetSizes = $pWorksheetSizes;
// Calculate the number of selected worksheet tabs and call the finalization
// methods for each worksheet
$total_worksheets = $this->spreadsheet->getSheetCount();
// Add part 1 of the Workbook globals, what goes before the SHEET records
$this->storeBof(0x0005);
$this->writeCodepage();
$this->writeWindow1();
$this->writeDateMode();
$this->writeAllFonts();
$this->writeAllNumberFormats();
$this->writeAllXfs();
$this->writeAllStyles();
$this->writePalette();
// Prepare part 3 of the workbook global stream, what goes after the SHEET records
$part3 = '';
if ($this->countryCode != -1) {
$part3 .= $this->writeCountry();
}
$part3 .= $this->writeRecalcId();
$part3 .= $this->writeSupbookInternal();
/* TODO: store external SUPBOOK records and XCT and CRN records
in case of external references for BIFF8 */
$part3 .= $this->writeExternalsheetBiff8();
$part3 .= $this->writeAllDefinedNamesBiff8();
$part3 .= $this->writeMsoDrawingGroup();
$part3 .= $this->writeSharedStringsTable();
$part3 .= $this->writeEof();
// Add part 2 of the Workbook globals, the SHEET records
$this->calcSheetOffsets();
for ($i = 0; $i < $total_worksheets; ++$i) {
$this->writeBoundSheet($this->spreadsheet->getSheet($i), $this->worksheetOffsets[$i]);
}
// Add part 3 of the Workbook globals
$this->_data .= $part3;
return $this->_data;
} | php | {
"resource": ""
} |
q250946 | Workbook.calcSheetOffsets | validation | private function calcSheetOffsets()
{
$boundsheet_length = 10; // fixed length for a BOUNDSHEET record
// size of Workbook globals part 1 + 3
$offset = $this->_datasize;
// add size of Workbook globals part 2, the length of the SHEET records
$total_worksheets = count($this->spreadsheet->getAllSheets());
foreach ($this->spreadsheet->getWorksheetIterator() as $sheet) {
$offset += $boundsheet_length + strlen(StringHelper::UTF8toBIFF8UnicodeShort($sheet->getTitle()));
}
// add the sizes of each of the Sheet substreams, respectively
for ($i = 0; $i < $total_worksheets; ++$i) {
$this->worksheetOffsets[$i] = $offset;
$offset += $this->worksheetSizes[$i];
}
$this->biffSize = $offset;
} | php | {
"resource": ""
} |
q250947 | Workbook.writeAllNumberFormats | validation | private function writeAllNumberFormats()
{
foreach ($this->numberFormats as $numberFormatIndex => $numberFormat) {
$this->writeNumberFormat($numberFormat->getFormatCode(), $numberFormatIndex);
}
} | php | {
"resource": ""
} |
q250948 | Workbook.writeDefinedNameBiff8 | validation | private function writeDefinedNameBiff8($name, $formulaData, $sheetIndex = 0, $isBuiltIn = false)
{
$record = 0x0018;
// option flags
$options = $isBuiltIn ? 0x20 : 0x00;
// length of the name, character count
$nlen = StringHelper::countCharacters($name);
// name with stripped length field
$name = substr(StringHelper::UTF8toBIFF8UnicodeLong($name), 2);
// size of the formula (in bytes)
$sz = strlen($formulaData);
// combine the parts
$data = pack('vCCvvvCCCC', $options, 0, $nlen, $sz, 0, $sheetIndex, 0, 0, 0, 0)
. $name . $formulaData;
$length = strlen($data);
$header = pack('vv', $record, $length);
return $header . $data;
} | php | {
"resource": ""
} |
q250949 | Workbook.writeShortNameBiff8 | validation | private function writeShortNameBiff8($name, $sheetIndex, $rangeBounds, $isHidden = false)
{
$record = 0x0018;
// option flags
$options = ($isHidden ? 0x21 : 0x00);
$extra = pack(
'Cvvvvv',
0x3B,
$sheetIndex - 1,
$rangeBounds[0][1] - 1,
$rangeBounds[1][1] - 1,
$rangeBounds[0][0] - 1,
$rangeBounds[1][0] - 1
);
// size of the formula (in bytes)
$sz = strlen($extra);
// combine the parts
$data = pack('vCCvvvCCCCC', $options, 0, 1, $sz, 0, $sheetIndex, 0, 0, 0, 0, 0)
. $name . $extra;
$length = strlen($data);
$header = pack('vv', $record, $length);
return $header . $data;
} | php | {
"resource": ""
} |
q250950 | Workbook.writeCodepage | validation | private function writeCodepage()
{
$record = 0x0042; // Record identifier
$length = 0x0002; // Number of bytes to follow
$cv = $this->codepage; // The code page
$header = pack('vv', $record, $length);
$data = pack('v', $cv);
$this->append($header . $data);
} | php | {
"resource": ""
} |
q250951 | Workbook.writeWindow1 | validation | private function writeWindow1()
{
$record = 0x003D; // Record identifier
$length = 0x0012; // Number of bytes to follow
$xWn = 0x0000; // Horizontal position of window
$yWn = 0x0000; // Vertical position of window
$dxWn = 0x25BC; // Width of window
$dyWn = 0x1572; // Height of window
$grbit = 0x0038; // Option flags
// not supported by PhpSpreadsheet, so there is only one selected sheet, the active
$ctabsel = 1; // Number of workbook tabs selected
$wTabRatio = 0x0258; // Tab to scrollbar ratio
// not supported by PhpSpreadsheet, set to 0
$itabFirst = 0; // 1st displayed worksheet
$itabCur = $this->spreadsheet->getActiveSheetIndex(); // Active worksheet
$header = pack('vv', $record, $length);
$data = pack('vvvvvvvvv', $xWn, $yWn, $dxWn, $dyWn, $grbit, $itabCur, $itabFirst, $ctabsel, $wTabRatio);
$this->append($header . $data);
} | php | {
"resource": ""
} |
q250952 | Workbook.writeBoundSheet | validation | private function writeBoundSheet($sheet, $offset)
{
$sheetname = $sheet->getTitle();
$record = 0x0085; // Record identifier
// sheet state
switch ($sheet->getSheetState()) {
case \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::SHEETSTATE_VISIBLE:
$ss = 0x00;
break;
case \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::SHEETSTATE_HIDDEN:
$ss = 0x01;
break;
case \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::SHEETSTATE_VERYHIDDEN:
$ss = 0x02;
break;
default:
$ss = 0x00;
break;
}
// sheet type
$st = 0x00;
$grbit = 0x0000; // Visibility and sheet type
$data = pack('VCC', $offset, $ss, $st);
$data .= StringHelper::UTF8toBIFF8UnicodeShort($sheetname);
$length = strlen($data);
$header = pack('vv', $record, $length);
$this->append($header . $data);
} | php | {
"resource": ""
} |
q250953 | Workbook.writeSupbookInternal | validation | private function writeSupbookInternal()
{
$record = 0x01AE; // Record identifier
$length = 0x0004; // Bytes to follow
$header = pack('vv', $record, $length);
$data = pack('vv', $this->spreadsheet->getSheetCount(), 0x0401);
return $this->writeData($header . $data);
} | php | {
"resource": ""
} |
q250954 | Workbook.writeExternalsheetBiff8 | validation | private function writeExternalsheetBiff8()
{
$totalReferences = count($this->parser->references);
$record = 0x0017; // Record identifier
$length = 2 + 6 * $totalReferences; // Number of bytes to follow
$supbook_index = 0; // FIXME: only using internal SUPBOOK record
$header = pack('vv', $record, $length);
$data = pack('v', $totalReferences);
for ($i = 0; $i < $totalReferences; ++$i) {
$data .= $this->parser->references[$i];
}
return $this->writeData($header . $data);
} | php | {
"resource": ""
} |
q250955 | Workbook.writeStyle | validation | private function writeStyle()
{
$record = 0x0293; // Record identifier
$length = 0x0004; // Bytes to follow
$ixfe = 0x8000; // Index to cell style XF
$BuiltIn = 0x00; // Built-in style
$iLevel = 0xff; // Outline style level
$header = pack('vv', $record, $length);
$data = pack('vCC', $ixfe, $BuiltIn, $iLevel);
$this->append($header . $data);
} | php | {
"resource": ""
} |
q250956 | Workbook.writeNumberFormat | validation | private function writeNumberFormat($format, $ifmt)
{
$record = 0x041E; // Record identifier
$numberFormatString = StringHelper::UTF8toBIFF8UnicodeLong($format);
$length = 2 + strlen($numberFormatString); // Number of bytes to follow
$header = pack('vv', $record, $length);
$data = pack('v', $ifmt) . $numberFormatString;
$this->append($header . $data);
} | php | {
"resource": ""
} |
q250957 | Workbook.writeCountry | validation | private function writeCountry()
{
$record = 0x008C; // Record identifier
$length = 4; // Number of bytes to follow
$header = pack('vv', $record, $length);
// using the same country code always for simplicity
$data = pack('vv', $this->countryCode, $this->countryCode);
return $this->writeData($header . $data);
} | php | {
"resource": ""
} |
q250958 | Workbook.writeRecalcId | validation | private function writeRecalcId()
{
$record = 0x01C1; // Record identifier
$length = 8; // Number of bytes to follow
$header = pack('vv', $record, $length);
// by inspection of real Excel files, MS Office Excel 2007 writes this
$data = pack('VV', 0x000001C1, 0x00001E667);
return $this->writeData($header . $data);
} | php | {
"resource": ""
} |
q250959 | Workbook.writePalette | validation | private function writePalette()
{
$aref = $this->palette;
$record = 0x0092; // Record identifier
$length = 2 + 4 * count($aref); // Number of bytes to follow
$ccv = count($aref); // Number of RGB values to follow
$data = ''; // The RGB data
// Pack the RGB data
foreach ($aref as $color) {
foreach ($color as $byte) {
$data .= pack('C', $byte);
}
}
$header = pack('vvv', $record, $length, $ccv);
$this->append($header . $data);
} | php | {
"resource": ""
} |
q250960 | Workbook.writeMsoDrawingGroup | validation | private function writeMsoDrawingGroup()
{
// write the Escher stream if necessary
if (isset($this->escher)) {
$writer = new Escher($this->escher);
$data = $writer->close();
$record = 0x00EB;
$length = strlen($data);
$header = pack('vv', $record, $length);
return $this->writeData($header . $data);
}
return '';
} | php | {
"resource": ""
} |
q250961 | Workbook.setEscher | validation | public function setEscher(\PhpOffice\PhpSpreadsheet\Shared\Escher $pValue = null)
{
$this->escher = $pValue;
} | php | {
"resource": ""
} |
q250962 | Sample.getSamples | validation | public function getSamples()
{
// Populate samples
$baseDir = realpath(__DIR__ . '/../../../samples');
$directory = new RecursiveDirectoryIterator($baseDir);
$iterator = new RecursiveIteratorIterator($directory);
$regex = new RegexIterator($iterator, '/^.+\.php$/', RecursiveRegexIterator::GET_MATCH);
$files = [];
foreach ($regex as $file) {
$file = str_replace($baseDir . '/', '', $file[0]);
$info = pathinfo($file);
$category = str_replace('_', ' ', $info['dirname']);
$name = str_replace('_', ' ', preg_replace('/(|\.php)/', '', $info['filename']));
if (!in_array($category, ['.', 'boostrap', 'templates'])) {
if (!isset($files[$category])) {
$files[$category] = [];
}
$files[$category][$name] = $file;
}
}
// Sort everything
ksort($files);
foreach ($files as &$f) {
asort($f);
}
return $files;
} | php | {
"resource": ""
} |
q250963 | Sample.write | validation | public function write(Spreadsheet $spreadsheet, $filename, array $writers = ['Xlsx', 'Xls'])
{
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$spreadsheet->setActiveSheetIndex(0);
// Write documents
foreach ($writers as $writerType) {
$path = $this->getFilename($filename, mb_strtolower($writerType));
$writer = IOFactory::createWriter($spreadsheet, $writerType);
if ($writer instanceof Pdf) {
// PDF writer needs temporary directory
$tempDir = $this->getTemporaryFolder();
$writer->setTempDir($tempDir);
}
$callStartTime = microtime(true);
$writer->save($path);
$this->logWrite($writer, $path, $callStartTime);
}
$this->logEndingNotes();
} | php | {
"resource": ""
} |
q250964 | Sample.getTemporaryFolder | validation | private function getTemporaryFolder()
{
$tempFolder = sys_get_temp_dir() . '/phpspreadsheet';
if (!is_dir($tempFolder)) {
if (!mkdir($tempFolder) && !is_dir($tempFolder)) {
throw new \RuntimeException(sprintf('Directory "%s" was not created', $tempFolder));
}
}
return $tempFolder;
} | php | {
"resource": ""
} |
q250965 | Sample.getFilename | validation | public function getFilename($filename, $extension = 'xlsx')
{
$originalExtension = pathinfo($filename, PATHINFO_EXTENSION);
return $this->getTemporaryFolder() . '/' . str_replace('.' . $originalExtension, '.' . $extension, basename($filename));
} | php | {
"resource": ""
} |
q250966 | Sample.getTemporaryFilename | validation | public function getTemporaryFilename($extension = 'xlsx')
{
$temporaryFilename = tempnam($this->getTemporaryFolder(), 'phpspreadsheet-');
unlink($temporaryFilename);
return $temporaryFilename . '.' . $extension;
} | php | {
"resource": ""
} |
q250967 | Sample.logWrite | validation | public function logWrite(IWriter $writer, $path, $callStartTime)
{
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
$reflection = new ReflectionClass($writer);
$format = $reflection->getShortName();
$message = "Write {$format} format to <code>{$path}</code> in " . sprintf('%.4f', $callTime) . ' seconds';
$this->log($message);
} | php | {
"resource": ""
} |
q250968 | Sample.logRead | validation | public function logRead($format, $path, $callStartTime)
{
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
$message = "Read {$format} format from <code>{$path}</code> in " . sprintf('%.4f', $callTime) . ' seconds';
$this->log($message);
} | php | {
"resource": ""
} |
q250969 | Schedule.fromXML | validation | function fromXML($xmlElement) {
if (isset($xmlElement->minutes)) $this->minutes = $xmlElement->minutes;
if (isset($xmlElement->hours)) $this->hours = $xmlElement->hours;
if (isset($xmlElement->state)) $this->state = $xmlElement->state;
if (isset($xmlElement->date)) $this->date = $xmlElement->date;
} | php | {
"resource": ""
} |
q250970 | Schedule.toDateTime | validation | function toDateTime() {
return $this->date . " " . str_pad($this->hours, 2, '0', STR_PAD_LEFT) . ":" . str_pad($this->minutes, 2, '0', STR_PAD_LEFT);
} | php | {
"resource": ""
} |
q250971 | Office.setMaxParcelDimensions | validation | public function setMaxParcelDimensions($value = null)
{
if(is_array($value)) {
$value = new ParcelDimensions($value);
} elseif(!($value instanceof ParcelDimensions)) {
$value = null;
}
return $this->setParameter('max_parcel_dimensions', $value);
} | php | {
"resource": ""
} |
q250972 | Slk.canRead | validation | public function canRead($pFilename)
{
// Check if file exists
try {
$this->openFile($pFilename);
} catch (Exception $e) {
return false;
}
// Read sample data (first 2 KB will do)
$data = fread($this->fileHandle, 2048);
// Count delimiters in file
$delimiterCount = substr_count($data, ';');
$hasDelimiter = $delimiterCount > 0;
// Analyze first line looking for ID; signature
$lines = explode("\n", $data);
$hasId = substr($lines[0], 0, 4) === 'ID;P';
fclose($this->fileHandle);
return $hasDelimiter && $hasId;
} | php | {
"resource": ""
} |
q250973 | Font.writeFont | validation | public function writeFont()
{
$font_outline = 0;
$font_shadow = 0;
$icv = $this->colorIndex; // Index to color palette
if ($this->font->getSuperscript()) {
$sss = 1;
} elseif ($this->font->getSubscript()) {
$sss = 2;
} else {
$sss = 0;
}
$bFamily = 0; // Font family
$bCharSet = \PhpOffice\PhpSpreadsheet\Shared\Font::getCharsetFromFontName($this->font->getName()); // Character set
$record = 0x31; // Record identifier
$reserved = 0x00; // Reserved
$grbit = 0x00; // Font attributes
if ($this->font->getItalic()) {
$grbit |= 0x02;
}
if ($this->font->getStrikethrough()) {
$grbit |= 0x08;
}
if ($font_outline) {
$grbit |= 0x10;
}
if ($font_shadow) {
$grbit |= 0x20;
}
$data = pack(
'vvvvvCCCC',
// Fontsize (in twips)
$this->font->getSize() * 20,
$grbit,
// Colour
$icv,
// Font weight
self::mapBold($this->font->getBold()),
// Superscript/Subscript
$sss,
self::mapUnderline($this->font->getUnderline()),
$bFamily,
$bCharSet,
$reserved
);
$data .= StringHelper::UTF8toBIFF8UnicodeShort($this->font->getName());
$length = strlen($data);
$header = pack('vv', $record, $length);
return $header . $data;
} | php | {
"resource": ""
} |
q250974 | Color.setARGB | validation | public function setARGB($pValue)
{
if ($pValue == '') {
$pValue = self::COLOR_BLACK;
}
if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(['argb' => $pValue]);
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else {
$this->argb = $pValue;
}
return $this;
} | php | {
"resource": ""
} |
q250975 | Color.setRGB | validation | public function setRGB($pValue)
{
if ($pValue == '') {
$pValue = '000000';
}
if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(['argb' => 'FF' . $pValue]);
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else {
$this->argb = 'FF' . $pValue;
}
return $this;
} | php | {
"resource": ""
} |
q250976 | Color.indexedColor | validation | public static function indexedColor($pIndex, $background = false)
{
// Clean parameter
$pIndex = (int) $pIndex;
// Indexed colors
if (self::$indexedColors === null) {
self::$indexedColors = [
1 => 'FF000000', // System Colour #1 - Black
2 => 'FFFFFFFF', // System Colour #2 - White
3 => 'FFFF0000', // System Colour #3 - Red
4 => 'FF00FF00', // System Colour #4 - Green
5 => 'FF0000FF', // System Colour #5 - Blue
6 => 'FFFFFF00', // System Colour #6 - Yellow
7 => 'FFFF00FF', // System Colour #7- Magenta
8 => 'FF00FFFF', // System Colour #8- Cyan
9 => 'FF800000', // Standard Colour #9
10 => 'FF008000', // Standard Colour #10
11 => 'FF000080', // Standard Colour #11
12 => 'FF808000', // Standard Colour #12
13 => 'FF800080', // Standard Colour #13
14 => 'FF008080', // Standard Colour #14
15 => 'FFC0C0C0', // Standard Colour #15
16 => 'FF808080', // Standard Colour #16
17 => 'FF9999FF', // Chart Fill Colour #17
18 => 'FF993366', // Chart Fill Colour #18
19 => 'FFFFFFCC', // Chart Fill Colour #19
20 => 'FFCCFFFF', // Chart Fill Colour #20
21 => 'FF660066', // Chart Fill Colour #21
22 => 'FFFF8080', // Chart Fill Colour #22
23 => 'FF0066CC', // Chart Fill Colour #23
24 => 'FFCCCCFF', // Chart Fill Colour #24
25 => 'FF000080', // Chart Line Colour #25
26 => 'FFFF00FF', // Chart Line Colour #26
27 => 'FFFFFF00', // Chart Line Colour #27
28 => 'FF00FFFF', // Chart Line Colour #28
29 => 'FF800080', // Chart Line Colour #29
30 => 'FF800000', // Chart Line Colour #30
31 => 'FF008080', // Chart Line Colour #31
32 => 'FF0000FF', // Chart Line Colour #32
33 => 'FF00CCFF', // Standard Colour #33
34 => 'FFCCFFFF', // Standard Colour #34
35 => 'FFCCFFCC', // Standard Colour #35
36 => 'FFFFFF99', // Standard Colour #36
37 => 'FF99CCFF', // Standard Colour #37
38 => 'FFFF99CC', // Standard Colour #38
39 => 'FFCC99FF', // Standard Colour #39
40 => 'FFFFCC99', // Standard Colour #40
41 => 'FF3366FF', // Standard Colour #41
42 => 'FF33CCCC', // Standard Colour #42
43 => 'FF99CC00', // Standard Colour #43
44 => 'FFFFCC00', // Standard Colour #44
45 => 'FFFF9900', // Standard Colour #45
46 => 'FFFF6600', // Standard Colour #46
47 => 'FF666699', // Standard Colour #47
48 => 'FF969696', // Standard Colour #48
49 => 'FF003366', // Standard Colour #49
50 => 'FF339966', // Standard Colour #50
51 => 'FF003300', // Standard Colour #51
52 => 'FF333300', // Standard Colour #52
53 => 'FF993300', // Standard Colour #53
54 => 'FF993366', // Standard Colour #54
55 => 'FF333399', // Standard Colour #55
56 => 'FF333333', // Standard Colour #56
];
}
if (isset(self::$indexedColors[$pIndex])) {
return new self(self::$indexedColors[$pIndex]);
}
if ($background) {
return new self(self::COLOR_WHITE);
}
return new self(self::COLOR_BLACK);
} | php | {
"resource": ""
} |
q250977 | BaseDrawing.setWorksheet | validation | public function setWorksheet(Worksheet $pValue = null, $pOverrideOld = false)
{
if ($this->worksheet === null) {
// Add drawing to \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
$this->worksheet = $pValue;
$this->worksheet->getCell($this->coordinates);
$this->worksheet->getDrawingCollection()->append($this);
} else {
if ($pOverrideOld) {
// Remove drawing from old \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
$iterator = $this->worksheet->getDrawingCollection()->getIterator();
while ($iterator->valid()) {
if ($iterator->current()->getHashCode() == $this->getHashCode()) {
$this->worksheet->getDrawingCollection()->offsetUnset($iterator->key());
$this->worksheet = null;
break;
}
}
// Set new \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
$this->setWorksheet($pValue);
} else {
throw new PhpSpreadsheetException('A Worksheet has already been assigned. Drawings can only exist on one \\PhpOffice\\PhpSpreadsheet\\Worksheet.');
}
}
return $this;
} | php | {
"resource": ""
} |
q250978 | BaseDrawing.setWidth | validation | public function setWidth($pValue)
{
// Resize proportional?
if ($this->resizeProportional && $pValue != 0) {
$ratio = $this->height / ($this->width != 0 ? $this->width : 1);
$this->height = round($ratio * $pValue);
}
// Set width
$this->width = $pValue;
return $this;
} | php | {
"resource": ""
} |
q250979 | PageSetup.setFitToHeight | validation | public function setFitToHeight($pValue, $pUpdate = true)
{
$this->fitToHeight = $pValue;
if ($pUpdate) {
$this->fitToPage = true;
}
return $this;
} | php | {
"resource": ""
} |
q250980 | PageSetup.setFitToWidth | validation | public function setFitToWidth($pValue, $pUpdate = true)
{
$this->fitToWidth = $pValue;
if ($pUpdate) {
$this->fitToPage = true;
}
return $this;
} | php | {
"resource": ""
} |
q250981 | PageSetup.getPrintArea | validation | public function getPrintArea($index = 0)
{
if ($index == 0) {
return $this->printArea;
}
$printAreas = explode(',', $this->printArea);
if (isset($printAreas[$index - 1])) {
return $printAreas[$index - 1];
}
throw new PhpSpreadsheetException('Requested Print Area does not exist');
} | php | {
"resource": ""
} |
q250982 | PageSetup.isPrintAreaSet | validation | public function isPrintAreaSet($index = 0)
{
if ($index == 0) {
return $this->printArea !== null;
}
$printAreas = explode(',', $this->printArea);
return isset($printAreas[$index - 1]);
} | php | {
"resource": ""
} |
q250983 | PageSetup.addPrintAreaByColumnAndRow | validation | public function addPrintAreaByColumnAndRow($column1, $row1, $column2, $row2, $index = -1)
{
return $this->setPrintArea(
Coordinate::stringFromColumnIndex($column1) . $row1 . ':' . Coordinate::stringFromColumnIndex($column2) . $row2,
$index,
self::SETPRINTRANGE_INSERT
);
} | php | {
"resource": ""
} |
q250984 | Address.setCountry | validation | public function setCountry($country)
{
if (!($country instanceof Country)) {
$country = new Country($country);
}
if ($country->isEmpty()) {
$this->invalidArguments('10001');
}
return $this->setParameter('country', $country);
} | php | {
"resource": ""
} |
q250985 | Address.setState | validation | public function setState($state)
{
if(!$state) {
return $this;
}
if (!($state instanceof State)) {
$state = new State($state);
}
if ($state->isEmpty()) {
$this->invalidArguments('10002');
}
return $this->setParameter('state', $state);
} | php | {
"resource": ""
} |
q250986 | Address.setCity | validation | public function setCity($city)
{
if (!($city instanceof City)) {
$city = new City($city);
}
if ($city->isEmpty()) {
$this->invalidArguments('10003');
}
return $this->setParameter('city', $city);
} | php | {
"resource": ""
} |
q250987 | Address.setQuarter | validation | public function setQuarter($quarter)
{
if(!$quarter) {
return $this;
}
if (!($quarter instanceof Quarter)) {
$quarter = new Quarter($quarter);
}
if ($quarter->isEmpty()) {
$this->invalidArguments('10005');
}
return $this->setParameter('quarter', $quarter);
} | php | {
"resource": ""
} |
q250988 | Address.setTimeZone | validation | public function setTimeZone($timezone)
{
if(!$timezone) {
return $this;
}
try {
Carbon::now($timezone);
} catch (\Exception $e) {
$this->invalidArguments('10004', sprintf('Invalid timezone set "%s"', $timezone));
}
return $this->setParameter('timezone', $timezone);
} | php | {
"resource": ""
} |
q250989 | Integration.checkOrderStatus | validation | public function checkOrderStatus( $orderId )
{
$function = 'CheckOrderStatus';
$parameters = [
'entityCode' => $this->connector->getEntityCode(),
'pedidoIDCliente' => $orderId
];
$response = $this->connector->doRequest( $function, $parameters );
$packageStatusResponse = new PackageStatus( $response->CheckOrderStatusResult );
$this->connector->log( 'Integration@checkOrderStatus', compact( 'packageStatusResponse' ) );
return $packageStatusResponse;
} | php | {
"resource": ""
} |
q250990 | Root._calcSize | validation | public function _calcSize(&$raList)
{
// Calculate Basic Setting
list($iSBDcnt, $iBBcnt, $iPPScnt) = [0, 0, 0];
$iSmallLen = 0;
$iSBcnt = 0;
$iCount = count($raList);
for ($i = 0; $i < $iCount; ++$i) {
if ($raList[$i]->Type == OLE::OLE_PPS_TYPE_FILE) {
$raList[$i]->Size = $raList[$i]->getDataLen();
if ($raList[$i]->Size < OLE::OLE_DATA_SIZE_SMALL) {
$iSBcnt += floor($raList[$i]->Size / $this->smallBlockSize)
+ (($raList[$i]->Size % $this->smallBlockSize) ? 1 : 0);
} else {
$iBBcnt += (floor($raList[$i]->Size / $this->bigBlockSize) +
(($raList[$i]->Size % $this->bigBlockSize) ? 1 : 0));
}
}
}
$iSmallLen = $iSBcnt * $this->smallBlockSize;
$iSlCnt = floor($this->bigBlockSize / OLE::OLE_LONG_INT_SIZE);
$iSBDcnt = floor($iSBcnt / $iSlCnt) + (($iSBcnt % $iSlCnt) ? 1 : 0);
$iBBcnt += (floor($iSmallLen / $this->bigBlockSize) +
(($iSmallLen % $this->bigBlockSize) ? 1 : 0));
$iCnt = count($raList);
$iBdCnt = $this->bigBlockSize / OLE::OLE_PPS_SIZE;
$iPPScnt = (floor($iCnt / $iBdCnt) + (($iCnt % $iBdCnt) ? 1 : 0));
return [$iSBDcnt, $iBBcnt, $iPPScnt];
} | php | {
"resource": ""
} |
q250991 | Root._savePps | validation | public function _savePps(&$raList)
{
// Save each PPS WK
$iC = count($raList);
for ($i = 0; $i < $iC; ++$i) {
fwrite($this->fileHandle, $raList[$i]->_getPpsWk());
}
// Adjust for Block
$iCnt = count($raList);
$iBCnt = $this->bigBlockSize / OLE::OLE_PPS_SIZE;
if ($iCnt % $iBCnt) {
fwrite($this->fileHandle, str_repeat("\x00", ($iBCnt - ($iCnt % $iBCnt)) * OLE::OLE_PPS_SIZE));
}
} | php | {
"resource": ""
} |
q250992 | Image.set_images | validation | public function set_images( $post_id ) {
if ( ! $post_id || is_null( $post_id ) ) {
return 0; }
update_post_meta( $post_id, 'custom_images_grifus', 'true' );
$count = 0;
$tmdb = 'image.tmdb.org';
$poster = get_post_meta( $post_id, 'poster_url', true );
if ( filter_var( $poster, FILTER_VALIDATE_URL ) && strpos( $poster, $tmdb ) ) {
$count++;
$poster = WP_Image::save( $poster, $post_id, true );
update_post_meta( $post_id, 'poster_url', $poster );
}
$main = get_post_meta( $post_id, 'fondo_player', true );
if ( filter_var( $main, FILTER_VALIDATE_URL ) && strpos( $main, $tmdb ) ) {
$count++;
$main = WP_Image::save( $main, $post_id );
update_post_meta( $post_id, 'fondo_player', $main );
}
$images = get_post_meta( $post_id, 'imagenes', true );
$images_array = explode( "\n", $images );
$new_images = '';
foreach ( $images_array as $image ) {
$image = trim( $image );
if ( filter_var( $image, FILTER_VALIDATE_URL ) && strpos( $image, $tmdb ) ) {
$count++;
$url = WP_Image::save( $image, $post_id );
$new_images .= $url . "\n";
}
}
if ( ! empty( $new_images ) ) {
update_post_meta( $post_id, 'imagenes', $new_images );
}
return $count;
} | php | {
"resource": ""
} |
q250993 | Image.set_posts_to_review | validation | public function set_posts_to_review() {
$total_posts = wp_count_posts();
$total_posts = isset( $total_posts->publish ) ? $total_posts->publish : 0;
$posts = get_posts(
[
'post_type' => 'post',
'numberposts' => $total_posts,
'post_status' => 'publish',
]
);
foreach ( $posts as $post ) {
if ( isset( $post->ID ) ) {
add_post_meta(
$post->ID,
'custom_images_grifus',
'false',
true
);
}
}
} | php | {
"resource": ""
} |
q250994 | File.sysGetTempDir | validation | public static function sysGetTempDir()
{
if (self::$useUploadTempDirectory) {
// use upload-directory when defined to allow running on environments having very restricted
// open_basedir configs
if (ini_get('upload_tmp_dir') !== false) {
if ($temp = ini_get('upload_tmp_dir')) {
if (file_exists($temp)) {
return realpath($temp);
}
}
}
}
return realpath(sys_get_temp_dir());
} | php | {
"resource": ""
} |
q250995 | File.assertFile | validation | public static function assertFile($filename)
{
if (!is_file($filename)) {
throw new InvalidArgumentException('File "' . $filename . '" does not exist.');
}
if (!is_readable($filename)) {
throw new InvalidArgumentException('Could not open "' . $filename . '" for reading.');
}
} | php | {
"resource": ""
} |
q250996 | Assertion.a | validation | function a(string $type = ''): self {
return mb_strlen($type) ? $this->expect($this->target, isType($type)) : $this;
} | php | {
"resource": ""
} |
q250997 | Assertion.above | validation | function above($value): self {
$target = $this->hasFlag('length') ? $this->getLength($this->target) : $this->target;
return $this->expect($target, greaterThan($value));
} | php | {
"resource": ""
} |
q250998 | Assertion.below | validation | function below($value): self {
$target = $this->hasFlag('length') ? $this->getLength($this->target) : $this->target;
return $this->expect($target, lessThan($value));
} | php | {
"resource": ""
} |
q250999 | Assertion.closeTo | validation | function closeTo($value, float $delta): self {
return $this->expect($this->target, equalTo($value, $delta));
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.