idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
46,000 | protected function translateModuleId ( $ oldModuleId ) { $ module = Module :: where ( 'name' , StudyModule :: findOrFail ( $ oldModuleId ) -> name ) -> first ( ) ; if ( $ module != null ) { return $ module -> id ; } throw new ModuleNotFoundByNameException ( ) ; } | Translate module id . |
46,001 | protected function translateSubmoduleId ( $ oldSubModuleId ) { $ submodule = Submodule :: where ( 'name' , StudySubModule :: findOrFail ( $ oldSubModuleId ) -> name ) -> first ( ) ; if ( $ submodule != null ) { return $ submodule -> id ; } throw new SubmoduleNotFoundByNameException ( ) ; } | Translate submodule id . |
46,002 | protected function translateStudyId ( $ oldStudyId ) { $ study = ScoolStudy :: where ( 'name' , Study :: findOrFail ( $ oldStudyId ) -> name ) -> first ( ) ; if ( $ study != null ) { return $ study -> id ; } throw new StudyNotFoundByNameException ( ) ; } | Translate old ebre - escool study id to scool id . |
46,003 | protected function translateCourseId ( $ oldCourseId ) { $ course = ScoolCourse :: where ( 'name' , Course :: findOrFail ( $ oldCourseId ) -> name ) -> first ( ) ; if ( $ course != null ) { return $ course -> id ; } throw new CourseNotFoundByNameException ( ) ; } | Translate old ebre - escool course id to scool id . |
46,004 | protected function translateClassroomId ( $ oldClassroomId ) { $ classroom = Classroom :: where ( 'name' , ClassroomGroup :: findOrFail ( $ oldClassroomId ) -> name ) -> first ( ) ; if ( $ classroom != null ) { return $ classroom -> id ; } throw new ClassroomNotFoundByNameException ( ) ; } | Translate old ebre - escool classroom id to scool id . |
46,005 | protected function migratePerson ( $ person ) { $ user = User :: firstOrNew ( [ 'email' => $ person -> email , ] ) ; $ user -> name = $ person -> name ; $ user -> password = bcrypt ( 'secret' ) ; $ user -> remember_token = str_random ( 10 ) ; $ user -> save ( ) ; return $ user ; } | Migrate ebre - escool person to scool person . |
46,006 | protected function migrateClassrooms ( ) { $ this -> output -> info ( '### Migrating classrooms ###' ) ; foreach ( $ classrooms = $ this -> classrooms ( ) as $ classroom ) { $ this -> showMigratingInfo ( $ classroom , 1 ) ; $ this -> migrateClassroom ( $ classroom ) ; } $ this -> output -> info ( '### END Migrating classrooms. Migrated ' . count ( $ classrooms ) . ' locations ###' ) ; } | Migrate classrooms . |
46,007 | protected function migrateLocations ( ) { $ this -> output -> info ( '### Migrating locations ###' ) ; foreach ( $ this -> locations ( ) as $ location ) { $ this -> showMigratingInfo ( $ location , 1 ) ; $ this -> migrateLocation ( $ location ) ; } $ this -> output -> info ( '### END Migrating locations. Migrated ' . count ( $ this -> locations ( ) ) . ' locations ###' ) ; } | Migrate locations . |
46,008 | protected function migrateLocation ( $ srcLocation ) { $ location = ScoolLocation :: firstOrNew ( [ 'name' => $ srcLocation -> name , ] ) ; $ location -> save ( ) ; $ location -> shortname = $ srcLocation -> shortName ; $ location -> description = $ srcLocation -> description ; $ location -> code = $ srcLocation -> external_code ; } | Migrate location . |
46,009 | protected function migrateClassroom ( $ srcClassroom ) { $ classroom = Classroom :: firstOrNew ( [ 'name' => $ srcClassroom -> name , ] ) ; $ classroom -> save ( ) ; $ this -> addCourseToClassroom ( $ classroom , $ srcClassroom -> course_id ) ; $ classroom -> shortname = $ srcClassroom -> shortName ; $ classroom -> description = $ srcClassroom -> description ; $ classroom -> code = $ srcClassroom -> external_code ; } | Migrate classroom . |
46,010 | private function migrateCurriculum ( ) { foreach ( $ this -> departments ( ) as $ department ) { $ this -> setDepartment ( $ department ) ; $ this -> showMigratingInfo ( $ department , 1 ) ; $ this -> migrateDepartment ( $ department ) ; foreach ( $ this -> studies ( $ department ) as $ study ) { $ this -> setStudy ( $ study ) ; $ this -> showMigratingInfo ( $ study , 2 ) ; $ this -> migrateStudy ( $ study ) ; $ this -> addStudyToDeparment ( ) ; foreach ( $ this -> courses ( $ study ) as $ course ) { $ this -> setCourse ( $ course ) ; $ this -> showMigratingInfo ( $ course , 3 ) ; $ this -> migrateCourse ( $ course ) ; $ this -> addCourseToStudy ( ) ; foreach ( $ this -> modules ( $ course ) as $ module ) { $ this -> setModule ( $ module ) ; $ this -> showMigratingInfo ( $ module , 4 ) ; $ this -> migrateModule ( $ module ) ; $ this -> addModuleToCourse ( ) ; foreach ( $ this -> submodules ( $ module ) as $ submodule ) { $ this -> setSubmodule ( $ submodule ) ; $ this -> showMigratingInfo ( $ submodule , 5 ) ; $ this -> migrateSubmodule ( $ submodule ) ; $ this -> addSubModuleToModule ( ) ; } } } } } } | Migrate curriculum . |
46,011 | private function migrateEnrollments ( ) { $ this -> output -> info ( '### Migrating enrollments ###' ) ; foreach ( $ this -> enrollments ( ) as $ enrollment ) { if ( $ enrollment -> person == null ) { $ this -> output -> error ( 'Skipping enrolmment because no personal data' ) ; continue ; } $ enrollment -> showMigratingInfo ( $ this -> output , 1 ) ; $ newEnrollment = $ this -> migrateEnrollment ( $ enrollment ) ; if ( $ newEnrollment ) $ this -> migrateEnrollmentDetails ( $ enrollment , $ newEnrollment ) ; } $ this -> output -> info ( '### END Migrating enrollments ###' ) ; } | Migrate enrollment . |
46,012 | protected function seedDays ( ) { $ this -> output -> info ( '### Seeding days###' ) ; $ timestamp = strtotime ( 'next Monday' ) ; $ days = array ( ) ; for ( $ i = 1 ; $ i < 8 ; $ i ++ ) { $ days [ $ i ] = strftime ( '%A' , $ timestamp ) ; $ timestamp = strtotime ( '+1 day' , $ timestamp ) ; } foreach ( $ days as $ dayNumber => $ day ) { $ this -> output -> info ( '### Seeding day: ' . $ day . ' ###' ) ; $ dayModel = Day :: firstOrNew ( [ 'code' => $ dayNumber , ] ) ; $ dayModel -> name = $ day ; $ dayModel -> code = $ dayNumber ; $ dayModel -> lective = true ; if ( $ dayNumber == 6 || $ dayNumber == 7 ) { $ dayModel -> lective = false ; } $ dayModel -> save ( ) ; } $ this -> output -> info ( '### END Seeding days###' ) ; } | Seed days of the week with ISO - 8601 numeric code . |
46,013 | protected function migrateTimeslots ( ) { $ this -> output -> info ( '### Migrating timeslots ###' ) ; foreach ( $ this -> timeslots ( ) as $ timeslot ) { $ timeslot -> showMigratingInfo ( $ this -> output , 1 ) ; $ this -> migrateTimeslot ( $ timeslot ) ; } $ this -> output -> info ( '### END OF Migrating timeslots ###' ) ; } | Migrate timeslots . |
46,014 | protected function migrateLessons ( ) { $ this -> output -> info ( '### Migrating lessons ###' ) ; if ( $ this -> checkLessonsMigrationState ( ) ) { foreach ( $ this -> lessons ( ) as $ lesson ) { $ lesson -> showMigratingInfo ( $ this -> output , 1 ) ; $ this -> migrateLesson ( $ lesson ) ; } } $ this -> output -> info ( '### END OF Migrating lessons ###' ) ; } | Migrate lessons . |
46,015 | 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 . |
46,016 | 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 . |
46,017 | 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 |
46,018 | public function migrateModule ( StudyModuleAcademicPeriod $ module ) { try { $ this -> setScoolModule ( $ this -> createModule ( $ module ) ) ; } catch ( \ LogicException $ le ) { $ this -> output -> error ( $ le -> getMessage ( ) ) ; } } | Migrate module . |
46,019 | 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 . |
46,020 | 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 . |
46,021 | protected function createSubmodule ( StudySubModule $ srcSubmodule ) { $ 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 . |
46,022 | 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 . |
46,023 | 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 . |
46,024 | protected function departments ( ) { 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 . |
46,025 | protected function studies ( Department $ department ) { return $ this -> validateCollection ( $ department -> studiesActiveOn ( $ this -> period ) -> get ( ) ) ; } | Get the studies to migrate . |
46,026 | 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 . |
46,027 | protected function submodules ( StudyModuleAcademicPeriod $ module ) { return $ this -> validateCollection ( $ module -> module ( ) -> first ( ) -> submodules ( ) -> active ( ) -> get ( ) ) ; } | Get the submodules to migrate . |
46,028 | protected function switchToDestinationConnection ( ) { $ env = env ( $ this -> composeDestinationConnectionEnvVarByCurrentPeriodInProcess ( ) , $ this -> composeDestinationConnectionNameByCurrentPeriodInProcess ( ) ) ; $ this -> switchConnection ( $ env , $ this -> getDestinationConnection ( ) ) ; } | Switch to current destination connection in process . |
46,029 | protected function compileComponents ( Builder $ query ) { $ request = [ ] ; foreach ( $ this -> requestComponents as $ component ) { 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 . |
46,030 | 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 . |
46,031 | 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 ; } | Set the page header . |
46,032 | 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 ; $ this -> mpdf -> SetHTMLFooter ( $ this -> getProperty ( 'pageFooter' , $ side ) , 'O' ) ; return $ this ; } | Set the page footer . |
46,033 | public function setFontType ( string $ fontname = null ) : PdfInterface { $ this -> setProperty ( 'fontType' , $ this -> getFontFamily ( strtolower ( $ fontname ) ) ) ; $ this -> mpdf -> SetDefaultBodyCSS ( 'font-family' , $ this -> getProperty ( 'fontType' ) ) ; return $ this ; } | Set the default document font . |
46,034 | protected function getFontFamily ( string $ fontname = null ) : string { return array_key_exists ( strtolower ( $ fontname ) , $ this -> fontFamily ) ? $ this -> fontFamily [ strtolower ( $ fontname ) ] : $ this -> fontFamily [ 'default' ] ; } | Return a specific font - family . |
46,035 | public function appendPageContent ( string $ str ) : PdfInterface { $ this -> setProperty ( 'pageContent' , $ str ) ; $ this -> mpdf -> WriteHTML ( $ this -> pageContent ) ; return $ this ; } | Append the HTML content . |
46,036 | 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 . |
46,037 | public function setPageSize ( string $ pageSize ) : PdfInterface { $ this -> setProperty ( 'pageSize' , $ pageSize ) ; $ this -> registerPageFormat ( ) ; return $ this ; } | Set the page size . |
46,038 | public function appendPageCSS ( string $ str ) : PdfInterface { $ this -> setProperty ( 'pageCSS' , $ str ) ; $ this -> mpdf -> WriteHTML ( $ this -> pageCSS , 1 ) ; return $ this ; } | Append a CSS style . |
46,039 | 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 . |
46,040 | 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 . |
46,041 | public function setMetaTitle ( string $ str ) : PdfInterface { $ this -> setProperty ( 'metaTitle' , $ str ) ; $ this -> mpdf -> SetTitle ( $ this -> metaTitle ) ; return $ this ; } | Set PDF Meta Title . |
46,042 | public function setMetaAuthor ( string $ str ) : PdfInterface { $ this -> setProperty ( 'metaAuthor' , $ str ) ; $ this -> mpdf -> SetAuthor ( $ this -> metaAuthor ) ; return $ this ; } | Set PDF Meta Author . |
46,043 | public function setMetaCreator ( string $ str ) : PdfInterface { $ this -> setProperty ( 'metaCreator' , $ str ) ; $ this -> mpdf -> SetCreator ( $ this -> metaCreator ) ; return $ this ; } | Set PDF Meta Creator . |
46,044 | public function setMetaSubject ( string $ str ) : PdfInterface { $ this -> setProperty ( 'metaSubject' , $ str ) ; $ this -> mpdf -> SetSubject ( $ this -> metaSubject ) ; return $ this ; } | Set PDF Meta Subject . |
46,045 | 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 . |
46,046 | 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 . |
46,047 | public function getSystemService ( ) : SystemService { if ( $ this -> _systemService === null ) { $ this -> _systemService = new SystemService ( ) ; } return $ this -> _systemService ; } | Returns the value of field _systemService . |
46,048 | public static function realPath ( $ 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 . |
46,049 | public static function containsPath ( $ top , $ 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 . |
46,050 | public static function openFile ( $ filePath , $ mode ) { return self :: isFile ( $ filePath ) ? fopen ( $ filePath , $ mode , false ) : false ; } | Opens the supplied file with the requested mode . |
46,051 | public static function tempFile ( $ 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 . |
46,052 | 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 . |
46,053 | 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 . |
46,054 | public function createPickles2ContentsEditor ( ) { $ px2ce = new \ pickles2 \ libs \ contentsEditor \ main ( ) ; $ px2ce -> init ( array ( 'page_path' => '/px2me-dummy.html' , 'appMode' => $ this -> getAppMode ( ) , 'entryScript' => $ this -> entryScript , 'customFields' => array ( ) , 'log' => function ( $ msg ) { } , 'commands' => @ $ this -> options [ 'commands' ] , ) ) ; return $ px2ce ; } | create pickles2 - contents - editor object |
46,055 | 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 |
46,056 | 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 . |
46,057 | 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 . |
46,058 | 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 |
46,059 | 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 . |
46,060 | public function launching ( ) { $ 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 |
46,061 | 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 |
46,062 | public function tidy ( $ value ) { if ( is_array ( $ value ) ) { $ value = array_map ( [ & $ this , 'tidy' ] , $ value ) ; } else { $ value = trim ( $ value ) ; $ value = preg_replace ( "=(\r\n|\r)=" , "\n" , $ value ) ; $ value = str_replace ( "\0" , '' , $ value ) ; } return $ value ; } | Trims a string unifies line breaks and deletes null bytes . |
46,063 | 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 . |
46,064 | public function checkRoute ( $ uri ) { foreach ( $ this -> strings as $ expression ) { $ 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 |
46,065 | private function setStrings ( ) { foreach ( $ this -> parts as $ part ) { $ this -> checkPart ( $ part ) ; } $ this -> strings [ 0 ] = ( $ this -> strings [ 0 ] == '' ) ? '\/' : $ this -> strings [ 0 ] ; $ this -> strings [ 0 ] = '^' . $ this -> strings [ 0 ] . '$' ; } | break the url t smithereens! garrr! |
46,066 | private function setOptionalStrings ( ) { if ( $ this -> optional ) { $ this -> strings [ 1 ] = $ this -> strings [ 0 ] . Url :: SLASH_WORD ; $ this -> strings = array_reverse ( $ this -> strings ) ; } } | checks fer the optional stuff |
46,067 | 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 . |
46,068 | public function Advanced ( ) { $ this -> Permission ( 'Garden.Settings.Manage' ) ; $ 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' ) ) ; $ this -> Form -> SetModel ( $ ConfigurationModel ) ; if ( $ this -> Form -> AuthenticatedPostBack ( ) === FALSE ) { $ this -> Form -> SetData ( $ ConfigurationModel -> Data ) ; } else { $ 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' ) ; $ ArchiveDateBak = Gdn :: Config ( 'Vanilla.Archive.Date' ) ; $ ArchiveExcludeBak = ( bool ) Gdn :: Config ( 'Vanilla.Archive.Exclude' ) ; $ 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' ) ) ; $ this -> Render ( ) ; } | Advanced settings . |
46,069 | public function Initialize ( ) { $ 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' ) ; } $ this -> MasterView = 'admin' ; parent :: Initialize ( ) ; Gdn_Theme :: Section ( 'Dashboard' ) ; } | Switch MasterView . Include JS CSS used by all methods . |
46,070 | public function AddSideMenu ( $ CurrentUrl ) { 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 . |
46,071 | public function FloodControl ( ) { $ this -> Permission ( 'Garden.Settings.Manage' ) ; $ this -> Title ( T ( 'Flood Control' ) ) ; $ this -> AddSideMenu ( 'vanilla/settings/floodcontrol' ) ; $ 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' ) ) ; $ this -> Form -> SetModel ( $ ConfigurationModel ) ; if ( $ this -> Form -> AuthenticatedPostBack ( ) === FALSE ) { $ this -> Form -> SetData ( $ ConfigurationModel -> Data ) ; } else { $ 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." ) ) ; } } $ this -> Render ( ) ; } | Display flood control options . |
46,072 | public function AddCategory ( ) { $ this -> Permission ( 'Garden.Settings.Manage' ) ; $ this -> AddJsFile ( 'jquery.alphanumeric.js' ) ; $ this -> AddJsFile ( 'categories.js' ) ; $ this -> AddJsFile ( 'jquery.gardencheckboxgrid.js' ) ; $ this -> Title ( T ( 'Add Category' ) ) ; $ this -> AddSideMenu ( 'vanilla/settings/managecategories' ) ; $ RoleModel = new RoleModel ( ) ; $ PermissionModel = Gdn :: PermissionModel ( ) ; $ this -> Form -> SetModel ( $ this -> CategoryModel ) ; $ this -> RoleArray = $ RoleModel -> GetArray ( ) ; $ this -> FireEvent ( 'AddEditCategory' ) ; if ( $ this -> Form -> IsPostBack ( ) == FALSE ) { $ this -> Form -> AddHidden ( 'CodeIsDefined' , '0' ) ; } else { $ 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 ) ; } } $ 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 ) ; } $ this -> Render ( ) ; } | Adding a new category . |
46,073 | public function DeleteCategory ( $ CategoryID = FALSE ) { $ this -> Permission ( 'Garden.Settings.Manage' ) ; $ this -> AddJsFile ( 'categories.js' ) ; $ this -> Title ( T ( 'Delete Category' ) ) ; $ this -> AddSideMenu ( 'vanilla/settings/managecategories' ) ; $ this -> Category = $ this -> CategoryModel -> GetID ( $ CategoryID ) ; if ( ! $ this -> Category ) { $ this -> Form -> AddError ( 'The specified category could not be found.' ) ; } else { $ this -> Form -> AddHidden ( 'CategoryID' , $ CategoryID ) ; $ this -> OtherCategories = $ this -> CategoryModel -> GetWhere ( array ( 'CategoryID <>' => $ CategoryID , 'AllowDiscussions' => $ this -> Category -> AllowDiscussions , 'CategoryID >' => 0 ) , 'Sort' ) ; if ( ! $ this -> Form -> AuthenticatedPostBack ( ) ) { $ this -> Form -> SetFormValue ( 'DeleteDiscussions' , '1' ) ; } else { $ ReplacementCategoryID = $ this -> Form -> GetValue ( 'ReplacementCategoryID' ) ; $ ReplacementCategory = $ this -> CategoryModel -> GetID ( $ ReplacementCategoryID ) ; if ( $ this -> Category -> AllowDiscussions == '1' && $ this -> OtherCategories -> NumRows ( ) == 0 ) $ this -> Form -> AddError ( 'You cannot remove the only remaining category that allows discussions' ) ; if ( $ this -> Form -> ErrorCount ( ) == 0 ) { 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...' ) ) ; } } } } $ this -> Render ( ) ; } | Deleting a category . |
46,074 | public function DeleteCategoryPhoto ( $ CategoryID = FALSE , $ TransientKey = '' ) { $ this -> Permission ( 'Garden.Settings.Manage' ) ; $ RedirectUrl = 'vanilla/settings/editcategory/' . $ CategoryID ; if ( Gdn :: Session ( ) -> ValidateTransientKey ( $ TransientKey ) ) { $ 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 . |
46,075 | public function EditCategory ( $ CategoryID = '' ) { $ this -> Permission ( 'Garden.Settings.Manage' ) ; $ RoleModel = new RoleModel ( ) ; $ PermissionModel = Gdn :: PermissionModel ( ) ; $ this -> Form -> SetModel ( $ this -> CategoryModel ) ; if ( ! $ CategoryID && $ this -> Form -> IsPostBack ( ) ) { if ( $ ID = $ this -> Form -> GetFormValue ( 'CategoryID' ) ) $ CategoryID = $ ID ; } $ this -> Category = $ this -> CategoryModel -> GetID ( $ CategoryID ) ; $ this -> Category -> CustomPermissions = $ this -> Category -> CategoryID == $ this -> Category -> PermissionCategoryID ; $ this -> AddJsFile ( 'jquery.alphanumeric.js' ) ; $ this -> AddJsFile ( 'categories.js' ) ; $ this -> AddJsFile ( 'jquery.gardencheckboxgrid.js' ) ; $ this -> Title ( T ( 'Edit Category' ) ) ; $ this -> AddSideMenu ( 'vanilla/settings/managecategories' ) ; $ this -> Form -> AddHidden ( 'CategoryID' , $ CategoryID ) ; $ this -> SetData ( 'CategoryID' , $ CategoryID ) ; $ 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 ) { $ TargetImage = $ Upload -> GenerateTargetName ( PATH_UPLOADS ) ; $ ImageBaseName = pathinfo ( $ TargetImage , PATHINFO_BASENAME ) ; $ 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' ) ; } } $ 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 ) ; $ this -> Render ( ) ; } | Editing a category . |
46,076 | public function ManageCategories ( ) { $ this -> Permission ( 'Garden.Settings.Manage' ) ; $ this -> AddSideMenu ( 'vanilla/settings/managecategories' ) ; $ 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' ) ) ; $ this -> SetData ( 'CategoryData' , $ this -> CategoryModel -> GetAll ( 'TreeLeft' ) , TRUE ) ; 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' ) ; } $ Validation = new Gdn_Validation ( ) ; $ ConfigurationModel = new Gdn_ConfigurationModel ( $ Validation ) ; $ ConfigurationModel -> SetField ( array ( 'Vanilla.Categories.MaxDisplayDepth' , 'Vanilla.Categories.DoHeadings' , 'Vanilla.Categories.HideModule' ) ) ; $ this -> Form -> SetModel ( $ ConfigurationModel ) ; $ 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 ( $ this -> Form -> AuthenticatedPostBack ( ) === FALSE ) { $ this -> Form -> SetData ( $ ConfigurationModel -> Data ) ; } else { if ( $ this -> Form -> Save ( ) !== FALSE ) $ this -> InformMessage ( T ( "Your settings have been saved." ) ) ; } $ this -> Render ( ) ; } | Enabling and disabling categories from list . |
46,077 | public function SortCategories ( ) { $ this -> Permission ( 'Garden.Settings.Manage' ) ; $ TransientKey = GetIncomingValue ( 'TransientKey' ) ; if ( Gdn :: Request ( ) -> IsPostBack ( ) ) { $ TreeArray = GetValue ( 'TreeArray' , $ _POST ) ; $ Saves = $ this -> CategoryModel -> SaveTree ( $ TreeArray ) ; $ this -> SetData ( 'Result' , TRUE ) ; $ this -> SetData ( 'Saves' , $ Saves ) ; } $ this -> Render ( ) ; } | Sorting display order of categories . |
46,078 | 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 |
46,079 | 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 . |
46,080 | 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 . |
46,081 | 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 . |
46,082 | public function createDoctrineDBALConnection ( $ driver , $ host , $ port , $ dbname , $ user , $ password ) { $ 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 |
46,083 | protected function getSQLResultFromConnection ( $ connection , $ sql , array $ params = array ( ) ) { $ result = $ connection -> fetchAll ( $ sql , $ params ) ; return $ result ; } | Permite ejecutar una consulta de tipo SELECT |
46,084 | 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 |
46,085 | 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 . |
46,086 | 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 . |
46,087 | 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 . |
46,088 | 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 . |
46,089 | 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 . |
46,090 | 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 . |
46,091 | 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 . |
46,092 | 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 |
46,093 | 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 . |
46,094 | 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 . |
46,095 | 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 |
46,096 | 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 |
46,097 | function ctc_sanitize ( $ instance ) { global $ allowedposttags ; $ sanitized_instance = array ( ) ; $ fields = $ this -> ctc_prepared_fields ( ) ; foreach ( $ fields as $ id => $ field ) { $ input = isset ( $ instance [ $ id ] ) ? $ instance [ $ id ] : '' ; $ output = trim ( stripslashes ( $ input ) ) ; switch ( $ field [ 'type' ] ) { case 'text' : case 'textarea' : if ( empty ( $ field [ 'allow_html' ] ) ) { $ output = trim ( strip_tags ( $ output ) ) ; } $ output = stripslashes ( wp_filter_post_kses ( addslashes ( $ output ) , $ allowedposttags ) ) ; break ; case 'checkbox' : $ output = ! empty ( $ output ) ? '1' : '' ; break ; case 'radio' : case 'select' : if ( ! isset ( $ field [ 'options' ] [ $ output ] ) ) { $ output = '' ; } break ; case 'number' : $ output = ( int ) $ output ; $ min = isset ( $ field [ 'number_min' ] ) && '' !== $ field [ 'number_min' ] ? ( int ) $ field [ 'number_min' ] : '' ; if ( '' !== $ min && $ output < $ min ) { $ output = $ min ; } $ max = isset ( $ field [ 'number_max' ] ) && '' !== $ field [ 'number_max' ] ? ( int ) $ field [ 'number_max' ] : '' ; if ( '' !== $ max && $ output > $ max ) { $ output = $ max ; } break ; case 'url' : $ output = esc_url_raw ( $ output ) ; break ; case 'image' : $ output = absint ( $ output ) ; if ( empty ( $ output ) || ! wp_get_attachment_image_src ( $ output ) ) { $ output = '' ; } break ; } if ( ! empty ( $ field [ 'custom_sanitize' ] ) ) { $ output = call_user_func ( $ field [ 'custom_sanitize' ] , $ output ) ; } $ output = trim ( $ output ) ; if ( empty ( $ output ) && ! empty ( $ field [ 'default' ] ) && ! empty ( $ field [ 'no_empty' ] ) ) { $ output = $ field [ 'default' ] ; } $ sanitized_instance [ $ id ] = $ output ; } return $ sanitized_instance ; } | Sanitize field values |
46,098 | function widget ( $ args , $ instance ) { global $ post ; $ widgets = ChurchThemeFrameworkWidgets :: widgetList ( ) ; $ template_file = $ widgets [ $ this -> id_base ] [ 'template_file' ] ; $ template_path = CTFW_WIDGETS_WIDGET_TEMPLATE_DIR . '/' . $ template_file ; $ instance = $ this -> ctc_sanitize ( $ instance ) ; $ this -> ctc_instance = $ instance ; if ( file_exists ( $ template_path ) ) { include $ template_path ; } } | Front - end display of widget |
46,099 | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.