_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q265000
BizField.getDefaultValue
test
public function getDefaultValue() { if ($this->defaultValue !== null) { return Expression::evaluateExpression($this->defaultValue, $this->getDataObj()); } return ""; }
php
{ "resource": "" }
q265001
BizField.getValueOnCreate
test
public function getValueOnCreate() { if ($this->valueOnCreate !== null) { return $this->getSqlValue(Expression::evaluateExpression($this->valueOnCreate, $this->getDataObj())); } return ""; }
php
{ "resource": "" }
q265002
BizField.getValueOnUpdate
test
public function getValueOnUpdate() { if ($this->valueOnUpdate !== null) return $this->getSqlValue(Expression::evaluateExpression($this->valueOnUpdate, $this->getDataObj())); return ""; }
php
{ "resource": "" }
q265003
BizField.checkRequired
test
public function checkRequired() { if (!$this->required || $this->required == "") { return false; } elseif ($this->required == "Y") { $required = true; } elseif ($required != "N") { $required = false; } else { $required = Expression::evaluateExpression($this->required, $this->getDataObj()); } return $required; }
php
{ "resource": "" }
q265004
BizField.checkValueType
test
public function checkValueType($value = null) { if (!$value) { $value = $this->value; } $validator = Openbizx::getService(VALIDATE_SERVICE); switch ($this->type) { case "Number": $result = is_numeric($value); break; case "Text": $result = is_string($value); break; case "Date": $result = $validator->date($value); break; /* case "Datetime": // zend doesn't support date time $result = $validator->date($value); break; case "Currency": $result = $validator->date($value); break; */ case "Phone": $result = $validator->phone($value); break; default: $result = true; break; } return $result; }
php
{ "resource": "" }
q265005
BizField.validate
test
public function validate() { $ret = true; if ($this->validator) $ret = Expression::evaluateExpression($this->validator, $this->getDataObj()); return $ret; }
php
{ "resource": "" }
q265006
Twig_Loader_Themes.findFile
test
public function findFile($name, $relative = true) { if ($this->refFindTemplate === null) { $this->refFindTemplate = new ReflectionMethod('Twig_Loader_Filesystem', 'findTemplate'); $this->refFindTemplate->setAccessible(true); } $name = $this->prepareName($name); $path = $this->refFindTemplate->invoke($this->fsloader, $name); return $relative ? ltrim(str_replace($this->basePath, '', $path), DIRECTORY_SEPARATOR) : $path; }
php
{ "resource": "" }
q265007
Twig_Loader_Themes.prepareName
test
protected function prepareName($name) { $name = preg_replace('#/{2,}#', '/', strtr($name, '\\', '/')); if (isset($name[0]) && static::NP_PREFIX != $name[0]) { $name = static::NP_PREFIX.$this->theme.'/'.$name; } return $name; }
php
{ "resource": "" }
q265008
Twig_Loader_Themes.useTheme
test
public function useTheme($theme) { if (!in_array($theme, $this->fsloader->getNamespaces())) { throw new Twig_Error_Loader(sprintf('Theme "%s" not registered.', $theme)); } $this->theme = $theme; }
php
{ "resource": "" }
q265009
Twig_Loader_Themes.registerTheme
test
public function registerTheme($themeNamespace, $autoUse = true) { $basePath = $this->basePath; $parentNamespace = null; $themesInheritanceList = explode(static::NP_DELIMITER, ltrim($themeNamespace, static::NP_DELIMITER)); while ($themeName = array_shift($themesInheritanceList)) { $leaf = count($themesInheritanceList); list($basePath, $parentNamespace) = $this->addTheme($basePath, $themeName, $parentNamespace, $leaf); } if ($autoUse) { $this->useTheme($parentNamespace); } return $this; }
php
{ "resource": "" }
q265010
Twig_Loader_Themes.addTheme
test
protected function addTheme($basePath, $themeName, $parentNamespace = null, $isContainer = false) { $themePaths = array(); $themeNamespace = $themeName; /** * If parent namespace provided, inherit paths from parent and append parent namespace to the theme namespace. */ if ($parentNamespace) { if (!in_array($parentNamespace, $this->fsloader->getNamespaces())) { throw new Twig_Error_Loader(sprintf('Parent theme "%s" not registered.', $parentNamespace)); } $themePaths = $this->fsloader->getPaths($parentNamespace); $themeNamespace = $parentNamespace.static::NP_DELIMITER.$themeName; } /** * Default directory optional. * Default directory should be on same level with the new theme. */ $themeDefaultPath = $basePath.DIRECTORY_SEPARATOR.static::DEFAULT_THEME_NAME; $themeDefaultPath .= $this->filesDir ? DIRECTORY_SEPARATOR . $this->filesDir : ''; if (is_dir($themeDefaultPath)) { $themeDefaultNamespace = ($parentNamespace ? $parentNamespace.static::NP_DELIMITER : ''); $themeDefaultNamespace .= static::DEFAULT_THEME_NAME; // Strict base name @[@parent]@base $this->fsloader->setPaths($themeDefaultPath, static::NP_PREFIX.$themeDefaultNamespace); // Add default to theme paths if (!in_array($themeDefaultNamespace, $themePaths)) { array_unshift($themePaths, $themeDefaultPath); } // Regular default name with full parent inheritance [@parent]@base $this->fsloader->setPaths($themePaths, $themeDefaultNamespace); } /** * Check if theme path directory exists. * In case theme is not leaf it is can be only container and it is can do not have files directory, * so only default path will be added to namespace paths. */ $themePath = $basePath.DIRECTORY_SEPARATOR.$themeName; if (!is_dir($themePath)) { throw new Twig_Error_Loader( sprintf('Container directory "%s" for theme "%s" not found.', $themePath, $themeNamespace) ); } if (!$isContainer) { $themeFilesPath = $this->filesDir ? $themePath.DIRECTORY_SEPARATOR.$this->filesDir : $themePath; if (!is_dir($themeFilesPath)) { throw new Twig_Error_Loader( sprintf('Files directory "%s" for theme "%s" not found.', $themeFilesPath, $themeNamespace) ); } // Add theme path to the top of paths if (!in_array($themeFilesPath, $themePaths)) { array_unshift($themePaths, $themeFilesPath); } // Strict theme namespace @[@parent]@theme $this->fsloader->setPaths($themeFilesPath, static::NP_PREFIX.$themeNamespace); } // Regular theme namespace [@parent]@theme $this->fsloader->setPaths($themePaths, $themeNamespace); return array($themePath, $themeNamespace); }
php
{ "resource": "" }
q265011
ArrayUtils.key2offset
test
public static function key2offset(array &$arr, $key) { return isset($arr[$key]) ? array_flip(array_keys($arr))[$key] : false; }
php
{ "resource": "" }
q265012
ArrayUtils.offset2key
test
public static function offset2key(array &$arr, $offset) { $keys = array_keys($arr); return isset($keys[$offset]) ? $keys[$offset] : false; }
php
{ "resource": "" }
q265013
ArrayUtils.stDeviation
test
public static function stDeviation(array $arr) { if (!is_array($arr) || sizeof($arr) < 2) { return null; } $mean = self::mean($arr); array_walk($arr, function (&$x) use ($mean) { $x = ($x - $mean)*($x -$mean); }); return sqrt(array_sum($arr)/(sizeof($arr)-1)); }
php
{ "resource": "" }
q265014
Route.setMiddleware
test
public function setMiddleware($middleware): Route { if( !is_array($middleware) ){ $middleware = [$middleware]; } $this->middleware = array_merge($this->middleware, $middleware); return $this; }
php
{ "resource": "" }
q265015
Route.getAction
test
public function getAction() { if( is_string($this->action) && $this->namespace ){ return trim($this->namespace, '\\') . '\\' . $this->action; } return $this->action; }
php
{ "resource": "" }
q265016
Route.getPathParams
test
public function getPathParams(string $path): array { $pathParams = []; // Build out the regex $pattern = implode("\/", $this->getPatternParts()); if( preg_match("/^{$pattern}$/", $path, $parts) ){ // Grab all but the first match, because that will always be the full string. foreach( array_slice($parts, 1, count($parts) - 1) as $i => $param ) { $pathParams[$this->namedPathParameters[$i]] = $param; } } return $pathParams; }
php
{ "resource": "" }
q265017
Route.matchScheme
test
public function matchScheme($scheme): bool { if( empty($this->schemes) ){ return true; } return array_search(strtolower($scheme), array_map('strtolower', $this->schemes)) !== false; }
php
{ "resource": "" }
q265018
Route.matchHostname
test
public function matchHostname(string $hostnames): bool { if( empty($this->hostnames) ){ return true; } return array_search(strtolower($hostnames), array_map('strtolower', $this->hostnames)) !== false; }
php
{ "resource": "" }
q265019
Route.matchUri
test
public function matchUri(string $uri): bool { $pattern = implode("\/", $this->patternParts); return preg_match("/^{$pattern}$/i", $this->stripLeadingAndTrailingSlash($uri)) != false; }
php
{ "resource": "" }
q265020
BizDataTree.fetchTree
test
public function fetchTree($rootSearchRule, $depth, $globalSearchRule = "") { $this->depth = $depth; $this->globalSearchRule = $globalSearchRule; // query on given search rule $searchRule = "(" . $rootSearchRule . ")"; if ($globalSearchRule != "") $searchRule .= " AND (" . $globalSearchRule . ")"; $recordList = $this->directFetch($searchRule); if (!$recordList) { $this->rootNodes = array(); return; } foreach ($recordList as $rec) { $this->rootNodes[] = new NodeRecord($rec); } if ($this->depth <= 1) return $this->rootNodes; if (is_array($this->rootNodes)) { foreach ($this->rootNodes as $node) { $this->_getChildrenNodes($node, 1); } } return $this->rootNodes; }
php
{ "resource": "" }
q265021
BizDataTree.fetchNodePath
test
public function fetchNodePath($nodeSearchRule, &$pathArray) { $recordList = $this->directFetch($nodeSearchRule); if (count($recordList) >= 1) { if ($recordList[0]['PId'] != '0') { $searchRule = "[Id]='" . $recordList[0]['PId'] . "'"; $this->fetchNodePath($searchRule, $pathArray); } $nodes = new \NodeRecord($recordList[0]); array_push($pathArray, $nodes); return $pathArray; } }
php
{ "resource": "" }
q265022
BizDataTree._getChildrenNodes
test
private function _getChildrenNodes(&$node, $depth) { $pid = $node->recordId; $searchRule = "[PId]='$pid'"; if ($this->globalSearchRule != "") $searchRule .= " AND " . $this->globalSearchRule; $recordList = $this->directFetch($searchRule); foreach ($recordList as $rec) { $node->childNodes[] = new NodeRecord($rec); } // reach leave node if ($node->childNodes == null) { return; } $depth++; // reach given depth if ($depth >= $this->depth) { return; } else { foreach ($node->childNodes as $node_c) { $this->_getChildrenNodes($node_c, $depth); } } }
php
{ "resource": "" }
q265023
Report.getSettings
test
public function getSettings($groups = null, $flag = null) { $settings = array(); foreach ($this->results as $result) { if (IResult::SUCCESS === $result->getStatus()) { $settings = array_merge($settings, $result->getSettings($groups, $flag)); } } return $settings; }
php
{ "resource": "" }
q265024
HTMLPreview.getLink
test
protected function getLink() { if ($this->link == null) return null; $formobj = $this->getFormObj(); return Expression::evaluateExpression($this->link, $formobj); }
php
{ "resource": "" }
q265025
HTMLPreview.getText
test
protected function getText() { if ($this->text == null) return null; $formObj = $this->getFormObj(); return Expression::evaluateExpression($this->text, $formObj); }
php
{ "resource": "" }
q265026
NewForm.getNewRecord
test
protected function getNewRecord() { if ($this->getDataObj()) { $recArr = $this->getDataObj()->newRecord(); } if (!$recArr) return null; // load default values if new record value is empty $defaultRecArr = array(); foreach ($this->dataPanel as $element) { if ($element->fieldName) { $defaultRecArr[$element->fieldName] = $element->getDefaultValue(); } } foreach ($recArr as $field => $val) { if ($val == "" && $defaultRecArr[$field] != "") { $recArr[$field] = $defaultRecArr[$field]; } } return $recArr; }
php
{ "resource": "" }
q265027
HOTPSecret.setSecret
test
public function setSecret($secret, $format = self::FORMAT_RAW) { if ($format == static::FORMAT_HEX) { $secret = hex2bin($secret); } elseif ($format == static::FORMAT_BASE32) { $secret = $this->base32decode($secret); } $this->secret = $secret; }
php
{ "resource": "" }
q265028
Number.getBinary
test
private static function getBinary(float $number): int { $num = 2; if ($number < $num) { return 0; } $result = $num; while (true) { $num *= 2; if ($number < $num) { return $result; } $result = $num; } return 0; }
php
{ "resource": "" }
q265029
Number.getNumber
test
public static function getNumber(float $number, int $decimal = 2): string { if (floor($number) == $number) { $decimal = 0; } switch (self::$locale) { default: case 'cs': case 'sk': case 'de': case 'pl': return number_format($number, $decimal, ',', ' '); case 'en': return number_format($number, $decimal); } }
php
{ "resource": "" }
q265030
BizDataSql.addTableColumn
test
public function addTableColumn($join, $column, $alias=null) { $tcol = $this->getTableColumn($join, $column); if ($alias) $tcol .= " AS ".$alias; if (!$this->_tableColumns) $this->_tableColumns = $tcol; else $this->_tableColumns .= ", ".$tcol; }
php
{ "resource": "" }
q265031
BizDataSql.addSqlExpression
test
public function addSqlExpression($sqlExpr, $alias=null) { if ($alias) $sqlExpr .= ' AS '.$alias; if (!$this->_tableColumns) $this->_tableColumns = $sqlExpr; else $this->_tableColumns .= ", ".$sqlExpr; }
php
{ "resource": "" }
q265032
BizDataSql.resetSQL
test
public function resetSQL() { $this->_sqlWhere = null; $this->_orderBy = null; $this->_otherSQL = null; }
php
{ "resource": "" }
q265033
BizDataSql.addOrderBy
test
public function addOrderBy($orderBy) { if ($orderBy == null) return; if ($this->_orderBy == null) { $this->_orderBy = $orderBy; } elseif (strpos($this->_orderBy, $orderBy) === false) { $this->_orderBy .= " AND " . $orderBy; } }
php
{ "resource": "" }
q265034
BizDataSql.addOtherSQL
test
public function addOtherSQL($otherSQL) { if ($otherSQL == null) return; if ($this->_otherSQL == null) { $this->_otherSQL = $otherSQL; } elseif (strpos($this->_otherSQL, $otherSQL) === false) { $this->_otherSQL .= " AND " . $otherSQL; } }
php
{ "resource": "" }
q265035
BizDataSql.addAssociation
test
public function addAssociation($assoc) { $where = ""; if ($assoc["Relationship"] == "1-M" || $assoc["Relationship"] == "M-1" || $assoc["Relationship"] == "1-1") { // assc table should same as maintable if ($assoc["Table"] != $this->_mainTable) return; // add table to join table $mytable_col = $this->getTableColumn(null, $assoc["Column"]); // construct table.column = 'field value' $where = $mytable_col." = '".$assoc["FieldRefVal"]."'"; $mytable_col2 = $this->getTableColumn(null, $assoc["Column2"]); if($assoc["Column2"]){ $where .= " AND ".$mytable_col2." = '".$assoc["FieldRefVal2"]."'"; } $mytable_cond_col = $this->getTableColumn(null, $assoc["CondColumn"]); if($assoc["CondColumn"]){ $where .= " AND $mytable_cond_col ='".$assoc["CondValue"]."' "; } if($assoc["Condition"]){ $where .= " AND ".$assoc["Condition"]." "; } } elseif ($assoc["Relationship"] == "M-M" || $assoc["Relationship"] == "Self-Self") { // ... INNER JOIN xtable TX ON TX.column2 = T0.column // WHERE ... Tx.column1 = 'PrtTableColumnValue' $mytable_col = $this->getTableColumn(null, $assoc["Column"]); // this table's alias.column $xtable = $assoc["XTable"]; // xtable's name $column1 = $assoc["XColumn1"]; // xtable column1 $column2 = $assoc["XColumn2"]; // xtable column2 $xalias = "TX"; if (isset($this->_tableAliasList[$xtable])) $xalias = $this->_tableAliasList[$xtable]; // add a table join for the xtable if such join of the table is not there before (note: may report error if has same join). //if (strpos($this->tableJoins, "JOIN $xtable") === false) if (!isset($this->_tableAliasList[$xtable])) { $this->_tableJoins .= " INNER JOIN `$xtable` $xalias ON $xalias.$column2 = $mytable_col "; $this->_tableAliasList[$xtable] = $xalias; } // add a new where condition if($assoc["Relationship"] == "Self-Self") { $columnId = $this->getTableColumn("", $assoc["ParentRecordIdColumn"]); $where = "($xalias.$column1 = '".$assoc["FieldRefVal"]."' OR $xalias.$column2 = '".$assoc["FieldRefVal"]."' ) AND $columnId != '".$assoc["FieldRefVal"]."'"; $this->_tableJoins .= " OR $xalias.$column1 = $mytable_col "; }else{ $where = "$xalias.$column1 = '".$assoc["FieldRefVal"]."'"; } } if (strlen($where) > 1) $this->addSqlWhere($where); }
php
{ "resource": "" }
q265036
BizDataSql.getSqlStatement
test
public function getSqlStatement() { $ret = "SELECT " . $this->_tableColumns; $ret .= " FROM " . $this->_tableJoins; if ($this->_sqlWhere != null) { $ret .= " WHERE " . $this->_sqlWhere; } /* if ($this->orderBy != null) { $ret .= " ORDER BY " . $this->orderBy; } */ if ($this->_otherSQL != null) { $ret .= " " . $this->_otherSQL; } if ($this->_orderBy != null) { $ret .= " ORDER BY " . $this->_orderBy; } return $ret; }
php
{ "resource": "" }
q265037
DataSet.get
test
public function get($key) { if (isset($this->varValue[$key])) { return new DataRecord($this->varValue[$key], $this->bizDataObj); } else { return NULL; } }
php
{ "resource": "" }
q265038
CliController.cliAction
test
public function cliAction() { $exitCode = $this->cliApplication->run(new RequestInput($this->getRequest())); if (is_numeric($exitCode)) { $model = new ConsoleModel(); $model->setErrorLevel($exitCode); return $model; } }
php
{ "resource": "" }
q265039
TemplateHelper.getDefaultTemplateLocations
test
private static function getDefaultTemplateLocations() { return array( Openbizx::$app->getModulePath() . "/$packagePath/template/$templateFile", dirname(Openbizx::$app->getModulePath() . "/$packagePath") . "/template/$templateFile", Openbizx::$app->getModulePath() . "/$moduleName/template/$templateFile", //Openbizx::$app->getModulePath()."/common/template/$templateFile", $templateRoot . "/$templateFile" ); }
php
{ "resource": "" }
q265040
LabelList.render
test
public function render() { $value = $this->text ? $this->getText() : $this->value; $fromList = array(); $this->getFromList($fromList); $valueArr = explode(',', $this->value); $style = $this->getStyle(); $func = $this->getFunction(); $id = $this->objectName; $selectedStr = ''; $selectedStr = $value; foreach ($fromList as $option) { $test = array_search($option['val'], $valueArr); if (!($test === false)) { $selectedStr = $option['txt'] ; break; } } if($selectedStr=="0" || $selectedStr==null){ $selectedStr = $this->blankOption; } if ($this->getLink()) { $link = $this->getLink(); $sHTML = "<a id=\"$id\" href=\"$link\" $func $style>" . $selectedStr . "</a>"; } else $sHTML = "<span $func $style>" . $selectedStr . "</span>"; if($this->backgroundColor) { $bgcolor = $this->getBackgroundColor(); if($bgcolor){ $sHTML = "<div style=\"background-color:#".$bgcolor.";text-indent:10px;\" >$sHTML</div>"; } } return $sHTML; }
php
{ "resource": "" }
q265041
Font.getFontGoogle
test
protected function getFontGoogle($api_key = '') { // Check API KEY if (!empty($api_key)) { $fonts = $this->getFontViaAPI($api_key); // Check fonts if (is_array($fonts) && !empty($fonts)) { return $fonts; } } /** * Return best fonts from Chad Mazzola * @see http://hellohappy.org/beautiful-web-type/ */ return [ 'sans_serif' => [ 'name' => 'sansserif', 'title' => 'sansserif', 'sizes' => '', ], 'abril_fatface' => [ 'name' => 'Abril+Fatface', 'title' => 'Abril Fatface', 'sizes' => '', ], 'cardo' => [ 'name' => 'Cardo', 'title' => 'Cardo', 'sizes' => '400,400italic', ], 'gravitas_one' => [ 'name' => 'Gravitas+One', 'title' => 'Gravitas One', 'sizes' => '', ], 'lato' => [ 'name' => 'Lato', 'title' => 'Lato', 'sizes' => '100,900', ], 'merriweather' => [ 'name' => 'Merriweather', 'title' => 'Merriweather', 'sizes' => '400,900', ], 'open_sans' => [ 'name' => 'Open+Sans', 'title' => 'Open Sans', 'sizes' => '300,400,600,700,800', ], 'oswald' => [ 'name' => 'Oswald', 'title' => 'Oswald', 'sizes' => '300,400,700', ], 'playfair_display' => [ 'name' => 'Playfair+Display', 'title' => 'Playfair Display', 'sizes' => '400,900,700italic', ], 'pt_sans' => [ 'name' => 'PT+Sans', 'title' => 'PT Sans', 'sizes' => '400,700', ], 'vollkorn' => [ 'name' => 'Vollkorn', 'title' => 'Vollkorn', 'sizes' => '400,400italic', ], ]; }
php
{ "resource": "" }
q265042
Setting.matchesGroup
test
public function matchesGroup($groups = null) { if (null !== $groups) { $group_names = self::getGroupNames($groups); return in_array($this->group, $group_names); } return true; }
php
{ "resource": "" }
q265043
BizDataObj.validateInput
test
public function validateInput() { $this->errorFields = array(); foreach ($this->bizRecord->inputFields as $fld) { /* @var $bizField BizField */ $bizField = $this->bizRecord->get($fld); if ($bizField->encrypted == "Y") { if ($bizField->checkRequired() == true && ($bizField->value === null || $bizField->value === "")) { $this->errorMessage = $this->getMessage("DATA_FIELD_REQUIRED", array($fld)); $this->errorFields[$bizField->objectName] = $this->errorMessage; } continue; } if ($bizField->checkRequired() == true && ($bizField->value === null || $bizField->value === "")) { $this->errorMessage = $this->getMessage("DATA_FIELD_REQUIRED", array($fld)); $this->errorFields[$bizField->objectName] = $this->errorMessage; } elseif ($bizField->value !== null && $bizField->checkValueType() == false) { $this->errorMessage = $this->getMessage("DATA_FIELD_INCORRECT_TYPE", array($fld, $bizField->type)); $this->errorFields[$bizField->objectName] = $this->errorMessage; } elseif ($bizField->value !== null && $bizField->Validate() == false) { /* @var $validateService validateService */ $validateService = Openbizx::getService(VALIDATE_SERVICE); $this->errorMessage = $validateService->getErrorMessage($bizField->validator, $bizField->objectName); if ($this->errorMessage == false) { //Couldn't get a clear error message so let's try this $this->errorMessage = $this->getMessage("DATA_FIELD_INVALID_INPUT", array($fld, $value, $bizField->validator)); // } $this->errorFields[$bizField->objectName] = $this->errorMessage; } } if (count($this->errorFields) > 0) { //print_r($this->errorFields); throw new Openbizx\Validation\Exception($this->errorFields); //return false; } // validate uniqueness if ($this->validateUniqueness() == false) { return false; } return true; }
php
{ "resource": "" }
q265044
BizDataObj.validateUniqueness
test
protected function validateUniqueness() { if (!$this->uniqueness) return true; $groupList = explode(";", $this->uniqueness); foreach ($groupList as $group) { $searchRule = ""; $needCheck = true; $fields = explode(",", $group); foreach ($fields as $fld) { $bizField = $this->bizRecord->get($fld); if ($bizField->value === null || $bizField->value === "" || $bizField->value == $bizField->oldValue) { $needCheck = false; break; } if ($searchRule == "") { $searchRule = "[" . $bizField->objectName . "]='" . addslashes($bizField->value) . "'"; } else { $searchRule .= " AND [" . $bizField->objectName . "]='" . addslashes($bizField->value) . "'"; } } if ($needCheck) { $recordList = $this->directFetch($searchRule, 1); if ($recordList->count() > 0) { $this->errorMessage = $this->getMessage("DATA_NOT_UNIQUE", array($group)); foreach ($fields as $fld) { $this->errorFields[$fld] = $this->errorMessage; } } } } if (count($this->errorFields) > 0) { throw new Openbizx\Validation\Exception($this->errorFields); return false; } return true; }
php
{ "resource": "" }
q265045
BizDataObj.canUpdateRecord
test
public function canUpdateRecord($record = null) { if ($this->dataPermControl == 'Y') { $svcObj = Openbizx::getService(OPENBIZ_DATAPERM_SERVICE); if (!$record) { $record = $this->getActiveRecord(); } $result = $svcObj->checkDataPerm($record, 2, $this); if ($result == false) { return false; } } $result = $this->canUpdateRecordCondition(); return $result; }
php
{ "resource": "" }
q265046
BizDataObj.canDeleteRecord
test
public function canDeleteRecord($record = null) { if ($this->dataPermControl == 'Y') { $svcObj = Openbizx::getService(OPENBIZ_DATAPERM_SERVICE); if (!$record) { $record = $this->getActiveRecord(); } $result = $svcObj->checkDataPerm($record, 3, $this); if ($result == false) { return false; } } $result = $this->canDeleteRecordCondition(); return $result; }
php
{ "resource": "" }
q265047
BizDataObj.updateRecord
test
public function updateRecord($recArr, $oldRecord = null) { $this->events()->trigger(__FUNCTION__ . '.pre', $this, array('record' => $recArr, 'old_record' => $oldRecord)); if (!$this->canUpdateRecord($oldRecord)) { $this->errorMessage = MessageHelper::getMessage("DATA_NO_PERMISSION_UPDATE", $this->objectName); throw new Openbizx\Data\Exception($this->errorMessage); return false; } if (!$oldRecord) $oldRecord = $this->getActiveRecord(); if (!$recArr["Id"]) $recArr["Id"] = $this->getFieldValue("Id"); // save the old values $this->bizRecord->saveOldRecord($oldRecord); // set the new values $this->bizRecord->setInputRecord($recArr); if (!$this->validateInput()) return false; $sql = $this->getSQLHelper()->buildUpdateSQL($this); if ($sql) { $db = $this->getDBConnection("WRITE"); if ($this->useTransaction) $db->beginTransaction(); try { $this->cascadeUpdate(); // cascade update Openbizx::$app->getLog()->log(LOG_DEBUG, "DATAOBJ", "Update Sql = $sql"); $db->query($sql); if ($this->useTransaction) $db->commit(); } catch (Exception $e) { if ($this->useTransaction) $db->rollBack(); if ($e instanceof Openbizx\Data\Exception) throw $e; else { Openbizx::$app->getLog()->log(LOG_ERR, "DATAOBJ", "Query error : " . $e->getMessage()); $this->errorMessage = $this->getMessage("DATA_ERROR_QUERY") . ": " . $sql . ". " . $e->getMessage(); throw new Openbizx\Data\Exception($this->errorMessage); } return false; } $this->cleanCache(); //clean cached data $this->_postUpdateLobFields($recArr); $this->currentRecord = null; $this->_postUpdateRecord($recArr); } $this->events()->trigger(__FUNCTION__ . '.post', $this, array('record' => $recArr, 'old_record' => $oldRecord)); return true; }
php
{ "resource": "" }
q265048
BizDataObj.newRecord
test
public function newRecord() { $recArr = $this->bizRecord->getEmptyRecordArr(); // if association is 1-M, set the field (pointing to the column) value as the FieldRefVal if ($this->association["Relationship"] == "1-M") { foreach ($this->bizRecord as $field) { if ($field->column == $this->association["Column"] && !$field->join) { $recArr[$field->objectName] = $this->association["FieldRefVal"]; break; } } } return $recArr; }
php
{ "resource": "" }
q265049
BizDataObj.generateId
test
protected function generateId($isBeforeInsert = true, $tableName = null, $idCloumnName = null) { // Identity type id is generated after insert is done. // If this method is called before insert, return null. if ($isBeforeInsert && $this->idGeneration == 'Identity') return null; if (!$isBeforeInsert && $this->idGeneration != 'Identity') { $this->errorMessage = MessageHelper::getMessage("DATA_UNABLE_GET_ID", $this->objectName); return false; } /* @var $genIdService genIdService */ $genIdService = Openbizx::getService(GENID_SERVICE); if ($this->m_db) { $db = $this->m_db; } else { $db = $this->getDBConnection("READ"); } $dbInfo = Openbizx::$app->getConfiguration()->getDatabaseInfo($this->databaseAliasName); $dbType = $dbInfo["Driver"]; $table = $tableName ? $tableName : $this->mainTableName; $column = $idCloumnName ? $idCloumnName : $this->getField("Id")->column; try { $newId = $genIdService->getNewID($this->idGeneration, $db, $dbType, $table, $column); } catch (Exception $e) { $this->errorMessage = $e->getMessage(); return false; } return $newId; }
php
{ "resource": "" }
q265050
BizDataObj.insertRecord
test
public function insertRecord($recArr) { $this->events()->trigger(__FUNCTION__ . '.pre', $this, array('record', $recArr)); if ($this->_isNeedGenerateId($recArr)) $recArr["Id"] = $this->generateId(); // for certain cases, id is generated before insert $this->bizRecord->setInputRecord($recArr); if (!$this->validateInput()) return false; $db = $this->getDBConnection("WRITE"); try { $sql = $this->getSQLHelper()->buildInsertSQL($this, $joinValues); if ($sql) { Openbizx::$app->getLog()->log(LOG_DEBUG, "DATAOBJ", "Insert Sql = $sql"); $db->query($sql, $bindValues); } //$mainId = $db->lastInsertId(); if ($this->_isNeedGenerateId($recArr)) { $this->m_db = $db; //compatiable for CLI mode and also speed up of it running $mainId = $this->generateId(false); $recArr["Id"] = $mainId; } Openbizx::$app->getLog()->log(LOG_DEBUG, "DATAOBJ", "New record Id is " . $recArr["Id"]); } catch (Exception $e) { Openbizx::$app->getLog()->log(LOG_ERR, "DATAOBJ", "Query Error : " . $e->getMessage()); $this->errorMessage = $this->getMessage("DATA_ERROR_QUERY") . ": " . $sql . ". " . $e->getMessage(); throw new Openbizx\Data\Exception($this->errorMessage); return null; } $this->bizRecord->setInputRecord($recArr); if ($this->_postUpdateLobFields($recArr) === false) { $this->errorMessage = $db->ErrorMsg(); return false; } $this->cleanCache(); $this->recordId = $recArr["Id"]; $this->currentRecord = null; $this->_postInsertRecord($recArr); $this->events()->trigger(__FUNCTION__ . '.post', $this, array('record', $recArr)); return $recArr["Id"]; }
php
{ "resource": "" }
q265051
BizDataObj.deleteRecord
test
public function deleteRecord($recArr) { $this->events()->trigger(__FUNCTION__ . '.pre', $this, array('record', $recArr)); if (!$this->canDeleteRecord()) { $this->errorMessage = MessageHelper::getMessage("DATA_NO_PERMISSION_DELETE", $this->objectName); throw new Openbizx\Data\Exception($this->errorMessage); return false; } if ($recArr) { $delrec = $recArr; } else { $delrec = $this->getActiveRecord(); } $this->bizRecord->setInputRecord($delrec); $sql = $this->getSQLHelper()->buildDeleteSQL($this); if ($sql) { $db = $this->getDBConnection("WRITE"); $db->beginTransaction(); try { $this->cascadeDelete(); // cascade delete Openbizx::$app->getLog()->log(LOG_DEBUG, "DATAOBJ", "Delete Sql = $sql"); $db->query($sql); $db->commit(); $this->bizRecord->saveOldRecord($delrec); // save old record only if delete success } catch (Exception $e) { $db->rollBack(); if ($e instanceof Openbizx\Data\Exception) throw $e; else { Openbizx::$app->getLog()->log(LOG_ERR, "DATAOBJ", "Query error : " . $e->getMessage()); $this->errorMessage = $this->getMessage("DATA_ERROR_QUERY") . ": " . $sql . ". " . $e->getMessage(); throw new Openbizx\Data\Exception($this->errorMessage); } return false; } } //clean cached data $this->cleanCache(); $this->_postDeleteRecord($this->bizRecord->getKeyValue()); $this->events()->trigger(__FUNCTION__ . '.pre', $this, array('record', $recArr)); return true; }
php
{ "resource": "" }
q265052
BizDataObj.getOnAuditFields
test
public function getOnAuditFields() { $fieldList = array(); foreach ($this->bizRecord as $field) { if ($field->onAudit) $fieldList[] = $field; } return $fieldList; }
php
{ "resource": "" }
q265053
BizDataObj._runDOTrigger
test
private function _runDOTrigger($triggerType) { // locate the trigger metadata file BOName_Trigger.xml $triggerServiceName = $this->objectName . "_Trigger"; $xmlFile = ObjectFactoryHelper::getXmlFileWithPath($triggerServiceName); if (!$xmlFile) { return; } $triggerService = Openbizx::getObject($triggerServiceName); if ($triggerService == null) { return; } // invoke trigger service ExecuteTrigger($triggerType, $currentRecord) $triggerService->execute($this, $triggerType); }
php
{ "resource": "" }
q265054
BizDataObj.getJoinFields
test
public function getJoinFields($joinDataObj) { // get the maintable of the joindataobj $joinTable = $joinDataObj->mainTableName; $returnRecord = array(); // find the proper join according to the maintable foreach ($this->tableJoins as $tableJoin) { if ($tableJoin->table == $joinTable) { // populate the column-fieldvalue to columnRef-fieldvalue // get the field mapping to the column, then get the field value $joinFieldName = $joinDataObj->bizRecord->getFieldByColumn($tableJoin->column); // joined-main table if (!$joinFieldName) { continue; } $refFieldName = $this->bizRecord->getFieldByColumn($tableJoin->columnRef); // join table $returnRecord[$refFieldName] = $joinFieldName; // populate joinRecord's field to current record foreach ($this->bizRecord as $field) { if ($field->join == $tableJoin->objectName) { // use join column to match joinRecord field's column $jFieldName = $joinDataObj->bizRecord->getFieldByColumn($field->column); // joined-main table $returnRecord[$field->objectName] = $jFieldName; } } break; } } return $returnRecord; }
php
{ "resource": "" }
q265055
BizDataObj.joinRecord
test
public function joinRecord($joinDataObj, $joinName = "") { // get the maintable of the joindataobj $joinTable = $joinDataObj->mainTableName; $joinRecord = null; $returnRecord = array(); // find the proper join according to join name and the maintable foreach ($this->tableJoins as $tableJoin) { if (($joinName == $tableJoin->objectName || $joinName == "") && $tableJoin->table == $joinTable) { // populate the column-fieldvalue to columnRef-fieldvalue // get the field mapping to the column, then get the field value $joinFieldName = $joinDataObj->bizRecord->getFieldByColumn($tableJoin->column); // joined-main table if (!$joinFieldName) continue; if (!$joinRecord) $joinRecord = $joinDataObj->getActiveRecord(); $refFieldName = $this->bizRecord->getFieldByColumn($tableJoin->columnRef); // join table $returnRecord[$refFieldName] = $joinRecord[$joinFieldName]; // populate joinRecord's field to current record foreach ($this->bizRecord as $fld) { if ($fld->join == $tableJoin->objectName) { // use join column to match joinRecord field's column $jfldname = $joinDataObj->bizRecord->getFieldByColumn($fld->column); // joined-main table $returnRecord[$fld->objectName] = $joinRecord[$jfldname]; } } break; } } // return a modified record with joined record data return $returnRecord; }
php
{ "resource": "" }
q265056
BizDataObj._isNeedGenerateId
test
private function _isNeedGenerateId($recArr) { if ($this->idGeneration != 'None' && (!$recArr["Id"] || $recArr["Id"] == "")) { return true; } if ($this->idGeneration == 'Identity') { return true; } }
php
{ "resource": "" }
q265057
Runner.run
test
public function run() { $successful = true; $this->initReport(); $checks = array(); foreach ($this->config->getCheckDefinitions() as $check_definition) { $checks[] = $this->getCheckInstance($check_definition); } $progress = $this->command->getHelperSet()->get('progress'); $progress->setFormat(' %current%/%max% [%bar%] %percent%% Elapsed: %elapsed% '); $progress->start($this->command->getOutput(), count($checks)); // run all checks defined in the configuration foreach ($checks as $check) { // process the check $succeeded = (bool) $check->run(); // collect the result $result = $check->getResult(); if (!$result instanceof IResult) { throw new \LogicException( 'The result of check "' . $check->getName() . '" (group "' . $check->getGroup() . '", class "' . get_class($check) . '") must implement IResult.' ); } // mark the check's result as success or failure if (!$succeeded) { $result->setStatus(IResult::FAIL); } else { $result->setStatus(IResult::SUCCESS); } // add the check's result to the report $this->report->addResult($result); $successful &= $succeeded; $progress->advance(); } $progress->finish(); return $successful; }
php
{ "resource": "" }
q265058
Runner.initReport
test
protected function initReport() { $report_implementor = $this->config->getReportImplementor(); $report = new $report_implementor(); if (!$report instanceof IReport) { throw new \InvalidArgumentException( 'The given report class "' . $report_implementor . '" does not implement IReport.' ); } $this->report = $report; $this->report->setParameters(new Parameters($this->config->get('report', array()))); return $this->report; }
php
{ "resource": "" }
q265059
HttpKernel.resolveRoute
test
private function resolveRoute(Request $request): Route { if( ($route = $this->router->resolve($request)) === null ){ // 405 Method Not Allowed if( ($methods = $this->router->getMethodsForUri($request)) ){ throw new MethodNotAllowedHttpException; } // 404 Not Found throw new NotFoundHttpException("Route not found"); } return $route; }
php
{ "resource": "" }
q265060
HttpKernel.resolveActionParameters
test
private function resolveActionParameters(Request $request, callable $target): array { // Get the target's parameters if( is_array($target) ) { $functionParameters = (new \ReflectionClass(get_class($target[0])))->getMethod($target[1])->getParameters(); } else{ $functionParameters = (new \ReflectionFunction($target))->getParameters(); } $params = []; /** @var \ReflectionParameter $parameter */ foreach( $functionParameters as $parameter ){ /** * * @NOTE We cast the ReflectionType to string because the ::getName() method does not appear in * PHP 7 until 7.1 * */ // Check container first for an instance of this parameter type if( $parameter->getType() && (string) $parameter->getType() === Request::class ){ $params[$parameter->getPosition()] = $request; } // Check request attributes for this parameter name elseif( $request->attributes->has($parameter->getName()) ){ $params[$parameter->getPosition()] = $request->attributes->get($parameter->getName()); } else { $params[$parameter->getPosition()] = null; } } return $params; }
php
{ "resource": "" }
q265061
ReadOnlyCache.has
test
public function has($name, $groups = null, $flag = null) { foreach ($this->settings as $setting) { if (($setting->getName() === $name) && $setting->matchesGroup($groups) && $setting->matchesFlag($flag)) { return true; } } return false; }
php
{ "resource": "" }
q265062
ReadOnlyCache.get
test
public function get($name, $groups = null, $flag = null) { $found = null; foreach ($this->settings as $setting) { if (($setting->getName() === $name) && $setting->matchesGroup($groups) && $setting->matchesFlag($flag)) { return $setting; } } return $found; }
php
{ "resource": "" }
q265063
ReadOnlyCache.getAll
test
public function getAll($groups = null, $flag = null) { $settings = array(); if (null === $groups) { foreach ($this->settings as $setting) { $settings[] = $setting; } } elseif (is_string($groups) || is_array($groups)) { foreach ($this->settings as $setting) { if ($setting->matchesGroup($groups) && $setting->matchesFlag($flag)) { $settings[] = $setting; } } } else { throw new \InvalidArgumentException( 'Only a null value, a single string as group name or an array of group names are supported.' ); } return $settings; }
php
{ "resource": "" }
q265064
ReadOnlyCache.load
test
public function load() { $location = $this->location; // no location given from commandline -> use config values or fallback to default location if (empty($location)) { $location = $this->parameters->get( 'read_location', $this->parameters->get( 'location', $this->getDefaultLocation() ) ); } $this->location = $location; if (!is_readable($location) || !is_file($location)) { return false; } $content = file_get_contents($location); if (false === $content) { return false; } $result = json_decode($content, true); if (null === $result) { throw new \InvalidArgumentException('Cache could not be decoded from file: ' . $location); } $items = array(); foreach ($result as $setting) { $items[] = new Setting($setting['name'], $setting['value'], $setting['group'], $setting['flag']); } $this->settings = $items; return true; }
php
{ "resource": "" }
q265065
ReadOnlyCache.setLocation
test
public function setLocation($location) { if (!is_readable($location)) { throw new \InvalidArgumentException('Given cache location "' . $location . '" is not readable.'); } $this->location = $location; return $this; }
php
{ "resource": "" }
q265066
PleasingPrefixFilter.prefixCss
test
protected function prefixCss( $content ) { $replaced = array(); if( $rules = $this->getRules( $content ) ) { foreach( $rules as $rule ) { $prefixed = array(); if( strpos( $content, $rule->getRaw() ) !== false && !in_array( $rule->getRaw(), $replaced ) ) { if( array_key_exists( $rule->getProperty(), $this->prefixValue ) ) { if( array_key_exists( $rule->getValue(), $this->prefixValue[ $rule->getProperty() ] ) ) { $prefixed = $this->getPrefixRules( $rule->getProperty(), $this->prefixValue[ $rule->getProperty() ][ $rule->getValue() ], $rule->getBang() ); } } elseif( array_key_exists( $rule->getProperty(), $this->prefixProperty ) ) { $prefixed = $this->getPrefixRules( $this->prefixProperty[ $rule->getProperty() ], $rule->getValue(), $rule->getBang() ); } elseif( array_key_exists( $rule->getProperty(), $this->prefixMethod ) ) { $method = $this->prefixMethod[ $rule->getProperty() ]; $prefixed = $this->$method( $rule->getValue(), $rule->getBang() ); } if( !empty( $prefixed ) ) { $newRules = array(); foreach( $prefixed as $pRule ) { /** @var CssRule $pRule */ $pRule->setTemplate( $rule->getTemplate() ); $newRules[] = $pRule->getOutput(); } $replaced[] = $rule->getRaw(); $replacement = str_replace( $rule->getOutput(), implode( "\n", $newRules ), $rule->getRaw() ); $content = str_replace($rule->getRaw(),$replacement,$content); } } } } return $content; }
php
{ "resource": "" }
q265067
PleasingPrefixFilter.prefixAlignItems
test
protected function prefixAlignItems( $value, $extra = null ) { $prop[] = '-ms-flex-align'; switch( $value ) { case 'flex-start': $val[] = 'start'; break; case 'flex-end': $val[] = 'end'; break; default: $val[] = $value; $prop[] = '-ms-grid-row-align'; $val[] = 'center'; break; } $prop[] = '-webkit-align-items'; $prop[] = 'align-items'; $val[] = $value; $val[] = $value; return $this->getPrefixRules( $prop, $val, $extra ); }
php
{ "resource": "" }
q265068
PleasingPrefixFilter.prefixAlignContent
test
protected function prefixAlignContent( $value, $extra = null ) { $prop = array( '-webkit-align-content', '-ms-flex-line-pack', 'align-content' ); $val[] = $value; switch( $value ) { case 'flex-start': $val[] = 'start'; break; case 'flex-end': $val[] = 'end'; break; case 'space-between': $val[] = 'justify'; break; case 'space-around': $val[] = 'distribute'; break; default: $val[] = $value; break; } $val[] = $value; return $this->getPrefixRules( $prop, $val, $extra ); }
php
{ "resource": "" }
q265069
PleasingPrefixFilter.prefixAlignSelf
test
protected function prefixAlignSelf( $value, $extra = null ) { $prop = array( '-webkit-align-self', '-ms-flex-item-align', 'align-self' ); $val[] = $value; switch( $value ) { case 'flex-start': $val[] = 'start'; break; case 'flex-end': $val[] = 'end'; break; default: $val[] = $value; break; } $val[] = $value; return $this->getPrefixRules( $prop, $val, $extra ); }
php
{ "resource": "" }
q265070
PleasingPrefixFilter.prefixFlex
test
protected function prefixFlex( $value, $extra = null ) { $parts = explode( " ", $value ); if( count( $parts ) == 3 ) { // Make sure there's a % after the basis to avoid IE10/11 Bugs. // 0px does not work because a minifier would remove it. // // https://github.com/philipwalton/flexbugs#4-flex-shorthand-declarations-with-unitless-flex-basis-values-are-ignored if( $parts[ 2 ] === 0 || $parts[ 2 ] === '0px' ) { $parts[ 2 ] = '0%'; } } $prop = array( '-webkit-flex', '-ms-flex', 'flex' ); $val = implode( ' ', $parts ); return $this->getPrefixRules( $prop, $val, $extra ); }
php
{ "resource": "" }
q265071
PleasingPrefixFilter.prefixJustifyContent
test
protected function prefixJustifyContent( $value, $extra = null ) { $prop = array( '-webkit-justify-content', '-ms-flex-pack', 'justify-content' ); $val[] = $value; switch( $value ) { case 'flex-start': $val[] = 'start'; break; case 'flex-end': $val[] = 'end'; break; case 'space-between': $val[] = 'justify'; break; case 'space-around': $val[] = 'distribute'; break; default: $val[] = $value; } $val[] = $value; return $this->getPrefixRules( $prop, $val, $extra ); }
php
{ "resource": "" }
q265072
PleasingPrefixFilter.getPrefixRules
test
private function getPrefixRules( $prop, $val, $extra = null ) { $extra = ( empty( $extra ) ) ? null : ' ' . $extra; if( !is_array( $prop ) && is_array( $val ) ) { $properties = array_fill( 0, count( $val ), $prop ); $values = $val; } elseif( !is_array( $val ) && is_array( $prop ) ) { $values = array_fill( 0, count( $prop ), $val ); $properties = $prop; } else { $properties = $prop; $values = $val; } $property = null; $value = null; do { $property = ( !empty( $properties ) ) ? array_shift( $properties ) : $property; $value = ( !empty( $values ) ) ? array_shift( $values ) : $property; $rules[] = new CssRule( $property, $value, $extra ); } while( !empty( $properties ) && !empty( $values ) ); return $rules; }
php
{ "resource": "" }
q265073
Media.Comment
test
public function Comment($media_id, $comment) { $this->AddParam('text', $comment); return $this->Post($this->buildUrl($media_id . '/comments')); }
php
{ "resource": "" }
q265074
InstagramBase.Delete
test
protected function Delete($url = null, $params = array()) { if (empty($url)) trigger_error('A URL is required in ' . __METHOD__, E_USER_ERROR); if (!empty($params)) $this->AddParams($params); return $this->request->Delete($url, array_merge($this->default_params, $this->parameters))->response; }
php
{ "resource": "" }
q265075
ContentResult.getFilteredMedia
test
function getFilteredMedia(array $filters, $allowPlaceholder = true) { $col = []; foreach($this['media'] as $medium) { if (!isset($hasImage) && $medium['type'] == 'image') { $hasImage = true; } if (in_array($medium['type'], $filters)) { $col[] = $medium; } } // Add a placeholder if the image type was requested, and no images were found. if (in_array('image', $filters) && !isset($hasImage) && $allowPlaceholder && $this->getPlaceholder()) { $col[] = $this->getPlaceholder(); } return $col; }
php
{ "resource": "" }
q265076
ContentResult.getPreferredImage
test
function getPreferredImage($aspect = null, $orientation = null) { // If theres no images, check for placeholders if (!$this->getFilteredMedia(['image'], false)) { if ($ph = $this->getPlaceholder()) { if ($aspect) { return $ph['meta']['src'][$aspect]; } return $ph; } return null; } if ($this->hasPreferredImage()) { $medium = $this->getMedium($this['meta']['media']['preferred_image']); } elseif ($orientation) { $medium = $this->getPreferredImageByOrientation($orientation); } else { $medium = $this['media'][0]; } if ($aspect) { return $medium['meta']['src'][$aspect]; } return $medium; }
php
{ "resource": "" }
q265077
ContentResult.getPlaceholder
test
function getPlaceholder($index = null) { if (!isset($this['meta']['media']['placeholder'])) { return null; } if (!$this->placeholder_pick) { $this->placeholder_pick = rand(0, count($this['meta']['media']['placeholder']) - 1); } return $this['meta']['media']['placeholder'][$index ?: $this->placeholder_pick]; }
php
{ "resource": "" }
q265078
CssRule.fromString
test
public static function fromString( $string ) { if( preg_match( '#(\s+)?([^:]+):([^!;]+)([^;]+)?#', trim( $string, "\n\r" ), $matches ) ) { $rule = new self(); $rule ->setRaw($string) ->setProperty( ( !empty( $matches[ 2 ] ) ) ? trim( $matches[ 2 ] ) : null ) ->setValue( ( !empty( $matches[ 3 ] ) ) ? trim( $matches[ 3 ] ) : null ) ->setBang( ( !empty( $matches[ 4 ] ) ) ? trim( $matches[ 4 ] ) : null ) ->setIndent( ( isset( $matches[ 1 ] ) ) ? strlen( $matches[ 1 ] ) : 0 ) ; // Replace Property in Template $pattern = "#(" . preg_quote( $rule->getProperty(), "#" ) . "([\s:]+))#"; $template = preg_replace( $pattern, "%s$2", $matches[ 0 ] . ';' ); // Replace Value in Template $pattern = "#(:([\s]+))" . preg_quote( $rule->getValue(), "#" ) . "#"; $template = preg_replace( $pattern, "$1%s", $template ); // Replace Bang in Template $pattern = "#([^!]+)" . preg_quote($rule->getBang(), "#") . ";#"; $template = preg_replace( $pattern, "$1%s;", $template ); return $rule->setTemplate( $template ); } return null; }
php
{ "resource": "" }
q265079
CssRule.getOutput
test
public function getOutput() { return sprintf( $this->getTemplate(), $this->getProperty(), $this->getValue(), $this->getBang() ); }
php
{ "resource": "" }
q265080
EloquentReflection.getEloquentReflectionMethod
test
public static function getEloquentReflectionMethod($object, string $method) { if ($object instanceof Builder) { if (method_exists(Model::class, $method)) { return new ReflectionMethod(Model::class, $method); } elseif (method_exists(Query::class, $method)) { return new ReflectionMethod(Query::class, $method); } } elseif ($object instanceof Model) { if (method_exists(Builder::class, $method)) { return new ReflectionMethod(Builder::class, $method); } elseif (method_exists(Query::class, $method)) { return new ReflectionMethod(Query::class, $method); } } // scoping is one of the ways custom methods are magically called. if (substr($method, 0, 5) !== "scope") { return static::getEloquentReflectionMethod($object, "scope" . ucfirst($method)); } return false; }
php
{ "resource": "" }
q265081
SitemapController.indexAction
test
public function indexAction(Request $request) { $registry = $this->get('ekyna_sitemap.provider_registry'); $sitemaps = []; $lastUpdateDate = null; foreach($registry->getSitemaps() as $sitemap) { $providers = $registry->getProvidersBySitemap($sitemap); $sitemapLastUpdateDate = null; /** @var \Ekyna\Bundle\SitemapBundle\Provider\ProviderInterface $provider */ foreach ($providers as $provider) { if (null === $sitemapLastUpdateDate || $sitemapLastUpdateDate < $provider->getLastUpdateDate()) { $sitemapLastUpdateDate = $provider->getLastUpdateDate(); } } $sitemaps[$sitemap] = $sitemapLastUpdateDate; if (null === $lastUpdateDate || $lastUpdateDate < $sitemapLastUpdateDate) { $lastUpdateDate = $sitemapLastUpdateDate; } } $response = new Response(); $response->setLastModified($lastUpdateDate); $response->setPublic(); if ($response->isNotModified($request)) { return $response; } $response->setMaxAge($this->container->getParameter('ekyna_sitemap.index_ttl')); $response->headers->add(['Content-Type' => 'application/xml; charset=UTF-8']); return $response->setContent($this->renderView('EkynaSitemapBundle:Sitemap:index.xml.twig', [ 'sitemaps' => $sitemaps, ])); }
php
{ "resource": "" }
q265082
SitemapController.sitemapAction
test
public function sitemapAction(Request $request) { $sitemap = $request->attributes->get('sitemap', null); $registry = $this->get('ekyna_sitemap.provider_registry'); $providers = $registry->getProvidersBySitemap($sitemap); if (0 === count($providers)) { throw new NotFoundHttpException('Sitemap not found.'); } $lastUpdateDate = null; /** @var \Ekyna\Bundle\SitemapBundle\Provider\ProviderInterface $provider */ foreach($providers as $provider) { if (null === $lastUpdateDate || $lastUpdateDate < $provider->getLastUpdateDate()) { $lastUpdateDate = $provider->getLastUpdateDate(); } } $response = new Response(); $response->setLastModified($lastUpdateDate); $response->setPublic(); if ($response->isNotModified($request)) { return $response; } $response->setMaxAge($this->container->getParameter('ekyna_sitemap.sitemap_ttl')); $response->headers->add(['Content-Type' => 'application/xml; charset=UTF-8']); return $response->setContent($this->renderView('EkynaSitemapBundle:Sitemap:sitemap.xml.twig', [ 'providers' => $providers, ])); }
php
{ "resource": "" }
q265083
XMLParser.&
test
function &getTree() { // load xml and check if it turns a valid object. TODO: it will throw error. /* $xml = simplexml_load_file($this->data); if (!$xml) { echo 'invalid xml file '.$this->data; exit; } */ //$parser = xml_parser_create('ISO-8859-1'); $parser = xml_parser_create(''); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parse_into_struct($parser, $this->data, $vals, $index); xml_parser_free($parser); $i = -1; return $this->getchildren($vals, $i); }
php
{ "resource": "" }
q265084
ResourceServer.isValidRequest
test
public function isValidRequest($headerOnly = true, $accessToken = null) { $accessTokenString = ($accessToken !== null) ? $accessToken : $this->determineAccessToken($headerOnly); // Set the access token $this->accessToken = $this->getAccessTokenStorage()->get($accessTokenString); // Ensure the access token exists if (!$this->accessToken instanceof AccessTokenEntity) { throw new AccessDeniedException(); } // Check the access token hasn't expired // Ensure the auth code hasn't expired if ($this->accessToken->isExpired() === true) { throw new AccessDeniedException(); } return true; }
php
{ "resource": "" }
q265085
ResourceServer.determineAccessToken
test
public function determineAccessToken($headerOnly = FALSE) { switch ($headerOnly){ case FALSE: $accessToken = $this->requestHandler->getParam($this->tokenKey); if ($accessToken !== null){ break; } case TRUE: $tokenType = $this->getTokenType(); if (strrpos(get_class($tokenType),"Bearer") !== FALSE){ $accessToken = $tokenType->determineAccessTokenInHeader($this->requestHandler,$this->authHeader); }else{ $accessToken = $tokenType->determineAccessTokenInHeader($this->requestHandler); } break; } if (empty($accessToken)) { throw new InvalidRequestException('access token'); } return $accessToken; }
php
{ "resource": "" }
q265086
CallsMiddleware.call
test
public function call( string $method, array &$arguments = [], string $callType = Caller::TYPE_DEFAULT, $result = null, bool $catchHalt = true ) { $done = false; $this->each(function ($middleware, $key) use (&$done, &$method, &$arguments, $callType, &$result, $catchHalt) { if ($done) { return; } $before = $result; if ($result === null && $middleware instanceof MiddlewareInterface) { $context = $middleware->getContext(); if (is_object($context)) { $result = $context; $before = clone $context; } } if ($method) { if ($middleware instanceof static) { $result = $middleware->call($method, $arguments, $callType, $result, $catchHalt); } elseif ($middleware) { $result = (new Caller($middleware, $result)) ->as($callType) ->catch($catchHalt) ->call($method, $arguments); } } if ($this->callContextChanged($callType, $before, $result)) { $done = true; } }); return $result; }
php
{ "resource": "" }
q265087
CallsMiddleware.callContextChanged
test
protected function callContextChanged(string $type, $before, $after): bool { $before = is_object($before) ? get_class($before) : ""; $after = is_object($after) ? get_class($after) : ""; return $type === Caller::TYPE_CALLER && $before && $after && $before !== $after; }
php
{ "resource": "" }
q265088
AbstractEngine.storeCommand
test
protected function storeCommand(CommandInterface $command) { $priority = $command->getPriority(); for ($count = count($this->commands), $i = 0; $i < $count; $i++) { if ($this->commands[$i]->getPriority() < $priority) { array_splice($this->commands, $i, 0, [ $command ]); return $command; } } return $this->commands[] = $command; }
php
{ "resource": "" }
q265089
AbstractEngine.performExecution
test
protected function performExecution(callable $callback) { $this->executionDepth++; $count = $this->executionCount; $this->executionCount = 0; $this->debug('BEGIN execution (depth: {depth})', [ 'depth' => $this->executionDepth ]); try { $result = $callback(); } finally { $this->debug('END execution (depth: {depth}), {count} commands executed', [ 'depth' => $this->executionDepth, 'count' => $this->executionCount ]); $this->executionCount = $count; $this->executionDepth--; } $this->syncExecutions(); return $result; }
php
{ "resource": "" }
q265090
GlobalPhsService.get
test
public function get($ph) { if (isset($this->phs[$ph])) { return $this->phs[$ph]; } return null; }
php
{ "resource": "" }
q265091
PharCompiler.create
test
public function create($phar_path = 'environaut.phar') { if (file_exists($phar_path)) { unlink($phar_path); } $phar = new \Phar($phar_path, 0, 'environaut.phar'); $phar->setSignatureAlgorithm(\Phar::SHA1); $phar->startBuffering(); $root_dir = dirname(dirname(__DIR__)); // add environaut files $finder = new Finder(); $finder->files()->notName('PharCompiler.php')->in($root_dir . '/src'); foreach ($finder as $file) { $phar->addFile($file->getRealPath(), 'src/' . $file->getRelativePathname()); } // add vendor files using a whitelist with excludes $finder = new Finder(); $finder->files() ->name('*.php') ->name('security\.sensiolabs\.org\.crt') ->path('/symfony\/console\//') ->path('/sensiolabs\/security-checker\//') ->notName('SecurityCheckerCommand.php') ->notPath('/(\/Tests\/|\/Tester\/)/') ->in($root_dir . '/vendor'); foreach ($finder as $file) { $phar->addFile($file->getRealPath(), 'vendor/' . $file->getRelativePathname()); } // add composer vendor autoloading $vendor_root_dir = $root_dir . '/vendor/'; $phar->addFile($vendor_root_dir . 'autoload.php', 'vendor/autoload.php'); $composer_dir = $vendor_root_dir . 'composer/'; $phar->addFile($composer_dir . 'autoload_namespaces.php', 'vendor/composer/autoload_namespaces.php'); $phar->addFile($composer_dir . 'autoload_classmap.php', 'vendor/composer/autoload_classmap.php'); $phar->addFile($composer_dir . 'autoload_psr4.php', 'vendor/composer/autoload_psr4.php'); $phar->addFile($composer_dir . 'autoload_real.php', 'vendor/composer/autoload_real.php'); //$phar->addFile($composer_dir . 'include_paths.php', 'vendor/composer/include_paths.php'); $phar->addFile($composer_dir . 'ClassLoader.php', 'vendor/composer/ClassLoader.php'); // environaut executable $phar->addFile($root_dir . '/bin/environaut', 'bin/environaut'); // additional markdown files like README.md or LICENSE.md $finder = new Finder(); $finder->files()->name('*.md')->depth('== 0')->in($root_dir); foreach ($finder as $file) { $phar->addFile($file->getRealPath(), '/' . $file->getRelativePathname()); } // add startup file $phar->setStub($this->getStub()); $phar->stopBuffering(); chmod($phar_path, 0755); }
php
{ "resource": "" }
q265092
Router.getPattern
test
public static function getPattern(string $name): ?string { if( array_key_exists($name, static::$patterns) ){ return static::$patterns[$name]; } return null; }
php
{ "resource": "" }
q265093
Router.mergeGroupConfig
test
protected function mergeGroupConfig(array $groupConfig): array { $config = $this->config; $config['hostname'] = $groupConfig['hostname'] ?? null; $config['prefix'] = $groupConfig['prefix'] ?? null; $config['namespace'] = $groupConfig['namespace'] ?? null; if( array_key_exists('middleware', $groupConfig) ){ if( array_key_exists('middleware', $config) ){ $config['middleware'] = array_merge($config['middleware'], $groupConfig['middleware']); } else { $config['middleware'] = $groupConfig['middleware']; } } return $config; }
php
{ "resource": "" }
q265094
BizDataObj_Assoc.removeRecord
test
public static function removeRecord($dataObj, $recArr, &$isParentObjUpdated) { if ($dataObj->association["Relationship"] == "M-M") { $isParentObjUpdated = false; return self::_removeRecordMtoM($dataObj, $recArr); } elseif ($dataObj->association["Relationship"] == "Self-Self") { $isParentObjUpdated = false; return self::_removeRecordSelftoSelf($dataObj, $recArr); } elseif ($dataObj->association["Relationship"] == "M-1" || $dataObj->association["Relationship"] == "1-1") { $isParentObjUpdated = true; return self::_removeRecordMto1($dataObj, $recArr); } elseif ($dataObj->association["Relationship"] == "1-M") { $isParentObjUpdated = false; return self::_removeRecord1toM($dataObj, $recArr); } else { throw new Openbizx\Data\Exception("You cannot add a record in dataobj who doesn't have M-M or M-1 or Self-Self relationship with its parent object"); return false; } }
php
{ "resource": "" }
q265095
BizDataObj_Assoc._removeRecordMtoM
test
private static function _removeRecordMtoM($dataObj, $recArr) { // delete a record on XTable $db = $dataObj->getDBConnection(); //TODO: delete using XDataObj if XDataObj is defined $where = $dataObj->association["XColumn1"] . "='" . $dataObj->association["FieldRefVal"] . "'"; $where .= " AND " . $dataObj->association["XColumn2"] . "='" . $recArr["Id"] . "'"; $sql = "DELETE FROM " . $dataObj->association["XTable"] . " WHERE " . $where; try { Openbizx::$app->getLog()->log(LOG_DEBUG, "DATAOBJ", "Associate Delete Sql = $sql"); $db->query($sql); } catch (Exception $e) { Openbizx::$app->getLog()->log(LOG_ERR, "DATAOBJ", "Query Error: " . $e->getMessage()); throw new Openbizx\Data\Exception("Query Error: " . $e->getMessage()); return false; } return true; }
php
{ "resource": "" }
q265096
BizDataObj_Assoc._removeRecordMto1
test
private static function _removeRecordMto1($dataObj, $recArr) { // set the $recArr[Id] to the parent table foriegn key column // get parent/association dataobj $asscObj = Openbizx::getObject($dataObj->association["AsscObjName"]); // call parent dataobj's updateRecord $updateRecArr["Id"] = $asscObj->getFieldValue("Id"); $updateRecArr[$dataObj->association["FieldRef"]] = ""; $ok = $asscObj->updateRecord($updateRecArr); if ($ok == false) return false; // requery on this object $dataObj->association["FieldRefVal"] = ""; return $dataObj->runSearch(); }
php
{ "resource": "" }
q265097
Model.relationsToArray
test
public function relationsToArray(){ $snakeAttributes = null; if (isset($this->ddvSnakeAttributes)&&is_bool($this->ddvSnakeAttributes)){ $snakeAttributes = static::$snakeAttributes; static::$snakeAttributes = $this->ddvSnakeAttributes; } $res = parent::relationsToArray(); is_null($snakeAttributes) || (static::$snakeAttributes = $snakeAttributes); return $res; }
php
{ "resource": "" }
q265098
MetaObject.readMetadata
test
protected function readMetadata(&$xmlArr) { $rootKeys = array_keys($xmlArr); $rootKey = $rootKeys[0]; if ($rootKey != "ATTRIBUTES") { $this->objectName = isset($xmlArr[$rootKey]["ATTRIBUTES"]["NAME"]) ? $xmlArr[$rootKey]["ATTRIBUTES"]["NAME"] : null; $this->objectDescription = isset($xmlArr[$rootKey]["ATTRIBUTES"]["DESCRIPTION"]) ? $xmlArr[$rootKey]["ATTRIBUTES"]["DESCRIPTION"] : null; $this->package = isset($xmlArr[$rootKey]["ATTRIBUTES"]["PACKAGE"]) ? $xmlArr[$rootKey]["ATTRIBUTES"]["PACKAGE"] : null; $this->className = isset($xmlArr[$rootKey]["ATTRIBUTES"]["CLASS"]) ? $xmlArr[$rootKey]["ATTRIBUTES"]["CLASS"] : null; $this->access = isset($xmlArr[$rootKey]["ATTRIBUTES"]["ACCESS"]) ? $xmlArr[$rootKey]["ATTRIBUTES"]["ACCESS"] : null; } else { $this->objectName = isset($xmlArr["ATTRIBUTES"]["NAME"]) ? $xmlArr["ATTRIBUTES"]["NAME"] : null; $this->objectDescription = isset($xmlArr["ATTRIBUTES"]["DESCRIPTION"]) ? $xmlArr["ATTRIBUTES"]["DESCRIPTION"] : null; $this->package = isset($xmlArr["ATTRIBUTES"]["PACKAGE"]) ? $xmlArr["ATTRIBUTES"]["PACKAGE"] : null; $this->className = isset($xmlArr["ATTRIBUTES"]["CLASS"]) ? $xmlArr["ATTRIBUTES"]["CLASS"] : null; $this->access = isset($xmlArr["ATTRIBUTES"]["ACCESS"]) ? $xmlArr["ATTRIBUTES"]["ACCESS"] : null; } }
php
{ "resource": "" }
q265099
MetaObject.readMetaCollection
test
protected function readMetaCollection(&$xmlArr, &$metaList) { if (!$xmlArr) { $metaList = null; return; } if (isset($xmlArr["ATTRIBUTES"])) { $metaList[] = $xmlArr; } else { $metaList = $xmlArr; } }
php
{ "resource": "" }