id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
46,300 | Spoje-NET/FlexiPeeHP | src/FlexiPeeHP/Adresar.php | Adresar.getAnyPhoneNumber | public function getAnyPhoneNumber()
{
$phoneNo = null;
$numbersRaw = $this->getFlexiData($this->getApiURL(),
['detail' => 'custom:id,mobil,tel,kontakty(primarni,mobil,tel)', 'relations' => 'kontakty']);
if (is_array($numbersRaw) && !empty($numbersRaw[0])) {
$numbers = $numbersRaw[0];
if (array_key_exists('mobil', $numbers) && strlen(trim($numbers['mobil']))) {
$phoneNo = $numbers['mobil'];
}
if (array_key_exists('tel', $numbers) && strlen(trim($numbers['tel']))) {
$phoneNo = $numbers['tel'];
}
if (array_key_exists('kontakty', $numbers) && !empty($numbers['kontakty'])) {
foreach ($numbers['kontakty'] as $kontakt) {
if ($kontakt['primarni'] == 'true') {
}
if (strlen(trim($kontakt['mobil']))) {
$phoneNo = $kontakt['mobil'];
break;
} elseif (strlen(trim($kontakt['mobil']))) {
$phoneNo = $kontakt['mobil'];
break;
}
}
}
}
return $phoneNo;
} | php | public function getAnyPhoneNumber()
{
$phoneNo = null;
$numbersRaw = $this->getFlexiData($this->getApiURL(),
['detail' => 'custom:id,mobil,tel,kontakty(primarni,mobil,tel)', 'relations' => 'kontakty']);
if (is_array($numbersRaw) && !empty($numbersRaw[0])) {
$numbers = $numbersRaw[0];
if (array_key_exists('mobil', $numbers) && strlen(trim($numbers['mobil']))) {
$phoneNo = $numbers['mobil'];
}
if (array_key_exists('tel', $numbers) && strlen(trim($numbers['tel']))) {
$phoneNo = $numbers['tel'];
}
if (array_key_exists('kontakty', $numbers) && !empty($numbers['kontakty'])) {
foreach ($numbers['kontakty'] as $kontakt) {
if ($kontakt['primarni'] == 'true') {
}
if (strlen(trim($kontakt['mobil']))) {
$phoneNo = $kontakt['mobil'];
break;
} elseif (strlen(trim($kontakt['mobil']))) {
$phoneNo = $kontakt['mobil'];
break;
}
}
}
}
return $phoneNo;
} | [
"public",
"function",
"getAnyPhoneNumber",
"(",
")",
"{",
"$",
"phoneNo",
"=",
"null",
";",
"$",
"numbersRaw",
"=",
"$",
"this",
"->",
"getFlexiData",
"(",
"$",
"this",
"->",
"getApiURL",
"(",
")",
",",
"[",
"'detail'",
"=>",
"'custom:id,mobil,tel,kontakty(p... | get any phone Number for Customer with primary contact prefered
@return string phone number of primary contact or address's phone number or null | [
"get",
"any",
"phone",
"Number",
"for",
"Customer",
"with",
"primary",
"contact",
"prefered"
] | 8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73 | https://github.com/Spoje-NET/FlexiPeeHP/blob/8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73/src/FlexiPeeHP/Adresar.php#L86-L115 |
46,301 | hiqdev/hipanel-core | src/components/SettingsStorage.php | SettingsStorage.perform | private function perform($action, $data)
{
if ($this->app->user->isGuest) {
return [];
}
return Client::perform($action, $data);
} | php | private function perform($action, $data)
{
if ($this->app->user->isGuest) {
return [];
}
return Client::perform($action, $data);
} | [
"private",
"function",
"perform",
"(",
"$",
"action",
",",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"app",
"->",
"user",
"->",
"isGuest",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"Client",
"::",
"perform",
"(",
"$",
"action",
... | Performs request to the API.
@param string $key
@param array $value
@return array | [
"Performs",
"request",
"to",
"the",
"API",
"."
] | 090eb4b95dd731b338cd661b569f6b9b999f95e4 | https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/components/SettingsStorage.php#L85-L92 |
46,302 | hiqdev/hipanel-core | src/grid/MainColumn.php | MainColumn.buildUrl | public function buildUrl($url)
{
if (strncmp($url, '/', 1) === 0) {
return $url;
}
$baseUrl = isset($this->grid->controllerUrl) ? $this->grid->controllerUrl : '';
return $baseUrl ? Url::to($baseUrl . '/' . $url) : Url::to($url);
} | php | public function buildUrl($url)
{
if (strncmp($url, '/', 1) === 0) {
return $url;
}
$baseUrl = isset($this->grid->controllerUrl) ? $this->grid->controllerUrl : '';
return $baseUrl ? Url::to($baseUrl . '/' . $url) : Url::to($url);
} | [
"public",
"function",
"buildUrl",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"strncmp",
"(",
"$",
"url",
",",
"'/'",
",",
"1",
")",
"===",
"0",
")",
"{",
"return",
"$",
"url",
";",
"}",
"$",
"baseUrl",
"=",
"isset",
"(",
"$",
"this",
"->",
"grid",
... | Builds url.
@param string $url
@return string | [
"Builds",
"url",
"."
] | 090eb4b95dd731b338cd661b569f6b9b999f95e4 | https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/grid/MainColumn.php#L49-L57 |
46,303 | hiqdev/hipanel-core | src/grid/MainColumn.php | MainColumn.renderNoteLink | public function renderNoteLink($model, $key, $index)
{
return $this->note ? Html::tag('span', Yii::t('hipanel', 'Note') . ': ', ['class' => 'bold']) . XEditable::widget([
'model' => $model,
'attribute' => $this->note === true ? 'note' : $this->note,
'pluginOptions' => $this->noteOptions,
]) : null;
} | php | public function renderNoteLink($model, $key, $index)
{
return $this->note ? Html::tag('span', Yii::t('hipanel', 'Note') . ': ', ['class' => 'bold']) . XEditable::widget([
'model' => $model,
'attribute' => $this->note === true ? 'note' : $this->note,
'pluginOptions' => $this->noteOptions,
]) : null;
} | [
"public",
"function",
"renderNoteLink",
"(",
"$",
"model",
",",
"$",
"key",
",",
"$",
"index",
")",
"{",
"return",
"$",
"this",
"->",
"note",
"?",
"Html",
"::",
"tag",
"(",
"'span'",
",",
"Yii",
"::",
"t",
"(",
"'hipanel'",
",",
"'Note'",
")",
".",... | Renders link to edit note.
@param $model
@param $key
@param $index
@return string|null | [
"Renders",
"link",
"to",
"edit",
"note",
"."
] | 090eb4b95dd731b338cd661b569f6b9b999f95e4 | https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/grid/MainColumn.php#L107-L114 |
46,304 | Spoje-NET/FlexiPeeHP | src/FlexiPeeHP/Company.php | Company.saveBackupTo | public function saveBackupTo($filename)
{
$result = false;
$headersBackup = $this->defaultHttpHeaders;
$this->defaultHttpHeaders['Accept'] = '*/*';
$this->defaultHttpHeaders['Content-Type'] = 'application/x-winstrom-backup';
$this->performRequest('backup', 'GET');
$this->defaultHttpHeaders = $headersBackup;
if ($this->lastResponseCode == 200) {
if (file_put_contents($filename, $this->lastCurlResponse)) {
$result = true;
}
}
$this->defaultHttpHeaders = $headersBackup;
return $result;
} | php | public function saveBackupTo($filename)
{
$result = false;
$headersBackup = $this->defaultHttpHeaders;
$this->defaultHttpHeaders['Accept'] = '*/*';
$this->defaultHttpHeaders['Content-Type'] = 'application/x-winstrom-backup';
$this->performRequest('backup', 'GET');
$this->defaultHttpHeaders = $headersBackup;
if ($this->lastResponseCode == 200) {
if (file_put_contents($filename, $this->lastCurlResponse)) {
$result = true;
}
}
$this->defaultHttpHeaders = $headersBackup;
return $result;
} | [
"public",
"function",
"saveBackupTo",
"(",
"$",
"filename",
")",
"{",
"$",
"result",
"=",
"false",
";",
"$",
"headersBackup",
"=",
"$",
"this",
"->",
"defaultHttpHeaders",
";",
"$",
"this",
"->",
"defaultHttpHeaders",
"[",
"'Accept'",
"]",
"=",
"'*/*'",
";... | Save company backup to file
@param string $filename
@return boolean was backup saved to file ? | [
"Save",
"company",
"backup",
"to",
"file"
] | 8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73 | https://github.com/Spoje-NET/FlexiPeeHP/blob/8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73/src/FlexiPeeHP/Company.php#L159-L175 |
46,305 | Spoje-NET/FlexiPeeHP | src/FlexiPeeHP/Company.php | Company.restoreBackupFrom | public function restoreBackupFrom($filename, $name = null,
$disableEet = false,
$disableAutoSendMail = false,
$disableWebHooks = false)
{
$options = [];
if (!empty($name)) {
$options['name'] = $name;
}
if ($disableEet === true) {
$options['disableEet'] = 1;
}
if ($disableAutoSendMail === true) {
$options['disableAutoSendMail'] = 1;
}
if ($disableWebHooks === true) {
$options['disableWebHooks'] = 1;
}
$headersBackup = $this->defaultHttpHeaders;
$this->defaultHttpHeaders['Accept'] = '*/*';
$this->defaultHttpHeaders['Content-Type'] = 'application/x-winstrom-backup';
$this->setPostFields(file_get_contents($filename));
$this->performRequest('restore'.(empty($options) ? '' : '?'.http_build_query($options) ),
'PUT');
return $this->lastResponseCode == 200;
} | php | public function restoreBackupFrom($filename, $name = null,
$disableEet = false,
$disableAutoSendMail = false,
$disableWebHooks = false)
{
$options = [];
if (!empty($name)) {
$options['name'] = $name;
}
if ($disableEet === true) {
$options['disableEet'] = 1;
}
if ($disableAutoSendMail === true) {
$options['disableAutoSendMail'] = 1;
}
if ($disableWebHooks === true) {
$options['disableWebHooks'] = 1;
}
$headersBackup = $this->defaultHttpHeaders;
$this->defaultHttpHeaders['Accept'] = '*/*';
$this->defaultHttpHeaders['Content-Type'] = 'application/x-winstrom-backup';
$this->setPostFields(file_get_contents($filename));
$this->performRequest('restore'.(empty($options) ? '' : '?'.http_build_query($options) ),
'PUT');
return $this->lastResponseCode == 200;
} | [
"public",
"function",
"restoreBackupFrom",
"(",
"$",
"filename",
",",
"$",
"name",
"=",
"null",
",",
"$",
"disableEet",
"=",
"false",
",",
"$",
"disableAutoSendMail",
"=",
"false",
",",
"$",
"disableWebHooks",
"=",
"false",
")",
"{",
"$",
"options",
"=",
... | Restore company from given file
@link https://www.flexibee.eu/api/dokumentace/ref/restore-backup/ Obnovení ze zálohy
@param string $filename *.winstrom-backup file
@param string $name Extra name for restored company
@param boolean $disableEet Disable EET on restored company
@param boolean $disableAutoSendMail Dsable auto sending of all documents
@param boolean $disableWebHooks Remove Registered webhooks
@return boolean restore result | [
"Restore",
"company",
"from",
"given",
"file"
] | 8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73 | https://github.com/Spoje-NET/FlexiPeeHP/blob/8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73/src/FlexiPeeHP/Company.php#L190-L216 |
46,306 | hiqdev/hipanel-core | src/helpers/ArrayHelper.php | ArrayHelper.csplit | public static function csplit($string, $delimiter = ',')
{
if (is_array($string)) {
return $string;
}
$res = [];
foreach (explode($delimiter, $string) as $k => $v) {
$v = trim($v);
if (strlen($v)) {
array_push($res, $v);
}
}
return $res;
} | php | public static function csplit($string, $delimiter = ',')
{
if (is_array($string)) {
return $string;
}
$res = [];
foreach (explode($delimiter, $string) as $k => $v) {
$v = trim($v);
if (strlen($v)) {
array_push($res, $v);
}
}
return $res;
} | [
"public",
"static",
"function",
"csplit",
"(",
"$",
"string",
",",
"$",
"delimiter",
"=",
"','",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"string",
")",
")",
"{",
"return",
"$",
"string",
";",
"}",
"$",
"res",
"=",
"[",
"]",
";",
"foreach",
"("... | Parses data, exploding the string by comma, trying to create array.
@param $string
@param string $delimiter
@return array | [
"Parses",
"data",
"exploding",
"the",
"string",
"by",
"comma",
"trying",
"to",
"create",
"array",
"."
] | 090eb4b95dd731b338cd661b569f6b9b999f95e4 | https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/helpers/ArrayHelper.php#L37-L51 |
46,307 | Spoje-NET/FlexiPeeHP | src/FlexiPeeHP/FakturaVydana.php | FakturaVydana.vytvorVazbuZDD | public function vytvorVazbuZDD($income)
{
switch (get_class($income)) {
case 'FlexiPeeHP\\Banka':
$modul = 'banka';
break;
case 'FlexiPeeHP\\PokladniPohyb':
$modul = 'pokladna';
break;
default :
throw new \Ease\Exception(_('Unsupported $income parameter type'));
}
$incomeId = $income->getRecordID();
$myId = $this->getRecordID();
$headersBackup = $this->defaultHttpHeaders;
$this->defaultHttpHeaders['Accept'] = 'text/html';
$this->setPostFields(http_build_query(['modul' => $modul,
'submit' => 'OK']));
$this->performRequest($myId.'/vytvor-vazbu-zdd/'.$incomeId, 'GET',
'json');
$responseArr = explode("\n", $this->lastCurlResponse);
$result = true;
$message = '';
foreach ($responseArr as $lineNo => $responseLine) {
if (strstr($responseLine, '<ul class = "flexibee-errors">')) {
$message = trim($responseArr[$lineNo + 1]);
$result = false;
}
if (strstr($responseLine, '<div class = "alert alert-success">')) {
$message = strip_tags(html_entity_decode(trim($responseArr[$lineNo
+ 1])));
$result = true;
}
}
if ($result === true) {
$this->addStatusMessage(empty($message) ? $this->getDataValue('kod').'/vytvor-vazbu-zdd/'.$income->getRecordCode()
: $message, 'success');
} else {
$this->addStatusMessage($this->getDataValue('kod').'/vytvor-vazbu-zdd/'.$incomeId,
'warning');
}
$this->defaultHttpHeaders = $headersBackup;
return $result;
} | php | public function vytvorVazbuZDD($income)
{
switch (get_class($income)) {
case 'FlexiPeeHP\\Banka':
$modul = 'banka';
break;
case 'FlexiPeeHP\\PokladniPohyb':
$modul = 'pokladna';
break;
default :
throw new \Ease\Exception(_('Unsupported $income parameter type'));
}
$incomeId = $income->getRecordID();
$myId = $this->getRecordID();
$headersBackup = $this->defaultHttpHeaders;
$this->defaultHttpHeaders['Accept'] = 'text/html';
$this->setPostFields(http_build_query(['modul' => $modul,
'submit' => 'OK']));
$this->performRequest($myId.'/vytvor-vazbu-zdd/'.$incomeId, 'GET',
'json');
$responseArr = explode("\n", $this->lastCurlResponse);
$result = true;
$message = '';
foreach ($responseArr as $lineNo => $responseLine) {
if (strstr($responseLine, '<ul class = "flexibee-errors">')) {
$message = trim($responseArr[$lineNo + 1]);
$result = false;
}
if (strstr($responseLine, '<div class = "alert alert-success">')) {
$message = strip_tags(html_entity_decode(trim($responseArr[$lineNo
+ 1])));
$result = true;
}
}
if ($result === true) {
$this->addStatusMessage(empty($message) ? $this->getDataValue('kod').'/vytvor-vazbu-zdd/'.$income->getRecordCode()
: $message, 'success');
} else {
$this->addStatusMessage($this->getDataValue('kod').'/vytvor-vazbu-zdd/'.$incomeId,
'warning');
}
$this->defaultHttpHeaders = $headersBackup;
return $result;
} | [
"public",
"function",
"vytvorVazbuZDD",
"(",
"$",
"income",
")",
"{",
"switch",
"(",
"get_class",
"(",
"$",
"income",
")",
")",
"{",
"case",
"'FlexiPeeHP\\\\Banka'",
":",
"$",
"modul",
"=",
"'banka'",
";",
"break",
";",
"case",
"'FlexiPeeHP\\\\PokladniPohyb'",... | add link to advance tax document
@param Banka|PokladniPohyb $income Income payment document
@return boolean success
@throws Exception | [
"add",
"link",
"to",
"advance",
"tax",
"document"
] | 8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73 | https://github.com/Spoje-NET/FlexiPeeHP/blob/8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73/src/FlexiPeeHP/FakturaVydana.php#L155-L205 |
46,308 | Spoje-NET/FlexiPeeHP | src/FlexiPeeHP/FakturaVydana.php | FakturaVydana.overdueDays | static public function overdueDays($dueDate)
{
$dateDiff = date_diff(is_object($dueDate) ? $dueDate : FlexiBeeRO::flexiDateToDateTime($dueDate),
new \DateTime());
if ($dateDiff->invert == 1) {
$ddif = $dateDiff->days * -1;
} else {
$ddif = $dateDiff->days;
}
return $ddif;
} | php | static public function overdueDays($dueDate)
{
$dateDiff = date_diff(is_object($dueDate) ? $dueDate : FlexiBeeRO::flexiDateToDateTime($dueDate),
new \DateTime());
if ($dateDiff->invert == 1) {
$ddif = $dateDiff->days * -1;
} else {
$ddif = $dateDiff->days;
}
return $ddif;
} | [
"static",
"public",
"function",
"overdueDays",
"(",
"$",
"dueDate",
")",
"{",
"$",
"dateDiff",
"=",
"date_diff",
"(",
"is_object",
"(",
"$",
"dueDate",
")",
"?",
"$",
"dueDate",
":",
"FlexiBeeRO",
"::",
"flexiDateToDateTime",
"(",
"$",
"dueDate",
")",
",",... | Get Number of days overdue
@param string $dueDate FlexiBee date
@return int | [
"Get",
"Number",
"of",
"days",
"overdue"
] | 8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73 | https://github.com/Spoje-NET/FlexiPeeHP/blob/8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73/src/FlexiPeeHP/FakturaVydana.php#L241-L252 |
46,309 | hiqdev/hipanel-core | src/widgets/ModalButton.php | ModalButton.initOptions | protected function initOptions()
{
if (!($this->model instanceof Model)) {
throw new InvalidConfigException('Model is required');
}
if (!($this->model->getPrimaryKey())) {
throw new InvalidConfigException('Model has empty primary key');
}
if ($this->button !== false) {
$this->button['position'] = isset($this->button['position']) ? $this->button['position'] : static::BUTTON_OUTSIDE;
}
if (empty($this->scenario)) {
$this->scenario = $this->model->scenario;
} else {
$this->_oldScenario = $this->model->scenario;
$this->model->scenario = $this->scenario;
}
if ($this->form !== false) {
$formConfig = [
'method' => 'POST',
'action' => $this->scenario,
'options' => [
'class' => 'inline',
'data' => [
'modal-form' => true,
],
],
];
if ($this->submit === static::SUBMIT_PJAX) {
$formConfig['options'] = ArrayHelper::merge($formConfig['options'], [
'data' => ['pjax' => 1, 'pjax-push' => 0],
]);
} elseif ($this->submit === static::SUBMIT_AJAX) {
$formConfig['options'] = ArrayHelper::merge($formConfig['options'], [
'data' => ['ajax-submit' => 1],
]);
$this->registerAjaxSubmit();
}
$this->form = ArrayHelper::merge($formConfig, $this->form);
}
if (is_array($footer = $this->modal['footer'])) {
$tag = ArrayHelper::remove($footer, 'tag', 'input');
$label = ArrayHelper::remove($footer, 'label', 'OK');
$footer = ArrayHelper::merge([
'data-modal-submit' => true,
'data-loading-text' => '<i class="fa fa-circle-o-notch fa-spin"></i> ' . Yii::t('hipanel', 'loading'),
], $footer);
if ($tag === 'input') {
$footer['type'] = 'submit';
$footer['value'] = $label;
}
$this->modal['footer'] = Html::tag($tag, $label, $footer);
$this->registerFooterButtonScript();
}
$this->modal = ArrayHelper::merge([
'id' => $this->getModalId(),
'toggleButton' => ($this->button['position'] === static::BUTTON_IN_MODAL) ? $this->button : false,
], $this->modal);
} | php | protected function initOptions()
{
if (!($this->model instanceof Model)) {
throw new InvalidConfigException('Model is required');
}
if (!($this->model->getPrimaryKey())) {
throw new InvalidConfigException('Model has empty primary key');
}
if ($this->button !== false) {
$this->button['position'] = isset($this->button['position']) ? $this->button['position'] : static::BUTTON_OUTSIDE;
}
if (empty($this->scenario)) {
$this->scenario = $this->model->scenario;
} else {
$this->_oldScenario = $this->model->scenario;
$this->model->scenario = $this->scenario;
}
if ($this->form !== false) {
$formConfig = [
'method' => 'POST',
'action' => $this->scenario,
'options' => [
'class' => 'inline',
'data' => [
'modal-form' => true,
],
],
];
if ($this->submit === static::SUBMIT_PJAX) {
$formConfig['options'] = ArrayHelper::merge($formConfig['options'], [
'data' => ['pjax' => 1, 'pjax-push' => 0],
]);
} elseif ($this->submit === static::SUBMIT_AJAX) {
$formConfig['options'] = ArrayHelper::merge($formConfig['options'], [
'data' => ['ajax-submit' => 1],
]);
$this->registerAjaxSubmit();
}
$this->form = ArrayHelper::merge($formConfig, $this->form);
}
if (is_array($footer = $this->modal['footer'])) {
$tag = ArrayHelper::remove($footer, 'tag', 'input');
$label = ArrayHelper::remove($footer, 'label', 'OK');
$footer = ArrayHelper::merge([
'data-modal-submit' => true,
'data-loading-text' => '<i class="fa fa-circle-o-notch fa-spin"></i> ' . Yii::t('hipanel', 'loading'),
], $footer);
if ($tag === 'input') {
$footer['type'] = 'submit';
$footer['value'] = $label;
}
$this->modal['footer'] = Html::tag($tag, $label, $footer);
$this->registerFooterButtonScript();
}
$this->modal = ArrayHelper::merge([
'id' => $this->getModalId(),
'toggleButton' => ($this->button['position'] === static::BUTTON_IN_MODAL) ? $this->button : false,
], $this->modal);
} | [
"protected",
"function",
"initOptions",
"(",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"model",
"instanceof",
"Model",
")",
")",
"{",
"throw",
"new",
"InvalidConfigException",
"(",
"'Model is required'",
")",
";",
"}",
"if",
"(",
"!",
"(",
"$",
... | Initialization of options.
@throws InvalidConfigException | [
"Initialization",
"of",
"options",
"."
] | 090eb4b95dd731b338cd661b569f6b9b999f95e4 | https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/widgets/ModalButton.php#L162-L230 |
46,310 | hiqdev/hipanel-core | src/widgets/ModalButton.php | ModalButton.run | public function run()
{
$this->endModal();
if ($this->form !== false) {
$this->endForm();
}
if ($this->_oldScenario !== null) {
$this->model->scenario = $this->_oldScenario;
}
} | php | public function run()
{
$this->endModal();
if ($this->form !== false) {
$this->endForm();
}
if ($this->_oldScenario !== null) {
$this->model->scenario = $this->_oldScenario;
}
} | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"this",
"->",
"endModal",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"form",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"endForm",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"_oldScena... | Runs widget. | [
"Runs",
"widget",
"."
] | 090eb4b95dd731b338cd661b569f6b9b999f95e4 | https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/widgets/ModalButton.php#L235-L246 |
46,311 | hiqdev/hipanel-core | src/widgets/ModalButton.php | ModalButton.renderButton | public function renderButton()
{
if (($button = $this->button) !== false) {
$tag = ArrayHelper::remove($button, 'tag', 'a');
$label = ArrayHelper::remove($button, 'label',
Inflector::camel2words(Inflector::id2camel($this->scenario)));
if ($tag === 'button' && !isset($button['type'])) {
$toggleButton['type'] = 'button';
}
if ($button['disabled']) {
$button = ArrayHelper::merge([
'onClick' => new JsExpression('return false'),
], $button);
} else {
$button = ArrayHelper::merge([
'data-toggle' => 'modal',
'data-target' => "#{$this->getModalId()}",
], $button);
}
if ($tag === 'a' && empty($button['href'])) {
$button['href'] = '#';
}
echo Html::tag($tag, $label, $button);
}
} | php | public function renderButton()
{
if (($button = $this->button) !== false) {
$tag = ArrayHelper::remove($button, 'tag', 'a');
$label = ArrayHelper::remove($button, 'label',
Inflector::camel2words(Inflector::id2camel($this->scenario)));
if ($tag === 'button' && !isset($button['type'])) {
$toggleButton['type'] = 'button';
}
if ($button['disabled']) {
$button = ArrayHelper::merge([
'onClick' => new JsExpression('return false'),
], $button);
} else {
$button = ArrayHelper::merge([
'data-toggle' => 'modal',
'data-target' => "#{$this->getModalId()}",
], $button);
}
if ($tag === 'a' && empty($button['href'])) {
$button['href'] = '#';
}
echo Html::tag($tag, $label, $button);
}
} | [
"public",
"function",
"renderButton",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"button",
"=",
"$",
"this",
"->",
"button",
")",
"!==",
"false",
")",
"{",
"$",
"tag",
"=",
"ArrayHelper",
"::",
"remove",
"(",
"$",
"button",
",",
"'tag'",
",",
"'a'",
")",
... | Renders toggle button. | [
"Renders",
"toggle",
"button",
"."
] | 090eb4b95dd731b338cd661b569f6b9b999f95e4 | https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/widgets/ModalButton.php#L251-L278 |
46,312 | hiqdev/hipanel-core | src/widgets/ModalButton.php | ModalButton.beginForm | public function beginForm()
{
$this->form = ActiveForm::begin($this->form);
$inputId = $this->getModalId() . '-hidden-value';
echo Html::activeHiddenInput($this->model, 'id', ['id' => $inputId]);
} | php | public function beginForm()
{
$this->form = ActiveForm::begin($this->form);
$inputId = $this->getModalId() . '-hidden-value';
echo Html::activeHiddenInput($this->model, 'id', ['id' => $inputId]);
} | [
"public",
"function",
"beginForm",
"(",
")",
"{",
"$",
"this",
"->",
"form",
"=",
"ActiveForm",
"::",
"begin",
"(",
"$",
"this",
"->",
"form",
")",
";",
"$",
"inputId",
"=",
"$",
"this",
"->",
"getModalId",
"(",
")",
".",
"'-hidden-value'",
";",
"ech... | Begins form. | [
"Begins",
"form",
"."
] | 090eb4b95dd731b338cd661b569f6b9b999f95e4 | https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/widgets/ModalButton.php#L298-L304 |
46,313 | hiqdev/hipanel-core | src/widgets/ModalButton.php | ModalButton.registerAjaxSubmit | public function registerAjaxSubmit()
{
$view = Yii::$app->view;
$options = ArrayHelper::merge([
'type' => new JsExpression("form.attr('method')"),
'url' => new JsExpression("form.attr('action')"),
'data' => new JsExpression('form.serialize()'),
], $this->ajaxOptions);
$options = Json::encode($options);
$view->registerJs(<<<JS
$('form[data-ajax-submit]').on('submit', function(event) {
var form = $(this);
if (event.eventPhase === 2) {
$.ajax($options);
$('.modal-backdrop').remove();
}
event.preventDefault();
});
JS
);
} | php | public function registerAjaxSubmit()
{
$view = Yii::$app->view;
$options = ArrayHelper::merge([
'type' => new JsExpression("form.attr('method')"),
'url' => new JsExpression("form.attr('action')"),
'data' => new JsExpression('form.serialize()'),
], $this->ajaxOptions);
$options = Json::encode($options);
$view->registerJs(<<<JS
$('form[data-ajax-submit]').on('submit', function(event) {
var form = $(this);
if (event.eventPhase === 2) {
$.ajax($options);
$('.modal-backdrop').remove();
}
event.preventDefault();
});
JS
);
} | [
"public",
"function",
"registerAjaxSubmit",
"(",
")",
"{",
"$",
"view",
"=",
"Yii",
"::",
"$",
"app",
"->",
"view",
";",
"$",
"options",
"=",
"ArrayHelper",
"::",
"merge",
"(",
"[",
"'type'",
"=>",
"new",
"JsExpression",
"(",
"\"form.attr('method')\"",
")"... | Registers JavaScript for ajax submit. | [
"Registers",
"JavaScript",
"for",
"ajax",
"submit",
"."
] | 090eb4b95dd731b338cd661b569f6b9b999f95e4 | https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/widgets/ModalButton.php#L333-L355 |
46,314 | hiqdev/hipanel-core | src/actions/Action.php | Action.getCollection | public function getCollection()
{
if ($this->parent) {
return $this->parent->getCollection();
}
if (!is_object($this->_collection)) {
$action = $this->controller->action;
if ($action instanceof self) {
$scenario = $action->getScenario();
} else {
$scenario = $action->id;
}
$this->_collection = Yii::createObject(ArrayHelper::merge([
'class' => Collection::class,
'model' => $this->controller->newModel(['scenario' => $scenario]),
'scenario' => $scenario,
'queryOptions' => $this->queryOptions,
], (array) $this->_collection));
}
return $this->_collection;
} | php | public function getCollection()
{
if ($this->parent) {
return $this->parent->getCollection();
}
if (!is_object($this->_collection)) {
$action = $this->controller->action;
if ($action instanceof self) {
$scenario = $action->getScenario();
} else {
$scenario = $action->id;
}
$this->_collection = Yii::createObject(ArrayHelper::merge([
'class' => Collection::class,
'model' => $this->controller->newModel(['scenario' => $scenario]),
'scenario' => $scenario,
'queryOptions' => $this->queryOptions,
], (array) $this->_collection));
}
return $this->_collection;
} | [
"public",
"function",
"getCollection",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"parent",
")",
"{",
"return",
"$",
"this",
"->",
"parent",
"->",
"getCollection",
"(",
")",
";",
"}",
"if",
"(",
"!",
"is_object",
"(",
"$",
"this",
"->",
"_collectio... | Gets the instance of the collection.
@return Collection | [
"Gets",
"the",
"instance",
"of",
"the",
"collection",
"."
] | 090eb4b95dd731b338cd661b569f6b9b999f95e4 | https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/actions/Action.php#L97-L120 |
46,315 | hiqdev/hipanel-core | src/actions/Action.php | Action.perform | public function perform()
{
$this->beforePerform();
$this->loadCollection();
try {
$error = !$this->saveCollection();
if ($error === true && $this->collection->hasErrors()) {
$error = $this->collection->getFirstError();
}
} catch (ResponseErrorException $e) {
$error = $e->getMessage();
} catch (InvalidCallException $e) {
$error = $e->getMessage();
}
$this->afterPerform();
return $error;
} | php | public function perform()
{
$this->beforePerform();
$this->loadCollection();
try {
$error = !$this->saveCollection();
if ($error === true && $this->collection->hasErrors()) {
$error = $this->collection->getFirstError();
}
} catch (ResponseErrorException $e) {
$error = $e->getMessage();
} catch (InvalidCallException $e) {
$error = $e->getMessage();
}
$this->afterPerform();
return $error;
} | [
"public",
"function",
"perform",
"(",
")",
"{",
"$",
"this",
"->",
"beforePerform",
"(",
")",
";",
"$",
"this",
"->",
"loadCollection",
"(",
")",
";",
"try",
"{",
"$",
"error",
"=",
"!",
"$",
"this",
"->",
"saveCollection",
"(",
")",
";",
"if",
"("... | Performs action.
@return boolean|string Whether save is success
- boolean true or sting - an error
- false - no errors | [
"Performs",
"action",
"."
] | 090eb4b95dd731b338cd661b569f6b9b999f95e4 | https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/actions/Action.php#L199-L220 |
46,316 | hiqdev/hipanel-core | src/actions/Action.php | Action.getModelClass | public function getModelClass()
{
if (isset($this->parent)) {
return $this->parent->getModelClass();
}
if (isset($this->getCollection()->first)) {
return $this->getCollection()->first->class;
}
return get_class($this->getCollection()->getModel());
} | php | public function getModelClass()
{
if (isset($this->parent)) {
return $this->parent->getModelClass();
}
if (isset($this->getCollection()->first)) {
return $this->getCollection()->first->class;
}
return get_class($this->getCollection()->getModel());
} | [
"public",
"function",
"getModelClass",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"parent",
")",
")",
"{",
"return",
"$",
"this",
"->",
"parent",
"->",
"getModelClass",
"(",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",... | Return the model class name.
@return string | [
"Return",
"the",
"model",
"class",
"name",
"."
] | 090eb4b95dd731b338cd661b569f6b9b999f95e4 | https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/actions/Action.php#L235-L246 |
46,317 | hiqdev/hipanel-core | src/actions/Action.php | Action.prepareData | public function prepareData($data = [])
{
return (array) ($this->data instanceof Closure ? call_user_func($this->data, $this, $data) : $this->data);
} | php | public function prepareData($data = [])
{
return (array) ($this->data instanceof Closure ? call_user_func($this->data, $this, $data) : $this->data);
} | [
"public",
"function",
"prepareData",
"(",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"return",
"(",
"array",
")",
"(",
"$",
"this",
"->",
"data",
"instanceof",
"Closure",
"?",
"call_user_func",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"this",
",",
"$",
... | Prepares additional data for render.
@param $data array Additional data, prepared by other classes. Optional.
@return array | [
"Prepares",
"additional",
"data",
"for",
"render",
"."
] | 090eb4b95dd731b338cd661b569f6b9b999f95e4 | https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/actions/Action.php#L262-L265 |
46,318 | hiqdev/hipanel-core | src/actions/Action.php | Action.addFlash | public function addFlash($type, $error = null)
{
if ($type === 'error' && is_string($error) && !empty($error)) {
$text = Yii::t('hipanel', $error);
} else {
$text = $this->getFlashText($type);
}
if ($type instanceof Closure) {
$text = call_user_func($text, $text, $this);
}
Yii::$app->session->addFlash($type, [
'text' => $text,
]);
} | php | public function addFlash($type, $error = null)
{
if ($type === 'error' && is_string($error) && !empty($error)) {
$text = Yii::t('hipanel', $error);
} else {
$text = $this->getFlashText($type);
}
if ($type instanceof Closure) {
$text = call_user_func($text, $text, $this);
}
Yii::$app->session->addFlash($type, [
'text' => $text,
]);
} | [
"public",
"function",
"addFlash",
"(",
"$",
"type",
",",
"$",
"error",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"type",
"===",
"'error'",
"&&",
"is_string",
"(",
"$",
"error",
")",
"&&",
"!",
"empty",
"(",
"$",
"error",
")",
")",
"{",
"$",
"text",
... | Adds flash message.
@param string $type the type of flash
@param string $error the text of error | [
"Adds",
"flash",
"message",
"."
] | 090eb4b95dd731b338cd661b569f6b9b999f95e4 | https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/actions/Action.php#L299-L314 |
46,319 | hiqdev/hipanel-core | src/actions/SmartUpdateAction.php | SmartUpdateAction.fetchModels | public function fetchModels()
{
$this->beforeFetchLoad();
$dataProvider = $this->getDataProvider();
$this->beforeFetch();
return $dataProvider->getModels();
} | php | public function fetchModels()
{
$this->beforeFetchLoad();
$dataProvider = $this->getDataProvider();
$this->beforeFetch();
return $dataProvider->getModels();
} | [
"public",
"function",
"fetchModels",
"(",
")",
"{",
"$",
"this",
"->",
"beforeFetchLoad",
"(",
")",
";",
"$",
"dataProvider",
"=",
"$",
"this",
"->",
"getDataProvider",
"(",
")",
";",
"$",
"this",
"->",
"beforeFetch",
"(",
")",
";",
"return",
"$",
"dat... | Fetches models that will be edited.
@throws BadRequestHttpException
@return Model[] | [
"Fetches",
"models",
"that",
"will",
"be",
"edited",
"."
] | 090eb4b95dd731b338cd661b569f6b9b999f95e4 | https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/actions/SmartUpdateAction.php#L239-L246 |
46,320 | Spoje-NET/FlexiPeeHP | src/FlexiPeeHP/SkladovyPohybPolozka.php | SkladovyPohybPolozka.addSerialNumber | public function addSerialNumber($number, $isMain = false)
{
$numberBranch['kod'] = $number;
$crrentSerialNumbers = $this->getDataValue('vyrobniCislaPrijata');
if ($isMain) {
if (!empty($crrentSerialNumbers)) {
foreach (array_keys($crrentSerialNumbers) as $serialNumberID) {
unset($this->data['vyrobniCislaPrijata'][$serialNumberID]['vyrobnicislohlav']);
}
}
$numberBranch['vyrobnicislohlav'] = 1;
}
$this->setDataValue('mnozMj', count($crrentSerialNumbers) + 1);
return $this->addArrayToBranch($numberBranch, 'vyrobniCislaPrijata');
} | php | public function addSerialNumber($number, $isMain = false)
{
$numberBranch['kod'] = $number;
$crrentSerialNumbers = $this->getDataValue('vyrobniCislaPrijata');
if ($isMain) {
if (!empty($crrentSerialNumbers)) {
foreach (array_keys($crrentSerialNumbers) as $serialNumberID) {
unset($this->data['vyrobniCislaPrijata'][$serialNumberID]['vyrobnicislohlav']);
}
}
$numberBranch['vyrobnicislohlav'] = 1;
}
$this->setDataValue('mnozMj', count($crrentSerialNumbers) + 1);
return $this->addArrayToBranch($numberBranch, 'vyrobniCislaPrijata');
} | [
"public",
"function",
"addSerialNumber",
"(",
"$",
"number",
",",
"$",
"isMain",
"=",
"false",
")",
"{",
"$",
"numberBranch",
"[",
"'kod'",
"]",
"=",
"$",
"number",
";",
"$",
"crrentSerialNumbers",
"=",
"$",
"this",
"->",
"getDataValue",
"(",
"'vyrobniCisl... | Add Items Serial Number
@param string $number serial number
@param boolean $isMain main number
@return boolean Success | [
"Add",
"Items",
"Serial",
"Number"
] | 8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73 | https://github.com/Spoje-NET/FlexiPeeHP/blob/8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73/src/FlexiPeeHP/SkladovyPohybPolozka.php#L35-L49 |
46,321 | hiqdev/hipanel-core | src/widgets/ArraySpoiler.php | ArraySpoiler.renderButtonSpoiler | protected function renderButtonSpoiler()
{
$options = ArrayHelper::merge([
'role' => 'button',
'data-spoiler-group' => 'main',
'data-spoiler-toggle' => true,
'data-target' => $this->button['id'] . '-body',
], $this->button);
$label = $this->getButtonLabel(ArrayHelper::remove($options, 'label'));
$this->parts['{button}'] = Html::tag(ArrayHelper::remove($options, 'tag'), $label, $options);
$this->getView()->registerJs("
$('[data-spoiler-toggle]').click(function (e) {
$('#'+$(this).data('target')).toggle();
$('[data-spoiler-group=\"{$options['data-spoiler-group']}\"]').not($(this)).trigger('hide');
}).on('hide', function () {
$('#'+$(this).data('target')).hide();
})",
View::POS_READY);
} | php | protected function renderButtonSpoiler()
{
$options = ArrayHelper::merge([
'role' => 'button',
'data-spoiler-group' => 'main',
'data-spoiler-toggle' => true,
'data-target' => $this->button['id'] . '-body',
], $this->button);
$label = $this->getButtonLabel(ArrayHelper::remove($options, 'label'));
$this->parts['{button}'] = Html::tag(ArrayHelper::remove($options, 'tag'), $label, $options);
$this->getView()->registerJs("
$('[data-spoiler-toggle]').click(function (e) {
$('#'+$(this).data('target')).toggle();
$('[data-spoiler-group=\"{$options['data-spoiler-group']}\"]').not($(this)).trigger('hide');
}).on('hide', function () {
$('#'+$(this).data('target')).hide();
})",
View::POS_READY);
} | [
"protected",
"function",
"renderButtonSpoiler",
"(",
")",
"{",
"$",
"options",
"=",
"ArrayHelper",
"::",
"merge",
"(",
"[",
"'role'",
"=>",
"'button'",
",",
"'data-spoiler-group'",
"=>",
"'main'",
",",
"'data-spoiler-toggle'",
"=>",
"true",
",",
"'data-target'",
... | Renders a button for spoiler activator.
Additional special options, that will be extracted from [[$this->button]]:
- `data-popover-group` - Group of popovers. Is used to close all other popovers in group, when new one is opening. Default: 'main'
@see http://getbootstrap.com/javascript/#popovers-options | [
"Renders",
"a",
"button",
"for",
"spoiler",
"activator",
"."
] | 090eb4b95dd731b338cd661b569f6b9b999f95e4 | https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/widgets/ArraySpoiler.php#L286-L306 |
46,322 | hiqdev/hipanel-core | src/widgets/ArraySpoiler.php | ArraySpoiler.renderHiddenSpoiler | public function renderHiddenSpoiler()
{
$options = ArrayHelper::merge([
'id' => $this->button['id'] . '-body',
'tag' => 'span',
'value' => implode($this->hiddenDelimiter ?? $this->delimiter, $this->getSpoiledItems()),
'class' => 'collapse',
'data-spoiler-body' => true,
], $this->hidden);
$this->parts['{hidden}'] = Html::tag(ArrayHelper::remove($options, 'tag'), ArrayHelper::remove($options, 'value'), $options);
} | php | public function renderHiddenSpoiler()
{
$options = ArrayHelper::merge([
'id' => $this->button['id'] . '-body',
'tag' => 'span',
'value' => implode($this->hiddenDelimiter ?? $this->delimiter, $this->getSpoiledItems()),
'class' => 'collapse',
'data-spoiler-body' => true,
], $this->hidden);
$this->parts['{hidden}'] = Html::tag(ArrayHelper::remove($options, 'tag'), ArrayHelper::remove($options, 'value'), $options);
} | [
"public",
"function",
"renderHiddenSpoiler",
"(",
")",
"{",
"$",
"options",
"=",
"ArrayHelper",
"::",
"merge",
"(",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"button",
"[",
"'id'",
"]",
".",
"'-body'",
",",
"'tag'",
"=>",
"'span'",
",",
"'value'",
"=>",
"i... | Renders a spoiler-button-activated hidden part. | [
"Renders",
"a",
"spoiler",
"-",
"button",
"-",
"activated",
"hidden",
"part",
"."
] | 090eb4b95dd731b338cd661b569f6b9b999f95e4 | https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/widgets/ArraySpoiler.php#L311-L322 |
46,323 | hiqdev/hipanel-core | src/widgets/ArraySpoiler.php | ArraySpoiler.getButtonLabel | public function getButtonLabel($label)
{
if ($label instanceof Closure) {
$label = call_user_func($label, $this);
} else {
$label = Yii::t('hipanel', $label, ['count' => count($this->getSpoiledItems())]);
}
return $label;
} | php | public function getButtonLabel($label)
{
if ($label instanceof Closure) {
$label = call_user_func($label, $this);
} else {
$label = Yii::t('hipanel', $label, ['count' => count($this->getSpoiledItems())]);
}
return $label;
} | [
"public",
"function",
"getButtonLabel",
"(",
"$",
"label",
")",
"{",
"if",
"(",
"$",
"label",
"instanceof",
"Closure",
")",
"{",
"$",
"label",
"=",
"call_user_func",
"(",
"$",
"label",
",",
"$",
"this",
")",
";",
"}",
"else",
"{",
"$",
"label",
"=",
... | Returns the button label.
@param $label string|Closure
@return mixed|string | [
"Returns",
"the",
"button",
"label",
"."
] | 090eb4b95dd731b338cd661b569f6b9b999f95e4 | https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/widgets/ArraySpoiler.php#L330-L339 |
46,324 | hiqdev/hipanel-core | src/widgets/ArraySpoiler.php | ArraySpoiler.run | public function run()
{
if (!isset($this->parts['{visible}'])) {
$this->renderVisible();
}
if (!isset($this->parts['{button}'])) {
$this->renderSpoiled();
}
if (!isset($this->parts['{hidden}'])) {
$this->renderHidden();
}
echo strtr($this->template, $this->parts);
} | php | public function run()
{
if (!isset($this->parts['{visible}'])) {
$this->renderVisible();
}
if (!isset($this->parts['{button}'])) {
$this->renderSpoiled();
}
if (!isset($this->parts['{hidden}'])) {
$this->renderHidden();
}
echo strtr($this->template, $this->parts);
} | [
"public",
"function",
"run",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"parts",
"[",
"'{visible}'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"renderVisible",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->... | Renders the all the widget. | [
"Renders",
"the",
"all",
"the",
"widget",
"."
] | 090eb4b95dd731b338cd661b569f6b9b999f95e4 | https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/widgets/ArraySpoiler.php#L344-L357 |
46,325 | Spoje-NET/FlexiPeeHP | src/FlexiPeeHP/Stitek.php | Stitek.getLabels | public static function getLabels($object)
{
$labels = null;
$labelsRaw = $object->getDataValue('stitky');
if (strlen($labelsRaw)) {
$labels = is_array($labelsRaw) ? $labelsRaw : self::listToArray($labelsRaw);
}
return $labels;
} | php | public static function getLabels($object)
{
$labels = null;
$labelsRaw = $object->getDataValue('stitky');
if (strlen($labelsRaw)) {
$labels = is_array($labelsRaw) ? $labelsRaw : self::listToArray($labelsRaw);
}
return $labels;
} | [
"public",
"static",
"function",
"getLabels",
"(",
"$",
"object",
")",
"{",
"$",
"labels",
"=",
"null",
";",
"$",
"labelsRaw",
"=",
"$",
"object",
"->",
"getDataValue",
"(",
"'stitky'",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"labelsRaw",
")",
")",
"... | Obtain labels for current record
@deprecated since version 1.21
@param FlexiBeeRO $object data source
@return array labels | [
"Obtain",
"labels",
"for",
"current",
"record"
] | 8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73 | https://github.com/Spoje-NET/FlexiPeeHP/blob/8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73/src/FlexiPeeHP/Stitek.php#L60-L69 |
46,326 | Spoje-NET/FlexiPeeHP | src/FlexiPeeHP/Stitek.php | Stitek.listToArray | public static function listToArray($listRaw)
{
if (is_array($listRaw)) {
$list = array_combine(array_values($listRaw), array_values($listRaw));
} else {
if (strstr($listRaw, ',')) {
$list = array_map('trim', explode(',', $listRaw));
} else {
$list = [$listRaw];
}
$list = array_combine($list, $list);
}
return empty($listRaw) ? [] : $list;
} | php | public static function listToArray($listRaw)
{
if (is_array($listRaw)) {
$list = array_combine(array_values($listRaw), array_values($listRaw));
} else {
if (strstr($listRaw, ',')) {
$list = array_map('trim', explode(',', $listRaw));
} else {
$list = [$listRaw];
}
$list = array_combine($list, $list);
}
return empty($listRaw) ? [] : $list;
} | [
"public",
"static",
"function",
"listToArray",
"(",
"$",
"listRaw",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"listRaw",
")",
")",
"{",
"$",
"list",
"=",
"array_combine",
"(",
"array_values",
"(",
"$",
"listRaw",
")",
",",
"array_values",
"(",
"$",
"l... | Convert coma-separated list to array
@param string $listRaw
@return array | [
"Convert",
"coma",
"-",
"separated",
"list",
"to",
"array"
] | 8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73 | https://github.com/Spoje-NET/FlexiPeeHP/blob/8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73/src/FlexiPeeHP/Stitek.php#L78-L91 |
46,327 | Spoje-NET/FlexiPeeHP | src/FlexiPeeHP/Stitek.php | Stitek.getAvailbleLabels | public static function getAvailbleLabels($object)
{
$labels = [];
$evidenceBackup = $object->getEvidence();
$object->setEvidence('stitek');
$pathToVsb = array_flip(self::$vsbToEvidencePath);
if (array_key_exists($evidenceBackup, $pathToVsb)) {
$labelsRaw = $object->getColumnsFromFlexiBee(['kod', 'nazev'],
[$pathToVsb[$evidenceBackup] => true], 'nazev');
if (count($labelsRaw)) {
foreach ($labelsRaw as $labelInfo) {
$labels[$labelInfo['kod']] = $labelInfo['nazev'];
}
}
}
$object->setEvidence($evidenceBackup);
return $labels;
} | php | public static function getAvailbleLabels($object)
{
$labels = [];
$evidenceBackup = $object->getEvidence();
$object->setEvidence('stitek');
$pathToVsb = array_flip(self::$vsbToEvidencePath);
if (array_key_exists($evidenceBackup, $pathToVsb)) {
$labelsRaw = $object->getColumnsFromFlexiBee(['kod', 'nazev'],
[$pathToVsb[$evidenceBackup] => true], 'nazev');
if (count($labelsRaw)) {
foreach ($labelsRaw as $labelInfo) {
$labels[$labelInfo['kod']] = $labelInfo['nazev'];
}
}
}
$object->setEvidence($evidenceBackup);
return $labels;
} | [
"public",
"static",
"function",
"getAvailbleLabels",
"(",
"$",
"object",
")",
"{",
"$",
"labels",
"=",
"[",
"]",
";",
"$",
"evidenceBackup",
"=",
"$",
"object",
"->",
"getEvidence",
"(",
")",
";",
"$",
"object",
"->",
"setEvidence",
"(",
"'stitek'",
")",... | Obtain list of availble labels for given object
@param FlexiBeeRO $object
@return array | [
"Obtain",
"list",
"of",
"availble",
"labels",
"for",
"given",
"object"
] | 8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73 | https://github.com/Spoje-NET/FlexiPeeHP/blob/8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73/src/FlexiPeeHP/Stitek.php#L100-L119 |
46,328 | Spoje-NET/FlexiPeeHP | src/FlexiPeeHP/Stitek.php | Stitek.createNew | public function createNew($name, $evidences, $options = [])
{
$this->setData($options, true);
$evidence2code = array_flip(self::$vsbToEvidencePath);
foreach ($evidences as $evidence) {
if (array_key_exists($evidence, $evidence2code)) {
$this->setDataValue($evidence2code[$evidence], true);
}
}
if (!array_key_exists('kod', $options)) {
$this->setDataValue('kod', self::code($name));
}
$this->setDataValue('nazev', $name);
return $this->sync();
} | php | public function createNew($name, $evidences, $options = [])
{
$this->setData($options, true);
$evidence2code = array_flip(self::$vsbToEvidencePath);
foreach ($evidences as $evidence) {
if (array_key_exists($evidence, $evidence2code)) {
$this->setDataValue($evidence2code[$evidence], true);
}
}
if (!array_key_exists('kod', $options)) {
$this->setDataValue('kod', self::code($name));
}
$this->setDataValue('nazev', $name);
return $this->sync();
} | [
"public",
"function",
"createNew",
"(",
"$",
"name",
",",
"$",
"evidences",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"setData",
"(",
"$",
"options",
",",
"true",
")",
";",
"$",
"evidence2code",
"=",
"array_flip",
"(",
"self",
... | Create New Label for given evidencies
@param string $name Label Name
@param array $evidences Evidence code list ex: ['faktura-vydana','faktura-prijata']
@param array $options Additional Label properties ex: ['kod'=>'EXAMPLE','skupVybKlic'=>'SKUPINA_STITKU']
@return boolean success | [
"Create",
"New",
"Label",
"for",
"given",
"evidencies"
] | 8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73 | https://github.com/Spoje-NET/FlexiPeeHP/blob/8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73/src/FlexiPeeHP/Stitek.php#L168-L183 |
46,329 | symbiote/silverstripe-multisites | src/Model/Site.php | Site.requireDefaultRecords | public function requireDefaultRecords() {
parent::requireDefaultRecords();
if(Site::get()->count() > 0) {
return;
}
$site = Site::create();
$site->Title = _t('Multisites.DEFAULTSITE', 'Default Site');
$site->IsDefault = true;
$site->FolderID = Folder::find_or_make('default-site')->ID;
$site->write();
$site->publish('Stage', 'Live');
DB::alteration_message('Default site created', 'created');
$pages = SiteTree::get()->exclude('ID', $site->ID)->filter('ParentID', 0);
$count = count($pages);
if ($count > 0) {
foreach($pages as $page) {
$page->ParentID = $site->ID;
$page->write();
if ($page->isPublished()) {
$page->publish('Stage', 'Live');
}
}
DB::alteration_message("Moved $count existing pages under new default site.", 'changed');
}
} | php | public function requireDefaultRecords() {
parent::requireDefaultRecords();
if(Site::get()->count() > 0) {
return;
}
$site = Site::create();
$site->Title = _t('Multisites.DEFAULTSITE', 'Default Site');
$site->IsDefault = true;
$site->FolderID = Folder::find_or_make('default-site')->ID;
$site->write();
$site->publish('Stage', 'Live');
DB::alteration_message('Default site created', 'created');
$pages = SiteTree::get()->exclude('ID', $site->ID)->filter('ParentID', 0);
$count = count($pages);
if ($count > 0) {
foreach($pages as $page) {
$page->ParentID = $site->ID;
$page->write();
if ($page->isPublished()) {
$page->publish('Stage', 'Live');
}
}
DB::alteration_message("Moved $count existing pages under new default site.", 'changed');
}
} | [
"public",
"function",
"requireDefaultRecords",
"(",
")",
"{",
"parent",
"::",
"requireDefaultRecords",
"(",
")",
";",
"if",
"(",
"Site",
"::",
"get",
"(",
")",
"->",
"count",
"(",
")",
">",
"0",
")",
"{",
"return",
";",
"}",
"$",
"site",
"=",
"Site",... | Make sure there is a site record. | [
"Make",
"sure",
"there",
"is",
"a",
"site",
"record",
"."
] | 9b3fa1d3375ce073c050bd137b68766073efd458 | https://github.com/symbiote/silverstripe-multisites/blob/9b3fa1d3375ce073c050bd137b68766073efd458/src/Model/Site.php#L236-L265 |
46,330 | symbiote/silverstripe-multisites | src/Model/Site.php | Site.get_by_link | static public function get_by_link($link, $cache = true) {
$current = Multisites::inst()->getCurrentSiteId();
if(trim($link, '/')) {
$link = trim(Director::makeRelative($link), '/');
} else {
$link = RootURLController::get_homepage_link();
}
$parts = Convert::raw2sql(preg_split('|/+|', $link));
// Grab the initial root level page to traverse down from.
$URLSegment = array_shift($parts);
$sitetree = DataObject::get_one (
SiteTree::class, "\"URLSegment\" = '$URLSegment' AND \"ParentID\" = " . $current, $cache
);
if (!$sitetree) {
return false;
}
/// Fall back on a unique URLSegment for b/c.
if(!$sitetree && self::nested_urls() && $page = DataObject::get(SiteTree::class, "\"URLSegment\" = '$URLSegment'")->First()) {
return $page;
}
// Check if we have any more URL parts to parse.
if(!count($parts)) return $sitetree;
// Traverse down the remaining URL segments and grab the relevant SiteTree objects.
foreach($parts as $segment) {
$next = DataObject::get_one (
SiteTree::class, "\"URLSegment\" = '$segment' AND \"ParentID\" = $sitetree->ID", $cache
);
if(!$next) {
return false;
}
$sitetree->destroy();
$sitetree = $next;
}
return $sitetree;
} | php | static public function get_by_link($link, $cache = true) {
$current = Multisites::inst()->getCurrentSiteId();
if(trim($link, '/')) {
$link = trim(Director::makeRelative($link), '/');
} else {
$link = RootURLController::get_homepage_link();
}
$parts = Convert::raw2sql(preg_split('|/+|', $link));
// Grab the initial root level page to traverse down from.
$URLSegment = array_shift($parts);
$sitetree = DataObject::get_one (
SiteTree::class, "\"URLSegment\" = '$URLSegment' AND \"ParentID\" = " . $current, $cache
);
if (!$sitetree) {
return false;
}
/// Fall back on a unique URLSegment for b/c.
if(!$sitetree && self::nested_urls() && $page = DataObject::get(SiteTree::class, "\"URLSegment\" = '$URLSegment'")->First()) {
return $page;
}
// Check if we have any more URL parts to parse.
if(!count($parts)) return $sitetree;
// Traverse down the remaining URL segments and grab the relevant SiteTree objects.
foreach($parts as $segment) {
$next = DataObject::get_one (
SiteTree::class, "\"URLSegment\" = '$segment' AND \"ParentID\" = $sitetree->ID", $cache
);
if(!$next) {
return false;
}
$sitetree->destroy();
$sitetree = $next;
}
return $sitetree;
} | [
"static",
"public",
"function",
"get_by_link",
"(",
"$",
"link",
",",
"$",
"cache",
"=",
"true",
")",
"{",
"$",
"current",
"=",
"Multisites",
"::",
"inst",
"(",
")",
"->",
"getCurrentSiteId",
"(",
")",
";",
"if",
"(",
"trim",
"(",
"$",
"link",
",",
... | Alternative implementation that takes into account the current site
as the root
@param type $link
@param type $cache
@return boolean | [
"Alternative",
"implementation",
"that",
"takes",
"into",
"account",
"the",
"current",
"site",
"as",
"the",
"root"
] | 9b3fa1d3375ce073c050bd137b68766073efd458 | https://github.com/symbiote/silverstripe-multisites/blob/9b3fa1d3375ce073c050bd137b68766073efd458/src/Model/Site.php#L275-L320 |
46,331 | symbiote/silverstripe-multisites | src/Model/Site.php | Site.getSiteTheme | public function getSiteTheme(){
$theme = $this->Theme;
if (!$theme) {
$theme = Config::inst()->get(SSViewer::class, 'theme');
}
$this->extend('updateGetSiteTheme', $theme);
return $theme;
} | php | public function getSiteTheme(){
$theme = $this->Theme;
if (!$theme) {
$theme = Config::inst()->get(SSViewer::class, 'theme');
}
$this->extend('updateGetSiteTheme', $theme);
return $theme;
} | [
"public",
"function",
"getSiteTheme",
"(",
")",
"{",
"$",
"theme",
"=",
"$",
"this",
"->",
"Theme",
";",
"if",
"(",
"!",
"$",
"theme",
")",
"{",
"$",
"theme",
"=",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"SSViewer",
"::",
"class",
","... | Get the name of the theme applied to this site, allow extensions to override
@return String | [
"Get",
"the",
"name",
"of",
"the",
"theme",
"applied",
"to",
"this",
"site",
"allow",
"extensions",
"to",
"override"
] | 9b3fa1d3375ce073c050bd137b68766073efd458 | https://github.com/symbiote/silverstripe-multisites/blob/9b3fa1d3375ce073c050bd137b68766073efd458/src/Model/Site.php#L327-L334 |
46,332 | symbiote/silverstripe-multisites | src/Model/Site.php | Site.hasFeature | public function hasFeature($feature){
if(!$this->DevID) return false;
$sites = Config::inst()->get('Multisites', 'site_features');
if(!isset($sites[$this->DevID])) return false;
$features = ArrayLib::valuekey($sites[$this->DevID]);
if(!isset($features[$feature])) return false;
return true;
} | php | public function hasFeature($feature){
if(!$this->DevID) return false;
$sites = Config::inst()->get('Multisites', 'site_features');
if(!isset($sites[$this->DevID])) return false;
$features = ArrayLib::valuekey($sites[$this->DevID]);
if(!isset($features[$feature])) return false;
return true;
} | [
"public",
"function",
"hasFeature",
"(",
"$",
"feature",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"DevID",
")",
"return",
"false",
";",
"$",
"sites",
"=",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"'Multisites'",
",",
"'site_features'",
... | Checks to see if this site has a feature as defined in Muiltisites.site_features config
@return Boolean | [
"Checks",
"to",
"see",
"if",
"this",
"site",
"has",
"a",
"feature",
"as",
"defined",
"in",
"Muiltisites",
".",
"site_features",
"config"
] | 9b3fa1d3375ce073c050bd137b68766073efd458 | https://github.com/symbiote/silverstripe-multisites/blob/9b3fa1d3375ce073c050bd137b68766073efd458/src/Model/Site.php#L341-L353 |
46,333 | hryvinskyi/magento2-base | Plugin/DebugHints.php | DebugHints.afterCreate | public function afterCreate(
TemplateEngineFactory $subject,
TemplateEngineInterface $invocationResult
): TemplateEngineInterface {
$storeCode = $this->storeManager->getStore()->getCode();
if (
$this->config->isEnabledLayoutDebug() &&
$this->request->getParam('hints') &&
$this->devHelper->isDevAllowed()
) {
$showBlockHints = (
$this->scopeConfig->getValue(
self::XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS,
ScopeInterface::SCOPE_STORE,
$storeCode
) || $this->request->getParam('hints-block')
);
return $this->debugHintsFactory->create([
'subject' => $invocationResult,
'showBlockHints' => $showBlockHints,
]);
}
return $invocationResult;
} | php | public function afterCreate(
TemplateEngineFactory $subject,
TemplateEngineInterface $invocationResult
): TemplateEngineInterface {
$storeCode = $this->storeManager->getStore()->getCode();
if (
$this->config->isEnabledLayoutDebug() &&
$this->request->getParam('hints') &&
$this->devHelper->isDevAllowed()
) {
$showBlockHints = (
$this->scopeConfig->getValue(
self::XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS,
ScopeInterface::SCOPE_STORE,
$storeCode
) || $this->request->getParam('hints-block')
);
return $this->debugHintsFactory->create([
'subject' => $invocationResult,
'showBlockHints' => $showBlockHints,
]);
}
return $invocationResult;
} | [
"public",
"function",
"afterCreate",
"(",
"TemplateEngineFactory",
"$",
"subject",
",",
"TemplateEngineInterface",
"$",
"invocationResult",
")",
":",
"TemplateEngineInterface",
"{",
"$",
"storeCode",
"=",
"$",
"this",
"->",
"storeManager",
"->",
"getStore",
"(",
")"... | Wrap template engine instance with the debugging hints decorator, depending of the store configuration
@param TemplateEngineFactory $subject
@param TemplateEngineInterface $invocationResult
@return TemplateEngineInterface | [
"Wrap",
"template",
"engine",
"instance",
"with",
"the",
"debugging",
"hints",
"decorator",
"depending",
"of",
"the",
"store",
"configuration"
] | 7648c4d0c82a281c82aa1cf30d1808674ca40604 | https://github.com/hryvinskyi/magento2-base/blob/7648c4d0c82a281c82aa1cf30d1808674ca40604/Plugin/DebugHints.php#L96-L121 |
46,334 | symbiote/silverstripe-multisites | src/Admin/MultisitesModelAdminExtension.php | MultisitesModelAdminExtension.checkMultisitesAware | public function checkMultisitesAware() {
// only true if using silverstripe-recipe <= 4.3.0
if (!$this->owner->hasMethod('getModelClass')) {
$models = $this->owner->getManagedModels();
// throw error if any models use MultisitesAware extension
foreach ($models as $model => $val) {
if($model::has_extension(MultisitesAware::class)) {
throw new \Exception(
'`ModelAdmin::getModelClass()` missing. You are likely using `silverstripe-recipe:4.3.0` which introduced this bug. This can be fixed by updating to `silverstripe-recipe:4.3.1` or greater.'
);
}
}
}
} | php | public function checkMultisitesAware() {
// only true if using silverstripe-recipe <= 4.3.0
if (!$this->owner->hasMethod('getModelClass')) {
$models = $this->owner->getManagedModels();
// throw error if any models use MultisitesAware extension
foreach ($models as $model => $val) {
if($model::has_extension(MultisitesAware::class)) {
throw new \Exception(
'`ModelAdmin::getModelClass()` missing. You are likely using `silverstripe-recipe:4.3.0` which introduced this bug. This can be fixed by updating to `silverstripe-recipe:4.3.1` or greater.'
);
}
}
}
} | [
"public",
"function",
"checkMultisitesAware",
"(",
")",
"{",
"// only true if using silverstripe-recipe <= 4.3.0",
"if",
"(",
"!",
"$",
"this",
"->",
"owner",
"->",
"hasMethod",
"(",
"'getModelClass'",
")",
")",
"{",
"$",
"models",
"=",
"$",
"this",
"->",
"owner... | Prevents use of MultisitesAware extension when using
silvestripe-recipe <= 4.3.0
@return void | [
"Prevents",
"use",
"of",
"MultisitesAware",
"extension",
"when",
"using",
"silvestripe",
"-",
"recipe",
"<",
"=",
"4",
".",
"3",
".",
"0"
] | 9b3fa1d3375ce073c050bd137b68766073efd458 | https://github.com/symbiote/silverstripe-multisites/blob/9b3fa1d3375ce073c050bd137b68766073efd458/src/Admin/MultisitesModelAdminExtension.php#L71-L84 |
46,335 | symbiote/silverstripe-multisites | src/Admin/MultisitesModelAdminExtension.php | MultisitesModelAdminExtension.updateList | public function updateList(&$list){
if($this->modelIsMultiSitesAware()){
$site = $this->getActiveSite();
if ($site) {
$list = $list->filter('SiteID', $site->ID);
}
}
} | php | public function updateList(&$list){
if($this->modelIsMultiSitesAware()){
$site = $this->getActiveSite();
if ($site) {
$list = $list->filter('SiteID', $site->ID);
}
}
} | [
"public",
"function",
"updateList",
"(",
"&",
"$",
"list",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"modelIsMultiSitesAware",
"(",
")",
")",
"{",
"$",
"site",
"=",
"$",
"this",
"->",
"getActiveSite",
"(",
")",
";",
"if",
"(",
"$",
"site",
")",
"{",
... | If this dataClass is MultisitesAware, filter the list by the current Multisites_ActiveSite | [
"If",
"this",
"dataClass",
"is",
"MultisitesAware",
"filter",
"the",
"list",
"by",
"the",
"current",
"Multisites_ActiveSite"
] | 9b3fa1d3375ce073c050bd137b68766073efd458 | https://github.com/symbiote/silverstripe-multisites/blob/9b3fa1d3375ce073c050bd137b68766073efd458/src/Admin/MultisitesModelAdminExtension.php#L89-L96 |
46,336 | symbiote/silverstripe-multisites | src/Admin/MultisitesModelAdminExtension.php | MultisitesModelAdminExtension.updateEditForm | public function updateEditForm($form){
if($this->modelIsMultiSitesAware()) {
$managedSites = Multisites::inst()->sitesManagedByMember();
$source = Site::get()->filter('ID', Multisites::inst()->sitesManagedByMember())->map('ID', 'Title')->toArray();
$plural = singleton($this->owner->modelClass)->plural_name();
if(!count($source)){
$form->setFields(FieldList::create(
LiteralField::create('NotAManager', "You do not have permission to manage $plural on any Sites")
));
}
}
} | php | public function updateEditForm($form){
if($this->modelIsMultiSitesAware()) {
$managedSites = Multisites::inst()->sitesManagedByMember();
$source = Site::get()->filter('ID', Multisites::inst()->sitesManagedByMember())->map('ID', 'Title')->toArray();
$plural = singleton($this->owner->modelClass)->plural_name();
if(!count($source)){
$form->setFields(FieldList::create(
LiteralField::create('NotAManager', "You do not have permission to manage $plural on any Sites")
));
}
}
} | [
"public",
"function",
"updateEditForm",
"(",
"$",
"form",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"modelIsMultiSitesAware",
"(",
")",
")",
"{",
"$",
"managedSites",
"=",
"Multisites",
"::",
"inst",
"(",
")",
"->",
"sitesManagedByMember",
"(",
")",
";",
"... | If the current member is not a "Manager" of any sites, they shouldn't be able to manage MultisitesAware DataObjects. | [
"If",
"the",
"current",
"member",
"is",
"not",
"a",
"Manager",
"of",
"any",
"sites",
"they",
"shouldn",
"t",
"be",
"able",
"to",
"manage",
"MultisitesAware",
"DataObjects",
"."
] | 9b3fa1d3375ce073c050bd137b68766073efd458 | https://github.com/symbiote/silverstripe-multisites/blob/9b3fa1d3375ce073c050bd137b68766073efd458/src/Admin/MultisitesModelAdminExtension.php#L101-L112 |
46,337 | symbiote/silverstripe-multisites | src/Admin/MultisitesModelAdminExtension.php | MultisitesModelAdminExtension.updateSearchForm | public function updateSearchForm($form){
if($this->modelIsMultiSitesAware()) {
$managedSites = Multisites::inst()->sitesManagedByMember();
$source = Site::get()->filter('ID', Multisites::inst()->sitesManagedByMember())->map('ID', 'Title')->toArray();
$plural = singleton($this->owner->modelClass)->plural_name();
if(count($source)){
$activeSite = $this->getActiveSite();
$form->Fields()->push(DropdownField::create(
'SiteID',
"Site: ",
$source,
$activeSite ? $activeSite->ID : null
));
}
}
} | php | public function updateSearchForm($form){
if($this->modelIsMultiSitesAware()) {
$managedSites = Multisites::inst()->sitesManagedByMember();
$source = Site::get()->filter('ID', Multisites::inst()->sitesManagedByMember())->map('ID', 'Title')->toArray();
$plural = singleton($this->owner->modelClass)->plural_name();
if(count($source)){
$activeSite = $this->getActiveSite();
$form->Fields()->push(DropdownField::create(
'SiteID',
"Site: ",
$source,
$activeSite ? $activeSite->ID : null
));
}
}
} | [
"public",
"function",
"updateSearchForm",
"(",
"$",
"form",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"modelIsMultiSitesAware",
"(",
")",
")",
"{",
"$",
"managedSites",
"=",
"Multisites",
"::",
"inst",
"(",
")",
"->",
"sitesManagedByMember",
"(",
")",
";",
... | Provide a Site filter | [
"Provide",
"a",
"Site",
"filter"
] | 9b3fa1d3375ce073c050bd137b68766073efd458 | https://github.com/symbiote/silverstripe-multisites/blob/9b3fa1d3375ce073c050bd137b68766073efd458/src/Admin/MultisitesModelAdminExtension.php#L117-L133 |
46,338 | symbiote/silverstripe-multisites | src/Admin/MultisitesModelAdminExtension.php | MultisitesModelAdminExtension.getActiveSite | public function getActiveSite() {
if($this->owner->config()->use_active_site_session) {
return Multisites::inst()->getActiveSite();
} else {
if($this->modelIsMultiSitesAware()) {
if($active = $this->owner->getRequest()->getSession()->get($this->getActiveSiteSessionKey())) {
return Site::get()->byID($active);
}
}
}
} | php | public function getActiveSite() {
if($this->owner->config()->use_active_site_session) {
return Multisites::inst()->getActiveSite();
} else {
if($this->modelIsMultiSitesAware()) {
if($active = $this->owner->getRequest()->getSession()->get($this->getActiveSiteSessionKey())) {
return Site::get()->byID($active);
}
}
}
} | [
"public",
"function",
"getActiveSite",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"config",
"(",
")",
"->",
"use_active_site_session",
")",
"{",
"return",
"Multisites",
"::",
"inst",
"(",
")",
"->",
"getActiveSite",
"(",
")",
";",
"}",
... | get the active site for this model admin
@return Site | [
"get",
"the",
"active",
"site",
"for",
"this",
"model",
"admin"
] | 9b3fa1d3375ce073c050bd137b68766073efd458 | https://github.com/symbiote/silverstripe-multisites/blob/9b3fa1d3375ce073c050bd137b68766073efd458/src/Admin/MultisitesModelAdminExtension.php#L140-L150 |
46,339 | symbiote/silverstripe-multisites | src/Admin/MultisitesModelAdminExtension.php | MultisitesModelAdminExtension.setActiveSite | public function setActiveSite($siteID) {
if($this->owner->config()->use_active_site_session) {
Multisites::inst()->setActiveSite($siteID);
} else {
$this->owner->getRequest()->getSession()->set($this->getActiveSiteSessionKey(), $siteID);
}
} | php | public function setActiveSite($siteID) {
if($this->owner->config()->use_active_site_session) {
Multisites::inst()->setActiveSite($siteID);
} else {
$this->owner->getRequest()->getSession()->set($this->getActiveSiteSessionKey(), $siteID);
}
} | [
"public",
"function",
"setActiveSite",
"(",
"$",
"siteID",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"config",
"(",
")",
"->",
"use_active_site_session",
")",
"{",
"Multisites",
"::",
"inst",
"(",
")",
"->",
"setActiveSite",
"(",
"$",
"siteI... | Set the active site for this model admin
@param int $siteID
@return void | [
"Set",
"the",
"active",
"site",
"for",
"this",
"model",
"admin"
] | 9b3fa1d3375ce073c050bd137b68766073efd458 | https://github.com/symbiote/silverstripe-multisites/blob/9b3fa1d3375ce073c050bd137b68766073efd458/src/Admin/MultisitesModelAdminExtension.php#L158-L164 |
46,340 | symbiote/silverstripe-multisites | src/Admin/MultisitesModelAdminExtension.php | MultisitesModelAdminExtension.getListDataClass | private function getListDataClass() {
/**
* Silverstripe-recipe 4.3.0 introduces changes that broke the
* previous approach to retrieving the model class.
*
* This is/will be fixed in silverstripe-recipe 4.3.1
*
* We've taken this approach so that Multisites can work with
* SS 4.3.0 so long as you don't use the MultisitesAware extension.
*/
if ($this->listDataClass === null) {
// only true if silverstripe-recipe > 4.3.0
if ($this->owner->hasMethod('getModelClass')) {
$this->listDataClass = $this->owner->getModelClass();
}
// else false to bypass the MultisitesAware extension
else {
$this->listDataClass = false;
}
}
return $this->listDataClass;
} | php | private function getListDataClass() {
/**
* Silverstripe-recipe 4.3.0 introduces changes that broke the
* previous approach to retrieving the model class.
*
* This is/will be fixed in silverstripe-recipe 4.3.1
*
* We've taken this approach so that Multisites can work with
* SS 4.3.0 so long as you don't use the MultisitesAware extension.
*/
if ($this->listDataClass === null) {
// only true if silverstripe-recipe > 4.3.0
if ($this->owner->hasMethod('getModelClass')) {
$this->listDataClass = $this->owner->getModelClass();
}
// else false to bypass the MultisitesAware extension
else {
$this->listDataClass = false;
}
}
return $this->listDataClass;
} | [
"private",
"function",
"getListDataClass",
"(",
")",
"{",
"/**\n * Silverstripe-recipe 4.3.0 introduces changes that broke the\n * previous approach to retrieving the model class.\n *\n * This is/will be fixed in silverstripe-recipe 4.3.1\n *\n * We've tak... | Get and cache an instance of the data class currently being listed
@return DataObject | [
"Get",
"and",
"cache",
"an",
"instance",
"of",
"the",
"data",
"class",
"currently",
"being",
"listed"
] | 9b3fa1d3375ce073c050bd137b68766073efd458 | https://github.com/symbiote/silverstripe-multisites/blob/9b3fa1d3375ce073c050bd137b68766073efd458/src/Admin/MultisitesModelAdminExtension.php#L180-L201 |
46,341 | symbiote/silverstripe-multisites | src/Admin/MultisitesModelAdminExtension.php | MultisitesModelAdminExtension.modelIsMultiSitesAware | private function modelIsMultiSitesAware() {
$model = $this->getListDataClass();
// always false if using silverstripe-recipe <= 4.3.0
if ($model) {
$isAware = $model::has_extension(MultisitesAware::class);
$isSiteTree = in_array(SiteTree::class, ClassInfo::ancestry($model));
return $isAware || $isSiteTree;
}
return false;
} | php | private function modelIsMultiSitesAware() {
$model = $this->getListDataClass();
// always false if using silverstripe-recipe <= 4.3.0
if ($model) {
$isAware = $model::has_extension(MultisitesAware::class);
$isSiteTree = in_array(SiteTree::class, ClassInfo::ancestry($model));
return $isAware || $isSiteTree;
}
return false;
} | [
"private",
"function",
"modelIsMultiSitesAware",
"(",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"getListDataClass",
"(",
")",
";",
"// always false if using silverstripe-recipe <= 4.3.0",
"if",
"(",
"$",
"model",
")",
"{",
"$",
"isAware",
"=",
"$",
"model"... | Determines whether the current model being managed is MultiSitesAware
@return boolean | [
"Determines",
"whether",
"the",
"current",
"model",
"being",
"managed",
"is",
"MultiSitesAware"
] | 9b3fa1d3375ce073c050bd137b68766073efd458 | https://github.com/symbiote/silverstripe-multisites/blob/9b3fa1d3375ce073c050bd137b68766073efd458/src/Admin/MultisitesModelAdminExtension.php#L208-L217 |
46,342 | michelsalib/BCCCronManagerBundle | Controller/DefaultController.php | DefaultController.indexAction | public function indexAction()
{
$cm = new CronManager();
$this->addFlashFromCronManager($cm);
$form = $this->createCronForm(new Cron());
return $this->render('@BCCCronManager/Default/index.html.twig', array(
'crons' => $cm->get(),
'raw' => $cm->getRaw(),
'form' => $form->createView(),
));
} | php | public function indexAction()
{
$cm = new CronManager();
$this->addFlashFromCronManager($cm);
$form = $this->createCronForm(new Cron());
return $this->render('@BCCCronManager/Default/index.html.twig', array(
'crons' => $cm->get(),
'raw' => $cm->getRaw(),
'form' => $form->createView(),
));
} | [
"public",
"function",
"indexAction",
"(",
")",
"{",
"$",
"cm",
"=",
"new",
"CronManager",
"(",
")",
";",
"$",
"this",
"->",
"addFlashFromCronManager",
"(",
"$",
"cm",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createCronForm",
"(",
"new",
"Cron",
... | Displays the current crons and a form to add a new one.
@return Response | [
"Displays",
"the",
"current",
"crons",
"and",
"a",
"form",
"to",
"add",
"a",
"new",
"one",
"."
] | f0c9062f3b2bc79b48b38c7374712f4bc23fb536 | https://github.com/michelsalib/BCCCronManagerBundle/blob/f0c9062f3b2bc79b48b38c7374712f4bc23fb536/Controller/DefaultController.php#L23-L35 |
46,343 | michelsalib/BCCCronManagerBundle | Controller/DefaultController.php | DefaultController.addAction | public function addAction(Request $request)
{
$cm = new CronManager();
$cron = new Cron();
$this->addFlashFromCronManager($cm);
$form = $this->createCronForm($cron);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$cm->add($cron);
$this->addFlashFromCronManager($cm);
return $this->redirect($this->generateUrl('BCCCronManagerBundle_index'));
}
return $this->render('@BCCCronManager:Default:index.html.twig', array(
'crons' => $cm->get(),
'raw' => $cm->getRaw(),
'form' => $form->createView(),
));
} | php | public function addAction(Request $request)
{
$cm = new CronManager();
$cron = new Cron();
$this->addFlashFromCronManager($cm);
$form = $this->createCronForm($cron);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$cm->add($cron);
$this->addFlashFromCronManager($cm);
return $this->redirect($this->generateUrl('BCCCronManagerBundle_index'));
}
return $this->render('@BCCCronManager:Default:index.html.twig', array(
'crons' => $cm->get(),
'raw' => $cm->getRaw(),
'form' => $form->createView(),
));
} | [
"public",
"function",
"addAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"cm",
"=",
"new",
"CronManager",
"(",
")",
";",
"$",
"cron",
"=",
"new",
"Cron",
"(",
")",
";",
"$",
"this",
"->",
"addFlashFromCronManager",
"(",
"$",
"cm",
")",
";",
... | Add a cron to the cron table
@param Request $request
@return Response | [
"Add",
"a",
"cron",
"to",
"the",
"cron",
"table"
] | f0c9062f3b2bc79b48b38c7374712f4bc23fb536 | https://github.com/michelsalib/BCCCronManagerBundle/blob/f0c9062f3b2bc79b48b38c7374712f4bc23fb536/Controller/DefaultController.php#L44-L64 |
46,344 | michelsalib/BCCCronManagerBundle | Controller/DefaultController.php | DefaultController.editAction | public function editAction($id, Request $request)
{
$cm = new CronManager();
$crons = $cm->get();
$this->addFlashFromCronManager($cm);
$form = $this->createCronForm($crons[$id]);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$cm->write();
$this->addFlashFromCronManager($cm);
return $this->redirect($this->generateUrl('BCCCronManagerBundle_index'));
}
return $this->render('@BCCCronManager:Default:edit.html.twig', array(
'form' => $form->createView(),
));
} | php | public function editAction($id, Request $request)
{
$cm = new CronManager();
$crons = $cm->get();
$this->addFlashFromCronManager($cm);
$form = $this->createCronForm($crons[$id]);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$cm->write();
$this->addFlashFromCronManager($cm);
return $this->redirect($this->generateUrl('BCCCronManagerBundle_index'));
}
return $this->render('@BCCCronManager:Default:edit.html.twig', array(
'form' => $form->createView(),
));
} | [
"public",
"function",
"editAction",
"(",
"$",
"id",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"cm",
"=",
"new",
"CronManager",
"(",
")",
";",
"$",
"crons",
"=",
"$",
"cm",
"->",
"get",
"(",
")",
";",
"$",
"this",
"->",
"addFlashFromCronManager",... | Edit a cron
@param $id int The line of the cron in the cron table
@param Request $request
@return RedirectResponse|Response | [
"Edit",
"a",
"cron"
] | f0c9062f3b2bc79b48b38c7374712f4bc23fb536 | https://github.com/michelsalib/BCCCronManagerBundle/blob/f0c9062f3b2bc79b48b38c7374712f4bc23fb536/Controller/DefaultController.php#L74-L93 |
46,345 | michelsalib/BCCCronManagerBundle | Controller/DefaultController.php | DefaultController.wakeupAction | public function wakeupAction($id)
{
$cm = new CronManager();
$crons = $cm->get();
$this->addFlashFromCronManager($cm);
$crons[$id]->setSuspended(false);
$cm->write();
$this->addFlashFromCronManager($cm);
return $this->redirect($this->generateUrl('BCCCronManagerBundle_index'));
} | php | public function wakeupAction($id)
{
$cm = new CronManager();
$crons = $cm->get();
$this->addFlashFromCronManager($cm);
$crons[$id]->setSuspended(false);
$cm->write();
$this->addFlashFromCronManager($cm);
return $this->redirect($this->generateUrl('BCCCronManagerBundle_index'));
} | [
"public",
"function",
"wakeupAction",
"(",
"$",
"id",
")",
"{",
"$",
"cm",
"=",
"new",
"CronManager",
"(",
")",
";",
"$",
"crons",
"=",
"$",
"cm",
"->",
"get",
"(",
")",
";",
"$",
"this",
"->",
"addFlashFromCronManager",
"(",
"$",
"cm",
")",
";",
... | Wake up a cron from the cron table
@param $id int The line of the cron in the cron table
@return RedirectResponse | [
"Wake",
"up",
"a",
"cron",
"from",
"the",
"cron",
"table"
] | f0c9062f3b2bc79b48b38c7374712f4bc23fb536 | https://github.com/michelsalib/BCCCronManagerBundle/blob/f0c9062f3b2bc79b48b38c7374712f4bc23fb536/Controller/DefaultController.php#L101-L111 |
46,346 | michelsalib/BCCCronManagerBundle | Controller/DefaultController.php | DefaultController.suspendAction | public function suspendAction($id)
{
$cm = new CronManager();
$crons = $cm->get();
$this->addFlashFromCronManager($cm);
$crons[$id]->setSuspended(true);
$cm->write();
$this->addFlashFromCronManager($cm);
return $this->redirect($this->generateUrl('BCCCronManagerBundle_index'));
} | php | public function suspendAction($id)
{
$cm = new CronManager();
$crons = $cm->get();
$this->addFlashFromCronManager($cm);
$crons[$id]->setSuspended(true);
$cm->write();
$this->addFlashFromCronManager($cm);
return $this->redirect($this->generateUrl('BCCCronManagerBundle_index'));
} | [
"public",
"function",
"suspendAction",
"(",
"$",
"id",
")",
"{",
"$",
"cm",
"=",
"new",
"CronManager",
"(",
")",
";",
"$",
"crons",
"=",
"$",
"cm",
"->",
"get",
"(",
")",
";",
"$",
"this",
"->",
"addFlashFromCronManager",
"(",
"$",
"cm",
")",
";",
... | Suspend a cron from the cron table
@param $id int The line of the cron in the cron table
@return RedirectResponse | [
"Suspend",
"a",
"cron",
"from",
"the",
"cron",
"table"
] | f0c9062f3b2bc79b48b38c7374712f4bc23fb536 | https://github.com/michelsalib/BCCCronManagerBundle/blob/f0c9062f3b2bc79b48b38c7374712f4bc23fb536/Controller/DefaultController.php#L119-L129 |
46,347 | michelsalib/BCCCronManagerBundle | Controller/DefaultController.php | DefaultController.fileAction | public function fileAction($id, $type)
{
$cm = new CronManager();
$crons = $cm->get();
$cron = $crons[$id];
$data = array();
$data['file'] = ($type == 'log') ? $cron->getLogFile(): $cron->getErrorFile();
$data['content'] = \file_get_contents($data['file']);
$serializer = new Serializer(array(), array('json' => new JsonEncoder()));
return new Response($serializer->serialize($data, 'json'));
} | php | public function fileAction($id, $type)
{
$cm = new CronManager();
$crons = $cm->get();
$cron = $crons[$id];
$data = array();
$data['file'] = ($type == 'log') ? $cron->getLogFile(): $cron->getErrorFile();
$data['content'] = \file_get_contents($data['file']);
$serializer = new Serializer(array(), array('json' => new JsonEncoder()));
return new Response($serializer->serialize($data, 'json'));
} | [
"public",
"function",
"fileAction",
"(",
"$",
"id",
",",
"$",
"type",
")",
"{",
"$",
"cm",
"=",
"new",
"CronManager",
"(",
")",
";",
"$",
"crons",
"=",
"$",
"cm",
"->",
"get",
"(",
")",
";",
"$",
"cron",
"=",
"$",
"crons",
"[",
"$",
"id",
"]"... | Gets a log file
@param $id int The line of the cron in the cron table
@param $type sting The type of file, log or error
@return \Symfony\Component\HttpFoundation\Response | [
"Gets",
"a",
"log",
"file"
] | f0c9062f3b2bc79b48b38c7374712f4bc23fb536 | https://github.com/michelsalib/BCCCronManagerBundle/blob/f0c9062f3b2bc79b48b38c7374712f4bc23fb536/Controller/DefaultController.php#L156-L169 |
46,348 | michelsalib/BCCCronManagerBundle | Controller/DefaultController.php | DefaultController.addFlashFromCronManager | protected function addFlashFromCronManager(CronManager $cm)
{
if ($cm->getOutput()) {
$this->addFlash('message', $cm->getOutput());
}
if ($cm->getError()) {
$this->addFlash('error', $cm->getError());
}
} | php | protected function addFlashFromCronManager(CronManager $cm)
{
if ($cm->getOutput()) {
$this->addFlash('message', $cm->getOutput());
}
if ($cm->getError()) {
$this->addFlash('error', $cm->getError());
}
} | [
"protected",
"function",
"addFlashFromCronManager",
"(",
"CronManager",
"$",
"cm",
")",
"{",
"if",
"(",
"$",
"cm",
"->",
"getOutput",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addFlash",
"(",
"'message'",
",",
"$",
"cm",
"->",
"getOutput",
"(",
")",
")",... | Set flash from CronManager
@param CronManager $cm | [
"Set",
"flash",
"from",
"CronManager"
] | f0c9062f3b2bc79b48b38c7374712f4bc23fb536 | https://github.com/michelsalib/BCCCronManagerBundle/blob/f0c9062f3b2bc79b48b38c7374712f4bc23fb536/Controller/DefaultController.php#L187-L196 |
46,349 | michelsalib/BCCCronManagerBundle | Manager/Cron.php | Cron.getExpression | public function getExpression()
{
return \sprintf('%s %s %s %s %s', $this->minute, $this->hour, $this->dayOfMonth, $this->month, $this->dayOfWeek);
} | php | public function getExpression()
{
return \sprintf('%s %s %s %s %s', $this->minute, $this->hour, $this->dayOfMonth, $this->month, $this->dayOfWeek);
} | [
"public",
"function",
"getExpression",
"(",
")",
"{",
"return",
"\\",
"sprintf",
"(",
"'%s %s %s %s %s'",
",",
"$",
"this",
"->",
"minute",
",",
"$",
"this",
"->",
"hour",
",",
"$",
"this",
"->",
"dayOfMonth",
",",
"$",
"this",
"->",
"month",
",",
"$",... | Concats time data to get the time expression
@return string | [
"Concats",
"time",
"data",
"to",
"get",
"the",
"time",
"expression"
] | f0c9062f3b2bc79b48b38c7374712f4bc23fb536 | https://github.com/michelsalib/BCCCronManagerBundle/blob/f0c9062f3b2bc79b48b38c7374712f4bc23fb536/Manager/Cron.php#L399-L402 |
46,350 | michelsalib/BCCCronManagerBundle | Manager/Cron.php | Cron.setSuspended | public function setSuspended($isSuspended = true)
{
if ($this->isSuspended != $isSuspended) {
$this->isSuspended = $isSuspended;
}
return $this;
} | php | public function setSuspended($isSuspended = true)
{
if ($this->isSuspended != $isSuspended) {
$this->isSuspended = $isSuspended;
}
return $this;
} | [
"public",
"function",
"setSuspended",
"(",
"$",
"isSuspended",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isSuspended",
"!=",
"$",
"isSuspended",
")",
"{",
"$",
"this",
"->",
"isSuspended",
"=",
"$",
"isSuspended",
";",
"}",
"return",
"$",
"... | Sets the value of isSuspended
@param boolean $isSuspended status
@return Cron | [
"Sets",
"the",
"value",
"of",
"isSuspended"
] | f0c9062f3b2bc79b48b38c7374712f4bc23fb536 | https://github.com/michelsalib/BCCCronManagerBundle/blob/f0c9062f3b2bc79b48b38c7374712f4bc23fb536/Manager/Cron.php#L421-L427 |
46,351 | symbiote/silverstripe-multisites | src/Job/MultisitesInitAssetsTask.php | MultisitesInitAssetsTask.run | public function run($request)
{
$currentSite = Multisites::inst()->getCurrentSite();
$folderName = $currentSite->Host ? $currentSite->Host : "site-$currentSite->ID";
$folder = Folder::find_or_make($folderName);
$files = File::get()->filter('ParentID', array(0))->exclude('ID', $folder->ID);
if (!$files->count()) {
return;
}
foreach ($files as $file) {
if (file_exists($file->getFullPath())) {
$file->ParentID = $folder->ID;
$file->write();
echo $file->Filename.' moved <br />';
}
}
} | php | public function run($request)
{
$currentSite = Multisites::inst()->getCurrentSite();
$folderName = $currentSite->Host ? $currentSite->Host : "site-$currentSite->ID";
$folder = Folder::find_or_make($folderName);
$files = File::get()->filter('ParentID', array(0))->exclude('ID', $folder->ID);
if (!$files->count()) {
return;
}
foreach ($files as $file) {
if (file_exists($file->getFullPath())) {
$file->ParentID = $folder->ID;
$file->write();
echo $file->Filename.' moved <br />';
}
}
} | [
"public",
"function",
"run",
"(",
"$",
"request",
")",
"{",
"$",
"currentSite",
"=",
"Multisites",
"::",
"inst",
"(",
")",
"->",
"getCurrentSite",
"(",
")",
";",
"$",
"folderName",
"=",
"$",
"currentSite",
"->",
"Host",
"?",
"$",
"currentSite",
"->",
"... | Implement this method in the task subclass to
execute via the TaskRunner | [
"Implement",
"this",
"method",
"in",
"the",
"task",
"subclass",
"to",
"execute",
"via",
"the",
"TaskRunner"
] | 9b3fa1d3375ce073c050bd137b68766073efd458 | https://github.com/symbiote/silverstripe-multisites/blob/9b3fa1d3375ce073c050bd137b68766073efd458/src/Job/MultisitesInitAssetsTask.php#L25-L44 |
46,352 | symbiote/silverstripe-multisites | src/Admin/MultisitesCmsMainExtension.php | MultisitesCMSMainExtension.doAddSite | public function doAddSite() {
$site = $this->owner->getNewItem('new-' . Site::class .'-0', false);
$site->write();
return $this->owner->redirect(
singleton(CMSPageEditController::class)->Link("show/$site->ID")
);
} | php | public function doAddSite() {
$site = $this->owner->getNewItem('new-' . Site::class .'-0', false);
$site->write();
return $this->owner->redirect(
singleton(CMSPageEditController::class)->Link("show/$site->ID")
);
} | [
"public",
"function",
"doAddSite",
"(",
")",
"{",
"$",
"site",
"=",
"$",
"this",
"->",
"owner",
"->",
"getNewItem",
"(",
"'new-'",
".",
"Site",
"::",
"class",
".",
"'-0'",
",",
"false",
")",
";",
"$",
"site",
"->",
"write",
"(",
")",
";",
"return",... | AddSiteForm action to add a new site | [
"AddSiteForm",
"action",
"to",
"add",
"a",
"new",
"site"
] | 9b3fa1d3375ce073c050bd137b68766073efd458 | https://github.com/symbiote/silverstripe-multisites/blob/9b3fa1d3375ce073c050bd137b68766073efd458/src/Admin/MultisitesCmsMainExtension.php#L91-L98 |
46,353 | symbiote/silverstripe-multisites | src/Admin/MultisitesCmsMainExtension.php | MultisitesCMSMainExtension.updateEditForm | public function updateEditForm($form) {
$classNameField = $form->Fields()->dataFieldByName('ClassName');
if ($classNameField) {
$className = $classNameField->Value();
if ($className === 'Site')
{
$form->Fields()->removeByName(array(SilverStripeNavigator::class));
$form->removeExtraClass('cms-previewable');
}
}
} | php | public function updateEditForm($form) {
$classNameField = $form->Fields()->dataFieldByName('ClassName');
if ($classNameField) {
$className = $classNameField->Value();
if ($className === 'Site')
{
$form->Fields()->removeByName(array(SilverStripeNavigator::class));
$form->removeExtraClass('cms-previewable');
}
}
} | [
"public",
"function",
"updateEditForm",
"(",
"$",
"form",
")",
"{",
"$",
"classNameField",
"=",
"$",
"form",
"->",
"Fields",
"(",
")",
"->",
"dataFieldByName",
"(",
"'ClassName'",
")",
";",
"if",
"(",
"$",
"classNameField",
")",
"{",
"$",
"className",
"=... | If viewing 'Site', disable preview panel. | [
"If",
"viewing",
"Site",
"disable",
"preview",
"panel",
"."
] | 9b3fa1d3375ce073c050bd137b68766073efd458 | https://github.com/symbiote/silverstripe-multisites/blob/9b3fa1d3375ce073c050bd137b68766073efd458/src/Admin/MultisitesCmsMainExtension.php#L103-L113 |
46,354 | symbiote/silverstripe-multisites | src/Admin/MultisitesCmsMainExtension.php | MultisitesCMSMainExtension.updateSearchForm | public function updateSearchForm(Form $form) {
$cms = $this->owner;
$req = $cms->getRequest();
$sites = Site::get()->sort(array(
'IsDefault' => 'DESC',
'Title' => 'ASC'
));
$site = new DropdownField(
'q[SiteID]',
_t('Multisites.SITE', 'Site'),
$sites->map(),
isset($req['q']['SiteID']) ? $req['q']['SiteID'] : null
);
$site->setEmptyString(_t('Multisites.ALLSITES', 'All sites'));
$form->Fields()->insertAfter($site, 'q[Term]');
} | php | public function updateSearchForm(Form $form) {
$cms = $this->owner;
$req = $cms->getRequest();
$sites = Site::get()->sort(array(
'IsDefault' => 'DESC',
'Title' => 'ASC'
));
$site = new DropdownField(
'q[SiteID]',
_t('Multisites.SITE', 'Site'),
$sites->map(),
isset($req['q']['SiteID']) ? $req['q']['SiteID'] : null
);
$site->setEmptyString(_t('Multisites.ALLSITES', 'All sites'));
$form->Fields()->insertAfter($site, 'q[Term]');
} | [
"public",
"function",
"updateSearchForm",
"(",
"Form",
"$",
"form",
")",
"{",
"$",
"cms",
"=",
"$",
"this",
"->",
"owner",
";",
"$",
"req",
"=",
"$",
"cms",
"->",
"getRequest",
"(",
")",
";",
"$",
"sites",
"=",
"Site",
"::",
"get",
"(",
")",
"->"... | Adds a dropdown field to the search form to filter searches by Site | [
"Adds",
"a",
"dropdown",
"field",
"to",
"the",
"search",
"form",
"to",
"filter",
"searches",
"by",
"Site"
] | 9b3fa1d3375ce073c050bd137b68766073efd458 | https://github.com/symbiote/silverstripe-multisites/blob/9b3fa1d3375ce073c050bd137b68766073efd458/src/Admin/MultisitesCmsMainExtension.php#L118-L136 |
46,355 | symbiote/silverstripe-multisites | src/Admin/MultisitesCmsMainExtension.php | MultisitesCMSMainExtension.updateCurrentPageID | public function updateCurrentPageID(&$id){
if (!$id) {
if($site = Multisites::inst()->getCurrentSite()){
$id = $site->Children()->first();
}
}
} | php | public function updateCurrentPageID(&$id){
if (!$id) {
if($site = Multisites::inst()->getCurrentSite()){
$id = $site->Children()->first();
}
}
} | [
"public",
"function",
"updateCurrentPageID",
"(",
"&",
"$",
"id",
")",
"{",
"if",
"(",
"!",
"$",
"id",
")",
"{",
"if",
"(",
"$",
"site",
"=",
"Multisites",
"::",
"inst",
"(",
")",
"->",
"getCurrentSite",
"(",
")",
")",
"{",
"$",
"id",
"=",
"$",
... | Makes the default page id the first child of the current site
This makes the site tree view load with the current site open instead of just the first one | [
"Makes",
"the",
"default",
"page",
"id",
"the",
"first",
"child",
"of",
"the",
"current",
"site",
"This",
"makes",
"the",
"site",
"tree",
"view",
"load",
"with",
"the",
"current",
"site",
"open",
"instead",
"of",
"just",
"the",
"first",
"one"
] | 9b3fa1d3375ce073c050bd137b68766073efd458 | https://github.com/symbiote/silverstripe-multisites/blob/9b3fa1d3375ce073c050bd137b68766073efd458/src/Admin/MultisitesCmsMainExtension.php#L143-L149 |
46,356 | symbiote/silverstripe-multisites | src/Extension/MultisitesControllerExtension.php | MultisitesControllerExtension.onBeforeHTTPError | public function onBeforeHTTPError($code, $request)
{
$errorPage = ErrorPage::get()->filter(array(
'ErrorCode' => $code,
'SiteID' => Multisites::inst()->getCurrentSiteId()
))->first();
if ($errorPage) {
Requirements::clear();
Requirements::clear_combined_files();
$response = ModelAsController::controller_for($errorPage)->handleRequest($request);
throw new HTTPResponse_Exception($response, $code);
}
} | php | public function onBeforeHTTPError($code, $request)
{
$errorPage = ErrorPage::get()->filter(array(
'ErrorCode' => $code,
'SiteID' => Multisites::inst()->getCurrentSiteId()
))->first();
if ($errorPage) {
Requirements::clear();
Requirements::clear_combined_files();
$response = ModelAsController::controller_for($errorPage)->handleRequest($request);
throw new HTTPResponse_Exception($response, $code);
}
} | [
"public",
"function",
"onBeforeHTTPError",
"(",
"$",
"code",
",",
"$",
"request",
")",
"{",
"$",
"errorPage",
"=",
"ErrorPage",
"::",
"get",
"(",
")",
"->",
"filter",
"(",
"array",
"(",
"'ErrorCode'",
"=>",
"$",
"code",
",",
"'SiteID'",
"=>",
"Multisites... | Retrieve the correct error page for the current multisite instance.
@param integer
@param SS_HTTPRequest
@throws SS_HTTPResponse_Exception | [
"Retrieve",
"the",
"correct",
"error",
"page",
"for",
"the",
"current",
"multisite",
"instance",
"."
] | 9b3fa1d3375ce073c050bd137b68766073efd458 | https://github.com/symbiote/silverstripe-multisites/blob/9b3fa1d3375ce073c050bd137b68766073efd458/src/Extension/MultisitesControllerExtension.php#L74-L87 |
46,357 | symbiote/silverstripe-multisites | src/Extension/MultisitesAware.php | MultisitesAware.canEdit | public function canEdit($member = null)
{
$managedSites = Multisites::inst()->sitesManagedByMember();
if (count($managedSites) && in_array($this->owner->SiteID, $managedSites)) {
// member has permission to manage MultisitesAware objects on this site,
// hand over to the object's canEdit method
return null;
} else {
// member does not have permission to edit objects on this object's Site
return false;
}
} | php | public function canEdit($member = null)
{
$managedSites = Multisites::inst()->sitesManagedByMember();
if (count($managedSites) && in_array($this->owner->SiteID, $managedSites)) {
// member has permission to manage MultisitesAware objects on this site,
// hand over to the object's canEdit method
return null;
} else {
// member does not have permission to edit objects on this object's Site
return false;
}
} | [
"public",
"function",
"canEdit",
"(",
"$",
"member",
"=",
"null",
")",
"{",
"$",
"managedSites",
"=",
"Multisites",
"::",
"inst",
"(",
")",
"->",
"sitesManagedByMember",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"managedSites",
")",
"&&",
"in_array",
... | Check to see if the current user has permission to edit this MultisitesAware object
On the site this object is associated with.
@return boolean|null | [
"Check",
"to",
"see",
"if",
"the",
"current",
"user",
"has",
"permission",
"to",
"edit",
"this",
"MultisitesAware",
"object",
"On",
"the",
"site",
"this",
"object",
"is",
"associated",
"with",
"."
] | 9b3fa1d3375ce073c050bd137b68766073efd458 | https://github.com/symbiote/silverstripe-multisites/blob/9b3fa1d3375ce073c050bd137b68766073efd458/src/Extension/MultisitesAware.php#L38-L49 |
46,358 | symbiote/silverstripe-multisites | src/Job/TidySiteTask.php | TidySiteTask.recursiveTidy | public function recursiveTidy($children)
{
foreach ($children as $page) {
$write = false;
// This is so something (events for example) can be purged.
if ($this->purge && is_a($page, $this->purge, true)) {
$page->delete();
$this->purged++;
continue;
}
// The most common issue is that the site ID doesn't match.
if ($page->SiteID != $this->siteID) {
// Update it to match.
$page->SiteID = $this->siteID;
$write = true;
}
// The next issue is that duplicated URL segments have numbers appended (`URL-segment-2` for example).
if (preg_match('%-[0-9]$%', $page->URLSegment)) {
// When a page title ends with a number, the URL should match this.
$last = substr($page->Title, -1);
if (is_numeric($last)) {
// Determine whether this actually needs fixing.
if ($last !== substr($page->URLSegment, -1)) {
// Update it to match.
$page->URLSegment = $page->Title;
$write = true;
}
}
// The number appended shouldn't exist.
else {
// Determine whether this is considered unique (otherwise it can't be updated).
$to = substr($page->URLSegment, 0, -2);
if (!SiteTree::get()->filter(array(
'ParentID' => $page->ParentID,
'URLSegment' => $to
))->exists()) {
// This isn't unique, so update it.
$page->URLSegment = $to;
$write = true;
}
}
}
// Determine whether this page needs a write.
if ($write) {
$page->write();
$this->count++;
}
// Where necessary, continue further down.
$this->recursiveTidy($page->AllChildren());
}
} | php | public function recursiveTidy($children)
{
foreach ($children as $page) {
$write = false;
// This is so something (events for example) can be purged.
if ($this->purge && is_a($page, $this->purge, true)) {
$page->delete();
$this->purged++;
continue;
}
// The most common issue is that the site ID doesn't match.
if ($page->SiteID != $this->siteID) {
// Update it to match.
$page->SiteID = $this->siteID;
$write = true;
}
// The next issue is that duplicated URL segments have numbers appended (`URL-segment-2` for example).
if (preg_match('%-[0-9]$%', $page->URLSegment)) {
// When a page title ends with a number, the URL should match this.
$last = substr($page->Title, -1);
if (is_numeric($last)) {
// Determine whether this actually needs fixing.
if ($last !== substr($page->URLSegment, -1)) {
// Update it to match.
$page->URLSegment = $page->Title;
$write = true;
}
}
// The number appended shouldn't exist.
else {
// Determine whether this is considered unique (otherwise it can't be updated).
$to = substr($page->URLSegment, 0, -2);
if (!SiteTree::get()->filter(array(
'ParentID' => $page->ParentID,
'URLSegment' => $to
))->exists()) {
// This isn't unique, so update it.
$page->URLSegment = $to;
$write = true;
}
}
}
// Determine whether this page needs a write.
if ($write) {
$page->write();
$this->count++;
}
// Where necessary, continue further down.
$this->recursiveTidy($page->AllChildren());
}
} | [
"public",
"function",
"recursiveTidy",
"(",
"$",
"children",
")",
"{",
"foreach",
"(",
"$",
"children",
"as",
"$",
"page",
")",
"{",
"$",
"write",
"=",
"false",
";",
"// This is so something (events for example) can be purged.",
"if",
"(",
"$",
"this",
"->",
"... | This recursively goes through children to ensure everything is tidy. | [
"This",
"recursively",
"goes",
"through",
"children",
"to",
"ensure",
"everything",
"is",
"tidy",
"."
] | 9b3fa1d3375ce073c050bd137b68766073efd458 | https://github.com/symbiote/silverstripe-multisites/blob/9b3fa1d3375ce073c050bd137b68766073efd458/src/Job/TidySiteTask.php#L65-L139 |
46,359 | symbiote/silverstripe-multisites | src/Extension/MultisitesSiteTreeExtension.php | MultisitesSiteTreeExtension.contentcontrollerInit | public function contentcontrollerInit($controller)
{
// If we've accessed the homepage as /home/, then we should redirect to /.
if ($controller->dataRecord && $controller->dataRecord instanceof SiteTree && MultisitesRootController::should_be_on_root($controller->dataRecord)
&& (!isset($controller->urlParams['Action']) || !$controller->urlParams['Action'] ) && !$_POST && !$_FILES && !$controller->redirectedTo()) {
$getVars = $_GET;
unset($getVars['url']);
if ($getVars) $url = "?".http_build_query($getVars);
else $url = "";
$controller->redirect($url, 301);
return;
}
} | php | public function contentcontrollerInit($controller)
{
// If we've accessed the homepage as /home/, then we should redirect to /.
if ($controller->dataRecord && $controller->dataRecord instanceof SiteTree && MultisitesRootController::should_be_on_root($controller->dataRecord)
&& (!isset($controller->urlParams['Action']) || !$controller->urlParams['Action'] ) && !$_POST && !$_FILES && !$controller->redirectedTo()) {
$getVars = $_GET;
unset($getVars['url']);
if ($getVars) $url = "?".http_build_query($getVars);
else $url = "";
$controller->redirect($url, 301);
return;
}
} | [
"public",
"function",
"contentcontrollerInit",
"(",
"$",
"controller",
")",
"{",
"// If we've accessed the homepage as /home/, then we should redirect to /.",
"if",
"(",
"$",
"controller",
"->",
"dataRecord",
"&&",
"$",
"controller",
"->",
"dataRecord",
"instanceof",
"SiteT... | Make sure site home pages are loaded at the root of the site. | [
"Make",
"sure",
"site",
"home",
"pages",
"are",
"loaded",
"at",
"the",
"root",
"of",
"the",
"site",
"."
] | 9b3fa1d3375ce073c050bd137b68766073efd458 | https://github.com/symbiote/silverstripe-multisites/blob/9b3fa1d3375ce073c050bd137b68766073efd458/src/Extension/MultisitesSiteTreeExtension.php#L60-L73 |
46,360 | symbiote/silverstripe-multisites | src/Extension/MultisitesSiteTreeExtension.php | MultisitesSiteTreeExtension.onBeforeWrite | public function onBeforeWrite()
{
if ($this->owner instanceof Site) {
if (!$this->owner->ID) {
// Initialise a new Site to the top level
$this->owner->SiteID = 0;
$this->owner->ParentID = 0;
}
return;
}
// Set the SiteID (and ParentID if required) for all new pages.
if (!$this->owner->ID) {
$parent = $this->owner->Parent();
if ($parent && $parent->exists()) {
// Page is beneath a Site
if ($parent instanceof Site) {
$this->owner->SiteID = $parent->ID;
} else {
$this->owner->SiteID = $parent->SiteID;
}
} else {
// Create the page beneath the current Site
$this->owner->SiteID = Multisites::inst()->getDefaultSiteId();
$this->owner->ParentID = $this->owner->SiteID;
}
}
// Make sure SiteID is changed when site tree is reorganised.
if ($this->owner->ID && $this->owner->isChanged('ParentID')) {
// Get the new parent
$parent = DataObject::get_by_id(SiteTree::class, $this->owner->ParentID);
// Make sure the parent exists
if ($parent) {
// Recursively change SiteID for this and all child pages
$siteId = ($parent instanceof Site) ? $parent->ID : $parent->SiteID;
$this->owner->updateSiteID($siteId);
}
}
} | php | public function onBeforeWrite()
{
if ($this->owner instanceof Site) {
if (!$this->owner->ID) {
// Initialise a new Site to the top level
$this->owner->SiteID = 0;
$this->owner->ParentID = 0;
}
return;
}
// Set the SiteID (and ParentID if required) for all new pages.
if (!$this->owner->ID) {
$parent = $this->owner->Parent();
if ($parent && $parent->exists()) {
// Page is beneath a Site
if ($parent instanceof Site) {
$this->owner->SiteID = $parent->ID;
} else {
$this->owner->SiteID = $parent->SiteID;
}
} else {
// Create the page beneath the current Site
$this->owner->SiteID = Multisites::inst()->getDefaultSiteId();
$this->owner->ParentID = $this->owner->SiteID;
}
}
// Make sure SiteID is changed when site tree is reorganised.
if ($this->owner->ID && $this->owner->isChanged('ParentID')) {
// Get the new parent
$parent = DataObject::get_by_id(SiteTree::class, $this->owner->ParentID);
// Make sure the parent exists
if ($parent) {
// Recursively change SiteID for this and all child pages
$siteId = ($parent instanceof Site) ? $parent->ID : $parent->SiteID;
$this->owner->updateSiteID($siteId);
}
}
} | [
"public",
"function",
"onBeforeWrite",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"owner",
"instanceof",
"Site",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"owner",
"->",
"ID",
")",
"{",
"// Initialise a new Site to the top level",
"$",
"this",
"->",
... | Keep the SiteID field consistent. | [
"Keep",
"the",
"SiteID",
"field",
"consistent",
"."
] | 9b3fa1d3375ce073c050bd137b68766073efd458 | https://github.com/symbiote/silverstripe-multisites/blob/9b3fa1d3375ce073c050bd137b68766073efd458/src/Extension/MultisitesSiteTreeExtension.php#L78-L118 |
46,361 | hryvinskyi/magento2-base | Helper/ConsoleHelper.php | ConsoleHelper.getScreenSize | public static function getScreenSize( $refresh = false ) {
static $size;
if ( $size !== null && ! $refresh ) {
return $size;
}
if ( static::isRunningOnWindows() ) {
$output = [];
exec( 'mode con', $output );
if ( isset( $output, $output[1] ) && strpos( $output[1], 'CON' ) !== false ) {
return $size = [
(int) preg_replace( '~\D~', '', $output[4] ),
(int) preg_replace( '~\D~', '', $output[3] )
];
}
} else {
// try stty if available
$stty = [];
if ( exec( 'stty -a 2>&1', $stty ) ) {
$stty = implode( ' ', $stty );
// Linux stty output
if ( preg_match( '/rows\s+(\d+);\s*columns\s+(\d+);/mi', $stty, $matches ) ) {
return $size = [ (int) $matches[2], (int) $matches[1] ];
}
// MacOS stty output
if ( preg_match( '/(\d+)\s+rows;\s*(\d+)\s+columns;/mi', $stty, $matches ) ) {
return $size = [ (int) $matches[2], (int) $matches[1] ];
}
}
// fallback to tput, which may not be updated on terminal resize
if ( ( $width = (int) exec( 'tput cols 2>&1' ) ) > 0 && ( $height = (int) exec( 'tput lines 2>&1' ) ) > 0 ) {
return $size = [ $width, $height ];
}
// fallback to ENV variables, which may not be updated on terminal resize
if ( ( $width = (int) getenv( 'COLUMNS' ) ) > 0 && ( $height = (int) getenv( 'LINES' ) ) > 0 ) {
return $size = [ $width, $height ];
}
}
return $size = false;
} | php | public static function getScreenSize( $refresh = false ) {
static $size;
if ( $size !== null && ! $refresh ) {
return $size;
}
if ( static::isRunningOnWindows() ) {
$output = [];
exec( 'mode con', $output );
if ( isset( $output, $output[1] ) && strpos( $output[1], 'CON' ) !== false ) {
return $size = [
(int) preg_replace( '~\D~', '', $output[4] ),
(int) preg_replace( '~\D~', '', $output[3] )
];
}
} else {
// try stty if available
$stty = [];
if ( exec( 'stty -a 2>&1', $stty ) ) {
$stty = implode( ' ', $stty );
// Linux stty output
if ( preg_match( '/rows\s+(\d+);\s*columns\s+(\d+);/mi', $stty, $matches ) ) {
return $size = [ (int) $matches[2], (int) $matches[1] ];
}
// MacOS stty output
if ( preg_match( '/(\d+)\s+rows;\s*(\d+)\s+columns;/mi', $stty, $matches ) ) {
return $size = [ (int) $matches[2], (int) $matches[1] ];
}
}
// fallback to tput, which may not be updated on terminal resize
if ( ( $width = (int) exec( 'tput cols 2>&1' ) ) > 0 && ( $height = (int) exec( 'tput lines 2>&1' ) ) > 0 ) {
return $size = [ $width, $height ];
}
// fallback to ENV variables, which may not be updated on terminal resize
if ( ( $width = (int) getenv( 'COLUMNS' ) ) > 0 && ( $height = (int) getenv( 'LINES' ) ) > 0 ) {
return $size = [ $width, $height ];
}
}
return $size = false;
} | [
"public",
"static",
"function",
"getScreenSize",
"(",
"$",
"refresh",
"=",
"false",
")",
"{",
"static",
"$",
"size",
";",
"if",
"(",
"$",
"size",
"!==",
"null",
"&&",
"!",
"$",
"refresh",
")",
"{",
"return",
"$",
"size",
";",
"}",
"if",
"(",
"stati... | Returns terminal screen size.
Usage:
```php
list($width, $height) = ConsoleHelper::getScreenSize();
```
@param bool $refresh whether to force checking and not re-use cached size value.
This is useful to detect changing window size while the application is running but may
not get up to date values on every terminal.
@return array|bool An array of ($width, $height) or false when it was not able to determine size. | [
"Returns",
"terminal",
"screen",
"size",
"."
] | 7648c4d0c82a281c82aa1cf30d1808674ca40604 | https://github.com/hryvinskyi/magento2-base/blob/7648c4d0c82a281c82aa1cf30d1808674ca40604/Helper/ConsoleHelper.php#L583-L622 |
46,362 | hryvinskyi/magento2-base | Helper/ConsoleHelper.php | ConsoleHelper.prompt | public static function prompt( $text, $options = [] ) {
$options = ArrayHelper::merge(
[
'required' => false,
'default' => null,
'pattern' => null,
'validator' => null,
'error' => 'Invalid input.',
],
$options
);
$error = null;
top:
$input = $options['default']
? static::input( "$text [" . $options['default'] . '] ' )
: static::input( "$text " );
if ( $input === '' ) {
if ( isset( $options['default'] ) ) {
$input = $options['default'];
} else if ( $options['required'] ) {
static::output( $options['error'] );
goto top;
}
} else if ( $options['pattern'] && ! preg_match( $options['pattern'], $input ) ) {
static::output( $options['error'] );
goto top;
} else if ( $options['validator'] &&
! call_user_func_array( $options['validator'], [ $input, &$error ] )
) {
static::output( isset( $error ) ? $error : $options['error'] );
goto top;
}
return $input;
} | php | public static function prompt( $text, $options = [] ) {
$options = ArrayHelper::merge(
[
'required' => false,
'default' => null,
'pattern' => null,
'validator' => null,
'error' => 'Invalid input.',
],
$options
);
$error = null;
top:
$input = $options['default']
? static::input( "$text [" . $options['default'] . '] ' )
: static::input( "$text " );
if ( $input === '' ) {
if ( isset( $options['default'] ) ) {
$input = $options['default'];
} else if ( $options['required'] ) {
static::output( $options['error'] );
goto top;
}
} else if ( $options['pattern'] && ! preg_match( $options['pattern'], $input ) ) {
static::output( $options['error'] );
goto top;
} else if ( $options['validator'] &&
! call_user_func_array( $options['validator'], [ $input, &$error ] )
) {
static::output( isset( $error ) ? $error : $options['error'] );
goto top;
}
return $input;
} | [
"public",
"static",
"function",
"prompt",
"(",
"$",
"text",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"ArrayHelper",
"::",
"merge",
"(",
"[",
"'required'",
"=>",
"false",
",",
"'default'",
"=>",
"null",
",",
"'pattern'",
"=>",
... | Prompts the user for input and validates it.
@param string $text prompt string
@param array $options the options to validate the input:
- `required`: whether it is required or not
- `default`: default value if no input is inserted by the user
- `pattern`: regular expression pattern to validate user input
- `validator`: a callable function to validate input. The function must accept two parameters:
- `input`: the user input to validate
- `error`: the error value passed by reference if validation failed.
@return string the user input | [
"Prompts",
"the",
"user",
"for",
"input",
"and",
"validates",
"it",
"."
] | 7648c4d0c82a281c82aa1cf30d1808674ca40604 | https://github.com/hryvinskyi/magento2-base/blob/7648c4d0c82a281c82aa1cf30d1808674ca40604/Helper/ConsoleHelper.php#L752-L786 |
46,363 | hryvinskyi/magento2-base | Helper/ConsoleHelper.php | ConsoleHelper.getProgressbarWidth | private static function getProgressbarWidth( $prefix ) {
$width = self::$_progressWidth;
if ( $width === false ) {
return 0;
}
$screenSize = static::getScreenSize( true );
if ( $screenSize === false && $width < 1 ) {
return 0;
}
if ( $width === null ) {
$width = $screenSize[0];
} else if ( $width > 0 && $width < 1 ) {
$width = floor( $screenSize[0] * $width );
}
$width -= static::ansiStrlen( $prefix );
return $width;
} | php | private static function getProgressbarWidth( $prefix ) {
$width = self::$_progressWidth;
if ( $width === false ) {
return 0;
}
$screenSize = static::getScreenSize( true );
if ( $screenSize === false && $width < 1 ) {
return 0;
}
if ( $width === null ) {
$width = $screenSize[0];
} else if ( $width > 0 && $width < 1 ) {
$width = floor( $screenSize[0] * $width );
}
$width -= static::ansiStrlen( $prefix );
return $width;
} | [
"private",
"static",
"function",
"getProgressbarWidth",
"(",
"$",
"prefix",
")",
"{",
"$",
"width",
"=",
"self",
"::",
"$",
"_progressWidth",
";",
"if",
"(",
"$",
"width",
"===",
"false",
")",
"{",
"return",
"0",
";",
"}",
"$",
"screenSize",
"=",
"stat... | Return width of the progressbar
@param string $prefix an optional string to display before the progress bar.
@see updateProgress
@return int screen width
@since 2.0.14 | [
"Return",
"width",
"of",
"the",
"progressbar"
] | 7648c4d0c82a281c82aa1cf30d1808674ca40604 | https://github.com/hryvinskyi/magento2-base/blob/7648c4d0c82a281c82aa1cf30d1808674ca40604/Helper/ConsoleHelper.php#L963-L980 |
46,364 | symbiote/silverstripe-multisites | src/Control/MultisitesFrontController.php | MultisitesFrontController.getNestedController | public function getNestedController() {
$request = $this->request;
$segment = $request->param('URLSegment');
$site = Multisites::inst()->getCurrentSiteId();
if(!$site) {
return $this->httpError(404);
}
$page = SiteTree::get()->filter(array(
'ParentID' => $site,
'URLSegment' => rawurlencode($segment)
));
$page = $page->first();
if(!$page) {
// Check to see if linkmapping module is installed and if so, if there a map for this request.
if(class_exists('LinkMapping')){
$queryString = '?';
if ($request->requestVars()){
foreach($request->requestVars() as $key => $value) {
if($key !='url'){$queryString .=$key.'='.$value.'&';}
}
$queryString = rtrim($queryString,'&');
}
$link = ($queryString != '?' ? $request->getURL().$queryString : $request->getURL());
$link = trim(Director::makeRelative($link));
$map = LinkMapping::get()->filter('MappedLink', $link)->first();
if ($map) {
$this->response = new HTTPResponse();
$this->response->redirect($map->getLink(), 301);
return $this->response;
}
}
// use OldPageRedirector if it exists, to find old page
if(class_exists(OldPageRedirector::class)){
if($redirect = OldPageRedirector::find_old_page(array($segment), Multisites::inst()->getCurrentSite())){
$redirect = SiteTree::get_by_link($redirect);
}
}else{
$redirect = self::find_old_page($segment, $site);
}
if($redirect) {
$getVars = $request->getVars();
//remove the url var as it confuses the routing
unset($getVars['url']);
$url = Controller::join_links(
$redirect->Link(
Controller::join_links(
$request->param('Action'),
$request->param('ID'),
$request->param('OtherID')
)
)
);
if(!empty($getVars)){
$url .= '?' . http_build_query($getVars);
}
$this->response->redirect($url, 301);
return $this->response;
}
return $this->httpError(404);
}
return self::controller_for($page, $request->param('Action'));
} | php | public function getNestedController() {
$request = $this->request;
$segment = $request->param('URLSegment');
$site = Multisites::inst()->getCurrentSiteId();
if(!$site) {
return $this->httpError(404);
}
$page = SiteTree::get()->filter(array(
'ParentID' => $site,
'URLSegment' => rawurlencode($segment)
));
$page = $page->first();
if(!$page) {
// Check to see if linkmapping module is installed and if so, if there a map for this request.
if(class_exists('LinkMapping')){
$queryString = '?';
if ($request->requestVars()){
foreach($request->requestVars() as $key => $value) {
if($key !='url'){$queryString .=$key.'='.$value.'&';}
}
$queryString = rtrim($queryString,'&');
}
$link = ($queryString != '?' ? $request->getURL().$queryString : $request->getURL());
$link = trim(Director::makeRelative($link));
$map = LinkMapping::get()->filter('MappedLink', $link)->first();
if ($map) {
$this->response = new HTTPResponse();
$this->response->redirect($map->getLink(), 301);
return $this->response;
}
}
// use OldPageRedirector if it exists, to find old page
if(class_exists(OldPageRedirector::class)){
if($redirect = OldPageRedirector::find_old_page(array($segment), Multisites::inst()->getCurrentSite())){
$redirect = SiteTree::get_by_link($redirect);
}
}else{
$redirect = self::find_old_page($segment, $site);
}
if($redirect) {
$getVars = $request->getVars();
//remove the url var as it confuses the routing
unset($getVars['url']);
$url = Controller::join_links(
$redirect->Link(
Controller::join_links(
$request->param('Action'),
$request->param('ID'),
$request->param('OtherID')
)
)
);
if(!empty($getVars)){
$url .= '?' . http_build_query($getVars);
}
$this->response->redirect($url, 301);
return $this->response;
}
return $this->httpError(404);
}
return self::controller_for($page, $request->param('Action'));
} | [
"public",
"function",
"getNestedController",
"(",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"request",
";",
"$",
"segment",
"=",
"$",
"request",
"->",
"param",
"(",
"'URLSegment'",
")",
";",
"$",
"site",
"=",
"Multisites",
"::",
"inst",
"(",
")... | Overrides ModelAsController->getNestedController to find the nested controller
on a per-site basis | [
"Overrides",
"ModelAsController",
"-",
">",
"getNestedController",
"to",
"find",
"the",
"nested",
"controller",
"on",
"a",
"per",
"-",
"site",
"basis"
] | 9b3fa1d3375ce073c050bd137b68766073efd458 | https://github.com/symbiote/silverstripe-multisites/blob/9b3fa1d3375ce073c050bd137b68766073efd458/src/Control/MultisitesFrontController.php#L22-L97 |
46,365 | symbiote/silverstripe-multisites | src/Multisites.php | Multisites.init | public function init()
{
$valid = null;
if ($this->cache->has(self::CACHE_KEY)) {
$cached = $this->cache->get(self::CACHE_KEY);
$valid = $cached && isset($cached['hosts']) && count($cached['hosts']);
}
if ($valid) {
$this->map = $cached;
} else {
$this->build();
}
} | php | public function init()
{
$valid = null;
if ($this->cache->has(self::CACHE_KEY)) {
$cached = $this->cache->get(self::CACHE_KEY);
$valid = $cached && isset($cached['hosts']) && count($cached['hosts']);
}
if ($valid) {
$this->map = $cached;
} else {
$this->build();
}
} | [
"public",
"function",
"init",
"(",
")",
"{",
"$",
"valid",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"cache",
"->",
"has",
"(",
"self",
"::",
"CACHE_KEY",
")",
")",
"{",
"$",
"cached",
"=",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"s... | Attempts to load the hostname map from the cache, and rebuilds it if
it cannot be loaded. | [
"Attempts",
"to",
"load",
"the",
"hostname",
"map",
"from",
"the",
"cache",
"and",
"rebuilds",
"it",
"if",
"it",
"cannot",
"be",
"loaded",
"."
] | 9b3fa1d3375ce073c050bd137b68766073efd458 | https://github.com/symbiote/silverstripe-multisites/blob/9b3fa1d3375ce073c050bd137b68766073efd458/src/Multisites.php#L91-L106 |
46,366 | symbiote/silverstripe-multisites | src/Multisites.php | Multisites.build | public function build()
{
$this->map = array(
'default' => null,
'hosts' => array()
);
if (!DB::is_active() ||
!DB::get_schema()->hasTable(Site::config()->table_name)) {
return;
}
$sites = Site::get();
/**
* After duplicating a site, the duplicate contains the same host and causes a 404 during resolution.
* IMPORTANT, this is required to prevent the site from going down.
* ---
*/
$sites = $sites->sort(array(
'ID' => 'DESC'
));
// ---
foreach ($sites as $site) {
if ($site->IsDefault) {
$this->map['default'] = $site->ID;
}
$hosts = array($site->Host);
$hosts = array_merge($hosts, (array) $site->HostAliases->getValue());
foreach ($hosts as $host) {
if (!$host) {
continue;
}
if ($site->Scheme != 'https') {
$this->map['hosts']["http://$host"] = $site->ID;
}
if ($site->Scheme != 'http') {
$this->map['hosts']["https://$host"] = $site->ID;
}
}
}
$this->cache->set(self::CACHE_KEY, $this->map);
} | php | public function build()
{
$this->map = array(
'default' => null,
'hosts' => array()
);
if (!DB::is_active() ||
!DB::get_schema()->hasTable(Site::config()->table_name)) {
return;
}
$sites = Site::get();
/**
* After duplicating a site, the duplicate contains the same host and causes a 404 during resolution.
* IMPORTANT, this is required to prevent the site from going down.
* ---
*/
$sites = $sites->sort(array(
'ID' => 'DESC'
));
// ---
foreach ($sites as $site) {
if ($site->IsDefault) {
$this->map['default'] = $site->ID;
}
$hosts = array($site->Host);
$hosts = array_merge($hosts, (array) $site->HostAliases->getValue());
foreach ($hosts as $host) {
if (!$host) {
continue;
}
if ($site->Scheme != 'https') {
$this->map['hosts']["http://$host"] = $site->ID;
}
if ($site->Scheme != 'http') {
$this->map['hosts']["https://$host"] = $site->ID;
}
}
}
$this->cache->set(self::CACHE_KEY, $this->map);
} | [
"public",
"function",
"build",
"(",
")",
"{",
"$",
"this",
"->",
"map",
"=",
"array",
"(",
"'default'",
"=>",
"null",
",",
"'hosts'",
"=>",
"array",
"(",
")",
")",
";",
"if",
"(",
"!",
"DB",
"::",
"is_active",
"(",
")",
"||",
"!",
"DB",
"::",
"... | Builds a map of hostnames to sites, and writes it to the cache. | [
"Builds",
"a",
"map",
"of",
"hostnames",
"to",
"sites",
"and",
"writes",
"it",
"to",
"the",
"cache",
"."
] | 9b3fa1d3375ce073c050bd137b68766073efd458 | https://github.com/symbiote/silverstripe-multisites/blob/9b3fa1d3375ce073c050bd137b68766073efd458/src/Multisites.php#L111-L159 |
46,367 | symbiote/silverstripe-multisites | src/Multisites.php | Multisites.getActiveSite | public function getActiveSite()
{
$controller = Controller::curr();
if ($controller instanceof CMSPageEditController) {
// requests to admin/pages/edit/EditorToolbar/viewfile?ID=XX
// are not reliable because $controller->currentPage()
// will return an incorrect page based on the ID $_GET parameter
if ($controller->getRequest()->param('ID') != 'viewfile') {
$page = $controller->currentPage();
if (!$page) {
// fixes fatal error when duplicating page
// TODO find the root of the problem...
return Site::get()->first();
}
if ($page instanceof Site) {
$this->setActiveSite($page);
return $page;
}
$site = $page->Site();
if ($site->ID) {
$this->setActiveSite($site);
return $site;
}
}
} else if (is_subclass_of($controller, ModelAdmin::class)) {
// if we are in a model admin that isn't using the global active_site_session,
// return it's ActiveSite. This is important for cases where a multisite aware
// data object is being saved for the first time in a model admin, we need to
// know what site to save it to
if (!$controller->config()->use_active_site_session) {
return $controller->getActiveSite();
}
}
if ($id = $controller->getRequest()->getSession()->get('Multisites_ActiveSite')) {
return Site::get()->byID($id);
}
// if($id = Session::get('MultisitesModelAdmin_SiteID')) { // legacy
// return Site::get()->byID($id);
// }
return $this->getCurrentSite();
} | php | public function getActiveSite()
{
$controller = Controller::curr();
if ($controller instanceof CMSPageEditController) {
// requests to admin/pages/edit/EditorToolbar/viewfile?ID=XX
// are not reliable because $controller->currentPage()
// will return an incorrect page based on the ID $_GET parameter
if ($controller->getRequest()->param('ID') != 'viewfile') {
$page = $controller->currentPage();
if (!$page) {
// fixes fatal error when duplicating page
// TODO find the root of the problem...
return Site::get()->first();
}
if ($page instanceof Site) {
$this->setActiveSite($page);
return $page;
}
$site = $page->Site();
if ($site->ID) {
$this->setActiveSite($site);
return $site;
}
}
} else if (is_subclass_of($controller, ModelAdmin::class)) {
// if we are in a model admin that isn't using the global active_site_session,
// return it's ActiveSite. This is important for cases where a multisite aware
// data object is being saved for the first time in a model admin, we need to
// know what site to save it to
if (!$controller->config()->use_active_site_session) {
return $controller->getActiveSite();
}
}
if ($id = $controller->getRequest()->getSession()->get('Multisites_ActiveSite')) {
return Site::get()->byID($id);
}
// if($id = Session::get('MultisitesModelAdmin_SiteID')) { // legacy
// return Site::get()->byID($id);
// }
return $this->getCurrentSite();
} | [
"public",
"function",
"getActiveSite",
"(",
")",
"{",
"$",
"controller",
"=",
"Controller",
"::",
"curr",
"(",
")",
";",
"if",
"(",
"$",
"controller",
"instanceof",
"CMSPageEditController",
")",
"{",
"// requests to admin/pages/edit/EditorToolbar/viewfile?ID=XX",
"// ... | Get's the site related to what is currently being edited in the cms
If a page or site is being edited, it will look up the site of the sitetree being edited,
If a MultisitesAware object is being managed in ModelAdmin, ModelAdmin will have set a Session variable MultisitesModelAdmin_SiteID
@return Site | [
"Get",
"s",
"the",
"site",
"related",
"to",
"what",
"is",
"currently",
"being",
"edited",
"in",
"the",
"cms",
"If",
"a",
"page",
"or",
"site",
"is",
"being",
"edited",
"it",
"will",
"look",
"up",
"the",
"site",
"of",
"the",
"sitetree",
"being",
"edited... | 9b3fa1d3375ce073c050bd137b68766073efd458 | https://github.com/symbiote/silverstripe-multisites/blob/9b3fa1d3375ce073c050bd137b68766073efd458/src/Multisites.php#L239-L287 |
46,368 | symbiote/silverstripe-multisites | src/Multisites.php | Multisites.sitesManagedByMember | public function sitesManagedByMember($member = null)
{
$member = $member ?: Member::currentUser();
if (!$member) return array();
$sites = Site::get();
if (Permission::check('ADMIN')) {
return $sites->column('ID');
}
$memberGroups = $member->Groups()->column('ID');
$sites = $sites->filter("EditorGroups.ID:ExactMatch", $memberGroups);
return $sites->column('ID');
} | php | public function sitesManagedByMember($member = null)
{
$member = $member ?: Member::currentUser();
if (!$member) return array();
$sites = Site::get();
if (Permission::check('ADMIN')) {
return $sites->column('ID');
}
$memberGroups = $member->Groups()->column('ID');
$sites = $sites->filter("EditorGroups.ID:ExactMatch", $memberGroups);
return $sites->column('ID');
} | [
"public",
"function",
"sitesManagedByMember",
"(",
"$",
"member",
"=",
"null",
")",
"{",
"$",
"member",
"=",
"$",
"member",
"?",
":",
"Member",
"::",
"currentUser",
"(",
")",
";",
"if",
"(",
"!",
"$",
"member",
")",
"return",
"array",
"(",
")",
";",
... | Finds sites that the given member is a "Manager" of
A manager is currently defined by a Member who has edit access to a Site Object
@var Member $member
@return array - Site IDs | [
"Finds",
"sites",
"that",
"the",
"given",
"member",
"is",
"a",
"Manager",
"of",
"A",
"manager",
"is",
"currently",
"defined",
"by",
"a",
"Member",
"who",
"has",
"edit",
"access",
"to",
"a",
"Site",
"Object"
] | 9b3fa1d3375ce073c050bd137b68766073efd458 | https://github.com/symbiote/silverstripe-multisites/blob/9b3fa1d3375ce073c050bd137b68766073efd458/src/Multisites.php#L311-L326 |
46,369 | tmconsulting/uniteller-php-sdk | src/Client.php | Client.verifyCallbackRequest | public function verifyCallbackRequest(array $params)
{
return $this->signatureCallback
->setOrderId(array_get($params, 'Order_ID'))
->setStatus(array_get($params, 'Status'))
->setFields(array_except($params, ['Order_ID', 'Status', 'Signature']))
->setPassword($this->getPassword())
->verify(array_get($params, 'Signature'));
} | php | public function verifyCallbackRequest(array $params)
{
return $this->signatureCallback
->setOrderId(array_get($params, 'Order_ID'))
->setStatus(array_get($params, 'Status'))
->setFields(array_except($params, ['Order_ID', 'Status', 'Signature']))
->setPassword($this->getPassword())
->verify(array_get($params, 'Signature'));
} | [
"public",
"function",
"verifyCallbackRequest",
"(",
"array",
"$",
"params",
")",
"{",
"return",
"$",
"this",
"->",
"signatureCallback",
"->",
"setOrderId",
"(",
"array_get",
"(",
"$",
"params",
",",
"'Order_ID'",
")",
")",
"->",
"setStatus",
"(",
"array_get",
... | Verify signature when Client will be send callback request.
@param array $params
@return bool | [
"Verify",
"signature",
"when",
"Client",
"will",
"be",
"send",
"callback",
"request",
"."
] | c296f4c9416e0445b8ae93d3ca4dc99423dc8d6e | https://github.com/tmconsulting/uniteller-php-sdk/blob/c296f4c9416e0445b8ae93d3ca4dc99423dc8d6e/src/Client.php#L494-L502 |
46,370 | silverstripe/silverstripe-environmentcheck | src/Checks/CacheHeadersCheck.php | CacheHeadersCheck.check | public function check()
{
// Using a validation result to capture messages
$this->result = new ValidationResult();
$response = $this->client->get($this->getURL());
$fullURL = $this->getURL();
if ($response === null) {
return [
EnvironmentCheck::ERROR,
"Cache headers check request failed for $fullURL",
];
}
//Check that Etag exists
$this->checkEtag($response);
// Check Cache-Control settings
$this->checkCacheControl($response);
if ($this->result->isValid()) {
return [
EnvironmentCheck::OK,
$this->getMessage(),
];
} else {
// @todo Ability to return a warning
return [
EnvironmentCheck::ERROR,
$this->getMessage(),
];
}
} | php | public function check()
{
// Using a validation result to capture messages
$this->result = new ValidationResult();
$response = $this->client->get($this->getURL());
$fullURL = $this->getURL();
if ($response === null) {
return [
EnvironmentCheck::ERROR,
"Cache headers check request failed for $fullURL",
];
}
//Check that Etag exists
$this->checkEtag($response);
// Check Cache-Control settings
$this->checkCacheControl($response);
if ($this->result->isValid()) {
return [
EnvironmentCheck::OK,
$this->getMessage(),
];
} else {
// @todo Ability to return a warning
return [
EnvironmentCheck::ERROR,
$this->getMessage(),
];
}
} | [
"public",
"function",
"check",
"(",
")",
"{",
"// Using a validation result to capture messages",
"$",
"this",
"->",
"result",
"=",
"new",
"ValidationResult",
"(",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"this",
"-... | Check that correct caching headers are present.
@return void | [
"Check",
"that",
"correct",
"caching",
"headers",
"are",
"present",
"."
] | 6fe0b1889e60678ed374735f037c4e69a87041bb | https://github.com/silverstripe/silverstripe-environmentcheck/blob/6fe0b1889e60678ed374735f037c4e69a87041bb/src/Checks/CacheHeadersCheck.php#L66-L98 |
46,371 | silverstripe/silverstripe-environmentcheck | src/Checks/CacheHeadersCheck.php | CacheHeadersCheck.getMessage | private function getMessage()
{
$ret = '';
// Filter good messages
$goodTypes = [ValidationResult::TYPE_GOOD, ValidationResult::TYPE_INFO];
$good = array_filter(
$this->result->getMessages(),
function ($val, $key) use ($goodTypes) {
if (in_array($val['messageType'], $goodTypes)) {
return true;
}
return false;
},
ARRAY_FILTER_USE_BOTH
);
if (!empty($good)) {
$ret .= "GOOD: " . implode('; ', array_column($good, 'message')) . " ";
}
// Filter bad messages
$badTypes = [ValidationResult::TYPE_ERROR, ValidationResult::TYPE_WARNING];
$bad = array_filter(
$this->result->getMessages(),
function ($val, $key) use ($badTypes) {
if (in_array($val['messageType'], $badTypes)) {
return true;
}
return false;
},
ARRAY_FILTER_USE_BOTH
);
if (!empty($bad)) {
$ret .= "BAD: " . implode('; ', array_column($bad, 'message'));
}
return $ret;
} | php | private function getMessage()
{
$ret = '';
// Filter good messages
$goodTypes = [ValidationResult::TYPE_GOOD, ValidationResult::TYPE_INFO];
$good = array_filter(
$this->result->getMessages(),
function ($val, $key) use ($goodTypes) {
if (in_array($val['messageType'], $goodTypes)) {
return true;
}
return false;
},
ARRAY_FILTER_USE_BOTH
);
if (!empty($good)) {
$ret .= "GOOD: " . implode('; ', array_column($good, 'message')) . " ";
}
// Filter bad messages
$badTypes = [ValidationResult::TYPE_ERROR, ValidationResult::TYPE_WARNING];
$bad = array_filter(
$this->result->getMessages(),
function ($val, $key) use ($badTypes) {
if (in_array($val['messageType'], $badTypes)) {
return true;
}
return false;
},
ARRAY_FILTER_USE_BOTH
);
if (!empty($bad)) {
$ret .= "BAD: " . implode('; ', array_column($bad, 'message'));
}
return $ret;
} | [
"private",
"function",
"getMessage",
"(",
")",
"{",
"$",
"ret",
"=",
"''",
";",
"// Filter good messages",
"$",
"goodTypes",
"=",
"[",
"ValidationResult",
"::",
"TYPE_GOOD",
",",
"ValidationResult",
"::",
"TYPE_INFO",
"]",
";",
"$",
"good",
"=",
"array_filter"... | Collate messages from ValidationResult so that it is clear which parts
of the check passed and which failed.
@return string | [
"Collate",
"messages",
"from",
"ValidationResult",
"so",
"that",
"it",
"is",
"clear",
"which",
"parts",
"of",
"the",
"check",
"passed",
"and",
"which",
"failed",
"."
] | 6fe0b1889e60678ed374735f037c4e69a87041bb | https://github.com/silverstripe/silverstripe-environmentcheck/blob/6fe0b1889e60678ed374735f037c4e69a87041bb/src/Checks/CacheHeadersCheck.php#L106-L141 |
46,372 | silverstripe/silverstripe-environmentcheck | src/Checks/CacheHeadersCheck.php | CacheHeadersCheck.checkEtag | private function checkEtag(ResponseInterface $response)
{
$eTag = $response->getHeaderLine('ETag');
$fullURL = Controller::join_links(Director::absoluteBaseURL(), $this->url);
if ($eTag) {
$this->result->addMessage(
"$fullURL includes an Etag header in response",
ValidationResult::TYPE_GOOD
);
return;
}
$this->result->addError(
"$fullURL is missing an Etag header",
ValidationResult::TYPE_WARNING
);
} | php | private function checkEtag(ResponseInterface $response)
{
$eTag = $response->getHeaderLine('ETag');
$fullURL = Controller::join_links(Director::absoluteBaseURL(), $this->url);
if ($eTag) {
$this->result->addMessage(
"$fullURL includes an Etag header in response",
ValidationResult::TYPE_GOOD
);
return;
}
$this->result->addError(
"$fullURL is missing an Etag header",
ValidationResult::TYPE_WARNING
);
} | [
"private",
"function",
"checkEtag",
"(",
"ResponseInterface",
"$",
"response",
")",
"{",
"$",
"eTag",
"=",
"$",
"response",
"->",
"getHeaderLine",
"(",
"'ETag'",
")",
";",
"$",
"fullURL",
"=",
"Controller",
"::",
"join_links",
"(",
"Director",
"::",
"absolut... | Check that ETag header exists
@param ResponseInterface $response
@return void | [
"Check",
"that",
"ETag",
"header",
"exists"
] | 6fe0b1889e60678ed374735f037c4e69a87041bb | https://github.com/silverstripe/silverstripe-environmentcheck/blob/6fe0b1889e60678ed374735f037c4e69a87041bb/src/Checks/CacheHeadersCheck.php#L149-L165 |
46,373 | silverstripe/silverstripe-environmentcheck | src/Checks/CacheHeadersCheck.php | CacheHeadersCheck.checkCacheControl | private function checkCacheControl(ResponseInterface $response)
{
$cacheControl = $response->getHeaderLine('Cache-Control');
$vals = array_map('trim', explode(',', $cacheControl));
$fullURL = Controller::join_links(Director::absoluteBaseURL(), $this->url);
// All entries from must contain should be present
if ($this->mustInclude == array_intersect($this->mustInclude, $vals)) {
$matched = implode(",", $this->mustInclude);
$this->result->addMessage(
"$fullURL includes all settings: {$matched}",
ValidationResult::TYPE_GOOD
);
} else {
$missing = implode(",", array_diff($this->mustInclude, $vals));
$this->result->addError(
"$fullURL is excluding some settings: {$missing}"
);
}
// All entries from must exclude should not be present
if (empty(array_intersect($this->mustExclude, $vals))) {
$missing = implode(",", $this->mustExclude);
$this->result->addMessage(
"$fullURL excludes all settings: {$missing}",
ValidationResult::TYPE_GOOD
);
} else {
$matched = implode(",", array_intersect($this->mustExclude, $vals));
$this->result->addError(
"$fullURL is including some settings: {$matched}"
);
}
} | php | private function checkCacheControl(ResponseInterface $response)
{
$cacheControl = $response->getHeaderLine('Cache-Control');
$vals = array_map('trim', explode(',', $cacheControl));
$fullURL = Controller::join_links(Director::absoluteBaseURL(), $this->url);
// All entries from must contain should be present
if ($this->mustInclude == array_intersect($this->mustInclude, $vals)) {
$matched = implode(",", $this->mustInclude);
$this->result->addMessage(
"$fullURL includes all settings: {$matched}",
ValidationResult::TYPE_GOOD
);
} else {
$missing = implode(",", array_diff($this->mustInclude, $vals));
$this->result->addError(
"$fullURL is excluding some settings: {$missing}"
);
}
// All entries from must exclude should not be present
if (empty(array_intersect($this->mustExclude, $vals))) {
$missing = implode(",", $this->mustExclude);
$this->result->addMessage(
"$fullURL excludes all settings: {$missing}",
ValidationResult::TYPE_GOOD
);
} else {
$matched = implode(",", array_intersect($this->mustExclude, $vals));
$this->result->addError(
"$fullURL is including some settings: {$matched}"
);
}
} | [
"private",
"function",
"checkCacheControl",
"(",
"ResponseInterface",
"$",
"response",
")",
"{",
"$",
"cacheControl",
"=",
"$",
"response",
"->",
"getHeaderLine",
"(",
"'Cache-Control'",
")",
";",
"$",
"vals",
"=",
"array_map",
"(",
"'trim'",
",",
"explode",
"... | Check that the correct header settings are either included or excluded.
@param ResponseInterface $response
@return void | [
"Check",
"that",
"the",
"correct",
"header",
"settings",
"are",
"either",
"included",
"or",
"excluded",
"."
] | 6fe0b1889e60678ed374735f037c4e69a87041bb | https://github.com/silverstripe/silverstripe-environmentcheck/blob/6fe0b1889e60678ed374735f037c4e69a87041bb/src/Checks/CacheHeadersCheck.php#L173-L206 |
46,374 | silverstripe/silverstripe-environmentcheck | src/EnvironmentChecker.php | EnvironmentChecker.canAccess | public function canAccess($member = null, $permission = 'ADMIN')
{
if (!$member) {
$member = Security::getCurrentUser();
}
// We allow access to this controller regardless of live-status or ADMIN permission only
// if on CLI. Access to this controller is always allowed in "dev-mode", or of the user is ADMIN.
if (Director::isDev()
|| Director::is_cli()
|| empty($permission)
|| Permission::checkMember($member, $permission)
) {
return true;
}
// Extended access checks.
// "Veto" style, return NULL to abstain vote.
$canExtended = null;
$results = $this->extend('canAccess', $member);
if ($results && is_array($results)) {
if (!min($results)) {
return false;
}
return true;
}
return false;
} | php | public function canAccess($member = null, $permission = 'ADMIN')
{
if (!$member) {
$member = Security::getCurrentUser();
}
// We allow access to this controller regardless of live-status or ADMIN permission only
// if on CLI. Access to this controller is always allowed in "dev-mode", or of the user is ADMIN.
if (Director::isDev()
|| Director::is_cli()
|| empty($permission)
|| Permission::checkMember($member, $permission)
) {
return true;
}
// Extended access checks.
// "Veto" style, return NULL to abstain vote.
$canExtended = null;
$results = $this->extend('canAccess', $member);
if ($results && is_array($results)) {
if (!min($results)) {
return false;
}
return true;
}
return false;
} | [
"public",
"function",
"canAccess",
"(",
"$",
"member",
"=",
"null",
",",
"$",
"permission",
"=",
"'ADMIN'",
")",
"{",
"if",
"(",
"!",
"$",
"member",
")",
"{",
"$",
"member",
"=",
"Security",
"::",
"getCurrentUser",
"(",
")",
";",
"}",
"// We allow acce... | Determine if the current member can access the environment checker
@param null|int|Member $member
@param string $permission
@return bool | [
"Determine",
"if",
"the",
"current",
"member",
"can",
"access",
"the",
"environment",
"checker"
] | 6fe0b1889e60678ed374735f037c4e69a87041bb | https://github.com/silverstripe/silverstripe-environmentcheck/blob/6fe0b1889e60678ed374735f037c4e69a87041bb/src/EnvironmentChecker.php#L133-L161 |
46,375 | silverstripe/silverstripe-environmentcheck | src/EnvironmentChecker.php | EnvironmentChecker.log | public function log($message, $level)
{
Injector::inst()->get(LoggerInterface::class)->log($level, $message);
} | php | public function log($message, $level)
{
Injector::inst()->get(LoggerInterface::class)->log($level, $message);
} | [
"public",
"function",
"log",
"(",
"$",
"message",
",",
"$",
"level",
")",
"{",
"Injector",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"LoggerInterface",
"::",
"class",
")",
"->",
"log",
"(",
"$",
"level",
",",
"$",
"message",
")",
";",
"}"
] | Sends a log entry to the configured PSR-3 LoggerInterface
@param string $message
@param int $level | [
"Sends",
"a",
"log",
"entry",
"to",
"the",
"configured",
"PSR",
"-",
"3",
"LoggerInterface"
] | 6fe0b1889e60678ed374735f037c4e69a87041bb | https://github.com/silverstripe/silverstripe-environmentcheck/blob/6fe0b1889e60678ed374735f037c4e69a87041bb/src/EnvironmentChecker.php#L227-L230 |
46,376 | silverstripe/silverstripe-environmentcheck | src/EnvironmentCheckSuite.php | EnvironmentCheckSuite.run | public function run()
{
$result = new EnvironmentCheckSuiteResult();
foreach ($this->checkInstances() as $check) {
list($checkClass, $checkTitle) = $check;
try {
list($status, $message) = $checkClass->check();
// If the check fails, register that as an error
} catch (Exception $e) {
$status = EnvironmentCheck::ERROR;
$message = $e->getMessage();
}
$result->addResult($status, $message, $checkTitle);
}
return $result;
} | php | public function run()
{
$result = new EnvironmentCheckSuiteResult();
foreach ($this->checkInstances() as $check) {
list($checkClass, $checkTitle) = $check;
try {
list($status, $message) = $checkClass->check();
// If the check fails, register that as an error
} catch (Exception $e) {
$status = EnvironmentCheck::ERROR;
$message = $e->getMessage();
}
$result->addResult($status, $message, $checkTitle);
}
return $result;
} | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"result",
"=",
"new",
"EnvironmentCheckSuiteResult",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"checkInstances",
"(",
")",
"as",
"$",
"check",
")",
"{",
"list",
"(",
"$",
"checkClass",
",",
"$",
... | Run this test suite and return the result code of the worst result.
@return EnvironmentCheckSuiteResult | [
"Run",
"this",
"test",
"suite",
"and",
"return",
"the",
"result",
"code",
"of",
"the",
"worst",
"result",
"."
] | 6fe0b1889e60678ed374735f037c4e69a87041bb | https://github.com/silverstripe/silverstripe-environmentcheck/blob/6fe0b1889e60678ed374735f037c4e69a87041bb/src/EnvironmentCheckSuite.php#L106-L123 |
46,377 | silverstripe/silverstripe-environmentcheck | src/EnvironmentCheckSuite.php | EnvironmentCheckSuite.checkInstances | protected function checkInstances()
{
$output = [];
foreach ($this->checks as $check) {
list($checkClass, $checkTitle) = $check;
if (is_string($checkClass)) {
$checkInst = Injector::inst()->create($checkClass);
if ($checkInst instanceof EnvironmentCheck) {
$output[] = [$checkInst, $checkTitle];
} else {
throw new InvalidArgumentException(
"Bad EnvironmentCheck: '$checkClass' - the named class doesn't implement EnvironmentCheck"
);
}
} elseif ($checkClass instanceof EnvironmentCheck) {
$output[] = [$checkClass, $checkTitle];
} else {
throw new InvalidArgumentException("Bad EnvironmentCheck: " . var_export($check, true));
}
}
return $output;
} | php | protected function checkInstances()
{
$output = [];
foreach ($this->checks as $check) {
list($checkClass, $checkTitle) = $check;
if (is_string($checkClass)) {
$checkInst = Injector::inst()->create($checkClass);
if ($checkInst instanceof EnvironmentCheck) {
$output[] = [$checkInst, $checkTitle];
} else {
throw new InvalidArgumentException(
"Bad EnvironmentCheck: '$checkClass' - the named class doesn't implement EnvironmentCheck"
);
}
} elseif ($checkClass instanceof EnvironmentCheck) {
$output[] = [$checkClass, $checkTitle];
} else {
throw new InvalidArgumentException("Bad EnvironmentCheck: " . var_export($check, true));
}
}
return $output;
} | [
"protected",
"function",
"checkInstances",
"(",
")",
"{",
"$",
"output",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"checks",
"as",
"$",
"check",
")",
"{",
"list",
"(",
"$",
"checkClass",
",",
"$",
"checkTitle",
")",
"=",
"$",
"check",
... | Get instances of all the environment checks.
@return EnvironmentChecker[]
@throws InvalidArgumentException | [
"Get",
"instances",
"of",
"all",
"the",
"environment",
"checks",
"."
] | 6fe0b1889e60678ed374735f037c4e69a87041bb | https://github.com/silverstripe/silverstripe-environmentcheck/blob/6fe0b1889e60678ed374735f037c4e69a87041bb/src/EnvironmentCheckSuite.php#L131-L152 |
46,378 | silverstripe/silverstripe-environmentcheck | src/EnvironmentCheckSuite.php | EnvironmentCheckSuite.push | public function push($check, $title = null)
{
if (!$title) {
$title = is_string($check) ? $check : get_class($check);
}
$this->checks[] = [$check, $title];
} | php | public function push($check, $title = null)
{
if (!$title) {
$title = is_string($check) ? $check : get_class($check);
}
$this->checks[] = [$check, $title];
} | [
"public",
"function",
"push",
"(",
"$",
"check",
",",
"$",
"title",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"title",
")",
"{",
"$",
"title",
"=",
"is_string",
"(",
"$",
"check",
")",
"?",
"$",
"check",
":",
"get_class",
"(",
"$",
"check",
"... | Add a check to this suite.
@param mixed $check
@param string $title | [
"Add",
"a",
"check",
"to",
"this",
"suite",
"."
] | 6fe0b1889e60678ed374735f037c4e69a87041bb | https://github.com/silverstripe/silverstripe-environmentcheck/blob/6fe0b1889e60678ed374735f037c4e69a87041bb/src/EnvironmentCheckSuite.php#L160-L166 |
46,379 | silverstripe/silverstripe-environmentcheck | src/EnvironmentCheckSuite.php | EnvironmentCheckSuite.inst | public static function inst($name)
{
if (!isset(self::$instances[$name])) {
self::$instances[$name] = new EnvironmentCheckSuite($name);
}
return self::$instances[$name];
} | php | public static function inst($name)
{
if (!isset(self::$instances[$name])) {
self::$instances[$name] = new EnvironmentCheckSuite($name);
}
return self::$instances[$name];
} | [
"public",
"static",
"function",
"inst",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"instances",
"[",
"$",
"name",
"]",
")",
")",
"{",
"self",
"::",
"$",
"instances",
"[",
"$",
"name",
"]",
"=",
"new",
"Environmen... | Return a named instance of EnvironmentCheckSuite.
@param string $name
@return EnvironmentCheckSuite | [
"Return",
"a",
"named",
"instance",
"of",
"EnvironmentCheckSuite",
"."
] | 6fe0b1889e60678ed374735f037c4e69a87041bb | https://github.com/silverstripe/silverstripe-environmentcheck/blob/6fe0b1889e60678ed374735f037c4e69a87041bb/src/EnvironmentCheckSuite.php#L182-L188 |
46,380 | silverstripe/silverstripe-environmentcheck | src/EnvironmentCheckSuite.php | EnvironmentCheckSuite.register | public static function register($names, $check, $title = null)
{
if (!is_array($names)) {
$names = [$names];
}
foreach ($names as $name) {
self::inst($name)->push($check, $title);
}
} | php | public static function register($names, $check, $title = null)
{
if (!is_array($names)) {
$names = [$names];
}
foreach ($names as $name) {
self::inst($name)->push($check, $title);
}
} | [
"public",
"static",
"function",
"register",
"(",
"$",
"names",
",",
"$",
"check",
",",
"$",
"title",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"names",
")",
")",
"{",
"$",
"names",
"=",
"[",
"$",
"names",
"]",
";",
"}",
"fore... | Register a check against the named check suite.
@param string|array $names
@param EnvironmentCheck $check
@param string|array | [
"Register",
"a",
"check",
"against",
"the",
"named",
"check",
"suite",
"."
] | 6fe0b1889e60678ed374735f037c4e69a87041bb | https://github.com/silverstripe/silverstripe-environmentcheck/blob/6fe0b1889e60678ed374735f037c4e69a87041bb/src/EnvironmentCheckSuite.php#L197-L206 |
46,381 | silverstripe/silverstripe-environmentcheck | src/EnvironmentCheckSuiteResult.php | EnvironmentCheckSuiteResult.toJSON | public function toJSON()
{
$result = [
'Status' => $this->Status(),
'ShouldPass' => $this->ShouldPass(),
'Checks' => []
];
foreach ($this->details as $detail) {
$result['Checks'][] = $detail->toMap();
}
return json_encode($result);
} | php | public function toJSON()
{
$result = [
'Status' => $this->Status(),
'ShouldPass' => $this->ShouldPass(),
'Checks' => []
];
foreach ($this->details as $detail) {
$result['Checks'][] = $detail->toMap();
}
return json_encode($result);
} | [
"public",
"function",
"toJSON",
"(",
")",
"{",
"$",
"result",
"=",
"[",
"'Status'",
"=>",
"$",
"this",
"->",
"Status",
"(",
")",
",",
"'ShouldPass'",
"=>",
"$",
"this",
"->",
"ShouldPass",
"(",
")",
",",
"'Checks'",
"=>",
"[",
"]",
"]",
";",
"forea... | Convert the final result status and details to JSON.
@return string | [
"Convert",
"the",
"final",
"result",
"status",
"and",
"details",
"to",
"JSON",
"."
] | 6fe0b1889e60678ed374735f037c4e69a87041bb | https://github.com/silverstripe/silverstripe-environmentcheck/blob/6fe0b1889e60678ed374735f037c4e69a87041bb/src/EnvironmentCheckSuiteResult.php#L85-L96 |
46,382 | silverstripe/silverstripe-environmentcheck | src/EnvironmentCheckSuiteResult.php | EnvironmentCheckSuiteResult.statusText | protected function statusText($status)
{
switch ($status) {
case EnvironmentCheck::ERROR:
return 'ERROR';
break;
case EnvironmentCheck::WARNING:
return 'WARNING';
break;
case EnvironmentCheck::OK:
return 'OK';
break;
case 0:
return 'NO CHECKS';
break;
default:
throw new InvalidArgumentException("Bad environment check status '$status'");
break;
}
} | php | protected function statusText($status)
{
switch ($status) {
case EnvironmentCheck::ERROR:
return 'ERROR';
break;
case EnvironmentCheck::WARNING:
return 'WARNING';
break;
case EnvironmentCheck::OK:
return 'OK';
break;
case 0:
return 'NO CHECKS';
break;
default:
throw new InvalidArgumentException("Bad environment check status '$status'");
break;
}
} | [
"protected",
"function",
"statusText",
"(",
"$",
"status",
")",
"{",
"switch",
"(",
"$",
"status",
")",
"{",
"case",
"EnvironmentCheck",
"::",
"ERROR",
":",
"return",
"'ERROR'",
";",
"break",
";",
"case",
"EnvironmentCheck",
"::",
"WARNING",
":",
"return",
... | Return a text version of a status code.
@param int $status
@return string
@throws InvalidArgumentException | [
"Return",
"a",
"text",
"version",
"of",
"a",
"status",
"code",
"."
] | 6fe0b1889e60678ed374735f037c4e69a87041bb | https://github.com/silverstripe/silverstripe-environmentcheck/blob/6fe0b1889e60678ed374735f037c4e69a87041bb/src/EnvironmentCheckSuiteResult.php#L105-L124 |
46,383 | silverstripe/silverstripe-environmentcheck | src/Checks/SessionCheck.php | SessionCheck.getCookie | public function getCookie(ResponseInterface $response)
{
$result = null;
$cookies = $response->getHeader('Set-Cookie');
foreach ($cookies as $cookie) {
if (strpos($cookie, 'SESSID') !== false) {
$result = $cookie;
}
}
return $result;
} | php | public function getCookie(ResponseInterface $response)
{
$result = null;
$cookies = $response->getHeader('Set-Cookie');
foreach ($cookies as $cookie) {
if (strpos($cookie, 'SESSID') !== false) {
$result = $cookie;
}
}
return $result;
} | [
"public",
"function",
"getCookie",
"(",
"ResponseInterface",
"$",
"response",
")",
"{",
"$",
"result",
"=",
"null",
";",
"$",
"cookies",
"=",
"$",
"response",
"->",
"getHeader",
"(",
"'Set-Cookie'",
")",
";",
"foreach",
"(",
"$",
"cookies",
"as",
"$",
"c... | Get PHPSESSID or SECSESSID cookie set from the response if it exists.
@param ResponseInterface $response
@return string|null Cookie contents or null if it doesn't exist | [
"Get",
"PHPSESSID",
"or",
"SECSESSID",
"cookie",
"set",
"from",
"the",
"response",
"if",
"it",
"exists",
"."
] | 6fe0b1889e60678ed374735f037c4e69a87041bb | https://github.com/silverstripe/silverstripe-environmentcheck/blob/6fe0b1889e60678ed374735f037c4e69a87041bb/src/Checks/SessionCheck.php#L59-L70 |
46,384 | phalapi/cli | src/Ulrichsg/Getopt/Getopt.php | Getopt.addOptions | public function addOptions($options)
{
if (is_string($options)) {
$this->mergeOptions($this->optionParser->parseString($options));
} elseif (is_array($options)) {
$this->mergeOptions($this->optionParser->parseArray($options));
} else {
throw new \InvalidArgumentException("Getopt(): argument must be string or array");
}
} | php | public function addOptions($options)
{
if (is_string($options)) {
$this->mergeOptions($this->optionParser->parseString($options));
} elseif (is_array($options)) {
$this->mergeOptions($this->optionParser->parseArray($options));
} else {
throw new \InvalidArgumentException("Getopt(): argument must be string or array");
}
} | [
"public",
"function",
"addOptions",
"(",
"$",
"options",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"options",
")",
")",
"{",
"$",
"this",
"->",
"mergeOptions",
"(",
"$",
"this",
"->",
"optionParser",
"->",
"parseString",
"(",
"$",
"options",
")",
")"... | Extends the list of known options. Takes the same argument types as the constructor.
@param mixed $options
@throws \InvalidArgumentException | [
"Extends",
"the",
"list",
"of",
"known",
"options",
".",
"Takes",
"the",
"same",
"argument",
"types",
"as",
"the",
"constructor",
"."
] | c5df41e5fa483ad5990296421cde808a0d29f36f | https://github.com/phalapi/cli/blob/c5df41e5fa483ad5990296421cde808a0d29f36f/src/Ulrichsg/Getopt/Getopt.php#L58-L67 |
46,385 | phalapi/cli | src/Ulrichsg/Getopt/Getopt.php | Getopt.mergeOptions | private function mergeOptions(array $options)
{
/** @var Option[] $mergedList */
$mergedList = array_merge($this->optionList, $options);
$duplicates = array();
foreach ($mergedList as $option) {
foreach ($mergedList as $otherOption) {
if (($option === $otherOption) || in_array($otherOption, $duplicates)) {
continue;
}
if ($this->optionsConflict($option, $otherOption)) {
throw new \InvalidArgumentException('Failed to add options due to conflict');
}
if (($option->short() === $otherOption->short()) && ($option->long() === $otherOption->long())) {
$duplicates[] = $option;
}
}
}
foreach ($mergedList as $index => $option) {
if (in_array($option, $duplicates)) {
unset($mergedList[$index]);
}
}
$this->optionList = array_values($mergedList);
} | php | private function mergeOptions(array $options)
{
/** @var Option[] $mergedList */
$mergedList = array_merge($this->optionList, $options);
$duplicates = array();
foreach ($mergedList as $option) {
foreach ($mergedList as $otherOption) {
if (($option === $otherOption) || in_array($otherOption, $duplicates)) {
continue;
}
if ($this->optionsConflict($option, $otherOption)) {
throw new \InvalidArgumentException('Failed to add options due to conflict');
}
if (($option->short() === $otherOption->short()) && ($option->long() === $otherOption->long())) {
$duplicates[] = $option;
}
}
}
foreach ($mergedList as $index => $option) {
if (in_array($option, $duplicates)) {
unset($mergedList[$index]);
}
}
$this->optionList = array_values($mergedList);
} | [
"private",
"function",
"mergeOptions",
"(",
"array",
"$",
"options",
")",
"{",
"/** @var Option[] $mergedList */",
"$",
"mergedList",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"optionList",
",",
"$",
"options",
")",
";",
"$",
"duplicates",
"=",
"array",
"(",... | Merges new options with the ones already in the Getopt optionList, making sure the resulting list is free of
conflicts.
@param Option[] $options The list of new options
@throws \InvalidArgumentException | [
"Merges",
"new",
"options",
"with",
"the",
"ones",
"already",
"in",
"the",
"Getopt",
"optionList",
"making",
"sure",
"the",
"resulting",
"list",
"is",
"free",
"of",
"conflicts",
"."
] | c5df41e5fa483ad5990296421cde808a0d29f36f | https://github.com/phalapi/cli/blob/c5df41e5fa483ad5990296421cde808a0d29f36f/src/Ulrichsg/Getopt/Getopt.php#L76-L100 |
46,386 | phalapi/cli | src/Ulrichsg/Getopt/Getopt.php | Getopt.parse | public function parse($arguments = null)
{
$this->options = array();
if (!isset($arguments)) {
global $argv;
$arguments = $argv;
$this->scriptName = array_shift($arguments); // $argv[0] is the script's name
} elseif (is_string($arguments)) {
$this->scriptName = $_SERVER['PHP_SELF'];
$arguments = explode(' ', $arguments);
}
$parser = new CommandLineParser($this->optionList);
$parser->parse($arguments);
$this->options = $parser->getOptions();
$this->operands = $parser->getOperands();
} | php | public function parse($arguments = null)
{
$this->options = array();
if (!isset($arguments)) {
global $argv;
$arguments = $argv;
$this->scriptName = array_shift($arguments); // $argv[0] is the script's name
} elseif (is_string($arguments)) {
$this->scriptName = $_SERVER['PHP_SELF'];
$arguments = explode(' ', $arguments);
}
$parser = new CommandLineParser($this->optionList);
$parser->parse($arguments);
$this->options = $parser->getOptions();
$this->operands = $parser->getOperands();
} | [
"public",
"function",
"parse",
"(",
"$",
"arguments",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"options",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"arguments",
")",
")",
"{",
"global",
"$",
"argv",
";",
"$",
"arguments",
"... | Evaluate the given arguments. These can be passed either as a string or as an array.
If nothing is passed, the running script's command line arguments are used.
An {@link \UnexpectedValueException} or {@link \InvalidArgumentException} is thrown
when the arguments are not well-formed or do not conform to the options passed by the user.
@param mixed $arguments optional ARGV array or space separated string | [
"Evaluate",
"the",
"given",
"arguments",
".",
"These",
"can",
"be",
"passed",
"either",
"as",
"a",
"string",
"or",
"as",
"an",
"array",
".",
"If",
"nothing",
"is",
"passed",
"the",
"running",
"script",
"s",
"command",
"line",
"arguments",
"are",
"used",
... | c5df41e5fa483ad5990296421cde808a0d29f36f | https://github.com/phalapi/cli/blob/c5df41e5fa483ad5990296421cde808a0d29f36f/src/Ulrichsg/Getopt/Getopt.php#L120-L136 |
46,387 | phalapi/cli | src/Ulrichsg/Getopt/Getopt.php | Getopt.getHelpText | public function getHelpText($padding = 25)
{
$helpText = sprintf($this->getBanner(), $this->scriptName);
$helpText .= "Options:\n";
foreach ($this->optionList as $option) {
$mode = '';
switch ($option->mode()) {
case self::NO_ARGUMENT:
$mode = '';
break;
case self::REQUIRED_ARGUMENT:
$mode = "<".$option->getArgument()->getName().">";
break;
case self::OPTIONAL_ARGUMENT:
$mode = "[<".$option->getArgument()->getName().">]";
break;
}
$short = ($option->short()) ? '-'.$option->short() : '';
$long = ($option->long()) ? '--'.$option->long() : '';
if ($short && $long) {
$options = $short.', '.$long;
} else {
$options = $short ? : $long;
}
$padded = str_pad(sprintf(" %s %s", $options, $mode), $padding);
$helpText .= sprintf("%s %s\n", $padded, $option->getDescription());
}
return $helpText;
} | php | public function getHelpText($padding = 25)
{
$helpText = sprintf($this->getBanner(), $this->scriptName);
$helpText .= "Options:\n";
foreach ($this->optionList as $option) {
$mode = '';
switch ($option->mode()) {
case self::NO_ARGUMENT:
$mode = '';
break;
case self::REQUIRED_ARGUMENT:
$mode = "<".$option->getArgument()->getName().">";
break;
case self::OPTIONAL_ARGUMENT:
$mode = "[<".$option->getArgument()->getName().">]";
break;
}
$short = ($option->short()) ? '-'.$option->short() : '';
$long = ($option->long()) ? '--'.$option->long() : '';
if ($short && $long) {
$options = $short.', '.$long;
} else {
$options = $short ? : $long;
}
$padded = str_pad(sprintf(" %s %s", $options, $mode), $padding);
$helpText .= sprintf("%s %s\n", $padded, $option->getDescription());
}
return $helpText;
} | [
"public",
"function",
"getHelpText",
"(",
"$",
"padding",
"=",
"25",
")",
"{",
"$",
"helpText",
"=",
"sprintf",
"(",
"$",
"this",
"->",
"getBanner",
"(",
")",
",",
"$",
"this",
"->",
"scriptName",
")",
";",
"$",
"helpText",
".=",
"\"Options:\\n\"",
";"... | Returns an usage information text generated from the given options.
@param int $padding Number of characters to pad output of options to
@return string | [
"Returns",
"an",
"usage",
"information",
"text",
"generated",
"from",
"the",
"given",
"options",
"."
] | c5df41e5fa483ad5990296421cde808a0d29f36f | https://github.com/phalapi/cli/blob/c5df41e5fa483ad5990296421cde808a0d29f36f/src/Ulrichsg/Getopt/Getopt.php#L217-L245 |
46,388 | phalapi/cli | src/Ulrichsg/Getopt/OptionParser.php | OptionParser.parseString | public function parseString($string)
{
if (!mb_strlen($string)) {
throw new \InvalidArgumentException('Option string must not be empty');
}
$options = array();
$eol = mb_strlen($string) - 1;
$nextCanBeColon = false;
for ($i = 0; $i <= $eol; ++$i) {
$ch = $string[$i];
if (!preg_match('/^[A-Za-z0-9]$/', $ch)) {
$colon = $nextCanBeColon ? " or ':'" : '';
throw new \InvalidArgumentException("Option string is not well formed: "
."expected a letter$colon, found '$ch' at position ".($i + 1));
}
if ($i == $eol || $string[$i + 1] != ':') {
$options[] = new Option($ch, null, Getopt::NO_ARGUMENT);
$nextCanBeColon = true;
} elseif ($i < $eol - 1 && $string[$i + 2] == ':') {
$options[] = new Option($ch, null, Getopt::OPTIONAL_ARGUMENT);
$i += 2;
$nextCanBeColon = false;
} else {
$options[] = new Option($ch, null, Getopt::REQUIRED_ARGUMENT);
++$i;
$nextCanBeColon = true;
}
}
return $options;
} | php | public function parseString($string)
{
if (!mb_strlen($string)) {
throw new \InvalidArgumentException('Option string must not be empty');
}
$options = array();
$eol = mb_strlen($string) - 1;
$nextCanBeColon = false;
for ($i = 0; $i <= $eol; ++$i) {
$ch = $string[$i];
if (!preg_match('/^[A-Za-z0-9]$/', $ch)) {
$colon = $nextCanBeColon ? " or ':'" : '';
throw new \InvalidArgumentException("Option string is not well formed: "
."expected a letter$colon, found '$ch' at position ".($i + 1));
}
if ($i == $eol || $string[$i + 1] != ':') {
$options[] = new Option($ch, null, Getopt::NO_ARGUMENT);
$nextCanBeColon = true;
} elseif ($i < $eol - 1 && $string[$i + 2] == ':') {
$options[] = new Option($ch, null, Getopt::OPTIONAL_ARGUMENT);
$i += 2;
$nextCanBeColon = false;
} else {
$options[] = new Option($ch, null, Getopt::REQUIRED_ARGUMENT);
++$i;
$nextCanBeColon = true;
}
}
return $options;
} | [
"public",
"function",
"parseString",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"!",
"mb_strlen",
"(",
"$",
"string",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Option string must not be empty'",
")",
";",
"}",
"$",
"options",
"=",... | Parse a GNU-style option string.
@param string $string the option string
@return Option[]
@throws \InvalidArgumentException | [
"Parse",
"a",
"GNU",
"-",
"style",
"option",
"string",
"."
] | c5df41e5fa483ad5990296421cde808a0d29f36f | https://github.com/phalapi/cli/blob/c5df41e5fa483ad5990296421cde808a0d29f36f/src/Ulrichsg/Getopt/OptionParser.php#L28-L57 |
46,389 | phalapi/cli | src/Ulrichsg/Getopt/CommandLineParser.php | CommandLineParser.parse | public function parse($arguments)
{
if (!is_array($arguments)) {
$arguments = explode(' ', $arguments);
}
$operands = array();
$numArgs = count($arguments);
for ($i = 0; $i < $numArgs; ++$i) {
$arg = trim($arguments[$i]);
if (empty($arg)) {
continue;
}
if (($arg === '--') || ($arg === '-') || (mb_substr($arg, 0, 1) !== '-')){
// no more options, treat the remaining arguments as operands
$firstOperandIndex = ($arg == '--') ? $i + 1 : $i;
$operands = array_slice($arguments, $firstOperandIndex);
break;
}
if (mb_substr($arg, 0, 2) == '--') {
$this->addLongOption($arguments, $i);
} else {
$this->addShortOption($arguments, $i);
}
} // endfor
$this->addDefaultValues();
// remove '--' from operands array
foreach ($operands as $operand) {
if ($operand !== '--') {
$this->operands[] = $operand;
}
}
} | php | public function parse($arguments)
{
if (!is_array($arguments)) {
$arguments = explode(' ', $arguments);
}
$operands = array();
$numArgs = count($arguments);
for ($i = 0; $i < $numArgs; ++$i) {
$arg = trim($arguments[$i]);
if (empty($arg)) {
continue;
}
if (($arg === '--') || ($arg === '-') || (mb_substr($arg, 0, 1) !== '-')){
// no more options, treat the remaining arguments as operands
$firstOperandIndex = ($arg == '--') ? $i + 1 : $i;
$operands = array_slice($arguments, $firstOperandIndex);
break;
}
if (mb_substr($arg, 0, 2) == '--') {
$this->addLongOption($arguments, $i);
} else {
$this->addShortOption($arguments, $i);
}
} // endfor
$this->addDefaultValues();
// remove '--' from operands array
foreach ($operands as $operand) {
if ($operand !== '--') {
$this->operands[] = $operand;
}
}
} | [
"public",
"function",
"parse",
"(",
"$",
"arguments",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"arguments",
")",
")",
"{",
"$",
"arguments",
"=",
"explode",
"(",
"' '",
",",
"$",
"arguments",
")",
";",
"}",
"$",
"operands",
"=",
"array",
"("... | Parses the given arguments and converts them into options and operands.
@param mixed $arguments a string or an array with one argument per element | [
"Parses",
"the",
"given",
"arguments",
"and",
"converts",
"them",
"into",
"options",
"and",
"operands",
"."
] | c5df41e5fa483ad5990296421cde808a0d29f36f | https://github.com/phalapi/cli/blob/c5df41e5fa483ad5990296421cde808a0d29f36f/src/Ulrichsg/Getopt/CommandLineParser.php#L31-L64 |
46,390 | phalapi/cli | src/Ulrichsg/Getopt/CommandLineParser.php | CommandLineParser.optionHasArgument | private function optionHasArgument($name)
{
foreach ($this->optionList as $option) {
if ($option->matches($name)) {
return $option->mode() != Getopt::NO_ARGUMENT;
}
}
return false;
} | php | private function optionHasArgument($name)
{
foreach ($this->optionList as $option) {
if ($option->matches($name)) {
return $option->mode() != Getopt::NO_ARGUMENT;
}
}
return false;
} | [
"private",
"function",
"optionHasArgument",
"(",
"$",
"name",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"optionList",
"as",
"$",
"option",
")",
"{",
"if",
"(",
"$",
"option",
"->",
"matches",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"option... | Return true if the given option can take an argument, false if it can't or is unknown.
@param string $name the option's name
@return boolean | [
"Return",
"true",
"if",
"the",
"given",
"option",
"can",
"take",
"an",
"argument",
"false",
"if",
"it",
"can",
"t",
"or",
"is",
"unknown",
"."
] | c5df41e5fa483ad5990296421cde808a0d29f36f | https://github.com/phalapi/cli/blob/c5df41e5fa483ad5990296421cde808a0d29f36f/src/Ulrichsg/Getopt/CommandLineParser.php#L216-L224 |
46,391 | phalapi/cli | src/Ulrichsg/Getopt/CommandLineParser.php | CommandLineParser.splitString | private function splitString($string)
{
$result = array();
for ($i = 0; $i < mb_strlen($string, "UTF-8"); ++$i) {
$result[] = mb_substr($string, $i, 1, "UTF-8");
}
return $result;
} | php | private function splitString($string)
{
$result = array();
for ($i = 0; $i < mb_strlen($string, "UTF-8"); ++$i) {
$result[] = mb_substr($string, $i, 1, "UTF-8");
}
return $result;
} | [
"private",
"function",
"splitString",
"(",
"$",
"string",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"mb_strlen",
"(",
"$",
"string",
",",
"\"UTF-8\"",
")",
";",
"++",
"$",
"i",
")"... | Split the string into individual characters,
@param string $string string to split
@return array | [
"Split",
"the",
"string",
"into",
"individual",
"characters"
] | c5df41e5fa483ad5990296421cde808a0d29f36f | https://github.com/phalapi/cli/blob/c5df41e5fa483ad5990296421cde808a0d29f36f/src/Ulrichsg/Getopt/CommandLineParser.php#L232-L239 |
46,392 | Algatux/influxdb-bundle | src/Form/Type/AbstractInfluxChoiceType.php | AbstractInfluxChoiceType.loadChoicesFromQuery | final protected function loadChoicesFromQuery(string $query, string $columnName, string $connectionName = null)
{
$connection = $connectionName
? $this->connectionRegistry->getHttpConnection($connectionName)
: $this->connectionRegistry->getDefaultHttpConnection()
;
$measurements = array_map(function ($point) use ($columnName) {
return $point[$columnName];
}, $connection->query($query)->getPoints());
return array_combine(array_values($measurements), $measurements);
} | php | final protected function loadChoicesFromQuery(string $query, string $columnName, string $connectionName = null)
{
$connection = $connectionName
? $this->connectionRegistry->getHttpConnection($connectionName)
: $this->connectionRegistry->getDefaultHttpConnection()
;
$measurements = array_map(function ($point) use ($columnName) {
return $point[$columnName];
}, $connection->query($query)->getPoints());
return array_combine(array_values($measurements), $measurements);
} | [
"final",
"protected",
"function",
"loadChoicesFromQuery",
"(",
"string",
"$",
"query",
",",
"string",
"$",
"columnName",
",",
"string",
"$",
"connectionName",
"=",
"null",
")",
"{",
"$",
"connection",
"=",
"$",
"connectionName",
"?",
"$",
"this",
"->",
"conn... | Executes the given query and converts the result to a proper choices list.
@param string $query
@param string $columnName
@param string|null $connectionName
@return array | [
"Executes",
"the",
"given",
"query",
"and",
"converts",
"the",
"result",
"to",
"a",
"proper",
"choices",
"list",
"."
] | 0945dbf0f5345d26897a99ea074e8f656ed49811 | https://github.com/Algatux/influxdb-bundle/blob/0945dbf0f5345d26897a99ea074e8f656ed49811/src/Form/Type/AbstractInfluxChoiceType.php#L65-L76 |
46,393 | snowcap/SnowcapImBundle | Twig/Extension/ImExtension.php | ImExtension.convert | public function convert($html)
{
preg_match_all('|<img ([^>]+)>|', $html, $matches);
foreach($matches[0] as $img)
{
$crawler = new Crawler();
$crawler->addContent($img);
$imgTag = $crawler->filter("img");
$src = $imgTag->attr('src');
$width = $imgTag->attr('width');
$height = $imgTag->attr('height');
if (!empty($width) || !empty($height)) {
$format = $width . "x" . $height;
$updatedTagString = preg_replace("| src=[\"']" . $src . "[\"']|", " src=\"" . $this->imResize($src, $format) . "\"", $img);
$html = str_replace($img, $updatedTagString, $html);
}
}
return $html;
} | php | public function convert($html)
{
preg_match_all('|<img ([^>]+)>|', $html, $matches);
foreach($matches[0] as $img)
{
$crawler = new Crawler();
$crawler->addContent($img);
$imgTag = $crawler->filter("img");
$src = $imgTag->attr('src');
$width = $imgTag->attr('width');
$height = $imgTag->attr('height');
if (!empty($width) || !empty($height)) {
$format = $width . "x" . $height;
$updatedTagString = preg_replace("| src=[\"']" . $src . "[\"']|", " src=\"" . $this->imResize($src, $format) . "\"", $img);
$html = str_replace($img, $updatedTagString, $html);
}
}
return $html;
} | [
"public",
"function",
"convert",
"(",
"$",
"html",
")",
"{",
"preg_match_all",
"(",
"'|<img ([^>]+)>|'",
",",
"$",
"html",
",",
"$",
"matches",
")",
";",
"foreach",
"(",
"$",
"matches",
"[",
"0",
"]",
"as",
"$",
"img",
")",
"{",
"$",
"crawler",
"=",
... | Called by the compile method to replace the image sources with image cache sources
@param string $html
@return string | [
"Called",
"by",
"the",
"compile",
"method",
"to",
"replace",
"the",
"image",
"sources",
"with",
"image",
"cache",
"sources"
] | 2a15913b371e4b7d45d03a79c7decb620cce9c64 | https://github.com/snowcap/SnowcapImBundle/blob/2a15913b371e4b7d45d03a79c7decb620cce9c64/Twig/Extension/ImExtension.php#L78-L100 |
46,394 | snowcap/SnowcapImBundle | Twig/Extension/ImExtension.php | ImExtension.imResize | public function imResize($path, $format)
{
// Remove extra whitespaces
$path = trim($path);
$separator = "";
// Transform absolute url to custom url like : http/ or https/ or simply /
if (strpos($path, "http://") === 0 || strpos($path, "https://") === 0 || strpos($path, "//") === 0) {
$path = str_replace(array("://", "//"), "/", $path);
} elseif (strpos($path, "/") === 0) {
// If the path started with a slash, we will add it at the start of the path result
$separator = "/";
}
// Remove the first slash, as we add it manually
$path = ltrim($path, '/');
return $separator . $this->manager->getCachePath() . '/' . $format . '/' . $path;
} | php | public function imResize($path, $format)
{
// Remove extra whitespaces
$path = trim($path);
$separator = "";
// Transform absolute url to custom url like : http/ or https/ or simply /
if (strpos($path, "http://") === 0 || strpos($path, "https://") === 0 || strpos($path, "//") === 0) {
$path = str_replace(array("://", "//"), "/", $path);
} elseif (strpos($path, "/") === 0) {
// If the path started with a slash, we will add it at the start of the path result
$separator = "/";
}
// Remove the first slash, as we add it manually
$path = ltrim($path, '/');
return $separator . $this->manager->getCachePath() . '/' . $format . '/' . $path;
} | [
"public",
"function",
"imResize",
"(",
"$",
"path",
",",
"$",
"format",
")",
"{",
"// Remove extra whitespaces",
"$",
"path",
"=",
"trim",
"(",
"$",
"path",
")",
";",
"$",
"separator",
"=",
"\"\"",
";",
"// Transform absolute url to custom url like : http/ or http... | Returns the cached path, after executing the asset twig function
@param string $path Path of the source file
@param string $format Imbundle format string
@return mixed | [
"Returns",
"the",
"cached",
"path",
"after",
"executing",
"the",
"asset",
"twig",
"function"
] | 2a15913b371e4b7d45d03a79c7decb620cce9c64 | https://github.com/snowcap/SnowcapImBundle/blob/2a15913b371e4b7d45d03a79c7decb620cce9c64/Twig/Extension/ImExtension.php#L110-L128 |
46,395 | snowcap/SnowcapImBundle | Manager.php | Manager.convert | public function convert($format, $file)
{
$file = ltrim($file, '/');
$this->checkImage($file);
return $this->wrapper->run("convert", $this->getWebDirectory() . '/' . $file, $this->convertFormat($format), $this->getCacheDirectory() . '/' . $this->pathify($format) . '/' . $file);
} | php | public function convert($format, $file)
{
$file = ltrim($file, '/');
$this->checkImage($file);
return $this->wrapper->run("convert", $this->getWebDirectory() . '/' . $file, $this->convertFormat($format), $this->getCacheDirectory() . '/' . $this->pathify($format) . '/' . $file);
} | [
"public",
"function",
"convert",
"(",
"$",
"format",
",",
"$",
"file",
")",
"{",
"$",
"file",
"=",
"ltrim",
"(",
"$",
"file",
",",
"'/'",
")",
";",
"$",
"this",
"->",
"checkImage",
"(",
"$",
"file",
")",
";",
"return",
"$",
"this",
"->",
"wrapper... | Shortcut to run a "convert" command => creates a new image
@param string $format ImBundle format string
@param string $file Source file path
@return string
@codeCoverageIgnore | [
"Shortcut",
"to",
"run",
"a",
"convert",
"command",
"=",
">",
"creates",
"a",
"new",
"image"
] | 2a15913b371e4b7d45d03a79c7decb620cce9c64 | https://github.com/snowcap/SnowcapImBundle/blob/2a15913b371e4b7d45d03a79c7decb620cce9c64/Manager.php#L188-L194 |
46,396 | snowcap/SnowcapImBundle | Manager.php | Manager.mogrify | public function mogrify($format, $file)
{
$this->checkImage($file);
return $this->wrapper->run("mogrify", $file, $this->convertFormat($format));
} | php | public function mogrify($format, $file)
{
$this->checkImage($file);
return $this->wrapper->run("mogrify", $file, $this->convertFormat($format));
} | [
"public",
"function",
"mogrify",
"(",
"$",
"format",
",",
"$",
"file",
")",
"{",
"$",
"this",
"->",
"checkImage",
"(",
"$",
"file",
")",
";",
"return",
"$",
"this",
"->",
"wrapper",
"->",
"run",
"(",
"\"mogrify\"",
",",
"$",
"file",
",",
"$",
"this... | Shortcut to run a "mogrify" command => modifies the image source
@param string $format ImBundle format string
@param string $file Source file path
@return string
@codeCoverageIgnore | [
"Shortcut",
"to",
"run",
"a",
"mogrify",
"command",
"=",
">",
"modifies",
"the",
"image",
"source"
] | 2a15913b371e4b7d45d03a79c7decb620cce9c64 | https://github.com/snowcap/SnowcapImBundle/blob/2a15913b371e4b7d45d03a79c7decb620cce9c64/Manager.php#L205-L210 |
46,397 | snowcap/SnowcapImBundle | Manager.php | Manager.convertFormat | private function convertFormat($format)
{
if (is_array($format)) {
// sounds like the format is already done, let's keep it as it is
return $format;
}
if (array_key_exists($format, $this->formats)) {
// it's a format defined in config, let's use all defined parameters
return $this->formats[$format];
} elseif (preg_match("/^([0-9]*)x([0-9]*)/", $format)) {
// it's a custom [width]x[height] format, let's make a thumb
return array('thumbnail' => $format);
} else {
throw new InvalidArgumentException(sprintf("Unknown IM format: %s", $format));
}
} | php | private function convertFormat($format)
{
if (is_array($format)) {
// sounds like the format is already done, let's keep it as it is
return $format;
}
if (array_key_exists($format, $this->formats)) {
// it's a format defined in config, let's use all defined parameters
return $this->formats[$format];
} elseif (preg_match("/^([0-9]*)x([0-9]*)/", $format)) {
// it's a custom [width]x[height] format, let's make a thumb
return array('thumbnail' => $format);
} else {
throw new InvalidArgumentException(sprintf("Unknown IM format: %s", $format));
}
} | [
"private",
"function",
"convertFormat",
"(",
"$",
"format",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"format",
")",
")",
"{",
"// sounds like the format is already done, let's keep it as it is",
"return",
"$",
"format",
";",
"}",
"if",
"(",
"array_key_exists",
"... | Returns the attributes for converting the image regarding a specific format
@param string $format
@return array
@throws InvalidArgumentException | [
"Returns",
"the",
"attributes",
"for",
"converting",
"the",
"image",
"regarding",
"a",
"specific",
"format"
] | 2a15913b371e4b7d45d03a79c7decb620cce9c64 | https://github.com/snowcap/SnowcapImBundle/blob/2a15913b371e4b7d45d03a79c7decb620cce9c64/Manager.php#L250-L265 |
46,398 | snowcap/SnowcapImBundle | Wrapper.php | Wrapper.run | public function run($command, $inputfile, $attributes = array(), $outputfile = "")
{
$commandString = $this->buildCommand($command, $inputfile, $attributes, $outputfile);
return $this->rawRun($commandString);
} | php | public function run($command, $inputfile, $attributes = array(), $outputfile = "")
{
$commandString = $this->buildCommand($command, $inputfile, $attributes, $outputfile);
return $this->rawRun($commandString);
} | [
"public",
"function",
"run",
"(",
"$",
"command",
",",
"$",
"inputfile",
",",
"$",
"attributes",
"=",
"array",
"(",
")",
",",
"$",
"outputfile",
"=",
"\"\"",
")",
"{",
"$",
"commandString",
"=",
"$",
"this",
"->",
"buildCommand",
"(",
"$",
"command",
... | Shortcut to construct & run an Imagemagick command
@param string $command @see _self::buildCommand
@param string $inputfile @see _self::buildCommand
@param array $attributes @see _self::buildCommand
@param string $outputfile @see _self::buildCommand
@return string
@codeCoverageIgnore | [
"Shortcut",
"to",
"construct",
"&",
"run",
"an",
"Imagemagick",
"command"
] | 2a15913b371e4b7d45d03a79c7decb620cce9c64 | https://github.com/snowcap/SnowcapImBundle/blob/2a15913b371e4b7d45d03a79c7decb620cce9c64/Wrapper.php#L67-L72 |
46,399 | snowcap/SnowcapImBundle | Wrapper.php | Wrapper.prepareAttributes | private function prepareAttributes($attributes = array())
{
if (!is_array($attributes)) {
throw new InvalidArgumentException("[ImBundle] format attributes must be an array, recieved: " . var_export($attributes, true));
}
$result = "";
foreach ($attributes as $key => $value) {
if ($key === null || $key === "") {
$result .= " " . $value;
} else {
$result .= " -" . $key;
if ($value != "") {
$result .= " \"" . $value . "\"";
}
}
}
return $result;
} | php | private function prepareAttributes($attributes = array())
{
if (!is_array($attributes)) {
throw new InvalidArgumentException("[ImBundle] format attributes must be an array, recieved: " . var_export($attributes, true));
}
$result = "";
foreach ($attributes as $key => $value) {
if ($key === null || $key === "") {
$result .= " " . $value;
} else {
$result .= " -" . $key;
if ($value != "") {
$result .= " \"" . $value . "\"";
}
}
}
return $result;
} | [
"private",
"function",
"prepareAttributes",
"(",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"attributes",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"[ImBundle] format attributes must be an arr... | Takes an array of attributes and formats it as CLI parameters
@param array $attributes
@return string
@throws InvalidArgumentException | [
"Takes",
"an",
"array",
"of",
"attributes",
"and",
"formats",
"it",
"as",
"CLI",
"parameters"
] | 2a15913b371e4b7d45d03a79c7decb620cce9c64 | https://github.com/snowcap/SnowcapImBundle/blob/2a15913b371e4b7d45d03a79c7decb620cce9c64/Wrapper.php#L134-L152 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.