id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
230,100
|
milesj/admin
|
Controller/AclController.php
|
AclController.beforeFilter
|
public function beforeFilter() {
parent::beforeFilter();
$this->Aco = Admin::introspectModel('Admin.ControlObject');
$this->Aro = Admin::introspectModel('Admin.RequestObject');
$this->Permission = Admin::introspectModel('Admin.ObjectPermission');
$this->Permission->cacheQueries = false;
}
|
php
|
public function beforeFilter() {
parent::beforeFilter();
$this->Aco = Admin::introspectModel('Admin.ControlObject');
$this->Aro = Admin::introspectModel('Admin.RequestObject');
$this->Permission = Admin::introspectModel('Admin.ObjectPermission');
$this->Permission->cacheQueries = false;
}
|
[
"public",
"function",
"beforeFilter",
"(",
")",
"{",
"parent",
"::",
"beforeFilter",
"(",
")",
";",
"$",
"this",
"->",
"Aco",
"=",
"Admin",
"::",
"introspectModel",
"(",
"'Admin.ControlObject'",
")",
";",
"$",
"this",
"->",
"Aro",
"=",
"Admin",
"::",
"introspectModel",
"(",
"'Admin.RequestObject'",
")",
";",
"$",
"this",
"->",
"Permission",
"=",
"Admin",
"::",
"introspectModel",
"(",
"'Admin.ObjectPermission'",
")",
";",
"$",
"this",
"->",
"Permission",
"->",
"cacheQueries",
"=",
"false",
";",
"}"
] |
Introspect ACL models and make them available.
|
[
"Introspect",
"ACL",
"models",
"and",
"make",
"them",
"available",
"."
] |
e5e93823d1eb4415f05a3191f653eb50c296d2c6
|
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/Controller/AclController.php#L66-L73
|
230,101
|
milesj/admin
|
Controller/AclController.php
|
AclController.getControllers
|
protected function getControllers() {
$mapParentId = array();
$acos = $this->Aco->getAll();
// Map IDs to parent IDs
foreach ($acos as $aco) {
$mapParentId[$aco['ControlObject']['id']] = $aco['ControlObject']['parent_id'];
}
// Determine the child depth
foreach ($acos as &$aco) {
$depth = 0;
$id = $aco['ControlObject']['id'];
while (isset($mapParentId[$id])) {
$depth++;
$id = $mapParentId[$id];
}
$aco['ControlObject']['depth'] = $depth;
}
return $acos;
}
|
php
|
protected function getControllers() {
$mapParentId = array();
$acos = $this->Aco->getAll();
// Map IDs to parent IDs
foreach ($acos as $aco) {
$mapParentId[$aco['ControlObject']['id']] = $aco['ControlObject']['parent_id'];
}
// Determine the child depth
foreach ($acos as &$aco) {
$depth = 0;
$id = $aco['ControlObject']['id'];
while (isset($mapParentId[$id])) {
$depth++;
$id = $mapParentId[$id];
}
$aco['ControlObject']['depth'] = $depth;
}
return $acos;
}
|
[
"protected",
"function",
"getControllers",
"(",
")",
"{",
"$",
"mapParentId",
"=",
"array",
"(",
")",
";",
"$",
"acos",
"=",
"$",
"this",
"->",
"Aco",
"->",
"getAll",
"(",
")",
";",
"// Map IDs to parent IDs",
"foreach",
"(",
"$",
"acos",
"as",
"$",
"aco",
")",
"{",
"$",
"mapParentId",
"[",
"$",
"aco",
"[",
"'ControlObject'",
"]",
"[",
"'id'",
"]",
"]",
"=",
"$",
"aco",
"[",
"'ControlObject'",
"]",
"[",
"'parent_id'",
"]",
";",
"}",
"// Determine the child depth",
"foreach",
"(",
"$",
"acos",
"as",
"&",
"$",
"aco",
")",
"{",
"$",
"depth",
"=",
"0",
";",
"$",
"id",
"=",
"$",
"aco",
"[",
"'ControlObject'",
"]",
"[",
"'id'",
"]",
";",
"while",
"(",
"isset",
"(",
"$",
"mapParentId",
"[",
"$",
"id",
"]",
")",
")",
"{",
"$",
"depth",
"++",
";",
"$",
"id",
"=",
"$",
"mapParentId",
"[",
"$",
"id",
"]",
";",
"}",
"$",
"aco",
"[",
"'ControlObject'",
"]",
"[",
"'depth'",
"]",
"=",
"$",
"depth",
";",
"}",
"return",
"$",
"acos",
";",
"}"
] |
Return all the ACOs.
@return array
|
[
"Return",
"all",
"the",
"ACOs",
"."
] |
e5e93823d1eb4415f05a3191f653eb50c296d2c6
|
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/Controller/AclController.php#L80-L104
|
230,102
|
milesj/admin
|
Controller/AclController.php
|
AclController.getRequesters
|
protected function getRequesters() {
$mapParentId = array();
$mapAroId = array();
$aros = $this->Aro->getAll();
$permissions = $this->Permission->getAll();
// Map ACOs to AROs indexed by IDs
foreach ($permissions as $permission) {
$permission = $permission['ObjectPermission'];
$mapAroId[$permission['aro_id']][$permission['aco_id']] = $permission;
}
// Map IDs to parent IDs
foreach ($aros as $aro) {
$mapParentId[$aro['RequestObject']['id']] = $aro['RequestObject'];
}
// Loop through AROs and determine permissions
// While taking into account inheritance
foreach ($aros as &$aro) {
$id = $aro['RequestObject']['id'];
$parent_id = $aro['RequestObject']['parent_id'];
$inheritance = array();
while (isset($mapParentId[$parent_id])) {
array_unshift($inheritance, $parent_id);
$parent_id = $mapParentId[$parent_id]['parent_id'];
}
$inheritance[] = $id;
// Fetch permissions from parents
$perms = array();
$parent_id = $aro['RequestObject']['parent_id']; // reset $parent_id
foreach ($inheritance as $pid) {
if (isset($mapAroId[$pid])) {
$perms = Hash::merge($perms, array_map(function($value) use ($id, $parent_id) {
// If the ARO on the permission doesn't match the current ARO
// It is being inherited, so force it to 0
if ($id != $value['aro_id']) {
$value = array_merge($value, array(
'_create' => 0,
'_read' => 0,
'_update' => 0,
'_delete' => 0
));
// Top level AROs cant inherit from nothing
// So change those values to denied
} else if (empty($parent_id)) {
foreach (array('_create', '_read', '_update', '_delete') as $action) {
if ($value[$action] == 0) {
$value[$action] = -1;
}
}
}
return $value;
}, $mapAroId[$pid]));
}
}
$aro['ObjectPermission'] = $perms;
}
return $aros;
}
|
php
|
protected function getRequesters() {
$mapParentId = array();
$mapAroId = array();
$aros = $this->Aro->getAll();
$permissions = $this->Permission->getAll();
// Map ACOs to AROs indexed by IDs
foreach ($permissions as $permission) {
$permission = $permission['ObjectPermission'];
$mapAroId[$permission['aro_id']][$permission['aco_id']] = $permission;
}
// Map IDs to parent IDs
foreach ($aros as $aro) {
$mapParentId[$aro['RequestObject']['id']] = $aro['RequestObject'];
}
// Loop through AROs and determine permissions
// While taking into account inheritance
foreach ($aros as &$aro) {
$id = $aro['RequestObject']['id'];
$parent_id = $aro['RequestObject']['parent_id'];
$inheritance = array();
while (isset($mapParentId[$parent_id])) {
array_unshift($inheritance, $parent_id);
$parent_id = $mapParentId[$parent_id]['parent_id'];
}
$inheritance[] = $id;
// Fetch permissions from parents
$perms = array();
$parent_id = $aro['RequestObject']['parent_id']; // reset $parent_id
foreach ($inheritance as $pid) {
if (isset($mapAroId[$pid])) {
$perms = Hash::merge($perms, array_map(function($value) use ($id, $parent_id) {
// If the ARO on the permission doesn't match the current ARO
// It is being inherited, so force it to 0
if ($id != $value['aro_id']) {
$value = array_merge($value, array(
'_create' => 0,
'_read' => 0,
'_update' => 0,
'_delete' => 0
));
// Top level AROs cant inherit from nothing
// So change those values to denied
} else if (empty($parent_id)) {
foreach (array('_create', '_read', '_update', '_delete') as $action) {
if ($value[$action] == 0) {
$value[$action] = -1;
}
}
}
return $value;
}, $mapAroId[$pid]));
}
}
$aro['ObjectPermission'] = $perms;
}
return $aros;
}
|
[
"protected",
"function",
"getRequesters",
"(",
")",
"{",
"$",
"mapParentId",
"=",
"array",
"(",
")",
";",
"$",
"mapAroId",
"=",
"array",
"(",
")",
";",
"$",
"aros",
"=",
"$",
"this",
"->",
"Aro",
"->",
"getAll",
"(",
")",
";",
"$",
"permissions",
"=",
"$",
"this",
"->",
"Permission",
"->",
"getAll",
"(",
")",
";",
"// Map ACOs to AROs indexed by IDs",
"foreach",
"(",
"$",
"permissions",
"as",
"$",
"permission",
")",
"{",
"$",
"permission",
"=",
"$",
"permission",
"[",
"'ObjectPermission'",
"]",
";",
"$",
"mapAroId",
"[",
"$",
"permission",
"[",
"'aro_id'",
"]",
"]",
"[",
"$",
"permission",
"[",
"'aco_id'",
"]",
"]",
"=",
"$",
"permission",
";",
"}",
"// Map IDs to parent IDs",
"foreach",
"(",
"$",
"aros",
"as",
"$",
"aro",
")",
"{",
"$",
"mapParentId",
"[",
"$",
"aro",
"[",
"'RequestObject'",
"]",
"[",
"'id'",
"]",
"]",
"=",
"$",
"aro",
"[",
"'RequestObject'",
"]",
";",
"}",
"// Loop through AROs and determine permissions",
"// While taking into account inheritance",
"foreach",
"(",
"$",
"aros",
"as",
"&",
"$",
"aro",
")",
"{",
"$",
"id",
"=",
"$",
"aro",
"[",
"'RequestObject'",
"]",
"[",
"'id'",
"]",
";",
"$",
"parent_id",
"=",
"$",
"aro",
"[",
"'RequestObject'",
"]",
"[",
"'parent_id'",
"]",
";",
"$",
"inheritance",
"=",
"array",
"(",
")",
";",
"while",
"(",
"isset",
"(",
"$",
"mapParentId",
"[",
"$",
"parent_id",
"]",
")",
")",
"{",
"array_unshift",
"(",
"$",
"inheritance",
",",
"$",
"parent_id",
")",
";",
"$",
"parent_id",
"=",
"$",
"mapParentId",
"[",
"$",
"parent_id",
"]",
"[",
"'parent_id'",
"]",
";",
"}",
"$",
"inheritance",
"[",
"]",
"=",
"$",
"id",
";",
"// Fetch permissions from parents",
"$",
"perms",
"=",
"array",
"(",
")",
";",
"$",
"parent_id",
"=",
"$",
"aro",
"[",
"'RequestObject'",
"]",
"[",
"'parent_id'",
"]",
";",
"// reset $parent_id",
"foreach",
"(",
"$",
"inheritance",
"as",
"$",
"pid",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"mapAroId",
"[",
"$",
"pid",
"]",
")",
")",
"{",
"$",
"perms",
"=",
"Hash",
"::",
"merge",
"(",
"$",
"perms",
",",
"array_map",
"(",
"function",
"(",
"$",
"value",
")",
"use",
"(",
"$",
"id",
",",
"$",
"parent_id",
")",
"{",
"// If the ARO on the permission doesn't match the current ARO",
"// It is being inherited, so force it to 0",
"if",
"(",
"$",
"id",
"!=",
"$",
"value",
"[",
"'aro_id'",
"]",
")",
"{",
"$",
"value",
"=",
"array_merge",
"(",
"$",
"value",
",",
"array",
"(",
"'_create'",
"=>",
"0",
",",
"'_read'",
"=>",
"0",
",",
"'_update'",
"=>",
"0",
",",
"'_delete'",
"=>",
"0",
")",
")",
";",
"// Top level AROs cant inherit from nothing",
"// So change those values to denied",
"}",
"else",
"if",
"(",
"empty",
"(",
"$",
"parent_id",
")",
")",
"{",
"foreach",
"(",
"array",
"(",
"'_create'",
",",
"'_read'",
",",
"'_update'",
",",
"'_delete'",
")",
"as",
"$",
"action",
")",
"{",
"if",
"(",
"$",
"value",
"[",
"$",
"action",
"]",
"==",
"0",
")",
"{",
"$",
"value",
"[",
"$",
"action",
"]",
"=",
"-",
"1",
";",
"}",
"}",
"}",
"return",
"$",
"value",
";",
"}",
",",
"$",
"mapAroId",
"[",
"$",
"pid",
"]",
")",
")",
";",
"}",
"}",
"$",
"aro",
"[",
"'ObjectPermission'",
"]",
"=",
"$",
"perms",
";",
"}",
"return",
"$",
"aros",
";",
"}"
] |
Return all the AROs with their permissions mapped.
@return array
|
[
"Return",
"all",
"the",
"AROs",
"with",
"their",
"permissions",
"mapped",
"."
] |
e5e93823d1eb4415f05a3191f653eb50c296d2c6
|
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/Controller/AclController.php#L111-L181
|
230,103
|
Webiny/Framework
|
src/Webiny/Component/ClassLoader/ClassLoader.php
|
ClassLoader.getClassFromCache
|
public function getClassFromCache($class)
{
// from cache
if (($file = $this->cache->read($class))) {
require $file;
}
// from disk
if ($file = $this->findClass($class)) {
$this->cache->save('wf.component.class_loader.' . $class, $file, 600, [
'_wf',
'_component',
'_class_loader'
]);
require $file;
}
}
|
php
|
public function getClassFromCache($class)
{
// from cache
if (($file = $this->cache->read($class))) {
require $file;
}
// from disk
if ($file = $this->findClass($class)) {
$this->cache->save('wf.component.class_loader.' . $class, $file, 600, [
'_wf',
'_component',
'_class_loader'
]);
require $file;
}
}
|
[
"public",
"function",
"getClassFromCache",
"(",
"$",
"class",
")",
"{",
"// from cache",
"if",
"(",
"(",
"$",
"file",
"=",
"$",
"this",
"->",
"cache",
"->",
"read",
"(",
"$",
"class",
")",
")",
")",
"{",
"require",
"$",
"file",
";",
"}",
"// from disk",
"if",
"(",
"$",
"file",
"=",
"$",
"this",
"->",
"findClass",
"(",
"$",
"class",
")",
")",
"{",
"$",
"this",
"->",
"cache",
"->",
"save",
"(",
"'wf.component.class_loader.'",
".",
"$",
"class",
",",
"$",
"file",
",",
"600",
",",
"[",
"'_wf'",
",",
"'_component'",
",",
"'_class_loader'",
"]",
")",
";",
"require",
"$",
"file",
";",
"}",
"}"
] |
First tries to find the class in the cache. If the class is not found in the cache, then it tries to find it
by using the registered maps.
@param string $class Name of the class you are trying to find.
@return bool True is retuned if the class if found and loaded into memory.
|
[
"First",
"tries",
"to",
"find",
"the",
"class",
"in",
"the",
"cache",
".",
"If",
"the",
"class",
"is",
"not",
"found",
"in",
"the",
"cache",
"then",
"it",
"tries",
"to",
"find",
"it",
"by",
"using",
"the",
"registered",
"maps",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/ClassLoader/ClassLoader.php#L167-L183
|
230,104
|
Webiny/Framework
|
src/Webiny/Component/ClassLoader/ClassLoader.php
|
ClassLoader.findClass
|
public function findClass($class)
{
if (strrpos($class, '\\') !== false) {
$file = Loaders\Psr4::getInstance()->findClass($class);
if (!$file) {
$file = Loaders\Psr0::getInstance()->findClass($class);
}
} else {
$file = Loaders\Pear::getInstance()->findClass($class);
}
return $file;
}
|
php
|
public function findClass($class)
{
if (strrpos($class, '\\') !== false) {
$file = Loaders\Psr4::getInstance()->findClass($class);
if (!$file) {
$file = Loaders\Psr0::getInstance()->findClass($class);
}
} else {
$file = Loaders\Pear::getInstance()->findClass($class);
}
return $file;
}
|
[
"public",
"function",
"findClass",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"strrpos",
"(",
"$",
"class",
",",
"'\\\\'",
")",
"!==",
"false",
")",
"{",
"$",
"file",
"=",
"Loaders",
"\\",
"Psr4",
"::",
"getInstance",
"(",
")",
"->",
"findClass",
"(",
"$",
"class",
")",
";",
"if",
"(",
"!",
"$",
"file",
")",
"{",
"$",
"file",
"=",
"Loaders",
"\\",
"Psr0",
"::",
"getInstance",
"(",
")",
"->",
"findClass",
"(",
"$",
"class",
")",
";",
"}",
"}",
"else",
"{",
"$",
"file",
"=",
"Loaders",
"\\",
"Pear",
"::",
"getInstance",
"(",
")",
"->",
"findClass",
"(",
"$",
"class",
")",
";",
"}",
"return",
"$",
"file",
";",
"}"
] |
Tries to get the path to the class based on registered maps.
@param string $class The name of the class
@return string|bool The path, if found, or false.
|
[
"Tries",
"to",
"get",
"the",
"path",
"to",
"the",
"class",
"based",
"on",
"registered",
"maps",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/ClassLoader/ClassLoader.php#L192-L204
|
230,105
|
ZenMagick/ZenCart
|
includes/modules/payment/authorizenet.php
|
authorizenet.InsertFP
|
function InsertFP ($loginid, $txnkey, $amount, $sequence, $currency = "") {
$tstamp = time ();
$fingerprint = $this->hmac ($txnkey, $loginid . "^" . $sequence . "^" . $tstamp . "^" . $amount . "^" . $currency);
$security_array = array('x_fp_sequence' => $sequence,
'x_fp_timestamp' => $tstamp,
'x_fp_hash' => $fingerprint);
return $security_array;
}
|
php
|
function InsertFP ($loginid, $txnkey, $amount, $sequence, $currency = "") {
$tstamp = time ();
$fingerprint = $this->hmac ($txnkey, $loginid . "^" . $sequence . "^" . $tstamp . "^" . $amount . "^" . $currency);
$security_array = array('x_fp_sequence' => $sequence,
'x_fp_timestamp' => $tstamp,
'x_fp_hash' => $fingerprint);
return $security_array;
}
|
[
"function",
"InsertFP",
"(",
"$",
"loginid",
",",
"$",
"txnkey",
",",
"$",
"amount",
",",
"$",
"sequence",
",",
"$",
"currency",
"=",
"\"\"",
")",
"{",
"$",
"tstamp",
"=",
"time",
"(",
")",
";",
"$",
"fingerprint",
"=",
"$",
"this",
"->",
"hmac",
"(",
"$",
"txnkey",
",",
"$",
"loginid",
".",
"\"^\"",
".",
"$",
"sequence",
".",
"\"^\"",
".",
"$",
"tstamp",
".",
"\"^\"",
".",
"$",
"amount",
".",
"\"^\"",
".",
"$",
"currency",
")",
";",
"$",
"security_array",
"=",
"array",
"(",
"'x_fp_sequence'",
"=>",
"$",
"sequence",
",",
"'x_fp_timestamp'",
"=>",
"$",
"tstamp",
",",
"'x_fp_hash'",
"=>",
"$",
"fingerprint",
")",
";",
"return",
"$",
"security_array",
";",
"}"
] |
Inserts the hidden variables in the HTML FORM required for SIM
Invokes hmac function to calculate fingerprint.
@param string $loginid
@param string $txnkey
@param float $amount
@param string $sequence
@param float $currency
@return string
|
[
"Inserts",
"the",
"hidden",
"variables",
"in",
"the",
"HTML",
"FORM",
"required",
"for",
"SIM",
"Invokes",
"hmac",
"function",
"to",
"calculate",
"fingerprint",
"."
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/modules/payment/authorizenet.php#L156-L163
|
230,106
|
ZenMagick/ZenCart
|
includes/modules/payment/authorizenet.php
|
authorizenet.update_status
|
function update_status() {
global $order, $db;
if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_AUTHORIZENET_ZONE > 0) ) {
$check_flag = false;
$check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_AUTHORIZENET_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");
while (!$check->EOF) {
if ($check->fields['zone_id'] < 1) {
$check_flag = true;
break;
} elseif ($check->fields['zone_id'] == $order->billing['zone_id']) {
$check_flag = true;
break;
}
$check->MoveNext();
}
if ($check_flag == false) {
$this->enabled = false;
}
}
}
|
php
|
function update_status() {
global $order, $db;
if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_AUTHORIZENET_ZONE > 0) ) {
$check_flag = false;
$check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_AUTHORIZENET_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");
while (!$check->EOF) {
if ($check->fields['zone_id'] < 1) {
$check_flag = true;
break;
} elseif ($check->fields['zone_id'] == $order->billing['zone_id']) {
$check_flag = true;
break;
}
$check->MoveNext();
}
if ($check_flag == false) {
$this->enabled = false;
}
}
}
|
[
"function",
"update_status",
"(",
")",
"{",
"global",
"$",
"order",
",",
"$",
"db",
";",
"if",
"(",
"(",
"$",
"this",
"->",
"enabled",
"==",
"true",
")",
"&&",
"(",
"(",
"int",
")",
"MODULE_PAYMENT_AUTHORIZENET_ZONE",
">",
"0",
")",
")",
"{",
"$",
"check_flag",
"=",
"false",
";",
"$",
"check",
"=",
"$",
"db",
"->",
"Execute",
"(",
"\"select zone_id from \"",
".",
"TABLE_ZONES_TO_GEO_ZONES",
".",
"\" where geo_zone_id = '\"",
".",
"MODULE_PAYMENT_AUTHORIZENET_ZONE",
".",
"\"' and zone_country_id = '\"",
".",
"$",
"order",
"->",
"billing",
"[",
"'country'",
"]",
"[",
"'id'",
"]",
".",
"\"' order by zone_id\"",
")",
";",
"while",
"(",
"!",
"$",
"check",
"->",
"EOF",
")",
"{",
"if",
"(",
"$",
"check",
"->",
"fields",
"[",
"'zone_id'",
"]",
"<",
"1",
")",
"{",
"$",
"check_flag",
"=",
"true",
";",
"break",
";",
"}",
"elseif",
"(",
"$",
"check",
"->",
"fields",
"[",
"'zone_id'",
"]",
"==",
"$",
"order",
"->",
"billing",
"[",
"'zone_id'",
"]",
")",
"{",
"$",
"check_flag",
"=",
"true",
";",
"break",
";",
"}",
"$",
"check",
"->",
"MoveNext",
"(",
")",
";",
"}",
"if",
"(",
"$",
"check_flag",
"==",
"false",
")",
"{",
"$",
"this",
"->",
"enabled",
"=",
"false",
";",
"}",
"}",
"}"
] |
Calculate zone matches and flag settings to determine whether this module should display to customers or not
|
[
"Calculate",
"zone",
"matches",
"and",
"flag",
"settings",
"to",
"determine",
"whether",
"this",
"module",
"should",
"display",
"to",
"customers",
"or",
"not"
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/modules/payment/authorizenet.php#L170-L191
|
230,107
|
naneau/semver
|
src/Naneau/SemVer/Version/Build.php
|
Build.addPart
|
public function addPart($part)
{
// Sanity check
if (!ctype_alnum($part)) {
throw new InvalidArgumentException(
'Build part "' . $part . '" is not alpha numerical'
);
}
$this->parts[] = $part;
return $this;
}
|
php
|
public function addPart($part)
{
// Sanity check
if (!ctype_alnum($part)) {
throw new InvalidArgumentException(
'Build part "' . $part . '" is not alpha numerical'
);
}
$this->parts[] = $part;
return $this;
}
|
[
"public",
"function",
"addPart",
"(",
"$",
"part",
")",
"{",
"// Sanity check",
"if",
"(",
"!",
"ctype_alnum",
"(",
"$",
"part",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Build part \"'",
".",
"$",
"part",
".",
"'\" is not alpha numerical'",
")",
";",
"}",
"$",
"this",
"->",
"parts",
"[",
"]",
"=",
"$",
"part",
";",
"return",
"$",
"this",
";",
"}"
] |
Add a part to the build parts stack
@param string $part
@return Build
|
[
"Add",
"a",
"part",
"to",
"the",
"build",
"parts",
"stack"
] |
c771ad1e6c89064c0a4fa714979639dc3649d6c8
|
https://github.com/naneau/semver/blob/c771ad1e6c89064c0a4fa714979639dc3649d6c8/src/Naneau/SemVer/Version/Build.php#L101-L113
|
230,108
|
clue/php-socket-react
|
src/Datagram/Factory.php
|
Factory.createServer
|
public function createServer($address, $context = array())
{
$that = $this;
$factory = $this->rawFactory;
return $this->resolve($address)->then(function ($address) use ($factory, $that, $context){
$scheme = 'udp';
$socket = $factory->createFromString($address, $scheme);
if ($socket->getType() !== SOCK_DGRAM) {
$socket->close();
throw new Exception('Not a datagram address scheme');
}
if (isset($context['broadcast']) && $context['broadcast']) {
$socket->setOption(SOL_SOCKET, SO_BROADCAST, 1);
}
$socket->setBlocking(false);
$socket->bind($address);
return $that->createFromRaw($socket);
});
}
|
php
|
public function createServer($address, $context = array())
{
$that = $this;
$factory = $this->rawFactory;
return $this->resolve($address)->then(function ($address) use ($factory, $that, $context){
$scheme = 'udp';
$socket = $factory->createFromString($address, $scheme);
if ($socket->getType() !== SOCK_DGRAM) {
$socket->close();
throw new Exception('Not a datagram address scheme');
}
if (isset($context['broadcast']) && $context['broadcast']) {
$socket->setOption(SOL_SOCKET, SO_BROADCAST, 1);
}
$socket->setBlocking(false);
$socket->bind($address);
return $that->createFromRaw($socket);
});
}
|
[
"public",
"function",
"createServer",
"(",
"$",
"address",
",",
"$",
"context",
"=",
"array",
"(",
")",
")",
"{",
"$",
"that",
"=",
"$",
"this",
";",
"$",
"factory",
"=",
"$",
"this",
"->",
"rawFactory",
";",
"return",
"$",
"this",
"->",
"resolve",
"(",
"$",
"address",
")",
"->",
"then",
"(",
"function",
"(",
"$",
"address",
")",
"use",
"(",
"$",
"factory",
",",
"$",
"that",
",",
"$",
"context",
")",
"{",
"$",
"scheme",
"=",
"'udp'",
";",
"$",
"socket",
"=",
"$",
"factory",
"->",
"createFromString",
"(",
"$",
"address",
",",
"$",
"scheme",
")",
";",
"if",
"(",
"$",
"socket",
"->",
"getType",
"(",
")",
"!==",
"SOCK_DGRAM",
")",
"{",
"$",
"socket",
"->",
"close",
"(",
")",
";",
"throw",
"new",
"Exception",
"(",
"'Not a datagram address scheme'",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"context",
"[",
"'broadcast'",
"]",
")",
"&&",
"$",
"context",
"[",
"'broadcast'",
"]",
")",
"{",
"$",
"socket",
"->",
"setOption",
"(",
"SOL_SOCKET",
",",
"SO_BROADCAST",
",",
"1",
")",
";",
"}",
"$",
"socket",
"->",
"setBlocking",
"(",
"false",
")",
";",
"$",
"socket",
"->",
"bind",
"(",
"$",
"address",
")",
";",
"return",
"$",
"that",
"->",
"createFromRaw",
"(",
"$",
"socket",
")",
";",
"}",
")",
";",
"}"
] |
create datagram server socket waiting for incoming messages on the given local address
@param string $address
@param array $context (optional) "broadcast" context option
@return PromiseInterface to return a \Socket\React\Datagram\Datagram
@uses RawFactory::createFromString()
@uses RawSocket::setBlocking() to turn on non-blocking mode
@uses RawSocket::bind() to initiate connection
|
[
"create",
"datagram",
"server",
"socket",
"waiting",
"for",
"incoming",
"messages",
"on",
"the",
"given",
"local",
"address"
] |
420dcbc20e8b007a7df2a12373af94b0b70ec15e
|
https://github.com/clue/php-socket-react/blob/420dcbc20e8b007a7df2a12373af94b0b70ec15e/src/Datagram/Factory.php#L91-L113
|
230,109
|
Webiny/Framework
|
src/Webiny/Component/Rest/Rest.php
|
Rest.initRest
|
public static function initRest($api, $url = '', $method = '')
{
$config = self::getConfig()->get($api, false);
if (!$config) {
throw new RestException('Configuration for "' . $api . '" not found.');
}
// check if we have the Path defined
$path = $config->get('Router.Path', false);
if (!$path) {
throw new RestException('Router.Path is not defined for "' . $api . '" api.');
}
// create the route for Router component
$route = [
'WebinyRest' . $api => [
'Path' => self::str($path)->trimRight('/')->append('/{webiny_rest_params}')->val(),
'Callback' => 'null',
'Options' => [
'webiny_rest_params' => [
'Pattern' => '.*?'
]
]
]
];
// call the router and match the request
// we must append some dummy content at the end of the url, because in case of a default API method, and since
// we have added an additional pattern to the url, the url will not match
self::router()->prependRoutes(new ConfigObject($route));
if ($url == '') {
$result = self::router()->match(self::str(self::httpRequest()->getCurrentUrl(true)->getPath())
->trimRight('/')
->append('/_w_rest/_foo')
->val());
} else {
$result = self::router()->match(self::str($url)->trimRight('/')->append('/_w_rest/_foo')->val());
}
if (!$result) {
return false;
}
self::$url = $url;
self::$method = $method;
return self::processRouterResponse($result, $config, $api);
}
|
php
|
public static function initRest($api, $url = '', $method = '')
{
$config = self::getConfig()->get($api, false);
if (!$config) {
throw new RestException('Configuration for "' . $api . '" not found.');
}
// check if we have the Path defined
$path = $config->get('Router.Path', false);
if (!$path) {
throw new RestException('Router.Path is not defined for "' . $api . '" api.');
}
// create the route for Router component
$route = [
'WebinyRest' . $api => [
'Path' => self::str($path)->trimRight('/')->append('/{webiny_rest_params}')->val(),
'Callback' => 'null',
'Options' => [
'webiny_rest_params' => [
'Pattern' => '.*?'
]
]
]
];
// call the router and match the request
// we must append some dummy content at the end of the url, because in case of a default API method, and since
// we have added an additional pattern to the url, the url will not match
self::router()->prependRoutes(new ConfigObject($route));
if ($url == '') {
$result = self::router()->match(self::str(self::httpRequest()->getCurrentUrl(true)->getPath())
->trimRight('/')
->append('/_w_rest/_foo')
->val());
} else {
$result = self::router()->match(self::str($url)->trimRight('/')->append('/_w_rest/_foo')->val());
}
if (!$result) {
return false;
}
self::$url = $url;
self::$method = $method;
return self::processRouterResponse($result, $config, $api);
}
|
[
"public",
"static",
"function",
"initRest",
"(",
"$",
"api",
",",
"$",
"url",
"=",
"''",
",",
"$",
"method",
"=",
"''",
")",
"{",
"$",
"config",
"=",
"self",
"::",
"getConfig",
"(",
")",
"->",
"get",
"(",
"$",
"api",
",",
"false",
")",
";",
"if",
"(",
"!",
"$",
"config",
")",
"{",
"throw",
"new",
"RestException",
"(",
"'Configuration for \"'",
".",
"$",
"api",
".",
"'\" not found.'",
")",
";",
"}",
"// check if we have the Path defined",
"$",
"path",
"=",
"$",
"config",
"->",
"get",
"(",
"'Router.Path'",
",",
"false",
")",
";",
"if",
"(",
"!",
"$",
"path",
")",
"{",
"throw",
"new",
"RestException",
"(",
"'Router.Path is not defined for \"'",
".",
"$",
"api",
".",
"'\" api.'",
")",
";",
"}",
"// create the route for Router component",
"$",
"route",
"=",
"[",
"'WebinyRest'",
".",
"$",
"api",
"=>",
"[",
"'Path'",
"=>",
"self",
"::",
"str",
"(",
"$",
"path",
")",
"->",
"trimRight",
"(",
"'/'",
")",
"->",
"append",
"(",
"'/{webiny_rest_params}'",
")",
"->",
"val",
"(",
")",
",",
"'Callback'",
"=>",
"'null'",
",",
"'Options'",
"=>",
"[",
"'webiny_rest_params'",
"=>",
"[",
"'Pattern'",
"=>",
"'.*?'",
"]",
"]",
"]",
"]",
";",
"// call the router and match the request",
"// we must append some dummy content at the end of the url, because in case of a default API method, and since",
"// we have added an additional pattern to the url, the url will not match",
"self",
"::",
"router",
"(",
")",
"->",
"prependRoutes",
"(",
"new",
"ConfigObject",
"(",
"$",
"route",
")",
")",
";",
"if",
"(",
"$",
"url",
"==",
"''",
")",
"{",
"$",
"result",
"=",
"self",
"::",
"router",
"(",
")",
"->",
"match",
"(",
"self",
"::",
"str",
"(",
"self",
"::",
"httpRequest",
"(",
")",
"->",
"getCurrentUrl",
"(",
"true",
")",
"->",
"getPath",
"(",
")",
")",
"->",
"trimRight",
"(",
"'/'",
")",
"->",
"append",
"(",
"'/_w_rest/_foo'",
")",
"->",
"val",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"self",
"::",
"router",
"(",
")",
"->",
"match",
"(",
"self",
"::",
"str",
"(",
"$",
"url",
")",
"->",
"trimRight",
"(",
"'/'",
")",
"->",
"append",
"(",
"'/_w_rest/_foo'",
")",
"->",
"val",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"return",
"false",
";",
"}",
"self",
"::",
"$",
"url",
"=",
"$",
"url",
";",
"self",
"::",
"$",
"method",
"=",
"$",
"method",
";",
"return",
"self",
"::",
"processRouterResponse",
"(",
"$",
"result",
",",
"$",
"config",
",",
"$",
"api",
")",
";",
"}"
] |
Initializes the current Rest configuration, tries to match the current URL with the defined Path.
If match was successful, an instance of Rest class is returned, otherwise false.
@param string $api Api configuration Name
@param string $url Url on which the to match. Leave blank to use the current url.
@param string $method Name of the HTTP method that will be used to match the request.
Leave blank to use the method from the current HTTP request.
@return bool|Rest
@throws RestException
@throws \Webiny\Component\StdLib\StdObject\StringObject\StringObjectException
|
[
"Initializes",
"the",
"current",
"Rest",
"configuration",
"tries",
"to",
"match",
"the",
"current",
"URL",
"with",
"the",
"defined",
"Path",
".",
"If",
"match",
"was",
"successful",
"an",
"instance",
"of",
"Rest",
"class",
"is",
"returned",
"otherwise",
"false",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Rest/Rest.php#L102-L150
|
230,110
|
Webiny/Framework
|
src/Webiny/Component/Rest/Rest.php
|
Rest.processRouterResponse
|
private static function processRouterResponse(MatchedRoute $matchedRoute, ConfigObject $config, $api)
{
// based on the matched route create the class name
$className = self::str($config->get('Router.Class'))->trimLeft('\\')->prepend('\\');
$normalize = $config->get('Router.Normalize', false);
$matchedParams = $matchedRoute->getParams();
foreach ($matchedParams as $mpName => $mpParam) {
if ($normalize) {
$mpParam = self::str($mpParam)->replace('-', ' ')->caseWordUpper()->replace(' ', '');
}
$className->replace('{' . $mpName . '}', $mpParam);
}
// return the new rest instance
return new self($api, $className->val());
}
|
php
|
private static function processRouterResponse(MatchedRoute $matchedRoute, ConfigObject $config, $api)
{
// based on the matched route create the class name
$className = self::str($config->get('Router.Class'))->trimLeft('\\')->prepend('\\');
$normalize = $config->get('Router.Normalize', false);
$matchedParams = $matchedRoute->getParams();
foreach ($matchedParams as $mpName => $mpParam) {
if ($normalize) {
$mpParam = self::str($mpParam)->replace('-', ' ')->caseWordUpper()->replace(' ', '');
}
$className->replace('{' . $mpName . '}', $mpParam);
}
// return the new rest instance
return new self($api, $className->val());
}
|
[
"private",
"static",
"function",
"processRouterResponse",
"(",
"MatchedRoute",
"$",
"matchedRoute",
",",
"ConfigObject",
"$",
"config",
",",
"$",
"api",
")",
"{",
"// based on the matched route create the class name",
"$",
"className",
"=",
"self",
"::",
"str",
"(",
"$",
"config",
"->",
"get",
"(",
"'Router.Class'",
")",
")",
"->",
"trimLeft",
"(",
"'\\\\'",
")",
"->",
"prepend",
"(",
"'\\\\'",
")",
";",
"$",
"normalize",
"=",
"$",
"config",
"->",
"get",
"(",
"'Router.Normalize'",
",",
"false",
")",
";",
"$",
"matchedParams",
"=",
"$",
"matchedRoute",
"->",
"getParams",
"(",
")",
";",
"foreach",
"(",
"$",
"matchedParams",
"as",
"$",
"mpName",
"=>",
"$",
"mpParam",
")",
"{",
"if",
"(",
"$",
"normalize",
")",
"{",
"$",
"mpParam",
"=",
"self",
"::",
"str",
"(",
"$",
"mpParam",
")",
"->",
"replace",
"(",
"'-'",
",",
"' '",
")",
"->",
"caseWordUpper",
"(",
")",
"->",
"replace",
"(",
"' '",
",",
"''",
")",
";",
"}",
"$",
"className",
"->",
"replace",
"(",
"'{'",
".",
"$",
"mpName",
".",
"'}'",
",",
"$",
"mpParam",
")",
";",
"}",
"// return the new rest instance",
"return",
"new",
"self",
"(",
"$",
"api",
",",
"$",
"className",
"->",
"val",
"(",
")",
")",
";",
"}"
] |
Internal static method that is called when initRest method matches a URL agains the Path.
This method then processes that matched response and then creates and returns a Rest instance back to iniRest.
@param MatchedRoute $matchedRoute The matched route.
@param ConfigObject $config Current api config.
@param string $api Current api name.
@return Rest
@throws \Webiny\Component\StdLib\StdObject\StringObject\StringObjectException
|
[
"Internal",
"static",
"method",
"that",
"is",
"called",
"when",
"initRest",
"method",
"matches",
"a",
"URL",
"agains",
"the",
"Path",
".",
"This",
"method",
"then",
"processes",
"that",
"matched",
"response",
"and",
"then",
"creates",
"and",
"returns",
"a",
"Rest",
"instance",
"back",
"to",
"iniRest",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Rest/Rest.php#L163-L179
|
230,111
|
Webiny/Framework
|
src/Webiny/Component/Rest/Rest.php
|
Rest.setEnvironment
|
public function setEnvironment($env = self::ENV_PRODUCTION)
{
if ($env != self::ENV_DEVELOPMENT && $env != self::ENV_PRODUCTION) {
throw new RestException('Unknown environment "' . $env . '".');
}
$this->environment = $env;
}
|
php
|
public function setEnvironment($env = self::ENV_PRODUCTION)
{
if ($env != self::ENV_DEVELOPMENT && $env != self::ENV_PRODUCTION) {
throw new RestException('Unknown environment "' . $env . '".');
}
$this->environment = $env;
}
|
[
"public",
"function",
"setEnvironment",
"(",
"$",
"env",
"=",
"self",
"::",
"ENV_PRODUCTION",
")",
"{",
"if",
"(",
"$",
"env",
"!=",
"self",
"::",
"ENV_DEVELOPMENT",
"&&",
"$",
"env",
"!=",
"self",
"::",
"ENV_PRODUCTION",
")",
"{",
"throw",
"new",
"RestException",
"(",
"'Unknown environment \"'",
".",
"$",
"env",
".",
"'\".'",
")",
";",
"}",
"$",
"this",
"->",
"environment",
"=",
"$",
"env",
";",
"}"
] |
Set the component environment.
If it's development, the component will output additional information inside the debug header.
@param string $env Can either be 'development' or 'production'
@throws RestException
|
[
"Set",
"the",
"component",
"environment",
".",
"If",
"it",
"s",
"development",
"the",
"component",
"will",
"output",
"additional",
"information",
"inside",
"the",
"debug",
"header",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Rest/Rest.php#L214-L221
|
230,112
|
Webiny/Framework
|
src/Webiny/Component/Rest/Rest.php
|
Rest.processRequest
|
public function processRequest()
{
try {
$router = new Router($this->api, $this->class, $this->normalize, $this->cacheInstance);
// check if url is set via the initRest method
if (!empty(self::$url)) {
$router->setUrl(self::$url);
}
// check if the method vas set via initRest method
if (!empty(self::$method)) {
$router->setHttpMethod(self::$method);
}
return $router->processRequest();
} catch (\Exception $e) {
$exception = new RestException('Unable to process request for class "' . $this->class . '". ' . $e->getMessage());
$exception->setRequestedClass($this->class);
throw $exception;
}
}
|
php
|
public function processRequest()
{
try {
$router = new Router($this->api, $this->class, $this->normalize, $this->cacheInstance);
// check if url is set via the initRest method
if (!empty(self::$url)) {
$router->setUrl(self::$url);
}
// check if the method vas set via initRest method
if (!empty(self::$method)) {
$router->setHttpMethod(self::$method);
}
return $router->processRequest();
} catch (\Exception $e) {
$exception = new RestException('Unable to process request for class "' . $this->class . '". ' . $e->getMessage());
$exception->setRequestedClass($this->class);
throw $exception;
}
}
|
[
"public",
"function",
"processRequest",
"(",
")",
"{",
"try",
"{",
"$",
"router",
"=",
"new",
"Router",
"(",
"$",
"this",
"->",
"api",
",",
"$",
"this",
"->",
"class",
",",
"$",
"this",
"->",
"normalize",
",",
"$",
"this",
"->",
"cacheInstance",
")",
";",
"// check if url is set via the initRest method",
"if",
"(",
"!",
"empty",
"(",
"self",
"::",
"$",
"url",
")",
")",
"{",
"$",
"router",
"->",
"setUrl",
"(",
"self",
"::",
"$",
"url",
")",
";",
"}",
"// check if the method vas set via initRest method",
"if",
"(",
"!",
"empty",
"(",
"self",
"::",
"$",
"method",
")",
")",
"{",
"$",
"router",
"->",
"setHttpMethod",
"(",
"self",
"::",
"$",
"method",
")",
";",
"}",
"return",
"$",
"router",
"->",
"processRequest",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"exception",
"=",
"new",
"RestException",
"(",
"'Unable to process request for class \"'",
".",
"$",
"this",
"->",
"class",
".",
"'\". '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"$",
"exception",
"->",
"setRequestedClass",
"(",
"$",
"this",
"->",
"class",
")",
";",
"throw",
"$",
"exception",
";",
"}",
"}"
] |
Processes the current request and returns an instance of CallbackResult.
@return bool|Response\CallbackResult
@throws RestException
|
[
"Processes",
"the",
"current",
"request",
"and",
"returns",
"an",
"instance",
"of",
"CallbackResult",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Rest/Rest.php#L239-L260
|
230,113
|
Webiny/Framework
|
src/Webiny/Component/Rest/Rest.php
|
Rest.registerClass
|
private function registerClass()
{
try {
if (!$this->cacheInstance->isCacheValid($this->api, $this->class) || $this->isDevelopment()) {
$this->parseClass();
}
} catch (\Exception $e) {
$exception = new RestException('Unable to register class "' . $this->class . '". ' . $e->getMessage());
$exception->setRequestedClass($this->class);
throw $exception;
}
}
|
php
|
private function registerClass()
{
try {
if (!$this->cacheInstance->isCacheValid($this->api, $this->class) || $this->isDevelopment()) {
$this->parseClass();
}
} catch (\Exception $e) {
$exception = new RestException('Unable to register class "' . $this->class . '". ' . $e->getMessage());
$exception->setRequestedClass($this->class);
throw $exception;
}
}
|
[
"private",
"function",
"registerClass",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"cacheInstance",
"->",
"isCacheValid",
"(",
"$",
"this",
"->",
"api",
",",
"$",
"this",
"->",
"class",
")",
"||",
"$",
"this",
"->",
"isDevelopment",
"(",
")",
")",
"{",
"$",
"this",
"->",
"parseClass",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"exception",
"=",
"new",
"RestException",
"(",
"'Unable to register class \"'",
".",
"$",
"this",
"->",
"class",
".",
"'\". '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"$",
"exception",
"->",
"setRequestedClass",
"(",
"$",
"this",
"->",
"class",
")",
";",
"throw",
"$",
"exception",
";",
"}",
"}"
] |
Registers the class and creates a compile cache version of it.
@throws RestException
|
[
"Registers",
"the",
"class",
"and",
"creates",
"a",
"compile",
"cache",
"version",
"of",
"it",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Rest/Rest.php#L277-L288
|
230,114
|
Webiny/Framework
|
src/Webiny/Component/Rest/Rest.php
|
Rest.parseClass
|
private function parseClass()
{
$parser = new Parser();
$parsedApi = $parser->parseApi($this->class, $this->normalize);
// in development we always write cache
$writer = new Compiler($this->api, $this->normalize, $this->cacheInstance);
$writer->writeCacheFiles($parsedApi);
}
|
php
|
private function parseClass()
{
$parser = new Parser();
$parsedApi = $parser->parseApi($this->class, $this->normalize);
// in development we always write cache
$writer = new Compiler($this->api, $this->normalize, $this->cacheInstance);
$writer->writeCacheFiles($parsedApi);
}
|
[
"private",
"function",
"parseClass",
"(",
")",
"{",
"$",
"parser",
"=",
"new",
"Parser",
"(",
")",
";",
"$",
"parsedApi",
"=",
"$",
"parser",
"->",
"parseApi",
"(",
"$",
"this",
"->",
"class",
",",
"$",
"this",
"->",
"normalize",
")",
";",
"// in development we always write cache",
"$",
"writer",
"=",
"new",
"Compiler",
"(",
"$",
"this",
"->",
"api",
",",
"$",
"this",
"->",
"normalize",
",",
"$",
"this",
"->",
"cacheInstance",
")",
";",
"$",
"writer",
"->",
"writeCacheFiles",
"(",
"$",
"parsedApi",
")",
";",
"}"
] |
Calls the Parser to parse the class and
then Compiler to create a compiled cache file of the parsed class.
|
[
"Calls",
"the",
"Parser",
"to",
"parse",
"the",
"class",
"and",
"then",
"Compiler",
"to",
"create",
"a",
"compiled",
"cache",
"file",
"of",
"the",
"parsed",
"class",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Rest/Rest.php#L294-L302
|
230,115
|
Webiny/Framework
|
src/Webiny/Component/Rest/Rest.php
|
Rest.initializeCache
|
private function initializeCache()
{
// get driver
if (!($driver = $this->config->get('CompilerCacheDriver', false))) {
// default driver
if ($this->isDevelopment()) {
$driver = self::DEV_CACHE_DRIVER;
} else {
$driver = self::PROD_CACHE_DRIVER;
}
}
// create driver instance
try {
$instance = $this->factory($driver, CacheDriverInterface::class);
$this->cacheInstance = new Cache($instance);
} catch (Exception $e) {
throw $e;
}
}
|
php
|
private function initializeCache()
{
// get driver
if (!($driver = $this->config->get('CompilerCacheDriver', false))) {
// default driver
if ($this->isDevelopment()) {
$driver = self::DEV_CACHE_DRIVER;
} else {
$driver = self::PROD_CACHE_DRIVER;
}
}
// create driver instance
try {
$instance = $this->factory($driver, CacheDriverInterface::class);
$this->cacheInstance = new Cache($instance);
} catch (Exception $e) {
throw $e;
}
}
|
[
"private",
"function",
"initializeCache",
"(",
")",
"{",
"// get driver",
"if",
"(",
"!",
"(",
"$",
"driver",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'CompilerCacheDriver'",
",",
"false",
")",
")",
")",
"{",
"// default driver",
"if",
"(",
"$",
"this",
"->",
"isDevelopment",
"(",
")",
")",
"{",
"$",
"driver",
"=",
"self",
"::",
"DEV_CACHE_DRIVER",
";",
"}",
"else",
"{",
"$",
"driver",
"=",
"self",
"::",
"PROD_CACHE_DRIVER",
";",
"}",
"}",
"// create driver instance",
"try",
"{",
"$",
"instance",
"=",
"$",
"this",
"->",
"factory",
"(",
"$",
"driver",
",",
"CacheDriverInterface",
"::",
"class",
")",
";",
"$",
"this",
"->",
"cacheInstance",
"=",
"new",
"Cache",
"(",
"$",
"instance",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"}"
] |
Initializes the compiler cache driver.
@throws Exception
@throws \Exception
|
[
"Initializes",
"the",
"compiler",
"cache",
"driver",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Rest/Rest.php#L310-L329
|
230,116
|
addiks/phpsql
|
src/Addiks/PHPSQL/Value/Database/Dsn.php
|
Dsn.getDriverName
|
public function getDriverName()
{
$value = $this->getValue();
$value = explode(":", $value);
$driver = reset($value);
return $driver;
}
|
php
|
public function getDriverName()
{
$value = $this->getValue();
$value = explode(":", $value);
$driver = reset($value);
return $driver;
}
|
[
"public",
"function",
"getDriverName",
"(",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"$",
"value",
"=",
"explode",
"(",
"\":\"",
",",
"$",
"value",
")",
";",
"$",
"driver",
"=",
"reset",
"(",
"$",
"value",
")",
";",
"return",
"$",
"driver",
";",
"}"
] |
gets the driver-name.
@return string
|
[
"gets",
"the",
"driver",
"-",
"name",
"."
] |
28dae64ffc2123f39f801a50ab53bfe29890cbd9
|
https://github.com/addiks/phpsql/blob/28dae64ffc2123f39f801a50ab53bfe29890cbd9/src/Addiks/PHPSQL/Value/Database/Dsn.php#L44-L53
|
230,117
|
Webiny/Framework
|
src/Webiny/Component/StdLib/StdObject/UrlObject/UrlObject.php
|
UrlObject.buildUrl
|
static function buildUrl($parts)
{
$parts = new ArrayObject($parts);
###################
### PARSE PARTS ###
###################
// scheme
$scheme = $parts->key('scheme', '', true);
// host
$host = $parts->key('host', '', true);
// port
$port = $parts->key('port', '', true);
// path
$path = $parts->key('path', '', true);
// parse query string
$query = '';
if($parts->keyExists('query')) {
if(self::isString($parts->key('query'))) {
parse_str($parts->key('query'), $queryData);
} else {
$queryData = $parts->key('query');
}
if(self::isArray($queryData)) {
$query = $queryData;
}
}
###################
### BUILD URL ###
###################
$url = '';
// scheme
if($scheme && $scheme != '') {
$url .= $scheme . '://';
}
// host
if($host && $host != '') {
$url .= $host;
}
// port
if($port != '') {
$url .= ':' . $port;
}
// path
if($path != '') {
$url .= $path;
}
// query
if(self::isArray($query)) {
$query = http_build_query($query);
if($query != "") {
$url .= '?' . $query;
}
}
try {
return new UrlObject($url);
} catch (\Exception $e) {
throw new UrlObjectException($e->getMessage());
}
}
|
php
|
static function buildUrl($parts)
{
$parts = new ArrayObject($parts);
###################
### PARSE PARTS ###
###################
// scheme
$scheme = $parts->key('scheme', '', true);
// host
$host = $parts->key('host', '', true);
// port
$port = $parts->key('port', '', true);
// path
$path = $parts->key('path', '', true);
// parse query string
$query = '';
if($parts->keyExists('query')) {
if(self::isString($parts->key('query'))) {
parse_str($parts->key('query'), $queryData);
} else {
$queryData = $parts->key('query');
}
if(self::isArray($queryData)) {
$query = $queryData;
}
}
###################
### BUILD URL ###
###################
$url = '';
// scheme
if($scheme && $scheme != '') {
$url .= $scheme . '://';
}
// host
if($host && $host != '') {
$url .= $host;
}
// port
if($port != '') {
$url .= ':' . $port;
}
// path
if($path != '') {
$url .= $path;
}
// query
if(self::isArray($query)) {
$query = http_build_query($query);
if($query != "") {
$url .= '?' . $query;
}
}
try {
return new UrlObject($url);
} catch (\Exception $e) {
throw new UrlObjectException($e->getMessage());
}
}
|
[
"static",
"function",
"buildUrl",
"(",
"$",
"parts",
")",
"{",
"$",
"parts",
"=",
"new",
"ArrayObject",
"(",
"$",
"parts",
")",
";",
"###################",
"### PARSE PARTS ###",
"###################",
"// scheme",
"$",
"scheme",
"=",
"$",
"parts",
"->",
"key",
"(",
"'scheme'",
",",
"''",
",",
"true",
")",
";",
"// host",
"$",
"host",
"=",
"$",
"parts",
"->",
"key",
"(",
"'host'",
",",
"''",
",",
"true",
")",
";",
"// port",
"$",
"port",
"=",
"$",
"parts",
"->",
"key",
"(",
"'port'",
",",
"''",
",",
"true",
")",
";",
"// path",
"$",
"path",
"=",
"$",
"parts",
"->",
"key",
"(",
"'path'",
",",
"''",
",",
"true",
")",
";",
"// parse query string",
"$",
"query",
"=",
"''",
";",
"if",
"(",
"$",
"parts",
"->",
"keyExists",
"(",
"'query'",
")",
")",
"{",
"if",
"(",
"self",
"::",
"isString",
"(",
"$",
"parts",
"->",
"key",
"(",
"'query'",
")",
")",
")",
"{",
"parse_str",
"(",
"$",
"parts",
"->",
"key",
"(",
"'query'",
")",
",",
"$",
"queryData",
")",
";",
"}",
"else",
"{",
"$",
"queryData",
"=",
"$",
"parts",
"->",
"key",
"(",
"'query'",
")",
";",
"}",
"if",
"(",
"self",
"::",
"isArray",
"(",
"$",
"queryData",
")",
")",
"{",
"$",
"query",
"=",
"$",
"queryData",
";",
"}",
"}",
"###################",
"### BUILD URL ###",
"###################",
"$",
"url",
"=",
"''",
";",
"// scheme",
"if",
"(",
"$",
"scheme",
"&&",
"$",
"scheme",
"!=",
"''",
")",
"{",
"$",
"url",
".=",
"$",
"scheme",
".",
"'://'",
";",
"}",
"// host",
"if",
"(",
"$",
"host",
"&&",
"$",
"host",
"!=",
"''",
")",
"{",
"$",
"url",
".=",
"$",
"host",
";",
"}",
"// port",
"if",
"(",
"$",
"port",
"!=",
"''",
")",
"{",
"$",
"url",
".=",
"':'",
".",
"$",
"port",
";",
"}",
"// path",
"if",
"(",
"$",
"path",
"!=",
"''",
")",
"{",
"$",
"url",
".=",
"$",
"path",
";",
"}",
"// query",
"if",
"(",
"self",
"::",
"isArray",
"(",
"$",
"query",
")",
")",
"{",
"$",
"query",
"=",
"http_build_query",
"(",
"$",
"query",
")",
";",
"if",
"(",
"$",
"query",
"!=",
"\"\"",
")",
"{",
"$",
"url",
".=",
"'?'",
".",
"$",
"query",
";",
"}",
"}",
"try",
"{",
"return",
"new",
"UrlObject",
"(",
"$",
"url",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"UrlObjectException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Build a UrlObject from array parts.
@param ArrayObject|array $parts Url parts, possible keys are: 'scheme', 'host', 'port', 'path' and 'query'
@throws UrlObjectException
@return UrlObject
|
[
"Build",
"a",
"UrlObject",
"from",
"array",
"parts",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/StdLib/StdObject/UrlObject/UrlObject.php#L70-L143
|
230,118
|
Webiny/Framework
|
src/Webiny/Component/StdLib/StdObject/UrlObject/UrlObject.php
|
UrlObject.rebuildUrl
|
private function rebuildUrl()
{
$url = self::buildUrl([
'scheme' => $this->scheme,
'host' => $this->host,
'port' => $this->port,
'path' => $this->path,
'query' => $this->query
]
);
$this->val($url->val());
return $this;
}
|
php
|
private function rebuildUrl()
{
$url = self::buildUrl([
'scheme' => $this->scheme,
'host' => $this->host,
'port' => $this->port,
'path' => $this->path,
'query' => $this->query
]
);
$this->val($url->val());
return $this;
}
|
[
"private",
"function",
"rebuildUrl",
"(",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"buildUrl",
"(",
"[",
"'scheme'",
"=>",
"$",
"this",
"->",
"scheme",
",",
"'host'",
"=>",
"$",
"this",
"->",
"host",
",",
"'port'",
"=>",
"$",
"this",
"->",
"port",
",",
"'path'",
"=>",
"$",
"this",
"->",
"path",
",",
"'query'",
"=>",
"$",
"this",
"->",
"query",
"]",
")",
";",
"$",
"this",
"->",
"val",
"(",
"$",
"url",
"->",
"val",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Builds url from current url elements.
@return $this
|
[
"Builds",
"url",
"from",
"current",
"url",
"elements",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/StdLib/StdObject/UrlObject/UrlObject.php#L150-L162
|
230,119
|
Webiny/Framework
|
src/Webiny/Component/StdLib/StdObject/UrlObject/UrlObject.php
|
UrlObject.getDomain
|
public function getDomain()
{
if($this->getScheme() && $this->getHost()) {
return $this->getScheme() . '://' . $this->getHost();
}
return false;
}
|
php
|
public function getDomain()
{
if($this->getScheme() && $this->getHost()) {
return $this->getScheme() . '://' . $this->getHost();
}
return false;
}
|
[
"public",
"function",
"getDomain",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getScheme",
"(",
")",
"&&",
"$",
"this",
"->",
"getHost",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getScheme",
"(",
")",
".",
"'://'",
".",
"$",
"this",
"->",
"getHost",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Get the domain name of the current url.
@return string|bool Domain name, or false it's not set.
|
[
"Get",
"the",
"domain",
"name",
"of",
"the",
"current",
"url",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/StdLib/StdObject/UrlObject/UrlObject.php#L209-L216
|
230,120
|
Webiny/Framework
|
src/Webiny/Component/StdLib/StdObject/UrlObject/UrlObject.php
|
UrlObject.getPath
|
public function getPath($asStringObject = false)
{
if($asStringObject) {
return $this->str($this->path);
}
return $this->path;
}
|
php
|
public function getPath($asStringObject = false)
{
if($asStringObject) {
return $this->str($this->path);
}
return $this->path;
}
|
[
"public",
"function",
"getPath",
"(",
"$",
"asStringObject",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"asStringObject",
")",
"{",
"return",
"$",
"this",
"->",
"str",
"(",
"$",
"this",
"->",
"path",
")",
";",
"}",
"return",
"$",
"this",
"->",
"path",
";",
"}"
] |
Get the path from the current url.
@param bool $asStringObject Return instance of StringObject
@return string|StringObject Path from the current instance.
|
[
"Get",
"the",
"path",
"from",
"the",
"current",
"url",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/StdLib/StdObject/UrlObject/UrlObject.php#L225-L232
|
230,121
|
Webiny/Framework
|
src/Webiny/Component/StdLib/StdObject/UrlObject/UrlObject.php
|
UrlObject.validateUrl
|
private function validateUrl()
{
$urlData = parse_url($this->val());
if(!$urlData || !$this->isArray($urlData)) {
throw new UrlObjectException(UrlObjectException::MSG_INVALID_URL, [$this->val()]);
}
// extract parts
$urlData = $this->arr($urlData);
// scheme
$this->scheme = $urlData->key('scheme', '', true);
// host
$this->host = $urlData->key('host', '', true);
// port
$this->port = $urlData->key('port', '', true);
// path
$this->path = $urlData->key('path', '', true);
// parse query string
if($urlData->keyExists('query')) {
parse_str($urlData->key('query'), $queryData);
if($this->isArray($queryData)) {
$this->query = $queryData;
}
}
}
|
php
|
private function validateUrl()
{
$urlData = parse_url($this->val());
if(!$urlData || !$this->isArray($urlData)) {
throw new UrlObjectException(UrlObjectException::MSG_INVALID_URL, [$this->val()]);
}
// extract parts
$urlData = $this->arr($urlData);
// scheme
$this->scheme = $urlData->key('scheme', '', true);
// host
$this->host = $urlData->key('host', '', true);
// port
$this->port = $urlData->key('port', '', true);
// path
$this->path = $urlData->key('path', '', true);
// parse query string
if($urlData->keyExists('query')) {
parse_str($urlData->key('query'), $queryData);
if($this->isArray($queryData)) {
$this->query = $queryData;
}
}
}
|
[
"private",
"function",
"validateUrl",
"(",
")",
"{",
"$",
"urlData",
"=",
"parse_url",
"(",
"$",
"this",
"->",
"val",
"(",
")",
")",
";",
"if",
"(",
"!",
"$",
"urlData",
"||",
"!",
"$",
"this",
"->",
"isArray",
"(",
"$",
"urlData",
")",
")",
"{",
"throw",
"new",
"UrlObjectException",
"(",
"UrlObjectException",
"::",
"MSG_INVALID_URL",
",",
"[",
"$",
"this",
"->",
"val",
"(",
")",
"]",
")",
";",
"}",
"// extract parts",
"$",
"urlData",
"=",
"$",
"this",
"->",
"arr",
"(",
"$",
"urlData",
")",
";",
"// scheme",
"$",
"this",
"->",
"scheme",
"=",
"$",
"urlData",
"->",
"key",
"(",
"'scheme'",
",",
"''",
",",
"true",
")",
";",
"// host",
"$",
"this",
"->",
"host",
"=",
"$",
"urlData",
"->",
"key",
"(",
"'host'",
",",
"''",
",",
"true",
")",
";",
"// port",
"$",
"this",
"->",
"port",
"=",
"$",
"urlData",
"->",
"key",
"(",
"'port'",
",",
"''",
",",
"true",
")",
";",
"// path",
"$",
"this",
"->",
"path",
"=",
"$",
"urlData",
"->",
"key",
"(",
"'path'",
",",
"''",
",",
"true",
")",
";",
"// parse query string",
"if",
"(",
"$",
"urlData",
"->",
"keyExists",
"(",
"'query'",
")",
")",
"{",
"parse_str",
"(",
"$",
"urlData",
"->",
"key",
"(",
"'query'",
")",
",",
"$",
"queryData",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isArray",
"(",
"$",
"queryData",
")",
")",
"{",
"$",
"this",
"->",
"query",
"=",
"$",
"queryData",
";",
"}",
"}",
"}"
] |
Validates current url and parses data like scheme, host, query, and similar from, it.
@throws UrlObjectException
|
[
"Validates",
"current",
"url",
"and",
"parses",
"data",
"like",
"scheme",
"host",
"query",
"and",
"similar",
"from",
"it",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/StdLib/StdObject/UrlObject/UrlObject.php#L268-L295
|
230,122
|
Webiny/Framework
|
src/Webiny/Component/StdLib/StdObject/UrlObject/UrlObject.php
|
UrlObject.getHeaderResponseString
|
private function getHeaderResponseString($headerCode)
{
switch ($headerCode) {
case 100:
$text = 'Continue';
break;
case 101:
$text = 'Switching Protocols';
break;
case 200:
$text = 'OK';
break;
case 201:
$text = 'Created';
break;
case 202:
$text = 'Accepted';
break;
case 203:
$text = 'Non-Authoritative Information';
break;
case 204:
$text = 'No Content';
break;
case 205:
$text = 'Reset Content';
break;
case 206:
$text = 'Partial Content';
break;
case 300:
$text = 'Multiple Choices';
break;
case 301:
$text = 'Moved Permanently';
break;
case 302:
$text = 'Moved Temporarily';
break;
case 303:
$text = 'See Other';
break;
case 304:
$text = 'Not Modified';
break;
case 305:
$text = 'Use Proxy';
break;
case 400:
$text = 'Bad Request';
break;
case 401:
$text = 'Unauthorized';
break;
case 402:
$text = 'Payment Required';
break;
case 403:
$text = 'Forbidden';
break;
case 404:
$text = 'Not Found';
break;
case 405:
$text = 'Method Not Allowed';
break;
case 406:
$text = 'Not Acceptable';
break;
case 407:
$text = 'Proxy Authentication Required';
break;
case 408:
$text = 'Request Time-out';
break;
case 409:
$text = 'Conflict';
break;
case 410:
$text = 'Gone';
break;
case 411:
$text = 'Length Required';
break;
case 412:
$text = 'Precondition Failed';
break;
case 413:
$text = 'Request Entity Too Large';
break;
case 414:
$text = 'Request-URI Too Large';
break;
case 415:
$text = 'Unsupported Media Type';
break;
case 500:
$text = 'Internal Server Error';
break;
case 501:
$text = 'Not Implemented';
break;
case 502:
$text = 'Bad Gateway';
break;
case 503:
$text = 'Service Unavailable';
break;
case 504:
$text = 'Gateway Time-out';
break;
case 505:
$text = 'HTTP Version not supported';
break;
default:
throw new UrlObjectException(UrlObjectException::MSG_ARG_OUT_OF_RANGE, [$headerCode]);
break;
}
return $text;
}
|
php
|
private function getHeaderResponseString($headerCode)
{
switch ($headerCode) {
case 100:
$text = 'Continue';
break;
case 101:
$text = 'Switching Protocols';
break;
case 200:
$text = 'OK';
break;
case 201:
$text = 'Created';
break;
case 202:
$text = 'Accepted';
break;
case 203:
$text = 'Non-Authoritative Information';
break;
case 204:
$text = 'No Content';
break;
case 205:
$text = 'Reset Content';
break;
case 206:
$text = 'Partial Content';
break;
case 300:
$text = 'Multiple Choices';
break;
case 301:
$text = 'Moved Permanently';
break;
case 302:
$text = 'Moved Temporarily';
break;
case 303:
$text = 'See Other';
break;
case 304:
$text = 'Not Modified';
break;
case 305:
$text = 'Use Proxy';
break;
case 400:
$text = 'Bad Request';
break;
case 401:
$text = 'Unauthorized';
break;
case 402:
$text = 'Payment Required';
break;
case 403:
$text = 'Forbidden';
break;
case 404:
$text = 'Not Found';
break;
case 405:
$text = 'Method Not Allowed';
break;
case 406:
$text = 'Not Acceptable';
break;
case 407:
$text = 'Proxy Authentication Required';
break;
case 408:
$text = 'Request Time-out';
break;
case 409:
$text = 'Conflict';
break;
case 410:
$text = 'Gone';
break;
case 411:
$text = 'Length Required';
break;
case 412:
$text = 'Precondition Failed';
break;
case 413:
$text = 'Request Entity Too Large';
break;
case 414:
$text = 'Request-URI Too Large';
break;
case 415:
$text = 'Unsupported Media Type';
break;
case 500:
$text = 'Internal Server Error';
break;
case 501:
$text = 'Not Implemented';
break;
case 502:
$text = 'Bad Gateway';
break;
case 503:
$text = 'Service Unavailable';
break;
case 504:
$text = 'Gateway Time-out';
break;
case 505:
$text = 'HTTP Version not supported';
break;
default:
throw new UrlObjectException(UrlObjectException::MSG_ARG_OUT_OF_RANGE, [$headerCode]);
break;
}
return $text;
}
|
[
"private",
"function",
"getHeaderResponseString",
"(",
"$",
"headerCode",
")",
"{",
"switch",
"(",
"$",
"headerCode",
")",
"{",
"case",
"100",
":",
"$",
"text",
"=",
"'Continue'",
";",
"break",
";",
"case",
"101",
":",
"$",
"text",
"=",
"'Switching Protocols'",
";",
"break",
";",
"case",
"200",
":",
"$",
"text",
"=",
"'OK'",
";",
"break",
";",
"case",
"201",
":",
"$",
"text",
"=",
"'Created'",
";",
"break",
";",
"case",
"202",
":",
"$",
"text",
"=",
"'Accepted'",
";",
"break",
";",
"case",
"203",
":",
"$",
"text",
"=",
"'Non-Authoritative Information'",
";",
"break",
";",
"case",
"204",
":",
"$",
"text",
"=",
"'No Content'",
";",
"break",
";",
"case",
"205",
":",
"$",
"text",
"=",
"'Reset Content'",
";",
"break",
";",
"case",
"206",
":",
"$",
"text",
"=",
"'Partial Content'",
";",
"break",
";",
"case",
"300",
":",
"$",
"text",
"=",
"'Multiple Choices'",
";",
"break",
";",
"case",
"301",
":",
"$",
"text",
"=",
"'Moved Permanently'",
";",
"break",
";",
"case",
"302",
":",
"$",
"text",
"=",
"'Moved Temporarily'",
";",
"break",
";",
"case",
"303",
":",
"$",
"text",
"=",
"'See Other'",
";",
"break",
";",
"case",
"304",
":",
"$",
"text",
"=",
"'Not Modified'",
";",
"break",
";",
"case",
"305",
":",
"$",
"text",
"=",
"'Use Proxy'",
";",
"break",
";",
"case",
"400",
":",
"$",
"text",
"=",
"'Bad Request'",
";",
"break",
";",
"case",
"401",
":",
"$",
"text",
"=",
"'Unauthorized'",
";",
"break",
";",
"case",
"402",
":",
"$",
"text",
"=",
"'Payment Required'",
";",
"break",
";",
"case",
"403",
":",
"$",
"text",
"=",
"'Forbidden'",
";",
"break",
";",
"case",
"404",
":",
"$",
"text",
"=",
"'Not Found'",
";",
"break",
";",
"case",
"405",
":",
"$",
"text",
"=",
"'Method Not Allowed'",
";",
"break",
";",
"case",
"406",
":",
"$",
"text",
"=",
"'Not Acceptable'",
";",
"break",
";",
"case",
"407",
":",
"$",
"text",
"=",
"'Proxy Authentication Required'",
";",
"break",
";",
"case",
"408",
":",
"$",
"text",
"=",
"'Request Time-out'",
";",
"break",
";",
"case",
"409",
":",
"$",
"text",
"=",
"'Conflict'",
";",
"break",
";",
"case",
"410",
":",
"$",
"text",
"=",
"'Gone'",
";",
"break",
";",
"case",
"411",
":",
"$",
"text",
"=",
"'Length Required'",
";",
"break",
";",
"case",
"412",
":",
"$",
"text",
"=",
"'Precondition Failed'",
";",
"break",
";",
"case",
"413",
":",
"$",
"text",
"=",
"'Request Entity Too Large'",
";",
"break",
";",
"case",
"414",
":",
"$",
"text",
"=",
"'Request-URI Too Large'",
";",
"break",
";",
"case",
"415",
":",
"$",
"text",
"=",
"'Unsupported Media Type'",
";",
"break",
";",
"case",
"500",
":",
"$",
"text",
"=",
"'Internal Server Error'",
";",
"break",
";",
"case",
"501",
":",
"$",
"text",
"=",
"'Not Implemented'",
";",
"break",
";",
"case",
"502",
":",
"$",
"text",
"=",
"'Bad Gateway'",
";",
"break",
";",
"case",
"503",
":",
"$",
"text",
"=",
"'Service Unavailable'",
";",
"break",
";",
"case",
"504",
":",
"$",
"text",
"=",
"'Gateway Time-out'",
";",
"break",
";",
"case",
"505",
":",
"$",
"text",
"=",
"'HTTP Version not supported'",
";",
"break",
";",
"default",
":",
"throw",
"new",
"UrlObjectException",
"(",
"UrlObjectException",
"::",
"MSG_ARG_OUT_OF_RANGE",
",",
"[",
"$",
"headerCode",
"]",
")",
";",
"break",
";",
"}",
"return",
"$",
"text",
";",
"}"
] |
Get a string for the given header response code.
@param integer $headerCode Header code.
@return string
@throws UrlObjectException
|
[
"Get",
"a",
"string",
"for",
"the",
"given",
"header",
"response",
"code",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/StdLib/StdObject/UrlObject/UrlObject.php#L305-L425
|
230,123
|
milesj/admin
|
Lib/Admin.php
|
Admin.cache
|
public static function cache($key, Closure $callback) {
if (is_array($key)) {
$key = implode('-', $key);
}
if (isset(self::$_cache[$key])) {
return self::$_cache[$key];
}
self::$_cache[$key] = $callback();
return self::$_cache[$key];
}
|
php
|
public static function cache($key, Closure $callback) {
if (is_array($key)) {
$key = implode('-', $key);
}
if (isset(self::$_cache[$key])) {
return self::$_cache[$key];
}
self::$_cache[$key] = $callback();
return self::$_cache[$key];
}
|
[
"public",
"static",
"function",
"cache",
"(",
"$",
"key",
",",
"Closure",
"$",
"callback",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"key",
")",
")",
"{",
"$",
"key",
"=",
"implode",
"(",
"'-'",
",",
"$",
"key",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"_cache",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"self",
"::",
"$",
"_cache",
"[",
"$",
"key",
"]",
";",
"}",
"self",
"::",
"$",
"_cache",
"[",
"$",
"key",
"]",
"=",
"$",
"callback",
"(",
")",
";",
"return",
"self",
"::",
"$",
"_cache",
"[",
"$",
"key",
"]",
";",
"}"
] |
Cache the result of the callback into the class.
@param string|array $key
@param callable $callback
@return mixed
|
[
"Cache",
"the",
"result",
"of",
"the",
"callback",
"into",
"the",
"class",
"."
] |
e5e93823d1eb4415f05a3191f653eb50c296d2c6
|
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/Lib/Admin.php#L24-L36
|
230,124
|
milesj/admin
|
Lib/Admin.php
|
Admin.getModels
|
public static function getModels() {
return self::cache(__METHOD__, function() {
$plugins = array_merge(array(Configure::read('Admin.coreName')), App::objects('plugins'));
$map = array();
foreach ($plugins as $plugin) {
$data = Admin::getPlugin($plugin);
if ($data['models']) {
$map[$plugin] = $data;
}
}
ksort($map);
return $map;
});
}
|
php
|
public static function getModels() {
return self::cache(__METHOD__, function() {
$plugins = array_merge(array(Configure::read('Admin.coreName')), App::objects('plugins'));
$map = array();
foreach ($plugins as $plugin) {
$data = Admin::getPlugin($plugin);
if ($data['models']) {
$map[$plugin] = $data;
}
}
ksort($map);
return $map;
});
}
|
[
"public",
"static",
"function",
"getModels",
"(",
")",
"{",
"return",
"self",
"::",
"cache",
"(",
"__METHOD__",
",",
"function",
"(",
")",
"{",
"$",
"plugins",
"=",
"array_merge",
"(",
"array",
"(",
"Configure",
"::",
"read",
"(",
"'Admin.coreName'",
")",
")",
",",
"App",
"::",
"objects",
"(",
"'plugins'",
")",
")",
";",
"$",
"map",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"$",
"data",
"=",
"Admin",
"::",
"getPlugin",
"(",
"$",
"plugin",
")",
";",
"if",
"(",
"$",
"data",
"[",
"'models'",
"]",
")",
"{",
"$",
"map",
"[",
"$",
"plugin",
"]",
"=",
"$",
"data",
";",
"}",
"}",
"ksort",
"(",
"$",
"map",
")",
";",
"return",
"$",
"map",
";",
"}",
")",
";",
"}"
] |
Return a list of all models grouped by plugin.
@return array
|
[
"Return",
"a",
"list",
"of",
"all",
"models",
"grouped",
"by",
"plugin",
"."
] |
e5e93823d1eb4415f05a3191f653eb50c296d2c6
|
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/Lib/Admin.php#L43-L60
|
230,125
|
milesj/admin
|
Lib/Admin.php
|
Admin.getPlugin
|
public static function getPlugin($plugin) {
return self::cache(array(__METHOD__, $plugin), function() use ($plugin) {
$path = null;
if ($plugin !== Configure::read('Admin.coreName')) {
if (!CakePlugin::loaded($plugin)) {
return null;
}
$path = CakePlugin::path($plugin);
}
return array(
'title' => $plugin,
'path' => $path,
'slug' => Inflector::underscore($plugin),
'models' => Admin::getPluginModels($plugin)
);
});
}
|
php
|
public static function getPlugin($plugin) {
return self::cache(array(__METHOD__, $plugin), function() use ($plugin) {
$path = null;
if ($plugin !== Configure::read('Admin.coreName')) {
if (!CakePlugin::loaded($plugin)) {
return null;
}
$path = CakePlugin::path($plugin);
}
return array(
'title' => $plugin,
'path' => $path,
'slug' => Inflector::underscore($plugin),
'models' => Admin::getPluginModels($plugin)
);
});
}
|
[
"public",
"static",
"function",
"getPlugin",
"(",
"$",
"plugin",
")",
"{",
"return",
"self",
"::",
"cache",
"(",
"array",
"(",
"__METHOD__",
",",
"$",
"plugin",
")",
",",
"function",
"(",
")",
"use",
"(",
"$",
"plugin",
")",
"{",
"$",
"path",
"=",
"null",
";",
"if",
"(",
"$",
"plugin",
"!==",
"Configure",
"::",
"read",
"(",
"'Admin.coreName'",
")",
")",
"{",
"if",
"(",
"!",
"CakePlugin",
"::",
"loaded",
"(",
"$",
"plugin",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"path",
"=",
"CakePlugin",
"::",
"path",
"(",
"$",
"plugin",
")",
";",
"}",
"return",
"array",
"(",
"'title'",
"=>",
"$",
"plugin",
",",
"'path'",
"=>",
"$",
"path",
",",
"'slug'",
"=>",
"Inflector",
"::",
"underscore",
"(",
"$",
"plugin",
")",
",",
"'models'",
"=>",
"Admin",
"::",
"getPluginModels",
"(",
"$",
"plugin",
")",
")",
";",
"}",
")",
";",
"}"
] |
Return meta information on a plugin while also including the model list.
@param string $plugin
@return array
|
[
"Return",
"meta",
"information",
"on",
"a",
"plugin",
"while",
"also",
"including",
"the",
"model",
"list",
"."
] |
e5e93823d1eb4415f05a3191f653eb50c296d2c6
|
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/Lib/Admin.php#L68-L87
|
230,126
|
milesj/admin
|
Lib/Admin.php
|
Admin.getPluginModels
|
public static function getPluginModels($plugin) {
return self::cache(array(__METHOD__, $plugin), function() use ($plugin) {
$search = 'Model';
$core = Configure::read('Admin.coreName') ?: 'Core';
if ($plugin !== $core) {
$search = $plugin . '.' . $search;
}
// Fetch models and filter out AppModel's
$models = array_filter(App::objects($search), function($value) {
return (mb_strpos($value, 'AppModel') === false);
});
// Filter out models that don't connect to the database or are admin disabled
$map = array();
$ignore = Configure::read('Admin.ignoreModels');
foreach ($models as $model) {
list($plugin, $model, $id, $class) = Admin::parseName($plugin . '.' . $model);
if (in_array($id, $ignore)) {
continue;
}
$object = Admin::introspectModel($id);
if (!$object) {
continue;
}
$map[] = array_merge($object->admin, array(
'id' => $id,
'title' => $object->pluralName,
'alias' => $model,
'class' => $class,
'url' => Inflector::underscore($id),
'installed' => Admin::isModelInstalled($id),
'group' => $object->useDbConfig
));
}
return $map;
});
}
|
php
|
public static function getPluginModels($plugin) {
return self::cache(array(__METHOD__, $plugin), function() use ($plugin) {
$search = 'Model';
$core = Configure::read('Admin.coreName') ?: 'Core';
if ($plugin !== $core) {
$search = $plugin . '.' . $search;
}
// Fetch models and filter out AppModel's
$models = array_filter(App::objects($search), function($value) {
return (mb_strpos($value, 'AppModel') === false);
});
// Filter out models that don't connect to the database or are admin disabled
$map = array();
$ignore = Configure::read('Admin.ignoreModels');
foreach ($models as $model) {
list($plugin, $model, $id, $class) = Admin::parseName($plugin . '.' . $model);
if (in_array($id, $ignore)) {
continue;
}
$object = Admin::introspectModel($id);
if (!$object) {
continue;
}
$map[] = array_merge($object->admin, array(
'id' => $id,
'title' => $object->pluralName,
'alias' => $model,
'class' => $class,
'url' => Inflector::underscore($id),
'installed' => Admin::isModelInstalled($id),
'group' => $object->useDbConfig
));
}
return $map;
});
}
|
[
"public",
"static",
"function",
"getPluginModels",
"(",
"$",
"plugin",
")",
"{",
"return",
"self",
"::",
"cache",
"(",
"array",
"(",
"__METHOD__",
",",
"$",
"plugin",
")",
",",
"function",
"(",
")",
"use",
"(",
"$",
"plugin",
")",
"{",
"$",
"search",
"=",
"'Model'",
";",
"$",
"core",
"=",
"Configure",
"::",
"read",
"(",
"'Admin.coreName'",
")",
"?",
":",
"'Core'",
";",
"if",
"(",
"$",
"plugin",
"!==",
"$",
"core",
")",
"{",
"$",
"search",
"=",
"$",
"plugin",
".",
"'.'",
".",
"$",
"search",
";",
"}",
"// Fetch models and filter out AppModel's",
"$",
"models",
"=",
"array_filter",
"(",
"App",
"::",
"objects",
"(",
"$",
"search",
")",
",",
"function",
"(",
"$",
"value",
")",
"{",
"return",
"(",
"mb_strpos",
"(",
"$",
"value",
",",
"'AppModel'",
")",
"===",
"false",
")",
";",
"}",
")",
";",
"// Filter out models that don't connect to the database or are admin disabled",
"$",
"map",
"=",
"array",
"(",
")",
";",
"$",
"ignore",
"=",
"Configure",
"::",
"read",
"(",
"'Admin.ignoreModels'",
")",
";",
"foreach",
"(",
"$",
"models",
"as",
"$",
"model",
")",
"{",
"list",
"(",
"$",
"plugin",
",",
"$",
"model",
",",
"$",
"id",
",",
"$",
"class",
")",
"=",
"Admin",
"::",
"parseName",
"(",
"$",
"plugin",
".",
"'.'",
".",
"$",
"model",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"id",
",",
"$",
"ignore",
")",
")",
"{",
"continue",
";",
"}",
"$",
"object",
"=",
"Admin",
"::",
"introspectModel",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"object",
")",
"{",
"continue",
";",
"}",
"$",
"map",
"[",
"]",
"=",
"array_merge",
"(",
"$",
"object",
"->",
"admin",
",",
"array",
"(",
"'id'",
"=>",
"$",
"id",
",",
"'title'",
"=>",
"$",
"object",
"->",
"pluralName",
",",
"'alias'",
"=>",
"$",
"model",
",",
"'class'",
"=>",
"$",
"class",
",",
"'url'",
"=>",
"Inflector",
"::",
"underscore",
"(",
"$",
"id",
")",
",",
"'installed'",
"=>",
"Admin",
"::",
"isModelInstalled",
"(",
"$",
"id",
")",
",",
"'group'",
"=>",
"$",
"object",
"->",
"useDbConfig",
")",
")",
";",
"}",
"return",
"$",
"map",
";",
"}",
")",
";",
"}"
] |
Return a list of all models within a plugin.
@param string $plugin
@return array
|
[
"Return",
"a",
"list",
"of",
"all",
"models",
"within",
"a",
"plugin",
"."
] |
e5e93823d1eb4415f05a3191f653eb50c296d2c6
|
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/Lib/Admin.php#L95-L139
|
230,127
|
milesj/admin
|
Lib/Admin.php
|
Admin.parseName
|
public static function parseName($model) {
return self::cache(array(__METHOD__, $model), function() use ($model) {
list($plugin, $model) = pluginSplit($model);
$core = Configure::read('Admin.coreName');
if (!$plugin) {
$plugin = $core;
}
$plugin = Inflector::camelize($plugin);
$model = Inflector::camelize($model);
$class = $model;
if ($plugin !== $core) {
$class = $plugin . '.' . $class;
}
return array(
$plugin, // plugin name, includes Core
$model, // model class name
$plugin . '.' . $model, // plugin and model, includes Core
$class // plugin and model, excludes Core
);
});
}
|
php
|
public static function parseName($model) {
return self::cache(array(__METHOD__, $model), function() use ($model) {
list($plugin, $model) = pluginSplit($model);
$core = Configure::read('Admin.coreName');
if (!$plugin) {
$plugin = $core;
}
$plugin = Inflector::camelize($plugin);
$model = Inflector::camelize($model);
$class = $model;
if ($plugin !== $core) {
$class = $plugin . '.' . $class;
}
return array(
$plugin, // plugin name, includes Core
$model, // model class name
$plugin . '.' . $model, // plugin and model, includes Core
$class // plugin and model, excludes Core
);
});
}
|
[
"public",
"static",
"function",
"parseName",
"(",
"$",
"model",
")",
"{",
"return",
"self",
"::",
"cache",
"(",
"array",
"(",
"__METHOD__",
",",
"$",
"model",
")",
",",
"function",
"(",
")",
"use",
"(",
"$",
"model",
")",
"{",
"list",
"(",
"$",
"plugin",
",",
"$",
"model",
")",
"=",
"pluginSplit",
"(",
"$",
"model",
")",
";",
"$",
"core",
"=",
"Configure",
"::",
"read",
"(",
"'Admin.coreName'",
")",
";",
"if",
"(",
"!",
"$",
"plugin",
")",
"{",
"$",
"plugin",
"=",
"$",
"core",
";",
"}",
"$",
"plugin",
"=",
"Inflector",
"::",
"camelize",
"(",
"$",
"plugin",
")",
";",
"$",
"model",
"=",
"Inflector",
"::",
"camelize",
"(",
"$",
"model",
")",
";",
"$",
"class",
"=",
"$",
"model",
";",
"if",
"(",
"$",
"plugin",
"!==",
"$",
"core",
")",
"{",
"$",
"class",
"=",
"$",
"plugin",
".",
"'.'",
".",
"$",
"class",
";",
"}",
"return",
"array",
"(",
"$",
"plugin",
",",
"// plugin name, includes Core",
"$",
"model",
",",
"// model class name",
"$",
"plugin",
".",
"'.'",
".",
"$",
"model",
",",
"// plugin and model, includes Core",
"$",
"class",
"// plugin and model, excludes Core",
")",
";",
"}",
")",
";",
"}"
] |
Parse a model name to extract the plugin and fully qualified name.
@param string $model
@return array
|
[
"Parse",
"a",
"model",
"name",
"to",
"extract",
"the",
"plugin",
"and",
"fully",
"qualified",
"name",
"."
] |
e5e93823d1eb4415f05a3191f653eb50c296d2c6
|
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/Lib/Admin.php#L194-L218
|
230,128
|
Webiny/Framework
|
src/Webiny/Component/Router/Route/Route.php
|
Route.setPath
|
public function setPath($path)
{
$this->path = '';
$this->realPath = $path;
if(!empty($path)) {
$this->path .= $this->str($path)->trim()->trimLeft('/')->trimRight('/')->val();
}
return $this;
}
|
php
|
public function setPath($path)
{
$this->path = '';
$this->realPath = $path;
if(!empty($path)) {
$this->path .= $this->str($path)->trim()->trimLeft('/')->trimRight('/')->val();
}
return $this;
}
|
[
"public",
"function",
"setPath",
"(",
"$",
"path",
")",
"{",
"$",
"this",
"->",
"path",
"=",
"''",
";",
"$",
"this",
"->",
"realPath",
"=",
"$",
"path",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"path",
")",
")",
"{",
"$",
"this",
"->",
"path",
".=",
"$",
"this",
"->",
"str",
"(",
"$",
"path",
")",
"->",
"trim",
"(",
")",
"->",
"trimLeft",
"(",
"'/'",
")",
"->",
"trimRight",
"(",
"'/'",
")",
"->",
"val",
"(",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets the route path.
@param string $path Route path.
@return $this
|
[
"Sets",
"the",
"route",
"path",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Router/Route/Route.php#L96-L106
|
230,129
|
Webiny/Framework
|
src/Webiny/Component/Router/Route/Route.php
|
Route.setOptions
|
public function setOptions(array $options)
{
$this->options = [];
foreach ($options as $k => $v) {
$this->addOption($k, (array)$v);
}
return $this;
}
|
php
|
public function setOptions(array $options)
{
$this->options = [];
foreach ($options as $k => $v) {
$this->addOption($k, (array)$v);
}
return $this;
}
|
[
"public",
"function",
"setOptions",
"(",
"array",
"$",
"options",
")",
"{",
"$",
"this",
"->",
"options",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"addOption",
"(",
"$",
"k",
",",
"(",
"array",
")",
"$",
"v",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set route options.
@param array $options An array of options. Each option must have a name and a list of attributes and their values.
Common attributes are 'prefix' and 'default'.
@return $this
|
[
"Set",
"route",
"options",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Router/Route/Route.php#L161-L170
|
230,130
|
Webiny/Framework
|
src/Webiny/Component/Router/Route/Route.php
|
Route.addOption
|
public function addOption($name, array $attributes)
{
$this->options[$name] = new RouteOption($name, $attributes);
return $this;
}
|
php
|
public function addOption($name, array $attributes)
{
$this->options[$name] = new RouteOption($name, $attributes);
return $this;
}
|
[
"public",
"function",
"addOption",
"(",
"$",
"name",
",",
"array",
"$",
"attributes",
")",
"{",
"$",
"this",
"->",
"options",
"[",
"$",
"name",
"]",
"=",
"new",
"RouteOption",
"(",
"$",
"name",
",",
"$",
"attributes",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds a single route option.
@param string $name Name of the parameter to which the option should be attached.
@param array $attributes An array of options.
@return $this
|
[
"Adds",
"a",
"single",
"route",
"option",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Router/Route/Route.php#L180-L185
|
230,131
|
Webiny/Framework
|
src/Webiny/Component/Router/Route/Route.php
|
Route.compile
|
public function compile()
{
if($this->isNull($this->compiledRoute)) {
$this->compiledRoute = RouteCompiler::compile($this);
}
return $this->compiledRoute;
}
|
php
|
public function compile()
{
if($this->isNull($this->compiledRoute)) {
$this->compiledRoute = RouteCompiler::compile($this);
}
return $this->compiledRoute;
}
|
[
"public",
"function",
"compile",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNull",
"(",
"$",
"this",
"->",
"compiledRoute",
")",
")",
"{",
"$",
"this",
"->",
"compiledRoute",
"=",
"RouteCompiler",
"::",
"compile",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
"->",
"compiledRoute",
";",
"}"
] |
Compiles the route object and returns an instance of CompiledRoute.
@return CompiledRoute
|
[
"Compiles",
"the",
"route",
"object",
"and",
"returns",
"an",
"instance",
"of",
"CompiledRoute",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Router/Route/Route.php#L313-L320
|
230,132
|
themsaid/katana-core
|
src/Katana.php
|
Katana.registerCommands
|
protected function registerCommands()
{
$this->application->addCommands([
new BuildCommand($this->viewFactory, $this->filesystem),
new PostCommand($this->viewFactory, $this->filesystem)
]);
}
|
php
|
protected function registerCommands()
{
$this->application->addCommands([
new BuildCommand($this->viewFactory, $this->filesystem),
new PostCommand($this->viewFactory, $this->filesystem)
]);
}
|
[
"protected",
"function",
"registerCommands",
"(",
")",
"{",
"$",
"this",
"->",
"application",
"->",
"addCommands",
"(",
"[",
"new",
"BuildCommand",
"(",
"$",
"this",
"->",
"viewFactory",
",",
"$",
"this",
"->",
"filesystem",
")",
",",
"new",
"PostCommand",
"(",
"$",
"this",
"->",
"viewFactory",
",",
"$",
"this",
"->",
"filesystem",
")",
"]",
")",
";",
"}"
] |
Register application commands.
@return void
|
[
"Register",
"application",
"commands",
"."
] |
897c1adb6863d5145f1f104cbc8c9200cd98c3fb
|
https://github.com/themsaid/katana-core/blob/897c1adb6863d5145f1f104cbc8c9200cd98c3fb/src/Katana.php#L72-L78
|
230,133
|
themsaid/katana-core
|
src/Katana.php
|
Katana.createViewFactory
|
protected function createViewFactory()
{
$resolver = new EngineResolver();
$bladeCompiler = $this->createBladeCompiler();
$resolver->register('blade', function () use ($bladeCompiler) {
return new CompilerEngine($bladeCompiler);
});
$dispatcher = new Dispatcher();
$dispatcher->listen('creating: *', function () {
/**
* On rendering Blade views we will mute error reporting as
* we don't care about undefined variables or type
* mistakes during compilation.
*/
error_reporting(error_reporting() & ~E_NOTICE & ~E_WARNING);
});
return new Factory(
$resolver,
new FileViewFinder($this->filesystem, [KATANA_CONTENT_DIR]),
$dispatcher
);
}
|
php
|
protected function createViewFactory()
{
$resolver = new EngineResolver();
$bladeCompiler = $this->createBladeCompiler();
$resolver->register('blade', function () use ($bladeCompiler) {
return new CompilerEngine($bladeCompiler);
});
$dispatcher = new Dispatcher();
$dispatcher->listen('creating: *', function () {
/**
* On rendering Blade views we will mute error reporting as
* we don't care about undefined variables or type
* mistakes during compilation.
*/
error_reporting(error_reporting() & ~E_NOTICE & ~E_WARNING);
});
return new Factory(
$resolver,
new FileViewFinder($this->filesystem, [KATANA_CONTENT_DIR]),
$dispatcher
);
}
|
[
"protected",
"function",
"createViewFactory",
"(",
")",
"{",
"$",
"resolver",
"=",
"new",
"EngineResolver",
"(",
")",
";",
"$",
"bladeCompiler",
"=",
"$",
"this",
"->",
"createBladeCompiler",
"(",
")",
";",
"$",
"resolver",
"->",
"register",
"(",
"'blade'",
",",
"function",
"(",
")",
"use",
"(",
"$",
"bladeCompiler",
")",
"{",
"return",
"new",
"CompilerEngine",
"(",
"$",
"bladeCompiler",
")",
";",
"}",
")",
";",
"$",
"dispatcher",
"=",
"new",
"Dispatcher",
"(",
")",
";",
"$",
"dispatcher",
"->",
"listen",
"(",
"'creating: *'",
",",
"function",
"(",
")",
"{",
"/**\n * On rendering Blade views we will mute error reporting as\n * we don't care about undefined variables or type\n * mistakes during compilation.\n */",
"error_reporting",
"(",
"error_reporting",
"(",
")",
"&",
"~",
"E_NOTICE",
"&",
"~",
"E_WARNING",
")",
";",
"}",
")",
";",
"return",
"new",
"Factory",
"(",
"$",
"resolver",
",",
"new",
"FileViewFinder",
"(",
"$",
"this",
"->",
"filesystem",
",",
"[",
"KATANA_CONTENT_DIR",
"]",
")",
",",
"$",
"dispatcher",
")",
";",
"}"
] |
Create the view factory with a Blade Compiler.
@return Factory
|
[
"Create",
"the",
"view",
"factory",
"with",
"a",
"Blade",
"Compiler",
"."
] |
897c1adb6863d5145f1f104cbc8c9200cd98c3fb
|
https://github.com/themsaid/katana-core/blob/897c1adb6863d5145f1f104cbc8c9200cd98c3fb/src/Katana.php#L85-L111
|
230,134
|
themsaid/katana-core
|
src/Katana.php
|
Katana.createBladeCompiler
|
protected function createBladeCompiler()
{
if (! $this->filesystem->isDirectory(KATANA_CACHE_DIR)) {
$this->filesystem->makeDirectory(KATANA_CACHE_DIR);
}
$blade = new Blade(
new BladeCompiler($this->filesystem, KATANA_CACHE_DIR)
);
return $blade->getCompiler();
}
|
php
|
protected function createBladeCompiler()
{
if (! $this->filesystem->isDirectory(KATANA_CACHE_DIR)) {
$this->filesystem->makeDirectory(KATANA_CACHE_DIR);
}
$blade = new Blade(
new BladeCompiler($this->filesystem, KATANA_CACHE_DIR)
);
return $blade->getCompiler();
}
|
[
"protected",
"function",
"createBladeCompiler",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"filesystem",
"->",
"isDirectory",
"(",
"KATANA_CACHE_DIR",
")",
")",
"{",
"$",
"this",
"->",
"filesystem",
"->",
"makeDirectory",
"(",
"KATANA_CACHE_DIR",
")",
";",
"}",
"$",
"blade",
"=",
"new",
"Blade",
"(",
"new",
"BladeCompiler",
"(",
"$",
"this",
"->",
"filesystem",
",",
"KATANA_CACHE_DIR",
")",
")",
";",
"return",
"$",
"blade",
"->",
"getCompiler",
"(",
")",
";",
"}"
] |
Create the Blade Compiler instance.
@return BladeCompiler
|
[
"Create",
"the",
"Blade",
"Compiler",
"instance",
"."
] |
897c1adb6863d5145f1f104cbc8c9200cd98c3fb
|
https://github.com/themsaid/katana-core/blob/897c1adb6863d5145f1f104cbc8c9200cd98c3fb/src/Katana.php#L118-L129
|
230,135
|
Webiny/Framework
|
src/Webiny/Component/Config/Drivers/AbstractDriver.php
|
AbstractDriver.getString
|
final public function getString()
{
$res = $this->getStringInternal();
if (!$this->isString($res) && !$this->isStringObject($res)) {
throw new ConfigException('AbstractDriver method _getString() must return string or StringObject.');
}
return StdObjectWrapper::toString($res);
}
|
php
|
final public function getString()
{
$res = $this->getStringInternal();
if (!$this->isString($res) && !$this->isStringObject($res)) {
throw new ConfigException('AbstractDriver method _getString() must return string or StringObject.');
}
return StdObjectWrapper::toString($res);
}
|
[
"final",
"public",
"function",
"getString",
"(",
")",
"{",
"$",
"res",
"=",
"$",
"this",
"->",
"getStringInternal",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isString",
"(",
"$",
"res",
")",
"&&",
"!",
"$",
"this",
"->",
"isStringObject",
"(",
"$",
"res",
")",
")",
"{",
"throw",
"new",
"ConfigException",
"(",
"'AbstractDriver method _getString() must return string or StringObject.'",
")",
";",
"}",
"return",
"StdObjectWrapper",
"::",
"toString",
"(",
"$",
"res",
")",
";",
"}"
] |
Get formatted config data as string
@throws ConfigException
@return string Formatted config data
|
[
"Get",
"formatted",
"config",
"data",
"as",
"string"
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Config/Drivers/AbstractDriver.php#L98-L106
|
230,136
|
Webiny/Framework
|
src/Webiny/Component/Config/Drivers/AbstractDriver.php
|
AbstractDriver.getArray
|
final public function getArray()
{
$res = $this->getArrayInternal();
if (!$this->isArray($res) && !$this->isArrayObject($res)) {
$errorMessage = 'AbstractDriver method _getArray() must return array or ArrayObject.';
$errorMessage .= ' Make sure you have provided a valid config file path with file extension.';
throw new ConfigException($errorMessage);
}
return StdObjectWrapper::toArray($res);
}
|
php
|
final public function getArray()
{
$res = $this->getArrayInternal();
if (!$this->isArray($res) && !$this->isArrayObject($res)) {
$errorMessage = 'AbstractDriver method _getArray() must return array or ArrayObject.';
$errorMessage .= ' Make sure you have provided a valid config file path with file extension.';
throw new ConfigException($errorMessage);
}
return StdObjectWrapper::toArray($res);
}
|
[
"final",
"public",
"function",
"getArray",
"(",
")",
"{",
"$",
"res",
"=",
"$",
"this",
"->",
"getArrayInternal",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isArray",
"(",
"$",
"res",
")",
"&&",
"!",
"$",
"this",
"->",
"isArrayObject",
"(",
"$",
"res",
")",
")",
"{",
"$",
"errorMessage",
"=",
"'AbstractDriver method _getArray() must return array or ArrayObject.'",
";",
"$",
"errorMessage",
".=",
"' Make sure you have provided a valid config file path with file extension.'",
";",
"throw",
"new",
"ConfigException",
"(",
"$",
"errorMessage",
")",
";",
"}",
"return",
"StdObjectWrapper",
"::",
"toArray",
"(",
"$",
"res",
")",
";",
"}"
] |
Get config data as array
@throws ConfigException
@return array Parsed resource data array
|
[
"Get",
"config",
"data",
"as",
"array"
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Config/Drivers/AbstractDriver.php#L114-L124
|
230,137
|
Webiny/Framework
|
src/Webiny/Component/Crypt/Bridge/Crypt.php
|
Crypt.getInstance
|
static function getInstance()
{
$driver = static::getLibrary();
try {
$instance = new $driver();
} catch (\Exception $e) {
throw new Exception('Unable to create an instance of ' . $driver);
}
if (!self::isInstanceOf($instance, CryptInterface::class)) {
throw new Exception(Exception::MSG_INVALID_ARG, ['driver', CryptInterface::class]);
}
return $instance;
}
|
php
|
static function getInstance()
{
$driver = static::getLibrary();
try {
$instance = new $driver();
} catch (\Exception $e) {
throw new Exception('Unable to create an instance of ' . $driver);
}
if (!self::isInstanceOf($instance, CryptInterface::class)) {
throw new Exception(Exception::MSG_INVALID_ARG, ['driver', CryptInterface::class]);
}
return $instance;
}
|
[
"static",
"function",
"getInstance",
"(",
")",
"{",
"$",
"driver",
"=",
"static",
"::",
"getLibrary",
"(",
")",
";",
"try",
"{",
"$",
"instance",
"=",
"new",
"$",
"driver",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Unable to create an instance of '",
".",
"$",
"driver",
")",
";",
"}",
"if",
"(",
"!",
"self",
"::",
"isInstanceOf",
"(",
"$",
"instance",
",",
"CryptInterface",
"::",
"class",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"Exception",
"::",
"MSG_INVALID_ARG",
",",
"[",
"'driver'",
",",
"CryptInterface",
"::",
"class",
"]",
")",
";",
"}",
"return",
"$",
"instance",
";",
"}"
] |
Create an instance of a crypt driver.
@throws \Webiny\Component\StdLib\Exception\Exception
@return CryptInterface
|
[
"Create",
"an",
"instance",
"of",
"a",
"crypt",
"driver",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Crypt/Bridge/Crypt.php#L57-L72
|
230,138
|
khepin/KhepinYamlFixturesBundle
|
Fixture/AbstractFixture.php
|
AbstractFixture.hasTag
|
public function hasTag(Array $tags)
{
// if no tags were specified, the fixture should always be loaded
if (count($this->tags) == 0 || count(array_intersect($this->tags, $tags)) > 0) {
return true;
}
return false;
}
|
php
|
public function hasTag(Array $tags)
{
// if no tags were specified, the fixture should always be loaded
if (count($this->tags) == 0 || count(array_intersect($this->tags, $tags)) > 0) {
return true;
}
return false;
}
|
[
"public",
"function",
"hasTag",
"(",
"Array",
"$",
"tags",
")",
"{",
"// if no tags were specified, the fixture should always be loaded",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"tags",
")",
"==",
"0",
"||",
"count",
"(",
"array_intersect",
"(",
"$",
"this",
"->",
"tags",
",",
"$",
"tags",
")",
")",
">",
"0",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Returns if the given tag is set for the current fixture
@param type $tag
@return boolean
|
[
"Returns",
"if",
"the",
"given",
"tag",
"is",
"set",
"for",
"the",
"current",
"fixture"
] |
4f1947b03809421057e7b8a3553ccaa93423d192
|
https://github.com/khepin/KhepinYamlFixturesBundle/blob/4f1947b03809421057e7b8a3553ccaa93423d192/Fixture/AbstractFixture.php#L31-L39
|
230,139
|
khepin/KhepinYamlFixturesBundle
|
Fixture/AbstractFixture.php
|
AbstractFixture.constructorArgs
|
public function constructorArgs($arguments)
{
$constructArguments = array();
if (is_array($arguments)) {
foreach ($arguments as $argument) {
if (is_array($argument)) {
if ($argument['type'] == 'datetime') {
$constructArguments[] = new \DateTime($argument['value']);
} elseif ($argument['type'] == 'reference') {
$constructArguments[] = $this->loader->getReference($argument['value']);
} else {
$constructArguments[] = $argument['value'];
}
} else {
$constructArguments[] = $argument;
}
}
} else {
$constructArguments[] = $arguments;
}
return $constructArguments;
}
|
php
|
public function constructorArgs($arguments)
{
$constructArguments = array();
if (is_array($arguments)) {
foreach ($arguments as $argument) {
if (is_array($argument)) {
if ($argument['type'] == 'datetime') {
$constructArguments[] = new \DateTime($argument['value']);
} elseif ($argument['type'] == 'reference') {
$constructArguments[] = $this->loader->getReference($argument['value']);
} else {
$constructArguments[] = $argument['value'];
}
} else {
$constructArguments[] = $argument;
}
}
} else {
$constructArguments[] = $arguments;
}
return $constructArguments;
}
|
[
"public",
"function",
"constructorArgs",
"(",
"$",
"arguments",
")",
"{",
"$",
"constructArguments",
"=",
"array",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"arguments",
")",
")",
"{",
"foreach",
"(",
"$",
"arguments",
"as",
"$",
"argument",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"argument",
")",
")",
"{",
"if",
"(",
"$",
"argument",
"[",
"'type'",
"]",
"==",
"'datetime'",
")",
"{",
"$",
"constructArguments",
"[",
"]",
"=",
"new",
"\\",
"DateTime",
"(",
"$",
"argument",
"[",
"'value'",
"]",
")",
";",
"}",
"elseif",
"(",
"$",
"argument",
"[",
"'type'",
"]",
"==",
"'reference'",
")",
"{",
"$",
"constructArguments",
"[",
"]",
"=",
"$",
"this",
"->",
"loader",
"->",
"getReference",
"(",
"$",
"argument",
"[",
"'value'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"constructArguments",
"[",
"]",
"=",
"$",
"argument",
"[",
"'value'",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"constructArguments",
"[",
"]",
"=",
"$",
"argument",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"constructArguments",
"[",
"]",
"=",
"$",
"arguments",
";",
"}",
"return",
"$",
"constructArguments",
";",
"}"
] |
Extract the constructor arguments
@param array $arguments
@return mixed
|
[
"Extract",
"the",
"constructor",
"arguments"
] |
4f1947b03809421057e7b8a3553ccaa93423d192
|
https://github.com/khepin/KhepinYamlFixturesBundle/blob/4f1947b03809421057e7b8a3553ccaa93423d192/Fixture/AbstractFixture.php#L110-L133
|
230,140
|
khepin/KhepinYamlFixturesBundle
|
Fixture/AbstractFixture.php
|
AbstractFixture.makeInstance
|
public function makeInstance($class, $data)
{
$class = new \ReflectionClass($class);
$constructArguments = [];
if (isset($data['__construct'])) {
$constructArguments = $this->constructorArgs($data['__construct']);
}
return $class->newInstanceArgs($constructArguments);
}
|
php
|
public function makeInstance($class, $data)
{
$class = new \ReflectionClass($class);
$constructArguments = [];
if (isset($data['__construct'])) {
$constructArguments = $this->constructorArgs($data['__construct']);
}
return $class->newInstanceArgs($constructArguments);
}
|
[
"public",
"function",
"makeInstance",
"(",
"$",
"class",
",",
"$",
"data",
")",
"{",
"$",
"class",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"$",
"constructArguments",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'__construct'",
"]",
")",
")",
"{",
"$",
"constructArguments",
"=",
"$",
"this",
"->",
"constructorArgs",
"(",
"$",
"data",
"[",
"'__construct'",
"]",
")",
";",
"}",
"return",
"$",
"class",
"->",
"newInstanceArgs",
"(",
"$",
"constructArguments",
")",
";",
"}"
] |
Creates an instance with any given constructor args
@param string $class
@param array $data
@return void
|
[
"Creates",
"an",
"instance",
"with",
"any",
"given",
"constructor",
"args"
] |
4f1947b03809421057e7b8a3553ccaa93423d192
|
https://github.com/khepin/KhepinYamlFixturesBundle/blob/4f1947b03809421057e7b8a3553ccaa93423d192/Fixture/AbstractFixture.php#L142-L151
|
230,141
|
Webiny/Framework
|
src/Webiny/Component/Bootstrap/ApplicationClasses/Application.php
|
Application.getWebPath
|
public function getWebPath()
{
$webPath = $this->environment->getCurrentEnvironmentConfig()->get('Domain', false);
if (!$webPath) {
$webPath = Request::getInstance()->getCurrentUrl(true)->getDomain() . '/';
}
return $webPath;
}
|
php
|
public function getWebPath()
{
$webPath = $this->environment->getCurrentEnvironmentConfig()->get('Domain', false);
if (!$webPath) {
$webPath = Request::getInstance()->getCurrentUrl(true)->getDomain() . '/';
}
return $webPath;
}
|
[
"public",
"function",
"getWebPath",
"(",
")",
"{",
"$",
"webPath",
"=",
"$",
"this",
"->",
"environment",
"->",
"getCurrentEnvironmentConfig",
"(",
")",
"->",
"get",
"(",
"'Domain'",
",",
"false",
")",
";",
"if",
"(",
"!",
"$",
"webPath",
")",
"{",
"$",
"webPath",
"=",
"Request",
"::",
"getInstance",
"(",
")",
"->",
"getCurrentUrl",
"(",
"true",
")",
"->",
"getDomain",
"(",
")",
".",
"'/'",
";",
"}",
"return",
"$",
"webPath",
";",
"}"
] |
Get application web path.
@return string
|
[
"Get",
"application",
"web",
"path",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Bootstrap/ApplicationClasses/Application.php#L69-L77
|
230,142
|
Webiny/Framework
|
src/Webiny/Component/Bootstrap/ApplicationClasses/Application.php
|
Application.showErrors
|
public function showErrors()
{
$reporting = $this->getEnvironmentConfig('ErrorReporting', false);
if ($reporting && strtolower($reporting) == 'on') {
return true;
}
return false;
}
|
php
|
public function showErrors()
{
$reporting = $this->getEnvironmentConfig('ErrorReporting', false);
if ($reporting && strtolower($reporting) == 'on') {
return true;
}
return false;
}
|
[
"public",
"function",
"showErrors",
"(",
")",
"{",
"$",
"reporting",
"=",
"$",
"this",
"->",
"getEnvironmentConfig",
"(",
"'ErrorReporting'",
",",
"false",
")",
";",
"if",
"(",
"$",
"reporting",
"&&",
"strtolower",
"(",
"$",
"reporting",
")",
"==",
"'on'",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Based on the current environment configuration, should system errors be shown or not.
@return bool
|
[
"Based",
"on",
"the",
"current",
"environment",
"configuration",
"should",
"system",
"errors",
"be",
"shown",
"or",
"not",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Bootstrap/ApplicationClasses/Application.php#L105-L113
|
230,143
|
Webiny/Framework
|
src/Webiny/Component/Bootstrap/ApplicationClasses/Application.php
|
Application.getEnvironmentConfig
|
public function getEnvironmentConfig($query = '', $default = null)
{
if ($query == '') {
return $this->environment->getCurrentEnvironmentConfig();
} else {
return $this->environment->getCurrentEnvironmentConfig()->get($query, $default);
}
}
|
php
|
public function getEnvironmentConfig($query = '', $default = null)
{
if ($query == '') {
return $this->environment->getCurrentEnvironmentConfig();
} else {
return $this->environment->getCurrentEnvironmentConfig()->get($query, $default);
}
}
|
[
"public",
"function",
"getEnvironmentConfig",
"(",
"$",
"query",
"=",
"''",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"query",
"==",
"''",
")",
"{",
"return",
"$",
"this",
"->",
"environment",
"->",
"getCurrentEnvironmentConfig",
"(",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"environment",
"->",
"getCurrentEnvironmentConfig",
"(",
")",
"->",
"get",
"(",
"$",
"query",
",",
"$",
"default",
")",
";",
"}",
"}"
] |
Returns the current environment configuration.
@param string $query Query inside the environment configuration.
@param null $default Default value which should be returned if query has no matches.
@return mixed|ConfigObject
|
[
"Returns",
"the",
"current",
"environment",
"configuration",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Bootstrap/ApplicationClasses/Application.php#L140-L147
|
230,144
|
Webiny/Framework
|
src/Webiny/Component/Bootstrap/ApplicationClasses/Application.php
|
Application.httpResponse
|
public function httpResponse()
{
// get the template
$template = $this->view()->getTemplate();
// if there is no template, then we return false
if(empty($template)) {
return false;
}
// get view data
$viewData = $this->view()->getAssignedData();
// assign application data to view
$viewData['App'] = [
'Config' => $this->getEnvironmentConfig(),
'Components' => $this->environment->getComponentConfigs()->toArray(),
'Environment' => $this->getEnvironmentName(),
'AbsolutePath' => $this->getAbsolutePath(),
'WebPath' => $this->getWebPath()
];
// render the view and assign it to the response object
return new Response($this->getTemplateEngineInstance()->fetch($this->view()->getTemplate(), $viewData));
}
|
php
|
public function httpResponse()
{
// get the template
$template = $this->view()->getTemplate();
// if there is no template, then we return false
if(empty($template)) {
return false;
}
// get view data
$viewData = $this->view()->getAssignedData();
// assign application data to view
$viewData['App'] = [
'Config' => $this->getEnvironmentConfig(),
'Components' => $this->environment->getComponentConfigs()->toArray(),
'Environment' => $this->getEnvironmentName(),
'AbsolutePath' => $this->getAbsolutePath(),
'WebPath' => $this->getWebPath()
];
// render the view and assign it to the response object
return new Response($this->getTemplateEngineInstance()->fetch($this->view()->getTemplate(), $viewData));
}
|
[
"public",
"function",
"httpResponse",
"(",
")",
"{",
"// get the template",
"$",
"template",
"=",
"$",
"this",
"->",
"view",
"(",
")",
"->",
"getTemplate",
"(",
")",
";",
"// if there is no template, then we return false",
"if",
"(",
"empty",
"(",
"$",
"template",
")",
")",
"{",
"return",
"false",
";",
"}",
"// get view data",
"$",
"viewData",
"=",
"$",
"this",
"->",
"view",
"(",
")",
"->",
"getAssignedData",
"(",
")",
";",
"// assign application data to view",
"$",
"viewData",
"[",
"'App'",
"]",
"=",
"[",
"'Config'",
"=>",
"$",
"this",
"->",
"getEnvironmentConfig",
"(",
")",
",",
"'Components'",
"=>",
"$",
"this",
"->",
"environment",
"->",
"getComponentConfigs",
"(",
")",
"->",
"toArray",
"(",
")",
",",
"'Environment'",
"=>",
"$",
"this",
"->",
"getEnvironmentName",
"(",
")",
",",
"'AbsolutePath'",
"=>",
"$",
"this",
"->",
"getAbsolutePath",
"(",
")",
",",
"'WebPath'",
"=>",
"$",
"this",
"->",
"getWebPath",
"(",
")",
"]",
";",
"// render the view and assign it to the response object",
"return",
"new",
"Response",
"(",
"$",
"this",
"->",
"getTemplateEngineInstance",
"(",
")",
"->",
"fetch",
"(",
"$",
"this",
"->",
"view",
"(",
")",
"->",
"getTemplate",
"(",
")",
",",
"$",
"viewData",
")",
")",
";",
"}"
] |
Send the http response to the browser.
This method is called automatically by the Dispatcher.
@return Response|bool
@throws \Exception
@throws \Webiny\Component\TemplateEngine\Bridge\TemplateEngineException
|
[
"Send",
"the",
"http",
"response",
"to",
"the",
"browser",
".",
"This",
"method",
"is",
"called",
"automatically",
"by",
"the",
"Dispatcher",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Bootstrap/ApplicationClasses/Application.php#L191-L215
|
230,145
|
Webiny/Framework
|
src/Webiny/Component/Bootstrap/ApplicationClasses/Application.php
|
Application.getTemplateEngineInstance
|
private function getTemplateEngineInstance()
{
$teConfig = $this->getComponentConfig('TemplateEngine', 'Engines', false);
// fallback to default template engine
if (!$teConfig) {
$defaultTemplateEngineConfig = [
'Engines' => [
'Smarty' => [
'ForceCompile' => false,
'CacheDir' => $this->getAbsolutePath() . 'App/Cache/Smarty/Cache',
'CompileDir' => $this->getAbsolutePath() . 'App/Cache/Smarty/Compile',
'TemplateDir' => $this->getAbsolutePath() . 'App/Layouts',
'AutoEscapeOutput' => false,
]
]
];
TemplateEngine::setConfig(new ConfigObject($defaultTemplateEngineConfig));
return TemplateEngineLoader::getInstance('Smarty');
}
$teConfig = $this->getComponentConfig('TemplateEngine', 'Engines')->toArray();
reset($teConfig);
$teName = key($teConfig);
return TemplateEngineLoader::getInstance($teName);
}
|
php
|
private function getTemplateEngineInstance()
{
$teConfig = $this->getComponentConfig('TemplateEngine', 'Engines', false);
// fallback to default template engine
if (!$teConfig) {
$defaultTemplateEngineConfig = [
'Engines' => [
'Smarty' => [
'ForceCompile' => false,
'CacheDir' => $this->getAbsolutePath() . 'App/Cache/Smarty/Cache',
'CompileDir' => $this->getAbsolutePath() . 'App/Cache/Smarty/Compile',
'TemplateDir' => $this->getAbsolutePath() . 'App/Layouts',
'AutoEscapeOutput' => false,
]
]
];
TemplateEngine::setConfig(new ConfigObject($defaultTemplateEngineConfig));
return TemplateEngineLoader::getInstance('Smarty');
}
$teConfig = $this->getComponentConfig('TemplateEngine', 'Engines')->toArray();
reset($teConfig);
$teName = key($teConfig);
return TemplateEngineLoader::getInstance($teName);
}
|
[
"private",
"function",
"getTemplateEngineInstance",
"(",
")",
"{",
"$",
"teConfig",
"=",
"$",
"this",
"->",
"getComponentConfig",
"(",
"'TemplateEngine'",
",",
"'Engines'",
",",
"false",
")",
";",
"// fallback to default template engine",
"if",
"(",
"!",
"$",
"teConfig",
")",
"{",
"$",
"defaultTemplateEngineConfig",
"=",
"[",
"'Engines'",
"=>",
"[",
"'Smarty'",
"=>",
"[",
"'ForceCompile'",
"=>",
"false",
",",
"'CacheDir'",
"=>",
"$",
"this",
"->",
"getAbsolutePath",
"(",
")",
".",
"'App/Cache/Smarty/Cache'",
",",
"'CompileDir'",
"=>",
"$",
"this",
"->",
"getAbsolutePath",
"(",
")",
".",
"'App/Cache/Smarty/Compile'",
",",
"'TemplateDir'",
"=>",
"$",
"this",
"->",
"getAbsolutePath",
"(",
")",
".",
"'App/Layouts'",
",",
"'AutoEscapeOutput'",
"=>",
"false",
",",
"]",
"]",
"]",
";",
"TemplateEngine",
"::",
"setConfig",
"(",
"new",
"ConfigObject",
"(",
"$",
"defaultTemplateEngineConfig",
")",
")",
";",
"return",
"TemplateEngineLoader",
"::",
"getInstance",
"(",
"'Smarty'",
")",
";",
"}",
"$",
"teConfig",
"=",
"$",
"this",
"->",
"getComponentConfig",
"(",
"'TemplateEngine'",
",",
"'Engines'",
")",
"->",
"toArray",
"(",
")",
";",
"reset",
"(",
"$",
"teConfig",
")",
";",
"$",
"teName",
"=",
"key",
"(",
"$",
"teConfig",
")",
";",
"return",
"TemplateEngineLoader",
"::",
"getInstance",
"(",
"$",
"teName",
")",
";",
"}"
] |
Returns template engine instance, based on current configuration.
If a template engine is not defined, a default template engine instance will be created.
@return \Webiny\Component\TemplateEngine\Bridge\TemplateEngineInterface
@throws \Exception
@throws \Webiny\Component\StdLib\Exception\Exception
@throws \Webiny\Component\TemplateEngine\TemplateEngineException
|
[
"Returns",
"template",
"engine",
"instance",
"based",
"on",
"current",
"configuration",
".",
"If",
"a",
"template",
"engine",
"is",
"not",
"defined",
"a",
"default",
"template",
"engine",
"instance",
"will",
"be",
"created",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Bootstrap/ApplicationClasses/Application.php#L226-L254
|
230,146
|
Webiny/Framework
|
src/Webiny/Component/Annotations/Bridge/Loader.php
|
Loader.getInstance
|
public static function getInstance()
{
$driver = static::getLibrary();
try {
$instance = self::factory($driver, AnnotationsInterface::class);
} catch (\Exception $e) {
throw new AnnotationsException($e->getMessage());
}
return $instance;
}
|
php
|
public static function getInstance()
{
$driver = static::getLibrary();
try {
$instance = self::factory($driver, AnnotationsInterface::class);
} catch (\Exception $e) {
throw new AnnotationsException($e->getMessage());
}
return $instance;
}
|
[
"public",
"static",
"function",
"getInstance",
"(",
")",
"{",
"$",
"driver",
"=",
"static",
"::",
"getLibrary",
"(",
")",
";",
"try",
"{",
"$",
"instance",
"=",
"self",
"::",
"factory",
"(",
"$",
"driver",
",",
"AnnotationsInterface",
"::",
"class",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"AnnotationsException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"$",
"instance",
";",
"}"
] |
Create an instance of a annotations driver.
@throws AnnotationsException
@return AnnotationsInterface
|
[
"Create",
"an",
"instance",
"of",
"a",
"annotations",
"driver",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Annotations/Bridge/Loader.php#L57-L68
|
230,147
|
ZenMagick/ZenCart
|
includes/modules/payment/paypaldp.php
|
paypaldp.update_status
|
function update_status() {
global $order, $db;
// $this->zcLog('update_status', 'Checking whether module should be enabled or not.');
// if store is not running in SSL, cannot offer credit card module, for PCI reasons
if (!defined('ENABLE_SSL') || ENABLE_SSL != 'true') {
$this->enabled = FALSE;
$this->zcLog('update_status', 'Module disabled because SSL is not enabled on this site.');
}
// check other reasons for the module to be deactivated:
if ($this->enabled && (int)$this->zone > 0) {
$check_flag = false;
$sql = "SELECT zone_id
FROM " . TABLE_ZONES_TO_GEO_ZONES . "
WHERE geo_zone_id = :zoneId
AND zone_country_id = :countryId
ORDER BY zone_id";
$sql = $db->bindVars($sql, ':zoneId', $this->zone, 'integer');
$sql = $db->bindVars($sql, ':countryId', $order->billing['country']['id'], 'integer');
$check = $db->Execute($sql);
while (!$check->EOF) {
if ($check->fields['zone_id'] < 1) {
$check_flag = true;
break;
} elseif ($check->fields['zone_id'] == $order->billing['zone_id']) {
$check_flag = true;
break;
}
$check->MoveNext();
}
if (!$check_flag) {
$this->enabled = false;
$this->zcLog('update_status', 'Module disabled due to zone restriction. Billing address is not within the Payment Zone selected in the module settings.');
}
// module cannot be used for purchase > $10,000 USD
$order_amount = $this->calc_order_amount($order->info['total'], 'USD');
if ($order_amount > 10000) {
$this->enabled = false;
$this->zcLog('update_status', 'Module disabled because purchase price (' . $order_amount . ') exceeds PayPal-imposed maximum limit of 10,000 USD.');
}
if ($order->info['total'] == 0) {
$this->enabled = false;
$this->zcLog('update_status', 'Module disabled because purchase amount is set to 0.00.' . "\n" . print_r($order, true));
}
}
}
|
php
|
function update_status() {
global $order, $db;
// $this->zcLog('update_status', 'Checking whether module should be enabled or not.');
// if store is not running in SSL, cannot offer credit card module, for PCI reasons
if (!defined('ENABLE_SSL') || ENABLE_SSL != 'true') {
$this->enabled = FALSE;
$this->zcLog('update_status', 'Module disabled because SSL is not enabled on this site.');
}
// check other reasons for the module to be deactivated:
if ($this->enabled && (int)$this->zone > 0) {
$check_flag = false;
$sql = "SELECT zone_id
FROM " . TABLE_ZONES_TO_GEO_ZONES . "
WHERE geo_zone_id = :zoneId
AND zone_country_id = :countryId
ORDER BY zone_id";
$sql = $db->bindVars($sql, ':zoneId', $this->zone, 'integer');
$sql = $db->bindVars($sql, ':countryId', $order->billing['country']['id'], 'integer');
$check = $db->Execute($sql);
while (!$check->EOF) {
if ($check->fields['zone_id'] < 1) {
$check_flag = true;
break;
} elseif ($check->fields['zone_id'] == $order->billing['zone_id']) {
$check_flag = true;
break;
}
$check->MoveNext();
}
if (!$check_flag) {
$this->enabled = false;
$this->zcLog('update_status', 'Module disabled due to zone restriction. Billing address is not within the Payment Zone selected in the module settings.');
}
// module cannot be used for purchase > $10,000 USD
$order_amount = $this->calc_order_amount($order->info['total'], 'USD');
if ($order_amount > 10000) {
$this->enabled = false;
$this->zcLog('update_status', 'Module disabled because purchase price (' . $order_amount . ') exceeds PayPal-imposed maximum limit of 10,000 USD.');
}
if ($order->info['total'] == 0) {
$this->enabled = false;
$this->zcLog('update_status', 'Module disabled because purchase amount is set to 0.00.' . "\n" . print_r($order, true));
}
}
}
|
[
"function",
"update_status",
"(",
")",
"{",
"global",
"$",
"order",
",",
"$",
"db",
";",
"// $this->zcLog('update_status', 'Checking whether module should be enabled or not.');",
"// if store is not running in SSL, cannot offer credit card module, for PCI reasons",
"if",
"(",
"!",
"defined",
"(",
"'ENABLE_SSL'",
")",
"||",
"ENABLE_SSL",
"!=",
"'true'",
")",
"{",
"$",
"this",
"->",
"enabled",
"=",
"FALSE",
";",
"$",
"this",
"->",
"zcLog",
"(",
"'update_status'",
",",
"'Module disabled because SSL is not enabled on this site.'",
")",
";",
"}",
"// check other reasons for the module to be deactivated:",
"if",
"(",
"$",
"this",
"->",
"enabled",
"&&",
"(",
"int",
")",
"$",
"this",
"->",
"zone",
">",
"0",
")",
"{",
"$",
"check_flag",
"=",
"false",
";",
"$",
"sql",
"=",
"\"SELECT zone_id\n FROM \"",
".",
"TABLE_ZONES_TO_GEO_ZONES",
".",
"\"\n WHERE geo_zone_id = :zoneId\n AND zone_country_id = :countryId\n ORDER BY zone_id\"",
";",
"$",
"sql",
"=",
"$",
"db",
"->",
"bindVars",
"(",
"$",
"sql",
",",
"':zoneId'",
",",
"$",
"this",
"->",
"zone",
",",
"'integer'",
")",
";",
"$",
"sql",
"=",
"$",
"db",
"->",
"bindVars",
"(",
"$",
"sql",
",",
"':countryId'",
",",
"$",
"order",
"->",
"billing",
"[",
"'country'",
"]",
"[",
"'id'",
"]",
",",
"'integer'",
")",
";",
"$",
"check",
"=",
"$",
"db",
"->",
"Execute",
"(",
"$",
"sql",
")",
";",
"while",
"(",
"!",
"$",
"check",
"->",
"EOF",
")",
"{",
"if",
"(",
"$",
"check",
"->",
"fields",
"[",
"'zone_id'",
"]",
"<",
"1",
")",
"{",
"$",
"check_flag",
"=",
"true",
";",
"break",
";",
"}",
"elseif",
"(",
"$",
"check",
"->",
"fields",
"[",
"'zone_id'",
"]",
"==",
"$",
"order",
"->",
"billing",
"[",
"'zone_id'",
"]",
")",
"{",
"$",
"check_flag",
"=",
"true",
";",
"break",
";",
"}",
"$",
"check",
"->",
"MoveNext",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"check_flag",
")",
"{",
"$",
"this",
"->",
"enabled",
"=",
"false",
";",
"$",
"this",
"->",
"zcLog",
"(",
"'update_status'",
",",
"'Module disabled due to zone restriction. Billing address is not within the Payment Zone selected in the module settings.'",
")",
";",
"}",
"// module cannot be used for purchase > $10,000 USD",
"$",
"order_amount",
"=",
"$",
"this",
"->",
"calc_order_amount",
"(",
"$",
"order",
"->",
"info",
"[",
"'total'",
"]",
",",
"'USD'",
")",
";",
"if",
"(",
"$",
"order_amount",
">",
"10000",
")",
"{",
"$",
"this",
"->",
"enabled",
"=",
"false",
";",
"$",
"this",
"->",
"zcLog",
"(",
"'update_status'",
",",
"'Module disabled because purchase price ('",
".",
"$",
"order_amount",
".",
"') exceeds PayPal-imposed maximum limit of 10,000 USD.'",
")",
";",
"}",
"if",
"(",
"$",
"order",
"->",
"info",
"[",
"'total'",
"]",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"enabled",
"=",
"false",
";",
"$",
"this",
"->",
"zcLog",
"(",
"'update_status'",
",",
"'Module disabled because purchase amount is set to 0.00.'",
".",
"\"\\n\"",
".",
"print_r",
"(",
"$",
"order",
",",
"true",
")",
")",
";",
"}",
"}",
"}"
] |
Sets payment module status based on zone restrictions etc
|
[
"Sets",
"payment",
"module",
"status",
"based",
"on",
"zone",
"restrictions",
"etc"
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/modules/payment/paypaldp.php#L195-L241
|
230,148
|
ZenMagick/ZenCart
|
includes/modules/payment/paypaldp.php
|
paypaldp.confirmation
|
function confirmation() {
$confirmation = array('title' => '',
'fields' => array(array('title' => MODULE_PAYMENT_PAYPALDP_TEXT_CREDIT_CARD_FIRSTNAME,
'field' => $_POST['paypalwpp_cc_firstname']),
array('title' => MODULE_PAYMENT_PAYPALDP_TEXT_CREDIT_CARD_LASTNAME,
'field' => $_POST['paypalwpp_cc_lastname']),
array('title' => MODULE_PAYMENT_PAYPALDP_TEXT_CREDIT_CARD_TYPE,
'field' => $this->cc_card_type),
array('title' => MODULE_PAYMENT_PAYPALDP_TEXT_CREDIT_CARD_NUMBER,
'field' => substr($_POST['paypalwpp_cc_number'], 0, 4) . str_repeat('X', (strlen($_POST['paypalwpp_cc_number']) - 8)) . substr($_POST['paypalwpp_cc_number'], -4)),
array('title' => MODULE_PAYMENT_PAYPALDP_TEXT_CREDIT_CARD_EXPIRES,
'field' => strftime('%B, %Y', mktime(0,0,0,$_POST['paypalwpp_cc_expires_month'], 1, '20' . $_POST['paypalwpp_cc_expires_year'])),
(isset($_POST['paypalwpp_cc_issuenumber']) ? array('title' => MODULE_PAYMENT_PAYPALDP_TEXT_ISSUE_NUMBER,
'field' => $_POST['paypalwpp_cc_issuenumber']) : '')
)));
// 3D-Secure
if (MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY == 'UK' && $this->requiresLookup($_POST['paypalwpp_cc_number']) == true) {
$confirmation['fields'][count($confirmation['fields'])] = array(
'title' => '',
'field' => '<div id="' . $this->code.'-cc-securetext"><p>' .
'<a href="javascript:void window.open(\'vbv_learn_more.html\',\'vbv_service\',\'width=550,height=450\')">' .
zen_image(DIR_WS_IMAGES.'3ds/vbv_learn_more.gif') . '</a>' .
'<a href="javascript:void window.open(\'mcs_learn_more.html\',\'mcsc_service\',\'width=550,height=450\')">' .
zen_image(DIR_WS_IMAGES.'3ds/mcsc_learn_more.gif') . '</a></p>' .
'<p>' . TEXT_3DS_CARD_MAY_BE_ENROLLED . '</p></div>');
}
return $confirmation;
}
|
php
|
function confirmation() {
$confirmation = array('title' => '',
'fields' => array(array('title' => MODULE_PAYMENT_PAYPALDP_TEXT_CREDIT_CARD_FIRSTNAME,
'field' => $_POST['paypalwpp_cc_firstname']),
array('title' => MODULE_PAYMENT_PAYPALDP_TEXT_CREDIT_CARD_LASTNAME,
'field' => $_POST['paypalwpp_cc_lastname']),
array('title' => MODULE_PAYMENT_PAYPALDP_TEXT_CREDIT_CARD_TYPE,
'field' => $this->cc_card_type),
array('title' => MODULE_PAYMENT_PAYPALDP_TEXT_CREDIT_CARD_NUMBER,
'field' => substr($_POST['paypalwpp_cc_number'], 0, 4) . str_repeat('X', (strlen($_POST['paypalwpp_cc_number']) - 8)) . substr($_POST['paypalwpp_cc_number'], -4)),
array('title' => MODULE_PAYMENT_PAYPALDP_TEXT_CREDIT_CARD_EXPIRES,
'field' => strftime('%B, %Y', mktime(0,0,0,$_POST['paypalwpp_cc_expires_month'], 1, '20' . $_POST['paypalwpp_cc_expires_year'])),
(isset($_POST['paypalwpp_cc_issuenumber']) ? array('title' => MODULE_PAYMENT_PAYPALDP_TEXT_ISSUE_NUMBER,
'field' => $_POST['paypalwpp_cc_issuenumber']) : '')
)));
// 3D-Secure
if (MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY == 'UK' && $this->requiresLookup($_POST['paypalwpp_cc_number']) == true) {
$confirmation['fields'][count($confirmation['fields'])] = array(
'title' => '',
'field' => '<div id="' . $this->code.'-cc-securetext"><p>' .
'<a href="javascript:void window.open(\'vbv_learn_more.html\',\'vbv_service\',\'width=550,height=450\')">' .
zen_image(DIR_WS_IMAGES.'3ds/vbv_learn_more.gif') . '</a>' .
'<a href="javascript:void window.open(\'mcs_learn_more.html\',\'mcsc_service\',\'width=550,height=450\')">' .
zen_image(DIR_WS_IMAGES.'3ds/mcsc_learn_more.gif') . '</a></p>' .
'<p>' . TEXT_3DS_CARD_MAY_BE_ENROLLED . '</p></div>');
}
return $confirmation;
}
|
[
"function",
"confirmation",
"(",
")",
"{",
"$",
"confirmation",
"=",
"array",
"(",
"'title'",
"=>",
"''",
",",
"'fields'",
"=>",
"array",
"(",
"array",
"(",
"'title'",
"=>",
"MODULE_PAYMENT_PAYPALDP_TEXT_CREDIT_CARD_FIRSTNAME",
",",
"'field'",
"=>",
"$",
"_POST",
"[",
"'paypalwpp_cc_firstname'",
"]",
")",
",",
"array",
"(",
"'title'",
"=>",
"MODULE_PAYMENT_PAYPALDP_TEXT_CREDIT_CARD_LASTNAME",
",",
"'field'",
"=>",
"$",
"_POST",
"[",
"'paypalwpp_cc_lastname'",
"]",
")",
",",
"array",
"(",
"'title'",
"=>",
"MODULE_PAYMENT_PAYPALDP_TEXT_CREDIT_CARD_TYPE",
",",
"'field'",
"=>",
"$",
"this",
"->",
"cc_card_type",
")",
",",
"array",
"(",
"'title'",
"=>",
"MODULE_PAYMENT_PAYPALDP_TEXT_CREDIT_CARD_NUMBER",
",",
"'field'",
"=>",
"substr",
"(",
"$",
"_POST",
"[",
"'paypalwpp_cc_number'",
"]",
",",
"0",
",",
"4",
")",
".",
"str_repeat",
"(",
"'X'",
",",
"(",
"strlen",
"(",
"$",
"_POST",
"[",
"'paypalwpp_cc_number'",
"]",
")",
"-",
"8",
")",
")",
".",
"substr",
"(",
"$",
"_POST",
"[",
"'paypalwpp_cc_number'",
"]",
",",
"-",
"4",
")",
")",
",",
"array",
"(",
"'title'",
"=>",
"MODULE_PAYMENT_PAYPALDP_TEXT_CREDIT_CARD_EXPIRES",
",",
"'field'",
"=>",
"strftime",
"(",
"'%B, %Y'",
",",
"mktime",
"(",
"0",
",",
"0",
",",
"0",
",",
"$",
"_POST",
"[",
"'paypalwpp_cc_expires_month'",
"]",
",",
"1",
",",
"'20'",
".",
"$",
"_POST",
"[",
"'paypalwpp_cc_expires_year'",
"]",
")",
")",
",",
"(",
"isset",
"(",
"$",
"_POST",
"[",
"'paypalwpp_cc_issuenumber'",
"]",
")",
"?",
"array",
"(",
"'title'",
"=>",
"MODULE_PAYMENT_PAYPALDP_TEXT_ISSUE_NUMBER",
",",
"'field'",
"=>",
"$",
"_POST",
"[",
"'paypalwpp_cc_issuenumber'",
"]",
")",
":",
"''",
")",
")",
")",
")",
";",
"// 3D-Secure",
"if",
"(",
"MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY",
"==",
"'UK'",
"&&",
"$",
"this",
"->",
"requiresLookup",
"(",
"$",
"_POST",
"[",
"'paypalwpp_cc_number'",
"]",
")",
"==",
"true",
")",
"{",
"$",
"confirmation",
"[",
"'fields'",
"]",
"[",
"count",
"(",
"$",
"confirmation",
"[",
"'fields'",
"]",
")",
"]",
"=",
"array",
"(",
"'title'",
"=>",
"''",
",",
"'field'",
"=>",
"'<div id=\"'",
".",
"$",
"this",
"->",
"code",
".",
"'-cc-securetext\"><p>'",
".",
"'<a href=\"javascript:void window.open(\\'vbv_learn_more.html\\',\\'vbv_service\\',\\'width=550,height=450\\')\">'",
".",
"zen_image",
"(",
"DIR_WS_IMAGES",
".",
"'3ds/vbv_learn_more.gif'",
")",
".",
"'</a>'",
".",
"'<a href=\"javascript:void window.open(\\'mcs_learn_more.html\\',\\'mcsc_service\\',\\'width=550,height=450\\')\">'",
".",
"zen_image",
"(",
"DIR_WS_IMAGES",
".",
"'3ds/mcsc_learn_more.gif'",
")",
".",
"'</a></p>'",
".",
"'<p>'",
".",
"TEXT_3DS_CARD_MAY_BE_ENROLLED",
".",
"'</p></div>'",
")",
";",
"}",
"return",
"$",
"confirmation",
";",
"}"
] |
Display Credit Card Information for review on the Checkout Confirmation Page
|
[
"Display",
"Credit",
"Card",
"Information",
"for",
"review",
"on",
"the",
"Checkout",
"Confirmation",
"Page"
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/modules/payment/paypaldp.php#L523-L550
|
230,149
|
ZenMagick/ZenCart
|
includes/modules/payment/paypaldp.php
|
paypaldp.process_button
|
function process_button() {
global $order;
$_SESSION['paypal_ec_markflow'] = 1;
$process_button_string = '';
$process_button_string .= "\n" . zen_draw_hidden_field('wpp_cc_type', $_POST['paypalwpp_cc_type']) . "\n" .
zen_draw_hidden_field('wpp_cc_expdate_month', $_POST['paypalwpp_cc_expires_month']) . "\n" .
zen_draw_hidden_field('wpp_cc_expdate_year', $_POST['paypalwpp_cc_expires_year']) . "\n" .
zen_draw_hidden_field('wpp_cc_issuedate_month', $_POST['paypalwpp_cc_issue_month']) . "\n" .
zen_draw_hidden_field('wpp_cc_issuedate_year', $_POST['paypalwpp_cc_issue_year']) . "\n" .
zen_draw_hidden_field('wpp_cc_issuenumber', $_POST['paypalwpp_cc_issuenumber']) . "\n" .
zen_draw_hidden_field('wpp_cc_number', $_POST['paypalwpp_cc_number']) . "\n" .
zen_draw_hidden_field('wpp_cc_checkcode', $_POST['paypalwpp_cc_checkcode']) . "\n" .
zen_draw_hidden_field('wpp_payer_firstname', $_POST['paypalwpp_cc_firstname']) . "\n" .
zen_draw_hidden_field('wpp_payer_lastname', $_POST['paypalwpp_cc_lastname']) . "\n";
$process_button_string .= zen_draw_hidden_field(zen_session_name(), zen_session_id());
return $process_button_string;
}
|
php
|
function process_button() {
global $order;
$_SESSION['paypal_ec_markflow'] = 1;
$process_button_string = '';
$process_button_string .= "\n" . zen_draw_hidden_field('wpp_cc_type', $_POST['paypalwpp_cc_type']) . "\n" .
zen_draw_hidden_field('wpp_cc_expdate_month', $_POST['paypalwpp_cc_expires_month']) . "\n" .
zen_draw_hidden_field('wpp_cc_expdate_year', $_POST['paypalwpp_cc_expires_year']) . "\n" .
zen_draw_hidden_field('wpp_cc_issuedate_month', $_POST['paypalwpp_cc_issue_month']) . "\n" .
zen_draw_hidden_field('wpp_cc_issuedate_year', $_POST['paypalwpp_cc_issue_year']) . "\n" .
zen_draw_hidden_field('wpp_cc_issuenumber', $_POST['paypalwpp_cc_issuenumber']) . "\n" .
zen_draw_hidden_field('wpp_cc_number', $_POST['paypalwpp_cc_number']) . "\n" .
zen_draw_hidden_field('wpp_cc_checkcode', $_POST['paypalwpp_cc_checkcode']) . "\n" .
zen_draw_hidden_field('wpp_payer_firstname', $_POST['paypalwpp_cc_firstname']) . "\n" .
zen_draw_hidden_field('wpp_payer_lastname', $_POST['paypalwpp_cc_lastname']) . "\n";
$process_button_string .= zen_draw_hidden_field(zen_session_name(), zen_session_id());
return $process_button_string;
}
|
[
"function",
"process_button",
"(",
")",
"{",
"global",
"$",
"order",
";",
"$",
"_SESSION",
"[",
"'paypal_ec_markflow'",
"]",
"=",
"1",
";",
"$",
"process_button_string",
"=",
"''",
";",
"$",
"process_button_string",
".=",
"\"\\n\"",
".",
"zen_draw_hidden_field",
"(",
"'wpp_cc_type'",
",",
"$",
"_POST",
"[",
"'paypalwpp_cc_type'",
"]",
")",
".",
"\"\\n\"",
".",
"zen_draw_hidden_field",
"(",
"'wpp_cc_expdate_month'",
",",
"$",
"_POST",
"[",
"'paypalwpp_cc_expires_month'",
"]",
")",
".",
"\"\\n\"",
".",
"zen_draw_hidden_field",
"(",
"'wpp_cc_expdate_year'",
",",
"$",
"_POST",
"[",
"'paypalwpp_cc_expires_year'",
"]",
")",
".",
"\"\\n\"",
".",
"zen_draw_hidden_field",
"(",
"'wpp_cc_issuedate_month'",
",",
"$",
"_POST",
"[",
"'paypalwpp_cc_issue_month'",
"]",
")",
".",
"\"\\n\"",
".",
"zen_draw_hidden_field",
"(",
"'wpp_cc_issuedate_year'",
",",
"$",
"_POST",
"[",
"'paypalwpp_cc_issue_year'",
"]",
")",
".",
"\"\\n\"",
".",
"zen_draw_hidden_field",
"(",
"'wpp_cc_issuenumber'",
",",
"$",
"_POST",
"[",
"'paypalwpp_cc_issuenumber'",
"]",
")",
".",
"\"\\n\"",
".",
"zen_draw_hidden_field",
"(",
"'wpp_cc_number'",
",",
"$",
"_POST",
"[",
"'paypalwpp_cc_number'",
"]",
")",
".",
"\"\\n\"",
".",
"zen_draw_hidden_field",
"(",
"'wpp_cc_checkcode'",
",",
"$",
"_POST",
"[",
"'paypalwpp_cc_checkcode'",
"]",
")",
".",
"\"\\n\"",
".",
"zen_draw_hidden_field",
"(",
"'wpp_payer_firstname'",
",",
"$",
"_POST",
"[",
"'paypalwpp_cc_firstname'",
"]",
")",
".",
"\"\\n\"",
".",
"zen_draw_hidden_field",
"(",
"'wpp_payer_lastname'",
",",
"$",
"_POST",
"[",
"'paypalwpp_cc_lastname'",
"]",
")",
".",
"\"\\n\"",
";",
"$",
"process_button_string",
".=",
"zen_draw_hidden_field",
"(",
"zen_session_name",
"(",
")",
",",
"zen_session_id",
"(",
")",
")",
";",
"return",
"$",
"process_button_string",
";",
"}"
] |
Prepare the hidden fields comprising the parameters for the Submit button on the checkout confirmation page
|
[
"Prepare",
"the",
"hidden",
"fields",
"comprising",
"the",
"parameters",
"for",
"the",
"Submit",
"button",
"on",
"the",
"checkout",
"confirmation",
"page"
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/modules/payment/paypaldp.php#L554-L570
|
230,150
|
ZenMagick/ZenCart
|
includes/modules/payment/paypaldp.php
|
paypaldp._doVoid
|
function _doVoid($oID, $note = '') {
global $db, $doPayPal, $messageStack;
$new_order_status = (int)MODULE_PAYMENT_PAYPALDP_REFUNDED_STATUS_ID;
$doPayPal = $this->paypal_init();
$voidNote = strip_tags(zen_db_input($_POST['voidnote']));
$voidAuthID = trim(strip_tags(zen_db_input($_POST['voidauthid'])));
if (isset($_POST['ordervoid']) && $_POST['ordervoid'] == MODULE_PAYMENT_PAYPAL_ENTRY_VOID_BUTTON_TEXT_FULL) {
if (isset($_POST['voidconfirm']) && $_POST['voidconfirm'] == 'on') {
$proceedToVoid = true;
} else {
$messageStack->add_session(MODULE_PAYMENT_PAYPALDP_TEXT_VOID_CONFIRM_ERROR, 'error');
}
}
// look up history on this order from PayPal table
$sql = "select * from " . TABLE_PAYPAL . " where order_id = :orderID AND parent_txn_id = '' ";
$sql = $db->bindVars($sql, ':orderID', $oID, 'integer');
$sql = $db->bindVars($sql, ':transID', $voidAuthID, 'string');
$zc_ppHist = $db->Execute($sql);
if ($zc_ppHist->RecordCount() == 0) return false;
$txnID = $zc_ppHist->fields['txn_id'];
/**
* Submit void request to PayPal
*/
if ($proceedToVoid) {
$response = $doPayPal->DoVoid($voidAuthID, $voidNote);
$error = $this->_errorHandler($response, 'DoVoid');
$new_order_status = ($new_order_status > 0 ? $new_order_status : 1);
if (!$error) {
// Success, so save the results
$sql_data_array = array('orders_id' => (int)$oID,
'orders_status_id' => (int)$new_order_status,
'date_added' => 'now()',
'comments' => 'VOIDED. Trans ID: ' . urldecode($response['AUTHORIZATIONID']). $response['PNREF'] . (isset($response['PPREF']) ? "\nPPRef: " . $response['PPREF'] : '') . "\n" . $voidNote,
'customer_notified' => 0
);
zen_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
$db->Execute("update " . TABLE_ORDERS . "
set orders_status = '" . (int)$new_order_status . "'
where orders_id = '" . (int)$oID . "'");
$messageStack->add_session(sprintf(MODULE_PAYMENT_PAYPALDP_TEXT_VOID_INITIATED, urldecode($response['AUTHORIZATIONID']) . $response['PNREF']), 'success');
return true;
}
}
}
|
php
|
function _doVoid($oID, $note = '') {
global $db, $doPayPal, $messageStack;
$new_order_status = (int)MODULE_PAYMENT_PAYPALDP_REFUNDED_STATUS_ID;
$doPayPal = $this->paypal_init();
$voidNote = strip_tags(zen_db_input($_POST['voidnote']));
$voidAuthID = trim(strip_tags(zen_db_input($_POST['voidauthid'])));
if (isset($_POST['ordervoid']) && $_POST['ordervoid'] == MODULE_PAYMENT_PAYPAL_ENTRY_VOID_BUTTON_TEXT_FULL) {
if (isset($_POST['voidconfirm']) && $_POST['voidconfirm'] == 'on') {
$proceedToVoid = true;
} else {
$messageStack->add_session(MODULE_PAYMENT_PAYPALDP_TEXT_VOID_CONFIRM_ERROR, 'error');
}
}
// look up history on this order from PayPal table
$sql = "select * from " . TABLE_PAYPAL . " where order_id = :orderID AND parent_txn_id = '' ";
$sql = $db->bindVars($sql, ':orderID', $oID, 'integer');
$sql = $db->bindVars($sql, ':transID', $voidAuthID, 'string');
$zc_ppHist = $db->Execute($sql);
if ($zc_ppHist->RecordCount() == 0) return false;
$txnID = $zc_ppHist->fields['txn_id'];
/**
* Submit void request to PayPal
*/
if ($proceedToVoid) {
$response = $doPayPal->DoVoid($voidAuthID, $voidNote);
$error = $this->_errorHandler($response, 'DoVoid');
$new_order_status = ($new_order_status > 0 ? $new_order_status : 1);
if (!$error) {
// Success, so save the results
$sql_data_array = array('orders_id' => (int)$oID,
'orders_status_id' => (int)$new_order_status,
'date_added' => 'now()',
'comments' => 'VOIDED. Trans ID: ' . urldecode($response['AUTHORIZATIONID']). $response['PNREF'] . (isset($response['PPREF']) ? "\nPPRef: " . $response['PPREF'] : '') . "\n" . $voidNote,
'customer_notified' => 0
);
zen_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
$db->Execute("update " . TABLE_ORDERS . "
set orders_status = '" . (int)$new_order_status . "'
where orders_id = '" . (int)$oID . "'");
$messageStack->add_session(sprintf(MODULE_PAYMENT_PAYPALDP_TEXT_VOID_INITIATED, urldecode($response['AUTHORIZATIONID']) . $response['PNREF']), 'success');
return true;
}
}
}
|
[
"function",
"_doVoid",
"(",
"$",
"oID",
",",
"$",
"note",
"=",
"''",
")",
"{",
"global",
"$",
"db",
",",
"$",
"doPayPal",
",",
"$",
"messageStack",
";",
"$",
"new_order_status",
"=",
"(",
"int",
")",
"MODULE_PAYMENT_PAYPALDP_REFUNDED_STATUS_ID",
";",
"$",
"doPayPal",
"=",
"$",
"this",
"->",
"paypal_init",
"(",
")",
";",
"$",
"voidNote",
"=",
"strip_tags",
"(",
"zen_db_input",
"(",
"$",
"_POST",
"[",
"'voidnote'",
"]",
")",
")",
";",
"$",
"voidAuthID",
"=",
"trim",
"(",
"strip_tags",
"(",
"zen_db_input",
"(",
"$",
"_POST",
"[",
"'voidauthid'",
"]",
")",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"_POST",
"[",
"'ordervoid'",
"]",
")",
"&&",
"$",
"_POST",
"[",
"'ordervoid'",
"]",
"==",
"MODULE_PAYMENT_PAYPAL_ENTRY_VOID_BUTTON_TEXT_FULL",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_POST",
"[",
"'voidconfirm'",
"]",
")",
"&&",
"$",
"_POST",
"[",
"'voidconfirm'",
"]",
"==",
"'on'",
")",
"{",
"$",
"proceedToVoid",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"messageStack",
"->",
"add_session",
"(",
"MODULE_PAYMENT_PAYPALDP_TEXT_VOID_CONFIRM_ERROR",
",",
"'error'",
")",
";",
"}",
"}",
"// look up history on this order from PayPal table",
"$",
"sql",
"=",
"\"select * from \"",
".",
"TABLE_PAYPAL",
".",
"\" where order_id = :orderID AND parent_txn_id = '' \"",
";",
"$",
"sql",
"=",
"$",
"db",
"->",
"bindVars",
"(",
"$",
"sql",
",",
"':orderID'",
",",
"$",
"oID",
",",
"'integer'",
")",
";",
"$",
"sql",
"=",
"$",
"db",
"->",
"bindVars",
"(",
"$",
"sql",
",",
"':transID'",
",",
"$",
"voidAuthID",
",",
"'string'",
")",
";",
"$",
"zc_ppHist",
"=",
"$",
"db",
"->",
"Execute",
"(",
"$",
"sql",
")",
";",
"if",
"(",
"$",
"zc_ppHist",
"->",
"RecordCount",
"(",
")",
"==",
"0",
")",
"return",
"false",
";",
"$",
"txnID",
"=",
"$",
"zc_ppHist",
"->",
"fields",
"[",
"'txn_id'",
"]",
";",
"/**\n * Submit void request to PayPal\n */",
"if",
"(",
"$",
"proceedToVoid",
")",
"{",
"$",
"response",
"=",
"$",
"doPayPal",
"->",
"DoVoid",
"(",
"$",
"voidAuthID",
",",
"$",
"voidNote",
")",
";",
"$",
"error",
"=",
"$",
"this",
"->",
"_errorHandler",
"(",
"$",
"response",
",",
"'DoVoid'",
")",
";",
"$",
"new_order_status",
"=",
"(",
"$",
"new_order_status",
">",
"0",
"?",
"$",
"new_order_status",
":",
"1",
")",
";",
"if",
"(",
"!",
"$",
"error",
")",
"{",
"// Success, so save the results",
"$",
"sql_data_array",
"=",
"array",
"(",
"'orders_id'",
"=>",
"(",
"int",
")",
"$",
"oID",
",",
"'orders_status_id'",
"=>",
"(",
"int",
")",
"$",
"new_order_status",
",",
"'date_added'",
"=>",
"'now()'",
",",
"'comments'",
"=>",
"'VOIDED. Trans ID: '",
".",
"urldecode",
"(",
"$",
"response",
"[",
"'AUTHORIZATIONID'",
"]",
")",
".",
"$",
"response",
"[",
"'PNREF'",
"]",
".",
"(",
"isset",
"(",
"$",
"response",
"[",
"'PPREF'",
"]",
")",
"?",
"\"\\nPPRef: \"",
".",
"$",
"response",
"[",
"'PPREF'",
"]",
":",
"''",
")",
".",
"\"\\n\"",
".",
"$",
"voidNote",
",",
"'customer_notified'",
"=>",
"0",
")",
";",
"zen_db_perform",
"(",
"TABLE_ORDERS_STATUS_HISTORY",
",",
"$",
"sql_data_array",
")",
";",
"$",
"db",
"->",
"Execute",
"(",
"\"update \"",
".",
"TABLE_ORDERS",
".",
"\"\n set orders_status = '\"",
".",
"(",
"int",
")",
"$",
"new_order_status",
".",
"\"'\n where orders_id = '\"",
".",
"(",
"int",
")",
"$",
"oID",
".",
"\"'\"",
")",
";",
"$",
"messageStack",
"->",
"add_session",
"(",
"sprintf",
"(",
"MODULE_PAYMENT_PAYPALDP_TEXT_VOID_INITIATED",
",",
"urldecode",
"(",
"$",
"response",
"[",
"'AUTHORIZATIONID'",
"]",
")",
".",
"$",
"response",
"[",
"'PNREF'",
"]",
")",
",",
"'success'",
")",
";",
"return",
"true",
";",
"}",
"}",
"}"
] |
Used to void a given previously-authorized transaction. FOR FUTURE USE.
|
[
"Used",
"to",
"void",
"a",
"given",
"previously",
"-",
"authorized",
"transaction",
".",
"FOR",
"FUTURE",
"USE",
"."
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/modules/payment/paypaldp.php#L1309-L1352
|
230,151
|
ZenMagick/ZenCart
|
includes/modules/payment/paypaldp.php
|
paypaldp.clear_3DSecure_session_vars
|
function clear_3DSecure_session_vars($thorough = FALSE) {
if ($thorough) {
if (isset($_SESSION['3Dsecure_requires_lookup'])) unset($_SESSION['3Dsecure_requires_lookup']);
if (isset($_SESSION['3Dsecure_card_type'])) unset($_SESSION['3Dsecure_card_type']);
}
if (isset($_SESSION['3Dsecure_merchantData'])) unset($_SESSION['3Dsecure_merchantData']);
if (isset($_SESSION['3Dsecure_enroll_lookup_attempted'])) unset($_SESSION['3Dsecure_enroll_lookup_attempted']);
if (isset($_SESSION['3Dsecure_authentication_attempted'])) unset($_SESSION['3Dsecure_authentication_attempted']);
if (isset($_SESSION['3Dsecure_transactionId'])) unset($_SESSION['3Dsecure_transactionId']);
if (isset($_SESSION['3Dsecure_enrolled'])) unset($_SESSION['3Dsecure_enrolled']);
if (isset($_SESSION['3Dsecure_acsURL'])) unset($_SESSION['3Dsecure_acsURL']);
if (isset($_SESSION['3Dsecure_payload'])) unset($_SESSION['3Dsecure_payload']);
if (isset($_SESSION['3Dsecure_auth_status'])) unset($_SESSION['3Dsecure_auth_status']);
if (isset($_SESSION['3Dsecure_sig_status'])) unset($_SESSION['3Dsecure_sig_status']);
if (isset($_SESSION['3Dsecure_auth_xid'])) unset($_SESSION['3Dsecure_auth_xid']);
if (isset($_SESSION['3Dsecure_auth_cavv'])) unset($_SESSION['3Dsecure_auth_cavv']);
if (isset($_SESSION['3Dsecure_auth_eci'])) unset($_SESSION['3Dsecure_auth_eci']);
if (isset($_SESSION['3Dsecure_term_url'])) unset($_SESSION['3Dsecure_term_url']);
if (isset($_SESSION['3Dsecure_auth_url'])) unset($_SESSION['3Dsecure_auth_url']);
}
|
php
|
function clear_3DSecure_session_vars($thorough = FALSE) {
if ($thorough) {
if (isset($_SESSION['3Dsecure_requires_lookup'])) unset($_SESSION['3Dsecure_requires_lookup']);
if (isset($_SESSION['3Dsecure_card_type'])) unset($_SESSION['3Dsecure_card_type']);
}
if (isset($_SESSION['3Dsecure_merchantData'])) unset($_SESSION['3Dsecure_merchantData']);
if (isset($_SESSION['3Dsecure_enroll_lookup_attempted'])) unset($_SESSION['3Dsecure_enroll_lookup_attempted']);
if (isset($_SESSION['3Dsecure_authentication_attempted'])) unset($_SESSION['3Dsecure_authentication_attempted']);
if (isset($_SESSION['3Dsecure_transactionId'])) unset($_SESSION['3Dsecure_transactionId']);
if (isset($_SESSION['3Dsecure_enrolled'])) unset($_SESSION['3Dsecure_enrolled']);
if (isset($_SESSION['3Dsecure_acsURL'])) unset($_SESSION['3Dsecure_acsURL']);
if (isset($_SESSION['3Dsecure_payload'])) unset($_SESSION['3Dsecure_payload']);
if (isset($_SESSION['3Dsecure_auth_status'])) unset($_SESSION['3Dsecure_auth_status']);
if (isset($_SESSION['3Dsecure_sig_status'])) unset($_SESSION['3Dsecure_sig_status']);
if (isset($_SESSION['3Dsecure_auth_xid'])) unset($_SESSION['3Dsecure_auth_xid']);
if (isset($_SESSION['3Dsecure_auth_cavv'])) unset($_SESSION['3Dsecure_auth_cavv']);
if (isset($_SESSION['3Dsecure_auth_eci'])) unset($_SESSION['3Dsecure_auth_eci']);
if (isset($_SESSION['3Dsecure_term_url'])) unset($_SESSION['3Dsecure_term_url']);
if (isset($_SESSION['3Dsecure_auth_url'])) unset($_SESSION['3Dsecure_auth_url']);
}
|
[
"function",
"clear_3DSecure_session_vars",
"(",
"$",
"thorough",
"=",
"FALSE",
")",
"{",
"if",
"(",
"$",
"thorough",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_requires_lookup'",
"]",
")",
")",
"unset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_requires_lookup'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_card_type'",
"]",
")",
")",
"unset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_card_type'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_merchantData'",
"]",
")",
")",
"unset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_merchantData'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_enroll_lookup_attempted'",
"]",
")",
")",
"unset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_enroll_lookup_attempted'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_authentication_attempted'",
"]",
")",
")",
"unset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_authentication_attempted'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_transactionId'",
"]",
")",
")",
"unset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_transactionId'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_enrolled'",
"]",
")",
")",
"unset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_enrolled'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_acsURL'",
"]",
")",
")",
"unset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_acsURL'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_payload'",
"]",
")",
")",
"unset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_payload'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_auth_status'",
"]",
")",
")",
"unset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_auth_status'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_sig_status'",
"]",
")",
")",
"unset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_sig_status'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_auth_xid'",
"]",
")",
")",
"unset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_auth_xid'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_auth_cavv'",
"]",
")",
")",
"unset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_auth_cavv'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_auth_eci'",
"]",
")",
")",
"unset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_auth_eci'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_term_url'",
"]",
")",
")",
"unset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_term_url'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_auth_url'",
"]",
")",
")",
"unset",
"(",
"$",
"_SESSION",
"[",
"'3Dsecure_auth_url'",
"]",
")",
";",
"}"
] |
reset session vars related to 3D-Secure processing
|
[
"reset",
"session",
"vars",
"related",
"to",
"3D",
"-",
"Secure",
"processing"
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/modules/payment/paypaldp.php#L2030-L2049
|
230,152
|
ZenMagick/ZenCart
|
includes/modules/payment/paypaldp.php
|
paypaldp.getISOCurrency
|
function getISOCurrency($curr) {
$out = "";
if(ctype_digit($curr) || is_int($curr)) {
$numCurr = $curr + 0;
if($numCurr < 10) {
$out = "00" . $numCurr;
} else if ($numCurr < 100) {
$out = "0" . $numCurr;
} else {
//Assume 3 digits (if greater let MAPs handle error)
$out = "" . $numCurr;
}
} else {
// Convert char to digit
$curCode = Array();
$curCode["AUD"]="036";
$curCode["CAD"]="124";
$curCode["CHF"]="756";
$curCode["CZK"]="203";
$curCode["DKK"]="208";
$curCode["EUR"]="978";
$curCode["GBP"]="826";
$curCode["HUF"]="348";
$curCode["JPY"]="392";
$curCode["NOK"]="578";
$curCode["NZD"]="554";
$curCode["PLN"]="985";
$curCode["SEK"]="752";
$curCode["SGD"]="702";
$curCode["USD"]="840";
$out = $curCode[$curr];
}
return $out;
}
|
php
|
function getISOCurrency($curr) {
$out = "";
if(ctype_digit($curr) || is_int($curr)) {
$numCurr = $curr + 0;
if($numCurr < 10) {
$out = "00" . $numCurr;
} else if ($numCurr < 100) {
$out = "0" . $numCurr;
} else {
//Assume 3 digits (if greater let MAPs handle error)
$out = "" . $numCurr;
}
} else {
// Convert char to digit
$curCode = Array();
$curCode["AUD"]="036";
$curCode["CAD"]="124";
$curCode["CHF"]="756";
$curCode["CZK"]="203";
$curCode["DKK"]="208";
$curCode["EUR"]="978";
$curCode["GBP"]="826";
$curCode["HUF"]="348";
$curCode["JPY"]="392";
$curCode["NOK"]="578";
$curCode["NZD"]="554";
$curCode["PLN"]="985";
$curCode["SEK"]="752";
$curCode["SGD"]="702";
$curCode["USD"]="840";
$out = $curCode[$curr];
}
return $out;
}
|
[
"function",
"getISOCurrency",
"(",
"$",
"curr",
")",
"{",
"$",
"out",
"=",
"\"\"",
";",
"if",
"(",
"ctype_digit",
"(",
"$",
"curr",
")",
"||",
"is_int",
"(",
"$",
"curr",
")",
")",
"{",
"$",
"numCurr",
"=",
"$",
"curr",
"+",
"0",
";",
"if",
"(",
"$",
"numCurr",
"<",
"10",
")",
"{",
"$",
"out",
"=",
"\"00\"",
".",
"$",
"numCurr",
";",
"}",
"else",
"if",
"(",
"$",
"numCurr",
"<",
"100",
")",
"{",
"$",
"out",
"=",
"\"0\"",
".",
"$",
"numCurr",
";",
"}",
"else",
"{",
"//Assume 3 digits (if greater let MAPs handle error)",
"$",
"out",
"=",
"\"\"",
".",
"$",
"numCurr",
";",
"}",
"}",
"else",
"{",
"// Convert char to digit",
"$",
"curCode",
"=",
"Array",
"(",
")",
";",
"$",
"curCode",
"[",
"\"AUD\"",
"]",
"=",
"\"036\"",
";",
"$",
"curCode",
"[",
"\"CAD\"",
"]",
"=",
"\"124\"",
";",
"$",
"curCode",
"[",
"\"CHF\"",
"]",
"=",
"\"756\"",
";",
"$",
"curCode",
"[",
"\"CZK\"",
"]",
"=",
"\"203\"",
";",
"$",
"curCode",
"[",
"\"DKK\"",
"]",
"=",
"\"208\"",
";",
"$",
"curCode",
"[",
"\"EUR\"",
"]",
"=",
"\"978\"",
";",
"$",
"curCode",
"[",
"\"GBP\"",
"]",
"=",
"\"826\"",
";",
"$",
"curCode",
"[",
"\"HUF\"",
"]",
"=",
"\"348\"",
";",
"$",
"curCode",
"[",
"\"JPY\"",
"]",
"=",
"\"392\"",
";",
"$",
"curCode",
"[",
"\"NOK\"",
"]",
"=",
"\"578\"",
";",
"$",
"curCode",
"[",
"\"NZD\"",
"]",
"=",
"\"554\"",
";",
"$",
"curCode",
"[",
"\"PLN\"",
"]",
"=",
"\"985\"",
";",
"$",
"curCode",
"[",
"\"SEK\"",
"]",
"=",
"\"752\"",
";",
"$",
"curCode",
"[",
"\"SGD\"",
"]",
"=",
"\"702\"",
";",
"$",
"curCode",
"[",
"\"USD\"",
"]",
"=",
"\"840\"",
";",
"$",
"out",
"=",
"$",
"curCode",
"[",
"$",
"curr",
"]",
";",
"}",
"return",
"$",
"out",
";",
"}"
] |
MAPs will return the appropriate error code.
|
[
"MAPs",
"will",
"return",
"the",
"appropriate",
"error",
"code",
"."
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/modules/payment/paypaldp.php#L2403-L2437
|
230,153
|
ZenMagick/ZenCart
|
includes/modules/payment/paypaldp.php
|
paypaldp.formatRawAmount
|
function formatRawAmount($amount, $curr) {
$dblAmount = $amount + 0.0;
// Build Currency format table
$curFormat = Array();
$curFormat["036"]=2;
$curFormat["124"]=2;
$curFormat["203"]=2;
$curFormat["208"]=2;
$curFormat["348"]=2;
$curFormat["392"]=0;
$curFormat["554"]=2;
$curFormat["578"]=2;
$curFormat["702"]=2;
$curFormat["752"]=2;
$curFormat["756"]=2;
$curFormat["826"]=2;
$curFormat["840"]=2;
$curFormat["978"]=2;
$curFormat["985"]=2;
$digCurr = $this->getISOCurrency("" . $curr);
$exponent = $curFormat[$digCurr];
$strAmount = "" . Round($dblAmount, $exponent);
$strRetVal = "" . $strAmount;
// decimal position
$curpos = strpos($strRetVal, ".");
// Pad with zeros
if($curpos == true) {
$padCount = $exponent - (strlen($strRetVal) - $curpos - 1);
for($i=0;$i<$padCount;$i++) {
$strRetVal .= "0";
}
} else {
$padCount = $exponent;
for($i=0;$i<$padCount;$i++) {
$strRetVal .= "0";
}
}
if($curpos !== false) {
$strRetVal = substr($strRetVal, 0, $curpos) . substr($strRetVal, $curpos+1);
}
return $strRetVal;
}
|
php
|
function formatRawAmount($amount, $curr) {
$dblAmount = $amount + 0.0;
// Build Currency format table
$curFormat = Array();
$curFormat["036"]=2;
$curFormat["124"]=2;
$curFormat["203"]=2;
$curFormat["208"]=2;
$curFormat["348"]=2;
$curFormat["392"]=0;
$curFormat["554"]=2;
$curFormat["578"]=2;
$curFormat["702"]=2;
$curFormat["752"]=2;
$curFormat["756"]=2;
$curFormat["826"]=2;
$curFormat["840"]=2;
$curFormat["978"]=2;
$curFormat["985"]=2;
$digCurr = $this->getISOCurrency("" . $curr);
$exponent = $curFormat[$digCurr];
$strAmount = "" . Round($dblAmount, $exponent);
$strRetVal = "" . $strAmount;
// decimal position
$curpos = strpos($strRetVal, ".");
// Pad with zeros
if($curpos == true) {
$padCount = $exponent - (strlen($strRetVal) - $curpos - 1);
for($i=0;$i<$padCount;$i++) {
$strRetVal .= "0";
}
} else {
$padCount = $exponent;
for($i=0;$i<$padCount;$i++) {
$strRetVal .= "0";
}
}
if($curpos !== false) {
$strRetVal = substr($strRetVal, 0, $curpos) . substr($strRetVal, $curpos+1);
}
return $strRetVal;
}
|
[
"function",
"formatRawAmount",
"(",
"$",
"amount",
",",
"$",
"curr",
")",
"{",
"$",
"dblAmount",
"=",
"$",
"amount",
"+",
"0.0",
";",
"// Build Currency format table",
"$",
"curFormat",
"=",
"Array",
"(",
")",
";",
"$",
"curFormat",
"[",
"\"036\"",
"]",
"=",
"2",
";",
"$",
"curFormat",
"[",
"\"124\"",
"]",
"=",
"2",
";",
"$",
"curFormat",
"[",
"\"203\"",
"]",
"=",
"2",
";",
"$",
"curFormat",
"[",
"\"208\"",
"]",
"=",
"2",
";",
"$",
"curFormat",
"[",
"\"348\"",
"]",
"=",
"2",
";",
"$",
"curFormat",
"[",
"\"392\"",
"]",
"=",
"0",
";",
"$",
"curFormat",
"[",
"\"554\"",
"]",
"=",
"2",
";",
"$",
"curFormat",
"[",
"\"578\"",
"]",
"=",
"2",
";",
"$",
"curFormat",
"[",
"\"702\"",
"]",
"=",
"2",
";",
"$",
"curFormat",
"[",
"\"752\"",
"]",
"=",
"2",
";",
"$",
"curFormat",
"[",
"\"756\"",
"]",
"=",
"2",
";",
"$",
"curFormat",
"[",
"\"826\"",
"]",
"=",
"2",
";",
"$",
"curFormat",
"[",
"\"840\"",
"]",
"=",
"2",
";",
"$",
"curFormat",
"[",
"\"978\"",
"]",
"=",
"2",
";",
"$",
"curFormat",
"[",
"\"985\"",
"]",
"=",
"2",
";",
"$",
"digCurr",
"=",
"$",
"this",
"->",
"getISOCurrency",
"(",
"\"\"",
".",
"$",
"curr",
")",
";",
"$",
"exponent",
"=",
"$",
"curFormat",
"[",
"$",
"digCurr",
"]",
";",
"$",
"strAmount",
"=",
"\"\"",
".",
"Round",
"(",
"$",
"dblAmount",
",",
"$",
"exponent",
")",
";",
"$",
"strRetVal",
"=",
"\"\"",
".",
"$",
"strAmount",
";",
"// decimal position",
"$",
"curpos",
"=",
"strpos",
"(",
"$",
"strRetVal",
",",
"\".\"",
")",
";",
"// Pad with zeros",
"if",
"(",
"$",
"curpos",
"==",
"true",
")",
"{",
"$",
"padCount",
"=",
"$",
"exponent",
"-",
"(",
"strlen",
"(",
"$",
"strRetVal",
")",
"-",
"$",
"curpos",
"-",
"1",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"padCount",
";",
"$",
"i",
"++",
")",
"{",
"$",
"strRetVal",
".=",
"\"0\"",
";",
"}",
"}",
"else",
"{",
"$",
"padCount",
"=",
"$",
"exponent",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"padCount",
";",
"$",
"i",
"++",
")",
"{",
"$",
"strRetVal",
".=",
"\"0\"",
";",
"}",
"}",
"if",
"(",
"$",
"curpos",
"!==",
"false",
")",
"{",
"$",
"strRetVal",
"=",
"substr",
"(",
"$",
"strRetVal",
",",
"0",
",",
"$",
"curpos",
")",
".",
"substr",
"(",
"$",
"strRetVal",
",",
"$",
"curpos",
"+",
"1",
")",
";",
"}",
"return",
"$",
"strRetVal",
";",
"}"
] |
curr - ISO4217 Currency code, 3char or 3digit
|
[
"curr",
"-",
"ISO4217",
"Currency",
"code",
"3char",
"or",
"3digit"
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/modules/payment/paypaldp.php#L2444-L2490
|
230,154
|
addiks/phpsql
|
src/Addiks/PHPSQL/Table/TableSchema.php
|
TableSchema.getCellPositionInPage
|
public function getCellPositionInPage($columnId)
{
if (count($this->columnPositionCache)<=0) {
$this->getRowPageSize();
}
if (!isset($this->columnPositionCache[$columnId])) {
throw new ErrorException("Tableschema has no column at index {$columnId}!");
}
return $this->columnPositionCache[$columnId];
}
|
php
|
public function getCellPositionInPage($columnId)
{
if (count($this->columnPositionCache)<=0) {
$this->getRowPageSize();
}
if (!isset($this->columnPositionCache[$columnId])) {
throw new ErrorException("Tableschema has no column at index {$columnId}!");
}
return $this->columnPositionCache[$columnId];
}
|
[
"public",
"function",
"getCellPositionInPage",
"(",
"$",
"columnId",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"columnPositionCache",
")",
"<=",
"0",
")",
"{",
"$",
"this",
"->",
"getRowPageSize",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"columnPositionCache",
"[",
"$",
"columnId",
"]",
")",
")",
"{",
"throw",
"new",
"ErrorException",
"(",
"\"Tableschema has no column at index {$columnId}!\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"columnPositionCache",
"[",
"$",
"columnId",
"]",
";",
"}"
] |
Gets the position in a row-page-data where a cell for a given column starts.
@param string
|
[
"Gets",
"the",
"position",
"in",
"a",
"row",
"-",
"page",
"-",
"data",
"where",
"a",
"cell",
"for",
"a",
"given",
"column",
"starts",
"."
] |
28dae64ffc2123f39f801a50ab53bfe29890cbd9
|
https://github.com/addiks/phpsql/blob/28dae64ffc2123f39f801a50ab53bfe29890cbd9/src/Addiks/PHPSQL/Table/TableSchema.php#L476-L488
|
230,155
|
deanblackborough/zf3-view-helpers
|
src/Bootstrap3Label.php
|
Bootstrap3Label.setStyle
|
public function setStyle(string $style): Bootstrap3Label
{
if (in_array($style, $this->supported_styles) === true) {
$this->style = $style;
} else {
$this->style = 'default';
}
return $this;
}
|
php
|
public function setStyle(string $style): Bootstrap3Label
{
if (in_array($style, $this->supported_styles) === true) {
$this->style = $style;
} else {
$this->style = 'default';
}
return $this;
}
|
[
"public",
"function",
"setStyle",
"(",
"string",
"$",
"style",
")",
":",
"Bootstrap3Label",
"{",
"if",
"(",
"in_array",
"(",
"$",
"style",
",",
"$",
"this",
"->",
"supported_styles",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"style",
"=",
"$",
"style",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"style",
"=",
"'default'",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set the style for the badge, one of the following, default, primary, success,
info, warning or danger. If an incorrect style is passed in we set the style to
label-default
@param string $style
@return Bootstrap3Label
|
[
"Set",
"the",
"style",
"for",
"the",
"badge",
"one",
"of",
"the",
"following",
"default",
"primary",
"success",
"info",
"warning",
"or",
"danger",
".",
"If",
"an",
"incorrect",
"style",
"is",
"passed",
"in",
"we",
"set",
"the",
"style",
"to",
"label",
"-",
"default"
] |
db8bea4ca62709b2ac8c732aedbb2a5235223f23
|
https://github.com/deanblackborough/zf3-view-helpers/blob/db8bea4ca62709b2ac8c732aedbb2a5235223f23/src/Bootstrap3Label.php#L65-L74
|
230,156
|
DevFactoryCH/imagecache
|
src/Imagecache.php
|
Imagecache.sanitizeDirectoryName
|
protected function sanitizeDirectoryName($name, $keep_leading_slash = FALSE) {
if (!$keep_leading_slash) {
$name = ltrim($name, '/\\');
}
return rtrim($name, '/\\') . '/';
}
|
php
|
protected function sanitizeDirectoryName($name, $keep_leading_slash = FALSE) {
if (!$keep_leading_slash) {
$name = ltrim($name, '/\\');
}
return rtrim($name, '/\\') . '/';
}
|
[
"protected",
"function",
"sanitizeDirectoryName",
"(",
"$",
"name",
",",
"$",
"keep_leading_slash",
"=",
"FALSE",
")",
"{",
"if",
"(",
"!",
"$",
"keep_leading_slash",
")",
"{",
"$",
"name",
"=",
"ltrim",
"(",
"$",
"name",
",",
"'/\\\\'",
")",
";",
"}",
"return",
"rtrim",
"(",
"$",
"name",
",",
"'/\\\\'",
")",
".",
"'/'",
";",
"}"
] |
Cleanup paths so that they all have a trailing slash, and
optional leading slash
@param $name string
The path to sanitize
@param $keep_leading_slash bool
TRUE to keep the leading /, otherwise FALSE
@return string
The sanitized path
|
[
"Cleanup",
"paths",
"so",
"that",
"they",
"all",
"have",
"a",
"trailing",
"slash",
"and",
"optional",
"leading",
"slash"
] |
73783d14f40d01d8bdb2385256d244521340b92b
|
https://github.com/DevFactoryCH/imagecache/blob/73783d14f40d01d8bdb2385256d244521340b92b/src/Imagecache.php#L149-L155
|
230,157
|
DevFactoryCH/imagecache
|
src/Imagecache.php
|
Imagecache.get
|
public function get($file, $preset, $args = NULL) {
$this->file = $file;
if (!$this->setFilename()) {
return $this->image_element_empty();
}
if (!$this->setPreset($preset)) {
return $this->image_element_empty();
}
$this->setupArguments($args);
if (!$this->image_exists()) {
return $this->image_element_empty();
}
if (!$this->is_image()) {
return $this->image_element_empty();
}
if ($this->is_svg()) {
return (object) $this->image_element_original();
}
if (!$this->generate_cached_image()) {
return $this->image_element_empty();
}
return (object) $this->image_element();
}
|
php
|
public function get($file, $preset, $args = NULL) {
$this->file = $file;
if (!$this->setFilename()) {
return $this->image_element_empty();
}
if (!$this->setPreset($preset)) {
return $this->image_element_empty();
}
$this->setupArguments($args);
if (!$this->image_exists()) {
return $this->image_element_empty();
}
if (!$this->is_image()) {
return $this->image_element_empty();
}
if ($this->is_svg()) {
return (object) $this->image_element_original();
}
if (!$this->generate_cached_image()) {
return $this->image_element_empty();
}
return (object) $this->image_element();
}
|
[
"public",
"function",
"get",
"(",
"$",
"file",
",",
"$",
"preset",
",",
"$",
"args",
"=",
"NULL",
")",
"{",
"$",
"this",
"->",
"file",
"=",
"$",
"file",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"setFilename",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"image_element_empty",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"setPreset",
"(",
"$",
"preset",
")",
")",
"{",
"return",
"$",
"this",
"->",
"image_element_empty",
"(",
")",
";",
"}",
"$",
"this",
"->",
"setupArguments",
"(",
"$",
"args",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"image_exists",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"image_element_empty",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"is_image",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"image_element_empty",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"is_svg",
"(",
")",
")",
"{",
"return",
"(",
"object",
")",
"$",
"this",
"->",
"image_element_original",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"generate_cached_image",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"image_element_empty",
"(",
")",
";",
"}",
"return",
"(",
"object",
")",
"$",
"this",
"->",
"image_element",
"(",
")",
";",
"}"
] |
Called by script to get the image information, performs all required steps
@param $file mixed
Object/array/string to check for a filename
@param $preset string
The name of the preset, must be one of the presets in config/presets.php
@return array
Containing the cached image src, img, and others
|
[
"Called",
"by",
"script",
"to",
"get",
"the",
"image",
"information",
"performs",
"all",
"required",
"steps"
] |
73783d14f40d01d8bdb2385256d244521340b92b
|
https://github.com/DevFactoryCH/imagecache/blob/73783d14f40d01d8bdb2385256d244521340b92b/src/Imagecache.php#L169-L199
|
230,158
|
DevFactoryCH/imagecache
|
src/Imagecache.php
|
Imagecache.get_original
|
public function get_original($file, $args = NULL) {
$this->file = $file;
if (!$this->setFilename()) {
return $this->image_element_empty();
}
$this->setupArguments($args);
return $this->image_element_original();
}
|
php
|
public function get_original($file, $args = NULL) {
$this->file = $file;
if (!$this->setFilename()) {
return $this->image_element_empty();
}
$this->setupArguments($args);
return $this->image_element_original();
}
|
[
"public",
"function",
"get_original",
"(",
"$",
"file",
",",
"$",
"args",
"=",
"NULL",
")",
"{",
"$",
"this",
"->",
"file",
"=",
"$",
"file",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"setFilename",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"image_element_empty",
"(",
")",
";",
"}",
"$",
"this",
"->",
"setupArguments",
"(",
"$",
"args",
")",
";",
"return",
"$",
"this",
"->",
"image_element_original",
"(",
")",
";",
"}"
] |
Get the imagecache array for an empty image
@param $file mixed
Object/array/string to check for a filename
@return array
An array containing to different image setups
|
[
"Get",
"the",
"imagecache",
"array",
"for",
"an",
"empty",
"image"
] |
73783d14f40d01d8bdb2385256d244521340b92b
|
https://github.com/DevFactoryCH/imagecache/blob/73783d14f40d01d8bdb2385256d244521340b92b/src/Imagecache.php#L210-L220
|
230,159
|
DevFactoryCH/imagecache
|
src/Imagecache.php
|
Imagecache.setPreset
|
protected function setPreset($preset) {
if (!$this->validate_preset($preset)) {
return FALSE;
}
$presets = $this->get_presets();
$this->preset = (object) $presets[$preset];
$this->preset->name = $preset;
return TRUE;
}
|
php
|
protected function setPreset($preset) {
if (!$this->validate_preset($preset)) {
return FALSE;
}
$presets = $this->get_presets();
$this->preset = (object) $presets[$preset];
$this->preset->name = $preset;
return TRUE;
}
|
[
"protected",
"function",
"setPreset",
"(",
"$",
"preset",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validate_preset",
"(",
"$",
"preset",
")",
")",
"{",
"return",
"FALSE",
";",
"}",
"$",
"presets",
"=",
"$",
"this",
"->",
"get_presets",
"(",
")",
";",
"$",
"this",
"->",
"preset",
"=",
"(",
"object",
")",
"$",
"presets",
"[",
"$",
"preset",
"]",
";",
"$",
"this",
"->",
"preset",
"->",
"name",
"=",
"$",
"preset",
";",
"return",
"TRUE",
";",
"}"
] |
Extract preset information from config file according to that chosen by the user
@param string $preset
The preset string
@return bool
|
[
"Extract",
"preset",
"information",
"from",
"config",
"file",
"according",
"to",
"that",
"chosen",
"by",
"the",
"user"
] |
73783d14f40d01d8bdb2385256d244521340b92b
|
https://github.com/DevFactoryCH/imagecache/blob/73783d14f40d01d8bdb2385256d244521340b92b/src/Imagecache.php#L230-L240
|
230,160
|
DevFactoryCH/imagecache
|
src/Imagecache.php
|
Imagecache.setFilename
|
protected function setFilename() {
if (is_object($this->file)) {
if (!isset($this->file->{$this->filename_field})) {
return FALSE;
}
$this->file_name = $this->file->{$this->filename_field};
return TRUE;
}
if (is_array($this->file)) {
$this->file_name = $field[$this->filename_field];
return TRUE;
}
if (is_string($this->file)) {
$this->file_name = $this->file;
return TRUE;
}
return FALSE;
}
|
php
|
protected function setFilename() {
if (is_object($this->file)) {
if (!isset($this->file->{$this->filename_field})) {
return FALSE;
}
$this->file_name = $this->file->{$this->filename_field};
return TRUE;
}
if (is_array($this->file)) {
$this->file_name = $field[$this->filename_field];
return TRUE;
}
if (is_string($this->file)) {
$this->file_name = $this->file;
return TRUE;
}
return FALSE;
}
|
[
"protected",
"function",
"setFilename",
"(",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"this",
"->",
"file",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"file",
"->",
"{",
"$",
"this",
"->",
"filename_field",
"}",
")",
")",
"{",
"return",
"FALSE",
";",
"}",
"$",
"this",
"->",
"file_name",
"=",
"$",
"this",
"->",
"file",
"->",
"{",
"$",
"this",
"->",
"filename_field",
"}",
";",
"return",
"TRUE",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"file",
")",
")",
"{",
"$",
"this",
"->",
"file_name",
"=",
"$",
"field",
"[",
"$",
"this",
"->",
"filename_field",
"]",
";",
"return",
"TRUE",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"this",
"->",
"file",
")",
")",
"{",
"$",
"this",
"->",
"file_name",
"=",
"$",
"this",
"->",
"file",
";",
"return",
"TRUE",
";",
"}",
"return",
"FALSE",
";",
"}"
] |
Take the passed file and check it to retrieve a filename
@return bool
TRUE if $this->filename set, otherwise FALSE
|
[
"Take",
"the",
"passed",
"file",
"and",
"check",
"it",
"to",
"retrieve",
"a",
"filename"
] |
73783d14f40d01d8bdb2385256d244521340b92b
|
https://github.com/DevFactoryCH/imagecache/blob/73783d14f40d01d8bdb2385256d244521340b92b/src/Imagecache.php#L248-L269
|
230,161
|
DevFactoryCH/imagecache
|
src/Imagecache.php
|
Imagecache.setupArguments
|
protected function setupArguments($args) {
$this->upload_path = (isset($args['base_dir']) ? $args['base_dir'] : $this->public_path . $this->upload_uri);
$this->class = (isset($args['class']) ? $args['class'] : NULL);
$this->alt = isset($args['alt']) ? $args['alt'] : $this->parseAlt();
$this->title = isset($args['title']) ? $args['title'] : $this->parseTitle();
}
|
php
|
protected function setupArguments($args) {
$this->upload_path = (isset($args['base_dir']) ? $args['base_dir'] : $this->public_path . $this->upload_uri);
$this->class = (isset($args['class']) ? $args['class'] : NULL);
$this->alt = isset($args['alt']) ? $args['alt'] : $this->parseAlt();
$this->title = isset($args['title']) ? $args['title'] : $this->parseTitle();
}
|
[
"protected",
"function",
"setupArguments",
"(",
"$",
"args",
")",
"{",
"$",
"this",
"->",
"upload_path",
"=",
"(",
"isset",
"(",
"$",
"args",
"[",
"'base_dir'",
"]",
")",
"?",
"$",
"args",
"[",
"'base_dir'",
"]",
":",
"$",
"this",
"->",
"public_path",
".",
"$",
"this",
"->",
"upload_uri",
")",
";",
"$",
"this",
"->",
"class",
"=",
"(",
"isset",
"(",
"$",
"args",
"[",
"'class'",
"]",
")",
"?",
"$",
"args",
"[",
"'class'",
"]",
":",
"NULL",
")",
";",
"$",
"this",
"->",
"alt",
"=",
"isset",
"(",
"$",
"args",
"[",
"'alt'",
"]",
")",
"?",
"$",
"args",
"[",
"'alt'",
"]",
":",
"$",
"this",
"->",
"parseAlt",
"(",
")",
";",
"$",
"this",
"->",
"title",
"=",
"isset",
"(",
"$",
"args",
"[",
"'title'",
"]",
")",
"?",
"$",
"args",
"[",
"'title'",
"]",
":",
"$",
"this",
"->",
"parseTitle",
"(",
")",
";",
"}"
] |
Parse the passed arguments and set the instance variables
@param $args array
An array of optional parameters as a key => value pair
@return void
|
[
"Parse",
"the",
"passed",
"arguments",
"and",
"set",
"the",
"instance",
"variables"
] |
73783d14f40d01d8bdb2385256d244521340b92b
|
https://github.com/DevFactoryCH/imagecache/blob/73783d14f40d01d8bdb2385256d244521340b92b/src/Imagecache.php#L279-L284
|
230,162
|
DevFactoryCH/imagecache
|
src/Imagecache.php
|
Imagecache.parseAlt
|
protected function parseAlt() {
if (is_object($this->file)) {
if (isset($this->file->alt)) {
return $this->file->alt;
}
}
if (is_array($this->file)) {
if (isset($this->file['alt'])) {
return $this->file['alt'];
}
}
return '';
}
|
php
|
protected function parseAlt() {
if (is_object($this->file)) {
if (isset($this->file->alt)) {
return $this->file->alt;
}
}
if (is_array($this->file)) {
if (isset($this->file['alt'])) {
return $this->file['alt'];
}
}
return '';
}
|
[
"protected",
"function",
"parseAlt",
"(",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"this",
"->",
"file",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"file",
"->",
"alt",
")",
")",
"{",
"return",
"$",
"this",
"->",
"file",
"->",
"alt",
";",
"}",
"}",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"file",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"file",
"[",
"'alt'",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"file",
"[",
"'alt'",
"]",
";",
"}",
"}",
"return",
"''",
";",
"}"
] |
If the file received is an object or array, check if the 'alt' field is set
@return string
|
[
"If",
"the",
"file",
"received",
"is",
"an",
"object",
"or",
"array",
"check",
"if",
"the",
"alt",
"field",
"is",
"set"
] |
73783d14f40d01d8bdb2385256d244521340b92b
|
https://github.com/DevFactoryCH/imagecache/blob/73783d14f40d01d8bdb2385256d244521340b92b/src/Imagecache.php#L291-L305
|
230,163
|
DevFactoryCH/imagecache
|
src/Imagecache.php
|
Imagecache.parseTitle
|
protected function parseTitle() {
if (is_object($this->file)) {
if (isset($this->file->title)) {
return $this->file->title;
}
}
if (is_array($this->file)) {
if (isset($this->file['title'])) {
return $this->file['title'];
}
}
return '';
}
|
php
|
protected function parseTitle() {
if (is_object($this->file)) {
if (isset($this->file->title)) {
return $this->file->title;
}
}
if (is_array($this->file)) {
if (isset($this->file['title'])) {
return $this->file['title'];
}
}
return '';
}
|
[
"protected",
"function",
"parseTitle",
"(",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"this",
"->",
"file",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"file",
"->",
"title",
")",
")",
"{",
"return",
"$",
"this",
"->",
"file",
"->",
"title",
";",
"}",
"}",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"file",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"file",
"[",
"'title'",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"file",
"[",
"'title'",
"]",
";",
"}",
"}",
"return",
"''",
";",
"}"
] |
If the file received is an object or array, check if the 'title' field is set
@return string
|
[
"If",
"the",
"file",
"received",
"is",
"an",
"object",
"or",
"array",
"check",
"if",
"the",
"title",
"field",
"is",
"set"
] |
73783d14f40d01d8bdb2385256d244521340b92b
|
https://github.com/DevFactoryCH/imagecache/blob/73783d14f40d01d8bdb2385256d244521340b92b/src/Imagecache.php#L312-L326
|
230,164
|
DevFactoryCH/imagecache
|
src/Imagecache.php
|
Imagecache.is_svg
|
protected function is_svg() {
$finfo = new \finfo(FILEINFO_MIME);
$type = $finfo->file($this->upload_path . $this->file_name);
if (str_contains($type, 'image/svg+xml')) {
return TRUE;
}
return FALSE;
}
|
php
|
protected function is_svg() {
$finfo = new \finfo(FILEINFO_MIME);
$type = $finfo->file($this->upload_path . $this->file_name);
if (str_contains($type, 'image/svg+xml')) {
return TRUE;
}
return FALSE;
}
|
[
"protected",
"function",
"is_svg",
"(",
")",
"{",
"$",
"finfo",
"=",
"new",
"\\",
"finfo",
"(",
"FILEINFO_MIME",
")",
";",
"$",
"type",
"=",
"$",
"finfo",
"->",
"file",
"(",
"$",
"this",
"->",
"upload_path",
".",
"$",
"this",
"->",
"file_name",
")",
";",
"if",
"(",
"str_contains",
"(",
"$",
"type",
",",
"'image/svg+xml'",
")",
")",
"{",
"return",
"TRUE",
";",
"}",
"return",
"FALSE",
";",
"}"
] |
Checks if we have an SVG image.
@return
TRUE if SVG and FALSE otherwise
|
[
"Checks",
"if",
"we",
"have",
"an",
"SVG",
"image",
"."
] |
73783d14f40d01d8bdb2385256d244521340b92b
|
https://github.com/DevFactoryCH/imagecache/blob/73783d14f40d01d8bdb2385256d244521340b92b/src/Imagecache.php#L373-L382
|
230,165
|
DevFactoryCH/imagecache
|
src/Imagecache.php
|
Imagecache.buildImage
|
protected function buildImage () {
$method = 'buildImage'. ucfirst($this->preset->method);
if (method_exists($this, $method)) {
return $this->{$method}();
}
return FALSE;
}
|
php
|
protected function buildImage () {
$method = 'buildImage'. ucfirst($this->preset->method);
if (method_exists($this, $method)) {
return $this->{$method}();
}
return FALSE;
}
|
[
"protected",
"function",
"buildImage",
"(",
")",
"{",
"$",
"method",
"=",
"'buildImage'",
".",
"ucfirst",
"(",
"$",
"this",
"->",
"preset",
"->",
"method",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
"{",
"return",
"$",
"this",
"->",
"{",
"$",
"method",
"}",
"(",
")",
";",
"}",
"return",
"FALSE",
";",
"}"
] |
Generates and calls the correct method for the generation method used in preset
@return mixed
FALSE if no matching method, otherwise the Image Object
|
[
"Generates",
"and",
"calls",
"the",
"correct",
"method",
"for",
"the",
"generation",
"method",
"used",
"in",
"preset"
] |
73783d14f40d01d8bdb2385256d244521340b92b
|
https://github.com/DevFactoryCH/imagecache/blob/73783d14f40d01d8bdb2385256d244521340b92b/src/Imagecache.php#L438-L445
|
230,166
|
DevFactoryCH/imagecache
|
src/Imagecache.php
|
Imagecache.buildImageResize
|
protected function buildImageResize() {
$image = Image::make($this->upload_path . $this->file_name)->orientate();
$image->resize($this->preset->width, $this->preset->height , function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
//if background_color is not set, do not resizeCanvas with black color, to avoid black zones in images.
if(isset($this->preset->background_color))
{
$image->resizeCanvas($this->preset->width, $this->preset->height, 'center', FALSE, $this->preset->background_color);
}
return $image;
}
|
php
|
protected function buildImageResize() {
$image = Image::make($this->upload_path . $this->file_name)->orientate();
$image->resize($this->preset->width, $this->preset->height , function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
//if background_color is not set, do not resizeCanvas with black color, to avoid black zones in images.
if(isset($this->preset->background_color))
{
$image->resizeCanvas($this->preset->width, $this->preset->height, 'center', FALSE, $this->preset->background_color);
}
return $image;
}
|
[
"protected",
"function",
"buildImageResize",
"(",
")",
"{",
"$",
"image",
"=",
"Image",
"::",
"make",
"(",
"$",
"this",
"->",
"upload_path",
".",
"$",
"this",
"->",
"file_name",
")",
"->",
"orientate",
"(",
")",
";",
"$",
"image",
"->",
"resize",
"(",
"$",
"this",
"->",
"preset",
"->",
"width",
",",
"$",
"this",
"->",
"preset",
"->",
"height",
",",
"function",
"(",
"$",
"constraint",
")",
"{",
"$",
"constraint",
"->",
"aspectRatio",
"(",
")",
";",
"$",
"constraint",
"->",
"upsize",
"(",
")",
";",
"}",
")",
";",
"//if background_color is not set, do not resizeCanvas with black color, to avoid black zones in images. ",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"preset",
"->",
"background_color",
")",
")",
"{",
"$",
"image",
"->",
"resizeCanvas",
"(",
"$",
"this",
"->",
"preset",
"->",
"width",
",",
"$",
"this",
"->",
"preset",
"->",
"height",
",",
"'center'",
",",
"FALSE",
",",
"$",
"this",
"->",
"preset",
"->",
"background_color",
")",
";",
"}",
"return",
"$",
"image",
";",
"}"
] |
Resize the image, contraining the aspect ratio and size
@return Image Object
|
[
"Resize",
"the",
"image",
"contraining",
"the",
"aspect",
"ratio",
"and",
"size"
] |
73783d14f40d01d8bdb2385256d244521340b92b
|
https://github.com/DevFactoryCH/imagecache/blob/73783d14f40d01d8bdb2385256d244521340b92b/src/Imagecache.php#L452-L467
|
230,167
|
DevFactoryCH/imagecache
|
src/Imagecache.php
|
Imagecache.delete_image
|
protected function delete_image() {
$presets = $this->get_presets();
foreach ($presets as $key => $preset) {
$file_name = $this->imagecache_path . $key .'/'. $this->file_name;
if (File::exists($file_name)) {
File::delete($file_name);
}
}
}
|
php
|
protected function delete_image() {
$presets = $this->get_presets();
foreach ($presets as $key => $preset) {
$file_name = $this->imagecache_path . $key .'/'. $this->file_name;
if (File::exists($file_name)) {
File::delete($file_name);
}
}
}
|
[
"protected",
"function",
"delete_image",
"(",
")",
"{",
"$",
"presets",
"=",
"$",
"this",
"->",
"get_presets",
"(",
")",
";",
"foreach",
"(",
"$",
"presets",
"as",
"$",
"key",
"=>",
"$",
"preset",
")",
"{",
"$",
"file_name",
"=",
"$",
"this",
"->",
"imagecache_path",
".",
"$",
"key",
".",
"'/'",
".",
"$",
"this",
"->",
"file_name",
";",
"if",
"(",
"File",
"::",
"exists",
"(",
"$",
"file_name",
")",
")",
"{",
"File",
"::",
"delete",
"(",
"$",
"file_name",
")",
";",
"}",
"}",
"}"
] |
Delete every image preset for one image
|
[
"Delete",
"every",
"image",
"preset",
"for",
"one",
"image"
] |
73783d14f40d01d8bdb2385256d244521340b92b
|
https://github.com/DevFactoryCH/imagecache/blob/73783d14f40d01d8bdb2385256d244521340b92b/src/Imagecache.php#L639-L648
|
230,168
|
naneau/semver
|
src/Naneau/SemVer/Compare.php
|
Compare.equals
|
public static function equals(Version $v1, Version $v2)
{
// Versionable part itself needs to be equal
if (!self::versionableEquals($v1, $v2)) {
return false;
}
// If only one has a pre-release, they're not equal
if ($v1->hasPreRelease() && !$v2->hasPreRelease()) {
return false;
}
if (!$v1->hasPreRelease() && $v2->hasPreRelease()) {
return false;
}
// See if pre-releases are equal if both versions have one
if ($v1->hasPreRelease() && $v2->hasPreRelease()) {
if (!self::preReleaseEquals($v1->getPreRelease(), $v2->getPreRelease())) {
return false;
}
}
// If only one has a build version, they're not equal
if (!$v1->hasBuild() && $v2->hasBuild()) {
return false;
}
if ($v1->hasBuild() && !$v2->hasBuild()) {
return false;
}
// Compare the build version
if ($v1->hasBuild() && $v2->hasBuild()) {
return self::buildEquals($v1->getBuild(), $v2->getBuild());
}
return true;
}
|
php
|
public static function equals(Version $v1, Version $v2)
{
// Versionable part itself needs to be equal
if (!self::versionableEquals($v1, $v2)) {
return false;
}
// If only one has a pre-release, they're not equal
if ($v1->hasPreRelease() && !$v2->hasPreRelease()) {
return false;
}
if (!$v1->hasPreRelease() && $v2->hasPreRelease()) {
return false;
}
// See if pre-releases are equal if both versions have one
if ($v1->hasPreRelease() && $v2->hasPreRelease()) {
if (!self::preReleaseEquals($v1->getPreRelease(), $v2->getPreRelease())) {
return false;
}
}
// If only one has a build version, they're not equal
if (!$v1->hasBuild() && $v2->hasBuild()) {
return false;
}
if ($v1->hasBuild() && !$v2->hasBuild()) {
return false;
}
// Compare the build version
if ($v1->hasBuild() && $v2->hasBuild()) {
return self::buildEquals($v1->getBuild(), $v2->getBuild());
}
return true;
}
|
[
"public",
"static",
"function",
"equals",
"(",
"Version",
"$",
"v1",
",",
"Version",
"$",
"v2",
")",
"{",
"// Versionable part itself needs to be equal",
"if",
"(",
"!",
"self",
"::",
"versionableEquals",
"(",
"$",
"v1",
",",
"$",
"v2",
")",
")",
"{",
"return",
"false",
";",
"}",
"// If only one has a pre-release, they're not equal",
"if",
"(",
"$",
"v1",
"->",
"hasPreRelease",
"(",
")",
"&&",
"!",
"$",
"v2",
"->",
"hasPreRelease",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"v1",
"->",
"hasPreRelease",
"(",
")",
"&&",
"$",
"v2",
"->",
"hasPreRelease",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"// See if pre-releases are equal if both versions have one",
"if",
"(",
"$",
"v1",
"->",
"hasPreRelease",
"(",
")",
"&&",
"$",
"v2",
"->",
"hasPreRelease",
"(",
")",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"preReleaseEquals",
"(",
"$",
"v1",
"->",
"getPreRelease",
"(",
")",
",",
"$",
"v2",
"->",
"getPreRelease",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"// If only one has a build version, they're not equal",
"if",
"(",
"!",
"$",
"v1",
"->",
"hasBuild",
"(",
")",
"&&",
"$",
"v2",
"->",
"hasBuild",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"v1",
"->",
"hasBuild",
"(",
")",
"&&",
"!",
"$",
"v2",
"->",
"hasBuild",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Compare the build version",
"if",
"(",
"$",
"v1",
"->",
"hasBuild",
"(",
")",
"&&",
"$",
"v2",
"->",
"hasBuild",
"(",
")",
")",
"{",
"return",
"self",
"::",
"buildEquals",
"(",
"$",
"v1",
"->",
"getBuild",
"(",
")",
",",
"$",
"v2",
"->",
"getBuild",
"(",
")",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Are two versions equal to one another?
@param Version $v1
@param Version $v2
@return bool
|
[
"Are",
"two",
"versions",
"equal",
"to",
"one",
"another?"
] |
c771ad1e6c89064c0a4fa714979639dc3649d6c8
|
https://github.com/naneau/semver/blob/c771ad1e6c89064c0a4fa714979639dc3649d6c8/src/Naneau/SemVer/Compare.php#L96-L132
|
230,169
|
naneau/semver
|
src/Naneau/SemVer/Compare.php
|
Compare.greaterThan
|
public static function greaterThan(Version $v1, Version $v2)
{
// If they are equal, they can not be greater/smaller than each other
if (self::equals($v1, $v2)) {
return false;
}
// Compare on the major/minor/patch level if we can
if (!self::versionableEquals($v1, $v2)) {
return self::versionableGreaterThan($v1, $v2);
}
// v1 has a pre-release, but v2 does not, v2 is bigger
if ($v1->hasPreRelease() && !$v2->hasPreRelease()) {
return false;
}
// v1 does not have a pre-release, but v2 does, v1 is bigger
if (!$v1->hasPreRelease() && $v2->hasPreRelease()) {
return true;
}
// Compare on the re-release level if possible
if ($v1->hasPreRelease() && $v2->hasPreRelease()) {
if (!self::preReleaseEquals($v1->getPreRelease(), $v2->getPreRelease())) {
// If v1 has a larger pre-release than v2, it's bigger
if (self::preReleaseGreaterThan($v1->getPreRelease(), $v2->getPreRelease())) {
return true;
}
// v2 has a larger pre-release than v1, v2 is bigger.
return false;
}
}
// Both have the same pre-release version, but only one has a build
// Version with a build is bigger
if ($v1->hasBuild() && !$v2->hasBuild()) {
return true;
}
if (!$v1->hasBuild() && $v2->hasBuild()) {
return false;
}
// Compare the build version
if ($v1->hasBuild() && $v2->hasBuild()) {
return self::buildGreaterThan($v1->getBuild(), $v2->getBuild());
}
return true;
}
|
php
|
public static function greaterThan(Version $v1, Version $v2)
{
// If they are equal, they can not be greater/smaller than each other
if (self::equals($v1, $v2)) {
return false;
}
// Compare on the major/minor/patch level if we can
if (!self::versionableEquals($v1, $v2)) {
return self::versionableGreaterThan($v1, $v2);
}
// v1 has a pre-release, but v2 does not, v2 is bigger
if ($v1->hasPreRelease() && !$v2->hasPreRelease()) {
return false;
}
// v1 does not have a pre-release, but v2 does, v1 is bigger
if (!$v1->hasPreRelease() && $v2->hasPreRelease()) {
return true;
}
// Compare on the re-release level if possible
if ($v1->hasPreRelease() && $v2->hasPreRelease()) {
if (!self::preReleaseEquals($v1->getPreRelease(), $v2->getPreRelease())) {
// If v1 has a larger pre-release than v2, it's bigger
if (self::preReleaseGreaterThan($v1->getPreRelease(), $v2->getPreRelease())) {
return true;
}
// v2 has a larger pre-release than v1, v2 is bigger.
return false;
}
}
// Both have the same pre-release version, but only one has a build
// Version with a build is bigger
if ($v1->hasBuild() && !$v2->hasBuild()) {
return true;
}
if (!$v1->hasBuild() && $v2->hasBuild()) {
return false;
}
// Compare the build version
if ($v1->hasBuild() && $v2->hasBuild()) {
return self::buildGreaterThan($v1->getBuild(), $v2->getBuild());
}
return true;
}
|
[
"public",
"static",
"function",
"greaterThan",
"(",
"Version",
"$",
"v1",
",",
"Version",
"$",
"v2",
")",
"{",
"// If they are equal, they can not be greater/smaller than each other",
"if",
"(",
"self",
"::",
"equals",
"(",
"$",
"v1",
",",
"$",
"v2",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Compare on the major/minor/patch level if we can",
"if",
"(",
"!",
"self",
"::",
"versionableEquals",
"(",
"$",
"v1",
",",
"$",
"v2",
")",
")",
"{",
"return",
"self",
"::",
"versionableGreaterThan",
"(",
"$",
"v1",
",",
"$",
"v2",
")",
";",
"}",
"// v1 has a pre-release, but v2 does not, v2 is bigger",
"if",
"(",
"$",
"v1",
"->",
"hasPreRelease",
"(",
")",
"&&",
"!",
"$",
"v2",
"->",
"hasPreRelease",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"// v1 does not have a pre-release, but v2 does, v1 is bigger",
"if",
"(",
"!",
"$",
"v1",
"->",
"hasPreRelease",
"(",
")",
"&&",
"$",
"v2",
"->",
"hasPreRelease",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"// Compare on the re-release level if possible",
"if",
"(",
"$",
"v1",
"->",
"hasPreRelease",
"(",
")",
"&&",
"$",
"v2",
"->",
"hasPreRelease",
"(",
")",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"preReleaseEquals",
"(",
"$",
"v1",
"->",
"getPreRelease",
"(",
")",
",",
"$",
"v2",
"->",
"getPreRelease",
"(",
")",
")",
")",
"{",
"// If v1 has a larger pre-release than v2, it's bigger",
"if",
"(",
"self",
"::",
"preReleaseGreaterThan",
"(",
"$",
"v1",
"->",
"getPreRelease",
"(",
")",
",",
"$",
"v2",
"->",
"getPreRelease",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"// v2 has a larger pre-release than v1, v2 is bigger.",
"return",
"false",
";",
"}",
"}",
"// Both have the same pre-release version, but only one has a build",
"// Version with a build is bigger",
"if",
"(",
"$",
"v1",
"->",
"hasBuild",
"(",
")",
"&&",
"!",
"$",
"v2",
"->",
"hasBuild",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"$",
"v1",
"->",
"hasBuild",
"(",
")",
"&&",
"$",
"v2",
"->",
"hasBuild",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Compare the build version",
"if",
"(",
"$",
"v1",
"->",
"hasBuild",
"(",
")",
"&&",
"$",
"v2",
"->",
"hasBuild",
"(",
")",
")",
"{",
"return",
"self",
"::",
"buildGreaterThan",
"(",
"$",
"v1",
"->",
"getBuild",
"(",
")",
",",
"$",
"v2",
"->",
"getBuild",
"(",
")",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Is a Version greater than another one?
@param Version $v1
@param Version $v2
@return bool
|
[
"Is",
"a",
"Version",
"greater",
"than",
"another",
"one?"
] |
c771ad1e6c89064c0a4fa714979639dc3649d6c8
|
https://github.com/naneau/semver/blob/c771ad1e6c89064c0a4fa714979639dc3649d6c8/src/Naneau/SemVer/Compare.php#L141-L192
|
230,170
|
naneau/semver
|
src/Naneau/SemVer/Compare.php
|
Compare.smallerThan
|
public static function smallerThan(Version $v1, Version $v2)
{
// If it's equal it can not be smaller
if (self::equals($v1, $v2)) {
return false;
}
// If it's not equal, and not greater, it must be smaller
return !self::greaterThan($v1, $v2);
}
|
php
|
public static function smallerThan(Version $v1, Version $v2)
{
// If it's equal it can not be smaller
if (self::equals($v1, $v2)) {
return false;
}
// If it's not equal, and not greater, it must be smaller
return !self::greaterThan($v1, $v2);
}
|
[
"public",
"static",
"function",
"smallerThan",
"(",
"Version",
"$",
"v1",
",",
"Version",
"$",
"v2",
")",
"{",
"// If it's equal it can not be smaller",
"if",
"(",
"self",
"::",
"equals",
"(",
"$",
"v1",
",",
"$",
"v2",
")",
")",
"{",
"return",
"false",
";",
"}",
"// If it's not equal, and not greater, it must be smaller",
"return",
"!",
"self",
"::",
"greaterThan",
"(",
"$",
"v1",
",",
"$",
"v2",
")",
";",
"}"
] |
Is a version smaller than another one?
@param Version $v1
@param Version $v2
@return bool
|
[
"Is",
"a",
"version",
"smaller",
"than",
"another",
"one?"
] |
c771ad1e6c89064c0a4fa714979639dc3649d6c8
|
https://github.com/naneau/semver/blob/c771ad1e6c89064c0a4fa714979639dc3649d6c8/src/Naneau/SemVer/Compare.php#L201-L210
|
230,171
|
naneau/semver
|
src/Naneau/SemVer/Compare.php
|
Compare.preReleaseEquals
|
private static function preReleaseEquals(PreRelease $v1, PreRelease $v2)
{
// If they don't match on the versionable level they can not match
if (!self::versionableEquals($v1, $v2)) {
return false;
}
// Both other parts need to match
if ($v1->getGreek() !== $v2->getGreek()) {
return false;
}
if ($v1->getReleaseNumber() !== $v2->getReleaseNumber()) {
return false;
}
return true;
}
|
php
|
private static function preReleaseEquals(PreRelease $v1, PreRelease $v2)
{
// If they don't match on the versionable level they can not match
if (!self::versionableEquals($v1, $v2)) {
return false;
}
// Both other parts need to match
if ($v1->getGreek() !== $v2->getGreek()) {
return false;
}
if ($v1->getReleaseNumber() !== $v2->getReleaseNumber()) {
return false;
}
return true;
}
|
[
"private",
"static",
"function",
"preReleaseEquals",
"(",
"PreRelease",
"$",
"v1",
",",
"PreRelease",
"$",
"v2",
")",
"{",
"// If they don't match on the versionable level they can not match",
"if",
"(",
"!",
"self",
"::",
"versionableEquals",
"(",
"$",
"v1",
",",
"$",
"v2",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Both other parts need to match",
"if",
"(",
"$",
"v1",
"->",
"getGreek",
"(",
")",
"!==",
"$",
"v2",
"->",
"getGreek",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"v1",
"->",
"getReleaseNumber",
"(",
")",
"!==",
"$",
"v2",
"->",
"getReleaseNumber",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Does a pre-release equal another one?
@param PreRelease $v1
@param PreRelease $v2
@return bool
|
[
"Does",
"a",
"pre",
"-",
"release",
"equal",
"another",
"one?"
] |
c771ad1e6c89064c0a4fa714979639dc3649d6c8
|
https://github.com/naneau/semver/blob/c771ad1e6c89064c0a4fa714979639dc3649d6c8/src/Naneau/SemVer/Compare.php#L302-L318
|
230,172
|
naneau/semver
|
src/Naneau/SemVer/Compare.php
|
Compare.preReleaseGreaterThan
|
private static function preReleaseGreaterThan(PreRelease $v1, PreRelease $v2)
{
// Pre-releases can be denoted as versionable (X.Y.Z) or greek (alpha.5)
// We let versionable take precedence
if (!self::versionableEquals($v1, $v2)) {
// If v1 is bigger on the versionable level, it's bigger.
return self::versionableGreaterThan($v1, $v2);
}
// "Greek" part is "bigger" for v1
if ($v1->getGreek() !== $v2->getGreek()) {
return self::greekLargerThan($v1->getGreek(), $v2->getGreek());
}
// Release number for v1 is bigger than v2's
if ($v1->getReleaseNumber() > $v2->getReleaseNumber()) {
return true;
}
return false;
}
|
php
|
private static function preReleaseGreaterThan(PreRelease $v1, PreRelease $v2)
{
// Pre-releases can be denoted as versionable (X.Y.Z) or greek (alpha.5)
// We let versionable take precedence
if (!self::versionableEquals($v1, $v2)) {
// If v1 is bigger on the versionable level, it's bigger.
return self::versionableGreaterThan($v1, $v2);
}
// "Greek" part is "bigger" for v1
if ($v1->getGreek() !== $v2->getGreek()) {
return self::greekLargerThan($v1->getGreek(), $v2->getGreek());
}
// Release number for v1 is bigger than v2's
if ($v1->getReleaseNumber() > $v2->getReleaseNumber()) {
return true;
}
return false;
}
|
[
"private",
"static",
"function",
"preReleaseGreaterThan",
"(",
"PreRelease",
"$",
"v1",
",",
"PreRelease",
"$",
"v2",
")",
"{",
"// Pre-releases can be denoted as versionable (X.Y.Z) or greek (alpha.5)",
"// We let versionable take precedence",
"if",
"(",
"!",
"self",
"::",
"versionableEquals",
"(",
"$",
"v1",
",",
"$",
"v2",
")",
")",
"{",
"// If v1 is bigger on the versionable level, it's bigger.",
"return",
"self",
"::",
"versionableGreaterThan",
"(",
"$",
"v1",
",",
"$",
"v2",
")",
";",
"}",
"// \"Greek\" part is \"bigger\" for v1",
"if",
"(",
"$",
"v1",
"->",
"getGreek",
"(",
")",
"!==",
"$",
"v2",
"->",
"getGreek",
"(",
")",
")",
"{",
"return",
"self",
"::",
"greekLargerThan",
"(",
"$",
"v1",
"->",
"getGreek",
"(",
")",
",",
"$",
"v2",
"->",
"getGreek",
"(",
")",
")",
";",
"}",
"// Release number for v1 is bigger than v2's",
"if",
"(",
"$",
"v1",
"->",
"getReleaseNumber",
"(",
")",
">",
"$",
"v2",
"->",
"getReleaseNumber",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Is one pre-release version bigger than another one?
@param PreRelease $v1
@param PreRelease $v2
@return bool
|
[
"Is",
"one",
"pre",
"-",
"release",
"version",
"bigger",
"than",
"another",
"one?"
] |
c771ad1e6c89064c0a4fa714979639dc3649d6c8
|
https://github.com/naneau/semver/blob/c771ad1e6c89064c0a4fa714979639dc3649d6c8/src/Naneau/SemVer/Compare.php#L327-L347
|
230,173
|
naneau/semver
|
src/Naneau/SemVer/Compare.php
|
Compare.greekLargerThan
|
private static function greekLargerThan($greek1, $greek2)
{
// If they do not exist as valid precendence identifiers assume
// bigger/smaller based on that
if (!in_array($greek1, self::$greekPrecendence)) {
return true;
}
if (!in_array($greek2, self::$greekPrecendence)) {
return false;
}
// Use the index in precendence for comparison
return
array_search($greek1, self::$greekPrecendence)
>
array_search($greek2, self::$greekPrecendence);
}
|
php
|
private static function greekLargerThan($greek1, $greek2)
{
// If they do not exist as valid precendence identifiers assume
// bigger/smaller based on that
if (!in_array($greek1, self::$greekPrecendence)) {
return true;
}
if (!in_array($greek2, self::$greekPrecendence)) {
return false;
}
// Use the index in precendence for comparison
return
array_search($greek1, self::$greekPrecendence)
>
array_search($greek2, self::$greekPrecendence);
}
|
[
"private",
"static",
"function",
"greekLargerThan",
"(",
"$",
"greek1",
",",
"$",
"greek2",
")",
"{",
"// If they do not exist as valid precendence identifiers assume",
"// bigger/smaller based on that",
"if",
"(",
"!",
"in_array",
"(",
"$",
"greek1",
",",
"self",
"::",
"$",
"greekPrecendence",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"greek2",
",",
"self",
"::",
"$",
"greekPrecendence",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Use the index in precendence for comparison",
"return",
"array_search",
"(",
"$",
"greek1",
",",
"self",
"::",
"$",
"greekPrecendence",
")",
">",
"array_search",
"(",
"$",
"greek2",
",",
"self",
"::",
"$",
"greekPrecendence",
")",
";",
"}"
] |
Compare "greek" strings
@see SemVer::$greekPrecendence
@param string $greek1
@param string $greek2
@return bool
|
[
"Compare",
"greek",
"strings"
] |
c771ad1e6c89064c0a4fa714979639dc3649d6c8
|
https://github.com/naneau/semver/blob/c771ad1e6c89064c0a4fa714979639dc3649d6c8/src/Naneau/SemVer/Compare.php#L358-L374
|
230,174
|
ZenMagick/ZenCart
|
includes/classes/class.smtp.php
|
SMTP.SMTP
|
function SMTP() {
$this->smtp_conn = 0;
$this->error = null;
$this->helo_rply = null;
$this->do_debug = 0;
}
|
php
|
function SMTP() {
$this->smtp_conn = 0;
$this->error = null;
$this->helo_rply = null;
$this->do_debug = 0;
}
|
[
"function",
"SMTP",
"(",
")",
"{",
"$",
"this",
"->",
"smtp_conn",
"=",
"0",
";",
"$",
"this",
"->",
"error",
"=",
"null",
";",
"$",
"this",
"->",
"helo_rply",
"=",
"null",
";",
"$",
"this",
"->",
"do_debug",
"=",
"0",
";",
"}"
] |
Initialize the class so that the data is in a known state.
@access public
@return void
|
[
"Initialize",
"the",
"class",
"so",
"that",
"the",
"data",
"is",
"in",
"a",
"known",
"state",
"."
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/classes/class.smtp.php#L75-L81
|
230,175
|
ZenMagick/ZenCart
|
includes/classes/class.smtp.php
|
SMTP.Hello
|
function Hello($host="") {
$this->error = null; # so no confusion is caused
if(!$this->connected()) {
$this->error = array(
"error" => "Called Hello() without being connected");
return false;
}
# if a hostname for the HELO wasn't specified determine
# a suitable one to send
if(empty($host)) {
# we need to determine some sort of appopiate default
# to send to the server
$host = "localhost";
}
// Send extended hello first (RFC 2821)
if(!$this->SendHello("EHLO", $host))
{
if(!$this->SendHello("HELO", $host))
return false;
}
return true;
}
|
php
|
function Hello($host="") {
$this->error = null; # so no confusion is caused
if(!$this->connected()) {
$this->error = array(
"error" => "Called Hello() without being connected");
return false;
}
# if a hostname for the HELO wasn't specified determine
# a suitable one to send
if(empty($host)) {
# we need to determine some sort of appopiate default
# to send to the server
$host = "localhost";
}
// Send extended hello first (RFC 2821)
if(!$this->SendHello("EHLO", $host))
{
if(!$this->SendHello("HELO", $host))
return false;
}
return true;
}
|
[
"function",
"Hello",
"(",
"$",
"host",
"=",
"\"\"",
")",
"{",
"$",
"this",
"->",
"error",
"=",
"null",
";",
"# so no confusion is caused",
"if",
"(",
"!",
"$",
"this",
"->",
"connected",
"(",
")",
")",
"{",
"$",
"this",
"->",
"error",
"=",
"array",
"(",
"\"error\"",
"=>",
"\"Called Hello() without being connected\"",
")",
";",
"return",
"false",
";",
"}",
"# if a hostname for the HELO wasn't specified determine",
"# a suitable one to send",
"if",
"(",
"empty",
"(",
"$",
"host",
")",
")",
"{",
"# we need to determine some sort of appopiate default",
"# to send to the server",
"$",
"host",
"=",
"\"localhost\"",
";",
"}",
"// Send extended hello first (RFC 2821)",
"if",
"(",
"!",
"$",
"this",
"->",
"SendHello",
"(",
"\"EHLO\"",
",",
"$",
"host",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"SendHello",
"(",
"\"HELO\"",
",",
"$",
"host",
")",
")",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Sends the HELO command to the smtp server.
This makes sure that we and the server are in
the same known state.
Implements from rfc 821: HELO <SP> <domain> <CRLF>
SMTP CODE SUCCESS: 250
SMTP CODE ERROR : 500, 501, 504, 421
@access public
@return bool
|
[
"Sends",
"the",
"HELO",
"command",
"to",
"the",
"smtp",
"server",
".",
"This",
"makes",
"sure",
"that",
"we",
"and",
"the",
"server",
"are",
"in",
"the",
"same",
"known",
"state",
"."
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/classes/class.smtp.php#L476-L501
|
230,176
|
ZenMagick/ZenCart
|
includes/classes/class.smtp.php
|
SMTP.Reset
|
function Reset() {
$this->error = null; # so no confusion is caused
if(!$this->connected()) {
$this->error = array(
"error" => "Called Reset() without being connected");
return false;
}
fputs($this->smtp_conn,"RSET" . $this->CRLF);
$rply = $this->get_lines();
$code = substr($rply,0,3);
if($this->do_debug >= 2) {
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
}
if($code != 250) {
$this->error =
array("error" => "RSET failed",
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
echo "SMTP -> ERROR: " . $this->error["error"] .
": " . $rply . $this->CRLF;
}
return false;
}
return true;
}
|
php
|
function Reset() {
$this->error = null; # so no confusion is caused
if(!$this->connected()) {
$this->error = array(
"error" => "Called Reset() without being connected");
return false;
}
fputs($this->smtp_conn,"RSET" . $this->CRLF);
$rply = $this->get_lines();
$code = substr($rply,0,3);
if($this->do_debug >= 2) {
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
}
if($code != 250) {
$this->error =
array("error" => "RSET failed",
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
echo "SMTP -> ERROR: " . $this->error["error"] .
": " . $rply . $this->CRLF;
}
return false;
}
return true;
}
|
[
"function",
"Reset",
"(",
")",
"{",
"$",
"this",
"->",
"error",
"=",
"null",
";",
"# so no confusion is caused",
"if",
"(",
"!",
"$",
"this",
"->",
"connected",
"(",
")",
")",
"{",
"$",
"this",
"->",
"error",
"=",
"array",
"(",
"\"error\"",
"=>",
"\"Called Reset() without being connected\"",
")",
";",
"return",
"false",
";",
"}",
"fputs",
"(",
"$",
"this",
"->",
"smtp_conn",
",",
"\"RSET\"",
".",
"$",
"this",
"->",
"CRLF",
")",
";",
"$",
"rply",
"=",
"$",
"this",
"->",
"get_lines",
"(",
")",
";",
"$",
"code",
"=",
"substr",
"(",
"$",
"rply",
",",
"0",
",",
"3",
")",
";",
"if",
"(",
"$",
"this",
"->",
"do_debug",
">=",
"2",
")",
"{",
"echo",
"\"SMTP -> FROM SERVER:\"",
".",
"$",
"this",
"->",
"CRLF",
".",
"$",
"rply",
";",
"}",
"if",
"(",
"$",
"code",
"!=",
"250",
")",
"{",
"$",
"this",
"->",
"error",
"=",
"array",
"(",
"\"error\"",
"=>",
"\"RSET failed\"",
",",
"\"smtp_code\"",
"=>",
"$",
"code",
",",
"\"smtp_msg\"",
"=>",
"substr",
"(",
"$",
"rply",
",",
"4",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"do_debug",
">=",
"1",
")",
"{",
"echo",
"\"SMTP -> ERROR: \"",
".",
"$",
"this",
"->",
"error",
"[",
"\"error\"",
"]",
".",
"\": \"",
".",
"$",
"rply",
".",
"$",
"this",
"->",
"CRLF",
";",
"}",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Sends the RSET command to abort and transaction that is
currently in progress. Returns true if successful false
otherwise.
Implements rfc 821: RSET <CRLF>
SMTP CODE SUCCESS: 250
SMTP CODE ERROR : 500,501,504,421
@access public
@return bool
|
[
"Sends",
"the",
"RSET",
"command",
"to",
"abort",
"and",
"transaction",
"that",
"is",
"currently",
"in",
"progress",
".",
"Returns",
"true",
"if",
"successful",
"false",
"otherwise",
"."
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/classes/class.smtp.php#L785-L816
|
230,177
|
ZenMagick/ZenCart
|
includes/classes/class.smtp.php
|
SMTP.Verify
|
function Verify($name) {
$this->error = null; # so no confusion is caused
if(!$this->connected()) {
$this->error = array(
"error" => "Called Verify() without being connected");
return false;
}
fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF);
$rply = $this->get_lines();
$code = substr($rply,0,3);
if($this->do_debug >= 2) {
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
}
if($code != 250 && $code != 251) {
$this->error =
array("error" => "VRFY failed on name '$name'",
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
echo "SMTP -> ERROR: " . $this->error["error"] .
": " . $rply . $this->CRLF;
}
return false;
}
return $rply;
}
|
php
|
function Verify($name) {
$this->error = null; # so no confusion is caused
if(!$this->connected()) {
$this->error = array(
"error" => "Called Verify() without being connected");
return false;
}
fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF);
$rply = $this->get_lines();
$code = substr($rply,0,3);
if($this->do_debug >= 2) {
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
}
if($code != 250 && $code != 251) {
$this->error =
array("error" => "VRFY failed on name '$name'",
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
echo "SMTP -> ERROR: " . $this->error["error"] .
": " . $rply . $this->CRLF;
}
return false;
}
return $rply;
}
|
[
"function",
"Verify",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"error",
"=",
"null",
";",
"# so no confusion is caused",
"if",
"(",
"!",
"$",
"this",
"->",
"connected",
"(",
")",
")",
"{",
"$",
"this",
"->",
"error",
"=",
"array",
"(",
"\"error\"",
"=>",
"\"Called Verify() without being connected\"",
")",
";",
"return",
"false",
";",
"}",
"fputs",
"(",
"$",
"this",
"->",
"smtp_conn",
",",
"\"VRFY \"",
".",
"$",
"name",
".",
"$",
"this",
"->",
"CRLF",
")",
";",
"$",
"rply",
"=",
"$",
"this",
"->",
"get_lines",
"(",
")",
";",
"$",
"code",
"=",
"substr",
"(",
"$",
"rply",
",",
"0",
",",
"3",
")",
";",
"if",
"(",
"$",
"this",
"->",
"do_debug",
">=",
"2",
")",
"{",
"echo",
"\"SMTP -> FROM SERVER:\"",
".",
"$",
"this",
"->",
"CRLF",
".",
"$",
"rply",
";",
"}",
"if",
"(",
"$",
"code",
"!=",
"250",
"&&",
"$",
"code",
"!=",
"251",
")",
"{",
"$",
"this",
"->",
"error",
"=",
"array",
"(",
"\"error\"",
"=>",
"\"VRFY failed on name '$name'\"",
",",
"\"smtp_code\"",
"=>",
"$",
"code",
",",
"\"smtp_msg\"",
"=>",
"substr",
"(",
"$",
"rply",
",",
"4",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"do_debug",
">=",
"1",
")",
"{",
"echo",
"\"SMTP -> ERROR: \"",
".",
"$",
"this",
"->",
"error",
"[",
"\"error\"",
"]",
".",
"\": \"",
".",
"$",
"rply",
".",
"$",
"this",
"->",
"CRLF",
";",
"}",
"return",
"false",
";",
"}",
"return",
"$",
"rply",
";",
"}"
] |
Verifies that the name is recognized by the server.
Returns false if the name could not be verified otherwise
the response from the server is returned.
Implements rfc 821: VRFY <SP> <string> <CRLF>
SMTP CODE SUCCESS: 250,251
SMTP CODE FAILURE: 550,551,553
SMTP CODE ERROR : 500,501,502,421
@access public
@return int
|
[
"Verifies",
"that",
"the",
"name",
"is",
"recognized",
"by",
"the",
"server",
".",
"Returns",
"false",
"if",
"the",
"name",
"could",
"not",
"be",
"verified",
"otherwise",
"the",
"response",
"from",
"the",
"server",
"is",
"returned",
"."
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/classes/class.smtp.php#L997-L1027
|
230,178
|
brysalazar12/thememanager
|
src/Helpers/Theme.php
|
Theme.set
|
public function set($theme, $group = null)
{
if (!is_null($group)) {
$this->currentGroup = $group;
$this->currentTheme[$group] = $theme;
}
if (is_null($this->currentGroup)) {
throw new \Exception('Current group cannot be null. Use Theme::setCurrentGroup($group) or Theme::set($theme, $group)');
}
$this->currentTheme[$this->currentGroup] = $theme;
return $this;
}
|
php
|
public function set($theme, $group = null)
{
if (!is_null($group)) {
$this->currentGroup = $group;
$this->currentTheme[$group] = $theme;
}
if (is_null($this->currentGroup)) {
throw new \Exception('Current group cannot be null. Use Theme::setCurrentGroup($group) or Theme::set($theme, $group)');
}
$this->currentTheme[$this->currentGroup] = $theme;
return $this;
}
|
[
"public",
"function",
"set",
"(",
"$",
"theme",
",",
"$",
"group",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"group",
")",
")",
"{",
"$",
"this",
"->",
"currentGroup",
"=",
"$",
"group",
";",
"$",
"this",
"->",
"currentTheme",
"[",
"$",
"group",
"]",
"=",
"$",
"theme",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"currentGroup",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Current group cannot be null. Use Theme::setCurrentGroup($group) or Theme::set($theme, $group)'",
")",
";",
"}",
"$",
"this",
"->",
"currentTheme",
"[",
"$",
"this",
"->",
"currentGroup",
"]",
"=",
"$",
"theme",
";",
"return",
"$",
"this",
";",
"}"
] |
Set current theme for this group.
@param string $theme Name of theme that belongs to this $group
@param string $group Group name
|
[
"Set",
"current",
"theme",
"for",
"this",
"group",
"."
] |
589b771ae412b5f3081bec16f5d84a62850fd9e1
|
https://github.com/brysalazar12/thememanager/blob/589b771ae412b5f3081bec16f5d84a62850fd9e1/src/Helpers/Theme.php#L79-L93
|
230,179
|
WadeShuler/yii2-ckeditor-cdn
|
widgets/CKEditor.php
|
CKEditor.registerPlugins
|
protected function registerPlugins()
{
if ( count($this->externalPlugins) )
{
foreach ( $this->externalPlugins as $plugin ) {
$this->getView()->registerJs("CKEDITOR.plugins.addExternal( '" . $plugin['name'] . "', '" . $plugin['path'] . "', '" . $plugin['file'] . "' );", View::POS_END);
}
}
}
|
php
|
protected function registerPlugins()
{
if ( count($this->externalPlugins) )
{
foreach ( $this->externalPlugins as $plugin ) {
$this->getView()->registerJs("CKEDITOR.plugins.addExternal( '" . $plugin['name'] . "', '" . $plugin['path'] . "', '" . $plugin['file'] . "' );", View::POS_END);
}
}
}
|
[
"protected",
"function",
"registerPlugins",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"externalPlugins",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"externalPlugins",
"as",
"$",
"plugin",
")",
"{",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"registerJs",
"(",
"\"CKEDITOR.plugins.addExternal( '\"",
".",
"$",
"plugin",
"[",
"'name'",
"]",
".",
"\"', '\"",
".",
"$",
"plugin",
"[",
"'path'",
"]",
".",
"\"', '\"",
".",
"$",
"plugin",
"[",
"'file'",
"]",
".",
"\"' );\"",
",",
"View",
"::",
"POS_END",
")",
";",
"}",
"}",
"}"
] |
Register plugins for CKEditor
|
[
"Register",
"plugins",
"for",
"CKEditor"
] |
86fc388023fc8f4f2be13fcd0da7410b1375386b
|
https://github.com/WadeShuler/yii2-ckeditor-cdn/blob/86fc388023fc8f4f2be13fcd0da7410b1375386b/widgets/CKEditor.php#L89-L97
|
230,180
|
Webiny/Framework
|
src/Webiny/Component/Entity/Attribute/Many2ManyAttribute.php
|
Many2ManyAttribute.save
|
public function save()
{
$collectionName = $this->intermediateCollection;
$existingIds = [];
$firstEntityId = $this->getParentEntity()->id;
foreach ($this->getValue() as $item) {
if ($item instanceof AbstractEntity && !$item->exists()) {
$item->save();
}
if ($item instanceof AbstractEntity) {
$secondEntityId = $item->id;
} else {
$secondEntityId = $item;
}
$existingIds[] = $secondEntityId;
$data = [
$this->thisField => $firstEntityId,
$this->refField => $secondEntityId
];
try {
Entity::getInstance()->getDatabase()->insertOne($collectionName, $this->arr($data)->sortKey()->val());
} catch (BulkWriteException $e) {
// Unique index was hit and an exception is thrown - that's ok, means the values are already inserted
continue;
}
}
/**
* Remove old links
*/
$removeQuery = [
$this->thisField => $firstEntityId,
$this->refField => [
'$nin' => $existingIds
]
];
Entity::getInstance()->getDatabase()->delete($collectionName, $removeQuery);
/**
* The value of many2many attribute must be set to 'null' to trigger data reload on next access.
* If this is not done, we may not have proper links between the 2 entities and it may seem as if data was missing.
*/
$this->setValue(null);
}
|
php
|
public function save()
{
$collectionName = $this->intermediateCollection;
$existingIds = [];
$firstEntityId = $this->getParentEntity()->id;
foreach ($this->getValue() as $item) {
if ($item instanceof AbstractEntity && !$item->exists()) {
$item->save();
}
if ($item instanceof AbstractEntity) {
$secondEntityId = $item->id;
} else {
$secondEntityId = $item;
}
$existingIds[] = $secondEntityId;
$data = [
$this->thisField => $firstEntityId,
$this->refField => $secondEntityId
];
try {
Entity::getInstance()->getDatabase()->insertOne($collectionName, $this->arr($data)->sortKey()->val());
} catch (BulkWriteException $e) {
// Unique index was hit and an exception is thrown - that's ok, means the values are already inserted
continue;
}
}
/**
* Remove old links
*/
$removeQuery = [
$this->thisField => $firstEntityId,
$this->refField => [
'$nin' => $existingIds
]
];
Entity::getInstance()->getDatabase()->delete($collectionName, $removeQuery);
/**
* The value of many2many attribute must be set to 'null' to trigger data reload on next access.
* If this is not done, we may not have proper links between the 2 entities and it may seem as if data was missing.
*/
$this->setValue(null);
}
|
[
"public",
"function",
"save",
"(",
")",
"{",
"$",
"collectionName",
"=",
"$",
"this",
"->",
"intermediateCollection",
";",
"$",
"existingIds",
"=",
"[",
"]",
";",
"$",
"firstEntityId",
"=",
"$",
"this",
"->",
"getParentEntity",
"(",
")",
"->",
"id",
";",
"foreach",
"(",
"$",
"this",
"->",
"getValue",
"(",
")",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"instanceof",
"AbstractEntity",
"&&",
"!",
"$",
"item",
"->",
"exists",
"(",
")",
")",
"{",
"$",
"item",
"->",
"save",
"(",
")",
";",
"}",
"if",
"(",
"$",
"item",
"instanceof",
"AbstractEntity",
")",
"{",
"$",
"secondEntityId",
"=",
"$",
"item",
"->",
"id",
";",
"}",
"else",
"{",
"$",
"secondEntityId",
"=",
"$",
"item",
";",
"}",
"$",
"existingIds",
"[",
"]",
"=",
"$",
"secondEntityId",
";",
"$",
"data",
"=",
"[",
"$",
"this",
"->",
"thisField",
"=>",
"$",
"firstEntityId",
",",
"$",
"this",
"->",
"refField",
"=>",
"$",
"secondEntityId",
"]",
";",
"try",
"{",
"Entity",
"::",
"getInstance",
"(",
")",
"->",
"getDatabase",
"(",
")",
"->",
"insertOne",
"(",
"$",
"collectionName",
",",
"$",
"this",
"->",
"arr",
"(",
"$",
"data",
")",
"->",
"sortKey",
"(",
")",
"->",
"val",
"(",
")",
")",
";",
"}",
"catch",
"(",
"BulkWriteException",
"$",
"e",
")",
"{",
"// Unique index was hit and an exception is thrown - that's ok, means the values are already inserted",
"continue",
";",
"}",
"}",
"/**\n * Remove old links\n */",
"$",
"removeQuery",
"=",
"[",
"$",
"this",
"->",
"thisField",
"=>",
"$",
"firstEntityId",
",",
"$",
"this",
"->",
"refField",
"=>",
"[",
"'$nin'",
"=>",
"$",
"existingIds",
"]",
"]",
";",
"Entity",
"::",
"getInstance",
"(",
")",
"->",
"getDatabase",
"(",
")",
"->",
"delete",
"(",
"$",
"collectionName",
",",
"$",
"removeQuery",
")",
";",
"/**\n * The value of many2many attribute must be set to 'null' to trigger data reload on next access.\n * If this is not done, we may not have proper links between the 2 entities and it may seem as if data was missing.\n */",
"$",
"this",
"->",
"setValue",
"(",
"null",
")",
";",
"}"
] |
Insert links into DB
@throws \Webiny\Component\Entity\EntityException
@throws \Webiny\Component\StdLib\StdObject\ArrayObject\ArrayObjectException
|
[
"Insert",
"links",
"into",
"DB"
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Entity/Attribute/Many2ManyAttribute.php#L170-L218
|
230,181
|
ZenMagick/ZenCart
|
includes/classes/http_client.php
|
httpClient.setProxy
|
function setProxy($proxyHost, $proxyPort) {
$this->useProxy = true;
$this->proxyHost = $proxyHost;
$this->proxyPort = $proxyPort;
}
|
php
|
function setProxy($proxyHost, $proxyPort) {
$this->useProxy = true;
$this->proxyHost = $proxyHost;
$this->proxyPort = $proxyPort;
}
|
[
"function",
"setProxy",
"(",
"$",
"proxyHost",
",",
"$",
"proxyPort",
")",
"{",
"$",
"this",
"->",
"useProxy",
"=",
"true",
";",
"$",
"this",
"->",
"proxyHost",
"=",
"$",
"proxyHost",
";",
"$",
"this",
"->",
"proxyPort",
"=",
"$",
"proxyPort",
";",
"}"
] |
turn on proxy support
@param proxyHost proxy host address eg "proxy.mycorp.com"
@param proxyPort proxy port usually 80 or 8080
|
[
"turn",
"on",
"proxy",
"support"
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/classes/http_client.php#L49-L53
|
230,182
|
ZenMagick/ZenCart
|
includes/classes/http_client.php
|
httpClient.setHeaders
|
function setHeaders($headers) {
if (is_array($headers)) {
reset($headers);
while (list($name, $value) = each($headers)) {
$this->requestHeaders[$name] = $value;
}
}
}
|
php
|
function setHeaders($headers) {
if (is_array($headers)) {
reset($headers);
while (list($name, $value) = each($headers)) {
$this->requestHeaders[$name] = $value;
}
}
}
|
[
"function",
"setHeaders",
"(",
"$",
"headers",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"headers",
")",
")",
"{",
"reset",
"(",
"$",
"headers",
")",
";",
"while",
"(",
"list",
"(",
"$",
"name",
",",
"$",
"value",
")",
"=",
"each",
"(",
"$",
"headers",
")",
")",
"{",
"$",
"this",
"->",
"requestHeaders",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"}"
] |
define a set of HTTP headers to be sent to the server
header names are lowercased to avoid duplicated headers
@param headers hash array containing the headers as headerName => headerValue pairs
|
[
"define",
"a",
"set",
"of",
"HTTP",
"headers",
"to",
"be",
"sent",
"to",
"the",
"server",
"header",
"names",
"are",
"lowercased",
"to",
"avoid",
"duplicated",
"headers"
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/classes/http_client.php#L86-L93
|
230,183
|
ZenMagick/ZenCart
|
includes/classes/http_client.php
|
httpClient.Connect
|
function Connect($host, $port = '') {
$this->url['scheme'] = 'http';
$this->url['host'] = $host;
if (zen_not_null($port)) $this->url['port'] = $port;
return true;
}
|
php
|
function Connect($host, $port = '') {
$this->url['scheme'] = 'http';
$this->url['host'] = $host;
if (zen_not_null($port)) $this->url['port'] = $port;
return true;
}
|
[
"function",
"Connect",
"(",
"$",
"host",
",",
"$",
"port",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"url",
"[",
"'scheme'",
"]",
"=",
"'http'",
";",
"$",
"this",
"->",
"url",
"[",
"'host'",
"]",
"=",
"$",
"host",
";",
"if",
"(",
"zen_not_null",
"(",
"$",
"port",
")",
")",
"$",
"this",
"->",
"url",
"[",
"'port'",
"]",
"=",
"$",
"port",
";",
"return",
"true",
";",
"}"
] |
Connect
open the connection to the server
@param host string server address (or IP)
@param port string server listening port - defaults to 80
@return boolean false is connection failed, true otherwise
|
[
"Connect",
"open",
"the",
"connection",
"to",
"the",
"server"
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/classes/http_client.php#L121-L127
|
230,184
|
ZenMagick/ZenCart
|
includes/classes/http_client.php
|
httpClient.Head
|
function Head($uri) {
$this->responseHeaders = $this->responseBody = '';
$uri = $this->makeUri($uri);
if ($this->sendCommand('HEAD ' . $uri . ' HTTP/' . $this->protocolVersion)) {
$this->processReply();
}
return $this->reply;
}
|
php
|
function Head($uri) {
$this->responseHeaders = $this->responseBody = '';
$uri = $this->makeUri($uri);
if ($this->sendCommand('HEAD ' . $uri . ' HTTP/' . $this->protocolVersion)) {
$this->processReply();
}
return $this->reply;
}
|
[
"function",
"Head",
"(",
"$",
"uri",
")",
"{",
"$",
"this",
"->",
"responseHeaders",
"=",
"$",
"this",
"->",
"responseBody",
"=",
"''",
";",
"$",
"uri",
"=",
"$",
"this",
"->",
"makeUri",
"(",
"$",
"uri",
")",
";",
"if",
"(",
"$",
"this",
"->",
"sendCommand",
"(",
"'HEAD '",
".",
"$",
"uri",
".",
"' HTTP/'",
".",
"$",
"this",
"->",
"protocolVersion",
")",
")",
"{",
"$",
"this",
"->",
"processReply",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"reply",
";",
"}"
] |
head
issue a HEAD request
@param uri string URI of the document
@return string response status code (200 if ok)
|
[
"head",
"issue",
"a",
"HEAD",
"request"
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/classes/http_client.php#L143-L153
|
230,185
|
ZenMagick/ZenCart
|
includes/classes/http_client.php
|
httpClient.Get
|
function Get($url) {
$this->responseHeaders = $this->responseBody = '';
$uri = $this->makeUri($url);
if ($this->sendCommand('GET ' . $uri . ' HTTP/' . $this->protocolVersion)) {
$this->processReply();
}
return $this->reply;
}
|
php
|
function Get($url) {
$this->responseHeaders = $this->responseBody = '';
$uri = $this->makeUri($url);
if ($this->sendCommand('GET ' . $uri . ' HTTP/' . $this->protocolVersion)) {
$this->processReply();
}
return $this->reply;
}
|
[
"function",
"Get",
"(",
"$",
"url",
")",
"{",
"$",
"this",
"->",
"responseHeaders",
"=",
"$",
"this",
"->",
"responseBody",
"=",
"''",
";",
"$",
"uri",
"=",
"$",
"this",
"->",
"makeUri",
"(",
"$",
"url",
")",
";",
"if",
"(",
"$",
"this",
"->",
"sendCommand",
"(",
"'GET '",
".",
"$",
"uri",
".",
"' HTTP/'",
".",
"$",
"this",
"->",
"protocolVersion",
")",
")",
"{",
"$",
"this",
"->",
"processReply",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"reply",
";",
"}"
] |
get
issue a GET http request
@param uri URI (path on server) or full URL of the document
@return string response status code (200 if ok)
|
[
"get",
"issue",
"a",
"GET",
"http",
"request"
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/classes/http_client.php#L161-L171
|
230,186
|
ZenMagick/ZenCart
|
includes/classes/http_client.php
|
httpClient.sendCommand
|
function sendCommand($command) {
$this->responseHeaders = array();
$this->responseBody = '';
// connect if necessary
if ( ($this->socket == false) || (feof($this->socket)) ) {
if ($this->useProxy) {
$host = $this->proxyHost;
$port = $this->proxyPort;
} else {
$host = $this->url['host'];
$port = $this->url['port'];
}
if (!zen_not_null($port)) $port = 80;
if (!$this->socket = @fsockopen($host, $port, $this->reply, $this->replyString, $this->timeout)) {
return false;
}
if (zen_not_null($this->requestBody)) {
$this->addHeader('Content-Length', strlen($this->requestBody));
}
$this->request = $command;
$cmd = $command . "\r\n";
if (is_array($this->requestHeaders)) {
reset($this->requestHeaders);
while (list($k, $v) = each($this->requestHeaders)) {
$cmd .= $k . ': ' . $v . "\r\n";
}
}
if (zen_not_null($this->requestBody)) {
$cmd .= "\r\n" . $this->requestBody;
}
// unset body (in case of successive requests)
$this->requestBody = '';
fputs($this->socket, $cmd . "\r\n");
return true;
}
}
|
php
|
function sendCommand($command) {
$this->responseHeaders = array();
$this->responseBody = '';
// connect if necessary
if ( ($this->socket == false) || (feof($this->socket)) ) {
if ($this->useProxy) {
$host = $this->proxyHost;
$port = $this->proxyPort;
} else {
$host = $this->url['host'];
$port = $this->url['port'];
}
if (!zen_not_null($port)) $port = 80;
if (!$this->socket = @fsockopen($host, $port, $this->reply, $this->replyString, $this->timeout)) {
return false;
}
if (zen_not_null($this->requestBody)) {
$this->addHeader('Content-Length', strlen($this->requestBody));
}
$this->request = $command;
$cmd = $command . "\r\n";
if (is_array($this->requestHeaders)) {
reset($this->requestHeaders);
while (list($k, $v) = each($this->requestHeaders)) {
$cmd .= $k . ': ' . $v . "\r\n";
}
}
if (zen_not_null($this->requestBody)) {
$cmd .= "\r\n" . $this->requestBody;
}
// unset body (in case of successive requests)
$this->requestBody = '';
fputs($this->socket, $cmd . "\r\n");
return true;
}
}
|
[
"function",
"sendCommand",
"(",
"$",
"command",
")",
"{",
"$",
"this",
"->",
"responseHeaders",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"responseBody",
"=",
"''",
";",
"// connect if necessary",
"if",
"(",
"(",
"$",
"this",
"->",
"socket",
"==",
"false",
")",
"||",
"(",
"feof",
"(",
"$",
"this",
"->",
"socket",
")",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"useProxy",
")",
"{",
"$",
"host",
"=",
"$",
"this",
"->",
"proxyHost",
";",
"$",
"port",
"=",
"$",
"this",
"->",
"proxyPort",
";",
"}",
"else",
"{",
"$",
"host",
"=",
"$",
"this",
"->",
"url",
"[",
"'host'",
"]",
";",
"$",
"port",
"=",
"$",
"this",
"->",
"url",
"[",
"'port'",
"]",
";",
"}",
"if",
"(",
"!",
"zen_not_null",
"(",
"$",
"port",
")",
")",
"$",
"port",
"=",
"80",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"socket",
"=",
"@",
"fsockopen",
"(",
"$",
"host",
",",
"$",
"port",
",",
"$",
"this",
"->",
"reply",
",",
"$",
"this",
"->",
"replyString",
",",
"$",
"this",
"->",
"timeout",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"zen_not_null",
"(",
"$",
"this",
"->",
"requestBody",
")",
")",
"{",
"$",
"this",
"->",
"addHeader",
"(",
"'Content-Length'",
",",
"strlen",
"(",
"$",
"this",
"->",
"requestBody",
")",
")",
";",
"}",
"$",
"this",
"->",
"request",
"=",
"$",
"command",
";",
"$",
"cmd",
"=",
"$",
"command",
".",
"\"\\r\\n\"",
";",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"requestHeaders",
")",
")",
"{",
"reset",
"(",
"$",
"this",
"->",
"requestHeaders",
")",
";",
"while",
"(",
"list",
"(",
"$",
"k",
",",
"$",
"v",
")",
"=",
"each",
"(",
"$",
"this",
"->",
"requestHeaders",
")",
")",
"{",
"$",
"cmd",
".=",
"$",
"k",
".",
"': '",
".",
"$",
"v",
".",
"\"\\r\\n\"",
";",
"}",
"}",
"if",
"(",
"zen_not_null",
"(",
"$",
"this",
"->",
"requestBody",
")",
")",
"{",
"$",
"cmd",
".=",
"\"\\r\\n\"",
".",
"$",
"this",
"->",
"requestBody",
";",
"}",
"// unset body (in case of successive requests)",
"$",
"this",
"->",
"requestBody",
"=",
"''",
";",
"fputs",
"(",
"$",
"this",
"->",
"socket",
",",
"$",
"cmd",
".",
"\"\\r\\n\"",
")",
";",
"return",
"true",
";",
"}",
"}"
] |
send a request
data sent are in order
a) the command
b) the request headers if they are defined
c) the request body if defined
@return string the server repsonse status code
|
[
"send",
"a",
"request",
"data",
"sent",
"are",
"in",
"order",
"a",
")",
"the",
"command",
"b",
")",
"the",
"request",
"headers",
"if",
"they",
"are",
"defined",
"c",
")",
"the",
"request",
"body",
"if",
"defined"
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/classes/http_client.php#L291-L335
|
230,187
|
themsaid/katana-core
|
src/RSSFeedBuilder.php
|
RSSFeedBuilder.build
|
public function build()
{
if (! $view = $this->getRSSView()) {
return;
}
$pageContent = $this->viewFactory->make($view, $this->viewsData)->render();
$this->filesystem->put(
sprintf('%s/%s', KATANA_PUBLIC_DIR, 'feed.rss'),
$pageContent
);
}
|
php
|
public function build()
{
if (! $view = $this->getRSSView()) {
return;
}
$pageContent = $this->viewFactory->make($view, $this->viewsData)->render();
$this->filesystem->put(
sprintf('%s/%s', KATANA_PUBLIC_DIR, 'feed.rss'),
$pageContent
);
}
|
[
"public",
"function",
"build",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"view",
"=",
"$",
"this",
"->",
"getRSSView",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"pageContent",
"=",
"$",
"this",
"->",
"viewFactory",
"->",
"make",
"(",
"$",
"view",
",",
"$",
"this",
"->",
"viewsData",
")",
"->",
"render",
"(",
")",
";",
"$",
"this",
"->",
"filesystem",
"->",
"put",
"(",
"sprintf",
"(",
"'%s/%s'",
",",
"KATANA_PUBLIC_DIR",
",",
"'feed.rss'",
")",
",",
"$",
"pageContent",
")",
";",
"}"
] |
Build blog RSS feed file.
@return void
|
[
"Build",
"blog",
"RSS",
"feed",
"file",
"."
] |
897c1adb6863d5145f1f104cbc8c9200cd98c3fb
|
https://github.com/themsaid/katana-core/blob/897c1adb6863d5145f1f104cbc8c9200cd98c3fb/src/RSSFeedBuilder.php#L33-L45
|
230,188
|
themsaid/katana-core
|
src/RSSFeedBuilder.php
|
RSSFeedBuilder.getRSSView
|
protected function getRSSView()
{
if (! isset($this->viewsData['rssFeedView']) || ! @$this->viewsData['rssFeedView']) {
return null;
}
if (! $this->viewFactory->exists($this->viewsData['rssFeedView'])) {
throw new \Exception(sprintf('The "%s" view is not found. Make sure the rssFeedView configuration key is correct.', $this->viewsData['rssFeedView']));
}
return $this->viewsData['rssFeedView'];
}
|
php
|
protected function getRSSView()
{
if (! isset($this->viewsData['rssFeedView']) || ! @$this->viewsData['rssFeedView']) {
return null;
}
if (! $this->viewFactory->exists($this->viewsData['rssFeedView'])) {
throw new \Exception(sprintf('The "%s" view is not found. Make sure the rssFeedView configuration key is correct.', $this->viewsData['rssFeedView']));
}
return $this->viewsData['rssFeedView'];
}
|
[
"protected",
"function",
"getRSSView",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"viewsData",
"[",
"'rssFeedView'",
"]",
")",
"||",
"!",
"@",
"$",
"this",
"->",
"viewsData",
"[",
"'rssFeedView'",
"]",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"viewFactory",
"->",
"exists",
"(",
"$",
"this",
"->",
"viewsData",
"[",
"'rssFeedView'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'The \"%s\" view is not found. Make sure the rssFeedView configuration key is correct.'",
",",
"$",
"this",
"->",
"viewsData",
"[",
"'rssFeedView'",
"]",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"viewsData",
"[",
"'rssFeedView'",
"]",
";",
"}"
] |
Get the name of the view to be used for generating the RSS feed.
@return mixed
@throws \Exception
|
[
"Get",
"the",
"name",
"of",
"the",
"view",
"to",
"be",
"used",
"for",
"generating",
"the",
"RSS",
"feed",
"."
] |
897c1adb6863d5145f1f104cbc8c9200cd98c3fb
|
https://github.com/themsaid/katana-core/blob/897c1adb6863d5145f1f104cbc8c9200cd98c3fb/src/RSSFeedBuilder.php#L53-L64
|
230,189
|
EdgedesignCZ/ares
|
Parser/AddressParser.php
|
AddressParser.parseAddress
|
public function parseAddress($xmlString)
{
$previousValue = libxml_use_internal_errors(true);
$xml = simplexml_load_string($xmlString);
libxml_use_internal_errors($previousValue);
if ($xml === false) {
$message = $this->getXmlErrorMessage();
throw new InvalidArgumentException('Failed to parse supplied XML string: ' . $message);
}
return $this->parseSubjectAddress($xml);
}
|
php
|
public function parseAddress($xmlString)
{
$previousValue = libxml_use_internal_errors(true);
$xml = simplexml_load_string($xmlString);
libxml_use_internal_errors($previousValue);
if ($xml === false) {
$message = $this->getXmlErrorMessage();
throw new InvalidArgumentException('Failed to parse supplied XML string: ' . $message);
}
return $this->parseSubjectAddress($xml);
}
|
[
"public",
"function",
"parseAddress",
"(",
"$",
"xmlString",
")",
"{",
"$",
"previousValue",
"=",
"libxml_use_internal_errors",
"(",
"true",
")",
";",
"$",
"xml",
"=",
"simplexml_load_string",
"(",
"$",
"xmlString",
")",
";",
"libxml_use_internal_errors",
"(",
"$",
"previousValue",
")",
";",
"if",
"(",
"$",
"xml",
"===",
"false",
")",
"{",
"$",
"message",
"=",
"$",
"this",
"->",
"getXmlErrorMessage",
"(",
")",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Failed to parse supplied XML string: '",
".",
"$",
"message",
")",
";",
"}",
"return",
"$",
"this",
"->",
"parseSubjectAddress",
"(",
"$",
"xml",
")",
";",
"}"
] |
Parse address from given XML and return Address object.
@param string $xmlString
@throws \Edge\Ares\Exception\InvalidArgumentException
@return Address
|
[
"Parse",
"address",
"from",
"given",
"XML",
"and",
"return",
"Address",
"object",
"."
] |
ae0f50155571875d09ba969e7b062854c823b57d
|
https://github.com/EdgedesignCZ/ares/blob/ae0f50155571875d09ba969e7b062854c823b57d/Parser/AddressParser.php#L24-L36
|
230,190
|
EdgedesignCZ/ares
|
Parser/AddressParser.php
|
AddressParser.getXmlErrorMessage
|
private function getXmlErrorMessage()
{
$errors = libxml_get_errors();
if (count($errors)) {
/** @var \LibXMLError $error */
$error = array_shift($errors);
return $error->message;
}
return 'Unknown error withing SimpleXML parser occured.';
}
|
php
|
private function getXmlErrorMessage()
{
$errors = libxml_get_errors();
if (count($errors)) {
/** @var \LibXMLError $error */
$error = array_shift($errors);
return $error->message;
}
return 'Unknown error withing SimpleXML parser occured.';
}
|
[
"private",
"function",
"getXmlErrorMessage",
"(",
")",
"{",
"$",
"errors",
"=",
"libxml_get_errors",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"errors",
")",
")",
"{",
"/** @var \\LibXMLError $error */",
"$",
"error",
"=",
"array_shift",
"(",
"$",
"errors",
")",
";",
"return",
"$",
"error",
"->",
"message",
";",
"}",
"return",
"'Unknown error withing SimpleXML parser occured.'",
";",
"}"
] |
Get error message from last supplied XML string.
@return string
|
[
"Get",
"error",
"message",
"from",
"last",
"supplied",
"XML",
"string",
"."
] |
ae0f50155571875d09ba969e7b062854c823b57d
|
https://github.com/EdgedesignCZ/ares/blob/ae0f50155571875d09ba969e7b062854c823b57d/Parser/AddressParser.php#L43-L53
|
230,191
|
deanblackborough/zf3-view-helpers
|
src/Bootstrap4Button.php
|
Bootstrap4Button.setOutlineStyle
|
public function setOutlineStyle(string $style): Bootstrap4Button
{
if (in_array($style, $this->supported_bg_styles) === true &&
$style !== 'link'
) {
$this->outline_style = $style;
} else {
$this->outline_style = 'primary';
}
return $this;
}
|
php
|
public function setOutlineStyle(string $style): Bootstrap4Button
{
if (in_array($style, $this->supported_bg_styles) === true &&
$style !== 'link'
) {
$this->outline_style = $style;
} else {
$this->outline_style = 'primary';
}
return $this;
}
|
[
"public",
"function",
"setOutlineStyle",
"(",
"string",
"$",
"style",
")",
":",
"Bootstrap4Button",
"{",
"if",
"(",
"in_array",
"(",
"$",
"style",
",",
"$",
"this",
"->",
"supported_bg_styles",
")",
"===",
"true",
"&&",
"$",
"style",
"!==",
"'link'",
")",
"{",
"$",
"this",
"->",
"outline_style",
"=",
"$",
"style",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"outline_style",
"=",
"'primary'",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set the outline style for the button, one of the following, primary, secondary, success,
info, warning or danger. If an incorrect style is passed in we set the style to
btn-outline-primary
@param string $style
@return Bootstrap4Button
|
[
"Set",
"the",
"outline",
"style",
"for",
"the",
"button",
"one",
"of",
"the",
"following",
"primary",
"secondary",
"success",
"info",
"warning",
"or",
"danger",
".",
"If",
"an",
"incorrect",
"style",
"is",
"passed",
"in",
"we",
"set",
"the",
"style",
"to",
"btn",
"-",
"outline",
"-",
"primary"
] |
db8bea4ca62709b2ac8c732aedbb2a5235223f23
|
https://github.com/deanblackborough/zf3-view-helpers/blob/db8bea4ca62709b2ac8c732aedbb2a5235223f23/src/Bootstrap4Button.php#L111-L123
|
230,192
|
themsaid/katana-core
|
src/BlogPaginationBuilder.php
|
BlogPaginationBuilder.build
|
public function build()
{
$view = $this->getPostsListView();
$postsPerPage = @$this->viewsData['postsPerPage'] ?: 5;
$this->pagesData = array_chunk($this->viewsData['blogPosts'], $postsPerPage);
foreach ($this->pagesData as $pageIndex => $posts) {
$this->buildPage($pageIndex, $view, $posts);
}
}
|
php
|
public function build()
{
$view = $this->getPostsListView();
$postsPerPage = @$this->viewsData['postsPerPage'] ?: 5;
$this->pagesData = array_chunk($this->viewsData['blogPosts'], $postsPerPage);
foreach ($this->pagesData as $pageIndex => $posts) {
$this->buildPage($pageIndex, $view, $posts);
}
}
|
[
"public",
"function",
"build",
"(",
")",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"getPostsListView",
"(",
")",
";",
"$",
"postsPerPage",
"=",
"@",
"$",
"this",
"->",
"viewsData",
"[",
"'postsPerPage'",
"]",
"?",
":",
"5",
";",
"$",
"this",
"->",
"pagesData",
"=",
"array_chunk",
"(",
"$",
"this",
"->",
"viewsData",
"[",
"'blogPosts'",
"]",
",",
"$",
"postsPerPage",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"pagesData",
"as",
"$",
"pageIndex",
"=>",
"$",
"posts",
")",
"{",
"$",
"this",
"->",
"buildPage",
"(",
"$",
"pageIndex",
",",
"$",
"view",
",",
"$",
"posts",
")",
";",
"}",
"}"
] |
Build blog pagination files.
@return void
|
[
"Build",
"blog",
"pagination",
"files",
"."
] |
897c1adb6863d5145f1f104cbc8c9200cd98c3fb
|
https://github.com/themsaid/katana-core/blob/897c1adb6863d5145f1f104cbc8c9200cd98c3fb/src/BlogPaginationBuilder.php#L34-L45
|
230,193
|
themsaid/katana-core
|
src/BlogPaginationBuilder.php
|
BlogPaginationBuilder.getPostsListView
|
protected function getPostsListView()
{
if (! isset($this->viewsData['postsListView'])) {
throw new \Exception('The postsListView config value is missing.');
}
if (! $this->viewFactory->exists($this->viewsData['postsListView'])) {
throw new \Exception(sprintf('The "%s" view is not found. Make sure the postsListView configuration key is correct.', $this->viewsData['postsListView']));
}
return $this->viewsData['postsListView'];
}
|
php
|
protected function getPostsListView()
{
if (! isset($this->viewsData['postsListView'])) {
throw new \Exception('The postsListView config value is missing.');
}
if (! $this->viewFactory->exists($this->viewsData['postsListView'])) {
throw new \Exception(sprintf('The "%s" view is not found. Make sure the postsListView configuration key is correct.', $this->viewsData['postsListView']));
}
return $this->viewsData['postsListView'];
}
|
[
"protected",
"function",
"getPostsListView",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"viewsData",
"[",
"'postsListView'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'The postsListView config value is missing.'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"viewFactory",
"->",
"exists",
"(",
"$",
"this",
"->",
"viewsData",
"[",
"'postsListView'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'The \"%s\" view is not found. Make sure the postsListView configuration key is correct.'",
",",
"$",
"this",
"->",
"viewsData",
"[",
"'postsListView'",
"]",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"viewsData",
"[",
"'postsListView'",
"]",
";",
"}"
] |
Get the name of the view to be used for pages.
@return mixed
@throws \Exception
|
[
"Get",
"the",
"name",
"of",
"the",
"view",
"to",
"be",
"used",
"for",
"pages",
"."
] |
897c1adb6863d5145f1f104cbc8c9200cd98c3fb
|
https://github.com/themsaid/katana-core/blob/897c1adb6863d5145f1f104cbc8c9200cd98c3fb/src/BlogPaginationBuilder.php#L53-L64
|
230,194
|
themsaid/katana-core
|
src/BlogPaginationBuilder.php
|
BlogPaginationBuilder.buildPage
|
protected function buildPage($pageIndex, $view, $posts)
{
$viewData = array_merge(
$this->viewsData,
[
'paginatedBlogPosts' => $posts,
'previousPage' => $this->getPreviousPageLink($pageIndex),
'nextPage' => $this->getNextPageLink($pageIndex),
]
);
$pageContent = $this->viewFactory->make($view, $viewData)->render();
$directory = sprintf('%s/blog-page/%d', KATANA_PUBLIC_DIR, $pageIndex + 1);
$this->filesystem->makeDirectory($directory, 0755, true);
$this->filesystem->put(
sprintf('%s/%s', $directory, 'index.html'),
$pageContent
);
}
|
php
|
protected function buildPage($pageIndex, $view, $posts)
{
$viewData = array_merge(
$this->viewsData,
[
'paginatedBlogPosts' => $posts,
'previousPage' => $this->getPreviousPageLink($pageIndex),
'nextPage' => $this->getNextPageLink($pageIndex),
]
);
$pageContent = $this->viewFactory->make($view, $viewData)->render();
$directory = sprintf('%s/blog-page/%d', KATANA_PUBLIC_DIR, $pageIndex + 1);
$this->filesystem->makeDirectory($directory, 0755, true);
$this->filesystem->put(
sprintf('%s/%s', $directory, 'index.html'),
$pageContent
);
}
|
[
"protected",
"function",
"buildPage",
"(",
"$",
"pageIndex",
",",
"$",
"view",
",",
"$",
"posts",
")",
"{",
"$",
"viewData",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"viewsData",
",",
"[",
"'paginatedBlogPosts'",
"=>",
"$",
"posts",
",",
"'previousPage'",
"=>",
"$",
"this",
"->",
"getPreviousPageLink",
"(",
"$",
"pageIndex",
")",
",",
"'nextPage'",
"=>",
"$",
"this",
"->",
"getNextPageLink",
"(",
"$",
"pageIndex",
")",
",",
"]",
")",
";",
"$",
"pageContent",
"=",
"$",
"this",
"->",
"viewFactory",
"->",
"make",
"(",
"$",
"view",
",",
"$",
"viewData",
")",
"->",
"render",
"(",
")",
";",
"$",
"directory",
"=",
"sprintf",
"(",
"'%s/blog-page/%d'",
",",
"KATANA_PUBLIC_DIR",
",",
"$",
"pageIndex",
"+",
"1",
")",
";",
"$",
"this",
"->",
"filesystem",
"->",
"makeDirectory",
"(",
"$",
"directory",
",",
"0755",
",",
"true",
")",
";",
"$",
"this",
"->",
"filesystem",
"->",
"put",
"(",
"sprintf",
"(",
"'%s/%s'",
",",
"$",
"directory",
",",
"'index.html'",
")",
",",
"$",
"pageContent",
")",
";",
"}"
] |
Build a pagination page.
@param integer $pageIndex
@param string $view
@param array $posts
@return void
|
[
"Build",
"a",
"pagination",
"page",
"."
] |
897c1adb6863d5145f1f104cbc8c9200cd98c3fb
|
https://github.com/themsaid/katana-core/blob/897c1adb6863d5145f1f104cbc8c9200cd98c3fb/src/BlogPaginationBuilder.php#L75-L96
|
230,195
|
themsaid/katana-core
|
src/BlogPaginationBuilder.php
|
BlogPaginationBuilder.getPreviousPageLink
|
protected function getPreviousPageLink($currentPageIndex)
{
if (! isset($this->pagesData[$currentPageIndex - 1])) {
return null;
} elseif ($currentPageIndex == 1) {
// If the current page is the second, then the first page's
// link should point to the blog's main view.
return '/'.$this->getBlogListPagePath();
}
return '/blog-page/'.$currentPageIndex.'/';
}
|
php
|
protected function getPreviousPageLink($currentPageIndex)
{
if (! isset($this->pagesData[$currentPageIndex - 1])) {
return null;
} elseif ($currentPageIndex == 1) {
// If the current page is the second, then the first page's
// link should point to the blog's main view.
return '/'.$this->getBlogListPagePath();
}
return '/blog-page/'.$currentPageIndex.'/';
}
|
[
"protected",
"function",
"getPreviousPageLink",
"(",
"$",
"currentPageIndex",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"pagesData",
"[",
"$",
"currentPageIndex",
"-",
"1",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"elseif",
"(",
"$",
"currentPageIndex",
"==",
"1",
")",
"{",
"// If the current page is the second, then the first page's",
"// link should point to the blog's main view.",
"return",
"'/'",
".",
"$",
"this",
"->",
"getBlogListPagePath",
"(",
")",
";",
"}",
"return",
"'/blog-page/'",
".",
"$",
"currentPageIndex",
".",
"'/'",
";",
"}"
] |
Get the link of the page before the given page.
@param integer $currentPageIndex
@return null|string
|
[
"Get",
"the",
"link",
"of",
"the",
"page",
"before",
"the",
"given",
"page",
"."
] |
897c1adb6863d5145f1f104cbc8c9200cd98c3fb
|
https://github.com/themsaid/katana-core/blob/897c1adb6863d5145f1f104cbc8c9200cd98c3fb/src/BlogPaginationBuilder.php#L105-L116
|
230,196
|
themsaid/katana-core
|
src/BlogPaginationBuilder.php
|
BlogPaginationBuilder.getBlogListPagePath
|
protected function getBlogListPagePath()
{
$path = str_replace('.', '/', $this->viewsData['postsListView']);
if (ends_with($path, 'index')) {
return rtrim($path, '/index');
}
return $path;
}
|
php
|
protected function getBlogListPagePath()
{
$path = str_replace('.', '/', $this->viewsData['postsListView']);
if (ends_with($path, 'index')) {
return rtrim($path, '/index');
}
return $path;
}
|
[
"protected",
"function",
"getBlogListPagePath",
"(",
")",
"{",
"$",
"path",
"=",
"str_replace",
"(",
"'.'",
",",
"'/'",
",",
"$",
"this",
"->",
"viewsData",
"[",
"'postsListView'",
"]",
")",
";",
"if",
"(",
"ends_with",
"(",
"$",
"path",
",",
"'index'",
")",
")",
"{",
"return",
"rtrim",
"(",
"$",
"path",
",",
"'/index'",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
] |
Get the URL path to the blog list page.
@return string
|
[
"Get",
"the",
"URL",
"path",
"to",
"the",
"blog",
"list",
"page",
"."
] |
897c1adb6863d5145f1f104cbc8c9200cd98c3fb
|
https://github.com/themsaid/katana-core/blob/897c1adb6863d5145f1f104cbc8c9200cd98c3fb/src/BlogPaginationBuilder.php#L139-L148
|
230,197
|
Webiny/Framework
|
src/Webiny/Component/Http/Cookie.php
|
Cookie.get
|
public function get($name)
{
return $this->cookieBag->key($this->cookiePrefix . $name, false, true);
}
|
php
|
public function get($name)
{
return $this->cookieBag->key($this->cookiePrefix . $name, false, true);
}
|
[
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"return",
"$",
"this",
"->",
"cookieBag",
"->",
"key",
"(",
"$",
"this",
"->",
"cookiePrefix",
".",
"$",
"name",
",",
"false",
",",
"true",
")",
";",
"}"
] |
Get the cookie.
@param string $name Cookie name.
@return string|bool String if cookie is found, false if cookie is not found.
|
[
"Get",
"the",
"cookie",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Http/Cookie.php#L102-L105
|
230,198
|
Webiny/Framework
|
src/Webiny/Component/Http/Cookie.php
|
Cookie.delete
|
public function delete($name)
{
try {
$result = $this->getStorage()->delete($this->cookiePrefix . $name);
$this->cookieBag->removeKey($this->cookiePrefix . $name);
} catch (\Exception $e) {
throw new CookieException($e->getMessage());
}
return $result;
}
|
php
|
public function delete($name)
{
try {
$result = $this->getStorage()->delete($this->cookiePrefix . $name);
$this->cookieBag->removeKey($this->cookiePrefix . $name);
} catch (\Exception $e) {
throw new CookieException($e->getMessage());
}
return $result;
}
|
[
"public",
"function",
"delete",
"(",
"$",
"name",
")",
"{",
"try",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getStorage",
"(",
")",
"->",
"delete",
"(",
"$",
"this",
"->",
"cookiePrefix",
".",
"$",
"name",
")",
";",
"$",
"this",
"->",
"cookieBag",
"->",
"removeKey",
"(",
"$",
"this",
"->",
"cookiePrefix",
".",
"$",
"name",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"CookieException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Remove the given cookie.
@param string $name Cookie name.
@return bool True if cookie was deleted, or if it doesn't exist, otherwise false.
@throws \Webiny\Component\Http\Cookie\CookieException
|
[
"Remove",
"the",
"given",
"cookie",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Http/Cookie.php#L115-L125
|
230,199
|
Webiny/Framework
|
src/Webiny/Component/Http/Cookie.php
|
Cookie.getStorage
|
private function getStorage(ConfigObject $config = null)
{
if (!isset($this->storage)) {
try {
$driver = $config->get('Storage.Driver', NativeStorage::class);
$this->storage = $this->factory($driver, CookieStorageInterface::class, [$config]);
} catch (Exception $e) {
throw new CookieException($e->getMessage());
}
}
return $this->storage;
}
|
php
|
private function getStorage(ConfigObject $config = null)
{
if (!isset($this->storage)) {
try {
$driver = $config->get('Storage.Driver', NativeStorage::class);
$this->storage = $this->factory($driver, CookieStorageInterface::class, [$config]);
} catch (Exception $e) {
throw new CookieException($e->getMessage());
}
}
return $this->storage;
}
|
[
"private",
"function",
"getStorage",
"(",
"ConfigObject",
"$",
"config",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"storage",
")",
")",
"{",
"try",
"{",
"$",
"driver",
"=",
"$",
"config",
"->",
"get",
"(",
"'Storage.Driver'",
",",
"NativeStorage",
"::",
"class",
")",
";",
"$",
"this",
"->",
"storage",
"=",
"$",
"this",
"->",
"factory",
"(",
"$",
"driver",
",",
"CookieStorageInterface",
"::",
"class",
",",
"[",
"$",
"config",
"]",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"CookieException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"storage",
";",
"}"
] |
Get cookie storage driver.
@param ConfigObject|null $config Cookie config - needed only if storage driver does not yet exist.
@return CookieStorageInterface
@throws \Webiny\Component\Http\Cookie\CookieException
|
[
"Get",
"cookie",
"storage",
"driver",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Http/Cookie.php#L135-L147
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.