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
32,400
chameleon-system/chameleon-shop
src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerIPaymentEndPoint.class.php
TShopPaymentHandlerIPaymentEndPoint.GetResultFormResponse
protected function GetResultFormResponse($response) { $aNeededResponseParameterToCheck = array('ret_status' => '', 'ret_errormsg' => '', 'trxuser_id' => '', 'trx_amount' => '', 'trx_currency' => '', 'ret_authcode' => '', 'ret_trx_number' => '', 'ret_param_checksum' => ''); preg_match('/<a href=".*'.self::URL_PARAMETER_NAME.'\\/(success|error)\?(.*)">/', $response, $aMatch); if (count($aMatch) > 2) { $aResponseParts = explode('&', $aMatch[2]); foreach ($aResponseParts as $sRepsponsePart) { $aResponseKeyValue = explode('=', $sRepsponsePart); if (2 == count($aResponseKeyValue) && array_key_exists($aResponseKeyValue[0], $aNeededResponseParameterToCheck)) { $aNeededResponseParameterToCheck[$aResponseKeyValue[0]] = $aResponseKeyValue[1]; } } } return $aNeededResponseParameterToCheck; }
php
protected function GetResultFormResponse($response) { $aNeededResponseParameterToCheck = array('ret_status' => '', 'ret_errormsg' => '', 'trxuser_id' => '', 'trx_amount' => '', 'trx_currency' => '', 'ret_authcode' => '', 'ret_trx_number' => '', 'ret_param_checksum' => ''); preg_match('/<a href=".*'.self::URL_PARAMETER_NAME.'\\/(success|error)\?(.*)">/', $response, $aMatch); if (count($aMatch) > 2) { $aResponseParts = explode('&', $aMatch[2]); foreach ($aResponseParts as $sRepsponsePart) { $aResponseKeyValue = explode('=', $sRepsponsePart); if (2 == count($aResponseKeyValue) && array_key_exists($aResponseKeyValue[0], $aNeededResponseParameterToCheck)) { $aNeededResponseParameterToCheck[$aResponseKeyValue[0]] = $aResponseKeyValue[1]; } } } return $aNeededResponseParameterToCheck; }
[ "protected", "function", "GetResultFormResponse", "(", "$", "response", ")", "{", "$", "aNeededResponseParameterToCheck", "=", "array", "(", "'ret_status'", "=>", "''", ",", "'ret_errormsg'", "=>", "''", ",", "'trxuser_id'", "=>", "''", ",", "'trx_amount'", "=>", "''", ",", "'trx_currency'", "=>", "''", ",", "'ret_authcode'", "=>", "''", ",", "'ret_trx_number'", "=>", "''", ",", "'ret_param_checksum'", "=>", "''", ")", ";", "preg_match", "(", "'/<a href=\".*'", ".", "self", "::", "URL_PARAMETER_NAME", ".", "'\\\\/(success|error)\\?(.*)\">/'", ",", "$", "response", ",", "$", "aMatch", ")", ";", "if", "(", "count", "(", "$", "aMatch", ")", ">", "2", ")", "{", "$", "aResponseParts", "=", "explode", "(", "'&'", ",", "$", "aMatch", "[", "2", "]", ")", ";", "foreach", "(", "$", "aResponseParts", "as", "$", "sRepsponsePart", ")", "{", "$", "aResponseKeyValue", "=", "explode", "(", "'='", ",", "$", "sRepsponsePart", ")", ";", "if", "(", "2", "==", "count", "(", "$", "aResponseKeyValue", ")", "&&", "array_key_exists", "(", "$", "aResponseKeyValue", "[", "0", "]", ",", "$", "aNeededResponseParameterToCheck", ")", ")", "{", "$", "aNeededResponseParameterToCheck", "[", "$", "aResponseKeyValue", "[", "0", "]", "]", "=", "$", "aResponseKeyValue", "[", "1", "]", ";", "}", "}", "}", "return", "$", "aNeededResponseParameterToCheck", ";", "}" ]
Get parameter from IPayment response which are needed to check if payment request was successful. @param string $response @return array $aNeededResponseParameterToCheck
[ "Get", "parameter", "from", "IPayment", "response", "which", "are", "needed", "to", "check", "if", "payment", "request", "was", "successful", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerIPaymentEndPoint.class.php#L593-L608
32,401
chameleon-system/chameleon-shop
src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerIPaymentEndPoint.class.php
TShopPaymentHandlerIPaymentEndPoint.GetNeedeResponsePostParameterForSecurityCheck
protected function GetNeedeResponsePostParameterForSecurityCheck() { $aParameter = array(); $oGlobal = TGlobal::instance(); $aParameter['trxuser_id'] = $oGlobal->GetUserData('trxuser_id'); $aParameter['trx_amount'] = $oGlobal->GetUserData('trx_amount'); $aParameter['trx_currency'] = $oGlobal->GetUserData('trx_currency'); $aParameter['ret_authcode'] = $oGlobal->GetUserData('ret_authcode'); $aParameter['ret_trx_number'] = $oGlobal->GetUserData('ret_trx_number'); $aParameter['ret_param_checksum'] = $oGlobal->GetUserData('ret_param_checksum'); return $aParameter; }
php
protected function GetNeedeResponsePostParameterForSecurityCheck() { $aParameter = array(); $oGlobal = TGlobal::instance(); $aParameter['trxuser_id'] = $oGlobal->GetUserData('trxuser_id'); $aParameter['trx_amount'] = $oGlobal->GetUserData('trx_amount'); $aParameter['trx_currency'] = $oGlobal->GetUserData('trx_currency'); $aParameter['ret_authcode'] = $oGlobal->GetUserData('ret_authcode'); $aParameter['ret_trx_number'] = $oGlobal->GetUserData('ret_trx_number'); $aParameter['ret_param_checksum'] = $oGlobal->GetUserData('ret_param_checksum'); return $aParameter; }
[ "protected", "function", "GetNeedeResponsePostParameterForSecurityCheck", "(", ")", "{", "$", "aParameter", "=", "array", "(", ")", ";", "$", "oGlobal", "=", "TGlobal", "::", "instance", "(", ")", ";", "$", "aParameter", "[", "'trxuser_id'", "]", "=", "$", "oGlobal", "->", "GetUserData", "(", "'trxuser_id'", ")", ";", "$", "aParameter", "[", "'trx_amount'", "]", "=", "$", "oGlobal", "->", "GetUserData", "(", "'trx_amount'", ")", ";", "$", "aParameter", "[", "'trx_currency'", "]", "=", "$", "oGlobal", "->", "GetUserData", "(", "'trx_currency'", ")", ";", "$", "aParameter", "[", "'ret_authcode'", "]", "=", "$", "oGlobal", "->", "GetUserData", "(", "'ret_authcode'", ")", ";", "$", "aParameter", "[", "'ret_trx_number'", "]", "=", "$", "oGlobal", "->", "GetUserData", "(", "'ret_trx_number'", ")", ";", "$", "aParameter", "[", "'ret_param_checksum'", "]", "=", "$", "oGlobal", "->", "GetUserData", "(", "'ret_param_checksum'", ")", ";", "return", "$", "aParameter", ";", "}" ]
Get response parameter from IPayment which are needed to make a security hash check. @return array $aParameter
[ "Get", "response", "parameter", "from", "IPayment", "which", "are", "needed", "to", "make", "a", "security", "hash", "check", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerIPaymentEndPoint.class.php#L615-L627
32,402
chameleon-system/chameleon-shop
src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerIPaymentEndPoint.class.php
TShopPaymentHandlerIPaymentEndPoint.bIsCorrectIPaymentType
protected function bIsCorrectIPaymentType() { $bIsCorrectIPaymentType = false; $aParameter = $this->GetPaymentTypeSpecifivParameter(); $oGlobal = TGlobal::instance(); $sResponsePaymentType = $oGlobal->GetUserData('trx_paymenttyp'); if (!empty($sResponsePaymentType) && array_key_exists('trx_paymenttyp', $aParameter) && $aParameter['trx_paymenttyp'] == $sResponsePaymentType) { $bIsCorrectIPaymentType = true; } return $bIsCorrectIPaymentType; }
php
protected function bIsCorrectIPaymentType() { $bIsCorrectIPaymentType = false; $aParameter = $this->GetPaymentTypeSpecifivParameter(); $oGlobal = TGlobal::instance(); $sResponsePaymentType = $oGlobal->GetUserData('trx_paymenttyp'); if (!empty($sResponsePaymentType) && array_key_exists('trx_paymenttyp', $aParameter) && $aParameter['trx_paymenttyp'] == $sResponsePaymentType) { $bIsCorrectIPaymentType = true; } return $bIsCorrectIPaymentType; }
[ "protected", "function", "bIsCorrectIPaymentType", "(", ")", "{", "$", "bIsCorrectIPaymentType", "=", "false", ";", "$", "aParameter", "=", "$", "this", "->", "GetPaymentTypeSpecifivParameter", "(", ")", ";", "$", "oGlobal", "=", "TGlobal", "::", "instance", "(", ")", ";", "$", "sResponsePaymentType", "=", "$", "oGlobal", "->", "GetUserData", "(", "'trx_paymenttyp'", ")", ";", "if", "(", "!", "empty", "(", "$", "sResponsePaymentType", ")", "&&", "array_key_exists", "(", "'trx_paymenttyp'", ",", "$", "aParameter", ")", "&&", "$", "aParameter", "[", "'trx_paymenttyp'", "]", "==", "$", "sResponsePaymentType", ")", "{", "$", "bIsCorrectIPaymentType", "=", "true", ";", "}", "return", "$", "bIsCorrectIPaymentType", ";", "}" ]
Check after response from IPayment if the paymenthandler is the one which sent request to IPayment. @return bool $bIsCorrectIPaymentType
[ "Check", "after", "response", "from", "IPayment", "if", "the", "paymenthandler", "is", "the", "one", "which", "sent", "request", "to", "IPayment", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerIPaymentEndPoint.class.php#L634-L645
32,403
sylingd/Yesf
src/Event/Listener.php
Listener.on
public function on($event, $callback) { if (!is_callable($callback)) { throw new ListenException(var_export($callback, true) . " is not callback"); } $this->callback[$event] = $callback; }
php
public function on($event, $callback) { if (!is_callable($callback)) { throw new ListenException(var_export($callback, true) . " is not callback"); } $this->callback[$event] = $callback; }
[ "public", "function", "on", "(", "$", "event", ",", "$", "callback", ")", "{", "if", "(", "!", "is_callable", "(", "$", "callback", ")", ")", "{", "throw", "new", "ListenException", "(", "var_export", "(", "$", "callback", ",", "true", ")", ".", "\" is not callback\"", ")", ";", "}", "$", "this", "->", "callback", "[", "$", "event", "]", "=", "$", "callback", ";", "}" ]
Set event handler @access public @param string $event @param callable $callback
[ "Set", "event", "handler" ]
0fc2b42903bb3519c54c596270c890c826aeb1df
https://github.com/sylingd/Yesf/blob/0fc2b42903bb3519c54c596270c890c826aeb1df/src/Event/Listener.php#L190-L195
32,404
edmondscommerce/doctrine-static-meta
src/Entity/Embeddable/Objects/AbstractEmbeddableObject.php
AbstractEmbeddableObject.notifyEmbeddablePrefixedProperties
protected function notifyEmbeddablePrefixedProperties( ?string $propName = null, $oldValue = null, $newValue = null ): void { if (null === $this->owningEntity) { return; } $this->owningEntity->notifyEmbeddablePrefixedProperties( $this->getPrefix(), $propName, $oldValue, $newValue ); }
php
protected function notifyEmbeddablePrefixedProperties( ?string $propName = null, $oldValue = null, $newValue = null ): void { if (null === $this->owningEntity) { return; } $this->owningEntity->notifyEmbeddablePrefixedProperties( $this->getPrefix(), $propName, $oldValue, $newValue ); }
[ "protected", "function", "notifyEmbeddablePrefixedProperties", "(", "?", "string", "$", "propName", "=", "null", ",", "$", "oldValue", "=", "null", ",", "$", "newValue", "=", "null", ")", ":", "void", "{", "if", "(", "null", "===", "$", "this", "->", "owningEntity", ")", "{", "return", ";", "}", "$", "this", "->", "owningEntity", "->", "notifyEmbeddablePrefixedProperties", "(", "$", "this", "->", "getPrefix", "(", ")", ",", "$", "propName", ",", "$", "oldValue", ",", "$", "newValue", ")", ";", "}" ]
If we are attached to an owning Entity, then we need to use it to Notify the Unit of Work about changes If we are not attached, then do nothing. When we are attached, this should be triggered automatically @param null|string $propName @param null|mixed $oldValue @param null|mixed $newValue
[ "If", "we", "are", "attached", "to", "an", "owning", "Entity", "then", "we", "need", "to", "use", "it", "to", "Notify", "the", "Unit", "of", "Work", "about", "changes" ]
c5b1caab0b2e3a84c34082af96529a274f0c3d7e
https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/Entity/Embeddable/Objects/AbstractEmbeddableObject.php#L41-L55
32,405
chameleon-system/chameleon-shop
src/ShopBundle/objects/db/TShopCategory.class.php
TShopCategory.GetNumberOfArticlesInCategory
public function GetNumberOfArticlesInCategory($bIncludeSubcategoriesInCount = false) { if ($bIncludeSubcategoriesInCount) { $oArticleList = $this->GetArticleListIncludingSubcategories(); } else { $oArticleList = $this->GetArticleList(); } return $oArticleList->Length(); }
php
public function GetNumberOfArticlesInCategory($bIncludeSubcategoriesInCount = false) { if ($bIncludeSubcategoriesInCount) { $oArticleList = $this->GetArticleListIncludingSubcategories(); } else { $oArticleList = $this->GetArticleList(); } return $oArticleList->Length(); }
[ "public", "function", "GetNumberOfArticlesInCategory", "(", "$", "bIncludeSubcategoriesInCount", "=", "false", ")", "{", "if", "(", "$", "bIncludeSubcategoriesInCount", ")", "{", "$", "oArticleList", "=", "$", "this", "->", "GetArticleListIncludingSubcategories", "(", ")", ";", "}", "else", "{", "$", "oArticleList", "=", "$", "this", "->", "GetArticleList", "(", ")", ";", "}", "return", "$", "oArticleList", "->", "Length", "(", ")", ";", "}" ]
returns a count of the number of articles in the category. the method caches the data since a count is expensive. @param bool $bIncludeSubcategoriesInCount @return int
[ "returns", "a", "count", "of", "the", "number", "of", "articles", "in", "the", "category", ".", "the", "method", "caches", "the", "data", "since", "a", "count", "is", "expensive", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopCategory.class.php#L162-L171
32,406
chameleon-system/chameleon-shop
src/ShopBundle/objects/db/TShopCategory.class.php
TShopCategory.&
public function &GetParent() { $oParent = null; if (!empty($this->fieldShopCategoryId)) { $oParent = TdbShopCategory::GetNewInstance(); $oParent->SetLanguage($this->iLanguageId); if (!$oParent->Load($this->fieldShopCategoryId)) { $oParent = null; } } return $oParent; }
php
public function &GetParent() { $oParent = null; if (!empty($this->fieldShopCategoryId)) { $oParent = TdbShopCategory::GetNewInstance(); $oParent->SetLanguage($this->iLanguageId); if (!$oParent->Load($this->fieldShopCategoryId)) { $oParent = null; } } return $oParent; }
[ "public", "function", "&", "GetParent", "(", ")", "{", "$", "oParent", "=", "null", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "fieldShopCategoryId", ")", ")", "{", "$", "oParent", "=", "TdbShopCategory", "::", "GetNewInstance", "(", ")", ";", "$", "oParent", "->", "SetLanguage", "(", "$", "this", "->", "iLanguageId", ")", ";", "if", "(", "!", "$", "oParent", "->", "Load", "(", "$", "this", "->", "fieldShopCategoryId", ")", ")", "{", "$", "oParent", "=", "null", ";", "}", "}", "return", "$", "oParent", ";", "}" ]
return the parent category, or null if no parent is found. @return TdbShopCategory
[ "return", "the", "parent", "category", "or", "null", "if", "no", "parent", "is", "found", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopCategory.class.php#L226-L238
32,407
chameleon-system/chameleon-shop
src/ShopBundle/objects/db/TShopCategory.class.php
TShopCategory.IsInCategoryPath
public function IsInCategoryPath($sCategoryId) { $oBreadCrumb = $this->GetBreadcrumb(); $oMatchingNode = $oBreadCrumb->FindItemWithProperty('id', $sCategoryId); if ($oMatchingNode) { return true; } else { return false; } }
php
public function IsInCategoryPath($sCategoryId) { $oBreadCrumb = $this->GetBreadcrumb(); $oMatchingNode = $oBreadCrumb->FindItemWithProperty('id', $sCategoryId); if ($oMatchingNode) { return true; } else { return false; } }
[ "public", "function", "IsInCategoryPath", "(", "$", "sCategoryId", ")", "{", "$", "oBreadCrumb", "=", "$", "this", "->", "GetBreadcrumb", "(", ")", ";", "$", "oMatchingNode", "=", "$", "oBreadCrumb", "->", "FindItemWithProperty", "(", "'id'", ",", "$", "sCategoryId", ")", ";", "if", "(", "$", "oMatchingNode", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
return true if the category id passed is in the path to this category. @param string $sCategoryId @return bool
[ "return", "true", "if", "the", "category", "id", "passed", "is", "in", "the", "path", "to", "this", "category", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopCategory.class.php#L267-L276
32,408
chameleon-system/chameleon-shop
src/ShopBundle/objects/db/TShopCategory.class.php
TShopCategory.GetCategoryPathAsString
public function GetCategoryPathAsString($sSeparator = '/') { $sKey = 'sCatPathCache'.$sSeparator; $sPath = $this->GetFromInternalCache($sKey); if (is_null($sPath)) { $sPath = ''; $oParent = &$this->GetParent(); if ($oParent) { $sPath = $oParent->GetCategoryPathAsString($sSeparator); } if (!empty($sPath)) { $sPath .= $sSeparator; } $sPath .= $this->GetName(); $this->SetInternalCache($sKey, $sPath); } return $sPath; }
php
public function GetCategoryPathAsString($sSeparator = '/') { $sKey = 'sCatPathCache'.$sSeparator; $sPath = $this->GetFromInternalCache($sKey); if (is_null($sPath)) { $sPath = ''; $oParent = &$this->GetParent(); if ($oParent) { $sPath = $oParent->GetCategoryPathAsString($sSeparator); } if (!empty($sPath)) { $sPath .= $sSeparator; } $sPath .= $this->GetName(); $this->SetInternalCache($sKey, $sPath); } return $sPath; }
[ "public", "function", "GetCategoryPathAsString", "(", "$", "sSeparator", "=", "'/'", ")", "{", "$", "sKey", "=", "'sCatPathCache'", ".", "$", "sSeparator", ";", "$", "sPath", "=", "$", "this", "->", "GetFromInternalCache", "(", "$", "sKey", ")", ";", "if", "(", "is_null", "(", "$", "sPath", ")", ")", "{", "$", "sPath", "=", "''", ";", "$", "oParent", "=", "&", "$", "this", "->", "GetParent", "(", ")", ";", "if", "(", "$", "oParent", ")", "{", "$", "sPath", "=", "$", "oParent", "->", "GetCategoryPathAsString", "(", "$", "sSeparator", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "sPath", ")", ")", "{", "$", "sPath", ".=", "$", "sSeparator", ";", "}", "$", "sPath", ".=", "$", "this", "->", "GetName", "(", ")", ";", "$", "this", "->", "SetInternalCache", "(", "$", "sKey", ",", "$", "sPath", ")", ";", "}", "return", "$", "sPath", ";", "}" ]
return the category path as a string, each node separated by the sSeparator. @param string $sSeparator @return string
[ "return", "the", "category", "path", "as", "a", "string", "each", "node", "separated", "by", "the", "sSeparator", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopCategory.class.php#L285-L304
32,409
chameleon-system/chameleon-shop
src/ShopBundle/objects/db/TShopCategory.class.php
TShopCategory.&
public function &GetRootCategory() { $oRootCategory = &$this->GetFromInternalCache('oRootCategory'); if (is_null($oRootCategory)) { $oRootCategory = clone $this; while (!empty($oRootCategory->fieldShopCategoryId)) { $oRootCategory = &$oRootCategory->GetParent(); } $this->SetInternalCache('oRootCategory', $oRootCategory); } return $oRootCategory; }
php
public function &GetRootCategory() { $oRootCategory = &$this->GetFromInternalCache('oRootCategory'); if (is_null($oRootCategory)) { $oRootCategory = clone $this; while (!empty($oRootCategory->fieldShopCategoryId)) { $oRootCategory = &$oRootCategory->GetParent(); } $this->SetInternalCache('oRootCategory', $oRootCategory); } return $oRootCategory; }
[ "public", "function", "&", "GetRootCategory", "(", ")", "{", "$", "oRootCategory", "=", "&", "$", "this", "->", "GetFromInternalCache", "(", "'oRootCategory'", ")", ";", "if", "(", "is_null", "(", "$", "oRootCategory", ")", ")", "{", "$", "oRootCategory", "=", "clone", "$", "this", ";", "while", "(", "!", "empty", "(", "$", "oRootCategory", "->", "fieldShopCategoryId", ")", ")", "{", "$", "oRootCategory", "=", "&", "$", "oRootCategory", "->", "GetParent", "(", ")", ";", "}", "$", "this", "->", "SetInternalCache", "(", "'oRootCategory'", ",", "$", "oRootCategory", ")", ";", "}", "return", "$", "oRootCategory", ";", "}" ]
return the currents category root category. @return TdbShopCategory
[ "return", "the", "currents", "category", "root", "category", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopCategory.class.php#L311-L323
32,410
chameleon-system/chameleon-shop
src/ShopBundle/objects/db/TShopCategory.class.php
TShopCategory.&
public function &GetBreadcrumb() { $oBreadCrumb = &$this->GetFromInternalCache('oCategoryBreadcrumb'); if (is_null($oBreadCrumb)) { $oBreadCrumb = &TdbShopCategoryList::GetCategoryPath($this->id, null, $this->GetLanguage()); $this->SetInternalCache('oCategoryBreadcrumb', $oBreadCrumb); } else { $oBreadCrumb->GoToStart(); } return $oBreadCrumb; }
php
public function &GetBreadcrumb() { $oBreadCrumb = &$this->GetFromInternalCache('oCategoryBreadcrumb'); if (is_null($oBreadCrumb)) { $oBreadCrumb = &TdbShopCategoryList::GetCategoryPath($this->id, null, $this->GetLanguage()); $this->SetInternalCache('oCategoryBreadcrumb', $oBreadCrumb); } else { $oBreadCrumb->GoToStart(); } return $oBreadCrumb; }
[ "public", "function", "&", "GetBreadcrumb", "(", ")", "{", "$", "oBreadCrumb", "=", "&", "$", "this", "->", "GetFromInternalCache", "(", "'oCategoryBreadcrumb'", ")", ";", "if", "(", "is_null", "(", "$", "oBreadCrumb", ")", ")", "{", "$", "oBreadCrumb", "=", "&", "TdbShopCategoryList", "::", "GetCategoryPath", "(", "$", "this", "->", "id", ",", "null", ",", "$", "this", "->", "GetLanguage", "(", ")", ")", ";", "$", "this", "->", "SetInternalCache", "(", "'oCategoryBreadcrumb'", ",", "$", "oBreadCrumb", ")", ";", "}", "else", "{", "$", "oBreadCrumb", "->", "GoToStart", "(", ")", ";", "}", "return", "$", "oBreadCrumb", ";", "}" ]
return a list of all categories to the current category. @return TIterator
[ "return", "a", "list", "of", "all", "categories", "to", "the", "current", "category", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopCategory.class.php#L330-L341
32,411
chameleon-system/chameleon-shop
src/ShopBundle/objects/db/TShopCategory.class.php
TShopCategory.AllowDisplayInShop
public function AllowDisplayInShop() { $bShowCat = false; $oShop = TdbShop::GetInstance(); if (!is_null($oShop) && !$oShop->fieldShowEmptyCategories) { $bShowCat = ($this->GetNumberOfArticlesInCategory(true) > 0); } else { $bShowCat = true; } if (false == $this->fieldActive || false == $this->fieldTreeActive) { $bShowCat = false; } $targetPage = $this->getTargetPage(); if (null === $targetPage || false === $targetPage) { return true; } // show only if the user has access to the category target page if (false === $targetPage->AllowAccessByCurrentUser()) { return false; } return $bShowCat; }
php
public function AllowDisplayInShop() { $bShowCat = false; $oShop = TdbShop::GetInstance(); if (!is_null($oShop) && !$oShop->fieldShowEmptyCategories) { $bShowCat = ($this->GetNumberOfArticlesInCategory(true) > 0); } else { $bShowCat = true; } if (false == $this->fieldActive || false == $this->fieldTreeActive) { $bShowCat = false; } $targetPage = $this->getTargetPage(); if (null === $targetPage || false === $targetPage) { return true; } // show only if the user has access to the category target page if (false === $targetPage->AllowAccessByCurrentUser()) { return false; } return $bShowCat; }
[ "public", "function", "AllowDisplayInShop", "(", ")", "{", "$", "bShowCat", "=", "false", ";", "$", "oShop", "=", "TdbShop", "::", "GetInstance", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "oShop", ")", "&&", "!", "$", "oShop", "->", "fieldShowEmptyCategories", ")", "{", "$", "bShowCat", "=", "(", "$", "this", "->", "GetNumberOfArticlesInCategory", "(", "true", ")", ">", "0", ")", ";", "}", "else", "{", "$", "bShowCat", "=", "true", ";", "}", "if", "(", "false", "==", "$", "this", "->", "fieldActive", "||", "false", "==", "$", "this", "->", "fieldTreeActive", ")", "{", "$", "bShowCat", "=", "false", ";", "}", "$", "targetPage", "=", "$", "this", "->", "getTargetPage", "(", ")", ";", "if", "(", "null", "===", "$", "targetPage", "||", "false", "===", "$", "targetPage", ")", "{", "return", "true", ";", "}", "// show only if the user has access to the category target page", "if", "(", "false", "===", "$", "targetPage", "->", "AllowAccessByCurrentUser", "(", ")", ")", "{", "return", "false", ";", "}", "return", "$", "bShowCat", ";", "}" ]
Hook for implementing category display logic. @return bool
[ "Hook", "for", "implementing", "category", "display", "logic", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopCategory.class.php#L435-L460
32,412
chameleon-system/chameleon-shop
src/ShopBundle/objects/db/TShopCategory.class.php
TShopCategory.GetSeoPattern
public function GetSeoPattern(&$sPaternIn) { //$sPaternIn = "[{PORTAL_NAME}] - [{CATEGORY_NAME}]"; //default $aPatRepl = null; if (!empty($this->sqlData['seo_pattern'])) { $sPaternIn = $this->sqlData['seo_pattern']; } $aPatRepl = array(); $activePage = $this->getActivePageService()->getActivePage(); $aPatRepl['PORTAL_NAME'] = $activePage->GetPortal()->GetTitle(); $aPatRepl['PAGE_NAME'] = $activePage->GetName(); $aPatRepl['CATEGORY_NAME'] = $this->GetName(); return $aPatRepl; }
php
public function GetSeoPattern(&$sPaternIn) { //$sPaternIn = "[{PORTAL_NAME}] - [{CATEGORY_NAME}]"; //default $aPatRepl = null; if (!empty($this->sqlData['seo_pattern'])) { $sPaternIn = $this->sqlData['seo_pattern']; } $aPatRepl = array(); $activePage = $this->getActivePageService()->getActivePage(); $aPatRepl['PORTAL_NAME'] = $activePage->GetPortal()->GetTitle(); $aPatRepl['PAGE_NAME'] = $activePage->GetName(); $aPatRepl['CATEGORY_NAME'] = $this->GetName(); return $aPatRepl; }
[ "public", "function", "GetSeoPattern", "(", "&", "$", "sPaternIn", ")", "{", "//$sPaternIn = \"[{PORTAL_NAME}] - [{CATEGORY_NAME}]\"; //default", "$", "aPatRepl", "=", "null", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "sqlData", "[", "'seo_pattern'", "]", ")", ")", "{", "$", "sPaternIn", "=", "$", "this", "->", "sqlData", "[", "'seo_pattern'", "]", ";", "}", "$", "aPatRepl", "=", "array", "(", ")", ";", "$", "activePage", "=", "$", "this", "->", "getActivePageService", "(", ")", "->", "getActivePage", "(", ")", ";", "$", "aPatRepl", "[", "'PORTAL_NAME'", "]", "=", "$", "activePage", "->", "GetPortal", "(", ")", "->", "GetTitle", "(", ")", ";", "$", "aPatRepl", "[", "'PAGE_NAME'", "]", "=", "$", "activePage", "->", "GetName", "(", ")", ";", "$", "aPatRepl", "[", "'CATEGORY_NAME'", "]", "=", "$", "this", "->", "GetName", "(", ")", ";", "return", "$", "aPatRepl", ";", "}" ]
Get SEO pattern of actual article. @param string $sPaternIn @return array
[ "Get", "SEO", "pattern", "of", "actual", "article", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopCategory.class.php#L469-L485
32,413
chameleon-system/chameleon-shop
src/ShopBundle/objects/db/TShopCategory.class.php
TShopCategory.GetProductNameExtensions
public function GetProductNameExtensions() { $sName = trim($this->fieldNameProduct); if (empty($sName)) { $sName = $this->fieldName; } return $sName; }
php
public function GetProductNameExtensions() { $sName = trim($this->fieldNameProduct); if (empty($sName)) { $sName = $this->fieldName; } return $sName; }
[ "public", "function", "GetProductNameExtensions", "(", ")", "{", "$", "sName", "=", "trim", "(", "$", "this", "->", "fieldNameProduct", ")", ";", "if", "(", "empty", "(", "$", "sName", ")", ")", "{", "$", "sName", "=", "$", "this", "->", "fieldName", ";", "}", "return", "$", "sName", ";", "}" ]
return the part of the category that should be used as part of the product name. @return string
[ "return", "the", "part", "of", "the", "category", "that", "should", "be", "used", "as", "part", "of", "the", "product", "name", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopCategory.class.php#L500-L508
32,414
chameleon-system/chameleon-shop
src/ShopBundle/objects/db/TShopCategory.class.php
TShopCategory.GetCurrentColorCode
public function GetCurrentColorCode($sDefaultColor = '000000') { $oRootCat = $this->GetRootCategory(); /** @var $oRootCat TdbShopCategory */ $sColorcode = $oRootCat->fieldColorcode; if ('' == $sColorcode) { $sColorcode = $sDefaultColor; } return $sColorcode; }
php
public function GetCurrentColorCode($sDefaultColor = '000000') { $oRootCat = $this->GetRootCategory(); /** @var $oRootCat TdbShopCategory */ $sColorcode = $oRootCat->fieldColorcode; if ('' == $sColorcode) { $sColorcode = $sDefaultColor; } return $sColorcode; }
[ "public", "function", "GetCurrentColorCode", "(", "$", "sDefaultColor", "=", "'000000'", ")", "{", "$", "oRootCat", "=", "$", "this", "->", "GetRootCategory", "(", ")", ";", "/** @var $oRootCat TdbShopCategory */", "$", "sColorcode", "=", "$", "oRootCat", "->", "fieldColorcode", ";", "if", "(", "''", "==", "$", "sColorcode", ")", "{", "$", "sColorcode", "=", "$", "sDefaultColor", ";", "}", "return", "$", "sColorcode", ";", "}" ]
returns the category color. @param string $sDefaultColor - default color = black; @return string
[ "returns", "the", "category", "color", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopCategory.class.php#L517-L527
32,415
chameleon-system/chameleon-shop
src/ShopBundle/objects/db/TShopCategory.class.php
TShopCategory.parentCategoriesAreActive
public function parentCategoriesAreActive() { $treeIsActive = true; $parentCategoryList = $this->getParentCategories(); while ($category = $parentCategoryList->Next()) { if (false === $category->fieldActive) { $treeIsActive = false; break; } } return $treeIsActive; }
php
public function parentCategoriesAreActive() { $treeIsActive = true; $parentCategoryList = $this->getParentCategories(); while ($category = $parentCategoryList->Next()) { if (false === $category->fieldActive) { $treeIsActive = false; break; } } return $treeIsActive; }
[ "public", "function", "parentCategoriesAreActive", "(", ")", "{", "$", "treeIsActive", "=", "true", ";", "$", "parentCategoryList", "=", "$", "this", "->", "getParentCategories", "(", ")", ";", "while", "(", "$", "category", "=", "$", "parentCategoryList", "->", "Next", "(", ")", ")", "{", "if", "(", "false", "===", "$", "category", "->", "fieldActive", ")", "{", "$", "treeIsActive", "=", "false", ";", "break", ";", "}", "}", "return", "$", "treeIsActive", ";", "}" ]
return true if the tree until this category is active. @return bool
[ "return", "true", "if", "the", "tree", "until", "this", "category", "is", "active", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopCategory.class.php#L542-L554
32,416
edmondscommerce/doctrine-static-meta
codeTemplates/src/Entity/Savers/TemplateEntityUpserter.php
TemplateEntityUpserter.getUpsertDtoByCriteria
public function getUpsertDtoByCriteria( array $criteria, NewUpsertDtoDataModifierInterface $modifier ): TemplateEntityDto { $entity = $this->repository->findOneBy($criteria); if ($entity === null) { $dto = $this->dtoFactory->create(); $modifier->addDataToNewlyCreatedDto($dto); return $dto; } return $this->dtoFactory->createDtoFromTemplateEntity($entity); }
php
public function getUpsertDtoByCriteria( array $criteria, NewUpsertDtoDataModifierInterface $modifier ): TemplateEntityDto { $entity = $this->repository->findOneBy($criteria); if ($entity === null) { $dto = $this->dtoFactory->create(); $modifier->addDataToNewlyCreatedDto($dto); return $dto; } return $this->dtoFactory->createDtoFromTemplateEntity($entity); }
[ "public", "function", "getUpsertDtoByCriteria", "(", "array", "$", "criteria", ",", "NewUpsertDtoDataModifierInterface", "$", "modifier", ")", ":", "TemplateEntityDto", "{", "$", "entity", "=", "$", "this", "->", "repository", "->", "findOneBy", "(", "$", "criteria", ")", ";", "if", "(", "$", "entity", "===", "null", ")", "{", "$", "dto", "=", "$", "this", "->", "dtoFactory", "->", "create", "(", ")", ";", "$", "modifier", "->", "addDataToNewlyCreatedDto", "(", "$", "dto", ")", ";", "return", "$", "dto", ";", "}", "return", "$", "this", "->", "dtoFactory", "->", "createDtoFromTemplateEntity", "(", "$", "entity", ")", ";", "}" ]
This method is used to get a DTO using search criteria, when you are not certain if the entity exists or not. The criteria is passed through to the repository findOneBy method, if an entity is found then a DTO will be created from it and returned. If an entity is not found then a new empty DTO will be created and returned instead. @param array $criteria @param NewUpsertDtoDataModifierInterface $modifier @return TemplateEntityDto @see \Doctrine\ORM\EntityRepository::findOneBy for how to use the crietia
[ "This", "method", "is", "used", "to", "get", "a", "DTO", "using", "search", "criteria", "when", "you", "are", "not", "certain", "if", "the", "entity", "exists", "or", "not", ".", "The", "criteria", "is", "passed", "through", "to", "the", "repository", "findOneBy", "method", "if", "an", "entity", "is", "found", "then", "a", "DTO", "will", "be", "created", "from", "it", "and", "returned", "." ]
c5b1caab0b2e3a84c34082af96529a274f0c3d7e
https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/codeTemplates/src/Entity/Savers/TemplateEntityUpserter.php#L92-L105
32,417
edmondscommerce/doctrine-static-meta
codeTemplates/src/Entity/Savers/TemplateEntityUpserter.php
TemplateEntityUpserter.persistUpsertDto
public function persistUpsertDto(TemplateEntityDto $dto): TemplateEntityInterface { $entity = $this->convertUpsertDtoToEntity($dto); $this->saver->save($entity); return $entity; }
php
public function persistUpsertDto(TemplateEntityDto $dto): TemplateEntityInterface { $entity = $this->convertUpsertDtoToEntity($dto); $this->saver->save($entity); return $entity; }
[ "public", "function", "persistUpsertDto", "(", "TemplateEntityDto", "$", "dto", ")", ":", "TemplateEntityInterface", "{", "$", "entity", "=", "$", "this", "->", "convertUpsertDtoToEntity", "(", "$", "dto", ")", ";", "$", "this", "->", "saver", "->", "save", "(", "$", "entity", ")", ";", "return", "$", "entity", ";", "}" ]
This is used to persist the DTO to the database. If the DTO is for a new entity then it will be created, if it is for an existing Entity then it will be updated. Be aware that this method should __only__ be used with DTOs that have been created using the self::getUpsertDtoByCriteria method, as if they come from elsewhere we will not not if the entity needs to be created or updated @param TemplateEntityDto $dto @return TemplateEntityInterface @throws \Doctrine\DBAL\DBALException
[ "This", "is", "used", "to", "persist", "the", "DTO", "to", "the", "database", ".", "If", "the", "DTO", "is", "for", "a", "new", "entity", "then", "it", "will", "be", "created", "if", "it", "is", "for", "an", "existing", "Entity", "then", "it", "will", "be", "updated", "." ]
c5b1caab0b2e3a84c34082af96529a274f0c3d7e
https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/codeTemplates/src/Entity/Savers/TemplateEntityUpserter.php#L127-L133
32,418
edmondscommerce/doctrine-static-meta
codeTemplates/src/Entity/Savers/TemplateEntityUpserter.php
TemplateEntityUpserter.convertUpsertDtoToEntity
public function convertUpsertDtoToEntity(TemplateEntityDto $dto): TemplateEntityInterface { if ($this->unitOfWorkHelper->hasRecordOfDto($dto) === false) { $entity = $this->entityFactory->create($dto); return $entity; } $entity = $this->unitOfWorkHelper->getEntityFromUnitOfWorkUsingDto($dto); $entity->update($dto); return $entity; }
php
public function convertUpsertDtoToEntity(TemplateEntityDto $dto): TemplateEntityInterface { if ($this->unitOfWorkHelper->hasRecordOfDto($dto) === false) { $entity = $this->entityFactory->create($dto); return $entity; } $entity = $this->unitOfWorkHelper->getEntityFromUnitOfWorkUsingDto($dto); $entity->update($dto); return $entity; }
[ "public", "function", "convertUpsertDtoToEntity", "(", "TemplateEntityDto", "$", "dto", ")", ":", "TemplateEntityInterface", "{", "if", "(", "$", "this", "->", "unitOfWorkHelper", "->", "hasRecordOfDto", "(", "$", "dto", ")", "===", "false", ")", "{", "$", "entity", "=", "$", "this", "->", "entityFactory", "->", "create", "(", "$", "dto", ")", ";", "return", "$", "entity", ";", "}", "$", "entity", "=", "$", "this", "->", "unitOfWorkHelper", "->", "getEntityFromUnitOfWorkUsingDto", "(", "$", "dto", ")", ";", "$", "entity", "->", "update", "(", "$", "dto", ")", ";", "return", "$", "entity", ";", "}" ]
This method will convert the DTO into an entity, but will not save it. This is useful if you want to bulk create or update entities @param TemplateEntityDto $dto @return TemplateEntityInterface
[ "This", "method", "will", "convert", "the", "DTO", "into", "an", "entity", "but", "will", "not", "save", "it", ".", "This", "is", "useful", "if", "you", "want", "to", "bulk", "create", "or", "update", "entities" ]
c5b1caab0b2e3a84c34082af96529a274f0c3d7e
https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/codeTemplates/src/Entity/Savers/TemplateEntityUpserter.php#L143-L154
32,419
chameleon-system/chameleon-shop
src/ShopWishlistBundle/objects/db/TPkgShopWishlist.class.php
TPkgShopWishlist.AddArticle
public function AddArticle($sArticleId, $dAmount = 1, $sComment = null) { $dNewAmount = 0; $aItemData = array(); $oItem = TdbPkgShopWishlistArticle::GetNewInstance(); /** @var $oItem TdbPkgShopWishlistArticle */ if ($oItem->LoadFromFields(array('pkg_shop_wishlist_id' => $this->id, 'shop_article_id' => $sArticleId))) { $aItemData = $oItem->sqlData; $aItemData['amount'] += $dAmount; } else { $aItemData['pkg_shop_wishlist_id'] = $this->id; $aItemData['shop_article_id'] = $sArticleId; $aItemData['amount'] = $dAmount; $aItemData['datecreated'] = date('Y-m-d H:i:s'); } if (!is_null($sComment)) { $aItemData['comment'] = $oItem->LoadFromRow($aItemData); } $oItem->LoadFromRow($aItemData); $oItem->AllowEditByAll(true); $oItem->Save(); $dNewAmount = $aItemData['amount']; return $dNewAmount; }
php
public function AddArticle($sArticleId, $dAmount = 1, $sComment = null) { $dNewAmount = 0; $aItemData = array(); $oItem = TdbPkgShopWishlistArticle::GetNewInstance(); /** @var $oItem TdbPkgShopWishlistArticle */ if ($oItem->LoadFromFields(array('pkg_shop_wishlist_id' => $this->id, 'shop_article_id' => $sArticleId))) { $aItemData = $oItem->sqlData; $aItemData['amount'] += $dAmount; } else { $aItemData['pkg_shop_wishlist_id'] = $this->id; $aItemData['shop_article_id'] = $sArticleId; $aItemData['amount'] = $dAmount; $aItemData['datecreated'] = date('Y-m-d H:i:s'); } if (!is_null($sComment)) { $aItemData['comment'] = $oItem->LoadFromRow($aItemData); } $oItem->LoadFromRow($aItemData); $oItem->AllowEditByAll(true); $oItem->Save(); $dNewAmount = $aItemData['amount']; return $dNewAmount; }
[ "public", "function", "AddArticle", "(", "$", "sArticleId", ",", "$", "dAmount", "=", "1", ",", "$", "sComment", "=", "null", ")", "{", "$", "dNewAmount", "=", "0", ";", "$", "aItemData", "=", "array", "(", ")", ";", "$", "oItem", "=", "TdbPkgShopWishlistArticle", "::", "GetNewInstance", "(", ")", ";", "/** @var $oItem TdbPkgShopWishlistArticle */", "if", "(", "$", "oItem", "->", "LoadFromFields", "(", "array", "(", "'pkg_shop_wishlist_id'", "=>", "$", "this", "->", "id", ",", "'shop_article_id'", "=>", "$", "sArticleId", ")", ")", ")", "{", "$", "aItemData", "=", "$", "oItem", "->", "sqlData", ";", "$", "aItemData", "[", "'amount'", "]", "+=", "$", "dAmount", ";", "}", "else", "{", "$", "aItemData", "[", "'pkg_shop_wishlist_id'", "]", "=", "$", "this", "->", "id", ";", "$", "aItemData", "[", "'shop_article_id'", "]", "=", "$", "sArticleId", ";", "$", "aItemData", "[", "'amount'", "]", "=", "$", "dAmount", ";", "$", "aItemData", "[", "'datecreated'", "]", "=", "date", "(", "'Y-m-d H:i:s'", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "sComment", ")", ")", "{", "$", "aItemData", "[", "'comment'", "]", "=", "$", "oItem", "->", "LoadFromRow", "(", "$", "aItemData", ")", ";", "}", "$", "oItem", "->", "LoadFromRow", "(", "$", "aItemData", ")", ";", "$", "oItem", "->", "AllowEditByAll", "(", "true", ")", ";", "$", "oItem", "->", "Save", "(", ")", ";", "$", "dNewAmount", "=", "$", "aItemData", "[", "'amount'", "]", ";", "return", "$", "dNewAmount", ";", "}" ]
adds an article to the wishlist - returns the new amount of that article on the list. @param string $sArticleId @param float $dAmount @param string $sComment - optional comment @return float
[ "adds", "an", "article", "to", "the", "wishlist", "-", "returns", "the", "new", "amount", "of", "that", "article", "on", "the", "list", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopWishlistBundle/objects/db/TPkgShopWishlist.class.php#L27-L51
32,420
chameleon-system/chameleon-shop
src/ShopWishlistBundle/objects/db/TPkgShopWishlist.class.php
TPkgShopWishlist.GetLink
public function GetLink($sMode = '', $aAdditionalParameter = array()) { if (!empty($sMode)) { $aAdditionalParameter[MTPkgShopWishlistCore::URL_MODE_PARAMETER_NAME] = $sMode; } $oShopConfig = TdbShop::GetInstance(); return $oShopConfig->GetLinkToSystemPage('wishlist', $aAdditionalParameter, true); }
php
public function GetLink($sMode = '', $aAdditionalParameter = array()) { if (!empty($sMode)) { $aAdditionalParameter[MTPkgShopWishlistCore::URL_MODE_PARAMETER_NAME] = $sMode; } $oShopConfig = TdbShop::GetInstance(); return $oShopConfig->GetLinkToSystemPage('wishlist', $aAdditionalParameter, true); }
[ "public", "function", "GetLink", "(", "$", "sMode", "=", "''", ",", "$", "aAdditionalParameter", "=", "array", "(", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "sMode", ")", ")", "{", "$", "aAdditionalParameter", "[", "MTPkgShopWishlistCore", "::", "URL_MODE_PARAMETER_NAME", "]", "=", "$", "sMode", ";", "}", "$", "oShopConfig", "=", "TdbShop", "::", "GetInstance", "(", ")", ";", "return", "$", "oShopConfig", "->", "GetLinkToSystemPage", "(", "'wishlist'", ",", "$", "aAdditionalParameter", ",", "true", ")", ";", "}" ]
return link to the private view of the wishlist. @param string $sMode - select a mode of the wishlist (such as SendForm) @param array $aAdditionalParameter @return string
[ "return", "link", "to", "the", "private", "view", "of", "the", "wishlist", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopWishlistBundle/objects/db/TPkgShopWishlist.class.php#L95-L103
32,421
chameleon-system/chameleon-shop
src/ShopWishlistBundle/objects/db/TPkgShopWishlist.class.php
TPkgShopWishlist.GetPublicLink
public function GetPublicLink($aAdditionalParameter = array()) { $oShopConfig = TdbShop::GetInstance(); $aAdditionalParameter[MTPkgShopWishlistPublicCore::URL_PARAMETER_NAME] = array('id' => $this->id); return $oShopConfig->GetLinkToSystemPage('wishlist-public', $aAdditionalParameter, true); }
php
public function GetPublicLink($aAdditionalParameter = array()) { $oShopConfig = TdbShop::GetInstance(); $aAdditionalParameter[MTPkgShopWishlistPublicCore::URL_PARAMETER_NAME] = array('id' => $this->id); return $oShopConfig->GetLinkToSystemPage('wishlist-public', $aAdditionalParameter, true); }
[ "public", "function", "GetPublicLink", "(", "$", "aAdditionalParameter", "=", "array", "(", ")", ")", "{", "$", "oShopConfig", "=", "TdbShop", "::", "GetInstance", "(", ")", ";", "$", "aAdditionalParameter", "[", "MTPkgShopWishlistPublicCore", "::", "URL_PARAMETER_NAME", "]", "=", "array", "(", "'id'", "=>", "$", "this", "->", "id", ")", ";", "return", "$", "oShopConfig", "->", "GetLinkToSystemPage", "(", "'wishlist-public'", ",", "$", "aAdditionalParameter", ",", "true", ")", ";", "}" ]
return the public link to the wishlist. @param array $aAdditionalParameter @return string
[ "return", "the", "public", "link", "to", "the", "wishlist", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopWishlistBundle/objects/db/TPkgShopWishlist.class.php#L112-L118
32,422
chameleon-system/chameleon-shop
src/ShopWishlistBundle/objects/db/TPkgShopWishlist.class.php
TPkgShopWishlist.&
public function &GetFieldPkgShopWishlistArticleList() { $oWishlistItems = $this->GetFromInternalCache('oPkgShopWishlistArticleList'); if (is_null($oWishlistItems)) { $oWishlistItems = TdbPkgShopWishlistArticleList::GetListForPkgShopWishlistId($this->id, $this->iLanguageId); $oWishlistItems->bAllowItemCache = true; $this->SetInternalCache('oPkgShopWishlistArticleList', $oWishlistItems); } $oWishlistItems->GoToStart(); return $oWishlistItems; }
php
public function &GetFieldPkgShopWishlistArticleList() { $oWishlistItems = $this->GetFromInternalCache('oPkgShopWishlistArticleList'); if (is_null($oWishlistItems)) { $oWishlistItems = TdbPkgShopWishlistArticleList::GetListForPkgShopWishlistId($this->id, $this->iLanguageId); $oWishlistItems->bAllowItemCache = true; $this->SetInternalCache('oPkgShopWishlistArticleList', $oWishlistItems); } $oWishlistItems->GoToStart(); return $oWishlistItems; }
[ "public", "function", "&", "GetFieldPkgShopWishlistArticleList", "(", ")", "{", "$", "oWishlistItems", "=", "$", "this", "->", "GetFromInternalCache", "(", "'oPkgShopWishlistArticleList'", ")", ";", "if", "(", "is_null", "(", "$", "oWishlistItems", ")", ")", "{", "$", "oWishlistItems", "=", "TdbPkgShopWishlistArticleList", "::", "GetListForPkgShopWishlistId", "(", "$", "this", "->", "id", ",", "$", "this", "->", "iLanguageId", ")", ";", "$", "oWishlistItems", "->", "bAllowItemCache", "=", "true", ";", "$", "this", "->", "SetInternalCache", "(", "'oPkgShopWishlistArticleList'", ",", "$", "oWishlistItems", ")", ";", "}", "$", "oWishlistItems", "->", "GoToStart", "(", ")", ";", "return", "$", "oWishlistItems", ";", "}" ]
Artikel der Wunschliste. @return TdbPkgShopWishlistArticleList
[ "Artikel", "der", "Wunschliste", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopWishlistBundle/objects/db/TPkgShopWishlist.class.php#L137-L148
32,423
chameleon-system/chameleon-shop
src/ShopWishlistBundle/objects/db/TPkgShopWishlist.class.php
TPkgShopWishlist.&
public function &GetFieldPkgShopWishlistMailHistoryList() { $oWishlistHistoryItems = $this->GetFromInternalCache('oPkgShopWishlistMailHistoryList'); if (is_null($oWishlistHistoryItems)) { $oWishlistHistoryItems = TdbPkgShopWishlistMailHistoryList::GetListForPkgShopWishlistId($this->id, $this->iLanguageId); $oWishlistHistoryItems->bAllowItemCache = true; $this->SetInternalCache('oPkgShopWishlistMailHistoryList', $oWishlistHistoryItems); } return $oWishlistHistoryItems; }
php
public function &GetFieldPkgShopWishlistMailHistoryList() { $oWishlistHistoryItems = $this->GetFromInternalCache('oPkgShopWishlistMailHistoryList'); if (is_null($oWishlistHistoryItems)) { $oWishlistHistoryItems = TdbPkgShopWishlistMailHistoryList::GetListForPkgShopWishlistId($this->id, $this->iLanguageId); $oWishlistHistoryItems->bAllowItemCache = true; $this->SetInternalCache('oPkgShopWishlistMailHistoryList', $oWishlistHistoryItems); } return $oWishlistHistoryItems; }
[ "public", "function", "&", "GetFieldPkgShopWishlistMailHistoryList", "(", ")", "{", "$", "oWishlistHistoryItems", "=", "$", "this", "->", "GetFromInternalCache", "(", "'oPkgShopWishlistMailHistoryList'", ")", ";", "if", "(", "is_null", "(", "$", "oWishlistHistoryItems", ")", ")", "{", "$", "oWishlistHistoryItems", "=", "TdbPkgShopWishlistMailHistoryList", "::", "GetListForPkgShopWishlistId", "(", "$", "this", "->", "id", ",", "$", "this", "->", "iLanguageId", ")", ";", "$", "oWishlistHistoryItems", "->", "bAllowItemCache", "=", "true", ";", "$", "this", "->", "SetInternalCache", "(", "'oPkgShopWishlistMailHistoryList'", ",", "$", "oWishlistHistoryItems", ")", ";", "}", "return", "$", "oWishlistHistoryItems", ";", "}" ]
Wunschslisten Mailhistory. @return TdbPkgShopWishlistMailHistoryList
[ "Wunschslisten", "Mailhistory", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopWishlistBundle/objects/db/TPkgShopWishlist.class.php#L155-L165
32,424
chameleon-system/chameleon-shop
src/ShopWishlistBundle/objects/db/TPkgShopWishlist.class.php
TPkgShopWishlist.GetDescriptionAsHTML
public function GetDescriptionAsHTML() { $sText = trim($this->fieldDescription); $sText = TGlobal::OutHTML($sText); $sText = nl2br($sText); return $sText; }
php
public function GetDescriptionAsHTML() { $sText = trim($this->fieldDescription); $sText = TGlobal::OutHTML($sText); $sText = nl2br($sText); return $sText; }
[ "public", "function", "GetDescriptionAsHTML", "(", ")", "{", "$", "sText", "=", "trim", "(", "$", "this", "->", "fieldDescription", ")", ";", "$", "sText", "=", "TGlobal", "::", "OutHTML", "(", "$", "sText", ")", ";", "$", "sText", "=", "nl2br", "(", "$", "sText", ")", ";", "return", "$", "sText", ";", "}" ]
return description text as html. @return string
[ "return", "description", "text", "as", "html", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopWishlistBundle/objects/db/TPkgShopWishlist.class.php#L186-L193
32,425
chameleon-system/chameleon-shop
src/ShopWishlistBundle/objects/db/TPkgShopWishlist.class.php
TPkgShopWishlist.SendPerMail
public function SendPerMail($sToMail, $sToName, $sComment) { $bSendSuccess = false; $oOwner = $this->GetFieldDataExtranetUser(); $oMail = TdbDataMailProfile::GetProfile('SendWishlist'); $aMailData = array('to_name' => $sToName, 'to_mail' => $sToMail, 'comment' => $sComment, 'sWishlistURL' => $this->GetPublicLink()); $oMail->AddDataArray($aMailData); $aUserData = $oOwner->GetObjectPropertiesAsArray(); $oMail->AddDataArray($aUserData); $oMail->ChangeFromAddress($oOwner->GetUserEMail(), $oOwner->fieldFirstname.' '.$oOwner->fieldLastname); $oMail->ChangeToAddress($sToMail, $sToName); if ($oMail->SendUsingObjectView('emails', 'Customer')) { $bSendSuccess = true; $oHistory = TdbPkgShopWishlistMailHistory::GetNewInstance(); /** @var $oHistory TdbPkgShopWishlistMailHistory */ $aData = array('to_name' => $sToName, 'to_email' => $sToMail, 'comment' => $sComment, 'datesend' => date('Y-m-d H:i:s'), 'pkg_shop_wishlist_id' => $this->id); $oHistory->LoadFromRow($aData); $oHistory->AllowEditByAll(true); $oHistory->Save(); } return $bSendSuccess; }
php
public function SendPerMail($sToMail, $sToName, $sComment) { $bSendSuccess = false; $oOwner = $this->GetFieldDataExtranetUser(); $oMail = TdbDataMailProfile::GetProfile('SendWishlist'); $aMailData = array('to_name' => $sToName, 'to_mail' => $sToMail, 'comment' => $sComment, 'sWishlistURL' => $this->GetPublicLink()); $oMail->AddDataArray($aMailData); $aUserData = $oOwner->GetObjectPropertiesAsArray(); $oMail->AddDataArray($aUserData); $oMail->ChangeFromAddress($oOwner->GetUserEMail(), $oOwner->fieldFirstname.' '.$oOwner->fieldLastname); $oMail->ChangeToAddress($sToMail, $sToName); if ($oMail->SendUsingObjectView('emails', 'Customer')) { $bSendSuccess = true; $oHistory = TdbPkgShopWishlistMailHistory::GetNewInstance(); /** @var $oHistory TdbPkgShopWishlistMailHistory */ $aData = array('to_name' => $sToName, 'to_email' => $sToMail, 'comment' => $sComment, 'datesend' => date('Y-m-d H:i:s'), 'pkg_shop_wishlist_id' => $this->id); $oHistory->LoadFromRow($aData); $oHistory->AllowEditByAll(true); $oHistory->Save(); } return $bSendSuccess; }
[ "public", "function", "SendPerMail", "(", "$", "sToMail", ",", "$", "sToName", ",", "$", "sComment", ")", "{", "$", "bSendSuccess", "=", "false", ";", "$", "oOwner", "=", "$", "this", "->", "GetFieldDataExtranetUser", "(", ")", ";", "$", "oMail", "=", "TdbDataMailProfile", "::", "GetProfile", "(", "'SendWishlist'", ")", ";", "$", "aMailData", "=", "array", "(", "'to_name'", "=>", "$", "sToName", ",", "'to_mail'", "=>", "$", "sToMail", ",", "'comment'", "=>", "$", "sComment", ",", "'sWishlistURL'", "=>", "$", "this", "->", "GetPublicLink", "(", ")", ")", ";", "$", "oMail", "->", "AddDataArray", "(", "$", "aMailData", ")", ";", "$", "aUserData", "=", "$", "oOwner", "->", "GetObjectPropertiesAsArray", "(", ")", ";", "$", "oMail", "->", "AddDataArray", "(", "$", "aUserData", ")", ";", "$", "oMail", "->", "ChangeFromAddress", "(", "$", "oOwner", "->", "GetUserEMail", "(", ")", ",", "$", "oOwner", "->", "fieldFirstname", ".", "' '", ".", "$", "oOwner", "->", "fieldLastname", ")", ";", "$", "oMail", "->", "ChangeToAddress", "(", "$", "sToMail", ",", "$", "sToName", ")", ";", "if", "(", "$", "oMail", "->", "SendUsingObjectView", "(", "'emails'", ",", "'Customer'", ")", ")", "{", "$", "bSendSuccess", "=", "true", ";", "$", "oHistory", "=", "TdbPkgShopWishlistMailHistory", "::", "GetNewInstance", "(", ")", ";", "/** @var $oHistory TdbPkgShopWishlistMailHistory */", "$", "aData", "=", "array", "(", "'to_name'", "=>", "$", "sToName", ",", "'to_email'", "=>", "$", "sToMail", ",", "'comment'", "=>", "$", "sComment", ",", "'datesend'", "=>", "date", "(", "'Y-m-d H:i:s'", ")", ",", "'pkg_shop_wishlist_id'", "=>", "$", "this", "->", "id", ")", ";", "$", "oHistory", "->", "LoadFromRow", "(", "$", "aData", ")", ";", "$", "oHistory", "->", "AllowEditByAll", "(", "true", ")", ";", "$", "oHistory", "->", "Save", "(", ")", ";", "}", "return", "$", "bSendSuccess", ";", "}" ]
send the wishlist per mail to a user. @param string $sToMail @param string $sToName @param string $sComment @return bool
[ "send", "the", "wishlist", "per", "mail", "to", "a", "user", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopWishlistBundle/objects/db/TPkgShopWishlist.class.php#L204-L226
32,426
Erebot/Erebot
src/Event/Match/Source.php
Source.setSource
public function setSource($source) { if ($source !== null && !\Erebot\Utils::stringifiable($source)) { throw new \Erebot\InvalidValueException('Not a valid nickname'); } $this->source = $source; }
php
public function setSource($source) { if ($source !== null && !\Erebot\Utils::stringifiable($source)) { throw new \Erebot\InvalidValueException('Not a valid nickname'); } $this->source = $source; }
[ "public", "function", "setSource", "(", "$", "source", ")", "{", "if", "(", "$", "source", "!==", "null", "&&", "!", "\\", "Erebot", "\\", "Utils", "::", "stringifiable", "(", "$", "source", ")", ")", "{", "throw", "new", "\\", "Erebot", "\\", "InvalidValueException", "(", "'Not a valid nickname'", ")", ";", "}", "$", "this", "->", "source", "=", "$", "source", ";", "}" ]
Sets the source used in comparisons. \param $source string|object Source to match incoming events against. \throw Erebot::InvalidValueException The given source is invalid.
[ "Sets", "the", "source", "used", "in", "comparisons", "." ]
691fc3fa8bc6f07061ff2b3798fec76bc3a039aa
https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/Event/Match/Source.php#L70-L77
32,427
chameleon-system/chameleon-shop
src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerDataTrans.class.php
TShopPaymentHandlerDataTrans.GetAdditionalViewVariables
protected function GetAdditionalViewVariables($sViewName, $sViewType) { $aViewVariables = parent::GetAdditionalViewVariables($sViewName, $sViewType); if (!is_array($aViewVariables)) { $aViewVariables = array(); } $aViewVariables['PaymentHiddenInput'] = $this->GetPaymentParameter(); $aViewVariables['PaymentHiddenInput']['sign'] = $this->GetSecurityHash($this->GetTestLiveModeParameter('sign'), $aViewVariables['PaymentHiddenInput']['merchantId'], $aViewVariables['PaymentHiddenInput']['amount'], $aViewVariables['PaymentHiddenInput']['currency'], $aViewVariables['PaymentHiddenInput']['refno']); $aViewVariables['aUserAddressData'] = $this->GetUserAddressDataParameter(); $aViewVariables['aPossiblePaymentMethodCreditCardList'] = $this->GetPaymentTypeSpecificParameter(); return $aViewVariables; }
php
protected function GetAdditionalViewVariables($sViewName, $sViewType) { $aViewVariables = parent::GetAdditionalViewVariables($sViewName, $sViewType); if (!is_array($aViewVariables)) { $aViewVariables = array(); } $aViewVariables['PaymentHiddenInput'] = $this->GetPaymentParameter(); $aViewVariables['PaymentHiddenInput']['sign'] = $this->GetSecurityHash($this->GetTestLiveModeParameter('sign'), $aViewVariables['PaymentHiddenInput']['merchantId'], $aViewVariables['PaymentHiddenInput']['amount'], $aViewVariables['PaymentHiddenInput']['currency'], $aViewVariables['PaymentHiddenInput']['refno']); $aViewVariables['aUserAddressData'] = $this->GetUserAddressDataParameter(); $aViewVariables['aPossiblePaymentMethodCreditCardList'] = $this->GetPaymentTypeSpecificParameter(); return $aViewVariables; }
[ "protected", "function", "GetAdditionalViewVariables", "(", "$", "sViewName", ",", "$", "sViewType", ")", "{", "$", "aViewVariables", "=", "parent", "::", "GetAdditionalViewVariables", "(", "$", "sViewName", ",", "$", "sViewType", ")", ";", "if", "(", "!", "is_array", "(", "$", "aViewVariables", ")", ")", "{", "$", "aViewVariables", "=", "array", "(", ")", ";", "}", "$", "aViewVariables", "[", "'PaymentHiddenInput'", "]", "=", "$", "this", "->", "GetPaymentParameter", "(", ")", ";", "$", "aViewVariables", "[", "'PaymentHiddenInput'", "]", "[", "'sign'", "]", "=", "$", "this", "->", "GetSecurityHash", "(", "$", "this", "->", "GetTestLiveModeParameter", "(", "'sign'", ")", ",", "$", "aViewVariables", "[", "'PaymentHiddenInput'", "]", "[", "'merchantId'", "]", ",", "$", "aViewVariables", "[", "'PaymentHiddenInput'", "]", "[", "'amount'", "]", ",", "$", "aViewVariables", "[", "'PaymentHiddenInput'", "]", "[", "'currency'", "]", ",", "$", "aViewVariables", "[", "'PaymentHiddenInput'", "]", "[", "'refno'", "]", ")", ";", "$", "aViewVariables", "[", "'aUserAddressData'", "]", "=", "$", "this", "->", "GetUserAddressDataParameter", "(", ")", ";", "$", "aViewVariables", "[", "'aPossiblePaymentMethodCreditCardList'", "]", "=", "$", "this", "->", "GetPaymentTypeSpecificParameter", "(", ")", ";", "return", "$", "aViewVariables", ";", "}" ]
added all needed parameter for a request to IPayment use this method to add any variables to the render method that you may require for some view. @param string $sViewName - the view being requested @param string $sViewType - the location of the view (Core, Custom-Core, Customer) @return array
[ "added", "all", "needed", "parameter", "for", "a", "request", "to", "IPayment", "use", "this", "method", "to", "add", "any", "variables", "to", "the", "render", "method", "that", "you", "may", "require", "for", "some", "view", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerDataTrans.class.php#L71-L83
32,428
chameleon-system/chameleon-shop
src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerDataTrans.class.php
TShopPaymentHandlerDataTrans.GetPaymentParameter
protected function GetPaymentParameter() { $aParameter = array(); $sCurrency = $this->GetCurrencyIdentifier(); $oLocal = &TCMSLocal::GetActive(); $oShopBasket = TShopBasket::GetInstance(); $aParameter['merchantId'] = $this->GetTestLiveModeParameter('merchantId'); $aParameter['refno'] = $this->GetRefNoParameter(); $aParameter['reqtype'] = $this->GetConfigParameter('reqtype'); $aParameter['amount'] = str_replace(',', '.', $oLocal->FormatNumber($oShopBasket->dCostTotal)) * 100; $aParameter['currency'] = $sCurrency; $aParameter['hiddenMode'] = $this->GetConfigParameter('hiddenMode'); $sRedirectULR = $this->GetResponseURL(); $aParameter['successUrl'] = $sRedirectULR; $aParameter['errorUrl'] = $sRedirectULR; $aParameter['cancelUrl'] = $sRedirectULR; return $aParameter; }
php
protected function GetPaymentParameter() { $aParameter = array(); $sCurrency = $this->GetCurrencyIdentifier(); $oLocal = &TCMSLocal::GetActive(); $oShopBasket = TShopBasket::GetInstance(); $aParameter['merchantId'] = $this->GetTestLiveModeParameter('merchantId'); $aParameter['refno'] = $this->GetRefNoParameter(); $aParameter['reqtype'] = $this->GetConfigParameter('reqtype'); $aParameter['amount'] = str_replace(',', '.', $oLocal->FormatNumber($oShopBasket->dCostTotal)) * 100; $aParameter['currency'] = $sCurrency; $aParameter['hiddenMode'] = $this->GetConfigParameter('hiddenMode'); $sRedirectULR = $this->GetResponseURL(); $aParameter['successUrl'] = $sRedirectULR; $aParameter['errorUrl'] = $sRedirectULR; $aParameter['cancelUrl'] = $sRedirectULR; return $aParameter; }
[ "protected", "function", "GetPaymentParameter", "(", ")", "{", "$", "aParameter", "=", "array", "(", ")", ";", "$", "sCurrency", "=", "$", "this", "->", "GetCurrencyIdentifier", "(", ")", ";", "$", "oLocal", "=", "&", "TCMSLocal", "::", "GetActive", "(", ")", ";", "$", "oShopBasket", "=", "TShopBasket", "::", "GetInstance", "(", ")", ";", "$", "aParameter", "[", "'merchantId'", "]", "=", "$", "this", "->", "GetTestLiveModeParameter", "(", "'merchantId'", ")", ";", "$", "aParameter", "[", "'refno'", "]", "=", "$", "this", "->", "GetRefNoParameter", "(", ")", ";", "$", "aParameter", "[", "'reqtype'", "]", "=", "$", "this", "->", "GetConfigParameter", "(", "'reqtype'", ")", ";", "$", "aParameter", "[", "'amount'", "]", "=", "str_replace", "(", "','", ",", "'.'", ",", "$", "oLocal", "->", "FormatNumber", "(", "$", "oShopBasket", "->", "dCostTotal", ")", ")", "*", "100", ";", "$", "aParameter", "[", "'currency'", "]", "=", "$", "sCurrency", ";", "$", "aParameter", "[", "'hiddenMode'", "]", "=", "$", "this", "->", "GetConfigParameter", "(", "'hiddenMode'", ")", ";", "$", "sRedirectULR", "=", "$", "this", "->", "GetResponseURL", "(", ")", ";", "$", "aParameter", "[", "'successUrl'", "]", "=", "$", "sRedirectULR", ";", "$", "aParameter", "[", "'errorUrl'", "]", "=", "$", "sRedirectULR", ";", "$", "aParameter", "[", "'cancelUrl'", "]", "=", "$", "sRedirectULR", ";", "return", "$", "aParameter", ";", "}" ]
Get hidden field parameter needed for payment. @return array
[ "Get", "hidden", "field", "parameter", "needed", "for", "payment", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerDataTrans.class.php#L191-L209
32,429
chameleon-system/chameleon-shop
src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerDataTrans.class.php
TShopPaymentHandlerDataTrans.CheckAuthorisationResponse
protected function CheckAuthorisationResponse($sMessageConsumer = '') { $bResponseSuccessful = false; if (empty($sMessageConsumer)) { $sMessageConsumer = $this->GetMsgManagerName(); } $sReturnMessage = $this->GetErrorCodesFromResponse(); if (!empty($sReturnMessage)) { $oMsgManager = TCMSMessageManager::GetInstance(); $oMsgManager->AddMessage($sMessageConsumer, $sReturnMessage); } else { $bResponseSuccessful = true; } return $bResponseSuccessful; }
php
protected function CheckAuthorisationResponse($sMessageConsumer = '') { $bResponseSuccessful = false; if (empty($sMessageConsumer)) { $sMessageConsumer = $this->GetMsgManagerName(); } $sReturnMessage = $this->GetErrorCodesFromResponse(); if (!empty($sReturnMessage)) { $oMsgManager = TCMSMessageManager::GetInstance(); $oMsgManager->AddMessage($sMessageConsumer, $sReturnMessage); } else { $bResponseSuccessful = true; } return $bResponseSuccessful; }
[ "protected", "function", "CheckAuthorisationResponse", "(", "$", "sMessageConsumer", "=", "''", ")", "{", "$", "bResponseSuccessful", "=", "false", ";", "if", "(", "empty", "(", "$", "sMessageConsumer", ")", ")", "{", "$", "sMessageConsumer", "=", "$", "this", "->", "GetMsgManagerName", "(", ")", ";", "}", "$", "sReturnMessage", "=", "$", "this", "->", "GetErrorCodesFromResponse", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "sReturnMessage", ")", ")", "{", "$", "oMsgManager", "=", "TCMSMessageManager", "::", "GetInstance", "(", ")", ";", "$", "oMsgManager", "->", "AddMessage", "(", "$", "sMessageConsumer", ",", "$", "sReturnMessage", ")", ";", "}", "else", "{", "$", "bResponseSuccessful", "=", "true", ";", "}", "return", "$", "bResponseSuccessful", ";", "}" ]
if request to DataTrans was not successfully create a error message. @param string $sMessageConsumer @return bool
[ "if", "request", "to", "DataTrans", "was", "not", "successfully", "create", "a", "error", "message", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerDataTrans.class.php#L239-L254
32,430
chameleon-system/chameleon-shop
src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerDataTrans.class.php
TShopPaymentHandlerDataTrans.ExecuteDataTransPaymentCall
protected function ExecuteDataTransPaymentCall(TdbShopOrder &$oOrder) { $sXMLSettlement = $this->GetXMLSettlement(); $ch = curl_init(); $settlementurl = trim($this->GetTestLiveModeParameter('settlementurl')); curl_setopt($ch, CURLOPT_URL, $settlementurl); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, 'xmlRequest='.$sXMLSettlement); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $sResponse = curl_exec($ch); $sCurlError = curl_error($ch); $bPaymentOk = $this->SettlementResponseSuccess($sResponse); if (!$bPaymentOk) { if (!empty($sCurlError)) { TTools::WriteLogEntrySimple('Payment DataTrans: curl failed to ['.$this->GetConfigParameter('settlementurl')."] using xml [{$sXMLSettlement}] with error: ".$sCurlError, 1, __FILE__, __LINE__); } $iFailure = $this->GetConfigParameter('failure_settlement'); if ('1' === $iFailure) { if ($this->SendFailureSettlementMail($oOrder)) { $bPaymentOk = true; } else { TTools::WriteLogEntrySimple('Payment DataTrans: Es konnte keine Abbuchungsfehlere-mail versand werden', 1, __FILE__, __LINE__); } } } curl_close($ch); return $bPaymentOk; }
php
protected function ExecuteDataTransPaymentCall(TdbShopOrder &$oOrder) { $sXMLSettlement = $this->GetXMLSettlement(); $ch = curl_init(); $settlementurl = trim($this->GetTestLiveModeParameter('settlementurl')); curl_setopt($ch, CURLOPT_URL, $settlementurl); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, 'xmlRequest='.$sXMLSettlement); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $sResponse = curl_exec($ch); $sCurlError = curl_error($ch); $bPaymentOk = $this->SettlementResponseSuccess($sResponse); if (!$bPaymentOk) { if (!empty($sCurlError)) { TTools::WriteLogEntrySimple('Payment DataTrans: curl failed to ['.$this->GetConfigParameter('settlementurl')."] using xml [{$sXMLSettlement}] with error: ".$sCurlError, 1, __FILE__, __LINE__); } $iFailure = $this->GetConfigParameter('failure_settlement'); if ('1' === $iFailure) { if ($this->SendFailureSettlementMail($oOrder)) { $bPaymentOk = true; } else { TTools::WriteLogEntrySimple('Payment DataTrans: Es konnte keine Abbuchungsfehlere-mail versand werden', 1, __FILE__, __LINE__); } } } curl_close($ch); return $bPaymentOk; }
[ "protected", "function", "ExecuteDataTransPaymentCall", "(", "TdbShopOrder", "&", "$", "oOrder", ")", "{", "$", "sXMLSettlement", "=", "$", "this", "->", "GetXMLSettlement", "(", ")", ";", "$", "ch", "=", "curl_init", "(", ")", ";", "$", "settlementurl", "=", "trim", "(", "$", "this", "->", "GetTestLiveModeParameter", "(", "'settlementurl'", ")", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_URL", ",", "$", "settlementurl", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_VERBOSE", ",", "1", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_SSL_VERIFYPEER", ",", "true", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_SSL_VERIFYHOST", ",", "2", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_RETURNTRANSFER", ",", "1", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POST", ",", "1", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POSTFIELDS", ",", "'xmlRequest='", ".", "$", "sXMLSettlement", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_FOLLOWLOCATION", ",", "1", ")", ";", "$", "sResponse", "=", "curl_exec", "(", "$", "ch", ")", ";", "$", "sCurlError", "=", "curl_error", "(", "$", "ch", ")", ";", "$", "bPaymentOk", "=", "$", "this", "->", "SettlementResponseSuccess", "(", "$", "sResponse", ")", ";", "if", "(", "!", "$", "bPaymentOk", ")", "{", "if", "(", "!", "empty", "(", "$", "sCurlError", ")", ")", "{", "TTools", "::", "WriteLogEntrySimple", "(", "'Payment DataTrans: curl failed to ['", ".", "$", "this", "->", "GetConfigParameter", "(", "'settlementurl'", ")", ".", "\"] using xml [{$sXMLSettlement}] with error: \"", ".", "$", "sCurlError", ",", "1", ",", "__FILE__", ",", "__LINE__", ")", ";", "}", "$", "iFailure", "=", "$", "this", "->", "GetConfigParameter", "(", "'failure_settlement'", ")", ";", "if", "(", "'1'", "===", "$", "iFailure", ")", "{", "if", "(", "$", "this", "->", "SendFailureSettlementMail", "(", "$", "oOrder", ")", ")", "{", "$", "bPaymentOk", "=", "true", ";", "}", "else", "{", "TTools", "::", "WriteLogEntrySimple", "(", "'Payment DataTrans: Es konnte keine Abbuchungsfehlere-mail versand werden'", ",", "1", ",", "__FILE__", ",", "__LINE__", ")", ";", "}", "}", "}", "curl_close", "(", "$", "ch", ")", ";", "return", "$", "bPaymentOk", ";", "}" ]
Send settlement for authorised transaction. @param \TdbShopOrder $oOrder @return bool
[ "Send", "settlement", "for", "authorised", "transaction", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerDataTrans.class.php#L478-L510
32,431
chameleon-system/chameleon-shop
src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerDataTrans.class.php
TShopPaymentHandlerDataTrans.SendFailureSettlementMail
protected function SendFailureSettlementMail(TdbShopOrder &$oOrder) { $bSendMail = false; $oMail = TdbDataMailProfile::GetProfile('payment_datatrans_error_settlement'); if (!is_null($oMail)) { $sInfo = TGlobal::OutHTML(TGlobal::Translate('chameleon_system_shop.payment_data_trans.settlement_failure_mail_info', array( '%ordernumber%' => $oOrder->fieldOrdernumber, '%ref%' => $this->GetRefNoParameter(false), ) )); $oMail->AddData('sInfo', $sInfo); $bSendMail = $oMail->SendUsingObjectView('emails', 'Customer'); } return $bSendMail; }
php
protected function SendFailureSettlementMail(TdbShopOrder &$oOrder) { $bSendMail = false; $oMail = TdbDataMailProfile::GetProfile('payment_datatrans_error_settlement'); if (!is_null($oMail)) { $sInfo = TGlobal::OutHTML(TGlobal::Translate('chameleon_system_shop.payment_data_trans.settlement_failure_mail_info', array( '%ordernumber%' => $oOrder->fieldOrdernumber, '%ref%' => $this->GetRefNoParameter(false), ) )); $oMail->AddData('sInfo', $sInfo); $bSendMail = $oMail->SendUsingObjectView('emails', 'Customer'); } return $bSendMail; }
[ "protected", "function", "SendFailureSettlementMail", "(", "TdbShopOrder", "&", "$", "oOrder", ")", "{", "$", "bSendMail", "=", "false", ";", "$", "oMail", "=", "TdbDataMailProfile", "::", "GetProfile", "(", "'payment_datatrans_error_settlement'", ")", ";", "if", "(", "!", "is_null", "(", "$", "oMail", ")", ")", "{", "$", "sInfo", "=", "TGlobal", "::", "OutHTML", "(", "TGlobal", "::", "Translate", "(", "'chameleon_system_shop.payment_data_trans.settlement_failure_mail_info'", ",", "array", "(", "'%ordernumber%'", "=>", "$", "oOrder", "->", "fieldOrdernumber", ",", "'%ref%'", "=>", "$", "this", "->", "GetRefNoParameter", "(", "false", ")", ",", ")", ")", ")", ";", "$", "oMail", "->", "AddData", "(", "'sInfo'", ",", "$", "sInfo", ")", ";", "$", "bSendMail", "=", "$", "oMail", "->", "SendUsingObjectView", "(", "'emails'", ",", "'Customer'", ")", ";", "}", "return", "$", "bSendMail", ";", "}" ]
Sends email to shop owner to settle transaction manually. @param TdbShopOrder $oOrder @return bool
[ "Sends", "email", "to", "shop", "owner", "to", "settle", "transaction", "manually", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerDataTrans.class.php#L519-L535
32,432
chameleon-system/chameleon-shop
src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerDataTrans.class.php
TShopPaymentHandlerDataTrans.SettlementResponseSuccess
protected function SettlementResponseSuccess($sResponse) { $bSettlementResponseSuccess = true; $sRefNo = $this->GetRefNoParameter(false); $oXML = simplexml_load_string($sResponse); if (isset($oXML->body->transaction->response)) { TTools::WriteLogEntrySimple('Payment DataTrans: Erfoglreiche XML Settlement Response for transaction'.$this->sTransactionId.'and reference number '.$sRefNo, 3, __FILE__, __LINE__); } else { if (isset($oXML->body->transaction->error)) { $sErrorCode = ''; $sErrorMessage = ''; if (isset($oXML->body->transaction->error->errorCode)) { $sErrorCode = strval($oXML->body->transaction->error->errorCode); } if (isset($oXML->body->transaction->error->errorDetail)) { $sErrorMessage = strval($oXML->body->transaction->error->errorDetail); } if (isset($oXML->body->transaction->error->errorMessage)) { $sErrorMessage .= strval($oXML->body->transaction->error->errorMessage); } TTools::WriteLogEntrySimple('Payment DataTrans: Fehlerhafte XML Settlement Response for transaction'.$this->sTransactionId.'and reference number '.$sRefNo.'. CODE('.$sErrorCode.') MESSAGE('.$sErrorMessage.')'.' response: '.$sResponse, 1, __FILE__, __LINE__); } else { TTools::WriteLogEntrySimple('Payment DataTrans: Fehlerhafte XML Settlement Response for transaction'.$this->sTransactionId.'and reference number '.$sRefNo.' response: '.$sResponse, 1, __FILE__, __LINE__); } $bSettlementResponseSuccess = false; } return $bSettlementResponseSuccess; }
php
protected function SettlementResponseSuccess($sResponse) { $bSettlementResponseSuccess = true; $sRefNo = $this->GetRefNoParameter(false); $oXML = simplexml_load_string($sResponse); if (isset($oXML->body->transaction->response)) { TTools::WriteLogEntrySimple('Payment DataTrans: Erfoglreiche XML Settlement Response for transaction'.$this->sTransactionId.'and reference number '.$sRefNo, 3, __FILE__, __LINE__); } else { if (isset($oXML->body->transaction->error)) { $sErrorCode = ''; $sErrorMessage = ''; if (isset($oXML->body->transaction->error->errorCode)) { $sErrorCode = strval($oXML->body->transaction->error->errorCode); } if (isset($oXML->body->transaction->error->errorDetail)) { $sErrorMessage = strval($oXML->body->transaction->error->errorDetail); } if (isset($oXML->body->transaction->error->errorMessage)) { $sErrorMessage .= strval($oXML->body->transaction->error->errorMessage); } TTools::WriteLogEntrySimple('Payment DataTrans: Fehlerhafte XML Settlement Response for transaction'.$this->sTransactionId.'and reference number '.$sRefNo.'. CODE('.$sErrorCode.') MESSAGE('.$sErrorMessage.')'.' response: '.$sResponse, 1, __FILE__, __LINE__); } else { TTools::WriteLogEntrySimple('Payment DataTrans: Fehlerhafte XML Settlement Response for transaction'.$this->sTransactionId.'and reference number '.$sRefNo.' response: '.$sResponse, 1, __FILE__, __LINE__); } $bSettlementResponseSuccess = false; } return $bSettlementResponseSuccess; }
[ "protected", "function", "SettlementResponseSuccess", "(", "$", "sResponse", ")", "{", "$", "bSettlementResponseSuccess", "=", "true", ";", "$", "sRefNo", "=", "$", "this", "->", "GetRefNoParameter", "(", "false", ")", ";", "$", "oXML", "=", "simplexml_load_string", "(", "$", "sResponse", ")", ";", "if", "(", "isset", "(", "$", "oXML", "->", "body", "->", "transaction", "->", "response", ")", ")", "{", "TTools", "::", "WriteLogEntrySimple", "(", "'Payment DataTrans: Erfoglreiche XML Settlement Response for transaction'", ".", "$", "this", "->", "sTransactionId", ".", "'and reference number '", ".", "$", "sRefNo", ",", "3", ",", "__FILE__", ",", "__LINE__", ")", ";", "}", "else", "{", "if", "(", "isset", "(", "$", "oXML", "->", "body", "->", "transaction", "->", "error", ")", ")", "{", "$", "sErrorCode", "=", "''", ";", "$", "sErrorMessage", "=", "''", ";", "if", "(", "isset", "(", "$", "oXML", "->", "body", "->", "transaction", "->", "error", "->", "errorCode", ")", ")", "{", "$", "sErrorCode", "=", "strval", "(", "$", "oXML", "->", "body", "->", "transaction", "->", "error", "->", "errorCode", ")", ";", "}", "if", "(", "isset", "(", "$", "oXML", "->", "body", "->", "transaction", "->", "error", "->", "errorDetail", ")", ")", "{", "$", "sErrorMessage", "=", "strval", "(", "$", "oXML", "->", "body", "->", "transaction", "->", "error", "->", "errorDetail", ")", ";", "}", "if", "(", "isset", "(", "$", "oXML", "->", "body", "->", "transaction", "->", "error", "->", "errorMessage", ")", ")", "{", "$", "sErrorMessage", ".=", "strval", "(", "$", "oXML", "->", "body", "->", "transaction", "->", "error", "->", "errorMessage", ")", ";", "}", "TTools", "::", "WriteLogEntrySimple", "(", "'Payment DataTrans: Fehlerhafte XML Settlement Response for transaction'", ".", "$", "this", "->", "sTransactionId", ".", "'and reference number '", ".", "$", "sRefNo", ".", "'. CODE('", ".", "$", "sErrorCode", ".", "') MESSAGE('", ".", "$", "sErrorMessage", ".", "')'", ".", "' response: '", ".", "$", "sResponse", ",", "1", ",", "__FILE__", ",", "__LINE__", ")", ";", "}", "else", "{", "TTools", "::", "WriteLogEntrySimple", "(", "'Payment DataTrans: Fehlerhafte XML Settlement Response for transaction'", ".", "$", "this", "->", "sTransactionId", ".", "'and reference number '", ".", "$", "sRefNo", ".", "' response: '", ".", "$", "sResponse", ",", "1", ",", "__FILE__", ",", "__LINE__", ")", ";", "}", "$", "bSettlementResponseSuccess", "=", "false", ";", "}", "return", "$", "bSettlementResponseSuccess", ";", "}" ]
Checks the response from settlement request. No sign check on settlement response because DataTrans do not send sign in settlement response. @param $sResponse @return bool
[ "Checks", "the", "response", "from", "settlement", "request", ".", "No", "sign", "check", "on", "settlement", "response", "because", "DataTrans", "do", "not", "send", "sign", "in", "settlement", "response", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerDataTrans.class.php#L545-L573
32,433
chameleon-system/chameleon-shop
src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerDataTrans.class.php
TShopPaymentHandlerDataTrans.GetXMLSettlement
protected function GetXMLSettlement() { $oShopBasket = TShopBasket::GetInstance(); $sMerchantId = $this->GetTestLiveModeParameter('merchantId'); $sRefNo = $this->GetRefNoParameter(false); $sCurrency = $this->GetCurrencyIdentifier(); $oLocal = &TCMSLocal::GetActive(); $sAmount = str_replace(',', '.', $oLocal->FormatNumber($oShopBasket->dCostTotal)) * 100; $sXML = '<?xml version="1.0" encoding="UTF-8" ?> <paymentService version="1"> <body merchantId="'.$this->GetTestLiveModeParameter('merchantId').'"> <transaction refno="'.$sRefNo.'"> <request> <amount>'.$sAmount.'</amount> <currency>'.$sCurrency.'</currency> <uppTransactionId>'.$this->sTransactionId.'</uppTransactionId> <transtype>'.self::PAYMENT_CREDIT_CARD_TRANS_TYPE_ID.'</transtype> <sign>'.$this->GetSecurityHash($this->GetTestLiveModeParameter('sign'), $sMerchantId, $sAmount, $sCurrency, $sRefNo).'</sign> </request> </transaction> </body> </paymentService>'; return $sXML; }
php
protected function GetXMLSettlement() { $oShopBasket = TShopBasket::GetInstance(); $sMerchantId = $this->GetTestLiveModeParameter('merchantId'); $sRefNo = $this->GetRefNoParameter(false); $sCurrency = $this->GetCurrencyIdentifier(); $oLocal = &TCMSLocal::GetActive(); $sAmount = str_replace(',', '.', $oLocal->FormatNumber($oShopBasket->dCostTotal)) * 100; $sXML = '<?xml version="1.0" encoding="UTF-8" ?> <paymentService version="1"> <body merchantId="'.$this->GetTestLiveModeParameter('merchantId').'"> <transaction refno="'.$sRefNo.'"> <request> <amount>'.$sAmount.'</amount> <currency>'.$sCurrency.'</currency> <uppTransactionId>'.$this->sTransactionId.'</uppTransactionId> <transtype>'.self::PAYMENT_CREDIT_CARD_TRANS_TYPE_ID.'</transtype> <sign>'.$this->GetSecurityHash($this->GetTestLiveModeParameter('sign'), $sMerchantId, $sAmount, $sCurrency, $sRefNo).'</sign> </request> </transaction> </body> </paymentService>'; return $sXML; }
[ "protected", "function", "GetXMLSettlement", "(", ")", "{", "$", "oShopBasket", "=", "TShopBasket", "::", "GetInstance", "(", ")", ";", "$", "sMerchantId", "=", "$", "this", "->", "GetTestLiveModeParameter", "(", "'merchantId'", ")", ";", "$", "sRefNo", "=", "$", "this", "->", "GetRefNoParameter", "(", "false", ")", ";", "$", "sCurrency", "=", "$", "this", "->", "GetCurrencyIdentifier", "(", ")", ";", "$", "oLocal", "=", "&", "TCMSLocal", "::", "GetActive", "(", ")", ";", "$", "sAmount", "=", "str_replace", "(", "','", ",", "'.'", ",", "$", "oLocal", "->", "FormatNumber", "(", "$", "oShopBasket", "->", "dCostTotal", ")", ")", "*", "100", ";", "$", "sXML", "=", "'<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n <paymentService version=\"1\">\n <body merchantId=\"'", ".", "$", "this", "->", "GetTestLiveModeParameter", "(", "'merchantId'", ")", ".", "'\">\n <transaction refno=\"'", ".", "$", "sRefNo", ".", "'\">\n <request>\n <amount>'", ".", "$", "sAmount", ".", "'</amount>\n <currency>'", ".", "$", "sCurrency", ".", "'</currency>\n <uppTransactionId>'", ".", "$", "this", "->", "sTransactionId", ".", "'</uppTransactionId>\n <transtype>'", ".", "self", "::", "PAYMENT_CREDIT_CARD_TRANS_TYPE_ID", ".", "'</transtype>\n <sign>'", ".", "$", "this", "->", "GetSecurityHash", "(", "$", "this", "->", "GetTestLiveModeParameter", "(", "'sign'", ")", ",", "$", "sMerchantId", ",", "$", "sAmount", ",", "$", "sCurrency", ",", "$", "sRefNo", ")", ".", "'</sign>\n </request>\n </transaction>\n </body>\n </paymentService>'", ";", "return", "$", "sXML", ";", "}" ]
Returns the xml request valeu for settlement. @return string
[ "Returns", "the", "xml", "request", "valeu", "for", "settlement", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerDataTrans.class.php#L580-L604
32,434
chameleon-system/chameleon-shop
src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerDataTrans.class.php
TShopPaymentHandlerDataTrans.hexstr
protected function hexstr($hex) { $string = ''; for ($i = 0; $i < strlen($hex) - 1; $i += 2) { $string .= chr(hexdec($hex[$i].$hex[$i + 1])); } return $string; }
php
protected function hexstr($hex) { $string = ''; for ($i = 0; $i < strlen($hex) - 1; $i += 2) { $string .= chr(hexdec($hex[$i].$hex[$i + 1])); } return $string; }
[ "protected", "function", "hexstr", "(", "$", "hex", ")", "{", "$", "string", "=", "''", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "strlen", "(", "$", "hex", ")", "-", "1", ";", "$", "i", "+=", "2", ")", "{", "$", "string", ".=", "chr", "(", "hexdec", "(", "$", "hex", "[", "$", "i", "]", ".", "$", "hex", "[", "$", "i", "+", "1", "]", ")", ")", ";", "}", "return", "$", "string", ";", "}" ]
Converts hex to string. Was needed for the sign check. @param $hex @return string
[ "Converts", "hex", "to", "string", ".", "Was", "needed", "for", "the", "sign", "check", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerDataTrans.class.php#L631-L639
32,435
chameleon-system/chameleon-shop
src/ShopBundle/objects/db/TShopOrderStep/TShopStepShippingCore.class.php
TShopStepShippingCore.ChangeShippingGroup
public function ChangeShippingGroup() { $oBasket = TShopBasket::GetInstance(); $this->oActiveShippingGroup = $oBasket->GetActiveShippingGroup(); // check if the group is still valid. if not, reload using default if (!$this->oActiveShippingGroup || false == $this->oActiveShippingGroup->IsAvailable()) { $oBasket->SetActiveShippingGroup(null); $oBasket->SetBasketRecalculationFlag(true); $this->oActiveShippingGroup = $oBasket->GetActiveShippingGroup(); } $iShippingGroupId = null; if (array_key_exists('shop_shipping_group_id', $this->aRequestData)) { //shop_payment_methode_id? $iShippingGroupId = $this->aRequestData['shop_shipping_group_id']; /** @var $oShippingGroup TdbShopShippingGroup */ $this->oActiveShippingGroup = TdbShopShippingGroup::GetNewInstance(); if (!$this->oActiveShippingGroup->Load($iShippingGroupId)) { // if the requested group was not found, fetch default from basket again if (is_null($this->oActiveShippingGroup)) { $this->oActiveShippingGroup = $oBasket->GetActiveShippingGroup(); } } else { $oBasket->SetActiveShippingGroup($this->oActiveShippingGroup); $oBasket->SetBasketRecalculationFlag(true); } } }
php
public function ChangeShippingGroup() { $oBasket = TShopBasket::GetInstance(); $this->oActiveShippingGroup = $oBasket->GetActiveShippingGroup(); // check if the group is still valid. if not, reload using default if (!$this->oActiveShippingGroup || false == $this->oActiveShippingGroup->IsAvailable()) { $oBasket->SetActiveShippingGroup(null); $oBasket->SetBasketRecalculationFlag(true); $this->oActiveShippingGroup = $oBasket->GetActiveShippingGroup(); } $iShippingGroupId = null; if (array_key_exists('shop_shipping_group_id', $this->aRequestData)) { //shop_payment_methode_id? $iShippingGroupId = $this->aRequestData['shop_shipping_group_id']; /** @var $oShippingGroup TdbShopShippingGroup */ $this->oActiveShippingGroup = TdbShopShippingGroup::GetNewInstance(); if (!$this->oActiveShippingGroup->Load($iShippingGroupId)) { // if the requested group was not found, fetch default from basket again if (is_null($this->oActiveShippingGroup)) { $this->oActiveShippingGroup = $oBasket->GetActiveShippingGroup(); } } else { $oBasket->SetActiveShippingGroup($this->oActiveShippingGroup); $oBasket->SetBasketRecalculationFlag(true); } } }
[ "public", "function", "ChangeShippingGroup", "(", ")", "{", "$", "oBasket", "=", "TShopBasket", "::", "GetInstance", "(", ")", ";", "$", "this", "->", "oActiveShippingGroup", "=", "$", "oBasket", "->", "GetActiveShippingGroup", "(", ")", ";", "// check if the group is still valid. if not, reload using default", "if", "(", "!", "$", "this", "->", "oActiveShippingGroup", "||", "false", "==", "$", "this", "->", "oActiveShippingGroup", "->", "IsAvailable", "(", ")", ")", "{", "$", "oBasket", "->", "SetActiveShippingGroup", "(", "null", ")", ";", "$", "oBasket", "->", "SetBasketRecalculationFlag", "(", "true", ")", ";", "$", "this", "->", "oActiveShippingGroup", "=", "$", "oBasket", "->", "GetActiveShippingGroup", "(", ")", ";", "}", "$", "iShippingGroupId", "=", "null", ";", "if", "(", "array_key_exists", "(", "'shop_shipping_group_id'", ",", "$", "this", "->", "aRequestData", ")", ")", "{", "//shop_payment_methode_id?", "$", "iShippingGroupId", "=", "$", "this", "->", "aRequestData", "[", "'shop_shipping_group_id'", "]", ";", "/** @var $oShippingGroup TdbShopShippingGroup */", "$", "this", "->", "oActiveShippingGroup", "=", "TdbShopShippingGroup", "::", "GetNewInstance", "(", ")", ";", "if", "(", "!", "$", "this", "->", "oActiveShippingGroup", "->", "Load", "(", "$", "iShippingGroupId", ")", ")", "{", "// if the requested group was not found, fetch default from basket again", "if", "(", "is_null", "(", "$", "this", "->", "oActiveShippingGroup", ")", ")", "{", "$", "this", "->", "oActiveShippingGroup", "=", "$", "oBasket", "->", "GetActiveShippingGroup", "(", ")", ";", "}", "}", "else", "{", "$", "oBasket", "->", "SetActiveShippingGroup", "(", "$", "this", "->", "oActiveShippingGroup", ")", ";", "$", "oBasket", "->", "SetBasketRecalculationFlag", "(", "true", ")", ";", "}", "}", "}" ]
changes the shipping group to the one passed via post or get in shippinggroupid=id.
[ "changes", "the", "shipping", "group", "to", "the", "one", "passed", "via", "post", "or", "get", "in", "shippinggroupid", "=", "id", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopOrderStep/TShopStepShippingCore.class.php#L221-L246
32,436
chameleon-system/chameleon-shop
src/ShopBundle/objects/db/TShopOrderStep/TShopStepShippingCore.class.php
TShopStepShippingCore.LoadActivePaymentMethod
protected function LoadActivePaymentMethod() { $oBasket = TShopBasket::GetInstance(); $this->oActivePaymentMethod = &$oBasket->GetActivePaymentMethod(); if (!is_null($this->oActiveShippingGroup)) { $iPaymentId = null; $bSelectionValid = true; if (array_key_exists('shop_payment_method_id', $this->aRequestData)) { $iPaymentId = $this->aRequestData['shop_payment_method_id']; // make sure the entry may be selected by the user $bSelectionValid = false; $oUserSelectablePaymentMethods = $this->oActiveShippingGroup->GetValidPaymentMethodsSelectableByTheUser(); if (true == $oUserSelectablePaymentMethods->FindItemWithProperty('id', $iPaymentId)) { if (is_null($this->oActivePaymentMethod) || !is_array($this->oActivePaymentMethod->sqlData) || $this->oActivePaymentMethod->id != $iPaymentId) { $this->oActivePaymentMethod = TdbShopPaymentMethod::GetNewInstance(); if (!$this->oActivePaymentMethod->Load($iPaymentId)) { $this->oActivePaymentMethod = null; } else { $bSelectionValid = true; } } else { $bSelectionValid = true; } } } if (true == $bSelectionValid) { // found one? make sure it is in the active shipping group $oList = $oBasket->GetAvailablePaymentMethods(); if (!is_null($this->oActivePaymentMethod)) { if (!$oList->IsInList($this->oActivePaymentMethod->id)) { $this->oActivePaymentMethod = null; } } // still nothing? just take the first one from the list if (is_null($this->oActivePaymentMethod)) { $oList->GoToStart(); if ($oList->Length() > 0) { $this->oActivePaymentMethod = &$oList->Current(); } } } } else { $this->oActivePaymentMethod = null; } }
php
protected function LoadActivePaymentMethod() { $oBasket = TShopBasket::GetInstance(); $this->oActivePaymentMethod = &$oBasket->GetActivePaymentMethod(); if (!is_null($this->oActiveShippingGroup)) { $iPaymentId = null; $bSelectionValid = true; if (array_key_exists('shop_payment_method_id', $this->aRequestData)) { $iPaymentId = $this->aRequestData['shop_payment_method_id']; // make sure the entry may be selected by the user $bSelectionValid = false; $oUserSelectablePaymentMethods = $this->oActiveShippingGroup->GetValidPaymentMethodsSelectableByTheUser(); if (true == $oUserSelectablePaymentMethods->FindItemWithProperty('id', $iPaymentId)) { if (is_null($this->oActivePaymentMethod) || !is_array($this->oActivePaymentMethod->sqlData) || $this->oActivePaymentMethod->id != $iPaymentId) { $this->oActivePaymentMethod = TdbShopPaymentMethod::GetNewInstance(); if (!$this->oActivePaymentMethod->Load($iPaymentId)) { $this->oActivePaymentMethod = null; } else { $bSelectionValid = true; } } else { $bSelectionValid = true; } } } if (true == $bSelectionValid) { // found one? make sure it is in the active shipping group $oList = $oBasket->GetAvailablePaymentMethods(); if (!is_null($this->oActivePaymentMethod)) { if (!$oList->IsInList($this->oActivePaymentMethod->id)) { $this->oActivePaymentMethod = null; } } // still nothing? just take the first one from the list if (is_null($this->oActivePaymentMethod)) { $oList->GoToStart(); if ($oList->Length() > 0) { $this->oActivePaymentMethod = &$oList->Current(); } } } } else { $this->oActivePaymentMethod = null; } }
[ "protected", "function", "LoadActivePaymentMethod", "(", ")", "{", "$", "oBasket", "=", "TShopBasket", "::", "GetInstance", "(", ")", ";", "$", "this", "->", "oActivePaymentMethod", "=", "&", "$", "oBasket", "->", "GetActivePaymentMethod", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "this", "->", "oActiveShippingGroup", ")", ")", "{", "$", "iPaymentId", "=", "null", ";", "$", "bSelectionValid", "=", "true", ";", "if", "(", "array_key_exists", "(", "'shop_payment_method_id'", ",", "$", "this", "->", "aRequestData", ")", ")", "{", "$", "iPaymentId", "=", "$", "this", "->", "aRequestData", "[", "'shop_payment_method_id'", "]", ";", "// make sure the entry may be selected by the user", "$", "bSelectionValid", "=", "false", ";", "$", "oUserSelectablePaymentMethods", "=", "$", "this", "->", "oActiveShippingGroup", "->", "GetValidPaymentMethodsSelectableByTheUser", "(", ")", ";", "if", "(", "true", "==", "$", "oUserSelectablePaymentMethods", "->", "FindItemWithProperty", "(", "'id'", ",", "$", "iPaymentId", ")", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "oActivePaymentMethod", ")", "||", "!", "is_array", "(", "$", "this", "->", "oActivePaymentMethod", "->", "sqlData", ")", "||", "$", "this", "->", "oActivePaymentMethod", "->", "id", "!=", "$", "iPaymentId", ")", "{", "$", "this", "->", "oActivePaymentMethod", "=", "TdbShopPaymentMethod", "::", "GetNewInstance", "(", ")", ";", "if", "(", "!", "$", "this", "->", "oActivePaymentMethod", "->", "Load", "(", "$", "iPaymentId", ")", ")", "{", "$", "this", "->", "oActivePaymentMethod", "=", "null", ";", "}", "else", "{", "$", "bSelectionValid", "=", "true", ";", "}", "}", "else", "{", "$", "bSelectionValid", "=", "true", ";", "}", "}", "}", "if", "(", "true", "==", "$", "bSelectionValid", ")", "{", "// found one? make sure it is in the active shipping group", "$", "oList", "=", "$", "oBasket", "->", "GetAvailablePaymentMethods", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "this", "->", "oActivePaymentMethod", ")", ")", "{", "if", "(", "!", "$", "oList", "->", "IsInList", "(", "$", "this", "->", "oActivePaymentMethod", "->", "id", ")", ")", "{", "$", "this", "->", "oActivePaymentMethod", "=", "null", ";", "}", "}", "// still nothing? just take the first one from the list", "if", "(", "is_null", "(", "$", "this", "->", "oActivePaymentMethod", ")", ")", "{", "$", "oList", "->", "GoToStart", "(", ")", ";", "if", "(", "$", "oList", "->", "Length", "(", ")", ">", "0", ")", "{", "$", "this", "->", "oActivePaymentMethod", "=", "&", "$", "oList", "->", "Current", "(", ")", ";", "}", "}", "}", "}", "else", "{", "$", "this", "->", "oActivePaymentMethod", "=", "null", ";", "}", "}" ]
loads the active payment method.
[ "loads", "the", "active", "payment", "method", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopOrderStep/TShopStepShippingCore.class.php#L251-L296
32,437
chameleon-system/chameleon-shop
src/ShopBundle/objects/db/TShopOrderStep/TShopStepShippingCore.class.php
TShopStepShippingCore.GetHtmlHeadIncludes
public function GetHtmlHeadIncludes() { $aIncludes = parent::GetHtmlHeadIncludes(); if (isset($this->oActiveShippingGroup)) { $oPaymentMethodList = TShopBasket::GetInstance()->GetAvailablePaymentMethods(); if ($oPaymentMethodList) { while ($oPaymentMethod = $oPaymentMethodList->Next()) { $oPaymentHandler = $oPaymentMethod->GetFieldShopPaymentHandler(); if (method_exists($oPaymentHandler, 'GetHtmlHeadIncludes')) { $aAdditionalIncludes = $oPaymentHandler->GetHtmlHeadIncludes(); if (count($aAdditionalIncludes) > 0) { $aIncludes = array_merge($aIncludes, $aAdditionalIncludes); } } } } } return $aIncludes; }
php
public function GetHtmlHeadIncludes() { $aIncludes = parent::GetHtmlHeadIncludes(); if (isset($this->oActiveShippingGroup)) { $oPaymentMethodList = TShopBasket::GetInstance()->GetAvailablePaymentMethods(); if ($oPaymentMethodList) { while ($oPaymentMethod = $oPaymentMethodList->Next()) { $oPaymentHandler = $oPaymentMethod->GetFieldShopPaymentHandler(); if (method_exists($oPaymentHandler, 'GetHtmlHeadIncludes')) { $aAdditionalIncludes = $oPaymentHandler->GetHtmlHeadIncludes(); if (count($aAdditionalIncludes) > 0) { $aIncludes = array_merge($aIncludes, $aAdditionalIncludes); } } } } } return $aIncludes; }
[ "public", "function", "GetHtmlHeadIncludes", "(", ")", "{", "$", "aIncludes", "=", "parent", "::", "GetHtmlHeadIncludes", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "oActiveShippingGroup", ")", ")", "{", "$", "oPaymentMethodList", "=", "TShopBasket", "::", "GetInstance", "(", ")", "->", "GetAvailablePaymentMethods", "(", ")", ";", "if", "(", "$", "oPaymentMethodList", ")", "{", "while", "(", "$", "oPaymentMethod", "=", "$", "oPaymentMethodList", "->", "Next", "(", ")", ")", "{", "$", "oPaymentHandler", "=", "$", "oPaymentMethod", "->", "GetFieldShopPaymentHandler", "(", ")", ";", "if", "(", "method_exists", "(", "$", "oPaymentHandler", ",", "'GetHtmlHeadIncludes'", ")", ")", "{", "$", "aAdditionalIncludes", "=", "$", "oPaymentHandler", "->", "GetHtmlHeadIncludes", "(", ")", ";", "if", "(", "count", "(", "$", "aAdditionalIncludes", ")", ">", "0", ")", "{", "$", "aIncludes", "=", "array_merge", "(", "$", "aIncludes", ",", "$", "aAdditionalIncludes", ")", ";", "}", "}", "}", "}", "}", "return", "$", "aIncludes", ";", "}" ]
define any head includes the step needs loads includes from payment handlers. @return array
[ "define", "any", "head", "includes", "the", "step", "needs", "loads", "includes", "from", "payment", "handlers", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopOrderStep/TShopStepShippingCore.class.php#L321-L342
32,438
chameleon-system/chameleon-shop
src/ShopBundle/pkgExtranet/objects/db/TShopDataExtranetCore.class.php
TShopDataExtranetCore.GetLinkLogout
public function GetLinkLogout($sSpotName) { $oGlobal = TGlobal::instance(); // if we are on the last page of checkout process we can't use the active page url for logout // so we redirect to the home url with logout method as parameter if ($oGlobal->UserDataExists(MTShopOrderWizardCore::URL_PARAM_STEP_SYSTEM_NAME) && 'thankyou' == $oGlobal->GetUserData(MTShopOrderWizardCore::URL_PARAM_STEP_SYSTEM_NAME)) { return self::getPageService()->getLinkToPortalHomePageAbsolute().'?'.TTools::GetArrayAsURL(array('module_fnc['.$sSpotName.']' => 'Logout')); } return parent::GetLinkLogout($sSpotName); }
php
public function GetLinkLogout($sSpotName) { $oGlobal = TGlobal::instance(); // if we are on the last page of checkout process we can't use the active page url for logout // so we redirect to the home url with logout method as parameter if ($oGlobal->UserDataExists(MTShopOrderWizardCore::URL_PARAM_STEP_SYSTEM_NAME) && 'thankyou' == $oGlobal->GetUserData(MTShopOrderWizardCore::URL_PARAM_STEP_SYSTEM_NAME)) { return self::getPageService()->getLinkToPortalHomePageAbsolute().'?'.TTools::GetArrayAsURL(array('module_fnc['.$sSpotName.']' => 'Logout')); } return parent::GetLinkLogout($sSpotName); }
[ "public", "function", "GetLinkLogout", "(", "$", "sSpotName", ")", "{", "$", "oGlobal", "=", "TGlobal", "::", "instance", "(", ")", ";", "// if we are on the last page of checkout process we can't use the active page url for logout", "// so we redirect to the home url with logout method as parameter", "if", "(", "$", "oGlobal", "->", "UserDataExists", "(", "MTShopOrderWizardCore", "::", "URL_PARAM_STEP_SYSTEM_NAME", ")", "&&", "'thankyou'", "==", "$", "oGlobal", "->", "GetUserData", "(", "MTShopOrderWizardCore", "::", "URL_PARAM_STEP_SYSTEM_NAME", ")", ")", "{", "return", "self", "::", "getPageService", "(", ")", "->", "getLinkToPortalHomePageAbsolute", "(", ")", ".", "'?'", ".", "TTools", "::", "GetArrayAsURL", "(", "array", "(", "'module_fnc['", ".", "$", "sSpotName", ".", "']'", "=>", "'Logout'", ")", ")", ";", "}", "return", "parent", "::", "GetLinkLogout", "(", "$", "sSpotName", ")", ";", "}" ]
returns link to current page with logout method as parameter for given spotname of extranet module if not on "thank you" page of order process otherwise it would return link to home page with logout method as parameter for given spotname. @param $sSpotName @return string
[ "returns", "link", "to", "current", "page", "with", "logout", "method", "as", "parameter", "for", "given", "spotname", "of", "extranet", "module", "if", "not", "on", "thank", "you", "page", "of", "order", "process", "otherwise", "it", "would", "return", "link", "to", "home", "page", "with", "logout", "method", "as", "parameter", "for", "given", "spotname", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/pkgExtranet/objects/db/TShopDataExtranetCore.class.php#L22-L32
32,439
PGB-LIV/php-ms
src/Utility/Fragment/AbstractFragment.php
AbstractFragment.getChargedIon
protected function getChargedIon($mass, $charge) { $chargedMass = $mass + (PhysicalConstants::PROTON_MASS * $charge); return $chargedMass / $charge; }
php
protected function getChargedIon($mass, $charge) { $chargedMass = $mass + (PhysicalConstants::PROTON_MASS * $charge); return $chargedMass / $charge; }
[ "protected", "function", "getChargedIon", "(", "$", "mass", ",", "$", "charge", ")", "{", "$", "chargedMass", "=", "$", "mass", "+", "(", "PhysicalConstants", "::", "PROTON_MASS", "*", "$", "charge", ")", ";", "return", "$", "chargedMass", "/", "$", "charge", ";", "}" ]
Charges the mass to the specified charge @param double $mass The neutral mass to charge @param int $charge The integer charge value to charge too @return double
[ "Charges", "the", "mass", "to", "the", "specified", "charge" ]
091751eb12512f4bc6ada07bda745ce49331e24f
https://github.com/PGB-LIV/php-ms/blob/091751eb12512f4bc6ada07bda745ce49331e24f/src/Utility/Fragment/AbstractFragment.php#L177-L181
32,440
Erebot/Erebot
src/Proxy/SOCKS.php
SOCKS.userpass
protected function userpass(\Erebot\URIInterface $proxyURI) { $username = $proxyURI->asParsedURL(PHP_URL_USER); $password = $proxyURI->asParsedURL(PHP_URL_PASS); if ($username === null || $password === null) { throw new \Erebot\InvalidValueException( 'No username or password supplied' ); } $ulen = strlen($username); $plen = strlen($password); if ($ulen > 255) { throw new \Erebot\InvalidValueException( 'Username too long (max. 255)' ); } if ($plen > 255) { throw new \Erebot\InvalidValueException( 'Password too long (max. 255)' ); } $this->write( "\x01".pack( "Ca*Ca*", $ulen, $username, $plen, $password ) ); $line = $this->read(2); if ($line[0] != "\x01") { throw new \Erebot\InvalidValueException( 'Bad subnegociation version' ); } if ($line[1] != "\x00") { throw new \Erebot\InvalidValueException('Bad username or password'); } }
php
protected function userpass(\Erebot\URIInterface $proxyURI) { $username = $proxyURI->asParsedURL(PHP_URL_USER); $password = $proxyURI->asParsedURL(PHP_URL_PASS); if ($username === null || $password === null) { throw new \Erebot\InvalidValueException( 'No username or password supplied' ); } $ulen = strlen($username); $plen = strlen($password); if ($ulen > 255) { throw new \Erebot\InvalidValueException( 'Username too long (max. 255)' ); } if ($plen > 255) { throw new \Erebot\InvalidValueException( 'Password too long (max. 255)' ); } $this->write( "\x01".pack( "Ca*Ca*", $ulen, $username, $plen, $password ) ); $line = $this->read(2); if ($line[0] != "\x01") { throw new \Erebot\InvalidValueException( 'Bad subnegociation version' ); } if ($line[1] != "\x00") { throw new \Erebot\InvalidValueException('Bad username or password'); } }
[ "protected", "function", "userpass", "(", "\\", "Erebot", "\\", "URIInterface", "$", "proxyURI", ")", "{", "$", "username", "=", "$", "proxyURI", "->", "asParsedURL", "(", "PHP_URL_USER", ")", ";", "$", "password", "=", "$", "proxyURI", "->", "asParsedURL", "(", "PHP_URL_PASS", ")", ";", "if", "(", "$", "username", "===", "null", "||", "$", "password", "===", "null", ")", "{", "throw", "new", "\\", "Erebot", "\\", "InvalidValueException", "(", "'No username or password supplied'", ")", ";", "}", "$", "ulen", "=", "strlen", "(", "$", "username", ")", ";", "$", "plen", "=", "strlen", "(", "$", "password", ")", ";", "if", "(", "$", "ulen", ">", "255", ")", "{", "throw", "new", "\\", "Erebot", "\\", "InvalidValueException", "(", "'Username too long (max. 255)'", ")", ";", "}", "if", "(", "$", "plen", ">", "255", ")", "{", "throw", "new", "\\", "Erebot", "\\", "InvalidValueException", "(", "'Password too long (max. 255)'", ")", ";", "}", "$", "this", "->", "write", "(", "\"\\x01\"", ".", "pack", "(", "\"Ca*Ca*\"", ",", "$", "ulen", ",", "$", "username", ",", "$", "plen", ",", "$", "password", ")", ")", ";", "$", "line", "=", "$", "this", "->", "read", "(", "2", ")", ";", "if", "(", "$", "line", "[", "0", "]", "!=", "\"\\x01\"", ")", "{", "throw", "new", "\\", "Erebot", "\\", "InvalidValueException", "(", "'Bad subnegociation version'", ")", ";", "}", "if", "(", "$", "line", "[", "1", "]", "!=", "\"\\x00\"", ")", "{", "throw", "new", "\\", "Erebot", "\\", "InvalidValueException", "(", "'Bad username or password'", ")", ";", "}", "}" ]
Does the authentication step. \param Erebot::URIInterface $proxyURI An object representing the URI of this SOCKS proxy server, containing the credentials that will be sent during the authentication step.
[ "Does", "the", "authentication", "step", "." ]
691fc3fa8bc6f07061ff2b3798fec76bc3a039aa
https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/Proxy/SOCKS.php#L123-L168
32,441
Erebot/Erebot
src/Proxy/SOCKS.php
SOCKS.write
protected function write($line) { for ($written = 0, $len = strlen($line); $written < $len; $written += $fwrite) { $fwrite = fwrite($this->socket, substr($line, $written)); if ($fwrite === false) { throw new \Erebot\Exception('Connection closed by proxy'); } } return $written; }
php
protected function write($line) { for ($written = 0, $len = strlen($line); $written < $len; $written += $fwrite) { $fwrite = fwrite($this->socket, substr($line, $written)); if ($fwrite === false) { throw new \Erebot\Exception('Connection closed by proxy'); } } return $written; }
[ "protected", "function", "write", "(", "$", "line", ")", "{", "for", "(", "$", "written", "=", "0", ",", "$", "len", "=", "strlen", "(", "$", "line", ")", ";", "$", "written", "<", "$", "len", ";", "$", "written", "+=", "$", "fwrite", ")", "{", "$", "fwrite", "=", "fwrite", "(", "$", "this", "->", "socket", ",", "substr", "(", "$", "line", ",", "$", "written", ")", ")", ";", "if", "(", "$", "fwrite", "===", "false", ")", "{", "throw", "new", "\\", "Erebot", "\\", "Exception", "(", "'Connection closed by proxy'", ")", ";", "}", "}", "return", "$", "written", ";", "}" ]
Passes some data to the proxy server. \param string $line Data to send. \retval int Number of bytes actually sent (this may be lower that the length of the initial $line if some bytes could not be sent).
[ "Passes", "some", "data", "to", "the", "proxy", "server", "." ]
691fc3fa8bc6f07061ff2b3798fec76bc3a039aa
https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/Proxy/SOCKS.php#L181-L190
32,442
Erebot/Erebot
src/Proxy/SOCKS.php
SOCKS.read
protected function read($len) { $contents = ""; $clen = 0; while (!feof($this->socket) && $clen < $len) { $read = fread($this->socket, $len - $clen); if ($read === false) { throw new \Erebot\Exception('Connection closed by proxy'); } $contents .= $read; $clen = strlen($contents); } return $contents; }
php
protected function read($len) { $contents = ""; $clen = 0; while (!feof($this->socket) && $clen < $len) { $read = fread($this->socket, $len - $clen); if ($read === false) { throw new \Erebot\Exception('Connection closed by proxy'); } $contents .= $read; $clen = strlen($contents); } return $contents; }
[ "protected", "function", "read", "(", "$", "len", ")", "{", "$", "contents", "=", "\"\"", ";", "$", "clen", "=", "0", ";", "while", "(", "!", "feof", "(", "$", "this", "->", "socket", ")", "&&", "$", "clen", "<", "$", "len", ")", "{", "$", "read", "=", "fread", "(", "$", "this", "->", "socket", ",", "$", "len", "-", "$", "clen", ")", ";", "if", "(", "$", "read", "===", "false", ")", "{", "throw", "new", "\\", "Erebot", "\\", "Exception", "(", "'Connection closed by proxy'", ")", ";", "}", "$", "contents", ".=", "$", "read", ";", "$", "clen", "=", "strlen", "(", "$", "contents", ")", ";", "}", "return", "$", "contents", ";", "}" ]
Reads some data from the proxy server. \param int $len Number of bytes to read from the proxy server. \retval string Actual data read.
[ "Reads", "some", "data", "from", "the", "proxy", "server", "." ]
691fc3fa8bc6f07061ff2b3798fec76bc3a039aa
https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/Proxy/SOCKS.php#L201-L214
32,443
chameleon-system/chameleon-shop
src/ShopBundle/objects/ArticleList/State.php
State.getStateString
public function getStateString(array $varyingStateParameter = null) { $stateInput = $this->getStateArrayWithoutQueryParameter(); $parts = array(); foreach ($stateInput as $key => $value) { if (null !== $varyingStateParameter && in_array($key, $varyingStateParameter)) { continue; } $parts[] = $key.':'.$value; } if (0 === count($parts)) { return ''; } return implode(',', $parts); }
php
public function getStateString(array $varyingStateParameter = null) { $stateInput = $this->getStateArrayWithoutQueryParameter(); $parts = array(); foreach ($stateInput as $key => $value) { if (null !== $varyingStateParameter && in_array($key, $varyingStateParameter)) { continue; } $parts[] = $key.':'.$value; } if (0 === count($parts)) { return ''; } return implode(',', $parts); }
[ "public", "function", "getStateString", "(", "array", "$", "varyingStateParameter", "=", "null", ")", "{", "$", "stateInput", "=", "$", "this", "->", "getStateArrayWithoutQueryParameter", "(", ")", ";", "$", "parts", "=", "array", "(", ")", ";", "foreach", "(", "$", "stateInput", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "null", "!==", "$", "varyingStateParameter", "&&", "in_array", "(", "$", "key", ",", "$", "varyingStateParameter", ")", ")", "{", "continue", ";", "}", "$", "parts", "[", "]", "=", "$", "key", ".", "':'", ".", "$", "value", ";", "}", "if", "(", "0", "===", "count", "(", "$", "parts", ")", ")", "{", "return", "''", ";", "}", "return", "implode", "(", "','", ",", "$", "parts", ")", ";", "}" ]
returns a string representation of the state, excluding the parameter specified by varyingStateParameter. @param array|null $varyingStateParameter @return string
[ "returns", "a", "string", "representation", "of", "the", "state", "excluding", "the", "parameter", "specified", "by", "varyingStateParameter", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/ArticleList/State.php#L79-L95
32,444
chameleon-system/chameleon-shop
src/ShopBundle/objects/ArticleList/State.php
State.setUnsetStatesOnly
public function setUnsetStatesOnly(array $stateValues) { foreach ($stateValues as $key => $value) { if (null === $this->getState($key, null)) { $this->setState($key, $value); } } }
php
public function setUnsetStatesOnly(array $stateValues) { foreach ($stateValues as $key => $value) { if (null === $this->getState($key, null)) { $this->setState($key, $value); } } }
[ "public", "function", "setUnsetStatesOnly", "(", "array", "$", "stateValues", ")", "{", "foreach", "(", "$", "stateValues", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "null", "===", "$", "this", "->", "getState", "(", "$", "key", ",", "null", ")", ")", "{", "$", "this", "->", "setState", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}", "}" ]
sets values in stateValues that have no value in the current state. ignores all others. @param array $stateValues
[ "sets", "values", "in", "stateValues", "that", "have", "no", "value", "in", "the", "current", "state", ".", "ignores", "all", "others", "." ]
2e47f4eeab604449605ee1867180c9a37a8c208e
https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/ArticleList/State.php#L171-L178
32,445
flash-global/mailer-common
src/Entity/Attachment.php
Attachment.getId
public function getId() { if (is_null($this->id)) { $this->id = md5(getmypid().'.'.time().'.'.uniqid(mt_rand(), true)) . '@mailer.generated'; } return $this->id; }
php
public function getId() { if (is_null($this->id)) { $this->id = md5(getmypid().'.'.time().'.'.uniqid(mt_rand(), true)) . '@mailer.generated'; } return $this->id; }
[ "public", "function", "getId", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "id", ")", ")", "{", "$", "this", "->", "id", "=", "md5", "(", "getmypid", "(", ")", ".", "'.'", ".", "time", "(", ")", ".", "'.'", ".", "uniqid", "(", "mt_rand", "(", ")", ",", "true", ")", ")", ".", "'@mailer.generated'", ";", "}", "return", "$", "this", "->", "id", ";", "}" ]
Get attachment ID @return string
[ "Get", "attachment", "ID" ]
3240ca53570d9b346af8087c9b32d4883f3383ce
https://github.com/flash-global/mailer-common/blob/3240ca53570d9b346af8087c9b32d4883f3383ce/src/Entity/Attachment.php#L90-L97
32,446
flash-global/mailer-common
src/Entity/Attachment.php
Attachment.getMimeType
public function getMimeType() { if (empty($this->mimeType)) { $resource = finfo_open(FILEINFO_MIME_TYPE); $this->mimeType = finfo_file($resource, $this->getRealPath()); } return $this->mimeType; }
php
public function getMimeType() { if (empty($this->mimeType)) { $resource = finfo_open(FILEINFO_MIME_TYPE); $this->mimeType = finfo_file($resource, $this->getRealPath()); } return $this->mimeType; }
[ "public", "function", "getMimeType", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "mimeType", ")", ")", "{", "$", "resource", "=", "finfo_open", "(", "FILEINFO_MIME_TYPE", ")", ";", "$", "this", "->", "mimeType", "=", "finfo_file", "(", "$", "resource", ",", "$", "this", "->", "getRealPath", "(", ")", ")", ";", "}", "return", "$", "this", "->", "mimeType", ";", "}" ]
Get Mime Type @return string
[ "Get", "Mime", "Type" ]
3240ca53570d9b346af8087c9b32d4883f3383ce
https://github.com/flash-global/mailer-common/blob/3240ca53570d9b346af8087c9b32d4883f3383ce/src/Entity/Attachment.php#L128-L136
32,447
flash-global/mailer-common
src/Validator/MailValidator.php
MailValidator.validateAddress
public function validateAddress($address, $field, $isRequired = true) { if ($isRequired && empty($address)) { $this->addError($field, sprintf('%s is empty', ucfirst($field))); return false; } $validator = new EmailValidator(); $validation = new RFCValidation(); $success = true; foreach ($address as $email => $label) { if (!is_scalar($label)) { $this->addError( $field, sprintf('Label for %s is not scalar, `%s` given', $field, gettype($label)) ); $label = gettype($label); $success = false; } if ($validator->isValid($email, $validation) == false) { $this->addError( $field, sprintf('`%s` is not a valid email address for %s `%s`', $email, $field, $label) ); $success = false; } } return $success; }
php
public function validateAddress($address, $field, $isRequired = true) { if ($isRequired && empty($address)) { $this->addError($field, sprintf('%s is empty', ucfirst($field))); return false; } $validator = new EmailValidator(); $validation = new RFCValidation(); $success = true; foreach ($address as $email => $label) { if (!is_scalar($label)) { $this->addError( $field, sprintf('Label for %s is not scalar, `%s` given', $field, gettype($label)) ); $label = gettype($label); $success = false; } if ($validator->isValid($email, $validation) == false) { $this->addError( $field, sprintf('`%s` is not a valid email address for %s `%s`', $email, $field, $label) ); $success = false; } } return $success; }
[ "public", "function", "validateAddress", "(", "$", "address", ",", "$", "field", ",", "$", "isRequired", "=", "true", ")", "{", "if", "(", "$", "isRequired", "&&", "empty", "(", "$", "address", ")", ")", "{", "$", "this", "->", "addError", "(", "$", "field", ",", "sprintf", "(", "'%s is empty'", ",", "ucfirst", "(", "$", "field", ")", ")", ")", ";", "return", "false", ";", "}", "$", "validator", "=", "new", "EmailValidator", "(", ")", ";", "$", "validation", "=", "new", "RFCValidation", "(", ")", ";", "$", "success", "=", "true", ";", "foreach", "(", "$", "address", "as", "$", "email", "=>", "$", "label", ")", "{", "if", "(", "!", "is_scalar", "(", "$", "label", ")", ")", "{", "$", "this", "->", "addError", "(", "$", "field", ",", "sprintf", "(", "'Label for %s is not scalar, `%s` given'", ",", "$", "field", ",", "gettype", "(", "$", "label", ")", ")", ")", ";", "$", "label", "=", "gettype", "(", "$", "label", ")", ";", "$", "success", "=", "false", ";", "}", "if", "(", "$", "validator", "->", "isValid", "(", "$", "email", ",", "$", "validation", ")", "==", "false", ")", "{", "$", "this", "->", "addError", "(", "$", "field", ",", "sprintf", "(", "'`%s` is not a valid email address for %s `%s`'", ",", "$", "email", ",", "$", "field", ",", "$", "label", ")", ")", ";", "$", "success", "=", "false", ";", "}", "}", "return", "$", "success", ";", "}" ]
Validate address fields @param array $address @param string $field @param bool $isRequired @return bool
[ "Validate", "address", "fields" ]
3240ca53570d9b346af8087c9b32d4883f3383ce
https://github.com/flash-global/mailer-common/blob/3240ca53570d9b346af8087c9b32d4883f3383ce/src/Validator/MailValidator.php#L93-L124
32,448
flash-global/mailer-common
src/Entity/Mail.php
Mail.getContext
public function getContext() { return array_filter(array( 'subject' => $this->getSubject(), 'from' => $this->addressToString((array) $this->getSender()), 'to' => $this->addressToString((array) $this->getRecipients()), 'cc' => $this->addressToString((array) $this->getCc()), 'bcc' => $this->addressToString((array) $this->getBcc()) )); }
php
public function getContext() { return array_filter(array( 'subject' => $this->getSubject(), 'from' => $this->addressToString((array) $this->getSender()), 'to' => $this->addressToString((array) $this->getRecipients()), 'cc' => $this->addressToString((array) $this->getCc()), 'bcc' => $this->addressToString((array) $this->getBcc()) )); }
[ "public", "function", "getContext", "(", ")", "{", "return", "array_filter", "(", "array", "(", "'subject'", "=>", "$", "this", "->", "getSubject", "(", ")", ",", "'from'", "=>", "$", "this", "->", "addressToString", "(", "(", "array", ")", "$", "this", "->", "getSender", "(", ")", ")", ",", "'to'", "=>", "$", "this", "->", "addressToString", "(", "(", "array", ")", "$", "this", "->", "getRecipients", "(", ")", ")", ",", "'cc'", "=>", "$", "this", "->", "addressToString", "(", "(", "array", ")", "$", "this", "->", "getCc", "(", ")", ")", ",", "'bcc'", "=>", "$", "this", "->", "addressToString", "(", "(", "array", ")", "$", "this", "->", "getBcc", "(", ")", ")", ")", ")", ";", "}" ]
Get mail context @return array
[ "Get", "mail", "context" ]
3240ca53570d9b346af8087c9b32d4883f3383ce
https://github.com/flash-global/mailer-common/blob/3240ca53570d9b346af8087c9b32d4883f3383ce/src/Entity/Mail.php#L420-L429
32,449
flash-global/mailer-common
src/Entity/Mail.php
Mail.initAddress
protected function initAddress(array $address, $field) { $this->{$this->methodName('clear', $field)}(); foreach ($address as $email => $label) { if (is_int($email)) { $email = $label; } $this->{$this->methodName('add', $field)}($email, $label); } }
php
protected function initAddress(array $address, $field) { $this->{$this->methodName('clear', $field)}(); foreach ($address as $email => $label) { if (is_int($email)) { $email = $label; } $this->{$this->methodName('add', $field)}($email, $label); } }
[ "protected", "function", "initAddress", "(", "array", "$", "address", ",", "$", "field", ")", "{", "$", "this", "->", "{", "$", "this", "->", "methodName", "(", "'clear'", ",", "$", "field", ")", "}", "(", ")", ";", "foreach", "(", "$", "address", "as", "$", "email", "=>", "$", "label", ")", "{", "if", "(", "is_int", "(", "$", "email", ")", ")", "{", "$", "email", "=", "$", "label", ";", "}", "$", "this", "->", "{", "$", "this", "->", "methodName", "(", "'add'", ",", "$", "field", ")", "}", "(", "$", "email", ",", "$", "label", ")", ";", "}", "}" ]
Set address purpose property @param array $address @param string $field
[ "Set", "address", "purpose", "property" ]
3240ca53570d9b346af8087c9b32d4883f3383ce
https://github.com/flash-global/mailer-common/blob/3240ca53570d9b346af8087c9b32d4883f3383ce/src/Entity/Mail.php#L437-L448
32,450
flash-global/mailer-common
src/Entity/Mail.php
Mail.addAddress
protected function addAddress($address, $label, $field) { $label = is_string($label) ? trim($label) : $label; $address = is_string($address) ? trim($address) : $label; $label = $label ?: $address; if (!empty($address)) { $this->{$field}[$address] = $label; } }
php
protected function addAddress($address, $label, $field) { $label = is_string($label) ? trim($label) : $label; $address = is_string($address) ? trim($address) : $label; $label = $label ?: $address; if (!empty($address)) { $this->{$field}[$address] = $label; } }
[ "protected", "function", "addAddress", "(", "$", "address", ",", "$", "label", ",", "$", "field", ")", "{", "$", "label", "=", "is_string", "(", "$", "label", ")", "?", "trim", "(", "$", "label", ")", ":", "$", "label", ";", "$", "address", "=", "is_string", "(", "$", "address", ")", "?", "trim", "(", "$", "address", ")", ":", "$", "label", ";", "$", "label", "=", "$", "label", "?", ":", "$", "address", ";", "if", "(", "!", "empty", "(", "$", "address", ")", ")", "{", "$", "this", "->", "{", "$", "field", "}", "[", "$", "address", "]", "=", "$", "label", ";", "}", "}" ]
Add a address in a array property @param string $address @param string $label @param string $field
[ "Add", "a", "address", "in", "a", "array", "property" ]
3240ca53570d9b346af8087c9b32d4883f3383ce
https://github.com/flash-global/mailer-common/blob/3240ca53570d9b346af8087c9b32d4883f3383ce/src/Entity/Mail.php#L457-L467
32,451
flash-global/mailer-common
src/Entity/Mail.php
Mail.formatAddress
protected function formatAddress($address) { if (is_array($address)) { $email = is_int(key($address)) ? current($address) : key($address); return array($email => current($address)); } return array($address => $address); }
php
protected function formatAddress($address) { if (is_array($address)) { $email = is_int(key($address)) ? current($address) : key($address); return array($email => current($address)); } return array($address => $address); }
[ "protected", "function", "formatAddress", "(", "$", "address", ")", "{", "if", "(", "is_array", "(", "$", "address", ")", ")", "{", "$", "email", "=", "is_int", "(", "key", "(", "$", "address", ")", ")", "?", "current", "(", "$", "address", ")", ":", "key", "(", "$", "address", ")", ";", "return", "array", "(", "$", "email", "=>", "current", "(", "$", "address", ")", ")", ";", "}", "return", "array", "(", "$", "address", "=>", "$", "address", ")", ";", "}" ]
Format a address @param string|array $address @return array
[ "Format", "a", "address" ]
3240ca53570d9b346af8087c9b32d4883f3383ce
https://github.com/flash-global/mailer-common/blob/3240ca53570d9b346af8087c9b32d4883f3383ce/src/Entity/Mail.php#L476-L484
32,452
flash-global/mailer-common
src/Entity/Mail.php
Mail.addressToString
protected function addressToString(array $field) { $address = array(); foreach ($field as $key => $value) { $address[] = $key == $value ? $value : sprintf('%s <%s>', $value, $key); } return empty($address) ? null : implode(', ', $address); }
php
protected function addressToString(array $field) { $address = array(); foreach ($field as $key => $value) { $address[] = $key == $value ? $value : sprintf('%s <%s>', $value, $key); } return empty($address) ? null : implode(', ', $address); }
[ "protected", "function", "addressToString", "(", "array", "$", "field", ")", "{", "$", "address", "=", "array", "(", ")", ";", "foreach", "(", "$", "field", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "address", "[", "]", "=", "$", "key", "==", "$", "value", "?", "$", "value", ":", "sprintf", "(", "'%s <%s>'", ",", "$", "value", ",", "$", "key", ")", ";", "}", "return", "empty", "(", "$", "address", ")", "?", "null", ":", "implode", "(", "', '", ",", "$", "address", ")", ";", "}" ]
Convert address container to a string representation @param array $field @return string
[ "Convert", "address", "container", "to", "a", "string", "representation" ]
3240ca53570d9b346af8087c9b32d4883f3383ce
https://github.com/flash-global/mailer-common/blob/3240ca53570d9b346af8087c9b32d4883f3383ce/src/Entity/Mail.php#L493-L501
32,453
flash-global/mailer-common
src/Entity/Mail.php
Mail.methodName
protected function methodName($action, $field) { if (substr($field, -1, 1) === 's' && $action != 'clear') { $field = substr($field, 0, -1); } return $action . ucfirst(strtolower($field)); }
php
protected function methodName($action, $field) { if (substr($field, -1, 1) === 's' && $action != 'clear') { $field = substr($field, 0, -1); } return $action . ucfirst(strtolower($field)); }
[ "protected", "function", "methodName", "(", "$", "action", ",", "$", "field", ")", "{", "if", "(", "substr", "(", "$", "field", ",", "-", "1", ",", "1", ")", "===", "'s'", "&&", "$", "action", "!=", "'clear'", ")", "{", "$", "field", "=", "substr", "(", "$", "field", ",", "0", ",", "-", "1", ")", ";", "}", "return", "$", "action", ".", "ucfirst", "(", "strtolower", "(", "$", "field", ")", ")", ";", "}" ]
Returns the method name given a action and a field name @param $action @param $field @return string
[ "Returns", "the", "method", "name", "given", "a", "action", "and", "a", "field", "name" ]
3240ca53570d9b346af8087c9b32d4883f3383ce
https://github.com/flash-global/mailer-common/blob/3240ca53570d9b346af8087c9b32d4883f3383ce/src/Entity/Mail.php#L511-L518
32,454
widop/WidopHttpAdapterBundle
DependencyInjection/WidopHttpAdapterExtension.php
WidopHttpAdapterExtension.loadMaxRedirects
private function loadMaxRedirects(array $config, ContainerBuilder $container) { $services = array('buzz', 'curl', 'guzzle', 'stream', 'zend'); foreach ($services as $service) { $container ->getDefinition(sprintf('widop_http_adapter.%s', $service)) ->addMethodCall('setMaxRedirects', array($config['max_redirects'])); } }
php
private function loadMaxRedirects(array $config, ContainerBuilder $container) { $services = array('buzz', 'curl', 'guzzle', 'stream', 'zend'); foreach ($services as $service) { $container ->getDefinition(sprintf('widop_http_adapter.%s', $service)) ->addMethodCall('setMaxRedirects', array($config['max_redirects'])); } }
[ "private", "function", "loadMaxRedirects", "(", "array", "$", "config", ",", "ContainerBuilder", "$", "container", ")", "{", "$", "services", "=", "array", "(", "'buzz'", ",", "'curl'", ",", "'guzzle'", ",", "'stream'", ",", "'zend'", ")", ";", "foreach", "(", "$", "services", "as", "$", "service", ")", "{", "$", "container", "->", "getDefinition", "(", "sprintf", "(", "'widop_http_adapter.%s'", ",", "$", "service", ")", ")", "->", "addMethodCall", "(", "'setMaxRedirects'", ",", "array", "(", "$", "config", "[", "'max_redirects'", "]", ")", ")", ";", "}", "}" ]
Loads the max redirects in all http adapters. @param array $config The configuration. @param \Symfony\Component\DependencyInjection\ContainerBuilder $container The container.
[ "Loads", "the", "max", "redirects", "in", "all", "http", "adapters", "." ]
f8ff24f423ee8db7ba0a72eecafcf53dcb453d79
https://github.com/widop/WidopHttpAdapterBundle/blob/f8ff24f423ee8db7ba0a72eecafcf53dcb453d79/DependencyInjection/WidopHttpAdapterExtension.php#L44-L53
32,455
jmikola/WildcardEventDispatcher
src/Jmikola/WildcardEventDispatcher/ListenerPattern.php
ListenerPattern.bind
public function bind(EventDispatcherInterface $dispatcher, $eventName) { if (isset($this->events[$eventName])) { return; } $dispatcher->addListener($eventName, $this->getListener(), $this->priority); $this->events[$eventName] = true; }
php
public function bind(EventDispatcherInterface $dispatcher, $eventName) { if (isset($this->events[$eventName])) { return; } $dispatcher->addListener($eventName, $this->getListener(), $this->priority); $this->events[$eventName] = true; }
[ "public", "function", "bind", "(", "EventDispatcherInterface", "$", "dispatcher", ",", "$", "eventName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "events", "[", "$", "eventName", "]", ")", ")", "{", "return", ";", "}", "$", "dispatcher", "->", "addListener", "(", "$", "eventName", ",", "$", "this", "->", "getListener", "(", ")", ",", "$", "this", "->", "priority", ")", ";", "$", "this", "->", "events", "[", "$", "eventName", "]", "=", "true", ";", "}" ]
Adds this pattern's listener to an event. @param EventDispatcherInterface $dispatcher @param string $eventName
[ "Adds", "this", "pattern", "s", "listener", "to", "an", "event", "." ]
cc3257181cfc25a025b049348c5f9053e83ec627
https://github.com/jmikola/WildcardEventDispatcher/blob/cc3257181cfc25a025b049348c5f9053e83ec627/src/Jmikola/WildcardEventDispatcher/ListenerPattern.php#L58-L66
32,456
jmikola/WildcardEventDispatcher
src/Jmikola/WildcardEventDispatcher/ListenerPattern.php
ListenerPattern.unbind
public function unbind(EventDispatcherInterface $dispatcher) { foreach ($this->events as $eventName => $_) { $dispatcher->removeListener($eventName, $this->getListener()); } $this->events = array(); }
php
public function unbind(EventDispatcherInterface $dispatcher) { foreach ($this->events as $eventName => $_) { $dispatcher->removeListener($eventName, $this->getListener()); } $this->events = array(); }
[ "public", "function", "unbind", "(", "EventDispatcherInterface", "$", "dispatcher", ")", "{", "foreach", "(", "$", "this", "->", "events", "as", "$", "eventName", "=>", "$", "_", ")", "{", "$", "dispatcher", "->", "removeListener", "(", "$", "eventName", ",", "$", "this", "->", "getListener", "(", ")", ")", ";", "}", "$", "this", "->", "events", "=", "array", "(", ")", ";", "}" ]
Removes this pattern's listener from all events to which it was previously added. @param EventDispatcherInterface $dispatcher
[ "Removes", "this", "pattern", "s", "listener", "from", "all", "events", "to", "which", "it", "was", "previously", "added", "." ]
cc3257181cfc25a025b049348c5f9053e83ec627
https://github.com/jmikola/WildcardEventDispatcher/blob/cc3257181cfc25a025b049348c5f9053e83ec627/src/Jmikola/WildcardEventDispatcher/ListenerPattern.php#L74-L81
32,457
jmikola/WildcardEventDispatcher
src/Jmikola/WildcardEventDispatcher/ListenerPattern.php
ListenerPattern.createRegex
private function createRegex($eventPattern) { $replacements = self::getReplacements(); return sprintf('/^%s$/', preg_replace( array_keys($replacements), array_values($replacements), preg_quote($eventPattern, '/') )); }
php
private function createRegex($eventPattern) { $replacements = self::getReplacements(); return sprintf('/^%s$/', preg_replace( array_keys($replacements), array_values($replacements), preg_quote($eventPattern, '/') )); }
[ "private", "function", "createRegex", "(", "$", "eventPattern", ")", "{", "$", "replacements", "=", "self", "::", "getReplacements", "(", ")", ";", "return", "sprintf", "(", "'/^%s$/'", ",", "preg_replace", "(", "array_keys", "(", "$", "replacements", ")", ",", "array_values", "(", "$", "replacements", ")", ",", "preg_quote", "(", "$", "eventPattern", ",", "'/'", ")", ")", ")", ";", "}" ]
Transforms an event pattern into a regular expression. @param string $eventPattern @return string
[ "Transforms", "an", "event", "pattern", "into", "a", "regular", "expression", "." ]
cc3257181cfc25a025b049348c5f9053e83ec627
https://github.com/jmikola/WildcardEventDispatcher/blob/cc3257181cfc25a025b049348c5f9053e83ec627/src/Jmikola/WildcardEventDispatcher/ListenerPattern.php#L100-L109
32,458
flipboxfactory/craft-ember
src/modules/LoggerTrait.php
LoggerTrait.loggerCategory
protected static function loggerCategory($category): string { /** @noinspection PhpUndefinedFieldInspection */ $prefix = static::$category ?? ''; if (empty($category)) { return $prefix; } return ($prefix ? $prefix . ':' : '') . $category; }
php
protected static function loggerCategory($category): string { /** @noinspection PhpUndefinedFieldInspection */ $prefix = static::$category ?? ''; if (empty($category)) { return $prefix; } return ($prefix ? $prefix . ':' : '') . $category; }
[ "protected", "static", "function", "loggerCategory", "(", "$", "category", ")", ":", "string", "{", "/** @noinspection PhpUndefinedFieldInspection */", "$", "prefix", "=", "static", "::", "$", "category", "??", "''", ";", "if", "(", "empty", "(", "$", "category", ")", ")", "{", "return", "$", "prefix", ";", "}", "return", "(", "$", "prefix", "?", "$", "prefix", ".", "':'", ":", "''", ")", ".", "$", "category", ";", "}" ]
The log categories @param $category @return string
[ "The", "log", "categories" ]
9185b885b404b1cb272a0983023eb7c6c0df61c8
https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/modules/LoggerTrait.php#L66-L76
32,459
flipboxfactory/craft-ember
src/modules/LoggerTrait.php
LoggerTrait.debug
public static function debug($message, $category = 'general') { Craft::getLogger()->log($message, Logger::LEVEL_TRACE, static::loggerCategory($category)); }
php
public static function debug($message, $category = 'general') { Craft::getLogger()->log($message, Logger::LEVEL_TRACE, static::loggerCategory($category)); }
[ "public", "static", "function", "debug", "(", "$", "message", ",", "$", "category", "=", "'general'", ")", "{", "Craft", "::", "getLogger", "(", ")", "->", "log", "(", "$", "message", ",", "Logger", "::", "LEVEL_TRACE", ",", "static", "::", "loggerCategory", "(", "$", "category", ")", ")", ";", "}" ]
Logs a debug message. Trace messages are logged mainly for development purpose to see the execution work flow of some code. This method will only log a message when the application is in debug mode. @param string|array $message the message to be logged. This can be a simple string or a more complex data structure, such as array. @param string $category the category of the message. @since 2.0.14
[ "Logs", "a", "debug", "message", ".", "Trace", "messages", "are", "logged", "mainly", "for", "development", "purpose", "to", "see", "the", "execution", "work", "flow", "of", "some", "code", ".", "This", "method", "will", "only", "log", "a", "message", "when", "the", "application", "is", "in", "debug", "mode", "." ]
9185b885b404b1cb272a0983023eb7c6c0df61c8
https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/modules/LoggerTrait.php#L88-L91
32,460
firebrandhq/silverstripe-hail
src/Tasks/FetchRecurringTask.php
FetchRecurringTask.sendException
public static function sendException($exception) { $emails = Config::inst()->get(self::class, 'Emails'); if ($emails) { $emails = explode(",", $emails); $email = new Email(); $email ->setTo($emails) ->setSubject('SilverStripe Hail module fetch error on ' . SiteConfig::current_site_config()->getTitle() . ' (' . gethostname() . ')') ->setBody("<p>Hi,</p><p>An error occurred while fetching from the Hail API: </p> <p>{$exception->getMessage()}</p><p>Website name: " . SiteConfig::current_site_config()->getTitle() . "</p><p>Website Folder: " . Director::baseFolder() . "</p><p>Server hostname: " . gethostname() . "</p>"); $email->send(); } }
php
public static function sendException($exception) { $emails = Config::inst()->get(self::class, 'Emails'); if ($emails) { $emails = explode(",", $emails); $email = new Email(); $email ->setTo($emails) ->setSubject('SilverStripe Hail module fetch error on ' . SiteConfig::current_site_config()->getTitle() . ' (' . gethostname() . ')') ->setBody("<p>Hi,</p><p>An error occurred while fetching from the Hail API: </p> <p>{$exception->getMessage()}</p><p>Website name: " . SiteConfig::current_site_config()->getTitle() . "</p><p>Website Folder: " . Director::baseFolder() . "</p><p>Server hostname: " . gethostname() . "</p>"); $email->send(); } }
[ "public", "static", "function", "sendException", "(", "$", "exception", ")", "{", "$", "emails", "=", "Config", "::", "inst", "(", ")", "->", "get", "(", "self", "::", "class", ",", "'Emails'", ")", ";", "if", "(", "$", "emails", ")", "{", "$", "emails", "=", "explode", "(", "\",\"", ",", "$", "emails", ")", ";", "$", "email", "=", "new", "Email", "(", ")", ";", "$", "email", "->", "setTo", "(", "$", "emails", ")", "->", "setSubject", "(", "'SilverStripe Hail module fetch error on '", ".", "SiteConfig", "::", "current_site_config", "(", ")", "->", "getTitle", "(", ")", ".", "' ('", ".", "gethostname", "(", ")", ".", "')'", ")", "->", "setBody", "(", "\"<p>Hi,</p><p>An error occurred while fetching from the Hail API: </p> <p>{$exception->getMessage()}</p><p>Website name: \"", ".", "SiteConfig", "::", "current_site_config", "(", ")", "->", "getTitle", "(", ")", ".", "\"</p><p>Website Folder: \"", ".", "Director", "::", "baseFolder", "(", ")", ".", "\"</p><p>Server hostname: \"", ".", "gethostname", "(", ")", ".", "\"</p>\"", ")", ";", "$", "email", "->", "send", "(", ")", ";", "}", "}" ]
Send exception to configured emails @param \Exception $exception
[ "Send", "exception", "to", "configured", "emails" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Tasks/FetchRecurringTask.php#L119-L131
32,461
czim/laravel-processor
src/Contexts/ContextRepositoryTrait.php
ContextRepositoryTrait.repository
public function repository($name, $method, array $parameters = []) { return call_user_func_array( [ $this->getRepository($name), $method ], $parameters ); }
php
public function repository($name, $method, array $parameters = []) { return call_user_func_array( [ $this->getRepository($name), $method ], $parameters ); }
[ "public", "function", "repository", "(", "$", "name", ",", "$", "method", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "return", "call_user_func_array", "(", "[", "$", "this", "->", "getRepository", "(", "$", "name", ")", ",", "$", "method", "]", ",", "$", "parameters", ")", ";", "}" ]
Perform a method on a repository @param string $name @param string $method @param array $parameters @return mixed @throws ContextRepositoryException if repository name not found
[ "Perform", "a", "method", "on", "a", "repository" ]
3d0025cd463653b7a8981ff52cebdafbe978f000
https://github.com/czim/laravel-processor/blob/3d0025cd463653b7a8981ff52cebdafbe978f000/src/Contexts/ContextRepositoryTrait.php#L54-L60
32,462
davidecesarano/Embryo-Http
Embryo/Http/Factory/UploadedFileFactory.php
UploadedFileFactory.createUploadedFile
public function createUploadedFile( StreamInterface $file, int $size = null, int $error = \UPLOAD_ERR_OK, string $clientFilename = null, string $clientMediaType = null ): UploadedFileInterface { if (!$file->isReadable()) { throw new \InvalidArgumentException('Temporany resource must be readable'); } $size = (is_null($size)) ? $file->getSize() : $size; return new UploadedFile($file, $size, $error, $clientFilename, $clientMediaType); }
php
public function createUploadedFile( StreamInterface $file, int $size = null, int $error = \UPLOAD_ERR_OK, string $clientFilename = null, string $clientMediaType = null ): UploadedFileInterface { if (!$file->isReadable()) { throw new \InvalidArgumentException('Temporany resource must be readable'); } $size = (is_null($size)) ? $file->getSize() : $size; return new UploadedFile($file, $size, $error, $clientFilename, $clientMediaType); }
[ "public", "function", "createUploadedFile", "(", "StreamInterface", "$", "file", ",", "int", "$", "size", "=", "null", ",", "int", "$", "error", "=", "\\", "UPLOAD_ERR_OK", ",", "string", "$", "clientFilename", "=", "null", ",", "string", "$", "clientMediaType", "=", "null", ")", ":", "UploadedFileInterface", "{", "if", "(", "!", "$", "file", "->", "isReadable", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Temporany resource must be readable'", ")", ";", "}", "$", "size", "=", "(", "is_null", "(", "$", "size", ")", ")", "?", "$", "file", "->", "getSize", "(", ")", ":", "$", "size", ";", "return", "new", "UploadedFile", "(", "$", "file", ",", "$", "size", ",", "$", "error", ",", "$", "clientFilename", ",", "$", "clientMediaType", ")", ";", "}" ]
Creates a new uploaded file. If a string is used to create the file, a temporary resource will be created with the content of the string. If a size is not provided it will be determined by checking the size of the file. @param StreamInterface $file @param int|null $size @param int $error @param string|null $clientFilename @param string|null $clientMediaType @return UploadedFileInterface @throws InvalidArgumentException
[ "Creates", "a", "new", "uploaded", "file", "." ]
5ff81c07fbff3abed051d710f0837544465887c8
https://github.com/davidecesarano/Embryo-Http/blob/5ff81c07fbff3abed051d710f0837544465887c8/Embryo/Http/Factory/UploadedFileFactory.php#L38-L51
32,463
davidecesarano/Embryo-Http
Embryo/Http/Factory/UploadedFileFactory.php
UploadedFileFactory.createUploadedFileFromServer
public function createUploadedFileFromServer(array $files) { $normalized = []; foreach ($files as $key => $value) { if (!isset($value['error'])) { if (is_array($value)) { $normalized[$key] = $this->createUploadedFileFromServer($value); } continue; } $normalized[$key] = []; if (!is_array($value['error'])) { if ($value['error'] === 4) { $stream = (new StreamFactory)->createStream(''); } else { $stream = (new StreamFactory)->createStreamFromFile($value['tmp_name'], 'r'); } $normalized[$key] = $this->createUploadedFile( $stream, $value['size'], $value['error'], $value['name'], $value['type'] ); } else { $sub = []; foreach ($value['error'] as $id => $error) { $sub[$id]['name'] = $value['name'][$id]; $sub[$id]['type'] = $value['type'][$id]; $sub[$id]['tmp_name'] = $value['tmp_name'][$id]; $sub[$id]['error'] = $value['error'][$id]; $sub[$id]['size'] = $value['size'][$id]; $normalized[$key] = $this->createUploadedFileFromServer($sub); } } } return $normalized; }
php
public function createUploadedFileFromServer(array $files) { $normalized = []; foreach ($files as $key => $value) { if (!isset($value['error'])) { if (is_array($value)) { $normalized[$key] = $this->createUploadedFileFromServer($value); } continue; } $normalized[$key] = []; if (!is_array($value['error'])) { if ($value['error'] === 4) { $stream = (new StreamFactory)->createStream(''); } else { $stream = (new StreamFactory)->createStreamFromFile($value['tmp_name'], 'r'); } $normalized[$key] = $this->createUploadedFile( $stream, $value['size'], $value['error'], $value['name'], $value['type'] ); } else { $sub = []; foreach ($value['error'] as $id => $error) { $sub[$id]['name'] = $value['name'][$id]; $sub[$id]['type'] = $value['type'][$id]; $sub[$id]['tmp_name'] = $value['tmp_name'][$id]; $sub[$id]['error'] = $value['error'][$id]; $sub[$id]['size'] = $value['size'][$id]; $normalized[$key] = $this->createUploadedFileFromServer($sub); } } } return $normalized; }
[ "public", "function", "createUploadedFileFromServer", "(", "array", "$", "files", ")", "{", "$", "normalized", "=", "[", "]", ";", "foreach", "(", "$", "files", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "value", "[", "'error'", "]", ")", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "normalized", "[", "$", "key", "]", "=", "$", "this", "->", "createUploadedFileFromServer", "(", "$", "value", ")", ";", "}", "continue", ";", "}", "$", "normalized", "[", "$", "key", "]", "=", "[", "]", ";", "if", "(", "!", "is_array", "(", "$", "value", "[", "'error'", "]", ")", ")", "{", "if", "(", "$", "value", "[", "'error'", "]", "===", "4", ")", "{", "$", "stream", "=", "(", "new", "StreamFactory", ")", "->", "createStream", "(", "''", ")", ";", "}", "else", "{", "$", "stream", "=", "(", "new", "StreamFactory", ")", "->", "createStreamFromFile", "(", "$", "value", "[", "'tmp_name'", "]", ",", "'r'", ")", ";", "}", "$", "normalized", "[", "$", "key", "]", "=", "$", "this", "->", "createUploadedFile", "(", "$", "stream", ",", "$", "value", "[", "'size'", "]", ",", "$", "value", "[", "'error'", "]", ",", "$", "value", "[", "'name'", "]", ",", "$", "value", "[", "'type'", "]", ")", ";", "}", "else", "{", "$", "sub", "=", "[", "]", ";", "foreach", "(", "$", "value", "[", "'error'", "]", "as", "$", "id", "=>", "$", "error", ")", "{", "$", "sub", "[", "$", "id", "]", "[", "'name'", "]", "=", "$", "value", "[", "'name'", "]", "[", "$", "id", "]", ";", "$", "sub", "[", "$", "id", "]", "[", "'type'", "]", "=", "$", "value", "[", "'type'", "]", "[", "$", "id", "]", ";", "$", "sub", "[", "$", "id", "]", "[", "'tmp_name'", "]", "=", "$", "value", "[", "'tmp_name'", "]", "[", "$", "id", "]", ";", "$", "sub", "[", "$", "id", "]", "[", "'error'", "]", "=", "$", "value", "[", "'error'", "]", "[", "$", "id", "]", ";", "$", "sub", "[", "$", "id", "]", "[", "'size'", "]", "=", "$", "value", "[", "'size'", "]", "[", "$", "id", "]", ";", "$", "normalized", "[", "$", "key", "]", "=", "$", "this", "->", "createUploadedFileFromServer", "(", "$", "sub", ")", ";", "}", "}", "}", "return", "$", "normalized", ";", "}" ]
Creates a new uploaded file from server. @param array $files @return array
[ "Creates", "a", "new", "uploaded", "file", "from", "server", "." ]
5ff81c07fbff3abed051d710f0837544465887c8
https://github.com/davidecesarano/Embryo-Http/blob/5ff81c07fbff3abed051d710f0837544465887c8/Embryo/Http/Factory/UploadedFileFactory.php#L59-L107
32,464
davidecesarano/Embryo-Http
Embryo/Http/Message/Uri.php
Uri.withHost
public function withHost($host) { if(!is_string($host)){ throw new InvalidArgumentException('Uri host must be a string'); } $clone = clone $this; $clone->host = $this->removePortFromHost($host); return $clone; }
php
public function withHost($host) { if(!is_string($host)){ throw new InvalidArgumentException('Uri host must be a string'); } $clone = clone $this; $clone->host = $this->removePortFromHost($host); return $clone; }
[ "public", "function", "withHost", "(", "$", "host", ")", "{", "if", "(", "!", "is_string", "(", "$", "host", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Uri host must be a string'", ")", ";", "}", "$", "clone", "=", "clone", "$", "this", ";", "$", "clone", "->", "host", "=", "$", "this", "->", "removePortFromHost", "(", "$", "host", ")", ";", "return", "$", "clone", ";", "}" ]
Returns an instance with the specified host. @param string $host @return static @throws InvalidArgumentException
[ "Returns", "an", "instance", "with", "the", "specified", "host", "." ]
5ff81c07fbff3abed051d710f0837544465887c8
https://github.com/davidecesarano/Embryo-Http/blob/5ff81c07fbff3abed051d710f0837544465887c8/Embryo/Http/Message/Uri.php#L219-L228
32,465
CradlePHP/cradle-system
src/Schema/Service/SqlService.php
SqlService.remove
public function remove($restorable = true) { //translate model data to sql data if (is_null($this->schema)) { throw Exception::forNoSchema(); } $data = $this->schema->toSql(); //queries to run $queries = []; // check if table is already archived if ($this->exists(sprintf('_%s', $data['name']))) { throw Exception::forSchemaArchiveExists($data['name']); } //if system exists if ($this->exists($data['name'])) { if ($restorable) { $queries[] = 'RENAME TABLE `' . $data['name'] . '` TO `_' . $data['name'] . '`;'; //determine the relation schema foreach ($data['relations'] as $table => $relation) { $queries[] = 'RENAME TABLE `' . $table . '` TO `_' . $table . '`;'; } } else { $queries[] = 'DROP TABLE IF EXISTS `' . $data['name'] . '`;'; $queries[] = 'DROP TABLE IF EXISTS `_' . $data['name'] . '`;'; //determine the relation schema foreach ($data['relations'] as $table => $relation) { $queries[] = 'DROP TABLE IF EXISTS `'. $table . '`;'; $queries[] = 'DROP TABLE IF EXISTS `_'. $table . '`;'; } } } //execute queries $results = []; foreach ($queries as $query) { $results[] = [ 'query' => $query, 'results' => $this->resource->query($query) ]; } return $results; }
php
public function remove($restorable = true) { //translate model data to sql data if (is_null($this->schema)) { throw Exception::forNoSchema(); } $data = $this->schema->toSql(); //queries to run $queries = []; // check if table is already archived if ($this->exists(sprintf('_%s', $data['name']))) { throw Exception::forSchemaArchiveExists($data['name']); } //if system exists if ($this->exists($data['name'])) { if ($restorable) { $queries[] = 'RENAME TABLE `' . $data['name'] . '` TO `_' . $data['name'] . '`;'; //determine the relation schema foreach ($data['relations'] as $table => $relation) { $queries[] = 'RENAME TABLE `' . $table . '` TO `_' . $table . '`;'; } } else { $queries[] = 'DROP TABLE IF EXISTS `' . $data['name'] . '`;'; $queries[] = 'DROP TABLE IF EXISTS `_' . $data['name'] . '`;'; //determine the relation schema foreach ($data['relations'] as $table => $relation) { $queries[] = 'DROP TABLE IF EXISTS `'. $table . '`;'; $queries[] = 'DROP TABLE IF EXISTS `_'. $table . '`;'; } } } //execute queries $results = []; foreach ($queries as $query) { $results[] = [ 'query' => $query, 'results' => $this->resource->query($query) ]; } return $results; }
[ "public", "function", "remove", "(", "$", "restorable", "=", "true", ")", "{", "//translate model data to sql data", "if", "(", "is_null", "(", "$", "this", "->", "schema", ")", ")", "{", "throw", "Exception", "::", "forNoSchema", "(", ")", ";", "}", "$", "data", "=", "$", "this", "->", "schema", "->", "toSql", "(", ")", ";", "//queries to run", "$", "queries", "=", "[", "]", ";", "// check if table is already archived", "if", "(", "$", "this", "->", "exists", "(", "sprintf", "(", "'_%s'", ",", "$", "data", "[", "'name'", "]", ")", ")", ")", "{", "throw", "Exception", "::", "forSchemaArchiveExists", "(", "$", "data", "[", "'name'", "]", ")", ";", "}", "//if system exists", "if", "(", "$", "this", "->", "exists", "(", "$", "data", "[", "'name'", "]", ")", ")", "{", "if", "(", "$", "restorable", ")", "{", "$", "queries", "[", "]", "=", "'RENAME TABLE `'", ".", "$", "data", "[", "'name'", "]", ".", "'` TO `_'", ".", "$", "data", "[", "'name'", "]", ".", "'`;'", ";", "//determine the relation schema", "foreach", "(", "$", "data", "[", "'relations'", "]", "as", "$", "table", "=>", "$", "relation", ")", "{", "$", "queries", "[", "]", "=", "'RENAME TABLE `'", ".", "$", "table", ".", "'` TO `_'", ".", "$", "table", ".", "'`;'", ";", "}", "}", "else", "{", "$", "queries", "[", "]", "=", "'DROP TABLE IF EXISTS `'", ".", "$", "data", "[", "'name'", "]", ".", "'`;'", ";", "$", "queries", "[", "]", "=", "'DROP TABLE IF EXISTS `_'", ".", "$", "data", "[", "'name'", "]", ".", "'`;'", ";", "//determine the relation schema", "foreach", "(", "$", "data", "[", "'relations'", "]", "as", "$", "table", "=>", "$", "relation", ")", "{", "$", "queries", "[", "]", "=", "'DROP TABLE IF EXISTS `'", ".", "$", "table", ".", "'`;'", ";", "$", "queries", "[", "]", "=", "'DROP TABLE IF EXISTS `_'", ".", "$", "table", ".", "'`;'", ";", "}", "}", "}", "//execute queries", "$", "results", "=", "[", "]", ";", "foreach", "(", "$", "queries", "as", "$", "query", ")", "{", "$", "results", "[", "]", "=", "[", "'query'", "=>", "$", "query", ",", "'results'", "=>", "$", "this", "->", "resource", "->", "query", "(", "$", "query", ")", "]", ";", "}", "return", "$", "results", ";", "}" ]
Removes a table @param array $data @return array
[ "Removes", "a", "table" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Schema/Service/SqlService.php#L172-L220
32,466
CradlePHP/cradle-system
src/Schema/Service/SqlService.php
SqlService.restore
public function restore() { //translate model data to sql data if (is_null($this->schema)) { throw Exception::forNoSchema(); } $data = $this->schema->toSql(); //queries to run $queries = []; // check if table is already archived if ($this->exists($data['name'])) { throw Exception::forSchemaAlreadyExists($data['name']); } //if there's no system if (!$this->exists('_' . $data['name'])) { //go to create mode return $this->create($data, true); } $queries[] = 'RENAME TABLE `_' . $data['name'] . '` TO `' . $data['name'] . '`;'; //determine the relation schema foreach ($data['relations'] as $table => $relation) { $queries[] = 'RENAME TABLE `_' . $table . '` TO `' . $table . '`;'; } //execute queries $results = []; foreach ($queries as $query) { $results[] = [ 'query' => $query, 'results' => $this->resource->query($query) ]; } return $results; }
php
public function restore() { //translate model data to sql data if (is_null($this->schema)) { throw Exception::forNoSchema(); } $data = $this->schema->toSql(); //queries to run $queries = []; // check if table is already archived if ($this->exists($data['name'])) { throw Exception::forSchemaAlreadyExists($data['name']); } //if there's no system if (!$this->exists('_' . $data['name'])) { //go to create mode return $this->create($data, true); } $queries[] = 'RENAME TABLE `_' . $data['name'] . '` TO `' . $data['name'] . '`;'; //determine the relation schema foreach ($data['relations'] as $table => $relation) { $queries[] = 'RENAME TABLE `_' . $table . '` TO `' . $table . '`;'; } //execute queries $results = []; foreach ($queries as $query) { $results[] = [ 'query' => $query, 'results' => $this->resource->query($query) ]; } return $results; }
[ "public", "function", "restore", "(", ")", "{", "//translate model data to sql data", "if", "(", "is_null", "(", "$", "this", "->", "schema", ")", ")", "{", "throw", "Exception", "::", "forNoSchema", "(", ")", ";", "}", "$", "data", "=", "$", "this", "->", "schema", "->", "toSql", "(", ")", ";", "//queries to run", "$", "queries", "=", "[", "]", ";", "// check if table is already archived", "if", "(", "$", "this", "->", "exists", "(", "$", "data", "[", "'name'", "]", ")", ")", "{", "throw", "Exception", "::", "forSchemaAlreadyExists", "(", "$", "data", "[", "'name'", "]", ")", ";", "}", "//if there's no system", "if", "(", "!", "$", "this", "->", "exists", "(", "'_'", ".", "$", "data", "[", "'name'", "]", ")", ")", "{", "//go to create mode", "return", "$", "this", "->", "create", "(", "$", "data", ",", "true", ")", ";", "}", "$", "queries", "[", "]", "=", "'RENAME TABLE `_'", ".", "$", "data", "[", "'name'", "]", ".", "'` TO `'", ".", "$", "data", "[", "'name'", "]", ".", "'`;'", ";", "//determine the relation schema", "foreach", "(", "$", "data", "[", "'relations'", "]", "as", "$", "table", "=>", "$", "relation", ")", "{", "$", "queries", "[", "]", "=", "'RENAME TABLE `_'", ".", "$", "table", ".", "'` TO `'", ".", "$", "table", ".", "'`;'", ";", "}", "//execute queries", "$", "results", "=", "[", "]", ";", "foreach", "(", "$", "queries", "as", "$", "query", ")", "{", "$", "results", "[", "]", "=", "[", "'query'", "=>", "$", "query", ",", "'results'", "=>", "$", "this", "->", "resource", "->", "query", "(", "$", "query", ")", "]", ";", "}", "return", "$", "results", ";", "}" ]
Restores a table @param array $data @return array
[ "Restores", "a", "table" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Schema/Service/SqlService.php#L229-L269
32,467
CradlePHP/cradle-system
src/Schema/Service/SqlService.php
SqlService.getSchemaTableRecordCount
public function getSchemaTableRecordCount($schema = null) { // information schema query $query = sprintf( 'SELECT table_name, table_rows FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = "%s"', $schema ); // send query return $this->resource->query($query); }
php
public function getSchemaTableRecordCount($schema = null) { // information schema query $query = sprintf( 'SELECT table_name, table_rows FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = "%s"', $schema ); // send query return $this->resource->query($query); }
[ "public", "function", "getSchemaTableRecordCount", "(", "$", "schema", "=", "null", ")", "{", "// information schema query", "$", "query", "=", "sprintf", "(", "'SELECT table_name, table_rows FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = \"%s\"'", ",", "$", "schema", ")", ";", "// send query", "return", "$", "this", "->", "resource", "->", "query", "(", "$", "query", ")", ";", "}" ]
Returns all the table record count @return array
[ "Returns", "all", "the", "table", "record", "count" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Schema/Service/SqlService.php#L484-L494
32,468
flipboxfactory/craft-ember
src/queries/CacheableQuery.php
CacheableQuery.nth
public function nth(int $n, Connection $db = null) { // Cached? if (($cachedResult = $this->getCachedResult()) !== null) { return $cachedResult[$n] ?? false; } return parent::nth($n, $db); }
php
public function nth(int $n, Connection $db = null) { // Cached? if (($cachedResult = $this->getCachedResult()) !== null) { return $cachedResult[$n] ?? false; } return parent::nth($n, $db); }
[ "public", "function", "nth", "(", "int", "$", "n", ",", "Connection", "$", "db", "=", "null", ")", "{", "// Cached?", "if", "(", "(", "$", "cachedResult", "=", "$", "this", "->", "getCachedResult", "(", ")", ")", "!==", "null", ")", "{", "return", "$", "cachedResult", "[", "$", "n", "]", "??", "false", ";", "}", "return", "parent", "::", "nth", "(", "$", "n", ",", "$", "db", ")", ";", "}" ]
Executes the query and returns a single row of result at a given offset. @param int $n The offset of the row to return. If [[offset]] is set, $offset will be added to it. @param Connection|null $db The database connection used to generate the SQL statement. If this parameter is not given, the `db` application component will be used. @return array|bool The object or row of the query result. False is returned if the query results in nothing.
[ "Executes", "the", "query", "and", "returns", "a", "single", "row", "of", "result", "at", "a", "given", "offset", "." ]
9185b885b404b1cb272a0983023eb7c6c0df61c8
https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/queries/CacheableQuery.php#L81-L89
32,469
flipboxfactory/craft-ember
src/records/FieldLayoutAttributeTrait.php
FieldLayoutAttributeTrait.getFieldLayoutId
public function getFieldLayoutId() { $fieldLayoutId = $this->getAttribute('fieldLayoutId'); if (null === $fieldLayoutId && null !== $this->fieldLayout) { $fieldLayoutId = $this->fieldLayoutId = $this->fieldLayout->id; } return $fieldLayoutId; }
php
public function getFieldLayoutId() { $fieldLayoutId = $this->getAttribute('fieldLayoutId'); if (null === $fieldLayoutId && null !== $this->fieldLayout) { $fieldLayoutId = $this->fieldLayoutId = $this->fieldLayout->id; } return $fieldLayoutId; }
[ "public", "function", "getFieldLayoutId", "(", ")", "{", "$", "fieldLayoutId", "=", "$", "this", "->", "getAttribute", "(", "'fieldLayoutId'", ")", ";", "if", "(", "null", "===", "$", "fieldLayoutId", "&&", "null", "!==", "$", "this", "->", "fieldLayout", ")", "{", "$", "fieldLayoutId", "=", "$", "this", "->", "fieldLayoutId", "=", "$", "this", "->", "fieldLayout", "->", "id", ";", "}", "return", "$", "fieldLayoutId", ";", "}" ]
Get associated fieldLayoutId @return int|null
[ "Get", "associated", "fieldLayoutId" ]
9185b885b404b1cb272a0983023eb7c6c0df61c8
https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/records/FieldLayoutAttributeTrait.php#L53-L61
32,470
CradlePHP/cradle-system
src/Model/Service/ElasticService.php
ElasticService.create
public function create($id) { $exists = false; try { // check if index exist $exists = $this->resource->indices()->exists(['index' => $this->schema->getName()]); } catch (\Throwable $e) { // return false if something went wrong return false; } // if index doesnt exist if (!$exists) { // do nothing return false; } // set schema to sql $this->sql->setSchema($this->schema); // get data from sql $body = $this->sql->get($this->schema->getPrimaryFieldName(), $id); if (!is_array($body) || empty($body)) { return false; } try { return $this->resource->index([ 'index' => $this->schema->getName(), 'type' => static::INDEX_TYPE, 'id' => $id, 'body' => $body ]); } catch (NoNodesAvailableException $e) { return false; } catch (BadRequest400Exception $e) { return false; } catch (\Throwable $e) { // catch all throwable // if something went wrong, dont panic, just return false return false; } }
php
public function create($id) { $exists = false; try { // check if index exist $exists = $this->resource->indices()->exists(['index' => $this->schema->getName()]); } catch (\Throwable $e) { // return false if something went wrong return false; } // if index doesnt exist if (!$exists) { // do nothing return false; } // set schema to sql $this->sql->setSchema($this->schema); // get data from sql $body = $this->sql->get($this->schema->getPrimaryFieldName(), $id); if (!is_array($body) || empty($body)) { return false; } try { return $this->resource->index([ 'index' => $this->schema->getName(), 'type' => static::INDEX_TYPE, 'id' => $id, 'body' => $body ]); } catch (NoNodesAvailableException $e) { return false; } catch (BadRequest400Exception $e) { return false; } catch (\Throwable $e) { // catch all throwable // if something went wrong, dont panic, just return false return false; } }
[ "public", "function", "create", "(", "$", "id", ")", "{", "$", "exists", "=", "false", ";", "try", "{", "// check if index exist", "$", "exists", "=", "$", "this", "->", "resource", "->", "indices", "(", ")", "->", "exists", "(", "[", "'index'", "=>", "$", "this", "->", "schema", "->", "getName", "(", ")", "]", ")", ";", "}", "catch", "(", "\\", "Throwable", "$", "e", ")", "{", "// return false if something went wrong", "return", "false", ";", "}", "// if index doesnt exist", "if", "(", "!", "$", "exists", ")", "{", "// do nothing", "return", "false", ";", "}", "// set schema to sql", "$", "this", "->", "sql", "->", "setSchema", "(", "$", "this", "->", "schema", ")", ";", "// get data from sql", "$", "body", "=", "$", "this", "->", "sql", "->", "get", "(", "$", "this", "->", "schema", "->", "getPrimaryFieldName", "(", ")", ",", "$", "id", ")", ";", "if", "(", "!", "is_array", "(", "$", "body", ")", "||", "empty", "(", "$", "body", ")", ")", "{", "return", "false", ";", "}", "try", "{", "return", "$", "this", "->", "resource", "->", "index", "(", "[", "'index'", "=>", "$", "this", "->", "schema", "->", "getName", "(", ")", ",", "'type'", "=>", "static", "::", "INDEX_TYPE", ",", "'id'", "=>", "$", "id", ",", "'body'", "=>", "$", "body", "]", ")", ";", "}", "catch", "(", "NoNodesAvailableException", "$", "e", ")", "{", "return", "false", ";", "}", "catch", "(", "BadRequest400Exception", "$", "e", ")", "{", "return", "false", ";", "}", "catch", "(", "\\", "Throwable", "$", "e", ")", "{", "// catch all throwable", "// if something went wrong, dont panic, just return false", "return", "false", ";", "}", "}" ]
Create in index @param *int $id @return array
[ "Create", "in", "index" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Model/Service/ElasticService.php#L59-L101
32,471
CradlePHP/cradle-system
src/Model/Service/ElasticService.php
ElasticService.remove
public function remove($id) { try { return $this->resource->delete([ 'index' => $this->schema->getName(), 'type' => static::INDEX_TYPE, 'id' => $id ]); } catch (NoNodesAvailableException $e) { return false; } }
php
public function remove($id) { try { return $this->resource->delete([ 'index' => $this->schema->getName(), 'type' => static::INDEX_TYPE, 'id' => $id ]); } catch (NoNodesAvailableException $e) { return false; } }
[ "public", "function", "remove", "(", "$", "id", ")", "{", "try", "{", "return", "$", "this", "->", "resource", "->", "delete", "(", "[", "'index'", "=>", "$", "this", "->", "schema", "->", "getName", "(", ")", ",", "'type'", "=>", "static", "::", "INDEX_TYPE", ",", "'id'", "=>", "$", "id", "]", ")", ";", "}", "catch", "(", "NoNodesAvailableException", "$", "e", ")", "{", "return", "false", ";", "}", "}" ]
Remove from index @param *int $id
[ "Remove", "from", "index" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Model/Service/ElasticService.php#L245-L256
32,472
CradlePHP/cradle-system
src/Model/Service/ElasticService.php
ElasticService.update
public function update($id) { // set schema to sql $this->sql->setSchema($this->schema); // get data from sql $body = $this->sql->get($this->schema->getPrimaryFieldName(), $id); if (!is_array($body) || empty($body)) { return false; } try { return $this->resource->update( [ 'index' => $this->schema->getName(), 'type' => static::INDEX_TYPE, 'id' => $id, 'body' => [ 'doc' => $body ] ] ); } catch (Missing404Exception $e) { return false; } catch (NoNodesAvailableException $e) { return false; } catch (\Throwable $e) { // catch all throwable // if something went wrong, dont panic, just return false return false; } }
php
public function update($id) { // set schema to sql $this->sql->setSchema($this->schema); // get data from sql $body = $this->sql->get($this->schema->getPrimaryFieldName(), $id); if (!is_array($body) || empty($body)) { return false; } try { return $this->resource->update( [ 'index' => $this->schema->getName(), 'type' => static::INDEX_TYPE, 'id' => $id, 'body' => [ 'doc' => $body ] ] ); } catch (Missing404Exception $e) { return false; } catch (NoNodesAvailableException $e) { return false; } catch (\Throwable $e) { // catch all throwable // if something went wrong, dont panic, just return false return false; } }
[ "public", "function", "update", "(", "$", "id", ")", "{", "// set schema to sql", "$", "this", "->", "sql", "->", "setSchema", "(", "$", "this", "->", "schema", ")", ";", "// get data from sql", "$", "body", "=", "$", "this", "->", "sql", "->", "get", "(", "$", "this", "->", "schema", "->", "getPrimaryFieldName", "(", ")", ",", "$", "id", ")", ";", "if", "(", "!", "is_array", "(", "$", "body", ")", "||", "empty", "(", "$", "body", ")", ")", "{", "return", "false", ";", "}", "try", "{", "return", "$", "this", "->", "resource", "->", "update", "(", "[", "'index'", "=>", "$", "this", "->", "schema", "->", "getName", "(", ")", ",", "'type'", "=>", "static", "::", "INDEX_TYPE", ",", "'id'", "=>", "$", "id", ",", "'body'", "=>", "[", "'doc'", "=>", "$", "body", "]", "]", ")", ";", "}", "catch", "(", "Missing404Exception", "$", "e", ")", "{", "return", "false", ";", "}", "catch", "(", "NoNodesAvailableException", "$", "e", ")", "{", "return", "false", ";", "}", "catch", "(", "\\", "Throwable", "$", "e", ")", "{", "// catch all throwable", "// if something went wrong, dont panic, just return false", "return", "false", ";", "}", "}" ]
Update to index @param *int $id @return array
[ "Update", "to", "index" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Model/Service/ElasticService.php#L265-L296
32,473
firebrandhq/silverstripe-hail
src/Models/ApiObject.php
ApiObject.isOutdated
public function isOutdated() { if ($this->Fetched) { $fetched = new \DateTime($this->Fetched); $now = new \DateTime("now"); $diff = $now->getTimestamp() - $fetched->getTimestamp(); if ($diff > Client::getRefreshRate()) { return true; } return false; } return true; }
php
public function isOutdated() { if ($this->Fetched) { $fetched = new \DateTime($this->Fetched); $now = new \DateTime("now"); $diff = $now->getTimestamp() - $fetched->getTimestamp(); if ($diff > Client::getRefreshRate()) { return true; } return false; } return true; }
[ "public", "function", "isOutdated", "(", ")", "{", "if", "(", "$", "this", "->", "Fetched", ")", "{", "$", "fetched", "=", "new", "\\", "DateTime", "(", "$", "this", "->", "Fetched", ")", ";", "$", "now", "=", "new", "\\", "DateTime", "(", "\"now\"", ")", ";", "$", "diff", "=", "$", "now", "->", "getTimestamp", "(", ")", "-", "$", "fetched", "->", "getTimestamp", "(", ")", ";", "if", "(", "$", "diff", ">", "Client", "::", "getRefreshRate", "(", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", "return", "true", ";", "}" ]
Determines if the object is outdated @return boolean
[ "Determines", "if", "the", "object", "is", "outdated" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Models/ApiObject.php#L116-L129
32,474
firebrandhq/silverstripe-hail
src/Models/ApiObject.php
ApiObject.refresh
public function refresh() { if ($this->ID && $this->HailID) { try { $api_client = new Client(); $data = $api_client->getOne($this); } catch (\Exception $ex) { return $this; } if (count($data) > 0) { $this->importHailData($data); } } return $this; }
php
public function refresh() { if ($this->ID && $this->HailID) { try { $api_client = new Client(); $data = $api_client->getOne($this); } catch (\Exception $ex) { return $this; } if (count($data) > 0) { $this->importHailData($data); } } return $this; }
[ "public", "function", "refresh", "(", ")", "{", "if", "(", "$", "this", "->", "ID", "&&", "$", "this", "->", "HailID", ")", "{", "try", "{", "$", "api_client", "=", "new", "Client", "(", ")", ";", "$", "data", "=", "$", "api_client", "->", "getOne", "(", "$", "this", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "ex", ")", "{", "return", "$", "this", ";", "}", "if", "(", "count", "(", "$", "data", ")", ">", "0", ")", "{", "$", "this", "->", "importHailData", "(", "$", "data", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Retrieves the latest version of this object from the Hail API @return ApiObject
[ "Retrieves", "the", "latest", "version", "of", "this", "object", "from", "the", "Hail", "API" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Models/ApiObject.php#L147-L162
32,475
firebrandhq/silverstripe-hail
src/Models/ApiObject.php
ApiObject.importHailData
protected function importHailData($data) { if ($this->excluded($data)) { return false; } $dataMap = array_merge( ['HailID' => 'id'], static::$api_map ); foreach ($dataMap as $ssKey => $hailKey) { $value = (isset($data[$hailKey]) && !empty($data[$hailKey])) ? $data[$hailKey] : ''; //Remove all NON UTF8 if Emoji support is disabled if (!Config::inst()->get(Client::class, 'EnableEmojiSupport')) { $value = preg_replace('/[^(\x20-\x7F)]*/', '', $value); } $this->{$ssKey} = html_entity_decode($value); } $this->Fetched = date("Y-m-d H:i:s"); $this->write(); $this->importing($data); $this->write(); return true; }
php
protected function importHailData($data) { if ($this->excluded($data)) { return false; } $dataMap = array_merge( ['HailID' => 'id'], static::$api_map ); foreach ($dataMap as $ssKey => $hailKey) { $value = (isset($data[$hailKey]) && !empty($data[$hailKey])) ? $data[$hailKey] : ''; //Remove all NON UTF8 if Emoji support is disabled if (!Config::inst()->get(Client::class, 'EnableEmojiSupport')) { $value = preg_replace('/[^(\x20-\x7F)]*/', '', $value); } $this->{$ssKey} = html_entity_decode($value); } $this->Fetched = date("Y-m-d H:i:s"); $this->write(); $this->importing($data); $this->write(); return true; }
[ "protected", "function", "importHailData", "(", "$", "data", ")", "{", "if", "(", "$", "this", "->", "excluded", "(", "$", "data", ")", ")", "{", "return", "false", ";", "}", "$", "dataMap", "=", "array_merge", "(", "[", "'HailID'", "=>", "'id'", "]", ",", "static", "::", "$", "api_map", ")", ";", "foreach", "(", "$", "dataMap", "as", "$", "ssKey", "=>", "$", "hailKey", ")", "{", "$", "value", "=", "(", "isset", "(", "$", "data", "[", "$", "hailKey", "]", ")", "&&", "!", "empty", "(", "$", "data", "[", "$", "hailKey", "]", ")", ")", "?", "$", "data", "[", "$", "hailKey", "]", ":", "''", ";", "//Remove all NON UTF8 if Emoji support is disabled", "if", "(", "!", "Config", "::", "inst", "(", ")", "->", "get", "(", "Client", "::", "class", ",", "'EnableEmojiSupport'", ")", ")", "{", "$", "value", "=", "preg_replace", "(", "'/[^(\\x20-\\x7F)]*/'", ",", "''", ",", "$", "value", ")", ";", "}", "$", "this", "->", "{", "$", "ssKey", "}", "=", "html_entity_decode", "(", "$", "value", ")", ";", "}", "$", "this", "->", "Fetched", "=", "date", "(", "\"Y-m-d H:i:s\"", ")", ";", "$", "this", "->", "write", "(", ")", ";", "$", "this", "->", "importing", "(", "$", "data", ")", ";", "$", "this", "->", "write", "(", ")", ";", "return", "true", ";", "}" ]
Process the json data from Hail API and writes to SS db Return true if the value should be saved to the database. False if it has been excluded. @param array $data JSON data from Hail @return boolean @throws
[ "Process", "the", "json", "data", "from", "Hail", "API", "and", "writes", "to", "SS", "db" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Models/ApiObject.php#L173-L202
32,476
firebrandhq/silverstripe-hail
src/Models/ApiObject.php
ApiObject.fetchAll
public static function fetchAll() { //Hail Api Client $hail_api_client = new Client(); $config = SiteConfig::current_site_config(); $orgs_ids = json_decode($config->HailOrgsIDs); if (!$orgs_ids) { //No organisations configured $hail_api_client->handleException(new \Exception("You need at least 1 Hail Organisation configured to be able to fetch")); return false; } //Fetch objects for all configured Hail organisations foreach ($orgs_ids as $org_id) { self::fetchForOrg($hail_api_client, $org_id); } }
php
public static function fetchAll() { //Hail Api Client $hail_api_client = new Client(); $config = SiteConfig::current_site_config(); $orgs_ids = json_decode($config->HailOrgsIDs); if (!$orgs_ids) { //No organisations configured $hail_api_client->handleException(new \Exception("You need at least 1 Hail Organisation configured to be able to fetch")); return false; } //Fetch objects for all configured Hail organisations foreach ($orgs_ids as $org_id) { self::fetchForOrg($hail_api_client, $org_id); } }
[ "public", "static", "function", "fetchAll", "(", ")", "{", "//Hail Api Client", "$", "hail_api_client", "=", "new", "Client", "(", ")", ";", "$", "config", "=", "SiteConfig", "::", "current_site_config", "(", ")", ";", "$", "orgs_ids", "=", "json_decode", "(", "$", "config", "->", "HailOrgsIDs", ")", ";", "if", "(", "!", "$", "orgs_ids", ")", "{", "//No organisations configured", "$", "hail_api_client", "->", "handleException", "(", "new", "\\", "Exception", "(", "\"You need at least 1 Hail Organisation configured to be able to fetch\"", ")", ")", ";", "return", "false", ";", "}", "//Fetch objects for all configured Hail organisations", "foreach", "(", "$", "orgs_ids", "as", "$", "org_id", ")", "{", "self", "::", "fetchForOrg", "(", "$", "hail_api_client", ",", "$", "org_id", ")", ";", "}", "}" ]
Fetch from Hail API for all configured organisations @throws
[ "Fetch", "from", "Hail", "API", "for", "all", "configured", "organisations" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Models/ApiObject.php#L355-L372
32,477
firebrandhq/silverstripe-hail
src/Models/ApiObject.php
ApiObject.makeRecordViewer
protected function makeRecordViewer($fields, $name, $relation, $viewComponent = 'Firebrand\Hail\Forms\GridFieldViewButton') { $config = GridFieldConfig_RecordViewer::create(); // Remove the standard GridFieldView button and replace it with our // custom button that will link to our the right action in our HailModelAdmin $config->removeComponentsByType('SilverStripe\Forms\GridField\GridFieldViewButton'); $config->addComponents(new $viewComponent()); //Relation tab names don't have spaces in SS4 $tab_name = str_replace(" ", "", $name); $grid = new GridFieldForReadonly($tab_name, $name, $relation, $config); $fields->addFieldToTab('Root.' . $tab_name, $grid); }
php
protected function makeRecordViewer($fields, $name, $relation, $viewComponent = 'Firebrand\Hail\Forms\GridFieldViewButton') { $config = GridFieldConfig_RecordViewer::create(); // Remove the standard GridFieldView button and replace it with our // custom button that will link to our the right action in our HailModelAdmin $config->removeComponentsByType('SilverStripe\Forms\GridField\GridFieldViewButton'); $config->addComponents(new $viewComponent()); //Relation tab names don't have spaces in SS4 $tab_name = str_replace(" ", "", $name); $grid = new GridFieldForReadonly($tab_name, $name, $relation, $config); $fields->addFieldToTab('Root.' . $tab_name, $grid); }
[ "protected", "function", "makeRecordViewer", "(", "$", "fields", ",", "$", "name", ",", "$", "relation", ",", "$", "viewComponent", "=", "'Firebrand\\Hail\\Forms\\GridFieldViewButton'", ")", "{", "$", "config", "=", "GridFieldConfig_RecordViewer", "::", "create", "(", ")", ";", "// Remove the standard GridFieldView button and replace it with our", "// custom button that will link to our the right action in our HailModelAdmin", "$", "config", "->", "removeComponentsByType", "(", "'SilverStripe\\Forms\\GridField\\GridFieldViewButton'", ")", ";", "$", "config", "->", "addComponents", "(", "new", "$", "viewComponent", "(", ")", ")", ";", "//Relation tab names don't have spaces in SS4", "$", "tab_name", "=", "str_replace", "(", "\" \"", ",", "\"\"", ",", "$", "name", ")", ";", "$", "grid", "=", "new", "GridFieldForReadonly", "(", "$", "tab_name", ",", "$", "name", ",", "$", "relation", ",", "$", "config", ")", ";", "$", "fields", "->", "addFieldToTab", "(", "'Root.'", ".", "$", "tab_name", ",", "$", "grid", ")", ";", "}" ]
Helper function to add a ReadOnly gridfield for a relation @param FieldList $fields @param string $name Name that should be given to the GridField @param ManyManyList $relation Relation to display @param string $viewComponent Full class name of the view Component to add (button)
[ "Helper", "function", "to", "add", "a", "ReadOnly", "gridfield", "for", "a", "relation" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Models/ApiObject.php#L421-L434
32,478
firebrandhq/silverstripe-hail
src/Models/ApiObject.php
ApiObject.processPublicTags
protected function processPublicTags($data) { $tagIdList = []; // Clean tags before importing the new ones // but have not been returned this time around $this->PublicTags()->removeAll(); foreach ($data as $tagData) { $tagIdList[] = $tagData['id']; // Find a matching HailTag or create an new one $tag = PublicTag::get()->filter(['HailID' => $tagData['id']])->first(); if (!$tag) { $tag = new PublicTag(); } $tag->OrganisationID = $this->OrganisationID; $tag->HailOrgID = $this->HailOrgID; $tag->HailOrgName = $this->HailOrgName; // Update the PublicTags $tag->importHailData($tagData); if (!$this->PublicTags()->byID($tag->ID)) { $this->PublicTags()->add($tag); } } }
php
protected function processPublicTags($data) { $tagIdList = []; // Clean tags before importing the new ones // but have not been returned this time around $this->PublicTags()->removeAll(); foreach ($data as $tagData) { $tagIdList[] = $tagData['id']; // Find a matching HailTag or create an new one $tag = PublicTag::get()->filter(['HailID' => $tagData['id']])->first(); if (!$tag) { $tag = new PublicTag(); } $tag->OrganisationID = $this->OrganisationID; $tag->HailOrgID = $this->HailOrgID; $tag->HailOrgName = $this->HailOrgName; // Update the PublicTags $tag->importHailData($tagData); if (!$this->PublicTags()->byID($tag->ID)) { $this->PublicTags()->add($tag); } } }
[ "protected", "function", "processPublicTags", "(", "$", "data", ")", "{", "$", "tagIdList", "=", "[", "]", ";", "// Clean tags before importing the new ones", "// but have not been returned this time around", "$", "this", "->", "PublicTags", "(", ")", "->", "removeAll", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "tagData", ")", "{", "$", "tagIdList", "[", "]", "=", "$", "tagData", "[", "'id'", "]", ";", "// Find a matching HailTag or create an new one", "$", "tag", "=", "PublicTag", "::", "get", "(", ")", "->", "filter", "(", "[", "'HailID'", "=>", "$", "tagData", "[", "'id'", "]", "]", ")", "->", "first", "(", ")", ";", "if", "(", "!", "$", "tag", ")", "{", "$", "tag", "=", "new", "PublicTag", "(", ")", ";", "}", "$", "tag", "->", "OrganisationID", "=", "$", "this", "->", "OrganisationID", ";", "$", "tag", "->", "HailOrgID", "=", "$", "this", "->", "HailOrgID", ";", "$", "tag", "->", "HailOrgName", "=", "$", "this", "->", "HailOrgName", ";", "// Update the PublicTags", "$", "tag", "->", "importHailData", "(", "$", "tagData", ")", ";", "if", "(", "!", "$", "this", "->", "PublicTags", "(", ")", "->", "byID", "(", "$", "tag", "->", "ID", ")", ")", "{", "$", "this", "->", "PublicTags", "(", ")", "->", "add", "(", "$", "tag", ")", ";", "}", "}", "}" ]
Go through the list of public tags and assign them to this object. @param array $data JSON data from Hail
[ "Go", "through", "the", "list", "of", "public", "tags", "and", "assign", "them", "to", "this", "object", "." ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Models/ApiObject.php#L441-L468
32,479
firebrandhq/silverstripe-hail
src/Models/ApiObject.php
ApiObject.processPrivateTags
protected function processPrivateTags($data) { $tagIdList = []; $this->PrivateTags()->removeAll(); foreach ($data as $tagData) { $tagIdList[] = $tagData['id']; // Find a matching PrivateTag or create an new one $tag = PrivateTag::get()->filter(['HailID' => $tagData['id']])->first(); if (!$tag) { $tag = new PrivateTag(); } $tag->OrganisationID = $this->OrganisationID; $tag->HailOrgID = $this->HailOrgID; $tag->HailOrgName = $this->HailOrgName; // Update the Hail Tag $tag->importHailData($tagData); if (!$this->PrivateTags()->byID($tag->ID)) { $this->PrivateTags()->add($tag); } } }
php
protected function processPrivateTags($data) { $tagIdList = []; $this->PrivateTags()->removeAll(); foreach ($data as $tagData) { $tagIdList[] = $tagData['id']; // Find a matching PrivateTag or create an new one $tag = PrivateTag::get()->filter(['HailID' => $tagData['id']])->first(); if (!$tag) { $tag = new PrivateTag(); } $tag->OrganisationID = $this->OrganisationID; $tag->HailOrgID = $this->HailOrgID; $tag->HailOrgName = $this->HailOrgName; // Update the Hail Tag $tag->importHailData($tagData); if (!$this->PrivateTags()->byID($tag->ID)) { $this->PrivateTags()->add($tag); } } }
[ "protected", "function", "processPrivateTags", "(", "$", "data", ")", "{", "$", "tagIdList", "=", "[", "]", ";", "$", "this", "->", "PrivateTags", "(", ")", "->", "removeAll", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "tagData", ")", "{", "$", "tagIdList", "[", "]", "=", "$", "tagData", "[", "'id'", "]", ";", "// Find a matching PrivateTag or create an new one", "$", "tag", "=", "PrivateTag", "::", "get", "(", ")", "->", "filter", "(", "[", "'HailID'", "=>", "$", "tagData", "[", "'id'", "]", "]", ")", "->", "first", "(", ")", ";", "if", "(", "!", "$", "tag", ")", "{", "$", "tag", "=", "new", "PrivateTag", "(", ")", ";", "}", "$", "tag", "->", "OrganisationID", "=", "$", "this", "->", "OrganisationID", ";", "$", "tag", "->", "HailOrgID", "=", "$", "this", "->", "HailOrgID", ";", "$", "tag", "->", "HailOrgName", "=", "$", "this", "->", "HailOrgName", ";", "// Update the Hail Tag", "$", "tag", "->", "importHailData", "(", "$", "tagData", ")", ";", "if", "(", "!", "$", "this", "->", "PrivateTags", "(", ")", "->", "byID", "(", "$", "tag", "->", "ID", ")", ")", "{", "$", "this", "->", "PrivateTags", "(", ")", "->", "add", "(", "$", "tag", ")", ";", "}", "}", "}" ]
Go through the list of private tags and assign them to this object. @param array $data JSON data from Hail
[ "Go", "through", "the", "list", "of", "private", "tags", "and", "assign", "them", "to", "this", "object", "." ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Models/ApiObject.php#L475-L499
32,480
firebrandhq/silverstripe-hail
src/Models/ApiObject.php
ApiObject.processHeroImage
protected function processHeroImage($heroImgData) { if ($heroImgData) { $hero = Image::get()->filter(['HailID' => $heroImgData['id']])->first(); if (!$hero) { $hero = new Image(); } $hero->OrganisationID = $this->OrganisationID; $hero->HailOrgID = $this->HailOrgID; $hero->HailOrgName = $this->HailOrgName; $hero->importHailData($heroImgData); $hero = $hero->ID; } else { $hero = null; } $this->HeroImageID = $hero; }
php
protected function processHeroImage($heroImgData) { if ($heroImgData) { $hero = Image::get()->filter(['HailID' => $heroImgData['id']])->first(); if (!$hero) { $hero = new Image(); } $hero->OrganisationID = $this->OrganisationID; $hero->HailOrgID = $this->HailOrgID; $hero->HailOrgName = $this->HailOrgName; $hero->importHailData($heroImgData); $hero = $hero->ID; } else { $hero = null; } $this->HeroImageID = $hero; }
[ "protected", "function", "processHeroImage", "(", "$", "heroImgData", ")", "{", "if", "(", "$", "heroImgData", ")", "{", "$", "hero", "=", "Image", "::", "get", "(", ")", "->", "filter", "(", "[", "'HailID'", "=>", "$", "heroImgData", "[", "'id'", "]", "]", ")", "->", "first", "(", ")", ";", "if", "(", "!", "$", "hero", ")", "{", "$", "hero", "=", "new", "Image", "(", ")", ";", "}", "$", "hero", "->", "OrganisationID", "=", "$", "this", "->", "OrganisationID", ";", "$", "hero", "->", "HailOrgID", "=", "$", "this", "->", "HailOrgID", ";", "$", "hero", "->", "HailOrgName", "=", "$", "this", "->", "HailOrgName", ";", "$", "hero", "->", "importHailData", "(", "$", "heroImgData", ")", ";", "$", "hero", "=", "$", "hero", "->", "ID", ";", "}", "else", "{", "$", "hero", "=", "null", ";", "}", "$", "this", "->", "HeroImageID", "=", "$", "hero", ";", "}" ]
Match the hero image if there's one and assign it to this object @param array $heroImgData JSON data from Hail
[ "Match", "the", "hero", "image", "if", "there", "s", "one", "and", "assign", "it", "to", "this", "object" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Models/ApiObject.php#L506-L524
32,481
firebrandhq/silverstripe-hail
src/Models/ApiObject.php
ApiObject.processHeroVideo
protected function processHeroVideo($heroVidData) { if ($heroVidData) { $hero = Video::get()->filter(['HailID' => $heroVidData['id']])->first(); if (!$hero) { $hero = new Video(); } $hero->OrganisationID = $this->OrganisationID; $hero->HailOrgID = $this->HailOrgID; $hero->HailOrgName = $this->HailOrgName; $hero->importHailData($heroVidData); $hero = $hero->ID; } else { $hero = null; } $this->HeroVideoID = $hero; }
php
protected function processHeroVideo($heroVidData) { if ($heroVidData) { $hero = Video::get()->filter(['HailID' => $heroVidData['id']])->first(); if (!$hero) { $hero = new Video(); } $hero->OrganisationID = $this->OrganisationID; $hero->HailOrgID = $this->HailOrgID; $hero->HailOrgName = $this->HailOrgName; $hero->importHailData($heroVidData); $hero = $hero->ID; } else { $hero = null; } $this->HeroVideoID = $hero; }
[ "protected", "function", "processHeroVideo", "(", "$", "heroVidData", ")", "{", "if", "(", "$", "heroVidData", ")", "{", "$", "hero", "=", "Video", "::", "get", "(", ")", "->", "filter", "(", "[", "'HailID'", "=>", "$", "heroVidData", "[", "'id'", "]", "]", ")", "->", "first", "(", ")", ";", "if", "(", "!", "$", "hero", ")", "{", "$", "hero", "=", "new", "Video", "(", ")", ";", "}", "$", "hero", "->", "OrganisationID", "=", "$", "this", "->", "OrganisationID", ";", "$", "hero", "->", "HailOrgID", "=", "$", "this", "->", "HailOrgID", ";", "$", "hero", "->", "HailOrgName", "=", "$", "this", "->", "HailOrgName", ";", "$", "hero", "->", "importHailData", "(", "$", "heroVidData", ")", ";", "$", "hero", "=", "$", "hero", "->", "ID", ";", "}", "else", "{", "$", "hero", "=", "null", ";", "}", "$", "this", "->", "HeroVideoID", "=", "$", "hero", ";", "}" ]
Match the hero video if there's one and assign it to this object @param array $heroVidData JSON data from Hail
[ "Match", "the", "hero", "video", "if", "there", "s", "one", "and", "assign", "it", "to", "this", "object" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Models/ApiObject.php#L531-L549
32,482
firebrandhq/silverstripe-hail
src/Models/ApiObject.php
ApiObject.processAttachments
protected function processAttachments($data) { $idList = []; foreach ($data as $attachmentData) { $idList[] = $attachmentData['id']; // Find a matching attachment or create it $attachment = Attachment::get()->filter(['HailID' => $attachmentData['id']])->first(); if (!$attachment) { $attachment = new Attachment(); } $attachment->OrganisationID = $this->OrganisationID; $attachment->HailOrgID = $this->HailOrgID; $attachment->HailOrgName = $this->HailOrgName; // Update the Hail Attachments $attachment->importHailData($attachmentData); if (!$this->Attachments()->byID($attachment->ID)) { $this->Attachments()->add($attachment); } } // Remove old attachments that are currently assigned to this article, // but have not been returned this time around if ($idList) { $this->Attachments()->exclude('HailID', $idList)->removeAll(); } else { // If there's no attachements, just remove everything. $this->Attachments()->removeAll(); } }
php
protected function processAttachments($data) { $idList = []; foreach ($data as $attachmentData) { $idList[] = $attachmentData['id']; // Find a matching attachment or create it $attachment = Attachment::get()->filter(['HailID' => $attachmentData['id']])->first(); if (!$attachment) { $attachment = new Attachment(); } $attachment->OrganisationID = $this->OrganisationID; $attachment->HailOrgID = $this->HailOrgID; $attachment->HailOrgName = $this->HailOrgName; // Update the Hail Attachments $attachment->importHailData($attachmentData); if (!$this->Attachments()->byID($attachment->ID)) { $this->Attachments()->add($attachment); } } // Remove old attachments that are currently assigned to this article, // but have not been returned this time around if ($idList) { $this->Attachments()->exclude('HailID', $idList)->removeAll(); } else { // If there's no attachements, just remove everything. $this->Attachments()->removeAll(); } }
[ "protected", "function", "processAttachments", "(", "$", "data", ")", "{", "$", "idList", "=", "[", "]", ";", "foreach", "(", "$", "data", "as", "$", "attachmentData", ")", "{", "$", "idList", "[", "]", "=", "$", "attachmentData", "[", "'id'", "]", ";", "// Find a matching attachment or create it", "$", "attachment", "=", "Attachment", "::", "get", "(", ")", "->", "filter", "(", "[", "'HailID'", "=>", "$", "attachmentData", "[", "'id'", "]", "]", ")", "->", "first", "(", ")", ";", "if", "(", "!", "$", "attachment", ")", "{", "$", "attachment", "=", "new", "Attachment", "(", ")", ";", "}", "$", "attachment", "->", "OrganisationID", "=", "$", "this", "->", "OrganisationID", ";", "$", "attachment", "->", "HailOrgID", "=", "$", "this", "->", "HailOrgID", ";", "$", "attachment", "->", "HailOrgName", "=", "$", "this", "->", "HailOrgName", ";", "// Update the Hail Attachments", "$", "attachment", "->", "importHailData", "(", "$", "attachmentData", ")", ";", "if", "(", "!", "$", "this", "->", "Attachments", "(", ")", "->", "byID", "(", "$", "attachment", "->", "ID", ")", ")", "{", "$", "this", "->", "Attachments", "(", ")", "->", "add", "(", "$", "attachment", ")", ";", "}", "}", "// Remove old attachments that are currently assigned to this article,", "// but have not been returned this time around", "if", "(", "$", "idList", ")", "{", "$", "this", "->", "Attachments", "(", ")", "->", "exclude", "(", "'HailID'", ",", "$", "idList", ")", "->", "removeAll", "(", ")", ";", "}", "else", "{", "// If there's no attachements, just remove everything.", "$", "this", "->", "Attachments", "(", ")", "->", "removeAll", "(", ")", ";", "}", "}" ]
Go through the attachments and assign them to this object. @param array $data JSON data from Hail
[ "Go", "through", "the", "attachments", "and", "assign", "them", "to", "this", "object", "." ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Models/ApiObject.php#L556-L588
32,483
firebrandhq/silverstripe-hail
src/Pages/HailPageController.php
HailPageController.article
public function article(HTTPRequest $request) { $params = $request->params(); if ($params['ID']) { $article = Article::get()->filter(['HailID' => $params['ID']])->first(); //Try to find the article with the database ID field, to be backward compatible with old Hail module (after upgrade) if(!isset($article) || empty($article)) { $article = Article::get()->filter(['ID' => $params['ID']])->first(); } } if (!$params['ID'] || !isset($article) || empty($article)) { return $this->httpError(404, 'That article could not be found'); } $data = [ 'Article' => $article, 'Related' => null ]; //Store the current article so we can use it in other functions in the controller $this->article = $article; //If Related Articles are enabled on the page (from the CMS) if ($this->owner->EnableRelated === "Yes") { //Try to find 3 related articles if ($article->PublicTags()->Count() > 0) { $related = Article::get()->filter(['PublicTags.ID' => $article->PublicTags()->map('ID', 'ID')->toArray()])->exclude(['HailID' => $params['ID']])->sort('Date DESC')->limit(3); if ($related->Count() > 0) { $data['Related'] = $related; } } } return $data; }
php
public function article(HTTPRequest $request) { $params = $request->params(); if ($params['ID']) { $article = Article::get()->filter(['HailID' => $params['ID']])->first(); //Try to find the article with the database ID field, to be backward compatible with old Hail module (after upgrade) if(!isset($article) || empty($article)) { $article = Article::get()->filter(['ID' => $params['ID']])->first(); } } if (!$params['ID'] || !isset($article) || empty($article)) { return $this->httpError(404, 'That article could not be found'); } $data = [ 'Article' => $article, 'Related' => null ]; //Store the current article so we can use it in other functions in the controller $this->article = $article; //If Related Articles are enabled on the page (from the CMS) if ($this->owner->EnableRelated === "Yes") { //Try to find 3 related articles if ($article->PublicTags()->Count() > 0) { $related = Article::get()->filter(['PublicTags.ID' => $article->PublicTags()->map('ID', 'ID')->toArray()])->exclude(['HailID' => $params['ID']])->sort('Date DESC')->limit(3); if ($related->Count() > 0) { $data['Related'] = $related; } } } return $data; }
[ "public", "function", "article", "(", "HTTPRequest", "$", "request", ")", "{", "$", "params", "=", "$", "request", "->", "params", "(", ")", ";", "if", "(", "$", "params", "[", "'ID'", "]", ")", "{", "$", "article", "=", "Article", "::", "get", "(", ")", "->", "filter", "(", "[", "'HailID'", "=>", "$", "params", "[", "'ID'", "]", "]", ")", "->", "first", "(", ")", ";", "//Try to find the article with the database ID field, to be backward compatible with old Hail module (after upgrade)\r", "if", "(", "!", "isset", "(", "$", "article", ")", "||", "empty", "(", "$", "article", ")", ")", "{", "$", "article", "=", "Article", "::", "get", "(", ")", "->", "filter", "(", "[", "'ID'", "=>", "$", "params", "[", "'ID'", "]", "]", ")", "->", "first", "(", ")", ";", "}", "}", "if", "(", "!", "$", "params", "[", "'ID'", "]", "||", "!", "isset", "(", "$", "article", ")", "||", "empty", "(", "$", "article", ")", ")", "{", "return", "$", "this", "->", "httpError", "(", "404", ",", "'That article could not be found'", ")", ";", "}", "$", "data", "=", "[", "'Article'", "=>", "$", "article", ",", "'Related'", "=>", "null", "]", ";", "//Store the current article so we can use it in other functions in the controller\r", "$", "this", "->", "article", "=", "$", "article", ";", "//If Related Articles are enabled on the page (from the CMS)\r", "if", "(", "$", "this", "->", "owner", "->", "EnableRelated", "===", "\"Yes\"", ")", "{", "//Try to find 3 related articles\r", "if", "(", "$", "article", "->", "PublicTags", "(", ")", "->", "Count", "(", ")", ">", "0", ")", "{", "$", "related", "=", "Article", "::", "get", "(", ")", "->", "filter", "(", "[", "'PublicTags.ID'", "=>", "$", "article", "->", "PublicTags", "(", ")", "->", "map", "(", "'ID'", ",", "'ID'", ")", "->", "toArray", "(", ")", "]", ")", "->", "exclude", "(", "[", "'HailID'", "=>", "$", "params", "[", "'ID'", "]", "]", ")", "->", "sort", "(", "'Date DESC'", ")", "->", "limit", "(", "3", ")", ";", "if", "(", "$", "related", "->", "Count", "(", ")", ">", "0", ")", "{", "$", "data", "[", "'Related'", "]", "=", "$", "related", ";", "}", "}", "}", "return", "$", "data", ";", "}" ]
Render a Hail Article @param HTTPRequest $request @return array @throws HTTPResponse_Exception
[ "Render", "a", "Hail", "Article" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Pages/HailPageController.php#L85-L119
32,484
jmikola/WildcardEventDispatcher
src/Jmikola/WildcardEventDispatcher/WildcardEventDispatcher.php
WildcardEventDispatcher.bindPatterns
protected function bindPatterns($eventName) { if (isset($this->syncedEvents[$eventName])) { return; } foreach ($this->patterns as $eventPattern => $patterns) { foreach ($patterns as $pattern) { if ($pattern->test($eventName)) { $pattern->bind($this->dispatcher, $eventName); } } } $this->syncedEvents[$eventName] = true; }
php
protected function bindPatterns($eventName) { if (isset($this->syncedEvents[$eventName])) { return; } foreach ($this->patterns as $eventPattern => $patterns) { foreach ($patterns as $pattern) { if ($pattern->test($eventName)) { $pattern->bind($this->dispatcher, $eventName); } } } $this->syncedEvents[$eventName] = true; }
[ "protected", "function", "bindPatterns", "(", "$", "eventName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "syncedEvents", "[", "$", "eventName", "]", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "this", "->", "patterns", "as", "$", "eventPattern", "=>", "$", "patterns", ")", "{", "foreach", "(", "$", "patterns", "as", "$", "pattern", ")", "{", "if", "(", "$", "pattern", "->", "test", "(", "$", "eventName", ")", ")", "{", "$", "pattern", "->", "bind", "(", "$", "this", "->", "dispatcher", ",", "$", "eventName", ")", ";", "}", "}", "}", "$", "this", "->", "syncedEvents", "[", "$", "eventName", "]", "=", "true", ";", "}" ]
Binds all patterns that match the specified event name. @param string $eventName
[ "Binds", "all", "patterns", "that", "match", "the", "specified", "event", "name", "." ]
cc3257181cfc25a025b049348c5f9053e83ec627
https://github.com/jmikola/WildcardEventDispatcher/blob/cc3257181cfc25a025b049348c5f9053e83ec627/src/Jmikola/WildcardEventDispatcher/WildcardEventDispatcher.php#L139-L154
32,485
jmikola/WildcardEventDispatcher
src/Jmikola/WildcardEventDispatcher/WildcardEventDispatcher.php
WildcardEventDispatcher.addListenerPattern
protected function addListenerPattern(ListenerPattern $pattern) { $this->patterns[$pattern->getEventPattern()][] = $pattern; foreach ($this->syncedEvents as $eventName => $_) { if ($pattern->test($eventName)) { unset($this->syncedEvents[$eventName]); } } }
php
protected function addListenerPattern(ListenerPattern $pattern) { $this->patterns[$pattern->getEventPattern()][] = $pattern; foreach ($this->syncedEvents as $eventName => $_) { if ($pattern->test($eventName)) { unset($this->syncedEvents[$eventName]); } } }
[ "protected", "function", "addListenerPattern", "(", "ListenerPattern", "$", "pattern", ")", "{", "$", "this", "->", "patterns", "[", "$", "pattern", "->", "getEventPattern", "(", ")", "]", "[", "]", "=", "$", "pattern", ";", "foreach", "(", "$", "this", "->", "syncedEvents", "as", "$", "eventName", "=>", "$", "_", ")", "{", "if", "(", "$", "pattern", "->", "test", "(", "$", "eventName", ")", ")", "{", "unset", "(", "$", "this", "->", "syncedEvents", "[", "$", "eventName", "]", ")", ";", "}", "}", "}" ]
Adds an event listener for all events matching the specified pattern. This method will lazily register the listener when a matching event is dispatched. @param ListenerPattern $pattern
[ "Adds", "an", "event", "listener", "for", "all", "events", "matching", "the", "specified", "pattern", "." ]
cc3257181cfc25a025b049348c5f9053e83ec627
https://github.com/jmikola/WildcardEventDispatcher/blob/cc3257181cfc25a025b049348c5f9053e83ec627/src/Jmikola/WildcardEventDispatcher/WildcardEventDispatcher.php#L164-L173
32,486
jmikola/WildcardEventDispatcher
src/Jmikola/WildcardEventDispatcher/WildcardEventDispatcher.php
WildcardEventDispatcher.removeListenerPattern
protected function removeListenerPattern($eventPattern, $listener) { if (!isset($this->patterns[$eventPattern])) { return; } foreach ($this->patterns[$eventPattern] as $key => $pattern) { if ($listener == $pattern->getListener()) { $pattern->unbind($this->dispatcher); unset($this->patterns[$eventPattern][$key]); } } }
php
protected function removeListenerPattern($eventPattern, $listener) { if (!isset($this->patterns[$eventPattern])) { return; } foreach ($this->patterns[$eventPattern] as $key => $pattern) { if ($listener == $pattern->getListener()) { $pattern->unbind($this->dispatcher); unset($this->patterns[$eventPattern][$key]); } } }
[ "protected", "function", "removeListenerPattern", "(", "$", "eventPattern", ",", "$", "listener", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "patterns", "[", "$", "eventPattern", "]", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "this", "->", "patterns", "[", "$", "eventPattern", "]", "as", "$", "key", "=>", "$", "pattern", ")", "{", "if", "(", "$", "listener", "==", "$", "pattern", "->", "getListener", "(", ")", ")", "{", "$", "pattern", "->", "unbind", "(", "$", "this", "->", "dispatcher", ")", ";", "unset", "(", "$", "this", "->", "patterns", "[", "$", "eventPattern", "]", "[", "$", "key", "]", ")", ";", "}", "}", "}" ]
Removes an event listener from any events to which it was applied due to pattern matching. This method cannot be used to remove a listener from a pattern that was never registered. @param string $eventPattern @param callback $listener
[ "Removes", "an", "event", "listener", "from", "any", "events", "to", "which", "it", "was", "applied", "due", "to", "pattern", "matching", "." ]
cc3257181cfc25a025b049348c5f9053e83ec627
https://github.com/jmikola/WildcardEventDispatcher/blob/cc3257181cfc25a025b049348c5f9053e83ec627/src/Jmikola/WildcardEventDispatcher/WildcardEventDispatcher.php#L185-L197
32,487
CradlePHP/cradle-system
src/Schema/Service/ElasticService.php
ElasticService.createMap
public function createMap() { if(is_null($this->schema)) { throw SystemException::forNoSchema(); } // translate data first to sql $data = $this->schema->toSql(); // then translate it to elastic mapping $mapping = $this->schema->toElastic($data); // get schema path $path = cradle()->package('global')->path('schema') . '/elastic'; // if elastic dir doesn't exists // create elastic folder if(!is_dir($path)) { mkdir($path, 0777); } // if elastic schema dir doesn't exist // create elastic schema dir mkdir ($path . '/' . ucwords($data['name'])); // save mapping file_put_contents( $path . '/' . ucwords($data['name']) . '/elastic.php', '<?php //-->' . "\n return " . var_export($mapping, true) . ';' ); }
php
public function createMap() { if(is_null($this->schema)) { throw SystemException::forNoSchema(); } // translate data first to sql $data = $this->schema->toSql(); // then translate it to elastic mapping $mapping = $this->schema->toElastic($data); // get schema path $path = cradle()->package('global')->path('schema') . '/elastic'; // if elastic dir doesn't exists // create elastic folder if(!is_dir($path)) { mkdir($path, 0777); } // if elastic schema dir doesn't exist // create elastic schema dir mkdir ($path . '/' . ucwords($data['name'])); // save mapping file_put_contents( $path . '/' . ucwords($data['name']) . '/elastic.php', '<?php //-->' . "\n return " . var_export($mapping, true) . ';' ); }
[ "public", "function", "createMap", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "schema", ")", ")", "{", "throw", "SystemException", "::", "forNoSchema", "(", ")", ";", "}", "// translate data first to sql", "$", "data", "=", "$", "this", "->", "schema", "->", "toSql", "(", ")", ";", "// then translate it to elastic mapping", "$", "mapping", "=", "$", "this", "->", "schema", "->", "toElastic", "(", "$", "data", ")", ";", "// get schema path", "$", "path", "=", "cradle", "(", ")", "->", "package", "(", "'global'", ")", "->", "path", "(", "'schema'", ")", ".", "'/elastic'", ";", "// if elastic dir doesn't exists", "// create elastic folder", "if", "(", "!", "is_dir", "(", "$", "path", ")", ")", "{", "mkdir", "(", "$", "path", ",", "0777", ")", ";", "}", "// if elastic schema dir doesn't exist", "// create elastic schema dir", "mkdir", "(", "$", "path", ".", "'/'", ".", "ucwords", "(", "$", "data", "[", "'name'", "]", ")", ")", ";", "// save mapping", "file_put_contents", "(", "$", "path", ".", "'/'", ".", "ucwords", "(", "$", "data", "[", "'name'", "]", ")", ".", "'/elastic.php'", ",", "'<?php //-->'", ".", "\"\\n return \"", ".", "var_export", "(", "$", "mapping", ",", "true", ")", ".", "';'", ")", ";", "}" ]
Create an elastic map @return void
[ "Create", "an", "elastic", "map" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Schema/Service/ElasticService.php#L57-L85
32,488
CradlePHP/cradle-system
src/Schema/Service/ElasticService.php
ElasticService.map
public function map() { // no schema validation if(is_null($this->schema)) { throw SystemException::forNoSchema(); } $table = $this->schema->getName(); $path = cradle()->package('global')->path('schema') . sprintf('/elastic/%s/elastic.php', ucwords($table)); // if mapped file doesn't exist, // do nothing if (!file_exists($path)) { return false; } $data = include_once($path); // try mapping try { $this->resource->indices()->create(['index' => $table]); $this->resource->indices()->putMapping([ 'index' => $table, 'type' => 'main', 'body' => [ '_source' => [ 'enabled' => true ], 'properties' => $data[$table] ] ]); } catch (NoNodesAvailableException $e) { //because there is no reason to continue; return false; } catch (BadRequest400Exception $e) { //already mapped return false; } catch (\Throwable $e) { // something is not right return false; } return true; }
php
public function map() { // no schema validation if(is_null($this->schema)) { throw SystemException::forNoSchema(); } $table = $this->schema->getName(); $path = cradle()->package('global')->path('schema') . sprintf('/elastic/%s/elastic.php', ucwords($table)); // if mapped file doesn't exist, // do nothing if (!file_exists($path)) { return false; } $data = include_once($path); // try mapping try { $this->resource->indices()->create(['index' => $table]); $this->resource->indices()->putMapping([ 'index' => $table, 'type' => 'main', 'body' => [ '_source' => [ 'enabled' => true ], 'properties' => $data[$table] ] ]); } catch (NoNodesAvailableException $e) { //because there is no reason to continue; return false; } catch (BadRequest400Exception $e) { //already mapped return false; } catch (\Throwable $e) { // something is not right return false; } return true; }
[ "public", "function", "map", "(", ")", "{", "// no schema validation", "if", "(", "is_null", "(", "$", "this", "->", "schema", ")", ")", "{", "throw", "SystemException", "::", "forNoSchema", "(", ")", ";", "}", "$", "table", "=", "$", "this", "->", "schema", "->", "getName", "(", ")", ";", "$", "path", "=", "cradle", "(", ")", "->", "package", "(", "'global'", ")", "->", "path", "(", "'schema'", ")", ".", "sprintf", "(", "'/elastic/%s/elastic.php'", ",", "ucwords", "(", "$", "table", ")", ")", ";", "// if mapped file doesn't exist,", "// do nothing", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "{", "return", "false", ";", "}", "$", "data", "=", "include_once", "(", "$", "path", ")", ";", "// try mapping", "try", "{", "$", "this", "->", "resource", "->", "indices", "(", ")", "->", "create", "(", "[", "'index'", "=>", "$", "table", "]", ")", ";", "$", "this", "->", "resource", "->", "indices", "(", ")", "->", "putMapping", "(", "[", "'index'", "=>", "$", "table", ",", "'type'", "=>", "'main'", ",", "'body'", "=>", "[", "'_source'", "=>", "[", "'enabled'", "=>", "true", "]", ",", "'properties'", "=>", "$", "data", "[", "$", "table", "]", "]", "]", ")", ";", "}", "catch", "(", "NoNodesAvailableException", "$", "e", ")", "{", "//because there is no reason to continue;", "return", "false", ";", "}", "catch", "(", "BadRequest400Exception", "$", "e", ")", "{", "//already mapped", "return", "false", ";", "}", "catch", "(", "\\", "Throwable", "$", "e", ")", "{", "// something is not right", "return", "false", ";", "}", "return", "true", ";", "}" ]
Map Elastic Schema @return bool
[ "Map", "Elastic", "Schema" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Schema/Service/ElasticService.php#L92-L135
32,489
CradlePHP/cradle-system
src/Schema/Service/ElasticService.php
ElasticService.flush
public function flush() { // no schema validation if(is_null($this->schema)) { throw SystemException::forNoSchema(); } // flush elastic schema try { $this->resource ->indices() ->delete( ['index' => $this->schema ->getName() ] ); return true; } catch(\Throwable $e) { return false; } }
php
public function flush() { // no schema validation if(is_null($this->schema)) { throw SystemException::forNoSchema(); } // flush elastic schema try { $this->resource ->indices() ->delete( ['index' => $this->schema ->getName() ] ); return true; } catch(\Throwable $e) { return false; } }
[ "public", "function", "flush", "(", ")", "{", "// no schema validation", "if", "(", "is_null", "(", "$", "this", "->", "schema", ")", ")", "{", "throw", "SystemException", "::", "forNoSchema", "(", ")", ";", "}", "// flush elastic schema", "try", "{", "$", "this", "->", "resource", "->", "indices", "(", ")", "->", "delete", "(", "[", "'index'", "=>", "$", "this", "->", "schema", "->", "getName", "(", ")", "]", ")", ";", "return", "true", ";", "}", "catch", "(", "\\", "Throwable", "$", "e", ")", "{", "return", "false", ";", "}", "}" ]
Flush Elastic Index @return bool
[ "Flush", "Elastic", "Index" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Schema/Service/ElasticService.php#L240-L260
32,490
oasmobile/php-http
src/ServiceProviders/Security/NullEntryPoint.php
NullEntryPoint.start
public function start(Request $request, AuthenticationException $authException = null) { $msg = $authException ? $authException->getMessage() : 'Access Denied'; throw new AccessDeniedHttpException($msg); }
php
public function start(Request $request, AuthenticationException $authException = null) { $msg = $authException ? $authException->getMessage() : 'Access Denied'; throw new AccessDeniedHttpException($msg); }
[ "public", "function", "start", "(", "Request", "$", "request", ",", "AuthenticationException", "$", "authException", "=", "null", ")", "{", "$", "msg", "=", "$", "authException", "?", "$", "authException", "->", "getMessage", "(", ")", ":", "'Access Denied'", ";", "throw", "new", "AccessDeniedHttpException", "(", "$", "msg", ")", ";", "}" ]
Returns a response that directs the user to authenticate. This is called when an anonymous request accesses a resource that requires authentication. The job of this method is to return some response that "helps" the user start into the authentication process. Examples: A) For a form login, you might redirect to the login page return new RedirectResponse('/login'); B) For an API token authentication system, you return a 401 response return new Response('Auth header required', 401); @param Request $request The request that resulted in an AuthenticationException @param AuthenticationException $authException The exception that started the authentication process @return Response
[ "Returns", "a", "response", "that", "directs", "the", "user", "to", "authenticate", "." ]
a7570893742286c30222c393891aeb6857064f37
https://github.com/oasmobile/php-http/blob/a7570893742286c30222c393891aeb6857064f37/src/ServiceProviders/Security/NullEntryPoint.php#L38-L42
32,491
MetaModels/filter_text
src/FilterSetting/Text.php
Text.doSimpleSearch
private function doSimpleSearch($strTextSearch, $objFilter, $arrFilterUrl) { $objMetaModel = $this->getMetaModel(); $objAttribute = $objMetaModel->getAttributeById($this->get('attr_id')); $arrLanguages = $this->getAvailableLanguages($objMetaModel); $strParamName = $this->getParamName(); $strParamValue = $arrFilterUrl[$strParamName]; // React on wildcard, overriding the search type. if (strpos($strParamValue, '*') !== false) { $strTextSearch = 'exact'; } // Type of search. switch ($strTextSearch) { case 'beginswith': $strWhat = $strParamValue . '*'; break; case 'endswith': $strWhat = '*' . $strParamValue; break; case 'exact': $strWhat = $strParamValue; break; default: $strWhat = '*' . $strParamValue . '*'; break; } if ($objAttribute && $strParamName && $strParamValue !== null) { $objFilter->addFilterRule(new SearchAttribute($objAttribute, $strWhat, $arrLanguages)); return; } $objFilter->addFilterRule(new StaticIdList(null)); }
php
private function doSimpleSearch($strTextSearch, $objFilter, $arrFilterUrl) { $objMetaModel = $this->getMetaModel(); $objAttribute = $objMetaModel->getAttributeById($this->get('attr_id')); $arrLanguages = $this->getAvailableLanguages($objMetaModel); $strParamName = $this->getParamName(); $strParamValue = $arrFilterUrl[$strParamName]; // React on wildcard, overriding the search type. if (strpos($strParamValue, '*') !== false) { $strTextSearch = 'exact'; } // Type of search. switch ($strTextSearch) { case 'beginswith': $strWhat = $strParamValue . '*'; break; case 'endswith': $strWhat = '*' . $strParamValue; break; case 'exact': $strWhat = $strParamValue; break; default: $strWhat = '*' . $strParamValue . '*'; break; } if ($objAttribute && $strParamName && $strParamValue !== null) { $objFilter->addFilterRule(new SearchAttribute($objAttribute, $strWhat, $arrLanguages)); return; } $objFilter->addFilterRule(new StaticIdList(null)); }
[ "private", "function", "doSimpleSearch", "(", "$", "strTextSearch", ",", "$", "objFilter", ",", "$", "arrFilterUrl", ")", "{", "$", "objMetaModel", "=", "$", "this", "->", "getMetaModel", "(", ")", ";", "$", "objAttribute", "=", "$", "objMetaModel", "->", "getAttributeById", "(", "$", "this", "->", "get", "(", "'attr_id'", ")", ")", ";", "$", "arrLanguages", "=", "$", "this", "->", "getAvailableLanguages", "(", "$", "objMetaModel", ")", ";", "$", "strParamName", "=", "$", "this", "->", "getParamName", "(", ")", ";", "$", "strParamValue", "=", "$", "arrFilterUrl", "[", "$", "strParamName", "]", ";", "// React on wildcard, overriding the search type.", "if", "(", "strpos", "(", "$", "strParamValue", ",", "'*'", ")", "!==", "false", ")", "{", "$", "strTextSearch", "=", "'exact'", ";", "}", "// Type of search.", "switch", "(", "$", "strTextSearch", ")", "{", "case", "'beginswith'", ":", "$", "strWhat", "=", "$", "strParamValue", ".", "'*'", ";", "break", ";", "case", "'endswith'", ":", "$", "strWhat", "=", "'*'", ".", "$", "strParamValue", ";", "break", ";", "case", "'exact'", ":", "$", "strWhat", "=", "$", "strParamValue", ";", "break", ";", "default", ":", "$", "strWhat", "=", "'*'", ".", "$", "strParamValue", ".", "'*'", ";", "break", ";", "}", "if", "(", "$", "objAttribute", "&&", "$", "strParamName", "&&", "$", "strParamValue", "!==", "null", ")", "{", "$", "objFilter", "->", "addFilterRule", "(", "new", "SearchAttribute", "(", "$", "objAttribute", ",", "$", "strWhat", ",", "$", "arrLanguages", ")", ")", ";", "return", ";", "}", "$", "objFilter", "->", "addFilterRule", "(", "new", "StaticIdList", "(", "null", ")", ")", ";", "}" ]
Make a simple search with a like. @param string $strTextSearch The mode for the search. @param IFilter $objFilter The filter to append the rules to. @param string[] $arrFilterUrl The parameters to evaluate. @return void
[ "Make", "a", "simple", "search", "with", "a", "like", "." ]
7537cfba0c38c9b6da84398d6109122d2d090593
https://github.com/MetaModels/filter_text/blob/7537cfba0c38c9b6da84398d6109122d2d090593/src/FilterSetting/Text.php#L103-L139
32,492
MetaModels/filter_text
src/FilterSetting/Text.php
Text.doComplexSearch
private function doComplexSearch($strTextSearch, $objFilter, $arrFilterUrl) { $objMetaModel = $this->getMetaModel(); $objAttribute = $objMetaModel->getAttributeById($this->get('attr_id')); $arrLanguages = $this->getAvailableLanguages($objMetaModel); $strParamName = $this->getParamName(); $strParamValue = $arrFilterUrl[$strParamName]; $parentFilter = null; $words = []; // Type of search. switch ($strTextSearch) { case 'any': $words = $this->getWords($strParamValue); $parentFilter = new ConditionOr(); break; case 'all': $words = $this->getWords($strParamValue); $parentFilter = new ConditionAnd(); break; default: // Do nothing. Because the parent function saved us. The value have to be any or all. break; } if ($objAttribute && $strParamName && $strParamValue !== null && $parentFilter) { foreach ($words as $word) { $subFilter = $objMetaModel->getEmptyFilter(); $subFilter->addFilterRule(new SearchAttribute($objAttribute, '%' . $word . '%', $arrLanguages)); $parentFilter->addChild($subFilter); } $objFilter->addFilterRule($parentFilter); return; } $objFilter->addFilterRule(new StaticIdList(null)); }
php
private function doComplexSearch($strTextSearch, $objFilter, $arrFilterUrl) { $objMetaModel = $this->getMetaModel(); $objAttribute = $objMetaModel->getAttributeById($this->get('attr_id')); $arrLanguages = $this->getAvailableLanguages($objMetaModel); $strParamName = $this->getParamName(); $strParamValue = $arrFilterUrl[$strParamName]; $parentFilter = null; $words = []; // Type of search. switch ($strTextSearch) { case 'any': $words = $this->getWords($strParamValue); $parentFilter = new ConditionOr(); break; case 'all': $words = $this->getWords($strParamValue); $parentFilter = new ConditionAnd(); break; default: // Do nothing. Because the parent function saved us. The value have to be any or all. break; } if ($objAttribute && $strParamName && $strParamValue !== null && $parentFilter) { foreach ($words as $word) { $subFilter = $objMetaModel->getEmptyFilter(); $subFilter->addFilterRule(new SearchAttribute($objAttribute, '%' . $word . '%', $arrLanguages)); $parentFilter->addChild($subFilter); } $objFilter->addFilterRule($parentFilter); return; } $objFilter->addFilterRule(new StaticIdList(null)); }
[ "private", "function", "doComplexSearch", "(", "$", "strTextSearch", ",", "$", "objFilter", ",", "$", "arrFilterUrl", ")", "{", "$", "objMetaModel", "=", "$", "this", "->", "getMetaModel", "(", ")", ";", "$", "objAttribute", "=", "$", "objMetaModel", "->", "getAttributeById", "(", "$", "this", "->", "get", "(", "'attr_id'", ")", ")", ";", "$", "arrLanguages", "=", "$", "this", "->", "getAvailableLanguages", "(", "$", "objMetaModel", ")", ";", "$", "strParamName", "=", "$", "this", "->", "getParamName", "(", ")", ";", "$", "strParamValue", "=", "$", "arrFilterUrl", "[", "$", "strParamName", "]", ";", "$", "parentFilter", "=", "null", ";", "$", "words", "=", "[", "]", ";", "// Type of search.", "switch", "(", "$", "strTextSearch", ")", "{", "case", "'any'", ":", "$", "words", "=", "$", "this", "->", "getWords", "(", "$", "strParamValue", ")", ";", "$", "parentFilter", "=", "new", "ConditionOr", "(", ")", ";", "break", ";", "case", "'all'", ":", "$", "words", "=", "$", "this", "->", "getWords", "(", "$", "strParamValue", ")", ";", "$", "parentFilter", "=", "new", "ConditionAnd", "(", ")", ";", "break", ";", "default", ":", "// Do nothing. Because the parent function saved us. The value have to be any or all.", "break", ";", "}", "if", "(", "$", "objAttribute", "&&", "$", "strParamName", "&&", "$", "strParamValue", "!==", "null", "&&", "$", "parentFilter", ")", "{", "foreach", "(", "$", "words", "as", "$", "word", ")", "{", "$", "subFilter", "=", "$", "objMetaModel", "->", "getEmptyFilter", "(", ")", ";", "$", "subFilter", "->", "addFilterRule", "(", "new", "SearchAttribute", "(", "$", "objAttribute", ",", "'%'", ".", "$", "word", ".", "'%'", ",", "$", "arrLanguages", ")", ")", ";", "$", "parentFilter", "->", "addChild", "(", "$", "subFilter", ")", ";", "}", "$", "objFilter", "->", "addFilterRule", "(", "$", "parentFilter", ")", ";", "return", ";", "}", "$", "objFilter", "->", "addFilterRule", "(", "new", "StaticIdList", "(", "null", ")", ")", ";", "}" ]
Do a complex search with each word. Search for all words or for any word. @param string $strTextSearch The mode any or all. @param IFilter $objFilter The filter to append the rules to. @param string[] $arrFilterUrl The parameters to evaluate. @return void
[ "Do", "a", "complex", "search", "with", "each", "word", ".", "Search", "for", "all", "words", "or", "for", "any", "word", "." ]
7537cfba0c38c9b6da84398d6109122d2d090593
https://github.com/MetaModels/filter_text/blob/7537cfba0c38c9b6da84398d6109122d2d090593/src/FilterSetting/Text.php#L152-L191
32,493
MetaModels/filter_text
src/FilterSetting/Text.php
Text.getWords
private function getWords($string) { $delimiter = $this->get('delimiter'); if (empty($delimiter)) { $delimiter = ' '; } return trimsplit($delimiter, $string); }
php
private function getWords($string) { $delimiter = $this->get('delimiter'); if (empty($delimiter)) { $delimiter = ' '; } return trimsplit($delimiter, $string); }
[ "private", "function", "getWords", "(", "$", "string", ")", "{", "$", "delimiter", "=", "$", "this", "->", "get", "(", "'delimiter'", ")", ";", "if", "(", "empty", "(", "$", "delimiter", ")", ")", "{", "$", "delimiter", "=", "' '", ";", "}", "return", "trimsplit", "(", "$", "delimiter", ",", "$", "string", ")", ";", "}" ]
Use the delimiter from the setting and make a list of words. @param string $string The list of words as a single string. @return array The list of word split on the delimiter.
[ "Use", "the", "delimiter", "from", "the", "setting", "and", "make", "a", "list", "of", "words", "." ]
7537cfba0c38c9b6da84398d6109122d2d090593
https://github.com/MetaModels/filter_text/blob/7537cfba0c38c9b6da84398d6109122d2d090593/src/FilterSetting/Text.php#L200-L208
32,494
MetaModels/filter_text
src/FilterSetting/Text.php
Text.doRegexpSearch
private function doRegexpSearch($objFilter, $arrFilterUrl) { $objMetaModel = $this->getMetaModel(); $objAttribute = $objMetaModel->getAttributeById($this->get('attr_id')); $strParamName = $this->getParamName(); $strParamValue = $arrFilterUrl[$strParamName]; $strPattern = $this->get('pattern'); if ($objAttribute && $strParamName && $strParamValue !== null) { if (empty($strPattern) || substr_count($strPattern, '%s') != 1) { $strPattern = '%s'; } $strRegex = sprintf($strPattern, $strParamValue); $strQuery = sprintf( 'SELECT id FROM %s WHERE %s REGEXP \'%s\'', $objMetaModel->getTableName(), $objAttribute->getColName(), $strRegex ); $objFilter->addFilterRule(new SimpleQuery($strQuery)); return; } $objFilter->addFilterRule(new StaticIdList(null)); }
php
private function doRegexpSearch($objFilter, $arrFilterUrl) { $objMetaModel = $this->getMetaModel(); $objAttribute = $objMetaModel->getAttributeById($this->get('attr_id')); $strParamName = $this->getParamName(); $strParamValue = $arrFilterUrl[$strParamName]; $strPattern = $this->get('pattern'); if ($objAttribute && $strParamName && $strParamValue !== null) { if (empty($strPattern) || substr_count($strPattern, '%s') != 1) { $strPattern = '%s'; } $strRegex = sprintf($strPattern, $strParamValue); $strQuery = sprintf( 'SELECT id FROM %s WHERE %s REGEXP \'%s\'', $objMetaModel->getTableName(), $objAttribute->getColName(), $strRegex ); $objFilter->addFilterRule(new SimpleQuery($strQuery)); return; } $objFilter->addFilterRule(new StaticIdList(null)); }
[ "private", "function", "doRegexpSearch", "(", "$", "objFilter", ",", "$", "arrFilterUrl", ")", "{", "$", "objMetaModel", "=", "$", "this", "->", "getMetaModel", "(", ")", ";", "$", "objAttribute", "=", "$", "objMetaModel", "->", "getAttributeById", "(", "$", "this", "->", "get", "(", "'attr_id'", ")", ")", ";", "$", "strParamName", "=", "$", "this", "->", "getParamName", "(", ")", ";", "$", "strParamValue", "=", "$", "arrFilterUrl", "[", "$", "strParamName", "]", ";", "$", "strPattern", "=", "$", "this", "->", "get", "(", "'pattern'", ")", ";", "if", "(", "$", "objAttribute", "&&", "$", "strParamName", "&&", "$", "strParamValue", "!==", "null", ")", "{", "if", "(", "empty", "(", "$", "strPattern", ")", "||", "substr_count", "(", "$", "strPattern", ",", "'%s'", ")", "!=", "1", ")", "{", "$", "strPattern", "=", "'%s'", ";", "}", "$", "strRegex", "=", "sprintf", "(", "$", "strPattern", ",", "$", "strParamValue", ")", ";", "$", "strQuery", "=", "sprintf", "(", "'SELECT id FROM %s WHERE %s REGEXP \\'%s\\''", ",", "$", "objMetaModel", "->", "getTableName", "(", ")", ",", "$", "objAttribute", "->", "getColName", "(", ")", ",", "$", "strRegex", ")", ";", "$", "objFilter", "->", "addFilterRule", "(", "new", "SimpleQuery", "(", "$", "strQuery", ")", ")", ";", "return", ";", "}", "$", "objFilter", "->", "addFilterRule", "(", "new", "StaticIdList", "(", "null", ")", ")", ";", "}" ]
Make a simple search with a regexp. @param IFilter $objFilter The filter to append the rules to. @param string[] $arrFilterUrl The parameters to evaluate. @return void
[ "Make", "a", "simple", "search", "with", "a", "regexp", "." ]
7537cfba0c38c9b6da84398d6109122d2d090593
https://github.com/MetaModels/filter_text/blob/7537cfba0c38c9b6da84398d6109122d2d090593/src/FilterSetting/Text.php#L219-L247
32,495
flipboxfactory/craft-ember
src/helpers/LoggerHelper.php
LoggerHelper.targetConfigs
public static function targetConfigs(array $categories): array { $configs = []; foreach ($categories as $category) { $configs[$category] = static::targetConfig($category); } return array_filter($configs); }
php
public static function targetConfigs(array $categories): array { $configs = []; foreach ($categories as $category) { $configs[$category] = static::targetConfig($category); } return array_filter($configs); }
[ "public", "static", "function", "targetConfigs", "(", "array", "$", "categories", ")", ":", "array", "{", "$", "configs", "=", "[", "]", ";", "foreach", "(", "$", "categories", "as", "$", "category", ")", "{", "$", "configs", "[", "$", "category", "]", "=", "static", "::", "targetConfig", "(", "$", "category", ")", ";", "}", "return", "array_filter", "(", "$", "configs", ")", ";", "}" ]
Takes an array of log categories and creates log target configs @param array $categories @return array
[ "Takes", "an", "array", "of", "log", "categories", "and", "creates", "log", "target", "configs" ]
9185b885b404b1cb272a0983023eb7c6c0df61c8
https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/helpers/LoggerHelper.php#L28-L37
32,496
flipboxfactory/craft-ember
src/helpers/LoggerHelper.php
LoggerHelper.targetConfig
public static function targetConfig(string $category): array { // Only log console requests and web requests that aren't getAuthTimeout requests $isConsoleRequest = Craft::$app->getRequest()->getIsConsoleRequest(); if (!$isConsoleRequest && !Craft::$app->getUser()->enableSession) { return []; } $generalConfig = Craft::$app->getConfig()->getGeneral(); $target = [ 'class' => FileTarget::class, 'fileMode' => $generalConfig->defaultFileMode, 'dirMode' => $generalConfig->defaultDirMode, 'logVars' => [], 'categories' => [$category, $category . ':*'], 'logFile' => '@storage/logs/'.$category.'.log' ]; if (!$isConsoleRequest) { // Only log errors and warnings, unless Craft is running in Dev Mode or it's being installed/updated if (!YII_DEBUG && Craft::$app->getIsInstalled() && !Craft::$app->getUpdates()->getIsCraftDbMigrationNeeded() ) { $target['levels'] = Logger::LEVEL_ERROR | Logger::LEVEL_WARNING; } } return $target; }
php
public static function targetConfig(string $category): array { // Only log console requests and web requests that aren't getAuthTimeout requests $isConsoleRequest = Craft::$app->getRequest()->getIsConsoleRequest(); if (!$isConsoleRequest && !Craft::$app->getUser()->enableSession) { return []; } $generalConfig = Craft::$app->getConfig()->getGeneral(); $target = [ 'class' => FileTarget::class, 'fileMode' => $generalConfig->defaultFileMode, 'dirMode' => $generalConfig->defaultDirMode, 'logVars' => [], 'categories' => [$category, $category . ':*'], 'logFile' => '@storage/logs/'.$category.'.log' ]; if (!$isConsoleRequest) { // Only log errors and warnings, unless Craft is running in Dev Mode or it's being installed/updated if (!YII_DEBUG && Craft::$app->getIsInstalled() && !Craft::$app->getUpdates()->getIsCraftDbMigrationNeeded() ) { $target['levels'] = Logger::LEVEL_ERROR | Logger::LEVEL_WARNING; } } return $target; }
[ "public", "static", "function", "targetConfig", "(", "string", "$", "category", ")", ":", "array", "{", "// Only log console requests and web requests that aren't getAuthTimeout requests", "$", "isConsoleRequest", "=", "Craft", "::", "$", "app", "->", "getRequest", "(", ")", "->", "getIsConsoleRequest", "(", ")", ";", "if", "(", "!", "$", "isConsoleRequest", "&&", "!", "Craft", "::", "$", "app", "->", "getUser", "(", ")", "->", "enableSession", ")", "{", "return", "[", "]", ";", "}", "$", "generalConfig", "=", "Craft", "::", "$", "app", "->", "getConfig", "(", ")", "->", "getGeneral", "(", ")", ";", "$", "target", "=", "[", "'class'", "=>", "FileTarget", "::", "class", ",", "'fileMode'", "=>", "$", "generalConfig", "->", "defaultFileMode", ",", "'dirMode'", "=>", "$", "generalConfig", "->", "defaultDirMode", ",", "'logVars'", "=>", "[", "]", ",", "'categories'", "=>", "[", "$", "category", ",", "$", "category", ".", "':*'", "]", ",", "'logFile'", "=>", "'@storage/logs/'", ".", "$", "category", ".", "'.log'", "]", ";", "if", "(", "!", "$", "isConsoleRequest", ")", "{", "// Only log errors and warnings, unless Craft is running in Dev Mode or it's being installed/updated", "if", "(", "!", "YII_DEBUG", "&&", "Craft", "::", "$", "app", "->", "getIsInstalled", "(", ")", "&&", "!", "Craft", "::", "$", "app", "->", "getUpdates", "(", ")", "->", "getIsCraftDbMigrationNeeded", "(", ")", ")", "{", "$", "target", "[", "'levels'", "]", "=", "Logger", "::", "LEVEL_ERROR", "|", "Logger", "::", "LEVEL_WARNING", ";", "}", "}", "return", "$", "target", ";", "}" ]
Takes a log category and creates a log target config @param string $category @return array
[ "Takes", "a", "log", "category", "and", "creates", "a", "log", "target", "config" ]
9185b885b404b1cb272a0983023eb7c6c0df61c8
https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/helpers/LoggerHelper.php#L45-L75
32,497
davidecesarano/Embryo-Http
Embryo/Http/Message/Traits/HeadersTrait.php
HeadersTrait.setHeaderName
protected function setHeaderName(string $key) { $key = strtr(strtolower($key), '_', '-'); if (strpos($key, 'http-') === 0) { $key = substr($key, 5); } return $key; }
php
protected function setHeaderName(string $key) { $key = strtr(strtolower($key), '_', '-'); if (strpos($key, 'http-') === 0) { $key = substr($key, 5); } return $key; }
[ "protected", "function", "setHeaderName", "(", "string", "$", "key", ")", "{", "$", "key", "=", "strtr", "(", "strtolower", "(", "$", "key", ")", ",", "'_'", ",", "'-'", ")", ";", "if", "(", "strpos", "(", "$", "key", ",", "'http-'", ")", "===", "0", ")", "{", "$", "key", "=", "substr", "(", "$", "key", ",", "5", ")", ";", "}", "return", "$", "key", ";", "}" ]
Sets case-insensitive header name. @param string $key @return string
[ "Sets", "case", "-", "insensitive", "header", "name", "." ]
5ff81c07fbff3abed051d710f0837544465887c8
https://github.com/davidecesarano/Embryo-Http/blob/5ff81c07fbff3abed051d710f0837544465887c8/Embryo/Http/Message/Traits/HeadersTrait.php#L68-L75
32,498
davidecesarano/Embryo-Http
Embryo/Http/Message/Traits/HeadersTrait.php
HeadersTrait.setPreserveHost
protected function setPreserveHost(string $headerHost, string $host) { $header = []; if ($host !== '' && $headerHost === '') { $header = [ 'original' => 'HTTP_HOST', 'values' => [$host] ]; } return $header; }
php
protected function setPreserveHost(string $headerHost, string $host) { $header = []; if ($host !== '' && $headerHost === '') { $header = [ 'original' => 'HTTP_HOST', 'values' => [$host] ]; } return $header; }
[ "protected", "function", "setPreserveHost", "(", "string", "$", "headerHost", ",", "string", "$", "host", ")", "{", "$", "header", "=", "[", "]", ";", "if", "(", "$", "host", "!==", "''", "&&", "$", "headerHost", "===", "''", ")", "{", "$", "header", "=", "[", "'original'", "=>", "'HTTP_HOST'", ",", "'values'", "=>", "[", "$", "host", "]", "]", ";", "}", "return", "$", "header", ";", "}" ]
Sets Host header if preserve host is true. @param string $headerHost @param string $host return string[][]
[ "Sets", "Host", "header", "if", "preserve", "host", "is", "true", "." ]
5ff81c07fbff3abed051d710f0837544465887c8
https://github.com/davidecesarano/Embryo-Http/blob/5ff81c07fbff3abed051d710f0837544465887c8/Embryo/Http/Message/Traits/HeadersTrait.php#L84-L94
32,499
firebrandhq/silverstripe-hail
src/Models/Image.php
Image.getRelativeCenterX
public function getRelativeCenterX() { $pos = 50; if ($this->FaceCentreX > 0 && $this->OriginalWidth > 0) { $pos = $this->FaceCentreX / $this->OriginalWidth * 100; $pos = ($pos > 100 || $pos < 0) ? 50 : $pos; } return $pos; }
php
public function getRelativeCenterX() { $pos = 50; if ($this->FaceCentreX > 0 && $this->OriginalWidth > 0) { $pos = $this->FaceCentreX / $this->OriginalWidth * 100; $pos = ($pos > 100 || $pos < 0) ? 50 : $pos; } return $pos; }
[ "public", "function", "getRelativeCenterX", "(", ")", "{", "$", "pos", "=", "50", ";", "if", "(", "$", "this", "->", "FaceCentreX", ">", "0", "&&", "$", "this", "->", "OriginalWidth", ">", "0", ")", "{", "$", "pos", "=", "$", "this", "->", "FaceCentreX", "/", "$", "this", "->", "OriginalWidth", "*", "100", ";", "$", "pos", "=", "(", "$", "pos", ">", "100", "||", "$", "pos", "<", "0", ")", "?", "50", ":", "$", "pos", ";", "}", "return", "$", "pos", ";", "}" ]
Get the X axis for the relative center of this image @return int
[ "Get", "the", "X", "axis", "for", "the", "relative", "center", "of", "this", "image" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Models/Image.php#L193-L202