Compare commits

..

247 commits

Author SHA1 Message Date
1bd4541faa Remove custom syntax for text formatting 2019-04-13 19:18:32 +02:00
0a33e29e4f Use .gitignore file instead of .hgignore 2019-04-13 19:18:10 +02:00
81e5b72f3d Use user “questlab” in database scripts and configuration 2019-04-13 19:16:50 +02:00
coderkun
e62ca15a66 Update English translation 2016-10-31 22:05:16 +01:00
coderkun
9e5f595d5a Enable languages en_EN and pt_BR in application config 2016-10-31 22:00:58 +01:00
coderkun
6c8abc3033 Add en_EN translation 2016-10-31 22:00:37 +01:00
coderkun
c2aefefb7f Merge pull request #15 from gabrielssilva/pt_br
Add pt_BR translation
2016-10-31 21:58:32 +01:00
Gabriel Silva
e97123bc24 Adds pt_BR translation
Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com>
2016-10-30 18:06:57 -03:00
coderkun
f8c5e2376a Update readme to properly mark Named Entities 2016-10-29 11:34:14 +02:00
coderkun
0f658ad96a Add readme with introduction text 2016-10-28 22:38:57 +02:00
oliver
dac75a7199 update translation 2016-10-28 21:52:43 +02:00
oliver
b925064d46 update header of source files with current year and new link 2016-10-28 21:43:18 +02:00
oliver
565a82326c set order to ascending for Character groups Quests 2016-06-28 10:40:45 +02:00
oliver
a36437e572 fix order of Character groups Quests (fixes #169) 2016-06-28 10:37:10 +02:00
oliver
8353cfc7d9 merge framework ?NRE? 2016-05-28 12:35:45 +02:00
oliver
16e5957854 fix some docstrings 2016-05-28 12:34:18 +02:00
oliver
63af0d0afa do not track generated documentation 2016-05-28 12:32:48 +02:00
oliver
7085de8fe2 fix many docstrings and their formatting 2016-05-28 12:30:53 +02:00
coderkun
7b44e19569 fix typos in some docstrings 2016-05-28 12:26:56 +02:00
oliver
e50c2bb5e6 do not use function boolval() to be compatible with PHP < 5.5 (fixes #163) 2016-04-23 14:32:22 +02:00
oliver
74e7ff5ac6 update translations 2016-04-17 14:41:16 +02:00
oliver
794462e3e9 questtype ?Submit?: use database transaction for adding terms 2016-04-17 14:35:45 +02:00
oliver
f4980652c2 do not use NumberFormatter for similarity values of questtype ?Submit? because it it broken 2016-04-16 21:11:42 +02:00
oliver
2b801227af questtype ?Multiple Choice?: escape content for text input fields 2016-04-16 18:23:41 +02:00
oliver
48c1f1c730 let Textile parser use unrestricted mode to allow HTML for formatted text 2016-04-16 18:23:08 +02:00
oliver
d8845371e6 fix permissions for Piwik plugins 2016-04-15 20:06:16 +02:00
oliver
9c9efafc65 do not reuse pointer (call-by-reference) $drag for editing task of questtype ?Drag&Drop? (fixs #160) 2016-04-15 18:56:58 +02:00
oliver
b8de91c048 don?t use array as class constant for mimetypes of questtype ?Submit? (fixes #161) 2016-04-15 18:03:07 +02:00
oliver
d885a4baa9 update Piwik to version 2.16 (fixes #91) 2016-04-10 18:55:57 +02:00
oliver
296343bf3b use anchor inside page to redirect to Character groups Quests on Character groups-group page 2016-04-10 14:41:16 +02:00
oliver
9c0b0d8d07 implement position for sorting of Character groups Quests (implements #157) 2016-04-10 14:28:22 +02:00
oliver
412326f69a set permissions for actions of CharactergroupsquestsController 2016-04-10 14:05:59 +02:00
oliver
814b88c787 fix handling of ?gender? during Character registration (fixes #154) 2016-04-10 12:42:06 +02:00
oliver
1925547cf4 merge branch ?submit-similarity? 2016-04-09 16:36:55 +02:00
oliver
7f97d4fb2d add Stored Procedure ?update_cache_characters_xplevels? to drop-script 2016-04-09 16:28:16 +02:00
oliver
59a3cba90e fix SQL-definer of Stored Procedure ?update_cache_characters_xplevels? 2016-04-09 16:23:48 +02:00
oliver
14e0e71011 use AppConfig instead of database table to configure mimetypes for questtype ?Submit? 2016-04-09 16:20:29 +02:00
oliver
4df159ba7e add docstrings to similarity methods 2016-04-09 15:57:11 +02:00
oliver
df14dfafc3 hide map for Character groups Quest Stations when there are no stations 2016-04-09 13:44:37 +02:00
oliver
53fda5caaf implement similarity algorithm for questtype ?Submit? 2016-04-09 13:21:23 +02:00
oliver
67f92d6174 fix check of Character groups-group title by using Seminary-ID (fixes #151) 2016-04-09 13:06:04 +02:00
oliver
4e7fdd973e fix condition for showing Achievments on Character groups-group page 2016-03-26 19:23:55 +01:00
oliver
699d1aaa84 redirect to overview instead of edit after creating a new Character title 2016-03-26 19:15:23 +01:00
oliver
74b093a61f add ?public? option for Character groups Quests (implements #146) 2016-03-26 19:15:02 +01:00
oliver
f876913ced fix formatting of some docstrings 2016-03-26 18:48:43 +01:00
oliver
bd29bcdd7c add routes for Character title pages 2016-03-26 18:48:27 +01:00
oliver
0ca2e3131f fix validation of Character?s gender 2016-03-26 18:41:00 +01:00
oliver
e5158e33d9 show title of Characters whereever their names appear 2016-03-26 18:40:45 +01:00
oliver
13ce3f3281 fix permissions of CharactertitlesController 2016-03-26 18:01:17 +01:00
oliver
7061a98f5b fix permissions of QrController 2016-03-26 18:01:08 +01:00
oliver
d3fae2e551 merge branch ?charactertitles? 2016-03-26 17:53:08 +01:00
oliver
0729c79a7d add notification for Character titles 2016-03-26 17:52:16 +01:00
oliver
f886d4139d update translations 2016-03-26 17:45:29 +01:00
oliver
eddc4036cf assign Character titles via QR-codes (implements #118) 2016-03-26 17:36:23 +01:00
oliver
40d2aa5768 fix label-tag for creating Character types 2016-03-26 17:06:42 +01:00
oliver
88954cd31e fix typo (missing ?s?) in CharactersModel 2016-03-26 17:06:11 +01:00
oliver
14b09065a2 implement CRUD for Character titles 2016-03-26 17:05:42 +01:00
oliver
ac0e5a32cb fix database keys for achievementconditions_qrcode.hash and characters.charactertitle_id 2016-03-26 16:21:12 +01:00
oliver
92ce598ad1 fix media config for Character groups quests 2016-03-26 16:12:31 +01:00
oliver
4aa2a379b0 fix a few docstrings and formattings 2016-03-26 16:12:11 +01:00
oliver
320a583753 add Character titles and let Characters choose gender and title 2016-03-26 15:46:37 +01:00
oliver
f70587db46 add Achievement condition ?qrcode? to import-script 2016-03-13 14:14:04 +01:00
oliver
4f544d5255 fix styling of rare Achievements 2016-03-12 19:22:25 +01:00
oliver
28c914a926 add Achievement condition ?qrcode? to trigger Achievements by scanning a QR-code (implements #126) 2016-03-12 19:19:20 +01:00
oliver
3939def456 add link to assign Character group Achievements manually (implements #125) 2016-03-12 17:28:37 +01:00
oliver
cff72efcb4 fix mimetypes for Achievement icons 2016-03-12 16:06:45 +01:00
oliver
e597142266 fix some permissions and their formatting 2016-03-12 16:06:27 +01:00
oliver
42e9b518d9 update translations 2016-03-12 16:05:25 +01:00
oliver
bdfd021673 add QR-codes for Character groups Achievements (implements #124) 2016-03-12 16:04:51 +01:00
oliver
dd2b15bbd7 add notification for Character groups Achievements 2016-03-12 16:04:01 +01:00
oliver
7c2b3111c2 include Character groups Achievements when copying Seminaries 2016-03-12 16:03:38 +01:00
oliver
e4f98c29d1 list Character groups Achievements for Character groups and groups-groups 2016-03-12 16:02:58 +01:00
oliver
73c378d9f3 add Agent for Character groups Achievements (implements #123) 2016-03-12 16:01:27 +01:00
oliver
bf0d324655 move method to create random hashes to Utils-class 2016-03-12 15:56:32 +01:00
oliver
60036ea794 update create script for last version of mysqldump 2016-03-06 11:47:22 +01:00
oliver
2c21c628ae add missing triggers to drop-script 2016-03-03 13:11:54 +01:00
oliver
cc3ad1be53 fix an exception variable 2016-02-27 20:00:40 +01:00
oliver
b6b2d40bd0 fix translation of Stationtype ?singlechoice? 2016-02-27 20:00:24 +01:00
oliver
676c2386fd use random hash strings for Station URLs 2016-02-27 19:59:59 +01:00
oliver
d1faa5b4b1 update translations 2016-02-27 19:06:11 +01:00
oliver
178361ef94 add Stationtype ?singlechoice? 2016-02-27 19:05:54 +01:00
oliver
0cfdaf8f49 fix status for Stationtype ?multiple choice? 2016-02-27 17:17:38 +01:00
oliver
e4b7980500 place wrong and right texts for Station tasks in boxes 2016-02-27 16:54:45 +01:00
oliver
b511a960c8 show submitted values for tried Station tasks 2016-02-27 16:54:27 +01:00
oliver
54ed53ac33 add Character group selector to Station pages and show groups? status 2016-02-27 16:07:25 +01:00
oliver
060282e9c0 add Icon to Station pages 2016-02-27 15:29:08 +01:00
oliver
6e1d1ede2a fix styling of Station images on Quest page 2016-02-27 15:14:22 +01:00
oliver
55dd05df3b show grayscaled image for entered Stations 2016-02-27 15:14:03 +01:00
oliver
da9095b89d change getMediaFile() of MediaController to allow multiple actions (resize and grayscale for now) 2016-02-27 15:12:20 +01:00
oliver
ef05402b16 update translations 2016-02-12 11:12:07 +01:00
oliver
ec7787c3e0 merge branch ?charactergroupsqueststations? 2016-02-12 11:06:06 +01:00
oliver
f53980f057 update database create-script 2016-02-12 11:05:10 +01:00
oliver
3fe164209b use Seminary location as default extent for Station locations (implements #134) 2016-02-12 11:02:50 +01:00
oliver
a4f443d87a add location to seminaries 2016-02-12 11:02:06 +01:00
oliver
880b91d5e6 fix formatting of MulitpleChoice tasks (fixes #137) 2016-02-12 10:28:24 +01:00
oliver
16f85f1006 fix typo in variable 2016-02-12 10:08:42 +01:00
oliver
14ea890c8b add selector which Character group to show for Stations (implements #133) 2016-02-12 09:57:11 +01:00
oliver
6f76c2a3dd show back-button for Stations also when their task is empty (implements #132) 2016-02-06 18:24:31 +01:00
oliver
f630b50027 show count of solved Stations only for admins and moderators (see #139) 2016-02-06 18:14:52 +01:00
oliver
011bae5cd8 fix translation of ?solved? literals for Stations 2016-02-02 12:02:38 +01:00
oliver
4f0c7e2fa8 hide Stations map if no station has been discovered yet 2016-02-02 12:02:11 +01:00
oliver
1b19187587 fix visibility of method getEnteredStationsForQuestAndGroup() 2016-02-02 12:01:39 +01:00
oliver
2e6315134f merge default branch 2016-02-02 10:49:51 +01:00
oliver
dce9963bdf remove GPS coordinates on Station page 2016-02-02 10:49:29 +01:00
oliver
dff5616da1 update translations (fixes #138) 2016-02-02 10:48:38 +01:00
oliver
76ba31c04e merge branch ?charactergroupsqueststations? 2016-02-02 10:38:52 +01:00
oliver
f0ea809813 add labels to Station map 2016-02-02 10:33:17 +01:00
oliver
03cc6a475b add count of Stations for each Character group (implements #139) 2016-02-02 10:02:17 +01:00
oliver
e3b1fa85b5 add back-button for solved Stations (implements #132) 2016-02-02 09:41:26 +01:00
oliver
877fe86f30 remove print_r() 2016-02-02 09:33:59 +01:00
oliver
87d70f70e2 add icon and date for wrongly solved Stations (fixes #131) 2016-02-02 09:31:56 +01:00
oliver
2904549a65 fix status icons for Stations (fixes #135) 2016-02-02 09:17:31 +01:00
oliver
cf21b6c1a0 Stationtype ?keyword?: check regex 2016-01-31 17:21:11 +01:00
oliver
813152b091 fix position of title for Stations 2016-01-31 17:20:41 +01:00
oliver
9f8d9fa05c correct paths and autoplay for Station media (fixes #130) 2016-01-30 21:35:03 +01:00
oliver
56627a5c1f remove some prints and useless comments 2016-01-30 21:32:38 +01:00
oliver
d84789dce7 merge branch ?charactergroupsqueststations? 2016-01-30 20:39:41 +01:00
oliver
40a233fa7d implement copying of Stations for Seminary copy feature 2016-01-30 20:15:13 +01:00
oliver
ba97244b15 merge branch ?charactergroupsqueststations? 2016-01-28 22:33:53 +01:00
oliver
5614b6c089 remove poster for videos for now 2016-01-24 19:37:06 +01:00
oliver
efd304833c add media to right/wrong text of Character group Quest Stations 2016-01-24 19:36:05 +01:00
oliver
2d65b2e4b0 set permissions for CRUD actions of Character groups Quest Stations 2016-01-22 20:55:15 +01:00
oliver
d5c68803f0 display icons for Character groups Quest Stations 2016-01-22 20:51:23 +01:00
oliver
538e1aa8b0 merge branch ?charactergroupsqueststations? 2016-01-15 23:01:30 +01:00
oliver
a27352cb66 add prolog to Character groups Quest Stations 2016-01-15 13:21:21 +01:00
oliver
476c18b6a9 fix labels and text editors for Quest creation 2016-01-15 12:33:07 +01:00
oliver
f91a24c46d correct a few docstrings and translation usages 2016-01-15 12:30:21 +01:00
oliver
457a382317 implement task editing for Stationtype ?multiplechoice? 2016-01-15 12:30:00 +01:00
oliver
a1e46ff2aa implement task editing for Stationtype ?keyword? 2016-01-15 12:29:32 +01:00
oliver
112c7d0b4f add editing of Character groups Quest Station tasks 2016-01-15 12:28:59 +01:00
oliver
b7ce9f09cd add map for creating and editing of Character groups Quest Stations 2016-01-15 10:26:17 +01:00
oliver
33e1c4d8b5 fix handling of null-values for coordinates of Character groups Quest Stations 2016-01-14 19:19:12 +01:00
oliver
e03dea0d80 add basic CRUD for Character groups Quest Stations 2016-01-14 19:04:56 +01:00
oliver
5f25a0a383 update import-script for recent changes including Stationtypes 2015-12-25 16:55:30 +01:00
oliver
939cf7b08e add QrAgent for short URLs used in QR codes 2015-12-25 16:44:47 +01:00
oliver
c424cfe30c integrate Character groups Quest Stations into Character groups Quests 2015-12-25 16:43:18 +01:00
oliver
a31252d81b add QrcodesAgent 2015-12-25 16:42:28 +01:00
oliver
d7095c005a add routes and config for Character groups Quest stations and Stationtypes 2015-12-25 16:40:12 +01:00
oliver
f779b22574 add CharactergroupsqueststationsAgent 2015-12-25 16:39:26 +01:00
oliver
f31032cbb2 add Stationtype ?multiplechoice? 2015-12-25 16:30:06 +01:00
oliver
cb2865c1d5 add Stationtype ?keyword? 2015-12-25 16:26:34 +01:00
oliver
08f83280f7 add database table for Stationtypes 2015-12-25 16:17:36 +01:00
oliver
ea0a283358 create abstract StationtypeAgent 2015-12-25 16:01:13 +01:00
oliver
54e36ff95c add library ?phpqrcode? to generate QR codes 2015-12-25 15:54:39 +01:00
oliver
a57be75415 update Font Awesome to version 4.4.0 2015-12-25 15:52:48 +01:00
oliver
26c6625d72 update OpenLayers to version 3.11.2 2015-12-25 15:51:58 +01:00
oliver
267029f17d correct list styling for formatted text 2015-10-31 17:19:28 +01:00
oliver
8c5c7e0b13 add additional pages and handle introduction page as ?system? page 2015-10-30 22:45:05 +01:00
oliver
02e7665fb7 add Questlab logo to menu 2015-10-30 20:37:03 +01:00
oliver
d990e08f49 add link for creating new Achievement to manage-page 2015-10-23 14:54:35 +02:00
oliver
5b68bab5d5 fix character cache updates when changing XP-levels 2015-10-23 13:17:00 +02:00
oliver
676137b956 correct Moodpic for Achievements (fixes #112) 2015-09-18 11:25:10 +02:00
coderkun
88f94709d1 translate some left metadata 2015-09-12 20:55:43 +02:00
coderkun
a95a948841 add compression for text-based mimetypes via Apache directive 2015-09-12 20:55:10 +02:00
coderkun
11261f0fe6 add caching information for Apache?s ?mod_expires? module for static files 2015-09-12 20:54:33 +02:00
oliver
96ea420e7f delete XP-levels in reverse order to handle levels correctly 2015-08-23 18:56:24 +02:00
oliver
f19a337efa fix ID for deleting Achievements 2015-08-23 18:55:10 +02:00
oliver
331cb22caf remove enclosing <p>-tags for Quest tasks 2015-08-21 10:43:17 +02:00
oliver
48e0445acd add image source for Quest images 2015-08-21 10:41:40 +02:00
oliver
5cd31ca82d update imagelightbox.js 2015-08-21 10:26:33 +02:00
oliver
21444a6047 1) move JavaScript-code to scripts.js
2) add image sources for Questtext images
2015-08-21 10:25:47 +02:00
oliver
443ddc343a simplify image sources 2015-08-21 10:19:52 +02:00
oliver
ca6af3fe92 improve image source label for Moodpics 2015-08-20 14:28:34 +02:00
oliver
fc587be483 correct DOM node list access 2015-08-20 13:56:19 +02:00
oliver
136afff5f1 fix some indentations 2015-08-20 13:24:53 +02:00
oliver
6f3a8339f8 fix redirect when cancelling Quest deletion 2015-08-20 13:24:42 +02:00
oliver
3ee63b6782 fix formatting of Quest texts 2015-08-20 13:23:52 +02:00
oliver
7cf35471aa fix formatting of links 2015-08-20 13:23:43 +02:00
oliver
b854554ed0 resize Quest images to the actually used size 2015-08-20 13:23:03 +02:00
oliver
5cb60679e0 add support for moodpic sources and revamp moodpic integration a little bit 2015-08-20 13:20:49 +02:00
oliver
41f3ee0349 Questtype ?chiceinput?: correct cascading of character choices 2015-08-19 22:24:22 +02:00
oliver
7ba9e2309f correct Questgroupshierarchy position when deleting Questgroups 2015-08-19 22:23:54 +02:00
oliver
3557ab7e33 update database create-script 2015-08-19 21:45:14 +02:00
oliver
f947a7a4df correct deletion of Questgroups 2015-08-19 21:44:54 +02:00
oliver
63a17ffc67 Questtype ?textinput?: correct two gettext-calls 2015-08-18 19:41:06 +02:00
oliver
a328e71613 Questtype ?textinput?: initialize list of fields if none has been entered 2015-08-18 19:11:49 +02:00
oliver
94d1821f79 correct indentation of some docstrings 2015-08-16 21:27:55 +02:00
oliver
60b7f12f79 implement clean deletion of Seminaries 2015-08-16 21:27:36 +02:00
oliver
4dca3e8089 merge framework 2015-08-10 20:30:58 +02:00
oliver
00fe33323f remove unused JavaScript files 2015-08-10 20:27:12 +02:00
oliver
d3e54c31c0 add database script for dropping triggers and procedures 2015-08-10 20:26:58 +02:00
coderkun
4beeac80ac change default log mode to AUTO 2015-08-10 20:24:52 +02:00
coderkun
ca03de048e detect localhost by HTTP_HOST instead of SERVER_ADDR 2015-08-10 20:21:30 +02:00
oliver
2e6aa4f6e9 replace remaining tabs with spaces 2015-07-27 15:31:42 +02:00
oliver
cdc2d2aee4 correct media validation for map image 2015-07-27 15:06:09 +02:00
oliver
a55b1bc887 correct validation handling for Quest texts 2015-07-27 15:05:27 +02:00
oliver
d94d2270b9 correct fieldset for user creation 2015-07-27 15:04:51 +02:00
oliver
7e7f9edff3 add MarkItUp editor for textareas with markup support 2015-07-27 15:02:32 +02:00
oliver
b11436b913 use HTML5 and Restricted mode of Textile parser 2015-07-27 14:56:47 +02:00
oliver
0e618b929d merge JavaScripts into one scripts-file 2015-07-27 14:55:53 +02:00
oliver
87baf8f052 correct checking of Achievements (fixes #107) 2015-07-14 16:01:40 +02:00
oliver
9a072b39c3 check Achievements when managing Charactergroups Quests 2015-05-22 14:24:08 +02:00
oliver
5d4e50318f check Achievements when managing Charactergroups 2015-05-22 14:23:31 +02:00
oliver
db60917439 move Achievement check to AchievementComponent 2015-05-22 14:22:36 +02:00
oliver
a8c97c6d8b implement loading models for Controller Components 2015-05-22 14:21:53 +02:00
coderkun
cf18f8b90c implement loading models for Controller Components 2015-05-22 12:59:52 +02:00
oliver
4f88edb9f2 update translations 2015-05-22 12:02:20 +02:00
oliver
8505c7b0cd set title for Map pages 2015-05-22 12:02:11 +02:00
oliver
6112da1571 always check permissions of previous Questgroup 2015-05-22 11:40:59 +02:00
oliver
7b27458321 check additional permissions of previous parent Questgroups for Questgroups and Quests 2015-05-22 11:34:16 +02:00
oliver
9c3369b324 reduce notification sound volume to 50% 2015-05-22 10:09:36 +02:00
oliver
47331d8181 remove empty-files 2015-05-19 15:07:57 +02:00
oliver
4fa73890d2 improve Moodpics by using a MoodpicAgent 2015-05-19 15:03:04 +02:00
oliver
9a02dec0cd correct moodpic for map pages 2015-05-19 13:34:45 +02:00
oliver
daf63951e0 set definer for database triggers 2015-05-19 12:24:24 +02:00
oliver
1e5602fc4c add routines to database create-script 2015-05-19 11:56:46 +02:00
oliver
85dc2f87ec correct database encoding to utf8mb4 and collation to utf8mb4_unicode_ci 2015-05-19 11:56:29 +02:00
oliver
324bc2fc19 set definer for database procedures 2015-05-19 11:55:35 +02:00
oliver
46722d0534 show map link to Seminary admins and moderators 2015-05-19 09:49:24 +02:00
oliver
bad67efeb9 delete map delete link (for now) 2015-05-19 09:46:57 +02:00
oliver
bcd5a6b8da correct check for notification sound 2015-05-17 20:54:00 +02:00
oliver
7d1cd83e3a make cleanup of media more robust 2015-05-17 20:53:43 +02:00
oliver
36cb0180cf hide map menu button if no map is set for the Seminary 2015-05-17 20:53:24 +02:00
oliver
1f1d91850e improve map implementation including edit functionality 2015-05-17 20:53:00 +02:00
oliver
d561cc78ed remove ?finally?-statement to support PHP < 5.5 2015-05-14 19:03:22 +02:00
oliver
77f846c92b hide notification sound element 2015-05-14 18:52:12 +02:00
coderkun
1ce1c18590 correct indentation of config-files 2015-04-26 10:51:42 +02:00
coderkun
a796249867 replace tabs with spaces 2015-04-25 16:22:31 +02:00
coderkun
655de39c6b make array of models to load unique 2015-04-25 14:10:52 +02:00
coderkun
68513e0a0a move PHPdoc configuration file to ?dist? version 2015-04-25 14:10:30 +02:00
coderkun
003bab0890 add RewriteBase to .htaccess files 2015-04-25 14:10:03 +02:00
coderkun
a4487a1028 add namespaces to docstrings 2015-04-25 14:09:46 +02:00
coderkun
a93ccec024 ignore generated documentation 2014-09-16 12:46:17 +02:00
coderkun
1c48c6d10a add PHPDoc configuration 2014-09-16 12:44:30 +02:00
coderkun
b8d4342926 correct typos in doc-tags and add missing tags 2014-09-16 12:42:19 +02:00
coderkun
bf679e9dec correct rewrite rule flags 2014-08-09 00:51:30 +02:00
coderkun
2c0f540f90 increase size of URL params 2014-08-09 00:40:27 +02:00
coderkun
4ee829ca3e ignore logs 2014-08-09 00:38:22 +02:00
coderkun
fa8b0cadcd improve Linker 2014-08-09 00:37:25 +02:00
coderkun
32af66a3e7 correct string comparison for layout 2014-08-09 00:36:55 +02:00
coderkun
6a5f3739cc also load Components of parent classes 2014-08-09 00:36:17 +02:00
coderkun
200b1fe937 change visibility of some properties and methods of core classes from private to protected 2014-08-09 00:35:32 +02:00
coderkun
d746b62308 add method to get current IntermediateAgent from ToplevelAgent() 2014-08-09 00:33:58 +02:00
coderkun
12ae8b180e add IPv6 support 2014-08-09 00:33:11 +02:00
coderkun
fdb115083e add support for Apache 2.4 2014-08-09 00:30:45 +02:00
coderkun
0a45d90ba1 disable auto logging to screen for AJAX-requests 2013-10-30 12:17:07 +01:00
coderkun
d9d85e2306 detect AJAX request and set layout automatically 2013-10-30 12:16:39 +01:00
coderkun
cc4bcac7f8 add IdNotFoundException 2013-09-22 21:49:07 +02:00
coderkun
8508390c27 extend request parameter handling 2013-09-22 21:48:56 +02:00
coderkun
996a501f4f add access-properties 2013-09-22 21:48:36 +02:00
coderkun
53d684d151 implement Components 2013-09-22 21:46:41 +02:00
coderkun
961c869c30 implement drivers as Singleton 2013-09-22 21:44:54 +02:00
coderkun
604e7c9bba load Models defined in parent classes 2013-09-22 21:43:17 +02:00
coderkun
23346a78b5 correct trifles 2013-09-22 21:41:38 +02:00
coderkun
1779c38218 correct namespaces 2013-09-22 21:39:53 +02:00
coderkun
7348ca080c correct namespaces 2013-08-27 14:24:31 +02:00
coderkun
b392eb9188 current state as framework 2013-08-09 02:41:06 +02:00
6886 changed files with 463681 additions and 802960 deletions

9
.gitignore vendored Normal file
View file

@ -0,0 +1,9 @@
/doc/
/logs/
/media/
/tmp/
/uploads/
/seminarymedia/
/seminaryuploads/
/www/analytics/tmp/
/app/lib/phpqrcode/cache/

View file

@ -1,9 +0,0 @@
syntax: regexp
^logs/*
^media/*
^tmp/*
^uploads/*
^seminarymedia/*
^seminaryuploads/*
^www/analytics/config/config.ini.php*
^www/analytics/temp/*

View file

@ -4,6 +4,8 @@ ErrorDocument 403 /www/error403.html
ErrorDocument 404 /www/error404.html
ErrorDocument 500 /www/error500.html
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript text/javascript
<IfModule mod_authz_core.c>

13
README.md Normal file
View file

@ -0,0 +1,13 @@
# Questlab
Questlab is a web application that allows anyone to rework learning content in a game-based manner. For this purpose the application provides a set of game elements and game mechanics which can be configured to be suitable for a specific content. Thus an interactive learning environment will be created which engages the users intrinsic motivation.
The project was founded in 2013, supported by the promotion fund of the [Heinrich-Heine University Düsseldorf](https://www.uni-duesseldorf.de) (Germany), under the name <i>Die Legende von Zyren</i> (eng: <i>The Legend of Zyren</i>). The goal was to impart the learning content of the course <i>Wissensrepräsentation</i> (eng: <i>Knowledge Representation</i>) with game elements and game models to the students of Information Science. This innovative learning environment consisted of a virtual text-based adventure which was accessible via a web-based platform and non-virtual games in class in which the students dived into the adventure and competed in teams against each other.
To generalise the concept and to make it available to other faculties and courses, the project <i>Questlab</i> (working title: <i>The Legendof Z</i>) was started in 2014. Teachers are able to use the application to create their own tasks (Quests) and to embed these into a story designed by them. Furthermore, a Responsive Design has been added and provides best access from all mobile devices.
## Team
* Kathrin Knautz (project management)
* Oliver Hanraths (implementation)
* Daniel Miskovic (user interface)

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\bottomlevel;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\bottomlevel;

View file

@ -0,0 +1,38 @@
<?php
/**
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\bottomlevel;
/**
* Agent to display a Moodpic.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class MoodpicAgent extends \nre\agents\BottomlevelAgent
{
/**
* Action: index.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
}
}
?>

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\bottomlevel;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\bottomlevel;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\bottomlevel;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\bottomlevel;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\intermediate;
@ -31,6 +31,73 @@
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: create.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function create(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: edit.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function edit(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: manage.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function manage(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: conditions.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function conditions(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3));
}
/**
* Action: delete.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function delete(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
}

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\intermediate;
@ -14,7 +14,7 @@
/**
* Agent to display Character groups.
*
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class CharactergroupsAgent extends \nre\agents\IntermediateAgent
@ -25,12 +25,131 @@
/**
* Action: index.
*
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: groupsgroup.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function groupsgroup(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: creategroupsgroups.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function creategroupsgroup(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: editgroupsgroup.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function editgroupsgroup(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: deletegroupsgroup.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function deletegroupsgroup(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: group.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function group(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: creategroup.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function creategroup(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: managegroup.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function managegroup(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: editgroup.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function editgroup(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: deletegroup.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function deletegroup(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
}

View file

@ -0,0 +1,92 @@
<?php
/**
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\intermediate;
/**
* Agent to list Charactergroups Achievements.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class CharactergroupsachievementsAgent extends \nre\agents\IntermediateAgent
{
/**
* Action: achievement.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function achievement(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: create.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function create(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: edit.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function edit(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: manage.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function manage(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: delete.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function delete(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
}
?>

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\intermediate;
@ -31,6 +31,73 @@
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), 'charactergroups');
}
/**
* Action: quest.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function quest(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), 'charactergroups');
}
/**
* Action: create.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function create(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), 'charactergroups');
}
/**
* Action: manage.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function manage(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), 'charactergroups');
}
/**
* Action: edit.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function edit(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), 'charactergroups');
}
/**
* Action: delete.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function delete(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), 'charactergroups');
}
}

View file

@ -0,0 +1,103 @@
<?php
/**
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\intermediate;
/**
* Agent to display Character groups Quest stations.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class CharactergroupsqueststationsAgent extends \nre\agents\IntermediateAgent
{
/**
* Action: index.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
}
/**
* Action: station.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function station(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), 'charactergroups');
}
/**
* Action: create.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function create(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), 'charactergroups');
}
/**
* Action: edit.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function edit(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), 'charactergroups');
}
/**
* Action: edittask.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function edittask(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), 'charactergroups');
}
/**
* Action: delete.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function delete(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), 'charactergroups');
}
}
?>

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\intermediate;
@ -31,6 +31,8 @@
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3));
}
@ -42,6 +44,60 @@
*/
public function character(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3));
}
/**
* Action: register.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function register(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3));
}
/**
* Action: manage.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function manage(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3));
}
/**
* Action: edit.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function edit(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3));
}
/**
* Action: delete.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function delete(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3));
}
}

View file

@ -0,0 +1,79 @@
<?php
/**
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\intermediate;
/**
* Agent to handle Character titles of a Seminary.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class CharactertitlesAgent extends \nre\agents\IntermediateAgent
{
/**
* Action: index.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: create.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function create(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: edit.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function edit(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: delete.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function delete(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
}
?>

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\intermediate;
@ -31,6 +31,47 @@
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: create.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function create(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: edit.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function edit(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: delete.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function delete(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
}

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\intermediate;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\intermediate;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\intermediate;
@ -31,6 +31,73 @@
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: create.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function create(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: topic.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function topic(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: manage.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function manage(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: edit.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function edit(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: delete.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function delete(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
}

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\intermediate;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\intermediate;
@ -31,6 +31,21 @@
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: edit.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function edit(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
}

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\intermediate;

View file

@ -0,0 +1,38 @@
<?php
/**
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\intermediate;
/**
* Agent to manage additional pages.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class PagesAgent extends \nre\agents\IntermediateAgent
{
/**
* Action: index.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
}
}
?>

View file

@ -0,0 +1,38 @@
<?php
/**
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\intermediate;
/**
* Agent to redirect to a page from a (short) QR-code link.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QrAgent extends \nre\agents\IntermediateAgent
{
/**
* Action: index.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
}
}
?>

View file

@ -0,0 +1,38 @@
<?php
/**
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\intermediate;
/**
* Agent to generate and show QR-codes.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QrcodesAgent extends \nre\agents\IntermediateAgent
{
/**
* Action: index.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
}
}
?>

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\intermediate;
@ -31,10 +31,27 @@
*/
public function questgroup(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'questgroup', $request->getParam(3), $request->getParam(4));
// Add Questgroups hierarchy path
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4));
}
/**
* Action: create.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function create(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3));
}
/**
* Action: edit.
*
@ -43,6 +60,10 @@
*/
public function edit(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'questgroup', $request->getParam(3), $request->getParam(4));
// Add Questgroups hierarchy path
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4));
}
@ -55,6 +76,10 @@
*/
public function edittexts(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'questgroup', $request->getParam(3), $request->getParam(4));
// Add Questgroups hierarchy path
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4));
}
@ -67,6 +92,10 @@
*/
public function moveup(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'questgroup', $request->getParam(3), $request->getParam(4));
// Add Questgroups hierarchy path
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4));
}
@ -79,6 +108,10 @@
*/
public function movedown(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'questgroup', $request->getParam(3), $request->getParam(4));
// Add Questgroups hierarchy path
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4));
}
@ -91,6 +124,10 @@
*/
public function delete(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'questgroup', $request->getParam(3), $request->getParam(4));
// Add Questgroups hierarchy path
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4));
}

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\intermediate;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\intermediate;
@ -23,6 +23,19 @@
/**
* Action: index.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3));
}
/**
* Action: quest.
*
@ -31,6 +44,10 @@
*/
public function quest(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'questgroup', $request->getParam(3), $request->getParam(4));
// Add Questgroups hierarchy path
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
}
@ -43,6 +60,10 @@
*/
public function submissions(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'questgroup', $request->getParam(3), $request->getParam(4));
// Add Questgroups hierarchy path
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
}
@ -55,6 +76,10 @@
*/
public function submission(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'questgroup', $request->getParam(3), $request->getParam(4));
// Add Questgroups hierarchy path
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
}
@ -67,6 +92,10 @@
*/
public function create(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'questgroup', $request->getParam(3), $request->getParam(4));
// Add Questgroups hierarchy path
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
}
@ -79,6 +108,10 @@
*/
public function edit(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'questgroup', $request->getParam(3), $request->getParam(4));
// Add Questgroups hierarchy path
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
}
@ -91,6 +124,10 @@
*/
public function edittask(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'questgroup', $request->getParam(3), $request->getParam(4));
// Add Questgroups hierarchy path
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
}
@ -103,6 +140,10 @@
*/
public function edittexts(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'questgroup', $request->getParam(3), $request->getParam(4));
// Add Questgroups hierarchy path
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
}
@ -115,6 +156,10 @@
*/
public function delete(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'questgroup', $request->getParam(3), $request->getParam(4));
// Add Questgroups hierarchy path
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
}

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\intermediate;
@ -31,6 +31,73 @@
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'index');
}
/**
* Action: seminary.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function seminary(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3));
}
/**
* Action: create.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function create(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'index');
}
/**
* Action: edit.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function edit(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: copy.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function copy(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
/**
* Action: delete.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function delete(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
}
}

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\intermediate;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\intermediate;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\intermediate;
@ -29,8 +29,10 @@
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
public function manage(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3));
}
}

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\toplevel;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\toplevel;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\toplevel;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\toplevel;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\toplevel;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents\toplevel;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z;
@ -59,15 +59,12 @@
{
// Use Textile
\hhu\z\lib\Textile::load();
$textileParser = new \Netcarver\Textile\Parser();
$textileParser = new \Netcarver\Textile\Parser('html5');
$string = $textileParser->textileThis($string);
// Add link targets
$string = $this->tLinks($string);
// Handle custom formatting
$string = $this->tCustom($string);
// Handle Seminarymedia
$string = $this->tSeminarymedia($string);
@ -119,12 +116,15 @@
return $string;
}
try {
$dom = new \DOMDocument();
$dom->loadHTML('<?xml encoding="UTF-8">'.$string);
$dom = new \DOMDocument('1.0');
$dom->loadHTML('<!DOCTYPE html><html><head><meta charset="utf-8" /></head><body>'.$string.'</body></html>');
foreach($dom->getElementsByTagName('a') as $link) {
$link->setAttribute('target', '_blank');
}
return $dom->saveHTML();
$body = $dom->getElementsByTagName('body')->item(0);
$string = $dom->saveHTML($body);
return trim(substr($string, 6, strlen($string) - 13));
}
catch(\Exception $e) {
return $string;
@ -132,39 +132,6 @@
}
/**
* Handle custom formatting syntax.
*
* @Deprecated
* @param string $string String to format
* @return string Formatted string
*/
private function tCustom($string)
{
// Important text
$string = str_replace('[strong]', '<strong>', $string);
$string = str_replace('[/strong]', '</strong>', $string);
// Create tables
$string = preg_replace('/(\[table\])\s+/u', '$1', $string);
$string = preg_replace('/\s*(\[tr\])\s*/u', '$1', $string);
$string = preg_replace('%\s+(\[/table\])%u', '$1', $string);
$string = preg_replace('%\s*(\[/tr\])\s*%u', '$1', $string);
$string = str_replace('[table]', '</p><table>', $string);
$string = str_replace('[/table]', '</table><p>', $string);
$string = str_replace('[tr]', '<tr>', $string);
$string = str_replace('[/tr]', '</tr>', $string);
$string = str_replace('[th]', '<th>', $string);
$string = str_replace('[/th]', '</th>', $string);
$string = str_replace('[td]', '<td>', $string);
$string = str_replace('[/td]', '</td>', $string);
// Return new string
return $string;
}
/**
* Handle including Seminarymedia.
*

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z;
@ -19,6 +19,14 @@
*/
class Utils
{
/**
* String length for hashes
*
* @var int
*/
const HASH_LENGTH = 10;
/**
@ -209,6 +217,23 @@
return $mimetype;
}
/**
* Create a random hash string.
*
* @param int Length of string
* @return string String with random characters
*/
public static function createRandomHash($length=self::HASH_LENGTH)
{
// Length of URL
$length = max(0, min(32, $length));
// Create and return random string
return substr(md5(microtime()), rand(0, 32-$length), $length);
}
}
?>

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents;

View file

@ -0,0 +1,298 @@
<?php
/**
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents;
/**
* Abstract class for implementing a StationtypeAgent.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
abstract class StationtypeAgent extends \nre\agents\BottomlevelAgent
{
/**
* Current request
*
* @var \nre\core\Request
*/
private $request;
/**
* Current response
*
* @var \nre\core\Response
*/
private $response;
/**
* Load a StationtypeAgent.
*
* @static
* @throws \hhu\z\exceptions\StationtypeAgentNotFoundException
* @throws \hhu\z\exceptions\StationtypeAgentNotValidException
* @param string $stationtypeName Name of the StationtypeAgent to load
*/
public static function load($stationtypeName)
{
// Determine full classname
$className = self::getClassName($stationtypeName);
try {
// Load class
static::loadClass($stationtypeName, $className);
// Validate class
static::checkClass($className, get_class());
}
catch(\nre\exceptions\ClassNotValidException $e) {
throw new \hhu\z\exceptions\StationtypeAgentNotValidException($e->getClassName());
}
catch(\nre\exceptions\ClassNotFoundException $e) {
throw new \hhu\z\exceptions\StationtypeAgentNotFoundException($e->getClassName());
}
}
/**
* Instantiate a StationtypeAgent (Factory Pattern).
*
* @static
* @throws \nre\exceptions\DatamodelException
* @throws \nre\exceptions\DriverNotValidException
* @throws \nre\exceptions\DriverNotFoundException
* @throws \nre\exceptions\ViewNotFoundException
* @throws \hhu\z\exceptions\StationtypeModelNotValidException
* @throws \hhu\z\exceptions\StationtypeModelNotFoundException
* @throws \hhu\z\exceptions\StationtypeControllerNotValidException
* @throws \hhu\z\exceptions\StationtypeControllerNotFoundException
* @param string $stationtypeName Name of the StationtypeAgent to instantiate
* @param Request $request Current request
* @param Response $response Current respone
* @param Logger $log Log-system
*/
public static function factory($stationtypeName, \nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
{
// Determine full classname
$className = self::getClassName($stationtypeName);
// Construct and return Stationmodule
return new $className($request, $response, $log);
}
/**
* Determine the Agent-classname for the given Stationtype-name.
*
* @static
* @param string $stationtypeName Stationtype-name to get Agent-classname of
* @param string $agentType Agent type of given Agent name
* @return string Classname for the Stationtype-name
*/
private static function getClassName($stationtypeName, $agentType=null)
{
$className = \nre\core\ClassLoader::concatClassNames(
$stationtypeName,
\nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::stripNamespace(get_class())),
'agent'
);
return \nre\configs\AppConfig::$app['namespace']."stationtypes\\$className";
}
/**
* Load the class of a StationtypeAgent.
*
* @static
* @throws \nre\exceptions\ClassNotFoundException
* @param string $stationtypeName Name of the StationtypeAgent to load
* @param string $fullClassName Name of the class to load
*/
private static function loadClass($stationtypeName, $fullClassName)
{
// Determine folder to look in
$className = explode('\\', $fullClassName);
$className = array_pop($className);
// Determine filename
$fileName = ROOT.DS.
\nre\configs\AppConfig::$dirs['stationtypes'].DS.
strtolower($stationtypeName).DS.$className.\nre\configs\CoreConfig::getFileExt('includes');
// Check file
if(!file_exists($fileName))
{
throw new \nre\exceptions\ClassNotFoundException(
$fullClassName
);
}
// Include file
include_once($fileName);
}
/**
* Check inheritance of the StationtypeAgent-class.
*
* @static
* @throws \nre\exceptions\ClassNotValidException
* @param string $className Name of the class to check
* @param string $parentClassName Name of the parent class
*/
public static function checkClass($className, $parentClassName)
{
// Check if class is subclass of parent class
if(!is_subclass_of($className, $parentClassName)) {
throw new \nre\exceptions\ClassNotValidException(
$className
);
}
}
/**
* Construct a new StationtypeAgent.
*
* @throws \nre\exceptions\DatamodelException
* @throws \nre\exceptions\DriverNotValidException
* @throws \nre\exceptions\DriverNotFoundException
* @throws \nre\exceptions\ViewNotFoundException
* @throws \nre\exceptions\ModelNotValidException
* @throws \nre\exceptions\ModelNotFoundException
* @throws \hhu\z\exceptions\StationtypeModelNotValidException
* @throws \hhu\z\exceptions\StationtypeModelNotFoundException
* @throws \hhu\z\exceptions\StationtypeControllerNotValidException
* @throws \hhu\z\exceptions\StationtypeControllerNotFoundException
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
* @param \nre\core\Logger $log Log-system
*/
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
{
// Store values
$this->request = $request;
$this->response = $response;
// Call parent constructor
parent::__construct($request, $response, $log);
}
/**
* Save the answer of a Character group for a Station.
*
* @param array $seminary Current Seminary data
* @param array $groupsgroup Current Groups group data
* @param array $quest Current Quest data
* @param array $station Current Station data
* @param array $group Current Character group data
* @param array $answer Character group answer for the Station
*/
public function saveAnswer($seminary, $groupsgroup, $quest, $station, $group, $answer)
{
$this->controller->saveAnswer(
$seminary,
$groupsgroup,
$quest,
$station,
$group,
$answer
);
}
/**
* Check if the answer of a Character group for a Station matches the
* correct one.
*
* @param array $seminary Current Seminary data
* @param array $groupsgroup Current Groups group data
* @param array $quest Current Quest data
* @param array $station Current Station data
* @param array $group Current Character group data
* @param array $answer Character group answer for the Station
*/
public function matchAnswer($seminary, $groupsgroup, $quest, $station, $group, $answer)
{
return $this->controller->matchAnswer(
$seminary,
$groupsgroup,
$quest,
$station,
$group,
$answer
);
}
/**
* Load the Controller of this Agent.
*
* @throws \nre\exceptions\DatamodelException
* @throws \nre\exceptions\DriverNotValidException
* @throws \nre\exceptions\DriverNotFoundException
* @throws \nre\exceptions\ViewNotFoundException
* @throws \nre\exceptions\ModelNotValidException
* @throws \nre\exceptions\ModelNotFoundException
* @throws \hhu\z\exceptions\StationxuesttypeModelNotValidException
* @throws \hhu\z\exceptions\StationtypeModelNotFoundException
* @throws \hhu\z\exceptions\StationtypeControllerNotValidException
* @throws \hhu\z\exceptions\StationtypeControllerNotFoundException
*/
protected function loadController()
{
// Determine Controller name
$controllerName = \nre\core\ClassLoader::stripClassType(
\nre\core\ClassLoader::getClassName(get_class($this))
);
// Determine ToplevelAgent
$toplevelAgentName = $this->response->getParam(0);
if(is_null($toplevelAgentName)) {
$toplevelAgentName = $this->request->getParam(0, 'toplevel');
$this->response->addParam($toplevelAgentName);
}
// Determine Action
$action = $this->response->getParam(2);
if(is_null($action)) {
$action = $this->request->getParam(2, 'action');
$this->response->addParam($action);
}
// Load Controller
\hhu\z\controllers\StationtypeController::load($controllerName);
// Construct Controller
$this->controller = \hhu\z\controllers\StationtypeController::factory(
$controllerName,
$toplevelAgentName,
$action,
$this
);
}
}
?>

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\agents;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\apis;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\controllers;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\controllers;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\controllers;
@ -31,7 +31,7 @@
*
* @var array
*/
public $models = array('seminaries', 'characters', 'characterroles', 'xplevels', 'avatars', 'achievements');
public $models = array('seminaries', 'characters', 'characterroles', 'xplevels', 'avatars', 'achievements', 'charactertitles');
/**
* Current Seminary
*
@ -91,6 +91,11 @@
catch(\nre\exceptions\IdNotFoundException $e) {
// No Avatar available
}
if(!is_null(self::$character['charactertitle_id']) && !is_null(self::$character['gender']))
{
$title = $this->Charactertitles->getTitleById(self::$character['charactertitle_id']);
self::$character['title'] = $title[(self::$character['gender']) ? 'title_male' : 'title_female'];
}
}
}
catch(\nre\exceptions\IdNotFoundException $e) {
@ -100,8 +105,8 @@
$this->checkPermission($request, $response);
// Check achievements
$this->checkAchievements($request, $response, 'date');
$this->checkAchievements($request, $response, 'achievement');
$this->checkAchievements($request, 'date');
$this->checkAchievements($request, 'achievement');
// Set Seminary and Character data
$this->set('loggedSeminary', self::$seminary);
@ -158,14 +163,13 @@
/**
* Check for newly achieved Achievements.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
* @param array $checkConditions Conditions to check
* @param \nre\core\Request $request Current request
* @param array $checkConditions Conditions to check
*/
protected function checkAchievements(\nre\core\Request $request, \nre\core\Response $response, $checkConditions=null)
protected function checkAchievements(\nre\core\Request $request, $checkConditions=null)
{
// Do not check MediaController
if($this->request->getParam(0, 'toplevel') != \nre\configs\AppConfig::$defaults['toplevel']) {
if($request->getParam(0, 'toplevel') != \nre\configs\AppConfig::$defaults['toplevel']) {
return;
}
@ -174,152 +178,22 @@
return;
}
// Set conditions to check
if(!is_null($checkConditions) && !is_array($checkConditions)) {
$checkConditions = array($checkConditions);
}
// Check Achievements
$achievements = $this->Achievement->checkAchievements(
self::$seminary['id'],
self::$character['id'],
$checkConditions
);
// Get unachieved Achievments
$achievements = $this->Achievements->getUnachhievedAchievementsForCharacter(self::$seminary['id'], self::$character['id']);
if(in_array('user', self::$character['characterroles'])) {
$achievements = array_merge($achievements, $this->Achievements->getUnachievedOnlyOnceAchievementsForSeminary(self::$seminary['id']));
}
// Check conditions
// Add notifications
foreach($achievements as &$achievement)
{
// Check condition to test
if(!is_null($checkConditions) && !in_array($achievement['condition'], $checkConditions)) {
continue;
}
// Check deadline
if(!is_null($achievement['deadline']) && $achievement['deadline'] < date('Y-m-d H:i:s')) {
continue;
}
// Get conditions
$conditions = array();
$progress = 0;
switch($achievement['condition'])
{
// Date conditions
case 'date':
$conditionsDate = $this->Achievements->getAchievementConditionsDate($achievement['id']);
foreach($conditionsDate as &$condition)
{
$conditions[] = array(
'func' => 'checkAchievementConditionDate',
'params' => array(
$condition['select']
)
);
}
break;
// Character conditions
case 'character':
$conditionsCharacter = $this->Achievements->getAchievementConditionsCharacter($achievement['id']);
foreach($conditionsCharacter as &$condition)
{
$conditions[] = array(
'func' => 'checkAchievementConditionCharacter',
'params' => array(
$condition['field'],
$condition['value'],
self::$character['id']
)
);
}
break;
// Quest conditions
case 'quest':
$conditionsQuest = $this->Achievements->getAchievementConditionsQuest($achievement['id']);
foreach($conditionsQuest as &$condition)
{
$conditions[] = array(
'func' => 'checkAchievementConditionQuest',
'params' => array(
$condition['field'],
$condition['count'],
$condition['value'],
$condition['status'],
$condition['groupby'],
$condition['quest_id'],
self::$character['id']
)
);
}
break;
// Achievement conditions
case 'achievement':
$conditionsAchievement = $this->Achievements->getAchievementConditionsAchievement($achievement['id']);
foreach($conditionsAchievement as &$condition)
{
$conditions[] = array(
'func' => 'checkAchievementConditionAchievement',
'params' => array(
$condition['field'],
$condition['count'],
$condition['value'],
$condition['groupby'],
$condition['meta_achievement_id'],
self::$character['id']
)
);
}
break;
}
// Do not achieve Achievements without conditions
if(empty($conditions)) {
continue;
}
// Check conditions
$achieved = ($achievement['all_conditions'] == 1);
foreach($conditions as &$condition)
{
// Calculate result of condition
$result = call_user_func_array(
array(
$this->Achievements,
$condition['func']
),
$condition['params']
);
// The overall result and abort if possible
if($achievement['all_conditions'])
{
if(!$result) {
$achieved = false;
break;
}
}
else
{
if($result) {
$achieved = true;
break;
}
}
}
// Achievement achieved
if($achieved)
{
// Set status
$this->Achievements->setAchievementAchieved($achievement['id'], self::$character['id']);
// Add notification
$this->Notification->addNotification(
\hhu\z\controllers\components\NotificationComponent::TYPE_ACHIEVEMENT,
$achievement['title'],
$this->linker->link(array('achievements', 'index', self::$seminary['url']), 0, true, null, true, $achievement['url']),
(!is_null($achievement['achieved_achievementsmedia_id']) ? $this->linker->link(array('media','achievement',self::$seminary['url'],$achievement['url'])) : null)
);
}
$this->Notification->addNotification(
\hhu\z\controllers\components\NotificationComponent::TYPE_ACHIEVEMENT,
$achievement['title'],
$this->linker->link(array('achievements', 'index', self::$seminary['url']), 0, true, null, true, $achievement['url']),
(!is_null($achievement['achieved_achievementsmedia_id']) ? $this->linker->link(array('media','achievement',self::$seminary['url'],$achievement['url'])) : null)
);
}
}

View file

@ -0,0 +1,320 @@
<?php
/**
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\controllers;
/**
* Abstract class for implementing a StationtypeController.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
abstract class StationtypeController extends \hhu\z\Controller
{
/**
* Required models
*
* @var array
*/
public $models = array('seminaries');
/**
* Save the answer of a Character group for a Station.
*
* @param array $seminary Current Seminary data
* @param array $groupsgroup Current Groups group data
* @param array $quest Current Quest data
* @param array $station Current Station data
* @param array $charactergroup Current Character group data
* @param array $answer Character group answer for the Station
*/
public abstract function saveAnswer($seminary, $groupsgroup, $quest, $station, $charactergroup, $answer);
/**
* Check if answer of a Character group for a Station matches the correct one.
*
* @param array $seminary Current Seminary data
* @param array $groupsgroup Current Groups group data
* @param array $quest Current Quest data
* @param array $station Current Station data
* @param array $charactergroup Current Character group data
* @param array $answer Character group answer for the Station
* @return boolean True/false for a right/wrong answer
*/
public abstract function matchAnswer($seminary, $groupsgroup, $quest, $station, $charactergroup, $answer);
/**
* Action: quest.
*
* Show the task of a Station.
*
* @param array $seminary Current Seminary data
* @param array $groupsgroup Current Groups group data
* @param array $quest Current Quest data
* @param array $station Current Station data
* @param array $charactergroup Current Character group data
*/
public abstract function quest($seminary, $groupsgroup, $quest, $station, $charactergroup);
/**
* Action: edittask.
*
* Edit the task of a Station.
*
* @param array $seminary Current Seminary data
* @param array $groupsgroup Current Groups group data
* @param array $quest Current Quest data
* @param array $station Current Station data
*/
public abstract function edittask($seminary, $groupsgroup, $quest, $station);
/**
* Load a StationtypeController.
*
* @static
* @throws \hhu\z\exceptions\StationtypeControllerNotFoundException
* @throws \hhu\z\exceptions\StationtypeControllerNotValidException
* @param string $controllerName Name of the StationtypeController to load
*/
public static function load($controllerName)
{
// Determine full classname
$className = self::getClassName($controllerName);
try {
// Load class
static::loadClass($controllerName, $className);
// Validate class
static::checkClass($className, get_class());
}
catch(\nre\exceptions\ClassNotValidException $e) {
throw new \hhu\z\exceptions\StationtypeControllerNotValidException($e->getClassName());
}
catch(\nre\exceptions\ClassNotFoundException $e) {
throw new \hhu\z\exceptions\StationtypeControllerNotFoundException($e->getClassName());
}
}
/**
* Instantiate a StationtypeController (Factory Pattern).
*
* @static
* @throws \nre\exceptions\DatamodelException
* @throws \nre\exceptions\DriverNotFoundException
* @throws \nre\exceptions\DriverNotValidException
* @throws \nre\exceptions\ModelNotValidException
* @throws \nre\exceptions\ModelNotFoundException
* @throws \nre\exceptions\ViewNotFoundException
* @throws \hhu\z\exceptions\StationtypeModelNotValidException
* @throws \hhu\z\exceptions\StationtypeModelNotFoundException
* @param string $controllerName Name of the StationtypeController to instantiate
* @param string $layoutName Name of the current Layout
* @param string $action Current Action
* @param \nre\core\Agent $agent Corresponding Agent
*/
public static function factory($controllerName, $layoutName, $action, $agent)
{
// Determine full classname
$className = self::getClassName($controllerName);
// Construct and return Controller
return new $className($layoutName, $action, $agent);
}
/**
* Determine the Controller-classname for the given Stationtype-name.
*
* @static
* @param string $stationtypeName Stationtype-name to get Controller-classname of
* @return string Classname for the Stationtype-name
*/
private static function getClassName($stationtypeName)
{
$className = \nre\core\ClassLoader::concatClassNames(
$stationtypeName,
\nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::stripNamespace(get_class())),
'controller'
);
return \nre\configs\AppConfig::$app['namespace']."stationtypes\\$className";
}
/**
* Load the class of a StationtypeController
*
* @static
* @throws \nre\exceptions\ClassNotFoundException
* @param string $stationtypeName Name of the StationtypeController to load
* @param string $fullClassName Name of the class to load
*/
private static function loadClass($stationtypeName, $fullClassName)
{
// Determine folder to look in
$className = explode('\\', $fullClassName);
$className = array_pop($className);
// Determine filename
$fileName = ROOT.DS.
\nre\configs\AppConfig::$dirs['stationtypes'].DS.
strtolower($stationtypeName).DS.
$className.\nre\configs\CoreConfig::getFileExt('includes');
// Check file
if(!file_exists($fileName))
{
throw new \nre\exceptions\ClassNotFoundException(
$fullClassName
);
}
// Include file
include_once($fileName);
}
/**
* Check inheritance of the StationtypeController-class.
*
* @static
* @throws \nre\exceptions\ClassNotValidException
* @param string $className Name of the class to check
* @param string $parentClassName Name of the parent class
*/
public static function checkClass($className, $parentClassName)
{
// Check if class is subclass of parent class
if(!is_subclass_of($className, $parentClassName)) {
throw new \nre\exceptions\ClassNotValidException(
$className
);
}
}
/**
* Construct a new application Controller.
*
* @throws \nre\exceptions\DriverNotFoundException
* @throws \nre\exceptions\DriverNotValidException
* @throws \nre\exceptions\ModelNotValidException
* @throws \nre\exceptions\ModelNotFoundException
* @throws \nre\exceptions\ViewNotFoundException
* @throws \hhu\z\exceptions\StationtypeModelNotValidException
* @throws \hhu\z\exceptions\StationtypeModelNotFoundException
* @param string $layoutName Name of the current Layout
* @param string $action Current Action
* @param Agent $agent Corresponding Agent
*/
public function __construct($layoutName, $action, $agent)
{
parent::__construct($layoutName, $action, $agent);
}
/**
* Load the Models of this Controller.
*
* @throws \nre\exceptions\DatamodelException
* @throws \nre\exceptions\DriverNotFoundException
* @throws \nre\exceptions\DriverNotValidException
* @throws \nre\exceptions\ModelNotValidException
* @throws \nre\exceptions\ModelNotFoundException
* @throws \hhu\z\exceptions\StationtypeModelNotValidException
* @throws \hhu\z\exceptions\StationtypeModelNotFoundException
*/
protected function loadModels()
{
// Load default models
parent::loadModels();
// Load StationtypeModel
$this->loadModel();
}
/**
* Load the Model of the Stationtype.
*
* @throws \hhu\z\exceptions\StationtypeModelNotValidException
* @throws \hhu\z\exceptions\StationtypeModelNotFoundException
*/
private function loadModel()
{
// Determine Model
$model = \nre\core\ClassLoader::stripClassType(
\nre\core\ClassLoader::stripClassType(
\nre\core\ClassLoader::stripNamespace(
get_class($this)
)
)
);
// Load class
\hhu\z\models\StationtypeModel::load($model);
// Construct Model
$modelName = ucfirst(strtolower($model));
$this->$modelName = \hhu\z\models\StationtypeModel::factory($model);
}
/**
* Load the View of this StationtypeController.
*
* @throws \nre\exceptions\ViewNotFoundException
* @param string $layoutName Name of the current Layout
* @param string $action Current Action
*/
protected function loadView($layoutName, $action)
{
// Check Layout name
if(is_null($layoutName)) {
return;
}
// Determine controller name
$controllerName = \nre\core\ClassLoader::stripClassType(
\nre\core\ClassLoader::getClassName(
get_class($this)
)
);
// Load view
$this->view = \hhu\z\views\StationtypeView::loadAndFactory(
$layoutName,
$controllerName,
$action
);
}
}
?>

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\exceptions;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\exceptions;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\exceptions;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\exceptions;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\exceptions;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\exceptions;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\exceptions;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\exceptions;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\exceptions;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\exceptions;

View file

@ -0,0 +1,79 @@
<?php
/**
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\exceptions;
/**
* Exception: StationtypeAgent not found.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class StationtypeAgentNotFoundException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 401;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'StationtypeAgent not found';
/**
* Name of the class that was not found
*
* @var string
*/
private $stationtypeName;
/**
* Construct a new exception.
*
* @param string $stationtypeName Name of the StationtypeAgent that was not found
* @param string $message Error message
* @param int $code Error code
*/
function __construct($stationtypeName, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code,
$stationtypeName
);
// Store values
$this->stationtypeName = $stationtypeName;
}
/**
* Get the name of the StationtypeAgent that was not found.
*
* @return string Name of the StationtypeAgent that was not found
*/
public function getClassName()
{
return $this->stationtypeName;
}
}
?>

View file

@ -0,0 +1,79 @@
<?php
/**
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\exceptions;
/**
* Exception: StationtypeAgent not valid.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class StationtypeAgentNotValidException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 402;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'StationtypeAgent not valid';
/**
* Name of the invalid class
*
* @var string
*/
private $stationtypeName;
/**
* Construct a new exception.
*
* @param string $stationtypeName Name of the invalid StationtypeAgent
* @param string $message Error message
* @param int $code Error code
*/
function __construct($stationtypeName, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code,
$stationtypeName
);
// Store value
$this->stationtypeName = $stationtypeName;
}
/**
* Get the name of the invalid StationtypeAgent.
*
* @return string Name of the invalid StationtypeAgent
*/
public function getClassName()
{
return $this->stationtypeName;
}
}
?>

View file

@ -0,0 +1,79 @@
<?php
/**
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\exceptions;
/**
* Exception: StationtypeController not found.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class StationtypeControllerNotFoundException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 403;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'StationtypeController not found';
/**
* Name of the class that was not found
*
* @var string
*/
private $stationtypeName;
/**
* Construct a new exception.
*
* @param string $stationtypeName Name of the StationtypeController that was not found
* @param string $message Error message
* @param int $code Error code
*/
function __construct($stationtypeName, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code,
$stationtypeName
);
// Store values
$this->stationtypeName = $stationtypeName;
}
/**
* Get the name of the StationtypeController that was not found.
*
* @return string Name of the StationtypeController that was not found
*/
public function getClassName()
{
return $this->stationtypeName;
}
}
?>

View file

@ -0,0 +1,79 @@
<?php
/**
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\exceptions;
/**
* Exception: StationtypeController not valid.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class StationtypeControllerNotValidException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 404;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'StationtypeController not valid';
/**
* Name of the invalid class
*
* @var string
*/
private $stationtypeName;
/**
* Construct a new exception.
*
* @param string $stationtypeName Name of the invalid StationtypeController
* @param string $message Error message
* @param int $code Error code
*/
function __construct($stationtypeName, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code,
$stationtypeName
);
// Store value
$this->stationtypeName = $stationtypeName;
}
/**
* Get the name of the invalid StationtypeController.
*
* @return string Name of the invalid StationtypeController
*/
public function getClassName()
{
return $this->stationtypeName;
}
}
?>

View file

@ -0,0 +1,79 @@
<?php
/**
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\exceptions;
/**
* Exception: StationtypeModel not found.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class StationtypeModelNotFoundException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 405;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'StationtypeModel not found';
/**
* Name of the class that was not found
*
* @var string
*/
private $stationtypeName;
/**
* Construct a new exception.
*
* @param string $stationtypeName Name of the StationtypeModel that was not found
* @param string $message Error message
* @param int $code Error code
*/
function __construct($stationtypeName, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code,
$stationtypeName
);
// Store values
$this->stationtypeName = $stationtypeName;
}
/**
* Get the name of the StationtypeModel that was not found.
*
* @return string Name of the StationtypeModel that was not found
*/
public function getClassName()
{
return $this->stationtypeName;
}
}
?>

View file

@ -0,0 +1,79 @@
<?php
/**
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\exceptions;
/**
* Exception: StationxuesttypeModel not valid.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class StationtypeModelNotValidException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 406;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'StationtypeModel not valid';
/**
* Name of the invalid class
*
* @var string
*/
private $stationtypeName;
/**
* Construct a new exception.
*
* @param string $stationtypeName Name of the invalid StationtypeModel
* @param string $message Error message
* @param int $code Error code
*/
function __construct($stationtypeName, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code,
$stationtypeName
);
// Store value
$this->stationtypeName = $stationtypeName;
}
/**
* Get the name of the invalid StationtypeModel.
*
* @return string Name of the invalid StationtypeModel
*/
public function getClassName()
{
return $this->stationtypeName;
}
}
?>

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\exceptions;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\exceptions;

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\lib

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\lib

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://github.com/coderkun/questlab
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/

33
app/lib/Phpqrcode-lib.inc Normal file
View file

@ -0,0 +1,33 @@
<?php
/**
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\lib;
/**
* Class to ensure that Compatibility library below is loaded.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class Phpqrcode
{
/**
* Call this function to load necessary files.
*/
public static function load()
{
require_once('phpqrcode'.DS.'qrlib.php');
}
}
?>

3346
app/lib/Phpqrcode.inc Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\lib

228
app/lib/Similarity.inc Normal file
View file

@ -0,0 +1,228 @@
<?php
/**
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\lib;
/**
* Class to calculate similarity between documents.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class Similarity
{
/**
* Read a file and return its text.
*
* Currently only PDF-files are supported and “pdftotext” needs to be
* installed. If reading fails, false is returned.
*
* @param string $filename Name of file to read
* @return mixed Text of document (string) or false (boolean)
*/
public static function readDocument($filename)
{
if(!file_exists($filename)) {
return false;
}
$text = array();
$result = 0;
exec(sprintf('pdftotext "%s" -', $filename), $text, $result);
if($result != 0) {
return false;
}
$text = mb_strtolower(implode('', $text));
return $text;
}
/**
* Split a text into N-grams.
*
* The default N is 3.
*
* @param string $document Text to be splitted
* @param int $n Size of grams to split into (N)
* @return array List of n-grams
*/
public static function splitNgrams($document, $n=3)
{
$affix = implode(' ', array_fill(0, $n-1, ' '));
$document = $affix.$document.$affix;
$ngrams = array();
for($i=0; $i<mb_strlen($document)-$n; $i++) {
$ngrams[] = mb_substr($document, $i, $n);
}
return $ngrams;
}
/**
* Compare to documents, represented by there Term Frequencies (TFs)
* values.
*
* $tfsA, $tfsB and $idf_n are expected to be associative arrays with
* the term as key and the corresponding frequency as value.
*
* @param array $tfsA Term Frequencies of document A
* @param array $tfsB Term Frequencies of document B
* @param int $idf_N Total count of documents in corpus
* @param array $idf_n Inverse Document Frequencies of all terms
* @return float Similarity value (between 0.0 and 1.0)
*/
public static function compare($tfsA, $tfsB, $idf_N, $idf_n)
{
// Create vector A
$vectorA = self::getVector($tfsA, $idf_N, $idf_n);
// Create vector B
$vectorB = self::getVector($tfsB, $idf_N, $idf_n);
// Compare vectors
$result = self::cosinus($vectorA, $vectorB);
// Return result
return $result;
}
/**
* Calculate the vector for a document based on TF and IDF.
*
* $tfs and $idf_n are expected to be associative arrays with the term
* as key and the corresponding frequency as value. The resulting
* vector is an associative array with the terms as keys and their
* corresponding values as value.
*
* @param array $tfs Term Frequencies of document
* @param int $idf_N Total count of documents in corpus
* @param array $idf_n Inverse Document Frequencies of all terms
* @return array Document vector
*/
protected static function getVector($tfs, $idf_N, $idf_n)
{
// TF * IDF
$tfidfs = self::getTFIDFs($tfs, $idf_N, $idf_n);
return $tfidfs;
}
/*
* Calculate TF*IDF values for a document.
*
* $tfs and $idf_n are expected to be associative arrays with the term
* as key and the corresponding frequency as value. The resulting
* value is an associative array with the terms as keys and their
* corresponding TF*IDF as values.
*
* @param array $tfs Term Frequencies of document
* @param int $idf_N Total count of documents in corpus
* @param array $idf_n Inverse Document Frequencies of all terms
* @return array TF*IDF values
*/
protected static function getTFIDFs($tfs, $idf_N, $idf_n)
{
$tfidfs = array();
// Calculate TF*IDF
foreach($tfs as $term => &$tf)
{
if(array_key_exists($term, $idf_n)) {
$idf = log($idf_N / $idf_n[$term], 2);
}
else {
// TODO Laplace norm: n = 1?
$idf = log($idf_N / 1, 2);
}
$tfidfs[$term] = $tf * $idf;
}
return $tfidfs;
}
/**
* Calculate cosinus similarity between two vectors.
*
* sim(a, b) = (a・b) / (||a|| * ||b||)
*
* @param array $a Vector A
* @param array $b Vector B
* @return float Similarity value (between 0.0 and 1.0)
*/
protected static function cosinus(array $a, array $b)
{
$normA = self::norm($a);
$normB = self::norm($b);
if(($normA * $normB) != 0) {
return self::dotProduct($a, $b) / ($normA * $normB);
}
else {
return 0;
}
}
/**
* Calculate the dot-product for two vectors.
*
* a・b = summation{i=1,n}(a[i] * b[i])
*
* @param array $a Vector A
* @param array $b Vector B
* @return float Dot-product
*/
protected static function dotProduct(array $a, array $b)
{
$dotProduct = 0;
$keysA = array_keys(array_filter($a));
$keysB = array_keys(array_filter($b));
$uniqueKeys = array_unique(array_merge($keysA, $keysB));
foreach($uniqueKeys as $key) {
if(!empty($a[$key]) && !empty($b[$key])) {
$dotProduct += ($a[$key] * $b[$key]);
}
}
return $dotProduct;
}
/**
* Caculate the Euclidean norm for a vector.
*
* ||x|| = sqrt(x・x) // ・ is a dot product
*
* @param array $vector Vector
* @return float Euclidean norm
*/
protected static function norm(array $vector)
{
return sqrt(self::dotProduct($vector, $vector));
}
}
?>

View file

@ -1,12 +1,12 @@
<?php
/**
* The Legend of Z
* Questlab
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @copyright 2014 2016 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @link https://github.com/coderkun/questlab
*/
namespace hhu\z\lib;

View file

@ -0,0 +1,38 @@
* 1.0.0 build 2010031920
- first public release
- help in readme, install
- cleanup ans separation of QRtools and QRspec
- now TCPDF binding requires minimal changes in TCPDF, having most of job
done in QRtools tcpdfBarcodeArray
- nicer QRtools::timeBenchmark output
- license and copyright notices in files
- indent cleanup - from tab to 4spc, keep it that way please :)
- sf project, repository, wiki
- simple code generator in index.php
* 1.1.0 build 2010032113
- added merge tool wich generate merged version of code
located in phpqrcode.php
- splited qrconst.php from qrlib.php
* 1.1.1 build 2010032405
- patch by Rick Seymour allowing saving PNG and displaying it at the same time
- added version info in VERSION file
- modified merge tool to include version info into generated file
- fixed e-mail in almost all head comments
* 1.1.2 build 2010032722
- full integration with TCPDF thanks to Nicola Asuni, it's author
- fixed bug with alphanumeric encoding detection
* 1.1.3 build 2010081807
- short opening tags replaced with standard ones
* 1.1.4 build 2010100721
- added missing static keyword QRinput::check (found by Luke Brookhart, Onjax LLC)

67
app/lib/phpqrcode/INSTALL Normal file
View file

@ -0,0 +1,67 @@
== REQUIREMENTS ==
* PHP5
* PHP GD2 extension with JPEG and PNG support
== INSTALLATION ==
If you want to recreate cache by yourself make sure cache directory is
writable and you have permisions to write into it. Also make sure you are
able to read files in it if you have cache option enabled
== CONFIGURATION ==
Feel free to modify config constants in qrconfig.php file. Read about it in
provided comments and project wiki page (links in README file)
== QUICK START ==
Notice: probably you should'nt use all of this in same script :)
<?phpb
//include only that one, rest required files will be included from it
include "qrlib.php"
//write code into file, Error corection lecer is lowest, L (one form: L,M,Q,H)
//each code square will be 4x4 pixels (4x zoom)
//code will have 2 code squares white boundary around
QRcode::png('PHP QR Code :)', 'test.png', 'L', 4, 2);
//same as above but outputs file directly into browser (with appr. header etc.)
//all other settings are default
//WARNING! it should be FIRST and ONLY output generated by script, otherwise
//rest of output will land inside PNG binary, breaking it for sure
QRcode::png('PHP QR Code :)');
//show benchmark
QRtools::timeBenchmark();
//rebuild cache
QRtools::buildCache();
//code generated in text mode - as a binary table
//then displayed out as HTML using Unicode block building chars :)
$tab = $qr->encode('PHP QR Code :)');
QRspec::debug($tab, true);
== TCPDF INTEGRATION ==
Inside bindings/tcpdf you will find slightly modified 2dbarcodes.php.
Instal phpqrcode liblaty inside tcpdf folder, then overwrite (or merge)
2dbarcodes.php
Then use similar as example #50 from TCPDF examples:
<?php
$style = array(
'border' => true,
'padding' => 4,
'fgcolor' => array(0,0,0),
'bgcolor' => false, //array(255,255,255)
);
//code name: QR, specify error correction level after semicolon (L,M,Q,H)
$pdf->write2DBarcode('PHP QR Code :)', 'QR,L', '', '', 30, 30, $style, 'N');

165
app/lib/phpqrcode/LICENSE Normal file
View file

@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

45
app/lib/phpqrcode/README Normal file
View file

@ -0,0 +1,45 @@
This is PHP implementation of QR Code 2-D barcode generator. It is pure-php
LGPL-licensed implementation based on C libqrencode by Kentaro Fukuchi.
== LICENSING ==
Copyright (C) 2010 by Dominik Dzienia
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU Lesser General Public License (LICENSE file)
for more details.
You should have received a copy of the GNU Lesser General Public License along
with this library; if not, write to the Free Software Foundation, Inc., 51
Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
== INSTALATION AND USAGE ==
* INSTALL file
* http://sourceforge.net/apps/mediawiki/phpqrcode/index.php?title=Main_Page
== CONTACT ==
Fell free to contact me via e-mail (deltalab at poczta dot fm) or using
folowing project pages:
* http://sourceforge.net/projects/phpqrcode/
* http://phpqrcode.sourceforge.net/
== ACKNOWLEDGMENTS ==
Based on C libqrencode library (ver. 3.1.1)
Copyright (C) 2006-2010 by Kentaro Fukuchi
http://megaui.net/fukuchi/works/qrencode/index.en.html
QR Code is registered trademarks of DENSO WAVE INCORPORATED in JAPAN and other
countries.
Reed-Solomon code encoder is written by Phil Karn, KA9Q.
Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q

View file

@ -0,0 +1,2 @@
1.1.4
2010100721

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,94 @@
<?php
/*
* PHP QR Code encoder
*
* Exemplatory usage
*
* PHP QR Code is distributed under LGPL 3
* Copyright (C) 2010 Dominik Dzienia <deltalab at poczta dot fm>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
echo "<h1>PHP QR Code</h1><hr/>";
//set it to writable location, a place for temp generated PNG files
$PNG_TEMP_DIR = dirname(__FILE__).DIRECTORY_SEPARATOR.'temp'.DIRECTORY_SEPARATOR;
//html PNG location prefix
$PNG_WEB_DIR = 'temp/';
include "qrlib.php";
//ofcourse we need rights to create temp dir
if (!file_exists($PNG_TEMP_DIR))
mkdir($PNG_TEMP_DIR);
$filename = $PNG_TEMP_DIR.'test.png';
//processing form input
//remember to sanitize user input in real-life solution !!!
$errorCorrectionLevel = 'L';
if (isset($_REQUEST['level']) && in_array($_REQUEST['level'], array('L','M','Q','H')))
$errorCorrectionLevel = $_REQUEST['level'];
$matrixPointSize = 4;
if (isset($_REQUEST['size']))
$matrixPointSize = min(max((int)$_REQUEST['size'], 1), 10);
if (isset($_REQUEST['data'])) {
//it's very important!
if (trim($_REQUEST['data']) == '')
die('data cannot be empty! <a href="?">back</a>');
// user data
$filename = $PNG_TEMP_DIR.'test'.md5($_REQUEST['data'].'|'.$errorCorrectionLevel.'|'.$matrixPointSize).'.png';
QRcode::png($_REQUEST['data'], $filename, $errorCorrectionLevel, $matrixPointSize, 2);
} else {
//default data
echo 'You can provide data in GET parameter: <a href="?data=like_that">like that</a><hr/>';
QRcode::png('PHP QR Code :)', $filename, $errorCorrectionLevel, $matrixPointSize, 2);
}
//display generated file
echo '<img src="'.$PNG_WEB_DIR.basename($filename).'" /><hr/>';
//config form
echo '<form action="index.php" method="post">
Data:&nbsp;<input name="data" value="'.(isset($_REQUEST['data'])?htmlspecialchars($_REQUEST['data']):'PHP QR Code :)').'" />&nbsp;
ECC:&nbsp;<select name="level">
<option value="L"'.(($errorCorrectionLevel=='L')?' selected':'').'>L - smallest</option>
<option value="M"'.(($errorCorrectionLevel=='M')?' selected':'').'>M</option>
<option value="Q"'.(($errorCorrectionLevel=='Q')?' selected':'').'>Q</option>
<option value="H"'.(($errorCorrectionLevel=='H')?' selected':'').'>H - best</option>
</select>&nbsp;
Size:&nbsp;<select name="size">';
for($i=1;$i<=10;$i++)
echo '<option value="'.$i.'"'.(($matrixPointSize==$i)?' selected':'').'>'.$i.'</option>';
echo '</select>&nbsp;
<input type="submit" value="GENERATE"></form><hr/>';
// benchmark
QRtools::timeBenchmark();

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,180 @@
<?php
/*
* PHP QR Code encoder
*
* Bitstream class
*
* Based on libqrencode C library distributed under LGPL 2.1
* Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi <fukuchi@megaui.net>
*
* PHP QR Code is distributed under LGPL 3
* Copyright (C) 2010 Dominik Dzienia <deltalab at poczta dot fm>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class QRbitstream {
public $data = array();
//----------------------------------------------------------------------
public function size()
{
return count($this->data);
}
//----------------------------------------------------------------------
public function allocate($setLength)
{
$this->data = array_fill(0, $setLength, 0);
return 0;
}
//----------------------------------------------------------------------
public static function newFromNum($bits, $num)
{
$bstream = new QRbitstream();
$bstream->allocate($bits);
$mask = 1 << ($bits - 1);
for($i=0; $i<$bits; $i++) {
if($num & $mask) {
$bstream->data[$i] = 1;
} else {
$bstream->data[$i] = 0;
}
$mask = $mask >> 1;
}
return $bstream;
}
//----------------------------------------------------------------------
public static function newFromBytes($size, $data)
{
$bstream = new QRbitstream();
$bstream->allocate($size * 8);
$p=0;
for($i=0; $i<$size; $i++) {
$mask = 0x80;
for($j=0; $j<8; $j++) {
if($data[$i] & $mask) {
$bstream->data[$p] = 1;
} else {
$bstream->data[$p] = 0;
}
$p++;
$mask = $mask >> 1;
}
}
return $bstream;
}
//----------------------------------------------------------------------
public function append(QRbitstream $arg)
{
if (is_null($arg)) {
return -1;
}
if($arg->size() == 0) {
return 0;
}
if($this->size() == 0) {
$this->data = $arg->data;
return 0;
}
$this->data = array_values(array_merge($this->data, $arg->data));
return 0;
}
//----------------------------------------------------------------------
public function appendNum($bits, $num)
{
if ($bits == 0)
return 0;
$b = QRbitstream::newFromNum($bits, $num);
if(is_null($b))
return -1;
$ret = $this->append($b);
unset($b);
return $ret;
}
//----------------------------------------------------------------------
public function appendBytes($size, $data)
{
if ($size == 0)
return 0;
$b = QRbitstream::newFromBytes($size, $data);
if(is_null($b))
return -1;
$ret = $this->append($b);
unset($b);
return $ret;
}
//----------------------------------------------------------------------
public function toByte()
{
$size = $this->size();
if($size == 0) {
return array();
}
$data = array_fill(0, (int)(($size + 7) / 8), 0);
$bytes = (int)($size / 8);
$p = 0;
for($i=0; $i<$bytes; $i++) {
$v = 0;
for($j=0; $j<8; $j++) {
$v = $v << 1;
$v |= $this->data[$p];
$p++;
}
$data[$i] = $v;
}
if($size & 7) {
$v = 0;
for($j=0; $j<($size & 7); $j++) {
$v = $v << 1;
$v |= $this->data[$p];
$p++;
}
$data[$bytes] = $v;
}
return $data;
}
}

View file

@ -0,0 +1,17 @@
<?php
/*
* PHP QR Code encoder
*
* Config file, feel free to modify
*/
define('QR_CACHEABLE', true); // use cache - more disk reads but less CPU power, masks and format templates are stored there
define('QR_CACHE_DIR', dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR); // used when QR_CACHEABLE === true
define('QR_LOG_DIR', dirname(__FILE__).DIRECTORY_SEPARATOR); // default error logs dir
define('QR_FIND_BEST_MASK', true); // if true, estimates best mask (spec. default, but extremally slow; set to false to significant performance boost but (propably) worst quality code
define('QR_FIND_FROM_RANDOM', false); // if false, checks all masks available, otherwise value tells count of masks need to be checked, mask id are got randomly
define('QR_DEFAULT_MASK', 2); // when QR_FIND_BEST_MASK === false
define('QR_PNG_MAXIMUM_SIZE', 1024); // maximum allowed png image width (in pixels), tune to make sure GD and PHP can handle such big images

View file

@ -0,0 +1,54 @@
<?php
/*
* PHP QR Code encoder
*
* Common constants
*
* Based on libqrencode C library distributed under LGPL 2.1
* Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi <fukuchi@megaui.net>
*
* PHP QR Code is distributed under LGPL 3
* Copyright (C) 2010 Dominik Dzienia <deltalab at poczta dot fm>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// Encoding modes
define('QR_MODE_NUL', -1);
define('QR_MODE_NUM', 0);
define('QR_MODE_AN', 1);
define('QR_MODE_8', 2);
define('QR_MODE_KANJI', 3);
define('QR_MODE_STRUCTURE', 4);
// Levels of error correction.
define('QR_ECLEVEL_L', 0);
define('QR_ECLEVEL_M', 1);
define('QR_ECLEVEL_Q', 2);
define('QR_ECLEVEL_H', 3);
// Supported output formats
define('QR_FORMAT_TEXT', 0);
define('QR_FORMAT_PNG', 1);
class qrstr {
public static function set(&$srctab, $x, $y, $repl, $replLen = false) {
$srctab[$y] = substr_replace($srctab[$y], ($replLen !== false)?substr($repl,0,$replLen):$repl, $x, ($replLen !== false)?$replLen:strlen($repl));
}
}

View file

@ -0,0 +1,502 @@
<?php
/*
* PHP QR Code encoder
*
* Main encoder classes.
*
* Based on libqrencode C library distributed under LGPL 2.1
* Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi <fukuchi@megaui.net>
*
* PHP QR Code is distributed under LGPL 3
* Copyright (C) 2010 Dominik Dzienia <deltalab at poczta dot fm>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class QRrsblock {
public $dataLength;
public $data = array();
public $eccLength;
public $ecc = array();
public function __construct($dl, $data, $el, &$ecc, QRrsItem $rs)
{
$rs->encode_rs_char($data, $ecc);
$this->dataLength = $dl;
$this->data = $data;
$this->eccLength = $el;
$this->ecc = $ecc;
}
};
//##########################################################################
class QRrawcode {
public $version;
public $datacode = array();
public $ecccode = array();
public $blocks;
public $rsblocks = array(); //of RSblock
public $count;
public $dataLength;
public $eccLength;
public $b1;
//----------------------------------------------------------------------
public function __construct(QRinput $input)
{
$spec = array(0,0,0,0,0);
$this->datacode = $input->getByteStream();
if(is_null($this->datacode)) {
throw new Exception('null imput string');
}
QRspec::getEccSpec($input->getVersion(), $input->getErrorCorrectionLevel(), $spec);
$this->version = $input->getVersion();
$this->b1 = QRspec::rsBlockNum1($spec);
$this->dataLength = QRspec::rsDataLength($spec);
$this->eccLength = QRspec::rsEccLength($spec);
$this->ecccode = array_fill(0, $this->eccLength, 0);
$this->blocks = QRspec::rsBlockNum($spec);
$ret = $this->init($spec);
if($ret < 0) {
throw new Exception('block alloc error');
return null;
}
$this->count = 0;
}
//----------------------------------------------------------------------
public function init(array $spec)
{
$dl = QRspec::rsDataCodes1($spec);
$el = QRspec::rsEccCodes1($spec);
$rs = QRrs::init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el);
$blockNo = 0;
$dataPos = 0;
$eccPos = 0;
for($i=0; $i<QRspec::rsBlockNum1($spec); $i++) {
$ecc = array_slice($this->ecccode,$eccPos);
$this->rsblocks[$blockNo] = new QRrsblock($dl, array_slice($this->datacode, $dataPos), $el, $ecc, $rs);
$this->ecccode = array_merge(array_slice($this->ecccode,0, $eccPos), $ecc);
$dataPos += $dl;
$eccPos += $el;
$blockNo++;
}
if(QRspec::rsBlockNum2($spec) == 0)
return 0;
$dl = QRspec::rsDataCodes2($spec);
$el = QRspec::rsEccCodes2($spec);
$rs = QRrs::init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el);
if($rs == NULL) return -1;
for($i=0; $i<QRspec::rsBlockNum2($spec); $i++) {
$ecc = array_slice($this->ecccode,$eccPos);
$this->rsblocks[$blockNo] = new QRrsblock($dl, array_slice($this->datacode, $dataPos), $el, $ecc, $rs);
$this->ecccode = array_merge(array_slice($this->ecccode,0, $eccPos), $ecc);
$dataPos += $dl;
$eccPos += $el;
$blockNo++;
}
return 0;
}
//----------------------------------------------------------------------
public function getCode()
{
$ret;
if($this->count < $this->dataLength) {
$row = $this->count % $this->blocks;
$col = $this->count / $this->blocks;
if($col >= $this->rsblocks[0]->dataLength) {
$row += $this->b1;
}
$ret = $this->rsblocks[$row]->data[$col];
} else if($this->count < $this->dataLength + $this->eccLength) {
$row = ($this->count - $this->dataLength) % $this->blocks;
$col = ($this->count - $this->dataLength) / $this->blocks;
$ret = $this->rsblocks[$row]->ecc[$col];
} else {
return 0;
}
$this->count++;
return $ret;
}
}
//##########################################################################
class QRcode {
public $version;
public $width;
public $data;
//----------------------------------------------------------------------
public function encodeMask(QRinput $input, $mask)
{
if($input->getVersion() < 0 || $input->getVersion() > QRSPEC_VERSION_MAX) {
throw new Exception('wrong version');
}
if($input->getErrorCorrectionLevel() > QR_ECLEVEL_H) {
throw new Exception('wrong level');
}
$raw = new QRrawcode($input);
QRtools::markTime('after_raw');
$version = $raw->version;
$width = QRspec::getWidth($version);
$frame = QRspec::newFrame($version);
$filler = new FrameFiller($width, $frame);
if(is_null($filler)) {
return NULL;
}
// inteleaved data and ecc codes
for($i=0; $i<$raw->dataLength + $raw->eccLength; $i++) {
$code = $raw->getCode();
$bit = 0x80;
for($j=0; $j<8; $j++) {
$addr = $filler->next();
$filler->setFrameAt($addr, 0x02 | (($bit & $code) != 0));
$bit = $bit >> 1;
}
}
QRtools::markTime('after_filler');
unset($raw);
// remainder bits
$j = QRspec::getRemainder($version);
for($i=0; $i<$j; $i++) {
$addr = $filler->next();
$filler->setFrameAt($addr, 0x02);
}
$frame = $filler->frame;
unset($filler);
// masking
$maskObj = new QRmask();
if($mask < 0) {
if (QR_FIND_BEST_MASK) {
$masked = $maskObj->mask($width, $frame, $input->getErrorCorrectionLevel());
} else {
$masked = $maskObj->makeMask($width, $frame, (intval(QR_DEFAULT_MASK) % 8), $input->getErrorCorrectionLevel());
}
} else {
$masked = $maskObj->makeMask($width, $frame, $mask, $input->getErrorCorrectionLevel());
}
if($masked == NULL) {
return NULL;
}
QRtools::markTime('after_mask');
$this->version = $version;
$this->width = $width;
$this->data = $masked;
return $this;
}
//----------------------------------------------------------------------
public function encodeInput(QRinput $input)
{
return $this->encodeMask($input, -1);
}
//----------------------------------------------------------------------
public function encodeString8bit($string, $version, $level)
{
if(string == NULL) {
throw new Exception('empty string!');
return NULL;
}
$input = new QRinput($version, $level);
if($input == NULL) return NULL;
$ret = $input->append($input, QR_MODE_8, strlen($string), str_split($string));
if($ret < 0) {
unset($input);
return NULL;
}
return $this->encodeInput($input);
}
//----------------------------------------------------------------------
public function encodeString($string, $version, $level, $hint, $casesensitive)
{
if($hint != QR_MODE_8 && $hint != QR_MODE_KANJI) {
throw new Exception('bad hint');
return NULL;
}
$input = new QRinput($version, $level);
if($input == NULL) return NULL;
$ret = QRsplit::splitStringToQRinput($string, $input, $hint, $casesensitive);
if($ret < 0) {
return NULL;
}
return $this->encodeInput($input);
}
//----------------------------------------------------------------------
public static function png($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4, $saveandprint=false)
{
$enc = QRencode::factory($level, $size, $margin);
return $enc->encodePNG($text, $outfile, $saveandprint=false);
}
//----------------------------------------------------------------------
public static function text($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4)
{
$enc = QRencode::factory($level, $size, $margin);
return $enc->encode($text, $outfile);
}
//----------------------------------------------------------------------
public static function raw($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4)
{
$enc = QRencode::factory($level, $size, $margin);
return $enc->encodeRAW($text, $outfile);
}
}
//##########################################################################
class FrameFiller {
public $width;
public $frame;
public $x;
public $y;
public $dir;
public $bit;
//----------------------------------------------------------------------
public function __construct($width, &$frame)
{
$this->width = $width;
$this->frame = $frame;
$this->x = $width - 1;
$this->y = $width - 1;
$this->dir = -1;
$this->bit = -1;
}
//----------------------------------------------------------------------
public function setFrameAt($at, $val)
{
$this->frame[$at['y']][$at['x']] = chr($val);
}
//----------------------------------------------------------------------
public function getFrameAt($at)
{
return ord($this->frame[$at['y']][$at['x']]);
}
//----------------------------------------------------------------------
public function next()
{
do {
if($this->bit == -1) {
$this->bit = 0;
return array('x'=>$this->x, 'y'=>$this->y);
}
$x = $this->x;
$y = $this->y;
$w = $this->width;
if($this->bit == 0) {
$x--;
$this->bit++;
} else {
$x++;
$y += $this->dir;
$this->bit--;
}
if($this->dir < 0) {
if($y < 0) {
$y = 0;
$x -= 2;
$this->dir = 1;
if($x == 6) {
$x--;
$y = 9;
}
}
} else {
if($y == $w) {
$y = $w - 1;
$x -= 2;
$this->dir = -1;
if($x == 6) {
$x--;
$y -= 8;
}
}
}
if($x < 0 || $y < 0) return null;
$this->x = $x;
$this->y = $y;
} while(ord($this->frame[$y][$x]) & 0x80);
return array('x'=>$x, 'y'=>$y);
}
} ;
//##########################################################################
class QRencode {
public $casesensitive = true;
public $eightbit = false;
public $version = 0;
public $size = 3;
public $margin = 4;
public $structured = 0; // not supported yet
public $level = QR_ECLEVEL_L;
public $hint = QR_MODE_8;
//----------------------------------------------------------------------
public static function factory($level = QR_ECLEVEL_L, $size = 3, $margin = 4)
{
$enc = new QRencode();
$enc->size = $size;
$enc->margin = $margin;
switch ($level.'') {
case '0':
case '1':
case '2':
case '3':
$enc->level = $level;
break;
case 'l':
case 'L':
$enc->level = QR_ECLEVEL_L;
break;
case 'm':
case 'M':
$enc->level = QR_ECLEVEL_M;
break;
case 'q':
case 'Q':
$enc->level = QR_ECLEVEL_Q;
break;
case 'h':
case 'H':
$enc->level = QR_ECLEVEL_H;
break;
}
return $enc;
}
//----------------------------------------------------------------------
public function encodeRAW($intext, $outfile = false)
{
$code = new QRcode();
if($this->eightbit) {
$code->encodeString8bit($intext, $this->version, $this->level);
} else {
$code->encodeString($intext, $this->version, $this->level, $this->hint, $this->casesensitive);
}
return $code->data;
}
//----------------------------------------------------------------------
public function encode($intext, $outfile = false)
{
$code = new QRcode();
if($this->eightbit) {
$code->encodeString8bit($intext, $this->version, $this->level);
} else {
$code->encodeString($intext, $this->version, $this->level, $this->hint, $this->casesensitive);
}
QRtools::markTime('after_encode');
if ($outfile!== false) {
file_put_contents($outfile, join("\n", QRtools::binarize($code->data)));
} else {
return QRtools::binarize($code->data);
}
}
//----------------------------------------------------------------------
public function encodePNG($intext, $outfile = false,$saveandprint=false)
{
try {
ob_start();
$tab = $this->encode($intext);
$err = ob_get_contents();
ob_end_clean();
if ($err != '')
QRtools::log($outfile, $err);
$maxSize = (int)(QR_PNG_MAXIMUM_SIZE / (count($tab)+2*$this->margin));
QRimage::png($tab, $outfile, min(max(1, $this->size), $maxSize), $this->margin,$saveandprint);
} catch (Exception $e) {
QRtools::log($outfile, $e->getMessage());
}
}
}

View file

@ -0,0 +1,95 @@
<?php
/*
* PHP QR Code encoder
*
* Image output of code using GD2
*
* PHP QR Code is distributed under LGPL 3
* Copyright (C) 2010 Dominik Dzienia <deltalab at poczta dot fm>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
define('QR_IMAGE', true);
class QRimage {
//----------------------------------------------------------------------
public static function png($frame, $filename = false, $pixelPerPoint = 4, $outerFrame = 4,$saveandprint=FALSE)
{
$image = self::image($frame, $pixelPerPoint, $outerFrame);
if ($filename === false) {
Header("Content-type: image/png");
ImagePng($image);
} else {
if($saveandprint===TRUE){
ImagePng($image, $filename);
header("Content-type: image/png");
ImagePng($image);
}else{
ImagePng($image, $filename);
}
}
ImageDestroy($image);
}
//----------------------------------------------------------------------
public static function jpg($frame, $filename = false, $pixelPerPoint = 8, $outerFrame = 4, $q = 85)
{
$image = self::image($frame, $pixelPerPoint, $outerFrame);
if ($filename === false) {
Header("Content-type: image/jpeg");
ImageJpeg($image, null, $q);
} else {
ImageJpeg($image, $filename, $q);
}
ImageDestroy($image);
}
//----------------------------------------------------------------------
private static function image($frame, $pixelPerPoint = 4, $outerFrame = 4)
{
$h = count($frame);
$w = strlen($frame[0]);
$imgW = $w + 2*$outerFrame;
$imgH = $h + 2*$outerFrame;
$base_image =ImageCreate($imgW, $imgH);
$col[0] = ImageColorAllocate($base_image,255,255,255);
$col[1] = ImageColorAllocate($base_image,0,0,0);
imagefill($base_image, 0, 0, $col[0]);
for($y=0; $y<$h; $y++) {
for($x=0; $x<$w; $x++) {
if ($frame[$y][$x] == '1') {
ImageSetPixel($base_image,$x+$outerFrame,$y+$outerFrame,$col[1]);
}
}
}
$target_image =ImageCreate($imgW * $pixelPerPoint, $imgH * $pixelPerPoint);
ImageCopyResized($target_image, $base_image, 0, 0, 0, 0, $imgW * $pixelPerPoint, $imgH * $pixelPerPoint, $imgW, $imgH);
ImageDestroy($base_image);
return $target_image;
}
}

View file

@ -0,0 +1,729 @@
<?php
/*
* PHP QR Code encoder
*
* Input encoding class
*
* Based on libqrencode C library distributed under LGPL 2.1
* Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi <fukuchi@megaui.net>
*
* PHP QR Code is distributed under LGPL 3
* Copyright (C) 2010 Dominik Dzienia <deltalab at poczta dot fm>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
define('STRUCTURE_HEADER_BITS', 20);
define('MAX_STRUCTURED_SYMBOLS', 16);
class QRinputItem {
public $mode;
public $size;
public $data;
public $bstream;
public function __construct($mode, $size, $data, $bstream = null)
{
$setData = array_slice($data, 0, $size);
if (count($setData) < $size) {
$setData = array_merge($setData, array_fill(0,$size-count($setData),0));
}
if(!QRinput::check($mode, $size, $setData)) {
throw new Exception('Error m:'.$mode.',s:'.$size.',d:'.join(',',$setData));
return null;
}
$this->mode = $mode;
$this->size = $size;
$this->data = $setData;
$this->bstream = $bstream;
}
//----------------------------------------------------------------------
public function encodeModeNum($version)
{
try {
$words = (int)($this->size / 3);
$bs = new QRbitstream();
$val = 0x1;
$bs->appendNum(4, $val);
$bs->appendNum(QRspec::lengthIndicator(QR_MODE_NUM, $version), $this->size);
for($i=0; $i<$words; $i++) {
$val = (ord($this->data[$i*3 ]) - ord('0')) * 100;
$val += (ord($this->data[$i*3+1]) - ord('0')) * 10;
$val += (ord($this->data[$i*3+2]) - ord('0'));
$bs->appendNum(10, $val);
}
if($this->size - $words * 3 == 1) {
$val = ord($this->data[$words*3]) - ord('0');
$bs->appendNum(4, $val);
} else if($this->size - $words * 3 == 2) {
$val = (ord($this->data[$words*3 ]) - ord('0')) * 10;
$val += (ord($this->data[$words*3+1]) - ord('0'));
$bs->appendNum(7, $val);
}
$this->bstream = $bs;
return 0;
} catch (Exception $e) {
return -1;
}
}
//----------------------------------------------------------------------
public function encodeModeAn($version)
{
try {
$words = (int)($this->size / 2);
$bs = new QRbitstream();
$bs->appendNum(4, 0x02);
$bs->appendNum(QRspec::lengthIndicator(QR_MODE_AN, $version), $this->size);
for($i=0; $i<$words; $i++) {
$val = (int)QRinput::lookAnTable(ord($this->data[$i*2 ])) * 45;
$val += (int)QRinput::lookAnTable(ord($this->data[$i*2+1]));
$bs->appendNum(11, $val);
}
if($this->size & 1) {
$val = QRinput::lookAnTable(ord($this->data[$words * 2]));
$bs->appendNum(6, $val);
}
$this->bstream = $bs;
return 0;
} catch (Exception $e) {
return -1;
}
}
//----------------------------------------------------------------------
public function encodeMode8($version)
{
try {
$bs = new QRbitstream();
$bs->appendNum(4, 0x4);
$bs->appendNum(QRspec::lengthIndicator(QR_MODE_8, $version), $this->size);
for($i=0; $i<$this->size; $i++) {
$bs->appendNum(8, ord($this->data[$i]));
}
$this->bstream = $bs;
return 0;
} catch (Exception $e) {
return -1;
}
}
//----------------------------------------------------------------------
public function encodeModeKanji($version)
{
try {
$bs = new QRbitrtream();
$bs->appendNum(4, 0x8);
$bs->appendNum(QRspec::lengthIndicator(QR_MODE_KANJI, $version), (int)($this->size / 2));
for($i=0; $i<$this->size; $i+=2) {
$val = (ord($this->data[$i]) << 8) | ord($this->data[$i+1]);
if($val <= 0x9ffc) {
$val -= 0x8140;
} else {
$val -= 0xc140;
}
$h = ($val >> 8) * 0xc0;
$val = ($val & 0xff) + $h;
$bs->appendNum(13, $val);
}
$this->bstream = $bs;
return 0;
} catch (Exception $e) {
return -1;
}
}
//----------------------------------------------------------------------
public function encodeModeStructure()
{
try {
$bs = new QRbitstream();
$bs->appendNum(4, 0x03);
$bs->appendNum(4, ord($this->data[1]) - 1);
$bs->appendNum(4, ord($this->data[0]) - 1);
$bs->appendNum(8, ord($this->data[2]));
$this->bstream = $bs;
return 0;
} catch (Exception $e) {
return -1;
}
}
//----------------------------------------------------------------------
public function estimateBitStreamSizeOfEntry($version)
{
$bits = 0;
if($version == 0)
$version = 1;
switch($this->mode) {
case QR_MODE_NUM: $bits = QRinput::estimateBitsModeNum($this->size); break;
case QR_MODE_AN: $bits = QRinput::estimateBitsModeAn($this->size); break;
case QR_MODE_8: $bits = QRinput::estimateBitsMode8($this->size); break;
case QR_MODE_KANJI: $bits = QRinput::estimateBitsModeKanji($this->size);break;
case QR_MODE_STRUCTURE: return STRUCTURE_HEADER_BITS;
default:
return 0;
}
$l = QRspec::lengthIndicator($this->mode, $version);
$m = 1 << $l;
$num = (int)(($this->size + $m - 1) / $m);
$bits += $num * (4 + $l);
return $bits;
}
//----------------------------------------------------------------------
public function encodeBitStream($version)
{
try {
unset($this->bstream);
$words = QRspec::maximumWords($this->mode, $version);
if($this->size > $words) {
$st1 = new QRinputItem($this->mode, $words, $this->data);
$st2 = new QRinputItem($this->mode, $this->size - $words, array_slice($this->data, $words));
$st1->encodeBitStream($version);
$st2->encodeBitStream($version);
$this->bstream = new QRbitstream();
$this->bstream->append($st1->bstream);
$this->bstream->append($st2->bstream);
unset($st1);
unset($st2);
} else {
$ret = 0;
switch($this->mode) {
case QR_MODE_NUM: $ret = $this->encodeModeNum($version); break;
case QR_MODE_AN: $ret = $this->encodeModeAn($version); break;
case QR_MODE_8: $ret = $this->encodeMode8($version); break;
case QR_MODE_KANJI: $ret = $this->encodeModeKanji($version);break;
case QR_MODE_STRUCTURE: $ret = $this->encodeModeStructure(); break;
default:
break;
}
if($ret < 0)
return -1;
}
return $this->bstream->size();
} catch (Exception $e) {
return -1;
}
}
};
//##########################################################################
class QRinput {
public $items;
private $version;
private $level;
//----------------------------------------------------------------------
public function __construct($version = 0, $level = QR_ECLEVEL_L)
{
if ($version < 0 || $version > QRSPEC_VERSION_MAX || $level > QR_ECLEVEL_H) {
throw new Exception('Invalid version no');
return NULL;
}
$this->version = $version;
$this->level = $level;
}
//----------------------------------------------------------------------
public function getVersion()
{
return $this->version;
}
//----------------------------------------------------------------------
public function setVersion($version)
{
if($version < 0 || $version > QRSPEC_VERSION_MAX) {
throw new Exception('Invalid version no');
return -1;
}
$this->version = $version;
return 0;
}
//----------------------------------------------------------------------
public function getErrorCorrectionLevel()
{
return $this->level;
}
//----------------------------------------------------------------------
public function setErrorCorrectionLevel($level)
{
if($level > QR_ECLEVEL_H) {
throw new Exception('Invalid ECLEVEL');
return -1;
}
$this->level = $level;
return 0;
}
//----------------------------------------------------------------------
public function appendEntry(QRinputItem $entry)
{
$this->items[] = $entry;
}
//----------------------------------------------------------------------
public function append($mode, $size, $data)
{
try {
$entry = new QRinputItem($mode, $size, $data);
$this->items[] = $entry;
return 0;
} catch (Exception $e) {
return -1;
}
}
//----------------------------------------------------------------------
public function insertStructuredAppendHeader($size, $index, $parity)
{
if( $size > MAX_STRUCTURED_SYMBOLS ) {
throw new Exception('insertStructuredAppendHeader wrong size');
}
if( $index <= 0 || $index > MAX_STRUCTURED_SYMBOLS ) {
throw new Exception('insertStructuredAppendHeader wrong index');
}
$buf = array($size, $index, $parity);
try {
$entry = new QRinputItem(QR_MODE_STRUCTURE, 3, buf);
array_unshift($this->items, $entry);
return 0;
} catch (Exception $e) {
return -1;
}
}
//----------------------------------------------------------------------
public function calcParity()
{
$parity = 0;
foreach($this->items as $item) {
if($item->mode != QR_MODE_STRUCTURE) {
for($i=$item->size-1; $i>=0; $i--) {
$parity ^= $item->data[$i];
}
}
}
return $parity;
}
//----------------------------------------------------------------------
public static function checkModeNum($size, $data)
{
for($i=0; $i<$size; $i++) {
if((ord($data[$i]) < ord('0')) || (ord($data[$i]) > ord('9'))){
return false;
}
}
return true;
}
//----------------------------------------------------------------------
public static function estimateBitsModeNum($size)
{
$w = (int)$size / 3;
$bits = $w * 10;
switch($size - $w * 3) {
case 1:
$bits += 4;
break;
case 2:
$bits += 7;
break;
default:
break;
}
return $bits;
}
//----------------------------------------------------------------------
public static $anTable = array(
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1,
-1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
);
//----------------------------------------------------------------------
public static function lookAnTable($c)
{
return (($c > 127)?-1:self::$anTable[$c]);
}
//----------------------------------------------------------------------
public static function checkModeAn($size, $data)
{
for($i=0; $i<$size; $i++) {
if (self::lookAnTable(ord($data[$i])) == -1) {
return false;
}
}
return true;
}
//----------------------------------------------------------------------
public static function estimateBitsModeAn($size)
{
$w = (int)($size / 2);
$bits = $w * 11;
if($size & 1) {
$bits += 6;
}
return $bits;
}
//----------------------------------------------------------------------
public static function estimateBitsMode8($size)
{
return $size * 8;
}
//----------------------------------------------------------------------
public function estimateBitsModeKanji($size)
{
return (int)(($size / 2) * 13);
}
//----------------------------------------------------------------------
public static function checkModeKanji($size, $data)
{
if($size & 1)
return false;
for($i=0; $i<$size; $i+=2) {
$val = (ord($data[$i]) << 8) | ord($data[$i+1]);
if( $val < 0x8140
|| ($val > 0x9ffc && $val < 0xe040)
|| $val > 0xebbf) {
return false;
}
}
return true;
}
/***********************************************************************
* Validation
**********************************************************************/
public static function check($mode, $size, $data)
{
if($size <= 0)
return false;
switch($mode) {
case QR_MODE_NUM: return self::checkModeNum($size, $data); break;
case QR_MODE_AN: return self::checkModeAn($size, $data); break;
case QR_MODE_KANJI: return self::checkModeKanji($size, $data); break;
case QR_MODE_8: return true; break;
case QR_MODE_STRUCTURE: return true; break;
default:
break;
}
return false;
}
//----------------------------------------------------------------------
public function estimateBitStreamSize($version)
{
$bits = 0;
foreach($this->items as $item) {
$bits += $item->estimateBitStreamSizeOfEntry($version);
}
return $bits;
}
//----------------------------------------------------------------------
public function estimateVersion()
{
$version = 0;
$prev = 0;
do {
$prev = $version;
$bits = $this->estimateBitStreamSize($prev);
$version = QRspec::getMinimumVersion((int)(($bits + 7) / 8), $this->level);
if ($version < 0) {
return -1;
}
} while ($version > $prev);
return $version;
}
//----------------------------------------------------------------------
public static function lengthOfCode($mode, $version, $bits)
{
$payload = $bits - 4 - QRspec::lengthIndicator($mode, $version);
switch($mode) {
case QR_MODE_NUM:
$chunks = (int)($payload / 10);
$remain = $payload - $chunks * 10;
$size = $chunks * 3;
if($remain >= 7) {
$size += 2;
} else if($remain >= 4) {
$size += 1;
}
break;
case QR_MODE_AN:
$chunks = (int)($payload / 11);
$remain = $payload - $chunks * 11;
$size = $chunks * 2;
if($remain >= 6)
$size++;
break;
case QR_MODE_8:
$size = (int)($payload / 8);
break;
case QR_MODE_KANJI:
$size = (int)(($payload / 13) * 2);
break;
case QR_MODE_STRUCTURE:
$size = (int)($payload / 8);
break;
default:
$size = 0;
break;
}
$maxsize = QRspec::maximumWords($mode, $version);
if($size < 0) $size = 0;
if($size > $maxsize) $size = $maxsize;
return $size;
}
//----------------------------------------------------------------------
public function createBitStream()
{
$total = 0;
foreach($this->items as $item) {
$bits = $item->encodeBitStream($this->version);
if($bits < 0)
return -1;
$total += $bits;
}
return $total;
}
//----------------------------------------------------------------------
public function convertData()
{
$ver = $this->estimateVersion();
if($ver > $this->getVersion()) {
$this->setVersion($ver);
}
for(;;) {
$bits = $this->createBitStream();
if($bits < 0)
return -1;
$ver = QRspec::getMinimumVersion((int)(($bits + 7) / 8), $this->level);
if($ver < 0) {
throw new Exception('WRONG VERSION');
return -1;
} else if($ver > $this->getVersion()) {
$this->setVersion($ver);
} else {
break;
}
}
return 0;
}
//----------------------------------------------------------------------
public function appendPaddingBit(&$bstream)
{
$bits = $bstream->size();
$maxwords = QRspec::getDataLength($this->version, $this->level);
$maxbits = $maxwords * 8;
if ($maxbits == $bits) {
return 0;
}
if ($maxbits - $bits < 5) {
return $bstream->appendNum($maxbits - $bits, 0);
}
$bits += 4;
$words = (int)(($bits + 7) / 8);
$padding = new QRbitstream();
$ret = $padding->appendNum($words * 8 - $bits + 4, 0);
if($ret < 0)
return $ret;
$padlen = $maxwords - $words;
if($padlen > 0) {
$padbuf = array();
for($i=0; $i<$padlen; $i++) {
$padbuf[$i] = ($i&1)?0x11:0xec;
}
$ret = $padding->appendBytes($padlen, $padbuf);
if($ret < 0)
return $ret;
}
$ret = $bstream->append($padding);
return $ret;
}
//----------------------------------------------------------------------
public function mergeBitStream()
{
if($this->convertData() < 0) {
return null;
}
$bstream = new QRbitstream();
foreach($this->items as $item) {
$ret = $bstream->append($item->bstream);
if($ret < 0) {
return null;
}
}
return $bstream;
}
//----------------------------------------------------------------------
public function getBitStream()
{
$bstream = $this->mergeBitStream();
if($bstream == null) {
return null;
}
$ret = $this->appendPaddingBit($bstream);
if($ret < 0) {
return null;
}
return $bstream;
}
//----------------------------------------------------------------------
public function getByteStream()
{
$bstream = $this->getBitStream();
if($bstream == null) {
return null;
}
return $bstream->toByte();
}
}

View file

@ -0,0 +1,43 @@
<?php
/*
* PHP QR Code encoder
*
* Root library file, prepares environment and includes dependencies
*
* Based on libqrencode C library distributed under LGPL 2.1
* Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi <fukuchi@megaui.net>
*
* PHP QR Code is distributed under LGPL 3
* Copyright (C) 2010 Dominik Dzienia <deltalab at poczta dot fm>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
$QR_BASEDIR = dirname(__FILE__).DIRECTORY_SEPARATOR;
// Required libs
include $QR_BASEDIR."qrconst.php";
include $QR_BASEDIR."qrconfig.php";
include $QR_BASEDIR."qrtools.php";
include $QR_BASEDIR."qrspec.php";
include $QR_BASEDIR."qrimage.php";
include $QR_BASEDIR."qrinput.php";
include $QR_BASEDIR."qrbitstream.php";
include $QR_BASEDIR."qrsplit.php";
include $QR_BASEDIR."qrrscode.php";
include $QR_BASEDIR."qrmask.php";
include $QR_BASEDIR."qrencode.php";

View file

@ -0,0 +1,328 @@
<?php
/*
* PHP QR Code encoder
*
* Masking
*
* Based on libqrencode C library distributed under LGPL 2.1
* Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi <fukuchi@megaui.net>
*
* PHP QR Code is distributed under LGPL 3
* Copyright (C) 2010 Dominik Dzienia <deltalab at poczta dot fm>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
define('N1', 3);
define('N2', 3);
define('N3', 40);
define('N4', 10);
class QRmask {
public $runLength = array();
//----------------------------------------------------------------------
public function __construct()
{
$this->runLength = array_fill(0, QRSPEC_WIDTH_MAX + 1, 0);
}
//----------------------------------------------------------------------
public function writeFormatInformation($width, &$frame, $mask, $level)
{
$blacks = 0;
$format = QRspec::getFormatInfo($mask, $level);
for($i=0; $i<8; $i++) {
if($format & 1) {
$blacks += 2;
$v = 0x85;
} else {
$v = 0x84;
}
$frame[8][$width - 1 - $i] = chr($v);
if($i < 6) {
$frame[$i][8] = chr($v);
} else {
$frame[$i + 1][8] = chr($v);
}
$format = $format >> 1;
}
for($i=0; $i<7; $i++) {
if($format & 1) {
$blacks += 2;
$v = 0x85;
} else {
$v = 0x84;
}
$frame[$width - 7 + $i][8] = chr($v);
if($i == 0) {
$frame[8][7] = chr($v);
} else {
$frame[8][6 - $i] = chr($v);
}
$format = $format >> 1;
}
return $blacks;
}
//----------------------------------------------------------------------
public function mask0($x, $y) { return ($x+$y)&1; }
public function mask1($x, $y) { return ($y&1); }
public function mask2($x, $y) { return ($x%3); }
public function mask3($x, $y) { return ($x+$y)%3; }
public function mask4($x, $y) { return (((int)($y/2))+((int)($x/3)))&1; }
public function mask5($x, $y) { return (($x*$y)&1)+($x*$y)%3; }
public function mask6($x, $y) { return ((($x*$y)&1)+($x*$y)%3)&1; }
public function mask7($x, $y) { return ((($x*$y)%3)+(($x+$y)&1))&1; }
//----------------------------------------------------------------------
private function generateMaskNo($maskNo, $width, $frame)
{
$bitMask = array_fill(0, $width, array_fill(0, $width, 0));
for($y=0; $y<$width; $y++) {
for($x=0; $x<$width; $x++) {
if(ord($frame[$y][$x]) & 0x80) {
$bitMask[$y][$x] = 0;
} else {
$maskFunc = call_user_func(array($this, 'mask'.$maskNo), $x, $y);
$bitMask[$y][$x] = ($maskFunc == 0)?1:0;
}
}
}
return $bitMask;
}
//----------------------------------------------------------------------
public static function serial($bitFrame)
{
$codeArr = array();
foreach ($bitFrame as $line)
$codeArr[] = join('', $line);
return gzcompress(join("\n", $codeArr), 9);
}
//----------------------------------------------------------------------
public static function unserial($code)
{
$codeArr = array();
$codeLines = explode("\n", gzuncompress($code));
foreach ($codeLines as $line)
$codeArr[] = str_split($line);
return $codeArr;
}
//----------------------------------------------------------------------
public function makeMaskNo($maskNo, $width, $s, &$d, $maskGenOnly = false)
{
$b = 0;
$bitMask = array();
$fileName = QR_CACHE_DIR.'mask_'.$maskNo.DIRECTORY_SEPARATOR.'mask_'.$width.'_'.$maskNo.'.dat';
if (QR_CACHEABLE) {
if (file_exists($fileName)) {
$bitMask = self::unserial(file_get_contents($fileName));
} else {
$bitMask = $this->generateMaskNo($maskNo, $width, $s, $d);
if (!file_exists(QR_CACHE_DIR.'mask_'.$maskNo))
mkdir(QR_CACHE_DIR.'mask_'.$maskNo);
file_put_contents($fileName, self::serial($bitMask));
}
} else {
$bitMask = $this->generateMaskNo($maskNo, $width, $s, $d);
}
if ($maskGenOnly)
return;
$d = $s;
for($y=0; $y<$width; $y++) {
for($x=0; $x<$width; $x++) {
if($bitMask[$y][$x] == 1) {
$d[$y][$x] = chr(ord($s[$y][$x]) ^ (int)$bitMask[$y][$x]);
}
$b += (int)(ord($d[$y][$x]) & 1);
}
}
return $b;
}
//----------------------------------------------------------------------
public function makeMask($width, $frame, $maskNo, $level)
{