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
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
5,400 | bishopb/vanilla | applications/dashboard/controllers/class.profilecontroller.php | ProfileController.NoMobile | public function NoMobile($Unset = 0) {
if ($Unset == 1) {
// Allow mobile again
Gdn_CookieIdentity::DeleteCookie('VanillaNoMobile');
}
else {
// Set 48-hour "no mobile" cookie
$Expiration = time() + 172800;
$Expire = 0;
$UserID = ((Gdn::Session()->IsValid()) ? Gdn::Session()->UserID : 0);
$KeyData = $UserID."-{$Expiration}";
Gdn_CookieIdentity::SetCookie('VanillaNoMobile', $KeyData, array($UserID, $Expiration, 'force'), $Expire);
}
Redirect("/", 302);
} | php | public function NoMobile($Unset = 0) {
if ($Unset == 1) {
// Allow mobile again
Gdn_CookieIdentity::DeleteCookie('VanillaNoMobile');
}
else {
// Set 48-hour "no mobile" cookie
$Expiration = time() + 172800;
$Expire = 0;
$UserID = ((Gdn::Session()->IsValid()) ? Gdn::Session()->UserID : 0);
$KeyData = $UserID."-{$Expiration}";
Gdn_CookieIdentity::SetCookie('VanillaNoMobile', $KeyData, array($UserID, $Expiration, 'force'), $Expire);
}
Redirect("/", 302);
} | [
"public",
"function",
"NoMobile",
"(",
"$",
"Unset",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"Unset",
"==",
"1",
")",
"{",
"// Allow mobile again",
"Gdn_CookieIdentity",
"::",
"DeleteCookie",
"(",
"'VanillaNoMobile'",
")",
";",
"}",
"else",
"{",
"// Set 48-hour \"no mobile\" cookie",
"$",
"Expiration",
"=",
"time",
"(",
")",
"+",
"172800",
";",
"$",
"Expire",
"=",
"0",
";",
"$",
"UserID",
"=",
"(",
"(",
"Gdn",
"::",
"Session",
"(",
")",
"->",
"IsValid",
"(",
")",
")",
"?",
"Gdn",
"::",
"Session",
"(",
")",
"->",
"UserID",
":",
"0",
")",
";",
"$",
"KeyData",
"=",
"$",
"UserID",
".",
"\"-{$Expiration}\"",
";",
"Gdn_CookieIdentity",
"::",
"SetCookie",
"(",
"'VanillaNoMobile'",
",",
"$",
"KeyData",
",",
"array",
"(",
"$",
"UserID",
",",
"$",
"Expiration",
",",
"'force'",
")",
",",
"$",
"Expire",
")",
";",
"}",
"Redirect",
"(",
"\"/\"",
",",
"302",
")",
";",
"}"
] | Set 'NoMobile' cookie for current user to prevent use of mobile theme.
@since 2.0.?
@access public | [
"Set",
"NoMobile",
"cookie",
"for",
"current",
"user",
"to",
"prevent",
"use",
"of",
"mobile",
"theme",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.profilecontroller.php#L482-L497 |
5,401 | bishopb/vanilla | applications/dashboard/controllers/class.profilecontroller.php | ProfileController.Notifications | public function Notifications($Page = FALSE) {
$this->Permission('Garden.SignIn.Allow');
$this->EditMode(FALSE);
list($Offset, $Limit) = OffsetLimit($Page, 30);
$this->GetUserInfo();
$this->_SetBreadcrumbs(T('Notifications'), '/profile/notifications');
$this->SetTabView('Notifications');
$Session = Gdn::Session();
$this->ActivityModel = new ActivityModel();
// Drop notification count back to zero.
$this->ActivityModel->MarkRead($Session->UserID);
// Get notifications data.
$Activities = $this->ActivityModel->GetNotifications($Session->UserID, $Offset, $Limit)->ResultArray();
$this->ActivityModel->JoinComments($Activities);
$this->SetData('Activities', $Activities);
unset($Activities);
//$TotalRecords = $this->ActivityModel->GetCountNotifications($Session->UserID);
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$this->Pager = $PagerFactory->GetPager('MorePager', $this);
$this->Pager->MoreCode = 'More';
$this->Pager->LessCode = 'Newer Notifications';
$this->Pager->ClientID = 'Pager';
$this->Pager->Configure(
$Offset,
$Limit,
FALSE,
'profile/notifications/%1$s/'
);
// Deliver json data if necessary
if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
$this->SetJson('LessRow', $this->Pager->ToString('less'));
$this->SetJson('MoreRow', $this->Pager->ToString('more'));
if ($Offset > 0) {
$this->View = 'activities';
$this->ControllerName = 'Activity';
}
}
$this->Render();
} | php | public function Notifications($Page = FALSE) {
$this->Permission('Garden.SignIn.Allow');
$this->EditMode(FALSE);
list($Offset, $Limit) = OffsetLimit($Page, 30);
$this->GetUserInfo();
$this->_SetBreadcrumbs(T('Notifications'), '/profile/notifications');
$this->SetTabView('Notifications');
$Session = Gdn::Session();
$this->ActivityModel = new ActivityModel();
// Drop notification count back to zero.
$this->ActivityModel->MarkRead($Session->UserID);
// Get notifications data.
$Activities = $this->ActivityModel->GetNotifications($Session->UserID, $Offset, $Limit)->ResultArray();
$this->ActivityModel->JoinComments($Activities);
$this->SetData('Activities', $Activities);
unset($Activities);
//$TotalRecords = $this->ActivityModel->GetCountNotifications($Session->UserID);
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$this->Pager = $PagerFactory->GetPager('MorePager', $this);
$this->Pager->MoreCode = 'More';
$this->Pager->LessCode = 'Newer Notifications';
$this->Pager->ClientID = 'Pager';
$this->Pager->Configure(
$Offset,
$Limit,
FALSE,
'profile/notifications/%1$s/'
);
// Deliver json data if necessary
if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
$this->SetJson('LessRow', $this->Pager->ToString('less'));
$this->SetJson('MoreRow', $this->Pager->ToString('more'));
if ($Offset > 0) {
$this->View = 'activities';
$this->ControllerName = 'Activity';
}
}
$this->Render();
} | [
"public",
"function",
"Notifications",
"(",
"$",
"Page",
"=",
"FALSE",
")",
"{",
"$",
"this",
"->",
"Permission",
"(",
"'Garden.SignIn.Allow'",
")",
";",
"$",
"this",
"->",
"EditMode",
"(",
"FALSE",
")",
";",
"list",
"(",
"$",
"Offset",
",",
"$",
"Limit",
")",
"=",
"OffsetLimit",
"(",
"$",
"Page",
",",
"30",
")",
";",
"$",
"this",
"->",
"GetUserInfo",
"(",
")",
";",
"$",
"this",
"->",
"_SetBreadcrumbs",
"(",
"T",
"(",
"'Notifications'",
")",
",",
"'/profile/notifications'",
")",
";",
"$",
"this",
"->",
"SetTabView",
"(",
"'Notifications'",
")",
";",
"$",
"Session",
"=",
"Gdn",
"::",
"Session",
"(",
")",
";",
"$",
"this",
"->",
"ActivityModel",
"=",
"new",
"ActivityModel",
"(",
")",
";",
"// Drop notification count back to zero.",
"$",
"this",
"->",
"ActivityModel",
"->",
"MarkRead",
"(",
"$",
"Session",
"->",
"UserID",
")",
";",
"// Get notifications data.",
"$",
"Activities",
"=",
"$",
"this",
"->",
"ActivityModel",
"->",
"GetNotifications",
"(",
"$",
"Session",
"->",
"UserID",
",",
"$",
"Offset",
",",
"$",
"Limit",
")",
"->",
"ResultArray",
"(",
")",
";",
"$",
"this",
"->",
"ActivityModel",
"->",
"JoinComments",
"(",
"$",
"Activities",
")",
";",
"$",
"this",
"->",
"SetData",
"(",
"'Activities'",
",",
"$",
"Activities",
")",
";",
"unset",
"(",
"$",
"Activities",
")",
";",
"//$TotalRecords = $this->ActivityModel->GetCountNotifications($Session->UserID);",
"// Build a pager",
"$",
"PagerFactory",
"=",
"new",
"Gdn_PagerFactory",
"(",
")",
";",
"$",
"this",
"->",
"Pager",
"=",
"$",
"PagerFactory",
"->",
"GetPager",
"(",
"'MorePager'",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"Pager",
"->",
"MoreCode",
"=",
"'More'",
";",
"$",
"this",
"->",
"Pager",
"->",
"LessCode",
"=",
"'Newer Notifications'",
";",
"$",
"this",
"->",
"Pager",
"->",
"ClientID",
"=",
"'Pager'",
";",
"$",
"this",
"->",
"Pager",
"->",
"Configure",
"(",
"$",
"Offset",
",",
"$",
"Limit",
",",
"FALSE",
",",
"'profile/notifications/%1$s/'",
")",
";",
"// Deliver json data if necessary",
"if",
"(",
"$",
"this",
"->",
"_DeliveryType",
"!=",
"DELIVERY_TYPE_ALL",
")",
"{",
"$",
"this",
"->",
"SetJson",
"(",
"'LessRow'",
",",
"$",
"this",
"->",
"Pager",
"->",
"ToString",
"(",
"'less'",
")",
")",
";",
"$",
"this",
"->",
"SetJson",
"(",
"'MoreRow'",
",",
"$",
"this",
"->",
"Pager",
"->",
"ToString",
"(",
"'more'",
")",
")",
";",
"if",
"(",
"$",
"Offset",
">",
"0",
")",
"{",
"$",
"this",
"->",
"View",
"=",
"'activities'",
";",
"$",
"this",
"->",
"ControllerName",
"=",
"'Activity'",
";",
"}",
"}",
"$",
"this",
"->",
"Render",
"(",
")",
";",
"}"
] | Show notifications for current user.
@since 2.0.0
@access public
@param int $Page Number to skip (paging). | [
"Show",
"notifications",
"for",
"current",
"user",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.profilecontroller.php#L506-L552 |
5,402 | bishopb/vanilla | applications/dashboard/controllers/class.profilecontroller.php | ProfileController.Password | public function Password() {
$this->Permission('Garden.SignIn.Allow');
// Don't allow password editing if using SSO Connect ONLY.
// This is for security. We encountered the case where a customer charges
// for membership using their external application and use SSO to let
// their customers into Vanilla. If you allow those people to change their
// password in Vanilla, they will then be able to log into Vanilla using
// Vanilla's login form regardless of the state of their membership in the
// external app.
if (C('Garden.Registration.Method') == 'Connect') {
Gdn::Dispatcher()->Dispatch('DefaultPermission');
exit();
}
Gdn::UserModel()->AddPasswordStrength($this);
// Get user data and set up form
$this->GetUserInfo();
$this->Form->SetModel($this->UserModel);
$this->Form->AddHidden('UserID', $this->User->UserID);
$this->AddDefinition('Username', $this->User->Name);
if ($this->Form->AuthenticatedPostBack() === TRUE) {
$this->UserModel->DefineSchema();
// $this->UserModel->Validation->AddValidationField('OldPassword', $this->Form->FormValues());
// No password may have been set if they have only signed in with a connect plugin
if (!$this->User->HashMethod || $this->User->HashMethod == "Vanilla") {
$this->UserModel->Validation->ApplyRule('OldPassword', 'Required');
$this->UserModel->Validation->ApplyRule('OldPassword', 'OldPassword', 'Your old password was incorrect.');
}
$this->UserModel->Validation->ApplyRule('Password', 'Required');
$this->UserModel->Validation->ApplyRule('Password', 'Strength');
$this->UserModel->Validation->ApplyRule('Password', 'Match');
if ($this->Form->Save()) {
$this->InformMessage(Sprite('Check', 'InformSprite').T('Your password has been changed.'), 'Dismissable AutoDismiss HasSprite');
$this->Form->ClearInputs();
}
}
$this->Title(T('Change My Password'));
$this->_SetBreadcrumbs(T('Change My Password'), '/profile/password');
$this->Render();
} | php | public function Password() {
$this->Permission('Garden.SignIn.Allow');
// Don't allow password editing if using SSO Connect ONLY.
// This is for security. We encountered the case where a customer charges
// for membership using their external application and use SSO to let
// their customers into Vanilla. If you allow those people to change their
// password in Vanilla, they will then be able to log into Vanilla using
// Vanilla's login form regardless of the state of their membership in the
// external app.
if (C('Garden.Registration.Method') == 'Connect') {
Gdn::Dispatcher()->Dispatch('DefaultPermission');
exit();
}
Gdn::UserModel()->AddPasswordStrength($this);
// Get user data and set up form
$this->GetUserInfo();
$this->Form->SetModel($this->UserModel);
$this->Form->AddHidden('UserID', $this->User->UserID);
$this->AddDefinition('Username', $this->User->Name);
if ($this->Form->AuthenticatedPostBack() === TRUE) {
$this->UserModel->DefineSchema();
// $this->UserModel->Validation->AddValidationField('OldPassword', $this->Form->FormValues());
// No password may have been set if they have only signed in with a connect plugin
if (!$this->User->HashMethod || $this->User->HashMethod == "Vanilla") {
$this->UserModel->Validation->ApplyRule('OldPassword', 'Required');
$this->UserModel->Validation->ApplyRule('OldPassword', 'OldPassword', 'Your old password was incorrect.');
}
$this->UserModel->Validation->ApplyRule('Password', 'Required');
$this->UserModel->Validation->ApplyRule('Password', 'Strength');
$this->UserModel->Validation->ApplyRule('Password', 'Match');
if ($this->Form->Save()) {
$this->InformMessage(Sprite('Check', 'InformSprite').T('Your password has been changed.'), 'Dismissable AutoDismiss HasSprite');
$this->Form->ClearInputs();
}
}
$this->Title(T('Change My Password'));
$this->_SetBreadcrumbs(T('Change My Password'), '/profile/password');
$this->Render();
} | [
"public",
"function",
"Password",
"(",
")",
"{",
"$",
"this",
"->",
"Permission",
"(",
"'Garden.SignIn.Allow'",
")",
";",
"// Don't allow password editing if using SSO Connect ONLY. ",
"// This is for security. We encountered the case where a customer charges ",
"// for membership using their external application and use SSO to let ",
"// their customers into Vanilla. If you allow those people to change their ",
"// password in Vanilla, they will then be able to log into Vanilla using ",
"// Vanilla's login form regardless of the state of their membership in the ",
"// external app.",
"if",
"(",
"C",
"(",
"'Garden.Registration.Method'",
")",
"==",
"'Connect'",
")",
"{",
"Gdn",
"::",
"Dispatcher",
"(",
")",
"->",
"Dispatch",
"(",
"'DefaultPermission'",
")",
";",
"exit",
"(",
")",
";",
"}",
"Gdn",
"::",
"UserModel",
"(",
")",
"->",
"AddPasswordStrength",
"(",
"$",
"this",
")",
";",
"// Get user data and set up form",
"$",
"this",
"->",
"GetUserInfo",
"(",
")",
";",
"$",
"this",
"->",
"Form",
"->",
"SetModel",
"(",
"$",
"this",
"->",
"UserModel",
")",
";",
"$",
"this",
"->",
"Form",
"->",
"AddHidden",
"(",
"'UserID'",
",",
"$",
"this",
"->",
"User",
"->",
"UserID",
")",
";",
"$",
"this",
"->",
"AddDefinition",
"(",
"'Username'",
",",
"$",
"this",
"->",
"User",
"->",
"Name",
")",
";",
"if",
"(",
"$",
"this",
"->",
"Form",
"->",
"AuthenticatedPostBack",
"(",
")",
"===",
"TRUE",
")",
"{",
"$",
"this",
"->",
"UserModel",
"->",
"DefineSchema",
"(",
")",
";",
"// $this->UserModel->Validation->AddValidationField('OldPassword', $this->Form->FormValues());",
"// No password may have been set if they have only signed in with a connect plugin",
"if",
"(",
"!",
"$",
"this",
"->",
"User",
"->",
"HashMethod",
"||",
"$",
"this",
"->",
"User",
"->",
"HashMethod",
"==",
"\"Vanilla\"",
")",
"{",
"$",
"this",
"->",
"UserModel",
"->",
"Validation",
"->",
"ApplyRule",
"(",
"'OldPassword'",
",",
"'Required'",
")",
";",
"$",
"this",
"->",
"UserModel",
"->",
"Validation",
"->",
"ApplyRule",
"(",
"'OldPassword'",
",",
"'OldPassword'",
",",
"'Your old password was incorrect.'",
")",
";",
"}",
"$",
"this",
"->",
"UserModel",
"->",
"Validation",
"->",
"ApplyRule",
"(",
"'Password'",
",",
"'Required'",
")",
";",
"$",
"this",
"->",
"UserModel",
"->",
"Validation",
"->",
"ApplyRule",
"(",
"'Password'",
",",
"'Strength'",
")",
";",
"$",
"this",
"->",
"UserModel",
"->",
"Validation",
"->",
"ApplyRule",
"(",
"'Password'",
",",
"'Match'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"Form",
"->",
"Save",
"(",
")",
")",
"{",
"$",
"this",
"->",
"InformMessage",
"(",
"Sprite",
"(",
"'Check'",
",",
"'InformSprite'",
")",
".",
"T",
"(",
"'Your password has been changed.'",
")",
",",
"'Dismissable AutoDismiss HasSprite'",
")",
";",
"$",
"this",
"->",
"Form",
"->",
"ClearInputs",
"(",
")",
";",
"}",
"}",
"$",
"this",
"->",
"Title",
"(",
"T",
"(",
"'Change My Password'",
")",
")",
";",
"$",
"this",
"->",
"_SetBreadcrumbs",
"(",
"T",
"(",
"'Change My Password'",
")",
",",
"'/profile/password'",
")",
";",
"$",
"this",
"->",
"Render",
"(",
")",
";",
"}"
] | Set new password for current user.
@since 2.0.0
@access public | [
"Set",
"new",
"password",
"for",
"current",
"user",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.profilecontroller.php#L577-L623 |
5,403 | bishopb/vanilla | applications/dashboard/controllers/class.profilecontroller.php | ProfileController.Preference | public function Preference($Key = FALSE) {
$this->Permission('Garden.SignIn.Allow');
$this->Form->InputPrefix = '';
if ($this->Form->IsPostBack()) {
$Data = $this->Form->FormValues();
Gdn::UserModel()->SavePreference(Gdn::Session()->UserID, $Data);
} else {
$User = Gdn::UserModel()->GetID(Gdn::Session()->UserID, DATASET_TYPE_ARRAY);
$Pref = GetValueR($Key, $User['Preferences'], NULL);
$this->SetData($Key, $Pref);
}
$this->Render('Blank', 'Utility');
} | php | public function Preference($Key = FALSE) {
$this->Permission('Garden.SignIn.Allow');
$this->Form->InputPrefix = '';
if ($this->Form->IsPostBack()) {
$Data = $this->Form->FormValues();
Gdn::UserModel()->SavePreference(Gdn::Session()->UserID, $Data);
} else {
$User = Gdn::UserModel()->GetID(Gdn::Session()->UserID, DATASET_TYPE_ARRAY);
$Pref = GetValueR($Key, $User['Preferences'], NULL);
$this->SetData($Key, $Pref);
}
$this->Render('Blank', 'Utility');
} | [
"public",
"function",
"Preference",
"(",
"$",
"Key",
"=",
"FALSE",
")",
"{",
"$",
"this",
"->",
"Permission",
"(",
"'Garden.SignIn.Allow'",
")",
";",
"$",
"this",
"->",
"Form",
"->",
"InputPrefix",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"Form",
"->",
"IsPostBack",
"(",
")",
")",
"{",
"$",
"Data",
"=",
"$",
"this",
"->",
"Form",
"->",
"FormValues",
"(",
")",
";",
"Gdn",
"::",
"UserModel",
"(",
")",
"->",
"SavePreference",
"(",
"Gdn",
"::",
"Session",
"(",
")",
"->",
"UserID",
",",
"$",
"Data",
")",
";",
"}",
"else",
"{",
"$",
"User",
"=",
"Gdn",
"::",
"UserModel",
"(",
")",
"->",
"GetID",
"(",
"Gdn",
"::",
"Session",
"(",
")",
"->",
"UserID",
",",
"DATASET_TYPE_ARRAY",
")",
";",
"$",
"Pref",
"=",
"GetValueR",
"(",
"$",
"Key",
",",
"$",
"User",
"[",
"'Preferences'",
"]",
",",
"NULL",
")",
";",
"$",
"this",
"->",
"SetData",
"(",
"$",
"Key",
",",
"$",
"Pref",
")",
";",
"}",
"$",
"this",
"->",
"Render",
"(",
"'Blank'",
",",
"'Utility'",
")",
";",
"}"
] | Gets or sets a user's preference. This method is meant for ajax calls.
@since 2.1
@param string $Key The name of the preference. | [
"Gets",
"or",
"sets",
"a",
"user",
"s",
"preference",
".",
"This",
"method",
"is",
"meant",
"for",
"ajax",
"calls",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.profilecontroller.php#L733-L749 |
5,404 | bishopb/vanilla | applications/dashboard/controllers/class.profilecontroller.php | ProfileController.RemovePicture | public function RemovePicture($UserReference = '', $Username = '', $TransientKey = '') {
$this->Permission('Garden.SignIn.Allow');
$Session = Gdn::Session();
if (!$Session->IsValid())
$this->Form->AddError('You must be authenticated in order to use this form.');
// Get user data & another permission check
$this->GetUserInfo($UserReference, $Username, '', TRUE);
$RedirectUrl = UserUrl($this->User, '', 'picture');
if ($Session->ValidateTransientKey($TransientKey)
&& is_object($this->User)
&& (
$this->User->UserID == $Session->UserID
|| $Session->CheckPermission('Garden.Users.Edit')
)
) {
// Do removal, set message, redirect
Gdn::UserModel()->RemovePicture($this->User->UserID);
$this->InformMessage(T('Your picture has been removed.'));
}
if ($this->_DeliveryType == DELIVERY_TYPE_ALL) {
Redirect($RedirectUrl);
} else {
$this->ControllerName = 'Home';
$this->View = 'FileNotFound';
$this->RedirectUrl = Url($RedirectUrl);
$this->Render();
}
} | php | public function RemovePicture($UserReference = '', $Username = '', $TransientKey = '') {
$this->Permission('Garden.SignIn.Allow');
$Session = Gdn::Session();
if (!$Session->IsValid())
$this->Form->AddError('You must be authenticated in order to use this form.');
// Get user data & another permission check
$this->GetUserInfo($UserReference, $Username, '', TRUE);
$RedirectUrl = UserUrl($this->User, '', 'picture');
if ($Session->ValidateTransientKey($TransientKey)
&& is_object($this->User)
&& (
$this->User->UserID == $Session->UserID
|| $Session->CheckPermission('Garden.Users.Edit')
)
) {
// Do removal, set message, redirect
Gdn::UserModel()->RemovePicture($this->User->UserID);
$this->InformMessage(T('Your picture has been removed.'));
}
if ($this->_DeliveryType == DELIVERY_TYPE_ALL) {
Redirect($RedirectUrl);
} else {
$this->ControllerName = 'Home';
$this->View = 'FileNotFound';
$this->RedirectUrl = Url($RedirectUrl);
$this->Render();
}
} | [
"public",
"function",
"RemovePicture",
"(",
"$",
"UserReference",
"=",
"''",
",",
"$",
"Username",
"=",
"''",
",",
"$",
"TransientKey",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"Permission",
"(",
"'Garden.SignIn.Allow'",
")",
";",
"$",
"Session",
"=",
"Gdn",
"::",
"Session",
"(",
")",
";",
"if",
"(",
"!",
"$",
"Session",
"->",
"IsValid",
"(",
")",
")",
"$",
"this",
"->",
"Form",
"->",
"AddError",
"(",
"'You must be authenticated in order to use this form.'",
")",
";",
"// Get user data & another permission check",
"$",
"this",
"->",
"GetUserInfo",
"(",
"$",
"UserReference",
",",
"$",
"Username",
",",
"''",
",",
"TRUE",
")",
";",
"$",
"RedirectUrl",
"=",
"UserUrl",
"(",
"$",
"this",
"->",
"User",
",",
"''",
",",
"'picture'",
")",
";",
"if",
"(",
"$",
"Session",
"->",
"ValidateTransientKey",
"(",
"$",
"TransientKey",
")",
"&&",
"is_object",
"(",
"$",
"this",
"->",
"User",
")",
"&&",
"(",
"$",
"this",
"->",
"User",
"->",
"UserID",
"==",
"$",
"Session",
"->",
"UserID",
"||",
"$",
"Session",
"->",
"CheckPermission",
"(",
"'Garden.Users.Edit'",
")",
")",
")",
"{",
"// Do removal, set message, redirect",
"Gdn",
"::",
"UserModel",
"(",
")",
"->",
"RemovePicture",
"(",
"$",
"this",
"->",
"User",
"->",
"UserID",
")",
";",
"$",
"this",
"->",
"InformMessage",
"(",
"T",
"(",
"'Your picture has been removed.'",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"_DeliveryType",
"==",
"DELIVERY_TYPE_ALL",
")",
"{",
"Redirect",
"(",
"$",
"RedirectUrl",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"ControllerName",
"=",
"'Home'",
";",
"$",
"this",
"->",
"View",
"=",
"'FileNotFound'",
";",
"$",
"this",
"->",
"RedirectUrl",
"=",
"Url",
"(",
"$",
"RedirectUrl",
")",
";",
"$",
"this",
"->",
"Render",
"(",
")",
";",
"}",
"}"
] | Remove the user's photo.
@since 2.0.0
@access public
@param mixed $UserReference Unique identifier, possibly username or ID.
@param string $Username.
@param string $TransientKey Security token. | [
"Remove",
"the",
"user",
"s",
"photo",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.profilecontroller.php#L922-L950 |
5,405 | bishopb/vanilla | applications/dashboard/controllers/class.profilecontroller.php | ProfileController.SendInvite | public function SendInvite($InvitationID = '', $TransientKey = '') {
$this->Permission('Garden.SignIn.Allow');
$InvitationModel = new InvitationModel();
$Session = Gdn::Session();
if ($Session->ValidateTransientKey($TransientKey)) {
try {
$Email = new Gdn_Email();
$InvitationModel->Send($InvitationID, $Email);
} catch (Exception $ex) {
$this->Form->AddError(strip_tags($ex->getMessage()));
}
if ($this->Form->ErrorCount() == 0)
$this->InformMessage(T('The invitation was sent successfully.'));
}
$this->View = 'Invitations';
$this->Invitations();
} | php | public function SendInvite($InvitationID = '', $TransientKey = '') {
$this->Permission('Garden.SignIn.Allow');
$InvitationModel = new InvitationModel();
$Session = Gdn::Session();
if ($Session->ValidateTransientKey($TransientKey)) {
try {
$Email = new Gdn_Email();
$InvitationModel->Send($InvitationID, $Email);
} catch (Exception $ex) {
$this->Form->AddError(strip_tags($ex->getMessage()));
}
if ($this->Form->ErrorCount() == 0)
$this->InformMessage(T('The invitation was sent successfully.'));
}
$this->View = 'Invitations';
$this->Invitations();
} | [
"public",
"function",
"SendInvite",
"(",
"$",
"InvitationID",
"=",
"''",
",",
"$",
"TransientKey",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"Permission",
"(",
"'Garden.SignIn.Allow'",
")",
";",
"$",
"InvitationModel",
"=",
"new",
"InvitationModel",
"(",
")",
";",
"$",
"Session",
"=",
"Gdn",
"::",
"Session",
"(",
")",
";",
"if",
"(",
"$",
"Session",
"->",
"ValidateTransientKey",
"(",
"$",
"TransientKey",
")",
")",
"{",
"try",
"{",
"$",
"Email",
"=",
"new",
"Gdn_Email",
"(",
")",
";",
"$",
"InvitationModel",
"->",
"Send",
"(",
"$",
"InvitationID",
",",
"$",
"Email",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"$",
"this",
"->",
"Form",
"->",
"AddError",
"(",
"strip_tags",
"(",
"$",
"ex",
"->",
"getMessage",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"Form",
"->",
"ErrorCount",
"(",
")",
"==",
"0",
")",
"$",
"this",
"->",
"InformMessage",
"(",
"T",
"(",
"'The invitation was sent successfully.'",
")",
")",
";",
"}",
"$",
"this",
"->",
"View",
"=",
"'Invitations'",
";",
"$",
"this",
"->",
"Invitations",
"(",
")",
";",
"}"
] | Let user send an invitation.
@since 2.0.0
@access public
@param int $InvitationID Unique identifier.
@param string $TransientKey Security token. | [
"Let",
"user",
"send",
"an",
"invitation",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.profilecontroller.php#L960-L978 |
5,406 | bishopb/vanilla | applications/dashboard/controllers/class.profilecontroller.php | ProfileController.UnInvite | public function UnInvite($InvitationID = '', $TransientKey = '') {
$this->Permission('Garden.SignIn.Allow');
$InvitationModel = new InvitationModel();
$Session = Gdn::Session();
if ($Session->ValidateTransientKey($TransientKey)) {
try {
$InvitationModel->Delete($InvitationID, $this->UserModel);
} catch (Exception $ex) {
$this->Form->AddError(strip_tags($ex->getMessage()));
}
if ($this->Form->ErrorCount() == 0)
$this->InformMessage(T('The invitation was removed successfully.'));
}
$this->View = 'Invitations';
$this->Invitations();
} | php | public function UnInvite($InvitationID = '', $TransientKey = '') {
$this->Permission('Garden.SignIn.Allow');
$InvitationModel = new InvitationModel();
$Session = Gdn::Session();
if ($Session->ValidateTransientKey($TransientKey)) {
try {
$InvitationModel->Delete($InvitationID, $this->UserModel);
} catch (Exception $ex) {
$this->Form->AddError(strip_tags($ex->getMessage()));
}
if ($this->Form->ErrorCount() == 0)
$this->InformMessage(T('The invitation was removed successfully.'));
}
$this->View = 'Invitations';
$this->Invitations();
} | [
"public",
"function",
"UnInvite",
"(",
"$",
"InvitationID",
"=",
"''",
",",
"$",
"TransientKey",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"Permission",
"(",
"'Garden.SignIn.Allow'",
")",
";",
"$",
"InvitationModel",
"=",
"new",
"InvitationModel",
"(",
")",
";",
"$",
"Session",
"=",
"Gdn",
"::",
"Session",
"(",
")",
";",
"if",
"(",
"$",
"Session",
"->",
"ValidateTransientKey",
"(",
"$",
"TransientKey",
")",
")",
"{",
"try",
"{",
"$",
"InvitationModel",
"->",
"Delete",
"(",
"$",
"InvitationID",
",",
"$",
"this",
"->",
"UserModel",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"$",
"this",
"->",
"Form",
"->",
"AddError",
"(",
"strip_tags",
"(",
"$",
"ex",
"->",
"getMessage",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"Form",
"->",
"ErrorCount",
"(",
")",
"==",
"0",
")",
"$",
"this",
"->",
"InformMessage",
"(",
"T",
"(",
"'The invitation was removed successfully.'",
")",
")",
";",
"}",
"$",
"this",
"->",
"View",
"=",
"'Invitations'",
";",
"$",
"this",
"->",
"Invitations",
"(",
")",
";",
"}"
] | Revoke an invitation.
@since 2.0.0
@access public
@param int $InvitationID Unique identifier.
@param string $TransientKey Security token. | [
"Revoke",
"an",
"invitation",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.profilecontroller.php#L1109-L1127 |
5,407 | bishopb/vanilla | applications/dashboard/controllers/class.profilecontroller.php | ProfileController.AddSideMenu | public function AddSideMenu($CurrentUrl = '') {
if (!$this->User)
return;
// Make sure to add the "Edit Profile" buttons.
$this->AddModule('ProfileOptionsModule');
// Show edit menu if in edit mode
// Show profile pic & filter menu otherwise
$SideMenu = new SideMenuModule($this);
$this->EventArguments['SideMenu'] = &$SideMenu; // Doing this out here for backwards compatibility.
if ($this->EditMode) {
$this->AddModule('UserBoxModule');
$this->BuildEditMenu($SideMenu, $CurrentUrl);
$this->FireEvent('AfterAddSideMenu');
$this->AddModule($SideMenu, 'Panel');
} else {
// Make sure the userphoto module gets added to the page
$this->AddModule('UserPhotoModule');
// And add the filter menu module
$this->FireEvent('AfterAddSideMenu');
$this->AddModule('ProfileFilterModule');
}
} | php | public function AddSideMenu($CurrentUrl = '') {
if (!$this->User)
return;
// Make sure to add the "Edit Profile" buttons.
$this->AddModule('ProfileOptionsModule');
// Show edit menu if in edit mode
// Show profile pic & filter menu otherwise
$SideMenu = new SideMenuModule($this);
$this->EventArguments['SideMenu'] = &$SideMenu; // Doing this out here for backwards compatibility.
if ($this->EditMode) {
$this->AddModule('UserBoxModule');
$this->BuildEditMenu($SideMenu, $CurrentUrl);
$this->FireEvent('AfterAddSideMenu');
$this->AddModule($SideMenu, 'Panel');
} else {
// Make sure the userphoto module gets added to the page
$this->AddModule('UserPhotoModule');
// And add the filter menu module
$this->FireEvent('AfterAddSideMenu');
$this->AddModule('ProfileFilterModule');
}
} | [
"public",
"function",
"AddSideMenu",
"(",
"$",
"CurrentUrl",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"User",
")",
"return",
";",
"// Make sure to add the \"Edit Profile\" buttons.",
"$",
"this",
"->",
"AddModule",
"(",
"'ProfileOptionsModule'",
")",
";",
"// Show edit menu if in edit mode",
"// Show profile pic & filter menu otherwise",
"$",
"SideMenu",
"=",
"new",
"SideMenuModule",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"EventArguments",
"[",
"'SideMenu'",
"]",
"=",
"&",
"$",
"SideMenu",
";",
"// Doing this out here for backwards compatibility.",
"if",
"(",
"$",
"this",
"->",
"EditMode",
")",
"{",
"$",
"this",
"->",
"AddModule",
"(",
"'UserBoxModule'",
")",
";",
"$",
"this",
"->",
"BuildEditMenu",
"(",
"$",
"SideMenu",
",",
"$",
"CurrentUrl",
")",
";",
"$",
"this",
"->",
"FireEvent",
"(",
"'AfterAddSideMenu'",
")",
";",
"$",
"this",
"->",
"AddModule",
"(",
"$",
"SideMenu",
",",
"'Panel'",
")",
";",
"}",
"else",
"{",
"// Make sure the userphoto module gets added to the page",
"$",
"this",
"->",
"AddModule",
"(",
"'UserPhotoModule'",
")",
";",
"// And add the filter menu module",
"$",
"this",
"->",
"FireEvent",
"(",
"'AfterAddSideMenu'",
")",
";",
"$",
"this",
"->",
"AddModule",
"(",
"'ProfileFilterModule'",
")",
";",
"}",
"}"
] | Adds the option menu to the panel asset.
@since 2.0.0
@access public
@param string $CurrentUrl Path to highlight. | [
"Adds",
"the",
"option",
"menu",
"to",
"the",
"panel",
"asset",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.profilecontroller.php#L1171-L1195 |
5,408 | bishopb/vanilla | applications/dashboard/controllers/class.profilecontroller.php | ProfileController.BuildProfile | public function BuildProfile() {
if (!is_object($this->User))
throw new Exception(T('Cannot build profile information if user is not defined.'));
$Session = Gdn::Session();
if (strpos($this->CssClass, 'Profile') === FALSE)
$this->CssClass .= ' Profile';
$this->Title(Gdn_Format::Text($this->User->Name));
if ($this->_DeliveryType != DELIVERY_TYPE_VIEW) {
// Javascript needed
$this->AddJsFile('jquery.jcrop.pack.js');
$this->AddJsFile('profile.js');
$this->AddJsFile('jquery.gardenmorepager.js');
$this->AddJsFile('activity.js');
// Build activity URL
$ActivityUrl = 'profile/activity/';
if ($this->User->UserID != $Session->UserID)
$ActivityUrl = UserUrl($this->User, '', 'activity');
// Show activity?
if (C('Garden.Profile.ShowActivities', TRUE))
$this->AddProfileTab(T('Activity'), $ActivityUrl, 'Activity', Sprite('SpActivity').' '.T('Activity'));
// Show notifications?
if ($this->User->UserID == $Session->UserID) {
$Notifications = T('Notifications');
$NotificationsHtml = Sprite('SpNotifications').' '.$Notifications;
$CountNotifications = $Session->User->CountNotifications;
if (is_numeric($CountNotifications) && $CountNotifications > 0)
$NotificationsHtml .= ' <span class="Aside"><span class="Count">'.$CountNotifications.'</span></span>';
$this->AddProfileTab($Notifications, 'profile/notifications', 'Notifications', $NotificationsHtml);
}
// Show invitations?
if (C('Garden.Registration.Method') == 'Invitation')
$this->AddProfileTab(T('Invitations'), 'profile/invitations', 'InvitationsLink');
$this->FireEvent('AddProfileTabs');
}
return TRUE;
} | php | public function BuildProfile() {
if (!is_object($this->User))
throw new Exception(T('Cannot build profile information if user is not defined.'));
$Session = Gdn::Session();
if (strpos($this->CssClass, 'Profile') === FALSE)
$this->CssClass .= ' Profile';
$this->Title(Gdn_Format::Text($this->User->Name));
if ($this->_DeliveryType != DELIVERY_TYPE_VIEW) {
// Javascript needed
$this->AddJsFile('jquery.jcrop.pack.js');
$this->AddJsFile('profile.js');
$this->AddJsFile('jquery.gardenmorepager.js');
$this->AddJsFile('activity.js');
// Build activity URL
$ActivityUrl = 'profile/activity/';
if ($this->User->UserID != $Session->UserID)
$ActivityUrl = UserUrl($this->User, '', 'activity');
// Show activity?
if (C('Garden.Profile.ShowActivities', TRUE))
$this->AddProfileTab(T('Activity'), $ActivityUrl, 'Activity', Sprite('SpActivity').' '.T('Activity'));
// Show notifications?
if ($this->User->UserID == $Session->UserID) {
$Notifications = T('Notifications');
$NotificationsHtml = Sprite('SpNotifications').' '.$Notifications;
$CountNotifications = $Session->User->CountNotifications;
if (is_numeric($CountNotifications) && $CountNotifications > 0)
$NotificationsHtml .= ' <span class="Aside"><span class="Count">'.$CountNotifications.'</span></span>';
$this->AddProfileTab($Notifications, 'profile/notifications', 'Notifications', $NotificationsHtml);
}
// Show invitations?
if (C('Garden.Registration.Method') == 'Invitation')
$this->AddProfileTab(T('Invitations'), 'profile/invitations', 'InvitationsLink');
$this->FireEvent('AddProfileTabs');
}
return TRUE;
} | [
"public",
"function",
"BuildProfile",
"(",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"this",
"->",
"User",
")",
")",
"throw",
"new",
"Exception",
"(",
"T",
"(",
"'Cannot build profile information if user is not defined.'",
")",
")",
";",
"$",
"Session",
"=",
"Gdn",
"::",
"Session",
"(",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"CssClass",
",",
"'Profile'",
")",
"===",
"FALSE",
")",
"$",
"this",
"->",
"CssClass",
".=",
"' Profile'",
";",
"$",
"this",
"->",
"Title",
"(",
"Gdn_Format",
"::",
"Text",
"(",
"$",
"this",
"->",
"User",
"->",
"Name",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_DeliveryType",
"!=",
"DELIVERY_TYPE_VIEW",
")",
"{",
"// Javascript needed",
"$",
"this",
"->",
"AddJsFile",
"(",
"'jquery.jcrop.pack.js'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'profile.js'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'jquery.gardenmorepager.js'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'activity.js'",
")",
";",
"// Build activity URL",
"$",
"ActivityUrl",
"=",
"'profile/activity/'",
";",
"if",
"(",
"$",
"this",
"->",
"User",
"->",
"UserID",
"!=",
"$",
"Session",
"->",
"UserID",
")",
"$",
"ActivityUrl",
"=",
"UserUrl",
"(",
"$",
"this",
"->",
"User",
",",
"''",
",",
"'activity'",
")",
";",
"// Show activity?",
"if",
"(",
"C",
"(",
"'Garden.Profile.ShowActivities'",
",",
"TRUE",
")",
")",
"$",
"this",
"->",
"AddProfileTab",
"(",
"T",
"(",
"'Activity'",
")",
",",
"$",
"ActivityUrl",
",",
"'Activity'",
",",
"Sprite",
"(",
"'SpActivity'",
")",
".",
"' '",
".",
"T",
"(",
"'Activity'",
")",
")",
";",
"// Show notifications?",
"if",
"(",
"$",
"this",
"->",
"User",
"->",
"UserID",
"==",
"$",
"Session",
"->",
"UserID",
")",
"{",
"$",
"Notifications",
"=",
"T",
"(",
"'Notifications'",
")",
";",
"$",
"NotificationsHtml",
"=",
"Sprite",
"(",
"'SpNotifications'",
")",
".",
"' '",
".",
"$",
"Notifications",
";",
"$",
"CountNotifications",
"=",
"$",
"Session",
"->",
"User",
"->",
"CountNotifications",
";",
"if",
"(",
"is_numeric",
"(",
"$",
"CountNotifications",
")",
"&&",
"$",
"CountNotifications",
">",
"0",
")",
"$",
"NotificationsHtml",
".=",
"' <span class=\"Aside\"><span class=\"Count\">'",
".",
"$",
"CountNotifications",
".",
"'</span></span>'",
";",
"$",
"this",
"->",
"AddProfileTab",
"(",
"$",
"Notifications",
",",
"'profile/notifications'",
",",
"'Notifications'",
",",
"$",
"NotificationsHtml",
")",
";",
"}",
"// Show invitations?",
"if",
"(",
"C",
"(",
"'Garden.Registration.Method'",
")",
"==",
"'Invitation'",
")",
"$",
"this",
"->",
"AddProfileTab",
"(",
"T",
"(",
"'Invitations'",
")",
",",
"'profile/invitations'",
",",
"'InvitationsLink'",
")",
";",
"$",
"this",
"->",
"FireEvent",
"(",
"'AddProfileTabs'",
")",
";",
"}",
"return",
"TRUE",
";",
"}"
] | Build the user profile.
Set the page title, add data to page modules, add modules to assets,
add tabs to tab menu. $this->User must be defined, or this method will throw an exception.
@since 2.0.0
@access public
@return bool Always true. | [
"Build",
"the",
"user",
"profile",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.profilecontroller.php#L1287-L1331 |
5,409 | bishopb/vanilla | applications/dashboard/controllers/class.profilecontroller.php | ProfileController.Get | public function Get($UserID = FALSE) {
if (!$UserID)
$UserID = Gdn::Session()->UserID;
if (($UserID != Gdn::Session()->UserID || !Gdn::Session()->UserID) && !Gdn::Session()->CheckPermission('Garden.Users.Edit')) {
throw new Exception(T('You do not have permission to view other profiles.'), 401);
}
$UserModel = new UserModel();
// Get the user.
$User = $UserModel->GetID($UserID, DATASET_TYPE_ARRAY);
if (!$User) {
throw new Exception(T('User not found.'), 404);
}
$PhotoUrl = $User['Photo'];
if ($PhotoUrl && strpos($PhotoUrl, '//') == FALSE) {
$PhotoUrl = Url('/uploads/'.ChangeBasename($PhotoUrl, 'n%s'), TRUE);
}
$User['Photo'] = $PhotoUrl;
// Remove unwanted fields.
$this->Data = ArrayTranslate($User, array('UserID', 'Name', 'Email', 'Photo'));
$this->Render();
} | php | public function Get($UserID = FALSE) {
if (!$UserID)
$UserID = Gdn::Session()->UserID;
if (($UserID != Gdn::Session()->UserID || !Gdn::Session()->UserID) && !Gdn::Session()->CheckPermission('Garden.Users.Edit')) {
throw new Exception(T('You do not have permission to view other profiles.'), 401);
}
$UserModel = new UserModel();
// Get the user.
$User = $UserModel->GetID($UserID, DATASET_TYPE_ARRAY);
if (!$User) {
throw new Exception(T('User not found.'), 404);
}
$PhotoUrl = $User['Photo'];
if ($PhotoUrl && strpos($PhotoUrl, '//') == FALSE) {
$PhotoUrl = Url('/uploads/'.ChangeBasename($PhotoUrl, 'n%s'), TRUE);
}
$User['Photo'] = $PhotoUrl;
// Remove unwanted fields.
$this->Data = ArrayTranslate($User, array('UserID', 'Name', 'Email', 'Photo'));
$this->Render();
} | [
"public",
"function",
"Get",
"(",
"$",
"UserID",
"=",
"FALSE",
")",
"{",
"if",
"(",
"!",
"$",
"UserID",
")",
"$",
"UserID",
"=",
"Gdn",
"::",
"Session",
"(",
")",
"->",
"UserID",
";",
"if",
"(",
"(",
"$",
"UserID",
"!=",
"Gdn",
"::",
"Session",
"(",
")",
"->",
"UserID",
"||",
"!",
"Gdn",
"::",
"Session",
"(",
")",
"->",
"UserID",
")",
"&&",
"!",
"Gdn",
"::",
"Session",
"(",
")",
"->",
"CheckPermission",
"(",
"'Garden.Users.Edit'",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"T",
"(",
"'You do not have permission to view other profiles.'",
")",
",",
"401",
")",
";",
"}",
"$",
"UserModel",
"=",
"new",
"UserModel",
"(",
")",
";",
"// Get the user.",
"$",
"User",
"=",
"$",
"UserModel",
"->",
"GetID",
"(",
"$",
"UserID",
",",
"DATASET_TYPE_ARRAY",
")",
";",
"if",
"(",
"!",
"$",
"User",
")",
"{",
"throw",
"new",
"Exception",
"(",
"T",
"(",
"'User not found.'",
")",
",",
"404",
")",
";",
"}",
"$",
"PhotoUrl",
"=",
"$",
"User",
"[",
"'Photo'",
"]",
";",
"if",
"(",
"$",
"PhotoUrl",
"&&",
"strpos",
"(",
"$",
"PhotoUrl",
",",
"'//'",
")",
"==",
"FALSE",
")",
"{",
"$",
"PhotoUrl",
"=",
"Url",
"(",
"'/uploads/'",
".",
"ChangeBasename",
"(",
"$",
"PhotoUrl",
",",
"'n%s'",
")",
",",
"TRUE",
")",
";",
"}",
"$",
"User",
"[",
"'Photo'",
"]",
"=",
"$",
"PhotoUrl",
";",
"// Remove unwanted fields.",
"$",
"this",
"->",
"Data",
"=",
"ArrayTranslate",
"(",
"$",
"User",
",",
"array",
"(",
"'UserID'",
",",
"'Name'",
",",
"'Email'",
",",
"'Photo'",
")",
")",
";",
"$",
"this",
"->",
"Render",
"(",
")",
";",
"}"
] | Render basic data about user.
@since 2.0.?
@access public
@param int $UserID Unique ID. | [
"Render",
"basic",
"data",
"about",
"user",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.profilecontroller.php#L1340-L1366 |
5,410 | bishopb/vanilla | applications/dashboard/controllers/class.profilecontroller.php | ProfileController.GetUserInfo | public function GetUserInfo($UserReference = '', $Username = '', $UserID = '', $CheckPermissions = FALSE) {
if ($this->_UserInfoRetrieved)
return;
if (!C('Garden.Profile.Public') && !Gdn::Session()->IsValid())
throw PermissionException();
// If a UserID was provided as a querystring parameter, use it over anything else:
if ($UserID) {
$UserReference = $UserID;
$Username = 'Unknown'; // Fill this with a value so the $UserReference is assumed to be an integer/userid.
}
$this->Roles = array();
if ($UserReference == '') {
if ($Username) {
$this->User = $this->UserModel->GetByUsername($Username);
} else
$this->User = $this->UserModel->GetID(Gdn::Session()->UserID);
} elseif (is_numeric($UserReference) && $Username != '') {
$this->User = $this->UserModel->GetID($UserReference);
} else {
$this->User = $this->UserModel->GetByUsername($UserReference);
}
if ($this->User === FALSE) {
throw NotFoundException('User');
} else if ($this->User->Deleted == 1) {
Redirect('dashboard/home/deleted');
} else {
$this->RoleData = $this->UserModel->GetRoles($this->User->UserID);
if ($this->RoleData !== FALSE && $this->RoleData->NumRows(DATASET_TYPE_ARRAY) > 0)
$this->Roles = ConsolidateArrayValuesByKey($this->RoleData->Result(), 'Name');
if (Gdn::Session()->CheckPermission('Garden.Settings.Manage') || Gdn::Session()->UserID == $this->User->UserID) {
$this->User->Transient = GetValueR('Attributes.TransientKey', $this->User);
}
// Hide personal info roles
if (!CheckPermission('Garden.PersonalInfo.View')) {
$this->Roles = array_filter($this->Roles, 'RoleModel::FilterPersonalInfo');
}
$this->SetData('Profile', $this->User);
$this->SetData('UserRoles', $this->Roles);
if ($CssClass = GetValue('_CssClass', $this->User)) {
$this->CssClass .= ' '.$CssClass;
}
}
if ($CheckPermissions && Gdn::Session()->UserID != $this->User->UserID)
$this->Permission('Garden.Users.Edit');
$this->AddSideMenu();
$this->_UserInfoRetrieved = TRUE;
return TRUE;
} | php | public function GetUserInfo($UserReference = '', $Username = '', $UserID = '', $CheckPermissions = FALSE) {
if ($this->_UserInfoRetrieved)
return;
if (!C('Garden.Profile.Public') && !Gdn::Session()->IsValid())
throw PermissionException();
// If a UserID was provided as a querystring parameter, use it over anything else:
if ($UserID) {
$UserReference = $UserID;
$Username = 'Unknown'; // Fill this with a value so the $UserReference is assumed to be an integer/userid.
}
$this->Roles = array();
if ($UserReference == '') {
if ($Username) {
$this->User = $this->UserModel->GetByUsername($Username);
} else
$this->User = $this->UserModel->GetID(Gdn::Session()->UserID);
} elseif (is_numeric($UserReference) && $Username != '') {
$this->User = $this->UserModel->GetID($UserReference);
} else {
$this->User = $this->UserModel->GetByUsername($UserReference);
}
if ($this->User === FALSE) {
throw NotFoundException('User');
} else if ($this->User->Deleted == 1) {
Redirect('dashboard/home/deleted');
} else {
$this->RoleData = $this->UserModel->GetRoles($this->User->UserID);
if ($this->RoleData !== FALSE && $this->RoleData->NumRows(DATASET_TYPE_ARRAY) > 0)
$this->Roles = ConsolidateArrayValuesByKey($this->RoleData->Result(), 'Name');
if (Gdn::Session()->CheckPermission('Garden.Settings.Manage') || Gdn::Session()->UserID == $this->User->UserID) {
$this->User->Transient = GetValueR('Attributes.TransientKey', $this->User);
}
// Hide personal info roles
if (!CheckPermission('Garden.PersonalInfo.View')) {
$this->Roles = array_filter($this->Roles, 'RoleModel::FilterPersonalInfo');
}
$this->SetData('Profile', $this->User);
$this->SetData('UserRoles', $this->Roles);
if ($CssClass = GetValue('_CssClass', $this->User)) {
$this->CssClass .= ' '.$CssClass;
}
}
if ($CheckPermissions && Gdn::Session()->UserID != $this->User->UserID)
$this->Permission('Garden.Users.Edit');
$this->AddSideMenu();
$this->_UserInfoRetrieved = TRUE;
return TRUE;
} | [
"public",
"function",
"GetUserInfo",
"(",
"$",
"UserReference",
"=",
"''",
",",
"$",
"Username",
"=",
"''",
",",
"$",
"UserID",
"=",
"''",
",",
"$",
"CheckPermissions",
"=",
"FALSE",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_UserInfoRetrieved",
")",
"return",
";",
"if",
"(",
"!",
"C",
"(",
"'Garden.Profile.Public'",
")",
"&&",
"!",
"Gdn",
"::",
"Session",
"(",
")",
"->",
"IsValid",
"(",
")",
")",
"throw",
"PermissionException",
"(",
")",
";",
"// If a UserID was provided as a querystring parameter, use it over anything else:",
"if",
"(",
"$",
"UserID",
")",
"{",
"$",
"UserReference",
"=",
"$",
"UserID",
";",
"$",
"Username",
"=",
"'Unknown'",
";",
"// Fill this with a value so the $UserReference is assumed to be an integer/userid.",
"}",
"$",
"this",
"->",
"Roles",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"UserReference",
"==",
"''",
")",
"{",
"if",
"(",
"$",
"Username",
")",
"{",
"$",
"this",
"->",
"User",
"=",
"$",
"this",
"->",
"UserModel",
"->",
"GetByUsername",
"(",
"$",
"Username",
")",
";",
"}",
"else",
"$",
"this",
"->",
"User",
"=",
"$",
"this",
"->",
"UserModel",
"->",
"GetID",
"(",
"Gdn",
"::",
"Session",
"(",
")",
"->",
"UserID",
")",
";",
"}",
"elseif",
"(",
"is_numeric",
"(",
"$",
"UserReference",
")",
"&&",
"$",
"Username",
"!=",
"''",
")",
"{",
"$",
"this",
"->",
"User",
"=",
"$",
"this",
"->",
"UserModel",
"->",
"GetID",
"(",
"$",
"UserReference",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"User",
"=",
"$",
"this",
"->",
"UserModel",
"->",
"GetByUsername",
"(",
"$",
"UserReference",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"User",
"===",
"FALSE",
")",
"{",
"throw",
"NotFoundException",
"(",
"'User'",
")",
";",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"User",
"->",
"Deleted",
"==",
"1",
")",
"{",
"Redirect",
"(",
"'dashboard/home/deleted'",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"RoleData",
"=",
"$",
"this",
"->",
"UserModel",
"->",
"GetRoles",
"(",
"$",
"this",
"->",
"User",
"->",
"UserID",
")",
";",
"if",
"(",
"$",
"this",
"->",
"RoleData",
"!==",
"FALSE",
"&&",
"$",
"this",
"->",
"RoleData",
"->",
"NumRows",
"(",
"DATASET_TYPE_ARRAY",
")",
">",
"0",
")",
"$",
"this",
"->",
"Roles",
"=",
"ConsolidateArrayValuesByKey",
"(",
"$",
"this",
"->",
"RoleData",
"->",
"Result",
"(",
")",
",",
"'Name'",
")",
";",
"if",
"(",
"Gdn",
"::",
"Session",
"(",
")",
"->",
"CheckPermission",
"(",
"'Garden.Settings.Manage'",
")",
"||",
"Gdn",
"::",
"Session",
"(",
")",
"->",
"UserID",
"==",
"$",
"this",
"->",
"User",
"->",
"UserID",
")",
"{",
"$",
"this",
"->",
"User",
"->",
"Transient",
"=",
"GetValueR",
"(",
"'Attributes.TransientKey'",
",",
"$",
"this",
"->",
"User",
")",
";",
"}",
"// Hide personal info roles",
"if",
"(",
"!",
"CheckPermission",
"(",
"'Garden.PersonalInfo.View'",
")",
")",
"{",
"$",
"this",
"->",
"Roles",
"=",
"array_filter",
"(",
"$",
"this",
"->",
"Roles",
",",
"'RoleModel::FilterPersonalInfo'",
")",
";",
"}",
"$",
"this",
"->",
"SetData",
"(",
"'Profile'",
",",
"$",
"this",
"->",
"User",
")",
";",
"$",
"this",
"->",
"SetData",
"(",
"'UserRoles'",
",",
"$",
"this",
"->",
"Roles",
")",
";",
"if",
"(",
"$",
"CssClass",
"=",
"GetValue",
"(",
"'_CssClass'",
",",
"$",
"this",
"->",
"User",
")",
")",
"{",
"$",
"this",
"->",
"CssClass",
".=",
"' '",
".",
"$",
"CssClass",
";",
"}",
"}",
"if",
"(",
"$",
"CheckPermissions",
"&&",
"Gdn",
"::",
"Session",
"(",
")",
"->",
"UserID",
"!=",
"$",
"this",
"->",
"User",
"->",
"UserID",
")",
"$",
"this",
"->",
"Permission",
"(",
"'Garden.Users.Edit'",
")",
";",
"$",
"this",
"->",
"AddSideMenu",
"(",
")",
";",
"$",
"this",
"->",
"_UserInfoRetrieved",
"=",
"TRUE",
";",
"return",
"TRUE",
";",
"}"
] | Retrieve the user to be manipulated. Defaults to current user.
@since 2.0.0
@access public
@param mixed $User Unique identifier, possibly username or ID.
@param string $Username.
@param int $UserID Unique ID.
@param bool $CheckPermissions Whether or not to check user permissions.
@return bool Always true. | [
"Retrieve",
"the",
"user",
"to",
"be",
"manipulated",
".",
"Defaults",
"to",
"current",
"user",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.profilecontroller.php#L1379-L1435 |
5,411 | bishopb/vanilla | applications/dashboard/controllers/class.profilecontroller.php | ProfileController.ProfileUrl | public function ProfileUrl($UserReference = NULL, $UserID = NULL) {
if (!property_exists($this, 'User'))
$this->GetUserInfo();
if ($UserReference === NULL)
$UserReference = $this->User->Name;
if ($UserID === NULL)
$UserID = $this->User->UserID;
$UserReferenceEnc = rawurlencode($UserReference);
if ($UserReferenceEnc == $UserReference)
return $UserReferenceEnc;
else
return "$UserID/$UserReferenceEnc";
} | php | public function ProfileUrl($UserReference = NULL, $UserID = NULL) {
if (!property_exists($this, 'User'))
$this->GetUserInfo();
if ($UserReference === NULL)
$UserReference = $this->User->Name;
if ($UserID === NULL)
$UserID = $this->User->UserID;
$UserReferenceEnc = rawurlencode($UserReference);
if ($UserReferenceEnc == $UserReference)
return $UserReferenceEnc;
else
return "$UserID/$UserReferenceEnc";
} | [
"public",
"function",
"ProfileUrl",
"(",
"$",
"UserReference",
"=",
"NULL",
",",
"$",
"UserID",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"property_exists",
"(",
"$",
"this",
",",
"'User'",
")",
")",
"$",
"this",
"->",
"GetUserInfo",
"(",
")",
";",
"if",
"(",
"$",
"UserReference",
"===",
"NULL",
")",
"$",
"UserReference",
"=",
"$",
"this",
"->",
"User",
"->",
"Name",
";",
"if",
"(",
"$",
"UserID",
"===",
"NULL",
")",
"$",
"UserID",
"=",
"$",
"this",
"->",
"User",
"->",
"UserID",
";",
"$",
"UserReferenceEnc",
"=",
"rawurlencode",
"(",
"$",
"UserReference",
")",
";",
"if",
"(",
"$",
"UserReferenceEnc",
"==",
"$",
"UserReference",
")",
"return",
"$",
"UserReferenceEnc",
";",
"else",
"return",
"\"$UserID/$UserReferenceEnc\"",
";",
"}"
] | Build URL to user's profile.
@since 2.0.0
@access public
@param mixed $UserReference Unique identifier, possibly username or ID.
@param string $UserID Unique ID.
@return string Relative URL path. | [
"Build",
"URL",
"to",
"user",
"s",
"profile",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.profilecontroller.php#L1446-L1460 |
5,412 | bishopb/vanilla | applications/dashboard/controllers/class.profilecontroller.php | ProfileController.Multi | public function Multi($UserID) {
$this->Permission('Garden.Settings.Manage');
$this->DeliveryMethod(DELIVERY_METHOD_JSON);
$this->DeliveryType(DELIVERY_TYPE_DATA);
// Get rid of Reactions busybody data
unset($this->Data['Counts']);
$UserID = (array)$UserID;
$Users = Gdn::UserModel()->GetIDs($UserID);
$AllowedFields = array('UserID','Name','Title','Location','About','Email','Gender','CountVisits','CountInvitations','CountNotifications','Admin','Verified','Banned','Deleted','CountDiscussions','CountComments','CountBookmarks','CountBadges','Points','Punished','RankID','PhotoUrl','Online','LastOnlineDate');
$AllowedFields = array_fill_keys($AllowedFields, NULL);
foreach ($Users as &$User)
$User = array_intersect_key($User, $AllowedFields);
$Users = array_values($Users);
$this->SetData('Users', $Users);
$this->Render();
} | php | public function Multi($UserID) {
$this->Permission('Garden.Settings.Manage');
$this->DeliveryMethod(DELIVERY_METHOD_JSON);
$this->DeliveryType(DELIVERY_TYPE_DATA);
// Get rid of Reactions busybody data
unset($this->Data['Counts']);
$UserID = (array)$UserID;
$Users = Gdn::UserModel()->GetIDs($UserID);
$AllowedFields = array('UserID','Name','Title','Location','About','Email','Gender','CountVisits','CountInvitations','CountNotifications','Admin','Verified','Banned','Deleted','CountDiscussions','CountComments','CountBookmarks','CountBadges','Points','Punished','RankID','PhotoUrl','Online','LastOnlineDate');
$AllowedFields = array_fill_keys($AllowedFields, NULL);
foreach ($Users as &$User)
$User = array_intersect_key($User, $AllowedFields);
$Users = array_values($Users);
$this->SetData('Users', $Users);
$this->Render();
} | [
"public",
"function",
"Multi",
"(",
"$",
"UserID",
")",
"{",
"$",
"this",
"->",
"Permission",
"(",
"'Garden.Settings.Manage'",
")",
";",
"$",
"this",
"->",
"DeliveryMethod",
"(",
"DELIVERY_METHOD_JSON",
")",
";",
"$",
"this",
"->",
"DeliveryType",
"(",
"DELIVERY_TYPE_DATA",
")",
";",
"// Get rid of Reactions busybody data",
"unset",
"(",
"$",
"this",
"->",
"Data",
"[",
"'Counts'",
"]",
")",
";",
"$",
"UserID",
"=",
"(",
"array",
")",
"$",
"UserID",
";",
"$",
"Users",
"=",
"Gdn",
"::",
"UserModel",
"(",
")",
"->",
"GetIDs",
"(",
"$",
"UserID",
")",
";",
"$",
"AllowedFields",
"=",
"array",
"(",
"'UserID'",
",",
"'Name'",
",",
"'Title'",
",",
"'Location'",
",",
"'About'",
",",
"'Email'",
",",
"'Gender'",
",",
"'CountVisits'",
",",
"'CountInvitations'",
",",
"'CountNotifications'",
",",
"'Admin'",
",",
"'Verified'",
",",
"'Banned'",
",",
"'Deleted'",
",",
"'CountDiscussions'",
",",
"'CountComments'",
",",
"'CountBookmarks'",
",",
"'CountBadges'",
",",
"'Points'",
",",
"'Punished'",
",",
"'RankID'",
",",
"'PhotoUrl'",
",",
"'Online'",
",",
"'LastOnlineDate'",
")",
";",
"$",
"AllowedFields",
"=",
"array_fill_keys",
"(",
"$",
"AllowedFields",
",",
"NULL",
")",
";",
"foreach",
"(",
"$",
"Users",
"as",
"&",
"$",
"User",
")",
"$",
"User",
"=",
"array_intersect_key",
"(",
"$",
"User",
",",
"$",
"AllowedFields",
")",
";",
"$",
"Users",
"=",
"array_values",
"(",
"$",
"Users",
")",
";",
"$",
"this",
"->",
"SetData",
"(",
"'Users'",
",",
"$",
"Users",
")",
";",
"$",
"this",
"->",
"Render",
"(",
")",
";",
"}"
] | Fetch multiple users
Note: API only
@param type $UserID | [
"Fetch",
"multiple",
"users"
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.profilecontroller.php#L1521-L1540 |
5,413 | Dhii/i18n-helper-base | src/StringTranslatingTrait.php | StringTranslatingTrait.__ | protected function __($string, $args = array(), $context = null)
{
$string = $this->_translate($string, $context);
array_unshift($args, $string);
$result = call_user_func_array('sprintf', $args);
return $result;
} | php | protected function __($string, $args = array(), $context = null)
{
$string = $this->_translate($string, $context);
array_unshift($args, $string);
$result = call_user_func_array('sprintf', $args);
return $result;
} | [
"protected",
"function",
"__",
"(",
"$",
"string",
",",
"$",
"args",
"=",
"array",
"(",
")",
",",
"$",
"context",
"=",
"null",
")",
"{",
"$",
"string",
"=",
"$",
"this",
"->",
"_translate",
"(",
"$",
"string",
",",
"$",
"context",
")",
";",
"array_unshift",
"(",
"$",
"args",
",",
"$",
"string",
")",
";",
"$",
"result",
"=",
"call_user_func_array",
"(",
"'sprintf'",
",",
"$",
"args",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Translates a string, and replaces placeholders.
@since [*next-version*]
@see sprintf()
@see _translate()
@param string $string The format string to translate.
@param array $args Placeholder values to replace in the string.
@param mixed $context The context for translation.
@return string The translated string. | [
"Translates",
"a",
"string",
"and",
"replaces",
"placeholders",
"."
] | fc4c881f3e528ea918588831ebeffb92738f8dd5 | https://github.com/Dhii/i18n-helper-base/blob/fc4c881f3e528ea918588831ebeffb92738f8dd5/src/StringTranslatingTrait.php#L25-L32 |
5,414 | liip/LiipDrupalEventManagerModule | src/Liip/Drupal/Modules/EventManager/EventSubject.php | EventSubject.attach | public function attach(EventObserverInterface $observer)
{
$key = $this->getRegistrationKey($observer);
if (empty($this->observers[$key])) {
$this->observers[$key] = $observer;
}
} | php | public function attach(EventObserverInterface $observer)
{
$key = $this->getRegistrationKey($observer);
if (empty($this->observers[$key])) {
$this->observers[$key] = $observer;
}
} | [
"public",
"function",
"attach",
"(",
"EventObserverInterface",
"$",
"observer",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"getRegistrationKey",
"(",
"$",
"observer",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"observers",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"observers",
"[",
"$",
"key",
"]",
"=",
"$",
"observer",
";",
"}",
"}"
] | Attach an EventObserver
@param \Liip\Drupal\Modules\EventManager\EventObserverInterface $observer
@link http://php.net/manual/en/splsubject.attach.php | [
"Attach",
"an",
"EventObserver"
] | c049662aa1efaab1149d7edb0cb7bca265983571 | https://github.com/liip/LiipDrupalEventManagerModule/blob/c049662aa1efaab1149d7edb0cb7bca265983571/src/Liip/Drupal/Modules/EventManager/EventSubject.php#L37-L44 |
5,415 | liip/LiipDrupalEventManagerModule | src/Liip/Drupal/Modules/EventManager/EventSubject.php | EventSubject.detach | public function detach(EventObserverInterface $observer)
{
$key = $this->getRegistrationKey($observer);
if (array_key_exists($key, $this->observers)){
unset($this->observers[$key]);
}
} | php | public function detach(EventObserverInterface $observer)
{
$key = $this->getRegistrationKey($observer);
if (array_key_exists($key, $this->observers)){
unset($this->observers[$key]);
}
} | [
"public",
"function",
"detach",
"(",
"EventObserverInterface",
"$",
"observer",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"getRegistrationKey",
"(",
"$",
"observer",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"observers",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"observers",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}"
] | Detach an EventObserver
@param \Liip\Drupal\Modules\EventManager\EventObserverInterface $observer
@link http://php.net/manual/en/splsubject.detach.php | [
"Detach",
"an",
"EventObserver"
] | c049662aa1efaab1149d7edb0cb7bca265983571 | https://github.com/liip/LiipDrupalEventManagerModule/blob/c049662aa1efaab1149d7edb0cb7bca265983571/src/Liip/Drupal/Modules/EventManager/EventSubject.php#L53-L60 |
5,416 | liip/LiipDrupalEventManagerModule | src/Liip/Drupal/Modules/EventManager/EventSubject.php | EventSubject.notify | public function notify()
{
if (0 < count($this->observers)) {
foreach ($this->observers as $observer) {
/** @var \Liip\Drupal\Modules\EventManager\EventObserverInterface $observer */
$observer->update($this);
}
}
} | php | public function notify()
{
if (0 < count($this->observers)) {
foreach ($this->observers as $observer) {
/** @var \Liip\Drupal\Modules\EventManager\EventObserverInterface $observer */
$observer->update($this);
}
}
} | [
"public",
"function",
"notify",
"(",
")",
"{",
"if",
"(",
"0",
"<",
"count",
"(",
"$",
"this",
"->",
"observers",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"observers",
"as",
"$",
"observer",
")",
"{",
"/** @var \\Liip\\Drupal\\Modules\\EventManager\\EventObserverInterface $observer */",
"$",
"observer",
"->",
"update",
"(",
"$",
"this",
")",
";",
"}",
"}",
"}"
] | Notify every attached observer
@link http://php.net/manual/en/splsubject.notify.php | [
"Notify",
"every",
"attached",
"observer"
] | c049662aa1efaab1149d7edb0cb7bca265983571 | https://github.com/liip/LiipDrupalEventManagerModule/blob/c049662aa1efaab1149d7edb0cb7bca265983571/src/Liip/Drupal/Modules/EventManager/EventSubject.php#L67-L75 |
5,417 | spipremix/facteur | phpmailer-php5/class.phpmailer.php | PHPMailer.addAnAddress | protected function addAnAddress($kind, $address, $name = '')
{
if (!in_array($kind, array('to', 'cc', 'bcc', 'Reply-To'))) {
$error_message = $this->lang('Invalid recipient kind: ') . $kind;
$this->setError($error_message);
$this->edebug($error_message);
if ($this->exceptions) {
throw new phpmailerException($error_message);
}
return false;
}
if (!$this->validateAddress($address)) {
$error_message = $this->lang('invalid_address') . " (addAnAddress $kind): $address";
$this->setError($error_message);
$this->edebug($error_message);
if ($this->exceptions) {
throw new phpmailerException($error_message);
}
return false;
}
if ($kind != 'Reply-To') {
if (!array_key_exists(strtolower($address), $this->all_recipients)) {
array_push($this->$kind, array($address, $name));
$this->all_recipients[strtolower($address)] = true;
return true;
}
} else {
if (!array_key_exists(strtolower($address), $this->ReplyTo)) {
$this->ReplyTo[strtolower($address)] = array($address, $name);
return true;
}
}
return false;
} | php | protected function addAnAddress($kind, $address, $name = '')
{
if (!in_array($kind, array('to', 'cc', 'bcc', 'Reply-To'))) {
$error_message = $this->lang('Invalid recipient kind: ') . $kind;
$this->setError($error_message);
$this->edebug($error_message);
if ($this->exceptions) {
throw new phpmailerException($error_message);
}
return false;
}
if (!$this->validateAddress($address)) {
$error_message = $this->lang('invalid_address') . " (addAnAddress $kind): $address";
$this->setError($error_message);
$this->edebug($error_message);
if ($this->exceptions) {
throw new phpmailerException($error_message);
}
return false;
}
if ($kind != 'Reply-To') {
if (!array_key_exists(strtolower($address), $this->all_recipients)) {
array_push($this->$kind, array($address, $name));
$this->all_recipients[strtolower($address)] = true;
return true;
}
} else {
if (!array_key_exists(strtolower($address), $this->ReplyTo)) {
$this->ReplyTo[strtolower($address)] = array($address, $name);
return true;
}
}
return false;
} | [
"protected",
"function",
"addAnAddress",
"(",
"$",
"kind",
",",
"$",
"address",
",",
"$",
"name",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"kind",
",",
"array",
"(",
"'to'",
",",
"'cc'",
",",
"'bcc'",
",",
"'Reply-To'",
")",
")",
")",
"{",
"$",
"error_message",
"=",
"$",
"this",
"->",
"lang",
"(",
"'Invalid recipient kind: '",
")",
".",
"$",
"kind",
";",
"$",
"this",
"->",
"setError",
"(",
"$",
"error_message",
")",
";",
"$",
"this",
"->",
"edebug",
"(",
"$",
"error_message",
")",
";",
"if",
"(",
"$",
"this",
"->",
"exceptions",
")",
"{",
"throw",
"new",
"phpmailerException",
"(",
"$",
"error_message",
")",
";",
"}",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"validateAddress",
"(",
"$",
"address",
")",
")",
"{",
"$",
"error_message",
"=",
"$",
"this",
"->",
"lang",
"(",
"'invalid_address'",
")",
".",
"\" (addAnAddress $kind): $address\"",
";",
"$",
"this",
"->",
"setError",
"(",
"$",
"error_message",
")",
";",
"$",
"this",
"->",
"edebug",
"(",
"$",
"error_message",
")",
";",
"if",
"(",
"$",
"this",
"->",
"exceptions",
")",
"{",
"throw",
"new",
"phpmailerException",
"(",
"$",
"error_message",
")",
";",
"}",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"kind",
"!=",
"'Reply-To'",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"strtolower",
"(",
"$",
"address",
")",
",",
"$",
"this",
"->",
"all_recipients",
")",
")",
"{",
"array_push",
"(",
"$",
"this",
"->",
"$",
"kind",
",",
"array",
"(",
"$",
"address",
",",
"$",
"name",
")",
")",
";",
"$",
"this",
"->",
"all_recipients",
"[",
"strtolower",
"(",
"$",
"address",
")",
"]",
"=",
"true",
";",
"return",
"true",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"strtolower",
"(",
"$",
"address",
")",
",",
"$",
"this",
"->",
"ReplyTo",
")",
")",
"{",
"$",
"this",
"->",
"ReplyTo",
"[",
"strtolower",
"(",
"$",
"address",
")",
"]",
"=",
"array",
"(",
"$",
"address",
",",
"$",
"name",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Add an address to one of the recipient arrays or to the ReplyTo array.
Addresses that have been added already return false, but do not throw exceptions.
@param string $kind One of 'to', 'cc', 'bcc', or 'ReplyTo'
@param string $address The email address to send, resp. to reply to
@param string $name
@throws phpmailerException
@return boolean true on success, false if address already used or invalid in some way
@access protected | [
"Add",
"an",
"address",
"to",
"one",
"of",
"the",
"recipient",
"arrays",
"or",
"to",
"the",
"ReplyTo",
"array",
".",
"Addresses",
"that",
"have",
"been",
"added",
"already",
"return",
"false",
"but",
"do",
"not",
"throw",
"exceptions",
"."
] | 9cdca595d1f8f9a66c29e5c74e8666d81ebc65ca | https://github.com/spipremix/facteur/blob/9cdca595d1f8f9a66c29e5c74e8666d81ebc65ca/phpmailer-php5/class.phpmailer.php#L915-L948 |
5,418 | spipremix/facteur | phpmailer-php5/class.phpmailer.php | PHPMailer.clearAddresses | public function clearAddresses()
{
foreach ($this->to as $to) {
unset($this->all_recipients[strtolower($to[0])]);
}
$this->to = array();
$this->clearQueuedAddresses('to');
} | php | public function clearAddresses()
{
foreach ($this->to as $to) {
unset($this->all_recipients[strtolower($to[0])]);
}
$this->to = array();
$this->clearQueuedAddresses('to');
} | [
"public",
"function",
"clearAddresses",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"to",
"as",
"$",
"to",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"all_recipients",
"[",
"strtolower",
"(",
"$",
"to",
"[",
"0",
"]",
")",
"]",
")",
";",
"}",
"$",
"this",
"->",
"to",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"clearQueuedAddresses",
"(",
"'to'",
")",
";",
"}"
] | Clear all To recipients.
@return void | [
"Clear",
"all",
"To",
"recipients",
"."
] | 9cdca595d1f8f9a66c29e5c74e8666d81ebc65ca | https://github.com/spipremix/facteur/blob/9cdca595d1f8f9a66c29e5c74e8666d81ebc65ca/phpmailer-php5/class.phpmailer.php#L3166-L3173 |
5,419 | bytepark/lib-migration | src/Repository/Filesystem/Grouped.php | Grouped.buildFilePath | private function buildFilePath($fileName)
{
$digest = md5($fileName);
$path = $this->basePath . '/' . substr($digest, 0, 1) . '/' . substr($digest, 1, 1);
if (!is_dir($path)) {
mkdir($path, 0777, true);
}
return $path . '/' . $fileName;
} | php | private function buildFilePath($fileName)
{
$digest = md5($fileName);
$path = $this->basePath . '/' . substr($digest, 0, 1) . '/' . substr($digest, 1, 1);
if (!is_dir($path)) {
mkdir($path, 0777, true);
}
return $path . '/' . $fileName;
} | [
"private",
"function",
"buildFilePath",
"(",
"$",
"fileName",
")",
"{",
"$",
"digest",
"=",
"md5",
"(",
"$",
"fileName",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"basePath",
".",
"'/'",
".",
"substr",
"(",
"$",
"digest",
",",
"0",
",",
"1",
")",
".",
"'/'",
".",
"substr",
"(",
"$",
"digest",
",",
"1",
",",
"1",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"mkdir",
"(",
"$",
"path",
",",
"0777",
",",
"true",
")",
";",
"}",
"return",
"$",
"path",
".",
"'/'",
".",
"$",
"fileName",
";",
"}"
] | Generates a subdirectory path for the given file
@param string $fileName
@return string | [
"Generates",
"a",
"subdirectory",
"path",
"for",
"the",
"given",
"file"
] | 14d75f6978e257f456493c673175ca5d07b28c84 | https://github.com/bytepark/lib-migration/blob/14d75f6978e257f456493c673175ca5d07b28c84/src/Repository/Filesystem/Grouped.php#L82-L93 |
5,420 | bytepark/lib-migration | src/Repository/Filesystem/Grouped.php | Grouped.buildFromSubDirectory | private function buildFromSubDirectory(\FilesystemIterator $directory)
{
/* @var $fileInfo \SplFileInfo */
foreach ($directory as $fileInfo) {
if ($fileInfo->isDir()) {
$subDirectory = new \FilesystemIterator($fileInfo->getRealPath());
$this->buildFromSubDirectory($subDirectory);
} elseif ($fileInfo->isFile() && $fileInfo->getExtension() === $this->extension) {
$migration = UnitOfWorkFactory::buildFromSplFileInfo($fileInfo);
$this->add($migration);
}
}
} | php | private function buildFromSubDirectory(\FilesystemIterator $directory)
{
/* @var $fileInfo \SplFileInfo */
foreach ($directory as $fileInfo) {
if ($fileInfo->isDir()) {
$subDirectory = new \FilesystemIterator($fileInfo->getRealPath());
$this->buildFromSubDirectory($subDirectory);
} elseif ($fileInfo->isFile() && $fileInfo->getExtension() === $this->extension) {
$migration = UnitOfWorkFactory::buildFromSplFileInfo($fileInfo);
$this->add($migration);
}
}
} | [
"private",
"function",
"buildFromSubDirectory",
"(",
"\\",
"FilesystemIterator",
"$",
"directory",
")",
"{",
"/* @var $fileInfo \\SplFileInfo */",
"foreach",
"(",
"$",
"directory",
"as",
"$",
"fileInfo",
")",
"{",
"if",
"(",
"$",
"fileInfo",
"->",
"isDir",
"(",
")",
")",
"{",
"$",
"subDirectory",
"=",
"new",
"\\",
"FilesystemIterator",
"(",
"$",
"fileInfo",
"->",
"getRealPath",
"(",
")",
")",
";",
"$",
"this",
"->",
"buildFromSubDirectory",
"(",
"$",
"subDirectory",
")",
";",
"}",
"elseif",
"(",
"$",
"fileInfo",
"->",
"isFile",
"(",
")",
"&&",
"$",
"fileInfo",
"->",
"getExtension",
"(",
")",
"===",
"$",
"this",
"->",
"extension",
")",
"{",
"$",
"migration",
"=",
"UnitOfWorkFactory",
"::",
"buildFromSplFileInfo",
"(",
"$",
"fileInfo",
")",
";",
"$",
"this",
"->",
"add",
"(",
"$",
"migration",
")",
";",
"}",
"}",
"}"
] | Recursive build of the migrations
Recursion ends when files are located in the given filesystem iterator.
Otherwise the recursion steps into the directory.
@param \FilesystemIterator $directory The directory to build from
@throws \Bytepark\Component\Migration\Exception\UnitIsAlreadyPresentException
@throws \InvalidArgumentException | [
"Recursive",
"build",
"of",
"the",
"migrations"
] | 14d75f6978e257f456493c673175ca5d07b28c84 | https://github.com/bytepark/lib-migration/blob/14d75f6978e257f456493c673175ca5d07b28c84/src/Repository/Filesystem/Grouped.php#L107-L119 |
5,421 | thienhungho/yii2-term-management | src/modules/TermManage/controllers/TermController.php | TermController.findModel | protected function findModel($id)
{
if (($model = Term::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException(t('app', 'The requested page does not exist.'));
}
} | php | protected function findModel($id)
{
if (($model = Term::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException(t('app', 'The requested page does not exist.'));
}
} | [
"protected",
"function",
"findModel",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"(",
"$",
"model",
"=",
"Term",
"::",
"findOne",
"(",
"$",
"id",
")",
")",
"!==",
"null",
")",
"{",
"return",
"$",
"model",
";",
"}",
"else",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
"t",
"(",
"'app'",
",",
"'The requested page does not exist.'",
")",
")",
";",
"}",
"}"
] | Finds the Term model based on its primary key value.
If the model is not found, a 404 HTTP exception will be thrown.
@param integer $id
@return Term the loaded model
@throws NotFoundHttpException if the model cannot be found | [
"Finds",
"the",
"Term",
"model",
"based",
"on",
"its",
"primary",
"key",
"value",
".",
"If",
"the",
"model",
"is",
"not",
"found",
"a",
"404",
"HTTP",
"exception",
"will",
"be",
"thrown",
"."
] | 9bbc4f4de3837f30e8f968f7d9b6f8d892610270 | https://github.com/thienhungho/yii2-term-management/blob/9bbc4f4de3837f30e8f968f7d9b6f8d892610270/src/modules/TermManage/controllers/TermController.php#L280-L287 |
5,422 | kgilden/pager | src/Page.php | Page.getItemsWithOneExtra | private function getItemsWithOneExtra()
{
if (null === $this->itemsWithOneExtra) {
$this->itemsWithOneExtra = $this
->adapter
->getItems($this->getOffset(), $this->getLength() + 1)
;
}
return $this->itemsWithOneExtra;
} | php | private function getItemsWithOneExtra()
{
if (null === $this->itemsWithOneExtra) {
$this->itemsWithOneExtra = $this
->adapter
->getItems($this->getOffset(), $this->getLength() + 1)
;
}
return $this->itemsWithOneExtra;
} | [
"private",
"function",
"getItemsWithOneExtra",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"itemsWithOneExtra",
")",
"{",
"$",
"this",
"->",
"itemsWithOneExtra",
"=",
"$",
"this",
"->",
"adapter",
"->",
"getItems",
"(",
"$",
"this",
"->",
"getOffset",
"(",
")",
",",
"$",
"this",
"->",
"getLength",
"(",
")",
"+",
"1",
")",
";",
"}",
"return",
"$",
"this",
"->",
"itemsWithOneExtra",
";",
"}"
] | Gets items of this page as well as the 1-st item from the next page.
Doing it this way keeps us from having to run the expensive total item
count query in some scenarios.
@return array | [
"Gets",
"items",
"of",
"this",
"page",
"as",
"well",
"as",
"the",
"1",
"-",
"st",
"item",
"from",
"the",
"next",
"page",
".",
"Doing",
"it",
"this",
"way",
"keeps",
"us",
"from",
"having",
"to",
"run",
"the",
"expensive",
"total",
"item",
"count",
"query",
"in",
"some",
"scenarios",
"."
] | 50e25d4a208922077b174bec5f1b8e60630f9fff | https://github.com/kgilden/pager/blob/50e25d4a208922077b174bec5f1b8e60630f9fff/src/Page.php#L232-L242 |
5,423 | kgilden/pager | src/Page.php | Page.getPage | private function getPage($number)
{
return new self($this->adapter, $this->strategy, $this->perPage, $number);
} | php | private function getPage($number)
{
return new self($this->adapter, $this->strategy, $this->perPage, $number);
} | [
"private",
"function",
"getPage",
"(",
"$",
"number",
")",
"{",
"return",
"new",
"self",
"(",
"$",
"this",
"->",
"adapter",
",",
"$",
"this",
"->",
"strategy",
",",
"$",
"this",
"->",
"perPage",
",",
"$",
"number",
")",
";",
"}"
] | Creates a new page with the given number.
@param integer $number
@return Page | [
"Creates",
"a",
"new",
"page",
"with",
"the",
"given",
"number",
"."
] | 50e25d4a208922077b174bec5f1b8e60630f9fff | https://github.com/kgilden/pager/blob/50e25d4a208922077b174bec5f1b8e60630f9fff/src/Page.php#L251-L254 |
5,424 | HeroicTeam/m | Foundation/Collection.php | Collection.set | public function set($key, $value, $dot_syntax = true)
{
if ($dot_syntax === true) {
$paths = explode('.', $key);
$pathCount = count($paths);
$currentIteration = 0;
$node =& $this->_data;
foreach ($paths as $path) {
if (isset($node[$path])) {
$node =& $node[$path];
$currentIteration++;
} elseif($currentIteration < $pathCount) {
$node[$path] = array();
$node =& $node[$path];
$currentIteration++;
}
}
$node = $value;
} else {
$this->_data[$key] = $value;
}
return $this;
} | php | public function set($key, $value, $dot_syntax = true)
{
if ($dot_syntax === true) {
$paths = explode('.', $key);
$pathCount = count($paths);
$currentIteration = 0;
$node =& $this->_data;
foreach ($paths as $path) {
if (isset($node[$path])) {
$node =& $node[$path];
$currentIteration++;
} elseif($currentIteration < $pathCount) {
$node[$path] = array();
$node =& $node[$path];
$currentIteration++;
}
}
$node = $value;
} else {
$this->_data[$key] = $value;
}
return $this;
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"dot_syntax",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"dot_syntax",
"===",
"true",
")",
"{",
"$",
"paths",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"$",
"pathCount",
"=",
"count",
"(",
"$",
"paths",
")",
";",
"$",
"currentIteration",
"=",
"0",
";",
"$",
"node",
"=",
"&",
"$",
"this",
"->",
"_data",
";",
"foreach",
"(",
"$",
"paths",
"as",
"$",
"path",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"node",
"[",
"$",
"path",
"]",
")",
")",
"{",
"$",
"node",
"=",
"&",
"$",
"node",
"[",
"$",
"path",
"]",
";",
"$",
"currentIteration",
"++",
";",
"}",
"elseif",
"(",
"$",
"currentIteration",
"<",
"$",
"pathCount",
")",
"{",
"$",
"node",
"[",
"$",
"path",
"]",
"=",
"array",
"(",
")",
";",
"$",
"node",
"=",
"&",
"$",
"node",
"[",
"$",
"path",
"]",
";",
"$",
"currentIteration",
"++",
";",
"}",
"}",
"$",
"node",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_data",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Stores an item in the collection at the designated key.
Dot syntax can be used to nest data in the array.
@param string $key
@param mixed $value
@return \m\Foundation\Collection | [
"Stores",
"an",
"item",
"in",
"the",
"collection",
"at",
"the",
"designated",
"key",
".",
"Dot",
"syntax",
"can",
"be",
"used",
"to",
"nest",
"data",
"in",
"the",
"array",
"."
] | daa6d5956ee6c989379fe5fae39feccc59cf4add | https://github.com/HeroicTeam/m/blob/daa6d5956ee6c989379fe5fae39feccc59cf4add/Foundation/Collection.php#L38-L66 |
5,425 | HeroicTeam/m | Foundation/Collection.php | Collection.setMany | public function setMany(array $data)
{
foreach($data as $key => $value) {
$this->_data[$key] = $value;
}
return $this;
} | php | public function setMany(array $data)
{
foreach($data as $key => $value) {
$this->_data[$key] = $value;
}
return $this;
} | [
"public",
"function",
"setMany",
"(",
"array",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"_data",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Merges the given array of data with the collection data.
@param array $data
@return \m\Foundation\Collection | [
"Merges",
"the",
"given",
"array",
"of",
"data",
"with",
"the",
"collection",
"data",
"."
] | daa6d5956ee6c989379fe5fae39feccc59cf4add | https://github.com/HeroicTeam/m/blob/daa6d5956ee6c989379fe5fae39feccc59cf4add/Foundation/Collection.php#L74-L81 |
5,426 | HeroicTeam/m | Foundation/Collection.php | Collection.get | public function get($key, $default = null, $dot_syntax = true)
{
if ($dot_syntax === true) {
$paths = explode('.', $key);
$node =& $this->_data;
foreach ($paths as $path) {
if (!is_array($node) || !isset($node[$path])) {
// error occurred
return $default;
}
$node =& $node[$path];
}
return $node;
} else {
return isset($this->_data[$key]) ? $this->_data[$key] : $default;
}
} | php | public function get($key, $default = null, $dot_syntax = true)
{
if ($dot_syntax === true) {
$paths = explode('.', $key);
$node =& $this->_data;
foreach ($paths as $path) {
if (!is_array($node) || !isset($node[$path])) {
// error occurred
return $default;
}
$node =& $node[$path];
}
return $node;
} else {
return isset($this->_data[$key]) ? $this->_data[$key] : $default;
}
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
",",
"$",
"dot_syntax",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"dot_syntax",
"===",
"true",
")",
"{",
"$",
"paths",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"$",
"node",
"=",
"&",
"$",
"this",
"->",
"_data",
";",
"foreach",
"(",
"$",
"paths",
"as",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"node",
")",
"||",
"!",
"isset",
"(",
"$",
"node",
"[",
"$",
"path",
"]",
")",
")",
"{",
"// error occurred",
"return",
"$",
"default",
";",
"}",
"$",
"node",
"=",
"&",
"$",
"node",
"[",
"$",
"path",
"]",
";",
"}",
"return",
"$",
"node",
";",
"}",
"else",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"_data",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"this",
"->",
"_data",
"[",
"$",
"key",
"]",
":",
"$",
"default",
";",
"}",
"}"
] | Returns a single item from the collection data.
@param string $key
@return mixed | [
"Returns",
"a",
"single",
"item",
"from",
"the",
"collection",
"data",
"."
] | daa6d5956ee6c989379fe5fae39feccc59cf4add | https://github.com/HeroicTeam/m/blob/daa6d5956ee6c989379fe5fae39feccc59cf4add/Foundation/Collection.php#L101-L122 |
5,427 | chesszebra/standard-algebraic-notation | src/Notation.php | Notation.withTargetColumnIndex | public function withTargetColumnIndex(int $index): Notation
{
if (!$this->getTargetRow()) {
throw new RuntimeException('No row has been set.');
}
$notation = chr(97 + $index) . $this->getTargetRow();
return new self($notation);
} | php | public function withTargetColumnIndex(int $index): Notation
{
if (!$this->getTargetRow()) {
throw new RuntimeException('No row has been set.');
}
$notation = chr(97 + $index) . $this->getTargetRow();
return new self($notation);
} | [
"public",
"function",
"withTargetColumnIndex",
"(",
"int",
"$",
"index",
")",
":",
"Notation",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getTargetRow",
"(",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'No row has been set.'",
")",
";",
"}",
"$",
"notation",
"=",
"chr",
"(",
"97",
"+",
"$",
"index",
")",
".",
"$",
"this",
"->",
"getTargetRow",
"(",
")",
";",
"return",
"new",
"self",
"(",
"$",
"notation",
")",
";",
"}"
] | Duplicates the notation with a column based on an index from 0 to 7.
@param int $index The index of the column to use.
@return Notation
@throws InvalidArgumentException Thrown when an invalid SAN value is created.
@throws RuntimeException Thrown when no target row is set. | [
"Duplicates",
"the",
"notation",
"with",
"a",
"column",
"based",
"on",
"an",
"index",
"from",
"0",
"to",
"7",
"."
] | c09113b78117a878f8daa735abe30f4913769d51 | https://github.com/chesszebra/standard-algebraic-notation/blob/c09113b78117a878f8daa735abe30f4913769d51/src/Notation.php#L419-L428 |
5,428 | chesszebra/standard-algebraic-notation | src/Notation.php | Notation.withTargetRow | public function withTargetRow(int $row): Notation
{
$notation = $this->getTargetColumn() . $row;
return new self($notation);
} | php | public function withTargetRow(int $row): Notation
{
$notation = $this->getTargetColumn() . $row;
return new self($notation);
} | [
"public",
"function",
"withTargetRow",
"(",
"int",
"$",
"row",
")",
":",
"Notation",
"{",
"$",
"notation",
"=",
"$",
"this",
"->",
"getTargetColumn",
"(",
")",
".",
"$",
"row",
";",
"return",
"new",
"self",
"(",
"$",
"notation",
")",
";",
"}"
] | Duplicates the notation with a new row.
@param int $row A value between 1 and 8.
@return Notation
@throws InvalidArgumentException Thrown when an invalid SAN value is created. | [
"Duplicates",
"the",
"notation",
"with",
"a",
"new",
"row",
"."
] | c09113b78117a878f8daa735abe30f4913769d51 | https://github.com/chesszebra/standard-algebraic-notation/blob/c09113b78117a878f8daa735abe30f4913769d51/src/Notation.php#L447-L452 |
5,429 | franckysolo/octopush-sdk | src/Octopush/Api.php | Api.getCredit | public function getCredit()
{
$this->client->request('credit');
$response = $this->getResponse();
if ($response['error_code'] !== '000') {
return 0.00;
}
return (float) $response['credit'];
} | php | public function getCredit()
{
$this->client->request('credit');
$response = $this->getResponse();
if ($response['error_code'] !== '000') {
return 0.00;
}
return (float) $response['credit'];
} | [
"public",
"function",
"getCredit",
"(",
")",
"{",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'credit'",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"getResponse",
"(",
")",
";",
"if",
"(",
"$",
"response",
"[",
"'error_code'",
"]",
"!==",
"'000'",
")",
"{",
"return",
"0.00",
";",
"}",
"return",
"(",
"float",
")",
"$",
"response",
"[",
"'credit'",
"]",
";",
"}"
] | Retourne le solde sms en Euros.
@return float | [
"Retourne",
"le",
"solde",
"sms",
"en",
"Euros",
"."
] | 3797e53d51474a64b65fbf437e5dd46e288f2ef8 | https://github.com/franckysolo/octopush-sdk/blob/3797e53d51474a64b65fbf437e5dd46e288f2ef8/src/Octopush/Api.php#L64-L74 |
5,430 | kaecyra/app-common | src/Log/FilesystemLogger.php | FilesystemLogger.openLog | public function openLog() {
if ($this->file) {
$logDir = dirname($this->file);
if (!is_dir($logDir) || !file_exists($logDir)) {
@mkdir($logDir, 0755, true);
}
if (!file_exists($this->file)) {
$touched = touch($this->file);
if (!$touched) {
throw new \Exception("Unable to open log file '{$this->file}', could not create");
}
}
if (!is_writable($this->file)) {
throw new \Exception("Unable to open log file '{$this->file}', not writable");
}
$this->fr = fopen($this->file, 'a');
}
} | php | public function openLog() {
if ($this->file) {
$logDir = dirname($this->file);
if (!is_dir($logDir) || !file_exists($logDir)) {
@mkdir($logDir, 0755, true);
}
if (!file_exists($this->file)) {
$touched = touch($this->file);
if (!$touched) {
throw new \Exception("Unable to open log file '{$this->file}', could not create");
}
}
if (!is_writable($this->file)) {
throw new \Exception("Unable to open log file '{$this->file}', not writable");
}
$this->fr = fopen($this->file, 'a');
}
} | [
"public",
"function",
"openLog",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"file",
")",
"{",
"$",
"logDir",
"=",
"dirname",
"(",
"$",
"this",
"->",
"file",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"logDir",
")",
"||",
"!",
"file_exists",
"(",
"$",
"logDir",
")",
")",
"{",
"@",
"mkdir",
"(",
"$",
"logDir",
",",
"0755",
",",
"true",
")",
";",
"}",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"file",
")",
")",
"{",
"$",
"touched",
"=",
"touch",
"(",
"$",
"this",
"->",
"file",
")",
";",
"if",
"(",
"!",
"$",
"touched",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Unable to open log file '{$this->file}', could not create\"",
")",
";",
"}",
"}",
"if",
"(",
"!",
"is_writable",
"(",
"$",
"this",
"->",
"file",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Unable to open log file '{$this->file}', not writable\"",
")",
";",
"}",
"$",
"this",
"->",
"fr",
"=",
"fopen",
"(",
"$",
"this",
"->",
"file",
",",
"'a'",
")",
";",
"}",
"}"
] | Open log file for writing
Also closes currently open log file if needed.
@return void | [
"Open",
"log",
"file",
"for",
"writing"
] | 8dbcf70c575fb587614b45da8ec02d098e3e843b | https://github.com/kaecyra/app-common/blob/8dbcf70c575fb587614b45da8ec02d098e3e843b/src/Log/FilesystemLogger.php#L59-L79 |
5,431 | monomelodies/ornament | src/Annotate.php | Annotate.annotations | public function annotations()
{
static $annotations;
if (!isset($annotations)) {
$annotator = get_class($this);
if (strpos($annotator, '@anonymous')) {
$annotator = (new ReflectionClass($this))
->getParentClass()->name;
}
$reflector = new ReflectionClass($annotator);
$annotations['class'] = new Annotations($reflector);
$annotations['methods'] = [];
foreach ($reflector->getMethods() as $method) {
$annotations['methods'][$method->getName()]
= new Annotations($method);
}
foreach ($reflector->getProperties() as $property) {
$annotations['properties'][$property->getName()]
= new Annotations($property);
}
}
return $annotations;
} | php | public function annotations()
{
static $annotations;
if (!isset($annotations)) {
$annotator = get_class($this);
if (strpos($annotator, '@anonymous')) {
$annotator = (new ReflectionClass($this))
->getParentClass()->name;
}
$reflector = new ReflectionClass($annotator);
$annotations['class'] = new Annotations($reflector);
$annotations['methods'] = [];
foreach ($reflector->getMethods() as $method) {
$annotations['methods'][$method->getName()]
= new Annotations($method);
}
foreach ($reflector->getProperties() as $property) {
$annotations['properties'][$property->getName()]
= new Annotations($property);
}
}
return $annotations;
} | [
"public",
"function",
"annotations",
"(",
")",
"{",
"static",
"$",
"annotations",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"annotations",
")",
")",
"{",
"$",
"annotator",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"annotator",
",",
"'@anonymous'",
")",
")",
"{",
"$",
"annotator",
"=",
"(",
"new",
"ReflectionClass",
"(",
"$",
"this",
")",
")",
"->",
"getParentClass",
"(",
")",
"->",
"name",
";",
"}",
"$",
"reflector",
"=",
"new",
"ReflectionClass",
"(",
"$",
"annotator",
")",
";",
"$",
"annotations",
"[",
"'class'",
"]",
"=",
"new",
"Annotations",
"(",
"$",
"reflector",
")",
";",
"$",
"annotations",
"[",
"'methods'",
"]",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"reflector",
"->",
"getMethods",
"(",
")",
"as",
"$",
"method",
")",
"{",
"$",
"annotations",
"[",
"'methods'",
"]",
"[",
"$",
"method",
"->",
"getName",
"(",
")",
"]",
"=",
"new",
"Annotations",
"(",
"$",
"method",
")",
";",
"}",
"foreach",
"(",
"$",
"reflector",
"->",
"getProperties",
"(",
")",
"as",
"$",
"property",
")",
"{",
"$",
"annotations",
"[",
"'properties'",
"]",
"[",
"$",
"property",
"->",
"getName",
"(",
")",
"]",
"=",
"new",
"Annotations",
"(",
"$",
"property",
")",
";",
"}",
"}",
"return",
"$",
"annotations",
";",
"}"
] | Helper method to get this object's annotations. The annotations are
cached for speed.
@return array An array with `class`, `methods` and `properties` entries
containing an Annotations object (for classes) or a hash of
name/Annotations object pairs (for methods/properties).
@see zpt\anno\Annotations | [
"Helper",
"method",
"to",
"get",
"this",
"object",
"s",
"annotations",
".",
"The",
"annotations",
"are",
"cached",
"for",
"speed",
"."
] | d7d070ad11f5731be141cf55c2756accaaf51402 | https://github.com/monomelodies/ornament/blob/d7d070ad11f5731be141cf55c2756accaaf51402/src/Annotate.php#L19-L41 |
5,432 | PSESD/chms-common | lib/Auth/Acl.php | Acl.isAllowedModel | public function isAllowedModel($modelClass, $privilege = null)
{
return $this->isAllowed($this->modelResourceGenerator($modelClass), $privilege);
} | php | public function isAllowedModel($modelClass, $privilege = null)
{
return $this->isAllowed($this->modelResourceGenerator($modelClass), $privilege);
} | [
"public",
"function",
"isAllowedModel",
"(",
"$",
"modelClass",
",",
"$",
"privilege",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"isAllowed",
"(",
"$",
"this",
"->",
"modelResourceGenerator",
"(",
"$",
"modelClass",
")",
",",
"$",
"privilege",
")",
";",
"}"
] | Check for access to a model
@param string $modelClass
@param string|array $privilege
@return boolean | [
"Check",
"for",
"access",
"to",
"a",
"model"
] | dba29f95de57cb6b1113c169ccb911152b18e288 | https://github.com/PSESD/chms-common/blob/dba29f95de57cb6b1113c169ccb911152b18e288/lib/Auth/Acl.php#L122-L125 |
5,433 | PSESD/chms-common | lib/Auth/Acl.php | Acl.isAllowedField | public function isAllowedField($modelClass, $fieldName, $privilege = null)
{
return $this->isAllowed($this->fieldResourceGenerator($modelClass, $fieldName), $privilege);
} | php | public function isAllowedField($modelClass, $fieldName, $privilege = null)
{
return $this->isAllowed($this->fieldResourceGenerator($modelClass, $fieldName), $privilege);
} | [
"public",
"function",
"isAllowedField",
"(",
"$",
"modelClass",
",",
"$",
"fieldName",
",",
"$",
"privilege",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"isAllowed",
"(",
"$",
"this",
"->",
"fieldResourceGenerator",
"(",
"$",
"modelClass",
",",
"$",
"fieldName",
")",
",",
"$",
"privilege",
")",
";",
"}"
] | Check for access to a model's field
@param string $modelClass
@param string $fieldName
@param string|array $privilege
@return boolean | [
"Check",
"for",
"access",
"to",
"a",
"model",
"s",
"field"
] | dba29f95de57cb6b1113c169ccb911152b18e288 | https://github.com/PSESD/chms-common/blob/dba29f95de57cb6b1113c169ccb911152b18e288/lib/Auth/Acl.php#L135-L138 |
5,434 | PSESD/chms-common | lib/Auth/Acl.php | Acl.isAllowed | public function isAllowed($resource = null, $privilege = null)
{
if (is_array($privilege)) {
foreach ($privilege as $privilegeSingular) {
if ($this->isAllowed($resource, $privilegeSingular)) {
return true;
}
}
return false;
}
try {
$result = $this->getContextualAcl()->isAllowed($this->getContextId(), $resource, $privilege);
} catch (InvalidArgumentException $e) {
return false;
}
return $result;
} | php | public function isAllowed($resource = null, $privilege = null)
{
if (is_array($privilege)) {
foreach ($privilege as $privilegeSingular) {
if ($this->isAllowed($resource, $privilegeSingular)) {
return true;
}
}
return false;
}
try {
$result = $this->getContextualAcl()->isAllowed($this->getContextId(), $resource, $privilege);
} catch (InvalidArgumentException $e) {
return false;
}
return $result;
} | [
"public",
"function",
"isAllowed",
"(",
"$",
"resource",
"=",
"null",
",",
"$",
"privilege",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"privilege",
")",
")",
"{",
"foreach",
"(",
"$",
"privilege",
"as",
"$",
"privilegeSingular",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isAllowed",
"(",
"$",
"resource",
",",
"$",
"privilegeSingular",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}",
"try",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getContextualAcl",
"(",
")",
"->",
"isAllowed",
"(",
"$",
"this",
"->",
"getContextId",
"(",
")",
",",
"$",
"resource",
",",
"$",
"privilege",
")",
";",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Check for a access to a resource
@param Zend\Permissions\Acl\Resource\ResourceInterface|string $resource
@param string|array $privilege
@return boolean | [
"Check",
"for",
"a",
"access",
"to",
"a",
"resource"
] | dba29f95de57cb6b1113c169ccb911152b18e288 | https://github.com/PSESD/chms-common/blob/dba29f95de57cb6b1113c169ccb911152b18e288/lib/Auth/Acl.php#L147-L163 |
5,435 | PSESD/chms-common | lib/Auth/Acl.php | Acl.getContextualAcl | public function getContextualAcl()
{
$acl = $this->getRules();
if (!$acl->hasRole($this->getContextId())) {
$contextRoles = $this->getContext()->getRoles();
if ($contextRoles instanceof RoleBucket) {
$contextRoles = $contextRoles->toArray();
}
$acl->addRole(new Role($this->getContextId()), $contextRoles);
}
return $acl;
} | php | public function getContextualAcl()
{
$acl = $this->getRules();
if (!$acl->hasRole($this->getContextId())) {
$contextRoles = $this->getContext()->getRoles();
if ($contextRoles instanceof RoleBucket) {
$contextRoles = $contextRoles->toArray();
}
$acl->addRole(new Role($this->getContextId()), $contextRoles);
}
return $acl;
} | [
"public",
"function",
"getContextualAcl",
"(",
")",
"{",
"$",
"acl",
"=",
"$",
"this",
"->",
"getRules",
"(",
")",
";",
"if",
"(",
"!",
"$",
"acl",
"->",
"hasRole",
"(",
"$",
"this",
"->",
"getContextId",
"(",
")",
")",
")",
"{",
"$",
"contextRoles",
"=",
"$",
"this",
"->",
"getContext",
"(",
")",
"->",
"getRoles",
"(",
")",
";",
"if",
"(",
"$",
"contextRoles",
"instanceof",
"RoleBucket",
")",
"{",
"$",
"contextRoles",
"=",
"$",
"contextRoles",
"->",
"toArray",
"(",
")",
";",
"}",
"$",
"acl",
"->",
"addRole",
"(",
"new",
"Role",
"(",
"$",
"this",
"->",
"getContextId",
"(",
")",
")",
",",
"$",
"contextRoles",
")",
";",
"}",
"return",
"$",
"acl",
";",
"}"
] | Set up ACL rules with the current context
@return AclRules | [
"Set",
"up",
"ACL",
"rules",
"with",
"the",
"current",
"context"
] | dba29f95de57cb6b1113c169ccb911152b18e288 | https://github.com/PSESD/chms-common/blob/dba29f95de57cb6b1113c169ccb911152b18e288/lib/Auth/Acl.php#L171-L182 |
5,436 | PSESD/chms-common | lib/Auth/Acl.php | Acl.getContext | public function getContext()
{
if (!isset($this->currentContext)) {
$this->initiateContext();
}
return $this->contexts[$this->currentContext];
} | php | public function getContext()
{
if (!isset($this->currentContext)) {
$this->initiateContext();
}
return $this->contexts[$this->currentContext];
} | [
"public",
"function",
"getContext",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"currentContext",
")",
")",
"{",
"$",
"this",
"->",
"initiateContext",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"contexts",
"[",
"$",
"this",
"->",
"currentContext",
"]",
";",
"}"
] | Get the current context
@return AclContextContract | [
"Get",
"the",
"current",
"context"
] | dba29f95de57cb6b1113c169ccb911152b18e288 | https://github.com/PSESD/chms-common/blob/dba29f95de57cb6b1113c169ccb911152b18e288/lib/Auth/Acl.php#L223-L229 |
5,437 | PSESD/chms-common | lib/Auth/Acl.php | Acl.initiateContext | private function initiateContext(Model $modelObject = null)
{
$context = $this->getContextFromAuth($modelObject);
$this->registerContext($context);
$this->currentContext = $context->getId();
//\dump($context->getRoles()->toArray());exit;
return $context;
} | php | private function initiateContext(Model $modelObject = null)
{
$context = $this->getContextFromAuth($modelObject);
$this->registerContext($context);
$this->currentContext = $context->getId();
//\dump($context->getRoles()->toArray());exit;
return $context;
} | [
"private",
"function",
"initiateContext",
"(",
"Model",
"$",
"modelObject",
"=",
"null",
")",
"{",
"$",
"context",
"=",
"$",
"this",
"->",
"getContextFromAuth",
"(",
"$",
"modelObject",
")",
";",
"$",
"this",
"->",
"registerContext",
"(",
"$",
"context",
")",
";",
"$",
"this",
"->",
"currentContext",
"=",
"$",
"context",
"->",
"getId",
"(",
")",
";",
"//\\dump($context->getRoles()->toArray());exit;",
"return",
"$",
"context",
";",
"}"
] | Initiate a context
@param Model $modelObject Optional protected model
@return AclContextContract | [
"Initiate",
"a",
"context"
] | dba29f95de57cb6b1113c169ccb911152b18e288 | https://github.com/PSESD/chms-common/blob/dba29f95de57cb6b1113c169ccb911152b18e288/lib/Auth/Acl.php#L247-L254 |
5,438 | PSESD/chms-common | lib/Auth/Acl.php | Acl.getRules | public function getRules($useCache = true)
{
if (!$useCache) { // || env('APP_ENV') !== 'production'
return $this->loadRules();
}
if ($this->aclRulesCache === null) {
$hash = sha1(serialize($this->config));
$key = md5(__CLASS__.__FUNCTION__);
$value = Cache::get($key, false);
if ($value === false || $value['hash'] !== $hash) {
$value = [
'hash' => $hash,
'acl' => $this->loadRules()
];
Cache::forever($key, $value);
}
$this->aclRulesCache = $value['acl'];
}
return $this->aclRulesCache;
} | php | public function getRules($useCache = true)
{
if (!$useCache) { // || env('APP_ENV') !== 'production'
return $this->loadRules();
}
if ($this->aclRulesCache === null) {
$hash = sha1(serialize($this->config));
$key = md5(__CLASS__.__FUNCTION__);
$value = Cache::get($key, false);
if ($value === false || $value['hash'] !== $hash) {
$value = [
'hash' => $hash,
'acl' => $this->loadRules()
];
Cache::forever($key, $value);
}
$this->aclRulesCache = $value['acl'];
}
return $this->aclRulesCache;
} | [
"public",
"function",
"getRules",
"(",
"$",
"useCache",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"useCache",
")",
"{",
"// || env('APP_ENV') !== 'production'",
"return",
"$",
"this",
"->",
"loadRules",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"aclRulesCache",
"===",
"null",
")",
"{",
"$",
"hash",
"=",
"sha1",
"(",
"serialize",
"(",
"$",
"this",
"->",
"config",
")",
")",
";",
"$",
"key",
"=",
"md5",
"(",
"__CLASS__",
".",
"__FUNCTION__",
")",
";",
"$",
"value",
"=",
"Cache",
"::",
"get",
"(",
"$",
"key",
",",
"false",
")",
";",
"if",
"(",
"$",
"value",
"===",
"false",
"||",
"$",
"value",
"[",
"'hash'",
"]",
"!==",
"$",
"hash",
")",
"{",
"$",
"value",
"=",
"[",
"'hash'",
"=>",
"$",
"hash",
",",
"'acl'",
"=>",
"$",
"this",
"->",
"loadRules",
"(",
")",
"]",
";",
"Cache",
"::",
"forever",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"$",
"this",
"->",
"aclRulesCache",
"=",
"$",
"value",
"[",
"'acl'",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"aclRulesCache",
";",
"}"
] | Get the ACL object; use cache when possible
@param boolean $useCache
@return AclRules | [
"Get",
"the",
"ACL",
"object",
";",
"use",
"cache",
"when",
"possible"
] | dba29f95de57cb6b1113c169ccb911152b18e288 | https://github.com/PSESD/chms-common/blob/dba29f95de57cb6b1113c169ccb911152b18e288/lib/Auth/Acl.php#L294-L313 |
5,439 | wpfulcrum/foundation | src/Foundation/Ajax.php | AJAX.ajaxResponseHandler | protected function ajaxResponseHandler()
{
echo json_encode([
'success' => $this->errorMessage ? 0 : 1,
'errorMessage' => $this->errorMessage,
'errorCode' => $this->errorCode,
'data' => $this->errorMessage ? '' : $this->dataPacket,
]);
die();
} | php | protected function ajaxResponseHandler()
{
echo json_encode([
'success' => $this->errorMessage ? 0 : 1,
'errorMessage' => $this->errorMessage,
'errorCode' => $this->errorCode,
'data' => $this->errorMessage ? '' : $this->dataPacket,
]);
die();
} | [
"protected",
"function",
"ajaxResponseHandler",
"(",
")",
"{",
"echo",
"json_encode",
"(",
"[",
"'success'",
"=>",
"$",
"this",
"->",
"errorMessage",
"?",
"0",
":",
"1",
",",
"'errorMessage'",
"=>",
"$",
"this",
"->",
"errorMessage",
",",
"'errorCode'",
"=>",
"$",
"this",
"->",
"errorCode",
",",
"'data'",
"=>",
"$",
"this",
"->",
"errorMessage",
"?",
"''",
":",
"$",
"this",
"->",
"dataPacket",
",",
"]",
")",
";",
"die",
"(",
")",
";",
"}"
] | AJAX Response Handler - Builds the response and returns it to the JavaScript
@since 3.0.0
@return null | [
"AJAX",
"Response",
"Handler",
"-",
"Builds",
"the",
"response",
"and",
"returns",
"it",
"to",
"the",
"JavaScript"
] | a9655d8fa3bcc4b9d99586bb84a9f36dfa63ed56 | https://github.com/wpfulcrum/foundation/blob/a9655d8fa3bcc4b9d99586bb84a9f36dfa63ed56/src/Foundation/Ajax.php#L98-L108 |
5,440 | wpfulcrum/foundation | src/Foundation/Ajax.php | AJAX.initProperties | protected function initProperties()
{
$this->errorMessage = '';
array_walk($this->config->dataPacket, [$this, 'initDataPacket']);
$this->errorCode = 0;
} | php | protected function initProperties()
{
$this->errorMessage = '';
array_walk($this->config->dataPacket, [$this, 'initDataPacket']);
$this->errorCode = 0;
} | [
"protected",
"function",
"initProperties",
"(",
")",
"{",
"$",
"this",
"->",
"errorMessage",
"=",
"''",
";",
"array_walk",
"(",
"$",
"this",
"->",
"config",
"->",
"dataPacket",
",",
"[",
"$",
"this",
",",
"'initDataPacket'",
"]",
")",
";",
"$",
"this",
"->",
"errorCode",
"=",
"0",
";",
"}"
] | Initialize the properties
@since 3.0.0
@return null | [
"Initialize",
"the",
"properties"
] | a9655d8fa3bcc4b9d99586bb84a9f36dfa63ed56 | https://github.com/wpfulcrum/foundation/blob/a9655d8fa3bcc4b9d99586bb84a9f36dfa63ed56/src/Foundation/Ajax.php#L131-L136 |
5,441 | wpfulcrum/foundation | src/Foundation/Ajax.php | AJAX.initDataPacket | protected function initDataPacket($filter, $key)
{
if (!array_key_exists($key, $_POST)) {
$this->errorMessage = $this->config->messages[$key];
$this->ajax_response_handler();
}
$this->dataPacket[$key] = $filter($_POST[$key]);
} | php | protected function initDataPacket($filter, $key)
{
if (!array_key_exists($key, $_POST)) {
$this->errorMessage = $this->config->messages[$key];
$this->ajax_response_handler();
}
$this->dataPacket[$key] = $filter($_POST[$key]);
} | [
"protected",
"function",
"initDataPacket",
"(",
"$",
"filter",
",",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"_POST",
")",
")",
"{",
"$",
"this",
"->",
"errorMessage",
"=",
"$",
"this",
"->",
"config",
"->",
"messages",
"[",
"$",
"key",
"]",
";",
"$",
"this",
"->",
"ajax_response_handler",
"(",
")",
";",
"}",
"$",
"this",
"->",
"dataPacket",
"[",
"$",
"key",
"]",
"=",
"$",
"filter",
"(",
"$",
"_POST",
"[",
"$",
"key",
"]",
")",
";",
"}"
] | Initialize data packet
@since 3.0.0
@param string $filter
@param string $key
@return null | [
"Initialize",
"data",
"packet"
] | a9655d8fa3bcc4b9d99586bb84a9f36dfa63ed56 | https://github.com/wpfulcrum/foundation/blob/a9655d8fa3bcc4b9d99586bb84a9f36dfa63ed56/src/Foundation/Ajax.php#L148-L155 |
5,442 | Celarius/nofuzz-framework | src/Helpers/EWT.php | EWT.decode | public static function decode(string $data, string $secret )
{
# Make a HASH of the secret
$secret = openssl_digest($secret,'sha256');
$b64 = static::base64url_decode($data);
$ewt = json_decode($b64,true);
$payload = openssl_decrypt($ewt['p'], $ewt['a'], $secret, 0, $ewt['i']);
# Verify signature - if fail return null
if ( strcasecmp(static::sign($payload,$secret,$ewt['h']),$ewt['s'])!=0) {
return null;
}
return $payload;
} | php | public static function decode(string $data, string $secret )
{
# Make a HASH of the secret
$secret = openssl_digest($secret,'sha256');
$b64 = static::base64url_decode($data);
$ewt = json_decode($b64,true);
$payload = openssl_decrypt($ewt['p'], $ewt['a'], $secret, 0, $ewt['i']);
# Verify signature - if fail return null
if ( strcasecmp(static::sign($payload,$secret,$ewt['h']),$ewt['s'])!=0) {
return null;
}
return $payload;
} | [
"public",
"static",
"function",
"decode",
"(",
"string",
"$",
"data",
",",
"string",
"$",
"secret",
")",
"{",
"# Make a HASH of the secret",
"$",
"secret",
"=",
"openssl_digest",
"(",
"$",
"secret",
",",
"'sha256'",
")",
";",
"$",
"b64",
"=",
"static",
"::",
"base64url_decode",
"(",
"$",
"data",
")",
";",
"$",
"ewt",
"=",
"json_decode",
"(",
"$",
"b64",
",",
"true",
")",
";",
"$",
"payload",
"=",
"openssl_decrypt",
"(",
"$",
"ewt",
"[",
"'p'",
"]",
",",
"$",
"ewt",
"[",
"'a'",
"]",
",",
"$",
"secret",
",",
"0",
",",
"$",
"ewt",
"[",
"'i'",
"]",
")",
";",
"# Verify signature - if fail return null",
"if",
"(",
"strcasecmp",
"(",
"static",
"::",
"sign",
"(",
"$",
"payload",
",",
"$",
"secret",
",",
"$",
"ewt",
"[",
"'h'",
"]",
")",
",",
"$",
"ewt",
"[",
"'s'",
"]",
")",
"!=",
"0",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"payload",
";",
"}"
] | Decode an EWT, returning the payload
@param string $data The encrypted EWT base64 string
@param string $secret Secret password used when encrypting
@return string|null | [
"Decode",
"an",
"EWT",
"returning",
"the",
"payload"
] | 867c5150baa431e8f800624a26ba80e95eebd4e5 | https://github.com/Celarius/nofuzz-framework/blob/867c5150baa431e8f800624a26ba80e95eebd4e5/src/Helpers/EWT.php#L109-L125 |
5,443 | Celarius/nofuzz-framework | src/Helpers/EWT.php | EWT.base64url_decode | public static function base64url_decode($input)
{
$remainder = strlen($input) % 4;
if ($remainder) {
$padlen = 4 - $remainder;
$input .= str_repeat('=', $padlen);
}
return base64_decode(strtr($input, '-_', '+/'));
} | php | public static function base64url_decode($input)
{
$remainder = strlen($input) % 4;
if ($remainder) {
$padlen = 4 - $remainder;
$input .= str_repeat('=', $padlen);
}
return base64_decode(strtr($input, '-_', '+/'));
} | [
"public",
"static",
"function",
"base64url_decode",
"(",
"$",
"input",
")",
"{",
"$",
"remainder",
"=",
"strlen",
"(",
"$",
"input",
")",
"%",
"4",
";",
"if",
"(",
"$",
"remainder",
")",
"{",
"$",
"padlen",
"=",
"4",
"-",
"$",
"remainder",
";",
"$",
"input",
".=",
"str_repeat",
"(",
"'='",
",",
"$",
"padlen",
")",
";",
"}",
"return",
"base64_decode",
"(",
"strtr",
"(",
"$",
"input",
",",
"'-_'",
",",
"'+/'",
")",
")",
";",
"}"
] | URL compatible Base64 Decode
@param string $input A base64 encoded string
@return mixed Decoded data | [
"URL",
"compatible",
"Base64",
"Decode"
] | 867c5150baa431e8f800624a26ba80e95eebd4e5 | https://github.com/Celarius/nofuzz-framework/blob/867c5150baa431e8f800624a26ba80e95eebd4e5/src/Helpers/EWT.php#L146-L155 |
5,444 | pokap/pool-dbm | src/Pok/PoolDBM/Mapping/Driver/AnnotationDriver.php | AnnotationDriver.create | public static function create($paths = array(), Reader $reader = null)
{
if ($reader == null) {
$reader = new AnnotationReader();
}
return new self($reader, $paths);
} | php | public static function create($paths = array(), Reader $reader = null)
{
if ($reader == null) {
$reader = new AnnotationReader();
}
return new self($reader, $paths);
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"paths",
"=",
"array",
"(",
")",
",",
"Reader",
"$",
"reader",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"reader",
"==",
"null",
")",
"{",
"$",
"reader",
"=",
"new",
"AnnotationReader",
"(",
")",
";",
"}",
"return",
"new",
"self",
"(",
"$",
"reader",
",",
"$",
"paths",
")",
";",
"}"
] | Factory method for the Annotation Driver
@param array|string $paths
@param Reader $reader
@return AnnotationDriver | [
"Factory",
"method",
"for",
"the",
"Annotation",
"Driver"
] | cce32d7cb5f13f42c358c8140b2f97ddf1d9435a | https://github.com/pokap/pool-dbm/blob/cce32d7cb5f13f42c358c8140b2f97ddf1d9435a/src/Pok/PoolDBM/Mapping/Driver/AnnotationDriver.php#L64-L71 |
5,445 | GovTribe/laravel-kinvey | src/GovTribe/LaravelKinvey/LaravelKinveyServiceProvider.php | LaravelKinveyServiceProvider.buildKinveyAPIClient | public function buildKinveyAPIClient()
{
require __DIR__ . '/Client/Service/APIV2Description.php';
require __DIR__ . '/Client/Service/ServiceBuilder.php';
$client = ServiceBuilder::factory($serviceBuilder)->get('KinveyClient');
$client->setDescription(ServiceDescription::factory($APIV2Description));
return $client;
} | php | public function buildKinveyAPIClient()
{
require __DIR__ . '/Client/Service/APIV2Description.php';
require __DIR__ . '/Client/Service/ServiceBuilder.php';
$client = ServiceBuilder::factory($serviceBuilder)->get('KinveyClient');
$client->setDescription(ServiceDescription::factory($APIV2Description));
return $client;
} | [
"public",
"function",
"buildKinveyAPIClient",
"(",
")",
"{",
"require",
"__DIR__",
".",
"'/Client/Service/APIV2Description.php'",
";",
"require",
"__DIR__",
".",
"'/Client/Service/ServiceBuilder.php'",
";",
"$",
"client",
"=",
"ServiceBuilder",
"::",
"factory",
"(",
"$",
"serviceBuilder",
")",
"->",
"get",
"(",
"'KinveyClient'",
")",
";",
"$",
"client",
"->",
"setDescription",
"(",
"ServiceDescription",
"::",
"factory",
"(",
"$",
"APIV2Description",
")",
")",
";",
"return",
"$",
"client",
";",
"}"
] | Build the Kinvey API client.
@return Guzzle\Service\Client | [
"Build",
"the",
"Kinvey",
"API",
"client",
"."
] | 8a25dafdf80a933384dfcfe8b70b0a7663fe9289 | https://github.com/GovTribe/laravel-kinvey/blob/8a25dafdf80a933384dfcfe8b70b0a7663fe9289/src/GovTribe/LaravelKinvey/LaravelKinveyServiceProvider.php#L55-L64 |
5,446 | SocietyCMS/Core | Console/Demo/DemoMode.php | DemoMode.enable | public function enable(Command $command)
{
$command->call('down');
foreach ($this->scripts as $script) {
try {
$this->app->make($script)->fire($command);
} catch (\Exception $e) {
$command->error($e->getMessage());
return false;
}
}
$command->call('up');
return true;
} | php | public function enable(Command $command)
{
$command->call('down');
foreach ($this->scripts as $script) {
try {
$this->app->make($script)->fire($command);
} catch (\Exception $e) {
$command->error($e->getMessage());
return false;
}
}
$command->call('up');
return true;
} | [
"public",
"function",
"enable",
"(",
"Command",
"$",
"command",
")",
"{",
"$",
"command",
"->",
"call",
"(",
"'down'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"scripts",
"as",
"$",
"script",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"$",
"script",
")",
"->",
"fire",
"(",
"$",
"command",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"command",
"->",
"error",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"}",
"$",
"command",
"->",
"call",
"(",
"'up'",
")",
";",
"return",
"true",
";",
"}"
] | Fire demo scripts.
@param Command $command
@return bool | [
"Fire",
"demo",
"scripts",
"."
] | fb6be1b1dd46c89a976c02feb998e9af01ddca54 | https://github.com/SocietyCMS/Core/blob/fb6be1b1dd46c89a976c02feb998e9af01ddca54/Console/Demo/DemoMode.php#L48-L65 |
5,447 | marando/phpSOFA | src/Marando/IAU/iauPr00.php | iauPr00.Pr00 | public static function Pr00($date1, $date2, &$dpsipr, &$depspr) {
$t;
/* Precession and obliquity corrections (radians per century) */
$PRECOR = -0.29965 * DAS2R;
$OBLCOR = -0.02524 * DAS2R;
/* Interval between fundamental epoch J2000.0 and given date (JC). */
$t = (($date1 - DJ00) + $date2) / DJC;
/* Precession rate contributions with respect to IAU 1976/80. */
$dpsipr = $PRECOR * $t;
$depspr = $OBLCOR * $t;
return;
} | php | public static function Pr00($date1, $date2, &$dpsipr, &$depspr) {
$t;
/* Precession and obliquity corrections (radians per century) */
$PRECOR = -0.29965 * DAS2R;
$OBLCOR = -0.02524 * DAS2R;
/* Interval between fundamental epoch J2000.0 and given date (JC). */
$t = (($date1 - DJ00) + $date2) / DJC;
/* Precession rate contributions with respect to IAU 1976/80. */
$dpsipr = $PRECOR * $t;
$depspr = $OBLCOR * $t;
return;
} | [
"public",
"static",
"function",
"Pr00",
"(",
"$",
"date1",
",",
"$",
"date2",
",",
"&",
"$",
"dpsipr",
",",
"&",
"$",
"depspr",
")",
"{",
"$",
"t",
";",
"/* Precession and obliquity corrections (radians per century) */",
"$",
"PRECOR",
"=",
"-",
"0.29965",
"*",
"DAS2R",
";",
"$",
"OBLCOR",
"=",
"-",
"0.02524",
"*",
"DAS2R",
";",
"/* Interval between fundamental epoch J2000.0 and given date (JC). */",
"$",
"t",
"=",
"(",
"(",
"$",
"date1",
"-",
"DJ00",
")",
"+",
"$",
"date2",
")",
"/",
"DJC",
";",
"/* Precession rate contributions with respect to IAU 1976/80. */",
"$",
"dpsipr",
"=",
"$",
"PRECOR",
"*",
"$",
"t",
";",
"$",
"depspr",
"=",
"$",
"OBLCOR",
"*",
"$",
"t",
";",
"return",
";",
"}"
] | - - - - - - - -
i a u P r 0 0
- - - - - - - -
Precession-rate part of the IAU 2000 precession-nutation models
(part of MHB2000).
This function is part of the International Astronomical Union's
SOFA (Standards Of Fundamental Astronomy) software collection.
Status: canonical model.
Given:
date1,date2 double TT as a 2-part Julian Date (Note 1)
Returned:
dpsipr,depspr double precession corrections (Notes 2,3)
Notes:
1) The TT date date1+date2 is a Julian Date, apportioned in any
convenient way between the two arguments. For example,
JD(TT)=2450123.7 could be expressed in any of these ways,
among others:
date1 date2
2450123.7 0.0 (JD method)
2451545.0 -1421.3 (J2000 method)
2400000.5 50123.2 (MJD method)
2450123.5 0.2 (date & time method)
The JD method is the most natural and convenient to use in
cases where the loss of several decimal digits of resolution
is acceptable. The J2000 method is best matched to the way
the argument is handled internally and will deliver the
optimum resolution. The MJD method and the date & time methods
are both good compromises between resolution and convenience.
2) The precession adjustments are expressed as "nutation
components", corrections in longitude and obliquity with respect
to the J2000.0 equinox and ecliptic.
3) Although the precession adjustments are stated to be with respect
to Lieske et al. (1977), the MHB2000 model does not specify which
set of Euler angles are to be used and how the adjustments are to
be applied. The most literal and straightforward procedure is to
adopt the 4-rotation epsilon_0, psi_A, omega_A, xi_A option, and
to add dpsipr to psi_A and depspr to both omega_A and eps_A.
4) This is an implementation of one aspect of the IAU 2000A nutation
model, formally adopted by the IAU General Assembly in 2000,
namely MHB2000 (Mathews et al. 2002).
References:
Lieske, J.H., Lederle, T., Fricke, W. & Morando, B., "Expressions
for the precession quantities based upon the IAU (1976) System of
Astronomical Constants", Astron.Astrophys., 58, 1-16 (1977)
Mathews, P.M., Herring, T.A., Buffet, B.A., "Modeling of nutation
and precession New nutation series for nonrigid Earth and
insights into the Earth's interior", J.Geophys.Res., 107, B4,
2002. The MHB2000 code itself was obtained on 9th September 2002
from ftp://maia.usno.navy.mil/conv2000/chapter5/IAU2000A.
Wallace, P.T., "Software for Implementing the IAU 2000
Resolutions", in IERS Workshop 5.1 (2002).
This revision: 2013 June 18
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end. | [
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"P",
"r",
"0",
"0",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
] | 757fa49fe335ae1210eaa7735473fd4388b13f07 | https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauPr00.php#L83-L98 |
5,448 | seeren/view | src/Template/XMLTemplate.php | XMLTemplate.appendTo | protected final function appendTo(
SimpleXMLElement $parent,
SimpleXMLElement $child): SimpleXMLElement
{
$dom = dom_import_simplexml($parent);
$dom->appendChild(
$dom->ownerDocument->importNode(dom_import_simplexml($child),
true));
return $parent;
} | php | protected final function appendTo(
SimpleXMLElement $parent,
SimpleXMLElement $child): SimpleXMLElement
{
$dom = dom_import_simplexml($parent);
$dom->appendChild(
$dom->ownerDocument->importNode(dom_import_simplexml($child),
true));
return $parent;
} | [
"protected",
"final",
"function",
"appendTo",
"(",
"SimpleXMLElement",
"$",
"parent",
",",
"SimpleXMLElement",
"$",
"child",
")",
":",
"SimpleXMLElement",
"{",
"$",
"dom",
"=",
"dom_import_simplexml",
"(",
"$",
"parent",
")",
";",
"$",
"dom",
"->",
"appendChild",
"(",
"$",
"dom",
"->",
"ownerDocument",
"->",
"importNode",
"(",
"dom_import_simplexml",
"(",
"$",
"child",
")",
",",
"true",
")",
")",
";",
"return",
"$",
"parent",
";",
"}"
] | Append a SimpleXmlElement
@param SimpleXMLElement $parent parent node
@param SimpleXMLElement $child child node
@return SimpleXMLElement parent | [
"Append",
"a",
"SimpleXmlElement"
] | 7c5feb9082d1f0f245ea16789c2bf3790dffe647 | https://github.com/seeren/view/blob/7c5feb9082d1f0f245ea16789c2bf3790dffe647/src/Template/XMLTemplate.php#L55-L64 |
5,449 | seeren/view | src/Template/XMLTemplate.php | XMLTemplate.appendXMLTo | protected final function appendXMLTo(
SimpleXMLElement $parent,
string $child): SimpleXMLElement
{
return $this->appendTo(
$parent,
simplexml_load_string(str_replace("\n", "\n\t", $child)));
} | php | protected final function appendXMLTo(
SimpleXMLElement $parent,
string $child): SimpleXMLElement
{
return $this->appendTo(
$parent,
simplexml_load_string(str_replace("\n", "\n\t", $child)));
} | [
"protected",
"final",
"function",
"appendXMLTo",
"(",
"SimpleXMLElement",
"$",
"parent",
",",
"string",
"$",
"child",
")",
":",
"SimpleXMLElement",
"{",
"return",
"$",
"this",
"->",
"appendTo",
"(",
"$",
"parent",
",",
"simplexml_load_string",
"(",
"str_replace",
"(",
"\"\\n\"",
",",
"\"\\n\\t\"",
",",
"$",
"child",
")",
")",
")",
";",
"}"
] | Append an xml string to a SimpleXmlElement
@param SimpleXMLElement $parent parent node
@param string $child child node to string
@return SimpleXMLElement parent | [
"Append",
"an",
"xml",
"string",
"to",
"a",
"SimpleXmlElement"
] | 7c5feb9082d1f0f245ea16789c2bf3790dffe647 | https://github.com/seeren/view/blob/7c5feb9082d1f0f245ea16789c2bf3790dffe647/src/Template/XMLTemplate.php#L73-L80 |
5,450 | seeren/view | src/Template/XMLTemplate.php | XMLTemplate.appendValueTo | protected final function appendValueTo(
SimpleXMLElement $parent,
$key,
$value): SimpleXMLElement
{
$parent->addChild($key);
if (is_object($value) || is_array($value)) {
foreach ($value as $subKey => $subValue) {
$this->appendValueTo($parent->{$key}, $subKey, $subValue);
}
if (!isset($subKey)) {
$parent->{$key}[0] = "";
}
} else if (is_scalar($value) || !$value) {
$parent->{$key}[0] = (string) $value;
}
return $parent->{$key};
} | php | protected final function appendValueTo(
SimpleXMLElement $parent,
$key,
$value): SimpleXMLElement
{
$parent->addChild($key);
if (is_object($value) || is_array($value)) {
foreach ($value as $subKey => $subValue) {
$this->appendValueTo($parent->{$key}, $subKey, $subValue);
}
if (!isset($subKey)) {
$parent->{$key}[0] = "";
}
} else if (is_scalar($value) || !$value) {
$parent->{$key}[0] = (string) $value;
}
return $parent->{$key};
} | [
"protected",
"final",
"function",
"appendValueTo",
"(",
"SimpleXMLElement",
"$",
"parent",
",",
"$",
"key",
",",
"$",
"value",
")",
":",
"SimpleXMLElement",
"{",
"$",
"parent",
"->",
"addChild",
"(",
"$",
"key",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
"||",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"subKey",
"=>",
"$",
"subValue",
")",
"{",
"$",
"this",
"->",
"appendValueTo",
"(",
"$",
"parent",
"->",
"{",
"$",
"key",
"}",
",",
"$",
"subKey",
",",
"$",
"subValue",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"subKey",
")",
")",
"{",
"$",
"parent",
"->",
"{",
"$",
"key",
"}",
"[",
"0",
"]",
"=",
"\"\"",
";",
"}",
"}",
"else",
"if",
"(",
"is_scalar",
"(",
"$",
"value",
")",
"||",
"!",
"$",
"value",
")",
"{",
"$",
"parent",
"->",
"{",
"$",
"key",
"}",
"[",
"0",
"]",
"=",
"(",
"string",
")",
"$",
"value",
";",
"}",
"return",
"$",
"parent",
"->",
"{",
"$",
"key",
"}",
";",
"}"
] | Append a value to a SimpleXmlElement
@param SimpleXMLElement $parent parent node
@param string $key value key
@param mixed $value value
@return SimpleXMLElement | [
"Append",
"a",
"value",
"to",
"a",
"SimpleXmlElement"
] | 7c5feb9082d1f0f245ea16789c2bf3790dffe647 | https://github.com/seeren/view/blob/7c5feb9082d1f0f245ea16789c2bf3790dffe647/src/Template/XMLTemplate.php#L90-L107 |
5,451 | CableFramework/Annotations | src/Cable/Annotation/Parser/DirectParser.php | DirectParser.findCommand | private function findCommand($i, array $matches)
{
$match = $matches[0][$i];
$cmd = isset($matches['function'][$i]) ? $matches['function'][$i] : '';
return [$match, $cmd];
} | php | private function findCommand($i, array $matches)
{
$match = $matches[0][$i];
$cmd = isset($matches['function'][$i]) ? $matches['function'][$i] : '';
return [$match, $cmd];
} | [
"private",
"function",
"findCommand",
"(",
"$",
"i",
",",
"array",
"$",
"matches",
")",
"{",
"$",
"match",
"=",
"$",
"matches",
"[",
"0",
"]",
"[",
"$",
"i",
"]",
";",
"$",
"cmd",
"=",
"isset",
"(",
"$",
"matches",
"[",
"'function'",
"]",
"[",
"$",
"i",
"]",
")",
"?",
"$",
"matches",
"[",
"'function'",
"]",
"[",
"$",
"i",
"]",
":",
"''",
";",
"return",
"[",
"$",
"match",
",",
"$",
"cmd",
"]",
";",
"}"
] | find command and match string
@param int $i
@param array $matches
@return array | [
"find",
"command",
"and",
"match",
"string"
] | 2fcac6f4e7b1d27655ce87dd82dfb485dcade28e | https://github.com/CableFramework/Annotations/blob/2fcac6f4e7b1d27655ce87dd82dfb485dcade28e/src/Cable/Annotation/Parser/DirectParser.php#L69-L75 |
5,452 | CableFramework/Annotations | src/Cable/Annotation/Parser/DirectParser.php | DirectParser.findString | private function findString($i, array $matches)
{
$string = isset($matches[0][$i]) ? $matches[0][$i] : '';
return substr($string, 1, -1);
} | php | private function findString($i, array $matches)
{
$string = isset($matches[0][$i]) ? $matches[0][$i] : '';
return substr($string, 1, -1);
} | [
"private",
"function",
"findString",
"(",
"$",
"i",
",",
"array",
"$",
"matches",
")",
"{",
"$",
"string",
"=",
"isset",
"(",
"$",
"matches",
"[",
"0",
"]",
"[",
"$",
"i",
"]",
")",
"?",
"$",
"matches",
"[",
"0",
"]",
"[",
"$",
"i",
"]",
":",
"''",
";",
"return",
"substr",
"(",
"$",
"string",
",",
"1",
",",
"-",
"1",
")",
";",
"}"
] | find string and return it
@param int $i
@param array $matches
@return bool|string | [
"find",
"string",
"and",
"return",
"it"
] | 2fcac6f4e7b1d27655ce87dd82dfb485dcade28e | https://github.com/CableFramework/Annotations/blob/2fcac6f4e7b1d27655ce87dd82dfb485dcade28e/src/Cable/Annotation/Parser/DirectParser.php#L84-L90 |
5,453 | quantaphp/class-names | src/VendorDirectory.php | VendorDirectory.isValidNamespace | private function isValidNamespace($namespace, $directories): bool
{
if (is_string($namespace) && is_array($directories)) {
$total = count($directories);
$valid = count(array_filter($directories, 'is_string'));
return $total > 0 && $total == $valid;
}
return false;
} | php | private function isValidNamespace($namespace, $directories): bool
{
if (is_string($namespace) && is_array($directories)) {
$total = count($directories);
$valid = count(array_filter($directories, 'is_string'));
return $total > 0 && $total == $valid;
}
return false;
} | [
"private",
"function",
"isValidNamespace",
"(",
"$",
"namespace",
",",
"$",
"directories",
")",
":",
"bool",
"{",
"if",
"(",
"is_string",
"(",
"$",
"namespace",
")",
"&&",
"is_array",
"(",
"$",
"directories",
")",
")",
"{",
"$",
"total",
"=",
"count",
"(",
"$",
"directories",
")",
";",
"$",
"valid",
"=",
"count",
"(",
"array_filter",
"(",
"$",
"directories",
",",
"'is_string'",
")",
")",
";",
"return",
"$",
"total",
">",
"0",
"&&",
"$",
"total",
"==",
"$",
"valid",
";",
"}",
"return",
"false",
";",
"}"
] | Return whether the given values defines a valid namespace.
@param mixed $namespace
@param mixed $directories
@return bool | [
"Return",
"whether",
"the",
"given",
"values",
"defines",
"a",
"valid",
"namespace",
"."
] | 2c0aea13ff82aa70df0fe6f78247415d15a994d1 | https://github.com/quantaphp/class-names/blob/2c0aea13ff82aa70df0fe6f78247415d15a994d1/src/VendorDirectory.php#L39-L49 |
5,454 | quantaphp/class-names | src/VendorDirectory.php | VendorDirectory.namespaces | private function namespaces(): \Generator
{
foreach ($this->map() as $namespace => $directories) {
if ($this->isValidNamespace($namespace, $directories)) {
yield new Psr4Namespace($namespace, ...$directories);
}
}
} | php | private function namespaces(): \Generator
{
foreach ($this->map() as $namespace => $directories) {
if ($this->isValidNamespace($namespace, $directories)) {
yield new Psr4Namespace($namespace, ...$directories);
}
}
} | [
"private",
"function",
"namespaces",
"(",
")",
":",
"\\",
"Generator",
"{",
"foreach",
"(",
"$",
"this",
"->",
"map",
"(",
")",
"as",
"$",
"namespace",
"=>",
"$",
"directories",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isValidNamespace",
"(",
"$",
"namespace",
",",
"$",
"directories",
")",
")",
"{",
"yield",
"new",
"Psr4Namespace",
"(",
"$",
"namespace",
",",
"...",
"$",
"directories",
")",
";",
"}",
"}",
"}"
] | Yield an instance of Psr4Namespace for each entry of the autoload map.
@return \Generator | [
"Yield",
"an",
"instance",
"of",
"Psr4Namespace",
"for",
"each",
"entry",
"of",
"the",
"autoload",
"map",
"."
] | 2c0aea13ff82aa70df0fe6f78247415d15a994d1 | https://github.com/quantaphp/class-names/blob/2c0aea13ff82aa70df0fe6f78247415d15a994d1/src/VendorDirectory.php#L70-L77 |
5,455 | jeromeklam/freefw | src/FreeFW/JsonApi/V1/Model/Document.php | Document.getFromObject | protected function getFromObject(\stdClass $p_data = null)
{
if (isset($p_data->data)) {
$data = $p_data->data;
if ($data instanceof \stdClass) {
// Single object
$this->data = $this->getResourceObject($data);
} else {
if (is_array($data)) {
// Collection
} else {
// @todo
}
}
}
return $this;
} | php | protected function getFromObject(\stdClass $p_data = null)
{
if (isset($p_data->data)) {
$data = $p_data->data;
if ($data instanceof \stdClass) {
// Single object
$this->data = $this->getResourceObject($data);
} else {
if (is_array($data)) {
// Collection
} else {
// @todo
}
}
}
return $this;
} | [
"protected",
"function",
"getFromObject",
"(",
"\\",
"stdClass",
"$",
"p_data",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"p_data",
"->",
"data",
")",
")",
"{",
"$",
"data",
"=",
"$",
"p_data",
"->",
"data",
";",
"if",
"(",
"$",
"data",
"instanceof",
"\\",
"stdClass",
")",
"{",
"// Single object",
"$",
"this",
"->",
"data",
"=",
"$",
"this",
"->",
"getResourceObject",
"(",
"$",
"data",
")",
";",
"}",
"else",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"// Collection",
"}",
"else",
"{",
"// @todo",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Get from StdClass
@param \stdClass $p_data
@return \FreeFW\JsonApi\V1\Model\Document | [
"Get",
"from",
"StdClass"
] | 16ecf24192375c920a070296f396b9d3fd994a1e | https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/JsonApi/V1/Model/Document.php#L155-L171 |
5,456 | jeromeklam/freefw | src/FreeFW/JsonApi/V1/Model/Document.php | Document.isSimpleResource | public function isSimpleResource()
{
if ($this->data instanceof \FreeFW\JsonApi\V1\Model\ResourceObject) {
return true;
}
return false;
} | php | public function isSimpleResource()
{
if ($this->data instanceof \FreeFW\JsonApi\V1\Model\ResourceObject) {
return true;
}
return false;
} | [
"public",
"function",
"isSimpleResource",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"data",
"instanceof",
"\\",
"FreeFW",
"\\",
"JsonApi",
"\\",
"V1",
"\\",
"Model",
"\\",
"ResourceObject",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Simple resource ?
@return boolean | [
"Simple",
"resource",
"?"
] | 16ecf24192375c920a070296f396b9d3fd994a1e | https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/JsonApi/V1/Model/Document.php#L193-L199 |
5,457 | jeromeklam/freefw | src/FreeFW/JsonApi/V1/Model/Document.php | Document.getHttpCode | public function getHttpCode()
{
$code= 200;
if ($this->errors) {
/**
* @var \FreeFW\JsonApi\V1\Model\ErrorObject $oneError
*/
foreach ($this->errors as $idx => $oneError) {
if ($oneError->getStatus() > $code) {
$code = $oneError->getStatus();
}
}
}
return $code;
} | php | public function getHttpCode()
{
$code= 200;
if ($this->errors) {
/**
* @var \FreeFW\JsonApi\V1\Model\ErrorObject $oneError
*/
foreach ($this->errors as $idx => $oneError) {
if ($oneError->getStatus() > $code) {
$code = $oneError->getStatus();
}
}
}
return $code;
} | [
"public",
"function",
"getHttpCode",
"(",
")",
"{",
"$",
"code",
"=",
"200",
";",
"if",
"(",
"$",
"this",
"->",
"errors",
")",
"{",
"/**\n * @var \\FreeFW\\JsonApi\\V1\\Model\\ErrorObject $oneError\n */",
"foreach",
"(",
"$",
"this",
"->",
"errors",
"as",
"$",
"idx",
"=>",
"$",
"oneError",
")",
"{",
"if",
"(",
"$",
"oneError",
"->",
"getStatus",
"(",
")",
">",
"$",
"code",
")",
"{",
"$",
"code",
"=",
"$",
"oneError",
"->",
"getStatus",
"(",
")",
";",
"}",
"}",
"}",
"return",
"$",
"code",
";",
"}"
] | Get Http code
@return int | [
"Get",
"Http",
"code"
] | 16ecf24192375c920a070296f396b9d3fd994a1e | https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/JsonApi/V1/Model/Document.php#L216-L230 |
5,458 | emaphp/eMapper | lib/eMapper/Fluent/Query/Clause/ArgumentClause.php | ArgumentClause.build | public function build(Schema &$schema, $alias = null) {
if ($this->clause instanceof SQLPredicate) {
if (!is_null($alias))
$this->clause->setAlias($alias);
return $this->clause->evaluate($this->driver, $schema);
}
return $this->clause;
} | php | public function build(Schema &$schema, $alias = null) {
if ($this->clause instanceof SQLPredicate) {
if (!is_null($alias))
$this->clause->setAlias($alias);
return $this->clause->evaluate($this->driver, $schema);
}
return $this->clause;
} | [
"public",
"function",
"build",
"(",
"Schema",
"&",
"$",
"schema",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"clause",
"instanceof",
"SQLPredicate",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"alias",
")",
")",
"$",
"this",
"->",
"clause",
"->",
"setAlias",
"(",
"$",
"alias",
")",
";",
"return",
"$",
"this",
"->",
"clause",
"->",
"evaluate",
"(",
"$",
"this",
"->",
"driver",
",",
"$",
"schema",
")",
";",
"}",
"return",
"$",
"this",
"->",
"clause",
";",
"}"
] | Builds current clause
@param \eMapper\Query\Schema $schema
@param string alias
@return string | [
"Builds",
"current",
"clause"
] | df7100e601d2a1363d07028a786b6ceb22271829 | https://github.com/emaphp/eMapper/blob/df7100e601d2a1363d07028a786b6ceb22271829/lib/eMapper/Fluent/Query/Clause/ArgumentClause.php#L56-L64 |
5,459 | rseyferth/chickenwire | src/ChickenWire/I18n.php | I18n.setLocale | public static function setLocale($locale)
{
static::$_locale = $locale;
// Apply to PHP locale
$sysLocales = \ChickenWire\Application::getConfiguration()->systemLocales;
if (array_key_exists($locale, $sysLocales)) {
setlocale(LC_ALL, $sysLocales[$locale]);
}
} | php | public static function setLocale($locale)
{
static::$_locale = $locale;
// Apply to PHP locale
$sysLocales = \ChickenWire\Application::getConfiguration()->systemLocales;
if (array_key_exists($locale, $sysLocales)) {
setlocale(LC_ALL, $sysLocales[$locale]);
}
} | [
"public",
"static",
"function",
"setLocale",
"(",
"$",
"locale",
")",
"{",
"static",
"::",
"$",
"_locale",
"=",
"$",
"locale",
";",
"// Apply to PHP locale",
"$",
"sysLocales",
"=",
"\\",
"ChickenWire",
"\\",
"Application",
"::",
"getConfiguration",
"(",
")",
"->",
"systemLocales",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"locale",
",",
"$",
"sysLocales",
")",
")",
"{",
"setlocale",
"(",
"LC_ALL",
",",
"$",
"sysLocales",
"[",
"$",
"locale",
"]",
")",
";",
"}",
"}"
] | Set the current locale
@param string The locale to use | [
"Set",
"the",
"current",
"locale"
] | 74921f0a0d489366602e25df43eda894719e43d3 | https://github.com/rseyferth/chickenwire/blob/74921f0a0d489366602e25df43eda894719e43d3/src/ChickenWire/I18n.php#L80-L90 |
5,460 | rseyferth/chickenwire | src/ChickenWire/I18n.php | I18n.setDefaultLocale | public static function setDefaultLocale($locale)
{
static::$_defaultLocale = $locale;
// Apply to PHP locale
if (is_null(static::$_locale)) {
$sysLocales = \ChickenWire\Application::getConfiguration()->systemLocales;
if (array_key_exists($locale, $sysLocales)) {
setlocale(LC_ALL, $sysLocales[$locale]);
}
}
} | php | public static function setDefaultLocale($locale)
{
static::$_defaultLocale = $locale;
// Apply to PHP locale
if (is_null(static::$_locale)) {
$sysLocales = \ChickenWire\Application::getConfiguration()->systemLocales;
if (array_key_exists($locale, $sysLocales)) {
setlocale(LC_ALL, $sysLocales[$locale]);
}
}
} | [
"public",
"static",
"function",
"setDefaultLocale",
"(",
"$",
"locale",
")",
"{",
"static",
"::",
"$",
"_defaultLocale",
"=",
"$",
"locale",
";",
"// Apply to PHP locale",
"if",
"(",
"is_null",
"(",
"static",
"::",
"$",
"_locale",
")",
")",
"{",
"$",
"sysLocales",
"=",
"\\",
"ChickenWire",
"\\",
"Application",
"::",
"getConfiguration",
"(",
")",
"->",
"systemLocales",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"locale",
",",
"$",
"sysLocales",
")",
")",
"{",
"setlocale",
"(",
"LC_ALL",
",",
"$",
"sysLocales",
"[",
"$",
"locale",
"]",
")",
";",
"}",
"}",
"}"
] | Set the default locale
@param string The default locale | [
"Set",
"the",
"default",
"locale"
] | 74921f0a0d489366602e25df43eda894719e43d3 | https://github.com/rseyferth/chickenwire/blob/74921f0a0d489366602e25df43eda894719e43d3/src/ChickenWire/I18n.php#L106-L118 |
5,461 | rseyferth/chickenwire | src/ChickenWire/I18n.php | I18n.getAll | public static function getAll($prefix = '')
{
// Make backend load all
$backend = static::getBackend();
$backend->loadAll($prefix);
// Now return requested translations
return $backend->translations($prefix);
} | php | public static function getAll($prefix = '')
{
// Make backend load all
$backend = static::getBackend();
$backend->loadAll($prefix);
// Now return requested translations
return $backend->translations($prefix);
} | [
"public",
"static",
"function",
"getAll",
"(",
"$",
"prefix",
"=",
"''",
")",
"{",
"// Make backend load all",
"$",
"backend",
"=",
"static",
"::",
"getBackend",
"(",
")",
";",
"$",
"backend",
"->",
"loadAll",
"(",
"$",
"prefix",
")",
";",
"// Now return requested translations",
"return",
"$",
"backend",
"->",
"translations",
"(",
"$",
"prefix",
")",
";",
"}"
] | Get an array containing all i18n keys for all locales
@param string A prefix filter for the keys to load, e.g.: nl.bmk.
@return array | [
"Get",
"an",
"array",
"containing",
"all",
"i18n",
"keys",
"for",
"all",
"locales"
] | 74921f0a0d489366602e25df43eda894719e43d3 | https://github.com/rseyferth/chickenwire/blob/74921f0a0d489366602e25df43eda894719e43d3/src/ChickenWire/I18n.php#L144-L154 |
5,462 | rseyferth/chickenwire | src/ChickenWire/I18n.php | I18n.parseFloat | public static function parseFloat($floatString){
$LocaleInfo = localeconv();
$floatString = str_replace($LocaleInfo["mon_thousands_sep"] , "", $floatString);
$floatString = str_replace($LocaleInfo["mon_decimal_point"] , ".", $floatString);
return floatval($floatString);
} | php | public static function parseFloat($floatString){
$LocaleInfo = localeconv();
$floatString = str_replace($LocaleInfo["mon_thousands_sep"] , "", $floatString);
$floatString = str_replace($LocaleInfo["mon_decimal_point"] , ".", $floatString);
return floatval($floatString);
} | [
"public",
"static",
"function",
"parseFloat",
"(",
"$",
"floatString",
")",
"{",
"$",
"LocaleInfo",
"=",
"localeconv",
"(",
")",
";",
"$",
"floatString",
"=",
"str_replace",
"(",
"$",
"LocaleInfo",
"[",
"\"mon_thousands_sep\"",
"]",
",",
"\"\"",
",",
"$",
"floatString",
")",
";",
"$",
"floatString",
"=",
"str_replace",
"(",
"$",
"LocaleInfo",
"[",
"\"mon_decimal_point\"",
"]",
",",
"\".\"",
",",
"$",
"floatString",
")",
";",
"return",
"floatval",
"(",
"$",
"floatString",
")",
";",
"}"
] | Parse a float value with localization in mind
@param string $floatString The string representation of a floating number
@return float The float value | [
"Parse",
"a",
"float",
"value",
"with",
"localization",
"in",
"mind"
] | 74921f0a0d489366602e25df43eda894719e43d3 | https://github.com/rseyferth/chickenwire/blob/74921f0a0d489366602e25df43eda894719e43d3/src/ChickenWire/I18n.php#L173-L178 |
5,463 | tonjoo/almari | src/Container.php | Container.bind | public function bind($name,$params)
{
$this->instances[$name] = $params;
$this->bind[$name] = true;
} | php | public function bind($name,$params)
{
$this->instances[$name] = $params;
$this->bind[$name] = true;
} | [
"public",
"function",
"bind",
"(",
"$",
"name",
",",
"$",
"params",
")",
"{",
"$",
"this",
"->",
"instances",
"[",
"$",
"name",
"]",
"=",
"$",
"params",
";",
"$",
"this",
"->",
"bind",
"[",
"$",
"name",
"]",
"=",
"true",
";",
"}"
] | Register service to the container | [
"Register",
"service",
"to",
"the",
"container"
] | 46cbcf63dab67be544468052b22a325d68c33c79 | https://github.com/tonjoo/almari/blob/46cbcf63dab67be544468052b22a325d68c33c79/src/Container.php#L51-L57 |
5,464 | tonjoo/almari | src/Container.php | Container.resolve | private function resolve($name)
{
// set as resolved
$this->resolved[$name] = true;
// resolve the service
if (is_string($this->instances[$name]) && class_exists($this->instances[$name]))
{
$object = $this->instances[$name];
return new $object();
}
elseif(is_callable($this->instances[$name]))
{
$callable = $this->instances[$name];
return $callable();
}
return $this->instances[$name];
} | php | private function resolve($name)
{
// set as resolved
$this->resolved[$name] = true;
// resolve the service
if (is_string($this->instances[$name]) && class_exists($this->instances[$name]))
{
$object = $this->instances[$name];
return new $object();
}
elseif(is_callable($this->instances[$name]))
{
$callable = $this->instances[$name];
return $callable();
}
return $this->instances[$name];
} | [
"private",
"function",
"resolve",
"(",
"$",
"name",
")",
"{",
"// set as resolved",
"$",
"this",
"->",
"resolved",
"[",
"$",
"name",
"]",
"=",
"true",
";",
"// resolve the service",
"if",
"(",
"is_string",
"(",
"$",
"this",
"->",
"instances",
"[",
"$",
"name",
"]",
")",
"&&",
"class_exists",
"(",
"$",
"this",
"->",
"instances",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"object",
"=",
"$",
"this",
"->",
"instances",
"[",
"$",
"name",
"]",
";",
"return",
"new",
"$",
"object",
"(",
")",
";",
"}",
"elseif",
"(",
"is_callable",
"(",
"$",
"this",
"->",
"instances",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"callable",
"=",
"$",
"this",
"->",
"instances",
"[",
"$",
"name",
"]",
";",
"return",
"$",
"callable",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"instances",
"[",
"$",
"name",
"]",
";",
"}"
] | Try to resolve the service | [
"Try",
"to",
"resolve",
"the",
"service"
] | 46cbcf63dab67be544468052b22a325d68c33c79 | https://github.com/tonjoo/almari/blob/46cbcf63dab67be544468052b22a325d68c33c79/src/Container.php#L112-L136 |
5,465 | jmpantoja/planb-utils | src/Type/Text/TextAssurance.php | TextAssurance.fromStringifable | public static function fromStringifable(Stringifable $object): self
{
if ($object instanceof Text) {
return self::fromText($object);
}
$text = Text::make($object->stringify());
return new static($text);
} | php | public static function fromStringifable(Stringifable $object): self
{
if ($object instanceof Text) {
return self::fromText($object);
}
$text = Text::make($object->stringify());
return new static($text);
} | [
"public",
"static",
"function",
"fromStringifable",
"(",
"Stringifable",
"$",
"object",
")",
":",
"self",
"{",
"if",
"(",
"$",
"object",
"instanceof",
"Text",
")",
"{",
"return",
"self",
"::",
"fromText",
"(",
"$",
"object",
")",
";",
"}",
"$",
"text",
"=",
"Text",
"::",
"make",
"(",
"$",
"object",
"->",
"stringify",
"(",
")",
")",
";",
"return",
"new",
"static",
"(",
"$",
"text",
")",
";",
"}"
] | Crea una nueva instancia a partir de un objeto Stringifable
@param \PlanB\Type\Stringifable $object
@return \PlanB\Type\Text\TextAssurance | [
"Crea",
"una",
"nueva",
"instancia",
"a",
"partir",
"de",
"un",
"objeto",
"Stringifable"
] | d17fbced4a285275928f8428ee56e269eb851690 | https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Type/Text/TextAssurance.php#L56-L65 |
5,466 | pletfix/core | src/Services/Collection.php | Collection.last | public function last(callable $callback = null, $default = null)
{
if (is_null($callback)) {
if (!empty($this->items)) {
return end($this->items);
}
}
else {
foreach (array_reverse($this->items, true) as $key => $value) {
if (call_user_func($callback, $value, $key)) {
return $value;
}
}
}
return $default instanceof Closure ? $default() : $default;
} | php | public function last(callable $callback = null, $default = null)
{
if (is_null($callback)) {
if (!empty($this->items)) {
return end($this->items);
}
}
else {
foreach (array_reverse($this->items, true) as $key => $value) {
if (call_user_func($callback, $value, $key)) {
return $value;
}
}
}
return $default instanceof Closure ? $default() : $default;
} | [
"public",
"function",
"last",
"(",
"callable",
"$",
"callback",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"callback",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"items",
")",
")",
"{",
"return",
"end",
"(",
"$",
"this",
"->",
"items",
")",
";",
"}",
"}",
"else",
"{",
"foreach",
"(",
"array_reverse",
"(",
"$",
"this",
"->",
"items",
",",
"true",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"call_user_func",
"(",
"$",
"callback",
",",
"$",
"value",
",",
"$",
"key",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"}",
"}",
"return",
"$",
"default",
"instanceof",
"Closure",
"?",
"$",
"default",
"(",
")",
":",
"$",
"default",
";",
"}"
] | Get the last item from the collection.
@param callable|null $callback
@param mixed $default
@return mixed | [
"Get",
"the",
"last",
"item",
"from",
"the",
"collection",
"."
] | 974945500f278eb6c1779832e08bbfca1007a7b3 | https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/Collection.php#L303-L319 |
5,467 | indigophp-archive/queue | src/Job.php | Job.createPayload | public function createPayload()
{
$payload = $this->extras;
$payload['job'] = $this->job;
$payload['data'] = $this->data;
// Create special payload if it is a Closure
if ($this->job instanceof \Closure) {
$payload['closure'] = serialize(new SerializableClosure($this->job));
$payload['job'] = $this->closureClass;
}
return $payload;
} | php | public function createPayload()
{
$payload = $this->extras;
$payload['job'] = $this->job;
$payload['data'] = $this->data;
// Create special payload if it is a Closure
if ($this->job instanceof \Closure) {
$payload['closure'] = serialize(new SerializableClosure($this->job));
$payload['job'] = $this->closureClass;
}
return $payload;
} | [
"public",
"function",
"createPayload",
"(",
")",
"{",
"$",
"payload",
"=",
"$",
"this",
"->",
"extras",
";",
"$",
"payload",
"[",
"'job'",
"]",
"=",
"$",
"this",
"->",
"job",
";",
"$",
"payload",
"[",
"'data'",
"]",
"=",
"$",
"this",
"->",
"data",
";",
"// Create special payload if it is a Closure",
"if",
"(",
"$",
"this",
"->",
"job",
"instanceof",
"\\",
"Closure",
")",
"{",
"$",
"payload",
"[",
"'closure'",
"]",
"=",
"serialize",
"(",
"new",
"SerializableClosure",
"(",
"$",
"this",
"->",
"job",
")",
")",
";",
"$",
"payload",
"[",
"'job'",
"]",
"=",
"$",
"this",
"->",
"closureClass",
";",
"}",
"return",
"$",
"payload",
";",
"}"
] | Creates a serialized payload
@return [] | [
"Creates",
"a",
"serialized",
"payload"
] | d364d5a1fc3b00d59846b19aa472d7f2aa130ff8 | https://github.com/indigophp-archive/queue/blob/d364d5a1fc3b00d59846b19aa472d7f2aa130ff8/src/Job.php#L176-L190 |
5,468 | indigophp-archive/queue | src/Job.php | Job.createFromPayload | public static function createFromPayload(array $payload)
{
$job = $payload['job'];
$data = $payload['data'];
unset($payload['job'], $payload['data']);
return new static($job, $data, [], $payload);
} | php | public static function createFromPayload(array $payload)
{
$job = $payload['job'];
$data = $payload['data'];
unset($payload['job'], $payload['data']);
return new static($job, $data, [], $payload);
} | [
"public",
"static",
"function",
"createFromPayload",
"(",
"array",
"$",
"payload",
")",
"{",
"$",
"job",
"=",
"$",
"payload",
"[",
"'job'",
"]",
";",
"$",
"data",
"=",
"$",
"payload",
"[",
"'data'",
"]",
";",
"unset",
"(",
"$",
"payload",
"[",
"'job'",
"]",
",",
"$",
"payload",
"[",
"'data'",
"]",
")",
";",
"return",
"new",
"static",
"(",
"$",
"job",
",",
"$",
"data",
",",
"[",
"]",
",",
"$",
"payload",
")",
";",
"}"
] | Creates a new Job from payload
@param [] $payload
@return self | [
"Creates",
"a",
"new",
"Job",
"from",
"payload"
] | d364d5a1fc3b00d59846b19aa472d7f2aa130ff8 | https://github.com/indigophp-archive/queue/blob/d364d5a1fc3b00d59846b19aa472d7f2aa130ff8/src/Job.php#L199-L207 |
5,469 | MLukman/Securilex | src/Authorization/SecuredAccessTrait.php | SecuredAccessTrait.addAllowedRole | public function addAllowedRole($role, $attribute = 'access')
{
$roleStr = (string) $role;
if (!isset($this->allowedRoles[$roleStr])) {
$this->allowedRoles[$roleStr] = array();
}
$this->allowedRoles[$roleStr][(string) $attribute] = true;
return $this;
} | php | public function addAllowedRole($role, $attribute = 'access')
{
$roleStr = (string) $role;
if (!isset($this->allowedRoles[$roleStr])) {
$this->allowedRoles[$roleStr] = array();
}
$this->allowedRoles[$roleStr][(string) $attribute] = true;
return $this;
} | [
"public",
"function",
"addAllowedRole",
"(",
"$",
"role",
",",
"$",
"attribute",
"=",
"'access'",
")",
"{",
"$",
"roleStr",
"=",
"(",
"string",
")",
"$",
"role",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"allowedRoles",
"[",
"$",
"roleStr",
"]",
")",
")",
"{",
"$",
"this",
"->",
"allowedRoles",
"[",
"$",
"roleStr",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"allowedRoles",
"[",
"$",
"roleStr",
"]",
"[",
"(",
"string",
")",
"$",
"attribute",
"]",
"=",
"true",
";",
"return",
"$",
"this",
";",
"}"
] | Allow user role to access
@param string $role User role to allow access
@param string $attribute Attribute
@return self $this object (to allow method chaining) | [
"Allow",
"user",
"role",
"to",
"access"
] | d86ccae6df2ff9029a6d033b20e15f7f48fab79d | https://github.com/MLukman/Securilex/blob/d86ccae6df2ff9029a6d033b20e15f7f48fab79d/src/Authorization/SecuredAccessTrait.php#L39-L47 |
5,470 | MLukman/Securilex | src/Authorization/SecuredAccessTrait.php | SecuredAccessTrait.isRoleAllowed | public function isRoleAllowed($role, $attribute = 'access')
{
if (is_array($role)) {
foreach ($role as $r) {
if ($this->isRoleAllowed($r, $attribute)) {
return true;
}
}
return false;
} else {
$roleStr = (string) $role;
$attrStr = (string) $attribute;
if (isset($this->allowedRoles[$roleStr])) {
return
(isset($this->allowedRoles[$roleStr][$attrStr]) ?
$this->allowedRoles[$roleStr][$attrStr] : false) ||
(isset($this->allowedRoles[$roleStr]['any']) ?
$this->allowedRoles[$roleStr]['any'] : false);
}
return false;
}
} | php | public function isRoleAllowed($role, $attribute = 'access')
{
if (is_array($role)) {
foreach ($role as $r) {
if ($this->isRoleAllowed($r, $attribute)) {
return true;
}
}
return false;
} else {
$roleStr = (string) $role;
$attrStr = (string) $attribute;
if (isset($this->allowedRoles[$roleStr])) {
return
(isset($this->allowedRoles[$roleStr][$attrStr]) ?
$this->allowedRoles[$roleStr][$attrStr] : false) ||
(isset($this->allowedRoles[$roleStr]['any']) ?
$this->allowedRoles[$roleStr]['any'] : false);
}
return false;
}
} | [
"public",
"function",
"isRoleAllowed",
"(",
"$",
"role",
",",
"$",
"attribute",
"=",
"'access'",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"role",
")",
")",
"{",
"foreach",
"(",
"$",
"role",
"as",
"$",
"r",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isRoleAllowed",
"(",
"$",
"r",
",",
"$",
"attribute",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}",
"else",
"{",
"$",
"roleStr",
"=",
"(",
"string",
")",
"$",
"role",
";",
"$",
"attrStr",
"=",
"(",
"string",
")",
"$",
"attribute",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"allowedRoles",
"[",
"$",
"roleStr",
"]",
")",
")",
"{",
"return",
"(",
"isset",
"(",
"$",
"this",
"->",
"allowedRoles",
"[",
"$",
"roleStr",
"]",
"[",
"$",
"attrStr",
"]",
")",
"?",
"$",
"this",
"->",
"allowedRoles",
"[",
"$",
"roleStr",
"]",
"[",
"$",
"attrStr",
"]",
":",
"false",
")",
"||",
"(",
"isset",
"(",
"$",
"this",
"->",
"allowedRoles",
"[",
"$",
"roleStr",
"]",
"[",
"'any'",
"]",
")",
"?",
"$",
"this",
"->",
"allowedRoles",
"[",
"$",
"roleStr",
"]",
"[",
"'any'",
"]",
":",
"false",
")",
";",
"}",
"return",
"false",
";",
"}",
"}"
] | Check if a specific user role is allowed to access
@param string $role User role
@param string $attribute Attribute
@return bool | [
"Check",
"if",
"a",
"specific",
"user",
"role",
"is",
"allowed",
"to",
"access"
] | d86ccae6df2ff9029a6d033b20e15f7f48fab79d | https://github.com/MLukman/Securilex/blob/d86ccae6df2ff9029a6d033b20e15f7f48fab79d/src/Authorization/SecuredAccessTrait.php#L55-L76 |
5,471 | MLukman/Securilex | src/Authorization/SecuredAccessTrait.php | SecuredAccessTrait.addAllowedUsername | public function addAllowedUsername($username, $attribute = 'access')
{
$usernameStr = (string) $username;
if (!isset($this->allowedUsernames[$usernameStr])) {
$this->allowedUsernames[$usernameStr] = array();
}
$this->allowedUsernames[$usernameStr][(string) $attribute] = true;
return $this;
} | php | public function addAllowedUsername($username, $attribute = 'access')
{
$usernameStr = (string) $username;
if (!isset($this->allowedUsernames[$usernameStr])) {
$this->allowedUsernames[$usernameStr] = array();
}
$this->allowedUsernames[$usernameStr][(string) $attribute] = true;
return $this;
} | [
"public",
"function",
"addAllowedUsername",
"(",
"$",
"username",
",",
"$",
"attribute",
"=",
"'access'",
")",
"{",
"$",
"usernameStr",
"=",
"(",
"string",
")",
"$",
"username",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"allowedUsernames",
"[",
"$",
"usernameStr",
"]",
")",
")",
"{",
"$",
"this",
"->",
"allowedUsernames",
"[",
"$",
"usernameStr",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"allowedUsernames",
"[",
"$",
"usernameStr",
"]",
"[",
"(",
"string",
")",
"$",
"attribute",
"]",
"=",
"true",
";",
"return",
"$",
"this",
";",
"}"
] | Allow username to access
@param string $username Username to allow access
@param string $attribute Attribute
@return self $this object (to allow method chaining) | [
"Allow",
"username",
"to",
"access"
] | d86ccae6df2ff9029a6d033b20e15f7f48fab79d | https://github.com/MLukman/Securilex/blob/d86ccae6df2ff9029a6d033b20e15f7f48fab79d/src/Authorization/SecuredAccessTrait.php#L84-L92 |
5,472 | MLukman/Securilex | src/Authorization/SecuredAccessTrait.php | SecuredAccessTrait.isUsernameAllowed | public function isUsernameAllowed($username, $attribute = 'access')
{
$usernameStr = (string) $username;
$attrStr = (string) $attribute;
return (isset($this->allowedUsernames[$usernameStr]) && isset($this->allowedUsernames[$usernameStr][$attrStr]))
? $this->allowedUsernames[$usernameStr][$attrStr] : false;
} | php | public function isUsernameAllowed($username, $attribute = 'access')
{
$usernameStr = (string) $username;
$attrStr = (string) $attribute;
return (isset($this->allowedUsernames[$usernameStr]) && isset($this->allowedUsernames[$usernameStr][$attrStr]))
? $this->allowedUsernames[$usernameStr][$attrStr] : false;
} | [
"public",
"function",
"isUsernameAllowed",
"(",
"$",
"username",
",",
"$",
"attribute",
"=",
"'access'",
")",
"{",
"$",
"usernameStr",
"=",
"(",
"string",
")",
"$",
"username",
";",
"$",
"attrStr",
"=",
"(",
"string",
")",
"$",
"attribute",
";",
"return",
"(",
"isset",
"(",
"$",
"this",
"->",
"allowedUsernames",
"[",
"$",
"usernameStr",
"]",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"allowedUsernames",
"[",
"$",
"usernameStr",
"]",
"[",
"$",
"attrStr",
"]",
")",
")",
"?",
"$",
"this",
"->",
"allowedUsernames",
"[",
"$",
"usernameStr",
"]",
"[",
"$",
"attrStr",
"]",
":",
"false",
";",
"}"
] | Check if a specific username is allowed to access this context
@param string $username Username
@param string $attribute Attribute
@return bool | [
"Check",
"if",
"a",
"specific",
"username",
"is",
"allowed",
"to",
"access",
"this",
"context"
] | d86ccae6df2ff9029a6d033b20e15f7f48fab79d | https://github.com/MLukman/Securilex/blob/d86ccae6df2ff9029a6d033b20e15f7f48fab79d/src/Authorization/SecuredAccessTrait.php#L100-L106 |
5,473 | fiedsch/datamanagement | src/Fiedsch/Data/File/CsvReader.php | CsvReader.isEmpty | public static function isEmpty($line, $strict = false)
{
if (!is_array($line)) {
throw new \RuntimeException("got a string that should already have been split into an array");
}
$test = array_filter($line, function ($element) use ($strict) {
return !Reader::isEmpty($element, $strict);
});
return empty($test);
} | php | public static function isEmpty($line, $strict = false)
{
if (!is_array($line)) {
throw new \RuntimeException("got a string that should already have been split into an array");
}
$test = array_filter($line, function ($element) use ($strict) {
return !Reader::isEmpty($element, $strict);
});
return empty($test);
} | [
"public",
"static",
"function",
"isEmpty",
"(",
"$",
"line",
",",
"$",
"strict",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"line",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"got a string that should already have been split into an array\"",
")",
";",
"}",
"$",
"test",
"=",
"array_filter",
"(",
"$",
"line",
",",
"function",
"(",
"$",
"element",
")",
"use",
"(",
"$",
"strict",
")",
"{",
"return",
"!",
"Reader",
"::",
"isEmpty",
"(",
"$",
"element",
",",
"$",
"strict",
")",
";",
"}",
")",
";",
"return",
"empty",
"(",
"$",
"test",
")",
";",
"}"
] | Check whether a line is to be considered empty.
@param array $line the line to check.
@param boolean $strict controls how to compare "empty" strings (see also Reader::isEmpty()).
@return boolean | [
"Check",
"whether",
"a",
"line",
"is",
"to",
"be",
"considered",
"empty",
"."
] | 06e8000399d46e83f848944b73afecabf619f52b | https://github.com/fiedsch/datamanagement/blob/06e8000399d46e83f848944b73afecabf619f52b/src/Fiedsch/Data/File/CsvReader.php#L153-L162 |
5,474 | bemailr/wp-requirements | includes/class-wp-requirements.php | WP_Requirements.set_plugin | protected function set_plugin( $the__file__ ) {
if ( ! function_exists( 'get_plugins' ) ) {
/* @noinspection PhpIncludeInspection */
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$this->plugin['fullpath'] = $the__file__;
$this->plugin['basename'] = plugin_basename( $this->plugin['fullpath'] );
list( $this->plugin['dirname'], $this->plugin['filename'] ) = explode( '/', $this->plugin['basename'] );
$plugin_data = get_plugin_data( $this->plugin['fullpath'] );
$this->plugin['name'] = $plugin_data['Name'];
} | php | protected function set_plugin( $the__file__ ) {
if ( ! function_exists( 'get_plugins' ) ) {
/* @noinspection PhpIncludeInspection */
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$this->plugin['fullpath'] = $the__file__;
$this->plugin['basename'] = plugin_basename( $this->plugin['fullpath'] );
list( $this->plugin['dirname'], $this->plugin['filename'] ) = explode( '/', $this->plugin['basename'] );
$plugin_data = get_plugin_data( $this->plugin['fullpath'] );
$this->plugin['name'] = $plugin_data['Name'];
} | [
"protected",
"function",
"set_plugin",
"(",
"$",
"the__file__",
")",
"{",
"if",
"(",
"!",
"function_exists",
"(",
"'get_plugins'",
")",
")",
"{",
"/* @noinspection PhpIncludeInspection */",
"require_once",
"ABSPATH",
".",
"'wp-admin/includes/plugin.php'",
";",
"}",
"$",
"this",
"->",
"plugin",
"[",
"'fullpath'",
"]",
"=",
"$",
"the__file__",
";",
"$",
"this",
"->",
"plugin",
"[",
"'basename'",
"]",
"=",
"plugin_basename",
"(",
"$",
"this",
"->",
"plugin",
"[",
"'fullpath'",
"]",
")",
";",
"list",
"(",
"$",
"this",
"->",
"plugin",
"[",
"'dirname'",
"]",
",",
"$",
"this",
"->",
"plugin",
"[",
"'filename'",
"]",
")",
"=",
"explode",
"(",
"'/'",
",",
"$",
"this",
"->",
"plugin",
"[",
"'basename'",
"]",
")",
";",
"$",
"plugin_data",
"=",
"get_plugin_data",
"(",
"$",
"this",
"->",
"plugin",
"[",
"'fullpath'",
"]",
")",
";",
"$",
"this",
"->",
"plugin",
"[",
"'name'",
"]",
"=",
"$",
"plugin_data",
"[",
"'Name'",
"]",
";",
"}"
] | Set paths, name etc for a plugin
@param string $the__file__ Pass `__FILE__` from the loader through Constructor. | [
"Set",
"paths",
"name",
"etc",
"for",
"a",
"plugin"
] | e903973b0dfc1178f89c757bd205327811ea4658 | https://github.com/bemailr/wp-requirements/blob/e903973b0dfc1178f89c757bd205327811ea4658/includes/class-wp-requirements.php#L125-L137 |
5,475 | bemailr/wp-requirements | includes/class-wp-requirements.php | WP_Requirements.set_params | protected function set_params( $params ) {
$this->requirements_details_url = ! empty( $params['requirements_details_url'] ) ? esc_url( trim( (string) $params['requirements_details_url'] ) ) : $this->requirements_details_url;
$this->version_compare_operator = ! empty( $params['version_compare_operator'] ) ? (string) $params['version_compare_operator'] : $this->version_compare_operator;
$this->not_valid_actions = ! empty( $params['not_valid_actions'] ) ? (array) $params['not_valid_actions'] : $this->not_valid_actions;
$this->show_valid_results = isset( $params['show_valid_results'] ) ? (bool) $params['show_valid_results'] : $this->show_valid_results;
} | php | protected function set_params( $params ) {
$this->requirements_details_url = ! empty( $params['requirements_details_url'] ) ? esc_url( trim( (string) $params['requirements_details_url'] ) ) : $this->requirements_details_url;
$this->version_compare_operator = ! empty( $params['version_compare_operator'] ) ? (string) $params['version_compare_operator'] : $this->version_compare_operator;
$this->not_valid_actions = ! empty( $params['not_valid_actions'] ) ? (array) $params['not_valid_actions'] : $this->not_valid_actions;
$this->show_valid_results = isset( $params['show_valid_results'] ) ? (bool) $params['show_valid_results'] : $this->show_valid_results;
} | [
"protected",
"function",
"set_params",
"(",
"$",
"params",
")",
"{",
"$",
"this",
"->",
"requirements_details_url",
"=",
"!",
"empty",
"(",
"$",
"params",
"[",
"'requirements_details_url'",
"]",
")",
"?",
"esc_url",
"(",
"trim",
"(",
"(",
"string",
")",
"$",
"params",
"[",
"'requirements_details_url'",
"]",
")",
")",
":",
"$",
"this",
"->",
"requirements_details_url",
";",
"$",
"this",
"->",
"version_compare_operator",
"=",
"!",
"empty",
"(",
"$",
"params",
"[",
"'version_compare_operator'",
"]",
")",
"?",
"(",
"string",
")",
"$",
"params",
"[",
"'version_compare_operator'",
"]",
":",
"$",
"this",
"->",
"version_compare_operator",
";",
"$",
"this",
"->",
"not_valid_actions",
"=",
"!",
"empty",
"(",
"$",
"params",
"[",
"'not_valid_actions'",
"]",
")",
"?",
"(",
"array",
")",
"$",
"params",
"[",
"'not_valid_actions'",
"]",
":",
"$",
"this",
"->",
"not_valid_actions",
";",
"$",
"this",
"->",
"show_valid_results",
"=",
"isset",
"(",
"$",
"params",
"[",
"'show_valid_results'",
"]",
")",
"?",
"(",
"bool",
")",
"$",
"params",
"[",
"'show_valid_results'",
"]",
":",
"$",
"this",
"->",
"show_valid_results",
";",
"}"
] | Redefine all params by those that were submitted by a user.
@param array $params The array of parameters. | [
"Redefine",
"all",
"params",
"by",
"those",
"that",
"were",
"submitted",
"by",
"a",
"user",
"."
] | e903973b0dfc1178f89c757bd205327811ea4658 | https://github.com/bemailr/wp-requirements/blob/e903973b0dfc1178f89c757bd205327811ea4658/includes/class-wp-requirements.php#L193-L198 |
5,476 | bemailr/wp-requirements | includes/class-wp-requirements.php | WP_Requirements.validate_php | protected function validate_php( $php ) {
$result = $required = array();
foreach ( $php as $type => $data ) {
switch ( $type ) {
case 'version':
$result[ $type ] = version_compare( phpversion(), $data, $this->version_compare_operator );
$required[ $type ] = $data;
break;
case 'extensions':
// Check that all required PHP extensions are loaded.
foreach ( (array) $data as $extension ) {
if ( $extension && is_string( $extension ) ) {
$result[ $type ][ $extension ] = extension_loaded( $extension );
$required[ $type ][] = $extension;
}
}
break;
}
}
$this->results['php'] = $result;
$this->required['php'] = $required;
} | php | protected function validate_php( $php ) {
$result = $required = array();
foreach ( $php as $type => $data ) {
switch ( $type ) {
case 'version':
$result[ $type ] = version_compare( phpversion(), $data, $this->version_compare_operator );
$required[ $type ] = $data;
break;
case 'extensions':
// Check that all required PHP extensions are loaded.
foreach ( (array) $data as $extension ) {
if ( $extension && is_string( $extension ) ) {
$result[ $type ][ $extension ] = extension_loaded( $extension );
$required[ $type ][] = $extension;
}
}
break;
}
}
$this->results['php'] = $result;
$this->required['php'] = $required;
} | [
"protected",
"function",
"validate_php",
"(",
"$",
"php",
")",
"{",
"$",
"result",
"=",
"$",
"required",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"php",
"as",
"$",
"type",
"=>",
"$",
"data",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'version'",
":",
"$",
"result",
"[",
"$",
"type",
"]",
"=",
"version_compare",
"(",
"phpversion",
"(",
")",
",",
"$",
"data",
",",
"$",
"this",
"->",
"version_compare_operator",
")",
";",
"$",
"required",
"[",
"$",
"type",
"]",
"=",
"$",
"data",
";",
"break",
";",
"case",
"'extensions'",
":",
"// Check that all required PHP extensions are loaded.",
"foreach",
"(",
"(",
"array",
")",
"$",
"data",
"as",
"$",
"extension",
")",
"{",
"if",
"(",
"$",
"extension",
"&&",
"is_string",
"(",
"$",
"extension",
")",
")",
"{",
"$",
"result",
"[",
"$",
"type",
"]",
"[",
"$",
"extension",
"]",
"=",
"extension_loaded",
"(",
"$",
"extension",
")",
";",
"$",
"required",
"[",
"$",
"type",
"]",
"[",
"]",
"=",
"$",
"extension",
";",
"}",
"}",
"break",
";",
"}",
"}",
"$",
"this",
"->",
"results",
"[",
"'php'",
"]",
"=",
"$",
"result",
";",
"$",
"this",
"->",
"required",
"[",
"'php'",
"]",
"=",
"$",
"required",
";",
"}"
] | Check all PHP related data, like version and extensions
@param array $php PHP requirements. | [
"Check",
"all",
"PHP",
"related",
"data",
"like",
"version",
"and",
"extensions"
] | e903973b0dfc1178f89c757bd205327811ea4658 | https://github.com/bemailr/wp-requirements/blob/e903973b0dfc1178f89c757bd205327811ea4658/includes/class-wp-requirements.php#L205-L230 |
5,477 | bemailr/wp-requirements | includes/class-wp-requirements.php | WP_Requirements.validate_wordpress | protected function validate_wordpress( $wordpress ) {
global $wp_version;
$result = $required = array();
foreach ( $wordpress as $type => $data ) {
switch ( $type ) {
case 'version':
$result[ $type ] = version_compare( $wp_version, $data, '>=' );
$required[ $type ] = $data;
break;
case 'plugins':
if ( ! function_exists( 'is_plugin_active' ) ) {
/* @noinspection PhpIncludeInspection */
include_once ABSPATH . 'wp-admin/includes/plugin.php';
}
foreach ( (array) $data as $plugin => $required_version ) {
if ( $plugin && is_string( $plugin ) ) {
$required[ $type ][ $plugin ] = $required_version;
$is_plugin_active = is_plugin_active( $plugin );
if ( is_bool( $required_version ) ) {
/**
* When the required version is specified
* as a Boolean (`true` or `false`),
* then we do not need to check the version number,
* just active or not.
*/
$result[ $type ][ $plugin ] =
( $is_plugin_active === $required_version );
} else {
/**
* Check that the plugin is active and
* that its version matches the requirements.
*/
$raw_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin,
false, false
);
// If the plugin does not have a version (?!) then
// we consider the version is OK.
$is_plugin_version_ok = (
! isset( $raw_data['Version'] ) ||
version_compare(
$raw_data['Version'],
$required_version,
$this->version_compare_operator
)
);
$result[ $type ][ $plugin ] = $is_plugin_active && $is_plugin_version_ok;
}
}
}
break;
case 'theme':
$theme = (array) $data;
$current_theme = wp_get_theme();
// Now check the theme: user defined slug can be either template
// (parent theme) or stylesheet (currently active theme).
foreach ( $theme as $slug => $required_version ) {
if (
( $current_theme->get_template() === $slug ||
$current_theme->get_stylesheet() === $slug ) &&
version_compare( $current_theme->get( 'Version' ), $required_version, $this->version_compare_operator )
) {
$result[ $type ][ $slug ] = true;
} else {
$result[ $type ][ $slug ] = false;
}
$required[ $type ][ $slug ] = $required_version;
}
break;
}
}
$this->results['wordpress'] = $result;
$this->required['wordpress'] = $required;
} | php | protected function validate_wordpress( $wordpress ) {
global $wp_version;
$result = $required = array();
foreach ( $wordpress as $type => $data ) {
switch ( $type ) {
case 'version':
$result[ $type ] = version_compare( $wp_version, $data, '>=' );
$required[ $type ] = $data;
break;
case 'plugins':
if ( ! function_exists( 'is_plugin_active' ) ) {
/* @noinspection PhpIncludeInspection */
include_once ABSPATH . 'wp-admin/includes/plugin.php';
}
foreach ( (array) $data as $plugin => $required_version ) {
if ( $plugin && is_string( $plugin ) ) {
$required[ $type ][ $plugin ] = $required_version;
$is_plugin_active = is_plugin_active( $plugin );
if ( is_bool( $required_version ) ) {
/**
* When the required version is specified
* as a Boolean (`true` or `false`),
* then we do not need to check the version number,
* just active or not.
*/
$result[ $type ][ $plugin ] =
( $is_plugin_active === $required_version );
} else {
/**
* Check that the plugin is active and
* that its version matches the requirements.
*/
$raw_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin,
false, false
);
// If the plugin does not have a version (?!) then
// we consider the version is OK.
$is_plugin_version_ok = (
! isset( $raw_data['Version'] ) ||
version_compare(
$raw_data['Version'],
$required_version,
$this->version_compare_operator
)
);
$result[ $type ][ $plugin ] = $is_plugin_active && $is_plugin_version_ok;
}
}
}
break;
case 'theme':
$theme = (array) $data;
$current_theme = wp_get_theme();
// Now check the theme: user defined slug can be either template
// (parent theme) or stylesheet (currently active theme).
foreach ( $theme as $slug => $required_version ) {
if (
( $current_theme->get_template() === $slug ||
$current_theme->get_stylesheet() === $slug ) &&
version_compare( $current_theme->get( 'Version' ), $required_version, $this->version_compare_operator )
) {
$result[ $type ][ $slug ] = true;
} else {
$result[ $type ][ $slug ] = false;
}
$required[ $type ][ $slug ] = $required_version;
}
break;
}
}
$this->results['wordpress'] = $result;
$this->required['wordpress'] = $required;
} | [
"protected",
"function",
"validate_wordpress",
"(",
"$",
"wordpress",
")",
"{",
"global",
"$",
"wp_version",
";",
"$",
"result",
"=",
"$",
"required",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"wordpress",
"as",
"$",
"type",
"=>",
"$",
"data",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'version'",
":",
"$",
"result",
"[",
"$",
"type",
"]",
"=",
"version_compare",
"(",
"$",
"wp_version",
",",
"$",
"data",
",",
"'>='",
")",
";",
"$",
"required",
"[",
"$",
"type",
"]",
"=",
"$",
"data",
";",
"break",
";",
"case",
"'plugins'",
":",
"if",
"(",
"!",
"function_exists",
"(",
"'is_plugin_active'",
")",
")",
"{",
"/* @noinspection PhpIncludeInspection */",
"include_once",
"ABSPATH",
".",
"'wp-admin/includes/plugin.php'",
";",
"}",
"foreach",
"(",
"(",
"array",
")",
"$",
"data",
"as",
"$",
"plugin",
"=>",
"$",
"required_version",
")",
"{",
"if",
"(",
"$",
"plugin",
"&&",
"is_string",
"(",
"$",
"plugin",
")",
")",
"{",
"$",
"required",
"[",
"$",
"type",
"]",
"[",
"$",
"plugin",
"]",
"=",
"$",
"required_version",
";",
"$",
"is_plugin_active",
"=",
"is_plugin_active",
"(",
"$",
"plugin",
")",
";",
"if",
"(",
"is_bool",
"(",
"$",
"required_version",
")",
")",
"{",
"/**\n\t\t\t\t\t\t\t\t * When the required version is specified\n\t\t\t\t\t\t\t\t * as a Boolean (`true` or `false`),\n\t\t\t\t\t\t\t\t * then we do not need to check the version number,\n\t\t\t\t\t\t\t\t * just active or not.\n\t\t\t\t\t\t\t\t */",
"$",
"result",
"[",
"$",
"type",
"]",
"[",
"$",
"plugin",
"]",
"=",
"(",
"$",
"is_plugin_active",
"===",
"$",
"required_version",
")",
";",
"}",
"else",
"{",
"/**\n\t\t\t\t\t\t\t\t * Check that the plugin is active and\n\t\t\t\t\t\t\t\t * that its version matches the requirements.\n\t\t\t\t\t\t\t\t */",
"$",
"raw_data",
"=",
"get_plugin_data",
"(",
"WP_PLUGIN_DIR",
".",
"'/'",
".",
"$",
"plugin",
",",
"false",
",",
"false",
")",
";",
"// If the plugin does not have a version (?!) then",
"// we consider the version is OK.",
"$",
"is_plugin_version_ok",
"=",
"(",
"!",
"isset",
"(",
"$",
"raw_data",
"[",
"'Version'",
"]",
")",
"||",
"version_compare",
"(",
"$",
"raw_data",
"[",
"'Version'",
"]",
",",
"$",
"required_version",
",",
"$",
"this",
"->",
"version_compare_operator",
")",
")",
";",
"$",
"result",
"[",
"$",
"type",
"]",
"[",
"$",
"plugin",
"]",
"=",
"$",
"is_plugin_active",
"&&",
"$",
"is_plugin_version_ok",
";",
"}",
"}",
"}",
"break",
";",
"case",
"'theme'",
":",
"$",
"theme",
"=",
"(",
"array",
")",
"$",
"data",
";",
"$",
"current_theme",
"=",
"wp_get_theme",
"(",
")",
";",
"// Now check the theme: user defined slug can be either template",
"// (parent theme) or stylesheet (currently active theme).",
"foreach",
"(",
"$",
"theme",
"as",
"$",
"slug",
"=>",
"$",
"required_version",
")",
"{",
"if",
"(",
"(",
"$",
"current_theme",
"->",
"get_template",
"(",
")",
"===",
"$",
"slug",
"||",
"$",
"current_theme",
"->",
"get_stylesheet",
"(",
")",
"===",
"$",
"slug",
")",
"&&",
"version_compare",
"(",
"$",
"current_theme",
"->",
"get",
"(",
"'Version'",
")",
",",
"$",
"required_version",
",",
"$",
"this",
"->",
"version_compare_operator",
")",
")",
"{",
"$",
"result",
"[",
"$",
"type",
"]",
"[",
"$",
"slug",
"]",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"$",
"type",
"]",
"[",
"$",
"slug",
"]",
"=",
"false",
";",
"}",
"$",
"required",
"[",
"$",
"type",
"]",
"[",
"$",
"slug",
"]",
"=",
"$",
"required_version",
";",
"}",
"break",
";",
"}",
"}",
"$",
"this",
"->",
"results",
"[",
"'wordpress'",
"]",
"=",
"$",
"result",
";",
"$",
"this",
"->",
"required",
"[",
"'wordpress'",
"]",
"=",
"$",
"required",
";",
"}"
] | Check all WordPress related data, like version, plugins and theme
@param array $wordpress WordPress requirements. | [
"Check",
"all",
"WordPress",
"related",
"data",
"like",
"version",
"plugins",
"and",
"theme"
] | e903973b0dfc1178f89c757bd205327811ea4658 | https://github.com/bemailr/wp-requirements/blob/e903973b0dfc1178f89c757bd205327811ea4658/includes/class-wp-requirements.php#L249-L340 |
5,478 | bemailr/wp-requirements | includes/class-wp-requirements.php | WP_Requirements.process_failure | public function process_failure() {
if ( ! count( $this->results ) || ! count( $this->not_valid_actions ) ) {
return;
}
foreach ( $this->not_valid_actions as $action ) {
switch ( $action ) {
case 'deactivate':
deactivate_plugins( $this->get_plugin( 'basename' ), true );
if ( isset( $_GET['activate'] ) ) {
unset( $_GET['activate'] );
}
break;
case 'admin_notice':
add_action( 'admin_notices', array( $this, 'display_admin_notice' ) );
break;
}
}
} | php | public function process_failure() {
if ( ! count( $this->results ) || ! count( $this->not_valid_actions ) ) {
return;
}
foreach ( $this->not_valid_actions as $action ) {
switch ( $action ) {
case 'deactivate':
deactivate_plugins( $this->get_plugin( 'basename' ), true );
if ( isset( $_GET['activate'] ) ) {
unset( $_GET['activate'] );
}
break;
case 'admin_notice':
add_action( 'admin_notices', array( $this, 'display_admin_notice' ) );
break;
}
}
} | [
"public",
"function",
"process_failure",
"(",
")",
"{",
"if",
"(",
"!",
"count",
"(",
"$",
"this",
"->",
"results",
")",
"||",
"!",
"count",
"(",
"$",
"this",
"->",
"not_valid_actions",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"not_valid_actions",
"as",
"$",
"action",
")",
"{",
"switch",
"(",
"$",
"action",
")",
"{",
"case",
"'deactivate'",
":",
"deactivate_plugins",
"(",
"$",
"this",
"->",
"get_plugin",
"(",
"'basename'",
")",
",",
"true",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"_GET",
"[",
"'activate'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"_GET",
"[",
"'activate'",
"]",
")",
";",
"}",
"break",
";",
"case",
"'admin_notice'",
":",
"add_action",
"(",
"'admin_notices'",
",",
"array",
"(",
"$",
"this",
",",
"'display_admin_notice'",
")",
")",
";",
"break",
";",
"}",
"}",
"}"
] | Get the list of registered actions and do everything defined by them | [
"Get",
"the",
"list",
"of",
"registered",
"actions",
"and",
"do",
"everything",
"defined",
"by",
"them"
] | e903973b0dfc1178f89c757bd205327811ea4658 | https://github.com/bemailr/wp-requirements/blob/e903973b0dfc1178f89c757bd205327811ea4658/includes/class-wp-requirements.php#L356-L376 |
5,479 | bemailr/wp-requirements | includes/class-wp-requirements.php | WP_Requirements.display_admin_notice | public function display_admin_notice() {
echo '<div class="notice is-dismissible error">';
echo '<p>';
printf(
esc_html__( '%s will not function correctly because your site doesn\'t meet some of the requirements:', 'wp-requirements' ),
'<strong>' . esc_html( $this->get_plugin( 'name' ) ) . '</strong>'
);
echo '</p>';
// Display the link to more details, if we have it.
if ( $this->requirements_details_url ) {
printf(
'<p>' . esc_html__( 'Please read more details %s here %s.', 'wp-requirements' ) . '</p>',
'<a href="' . esc_url( $this->requirements_details_url ) . '">',
'</a>'
);
} else { // So we need to display all the failures in a notice.
echo '<ul>';
foreach ( $this->results as $type => $data ) {
$notices = $this->php_mysql_notices( $type, $data );
echo '<li>' . implode( '</li><li>', $notices ) . '</li>'; // WPCS: XSS ok.
}
echo '</ul>';
}
echo '</div>';
} | php | public function display_admin_notice() {
echo '<div class="notice is-dismissible error">';
echo '<p>';
printf(
esc_html__( '%s will not function correctly because your site doesn\'t meet some of the requirements:', 'wp-requirements' ),
'<strong>' . esc_html( $this->get_plugin( 'name' ) ) . '</strong>'
);
echo '</p>';
// Display the link to more details, if we have it.
if ( $this->requirements_details_url ) {
printf(
'<p>' . esc_html__( 'Please read more details %s here %s.', 'wp-requirements' ) . '</p>',
'<a href="' . esc_url( $this->requirements_details_url ) . '">',
'</a>'
);
} else { // So we need to display all the failures in a notice.
echo '<ul>';
foreach ( $this->results as $type => $data ) {
$notices = $this->php_mysql_notices( $type, $data );
echo '<li>' . implode( '</li><li>', $notices ) . '</li>'; // WPCS: XSS ok.
}
echo '</ul>';
}
echo '</div>';
} | [
"public",
"function",
"display_admin_notice",
"(",
")",
"{",
"echo",
"'<div class=\"notice is-dismissible error\">'",
";",
"echo",
"'<p>'",
";",
"printf",
"(",
"esc_html__",
"(",
"'%s will not function correctly because your site doesn\\'t meet some of the requirements:'",
",",
"'wp-requirements'",
")",
",",
"'<strong>'",
".",
"esc_html",
"(",
"$",
"this",
"->",
"get_plugin",
"(",
"'name'",
")",
")",
".",
"'</strong>'",
")",
";",
"echo",
"'</p>'",
";",
"// Display the link to more details, if we have it.",
"if",
"(",
"$",
"this",
"->",
"requirements_details_url",
")",
"{",
"printf",
"(",
"'<p>'",
".",
"esc_html__",
"(",
"'Please read more details %s here %s.'",
",",
"'wp-requirements'",
")",
".",
"'</p>'",
",",
"'<a href=\"'",
".",
"esc_url",
"(",
"$",
"this",
"->",
"requirements_details_url",
")",
".",
"'\">'",
",",
"'</a>'",
")",
";",
"}",
"else",
"{",
"// So we need to display all the failures in a notice.",
"echo",
"'<ul>'",
";",
"foreach",
"(",
"$",
"this",
"->",
"results",
"as",
"$",
"type",
"=>",
"$",
"data",
")",
"{",
"$",
"notices",
"=",
"$",
"this",
"->",
"php_mysql_notices",
"(",
"$",
"type",
",",
"$",
"data",
")",
";",
"echo",
"'<li>'",
".",
"implode",
"(",
"'</li><li>'",
",",
"$",
"notices",
")",
".",
"'</li>'",
";",
"// WPCS: XSS ok.",
"}",
"echo",
"'</ul>'",
";",
"}",
"echo",
"'</div>'",
";",
"}"
] | Display an admin notice in WordPress admin area | [
"Display",
"an",
"admin",
"notice",
"in",
"WordPress",
"admin",
"area"
] | e903973b0dfc1178f89c757bd205327811ea4658 | https://github.com/bemailr/wp-requirements/blob/e903973b0dfc1178f89c757bd205327811ea4658/includes/class-wp-requirements.php#L381-L411 |
5,480 | bemailr/wp-requirements | includes/class-wp-requirements.php | WP_Requirements.get_plugin | public function get_plugin( $data = '' ) {
// Get all the data.
if ( ! $data ) {
return $this->plugin;
}
// Get specific plugin data.
if ( ! empty( $this->plugin[ $data ] ) ) {
return $this->plugin[ $data ];
}
return null;
} | php | public function get_plugin( $data = '' ) {
// Get all the data.
if ( ! $data ) {
return $this->plugin;
}
// Get specific plugin data.
if ( ! empty( $this->plugin[ $data ] ) ) {
return $this->plugin[ $data ];
}
return null;
} | [
"public",
"function",
"get_plugin",
"(",
"$",
"data",
"=",
"''",
")",
"{",
"// Get all the data.",
"if",
"(",
"!",
"$",
"data",
")",
"{",
"return",
"$",
"this",
"->",
"plugin",
";",
"}",
"// Get specific plugin data.",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"plugin",
"[",
"$",
"data",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"plugin",
"[",
"$",
"data",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Retrieve current plugin data, like paths, name etc
@param string $data Which data is requested.
@return mixed | [
"Retrieve",
"current",
"plugin",
"data",
"like",
"paths",
"name",
"etc"
] | e903973b0dfc1178f89c757bd205327811ea4658 | https://github.com/bemailr/wp-requirements/blob/e903973b0dfc1178f89c757bd205327811ea4658/includes/class-wp-requirements.php#L625-L637 |
5,481 | bemailr/wp-requirements | includes/class-wp-requirements.php | WP_Requirements.load_json | protected function load_json() {
$json_file = $this->locate_configuration_file();
$json_data = '{}';
if ( '' !== $json_file ) {
$json_data = file_get_contents( $json_file );
}
return $json_data ? $this->parse_json( $json_data ) : array();
} | php | protected function load_json() {
$json_file = $this->locate_configuration_file();
$json_data = '{}';
if ( '' !== $json_file ) {
$json_data = file_get_contents( $json_file );
}
return $json_data ? $this->parse_json( $json_data ) : array();
} | [
"protected",
"function",
"load_json",
"(",
")",
"{",
"$",
"json_file",
"=",
"$",
"this",
"->",
"locate_configuration_file",
"(",
")",
";",
"$",
"json_data",
"=",
"'{}'",
";",
"if",
"(",
"''",
"!==",
"$",
"json_file",
")",
"{",
"$",
"json_data",
"=",
"file_get_contents",
"(",
"$",
"json_file",
")",
";",
"}",
"return",
"$",
"json_data",
"?",
"$",
"this",
"->",
"parse_json",
"(",
"$",
"json_data",
")",
":",
"array",
"(",
")",
";",
"}"
] | Load wp-requirements.json
@return array | [
"Load",
"wp",
"-",
"requirements",
".",
"json"
] | e903973b0dfc1178f89c757bd205327811ea4658 | https://github.com/bemailr/wp-requirements/blob/e903973b0dfc1178f89c757bd205327811ea4658/includes/class-wp-requirements.php#L644-L653 |
5,482 | bemailr/wp-requirements | includes/class-wp-requirements.php | WP_Requirements.locate_configuration_file | protected function locate_configuration_file() {
$located = '';
// By default, search only in the plugin folder.
$folders = array( dirname( $this->get_plugin( 'fullpath' ) ) );
/**
* Filter to modify the array of configuration folders.
*
* @since 2.0.0
*
* @param string[] $folders The array of folders.
*/
$folders = (array) apply_filters( 'wp_requirements_configuration_folders', $folders );
foreach ( $folders as $folder ) {
$path = trailingslashit( $folder ) . self::CONFIG_FILE_NAME;
if ( is_readable( $path ) ) {
$located = $path;
break;
}
}
return $located;
} | php | protected function locate_configuration_file() {
$located = '';
// By default, search only in the plugin folder.
$folders = array( dirname( $this->get_plugin( 'fullpath' ) ) );
/**
* Filter to modify the array of configuration folders.
*
* @since 2.0.0
*
* @param string[] $folders The array of folders.
*/
$folders = (array) apply_filters( 'wp_requirements_configuration_folders', $folders );
foreach ( $folders as $folder ) {
$path = trailingslashit( $folder ) . self::CONFIG_FILE_NAME;
if ( is_readable( $path ) ) {
$located = $path;
break;
}
}
return $located;
} | [
"protected",
"function",
"locate_configuration_file",
"(",
")",
"{",
"$",
"located",
"=",
"''",
";",
"// By default, search only in the plugin folder.",
"$",
"folders",
"=",
"array",
"(",
"dirname",
"(",
"$",
"this",
"->",
"get_plugin",
"(",
"'fullpath'",
")",
")",
")",
";",
"/**\n\t\t * Filter to modify the array of configuration folders.\n\t\t *\n\t\t * @since 2.0.0\n\t\t *\n\t\t * @param string[] $folders The array of folders.\n\t\t */",
"$",
"folders",
"=",
"(",
"array",
")",
"apply_filters",
"(",
"'wp_requirements_configuration_folders'",
",",
"$",
"folders",
")",
";",
"foreach",
"(",
"$",
"folders",
"as",
"$",
"folder",
")",
"{",
"$",
"path",
"=",
"trailingslashit",
"(",
"$",
"folder",
")",
".",
"self",
"::",
"CONFIG_FILE_NAME",
";",
"if",
"(",
"is_readable",
"(",
"$",
"path",
")",
")",
"{",
"$",
"located",
"=",
"$",
"path",
";",
"break",
";",
"}",
"}",
"return",
"$",
"located",
";",
"}"
] | Search for a configuration file.
@return string Path to the file found. Blank string if not found. | [
"Search",
"for",
"a",
"configuration",
"file",
"."
] | e903973b0dfc1178f89c757bd205327811ea4658 | https://github.com/bemailr/wp-requirements/blob/e903973b0dfc1178f89c757bd205327811ea4658/includes/class-wp-requirements.php#L660-L685 |
5,483 | bemailr/wp-requirements | includes/class-wp-requirements.php | WP_Requirements.parse_json | protected function parse_json( $json ) {
$data = json_decode( $json, true );
if ( ! is_array( $data ) ) {
$data = array();
}
return $data;
} | php | protected function parse_json( $json ) {
$data = json_decode( $json, true );
if ( ! is_array( $data ) ) {
$data = array();
}
return $data;
} | [
"protected",
"function",
"parse_json",
"(",
"$",
"json",
")",
"{",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"json",
",",
"true",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Parse JSON string to make it an array that is usable for us
@param string $json JSON string.
@return array | [
"Parse",
"JSON",
"string",
"to",
"make",
"it",
"an",
"array",
"that",
"is",
"usable",
"for",
"us"
] | e903973b0dfc1178f89c757bd205327811ea4658 | https://github.com/bemailr/wp-requirements/blob/e903973b0dfc1178f89c757bd205327811ea4658/includes/class-wp-requirements.php#L694-L703 |
5,484 | bemailr/wp-requirements | includes/class-wp-requirements.php | WP_Requirements.validate | public static function validate( $the__file__, array $requirements = array() ) {
$_wpr = new WP_Requirements( $the__file__, $requirements );
$is_valid = $_wpr->valid();
if ( ! $is_valid ) {
$_wpr->process_failure();
}
return $is_valid;
} | php | public static function validate( $the__file__, array $requirements = array() ) {
$_wpr = new WP_Requirements( $the__file__, $requirements );
$is_valid = $_wpr->valid();
if ( ! $is_valid ) {
$_wpr->process_failure();
}
return $is_valid;
} | [
"public",
"static",
"function",
"validate",
"(",
"$",
"the__file__",
",",
"array",
"$",
"requirements",
"=",
"array",
"(",
")",
")",
"{",
"$",
"_wpr",
"=",
"new",
"WP_Requirements",
"(",
"$",
"the__file__",
",",
"$",
"requirements",
")",
";",
"$",
"is_valid",
"=",
"$",
"_wpr",
"->",
"valid",
"(",
")",
";",
"if",
"(",
"!",
"$",
"is_valid",
")",
"{",
"$",
"_wpr",
"->",
"process_failure",
"(",
")",
";",
"}",
"return",
"$",
"is_valid",
";",
"}"
] | Shortcut to construct the object and process the failure actions.
@param string $the__file__ Pass `__FILE__` from the loader.
@param array $requirements The array of requirements.
@return bool True if requirements met. | [
"Shortcut",
"to",
"construct",
"the",
"object",
"and",
"process",
"the",
"failure",
"actions",
"."
] | e903973b0dfc1178f89c757bd205327811ea4658 | https://github.com/bemailr/wp-requirements/blob/e903973b0dfc1178f89c757bd205327811ea4658/includes/class-wp-requirements.php#L713-L723 |
5,485 | Atlantic18/CoralContentBundle | Controller/NodeController.php | NodeController.getTreeQueryAsArray | private function getTreeQueryAsArray(\Doctrine\ORM\Query $query)
{
$items = array();
$index = array();
$nodes = $query->getResult();
$count = count($nodes);
for($i = 0; $i < $count; $i++)
{
$node = $nodes[$i];
$newItem = array(
'id' => $node->getId(),
'name' => $node->getName(),
'slug' => $node->getSlug()
);
if($i == 0)
{
//for first item - parent of the subtree - add tree_ params
$newItem = array_merge($this->getParentTreeParams($node), $newItem);
}
foreach ($node->getNodeAttributes() as $attribute) {
$newItem[$attribute->getName()] = $attribute->getValue();
}
if(($node->getParent()) && isset($index[$node->getParent()->getId()]))
{
$_path = $index[$node->getParent()->getId()];
eval('$parent = &$items' . $_path . ';');
if(!isset($parent['items']))
{
$parent['items'] = array();
}
//copy tree_ params
foreach ($parent as $paramKey => $paramValue)
{
if(substr($paramKey, 0, 5) == 'tree_')
{
$newItem[$paramKey] = $paramValue;
}
}
$index[$node->getId()] = $_path . '["items"][' . count($parent['items']) . ']';
$parent['items'][] = $newItem;
}
else
{
$index[$node->getId()] = '[' . count($items) . ']';
$items[] = $newItem;
}
}
return $items;
} | php | private function getTreeQueryAsArray(\Doctrine\ORM\Query $query)
{
$items = array();
$index = array();
$nodes = $query->getResult();
$count = count($nodes);
for($i = 0; $i < $count; $i++)
{
$node = $nodes[$i];
$newItem = array(
'id' => $node->getId(),
'name' => $node->getName(),
'slug' => $node->getSlug()
);
if($i == 0)
{
//for first item - parent of the subtree - add tree_ params
$newItem = array_merge($this->getParentTreeParams($node), $newItem);
}
foreach ($node->getNodeAttributes() as $attribute) {
$newItem[$attribute->getName()] = $attribute->getValue();
}
if(($node->getParent()) && isset($index[$node->getParent()->getId()]))
{
$_path = $index[$node->getParent()->getId()];
eval('$parent = &$items' . $_path . ';');
if(!isset($parent['items']))
{
$parent['items'] = array();
}
//copy tree_ params
foreach ($parent as $paramKey => $paramValue)
{
if(substr($paramKey, 0, 5) == 'tree_')
{
$newItem[$paramKey] = $paramValue;
}
}
$index[$node->getId()] = $_path . '["items"][' . count($parent['items']) . ']';
$parent['items'][] = $newItem;
}
else
{
$index[$node->getId()] = '[' . count($items) . ']';
$items[] = $newItem;
}
}
return $items;
} | [
"private",
"function",
"getTreeQueryAsArray",
"(",
"\\",
"Doctrine",
"\\",
"ORM",
"\\",
"Query",
"$",
"query",
")",
"{",
"$",
"items",
"=",
"array",
"(",
")",
";",
"$",
"index",
"=",
"array",
"(",
")",
";",
"$",
"nodes",
"=",
"$",
"query",
"->",
"getResult",
"(",
")",
";",
"$",
"count",
"=",
"count",
"(",
"$",
"nodes",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"count",
";",
"$",
"i",
"++",
")",
"{",
"$",
"node",
"=",
"$",
"nodes",
"[",
"$",
"i",
"]",
";",
"$",
"newItem",
"=",
"array",
"(",
"'id'",
"=>",
"$",
"node",
"->",
"getId",
"(",
")",
",",
"'name'",
"=>",
"$",
"node",
"->",
"getName",
"(",
")",
",",
"'slug'",
"=>",
"$",
"node",
"->",
"getSlug",
"(",
")",
")",
";",
"if",
"(",
"$",
"i",
"==",
"0",
")",
"{",
"//for first item - parent of the subtree - add tree_ params",
"$",
"newItem",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"getParentTreeParams",
"(",
"$",
"node",
")",
",",
"$",
"newItem",
")",
";",
"}",
"foreach",
"(",
"$",
"node",
"->",
"getNodeAttributes",
"(",
")",
"as",
"$",
"attribute",
")",
"{",
"$",
"newItem",
"[",
"$",
"attribute",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"attribute",
"->",
"getValue",
"(",
")",
";",
"}",
"if",
"(",
"(",
"$",
"node",
"->",
"getParent",
"(",
")",
")",
"&&",
"isset",
"(",
"$",
"index",
"[",
"$",
"node",
"->",
"getParent",
"(",
")",
"->",
"getId",
"(",
")",
"]",
")",
")",
"{",
"$",
"_path",
"=",
"$",
"index",
"[",
"$",
"node",
"->",
"getParent",
"(",
")",
"->",
"getId",
"(",
")",
"]",
";",
"eval",
"(",
"'$parent = &$items'",
".",
"$",
"_path",
".",
"';'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"parent",
"[",
"'items'",
"]",
")",
")",
"{",
"$",
"parent",
"[",
"'items'",
"]",
"=",
"array",
"(",
")",
";",
"}",
"//copy tree_ params",
"foreach",
"(",
"$",
"parent",
"as",
"$",
"paramKey",
"=>",
"$",
"paramValue",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"paramKey",
",",
"0",
",",
"5",
")",
"==",
"'tree_'",
")",
"{",
"$",
"newItem",
"[",
"$",
"paramKey",
"]",
"=",
"$",
"paramValue",
";",
"}",
"}",
"$",
"index",
"[",
"$",
"node",
"->",
"getId",
"(",
")",
"]",
"=",
"$",
"_path",
".",
"'[\"items\"]['",
".",
"count",
"(",
"$",
"parent",
"[",
"'items'",
"]",
")",
".",
"']'",
";",
"$",
"parent",
"[",
"'items'",
"]",
"[",
"]",
"=",
"$",
"newItem",
";",
"}",
"else",
"{",
"$",
"index",
"[",
"$",
"node",
"->",
"getId",
"(",
")",
"]",
"=",
"'['",
".",
"count",
"(",
"$",
"items",
")",
".",
"']'",
";",
"$",
"items",
"[",
"]",
"=",
"$",
"newItem",
";",
"}",
"}",
"return",
"$",
"items",
";",
"}"
] | Returns doctrine query nested set as an array for json
@param DoctrineORMQuery $query Nested set tree query
@return array Result as array for json | [
"Returns",
"doctrine",
"query",
"nested",
"set",
"as",
"an",
"array",
"for",
"json"
] | 26ebc612959ca8ba7d429424c39a9fc5b0778ffc | https://github.com/Atlantic18/CoralContentBundle/blob/26ebc612959ca8ba7d429424c39a9fc5b0778ffc/Controller/NodeController.php#L103-L156 |
5,486 | Atlantic18/CoralContentBundle | Controller/NodeController.php | NodeController.getParentTreeParams | private function getParentTreeParams(\Coral\ContentBundle\Entity\Node $node)
{
$params = $this->getDoctrine()->getManager()->createQuery(
'SELECT n.level, na.name, na.value
FROM CoralContentBundle:NodeAttribute na
INNER JOIN na.node n WITH (n.lft < :lft AND n.rgt > :rgt)
INNER JOIN n.account a WITH (a.id = :account_id)
WHERE
na.name LIKE \'tree_%\'
ORDER BY n.level ASC'
)
->setParameter('account_id', $this->getAccount()->getId())
->setParameter('lft', $node->getLft())
->setParameter('rgt', $node->getRgt())
->getResult(\Doctrine\ORM\AbstractQuery::HYDRATE_ARRAY);
$treeParams = array();
foreach ($params as $param)
{
$treeParams[$param['name']] = $param['value'];
}
return $treeParams;
} | php | private function getParentTreeParams(\Coral\ContentBundle\Entity\Node $node)
{
$params = $this->getDoctrine()->getManager()->createQuery(
'SELECT n.level, na.name, na.value
FROM CoralContentBundle:NodeAttribute na
INNER JOIN na.node n WITH (n.lft < :lft AND n.rgt > :rgt)
INNER JOIN n.account a WITH (a.id = :account_id)
WHERE
na.name LIKE \'tree_%\'
ORDER BY n.level ASC'
)
->setParameter('account_id', $this->getAccount()->getId())
->setParameter('lft', $node->getLft())
->setParameter('rgt', $node->getRgt())
->getResult(\Doctrine\ORM\AbstractQuery::HYDRATE_ARRAY);
$treeParams = array();
foreach ($params as $param)
{
$treeParams[$param['name']] = $param['value'];
}
return $treeParams;
} | [
"private",
"function",
"getParentTreeParams",
"(",
"\\",
"Coral",
"\\",
"ContentBundle",
"\\",
"Entity",
"\\",
"Node",
"$",
"node",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
"->",
"createQuery",
"(",
"'SELECT n.level, na.name, na.value\n FROM CoralContentBundle:NodeAttribute na\n INNER JOIN na.node n WITH (n.lft < :lft AND n.rgt > :rgt)\n INNER JOIN n.account a WITH (a.id = :account_id)\n WHERE\n na.name LIKE \\'tree_%\\'\n ORDER BY n.level ASC'",
")",
"->",
"setParameter",
"(",
"'account_id'",
",",
"$",
"this",
"->",
"getAccount",
"(",
")",
"->",
"getId",
"(",
")",
")",
"->",
"setParameter",
"(",
"'lft'",
",",
"$",
"node",
"->",
"getLft",
"(",
")",
")",
"->",
"setParameter",
"(",
"'rgt'",
",",
"$",
"node",
"->",
"getRgt",
"(",
")",
")",
"->",
"getResult",
"(",
"\\",
"Doctrine",
"\\",
"ORM",
"\\",
"AbstractQuery",
"::",
"HYDRATE_ARRAY",
")",
";",
"$",
"treeParams",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"param",
")",
"{",
"$",
"treeParams",
"[",
"$",
"param",
"[",
"'name'",
"]",
"]",
"=",
"$",
"param",
"[",
"'value'",
"]",
";",
"}",
"return",
"$",
"treeParams",
";",
"}"
] | Fetches all parent params and returns as array
@param CoralContentBundleEntityNode $node Child node
@return array param => value | [
"Fetches",
"all",
"parent",
"params",
"and",
"returns",
"as",
"array"
] | 26ebc612959ca8ba7d429424c39a9fc5b0778ffc | https://github.com/Atlantic18/CoralContentBundle/blob/26ebc612959ca8ba7d429424c39a9fc5b0778ffc/Controller/NodeController.php#L164-L188 |
5,487 | fabsgc/framework | Core/Controller/Controller.php | Controller.showDefault | final public function showDefault() {
$request = Request::instance();
$t = new Template('.app/system/default', 'systemDefault');
$t->assign(['action' => $request->src . '::' . $request->controller . '::' . $request->action]);
return $t->show();
} | php | final public function showDefault() {
$request = Request::instance();
$t = new Template('.app/system/default', 'systemDefault');
$t->assign(['action' => $request->src . '::' . $request->controller . '::' . $request->action]);
return $t->show();
} | [
"final",
"public",
"function",
"showDefault",
"(",
")",
"{",
"$",
"request",
"=",
"Request",
"::",
"instance",
"(",
")",
";",
"$",
"t",
"=",
"new",
"Template",
"(",
"'.app/system/default'",
",",
"'systemDefault'",
")",
";",
"$",
"t",
"->",
"assign",
"(",
"[",
"'action'",
"=>",
"$",
"request",
"->",
"src",
".",
"'::'",
".",
"$",
"request",
"->",
"controller",
".",
"'::'",
".",
"$",
"request",
"->",
"action",
"]",
")",
";",
"return",
"$",
"t",
"->",
"show",
"(",
")",
";",
"}"
] | display a default template
@access public
@return string
@since 3.0
@package Gcs\Framework\Core\Controller | [
"display",
"a",
"default",
"template"
] | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Controller/Controller.php#L133-L139 |
5,488 | jaeger-app/compress | src/Compress.php | Compress.extract | public function extract($file, $destination = false)
{
$archive = $this->getArchiver()->open($file);
if ($archive) {
$this->getArchiver()->extractTo($destination);
return $this->getArchiver()->close();
}
} | php | public function extract($file, $destination = false)
{
$archive = $this->getArchiver()->open($file);
if ($archive) {
$this->getArchiver()->extractTo($destination);
return $this->getArchiver()->close();
}
} | [
"public",
"function",
"extract",
"(",
"$",
"file",
",",
"$",
"destination",
"=",
"false",
")",
"{",
"$",
"archive",
"=",
"$",
"this",
"->",
"getArchiver",
"(",
")",
"->",
"open",
"(",
"$",
"file",
")",
";",
"if",
"(",
"$",
"archive",
")",
"{",
"$",
"this",
"->",
"getArchiver",
"(",
")",
"->",
"extractTo",
"(",
"$",
"destination",
")",
";",
"return",
"$",
"this",
"->",
"getArchiver",
"(",
")",
"->",
"close",
"(",
")",
";",
"}",
"}"
] | Extracts a compressed file to the destination
@param string $file
The full path to the file to extract
@param string $destination
The destination to extract to
@return bool | [
"Extracts",
"a",
"compressed",
"file",
"to",
"the",
"destination"
] | 28d0532af7c24ddc1423be8383fa2e4732d8de99 | https://github.com/jaeger-app/compress/blob/28d0532af7c24ddc1423be8383fa2e4732d8de99/src/Compress.php#L69-L76 |
5,489 | jaeger-app/compress | src/Compress.php | Compress.create | public function create($name)
{
$this->setArchiveName($name);
$this->getArchiver()->open($this->getArchiveName(), \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
return $this;
} | php | public function create($name)
{
$this->setArchiveName($name);
$this->getArchiver()->open($this->getArchiveName(), \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
return $this;
} | [
"public",
"function",
"create",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"setArchiveName",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"getArchiver",
"(",
")",
"->",
"open",
"(",
"$",
"this",
"->",
"getArchiveName",
"(",
")",
",",
"\\",
"ZipArchive",
"::",
"CREATE",
"|",
"\\",
"ZipArchive",
"::",
"OVERWRITE",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Starts the process of creating an archive
@param string $name
@return \mithra62\Compress | [
"Starts",
"the",
"process",
"of",
"creating",
"an",
"archive"
] | 28d0532af7c24ddc1423be8383fa2e4732d8de99 | https://github.com/jaeger-app/compress/blob/28d0532af7c24ddc1423be8383fa2e4732d8de99/src/Compress.php#L106-L111 |
5,490 | jaeger-app/compress | src/Compress.php | Compress.archiveSingle | public function archiveSingle($file, $desination = false)
{
if ($file == '') {
throw new CompressException('__exception_compress_file_value_empty');
}
if (! file_exists($file)) {
throw new CompressException('__exception_compress_file_not_exist');
}
if (! is_readable($file)) {
throw new CompressException('__exception_compress_file_not_readable');
}
// work out path stuff
$old_cwd = getcwd();
$path = dirname($file);
chdir($path);
$name = $this->getArchiveName();
$zip = $this->getArchiver();
$zip->open($name, \ZipArchive::CREATE);
if (file_exists($file)) {
$zip->addFile(basename($file));
}
if ($zip->status != '0') {
throw new CompressException('__exception_compression');
}
$zip->close();
if (! $this->getKeepOriginal() && file_exists($file)) {
unlink($file);
}
if ($desination) {
$desination = realpath($desination) . DIRECTORY_SEPARATOR . $name;
copy($name, $desination);
unlink($name);
$name = $desination;
} else {
$name = $path . DIRECTORY_SEPARATOR . $name;
}
// reset path
chdir($old_cwd);
return $name;
} | php | public function archiveSingle($file, $desination = false)
{
if ($file == '') {
throw new CompressException('__exception_compress_file_value_empty');
}
if (! file_exists($file)) {
throw new CompressException('__exception_compress_file_not_exist');
}
if (! is_readable($file)) {
throw new CompressException('__exception_compress_file_not_readable');
}
// work out path stuff
$old_cwd = getcwd();
$path = dirname($file);
chdir($path);
$name = $this->getArchiveName();
$zip = $this->getArchiver();
$zip->open($name, \ZipArchive::CREATE);
if (file_exists($file)) {
$zip->addFile(basename($file));
}
if ($zip->status != '0') {
throw new CompressException('__exception_compression');
}
$zip->close();
if (! $this->getKeepOriginal() && file_exists($file)) {
unlink($file);
}
if ($desination) {
$desination = realpath($desination) . DIRECTORY_SEPARATOR . $name;
copy($name, $desination);
unlink($name);
$name = $desination;
} else {
$name = $path . DIRECTORY_SEPARATOR . $name;
}
// reset path
chdir($old_cwd);
return $name;
} | [
"public",
"function",
"archiveSingle",
"(",
"$",
"file",
",",
"$",
"desination",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"file",
"==",
"''",
")",
"{",
"throw",
"new",
"CompressException",
"(",
"'__exception_compress_file_value_empty'",
")",
";",
"}",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"throw",
"new",
"CompressException",
"(",
"'__exception_compress_file_not_exist'",
")",
";",
"}",
"if",
"(",
"!",
"is_readable",
"(",
"$",
"file",
")",
")",
"{",
"throw",
"new",
"CompressException",
"(",
"'__exception_compress_file_not_readable'",
")",
";",
"}",
"// work out path stuff",
"$",
"old_cwd",
"=",
"getcwd",
"(",
")",
";",
"$",
"path",
"=",
"dirname",
"(",
"$",
"file",
")",
";",
"chdir",
"(",
"$",
"path",
")",
";",
"$",
"name",
"=",
"$",
"this",
"->",
"getArchiveName",
"(",
")",
";",
"$",
"zip",
"=",
"$",
"this",
"->",
"getArchiver",
"(",
")",
";",
"$",
"zip",
"->",
"open",
"(",
"$",
"name",
",",
"\\",
"ZipArchive",
"::",
"CREATE",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"$",
"zip",
"->",
"addFile",
"(",
"basename",
"(",
"$",
"file",
")",
")",
";",
"}",
"if",
"(",
"$",
"zip",
"->",
"status",
"!=",
"'0'",
")",
"{",
"throw",
"new",
"CompressException",
"(",
"'__exception_compression'",
")",
";",
"}",
"$",
"zip",
"->",
"close",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"getKeepOriginal",
"(",
")",
"&&",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"unlink",
"(",
"$",
"file",
")",
";",
"}",
"if",
"(",
"$",
"desination",
")",
"{",
"$",
"desination",
"=",
"realpath",
"(",
"$",
"desination",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"name",
";",
"copy",
"(",
"$",
"name",
",",
"$",
"desination",
")",
";",
"unlink",
"(",
"$",
"name",
")",
";",
"$",
"name",
"=",
"$",
"desination",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"$",
"path",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"name",
";",
"}",
"// reset path",
"chdir",
"(",
"$",
"old_cwd",
")",
";",
"return",
"$",
"name",
";",
"}"
] | Compresses a single file
@param string $file
the full path to the file to compress
@param string $desination
optional the full path to the destination. If none is given then $file is used with the extension appended | [
"Compresses",
"a",
"single",
"file"
] | 28d0532af7c24ddc1423be8383fa2e4732d8de99 | https://github.com/jaeger-app/compress/blob/28d0532af7c24ddc1423be8383fa2e4732d8de99/src/Compress.php#L145-L195 |
5,491 | TreasurerPHP/Models | src/models/Invoice.php | Invoice.pay | public function pay($amount, $parameters) {
$payment = new InvoicePayment();
$payment->amount = $amount;
$payment->setPreCommitMetadataArray($parameters['metadata']);
$payment->invoice()->associate($this);
$payment->type()->associate($parameters['type']);
if(isset($parameters['id'])) {
$payment->payment_id = $parameters['id'];
}
$payment->save();
return $payment;
} | php | public function pay($amount, $parameters) {
$payment = new InvoicePayment();
$payment->amount = $amount;
$payment->setPreCommitMetadataArray($parameters['metadata']);
$payment->invoice()->associate($this);
$payment->type()->associate($parameters['type']);
if(isset($parameters['id'])) {
$payment->payment_id = $parameters['id'];
}
$payment->save();
return $payment;
} | [
"public",
"function",
"pay",
"(",
"$",
"amount",
",",
"$",
"parameters",
")",
"{",
"$",
"payment",
"=",
"new",
"InvoicePayment",
"(",
")",
";",
"$",
"payment",
"->",
"amount",
"=",
"$",
"amount",
";",
"$",
"payment",
"->",
"setPreCommitMetadataArray",
"(",
"$",
"parameters",
"[",
"'metadata'",
"]",
")",
";",
"$",
"payment",
"->",
"invoice",
"(",
")",
"->",
"associate",
"(",
"$",
"this",
")",
";",
"$",
"payment",
"->",
"type",
"(",
")",
"->",
"associate",
"(",
"$",
"parameters",
"[",
"'type'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"parameters",
"[",
"'id'",
"]",
")",
")",
"{",
"$",
"payment",
"->",
"payment_id",
"=",
"$",
"parameters",
"[",
"'id'",
"]",
";",
"}",
"$",
"payment",
"->",
"save",
"(",
")",
";",
"return",
"$",
"payment",
";",
"}"
] | Apply a payment to this invoice.
@param $amount
@param $parameters String[][] Key/value array: type => PaymentType, id => string
@return InvoicePayment Return the invoice payment made. | [
"Apply",
"a",
"payment",
"to",
"this",
"invoice",
"."
] | 614c57b78b313fd88167735fe3f3dc0183ee6bda | https://github.com/TreasurerPHP/Models/blob/614c57b78b313fd88167735fe3f3dc0183ee6bda/src/models/Invoice.php#L44-L59 |
5,492 | Jinxes/layton | Layton/Container.php | Container.offsetGet | public function offsetGet($offset)
{
if (! $this->has($offset)) {
throw new UnknownIdentifierException($offset);
}
if (!isset($this->_frozen[$offset])) {
$entry = &$this->_store[$offset];
if (is_callable($entry)) {
$entry = $entry($this);
}
$this->_frozen[$offset] = &$entry;
}
return $this->_frozen[$offset];
} | php | public function offsetGet($offset)
{
if (! $this->has($offset)) {
throw new UnknownIdentifierException($offset);
}
if (!isset($this->_frozen[$offset])) {
$entry = &$this->_store[$offset];
if (is_callable($entry)) {
$entry = $entry($this);
}
$this->_frozen[$offset] = &$entry;
}
return $this->_frozen[$offset];
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"offset",
")",
")",
"{",
"throw",
"new",
"UnknownIdentifierException",
"(",
"$",
"offset",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_frozen",
"[",
"$",
"offset",
"]",
")",
")",
"{",
"$",
"entry",
"=",
"&",
"$",
"this",
"->",
"_store",
"[",
"$",
"offset",
"]",
";",
"if",
"(",
"is_callable",
"(",
"$",
"entry",
")",
")",
"{",
"$",
"entry",
"=",
"$",
"entry",
"(",
"$",
"this",
")",
";",
"}",
"$",
"this",
"->",
"_frozen",
"[",
"$",
"offset",
"]",
"=",
"&",
"$",
"entry",
";",
"}",
"return",
"$",
"this",
"->",
"_frozen",
"[",
"$",
"offset",
"]",
";",
"}"
] | Retrieve an entry to return.
@param string|integer $offset
@throws UnknownIdentifierException No entry was found for **this** identifier.
@return mixed Entry | [
"Retrieve",
"an",
"entry",
"to",
"return",
"."
] | 27b8eab2c59b9887eb93e40a533eb77cc5690584 | https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Container.php#L75-L90 |
5,493 | Jinxes/layton | Layton/Container.php | Container.offsetSet | public function offsetSet($offset, $value)
{
if ($this->has($offset)) {
throw new StoreReattachException('The entry is exists.');
}
$this->_store[$offset] = $value;
} | php | public function offsetSet($offset, $value)
{
if ($this->has($offset)) {
throw new StoreReattachException('The entry is exists.');
}
$this->_store[$offset] = $value;
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"offset",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"offset",
")",
")",
"{",
"throw",
"new",
"StoreReattachException",
"(",
"'The entry is exists.'",
")",
";",
"}",
"$",
"this",
"->",
"_store",
"[",
"$",
"offset",
"]",
"=",
"$",
"value",
";",
"}"
] | Assign a value to the specified entry id.
@param string|integer $offset Entry id
@param mixed $value Entry
@throws StoreReattachException When entry is exists. | [
"Assign",
"a",
"value",
"to",
"the",
"specified",
"entry",
"id",
"."
] | 27b8eab2c59b9887eb93e40a533eb77cc5690584 | https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Container.php#L100-L107 |
5,494 | Jinxes/layton | Layton/Container.php | Container.offsetUnset | public function offsetUnset($offset)
{
if ($this->has($offset)) {
unset(
$this->_store[$offset],
$this->_frozen[$offset]
);
}
} | php | public function offsetUnset($offset)
{
if ($this->has($offset)) {
unset(
$this->_store[$offset],
$this->_frozen[$offset]
);
}
} | [
"public",
"function",
"offsetUnset",
"(",
"$",
"offset",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"offset",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_store",
"[",
"$",
"offset",
"]",
",",
"$",
"this",
"->",
"_frozen",
"[",
"$",
"offset",
"]",
")",
";",
"}",
"}"
] | Unset an Entry
@param string|integer $offset Entry id | [
"Unset",
"an",
"Entry"
] | 27b8eab2c59b9887eb93e40a533eb77cc5690584 | https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Container.php#L114-L122 |
5,495 | Jinxes/layton | Layton/Container.php | Container.clear | public function clear()
{
foreach ($this->keys() as $key) {
unset($this->_store[$key]);
}
$frozenKeys = \array_keys($this->_frozen);
foreach ($frozenKeys as $key) {
unset($this->_frozen[$key]);
}
} | php | public function clear()
{
foreach ($this->keys() as $key) {
unset($this->_store[$key]);
}
$frozenKeys = \array_keys($this->_frozen);
foreach ($frozenKeys as $key) {
unset($this->_frozen[$key]);
}
} | [
"public",
"function",
"clear",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"keys",
"(",
")",
"as",
"$",
"key",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_store",
"[",
"$",
"key",
"]",
")",
";",
"}",
"$",
"frozenKeys",
"=",
"\\",
"array_keys",
"(",
"$",
"this",
"->",
"_frozen",
")",
";",
"foreach",
"(",
"$",
"frozenKeys",
"as",
"$",
"key",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_frozen",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}"
] | Clear store and frozen entrys | [
"Clear",
"store",
"and",
"frozen",
"entrys"
] | 27b8eab2c59b9887eb93e40a533eb77cc5690584 | https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Container.php#L127-L136 |
5,496 | titon/model | src/Titon/Model/Model.php | Model.addRelation | public function addRelation(Relation $relation) {
$relation->setPrimaryModel($this);
$this->_relations[$relation->getAlias()] = $relation;
$this->_aliases[$relation->getRelatedClass()] = $relation->getAlias();
$this->reserved[] = $relation->getAlias();
$this->on('relation', $relation);
return $this;
} | php | public function addRelation(Relation $relation) {
$relation->setPrimaryModel($this);
$this->_relations[$relation->getAlias()] = $relation;
$this->_aliases[$relation->getRelatedClass()] = $relation->getAlias();
$this->reserved[] = $relation->getAlias();
$this->on('relation', $relation);
return $this;
} | [
"public",
"function",
"addRelation",
"(",
"Relation",
"$",
"relation",
")",
"{",
"$",
"relation",
"->",
"setPrimaryModel",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"_relations",
"[",
"$",
"relation",
"->",
"getAlias",
"(",
")",
"]",
"=",
"$",
"relation",
";",
"$",
"this",
"->",
"_aliases",
"[",
"$",
"relation",
"->",
"getRelatedClass",
"(",
")",
"]",
"=",
"$",
"relation",
"->",
"getAlias",
"(",
")",
";",
"$",
"this",
"->",
"reserved",
"[",
"]",
"=",
"$",
"relation",
"->",
"getAlias",
"(",
")",
";",
"$",
"this",
"->",
"on",
"(",
"'relation'",
",",
"$",
"relation",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Add a relation between two models.
@param \Titon\Model\Relation $relation
@return $this | [
"Add",
"a",
"relation",
"between",
"two",
"models",
"."
] | 274e3810c2cfbb6818a388daaa462ff05de99cbd | https://github.com/titon/model/blob/274e3810c2cfbb6818a388daaa462ff05de99cbd/src/Titon/Model/Model.php#L285-L295 |
5,497 | titon/model | src/Titon/Model/Model.php | Model.belongsTo | public function belongsTo($alias, $class, $foreignKey = null, Closure $conditions = null) {
$relation = (new ManyToOne($alias, $class))
->setPrimaryForeignKey($foreignKey);
if ($conditions) {
$relation->setConditions($conditions);
}
return $this->addRelation($relation);
} | php | public function belongsTo($alias, $class, $foreignKey = null, Closure $conditions = null) {
$relation = (new ManyToOne($alias, $class))
->setPrimaryForeignKey($foreignKey);
if ($conditions) {
$relation->setConditions($conditions);
}
return $this->addRelation($relation);
} | [
"public",
"function",
"belongsTo",
"(",
"$",
"alias",
",",
"$",
"class",
",",
"$",
"foreignKey",
"=",
"null",
",",
"Closure",
"$",
"conditions",
"=",
"null",
")",
"{",
"$",
"relation",
"=",
"(",
"new",
"ManyToOne",
"(",
"$",
"alias",
",",
"$",
"class",
")",
")",
"->",
"setPrimaryForeignKey",
"(",
"$",
"foreignKey",
")",
";",
"if",
"(",
"$",
"conditions",
")",
"{",
"$",
"relation",
"->",
"setConditions",
"(",
"$",
"conditions",
")",
";",
"}",
"return",
"$",
"this",
"->",
"addRelation",
"(",
"$",
"relation",
")",
";",
"}"
] | Add a many-to-one relationship.
@param string $alias
@param string $class
@param string $foreignKey
@param \Closure $conditions
@return $this | [
"Add",
"a",
"many",
"-",
"to",
"-",
"one",
"relationship",
"."
] | 274e3810c2cfbb6818a388daaa462ff05de99cbd | https://github.com/titon/model/blob/274e3810c2cfbb6818a388daaa462ff05de99cbd/src/Titon/Model/Model.php#L306-L315 |
5,498 | titon/model | src/Titon/Model/Model.php | Model.belongsToMany | public function belongsToMany($alias, $class, $junction, $foreignKey = null, $relatedKey = null, Closure $conditions = null) {
$relation = (new ManyToMany($alias, $class))
->setJunction($junction)
->setPrimaryForeignKey($foreignKey)
->setRelatedForeignKey($relatedKey);
if ($conditions) {
$relation->setConditions($conditions);
}
return $this->addRelation($relation);
} | php | public function belongsToMany($alias, $class, $junction, $foreignKey = null, $relatedKey = null, Closure $conditions = null) {
$relation = (new ManyToMany($alias, $class))
->setJunction($junction)
->setPrimaryForeignKey($foreignKey)
->setRelatedForeignKey($relatedKey);
if ($conditions) {
$relation->setConditions($conditions);
}
return $this->addRelation($relation);
} | [
"public",
"function",
"belongsToMany",
"(",
"$",
"alias",
",",
"$",
"class",
",",
"$",
"junction",
",",
"$",
"foreignKey",
"=",
"null",
",",
"$",
"relatedKey",
"=",
"null",
",",
"Closure",
"$",
"conditions",
"=",
"null",
")",
"{",
"$",
"relation",
"=",
"(",
"new",
"ManyToMany",
"(",
"$",
"alias",
",",
"$",
"class",
")",
")",
"->",
"setJunction",
"(",
"$",
"junction",
")",
"->",
"setPrimaryForeignKey",
"(",
"$",
"foreignKey",
")",
"->",
"setRelatedForeignKey",
"(",
"$",
"relatedKey",
")",
";",
"if",
"(",
"$",
"conditions",
")",
"{",
"$",
"relation",
"->",
"setConditions",
"(",
"$",
"conditions",
")",
";",
"}",
"return",
"$",
"this",
"->",
"addRelation",
"(",
"$",
"relation",
")",
";",
"}"
] | Add a many-to-many relationship.
@param string $alias
@param string $class
@param string $junction
@param string $foreignKey
@param string $relatedKey
@param \Closure $conditions
@return $this | [
"Add",
"a",
"many",
"-",
"to",
"-",
"many",
"relationship",
"."
] | 274e3810c2cfbb6818a388daaa462ff05de99cbd | https://github.com/titon/model/blob/274e3810c2cfbb6818a388daaa462ff05de99cbd/src/Titon/Model/Model.php#L328-L339 |
5,499 | titon/model | src/Titon/Model/Model.php | Model.delete | public function delete(array $options = []) {
$options = $options + ['atomic' => true];
$id = $this->get($this->primaryKey);
if (!$id) {
throw new MissingPrimaryKeyException(sprintf('Cannot delete %s record if no ID is present', get_class($this)));
}
$model = $this;
$operation = function() use ($model, $id, $options) {
if ($count = $model->getRepository()->delete($id, $options)) {
$model->flush();
return $count;
}
return 0;
};
// Wrap in a transaction if atomic
if ($options['atomic']) {
try {
$count = $this->getRepository()->getDriver()->transaction($operation);
} catch (Exception $e) {
return 0;
}
} else {
$count = call_user_func($operation);
}
return $count;
} | php | public function delete(array $options = []) {
$options = $options + ['atomic' => true];
$id = $this->get($this->primaryKey);
if (!$id) {
throw new MissingPrimaryKeyException(sprintf('Cannot delete %s record if no ID is present', get_class($this)));
}
$model = $this;
$operation = function() use ($model, $id, $options) {
if ($count = $model->getRepository()->delete($id, $options)) {
$model->flush();
return $count;
}
return 0;
};
// Wrap in a transaction if atomic
if ($options['atomic']) {
try {
$count = $this->getRepository()->getDriver()->transaction($operation);
} catch (Exception $e) {
return 0;
}
} else {
$count = call_user_func($operation);
}
return $count;
} | [
"public",
"function",
"delete",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"$",
"options",
"+",
"[",
"'atomic'",
"=>",
"true",
"]",
";",
"$",
"id",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"this",
"->",
"primaryKey",
")",
";",
"if",
"(",
"!",
"$",
"id",
")",
"{",
"throw",
"new",
"MissingPrimaryKeyException",
"(",
"sprintf",
"(",
"'Cannot delete %s record if no ID is present'",
",",
"get_class",
"(",
"$",
"this",
")",
")",
")",
";",
"}",
"$",
"model",
"=",
"$",
"this",
";",
"$",
"operation",
"=",
"function",
"(",
")",
"use",
"(",
"$",
"model",
",",
"$",
"id",
",",
"$",
"options",
")",
"{",
"if",
"(",
"$",
"count",
"=",
"$",
"model",
"->",
"getRepository",
"(",
")",
"->",
"delete",
"(",
"$",
"id",
",",
"$",
"options",
")",
")",
"{",
"$",
"model",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"count",
";",
"}",
"return",
"0",
";",
"}",
";",
"// Wrap in a transaction if atomic",
"if",
"(",
"$",
"options",
"[",
"'atomic'",
"]",
")",
"{",
"try",
"{",
"$",
"count",
"=",
"$",
"this",
"->",
"getRepository",
"(",
")",
"->",
"getDriver",
"(",
")",
"->",
"transaction",
"(",
"$",
"operation",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"0",
";",
"}",
"}",
"else",
"{",
"$",
"count",
"=",
"call_user_func",
"(",
"$",
"operation",
")",
";",
"}",
"return",
"$",
"count",
";",
"}"
] | Delete the record that is currently present in the model instance.
@see \Titon\Db\Repository::delete()
@param array $options {
@type bool $atomic Will wrap the delete query and all nested queries in a transaction
}
@return int
@throws \Titon\Model\Exception\MissingPrimaryKeyException | [
"Delete",
"the",
"record",
"that",
"is",
"currently",
"present",
"in",
"the",
"model",
"instance",
"."
] | 274e3810c2cfbb6818a388daaa462ff05de99cbd | https://github.com/titon/model/blob/274e3810c2cfbb6818a388daaa462ff05de99cbd/src/Titon/Model/Model.php#L370-L401 |
Subsets and Splits