repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
symbiote/silverstripe-advancedworkflow | src/Extensions/WorkflowEmbargoExpiryExtension.php | WorkflowEmbargoExpiryExtension.getIsUnPublishScheduled | public function getIsUnPublishScheduled()
{
if (!$this->owner->UnPublishOnDate) {
return false;
}
$now = DBDatetime::now()->getTimestamp();
$unpublish = $this->owner->dbObject('UnPublishOnDate')->getTimestamp();
return $now < $unpublish;
} | php | public function getIsUnPublishScheduled()
{
if (!$this->owner->UnPublishOnDate) {
return false;
}
$now = DBDatetime::now()->getTimestamp();
$unpublish = $this->owner->dbObject('UnPublishOnDate')->getTimestamp();
return $now < $unpublish;
} | [
"public",
"function",
"getIsUnPublishScheduled",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"owner",
"->",
"UnPublishOnDate",
")",
"{",
"return",
"false",
";",
"}",
"$",
"now",
"=",
"DBDatetime",
"::",
"now",
"(",
")",
"->",
"getTimestamp",
"(",
... | Returns whether an unpublishing date has been set and is after the current date
@return bool | [
"Returns",
"whether",
"an",
"unpublishing",
"date",
"has",
"been",
"set",
"and",
"is",
"after",
"the",
"current",
"date"
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/Extensions/WorkflowEmbargoExpiryExtension.php#L528-L537 |
symbiote/silverstripe-advancedworkflow | src/Extensions/WorkflowEmbargoExpiryExtension.php | WorkflowEmbargoExpiryExtension.canEdit | public function canEdit($member)
{
if (!Permission::check('EDIT_EMBARGOED_WORKFLOW') && // not given global/override permission to edit
!$this->owner->AllowEmbargoedEditing) { // item flagged as not editable
$publishTime = $this->owner->dbObject('PublishOnDate');
if ($pu... | php | public function canEdit($member)
{
if (!Permission::check('EDIT_EMBARGOED_WORKFLOW') && // not given global/override permission to edit
!$this->owner->AllowEmbargoedEditing) { // item flagged as not editable
$publishTime = $this->owner->dbObject('PublishOnDate');
if ($pu... | [
"public",
"function",
"canEdit",
"(",
"$",
"member",
")",
"{",
"if",
"(",
"!",
"Permission",
"::",
"check",
"(",
"'EDIT_EMBARGOED_WORKFLOW'",
")",
"&&",
"// not given global/override permission to edit",
"!",
"$",
"this",
"->",
"owner",
"->",
"AllowEmbargoedEditing"... | Add edit check for when publishing has been scheduled and if any workflow definitions want the item to be
disabled.
@param Member $member
@return bool|null | [
"Add",
"edit",
"check",
"for",
"when",
"publishing",
"has",
"been",
"scheduled",
"and",
"if",
"any",
"workflow",
"definitions",
"want",
"the",
"item",
"to",
"be",
"disabled",
"."
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/Extensions/WorkflowEmbargoExpiryExtension.php#L546-L560 |
symbiote/silverstripe-advancedworkflow | src/Admin/AdvancedWorkflowAdmin.php | AdvancedWorkflowAdmin.getEditForm | public function getEditForm($id = null, $fields = null)
{
$form = parent::getEditForm($id, $fields);
$definitionGridFieldName = $this->sanitiseClassName(WorkflowDefinition::class);
// Show items submitted into a workflow for current user to action
$fieldName = 'PendingObjects';
... | php | public function getEditForm($id = null, $fields = null)
{
$form = parent::getEditForm($id, $fields);
$definitionGridFieldName = $this->sanitiseClassName(WorkflowDefinition::class);
// Show items submitted into a workflow for current user to action
$fieldName = 'PendingObjects';
... | [
"public",
"function",
"getEditForm",
"(",
"$",
"id",
"=",
"null",
",",
"$",
"fields",
"=",
"null",
")",
"{",
"$",
"form",
"=",
"parent",
"::",
"getEditForm",
"(",
"$",
"id",
",",
"$",
"fields",
")",
";",
"$",
"definitionGridFieldName",
"=",
"$",
"thi... | /*
Shows up to x2 GridFields for Pending and Submitted items, dependent upon the current CMS user and
that user's permissions on the objects showing in each field. | [
"/",
"*",
"Shows",
"up",
"to",
"x2",
"GridFields",
"for",
"Pending",
"and",
"Submitted",
"items",
"dependent",
"upon",
"the",
"current",
"CMS",
"user",
"and",
"that",
"user",
"s",
"permissions",
"on",
"the",
"objects",
"showing",
"in",
"each",
"field",
"."... | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/Admin/AdvancedWorkflowAdmin.php#L100-L200 |
symbiote/silverstripe-advancedworkflow | src/Admin/AdvancedWorkflowAdmin.php | AdvancedWorkflowAdmin.columns | public function columns()
{
$fields = array(
'Title' => array(
'link' => function ($value, $item) {
$pageAdminLink = singleton(CMSPageEditController::class)->Link('show');
return sprintf('<a href="%s/%s">%s</a>', $pageAdminLink, $item->Link... | php | public function columns()
{
$fields = array(
'Title' => array(
'link' => function ($value, $item) {
$pageAdminLink = singleton(CMSPageEditController::class)->Link('show');
return sprintf('<a href="%s/%s">%s</a>', $pageAdminLink, $item->Link... | [
"public",
"function",
"columns",
"(",
")",
"{",
"$",
"fields",
"=",
"array",
"(",
"'Title'",
"=>",
"array",
"(",
"'link'",
"=>",
"function",
"(",
"$",
"value",
",",
"$",
"item",
")",
"{",
"$",
"pageAdminLink",
"=",
"singleton",
"(",
"CMSPageEditControlle... | /*
By default, we implement GridField_ColumnProvider to allow users to click through to the PagesAdmin.
We would also like a "Quick View", that allows users to quickly make a decision on a given workflow-bound
content-object | [
"/",
"*",
"By",
"default",
"we",
"implement",
"GridField_ColumnProvider",
"to",
"allow",
"users",
"to",
"click",
"through",
"to",
"the",
"PagesAdmin",
".",
"We",
"would",
"also",
"like",
"a",
"Quick",
"View",
"that",
"allows",
"users",
"to",
"quickly",
"make... | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/Admin/AdvancedWorkflowAdmin.php#L219-L235 |
symbiote/silverstripe-advancedworkflow | src/Admin/AdvancedWorkflowAdmin.php | AdvancedWorkflowAdmin.setFieldFormatting | public function setFieldFormatting(&$config)
{
$fieldFormatting = array();
// Parse the column information
foreach ($this->columns() as $source => $info) {
if (isset($info['link']) && $info['link']) {
$fieldFormatting[$source] = '<a href=\"$ObjectRecordLink\">$val... | php | public function setFieldFormatting(&$config)
{
$fieldFormatting = array();
// Parse the column information
foreach ($this->columns() as $source => $info) {
if (isset($info['link']) && $info['link']) {
$fieldFormatting[$source] = '<a href=\"$ObjectRecordLink\">$val... | [
"public",
"function",
"setFieldFormatting",
"(",
"&",
"$",
"config",
")",
"{",
"$",
"fieldFormatting",
"=",
"array",
"(",
")",
";",
"// Parse the column information",
"foreach",
"(",
"$",
"this",
"->",
"columns",
"(",
")",
"as",
"$",
"source",
"=>",
"$",
"... | /*
Discreet method used by both intro gridfields to format the target object's links and clickable text
@param GridFieldConfig $config
@return array $fieldFormatting | [
"/",
"*",
"Discreet",
"method",
"used",
"by",
"both",
"intro",
"gridfields",
"to",
"format",
"the",
"target",
"object",
"s",
"links",
"and",
"clickable",
"text"
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/Admin/AdvancedWorkflowAdmin.php#L243-L256 |
symbiote/silverstripe-advancedworkflow | src/Admin/AdvancedWorkflowAdmin.php | AdvancedWorkflowAdmin.userObjects | public function userObjects(Member $user, $fieldName)
{
$list = new ArrayList();
$userWorkflowInstances = $this->getFieldDependentData($user, $fieldName);
foreach ($userWorkflowInstances as $instance) {
if (!$instance->TargetID || !$instance->DefinitionID) {
conti... | php | public function userObjects(Member $user, $fieldName)
{
$list = new ArrayList();
$userWorkflowInstances = $this->getFieldDependentData($user, $fieldName);
foreach ($userWorkflowInstances as $instance) {
if (!$instance->TargetID || !$instance->DefinitionID) {
conti... | [
"public",
"function",
"userObjects",
"(",
"Member",
"$",
"user",
",",
"$",
"fieldName",
")",
"{",
"$",
"list",
"=",
"new",
"ArrayList",
"(",
")",
";",
"$",
"userWorkflowInstances",
"=",
"$",
"this",
"->",
"getFieldDependentData",
"(",
"$",
"user",
",",
"... | Get WorkflowInstance Target objects to show for users in initial gridfield(s)
@param Member $member
@param string $fieldName The name of the gridfield that determines which dataset to return
@return DataList
@todo Add the ability to see embargo/expiry dates in report-gridfields at-a-glance if QueuedJobs module install... | [
"Get",
"WorkflowInstance",
"Target",
"objects",
"to",
"show",
"for",
"users",
"in",
"initial",
"gridfield",
"(",
"s",
")"
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/Admin/AdvancedWorkflowAdmin.php#L266-L294 |
symbiote/silverstripe-advancedworkflow | src/Admin/AdvancedWorkflowAdmin.php | AdvancedWorkflowAdmin.getFieldDependentData | public function getFieldDependentData(Member $user, $fieldName)
{
if ($fieldName == 'PendingObjects') {
return $this->getWorkflowService()->userPendingItems($user);
}
if ($fieldName == 'SubmittedObjects') {
return $this->getWorkflowService()->userSubmittedItems($user)... | php | public function getFieldDependentData(Member $user, $fieldName)
{
if ($fieldName == 'PendingObjects') {
return $this->getWorkflowService()->userPendingItems($user);
}
if ($fieldName == 'SubmittedObjects') {
return $this->getWorkflowService()->userSubmittedItems($user)... | [
"public",
"function",
"getFieldDependentData",
"(",
"Member",
"$",
"user",
",",
"$",
"fieldName",
")",
"{",
"if",
"(",
"$",
"fieldName",
"==",
"'PendingObjects'",
")",
"{",
"return",
"$",
"this",
"->",
"getWorkflowService",
"(",
")",
"->",
"userPendingItems",
... | /*
Return content-object data depending on which gridfeld is calling for it
@param Member $user
@param string $fieldName | [
"/",
"*",
"Return",
"content",
"-",
"object",
"data",
"depending",
"on",
"which",
"gridfeld",
"is",
"calling",
"for",
"it"
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/Admin/AdvancedWorkflowAdmin.php#L302-L310 |
symbiote/silverstripe-advancedworkflow | src/Admin/AdvancedWorkflowAdmin.php | AdvancedWorkflowAdmin.export | public function export(HTTPRequest $request)
{
$url = explode('/', $request->getURL());
$definitionID = end($url);
if ($definitionID && is_numeric($definitionID)) {
$exporter = new WorkflowDefinitionExporter($definitionID);
$exportFilename = WorkflowDefinitionExporter... | php | public function export(HTTPRequest $request)
{
$url = explode('/', $request->getURL());
$definitionID = end($url);
if ($definitionID && is_numeric($definitionID)) {
$exporter = new WorkflowDefinitionExporter($definitionID);
$exportFilename = WorkflowDefinitionExporter... | [
"public",
"function",
"export",
"(",
"HTTPRequest",
"$",
"request",
")",
"{",
"$",
"url",
"=",
"explode",
"(",
"'/'",
",",
"$",
"request",
"->",
"getURL",
"(",
")",
")",
";",
"$",
"definitionID",
"=",
"end",
"(",
"$",
"url",
")",
";",
"if",
"(",
... | Spits out an exported version of the selected WorkflowDefinition for download.
@param HTTPRequest $request
@return HTTPResponse | [
"Spits",
"out",
"an",
"exported",
"version",
"of",
"the",
"selected",
"WorkflowDefinition",
"for",
"download",
"."
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/Admin/AdvancedWorkflowAdmin.php#L318-L335 |
symbiote/silverstripe-advancedworkflow | src/Admin/AdvancedWorkflowAdmin.php | AdvancedWorkflowAdmin.ImportForm | public function ImportForm()
{
$form = parent::ImportForm();
if (!$form) {
return;
}
$form->unsetAllActions();
$newActionList = new FieldList(array(
new FormAction('import', _t('AdvancedWorkflowAdmin.IMPORT', 'Import workflow'))
));
$f... | php | public function ImportForm()
{
$form = parent::ImportForm();
if (!$form) {
return;
}
$form->unsetAllActions();
$newActionList = new FieldList(array(
new FormAction('import', _t('AdvancedWorkflowAdmin.IMPORT', 'Import workflow'))
));
$f... | [
"public",
"function",
"ImportForm",
"(",
")",
"{",
"$",
"form",
"=",
"parent",
"::",
"ImportForm",
"(",
")",
";",
"if",
"(",
"!",
"$",
"form",
")",
"{",
"return",
";",
"}",
"$",
"form",
"->",
"unsetAllActions",
"(",
")",
";",
"$",
"newActionList",
... | Required so we can simply change the visible label of the "Import" button and lose some redundant form-fields.
@return Form | [
"Required",
"so",
"we",
"can",
"simply",
"change",
"the",
"visible",
"label",
"of",
"the",
"Import",
"button",
"and",
"lose",
"some",
"redundant",
"form",
"-",
"fields",
"."
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/Admin/AdvancedWorkflowAdmin.php#L342-L358 |
symbiote/silverstripe-advancedworkflow | src/Forms/gridfield/GridFieldWorkflowRestrictedEditButton.php | GridFieldWorkflowRestrictedEditButton.getColumnAttributes | public function getColumnAttributes($gridField, $record, $columnName)
{
$defaultAtts = array('class' => 'col-buttons');
if ($record instanceof WorkflowInstance) {
$isAdmin = Permission::check('ADMIN');
$isAssigned = $record->getAssignedMembers()->find('ID', Security::getCurre... | php | public function getColumnAttributes($gridField, $record, $columnName)
{
$defaultAtts = array('class' => 'col-buttons');
if ($record instanceof WorkflowInstance) {
$isAdmin = Permission::check('ADMIN');
$isAssigned = $record->getAssignedMembers()->find('ID', Security::getCurre... | [
"public",
"function",
"getColumnAttributes",
"(",
"$",
"gridField",
",",
"$",
"record",
",",
"$",
"columnName",
")",
"{",
"$",
"defaultAtts",
"=",
"array",
"(",
"'class'",
"=>",
"'col-buttons'",
")",
";",
"if",
"(",
"$",
"record",
"instanceof",
"WorkflowInst... | Append a 'disabled' CSS class to GridField rows whose WorkflowInstance records are not viewable/editable
by the current user.
This is used to visually "grey out" records and it's leveraged in some overriding JavaScript, to maintain
an ability to click the target object's hyperlink.
@param GridField $gridField
@param ... | [
"Append",
"a",
"disabled",
"CSS",
"class",
"to",
"GridField",
"rows",
"whose",
"WorkflowInstance",
"records",
"are",
"not",
"viewable",
"/",
"editable",
"by",
"the",
"current",
"user",
"."
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/Forms/gridfield/GridFieldWorkflowRestrictedEditButton.php#L44-L57 |
symbiote/silverstripe-advancedworkflow | src/Forms/gridfield/GridFieldWorkflowRestrictedEditButton.php | GridFieldWorkflowRestrictedEditButton.getColumnContent | public function getColumnContent($gridField, $record, $columnName)
{
$data = new ArrayData(array(
'Link' => Controller::join_links($gridField->Link('item'), $record->ID, 'edit')
));
return $data->renderWith(GridFieldEditButton::class);
} | php | public function getColumnContent($gridField, $record, $columnName)
{
$data = new ArrayData(array(
'Link' => Controller::join_links($gridField->Link('item'), $record->ID, 'edit')
));
return $data->renderWith(GridFieldEditButton::class);
} | [
"public",
"function",
"getColumnContent",
"(",
"$",
"gridField",
",",
"$",
"record",
",",
"$",
"columnName",
")",
"{",
"$",
"data",
"=",
"new",
"ArrayData",
"(",
"array",
"(",
"'Link'",
"=>",
"Controller",
"::",
"join_links",
"(",
"$",
"gridField",
"->",
... | @param GridField $gridField
@param DataObject $record
@param string $columnName
@return string - the HTML for the column | [
"@param",
"GridField",
"$gridField",
"@param",
"DataObject",
"$record",
"@param",
"string",
"$columnName"
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/Forms/gridfield/GridFieldWorkflowRestrictedEditButton.php#L91-L97 |
symbiote/silverstripe-advancedworkflow | src/DataObjects/WorkflowActionInstance.php | WorkflowActionInstance.updateWorkflowFields | public function updateWorkflowFields($fields)
{
$fieldDiff = $this->Workflow()->getTargetDiff();
foreach ($fieldDiff as $field) {
$display = ReadonlyField::create(
'workflow-' . $field->Name,
$field->Title,
DBField::create_field('HTMLText'... | php | public function updateWorkflowFields($fields)
{
$fieldDiff = $this->Workflow()->getTargetDiff();
foreach ($fieldDiff as $field) {
$display = ReadonlyField::create(
'workflow-' . $field->Name,
$field->Title,
DBField::create_field('HTMLText'... | [
"public",
"function",
"updateWorkflowFields",
"(",
"$",
"fields",
")",
"{",
"$",
"fieldDiff",
"=",
"$",
"this",
"->",
"Workflow",
"(",
")",
"->",
"getTargetDiff",
"(",
")",
";",
"foreach",
"(",
"$",
"fieldDiff",
"as",
"$",
"field",
")",
"{",
"$",
"disp... | Gets fields for when this is part of an active workflow | [
"Gets",
"fields",
"for",
"when",
"this",
"is",
"part",
"of",
"an",
"active",
"workflow"
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/DataObjects/WorkflowActionInstance.php#L62-L79 |
symbiote/silverstripe-advancedworkflow | src/DataObjects/WorkflowActionInstance.php | WorkflowActionInstance.getFrontEndDataObject | public function getFrontEndDataObject()
{
$obj = null;
$ba = $this->BaseAction();
if ($ba->hasMethod('getFrontEndDataObject')) {
$obj = $ba->getFrontEndDataObject();
} else {
$obj = $this->Workflow()->getTarget();
}
return $obj;
} | php | public function getFrontEndDataObject()
{
$obj = null;
$ba = $this->BaseAction();
if ($ba->hasMethod('getFrontEndDataObject')) {
$obj = $ba->getFrontEndDataObject();
} else {
$obj = $this->Workflow()->getTarget();
}
return $obj;
} | [
"public",
"function",
"getFrontEndDataObject",
"(",
")",
"{",
"$",
"obj",
"=",
"null",
";",
"$",
"ba",
"=",
"$",
"this",
"->",
"BaseAction",
"(",
")",
";",
"if",
"(",
"$",
"ba",
"->",
"hasMethod",
"(",
"'getFrontEndDataObject'",
")",
")",
"{",
"$",
"... | Gets Front-End DataObject
Use the DataObject as defined in the WorkflowAction, otherwise fall back to the
context object.
Useful for situations where front end workflow deals with multiple data objects
@return DataObject | [
"Gets",
"Front",
"-",
"End",
"DataObject"
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/DataObjects/WorkflowActionInstance.php#L104-L116 |
symbiote/silverstripe-advancedworkflow | src/DataObjects/WorkflowActionInstance.php | WorkflowActionInstance.getValidTransitions | public function getValidTransitions()
{
$available = $this->BaseAction()->Transitions();
$valid = new ArrayList();
// iterate through the transitions and see if they're valid for the current state of the item being
// workflowed
if ($available) {
foreach ($av... | php | public function getValidTransitions()
{
$available = $this->BaseAction()->Transitions();
$valid = new ArrayList();
// iterate through the transitions and see if they're valid for the current state of the item being
// workflowed
if ($available) {
foreach ($av... | [
"public",
"function",
"getValidTransitions",
"(",
")",
"{",
"$",
"available",
"=",
"$",
"this",
"->",
"BaseAction",
"(",
")",
"->",
"Transitions",
"(",
")",
";",
"$",
"valid",
"=",
"new",
"ArrayList",
"(",
")",
";",
"// iterate through the transitions and see ... | Returns all the valid transitions that lead out from this action.
This is called if this action has finished, and the workflow engine wants
to run the next action.
If this action returns only one valid transition it will be immediately
followed; otherwise the user will decide which transition to follow.
@return Arra... | [
"Returns",
"all",
"the",
"valid",
"transitions",
"that",
"lead",
"out",
"from",
"this",
"action",
"."
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/DataObjects/WorkflowActionInstance.php#L184-L202 |
symbiote/silverstripe-advancedworkflow | src/DataObjects/WorkflowActionInstance.php | WorkflowActionInstance.actionComplete | public function actionComplete(WorkflowTransition $transition)
{
$this->MemberID = Member::currentUserID();
$this->write();
$this->extend('onActionComplete', $transition);
} | php | public function actionComplete(WorkflowTransition $transition)
{
$this->MemberID = Member::currentUserID();
$this->write();
$this->extend('onActionComplete', $transition);
} | [
"public",
"function",
"actionComplete",
"(",
"WorkflowTransition",
"$",
"transition",
")",
"{",
"$",
"this",
"->",
"MemberID",
"=",
"Member",
"::",
"currentUserID",
"(",
")",
";",
"$",
"this",
"->",
"write",
"(",
")",
";",
"$",
"this",
"->",
"extend",
"(... | Called when this action has been completed within the workflow | [
"Called",
"when",
"this",
"action",
"has",
"been",
"completed",
"within",
"the",
"workflow"
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/DataObjects/WorkflowActionInstance.php#L215-L220 |
symbiote/silverstripe-advancedworkflow | src/DataObjects/WorkflowActionInstance.php | WorkflowActionInstance.canEditTarget | public function canEditTarget(DataObject $target)
{
$absolute = $this->BaseAction()->canEditTarget($target);
if (!is_null($absolute)) {
return $absolute;
}
switch ($this->BaseAction()->AllowEditing) {
case 'By Assignees':
return $this->Workflow... | php | public function canEditTarget(DataObject $target)
{
$absolute = $this->BaseAction()->canEditTarget($target);
if (!is_null($absolute)) {
return $absolute;
}
switch ($this->BaseAction()->AllowEditing) {
case 'By Assignees':
return $this->Workflow... | [
"public",
"function",
"canEditTarget",
"(",
"DataObject",
"$",
"target",
")",
"{",
"$",
"absolute",
"=",
"$",
"this",
"->",
"BaseAction",
"(",
")",
"->",
"canEditTarget",
"(",
"$",
"target",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"absolute",
")... | Can documents in the current workflow state be edited?
@param DataObject $target
@return bool | [
"Can",
"documents",
"in",
"the",
"current",
"workflow",
"state",
"be",
"edited?"
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/DataObjects/WorkflowActionInstance.php#L229-L244 |
symbiote/silverstripe-advancedworkflow | src/DataObjects/WorkflowActionInstance.php | WorkflowActionInstance.canPublishTarget | public function canPublishTarget(DataObject $target)
{
$absolute = $this->BaseAction()->canPublishTarget($target);
if (!is_null($absolute)) {
return $absolute;
}
return false;
} | php | public function canPublishTarget(DataObject $target)
{
$absolute = $this->BaseAction()->canPublishTarget($target);
if (!is_null($absolute)) {
return $absolute;
}
return false;
} | [
"public",
"function",
"canPublishTarget",
"(",
"DataObject",
"$",
"target",
")",
"{",
"$",
"absolute",
"=",
"$",
"this",
"->",
"BaseAction",
"(",
")",
"->",
"canPublishTarget",
"(",
"$",
"target",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"absolute"... | Does this action restrict the publishing of a document?
@param DataObject $target
@return bool | [
"Does",
"this",
"action",
"restrict",
"the",
"publishing",
"of",
"a",
"document?"
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/DataObjects/WorkflowActionInstance.php#L263-L270 |
symbiote/silverstripe-advancedworkflow | src/Actions/NotifyUsersWorkflowAction.php | NotifyUsersWorkflowAction.getMemberFields | public function getMemberFields(Member $member = null)
{
if (!$member) {
$member = Security::getCurrentUser();
}
$result = array();
if ($member) {
foreach ($member->summaryFields() as $field => $title) {
$result[$field] = $member->$field;
... | php | public function getMemberFields(Member $member = null)
{
if (!$member) {
$member = Security::getCurrentUser();
}
$result = array();
if ($member) {
foreach ($member->summaryFields() as $field => $title) {
$result[$field] = $member->$field;
... | [
"public",
"function",
"getMemberFields",
"(",
"Member",
"$",
"member",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"member",
")",
"{",
"$",
"member",
"=",
"Security",
"::",
"getCurrentUser",
"(",
")",
";",
"}",
"$",
"result",
"=",
"array",
"(",
")",
... | Builds an array with the member information
@param Member $member An optional member to use. If null, will use the current logged in member
@return array | [
"Builds",
"an",
"array",
"with",
"the",
"member",
"information"
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/Actions/NotifyUsersWorkflowAction.php#L210-L228 |
symbiote/silverstripe-advancedworkflow | src/Actions/NotifyUsersWorkflowAction.php | NotifyUsersWorkflowAction.getFormattingHelp | public function getFormattingHelp()
{
$note = _t(
'NotifyUsersWorkflowAction.FORMATTINGNOTE',
'Notification emails can contain HTML formatting. The following special variables are replaced with their
respective values in the email subject, email from and template/body.'
);... | php | public function getFormattingHelp()
{
$note = _t(
'NotifyUsersWorkflowAction.FORMATTINGNOTE',
'Notification emails can contain HTML formatting. The following special variables are replaced with their
respective values in the email subject, email from and template/body.'
);... | [
"public",
"function",
"getFormattingHelp",
"(",
")",
"{",
"$",
"note",
"=",
"_t",
"(",
"'NotifyUsersWorkflowAction.FORMATTINGNOTE'",
",",
"'Notification emails can contain HTML formatting. The following special variables are replaced with their\n\t\t\trespective values in the email subject... | Returns a basic set of instructions on how email templates are populated with variables.
@return string | [
"Returns",
"a",
"basic",
"set",
"of",
"instructions",
"on",
"how",
"email",
"templates",
"are",
"populated",
"with",
"variables",
"."
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/Actions/NotifyUsersWorkflowAction.php#L236-L271 |
symbiote/silverstripe-advancedworkflow | src/Extensions/WorkflowApplicable.php | WorkflowApplicable.AbsoluteEditLink | public function AbsoluteEditLink()
{
$CMSEditLink = null;
if ($this->owner instanceof CMSPreviewable) {
$CMSEditLink = $this->owner->CMSEditLink();
} elseif ($this->owner->hasMethod('WorkflowLink')) {
$CMSEditLink = $this->owner->WorkflowLink();
}
if... | php | public function AbsoluteEditLink()
{
$CMSEditLink = null;
if ($this->owner instanceof CMSPreviewable) {
$CMSEditLink = $this->owner->CMSEditLink();
} elseif ($this->owner->hasMethod('WorkflowLink')) {
$CMSEditLink = $this->owner->WorkflowLink();
}
if... | [
"public",
"function",
"AbsoluteEditLink",
"(",
")",
"{",
"$",
"CMSEditLink",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"owner",
"instanceof",
"CMSPreviewable",
")",
"{",
"$",
"CMSEditLink",
"=",
"$",
"this",
"->",
"owner",
"->",
"CMSEditLink",
"(",
... | Included in CMS-generated email templates for a NotifyUsersWorkflowAction.
Returns an absolute link to the CMS UI for a Page object
@return string|null | [
"Included",
"in",
"CMS",
"-",
"generated",
"email",
"templates",
"for",
"a",
"NotifyUsersWorkflowAction",
".",
"Returns",
"an",
"absolute",
"link",
"to",
"the",
"CMS",
"UI",
"for",
"a",
"Page",
"object"
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/Extensions/WorkflowApplicable.php#L287-L302 |
symbiote/silverstripe-advancedworkflow | src/Extensions/WorkflowApplicable.php | WorkflowApplicable.LinkToPendingItems | public function LinkToPendingItems()
{
$urlBase = Director::absoluteBaseURL();
$urlFrag = 'admin/workflows/WorkflowDefinition/EditForm/field';
$urlInst = $this->getWorkflowInstance();
return Controller::join_links($urlBase, $urlFrag, 'PendingObjects', 'item', $urlInst->ID, 'edit');
... | php | public function LinkToPendingItems()
{
$urlBase = Director::absoluteBaseURL();
$urlFrag = 'admin/workflows/WorkflowDefinition/EditForm/field';
$urlInst = $this->getWorkflowInstance();
return Controller::join_links($urlBase, $urlFrag, 'PendingObjects', 'item', $urlInst->ID, 'edit');
... | [
"public",
"function",
"LinkToPendingItems",
"(",
")",
"{",
"$",
"urlBase",
"=",
"Director",
"::",
"absoluteBaseURL",
"(",
")",
";",
"$",
"urlFrag",
"=",
"'admin/workflows/WorkflowDefinition/EditForm/field'",
";",
"$",
"urlInst",
"=",
"$",
"this",
"->",
"getWorkflo... | Included in CMS-generated email templates for a NotifyUsersWorkflowAction.
Allows users to select a link in an email for direct access to the transition-selection dropdown in the CMS UI.
@return string | [
"Included",
"in",
"CMS",
"-",
"generated",
"email",
"templates",
"for",
"a",
"NotifyUsersWorkflowAction",
".",
"Allows",
"users",
"to",
"select",
"a",
"link",
"in",
"an",
"email",
"for",
"direct",
"access",
"to",
"the",
"transition",
"-",
"selection",
"dropdow... | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/Extensions/WorkflowApplicable.php#L310-L316 |
symbiote/silverstripe-advancedworkflow | src/Extensions/WorkflowApplicable.php | WorkflowApplicable.onAfterWrite | public function onAfterWrite()
{
$instance = $this->getWorkflowInstance();
if ($instance && $instance->CurrentActionID) {
$action = $instance->CurrentAction()->BaseAction()->targetUpdated($instance);
}
} | php | public function onAfterWrite()
{
$instance = $this->getWorkflowInstance();
if ($instance && $instance->CurrentActionID) {
$action = $instance->CurrentAction()->BaseAction()->targetUpdated($instance);
}
} | [
"public",
"function",
"onAfterWrite",
"(",
")",
"{",
"$",
"instance",
"=",
"$",
"this",
"->",
"getWorkflowInstance",
"(",
")",
";",
"if",
"(",
"$",
"instance",
"&&",
"$",
"instance",
"->",
"CurrentActionID",
")",
"{",
"$",
"action",
"=",
"$",
"instance",... | After a workflow item is written, we notify the
workflow so that it can take action if needbe | [
"After",
"a",
"workflow",
"item",
"is",
"written",
"we",
"notify",
"the",
"workflow",
"so",
"that",
"it",
"can",
"take",
"action",
"if",
"needbe"
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/Extensions/WorkflowApplicable.php#L322-L328 |
symbiote/silverstripe-advancedworkflow | src/Extensions/WorkflowApplicable.php | WorkflowApplicable.getWorkflowInstance | public function getWorkflowInstance()
{
if (!$this->currentInstance) {
$this->currentInstance = $this->getWorkflowService()->getWorkflowFor($this->owner);
}
return $this->currentInstance;
} | php | public function getWorkflowInstance()
{
if (!$this->currentInstance) {
$this->currentInstance = $this->getWorkflowService()->getWorkflowFor($this->owner);
}
return $this->currentInstance;
} | [
"public",
"function",
"getWorkflowInstance",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"currentInstance",
")",
"{",
"$",
"this",
"->",
"currentInstance",
"=",
"$",
"this",
"->",
"getWorkflowService",
"(",
")",
"->",
"getWorkflowFor",
"(",
"$",
"thi... | Gets the current instance of workflow
@return WorkflowInstance | [
"Gets",
"the",
"current",
"instance",
"of",
"workflow"
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/Extensions/WorkflowApplicable.php#L343-L350 |
symbiote/silverstripe-advancedworkflow | src/Extensions/WorkflowApplicable.php | WorkflowApplicable.RecentWorkflowComment | public function RecentWorkflowComment($limit = 10)
{
if ($actions = $this->getWorkflowHistory($limit)) {
foreach ($actions as $action) {
if ($action->Comment != '') {
return $action;
}
}
}
} | php | public function RecentWorkflowComment($limit = 10)
{
if ($actions = $this->getWorkflowHistory($limit)) {
foreach ($actions as $action) {
if ($action->Comment != '') {
return $action;
}
}
}
} | [
"public",
"function",
"RecentWorkflowComment",
"(",
"$",
"limit",
"=",
"10",
")",
"{",
"if",
"(",
"$",
"actions",
"=",
"$",
"this",
"->",
"getWorkflowHistory",
"(",
"$",
"limit",
")",
")",
"{",
"foreach",
"(",
"$",
"actions",
"as",
"$",
"action",
")",
... | Check all recent WorkflowActionIntances and return the most recent one with a Comment
@param int $limit
@return WorkflowActionInstance|null | [
"Check",
"all",
"recent",
"WorkflowActionIntances",
"and",
"return",
"the",
"most",
"recent",
"one",
"with",
"a",
"Comment"
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/Extensions/WorkflowApplicable.php#L369-L378 |
symbiote/silverstripe-advancedworkflow | src/Extensions/WorkflowApplicable.php | WorkflowApplicable.canPublish | public function canPublish()
{
// Override any default behaviour, to allow queuedjobs to complete
if ($this->isPublishJobRunning()) {
return true;
}
if ($active = $this->getWorkflowInstance()) {
$publish = $active->canPublishTarget($this->owner);
... | php | public function canPublish()
{
// Override any default behaviour, to allow queuedjobs to complete
if ($this->isPublishJobRunning()) {
return true;
}
if ($active = $this->getWorkflowInstance()) {
$publish = $active->canPublishTarget($this->owner);
... | [
"public",
"function",
"canPublish",
"(",
")",
"{",
"// Override any default behaviour, to allow queuedjobs to complete",
"if",
"(",
"$",
"this",
"->",
"isPublishJobRunning",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"active",
"=",
"$",
"thi... | Content can never be directly publishable if there's a workflow applied.
If there's an active instance, then it 'might' be publishable | [
"Content",
"can",
"never",
"be",
"directly",
"publishable",
"if",
"there",
"s",
"a",
"workflow",
"applied",
"."
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/Extensions/WorkflowApplicable.php#L385-L412 |
symbiote/silverstripe-advancedworkflow | src/Extensions/WorkflowApplicable.php | WorkflowApplicable.canEdit | public function canEdit($member)
{
// Override any default behaviour, to allow queuedjobs to complete
if ($this->isPublishJobRunning()) {
return true;
}
if ($active = $this->getWorkflowInstance()) {
return $active->canEditTarget();
}
} | php | public function canEdit($member)
{
// Override any default behaviour, to allow queuedjobs to complete
if ($this->isPublishJobRunning()) {
return true;
}
if ($active = $this->getWorkflowInstance()) {
return $active->canEditTarget();
}
} | [
"public",
"function",
"canEdit",
"(",
"$",
"member",
")",
"{",
"// Override any default behaviour, to allow queuedjobs to complete",
"if",
"(",
"$",
"this",
"->",
"isPublishJobRunning",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"active",
"=... | Can only edit content that's NOT in another person's content changeset
@return bool | [
"Can",
"only",
"edit",
"content",
"that",
"s",
"NOT",
"in",
"another",
"person",
"s",
"content",
"changeset"
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/Extensions/WorkflowApplicable.php#L419-L429 |
symbiote/silverstripe-advancedworkflow | src/Admin/WorkflowDefinitionImporter.php | WorkflowDefinitionImporter.getImportedWorkflows | public function getImportedWorkflows($name = null)
{
$imports = DataObject::get(ImportedWorkflowTemplate::class);
$importedDefs = array();
foreach ($imports as $import) {
if (!$import->Content) {
continue;
}
$structure = unserialize($import... | php | public function getImportedWorkflows($name = null)
{
$imports = DataObject::get(ImportedWorkflowTemplate::class);
$importedDefs = array();
foreach ($imports as $import) {
if (!$import->Content) {
continue;
}
$structure = unserialize($import... | [
"public",
"function",
"getImportedWorkflows",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"imports",
"=",
"DataObject",
"::",
"get",
"(",
"ImportedWorkflowTemplate",
"::",
"class",
")",
";",
"$",
"importedDefs",
"=",
"array",
"(",
")",
";",
"foreach",
"(... | Generates an array of WorkflowTemplate Objects of all uploaded workflows.
@param string $name. If set, a single-value array comprising a WorkflowTemplate object who's first
constructor param matches $name is returned.
@return WorkflowTemplate|WorkflowTemplate[] | [
"Generates",
"an",
"array",
"of",
"WorkflowTemplate",
"Objects",
"of",
"all",
"uploaded",
"workflows",
"."
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/Admin/WorkflowDefinitionImporter.php#L29-L50 |
symbiote/silverstripe-advancedworkflow | src/Admin/WorkflowDefinitionImporter.php | WorkflowDefinitionImporter.parseYAMLImport | public function parseYAMLImport($source)
{
if (is_file($source)) {
$source = file_get_contents($source);
}
// Make sure the linefeeds are all converted to \n, PCRE '$' will not match anything else.
$convertLF = str_replace(array("\r\n", "\r"), "\n", $source);
/*
... | php | public function parseYAMLImport($source)
{
if (is_file($source)) {
$source = file_get_contents($source);
}
// Make sure the linefeeds are all converted to \n, PCRE '$' will not match anything else.
$convertLF = str_replace(array("\r\n", "\r"), "\n", $source);
/*
... | [
"public",
"function",
"parseYAMLImport",
"(",
"$",
"source",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"source",
")",
")",
"{",
"$",
"source",
"=",
"file_get_contents",
"(",
"$",
"source",
")",
";",
"}",
"// Make sure the linefeeds are all converted to \\n, PCRE... | Handles finding and parsing YAML input as a string or from the contents of a file.
@see addYAMLConfigFile() on {@link SS_ConfigManifest} from where this logic was taken and adapted.
@param string $source YAML as a string or a filename
@return array | [
"Handles",
"finding",
"and",
"parsing",
"YAML",
"input",
"as",
"a",
"string",
"or",
"from",
"the",
"contents",
"of",
"a",
"file",
"."
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/Admin/WorkflowDefinitionImporter.php#L59-L91 |
symbiote/silverstripe-advancedworkflow | src/Dev/WorkflowBulkLoader.php | WorkflowBulkLoader.createImport | protected function createImport($name, $filename, $record)
{
// This is needed to feed WorkflowService#getNamedTemplate()
$import = ImportedWorkflowTemplate::create();
$import->Name = $name;
$import->Filename = $filename;
$import->Content = serialize($record);
$import... | php | protected function createImport($name, $filename, $record)
{
// This is needed to feed WorkflowService#getNamedTemplate()
$import = ImportedWorkflowTemplate::create();
$import->Name = $name;
$import->Filename = $filename;
$import->Content = serialize($record);
$import... | [
"protected",
"function",
"createImport",
"(",
"$",
"name",
",",
"$",
"filename",
",",
"$",
"record",
")",
"{",
"// This is needed to feed WorkflowService#getNamedTemplate()",
"$",
"import",
"=",
"ImportedWorkflowTemplate",
"::",
"create",
"(",
")",
";",
"$",
"import... | Create the ImportedWorkflowTemplate record for the uploaded YML file.
@param string $name
@param string $filename
@param array $record
@return ImportedWorkflowTemplate $import | [
"Create",
"the",
"ImportedWorkflowTemplate",
"record",
"for",
"the",
"uploaded",
"YML",
"file",
"."
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/Dev/WorkflowBulkLoader.php#L97-L107 |
symbiote/silverstripe-advancedworkflow | src/DataObjects/WorkflowDefinition.php | WorkflowDefinition.onBeforeWrite | public function onBeforeWrite()
{
if (!$this->Sort) {
$this->Sort = DB::query('SELECT MAX("Sort") + 1 FROM "WorkflowDefinition"')->value();
}
if (!$this->ID && !$this->Title) {
$this->Title = $this->getDefaultWorkflowTitle();
}
parent::onBeforeWrite()... | php | public function onBeforeWrite()
{
if (!$this->Sort) {
$this->Sort = DB::query('SELECT MAX("Sort") + 1 FROM "WorkflowDefinition"')->value();
}
if (!$this->ID && !$this->Title) {
$this->Title = $this->getDefaultWorkflowTitle();
}
parent::onBeforeWrite()... | [
"public",
"function",
"onBeforeWrite",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"Sort",
")",
"{",
"$",
"this",
"->",
"Sort",
"=",
"DB",
"::",
"query",
"(",
"'SELECT MAX(\"Sort\") + 1 FROM \"WorkflowDefinition\"'",
")",
"->",
"value",
"(",
")",
";"... | Ensure a sort value is set and we get a useable initial workflow title. | [
"Ensure",
"a",
"sort",
"value",
"is",
"set",
"and",
"we",
"get",
"a",
"useable",
"initial",
"workflow",
"title",
"."
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/DataObjects/WorkflowDefinition.php#L117-L127 |
symbiote/silverstripe-advancedworkflow | src/DataObjects/WorkflowDefinition.php | WorkflowDefinition.onAfterWrite | public function onAfterWrite()
{
parent::onAfterWrite();
// Request via ImportForm where TemplateVersion is already set, so unset it
$posted = Controller::curr()->getRequest()->postVars();
if (isset($posted['_CsvFile']) && $this->TemplateVersion) {
$this->TemplateVersion... | php | public function onAfterWrite()
{
parent::onAfterWrite();
// Request via ImportForm where TemplateVersion is already set, so unset it
$posted = Controller::curr()->getRequest()->postVars();
if (isset($posted['_CsvFile']) && $this->TemplateVersion) {
$this->TemplateVersion... | [
"public",
"function",
"onAfterWrite",
"(",
")",
"{",
"parent",
"::",
"onAfterWrite",
"(",
")",
";",
"// Request via ImportForm where TemplateVersion is already set, so unset it",
"$",
"posted",
"=",
"Controller",
"::",
"curr",
"(",
")",
"->",
"getRequest",
"(",
")",
... | After we've been written, check whether we've got a template and to then
create the relevant actions etc. | [
"After",
"we",
"ve",
"been",
"written",
"check",
"whether",
"we",
"ve",
"got",
"a",
"template",
"and",
"to",
"then",
"create",
"the",
"relevant",
"actions",
"etc",
"."
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/DataObjects/WorkflowDefinition.php#L133-L145 |
symbiote/silverstripe-advancedworkflow | src/DataObjects/WorkflowDefinition.php | WorkflowDefinition.removeRelatedHasLists | private function removeRelatedHasLists()
{
$this->Users()->removeAll();
$this->Groups()->removeAll();
$this->Actions()->each(function ($action) {
if ($orphan = DataObject::get_by_id(WorkflowAction::class, $action->ID)) {
$orphan->delete();
}
})... | php | private function removeRelatedHasLists()
{
$this->Users()->removeAll();
$this->Groups()->removeAll();
$this->Actions()->each(function ($action) {
if ($orphan = DataObject::get_by_id(WorkflowAction::class, $action->ID)) {
$orphan->delete();
}
})... | [
"private",
"function",
"removeRelatedHasLists",
"(",
")",
"{",
"$",
"this",
"->",
"Users",
"(",
")",
"->",
"removeAll",
"(",
")",
";",
"$",
"this",
"->",
"Groups",
"(",
")",
"->",
"removeAll",
"(",
")",
";",
"$",
"this",
"->",
"Actions",
"(",
")",
... | Removes User+Group relations from this object as well as WorkflowAction relations.
When a WorkflowAction is deleted, its own relations are also removed:
- WorkflowInstance
- WorkflowTransition
@see WorkflowAction::onAfterDelete()
@return void | [
"Removes",
"User",
"+",
"Group",
"relations",
"from",
"this",
"object",
"as",
"well",
"as",
"WorkflowAction",
"relations",
".",
"When",
"a",
"WorkflowAction",
"is",
"deleted",
"its",
"own",
"relations",
"are",
"also",
"removed",
":",
"-",
"WorkflowInstance",
"... | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/DataObjects/WorkflowDefinition.php#L174-L183 |
symbiote/silverstripe-advancedworkflow | src/DataObjects/WorkflowDefinition.php | WorkflowDefinition.getDefaultWorkflowTitle | public function getDefaultWorkflowTitle()
{
// Where is the title coming from that we wish to test?
$incomingTitle = $this->incomingTitle();
$defs = WorkflowDefinition::get()->map()->toArray();
$tmp = [];
foreach ($defs as $def) {
$parts = preg_split("#\s#", $def... | php | public function getDefaultWorkflowTitle()
{
// Where is the title coming from that we wish to test?
$incomingTitle = $this->incomingTitle();
$defs = WorkflowDefinition::get()->map()->toArray();
$tmp = [];
foreach ($defs as $def) {
$parts = preg_split("#\s#", $def... | [
"public",
"function",
"getDefaultWorkflowTitle",
"(",
")",
"{",
"// Where is the title coming from that we wish to test?",
"$",
"incomingTitle",
"=",
"$",
"this",
"->",
"incomingTitle",
"(",
")",
";",
"$",
"defs",
"=",
"WorkflowDefinition",
"::",
"get",
"(",
")",
"-... | If a workflow-title doesn't already exist, we automatically create a suitable default title
when users attempt to create title-less workflow definitions or upload/create Workflows that would
otherwise have the same name.
@return string
@todo Filter query on current-user's workflows. Avoids confusion when other user... | [
"If",
"a",
"workflow",
"-",
"title",
"doesn",
"t",
"already",
"exist",
"we",
"automatically",
"create",
"a",
"suitable",
"default",
"title",
"when",
"users",
"attempt",
"to",
"create",
"title",
"-",
"less",
"workflow",
"definitions",
"or",
"upload",
"/",
"cr... | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/DataObjects/WorkflowDefinition.php#L425-L451 |
symbiote/silverstripe-advancedworkflow | src/DataObjects/WorkflowDefinition.php | WorkflowDefinition.incomingTitle | public function incomingTitle()
{
$req = Controller::curr()->getRequest();
if (isset($req['_CsvFile']['name']) && !empty($req['_CsvFile']['name'])) {
$import = ImportedWorkflowTemplate::get()->filter('Filename', $req['_CsvFile']['name'])->first();
$incomingTitle = $import->Na... | php | public function incomingTitle()
{
$req = Controller::curr()->getRequest();
if (isset($req['_CsvFile']['name']) && !empty($req['_CsvFile']['name'])) {
$import = ImportedWorkflowTemplate::get()->filter('Filename', $req['_CsvFile']['name'])->first();
$incomingTitle = $import->Na... | [
"public",
"function",
"incomingTitle",
"(",
")",
"{",
"$",
"req",
"=",
"Controller",
"::",
"curr",
"(",
")",
"->",
"getRequest",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"req",
"[",
"'_CsvFile'",
"]",
"[",
"'name'",
"]",
")",
"&&",
"!",
"empty"... | Return the workflow definition title according to the source
@return string | [
"Return",
"the",
"workflow",
"definition",
"title",
"according",
"to",
"the",
"source"
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/DataObjects/WorkflowDefinition.php#L458-L472 |
symbiote/silverstripe-advancedworkflow | src/DataObjects/WorkflowDefinition.php | WorkflowDefinition.canWorkflowPublish | public function canWorkflowPublish($member, $target)
{
$publish = $this->extendedCan('canWorkflowPublish', $member, $target);
if (is_null($publish)) {
$publish = Permission::checkMember($member, 'ADMIN');
}
return $publish;
} | php | public function canWorkflowPublish($member, $target)
{
$publish = $this->extendedCan('canWorkflowPublish', $member, $target);
if (is_null($publish)) {
$publish = Permission::checkMember($member, 'ADMIN');
}
return $publish;
} | [
"public",
"function",
"canWorkflowPublish",
"(",
"$",
"member",
",",
"$",
"target",
")",
"{",
"$",
"publish",
"=",
"$",
"this",
"->",
"extendedCan",
"(",
"'canWorkflowPublish'",
",",
"$",
"member",
",",
"$",
"target",
")",
";",
"if",
"(",
"is_null",
"(",... | Determines if target can be published directly when no workflow has started yet
Opens extension hook to allow an extension to determine if this is allowed as well
By default returns false
@param $member
@param $target
@return Boolean | [
"Determines",
"if",
"target",
"can",
"be",
"published",
"directly",
"when",
"no",
"workflow",
"has",
"started",
"yet",
"Opens",
"extension",
"hook",
"to",
"allow",
"an",
"extension",
"to",
"determine",
"if",
"this",
"is",
"allowed",
"as",
"well"
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/DataObjects/WorkflowDefinition.php#L484-L491 |
symbiote/silverstripe-advancedworkflow | src/DataObjects/WorkflowDefinition.php | WorkflowDefinition.userHasAccess | protected function userHasAccess($member)
{
if (!$member) {
if (!Security::getCurrentUser()) {
return false;
}
$member = Security::getCurrentUser();
}
if (Permission::checkMember($member, "VIEW_ACTIVE_WORKFLOWS")) {
return true... | php | protected function userHasAccess($member)
{
if (!$member) {
if (!Security::getCurrentUser()) {
return false;
}
$member = Security::getCurrentUser();
}
if (Permission::checkMember($member, "VIEW_ACTIVE_WORKFLOWS")) {
return true... | [
"protected",
"function",
"userHasAccess",
"(",
"$",
"member",
")",
"{",
"if",
"(",
"!",
"$",
"member",
")",
"{",
"if",
"(",
"!",
"Security",
"::",
"getCurrentUser",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"member",
"=",
"Security",
"::"... | Checks whether the passed user is able to view this ModelAdmin
@param Member $member
@return bool | [
"Checks",
"whether",
"the",
"passed",
"user",
"is",
"able",
"to",
"view",
"this",
"ModelAdmin"
] | train | https://github.com/symbiote/silverstripe-advancedworkflow/blob/a71f7ca1a04cd03597fafda3ad052413f259f967/src/DataObjects/WorkflowDefinition.php#L563-L575 |
ElfSundae/laravel-hashid | src/HashidManager.php | HashidManager.createDriver | protected function createDriver($name)
{
$config = Arr::get($this->app['config']['hashid.connections'], $name, []);
return $this->createForConnection($name, $config) ?:
$this->createForDriver(Arr::pull($config, 'driver', $name), $config);
} | php | protected function createDriver($name)
{
$config = Arr::get($this->app['config']['hashid.connections'], $name, []);
return $this->createForConnection($name, $config) ?:
$this->createForDriver(Arr::pull($config, 'driver', $name), $config);
} | [
"protected",
"function",
"createDriver",
"(",
"$",
"name",
")",
"{",
"$",
"config",
"=",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"app",
"[",
"'config'",
"]",
"[",
"'hashid.connections'",
"]",
",",
"$",
"name",
",",
"[",
"]",
")",
";",
"return",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/ElfSundae/laravel-hashid/blob/226d90c9dece8787e73a1da378886fe0936876e0/src/HashidManager.php#L66-L72 |
ElfSundae/laravel-hashid | src/HashidManager.php | HashidManager.createForConnection | protected function createForConnection($name, array $config = [])
{
if (isset($this->customCreators[$name])) {
return $this->callCustom($name, compact('config'));
}
} | php | protected function createForConnection($name, array $config = [])
{
if (isset($this->customCreators[$name])) {
return $this->callCustom($name, compact('config'));
}
} | [
"protected",
"function",
"createForConnection",
"(",
"$",
"name",
",",
"array",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"customCreators",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
... | Create a new driver instance for the given connection.
@param string $name
@param array $config
@return mixed | [
"Create",
"a",
"new",
"driver",
"instance",
"for",
"the",
"given",
"connection",
"."
] | train | https://github.com/ElfSundae/laravel-hashid/blob/226d90c9dece8787e73a1da378886fe0936876e0/src/HashidManager.php#L81-L86 |
ElfSundae/laravel-hashid | src/HashidManager.php | HashidManager.createForDriver | protected function createForDriver($driver, array $config = [])
{
if (isset($this->customCreators[$driver])) {
return $this->callCustom($driver, compact('config'));
}
if ($binding = $this->getBindingKeyForDriver($driver)) {
return $this->resolveBinding($binding, comp... | php | protected function createForDriver($driver, array $config = [])
{
if (isset($this->customCreators[$driver])) {
return $this->callCustom($driver, compact('config'));
}
if ($binding = $this->getBindingKeyForDriver($driver)) {
return $this->resolveBinding($binding, comp... | [
"protected",
"function",
"createForDriver",
"(",
"$",
"driver",
",",
"array",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"customCreators",
"[",
"$",
"driver",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
... | Create a new driver instance for the given driver.
We will check to see if a creator method exists for the given driver,
and will call the Closure if so, which allows us to have a more generic
resolver for the drivers themselves which applies to all connections.
@param string $driver
@param array $config
@return ... | [
"Create",
"a",
"new",
"driver",
"instance",
"for",
"the",
"given",
"driver",
"."
] | train | https://github.com/ElfSundae/laravel-hashid/blob/226d90c9dece8787e73a1da378886fe0936876e0/src/HashidManager.php#L101-L112 |
ElfSundae/laravel-hashid | src/HashidManager.php | HashidManager.callCustom | protected function callCustom($key, array $parameters = [])
{
return $this->app->call($this->customCreators[$key], $parameters);
} | php | protected function callCustom($key, array $parameters = [])
{
return $this->app->call($this->customCreators[$key], $parameters);
} | [
"protected",
"function",
"callCustom",
"(",
"$",
"key",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"app",
"->",
"call",
"(",
"$",
"this",
"->",
"customCreators",
"[",
"$",
"key",
"]",
",",
"$",
"parameters"... | Call a custom creator.
@param string $key
@param array $parameters
@return mixed | [
"Call",
"a",
"custom",
"creator",
"."
] | train | https://github.com/ElfSundae/laravel-hashid/blob/226d90c9dece8787e73a1da378886fe0936876e0/src/HashidManager.php#L121-L124 |
ElfSundae/laravel-hashid | src/HashidManager.php | HashidManager.getBindingKeyForDriver | protected function getBindingKeyForDriver($driver)
{
if (class_exists($driver)) {
return $driver;
}
if ($this->app->bound($key = "hashid.driver.$driver")) {
return $key;
}
} | php | protected function getBindingKeyForDriver($driver)
{
if (class_exists($driver)) {
return $driver;
}
if ($this->app->bound($key = "hashid.driver.$driver")) {
return $key;
}
} | [
"protected",
"function",
"getBindingKeyForDriver",
"(",
"$",
"driver",
")",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"driver",
")",
")",
"{",
"return",
"$",
"driver",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"app",
"->",
"bound",
"(",
"$",
"key",
"="... | Get the binding key for the driver.
@param string $driver
@return string|null | [
"Get",
"the",
"binding",
"key",
"for",
"the",
"driver",
"."
] | train | https://github.com/ElfSundae/laravel-hashid/blob/226d90c9dece8787e73a1da378886fe0936876e0/src/HashidManager.php#L132-L141 |
ElfSundae/laravel-hashid | src/HashidManager.php | HashidManager.resolveBinding | protected function resolveBinding($key, array $parameters = [])
{
if ($this->app->isShared($key)) {
return $this->app->make($key);
}
$makeWith = method_exists($this->app, 'makeWith') ? 'makeWith' : 'make';
return $this->app->$makeWith($key, $parameters);
} | php | protected function resolveBinding($key, array $parameters = [])
{
if ($this->app->isShared($key)) {
return $this->app->make($key);
}
$makeWith = method_exists($this->app, 'makeWith') ? 'makeWith' : 'make';
return $this->app->$makeWith($key, $parameters);
} | [
"protected",
"function",
"resolveBinding",
"(",
"$",
"key",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"app",
"->",
"isShared",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"this",
"->",
"app",
"->",
... | Resolve the given binding from the container.
NOTE:
`Container::make($abstract, $parameters)` which can pass additional
parameters to the constructor was removed in Laravel 5.4
(https://github.com/laravel/internals/issues/391), but then re-added
as `makeWith()` in v5.4.16 (https://github.com/laravel/framework/pull/182... | [
"Resolve",
"the",
"given",
"binding",
"from",
"the",
"container",
"."
] | train | https://github.com/ElfSundae/laravel-hashid/blob/226d90c9dece8787e73a1da378886fe0936876e0/src/HashidManager.php#L157-L166 |
ElfSundae/laravel-hashid | src/Base64IntegerDriver.php | Base64IntegerDriver.decode | public function decode($data)
{
$int = (int) ($decoded = parent::decode($data));
return (string) $int === $decoded ? $int : 0;
} | php | public function decode($data)
{
$int = (int) ($decoded = parent::decode($data));
return (string) $int === $decoded ? $int : 0;
} | [
"public",
"function",
"decode",
"(",
"$",
"data",
")",
"{",
"$",
"int",
"=",
"(",
"int",
")",
"(",
"$",
"decoded",
"=",
"parent",
"::",
"decode",
"(",
"$",
"data",
")",
")",
";",
"return",
"(",
"string",
")",
"$",
"int",
"===",
"$",
"decoded",
... | Decode the data.
@param mixed $data
@return int | [
"Decode",
"the",
"data",
"."
] | train | https://github.com/ElfSundae/laravel-hashid/blob/226d90c9dece8787e73a1da378886fe0936876e0/src/Base64IntegerDriver.php#L13-L18 |
ElfSundae/laravel-hashid | src/Console/OptimusGenerateCommand.php | OptimusGenerateCommand.handle | public function handle()
{
$numbers = $this->generateOptimusNumbers(
$this->getTimes(),
(int) $this->option('prime')
);
$this->table(['prime', 'inverse', 'random'], $numbers);
} | php | public function handle()
{
$numbers = $this->generateOptimusNumbers(
$this->getTimes(),
(int) $this->option('prime')
);
$this->table(['prime', 'inverse', 'random'], $numbers);
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"numbers",
"=",
"$",
"this",
"->",
"generateOptimusNumbers",
"(",
"$",
"this",
"->",
"getTimes",
"(",
")",
",",
"(",
"int",
")",
"$",
"this",
"->",
"option",
"(",
"'prime'",
")",
")",
";",
"$",
"t... | Execute the console command.
@return mixed | [
"Execute",
"the",
"console",
"command",
"."
] | train | https://github.com/ElfSundae/laravel-hashid/blob/226d90c9dece8787e73a1da378886fe0936876e0/src/Console/OptimusGenerateCommand.php#L30-L38 |
ElfSundae/laravel-hashid | src/Console/OptimusGenerateCommand.php | OptimusGenerateCommand.generateOptimusNumbers | protected function generateOptimusNumbers($times = 1, $prime = null)
{
$prime = $prime ?: null;
$result = [];
for ($i = 0; $i < $times; $i++) {
$result[] = Energon::generate($prime);
}
return $result;
} | php | protected function generateOptimusNumbers($times = 1, $prime = null)
{
$prime = $prime ?: null;
$result = [];
for ($i = 0; $i < $times; $i++) {
$result[] = Energon::generate($prime);
}
return $result;
} | [
"protected",
"function",
"generateOptimusNumbers",
"(",
"$",
"times",
"=",
"1",
",",
"$",
"prime",
"=",
"null",
")",
"{",
"$",
"prime",
"=",
"$",
"prime",
"?",
":",
"null",
";",
"$",
"result",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"0",
... | Generate Optimus numbers.
@param int $times
@param int $prime
@return array | [
"Generate",
"Optimus",
"numbers",
"."
] | train | https://github.com/ElfSundae/laravel-hashid/blob/226d90c9dece8787e73a1da378886fe0936876e0/src/Console/OptimusGenerateCommand.php#L57-L67 |
ElfSundae/laravel-hashid | src/HashidsIntegerDriver.php | HashidsIntegerDriver.decode | public function decode($data)
{
$decoded = parent::decode($data);
return 1 === count($decoded) ? reset($decoded) : 0;
} | php | public function decode($data)
{
$decoded = parent::decode($data);
return 1 === count($decoded) ? reset($decoded) : 0;
} | [
"public",
"function",
"decode",
"(",
"$",
"data",
")",
"{",
"$",
"decoded",
"=",
"parent",
"::",
"decode",
"(",
"$",
"data",
")",
";",
"return",
"1",
"===",
"count",
"(",
"$",
"decoded",
")",
"?",
"reset",
"(",
"$",
"decoded",
")",
":",
"0",
";",... | Decode the data.
@param mixed $data
@return int | [
"Decode",
"the",
"data",
"."
] | train | https://github.com/ElfSundae/laravel-hashid/blob/226d90c9dece8787e73a1da378886fe0936876e0/src/HashidsIntegerDriver.php#L13-L18 |
ElfSundae/laravel-hashid | src/Console/AlphabetGenerateCommand.php | AlphabetGenerateCommand.handle | public function handle()
{
$alphabets = $this->generateRandomAlphabets(
$this->getTimes(),
(string) $this->option('characters')
);
$this->comment(implode(PHP_EOL, $alphabets));
} | php | public function handle()
{
$alphabets = $this->generateRandomAlphabets(
$this->getTimes(),
(string) $this->option('characters')
);
$this->comment(implode(PHP_EOL, $alphabets));
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"alphabets",
"=",
"$",
"this",
"->",
"generateRandomAlphabets",
"(",
"$",
"this",
"->",
"getTimes",
"(",
")",
",",
"(",
"string",
")",
"$",
"this",
"->",
"option",
"(",
"'characters'",
")",
")",
";",
... | Execute the console command.
@return mixed | [
"Execute",
"the",
"console",
"command",
"."
] | train | https://github.com/ElfSundae/laravel-hashid/blob/226d90c9dece8787e73a1da378886fe0936876e0/src/Console/AlphabetGenerateCommand.php#L36-L44 |
ElfSundae/laravel-hashid | src/Console/AlphabetGenerateCommand.php | AlphabetGenerateCommand.generateRandomAlphabets | protected function generateRandomAlphabets($times = 1, $characters = null)
{
$characters = $characters ?: $this->defaultCharacters;
$result = [];
for ($i = 0; $i < $times; $i++) {
$result[] = str_shuffle(count_chars($characters, 3));
}
return $result;
} | php | protected function generateRandomAlphabets($times = 1, $characters = null)
{
$characters = $characters ?: $this->defaultCharacters;
$result = [];
for ($i = 0; $i < $times; $i++) {
$result[] = str_shuffle(count_chars($characters, 3));
}
return $result;
} | [
"protected",
"function",
"generateRandomAlphabets",
"(",
"$",
"times",
"=",
"1",
",",
"$",
"characters",
"=",
"null",
")",
"{",
"$",
"characters",
"=",
"$",
"characters",
"?",
":",
"$",
"this",
"->",
"defaultCharacters",
";",
"$",
"result",
"=",
"[",
"]"... | Generate random alphabets.
@param int $times
@param string $characters
@return array | [
"Generate",
"random",
"alphabets",
"."
] | train | https://github.com/ElfSundae/laravel-hashid/blob/226d90c9dece8787e73a1da378886fe0936876e0/src/Console/AlphabetGenerateCommand.php#L63-L73 |
ElfSundae/laravel-hashid | src/HashidServiceProvider.php | HashidServiceProvider.setupAssets | protected function setupAssets()
{
if ($this->app instanceof LumenApplication) {
$this->app->configure('hashid'); // @codeCoverageIgnore
}
$this->mergeConfigFrom($config = __DIR__.'/../config/hashid.php', 'hashid');
if ($this->app->runningInConsole()) {
$thi... | php | protected function setupAssets()
{
if ($this->app instanceof LumenApplication) {
$this->app->configure('hashid'); // @codeCoverageIgnore
}
$this->mergeConfigFrom($config = __DIR__.'/../config/hashid.php', 'hashid');
if ($this->app->runningInConsole()) {
$thi... | [
"protected",
"function",
"setupAssets",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"app",
"instanceof",
"LumenApplication",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"configure",
"(",
"'hashid'",
")",
";",
"// @codeCoverageIgnore",
"}",
"$",
"this",
"->"... | Setup package assets.
@return void | [
"Setup",
"package",
"assets",
"."
] | train | https://github.com/ElfSundae/laravel-hashid/blob/226d90c9dece8787e73a1da378886fe0936876e0/src/HashidServiceProvider.php#L29-L40 |
ElfSundae/laravel-hashid | src/HashidServiceProvider.php | HashidServiceProvider.registerServices | protected function registerServices()
{
$this->app->singleton('hashid', function ($app) {
return new HashidManager($app);
});
$this->app->alias('hashid', HashidManager::class);
foreach ($this->getSingletonDrivers() as $class) {
$this->app->singleton(
... | php | protected function registerServices()
{
$this->app->singleton('hashid', function ($app) {
return new HashidManager($app);
});
$this->app->alias('hashid', HashidManager::class);
foreach ($this->getSingletonDrivers() as $class) {
$this->app->singleton(
... | [
"protected",
"function",
"registerServices",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'hashid'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"HashidManager",
"(",
"$",
"app",
")",
";",
"}",
")",
";",
"$",
"th... | Register service bindings.
@return void | [
"Register",
"service",
"bindings",
"."
] | train | https://github.com/ElfSundae/laravel-hashid/blob/226d90c9dece8787e73a1da378886fe0936876e0/src/HashidServiceProvider.php#L47-L67 |
ElfSundae/laravel-hashid | src/HashidServiceProvider.php | HashidServiceProvider.registerCommands | protected function registerCommands()
{
if ($this->app->runningInConsole()) {
$this->commands([
Console\AlphabetGenerateCommand::class,
Console\OptimusGenerateCommand::class,
]);
}
} | php | protected function registerCommands()
{
if ($this->app->runningInConsole()) {
$this->commands([
Console\AlphabetGenerateCommand::class,
Console\OptimusGenerateCommand::class,
]);
}
} | [
"protected",
"function",
"registerCommands",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"app",
"->",
"runningInConsole",
"(",
")",
")",
"{",
"$",
"this",
"->",
"commands",
"(",
"[",
"Console",
"\\",
"AlphabetGenerateCommand",
"::",
"class",
",",
"Console... | Register console commands.
@return void | [
"Register",
"console",
"commands",
"."
] | train | https://github.com/ElfSundae/laravel-hashid/blob/226d90c9dece8787e73a1da378886fe0936876e0/src/HashidServiceProvider.php#L120-L128 |
dapphp/securimage | WavFile.php | WavFile.unpackSample | public static function unpackSample($sampleBinary, $bitDepth = null)
{
if ($bitDepth === null) {
$bitDepth = strlen($sampleBinary) * 8;
}
switch ($bitDepth) {
case 8:
// unsigned char
return ord($sampleBinary);
case 16:
... | php | public static function unpackSample($sampleBinary, $bitDepth = null)
{
if ($bitDepth === null) {
$bitDepth = strlen($sampleBinary) * 8;
}
switch ($bitDepth) {
case 8:
// unsigned char
return ord($sampleBinary);
case 16:
... | [
"public",
"static",
"function",
"unpackSample",
"(",
"$",
"sampleBinary",
",",
"$",
"bitDepth",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"bitDepth",
"===",
"null",
")",
"{",
"$",
"bitDepth",
"=",
"strlen",
"(",
"$",
"sampleBinary",
")",
"*",
"8",
";",
... | Unpacks a single binary sample to numeric value.
@param string $sampleBinary (Required) The sample to decode.
@param int $bitDepth (Optional) The bits per sample to decode. If omitted, derives it from the length of $sampleBinary.
@return int|float|null The numeric sample value. Float for 32-bit samples. Returns nul... | [
"Unpacks",
"a",
"single",
"binary",
"sample",
"to",
"numeric",
"value",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/WavFile.php#L301-L338 |
dapphp/securimage | WavFile.php | WavFile.packSample | public static function packSample($sample, $bitDepth)
{
switch ($bitDepth) {
case 8:
// unsigned char
return chr($sample);
case 16:
// signed short, little endian
if ($sample < 0) {
$sample += 0x1000... | php | public static function packSample($sample, $bitDepth)
{
switch ($bitDepth) {
case 8:
// unsigned char
return chr($sample);
case 16:
// signed short, little endian
if ($sample < 0) {
$sample += 0x1000... | [
"public",
"static",
"function",
"packSample",
"(",
"$",
"sample",
",",
"$",
"bitDepth",
")",
"{",
"switch",
"(",
"$",
"bitDepth",
")",
"{",
"case",
"8",
":",
"// unsigned char",
"return",
"chr",
"(",
"$",
"sample",
")",
";",
"case",
"16",
":",
"// sign... | Packs a single numeric sample to binary.
@param int|float $sample (Required) The sample to encode. Has to be within valid range for $bitDepth. Float values only for 32 bits.
@param int $bitDepth (Required) The bits per sample to encode with.
@return string|null The encoded binary sample. Returns null for unsupporte... | [
"Packs",
"a",
"single",
"numeric",
"sample",
"to",
"binary",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/WavFile.php#L347-L375 |
dapphp/securimage | WavFile.php | WavFile.unpackSampleBlock | public static function unpackSampleBlock($sampleBlock, $bitDepth, $numChannels = null) {
$sampleBytes = $bitDepth / 8;
if ($numChannels === null) {
$numChannels = strlen($sampleBlock) / $sampleBytes;
}
$samples = array();
for ($i = 0; $i < $numChannels; $i++) {
... | php | public static function unpackSampleBlock($sampleBlock, $bitDepth, $numChannels = null) {
$sampleBytes = $bitDepth / 8;
if ($numChannels === null) {
$numChannels = strlen($sampleBlock) / $sampleBytes;
}
$samples = array();
for ($i = 0; $i < $numChannels; $i++) {
... | [
"public",
"static",
"function",
"unpackSampleBlock",
"(",
"$",
"sampleBlock",
",",
"$",
"bitDepth",
",",
"$",
"numChannels",
"=",
"null",
")",
"{",
"$",
"sampleBytes",
"=",
"$",
"bitDepth",
"/",
"8",
";",
"if",
"(",
"$",
"numChannels",
"===",
"null",
")"... | Unpacks a binary sample block to numeric values.
@param string $sampleBlock (Required) The binary sample block (all channels).
@param int $bitDepth (Required) The bits per sample to decode.
@param int $numChannels (Optional) The number of channels to decode. If omitted, derives it from the length of $sampleBlock an... | [
"Unpacks",
"a",
"binary",
"sample",
"block",
"to",
"numeric",
"values",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/WavFile.php#L385-L398 |
dapphp/securimage | WavFile.php | WavFile.packSampleBlock | public static function packSampleBlock($samples, $bitDepth) {
$sampleBlock = '';
foreach($samples as $sample) {
$sampleBlock .= self::packSample($sample, $bitDepth);
}
return $sampleBlock;
} | php | public static function packSampleBlock($samples, $bitDepth) {
$sampleBlock = '';
foreach($samples as $sample) {
$sampleBlock .= self::packSample($sample, $bitDepth);
}
return $sampleBlock;
} | [
"public",
"static",
"function",
"packSampleBlock",
"(",
"$",
"samples",
",",
"$",
"bitDepth",
")",
"{",
"$",
"sampleBlock",
"=",
"''",
";",
"foreach",
"(",
"$",
"samples",
"as",
"$",
"sample",
")",
"{",
"$",
"sampleBlock",
".=",
"self",
"::",
"packSample... | Packs an array of numeric channel samples to a binary sample block.
@param array $samples (Required) The array of channel sample values. Expects float values for 32 bits and integer otherwise.
@param int $bitDepth (Required) The bits per sample to encode with.
@return string The encoded binary sample block. | [
"Packs",
"an",
"array",
"of",
"numeric",
"channel",
"samples",
"to",
"a",
"binary",
"sample",
"block",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/WavFile.php#L407-L414 |
dapphp/securimage | WavFile.php | WavFile.normalizeSample | public static function normalizeSample($sampleFloat, $threshold) {
// apply positive gain
if ($threshold >= 1) {
return $sampleFloat * $threshold;
}
// apply negative gain
if ($threshold <= -1) {
return $sampleFloat / -$threshold;
}
$sign... | php | public static function normalizeSample($sampleFloat, $threshold) {
// apply positive gain
if ($threshold >= 1) {
return $sampleFloat * $threshold;
}
// apply negative gain
if ($threshold <= -1) {
return $sampleFloat / -$threshold;
}
$sign... | [
"public",
"static",
"function",
"normalizeSample",
"(",
"$",
"sampleFloat",
",",
"$",
"threshold",
")",
"{",
"// apply positive gain",
"if",
"(",
"$",
"threshold",
">=",
"1",
")",
"{",
"return",
"$",
"sampleFloat",
"*",
"$",
"threshold",
";",
"}",
"// apply ... | Normalizes a float audio sample. Maximum input range assumed for compression is [-2, 2].
See http://www.voegler.eu/pub/audio/ for more information.
@param float $sampleFloat (Required) The float sample to normalize.
@param float $threshold (Required) The threshold or gain factor for normalizing the amplitude. <ul>
<... | [
"Normalizes",
"a",
"float",
"audio",
"sample",
".",
"Maximum",
"input",
"range",
"assumed",
"for",
"compression",
"is",
"[",
"-",
"2",
"2",
"]",
".",
"See",
"http",
":",
"//",
"www",
".",
"voegler",
".",
"eu",
"/",
"pub",
"/",
"audio",
"/",
"for",
... | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/WavFile.php#L434-L462 |
dapphp/securimage | WavFile.php | WavFile.makeHeader | public function makeHeader()
{
// reset and recalculate
$this->setAudioFormat(); // implicit setAudioSubFormat(), setFactChunkSize(), setFmtExtendedSize(), setFmtChunkSize(), setSize(), setActualSize(), setDataOffset()
$this->setNumBlocks();
// RIF... | php | public function makeHeader()
{
// reset and recalculate
$this->setAudioFormat(); // implicit setAudioSubFormat(), setFactChunkSize(), setFmtExtendedSize(), setFmtChunkSize(), setSize(), setActualSize(), setDataOffset()
$this->setNumBlocks();
// RIF... | [
"public",
"function",
"makeHeader",
"(",
")",
"{",
"// reset and recalculate",
"$",
"this",
"->",
"setAudioFormat",
"(",
")",
";",
"// implicit setAudioSubFormat(), setFactChunkSize(), setFmtExtendedSize(), setFmtChunkSize(), setSize(), setActualSize(), setDataOffset()",
"$",
"this",... | Construct a wav header from this object. Includes "fact" chunk if necessary.
http://www-mmsp.ece.mcgill.ca/documents/audioformats/wave/wave.html
@return string The RIFF header data. | [
"Construct",
"a",
"wav",
"header",
"from",
"this",
"object",
".",
"Includes",
"fact",
"chunk",
"if",
"necessary",
".",
"http",
":",
"//",
"www",
"-",
"mmsp",
".",
"ece",
".",
"mcgill",
".",
"ca",
"/",
"documents",
"/",
"audioformats",
"/",
"wave",
"/",... | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/WavFile.php#L879-L916 |
dapphp/securimage | WavFile.php | WavFile.getDataSubchunk | public function getDataSubchunk()
{
// check preconditions
if (!$this->_dataSize_valid) {
$this->setDataSize(); // implicit setSize(), setActualSize(), setNumBlocks()
}
// create subchunk
return pack('N', 0x64617461) . // SubchunkID - "data"
... | php | public function getDataSubchunk()
{
// check preconditions
if (!$this->_dataSize_valid) {
$this->setDataSize(); // implicit setSize(), setActualSize(), setNumBlocks()
}
// create subchunk
return pack('N', 0x64617461) . // SubchunkID - "data"
... | [
"public",
"function",
"getDataSubchunk",
"(",
")",
"{",
"// check preconditions",
"if",
"(",
"!",
"$",
"this",
"->",
"_dataSize_valid",
")",
"{",
"$",
"this",
"->",
"setDataSize",
"(",
")",
";",
"// implicit setSize(), setActualSize(), setNumBlocks()",
"}",
"// crea... | Construct wav DATA chunk.
@return string The DATA header and chunk. | [
"Construct",
"wav",
"DATA",
"chunk",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/WavFile.php#L923-L936 |
dapphp/securimage | WavFile.php | WavFile.save | public function save($filename)
{
$fp = @fopen($filename, 'w+b');
if (!is_resource($fp)) {
throw new WavFileException('Failed to open "' . $filename . '" for writing.');
}
fwrite($fp, $this->makeHeader());
fwrite($fp, $this->getDataSubchunk());
fclose($fp... | php | public function save($filename)
{
$fp = @fopen($filename, 'w+b');
if (!is_resource($fp)) {
throw new WavFileException('Failed to open "' . $filename . '" for writing.');
}
fwrite($fp, $this->makeHeader());
fwrite($fp, $this->getDataSubchunk());
fclose($fp... | [
"public",
"function",
"save",
"(",
"$",
"filename",
")",
"{",
"$",
"fp",
"=",
"@",
"fopen",
"(",
"$",
"filename",
",",
"'w+b'",
")",
";",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"fp",
")",
")",
"{",
"throw",
"new",
"WavFileException",
"(",
"'Faile... | Save the wav data to a file.
@param string $filename (Required) The file path to save the wav to.
@throws WavFileException | [
"Save",
"the",
"wav",
"data",
"to",
"a",
"file",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/WavFile.php#L944-L956 |
dapphp/securimage | WavFile.php | WavFile.openWav | public function openWav($filename, $readData = true)
{
// check preconditions
if (!file_exists($filename)) {
throw new WavFileException('Failed to open "' . $filename . '". File not found.');
} elseif (!is_readable($filename)) {
throw new WavFileException('Failed to o... | php | public function openWav($filename, $readData = true)
{
// check preconditions
if (!file_exists($filename)) {
throw new WavFileException('Failed to open "' . $filename . '". File not found.');
} elseif (!is_readable($filename)) {
throw new WavFileException('Failed to o... | [
"public",
"function",
"openWav",
"(",
"$",
"filename",
",",
"$",
"readData",
"=",
"true",
")",
"{",
"// check preconditions",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"throw",
"new",
"WavFileException",
"(",
"'Failed to open \"'",
... | Reads a wav header and data from a file.
@param string $filename (Required) The path to the wav file to read.
@param bool $readData (Optional) If true, also read the data chunk.
@throws WavFormatException
@throws WavFileException | [
"Reads",
"a",
"wav",
"header",
"and",
"data",
"from",
"a",
"file",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/WavFile.php#L966-L986 |
dapphp/securimage | WavFile.php | WavFile.setWavData | public function setWavData(&$data, $free = true)
{
// check preconditions
if (is_resource($this->_fp)) $this->closeWav();
// open temporary stream in memory
$this->_fp = @fopen('php://memory', 'w+b');
if (!is_resource($this->_fp)) {
throw new WavFileException('F... | php | public function setWavData(&$data, $free = true)
{
// check preconditions
if (is_resource($this->_fp)) $this->closeWav();
// open temporary stream in memory
$this->_fp = @fopen('php://memory', 'w+b');
if (!is_resource($this->_fp)) {
throw new WavFileException('F... | [
"public",
"function",
"setWavData",
"(",
"&",
"$",
"data",
",",
"$",
"free",
"=",
"true",
")",
"{",
"// check preconditions",
"if",
"(",
"is_resource",
"(",
"$",
"this",
"->",
"_fp",
")",
")",
"$",
"this",
"->",
"closeWav",
"(",
")",
";",
"// open temp... | Set the wav file data and properties from a wav file in a string.
@param string $data (Required) The wav file data. Passed by reference.
@param bool $free (Optional) True to free the passed $data after copying.
@throws WavFormatException
@throws WavFileException | [
"Set",
"the",
"wav",
"file",
"data",
"and",
"properties",
"from",
"a",
"wav",
"file",
"in",
"a",
"string",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/WavFile.php#L1006-L1027 |
dapphp/securimage | WavFile.php | WavFile.readWav | protected function readWav($readData = true)
{
if (!is_resource($this->_fp)) {
throw new WavFileException('No wav file open. Use openWav() first.');
}
try {
$this->readWavHeader();
} catch (WavFileException $ex) {
$this->closeWav();
th... | php | protected function readWav($readData = true)
{
if (!is_resource($this->_fp)) {
throw new WavFileException('No wav file open. Use openWav() first.');
}
try {
$this->readWavHeader();
} catch (WavFileException $ex) {
$this->closeWav();
th... | [
"protected",
"function",
"readWav",
"(",
"$",
"readData",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"this",
"->",
"_fp",
")",
")",
"{",
"throw",
"new",
"WavFileException",
"(",
"'No wav file open. Use openWav() first.'",
")",
";",
"}",
... | Read wav file from a stream.
@param bool $readData (Optional) If true, also read the data chunk.
@throws WavFormatException
@throws WavFileException | [
"Read",
"wav",
"file",
"from",
"a",
"stream",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/WavFile.php#L1036-L1052 |
dapphp/securimage | WavFile.php | WavFile.readWavHeader | protected function readWavHeader()
{
if (!is_resource($this->_fp)) {
throw new WavFileException('No wav file open. Use openWav() first.');
}
// get actual file size
$stat = fstat($this->_fp);
$actualSize = $stat['size'];
$this->_actualSize = $actualSize;... | php | protected function readWavHeader()
{
if (!is_resource($this->_fp)) {
throw new WavFileException('No wav file open. Use openWav() first.');
}
// get actual file size
$stat = fstat($this->_fp);
$actualSize = $stat['size'];
$this->_actualSize = $actualSize;... | [
"protected",
"function",
"readWavHeader",
"(",
")",
"{",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"this",
"->",
"_fp",
")",
")",
"{",
"throw",
"new",
"WavFileException",
"(",
"'No wav file open. Use openWav() first.'",
")",
";",
"}",
"// get actual file size",
"... | Parse a wav header.
http://www-mmsp.ece.mcgill.ca/documents/audioformats/wave/wave.html
@throws WavFormatException
@throws WavFileException | [
"Parse",
"a",
"wav",
"header",
".",
"http",
":",
"//",
"www",
"-",
"mmsp",
".",
"ece",
".",
"mcgill",
".",
"ca",
"/",
"documents",
"/",
"audioformats",
"/",
"wave",
"/",
"wave",
".",
"html"
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/WavFile.php#L1061-L1303 |
dapphp/securimage | WavFile.php | WavFile.readWavData | public function readWavData($dataOffset = 0, $dataSize = null)
{
// check preconditions
if (!is_resource($this->_fp)) {
throw new WavFileException('No wav file open. Use openWav() first.');
}
if ($dataOffset < 0 || $dataOffset % $this->getBlockAlign() > 0) {
... | php | public function readWavData($dataOffset = 0, $dataSize = null)
{
// check preconditions
if (!is_resource($this->_fp)) {
throw new WavFileException('No wav file open. Use openWav() first.');
}
if ($dataOffset < 0 || $dataOffset % $this->getBlockAlign() > 0) {
... | [
"public",
"function",
"readWavData",
"(",
"$",
"dataOffset",
"=",
"0",
",",
"$",
"dataSize",
"=",
"null",
")",
"{",
"// check preconditions",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"this",
"->",
"_fp",
")",
")",
"{",
"throw",
"new",
"WavFileException",
... | Read the wav data from the file into the buffer.
@param int $dataOffset (Optional) The byte offset to skip before starting to read. Must be a multiple of BlockAlign.
@param int $dataSize (Optional) The size of the data to read in bytes. Must be a multiple of BlockAlign. Defaults to all data.
@throws WavFileException | [
"Read",
"the",
"wav",
"data",
"from",
"the",
"file",
"into",
"the",
"buffer",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/WavFile.php#L1312-L1341 |
dapphp/securimage | WavFile.php | WavFile.getSampleBlock | public function getSampleBlock($blockNum)
{
// check preconditions
if (!$this->_dataSize_valid) {
$this->setDataSize(); // implicit setSize(), setActualSize(), setNumBlocks()
}
$offset = $blockNum * $this->_blockAlign;
if ($offset + $this->_blockAlign > $this->_... | php | public function getSampleBlock($blockNum)
{
// check preconditions
if (!$this->_dataSize_valid) {
$this->setDataSize(); // implicit setSize(), setActualSize(), setNumBlocks()
}
$offset = $blockNum * $this->_blockAlign;
if ($offset + $this->_blockAlign > $this->_... | [
"public",
"function",
"getSampleBlock",
"(",
"$",
"blockNum",
")",
"{",
"// check preconditions",
"if",
"(",
"!",
"$",
"this",
"->",
"_dataSize_valid",
")",
"{",
"$",
"this",
"->",
"setDataSize",
"(",
")",
";",
"// implicit setSize(), setActualSize(), setNumBlocks()... | Return a single sample block from the file.
@param int $blockNum (Required) The sample block number. Zero based.
@return string|null The binary sample block (all channels). Returns null if the sample block number was out of range. | [
"Return",
"a",
"single",
"sample",
"block",
"from",
"the",
"file",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/WavFile.php#L1353-L1368 |
dapphp/securimage | WavFile.php | WavFile.setSampleBlock | public function setSampleBlock($sampleBlock, $blockNum)
{
// check preconditions
$blockAlign = $this->_blockAlign;
if (!isset($sampleBlock[$blockAlign - 1]) || isset($sampleBlock[$blockAlign])) { // faster than: if (strlen($sampleBlock) != $blockAlign)
throw new WavFileException... | php | public function setSampleBlock($sampleBlock, $blockNum)
{
// check preconditions
$blockAlign = $this->_blockAlign;
if (!isset($sampleBlock[$blockAlign - 1]) || isset($sampleBlock[$blockAlign])) { // faster than: if (strlen($sampleBlock) != $blockAlign)
throw new WavFileException... | [
"public",
"function",
"setSampleBlock",
"(",
"$",
"sampleBlock",
",",
"$",
"blockNum",
")",
"{",
"// check preconditions",
"$",
"blockAlign",
"=",
"$",
"this",
"->",
"_blockAlign",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"sampleBlock",
"[",
"$",
"blockAlign"... | Set a single sample block. <br />
Allows to append a sample block.
@param string $sampleBlock (Required) The binary sample block (all channels).
@param int $blockNum (Required) The sample block number. Zero based.
@throws WavFileException | [
"Set",
"a",
"single",
"sample",
"block",
".",
"<br",
"/",
">",
"Allows",
"to",
"append",
"a",
"sample",
"block",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/WavFile.php#L1378-L1413 |
dapphp/securimage | WavFile.php | WavFile.getSampleValue | public function getSampleValue($blockNum, $channelNum)
{
// check preconditions
if ($channelNum < 1 || $channelNum > $this->_numChannels) {
throw new WavFileException('Channel number is out of range.');
}
if (!$this->_dataSize_valid) {
$this->setDataSize(); ... | php | public function getSampleValue($blockNum, $channelNum)
{
// check preconditions
if ($channelNum < 1 || $channelNum > $this->_numChannels) {
throw new WavFileException('Channel number is out of range.');
}
if (!$this->_dataSize_valid) {
$this->setDataSize(); ... | [
"public",
"function",
"getSampleValue",
"(",
"$",
"blockNum",
",",
"$",
"channelNum",
")",
"{",
"// check preconditions",
"if",
"(",
"$",
"channelNum",
"<",
"1",
"||",
"$",
"channelNum",
">",
"$",
"this",
"->",
"_numChannels",
")",
"{",
"throw",
"new",
"Wa... | Get a float sample value for a specific sample block and channel number.
@param int $blockNum (Required) The sample block number to fetch. Zero based.
@param int $channelNum (Required) The channel number within the sample block to fetch. First channel is 1.
@return float|null The float sample value. Returns null if... | [
"Get",
"a",
"float",
"sample",
"value",
"for",
"a",
"specific",
"sample",
"block",
"and",
"channel",
"number",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/WavFile.php#L1423-L1475 |
dapphp/securimage | WavFile.php | WavFile.setSampleValue | public function setSampleValue($sampleFloat, $blockNum, $channelNum)
{
// check preconditions
if ($channelNum < 1 || $channelNum > $this->_numChannels) {
throw new WavFileException('Channel number is out of range.');
}
if (!$this->_dataSize_valid) {
$this->se... | php | public function setSampleValue($sampleFloat, $blockNum, $channelNum)
{
// check preconditions
if ($channelNum < 1 || $channelNum > $this->_numChannels) {
throw new WavFileException('Channel number is out of range.');
}
if (!$this->_dataSize_valid) {
$this->se... | [
"public",
"function",
"setSampleValue",
"(",
"$",
"sampleFloat",
",",
"$",
"blockNum",
",",
"$",
"channelNum",
")",
"{",
"// check preconditions",
"if",
"(",
"$",
"channelNum",
"<",
"1",
"||",
"$",
"channelNum",
">",
"$",
"this",
"->",
"_numChannels",
")",
... | Sets a float sample value for a specific sample block number and channel. <br />
Converts float values to appropriate integer values and clips properly. <br />
Allows to append samples (in order).
@param float $sampleFloat (Required) The float sample value to set. Converts float values and clips if necessary.
@param ... | [
"Sets",
"a",
"float",
"sample",
"value",
"for",
"a",
"specific",
"sample",
"block",
"number",
"and",
"channel",
".",
"<br",
"/",
">",
"Converts",
"float",
"values",
"to",
"appropriate",
"integer",
"values",
"and",
"clips",
"properly",
".",
"<br",
"/",
">",... | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/WavFile.php#L1487-L1574 |
dapphp/securimage | WavFile.php | WavFile.filter | public function filter($filters, $blockOffset = 0, $numBlocks = null)
{
// check preconditions
$totalBlocks = $this->getNumBlocks();
$numChannels = $this->getNumChannels();
if (is_null($numBlocks)) $numBlocks = $totalBlocks - $blockOffset;
if (!is_array($filters) || empty($f... | php | public function filter($filters, $blockOffset = 0, $numBlocks = null)
{
// check preconditions
$totalBlocks = $this->getNumBlocks();
$numChannels = $this->getNumChannels();
if (is_null($numBlocks)) $numBlocks = $totalBlocks - $blockOffset;
if (!is_array($filters) || empty($f... | [
"public",
"function",
"filter",
"(",
"$",
"filters",
",",
"$",
"blockOffset",
"=",
"0",
",",
"$",
"numBlocks",
"=",
"null",
")",
"{",
"// check preconditions",
"$",
"totalBlocks",
"=",
"$",
"this",
"->",
"getNumBlocks",
"(",
")",
";",
"$",
"numChannels",
... | Run samples through audio processing filters.
<code>
$wav->filter(
array(
WavFile::FILTER_MIX => array( // Filter for mixing 2 WavFile instances.
'wav' => $wav2, // (Required) The WavFile to mix into this WhavFile. If no optional arguments are given, can be passed without the array.
'loop' ... | [
"Run",
"samples",
"through",
"audio",
"processing",
"filters",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/WavFile.php#L1606-L1718 |
dapphp/securimage | WavFile.php | WavFile.appendWav | public function appendWav(WavFile $wav) {
// basic checks
if ($wav->getSampleRate() != $this->getSampleRate()) {
throw new WavFileException("Sample rate for wav files do not match.");
} else if ($wav->getBitsPerSample() != $this->getBitsPerSample()) {
throw new WavFileExc... | php | public function appendWav(WavFile $wav) {
// basic checks
if ($wav->getSampleRate() != $this->getSampleRate()) {
throw new WavFileException("Sample rate for wav files do not match.");
} else if ($wav->getBitsPerSample() != $this->getBitsPerSample()) {
throw new WavFileExc... | [
"public",
"function",
"appendWav",
"(",
"WavFile",
"$",
"wav",
")",
"{",
"// basic checks",
"if",
"(",
"$",
"wav",
"->",
"getSampleRate",
"(",
")",
"!=",
"$",
"this",
"->",
"getSampleRate",
"(",
")",
")",
"{",
"throw",
"new",
"WavFileException",
"(",
"\"... | Append a wav file to the current wav. <br />
The wav files must have the same sample rate, number of bits per sample, and number of channels.
@param WavFile $wav (Required) The wav file to append.
@throws WavFileException | [
"Append",
"a",
"wav",
"file",
"to",
"the",
"current",
"wav",
".",
"<br",
"/",
">",
"The",
"wav",
"files",
"must",
"have",
"the",
"same",
"sample",
"rate",
"number",
"of",
"bits",
"per",
"sample",
"and",
"number",
"of",
"channels",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/WavFile.php#L1727-L1741 |
dapphp/securimage | WavFile.php | WavFile.mergeWav | public function mergeWav(WavFile $wav, $normalizeThreshold = null) {
return $this->filter(array(
WavFile::FILTER_MIX => $wav,
WavFile::FILTER_NORMALIZE => $normalizeThreshold
));
} | php | public function mergeWav(WavFile $wav, $normalizeThreshold = null) {
return $this->filter(array(
WavFile::FILTER_MIX => $wav,
WavFile::FILTER_NORMALIZE => $normalizeThreshold
));
} | [
"public",
"function",
"mergeWav",
"(",
"WavFile",
"$",
"wav",
",",
"$",
"normalizeThreshold",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"filter",
"(",
"array",
"(",
"WavFile",
"::",
"FILTER_MIX",
"=>",
"$",
"wav",
",",
"WavFile",
"::",
"FILTER_... | Mix 2 wav files together. <br />
Both wavs must have the same sample rate and same number of channels.
@param WavFile $wav (Required) The WavFile to mix.
@param float $normalizeThreshold (Optional) See normalizeSample for an explanation.
@throws WavFileException | [
"Mix",
"2",
"wav",
"files",
"together",
".",
"<br",
"/",
">",
"Both",
"wavs",
"must",
"have",
"the",
"same",
"sample",
"rate",
"and",
"same",
"number",
"of",
"channels",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/WavFile.php#L1751-L1756 |
dapphp/securimage | WavFile.php | WavFile.insertSilence | public function insertSilence($duration = 1.0)
{
$numSamples = (int)($this->getSampleRate() * abs($duration));
$numChannels = $this->getNumChannels();
$data = str_repeat(self::packSample($this->getZeroAmplitude(), $this->getBitsPerSample()), $numSamples * $numChannels);
if ($durati... | php | public function insertSilence($duration = 1.0)
{
$numSamples = (int)($this->getSampleRate() * abs($duration));
$numChannels = $this->getNumChannels();
$data = str_repeat(self::packSample($this->getZeroAmplitude(), $this->getBitsPerSample()), $numSamples * $numChannels);
if ($durati... | [
"public",
"function",
"insertSilence",
"(",
"$",
"duration",
"=",
"1.0",
")",
"{",
"$",
"numSamples",
"=",
"(",
"int",
")",
"(",
"$",
"this",
"->",
"getSampleRate",
"(",
")",
"*",
"abs",
"(",
"$",
"duration",
")",
")",
";",
"$",
"numChannels",
"=",
... | Add silence to the wav file.
@param float $duration (Optional) How many seconds of silence. If negative, add to the beginning of the file. Defaults to 1s. | [
"Add",
"silence",
"to",
"the",
"wav",
"file",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/WavFile.php#L1763-L1778 |
dapphp/securimage | WavFile.php | WavFile.generateNoise | public function generateNoise($duration = 1.0, $percent = 100)
{
$numChannels = $this->getNumChannels();
$numSamples = $this->getSampleRate() * $duration;
$minAmp = $this->getMinAmplitude();
$maxAmp = $this->getMaxAmplitude();
$bitDepth = $this->getBitsPerSample... | php | public function generateNoise($duration = 1.0, $percent = 100)
{
$numChannels = $this->getNumChannels();
$numSamples = $this->getSampleRate() * $duration;
$minAmp = $this->getMinAmplitude();
$maxAmp = $this->getMaxAmplitude();
$bitDepth = $this->getBitsPerSample... | [
"public",
"function",
"generateNoise",
"(",
"$",
"duration",
"=",
"1.0",
",",
"$",
"percent",
"=",
"100",
")",
"{",
"$",
"numChannels",
"=",
"$",
"this",
"->",
"getNumChannels",
"(",
")",
";",
"$",
"numSamples",
"=",
"$",
"this",
"->",
"getSampleRate",
... | Generate noise at the end of the wav for the specified duration and volume.
@param float $duration (Optional) Number of seconds of noise to generate.
@param float $percent (Optional) The percentage of the maximum amplitude to use. 100 = full amplitude. | [
"Generate",
"noise",
"at",
"the",
"end",
"of",
"the",
"wav",
"for",
"the",
"specified",
"duration",
"and",
"volume",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/WavFile.php#L1798-L1820 |
dapphp/securimage | WavFile.php | WavFile.convertBitsPerSample | public function convertBitsPerSample($bitsPerSample) {
if ($this->getBitsPerSample() == $bitsPerSample) {
return $this;
}
$tempWav = new WavFile($this->getNumChannels(), $this->getSampleRate(), $bitsPerSample);
$tempWav->filter(
array(self::FILTER_MIX => $this),
... | php | public function convertBitsPerSample($bitsPerSample) {
if ($this->getBitsPerSample() == $bitsPerSample) {
return $this;
}
$tempWav = new WavFile($this->getNumChannels(), $this->getSampleRate(), $bitsPerSample);
$tempWav->filter(
array(self::FILTER_MIX => $this),
... | [
"public",
"function",
"convertBitsPerSample",
"(",
"$",
"bitsPerSample",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getBitsPerSample",
"(",
")",
"==",
"$",
"bitsPerSample",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"tempWav",
"=",
"new",
"WavFile",
"... | Convert sample data to different bits per sample.
@param int $bitsPerSample (Required) The new number of bits per sample;
@throws WavFileException | [
"Convert",
"sample",
"data",
"to",
"different",
"bits",
"per",
"sample",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/WavFile.php#L1828-L1846 |
dapphp/securimage | WavFile.php | WavFile.displayInfo | public function displayInfo()
{
$s = "File Size: %u\n"
."Chunk Size: %u\n"
."fmt Subchunk Size: %u\n"
."Extended fmt Size: %u\n"
."fact Subchunk Size: %u\n"
."Data Offset: %u\n"
."Data Size: %u\n"
."Audio Format: %s\n"
... | php | public function displayInfo()
{
$s = "File Size: %u\n"
."Chunk Size: %u\n"
."fmt Subchunk Size: %u\n"
."Extended fmt Size: %u\n"
."fact Subchunk Size: %u\n"
."Data Offset: %u\n"
."Data Size: %u\n"
."Audio Format: %s\n"
... | [
"public",
"function",
"displayInfo",
"(",
")",
"{",
"$",
"s",
"=",
"\"File Size: %u\\n\"",
".",
"\"Chunk Size: %u\\n\"",
".",
"\"fmt Subchunk Size: %u\\n\"",
".",
"\"Extended fmt Size: %u\\n\"",
".",
"\"fact Subchunk Size: %u\\n\"",
".",
"\"Data Offset: %u\\n\"",
".",
"\"Da... | Output information about the wav object. | [
"Output",
"information",
"about",
"the",
"wav",
"object",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/WavFile.php#L1855-L1898 |
dapphp/securimage | securimage.php | Securimage.getCaptchaId | public static function getCaptchaId($new = true, array $options = array())
{
if (is_null($new) || (bool)$new == true) {
$id = sha1(uniqid($_SERVER['REMOTE_ADDR'], true));
$opts = array('no_session' => true,
'use_database' => true);
if (sizeof... | php | public static function getCaptchaId($new = true, array $options = array())
{
if (is_null($new) || (bool)$new == true) {
$id = sha1(uniqid($_SERVER['REMOTE_ADDR'], true));
$opts = array('no_session' => true,
'use_database' => true);
if (sizeof... | [
"public",
"static",
"function",
"getCaptchaId",
"(",
"$",
"new",
"=",
"true",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"new",
")",
"||",
"(",
"bool",
")",
"$",
"new",
"==",
"true",
")",
"{",
... | Generate a new captcha ID or retrieve the current ID (if exists).
@param bool $new If true, generates a new challenge and returns and ID. If false, the existing captcha ID is returned, or null if none exists.
@param array $options Additional options to be passed to Securimage.
$options must include database settings ... | [
"Generate",
"a",
"new",
"captcha",
"ID",
"or",
"retrieve",
"the",
"current",
"ID",
"(",
"if",
"exists",
")",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L1175-L1190 |
dapphp/securimage | securimage.php | Securimage.checkByCaptchaId | public static function checkByCaptchaId($id, $value, array $options = array())
{
$opts = array('captchaId' => $id,
'no_session' => true,
'use_database' => true);
if (sizeof($options) > 0) $opts = array_merge($options, $opts);
$si = new self(... | php | public static function checkByCaptchaId($id, $value, array $options = array())
{
$opts = array('captchaId' => $id,
'no_session' => true,
'use_database' => true);
if (sizeof($options) > 0) $opts = array_merge($options, $opts);
$si = new self(... | [
"public",
"static",
"function",
"checkByCaptchaId",
"(",
"$",
"id",
",",
"$",
"value",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"opts",
"=",
"array",
"(",
"'captchaId'",
"=>",
"$",
"id",
",",
"'no_session'",
"=>",
"true",
... | Validate a captcha code input against a captcha ID
@param string $id The captcha ID to check
@param string $value The captcha value supplied by the user
@param array $options Array of options to construct Securimage with.
Options must include database options if they are not set in securimage.php
@see Secu... | [
"Validate",
"a",
"captcha",
"code",
"input",
"against",
"a",
"captcha",
"ID"
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L1203-L1231 |
dapphp/securimage | securimage.php | Securimage.show | public function show($background_image = '')
{
set_error_handler(array(&$this, 'errorHandler'));
if($background_image != '' && is_readable($background_image)) {
$this->bgimg = $background_image;
}
$this->doImage();
} | php | public function show($background_image = '')
{
set_error_handler(array(&$this, 'errorHandler'));
if($background_image != '' && is_readable($background_image)) {
$this->bgimg = $background_image;
}
$this->doImage();
} | [
"public",
"function",
"show",
"(",
"$",
"background_image",
"=",
"''",
")",
"{",
"set_error_handler",
"(",
"array",
"(",
"&",
"$",
"this",
",",
"'errorHandler'",
")",
")",
";",
"if",
"(",
"$",
"background_image",
"!=",
"''",
"&&",
"is_readable",
"(",
"$"... | Generates a new challenge and serves a captcha image.
Appropriate headers will be sent to the browser unless the *send_headers* option is false.
@param string $background_image The absolute or relative path to the background image to use as the background of the captcha image.
$img = new Securimage();
$img->code_len... | [
"Generates",
"a",
"new",
"challenge",
"and",
"serves",
"a",
"captcha",
"image",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L1249-L1258 |
dapphp/securimage | securimage.php | Securimage.check | public function check($code)
{
if (!is_string($code)) {
trigger_error("The \$code parameter passed to Securimage::check() must be a string, " . gettype($code) . " given", E_USER_NOTICE);
$code = '';
}
$this->code_entered = $code;
$this->validate();
re... | php | public function check($code)
{
if (!is_string($code)) {
trigger_error("The \$code parameter passed to Securimage::check() must be a string, " . gettype($code) . " given", E_USER_NOTICE);
$code = '';
}
$this->code_entered = $code;
$this->validate();
re... | [
"public",
"function",
"check",
"(",
"$",
"code",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"code",
")",
")",
"{",
"trigger_error",
"(",
"\"The \\$code parameter passed to Securimage::check() must be a string, \"",
".",
"gettype",
"(",
"$",
"code",
")",
".... | Checks a given code against the correct value from the session and/or database.
@param string $code The captcha code to check
$code = $_POST['code'];
$img = new Securimage();
if ($img->check($code) == true) {
$captcha_valid = true;
} else {
$captcha_valid = false;
}
@return bool true if the given code was correct,... | [
"Checks",
"a",
"given",
"code",
"against",
"the",
"correct",
"value",
"from",
"the",
"session",
"and",
"/",
"or",
"database",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L1275-L1285 |
dapphp/securimage | securimage.php | Securimage.getCaptchaHtml | public static function getCaptchaHtml($options = array(), $parts = Securimage::HTML_ALL)
{
static $javascript_init = false;
if (!isset($options['securimage_path'])) {
$docroot = (isset($_SERVER['DOCUMENT_ROOT'])) ? $_SERVER['DOCUMENT_ROOT'] : substr($_SERVER['SCRIPT_FILENAME'], 0, -strl... | php | public static function getCaptchaHtml($options = array(), $parts = Securimage::HTML_ALL)
{
static $javascript_init = false;
if (!isset($options['securimage_path'])) {
$docroot = (isset($_SERVER['DOCUMENT_ROOT'])) ? $_SERVER['DOCUMENT_ROOT'] : substr($_SERVER['SCRIPT_FILENAME'], 0, -strl... | [
"public",
"static",
"function",
"getCaptchaHtml",
"(",
"$",
"options",
"=",
"array",
"(",
")",
",",
"$",
"parts",
"=",
"Securimage",
"::",
"HTML_ALL",
")",
"{",
"static",
"$",
"javascript_init",
"=",
"false",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"op... | Returns HTML code for displaying the captcha image, audio button, and form text input.
Options can be specified to modify the output of the HTML. Accepted options:
'securimage_path':
Optional: The URI to where securimage is installed (e.g. /securimage)
'show_image_url':
Path to the securimage_show.php script (useful... | [
"Returns",
"HTML",
"code",
"for",
"displaying",
"the",
"captcha",
"image",
"audio",
"button",
"and",
"form",
"text",
"input",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L1339-L1545 |
dapphp/securimage | securimage.php | Securimage.outputAudioFile | public function outputAudioFile($format = null)
{
set_error_handler(array(&$this, 'errorHandler'));
if (isset($_SERVER['HTTP_RANGE'])) {
$range = true;
$rangeId = (isset($_SERVER['HTTP_X_PLAYBACK_SESSION_ID'])) ?
'ID' . $_SERVER['HTTP_X_PLAYBACK_SESS... | php | public function outputAudioFile($format = null)
{
set_error_handler(array(&$this, 'errorHandler'));
if (isset($_SERVER['HTTP_RANGE'])) {
$range = true;
$rangeId = (isset($_SERVER['HTTP_X_PLAYBACK_SESSION_ID'])) ?
'ID' . $_SERVER['HTTP_X_PLAYBACK_SESS... | [
"public",
"function",
"outputAudioFile",
"(",
"$",
"format",
"=",
"null",
")",
"{",
"set_error_handler",
"(",
"array",
"(",
"&",
"$",
"this",
",",
"'errorHandler'",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_RANGE'",
"]",
")",
... | Generate an audible captcha in WAV format and send it to the browser with appropriate headers.
Example:
$img = new Securimage();
$img->outputAudioFile(); // outputs a wav file to the browser
exit;
@param string $format | [
"Generate",
"an",
"audible",
"captcha",
"in",
"WAV",
"format",
"and",
"send",
"it",
"to",
"the",
"browser",
"with",
"appropriate",
"headers",
".",
"Example",
":"
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L1586-L1658 |
dapphp/securimage | securimage.php | Securimage.rangeDownload | public function rangeDownload($audio)
{
/* Congratulations Firefox Android/Linux/Windows for being the most
* sensible browser of all when streaming HTML5 audio!
*
* Chrome on Android and iOS on iPad/iPhone both make extra HTTP requests
* for the audio whether on WiFi or ... | php | public function rangeDownload($audio)
{
/* Congratulations Firefox Android/Linux/Windows for being the most
* sensible browser of all when streaming HTML5 audio!
*
* Chrome on Android and iOS on iPad/iPhone both make extra HTTP requests
* for the audio whether on WiFi or ... | [
"public",
"function",
"rangeDownload",
"(",
"$",
"audio",
")",
"{",
"/* Congratulations Firefox Android/Linux/Windows for being the most\n * sensible browser of all when streaming HTML5 audio!\n *\n * Chrome on Android and iOS on iPad/iPhone both make extra HTTP requests\n ... | Output audio data with http range support. Typically this shouldn't be
called directly unless being used with a custom implentation. Use
Securimage::outputAudioFile instead.
@param string $audio Raw wav or mp3 audio file content | [
"Output",
"audio",
"data",
"with",
"http",
"range",
"support",
".",
"Typically",
"this",
"shouldn",
"t",
"be",
"called",
"directly",
"unless",
"being",
"used",
"with",
"a",
"custom",
"implentation",
".",
"Use",
"Securimage",
"::",
"outputAudioFile",
"instead",
... | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L1667-L1720 |
dapphp/securimage | securimage.php | Securimage.getCode | public function getCode($array = false, $returnExisting = false)
{
$code = array();
$time = 0;
$disp = 'error';
if ($returnExisting && strlen($this->code) > 0) {
if ($array) {
return array(
'code' => $this->code,
... | php | public function getCode($array = false, $returnExisting = false)
{
$code = array();
$time = 0;
$disp = 'error';
if ($returnExisting && strlen($this->code) > 0) {
if ($array) {
return array(
'code' => $this->code,
... | [
"public",
"function",
"getCode",
"(",
"$",
"array",
"=",
"false",
",",
"$",
"returnExisting",
"=",
"false",
")",
"{",
"$",
"code",
"=",
"array",
"(",
")",
";",
"$",
"time",
"=",
"0",
";",
"$",
"disp",
"=",
"'error'",
";",
"if",
"(",
"$",
"returnE... | Return the code from the session or database (if configured). If none exists or was found, an empty string is returned.
@param bool $array true to receive an array containing the code and properties, false to receive just the code.
@param bool $returnExisting If true, and the class property *code* is set, it will be... | [
"Return",
"the",
"code",
"from",
"the",
"session",
"or",
"database",
"(",
"if",
"configured",
")",
".",
"If",
"none",
"exists",
"or",
"was",
"found",
"an",
"empty",
"string",
"is",
"returned",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L1729-L1775 |
dapphp/securimage | securimage.php | Securimage.doImage | protected function doImage()
{
if($this->use_transparent_text == true || $this->bgimg != '' || function_exists('imagecreatetruecolor')) {
$imagecreate = 'imagecreatetruecolor';
} else {
$imagecreate = 'imagecreate';
}
$this->im = $imagecreate($this->image_wid... | php | protected function doImage()
{
if($this->use_transparent_text == true || $this->bgimg != '' || function_exists('imagecreatetruecolor')) {
$imagecreate = 'imagecreatetruecolor';
} else {
$imagecreate = 'imagecreate';
}
$this->im = $imagecreate($this->image_wid... | [
"protected",
"function",
"doImage",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"use_transparent_text",
"==",
"true",
"||",
"$",
"this",
"->",
"bgimg",
"!=",
"''",
"||",
"function_exists",
"(",
"'imagecreatetruecolor'",
")",
")",
"{",
"$",
"imagecreate",
... | The main image drawing routing, responsible for constructing the entire image and serving it | [
"The",
"main",
"image",
"drawing",
"routing",
"responsible",
"for",
"constructing",
"the",
"entire",
"image",
"and",
"serving",
"it"
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L1780-L1855 |
dapphp/securimage | securimage.php | Securimage.allocateColors | protected function allocateColors()
{
// allocate bg color first for imagecreate
$this->gdbgcolor = imagecolorallocate($this->im,
$this->image_bg_color->r,
$this->image_bg_color->g,
... | php | protected function allocateColors()
{
// allocate bg color first for imagecreate
$this->gdbgcolor = imagecolorallocate($this->im,
$this->image_bg_color->r,
$this->image_bg_color->g,
... | [
"protected",
"function",
"allocateColors",
"(",
")",
"{",
"// allocate bg color first for imagecreate",
"$",
"this",
"->",
"gdbgcolor",
"=",
"imagecolorallocate",
"(",
"$",
"this",
"->",
"im",
",",
"$",
"this",
"->",
"image_bg_color",
"->",
"r",
",",
"$",
"this"... | Allocate the colors to be used for the image | [
"Allocate",
"the",
"colors",
"to",
"be",
"used",
"for",
"the",
"image"
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L1860-L1906 |
dapphp/securimage | securimage.php | Securimage.setBackground | protected function setBackground()
{
// set background color of image by drawing a rectangle since imagecreatetruecolor doesn't set a bg color
imagefilledrectangle($this->im, 0, 0,
$this->image_width, $this->image_height,
$this->gdbgcolor);
... | php | protected function setBackground()
{
// set background color of image by drawing a rectangle since imagecreatetruecolor doesn't set a bg color
imagefilledrectangle($this->im, 0, 0,
$this->image_width, $this->image_height,
$this->gdbgcolor);
... | [
"protected",
"function",
"setBackground",
"(",
")",
"{",
"// set background color of image by drawing a rectangle since imagecreatetruecolor doesn't set a bg color",
"imagefilledrectangle",
"(",
"$",
"this",
"->",
"im",
",",
"0",
",",
"0",
",",
"$",
"this",
"->",
"image_wid... | The the background color, or background image to be used | [
"The",
"the",
"background",
"color",
"or",
"background",
"image",
"to",
"be",
"used"
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L1911-L1957 |
dapphp/securimage | securimage.php | Securimage.getBackgroundFromDirectory | protected function getBackgroundFromDirectory()
{
$images = array();
if ( ($dh = opendir($this->background_directory)) !== false) {
while (($file = readdir($dh)) !== false) {
if (preg_match('/(jpg|gif|png)$/i', $file)) $images[] = $file;
}
closed... | php | protected function getBackgroundFromDirectory()
{
$images = array();
if ( ($dh = opendir($this->background_directory)) !== false) {
while (($file = readdir($dh)) !== false) {
if (preg_match('/(jpg|gif|png)$/i', $file)) $images[] = $file;
}
closed... | [
"protected",
"function",
"getBackgroundFromDirectory",
"(",
")",
"{",
"$",
"images",
"=",
"array",
"(",
")",
";",
"if",
"(",
"(",
"$",
"dh",
"=",
"opendir",
"(",
"$",
"this",
"->",
"background_directory",
")",
")",
"!==",
"false",
")",
"{",
"while",
"(... | Scan the directory for a background image to use
@return string|bool | [
"Scan",
"the",
"directory",
"for",
"a",
"background",
"image",
"to",
"use"
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L1963-L1980 |
dapphp/securimage | securimage.php | Securimage.createCode | public function createCode()
{
$this->code = false;
switch($this->captcha_type) {
case self::SI_CAPTCHA_MATHEMATIC:
{
do {
$signs = array('+', '-', 'x');
$left = mt_rand(1, 10);
$right = mt_rand(1, ... | php | public function createCode()
{
$this->code = false;
switch($this->captcha_type) {
case self::SI_CAPTCHA_MATHEMATIC:
{
do {
$signs = array('+', '-', 'x');
$left = mt_rand(1, 10);
$right = mt_rand(1, ... | [
"public",
"function",
"createCode",
"(",
")",
"{",
"$",
"this",
"->",
"code",
"=",
"false",
";",
"switch",
"(",
"$",
"this",
"->",
"captcha_type",
")",
"{",
"case",
"self",
"::",
"SI_CAPTCHA_MATHEMATIC",
":",
"{",
"do",
"{",
"$",
"signs",
"=",
"array",... | This method generates a new captcha code.
Generates a random captcha code based on *charset*, math problem, or captcha from the wordlist and saves the value to the session and/or database. | [
"This",
"method",
"generates",
"a",
"new",
"captcha",
"code",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L1987-L2034 |
dapphp/securimage | securimage.php | Securimage.drawWord | protected function drawWord()
{
$ratio = ($this->font_ratio) ? $this->font_ratio : 0.4;
if ((float)$ratio < 0.1 || (float)$ratio >= 1) {
$ratio = 0.4;
}
if (!is_readable($this->ttfFile())) {
// this will not catch missing fonts after the first!
$... | php | protected function drawWord()
{
$ratio = ($this->font_ratio) ? $this->font_ratio : 0.4;
if ((float)$ratio < 0.1 || (float)$ratio >= 1) {
$ratio = 0.4;
}
if (!is_readable($this->ttfFile())) {
// this will not catch missing fonts after the first!
$... | [
"protected",
"function",
"drawWord",
"(",
")",
"{",
"$",
"ratio",
"=",
"(",
"$",
"this",
"->",
"font_ratio",
")",
"?",
"$",
"this",
"->",
"font_ratio",
":",
"0.4",
";",
"if",
"(",
"(",
"float",
")",
"$",
"ratio",
"<",
"0.1",
"||",
"(",
"float",
"... | Draws the captcha code on the image | [
"Draws",
"the",
"captcha",
"code",
"on",
"the",
"image"
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L2039-L2207 |
dapphp/securimage | securimage.php | Securimage.getCharacterDimensions | protected function getCharacterDimensions($char, $size, $angle, $font)
{
$box = imagettfbbox($size, $angle, $font, $char);
return array($box[2] - $box[0], max($box[1] - $box[7], $box[5] - $box[3]), $box[1]);
} | php | protected function getCharacterDimensions($char, $size, $angle, $font)
{
$box = imagettfbbox($size, $angle, $font, $char);
return array($box[2] - $box[0], max($box[1] - $box[7], $box[5] - $box[3]), $box[1]);
} | [
"protected",
"function",
"getCharacterDimensions",
"(",
"$",
"char",
",",
"$",
"size",
",",
"$",
"angle",
",",
"$",
"font",
")",
"{",
"$",
"box",
"=",
"imagettfbbox",
"(",
"$",
"size",
",",
"$",
"angle",
",",
"$",
"font",
",",
"$",
"char",
")",
";"... | Get the width and height (in points) of a character for a given font,
angle, and size.
@param string $char The character to get dimensions for
@param number $size The font size, in points
@param number $angle The angle of the text
@return number[] A 3-element array representing the width, height and baseline of the te... | [
"Get",
"the",
"width",
"and",
"height",
"(",
"in",
"points",
")",
"of",
"a",
"character",
"for",
"a",
"given",
"font",
"angle",
"and",
"size",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L2218-L2223 |
dapphp/securimage | securimage.php | Securimage.distortedCopy | protected function distortedCopy()
{
$numpoles = 3; // distortion factor
$px = array(); // x coordinates of poles
$py = array(); // y coordinates of poles
$rad = array(); // radius of distortion from pole
$amp = array(); // amplitude
$x ... | php | protected function distortedCopy()
{
$numpoles = 3; // distortion factor
$px = array(); // x coordinates of poles
$py = array(); // y coordinates of poles
$rad = array(); // radius of distortion from pole
$amp = array(); // amplitude
$x ... | [
"protected",
"function",
"distortedCopy",
"(",
")",
"{",
"$",
"numpoles",
"=",
"3",
";",
"// distortion factor",
"$",
"px",
"=",
"array",
"(",
")",
";",
"// x coordinates of poles",
"$",
"py",
"=",
"array",
"(",
")",
";",
"// y coordinates of poles",
"$",
"r... | Copies the captcha image to the final image with distortion applied | [
"Copies",
"the",
"captcha",
"image",
"to",
"the",
"final",
"image",
"with",
"distortion",
"applied"
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L2228-L2287 |
dapphp/securimage | securimage.php | Securimage.drawLines | protected function drawLines()
{
for ($line = 0; $line < $this->num_lines; ++ $line) {
$x = $this->image_width * (1 + $line) / ($this->num_lines + 1);
$x += (0.5 - $this->frand()) * $this->image_width / $this->num_lines;
$y = mt_rand($this->image_height * 0.1, $this->imag... | php | protected function drawLines()
{
for ($line = 0; $line < $this->num_lines; ++ $line) {
$x = $this->image_width * (1 + $line) / ($this->num_lines + 1);
$x += (0.5 - $this->frand()) * $this->image_width / $this->num_lines;
$y = mt_rand($this->image_height * 0.1, $this->imag... | [
"protected",
"function",
"drawLines",
"(",
")",
"{",
"for",
"(",
"$",
"line",
"=",
"0",
";",
"$",
"line",
"<",
"$",
"this",
"->",
"num_lines",
";",
"++",
"$",
"line",
")",
"{",
"$",
"x",
"=",
"$",
"this",
"->",
"image_width",
"*",
"(",
"1",
"+"... | Draws distorted lines on the image | [
"Draws",
"distorted",
"lines",
"on",
"the",
"image"
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L2292-L2324 |
dapphp/securimage | securimage.php | Securimage.drawNoise | protected function drawNoise()
{
if ($this->noise_level > 10) {
$noise_level = 10;
} else {
$noise_level = $this->noise_level;
}
$t0 = microtime(true);
$noise_level *= M_LOG2E;
for ($x = 1; $x < $this->image_width; $x += 20) {
for... | php | protected function drawNoise()
{
if ($this->noise_level > 10) {
$noise_level = 10;
} else {
$noise_level = $this->noise_level;
}
$t0 = microtime(true);
$noise_level *= M_LOG2E;
for ($x = 1; $x < $this->image_width; $x += 20) {
for... | [
"protected",
"function",
"drawNoise",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"noise_level",
">",
"10",
")",
"{",
"$",
"noise_level",
"=",
"10",
";",
"}",
"else",
"{",
"$",
"noise_level",
"=",
"$",
"this",
"->",
"noise_level",
";",
"}",
"$",
"... | Draws random noise on the image | [
"Draws",
"random",
"noise",
"on",
"the",
"image"
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L2329-L2362 |
dapphp/securimage | securimage.php | Securimage.addSignature | protected function addSignature()
{
$bbox = imagettfbbox(10, 0, $this->signature_font, $this->image_signature);
$textlen = $bbox[2] - $bbox[0];
$x = $this->image_width - $textlen - 5;
$y = $this->image_height - 3;
imagettftext($this->im, 10, 0, $x, $y, $this->gdsignaturecolo... | php | protected function addSignature()
{
$bbox = imagettfbbox(10, 0, $this->signature_font, $this->image_signature);
$textlen = $bbox[2] - $bbox[0];
$x = $this->image_width - $textlen - 5;
$y = $this->image_height - 3;
imagettftext($this->im, 10, 0, $x, $y, $this->gdsignaturecolo... | [
"protected",
"function",
"addSignature",
"(",
")",
"{",
"$",
"bbox",
"=",
"imagettfbbox",
"(",
"10",
",",
"0",
",",
"$",
"this",
"->",
"signature_font",
",",
"$",
"this",
"->",
"image_signature",
")",
";",
"$",
"textlen",
"=",
"$",
"bbox",
"[",
"2",
... | Print signature text on image | [
"Print",
"signature",
"text",
"on",
"image"
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L2367-L2375 |
dapphp/securimage | securimage.php | Securimage.output | protected function output()
{
if ($this->canSendHeaders() || $this->send_headers == false) {
if ($this->send_headers) {
// only send the content-type headers if no headers have been output
// this will ease debugging on misconfigured servers where warnings
... | php | protected function output()
{
if ($this->canSendHeaders() || $this->send_headers == false) {
if ($this->send_headers) {
// only send the content-type headers if no headers have been output
// this will ease debugging on misconfigured servers where warnings
... | [
"protected",
"function",
"output",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"canSendHeaders",
"(",
")",
"||",
"$",
"this",
"->",
"send_headers",
"==",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"send_headers",
")",
"{",
"// only send the conten... | Sends the appropriate image and cache headers and outputs image to the browser | [
"Sends",
"the",
"appropriate",
"image",
"and",
"cache",
"headers",
"and",
"outputs",
"image",
"to",
"the",
"browser"
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L2380-L2420 |
dapphp/securimage | securimage.php | Securimage.getAudibleCode | protected function getAudibleCode()
{
$letters = array();
$code = $this->getCode(true, true);
if (empty($code) || empty($code['code'])) {
if (strlen($this->display_value) > 0) {
$code = array('code' => $this->display_value, 'display' => $this->display_value);
... | php | protected function getAudibleCode()
{
$letters = array();
$code = $this->getCode(true, true);
if (empty($code) || empty($code['code'])) {
if (strlen($this->display_value) > 0) {
$code = array('code' => $this->display_value, 'display' => $this->display_value);
... | [
"protected",
"function",
"getAudibleCode",
"(",
")",
"{",
"$",
"letters",
"=",
"array",
"(",
")",
";",
"$",
"code",
"=",
"$",
"this",
"->",
"getCode",
"(",
"true",
",",
"true",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"code",
")",
"||",
"empty",
"... | Generates an audio captcha in WAV format
@return string The audio representation of the captcha in Wav format | [
"Generates",
"an",
"audio",
"captcha",
"in",
"WAV",
"format"
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L2427-L2471 |
dapphp/securimage | securimage.php | Securimage.readCodeFromFile | protected function readCodeFromFile($numWords = 1)
{
$strtolower_func = 'strtolower';
$mb_support = false;
if (!empty($this->wordlist_file_encoding)) {
if (!extension_loaded('mbstring')) {
trigger_error("wordlist_file_encoding option set, but PHP does not ha... | php | protected function readCodeFromFile($numWords = 1)
{
$strtolower_func = 'strtolower';
$mb_support = false;
if (!empty($this->wordlist_file_encoding)) {
if (!extension_loaded('mbstring')) {
trigger_error("wordlist_file_encoding option set, but PHP does not ha... | [
"protected",
"function",
"readCodeFromFile",
"(",
"$",
"numWords",
"=",
"1",
")",
"{",
"$",
"strtolower_func",
"=",
"'strtolower'",
";",
"$",
"mb_support",
"=",
"false",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"wordlist_file_encoding",
")",
"... | Gets a captcha code from a file containing a list of words.
Seek to a random offset in the file and reads a block of data and returns a line from the file.
@param int $numWords Number of words (lines) to read from the file
@return string|array|bool Returns a string if only one word is to be read, or an array of word... | [
"Gets",
"a",
"captcha",
"code",
"from",
"a",
"file",
"containing",
"a",
"list",
"of",
"words",
"."
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L2481-L2549 |
dapphp/securimage | securimage.php | Securimage.generateCode | protected function generateCode()
{
$code = '';
for($i = 1, $cslen = $this->strlen($this->charset); $i <= $this->code_length; ++$i) {
$code .= $this->substr($this->charset, mt_rand(0, $cslen - 1), 1);
}
return $code;
} | php | protected function generateCode()
{
$code = '';
for($i = 1, $cslen = $this->strlen($this->charset); $i <= $this->code_length; ++$i) {
$code .= $this->substr($this->charset, mt_rand(0, $cslen - 1), 1);
}
return $code;
} | [
"protected",
"function",
"generateCode",
"(",
")",
"{",
"$",
"code",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"1",
",",
"$",
"cslen",
"=",
"$",
"this",
"->",
"strlen",
"(",
"$",
"this",
"->",
"charset",
")",
";",
"$",
"i",
"<=",
"$",
"this",
... | Generates a random captcha code from the set character set
@see Securimage::$charset Charset option
@return string A randomly generated CAPTCHA code | [
"Generates",
"a",
"random",
"captcha",
"code",
"from",
"the",
"set",
"character",
"set"
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L2557-L2566 |
dapphp/securimage | securimage.php | Securimage.validate | protected function validate()
{
if (!is_string($this->code) || strlen($this->code) == 0) {
$code = $this->getCode(true);
// returns stored code, or an empty string if no stored code was found
// checks the session and database if enabled
} else {
$code... | php | protected function validate()
{
if (!is_string($this->code) || strlen($this->code) == 0) {
$code = $this->getCode(true);
// returns stored code, or an empty string if no stored code was found
// checks the session and database if enabled
} else {
$code... | [
"protected",
"function",
"validate",
"(",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"this",
"->",
"code",
")",
"||",
"strlen",
"(",
"$",
"this",
"->",
"code",
")",
"==",
"0",
")",
"{",
"$",
"code",
"=",
"$",
"this",
"->",
"getCode",
"(",
... | Validate a code supplied by the user
Checks the entered code against the value stored in the session and/or database (if configured). Handles case sensitivity.
Also removes the code from session/database if the code was entered correctly to prevent re-use attack.
This function does not return a value.
@see Securima... | [
"Validate",
"a",
"code",
"supplied",
"by",
"the",
"user"
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L2578-L2628 |
dapphp/securimage | securimage.php | Securimage.saveData | protected function saveData()
{
if ($this->no_session != true) {
if (isset($_SESSION['securimage_code_value']) && is_scalar($_SESSION['securimage_code_value'])) {
// fix for migration from v2 - v3
unset($_SESSION['securimage_code_value']);
unset($_... | php | protected function saveData()
{
if ($this->no_session != true) {
if (isset($_SESSION['securimage_code_value']) && is_scalar($_SESSION['securimage_code_value'])) {
// fix for migration from v2 - v3
unset($_SESSION['securimage_code_value']);
unset($_... | [
"protected",
"function",
"saveData",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"no_session",
"!=",
"true",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"'securimage_code_value'",
"]",
")",
"&&",
"is_scalar",
"(",
"$",
"_SESSION",
"[",
"'... | Save CAPTCHA data to session and database (if configured) | [
"Save",
"CAPTCHA",
"data",
"to",
"session",
"and",
"database",
"(",
"if",
"configured",
")"
] | train | https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L2633-L2651 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.