From efaeea07319c63be2f2c6a8bd076e4de8ac8f11d Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms Date: Thu, 16 May 2024 11:05:47 +0000 Subject: relocate flexi, fixes #4101 Closes #4101 Merge request studip/studip!2977 --- RELEASE-NOTES.md | 9 + app/controllers/admin/courses.php | 25 +- app/controllers/calendar/schedule.php | 2 +- app/controllers/file.php | 4 +- app/controllers/resources/booking.php | 4 +- app/controllers/room_management/planning.php | 2 +- app/controllers/shared/download.php | 4 +- app/controllers/start.php | 2 + app/views/file/file_details.php | 20 +- app/views/file/folder_details.php | 2 +- app/views/file/new_edit_folder_form.php | 2 +- app/views/files/_fileref_tr.php | 2 +- app/views/files/_folder_tr.php | 2 +- app/views/files/flat.php | 2 +- app/views/files/index.php | 2 +- app/views/start/index.php | 3 +- .../ConditionalAdmission.class.php | 4 +- .../CourseMemberAdmission.class.php | 4 +- .../limitedadmission/LimitedAdmission.class.php | 4 +- .../lockedadmission/LockedAdmission.class.php | 6 +- .../ParticipantRestrictedAdmission.class.php | 4 +- .../passwordadmission/PasswordAdmission.class.php | 6 +- .../PreferentialAdmission.class.php | 4 +- .../termsadmission/TermsAdmission.class.php | 16 +- .../timedadmission/TimedAdmission.class.php | 4 +- lib/bootstrap-autoload.php | 9 +- lib/bootstrap.php | 5 +- lib/calendar/CalendarView.class.php | 2 +- lib/classes/Fullcalendar.class.php | 2 +- lib/classes/I18N.php | 4 +- lib/classes/QuestionType.interface.php | 7 +- lib/classes/Seminar.class.php | 2 +- lib/classes/Siteinfo.php | 4 +- lib/classes/StudipFileloader.php | 2 +- .../AdvancedBasicDataWizardStep.php | 2 +- .../coursewizardsteps/BasicDataWizardStep.php | 2 +- .../coursewizardsteps/LVGroupsWizardStep.php | 8 +- .../coursewizardsteps/StudyAreasWizardStep.php | 2 +- lib/classes/forms/Form.php | 2 +- .../librarysearch/LibraryDocument.class.php | 5 +- lib/classes/sidebar/TemplateWidget.php | 4 +- lib/filesystem/CourseDateFolder.php | 4 +- lib/filesystem/CoursePublicFolder.php | 2 +- lib/filesystem/FileType.php | 12 +- lib/filesystem/FolderType.php | 12 +- lib/filesystem/HiddenFolder.php | 2 +- lib/filesystem/InboxOutboxFolder.php | 8 +- lib/filesystem/PublicFolder.php | 2 +- lib/filesystem/RootFolder.php | 2 +- lib/filesystem/StandardFile.php | 8 +- lib/filesystem/StandardFolder.php | 10 +- lib/filesystem/TimedFolder.php | 4 +- lib/flexi/Factory.php | 243 ++++++ lib/flexi/PhpTemplate.php | 111 +++ lib/flexi/Template.php | 208 +++++ lib/flexi/TemplateNotFoundException.php | 12 + lib/models/Courseware/BlockTypes/BlockType.php | 4 +- .../Courseware/ContainerTypes/ContainerType.php | 4 +- lib/models/Freetext.php | 15 +- lib/models/LikertScale.php | 6 +- lib/models/OERMaterial.php | 2 +- lib/models/QuestionnaireInfo.php | 4 +- lib/models/RangeScale.php | 6 +- lib/models/Vote.php | 4 +- lib/models/calendar/CalendarDate.class.php | 2 +- .../calendar/CalendarDateAssignment.class.php | 6 +- lib/models/resources/ResourceBooking.class.php | 4 +- .../resources/ResourcePropertyDefinition.class.php | 2 +- lib/models/resources/ResourceRequest.class.php | 8 +- lib/modules/ScheduleWidget.php | 2 +- lib/modules/StudipModule.class.php | 4 +- lib/plugins/core/AdminCourseContents.class.php | 4 +- lib/plugins/core/DetailspagePlugin.class.php | 4 +- lib/plugins/core/ExternPagePlugin.php | 4 +- lib/plugins/core/FilesystemPlugin.class.php | 5 +- lib/plugins/core/HomepagePlugin.class.php | 4 +- lib/plugins/core/PortalPlugin.class.php | 4 +- .../core/QuestionnaireAssignmentPlugin.class.php | 4 +- lib/raumzeit/SingleDate.class.php | 2 +- public/install.php | 4 +- public/web_migrate.php | 2 +- templates/contentbar/contentbar.php | 12 +- tests/functional/_bootstrap.php | 4 +- tests/jsonapi/BlubberThreadsCreateTest.php | 2 +- tests/jsonapi/BlubberThreadsIndexTest.php | 3 +- tests/jsonapi/BlubberThreadsShowTest.php | 2 +- tests/jsonapi/ConsultationHelper.php | 5 +- tests/jsonapi/_bootstrap.php | 1 + tests/unit/_bootstrap.php | 6 +- tests/unit/lib/classes/StudipFileloaderTest.php | 2 +- tests/unit/lib/flexi/FactoryTest.php | 119 +++ tests/unit/lib/flexi/PHPTemplatePartialBugTest.php | 45 + tests/unit/lib/flexi/PHPTemplateTest.php | 136 +++ tests/unit/lib/flexi/TemplateEmptyTest.php | 44 + tests/unit/lib/flexi/TemplateMagicMethodsTest.php | 78 ++ tests/unit/lib/flexi/TemplateTest.php | 68 ++ tests/unit/varstream.php | 106 ++- vendor/flexi/LICENSE | 22 - vendor/flexi/README | 0 vendor/flexi/Rakefile | 22 - vendor/flexi/examples/01_hello_world/index.php | 39 - .../01_hello_world/templates/hello_world.php | 1 - vendor/flexi/examples/02_quotes/index.php | 63 -- .../flexi/examples/02_quotes/templates/quotes.php | 23 - vendor/flexi/examples/03_layout/bgbody.gif | Bin 1109 -> 0 bytes vendor/flexi/examples/03_layout/index.php | 66 -- vendor/flexi/examples/03_layout/style.css | 18 - .../flexi/examples/03_layout/templates/layout.php | 10 - .../flexi/examples/03_layout/templates/quotes.php | 20 - .../flexi/examples/04_handler_plugin/mustache.php | 32 - .../04_handler_plugin/templates/layout.php | 3 - .../04_handler_plugin/templates/mustache.mustache | 5 - vendor/flexi/examples/xx_js_templates/index.php | 39 - .../xx_js_templates/templates/js_template.pjs | 3 - vendor/flexi/flexi.php | 24 - vendor/flexi/lib/exceptions.php | 23 - vendor/flexi/lib/flexi.php | 41 - vendor/flexi/lib/helper/js_helper.php | 135 --- vendor/flexi/lib/helper/prototype_helper.php | 764 ----------------- vendor/flexi/lib/helper/scriptaculous_helper.php | 142 ---- vendor/flexi/lib/helper/tag_helper.php | 122 --- vendor/flexi/lib/helper/text_helper.php | 183 ---- vendor/flexi/lib/js_template.php | 55 -- vendor/flexi/lib/mustache_template.php | 85 -- vendor/flexi/lib/php_template.php | 119 --- vendor/flexi/lib/template.php | 251 ------ vendor/flexi/lib/template_factory.php | 281 ------- vendor/flexi/test/all_tests.php | 41 - vendor/flexi/test/coverage.php | 43 - vendor/flexi/test/flexi_tests.php | 61 -- vendor/flexi/test/lib/helper/js_helper_test.php | 93 -- .../test/lib/helper/prototype_helper_test.php | 180 ---- .../test/lib/helper/scriptaculous_helper_test.php | 67 -- vendor/flexi/test/lib/helper/tag_helper_test.php | 65 -- vendor/flexi/test/lib/helper/text_helper_test.php | 80 -- vendor/flexi/test/lib/js_template_test.php | 56 -- vendor/flexi/test/lib/php_template_test.php | 182 ---- vendor/flexi/test/lib/template_factory_test.php | 117 --- vendor/flexi/test/lib/template_test.php | 215 ----- .../templates/factory_tests/baz.unknown_extension | 0 vendor/flexi/test/templates/factory_tests/foo.php | 1 - .../test/templates/layout_with_partials/layout.php | 3 - .../templates/layout_with_partials/partial.php | 1 - .../templates/layout_with_partials/template.php | 1 - .../test/templates/template_tests/attributes.php | 3 - vendor/flexi/test/templates/template_tests/foo.php | 1 - .../templates/template_tests/foo_using_partial.php | 1 - .../template_tests/foo_with_partial_collection.php | 1 - .../test/templates/template_tests/foos_partial.php | 1 - .../flexi/test/templates/template_tests/item.php | 1 - .../templates/template_tests/layouts/layout.php | 1 - .../flexi/test/templates/template_tests/spacer.php | 1 - vendor/flexi/test/varstream.php | 244 ------ vendor/flexi/vendor/mustache.php/LICENSE | 22 - vendor/flexi/vendor/mustache.php/Mustache.php | 931 --------------------- .../flexi/vendor/mustache.php/MustacheLoader.php | 85 -- vendor/flexi/vendor/mustache.php/README.markdown | 98 --- .../vendor/mustache.php/bin/create_example.php | 172 ---- .../examples/child_context/ChildContext.php | 13 - .../examples/child_context/child_context.mustache | 2 - .../examples/child_context/child_context.txt | 2 - .../mustache.php/examples/comments/Comments.php | 7 - .../examples/comments/comments.mustache | 1 - .../mustache.php/examples/comments/comments.txt | 1 - .../mustache.php/examples/complex/complex.mustache | 16 - .../mustache.php/examples/complex/complex.php | 19 - .../mustache.php/examples/complex/complex.txt | 6 - .../examples/delimiters/Delimiters.php | 14 - .../examples/delimiters/delimiters.mustache | 8 - .../examples/delimiters/delimiters.txt | 4 - .../examples/dot_notation/DotNotation.php | 20 - .../examples/dot_notation/dot_notation.mustache | 5 - .../examples/dot_notation/dot_notation.txt | 5 - .../examples/double_section/DoubleSection.php | 9 - .../double_section/double_section.mustache | 7 - .../examples/double_section/double_section.txt | 3 - .../mustache.php/examples/escaped/Escaped.php | 5 - .../mustache.php/examples/escaped/escaped.mustache | 1 - .../mustache.php/examples/escaped/escaped.txt | 1 - .../grand_parent_context/GrandParentContext.php | 24 - .../grand_parent_context.mustache | 7 - .../grand_parent_context/grand_parent_context.txt | 7 - .../vendor/mustache.php/examples/i18n/I18n.php | 20 - .../mustache.php/examples/i18n/i18n.mustache | 1 - .../vendor/mustache.php/examples/i18n/i18n.txt | 1 - .../implicit_iterator/ImplicitIterator.php | 5 - .../implicit_iterator/implicit_iterator.mustache | 3 - .../implicit_iterator/implicit_iterator.txt | 5 - .../InvertedDoubleSection.php | 6 - .../inverted_double_section.mustache | 7 - .../inverted_double_section.txt | 3 - .../examples/inverted_section/InvertedSection.php | 5 - .../inverted_section/inverted_section.mustache | 2 - .../examples/inverted_section/inverted_section.txt | 1 - .../mustache.php/examples/partials/Partials.php | 13 - .../examples/partials/partials.mustache | 2 - .../mustache.php/examples/partials/partials.txt | 3 - .../PartialsWithViewClass.php | 19 - .../partials_with_view_class.mustache | 2 - .../partials_with_view_class.txt | 3 - .../examples/pragma_unescaped/PragmaUnescaped.php | 5 - .../pragma_unescaped/pragma_unescaped.mustache | 3 - .../examples/pragma_unescaped/pragma_unescaped.txt | 2 - .../pragmas_in_partials/PragmasInPartials.php | 8 - .../pragmas_in_partials.mustache | 3 - .../pragmas_in_partials/pragmas_in_partials.txt | 2 - .../recursive_partials/RecursivePartials.php | 16 - .../recursive_partials/recursive_partials.mustache | 1 - .../recursive_partials/recursive_partials.txt | 1 - .../SectionIteratorObjects.php | 16 - .../section_iterator_objects.mustache | 5 - .../section_iterator_objects.txt | 4 - .../section_magic_objects/SectionMagicObjects.php | 26 - .../section_magic_objects.mustache | 6 - .../section_magic_objects.txt | 4 - .../examples/section_objects/SectionObjects.php | 16 - .../section_objects/section_objects.mustache | 6 - .../examples/section_objects/section_objects.txt | 4 - .../mustache.php/examples/sections/Sections.php | 14 - .../examples/sections/sections.mustache | 5 - .../mustache.php/examples/sections/sections.txt | 4 - .../examples/sections_nested/SectionsNested.php | 33 - .../sections_nested/sections_nested.mustache | 7 - .../examples/sections_nested/sections_nested.txt | 12 - .../vendor/mustache.php/examples/simple/Simple.php | 12 - .../mustache.php/examples/simple/simple.mustache | 5 - .../vendor/mustache.php/examples/simple/simple.txt | 3 - .../mustache.php/examples/unescaped/Unescaped.php | 5 - .../examples/unescaped/unescaped.mustache | 1 - .../mustache.php/examples/unescaped/unescaped.txt | 1 - .../vendor/mustache.php/examples/utf8/UTF8.php | 5 - .../mustache.php/examples/utf8/utf8.mustache | 1 - .../vendor/mustache.php/examples/utf8/utf8.txt | 1 - .../examples/utf8_unescaped/UTF8Unescaped.php | 5 - .../utf8_unescaped/utf8_unescaped.mustache | 1 - .../examples/utf8_unescaped/utf8_unescaped.txt | 1 - .../examples/whitespace/Whitespace.php | 37 - .../examples/whitespace/whitespace.mustache | 10 - .../examples/whitespace/whitespace.txt | 12 - .../vendor/mustache.php/test/MustacheCallTest.php | 24 - .../mustache.php/test/MustacheExceptionTest.php | 152 ---- .../test/MustacheHigherOrderSectionsTest.php | 114 --- .../mustache.php/test/MustacheInjectionTest.php | 127 --- .../mustache.php/test/MustacheLoaderTest.php | 60 -- .../test/MustacheObjectSectionTest.php | 73 -- .../mustache.php/test/MustachePragmaTest.php | 74 -- .../test/MustachePragmaUnescapedTest.php | 19 - .../vendor/mustache.php/test/MustacheSpecTest.php | 174 ---- .../vendor/mustache.php/test/MustacheTest.php | 464 ---------- .../vendor/mustache.php/test/fixtures/bar.mustache | 1 - .../vendor/mustache.php/test/fixtures/foo.mustache | 1 - .../vendor/mustache.php/test/lib/yaml/LICENSE | 19 - .../mustache.php/test/lib/yaml/README.markdown | 15 - .../test/lib/yaml/doc/00-Introduction.markdown | 143 ---- .../test/lib/yaml/doc/01-Usage.markdown | 110 --- .../test/lib/yaml/doc/02-YAML.markdown | 312 ------- .../test/lib/yaml/doc/A-License.markdown | 108 --- .../mustache.php/test/lib/yaml/lib/sfYaml.php | 135 --- .../test/lib/yaml/lib/sfYamlDumper.php | 60 -- .../test/lib/yaml/lib/sfYamlInline.php | 442 ---------- .../test/lib/yaml/lib/sfYamlParser.php | 622 -------------- .../vendor/mustache.php/test/lib/yaml/package.xml | 102 --- vendor/flexi/vendor/mustache.php/test/phpunit.xml | 10 - vendor/trails/src/controller.php | 12 +- vendor/trails/trails-abridged.php | 3 +- vendor/trails/trails.php | 12 +- 266 files changed, 1365 insertions(+), 9557 deletions(-) create mode 100644 lib/flexi/Factory.php create mode 100644 lib/flexi/PhpTemplate.php create mode 100644 lib/flexi/Template.php create mode 100644 lib/flexi/TemplateNotFoundException.php create mode 100644 tests/unit/lib/flexi/FactoryTest.php create mode 100644 tests/unit/lib/flexi/PHPTemplatePartialBugTest.php create mode 100644 tests/unit/lib/flexi/PHPTemplateTest.php create mode 100644 tests/unit/lib/flexi/TemplateEmptyTest.php create mode 100644 tests/unit/lib/flexi/TemplateMagicMethodsTest.php create mode 100644 tests/unit/lib/flexi/TemplateTest.php delete mode 100644 vendor/flexi/LICENSE delete mode 100644 vendor/flexi/README delete mode 100644 vendor/flexi/Rakefile delete mode 100644 vendor/flexi/examples/01_hello_world/index.php delete mode 100644 vendor/flexi/examples/01_hello_world/templates/hello_world.php delete mode 100644 vendor/flexi/examples/02_quotes/index.php delete mode 100644 vendor/flexi/examples/02_quotes/templates/quotes.php delete mode 100644 vendor/flexi/examples/03_layout/bgbody.gif delete mode 100644 vendor/flexi/examples/03_layout/index.php delete mode 100644 vendor/flexi/examples/03_layout/style.css delete mode 100644 vendor/flexi/examples/03_layout/templates/layout.php delete mode 100644 vendor/flexi/examples/03_layout/templates/quotes.php delete mode 100644 vendor/flexi/examples/04_handler_plugin/mustache.php delete mode 100644 vendor/flexi/examples/04_handler_plugin/templates/layout.php delete mode 100644 vendor/flexi/examples/04_handler_plugin/templates/mustache.mustache delete mode 100644 vendor/flexi/examples/xx_js_templates/index.php delete mode 100644 vendor/flexi/examples/xx_js_templates/templates/js_template.pjs delete mode 100644 vendor/flexi/flexi.php delete mode 100644 vendor/flexi/lib/exceptions.php delete mode 100644 vendor/flexi/lib/flexi.php delete mode 100644 vendor/flexi/lib/helper/js_helper.php delete mode 100644 vendor/flexi/lib/helper/prototype_helper.php delete mode 100644 vendor/flexi/lib/helper/scriptaculous_helper.php delete mode 100644 vendor/flexi/lib/helper/tag_helper.php delete mode 100644 vendor/flexi/lib/helper/text_helper.php delete mode 100644 vendor/flexi/lib/js_template.php delete mode 100644 vendor/flexi/lib/mustache_template.php delete mode 100644 vendor/flexi/lib/php_template.php delete mode 100644 vendor/flexi/lib/template.php delete mode 100644 vendor/flexi/lib/template_factory.php delete mode 100644 vendor/flexi/test/all_tests.php delete mode 100644 vendor/flexi/test/coverage.php delete mode 100644 vendor/flexi/test/flexi_tests.php delete mode 100644 vendor/flexi/test/lib/helper/js_helper_test.php delete mode 100644 vendor/flexi/test/lib/helper/prototype_helper_test.php delete mode 100644 vendor/flexi/test/lib/helper/scriptaculous_helper_test.php delete mode 100644 vendor/flexi/test/lib/helper/tag_helper_test.php delete mode 100644 vendor/flexi/test/lib/helper/text_helper_test.php delete mode 100644 vendor/flexi/test/lib/js_template_test.php delete mode 100644 vendor/flexi/test/lib/php_template_test.php delete mode 100644 vendor/flexi/test/lib/template_factory_test.php delete mode 100644 vendor/flexi/test/lib/template_test.php delete mode 100644 vendor/flexi/test/templates/factory_tests/baz.unknown_extension delete mode 100644 vendor/flexi/test/templates/factory_tests/foo.php delete mode 100644 vendor/flexi/test/templates/layout_with_partials/layout.php delete mode 100644 vendor/flexi/test/templates/layout_with_partials/partial.php delete mode 100644 vendor/flexi/test/templates/layout_with_partials/template.php delete mode 100644 vendor/flexi/test/templates/template_tests/attributes.php delete mode 100644 vendor/flexi/test/templates/template_tests/foo.php delete mode 100644 vendor/flexi/test/templates/template_tests/foo_using_partial.php delete mode 100644 vendor/flexi/test/templates/template_tests/foo_with_partial_collection.php delete mode 100644 vendor/flexi/test/templates/template_tests/foos_partial.php delete mode 100644 vendor/flexi/test/templates/template_tests/item.php delete mode 100644 vendor/flexi/test/templates/template_tests/layouts/layout.php delete mode 100644 vendor/flexi/test/templates/template_tests/spacer.php delete mode 100644 vendor/flexi/test/varstream.php delete mode 100644 vendor/flexi/vendor/mustache.php/LICENSE delete mode 100644 vendor/flexi/vendor/mustache.php/Mustache.php delete mode 100644 vendor/flexi/vendor/mustache.php/MustacheLoader.php delete mode 100644 vendor/flexi/vendor/mustache.php/README.markdown delete mode 100644 vendor/flexi/vendor/mustache.php/bin/create_example.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/child_context/ChildContext.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/child_context/child_context.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/examples/child_context/child_context.txt delete mode 100644 vendor/flexi/vendor/mustache.php/examples/comments/Comments.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/comments/comments.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/examples/comments/comments.txt delete mode 100644 vendor/flexi/vendor/mustache.php/examples/complex/complex.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/examples/complex/complex.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/complex/complex.txt delete mode 100644 vendor/flexi/vendor/mustache.php/examples/delimiters/Delimiters.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/delimiters/delimiters.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/examples/delimiters/delimiters.txt delete mode 100644 vendor/flexi/vendor/mustache.php/examples/dot_notation/DotNotation.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/dot_notation/dot_notation.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/examples/dot_notation/dot_notation.txt delete mode 100644 vendor/flexi/vendor/mustache.php/examples/double_section/DoubleSection.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/double_section/double_section.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/examples/double_section/double_section.txt delete mode 100644 vendor/flexi/vendor/mustache.php/examples/escaped/Escaped.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/escaped/escaped.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/examples/escaped/escaped.txt delete mode 100644 vendor/flexi/vendor/mustache.php/examples/grand_parent_context/GrandParentContext.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/grand_parent_context/grand_parent_context.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/examples/grand_parent_context/grand_parent_context.txt delete mode 100644 vendor/flexi/vendor/mustache.php/examples/i18n/I18n.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/i18n/i18n.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/examples/i18n/i18n.txt delete mode 100644 vendor/flexi/vendor/mustache.php/examples/implicit_iterator/ImplicitIterator.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/implicit_iterator/implicit_iterator.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/examples/implicit_iterator/implicit_iterator.txt delete mode 100644 vendor/flexi/vendor/mustache.php/examples/inverted_double_section/InvertedDoubleSection.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/inverted_double_section/inverted_double_section.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/examples/inverted_double_section/inverted_double_section.txt delete mode 100644 vendor/flexi/vendor/mustache.php/examples/inverted_section/InvertedSection.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/inverted_section/inverted_section.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/examples/inverted_section/inverted_section.txt delete mode 100644 vendor/flexi/vendor/mustache.php/examples/partials/Partials.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/partials/partials.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/examples/partials/partials.txt delete mode 100644 vendor/flexi/vendor/mustache.php/examples/partials_with_view_class/PartialsWithViewClass.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/partials_with_view_class/partials_with_view_class.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/examples/partials_with_view_class/partials_with_view_class.txt delete mode 100644 vendor/flexi/vendor/mustache.php/examples/pragma_unescaped/PragmaUnescaped.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/pragma_unescaped/pragma_unescaped.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/examples/pragma_unescaped/pragma_unescaped.txt delete mode 100644 vendor/flexi/vendor/mustache.php/examples/pragmas_in_partials/PragmasInPartials.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/pragmas_in_partials/pragmas_in_partials.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/examples/pragmas_in_partials/pragmas_in_partials.txt delete mode 100644 vendor/flexi/vendor/mustache.php/examples/recursive_partials/RecursivePartials.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/recursive_partials/recursive_partials.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/examples/recursive_partials/recursive_partials.txt delete mode 100644 vendor/flexi/vendor/mustache.php/examples/section_iterator_objects/SectionIteratorObjects.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/section_iterator_objects/section_iterator_objects.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/examples/section_iterator_objects/section_iterator_objects.txt delete mode 100644 vendor/flexi/vendor/mustache.php/examples/section_magic_objects/SectionMagicObjects.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/section_magic_objects/section_magic_objects.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/examples/section_magic_objects/section_magic_objects.txt delete mode 100644 vendor/flexi/vendor/mustache.php/examples/section_objects/SectionObjects.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/section_objects/section_objects.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/examples/section_objects/section_objects.txt delete mode 100644 vendor/flexi/vendor/mustache.php/examples/sections/Sections.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/sections/sections.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/examples/sections/sections.txt delete mode 100644 vendor/flexi/vendor/mustache.php/examples/sections_nested/SectionsNested.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/sections_nested/sections_nested.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/examples/sections_nested/sections_nested.txt delete mode 100644 vendor/flexi/vendor/mustache.php/examples/simple/Simple.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/simple/simple.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/examples/simple/simple.txt delete mode 100644 vendor/flexi/vendor/mustache.php/examples/unescaped/Unescaped.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/unescaped/unescaped.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/examples/unescaped/unescaped.txt delete mode 100644 vendor/flexi/vendor/mustache.php/examples/utf8/UTF8.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/utf8/utf8.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/examples/utf8/utf8.txt delete mode 100644 vendor/flexi/vendor/mustache.php/examples/utf8_unescaped/UTF8Unescaped.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/utf8_unescaped/utf8_unescaped.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/examples/utf8_unescaped/utf8_unescaped.txt delete mode 100644 vendor/flexi/vendor/mustache.php/examples/whitespace/Whitespace.php delete mode 100644 vendor/flexi/vendor/mustache.php/examples/whitespace/whitespace.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/examples/whitespace/whitespace.txt delete mode 100644 vendor/flexi/vendor/mustache.php/test/MustacheCallTest.php delete mode 100644 vendor/flexi/vendor/mustache.php/test/MustacheExceptionTest.php delete mode 100644 vendor/flexi/vendor/mustache.php/test/MustacheHigherOrderSectionsTest.php delete mode 100644 vendor/flexi/vendor/mustache.php/test/MustacheInjectionTest.php delete mode 100644 vendor/flexi/vendor/mustache.php/test/MustacheLoaderTest.php delete mode 100644 vendor/flexi/vendor/mustache.php/test/MustacheObjectSectionTest.php delete mode 100644 vendor/flexi/vendor/mustache.php/test/MustachePragmaTest.php delete mode 100644 vendor/flexi/vendor/mustache.php/test/MustachePragmaUnescapedTest.php delete mode 100644 vendor/flexi/vendor/mustache.php/test/MustacheSpecTest.php delete mode 100644 vendor/flexi/vendor/mustache.php/test/MustacheTest.php delete mode 100644 vendor/flexi/vendor/mustache.php/test/fixtures/bar.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/test/fixtures/foo.mustache delete mode 100644 vendor/flexi/vendor/mustache.php/test/lib/yaml/LICENSE delete mode 100644 vendor/flexi/vendor/mustache.php/test/lib/yaml/README.markdown delete mode 100644 vendor/flexi/vendor/mustache.php/test/lib/yaml/doc/00-Introduction.markdown delete mode 100644 vendor/flexi/vendor/mustache.php/test/lib/yaml/doc/01-Usage.markdown delete mode 100644 vendor/flexi/vendor/mustache.php/test/lib/yaml/doc/02-YAML.markdown delete mode 100644 vendor/flexi/vendor/mustache.php/test/lib/yaml/doc/A-License.markdown delete mode 100644 vendor/flexi/vendor/mustache.php/test/lib/yaml/lib/sfYaml.php delete mode 100644 vendor/flexi/vendor/mustache.php/test/lib/yaml/lib/sfYamlDumper.php delete mode 100644 vendor/flexi/vendor/mustache.php/test/lib/yaml/lib/sfYamlInline.php delete mode 100644 vendor/flexi/vendor/mustache.php/test/lib/yaml/lib/sfYamlParser.php delete mode 100644 vendor/flexi/vendor/mustache.php/test/lib/yaml/package.xml delete mode 100644 vendor/flexi/vendor/mustache.php/test/phpunit.xml diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index d262513..9ac30a3 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -32,6 +32,15 @@ - Die Bibliothek `opis/json-schema` wurde auf Version 2.3.0 aktualisiert ([Issue #4173](https://gitlab.studip.de/studip/studip/-/issues/4173)). Dadurch ergeben sich die folgenden Änderungen für Komponenten aus Courseware (siehe auch [Migration Guide](https://opis.io/json-schema/2.x/php-migration.html#validator)): - Instanzen von `Courseware\ContainerTypes\BlockType` müssen die Methode `getJsonSchema` anpassen. Der Return Type ist nun `string` und es muss der Inhalt der Schema-Datei zurückgegeben werden ohne Aufruf von `Schema::fromJsonString()`. - Instanzen von `Courseware\ContainerTypes\ContainerType` müssen die Methode `getJsonSchema` anpassen. Der Return Type ist nun `string` und es muss der Inhalt der Schema-Datei zurückgegeben werden ohne Aufruf von `Schema::fromJsonString()`. +- Die von Stud.IP verwendete Template-Bibliothek "Flexi Templates" wurde vollständig in den Kern integriert. + Obwohl die Umstellung abwärtskompatibel sein sollte, sollten die Klassen folgendermassen ersetzt werden: + - `Flexi_TemplateFactory` > `Flexi\Factory` + - `Flexi_Template` > `Flexi\Template` + - `Flexi_PhpTemplate` > `Flexi\PhpTemplate` + - `Flexi_TemplateNotFoundException` > `Flexi\TemplateNotFoundException` + + Sollte ein Plugin manuell Flexi einbinden, so wird dies zu einem Fehler führen. Jegliches Einbinden von Dateien + unterhalb von `vendor/flexi` muss ersatzlos entfernt werden. ## Security related issues diff --git a/app/controllers/admin/courses.php b/app/controllers/admin/courses.php index 82c389b..27b6ca6 100644 --- a/app/controllers/admin/courses.php +++ b/app/controllers/admin/courses.php @@ -22,6 +22,7 @@ * @category Stud.IP * @since 3.1 */ + require_once 'lib/meine_seminare_func.inc.php'; require_once 'lib/object.inc.php'; require_once 'lib/archiv.inc.php'; //for lastActivity in getCourses() method @@ -420,7 +421,7 @@ class Admin_CoursesController extends AuthenticatedController } } } - $tf = new Flexi_TemplateFactory($GLOBALS['STUDIP_BASE_PATH'] . '/app/views'); + $tf = new Flexi\Factory($GLOBALS['STUDIP_BASE_PATH'] . '/app/views'); switch ($GLOBALS['user']->cfg->MY_COURSES_ACTION_AREA) { case 1: case 2: @@ -495,7 +496,7 @@ class Admin_CoursesController extends AuthenticatedController $multimode = $plugin->useMultimode(); if ($multimode) { $data['buttons_top'] = ''; - if ($multimode instanceof Flexi_Template) { + if ($multimode instanceof Flex\Template) { $data['buttons_bottom'] = $multimode->render(); } elseif ($multimode instanceof \Studip\Button) { $data['buttons_bottom'] = (string) $multimode; @@ -715,11 +716,14 @@ class Admin_CoursesController extends AuthenticatedController foreach ($plugin->adminAvailableContents() as $index => $label) { if (in_array($plugin->getPluginId() . '_' . $index, $activated_fields)) { $content = $plugin->adminAreaGetCourseContent($course, $index); - $d[$plugin->getPluginId()."_".$index] = $content instanceof Flexi_Template ? $content->render() : $content; + if ($content instanceof Flexi\Template) { + $content = $content->render(); + } + $d[$plugin->getPluginId()."_".$index] = $content; } } } - $tf = new Flexi_TemplateFactory($GLOBALS['STUDIP_BASE_PATH'].'/app/views'); + $tf = new Flexi\Factory($GLOBALS['STUDIP_BASE_PATH'].'/app/views'); switch ($GLOBALS['user']->cfg->MY_COURSES_ACTION_AREA) { case 1: @@ -840,7 +844,10 @@ class Admin_CoursesController extends AuthenticatedController foreach (PluginManager::getInstance()->getPlugins(AdminCourseAction::class) as $plugin) { if ($GLOBALS['user']->cfg->MY_COURSES_ACTION_AREA === get_class($plugin)) { $output = $plugin->getAdminCourseActionTemplate($course->getId()); - $d['action'] = $output instanceof Flexi_Template ? $output->render() : (string) $output; + if ($output instanceof Flexi\Template) { + $output = $output->render(); + } + $d['action'] = (string) $output; break; } } @@ -1033,10 +1040,10 @@ class Admin_CoursesController extends AuthenticatedController foreach ($plugin->adminAvailableContents() as $index => $label) { if (in_array($plugin->getPluginId() . "_" . $index, $filter_config)) { $content = $plugin->adminAreaGetCourseContent($course, $index); - $row[$plugin->getPluginId() . "_" . $index] = strip_tags(is_a($content, 'Flexi_Template') - ? $content->render() - : $content - ); + if ($content instanceof Flexi\Template) { + $content = $content->render(); + } + $row[$plugin->getPluginId() . "_" . $index] = strip_tags($content); } } } diff --git a/app/controllers/calendar/schedule.php b/app/controllers/calendar/schedule.php index 88c4304..5d9a26e 100644 --- a/app/controllers/calendar/schedule.php +++ b/app/controllers/calendar/schedule.php @@ -143,7 +143,7 @@ class Calendar_ScheduleController extends AuthenticatedController 'entry_height' => $this->calendar_view->getHeight() ]; - $factory = new Flexi_TemplateFactory($this->dispatcher->trails_root . '/views'); + $factory = new Flexi\Factory($this->dispatcher->trails_root . '/views'); PageLayout::addStyle($factory->render('calendar/schedule/stylesheet', $style_parameters), 'screen, print'); if (Request::option('printview')) { diff --git a/app/controllers/file.php b/app/controllers/file.php index 11b1949..095e295 100644 --- a/app/controllers/file.php +++ b/app/controllers/file.php @@ -980,7 +980,7 @@ class FileController extends AuthenticatedController ); } else { $this->top_folder = $this->filesystemplugin->getFolder($folder_id, true); - if (is_a($this->top_folder, 'Flexi_Template')) { + if ($this->top_folder instanceof Flexi\Template) { $this->top_folder->select = true; $this->top_folder->to_folder = $this->to_folder; $this->render_text($this->top_folder); @@ -1505,7 +1505,7 @@ class FileController extends AuthenticatedController $folder_id = substr($folder_id, 0, strpos($folder_id, "?")); } $this->top_folder = $this->filesystemplugin->getFolder($folder_id, true); - if (is_a($this->top_folder, 'Flexi_Template')) { + if ($this->top_folder instanceof Flexi\Template) { $this->top_folder->select = true; $this->top_folder->to_folder = $this->to_folder; $this->render_text($this->top_folder->render()); diff --git a/app/controllers/resources/booking.php b/app/controllers/resources/booking.php index 294aeaa..45ccb16 100644 --- a/app/controllers/resources/booking.php +++ b/app/controllers/resources/booking.php @@ -242,9 +242,7 @@ class Resources_BookingController extends AuthenticatedController return true; } - $template_factory = new Flexi_TemplateFactory( - $GLOBALS['STUDIP_BASE_PATH'] . '/locale/' - ); + $template_factory = new Flexi\Factory($GLOBALS['STUDIP_BASE_PATH'] . '/locale/'); $derived_resource = $booking->resource->getDerivedClassInstance(); $system_lang = $_SESSION['_language']; diff --git a/app/controllers/room_management/planning.php b/app/controllers/room_management/planning.php index 1484bbb..3da7904 100644 --- a/app/controllers/room_management/planning.php +++ b/app/controllers/room_management/planning.php @@ -1371,7 +1371,7 @@ class RoomManagement_PlanningController extends AuthenticatedController $export = Request::get('export'); if ($export == 'html') { //Load the export template: - $factory = new Flexi_TemplateFactory( + $factory = new Flexi\Factory( $GLOBALS['STUDIP_BASE_PATH'] . '/app/views/room_management/planning/' ); diff --git a/app/controllers/shared/download.php b/app/controllers/shared/download.php index 92d15d9..f94bc86 100644 --- a/app/controllers/shared/download.php +++ b/app/controllers/shared/download.php @@ -158,7 +158,7 @@ class Shared_DownloadController extends AuthenticatedController } $path = $GLOBALS['STUDIP_BASE_PATH'] . '/app/views/shared/modul/'; - $factory = new Flexi_TemplateFactory($path); + $factory = new Flexi\Factory($path); $template = $factory->open('_modul'); $template->_ = function ($string) { return $this->_($string); }; @@ -166,7 +166,7 @@ class Shared_DownloadController extends AuthenticatedController $template->display_language = $display_language; $content = $template->render(); - $factory = new \Flexi_TemplateFactory($path); + $factory = new Flexi\Factory($path); $type = 1; if (count($modul->modulteile) == 1) { $modulteil = $modul->modulteile->first(); diff --git a/app/controllers/start.php b/app/controllers/start.php index 87c493e..3040d58 100644 --- a/app/controllers/start.php +++ b/app/controllers/start.php @@ -53,6 +53,8 @@ class StartController extends AuthenticatedController } } + $this->widget_layout = $this->get_template_factory()->open('start/_widget.php'); + $sidebar = Sidebar::get(); $nav = $sidebar->addWidget(new NavigationWidget()); diff --git a/app/views/file/file_details.php b/app/views/file/file_details.php index 76f996a..ddbd7e4 100644 --- a/app/views/file/file_details.php +++ b/app/views/file/file_details.php @@ -1,21 +1,21 @@
render_partial('file/_file_aside.php') ?>
- + render() ?>

diff --git a/app/views/file/folder_details.php b/app/views/file/folder_details.php index 5bd6574..7d1fe04 100644 --- a/app/views/file/folder_details.php +++ b/app/views/file/folder_details.php @@ -10,7 +10,7 @@ $folder_template = $folder->getDescriptionTemplate();

- + render() ?> diff --git a/app/views/file/new_edit_folder_form.php b/app/views/file/new_edit_folder_form.php index d2dd931..32b9800 100644 --- a/app/views/file/new_edit_folder_form.php +++ b/app/views/file/new_edit_folder_form.php @@ -32,7 +32,7 @@
getDescriptionTemplate()): ?> - render() : $template, false, true) ?> + render() : $template, false, true) ?>
diff --git a/app/views/files/_fileref_tr.php b/app/views/files/_fileref_tr.php index f282f79..fc486ae 100644 --- a/app/views/files/_fileref_tr.php +++ b/app/views/files/_fileref_tr.php @@ -75,7 +75,7 @@ if ($file->isDownloadable($GLOBALS['user']->id)) { data-sort-value="getAdditionalColumnOrderWeigh($index)) ?>"> getContentForAdditionalColumn($index) ?> - render() : $content ?> + render() : $content ?> diff --git a/app/views/files/_folder_tr.php b/app/views/files/_folder_tr.php index 09cd295..c3f77f6 100644 --- a/app/views/files/_folder_tr.php +++ b/app/views/files/_folder_tr.php @@ -61,7 +61,7 @@ if ($folder->isReadable($GLOBALS['user']->id)) { data-sort-value="getAdditionalColumnOrderWeigh($index)) ?>"> getContentForAdditionalColumn($index) ?> - render() : $content ?> + render() : $content ?> diff --git a/app/views/files/flat.php b/app/views/files/flat.php index a7d0c93..1440117 100644 --- a/app/views/files/flat.php +++ b/app/views/files/flat.php @@ -13,7 +13,7 @@ $vue_topFolder = [ 'description' => $topFolder->getDescriptionTemplate(), 'additionalColumns' => $topFolder->getAdditionalColumns(), ]; -if (is_a($vue_topFolder['description'], "Flexi_Template")) { +if ($vue_topFolder['description'] instanceof Flexi\Template) { $vue_topFolder['description'] = $vue_topFolder['description']->render(); } $vue_topFolder['buttons'] = ''; diff --git a/app/views/files/index.php b/app/views/files/index.php index 94ae3f4..6bf28f7 100644 --- a/app/views/files/index.php +++ b/app/views/files/index.php @@ -23,7 +23,7 @@ 'additionalColumns' => $topFolder->getAdditionalColumns(), 'buttons' => null ]; - if (is_a($vue_topFolder['description'], "Flexi_Template")) { + if ($vue_topFolder['description'] instanceof Flexi\Template) { $vue_topFolder['description'] = $vue_topFolder['description']->render(); } $vue_files = []; diff --git a/app/views/start/index.php b/app/views/start/index.php index f4e7fcc..1fa65ca 100644 --- a/app/views/start/index.php +++ b/app/views/start/index.php @@ -1,6 +1,7 @@

@@ -29,7 +30,7 @@ if (Config::get()->BANNER_ADS_ENABLE) {
  • getPortalTemplate()): ?> - set_layout($this->_factory->open('start/_widget')) ?> + set_layout($widget_layout) ?> render_partial($template, compact('widget')) ?> render_partial('start/_widget', compact('widget')) ?> diff --git a/lib/admissionrules/conditionaladmission/ConditionalAdmission.class.php b/lib/admissionrules/conditionaladmission/ConditionalAdmission.class.php index 63275f0..7fdbc00 100644 --- a/lib/admissionrules/conditionaladmission/ConditionalAdmission.class.php +++ b/lib/admissionrules/conditionaladmission/ConditionalAdmission.class.php @@ -207,7 +207,7 @@ class ConditionalAdmission extends AdmissionRule // Open generic admission rule template. $tpl = $GLOBALS['template_factory']->open('admission/rules/configure'); $tpl->set_attribute('rule', $this); - $factory = new Flexi_TemplateFactory(dirname(__FILE__).'/templates/'); + $factory = new Flexi\Factory(__DIR__ . '/templates/'); // Now open specific template for this rule and insert base template. $tpl2 = $factory->open('configure'); $tpl2->set_attribute('rule', $this); @@ -471,7 +471,7 @@ class ConditionalAdmission extends AdmissionRule */ public function toString() { - $factory = new Flexi_TemplateFactory(dirname(__FILE__).'/templates/'); + $factory = new Flexi\Factory(__DIR__ . '/templates/'); $tpl = $factory->open('info'); $tpl->set_attribute('rule', $this); return $tpl->render(); diff --git a/lib/admissionrules/coursememberadmission/CourseMemberAdmission.class.php b/lib/admissionrules/coursememberadmission/CourseMemberAdmission.class.php index a502971..a3309e8 100644 --- a/lib/admissionrules/coursememberadmission/CourseMemberAdmission.class.php +++ b/lib/admissionrules/coursememberadmission/CourseMemberAdmission.class.php @@ -253,8 +253,8 @@ class CourseMemberAdmission extends AdmissionRule return ''; } - private function getTemplateFactory(): Flexi_TemplateFactory + private function getTemplateFactory(): Flexi\Factory { - return new Flexi_TemplateFactory(__DIR__ . '/templates/'); + return new Flexi\Factory(__DIR__ . '/templates/'); } } diff --git a/lib/admissionrules/limitedadmission/LimitedAdmission.class.php b/lib/admissionrules/limitedadmission/LimitedAdmission.class.php index b0cb1ca..a193bda 100644 --- a/lib/admissionrules/limitedadmission/LimitedAdmission.class.php +++ b/lib/admissionrules/limitedadmission/LimitedAdmission.class.php @@ -126,7 +126,7 @@ class LimitedAdmission extends AdmissionRule // Open generic admission rule template. $tpl = $GLOBALS['template_factory']->open('admission/rules/configure'); $tpl->set_attribute('rule', $this); - $factory = new Flexi_TemplateFactory(dirname(__FILE__).'/templates/'); + $factory = new Flexi\Factory(dirname(__FILE__).'/templates/'); // Now open specific template for this rule and insert base template. $tpl2 = $factory->open('configure'); $tpl2->set_attribute('rule', $this); @@ -248,7 +248,7 @@ class LimitedAdmission extends AdmissionRule * @return String */ public function toString() { - $factory = new Flexi_TemplateFactory(dirname(__FILE__).'/templates/'); + $factory = new Flexi\Factory(dirname(__FILE__).'/templates/'); $tpl = $factory->open('info'); $tpl->set_attribute('rule', $this); return $tpl->render(); diff --git a/lib/admissionrules/lockedadmission/LockedAdmission.class.php b/lib/admissionrules/lockedadmission/LockedAdmission.class.php index c313d55..0ca324b 100644 --- a/lib/admissionrules/lockedadmission/LockedAdmission.class.php +++ b/lib/admissionrules/lockedadmission/LockedAdmission.class.php @@ -72,7 +72,7 @@ class LockedAdmission extends AdmissionRule * @return String */ public function getTemplate() { - $factory = new Flexi_TemplateFactory(dirname(__FILE__).'/templates/'); + $factory = new Flexi\Factory(dirname(__FILE__).'/templates/'); // Now open specific template for this rule and insert base template. $tpl = $factory->open('configure'); $tpl->set_attribute('rule', $this); @@ -125,7 +125,7 @@ class LockedAdmission extends AdmissionRule * @return String */ public function toString() { - $factory = new Flexi_TemplateFactory(dirname(__FILE__).'/templates/'); + $factory = new Flexi\Factory(dirname(__FILE__).'/templates/'); $tpl = $factory->open('info'); $tpl->set_attribute('rule', $this); return $tpl->render(); @@ -133,4 +133,4 @@ class LockedAdmission extends AdmissionRule } /* end of class LockedAdmission */ -?> \ No newline at end of file +?> diff --git a/lib/admissionrules/participantrestrictedadmission/ParticipantRestrictedAdmission.class.php b/lib/admissionrules/participantrestrictedadmission/ParticipantRestrictedAdmission.class.php index a64b88a..28a910d 100644 --- a/lib/admissionrules/participantrestrictedadmission/ParticipantRestrictedAdmission.class.php +++ b/lib/admissionrules/participantrestrictedadmission/ParticipantRestrictedAdmission.class.php @@ -107,7 +107,7 @@ class ParticipantRestrictedAdmission extends AdmissionRule */ public function getTemplate() { - $factory = new Flexi_TemplateFactory(dirname(__FILE__).'/templates/'); + $factory = new Flexi\Factory(dirname(__FILE__).'/templates/'); // Open specific template for this rule and insert base template. $tpl = $factory->open('configure'); $tpl->set_attribute('rule', $this); @@ -199,7 +199,7 @@ class ParticipantRestrictedAdmission extends AdmissionRule */ public function toString() { - $factory = new Flexi_TemplateFactory(dirname(__FILE__).'/templates/'); + $factory = new Flexi\Factory(dirname(__FILE__).'/templates/'); $tpl = $factory->open('info'); $tpl->set_attribute('rule', $this); return $tpl->render(); diff --git a/lib/admissionrules/passwordadmission/PasswordAdmission.class.php b/lib/admissionrules/passwordadmission/PasswordAdmission.class.php index 6a99066..0650630 100644 --- a/lib/admissionrules/passwordadmission/PasswordAdmission.class.php +++ b/lib/admissionrules/passwordadmission/PasswordAdmission.class.php @@ -80,7 +80,7 @@ class PasswordAdmission extends AdmissionRule * @return String A template-based input form. */ public function getInput() { - $factory = new Flexi_TemplateFactory(dirname(__FILE__).'/templates/'); + $factory = new Flexi\Factory(dirname(__FILE__).'/templates/'); $tpl = $factory->open('input'); $tpl->set_attribute('rule', $this); return $tpl->render(); @@ -111,7 +111,7 @@ class PasswordAdmission extends AdmissionRule // Open generic admission rule template. $tpl = $GLOBALS['template_factory']->open('admission/rules/configure'); $tpl->set_attribute('rule', $this); - $factory = new Flexi_TemplateFactory(dirname(__FILE__).'/templates/'); + $factory = new Flexi\Factory(dirname(__FILE__).'/templates/'); // Now open specific template for this rule and insert base template. $tpl2 = $factory->open('configure'); $tpl2->set_attribute('rule', $this); @@ -214,7 +214,7 @@ class PasswordAdmission extends AdmissionRule * @return String */ public function toString() { - $factory = new Flexi_TemplateFactory(dirname(__FILE__).'/templates/'); + $factory = new Flexi\Factory(dirname(__FILE__).'/templates/'); $tpl = $factory->open('info'); $tpl->set_attribute('rule', $this); return $tpl->render(); diff --git a/lib/admissionrules/preferentialadmission/PreferentialAdmission.class.php b/lib/admissionrules/preferentialadmission/PreferentialAdmission.class.php index 6bb6ceb..bee3e19 100644 --- a/lib/admissionrules/preferentialadmission/PreferentialAdmission.class.php +++ b/lib/admissionrules/preferentialadmission/PreferentialAdmission.class.php @@ -338,7 +338,7 @@ class PreferentialAdmission extends AdmissionRule */ public function getTemplate() { - $factory = new Flexi_TemplateFactory(__DIR__.'/templates/'); + $factory = new Flexi\Factory(__DIR__.'/templates/'); // Now open specific template for this rule and insert base template. $tpl = $factory->open('configure'); $tpl->set_attribute('rule', $this); @@ -503,7 +503,7 @@ class PreferentialAdmission extends AdmissionRule */ public function toString() { - $factory = new Flexi_TemplateFactory(__DIR__.'/templates/'); + $factory = new Flexi\Factory(__DIR__.'/templates/'); $tpl = $factory->open('info'); $tpl->set_attribute('rule', $this); return $tpl->render(); diff --git a/lib/admissionrules/termsadmission/TermsAdmission.class.php b/lib/admissionrules/termsadmission/TermsAdmission.class.php index 112a12e..50c8712 100644 --- a/lib/admissionrules/termsadmission/TermsAdmission.class.php +++ b/lib/admissionrules/termsadmission/TermsAdmission.class.php @@ -61,16 +61,16 @@ class TermsAdmission extends AdmissionRule /** * Shows an input form * - * @return String A template-based input form. - * @throws Flexi_TemplateNotFoundException + * @return string A template-based input form. + * @throws Flexi\TemplateNotFoundException */ public function getInput() { - $factory = new Flexi_TemplateFactory(__DIR__ . '/templates'); + $factory = new Flexi\Factory(__DIR__ . '/templates'); $template = $factory->open('input'); $template->rule = $this; - return MessageBox::info($template->render())->hideClose(true); + return (string) MessageBox::info($template->render())->hideClose(); } /** @@ -84,11 +84,11 @@ class TermsAdmission extends AdmissionRule * Gets the template that provides a configuration GUI for this rule. * * @return String - * @throws Flexi_TemplateNotFoundException + * @throws Flexi\TemplateNotFoundException */ public function getTemplate() { - $factory = new Flexi_TemplateFactory(__DIR__ . '/templates'); + $factory = new Flexi\Factory(__DIR__ . '/templates'); $template = $factory->open('configure'); $template->rule = $this; @@ -158,11 +158,11 @@ class TermsAdmission extends AdmissionRule * A textual description of the current rule. * * @return String - * @throws Flexi_TemplateNotFoundException + * @throws Flexi\TemplateNotFoundException */ public function toString() { - $factory = new Flexi_TemplateFactory(__DIR__ . '/templates/'); + $factory = new Flexi\Factory(__DIR__ . '/templates/'); $template = $factory->open('info'); $template->rule = $this; diff --git a/lib/admissionrules/timedadmission/TimedAdmission.class.php b/lib/admissionrules/timedadmission/TimedAdmission.class.php index 735fdee..e167bd8 100644 --- a/lib/admissionrules/timedadmission/TimedAdmission.class.php +++ b/lib/admissionrules/timedadmission/TimedAdmission.class.php @@ -101,7 +101,7 @@ class TimedAdmission extends AdmissionRule * @return String */ public function getTemplate() { - $factory = new Flexi_TemplateFactory(dirname(__FILE__).'/templates/'); + $factory = new Flexi\Factory(dirname(__FILE__).'/templates/'); // Open specific template for this rule and insert base template. $tpl = $factory->open('configure'); $tpl->set_attribute('rule', $this); @@ -213,7 +213,7 @@ class TimedAdmission extends AdmissionRule */ public function toString() { - $factory = new Flexi_TemplateFactory(dirname(__FILE__).'/templates/'); + $factory = new Flexi\Factory(dirname(__FILE__).'/templates/'); $tpl = $factory->open('info'); $tpl->set_attribute('rule', $this); return $tpl->render(); diff --git a/lib/bootstrap-autoload.php b/lib/bootstrap-autoload.php index 1f3f6d4..0bbad81 100644 --- a/lib/bootstrap-autoload.php +++ b/lib/bootstrap-autoload.php @@ -51,11 +51,18 @@ StudipAutoloader::addAutoloadPath('lib/raumzeit'); StudipAutoloader::addAutoloadPath('lib/resources'); StudipAutoloader::addAutoloadPath('lib/activities', 'Studip\\Activity'); -StudipAutoloader::addAutoloadPath('lib/extern'); StudipAutoloader::addAutoloadPath('lib/calendar/lib'); StudipAutoloader::addAutoloadPath('lib/elearning'); +StudipAutoloader::addAutoloadPath('lib/extern'); StudipAutoloader::addAutoloadPath('lib/ilias_interface'); +// Flexi +StudipAutoloader::addAutoloadPath('lib/flexi', 'Flexi'); +class_alias(Flexi\PhpTemplate::class, 'Flexi_PhpTemplate'); +class_alias(Flexi\Template::class, 'Flexi_Template'); +class_alias(Flexi\Factory::class, 'Flexi_TemplateFactory'); +class_alias(Flexi\TemplateNotFoundException::class, 'Flexi_TemplateNotFoundException'); + // Messy file names StudipAutoloader::addClassLookups([ 'email_validation_class' => 'lib/phplib/email_validation.class.php', diff --git a/lib/bootstrap.php b/lib/bootstrap.php index 0c66a97..e9c9bb5 100644 --- a/lib/bootstrap.php +++ b/lib/bootstrap.php @@ -54,7 +54,7 @@ $ABSOLUTE_URI_STUDIP = ""; if (isset($_SERVER['SERVER_NAME'])) { // work around possible bug in lighttpd if (mb_strpos($_SERVER['SERVER_NAME'], ':') !== false) { - list($_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT']) = + [$_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT']] = explode(':', $_SERVER['SERVER_NAME']); } @@ -125,8 +125,7 @@ Assets::set_assets_url($GLOBALS['ASSETS_URL']); Assets::set_assets_path($GLOBALS['ASSETS_PATH']); // globale template factory anlegen -require_once 'vendor/flexi/lib/flexi.php'; -$GLOBALS['template_factory'] = new Flexi_TemplateFactory("{$STUDIP_BASE_PATH}/templates"); +$GLOBALS['template_factory'] = new Flexi\Factory("{$STUDIP_BASE_PATH}/templates"); // set default pdo connection try { diff --git a/lib/calendar/CalendarView.class.php b/lib/calendar/CalendarView.class.php index fc69127..3d89ef1 100644 --- a/lib/calendar/CalendarView.class.php +++ b/lib/calendar/CalendarView.class.php @@ -214,7 +214,7 @@ class CalendarView 'whole_height' => $this->getOverallHeight(), 'entry_height' => $this->getHeight() ]; - $factory = new Flexi_TemplateFactory(dirname(__file__).'/../../app/views'); + $factory = new Flexi\Factory(dirname(__file__).'/../../app/views'); PageLayout::addStyle($factory->render('calendar/schedule/stylesheet', $style_parameters)); $template = $GLOBALS['template_factory']->open("calendar/calendar_view.php"); diff --git a/lib/classes/Fullcalendar.class.php b/lib/classes/Fullcalendar.class.php index 467b583..db8364a 100644 --- a/lib/classes/Fullcalendar.class.php +++ b/lib/classes/Fullcalendar.class.php @@ -64,7 +64,7 @@ class Fullcalendar public function render() { - $factory = new \Flexi_TemplateFactory($GLOBALS['STUDIP_BASE_PATH'] . '/templates'); + $factory = new \Flexi\Factory($GLOBALS['STUDIP_BASE_PATH'] . '/templates'); $template = $factory->open('studip-fullcalendar.php'); $real_data_name = sprintf('data-%s', $this->data_name); return $template->render( diff --git a/lib/classes/I18N.php b/lib/classes/I18N.php index d34ed0b..44252f3 100644 --- a/lib/classes/I18N.php +++ b/lib/classes/I18N.php @@ -61,10 +61,10 @@ class I18N /** * Protected constructor in order to always force a specific input type. * - * @param string|Flexi_Template $template Template to use + * @param string|Flexi\Template $template Template to use * @param string $name Name of the element * @param string|I18NString $value Value of the element - * @param array $attributes Additional variables for the + * @param array $attributes Additional variables for the * element */ final protected function __construct($template, $name, $value, array $attributes) diff --git a/lib/classes/QuestionType.interface.php b/lib/classes/QuestionType.interface.php index ada6005..03019fe 100644 --- a/lib/classes/QuestionType.interface.php +++ b/lib/classes/QuestionType.interface.php @@ -60,7 +60,8 @@ interface QuestionType { * * Try to prefix all your input variables at least with the id of the question, * so that they will never conflict with other variables. - * @return Flexi_Template + * + * @return Flexi\Template */ public function getDisplayTemplate(); @@ -82,11 +83,13 @@ interface QuestionType { /** * Returns a template with the results of this question. + * * @param $only_user_ids : array\null array of user_ids that the results should be restricted to. * this is used to show only a subset of results to the user for * visible evaluation of the results. If the questionnaire is anonymous * just do nothing. - * @return Flexi_Template + * + * @return Flexi\Template */ public function getResultTemplate($only_user_ids = null); diff --git a/lib/classes/Seminar.class.php b/lib/classes/Seminar.class.php index 8aa3d41..a2d69ea 100644 --- a/lib/classes/Seminar.class.php +++ b/lib/classes/Seminar.class.php @@ -1735,7 +1735,7 @@ class Seminar */ public function getDatesTemplate($template, $params = []) { - if (!$template instanceof Flexi_Template && is_string($template)) { + if (!$template instanceof Flexi\Template && is_string($template)) { $template = $GLOBALS['template_factory']->open($template); } diff --git a/lib/classes/Siteinfo.php b/lib/classes/Siteinfo.php index 0d849ca..4a969ee 100644 --- a/lib/classes/Siteinfo.php +++ b/lib/classes/Siteinfo.php @@ -281,7 +281,7 @@ class SiteinfoMarkupEngine { function __construct() { $this->db = DBManager::get(); - $this->template_factory = new Flexi_TemplateFactory($GLOBALS['STUDIP_BASE_PATH'].'/app/views/siteinfo/markup/'); + $this->template_factory = new Flexi\Factory($GLOBALS['STUDIP_BASE_PATH'].'/app/views/siteinfo/markup/'); $this->siteinfoMarkup("/\(:version:\)/", [$this, 'version']); $this->siteinfoMarkup("/\(:uniname:\)/", [$this, 'uniName']); $this->siteinfoMarkup("/\(:unicontact:\)/", [$this, 'uniContact']); @@ -659,7 +659,7 @@ function language_filter($input) { } function stripforeignlanguage($language, $text) { - list($primary, $sub) = explode('_',$_SESSION['_language']); + [$primary, $sub] = explode('_',$_SESSION['_language']); if ($language === $primary || $language === $_SESSION['_language']) { return str_replace('\"', '"', $text); } else { diff --git a/lib/classes/StudipFileloader.php b/lib/classes/StudipFileloader.php index 661c062..aab0b31 100644 --- a/lib/classes/StudipFileloader.php +++ b/lib/classes/StudipFileloader.php @@ -31,7 +31,7 @@ class StudipFileloader !file_exists($file) && !stream_resolve_include_path($file) ) { - continue; + throw new Exception('Missing file '. $file); } include $file; } diff --git a/lib/classes/coursewizardsteps/AdvancedBasicDataWizardStep.php b/lib/classes/coursewizardsteps/AdvancedBasicDataWizardStep.php index 780f837..cd33fd3 100644 --- a/lib/classes/coursewizardsteps/AdvancedBasicDataWizardStep.php +++ b/lib/classes/coursewizardsteps/AdvancedBasicDataWizardStep.php @@ -36,7 +36,7 @@ class AdvancedBasicDataWizardStep extends BasicDataWizardStep } // Load template from step template directory. - $factory = new Flexi_TemplateFactory($GLOBALS['STUDIP_BASE_PATH'].'/app/views/course/wizard/steps'); + $factory = new Flexi\Factory($GLOBALS['STUDIP_BASE_PATH'].'/app/views/course/wizard/steps'); $template = $factory->open('advancedbasicdata/index'); $template = $this->setupTemplateAttributes($template, $values, $stepnumber, $temp_id); diff --git a/lib/classes/coursewizardsteps/BasicDataWizardStep.php b/lib/classes/coursewizardsteps/BasicDataWizardStep.php index 6a1438f..d47c4f3 100644 --- a/lib/classes/coursewizardsteps/BasicDataWizardStep.php +++ b/lib/classes/coursewizardsteps/BasicDataWizardStep.php @@ -28,7 +28,7 @@ class BasicDataWizardStep implements CourseWizardStep public function getStepTemplate($values, $stepnumber, $temp_id) { // Load template from step template directory. - $factory = new Flexi_TemplateFactory($GLOBALS['STUDIP_BASE_PATH'] . '/app/views/course/wizard/steps'); + $factory = new Flexi\Factory($GLOBALS['STUDIP_BASE_PATH'] . '/app/views/course/wizard/steps'); if (!empty($values[__CLASS__]['studygroup'])) { $tpl = $factory->open('basicdata/index_studygroup'); $values[__CLASS__]['lecturers'][$GLOBALS['user']->id] = 1; diff --git a/lib/classes/coursewizardsteps/LVGroupsWizardStep.php b/lib/classes/coursewizardsteps/LVGroupsWizardStep.php index f343730..e79e1bd 100644 --- a/lib/classes/coursewizardsteps/LVGroupsWizardStep.php +++ b/lib/classes/coursewizardsteps/LVGroupsWizardStep.php @@ -39,7 +39,7 @@ class LVGroupsWizardStep implements CourseWizardStep $values = $values[__CLASS__] ?? []; // Load template from step template directory. - $factory = new Flexi_TemplateFactory($GLOBALS['STUDIP_BASE_PATH'] . '/app/views/course/wizard/steps'); + $factory = new Flexi\Factory($GLOBALS['STUDIP_BASE_PATH'] . '/app/views/course/wizard/steps'); $tpl = $factory->open('lvgroups/index'); $tpl->set_attribute('values', $values); @@ -226,7 +226,7 @@ class LVGroupsWizardStep implements CourseWizardStep continue; } - $factory = new Flexi_TemplateFactory($GLOBALS['STUDIP_BASE_PATH'] . '/app/views'); + $factory = new Flexi\Factory($GLOBALS['STUDIP_BASE_PATH'] . '/app/views'); $html = $factory->render('course/wizard/steps/lvgroups/lvgroup_searchentry', compact('area')); $data = [ 'id' => $area->id, @@ -288,7 +288,7 @@ class LVGroupsWizardStep implements CourseWizardStep 'Studiengang']); $pathes = ModuleManagementModelTreeItem::getPathes($trails); - $factory = new Flexi_TemplateFactory($GLOBALS['STUDIP_BASE_PATH'] . '/app/views'); + $factory = new Flexi\Factory($GLOBALS['STUDIP_BASE_PATH'] . '/app/views'); $html = $factory->render('course/lvgselector/entry_trails', compact('area', 'pathes')); @@ -308,7 +308,7 @@ class LVGroupsWizardStep implements CourseWizardStep $mvvid = explode('-', $id); $area = Lvgruppe::find($mvvid[0]); - $factory = new Flexi_TemplateFactory($GLOBALS['STUDIP_BASE_PATH'] . '/app/views'); + $factory = new Flexi\Factory($GLOBALS['STUDIP_BASE_PATH'] . '/app/views'); $html = $factory->render('course/wizard/steps/lvgroups/lvgroup_entry', ['area' => $area, 'locked' => false, 'course_id' => '']); $data = [ diff --git a/lib/classes/coursewizardsteps/StudyAreasWizardStep.php b/lib/classes/coursewizardsteps/StudyAreasWizardStep.php index 29de617..eac7e37 100644 --- a/lib/classes/coursewizardsteps/StudyAreasWizardStep.php +++ b/lib/classes/coursewizardsteps/StudyAreasWizardStep.php @@ -30,7 +30,7 @@ class StudyAreasWizardStep implements CourseWizardStep // We only need our own stored values here. $values = $values[get_class($this)] ?? []; // Load template from step template directory. - $factory = new Flexi_TemplateFactory($GLOBALS['STUDIP_BASE_PATH'].'/app/views/course/wizard/steps'); + $factory = new Flexi\Factory($GLOBALS['STUDIP_BASE_PATH'].'/app/views/course/wizard/steps'); $tpl = $factory->open('studyareas/index'); if (!empty($values['studyareas'])) { $tree = $this->buildPartialSemTree(StudipStudyArea::backwards(StudipStudyArea::findMany($values['studyareas']))); diff --git a/lib/classes/forms/Form.php b/lib/classes/forms/Form.php index 8977a37..36a2e7d 100644 --- a/lib/classes/forms/Form.php +++ b/lib/classes/forms/Form.php @@ -492,7 +492,7 @@ class Form extends Part /** * Renders the whole form as a string. * @return string - * @throws \Flexi_TemplateNotFoundException + * @throws \Flexi\TemplateNotFoundException */ public function render() { diff --git a/lib/classes/librarysearch/LibraryDocument.class.php b/lib/classes/librarysearch/LibraryDocument.class.php index 4c90e0b4..46e11b2 100644 --- a/lib/classes/librarysearch/LibraryDocument.class.php +++ b/lib/classes/librarysearch/LibraryDocument.class.php @@ -14,7 +14,6 @@ * @since 4.6 */ - /** * This class represents a document from a library. */ @@ -386,12 +385,12 @@ class LibraryDocument /** - * @returns Flexi_Template A template containing information about the + * @returns Flexi\Template A template containing information about the * the document. */ public function getInfoTemplate($format = 'short') { - $factory = new Flexi_TemplateFactory( + $factory = new Flexi\Factory( $GLOBALS['STUDIP_BASE_PATH'] . '/templates/library/' ); $template = $factory->open('library_document_info'); diff --git a/lib/classes/sidebar/TemplateWidget.php b/lib/classes/sidebar/TemplateWidget.php index c937c3b..2ca2d70 100644 --- a/lib/classes/sidebar/TemplateWidget.php +++ b/lib/classes/sidebar/TemplateWidget.php @@ -15,10 +15,10 @@ class TemplateWidget extends SidebarWidget * Constructor of the widget. * * @param String $title Title of the widget - * @param Flexi_Template $template Template for the widget + * @param Flexi\Template $template Template for the widget * @param array $variables Associated variables for the template */ - public function __construct($title, Flexi_Template $template, array $variables = []) + public function __construct($title, Flexi\Template $template, array $variables = []) { parent::__construct(); diff --git a/lib/filesystem/CourseDateFolder.php b/lib/filesystem/CourseDateFolder.php index 2ab0435..7c91c87 100644 --- a/lib/filesystem/CourseDateFolder.php +++ b/lib/filesystem/CourseDateFolder.php @@ -92,7 +92,7 @@ class CourseDateFolder extends PermissionEnabledFolder implements FolderType /** * This method returns the special part for the edit template * - * @return Flexi_Template edit template + * @return Flexi\Template edit template */ public function getEditTemplate() { @@ -126,7 +126,7 @@ class CourseDateFolder extends PermissionEnabledFolder implements FolderType /** * Returns the description template * - * @return Flexi_Template description template + * @return Flexi\Template description template */ public function getDescriptionTemplate() { diff --git a/lib/filesystem/CoursePublicFolder.php b/lib/filesystem/CoursePublicFolder.php index 463fe19..6fa722d 100644 --- a/lib/filesystem/CoursePublicFolder.php +++ b/lib/filesystem/CoursePublicFolder.php @@ -112,7 +112,7 @@ class CoursePublicFolder extends StandardFolder /** * Returns the edit template for this folder type. * - * @return Flexi_Template + * @return Flexi\Template */ public function getEditTemplate() { diff --git a/lib/filesystem/FileType.php b/lib/filesystem/FileType.php index 5a53896..3dcd32f 100644 --- a/lib/filesystem/FileType.php +++ b/lib/filesystem/FileType.php @@ -177,10 +177,12 @@ interface FileType public function convertToStandardFile(); /** - * Returns the content for that additional column, if it exists. You can return null a string - * or a Flexi_Template as the content. + * Returns the content for that additional column, if it exists. You can + * return null, a string or a Flexi\Template as the content. + * * @param string $column_index - * @return null|string|Flexi_Template + * + * @return null|string|Flexi\Template */ public function getContentForAdditionalColumn($column_index); @@ -194,14 +196,14 @@ interface FileType /** - * Generates a Flexi_Template containing additional information that are + * Generates a Flexi\Template containing additional information that are * displayes in the information dialog of a file. * * @param bool $include_downloadable_infos Whether to include information * like file previews that can be downloaded (true) or to not * include them (false). Defaults to false. * - * @returns Flexi_Template|null Either a Flexi_Template containing + * @returns Flexi\Template|null Either a Flexi\Template containing * additional information or null if no such information shall be * displayed in the information dialog. */ diff --git a/lib/filesystem/FolderType.php b/lib/filesystem/FolderType.php index 94d8667..69dae30 100644 --- a/lib/filesystem/FolderType.php +++ b/lib/filesystem/FolderType.php @@ -119,7 +119,7 @@ interface FolderType /** * returns description of the folder * - * @return Flexi_Template | string + * @return Flexi\Template | string */ public function getDescriptionTemplate(); @@ -144,7 +144,7 @@ interface FolderType /** * returns template form, must not contain opening and closing
    tags * - * @return Flexi_Template | string + * @return Flexi\Template | string */ public function getEditTemplate(); @@ -243,10 +243,12 @@ interface FolderType public function getAdditionalColumns(); /** - * Returns the content for that additional column, if it exists. You can return null a string - * or a Flexi_Template as the content. + * Returns the content for that additional column, if it exists. You can + * return null, a string or a Flexi\Template as the content. + * * @param string $column_index - * @return null|string|Flexi_Template + * + * @return null|string|Flexi\Template */ public function getContentForAdditionalColumn($column_index); diff --git a/lib/filesystem/HiddenFolder.php b/lib/filesystem/HiddenFolder.php index b29f5fb..4daee0b 100644 --- a/lib/filesystem/HiddenFolder.php +++ b/lib/filesystem/HiddenFolder.php @@ -78,7 +78,7 @@ class HiddenFolder extends PermissionEnabledFolder /** * Returns the edit template for this folder type. * - * @return Flexi_Template + * @return Flexi\Template */ public function getEditTemplate() { diff --git a/lib/filesystem/InboxOutboxFolder.php b/lib/filesystem/InboxOutboxFolder.php index 9386be4..6a8f2fd 100644 --- a/lib/filesystem/InboxOutboxFolder.php +++ b/lib/filesystem/InboxOutboxFolder.php @@ -269,10 +269,12 @@ class InboxOutboxFolder implements FolderType } /** - * Returns the content for that additional column, if it exists. You can return null a string - * or a Flexi_Template as the content. + * Returns the content for that additional column, if it exists. You can + * return null, a string or a Flexi\Template as the content. + * * @param string $column_index - * @return null|string|Flexi_Template + * + * @return null|string|Flexi\Template */ public function getContentForAdditionalColumn($column_index) { diff --git a/lib/filesystem/PublicFolder.php b/lib/filesystem/PublicFolder.php index 6b06ac9..2dc4847 100644 --- a/lib/filesystem/PublicFolder.php +++ b/lib/filesystem/PublicFolder.php @@ -160,7 +160,7 @@ class PublicFolder extends StandardFolder /** * Returns the edit template for this folder type. * - * @return Flexi_Template + * @return Flexi\Template */ public function getEditTemplate() { diff --git a/lib/filesystem/RootFolder.php b/lib/filesystem/RootFolder.php index 0727770..9771c32 100644 --- a/lib/filesystem/RootFolder.php +++ b/lib/filesystem/RootFolder.php @@ -86,7 +86,7 @@ class RootFolder extends StandardFolder } /** - * @return Flexi_Template + * @return Flexi\Template */ public function getEditTemplate() { diff --git a/lib/filesystem/StandardFile.php b/lib/filesystem/StandardFile.php index 9d2d35c..4eb3140 100644 --- a/lib/filesystem/StandardFile.php +++ b/lib/filesystem/StandardFile.php @@ -460,9 +460,11 @@ class StandardFile implements FileType, ArrayAccess, StandardFileInterface /** * Returns the content for that additional column, if it exists. You can return null a string - * or a Flexi_Template as the content. + * or a Flexi\Template as the content. + * * @param string $column_index - * @return null|string|Flexi_Template + * + * @return null|string|Flexi\Template */ public function getContentForAdditionalColumn($column_index) { @@ -497,7 +499,7 @@ class StandardFile implements FileType, ArrayAccess, StandardFileInterface return null; } - $factory = new Flexi_TemplateFactory( + $factory = new Flexi\Factory( $GLOBALS['STUDIP_BASE_PATH'] . '/templates/filesystem/file_types/' ); $template = $factory->open('standard_file_info'); diff --git a/lib/filesystem/StandardFolder.php b/lib/filesystem/StandardFolder.php index a34ca4a..bbbb1fc 100644 --- a/lib/filesystem/StandardFolder.php +++ b/lib/filesystem/StandardFolder.php @@ -186,7 +186,7 @@ class StandardFolder implements FolderType } /** - * @return string|Flexi_Template + * @return string|Flexi\Template */ public function getDescriptionTemplate() { @@ -194,7 +194,7 @@ class StandardFolder implements FolderType } /** - * @return string|Flexi_Template + * @return string|Flexi\Template */ public function getEditTemplate() { @@ -509,9 +509,11 @@ class StandardFolder implements FolderType /** * Returns the content for that additional column, if it exists. You can return null a string - * or a Flexi_Template as the content. + * or a Flexi\Template as the content. + * * @param string $column_index - * @return null|string|Flexi_Template + * + * @return null|string|Flexi\Template */ public function getContentForAdditionalColumn($column_index) { diff --git a/lib/filesystem/TimedFolder.php b/lib/filesystem/TimedFolder.php index 442c084..d5f933b 100644 --- a/lib/filesystem/TimedFolder.php +++ b/lib/filesystem/TimedFolder.php @@ -132,7 +132,7 @@ class TimedFolder extends PermissionEnabledFolder /** * Returns the description template for a instance of a TimedFolder type. * - * @return Flexi_Template A description template for a instance of the type TimedFolder + * @return Flexi\Template A description template for a instance of the type TimedFolder */ public function getDescriptionTemplate() { @@ -155,7 +155,7 @@ class TimedFolder extends PermissionEnabledFolder /** * Returns the edit template for this folder type. * - * @return Flexi_Template + * @return Flexi\Template */ public function getEditTemplate() { diff --git a/lib/flexi/Factory.php b/lib/flexi/Factory.php new file mode 100644 index 0000000..b6c30fd --- /dev/null +++ b/lib/flexi/Factory.php @@ -0,0 +1,243 @@ + + * @author Marcus Lunzenauer + * @license MIT + */ + +namespace Flexi; + +class Factory +{ + /** + * mapping of file extensions to supported template classes + */ + protected array $handlers = [ + 'php' => [PhpTemplate::class, []], + ]; + + /** + * Constructor of TemplateFactory. + * + * @param string $path the template include path + */ + public function __construct(protected string $path) + { + $this->set_path($path); + } + + /** + * Sets a new include path for the factory and returns the old one. + * + * @param string $path the new path + * + * @return string the old path + */ + public function set_path(string $path): string + { + $old_path = $this->get_path(); + + if (!str_ends_with($path, '/')) { + $path .= '/'; + } + + $this->path = $path; + + return $old_path; + } + + /** + * Returns the include path of the factory + * + * @return string the current include path + */ + public function get_path(): string + { + return $this->path; + } + + /** + * Open a template of the given name using the factory method pattern. + * If a string was given, the path of the factory is searched for a matching + * template. + * If this string starts with a slash or with /\w+:\/\//, the string is + * interpreted as an absolute path. Otherwise the path of the factory will be + * prepended. + * After that the factory searches for a file extension in this string. If + * there is none, the directory where the template is supposed to live is + * searched for a file starting with the template string and a supported + * file extension. + * At last the factory instantiates a template object of the matching template + * class. + * + * Examples: + * + * $factory->open('/path/to/template') + * does not prepend the factory's path but searches for "template.*" in + * "/path/to" + * + * $factory->open('template') + * prepends the factory's path and searches there for "template.*" + * + * $factory->open('template.php') + * prepends the factory's path but does not search and instantiates a + * PHPTemplate instead + * + * This method returns it's parameter, if it is not a string. This + * functionality is useful for helper methods like #render_partial + * + * @param Template|string $template A name of a template. + * @return Template the factored object + * @throws TemplateNotFoundException if the template could not be found + */ + public function open(Template|string $template): Template + { + # if it is not a string, this method behaves like identity + if ($template instanceof Template) { + return $template; + } + + # get file + $file = $this->get_template_file($template); + + # retrieve handler + [$class, $options] = $this->get_template_handler($file); + + return new $class($file, $this, $options); + } + + /** + * This method returns the absolute filename of the template + * + * @param string $template0 a template string + * + * @return string an absolute filename + * + * @throws TemplateNotFoundException if the template could not be found + */ + public function get_template_file(string $template0): string + { + $template = $this->get_absolute_path($template0); + $extension = $this->get_extension($template); + + # extension defined, is there a matching template class? + if ($extension !== null) { + if (file_exists($template)) { + return $template; + } + } # no extension defined, find it + else { + $file = $this->find_template($template); + if ($file !== null) { + return $file; + } + } + + # falling through to throw exception + throw new TemplateNotFoundException(sprintf( + 'Missing template "%s" in "%s".', + $template0, + $this->path + )); + } + + /** + * Matches an extension to a template handler. + * + * @param string $template the template + * + * @return array|null an array containing the class name and an array of + * options of the matched extension; + * or NULL if the extension did not match + */ + public function get_template_handler(string $template): ?array + { + $extension = $this->get_extension($template); + return $this->handlers[$extension] ?? null; + } + + /** + * Registers a handler for templates with a matching extension. + * + * @param string $extension the extension of the templates to handle + * @param class-string