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 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
LostKobrakai/Migrations | classes/TemplateMigration.php | TemplateMigration.downgrade | public function downgrade() {
$template = $this->getTemplate($this->getTemplateName());
$fieldgroup = $template->fieldgroup;
$fg = $this->wire('fieldgroups')->get($template->name);
$minNumberToError = $fg->id == $fieldgroup->id ? 2 : 1;
if($fg->numTemplates() >= $minNumberToError)
throw new WireException("Cannot delete $template->name, because it's fieldgroup is used by at least one other template.");
// Remove all pages of that template
$selector = "template=$template, include=all, check_access=0";
$this->eachPageUncache($selector, function($p) { $this->pages->delete($p, true); });
// Delete fieldgroup and template
$this->templates->delete($template);
$this->fieldgroups->delete($fieldgroup);
} | php | public function downgrade() {
$template = $this->getTemplate($this->getTemplateName());
$fieldgroup = $template->fieldgroup;
$fg = $this->wire('fieldgroups')->get($template->name);
$minNumberToError = $fg->id == $fieldgroup->id ? 2 : 1;
if($fg->numTemplates() >= $minNumberToError)
throw new WireException("Cannot delete $template->name, because it's fieldgroup is used by at least one other template.");
// Remove all pages of that template
$selector = "template=$template, include=all, check_access=0";
$this->eachPageUncache($selector, function($p) { $this->pages->delete($p, true); });
// Delete fieldgroup and template
$this->templates->delete($template);
$this->fieldgroups->delete($fieldgroup);
} | [
"public",
"function",
"downgrade",
"(",
")",
"{",
"$",
"template",
"=",
"$",
"this",
"->",
"getTemplate",
"(",
"$",
"this",
"->",
"getTemplateName",
"(",
")",
")",
";",
"$",
"fieldgroup",
"=",
"$",
"template",
"->",
"fieldgroup",
";",
"$",
"fg",
"=",
... | Delete the template
Does delete all pages of that template and does even delete system templates | [
"Delete",
"the",
"template",
"Does",
"delete",
"all",
"pages",
"of",
"that",
"template",
"and",
"does",
"even",
"delete",
"system",
"templates"
] | 54972f8c0c45e9dc8710845f61f32cb70af3e72d | https://github.com/LostKobrakai/Migrations/blob/54972f8c0c45e9dc8710845f61f32cb70af3e72d/classes/TemplateMigration.php#L43-L60 | train |
dynamic/foxystripe | src/Page/ProductHolder.php | ProductHolder.loadDescendantProductGroupIDListInto | public function loadDescendantProductGroupIDListInto(&$idList)
{
if ($children = $this->AllChildren()) {
foreach ($children as $child) {
if (in_array($child->ID, $idList)) {
continue;
}
if ($child instanceof self) {
$idList[] = $child->ID;
$child->loadDescendantProductGroupIDListInto($idList);
}
}
}
} | php | public function loadDescendantProductGroupIDListInto(&$idList)
{
if ($children = $this->AllChildren()) {
foreach ($children as $child) {
if (in_array($child->ID, $idList)) {
continue;
}
if ($child instanceof self) {
$idList[] = $child->ID;
$child->loadDescendantProductGroupIDListInto($idList);
}
}
}
} | [
"public",
"function",
"loadDescendantProductGroupIDListInto",
"(",
"&",
"$",
"idList",
")",
"{",
"if",
"(",
"$",
"children",
"=",
"$",
"this",
"->",
"AllChildren",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"children",
"as",
"$",
"child",
")",
"{",
"if",
... | loadDescendantProductGroupIDListInto function.
@param mixed &$idList | [
"loadDescendantProductGroupIDListInto",
"function",
"."
] | cfffae6021788de18fd78489753821f7faf5b9a9 | https://github.com/dynamic/foxystripe/blob/cfffae6021788de18fd78489753821f7faf5b9a9/src/Page/ProductHolder.php#L107-L121 | train |
afbora/resellerclub-php-sdk | src/APIs/Customers.php | Customers.modify | public function modify(
$customerId,
$username,
$name,
$company,
$address,
$city,
$state,
$country,
$zipCode,
$phoneCC,
$phone,
$lang
)
{
return $this->post(
'modify',
[
'customer-id' => $customerId,
'username' => $username,
'name' => $name,
'company' => $company,
'address-line-1' => $address,
'city' => $city,
'state' => $state,
'country' => $country,
'zipcode' => $zipCode,
'phone-cc' => $phoneCC,
'phone' => $phone,
'lang-pref' => $lang,
]
);
} | php | public function modify(
$customerId,
$username,
$name,
$company,
$address,
$city,
$state,
$country,
$zipCode,
$phoneCC,
$phone,
$lang
)
{
return $this->post(
'modify',
[
'customer-id' => $customerId,
'username' => $username,
'name' => $name,
'company' => $company,
'address-line-1' => $address,
'city' => $city,
'state' => $state,
'country' => $country,
'zipcode' => $zipCode,
'phone-cc' => $phoneCC,
'phone' => $phone,
'lang-pref' => $lang,
]
);
} | [
"public",
"function",
"modify",
"(",
"$",
"customerId",
",",
"$",
"username",
",",
"$",
"name",
",",
"$",
"company",
",",
"$",
"address",
",",
"$",
"city",
",",
"$",
"state",
",",
"$",
"country",
",",
"$",
"zipCode",
",",
"$",
"phoneCC",
",",
"$",
... | Modifies the Account details of the specified Customer.
@param $customerId
@param $username
@param $name
@param $company
@param $address
@param $city
@param $state
@param $country
@param $zipCode
@param $phoneCC
@param $phone
@param $lang
@return mixed|\SimpleXMLElement | [
"Modifies",
"the",
"Account",
"details",
"of",
"the",
"specified",
"Customer",
"."
] | 6b9442a0939e582256c940b4ba76517f74774d30 | https://github.com/afbora/resellerclub-php-sdk/blob/6b9442a0939e582256c940b4ba76517f74774d30/src/APIs/Customers.php#L63-L95 | train |
afbora/resellerclub-php-sdk | src/APIs/Customers.php | Customers.signup | public function signup(
$username,
$passwd,
$name,
$company,
$address,
$city,
$state,
$country,
$zipCode,
$phoneCC,
$phone,
$lang
)
{
return $this->post(
'signup',
[
'username' => $username,
'passwd' => $passwd,
'name' => $name,
'company' => $company,
'address-line-1' => $address,
'city' => $city,
'state' => $state,
'country' => $country,
'zipcode' => $zipCode,
'phone-cc' => $phoneCC,
'phone' => $phone,
'lang-pref' => $lang,
]
);
} | php | public function signup(
$username,
$passwd,
$name,
$company,
$address,
$city,
$state,
$country,
$zipCode,
$phoneCC,
$phone,
$lang
)
{
return $this->post(
'signup',
[
'username' => $username,
'passwd' => $passwd,
'name' => $name,
'company' => $company,
'address-line-1' => $address,
'city' => $city,
'state' => $state,
'country' => $country,
'zipcode' => $zipCode,
'phone-cc' => $phoneCC,
'phone' => $phone,
'lang-pref' => $lang,
]
);
} | [
"public",
"function",
"signup",
"(",
"$",
"username",
",",
"$",
"passwd",
",",
"$",
"name",
",",
"$",
"company",
",",
"$",
"address",
",",
"$",
"city",
",",
"$",
"state",
",",
"$",
"country",
",",
"$",
"zipCode",
",",
"$",
"phoneCC",
",",
"$",
"p... | Creates a Customer Account using the details provided.
@param $username
@param $passwd
@param $name
@param $company
@param $address
@param $city
@param $state
@param $country
@param $zipCode
@param $phoneCC
@param $phone
@param $lang
@return mixed|\SimpleXMLElement | [
"Creates",
"a",
"Customer",
"Account",
"using",
"the",
"details",
"provided",
"."
] | 6b9442a0939e582256c940b4ba76517f74774d30 | https://github.com/afbora/resellerclub-php-sdk/blob/6b9442a0939e582256c940b4ba76517f74774d30/src/APIs/Customers.php#L113-L145 | train |
adrianorsouza/reCAPTCHA-lib | lib/ReCaptcha/Captcha.php | Captcha.setConfig | public function setConfig($config_location = NULL)
{
static $CAPTCHA_CONFIG = array();
$path = ( NULL === $config_location )
? __DIR__ . DIRECTORY_SEPARATOR . 'captcha_config.php'
: realpath($config_location);
if ( false === $path ) {
throw new CaptchaException(
sprintf("Config File not found in: %s ", $config_location)
);
}
if ( $path ) {
include_once $path;
foreach (get_class_vars(get_class($this)) as $key => $value) {
$config = preg_replace('/^[\_A-Z]/', '\\1', $key);
if ( array_key_exists($config, $CAPTCHA_CONFIG) ) {
$this->$key = $CAPTCHA_CONFIG[$config];
}
}
}
} | php | public function setConfig($config_location = NULL)
{
static $CAPTCHA_CONFIG = array();
$path = ( NULL === $config_location )
? __DIR__ . DIRECTORY_SEPARATOR . 'captcha_config.php'
: realpath($config_location);
if ( false === $path ) {
throw new CaptchaException(
sprintf("Config File not found in: %s ", $config_location)
);
}
if ( $path ) {
include_once $path;
foreach (get_class_vars(get_class($this)) as $key => $value) {
$config = preg_replace('/^[\_A-Z]/', '\\1', $key);
if ( array_key_exists($config, $CAPTCHA_CONFIG) ) {
$this->$key = $CAPTCHA_CONFIG[$config];
}
}
}
} | [
"public",
"function",
"setConfig",
"(",
"$",
"config_location",
"=",
"NULL",
")",
"{",
"static",
"$",
"CAPTCHA_CONFIG",
"=",
"array",
"(",
")",
";",
"$",
"path",
"=",
"(",
"NULL",
"===",
"$",
"config_location",
")",
"?",
"__DIR__",
".",
"DIRECTORY_SEPARATO... | Set global reCAPTCHA options by loading an external config file
these options can be set for all instances of reCAPTCHA in your
app, this avoid to set options, private and public Keys all the
time individualy within your forms that has a Captcha widget.
@param string $config_location The absolute path to config file
@throws \ReCaptcha\CaptchaException
@return void | [
"Set",
"global",
"reCAPTCHA",
"options",
"by",
"loading",
"an",
"external",
"config",
"file",
"these",
"options",
"can",
"be",
"set",
"for",
"all",
"instances",
"of",
"reCAPTCHA",
"in",
"your",
"app",
"this",
"avoid",
"to",
"set",
"options",
"private",
"and"... | 0875e6deab68b9949033417d10db4d2aefeccdcb | https://github.com/adrianorsouza/reCAPTCHA-lib/blob/0875e6deab68b9949033417d10db4d2aefeccdcb/lib/ReCaptcha/Captcha.php#L124-L151 | train |
adrianorsouza/reCAPTCHA-lib | lib/ReCaptcha/Captcha.php | Captcha.displayHTML | public function displayHTML($theme_name = NULL, $options = array())
{
if ( strlen($this->_publicKey == 0) ) {
throw new CaptchaException('To use reCAPTCHA you must get a Public API key from https://www.google.com/recaptcha/admin');
}
// append a Theme
$captcha_snippet = $this->_theme($theme_name, $options);
$captcha_snippet .= '<script type="text/javascript" src="'. $this->_buildServerURI() . '"></script>
<noscript>
<iframe src="' . $this->_buildServerURI('noscript') . '" height="300" width="500" frameborder="0"></iframe><br>
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
<input type="hidden" name="recaptcha_response_field" value="manual_challenge">
</noscript>';
return $captcha_snippet;
} | php | public function displayHTML($theme_name = NULL, $options = array())
{
if ( strlen($this->_publicKey == 0) ) {
throw new CaptchaException('To use reCAPTCHA you must get a Public API key from https://www.google.com/recaptcha/admin');
}
// append a Theme
$captcha_snippet = $this->_theme($theme_name, $options);
$captcha_snippet .= '<script type="text/javascript" src="'. $this->_buildServerURI() . '"></script>
<noscript>
<iframe src="' . $this->_buildServerURI('noscript') . '" height="300" width="500" frameborder="0"></iframe><br>
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
<input type="hidden" name="recaptcha_response_field" value="manual_challenge">
</noscript>';
return $captcha_snippet;
} | [
"public",
"function",
"displayHTML",
"(",
"$",
"theme_name",
"=",
"NULL",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"this",
"->",
"_publicKey",
"==",
"0",
")",
")",
"{",
"throw",
"new",
"CaptchaException",
... | Create embedded widget script HTML called within a form
NOTE: $theme_name is used to set theme name separated instead set
it within array of options available, this is to keep compatibility
for newer version in future.
@param string $theme_name Optional Standard_Theme or custom theme name
@param array $options Optional array of reCAPTCHA options
@throws \ReCaptcha\CaptchaException
@return string The reCAPTCHA widget embed HTML | [
"Create",
"embedded",
"widget",
"script",
"HTML",
"called",
"within",
"a",
"form"
] | 0875e6deab68b9949033417d10db4d2aefeccdcb | https://github.com/adrianorsouza/reCAPTCHA-lib/blob/0875e6deab68b9949033417d10db4d2aefeccdcb/lib/ReCaptcha/Captcha.php#L233-L250 | train |
adrianorsouza/reCAPTCHA-lib | lib/ReCaptcha/Captcha.php | Captcha.isValid | public function isValid()
{
// Skip without submission
if (strtoupper($_SERVER['REQUEST_METHOD']) !== 'POST') {
return FALSE;
} else {
$captchaChallenge = isset($_POST['recaptcha_challenge_field'])
? $this->_sanitizeField($_POST['recaptcha_challenge_field'])
: NULL;
$captchaResponse = isset($_POST['recaptcha_response_field'])
? $this->_sanitizeField($_POST['recaptcha_response_field'])
: NULL;
// Skip empty submission
if ( strlen($captchaChallenge) == 0 || strlen($captchaResponse) == 0 ) {
$this->setError('incorrect-captcha-sol');
return FALSE;
}
$data = array(
'privatekey' => $this->_privateKey,
'remoteip' => $this->_remoteIp(),
'challenge' => $captchaChallenge,
'response' => $captchaResponse
);
$result = $this->_postHttpChallenge($data);
if ( $result['isvalid'] === "true") {
return TRUE;
} else {
$this->setError($result['error']);
}
return FALSE;
}
} | php | public function isValid()
{
// Skip without submission
if (strtoupper($_SERVER['REQUEST_METHOD']) !== 'POST') {
return FALSE;
} else {
$captchaChallenge = isset($_POST['recaptcha_challenge_field'])
? $this->_sanitizeField($_POST['recaptcha_challenge_field'])
: NULL;
$captchaResponse = isset($_POST['recaptcha_response_field'])
? $this->_sanitizeField($_POST['recaptcha_response_field'])
: NULL;
// Skip empty submission
if ( strlen($captchaChallenge) == 0 || strlen($captchaResponse) == 0 ) {
$this->setError('incorrect-captcha-sol');
return FALSE;
}
$data = array(
'privatekey' => $this->_privateKey,
'remoteip' => $this->_remoteIp(),
'challenge' => $captchaChallenge,
'response' => $captchaResponse
);
$result = $this->_postHttpChallenge($data);
if ( $result['isvalid'] === "true") {
return TRUE;
} else {
$this->setError($result['error']);
}
return FALSE;
}
} | [
"public",
"function",
"isValid",
"(",
")",
"{",
"// Skip without submission",
"if",
"(",
"strtoupper",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_METHOD'",
"]",
")",
"!==",
"'POST'",
")",
"{",
"return",
"FALSE",
";",
"}",
"else",
"{",
"$",
"captchaChallenge",
"=",
... | Verifying reCAPTCHA User's Answer
resolves response challenge return TRUE if the answer matches
@return bool | [
"Verifying",
"reCAPTCHA",
"User",
"s",
"Answer",
"resolves",
"response",
"challenge",
"return",
"TRUE",
"if",
"the",
"answer",
"matches"
] | 0875e6deab68b9949033417d10db4d2aefeccdcb | https://github.com/adrianorsouza/reCAPTCHA-lib/blob/0875e6deab68b9949033417d10db4d2aefeccdcb/lib/ReCaptcha/Captcha.php#L258-L297 | train |
adrianorsouza/reCAPTCHA-lib | lib/ReCaptcha/Captcha.php | Captcha._postHttpChallenge | protected function _postHttpChallenge(array $data)
{
if ( strlen($this->_privateKey) == 0 ) {
throw new CaptchaException(
'To use reCAPTCHA you must get a Private API key from https://www.google.com/recaptcha/admin'
);
}
$responseHeader = '';
$result = array('isvalid'=>'false', 'error'=>'');
$remote_url = parse_url(self::RECAPTCHA_VERIFY_SERVER);
$httpQuery = http_build_query($data);
$requestHeader = sprintf(
self::RECAPTCHA_HEADER,
$remote_url['path'],
$remote_url['host'],
strlen($httpQuery),
$httpQuery);
if ( function_exists('fsockopen') ) {
$handler = @fsockopen($remote_url['host'], 80, $errno, $errstr, $this->timeout);
if( false == ( $handler ) ) {
throw new CaptchaException(
sprintf('Could not open sock to check reCAPTCHA at %s.', self::RECAPTCHA_VERIFY_SERVER)
);
}
stream_set_timeout($handler, $this->timeout);
fwrite($handler, $requestHeader);
$remote_response = stream_get_line($handler, 32, "\n");
if (strpos($remote_response, '200 OK') !== false) {
while (!feof($handler)) {
$responseHeader .= stream_get_line($handler, 356);
}
fclose($handler);
$responseHeader = str_replace("\r\n", "\n", $responseHeader);
$responseHeader = explode("\n\n", $responseHeader);
array_shift($responseHeader);
$responseHeader = explode("\n", implode("\n\n", $responseHeader));
}
// Fallback to CURL if fsockopen is not enabled
} elseif ( extension_loaded('curl') ) {
$ch = curl_init(self::RECAPTCHA_VERIFY_SERVER);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->timeout);
curl_setopt($ch, CURLOPT_USERAGENT, 'reCAPTCHA/PHP');
curl_setopt($ch, CURLOPT_HTTPHEADER, explode("\r\n", $requestHeader) );
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $httpQuery);
$responseHeader = curl_exec($ch);
curl_close($ch);
if ($responseHeader !== false) {
$responseHeader = explode("\n\n", $responseHeader);
$responseHeader = explode("\n", implode("\n\n", $responseHeader));
}
} else {
throw new CaptchaException(
sprintf('Can\'t connect to the server %s. Try again.', self::RECAPTCHA_VERIFY_SERVER )
);
}
$result = ( count($responseHeader) == 2 )
? array_combine(array_keys($result), $responseHeader)
: $result;
return $result;
} | php | protected function _postHttpChallenge(array $data)
{
if ( strlen($this->_privateKey) == 0 ) {
throw new CaptchaException(
'To use reCAPTCHA you must get a Private API key from https://www.google.com/recaptcha/admin'
);
}
$responseHeader = '';
$result = array('isvalid'=>'false', 'error'=>'');
$remote_url = parse_url(self::RECAPTCHA_VERIFY_SERVER);
$httpQuery = http_build_query($data);
$requestHeader = sprintf(
self::RECAPTCHA_HEADER,
$remote_url['path'],
$remote_url['host'],
strlen($httpQuery),
$httpQuery);
if ( function_exists('fsockopen') ) {
$handler = @fsockopen($remote_url['host'], 80, $errno, $errstr, $this->timeout);
if( false == ( $handler ) ) {
throw new CaptchaException(
sprintf('Could not open sock to check reCAPTCHA at %s.', self::RECAPTCHA_VERIFY_SERVER)
);
}
stream_set_timeout($handler, $this->timeout);
fwrite($handler, $requestHeader);
$remote_response = stream_get_line($handler, 32, "\n");
if (strpos($remote_response, '200 OK') !== false) {
while (!feof($handler)) {
$responseHeader .= stream_get_line($handler, 356);
}
fclose($handler);
$responseHeader = str_replace("\r\n", "\n", $responseHeader);
$responseHeader = explode("\n\n", $responseHeader);
array_shift($responseHeader);
$responseHeader = explode("\n", implode("\n\n", $responseHeader));
}
// Fallback to CURL if fsockopen is not enabled
} elseif ( extension_loaded('curl') ) {
$ch = curl_init(self::RECAPTCHA_VERIFY_SERVER);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->timeout);
curl_setopt($ch, CURLOPT_USERAGENT, 'reCAPTCHA/PHP');
curl_setopt($ch, CURLOPT_HTTPHEADER, explode("\r\n", $requestHeader) );
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $httpQuery);
$responseHeader = curl_exec($ch);
curl_close($ch);
if ($responseHeader !== false) {
$responseHeader = explode("\n\n", $responseHeader);
$responseHeader = explode("\n", implode("\n\n", $responseHeader));
}
} else {
throw new CaptchaException(
sprintf('Can\'t connect to the server %s. Try again.', self::RECAPTCHA_VERIFY_SERVER )
);
}
$result = ( count($responseHeader) == 2 )
? array_combine(array_keys($result), $responseHeader)
: $result;
return $result;
} | [
"protected",
"function",
"_postHttpChallenge",
"(",
"array",
"$",
"data",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"this",
"->",
"_privateKey",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"CaptchaException",
"(",
"'To use reCAPTCHA you must get a Private API key fro... | reCAPTCHA API Request
Post reCAPTCHA input challenge, response
Uses function fsockopen() and curl() as a fallback
If both functions are unavailable in server configuration
an {@link \ReCaptcha\CaptchaException} exception will be thrown
@param array $data Array of reCAPTCHA parameters
@throws \ReCaptcha\CaptchaException
@return array | [
"reCAPTCHA",
"API",
"Request"
] | 0875e6deab68b9949033417d10db4d2aefeccdcb | https://github.com/adrianorsouza/reCAPTCHA-lib/blob/0875e6deab68b9949033417d10db4d2aefeccdcb/lib/ReCaptcha/Captcha.php#L311-L395 | train |
adrianorsouza/reCAPTCHA-lib | lib/ReCaptcha/Captcha.php | Captcha._buildServerURI | private function _buildServerURI($path = 'challenge')
{
// Scheme
$uri = ( TRUE === $this->_ssl ) ? 'https://' : 'http://';
// Host
$uri .= self::RECAPTCHA_API_SERVER;
// Path
$uri .= ($path !== 'challenge') ? 'noscript' : $path;
// Query
$uri .= '?k=' . $this->_publicKey;
$uri .= ($this->_error) ? '&error=' . $this->_error : NULL;
$uri .= ( isset($this->_recaptchaOptions['lang']) ) ? '&hl=' . $this->_recaptchaOptions['lang'] : '&hl=' .$this->clientLang();
return $uri;
} | php | private function _buildServerURI($path = 'challenge')
{
// Scheme
$uri = ( TRUE === $this->_ssl ) ? 'https://' : 'http://';
// Host
$uri .= self::RECAPTCHA_API_SERVER;
// Path
$uri .= ($path !== 'challenge') ? 'noscript' : $path;
// Query
$uri .= '?k=' . $this->_publicKey;
$uri .= ($this->_error) ? '&error=' . $this->_error : NULL;
$uri .= ( isset($this->_recaptchaOptions['lang']) ) ? '&hl=' . $this->_recaptchaOptions['lang'] : '&hl=' .$this->clientLang();
return $uri;
} | [
"private",
"function",
"_buildServerURI",
"(",
"$",
"path",
"=",
"'challenge'",
")",
"{",
"// Scheme",
"$",
"uri",
"=",
"(",
"TRUE",
"===",
"$",
"this",
"->",
"_ssl",
")",
"?",
"'https://'",
":",
"'http://'",
";",
"// Host",
"$",
"uri",
".=",
"self",
"... | Build API server URI
@param string $path The path whether is noscript for iframe or not
@return string
@deprecated will be remove in major release v1.0.0 | [
"Build",
"API",
"server",
"URI"
] | 0875e6deab68b9949033417d10db4d2aefeccdcb | https://github.com/adrianorsouza/reCAPTCHA-lib/blob/0875e6deab68b9949033417d10db4d2aefeccdcb/lib/ReCaptcha/Captcha.php#L436-L450 | train |
FastFeed/FastFeed | src/Parser/RSSParser.php | RSSParser.getNodes | public function getNodes($content)
{
$items = array();
$document = $this->createDocumentFromXML($content);
$nodes = $document->getElementsByTagName('item');
if ($nodes->length) {
foreach ($nodes as $node) {
try {
$item = $this->create($node);
$items[] = $item;
} catch (\Exception $e) {
throw new RuntimeException($e->getMessage());
}
}
}
return $items;
} | php | public function getNodes($content)
{
$items = array();
$document = $this->createDocumentFromXML($content);
$nodes = $document->getElementsByTagName('item');
if ($nodes->length) {
foreach ($nodes as $node) {
try {
$item = $this->create($node);
$items[] = $item;
} catch (\Exception $e) {
throw new RuntimeException($e->getMessage());
}
}
}
return $items;
} | [
"public",
"function",
"getNodes",
"(",
"$",
"content",
")",
"{",
"$",
"items",
"=",
"array",
"(",
")",
";",
"$",
"document",
"=",
"$",
"this",
"->",
"createDocumentFromXML",
"(",
"$",
"content",
")",
";",
"$",
"nodes",
"=",
"$",
"document",
"->",
"ge... | Retrieve a Items's array
@param $content
@return array
@throws \FastFeed\Exception\RuntimeException | [
"Retrieve",
"a",
"Items",
"s",
"array"
] | 2c8fbf91d37969b61fadefb4d647f2a366159c88 | https://github.com/FastFeed/FastFeed/blob/2c8fbf91d37969b61fadefb4d647f2a366159c88/src/Parser/RSSParser.php#L35-L52 | train |
Divergence/framework | src/Models/Relations.php | Relations._defineRelationships | protected static function _defineRelationships()
{
$className = get_called_class();
$classes = class_parents($className);
array_unshift($classes, $className);
static::$_classRelationships[$className] = [];
while ($class = array_pop($classes)) {
if (!empty($class::$relationships)) {
static::$_classRelationships[$className] = array_merge(static::$_classRelationships[$className], $class::$relationships);
}
if (static::isVersioned() && !empty($class::$versioningRelationships)) {
static::$_classRelationships[$className] = array_merge(static::$_classRelationships[$className], $class::$versioningRelationships);
}
}
} | php | protected static function _defineRelationships()
{
$className = get_called_class();
$classes = class_parents($className);
array_unshift($classes, $className);
static::$_classRelationships[$className] = [];
while ($class = array_pop($classes)) {
if (!empty($class::$relationships)) {
static::$_classRelationships[$className] = array_merge(static::$_classRelationships[$className], $class::$relationships);
}
if (static::isVersioned() && !empty($class::$versioningRelationships)) {
static::$_classRelationships[$className] = array_merge(static::$_classRelationships[$className], $class::$versioningRelationships);
}
}
} | [
"protected",
"static",
"function",
"_defineRelationships",
"(",
")",
"{",
"$",
"className",
"=",
"get_called_class",
"(",
")",
";",
"$",
"classes",
"=",
"class_parents",
"(",
"$",
"className",
")",
";",
"array_unshift",
"(",
"$",
"classes",
",",
"$",
"classN... | Called when anything relationships related is used for the first time to define relationships before _initRelationships | [
"Called",
"when",
"anything",
"relationships",
"related",
"is",
"used",
"for",
"the",
"first",
"time",
"to",
"define",
"relationships",
"before",
"_initRelationships"
] | daaf78aa4b10ad59bf52b9e31480c748ad82e8c3 | https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/Relations.php#L41-L55 | train |
Divergence/framework | src/Models/Relations.php | Relations._initRelationships | protected static function _initRelationships()
{
$className = get_called_class();
if (!empty(static::$_classRelationships[$className])) {
$relationships = [];
foreach (static::$_classRelationships[$className] as $relationship => $options) {
if (is_array($options)) {
$relationships[$relationship] = static::_initRelationship($relationship, $options);
}
}
static::$_classRelationships[$className] = $relationships;
}
} | php | protected static function _initRelationships()
{
$className = get_called_class();
if (!empty(static::$_classRelationships[$className])) {
$relationships = [];
foreach (static::$_classRelationships[$className] as $relationship => $options) {
if (is_array($options)) {
$relationships[$relationship] = static::_initRelationship($relationship, $options);
}
}
static::$_classRelationships[$className] = $relationships;
}
} | [
"protected",
"static",
"function",
"_initRelationships",
"(",
")",
"{",
"$",
"className",
"=",
"get_called_class",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"static",
"::",
"$",
"_classRelationships",
"[",
"$",
"className",
"]",
")",
")",
"{",
"$",
"r... | Called after _defineRelationships to initialize and apply defaults to the relationships property
Must be idempotent as it may be applied multiple times up the inheritence chain | [
"Called",
"after",
"_defineRelationships",
"to",
"initialize",
"and",
"apply",
"defaults",
"to",
"the",
"relationships",
"property",
"Must",
"be",
"idempotent",
"as",
"it",
"may",
"be",
"applied",
"multiple",
"times",
"up",
"the",
"inheritence",
"chain"
] | daaf78aa4b10ad59bf52b9e31480c748ad82e8c3 | https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/Relations.php#L62-L74 | train |
Divergence/framework | src/Models/RecordValidator.php | RecordValidator.resolveValue | protected function resolveValue($field)
{
$cur = &$this->_record;
if (array_key_exists($field, $cur)) {
$cur = &$cur[$field];
} else {
return null;
}
return $cur;
} | php | protected function resolveValue($field)
{
$cur = &$this->_record;
if (array_key_exists($field, $cur)) {
$cur = &$cur[$field];
} else {
return null;
}
return $cur;
} | [
"protected",
"function",
"resolveValue",
"(",
"$",
"field",
")",
"{",
"$",
"cur",
"=",
"&",
"$",
"this",
"->",
"_record",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"field",
",",
"$",
"cur",
")",
")",
"{",
"$",
"cur",
"=",
"&",
"$",
"cur",
"["... | protected instance methods | [
"protected",
"instance",
"methods"
] | daaf78aa4b10ad59bf52b9e31480c748ad82e8c3 | https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/RecordValidator.php#L153-L162 | train |
asinfotrack/yii2-comments | behaviors/CommentsBehavior.php | CommentsBehavior.getComments | public function getComments($newestFirst=true, $limit=null, $offset=null)
{
$query = Comment::find()->subject($this->owner);
$query->orderNewestFirst($newestFirst);
if ($limit !== null) $query->limit($limit);
if ($offset !== null) $query->offset($offset);
return $query->all();
} | php | public function getComments($newestFirst=true, $limit=null, $offset=null)
{
$query = Comment::find()->subject($this->owner);
$query->orderNewestFirst($newestFirst);
if ($limit !== null) $query->limit($limit);
if ($offset !== null) $query->offset($offset);
return $query->all();
} | [
"public",
"function",
"getComments",
"(",
"$",
"newestFirst",
"=",
"true",
",",
"$",
"limit",
"=",
"null",
",",
"$",
"offset",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"Comment",
"::",
"find",
"(",
")",
"->",
"subject",
"(",
"$",
"this",
"->",
"ow... | Fetches comments related to the owner of this behavior
@param bool $newestFirst if true, the newest records will be first (default: true)
@param integer $limit the max number of comments to return (default: all)
@param integer $offset the offset to start from (default: no offset)
@return \asinfotrack\yii2\comments\models\Comment[] the comments | [
"Fetches",
"comments",
"related",
"to",
"the",
"owner",
"of",
"this",
"behavior"
] | 8f3b1ea239a4e940bc32472d16fb09c2b71135f7 | https://github.com/asinfotrack/yii2-comments/blob/8f3b1ea239a4e940bc32472d16fb09c2b71135f7/behaviors/CommentsBehavior.php#L47-L56 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/pattern/PatternFileTree.php | PatternFileTree.getImageSizeList | protected function getImageSizeList()
{
$arrSizes = \System::getContainer()->get('contao.image.image_sizes')->getAllOptions();
if (is_array($arrList = \StringUtil::deserialize($this->sizeList)))
{
$arrSizes['image_sizes'] = array_intersect_key($arrSizes['image_sizes'], array_flip($arrList));
}
else
{
$arrSizes['image_sizes'] = array();
}
if ($this->canEnterSize)
{
return $arrSizes;
}
return $arrSizes['image_sizes'];
} | php | protected function getImageSizeList()
{
$arrSizes = \System::getContainer()->get('contao.image.image_sizes')->getAllOptions();
if (is_array($arrList = \StringUtil::deserialize($this->sizeList)))
{
$arrSizes['image_sizes'] = array_intersect_key($arrSizes['image_sizes'], array_flip($arrList));
}
else
{
$arrSizes['image_sizes'] = array();
}
if ($this->canEnterSize)
{
return $arrSizes;
}
return $arrSizes['image_sizes'];
} | [
"protected",
"function",
"getImageSizeList",
"(",
")",
"{",
"$",
"arrSizes",
"=",
"\\",
"System",
"::",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'contao.image.image_sizes'",
")",
"->",
"getAllOptions",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"a... | Get a list of image sizes | [
"Get",
"a",
"list",
"of",
"image",
"sizes"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/pattern/PatternFileTree.php#L634-L653 | train |
LostKobrakai/Migrations | classes/Migration.php | Migration.eachPageUncache | protected function eachPageUncache($selector, callable $callback)
{
$num = 0;
$id = 0;
while (true) {
$p = $this->pages->get("{$selector}, id>$id");
if(!$id = $p->id) break;
$callback($p);
$this->pages->uncacheAll($p);
$num++;
}
return $num;
} | php | protected function eachPageUncache($selector, callable $callback)
{
$num = 0;
$id = 0;
while (true) {
$p = $this->pages->get("{$selector}, id>$id");
if(!$id = $p->id) break;
$callback($p);
$this->pages->uncacheAll($p);
$num++;
}
return $num;
} | [
"protected",
"function",
"eachPageUncache",
"(",
"$",
"selector",
",",
"callable",
"$",
"callback",
")",
"{",
"$",
"num",
"=",
"0",
";",
"$",
"id",
"=",
"0",
";",
"while",
"(",
"true",
")",
"{",
"$",
"p",
"=",
"$",
"this",
"->",
"pages",
"->",
"g... | Cycle over a group of pages without running into memory exhaustion
@param string $selector
@param callable $callback
@return int $num | [
"Cycle",
"over",
"a",
"group",
"of",
"pages",
"without",
"running",
"into",
"memory",
"exhaustion"
] | 54972f8c0c45e9dc8710845f61f32cb70af3e72d | https://github.com/LostKobrakai/Migrations/blob/54972f8c0c45e9dc8710845f61f32cb70af3e72d/classes/Migration.php#L18-L30 | train |
LostKobrakai/Migrations | classes/Migration.php | Migration.insertIntoTemplate | protected function insertIntoTemplate ($template, $field, $reference = null, $after = true)
{
$template = $this->getTemplate($template);
$fieldgroup = $template->fieldgroup;
$method = $after ? 'insertAfter' : 'insertBefore';
$field = $this->getField($field);
// Get reference if supplied
if($reference instanceof Field)
$reference = $fieldgroup->get($reference->name);
else if(is_string($reference))
$reference = $fieldgroup->get($reference);
// Insert field or append
if($reference instanceof Field)
$fieldgroup->$method($field, $reference);
else
$fieldgroup->append($field);
$fieldgroup->save();
} | php | protected function insertIntoTemplate ($template, $field, $reference = null, $after = true)
{
$template = $this->getTemplate($template);
$fieldgroup = $template->fieldgroup;
$method = $after ? 'insertAfter' : 'insertBefore';
$field = $this->getField($field);
// Get reference if supplied
if($reference instanceof Field)
$reference = $fieldgroup->get($reference->name);
else if(is_string($reference))
$reference = $fieldgroup->get($reference);
// Insert field or append
if($reference instanceof Field)
$fieldgroup->$method($field, $reference);
else
$fieldgroup->append($field);
$fieldgroup->save();
} | [
"protected",
"function",
"insertIntoTemplate",
"(",
"$",
"template",
",",
"$",
"field",
",",
"$",
"reference",
"=",
"null",
",",
"$",
"after",
"=",
"true",
")",
"{",
"$",
"template",
"=",
"$",
"this",
"->",
"getTemplate",
"(",
"$",
"template",
")",
";"... | Insert a field into a template optionally at a specific position.
@param Template|string $template
@param Field|string $field
@param Field|string|null $reference
@param bool $after
@throws WireException | [
"Insert",
"a",
"field",
"into",
"a",
"template",
"optionally",
"at",
"a",
"specific",
"position",
"."
] | 54972f8c0c45e9dc8710845f61f32cb70af3e72d | https://github.com/LostKobrakai/Migrations/blob/54972f8c0c45e9dc8710845f61f32cb70af3e72d/classes/Migration.php#L41-L62 | train |
LostKobrakai/Migrations | classes/Migration.php | Migration.removeFromTemplate | protected function removeFromTemplate($template, $field) {
$t = $this->getTemplate($template);
$f = $this->getField($field);
$success = $t->fieldgroup->remove($f);
$t->fieldgroup->save();
return $success;
} | php | protected function removeFromTemplate($template, $field) {
$t = $this->getTemplate($template);
$f = $this->getField($field);
$success = $t->fieldgroup->remove($f);
$t->fieldgroup->save();
return $success;
} | [
"protected",
"function",
"removeFromTemplate",
"(",
"$",
"template",
",",
"$",
"field",
")",
"{",
"$",
"t",
"=",
"$",
"this",
"->",
"getTemplate",
"(",
"$",
"template",
")",
";",
"$",
"f",
"=",
"$",
"this",
"->",
"getField",
"(",
"$",
"field",
")",
... | Removes a field from a template.
Also removes all data for that field from pages using the template.
@param Template|string $template
@param Field|string $field
@return bool $success (true => success, false => failure)
@throws WireException | [
"Removes",
"a",
"field",
"from",
"a",
"template",
".",
"Also",
"removes",
"all",
"data",
"for",
"that",
"field",
"from",
"pages",
"using",
"the",
"template",
"."
] | 54972f8c0c45e9dc8710845f61f32cb70af3e72d | https://github.com/LostKobrakai/Migrations/blob/54972f8c0c45e9dc8710845f61f32cb70af3e72d/classes/Migration.php#L73-L79 | train |
LostKobrakai/Migrations | classes/Migration.php | Migration.editInTemplateContext | protected function editInTemplateContext ($template, $field, callable $callback)
{
$template = $this->getTemplate($template);
$fieldgroup = $template->fieldgroup;
$field = $this->getField($field);
$context = $fieldgroup->getField($field->name, true);
$callback($context, $template);
$this->fields->saveFieldgroupContext($context, $fieldgroup);
} | php | protected function editInTemplateContext ($template, $field, callable $callback)
{
$template = $this->getTemplate($template);
$fieldgroup = $template->fieldgroup;
$field = $this->getField($field);
$context = $fieldgroup->getField($field->name, true);
$callback($context, $template);
$this->fields->saveFieldgroupContext($context, $fieldgroup);
} | [
"protected",
"function",
"editInTemplateContext",
"(",
"$",
"template",
",",
"$",
"field",
",",
"callable",
"$",
"callback",
")",
"{",
"$",
"template",
"=",
"$",
"this",
"->",
"getTemplate",
"(",
"$",
"template",
")",
";",
"$",
"fieldgroup",
"=",
"$",
"t... | Edit a field in template context
@param Template|string $template
@param Field|string $field
@param callable $callback | [
"Edit",
"a",
"field",
"in",
"template",
"context"
] | 54972f8c0c45e9dc8710845f61f32cb70af3e72d | https://github.com/LostKobrakai/Migrations/blob/54972f8c0c45e9dc8710845f61f32cb70af3e72d/classes/Migration.php#L88-L97 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/dca/tl_pattern.php | tl_pattern.setPickerOptions | public function setPickerOptions($value, $dc)
{
$db = Database::getInstance();
switch ($value)
{
case 'datetime':
if (!in_array($dc->activeRecord->rgxp, array('date', 'time', 'datim')))
{
// Change rgxp in database
$db->prepare("UPDATE " . $this->table . " SET rgxp=? WHERE id=?")
->execute('date', $dc->activeRecord->id);
}
if ($dc->activeRecord->multiple)
{
// Reset multiple in database
$db->prepare("UPDATE " . $this->table . " SET multiple=? WHERE id=?")
->execute('', $dc->activeRecord->id);
}
break;
case 'color':
if (!in_array($dc->activeRecord->rgxp, array('alnum', 'extnd')))
{
// Change rgxp in database
$db->prepare("UPDATE " . $this->table . " SET rgxp=? WHERE id=?")
->execute('', $dc->activeRecord->id);
}
break;
case 'link':
if ($dc->activeRecord->rgxp != 'url')
{
// Change rgxp in database
$db->prepare("UPDATE " . $this->table . " SET rgxp=? WHERE id=?")
->execute('url', $dc->activeRecord->id);
}
if ($dc->activeRecord->multiple)
{
// Reset multiple in database
$db->prepare("UPDATE " . $this->table . " SET multiple=? WHERE id=?")
->execute('', $dc->activeRecord->id);
}
break;
case 'unit':
if ($dc->activeRecord->maxLength > 200)
{
// Change maxLength in database
$db->prepare("UPDATE " . $this->table . " SET maxLength=? WHERE id=?")
->execute(200, $dc->activeRecord->id);
}
if ($dc->activeRecord->multiple)
{
// Change multiple in database
$db->prepare("UPDATE " . $this->table . " SET multiple=? WHERE id=?")
->execute('', $dc->activeRecord->id);
}
break;
}
return $value;
} | php | public function setPickerOptions($value, $dc)
{
$db = Database::getInstance();
switch ($value)
{
case 'datetime':
if (!in_array($dc->activeRecord->rgxp, array('date', 'time', 'datim')))
{
// Change rgxp in database
$db->prepare("UPDATE " . $this->table . " SET rgxp=? WHERE id=?")
->execute('date', $dc->activeRecord->id);
}
if ($dc->activeRecord->multiple)
{
// Reset multiple in database
$db->prepare("UPDATE " . $this->table . " SET multiple=? WHERE id=?")
->execute('', $dc->activeRecord->id);
}
break;
case 'color':
if (!in_array($dc->activeRecord->rgxp, array('alnum', 'extnd')))
{
// Change rgxp in database
$db->prepare("UPDATE " . $this->table . " SET rgxp=? WHERE id=?")
->execute('', $dc->activeRecord->id);
}
break;
case 'link':
if ($dc->activeRecord->rgxp != 'url')
{
// Change rgxp in database
$db->prepare("UPDATE " . $this->table . " SET rgxp=? WHERE id=?")
->execute('url', $dc->activeRecord->id);
}
if ($dc->activeRecord->multiple)
{
// Reset multiple in database
$db->prepare("UPDATE " . $this->table . " SET multiple=? WHERE id=?")
->execute('', $dc->activeRecord->id);
}
break;
case 'unit':
if ($dc->activeRecord->maxLength > 200)
{
// Change maxLength in database
$db->prepare("UPDATE " . $this->table . " SET maxLength=? WHERE id=?")
->execute(200, $dc->activeRecord->id);
}
if ($dc->activeRecord->multiple)
{
// Change multiple in database
$db->prepare("UPDATE " . $this->table . " SET multiple=? WHERE id=?")
->execute('', $dc->activeRecord->id);
}
break;
}
return $value;
} | [
"public",
"function",
"setPickerOptions",
"(",
"$",
"value",
",",
"$",
"dc",
")",
"{",
"$",
"db",
"=",
"Database",
"::",
"getInstance",
"(",
")",
";",
"switch",
"(",
"$",
"value",
")",
"{",
"case",
"'datetime'",
":",
"if",
"(",
"!",
"in_array",
"(",
... | Adjust maxlength and multiple settings according to the rgxp settings
@param mixed $value
@param DataContainer $dc
@return mixed | [
"Adjust",
"maxlength",
"and",
"multiple",
"settings",
"according",
"to",
"the",
"rgxp",
"settings"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/dca/tl_pattern.php#L701-L764 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/dca/tl_pattern.php | tl_pattern.setMultipleOption | public function setMultipleOption($value, $dc)
{
$db = Database::getInstance();
if ($value > 3 && $dc->activeRecord->maxLength > 200)
{
// change maxLegth in database
$db->prepare("UPDATE " . $this->table . " SET maxLength=? WHERE id=?")
->execute(200, $dc->activeRecord->id);
}
return $value;
} | php | public function setMultipleOption($value, $dc)
{
$db = Database::getInstance();
if ($value > 3 && $dc->activeRecord->maxLength > 200)
{
// change maxLegth in database
$db->prepare("UPDATE " . $this->table . " SET maxLength=? WHERE id=?")
->execute(200, $dc->activeRecord->id);
}
return $value;
} | [
"public",
"function",
"setMultipleOption",
"(",
"$",
"value",
",",
"$",
"dc",
")",
"{",
"$",
"db",
"=",
"Database",
"::",
"getInstance",
"(",
")",
";",
"if",
"(",
"$",
"value",
">",
"3",
"&&",
"$",
"dc",
"->",
"activeRecord",
"->",
"maxLength",
">",
... | Reduce the maxLength for 4 input fields
@param mixed $value
@param DataContainer $dc
@return mixed | [
"Reduce",
"the",
"maxLength",
"for",
"4",
"input",
"fields"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/dca/tl_pattern.php#L774-L786 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/dca/tl_pattern.php | tl_pattern.setSourceOptions | public function setSourceOptions($value, $dc)
{
$db = Database::getInstance();
if ($value == 'video' || $value == 'audio')
{
if (!$dc->activeRecord->multiSource)
{
// Change multiSource in database
$db->prepare("UPDATE " . $this->table . " SET multiSource=? WHERE id=?")
->execute(1, $dc->activeRecord->id);
}
if ($dc->activeRecord->sortBy != 'html5media')
{
// Change sortBy in database
$db->prepare("UPDATE " . $this->table . " SET sortBy=? WHERE id=?")
->execute('html5media', $dc->activeRecord->id);
}
if ($dc->activeRecord->canChangeSortBy)
{
// Change canChangeSortBy in database
$db->prepare("UPDATE " . $this->table . " SET canChangeSortBy=? WHERE id=?")
->execute(0, $dc->activeRecord->id);
}
}
return $value;
} | php | public function setSourceOptions($value, $dc)
{
$db = Database::getInstance();
if ($value == 'video' || $value == 'audio')
{
if (!$dc->activeRecord->multiSource)
{
// Change multiSource in database
$db->prepare("UPDATE " . $this->table . " SET multiSource=? WHERE id=?")
->execute(1, $dc->activeRecord->id);
}
if ($dc->activeRecord->sortBy != 'html5media')
{
// Change sortBy in database
$db->prepare("UPDATE " . $this->table . " SET sortBy=? WHERE id=?")
->execute('html5media', $dc->activeRecord->id);
}
if ($dc->activeRecord->canChangeSortBy)
{
// Change canChangeSortBy in database
$db->prepare("UPDATE " . $this->table . " SET canChangeSortBy=? WHERE id=?")
->execute(0, $dc->activeRecord->id);
}
}
return $value;
} | [
"public",
"function",
"setSourceOptions",
"(",
"$",
"value",
",",
"$",
"dc",
")",
"{",
"$",
"db",
"=",
"Database",
"::",
"getInstance",
"(",
")",
";",
"if",
"(",
"$",
"value",
"==",
"'video'",
"||",
"$",
"value",
"==",
"'audio'",
")",
"{",
"if",
"(... | Adjust multiSource and sortBy according to the source type
@param mixed $value
@param DataContainer $dc
@return mixed | [
"Adjust",
"multiSource",
"and",
"sortBy",
"according",
"to",
"the",
"source",
"type"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/dca/tl_pattern.php#L797-L824 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/dca/tl_pattern.php | tl_pattern.getPattern | public function getPattern($dc)
{
$pattern = array();
foreach ($GLOBALS['TL_CTP'] as $k=>$v)
{
foreach ($v as $kk=>$vv)
{
if (!$vv['unique'])
{
$pattern[$k][] = $kk;
}
elseif (\PatternModel::countByPidAndType($dc->activeRecord->pid, $kk) < 1 || $dc->activeRecord->type == $kk)
{
$pattern[$k][] = $kk;
}
}
}
return $pattern;
} | php | public function getPattern($dc)
{
$pattern = array();
foreach ($GLOBALS['TL_CTP'] as $k=>$v)
{
foreach ($v as $kk=>$vv)
{
if (!$vv['unique'])
{
$pattern[$k][] = $kk;
}
elseif (\PatternModel::countByPidAndType($dc->activeRecord->pid, $kk) < 1 || $dc->activeRecord->type == $kk)
{
$pattern[$k][] = $kk;
}
}
}
return $pattern;
} | [
"public",
"function",
"getPattern",
"(",
"$",
"dc",
")",
"{",
"$",
"pattern",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"GLOBALS",
"[",
"'TL_CTP'",
"]",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"foreach",
"(",
"$",
"v",
"as",
"$",
"kk"... | Return content pattern as array
@param DataContainer $dc
@return array | [
"Return",
"content",
"pattern",
"as",
"array"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/dca/tl_pattern.php#L834-L855 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/dca/tl_pattern.php | tl_pattern.saveGroups | public function saveGroups ($dc)
{
$db = Database::getInstance();
// Change predefined groups
if ($dc->activeRecord->type == 'protection' && !$dc->activeRecord->canChangeGroups)
{
// Serialize array if not
$groups = is_array($dc->activeRecord->groups) ? serialize($dc->activeRecord->groups) : $dc->activeRecord->groups;
// Save alias to database
$db->prepare("UPDATE tl_content SET groups=? WHERE type=(SELECT alias FROM tl_elements WHERE id=?)")
->execute($groups, $dc->activeRecord->pid);
}
} | php | public function saveGroups ($dc)
{
$db = Database::getInstance();
// Change predefined groups
if ($dc->activeRecord->type == 'protection' && !$dc->activeRecord->canChangeGroups)
{
// Serialize array if not
$groups = is_array($dc->activeRecord->groups) ? serialize($dc->activeRecord->groups) : $dc->activeRecord->groups;
// Save alias to database
$db->prepare("UPDATE tl_content SET groups=? WHERE type=(SELECT alias FROM tl_elements WHERE id=?)")
->execute($groups, $dc->activeRecord->pid);
}
} | [
"public",
"function",
"saveGroups",
"(",
"$",
"dc",
")",
"{",
"$",
"db",
"=",
"Database",
"::",
"getInstance",
"(",
")",
";",
"// Change predefined groups",
"if",
"(",
"$",
"dc",
"->",
"activeRecord",
"->",
"type",
"==",
"'protection'",
"&&",
"!",
"$",
"... | Save group settings from the pattern to the content element
@param DataContainer $dc | [
"Save",
"group",
"settings",
"from",
"the",
"pattern",
"to",
"the",
"content",
"element"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/dca/tl_pattern.php#L903-L917 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/dca/tl_pattern.php | tl_pattern.getForms | public function getForms()
{
$arrForms = array();
$objForms = $this->Database->execute("SELECT id, title FROM tl_form ORDER BY title");
while ($objForms->next())
{
$arrForms[$objForms->id] = $objForms->title . ' (ID ' . $objForms->id . ')';
}
return $arrForms;
} | php | public function getForms()
{
$arrForms = array();
$objForms = $this->Database->execute("SELECT id, title FROM tl_form ORDER BY title");
while ($objForms->next())
{
$arrForms[$objForms->id] = $objForms->title . ' (ID ' . $objForms->id . ')';
}
return $arrForms;
} | [
"public",
"function",
"getForms",
"(",
")",
"{",
"$",
"arrForms",
"=",
"array",
"(",
")",
";",
"$",
"objForms",
"=",
"$",
"this",
"->",
"Database",
"->",
"execute",
"(",
"\"SELECT id, title FROM tl_form ORDER BY title\"",
")",
";",
"while",
"(",
"$",
"objFor... | Get forms and return them as array
@return array | [
"Get",
"forms",
"and",
"return",
"them",
"as",
"array"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/dca/tl_pattern.php#L1082-L1093 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/classes/Theme.php | Theme.exportTables | public function exportTables ($xml, $objArchive, $objThemeId)
{
// Find tables node
$tables = $xml->getElementsByTagName('tables')[0];
// Add the table (elements)
$table = $xml->createElement('table');
$table->setAttribute('name', 'tl_elements');
$table = $tables->appendChild($table);
// Load the DCA
$this->loadDataContainer('tl_elements');
// Get the order fields
$objDcaExtractor = \DcaExtractor::getInstance('tl_elements');
$arrOrder = $objDcaExtractor->getOrderFields();
// Get all content blocks
$objContentBlocks = $this->Database->prepare("SELECT * FROM tl_elements WHERE pid=?")
->execute($objThemeId);
// Add the rows
while ($objContentBlocks->next())
{
$this->addDataRow($xml, $table, $objContentBlocks->row(), $arrOrder);
}
$objContentBlocks->reset();
// Add the child table (pattern)
$table = $xml->createElement('table');
$table->setAttribute('name', 'tl_pattern');
$table = $tables->appendChild($table);
// Load the DCA
$this->loadDataContainer('tl_pattern');
// Get the order fields
$objDcaExtractor = \DcaExtractor::getInstance('tl_pattern');
$arrOrder = $objDcaExtractor->getOrderFields();
// Add pattern recursively
while ($objContentBlocks->next())
{
$this->addPatternData($xml, $table, $arrOrder, $objContentBlocks->id);
}
} | php | public function exportTables ($xml, $objArchive, $objThemeId)
{
// Find tables node
$tables = $xml->getElementsByTagName('tables')[0];
// Add the table (elements)
$table = $xml->createElement('table');
$table->setAttribute('name', 'tl_elements');
$table = $tables->appendChild($table);
// Load the DCA
$this->loadDataContainer('tl_elements');
// Get the order fields
$objDcaExtractor = \DcaExtractor::getInstance('tl_elements');
$arrOrder = $objDcaExtractor->getOrderFields();
// Get all content blocks
$objContentBlocks = $this->Database->prepare("SELECT * FROM tl_elements WHERE pid=?")
->execute($objThemeId);
// Add the rows
while ($objContentBlocks->next())
{
$this->addDataRow($xml, $table, $objContentBlocks->row(), $arrOrder);
}
$objContentBlocks->reset();
// Add the child table (pattern)
$table = $xml->createElement('table');
$table->setAttribute('name', 'tl_pattern');
$table = $tables->appendChild($table);
// Load the DCA
$this->loadDataContainer('tl_pattern');
// Get the order fields
$objDcaExtractor = \DcaExtractor::getInstance('tl_pattern');
$arrOrder = $objDcaExtractor->getOrderFields();
// Add pattern recursively
while ($objContentBlocks->next())
{
$this->addPatternData($xml, $table, $arrOrder, $objContentBlocks->id);
}
} | [
"public",
"function",
"exportTables",
"(",
"$",
"xml",
",",
"$",
"objArchive",
",",
"$",
"objThemeId",
")",
"{",
"// Find tables node",
"$",
"tables",
"=",
"$",
"xml",
"->",
"getElementsByTagName",
"(",
"'tables'",
")",
"[",
"0",
"]",
";",
"// Add the table ... | Export content blocks tables with template export | [
"Export",
"content",
"blocks",
"tables",
"with",
"template",
"export"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/classes/Theme.php#L319-L367 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/classes/Theme.php | Theme.addPatternData | protected function addPatternData ($xml, $table, $arrOrder, $intParentID)
{
// Get all content patterns
$objContentPattern = $this->Database->prepare("SELECT * FROM tl_pattern WHERE pid=?")
->execute($intParentID);
// Add the rows
while ($objContentPattern->next())
{
$this->addDataRow($xml, $table, $objContentPattern->row(), $arrOrder);
if (in_array($objContentPattern->type, $GLOBALS['TL_CTP_SUB']))
{
$this->addPatternData($xml, $table, $arrOrder, $objContentPattern->id);
}
}
} | php | protected function addPatternData ($xml, $table, $arrOrder, $intParentID)
{
// Get all content patterns
$objContentPattern = $this->Database->prepare("SELECT * FROM tl_pattern WHERE pid=?")
->execute($intParentID);
// Add the rows
while ($objContentPattern->next())
{
$this->addDataRow($xml, $table, $objContentPattern->row(), $arrOrder);
if (in_array($objContentPattern->type, $GLOBALS['TL_CTP_SUB']))
{
$this->addPatternData($xml, $table, $arrOrder, $objContentPattern->id);
}
}
} | [
"protected",
"function",
"addPatternData",
"(",
"$",
"xml",
",",
"$",
"table",
",",
"$",
"arrOrder",
",",
"$",
"intParentID",
")",
"{",
"// Get all content patterns",
"$",
"objContentPattern",
"=",
"$",
"this",
"->",
"Database",
"->",
"prepare",
"(",
"\"SELECT... | Add pattern recursively | [
"Add",
"pattern",
"recursively"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/classes/Theme.php#L373-L390 | train |
alphazygma/Combinatorics | src/Math/Combinatorics/Combination.php | Combination.getCombinations | public function getCombinations(array $sourceDataSet, $subsetSize = null)
{
// If the subset size is supplied, then just return the combinations that match such size
if (isset($subsetSize)) {
return $this->_getCombinationSubset($sourceDataSet, $subsetSize);
}
// Otherwise, we return all possible combinations
$masterCombinationSet = [];
// Calculate the combinations for all the possible lengths and add them to the master set
$sourceDataSetLength = count($sourceDataSet);
for ($i = 1; $i <= $sourceDataSetLength; $i++) {
$combinationSubset = $this->_getCombinationSubset($sourceDataSet, $i);
$masterCombinationSet = array_merge($masterCombinationSet, $combinationSubset);
}
return $masterCombinationSet;
} | php | public function getCombinations(array $sourceDataSet, $subsetSize = null)
{
// If the subset size is supplied, then just return the combinations that match such size
if (isset($subsetSize)) {
return $this->_getCombinationSubset($sourceDataSet, $subsetSize);
}
// Otherwise, we return all possible combinations
$masterCombinationSet = [];
// Calculate the combinations for all the possible lengths and add them to the master set
$sourceDataSetLength = count($sourceDataSet);
for ($i = 1; $i <= $sourceDataSetLength; $i++) {
$combinationSubset = $this->_getCombinationSubset($sourceDataSet, $i);
$masterCombinationSet = array_merge($masterCombinationSet, $combinationSubset);
}
return $masterCombinationSet;
} | [
"public",
"function",
"getCombinations",
"(",
"array",
"$",
"sourceDataSet",
",",
"$",
"subsetSize",
"=",
"null",
")",
"{",
"// If the subset size is supplied, then just return the combinations that match such size",
"if",
"(",
"isset",
"(",
"$",
"subsetSize",
")",
")",
... | Creates all the possible combinations for the source data set.
@param array $sourceDataSet The source data from which to calculate combiantions.
@param int $subsetSize (Optional)<br/>If supplied, only combinations of the indicated
size will be returned.
<p>If the subset size is greater than the source data set size, only one combination will
be returned which includes all the elements in the source data set.</p>
<p>If the subset size is less or equal to 0, only one combination will be returned with
no elements.</p>
@return array A list of arrays containing all the combinations from the source data set. | [
"Creates",
"all",
"the",
"possible",
"combinations",
"for",
"the",
"source",
"data",
"set",
"."
] | 153d096119d21190a32bbe567f1eec367e2f4709 | https://github.com/alphazygma/Combinatorics/blob/153d096119d21190a32bbe567f1eec367e2f4709/src/Math/Combinatorics/Combination.php#L61-L79 | train |
alphazygma/Combinatorics | src/Math/Combinatorics/Combination.php | Combination._getCombinationSubset | protected function _getCombinationSubset(array $sourceDataSet, $subsetSize)
{
if (!isset($subsetSize) || $subsetSize < 0) {
throw new \InvalidArgumentException('Subset size cannot be empty or less than 0');
}
$sourceSetSize = count($sourceDataSet);
if ($subsetSize >= $sourceSetSize) {
return [$sourceDataSet];
} else if ($subsetSize == 1) {
return array_chunk($sourceDataSet, 1, true);
} else if ($subsetSize == 0) {
return [];
}
$combinations = [];
$setKeys = array_keys($sourceDataSet);
$pointer = new Pointer($sourceDataSet, $subsetSize);
do {
$combinations[] = $this->_getCombination($sourceDataSet, $setKeys, $pointer);
} while ($pointer->advance());
return $combinations;
} | php | protected function _getCombinationSubset(array $sourceDataSet, $subsetSize)
{
if (!isset($subsetSize) || $subsetSize < 0) {
throw new \InvalidArgumentException('Subset size cannot be empty or less than 0');
}
$sourceSetSize = count($sourceDataSet);
if ($subsetSize >= $sourceSetSize) {
return [$sourceDataSet];
} else if ($subsetSize == 1) {
return array_chunk($sourceDataSet, 1, true);
} else if ($subsetSize == 0) {
return [];
}
$combinations = [];
$setKeys = array_keys($sourceDataSet);
$pointer = new Pointer($sourceDataSet, $subsetSize);
do {
$combinations[] = $this->_getCombination($sourceDataSet, $setKeys, $pointer);
} while ($pointer->advance());
return $combinations;
} | [
"protected",
"function",
"_getCombinationSubset",
"(",
"array",
"$",
"sourceDataSet",
",",
"$",
"subsetSize",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"subsetSize",
")",
"||",
"$",
"subsetSize",
"<",
"0",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumen... | Calculates all the combinations of a given subset size.
@param array $sourceDataSet The source data from which to calculate combiantions.
@param int $subsetSize Size of the combinations to calculate
@return array
@throws \InvalidArgumentException if the subset size is not supplied | [
"Calculates",
"all",
"the",
"combinations",
"of",
"a",
"given",
"subset",
"size",
"."
] | 153d096119d21190a32bbe567f1eec367e2f4709 | https://github.com/alphazygma/Combinatorics/blob/153d096119d21190a32bbe567f1eec367e2f4709/src/Math/Combinatorics/Combination.php#L88-L116 | train |
alphazygma/Combinatorics | src/Math/Combinatorics/Combination.php | Combination._getCombination | private function _getCombination($sourceDataSet, $setKeyList, Pointer $pointer)
{
$combination = array();
$indexPointerList = $pointer->getPointerList();
foreach ($indexPointerList as $indexPointer) {
$namedKey = $setKeyList[$indexPointer];
$combination[$namedKey] = $sourceDataSet[$namedKey];
}
return $combination;
} | php | private function _getCombination($sourceDataSet, $setKeyList, Pointer $pointer)
{
$combination = array();
$indexPointerList = $pointer->getPointerList();
foreach ($indexPointerList as $indexPointer) {
$namedKey = $setKeyList[$indexPointer];
$combination[$namedKey] = $sourceDataSet[$namedKey];
}
return $combination;
} | [
"private",
"function",
"_getCombination",
"(",
"$",
"sourceDataSet",
",",
"$",
"setKeyList",
",",
"Pointer",
"$",
"pointer",
")",
"{",
"$",
"combination",
"=",
"array",
"(",
")",
";",
"$",
"indexPointerList",
"=",
"$",
"pointer",
"->",
"getPointerList",
"(",... | Get the combination for the current pointer positions.
@param array $sourceDataSet The source data set.
@param array $setKeyList The keys of the source data set.<br/>These can be calculated off
of the source data set, however, for performance optimization, this value can be
calculated once outside this method and thus no more memory needs to be initialized
to temporarily store this keys.
@param \Math\Set\Combination\Pointer $pointer Object that represents the indexes to
be used for the current combination
@return array A list of elements representing the combination given by the current pointers. | [
"Get",
"the",
"combination",
"for",
"the",
"current",
"pointer",
"positions",
"."
] | 153d096119d21190a32bbe567f1eec367e2f4709 | https://github.com/alphazygma/Combinatorics/blob/153d096119d21190a32bbe567f1eec367e2f4709/src/Math/Combinatorics/Combination.php#L129-L141 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/classes/Pattern.php | Pattern.generateDCA | public function generateDCA($strFieldName, $arrFieldDCA=array(), $bolVisble=true, $bolCallbacks=true)
{
$strVirtualField = $this->virtualFieldName($strFieldName);
// Add to palette
if ($bolVisble)
{
/* Using the subpalette system of the DC_TABLE not possible because of direct database check
(see https://github.com/contao/core-bundle/blob/2a85914f4ba858780ffbac38a468acb7028772c7/src/Resources/contao/drivers/DC_Table.php#L3191)
if (!empty($this->parent))
{
if (isset($GLOBALS['TL_DCA']['tl_content']['subpalettes'][$this->parent]))
{
$GLOBALS['TL_DCA']['tl_content']['subpalettes'][$this->parent] .= ',' . $strVirtualField;
}
else
{
$GLOBALS['TL_DCA']['tl_content']['palettes']['__selector__'][] = $this->parent;
$GLOBALS['TL_DCA']['tl_content']['subpalettes'][$this->parent] = $strVirtualField;
}
}
else
{
$GLOBALS['TL_DCA']['tl_content']['palettes'][$this->alias] .= ',' . $strVirtualField;
}
*/
$GLOBALS['TL_DCA']['tl_content']['palettes'][$this->element] .= ',' . $strVirtualField;
}
// Add necessary virtual field callbacks
if ($bolCallbacks)
{
$arrFieldDCA['eval']['doNotSaveEmpty'] = true;
$arrFieldDCA['load_callback'] = is_array($arrFieldDCA['load_callback']) ? $arrFieldDCA['load_callback'] : array();
$arrFieldDCA['save_callback'] = is_array($arrFieldDCA['save_callback']) ? $arrFieldDCA['save_callback'] : array();
// load default value
if ($arrFieldDCA['default'])
{
array_unshift($arrFieldDCA['load_callback'], array('tl_content_elements', 'defaultValue'));
}
// load/save database values first/last
array_unshift($arrFieldDCA['load_callback'], array('tl_content_elements', 'loadFieldValue'));
array_push($arrFieldDCA['save_callback'], array('tl_content_elements', 'saveFieldAndClear'));
}
// Virtual field data
$arrFieldDCA = array_merge($arrFieldDCA, array
(
'id' => (isset($this->data->id)) ? $this->data->id : null,
'pattern' => $this->pattern,
'parent' => (isset($this->parent)) ? $this->parent : 0,
'column' => $strFieldName,
'data' => (isset($this->data->$strFieldName)) ? $this->data->$strFieldName : null
));
// Add field informations
$GLOBALS['TL_DCA']['tl_content']['fields'][$strVirtualField] = $arrFieldDCA;
} | php | public function generateDCA($strFieldName, $arrFieldDCA=array(), $bolVisble=true, $bolCallbacks=true)
{
$strVirtualField = $this->virtualFieldName($strFieldName);
// Add to palette
if ($bolVisble)
{
/* Using the subpalette system of the DC_TABLE not possible because of direct database check
(see https://github.com/contao/core-bundle/blob/2a85914f4ba858780ffbac38a468acb7028772c7/src/Resources/contao/drivers/DC_Table.php#L3191)
if (!empty($this->parent))
{
if (isset($GLOBALS['TL_DCA']['tl_content']['subpalettes'][$this->parent]))
{
$GLOBALS['TL_DCA']['tl_content']['subpalettes'][$this->parent] .= ',' . $strVirtualField;
}
else
{
$GLOBALS['TL_DCA']['tl_content']['palettes']['__selector__'][] = $this->parent;
$GLOBALS['TL_DCA']['tl_content']['subpalettes'][$this->parent] = $strVirtualField;
}
}
else
{
$GLOBALS['TL_DCA']['tl_content']['palettes'][$this->alias] .= ',' . $strVirtualField;
}
*/
$GLOBALS['TL_DCA']['tl_content']['palettes'][$this->element] .= ',' . $strVirtualField;
}
// Add necessary virtual field callbacks
if ($bolCallbacks)
{
$arrFieldDCA['eval']['doNotSaveEmpty'] = true;
$arrFieldDCA['load_callback'] = is_array($arrFieldDCA['load_callback']) ? $arrFieldDCA['load_callback'] : array();
$arrFieldDCA['save_callback'] = is_array($arrFieldDCA['save_callback']) ? $arrFieldDCA['save_callback'] : array();
// load default value
if ($arrFieldDCA['default'])
{
array_unshift($arrFieldDCA['load_callback'], array('tl_content_elements', 'defaultValue'));
}
// load/save database values first/last
array_unshift($arrFieldDCA['load_callback'], array('tl_content_elements', 'loadFieldValue'));
array_push($arrFieldDCA['save_callback'], array('tl_content_elements', 'saveFieldAndClear'));
}
// Virtual field data
$arrFieldDCA = array_merge($arrFieldDCA, array
(
'id' => (isset($this->data->id)) ? $this->data->id : null,
'pattern' => $this->pattern,
'parent' => (isset($this->parent)) ? $this->parent : 0,
'column' => $strFieldName,
'data' => (isset($this->data->$strFieldName)) ? $this->data->$strFieldName : null
));
// Add field informations
$GLOBALS['TL_DCA']['tl_content']['fields'][$strVirtualField] = $arrFieldDCA;
} | [
"public",
"function",
"generateDCA",
"(",
"$",
"strFieldName",
",",
"$",
"arrFieldDCA",
"=",
"array",
"(",
")",
",",
"$",
"bolVisble",
"=",
"true",
",",
"$",
"bolCallbacks",
"=",
"true",
")",
"{",
"$",
"strVirtualField",
"=",
"$",
"this",
"->",
"virtualF... | Generate the DCA for a virtual input field
@param string $strFieldName The input field name
@param array $arrFieldDCA The input field DCA array
@param boolean $bolVisble Make the input field visible
@param boolean $bolCallbacks Set callbacks for the input field | [
"Generate",
"the",
"DCA",
"for",
"a",
"virtual",
"input",
"field"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/classes/Pattern.php#L114-L176 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/classes/Pattern.php | Pattern.virtualFieldName | protected function virtualFieldName($strFieldName)
{
$strVirtualField = $this->pattern . '-' . $strFieldName;
if ($this->data !== null)
{
$strVirtualField .= '-' . $this->data->id;
}
return $strVirtualField;
} | php | protected function virtualFieldName($strFieldName)
{
$strVirtualField = $this->pattern . '-' . $strFieldName;
if ($this->data !== null)
{
$strVirtualField .= '-' . $this->data->id;
}
return $strVirtualField;
} | [
"protected",
"function",
"virtualFieldName",
"(",
"$",
"strFieldName",
")",
"{",
"$",
"strVirtualField",
"=",
"$",
"this",
"->",
"pattern",
".",
"'-'",
".",
"$",
"strFieldName",
";",
"if",
"(",
"$",
"this",
"->",
"data",
"!==",
"null",
")",
"{",
"$",
"... | Generate a field alias with the right syntax
@param string $strName The field name
@return string The field alias | [
"Generate",
"a",
"field",
"alias",
"with",
"the",
"right",
"syntax"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/classes/Pattern.php#L186-L196 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/classes/Pattern.php | Pattern.writeToTemplate | public function writeToTemplate($value)
{
if (is_array($this->arrMapper))
{
$arrValue[$this->arrMapper[0]] = $this->Template->{$this->arrMapper[0]};
$map =& $arrValue;
foreach ($this->arrMapper as $key)
{
if (!is_array($map[$key]))
{
$map[$key] = array();
}
$map =& $map[$key];
}
$map[$this->alias] = $value;
$this->Template->{$this->arrMapper[0]} = $arrValue[$this->arrMapper[0]];
return;
}
$this->Template->{$this->alias} = $value;
} | php | public function writeToTemplate($value)
{
if (is_array($this->arrMapper))
{
$arrValue[$this->arrMapper[0]] = $this->Template->{$this->arrMapper[0]};
$map =& $arrValue;
foreach ($this->arrMapper as $key)
{
if (!is_array($map[$key]))
{
$map[$key] = array();
}
$map =& $map[$key];
}
$map[$this->alias] = $value;
$this->Template->{$this->arrMapper[0]} = $arrValue[$this->arrMapper[0]];
return;
}
$this->Template->{$this->alias} = $value;
} | [
"public",
"function",
"writeToTemplate",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"arrMapper",
")",
")",
"{",
"$",
"arrValue",
"[",
"$",
"this",
"->",
"arrMapper",
"[",
"0",
"]",
"]",
"=",
"$",
"this",
"->",
"Temp... | Write a value to the template
@param mixed $value The value to be written to the template | [
"Write",
"a",
"value",
"to",
"the",
"template"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/classes/Pattern.php#L224-L250 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/classes/Pattern.php | Pattern.hasData | public static function hasData($strName)
{
foreach ($GLOBALS['TL_CTP'] as $v)
{
foreach ($v as $kk=>$vv)
{
if ($kk == $strName)
{
return ($vv['data']) ?:false;
}
}
}
return null;
} | php | public static function hasData($strName)
{
foreach ($GLOBALS['TL_CTP'] as $v)
{
foreach ($v as $kk=>$vv)
{
if ($kk == $strName)
{
return ($vv['data']) ?:false;
}
}
}
return null;
} | [
"public",
"static",
"function",
"hasData",
"(",
"$",
"strName",
")",
"{",
"foreach",
"(",
"$",
"GLOBALS",
"[",
"'TL_CTP'",
"]",
"as",
"$",
"v",
")",
"{",
"foreach",
"(",
"$",
"v",
"as",
"$",
"kk",
"=>",
"$",
"vv",
")",
"{",
"if",
"(",
"$",
"kk"... | Check if a pattern saves data to the database
@param string $strName The pattern name
@return boolean Returns true if the pattern saves data to the db | [
"Check",
"if",
"a",
"pattern",
"saves",
"data",
"to",
"the",
"database"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/classes/Pattern.php#L284-L298 | train |
dynamic/foxystripe | thirdparty/rc4crypt.php | rc4crypt.encrypt | static function encrypt ($pwd, $data, $ispwdHex = 0)
{
if ($ispwdHex)
$pwd = @pack('H*', $pwd); // valid input, please!
$key[] = '';
$box[] = '';
$cipher = '';
$pwd_length = strlen($pwd);
$data_length = strlen($data);
for ($i = 0; $i < 256; $i++)
{
$key[$i] = ord($pwd[$i % $pwd_length]);
$box[$i] = $i;
}
for ($j = $i = 0; $i < 256; $i++)
{
$j = ($j + $box[$i] + $key[$i]) % 256;
$tmp = $box[$i];
$box[$i] = $box[$j];
$box[$j] = $tmp;
}
for ($a = $j = $i = 0; $i < $data_length; $i++)
{
$a = ($a + 1) % 256;
$j = ($j + $box[$a]) % 256;
$tmp = $box[$a];
$box[$a] = $box[$j];
$box[$j] = $tmp;
$k = $box[(($box[$a] + $box[$j]) % 256)];
$cipher .= chr(ord($data[$i]) ^ $k);
}
return $cipher;
} | php | static function encrypt ($pwd, $data, $ispwdHex = 0)
{
if ($ispwdHex)
$pwd = @pack('H*', $pwd); // valid input, please!
$key[] = '';
$box[] = '';
$cipher = '';
$pwd_length = strlen($pwd);
$data_length = strlen($data);
for ($i = 0; $i < 256; $i++)
{
$key[$i] = ord($pwd[$i % $pwd_length]);
$box[$i] = $i;
}
for ($j = $i = 0; $i < 256; $i++)
{
$j = ($j + $box[$i] + $key[$i]) % 256;
$tmp = $box[$i];
$box[$i] = $box[$j];
$box[$j] = $tmp;
}
for ($a = $j = $i = 0; $i < $data_length; $i++)
{
$a = ($a + 1) % 256;
$j = ($j + $box[$a]) % 256;
$tmp = $box[$a];
$box[$a] = $box[$j];
$box[$j] = $tmp;
$k = $box[(($box[$a] + $box[$j]) % 256)];
$cipher .= chr(ord($data[$i]) ^ $k);
}
return $cipher;
} | [
"static",
"function",
"encrypt",
"(",
"$",
"pwd",
",",
"$",
"data",
",",
"$",
"ispwdHex",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"ispwdHex",
")",
"$",
"pwd",
"=",
"@",
"pack",
"(",
"'H*'",
",",
"$",
"pwd",
")",
";",
"// valid input, please!",
"$",
"... | The symmetric encryption function
@param string $pwd Key to encrypt with (can be binary of hex)
@param string $data Content to be encrypted
@param bool $ispwdHex Key passed is in hexadecimal or not
@access public
@return string | [
"The",
"symmetric",
"encryption",
"function"
] | cfffae6021788de18fd78489753821f7faf5b9a9 | https://github.com/dynamic/foxystripe/blob/cfffae6021788de18fd78489753821f7faf5b9a9/thirdparty/rc4crypt.php#L38-L73 | train |
dynamic/foxystripe | src/Page/OrderHistoryPage.php | OrderHistoryPage.getOrders | public function getOrders($limit = 10)
{
if ($Member = Security::getCurrentUser()) {
$Orders = $Member->Orders()->sort('TransactionDate', 'DESC');
$list = new PaginatedList($Orders, Controller::curr()->getRequest());
$list->setPageLength($limit);
return $list;
}
return false;
} | php | public function getOrders($limit = 10)
{
if ($Member = Security::getCurrentUser()) {
$Orders = $Member->Orders()->sort('TransactionDate', 'DESC');
$list = new PaginatedList($Orders, Controller::curr()->getRequest());
$list->setPageLength($limit);
return $list;
}
return false;
} | [
"public",
"function",
"getOrders",
"(",
"$",
"limit",
"=",
"10",
")",
"{",
"if",
"(",
"$",
"Member",
"=",
"Security",
"::",
"getCurrentUser",
"(",
")",
")",
"{",
"$",
"Orders",
"=",
"$",
"Member",
"->",
"Orders",
"(",
")",
"->",
"sort",
"(",
"'Tran... | return all current Member's Orders.
@param int $limit
@return bool|PaginatedList
@throws \Exception | [
"return",
"all",
"current",
"Member",
"s",
"Orders",
"."
] | cfffae6021788de18fd78489753821f7faf5b9a9 | https://github.com/dynamic/foxystripe/blob/cfffae6021788de18fd78489753821f7faf5b9a9/src/Page/OrderHistoryPage.php#L36-L48 | train |
asinfotrack/yii2-comments | models/CommentQuery.php | CommentQuery.subject | public function subject($model)
{
Comment::validateSubject($model, true);
$this->modelClass($model::className());
$this->andWhere(['foreign_pk'=>$this->createPrimaryKeyJson($model)]);
return $this;
} | php | public function subject($model)
{
Comment::validateSubject($model, true);
$this->modelClass($model::className());
$this->andWhere(['foreign_pk'=>$this->createPrimaryKeyJson($model)]);
return $this;
} | [
"public",
"function",
"subject",
"(",
"$",
"model",
")",
"{",
"Comment",
"::",
"validateSubject",
"(",
"$",
"model",
",",
"true",
")",
";",
"$",
"this",
"->",
"modelClass",
"(",
"$",
"model",
"::",
"className",
"(",
")",
")",
";",
"$",
"this",
"->",
... | Named scope to get entries for a certain model
@param \yii\db\ActiveRecord $model the model to get the audit trail for
@return \asinfotrack\yii2\comments\models\CommentQuery
@throws \yii\base\InvalidParamException if the model is not of type ActiveRecord
@throws \yii\base\InvalidConfigException if the models pk is empty or invalid | [
"Named",
"scope",
"to",
"get",
"entries",
"for",
"a",
"certain",
"model"
] | 8f3b1ea239a4e940bc32472d16fb09c2b71135f7 | https://github.com/asinfotrack/yii2-comments/blob/8f3b1ea239a4e940bc32472d16fb09c2b71135f7/models/CommentQuery.php#L26-L34 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/dca/tl_content.php | tl_content_elements.addCteType | public function addCteType($arrRow)
{
$return = \tl_content::addCteType($arrRow);
if (($objElement = $objElement = \ElementsModel::findOneByAlias($arrRow['type'])) === null && !array_key_exists($arrRow['type'], $GLOBALS['TL_DCA']['tl_content']['palettes']))
{
$tag = '<span style="color: #222;">' . $GLOBALS['TL_LANG']['CTE']['deleted'] . '</span>';
}
else if ($objElement->invisible)
{
$tag = ' <span style="color: #c6c6c6;">(' . $GLOBALS['TL_LANG']['CTE']['invisible'] . ')</span>';
}
return ($tag) ? substr_replace($return, $tag . '</div>', strpos($return, '</div>')) : $return;
} | php | public function addCteType($arrRow)
{
$return = \tl_content::addCteType($arrRow);
if (($objElement = $objElement = \ElementsModel::findOneByAlias($arrRow['type'])) === null && !array_key_exists($arrRow['type'], $GLOBALS['TL_DCA']['tl_content']['palettes']))
{
$tag = '<span style="color: #222;">' . $GLOBALS['TL_LANG']['CTE']['deleted'] . '</span>';
}
else if ($objElement->invisible)
{
$tag = ' <span style="color: #c6c6c6;">(' . $GLOBALS['TL_LANG']['CTE']['invisible'] . ')</span>';
}
return ($tag) ? substr_replace($return, $tag . '</div>', strpos($return, '</div>')) : $return;
} | [
"public",
"function",
"addCteType",
"(",
"$",
"arrRow",
")",
"{",
"$",
"return",
"=",
"\\",
"tl_content",
"::",
"addCteType",
"(",
"$",
"arrRow",
")",
";",
"if",
"(",
"(",
"$",
"objElement",
"=",
"$",
"objElement",
"=",
"\\",
"ElementsModel",
"::",
"fi... | Wrap the content block elements into an div block and
mark content element if content block is invisible
@param array $arrRow
@return string | [
"Wrap",
"the",
"content",
"block",
"elements",
"into",
"an",
"div",
"block",
"and",
"mark",
"content",
"element",
"if",
"content",
"block",
"is",
"invisible"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/dca/tl_content.php#L63-L77 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/dca/tl_content.php | tl_content_elements.addTypeHelpWizard | public function addTypeHelpWizard ($dc)
{
return ' <a href="contao/help.php?table='.$dc->table.'&field='.$dc->field.'&ptable='.$dc->parentTable.'&pid='.$dc->activeRecord->pid.'" title="' . \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['helpWizard']) . '" onclick="Backend.openModalIframe({\'width\':735,\'title\':\''.\StringUtil::specialchars(str_replace("'", "\\'", $arrData['label'][0])).'\',\'url\':this.href});return false">'.\Image::getHtml('about.svg', $GLOBALS['TL_LANG']['MSC']['helpWizard'], 'style="vertical-align:text-bottom"').'</a>';
} | php | public function addTypeHelpWizard ($dc)
{
return ' <a href="contao/help.php?table='.$dc->table.'&field='.$dc->field.'&ptable='.$dc->parentTable.'&pid='.$dc->activeRecord->pid.'" title="' . \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['helpWizard']) . '" onclick="Backend.openModalIframe({\'width\':735,\'title\':\''.\StringUtil::specialchars(str_replace("'", "\\'", $arrData['label'][0])).'\',\'url\':this.href});return false">'.\Image::getHtml('about.svg', $GLOBALS['TL_LANG']['MSC']['helpWizard'], 'style="vertical-align:text-bottom"').'</a>';
} | [
"public",
"function",
"addTypeHelpWizard",
"(",
"$",
"dc",
")",
"{",
"return",
"' <a href=\"contao/help.php?table='",
".",
"$",
"dc",
"->",
"table",
".",
"'&field='",
".",
"$",
"dc",
"->",
"field",
".",
"'&ptable='",
".",
"$",
"dc",
"->",
"parentTable"... | Add a custom help wirzard to the type field
@param DataContainer $dc
@return string | [
"Add",
"a",
"custom",
"help",
"wirzard",
"to",
"the",
"type",
"field"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/dca/tl_content.php#L87-L90 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/dca/tl_content.php | tl_content_elements.getElements | public function getElements ($dc)
{
if ($dc->activeRecord !== null)
{
$ptable = $dc->activeRecord->ptable;
$pid = $dc->activeRecord->pid;
}
else
{
// If no activeRecord try to use get parameters (submitted by the custom help wizard)
$ptable = \Input::get('ptable');
$pid = \Input::get('pid');
}
// Try to find content block elements for the theme
$objLayout = \LayoutModel::findById(\Agoat\CustomContentElementsBundle\Contao\Controller::getLayoutId($ptable, $pid));
$colElements = \ElementsModel::findPublishedByPid($objLayout->pid);
$arrElements = array();
$strGroup = 'cte';
if ($colElements !== null)
{
foreach ($colElements as $objElement)
{
if ($objElement->type == 'group')
{
$strGroup = $objElement->alias;
}
else
{
$arrElements[$strGroup][] = $objElement->alias;
}
}
}
// Add standard content elements
if (!\Config::get('hideLegacyCTE'))
{
unset($GLOBALS['TL_CTE']['CTE']);
foreach ($GLOBALS['TL_CTE'] as $k=>$v)
{
foreach (array_keys($v) as $kk)
{
$arrElements[$k][] = $kk;
}
}
}
// Legacy support
if ($dc->value != '' && !in_array($dc->value, array_reduce($arrElements, 'array_merge', array())))
{
if (($objLegacy = \ElementsModel::findOneByAlias($dc->value)) === null && !array_key_exists($dc->value, $GLOBALS['TL_DCA']['tl_content']['palettes']))
{
$arrLegacy = array('deleted' => array ($dc->value));
}
else if ($objLegacy->invisible)
{
$arrLegacy = array('invisible' => array ($dc->value));
}
else
{
$arrLegacy = array('legacy' => array ($dc->value));
}
// Add current at top of the list
$arrElements = array_merge($arrLegacy, $arrElements);
}
return $arrElements;
} | php | public function getElements ($dc)
{
if ($dc->activeRecord !== null)
{
$ptable = $dc->activeRecord->ptable;
$pid = $dc->activeRecord->pid;
}
else
{
// If no activeRecord try to use get parameters (submitted by the custom help wizard)
$ptable = \Input::get('ptable');
$pid = \Input::get('pid');
}
// Try to find content block elements for the theme
$objLayout = \LayoutModel::findById(\Agoat\CustomContentElementsBundle\Contao\Controller::getLayoutId($ptable, $pid));
$colElements = \ElementsModel::findPublishedByPid($objLayout->pid);
$arrElements = array();
$strGroup = 'cte';
if ($colElements !== null)
{
foreach ($colElements as $objElement)
{
if ($objElement->type == 'group')
{
$strGroup = $objElement->alias;
}
else
{
$arrElements[$strGroup][] = $objElement->alias;
}
}
}
// Add standard content elements
if (!\Config::get('hideLegacyCTE'))
{
unset($GLOBALS['TL_CTE']['CTE']);
foreach ($GLOBALS['TL_CTE'] as $k=>$v)
{
foreach (array_keys($v) as $kk)
{
$arrElements[$k][] = $kk;
}
}
}
// Legacy support
if ($dc->value != '' && !in_array($dc->value, array_reduce($arrElements, 'array_merge', array())))
{
if (($objLegacy = \ElementsModel::findOneByAlias($dc->value)) === null && !array_key_exists($dc->value, $GLOBALS['TL_DCA']['tl_content']['palettes']))
{
$arrLegacy = array('deleted' => array ($dc->value));
}
else if ($objLegacy->invisible)
{
$arrLegacy = array('invisible' => array ($dc->value));
}
else
{
$arrLegacy = array('legacy' => array ($dc->value));
}
// Add current at top of the list
$arrElements = array_merge($arrLegacy, $arrElements);
}
return $arrElements;
} | [
"public",
"function",
"getElements",
"(",
"$",
"dc",
")",
"{",
"if",
"(",
"$",
"dc",
"->",
"activeRecord",
"!==",
"null",
")",
"{",
"$",
"ptable",
"=",
"$",
"dc",
"->",
"activeRecord",
"->",
"ptable",
";",
"$",
"pid",
"=",
"$",
"dc",
"->",
"activeR... | Generate a content element list array
@param DataContainer $dc
@return array | [
"Generate",
"a",
"content",
"element",
"list",
"array"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/dca/tl_content.php#L100-L171 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/dca/tl_content.php | tl_content_elements.setDefaultType | public function setDefaultType($value, $dc)
{
if (!$value)
{
if ($dc->activeRecord !== null)
{
$ptable = $dc->activeRecord->ptable;
$pid = $dc->activeRecord->pid;
}
else
{
return $value;
}
// Try to find content block elements for the theme
$objLayout = \LayoutModel::findById(\Agoat\CustomContentElementsBundle\Contao\Controller::getLayoutId($ptable, $pid));
$objDefault = \ElementsModel::findDefaultPublishedElementByPid($objLayout->pid);
// if no default content element is found
if ($objDefault === null)
{
if (\Config::get('hideLegacyCTE'))
{
$objDefault = \ElementsModel::findFirstPublishedElementByPid($objLayout->pid);
}
if ($objDefault === null)
{
$objDefault = new \stdClass();
$objDefault->alias = 'text';
}
}
$objContent = \ContentModel::findByPk($dc->id);
$objContent->type = $objDefault->alias;
$objContent->save();
$this->redirect(\Environment::get('request'));
}
return $value;
} | php | public function setDefaultType($value, $dc)
{
if (!$value)
{
if ($dc->activeRecord !== null)
{
$ptable = $dc->activeRecord->ptable;
$pid = $dc->activeRecord->pid;
}
else
{
return $value;
}
// Try to find content block elements for the theme
$objLayout = \LayoutModel::findById(\Agoat\CustomContentElementsBundle\Contao\Controller::getLayoutId($ptable, $pid));
$objDefault = \ElementsModel::findDefaultPublishedElementByPid($objLayout->pid);
// if no default content element is found
if ($objDefault === null)
{
if (\Config::get('hideLegacyCTE'))
{
$objDefault = \ElementsModel::findFirstPublishedElementByPid($objLayout->pid);
}
if ($objDefault === null)
{
$objDefault = new \stdClass();
$objDefault->alias = 'text';
}
}
$objContent = \ContentModel::findByPk($dc->id);
$objContent->type = $objDefault->alias;
$objContent->save();
$this->redirect(\Environment::get('request'));
}
return $value;
} | [
"public",
"function",
"setDefaultType",
"(",
"$",
"value",
",",
"$",
"dc",
")",
"{",
"if",
"(",
"!",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"dc",
"->",
"activeRecord",
"!==",
"null",
")",
"{",
"$",
"ptable",
"=",
"$",
"dc",
"->",
"activeRecord",
... | Set default value for new records
@param mixed @value
@param DataContainer $dc
@return mixed | [
"Set",
"default",
"value",
"for",
"new",
"records"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/dca/tl_content.php#L182-L224 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/dca/tl_content.php | tl_content_elements.buildPaletteAndFields | public function buildPaletteAndFields ($dc)
{
// Build the content block elements palette and fields only when editing a content element (see #5)
if (\Input::get('act') != 'edit' && \Input::get('act') != 'show' && !isset($_GET['target']))
{
return;
}
$intId = (isset($_GET['target'])) ? explode('.', \Input::get('target'))[2] : $dc->id;
$objContent = \ContentModel::findByPk($intId);
if ($objContent === null)
{
return;
}
// Get block element
$objElement = \ElementsModel::findOneByAlias($objContent->type);
if ($objElement === null)
{
return;
}
// Add default palette (for type selection)
$GLOBALS['TL_DCA']['tl_content']['palettes'][$objElement->alias] = '{type_legend},type';
// Add pattern to palette
$colPattern = \PatternModel::findVisibleByPid($objElement->id);
if ($colPattern === null)
{
return;
}
$arrData = array();
$colData = \DataModel::findByPid($intId);
if ($colData !== null)
{
foreach ($colData as $objData)
{
$arrData[$objData->pattern] = $objData;
}
}
foreach($colPattern as $objPattern)
{
// Construct dca for pattern
$strClass = Agoat\CustomContentElementsBundle\Contao\Pattern::findClass($objPattern->type);
$bolData = Agoat\CustomContentElementsBundle\Contao\Pattern::hasData($objPattern->type);
if (!class_exists($strClass))
{
\System::log('Pattern element class "'.$strClass.'" (pattern element "'.$objPattern->type.'") does not exist', __METHOD__, TL_ERROR);
}
else
{
if ($bolData && !isset($arrData[$objPattern->alias]))
{
$arrData[$objPattern->alias] = new \DataModel();
$arrData[$objPattern->alias]->pid = $objContent->id;
$arrData[$objPattern->alias]->pattern = $objPattern->alias;
$arrData[$objPattern->alias]->save();
}
$objPatternClass = new $strClass($objPattern);
$objPatternClass->pid = $objContent->id;
$objPatternClass->pattern = $objPattern->alias;
$objPatternClass->element = $objElement->alias;
$objPatternClass->data = $arrData[$objPattern->alias]; // Save data to the DCA
$objPatternClass->create();
}
}
} | php | public function buildPaletteAndFields ($dc)
{
// Build the content block elements palette and fields only when editing a content element (see #5)
if (\Input::get('act') != 'edit' && \Input::get('act') != 'show' && !isset($_GET['target']))
{
return;
}
$intId = (isset($_GET['target'])) ? explode('.', \Input::get('target'))[2] : $dc->id;
$objContent = \ContentModel::findByPk($intId);
if ($objContent === null)
{
return;
}
// Get block element
$objElement = \ElementsModel::findOneByAlias($objContent->type);
if ($objElement === null)
{
return;
}
// Add default palette (for type selection)
$GLOBALS['TL_DCA']['tl_content']['palettes'][$objElement->alias] = '{type_legend},type';
// Add pattern to palette
$colPattern = \PatternModel::findVisibleByPid($objElement->id);
if ($colPattern === null)
{
return;
}
$arrData = array();
$colData = \DataModel::findByPid($intId);
if ($colData !== null)
{
foreach ($colData as $objData)
{
$arrData[$objData->pattern] = $objData;
}
}
foreach($colPattern as $objPattern)
{
// Construct dca for pattern
$strClass = Agoat\CustomContentElementsBundle\Contao\Pattern::findClass($objPattern->type);
$bolData = Agoat\CustomContentElementsBundle\Contao\Pattern::hasData($objPattern->type);
if (!class_exists($strClass))
{
\System::log('Pattern element class "'.$strClass.'" (pattern element "'.$objPattern->type.'") does not exist', __METHOD__, TL_ERROR);
}
else
{
if ($bolData && !isset($arrData[$objPattern->alias]))
{
$arrData[$objPattern->alias] = new \DataModel();
$arrData[$objPattern->alias]->pid = $objContent->id;
$arrData[$objPattern->alias]->pattern = $objPattern->alias;
$arrData[$objPattern->alias]->save();
}
$objPatternClass = new $strClass($objPattern);
$objPatternClass->pid = $objContent->id;
$objPatternClass->pattern = $objPattern->alias;
$objPatternClass->element = $objElement->alias;
$objPatternClass->data = $arrData[$objPattern->alias]; // Save data to the DCA
$objPatternClass->create();
}
}
} | [
"public",
"function",
"buildPaletteAndFields",
"(",
"$",
"dc",
")",
"{",
"// Build the content block elements palette and fields only when editing a content element (see #5)",
"if",
"(",
"\\",
"Input",
"::",
"get",
"(",
"'act'",
")",
"!=",
"'edit'",
"&&",
"\\",
"Input",
... | Build the palette and field DCA for the virtual input fields
@param DataContainer $dc | [
"Build",
"the",
"palette",
"and",
"field",
"DCA",
"for",
"the",
"virtual",
"input",
"fields"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/dca/tl_content.php#L232-L310 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/dca/tl_content.php | tl_content_elements.loadFieldValue | public function loadFieldValue ($value, $dc)
{
if (!empty($value))
{
return $value;
}
if (!empty($GLOBALS['TL_DCA']['tl_content']['fields'][$dc->field]['data']))
{
return $GLOBALS['TL_DCA']['tl_content']['fields'][$dc->field]['data'];
}
return null;
} | php | public function loadFieldValue ($value, $dc)
{
if (!empty($value))
{
return $value;
}
if (!empty($GLOBALS['TL_DCA']['tl_content']['fields'][$dc->field]['data']))
{
return $GLOBALS['TL_DCA']['tl_content']['fields'][$dc->field]['data'];
}
return null;
} | [
"public",
"function",
"loadFieldValue",
"(",
"$",
"value",
",",
"$",
"dc",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"GLOBALS",
"[",
"'TL_DCA'",
"]",
... | Load the virtual field value from the DCA
@param mixed $value
@param DataContainer $dc
@return mixed|null | [
"Load",
"the",
"virtual",
"field",
"value",
"from",
"the",
"DCA"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/dca/tl_content.php#L321-L334 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/dca/tl_content.php | tl_content_elements.saveData | public function saveData (&$dc)
{
// Save all modified values
foreach ($this->arrModifiedData as $field => $value)
{
// Get virtual field attributes from DCA
$id = $GLOBALS['TL_DCA']['tl_content']['fields'][$field]['id'];
$pattern = $GLOBALS['TL_DCA']['tl_content']['fields'][$field]['pattern'];
$parent = $GLOBALS['TL_DCA']['tl_content']['fields'][$field]['parent'];
$column = $GLOBALS['TL_DCA']['tl_content']['fields'][$field]['column'];
if ($id !== null)
{
$objData = \DataModel::findByPK($id);
}
else
{
$objData = \DataModel::findByPidAndPatternAndParent($dc->activeRecord->id, $pattern, $parent);
}
if ($objData === null)
{
// if no dataset exist make a new one
$objData = new \DataModel();
$objData->tstamp = time();
}
$objData->pid = $dc->activeRecord->id;
$objData->pattern = $pattern;
$objData->parent = $parent;
if ($objData->$column != $value)
{
$dc->blnCreateNewVersion = true;
$objData->$column = $value;
$objData->tstamp = time();
}
$objData->save();
}
} | php | public function saveData (&$dc)
{
// Save all modified values
foreach ($this->arrModifiedData as $field => $value)
{
// Get virtual field attributes from DCA
$id = $GLOBALS['TL_DCA']['tl_content']['fields'][$field]['id'];
$pattern = $GLOBALS['TL_DCA']['tl_content']['fields'][$field]['pattern'];
$parent = $GLOBALS['TL_DCA']['tl_content']['fields'][$field]['parent'];
$column = $GLOBALS['TL_DCA']['tl_content']['fields'][$field]['column'];
if ($id !== null)
{
$objData = \DataModel::findByPK($id);
}
else
{
$objData = \DataModel::findByPidAndPatternAndParent($dc->activeRecord->id, $pattern, $parent);
}
if ($objData === null)
{
// if no dataset exist make a new one
$objData = new \DataModel();
$objData->tstamp = time();
}
$objData->pid = $dc->activeRecord->id;
$objData->pattern = $pattern;
$objData->parent = $parent;
if ($objData->$column != $value)
{
$dc->blnCreateNewVersion = true;
$objData->$column = $value;
$objData->tstamp = time();
}
$objData->save();
}
} | [
"public",
"function",
"saveData",
"(",
"&",
"$",
"dc",
")",
"{",
"// Save all modified values",
"foreach",
"(",
"$",
"this",
"->",
"arrModifiedData",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"// Get virtual field attributes from DCA",
"$",
"id",
"=",
... | Save the virtual field values into the tl_data table
@param DataContainer $dc | [
"Save",
"the",
"virtual",
"field",
"values",
"into",
"the",
"tl_data",
"table"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/dca/tl_content.php#L342-L382 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/dca/tl_content.php | tl_content_elements.prepareOrderValue | public function prepareOrderValue ($value, $dc)
{
$orderField = $GLOBALS['TL_DCA']['tl_content']['fields'][$dc->field]['eval']['orderField'];
$orderData = \StringUtil::deserialize($GLOBALS['TL_DCA']['tl_content']['fields'][$orderField]['data']);
$GLOBALS['TL_DCA']['tl_content']['fields'][$dc->field]['eval'][$orderField] = (is_array($orderData)) ? $orderData : array();
return $value;
} | php | public function prepareOrderValue ($value, $dc)
{
$orderField = $GLOBALS['TL_DCA']['tl_content']['fields'][$dc->field]['eval']['orderField'];
$orderData = \StringUtil::deserialize($GLOBALS['TL_DCA']['tl_content']['fields'][$orderField]['data']);
$GLOBALS['TL_DCA']['tl_content']['fields'][$dc->field]['eval'][$orderField] = (is_array($orderData)) ? $orderData : array();
return $value;
} | [
"public",
"function",
"prepareOrderValue",
"(",
"$",
"value",
",",
"$",
"dc",
")",
"{",
"$",
"orderField",
"=",
"$",
"GLOBALS",
"[",
"'TL_DCA'",
"]",
"[",
"'tl_content'",
"]",
"[",
"'fields'",
"]",
"[",
"$",
"dc",
"->",
"field",
"]",
"[",
"'eval'",
"... | Prepare the virtual order field
@param mixed $value
@param DataContainer $dc
@return mixed | [
"Prepare",
"the",
"virtual",
"order",
"field"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/dca/tl_content.php#L409-L417 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/dca/tl_content.php | tl_content_elements.saveOrderValue | public function saveOrderValue ($value, $dc)
{
$orderField = $GLOBALS['TL_DCA']['tl_content']['fields'][$dc->field]['eval']['orderField'];
$orderData = \Input::post($orderField);
if ($orderData)
{
// Convert UUID to binary data for file sources
if ($GLOBALS['TL_DCA']['tl_content']['fields'][$dc->field]['inputType'] == 'fileTree')
{
$this->arrModifiedData[$orderField] = array_map('\StringUtil::uuidToBin', explode(',', $orderData));
}
else
{
$this->arrModifiedData[$orderField] = explode(',', $orderData);
}
}
else
{
$this->arrModifiedData[$orderField] = NULL;
}
return $value;
} | php | public function saveOrderValue ($value, $dc)
{
$orderField = $GLOBALS['TL_DCA']['tl_content']['fields'][$dc->field]['eval']['orderField'];
$orderData = \Input::post($orderField);
if ($orderData)
{
// Convert UUID to binary data for file sources
if ($GLOBALS['TL_DCA']['tl_content']['fields'][$dc->field]['inputType'] == 'fileTree')
{
$this->arrModifiedData[$orderField] = array_map('\StringUtil::uuidToBin', explode(',', $orderData));
}
else
{
$this->arrModifiedData[$orderField] = explode(',', $orderData);
}
}
else
{
$this->arrModifiedData[$orderField] = NULL;
}
return $value;
} | [
"public",
"function",
"saveOrderValue",
"(",
"$",
"value",
",",
"$",
"dc",
")",
"{",
"$",
"orderField",
"=",
"$",
"GLOBALS",
"[",
"'TL_DCA'",
"]",
"[",
"'tl_content'",
"]",
"[",
"'fields'",
"]",
"[",
"$",
"dc",
"->",
"field",
"]",
"[",
"'eval'",
"]",... | Save the virtual order field
@param mixed $value
@param DataContainer $dc
@return mixed | [
"Save",
"the",
"virtual",
"order",
"field"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/dca/tl_content.php#L428-L452 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/dca/tl_content.php | tl_content_elements.setAceCodeHighlighting | public function setAceCodeHighlighting($value, $dc)
{
$pattern = $GLOBALS['TL_DCA']['tl_content']['fields'][$dc->field]['pattern'];
$highlight = $GLOBALS['TL_DCA']['tl_content']['fields'][$pattern . '-highlight']['data'];
if (!empty($highlight))
{
$GLOBALS['TL_DCA']['tl_content']['fields'][$dc->field]['eval']['rte'] = 'ace|' . strtolower($highlight);
}
return $value;
} | php | public function setAceCodeHighlighting($value, $dc)
{
$pattern = $GLOBALS['TL_DCA']['tl_content']['fields'][$dc->field]['pattern'];
$highlight = $GLOBALS['TL_DCA']['tl_content']['fields'][$pattern . '-highlight']['data'];
if (!empty($highlight))
{
$GLOBALS['TL_DCA']['tl_content']['fields'][$dc->field]['eval']['rte'] = 'ace|' . strtolower($highlight);
}
return $value;
} | [
"public",
"function",
"setAceCodeHighlighting",
"(",
"$",
"value",
",",
"$",
"dc",
")",
"{",
"$",
"pattern",
"=",
"$",
"GLOBALS",
"[",
"'TL_DCA'",
"]",
"[",
"'tl_content'",
"]",
"[",
"'fields'",
"]",
"[",
"$",
"dc",
"->",
"field",
"]",
"[",
"'pattern'"... | Dynamically set the ace highlight syntax
@param mixed $value
@param DataContainer $dc
@return mixed | [
"Dynamically",
"set",
"the",
"ace",
"highlight",
"syntax"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/dca/tl_content.php#L464-L475 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/dca/tl_content.php | tl_content_elements.createDataVersion | public function createDataVersion ($strTable, $intPid, $intVersion)
{
$db = Database::getInstance();
$objData = $db->prepare("SELECT * FROM tl_data WHERE pid=?")
->execute($intPid);
if ($objData === null)
{
return;
}
$db->prepare("INSERT INTO tl_version (pid, tstamp, version, fromTable, data) VALUES (?, ?, ?, ?, ?)")
->execute($intPid, time(), $intVersion, 'tl_data', serialize($objData->fetchAllAssoc()));
} | php | public function createDataVersion ($strTable, $intPid, $intVersion)
{
$db = Database::getInstance();
$objData = $db->prepare("SELECT * FROM tl_data WHERE pid=?")
->execute($intPid);
if ($objData === null)
{
return;
}
$db->prepare("INSERT INTO tl_version (pid, tstamp, version, fromTable, data) VALUES (?, ?, ?, ?, ?)")
->execute($intPid, time(), $intVersion, 'tl_data', serialize($objData->fetchAllAssoc()));
} | [
"public",
"function",
"createDataVersion",
"(",
"$",
"strTable",
",",
"$",
"intPid",
",",
"$",
"intVersion",
")",
"{",
"$",
"db",
"=",
"Database",
"::",
"getInstance",
"(",
")",
";",
"$",
"objData",
"=",
"$",
"db",
"->",
"prepare",
"(",
"\"SELECT * FROM ... | Save tl_data versions
@param string $strTable
@param integer $intPid
@param integer $intVersion | [
"Save",
"tl_data",
"versions"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/dca/tl_content.php#L503-L517 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/dca/tl_content.php | tl_content_elements.restoreDataVersion | public function restoreDataVersion ($strTable, $intPid, $intVersion)
{
$db = Database::getInstance();
$objData = $db->prepare("SELECT * FROM tl_version WHERE fromTable=? AND pid=? AND version=?")
->execute('tl_data', $intPid, $intVersion);
if ($objData->numRows < 1)
{
return;
}
$data = \StringUtil::deserialize($objData->data);
if (!is_array($data))
{
return;
}
// Get the currently available fields
$arrFields = array_flip($this->Database->getFieldnames('tl_data'));
$objStmt = $db->prepare("DELETE FROM tl_data WHERE pid=?")
->execute($intPid);
foreach ($data as $row)
{
// Unset fields that do not exist (see #5219)
$row = array_intersect_key($row, $arrFields);
// Reset fields added after storing the version to their default value (see #7755)
foreach (array_diff_key($arrFields, $row) as $k=>$v)
{
$row[$k] = \Widget::getEmptyValueByFieldType($GLOBALS['TL_DCA']['tl_data']['fields'][$k]['sql']);
}
$db->prepare("INSERT INTO tl_data %s")
->set($row)
->execute($row['id']);
}
} | php | public function restoreDataVersion ($strTable, $intPid, $intVersion)
{
$db = Database::getInstance();
$objData = $db->prepare("SELECT * FROM tl_version WHERE fromTable=? AND pid=? AND version=?")
->execute('tl_data', $intPid, $intVersion);
if ($objData->numRows < 1)
{
return;
}
$data = \StringUtil::deserialize($objData->data);
if (!is_array($data))
{
return;
}
// Get the currently available fields
$arrFields = array_flip($this->Database->getFieldnames('tl_data'));
$objStmt = $db->prepare("DELETE FROM tl_data WHERE pid=?")
->execute($intPid);
foreach ($data as $row)
{
// Unset fields that do not exist (see #5219)
$row = array_intersect_key($row, $arrFields);
// Reset fields added after storing the version to their default value (see #7755)
foreach (array_diff_key($arrFields, $row) as $k=>$v)
{
$row[$k] = \Widget::getEmptyValueByFieldType($GLOBALS['TL_DCA']['tl_data']['fields'][$k]['sql']);
}
$db->prepare("INSERT INTO tl_data %s")
->set($row)
->execute($row['id']);
}
} | [
"public",
"function",
"restoreDataVersion",
"(",
"$",
"strTable",
",",
"$",
"intPid",
",",
"$",
"intVersion",
")",
"{",
"$",
"db",
"=",
"Database",
"::",
"getInstance",
"(",
")",
";",
"$",
"objData",
"=",
"$",
"db",
"->",
"prepare",
"(",
"\"SELECT * FROM... | Restore tl_data versions
@param string $strTable
@param integer $intPid
@param integer $intVersion | [
"Restore",
"tl_data",
"versions"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/dca/tl_content.php#L527-L567 | train |
BlueTeaNL/JIRA-Rest-API-PHP | src/Jira/Endpoint/ProjectEndpoint.php | ProjectEndpoint.convertAvatar | public function convertAvatar($projectId, $cropperWidth, $cropperOffsetX, $cropperOffsetY, $needsCropping)
{
return $this->apiClient->callEndpoint(
sprintf('%s/%s/avatar', self::ENDPOINT, $projectId),
array(
"cropperWidth" => $cropperWidth,
"cropperOffsetX" => $cropperOffsetX,
"cropperOffsetY" => $cropperOffsetY,
"needsCropping" => $needsCropping
),
HttpMethod::REQUEST_POST
);
} | php | public function convertAvatar($projectId, $cropperWidth, $cropperOffsetX, $cropperOffsetY, $needsCropping)
{
return $this->apiClient->callEndpoint(
sprintf('%s/%s/avatar', self::ENDPOINT, $projectId),
array(
"cropperWidth" => $cropperWidth,
"cropperOffsetX" => $cropperOffsetX,
"cropperOffsetY" => $cropperOffsetY,
"needsCropping" => $needsCropping
),
HttpMethod::REQUEST_POST
);
} | [
"public",
"function",
"convertAvatar",
"(",
"$",
"projectId",
",",
"$",
"cropperWidth",
",",
"$",
"cropperOffsetX",
",",
"$",
"cropperOffsetY",
",",
"$",
"needsCropping",
")",
"{",
"return",
"$",
"this",
"->",
"apiClient",
"->",
"callEndpoint",
"(",
"sprintf",... | Converts temporary avatar into a real avatar
@param int|string $projectId
@param int $cropperWidth
@param int $cropperOffsetX
@param int $cropperOffsetY
@param bool $needsCropping
@return mixed | [
"Converts",
"temporary",
"avatar",
"into",
"a",
"real",
"avatar"
] | 56309ee711f86d5bc085f391bba3e50155e14106 | https://github.com/BlueTeaNL/JIRA-Rest-API-PHP/blob/56309ee711f86d5bc085f391bba3e50155e14106/src/Jira/Endpoint/ProjectEndpoint.php#L46-L58 | train |
BlueTeaNL/JIRA-Rest-API-PHP | src/Jira/Endpoint/ProjectEndpoint.php | ProjectEndpoint.findProperty | public function findProperty($projectId, $propertyKey)
{
return $this->apiClient->callEndpoint(sprintf('%s/%s/properties/%s', self::ENDPOINT, $projectId, $propertyKey));
} | php | public function findProperty($projectId, $propertyKey)
{
return $this->apiClient->callEndpoint(sprintf('%s/%s/properties/%s', self::ENDPOINT, $projectId, $propertyKey));
} | [
"public",
"function",
"findProperty",
"(",
"$",
"projectId",
",",
"$",
"propertyKey",
")",
"{",
"return",
"$",
"this",
"->",
"apiClient",
"->",
"callEndpoint",
"(",
"sprintf",
"(",
"'%s/%s/properties/%s'",
",",
"self",
"::",
"ENDPOINT",
",",
"$",
"projectId",
... | Returns the value of the property with a given key from the project identified by the key or by the id. The user
who retrieves the property is required to have permissions to read the project.
@param $projectId
@param $propertyKey
@return mixed | [
"Returns",
"the",
"value",
"of",
"the",
"property",
"with",
"a",
"given",
"key",
"from",
"the",
"project",
"identified",
"by",
"the",
"key",
"or",
"by",
"the",
"id",
".",
"The",
"user",
"who",
"retrieves",
"the",
"property",
"is",
"required",
"to",
"have... | 56309ee711f86d5bc085f391bba3e50155e14106 | https://github.com/BlueTeaNL/JIRA-Rest-API-PHP/blob/56309ee711f86d5bc085f391bba3e50155e14106/src/Jira/Endpoint/ProjectEndpoint.php#L140-L143 | train |
BlueTeaNL/JIRA-Rest-API-PHP | src/Jira/Endpoint/ProjectEndpoint.php | ProjectEndpoint.findRole | public function findRole($projectId, $roleId)
{
return $this->apiClient->callEndpoint(sprintf('%s/%s/role/%s', self::ENDPOINT, $projectId, $roleId));
} | php | public function findRole($projectId, $roleId)
{
return $this->apiClient->callEndpoint(sprintf('%s/%s/role/%s', self::ENDPOINT, $projectId, $roleId));
} | [
"public",
"function",
"findRole",
"(",
"$",
"projectId",
",",
"$",
"roleId",
")",
"{",
"return",
"$",
"this",
"->",
"apiClient",
"->",
"callEndpoint",
"(",
"sprintf",
"(",
"'%s/%s/role/%s'",
",",
"self",
"::",
"ENDPOINT",
",",
"$",
"projectId",
",",
"$",
... | Details on a given project role.
@param $projectId
@param $roleId
@return mixed | [
"Details",
"on",
"a",
"given",
"project",
"role",
"."
] | 56309ee711f86d5bc085f391bba3e50155e14106 | https://github.com/BlueTeaNL/JIRA-Rest-API-PHP/blob/56309ee711f86d5bc085f391bba3e50155e14106/src/Jira/Endpoint/ProjectEndpoint.php#L163-L166 | train |
BlueTeaNL/JIRA-Rest-API-PHP | src/Jira/Endpoint/ProjectEndpoint.php | ProjectEndpoint.updateRole | public function updateRole($projectId, $roleId, $user = null, $group = null)
{
$parameters = [];
if ((is_null($user) && is_null($group)) || (!is_null($user) && !is_null($group))) {
throw new EndpointParameterException('User or group should be given');
} elseif (!is_null($user)) {
$parameters['user'] = $user;
} else {
$parameters['group'] = $group;
}
return $this->apiClient->callEndpoint(
sprintf('%s/%s/role/%s', self::ENDPOINT, $projectId, $roleId),
$parameters,
null,
HttpMethod::REQUEST_PUT
);
} | php | public function updateRole($projectId, $roleId, $user = null, $group = null)
{
$parameters = [];
if ((is_null($user) && is_null($group)) || (!is_null($user) && !is_null($group))) {
throw new EndpointParameterException('User or group should be given');
} elseif (!is_null($user)) {
$parameters['user'] = $user;
} else {
$parameters['group'] = $group;
}
return $this->apiClient->callEndpoint(
sprintf('%s/%s/role/%s', self::ENDPOINT, $projectId, $roleId),
$parameters,
null,
HttpMethod::REQUEST_PUT
);
} | [
"public",
"function",
"updateRole",
"(",
"$",
"projectId",
",",
"$",
"roleId",
",",
"$",
"user",
"=",
"null",
",",
"$",
"group",
"=",
"null",
")",
"{",
"$",
"parameters",
"=",
"[",
"]",
";",
"if",
"(",
"(",
"is_null",
"(",
"$",
"user",
")",
"&&",... | Updates a project role to contain the sent actors.
@param $projectId
@param $roleId
@param null|string $user
@param null|string $group
@throws \Bluetea\Api\Exception\EndpointParameterException
@return mixed | [
"Updates",
"a",
"project",
"role",
"to",
"contain",
"the",
"sent",
"actors",
"."
] | 56309ee711f86d5bc085f391bba3e50155e14106 | https://github.com/BlueTeaNL/JIRA-Rest-API-PHP/blob/56309ee711f86d5bc085f391bba3e50155e14106/src/Jira/Endpoint/ProjectEndpoint.php#L178-L195 | train |
BlueTeaNL/JIRA-Rest-API-PHP | src/Jira/Endpoint/ProjectEndpoint.php | ProjectEndpoint.addRole | public function addRole($projectId, $roleId, $user = null, $group = null)
{
$parameters = [];
if ((is_null($user) && is_null($group)) || (!is_null($user) && !is_null($group))) {
throw new EndpointParameterException('User or group should be given');
} elseif (!is_null($user)) {
$parameters['user'] = $user;
} else {
$parameters['group'] = $group;
}
return $this->apiClient->callEndpoint(
sprintf('%s/%s/role/%s', self::ENDPOINT, $projectId, $roleId),
$parameters,
null,
HttpMethod::REQUEST_POST
);
} | php | public function addRole($projectId, $roleId, $user = null, $group = null)
{
$parameters = [];
if ((is_null($user) && is_null($group)) || (!is_null($user) && !is_null($group))) {
throw new EndpointParameterException('User or group should be given');
} elseif (!is_null($user)) {
$parameters['user'] = $user;
} else {
$parameters['group'] = $group;
}
return $this->apiClient->callEndpoint(
sprintf('%s/%s/role/%s', self::ENDPOINT, $projectId, $roleId),
$parameters,
null,
HttpMethod::REQUEST_POST
);
} | [
"public",
"function",
"addRole",
"(",
"$",
"projectId",
",",
"$",
"roleId",
",",
"$",
"user",
"=",
"null",
",",
"$",
"group",
"=",
"null",
")",
"{",
"$",
"parameters",
"=",
"[",
"]",
";",
"if",
"(",
"(",
"is_null",
"(",
"$",
"user",
")",
"&&",
... | Add an actor to a project role.
@param $projectId
@param $roleId
@param null|string $user
@param null|string $group
@throws \Bluetea\Api\Exception\EndpointParameterException
@return mixed | [
"Add",
"an",
"actor",
"to",
"a",
"project",
"role",
"."
] | 56309ee711f86d5bc085f391bba3e50155e14106 | https://github.com/BlueTeaNL/JIRA-Rest-API-PHP/blob/56309ee711f86d5bc085f391bba3e50155e14106/src/Jira/Endpoint/ProjectEndpoint.php#L207-L224 | train |
BlueTeaNL/JIRA-Rest-API-PHP | src/Jira/Endpoint/ProjectEndpoint.php | ProjectEndpoint.deleteRole | public function deleteRole($projectId, $roleId)
{
return $this->apiClient->callEndpoint(
sprintf('%s/%s/role/%s', self::ENDPOINT, $projectId, $roleId),
array(),
null,
HttpMethod::REQUEST_DELETE
);
} | php | public function deleteRole($projectId, $roleId)
{
return $this->apiClient->callEndpoint(
sprintf('%s/%s/role/%s', self::ENDPOINT, $projectId, $roleId),
array(),
null,
HttpMethod::REQUEST_DELETE
);
} | [
"public",
"function",
"deleteRole",
"(",
"$",
"projectId",
",",
"$",
"roleId",
")",
"{",
"return",
"$",
"this",
"->",
"apiClient",
"->",
"callEndpoint",
"(",
"sprintf",
"(",
"'%s/%s/role/%s'",
",",
"self",
"::",
"ENDPOINT",
",",
"$",
"projectId",
",",
"$",... | Remove actors from a project role.
@param $projectId
@param $roleId
@return mixed | [
"Remove",
"actors",
"from",
"a",
"project",
"role",
"."
] | 56309ee711f86d5bc085f391bba3e50155e14106 | https://github.com/BlueTeaNL/JIRA-Rest-API-PHP/blob/56309ee711f86d5bc085f391bba3e50155e14106/src/Jira/Endpoint/ProjectEndpoint.php#L233-L241 | train |
nathanmac/datetime-codeception-module | src/Module/Time.php | Time.dontSeeTimeIsInSecs | public function dontSeeTimeIsInSecs($time, $seconds) {
\PHPUnit_Framework_Assert::assertNotEquals($seconds, $this->_GetNow()->diffInSeconds($this->_ParseDate($time), false));
} | php | public function dontSeeTimeIsInSecs($time, $seconds) {
\PHPUnit_Framework_Assert::assertNotEquals($seconds, $this->_GetNow()->diffInSeconds($this->_ParseDate($time), false));
} | [
"public",
"function",
"dontSeeTimeIsInSecs",
"(",
"$",
"time",
",",
"$",
"seconds",
")",
"{",
"\\",
"PHPUnit_Framework_Assert",
"::",
"assertNotEquals",
"(",
"$",
"seconds",
",",
"$",
"this",
"->",
"_GetNow",
"(",
")",
"->",
"diffInSeconds",
"(",
"$",
"this"... | See time is not in a given number of seconds.
@param string $time
@param int $seconds | [
"See",
"time",
"is",
"not",
"in",
"a",
"given",
"number",
"of",
"seconds",
"."
] | 0dfda12968af4baa8d755656d5416db9f3c37db2 | https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Time.php#L27-L29 | train |
nathanmac/datetime-codeception-module | src/Module/Time.php | Time.seeTimeWasInSecs | public function seeTimeWasInSecs($time, $seconds) {
\PHPUnit_Framework_Assert::assertEquals($seconds, $this->_ParseDate($time)->diffInSeconds($this->_GetNow(), false));
} | php | public function seeTimeWasInSecs($time, $seconds) {
\PHPUnit_Framework_Assert::assertEquals($seconds, $this->_ParseDate($time)->diffInSeconds($this->_GetNow(), false));
} | [
"public",
"function",
"seeTimeWasInSecs",
"(",
"$",
"time",
",",
"$",
"seconds",
")",
"{",
"\\",
"PHPUnit_Framework_Assert",
"::",
"assertEquals",
"(",
"$",
"seconds",
",",
"$",
"this",
"->",
"_ParseDate",
"(",
"$",
"time",
")",
"->",
"diffInSeconds",
"(",
... | See time was in a given number of seconds.
@param string $time
@param int $seconds | [
"See",
"time",
"was",
"in",
"a",
"given",
"number",
"of",
"seconds",
"."
] | 0dfda12968af4baa8d755656d5416db9f3c37db2 | https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Time.php#L37-L39 | train |
nathanmac/datetime-codeception-module | src/Module/Time.php | Time.seeTimeIsInMins | public function seeTimeIsInMins($time, $minutes) {
\PHPUnit_Framework_Assert::assertEquals($minutes, $this->_GetNow()->diffInMinutes($this->_ParseDate($time), false));
} | php | public function seeTimeIsInMins($time, $minutes) {
\PHPUnit_Framework_Assert::assertEquals($minutes, $this->_GetNow()->diffInMinutes($this->_ParseDate($time), false));
} | [
"public",
"function",
"seeTimeIsInMins",
"(",
"$",
"time",
",",
"$",
"minutes",
")",
"{",
"\\",
"PHPUnit_Framework_Assert",
"::",
"assertEquals",
"(",
"$",
"minutes",
",",
"$",
"this",
"->",
"_GetNow",
"(",
")",
"->",
"diffInMinutes",
"(",
"$",
"this",
"->... | See time is in a given number of minutes.
@param string $time
@param int $minutes | [
"See",
"time",
"is",
"in",
"a",
"given",
"number",
"of",
"minutes",
"."
] | 0dfda12968af4baa8d755656d5416db9f3c37db2 | https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Time.php#L59-L61 | train |
nathanmac/datetime-codeception-module | src/Module/Time.php | Time.dontSeeTimeIsInMins | public function dontSeeTimeIsInMins($time, $minutes) {
\PHPUnit_Framework_Assert::assertNotEquals($minutes, $this->_GetNow()->diffInMinutes($this->_ParseDate($time), false));
} | php | public function dontSeeTimeIsInMins($time, $minutes) {
\PHPUnit_Framework_Assert::assertNotEquals($minutes, $this->_GetNow()->diffInMinutes($this->_ParseDate($time), false));
} | [
"public",
"function",
"dontSeeTimeIsInMins",
"(",
"$",
"time",
",",
"$",
"minutes",
")",
"{",
"\\",
"PHPUnit_Framework_Assert",
"::",
"assertNotEquals",
"(",
"$",
"minutes",
",",
"$",
"this",
"->",
"_GetNow",
"(",
")",
"->",
"diffInMinutes",
"(",
"$",
"this"... | See time is not in a given number of minutes.
@param string $time
@param int $minutes | [
"See",
"time",
"is",
"not",
"in",
"a",
"given",
"number",
"of",
"minutes",
"."
] | 0dfda12968af4baa8d755656d5416db9f3c37db2 | https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Time.php#L69-L71 | train |
nathanmac/datetime-codeception-module | src/Module/Time.php | Time.dontSeeTimeIsInHours | public function dontSeeTimeIsInHours($time, $hours) {
\PHPUnit_Framework_Assert::assertNotEquals($hours, $this->_GetNow()->diffInHours($this->_ParseDate($time), false));
} | php | public function dontSeeTimeIsInHours($time, $hours) {
\PHPUnit_Framework_Assert::assertNotEquals($hours, $this->_GetNow()->diffInHours($this->_ParseDate($time), false));
} | [
"public",
"function",
"dontSeeTimeIsInHours",
"(",
"$",
"time",
",",
"$",
"hours",
")",
"{",
"\\",
"PHPUnit_Framework_Assert",
"::",
"assertNotEquals",
"(",
"$",
"hours",
",",
"$",
"this",
"->",
"_GetNow",
"(",
")",
"->",
"diffInHours",
"(",
"$",
"this",
"... | See time is not in a given number of hours.
@param string $time
@param int $hours | [
"See",
"time",
"is",
"not",
"in",
"a",
"given",
"number",
"of",
"hours",
"."
] | 0dfda12968af4baa8d755656d5416db9f3c37db2 | https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Time.php#L111-L113 | train |
nathanmac/datetime-codeception-module | src/Module/Time.php | Time.seeTimeWasInHours | public function seeTimeWasInHours($time, $hours) {
\PHPUnit_Framework_Assert::assertEquals($hours, $this->_ParseDate($time)->diffInHours($this->_GetNow(), false));
} | php | public function seeTimeWasInHours($time, $hours) {
\PHPUnit_Framework_Assert::assertEquals($hours, $this->_ParseDate($time)->diffInHours($this->_GetNow(), false));
} | [
"public",
"function",
"seeTimeWasInHours",
"(",
"$",
"time",
",",
"$",
"hours",
")",
"{",
"\\",
"PHPUnit_Framework_Assert",
"::",
"assertEquals",
"(",
"$",
"hours",
",",
"$",
"this",
"->",
"_ParseDate",
"(",
"$",
"time",
")",
"->",
"diffInHours",
"(",
"$",... | See time was in a given number of hours.
@param string $time
@param int $hours | [
"See",
"time",
"was",
"in",
"a",
"given",
"number",
"of",
"hours",
"."
] | 0dfda12968af4baa8d755656d5416db9f3c37db2 | https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Time.php#L121-L123 | train |
nathanmac/datetime-codeception-module | src/Module/Time.php | Time.seeTimeMatches | public function seeTimeMatches($t1, $t2) {
\PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($t1)->eq($this->_ParseDate($t2)));
} | php | public function seeTimeMatches($t1, $t2) {
\PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($t1)->eq($this->_ParseDate($t2)));
} | [
"public",
"function",
"seeTimeMatches",
"(",
"$",
"t1",
",",
"$",
"t2",
")",
"{",
"\\",
"PHPUnit_Framework_Assert",
"::",
"assertTrue",
"(",
"$",
"this",
"->",
"_ParseDate",
"(",
"$",
"t1",
")",
"->",
"eq",
"(",
"$",
"this",
"->",
"_ParseDate",
"(",
"$... | See that two times match.
@param string $t1
@param string $t2 | [
"See",
"that",
"two",
"times",
"match",
"."
] | 0dfda12968af4baa8d755656d5416db9f3c37db2 | https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Time.php#L181-L183 | train |
nathanmac/datetime-codeception-module | src/Module/Time.php | Time.dontSeeTimeMatches | public function dontSeeTimeMatches($t1, $t2) {
\PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($t1)->ne($this->_ParseDate($t2)));
} | php | public function dontSeeTimeMatches($t1, $t2) {
\PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($t1)->ne($this->_ParseDate($t2)));
} | [
"public",
"function",
"dontSeeTimeMatches",
"(",
"$",
"t1",
",",
"$",
"t2",
")",
"{",
"\\",
"PHPUnit_Framework_Assert",
"::",
"assertTrue",
"(",
"$",
"this",
"->",
"_ParseDate",
"(",
"$",
"t1",
")",
"->",
"ne",
"(",
"$",
"this",
"->",
"_ParseDate",
"(",
... | See that two times don't match.
@param string $t1
@param string $t2 | [
"See",
"that",
"two",
"times",
"don",
"t",
"match",
"."
] | 0dfda12968af4baa8d755656d5416db9f3c37db2 | https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Time.php#L191-L193 | train |
botman/driver-cisco-spark | src/CiscoSparkDriver.php | CiscoSparkDriver.getBotId | private function getBotId()
{
if (is_null($this->botId)) {
$response = $this->http->get(self::API_ENDPOINT.'people/me', [], $this->getHeaders());
$bot = json_decode($response->getContent());
$this->botId = $bot->id;
}
return $this->botId;
} | php | private function getBotId()
{
if (is_null($this->botId)) {
$response = $this->http->get(self::API_ENDPOINT.'people/me', [], $this->getHeaders());
$bot = json_decode($response->getContent());
$this->botId = $bot->id;
}
return $this->botId;
} | [
"private",
"function",
"getBotId",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"botId",
")",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"http",
"->",
"get",
"(",
"self",
"::",
"API_ENDPOINT",
".",
"'people/me'",
",",
"[",
"... | Returns the chatbot ID.
@return string | [
"Returns",
"the",
"chatbot",
"ID",
"."
] | 1c23b405347ae6361da616b8183443c403252dd8 | https://github.com/botman/driver-cisco-spark/blob/1c23b405347ae6361da616b8183443c403252dd8/src/CiscoSparkDriver.php#L180-L189 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/classes/Template.php | Template.parse | public function parse()
{
$strBuffer = parent::parse();
if (TL_MODE == 'BE')
{
$strBuffer = '<div class="tl_ce ' . $this->strTemplate . '">' . $strBuffer . '</div>';
}
return $strBuffer;
} | php | public function parse()
{
$strBuffer = parent::parse();
if (TL_MODE == 'BE')
{
$strBuffer = '<div class="tl_ce ' . $this->strTemplate . '">' . $strBuffer . '</div>';
}
return $strBuffer;
} | [
"public",
"function",
"parse",
"(",
")",
"{",
"$",
"strBuffer",
"=",
"parent",
"::",
"parse",
"(",
")",
";",
"if",
"(",
"TL_MODE",
"==",
"'BE'",
")",
"{",
"$",
"strBuffer",
"=",
"'<div class=\"tl_ce '",
".",
"$",
"this",
"->",
"strTemplate",
".",
"'\">... | Add a wrapper in the backend
@return string The template markup | [
"Add",
"a",
"wrapper",
"in",
"the",
"backend"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/classes/Template.php#L34-L44 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/classes/Template.php | Template.addImage | public function addImage ($image, $size, $width=0, $height=0)
{
if (!is_array($image))
{
return;
}
if (@unserialize($size) === false)
{
$size = serialize(array((string)$width, (string)$height, $size));
}
$image['size'] = $size;
$image['singleSRC'] = $image['path'];
Pattern::addImageToTemplate($picture = new \stdClass(), $image);
$picture = $picture->picture;
$picture['imageUrl'] = $image['imageUrl'];
$picture['caption'] = $image['caption'];
$picture['id'] = $image['id'];
$picture['uuid'] = $image['uuid'];
$picture['name'] = $image['name'];
$picture['path'] = $image['path'];
$picture['extension'] = $image['extension'];
return $picture;
} | php | public function addImage ($image, $size, $width=0, $height=0)
{
if (!is_array($image))
{
return;
}
if (@unserialize($size) === false)
{
$size = serialize(array((string)$width, (string)$height, $size));
}
$image['size'] = $size;
$image['singleSRC'] = $image['path'];
Pattern::addImageToTemplate($picture = new \stdClass(), $image);
$picture = $picture->picture;
$picture['imageUrl'] = $image['imageUrl'];
$picture['caption'] = $image['caption'];
$picture['id'] = $image['id'];
$picture['uuid'] = $image['uuid'];
$picture['name'] = $image['name'];
$picture['path'] = $image['path'];
$picture['extension'] = $image['extension'];
return $picture;
} | [
"public",
"function",
"addImage",
"(",
"$",
"image",
",",
"$",
"size",
",",
"$",
"width",
"=",
"0",
",",
"$",
"height",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"image",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"@",
"uns... | Add an image to template
@param array $image The image parameter array from the FileTree pattern
@param string|int $size The image size from the ImageSize widget as serialized array or imagesize id
@param integer $width An optional width of the image
@param integer $height An optional height of the image
@return array The new (resized) image parameter array | [
"Add",
"an",
"image",
"to",
"template"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/classes/Template.php#L57-L84 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/classes/Template.php | Template.addCSS | public function addCSS ($strCSS, $strType='scss', $bolStatic=true)
{
if ($strCSS == '')
{
return;
}
$strType = strtoupper($strType);
if (!in_array($strType, array('CSS', 'SCSS' , 'LESS')))
{
return;
}
if (!$bolStatic && $strType == 'css')
{
$strKey = substr(md5($strType . $strCSS), 0, 12);
$strPath = 'assets/css/' . $strKey . '.' . $strType;
// Write to a temporary file in the assets folder
if (!file_exists($strPath))
{
$objFile = new File($strPath, true);
$objFile->write($strCSS);
$objFile->close();
}
// Add the file path to TL_USER_CSS
$GLOBALS[TL_USER_CSS][] = $strPath;
return;
}
// Add to the combined CSS string
$GLOBALS['TL_CTB_' . $strType] .= $strCSS;
} | php | public function addCSS ($strCSS, $strType='scss', $bolStatic=true)
{
if ($strCSS == '')
{
return;
}
$strType = strtoupper($strType);
if (!in_array($strType, array('CSS', 'SCSS' , 'LESS')))
{
return;
}
if (!$bolStatic && $strType == 'css')
{
$strKey = substr(md5($strType . $strCSS), 0, 12);
$strPath = 'assets/css/' . $strKey . '.' . $strType;
// Write to a temporary file in the assets folder
if (!file_exists($strPath))
{
$objFile = new File($strPath, true);
$objFile->write($strCSS);
$objFile->close();
}
// Add the file path to TL_USER_CSS
$GLOBALS[TL_USER_CSS][] = $strPath;
return;
}
// Add to the combined CSS string
$GLOBALS['TL_CTB_' . $strType] .= $strCSS;
} | [
"public",
"function",
"addCSS",
"(",
"$",
"strCSS",
",",
"$",
"strType",
"=",
"'scss'",
",",
"$",
"bolStatic",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"strCSS",
"==",
"''",
")",
"{",
"return",
";",
"}",
"$",
"strType",
"=",
"strtoupper",
"(",
"$",
... | Add CSS to the page
@param string $strCSS The css, scss or less content
@param string $strType The type of the content
@param boolean $bolStatic Set false to add the content in an extra file (only when type is css) | [
"Add",
"CSS",
"to",
"the",
"page"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/classes/Template.php#L94-L128 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/classes/Template.php | Template.addJS | public function addJS ($strJS, $bolStatic=true)
{
if ($strJS == '')
{
return;
}
if (!$bolStatic)
{
$strKey = substr(md5('js' . $strJS), 0, 12);
$strPath = 'assets/js/' . $strKey . '.js';
// Write to a temporary file in the assets folder
if (!file_exists($strPath))
{
$objFile = new File($strPath, true);
$objFile->write($strCSS);
$objFile->close();
}
// Add the file path to TL_USER_CSS
$GLOBALS[TL_JAVASCRIPT][] = $strPath;
return;
}
// Add to the combined CSS string
$GLOBALS['TL_CTB_JS'] .= $strJS;
} | php | public function addJS ($strJS, $bolStatic=true)
{
if ($strJS == '')
{
return;
}
if (!$bolStatic)
{
$strKey = substr(md5('js' . $strJS), 0, 12);
$strPath = 'assets/js/' . $strKey . '.js';
// Write to a temporary file in the assets folder
if (!file_exists($strPath))
{
$objFile = new File($strPath, true);
$objFile->write($strCSS);
$objFile->close();
}
// Add the file path to TL_USER_CSS
$GLOBALS[TL_JAVASCRIPT][] = $strPath;
return;
}
// Add to the combined CSS string
$GLOBALS['TL_CTB_JS'] .= $strJS;
} | [
"public",
"function",
"addJS",
"(",
"$",
"strJS",
",",
"$",
"bolStatic",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"strJS",
"==",
"''",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"$",
"bolStatic",
")",
"{",
"$",
"strKey",
"=",
"substr",
"(",
"m... | Add Javascript to the page
@param string $strJS The javascript content
@param boolean $bolStatic Set false to add the content in an extra file | [
"Add",
"Javascript",
"to",
"the",
"page"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/classes/Template.php#L137-L164 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/classes/Template.php | Template.prevElement | public function prevElement ()
{
if (($arrTypes = $GLOBALS['templateTypes'][$this->ptable.'.'.$this->pid]) === null)
{
$objCte = \ContentModel::findPublishedByPidAndTable($this->pid, $this->ptable);
if ($objCte === null)
{
return;
}
$arrTypes = $GLOBALS['templateTypes'][$this->ptable.'.'.$this->pid] = $objCte->fetchEach('type');
}
return $arrTypes[array_keys($arrTypes)[array_search($this->id, array_keys($arrTypes)) - 1]];
} | php | public function prevElement ()
{
if (($arrTypes = $GLOBALS['templateTypes'][$this->ptable.'.'.$this->pid]) === null)
{
$objCte = \ContentModel::findPublishedByPidAndTable($this->pid, $this->ptable);
if ($objCte === null)
{
return;
}
$arrTypes = $GLOBALS['templateTypes'][$this->ptable.'.'.$this->pid] = $objCte->fetchEach('type');
}
return $arrTypes[array_keys($arrTypes)[array_search($this->id, array_keys($arrTypes)) - 1]];
} | [
"public",
"function",
"prevElement",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"arrTypes",
"=",
"$",
"GLOBALS",
"[",
"'templateTypes'",
"]",
"[",
"$",
"this",
"->",
"ptable",
".",
"'.'",
".",
"$",
"this",
"->",
"pid",
"]",
")",
"===",
"null",
")",
"{",
... | Get the alias of the previous content element
@return string The type of the previous content element | [
"Get",
"the",
"alias",
"of",
"the",
"previous",
"content",
"element"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/classes/Template.php#L202-L217 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/classes/Template.php | Template.insert | public function insert($name, array $data=null)
{
// Register the template file (to find the custom templates)
if (!array_key_exists($name, TemplateLoader::getFiles()))
{
$objTheme = \LayoutModel::findById(Controller::getLayoutId($this->ptable, $this->pid))->getRelated('pid');
TemplateLoader::addFile($name, $objTheme->templates);
}
/** @var \Template $tpl */
if ($this instanceof \Template)
{
$tpl = new static($name);
}
elseif (TL_MODE == 'BE')
{
$tpl = new BackendTemplate($name);
}
else
{
$tpl = new FrontendTemplate($name);
}
if ($data !== null)
{
$tpl->setData($data);
}
echo $tpl->parse();
} | php | public function insert($name, array $data=null)
{
// Register the template file (to find the custom templates)
if (!array_key_exists($name, TemplateLoader::getFiles()))
{
$objTheme = \LayoutModel::findById(Controller::getLayoutId($this->ptable, $this->pid))->getRelated('pid');
TemplateLoader::addFile($name, $objTheme->templates);
}
/** @var \Template $tpl */
if ($this instanceof \Template)
{
$tpl = new static($name);
}
elseif (TL_MODE == 'BE')
{
$tpl = new BackendTemplate($name);
}
else
{
$tpl = new FrontendTemplate($name);
}
if ($data !== null)
{
$tpl->setData($data);
}
echo $tpl->parse();
} | [
"public",
"function",
"insert",
"(",
"$",
"name",
",",
"array",
"$",
"data",
"=",
"null",
")",
"{",
"// Register the template file (to find the custom templates)",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"name",
",",
"TemplateLoader",
"::",
"getFiles",
"(",
... | Insert a template
@param string $name The template name
@param array $data An optional data array | [
"Insert",
"a",
"template"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/classes/Template.php#L249-L278 | train |
swoft-cloud/swoft-websocket-server | src/WebSocketEventTrait.php | WebSocketEventTrait.onMessage | public function onMessage(Server $server, Frame $frame)
{
$fd = $frame->fd;
// init fd and coId mapping
WebSocketContext::setFdToCoId($fd);
App::trigger(WsEvent::ON_MESSAGE, null, $server, $frame);
$this->log("received message: {$frame->data} from fd #{$fd}, co ID #" . Coroutine::tid(), [], 'debug');
/** @see Dispatcher::message() */
\bean('wsDispatcher')->message($server, $frame);
// delete coId to fd mapping
WebSocketContext::delFdByCoId();
RequestContext::destroy();
} | php | public function onMessage(Server $server, Frame $frame)
{
$fd = $frame->fd;
// init fd and coId mapping
WebSocketContext::setFdToCoId($fd);
App::trigger(WsEvent::ON_MESSAGE, null, $server, $frame);
$this->log("received message: {$frame->data} from fd #{$fd}, co ID #" . Coroutine::tid(), [], 'debug');
/** @see Dispatcher::message() */
\bean('wsDispatcher')->message($server, $frame);
// delete coId to fd mapping
WebSocketContext::delFdByCoId();
RequestContext::destroy();
} | [
"public",
"function",
"onMessage",
"(",
"Server",
"$",
"server",
",",
"Frame",
"$",
"frame",
")",
"{",
"$",
"fd",
"=",
"$",
"frame",
"->",
"fd",
";",
"// init fd and coId mapping",
"WebSocketContext",
"::",
"setFdToCoId",
"(",
"$",
"fd",
")",
";",
"App",
... | When you receive the message
@param Server $server
@param Frame $frame
@throws \Swoft\WebSocket\Server\Exception\WsRouteException
@throws \Swoft\WebSocket\Server\Exception\WsMessageException
@throws \InvalidArgumentException | [
"When",
"you",
"receive",
"the",
"message"
] | b1f7ae57618a1b4746d5f92b114d23bc3f5f91e5 | https://github.com/swoft-cloud/swoft-websocket-server/blob/b1f7ae57618a1b4746d5f92b114d23bc3f5f91e5/src/WebSocketEventTrait.php#L158-L175 | train |
umbrellaTech/ya-boleto-php | src/AbstractBoleto.php | AbstractBoleto.getTotal | public function getTotal()
{
return (float)($this->valorDocumento + $this->taxa + $this->outrosAcrescimos) - ($this->desconto + $this->outrasDeducoes);
} | php | public function getTotal()
{
return (float)($this->valorDocumento + $this->taxa + $this->outrosAcrescimos) - ($this->desconto + $this->outrasDeducoes);
} | [
"public",
"function",
"getTotal",
"(",
")",
"{",
"return",
"(",
"float",
")",
"(",
"$",
"this",
"->",
"valorDocumento",
"+",
"$",
"this",
"->",
"taxa",
"+",
"$",
"this",
"->",
"outrosAcrescimos",
")",
"-",
"(",
"$",
"this",
"->",
"desconto",
"+",
"$"... | Retorna a valor total do boleto.
@return float | [
"Retorna",
"a",
"valor",
"total",
"do",
"boleto",
"."
] | 3d2e0f2db63e380eaa6db66d1103294705197118 | https://github.com/umbrellaTech/ya-boleto-php/blob/3d2e0f2db63e380eaa6db66d1103294705197118/src/AbstractBoleto.php#L537-L540 | train |
yajra/cms-core | src/Http/Controllers/ArticlesController.php | ArticlesController.index | public function index(ArticlesDataTable $dataTable)
{
$categories = [];
$allYesNo = [];
$statuses = [];
if (! request()->wantsJson()) {
$categories = Category::root()->getDescendants()->map(function(Category $category) {
$category->title = $category->present()->name;
return $category;
})->pluck('title', 'id');
$categories = collect(['' => '- Select Category -'])->union($categories);
$allYesNo = [
'' => '- Select Article Type -',
0 => 'Article',
1 => 'Page',
];
$statuses = [
'' => '- Select Status -',
0 => 'Unpublished',
1 => 'Published',
];
}
return $dataTable->render('administrator.articles.index', compact('categories', 'allYesNo', 'statuses'));
} | php | public function index(ArticlesDataTable $dataTable)
{
$categories = [];
$allYesNo = [];
$statuses = [];
if (! request()->wantsJson()) {
$categories = Category::root()->getDescendants()->map(function(Category $category) {
$category->title = $category->present()->name;
return $category;
})->pluck('title', 'id');
$categories = collect(['' => '- Select Category -'])->union($categories);
$allYesNo = [
'' => '- Select Article Type -',
0 => 'Article',
1 => 'Page',
];
$statuses = [
'' => '- Select Status -',
0 => 'Unpublished',
1 => 'Published',
];
}
return $dataTable->render('administrator.articles.index', compact('categories', 'allYesNo', 'statuses'));
} | [
"public",
"function",
"index",
"(",
"ArticlesDataTable",
"$",
"dataTable",
")",
"{",
"$",
"categories",
"=",
"[",
"]",
";",
"$",
"allYesNo",
"=",
"[",
"]",
";",
"$",
"statuses",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"request",
"(",
")",
"->",
"wantsJ... | Display list of articles.
@param \Yajra\CMS\DataTables\ArticlesDataTable $dataTable
@return \Illuminate\Http\JsonResponse|\Illuminate\View\View | [
"Display",
"list",
"of",
"articles",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/ArticlesController.php#L37-L64 | train |
yajra/cms-core | src/Http/Controllers/ArticlesController.php | ArticlesController.create | public function create(Article $article)
{
$article->published = true;
$article->setHighestOrderNumber();
$tags = Article::existingTags()->pluck('name');
return view('administrator.articles.create', compact('article', 'tags'));
} | php | public function create(Article $article)
{
$article->published = true;
$article->setHighestOrderNumber();
$tags = Article::existingTags()->pluck('name');
return view('administrator.articles.create', compact('article', 'tags'));
} | [
"public",
"function",
"create",
"(",
"Article",
"$",
"article",
")",
"{",
"$",
"article",
"->",
"published",
"=",
"true",
";",
"$",
"article",
"->",
"setHighestOrderNumber",
"(",
")",
";",
"$",
"tags",
"=",
"Article",
"::",
"existingTags",
"(",
")",
"->"... | Show articles form.
@param \Yajra\CMS\Entities\Article $article
@return mixed | [
"Show",
"articles",
"form",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/ArticlesController.php#L72-L79 | train |
yajra/cms-core | src/Http/Controllers/ArticlesController.php | ArticlesController.store | public function store(ArticlesFormRequest $request)
{
$article = new Article;
$article->fill($request->all());
$article->published = $request->get('published', false);
$article->featured = $request->get('featured', false);
$article->authenticated = $request->get('authenticated', false);
$article->is_page = $request->get('is_page', false);
$article->save();
$article->permissions()->sync($request->get('permissions', []));
if ($request->tags) {
$article->tag(explode(',', $request->tags));
}
event(new ArticleWasCreated($article));
flash()->success(trans('cms::article.store.success'));
return redirect()->route('administrator.articles.index');
} | php | public function store(ArticlesFormRequest $request)
{
$article = new Article;
$article->fill($request->all());
$article->published = $request->get('published', false);
$article->featured = $request->get('featured', false);
$article->authenticated = $request->get('authenticated', false);
$article->is_page = $request->get('is_page', false);
$article->save();
$article->permissions()->sync($request->get('permissions', []));
if ($request->tags) {
$article->tag(explode(',', $request->tags));
}
event(new ArticleWasCreated($article));
flash()->success(trans('cms::article.store.success'));
return redirect()->route('administrator.articles.index');
} | [
"public",
"function",
"store",
"(",
"ArticlesFormRequest",
"$",
"request",
")",
"{",
"$",
"article",
"=",
"new",
"Article",
";",
"$",
"article",
"->",
"fill",
"(",
"$",
"request",
"->",
"all",
"(",
")",
")",
";",
"$",
"article",
"->",
"published",
"=",... | Store a newly created article.
@param ArticlesFormRequest $request
@return mixed | [
"Store",
"a",
"newly",
"created",
"article",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/ArticlesController.php#L87-L107 | train |
yajra/cms-core | src/Http/Controllers/ArticlesController.php | ArticlesController.edit | public function edit(Article $article)
{
$tags = Article::existingTags()->pluck('name');
$selectedTags = implode(',', $article->tagNames());
return view('administrator.articles.edit', compact('article', 'tags', 'selectedTags'));
} | php | public function edit(Article $article)
{
$tags = Article::existingTags()->pluck('name');
$selectedTags = implode(',', $article->tagNames());
return view('administrator.articles.edit', compact('article', 'tags', 'selectedTags'));
} | [
"public",
"function",
"edit",
"(",
"Article",
"$",
"article",
")",
"{",
"$",
"tags",
"=",
"Article",
"::",
"existingTags",
"(",
")",
"->",
"pluck",
"(",
"'name'",
")",
";",
"$",
"selectedTags",
"=",
"implode",
"(",
"','",
",",
"$",
"article",
"->",
"... | Show and edit selected article.
@param \Yajra\CMS\Entities\Article $article
@return mixed | [
"Show",
"and",
"edit",
"selected",
"article",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/ArticlesController.php#L115-L121 | train |
yajra/cms-core | src/Http/Controllers/ArticlesController.php | ArticlesController.update | public function update(Article $article, ArticlesFormRequest $request)
{
$article->fill($request->all());
$article->published = $request->get('published', false);
$article->featured = $request->get('featured', false);
$article->authenticated = $request->get('authenticated', false);
$article->is_page = $request->get('is_page', false);
$article->save();
$article->permissions()->sync($request->get('permissions', []));
if ($request->tags) {
$article->retag(explode(',', $request->tags));
}
event(new ArticleWasUpdated($article));
flash()->success(trans('cms::article.update.success'));
return redirect()->route('administrator.articles.index');
} | php | public function update(Article $article, ArticlesFormRequest $request)
{
$article->fill($request->all());
$article->published = $request->get('published', false);
$article->featured = $request->get('featured', false);
$article->authenticated = $request->get('authenticated', false);
$article->is_page = $request->get('is_page', false);
$article->save();
$article->permissions()->sync($request->get('permissions', []));
if ($request->tags) {
$article->retag(explode(',', $request->tags));
}
event(new ArticleWasUpdated($article));
flash()->success(trans('cms::article.update.success'));
return redirect()->route('administrator.articles.index');
} | [
"public",
"function",
"update",
"(",
"Article",
"$",
"article",
",",
"ArticlesFormRequest",
"$",
"request",
")",
"{",
"$",
"article",
"->",
"fill",
"(",
"$",
"request",
"->",
"all",
"(",
")",
")",
";",
"$",
"article",
"->",
"published",
"=",
"$",
"requ... | Update selected article.
@param \Yajra\CMS\Entities\Article $article
@param ArticlesFormRequest $request
@return mixed | [
"Update",
"selected",
"article",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/ArticlesController.php#L130-L149 | train |
neos/redirecthandler | Classes/Command/RedirectCommandController.php | RedirectCommandController.listCommand | public function listCommand($host = null, $match = null)
{
$outputByHost = function ($host = null) use ($match) {
$redirects = $this->redirectStorage->getAll($host);
$this->outputLine();
if ($host !== null) {
$this->outputLine('<info>==</info> <b>Redirect for %s</b>', [$host]);
} else {
$this->outputLine('<info>==</info> <b>Redirects valid for all hosts</b>', [$host]);
}
if ($match !== null) {
$this->outputLine(' <info>++</info> <b>Only showing redirects where source or target URI matches <u>%s</u></b>', [$match]);
sleep(1);
}
$this->outputLine();
/** @var $redirect RedirectInterface */
foreach ($redirects as $redirect) {
$outputLine = function ($source, $target, $statusCode) {
$this->outputLine(' <comment>></comment> %s <info>=></info> %s <comment>(%d)</comment>', [
$source,
$target,
$statusCode
]);
};
$source = $redirect->getSourceUriPath();
$target = $redirect->getTargetUriPath();
$statusCode = $redirect->getStatusCode();
if ($match === null) {
$outputLine($source, $target, $statusCode);
} else {
$regexp = sprintf('#%s#', $match);
$matches = preg_grep($regexp, [$target, $source]);
if (count($matches) > 0) {
$replace = "<error>$0</error>";
$source = preg_replace($regexp, $replace, $source);
$target = preg_replace($regexp, $replace, $target);
$outputLine($source, $target, $statusCode);
}
}
}
};
if ($host !== null) {
$outputByHost($host);
} else {
$hosts = $this->redirectStorage->getDistinctHosts();
array_map($outputByHost, $hosts);
}
$this->outputLine();
} | php | public function listCommand($host = null, $match = null)
{
$outputByHost = function ($host = null) use ($match) {
$redirects = $this->redirectStorage->getAll($host);
$this->outputLine();
if ($host !== null) {
$this->outputLine('<info>==</info> <b>Redirect for %s</b>', [$host]);
} else {
$this->outputLine('<info>==</info> <b>Redirects valid for all hosts</b>', [$host]);
}
if ($match !== null) {
$this->outputLine(' <info>++</info> <b>Only showing redirects where source or target URI matches <u>%s</u></b>', [$match]);
sleep(1);
}
$this->outputLine();
/** @var $redirect RedirectInterface */
foreach ($redirects as $redirect) {
$outputLine = function ($source, $target, $statusCode) {
$this->outputLine(' <comment>></comment> %s <info>=></info> %s <comment>(%d)</comment>', [
$source,
$target,
$statusCode
]);
};
$source = $redirect->getSourceUriPath();
$target = $redirect->getTargetUriPath();
$statusCode = $redirect->getStatusCode();
if ($match === null) {
$outputLine($source, $target, $statusCode);
} else {
$regexp = sprintf('#%s#', $match);
$matches = preg_grep($regexp, [$target, $source]);
if (count($matches) > 0) {
$replace = "<error>$0</error>";
$source = preg_replace($regexp, $replace, $source);
$target = preg_replace($regexp, $replace, $target);
$outputLine($source, $target, $statusCode);
}
}
}
};
if ($host !== null) {
$outputByHost($host);
} else {
$hosts = $this->redirectStorage->getDistinctHosts();
array_map($outputByHost, $hosts);
}
$this->outputLine();
} | [
"public",
"function",
"listCommand",
"(",
"$",
"host",
"=",
"null",
",",
"$",
"match",
"=",
"null",
")",
"{",
"$",
"outputByHost",
"=",
"function",
"(",
"$",
"host",
"=",
"null",
")",
"use",
"(",
"$",
"match",
")",
"{",
"$",
"redirects",
"=",
"$",
... | List all redirects
Lists all saved redirects. Optionally it is possible to filter by ``host`` and to use the argument ``match`` to
look for certain ``source`` or ``target`` paths.
@param string $host (optional) Filter redirects by the given hostname
@param string $match (optional) A string to match for the ``source`` or the ``target``
@return void | [
"List",
"all",
"redirects"
] | 351effbe2d184e82cc1dc65a5e409d092ba56194 | https://github.com/neos/redirecthandler/blob/351effbe2d184e82cc1dc65a5e409d092ba56194/Classes/Command/RedirectCommandController.php#L61-L109 | train |
neos/redirecthandler | Classes/Command/RedirectCommandController.php | RedirectCommandController.exportCommand | public function exportCommand($filename = null, $host = null)
{
if (!class_exists(Writer::class)) {
$this->outputWarningForLeagueCsvPackage();
}
$writer = Writer::createFromFileObject(new \SplTempFileObject());
if ($host !== null) {
$redirects = $this->redirectStorage->getAll($host);
} else {
$redirects = new \AppendIterator();
foreach ($this->redirectStorage->getDistinctHosts() as $host) {
$redirects->append($this->redirectStorage->getAll($host));
}
}
/** @var $redirect RedirectInterface */
foreach ($redirects as $redirect) {
$writer->insertOne([
$redirect->getSourceUriPath(),
$redirect->getTargetUriPath(),
$redirect->getStatusCode(),
$redirect->getHost()
]);
}
if ($filename === null) {
$writer->output();
} else {
file_put_contents($filename, (string)$writer);
}
} | php | public function exportCommand($filename = null, $host = null)
{
if (!class_exists(Writer::class)) {
$this->outputWarningForLeagueCsvPackage();
}
$writer = Writer::createFromFileObject(new \SplTempFileObject());
if ($host !== null) {
$redirects = $this->redirectStorage->getAll($host);
} else {
$redirects = new \AppendIterator();
foreach ($this->redirectStorage->getDistinctHosts() as $host) {
$redirects->append($this->redirectStorage->getAll($host));
}
}
/** @var $redirect RedirectInterface */
foreach ($redirects as $redirect) {
$writer->insertOne([
$redirect->getSourceUriPath(),
$redirect->getTargetUriPath(),
$redirect->getStatusCode(),
$redirect->getHost()
]);
}
if ($filename === null) {
$writer->output();
} else {
file_put_contents($filename, (string)$writer);
}
} | [
"public",
"function",
"exportCommand",
"(",
"$",
"filename",
"=",
"null",
",",
"$",
"host",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"Writer",
"::",
"class",
")",
")",
"{",
"$",
"this",
"->",
"outputWarningForLeagueCsvPackage",
"(",
")... | Export redirects to CSV
This command will export all redirects in CSV format. You can set a preferred
filename before the export with the optional ``filename`` argument. If no ``filename`` argument is supplied, the
export will be returned within the CLI. This operation requires the package ``league/csv``. Install it by running
``composer require league/csv``.
@param string $filename (optional) The filename for the CSV file
@param string $host (optional) Only export hosts for a specified host
@return void | [
"Export",
"redirects",
"to",
"CSV"
] | 351effbe2d184e82cc1dc65a5e409d092ba56194 | https://github.com/neos/redirecthandler/blob/351effbe2d184e82cc1dc65a5e409d092ba56194/Classes/Command/RedirectCommandController.php#L123-L151 | train |
neos/redirecthandler | Classes/Command/RedirectCommandController.php | RedirectCommandController.removeCommand | public function removeCommand($source, $host = null)
{
$redirect = $this->redirectStorage->getOneBySourceUriPathAndHost($source, $host);
if ($redirect === null) {
$this->outputLine('There is no redirect with the source URI path "%s", maybe you forgot the --host argument ?', [$source]);
$this->quit(1);
}
$this->redirectStorage->removeOneBySourceUriPathAndHost($source, $host);
$this->outputLine('Removed redirect with the source URI path "%s"', [$source]);
} | php | public function removeCommand($source, $host = null)
{
$redirect = $this->redirectStorage->getOneBySourceUriPathAndHost($source, $host);
if ($redirect === null) {
$this->outputLine('There is no redirect with the source URI path "%s", maybe you forgot the --host argument ?', [$source]);
$this->quit(1);
}
$this->redirectStorage->removeOneBySourceUriPathAndHost($source, $host);
$this->outputLine('Removed redirect with the source URI path "%s"', [$source]);
} | [
"public",
"function",
"removeCommand",
"(",
"$",
"source",
",",
"$",
"host",
"=",
"null",
")",
"{",
"$",
"redirect",
"=",
"$",
"this",
"->",
"redirectStorage",
"->",
"getOneBySourceUriPathAndHost",
"(",
"$",
"source",
",",
"$",
"host",
")",
";",
"if",
"(... | Remove a single redirect
This command is used the delete a single redirect. The redirect is identified by the ``source`` argument.
When using multiple domains for redirects the ``host`` argument is necessary to identify the correct one.
@param string $source The source URI path of the redirect to remove, as given by ``redirect:list``
@param string $host (optional) Only remove redirects that use this host
@return void | [
"Remove",
"a",
"single",
"redirect"
] | 351effbe2d184e82cc1dc65a5e409d092ba56194 | https://github.com/neos/redirecthandler/blob/351effbe2d184e82cc1dc65a5e409d092ba56194/Classes/Command/RedirectCommandController.php#L284-L293 | train |
neos/redirecthandler | Classes/Command/RedirectCommandController.php | RedirectCommandController.removeByHostCommand | public function removeByHostCommand($host)
{
if ($host === 'all') {
$this->redirectStorage->removeByHost(null);
$this->outputLine('Removed redirects matching all hosts');
} else {
$this->redirectStorage->removeByHost($host);
$this->outputLine('Removed all redirects for host "%s"', [$host]);
}
} | php | public function removeByHostCommand($host)
{
if ($host === 'all') {
$this->redirectStorage->removeByHost(null);
$this->outputLine('Removed redirects matching all hosts');
} else {
$this->redirectStorage->removeByHost($host);
$this->outputLine('Removed all redirects for host "%s"', [$host]);
}
} | [
"public",
"function",
"removeByHostCommand",
"(",
"$",
"host",
")",
"{",
"if",
"(",
"$",
"host",
"===",
"'all'",
")",
"{",
"$",
"this",
"->",
"redirectStorage",
"->",
"removeByHost",
"(",
"null",
")",
";",
"$",
"this",
"->",
"outputLine",
"(",
"'Removed ... | Remove all redirects by host
This command deletes all redirects from the RedirectRepository by host value.
If ``all`` is entered the redirects valid for all hosts are deleted.
@param string $host Fully qualified host name or `all` to delete redirects valid for all hosts
@return void | [
"Remove",
"all",
"redirects",
"by",
"host"
] | 351effbe2d184e82cc1dc65a5e409d092ba56194 | https://github.com/neos/redirecthandler/blob/351effbe2d184e82cc1dc65a5e409d092ba56194/Classes/Command/RedirectCommandController.php#L317-L326 | train |
gourmet/social-meta | src/View/Helper/MetaTagAwareTrait.php | MetaTagAwareTrait.render | public function render()
{
$block = $this->config('viewBlockName');
foreach ((array)$this->config('tags') as $namespace => $values) {
foreach ($values as $tag => $content) {
$property = "$namespace:$tag";
if (!is_array($content)) {
$this->Html->meta(null, null, compact('property', 'content', 'block'));
continue;
}
$options = array_pop($content);
$content = array_shift($content);
$this->Html->meta(null, null, compact('property', 'content', 'block'));
foreach ($options as $key => $value) {
if (!is_array($value)) {
$this->Html->meta(null, null, [
'property' => "$property:$key",
'content' => $value,
'block' => $block
]);
continue;
}
foreach ($value as $content) {
$this->Html->meta(null, null, [
'property' => "$property:$key",
'content' => $content,
'block' => $block
]);
}
}
}
}
return $this->_View->fetch($block);
} | php | public function render()
{
$block = $this->config('viewBlockName');
foreach ((array)$this->config('tags') as $namespace => $values) {
foreach ($values as $tag => $content) {
$property = "$namespace:$tag";
if (!is_array($content)) {
$this->Html->meta(null, null, compact('property', 'content', 'block'));
continue;
}
$options = array_pop($content);
$content = array_shift($content);
$this->Html->meta(null, null, compact('property', 'content', 'block'));
foreach ($options as $key => $value) {
if (!is_array($value)) {
$this->Html->meta(null, null, [
'property' => "$property:$key",
'content' => $value,
'block' => $block
]);
continue;
}
foreach ($value as $content) {
$this->Html->meta(null, null, [
'property' => "$property:$key",
'content' => $content,
'block' => $block
]);
}
}
}
}
return $this->_View->fetch($block);
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"block",
"=",
"$",
"this",
"->",
"config",
"(",
"'viewBlockName'",
")",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"config",
"(",
"'tags'",
")",
"as",
"$",
"namespace",
"=>",
"$",
... | Render view block.
@return string | [
"Render",
"view",
"block",
"."
] | d4ffe7ba417d06dca0664a5b1f0870652b1df2e8 | https://github.com/gourmet/social-meta/blob/d4ffe7ba417d06dca0664a5b1f0870652b1df2e8/src/View/Helper/MetaTagAwareTrait.php#L13-L53 | train |
Speicher210/CloudinaryBundle | Command/UploadCommand.php | UploadCommand.uploadFileToCloudinary | protected function uploadFileToCloudinary($file, $publicId)
{
$result = $this->uploader->upload(
$file->getRealPath(),
[
'public_id' => $publicId,
]
);
return $result;
} | php | protected function uploadFileToCloudinary($file, $publicId)
{
$result = $this->uploader->upload(
$file->getRealPath(),
[
'public_id' => $publicId,
]
);
return $result;
} | [
"protected",
"function",
"uploadFileToCloudinary",
"(",
"$",
"file",
",",
"$",
"publicId",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"uploader",
"->",
"upload",
"(",
"$",
"file",
"->",
"getRealPath",
"(",
")",
",",
"[",
"'public_id'",
"=>",
"$",
... | Upload a picture to Cloudinary.
@param SplFileInfo $file The file to upload.
@param string $publicId Path where to upload in Cloudinary.
@return array | [
"Upload",
"a",
"picture",
"to",
"Cloudinary",
"."
] | a8234c8da91c4802a4cbba399cada3181f02f03e | https://github.com/Speicher210/CloudinaryBundle/blob/a8234c8da91c4802a4cbba399cada3181f02f03e/Command/UploadCommand.php#L87-L97 | train |
Matthimatiker/OpcacheBundle | ByteCodeCache/PhpOpcache.php | PhpOpcache.memory | public function memory()
{
$usedInBytes = $this->data['memory_usage']['used_memory'];
$wastedInBytes = $this->data['memory_usage']['wasted_memory'];
$sizeInBytes = $usedInBytes + $wastedInBytes + $this->data['memory_usage']['free_memory'];
return new Memory(
$this->bytesToMb($usedInBytes),
$this->bytesToMb($sizeInBytes),
$this->bytesToMb($wastedInBytes)
);
} | php | public function memory()
{
$usedInBytes = $this->data['memory_usage']['used_memory'];
$wastedInBytes = $this->data['memory_usage']['wasted_memory'];
$sizeInBytes = $usedInBytes + $wastedInBytes + $this->data['memory_usage']['free_memory'];
return new Memory(
$this->bytesToMb($usedInBytes),
$this->bytesToMb($sizeInBytes),
$this->bytesToMb($wastedInBytes)
);
} | [
"public",
"function",
"memory",
"(",
")",
"{",
"$",
"usedInBytes",
"=",
"$",
"this",
"->",
"data",
"[",
"'memory_usage'",
"]",
"[",
"'used_memory'",
"]",
";",
"$",
"wastedInBytes",
"=",
"$",
"this",
"->",
"data",
"[",
"'memory_usage'",
"]",
"[",
"'wasted... | Provides information about the memory usage.
@return Memory | [
"Provides",
"information",
"about",
"the",
"memory",
"usage",
"."
] | c0e7c7400d40ff9da64c9855097f7581d731fcb9 | https://github.com/Matthimatiker/OpcacheBundle/blob/c0e7c7400d40ff9da64c9855097f7581d731fcb9/ByteCodeCache/PhpOpcache.php#L59-L69 | train |
Matthimatiker/OpcacheBundle | ByteCodeCache/PhpOpcache.php | PhpOpcache.scripts | public function scripts()
{
$scripts = array_map(function ($scriptData) {
/* @var $scriptData array<string, mixed> */
return new Script(
$scriptData['full_path'],
$this->bytesToMb($scriptData['memory_consumption']),
$scriptData['hits'],
new \DateTimeImmutable('@' . $scriptData['last_used_timestamp'])
);
}, $this->data['scripts']);
return new ScriptCollection($scripts, $this->calculateCacheSlots());
} | php | public function scripts()
{
$scripts = array_map(function ($scriptData) {
/* @var $scriptData array<string, mixed> */
return new Script(
$scriptData['full_path'],
$this->bytesToMb($scriptData['memory_consumption']),
$scriptData['hits'],
new \DateTimeImmutable('@' . $scriptData['last_used_timestamp'])
);
}, $this->data['scripts']);
return new ScriptCollection($scripts, $this->calculateCacheSlots());
} | [
"public",
"function",
"scripts",
"(",
")",
"{",
"$",
"scripts",
"=",
"array_map",
"(",
"function",
"(",
"$",
"scriptData",
")",
"{",
"/* @var $scriptData array<string, mixed> */",
"return",
"new",
"Script",
"(",
"$",
"scriptData",
"[",
"'full_path'",
"]",
",",
... | Returns data about cached scripts.
@return ScriptCollection | [
"Returns",
"data",
"about",
"cached",
"scripts",
"."
] | c0e7c7400d40ff9da64c9855097f7581d731fcb9 | https://github.com/Matthimatiker/OpcacheBundle/blob/c0e7c7400d40ff9da64c9855097f7581d731fcb9/ByteCodeCache/PhpOpcache.php#L89-L101 | train |
Matthimatiker/OpcacheBundle | ByteCodeCache/PhpOpcache.php | PhpOpcache.internedStrings | public function internedStrings(): InternedStrings
{
$usageInMb = $this->bytesToMb($this->data['interned_strings_usage']['used_memory'] ?? 0);
$sizeInMb = $this->bytesToMb($this->data['interned_strings_usage']['buffer_size'] ?? 0);
$freeInMb = $this->bytesToMb($this->data['interned_strings_usage']['free_memory'] ?? 0);
$stringCount = $this->data['interned_strings_usage']['number_of_strings'] ?? 0;
return new InternedStrings(
$usageInMb,
$sizeInMb,
$freeInMb,
$stringCount
);
} | php | public function internedStrings(): InternedStrings
{
$usageInMb = $this->bytesToMb($this->data['interned_strings_usage']['used_memory'] ?? 0);
$sizeInMb = $this->bytesToMb($this->data['interned_strings_usage']['buffer_size'] ?? 0);
$freeInMb = $this->bytesToMb($this->data['interned_strings_usage']['free_memory'] ?? 0);
$stringCount = $this->data['interned_strings_usage']['number_of_strings'] ?? 0;
return new InternedStrings(
$usageInMb,
$sizeInMb,
$freeInMb,
$stringCount
);
} | [
"public",
"function",
"internedStrings",
"(",
")",
":",
"InternedStrings",
"{",
"$",
"usageInMb",
"=",
"$",
"this",
"->",
"bytesToMb",
"(",
"$",
"this",
"->",
"data",
"[",
"'interned_strings_usage'",
"]",
"[",
"'used_memory'",
"]",
"??",
"0",
")",
";",
"$"... | Returns data about interned strings.
@return InternedStrings | [
"Returns",
"data",
"about",
"interned",
"strings",
"."
] | c0e7c7400d40ff9da64c9855097f7581d731fcb9 | https://github.com/Matthimatiker/OpcacheBundle/blob/c0e7c7400d40ff9da64c9855097f7581d731fcb9/ByteCodeCache/PhpOpcache.php#L118-L131 | train |
Matthimatiker/OpcacheBundle | ByteCodeCache/PhpOpcache.php | PhpOpcache.calculateCacheSlots | protected function calculateCacheSlots()
{
$cachedScripts = $this->data['opcache_statistics']['num_cached_scripts'];
$wasted = $this->data['opcache_statistics']['num_cached_keys'] - $cachedScripts;
return new ScriptSlots(
$cachedScripts,
$this->data['opcache_statistics']['max_cached_keys'],
$wasted
);
} | php | protected function calculateCacheSlots()
{
$cachedScripts = $this->data['opcache_statistics']['num_cached_scripts'];
$wasted = $this->data['opcache_statistics']['num_cached_keys'] - $cachedScripts;
return new ScriptSlots(
$cachedScripts,
$this->data['opcache_statistics']['max_cached_keys'],
$wasted
);
} | [
"protected",
"function",
"calculateCacheSlots",
"(",
")",
"{",
"$",
"cachedScripts",
"=",
"$",
"this",
"->",
"data",
"[",
"'opcache_statistics'",
"]",
"[",
"'num_cached_scripts'",
"]",
";",
"$",
"wasted",
"=",
"$",
"this",
"->",
"data",
"[",
"'opcache_statisti... | Calculates cache slot statistics.
@return ScriptSlots | [
"Calculates",
"cache",
"slot",
"statistics",
"."
] | c0e7c7400d40ff9da64c9855097f7581d731fcb9 | https://github.com/Matthimatiker/OpcacheBundle/blob/c0e7c7400d40ff9da64c9855097f7581d731fcb9/ByteCodeCache/PhpOpcache.php#L138-L147 | train |
bringyourownideas/silverstripe-composer-security-checker | src/Tasks/SecurityAlertCheckTask.php | SecurityAlertCheckTask.discernIdentifier | protected function discernIdentifier($cve, $title)
{
$identifier = $cve;
if (!$identifier || $identifier === '~') {
$identifier = explode(':', $title);
$identifier = array_shift($identifier);
}
$this->extend('updateIdentifier', $identifier, $cve, $title);
return $identifier;
} | php | protected function discernIdentifier($cve, $title)
{
$identifier = $cve;
if (!$identifier || $identifier === '~') {
$identifier = explode(':', $title);
$identifier = array_shift($identifier);
}
$this->extend('updateIdentifier', $identifier, $cve, $title);
return $identifier;
} | [
"protected",
"function",
"discernIdentifier",
"(",
"$",
"cve",
",",
"$",
"title",
")",
"{",
"$",
"identifier",
"=",
"$",
"cve",
";",
"if",
"(",
"!",
"$",
"identifier",
"||",
"$",
"identifier",
"===",
"'~'",
")",
"{",
"$",
"identifier",
"=",
"explode",
... | Most SilverStripe issued alerts are _not_ assiged CVEs.
However they have their own identifier in the form of a
prefix to the title - we can use this instead of a CVE ID.
@param string $cve
@param string $title
@return string | [
"Most",
"SilverStripe",
"issued",
"alerts",
"are",
"_not_",
"assiged",
"CVEs",
".",
"However",
"they",
"have",
"their",
"own",
"identifier",
"in",
"the",
"form",
"of",
"a",
"prefix",
"to",
"the",
"title",
"-",
"we",
"can",
"use",
"this",
"instead",
"of",
... | e8e18929752c0ca7fb51c7f52d1858c3ab3e5ee6 | https://github.com/bringyourownideas/silverstripe-composer-security-checker/blob/e8e18929752c0ca7fb51c7f52d1858c3ab3e5ee6/src/Tasks/SecurityAlertCheckTask.php#L64-L73 | train |
yajra/cms-core | src/Presenters/ArticlePresenter.php | ArticlePresenter.published | public function published()
{
$class = $this->entity->published ? 'fa fa-check-circle-o' : 'fa fa-circle-o';
$state = $this->entity->published ? 'Published' : 'Unpublished';
return html()->tag('i', '', ["class" => $class, "data-toggle" => "tooltip", "data-title" => $state]);
} | php | public function published()
{
$class = $this->entity->published ? 'fa fa-check-circle-o' : 'fa fa-circle-o';
$state = $this->entity->published ? 'Published' : 'Unpublished';
return html()->tag('i', '', ["class" => $class, "data-toggle" => "tooltip", "data-title" => $state]);
} | [
"public",
"function",
"published",
"(",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"entity",
"->",
"published",
"?",
"'fa fa-check-circle-o'",
":",
"'fa fa-circle-o'",
";",
"$",
"state",
"=",
"$",
"this",
"->",
"entity",
"->",
"published",
"?",
"'Publ... | Publication state.
@return string | [
"Publication",
"state",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Presenters/ArticlePresenter.php#L66-L72 | train |
yajra/cms-core | src/Presenters/ArticlePresenter.php | ArticlePresenter.author | public function author()
{
$author = ! empty($this->entity->author_alias)
? $this->entity->author_alias
: $this->entity->createdByName;
return $author ?? config('site.author');
} | php | public function author()
{
$author = ! empty($this->entity->author_alias)
? $this->entity->author_alias
: $this->entity->createdByName;
return $author ?? config('site.author');
} | [
"public",
"function",
"author",
"(",
")",
"{",
"$",
"author",
"=",
"!",
"empty",
"(",
"$",
"this",
"->",
"entity",
"->",
"author_alias",
")",
"?",
"$",
"this",
"->",
"entity",
"->",
"author_alias",
":",
"$",
"this",
"->",
"entity",
"->",
"createdByName... | Get article's author name.
@return string | [
"Get",
"article",
"s",
"author",
"name",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Presenters/ArticlePresenter.php#L79-L86 | train |
yajra/cms-core | src/Presenters/ArticlePresenter.php | ArticlePresenter.title | public function title()
{
$heading = null;
if (session()->has('active_menu')) {
$heading = session('active_menu')->param('page_heading');
}
return $heading ? $heading : $this->entity->title;
} | php | public function title()
{
$heading = null;
if (session()->has('active_menu')) {
$heading = session('active_menu')->param('page_heading');
}
return $heading ? $heading : $this->entity->title;
} | [
"public",
"function",
"title",
"(",
")",
"{",
"$",
"heading",
"=",
"null",
";",
"if",
"(",
"session",
"(",
")",
"->",
"has",
"(",
"'active_menu'",
")",
")",
"{",
"$",
"heading",
"=",
"session",
"(",
"'active_menu'",
")",
"->",
"param",
"(",
"'page_he... | Get the article's title.
@return mixed | [
"Get",
"the",
"article",
"s",
"title",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Presenters/ArticlePresenter.php#L105-L113 | train |
yajra/cms-core | src/Presenters/ArticlePresenter.php | ArticlePresenter.introText | public function introText()
{
$body = explode('<hr id="system-readmore" />', $this->entity->body);
if ($body[0] === $this->entity->body) {
return '';
}
return $body[0];
} | php | public function introText()
{
$body = explode('<hr id="system-readmore" />', $this->entity->body);
if ($body[0] === $this->entity->body) {
return '';
}
return $body[0];
} | [
"public",
"function",
"introText",
"(",
")",
"{",
"$",
"body",
"=",
"explode",
"(",
"'<hr id=\"system-readmore\" />'",
",",
"$",
"this",
"->",
"entity",
"->",
"body",
")",
";",
"if",
"(",
"$",
"body",
"[",
"0",
"]",
"===",
"$",
"this",
"->",
"entity",
... | Get intro text.
@return string | [
"Get",
"intro",
"text",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Presenters/ArticlePresenter.php#L130-L139 | train |
yajra/cms-core | src/Presenters/ArticlePresenter.php | ArticlePresenter.image | public function image()
{
if ($image = $this->articleImage()) {
return $image;
}
if ($image = $this->introImage()) {
return $image;
}
return config('article.image');
} | php | public function image()
{
if ($image = $this->articleImage()) {
return $image;
}
if ($image = $this->introImage()) {
return $image;
}
return config('article.image');
} | [
"public",
"function",
"image",
"(",
")",
"{",
"if",
"(",
"$",
"image",
"=",
"$",
"this",
"->",
"articleImage",
"(",
")",
")",
"{",
"return",
"$",
"image",
";",
"}",
"if",
"(",
"$",
"image",
"=",
"$",
"this",
"->",
"introImage",
"(",
")",
")",
"... | Get article intro image.
@return \Illuminate\Contracts\Routing\UrlGenerator|string | [
"Get",
"article",
"intro",
"image",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Presenters/ArticlePresenter.php#L146-L156 | train |
swoft-cloud/swoft-websocket-server | src/WebSocketContext.php | WebSocketContext.setFdToCoId | public static function setFdToCoId(int $fd)
{
$cid = self::getCoroutineId();
self::$map[$cid] = $fd;
} | php | public static function setFdToCoId(int $fd)
{
$cid = self::getCoroutineId();
self::$map[$cid] = $fd;
} | [
"public",
"static",
"function",
"setFdToCoId",
"(",
"int",
"$",
"fd",
")",
"{",
"$",
"cid",
"=",
"self",
"::",
"getCoroutineId",
"(",
")",
";",
"self",
"::",
"$",
"map",
"[",
"$",
"cid",
"]",
"=",
"$",
"fd",
";",
"}"
] | init coId to fd mapping
@param int $fd | [
"init",
"coId",
"to",
"fd",
"mapping"
] | b1f7ae57618a1b4746d5f92b114d23bc3f5f91e5 | https://github.com/swoft-cloud/swoft-websocket-server/blob/b1f7ae57618a1b4746d5f92b114d23bc3f5f91e5/src/WebSocketContext.php#L246-L251 | train |
swoft-cloud/swoft-websocket-server | src/WebSocketContext.php | WebSocketContext.delFdByCoId | public static function delFdByCoId(int $cid = null): bool
{
$cid = $cid > -1 ? $cid : self::getCoroutineId();
if (isset(self::$map[$cid])) {
unset(self::$map[$cid]);
return true;
}
return false;
} | php | public static function delFdByCoId(int $cid = null): bool
{
$cid = $cid > -1 ? $cid : self::getCoroutineId();
if (isset(self::$map[$cid])) {
unset(self::$map[$cid]);
return true;
}
return false;
} | [
"public",
"static",
"function",
"delFdByCoId",
"(",
"int",
"$",
"cid",
"=",
"null",
")",
":",
"bool",
"{",
"$",
"cid",
"=",
"$",
"cid",
">",
"-",
"1",
"?",
"$",
"cid",
":",
"self",
"::",
"getCoroutineId",
"(",
")",
";",
"if",
"(",
"isset",
"(",
... | delete coId to fd mapping
@param int|null $cid
@return bool | [
"delete",
"coId",
"to",
"fd",
"mapping"
] | b1f7ae57618a1b4746d5f92b114d23bc3f5f91e5 | https://github.com/swoft-cloud/swoft-websocket-server/blob/b1f7ae57618a1b4746d5f92b114d23bc3f5f91e5/src/WebSocketContext.php#L268-L279 | train |
yajra/cms-core | src/Repositories/Extension/CacheRepository.php | CacheRepository.findOrFail | public function findOrFail($id)
{
return $this->cache->rememberForever('extension.' . $id, function () use ($id){
return $this->repository->findOrFail($id);
});
} | php | public function findOrFail($id)
{
return $this->cache->rememberForever('extension.' . $id, function () use ($id){
return $this->repository->findOrFail($id);
});
} | [
"public",
"function",
"findOrFail",
"(",
"$",
"id",
")",
"{",
"return",
"$",
"this",
"->",
"cache",
"->",
"rememberForever",
"(",
"'extension.'",
".",
"$",
"id",
",",
"function",
"(",
")",
"use",
"(",
"$",
"id",
")",
"{",
"return",
"$",
"this",
"->",... | Find or fail an extension.
@param int $id
@return \Yajra\CMS\Entities\Extension | [
"Find",
"or",
"fail",
"an",
"extension",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Repositories/Extension/CacheRepository.php#L75-L80 | train |
yajra/cms-core | src/Providers/ViewComposerServiceProvider.php | ViewComposerServiceProvider.bootAdministratorViewComposer | protected function bootAdministratorViewComposer()
{
view()->composer('administrator.widgets.*', function (View $view) {
/** @var \Yajra\CMS\Themes\Repositories\Repository $themes */
$themes = $this->app['themes'];
$theme = $themes->current();
$positions = $theme->positions;
$data = [];
foreach ($positions as $position) {
$data[$position] = Str::title($position);
}
$view->with('widget_positions', $data);
$view->with('theme', $theme);
/** @var \Yajra\CMS\Repositories\Extension\Repository $extensions */
$extensions = $this->app['extensions'];
$widgets = $extensions->allWidgets()->filter(function ($extension) {
return $extension->enabled;
});
$view->with('extensions', $widgets);
});
view()->composer(['administrator.partials.permissions'], function (View $view) {
$view->with('permissions', Permission::orderBy('resource')->get());
});
} | php | protected function bootAdministratorViewComposer()
{
view()->composer('administrator.widgets.*', function (View $view) {
/** @var \Yajra\CMS\Themes\Repositories\Repository $themes */
$themes = $this->app['themes'];
$theme = $themes->current();
$positions = $theme->positions;
$data = [];
foreach ($positions as $position) {
$data[$position] = Str::title($position);
}
$view->with('widget_positions', $data);
$view->with('theme', $theme);
/** @var \Yajra\CMS\Repositories\Extension\Repository $extensions */
$extensions = $this->app['extensions'];
$widgets = $extensions->allWidgets()->filter(function ($extension) {
return $extension->enabled;
});
$view->with('extensions', $widgets);
});
view()->composer(['administrator.partials.permissions'], function (View $view) {
$view->with('permissions', Permission::orderBy('resource')->get());
});
} | [
"protected",
"function",
"bootAdministratorViewComposer",
"(",
")",
"{",
"view",
"(",
")",
"->",
"composer",
"(",
"'administrator.widgets.*'",
",",
"function",
"(",
"View",
"$",
"view",
")",
"{",
"/** @var \\Yajra\\CMS\\Themes\\Repositories\\Repository $themes */",
"$",
... | Register administrator view composers. | [
"Register",
"administrator",
"view",
"composers",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Providers/ViewComposerServiceProvider.php#L33-L59 | train |
siphoc/PdfBundle | Converter/CssPathToUrl.php | CssPathToUrl.replaceCssPaths | public function replaceCssPaths(array $links)
{
foreach ($links as $key => $link) {
if (!$this->isExternalStylesheet($link)) {
$links[$key] = $this->getUrl() . $link;
}
}
return $links;
} | php | public function replaceCssPaths(array $links)
{
foreach ($links as $key => $link) {
if (!$this->isExternalStylesheet($link)) {
$links[$key] = $this->getUrl() . $link;
}
}
return $links;
} | [
"public",
"function",
"replaceCssPaths",
"(",
"array",
"$",
"links",
")",
"{",
"foreach",
"(",
"$",
"links",
"as",
"$",
"key",
"=>",
"$",
"link",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isExternalStylesheet",
"(",
"$",
"link",
")",
")",
"{",
... | Replace a given set of links with the proper url if it is an external
css file.
@param array $links
@return array | [
"Replace",
"a",
"given",
"set",
"of",
"links",
"with",
"the",
"proper",
"url",
"if",
"it",
"is",
"an",
"external",
"css",
"file",
"."
] | 89fcc6974158069a4e97b9a8cba2587b9c9b8ce0 | https://github.com/siphoc/PdfBundle/blob/89fcc6974158069a4e97b9a8cba2587b9c9b8ce0/Converter/CssPathToUrl.php#L57-L66 | train |
yajra/cms-core | src/Http/Controllers/UtilitiesController.php | UtilitiesController.backup | public function backup($task = 'run')
{
if (! in_array($task, ['run', 'clean'])) {
$message = trans('cms::utilities.backup.not_allowed',
['task' => $task]) . trans('cms::utilities.field.executed_by',
['name' => $this->getCurrentUserName()]);
$this->log->info($message);
return $this->notifyError($message);
}
Artisan::call('backup:' . $task);
$message = $task == 'clean' ? trans('cms::utilities.backup.cleanup_complete') : trans('cms::utilities.backup.complete');
$this->log->info($message . trans('cms::utilities.field.executed_by', ['name' => $this->getCurrentUserName()]));
return $this->notifySuccess($message);
} | php | public function backup($task = 'run')
{
if (! in_array($task, ['run', 'clean'])) {
$message = trans('cms::utilities.backup.not_allowed',
['task' => $task]) . trans('cms::utilities.field.executed_by',
['name' => $this->getCurrentUserName()]);
$this->log->info($message);
return $this->notifyError($message);
}
Artisan::call('backup:' . $task);
$message = $task == 'clean' ? trans('cms::utilities.backup.cleanup_complete') : trans('cms::utilities.backup.complete');
$this->log->info($message . trans('cms::utilities.field.executed_by', ['name' => $this->getCurrentUserName()]));
return $this->notifySuccess($message);
} | [
"public",
"function",
"backup",
"(",
"$",
"task",
"=",
"'run'",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"task",
",",
"[",
"'run'",
",",
"'clean'",
"]",
")",
")",
"{",
"$",
"message",
"=",
"trans",
"(",
"'cms::utilities.backup.not_allowed'",
","... | Execute back up manually.
@param string $task
@return \Illuminate\Http\JsonResponse | [
"Execute",
"back",
"up",
"manually",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/UtilitiesController.php#L70-L86 | train |
yajra/cms-core | src/Http/Controllers/UtilitiesController.php | UtilitiesController.cache | public function cache()
{
Artisan::call('cache:clear');
$this->log->info(trans('cms::utilities.cache.success') . trans('cms::utilities.field.executed_by',
['name' => $this->getCurrentUserName()]));
return $this->notifySuccess(trans('cms::utilities.cache.success'));
} | php | public function cache()
{
Artisan::call('cache:clear');
$this->log->info(trans('cms::utilities.cache.success') . trans('cms::utilities.field.executed_by',
['name' => $this->getCurrentUserName()]));
return $this->notifySuccess(trans('cms::utilities.cache.success'));
} | [
"public",
"function",
"cache",
"(",
")",
"{",
"Artisan",
"::",
"call",
"(",
"'cache:clear'",
")",
";",
"$",
"this",
"->",
"log",
"->",
"info",
"(",
"trans",
"(",
"'cms::utilities.cache.success'",
")",
".",
"trans",
"(",
"'cms::utilities.field.executed_by'",
",... | Clear cache manually.
@return \Illuminate\Http\JsonResponse | [
"Clear",
"cache",
"manually",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/UtilitiesController.php#L103-L110 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.