_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q800
Workbook.createWorkbookFromTemplate
train
public function createWorkbookFromTemplate($templateFileName) { if ($templateFileName == '') throw new Exception('Template file not specified'); //build URI to merge Docs $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '?templatefile=' . $templateFileName; //sign URI $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'PUT'); $json = json_decode($responseStream); return $json; }
php
{ "resource": "" }
q801
Workbook.getWorksheetsCount
train
public function getWorksheetsCount() { //build URI to merge Docs $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets'; //sign URI $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $json = json_decode($responseStream); return count($json->Worksheets->WorksheetList); }
php
{ "resource": "" }
q802
Workbook.getNamesCount
train
public function getNamesCount() { //build URI to merge Docs $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/names'; //sign URI $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $json = json_decode($responseStream); return $json->Names->Count; }
php
{ "resource": "" }
q803
Workbook.getDefaultStyle
train
public function getDefaultStyle() { //build URI to merge Docs $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/defaultStyle'; //sign URI $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET', ''); $json = json_decode($responseStream); return $json->Style; }
php
{ "resource": "" }
q804
Workbook.encryptWorkbook
train
public function encryptWorkbook($encryptionType = 'XOR', $password = '', $keyLength = '') { //Build JSON to post $fieldsArray['EncriptionType'] = $encryptionType; $fieldsArray['KeyLength'] = $keyLength; $fieldsArray['Password'] = $password; $json = json_encode($fieldsArray); $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/encryption'; $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'POST', 'json', $json); $json_response = json_decode($responseStream); if ($json_response->Code == 200) return true; else return false; }
php
{ "resource": "" }
q805
Workbook.addWorksheet
train
public function addWorksheet($worksheetName) { $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets/' . $worksheetName; $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'PUT', '', ''); $json_response = json_decode($responseStream); if ($json_response->Code == 201) return true; else return false; }
php
{ "resource": "" }
q806
Workbook.mergeWorkbook
train
public function mergeWorkbook($mergeFileName) { $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/merge?mergeWith=' . $mergeFileName; $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'POST', '', ''); $json_response = json_decode($responseStream); if ($json_response->Code == 200) return true; else return false; }
php
{ "resource": "" }
q807
Workbook.autofitRows
train
public function autofitRows($saveFormat = "") { $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '?isAutoFit=true'; if ($saveFormat != '') $strURI .= '&format=' . $saveFormat; $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $v_output = Utils::validateOutput($responseStream); if ($v_output === '') { if ($saveFormat == '') { $strURI = Product::$baseProductUri . '/storage/file/' . $this->getFileName(); $signedURI = Utils::Sign($strURI); $responseStream = Utils::processCommand($signedURI, "GET", "", ""); $outputPath = AsposeApp::$outPutLocation . $this->getFileName(); Utils::saveFile($responseStream, $outputFile); } else { $outputPath = AsposeApp::$outPutLocation . Utils::getFileName($this->getFileName()) . '.' . $saveFormat; Utils::saveFile($responseStream, $outputPath); } return $outputPath; } else { return $v_output; } }
php
{ "resource": "" }
q808
Workbook.saveAs
train
public function saveAs($strXML, $outputFile) { if ($strXML == '') throw new Exception('XML Data not specified'); if ($outputFile == '') throw new Exception('Output Filename along extension not specified'); $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/saveAs?newfilename=' . $outputFile; $signedURI = Utils::Sign($strURI); $responseStream = Utils::processCommand($signedURI, "POST", "XML", $strXML); $v_output = Utils::validateOutput($responseStream); if ($v_output === '') { $strURI = Product::$baseProductUri . '/storage/file/' . $outputFile; $signedURI = Utils::Sign($strURI); $responseStream = Utils::processCommand($signedURI, "GET", "", ""); $outputPath = AsposeApp::$outPutLocation . $outputFile; Utils::saveFile($responseStream, $outputPath); return $outputPath; } else { return $v_output; } }
php
{ "resource": "" }
q809
Utils.codepointToUtf8
train
public static function codepointToUtf8( $codepoint ) { if ( $codepoint < 0x80 ) { return chr( $codepoint ); } if ( $codepoint < 0x800 ) { return chr( $codepoint >> 6 & 0x3f | 0xc0 ) . chr( $codepoint & 0x3f | 0x80 ); } if ( $codepoint < 0x10000 ) { return chr( $codepoint >> 12 & 0x0f | 0xe0 ) . chr( $codepoint >> 6 & 0x3f | 0x80 ) . chr( $codepoint & 0x3f | 0x80 ); } if ( $codepoint < 0x110000 ) { return chr( $codepoint >> 18 & 0x07 | 0xf0 ) . chr( $codepoint >> 12 & 0x3f | 0x80 ) . chr( $codepoint >> 6 & 0x3f | 0x80 ) . chr( $codepoint & 0x3f | 0x80 ); } throw new InvalidArgumentException( "Asked for code outside of range ($codepoint)" ); }
php
{ "resource": "" }
q810
Utils.hexSequenceToUtf8
train
public static function hexSequenceToUtf8( $sequence ) { $utf = ''; foreach ( explode( ' ', $sequence ) as $hex ) { $n = hexdec( $hex ); $utf .= self::codepointToUtf8( $n ); } return $utf; }
php
{ "resource": "" }
q811
Utils.utf8ToHexSequence
train
private static function utf8ToHexSequence( $str ) { $buf = ''; foreach ( preg_split( '//u', $str, -1, PREG_SPLIT_NO_EMPTY ) as $cp ) { $buf .= sprintf( '%04x ', self::utf8ToCodepoint( $cp ) ); } return rtrim( $buf ); }
php
{ "resource": "" }
q812
Utils.utf8ToCodepoint
train
public static function utf8ToCodepoint( $char ) { # Find the length $z = ord( $char[0] ); if ( $z & 0x80 ) { $length = 0; while ( $z & 0x80 ) { $length++; $z <<= 1; } } else { $length = 1; } if ( $length != strlen( $char ) ) { return false; } if ( $length == 1 ) { return ord( $char ); } # Mask off the length-determining bits and shift back to the original location $z &= 0xff; $z >>= $length; # Add in the free bits from subsequent bytes for ( $i = 1; $i < $length; $i++ ) { $z <<= 6; $z |= ord( $char[$i] ) & 0x3f; } return $z; }
php
{ "resource": "" }
q813
HttpObservable.setContentLength
train
private function setContentLength() { if (!is_string($this->body)) { return; } $headers = array_map('strtolower', array_keys($this->headers)); if (!in_array('content-length', $headers, true)) { $this->headers['Content-Length'] = strlen($this->body); } }
php
{ "resource": "" }
q814
AttributeValue.instantiate
train
public static function instantiate(AttributeContract $attribute, $value) { if (! $attribute->supportsValues()) { throw new AttributeMustSupportValues(); } return new static([ 'attribute_id' => $attribute->id, 'value' => $value, ]); }
php
{ "resource": "" }
q815
Product.instantiate
train
public static function instantiate(ProductNumberContract $productNumber, ProductTypeContract $productType, $description) { return new static([ 'product_number' => $productNumber, 'product_type_id' => $productType->id, 'description' => $description, ]); }
php
{ "resource": "" }
q816
CronController.actionStart
train
public function actionStart($taskCommand = null ) { /** * @var $cron Crontab */ $cron = $this->module->get($this->module->nameComponent); $cron->eraseJobs(); $common_params = $this->module->params; if(!empty($this->module->tasks)) { if($taskCommand && isset($this->module->tasks[$taskCommand])){ $task = $this->module->tasks[$taskCommand]; $params = ArrayHelper::merge( ArrayHelper::getValue($task, 'params',[]), $common_params ); $cron->addApplicationJob($this->module->phpPath.' '.$this->getYiiPath(), $task['command'], $params, ArrayHelper::getValue($task, 'min'), ArrayHelper::getValue($task, 'hour'), ArrayHelper::getValue($task, 'day'), ArrayHelper::getValue($task, 'month'), ArrayHelper::getValue($task, 'dayofweek'), $this->module->cronGroup //mast be unique for any app on server ); } else { foreach ($this->module->tasks as $commandName => $task) { $params = ArrayHelper::merge( ArrayHelper::getValue($task, 'params',[]), $common_params ); $cron->addApplicationJob($this->module->phpPath.' '.$this->getYiiPath(), $task['command'], $params, ArrayHelper::getValue($task, 'min'), ArrayHelper::getValue($task, 'hour'), ArrayHelper::getValue($task, 'day'), ArrayHelper::getValue($task, 'month'), ArrayHelper::getValue($task, 'dayofweek'), $this->module->cronGroup //mast be unique for any app on server ); } } $cron->saveCronFile(); // save to my_crontab cronfile $cron->saveToCrontab(); // adds all my_crontab jobs to system (replacing previous my_crontab jobs) echo $this->ansiFormat('Cron Tasks started.' . PHP_EOL, Console::FG_GREEN); } else { echo $this->ansiFormat('Cron do not have Tasks.' . PHP_EOL, Console::FG_GREEN); } }
php
{ "resource": "" }
q817
CronController.actionLs
train
public function actionLs($params = false){ /** * @var $cron Crontab */ if(false == $params) { $cron = $this->module->get($this->module->nameComponent); $jobs = $cron->getJobs(); foreach ($jobs as $index=>$job) { /** * @var $job Cronjob */ if($job->getGroup() == $this->module->cronGroup) echo '['.$index.'] '. $this->ansiFormat($job->getJobCommand(), Console::FG_CYAN); } } elseif($params == 'a' || $params == 'al') { echo shell_exec('crontab -l') . PHP_EOL; } }
php
{ "resource": "" }
q818
ActionsMadeMap.runActionHandler
train
protected function runActionHandler($action, TreeNodeInterface $node) { if ($node instanceof Token) { try { return $action($node->getContent()); } catch (AbortParsingException $e) { if (null === $e->getOffset()) { throw new AbortParsingException($e->getMessage(), $node->getOffset(), $e); } throw $e; } catch (AbortNodeException $e) { throw new AbortParsingException($e->getMessage(), $node->getOffset(), $e); } catch (\Throwable $e) { throw new \RuntimeException("Action failure in `{$this::buildActionName($node)}`", 0, $e); } } $args = []; foreach ($node->getChildren() as $child) { $args[] = $child->made(); } try { $result = $action(...$args); } catch (AbortNodeException $e) { throw new AbortParsingException( $e->getMessage(), $node->getChild($e->getNodeIndex() - 1)->getOffset(), $e ); } catch (AbortParsingException $e) { if (null === $e->getOffset()) { throw new AbortParsingException($e->getMessage(), $node->getOffset(), $e); } throw $e; } catch (\Throwable $e) { throw new \RuntimeException("Action failure in `{$this::buildActionName($node)}`", 0, $e); } if ($this->prune) { $node->prune(); } return $result; }
php
{ "resource": "" }
q819
Extractor.extractTextFromLocalFile
train
public function extractTextFromLocalFile($localFile, $language, $useDefaultDictionaries) { $strURI = Product::$baseProductUri . '/ocr/recognize?language=' . $language . '&useDefaultDictionaries='; $strURI .= ($useDefaultDictionaries) ? 'true' : 'false'; $signedURI = Utils::sign($strURI); $stream = file_get_contents($localFile); $responseStream = Utils::processCommand($signedURI, 'POST', 'json', $stream); $json = json_decode($responseStream); return $json; }
php
{ "resource": "" }
q820
Extractor.extractTextFromUrl
train
public function extractTextFromUrl($url, $language, $useDefaultDictionaries) { $strURI = Product::$baseProductUri . '/ocr/recognize?url=' . $url . '&language=' . $language . '&useDefaultDictionaries=' . $useDefaultDictionaries; $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI); $json = json_decode($responseStream); return $json; }
php
{ "resource": "" }
q821
BaseLexer.parse
train
public function parse(string $input) { $pos = 0; while (null !== ($match = $this->parseOne($input, $pos))) { $pos = $match->nextOffset; yield $match->token; } }
php
{ "resource": "" }
q822
BaseLexer.parseOne
train
public function parseOne(string $input, int $pos, array $preferredTokens = []): ?Match { $length = strlen($input); if ($pos >= $length) { return null; } $this->compile(); $whitespace_length = $this->getWhitespaceLength($input, $pos); if ($whitespace_length) { $pos += $whitespace_length; if ($pos >= $length) { return null; } } $match = $this->match($input, $pos, $preferredTokens); if (!$match) { $near = substr($input, $pos, self::DUMP_NEAR_LENGTH); if ("" === $near || false === $near) { $near = '<EOF>'; } else { $near = '"' . $near . '"'; } throw new UnknownCharacterException( "Cannot parse none of expected tokens near $near", $pos ); } return $match; }
php
{ "resource": "" }
q823
BaseLexer.checkOverlappingNames
train
private function checkOverlappingNames(array $maps): void { $index = 0; foreach ($maps as $type => $map) { $rest_maps = array_slice($maps, $index + 1, null, true); foreach ($rest_maps as $type2 => $map2) { $same = array_intersect_key($map, $map2); if ($same) { throw new \InvalidArgumentException( "Duplicating $type tokens and $type2 tokens: " . join(', ', array_keys($same)) ); } } ++$index; } }
php
{ "resource": "" }
q824
BaseLexer.buildFixedAndInlines
train
private function buildFixedAndInlines(array $fixedMap, array $inlines): array { $overlapped = array_intersect($fixedMap, $inlines); if ($overlapped) { throw new \InvalidArgumentException( "Duplicating fixed tokens and inline tokens strings: " . join(', ', array_map('json_encode', $overlapped)) ); } // $fixedMap all keys are valid names, so + with integer keys will not loss anything $all = $fixedMap + array_values($inlines); // sort in reverse order to let more long items match first // so /'$$' | '$'/ will find ['$$', '$'] in '$$$' and not ['$', '$', '$'] arsort($all, SORT_STRING); $re_map = []; $alias_name = 'a'; foreach ($all as $name => $text) { // inline? if (is_int($name)) { $name = '_' . $alias_name; // string increment $alias_name++; $this->aliased[$name] = $text; $this->aliasOf[$text] = $name; } $re_map[$name] = $this->textToRegExp($text); } return $re_map; }
php
{ "resource": "" }
q825
BaseLexer.buildMap
train
private function buildMap(array $map, string $join): string { $alt = []; foreach ($map as $type => $re) { $alt[] = "(?<$type>$re)"; } if (false !== $join) { $alt = join($join, $alt); } return $alt; }
php
{ "resource": "" }
q826
BaseLexer.match
train
private function match(string $input, int $pos, array $preferredTokens): ?Match { $current_regexp = $this->getRegexpForTokens($preferredTokens); if (false === preg_match($current_regexp, $input, $match, 0, $pos)) { $error_code = preg_last_error(); throw new \RuntimeException( "PCRE error #" . $error_code . " for token at input pos $pos; REGEXP = $current_regexp", $error_code ); } if (!$match) { return null; } $full_match = $match[0]; if ('' === $full_match) { throw new DevException( 'Tokens should not match empty string' . '; context: `' . substr($input, $pos, 10) . '`' . '; expected: ' . json_encode($preferredTokens) . "; REGEXP: $current_regexp" ); } // remove null, empty "" values and integer keys but [0] foreach ($match as $key => $value) { if ( null === $value || '' === $value || (0 !== $key && is_int($key)) ) { unset($match[$key]); } } $named = $match; unset($named[0]); if (1 !== count($named)) { throw new InternalException('Match with multiple named group'); } $content = reset($named); $type = key($named); $is_inline = false; if (isset($this->aliased[$type])) { $type = $this->aliased[$type]; $is_inline = true; } $token = new Token($type, $content, $match, $pos, $is_inline); $result = new Match(); $result->token = $token; $result->nextOffset = $pos + strlen($full_match); return $result; }
php
{ "resource": "" }
q827
BaseLexer.getWhitespaceLength
train
private function getWhitespaceLength(string $input, int $pos): int { if ($this->regexpWhitespace) { if ( false === preg_match( $this->regexpWhitespace, $input, $match, 0, $pos ) ) { $error_code = preg_last_error(); throw new \RuntimeException( "PCRE error #$error_code for whitespace at input pos $pos" . '; REGEXP = ' . $this->regexpWhitespace, $error_code ); } if ($match) { return strlen($match[0]); } } return 0; }
php
{ "resource": "" }
q828
BaseLexer.checkMapNames
train
private function checkMapNames(array $map): void { $names = array_keys($map); $bad_names = preg_grep(self::RE_NAME, $names, PREG_GREP_INVERT); if ($bad_names) { throw new \InvalidArgumentException( 'Bad names: ' . join(', ', $bad_names) ); } }
php
{ "resource": "" }
q829
BaseLexer.validateRegExp
train
private static function validateRegExp(string $regExp, string $displayName): void { /** @uses convertErrorToException() */ set_error_handler([__CLASS__, 'convertErrorToException'], E_WARNING); try { if (false === preg_match($regExp, null)) { throw new \InvalidArgumentException( "PCRE error in $displayName RegExp: $regExp", preg_last_error() ); } } catch (\ErrorException $e) { throw new \InvalidArgumentException( "PCRE error in $displayName RegExp: " . $e->getMessage() . "; RegExp: $regExp", preg_last_error(), $e ); } finally { restore_error_handler(); } }
php
{ "resource": "" }
q830
BaseLexer.textToRegExp
train
protected function textToRegExp(string $text): string { // preg_quote() is useless with /x modifier: https://3v4l.org/brdeT if (false === strpos($this->modifiers, 'x') || !preg_match('~[\\s/#]|\\\\E~', $text)) { return preg_quote($text, '/'); } // foo\Efoo --> \Qfoo\E\\\QEfoo\E // ---^==== --- ^^ ==== // // foo/foo --> \Qfoo\E\/\Qfoo\E // ---^=== --- ^^ === return '\\Q' . strtr($text, ['\\E' => '\\E\\\\\\QE', '/' => '\\E\\/\\Q']) . '\\E'; }
php
{ "resource": "" }
q831
Symbol.compare
train
public static function compare(Symbol $a, Symbol $b): int { return ($a->isTerminal - $b->isTerminal) ?: strcmp($a->name, $b->name); }
php
{ "resource": "" }
q832
Symbol.compareList
train
public static function compareList(array $a, array $b): int { foreach ($a as $i => $symbol) { // $b finished, but $a not yet if (!isset($b[$i])) { // $a > $b return 1; } // $a[$i] <=> $b[$i] $result = static::compare($symbol, $b[$i]); if ($result) { //# $a[$i] <> $b[$i] return $result; } } // $b starts with $a // if $b longer then $a if (count($b) > count($a)) { // $a < $b return -1; } // $a == $b return 0; }
php
{ "resource": "" }
q833
Symbol.dumpName
train
public static function dumpName(string $name): string { if (self::isLikeName($name)) { return $name; } return self::dumpInline($name); }
php
{ "resource": "" }
q834
Symbol.dumpType
train
public static function dumpType(string $type): string { if (self::isLikeName($type)) { return "<$type>"; } return self::dumpInline($type); }
php
{ "resource": "" }
q835
Symbol.dumpInline
train
public static function dumpInline(string $inline): string { if (false === strpos($inline, '"')) { return '"' . $inline . '"'; } if (false === strpos($inline, "'")) { return "'$inline'"; } return "<$inline>"; }
php
{ "resource": "" }
q836
Extractor.getText
train
public function getText() { $strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '/textItems'; $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $json = json_decode($responseStream); return $json->TextItems->List; }
php
{ "resource": "" }
q837
Extractor.getDrawingObject
train
public function getDrawingObject($objectURI, $outputPath) { if ($outputPath == '') throw new Exception('Output path not specified'); if ($objectURI == '') throw new Exception('Object URI not specified'); $url_arr = explode('/', $objectURI); $objectIndex = end($url_arr); $strURI = $objectURI; $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $json = json_decode($responseStream); if ($json->Code == 200) { if ($json->DrawingObject->ImageDataLink != '') { $strURI = $strURI . '/imageData'; $outputPath = $outputPath . '\\DrawingObject_' . $objectIndex . '.jpeg'; } else if ($json->DrawingObject->OleDataLink != '') { $strURI = $strURI . '/oleData'; $outputPath = $outputPath . '\\DrawingObject_' . $objectIndex . '.xlsx'; } else { $strURI = $strURI . '?format=jpeg'; $outputPath = $outputPath . '\\DrawingObject_' . $objectIndex . '.jpeg'; } $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $v_output = Utils::validateOutput($responseStream); if ($v_output === '') { Utils::saveFile($responseStream, $outputPath); return $outputPath; } else return $v_output; } else { return false; } }
php
{ "resource": "" }
q838
Extractor.getProtection
train
public function getProtection() { $strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '/protection'; $signedURI = Utils::sign($strURI); $response = Utils::processCommand($signedURI, 'GET', '', ''); $json = json_decode($response); if ($json->Code == 200) return $json->ProtectionData->ProtectionType; else return false; }
php
{ "resource": "" }
q839
StatementPool.push
train
protected function push(Statement $statement) { $maxConnections = $this->pool->getConnectionLimit(); if ($this->statements->count() > ($maxConnections / 10)) { return; } if ($maxConnections === $this->pool->getConnectionCount() && $this->pool->getIdleConnectionCount() === 0) { return; } $this->statements->push($statement); }
php
{ "resource": "" }
q840
StatementPool.pop
train
protected function pop(): \Generator { while (!$this->statements->isEmpty()) { $statement = $this->statements->shift(); \assert($statement instanceof Statement); if ($statement->isAlive()) { return $statement; } } $statement = yield ($this->prepare)($this->sql); \assert($statement instanceof Statement); return $statement; }
php
{ "resource": "" }
q841
Converter.convertToImagebySize
train
public function convertToImagebySize($slideNumber, $imageFormat, $width, $height) { $strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '/slides/' . $slideNumber . '?format=' . $imageFormat . '&width=' . $width . '&height=' . $height; $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $v_output = Utils::validateOutput($responseStream); if ($v_output == '') { $outputPath = AsposeApp::$outPutLocation . 'output.' . $imageFormat; Utils::saveFile($responseStream, $outputPath); return $outputPath; } else { return $v_output; } }
php
{ "resource": "" }
q842
Converter.convertWithAdditionalSettings
train
public function convertWithAdditionalSettings($saveFormat = 'pdf', $textCompression = '', $embedFullFonts = '', $compliance ='', $jpegQuality = '', $saveMetafilesAsPng = '', $pdfPassword = '', $embedTrueTypeFontsForASCII = '') { $strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '?format=' . $saveFormat; if ($textCompression != '') $strURI .= '&TextCompression=' . $textCompression; if ($embedFullFonts != '') $strURI .= '&EmbedFullFonts=' . $embedFullFonts; if ($compliance != '') $strURI .= '&Compliance=' . $compliance; if ($jpegQuality != '') $strURI .= '&JpegQuality=' . $jpegQuality; if ($saveMetafilesAsPng != '') $strURI .= '&SaveMetafilesAsPng=' . $saveMetafilesAsPng; if ($pdfPassword != '') $strURI .= '&PdfPassword=' . $pdfPassword; if ($embedTrueTypeFontsForASCII != '') $strURI .= '&EmbedTrueTypeFontsForASCII=' . $embedTrueTypeFontsForASCII; $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $v_output = Utils::validateOutput($responseStream); if ($v_output === '') { $outputPath = AsposeApp::$outPutLocation . Utils::getFileName($this->getFileName()) . '.' . $saveFormat; Utils::saveFile($responseStream, $outputPath); return $outputPath; } else { return $v_output; } }
php
{ "resource": "" }
q843
Extractor.getTiffFrameProperties
train
public function getTiffFrameProperties($frameId) { if ($frameId == '') throw new Exception('Frame ID not specified'); //build URI $strURI = Product::$baseProductUri . '/imaging/' . $this->getFileName() . '/frames/' . $frameId . '/properties'; //sign URI $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $json = json_decode($responseStream); if ($json->Code == 200) return $json; else return false; }
php
{ "resource": "" }
q844
Extractor.extractFrames
train
public function extractFrames($frameId, $outPath) { if ($frameId == '') throw new Exception('Frame ID not specified'); if ($outPath == '') throw new Exception('Output file not specified'); //build URI $strURI = Product::$baseProductUri . '/imaging/' . $this->getFileName() . '/frames/' . $frameId . '?saveOtherFrames=false&outPath=' . $outPath; //sign URI $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $v_output = Utils::validateOutput($responseStream); if ($v_output === '') { $folder = new Folder(); $outputStream = $folder->GetFile($outPath); $outputPath = AsposeApp::$outPutLocation . $outPath; Utils::saveFile($outputStream, $outputPath); return $outputPath; } else return $v_output; }
php
{ "resource": "" }
q845
Extractor.cropFrame
train
public function cropFrame($frameId, $x, $y, $recWidth, $recHeight, $outPath) { if ($frameId == '') throw new Exception('Frame ID not specified'); if ($x == '') throw new Exception('X position not specified'); if ($y == '') throw new Exception('Y position not specified'); if ($recWidth == '') throw new Exception('Width of cropping rectangle not specified'); if ($recHeight == '') throw new Exception('Height of cropping rectangle not specified'); if ($outPath == '') throw new Exception('Output file not specified'); //build URI $strURI = Product::$baseProductUri . '/imaging/' . $this->getFileName() . '/frames/' . $frameId . '?saveOtherFrames=true&$x=' . $x . '&y=' . $y . '&rectWidth=' . $recWidth . '&rectHeight=' . $recHeight . '&outPath=' . $outPath; //sign URI $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $v_output = Utils::validateOutput($responseStream); if ($v_output === '') { $folder = new Folder(); $outputStream = $folder->GetFile($outPath); $outputPath = AsposeApp::$outPutLocation . $outPath; Utils::saveFile($outputStream, $outputPath); return $outputPath; } else return $v_output; }
php
{ "resource": "" }
q846
Extractor.manipulateFrame
train
public function manipulateFrame($frameId, $rotateFlipMethod, $newWidth, $newHeight, $x, $y, $rectWidth, $rectHeight, $outPath) { if ($frameId == '') throw new Exception('Frame ID not specified'); if ($rotateFlipMethod == '') throw new Exception('RotateFlip method not specified'); if ($newWidth == '') throw new Exception('New width not specified'); if ($newHeight == '') throw new Exception('New height not specified'); if ($x == '') throw new Exception('X position not specified'); if ($y == '') throw new Exception('Y position not specified'); if ($rectWidth == '') throw new Exception('Width of cropping rectangle not specified'); if ($rectHeight == '') throw new Exception('Height of cropping rectangle not specified'); if ($outPath == '') throw new Exception('Output file not specified'); //build URI $strURI = Product::$baseProductUri . '/imaging/' . $this->getFileName() . '/frames/' . $frameId . '?saveOtherFrames=false&rotateFlipMethod=' . $rotateFlipMethod . '&newWidth=' . $newWidth . '&newHeight=' . $newHeight . '&x=' . $x . '&y=' . $y . '&rectWidth=' . $rectWidth . '&rectHeight=' . $rectHeight . '&outPath=' . $outPath; //sign URI $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $v_output = Utils::validateOutput($responseStream); if ($v_output === '') { $folder = new Folder(); $outputStream = $folder->GetFile($outPath); $outputPath = AsposeApp::$outPutLocation . $outPath; Utils::saveFile($outputStream, $outputPath); return $outputPath; } else return $v_output; }
php
{ "resource": "" }
q847
UserIsAuthor.checkFlag
train
public function checkFlag(array $context): bool { if (!isset($context['user'])) { throw new \InvalidArgumentException(sprintf('The context parameter must contain a "user" key to be able to evaluate the %s flag.', $this->getName())); } $user = $context['user']; if (is_string($user)) { //Anonymous user return false; } if (!($user instanceof UserInterface)) { throw new \InvalidArgumentException(sprintf('The user class must implement Ordermind\LogicalAuthorizationBundle\Interfaces\UserInterface to be able to evaluate the %s flag.', $this->getName())); } if (!isset($context['model'])) { throw new \InvalidArgumentException(sprintf('Missing key "model" in context parameter. We cannot evaluate the %s flag without a model.', $this->getName())); } $model = $context['model']; if (is_string($model) && class_exists($model)) { // A class string was passed which means that we don't have an actual object to evaluate. We interpret this as it not having an author which means that we return false. return false; } if ($model instanceof UserInterface) { return $user->getId() === $model->getId(); } if ($model instanceof ModelInterface) { $author = $model->getAuthor(); // If there is no author it probably means that the entity is not yet persisted. In that case it's reasonable to assume that the current user is the author. // If the lack of author is due to some other reason it's also reasonable to fall back to granting permission because the reason for this flag is to protect models that do have an author against other users. if (!$author) { return true; } if (!($author instanceof UserInterface)) { throw new \InvalidArgumentException(sprintf('The author of the model must implement Ordermind\LogicalAuthorizationBundle\Interfaces\UserInterface to be able to evaluate the %s flag.', $this->getName())); } return $user->getId() === $author->getId(); } throw new \InvalidArgumentException(sprintf('The model class must implement either Ordermind\LogicalAuthorizationBundle\Interfaces\ModelInterface or Ordermind\LogicalAuthorizationBundle\Interfaces\UserInterface to be able to evaluate the %s flag.', $this->getName())); }
php
{ "resource": "" }
q848
Stack.shift
train
public function shift(TreeNodeInterface $node, int $stateIndex): void { $item = new StackItem(); $item->state = $stateIndex; $item->node = $node; if ($this->actions) { $this->actions->applyToNode($node); } $this->items[] = $item; $this->stateIndex = $stateIndex; $this->stateRow = $this->table->getRow($stateIndex); }
php
{ "resource": "" }
q849
Stack.reduce
train
public function reduce(): void { $rule = $this->stateRow->reduceRule; if (!$rule) { throw new NoReduceException(); } $reduce_count = count($rule->getDefinition()); $total_count = count($this->items); if ($total_count < $reduce_count) { throw new InternalException('Not enough items in stack'); } $nodes = []; $offset = null; $reduce_items = array_slice($this->items, -$reduce_count); foreach ($rule->getDefinition() as $i => $symbol) { $item = $reduce_items[$i]; if ($item->node->getNodeName() !== $symbol->getName()) { throw new InternalException('Unexpected stack content'); } if (!$symbol->isHidden()) { $nodes[] = $item->node; } if (null === $offset) { $offset = $item->node->getOffset(); } } $base_state_index = ($total_count > $reduce_count) ? $this->items[$total_count - 1 - $reduce_count]->state : 0; $base_state_row = $this->table->getRow($base_state_index); $new_symbol_name = $rule->getSubject()->getName(); $new_node = new NonTerminal($new_symbol_name, $nodes, $rule->getTag(), $offset); $goto = $base_state_row->gotoSwitches; if (!isset($goto[$new_symbol_name])) { throw new InternalException('No required state in GOTO table'); } $next_state = $goto[$new_symbol_name]; array_splice($this->items, -$reduce_count); $this->shift($new_node, $next_state); }
php
{ "resource": "" }
q850
QuoteManager.setInstallmentDataBeforeAuthorization
train
public function setInstallmentDataBeforeAuthorization($installmentQuantity) { if ($this->_calculator === null) { throw new LocalizedException(new Phrase('You need to set an installment calculator befor prior to' . 'installments')); } /* @var Quote $quote */ $quote = $this->_getQuote(); $interestRate = $this->_getCalculator()->getInterestRateForInstallment($installmentQuantity); $interestAmount = $this->_getCalculator()->getInterestAmount($this->_getPaymentAmount(), $installmentQuantity); $baseinterestAmount = $this->_getCalculator() ->getInterestAmount($this->_getBasePaymentAmount(), $installmentQuantity); $quote ->setGabrielqsInstallmentsQty($installmentQuantity) ->setGabrielqsInstallmentsInterestRate($interestRate) ->setGabrielqsInstallmentsInterestAmount($interestAmount) ->setBaseGabrielqsInstallmentsInterestAmount($baseinterestAmount) ->setTotalsCollectedFlag(false) ->collectTotals(); }
php
{ "resource": "" }
q851
Calculator.getInstallmentConfig
train
public function getInstallmentConfig() { $installmentConfig = $this->_dataObjectFactory->create(); $maxInstallmentQty = $this->getMaximumInstallmentQuantity(); $installmentConfig->maximumInstallmentQty = $maxInstallmentQty; $installmentConfig->minimumInstallmentAmount = $this->getMinimumInstallmentAmount(); $installmentConfig->interestRate = $this->getInterestRate(); $installments = []; # Looping through all possible installment values for ($curInstallment = 1; ($curInstallment <= 12 && $curInstallment <= $maxInstallmentQty); $curInstallment++) { if ($curInstallment === 1) { # If this is a one time payment, we use the current value and only one installment, no interest $installments[$curInstallment] = $this->_dataObjectFactory->create(); $installments[$curInstallment]->interestRate = $this->getInterestRateForInstallment($curInstallment); $installments[$curInstallment]->numberInstallments = 1; $installments[$curInstallment]->minimumAmountNoInterest = null; continue; } else { $installments[$curInstallment] = $this->_dataObjectFactory->create(); $installments[$curInstallment]->interestRate = $this->getInterestRateForInstallment($curInstallment); $installments[$curInstallment]->numberInstallments = $curInstallment; $installments[$curInstallment]->minimumAmountNoInterest = $this->getMinimumAmountNoInterest($curInstallment); } } $installmentConfig->installments = $installments; return $installmentConfig; }
php
{ "resource": "" }
q852
Calculator.getInstallments
train
public function getInstallments($paymentAmount) { $installments = []; $this->setPaymentAmount($paymentAmount); $maxInstallmentQty = $this->getMaximumInstallmentQuantity(); # Looping through all possible installment values for ($curInstallment = 1; ($curInstallment <= 12 && $curInstallment <= $maxInstallmentQty); $curInstallment++) { if ($curInstallment === 1) { # If this is a one time payment, we use the current value and only one installment, no interest $installments[$curInstallment] = $this->_dataObjectFactory->create(); $installments[$curInstallment]->installmentValue = $paymentAmount; $installments[$curInstallment]->numberInstallments = 1; $installments[$curInstallment]->interestsApplied = false; continue; } else { $totalAmountAfterInterest = $this->getTotalAmountAfterInterest($curInstallment); $amountPerInstallment = $totalAmountAfterInterest / $curInstallment; # If the total per installment is less then the minimum installment amount, we won't # include this installment $minimumInstallmentAmount = $this->getMinimumInstallmentAmount(); if ($amountPerInstallment < $minimumInstallmentAmount) { continue; } $installments[$curInstallment] = $this->_dataObjectFactory->create(); $installments[$curInstallment]->installmentValue = $amountPerInstallment; $installments[$curInstallment]->numberInstallments = $curInstallment; $installments[$curInstallment]->interestsApplied = $this->isApplyInterest($curInstallment); } } return (array) $installments; }
php
{ "resource": "" }
q853
Calculator.getInterestAmount
train
public function getInterestAmount($amount, $installmentQuantity) { $minimumAmountNoInterest = $this->getMinimumAmountNoInterest($installmentQuantity); if ( ($minimumAmountNoInterest === null) || ($minimumAmountNoInterest !== null) && ($amount < $minimumAmountNoInterest) ) { $interestRateForInstallment = $this->getInterestRateForInstallment($installmentQuantity); } else { $interestRateForInstallment = 1; } $totalInstallmentAmount = $interestRateForInstallment * $amount; return ($totalInstallmentAmount - $amount); }
php
{ "resource": "" }
q854
Calculator.getInterestRateForInstallment
train
public function getInterestRateForInstallment($installments) { $interestRate = $this->getInterestRate(); $computationInstallments = ($installments - 1); $totalInterestRate = (float) pow($interestRate, $computationInstallments); return $totalInterestRate; }
php
{ "resource": "" }
q855
Calculator.getMinimumAmountNoInterest
train
public function getMinimumAmountNoInterest($installments) { $return = null; foreach ($this->_minimumAmountNoInterest as $installmentQty => $minOrderValue) { if ($installmentQty == $installments) { $return = (float) $minOrderValue; break; } } return $return; }
php
{ "resource": "" }
q856
Calculator.getTotalAmountAfterInterest
train
public function getTotalAmountAfterInterest($installments) { $return = $amount = $this->getPaymentAmount(); if ($this->isApplyInterest($installments)) { $return = ($amount) * $this->getInterestRateForInstallment($installments); } return $return; }
php
{ "resource": "" }
q857
Calculator.isApplyInterest
train
public function isApplyInterest($installments) { $return = true; $interestRate = $this->getInterestRate(); $paymentAmount = $this->getPaymentAmount(); if (($installments > 1) && ($interestRate > 1)) { # If we're not dealing with a one time payment and the interest rate is defined, interest will always be # applied, except when the payment total is higher than the minimum order value for no interest setting $minimumOrderValueNoInterest = $this->getMinimumAmountNoInterest($installments); if ( ($paymentAmount > $minimumOrderValueNoInterest) && ($minimumOrderValueNoInterest !== null) ) { $return = false; } } return $return; }
php
{ "resource": "" }
q858
Consumer.reset
train
public function reset() { // clears the object entirely $this->url = null; $this->params = array(); $this->options = array(); $this->callType = null; $this->responseType = null; }
php
{ "resource": "" }
q859
Consumer.setParams
train
public function setParams($params) { // $param should be a single key => value pair if (is_array($params)) { foreach ($params as $key => $param) { $this->params[$key] = $param; } } }
php
{ "resource": "" }
q860
Consumer.setOptions
train
public function setOptions($options) { // $param should be a single key => value pair if (is_array($options)) { foreach ($options as $key => $option) { $this->options[$key] = $option; } } }
php
{ "resource": "" }
q861
Consumer.doApiCall
train
public function doApiCall() { $parsedResponse = array(); $jsonResponse = false; $curlUrl = $this->createUrl(); if ($curlUrl) { $jsonResponse = $this->submitCurlRequest($curlUrl); } if ($jsonResponse) { $parsedResponse = $this->parseJsonResponse($jsonResponse); } return $parsedResponse; }
php
{ "resource": "" }
q862
Consumer.createUrl
train
public function createUrl() { $curlUrl = $this->url . '?'; foreach ($this->params as $key => $value) { $curlUrl .= $key . '=' . $value; $curlUrl .= '&'; } return $curlUrl; }
php
{ "resource": "" }
q863
Consumer.submitCurlRequest
train
protected function submitCurlRequest($curlUrl) { $session = curl_init(); curl_setopt($session, CURLOPT_URL, $curlUrl); curl_setopt($session, CURLOPT_HEADER, 0); curl_setopt($session, CURLOPT_RETURNTRANSFER, 1); if (!empty($this->options)) { foreach ($this->options as $key => $value) { curl_setopt($session, $key, $value); } } $rawResponse = curl_exec($session); curl_close($session); return $rawResponse; }
php
{ "resource": "" }
q864
Utils.processCommand
train
public static function processCommand($url, $method = 'GET', $headerType = 'XML', $src = '', $returnType = 'xml') { $dispatcher = AsposeApp::getEventDispatcher(); $method = strtoupper($method); $headerType = strtoupper($headerType); AsposeApp::getLogger()->info("Aspose Cloud SDK: processCommand called", array( 'url' => $url, 'method' => $method, 'headerType' => $headerType, 'src' => $src, 'returnType' => $returnType, )); $session = curl_init(); curl_setopt($session, CURLOPT_URL, $url); if ($method == 'GET') { curl_setopt($session, CURLOPT_HTTPGET, 1); } else { curl_setopt($session, CURLOPT_POST, 1); curl_setopt($session, CURLOPT_POSTFIELDS, $src); curl_setopt($session, CURLOPT_CUSTOMREQUEST, $method); } curl_setopt($session, CURLOPT_HEADER, false); if ($headerType == 'XML') { curl_setopt($session, CURLOPT_HTTPHEADER, array('Accept: application/' . $returnType . '', 'Content-Type: application/xml', 'x-aspose-client: PHPSDK/v1.0')); } else { curl_setopt($session, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'x-aspose-client: PHPSDK/v1.0')); } curl_setopt($session, CURLOPT_RETURNTRANSFER, true); if (preg_match('/^(https)/i', $url)) curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false); // Allow users to register curl options before the call is executed $event = new ProcessCommandEvent($session); $dispatcher->dispatch(ProcessCommandEvent::PRE_CURL, $event); $result = curl_exec($session); $headers = curl_getinfo($session); if (substr($headers['http_code'], 0, 1) != '2') { if (curl_errno($session) !== 0) { throw new AsposeCurlException(curl_strerror(curl_errno($session)), $headers, curl_errno($session)); AsposeApp::getLogger()->warning(curl_strerror(curl_errno($session))); } else { throw new Exception($result); AsposeApp::getLogger()->warning($result); } } else { if (preg_match('/You have processed/i', $result) || preg_match('/Your pricing plan allows only/i', $result)) { AsposeApp::getLogger()->alert($result); throw new Exception($result); } } // Allow users to alter the result $event = new ProcessCommandEvent($session, $result); /** @var ProcessCommandEvent $dispatchedEvent */ $dispatchedEvent = $dispatcher->dispatch(ProcessCommandEvent::POST_CURL, $event); curl_close($session); // TODO test or the Event result needs to be returned in case an listener was triggered return $dispatchedEvent->getResult(); }
php
{ "resource": "" }
q865
Utils.uploadFileBinary
train
public static function uploadFileBinary($url, $localFile, $headerType = 'XML', $method = 'PUT') { $method = strtoupper($method); $headerType = strtoupper($headerType); AsposeApp::getLogger()->info("Aspose Cloud SDK: uploadFileBinary called", array( 'url' => $url, 'localFile' => $localFile, 'headerType' => $headerType, 'method' => $method, )); $fp = fopen($localFile, 'r'); $session = curl_init(); curl_setopt($session, CURLOPT_VERBOSE, 1); curl_setopt($session, CURLOPT_USERPWD, 'user:password'); curl_setopt($session, CURLOPT_URL, $url); if ($method == 'PUT') { curl_setopt($session, CURLOPT_PUT, 1); } else { curl_setopt($session, CURLOPT_UPLOAD, true); curl_setopt($session, CURLOPT_CUSTOMREQUEST, 'POST'); } curl_setopt($session, CURLOPT_RETURNTRANSFER, 1); curl_setopt($session, CURLOPT_HEADER, false); if ($headerType == 'XML') { curl_setopt($session, CURLOPT_HTTPHEADER, array('Accept: application/xml', 'Content-Type: application/xml', 'x-aspose-client: PHPSDK/v1.0')); } else { curl_setopt($session, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'x-aspose-client: PHPSDK/v1.0')); } curl_setopt($session, CURLOPT_INFILE, $fp); curl_setopt($session, CURLOPT_INFILESIZE, filesize($localFile)); $result = curl_exec($session); curl_close($session); fclose($fp); return $result; }
php
{ "resource": "" }
q866
Utils.saveFile
train
public static function saveFile($input, $fileName) { $fh = fopen($fileName, 'w') or die('cant open file'); fwrite($fh, $input); fclose($fh); }
php
{ "resource": "" }
q867
Utils.getFieldCount
train
public function getFieldCount($jsonResponse, $fieldName) { $arr = json_decode($jsonResponse)->{$fieldName}; return count($arr, COUNT_RECURSIVE); }
php
{ "resource": "" }
q868
WeChatVideoDriver.getVideo
train
private function getVideo() { $videoUrl = 'http://file.api.wechat.com/cgi-bin/media/get?access_token='.$this->getAccessToken().'&media_id='.$this->event->get('MediaId'); return [new Video($videoUrl, $this->event)]; }
php
{ "resource": "" }
q869
BarcodeReader.read
train
public function read($symbology) { //build URI to read barcode $strURI = Product::$baseProductUri . '/barcode/' . $this->getFileName() . '/recognize?' . (!isset($symbology) || trim($symbology) === '' ? 'type=' : 'type=' . $symbology); //sign URI $signedURI = Utils::sign($strURI); //get response stream $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $json = json_decode($responseStream); //returns a list of extracted barcodes return $json->Barcodes; }
php
{ "resource": "" }
q870
BarcodeReader.readFromLocalImage
train
public function readFromLocalImage($localImage, $remoteFolder, $barcodeReadType) { $folder = new Folder(); $folder->UploadFile($localImage, $remoteFolder); $data = $this->ReadR(basename($localImage), $remoteFolder, $barcodeReadType); return $data; }
php
{ "resource": "" }
q871
BarcodeReader.readR
train
public function readR($remoteImageName, $remoteFolder, $readType) { $uri = $this->uriBuilder($remoteImageName, $remoteFolder, $readType); $signedURI = Utils::sign($uri); $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $json = json_decode($responseStream); return $json->Barcodes; }
php
{ "resource": "" }
q872
BarcodeReader.uriBuilder
train
public function uriBuilder($remoteImage, $remoteFolder, $readType) { $uri = Product::$baseProductUri . '/barcode/'; if ($remoteImage != null) $uri .= $remoteImage . '/'; $uri .= 'recognize?'; if ($readType == 'AllSupportedTypes') $uri .= 'type='; else $uri .= 'type=' . $readType; if ($remoteFolder != null && trim($remoteFolder) === '') $uri .= '&format=' . $remoteFolder; if ($remoteFolder != null && trim($remoteFolder) === '') $uri .= '&folder=' . $remoteFolder; return $uri; }
php
{ "resource": "" }
q873
BarcodeReader.readFromURL
train
public function readFromURL($url, $symbology) { if ($url == '') throw new Exception('URL not specified'); if ($symbology == '') throw new Exception('Symbology not specified'); //build URI to read barcode $strURI = Product::$baseProductUri . '/barcode/recognize?type=' . $symbology . '&url=' . $url; //sign URI $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'POST', '', ''); $json = json_decode($responseStream); if ($json->Code == 200) return $json->Barcodes; else return false; }
php
{ "resource": "" }
q874
BarcodeReader.readSpecificRegion
train
public function readSpecificRegion($symbology, $rectX, $rectY, $rectWidth, $rectHeight) { if ($symbology == '') throw new Exception('Symbology not specified'); if ($rectX == '') throw new Exception('X position not specified'); if ($rectY == '') throw new Exception('Y position not specified'); if ($rectWidth == '') throw new Exception('Width not specified'); if ($rectHeight == '') throw new Exception('Height not specified'); //build URI to read barcode $strURI = Product::$baseProductUri . '/barcode/' . $this->getFileName() . '/recognize?type=' . $symbology . '&rectX=' . $rectX . '&rectY=' . $rectY . '&rectWidth=' . $rectWidth . '&rectHeight=' . $rectHeight; //sign URI $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $json = json_decode($responseStream); if ($json->Code == 200) return $json->Barcodes; else return false; }
php
{ "resource": "" }
q875
BarcodeReader.readWithChecksum
train
public function readWithChecksum($symbology, $checksumValidation) { if ($symbology == '') throw new Exception('Symbology not specified'); if ($checksumValidation == '') throw new Exception('Checksum not specified'); //build URI to read barcode $strURI = Product::$baseProductUri . '/barcode/' . $this->getFileName() . '/recognize?type=' . $symbology . '&checksumValidation=' . $checksumValidation; //sign URI $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $json = json_decode($responseStream); if ($json->Code == 200) return $json->Barcodes; else return false; }
php
{ "resource": "" }
q876
BarcodeReader.readByAlgorithm
train
public function readByAlgorithm($symbology, $binarizationHints) { if ($symbology == '') throw new Exception('Symbology not specified'); if ($binarizationHints == '') throw new Exception('Binarization Hints count not specified'); //build URI to read barcode $strURI = Product::$baseProductUri . '/barcode/' . $this->getFileName() . '/recognize?type=' . $symbology . '&BinarizationHints=' . $binarizationHints; //sign URI $signedURI = Utils::sign($strURI); $response = Utils::processCommand($signedURI, 'GET', '', ''); $json = json_decode($response); if ($json->Code == 200) return $json->Barcodes; else return false; }
php
{ "resource": "" }
q877
Field.insertPageNumber
train
public function insertPageNumber($fileName, $alignment, $format, $isTop, $setPageNumberOnFirstPage) { //check whether files are set or not if ($fileName == '') throw new Exception('File not specified'); //Build JSON to post $fieldsArray = array('Format' => $format, 'Alignment' => $alignment, 'IsTop' => $isTop, 'SetPageNumberOnFirstPage' => $setPageNumberOnFirstPage); $json = json_encode($fieldsArray); //build URI to insert page number $strURI = Product::$baseProductUri . '/words/' . $fileName . '/insertPageNumbers'; //sign URI $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'POST', 'json', $json); $v_output = Utils::validateOutput($responseStream); if ($v_output === '') { //Save docs on server $folder = new Folder(); $outputStream = $folder->GetFile($fileName); $outputPath = AsposeApp::$outPutLocation . $fileName; Utils::saveFile($outputStream, $outputPath); return $outputPath; } else return $v_output; }
php
{ "resource": "" }
q878
Field.getMailMergeFieldNames
train
public function getMailMergeFieldNames($fileName) { //check whether file is set or not if ($fileName == '') throw new Exception('No file name specified'); $strURI = Product::$baseProductUri . '/words/' . $fileName . '/mailMergeFieldNames'; $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $json = json_decode($responseStream); return $json->FieldNames->Names; }
php
{ "resource": "" }
q879
ProductRepository.query
train
public function query($q = null) { return Product::where(function ($query) use ($q) { if ($q) { foreach (explode(' ', $q) as $keyword) { $query->where('description', 'like', "%{$keyword}%"); } } }) ->orderBy('description') ->paginate(); }
php
{ "resource": "" }
q880
ProductRepository.save
train
public function save(ProductContract $product, array $attributes = []) { $result = $product->save(); $details = []; foreach ($attributes as $key => $value) { if ($value) { $details[$key] = compact('value'); } } $product->attributes()->sync($details); return $result; }
php
{ "resource": "" }
q881
Resource.getResources
train
public function getResources() { //build URI $strURI = Product::$baseProductUri . '/tasks/' . $this->getFileName() . '/resources/'; //sign URI $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $json = json_decode($responseStream); if ($json->Code == 200) return $json->Resources->ResourceItem; else return false; }
php
{ "resource": "" }
q882
Resource.getResource
train
public function getResource($resourceId) { if ($resourceId == '') throw new Exception('Resource ID not specified'); //build URI $strURI = Product::$baseProductUri . '/tasks/' . $this->getFileName() . '/resources/' . $resourceId; //sign URI $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $json = json_decode($responseStream); if ($json->Code == 200) return $json->Resource; else return false; }
php
{ "resource": "" }
q883
HasStub.getStubContent
train
protected function getStubContent($name) { if (!isset(static::$stubs[$name])) { if (!is_file($path = base_path("resources/stubs/vendor/models-generator/$name.stub"))) { $path = __DIR__."/../../resources/stubs/$name.stub"; } static::$stubs[$name] = file_get_contents($path); } return static::$stubs[$name]; }
php
{ "resource": "" }
q884
CommentsHelper.handle
train
public static function handle($model) { if (!$model->load(Yii::$app->request->post())) return false; return $model->save(); }
php
{ "resource": "" }
q885
Query.querySync
train
public function querySync(){ $adapter = $this->_dbAdapter ?: Table::getDefaultDbAdapter(); return $adapter->querySync($this->assemble(), $this->_bind, $this->_consistency, $this->_options); }
php
{ "resource": "" }
q886
Query.prepare
train
public function prepare(){ $adapter = $this->_dbAdapter ?: Table::getDefaultDbAdapter(); return $adapter->prepare($this->assemble()); }
php
{ "resource": "" }
q887
Config.loadParameters
train
public function loadParameters() { $container = \System::getContainer(); if ($container->hasParameter('contao.video.valid_extensions')) { $GLOBALS['TL_CONFIG']['validVideoTypes'] = implode(',', $container->getParameter('contao.video.valid_extensions')); } if ($container->hasParameter('contao.audio.valid_extensions')) { $GLOBALS['TL_CONFIG']['validAudioTypes'] = implode(',', $container->getParameter('contao.audio.valid_extensions')); } }
php
{ "resource": "" }
q888
Session.getFromRequest
train
public static function getFromRequest($create = true) { $sessionData = [ 'LastIP' => inet_pton($_SERVER['REMOTE_ADDR']), 'LastRequest' => time(), ]; // try to load from cookie if (!empty($_COOKIE[static::$cookieName])) { if ($Session = static::getByHandle($_COOKIE[static::$cookieName])) { // update session & check expiration $Session = static::updateSession($Session, $sessionData); } } // try to load from any request method if (empty($Session) && !empty($_REQUEST[static::$cookieName])) { if ($Session = static::getByHandle($_REQUEST[static::$cookieName])) { // update session & check expiration $Session = static::updateSession($Session, $sessionData); } } if (!empty($Session)) { // session found return $Session; } elseif ($create) { // create session return static::create($sessionData, true); } else { // no session available return false; } }
php
{ "resource": "" }
q889
EditorController.overviewAction
train
public function overviewAction( Request $request, FormFactoryInterface $formFactory, ExtraFormBuilderInterface $extraFormBuilder ) { $formName = 'overview'; $data = $request->request->get($formName); $configurationRaw = $data['configuration']; $configuration = json_decode($configurationRaw, true); $overviewBuilder = $formFactory ->createNamedBuilder($formName) ->setAction($this->generateUrl('idci_extra_form_editor_overview')) ->add('configuration', HiddenType::class, array( 'data' => $configurationRaw, )) ; $form = $extraFormBuilder ->build($configuration, array(), array(), $overviewBuilder) ->add('submit', SubmitType::class) ->getForm() ; // The form overview has been submitted if (count($data) > 1) { $form->handleRequest($request); if ($form->isValid()) { return new Response('This form was well submitted'); } } // Render the form with or without errors return $this->render('@IDCIExtraForm/Editor/overview.html.twig', array( 'form' => $form->createView(), )); }
php
{ "resource": "" }
q890
ImageThumb.create
train
public function create($filename = null, array $options = [], array $plugins = []) { try { $thumb = new PHPThumb($filename, $options, $plugins); } catch (\Exception $exc) { throw new Exception\RuntimeException($exc->getMessage(), $exc->getCode(), $exc); } return $thumb; }
php
{ "resource": "" }
q891
ImageThumb.createReflection
train
public function createReflection($percent, $reflection, $white, $border, $borderColor) { return new Plugins\Reflection($percent, $reflection, $white, $border, $borderColor); }
php
{ "resource": "" }
q892
ImageThumb.createWatermark
train
public function createWatermark(PHPThumb $watermarkThumb, array $position = [0, 0], $scale = .5) { return new Plugins\Watermark($watermarkThumb, $position, $scale); }
php
{ "resource": "" }
q893
Table.offsetSet
train
public function offsetSet($columnName, $value) { if (!in_array($columnName, static::$_primary)){ $this->_modifiedData[$columnName] = $value; } parent::offsetSet($columnName, $value); }
php
{ "resource": "" }
q894
SerializerSubscriber.onPreSerialize
train
public function onPreSerialize(ObjectEvent $event) { $configuredType = $event->getObject(); if ($configuredType instanceof ConfiguredType) { try { $configurationArray = json_decode($configuredType->getConfiguration(), true); $extraFormType = $this->registry->getType($configurationArray['form_type']); $configuredType->setExtraFormType($extraFormType); } catch (\Exception $e) { return; } } }
php
{ "resource": "" }
q895
Comments.outputComment
train
protected function outputComment($comment) { if ($this->commentOptions instanceof \Closure) { $options = call_user_func($this->commentOptions, $comment); } else { $options = $this->commentOptions; } $options = ArrayHelper::merge($options, ['data-comment-id'=>$comment->id]); if ($this->useBootstrapClasses) Html::addCssClass($options, 'media'); //render comment echo Html::beginTag('div', $options); //body $wrapperOptions = ['class'=>'comment-wrapper']; if ($this->useBootstrapClasses) Html::addCssClass($wrapperOptions, 'media-body'); echo Html::beginTag('div', $wrapperOptions); //title if (!empty($comment->title)) { $titleOptions = ['class'=>'comment-title']; if ($this->useBootstrapClasses) Html::addCssClass($titleOptions, 'media-heading'); $title = $this->encodeCommentTitle ? Html::encode($comment->title) : $comment->title; echo Html::tag($this->commentTitleTag, $title, $titleOptions); } //content $content = $this->encodeCommentContents ? Html::encode($comment->content) : $comment->content; echo Html::tag('div', $content, ['class'=>'comment-content']); //meta echo Html::beginTag('dl', ['class'=>'comment-meta']); echo Html::tag('dt', Yii::t('app', 'Created')); echo Html::tag('dd', Yii::$app->formatter->asDatetime($comment->created)); if (!empty($comment->updated) && $comment->updated != $comment->created) { echo Html::tag('dt', Yii::t('app', 'Updated')); echo Html::tag('dd', Yii::$app->formatter->asDatetime($comment->updated)); } if (!empty($comment->user_id)) { $author = $this->authorCallback === null ? $comment->created_by : call_user_func($this->authorCallback, $comment->created_by); echo Html::tag('dt', Yii::t('app', 'Author')); echo Html::tag('dd', $author); } echo Html::endTag('dl'); echo Html::endTag('div'); echo Html::endTag('div'); }
php
{ "resource": "" }
q896
PHPGit_Repository.create
train
public static function create($dir, $debug = false, array $options = array()) { $options = array_merge(self::$defaultOptions, $options); $commandString = $options['git_executable'].' init'; $command = new $options['command_class']($dir, $commandString, $debug); $command->run(); $repo = new self($dir, $debug, $options); return $repo; }
php
{ "resource": "" }
q897
PHPGit_Repository.cloneUrl
train
public static function cloneUrl($url, $dir, $debug = false, array $options = array()) { $options = array_merge(self::$defaultOptions, $options); $commandString = $options['git_executable'].' clone '.escapeshellarg($url).' '.escapeshellarg($dir); $command = new $options['command_class'](getcwd(), $commandString, $debug); $command->run(); $repo = new self($dir, $debug, $options); return $repo; }
php
{ "resource": "" }
q898
PHPGit_Repository.getCommits
train
public function getCommits($nbCommits = 10) { $output = $this->git(sprintf('log -n %d --date=%s --format=format:%s', $nbCommits, $this->dateFormat, $this->logFormat)); return $this->parseLogsIntoArray($output); }
php
{ "resource": "" }
q899
PHPGit_Repository.parseLogsIntoArray
train
private function parseLogsIntoArray($logOutput) { $commits = array(); foreach(explode("\n", $logOutput) as $line) { $infos = explode('|', $line); $commits[] = array( 'id' => $infos[0], 'tree' => $infos[1], 'author' => array( 'name' => $infos[2], 'email' => $infos[3] ), 'authored_date' => $infos[4], 'commiter' => array( 'name' => $infos[5], 'email' => $infos[6] ), 'committed_date' => $infos[7], 'message' => $infos[8] ); } return $commits; }
php
{ "resource": "" }