id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
239,700
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.checkLessonsMigrationState
|
protected function checkLessonsMigrationState()
{
$this->output->info('# Checkin lessons migration state... #');
switch ($this->checkLessonMigrationStats()) {
case 0:
return true;
case 1:
$this->output->error(' Migration stats does not match!');
if ($this->output->confirm('Do you wish to continue (lesson_migration and scool lesson tables will be truncated)?')) {
DB::connection('ebre_escool')->statement('DELETE FROM lesson_migration');
DB::connection('ebre_escool')->statement('ALTER TABLE lesson_migration AUTO_INCREMENT = 1');
DB::statement('DELETE FROM lessons');
DB::statement('ALTER TABLE lessons AUTO_INCREMENT = 1');
DB::statement('DELETE FROM lesson_user');
DB::statement('ALTER TABLE lesson_user AUTO_INCREMENT = 1');
DB::statement('DELETE FROM lesson_submodule');
DB::statement('ALTER TABLE lesson_submodule AUTO_INCREMENT = 1');
DB::statement('DELETE FROM classroom_submodule');
DB::statement('ALTER TABLE classroom_submodule AUTO_INCREMENT = 1');
} else {
die();
}
return true;
case 2:
$this->output->info(' Lesson data seems already migrated. Skipping lessons migration...');
return false;
}
}
|
php
|
protected function checkLessonsMigrationState()
{
$this->output->info('# Checkin lessons migration state... #');
switch ($this->checkLessonMigrationStats()) {
case 0:
return true;
case 1:
$this->output->error(' Migration stats does not match!');
if ($this->output->confirm('Do you wish to continue (lesson_migration and scool lesson tables will be truncated)?')) {
DB::connection('ebre_escool')->statement('DELETE FROM lesson_migration');
DB::connection('ebre_escool')->statement('ALTER TABLE lesson_migration AUTO_INCREMENT = 1');
DB::statement('DELETE FROM lessons');
DB::statement('ALTER TABLE lessons AUTO_INCREMENT = 1');
DB::statement('DELETE FROM lesson_user');
DB::statement('ALTER TABLE lesson_user AUTO_INCREMENT = 1');
DB::statement('DELETE FROM lesson_submodule');
DB::statement('ALTER TABLE lesson_submodule AUTO_INCREMENT = 1');
DB::statement('DELETE FROM classroom_submodule');
DB::statement('ALTER TABLE classroom_submodule AUTO_INCREMENT = 1');
} else {
die();
}
return true;
case 2:
$this->output->info(' Lesson data seems already migrated. Skipping lessons migration...');
return false;
}
}
|
[
"protected",
"function",
"checkLessonsMigrationState",
"(",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"info",
"(",
"'# Checkin lessons migration state... #'",
")",
";",
"switch",
"(",
"$",
"this",
"->",
"checkLessonMigrationStats",
"(",
")",
")",
"{",
"case",
"0",
":",
"return",
"true",
";",
"case",
"1",
":",
"$",
"this",
"->",
"output",
"->",
"error",
"(",
"' Migration stats does not match!'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"output",
"->",
"confirm",
"(",
"'Do you wish to continue (lesson_migration and scool lesson tables will be truncated)?'",
")",
")",
"{",
"DB",
"::",
"connection",
"(",
"'ebre_escool'",
")",
"->",
"statement",
"(",
"'DELETE FROM lesson_migration'",
")",
";",
"DB",
"::",
"connection",
"(",
"'ebre_escool'",
")",
"->",
"statement",
"(",
"'ALTER TABLE lesson_migration AUTO_INCREMENT = 1'",
")",
";",
"DB",
"::",
"statement",
"(",
"'DELETE FROM lessons'",
")",
";",
"DB",
"::",
"statement",
"(",
"'ALTER TABLE lessons AUTO_INCREMENT = 1'",
")",
";",
"DB",
"::",
"statement",
"(",
"'DELETE FROM lesson_user'",
")",
";",
"DB",
"::",
"statement",
"(",
"'ALTER TABLE lesson_user AUTO_INCREMENT = 1'",
")",
";",
"DB",
"::",
"statement",
"(",
"'DELETE FROM lesson_submodule'",
")",
";",
"DB",
"::",
"statement",
"(",
"'ALTER TABLE lesson_submodule AUTO_INCREMENT = 1'",
")",
";",
"DB",
"::",
"statement",
"(",
"'DELETE FROM classroom_submodule'",
")",
";",
"DB",
"::",
"statement",
"(",
"'ALTER TABLE classroom_submodule AUTO_INCREMENT = 1'",
")",
";",
"}",
"else",
"{",
"die",
"(",
")",
";",
"}",
"return",
"true",
";",
"case",
"2",
":",
"$",
"this",
"->",
"output",
"->",
"info",
"(",
"' Lesson data seems already migrated. Skipping lessons migration...'",
")",
";",
"return",
"false",
";",
"}",
"}"
] |
Check state of lessons migration.
@return bool
|
[
"Check",
"state",
"of",
"lessons",
"migration",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L911-L939
|
239,701
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.checkLessonMigrationStats
|
protected function checkLessonMigrationStats()
{
$numberOfOriginalLessons = Lesson::activeOn($this->period)->count();
$numberOfTrackedLessons = LessonMigration::all()->count();
$numberOfMigratedLessons = ScoolLesson::all()->count();
$this->output->info(' Original lessons: ' . $numberOfOriginalLessons);
$this->output->info(' Tracked migrated lessons (table lesson_migration): ' . $numberOfTrackedLessons );
$this->output->info(' Already migrated lessons: ' . $numberOfMigratedLessons);
if ($numberOfTrackedLessons == 0 && $numberOfMigratedLessons == 0) return 0;
if ( $numberOfOriginalLessons != $numberOfTrackedLessons ||
$numberOfTrackedLessons != $numberOfMigratedLessons) return 1;
if ( $numberOfOriginalLessons == $numberOfTrackedLessons ||
$numberOfTrackedLessons == $numberOfMigratedLessons) return 2;
}
|
php
|
protected function checkLessonMigrationStats()
{
$numberOfOriginalLessons = Lesson::activeOn($this->period)->count();
$numberOfTrackedLessons = LessonMigration::all()->count();
$numberOfMigratedLessons = ScoolLesson::all()->count();
$this->output->info(' Original lessons: ' . $numberOfOriginalLessons);
$this->output->info(' Tracked migrated lessons (table lesson_migration): ' . $numberOfTrackedLessons );
$this->output->info(' Already migrated lessons: ' . $numberOfMigratedLessons);
if ($numberOfTrackedLessons == 0 && $numberOfMigratedLessons == 0) return 0;
if ( $numberOfOriginalLessons != $numberOfTrackedLessons ||
$numberOfTrackedLessons != $numberOfMigratedLessons) return 1;
if ( $numberOfOriginalLessons == $numberOfTrackedLessons ||
$numberOfTrackedLessons == $numberOfMigratedLessons) return 2;
}
|
[
"protected",
"function",
"checkLessonMigrationStats",
"(",
")",
"{",
"$",
"numberOfOriginalLessons",
"=",
"Lesson",
"::",
"activeOn",
"(",
"$",
"this",
"->",
"period",
")",
"->",
"count",
"(",
")",
";",
"$",
"numberOfTrackedLessons",
"=",
"LessonMigration",
"::",
"all",
"(",
")",
"->",
"count",
"(",
")",
";",
"$",
"numberOfMigratedLessons",
"=",
"ScoolLesson",
"::",
"all",
"(",
")",
"->",
"count",
"(",
")",
";",
"$",
"this",
"->",
"output",
"->",
"info",
"(",
"' Original lessons: '",
".",
"$",
"numberOfOriginalLessons",
")",
";",
"$",
"this",
"->",
"output",
"->",
"info",
"(",
"' Tracked migrated lessons (table lesson_migration): '",
".",
"$",
"numberOfTrackedLessons",
")",
";",
"$",
"this",
"->",
"output",
"->",
"info",
"(",
"' Already migrated lessons: '",
".",
"$",
"numberOfMigratedLessons",
")",
";",
"if",
"(",
"$",
"numberOfTrackedLessons",
"==",
"0",
"&&",
"$",
"numberOfMigratedLessons",
"==",
"0",
")",
"return",
"0",
";",
"if",
"(",
"$",
"numberOfOriginalLessons",
"!=",
"$",
"numberOfTrackedLessons",
"||",
"$",
"numberOfTrackedLessons",
"!=",
"$",
"numberOfMigratedLessons",
")",
"return",
"1",
";",
"if",
"(",
"$",
"numberOfOriginalLessons",
"==",
"$",
"numberOfTrackedLessons",
"||",
"$",
"numberOfTrackedLessons",
"==",
"$",
"numberOfMigratedLessons",
")",
"return",
"2",
";",
"}"
] |
Check lesson migrations stats.
@return bool
|
[
"Check",
"lesson",
"migrations",
"stats",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L946-L959
|
239,702
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.enrollments
|
private function enrollments()
{
return $this->validateCollection(
Enrollment::activeOn(
AcademicPeriod::findOrFail($this->period)->shortname)
)->orderBy(
'enrollment_study_id',
'enrollment_course_id',
'enrollment_group_id')->get();
}
|
php
|
private function enrollments()
{
return $this->validateCollection(
Enrollment::activeOn(
AcademicPeriod::findOrFail($this->period)->shortname)
)->orderBy(
'enrollment_study_id',
'enrollment_course_id',
'enrollment_group_id')->get();
}
|
[
"private",
"function",
"enrollments",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"validateCollection",
"(",
"Enrollment",
"::",
"activeOn",
"(",
"AcademicPeriod",
"::",
"findOrFail",
"(",
"$",
"this",
"->",
"period",
")",
"->",
"shortname",
")",
")",
"->",
"orderBy",
"(",
"'enrollment_study_id'",
",",
"'enrollment_course_id'",
",",
"'enrollment_group_id'",
")",
"->",
"get",
"(",
")",
";",
"}"
] |
Obtain all ebre_escool_enrollments
|
[
"Obtain",
"all",
"ebre_escool_enrollments"
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L986-L995
|
239,703
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.migrateModule
|
public function migrateModule(StudyModuleAcademicPeriod $module)
{
try {
$this->setScoolModule(
$this->createModule($module)
);
} catch (\LogicException $le) {
$this->output->error($le->getMessage());
}
}
|
php
|
public function migrateModule(StudyModuleAcademicPeriod $module)
{
try {
$this->setScoolModule(
$this->createModule($module)
);
} catch (\LogicException $le) {
$this->output->error($le->getMessage());
}
}
|
[
"public",
"function",
"migrateModule",
"(",
"StudyModuleAcademicPeriod",
"$",
"module",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"setScoolModule",
"(",
"$",
"this",
"->",
"createModule",
"(",
"$",
"module",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"LogicException",
"$",
"le",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"error",
"(",
"$",
"le",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Migrate module.
@param StudyModuleAcademicPeriod $module
|
[
"Migrate",
"module",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L1078-L1088
|
239,704
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.createCourse
|
protected function createCourse(Course $srcCourse)
{
$course = ScoolCourse::firstOrNew([
'name' => $srcCourse->name,
]);
$course->save();
$course->shortname = $srcCourse->shortname;
$course->description = $srcCourse->description;
return $course;
}
|
php
|
protected function createCourse(Course $srcCourse)
{
$course = ScoolCourse::firstOrNew([
'name' => $srcCourse->name,
]);
$course->save();
$course->shortname = $srcCourse->shortname;
$course->description = $srcCourse->description;
return $course;
}
|
[
"protected",
"function",
"createCourse",
"(",
"Course",
"$",
"srcCourse",
")",
"{",
"$",
"course",
"=",
"ScoolCourse",
"::",
"firstOrNew",
"(",
"[",
"'name'",
"=>",
"$",
"srcCourse",
"->",
"name",
",",
"]",
")",
";",
"$",
"course",
"->",
"save",
"(",
")",
";",
"$",
"course",
"->",
"shortname",
"=",
"$",
"srcCourse",
"->",
"shortname",
";",
"$",
"course",
"->",
"description",
"=",
"$",
"srcCourse",
"->",
"description",
";",
"return",
"$",
"course",
";",
"}"
] |
Create scool course using ebre-escool course.
@param Course $srcCourse
@return mixed
|
[
"Create",
"scool",
"course",
"using",
"ebre",
"-",
"escool",
"course",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L1147-L1157
|
239,705
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.createModule
|
protected function createModule(StudyModuleAcademicPeriod $studyModule)
{
$module = ScoolModule::firstOrNew([
'name' => $studyModule->name,
'study_id' => $this->getScoolStudy()->id
]);
if($studyModule->study_shortname != $this->getScoolStudy()->shortname) {
throw new \LogicException(
'study_shortname in Ebre-escool study module (' . $studyModule->study_shortname
. ") doesn't match study shortname (" . $this->getScoolStudy()->shortname . ')');
}
$module->save();
$module->order = $studyModule->order;
$module->shortname = $studyModule->shortname;
$module->description = $studyModule->description;
return $module;
}
|
php
|
protected function createModule(StudyModuleAcademicPeriod $studyModule)
{
$module = ScoolModule::firstOrNew([
'name' => $studyModule->name,
'study_id' => $this->getScoolStudy()->id
]);
if($studyModule->study_shortname != $this->getScoolStudy()->shortname) {
throw new \LogicException(
'study_shortname in Ebre-escool study module (' . $studyModule->study_shortname
. ") doesn't match study shortname (" . $this->getScoolStudy()->shortname . ')');
}
$module->save();
$module->order = $studyModule->order;
$module->shortname = $studyModule->shortname;
$module->description = $studyModule->description;
return $module;
}
|
[
"protected",
"function",
"createModule",
"(",
"StudyModuleAcademicPeriod",
"$",
"studyModule",
")",
"{",
"$",
"module",
"=",
"ScoolModule",
"::",
"firstOrNew",
"(",
"[",
"'name'",
"=>",
"$",
"studyModule",
"->",
"name",
",",
"'study_id'",
"=>",
"$",
"this",
"->",
"getScoolStudy",
"(",
")",
"->",
"id",
"]",
")",
";",
"if",
"(",
"$",
"studyModule",
"->",
"study_shortname",
"!=",
"$",
"this",
"->",
"getScoolStudy",
"(",
")",
"->",
"shortname",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'study_shortname in Ebre-escool study module ('",
".",
"$",
"studyModule",
"->",
"study_shortname",
".",
"\") doesn't match study shortname (\"",
".",
"$",
"this",
"->",
"getScoolStudy",
"(",
")",
"->",
"shortname",
".",
"')'",
")",
";",
"}",
"$",
"module",
"->",
"save",
"(",
")",
";",
"$",
"module",
"->",
"order",
"=",
"$",
"studyModule",
"->",
"order",
";",
"$",
"module",
"->",
"shortname",
"=",
"$",
"studyModule",
"->",
"shortname",
";",
"$",
"module",
"->",
"description",
"=",
"$",
"studyModule",
"->",
"description",
";",
"return",
"$",
"module",
";",
"}"
] |
Create scool study module using ebre-escool study module.
@param StudyModuleAcademicPeriod $studyModule
@return mixed
@throws \Exception
|
[
"Create",
"scool",
"study",
"module",
"using",
"ebre",
"-",
"escool",
"study",
"module",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L1166-L1182
|
239,706
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.createSubmodule
|
protected function createSubmodule(StudySubModule $srcSubmodule)
{
//First Or new
$id = $this->SubModuleAlreadyExists($srcSubmodule);
if ($id != null) {
$submodule = Submodule::findOrFail($id);
} else {
$submodule = new Submodule();
}
$submodule->name = $srcSubmodule->name;
$submodule->order = $srcSubmodule->order;
$submodule->type = $this->mapTypes($srcSubmodule->type->id);
$submodule->save();
$submodule->altnames = [
'shortname' => $srcSubmodule->shortname,
'description' => $srcSubmodule->description
];
$submodule->addModule($this->getScoolModule());
return $submodule;
}
|
php
|
protected function createSubmodule(StudySubModule $srcSubmodule)
{
//First Or new
$id = $this->SubModuleAlreadyExists($srcSubmodule);
if ($id != null) {
$submodule = Submodule::findOrFail($id);
} else {
$submodule = new Submodule();
}
$submodule->name = $srcSubmodule->name;
$submodule->order = $srcSubmodule->order;
$submodule->type = $this->mapTypes($srcSubmodule->type->id);
$submodule->save();
$submodule->altnames = [
'shortname' => $srcSubmodule->shortname,
'description' => $srcSubmodule->description
];
$submodule->addModule($this->getScoolModule());
return $submodule;
}
|
[
"protected",
"function",
"createSubmodule",
"(",
"StudySubModule",
"$",
"srcSubmodule",
")",
"{",
"//First Or new",
"$",
"id",
"=",
"$",
"this",
"->",
"SubModuleAlreadyExists",
"(",
"$",
"srcSubmodule",
")",
";",
"if",
"(",
"$",
"id",
"!=",
"null",
")",
"{",
"$",
"submodule",
"=",
"Submodule",
"::",
"findOrFail",
"(",
"$",
"id",
")",
";",
"}",
"else",
"{",
"$",
"submodule",
"=",
"new",
"Submodule",
"(",
")",
";",
"}",
"$",
"submodule",
"->",
"name",
"=",
"$",
"srcSubmodule",
"->",
"name",
";",
"$",
"submodule",
"->",
"order",
"=",
"$",
"srcSubmodule",
"->",
"order",
";",
"$",
"submodule",
"->",
"type",
"=",
"$",
"this",
"->",
"mapTypes",
"(",
"$",
"srcSubmodule",
"->",
"type",
"->",
"id",
")",
";",
"$",
"submodule",
"->",
"save",
"(",
")",
";",
"$",
"submodule",
"->",
"altnames",
"=",
"[",
"'shortname'",
"=>",
"$",
"srcSubmodule",
"->",
"shortname",
",",
"'description'",
"=>",
"$",
"srcSubmodule",
"->",
"description",
"]",
";",
"$",
"submodule",
"->",
"addModule",
"(",
"$",
"this",
"->",
"getScoolModule",
"(",
")",
")",
";",
"return",
"$",
"submodule",
";",
"}"
] |
Create scool study submodule using ebre-escool study submodule.
@param StudySubModule $srcSubmodule
@return ScoolSubmodule
|
[
"Create",
"scool",
"study",
"submodule",
"using",
"ebre",
"-",
"escool",
"study",
"submodule",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L1190-L1211
|
239,707
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.showMigratingInfo
|
protected function showMigratingInfo($model, $level = 0) {
$suffix = '';
if ($model instanceof Study) {
$suffix = $model->multiple() ? ". <bg=yellow;options=bold>Study is multiple!</>" : "";
}
if ($this->verbose && $model->periods != null) $suffix .= ' ' . $model->periods->pluck('academic_periods_id');
$this->output->info(
str_repeat("_",$level) . 'Migrating ' . class_basename($model) . ': ' .
$model->name . '('. $model->id . ')...' . $suffix
);
}
|
php
|
protected function showMigratingInfo($model, $level = 0) {
$suffix = '';
if ($model instanceof Study) {
$suffix = $model->multiple() ? ". <bg=yellow;options=bold>Study is multiple!</>" : "";
}
if ($this->verbose && $model->periods != null) $suffix .= ' ' . $model->periods->pluck('academic_periods_id');
$this->output->info(
str_repeat("_",$level) . 'Migrating ' . class_basename($model) . ': ' .
$model->name . '('. $model->id . ')...' . $suffix
);
}
|
[
"protected",
"function",
"showMigratingInfo",
"(",
"$",
"model",
",",
"$",
"level",
"=",
"0",
")",
"{",
"$",
"suffix",
"=",
"''",
";",
"if",
"(",
"$",
"model",
"instanceof",
"Study",
")",
"{",
"$",
"suffix",
"=",
"$",
"model",
"->",
"multiple",
"(",
")",
"?",
"\". <bg=yellow;options=bold>Study is multiple!</>\"",
":",
"\"\"",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"verbose",
"&&",
"$",
"model",
"->",
"periods",
"!=",
"null",
")",
"$",
"suffix",
".=",
"' '",
".",
"$",
"model",
"->",
"periods",
"->",
"pluck",
"(",
"'academic_periods_id'",
")",
";",
"$",
"this",
"->",
"output",
"->",
"info",
"(",
"str_repeat",
"(",
"\"_\"",
",",
"$",
"level",
")",
".",
"'Migrating '",
".",
"class_basename",
"(",
"$",
"model",
")",
".",
"': '",
".",
"$",
"model",
"->",
"name",
".",
"'('",
".",
"$",
"model",
"->",
"id",
".",
"')...'",
".",
"$",
"suffix",
")",
";",
"}"
] |
Show migrating info.
@param $model
@param int $level
TODO https://github.com/acacha/ebre_escool_migration/issues/4
|
[
"Show",
"migrating",
"info",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L1245-L1256
|
239,708
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.academicPeriods
|
protected function academicPeriods()
{
if ( ! $this->filtersAppliedToPeriods()) return AcademicPeriod::all();
if (str_contains($this->filters[0], '-')) {
try {
return collect([AcademicPeriod::where(['academic_periods_name' => $this->filters[0]])->firstOrFail()]);
} catch (\Exception $e) {
return collect([AcademicPeriod::where(['academic_periods_shortname' => $this->filters[0]])->firstOrFail()]);
}
}
if ( ! is_numeric($this->filters[0])) throw new \InvalidArgumentException();
return collect([AcademicPeriod::findOrFail(intval($this->filters[0]))]);
}
|
php
|
protected function academicPeriods()
{
if ( ! $this->filtersAppliedToPeriods()) return AcademicPeriod::all();
if (str_contains($this->filters[0], '-')) {
try {
return collect([AcademicPeriod::where(['academic_periods_name' => $this->filters[0]])->firstOrFail()]);
} catch (\Exception $e) {
return collect([AcademicPeriod::where(['academic_periods_shortname' => $this->filters[0]])->firstOrFail()]);
}
}
if ( ! is_numeric($this->filters[0])) throw new \InvalidArgumentException();
return collect([AcademicPeriod::findOrFail(intval($this->filters[0]))]);
}
|
[
"protected",
"function",
"academicPeriods",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"filtersAppliedToPeriods",
"(",
")",
")",
"return",
"AcademicPeriod",
"::",
"all",
"(",
")",
";",
"if",
"(",
"str_contains",
"(",
"$",
"this",
"->",
"filters",
"[",
"0",
"]",
",",
"'-'",
")",
")",
"{",
"try",
"{",
"return",
"collect",
"(",
"[",
"AcademicPeriod",
"::",
"where",
"(",
"[",
"'academic_periods_name'",
"=>",
"$",
"this",
"->",
"filters",
"[",
"0",
"]",
"]",
")",
"->",
"firstOrFail",
"(",
")",
"]",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"collect",
"(",
"[",
"AcademicPeriod",
"::",
"where",
"(",
"[",
"'academic_periods_shortname'",
"=>",
"$",
"this",
"->",
"filters",
"[",
"0",
"]",
"]",
")",
"->",
"firstOrFail",
"(",
")",
"]",
")",
";",
"}",
"}",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"this",
"->",
"filters",
"[",
"0",
"]",
")",
")",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
")",
";",
"return",
"collect",
"(",
"[",
"AcademicPeriod",
"::",
"findOrFail",
"(",
"intval",
"(",
"$",
"this",
"->",
"filters",
"[",
"0",
"]",
")",
")",
"]",
")",
";",
"}"
] |
Get academic periods.
@return \Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection|static[]
|
[
"Get",
"academic",
"periods",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L1301-L1313
|
239,709
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.departments
|
protected function departments()
{
//Avoid using FOL because is a transversal department
if ( ! $this->filtersAppliedToDepartments()) return $this->validateCollection(Department::whereNotIn('department_id', [3])->get());
if ( ! is_numeric($this->filters[1]) ) throw new \InvalidArgumentException();
return collect([Department::findOrFail(intval($this->filters[1]))]);
}
|
php
|
protected function departments()
{
//Avoid using FOL because is a transversal department
if ( ! $this->filtersAppliedToDepartments()) return $this->validateCollection(Department::whereNotIn('department_id', [3])->get());
if ( ! is_numeric($this->filters[1]) ) throw new \InvalidArgumentException();
return collect([Department::findOrFail(intval($this->filters[1]))]);
}
|
[
"protected",
"function",
"departments",
"(",
")",
"{",
"//Avoid using FOL because is a transversal department",
"if",
"(",
"!",
"$",
"this",
"->",
"filtersAppliedToDepartments",
"(",
")",
")",
"return",
"$",
"this",
"->",
"validateCollection",
"(",
"Department",
"::",
"whereNotIn",
"(",
"'department_id'",
",",
"[",
"3",
"]",
")",
"->",
"get",
"(",
")",
")",
";",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"this",
"->",
"filters",
"[",
"1",
"]",
")",
")",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
")",
";",
"return",
"collect",
"(",
"[",
"Department",
"::",
"findOrFail",
"(",
"intval",
"(",
"$",
"this",
"->",
"filters",
"[",
"1",
"]",
")",
")",
"]",
")",
";",
"}"
] |
Get the departments to migrate.
@return \Illuminate\Support\Collection|mixed
|
[
"Get",
"the",
"departments",
"to",
"migrate",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L1350-L1356
|
239,710
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.studies
|
protected function studies(Department $department) {
return $this->validateCollection($department->studiesActiveOn($this->period)->get());
}
|
php
|
protected function studies(Department $department) {
return $this->validateCollection($department->studiesActiveOn($this->period)->get());
}
|
[
"protected",
"function",
"studies",
"(",
"Department",
"$",
"department",
")",
"{",
"return",
"$",
"this",
"->",
"validateCollection",
"(",
"$",
"department",
"->",
"studiesActiveOn",
"(",
"$",
"this",
"->",
"period",
")",
"->",
"get",
"(",
")",
")",
";",
"}"
] |
Get the studies to migrate.
@param Department $department
@return mixed
|
[
"Get",
"the",
"studies",
"to",
"migrate",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L1364-L1366
|
239,711
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.modules
|
protected function modules(Course $course) {
$modules = $course->modules()->active()->get();
$sortedModules = $modules->sortBy(
function ($module, $key) {
return $module->order;
}
);
return $this->validateCollection($sortedModules);
}
|
php
|
protected function modules(Course $course) {
$modules = $course->modules()->active()->get();
$sortedModules = $modules->sortBy(
function ($module, $key) {
return $module->order;
}
);
return $this->validateCollection($sortedModules);
}
|
[
"protected",
"function",
"modules",
"(",
"Course",
"$",
"course",
")",
"{",
"$",
"modules",
"=",
"$",
"course",
"->",
"modules",
"(",
")",
"->",
"active",
"(",
")",
"->",
"get",
"(",
")",
";",
"$",
"sortedModules",
"=",
"$",
"modules",
"->",
"sortBy",
"(",
"function",
"(",
"$",
"module",
",",
"$",
"key",
")",
"{",
"return",
"$",
"module",
"->",
"order",
";",
"}",
")",
";",
"return",
"$",
"this",
"->",
"validateCollection",
"(",
"$",
"sortedModules",
")",
";",
"}"
] |
Get the modules to migrate.
@param Course $course
@return \Illuminate\Database\Eloquent\Collection|static[]
|
[
"Get",
"the",
"modules",
"to",
"migrate",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L1384-L1392
|
239,712
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.submodules
|
protected function submodules(StudyModuleAcademicPeriod $module) {
return $this->validateCollection($module->module()->first()->submodules()->active()->get());
}
|
php
|
protected function submodules(StudyModuleAcademicPeriod $module) {
return $this->validateCollection($module->module()->first()->submodules()->active()->get());
}
|
[
"protected",
"function",
"submodules",
"(",
"StudyModuleAcademicPeriod",
"$",
"module",
")",
"{",
"return",
"$",
"this",
"->",
"validateCollection",
"(",
"$",
"module",
"->",
"module",
"(",
")",
"->",
"first",
"(",
")",
"->",
"submodules",
"(",
")",
"->",
"active",
"(",
")",
"->",
"get",
"(",
")",
")",
";",
"}"
] |
Get the submodules to migrate.
@param StudyModuleAcademicPeriod $module
@return mixed
|
[
"Get",
"the",
"submodules",
"to",
"migrate",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L1400-L1402
|
239,713
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.switchToDestinationConnection
|
protected function switchToDestinationConnection()
{ $env = env(
$this->composeDestinationConnectionEnvVarByCurrentPeriodInProcess(),
$this->composeDestinationConnectionNameByCurrentPeriodInProcess()
);
$this->switchConnection($env,$this->getDestinationConnection());
}
|
php
|
protected function switchToDestinationConnection()
{ $env = env(
$this->composeDestinationConnectionEnvVarByCurrentPeriodInProcess(),
$this->composeDestinationConnectionNameByCurrentPeriodInProcess()
);
$this->switchConnection($env,$this->getDestinationConnection());
}
|
[
"protected",
"function",
"switchToDestinationConnection",
"(",
")",
"{",
"$",
"env",
"=",
"env",
"(",
"$",
"this",
"->",
"composeDestinationConnectionEnvVarByCurrentPeriodInProcess",
"(",
")",
",",
"$",
"this",
"->",
"composeDestinationConnectionNameByCurrentPeriodInProcess",
"(",
")",
")",
";",
"$",
"this",
"->",
"switchConnection",
"(",
"$",
"env",
",",
"$",
"this",
"->",
"getDestinationConnection",
"(",
")",
")",
";",
"}"
] |
Switch to current destination connection in process.
|
[
"Switch",
"to",
"current",
"destination",
"connection",
"in",
"process",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L1601-L1607
|
239,714
|
kevindierkx/elicit
|
src/Query/Grammars/Grammar.php
|
Grammar.compileComponents
|
protected function compileComponents(Builder $query)
{
$request = [];
foreach ($this->requestComponents as $component) {
// To compile the query, we'll spin through each component of the query and
// see if that component exists. If it does we'll just call the compiler
// function for the component which is responsible for making the request.
if (!is_null($query->$component)) {
$method = 'compile' . ucfirst($component);
$request[$component] = $this->$method($query, $query->$component);
}
}
return $request;
}
|
php
|
protected function compileComponents(Builder $query)
{
$request = [];
foreach ($this->requestComponents as $component) {
// To compile the query, we'll spin through each component of the query and
// see if that component exists. If it does we'll just call the compiler
// function for the component which is responsible for making the request.
if (!is_null($query->$component)) {
$method = 'compile' . ucfirst($component);
$request[$component] = $this->$method($query, $query->$component);
}
}
return $request;
}
|
[
"protected",
"function",
"compileComponents",
"(",
"Builder",
"$",
"query",
")",
"{",
"$",
"request",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"requestComponents",
"as",
"$",
"component",
")",
"{",
"// To compile the query, we'll spin through each component of the query and",
"// see if that component exists. If it does we'll just call the compiler",
"// function for the component which is responsible for making the request.",
"if",
"(",
"!",
"is_null",
"(",
"$",
"query",
"->",
"$",
"component",
")",
")",
"{",
"$",
"method",
"=",
"'compile'",
".",
"ucfirst",
"(",
"$",
"component",
")",
";",
"$",
"request",
"[",
"$",
"component",
"]",
"=",
"$",
"this",
"->",
"$",
"method",
"(",
"$",
"query",
",",
"$",
"query",
"->",
"$",
"component",
")",
";",
"}",
"}",
"return",
"$",
"request",
";",
"}"
] |
Compile the components necessary for the request.
@param \Kevindierkx\Elicit\Query\Builder
@return array
|
[
"Compile",
"the",
"components",
"necessary",
"for",
"the",
"request",
"."
] |
c277942f5f5f63b175bc37e9d392faa946888f65
|
https://github.com/kevindierkx/elicit/blob/c277942f5f5f63b175bc37e9d392faa946888f65/src/Query/Grammars/Grammar.php#L36-L52
|
239,715
|
kevindierkx/elicit
|
src/Query/Grammars/Grammar.php
|
Grammar.compileBody
|
protected function compileBody(Builder $query)
{
$body = [];
$hasBody = !is_null($query->body);
if ($hasBody) {
foreach ($query->body as $postField) {
$body[$postField['column']] = $postField['value'];
}
if (count($body) > 0) {
return $body;
}
}
return '';
}
|
php
|
protected function compileBody(Builder $query)
{
$body = [];
$hasBody = !is_null($query->body);
if ($hasBody) {
foreach ($query->body as $postField) {
$body[$postField['column']] = $postField['value'];
}
if (count($body) > 0) {
return $body;
}
}
return '';
}
|
[
"protected",
"function",
"compileBody",
"(",
"Builder",
"$",
"query",
")",
"{",
"$",
"body",
"=",
"[",
"]",
";",
"$",
"hasBody",
"=",
"!",
"is_null",
"(",
"$",
"query",
"->",
"body",
")",
";",
"if",
"(",
"$",
"hasBody",
")",
"{",
"foreach",
"(",
"$",
"query",
"->",
"body",
"as",
"$",
"postField",
")",
"{",
"$",
"body",
"[",
"$",
"postField",
"[",
"'column'",
"]",
"]",
"=",
"$",
"postField",
"[",
"'value'",
"]",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"body",
")",
">",
"0",
")",
"{",
"return",
"$",
"body",
";",
"}",
"}",
"return",
"''",
";",
"}"
] |
Compile the "body" portions of the query.
@param \Kevindierkx\Elicit\Query\Builder $query
@return string
|
[
"Compile",
"the",
"body",
"portions",
"of",
"the",
"query",
"."
] |
c277942f5f5f63b175bc37e9d392faa946888f65
|
https://github.com/kevindierkx/elicit/blob/c277942f5f5f63b175bc37e9d392faa946888f65/src/Query/Grammars/Grammar.php#L130-L147
|
239,716
|
vox-tecnologia/pdf
|
src/Pdf/AbstractPdfAdapter.php
|
AbstractPdfAdapter.setHeader
|
public function setHeader(array $data): PdfInterface
{
$string_right = str_replace("{{date(\"n/d/Y g:i A\")}}", Carbon::now()->format('n/d/Y g:i A'), $data['right']);
$string_left = str_replace("|", '<br>', $data['left']);
$html = "<table border='0' cellspacing='0' cellpadding='0' width='100%'><tr>
<td style='font-family:arial;font-size:14px;font-weight:bold;'>$string_left</td>
<td style='font-size:13px;font-family:arial;text-align:right;font-style:italic;'>$string_right</td>
</tr></table><br>";
$this->setProperty('pageHeader', $html);
$this->appendPageContent($this->pageHeader);
return $this;
}
|
php
|
public function setHeader(array $data): PdfInterface
{
$string_right = str_replace("{{date(\"n/d/Y g:i A\")}}", Carbon::now()->format('n/d/Y g:i A'), $data['right']);
$string_left = str_replace("|", '<br>', $data['left']);
$html = "<table border='0' cellspacing='0' cellpadding='0' width='100%'><tr>
<td style='font-family:arial;font-size:14px;font-weight:bold;'>$string_left</td>
<td style='font-size:13px;font-family:arial;text-align:right;font-style:italic;'>$string_right</td>
</tr></table><br>";
$this->setProperty('pageHeader', $html);
$this->appendPageContent($this->pageHeader);
return $this;
}
|
[
"public",
"function",
"setHeader",
"(",
"array",
"$",
"data",
")",
":",
"PdfInterface",
"{",
"$",
"string_right",
"=",
"str_replace",
"(",
"\"{{date(\\\"n/d/Y g:i A\\\")}}\"",
",",
"Carbon",
"::",
"now",
"(",
")",
"->",
"format",
"(",
"'n/d/Y g:i A'",
")",
",",
"$",
"data",
"[",
"'right'",
"]",
")",
";",
"$",
"string_left",
"=",
"str_replace",
"(",
"\"|\"",
",",
"'<br>'",
",",
"$",
"data",
"[",
"'left'",
"]",
")",
";",
"$",
"html",
"=",
"\"<table border='0' cellspacing='0' cellpadding='0' width='100%'><tr>\n <td style='font-family:arial;font-size:14px;font-weight:bold;'>$string_left</td>\n <td style='font-size:13px;font-family:arial;text-align:right;font-style:italic;'>$string_right</td>\n </tr></table><br>\"",
";",
"$",
"this",
"->",
"setProperty",
"(",
"'pageHeader'",
",",
"$",
"html",
")",
";",
"$",
"this",
"->",
"appendPageContent",
"(",
"$",
"this",
"->",
"pageHeader",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the page header.
@param array $data The list of header items ('left','right')
@return PdfInterface The current instance
@api
|
[
"Set",
"the",
"page",
"header",
"."
] |
c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969
|
https://github.com/vox-tecnologia/pdf/blob/c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969/src/Pdf/AbstractPdfAdapter.php#L179-L193
|
239,717
|
vox-tecnologia/pdf
|
src/Pdf/AbstractPdfAdapter.php
|
AbstractPdfAdapter.setFooter
|
public function setFooter(array $data, string $side = 'both'): PdfInterface
{
$data = array_change_key_case($data, CASE_LOWER);
$footer = ('<table width="100%" style="vertical-align: bottom; font-family: arial; font-size: 9pt; color: #000000; font-weight: bold; font-style: italic;"><tr>'.
$this->setFooterContent('left', (string) $data['left']).
$this->setFooterContent('center', (string) $data['center']).
$this->setFooterContent('right', (string) $data['right']).
'</tr></table>');
$this->setProperty('pageFooter', $footer, $side);
$this->mpdf->mirrorMargins = false; // if unique sides -> true
$this->mpdf->SetHTMLFooter($this->getProperty('pageFooter', $side), 'O'); // Odd = 'O', Even = 'E'
return $this;
}
|
php
|
public function setFooter(array $data, string $side = 'both'): PdfInterface
{
$data = array_change_key_case($data, CASE_LOWER);
$footer = ('<table width="100%" style="vertical-align: bottom; font-family: arial; font-size: 9pt; color: #000000; font-weight: bold; font-style: italic;"><tr>'.
$this->setFooterContent('left', (string) $data['left']).
$this->setFooterContent('center', (string) $data['center']).
$this->setFooterContent('right', (string) $data['right']).
'</tr></table>');
$this->setProperty('pageFooter', $footer, $side);
$this->mpdf->mirrorMargins = false; // if unique sides -> true
$this->mpdf->SetHTMLFooter($this->getProperty('pageFooter', $side), 'O'); // Odd = 'O', Even = 'E'
return $this;
}
|
[
"public",
"function",
"setFooter",
"(",
"array",
"$",
"data",
",",
"string",
"$",
"side",
"=",
"'both'",
")",
":",
"PdfInterface",
"{",
"$",
"data",
"=",
"array_change_key_case",
"(",
"$",
"data",
",",
"CASE_LOWER",
")",
";",
"$",
"footer",
"=",
"(",
"'<table width=\"100%\" style=\"vertical-align: bottom; font-family: arial; font-size: 9pt; color: #000000; font-weight: bold; font-style: italic;\"><tr>'",
".",
"$",
"this",
"->",
"setFooterContent",
"(",
"'left'",
",",
"(",
"string",
")",
"$",
"data",
"[",
"'left'",
"]",
")",
".",
"$",
"this",
"->",
"setFooterContent",
"(",
"'center'",
",",
"(",
"string",
")",
"$",
"data",
"[",
"'center'",
"]",
")",
".",
"$",
"this",
"->",
"setFooterContent",
"(",
"'right'",
",",
"(",
"string",
")",
"$",
"data",
"[",
"'right'",
"]",
")",
".",
"'</tr></table>'",
")",
";",
"$",
"this",
"->",
"setProperty",
"(",
"'pageFooter'",
",",
"$",
"footer",
",",
"$",
"side",
")",
";",
"$",
"this",
"->",
"mpdf",
"->",
"mirrorMargins",
"=",
"false",
";",
"// if unique sides -> true",
"$",
"this",
"->",
"mpdf",
"->",
"SetHTMLFooter",
"(",
"$",
"this",
"->",
"getProperty",
"(",
"'pageFooter'",
",",
"$",
"side",
")",
",",
"'O'",
")",
";",
"// Odd = 'O', Even = 'E'",
"return",
"$",
"this",
";",
"}"
] |
Set the page footer.
{@note: printing even/odd pages is not available yet.}
@param array $data The list of footer items ('left','center','right')
@param string $side The option for unique even/odd page printing ('both','even','odd')
@return PdfInterface The current instance
@api
|
[
"Set",
"the",
"page",
"footer",
"."
] |
c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969
|
https://github.com/vox-tecnologia/pdf/blob/c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969/src/Pdf/AbstractPdfAdapter.php#L209-L224
|
239,718
|
vox-tecnologia/pdf
|
src/Pdf/AbstractPdfAdapter.php
|
AbstractPdfAdapter.setFontType
|
public function setFontType(string $fontname = null): PdfInterface
{
/**
* Font sets to be used for PDF documents:
*
* - Arial - Times - Tahoma
* - Georgia - Trebuchet - Courier
* - Lucida - Lucida-Bright - Palatino
* - Garamond - Verdana - Console
* - Monaco - Helvetica - Calibri
* - Avant-Garde - Cambria
*/
$this->setProperty('fontType', $this->getFontFamily(strtolower($fontname)));
$this->mpdf->SetDefaultBodyCSS('font-family', $this->getProperty('fontType'));
return $this;
}
|
php
|
public function setFontType(string $fontname = null): PdfInterface
{
/**
* Font sets to be used for PDF documents:
*
* - Arial - Times - Tahoma
* - Georgia - Trebuchet - Courier
* - Lucida - Lucida-Bright - Palatino
* - Garamond - Verdana - Console
* - Monaco - Helvetica - Calibri
* - Avant-Garde - Cambria
*/
$this->setProperty('fontType', $this->getFontFamily(strtolower($fontname)));
$this->mpdf->SetDefaultBodyCSS('font-family', $this->getProperty('fontType'));
return $this;
}
|
[
"public",
"function",
"setFontType",
"(",
"string",
"$",
"fontname",
"=",
"null",
")",
":",
"PdfInterface",
"{",
"/**\n * Font sets to be used for PDF documents:\n *\n * - Arial - Times - Tahoma\n * - Georgia - Trebuchet - Courier\n * - Lucida - Lucida-Bright - Palatino\n * - Garamond - Verdana - Console\n * - Monaco - Helvetica - Calibri\n * - Avant-Garde - Cambria\n */",
"$",
"this",
"->",
"setProperty",
"(",
"'fontType'",
",",
"$",
"this",
"->",
"getFontFamily",
"(",
"strtolower",
"(",
"$",
"fontname",
")",
")",
")",
";",
"$",
"this",
"->",
"mpdf",
"->",
"SetDefaultBodyCSS",
"(",
"'font-family'",
",",
"$",
"this",
"->",
"getProperty",
"(",
"'fontType'",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the default document font.
@param string $fontname The font name ('Times','Helvetica','Courier')
@return PdfInterface The current instance
@api
|
[
"Set",
"the",
"default",
"document",
"font",
"."
] |
c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969
|
https://github.com/vox-tecnologia/pdf/blob/c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969/src/Pdf/AbstractPdfAdapter.php#L257-L273
|
239,719
|
vox-tecnologia/pdf
|
src/Pdf/AbstractPdfAdapter.php
|
AbstractPdfAdapter.getFontFamily
|
protected function getFontFamily(string $fontname = null): string
{
/**
* Font sets to be used for PDF documents:
*
* - Arial - Times - Tahoma
* - Georgia - Trebuchet - Courier
* - Lucida - Lucida-Bright - Palatino
* - Garamond - Verdana - Console
* - Monaco - Helvetica - Calibri
* - Avant-Garde - Cambria
*/
return array_key_exists(strtolower($fontname), $this->fontFamily)
? $this->fontFamily[strtolower($fontname)]
: $this->fontFamily['default'];
}
|
php
|
protected function getFontFamily(string $fontname = null): string
{
/**
* Font sets to be used for PDF documents:
*
* - Arial - Times - Tahoma
* - Georgia - Trebuchet - Courier
* - Lucida - Lucida-Bright - Palatino
* - Garamond - Verdana - Console
* - Monaco - Helvetica - Calibri
* - Avant-Garde - Cambria
*/
return array_key_exists(strtolower($fontname), $this->fontFamily)
? $this->fontFamily[strtolower($fontname)]
: $this->fontFamily['default'];
}
|
[
"protected",
"function",
"getFontFamily",
"(",
"string",
"$",
"fontname",
"=",
"null",
")",
":",
"string",
"{",
"/**\n * Font sets to be used for PDF documents:\n *\n * - Arial - Times - Tahoma\n * - Georgia - Trebuchet - Courier\n * - Lucida - Lucida-Bright - Palatino\n * - Garamond - Verdana - Console\n * - Monaco - Helvetica - Calibri\n * - Avant-Garde - Cambria\n */",
"return",
"array_key_exists",
"(",
"strtolower",
"(",
"$",
"fontname",
")",
",",
"$",
"this",
"->",
"fontFamily",
")",
"?",
"$",
"this",
"->",
"fontFamily",
"[",
"strtolower",
"(",
"$",
"fontname",
")",
"]",
":",
"$",
"this",
"->",
"fontFamily",
"[",
"'default'",
"]",
";",
"}"
] |
Return a specific font-family.
@param string $fontname The font name type
@return string
@api
|
[
"Return",
"a",
"specific",
"font",
"-",
"family",
"."
] |
c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969
|
https://github.com/vox-tecnologia/pdf/blob/c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969/src/Pdf/AbstractPdfAdapter.php#L286-L301
|
239,720
|
vox-tecnologia/pdf
|
src/Pdf/AbstractPdfAdapter.php
|
AbstractPdfAdapter.appendPageContent
|
public function appendPageContent(string $str): PdfInterface
{
$this->setProperty('pageContent', $str);
$this->mpdf->WriteHTML($this->pageContent);
return $this;
}
|
php
|
public function appendPageContent(string $str): PdfInterface
{
$this->setProperty('pageContent', $str);
$this->mpdf->WriteHTML($this->pageContent);
return $this;
}
|
[
"public",
"function",
"appendPageContent",
"(",
"string",
"$",
"str",
")",
":",
"PdfInterface",
"{",
"$",
"this",
"->",
"setProperty",
"(",
"'pageContent'",
",",
"$",
"str",
")",
";",
"$",
"this",
"->",
"mpdf",
"->",
"WriteHTML",
"(",
"$",
"this",
"->",
"pageContent",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Append the HTML content.
@param string $str The string data used for render
@return PdfInterface The current instance
@api
|
[
"Append",
"the",
"HTML",
"content",
"."
] |
c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969
|
https://github.com/vox-tecnologia/pdf/blob/c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969/src/Pdf/AbstractPdfAdapter.php#L314-L320
|
239,721
|
vox-tecnologia/pdf
|
src/Pdf/AbstractPdfAdapter.php
|
AbstractPdfAdapter.setMargins
|
public function setMargins(array $setting): PdfInterface
{
$this->setProperty('marginTop', (int) $setting['marginTop']);
$this->setProperty('marginRight', (int) $setting['marginRight']);
$this->setProperty('marginBottom', (int) $setting['marginBottom']);
$this->setProperty('marginLeft', (int) $setting['marginLeft']);
$this->setProperty('marginHeader', (int) $setting['marginHeader']);
$this->setProperty('marginFooter', (int) $setting['marginFooter']);
return $this;
}
|
php
|
public function setMargins(array $setting): PdfInterface
{
$this->setProperty('marginTop', (int) $setting['marginTop']);
$this->setProperty('marginRight', (int) $setting['marginRight']);
$this->setProperty('marginBottom', (int) $setting['marginBottom']);
$this->setProperty('marginLeft', (int) $setting['marginLeft']);
$this->setProperty('marginHeader', (int) $setting['marginHeader']);
$this->setProperty('marginFooter', (int) $setting['marginFooter']);
return $this;
}
|
[
"public",
"function",
"setMargins",
"(",
"array",
"$",
"setting",
")",
":",
"PdfInterface",
"{",
"$",
"this",
"->",
"setProperty",
"(",
"'marginTop'",
",",
"(",
"int",
")",
"$",
"setting",
"[",
"'marginTop'",
"]",
")",
";",
"$",
"this",
"->",
"setProperty",
"(",
"'marginRight'",
",",
"(",
"int",
")",
"$",
"setting",
"[",
"'marginRight'",
"]",
")",
";",
"$",
"this",
"->",
"setProperty",
"(",
"'marginBottom'",
",",
"(",
"int",
")",
"$",
"setting",
"[",
"'marginBottom'",
"]",
")",
";",
"$",
"this",
"->",
"setProperty",
"(",
"'marginLeft'",
",",
"(",
"int",
")",
"$",
"setting",
"[",
"'marginLeft'",
"]",
")",
";",
"$",
"this",
"->",
"setProperty",
"(",
"'marginHeader'",
",",
"(",
"int",
")",
"$",
"setting",
"[",
"'marginHeader'",
"]",
")",
";",
"$",
"this",
"->",
"setProperty",
"(",
"'marginFooter'",
",",
"(",
"int",
")",
"$",
"setting",
"[",
"'marginFooter'",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the page margins.
@param array $setting The margin configiration setting
@return PdfInterface The current instance
@api
|
[
"Set",
"the",
"page",
"margins",
"."
] |
c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969
|
https://github.com/vox-tecnologia/pdf/blob/c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969/src/Pdf/AbstractPdfAdapter.php#L441-L451
|
239,722
|
vox-tecnologia/pdf
|
src/Pdf/AbstractPdfAdapter.php
|
AbstractPdfAdapter.setPageSize
|
public function setPageSize(string $pageSize): PdfInterface
{
$this->setProperty('pageSize', $pageSize);
$this->registerPageFormat();
return $this;
}
|
php
|
public function setPageSize(string $pageSize): PdfInterface
{
$this->setProperty('pageSize', $pageSize);
$this->registerPageFormat();
return $this;
}
|
[
"public",
"function",
"setPageSize",
"(",
"string",
"$",
"pageSize",
")",
":",
"PdfInterface",
"{",
"$",
"this",
"->",
"setProperty",
"(",
"'pageSize'",
",",
"$",
"pageSize",
")",
";",
"$",
"this",
"->",
"registerPageFormat",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the page size.
@param string $pageSize The page format/size type ['Letter','Legal', etc.]
@return PdfInterface The current instance
@api
|
[
"Set",
"the",
"page",
"size",
"."
] |
c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969
|
https://github.com/vox-tecnologia/pdf/blob/c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969/src/Pdf/AbstractPdfAdapter.php#L464-L470
|
239,723
|
vox-tecnologia/pdf
|
src/Pdf/AbstractPdfAdapter.php
|
AbstractPdfAdapter.appendPageCSS
|
public function appendPageCSS(string $str): PdfInterface
{
$this->setProperty('pageCSS', $str);
$this->mpdf->WriteHTML($this->pageCSS, 1);
return $this;
}
|
php
|
public function appendPageCSS(string $str): PdfInterface
{
$this->setProperty('pageCSS', $str);
$this->mpdf->WriteHTML($this->pageCSS, 1);
return $this;
}
|
[
"public",
"function",
"appendPageCSS",
"(",
"string",
"$",
"str",
")",
":",
"PdfInterface",
"{",
"$",
"this",
"->",
"setProperty",
"(",
"'pageCSS'",
",",
"$",
"str",
")",
";",
"$",
"this",
"->",
"mpdf",
"->",
"WriteHTML",
"(",
"$",
"this",
"->",
"pageCSS",
",",
"1",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Append a CSS style.
@param string $str The string data used for render
@return PdfInterface The current instance
@api
|
[
"Append",
"a",
"CSS",
"style",
"."
] |
c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969
|
https://github.com/vox-tecnologia/pdf/blob/c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969/src/Pdf/AbstractPdfAdapter.php#L483-L489
|
239,724
|
vox-tecnologia/pdf
|
src/Pdf/AbstractPdfAdapter.php
|
AbstractPdfAdapter.registerPageFormat
|
protected function registerPageFormat(string $pageSize = null, string $orientation = null): PdfInterface
{
in_array($pageSize, $this->pageTypes)
? $this->setProperty('pageSize', $pageSize)
: $this->setProperty('pageSize', static::DEFAULT_PAGE_SIZE);
$this->setPageOrientation($orientation);
return $this;
}
|
php
|
protected function registerPageFormat(string $pageSize = null, string $orientation = null): PdfInterface
{
in_array($pageSize, $this->pageTypes)
? $this->setProperty('pageSize', $pageSize)
: $this->setProperty('pageSize', static::DEFAULT_PAGE_SIZE);
$this->setPageOrientation($orientation);
return $this;
}
|
[
"protected",
"function",
"registerPageFormat",
"(",
"string",
"$",
"pageSize",
"=",
"null",
",",
"string",
"$",
"orientation",
"=",
"null",
")",
":",
"PdfInterface",
"{",
"in_array",
"(",
"$",
"pageSize",
",",
"$",
"this",
"->",
"pageTypes",
")",
"?",
"$",
"this",
"->",
"setProperty",
"(",
"'pageSize'",
",",
"$",
"pageSize",
")",
":",
"$",
"this",
"->",
"setProperty",
"(",
"'pageSize'",
",",
"static",
"::",
"DEFAULT_PAGE_SIZE",
")",
";",
"$",
"this",
"->",
"setPageOrientation",
"(",
"$",
"orientation",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Generate and store a defined PDF page format.
@param string $pageSize The page format type ['Letter','Legal', etc.]
@param string $orientation The page orientation ['Portrait','Landscape']
@return PdfInterface The current instance
|
[
"Generate",
"and",
"store",
"a",
"defined",
"PDF",
"page",
"format",
"."
] |
c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969
|
https://github.com/vox-tecnologia/pdf/blob/c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969/src/Pdf/AbstractPdfAdapter.php#L501-L510
|
239,725
|
vox-tecnologia/pdf
|
src/Pdf/AbstractPdfAdapter.php
|
AbstractPdfAdapter.setPageOrientation
|
public function setPageOrientation(string $orientation): PdfInterface
{
$this->setProperty('pageOrientation', strtoupper($orientation[0]));
$this->pageOrientation === 'L'
? $this->setProperty('pageFormat', $this->pageSize . '-' . $this->pageOrientation)
: $this->setProperty('pageFormat', $this->pageSize);
return $this;
}
|
php
|
public function setPageOrientation(string $orientation): PdfInterface
{
$this->setProperty('pageOrientation', strtoupper($orientation[0]));
$this->pageOrientation === 'L'
? $this->setProperty('pageFormat', $this->pageSize . '-' . $this->pageOrientation)
: $this->setProperty('pageFormat', $this->pageSize);
return $this;
}
|
[
"public",
"function",
"setPageOrientation",
"(",
"string",
"$",
"orientation",
")",
":",
"PdfInterface",
"{",
"$",
"this",
"->",
"setProperty",
"(",
"'pageOrientation'",
",",
"strtoupper",
"(",
"$",
"orientation",
"[",
"0",
"]",
")",
")",
";",
"$",
"this",
"->",
"pageOrientation",
"===",
"'L'",
"?",
"$",
"this",
"->",
"setProperty",
"(",
"'pageFormat'",
",",
"$",
"this",
"->",
"pageSize",
".",
"'-'",
".",
"$",
"this",
"->",
"pageOrientation",
")",
":",
"$",
"this",
"->",
"setProperty",
"(",
"'pageFormat'",
",",
"$",
"this",
"->",
"pageSize",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the page orientation.
@param string $orientation The page orientation ['Portrait','Landscape']
@return PdfInterface The current instance
|
[
"Set",
"the",
"page",
"orientation",
"."
] |
c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969
|
https://github.com/vox-tecnologia/pdf/blob/c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969/src/Pdf/AbstractPdfAdapter.php#L521-L530
|
239,726
|
vox-tecnologia/pdf
|
src/Pdf/AbstractPdfAdapter.php
|
AbstractPdfAdapter.setMetaTitle
|
public function setMetaTitle(string $str): PdfInterface
{
$this->setProperty('metaTitle', $str);
$this->mpdf->SetTitle($this->metaTitle);
return $this;
}
|
php
|
public function setMetaTitle(string $str): PdfInterface
{
$this->setProperty('metaTitle', $str);
$this->mpdf->SetTitle($this->metaTitle);
return $this;
}
|
[
"public",
"function",
"setMetaTitle",
"(",
"string",
"$",
"str",
")",
":",
"PdfInterface",
"{",
"$",
"this",
"->",
"setProperty",
"(",
"'metaTitle'",
",",
"$",
"str",
")",
";",
"$",
"this",
"->",
"mpdf",
"->",
"SetTitle",
"(",
"$",
"this",
"->",
"metaTitle",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set PDF Meta Title.
@param string $str The page title
@return PdfInterface The current instance
|
[
"Set",
"PDF",
"Meta",
"Title",
"."
] |
c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969
|
https://github.com/vox-tecnologia/pdf/blob/c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969/src/Pdf/AbstractPdfAdapter.php#L541-L547
|
239,727
|
vox-tecnologia/pdf
|
src/Pdf/AbstractPdfAdapter.php
|
AbstractPdfAdapter.setMetaAuthor
|
public function setMetaAuthor(string $str): PdfInterface
{
$this->setProperty('metaAuthor', $str);
$this->mpdf->SetAuthor($this->metaAuthor);
return $this;
}
|
php
|
public function setMetaAuthor(string $str): PdfInterface
{
$this->setProperty('metaAuthor', $str);
$this->mpdf->SetAuthor($this->metaAuthor);
return $this;
}
|
[
"public",
"function",
"setMetaAuthor",
"(",
"string",
"$",
"str",
")",
":",
"PdfInterface",
"{",
"$",
"this",
"->",
"setProperty",
"(",
"'metaAuthor'",
",",
"$",
"str",
")",
";",
"$",
"this",
"->",
"mpdf",
"->",
"SetAuthor",
"(",
"$",
"this",
"->",
"metaAuthor",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set PDF Meta Author.
@param string $str The page author
@return PdfInterface The current instance
|
[
"Set",
"PDF",
"Meta",
"Author",
"."
] |
c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969
|
https://github.com/vox-tecnologia/pdf/blob/c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969/src/Pdf/AbstractPdfAdapter.php#L558-L564
|
239,728
|
vox-tecnologia/pdf
|
src/Pdf/AbstractPdfAdapter.php
|
AbstractPdfAdapter.setMetaCreator
|
public function setMetaCreator(string $str): PdfInterface
{
$this->setProperty('metaCreator', $str);
$this->mpdf->SetCreator($this->metaCreator);
return $this;
}
|
php
|
public function setMetaCreator(string $str): PdfInterface
{
$this->setProperty('metaCreator', $str);
$this->mpdf->SetCreator($this->metaCreator);
return $this;
}
|
[
"public",
"function",
"setMetaCreator",
"(",
"string",
"$",
"str",
")",
":",
"PdfInterface",
"{",
"$",
"this",
"->",
"setProperty",
"(",
"'metaCreator'",
",",
"$",
"str",
")",
";",
"$",
"this",
"->",
"mpdf",
"->",
"SetCreator",
"(",
"$",
"this",
"->",
"metaCreator",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set PDF Meta Creator.
@param string $str The page creator
@return PdfInterface The current instance
|
[
"Set",
"PDF",
"Meta",
"Creator",
"."
] |
c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969
|
https://github.com/vox-tecnologia/pdf/blob/c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969/src/Pdf/AbstractPdfAdapter.php#L575-L581
|
239,729
|
vox-tecnologia/pdf
|
src/Pdf/AbstractPdfAdapter.php
|
AbstractPdfAdapter.setMetaSubject
|
public function setMetaSubject(string $str): PdfInterface
{
$this->setProperty('metaSubject', $str);
$this->mpdf->SetSubject($this->metaSubject);
return $this;
}
|
php
|
public function setMetaSubject(string $str): PdfInterface
{
$this->setProperty('metaSubject', $str);
$this->mpdf->SetSubject($this->metaSubject);
return $this;
}
|
[
"public",
"function",
"setMetaSubject",
"(",
"string",
"$",
"str",
")",
":",
"PdfInterface",
"{",
"$",
"this",
"->",
"setProperty",
"(",
"'metaSubject'",
",",
"$",
"str",
")",
";",
"$",
"this",
"->",
"mpdf",
"->",
"SetSubject",
"(",
"$",
"this",
"->",
"metaSubject",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set PDF Meta Subject.
@param string $str The page subject
@return PdfInterface The current instance
|
[
"Set",
"PDF",
"Meta",
"Subject",
"."
] |
c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969
|
https://github.com/vox-tecnologia/pdf/blob/c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969/src/Pdf/AbstractPdfAdapter.php#L592-L598
|
239,730
|
vox-tecnologia/pdf
|
src/Pdf/AbstractPdfAdapter.php
|
AbstractPdfAdapter.setMetaKeywords
|
public function setMetaKeywords(array $words): PdfInterface
{
$this->setProperty('metaKeywords', array_merge($this->metaKeywords, $words));
$this->mpdf->SetKeywords(implode(', ', $this->metaKeywords));
return $this;
}
|
php
|
public function setMetaKeywords(array $words): PdfInterface
{
$this->setProperty('metaKeywords', array_merge($this->metaKeywords, $words));
$this->mpdf->SetKeywords(implode(', ', $this->metaKeywords));
return $this;
}
|
[
"public",
"function",
"setMetaKeywords",
"(",
"array",
"$",
"words",
")",
":",
"PdfInterface",
"{",
"$",
"this",
"->",
"setProperty",
"(",
"'metaKeywords'",
",",
"array_merge",
"(",
"$",
"this",
"->",
"metaKeywords",
",",
"$",
"words",
")",
")",
";",
"$",
"this",
"->",
"mpdf",
"->",
"SetKeywords",
"(",
"implode",
"(",
"', '",
",",
"$",
"this",
"->",
"metaKeywords",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set PDF Meta Key Words.
@param array $words The page key words
@return PdfInterface The current instance
|
[
"Set",
"PDF",
"Meta",
"Key",
"Words",
"."
] |
c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969
|
https://github.com/vox-tecnologia/pdf/blob/c9ca4303beb57c93bb0f2884d12cc0a8bbe2a969/src/Pdf/AbstractPdfAdapter.php#L609-L615
|
239,731
|
tomphp/TjoAnnotationRouter
|
src/TjoAnnotationRouter/Parser/ControllerParser.php
|
ControllerParser.parseReflectedController
|
public function parseReflectedController($name, ClassReflection $reflection, ArrayObject $config)
{
$annotations = $reflection->getAnnotations($this->annotationManager);
if ($annotations instanceof AnnotationCollection) {
$this->processor->processController($name, $annotations);
}
foreach ($reflection->getMethods() as $method) {
$annotations = $method->getAnnotations($this->annotationManager);
if (!$annotations instanceof AnnotationCollection) {
continue;
}
$this->processor->processMethod($method->getName(), $annotations, $config);
}
return $config;
}
|
php
|
public function parseReflectedController($name, ClassReflection $reflection, ArrayObject $config)
{
$annotations = $reflection->getAnnotations($this->annotationManager);
if ($annotations instanceof AnnotationCollection) {
$this->processor->processController($name, $annotations);
}
foreach ($reflection->getMethods() as $method) {
$annotations = $method->getAnnotations($this->annotationManager);
if (!$annotations instanceof AnnotationCollection) {
continue;
}
$this->processor->processMethod($method->getName(), $annotations, $config);
}
return $config;
}
|
[
"public",
"function",
"parseReflectedController",
"(",
"$",
"name",
",",
"ClassReflection",
"$",
"reflection",
",",
"ArrayObject",
"$",
"config",
")",
"{",
"$",
"annotations",
"=",
"$",
"reflection",
"->",
"getAnnotations",
"(",
"$",
"this",
"->",
"annotationManager",
")",
";",
"if",
"(",
"$",
"annotations",
"instanceof",
"AnnotationCollection",
")",
"{",
"$",
"this",
"->",
"processor",
"->",
"processController",
"(",
"$",
"name",
",",
"$",
"annotations",
")",
";",
"}",
"foreach",
"(",
"$",
"reflection",
"->",
"getMethods",
"(",
")",
"as",
"$",
"method",
")",
"{",
"$",
"annotations",
"=",
"$",
"method",
"->",
"getAnnotations",
"(",
"$",
"this",
"->",
"annotationManager",
")",
";",
"if",
"(",
"!",
"$",
"annotations",
"instanceof",
"AnnotationCollection",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"processor",
"->",
"processMethod",
"(",
"$",
"method",
"->",
"getName",
"(",
")",
",",
"$",
"annotations",
",",
"$",
"config",
")",
";",
"}",
"return",
"$",
"config",
";",
"}"
] |
Builds the config for a controller.
@param string $name
@param ClassReflection $reflection
@param ArrayObject $config
@return ArrayObject Returns the config array object.
|
[
"Builds",
"the",
"config",
"for",
"a",
"controller",
"."
] |
ee323691e948d82449287eae5c1ecce80cc90971
|
https://github.com/tomphp/TjoAnnotationRouter/blob/ee323691e948d82449287eae5c1ecce80cc90971/src/TjoAnnotationRouter/Parser/ControllerParser.php#L69-L88
|
239,732
|
ironedgesoftware/graphs
|
src/Export/Utils.php
|
Utils.getSystemService
|
public function getSystemService(): SystemService
{
if ($this->_systemService === null) {
$this->_systemService = new SystemService();
}
return $this->_systemService;
}
|
php
|
public function getSystemService(): SystemService
{
if ($this->_systemService === null) {
$this->_systemService = new SystemService();
}
return $this->_systemService;
}
|
[
"public",
"function",
"getSystemService",
"(",
")",
":",
"SystemService",
"{",
"if",
"(",
"$",
"this",
"->",
"_systemService",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"_systemService",
"=",
"new",
"SystemService",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_systemService",
";",
"}"
] |
Returns the value of field _systemService.
@return SystemService
|
[
"Returns",
"the",
"value",
"of",
"field",
"_systemService",
"."
] |
c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0
|
https://github.com/ironedgesoftware/graphs/blob/c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0/src/Export/Utils.php#L45-L52
|
239,733
|
noordawod/php-util
|
src/System.php
|
System.realPath
|
public static function realPath(/*string*/ $filePath = '') {
if('' === $filePath) {
$filePath = '.';
}
$filePath = @realpath($filePath);
if(false !== $filePath) {
$filePath = str_replace('\\', '/', $filePath);
if('/' !== $filePath) {
$filePath = rtrim($filePath, '/');
}
}
return $filePath;
}
|
php
|
public static function realPath(/*string*/ $filePath = '') {
if('' === $filePath) {
$filePath = '.';
}
$filePath = @realpath($filePath);
if(false !== $filePath) {
$filePath = str_replace('\\', '/', $filePath);
if('/' !== $filePath) {
$filePath = rtrim($filePath, '/');
}
}
return $filePath;
}
|
[
"public",
"static",
"function",
"realPath",
"(",
"/*string*/",
"$",
"filePath",
"=",
"''",
")",
"{",
"if",
"(",
"''",
"===",
"$",
"filePath",
")",
"{",
"$",
"filePath",
"=",
"'.'",
";",
"}",
"$",
"filePath",
"=",
"@",
"realpath",
"(",
"$",
"filePath",
")",
";",
"if",
"(",
"false",
"!==",
"$",
"filePath",
")",
"{",
"$",
"filePath",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"filePath",
")",
";",
"if",
"(",
"'/'",
"!==",
"$",
"filePath",
")",
"{",
"$",
"filePath",
"=",
"rtrim",
"(",
"$",
"filePath",
",",
"'/'",
")",
";",
"}",
"}",
"return",
"$",
"filePath",
";",
"}"
] |
Returns an absolute path for the specified file path. The file must exist
on the file system for this call to yield something.
Three important notes:
1) The directory separator will always be a slash (/) character, even on
hosts with a different separator (ex.: Windows)
2) Except for the case of the root directory, no trailing slash will be
added to the absolute path.
3) If an empty string is passed as a value, current directory will be used
as the path.
@param string $filePath to target file (defaults to current directory)
@return string||FALSE absolute path on success, FALSE otherwise
|
[
"Returns",
"an",
"absolute",
"path",
"for",
"the",
"specified",
"file",
"path",
".",
"The",
"file",
"must",
"exist",
"on",
"the",
"file",
"system",
"for",
"this",
"call",
"to",
"yield",
"something",
"."
] |
6458690cc2c8457914a2aa74b131451d4a8e5797
|
https://github.com/noordawod/php-util/blob/6458690cc2c8457914a2aa74b131451d4a8e5797/src/System.php#L126-L138
|
239,734
|
noordawod/php-util
|
src/System.php
|
System.containsPath
|
public static function containsPath(/*string*/ $top, /*string*/ $sub) {
$top = self::realPath($top);
$sub = self::realPath($sub);
return self::isDir($top) && self::isDir($sub) &&
0 === strpos($sub, $top . '/');
}
|
php
|
public static function containsPath(/*string*/ $top, /*string*/ $sub) {
$top = self::realPath($top);
$sub = self::realPath($sub);
return self::isDir($top) && self::isDir($sub) &&
0 === strpos($sub, $top . '/');
}
|
[
"public",
"static",
"function",
"containsPath",
"(",
"/*string*/",
"$",
"top",
",",
"/*string*/",
"$",
"sub",
")",
"{",
"$",
"top",
"=",
"self",
"::",
"realPath",
"(",
"$",
"top",
")",
";",
"$",
"sub",
"=",
"self",
"::",
"realPath",
"(",
"$",
"sub",
")",
";",
"return",
"self",
"::",
"isDir",
"(",
"$",
"top",
")",
"&&",
"self",
"::",
"isDir",
"(",
"$",
"sub",
")",
"&&",
"0",
"===",
"strpos",
"(",
"$",
"sub",
",",
"$",
"top",
".",
"'/'",
")",
";",
"}"
] |
Checks whether a parent directory contains the specified sub-directory.
@param string $top parent (top) directory
@param string $sub directory
@return boolean TRUE if top directory contains the sub, FALSE otherwise
|
[
"Checks",
"whether",
"a",
"parent",
"directory",
"contains",
"the",
"specified",
"sub",
"-",
"directory",
"."
] |
6458690cc2c8457914a2aa74b131451d4a8e5797
|
https://github.com/noordawod/php-util/blob/6458690cc2c8457914a2aa74b131451d4a8e5797/src/System.php#L147-L152
|
239,735
|
noordawod/php-util
|
src/System.php
|
System.openFile
|
public static function openFile(/*string*/ $filePath, /*string*/ $mode) {
return self::isFile($filePath) ? fopen($filePath, $mode, false) : false;
}
|
php
|
public static function openFile(/*string*/ $filePath, /*string*/ $mode) {
return self::isFile($filePath) ? fopen($filePath, $mode, false) : false;
}
|
[
"public",
"static",
"function",
"openFile",
"(",
"/*string*/",
"$",
"filePath",
",",
"/*string*/",
"$",
"mode",
")",
"{",
"return",
"self",
"::",
"isFile",
"(",
"$",
"filePath",
")",
"?",
"fopen",
"(",
"$",
"filePath",
",",
"$",
"mode",
",",
"false",
")",
":",
"false",
";",
"}"
] |
Opens the supplied file with the requested mode.
@param string $filePath to target file
@param string $mode for opening the file
@see \fopen()
@return resource|FALSE resource to the opened file, FALSE on error
|
[
"Opens",
"the",
"supplied",
"file",
"with",
"the",
"requested",
"mode",
"."
] |
6458690cc2c8457914a2aa74b131451d4a8e5797
|
https://github.com/noordawod/php-util/blob/6458690cc2c8457914a2aa74b131451d4a8e5797/src/System.php#L162-L164
|
239,736
|
noordawod/php-util
|
src/System.php
|
System.tempFile
|
public static function tempFile(/*string*/ $prefix = '') {
$prefix = @trim($prefix);
if('' === $prefix) {
$prefix = time() . '-' . rand(11111, 99999);
}
$prefix .= '.';
$tempPath = tempnam(sys_get_temp_dir(), $prefix);
return $tempPath;
}
|
php
|
public static function tempFile(/*string*/ $prefix = '') {
$prefix = @trim($prefix);
if('' === $prefix) {
$prefix = time() . '-' . rand(11111, 99999);
}
$prefix .= '.';
$tempPath = tempnam(sys_get_temp_dir(), $prefix);
return $tempPath;
}
|
[
"public",
"static",
"function",
"tempFile",
"(",
"/*string*/",
"$",
"prefix",
"=",
"''",
")",
"{",
"$",
"prefix",
"=",
"@",
"trim",
"(",
"$",
"prefix",
")",
";",
"if",
"(",
"''",
"===",
"$",
"prefix",
")",
"{",
"$",
"prefix",
"=",
"time",
"(",
")",
".",
"'-'",
".",
"rand",
"(",
"11111",
",",
"99999",
")",
";",
"}",
"$",
"prefix",
".=",
"'.'",
";",
"$",
"tempPath",
"=",
"tempnam",
"(",
"sys_get_temp_dir",
"(",
")",
",",
"$",
"prefix",
")",
";",
"return",
"$",
"tempPath",
";",
"}"
] |
Creates a new temporary file in the system's default temporary directory.
@param string $prefix to append to the name (optional)
@see \tempnam()
@see \sys_get_temp_dir()
@return string|FALSE temporary file's location, FALSE on error
|
[
"Creates",
"a",
"new",
"temporary",
"file",
"in",
"the",
"system",
"s",
"default",
"temporary",
"directory",
"."
] |
6458690cc2c8457914a2aa74b131451d4a8e5797
|
https://github.com/noordawod/php-util/blob/6458690cc2c8457914a2aa74b131451d4a8e5797/src/System.php#L196-L204
|
239,737
|
veridu/idos-sdk-php
|
src/idOS/Facade/Profile/Raw.php
|
Raw.getInstance
|
private static function getInstance(
string $userName,
Auth $auth
) : RawEndpoint {
return new RawEndpoint(
$userName,
$auth,
new Client()
);
}
|
php
|
private static function getInstance(
string $userName,
Auth $auth
) : RawEndpoint {
return new RawEndpoint(
$userName,
$auth,
new Client()
);
}
|
[
"private",
"static",
"function",
"getInstance",
"(",
"string",
"$",
"userName",
",",
"Auth",
"$",
"auth",
")",
":",
"RawEndpoint",
"{",
"return",
"new",
"RawEndpoint",
"(",
"$",
"userName",
",",
"$",
"auth",
",",
"new",
"Client",
"(",
")",
")",
";",
"}"
] |
Returns the raw instance or, creates a new one if it doesn't exists yet and returns it.
@param string $userName
@param Auth $auth
@return Raw instance
|
[
"Returns",
"the",
"raw",
"instance",
"or",
"creates",
"a",
"new",
"one",
"if",
"it",
"doesn",
"t",
"exists",
"yet",
"and",
"returns",
"it",
"."
] |
e56757bed10404756f2f0485a4b7f55794192008
|
https://github.com/veridu/idos-sdk-php/blob/e56757bed10404756f2f0485a4b7f55794192008/src/idOS/Facade/Profile/Raw.php#L20-L29
|
239,738
|
veridu/idos-sdk-php
|
src/idOS/Facade/Profile/Raw.php
|
Raw.createNew
|
public static function createNew(
string $userName,
int $sourceId,
string $collectionName,
array $data,
Auth $auth
) {
return static::getInstance()
->createNew($sourceId, $collectionName, $data);
}
|
php
|
public static function createNew(
string $userName,
int $sourceId,
string $collectionName,
array $data,
Auth $auth
) {
return static::getInstance()
->createNew($sourceId, $collectionName, $data);
}
|
[
"public",
"static",
"function",
"createNew",
"(",
"string",
"$",
"userName",
",",
"int",
"$",
"sourceId",
",",
"string",
"$",
"collectionName",
",",
"array",
"$",
"data",
",",
"Auth",
"$",
"auth",
")",
"{",
"return",
"static",
"::",
"getInstance",
"(",
")",
"->",
"createNew",
"(",
"$",
"sourceId",
",",
"$",
"collectionName",
",",
"$",
"data",
")",
";",
"}"
] |
Creates a new instance of Raw.
@param string $userName
@param int $sourceId
@param string $collectionName
@param array $data
@param Auth $auth
@return array response
|
[
"Creates",
"a",
"new",
"instance",
"of",
"Raw",
"."
] |
e56757bed10404756f2f0485a4b7f55794192008
|
https://github.com/veridu/idos-sdk-php/blob/e56757bed10404756f2f0485a4b7f55794192008/src/idOS/Facade/Profile/Raw.php#L42-L51
|
239,739
|
pickles2/node-pickles2-module-editor
|
php/main.php
|
main.createPickles2ContentsEditor
|
public function createPickles2ContentsEditor(){
$px2ce = new \pickles2\libs\contentsEditor\main();
$px2ce->init(
array(
'page_path' => '/px2me-dummy.html', // <- 編集対象ページのパス
'appMode' => $this->getAppMode(), // 'web' or 'desktop'. default to 'web'
'entryScript' => $this->entryScript,
'customFields' => array() ,
'log' => function($msg){},
'commands' => @$this->options['commands'],
)
);
return $px2ce;
}
|
php
|
public function createPickles2ContentsEditor(){
$px2ce = new \pickles2\libs\contentsEditor\main();
$px2ce->init(
array(
'page_path' => '/px2me-dummy.html', // <- 編集対象ページのパス
'appMode' => $this->getAppMode(), // 'web' or 'desktop'. default to 'web'
'entryScript' => $this->entryScript,
'customFields' => array() ,
'log' => function($msg){},
'commands' => @$this->options['commands'],
)
);
return $px2ce;
}
|
[
"public",
"function",
"createPickles2ContentsEditor",
"(",
")",
"{",
"$",
"px2ce",
"=",
"new",
"\\",
"pickles2",
"\\",
"libs",
"\\",
"contentsEditor",
"\\",
"main",
"(",
")",
";",
"$",
"px2ce",
"->",
"init",
"(",
"array",
"(",
"'page_path'",
"=>",
"'/px2me-dummy.html'",
",",
"// <- 編集対象ページのパス",
"'appMode'",
"=>",
"$",
"this",
"->",
"getAppMode",
"(",
")",
",",
"// 'web' or 'desktop'. default to 'web'",
"'entryScript'",
"=>",
"$",
"this",
"->",
"entryScript",
",",
"'customFields'",
"=>",
"array",
"(",
")",
",",
"'log'",
"=>",
"function",
"(",
"$",
"msg",
")",
"{",
"}",
",",
"'commands'",
"=>",
"@",
"$",
"this",
"->",
"options",
"[",
"'commands'",
"]",
",",
")",
")",
";",
"return",
"$",
"px2ce",
";",
"}"
] |
create pickles2-contents-editor object
|
[
"create",
"pickles2",
"-",
"contents",
"-",
"editor",
"object"
] |
a4270c09cb047b119ccb28eef654e223cc33f3c8
|
https://github.com/pickles2/node-pickles2-module-editor/blob/a4270c09cb047b119ccb28eef654e223cc33f3c8/php/main.php#L307-L322
|
239,740
|
axypro/creator
|
helpers/NameResolver.php
|
NameResolver.resolve
|
public static function resolve($classname, array $context)
{
if ($classname[0] === '\\') {
return substr($classname, 1);
}
$cn = explode(':', $classname, 2);
if (count($cn) === 1) {
if (!empty($context['namespace'])) {
$classname = $context['namespace'].$classname;
}
return $classname;
}
$module = $cn[0];
$cn = $cn[1];
if (!empty($context['modules'])) {
$modules = $context['modules'];
if (isset($modules[$module])) {
return $modules[$module].'\\'.$cn;
}
}
if (!empty($context['moduleResolver'])) {
$cn = Callback::call($context['moduleResolver'], [$module, $cn]);
if (is_string($cn)) {
return $cn;
}
}
throw new InvalidPointer($classname);
}
|
php
|
public static function resolve($classname, array $context)
{
if ($classname[0] === '\\') {
return substr($classname, 1);
}
$cn = explode(':', $classname, 2);
if (count($cn) === 1) {
if (!empty($context['namespace'])) {
$classname = $context['namespace'].$classname;
}
return $classname;
}
$module = $cn[0];
$cn = $cn[1];
if (!empty($context['modules'])) {
$modules = $context['modules'];
if (isset($modules[$module])) {
return $modules[$module].'\\'.$cn;
}
}
if (!empty($context['moduleResolver'])) {
$cn = Callback::call($context['moduleResolver'], [$module, $cn]);
if (is_string($cn)) {
return $cn;
}
}
throw new InvalidPointer($classname);
}
|
[
"public",
"static",
"function",
"resolve",
"(",
"$",
"classname",
",",
"array",
"$",
"context",
")",
"{",
"if",
"(",
"$",
"classname",
"[",
"0",
"]",
"===",
"'\\\\'",
")",
"{",
"return",
"substr",
"(",
"$",
"classname",
",",
"1",
")",
";",
"}",
"$",
"cn",
"=",
"explode",
"(",
"':'",
",",
"$",
"classname",
",",
"2",
")",
";",
"if",
"(",
"count",
"(",
"$",
"cn",
")",
"===",
"1",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"context",
"[",
"'namespace'",
"]",
")",
")",
"{",
"$",
"classname",
"=",
"$",
"context",
"[",
"'namespace'",
"]",
".",
"$",
"classname",
";",
"}",
"return",
"$",
"classname",
";",
"}",
"$",
"module",
"=",
"$",
"cn",
"[",
"0",
"]",
";",
"$",
"cn",
"=",
"$",
"cn",
"[",
"1",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"context",
"[",
"'modules'",
"]",
")",
")",
"{",
"$",
"modules",
"=",
"$",
"context",
"[",
"'modules'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"modules",
"[",
"$",
"module",
"]",
")",
")",
"{",
"return",
"$",
"modules",
"[",
"$",
"module",
"]",
".",
"'\\\\'",
".",
"$",
"cn",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"context",
"[",
"'moduleResolver'",
"]",
")",
")",
"{",
"$",
"cn",
"=",
"Callback",
"::",
"call",
"(",
"$",
"context",
"[",
"'moduleResolver'",
"]",
",",
"[",
"$",
"module",
",",
"$",
"cn",
"]",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"cn",
")",
")",
"{",
"return",
"$",
"cn",
";",
"}",
"}",
"throw",
"new",
"InvalidPointer",
"(",
"$",
"classname",
")",
";",
"}"
] |
Resolves a class name
@param string $classname
@param array $context
@return string
@throws \axy\creator\errors\InvalidPointer
|
[
"Resolves",
"a",
"class",
"name"
] |
3d74e2201cdb93912d32b1d80d1fdc44018f132a
|
https://github.com/axypro/creator/blob/3d74e2201cdb93912d32b1d80d1fdc44018f132a/helpers/NameResolver.php#L25-L52
|
239,741
|
rozaverta/cmf
|
core/Support/Str.php
|
Str.cache
|
public static function cache( $value, $name, $delimiter = null )
{
if( $value === '' )
{
return $value;
}
$func = $name;
$arg2 = $name == "snake";
if( $arg2 )
{
if( is_null($delimiter) )
{
$delimiter = "_";
}
}
else if( ($arg2 = $arg2 == "ascii") )
{
if( is_null($delimiter) )
{
$delimiter = "en";
}
}
if( $arg2 )
{
$name .= $delimiter;
}
if( isset(self::$cache[$name][$value]) )
{
return self::$cache[$name][$value];
}
return self::$cache[$name][$value] = ( $func == "snake" ? static::snake($value, $delimiter) : static::$func($value) );
}
|
php
|
public static function cache( $value, $name, $delimiter = null )
{
if( $value === '' )
{
return $value;
}
$func = $name;
$arg2 = $name == "snake";
if( $arg2 )
{
if( is_null($delimiter) )
{
$delimiter = "_";
}
}
else if( ($arg2 = $arg2 == "ascii") )
{
if( is_null($delimiter) )
{
$delimiter = "en";
}
}
if( $arg2 )
{
$name .= $delimiter;
}
if( isset(self::$cache[$name][$value]) )
{
return self::$cache[$name][$value];
}
return self::$cache[$name][$value] = ( $func == "snake" ? static::snake($value, $delimiter) : static::$func($value) );
}
|
[
"public",
"static",
"function",
"cache",
"(",
"$",
"value",
",",
"$",
"name",
",",
"$",
"delimiter",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"''",
")",
"{",
"return",
"$",
"value",
";",
"}",
"$",
"func",
"=",
"$",
"name",
";",
"$",
"arg2",
"=",
"$",
"name",
"==",
"\"snake\"",
";",
"if",
"(",
"$",
"arg2",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"delimiter",
")",
")",
"{",
"$",
"delimiter",
"=",
"\"_\"",
";",
"}",
"}",
"else",
"if",
"(",
"(",
"$",
"arg2",
"=",
"$",
"arg2",
"==",
"\"ascii\"",
")",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"delimiter",
")",
")",
"{",
"$",
"delimiter",
"=",
"\"en\"",
";",
"}",
"}",
"if",
"(",
"$",
"arg2",
")",
"{",
"$",
"name",
".=",
"$",
"delimiter",
";",
"}",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"cache",
"[",
"$",
"name",
"]",
"[",
"$",
"value",
"]",
")",
")",
"{",
"return",
"self",
"::",
"$",
"cache",
"[",
"$",
"name",
"]",
"[",
"$",
"value",
"]",
";",
"}",
"return",
"self",
"::",
"$",
"cache",
"[",
"$",
"name",
"]",
"[",
"$",
"value",
"]",
"=",
"(",
"$",
"func",
"==",
"\"snake\"",
"?",
"static",
"::",
"snake",
"(",
"$",
"value",
",",
"$",
"delimiter",
")",
":",
"static",
"::",
"$",
"func",
"(",
"$",
"value",
")",
")",
";",
"}"
] |
Read the given string from cache or convert to needle case and save to cache.
@param string $value
@param string $name
@param string $delimiter used only snake case
@return string
|
[
"Read",
"the",
"given",
"string",
"from",
"cache",
"or",
"convert",
"to",
"needle",
"case",
"and",
"save",
"to",
"cache",
"."
] |
95ed38362e397d1c700ee255f7200234ef98d356
|
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Support/Str.php#L132-L168
|
239,742
|
northern/PHP-Common
|
src/Northern/Common/Util/UrlUtil.php
|
UrlUtil.getSlug
|
public static function getSlug($text, $separator = '-')
{
return strtolower(
trim(
preg_replace('~[^0-9a-z]+~i', '-', html_entity_decode(
preg_replace('~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', htmlentities(
$text, ENT_QUOTES, 'UTF-8'
)
), ENT_QUOTES, 'UTF-8')
), $separator)
);
}
|
php
|
public static function getSlug($text, $separator = '-')
{
return strtolower(
trim(
preg_replace('~[^0-9a-z]+~i', '-', html_entity_decode(
preg_replace('~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', htmlentities(
$text, ENT_QUOTES, 'UTF-8'
)
), ENT_QUOTES, 'UTF-8')
), $separator)
);
}
|
[
"public",
"static",
"function",
"getSlug",
"(",
"$",
"text",
",",
"$",
"separator",
"=",
"'-'",
")",
"{",
"return",
"strtolower",
"(",
"trim",
"(",
"preg_replace",
"(",
"'~[^0-9a-z]+~i'",
",",
"'-'",
",",
"html_entity_decode",
"(",
"preg_replace",
"(",
"'~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i'",
",",
"'$1'",
",",
"htmlentities",
"(",
"$",
"text",
",",
"ENT_QUOTES",
",",
"'UTF-8'",
")",
")",
",",
"ENT_QUOTES",
",",
"'UTF-8'",
")",
")",
",",
"$",
"separator",
")",
")",
";",
"}"
] |
Transforms a given string into a URL safe "slug".
@param string $text
@param string $separator
@return string
Source: http://stackoverflow.com/questions/2103797/url-friendly-username-in-php
|
[
"Transforms",
"a",
"given",
"string",
"into",
"a",
"URL",
"safe",
"slug",
"."
] |
7c63ef19252fd540fb412a18af956b8563afaa55
|
https://github.com/northern/PHP-Common/blob/7c63ef19252fd540fb412a18af956b8563afaa55/src/Northern/Common/Util/UrlUtil.php#L29-L40
|
239,743
|
tux-rampage/rampage-php
|
library/rampage/core/resources/UrlLocator.php
|
UrlLocator.resolve
|
protected function resolve($filename, $scope)
{
$scopeIndex = ($scope === false)? '' : $scope;
$theme = $this->getCurrentTheme();
$url = false;
if (isset($this->locations[$theme][$scopeIndex][$filename])) {
return $this->locations[$theme][$scopeIndex][$filename];
}
if ($this->publishingStrategy) {
$url = $this->publishingStrategy->find($filename, $scope, $this->getTheme());
}
if ($url === false) {
if (!$this->router) {
throw new exception\DependencyException('Missing router instance to build dynamic resource url');
}
$routeOptions = array(
'name' => 'rampage.core.resources',
);
$routeParams = array(
'theme' => $theme,
'scope' => ($scope? : '__theme__'),
'file' => $filename
);
$url = $this->router->assemble($routeParams, $routeOptions);
if ($this->baseUrl) {
$url = $this->baseUrl->getUrl($url);
}
}
$this->locations[$theme][$scopeIndex][$filename] = $url;
return $url;
}
|
php
|
protected function resolve($filename, $scope)
{
$scopeIndex = ($scope === false)? '' : $scope;
$theme = $this->getCurrentTheme();
$url = false;
if (isset($this->locations[$theme][$scopeIndex][$filename])) {
return $this->locations[$theme][$scopeIndex][$filename];
}
if ($this->publishingStrategy) {
$url = $this->publishingStrategy->find($filename, $scope, $this->getTheme());
}
if ($url === false) {
if (!$this->router) {
throw new exception\DependencyException('Missing router instance to build dynamic resource url');
}
$routeOptions = array(
'name' => 'rampage.core.resources',
);
$routeParams = array(
'theme' => $theme,
'scope' => ($scope? : '__theme__'),
'file' => $filename
);
$url = $this->router->assemble($routeParams, $routeOptions);
if ($this->baseUrl) {
$url = $this->baseUrl->getUrl($url);
}
}
$this->locations[$theme][$scopeIndex][$filename] = $url;
return $url;
}
|
[
"protected",
"function",
"resolve",
"(",
"$",
"filename",
",",
"$",
"scope",
")",
"{",
"$",
"scopeIndex",
"=",
"(",
"$",
"scope",
"===",
"false",
")",
"?",
"''",
":",
"$",
"scope",
";",
"$",
"theme",
"=",
"$",
"this",
"->",
"getCurrentTheme",
"(",
")",
";",
"$",
"url",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"locations",
"[",
"$",
"theme",
"]",
"[",
"$",
"scopeIndex",
"]",
"[",
"$",
"filename",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"locations",
"[",
"$",
"theme",
"]",
"[",
"$",
"scopeIndex",
"]",
"[",
"$",
"filename",
"]",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"publishingStrategy",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"publishingStrategy",
"->",
"find",
"(",
"$",
"filename",
",",
"$",
"scope",
",",
"$",
"this",
"->",
"getTheme",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"url",
"===",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"router",
")",
"{",
"throw",
"new",
"exception",
"\\",
"DependencyException",
"(",
"'Missing router instance to build dynamic resource url'",
")",
";",
"}",
"$",
"routeOptions",
"=",
"array",
"(",
"'name'",
"=>",
"'rampage.core.resources'",
",",
")",
";",
"$",
"routeParams",
"=",
"array",
"(",
"'theme'",
"=>",
"$",
"theme",
",",
"'scope'",
"=>",
"(",
"$",
"scope",
"?",
":",
"'__theme__'",
")",
",",
"'file'",
"=>",
"$",
"filename",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"router",
"->",
"assemble",
"(",
"$",
"routeParams",
",",
"$",
"routeOptions",
")",
";",
"if",
"(",
"$",
"this",
"->",
"baseUrl",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"baseUrl",
"->",
"getUrl",
"(",
"$",
"url",
")",
";",
"}",
"}",
"$",
"this",
"->",
"locations",
"[",
"$",
"theme",
"]",
"[",
"$",
"scopeIndex",
"]",
"[",
"$",
"filename",
"]",
"=",
"$",
"url",
";",
"return",
"$",
"url",
";",
"}"
] |
Resolve relative path
@param string $filename
@param string $scope
@param $theme
|
[
"Resolve",
"relative",
"path"
] |
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
|
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/resources/UrlLocator.php#L148-L186
|
239,744
|
gourmet/common
|
Model/Behavior/ComputableBehavior.php
|
ComputableBehavior._findComputed
|
public function _findComputed(Model $Model, $func, $state, $query, $result = array()) {
if ('after' == $state) {
return $result;
}
$query['fields'] = array(sprintf(
'%s(%s) AS %s'
, strtoupper($this->_methods[strtolower($this->settings[$Model->alias]['method'])])
, $Model->alias . '.' . $this->settings[$Model->alias]['column']
, $this->settings[$Model->alias]['result']
));
return $query;
}
|
php
|
public function _findComputed(Model $Model, $func, $state, $query, $result = array()) {
if ('after' == $state) {
return $result;
}
$query['fields'] = array(sprintf(
'%s(%s) AS %s'
, strtoupper($this->_methods[strtolower($this->settings[$Model->alias]['method'])])
, $Model->alias . '.' . $this->settings[$Model->alias]['column']
, $this->settings[$Model->alias]['result']
));
return $query;
}
|
[
"public",
"function",
"_findComputed",
"(",
"Model",
"$",
"Model",
",",
"$",
"func",
",",
"$",
"state",
",",
"$",
"query",
",",
"$",
"result",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"'after'",
"==",
"$",
"state",
")",
"{",
"return",
"$",
"result",
";",
"}",
"$",
"query",
"[",
"'fields'",
"]",
"=",
"array",
"(",
"sprintf",
"(",
"'%s(%s) AS %s'",
",",
"strtoupper",
"(",
"$",
"this",
"->",
"_methods",
"[",
"strtolower",
"(",
"$",
"this",
"->",
"settings",
"[",
"$",
"Model",
"->",
"alias",
"]",
"[",
"'method'",
"]",
")",
"]",
")",
",",
"$",
"Model",
"->",
"alias",
".",
"'.'",
".",
"$",
"this",
"->",
"settings",
"[",
"$",
"Model",
"->",
"alias",
"]",
"[",
"'column'",
"]",
",",
"$",
"this",
"->",
"settings",
"[",
"$",
"Model",
"->",
"alias",
"]",
"[",
"'result'",
"]",
")",
")",
";",
"return",
"$",
"query",
";",
"}"
] |
Custom find method to compute resultset's computable field.
@param Model $model Model to query.
@param string $func
@param string $state Either "before" or "after"
@param array $query
@param array $result
@return array
|
[
"Custom",
"find",
"method",
"to",
"compute",
"resultset",
"s",
"computable",
"field",
"."
] |
53ad4e919c51606dc81f2c716267d01ee768ade5
|
https://github.com/gourmet/common/blob/53ad4e919c51606dc81f2c716267d01ee768ade5/Model/Behavior/ComputableBehavior.php#L230-L243
|
239,745
|
laravel-commode/bladed
|
src/LaravelCommode/Bladed/BladedServiceProvider.php
|
BladedServiceProvider.launching
|
public function launching()
{
/**
* registering default commands
*/
$this->with([self::PROVIDES_SERVICE], function (IBladedManager $manager) {
$manager->registerCommandNamespace('scope', Scope::class);
\phpQuery::newDocument();
$manager->registerCommandNamespace('form', Form::class);
$manager->registerCommandNamespace('template', Template::class);
});
}
|
php
|
public function launching()
{
/**
* registering default commands
*/
$this->with([self::PROVIDES_SERVICE], function (IBladedManager $manager) {
$manager->registerCommandNamespace('scope', Scope::class);
\phpQuery::newDocument();
$manager->registerCommandNamespace('form', Form::class);
$manager->registerCommandNamespace('template', Template::class);
});
}
|
[
"public",
"function",
"launching",
"(",
")",
"{",
"/**\n * registering default commands\n */",
"$",
"this",
"->",
"with",
"(",
"[",
"self",
"::",
"PROVIDES_SERVICE",
"]",
",",
"function",
"(",
"IBladedManager",
"$",
"manager",
")",
"{",
"$",
"manager",
"->",
"registerCommandNamespace",
"(",
"'scope'",
",",
"Scope",
"::",
"class",
")",
";",
"\\",
"phpQuery",
"::",
"newDocument",
"(",
")",
";",
"$",
"manager",
"->",
"registerCommandNamespace",
"(",
"'form'",
",",
"Form",
"::",
"class",
")",
";",
"$",
"manager",
"->",
"registerCommandNamespace",
"(",
"'template'",
",",
"Template",
"::",
"class",
")",
";",
"}",
")",
";",
"}"
] |
Will be triggered when the app's 'booting' event is triggered
|
[
"Will",
"be",
"triggered",
"when",
"the",
"app",
"s",
"booting",
"event",
"is",
"triggered"
] |
3a81f354ecac3b284fde4dce461c90b1aa367c22
|
https://github.com/laravel-commode/bladed/blob/3a81f354ecac3b284fde4dce461c90b1aa367c22/src/LaravelCommode/Bladed/BladedServiceProvider.php#L47-L58
|
239,746
|
RowlandOti/ooglee-core
|
src/OoGlee/Application/CommandBus/CommandNameInflector.php
|
CommandNameInflector.inflect
|
public function inflect(ICommand $command)
{
$tmpClass = str_replace('Domain', 'Application', get_class($command));
$handlerClass = str_replace('Command', 'Handler', $tmpClass);
return $handlerClass;
}
|
php
|
public function inflect(ICommand $command)
{
$tmpClass = str_replace('Domain', 'Application', get_class($command));
$handlerClass = str_replace('Command', 'Handler', $tmpClass);
return $handlerClass;
}
|
[
"public",
"function",
"inflect",
"(",
"ICommand",
"$",
"command",
")",
"{",
"$",
"tmpClass",
"=",
"str_replace",
"(",
"'Domain'",
",",
"'Application'",
",",
"get_class",
"(",
"$",
"command",
")",
")",
";",
"$",
"handlerClass",
"=",
"str_replace",
"(",
"'Command'",
",",
"'Handler'",
",",
"$",
"tmpClass",
")",
";",
"return",
"$",
"handlerClass",
";",
"}"
] |
Map a Handler Class for corresponding Command
@param Command $command
@return string
|
[
"Map",
"a",
"Handler",
"Class",
"for",
"corresponding",
"Command"
] |
6cd8a8e58e37749e1c58e99063ea72c9d37a98bc
|
https://github.com/RowlandOti/ooglee-core/blob/6cd8a8e58e37749e1c58e99063ea72c9d37a98bc/src/OoGlee/Application/CommandBus/CommandNameInflector.php#L20-L26
|
239,747
|
MINISTRYGmbH/morrow-core
|
src/Input.php
|
Input.tidy
|
public function tidy($value) {
if (is_array($value)) {
$value = array_map([&$this, 'tidy'], $value);
} else {
$value = trim($value);
// unify line breaks
$value = preg_replace("=(\r\n|\r)=", "\n", $value);
// filter nullbyte
$value = str_replace("\0", '', $value);
}
return $value;
}
|
php
|
public function tidy($value) {
if (is_array($value)) {
$value = array_map([&$this, 'tidy'], $value);
} else {
$value = trim($value);
// unify line breaks
$value = preg_replace("=(\r\n|\r)=", "\n", $value);
// filter nullbyte
$value = str_replace("\0", '', $value);
}
return $value;
}
|
[
"public",
"function",
"tidy",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"array_map",
"(",
"[",
"&",
"$",
"this",
",",
"'tidy'",
"]",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"trim",
"(",
"$",
"value",
")",
";",
"// unify line breaks",
"$",
"value",
"=",
"preg_replace",
"(",
"\"=(\\r\\n|\\r)=\"",
",",
"\"\\n\"",
",",
"$",
"value",
")",
";",
"// filter nullbyte",
"$",
"value",
"=",
"str_replace",
"(",
"\"\\0\"",
",",
"''",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Trims a string, unifies line breaks and deletes null bytes.
@param mixed $value An array or scalar to clean up.
@return mixed The cleaned version of the input.
|
[
"Trims",
"a",
"string",
"unifies",
"line",
"breaks",
"and",
"deletes",
"null",
"bytes",
"."
] |
bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e
|
https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Input.php#L89-L100
|
239,748
|
MINISTRYGmbH/morrow-core
|
src/Input.php
|
Input._array_merge_recursive_distinct
|
protected function _array_merge_recursive_distinct ($array) {
$arrays = func_get_args();
$base = array_shift($arrays);
if (!is_array($base)) $base = empty($base) ? [] : [$base];
foreach ($arrays as $append) {
if (!is_array($append)) $append = [$append];
foreach ($append as $key => $value) {
if (!array_key_exists($key, $base)) {
$base[$key] = $append[$key];
continue;
}
if (is_array($value) or is_array($base[$key])) {
$base[$key] = $this->_array_merge_recursive_distinct($base[$key], $append[$key]);
} else {
$base[$key] = $value;
}
}
}
return $base;
}
|
php
|
protected function _array_merge_recursive_distinct ($array) {
$arrays = func_get_args();
$base = array_shift($arrays);
if (!is_array($base)) $base = empty($base) ? [] : [$base];
foreach ($arrays as $append) {
if (!is_array($append)) $append = [$append];
foreach ($append as $key => $value) {
if (!array_key_exists($key, $base)) {
$base[$key] = $append[$key];
continue;
}
if (is_array($value) or is_array($base[$key])) {
$base[$key] = $this->_array_merge_recursive_distinct($base[$key], $append[$key]);
} else {
$base[$key] = $value;
}
}
}
return $base;
}
|
[
"protected",
"function",
"_array_merge_recursive_distinct",
"(",
"$",
"array",
")",
"{",
"$",
"arrays",
"=",
"func_get_args",
"(",
")",
";",
"$",
"base",
"=",
"array_shift",
"(",
"$",
"arrays",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"base",
")",
")",
"$",
"base",
"=",
"empty",
"(",
"$",
"base",
")",
"?",
"[",
"]",
":",
"[",
"$",
"base",
"]",
";",
"foreach",
"(",
"$",
"arrays",
"as",
"$",
"append",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"append",
")",
")",
"$",
"append",
"=",
"[",
"$",
"append",
"]",
";",
"foreach",
"(",
"$",
"append",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"base",
")",
")",
"{",
"$",
"base",
"[",
"$",
"key",
"]",
"=",
"$",
"append",
"[",
"$",
"key",
"]",
";",
"continue",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"or",
"is_array",
"(",
"$",
"base",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"base",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"_array_merge_recursive_distinct",
"(",
"$",
"base",
"[",
"$",
"key",
"]",
",",
"$",
"append",
"[",
"$",
"key",
"]",
")",
";",
"}",
"else",
"{",
"$",
"base",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"}",
"return",
"$",
"base",
";",
"}"
] |
Merges any number of arrays.
array_merge_recursive() does indeed merge arrays, but it converts values with duplicate keys to arrays rather than overwriting the value in the first array with the duplicate value in the second array, as array_merge does.
@param array $array Any number of arrays.
@return array
|
[
"Merges",
"any",
"number",
"of",
"arrays",
"."
] |
bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e
|
https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Input.php#L168-L187
|
239,749
|
delboy1978uk/bone
|
src/Mvc/Router/Route.php
|
Route.checkRoute
|
public function checkRoute($uri)
{
foreach($this->strings as $expression)
{
// check if it matches the pattern
$this->regex->setPattern($expression);
if($this->regex->getMatches($uri))
{
$this->matchedUriParts = explode('/',$uri);
return true;
}
}
return false;
}
|
php
|
public function checkRoute($uri)
{
foreach($this->strings as $expression)
{
// check if it matches the pattern
$this->regex->setPattern($expression);
if($this->regex->getMatches($uri))
{
$this->matchedUriParts = explode('/',$uri);
return true;
}
}
return false;
}
|
[
"public",
"function",
"checkRoute",
"(",
"$",
"uri",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"strings",
"as",
"$",
"expression",
")",
"{",
"// check if it matches the pattern",
"$",
"this",
"->",
"regex",
"->",
"setPattern",
"(",
"$",
"expression",
")",
";",
"if",
"(",
"$",
"this",
"->",
"regex",
"->",
"getMatches",
"(",
"$",
"uri",
")",
")",
"{",
"$",
"this",
"->",
"matchedUriParts",
"=",
"explode",
"(",
"'/'",
",",
"$",
"uri",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
checks t' see if th' uri matches the regex routes
@param $uri
@return bool
|
[
"checks",
"t",
"see",
"if",
"th",
"uri",
"matches",
"the",
"regex",
"routes"
] |
dd6200e9ec9e33234a0cb363e6a4ab60cc3e0268
|
https://github.com/delboy1978uk/bone/blob/dd6200e9ec9e33234a0cb363e6a4ab60cc3e0268/src/Mvc/Router/Route.php#L104-L117
|
239,750
|
delboy1978uk/bone
|
src/Mvc/Router/Route.php
|
Route.setStrings
|
private function setStrings()
{
/*
* Sift through the wreckage
*/
foreach($this->parts as $part)
{
$this->checkPart($part);
}
/*
* if there's still nuthin', we must be on the feckin' home page
*/
$this->strings[0] = ($this->strings[0] == '') ? '\/' : $this->strings[0];
$this->strings[0] = '^' . $this->strings[0] . '$';
}
|
php
|
private function setStrings()
{
/*
* Sift through the wreckage
*/
foreach($this->parts as $part)
{
$this->checkPart($part);
}
/*
* if there's still nuthin', we must be on the feckin' home page
*/
$this->strings[0] = ($this->strings[0] == '') ? '\/' : $this->strings[0];
$this->strings[0] = '^' . $this->strings[0] . '$';
}
|
[
"private",
"function",
"setStrings",
"(",
")",
"{",
"/*\n * Sift through the wreckage\n */",
"foreach",
"(",
"$",
"this",
"->",
"parts",
"as",
"$",
"part",
")",
"{",
"$",
"this",
"->",
"checkPart",
"(",
"$",
"part",
")",
";",
"}",
"/*\n * if there's still nuthin', we must be on the feckin' home page\n */",
"$",
"this",
"->",
"strings",
"[",
"0",
"]",
"=",
"(",
"$",
"this",
"->",
"strings",
"[",
"0",
"]",
"==",
"''",
")",
"?",
"'\\/'",
":",
"$",
"this",
"->",
"strings",
"[",
"0",
"]",
";",
"$",
"this",
"->",
"strings",
"[",
"0",
"]",
"=",
"'^'",
".",
"$",
"this",
"->",
"strings",
"[",
"0",
"]",
".",
"'$'",
";",
"}"
] |
break the url t' smithereens! garrr!
|
[
"break",
"the",
"url",
"t",
"smithereens!",
"garrr!"
] |
dd6200e9ec9e33234a0cb363e6a4ab60cc3e0268
|
https://github.com/delboy1978uk/bone/blob/dd6200e9ec9e33234a0cb363e6a4ab60cc3e0268/src/Mvc/Router/Route.php#L133-L148
|
239,751
|
delboy1978uk/bone
|
src/Mvc/Router/Route.php
|
Route.setOptionalStrings
|
private function setOptionalStrings()
{
/*
* Make another string t' check fer
*/
if($this->optional)
{
$this->strings[1] = $this->strings[0].Url::SLASH_WORD;
//reverse the fecker, if the longer one matches first, good!
$this->strings = array_reverse($this->strings);
}
}
|
php
|
private function setOptionalStrings()
{
/*
* Make another string t' check fer
*/
if($this->optional)
{
$this->strings[1] = $this->strings[0].Url::SLASH_WORD;
//reverse the fecker, if the longer one matches first, good!
$this->strings = array_reverse($this->strings);
}
}
|
[
"private",
"function",
"setOptionalStrings",
"(",
")",
"{",
"/*\n * Make another string t' check fer\n */",
"if",
"(",
"$",
"this",
"->",
"optional",
")",
"{",
"$",
"this",
"->",
"strings",
"[",
"1",
"]",
"=",
"$",
"this",
"->",
"strings",
"[",
"0",
"]",
".",
"Url",
"::",
"SLASH_WORD",
";",
"//reverse the fecker, if the longer one matches first, good!",
"$",
"this",
"->",
"strings",
"=",
"array_reverse",
"(",
"$",
"this",
"->",
"strings",
")",
";",
"}",
"}"
] |
checks fer the optional stuff
|
[
"checks",
"fer",
"the",
"optional",
"stuff"
] |
dd6200e9ec9e33234a0cb363e6a4ab60cc3e0268
|
https://github.com/delboy1978uk/bone/blob/dd6200e9ec9e33234a0cb363e6a4ab60cc3e0268/src/Mvc/Router/Route.php#L177-L188
|
239,752
|
phergie/phergie-irc-plugin-react-eventfilter
|
src/UserFilter.php
|
UserFilter.filter
|
public function filter(EventInterface $event)
{
if (!$event instanceof UserEventInterface) {
return null;
}
$nick = $event->getNick();
if ($nick === null) {
return null;
}
$userMask = sprintf('%s!%s@%s',
$nick,
$event->getUsername(),
$event->getHost()
);
foreach ($this->masks as $mask) {
$pattern = '/^' . str_replace('\*', '.*', preg_quote($mask, '/')) . '$/';
if ($this->caseless) {
$pattern .= "i";
}
if (preg_match($pattern, $userMask)) {
return true;
}
}
return false;
}
|
php
|
public function filter(EventInterface $event)
{
if (!$event instanceof UserEventInterface) {
return null;
}
$nick = $event->getNick();
if ($nick === null) {
return null;
}
$userMask = sprintf('%s!%s@%s',
$nick,
$event->getUsername(),
$event->getHost()
);
foreach ($this->masks as $mask) {
$pattern = '/^' . str_replace('\*', '.*', preg_quote($mask, '/')) . '$/';
if ($this->caseless) {
$pattern .= "i";
}
if (preg_match($pattern, $userMask)) {
return true;
}
}
return false;
}
|
[
"public",
"function",
"filter",
"(",
"EventInterface",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"$",
"event",
"instanceof",
"UserEventInterface",
")",
"{",
"return",
"null",
";",
"}",
"$",
"nick",
"=",
"$",
"event",
"->",
"getNick",
"(",
")",
";",
"if",
"(",
"$",
"nick",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"$",
"userMask",
"=",
"sprintf",
"(",
"'%s!%s@%s'",
",",
"$",
"nick",
",",
"$",
"event",
"->",
"getUsername",
"(",
")",
",",
"$",
"event",
"->",
"getHost",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"masks",
"as",
"$",
"mask",
")",
"{",
"$",
"pattern",
"=",
"'/^'",
".",
"str_replace",
"(",
"'\\*'",
",",
"'.*'",
",",
"preg_quote",
"(",
"$",
"mask",
",",
"'/'",
")",
")",
".",
"'$/'",
";",
"if",
"(",
"$",
"this",
"->",
"caseless",
")",
"{",
"$",
"pattern",
".=",
"\"i\"",
";",
"}",
"if",
"(",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"userMask",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Filters events that are not user-specific or are from the specified users.
@param \Phergie\Irc\Event\EventInterface $event
@return boolean|null TRUE if the event originated from a user with a matching mask
associated with this filter, FALSE if it originated from a user without a
matching mask, or NULL if it did not originate from a user.
|
[
"Filters",
"events",
"that",
"are",
"not",
"user",
"-",
"specific",
"or",
"are",
"from",
"the",
"specified",
"users",
"."
] |
8fdde571a23ab1379d62a48e9de4570845c0e9dd
|
https://github.com/phergie/phergie-irc-plugin-react-eventfilter/blob/8fdde571a23ab1379d62a48e9de4570845c0e9dd/src/UserFilter.php#L62-L92
|
239,753
|
bishopb/vanilla
|
applications/vanilla/controllers/class.settingscontroller.php
|
SettingsController.Advanced
|
public function Advanced() {
// Check permission
$this->Permission('Garden.Settings.Manage');
// Load up config options we'll be setting
$Validation = new Gdn_Validation();
$ConfigurationModel = new Gdn_ConfigurationModel($Validation);
$ConfigurationModel->SetField(array(
'Vanilla.Discussions.PerPage',
'Vanilla.Comments.AutoRefresh',
'Vanilla.Comments.PerPage',
'Garden.Html.AllowedElements',
'Vanilla.Archive.Date',
'Vanilla.Archive.Exclude',
'Garden.EditContentTimeout',
'Vanilla.AdminCheckboxes.Use',
'Vanilla.Discussions.SortField' => 'd.DateLastComment',
'Vanilla.Discussions.UserSortField'
));
// Set the model on the form.
$this->Form->SetModel($ConfigurationModel);
// If seeing the form for the first time...
if ($this->Form->AuthenticatedPostBack() === FALSE) {
// Apply the config settings to the form.
$this->Form->SetData($ConfigurationModel->Data);
} else {
// Define some validation rules for the fields being saved
$ConfigurationModel->Validation->ApplyRule('Vanilla.Discussions.PerPage', 'Required');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Discussions.PerPage', 'Integer');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Comments.AutoRefresh', 'Integer');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Comments.PerPage', 'Required');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Comments.PerPage', 'Integer');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Archive.Date', 'Date');
$ConfigurationModel->Validation->ApplyRule('Garden.EditContentTimeout', 'Integer');
// Grab old config values to check for an update.
$ArchiveDateBak = Gdn::Config('Vanilla.Archive.Date');
$ArchiveExcludeBak = (bool)Gdn::Config('Vanilla.Archive.Exclude');
// Save new settings
$Saved = $this->Form->Save();
if($Saved) {
$ArchiveDate = Gdn::Config('Vanilla.Archive.Date');
$ArchiveExclude = (bool)Gdn::Config('Vanilla.Archive.Exclude');
if($ArchiveExclude != $ArchiveExcludeBak || ($ArchiveExclude && $ArchiveDate != $ArchiveDateBak)) {
$DiscussionModel = new DiscussionModel();
$DiscussionModel->UpdateDiscussionCount('All');
}
$this->InformMessage(T("Your changes have been saved."));
}
}
$this->AddSideMenu('vanilla/settings/advanced');
$this->AddJsFile('settings.js');
$this->Title(T('Advanced Forum Settings'));
// Render default view (settings/advanced.php)
$this->Render();
}
|
php
|
public function Advanced() {
// Check permission
$this->Permission('Garden.Settings.Manage');
// Load up config options we'll be setting
$Validation = new Gdn_Validation();
$ConfigurationModel = new Gdn_ConfigurationModel($Validation);
$ConfigurationModel->SetField(array(
'Vanilla.Discussions.PerPage',
'Vanilla.Comments.AutoRefresh',
'Vanilla.Comments.PerPage',
'Garden.Html.AllowedElements',
'Vanilla.Archive.Date',
'Vanilla.Archive.Exclude',
'Garden.EditContentTimeout',
'Vanilla.AdminCheckboxes.Use',
'Vanilla.Discussions.SortField' => 'd.DateLastComment',
'Vanilla.Discussions.UserSortField'
));
// Set the model on the form.
$this->Form->SetModel($ConfigurationModel);
// If seeing the form for the first time...
if ($this->Form->AuthenticatedPostBack() === FALSE) {
// Apply the config settings to the form.
$this->Form->SetData($ConfigurationModel->Data);
} else {
// Define some validation rules for the fields being saved
$ConfigurationModel->Validation->ApplyRule('Vanilla.Discussions.PerPage', 'Required');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Discussions.PerPage', 'Integer');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Comments.AutoRefresh', 'Integer');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Comments.PerPage', 'Required');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Comments.PerPage', 'Integer');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Archive.Date', 'Date');
$ConfigurationModel->Validation->ApplyRule('Garden.EditContentTimeout', 'Integer');
// Grab old config values to check for an update.
$ArchiveDateBak = Gdn::Config('Vanilla.Archive.Date');
$ArchiveExcludeBak = (bool)Gdn::Config('Vanilla.Archive.Exclude');
// Save new settings
$Saved = $this->Form->Save();
if($Saved) {
$ArchiveDate = Gdn::Config('Vanilla.Archive.Date');
$ArchiveExclude = (bool)Gdn::Config('Vanilla.Archive.Exclude');
if($ArchiveExclude != $ArchiveExcludeBak || ($ArchiveExclude && $ArchiveDate != $ArchiveDateBak)) {
$DiscussionModel = new DiscussionModel();
$DiscussionModel->UpdateDiscussionCount('All');
}
$this->InformMessage(T("Your changes have been saved."));
}
}
$this->AddSideMenu('vanilla/settings/advanced');
$this->AddJsFile('settings.js');
$this->Title(T('Advanced Forum Settings'));
// Render default view (settings/advanced.php)
$this->Render();
}
|
[
"public",
"function",
"Advanced",
"(",
")",
"{",
"// Check permission",
"$",
"this",
"->",
"Permission",
"(",
"'Garden.Settings.Manage'",
")",
";",
"// Load up config options we'll be setting",
"$",
"Validation",
"=",
"new",
"Gdn_Validation",
"(",
")",
";",
"$",
"ConfigurationModel",
"=",
"new",
"Gdn_ConfigurationModel",
"(",
"$",
"Validation",
")",
";",
"$",
"ConfigurationModel",
"->",
"SetField",
"(",
"array",
"(",
"'Vanilla.Discussions.PerPage'",
",",
"'Vanilla.Comments.AutoRefresh'",
",",
"'Vanilla.Comments.PerPage'",
",",
"'Garden.Html.AllowedElements'",
",",
"'Vanilla.Archive.Date'",
",",
"'Vanilla.Archive.Exclude'",
",",
"'Garden.EditContentTimeout'",
",",
"'Vanilla.AdminCheckboxes.Use'",
",",
"'Vanilla.Discussions.SortField'",
"=>",
"'d.DateLastComment'",
",",
"'Vanilla.Discussions.UserSortField'",
")",
")",
";",
"// Set the model on the form.",
"$",
"this",
"->",
"Form",
"->",
"SetModel",
"(",
"$",
"ConfigurationModel",
")",
";",
"// If seeing the form for the first time...",
"if",
"(",
"$",
"this",
"->",
"Form",
"->",
"AuthenticatedPostBack",
"(",
")",
"===",
"FALSE",
")",
"{",
"// Apply the config settings to the form.",
"$",
"this",
"->",
"Form",
"->",
"SetData",
"(",
"$",
"ConfigurationModel",
"->",
"Data",
")",
";",
"}",
"else",
"{",
"// Define some validation rules for the fields being saved",
"$",
"ConfigurationModel",
"->",
"Validation",
"->",
"ApplyRule",
"(",
"'Vanilla.Discussions.PerPage'",
",",
"'Required'",
")",
";",
"$",
"ConfigurationModel",
"->",
"Validation",
"->",
"ApplyRule",
"(",
"'Vanilla.Discussions.PerPage'",
",",
"'Integer'",
")",
";",
"$",
"ConfigurationModel",
"->",
"Validation",
"->",
"ApplyRule",
"(",
"'Vanilla.Comments.AutoRefresh'",
",",
"'Integer'",
")",
";",
"$",
"ConfigurationModel",
"->",
"Validation",
"->",
"ApplyRule",
"(",
"'Vanilla.Comments.PerPage'",
",",
"'Required'",
")",
";",
"$",
"ConfigurationModel",
"->",
"Validation",
"->",
"ApplyRule",
"(",
"'Vanilla.Comments.PerPage'",
",",
"'Integer'",
")",
";",
"$",
"ConfigurationModel",
"->",
"Validation",
"->",
"ApplyRule",
"(",
"'Vanilla.Archive.Date'",
",",
"'Date'",
")",
";",
"$",
"ConfigurationModel",
"->",
"Validation",
"->",
"ApplyRule",
"(",
"'Garden.EditContentTimeout'",
",",
"'Integer'",
")",
";",
"// Grab old config values to check for an update.",
"$",
"ArchiveDateBak",
"=",
"Gdn",
"::",
"Config",
"(",
"'Vanilla.Archive.Date'",
")",
";",
"$",
"ArchiveExcludeBak",
"=",
"(",
"bool",
")",
"Gdn",
"::",
"Config",
"(",
"'Vanilla.Archive.Exclude'",
")",
";",
"// Save new settings",
"$",
"Saved",
"=",
"$",
"this",
"->",
"Form",
"->",
"Save",
"(",
")",
";",
"if",
"(",
"$",
"Saved",
")",
"{",
"$",
"ArchiveDate",
"=",
"Gdn",
"::",
"Config",
"(",
"'Vanilla.Archive.Date'",
")",
";",
"$",
"ArchiveExclude",
"=",
"(",
"bool",
")",
"Gdn",
"::",
"Config",
"(",
"'Vanilla.Archive.Exclude'",
")",
";",
"if",
"(",
"$",
"ArchiveExclude",
"!=",
"$",
"ArchiveExcludeBak",
"||",
"(",
"$",
"ArchiveExclude",
"&&",
"$",
"ArchiveDate",
"!=",
"$",
"ArchiveDateBak",
")",
")",
"{",
"$",
"DiscussionModel",
"=",
"new",
"DiscussionModel",
"(",
")",
";",
"$",
"DiscussionModel",
"->",
"UpdateDiscussionCount",
"(",
"'All'",
")",
";",
"}",
"$",
"this",
"->",
"InformMessage",
"(",
"T",
"(",
"\"Your changes have been saved.\"",
")",
")",
";",
"}",
"}",
"$",
"this",
"->",
"AddSideMenu",
"(",
"'vanilla/settings/advanced'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'settings.js'",
")",
";",
"$",
"this",
"->",
"Title",
"(",
"T",
"(",
"'Advanced Forum Settings'",
")",
")",
";",
"// Render default view (settings/advanced.php)",
"$",
"this",
"->",
"Render",
"(",
")",
";",
"}"
] |
Advanced settings.
Allows setting configuration values via form elements.
@since 2.0.0
@access public
|
[
"Advanced",
"settings",
"."
] |
8494eb4a4ad61603479015a8054d23ff488364e8
|
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/controllers/class.settingscontroller.php#L37-L98
|
239,754
|
bishopb/vanilla
|
applications/vanilla/controllers/class.settingscontroller.php
|
SettingsController.Initialize
|
public function Initialize() {
// Set up head
$this->Head = new HeadModule($this);
$this->AddJsFile('jquery.js');
$this->AddJsFile('jquery.livequery.js');
$this->AddJsFile('jquery.form.js');
$this->AddJsFile('jquery.popup.js');
$this->AddJsFile('jquery.gardenhandleajaxform.js');
$this->AddJsFile('global.js');
if (in_array($this->ControllerName, array('profilecontroller', 'activitycontroller'))) {
$this->AddCssFile('style.css');
} else {
$this->AddCssFile('admin.css');
}
// Change master template
$this->MasterView = 'admin';
parent::Initialize();
Gdn_Theme::Section('Dashboard');
}
|
php
|
public function Initialize() {
// Set up head
$this->Head = new HeadModule($this);
$this->AddJsFile('jquery.js');
$this->AddJsFile('jquery.livequery.js');
$this->AddJsFile('jquery.form.js');
$this->AddJsFile('jquery.popup.js');
$this->AddJsFile('jquery.gardenhandleajaxform.js');
$this->AddJsFile('global.js');
if (in_array($this->ControllerName, array('profilecontroller', 'activitycontroller'))) {
$this->AddCssFile('style.css');
} else {
$this->AddCssFile('admin.css');
}
// Change master template
$this->MasterView = 'admin';
parent::Initialize();
Gdn_Theme::Section('Dashboard');
}
|
[
"public",
"function",
"Initialize",
"(",
")",
"{",
"// Set up head",
"$",
"this",
"->",
"Head",
"=",
"new",
"HeadModule",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'jquery.js'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'jquery.livequery.js'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'jquery.form.js'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'jquery.popup.js'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'jquery.gardenhandleajaxform.js'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'global.js'",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"this",
"->",
"ControllerName",
",",
"array",
"(",
"'profilecontroller'",
",",
"'activitycontroller'",
")",
")",
")",
"{",
"$",
"this",
"->",
"AddCssFile",
"(",
"'style.css'",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"AddCssFile",
"(",
"'admin.css'",
")",
";",
"}",
"// Change master template",
"$",
"this",
"->",
"MasterView",
"=",
"'admin'",
";",
"parent",
"::",
"Initialize",
"(",
")",
";",
"Gdn_Theme",
"::",
"Section",
"(",
"'Dashboard'",
")",
";",
"}"
] |
Switch MasterView. Include JS, CSS used by all methods.
Always called by dispatcher before controller's requested method.
@since 2.0.0
@access public
|
[
"Switch",
"MasterView",
".",
"Include",
"JS",
"CSS",
"used",
"by",
"all",
"methods",
"."
] |
8494eb4a4ad61603479015a8054d23ff488364e8
|
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/controllers/class.settingscontroller.php#L119-L139
|
239,755
|
bishopb/vanilla
|
applications/vanilla/controllers/class.settingscontroller.php
|
SettingsController.AddSideMenu
|
public function AddSideMenu($CurrentUrl) {
// Only add to the assets if this is not a view-only request
if ($this->_DeliveryType == DELIVERY_TYPE_ALL) {
$SideMenu = new SideMenuModule($this);
$SideMenu->HtmlId = '';
$SideMenu->HighlightRoute($CurrentUrl);
$SideMenu->Sort = C('Garden.DashboardMenu.Sort');
$this->EventArguments['SideMenu'] = &$SideMenu;
$this->FireEvent('GetAppSettingsMenuItems');
$this->AddModule($SideMenu, 'Panel');
}
}
|
php
|
public function AddSideMenu($CurrentUrl) {
// Only add to the assets if this is not a view-only request
if ($this->_DeliveryType == DELIVERY_TYPE_ALL) {
$SideMenu = new SideMenuModule($this);
$SideMenu->HtmlId = '';
$SideMenu->HighlightRoute($CurrentUrl);
$SideMenu->Sort = C('Garden.DashboardMenu.Sort');
$this->EventArguments['SideMenu'] = &$SideMenu;
$this->FireEvent('GetAppSettingsMenuItems');
$this->AddModule($SideMenu, 'Panel');
}
}
|
[
"public",
"function",
"AddSideMenu",
"(",
"$",
"CurrentUrl",
")",
"{",
"// Only add to the assets if this is not a view-only request",
"if",
"(",
"$",
"this",
"->",
"_DeliveryType",
"==",
"DELIVERY_TYPE_ALL",
")",
"{",
"$",
"SideMenu",
"=",
"new",
"SideMenuModule",
"(",
"$",
"this",
")",
";",
"$",
"SideMenu",
"->",
"HtmlId",
"=",
"''",
";",
"$",
"SideMenu",
"->",
"HighlightRoute",
"(",
"$",
"CurrentUrl",
")",
";",
"$",
"SideMenu",
"->",
"Sort",
"=",
"C",
"(",
"'Garden.DashboardMenu.Sort'",
")",
";",
"$",
"this",
"->",
"EventArguments",
"[",
"'SideMenu'",
"]",
"=",
"&",
"$",
"SideMenu",
";",
"$",
"this",
"->",
"FireEvent",
"(",
"'GetAppSettingsMenuItems'",
")",
";",
"$",
"this",
"->",
"AddModule",
"(",
"$",
"SideMenu",
",",
"'Panel'",
")",
";",
"}",
"}"
] |
Configures navigation sidebar in Dashboard.
@since 2.0.0
@access public
@param $CurrentUrl Path to current location in dashboard.
|
[
"Configures",
"navigation",
"sidebar",
"in",
"Dashboard",
"."
] |
8494eb4a4ad61603479015a8054d23ff488364e8
|
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/controllers/class.settingscontroller.php#L149-L160
|
239,756
|
bishopb/vanilla
|
applications/vanilla/controllers/class.settingscontroller.php
|
SettingsController.FloodControl
|
public function FloodControl() {
// Check permission
$this->Permission('Garden.Settings.Manage');
// Display options
$this->Title(T('Flood Control'));
$this->AddSideMenu('vanilla/settings/floodcontrol');
// Load up config options we'll be setting
$Validation = new Gdn_Validation();
$ConfigurationModel = new Gdn_ConfigurationModel($Validation);
$ConfigurationModel->SetField(array(
'Vanilla.Discussion.SpamCount',
'Vanilla.Discussion.SpamTime',
'Vanilla.Discussion.SpamLock',
'Vanilla.Comment.SpamCount',
'Vanilla.Comment.SpamTime',
'Vanilla.Comment.SpamLock',
'Vanilla.Comment.MaxLength',
'Vanilla.Comment.MinLength'
));
// Set the model on the form.
$this->Form->SetModel($ConfigurationModel);
// If seeing the form for the first time...
if ($this->Form->AuthenticatedPostBack() === FALSE) {
// Apply the config settings to the form.
$this->Form->SetData($ConfigurationModel->Data);
} else {
// Define some validation rules for the fields being saved
$ConfigurationModel->Validation->ApplyRule('Vanilla.Discussion.SpamCount', 'Required');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Discussion.SpamCount', 'Integer');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Discussion.SpamTime', 'Required');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Discussion.SpamTime', 'Integer');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Discussion.SpamLock', 'Required');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Discussion.SpamLock', 'Integer');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Comment.SpamCount', 'Required');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Comment.SpamCount', 'Integer');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Comment.SpamTime', 'Required');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Comment.SpamTime', 'Integer');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Comment.SpamLock', 'Required');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Comment.SpamLock', 'Integer');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Comment.MaxLength', 'Required');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Comment.MaxLength', 'Integer');
if ($this->Form->Save() !== FALSE) {
$this->InformMessage(T("Your changes have been saved."));
}
}
// Render default view
$this->Render();
}
|
php
|
public function FloodControl() {
// Check permission
$this->Permission('Garden.Settings.Manage');
// Display options
$this->Title(T('Flood Control'));
$this->AddSideMenu('vanilla/settings/floodcontrol');
// Load up config options we'll be setting
$Validation = new Gdn_Validation();
$ConfigurationModel = new Gdn_ConfigurationModel($Validation);
$ConfigurationModel->SetField(array(
'Vanilla.Discussion.SpamCount',
'Vanilla.Discussion.SpamTime',
'Vanilla.Discussion.SpamLock',
'Vanilla.Comment.SpamCount',
'Vanilla.Comment.SpamTime',
'Vanilla.Comment.SpamLock',
'Vanilla.Comment.MaxLength',
'Vanilla.Comment.MinLength'
));
// Set the model on the form.
$this->Form->SetModel($ConfigurationModel);
// If seeing the form for the first time...
if ($this->Form->AuthenticatedPostBack() === FALSE) {
// Apply the config settings to the form.
$this->Form->SetData($ConfigurationModel->Data);
} else {
// Define some validation rules for the fields being saved
$ConfigurationModel->Validation->ApplyRule('Vanilla.Discussion.SpamCount', 'Required');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Discussion.SpamCount', 'Integer');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Discussion.SpamTime', 'Required');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Discussion.SpamTime', 'Integer');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Discussion.SpamLock', 'Required');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Discussion.SpamLock', 'Integer');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Comment.SpamCount', 'Required');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Comment.SpamCount', 'Integer');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Comment.SpamTime', 'Required');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Comment.SpamTime', 'Integer');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Comment.SpamLock', 'Required');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Comment.SpamLock', 'Integer');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Comment.MaxLength', 'Required');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Comment.MaxLength', 'Integer');
if ($this->Form->Save() !== FALSE) {
$this->InformMessage(T("Your changes have been saved."));
}
}
// Render default view
$this->Render();
}
|
[
"public",
"function",
"FloodControl",
"(",
")",
"{",
"// Check permission",
"$",
"this",
"->",
"Permission",
"(",
"'Garden.Settings.Manage'",
")",
";",
"// Display options",
"$",
"this",
"->",
"Title",
"(",
"T",
"(",
"'Flood Control'",
")",
")",
";",
"$",
"this",
"->",
"AddSideMenu",
"(",
"'vanilla/settings/floodcontrol'",
")",
";",
"// Load up config options we'll be setting",
"$",
"Validation",
"=",
"new",
"Gdn_Validation",
"(",
")",
";",
"$",
"ConfigurationModel",
"=",
"new",
"Gdn_ConfigurationModel",
"(",
"$",
"Validation",
")",
";",
"$",
"ConfigurationModel",
"->",
"SetField",
"(",
"array",
"(",
"'Vanilla.Discussion.SpamCount'",
",",
"'Vanilla.Discussion.SpamTime'",
",",
"'Vanilla.Discussion.SpamLock'",
",",
"'Vanilla.Comment.SpamCount'",
",",
"'Vanilla.Comment.SpamTime'",
",",
"'Vanilla.Comment.SpamLock'",
",",
"'Vanilla.Comment.MaxLength'",
",",
"'Vanilla.Comment.MinLength'",
")",
")",
";",
"// Set the model on the form.",
"$",
"this",
"->",
"Form",
"->",
"SetModel",
"(",
"$",
"ConfigurationModel",
")",
";",
"// If seeing the form for the first time...",
"if",
"(",
"$",
"this",
"->",
"Form",
"->",
"AuthenticatedPostBack",
"(",
")",
"===",
"FALSE",
")",
"{",
"// Apply the config settings to the form.",
"$",
"this",
"->",
"Form",
"->",
"SetData",
"(",
"$",
"ConfigurationModel",
"->",
"Data",
")",
";",
"}",
"else",
"{",
"// Define some validation rules for the fields being saved",
"$",
"ConfigurationModel",
"->",
"Validation",
"->",
"ApplyRule",
"(",
"'Vanilla.Discussion.SpamCount'",
",",
"'Required'",
")",
";",
"$",
"ConfigurationModel",
"->",
"Validation",
"->",
"ApplyRule",
"(",
"'Vanilla.Discussion.SpamCount'",
",",
"'Integer'",
")",
";",
"$",
"ConfigurationModel",
"->",
"Validation",
"->",
"ApplyRule",
"(",
"'Vanilla.Discussion.SpamTime'",
",",
"'Required'",
")",
";",
"$",
"ConfigurationModel",
"->",
"Validation",
"->",
"ApplyRule",
"(",
"'Vanilla.Discussion.SpamTime'",
",",
"'Integer'",
")",
";",
"$",
"ConfigurationModel",
"->",
"Validation",
"->",
"ApplyRule",
"(",
"'Vanilla.Discussion.SpamLock'",
",",
"'Required'",
")",
";",
"$",
"ConfigurationModel",
"->",
"Validation",
"->",
"ApplyRule",
"(",
"'Vanilla.Discussion.SpamLock'",
",",
"'Integer'",
")",
";",
"$",
"ConfigurationModel",
"->",
"Validation",
"->",
"ApplyRule",
"(",
"'Vanilla.Comment.SpamCount'",
",",
"'Required'",
")",
";",
"$",
"ConfigurationModel",
"->",
"Validation",
"->",
"ApplyRule",
"(",
"'Vanilla.Comment.SpamCount'",
",",
"'Integer'",
")",
";",
"$",
"ConfigurationModel",
"->",
"Validation",
"->",
"ApplyRule",
"(",
"'Vanilla.Comment.SpamTime'",
",",
"'Required'",
")",
";",
"$",
"ConfigurationModel",
"->",
"Validation",
"->",
"ApplyRule",
"(",
"'Vanilla.Comment.SpamTime'",
",",
"'Integer'",
")",
";",
"$",
"ConfigurationModel",
"->",
"Validation",
"->",
"ApplyRule",
"(",
"'Vanilla.Comment.SpamLock'",
",",
"'Required'",
")",
";",
"$",
"ConfigurationModel",
"->",
"Validation",
"->",
"ApplyRule",
"(",
"'Vanilla.Comment.SpamLock'",
",",
"'Integer'",
")",
";",
"$",
"ConfigurationModel",
"->",
"Validation",
"->",
"ApplyRule",
"(",
"'Vanilla.Comment.MaxLength'",
",",
"'Required'",
")",
";",
"$",
"ConfigurationModel",
"->",
"Validation",
"->",
"ApplyRule",
"(",
"'Vanilla.Comment.MaxLength'",
",",
"'Integer'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"Form",
"->",
"Save",
"(",
")",
"!==",
"FALSE",
")",
"{",
"$",
"this",
"->",
"InformMessage",
"(",
"T",
"(",
"\"Your changes have been saved.\"",
")",
")",
";",
"}",
"}",
"// Render default view",
"$",
"this",
"->",
"Render",
"(",
")",
";",
"}"
] |
Display flood control options.
@since 2.0.0
@access public
|
[
"Display",
"flood",
"control",
"options",
"."
] |
8494eb4a4ad61603479015a8054d23ff488364e8
|
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/controllers/class.settingscontroller.php#L168-L221
|
239,757
|
bishopb/vanilla
|
applications/vanilla/controllers/class.settingscontroller.php
|
SettingsController.AddCategory
|
public function AddCategory() {
// Check permission
$this->Permission('Garden.Settings.Manage');
// Set up head
$this->AddJsFile('jquery.alphanumeric.js');
$this->AddJsFile('categories.js');
$this->AddJsFile('jquery.gardencheckboxgrid.js');
$this->Title(T('Add Category'));
$this->AddSideMenu('vanilla/settings/managecategories');
// Prep models
$RoleModel = new RoleModel();
$PermissionModel = Gdn::PermissionModel();
$this->Form->SetModel($this->CategoryModel);
// Load all roles with editable permissions.
$this->RoleArray = $RoleModel->GetArray();
$this->FireEvent('AddEditCategory');
if ($this->Form->IsPostBack() == FALSE) {
$this->Form->AddHidden('CodeIsDefined', '0');
} else {
// Form was validly submitted
$IsParent = $this->Form->GetFormValue('IsParent', '0');
$this->Form->SetFormValue('AllowDiscussions', $IsParent == '1' ? '0' : '1');
$this->Form->SetFormValue('CustomPoints', (bool)$this->Form->GetFormValue('CustomPoints'));
$CategoryID = $this->Form->Save();
if ($CategoryID) {
$Category = CategoryModel::Categories($CategoryID);
$this->SetData('Category', $Category);
if ($this->DeliveryType() == DELIVERY_TYPE_ALL)
Redirect('vanilla/settings/managecategories');
} else {
unset($CategoryID);
}
}
// Get all of the currently selected role/permission combinations for this junction.
$Permissions = $PermissionModel->GetJunctionPermissions(array('JunctionID' => isset($CategoryID) ? $CategoryID : 0), 'Category');
$Permissions = $PermissionModel->UnpivotPermissions($Permissions, TRUE);
if ($this->DeliveryType() == DELIVERY_TYPE_ALL) {
$this->SetData('PermissionData', $Permissions, TRUE);
}
// Render default view
$this->Render();
}
|
php
|
public function AddCategory() {
// Check permission
$this->Permission('Garden.Settings.Manage');
// Set up head
$this->AddJsFile('jquery.alphanumeric.js');
$this->AddJsFile('categories.js');
$this->AddJsFile('jquery.gardencheckboxgrid.js');
$this->Title(T('Add Category'));
$this->AddSideMenu('vanilla/settings/managecategories');
// Prep models
$RoleModel = new RoleModel();
$PermissionModel = Gdn::PermissionModel();
$this->Form->SetModel($this->CategoryModel);
// Load all roles with editable permissions.
$this->RoleArray = $RoleModel->GetArray();
$this->FireEvent('AddEditCategory');
if ($this->Form->IsPostBack() == FALSE) {
$this->Form->AddHidden('CodeIsDefined', '0');
} else {
// Form was validly submitted
$IsParent = $this->Form->GetFormValue('IsParent', '0');
$this->Form->SetFormValue('AllowDiscussions', $IsParent == '1' ? '0' : '1');
$this->Form->SetFormValue('CustomPoints', (bool)$this->Form->GetFormValue('CustomPoints'));
$CategoryID = $this->Form->Save();
if ($CategoryID) {
$Category = CategoryModel::Categories($CategoryID);
$this->SetData('Category', $Category);
if ($this->DeliveryType() == DELIVERY_TYPE_ALL)
Redirect('vanilla/settings/managecategories');
} else {
unset($CategoryID);
}
}
// Get all of the currently selected role/permission combinations for this junction.
$Permissions = $PermissionModel->GetJunctionPermissions(array('JunctionID' => isset($CategoryID) ? $CategoryID : 0), 'Category');
$Permissions = $PermissionModel->UnpivotPermissions($Permissions, TRUE);
if ($this->DeliveryType() == DELIVERY_TYPE_ALL) {
$this->SetData('PermissionData', $Permissions, TRUE);
}
// Render default view
$this->Render();
}
|
[
"public",
"function",
"AddCategory",
"(",
")",
"{",
"// Check permission",
"$",
"this",
"->",
"Permission",
"(",
"'Garden.Settings.Manage'",
")",
";",
"// Set up head",
"$",
"this",
"->",
"AddJsFile",
"(",
"'jquery.alphanumeric.js'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'categories.js'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'jquery.gardencheckboxgrid.js'",
")",
";",
"$",
"this",
"->",
"Title",
"(",
"T",
"(",
"'Add Category'",
")",
")",
";",
"$",
"this",
"->",
"AddSideMenu",
"(",
"'vanilla/settings/managecategories'",
")",
";",
"// Prep models",
"$",
"RoleModel",
"=",
"new",
"RoleModel",
"(",
")",
";",
"$",
"PermissionModel",
"=",
"Gdn",
"::",
"PermissionModel",
"(",
")",
";",
"$",
"this",
"->",
"Form",
"->",
"SetModel",
"(",
"$",
"this",
"->",
"CategoryModel",
")",
";",
"// Load all roles with editable permissions.",
"$",
"this",
"->",
"RoleArray",
"=",
"$",
"RoleModel",
"->",
"GetArray",
"(",
")",
";",
"$",
"this",
"->",
"FireEvent",
"(",
"'AddEditCategory'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"Form",
"->",
"IsPostBack",
"(",
")",
"==",
"FALSE",
")",
"{",
"$",
"this",
"->",
"Form",
"->",
"AddHidden",
"(",
"'CodeIsDefined'",
",",
"'0'",
")",
";",
"}",
"else",
"{",
"// Form was validly submitted",
"$",
"IsParent",
"=",
"$",
"this",
"->",
"Form",
"->",
"GetFormValue",
"(",
"'IsParent'",
",",
"'0'",
")",
";",
"$",
"this",
"->",
"Form",
"->",
"SetFormValue",
"(",
"'AllowDiscussions'",
",",
"$",
"IsParent",
"==",
"'1'",
"?",
"'0'",
":",
"'1'",
")",
";",
"$",
"this",
"->",
"Form",
"->",
"SetFormValue",
"(",
"'CustomPoints'",
",",
"(",
"bool",
")",
"$",
"this",
"->",
"Form",
"->",
"GetFormValue",
"(",
"'CustomPoints'",
")",
")",
";",
"$",
"CategoryID",
"=",
"$",
"this",
"->",
"Form",
"->",
"Save",
"(",
")",
";",
"if",
"(",
"$",
"CategoryID",
")",
"{",
"$",
"Category",
"=",
"CategoryModel",
"::",
"Categories",
"(",
"$",
"CategoryID",
")",
";",
"$",
"this",
"->",
"SetData",
"(",
"'Category'",
",",
"$",
"Category",
")",
";",
"if",
"(",
"$",
"this",
"->",
"DeliveryType",
"(",
")",
"==",
"DELIVERY_TYPE_ALL",
")",
"Redirect",
"(",
"'vanilla/settings/managecategories'",
")",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"CategoryID",
")",
";",
"}",
"}",
"// Get all of the currently selected role/permission combinations for this junction.",
"$",
"Permissions",
"=",
"$",
"PermissionModel",
"->",
"GetJunctionPermissions",
"(",
"array",
"(",
"'JunctionID'",
"=>",
"isset",
"(",
"$",
"CategoryID",
")",
"?",
"$",
"CategoryID",
":",
"0",
")",
",",
"'Category'",
")",
";",
"$",
"Permissions",
"=",
"$",
"PermissionModel",
"->",
"UnpivotPermissions",
"(",
"$",
"Permissions",
",",
"TRUE",
")",
";",
"if",
"(",
"$",
"this",
"->",
"DeliveryType",
"(",
")",
"==",
"DELIVERY_TYPE_ALL",
")",
"{",
"$",
"this",
"->",
"SetData",
"(",
"'PermissionData'",
",",
"$",
"Permissions",
",",
"TRUE",
")",
";",
"}",
"// Render default view",
"$",
"this",
"->",
"Render",
"(",
")",
";",
"}"
] |
Adding a new category.
@since 2.0.0
@access public
|
[
"Adding",
"a",
"new",
"category",
"."
] |
8494eb4a4ad61603479015a8054d23ff488364e8
|
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/controllers/class.settingscontroller.php#L229-L278
|
239,758
|
bishopb/vanilla
|
applications/vanilla/controllers/class.settingscontroller.php
|
SettingsController.DeleteCategory
|
public function DeleteCategory($CategoryID = FALSE) {
// Check permission
$this->Permission('Garden.Settings.Manage');
// Set up head
$this->AddJsFile('categories.js');
$this->Title(T('Delete Category'));
$this->AddSideMenu('vanilla/settings/managecategories');
// Get category data
$this->Category = $this->CategoryModel->GetID($CategoryID);
if (!$this->Category) {
$this->Form->AddError('The specified category could not be found.');
} else {
// Make sure the form knows which item we are deleting.
$this->Form->AddHidden('CategoryID', $CategoryID);
// Get a list of categories other than this one that can act as a replacement
$this->OtherCategories = $this->CategoryModel->GetWhere(
array(
'CategoryID <>' => $CategoryID,
'AllowDiscussions' => $this->Category->AllowDiscussions, // Don't allow a category with discussion to be the replacement for one without discussions (or vice versa)
'CategoryID >' => 0
),
'Sort'
);
if (!$this->Form->AuthenticatedPostBack()) {
$this->Form->SetFormValue('DeleteDiscussions', '1'); // Checked by default
} else {
$ReplacementCategoryID = $this->Form->GetValue('ReplacementCategoryID');
$ReplacementCategory = $this->CategoryModel->GetID($ReplacementCategoryID);
// Error if:
// 1. The category being deleted is the last remaining category that
// allows discussions.
if ($this->Category->AllowDiscussions == '1'
&& $this->OtherCategories->NumRows() == 0)
$this->Form->AddError('You cannot remove the only remaining category that allows discussions');
/*
// 2. The category being deleted allows discussions, and it contains
// discussions, and there is no replacement category specified.
if ($this->Form->ErrorCount() == 0
&& $this->Category->AllowDiscussions == '1'
&& $this->Category->CountDiscussions > 0
&& ($ReplacementCategory == FALSE || $ReplacementCategory->AllowDiscussions != '1'))
$this->Form->AddError('You must select a replacement category in order to remove this category.');
*/
// 3. The category being deleted does not allow discussions, and it
// does contain other categories, and there are replacement parent
// categories available, and one is not selected.
/*
if ($this->Category->AllowDiscussions == '0'
&& $this->OtherCategories->NumRows() > 0
&& !$ReplacementCategory) {
if ($this->CategoryModel->GetWhere(array('ParentCategoryID' => $CategoryID))->NumRows() > 0)
$this->Form->AddError('You must select a replacement category in order to remove this category.');
}
*/
if ($this->Form->ErrorCount() == 0) {
// Go ahead and delete the category
try {
$this->CategoryModel->Delete($this->Category, $this->Form->GetValue('ReplacementCategoryID'));
} catch (Exception $ex) {
$this->Form->AddError($ex);
}
if ($this->Form->ErrorCount() == 0) {
$this->RedirectUrl = Url('vanilla/settings/managecategories');
$this->InformMessage(T('Deleting category...'));
}
}
}
}
// Render default view
$this->Render();
}
|
php
|
public function DeleteCategory($CategoryID = FALSE) {
// Check permission
$this->Permission('Garden.Settings.Manage');
// Set up head
$this->AddJsFile('categories.js');
$this->Title(T('Delete Category'));
$this->AddSideMenu('vanilla/settings/managecategories');
// Get category data
$this->Category = $this->CategoryModel->GetID($CategoryID);
if (!$this->Category) {
$this->Form->AddError('The specified category could not be found.');
} else {
// Make sure the form knows which item we are deleting.
$this->Form->AddHidden('CategoryID', $CategoryID);
// Get a list of categories other than this one that can act as a replacement
$this->OtherCategories = $this->CategoryModel->GetWhere(
array(
'CategoryID <>' => $CategoryID,
'AllowDiscussions' => $this->Category->AllowDiscussions, // Don't allow a category with discussion to be the replacement for one without discussions (or vice versa)
'CategoryID >' => 0
),
'Sort'
);
if (!$this->Form->AuthenticatedPostBack()) {
$this->Form->SetFormValue('DeleteDiscussions', '1'); // Checked by default
} else {
$ReplacementCategoryID = $this->Form->GetValue('ReplacementCategoryID');
$ReplacementCategory = $this->CategoryModel->GetID($ReplacementCategoryID);
// Error if:
// 1. The category being deleted is the last remaining category that
// allows discussions.
if ($this->Category->AllowDiscussions == '1'
&& $this->OtherCategories->NumRows() == 0)
$this->Form->AddError('You cannot remove the only remaining category that allows discussions');
/*
// 2. The category being deleted allows discussions, and it contains
// discussions, and there is no replacement category specified.
if ($this->Form->ErrorCount() == 0
&& $this->Category->AllowDiscussions == '1'
&& $this->Category->CountDiscussions > 0
&& ($ReplacementCategory == FALSE || $ReplacementCategory->AllowDiscussions != '1'))
$this->Form->AddError('You must select a replacement category in order to remove this category.');
*/
// 3. The category being deleted does not allow discussions, and it
// does contain other categories, and there are replacement parent
// categories available, and one is not selected.
/*
if ($this->Category->AllowDiscussions == '0'
&& $this->OtherCategories->NumRows() > 0
&& !$ReplacementCategory) {
if ($this->CategoryModel->GetWhere(array('ParentCategoryID' => $CategoryID))->NumRows() > 0)
$this->Form->AddError('You must select a replacement category in order to remove this category.');
}
*/
if ($this->Form->ErrorCount() == 0) {
// Go ahead and delete the category
try {
$this->CategoryModel->Delete($this->Category, $this->Form->GetValue('ReplacementCategoryID'));
} catch (Exception $ex) {
$this->Form->AddError($ex);
}
if ($this->Form->ErrorCount() == 0) {
$this->RedirectUrl = Url('vanilla/settings/managecategories');
$this->InformMessage(T('Deleting category...'));
}
}
}
}
// Render default view
$this->Render();
}
|
[
"public",
"function",
"DeleteCategory",
"(",
"$",
"CategoryID",
"=",
"FALSE",
")",
"{",
"// Check permission",
"$",
"this",
"->",
"Permission",
"(",
"'Garden.Settings.Manage'",
")",
";",
"// Set up head",
"$",
"this",
"->",
"AddJsFile",
"(",
"'categories.js'",
")",
";",
"$",
"this",
"->",
"Title",
"(",
"T",
"(",
"'Delete Category'",
")",
")",
";",
"$",
"this",
"->",
"AddSideMenu",
"(",
"'vanilla/settings/managecategories'",
")",
";",
"// Get category data",
"$",
"this",
"->",
"Category",
"=",
"$",
"this",
"->",
"CategoryModel",
"->",
"GetID",
"(",
"$",
"CategoryID",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"Category",
")",
"{",
"$",
"this",
"->",
"Form",
"->",
"AddError",
"(",
"'The specified category could not be found.'",
")",
";",
"}",
"else",
"{",
"// Make sure the form knows which item we are deleting.",
"$",
"this",
"->",
"Form",
"->",
"AddHidden",
"(",
"'CategoryID'",
",",
"$",
"CategoryID",
")",
";",
"// Get a list of categories other than this one that can act as a replacement",
"$",
"this",
"->",
"OtherCategories",
"=",
"$",
"this",
"->",
"CategoryModel",
"->",
"GetWhere",
"(",
"array",
"(",
"'CategoryID <>'",
"=>",
"$",
"CategoryID",
",",
"'AllowDiscussions'",
"=>",
"$",
"this",
"->",
"Category",
"->",
"AllowDiscussions",
",",
"// Don't allow a category with discussion to be the replacement for one without discussions (or vice versa)",
"'CategoryID >'",
"=>",
"0",
")",
",",
"'Sort'",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"Form",
"->",
"AuthenticatedPostBack",
"(",
")",
")",
"{",
"$",
"this",
"->",
"Form",
"->",
"SetFormValue",
"(",
"'DeleteDiscussions'",
",",
"'1'",
")",
";",
"// Checked by default",
"}",
"else",
"{",
"$",
"ReplacementCategoryID",
"=",
"$",
"this",
"->",
"Form",
"->",
"GetValue",
"(",
"'ReplacementCategoryID'",
")",
";",
"$",
"ReplacementCategory",
"=",
"$",
"this",
"->",
"CategoryModel",
"->",
"GetID",
"(",
"$",
"ReplacementCategoryID",
")",
";",
"// Error if:",
"// 1. The category being deleted is the last remaining category that",
"// allows discussions.",
"if",
"(",
"$",
"this",
"->",
"Category",
"->",
"AllowDiscussions",
"==",
"'1'",
"&&",
"$",
"this",
"->",
"OtherCategories",
"->",
"NumRows",
"(",
")",
"==",
"0",
")",
"$",
"this",
"->",
"Form",
"->",
"AddError",
"(",
"'You cannot remove the only remaining category that allows discussions'",
")",
";",
"/*\n // 2. The category being deleted allows discussions, and it contains\n // discussions, and there is no replacement category specified.\n if ($this->Form->ErrorCount() == 0\n && $this->Category->AllowDiscussions == '1'\n && $this->Category->CountDiscussions > 0\n && ($ReplacementCategory == FALSE || $ReplacementCategory->AllowDiscussions != '1'))\n $this->Form->AddError('You must select a replacement category in order to remove this category.');\n */",
"// 3. The category being deleted does not allow discussions, and it",
"// does contain other categories, and there are replacement parent",
"// categories available, and one is not selected.",
"/*\n if ($this->Category->AllowDiscussions == '0'\n && $this->OtherCategories->NumRows() > 0\n && !$ReplacementCategory) {\n if ($this->CategoryModel->GetWhere(array('ParentCategoryID' => $CategoryID))->NumRows() > 0)\n $this->Form->AddError('You must select a replacement category in order to remove this category.');\n }\n */",
"if",
"(",
"$",
"this",
"->",
"Form",
"->",
"ErrorCount",
"(",
")",
"==",
"0",
")",
"{",
"// Go ahead and delete the category",
"try",
"{",
"$",
"this",
"->",
"CategoryModel",
"->",
"Delete",
"(",
"$",
"this",
"->",
"Category",
",",
"$",
"this",
"->",
"Form",
"->",
"GetValue",
"(",
"'ReplacementCategoryID'",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"$",
"this",
"->",
"Form",
"->",
"AddError",
"(",
"$",
"ex",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"Form",
"->",
"ErrorCount",
"(",
")",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"RedirectUrl",
"=",
"Url",
"(",
"'vanilla/settings/managecategories'",
")",
";",
"$",
"this",
"->",
"InformMessage",
"(",
"T",
"(",
"'Deleting category...'",
")",
")",
";",
"}",
"}",
"}",
"}",
"// Render default view",
"$",
"this",
"->",
"Render",
"(",
")",
";",
"}"
] |
Deleting a category.
@since 2.0.0
@access public
@param int $CategoryID Unique ID of the category to be deleted.
|
[
"Deleting",
"a",
"category",
"."
] |
8494eb4a4ad61603479015a8054d23ff488364e8
|
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/controllers/class.settingscontroller.php#L288-L368
|
239,759
|
bishopb/vanilla
|
applications/vanilla/controllers/class.settingscontroller.php
|
SettingsController.DeleteCategoryPhoto
|
public function DeleteCategoryPhoto($CategoryID = FALSE, $TransientKey = '') {
// Check permission
$this->Permission('Garden.Settings.Manage');
$RedirectUrl = 'vanilla/settings/editcategory/'.$CategoryID;
if (Gdn::Session()->ValidateTransientKey($TransientKey)) {
// Do removal, set message, redirect
$CategoryModel = new CategoryModel();
$CategoryModel->SetField($CategoryID, 'Photo', NULL);
$this->InformMessage(T('Category photo has been deleted.'));
}
if ($this->_DeliveryType == DELIVERY_TYPE_ALL) {
Redirect($RedirectUrl);
} else {
$this->ControllerName = 'Home';
$this->View = 'FileNotFound';
$this->RedirectUrl = Url($RedirectUrl);
$this->Render();
}
}
|
php
|
public function DeleteCategoryPhoto($CategoryID = FALSE, $TransientKey = '') {
// Check permission
$this->Permission('Garden.Settings.Manage');
$RedirectUrl = 'vanilla/settings/editcategory/'.$CategoryID;
if (Gdn::Session()->ValidateTransientKey($TransientKey)) {
// Do removal, set message, redirect
$CategoryModel = new CategoryModel();
$CategoryModel->SetField($CategoryID, 'Photo', NULL);
$this->InformMessage(T('Category photo has been deleted.'));
}
if ($this->_DeliveryType == DELIVERY_TYPE_ALL) {
Redirect($RedirectUrl);
} else {
$this->ControllerName = 'Home';
$this->View = 'FileNotFound';
$this->RedirectUrl = Url($RedirectUrl);
$this->Render();
}
}
|
[
"public",
"function",
"DeleteCategoryPhoto",
"(",
"$",
"CategoryID",
"=",
"FALSE",
",",
"$",
"TransientKey",
"=",
"''",
")",
"{",
"// Check permission",
"$",
"this",
"->",
"Permission",
"(",
"'Garden.Settings.Manage'",
")",
";",
"$",
"RedirectUrl",
"=",
"'vanilla/settings/editcategory/'",
".",
"$",
"CategoryID",
";",
"if",
"(",
"Gdn",
"::",
"Session",
"(",
")",
"->",
"ValidateTransientKey",
"(",
"$",
"TransientKey",
")",
")",
"{",
"// Do removal, set message, redirect",
"$",
"CategoryModel",
"=",
"new",
"CategoryModel",
"(",
")",
";",
"$",
"CategoryModel",
"->",
"SetField",
"(",
"$",
"CategoryID",
",",
"'Photo'",
",",
"NULL",
")",
";",
"$",
"this",
"->",
"InformMessage",
"(",
"T",
"(",
"'Category photo has been deleted.'",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"_DeliveryType",
"==",
"DELIVERY_TYPE_ALL",
")",
"{",
"Redirect",
"(",
"$",
"RedirectUrl",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"ControllerName",
"=",
"'Home'",
";",
"$",
"this",
"->",
"View",
"=",
"'FileNotFound'",
";",
"$",
"this",
"->",
"RedirectUrl",
"=",
"Url",
"(",
"$",
"RedirectUrl",
")",
";",
"$",
"this",
"->",
"Render",
"(",
")",
";",
"}",
"}"
] |
Deleting a category photo.
@since 2.1
@access public
@param int $CategoryID Unique ID of the category to have its photo deleted.
|
[
"Deleting",
"a",
"category",
"photo",
"."
] |
8494eb4a4ad61603479015a8054d23ff488364e8
|
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/controllers/class.settingscontroller.php#L378-L398
|
239,760
|
bishopb/vanilla
|
applications/vanilla/controllers/class.settingscontroller.php
|
SettingsController.EditCategory
|
public function EditCategory($CategoryID = '') {
// Check permission
$this->Permission('Garden.Settings.Manage');
// Set up models
$RoleModel = new RoleModel();
$PermissionModel = Gdn::PermissionModel();
$this->Form->SetModel($this->CategoryModel);
if (!$CategoryID && $this->Form->IsPostBack()) {
if ($ID = $this->Form->GetFormValue('CategoryID'))
$CategoryID = $ID;
}
// Get category data
$this->Category = $this->CategoryModel->GetID($CategoryID);
$this->Category->CustomPermissions = $this->Category->CategoryID == $this->Category->PermissionCategoryID;
// Set up head
$this->AddJsFile('jquery.alphanumeric.js');
$this->AddJsFile('categories.js');
$this->AddJsFile('jquery.gardencheckboxgrid.js');
$this->Title(T('Edit Category'));
$this->AddSideMenu('vanilla/settings/managecategories');
// Make sure the form knows which item we are editing.
$this->Form->AddHidden('CategoryID', $CategoryID);
$this->SetData('CategoryID', $CategoryID);
// Load all roles with editable permissions
$this->RoleArray = $RoleModel->GetArray();
$this->FireEvent('AddEditCategory');
if ($this->Form->IsPostBack() == FALSE) {
$this->Form->SetData($this->Category);
$this->Form->SetValue('CustomPoints', $this->Category->PointsCategoryID == $this->Category->CategoryID);
} else {
$Upload = new Gdn_Upload();
$TmpImage = $Upload->ValidateUpload('PhotoUpload', FALSE);
if ($TmpImage) {
// Generate the target image name
$TargetImage = $Upload->GenerateTargetName(PATH_UPLOADS);
$ImageBaseName = pathinfo($TargetImage, PATHINFO_BASENAME);
// Save the uploaded image
$Parts = $Upload->SaveAs(
$TmpImage,
$ImageBaseName
);
$this->Form->SetFormValue('Photo', $Parts['SaveName']);
}
$this->Form->SetFormValue('CustomPoints', (bool)$this->Form->GetFormValue('CustomPoints'));
if ($this->Form->Save()) {
$Category = CategoryModel::Categories($CategoryID);
$this->SetData('Category', $Category);
if ($this->DeliveryType() == DELIVERY_TYPE_ALL)
Redirect('vanilla/settings/managecategories');
}
}
// Get all of the currently selected role/permission combinations for this junction.
$Permissions = $PermissionModel->GetJunctionPermissions(array('JunctionID' => $CategoryID), 'Category', '', array('AddDefaults' => !$this->Category->CustomPermissions));
$Permissions = $PermissionModel->UnpivotPermissions($Permissions, TRUE);
if ($this->DeliveryType() == DELIVERY_TYPE_ALL)
$this->SetData('PermissionData', $Permissions, TRUE);
// Render default view
$this->Render();
}
|
php
|
public function EditCategory($CategoryID = '') {
// Check permission
$this->Permission('Garden.Settings.Manage');
// Set up models
$RoleModel = new RoleModel();
$PermissionModel = Gdn::PermissionModel();
$this->Form->SetModel($this->CategoryModel);
if (!$CategoryID && $this->Form->IsPostBack()) {
if ($ID = $this->Form->GetFormValue('CategoryID'))
$CategoryID = $ID;
}
// Get category data
$this->Category = $this->CategoryModel->GetID($CategoryID);
$this->Category->CustomPermissions = $this->Category->CategoryID == $this->Category->PermissionCategoryID;
// Set up head
$this->AddJsFile('jquery.alphanumeric.js');
$this->AddJsFile('categories.js');
$this->AddJsFile('jquery.gardencheckboxgrid.js');
$this->Title(T('Edit Category'));
$this->AddSideMenu('vanilla/settings/managecategories');
// Make sure the form knows which item we are editing.
$this->Form->AddHidden('CategoryID', $CategoryID);
$this->SetData('CategoryID', $CategoryID);
// Load all roles with editable permissions
$this->RoleArray = $RoleModel->GetArray();
$this->FireEvent('AddEditCategory');
if ($this->Form->IsPostBack() == FALSE) {
$this->Form->SetData($this->Category);
$this->Form->SetValue('CustomPoints', $this->Category->PointsCategoryID == $this->Category->CategoryID);
} else {
$Upload = new Gdn_Upload();
$TmpImage = $Upload->ValidateUpload('PhotoUpload', FALSE);
if ($TmpImage) {
// Generate the target image name
$TargetImage = $Upload->GenerateTargetName(PATH_UPLOADS);
$ImageBaseName = pathinfo($TargetImage, PATHINFO_BASENAME);
// Save the uploaded image
$Parts = $Upload->SaveAs(
$TmpImage,
$ImageBaseName
);
$this->Form->SetFormValue('Photo', $Parts['SaveName']);
}
$this->Form->SetFormValue('CustomPoints', (bool)$this->Form->GetFormValue('CustomPoints'));
if ($this->Form->Save()) {
$Category = CategoryModel::Categories($CategoryID);
$this->SetData('Category', $Category);
if ($this->DeliveryType() == DELIVERY_TYPE_ALL)
Redirect('vanilla/settings/managecategories');
}
}
// Get all of the currently selected role/permission combinations for this junction.
$Permissions = $PermissionModel->GetJunctionPermissions(array('JunctionID' => $CategoryID), 'Category', '', array('AddDefaults' => !$this->Category->CustomPermissions));
$Permissions = $PermissionModel->UnpivotPermissions($Permissions, TRUE);
if ($this->DeliveryType() == DELIVERY_TYPE_ALL)
$this->SetData('PermissionData', $Permissions, TRUE);
// Render default view
$this->Render();
}
|
[
"public",
"function",
"EditCategory",
"(",
"$",
"CategoryID",
"=",
"''",
")",
"{",
"// Check permission",
"$",
"this",
"->",
"Permission",
"(",
"'Garden.Settings.Manage'",
")",
";",
"// Set up models",
"$",
"RoleModel",
"=",
"new",
"RoleModel",
"(",
")",
";",
"$",
"PermissionModel",
"=",
"Gdn",
"::",
"PermissionModel",
"(",
")",
";",
"$",
"this",
"->",
"Form",
"->",
"SetModel",
"(",
"$",
"this",
"->",
"CategoryModel",
")",
";",
"if",
"(",
"!",
"$",
"CategoryID",
"&&",
"$",
"this",
"->",
"Form",
"->",
"IsPostBack",
"(",
")",
")",
"{",
"if",
"(",
"$",
"ID",
"=",
"$",
"this",
"->",
"Form",
"->",
"GetFormValue",
"(",
"'CategoryID'",
")",
")",
"$",
"CategoryID",
"=",
"$",
"ID",
";",
"}",
"// Get category data",
"$",
"this",
"->",
"Category",
"=",
"$",
"this",
"->",
"CategoryModel",
"->",
"GetID",
"(",
"$",
"CategoryID",
")",
";",
"$",
"this",
"->",
"Category",
"->",
"CustomPermissions",
"=",
"$",
"this",
"->",
"Category",
"->",
"CategoryID",
"==",
"$",
"this",
"->",
"Category",
"->",
"PermissionCategoryID",
";",
"// Set up head",
"$",
"this",
"->",
"AddJsFile",
"(",
"'jquery.alphanumeric.js'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'categories.js'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'jquery.gardencheckboxgrid.js'",
")",
";",
"$",
"this",
"->",
"Title",
"(",
"T",
"(",
"'Edit Category'",
")",
")",
";",
"$",
"this",
"->",
"AddSideMenu",
"(",
"'vanilla/settings/managecategories'",
")",
";",
"// Make sure the form knows which item we are editing.",
"$",
"this",
"->",
"Form",
"->",
"AddHidden",
"(",
"'CategoryID'",
",",
"$",
"CategoryID",
")",
";",
"$",
"this",
"->",
"SetData",
"(",
"'CategoryID'",
",",
"$",
"CategoryID",
")",
";",
"// Load all roles with editable permissions",
"$",
"this",
"->",
"RoleArray",
"=",
"$",
"RoleModel",
"->",
"GetArray",
"(",
")",
";",
"$",
"this",
"->",
"FireEvent",
"(",
"'AddEditCategory'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"Form",
"->",
"IsPostBack",
"(",
")",
"==",
"FALSE",
")",
"{",
"$",
"this",
"->",
"Form",
"->",
"SetData",
"(",
"$",
"this",
"->",
"Category",
")",
";",
"$",
"this",
"->",
"Form",
"->",
"SetValue",
"(",
"'CustomPoints'",
",",
"$",
"this",
"->",
"Category",
"->",
"PointsCategoryID",
"==",
"$",
"this",
"->",
"Category",
"->",
"CategoryID",
")",
";",
"}",
"else",
"{",
"$",
"Upload",
"=",
"new",
"Gdn_Upload",
"(",
")",
";",
"$",
"TmpImage",
"=",
"$",
"Upload",
"->",
"ValidateUpload",
"(",
"'PhotoUpload'",
",",
"FALSE",
")",
";",
"if",
"(",
"$",
"TmpImage",
")",
"{",
"// Generate the target image name",
"$",
"TargetImage",
"=",
"$",
"Upload",
"->",
"GenerateTargetName",
"(",
"PATH_UPLOADS",
")",
";",
"$",
"ImageBaseName",
"=",
"pathinfo",
"(",
"$",
"TargetImage",
",",
"PATHINFO_BASENAME",
")",
";",
"// Save the uploaded image",
"$",
"Parts",
"=",
"$",
"Upload",
"->",
"SaveAs",
"(",
"$",
"TmpImage",
",",
"$",
"ImageBaseName",
")",
";",
"$",
"this",
"->",
"Form",
"->",
"SetFormValue",
"(",
"'Photo'",
",",
"$",
"Parts",
"[",
"'SaveName'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"Form",
"->",
"SetFormValue",
"(",
"'CustomPoints'",
",",
"(",
"bool",
")",
"$",
"this",
"->",
"Form",
"->",
"GetFormValue",
"(",
"'CustomPoints'",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"Form",
"->",
"Save",
"(",
")",
")",
"{",
"$",
"Category",
"=",
"CategoryModel",
"::",
"Categories",
"(",
"$",
"CategoryID",
")",
";",
"$",
"this",
"->",
"SetData",
"(",
"'Category'",
",",
"$",
"Category",
")",
";",
"if",
"(",
"$",
"this",
"->",
"DeliveryType",
"(",
")",
"==",
"DELIVERY_TYPE_ALL",
")",
"Redirect",
"(",
"'vanilla/settings/managecategories'",
")",
";",
"}",
"}",
"// Get all of the currently selected role/permission combinations for this junction.",
"$",
"Permissions",
"=",
"$",
"PermissionModel",
"->",
"GetJunctionPermissions",
"(",
"array",
"(",
"'JunctionID'",
"=>",
"$",
"CategoryID",
")",
",",
"'Category'",
",",
"''",
",",
"array",
"(",
"'AddDefaults'",
"=>",
"!",
"$",
"this",
"->",
"Category",
"->",
"CustomPermissions",
")",
")",
";",
"$",
"Permissions",
"=",
"$",
"PermissionModel",
"->",
"UnpivotPermissions",
"(",
"$",
"Permissions",
",",
"TRUE",
")",
";",
"if",
"(",
"$",
"this",
"->",
"DeliveryType",
"(",
")",
"==",
"DELIVERY_TYPE_ALL",
")",
"$",
"this",
"->",
"SetData",
"(",
"'PermissionData'",
",",
"$",
"Permissions",
",",
"TRUE",
")",
";",
"// Render default view",
"$",
"this",
"->",
"Render",
"(",
")",
";",
"}"
] |
Editing a category.
@since 2.0.0
@access public
@param int $CategoryID Unique ID of the category to be updated.
|
[
"Editing",
"a",
"category",
"."
] |
8494eb4a4ad61603479015a8054d23ff488364e8
|
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/controllers/class.settingscontroller.php#L408-L482
|
239,761
|
bishopb/vanilla
|
applications/vanilla/controllers/class.settingscontroller.php
|
SettingsController.ManageCategories
|
public function ManageCategories() {
// Check permission
$this->Permission('Garden.Settings.Manage');
$this->AddSideMenu('vanilla/settings/managecategories');
// Nested sortable always breaks when we update jQuery so we give it it's own old version of jquery.
$this->RemoveJsFile('jquery.js');
$this->AddJsFile('js/library/nestedSortable.1.3.4/jquery-1.7.2.min.js', '', array('Sort' => 0));
$this->AddJsFile('categories.js');
$this->AddJsFile('js/library/jquery.alphanumeric.js');
$this->AddJsFile('js/library/nestedSortable.1.3.4/jquery-ui-1.8.11.custom.min.js');
$this->AddJsFile('js/library/nestedSortable.1.3.4/jquery.ui.nestedSortable.js');
$this->Title(T('Categories'));
// Get category data
$this->SetData('CategoryData', $this->CategoryModel->GetAll('TreeLeft'), TRUE);
// Enable/Disable Categories
if (Gdn::Session()->ValidateTransientKey(GetValue(1, $this->RequestArgs))) {
$Toggle = GetValue(0, $this->RequestArgs, '');
if ($Toggle == 'enable') {
SaveToConfig('Vanilla.Categories.Use', TRUE);
} else if ($Toggle == 'disable') {
SaveToConfig('Vanilla.Categories.Use', FALSE);
}
Redirect('vanilla/settings/managecategories');
}
// Setup & save forms
$Validation = new Gdn_Validation();
$ConfigurationModel = new Gdn_ConfigurationModel($Validation);
$ConfigurationModel->SetField(array(
'Vanilla.Categories.MaxDisplayDepth',
'Vanilla.Categories.DoHeadings',
'Vanilla.Categories.HideModule'
));
// Set the model on the form.
$this->Form->SetModel($ConfigurationModel);
// Define MaxDepthOptions
$DepthData = array();
$DepthData['2'] = sprintf(T('more than %s deep'), Plural(1, '%s level', '%s levels'));
$DepthData['3'] = sprintf(T('more than %s deep'), Plural(2, '%s level', '%s levels'));
$DepthData['4'] = sprintf(T('more than %s deep'), Plural(3, '%s level', '%s levels')) ;
$DepthData['0'] = T('never');
$this->SetData('MaxDepthData', $DepthData);
// If seeing the form for the first time...
if ($this->Form->AuthenticatedPostBack() === FALSE) {
// Apply the config settings to the form.
$this->Form->SetData($ConfigurationModel->Data);
} else {
if ($this->Form->Save() !== FALSE)
$this->InformMessage(T("Your settings have been saved."));
}
// Render default view
$this->Render();
}
|
php
|
public function ManageCategories() {
// Check permission
$this->Permission('Garden.Settings.Manage');
$this->AddSideMenu('vanilla/settings/managecategories');
// Nested sortable always breaks when we update jQuery so we give it it's own old version of jquery.
$this->RemoveJsFile('jquery.js');
$this->AddJsFile('js/library/nestedSortable.1.3.4/jquery-1.7.2.min.js', '', array('Sort' => 0));
$this->AddJsFile('categories.js');
$this->AddJsFile('js/library/jquery.alphanumeric.js');
$this->AddJsFile('js/library/nestedSortable.1.3.4/jquery-ui-1.8.11.custom.min.js');
$this->AddJsFile('js/library/nestedSortable.1.3.4/jquery.ui.nestedSortable.js');
$this->Title(T('Categories'));
// Get category data
$this->SetData('CategoryData', $this->CategoryModel->GetAll('TreeLeft'), TRUE);
// Enable/Disable Categories
if (Gdn::Session()->ValidateTransientKey(GetValue(1, $this->RequestArgs))) {
$Toggle = GetValue(0, $this->RequestArgs, '');
if ($Toggle == 'enable') {
SaveToConfig('Vanilla.Categories.Use', TRUE);
} else if ($Toggle == 'disable') {
SaveToConfig('Vanilla.Categories.Use', FALSE);
}
Redirect('vanilla/settings/managecategories');
}
// Setup & save forms
$Validation = new Gdn_Validation();
$ConfigurationModel = new Gdn_ConfigurationModel($Validation);
$ConfigurationModel->SetField(array(
'Vanilla.Categories.MaxDisplayDepth',
'Vanilla.Categories.DoHeadings',
'Vanilla.Categories.HideModule'
));
// Set the model on the form.
$this->Form->SetModel($ConfigurationModel);
// Define MaxDepthOptions
$DepthData = array();
$DepthData['2'] = sprintf(T('more than %s deep'), Plural(1, '%s level', '%s levels'));
$DepthData['3'] = sprintf(T('more than %s deep'), Plural(2, '%s level', '%s levels'));
$DepthData['4'] = sprintf(T('more than %s deep'), Plural(3, '%s level', '%s levels')) ;
$DepthData['0'] = T('never');
$this->SetData('MaxDepthData', $DepthData);
// If seeing the form for the first time...
if ($this->Form->AuthenticatedPostBack() === FALSE) {
// Apply the config settings to the form.
$this->Form->SetData($ConfigurationModel->Data);
} else {
if ($this->Form->Save() !== FALSE)
$this->InformMessage(T("Your settings have been saved."));
}
// Render default view
$this->Render();
}
|
[
"public",
"function",
"ManageCategories",
"(",
")",
"{",
"// Check permission",
"$",
"this",
"->",
"Permission",
"(",
"'Garden.Settings.Manage'",
")",
";",
"$",
"this",
"->",
"AddSideMenu",
"(",
"'vanilla/settings/managecategories'",
")",
";",
"// Nested sortable always breaks when we update jQuery so we give it it's own old version of jquery.",
"$",
"this",
"->",
"RemoveJsFile",
"(",
"'jquery.js'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'js/library/nestedSortable.1.3.4/jquery-1.7.2.min.js'",
",",
"''",
",",
"array",
"(",
"'Sort'",
"=>",
"0",
")",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'categories.js'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'js/library/jquery.alphanumeric.js'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'js/library/nestedSortable.1.3.4/jquery-ui-1.8.11.custom.min.js'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'js/library/nestedSortable.1.3.4/jquery.ui.nestedSortable.js'",
")",
";",
"$",
"this",
"->",
"Title",
"(",
"T",
"(",
"'Categories'",
")",
")",
";",
"// Get category data",
"$",
"this",
"->",
"SetData",
"(",
"'CategoryData'",
",",
"$",
"this",
"->",
"CategoryModel",
"->",
"GetAll",
"(",
"'TreeLeft'",
")",
",",
"TRUE",
")",
";",
"// Enable/Disable Categories",
"if",
"(",
"Gdn",
"::",
"Session",
"(",
")",
"->",
"ValidateTransientKey",
"(",
"GetValue",
"(",
"1",
",",
"$",
"this",
"->",
"RequestArgs",
")",
")",
")",
"{",
"$",
"Toggle",
"=",
"GetValue",
"(",
"0",
",",
"$",
"this",
"->",
"RequestArgs",
",",
"''",
")",
";",
"if",
"(",
"$",
"Toggle",
"==",
"'enable'",
")",
"{",
"SaveToConfig",
"(",
"'Vanilla.Categories.Use'",
",",
"TRUE",
")",
";",
"}",
"else",
"if",
"(",
"$",
"Toggle",
"==",
"'disable'",
")",
"{",
"SaveToConfig",
"(",
"'Vanilla.Categories.Use'",
",",
"FALSE",
")",
";",
"}",
"Redirect",
"(",
"'vanilla/settings/managecategories'",
")",
";",
"}",
"// Setup & save forms",
"$",
"Validation",
"=",
"new",
"Gdn_Validation",
"(",
")",
";",
"$",
"ConfigurationModel",
"=",
"new",
"Gdn_ConfigurationModel",
"(",
"$",
"Validation",
")",
";",
"$",
"ConfigurationModel",
"->",
"SetField",
"(",
"array",
"(",
"'Vanilla.Categories.MaxDisplayDepth'",
",",
"'Vanilla.Categories.DoHeadings'",
",",
"'Vanilla.Categories.HideModule'",
")",
")",
";",
"// Set the model on the form.",
"$",
"this",
"->",
"Form",
"->",
"SetModel",
"(",
"$",
"ConfigurationModel",
")",
";",
"// Define MaxDepthOptions",
"$",
"DepthData",
"=",
"array",
"(",
")",
";",
"$",
"DepthData",
"[",
"'2'",
"]",
"=",
"sprintf",
"(",
"T",
"(",
"'more than %s deep'",
")",
",",
"Plural",
"(",
"1",
",",
"'%s level'",
",",
"'%s levels'",
")",
")",
";",
"$",
"DepthData",
"[",
"'3'",
"]",
"=",
"sprintf",
"(",
"T",
"(",
"'more than %s deep'",
")",
",",
"Plural",
"(",
"2",
",",
"'%s level'",
",",
"'%s levels'",
")",
")",
";",
"$",
"DepthData",
"[",
"'4'",
"]",
"=",
"sprintf",
"(",
"T",
"(",
"'more than %s deep'",
")",
",",
"Plural",
"(",
"3",
",",
"'%s level'",
",",
"'%s levels'",
")",
")",
";",
"$",
"DepthData",
"[",
"'0'",
"]",
"=",
"T",
"(",
"'never'",
")",
";",
"$",
"this",
"->",
"SetData",
"(",
"'MaxDepthData'",
",",
"$",
"DepthData",
")",
";",
"// If seeing the form for the first time...",
"if",
"(",
"$",
"this",
"->",
"Form",
"->",
"AuthenticatedPostBack",
"(",
")",
"===",
"FALSE",
")",
"{",
"// Apply the config settings to the form.",
"$",
"this",
"->",
"Form",
"->",
"SetData",
"(",
"$",
"ConfigurationModel",
"->",
"Data",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"Form",
"->",
"Save",
"(",
")",
"!==",
"FALSE",
")",
"$",
"this",
"->",
"InformMessage",
"(",
"T",
"(",
"\"Your settings have been saved.\"",
")",
")",
";",
"}",
"// Render default view",
"$",
"this",
"->",
"Render",
"(",
")",
";",
"}"
] |
Enabling and disabling categories from list.
@since 2.0.0
@access public
|
[
"Enabling",
"and",
"disabling",
"categories",
"from",
"list",
"."
] |
8494eb4a4ad61603479015a8054d23ff488364e8
|
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/controllers/class.settingscontroller.php#L490-L551
|
239,762
|
bishopb/vanilla
|
applications/vanilla/controllers/class.settingscontroller.php
|
SettingsController.SortCategories
|
public function SortCategories() {
// Check permission
$this->Permission('Garden.Settings.Manage');
// Set delivery type to true/false
$TransientKey = GetIncomingValue('TransientKey');
if (Gdn::Request()->IsPostBack()) {
$TreeArray = GetValue('TreeArray', $_POST);
$Saves = $this->CategoryModel->SaveTree($TreeArray);
$this->SetData('Result', TRUE);
$this->SetData('Saves', $Saves);
}
// Renders true/false rather than template
$this->Render();
}
|
php
|
public function SortCategories() {
// Check permission
$this->Permission('Garden.Settings.Manage');
// Set delivery type to true/false
$TransientKey = GetIncomingValue('TransientKey');
if (Gdn::Request()->IsPostBack()) {
$TreeArray = GetValue('TreeArray', $_POST);
$Saves = $this->CategoryModel->SaveTree($TreeArray);
$this->SetData('Result', TRUE);
$this->SetData('Saves', $Saves);
}
// Renders true/false rather than template
$this->Render();
}
|
[
"public",
"function",
"SortCategories",
"(",
")",
"{",
"// Check permission",
"$",
"this",
"->",
"Permission",
"(",
"'Garden.Settings.Manage'",
")",
";",
"// Set delivery type to true/false",
"$",
"TransientKey",
"=",
"GetIncomingValue",
"(",
"'TransientKey'",
")",
";",
"if",
"(",
"Gdn",
"::",
"Request",
"(",
")",
"->",
"IsPostBack",
"(",
")",
")",
"{",
"$",
"TreeArray",
"=",
"GetValue",
"(",
"'TreeArray'",
",",
"$",
"_POST",
")",
";",
"$",
"Saves",
"=",
"$",
"this",
"->",
"CategoryModel",
"->",
"SaveTree",
"(",
"$",
"TreeArray",
")",
";",
"$",
"this",
"->",
"SetData",
"(",
"'Result'",
",",
"TRUE",
")",
";",
"$",
"this",
"->",
"SetData",
"(",
"'Saves'",
",",
"$",
"Saves",
")",
";",
"}",
"// Renders true/false rather than template ",
"$",
"this",
"->",
"Render",
"(",
")",
";",
"}"
] |
Sorting display order of categories.
Accessed by ajax so its default is to only output true/false.
@since 2.0.0
@access public
|
[
"Sorting",
"display",
"order",
"of",
"categories",
"."
] |
8494eb4a4ad61603479015a8054d23ff488364e8
|
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/controllers/class.settingscontroller.php#L561-L576
|
239,763
|
larriereguichet/DoctrineRepositoryBundle
|
Repository/RepositoryPool.php
|
RepositoryPool.get
|
public function get($className)
{
if (!$this->has($className)) {
throw new Exception('Repository ' . $className . ' not found');
}
return $this->pool[$className];
}
|
php
|
public function get($className)
{
if (!$this->has($className)) {
throw new Exception('Repository ' . $className . ' not found');
}
return $this->pool[$className];
}
|
[
"public",
"function",
"get",
"(",
"$",
"className",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"className",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Repository '",
".",
"$",
"className",
".",
"' not found'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"pool",
"[",
"$",
"className",
"]",
";",
"}"
] |
Return a doctrine repository according to its class name
@param $className
@return DoctrineRepository
@throws Exception
|
[
"Return",
"a",
"doctrine",
"repository",
"according",
"to",
"its",
"class",
"name"
] |
d98e91d115a6c9f0fe9e9fb03de92f1268b51c10
|
https://github.com/larriereguichet/DoctrineRepositoryBundle/blob/d98e91d115a6c9f0fe9e9fb03de92f1268b51c10/Repository/RepositoryPool.php#L31-L37
|
239,764
|
AlcyZ/Alcys-ORM
|
src/Core/Db/Facade/SelectFacade.php
|
SelectFacade.table
|
public function table($tableName, $alias = null)
{
$table = $this->factory->references('Table', $tableName, $alias);
$this->select->table($table);
return $this;
}
|
php
|
public function table($tableName, $alias = null)
{
$table = $this->factory->references('Table', $tableName, $alias);
$this->select->table($table);
return $this;
}
|
[
"public",
"function",
"table",
"(",
"$",
"tableName",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"factory",
"->",
"references",
"(",
"'Table'",
",",
"$",
"tableName",
",",
"$",
"alias",
")",
";",
"$",
"this",
"->",
"select",
"->",
"table",
"(",
"$",
"table",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add a table to the query.
@param string $tableName The name of the table.
@param string|null $alias (Optional) An alias name, if exists.
@return $this The same instance to concatenate methods.
|
[
"Add",
"a",
"table",
"to",
"the",
"query",
"."
] |
dd30946ad35ab06cba2167cf6dfa02b733614720
|
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Facade/SelectFacade.php#L119-L125
|
239,765
|
AlcyZ/Alcys-ORM
|
src/Core/Db/Facade/SelectFacade.php
|
SelectFacade.limit
|
public function limit($beginAmount, $amount = null)
{
$beginObj = new Numeric((int)$beginAmount);
$amountObj = ($amount) ? new Numeric((int)$amount) : null;
$this->select->limit($beginObj, $amountObj);
return $this;
}
|
php
|
public function limit($beginAmount, $amount = null)
{
$beginObj = new Numeric((int)$beginAmount);
$amountObj = ($amount) ? new Numeric((int)$amount) : null;
$this->select->limit($beginObj, $amountObj);
return $this;
}
|
[
"public",
"function",
"limit",
"(",
"$",
"beginAmount",
",",
"$",
"amount",
"=",
"null",
")",
"{",
"$",
"beginObj",
"=",
"new",
"Numeric",
"(",
"(",
"int",
")",
"$",
"beginAmount",
")",
";",
"$",
"amountObj",
"=",
"(",
"$",
"amount",
")",
"?",
"new",
"Numeric",
"(",
"(",
"int",
")",
"$",
"amount",
")",
":",
"null",
";",
"$",
"this",
"->",
"select",
"->",
"limit",
"(",
"$",
"beginObj",
",",
"$",
"amountObj",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add a limit expression to the query.
@param int $beginAmount Amount if only one arg isset, if two, the first entry which will used.
@param int|null $amount (Optional) Amount of entries which.
@return $this The same instance to concatenate methods.
|
[
"Add",
"a",
"limit",
"expression",
"to",
"the",
"query",
"."
] |
dd30946ad35ab06cba2167cf6dfa02b733614720
|
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Facade/SelectFacade.php#L172-L180
|
239,766
|
AlcyZ/Alcys-ORM
|
src/Core/Db/Facade/SelectFacade.php
|
SelectFacade.groupBy
|
public function groupBy($column, $orderMode = null)
{
$columnObj = $this->factory->references('Column', $column);
$orderModeObj = ($orderMode) ? $this->factory->references('OrderModeEnum', $orderMode) : null;
$this->select->groupBy($columnObj, $orderModeObj);
return $this;
}
|
php
|
public function groupBy($column, $orderMode = null)
{
$columnObj = $this->factory->references('Column', $column);
$orderModeObj = ($orderMode) ? $this->factory->references('OrderModeEnum', $orderMode) : null;
$this->select->groupBy($columnObj, $orderModeObj);
return $this;
}
|
[
"public",
"function",
"groupBy",
"(",
"$",
"column",
",",
"$",
"orderMode",
"=",
"null",
")",
"{",
"$",
"columnObj",
"=",
"$",
"this",
"->",
"factory",
"->",
"references",
"(",
"'Column'",
",",
"$",
"column",
")",
";",
"$",
"orderModeObj",
"=",
"(",
"$",
"orderMode",
")",
"?",
"$",
"this",
"->",
"factory",
"->",
"references",
"(",
"'OrderModeEnum'",
",",
"$",
"orderMode",
")",
":",
"null",
";",
"$",
"this",
"->",
"select",
"->",
"groupBy",
"(",
"$",
"columnObj",
",",
"$",
"orderModeObj",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add a group by expression to the query.
@param string $column
@param string|null $orderMode
@return $this The same instance to concatenate methods
|
[
"Add",
"a",
"group",
"by",
"expression",
"to",
"the",
"query",
"."
] |
dd30946ad35ab06cba2167cf6dfa02b733614720
|
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Facade/SelectFacade.php#L191-L198
|
239,767
|
TechPromux/TechPromuxDynamicQueryBundle
|
Manager/DataSourceManager.php
|
DataSourceManager.createDoctrineDBALConnection
|
public function createDoctrineDBALConnection($driver, $host, $port, $dbname, $user, $password)
{
// TODO caching for connection
$connectionFactory = $this->getDoctrineConnectionFactory();
$connection = $connectionFactory->createConnection(array(
'driver' => $driver,
'host' => $host,
'port' => $port,
'dbname' => $dbname,
'user' => $user,
'password' => $password,
));
return $connection;
}
|
php
|
public function createDoctrineDBALConnection($driver, $host, $port, $dbname, $user, $password)
{
// TODO caching for connection
$connectionFactory = $this->getDoctrineConnectionFactory();
$connection = $connectionFactory->createConnection(array(
'driver' => $driver,
'host' => $host,
'port' => $port,
'dbname' => $dbname,
'user' => $user,
'password' => $password,
));
return $connection;
}
|
[
"public",
"function",
"createDoctrineDBALConnection",
"(",
"$",
"driver",
",",
"$",
"host",
",",
"$",
"port",
",",
"$",
"dbname",
",",
"$",
"user",
",",
"$",
"password",
")",
"{",
"// TODO caching for connection",
"$",
"connectionFactory",
"=",
"$",
"this",
"->",
"getDoctrineConnectionFactory",
"(",
")",
";",
"$",
"connection",
"=",
"$",
"connectionFactory",
"->",
"createConnection",
"(",
"array",
"(",
"'driver'",
"=>",
"$",
"driver",
",",
"'host'",
"=>",
"$",
"host",
",",
"'port'",
"=>",
"$",
"port",
",",
"'dbname'",
"=>",
"$",
"dbname",
",",
"'user'",
"=>",
"$",
"user",
",",
"'password'",
"=>",
"$",
"password",
",",
")",
")",
";",
"return",
"$",
"connection",
";",
"}"
] |
Creates a Doctrine DBAL Connection
@param string $driver
@param string $host
@param string $port
@param string $dbname
@param string $user
@param string $password
@return \Doctrine\DBAL\Connection
|
[
"Creates",
"a",
"Doctrine",
"DBAL",
"Connection"
] |
aadee662ce88e37443f32b110126f835fc1a6fd8
|
https://github.com/TechPromux/TechPromuxDynamicQueryBundle/blob/aadee662ce88e37443f32b110126f835fc1a6fd8/Manager/DataSourceManager.php#L120-L136
|
239,768
|
TechPromux/TechPromuxDynamicQueryBundle
|
Manager/DataSourceManager.php
|
DataSourceManager.getSQLResultFromConnection
|
protected function getSQLResultFromConnection($connection, $sql, array $params = array())
{
$result = $connection->fetchAll($sql, $params);
return $result;
}
|
php
|
protected function getSQLResultFromConnection($connection, $sql, array $params = array())
{
$result = $connection->fetchAll($sql, $params);
return $result;
}
|
[
"protected",
"function",
"getSQLResultFromConnection",
"(",
"$",
"connection",
",",
"$",
"sql",
",",
"array",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"result",
"=",
"$",
"connection",
"->",
"fetchAll",
"(",
"$",
"sql",
",",
"$",
"params",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Permite ejecutar una consulta de tipo SELECT
@param \Doctrine\DBAL\Connection $connection
@param string $sql
@return array
|
[
"Permite",
"ejecutar",
"una",
"consulta",
"de",
"tipo",
"SELECT"
] |
aadee662ce88e37443f32b110126f835fc1a6fd8
|
https://github.com/TechPromux/TechPromuxDynamicQueryBundle/blob/aadee662ce88e37443f32b110126f835fc1a6fd8/Manager/DataSourceManager.php#L206-L210
|
239,769
|
razielsd/webdriverlib
|
WebDriver/WebDriver/Server/Appium.php
|
WebDriver_Server_Appium.findByXpath
|
public function findByXpath($locator)
{
$locator = \Normalizer::normalize($locator, \Normalizer::FORM_D);
return parent::find($locator);
}
|
php
|
public function findByXpath($locator)
{
$locator = \Normalizer::normalize($locator, \Normalizer::FORM_D);
return parent::find($locator);
}
|
[
"public",
"function",
"findByXpath",
"(",
"$",
"locator",
")",
"{",
"$",
"locator",
"=",
"\\",
"Normalizer",
"::",
"normalize",
"(",
"$",
"locator",
",",
"\\",
"Normalizer",
"::",
"FORM_D",
")",
";",
"return",
"parent",
"::",
"find",
"(",
"$",
"locator",
")",
";",
"}"
] |
Get page element using normalized locator for xpath UTF strings
@param $locator
@return WebDriver_Element
|
[
"Get",
"page",
"element",
"using",
"normalized",
"locator",
"for",
"xpath",
"UTF",
"strings"
] |
e498afc36a8cdeab5b6ca95016420557baf32f36
|
https://github.com/razielsd/webdriverlib/blob/e498afc36a8cdeab5b6ca95016420557baf32f36/WebDriver/WebDriver/Server/Appium.php#L13-L17
|
239,770
|
movicon/movicon-http
|
src/http/HttpController.php
|
HttpController.on
|
public function on($method, $listener)
{
if (!array_key_exists($method, $this->_listeners)) {
$this->_listeners[$method] = [];
}
array_push($this->_listeners[$method], $listener);
}
|
php
|
public function on($method, $listener)
{
if (!array_key_exists($method, $this->_listeners)) {
$this->_listeners[$method] = [];
}
array_push($this->_listeners[$method], $listener);
}
|
[
"public",
"function",
"on",
"(",
"$",
"method",
",",
"$",
"listener",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"method",
",",
"$",
"this",
"->",
"_listeners",
")",
")",
"{",
"$",
"this",
"->",
"_listeners",
"[",
"$",
"method",
"]",
"=",
"[",
"]",
";",
"}",
"array_push",
"(",
"$",
"this",
"->",
"_listeners",
"[",
"$",
"method",
"]",
",",
"$",
"listener",
")",
";",
"}"
] |
Adds a request listener.
Example:
$c = new HttpController();
$c->on("PUT", function () {
echo "Processing PUT request\n";
});
$c->processRequest();
@param string $method Method name (GET, POST, PUT, etc...)
@param callable $listener Request listener
@return void
|
[
"Adds",
"a",
"request",
"listener",
"."
] |
ae9e4aa763c52f272c628fef0ec4496478312355
|
https://github.com/movicon/movicon-http/blob/ae9e4aa763c52f272c628fef0ec4496478312355/src/http/HttpController.php#L94-L101
|
239,771
|
wasabi-cms/core
|
src/Enum/EnumTrait.php
|
EnumTrait.getConstants
|
public static function getConstants()
{
if (empty(self::$_constantsCache)) {
$reflectionClass = new \ReflectionClass(get_called_class());
self::$_constantsCache = $reflectionClass->getConstants();
}
return self::$_constantsCache;
}
|
php
|
public static function getConstants()
{
if (empty(self::$_constantsCache)) {
$reflectionClass = new \ReflectionClass(get_called_class());
self::$_constantsCache = $reflectionClass->getConstants();
}
return self::$_constantsCache;
}
|
[
"public",
"static",
"function",
"getConstants",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"_constantsCache",
")",
")",
"{",
"$",
"reflectionClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"get_called_class",
"(",
")",
")",
";",
"self",
"::",
"$",
"_constantsCache",
"=",
"$",
"reflectionClass",
"->",
"getConstants",
"(",
")",
";",
"}",
"return",
"self",
"::",
"$",
"_constantsCache",
";",
"}"
] |
Get and cache all constants of for this enum.
@return array
|
[
"Get",
"and",
"cache",
"all",
"constants",
"of",
"for",
"this",
"enum",
"."
] |
0eadbb64d2fc201bacc63c93814adeca70e08f90
|
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Enum/EnumTrait.php#L34-L41
|
239,772
|
wasabi-cms/core
|
src/Enum/EnumTrait.php
|
EnumTrait.getConstantConfigByValue
|
public static function getConstantConfigByValue($value)
{
foreach (self::getConstants() as $constant) {
if ($constant['value'] === $value) {
return $constant;
}
}
return false;
}
|
php
|
public static function getConstantConfigByValue($value)
{
foreach (self::getConstants() as $constant) {
if ($constant['value'] === $value) {
return $constant;
}
}
return false;
}
|
[
"public",
"static",
"function",
"getConstantConfigByValue",
"(",
"$",
"value",
")",
"{",
"foreach",
"(",
"self",
"::",
"getConstants",
"(",
")",
"as",
"$",
"constant",
")",
"{",
"if",
"(",
"$",
"constant",
"[",
"'value'",
"]",
"===",
"$",
"value",
")",
"{",
"return",
"$",
"constant",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Get a single enum constant configuration for a specific value.
@param int|string $value The value to find a constant config for.
@return array|bool
|
[
"Get",
"a",
"single",
"enum",
"constant",
"configuration",
"for",
"a",
"specific",
"value",
"."
] |
0eadbb64d2fc201bacc63c93814adeca70e08f90
|
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Enum/EnumTrait.php#L69-L77
|
239,773
|
wasabi-cms/core
|
src/Enum/EnumTrait.php
|
EnumTrait.getNameForValue
|
public static function getNameForValue($value)
{
foreach (self::getConstants() as $constant) {
if ($constant['value'] === $value) {
return $constant['name'];
}
}
return false;
}
|
php
|
public static function getNameForValue($value)
{
foreach (self::getConstants() as $constant) {
if ($constant['value'] === $value) {
return $constant['name'];
}
}
return false;
}
|
[
"public",
"static",
"function",
"getNameForValue",
"(",
"$",
"value",
")",
"{",
"foreach",
"(",
"self",
"::",
"getConstants",
"(",
")",
"as",
"$",
"constant",
")",
"{",
"if",
"(",
"$",
"constant",
"[",
"'value'",
"]",
"===",
"$",
"value",
")",
"{",
"return",
"$",
"constant",
"[",
"'name'",
"]",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Get the descriptive name for the given value.
@param int|string $value The value to get the name of a constant for.
@return bool|string
|
[
"Get",
"the",
"descriptive",
"name",
"for",
"the",
"given",
"value",
"."
] |
0eadbb64d2fc201bacc63c93814adeca70e08f90
|
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Enum/EnumTrait.php#L85-L93
|
239,774
|
wasabi-cms/core
|
src/Enum/EnumTrait.php
|
EnumTrait.getValueForName
|
public static function getValueForName($name)
{
foreach (self::getConstants() as $constant) {
if ($constant['name'] === $name) {
return $constant['value'];
}
}
return false;
}
|
php
|
public static function getValueForName($name)
{
foreach (self::getConstants() as $constant) {
if ($constant['name'] === $name) {
return $constant['value'];
}
}
return false;
}
|
[
"public",
"static",
"function",
"getValueForName",
"(",
"$",
"name",
")",
"{",
"foreach",
"(",
"self",
"::",
"getConstants",
"(",
")",
"as",
"$",
"constant",
")",
"{",
"if",
"(",
"$",
"constant",
"[",
"'name'",
"]",
"===",
"$",
"name",
")",
"{",
"return",
"$",
"constant",
"[",
"'value'",
"]",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Get the descriptive value for the given name.
@param int|string $name The name to get the value of a constant for.
@return bool|string
|
[
"Get",
"the",
"descriptive",
"value",
"for",
"the",
"given",
"name",
"."
] |
0eadbb64d2fc201bacc63c93814adeca70e08f90
|
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Enum/EnumTrait.php#L101-L109
|
239,775
|
frankfoerster/cakephp-filter
|
src/View/Helper/FilterHelper.php
|
FilterHelper.pagination
|
public function pagination($maxPageNumbers = 10, $itemType = 'Items', $class = '', $element = 'Filter/pagination', $passParams = [])
{
if (empty($this->paginationParams)) {
return '';
}
$this->_passParams = array_merge($this->paginationParams['passParams'], $passParams);
$page = (integer)$this->paginationParams['page'];
$pages = (integer)$this->paginationParams['pages'];
$pagesOnLeft = floor($maxPageNumbers / 2);
$pagesOnRight = $maxPageNumbers - $pagesOnLeft - 1;
$minPage = $page - $pagesOnLeft;
$maxPage = $page + $pagesOnRight;
$firstUrl = false;
$prevUrl = false;
$pageLinks = [];
$nextUrl = false;
$lastUrl = false;
if ($page > 1) {
$firstUrl = $this->_getPaginatedUrl(1);
$prevUrl = $this->_getPaginatedUrl($page - 1);
}
if ($minPage < 1) {
$minPage = 1;
$maxPage = $maxPageNumbers;
}
if ($maxPage > $pages) {
$maxPage = $pages;
$minPage = $maxPage + 1 - $maxPageNumbers;
}
if ($minPage < 1) {
$minPage = 1;
}
foreach (range($minPage, $maxPage) as $p) {
$link = [
'page' => (int)$p,
'url' => $this->_getPaginatedUrl($p),
'active' => ((int)$p === $page)
];
$pageLinks[] = $link;
}
if ($page < $pages) {
$nextUrl = $this->_getPaginatedUrl($page + 1);
$lastUrl = $this->_getPaginatedUrl($pages);
}
return $this->_View->element($element, [
'total' => $this->paginationParams['total'],
'itemType' => $itemType,
'first' => $firstUrl,
'prev' => $prevUrl,
'pages' => $pageLinks,
'next' => $nextUrl,
'last' => $lastUrl,
'class' => $class,
'currentPage' => $page,
'baseUrl' => Router::url($this->_getFilterUrl(false)),
'from' => $this->paginationParams['from'],
'to' => $this->paginationParams['to'],
'nrOfPages' => $pages
]);
}
|
php
|
public function pagination($maxPageNumbers = 10, $itemType = 'Items', $class = '', $element = 'Filter/pagination', $passParams = [])
{
if (empty($this->paginationParams)) {
return '';
}
$this->_passParams = array_merge($this->paginationParams['passParams'], $passParams);
$page = (integer)$this->paginationParams['page'];
$pages = (integer)$this->paginationParams['pages'];
$pagesOnLeft = floor($maxPageNumbers / 2);
$pagesOnRight = $maxPageNumbers - $pagesOnLeft - 1;
$minPage = $page - $pagesOnLeft;
$maxPage = $page + $pagesOnRight;
$firstUrl = false;
$prevUrl = false;
$pageLinks = [];
$nextUrl = false;
$lastUrl = false;
if ($page > 1) {
$firstUrl = $this->_getPaginatedUrl(1);
$prevUrl = $this->_getPaginatedUrl($page - 1);
}
if ($minPage < 1) {
$minPage = 1;
$maxPage = $maxPageNumbers;
}
if ($maxPage > $pages) {
$maxPage = $pages;
$minPage = $maxPage + 1 - $maxPageNumbers;
}
if ($minPage < 1) {
$minPage = 1;
}
foreach (range($minPage, $maxPage) as $p) {
$link = [
'page' => (int)$p,
'url' => $this->_getPaginatedUrl($p),
'active' => ((int)$p === $page)
];
$pageLinks[] = $link;
}
if ($page < $pages) {
$nextUrl = $this->_getPaginatedUrl($page + 1);
$lastUrl = $this->_getPaginatedUrl($pages);
}
return $this->_View->element($element, [
'total' => $this->paginationParams['total'],
'itemType' => $itemType,
'first' => $firstUrl,
'prev' => $prevUrl,
'pages' => $pageLinks,
'next' => $nextUrl,
'last' => $lastUrl,
'class' => $class,
'currentPage' => $page,
'baseUrl' => Router::url($this->_getFilterUrl(false)),
'from' => $this->paginationParams['from'],
'to' => $this->paginationParams['to'],
'nrOfPages' => $pages
]);
}
|
[
"public",
"function",
"pagination",
"(",
"$",
"maxPageNumbers",
"=",
"10",
",",
"$",
"itemType",
"=",
"'Items'",
",",
"$",
"class",
"=",
"''",
",",
"$",
"element",
"=",
"'Filter/pagination'",
",",
"$",
"passParams",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"paginationParams",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"this",
"->",
"_passParams",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"paginationParams",
"[",
"'passParams'",
"]",
",",
"$",
"passParams",
")",
";",
"$",
"page",
"=",
"(",
"integer",
")",
"$",
"this",
"->",
"paginationParams",
"[",
"'page'",
"]",
";",
"$",
"pages",
"=",
"(",
"integer",
")",
"$",
"this",
"->",
"paginationParams",
"[",
"'pages'",
"]",
";",
"$",
"pagesOnLeft",
"=",
"floor",
"(",
"$",
"maxPageNumbers",
"/",
"2",
")",
";",
"$",
"pagesOnRight",
"=",
"$",
"maxPageNumbers",
"-",
"$",
"pagesOnLeft",
"-",
"1",
";",
"$",
"minPage",
"=",
"$",
"page",
"-",
"$",
"pagesOnLeft",
";",
"$",
"maxPage",
"=",
"$",
"page",
"+",
"$",
"pagesOnRight",
";",
"$",
"firstUrl",
"=",
"false",
";",
"$",
"prevUrl",
"=",
"false",
";",
"$",
"pageLinks",
"=",
"[",
"]",
";",
"$",
"nextUrl",
"=",
"false",
";",
"$",
"lastUrl",
"=",
"false",
";",
"if",
"(",
"$",
"page",
">",
"1",
")",
"{",
"$",
"firstUrl",
"=",
"$",
"this",
"->",
"_getPaginatedUrl",
"(",
"1",
")",
";",
"$",
"prevUrl",
"=",
"$",
"this",
"->",
"_getPaginatedUrl",
"(",
"$",
"page",
"-",
"1",
")",
";",
"}",
"if",
"(",
"$",
"minPage",
"<",
"1",
")",
"{",
"$",
"minPage",
"=",
"1",
";",
"$",
"maxPage",
"=",
"$",
"maxPageNumbers",
";",
"}",
"if",
"(",
"$",
"maxPage",
">",
"$",
"pages",
")",
"{",
"$",
"maxPage",
"=",
"$",
"pages",
";",
"$",
"minPage",
"=",
"$",
"maxPage",
"+",
"1",
"-",
"$",
"maxPageNumbers",
";",
"}",
"if",
"(",
"$",
"minPage",
"<",
"1",
")",
"{",
"$",
"minPage",
"=",
"1",
";",
"}",
"foreach",
"(",
"range",
"(",
"$",
"minPage",
",",
"$",
"maxPage",
")",
"as",
"$",
"p",
")",
"{",
"$",
"link",
"=",
"[",
"'page'",
"=>",
"(",
"int",
")",
"$",
"p",
",",
"'url'",
"=>",
"$",
"this",
"->",
"_getPaginatedUrl",
"(",
"$",
"p",
")",
",",
"'active'",
"=>",
"(",
"(",
"int",
")",
"$",
"p",
"===",
"$",
"page",
")",
"]",
";",
"$",
"pageLinks",
"[",
"]",
"=",
"$",
"link",
";",
"}",
"if",
"(",
"$",
"page",
"<",
"$",
"pages",
")",
"{",
"$",
"nextUrl",
"=",
"$",
"this",
"->",
"_getPaginatedUrl",
"(",
"$",
"page",
"+",
"1",
")",
";",
"$",
"lastUrl",
"=",
"$",
"this",
"->",
"_getPaginatedUrl",
"(",
"$",
"pages",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_View",
"->",
"element",
"(",
"$",
"element",
",",
"[",
"'total'",
"=>",
"$",
"this",
"->",
"paginationParams",
"[",
"'total'",
"]",
",",
"'itemType'",
"=>",
"$",
"itemType",
",",
"'first'",
"=>",
"$",
"firstUrl",
",",
"'prev'",
"=>",
"$",
"prevUrl",
",",
"'pages'",
"=>",
"$",
"pageLinks",
",",
"'next'",
"=>",
"$",
"nextUrl",
",",
"'last'",
"=>",
"$",
"lastUrl",
",",
"'class'",
"=>",
"$",
"class",
",",
"'currentPage'",
"=>",
"$",
"page",
",",
"'baseUrl'",
"=>",
"Router",
"::",
"url",
"(",
"$",
"this",
"->",
"_getFilterUrl",
"(",
"false",
")",
")",
",",
"'from'",
"=>",
"$",
"this",
"->",
"paginationParams",
"[",
"'from'",
"]",
",",
"'to'",
"=>",
"$",
"this",
"->",
"paginationParams",
"[",
"'to'",
"]",
",",
"'nrOfPages'",
"=>",
"$",
"pages",
"]",
")",
";",
"}"
] |
Render the pagination.
@param int $maxPageNumbers The maximum number of pages to show in the link list.
@param string $itemType The item type that is paginated.
@param string $class An optional css class for the pagination.
@param string $element The pagination element to render.
@param array $passParams Optional params passed to the filter urls.
@return string
|
[
"Render",
"the",
"pagination",
"."
] |
539ec2d5c01c9b00766a6db98b60f32832fa5dee
|
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/View/Helper/FilterHelper.php#L142-L204
|
239,776
|
frankfoerster/cakephp-filter
|
src/View/Helper/FilterHelper.php
|
FilterHelper._getFilterUrl
|
protected function _getFilterUrl($withLimit = true)
{
$url = [
'plugin' => $this->request->getParam('plugin'),
'controller' => $this->request->getParam('controller'),
'action' => $this->request->getParam('action'),
];
foreach($this->_passParams as $name => $value) {
$url[$name] = $value;
}
if (!empty($this->request->getParam('sluggedFilter'))) {
$url['sluggedFilter'] = $this->request->getParam('sluggedFilter');
};
$limit = $this->request->getData('l');
if ($withLimit && !empty($limit) && $limit !== $this->paginationParams['defaultLimit']) {
$url['?']['l'] = $limit;
}
return $url;
}
|
php
|
protected function _getFilterUrl($withLimit = true)
{
$url = [
'plugin' => $this->request->getParam('plugin'),
'controller' => $this->request->getParam('controller'),
'action' => $this->request->getParam('action'),
];
foreach($this->_passParams as $name => $value) {
$url[$name] = $value;
}
if (!empty($this->request->getParam('sluggedFilter'))) {
$url['sluggedFilter'] = $this->request->getParam('sluggedFilter');
};
$limit = $this->request->getData('l');
if ($withLimit && !empty($limit) && $limit !== $this->paginationParams['defaultLimit']) {
$url['?']['l'] = $limit;
}
return $url;
}
|
[
"protected",
"function",
"_getFilterUrl",
"(",
"$",
"withLimit",
"=",
"true",
")",
"{",
"$",
"url",
"=",
"[",
"'plugin'",
"=>",
"$",
"this",
"->",
"request",
"->",
"getParam",
"(",
"'plugin'",
")",
",",
"'controller'",
"=>",
"$",
"this",
"->",
"request",
"->",
"getParam",
"(",
"'controller'",
")",
",",
"'action'",
"=>",
"$",
"this",
"->",
"request",
"->",
"getParam",
"(",
"'action'",
")",
",",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"_passParams",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"url",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"request",
"->",
"getParam",
"(",
"'sluggedFilter'",
")",
")",
")",
"{",
"$",
"url",
"[",
"'sluggedFilter'",
"]",
"=",
"$",
"this",
"->",
"request",
"->",
"getParam",
"(",
"'sluggedFilter'",
")",
";",
"}",
";",
"$",
"limit",
"=",
"$",
"this",
"->",
"request",
"->",
"getData",
"(",
"'l'",
")",
";",
"if",
"(",
"$",
"withLimit",
"&&",
"!",
"empty",
"(",
"$",
"limit",
")",
"&&",
"$",
"limit",
"!==",
"$",
"this",
"->",
"paginationParams",
"[",
"'defaultLimit'",
"]",
")",
"{",
"$",
"url",
"[",
"'?'",
"]",
"[",
"'l'",
"]",
"=",
"$",
"limit",
";",
"}",
"return",
"$",
"url",
";",
"}"
] |
Get the filter url.
@param boolean $withLimit
@return array
|
[
"Get",
"the",
"filter",
"url",
"."
] |
539ec2d5c01c9b00766a6db98b60f32832fa5dee
|
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/View/Helper/FilterHelper.php#L296-L319
|
239,777
|
fond-of/active-campaign
|
src/Service/Contact.php
|
Contact.getByEmail
|
public function getByEmail($email)
{
if (!is_string($email) || empty($email)) {
return null;
}
$parameters = array(
'api_action' => 'contact_view_email',
'email' => $email
);
$response = $this->request($parameters);
if ($response === null || $response->getStatusCode() !== 200) {
return null;
}
$json = $response->getBody()->getContents();
return $this->serializer->deserialize(
$this->removeResultInformation($json),
\FondOfPHP\ActiveCampaign\DataTransferObject\Contact::class,
'json'
);
}
|
php
|
public function getByEmail($email)
{
if (!is_string($email) || empty($email)) {
return null;
}
$parameters = array(
'api_action' => 'contact_view_email',
'email' => $email
);
$response = $this->request($parameters);
if ($response === null || $response->getStatusCode() !== 200) {
return null;
}
$json = $response->getBody()->getContents();
return $this->serializer->deserialize(
$this->removeResultInformation($json),
\FondOfPHP\ActiveCampaign\DataTransferObject\Contact::class,
'json'
);
}
|
[
"public",
"function",
"getByEmail",
"(",
"$",
"email",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"email",
")",
"||",
"empty",
"(",
"$",
"email",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"parameters",
"=",
"array",
"(",
"'api_action'",
"=>",
"'contact_view_email'",
",",
"'email'",
"=>",
"$",
"email",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"(",
"$",
"parameters",
")",
";",
"if",
"(",
"$",
"response",
"===",
"null",
"||",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
"!==",
"200",
")",
"{",
"return",
"null",
";",
"}",
"$",
"json",
"=",
"$",
"response",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
";",
"return",
"$",
"this",
"->",
"serializer",
"->",
"deserialize",
"(",
"$",
"this",
"->",
"removeResultInformation",
"(",
"$",
"json",
")",
",",
"\\",
"FondOfPHP",
"\\",
"ActiveCampaign",
"\\",
"DataTransferObject",
"\\",
"Contact",
"::",
"class",
",",
"'json'",
")",
";",
"}"
] |
Retrieve by email
@param $email
@return null|\FondOfPHP\ActiveCampaign\DataTransferObject\Contact
|
[
"Retrieve",
"by",
"email"
] |
389e6c3ca4e39f2f94f92a9673fe3207a9d15807
|
https://github.com/fond-of/active-campaign/blob/389e6c3ca4e39f2f94f92a9673fe3207a9d15807/src/Service/Contact.php#L15-L41
|
239,778
|
asbsoft/yii2-common_2_170212
|
models/QueryTrait.php
|
QueryTrait.hasJoin
|
public function hasJoin($aliasOrTable)
{
if ($this->join) {
foreach ($this->join as $join) {
$secondJoinParam = $join[1];
if (is_array($secondJoinParam)) {
list($key, $val) = each($secondJoinParam);
if ($key == $aliasOrTable) {
return true;
}
}
if (is_string($secondJoinParam)) {
if ($secondJoinParam == $aliasOrTable) {
return true;
} else {
$pos = strrpos($secondJoinParam, ' ');
if ($pos) {
$alias = substr($secondJoinParam, $pos);
$alias = trim($alias, " \t`");
$table = substr($secondJoinParam, 0, $pos);
$table = trim($table);
if ($alias == $aliasOrTable || $table == $aliasOrTable) {
return true;
}
}
}
}
}
}
return false;
}
|
php
|
public function hasJoin($aliasOrTable)
{
if ($this->join) {
foreach ($this->join as $join) {
$secondJoinParam = $join[1];
if (is_array($secondJoinParam)) {
list($key, $val) = each($secondJoinParam);
if ($key == $aliasOrTable) {
return true;
}
}
if (is_string($secondJoinParam)) {
if ($secondJoinParam == $aliasOrTable) {
return true;
} else {
$pos = strrpos($secondJoinParam, ' ');
if ($pos) {
$alias = substr($secondJoinParam, $pos);
$alias = trim($alias, " \t`");
$table = substr($secondJoinParam, 0, $pos);
$table = trim($table);
if ($alias == $aliasOrTable || $table == $aliasOrTable) {
return true;
}
}
}
}
}
}
return false;
}
|
[
"public",
"function",
"hasJoin",
"(",
"$",
"aliasOrTable",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"join",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"join",
"as",
"$",
"join",
")",
"{",
"$",
"secondJoinParam",
"=",
"$",
"join",
"[",
"1",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"secondJoinParam",
")",
")",
"{",
"list",
"(",
"$",
"key",
",",
"$",
"val",
")",
"=",
"each",
"(",
"$",
"secondJoinParam",
")",
";",
"if",
"(",
"$",
"key",
"==",
"$",
"aliasOrTable",
")",
"{",
"return",
"true",
";",
"}",
"}",
"if",
"(",
"is_string",
"(",
"$",
"secondJoinParam",
")",
")",
"{",
"if",
"(",
"$",
"secondJoinParam",
"==",
"$",
"aliasOrTable",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"$",
"pos",
"=",
"strrpos",
"(",
"$",
"secondJoinParam",
",",
"' '",
")",
";",
"if",
"(",
"$",
"pos",
")",
"{",
"$",
"alias",
"=",
"substr",
"(",
"$",
"secondJoinParam",
",",
"$",
"pos",
")",
";",
"$",
"alias",
"=",
"trim",
"(",
"$",
"alias",
",",
"\" \\t`\"",
")",
";",
"$",
"table",
"=",
"substr",
"(",
"$",
"secondJoinParam",
",",
"0",
",",
"$",
"pos",
")",
";",
"$",
"table",
"=",
"trim",
"(",
"$",
"table",
")",
";",
"if",
"(",
"$",
"alias",
"==",
"$",
"aliasOrTable",
"||",
"$",
"table",
"==",
"$",
"aliasOrTable",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Check if join already exists.
Useful to prevent double joins.
@param string $aliasOrTable for alias is string without quotes, for table - in format '{{%tablename}}'
@return bool
|
[
"Check",
"if",
"join",
"already",
"exists",
".",
"Useful",
"to",
"prevent",
"double",
"joins",
"."
] |
6c58012ff89225d7d4e42b200cf39e009e9d9dac
|
https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/models/QueryTrait.php#L17-L48
|
239,779
|
dan-har/presentit
|
src/Resource/Collection.php
|
Collection.transform
|
public function transform()
{
$presentation = [];
if( ! $this->transformer) {
return $presentation;
}
foreach ($this->resource as $key => $resource) {
$presentation[$key] = Item::create($resource)->setTransformer($this->transformer)->transform();
}
return $presentation;
}
|
php
|
public function transform()
{
$presentation = [];
if( ! $this->transformer) {
return $presentation;
}
foreach ($this->resource as $key => $resource) {
$presentation[$key] = Item::create($resource)->setTransformer($this->transformer)->transform();
}
return $presentation;
}
|
[
"public",
"function",
"transform",
"(",
")",
"{",
"$",
"presentation",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"transformer",
")",
"{",
"return",
"$",
"presentation",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"resource",
"as",
"$",
"key",
"=>",
"$",
"resource",
")",
"{",
"$",
"presentation",
"[",
"$",
"key",
"]",
"=",
"Item",
"::",
"create",
"(",
"$",
"resource",
")",
"->",
"setTransformer",
"(",
"$",
"this",
"->",
"transformer",
")",
"->",
"transform",
"(",
")",
";",
"}",
"return",
"$",
"presentation",
";",
"}"
] |
Present each item of the collection using a transformer.
@return array
|
[
"Present",
"each",
"item",
"of",
"the",
"collection",
"using",
"a",
"transformer",
"."
] |
283db977d5b6d91bc2c139ec377c05010935682d
|
https://github.com/dan-har/presentit/blob/283db977d5b6d91bc2c139ec377c05010935682d/src/Resource/Collection.php#L57-L70
|
239,780
|
MichaelJ2324/OO-cURL
|
src/Request/File.php
|
File.configureHTTPMethod
|
protected function configureHTTPMethod($method) {
switch($method){
case self::HTTP_GET:
$this->removeHeader('Content-Type');
break;
case self::HTTP_POST:
case self::HTTP_PUT:
$this->addHeader("Content-Type", "multipart/form-data");
}
return parent::configureHTTPMethod($method);
}
|
php
|
protected function configureHTTPMethod($method) {
switch($method){
case self::HTTP_GET:
$this->removeHeader('Content-Type');
break;
case self::HTTP_POST:
case self::HTTP_PUT:
$this->addHeader("Content-Type", "multipart/form-data");
}
return parent::configureHTTPMethod($method);
}
|
[
"protected",
"function",
"configureHTTPMethod",
"(",
"$",
"method",
")",
"{",
"switch",
"(",
"$",
"method",
")",
"{",
"case",
"self",
"::",
"HTTP_GET",
":",
"$",
"this",
"->",
"removeHeader",
"(",
"'Content-Type'",
")",
";",
"break",
";",
"case",
"self",
"::",
"HTTP_POST",
":",
"case",
"self",
"::",
"HTTP_PUT",
":",
"$",
"this",
"->",
"addHeader",
"(",
"\"Content-Type\"",
",",
"\"multipart/form-data\"",
")",
";",
"}",
"return",
"parent",
"::",
"configureHTTPMethod",
"(",
"$",
"method",
")",
";",
"}"
] |
Configure Headers for File Requests based on HTTP Method
@inheritdoc
|
[
"Configure",
"Headers",
"for",
"File",
"Requests",
"based",
"on",
"HTTP",
"Method"
] |
067a29f7e5fe1941d870819658952be6d4a1f9b4
|
https://github.com/MichaelJ2324/OO-cURL/blob/067a29f7e5fe1941d870819658952be6d4a1f9b4/src/Request/File.php#L30-L40
|
239,781
|
ridvanbaluyos/chikka
|
src/Ridvanbaluyos/Chikka/Chikka.php
|
Chikka._init
|
protected function _init()
{
$this->url = Config::get('chikka::url');
$this->client_id = Config::get('chikka::client_id');
$this->secret_key = Config::get('chikka::secret_key');
$this->short_code = Config::get('chikka::short_code');
}
|
php
|
protected function _init()
{
$this->url = Config::get('chikka::url');
$this->client_id = Config::get('chikka::client_id');
$this->secret_key = Config::get('chikka::secret_key');
$this->short_code = Config::get('chikka::short_code');
}
|
[
"protected",
"function",
"_init",
"(",
")",
"{",
"$",
"this",
"->",
"url",
"=",
"Config",
"::",
"get",
"(",
"'chikka::url'",
")",
";",
"$",
"this",
"->",
"client_id",
"=",
"Config",
"::",
"get",
"(",
"'chikka::client_id'",
")",
";",
"$",
"this",
"->",
"secret_key",
"=",
"Config",
"::",
"get",
"(",
"'chikka::secret_key'",
")",
";",
"$",
"this",
"->",
"short_code",
"=",
"Config",
"::",
"get",
"(",
"'chikka::short_code'",
")",
";",
"}"
] |
Initialise chikka configuration
@return void
|
[
"Initialise",
"chikka",
"configuration"
] |
a8d7e2cdbbb7d0beceb22330d68e979b8801d9af
|
https://github.com/ridvanbaluyos/chikka/blob/a8d7e2cdbbb7d0beceb22330d68e979b8801d9af/src/Ridvanbaluyos/Chikka/Chikka.php#L25-L31
|
239,782
|
faithmade/churchthemes
|
includes/classes/widget.php
|
CTFW_Widget.ctc_sanitize
|
function ctc_sanitize( $instance ) { // prefix in case WP core adds method with same name
global $allowedposttags;
// Array to add sanitized values to
$sanitized_instance = array();
// Loop valid fields to sanitize
$fields = $this->ctc_prepared_fields();
foreach ( $fields as $id => $field ) {
// Get posted value
$input = isset( $instance[$id] ) ? $instance[$id] : '';
// General sanitization
$output = trim( stripslashes( $input ) );
// Sanitize based on type
switch ( $field['type'] ) {
// Text
// Textarea
case 'text':
case 'textarea':
// Strip tags if config does not allow HTML
if ( empty( $field['allow_html'] ) ) {
$output = trim( strip_tags( $output ) );
}
// Sanitize HTML in case used (remove evil tags like script, iframe) - same as post content
$output = stripslashes( wp_filter_post_kses( addslashes( $output ), $allowedposttags ) );
break;
// Checkbox
case 'checkbox':
$output = ! empty( $output ) ? '1' : '';
break;
// Radio
// Select
case 'radio':
case 'select':
// If option invalid, blank it so default will be used
if ( ! isset( $field['options'][$output] ) ) {
$output = '';
}
break;
// Number
case 'number':
// Force number
$output = (int) $output;
// Enforce minimum value
$min = isset( $field['number_min'] ) && '' !== $field['number_min'] ? (int) $field['number_min'] : ''; // force number if set
if ( '' !== $min && $output < $min ) { // allow 0, don't process if no value given ('')
$output = $min;
}
// Enforce maximum value
$max = isset( $field['number_max'] ) && '' !== $field['number_max'] ? (int) $field['number_max'] : ''; // force number if set
if ( '' !== $max && $output > $max ) { // allow 0, don't process if no value given ('')
$output = $max;
}
break;
// URL
case 'url':
$output = esc_url_raw( $output ); // force valid URL or use nothing
break;
// Image
case 'image':
// Sanitize attachment ID
$output = absint( $output );
// Set empty if value is 0, attachment does not exist, or is not an image
if ( empty( $output ) || ! wp_get_attachment_image_src( $output ) ) {
$output = '';
}
break;
}
// Run additional custom sanitization function if field config requires it
if ( ! empty( $field['custom_sanitize'] ) ) {
$output = call_user_func( $field['custom_sanitize'], $output );
}
// Sanitization left value empty, use default if empty not allowed
$output = trim( $output );
if ( empty( $output ) && ! empty( $field['default'] ) && ! empty( $field['no_empty'] ) ) {
$output = $field['default'];
}
// Add output to instance array
$sanitized_instance[$id] = $output;
}
// Return for saving
return $sanitized_instance;
}
|
php
|
function ctc_sanitize( $instance ) { // prefix in case WP core adds method with same name
global $allowedposttags;
// Array to add sanitized values to
$sanitized_instance = array();
// Loop valid fields to sanitize
$fields = $this->ctc_prepared_fields();
foreach ( $fields as $id => $field ) {
// Get posted value
$input = isset( $instance[$id] ) ? $instance[$id] : '';
// General sanitization
$output = trim( stripslashes( $input ) );
// Sanitize based on type
switch ( $field['type'] ) {
// Text
// Textarea
case 'text':
case 'textarea':
// Strip tags if config does not allow HTML
if ( empty( $field['allow_html'] ) ) {
$output = trim( strip_tags( $output ) );
}
// Sanitize HTML in case used (remove evil tags like script, iframe) - same as post content
$output = stripslashes( wp_filter_post_kses( addslashes( $output ), $allowedposttags ) );
break;
// Checkbox
case 'checkbox':
$output = ! empty( $output ) ? '1' : '';
break;
// Radio
// Select
case 'radio':
case 'select':
// If option invalid, blank it so default will be used
if ( ! isset( $field['options'][$output] ) ) {
$output = '';
}
break;
// Number
case 'number':
// Force number
$output = (int) $output;
// Enforce minimum value
$min = isset( $field['number_min'] ) && '' !== $field['number_min'] ? (int) $field['number_min'] : ''; // force number if set
if ( '' !== $min && $output < $min ) { // allow 0, don't process if no value given ('')
$output = $min;
}
// Enforce maximum value
$max = isset( $field['number_max'] ) && '' !== $field['number_max'] ? (int) $field['number_max'] : ''; // force number if set
if ( '' !== $max && $output > $max ) { // allow 0, don't process if no value given ('')
$output = $max;
}
break;
// URL
case 'url':
$output = esc_url_raw( $output ); // force valid URL or use nothing
break;
// Image
case 'image':
// Sanitize attachment ID
$output = absint( $output );
// Set empty if value is 0, attachment does not exist, or is not an image
if ( empty( $output ) || ! wp_get_attachment_image_src( $output ) ) {
$output = '';
}
break;
}
// Run additional custom sanitization function if field config requires it
if ( ! empty( $field['custom_sanitize'] ) ) {
$output = call_user_func( $field['custom_sanitize'], $output );
}
// Sanitization left value empty, use default if empty not allowed
$output = trim( $output );
if ( empty( $output ) && ! empty( $field['default'] ) && ! empty( $field['no_empty'] ) ) {
$output = $field['default'];
}
// Add output to instance array
$sanitized_instance[$id] = $output;
}
// Return for saving
return $sanitized_instance;
}
|
[
"function",
"ctc_sanitize",
"(",
"$",
"instance",
")",
"{",
"// prefix in case WP core adds method with same name",
"global",
"$",
"allowedposttags",
";",
"// Array to add sanitized values to",
"$",
"sanitized_instance",
"=",
"array",
"(",
")",
";",
"// Loop valid fields to sanitize",
"$",
"fields",
"=",
"$",
"this",
"->",
"ctc_prepared_fields",
"(",
")",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"id",
"=>",
"$",
"field",
")",
"{",
"// Get posted value",
"$",
"input",
"=",
"isset",
"(",
"$",
"instance",
"[",
"$",
"id",
"]",
")",
"?",
"$",
"instance",
"[",
"$",
"id",
"]",
":",
"''",
";",
"// General sanitization",
"$",
"output",
"=",
"trim",
"(",
"stripslashes",
"(",
"$",
"input",
")",
")",
";",
"// Sanitize based on type",
"switch",
"(",
"$",
"field",
"[",
"'type'",
"]",
")",
"{",
"// Text",
"// Textarea",
"case",
"'text'",
":",
"case",
"'textarea'",
":",
"// Strip tags if config does not allow HTML",
"if",
"(",
"empty",
"(",
"$",
"field",
"[",
"'allow_html'",
"]",
")",
")",
"{",
"$",
"output",
"=",
"trim",
"(",
"strip_tags",
"(",
"$",
"output",
")",
")",
";",
"}",
"// Sanitize HTML in case used (remove evil tags like script, iframe) - same as post content",
"$",
"output",
"=",
"stripslashes",
"(",
"wp_filter_post_kses",
"(",
"addslashes",
"(",
"$",
"output",
")",
",",
"$",
"allowedposttags",
")",
")",
";",
"break",
";",
"// Checkbox",
"case",
"'checkbox'",
":",
"$",
"output",
"=",
"!",
"empty",
"(",
"$",
"output",
")",
"?",
"'1'",
":",
"''",
";",
"break",
";",
"// Radio",
"// Select",
"case",
"'radio'",
":",
"case",
"'select'",
":",
"// If option invalid, blank it so default will be used",
"if",
"(",
"!",
"isset",
"(",
"$",
"field",
"[",
"'options'",
"]",
"[",
"$",
"output",
"]",
")",
")",
"{",
"$",
"output",
"=",
"''",
";",
"}",
"break",
";",
"// Number",
"case",
"'number'",
":",
"// Force number",
"$",
"output",
"=",
"(",
"int",
")",
"$",
"output",
";",
"// Enforce minimum value",
"$",
"min",
"=",
"isset",
"(",
"$",
"field",
"[",
"'number_min'",
"]",
")",
"&&",
"''",
"!==",
"$",
"field",
"[",
"'number_min'",
"]",
"?",
"(",
"int",
")",
"$",
"field",
"[",
"'number_min'",
"]",
":",
"''",
";",
"// force number if set",
"if",
"(",
"''",
"!==",
"$",
"min",
"&&",
"$",
"output",
"<",
"$",
"min",
")",
"{",
"// allow 0, don't process if no value given ('')",
"$",
"output",
"=",
"$",
"min",
";",
"}",
"// Enforce maximum value",
"$",
"max",
"=",
"isset",
"(",
"$",
"field",
"[",
"'number_max'",
"]",
")",
"&&",
"''",
"!==",
"$",
"field",
"[",
"'number_max'",
"]",
"?",
"(",
"int",
")",
"$",
"field",
"[",
"'number_max'",
"]",
":",
"''",
";",
"// force number if set",
"if",
"(",
"''",
"!==",
"$",
"max",
"&&",
"$",
"output",
">",
"$",
"max",
")",
"{",
"// allow 0, don't process if no value given ('')",
"$",
"output",
"=",
"$",
"max",
";",
"}",
"break",
";",
"// URL",
"case",
"'url'",
":",
"$",
"output",
"=",
"esc_url_raw",
"(",
"$",
"output",
")",
";",
"// force valid URL or use nothing",
"break",
";",
"// Image",
"case",
"'image'",
":",
"// Sanitize attachment ID",
"$",
"output",
"=",
"absint",
"(",
"$",
"output",
")",
";",
"// Set empty if value is 0, attachment does not exist, or is not an image",
"if",
"(",
"empty",
"(",
"$",
"output",
")",
"||",
"!",
"wp_get_attachment_image_src",
"(",
"$",
"output",
")",
")",
"{",
"$",
"output",
"=",
"''",
";",
"}",
"break",
";",
"}",
"// Run additional custom sanitization function if field config requires it",
"if",
"(",
"!",
"empty",
"(",
"$",
"field",
"[",
"'custom_sanitize'",
"]",
")",
")",
"{",
"$",
"output",
"=",
"call_user_func",
"(",
"$",
"field",
"[",
"'custom_sanitize'",
"]",
",",
"$",
"output",
")",
";",
"}",
"// Sanitization left value empty, use default if empty not allowed",
"$",
"output",
"=",
"trim",
"(",
"$",
"output",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"output",
")",
"&&",
"!",
"empty",
"(",
"$",
"field",
"[",
"'default'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"field",
"[",
"'no_empty'",
"]",
")",
")",
"{",
"$",
"output",
"=",
"$",
"field",
"[",
"'default'",
"]",
";",
"}",
"// Add output to instance array",
"$",
"sanitized_instance",
"[",
"$",
"id",
"]",
"=",
"$",
"output",
";",
"}",
"// Return for saving",
"return",
"$",
"sanitized_instance",
";",
"}"
] |
Sanitize field values
Used before saving and before providing instance to widget template.
@since 0.9
@param array $instance Widget instance
@return array Sanitized instance
|
[
"Sanitize",
"field",
"values"
] |
b121e840edaec8fdb3189fc9324cc88d7a0db81c
|
https://github.com/faithmade/churchthemes/blob/b121e840edaec8fdb3189fc9324cc88d7a0db81c/includes/classes/widget.php#L363-L478
|
239,783
|
faithmade/churchthemes
|
includes/classes/widget.php
|
CTFW_Widget.widget
|
function widget( $args, $instance ) {
global $post; // setup_postdata() needs this
// Available widgets
$widgets = ChurchThemeFrameworkWidgets::widgetList();
// Get template filename
$template_file = $widgets[$this->id_base]['template_file'];
// Check if template exists
$template_path = CTFW_WIDGETS_WIDGET_TEMPLATE_DIR . '/' . $template_file;
// Sanitize widget instance (field values) before loading template
$instance = $this->ctc_sanitize( $instance );
// Make instance available to other methods used by template (e.g. get_posts())
$this->ctc_instance = $instance;
if( file_exists( $template_path ) ){
include $template_path;
}
}
|
php
|
function widget( $args, $instance ) {
global $post; // setup_postdata() needs this
// Available widgets
$widgets = ChurchThemeFrameworkWidgets::widgetList();
// Get template filename
$template_file = $widgets[$this->id_base]['template_file'];
// Check if template exists
$template_path = CTFW_WIDGETS_WIDGET_TEMPLATE_DIR . '/' . $template_file;
// Sanitize widget instance (field values) before loading template
$instance = $this->ctc_sanitize( $instance );
// Make instance available to other methods used by template (e.g. get_posts())
$this->ctc_instance = $instance;
if( file_exists( $template_path ) ){
include $template_path;
}
}
|
[
"function",
"widget",
"(",
"$",
"args",
",",
"$",
"instance",
")",
"{",
"global",
"$",
"post",
";",
"// setup_postdata() needs this",
"// Available widgets",
"$",
"widgets",
"=",
"ChurchThemeFrameworkWidgets",
"::",
"widgetList",
"(",
")",
";",
"// Get template filename",
"$",
"template_file",
"=",
"$",
"widgets",
"[",
"$",
"this",
"->",
"id_base",
"]",
"[",
"'template_file'",
"]",
";",
"// Check if template exists",
"$",
"template_path",
"=",
"CTFW_WIDGETS_WIDGET_TEMPLATE_DIR",
".",
"'/'",
".",
"$",
"template_file",
";",
"// Sanitize widget instance (field values) before loading template",
"$",
"instance",
"=",
"$",
"this",
"->",
"ctc_sanitize",
"(",
"$",
"instance",
")",
";",
"// Make instance available to other methods used by template (e.g. get_posts())",
"$",
"this",
"->",
"ctc_instance",
"=",
"$",
"instance",
";",
"if",
"(",
"file_exists",
"(",
"$",
"template_path",
")",
")",
"{",
"include",
"$",
"template_path",
";",
"}",
"}"
] |
Front-end display of widget
Load template from parent or child theme if exists.
@since 0.9
@param array $args Widget arguments
@param array $instance Widget instance
|
[
"Front",
"-",
"end",
"display",
"of",
"widget"
] |
b121e840edaec8fdb3189fc9324cc88d7a0db81c
|
https://github.com/faithmade/churchthemes/blob/b121e840edaec8fdb3189fc9324cc88d7a0db81c/includes/classes/widget.php#L507-L531
|
239,784
|
vworldat/MenuBundle
|
Menu/Menu.php
|
Menu.initialize
|
protected function initialize()
{
$itemData = $this->getItemData();
$itemsMerged = array();
foreach ($itemData as $key => $itemOptions)
{
$itemsMerged[$key] = array_merge($this->defaults, $itemOptions);
if (isset($itemsMerged[$key]['children']['.defaults']))
{
$itemsMerged[$key]['children']['.defaults'] = array_merge($this->defaults, $itemsMerged[$key]['children']['.defaults']);
}
else
{
$itemsMerged[$key]['children']['.defaults'] = $this->defaults;
}
}
$this->baseItem = $this->createItem('', array(
'title' => '',
'item_class' => 'C33s\MenuBundle\Item\MenuItem',
'children' => $itemsMerged,
));
}
|
php
|
protected function initialize()
{
$itemData = $this->getItemData();
$itemsMerged = array();
foreach ($itemData as $key => $itemOptions)
{
$itemsMerged[$key] = array_merge($this->defaults, $itemOptions);
if (isset($itemsMerged[$key]['children']['.defaults']))
{
$itemsMerged[$key]['children']['.defaults'] = array_merge($this->defaults, $itemsMerged[$key]['children']['.defaults']);
}
else
{
$itemsMerged[$key]['children']['.defaults'] = $this->defaults;
}
}
$this->baseItem = $this->createItem('', array(
'title' => '',
'item_class' => 'C33s\MenuBundle\Item\MenuItem',
'children' => $itemsMerged,
));
}
|
[
"protected",
"function",
"initialize",
"(",
")",
"{",
"$",
"itemData",
"=",
"$",
"this",
"->",
"getItemData",
"(",
")",
";",
"$",
"itemsMerged",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"itemData",
"as",
"$",
"key",
"=>",
"$",
"itemOptions",
")",
"{",
"$",
"itemsMerged",
"[",
"$",
"key",
"]",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"defaults",
",",
"$",
"itemOptions",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"itemsMerged",
"[",
"$",
"key",
"]",
"[",
"'children'",
"]",
"[",
"'.defaults'",
"]",
")",
")",
"{",
"$",
"itemsMerged",
"[",
"$",
"key",
"]",
"[",
"'children'",
"]",
"[",
"'.defaults'",
"]",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"defaults",
",",
"$",
"itemsMerged",
"[",
"$",
"key",
"]",
"[",
"'children'",
"]",
"[",
"'.defaults'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"itemsMerged",
"[",
"$",
"key",
"]",
"[",
"'children'",
"]",
"[",
"'.defaults'",
"]",
"=",
"$",
"this",
"->",
"defaults",
";",
"}",
"}",
"$",
"this",
"->",
"baseItem",
"=",
"$",
"this",
"->",
"createItem",
"(",
"''",
",",
"array",
"(",
"'title'",
"=>",
"''",
",",
"'item_class'",
"=>",
"'C33s\\MenuBundle\\Item\\MenuItem'",
",",
"'children'",
"=>",
"$",
"itemsMerged",
",",
")",
")",
";",
"}"
] |
Initialize base menu item and its children
|
[
"Initialize",
"base",
"menu",
"item",
"and",
"its",
"children"
] |
136e5ee859c3be95a199a7207fa5aacc5ccb26ec
|
https://github.com/vworldat/MenuBundle/blob/136e5ee859c3be95a199a7207fa5aacc5ccb26ec/Menu/Menu.php#L89-L113
|
239,785
|
vworldat/MenuBundle
|
Menu/Menu.php
|
Menu.createItem
|
public function createItem($itemRouteName, array $itemOptions)
{
if (isset($itemOptions['item_class']))
{
$class = $itemOptions['item_class'];
}
else
{
$class = $this->getDefaultItemClass();
}
if (isset($this->itemClassAliases[$class]))
{
$class = $this->itemClassAliases[$class];
}
if (!$this->isValidMenuItemClass($class))
{
throw new NoMenuItemClassException(sprintf('Item class %s does not extend \C33s\MenuBundle\Item\MenuItem', $itemOptions['item_class']));
}
$item = new $class($itemRouteName, $itemOptions, $this);
return $item;
}
|
php
|
public function createItem($itemRouteName, array $itemOptions)
{
if (isset($itemOptions['item_class']))
{
$class = $itemOptions['item_class'];
}
else
{
$class = $this->getDefaultItemClass();
}
if (isset($this->itemClassAliases[$class]))
{
$class = $this->itemClassAliases[$class];
}
if (!$this->isValidMenuItemClass($class))
{
throw new NoMenuItemClassException(sprintf('Item class %s does not extend \C33s\MenuBundle\Item\MenuItem', $itemOptions['item_class']));
}
$item = new $class($itemRouteName, $itemOptions, $this);
return $item;
}
|
[
"public",
"function",
"createItem",
"(",
"$",
"itemRouteName",
",",
"array",
"$",
"itemOptions",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"itemOptions",
"[",
"'item_class'",
"]",
")",
")",
"{",
"$",
"class",
"=",
"$",
"itemOptions",
"[",
"'item_class'",
"]",
";",
"}",
"else",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"getDefaultItemClass",
"(",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"itemClassAliases",
"[",
"$",
"class",
"]",
")",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"itemClassAliases",
"[",
"$",
"class",
"]",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isValidMenuItemClass",
"(",
"$",
"class",
")",
")",
"{",
"throw",
"new",
"NoMenuItemClassException",
"(",
"sprintf",
"(",
"'Item class %s does not extend \\C33s\\MenuBundle\\Item\\MenuItem'",
",",
"$",
"itemOptions",
"[",
"'item_class'",
"]",
")",
")",
";",
"}",
"$",
"item",
"=",
"new",
"$",
"class",
"(",
"$",
"itemRouteName",
",",
"$",
"itemOptions",
",",
"$",
"this",
")",
";",
"return",
"$",
"item",
";",
"}"
] |
MenuItem factory method.
@param string $itemRouteName
@param array $itemOptions
@throws NoMenuItemClassException
@return MenuItem
|
[
"MenuItem",
"factory",
"method",
"."
] |
136e5ee859c3be95a199a7207fa5aacc5ccb26ec
|
https://github.com/vworldat/MenuBundle/blob/136e5ee859c3be95a199a7207fa5aacc5ccb26ec/Menu/Menu.php#L124-L148
|
239,786
|
vworldat/MenuBundle
|
Menu/Menu.php
|
Menu.getBreadcrumbItems
|
public function getBreadcrumbItems()
{
$item = $this->getBaseItem();
$items = array();
while ($current = $item->getCurrentChild())
{
$items[] = $current;
$item = $current;
}
return $items;
}
|
php
|
public function getBreadcrumbItems()
{
$item = $this->getBaseItem();
$items = array();
while ($current = $item->getCurrentChild())
{
$items[] = $current;
$item = $current;
}
return $items;
}
|
[
"public",
"function",
"getBreadcrumbItems",
"(",
")",
"{",
"$",
"item",
"=",
"$",
"this",
"->",
"getBaseItem",
"(",
")",
";",
"$",
"items",
"=",
"array",
"(",
")",
";",
"while",
"(",
"$",
"current",
"=",
"$",
"item",
"->",
"getCurrentChild",
"(",
")",
")",
"{",
"$",
"items",
"[",
"]",
"=",
"$",
"current",
";",
"$",
"item",
"=",
"$",
"current",
";",
"}",
"return",
"$",
"items",
";",
"}"
] |
Get all items on the current item's path, starting with the lowest. Useful for breadcrumb rendering.
@return array
|
[
"Get",
"all",
"items",
"on",
"the",
"current",
"item",
"s",
"path",
"starting",
"with",
"the",
"lowest",
".",
"Useful",
"for",
"breadcrumb",
"rendering",
"."
] |
136e5ee859c3be95a199a7207fa5aacc5ccb26ec
|
https://github.com/vworldat/MenuBundle/blob/136e5ee859c3be95a199a7207fa5aacc5ccb26ec/Menu/Menu.php#L181-L194
|
239,787
|
vworldat/MenuBundle
|
Menu/Menu.php
|
Menu.isValidMenuItemClass
|
protected function isValidMenuItemClass($className)
{
if (!isset($this->checkedClasses[$className]))
{
$this->checkedClasses[$className] = $this->hasParentClass($className, 'C33s\\MenuBundle\\Item\\MenuItem');
}
return $this->checkedClasses[$className];
}
|
php
|
protected function isValidMenuItemClass($className)
{
if (!isset($this->checkedClasses[$className]))
{
$this->checkedClasses[$className] = $this->hasParentClass($className, 'C33s\\MenuBundle\\Item\\MenuItem');
}
return $this->checkedClasses[$className];
}
|
[
"protected",
"function",
"isValidMenuItemClass",
"(",
"$",
"className",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"checkedClasses",
"[",
"$",
"className",
"]",
")",
")",
"{",
"$",
"this",
"->",
"checkedClasses",
"[",
"$",
"className",
"]",
"=",
"$",
"this",
"->",
"hasParentClass",
"(",
"$",
"className",
",",
"'C33s\\\\MenuBundle\\\\Item\\\\MenuItem'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"checkedClasses",
"[",
"$",
"className",
"]",
";",
"}"
] |
Check if the given class is a valid MenuItem class.
@param string $className
@return boolean
|
[
"Check",
"if",
"the",
"given",
"class",
"is",
"a",
"valid",
"MenuItem",
"class",
"."
] |
136e5ee859c3be95a199a7207fa5aacc5ccb26ec
|
https://github.com/vworldat/MenuBundle/blob/136e5ee859c3be95a199a7207fa5aacc5ccb26ec/Menu/Menu.php#L228-L236
|
239,788
|
teamelf/core
|
src/Application/Server.php
|
Server.boot
|
protected function boot(): void
{
// boot extensions
foreach ($this->extensionManager->getExtensions() as $extension) {
if ($extension->isActivated()) {
$extension->boot();
}
}
// boot app
$this->dispatch(new RoutesWillBeLoaded($this->router));
$this->dispatch(new RoutesHaveBeenLoaded($this->router));
// send back responses
try {
$response = $this->router->getResponse();
$response->send();
} catch (RouteNotFoundException $exception) {
throw new HttpNotFoundException();
} catch (ResourceNotFoundException $exception) {
throw new HttpNotFoundException();
} catch (MethodNotAllowedException $exception) {
throw new HttpMethodNotAllowedException();
}
}
|
php
|
protected function boot(): void
{
// boot extensions
foreach ($this->extensionManager->getExtensions() as $extension) {
if ($extension->isActivated()) {
$extension->boot();
}
}
// boot app
$this->dispatch(new RoutesWillBeLoaded($this->router));
$this->dispatch(new RoutesHaveBeenLoaded($this->router));
// send back responses
try {
$response = $this->router->getResponse();
$response->send();
} catch (RouteNotFoundException $exception) {
throw new HttpNotFoundException();
} catch (ResourceNotFoundException $exception) {
throw new HttpNotFoundException();
} catch (MethodNotAllowedException $exception) {
throw new HttpMethodNotAllowedException();
}
}
|
[
"protected",
"function",
"boot",
"(",
")",
":",
"void",
"{",
"// boot extensions",
"foreach",
"(",
"$",
"this",
"->",
"extensionManager",
"->",
"getExtensions",
"(",
")",
"as",
"$",
"extension",
")",
"{",
"if",
"(",
"$",
"extension",
"->",
"isActivated",
"(",
")",
")",
"{",
"$",
"extension",
"->",
"boot",
"(",
")",
";",
"}",
"}",
"// boot app",
"$",
"this",
"->",
"dispatch",
"(",
"new",
"RoutesWillBeLoaded",
"(",
"$",
"this",
"->",
"router",
")",
")",
";",
"$",
"this",
"->",
"dispatch",
"(",
"new",
"RoutesHaveBeenLoaded",
"(",
"$",
"this",
"->",
"router",
")",
")",
";",
"// send back responses",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"router",
"->",
"getResponse",
"(",
")",
";",
"$",
"response",
"->",
"send",
"(",
")",
";",
"}",
"catch",
"(",
"RouteNotFoundException",
"$",
"exception",
")",
"{",
"throw",
"new",
"HttpNotFoundException",
"(",
")",
";",
"}",
"catch",
"(",
"ResourceNotFoundException",
"$",
"exception",
")",
"{",
"throw",
"new",
"HttpNotFoundException",
"(",
")",
";",
"}",
"catch",
"(",
"MethodNotAllowedException",
"$",
"exception",
")",
"{",
"throw",
"new",
"HttpMethodNotAllowedException",
"(",
")",
";",
"}",
"}"
] |
boot all services
@throws HttpMethodNotAllowedException
@throws HttpNotFoundException
|
[
"boot",
"all",
"services"
] |
653fc6e27f42239c2a8998a5fea325480e9dd39e
|
https://github.com/teamelf/core/blob/653fc6e27f42239c2a8998a5fea325480e9dd39e/src/Application/Server.php#L66-L90
|
239,789
|
rodchyn/elephant-lang
|
lib/ParserGenerator/PHP/ParserGenerator/Action.php
|
PHP_ParserGenerator_Action.actioncmp
|
static function actioncmp(PHP_ParserGenerator_Action $ap1, PHP_ParserGenerator_Action $ap2)
{
$rc = $ap1->sp->index - $ap2->sp->index;
if ($rc === 0) {
$rc = $ap1->type - $ap2->type;
}
if ($rc === 0) {
if ($ap1->type == self::SHIFT) {
if ($ap1->x->statenum != $ap2->x->statenum) {
throw new Exception('Shift conflict: ' . $ap1->sp->name .
' shifts both to state ' . $ap1->x->statenum . ' (rule ' .
$ap1->x->cfp->rp->lhs->name . ' on line ' .
$ap1->x->cfp->rp->ruleline . ') and to state ' .
$ap2->x->statenum . ' (rule ' .
$ap2->x->cfp->rp->lhs->name . ' on line ' .
$ap2->x->cfp->rp->ruleline . ')');
}
}
if ($ap1->type != self::REDUCE
&& $ap1->type != self::RD_RESOLVED
&& $ap1->type != self::CONFLICT
) {
throw new Exception('action has not been processed: ' .
$ap1->sp->name . ' on line ' . $ap1->x->cfp->rp->ruleline .
', rule ' . $ap1->x->cfp->rp->lhs->name);
}
if ($ap2->type != self::REDUCE
&& $ap2->type != self::RD_RESOLVED
&& $ap2->type != self::CONFLICT
) {
throw new Exception('action has not been processed: ' .
$ap2->sp->name . ' on line ' . $ap2->x->cfp->rp->ruleline .
', rule ' . $ap2->x->cfp->rp->lhs->name);
}
$rc = $ap1->x->index - $ap2->x->index;
}
return $rc;
}
|
php
|
static function actioncmp(PHP_ParserGenerator_Action $ap1, PHP_ParserGenerator_Action $ap2)
{
$rc = $ap1->sp->index - $ap2->sp->index;
if ($rc === 0) {
$rc = $ap1->type - $ap2->type;
}
if ($rc === 0) {
if ($ap1->type == self::SHIFT) {
if ($ap1->x->statenum != $ap2->x->statenum) {
throw new Exception('Shift conflict: ' . $ap1->sp->name .
' shifts both to state ' . $ap1->x->statenum . ' (rule ' .
$ap1->x->cfp->rp->lhs->name . ' on line ' .
$ap1->x->cfp->rp->ruleline . ') and to state ' .
$ap2->x->statenum . ' (rule ' .
$ap2->x->cfp->rp->lhs->name . ' on line ' .
$ap2->x->cfp->rp->ruleline . ')');
}
}
if ($ap1->type != self::REDUCE
&& $ap1->type != self::RD_RESOLVED
&& $ap1->type != self::CONFLICT
) {
throw new Exception('action has not been processed: ' .
$ap1->sp->name . ' on line ' . $ap1->x->cfp->rp->ruleline .
', rule ' . $ap1->x->cfp->rp->lhs->name);
}
if ($ap2->type != self::REDUCE
&& $ap2->type != self::RD_RESOLVED
&& $ap2->type != self::CONFLICT
) {
throw new Exception('action has not been processed: ' .
$ap2->sp->name . ' on line ' . $ap2->x->cfp->rp->ruleline .
', rule ' . $ap2->x->cfp->rp->lhs->name);
}
$rc = $ap1->x->index - $ap2->x->index;
}
return $rc;
}
|
[
"static",
"function",
"actioncmp",
"(",
"PHP_ParserGenerator_Action",
"$",
"ap1",
",",
"PHP_ParserGenerator_Action",
"$",
"ap2",
")",
"{",
"$",
"rc",
"=",
"$",
"ap1",
"->",
"sp",
"->",
"index",
"-",
"$",
"ap2",
"->",
"sp",
"->",
"index",
";",
"if",
"(",
"$",
"rc",
"===",
"0",
")",
"{",
"$",
"rc",
"=",
"$",
"ap1",
"->",
"type",
"-",
"$",
"ap2",
"->",
"type",
";",
"}",
"if",
"(",
"$",
"rc",
"===",
"0",
")",
"{",
"if",
"(",
"$",
"ap1",
"->",
"type",
"==",
"self",
"::",
"SHIFT",
")",
"{",
"if",
"(",
"$",
"ap1",
"->",
"x",
"->",
"statenum",
"!=",
"$",
"ap2",
"->",
"x",
"->",
"statenum",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Shift conflict: '",
".",
"$",
"ap1",
"->",
"sp",
"->",
"name",
".",
"' shifts both to state '",
".",
"$",
"ap1",
"->",
"x",
"->",
"statenum",
".",
"' (rule '",
".",
"$",
"ap1",
"->",
"x",
"->",
"cfp",
"->",
"rp",
"->",
"lhs",
"->",
"name",
".",
"' on line '",
".",
"$",
"ap1",
"->",
"x",
"->",
"cfp",
"->",
"rp",
"->",
"ruleline",
".",
"') and to state '",
".",
"$",
"ap2",
"->",
"x",
"->",
"statenum",
".",
"' (rule '",
".",
"$",
"ap2",
"->",
"x",
"->",
"cfp",
"->",
"rp",
"->",
"lhs",
"->",
"name",
".",
"' on line '",
".",
"$",
"ap2",
"->",
"x",
"->",
"cfp",
"->",
"rp",
"->",
"ruleline",
".",
"')'",
")",
";",
"}",
"}",
"if",
"(",
"$",
"ap1",
"->",
"type",
"!=",
"self",
"::",
"REDUCE",
"&&",
"$",
"ap1",
"->",
"type",
"!=",
"self",
"::",
"RD_RESOLVED",
"&&",
"$",
"ap1",
"->",
"type",
"!=",
"self",
"::",
"CONFLICT",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'action has not been processed: '",
".",
"$",
"ap1",
"->",
"sp",
"->",
"name",
".",
"' on line '",
".",
"$",
"ap1",
"->",
"x",
"->",
"cfp",
"->",
"rp",
"->",
"ruleline",
".",
"', rule '",
".",
"$",
"ap1",
"->",
"x",
"->",
"cfp",
"->",
"rp",
"->",
"lhs",
"->",
"name",
")",
";",
"}",
"if",
"(",
"$",
"ap2",
"->",
"type",
"!=",
"self",
"::",
"REDUCE",
"&&",
"$",
"ap2",
"->",
"type",
"!=",
"self",
"::",
"RD_RESOLVED",
"&&",
"$",
"ap2",
"->",
"type",
"!=",
"self",
"::",
"CONFLICT",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'action has not been processed: '",
".",
"$",
"ap2",
"->",
"sp",
"->",
"name",
".",
"' on line '",
".",
"$",
"ap2",
"->",
"x",
"->",
"cfp",
"->",
"rp",
"->",
"ruleline",
".",
"', rule '",
".",
"$",
"ap2",
"->",
"x",
"->",
"cfp",
"->",
"rp",
"->",
"lhs",
"->",
"name",
")",
";",
"}",
"$",
"rc",
"=",
"$",
"ap1",
"->",
"x",
"->",
"index",
"-",
"$",
"ap2",
"->",
"x",
"->",
"index",
";",
"}",
"return",
"$",
"rc",
";",
"}"
] |
Compare two actions
This is used by {@link Action_sort()} to compare actions
|
[
"Compare",
"two",
"actions"
] |
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
|
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/PHP/ParserGenerator/Action.php#L122-L159
|
239,790
|
rodchyn/elephant-lang
|
lib/ParserGenerator/PHP/ParserGenerator/Action.php
|
PHP_ParserGenerator_Action.Action_add
|
static function Action_add(&$app, $type, PHP_ParserGenerator_Symbol $sp, $arg)
{
$new = new PHP_ParserGenerator_Action;
$new->next = $app;
$app = $new;
$new->type = $type;
$new->sp = $sp;
$new->x = $arg;
echo ' Adding ';
$new->display();
}
|
php
|
static function Action_add(&$app, $type, PHP_ParserGenerator_Symbol $sp, $arg)
{
$new = new PHP_ParserGenerator_Action;
$new->next = $app;
$app = $new;
$new->type = $type;
$new->sp = $sp;
$new->x = $arg;
echo ' Adding ';
$new->display();
}
|
[
"static",
"function",
"Action_add",
"(",
"&",
"$",
"app",
",",
"$",
"type",
",",
"PHP_ParserGenerator_Symbol",
"$",
"sp",
",",
"$",
"arg",
")",
"{",
"$",
"new",
"=",
"new",
"PHP_ParserGenerator_Action",
";",
"$",
"new",
"->",
"next",
"=",
"$",
"app",
";",
"$",
"app",
"=",
"$",
"new",
";",
"$",
"new",
"->",
"type",
"=",
"$",
"type",
";",
"$",
"new",
"->",
"sp",
"=",
"$",
"sp",
";",
"$",
"new",
"->",
"x",
"=",
"$",
"arg",
";",
"echo",
"' Adding '",
";",
"$",
"new",
"->",
"display",
"(",
")",
";",
"}"
] |
create linked list of PHP_ParserGenerator_Actions
@param PHP_ParserGenerator_Action|null $app
@param int $type one of the class constants from PHP_ParserGenerator_Action
@param PHP_ParserGenerator_Symbol $sp
@param PHP_ParserGenerator_State|PHP_ParserGenerator_Rule $arg
|
[
"create",
"linked",
"list",
"of",
"PHP_ParserGenerator_Actions"
] |
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
|
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/PHP/ParserGenerator/Action.php#L187-L197
|
239,791
|
rodchyn/elephant-lang
|
lib/ParserGenerator/PHP/ParserGenerator/Action.php
|
PHP_ParserGenerator_Action.PrintAction
|
function PrintAction($fp, $indent)
{
if (!$fp) {
$fp = STDOUT;
}
$result = 1;
switch ($this->type)
{
case self::SHIFT:
fprintf($fp, "%${indent}s shift %d", $this->sp->name, $this->x->statenum);
break;
case self::REDUCE:
fprintf($fp, "%${indent}s reduce %d", $this->sp->name, $this->x->index);
break;
case self::ACCEPT:
fprintf($fp, "%${indent}s accept", $this->sp->name);
break;
case self::ERROR:
fprintf($fp, "%${indent}s error", $this->sp->name);
break;
case self::CONFLICT:
fprintf($fp, "%${indent}s reduce %-3d ** Parsing conflict **", $this->sp->name, $this->x->index);
break;
case self::SH_RESOLVED:
case self::RD_RESOLVED:
case self::NOT_USED:
$result = 0;
break;
}
return $result;
}
|
php
|
function PrintAction($fp, $indent)
{
if (!$fp) {
$fp = STDOUT;
}
$result = 1;
switch ($this->type)
{
case self::SHIFT:
fprintf($fp, "%${indent}s shift %d", $this->sp->name, $this->x->statenum);
break;
case self::REDUCE:
fprintf($fp, "%${indent}s reduce %d", $this->sp->name, $this->x->index);
break;
case self::ACCEPT:
fprintf($fp, "%${indent}s accept", $this->sp->name);
break;
case self::ERROR:
fprintf($fp, "%${indent}s error", $this->sp->name);
break;
case self::CONFLICT:
fprintf($fp, "%${indent}s reduce %-3d ** Parsing conflict **", $this->sp->name, $this->x->index);
break;
case self::SH_RESOLVED:
case self::RD_RESOLVED:
case self::NOT_USED:
$result = 0;
break;
}
return $result;
}
|
[
"function",
"PrintAction",
"(",
"$",
"fp",
",",
"$",
"indent",
")",
"{",
"if",
"(",
"!",
"$",
"fp",
")",
"{",
"$",
"fp",
"=",
"STDOUT",
";",
"}",
"$",
"result",
"=",
"1",
";",
"switch",
"(",
"$",
"this",
"->",
"type",
")",
"{",
"case",
"self",
"::",
"SHIFT",
":",
"fprintf",
"(",
"$",
"fp",
",",
"\"%${indent}s shift %d\"",
",",
"$",
"this",
"->",
"sp",
"->",
"name",
",",
"$",
"this",
"->",
"x",
"->",
"statenum",
")",
";",
"break",
";",
"case",
"self",
"::",
"REDUCE",
":",
"fprintf",
"(",
"$",
"fp",
",",
"\"%${indent}s reduce %d\"",
",",
"$",
"this",
"->",
"sp",
"->",
"name",
",",
"$",
"this",
"->",
"x",
"->",
"index",
")",
";",
"break",
";",
"case",
"self",
"::",
"ACCEPT",
":",
"fprintf",
"(",
"$",
"fp",
",",
"\"%${indent}s accept\"",
",",
"$",
"this",
"->",
"sp",
"->",
"name",
")",
";",
"break",
";",
"case",
"self",
"::",
"ERROR",
":",
"fprintf",
"(",
"$",
"fp",
",",
"\"%${indent}s error\"",
",",
"$",
"this",
"->",
"sp",
"->",
"name",
")",
";",
"break",
";",
"case",
"self",
"::",
"CONFLICT",
":",
"fprintf",
"(",
"$",
"fp",
",",
"\"%${indent}s reduce %-3d ** Parsing conflict **\"",
",",
"$",
"this",
"->",
"sp",
"->",
"name",
",",
"$",
"this",
"->",
"x",
"->",
"index",
")",
";",
"break",
";",
"case",
"self",
"::",
"SH_RESOLVED",
":",
"case",
"self",
"::",
"RD_RESOLVED",
":",
"case",
"self",
"::",
"NOT_USED",
":",
"$",
"result",
"=",
"0",
";",
"break",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Print an action to the given file descriptor. Return FALSE if
nothing was actually printed.
@param resource $fp File descriptor to print on
@param integer $indent Number of indents
@see PHP_ParserGenerator_Data::ReportOutput()
@return int|false
|
[
"Print",
"an",
"action",
"to",
"the",
"given",
"file",
"descriptor",
".",
"Return",
"FALSE",
"if",
"nothing",
"was",
"actually",
"printed",
"."
] |
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
|
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/PHP/ParserGenerator/Action.php#L225-L255
|
239,792
|
m-jch/ZagrosCore
|
src/models/Project.php
|
Project.removeElementFromArray
|
public static function removeElementFromArray($elements, $array)
{
if (is_array($elements) && is_array($array))
{
foreach ($elements as $element)
{
if (in_array($element, $array))
{
$key = array_search($element, $array);
unset($array[$key]);
}
}
}
return $array;
}
|
php
|
public static function removeElementFromArray($elements, $array)
{
if (is_array($elements) && is_array($array))
{
foreach ($elements as $element)
{
if (in_array($element, $array))
{
$key = array_search($element, $array);
unset($array[$key]);
}
}
}
return $array;
}
|
[
"public",
"static",
"function",
"removeElementFromArray",
"(",
"$",
"elements",
",",
"$",
"array",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"elements",
")",
"&&",
"is_array",
"(",
"$",
"array",
")",
")",
"{",
"foreach",
"(",
"$",
"elements",
"as",
"$",
"element",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"element",
",",
"$",
"array",
")",
")",
"{",
"$",
"key",
"=",
"array_search",
"(",
"$",
"element",
",",
"$",
"array",
")",
";",
"unset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"}",
"return",
"$",
"array",
";",
"}"
] |
For example remove admins from writers array
@param $elements array
@param $array array
@return array
|
[
"For",
"example",
"remove",
"admins",
"from",
"writers",
"array"
] |
06771fe13e77f7663ea5cc561c6078be08b0f557
|
https://github.com/m-jch/ZagrosCore/blob/06771fe13e77f7663ea5cc561c6078be08b0f557/src/models/Project.php#L70-L84
|
239,793
|
benkle-libs/feed-parser
|
src/Utilities/PriorityList.php
|
PriorityList.add
|
public function add($entry, $priority = self::DEFAULT_PRIORITY)
{
if (isset($this->entryClass) && !($entry instanceof $this->entryClass)) {
throw new InvalidObjectClassException($this->entryClass, get_class($entry));
}
$this->entries[] = ['data' => $entry, 'priority' => $priority];
$this->sorted = false;
return $this;
}
|
php
|
public function add($entry, $priority = self::DEFAULT_PRIORITY)
{
if (isset($this->entryClass) && !($entry instanceof $this->entryClass)) {
throw new InvalidObjectClassException($this->entryClass, get_class($entry));
}
$this->entries[] = ['data' => $entry, 'priority' => $priority];
$this->sorted = false;
return $this;
}
|
[
"public",
"function",
"add",
"(",
"$",
"entry",
",",
"$",
"priority",
"=",
"self",
"::",
"DEFAULT_PRIORITY",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"entryClass",
")",
"&&",
"!",
"(",
"$",
"entry",
"instanceof",
"$",
"this",
"->",
"entryClass",
")",
")",
"{",
"throw",
"new",
"InvalidObjectClassException",
"(",
"$",
"this",
"->",
"entryClass",
",",
"get_class",
"(",
"$",
"entry",
")",
")",
";",
"}",
"$",
"this",
"->",
"entries",
"[",
"]",
"=",
"[",
"'data'",
"=>",
"$",
"entry",
",",
"'priority'",
"=>",
"$",
"priority",
"]",
";",
"$",
"this",
"->",
"sorted",
"=",
"false",
";",
"return",
"$",
"this",
";",
"}"
] |
Add an entry to the list.
@param mixed $entry
@param int $priority
@return $this
@throws InvalidObjectClassException
|
[
"Add",
"an",
"entry",
"to",
"the",
"list",
"."
] |
8b86daf9dfe57e6e7ccae83dbc65ac7ce462144f
|
https://github.com/benkle-libs/feed-parser/blob/8b86daf9dfe57e6e7ccae83dbc65ac7ce462144f/src/Utilities/PriorityList.php#L55-L63
|
239,794
|
benkle-libs/feed-parser
|
src/Utilities/PriorityList.php
|
PriorityList.remove
|
public function remove($entry, $priority = false)
{
$unsetAnything = false;
foreach ($this->entries as $i => $entryData) {
if ($entry === $entryData['data'] && ($priority === false || $entryData['priority'] == $priority)) {
unset($this->entries[$i]);
$unsetAnything = true;
}
}
if ($unsetAnything) {
$this->sorted = false;
}
return $this;
}
|
php
|
public function remove($entry, $priority = false)
{
$unsetAnything = false;
foreach ($this->entries as $i => $entryData) {
if ($entry === $entryData['data'] && ($priority === false || $entryData['priority'] == $priority)) {
unset($this->entries[$i]);
$unsetAnything = true;
}
}
if ($unsetAnything) {
$this->sorted = false;
}
return $this;
}
|
[
"public",
"function",
"remove",
"(",
"$",
"entry",
",",
"$",
"priority",
"=",
"false",
")",
"{",
"$",
"unsetAnything",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"entries",
"as",
"$",
"i",
"=>",
"$",
"entryData",
")",
"{",
"if",
"(",
"$",
"entry",
"===",
"$",
"entryData",
"[",
"'data'",
"]",
"&&",
"(",
"$",
"priority",
"===",
"false",
"||",
"$",
"entryData",
"[",
"'priority'",
"]",
"==",
"$",
"priority",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"entries",
"[",
"$",
"i",
"]",
")",
";",
"$",
"unsetAnything",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"$",
"unsetAnything",
")",
"{",
"$",
"this",
"->",
"sorted",
"=",
"false",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Removes an entry from the list.
@param mixed $entry
@param bool|int $priority When false, remove all instances of $entry from the list, otherwise only those with matching priority
@return $this
|
[
"Removes",
"an",
"entry",
"from",
"the",
"list",
"."
] |
8b86daf9dfe57e6e7ccae83dbc65ac7ce462144f
|
https://github.com/benkle-libs/feed-parser/blob/8b86daf9dfe57e6e7ccae83dbc65ac7ce462144f/src/Utilities/PriorityList.php#L71-L84
|
239,795
|
benkle-libs/feed-parser
|
src/Utilities/PriorityList.php
|
PriorityList.reprioritise
|
public function reprioritise($entry, $newPriority, $oldPriority = false)
{
$changedAnything = false;
foreach ($this->entries as $i => &$entryData) {
if ($entry === $entryData['data'] && ($oldPriority === false || $entryData['priority'] == $oldPriority)) {
$entryData['priority'] = $newPriority;
$changedAnything = true;
}
}
if ($changedAnything) {
$this->sorted = false;
}
return $this;
}
|
php
|
public function reprioritise($entry, $newPriority, $oldPriority = false)
{
$changedAnything = false;
foreach ($this->entries as $i => &$entryData) {
if ($entry === $entryData['data'] && ($oldPriority === false || $entryData['priority'] == $oldPriority)) {
$entryData['priority'] = $newPriority;
$changedAnything = true;
}
}
if ($changedAnything) {
$this->sorted = false;
}
return $this;
}
|
[
"public",
"function",
"reprioritise",
"(",
"$",
"entry",
",",
"$",
"newPriority",
",",
"$",
"oldPriority",
"=",
"false",
")",
"{",
"$",
"changedAnything",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"entries",
"as",
"$",
"i",
"=>",
"&",
"$",
"entryData",
")",
"{",
"if",
"(",
"$",
"entry",
"===",
"$",
"entryData",
"[",
"'data'",
"]",
"&&",
"(",
"$",
"oldPriority",
"===",
"false",
"||",
"$",
"entryData",
"[",
"'priority'",
"]",
"==",
"$",
"oldPriority",
")",
")",
"{",
"$",
"entryData",
"[",
"'priority'",
"]",
"=",
"$",
"newPriority",
";",
"$",
"changedAnything",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"$",
"changedAnything",
")",
"{",
"$",
"this",
"->",
"sorted",
"=",
"false",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
change the priority for an entry.
@param mixed $entry
@param int $newPriority
@param bool|int $oldPriority If falsechange remove all instances of $entry from the list, otherwise only those with matching priority
@return $this
|
[
"change",
"the",
"priority",
"for",
"an",
"entry",
"."
] |
8b86daf9dfe57e6e7ccae83dbc65ac7ce462144f
|
https://github.com/benkle-libs/feed-parser/blob/8b86daf9dfe57e6e7ccae83dbc65ac7ce462144f/src/Utilities/PriorityList.php#L93-L106
|
239,796
|
benkle-libs/feed-parser
|
src/Utilities/PriorityList.php
|
PriorityList.toArray
|
public function toArray()
{
if (!$this->sorted) {
$this->rewind();
}
return array_map(
function ($entry) {
return $entry['data'];
}, $this->entries
);
}
|
php
|
public function toArray()
{
if (!$this->sorted) {
$this->rewind();
}
return array_map(
function ($entry) {
return $entry['data'];
}, $this->entries
);
}
|
[
"public",
"function",
"toArray",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"sorted",
")",
"{",
"$",
"this",
"->",
"rewind",
"(",
")",
";",
"}",
"return",
"array_map",
"(",
"function",
"(",
"$",
"entry",
")",
"{",
"return",
"$",
"entry",
"[",
"'data'",
"]",
";",
"}",
",",
"$",
"this",
"->",
"entries",
")",
";",
"}"
] |
Returns all items, ordered by priority.
@return array
|
[
"Returns",
"all",
"items",
"ordered",
"by",
"priority",
"."
] |
8b86daf9dfe57e6e7ccae83dbc65ac7ce462144f
|
https://github.com/benkle-libs/feed-parser/blob/8b86daf9dfe57e6e7ccae83dbc65ac7ce462144f/src/Utilities/PriorityList.php#L189-L199
|
239,797
|
sellerlabs/nucleus
|
src/SellerLabs/Nucleus/Support/Arr.php
|
Arr.dotGet
|
public static function dotGet(array $array, $key, $default = null)
{
if (is_null($key)) {
return $array;
}
if (isset($array[$key])) {
return $array[$key];
}
foreach (explode('.', $key) as $segment) {
if (!is_array($array) || !array_key_exists($segment, $array)) {
return Std::thunk($default);
}
$array = $array[$segment];
}
return $array;
}
|
php
|
public static function dotGet(array $array, $key, $default = null)
{
if (is_null($key)) {
return $array;
}
if (isset($array[$key])) {
return $array[$key];
}
foreach (explode('.', $key) as $segment) {
if (!is_array($array) || !array_key_exists($segment, $array)) {
return Std::thunk($default);
}
$array = $array[$segment];
}
return $array;
}
|
[
"public",
"static",
"function",
"dotGet",
"(",
"array",
"$",
"array",
",",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"array",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"array",
"[",
"$",
"key",
"]",
";",
"}",
"foreach",
"(",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
"as",
"$",
"segment",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"array",
")",
"||",
"!",
"array_key_exists",
"(",
"$",
"segment",
",",
"$",
"array",
")",
")",
"{",
"return",
"Std",
"::",
"thunk",
"(",
"$",
"default",
")",
";",
"}",
"$",
"array",
"=",
"$",
"array",
"[",
"$",
"segment",
"]",
";",
"}",
"return",
"$",
"array",
";",
"}"
] |
Get the resulting value of an attempt to traverse a key path.
Each key in the path is separated with a dot.
For example, the following snippet should return `true`:
```php
Arr::dotGet([
'hello' => [
'world' => true,
],
], 'hello.world');
```
Additionally, a default value may be provided, which will be returned if
the path does not yield to a value.
@param array $array
@param string $key
@param null|mixed $default
@return mixed
|
[
"Get",
"the",
"resulting",
"value",
"of",
"an",
"attempt",
"to",
"traverse",
"a",
"key",
"path",
"."
] |
c05d9c23d424a6bd5ab2e29140805cc6e37e4623
|
https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/Support/Arr.php#L53-L72
|
239,798
|
sellerlabs/nucleus
|
src/SellerLabs/Nucleus/Support/Arr.php
|
Arr.dotSet
|
public static function dotSet(array $array, $key, $value)
{
$path = explode('.', $key);
$total = count($path);
$current = &$array;
for ($ii = 0; $ii < $total; $ii++) {
if ($ii === $total - 1) {
$current[$path[$ii]] = $value;
} else {
if (!is_array($current)) {
throw new LackOfCoffeeException(
'Part of the path is not an array.'
);
}
if (!array_key_exists($path[$ii], $current)) {
$current[$path[$ii]] = [];
}
$current = &$current[$path[$ii]];
}
}
}
|
php
|
public static function dotSet(array $array, $key, $value)
{
$path = explode('.', $key);
$total = count($path);
$current = &$array;
for ($ii = 0; $ii < $total; $ii++) {
if ($ii === $total - 1) {
$current[$path[$ii]] = $value;
} else {
if (!is_array($current)) {
throw new LackOfCoffeeException(
'Part of the path is not an array.'
);
}
if (!array_key_exists($path[$ii], $current)) {
$current[$path[$ii]] = [];
}
$current = &$current[$path[$ii]];
}
}
}
|
[
"public",
"static",
"function",
"dotSet",
"(",
"array",
"$",
"array",
",",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"path",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"$",
"total",
"=",
"count",
"(",
"$",
"path",
")",
";",
"$",
"current",
"=",
"&",
"$",
"array",
";",
"for",
"(",
"$",
"ii",
"=",
"0",
";",
"$",
"ii",
"<",
"$",
"total",
";",
"$",
"ii",
"++",
")",
"{",
"if",
"(",
"$",
"ii",
"===",
"$",
"total",
"-",
"1",
")",
"{",
"$",
"current",
"[",
"$",
"path",
"[",
"$",
"ii",
"]",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"current",
")",
")",
"{",
"throw",
"new",
"LackOfCoffeeException",
"(",
"'Part of the path is not an array.'",
")",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"path",
"[",
"$",
"ii",
"]",
",",
"$",
"current",
")",
")",
"{",
"$",
"current",
"[",
"$",
"path",
"[",
"$",
"ii",
"]",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"current",
"=",
"&",
"$",
"current",
"[",
"$",
"path",
"[",
"$",
"ii",
"]",
"]",
";",
"}",
"}",
"}"
] |
Set an array element using dot notation.
Same as `Arr::dotGet()`, but the value is replaced instead of fetched.
@param array $array
@param string $key
@param mixed $value
@throws LackOfCoffeeException
|
[
"Set",
"an",
"array",
"element",
"using",
"dot",
"notation",
"."
] |
c05d9c23d424a6bd5ab2e29140805cc6e37e4623
|
https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/Support/Arr.php#L85-L109
|
239,799
|
sellerlabs/nucleus
|
src/SellerLabs/Nucleus/Support/Arr.php
|
Arr.walk
|
public static function walk(
array &$array,
callable $callback,
$recurse = false,
$path = '',
$considerLeaves = true
) {
$path = trim($path, '.');
foreach ($array as $key => $value) {
if (is_array($value) && $recurse) {
if ($considerLeaves === false && !static::hasNested($value)) {
$callback($key, $value, $array, $path);
continue;
}
$deeperPath = $key;
if ($path !== '') {
$deeperPath = vsprintf('%s.%s', [$path, $key]);
}
static::walk(
$array[$key],
$callback,
true,
$deeperPath,
$considerLeaves
);
continue;
}
$callback($key, $value, $array, $path);
}
return $array;
}
|
php
|
public static function walk(
array &$array,
callable $callback,
$recurse = false,
$path = '',
$considerLeaves = true
) {
$path = trim($path, '.');
foreach ($array as $key => $value) {
if (is_array($value) && $recurse) {
if ($considerLeaves === false && !static::hasNested($value)) {
$callback($key, $value, $array, $path);
continue;
}
$deeperPath = $key;
if ($path !== '') {
$deeperPath = vsprintf('%s.%s', [$path, $key]);
}
static::walk(
$array[$key],
$callback,
true,
$deeperPath,
$considerLeaves
);
continue;
}
$callback($key, $value, $array, $path);
}
return $array;
}
|
[
"public",
"static",
"function",
"walk",
"(",
"array",
"&",
"$",
"array",
",",
"callable",
"$",
"callback",
",",
"$",
"recurse",
"=",
"false",
",",
"$",
"path",
"=",
"''",
",",
"$",
"considerLeaves",
"=",
"true",
")",
"{",
"$",
"path",
"=",
"trim",
"(",
"$",
"path",
",",
"'.'",
")",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"&&",
"$",
"recurse",
")",
"{",
"if",
"(",
"$",
"considerLeaves",
"===",
"false",
"&&",
"!",
"static",
"::",
"hasNested",
"(",
"$",
"value",
")",
")",
"{",
"$",
"callback",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"array",
",",
"$",
"path",
")",
";",
"continue",
";",
"}",
"$",
"deeperPath",
"=",
"$",
"key",
";",
"if",
"(",
"$",
"path",
"!==",
"''",
")",
"{",
"$",
"deeperPath",
"=",
"vsprintf",
"(",
"'%s.%s'",
",",
"[",
"$",
"path",
",",
"$",
"key",
"]",
")",
";",
"}",
"static",
"::",
"walk",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
",",
"$",
"callback",
",",
"true",
",",
"$",
"deeperPath",
",",
"$",
"considerLeaves",
")",
";",
"continue",
";",
"}",
"$",
"callback",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"array",
",",
"$",
"path",
")",
";",
"}",
"return",
"$",
"array",
";",
"}"
] |
A more complicated, but flexible, version of `array_walk`.
This modified version is useful for flattening arrays without losing
important structure data (how the array is arranged and nested).
Possible applications: flattening complex validation responses or a
configuration file.
Additional features:
- The current path in dot notation is provided to the callback.
- Leaf arrays (no nested arrays) can be optionally ignored.
Callback signature:
```php
$callback($key, $value, $array, $path);
```
@param array $array
@param callable $callback
@param bool $recurse
@param string $path - The current path prefix.
@param bool $considerLeaves
@return array
|
[
"A",
"more",
"complicated",
"but",
"flexible",
"version",
"of",
"array_walk",
"."
] |
c05d9c23d424a6bd5ab2e29140805cc6e37e4623
|
https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/Support/Arr.php#L164-L200
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.