_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 33
8k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q265000
|
BizField.getDefaultValue
|
test
|
public function getDefaultValue()
{
if ($this->defaultValue !== null) {
|
php
|
{
"resource": ""
}
|
q265001
|
BizField.getValueOnCreate
|
test
|
public function getValueOnCreate()
{
if ($this->valueOnCreate !== null) {
|
php
|
{
"resource": ""
}
|
q265002
|
BizField.getValueOnUpdate
|
test
|
public function getValueOnUpdate()
{
if ($this->valueOnUpdate !== null)
|
php
|
{
"resource": ""
}
|
q265003
|
BizField.checkRequired
|
test
|
public function checkRequired()
{
if (!$this->required || $this->required == "") {
return false;
} elseif ($this->required == "Y") {
|
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":
|
php
|
{
"resource": ""
}
|
q265005
|
BizField.validate
|
test
|
public function validate()
{
$ret = true;
if ($this->validator)
|
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);
|
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]) {
|
php
|
{
"resource": ""
}
|
q265008
|
Twig_Loader_Themes.useTheme
|
test
|
public function useTheme($theme)
{
if (!in_array($theme, $this->fsloader->getNamespaces())) {
|
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);
|
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,
|
php
|
{
"resource": ""
}
|
q265011
|
ArrayUtils.key2offset
|
test
|
public static function key2offset(array &$arr, $key)
{
return
|
php
|
{
"resource": ""
}
|
q265012
|
ArrayUtils.offset2key
|
test
|
public static function offset2key(array &$arr, $offset)
{
|
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) {
|
php
|
{
"resource": ""
}
|
q265014
|
Route.setMiddleware
|
test
|
public function setMiddleware($middleware): Route
{
if( !is_array($middleware) ){
$middleware = [$middleware];
|
php
|
{
"resource": ""
}
|
q265015
|
Route.getAction
|
test
|
public function getAction()
{
if( is_string($this->action) &&
$this->namespace ){
|
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.
|
php
|
{
"resource": ""
}
|
q265017
|
Route.matchScheme
|
test
|
public function matchScheme($scheme): bool
{
if( empty($this->schemes) ){
return true;
}
|
php
|
{
"resource": ""
}
|
q265018
|
Route.matchHostname
|
test
|
public function matchHostname(string $hostnames): bool
{
if( empty($this->hostnames) ){
|
php
|
{
"resource": ""
}
|
q265019
|
Route.matchUri
|
test
|
public function matchUri(string $uri): bool
{
$pattern = implode("\/", $this->patternParts);
return
|
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) {
|
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'] . "'";
|
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;
|
php
|
{
"resource": ""
}
|
q265023
|
Report.getSettings
|
test
|
public function getSettings($groups = null, $flag = null)
{
$settings = array();
foreach ($this->results as $result) {
|
php
|
{
"resource": ""
}
|
q265024
|
HTMLPreview.getLink
|
test
|
protected function getLink()
{
if ($this->link == null)
return null;
$formobj = $this->getFormObj();
|
php
|
{
"resource": ""
}
|
q265025
|
HTMLPreview.getText
|
test
|
protected function getText()
{
if ($this->text == null)
return null;
$formObj = $this->getFormObj();
|
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();
}
}
|
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)
|
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
|
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) {
|
php
|
{
"resource": ""
}
|
q265030
|
BizDataSql.addTableColumn
|
test
|
public function addTableColumn($join, $column, $alias=null)
{
$tcol = $this->getTableColumn($join, $column);
|
php
|
{
"resource": ""
}
|
q265031
|
BizDataSql.addSqlExpression
|
test
|
public function addSqlExpression($sqlExpr, $alias=null)
{
if ($alias)
$sqlExpr .= ' AS '.$alias;
if (!$this->_tableColumns)
|
php
|
{
"resource": ""
}
|
q265032
|
BizDataSql.resetSQL
|
test
|
public function resetSQL()
{
$this->_sqlWhere = null;
|
php
|
{
"resource": ""
}
|
q265033
|
BizDataSql.addOrderBy
|
test
|
public function addOrderBy($orderBy)
{
if ($orderBy == null)
return;
if ($this->_orderBy == null)
{
$this->_orderBy = $orderBy;
}
|
php
|
{
"resource": ""
}
|
q265034
|
BizDataSql.addOtherSQL
|
test
|
public function addOtherSQL($otherSQL)
{
if ($otherSQL == null)
return;
if ($this->_otherSQL == null)
{
$this->_otherSQL = $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";
|
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
|
php
|
{
"resource": ""
}
|
q265037
|
DataSet.get
|
test
|
public function get($key)
{
if (isset($this->varValue[$key])) {
|
php
|
{
"resource": ""
}
|
q265038
|
CliController.cliAction
|
test
|
public function cliAction()
{
$exitCode = $this->cliApplication->run(new RequestInput($this->getRequest()));
|
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() .
|
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();
|
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'
|
php
|
{
"resource": ""
}
|
q265042
|
Setting.matchesGroup
|
test
|
public function matchesGroup($groups = null)
{
if (null !== $groups) {
|
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,
|
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) {
|
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();
}
|
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();
}
|
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 {
|
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) {
|
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 {
|
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());
|
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();
|
php
|
{
"resource": ""
}
|
q265052
|
BizDataObj.getOnAuditFields
|
test
|
public function getOnAuditFields()
{
$fieldList = array();
foreach ($this->bizRecord as $field) {
if ($field->onAudit)
|
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;
}
|
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
|
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
|
php
|
{
"resource": ""
}
|
q265056
|
BizDataObj._isNeedGenerateId
|
test
|
private function _isNeedGenerateId($recArr)
{
if ($this->idGeneration != 'None' && (!$recArr["Id"] || $recArr["Id"] == "")) {
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) .
|
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.'
|
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;
|
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 ){
|
php
|
{
"resource": ""
}
|
q265061
|
ReadOnlyCache.has
|
test
|
public function has($name, $groups = null, $flag = null)
{
foreach ($this->settings as $setting) {
if (($setting->getName() === $name) &&
|
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) &&
|
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;
}
|
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;
|
php
|
{
"resource": ""
}
|
q265065
|
ReadOnlyCache.setLocation
|
test
|
public function setLocation($location)
{
if (!is_readable($location)) {
throw new \InvalidArgumentException('Given cache location "' . $location . '" is not
|
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 ) )
|
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';
|
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;
|
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 )
|
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' )
|
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';
|
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
|
php
|
{
"resource": ""
}
|
q265073
|
Media.Comment
|
test
|
public function Comment($media_id, $comment)
{
$this->AddParam('text', $comment);
|
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);
|
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.
|
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()) {
|
php
|
{
"resource": ""
}
|
q265077
|
ContentResult.getPlaceholder
|
test
|
function getPlaceholder($index = null)
{
if (!isset($this['meta']['media']['placeholder'])) {
return null;
}
if (!$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
|
php
|
{
"resource": ""
}
|
q265079
|
CssRule.getOutput
|
test
|
public function getOutput()
{
return sprintf( $this->getTemplate(),
|
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)) {
|
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();
|
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();
}
}
|
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('');
|
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) {
|
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{
|
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) {
|
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) : "";
|
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, [
|
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', [
|
php
|
{
"resource": ""
}
|
q265090
|
GlobalPhsService.get
|
test
|
public function get($ph)
{
if (isset($this->phs[$ph])) {
|
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');
|
php
|
{
"resource": ""
}
|
q265092
|
Router.getPattern
|
test
|
public static function getPattern(string $name): ?string
{
if( array_key_exists($name, static::$patterns)
|
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) ){
|
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") {
|
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);
|
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
|
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 =
|
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;
|
php
|
{
"resource": ""
}
|
q265099
|
MetaObject.readMetaCollection
|
test
|
protected function readMetaCollection(&$xmlArr, &$metaList)
{
if (!$xmlArr) {
$metaList = null;
return;
}
if (isset($xmlArr["ATTRIBUTES"])) {
|
php
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.