_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q700 | Worksheet.getPicturesCount | train | public function getPicturesCount()
{
//check whether workshett name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
'/worksheets/' . $this->worksheetName . '/pictures';
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return count($json->Pictures->PictureList);
} | php | {
"resource": ""
} |
q701 | Worksheet.getOleObjectsCount | train | public function getOleObjectsCount()
{
//check whether workshett name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
'/worksheets/' . $this->worksheetName . '/oleobjects';
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return count($json->OleObjects->OleObjectList);
} | php | {
"resource": ""
} |
q702 | Worksheet.getCommentsCount | train | public function getCommentsCount()
{
//check whether workshett name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
'/worksheets/' . $this->worksheetName . '/comments';
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return count($json->Comments->CommentList);
} | php | {
"resource": ""
} |
q703 | Worksheet.freezePanes | train | public function freezePanes($row = 1, $col = 1, $freezedRows = 1, $freezedCols = 1)
{
//check whether worksheet name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
'/worksheets/' . $this->worksheetName . '/FreezePanes?row=' . $row . '&column=' . $col . '&freezedRows=' . $freezedRows . '&freezedColumns=' . $freezedCols;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'PUT', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200)
return true;
else
return false;
} | php | {
"resource": ""
} |
q704 | Worksheet.updateProperties | train | public function updateProperties($properties = array())
{
//check whether worksheet name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
'/workbook/worksheets/' . $this->worksheetName;
$signedURI = Utils::sign($strURI);
$json_data = json_encode($properties);
$responseStream = Utils::processCommand($signedURI, 'POST', 'json', $json_data);
$json = json_decode($responseStream);
if ($json->Code == 200)
return $json->Worksheet;
else
return false;
} | php | {
"resource": ""
} |
q705 | Worksheet.moveWorksheet | train | public function moveWorksheet($worksheetName, $position)
{
//check whether worksheet name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$fieldsArray['DestinationWorsheet'] = $worksheetName;
$fieldsArray['Position'] = $position;
$jsonData = json_encode($fieldsArray);
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
'/worksheets/' . $this->worksheetName . '/position';
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', 'json', $jsonData);
$json = json_decode($responseStream);
if ($json->Code == 200)
return true;
else
return false;
} | php | {
"resource": ""
} |
q706 | Worksheet.calculateFormula | train | public function calculateFormula($formula)
{
//check whether worksheet name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
'/worksheets/' . $this->worksheetName . '/formulaResult?formula=' . $formula;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return $json->Value->Value;
} | php | {
"resource": ""
} |
q707 | Worksheet.setCellValue | train | public function setCellValue($cellName, $valueType, $value)
{
//check whether worksheet name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
'/worksheets/' . $this->worksheetName . '/cells/' . $cellName . '?value=' . $value . '&type=' . $valueType;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200)
return true;
else
return false;
} | php | {
"resource": ""
} |
q708 | Worksheet.getRowsCount | train | public function getRowsCount($offset, $count)
{
//check whether worksheet name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
'/worksheets/' . $this->worksheetName . '/cells/rows?offset=' . $offset . '&count=' . $count;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return $json->Rows->RowsCount;
} | php | {
"resource": ""
} |
q709 | Worksheet.copyRows | train | public function copyRows($sourceRowIndex = 1, $destRowIndex = 1, $rowNumber = 1)
{
//check whether worksheet name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
'/worksheets/' . $this->worksheetName . '/cells/rows/copy?sourceRowIndex=' . $sourceRowIndex . '&destinationRowIndex=' . $destRowIndex . '&rowNumber=' . $rowNumber;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200)
return true;
else
return false;
} | php | {
"resource": ""
} |
q710 | Worksheet.getRow | train | public function getRow($rowIndex)
{
//check whether worksheet name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
'/worksheets/' . $this->worksheetName . '/cells/rows/' . $rowIndex;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return $json->Row;
} | php | {
"resource": ""
} |
q711 | Worksheet.getColumn | train | public function getColumn($columnIndex)
{
//check whether worksheet name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
'/worksheets/' . $this->worksheetName . '/cells/columns/' . $columnIndex;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return $json->Column;
} | php | {
"resource": ""
} |
q712 | Worksheet.sortData | train | public function sortData(array $dataSort, $cellArea = '')
{
//check whether worksheet name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
'/worksheets/' . $this->worksheetName . '/sort?cellArea=' . $cellArea;
$json_array = json_encode($dataSort);
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', 'json', $json_array);
$json = json_decode($responseStream);
if ($json->Code == 200)
return true;
else
return false;
} | php | {
"resource": ""
} |
q713 | Worksheet.setCellStyle | train | public function setCellStyle($cellName, array $style)
{
//check whether worksheet name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
'/worksheets/' . $this->worksheetName . '/cells/' . $cellName . '/style';
$jsonArray = json_encode($style);
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', 'json', $jsonArray);
$json = json_decode($responseStream);
if ($json->Code == 200)
return true;
else
return false;
} | php | {
"resource": ""
} |
q714 | Worksheet.getCell | train | public function getCell($cellName)
{
if ($this->worksheetName == '') {
throw new Exception('No Worksheet Specified');
}
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets/' . $this->worksheetName . '/cells/' . $cellName;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', 'json');
$json = json_decode($responseStream);
if ($json->Code == 200) {
return $json->Cell;
} else {
return false;
}
} | php | {
"resource": ""
} |
q715 | Worksheet.addPicture | train | public function addPicture($picturePath, $pictureLocation, $upperLeftRow = 0, $upperLeftColumn = 0, $lowerRightRow = 0, $lowerRightColumn = 0)
{
if ($this->worksheetName == '') {
throw new Exception('No Worksheet Specified');
}
if ($pictureLocation == 'Server' || $pictureLocation == 'server') {
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets/' . $this->worksheetName . '/pictures?upperLeftRow=' .
$upperLeftRow . '&upperLeftColumn=' . $upperLeftColumn .
'&lowerRightRow=' . $lowerRightRow . '&lowerRightColumn=' . $lowerRightColumn .
'&picturePath=' . $picturePath;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'PUT');
} else if ($pictureLocation == 'Local' || $pictureLocation == 'local') {
if (!file_exists($picturePath)) {
throw new Exception('File Does not Exists');
}
$stream = file_get_contents($picturePath);
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets/' . $this->worksheetName . '/pictures?upperLeftRow=' .
$upperLeftRow . '&upperLeftColumn=' . $upperLeftColumn .
'&lowerRightRow=' . $lowerRightRow . '&lowerRightColumn=' . $lowerRightColumn .
'&picturePath=' . $picturePath;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'PUT', '', $stream);
}
$json = json_decode($responseStream);
if ($json->Code == 200) {
return true;
} else {
return false;
}
} | php | {
"resource": ""
} |
q716 | Worksheet.addOleObject | train | public function addOleObject($oleFile = '', $imageFile = '', $upperLeftRow = 0, $upperLeftColumn = 0, $height = 0, $width = 0)
{
if ($this->worksheetName == '') {
throw new Exception('No Worksheet Specified');
}
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets/' . $this->worksheetName . '/oleobjects?upperLeftRow=' .
$upperLeftRow . '&upperLeftColumn=' . $upperLeftColumn .
'&height=' . $height . '&width=' . $width .
'&oleFile=' . $oleFile . '&imageFile=' . $imageFile;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'PUT');
$json = json_decode($responseStream);
if ($json->Code == 200) {
return true;
} else {
return false;
}
} | php | {
"resource": ""
} |
q717 | Worksheet.updateOleObject | train | public function updateOleObject($objectIndex, $object_data)
{
//Build URI
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets/' . $this->worksheetName . '/oleobjects/' . $objectIndex;
//Sign URI
$signedURI = Utils::sign($strURI);
//Send request and receive response stream
$responseStream = Utils::processCommand($signedURI, 'POST', 'json', $object_data);
$json = json_decode($responseStream);
return $json;
} | php | {
"resource": ""
} |
q718 | Worksheet.updatePicture | train | public function updatePicture($pictureIndex, $picture_data)
{
//Build URI
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets/' . $this->worksheetName . '/pictures/' . $pictureIndex;
//Sign URI
$signedURI = Utils::sign($strURI);
//Send request and receive response stream
$responseStream = Utils::processCommand($signedURI, 'POST', 'json', $picture_data);
$json = json_decode($responseStream);
return $json;
} | php | {
"resource": ""
} |
q719 | Worksheet.addEmptyRow | train | public function addEmptyRow($rowId)
{
if ($rowId == '')
throw new Exception('Row ID not specified');
//Build URI
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets/' . $this->worksheetName . '/cells/rows/' . $rowId;
//Sign URI
$signedURI = Utils::sign($strURI);
//Send request and receive response
$response = Utils::processCommand($signedURI, 'PUT', '', '');
$json = json_decode($response);
if ($json->Code == 200)
return $json->Row;
else
return false;
} | php | {
"resource": ""
} |
q720 | Worksheet.setFormula | train | public function setFormula($cellName, $formula)
{
if ($cellName == '')
throw new Exception('Cell Name not specified');
if ($formula == '')
throw new Exception('Formula not specified');
//Build URI
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets/' . $this->worksheetName .
'/cells/' . $cellName . '?formula=' . $formula;
//Sign URI
$signedURI = Utils::sign($strURI);
//Send request and receive response
$response = Utils::processCommand($signedURI, 'POST', '', '');
$json = json_decode($response);
if ($json->Code == 200)
return $json->Cell;
else
return false;
} | php | {
"resource": ""
} |
q721 | Worksheet.clearCellsContents | train | public function clearCellsContents($range)
{
if ($range == '')
throw new Exception('Range not specified');
//Build URI
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets/' . $this->worksheetName .
'/cells/clearcontents?range=' . $range;
//Sign URI
$signedURI = Utils::sign($strURI);
//Send request and receive response
$response = Utils::processCommand($signedURI, 'POST', '', '');
$json = json_decode($response);
if ($json->Code == 200)
return true;
else
return false;
} | php | {
"resource": ""
} |
q722 | Worksheet.mergeCells | train | public function mergeCells($startRow, $startColumn, $totalRows, $totalColumns)
{
if ($startRow == '')
throw new Exception('Start Row not specified');
if ($startColumn == '')
throw new Exception('Start Column not specified');
if ($totalRows == '')
throw new Exception('Total Rows not specified');
if ($totalColumns == '')
throw new Exception('Total Columns not specified');
//Build URI
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets/' . $this->worksheetName .
'/cells/merge?startrow=' . $startRow . '&startcolumn=' . $startColumn .
'&totalrows=' . $totalRows . '&totalcolumns=' . $totalColumns;
//Sign URI
$signedURI = Utils::sign($strURI);
//Send request and receive response
$response = Utils::processCommand($signedURI, 'POST', '', '');
$json = json_decode($response);
if ($json->Code == 200) {
$strURI = Product::$baseProductUri . '/storage/file/' . $this->getFileName();
$signedURI = Utils::Sign($strURI);
$responseStream = Utils::processCommand($signedURI, "GET", "", "");
$outputPath = AsposeApp::$outPutLocation . $this->getFileName();
Utils::saveFile($responseStream, $outputPath);
return $outputPath;
}
else
return false;
} | php | {
"resource": ""
} |
q723 | Worksheet.setRangeValue | train | public function setRangeValue($cellarea, $value, $type)
{
if ($cellarea == '')
throw new Exception('Cellarea not specified');
if ($value == '')
throw new Exception('Value not specified');
if ($type == '')
throw new Exception('Type not specified');
//Build URI
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets/' . $this->worksheetName .
'/cells?cellarea=' . $cellarea . '&value=' . $value . '&type=' . $type;
//Sign URI
$signedURI = Utils::sign($strURI);
//Send request and receive response stream
$responseStream = Utils::processCommand($signedURI, 'POST', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output == '') {
$strURI = Product::$baseProductUri . '/storage/file/' . $this->getFileName();
$signedURI = Utils::Sign($strURI);
$responseStream = Utils::processCommand($signedURI, "GET", "", "");
$outputPath = AsposeApp::$outPutLocation . $this->getFileName();
Utils::saveFile($responseStream, $outputPath);
return $outputPath;
}
else
return $v_output;
} | php | {
"resource": ""
} |
q724 | Worksheet.clearCellsFormatting | train | public function clearCellsFormatting($startRow, $startColumn, $endRow, $endColumn)
{
if ($startRow == '')
throw new Exception('Start Row not specified');
if ($startColumn == '')
throw new Exception('Start Column not specified');
if ($endRow == '')
throw new Exception('End Row not specified');
if ($endColumn == '')
throw new Exception('End Column not specified');
//Build URI
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets/' . $this->worksheetName .
'/cells/ClearFormats?startRow=' . $startRow . '&startColumn=' . $startColumn .
'&endRow=' . $endRow . '&endColumn=' . $endColumn;
//Sign URI
$signedURI = Utils::sign($strURI);
//Send request and receive response stream
$responseStream = Utils::processCommand($signedURI, 'POST', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output == '') {
$strURI = Product::$baseProductUri . '/storage/file/' . $this->getFileName();
$signedURI = Utils::Sign($strURI);
$responseStream = Utils::processCommand($signedURI, "GET", "", "");
$outputPath = AsposeApp::$outPutLocation . $this->getFileName();
Utils::saveFile($responseStream, $outputPath);
return $outputPath;
}
else
return $v_output;
} | php | {
"resource": ""
} |
q725 | TableRow.isReduceOnly | train | public function isReduceOnly(): bool
{
return !$this->eofAction
&& !$this->terminalActions
&& !$this->gotoSwitches
&& $this->reduceRule;
} | php | {
"resource": ""
} |
q726 | WeChatLocationDriver.getLocation | train | private function getLocation()
{
return new Location($this->event->get('Location_X'), $this->event->get('Location_Y'), $this->event);
} | php | {
"resource": ""
} |
q727 | TextEditor.getText | train | public function getText()
{
$parameters = func_get_args();
//set parameter values
if (count($parameters) > 0) {
$pageNumber = $parameters[0];
}
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() .
((isset($parameters[0])) ? '/pages/' . $pageNumber . '/TextItems' : '/TextItems');
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
$rawText = '';
foreach ($json->TextItems->List as $textItem) {
$rawText .= $textItem->Text;
}
return $rawText;
} | php | {
"resource": ""
} |
q728 | TextEditor.getTextItems | train | public function getTextItems()
{
$parameters = func_get_args();
//set parameter values
if (count($parameters) == 1) {
$pageNumber = $parameters[0];
} else if (count($parameters) == 2) {
$pageNumber = $parameters[0];
$fragmentNumber = $parameters[1];
}
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName();
if (isset($parameters[0])) {
$strURI .= '/pages/' . $pageNumber;
if (isset($parameters[1])) {
$strURI .= '/fragments/' . $fragmentNumber;
}
}
$strURI .= '/TextItems';
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return $json->TextItems->List;
} | php | {
"resource": ""
} |
q729 | TextEditor.getPagesWordCount | train | public function getPagesWordCount()
{
try {
$strURI = Product::$baseProductUri . "/pdf/" . $this->getFileName() . "/pages/wordCount";
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, "GET", "", "");
$json = json_decode($responseStream);
return $json->WordsPerPage->List;
} catch (Exception $e) {
throw new Exception($e->getMessage());
}
} | php | {
"resource": ""
} |
q730 | TextEditor.getSegmentCount | train | public function getSegmentCount($pageNumber = '', $fragmentNumber = '')
{
if ($pageNumber == '')
throw new Exception('page number not specified');
if ($fragmentNumber == '')
throw new Exception('fragment number not specified');
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/pages/' . $pageNumber . '/fragments/' . $fragmentNumber;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return count($json->TextItems->List);
} | php | {
"resource": ""
} |
q731 | TextEditor.getTextFormat | train | public function getTextFormat()
{
$args = func_get_args();
if (count($args) == 2) {
$pageNumber = $args[0];
$fragmentNumber = $args[1];
}
if (count($args) == 3) {
$pageNumber = $args[0];
$fragmentNumber = $args[1];
$segamentNumber = $args[2];
}
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/pages/' . $pageNumber .
'/fragments/' . $fragmentNumber;
if (isset($segamentNumber)) {
$strURI .= '/segments/' . '/textformat';
} else {
$strURI .= '/textformat';
}
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return $json->TextFormat;
} | php | {
"resource": ""
} |
q732 | Client.getMessageDefaults | train | public function getMessageDefaults($key = null)
{
if (is_null($key)) {
return $this->messageDefaults;
}
if (isset($this->messageDefaults[$key])) {
return $this->messageDefaults[$key];
}
} | php | {
"resource": ""
} |
q733 | Client.sendMessage | train | public function sendMessage($message)
{
if ($payload = $this->getJsonPayload($message)) {
$response = $this->getHttpClient()
->post($this->getWebhook(), [
'headers' => ['Content-Type' => 'application/json'],
'body' => $payload,
]);
return 200 === $response->getStatusCode();
}
return false;
} | php | {
"resource": ""
} |
q734 | Client.getJsonPayload | train | protected function getJsonPayload($message)
{
if (is_array($message) || $message instanceof JsonSerializable) {
return json_encode($message);
} elseif (method_exists($message, 'toJson')) {
return $message->toJson();
} elseif (method_exists($message, 'toArray')) {
return json_encode($message->toArray());
} elseif (is_string($message) && is_array(json_decode($message, true))) {
return $message;
}
} | php | {
"resource": ""
} |
q735 | Document.changeSlidePosition | train | public function changeSlidePosition($old_position = '', $new_position = '', $storageName = '', $folder = '')
{
if ($old_position == '' || $new_position == '')
throw new Exception('Missing Required Params');
$strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '/slides?OldPosition=' . $old_position . '&NewPosition=' . $new_position;
if ($folder != '') {
$strURI .= 'folder=' . $folder;
}
if ($storageName != '') {
$strURI .= '&storage=' . $storageName;
}
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200)
return $json->Slides;
else
return false;
} | php | {
"resource": ""
} |
q736 | Document.cloneSlide | train | public function cloneSlide($slideno = '', $position = '', $storageName = '', $folder = '')
{
if ($position == '')
throw new Exception('Position not speciefied.');
if ($slideno == '')
throw new Exception('Slide not speciefied.');
$strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '/slides?SlideToClone=' . $slideno . '&Position=' . $position;
if ($folder != '') {
$strURI .= 'folder=' . $folder;
}
if ($storageName != '') {
$strURI .= '&storage=' . $storageName;
}
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200)
return $json->Slides;
else
return false;
} | php | {
"resource": ""
} |
q737 | Document.splitPresentation | train | public function splitPresentation($from = '', $to = '', $destination = '', $format = '', $storageName = '', $folder = '')
{
$strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '/split?';
if ($folder != '') {
$strURI .= '&folder=' . $folder;
}
if ($storageName != '') {
$strURI .= '&storage=' . $storageName;
}
if ($from != '') {
$strURI .= '&from=' . $from;
}
if ($to != '') {
$strURI .= '&to=' . $to;
}
if ($destination != '') {
$strURI .= '&destFolder=' . $destination;
}
if ($format != '') {
$strURI .= '&format=' . $format;
}
$strURI = rtrim($strURI, '?');
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200) {
foreach ($json->SplitResult->Slides as $splitPage) {
$splitFileName = basename($splitPage->Href);
//build URI to download split slides
$strURI = Product::$baseProductUri . '/storage/file/' . $splitFileName;
//sign URI
$signedURI = Utils::Sign($strURI);
$responseStream = Utils::processCommand($signedURI, "GET", "", "");
//save split slides
$outputFile = AsposeApp::$outPutLocation . $splitFileName;
Utils::saveFile($responseStream, $outputFile);
}
} else
return false;
} | php | {
"resource": ""
} |
q738 | Document.mergePresentations | train | public function mergePresentations($presentationsList = array(), $storageName = '', $folder = '')
{
if (!is_array($presentationsList) || empty($presentationsList))
throw new Exception('Presentation list not speciefied');
$strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '/merge';
if ($folder != '') {
$strURI .= '?folder=' . $folder;
}
if ($storageName != '') {
$strURI .= '&storage=' . $storageName;
}
$signedURI = Utils::sign($strURI);
$json_data = json_encode($presentationsList);
$responseStream = Utils::processCommand($signedURI, 'PUT', 'json', $json_data);
$json = json_decode($responseStream);
if ($json->Code == 200)
return $json->Document;
else
return false;
} | php | {
"resource": ""
} |
q739 | Document.createEmptyPresentation | train | public function createEmptyPresentation($storageName = '', $folder = '')
{
//Build URI to get a list of slides
$strURI = Product::$baseProductUri . '/slides/' . $this->getFileName();
if ($folder != '') {
$strURI .= '?folder=' . $folder;
}
if ($storageName != '') {
$strURI .= '&storage=' . $storageName;
}
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'PUT', '', '');
$json = json_decode($responseStream);
if ($json->Code == 201)
return $json->Document;
else
return false;
} | php | {
"resource": ""
} |
q740 | Document.getSlideCount | train | public function getSlideCount($storageName = '', $folder = '')
{
//Build URI to get a list of slides
$strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '/slides';
if ($folder != '') {
$strURI .= '?folder=' . $folder;
}
if ($storageName != '') {
$strURI .= '&storage=' . $storageName;
}
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return count($json->Slides->SlideList);
} | php | {
"resource": ""
} |
q741 | Document.getAllTextItems | train | public function getAllTextItems()
{
$parameters = func_get_args();
//set parameter values
if (count($parameters) == 2) {
$slideNumber = $parameters[0];
$withEmpty = $parameters[1];
}
//Build URI to get all text items
$strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() .
((isset($parameters[0])) ? '/slides/' . $slideNumber . '/textItems?withEmpty=' . $withEmpty : '/textItems');
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return $json->TextItems->Items;
} | php | {
"resource": ""
} |
q742 | Document.addCustomProperty | train | public function addCustomProperty($propertiesList)
{
if ($propertiesList == '')
throw new Exception('Properties not specified');
//build URI to merge Docs
$strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '/documentProperties';
$put_data = json_encode($propertiesList);
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'PUT', 'json', $put_data);
$json = json_decode($responseStream);
return $json;
} | php | {
"resource": ""
} |
q743 | Document.saveAs | train | public function saveAs($outputPath, $saveFormat, $jpegQuality = '', $storageName = '', $folder = '')
{
if ($outputPath == '')
throw new Exception('Output path not specified');
if ($saveFormat == '')
throw new Exception('Save format not specified');
$strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '?format=' . $saveFormat;
if ($folder != '') {
$strURI .= '&folder=' . $folder;
}
if ($storageName != '') {
$strURI .= '&storage=' . $storageName;
}
if ($jpegQuality != '') {
$strURI .= '&jpegQuality=' . $jpegQuality;
}
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
$output = $outputPath . Utils::getFileName($this->getFileName()) . '.' . $saveFormat;
Utils::saveFile($responseStream, $output);
return $output;
} else
return $v_output;
} | php | {
"resource": ""
} |
q744 | Document.saveSlideAs | train | public function saveSlideAs($slideNumber, $outputPath, $saveFormat)
{
if ($outputPath == '')
throw new Exception('Output path not specified');
if ($saveFormat == '')
throw new Exception('Save format not specified');
if ($slideNumber == '')
throw new Exception('Slide number not specified');
$strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '/slides/' . $slideNumber . '?format=' . $saveFormat;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
$output = $outputPath . Utils::getFileName($this->getFileName()) . '_' . $slideNumber . '.' . $saveFormat;
Utils::saveFile($responseStream, $output);
return $output;
} else
return $v_output;
} | php | {
"resource": ""
} |
q745 | Document.aspectRatio | train | public function aspectRatio($slideNumber)
{
if ($slideNumber == '')
throw new Exception('Slide number not specified');
//build URI
$strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '/slides/' . $slideNumber;
//sign URI
$signedURI = Utils::sign($strURI);
$response = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($response);
if ($json->Code == 200)
return $json->Slide->Width / $json->Slide->Height;
else
return false;
} | php | {
"resource": ""
} |
q746 | TextLoader.wantSymbol | train | private function wantSymbol(string $name, bool $isHidden = false, bool $isInline = false): Symbol
{
if ($isInline) {
if (!isset($this->inline[$name]) && isset($this->symbols[$name])) {
throw new GrammarException(
"Inline '$name' conflicts with token <$name> defined previously"
);
}
if (isset($this->defines[$name])) {
throw new GrammarException("Inline '$name' conflicts with DEFINE");
}
$this->inline[$name] = $name;
$isHidden = true;
} else {
if (isset($this->inline[$name])) {
throw new GrammarException(
"Token <$name> conflicts with inline '$name' defined previously"
);
}
if (isset($this->defines[$name])) {
throw new GrammarException("Token <$name> conflicts with DEFINE");
}
}
return $this->symbols[$name][$isHidden]
?? ($this->symbols[$name][$isHidden] = new Symbol($name, true, $isHidden));
} | php | {
"resource": ""
} |
q747 | Calendar.getCalendars | train | public function getCalendars()
{
//build URI
$strURI = Product::$baseProductUri . '/tasks/' . $this->getFileName() . '/calendars/';
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200)
return $json->Calendars->List;
else
return false;
} | php | {
"resource": ""
} |
q748 | Calendar.getCalendar | train | public function getCalendar($calendarUid)
{
if ($calendarUid == '')
throw new Exception('Calendar Uid not specified');
//build URI
$strURI = Product::$baseProductUri . '/tasks/' . $this->getFileName() . '/calendars/' . $calendarUid;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200)
return $json->Calendar;
else
return false;
} | php | {
"resource": ""
} |
q749 | Calendar.addCalendar | train | public function addCalendar($jsonData)
{
if ($jsonData == '')
throw new Exception('Data not specified');
//build URI
$strURI = Product::$baseProductUri . '/tasks/' . $this->getFileName() . '/calendars/';
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', 'json', $jsonData);
$json = json_decode($responseStream);
if ($json->Status == 'Created')
return $json->CalendarItem;
else
return false;
} | php | {
"resource": ""
} |
q750 | Lexer.defines | train | public function defines(array $defines): self
{
if (!$defines) {
return $this;
}
$dup_keys = array_intersect_key($this->defines, $defines);
if ($dup_keys) {
throw new \InvalidArgumentException(
"Cannot redefine defines: " . join(', ', array_keys($dup_keys))
);
}
$copy = clone $this;
$copy->defines += $defines;
return $copy;
} | php | {
"resource": ""
} |
q751 | Lexer.whitespaces | train | public function whitespaces(array $whitespaces): self
{
if (!$whitespaces) {
return $this;
}
$copy = clone $this;
$copy->whitespaces = array_merge($copy->whitespaces, $whitespaces);
return $copy;
} | php | {
"resource": ""
} |
q752 | Lexer.fixed | train | public function fixed(array $fixed): self
{
if (!$fixed) {
return $this;
}
$new_fixed = $this->addNamedTokens($this->fixed, $fixed, 'fixed');
$copy = clone $this;
$copy->fixed = $new_fixed;
return $copy;
} | php | {
"resource": ""
} |
q753 | Lexer.inline | train | public function inline(array $inline): self
{
if (!$inline) {
return $this;
}
$copy = clone $this;
$copy->inlines = array_merge($this->inlines, $inline);
return $copy;
} | php | {
"resource": ""
} |
q754 | Lexer.terminals | train | public function terminals(array $terminals): self
{
if (!$terminals) {
return $this;
}
$new_terminals = $this->addNamedTokens($this->regexpMap, $terminals, 'terminal');
$copy = clone $this;
$copy->regexpMap = $new_terminals;
return $copy;
} | php | {
"resource": ""
} |
q755 | Lexer.modifiers | train | public function modifiers(string $modifiers): self
{
if ('' === $modifiers) {
return $this;
}
$copy = clone $this;
$copy->modifiers .= $modifiers;
return $copy;
} | php | {
"resource": ""
} |
q756 | Lexer.addNamedTokens | train | private function addNamedTokens(array $oldTokens, array $addTokens, string $errorType): array
{
$dup_keys = array_intersect_key($oldTokens, $addTokens);
if ($dup_keys) {
throw new \InvalidArgumentException(
"Cannot redefine $errorType: " . join(', ', array_keys($dup_keys))
);
}
return $oldTokens + $addTokens;
} | php | {
"resource": ""
} |
q757 | AnnotationEditor.getAllAnnotations | train | public function getAllAnnotations($pageNumber)
{
$iTotalAnnotation = $this->GetAnnotationsCount($pageNumber);
$listAnnotations = array();
for ($index = 1; $index <= $iTotalAnnotation; $index++) {
array_push($listAnnotations, $this->GetAnnotation($pageNumber, $index));
}
return $listAnnotations;
} | php | {
"resource": ""
} |
q758 | AnnotationEditor.getAnnotationsCount | train | public function getAnnotationsCount($pageNumber)
{
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/pages/' . $pageNumber . '/annotations';
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return count($json->Annotations->List);
} | php | {
"resource": ""
} |
q759 | AnnotationEditor.getAnnotation | train | public function getAnnotation($pageNumber, $annotationIndex)
{
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/pages/' . $pageNumber . '/annotations/' . $annotationIndex;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return $json->Annotation;
} | php | {
"resource": ""
} |
q760 | AnnotationEditor.getChildBookmarksCount | train | public function getChildBookmarksCount($parent)
{
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/bookmarks/' . $parent . '/bookmarks';
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return count($json->Bookmarks->List);
} | php | {
"resource": ""
} |
q761 | AnnotationEditor.getChildBookmark | train | public function getChildBookmark($parentIndex, $childIndex)
{
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/bookmarks/' . $parentIndex . '/bookmarks/' . $childIndex;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return $json->Bookmark;
} | php | {
"resource": ""
} |
q762 | AnnotationEditor.isChildBookmark | train | public function isChildBookmark($bookmarkIndex)
{
if ($bookmarkIndex === '')
throw new Exception('bookmark index not specified');
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/bookmarks/' . $bookmarkIndex;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return $json->Bookmark;
} | php | {
"resource": ""
} |
q763 | AnnotationEditor.getAllBookmarks | train | public function getAllBookmarks()
{
$iTotalBookmarks = $this->GetBookmarksCount();
$listBookmarks = array();
for ($index = 1; $index <= $iTotalBookmarks; $index++) {
array_push($listBookmarks, $this->GetBookmark($index));
}
return $listBookmarks;
} | php | {
"resource": ""
} |
q764 | AnnotationEditor.getAllAttachments | train | public function getAllAttachments()
{
$iTotalAttachments = $this->GetAttachmentsCount();
$listAttachments = array();
for ($index = 1; $index <= $iTotalAttachments; $index++) {
array_push($listAttachments, $this->GetAttachment($index));
}
return $listAttachments;
} | php | {
"resource": ""
} |
q765 | AnnotationEditor.getAttachmentsCount | train | public function getAttachmentsCount()
{
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/attachments';
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return count($json->Attachments->List);
} | php | {
"resource": ""
} |
q766 | AnnotationEditor.getAttachment | train | public function getAttachment($attachmentIndex)
{
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/attachments/' . $attachmentIndex;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return $json->Attachment;
} | php | {
"resource": ""
} |
q767 | AnnotationEditor.downloadAttachment | train | public function downloadAttachment($attachmentIndex)
{
$fileInformation = $this->GetAttachment($attachmentIndex);
//build URI to download attachment
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/attachments/' . $attachmentIndex . '/download';
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
Utils::saveFile($responseStream, AsposeApp::$outPutLocation . $fileInformation->Name);
return '';
} else
return $v_output;
} | php | {
"resource": ""
} |
q768 | AnnotationEditor.getAllLinks | train | public function getAllLinks($pageNumber)
{
$iTotalLinks = $this->GetLinksCount($pageNumber);
$listLinks = array();
for ($index = 1; $index <= $iTotalLinks; $index++) {
array_push($listLinks, $this->GetLink($pageNumber, $index));
}
return $listLinks;
} | php | {
"resource": ""
} |
q769 | AnnotationEditor.getLinksCount | train | public function getLinksCount($pageNumber)
{
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/pages/' . $pageNumber . '/links';
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return count($json->Links->List);
} | php | {
"resource": ""
} |
q770 | AnnotationEditor.getLink | train | public function getLink($pageNumber, $linkIndex)
{
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/pages/' . $pageNumber . '/links/' . $linkIndex;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return $json->Link;
} | php | {
"resource": ""
} |
q771 | Role.checkPermission | train | public function checkPermission($role, $context)
{
if (!is_string($role)) {
throw new \TypeError('The role parameter must be a string.');
}
if (!$role) {
throw new \InvalidArgumentException('The role parameter cannot be empty.');
}
if (!is_array($context)) {
throw new \TypeError('The context parameter must be an array.');
}
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 SecurityUserInterface)) {
throw new \InvalidArgumentException('The user class must implement Symfony\Component\Security\Core\User\UserInterface to be able to evaluate the user role.');
}
$roles = $user->getRoles();
// Use Symfony Security Role class to make roles compatible with RoleHierarchy::getReachableRoles().
foreach ($roles as $i => $thisRole) {
if (is_string($thisRole)) {
$roles[$i] = new SecurityRole($thisRole);
} elseif (!($thisRole instanceof SecurityRole)) {
throw new \InvalidArgumentException('One of the roles of this user is neither a string nor an instance of Symfony\Component\Security\Core\Role\Role.');
}
}
$roles = $this->roleHierarchy->getReachableRoles($roles);
foreach ($roles as $thisRole) {
$strRole = (string) $thisRole->getRole();
if ($role === $strRole) {
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q772 | Connect2PayClient.getAccountInformation | train | public function getAccountInformation() {
$url = $this->url . self::$API_ROUTES['ACCOUNT_INFO'];
$url .= '?apiVersion=' . $this->apiVersion;
$result = $this->doGet($url, array(), false);
if ($result !== null && is_object($result)) {
$accountInfo = AccountInformation::getFromJson($result);
if ($accountInfo != null) {
return $accountInfo;
}
}
return null;
} | php | {
"resource": ""
} |
q773 | Connect2PayClient.preparePayment | train | public function preparePayment() {
if ($this->validate()) {
$trans = array();
foreach ($this->fieldsJSON as $fieldName) {
if (is_array($this->{$fieldName}) || !C2PValidate::isEmpty($this->{$fieldName})) {
$trans[$fieldName] = $this->{"get" . ucfirst($fieldName)}();
}
}
// Only PHP >= 5.4 has JSON_UNESCAPED_SLASHES option
$post_data = str_replace('\\/', '/', json_encode($trans));
$url = $this->url . Connect2PayClient::$API_ROUTES['TRANS_PREPARE'];
$result = $this->doPost($url, $post_data);
if ($result != null && is_array($result)) {
$this->returnCode = $result['code'];
$this->returnMessage = $result['message'];
if ($this->returnCode == "200") {
$this->merchantToken = $result['merchantToken'];
$this->customerToken = $result['customerToken'];
return true;
} else {
$this->clientErrorMessage = $this->returnMessage;
}
}
}
return false;
} | php | {
"resource": ""
} |
q774 | Connect2PayClient.getPaymentStatus | train | public function getPaymentStatus($merchantToken) {
if ($merchantToken != null && strlen(trim($merchantToken)) > 0) {
$url = $this->url . str_replace(":merchantToken", $merchantToken, Connect2PayClient::$API_ROUTES['PAYMENT_STATUS']);
$url .= '?apiVersion=' . $this->apiVersion;
$result = $this->doGet($url, array(), false);
if ($result !== null && is_object($result)) {
$this->initStatus($result);
if (isset($this->status)) {
return $this->status;
}
}
}
return null;
} | php | {
"resource": ""
} |
q775 | Connect2PayClient.refundTransaction | train | public function refundTransaction($transactionID, $amount) {
if ($transactionID !== null && $amount !== null && (is_int($amount) || ctype_digit($amount))) {
$url = $this->url . str_replace(":transactionID", $transactionID, Connect2PayClient::$API_ROUTES['TRANS_REFUND']);
$trans = array();
$trans['apiVersion'] = $this->apiVersion;
$trans['amount'] = intval($amount);
$result = $this->doPost($url, json_encode($trans));
$this->status = null;
if ($result != null && is_array($result)) {
$this->status = new RefundStatus();
if (isset($result['code'])) {
$this->status->setCode($result['code']);
}
if (isset($result['message'])) {
$this->status->setMessage($result['message']);
}
if (isset($result['transactionID'])) {
$this->status->setTransactionID($result['transactionID']);
}
if (isset($result['operation'])) {
$this->status->setOperation($result['operation']);
}
return $this->status;
} else {
$this->clientErrorMessage = 'No result received from refund call';
}
} else {
$this->clientErrorMessage = '"transactionID" must not be null, "amount" must be a positive integer';
}
return null;
} | php | {
"resource": ""
} |
q776 | Connect2PayClient.cancelSubscription | train | public function cancelSubscription($subscriptionID, $cancelReason) {
if ($subscriptionID != null && is_numeric($subscriptionID) && isset($cancelReason) && is_numeric($cancelReason)) {
$url = $this->url . str_replace(":subscriptionID", $subscriptionID, Connect2PayClient::$API_ROUTES['SUB_CANCEL']);
$trans = array();
$trans['apiVersion'] = $this->apiVersion;
$trans['cancelReason'] = intval($cancelReason);
$result = $this->doPost($url, json_encode($trans));
if ($result != null && is_array($result)) {
$this->clientErrorMessage = $result['message'];
return $result['code'];
}
} else {
$this->clientErrorMessage = 'subscriptionID and cancelReason must be not null and numeric';
}
return null;
} | php | {
"resource": ""
} |
q777 | Connect2PayClient.directAliPayProcess | train | public function directAliPayProcess($customerToken, $request) {
if ($customerToken !== null && $request !== null) {
$url = $this->url . str_replace(":customerToken", $customerToken, Connect2PayClient::$API_ROUTES['ALIPAY_DIRECT_PROCESS']);
$request->setApiVersion($this->getApiVersion());
$result = $this->doPost($url, json_encode($request), false);
if ($result != null && is_object($result)) {
$apiResponse = AliPayDirectProcessResponse::getFromJson($result);
return $apiResponse;
} else {
$this->clientErrorMessage = 'No result received from direct AliPay processing call: ' . $this->clientErrorMessage;
}
} else {
$this->clientErrorMessage = '"customerToken" and "request" must not be null';
}
return null;
} | php | {
"resource": ""
} |
q778 | Connect2PayClient.validate | train | public function validate() {
$arrErrors = array();
$arrErrors = $this->validateFields();
if (sizeof($arrErrors) > 0) {
foreach ($arrErrors as $error) {
$this->clientErrorMessage .= $error . " * ";
}
return false;
}
return true;
} | php | {
"resource": ""
} |
q779 | Connect2PayClient.addCartProduct | train | public function addCartProduct($cartProduct) {
if ($this->orderCartContent == null || !is_array($this->orderCartContent)) {
$this->orderCartContent = array();
}
if ($cartProduct instanceof CartProduct) {
$this->orderCartContent[] = $cartProduct;
}
return $this;
} | php | {
"resource": ""
} |
q780 | Connect2PayClient.setDefaultOrderCartContent | train | public function setDefaultOrderCartContent() {
$this->orderCartContent = array();
$product = new CartProduct();
$product->setCartProductId(0)->setCartProductName("NA");
$product->setCartProductUnitPrice(0)->setCartProductQuantity(1);
$product->setCartProductBrand("NA")->setCartProductMPN("NA");
$product->setCartProductCategoryName("NA")->setCartProductCategoryID(0);
$this->orderCartContent[] = $product;
} | php | {
"resource": ""
} |
q781 | Connect2PayClient.validateFields | train | private function validateFields() {
$fieldsRequired = $this->fieldsRequired;
$returnError = array();
foreach ($fieldsRequired as $field) {
if (C2PValidate::isEmpty($this->{$field}) && (!is_numeric($this->{$field})))
$returnError[] = $field . ' is empty';
}
foreach ($this->fieldsSize as $field => $size) {
if (isset($this->{$field}) && C2PValidate::strlen($this->{$field}) > $size)
$returnError[] = $field . ' Length ' . $size;
}
foreach ($this->fieldsValidate as $field => $method) {
if (!C2PValidate::isEmpty($this->{$field}) && !call_user_func(array('PayXpert\Connect2Pay\C2PValidate', $method), $this->{$field}))
$returnError[] = $field . ' = ' . $this->{$field};
}
return $returnError;
} | php | {
"resource": ""
} |
q782 | PaymentStatus.getLastInitialTransactionAttempt | train | public function getLastInitialTransactionAttempt() {
$lastAttempt = null;
if (isset($this->transactions) && is_array($this->transactions) && count($this->transactions) > 0) {
// Return the entry with the highest timestamp with type sale, authorize,
// or submission
foreach ($this->transactions as $transaction) {
if (in_array($transaction->getOperation(), array("sale", "authorize", "submission")) && $transaction->getRefTransactionID() == null) {
if ($lastAttempt == null || $lastAttempt->getDate() < $transaction->getDate()) {
$lastAttempt = $transaction;
}
}
}
}
return $lastAttempt;
} | php | {
"resource": ""
} |
q783 | PaymentStatus.getReferringTransactionAttempt | train | public function getReferringTransactionAttempt($refTransactionId, $transactionOperation) {
$attempts = $this->getReferringTransactionAttempts($refTransactionId, $transactionOperation);
if (is_array($attempts) && count($attempts) > 0) {
return $attempts[0];
}
return null;
} | php | {
"resource": ""
} |
q784 | PaymentStatus.getReferringTransactionAttempts | train | public function getReferringTransactionAttempts($refTransactionId, $transactionOperation = null) {
$attempts = array();
if ($refTransactionId !== null && isset($this->transactions) && is_array($this->transactions) && count($this->transactions) > 0) {
foreach ($this->transactions as $transaction) {
if ($refTransactionId === $transaction->getRefTransactionId() &&
($transactionOperation == null || $transactionOperation === $transaction->getOperation())) {
$attempts[] = $transaction;
}
}
// Sort the array by transaction date ascending
if (count($attempts) > 1) {
usort($attempts,
function ($t1, $t2) {
$date1 = $t1->getDate();
$date2 = $t2->getDate();
if ($date1 === null && $date2 !== null) {
return -1;
}
if ($date1 !== null && $date2 === null) {
return 1;
}
return ($date1 === $date2 ? 0 : ($date1 < $date2 ? -1 : 1));
});
}
}
return $attempts;
} | php | {
"resource": ""
} |
q785 | Connect2PayCurrencyHelper.getISO4217CurrencyFromCode | train | public static function getISO4217CurrencyFromCode($code) {
foreach (Connect2PayCurrencyHelper::$currencies as $currency => $data) {
if ($data["code"] == $code) {
return $currency;
}
}
return null;
} | php | {
"resource": ""
} |
q786 | Connect2PayCurrencyHelper.getISO4217CurrencyCode | train | public static function getISO4217CurrencyCode($currency) {
return (array_key_exists($currency, Connect2PayCurrencyHelper::$currencies)) ? Connect2PayCurrencyHelper::$currencies[$currency]["code"] : null;
} | php | {
"resource": ""
} |
q787 | Connect2PayCurrencyHelper.getCurrencySymbol | train | public static function getCurrencySymbol($currency) {
return (array_key_exists($currency, Connect2PayCurrencyHelper::$currencies)) ? Connect2PayCurrencyHelper::$currencies[$currency]["symbol"] : null;
} | php | {
"resource": ""
} |
q788 | Connect2PayCurrencyHelper.getCurrencyName | train | public static function getCurrencyName($currency) {
return (array_key_exists($currency, Connect2PayCurrencyHelper::$currencies)) ? Connect2PayCurrencyHelper::$currencies[$currency]["currency"] : null;
} | php | {
"resource": ""
} |
q789 | Connect2PayCurrencyHelper.getRate | train | public static function getRate($from, $to) {
// Check if currencies exists
if (!Connect2PayCurrencyHelper::currencyIsAvailable($from) || !Connect2PayCurrencyHelper::currencyIsAvailable($to)) {
return null;
}
// Build the request URL
$url = Connect2PayCurrencyHelper::$APIIO_SERVICE_URL . date("Y-m-d") . "?base=" . $from . "&symbols=" . $to;
// Do the request
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
if (Connect2PayCurrencyHelper::$proxy_host != null && Connect2PayCurrencyHelper::$proxy_port != null) {
curl_setopt($curl, CURLOPT_PROXY, Connect2PayCurrencyHelper::$proxy_host);
curl_setopt($curl, CURLOPT_PROXYPORT, Connect2PayCurrencyHelper::$proxy_port);
if (Connect2PayCurrencyHelper::$proxy_username != null && Connect2PayCurrencyHelper::$proxy_password != null) {
curl_setopt($curl, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_PROXYUSERPWD,
Connect2PayCurrencyHelper::$proxy_username . ":" . Connect2PayCurrencyHelper::$proxy_password);
}
}
$json = trim(curl_exec($curl));
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if ($httpCode == 200) {
// Parse the CSV, we should only have a number, check this
$obj = json_decode($json, true);
if (is_array($obj) && array_key_exists("rates", $obj) && array_key_exists($to, $obj['rates']) &&
preg_match('/^[0-9.]+$/', $obj['rates'][$to])) {
return $obj['rates'][$to];
}
}
return null;
} | php | {
"resource": ""
} |
q790 | Connect2PayCurrencyHelper.convert | train | public static function convert($amount, $from, $to, $cent = true) {
// Get the conversion rate
$rate = Connect2PayCurrencyHelper::getRate($from, $to);
if ($rate != null) {
$convert = $amount * $rate;
// If the amount was in cent, truncate the digit after the comma
// else round the result to 2 digits only
return ($cent) ? round($convert, 0) : round($convert, 2);
}
return null;
} | php | {
"resource": ""
} |
q791 | C2PValidate.isPaymentMethod | train | static public function isPaymentMethod($paymentMethod) {
return ((string) $paymentMethod == Connect2PayClient::PAYMENT_METHOD_CREDITCARD ||
(string) $paymentMethod == Connect2PayClient::PAYMENT_METHOD_TODITOCASH ||
(string) $paymentMethod == Connect2PayClient::PAYMENT_METHOD_BANKTRANSFER ||
(string) $paymentMethod == Connect2PayClient::PAYMENT_METHOD_DIRECTDEBIT ||
(string) $paymentMethod == Connect2PayClient::PAYMENT_METHOD_WECHAT ||
(string) $paymentMethod == Connect2PayClient::PAYMENT_METHOD_LINE ||
(string) $paymentMethod == Connect2PayClient::PAYMENT_METHOD_ALIPAY);
} | php | {
"resource": ""
} |
q792 | C2PValidate.isPaymentNetwork | train | static public function isPaymentNetwork($paymentNetwork) {
return ((string) $paymentNetwork == Connect2PayClient::PAYMENT_NETWORK_SOFORT ||
(string) $paymentNetwork == Connect2PayClient::PAYMENT_NETWORK_PRZELEWY24 ||
(string) $paymentNetwork == Connect2PayClient::PAYMENT_NETWORK_IDEAL ||
(string) $paymentNetwork == Connect2PayClient::PAYMENT_NETWORK_GIROPAY ||
(string) $paymentNetwork == Connect2PayClient::PAYMENT_NETWORK_EPS ||
(string) $paymentNetwork == Connect2PayClient::PAYMENT_NETWORK_POLI ||
(string) $paymentNetwork == Connect2PayClient::PAYMENT_NETWORK_DRAGONPAY ||
(string) $paymentNetwork == Connect2PayClient::PAYMENT_NETWORK_TRUSTLY);
} | php | {
"resource": ""
} |
q793 | C2PValidate.isPaymentMode | train | static public function isPaymentMode($paymentMode) {
return ((string) $paymentMode == Connect2PayClient::PAYMENT_MODE_SINGLE ||
(string) $paymentMode == Connect2PayClient::PAYMENT_MODE_ONSHIPPING ||
(string) $paymentMode == Connect2PayClient::PAYMENT_MODE_RECURRENT ||
(string) $paymentMode == Connect2PayClient::PAYMENT_MODE_INSTALMENTS);
} | php | {
"resource": ""
} |
q794 | C2PValidate.isSubscriptionType | train | static public function isSubscriptionType($subscriptionType) {
return ((string) $subscriptionType == Connect2PayClient::SUBSCRIPTION_TYPE_NORMAL ||
(string) $subscriptionType == Connect2PayClient::SUBSCRIPTION_TYPE_INFINITE ||
(string) $subscriptionType == Connect2PayClient::SUBSCRIPTION_TYPE_ONETIME ||
(string) $subscriptionType == Connect2PayClient::SUBSCRIPTION_TYPE_LIFETIME);
} | php | {
"resource": ""
} |
q795 | C2PValidate.strlen | train | public static function strlen($str) {
if (is_array($str))
return false;
if (function_exists('mb_strlen'))
return mb_strlen($str, 'UTF-8');
return strlen($str);
} | php | {
"resource": ""
} |
q796 | ModulesInstaller.migrateModule | train | public function migrateModule(ModuleContainerInterface $module)
{
$path = $module->getPath(['database', 'migrations']);
$files = $this->migrator->getMigrationFiles($path);
// Once we grab all of the migration files for the path, we will compare them
// against the migrations that have already been run for this package then
// run each of the outstanding migrations against a database connection.
$ran = $this->migrator->getRepository()->getRan();
$migrations = array_diff($files, $ran);
$this->migrator->requireFiles($path, $migrations);
foreach ($migrations as $migration) {
$this->migrations[] = $migration;
}
return $this;
} | php | {
"resource": ""
} |
q797 | ModulesInstaller.addModuleToReset | train | public function addModuleToReset(ModuleContainerInterface $module)
{
$path = $module->getPath(['database', 'migrations']);
$this->migrator->requireFiles($path, $this->migrator->getMigrationFiles($path));
return $this;
} | php | {
"resource": ""
} |
q798 | ModulesInstaller.seedModule | train | public function seedModule(ModuleContainerInterface $module, array $data = [])
{
$className = $module->getNamespace().'\\database\\seeds\\DatabaseSeeder';
if (!class_exists($className)) {
return false;
}
$seeder = app($className, $data);
$seeder->run();
$this->output(sprintf('<info>Seeded %s</info> ', $module));
return $this;
} | php | {
"resource": ""
} |
q799 | Workbook.removeAllProperties | train | public function removeAllProperties()
{
//build URI to merge Docs
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/documentProperties';
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'DELETE');
$json = json_decode($responseStream);
if (is_object($json)) {
if ($json->Code == 200)
return true;
else
return false;
}
return true;
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.