Compare commits
741 Commits
Author | SHA1 | Date |
---|---|---|
Timothy Warren | 77ffd46cd8 | |
Timothy Warren | 59ba0f49c7 | |
Timothy Warren | 44ec41b0f7 | |
Timothy Warren | fec671e3cd | |
Timothy Warren | 848f667626 | |
Timothy Warren | 361ebcbbe4 | |
Timothy Warren | 6f2a59ae95 | |
Timothy Warren | d10e930a6b | |
Timothy Warren | c6b74e2775 | |
Timothy Warren | f3b42ae056 | |
Timothy Warren | 9140ebaa19 | |
Timothy Warren | 27160bda9a | |
Timothy Warren | 3fae7fe9d6 | |
Timothy Warren | b5ec89de34 | |
Timothy Warren | 8eca9c9d04 | |
Timothy Warren | dfce7f649e | |
Timothy Warren | b4a5e8ce77 | |
Timothy Warren | 1f2accf4ec | |
Timothy Warren | 6e950613e6 | |
Timothy Warren | 9214b0c87b | |
Timothy Warren | 73488d8244 | |
Timothy Warren | c93629dea2 | |
Timothy Warren | 5bf8277376 | |
Timothy Warren | 51bf392d1b | |
Timothy Warren | dd6e99877a | |
Timothy Warren | 4de92a3591 | |
Timothy Warren | 2943f716b9 | |
Timothy Warren | 62781355b1 | |
Timothy Warren | 9e6ce8171a | |
Timothy Warren | aa1e6675c2 | |
Timothy Warren | 9f585bf1b4 | |
Timothy Warren | ca03e96edd | |
Timothy Warren | 76b23c7646 | |
Timothy Warren | 82c8fa8661 | |
Timothy Warren | 74ab8bd8b9 | |
Timothy Warren | 62e7cc7bed | |
Timothy Warren | 1d9537126b | |
Timothy Warren | 2c915188a8 | |
Timothy Warren | 765fc9de42 | |
Timothy Warren | b944e1f250 | |
Timothy Warren | 92243189ee | |
Timothy Warren | 4c896349b9 | |
Timothy Warren | f3f2879c54 | |
Timothy Warren | b70ba1da6f | |
Timothy Warren | 28146ad909 | |
Timothy Warren | 0348d0db00 | |
Timothy Warren | 84ca0a9481 | |
Timothy Warren | aec9a2f2b8 | |
Timothy Warren | 42ec5faa4a | |
Timothy Warren | 1c3b478d49 | |
Timothy Warren | 5d752f6ee3 | |
Timothy Warren | 0503cad15f | |
Timothy Warren | 49dc661de1 | |
Timothy Warren | 59403b9cb5 | |
Timothy Warren | 4d26acea5b | |
Timothy Warren | a38c9712e6 | |
Timothy Warren | b871a4fac2 | |
Timothy Warren | aacf7ece65 | |
Timothy Warren | 826cb0c1cb | |
Timothy Warren | 94e61e35a8 | |
Timothy Warren | f09716b040 | |
Timothy Warren | 921febaeb4 | |
Timothy Warren | e3d6ac20ea | |
Timothy Warren | f3c85da8cc | |
Timothy Warren | 92c5b2baf7 | |
Timothy Warren | 9ad74ed887 | |
Timothy Warren | 27977a0c8a | |
Timothy Warren | 11475187fc | |
Timothy Warren | f88f1578a8 | |
Timothy Warren | b9e8ddfc9a | |
Timothy Warren | 99c94963e6 | |
Timothy Warren | 556e184ce5 | |
Timothy Warren | c4f759e5d8 | |
Timothy Warren | 61b7a799b9 | |
Timothy Warren | 38cd9c74d9 | |
Timothy Warren | 67e068f053 | |
Timothy Warren | 24edf55f44 | |
Timothy Warren | 6770c133fb | |
Timothy Warren | 7a4816d34d | |
Timothy Warren | d09908cb1d | |
Timothy Warren | cd2dcf2873 | |
Timothy Warren | c2d51b2b7e | |
Timothy Warren | 067c9b4035 | |
Timothy Warren | 3244db3438 | |
Timothy Warren | fa27abb954 | |
Timothy Warren | 96820a6418 | |
Timothy Warren | cf1c55782f | |
Timothy Warren | bd4cfaafe1 | |
Timothy Warren | 679c369427 | |
Timothy Warren | 0fa54d9f7f | |
Timothy Warren | 015929b48d | |
Timothy Warren | 2a6929c6ff | |
Timothy Warren | 50b65d66e1 | |
Timothy Warren | 14be365a16 | |
Timothy Warren | db686dbd8d | |
Timothy Warren | 16f62ceb8d | |
Timothy Warren | 28164f72da | |
Timothy Warren | f243dd4583 | |
Timothy Warren | fccc794528 | |
Timothy Warren | 12dfb491bc | |
Timothy Warren | 82520afa0e | |
Timothy Warren | 779d7263d0 | |
Timothy Warren | 762bdba724 | |
Timothy Warren | 592e9d2c86 | |
Timothy Warren | ef33664f6f | |
Timothy Warren | 0d84cdb1c1 | |
Timothy Warren | 562e88dc43 | |
Timothy Warren | 8100f6fd71 | |
Timothy Warren | 07cae83e15 | |
Timothy Warren | f7cfcbbced | |
Timothy Warren | ca6954936f | |
Timothy Warren | 4eb258bb2f | |
Timothy Warren | 54b4e11335 | |
Timothy Warren | aaafebec99 | |
Timothy Warren | 5258b215d4 | |
Timothy Warren | ee3f3e1743 | |
Timothy Warren | 5b4e1df740 | |
Timothy Warren | fec30b7e36 | |
Timothy Warren | 7a2bb1ba05 | |
Timothy Warren | bb9e7b8d49 | |
Timothy Warren | e4110f089e | |
Timothy Warren | 88b68b847c | |
Timothy Warren | b625f22d6a | |
Timothy Warren | f1a54d8782 | |
Timothy Warren | 616ae1ea82 | |
Timothy Warren | 0102a0b3ee | |
Timothy Warren | 789af166ae | |
Timothy Warren | 3098fef20c | |
Timothy Warren | 4d29b43123 | |
Timothy Warren | 5632c0c815 | |
Timothy Warren | 6f5db162a0 | |
Timothy Warren | dde6c328f4 | |
Timothy Warren | e3b4b9dd32 | |
Timothy Warren | 9821c17de3 | |
Timothy Warren | 2d3295757d | |
Timothy Warren | ede69b6099 | |
Timothy Warren | ca5bfafe88 | |
Timothy Warren | d8db517fa5 | |
Timothy Warren | 77f2ffa93f | |
Timothy Warren | 664a9ec14a | |
Timothy Warren | 4284c38e9c | |
Timothy Warren | b19f8965e0 | |
Timothy Warren | 0fefece3e3 | |
Timothy Warren | 5fe48dfd57 | |
Timothy Warren | 45b545d32d | |
Timothy Warren | 0cb09dc4b8 | |
Timothy Warren | 282ba45960 | |
Timothy Warren | 348fe6e724 | |
Timothy Warren | 153230580e | |
Timothy Warren | ca3fa85df3 | |
Timothy Warren | 1fa5695a9f | |
Timothy Warren | 807c701edd | |
Timothy Warren | 282022dbd2 | |
Timothy Warren | ba8663b22a | |
Timothy Warren | ce44761420 | |
Timothy Warren | ff97cc1cb2 | |
Timothy Warren | b3474ddff2 | |
Timothy Warren | 64a9f41a64 | |
Timothy Warren | 1ab47ca03a | |
Timothy Warren | 6df059fe75 | |
Timothy Warren | 79b8c09a9b | |
Timothy Warren | 24ea198dad | |
Timothy Warren | 7c7a2d0824 | |
Timothy Warren | 0ff848c614 | |
Timothy Warren | 787687abf8 | |
Timothy Warren | b4a843e699 | |
Timothy Warren | 1dc1370115 | |
Timothy Warren | 6f7d94641e | |
Timothy Warren | 3d51a81347 | |
Timothy Warren | 6e58844286 | |
Timothy Warren | 28e4f22d7c | |
Timothy Warren | 7a1967b404 | |
Timothy Warren | 3b3156e78a | |
Timothy Warren | d29945eb96 | |
Timothy Warren | f04cc7d1d5 | |
Timothy Warren | e50ce3fa5b | |
Timothy Warren | e0e72eeef8 | |
Timothy Warren | 204313abbf | |
Timothy Warren | c4332d0ccd | |
Timothy Warren | b078690fdf | |
Timothy Warren | bc98b977f4 | |
Timothy Warren | 116b4de204 | |
Timothy Warren | 1df419cde5 | |
Timothy Warren | 3c5bac98a1 | |
Timothy Warren | 98cabd32af | |
Timothy Warren | fa2d79c77e | |
Timothy Warren | 70832f8b63 | |
Timothy Warren | ad92e51258 | |
Timothy Warren | 79f6ae8db7 | |
Timothy Warren | e6b534078f | |
Timothy Warren | a6dc8caaa0 | |
Timothy Warren | 23a6241e2c | |
Timothy Warren | fe383249e4 | |
Timothy Warren | 322833ff13 | |
Timothy Warren | dc9d7ab4e1 | |
Timothy Warren | c67fbff9ed | |
Timothy Warren | 32a5ab6492 | |
Timothy Warren | 9f61123479 | |
Timothy Warren | 55cabc5840 | |
Timothy Warren | 0f705750e7 | |
Timothy Warren | 4a0792e4fe | |
Timothy Warren | f5d8d4f18a | |
Timothy Warren | 7a3ad6ebc6 | |
Timothy Warren | bd61bd734b | |
Timothy Warren | f205ba8cff | |
Timothy Warren | fb8db698a6 | |
Timothy Warren | d1987fc710 | |
Timothy Warren | 98283e27d8 | |
Timothy Warren | 19a032b874 | |
Timothy Warren | d3cbe06cb0 | |
Timothy Warren | 1634e98799 | |
Timothy Warren | 2bdefd1aa1 | |
Timothy Warren | 1ea3a59b6a | |
Timothy Warren | 815bf835d3 | |
Timothy Warren | b5c7d430f4 | |
Timothy Warren | 72e68e18ac | |
Timothy Warren | d08ffd1d17 | |
Timothy Warren | a6e63b07f0 | |
Timothy Warren | 7703187cd9 | |
Timothy Warren | 30062ab65d | |
Timothy Warren | a2f6805417 | |
Timothy Warren | d13ad92dd1 | |
Timothy Warren | f02a94b862 | |
Timothy Warren | cce0e714dc | |
Timothy Warren | 42117a1386 | |
Timothy Warren | b1cae947a7 | |
Timothy Warren | c76f23bffd | |
Timothy Warren | d51ee20abf | |
Timothy Warren | 40d3ebcc6f | |
Timothy Warren | 79c6f21a2f | |
Timothy Warren | 534079b6e7 | |
Timothy Warren | fab01c3e89 | |
Timothy Warren | c0d912a1c4 | |
Timothy Warren | 23552d62b1 | |
Timothy Warren | 4b248eb8cf | |
Timothy Warren | f9a667b20b | |
Timothy Warren | 0f94c0b479 | |
Timothy Warren | d798a057c7 | |
Timothy Warren | 2d19809ad3 | |
Timothy Warren | d632cc11e4 | |
Timothy Warren | 318c582fe9 | |
Timothy Warren | 26aab3eef6 | |
Timothy Warren | da2fa371e5 | |
Timothy Warren | e808f751e1 | |
Timothy Warren | 8bfc9fcc6e | |
Timothy Warren | 5ef0ccf9a7 | |
Timothy Warren | 90f81fdf7f | |
Timothy Warren | dd07a441b2 | |
Timothy Warren | 6caa031c86 | |
Timothy Warren | e632843bab | |
Timothy Warren | d8b985c993 | |
Timothy Warren | 510ae24dca | |
Timothy Warren | 06213df29f | |
Timothy Warren | c81e12bb89 | |
Timothy Warren | 54c544113b | |
Timothy Warren | e714599fad | |
Timothy Warren | 1df71121eb | |
Timothy Warren | d62710bdf8 | |
Timothy Warren | 029073a4ea | |
Timothy Warren | 1c06748232 | |
Timothy Warren | 2d9c5b3093 | |
Timothy Warren | 33099df6ea | |
Timothy Warren | 59446649f6 | |
Timothy Warren | 4bd62ce881 | |
Timothy Warren | e6cfe2b6e9 | |
Timothy Warren | 555de3d17b | |
Timothy Warren | ed4f9152d4 | |
Timothy Warren | 3f81068182 | |
Timothy Warren | e5e4323486 | |
Timothy Warren | 5357bfb122 | |
Timothy Warren | b444648a3d | |
Timothy Warren | e0516e4cc0 | |
Timothy Warren | f412aaad27 | |
Timothy Warren | 05b8136a1e | |
Timothy Warren | 853a349a4b | |
Timothy Warren | ea2b4fe148 | |
Timothy Warren | d435438b20 | |
Timothy Warren | 255895097a | |
Timothy Warren | 06a92a5a8e | |
Timothy Warren | 388c0a274d | |
Timothy Warren | d91665e3ae | |
Timothy Warren | 650ddc781f | |
Timothy Warren | 9f41603152 | |
Timothy Warren | 06bc655a59 | |
Timothy Warren | ca402bd826 | |
Timothy Warren | 82c86b7b47 | |
Timothy Warren | 8223786bb5 | |
Timothy Warren | aa901550a1 | |
Timothy Warren | f8f499520e | |
Timothy Warren | ffd034220c | |
Timothy Warren | 67819156ed | |
Timothy Warren | e7ef11c423 | |
Timothy Warren | a767c75014 | |
Timothy Warren | 9dfc99f49b | |
Timothy Warren | 88c65dd0df | |
Timothy Warren | 528deae789 | |
Timothy Warren | be252836be | |
Timothy Warren | 3bb4f32bdb | |
Timothy Warren | 08a882bbb6 | |
Timothy Warren | a892d875fd | |
Timothy Warren | 4f528ca2c8 | |
Timothy Warren | 754a5e7b98 | |
Timothy Warren | 161c2b3bc1 | |
Timothy Warren | e740b9e314 | |
Timothy Warren | 493ac3ca03 | |
Timothy Warren | f59827f95f | |
Timothy Warren | bc8822e725 | |
Timothy Warren | da336876b6 | |
Timothy Warren | f7119a5b0f | |
Timothy Warren | f3df8f1588 | |
Timothy Warren | e7aba2a256 | |
Timothy Warren | d6b7075229 | |
Timothy Warren | 7caa6d254f | |
Timothy Warren | 71b692c791 | |
Timothy Warren | 54cd406187 | |
Timothy Warren | 0d49a3fc93 | |
Timothy Warren | 6f643454ef | |
Timothy Warren | 1fd2dd1146 | |
Timothy Warren | 857d484b61 | |
Timothy Warren | 535de1cf50 | |
Timothy Warren | e84b837dce | |
Timothy Warren | a58d654d1d | |
Timothy Warren | 40a899066e | |
Timothy Warren | 185416f09d | |
Timothy Warren | 66236129a6 | |
Timothy Warren | 0187140e8e | |
Timothy Warren | 39e083d17c | |
Timothy Warren | b38d5811a4 | |
Timothy Warren | c895dfcfbe | |
Timothy Warren | 4653ce2f42 | |
Timothy Warren | 5605384b6a | |
Timothy Warren | 3e68fec704 | |
Timothy Warren | d7c47f3c1f | |
Timothy Warren | 34604d1b7b | |
Timothy Warren | b6dc104947 | |
Timothy Warren | 26d339e546 | |
Timothy Warren | 663258df0d | |
Timothy Warren | 451c7904d8 | |
Timothy Warren | 15b6d492f1 | |
Timothy Warren | e4f6db8229 | |
Timothy Warren | c7a75dd2b4 | |
Timothy Warren | 5c382db49c | |
Timothy Warren | df249fd423 | |
Timothy Warren | 88f6a3fc4f | |
Timothy Warren | 9c7ed16538 | |
Timothy Warren | 1f86d4460c | |
Timothy Warren | 7faaa06079 | |
Timothy Warren | 2223243a45 | |
Timothy Warren | dc879d0511 | |
Timothy Warren | f1e5a0a237 | |
Timothy Warren | 9ec3e0cd94 | |
Timothy Warren | 7d03a69196 | |
Timothy Warren | c82898b16c | |
Timothy Warren | 92a1b147fc | |
Timothy Warren | d15710abfa | |
Timothy Warren | d620e44114 | |
Timothy Warren | e6dde8c42a | |
Timothy Warren | 7889849fe2 | |
Timothy Warren | adecbe1e5c | |
Timothy Warren | 774f9de80f | |
Timothy Warren | 59cac2cbb3 | |
Timothy Warren | b5e2b9a8a3 | |
Timothy Warren | 8f9a77c1eb | |
Timothy Warren | 96fce9a6d5 | |
Timothy Warren | fdd7f91835 | |
Timothy Warren | 9951053b4f | |
Timothy Warren | 1f58d7a419 | |
Timothy Warren | 58549b7018 | |
Timothy Warren | 856aaec7ca | |
Timothy Warren | 1f6100c367 | |
Timothy Warren | 23d78c3b28 | |
Timothy Warren | 672aa287dc | |
Timothy Warren | 4def692123 | |
Timothy Warren | 086b5a9f2d | |
Timothy Warren | dfdc06d048 | |
Timothy Warren | 365da603fa | |
Timothy Warren | b902464446 | |
Timothy Warren | 71610b241c | |
Timothy Warren | 8c31a3b6d6 | |
Timothy Warren | 7648d31e53 | |
Timothy Warren | 24bba26c38 | |
Timothy Warren | e6fb7d4cc4 | |
Timothy Warren | 7c33a6ef70 | |
Timothy Warren | 6652ed7354 | |
Timothy Warren | a04643ea10 | |
Timothy Warren | 30b398c946 | |
Timothy Warren | e5db6bebe8 | |
Timothy Warren | 506cce02cf | |
Timothy Warren | 325d391c2e | |
Timothy Warren | 3e4e76cf0f | |
Timothy Warren | 8a789e0786 | |
Timothy Warren | ed13df885b | |
Timothy Warren | e3cc53e23d | |
Timothy Warren | 1a8042191f | |
Timothy Warren | 77c314dd0f | |
Timothy Warren | 5e1600d35d | |
Timothy Warren | c77afcb580 | |
Timothy Warren | 3778a8e6de | |
Timothy Warren | b4c8cafde7 | |
Timothy Warren | 874a1cdfee | |
Timothy Warren | fa889ad7fc | |
Timothy Warren | c733a892fd | |
Timothy Warren | d88220d9f7 | |
Timothy Warren | a29feae442 | |
Timothy Warren | 28584be828 | |
Timothy Warren | 0d553b7dd4 | |
Timothy Warren | 9c1dc50e65 | |
Timothy Warren | cfa23b8066 | |
Timothy Warren | 8ddd2f5fd5 | |
Timothy Warren | fb1af97bae | |
Timothy Warren | 0b04c22b58 | |
Timothy Warren | e2aa61f580 | |
Timothy Warren | c9f74dd863 | |
Timothy Warren | c5b51054df | |
Timothy Warren | 0e9c257ab7 | |
Timothy Warren | 5aafbc9cb2 | |
Timothy Warren | 5f0f830aea | |
Timothy Warren | 20540963ff | |
Timothy Warren | 76c9adbc43 | |
Timothy Warren | 5c5b1cd318 | |
Timothy Warren | f41cbf70e3 | |
Timothy Warren | 6d735ebab5 | |
Timothy Warren | b4de2cfe01 | |
Timothy Warren | 0c70bcb948 | |
Timothy Warren | 3dbbcd218a | |
Timothy Warren | 093abdb14b | |
Timothy Warren | a48c3e5f8e | |
Timothy Warren | 47bfe810fc | |
Timothy Warren | 82e0078dbf | |
Timothy Warren | c38b4b7f45 | |
Timothy Warren | da4163bc6a | |
Timothy Warren | f697e3e18e | |
Timothy Warren | e2e51a0025 | |
Timothy Warren | ad4b71ac03 | |
Timothy Warren | 627c33356c | |
Timothy Warren | 17372bafd2 | |
Timothy Warren | ef6d0f82fd | |
Timothy Warren | b800dcb407 | |
Timothy Warren | 28fcdd1e2d | |
Timothy Warren | df09e27dee | |
Timothy Warren | 57b103c136 | |
Timothy Warren | 780b1ae837 | |
Timothy Warren | 3f90e93af1 | |
Timothy Warren | 192618b890 | |
Timothy Warren | 04e8a9e514 | |
Timothy Warren | 005014a9c7 | |
Timothy Warren | b8f75e14ec | |
Timothy Warren | 833cd0f7e3 | |
Timothy Warren | 1818bf105d | |
Timothy Warren | 5f6c1f9f48 | |
Timothy Warren | 2505df6501 | |
Timothy Warren | 94bfdebf46 | |
Timothy Warren | 2c106f607c | |
Timothy Warren | 95f768aed3 | |
Timothy Warren | 5c34c92453 | |
Timothy Warren | 07c4682711 | |
Timothy Warren | 3dac007390 | |
Timothy Warren | 747dc66d67 | |
Timothy Warren | 27895a27be | |
Timothy Warren | a266c68f9b | |
Timothy Warren | d79370deb9 | |
Timothy Warren | 68bee55f6a | |
Timothy Warren | 29d8207c63 | |
Timothy Warren | abfa97d99c | |
Timothy Warren | 76c5e50b0e | |
Timothy Warren | 270f9ab167 | |
Timothy Warren | f10b0f5284 | |
Timothy Warren | adbed10173 | |
Timothy Warren | 2e3cc1837b | |
Timothy Warren | 951187783b | |
Timothy Warren | e6e9c9424b | |
Timothy Warren | 3f34ecee28 | |
Timothy Warren | 0644c40b1c | |
Timothy Warren | 036396a382 | |
Timothy Warren | 7be02bb292 | |
Timothy Warren | 8d559dc664 | |
Timothy Warren | a5dd9f0650 | |
Timothy Warren | 5fc70bb4fe | |
Timothy Warren | 08b4227b34 | |
Timothy Warren | 187812576c | |
Timothy Warren | 8412588940 | |
Timothy Warren | 4c75701c0d | |
Timothy Warren | 9eda005399 | |
Timothy Warren | e6c96bed21 | |
Timothy Warren | 9c8df03c36 | |
Timothy Warren | 609ba57078 | |
Timothy Warren | 772aeae20f | |
Timothy Warren | 9bd5d62ca7 | |
Timothy Warren | a92acd203d | |
Timothy Warren | 0c910bff1a | |
Timothy Warren | a41acb28f6 | |
Timothy Warren | 14181c9c51 | |
Timothy Warren | 276c492355 | |
Timothy Warren | fe91235436 | |
Timothy Warren | 08c793b912 | |
Timothy Warren | bc0452aa2f | |
Timothy Warren | 27f66cfea3 | |
Timothy Warren | 5e2a68dc84 | |
Timothy Warren | 08b61d08e9 | |
Timothy Warren | c3ec94c063 | |
Timothy Warren | 9ec66803c8 | |
Timothy Warren | afbde14116 | |
Timothy Warren | 52b1959338 | |
Timothy Warren | 4607d146a4 | |
Timothy Warren | bf01e41e32 | |
Timothy Warren | 756db06540 | |
Timothy Warren | d6f9ceb5c7 | |
Timothy Warren | f1a6f99fc4 | |
Timothy Warren | 3335093e87 | |
Timothy Warren | 1d6e347b78 | |
Timothy Warren | f163ea41d6 | |
Timothy Warren | d30e90937b | |
Timothy Warren | 30834be3a8 | |
Timothy Warren | 282fb44603 | |
Timothy Warren | aac478a455 | |
Timothy Warren | b14413af3f | |
Timothy Warren | cc65cc9cf1 | |
Timothy Warren | 1ccce00e46 | |
Timothy Warren | 7f1bcc841a | |
Timothy Warren | ba6ada32f9 | |
Timothy Warren | 3d66fa9c11 | |
Timothy Warren | 2a3a64f0eb | |
Timothy Warren | 1b93adefa3 | |
Timothy Warren | 756b5b5136 | |
Timothy Warren | ac76994a70 | |
Timothy Warren | 1d2936df92 | |
Timothy Warren | fec9de0e3d | |
Timothy Warren | 5a69da4466 | |
Timothy Warren | 4772c6df95 | |
Timothy Warren | 0632ebba66 | |
Timothy Warren | b61f0b5e6c | |
Timothy Warren | d54d180090 | |
Timothy Warren | 23fa88bb33 | |
Timothy Warren | c0c90eb565 | |
Timothy Warren | 1f80491968 | |
Timothy Warren | 691387b7c9 | |
Timothy Warren | 229387a972 | |
Timothy Warren | 8ba6e83032 | |
Timothy Warren | 3f7711dd20 | |
Timothy Warren | 9fc3d60835 | |
Timothy Warren | c9e0b333bf | |
Timothy Warren | 6da1924f53 | |
Timothy Warren | 1afb45522d | |
Timothy Warren | e0b58a29ea | |
Timothy Warren | 675ccac14d | |
Timothy Warren | 47b8a83d86 | |
Timothy Warren | 1bc1d2fa31 | |
Timothy Warren | 1844f89e63 | |
Timothy Warren | 741d9d0805 | |
Timothy Warren | 05391eceab | |
Timothy Warren | cf7b645d54 | |
Timothy Warren | 3710f42505 | |
Timothy Warren | 01d25f2817 | |
Timothy Warren | d17549c0fb | |
Timothy Warren | 79f71eee09 | |
Timothy Warren | de2f4fca1e | |
Timothy Warren | aa2e6a5418 | |
Timothy Warren | 29041a4667 | |
Timothy Warren | a7063e9a49 | |
Timothy Warren | 35b42d5234 | |
Timothy Warren | d8e67e914f | |
Timothy Warren | 6817082816 | |
Timothy Warren | 5caa85d8f1 | |
Timothy Warren | d895c44c0c | |
Timothy Warren | 86065d16df | |
Timothy Warren | ea1b63265b | |
Timothy Warren | 52c1cff5e8 | |
Timothy Warren | 5fee288016 | |
Timothy Warren | c08880c19d | |
Timothy Warren | 1c08959ed3 | |
Timothy Warren | 4e58950ae2 | |
Timothy Warren | c7b4ddf71e | |
Timothy Warren | 3d19f93001 | |
Timothy Warren | 5db1d8b494 | |
Timothy Warren | 181af86899 | |
Timothy Warren | 352ebb4105 | |
Timothy Warren | 3127e06a47 | |
Timothy Warren | 44e4aaa732 | |
Timothy Warren | 125dc96de5 | |
Timothy Warren | 5aa8a70b0b | |
Timothy Warren | 510211cfd0 | |
Timothy Warren | 26c6df74e4 | |
Timothy Warren | d8c89c9deb | |
Timothy Warren | dbaadc4c2a | |
Timothy Warren | 2da5935d1f | |
Timothy Warren | 9d00fc140c | |
Timothy Warren | 28adcaf95a | |
Timothy Warren | a5f59092bb | |
Timothy Warren | 598d987b37 | |
Timothy Warren | eb8090b350 | |
Timothy Warren | 38abb27eb3 | |
Timothy Warren | b6307eb88b | |
Timothy Warren | b2522acd08 | |
Timothy Warren | ba4597973e | |
Timothy Warren | 63b26a104d | |
Timothy Warren | b346bdf337 | |
Timothy Warren | c12bff6027 | |
Timothy Warren | 825e0c1a90 | |
Timothy Warren | db69b13d87 | |
Timothy Warren | 918b8fd18c | |
Timothy Warren | 170acbaffd | |
Timothy Warren | 2effae1bd5 | |
Timothy Warren | 41e6f6e57a | |
Timothy Warren | 5c188f3513 | |
Timothy Warren | 3019e9f62e | |
Timothy Warren | dcf5bebb9b | |
Timothy Warren | fc02a68691 | |
Timothy Warren | b1549440e0 | |
Timothy Warren | af29c68ec9 | |
Timothy Warren | f3a44e6f33 | |
Timothy Warren | 6555aac2fb | |
Timothy Warren | 93b885dc0d | |
Timothy Warren | d746de34ea | |
Timothy Warren | 49bd468aa4 | |
Timothy Warren | f007ad987d | |
Timothy Warren | daf4b71bbb | |
Timothy Warren | e59ead5a84 | |
Timothy Warren | 2e3306708e | |
Timothy Warren | c59288b5f9 | |
Timothy Warren | 6ff4ee2746 | |
Timothy Warren | 9b03f102f3 | |
Timothy Warren | 816a309f18 | |
Timothy Warren | b85ddb9464 | |
Timothy Warren | 3918ce4eb7 | |
Timothy Warren | 3bd5c7d218 | |
Timothy Warren | 9c73ab928c | |
Timothy Warren | 016e0988e9 | |
Timothy Warren | 97dfa89b6d | |
Timothy Warren | f5549934fe | |
Timothy Warren | 27ac7e8063 | |
Timothy Warren | 275b0eea40 | |
Timothy Warren | fa4940f22d | |
Timothy Warren | bfe46fbbd1 | |
Timothy Warren | 38faaebb5f | |
Timothy Warren | 3c124456d0 | |
Timothy Warren | b4489311c9 | |
Timothy Warren | 7a9fe42d83 | |
Scrutinizer Auto-Fixer | dd0e15137a | |
Timothy Warren | 205c7ac76d | |
Timothy Warren | 6455541210 | |
Scrutinizer Auto-Fixer | 7cdd79a116 | |
Timothy Warren | 6e4e8edd9d | |
Timothy Warren | 1251486aa3 | |
Timothy Warren | 1b8ed53afb | |
Timothy Warren | 5e048977a3 | |
Scrutinizer Auto-Fixer | 355aff2951 | |
Timothy Warren | 3c41682d73 | |
Timothy Warren | 77709c068a | |
Timothy Warren | d48cafa54d | |
Timothy Warren | f386766841 | |
Timothy Warren | 52397bbd61 | |
Timothy Warren | 99b429433c | |
Timothy Warren | c23c63cb15 | |
Timothy Warren | fff46421bf | |
Timothy Warren | 61f1963db8 | |
Timothy Warren | 253f191113 | |
Timothy Warren | 6622014bd1 | |
Timothy Warren | bd6b5e2b54 | |
Timothy Warren | 4ed6200d9f | |
Timothy Warren | c009a96a15 | |
Timothy Warren | ae88282b13 | |
Scrutinizer Auto-Fixer | 38b2f34527 | |
Timothy Warren | afced2339a | |
Timothy Warren | 83cd815750 | |
Timothy Warren | ca2e72d3f0 | |
Timothy Warren | 3c4ba096c6 | |
Timothy Warren | 1891aafef5 | |
Timothy Warren | aee2fa7120 | |
Timothy Warren | c55f91a79f | |
Timothy Warren | 8f95bfe7e0 | |
Scrutinizer Auto-Fixer | db33f46547 | |
Timothy Warren | 68cb36b193 | |
Timothy Warren | ff28b40c9e | |
Timothy Warren | e6b4fe59a3 | |
Timothy Warren | 0cd30e811d | |
Timothy Warren | d3541da789 | |
Timothy Warren | cdb4406e14 | |
Timothy Warren | 6ef8caca00 | |
Timothy Warren | beb127c06c | |
Timothy Warren | 9b38242f9d | |
Scrutinizer Auto-Fixer | d63d33d245 | |
Timothy Warren | 30f18106cb | |
Timothy Warren | fdd0da8d93 | |
Timothy Warren | 4ad6178bf0 | |
Timothy Warren | 32d20a9234 | |
Timothy Warren | def424da72 | |
Timothy Warren | c99d4ee53d | |
Timothy Warren | 935076cc63 | |
Timothy Warren | 766fad6bb2 | |
Timothy Warren | 672b781425 | |
Timothy Warren | 95ecc9e9b8 | |
Timothy Warren | 8625f20b74 | |
Timothy Warren | 944a0c9c2a | |
Timothy Warren | f22015635e | |
Timothy Warren | 23122964d2 | |
Timothy Warren | 67080a098f | |
Timothy Warren | 5bf46e0840 | |
Timothy Warren | 454679626c | |
Timothy Warren | e2e27c2311 | |
Timothy Warren | 3cf753a707 | |
Timothy Warren | 9ed18ce131 | |
Timothy Warren | 6b1f39525d | |
Timothy Warren | 725915060b | |
Scrutinizer Auto-Fixer | 2b6b8bff43 | |
Timothy Warren | f49e4fe3d8 | |
Timothy Warren | 9cf958b1ed | |
Scrutinizer Auto-Fixer | 25981afeef | |
Timothy Warren | 3de32f52af | |
Timothy Warren | 15707167f1 | |
Timothy Warren | c86d72f3e2 | |
Scrutinizer Auto-Fixer | edd393793a | |
Timothy Warren | f9b3d64eca | |
Timothy Warren | 83f1a9afd9 | |
Timothy Warren | d53524ed86 | |
Timothy Warren | aedabd6eda | |
Timothy Warren | af95ac941f | |
Scrutinizer Auto-Fixer | 7c5a73e73b | |
Timothy Warren | 5e5434d057 | |
Timothy Warren | 9f123822b1 | |
Timothy Warren | 651b9c4483 | |
Timothy Warren | e71e76dbc6 | |
Timothy Warren | 7917c39065 | |
Timothy Warren | e8a9982f9a | |
Timothy Warren | e634a22134 | |
Timothy Warren | a7ae1ac3a6 | |
Timothy Warren | 5624d9b44e | |
Timothy Warren | 92d9124bb7 | |
Timothy Warren | 8fb6dae119 | |
Timothy Warren | 5f6119c86b | |
Timothy Warren | 602759b471 | |
Timothy Warren | c788cf5d87 | |
Timothy Warren | 9193938dee | |
Timothy Warren | b1c6039630 | |
Timothy Warren | 67799fcdfa | |
Timothy Warren | dfe0b3a6cf | |
Timothy Warren | cee211621c | |
Timothy Warren | 8904054212 | |
Timothy Warren | 6450a76351 | |
Timothy Warren | 54371bf76a | |
Timothy Warren | c33575e3d8 | |
Timothy Warren | ef4e9b3e85 |
|
@ -0,0 +1,20 @@
|
|||
# EditorConfig is awesome: http://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# Unix-style newlines with a newline ending every file
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = false
|
||||
charset = utf-8
|
||||
indent_style = tab
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.{cpp,c,h,hpp,cxx}]
|
||||
insert_final_newline = true
|
||||
|
||||
# Yaml files
|
||||
[*.{yml,yaml}]
|
||||
indent_style = space
|
||||
indent_size = 4
|
|
@ -1,10 +1,148 @@
|
|||
vendor
|
||||
app/cache/*
|
||||
public/images/*
|
||||
public/js/cache/*
|
||||
composer.lock
|
||||
*.sqlite
|
||||
*.db
|
||||
*.sqlite3
|
||||
docs/*
|
||||
coverage/*
|
||||
|
||||
# Created by https://www.gitignore.io/api/macos,jetbrains+all
|
||||
|
||||
### JetBrains+all ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
### JetBrains+all Patch ###
|
||||
# Ignores the whole .idea folder and all .iml files
|
||||
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
|
||||
|
||||
.idea/
|
||||
|
||||
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
|
||||
|
||||
*.iml
|
||||
modules.xml
|
||||
.idea/misc.xml
|
||||
*.ipr
|
||||
|
||||
### macOS ###
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
|
||||
# End of https://www.gitignore.io/api/macos,jetbrains+all
|
||||
|
||||
.codelite
|
||||
.phing_targets
|
||||
.sonar/
|
||||
*.phprj
|
||||
*.workspace
|
||||
vendor
|
||||
**/cache/**
|
||||
**/logs/**
|
||||
**/coverage/**
|
||||
**/docs/**
|
||||
**/node_modules/**
|
||||
composer.lock
|
||||
*.sqlite
|
||||
*.db
|
||||
*.sqlite3
|
||||
apidocs/**
|
||||
tests/test_data/sessions/*
|
||||
cache.properties
|
||||
build/**
|
||||
!build/*.txt
|
||||
!build/*.xml
|
||||
!build/*.php
|
||||
app/config/*.toml
|
||||
!app/config/*.toml.example
|
||||
phinx.yml
|
||||
Caddyfile
|
||||
build/humbuglog.txt
|
||||
public/images/anime/**
|
||||
public/images/avatars/**
|
||||
public/images/manga/**
|
||||
public/images/characters/**
|
||||
public/images/people/**
|
||||
public/mal_mappings.json
|
|
@ -0,0 +1,6 @@
|
|||
#Rewrite index.php out of the app urls
|
||||
RewriteEngine On
|
||||
RewriteBase /
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule ^(.*)$ index.php/$1 [L]
|
24
.travis.yml
24
.travis.yml
|
@ -1,20 +1,26 @@
|
|||
language: php
|
||||
|
||||
install:
|
||||
- composer install
|
||||
- composer install --ignore-platform-reqs
|
||||
|
||||
php:
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7
|
||||
- hhvm
|
||||
- 7.1
|
||||
- 7.2
|
||||
- 7.3
|
||||
- nightly
|
||||
|
||||
script:
|
||||
- mkdir -p build/logs
|
||||
- phpunit --coverage-clover=coverage.clover
|
||||
- phpdbg -qrr -- vendor/bin/phpunit -c build
|
||||
|
||||
after_script:
|
||||
- wget https://scrutinizer-ci.com/ocular.phar
|
||||
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
|
||||
- CODECLIMATE_REPO_TOKEN=2cbddcebcb9256b3402867282e119dbe61de0b31039325356af3c7d72ed6d058 vendor/bin/test-reporter
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- php: nightly
|
||||
- php: hhvm
|
||||
|
||||
addons:
|
||||
code_climate:
|
||||
repo_token: 2cbddcebcb9256b3402867282e119dbe61de0b31039325356af3c7d72ed6d058
|
|
@ -0,0 +1,26 @@
|
|||
# Changelog
|
||||
|
||||
## Version 4.1
|
||||
* Removed MAL integration, added Anilist Integration
|
||||
* Now uses WebP cache images when the browser supports it
|
||||
* Replaces JS minifier with pre-minified scripts (Removes the need for one caching folder, too)
|
||||
* Updated console command to sync Kitsu and Anilist data (Kitsu can sync MAL, and MAL's API broke, so MAL sync was removed)
|
||||
* Added page to update settings without having to edit config files
|
||||
* Defaulted to secure (HTTPS) urls
|
||||
* Updated Character pages to show voice actors
|
||||
* Added People pages, showing which works they contributed to, and in what role
|
||||
|
||||
## Version 4
|
||||
* Updated to use Kitsu API after discontinuation of Hummingbird
|
||||
* Added streaming links to list entries from the Kitsu API
|
||||
* Added simple integration with MyAnimeList, so an update can cross-post to both Kitsu and MyAnimeList (anime and manga)
|
||||
* Added console command to sync Kitsu and MyAnimeList data
|
||||
* Added character pages
|
||||
|
||||
## Version 3
|
||||
* Converted user configuration to toml files
|
||||
* Added a caching layer for api calls, which resets upon updates from the
|
||||
app.
|
||||
* Added a bulk thumbnail generator script
|
||||
* Removed json file "cache" from the app folder
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
pipeline {
|
||||
agent none
|
||||
stages {
|
||||
stage('PHP 7.1') {
|
||||
agent {
|
||||
docker {
|
||||
image 'php:7.1-alpine'
|
||||
args '-u root --privileged'
|
||||
}
|
||||
}
|
||||
steps {
|
||||
sh 'chmod +x ./build/docker_install.sh'
|
||||
sh 'sh build/docker_install.sh'
|
||||
sh 'apk add --no-cache php7-phpdbg'
|
||||
sh 'curl -sS https://getcomposer.org/installer | php'
|
||||
sh 'php composer.phar install --ignore-platform-reqs'
|
||||
sh 'phpdbg -qrr -- ./vendor/bin/phpunit --coverage-text --colors=never'
|
||||
}
|
||||
}
|
||||
stage('PHP 7.2') {
|
||||
agent {
|
||||
docker {
|
||||
image 'php:7.2-alpine'
|
||||
args '-u root --privileged'
|
||||
}
|
||||
}
|
||||
steps {
|
||||
sh 'chmod +x ./build/docker_install.sh'
|
||||
sh 'sh build/docker_install.sh'
|
||||
sh 'apk add --no-cache php7-phpdbg'
|
||||
sh 'curl -sS https://getcomposer.org/installer | php'
|
||||
sh 'php composer.phar install --ignore-platform-reqs'
|
||||
sh 'phpdbg -qrr -- ./vendor/bin/phpunit --coverage-text --colors=never'
|
||||
}
|
||||
}
|
||||
stage('PHP 7.3') {
|
||||
agent {
|
||||
docker {
|
||||
image 'php:7.3-alpine'
|
||||
args '-u root --privileged'
|
||||
}
|
||||
}
|
||||
steps {
|
||||
sh 'chmod +x ./build/docker_install.sh'
|
||||
sh 'sh build/docker_install.sh'
|
||||
sh 'apk add --no-cache php7-phpdbg'
|
||||
sh 'curl -sS https://getcomposer.org/installer | php'
|
||||
sh 'php composer.phar install --ignore-platform-reqs'
|
||||
sh 'phpdbg -qrr -- ./vendor/bin/phpunit --coverage-text --colors=never'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 Timothy J Warren
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
55
README.md
55
README.md
|
@ -1,10 +1,11 @@
|
|||
# Hummingbird Anime Client
|
||||
|
||||
A self-hosted client that allows custom formatting of data from the hummingbird api
|
||||
Update your anime/manga list on Kitsu.io and MyAnimeList.net
|
||||
|
||||
[![Build Status](https://travis-ci.org/timw4mail/HummingBirdAnimeClient.svg)](https://travis-ci.org/timw4mail/HummingBirdAnimeClient)
|
||||
[![Build Status](https://travis-ci.org/timw4mail/HummingBirdAnimeClient.svg?branch=master)](https://travis-ci.org/timw4mail/HummingBirdAnimeClient)
|
||||
[![Build Status](https://jenkins.timshomepage.net/buildStatus/icon?job=aviat/HummingBirdAnimeClient/develop)](https://jenkins.timshomepage.net/job/aviat/HummingBirdAnimeClient/develop)
|
||||
|
||||
[[Hosted Example](https://anime.timshomepage.net)]
|
||||
[[Hosted Example](https://list.timshomepage.net)]
|
||||
|
||||
## Features
|
||||
|
||||
|
@ -13,43 +14,47 @@ A self-hosted client that allows custom formatting of data from the hummingbird
|
|||
* Plan to Watch
|
||||
* On Hold
|
||||
* Dropped
|
||||
* Completed
|
||||
* All of the above
|
||||
|
||||
* Completed
|
||||
* Combined View
|
||||
|
||||
* Manga List views (Each with list and cover views):
|
||||
* Reading
|
||||
* Plan to Read
|
||||
* On Hold
|
||||
* Dropped
|
||||
* Completed
|
||||
* All of the above
|
||||
|
||||
* Combined View
|
||||
|
||||
* Anime collection view (segmented by media type):
|
||||
* Cover Images
|
||||
* Table List
|
||||
|
||||
|
||||
### Requirements
|
||||
|
||||
* PHP 5.4+
|
||||
* PDO SQLite (For collection tab)
|
||||
* GD
|
||||
* PHP 7.1+
|
||||
* PDO SQLite or PDO PostgreSQL (For collection tab)
|
||||
* GD extension for caching images
|
||||
|
||||
### Highly Recommended
|
||||
* Redis or Memcached for caching
|
||||
|
||||
### Installation
|
||||
|
||||
1. Install dependencies via composer: `composer install`
|
||||
2. Change the `WHOSE` constant declaration in `index.php` to your name
|
||||
3. Configure settings in `app/config/config.php` to your liking
|
||||
1. Install via git, then install dependencies via composer: `composer install`
|
||||
2. Duplicate `app/config/config.toml.example` file as `app/config/config.toml`
|
||||
3. Configure settings in `app/config/config.toml` to your liking
|
||||
4. Create the following directories if they don't exist, and make sure they are world writable
|
||||
* app/cache
|
||||
* public/images/manga
|
||||
* app/config
|
||||
* app/logs
|
||||
* public/images/avatars
|
||||
* public/images/anime
|
||||
* public/js/cache
|
||||
* public/images/characters
|
||||
* public/images/manga
|
||||
5. Make sure the `console` script is executable
|
||||
6. Additional settings are on the settings page once you log in.
|
||||
|
||||
#### Anime Collection Additional Installation
|
||||
* Run `php /vendor/bin/phinx migrate -e development` to create the database tables
|
||||
* For importing anime:
|
||||
1. Find the anime you are looking for on the hummingbird search api page: `https://hummingbird.me/api/v1/search/anime?query=`
|
||||
2. Create an `import.json` file in the root of the app, with an array of objects from the search page that you want to import
|
||||
3. Go to the anime collection tab, and the import will be run
|
||||
### Server Setup
|
||||
|
||||
See the [wiki](https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient/wiki)
|
||||
for more in-depth information
|
||||
|
||||
|
|
@ -0,0 +1,305 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
use Robo\Tasks;
|
||||
|
||||
if ( ! function_exists('glob_recursive'))
|
||||
{
|
||||
// Does not support flag GLOB_BRACE
|
||||
function glob_recursive($pattern, $flags = 0)
|
||||
{
|
||||
$files = glob($pattern, $flags);
|
||||
|
||||
foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir)
|
||||
{
|
||||
$files = array_merge($files, glob_recursive($dir.'/'.basename($pattern), $flags));
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is project's console commands configuration for Robo task runner.
|
||||
*
|
||||
* @see http://robo.li/
|
||||
*/
|
||||
class RoboFile extends Tasks {
|
||||
|
||||
/**
|
||||
* Directories used by analysis tools
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $taskDirs = [
|
||||
'build/logs',
|
||||
'build/pdepend',
|
||||
'build/phpdox',
|
||||
];
|
||||
|
||||
/**
|
||||
* Directories to remove with the clean task
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $cleanDirs = [
|
||||
'coverage',
|
||||
'docs',
|
||||
'phpdoc',
|
||||
'build/logs',
|
||||
'build/phpdox',
|
||||
'build/pdepend'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Do static analysis tasks
|
||||
*/
|
||||
public function analyze()
|
||||
{
|
||||
$this->prepare();
|
||||
$this->lint();
|
||||
$this->phploc(TRUE);
|
||||
$this->phpcs(TRUE);
|
||||
$this->dependencyReport();
|
||||
$this->phpcpdReport();
|
||||
}
|
||||
|
||||
/**
|
||||
* Run all tests, generate coverage, generate docs, generate code statistics
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->analyze();
|
||||
$this->coverage();
|
||||
$this->docs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup temporary files
|
||||
*/
|
||||
public function clean()
|
||||
{
|
||||
$cleanFiles = [
|
||||
'build/humbug.json',
|
||||
'build/humbug-log.txt',
|
||||
];
|
||||
array_map(function ($file) {
|
||||
@unlink($file);
|
||||
}, $cleanFiles);
|
||||
|
||||
// So the task doesn't complain,
|
||||
// make any 'missing' dirs to cleanup
|
||||
array_map(function ($dir) {
|
||||
if ( ! is_dir($dir))
|
||||
{
|
||||
`mkdir -p {$dir}`;
|
||||
}
|
||||
}, $this->cleanDirs);
|
||||
|
||||
$this->_cleanDir($this->cleanDirs);
|
||||
$this->_deleteDir($this->cleanDirs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run unit tests and generate coverage reports
|
||||
*/
|
||||
public function coverage()
|
||||
{
|
||||
$this->_run(['phpdbg -qrr -- vendor/bin/phpunit -c build']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate documentation with phpdox
|
||||
*/
|
||||
public function docs()
|
||||
{
|
||||
$cmd_parts = [
|
||||
'vendor/bin/phpdox',
|
||||
];
|
||||
$this->_run($cmd_parts, ' && ');
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that source files are valid
|
||||
*/
|
||||
public function lint()
|
||||
{
|
||||
$files = $this->getAllSourceFiles();
|
||||
|
||||
$chunks = array_chunk($files, 12);
|
||||
|
||||
foreach($chunks as $chunk)
|
||||
{
|
||||
$this->parallelLint($chunk);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the phpcs tool
|
||||
*
|
||||
* @param bool $report - if true, generates reports instead of direct output
|
||||
*/
|
||||
public function phpcs($report = FALSE)
|
||||
{
|
||||
$report_cmd_parts = [
|
||||
'vendor/bin/phpcs',
|
||||
'--standard=./build/phpcs.xml',
|
||||
'--report-checkstyle=./build/logs/phpcs.xml',
|
||||
];
|
||||
|
||||
$normal_cmd_parts = [
|
||||
'vendor/bin/phpcs',
|
||||
'--standard=./build/phpcs.xml',
|
||||
];
|
||||
|
||||
$cmd_parts = ($report) ? $report_cmd_parts : $normal_cmd_parts;
|
||||
|
||||
$this->_run($cmd_parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the phploc tool
|
||||
*
|
||||
* @param bool $report - if true, generates reports instead of direct output
|
||||
*/
|
||||
public function phploc($report = FALSE)
|
||||
{
|
||||
// Command for generating reports
|
||||
$report_cmd_parts = [
|
||||
'vendor/bin/phploc',
|
||||
'--count-tests',
|
||||
'--log-csv=build/logs/phploc.csv',
|
||||
'--log-xml=build/logs/phploc.xml',
|
||||
'src',
|
||||
'tests'
|
||||
];
|
||||
|
||||
// Command for generating direct output
|
||||
$normal_cmd_parts = [
|
||||
'vendor/bin/phploc',
|
||||
'--count-tests',
|
||||
'src',
|
||||
'tests'
|
||||
];
|
||||
|
||||
$cmd_parts = ($report) ? $report_cmd_parts : $normal_cmd_parts;
|
||||
|
||||
$this->_run($cmd_parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create temporary directories
|
||||
*/
|
||||
public function prepare()
|
||||
{
|
||||
array_map([$this, '_mkdir'], $this->taskDirs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lint php files and run unit tests
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
$this->lint();
|
||||
|
||||
$this->_run(['phpunit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Watches for file updates, and automatically runs appropriate actions
|
||||
*/
|
||||
public function watch()
|
||||
{
|
||||
$this->taskWatch()
|
||||
->monitor('composer.json', function() {
|
||||
$this->taskComposerUpdate()->run();
|
||||
})
|
||||
->monitor('src', function () {
|
||||
$this->taskExec('test')->run();
|
||||
})
|
||||
->monitor('tests', function () {
|
||||
$this->taskExec('test')->run();
|
||||
})
|
||||
->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create pdepend reports
|
||||
*/
|
||||
protected function dependencyReport()
|
||||
{
|
||||
$cmd_parts = [
|
||||
'vendor/bin/pdepend',
|
||||
'--jdepend-xml=build/logs/jdepend.xml',
|
||||
'--jdepend-chart=build/pdepend/dependencies.svg',
|
||||
'--overview-pyramid=build/pdepend/overview-pyramid.svg',
|
||||
'src'
|
||||
];
|
||||
$this->_run($cmd_parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total list of source files, including tests
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getAllSourceFiles()
|
||||
{
|
||||
$files = array_merge(
|
||||
glob_recursive('build/*.php'),
|
||||
glob_recursive('src/*.php'),
|
||||
glob_recursive('src/**/*.php'),
|
||||
glob_recursive('tests/*.php'),
|
||||
glob_recursive('tests/**/*.php'),
|
||||
glob('*.php')
|
||||
);
|
||||
|
||||
sort($files);
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run php's linter in one parallel task for the passed chunk
|
||||
*
|
||||
* @param array $chunk
|
||||
*/
|
||||
protected function parallelLint(array $chunk)
|
||||
{
|
||||
$task = $this->taskParallelExec()
|
||||
->timeout(5)
|
||||
->printed(FALSE);
|
||||
|
||||
foreach($chunk as $file)
|
||||
{
|
||||
$task = $task->process("php -l {$file}");
|
||||
}
|
||||
|
||||
$task->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate copy paste detector report
|
||||
*/
|
||||
protected function phpcpdReport()
|
||||
{
|
||||
$cmd_parts = [
|
||||
'vendor/bin/phpcpd',
|
||||
'--log-pmd build/logs/pmd-cpd.xml',
|
||||
'src'
|
||||
];
|
||||
$this->_run($cmd_parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut for joining an array of command arguments
|
||||
* and then running it
|
||||
*
|
||||
* @param array $cmd_parts - command arguments
|
||||
* @param string $join_on - what to join the command arguments with
|
||||
*/
|
||||
protected function _run(array $cmd_parts, $join_on = ' ')
|
||||
{
|
||||
$this->taskExec(implode($join_on, $cmd_parts))->run();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime List Client
|
||||
*
|
||||
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
* @copyright 2015 - 2017 Timothy J. Warren
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @version 4.0
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
use function Aviat\AnimeClient\loadToml;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Lower level configuration
|
||||
//
|
||||
// You shouldn't generally need to change anything below this line
|
||||
// ----------------------------------------------------------------------------
|
||||
$APP_DIR = realpath(__DIR__ . '/../');
|
||||
$ROOT_DIR = realpath("{$APP_DIR}/../");
|
||||
|
||||
$tomlConfig = loadToml(__DIR__);
|
||||
|
||||
return array_merge($tomlConfig, [
|
||||
'asset_dir' => "{$ROOT_DIR}/public",
|
||||
'base_config_dir' => __DIR__,
|
||||
'config_dir' => "{$APP_DIR}/config",
|
||||
|
||||
// No config defaults
|
||||
'kitsu_username' => 'timw4mail',
|
||||
'whose_list' => 'Someone',
|
||||
'cache' => [
|
||||
'connection' => [],
|
||||
'driver' => 'null',
|
||||
],
|
||||
'secure_urls' => TRUE,
|
||||
|
||||
// Routing defaults
|
||||
'asset_path' => '/public',
|
||||
'default_list' => 'anime', //anime|manga
|
||||
'default_anime_list_path' => 'watching', // watching|plan_to_watch|on_hold|dropped|completed|all
|
||||
'default_manga_list_path' => 'reading', // reading|plan_to_read|on_hold|dropped|completed|all
|
||||
'default_view_type' => 'cover_view', // cover_view|list_view
|
||||
|
||||
// Template file path
|
||||
'view_path' => "{$APP_DIR}/views",
|
||||
|
||||
// Cache paths
|
||||
'data_cache_path' => "{$APP_DIR}/cache",
|
||||
'img_cache_path' => "{$ROOT_DIR}/public/images",
|
||||
|
||||
// Included config files
|
||||
'routes' => require 'routes.php',
|
||||
]);
|
|
@ -0,0 +1,19 @@
|
|||
[anime_list]
|
||||
route_prefix = "/anime"
|
||||
[anime_list.items]
|
||||
watching = '/watching'
|
||||
plan_to_watch = '/plan_to_watch'
|
||||
on_hold = '/on_hold'
|
||||
dropped = '/dropped'
|
||||
completed = '/completed'
|
||||
all = '/all'
|
||||
|
||||
[manga_list]
|
||||
route_prefix = "/manga"
|
||||
[manga_list.items]
|
||||
reading = '/reading'
|
||||
plan_to_read = '/plan_to_read'
|
||||
on_hold = '/on_hold'
|
||||
dropped = '/dropped'
|
||||
completed = '/completed'
|
||||
all = '/all'
|
|
@ -0,0 +1,306 @@
|
|||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime List Client
|
||||
*
|
||||
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
* @copyright 2015 - 2018 Timothy J. Warren
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @version 4.0
|
||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
use const Aviat\AnimeClient\{
|
||||
ALPHA_SLUG_PATTERN,
|
||||
NUM_PATTERN,
|
||||
SLUG_PATTERN,
|
||||
DEFAULT_CONTROLLER_METHOD,
|
||||
DEFAULT_CONTROLLER
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Routing Config
|
||||
//
|
||||
// Maps paths to controllers and methods
|
||||
// -------------------------------------------------------------------------
|
||||
$routes = [
|
||||
// ---------------------------------------------------------------------
|
||||
// Anime List Routes
|
||||
// ---------------------------------------------------------------------
|
||||
'anime.add.get' => [
|
||||
'path' => '/anime/add',
|
||||
'action' => 'addForm',
|
||||
],
|
||||
'anime.add.post' => [
|
||||
'path' => '/anime/add',
|
||||
'action' => 'add',
|
||||
'verb' => 'post',
|
||||
],
|
||||
'anime.details' => [
|
||||
'path' => '/anime/details/{id}',
|
||||
'action' => 'details',
|
||||
'tokens' => [
|
||||
'id' => SLUG_PATTERN,
|
||||
],
|
||||
],
|
||||
'anime.delete' => [
|
||||
'path' => '/anime/delete',
|
||||
'action' => 'delete',
|
||||
'verb' => 'post',
|
||||
],
|
||||
// ---------------------------------------------------------------------
|
||||
// Manga Routes
|
||||
// ---------------------------------------------------------------------
|
||||
'manga.search' => [
|
||||
'path' => '/manga/search',
|
||||
'action' => 'search',
|
||||
],
|
||||
'manga.add.get' => [
|
||||
'path' => '/manga/add',
|
||||
'action' => 'addForm',
|
||||
],
|
||||
'manga.add.post' => [
|
||||
'path' => '/manga/add',
|
||||
'action' => 'add',
|
||||
'verb' => 'post',
|
||||
],
|
||||
'manga.delete' => [
|
||||
'path' => '/manga/delete',
|
||||
'action' => 'delete',
|
||||
'verb' => 'post',
|
||||
],
|
||||
'manga.details' => [
|
||||
'path' => '/manga/details/{id}',
|
||||
'action' => 'details',
|
||||
'tokens' => [
|
||||
'id' => SLUG_PATTERN,
|
||||
],
|
||||
],
|
||||
// ---------------------------------------------------------------------
|
||||
// Anime Collection Routes
|
||||
// ---------------------------------------------------------------------
|
||||
'anime.collection.search' => [
|
||||
'path' => '/anime-collection/search',
|
||||
'action' => 'search',
|
||||
],
|
||||
'anime.collection.add.get' => [
|
||||
'path' => '/anime-collection/add',
|
||||
'action' => 'form',
|
||||
],
|
||||
'anime.collection.edit.get' => [
|
||||
'path' => '/anime-collection/edit/{id}',
|
||||
'action' => 'form',
|
||||
'tokens' => [
|
||||
'id' => NUM_PATTERN,
|
||||
],
|
||||
],
|
||||
'anime.collection.add.post' => [
|
||||
'path' => '/anime-collection/add',
|
||||
'action' => 'add',
|
||||
'verb' => 'post',
|
||||
],
|
||||
'anime.collection.edit.post' => [
|
||||
'path' => '/anime-collection/edit',
|
||||
'action' => 'edit',
|
||||
'verb' => 'post',
|
||||
],
|
||||
'anime.collection.view' => [
|
||||
'path' => '/anime-collection/view{/view}',
|
||||
'action' => 'view',
|
||||
'tokens' => [
|
||||
'view' => ALPHA_SLUG_PATTERN,
|
||||
],
|
||||
],
|
||||
'anime.collection.delete' => [
|
||||
'path' => '/anime-collection/delete',
|
||||
'action' => 'delete',
|
||||
'verb' => 'post',
|
||||
],
|
||||
'anime.collection.redirect' => [
|
||||
'path' => '/anime-collection',
|
||||
],
|
||||
'anime.collection.redirect2' => [
|
||||
'path' => '/anime-collection/',
|
||||
],
|
||||
// ---------------------------------------------------------------------
|
||||
// Manga Collection Routes
|
||||
// ---------------------------------------------------------------------
|
||||
'manga.collection.search' => [
|
||||
'path' => '/manga-collection/search',
|
||||
'action' => 'search',
|
||||
],
|
||||
'manga.collection.add.get' => [
|
||||
'path' => '/manga-collection/add',
|
||||
'action' => 'form',
|
||||
],
|
||||
'manga.collection.edit.get' => [
|
||||
'path' => '/manga-collection/edit/{id}',
|
||||
'action' => 'form',
|
||||
'tokens' => [
|
||||
'id' => NUM_PATTERN,
|
||||
],
|
||||
],
|
||||
'manga.collection.add.post' => [
|
||||
'path' => '/manga-collection/add',
|
||||
'action' => 'add',
|
||||
'verb' => 'post',
|
||||
],
|
||||
'manga.collection.edit.post' => [
|
||||
'path' => '/manga-collection/edit',
|
||||
'action' => 'edit',
|
||||
'verb' => 'post',
|
||||
],
|
||||
'manga.collection.view' => [
|
||||
'path' => '/manga-collection/view{/view}',
|
||||
'tokens' => [
|
||||
'view' => ALPHA_SLUG_PATTERN,
|
||||
],
|
||||
],
|
||||
'manga.collection.delete' => [
|
||||
'path' => '/manga-collection/delete',
|
||||
'action' => 'delete',
|
||||
'verb' => 'post',
|
||||
],
|
||||
// ---------------------------------------------------------------------
|
||||
// Other Routes
|
||||
// ---------------------------------------------------------------------
|
||||
'character' => [
|
||||
'path' => '/character/{slug}',
|
||||
'tokens' => [
|
||||
'slug' => SLUG_PATTERN
|
||||
]
|
||||
],
|
||||
'person' => [
|
||||
'path' => '/people/{id}',
|
||||
'tokens' => [
|
||||
'id' => SLUG_PATTERN
|
||||
]
|
||||
],
|
||||
'default_user_info' => [
|
||||
'path' => '/me',
|
||||
'action' => 'me',
|
||||
'controller' => 'user',
|
||||
],
|
||||
'user_info' => [
|
||||
'path' => '/user/{username}',
|
||||
'controller' => 'user',
|
||||
'action' => 'about',
|
||||
'tokens' => [
|
||||
'username' => '.*?'
|
||||
]
|
||||
],
|
||||
// ---------------------------------------------------------------------
|
||||
// Default / Shared routes
|
||||
// ---------------------------------------------------------------------
|
||||
'anilist-redirect' => [
|
||||
'path' => '/anilist-redirect',
|
||||
'action' => 'anilistRedirect',
|
||||
'controller' => 'settings',
|
||||
],
|
||||
'anilist-callback' => [
|
||||
'path' => '/anilist-oauth',
|
||||
'action' => 'anilistCallback',
|
||||
'controller' => 'settings',
|
||||
],
|
||||
'image_proxy' => [
|
||||
'path' => '/public/images/{type}/{file}',
|
||||
'action' => 'cache',
|
||||
'controller' => 'images',
|
||||
'tokens' => [
|
||||
'type' => SLUG_PATTERN,
|
||||
'file' => '[a-z0-9\-]+\.[a-z]{3,4}'
|
||||
]
|
||||
],
|
||||
'cache_purge' => [
|
||||
'path' => '/cache_purge',
|
||||
'action' => 'clearCache',
|
||||
],
|
||||
'settings' => [
|
||||
'path' => '/settings',
|
||||
],
|
||||
'settings-post' => [
|
||||
'path' => '/settings/update',
|
||||
'action' => 'update',
|
||||
'verb' => 'post',
|
||||
],
|
||||
'login' => [
|
||||
'path' => '/login',
|
||||
'action' => 'login',
|
||||
],
|
||||
'login.post' => [
|
||||
'path' => '/login',
|
||||
'action' => 'loginAction',
|
||||
'verb' => 'post',
|
||||
],
|
||||
'logout' => [
|
||||
'path' => '/logout',
|
||||
'action' => 'logout',
|
||||
],
|
||||
'increment' => [
|
||||
'path' => '/{controller}/increment',
|
||||
'action' => 'increment',
|
||||
'verb' => 'post',
|
||||
'tokens' => [
|
||||
'controller' => ALPHA_SLUG_PATTERN,
|
||||
],
|
||||
],
|
||||
'update' => [
|
||||
'path' => '/{controller}/update',
|
||||
'action' => 'update',
|
||||
'verb' => 'post',
|
||||
'tokens' => [
|
||||
'controller' => ALPHA_SLUG_PATTERN,
|
||||
],
|
||||
],
|
||||
'update.post' => [
|
||||
'path' => '/{controller}/update_form',
|
||||
'action' => 'formUpdate',
|
||||
'verb' => 'post',
|
||||
'tokens' => [
|
||||
'controller' => ALPHA_SLUG_PATTERN,
|
||||
],
|
||||
],
|
||||
'edit' => [
|
||||
'path' => '/{controller}/edit/{id}/{status}',
|
||||
'action' => 'edit',
|
||||
'tokens' => [
|
||||
'id' => SLUG_PATTERN,
|
||||
'status' => '([a-zA-Z\-_]|%20)+',
|
||||
],
|
||||
],
|
||||
'list' => [
|
||||
'path' => '/{controller}/{type}{/view}',
|
||||
'tokens' => [
|
||||
'type' => ALPHA_SLUG_PATTERN,
|
||||
'view' => ALPHA_SLUG_PATTERN,
|
||||
],
|
||||
],
|
||||
'index_redirect' => [
|
||||
'path' => '/',
|
||||
'action' => 'redirectToDefaultRoute',
|
||||
],
|
||||
];
|
||||
|
||||
$defaultMap = [
|
||||
'action' => DEFAULT_CONTROLLER_METHOD,
|
||||
'controller' => DEFAULT_CONTROLLER,
|
||||
'params' => [],
|
||||
'verb' => 'get',
|
||||
];
|
||||
|
||||
foreach ($routes as &$route)
|
||||
{
|
||||
foreach($defaultMap as $key => $val)
|
||||
{
|
||||
if ( ! array_key_exists($key, $route))
|
||||
{
|
||||
$route[$key] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $routes;
|
|
@ -1,81 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Base API Model
|
||||
*/
|
||||
namespace AnimeClient;
|
||||
|
||||
use \GuzzleHttp\Client;
|
||||
use \GuzzleHttp\Cookie\CookieJar;
|
||||
|
||||
/**
|
||||
* Base model for api interaction
|
||||
*/
|
||||
class BaseApiModel extends BaseModel {
|
||||
|
||||
/**
|
||||
* Base url for making api requests
|
||||
* @var string
|
||||
*/
|
||||
protected $base_url = '';
|
||||
|
||||
/**
|
||||
* The Guzzle http client object
|
||||
* @var object
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* Cookie jar object for api requests
|
||||
* @var object
|
||||
*/
|
||||
protected $cookieJar;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->cookieJar = new CookieJar();
|
||||
$this->client = new Client([
|
||||
'base_url' => $this->base_url,
|
||||
'defaults' => [
|
||||
'cookies' => $this->cookieJar,
|
||||
'headers' => [
|
||||
'User-Agent' => $_SERVER['HTTP_USER_AGENT'],
|
||||
'Accept-Encoding' => 'application/json'
|
||||
],
|
||||
'timeout' => 5,
|
||||
'connect_timeout' => 5
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt login via the api
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @return bool
|
||||
*/
|
||||
public function authenticate($username, $password)
|
||||
{
|
||||
$result = $this->client->post('https://hummingbird.me/api/v1/users/authenticate', [
|
||||
'body' => [
|
||||
'username' => $username,
|
||||
'password' => $password
|
||||
]
|
||||
]);
|
||||
|
||||
if ($result->getStatusCode() === 201)
|
||||
{
|
||||
$_SESSION['hummingbird_anime_token'] = $result->json();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
// End of BaseApiModel.php
|
|
@ -1,254 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Base Controller
|
||||
*/
|
||||
namespace AnimeClient;
|
||||
|
||||
use Aura\Web\WebFactory;
|
||||
|
||||
/**
|
||||
* Base class for controllers, defines output methods
|
||||
*/
|
||||
class BaseController {
|
||||
|
||||
/**
|
||||
* The global configuration object
|
||||
* @var object $config
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* Request object
|
||||
* @var object $request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Response object
|
||||
* @var object $response
|
||||
*/
|
||||
protected $response;
|
||||
|
||||
/**
|
||||
* The api model for the current controller
|
||||
* @var object
|
||||
*/
|
||||
protected $model;
|
||||
|
||||
/**
|
||||
* Common data to be sent to views
|
||||
* @var array
|
||||
*/
|
||||
protected $base_data = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct(Config $config, Array $web)
|
||||
{
|
||||
$this->config = $config;
|
||||
|
||||
list($request, $response) = $web;
|
||||
$this->request = $request;
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
$this->output();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the string output of a partial template
|
||||
*
|
||||
* @param string $template
|
||||
* @param array|object $data
|
||||
* @return string
|
||||
*/
|
||||
public function load_partial($template, $data=[])
|
||||
{
|
||||
if (isset($this->base_data))
|
||||
{
|
||||
$data = array_merge($this->base_data, $data);
|
||||
}
|
||||
|
||||
global $router, $defaultHandler;
|
||||
$route = $router->get_route();
|
||||
$data['route_path'] = ($route) ? $router->get_route()->path : "";
|
||||
|
||||
$defaultHandler->addDataTable('Template Data', $data);
|
||||
|
||||
$template_path = _dir(APP_DIR, 'views', "{$template}.php");
|
||||
|
||||
if ( ! is_file($template_path))
|
||||
{
|
||||
throw new Exception("Invalid template : {$path}");
|
||||
}
|
||||
|
||||
ob_start();
|
||||
extract($data);
|
||||
include _dir(APP_DIR, 'views', 'header.php');
|
||||
include $template_path;
|
||||
include _dir(APP_DIR, 'views', 'footer.php');
|
||||
$buffer = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output a template to HTML, using the provided data
|
||||
*
|
||||
* @param string $template
|
||||
* @param array|object $data
|
||||
* @return void
|
||||
*/
|
||||
public function outputHTML($template, $data=[])
|
||||
{
|
||||
$buffer = $this->load_partial($template, $data);
|
||||
|
||||
$this->response->content->setType('text/html');
|
||||
$this->response->content->set($buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Output json with the proper content type
|
||||
*
|
||||
* @param mixed $data
|
||||
* @return void
|
||||
*/
|
||||
public function outputJSON($data)
|
||||
{
|
||||
if ( ! is_string($data))
|
||||
{
|
||||
$data = json_encode($data);
|
||||
}
|
||||
|
||||
$this->response->content->setType('application/json');
|
||||
$this->response->content->set($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to the selected page
|
||||
*
|
||||
* @param string $url
|
||||
* @param int $code
|
||||
* @return void
|
||||
*/
|
||||
public function redirect($url, $code, $type="anime")
|
||||
{
|
||||
$url = full_url($url, $type);
|
||||
|
||||
$codes = [
|
||||
301 => 'Moved Permanently',
|
||||
302 => 'Found',
|
||||
303 => 'See Other'
|
||||
];
|
||||
|
||||
header("HTTP/1.1 {$code} {$codes[$code]}");
|
||||
header("Location: {$url}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a message box to the page
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $message
|
||||
* @return string
|
||||
*/
|
||||
public function show_message($type, $message)
|
||||
{
|
||||
return $this->load_partial('message', [
|
||||
'stat_class' => $type,
|
||||
'message' => $message
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the api session
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
session_destroy();
|
||||
$this->response->redirect->seeOther(full_url(''));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the login form
|
||||
*
|
||||
* @param string $status
|
||||
* @return void
|
||||
*/
|
||||
public function login($status="")
|
||||
{
|
||||
$message = "";
|
||||
|
||||
if ($status != "")
|
||||
{
|
||||
$message = $this->show_message('error', $status);
|
||||
}
|
||||
|
||||
$this->outputHTML('login', [
|
||||
'title' => 'Api login',
|
||||
'message' => $message
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to log in with the api
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function login_action()
|
||||
{
|
||||
if (
|
||||
$this->model->authenticate(
|
||||
$this->config->hummingbird_username,
|
||||
$this->request->post->get('password')
|
||||
)
|
||||
)
|
||||
{
|
||||
$this->response->redirect->afterPost(full_url('', $this->base_data['url_type']));
|
||||
return;
|
||||
}
|
||||
|
||||
$this->login("Invalid username or password.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the appropriate response
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function output()
|
||||
{
|
||||
// send status
|
||||
@header($this->response->status->get(), true, $this->response->status->getCode());
|
||||
|
||||
// headers
|
||||
foreach($this->response->headers->get() as $label => $value)
|
||||
{
|
||||
@header("{$label}: {$value}");
|
||||
}
|
||||
|
||||
// cookies
|
||||
foreach($this->response->cookies->get() as $name => $cookie)
|
||||
{
|
||||
@setcookie(
|
||||
$name,
|
||||
$cookie['value'],
|
||||
$cookie['expire'],
|
||||
$cookie['path'],
|
||||
$cookie['domain'],
|
||||
$cookie['secure'],
|
||||
$cookie['httponly']
|
||||
);
|
||||
}
|
||||
|
||||
// send the actual response
|
||||
echo $this->response->content->get();
|
||||
}
|
||||
}
|
||||
// End of BaseController.php
|
|
@ -1,32 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Base DB model
|
||||
*/
|
||||
namespace AnimeClient;
|
||||
|
||||
/**
|
||||
* Base model for database interaction
|
||||
*/
|
||||
class BaseDBModel extends BaseModel {
|
||||
/**
|
||||
* The query builder object
|
||||
* @var object $db
|
||||
*/
|
||||
protected $db;
|
||||
|
||||
/**
|
||||
* The database connection information array
|
||||
* @var array $db_config
|
||||
*/
|
||||
protected $db_config;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_config = $this->config->database;
|
||||
}
|
||||
}
|
||||
// End of BaseDBModel.php
|
|
@ -1,106 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Base for base models
|
||||
*/
|
||||
namespace AnimeClient;
|
||||
|
||||
use abeautifulsite\SimpleImage;
|
||||
|
||||
/**
|
||||
* Common base for all Models
|
||||
*/
|
||||
class BaseModel {
|
||||
|
||||
/**
|
||||
* The global configuration object
|
||||
* @var object $config
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
global $config;
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path of the cached version of the image. Create the cached image
|
||||
* if the file does not already exist
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @param string $api_path - The original image url
|
||||
* @param string $series_slug - The part of the url with the series name, becomes the image name
|
||||
* @param string $type - Anime or Manga, controls cache path
|
||||
* @return string - the frontend path for the cached image
|
||||
*/
|
||||
public function get_cached_image($api_path, $series_slug, $type="anime")
|
||||
{
|
||||
$api_path = str_replace("jjpg", "jpg", $api_path);
|
||||
$path_parts = explode('?', basename($api_path));
|
||||
$path = current($path_parts);
|
||||
$ext_parts = explode('.', $path);
|
||||
$ext = end($ext_parts);
|
||||
|
||||
// Workaround for some broken extensions
|
||||
if ($ext == "jjpg") $ext = "jpg";
|
||||
|
||||
// Failsafe for weird urls
|
||||
if (strlen($ext) > 3) return $api_path;
|
||||
|
||||
$cached_image = "{$series_slug}.{$ext}";
|
||||
$cached_path = "{$this->config->img_cache_path}/{$type}/{$cached_image}";
|
||||
|
||||
// Cache the file if it doesn't already exist
|
||||
if ( ! file_exists($cached_path))
|
||||
{
|
||||
if (ini_get('allow_url_fopen'))
|
||||
{
|
||||
copy($api_path, $cached_path);
|
||||
}
|
||||
elseif (function_exists('curl_init'))
|
||||
{
|
||||
$ch = curl_init($api_path);
|
||||
$fp = fopen($cached_path, 'wb');
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_FILE => $fp,
|
||||
CURLOPT_HEADER => 0
|
||||
]);
|
||||
curl_exec($ch);
|
||||
curl_close($ch);
|
||||
fclose($ch);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Couldn't cache images because they couldn't be downloaded.");
|
||||
}
|
||||
|
||||
// Resize the image
|
||||
if ($type == 'anime')
|
||||
{
|
||||
$resize_width = 220;
|
||||
$resize_height = 319;
|
||||
$this->_resize($cached_path, $resize_width, $resize_height);
|
||||
}
|
||||
}
|
||||
|
||||
return "/public/images/{$type}/{$cached_image}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize an image
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @param string $path
|
||||
* @param string $width
|
||||
* @param string $height
|
||||
*/
|
||||
private function _resize($path, $width, $height)
|
||||
{
|
||||
$img = new SimpleImage($path);
|
||||
$img->resize($width,$height)->save();
|
||||
}
|
||||
}
|
||||
// End of BaseModel.php
|
|
@ -1,56 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace AnimeClient;
|
||||
|
||||
/**
|
||||
* Wrapper for configuration values
|
||||
*/
|
||||
class Config {
|
||||
|
||||
/**
|
||||
* Config object
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $config = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $config_files
|
||||
*/
|
||||
public function __construct(Array $config_files=[])
|
||||
{
|
||||
// @codeCoverageIgnoreStart
|
||||
if (empty($config_files))
|
||||
{
|
||||
require_once _dir(CONF_DIR, 'config.php'); // $config
|
||||
require_once _dir(CONF_DIR, 'base_config.php'); // $base_config
|
||||
}
|
||||
else // @codeCoverageIgnoreEnd
|
||||
{
|
||||
$config = $config_files['config'];
|
||||
$base_config = $config_files['base_config'];
|
||||
}
|
||||
|
||||
$this->config = array_merge($config, $base_config);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for config values
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($key)
|
||||
{
|
||||
if (isset($this->config[$key]))
|
||||
{
|
||||
return $this->config[$key];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
// End of config.php
|
|
@ -1,175 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Routing logic
|
||||
*/
|
||||
|
||||
namespace AnimeClient;
|
||||
|
||||
/**
|
||||
* Basic routing/ dispatch
|
||||
*/
|
||||
class Router {
|
||||
|
||||
/**
|
||||
* The route-matching object
|
||||
* @var object $router
|
||||
*/
|
||||
protected $router;
|
||||
|
||||
/**
|
||||
* The global configuration object
|
||||
* @var object $config
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* Array containing request and response objects
|
||||
* @var array $web
|
||||
*/
|
||||
protected $web;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
public function __construct(Config $config, \Aura\Router\Router $router, \Aura\Web\Request $request, \Aura\Web\Response $response)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->router = $router;
|
||||
$this->web = [$request, $response];
|
||||
|
||||
$this->_setup_routes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current route object, if one matches
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function get_route()
|
||||
{
|
||||
global $defaultHandler;
|
||||
|
||||
$raw_route = $_SERVER['REQUEST_URI'];
|
||||
$route_path = str_replace([$this->config->anime_path, $this->config->manga_path], '', $raw_route);
|
||||
$route_path = "/" . trim($route_path, '/');
|
||||
|
||||
$defaultHandler->addDataTable('Route Info', [
|
||||
'route_path' => $route_path
|
||||
]);
|
||||
|
||||
$route = $this->router->match($route_path, $_SERVER);
|
||||
|
||||
return $route;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the current route
|
||||
*
|
||||
* @param [object] $route
|
||||
* @return void
|
||||
*/
|
||||
public function dispatch($route = NULL)
|
||||
{
|
||||
global $defaultHandler;
|
||||
|
||||
if (is_null($route))
|
||||
{
|
||||
$route = $this->get_route();
|
||||
}
|
||||
|
||||
if ( ! $route)
|
||||
{
|
||||
$failure = $this->router->getFailedRoute();
|
||||
$defaultHandler->addDataTable('failed_route', (array)$failure);
|
||||
|
||||
$controller_name = 'BaseController';
|
||||
$action_method = 'outputHTML';
|
||||
$params = [
|
||||
'template' => '404',
|
||||
'data' => [
|
||||
'title' => 'Page Not Found'
|
||||
]
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
list($controller_name, $action_method) = $route->params['action'];
|
||||
$params = (isset($route->params['params'])) ? $route->params['params'] : [];
|
||||
|
||||
if ( ! empty($route->tokens))
|
||||
{
|
||||
foreach($route->tokens as $key => $v)
|
||||
{
|
||||
if (array_key_exists($key, $route->params))
|
||||
{
|
||||
$params[$key] = $route->params[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$controller = new $controller_name($this->config, $this->web);
|
||||
|
||||
// Run the appropriate controller method
|
||||
$defaultHandler->addDataTable('controller_args', $params);
|
||||
call_user_func_array([$controller, $action_method], $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Select controller based on the current url, and apply its relevent routes
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _setup_routes()
|
||||
{
|
||||
$route_map = [
|
||||
'anime' => '\\AnimeClient\\AnimeController',
|
||||
'manga' => '\\AnimeClient\\MangaController',
|
||||
];
|
||||
$route_type = "anime";
|
||||
|
||||
if ($this->config->manga_host !== "" && strpos($_SERVER['HTTP_HOST'], $this->config->manga_host) !== FALSE)
|
||||
{
|
||||
$route_type = "manga";
|
||||
}
|
||||
else if ($this->config->manga_path !== "" && strpos($_SERVER['REQUEST_URI'], $this->config->manga_path) !== FALSE)
|
||||
{
|
||||
$route_type = "manga";
|
||||
}
|
||||
|
||||
$routes = $this->config->routes;
|
||||
|
||||
// Add routes
|
||||
foreach(['common', $route_type] as $key)
|
||||
{
|
||||
foreach($routes[$key] as $name => &$route)
|
||||
{
|
||||
$path = $route['path'];
|
||||
unset($route['path']);
|
||||
|
||||
// Prepend the controller to the route parameters
|
||||
array_unshift($route['action'], $route_map[$route_type]);
|
||||
|
||||
// Select the appropriate router method based on the http verb
|
||||
$add = (array_key_exists('verb', $route)) ? "add" . ucfirst(strtolower($route['verb'])) : "addGet";
|
||||
|
||||
if ( ! array_key_exists('tokens', $route))
|
||||
{
|
||||
$this->router->$add($name, $path)->addValues($route);
|
||||
}
|
||||
else
|
||||
{
|
||||
$tokens = $route['tokens'];
|
||||
unset($route['tokens']);
|
||||
|
||||
$this->router->$add($name, $path)
|
||||
->addValues($route)
|
||||
->addTokens($tokens);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// End of Router.php
|
|
@ -1,134 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Global functions
|
||||
*/
|
||||
|
||||
/**
|
||||
* Check if the user is currently logged in
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function is_logged_in()
|
||||
{
|
||||
return array_key_exists('hummingbird_anime_token', $_SESSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* HTML selection helper function
|
||||
*
|
||||
* @param string $a - First item to compare
|
||||
* @param string $b - Second item to compare
|
||||
* @return string
|
||||
*/
|
||||
function is_selected($a, $b)
|
||||
{
|
||||
return ($a === $b) ? 'selected' : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Inverse of selected helper function
|
||||
*
|
||||
* @param string $a - First item to compare
|
||||
* @param string $b - Second item to compare
|
||||
* @return string
|
||||
*/
|
||||
function is_not_selected($a, $b)
|
||||
{
|
||||
return ($a !== $b) ? 'selected' : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the base url for css/js/images
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function asset_url(/*...*/)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$args = func_get_args();
|
||||
$base_url = rtrim($config->asset_path, '/');
|
||||
|
||||
array_unshift($args, $base_url);
|
||||
|
||||
return implode("/", $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the base url from the config
|
||||
*
|
||||
* @param string $type - (optional) The controller
|
||||
# @param object $config - (optional) Config
|
||||
* @return string
|
||||
*/
|
||||
function base_url($type="anime", $config=NULL)
|
||||
{
|
||||
if (is_null($config)) global $config;
|
||||
|
||||
|
||||
$config_path = trim($config->{"{$type}_path"}, "/");
|
||||
$config_host = $config->{"{$type}_host"};
|
||||
|
||||
// Set the appropriate HTTP host
|
||||
$host = ($config_host !== '') ? $config_host : $_SERVER['HTTP_HOST'];
|
||||
$path = ($config_path !== '') ? $config_path : "";
|
||||
|
||||
return implode("/", ['/', $host, $path]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate full url path from the route path based on config
|
||||
*
|
||||
* @param string $path - (optional) The route path
|
||||
* @param string $type - (optional) The controller (anime or manga), defaults to anime
|
||||
# @param object $config - (optional) Config
|
||||
* @return string
|
||||
*/
|
||||
function full_url($path="", $type="anime", $config=NULL)
|
||||
{
|
||||
if (is_null($config)) global $config;
|
||||
|
||||
$config_path = trim($config->{"{$type}_path"}, "/");
|
||||
$config_host = $config->{"{$type}_host"};
|
||||
$config_default_route = $config->{"default_{$type}_path"};
|
||||
|
||||
// Remove beginning/trailing slashes
|
||||
$config_path = trim($config_path, '/');
|
||||
$path = trim($path, '/');
|
||||
|
||||
// Remove any optional parameters from the route
|
||||
$path = preg_replace('`{/.*?}`i', '', $path);
|
||||
|
||||
// Set the appropriate HTTP host
|
||||
$host = ($config_host !== '') ? $config_host : $_SERVER['HTTP_HOST'];
|
||||
|
||||
// Set the default view
|
||||
if ($path === '')
|
||||
{
|
||||
$path .= trim($config_default_route, '/');
|
||||
if ($config->default_to_list_view) $path .= '/list';
|
||||
}
|
||||
|
||||
// Set an leading folder
|
||||
if ($config_path !== '')
|
||||
{
|
||||
$path = "{$config_path}/{$path}";
|
||||
}
|
||||
|
||||
return "//{$host}/{$path}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last segment of the current url
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function last_segment()
|
||||
{
|
||||
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
||||
$segments = explode('/', $path);
|
||||
return end($segments);
|
||||
}
|
||||
|
||||
// End of functions.php
|
|
@ -1,43 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Functions that need to be included before config
|
||||
*/
|
||||
|
||||
/**
|
||||
* Joins paths together. Variadic to take an
|
||||
* arbitrary number of arguments
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function _dir()
|
||||
{
|
||||
return implode(DIRECTORY_SEPARATOR, func_get_args());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up autoloaders
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @return void
|
||||
*/
|
||||
function _setup_autoloaders()
|
||||
{
|
||||
require _dir(ROOT_DIR, '/vendor/autoload.php');
|
||||
spl_autoload_register(function ($class) {
|
||||
$class_parts = explode('\\', $class);
|
||||
$class = end($class_parts);
|
||||
|
||||
$dirs = ["base", "controllers", "models"];
|
||||
|
||||
foreach($dirs as $dir)
|
||||
{
|
||||
$file = _dir(APP_DIR, $dir, "{$class}.php");
|
||||
if (file_exists($file))
|
||||
{
|
||||
require_once $file;
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
|
@ -1,57 +1,195 @@
|
|||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime List Client
|
||||
*
|
||||
* An API client for Kitsu to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 7.1
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
* @copyright 2015 - 2018 Timothy J. Warren
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @version 4.1
|
||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
namespace AnimeClient;
|
||||
namespace Aviat\AnimeClient;
|
||||
|
||||
use \Whoops\Handler\PrettyPageHandler;
|
||||
use \Whoops\Handler\JsonResponseHandler;
|
||||
use \Aura\Web\WebFactory;
|
||||
use \Aura\Router\RouterFactory;
|
||||
use \GuzzleHttp\Client;
|
||||
use \GuzzleHttp\Cookie\CookieJar;
|
||||
use Aura\Html\HelperLocatorFactory;
|
||||
use Aura\Router\RouterContainer;
|
||||
use Aura\Session\SessionFactory;
|
||||
use Aviat\AnimeClient\API\{
|
||||
Anilist,
|
||||
Kitsu,
|
||||
Kitsu\KitsuRequestBuilder
|
||||
};
|
||||
use Aviat\AnimeClient\Model;
|
||||
use Aviat\Banker\Pool;
|
||||
use Aviat\Ion\Config;
|
||||
use Aviat\Ion\Di\Container;
|
||||
use Monolog\Handler\RotatingFileHandler;
|
||||
use Monolog\Logger;
|
||||
use Zend\Diactoros\{Response, ServerRequestFactory};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Setup error handling
|
||||
// Setup DI container
|
||||
// -----------------------------------------------------------------------------
|
||||
$whoops = new \Whoops\Run();
|
||||
return static function ($configArray = []) {
|
||||
$container = new Container();
|
||||
|
||||
// Set up default handler for general errors
|
||||
$defaultHandler = new PrettyPageHandler();
|
||||
$whoops->pushHandler($defaultHandler);
|
||||
// -------------------------------------------------------------------------
|
||||
// Logging
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
// Set up json handler for ajax errors
|
||||
$jsonHandler = new JsonResponseHandler();
|
||||
$jsonHandler->onlyForAjaxRequests(true);
|
||||
$whoops->pushHandler($jsonHandler);
|
||||
$appLogger = new Logger('animeclient');
|
||||
$appLogger->pushHandler(new RotatingFileHandler(__DIR__ . '/logs/app.log', Logger::NOTICE));
|
||||
$anilistRequestLogger = new Logger('anilist-request');
|
||||
$anilistRequestLogger->pushHandler(new RotatingFileHandler(__DIR__ . '/logs/anilist_request.log', Logger::NOTICE));
|
||||
$kitsuRequestLogger = new Logger('kitsu-request');
|
||||
$kitsuRequestLogger->pushHandler(new RotatingFileHandler(__DIR__ . '/logs/kitsu_request.log', Logger::NOTICE));
|
||||
$container->setLogger($appLogger);
|
||||
$container->setLogger($anilistRequestLogger, 'anilist-request');
|
||||
$container->setLogger($kitsuRequestLogger, 'kitsu-request');
|
||||
|
||||
$whoops->register();
|
||||
// -------------------------------------------------------------------------
|
||||
// Injected Objects
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Injected Objects
|
||||
// -----------------------------------------------------------------------------
|
||||
// Create Config Object
|
||||
$container->set('config', static function() use ($configArray) {
|
||||
return new Config($configArray);
|
||||
});
|
||||
|
||||
// Create Config Object
|
||||
$config = new Config();
|
||||
require _dir(BASE_DIR, '/functions.php');
|
||||
// Create Cache Object
|
||||
$container->set('cache', static function($container) {
|
||||
$logger = $container->getLogger();
|
||||
$config = $container->get('config')->get('cache');
|
||||
return new Pool($config, $logger);
|
||||
});
|
||||
|
||||
// Create Aura Router Object
|
||||
$router_factory = new RouterFactory();
|
||||
$aura_router = $router_factory->newInstance();
|
||||
// Create List Cache
|
||||
|
||||
// Create Request/Response Objects
|
||||
$web_factory = new WebFactory([
|
||||
'_GET' => $_GET,
|
||||
'_POST' => $_POST,
|
||||
'_COOKIE' => $_COOKIE,
|
||||
'_SERVER' => $_SERVER,
|
||||
'_FILES' => $_FILES
|
||||
]);
|
||||
$request = $web_factory->newRequest();
|
||||
$response = $web_factory->newResponse();
|
||||
// Create Aura Router Object
|
||||
$container->set('aura-router', static function() {
|
||||
return new RouterContainer;
|
||||
});
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Router
|
||||
// -----------------------------------------------------------------------------
|
||||
$router = new Router($config, $aura_router, $request, $response);
|
||||
$router->dispatch();
|
||||
// Create Html helper Object
|
||||
$container->set('html-helper', static function($container) {
|
||||
$htmlHelper = (new HelperLocatorFactory)->newInstance();
|
||||
$htmlHelper->set('menu', static function() use ($container) {
|
||||
$menuHelper = new Helper\Menu();
|
||||
$menuHelper->setContainer($container);
|
||||
return $menuHelper;
|
||||
});
|
||||
$htmlHelper->set('field', static function() use ($container) {
|
||||
$formHelper = new Helper\Form();
|
||||
$formHelper->setContainer($container);
|
||||
return $formHelper;
|
||||
});
|
||||
$htmlHelper->set('picture', static function() use ($container) {
|
||||
$pictureHelper = new Helper\Picture();
|
||||
$pictureHelper->setContainer($container);
|
||||
return $pictureHelper;
|
||||
});
|
||||
|
||||
return $htmlHelper;
|
||||
});
|
||||
|
||||
// Create Request/Response Objects
|
||||
$container->set('request', static function() {
|
||||
return ServerRequestFactory::fromGlobals(
|
||||
$_SERVER,
|
||||
$_GET,
|
||||
$_POST,
|
||||
$_COOKIE,
|
||||
$_FILES
|
||||
);
|
||||
});
|
||||
$container->set('response', static function() {
|
||||
return new Response;
|
||||
});
|
||||
|
||||
// Create session Object
|
||||
$container->set('session', static function() {
|
||||
return (new SessionFactory())->newInstance($_COOKIE);
|
||||
});
|
||||
|
||||
// Miscellaneous helper methods
|
||||
$container->set('util', static function($container) {
|
||||
return new Util($container);
|
||||
});
|
||||
|
||||
// Models
|
||||
$container->set('kitsu-model', static function($container) {
|
||||
$requestBuilder = new KitsuRequestBuilder();
|
||||
$requestBuilder->setLogger($container->getLogger('kitsu-request'));
|
||||
|
||||
$listItem = new Kitsu\ListItem();
|
||||
$listItem->setContainer($container);
|
||||
$listItem->setRequestBuilder($requestBuilder);
|
||||
|
||||
$model = new Kitsu\Model($listItem);
|
||||
$model->setContainer($container);
|
||||
$model->setRequestBuilder($requestBuilder);
|
||||
|
||||
$cache = $container->get('cache');
|
||||
$model->setCache($cache);
|
||||
return $model;
|
||||
});
|
||||
$container->set('anilist-model', static function($container) {
|
||||
$requestBuilder = new Anilist\AnilistRequestBuilder();
|
||||
$requestBuilder->setLogger($container->getLogger('anilist-request'));
|
||||
|
||||
$listItem = new Anilist\ListItem();
|
||||
$listItem->setContainer($container);
|
||||
$listItem->setRequestBuilder($requestBuilder);
|
||||
|
||||
$model = new Anilist\Model($listItem);
|
||||
$model->setContainer($container);
|
||||
$model->setRequestBuilder($requestBuilder);
|
||||
|
||||
return $model;
|
||||
});
|
||||
|
||||
$container->set('api-model', static function($container) {
|
||||
return new Model\API($container);
|
||||
});
|
||||
$container->set('anime-model', static function($container) {
|
||||
return new Model\Anime($container);
|
||||
});
|
||||
$container->set('manga-model', static function($container) {
|
||||
return new Model\Manga($container);
|
||||
});
|
||||
$container->set('anime-collection-model', static function($container) {
|
||||
return new Model\AnimeCollection($container);
|
||||
});
|
||||
$container->set('manga-collection-model', static function($container) {
|
||||
return new Model\MangaCollection($container);
|
||||
});
|
||||
$container->set('settings-model', static function($container) {
|
||||
$model = new Model\Settings($container->get('config'));
|
||||
$model->setContainer($container);
|
||||
return $model;
|
||||
});
|
||||
|
||||
// Miscellaneous Classes
|
||||
$container->set('auth', static function($container) {
|
||||
return new Kitsu\Auth($container);
|
||||
});
|
||||
$container->set('url-generator', static function($container) {
|
||||
return new UrlGenerator($container);
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Dispatcher
|
||||
// -------------------------------------------------------------------------
|
||||
$container->set('dispatcher', static function($container) {
|
||||
return new Dispatcher($container);
|
||||
});
|
||||
|
||||
return $container;
|
||||
};
|
||||
|
||||
// End of bootstrap.php
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
// ----------------------------------------------------------------------------
|
||||
// Lower level configuration
|
||||
//
|
||||
// You shouldn't generally need to change anything below this line
|
||||
// ----------------------------------------------------------------------------
|
||||
$base_config = [
|
||||
// Cache paths
|
||||
'data_cache_path' => _dir(APP_DIR, 'cache'),
|
||||
'img_cache_path' => _dir(ROOT_DIR, 'public/images'),
|
||||
|
||||
// Included config files
|
||||
'routes' => require _dir(CONF_DIR, 'routes.php'),
|
||||
'database' => require _dir(CONF_DIR, 'database.php'),
|
||||
];
|
|
@ -0,0 +1,22 @@
|
|||
################################################################################
|
||||
# Cache Setup #
|
||||
################################################################################
|
||||
|
||||
# See https://git.timshomepage.net/aviat/banker for more information
|
||||
|
||||
# Available drivers are apcu, memcache, memcached, redis or null
|
||||
# Null cache driver means no caching
|
||||
driver = "redis"
|
||||
|
||||
[connection]
|
||||
# Host or socket to connect to
|
||||
host = "127.0.0.1"
|
||||
|
||||
# Connection port
|
||||
#port = 6379
|
||||
|
||||
# Connection password
|
||||
#password = ""
|
||||
|
||||
# Database number
|
||||
database = 2
|
|
@ -1,40 +0,0 @@
|
|||
<?php
|
||||
$config = [
|
||||
// ----------------------------------------------------------------------------
|
||||
// Username for anime and manga lists
|
||||
// ----------------------------------------------------------------------------
|
||||
'hummingbird_username' => 'timw4mail',
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// General config
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// do you wish to show the anime collection tab?
|
||||
'show_anime_collection' => TRUE,
|
||||
|
||||
// path to public directory
|
||||
'asset_path' => '//' . $_SERVER['HTTP_HOST'] . '/public',
|
||||
|
||||
// path to public directory on the server
|
||||
'asset_dir' => __DIR__ . '/../../public',
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Routing
|
||||
//
|
||||
// Route by path, or route by domain. To route by path, set the _host suffixed
|
||||
// options to an empty string. To route by host, set the _path suffixed options
|
||||
// to an empty string
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
'anime_host' => 'anime.timshomepage.net',
|
||||
'manga_host' => 'manga.timshomepage.net',
|
||||
'anime_path' => '',
|
||||
'manga_path' => '',
|
||||
|
||||
// Default pages for anime/manga
|
||||
'default_anime_path' => '/watching',
|
||||
'default_manga_path' => '/all',
|
||||
|
||||
// Default to list view?
|
||||
'default_to_list_view' => FALSE,
|
||||
];
|
|
@ -0,0 +1,36 @@
|
|||
################################################################################
|
||||
# Main User Configuration #
|
||||
################################################################################
|
||||
|
||||
# Username for anime and manga lists
|
||||
kitsu_username = "johnsmith"
|
||||
|
||||
# Whose list is it?
|
||||
whose_list = "Someone"
|
||||
|
||||
# do you wish to show the anime collection?
|
||||
show_anime_collection = true
|
||||
|
||||
# do you wish to show the manga collection?
|
||||
show_manga_collection = false
|
||||
|
||||
################################################################################
|
||||
# Default views and paths
|
||||
################################################################################
|
||||
|
||||
# Which list should be the default?
|
||||
default_list = "anime" # anime or manga
|
||||
|
||||
# Default pages for anime/manga
|
||||
default_anime_list_path = "watching" # watching|plan_to_watch|on_hold|dropped|completed|all
|
||||
default_manga_list_path = "reading" # reading|plan_to_read|on_hold|dropped|completed|all
|
||||
|
||||
################################################################################
|
||||
# Not on Settings Page
|
||||
#
|
||||
# These settings are not available to change on the settings page
|
||||
################################################################################
|
||||
|
||||
# Use HTTPs for URLs
|
||||
# It is not recommended to change this setting
|
||||
secure_urls = true
|
|
@ -1,13 +0,0 @@
|
|||
<?php
|
||||
return [
|
||||
'collection' => [
|
||||
'type' => 'sqlite',
|
||||
'host' => '',
|
||||
'user' => '',
|
||||
'pass' => '',
|
||||
'port' => '',
|
||||
'name' => 'default',
|
||||
'database' => '',
|
||||
'file' => __DIR__ . '/../../anime_collection.sqlite',
|
||||
]
|
||||
];
|
|
@ -0,0 +1,11 @@
|
|||
################################################################################
|
||||
# Database Configuration #
|
||||
################################################################################
|
||||
|
||||
type = "sqlite"
|
||||
host = ""
|
||||
user = ""
|
||||
pass = ""
|
||||
port = ""
|
||||
database = ""
|
||||
file = "anime_collection.sqlite3"
|
|
@ -1,60 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Easy Min
|
||||
*
|
||||
* Simple minification for better website performance
|
||||
*
|
||||
* @author Timothy J. Warren
|
||||
* @copyright Copyright (c) 2012
|
||||
* @link https://github.com/aviat4ion/Easy-Min
|
||||
* @license http://philsturgeon.co.uk/code/dbad-license
|
||||
*/
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/* $config = */require 'config.php';
|
||||
|
||||
$config = (object)$config;
|
||||
|
||||
// Should we use myth to preprocess?
|
||||
$use_myth = FALSE;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| CSS Folder
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The folder where css files exist, in relation to the document root
|
||||
|
|
||||
*/
|
||||
$css_root = $config->asset_dir. '/css/';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Path from
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Path fragment to rewrite in css files
|
||||
|
|
||||
*/
|
||||
$path_from = '';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Path to
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The path fragment replacement for the css files
|
||||
|
|
||||
*/
|
||||
$path_to = '';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| JS Folder
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The folder where javascript files exist, in relation to the document root
|
||||
|
|
||||
*/
|
||||
$js_root = $config->asset_dir. '/js/';
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Easy Min
|
||||
*
|
||||
* Simple minification for better website performance
|
||||
*
|
||||
* @author Timothy J. Warren
|
||||
* @copyright Copyright (c) 2012
|
||||
* @link https://github.com/aviat4ion/Easy-Min
|
||||
* @license http://philsturgeon.co.uk/code/dbad-license
|
||||
*/
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* This is the config array for css files to concatenate and minify
|
||||
*/
|
||||
return [
|
||||
/*-----
|
||||
Css
|
||||
-----*/
|
||||
|
||||
/*
|
||||
For each group create an array like so
|
||||
|
||||
'my_group' => array(
|
||||
'path/to/css/file1.css',
|
||||
'path/to/css/file2.css'
|
||||
),
|
||||
*/
|
||||
'base' => [
|
||||
'marx.css',
|
||||
'base.css'
|
||||
]
|
||||
];
|
||||
// End of css_groups.php
|
|
@ -1,40 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Easy Min
|
||||
*
|
||||
* Simple minification for better website performance
|
||||
*
|
||||
* @author Timothy J. Warren
|
||||
* @copyright Copyright (c) 2012
|
||||
* @link https://github.com/aviat4ion/Easy-Min
|
||||
* @license http://philsturgeon.co.uk/code/dbad-license
|
||||
*/
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* This is the config array for javascript files to concatenate and minify
|
||||
*/
|
||||
return [
|
||||
/*
|
||||
For each group create an array like so
|
||||
|
||||
'my_group' => array(
|
||||
'path/to/js/file1.js',
|
||||
'path/to/js/file2.js'
|
||||
),
|
||||
*/
|
||||
'table' => [
|
||||
'lib/jquery.min.js',
|
||||
'lib/table_sorter/jquery.tablesorter.min.js',
|
||||
'sort_tables.js'
|
||||
],
|
||||
'edit' => [
|
||||
'lib/jquery.min.js',
|
||||
'show_message.js',
|
||||
'anime_edit.js',
|
||||
'manga_edit.js'
|
||||
]
|
||||
];
|
||||
|
||||
// End of js_groups.php
|
|
@ -1,188 +0,0 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
// Routes on all controllers
|
||||
'common' => [
|
||||
'update' => [
|
||||
'path' => '/update',
|
||||
'action' => ['update'],
|
||||
'verb' => 'post'
|
||||
],
|
||||
'login_form' => [
|
||||
'path' => '/login',
|
||||
'action' => ['login'],
|
||||
'verb' => 'get'
|
||||
],
|
||||
'login_action' => [
|
||||
'path' => '/login',
|
||||
'action' => ['login_action'],
|
||||
'verb' => 'post'
|
||||
],
|
||||
'logout' => [
|
||||
'path' => '/logout',
|
||||
'action' => ['logout']
|
||||
],
|
||||
],
|
||||
// Routes on anime controller
|
||||
'anime' => [
|
||||
'index' => [
|
||||
'path' => '/',
|
||||
'action' => ['redirect'],
|
||||
'params' => [
|
||||
'url' => '', // Determined by config
|
||||
'code' => '301'
|
||||
]
|
||||
],
|
||||
'all' => [
|
||||
'path' => '/all{/view}',
|
||||
'action' => ['anime_list'],
|
||||
'params' => [
|
||||
'type' => 'all',
|
||||
'title' => WHOSE . " Anime List · All"
|
||||
],
|
||||
'tokens' => [
|
||||
'view' => '[a-z_]+'
|
||||
]
|
||||
],
|
||||
'watching' => [
|
||||
'path' => '/watching{/view}',
|
||||
'action' => ['anime_list'],
|
||||
'params' => [
|
||||
'type' => 'currently-watching',
|
||||
'title' => WHOSE . " Anime List · Watching"
|
||||
],
|
||||
'tokens' => [
|
||||
'view' => '[a-z_]+'
|
||||
]
|
||||
],
|
||||
'plan_to_watch' => [
|
||||
'path' => '/plan_to_watch{/view}',
|
||||
'action' => ['anime_list'],
|
||||
'params' => [
|
||||
'type' => 'plan-to-watch',
|
||||
'title' => WHOSE . " Anime List · Plan to Watch"
|
||||
],
|
||||
'tokens' => [
|
||||
'view' => '[a-z_]+'
|
||||
]
|
||||
],
|
||||
'on_hold' => [
|
||||
'path' => '/on_hold{/view}',
|
||||
'action' => ['anime_list'],
|
||||
'params' => [
|
||||
'type' => 'on-hold',
|
||||
'title' => WHOSE . " Anime List · On Hold"
|
||||
],
|
||||
'tokens' => [
|
||||
'view' => '[a-z_]+'
|
||||
]
|
||||
],
|
||||
'dropped' => [
|
||||
'path' => '/dropped{/view}',
|
||||
'action' => ['anime_list'],
|
||||
'params' => [
|
||||
'type' => 'dropped',
|
||||
'title' => WHOSE . " Anime List · Dropped"
|
||||
],
|
||||
'tokens' => [
|
||||
'view' => '[a-z_]+'
|
||||
]
|
||||
],
|
||||
'completed' => [
|
||||
'path' => '/completed{/view}',
|
||||
'action' => ['anime_list'],
|
||||
'params' => [
|
||||
'type' => 'completed',
|
||||
'title' => WHOSE . " Anime List · Completed"
|
||||
],
|
||||
'tokens' => [
|
||||
'view' => '[a-z_]+'
|
||||
]
|
||||
],
|
||||
'collection' => [
|
||||
'path' => '/collection{/view}',
|
||||
'action' => ['collection'],
|
||||
'params' => [],
|
||||
'tokens' => [
|
||||
'view' => '[a-z_]+'
|
||||
]
|
||||
]
|
||||
],
|
||||
'manga' => [
|
||||
'index' => [
|
||||
'path' => '/',
|
||||
'action' => ['redirect'],
|
||||
'params' => [
|
||||
'url' => '', // Determined by config
|
||||
'code' => '301',
|
||||
'type' => 'manga'
|
||||
]
|
||||
],
|
||||
'all' => [
|
||||
'path' => '/all{/view}',
|
||||
'action' => ['manga_list'],
|
||||
'params' => [
|
||||
'type' => 'all',
|
||||
'title' => WHOSE . " Manga List · All"
|
||||
],
|
||||
'tokens' => [
|
||||
'view' => '[a-z_]+'
|
||||
]
|
||||
],
|
||||
'reading' => [
|
||||
'path' => '/reading{/view}',
|
||||
'action' => ['manga_list'],
|
||||
'params' => [
|
||||
'type' => 'Reading',
|
||||
'title' => WHOSE . " Manga List · Reading"
|
||||
],
|
||||
'tokens' => [
|
||||
'view' => '[a-z_]+'
|
||||
]
|
||||
],
|
||||
'plan_to_read' => [
|
||||
'path' => '/plan_to_read{/view}',
|
||||
'action' => ['manga_list'],
|
||||
'params' => [
|
||||
'type' => 'Plan to Read',
|
||||
'title' => WHOSE . " Manga List · Plan to Read"
|
||||
],
|
||||
'tokens' => [
|
||||
'view' => '[a-z_]+'
|
||||
]
|
||||
],
|
||||
'on_hold' => [
|
||||
'path' => '/on_hold{/view}',
|
||||
'action' => ['manga_list'],
|
||||
'params' => [
|
||||
'type' => 'On Hold',
|
||||
'title' => WHOSE . " Manga List · On Hold"
|
||||
],
|
||||
'tokens' => [
|
||||
'view' => '[a-z_]+'
|
||||
]
|
||||
],
|
||||
'dropped' => [
|
||||
'path' => '/dropped{/view}',
|
||||
'action' => ['manga_list'],
|
||||
'params' => [
|
||||
'type' => 'Dropped',
|
||||
'title' => WHOSE . " Manga List · Dropped"
|
||||
],
|
||||
'tokens' => [
|
||||
'view' => '[a-z_]+'
|
||||
]
|
||||
],
|
||||
'completed' => [
|
||||
'path' => '/completed{/view}',
|
||||
'action' => ['manga_list'],
|
||||
'params' => [
|
||||
'type' => 'Completed',
|
||||
'title' => WHOSE . " Manga List · Completed"
|
||||
],
|
||||
'tokens' => [
|
||||
'view' => '[a-z_]+'
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
|
@ -1,121 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Anime Controller
|
||||
*/
|
||||
|
||||
namespace AnimeClient;
|
||||
|
||||
/**
|
||||
* Controller for Anime-related pages
|
||||
*/
|
||||
class AnimeController extends BaseController {
|
||||
|
||||
/**
|
||||
* The anime list model
|
||||
* @var object $model
|
||||
*/
|
||||
protected $model;
|
||||
|
||||
/**
|
||||
* The anime collection model
|
||||
* @var object $collection_model
|
||||
*/
|
||||
private $collection_model;
|
||||
|
||||
/**
|
||||
* Data to ve sent to all routes in this controller
|
||||
* @var array $base_data
|
||||
*/
|
||||
protected $base_data;
|
||||
|
||||
/**
|
||||
* Route mapping for main navigation
|
||||
* @var array $nav_routes
|
||||
*/
|
||||
private $nav_routes = [
|
||||
'Watching' => '/watching{/view}',
|
||||
'Plan to Watch' => '/plan_to_watch{/view}',
|
||||
'On Hold' => '/on_hold{/view}',
|
||||
'Dropped' => '/dropped{/view}',
|
||||
'Completed' => '/completed{/view}',
|
||||
'Collection' => '/collection{/view}',
|
||||
'All' => '/all{/view}'
|
||||
];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct(Config $config, Array $web)
|
||||
{
|
||||
parent::__construct($config, $web);
|
||||
|
||||
if ($this->config->show_anime_collection === FALSE)
|
||||
{
|
||||
unset($this->nav_routes['Collection']);
|
||||
}
|
||||
|
||||
$this->model = new AnimeModel();
|
||||
$this->collection_model = new AnimeCollectionModel();
|
||||
$this->base_data = [
|
||||
'message' => '',
|
||||
'url_type' => 'anime',
|
||||
'other_type' => 'manga',
|
||||
'nav_routes' => $this->nav_routes,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a portion, or all of the anime list
|
||||
*
|
||||
* @param string $type - The section of the list
|
||||
* @param string $title - The title of the page
|
||||
* @return void
|
||||
*/
|
||||
public function anime_list($type, $title, $view)
|
||||
{
|
||||
$view_map = [
|
||||
'' => 'cover',
|
||||
'list' => 'list'
|
||||
];
|
||||
|
||||
$data = ($type != 'all')
|
||||
? $this->model->get_list($type)
|
||||
: $this->model->get_all_lists();
|
||||
|
||||
$this->outputHTML('anime/' . $view_map[$view], [
|
||||
'title' => $title,
|
||||
'sections' => $data
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the anime collection page
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function collection($view)
|
||||
{
|
||||
$view_map = [
|
||||
'' => 'collection',
|
||||
'list' => 'collection_list'
|
||||
];
|
||||
|
||||
$data = $this->collection_model->get_collection();
|
||||
|
||||
$this->outputHTML('anime/' . $view_map[$view], [
|
||||
'title' => WHOSE . " Anime Collection",
|
||||
'sections' => $data
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an anime item
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
print_r($this->model->update($this->request->post->get()));
|
||||
}
|
||||
}
|
||||
// End of AnimeController.php
|
|
@ -1,87 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Manga Controller
|
||||
*/
|
||||
namespace AnimeClient;
|
||||
|
||||
/**
|
||||
* Controller for manga list
|
||||
*/
|
||||
class MangaController extends BaseController {
|
||||
|
||||
/**
|
||||
* The manga model
|
||||
* @var object $model
|
||||
*/
|
||||
protected $model;
|
||||
|
||||
/**
|
||||
* Data to ve sent to all routes in this controller
|
||||
* @var array $base_data
|
||||
*/
|
||||
protected $base_data;
|
||||
|
||||
|
||||
/**
|
||||
* Route mapping for main navigation
|
||||
* @var array $nav_routes
|
||||
*/
|
||||
private $nav_routes = [
|
||||
'Reading' => '/reading{/view}',
|
||||
'Plan to Read' => '/plan_to_read{/view}',
|
||||
'On Hold' => '/on_hold{/view}',
|
||||
'Dropped' => '/dropped{/view}',
|
||||
'Completed' => '/completed{/view}',
|
||||
'All' => '/all{/view}'
|
||||
];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct(Config $config, Array $web)
|
||||
{
|
||||
parent::__construct($config, $web);
|
||||
$this->model = new MangaModel();
|
||||
$this->base_data = [
|
||||
'url_type' => 'manga',
|
||||
'other_type' => 'anime',
|
||||
'nav_routes' => $this->nav_routes
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an anime item
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
$this->outputJSON($this->model->update($this->request->post->get()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a section of the manga list
|
||||
*
|
||||
* @param string $status
|
||||
* @param string $title
|
||||
* @param string $view
|
||||
* @return void
|
||||
*/
|
||||
public function manga_list($status, $title, $view)
|
||||
{
|
||||
$view_map = [
|
||||
'' => 'cover',
|
||||
'list' => 'list'
|
||||
];
|
||||
|
||||
$data = ($status !== 'all')
|
||||
? [$status => $this->model->get_list($status)]
|
||||
: $this->model->get_all_lists();
|
||||
|
||||
$this->outputHTML('manga/' . $view_map[$view], [
|
||||
'title' => $title,
|
||||
'sections' => $data
|
||||
]);
|
||||
}
|
||||
}
|
||||
// End of MangaController.php
|
|
@ -1,206 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Anime Collection DB Model
|
||||
*/
|
||||
|
||||
namespace AnimeClient;
|
||||
|
||||
/**
|
||||
* Model for getting anime collection data
|
||||
*/
|
||||
class AnimeCollectionModel extends BaseDBModel {
|
||||
|
||||
/**
|
||||
* Anime API Model
|
||||
* @var object $anime_model
|
||||
*/
|
||||
private $anime_model;
|
||||
|
||||
/**
|
||||
* Whether the database is valid for querying
|
||||
* @var bool
|
||||
*/
|
||||
private $valid_database = FALSE;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->db = \Query($this->db_config['collection']);
|
||||
$this->anime_model = new AnimeModel();
|
||||
|
||||
// Is database valid? If not, set a flag so the
|
||||
// app can be run without a valid database
|
||||
$db_file = file_get_contents($this->db_config['collection']['file']);
|
||||
$this->valid_database = (strpos($db_file, 'SQLite format 3') === 0);
|
||||
|
||||
|
||||
// Do an import if an import file exists
|
||||
$this->json_import();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collection from the database, and organize by media type
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_collection()
|
||||
{
|
||||
$raw_collection = $this->_get_collection();
|
||||
|
||||
$collection = [];
|
||||
|
||||
foreach($raw_collection as $row)
|
||||
{
|
||||
if (array_key_exists($row['media'], $collection))
|
||||
{
|
||||
$collection[$row['media']][] = $row;
|
||||
}
|
||||
else
|
||||
{
|
||||
$collection[$row['media']] = [$row];
|
||||
}
|
||||
}
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get full collection from the database
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function _get_collection()
|
||||
{
|
||||
if ( ! $this->valid_database) return [];
|
||||
|
||||
$query = $this->db->select('hummingbird_id, slug, title, alternate_title, show_type, age_rating, episode_count, episode_length, cover_image, notes, media.type as media')
|
||||
->from('anime_set a')
|
||||
->join('media', 'media.id=a.media_id', 'inner')
|
||||
->order_by('media')
|
||||
->order_by('title')
|
||||
->get();
|
||||
|
||||
return $query->fetchAll(\PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
/**
|
||||
* Import anime into collection from a json file
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function json_import()
|
||||
{
|
||||
if ( ! file_exists('import.json')) return;
|
||||
if ( ! $this->valid_database) return;
|
||||
|
||||
$anime = json_decode(file_get_contents("import.json"));
|
||||
|
||||
foreach($anime as $item)
|
||||
{
|
||||
$this->db->set([
|
||||
'hummingbird_id' => $item->id,
|
||||
'slug' => $item->slug,
|
||||
'title' => $item->title,
|
||||
'alternate_title' => $item->alternate_title,
|
||||
'show_type' => $item->show_type,
|
||||
'age_rating' => $item->age_rating,
|
||||
'cover_image' => $this->get_cached_image($item->cover_image, $item->slug, 'anime'),
|
||||
'episode_count' => $item->episode_count,
|
||||
'episode_length' => $item->episode_length
|
||||
])->insert('anime_set');
|
||||
}
|
||||
|
||||
// Delete the import file
|
||||
unlink('import.json');
|
||||
|
||||
// Update genre info
|
||||
$this->update_genres();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update genre information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function update_genres()
|
||||
{
|
||||
$genres = [];
|
||||
$flipped_genres = [];
|
||||
|
||||
$links = [];
|
||||
|
||||
// Get existing genres
|
||||
$query = $this->db->select('id, genre')
|
||||
->from('genres')
|
||||
->get();
|
||||
foreach($query->fetchAll(PDO::FETCH_ASSOC) as $genre)
|
||||
{
|
||||
$genres[$genre['id']] = $genre['genre'];
|
||||
}
|
||||
|
||||
// Get existing link table entries
|
||||
$query = $this->db->select('hummingbird_id, genre_id')
|
||||
->from('genre_anime_set_link')
|
||||
->get();
|
||||
foreach($query->fetchAll(PDO::FETCH_ASSOC) as $link)
|
||||
{
|
||||
if (array_key_exists($link['hummingbird_id'], $links))
|
||||
{
|
||||
$links[$link['hummingbird_id']][] = $link['genre_id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$links[$link['hummingbird_id']] = [$link['genre_id']];
|
||||
}
|
||||
}
|
||||
|
||||
// Get the anime collection
|
||||
$collection = $this->_get_collection();
|
||||
foreach($collection as $anime)
|
||||
{
|
||||
// Get api information
|
||||
$api = $this->anime_model->get_anime($anime['hummingbird_id']);
|
||||
|
||||
|
||||
foreach($api['genres'] as $genre)
|
||||
{
|
||||
// Add genres that don't currently exist
|
||||
if ( ! in_array($genre['name'], $genres))
|
||||
{
|
||||
$this->db->set('genre', $genre['name'])
|
||||
->insert('genres');
|
||||
|
||||
$genres[] = $genre['name'];
|
||||
}
|
||||
|
||||
|
||||
// Update link table
|
||||
|
||||
// Get id of genre to put in link table
|
||||
$flipped_genres = array_flip($genres);
|
||||
|
||||
$insert_array = [
|
||||
'hummingbird_id' => $anime['hummingbird_id'],
|
||||
'genre_id' => $flipped_genres[$genre['name']]
|
||||
];
|
||||
|
||||
if (array_key_exists($anime['hummingbird_id'], $links))
|
||||
{
|
||||
if ( ! in_array($flipped_genres[$genre['name']], $links[$anime['hummingbird_id']]))
|
||||
{
|
||||
$this->db->set($insert_array)->insert('genre_anime_set_link');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->set($insert_array)->insert('genre_anime_set_link');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// End of AnimeCollectionModel.php
|
|
@ -1,245 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Anime API Model
|
||||
*/
|
||||
|
||||
namespace AnimeClient;
|
||||
|
||||
/**
|
||||
* Model for handling requests dealing with the anime list
|
||||
*/
|
||||
class AnimeModel extends BaseApiModel {
|
||||
/**
|
||||
* The base url for api requests
|
||||
* @var string $base_url
|
||||
*/
|
||||
protected $base_url = "https://hummingbird.me/api/v1/";
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the selected anime
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function update($data)
|
||||
{
|
||||
$data['auth_token'] = $_SESSION['hummingbird_anime_token'];
|
||||
|
||||
$result = $this->client->post("libraries/{$data['id']}", [
|
||||
'body' => $data
|
||||
]);
|
||||
|
||||
return $result->json();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the full set of anime lists
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_all_lists()
|
||||
{
|
||||
$output = [
|
||||
'Watching' => [],
|
||||
'Plan to Watch' => [],
|
||||
'On Hold' => [],
|
||||
'Dropped' => [],
|
||||
'Completed' => [],
|
||||
];
|
||||
|
||||
$data = $this->_get_list();
|
||||
|
||||
foreach($data as $datum)
|
||||
{
|
||||
switch($datum['status'])
|
||||
{
|
||||
case "completed":
|
||||
$output['Completed'][] = $datum;
|
||||
break;
|
||||
|
||||
case "plan-to-watch":
|
||||
$output['Plan to Watch'][] = $datum;
|
||||
break;
|
||||
|
||||
case "dropped":
|
||||
$output['Dropped'][] = $datum;
|
||||
break;
|
||||
|
||||
case "on-hold":
|
||||
$output['On Hold'][] = $datum;
|
||||
break;
|
||||
|
||||
case "currently-watching":
|
||||
$output['Watching'][] = $datum;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Sort anime by name
|
||||
foreach($output as &$status_list)
|
||||
{
|
||||
$this->sort_by_name($status_list);
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a category out of the full list
|
||||
*
|
||||
* @param string $status
|
||||
* @return array
|
||||
*/
|
||||
public function get_list($status)
|
||||
{
|
||||
$map = [
|
||||
'currently-watching' => 'Watching',
|
||||
'plan-to-watch' => 'Plan to Watch',
|
||||
'on-hold' => 'On Hold',
|
||||
'dropped' => 'Dropped',
|
||||
'completed' => 'Completed',
|
||||
];
|
||||
|
||||
$data = $this->_get_list($status);
|
||||
$this->sort_by_name($data);
|
||||
|
||||
$output = [];
|
||||
$output[$map[$status]] = $data;
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about an anime from its id
|
||||
*
|
||||
* @param string $anime_id
|
||||
* @return array
|
||||
*/
|
||||
public function get_anime($anime_id)
|
||||
{
|
||||
$config = [
|
||||
'query' => [
|
||||
'id' => $anime_id
|
||||
]
|
||||
];
|
||||
|
||||
$response = $this->client->get("anime/{$anime_id}", $config);
|
||||
|
||||
return $response->json();
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for anime by name
|
||||
*
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
public function search($name)
|
||||
{
|
||||
global $defaultHandler;
|
||||
|
||||
$config = [
|
||||
'query' => [
|
||||
'query' => $name
|
||||
]
|
||||
];
|
||||
|
||||
$response = $this->client->get('search/anime', $config);
|
||||
$defaultHandler->addDataTable('anime_search_response', (array)$response);
|
||||
|
||||
if ($response->getStatusCode() != 200)
|
||||
{
|
||||
throw new Exception($response->getEffectiveUrl());
|
||||
}
|
||||
|
||||
return $response->json();
|
||||
}
|
||||
|
||||
/**
|
||||
* Actually retreive the data from the api
|
||||
*
|
||||
* @param string $status - Status to filter by
|
||||
* @return array
|
||||
*/
|
||||
private function _get_list($status="all")
|
||||
{
|
||||
global $defaultHandler;
|
||||
|
||||
$cache_file = "{$this->config->data_cache_path}/anime-{$status}.json";
|
||||
|
||||
$config = [
|
||||
'allow_redirects' => FALSE
|
||||
];
|
||||
|
||||
if ($status != "all")
|
||||
{
|
||||
$config['query']['status'] = $status;
|
||||
}
|
||||
|
||||
$response = $this->client->get("users/{$this->config->hummingbird_username}/library", $config);
|
||||
|
||||
$defaultHandler->addDataTable('anime_list_response', (array)$response);
|
||||
|
||||
if ($response->getStatusCode() != 200)
|
||||
{
|
||||
if ( ! file_exists($cache_file))
|
||||
{
|
||||
throw new Exception($response->getEffectiveUrl());
|
||||
}
|
||||
else
|
||||
{
|
||||
$output = json_decode(file_get_contents($cache_file), TRUE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$output = $response->json();
|
||||
$output_json = json_encode($output);
|
||||
|
||||
if (( ! file_exists($cache_file)) || file_get_contents($cache_file) !== $output_json)
|
||||
{
|
||||
// Attempt to create the cache folder if it doesn't exist
|
||||
if ( ! is_dir($this->config->data_cache_path))
|
||||
{
|
||||
mkdir($this->config->data_cache_path);
|
||||
}
|
||||
// Cache the call in case of downtime
|
||||
file_put_contents($cache_file, json_encode($output));
|
||||
}
|
||||
}
|
||||
|
||||
foreach($output as &$row)
|
||||
{
|
||||
$row['anime']['cover_image'] = $this->get_cached_image($row['anime']['cover_image'], $row['anime']['slug'], 'anime');
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the list by title
|
||||
*
|
||||
* @param array $array
|
||||
* @return void
|
||||
*/
|
||||
private function sort_by_name(&$array)
|
||||
{
|
||||
$sort = array();
|
||||
|
||||
foreach($array as $key => $item)
|
||||
{
|
||||
$sort[$key] = $item['anime']['title'];
|
||||
}
|
||||
|
||||
array_multisort($sort, SORT_ASC, $array);
|
||||
}
|
||||
}
|
||||
// End of AnimeModel.php
|
|
@ -1,193 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Manga API Model
|
||||
*/
|
||||
namespace AnimeClient;
|
||||
|
||||
/**
|
||||
* Model for handling requests dealing with the manga list
|
||||
*/
|
||||
class MangaModel extends BaseApiModel {
|
||||
|
||||
/**
|
||||
* The base url for api requests
|
||||
* @var string
|
||||
*/
|
||||
protected $base_url = "https://hummingbird.me/";
|
||||
|
||||
|
||||
/**
|
||||
* Update the selected manga
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function update($data)
|
||||
{
|
||||
$id = $data['id'];
|
||||
unset($data['id']);
|
||||
|
||||
$result = $this->client->put("manga_library_entries/{$id}", [
|
||||
'cookies' => ['token' => $_SESSION['hummingbird_anime_token']],
|
||||
'json' => ['manga_library_entry' => $data]
|
||||
]);
|
||||
|
||||
return $result->json();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the full set of anime lists
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_all_lists()
|
||||
{
|
||||
$data = $this->_get_list();
|
||||
|
||||
foreach ($data as $key => &$val)
|
||||
{
|
||||
$this->sort_by_name($val);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a category out of the full list
|
||||
*
|
||||
* @param string $status
|
||||
* @return array
|
||||
*/
|
||||
public function get_list($status)
|
||||
{
|
||||
$data = $this->_get_list($status);
|
||||
|
||||
$this->sort_by_name($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Massage the list of manga entries into something more usable
|
||||
*
|
||||
* @param string $status
|
||||
* @return array
|
||||
*/
|
||||
private function _get_list($status="all")
|
||||
{
|
||||
global $defaultHandler;
|
||||
|
||||
$cache_file = _dir($this->config->data_cache_path, 'manga.json');
|
||||
|
||||
$config = [
|
||||
'query' => [
|
||||
'user_id' => $this->config->hummingbird_username
|
||||
],
|
||||
'allow_redirects' => FALSE
|
||||
];
|
||||
|
||||
$response = $this->client->get('manga_library_entries', $config);
|
||||
|
||||
$defaultHandler->addDataTable('response', (array)$response);
|
||||
|
||||
if ($response->getStatusCode() != 200)
|
||||
{
|
||||
if ( ! file_exists($cache_file))
|
||||
{
|
||||
throw new Exception($response->getEffectiveUrl());
|
||||
}
|
||||
else
|
||||
{
|
||||
$raw_data = json_decode(file_get_contents($cache_file), TRUE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reorganize data to be more usable
|
||||
$raw_data = $response->json();
|
||||
|
||||
// Attempt to create the cache dir if it doesn't exist
|
||||
if ( ! is_dir($this->config->data_cache_path))
|
||||
{
|
||||
mkdir($this->config->data_cache_path);
|
||||
}
|
||||
|
||||
// Cache data in case of downtime
|
||||
file_put_contents($cache_file, json_encode($raw_data));
|
||||
}
|
||||
|
||||
// Bail out early if there isn't any manga data
|
||||
if (empty($raw_data)) return [];
|
||||
|
||||
$data = [
|
||||
'Reading' => [],
|
||||
'Plan to Read' => [],
|
||||
'On Hold' => [],
|
||||
'Dropped' => [],
|
||||
'Completed' => [],
|
||||
];
|
||||
$manga_data = [];
|
||||
|
||||
// Massage the two lists into one
|
||||
foreach($raw_data['manga'] as $manga)
|
||||
{
|
||||
$manga_data[$manga['id']] = $manga;
|
||||
}
|
||||
|
||||
// Filter data by status
|
||||
foreach($raw_data['manga_library_entries'] as &$entry)
|
||||
{
|
||||
$entry['manga'] = $manga_data[$entry['manga_id']];
|
||||
|
||||
// Cache poster images
|
||||
$entry['manga']['poster_image'] = $this->get_cached_image($entry['manga']['poster_image'], $entry['manga_id'], 'manga');
|
||||
|
||||
switch($entry['status'])
|
||||
{
|
||||
case "Plan to Read":
|
||||
$data['Plan to Read'][] = $entry;
|
||||
break;
|
||||
|
||||
case "Dropped":
|
||||
$data['Dropped'][] = $entry;
|
||||
break;
|
||||
|
||||
case "On Hold":
|
||||
$data['On Hold'][] = $entry;
|
||||
break;
|
||||
|
||||
case "Currently Reading":
|
||||
$data['Reading'][] = $entry;
|
||||
break;
|
||||
|
||||
case "Completed":
|
||||
default:
|
||||
$data['Completed'][] = $entry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//file_put_contents(_dir($this->config->data_cache_path, "manga-processed.json"), json_encode($data, JSON_PRETTY_PRINT));
|
||||
|
||||
return (array_key_exists($status, $data)) ? $data[$status] : $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the manga entries by their title
|
||||
*
|
||||
* @param array $array
|
||||
* @return void
|
||||
*/
|
||||
private function sort_by_name(&$array)
|
||||
{
|
||||
$sort = array();
|
||||
|
||||
foreach($array as $key => $item)
|
||||
{
|
||||
$sort[$key] = $item['manga']['romaji_title'];
|
||||
}
|
||||
|
||||
array_multisort($sort, SORT_ASC, $array);
|
||||
}
|
||||
}
|
||||
// End of MangaModel.php
|
|
@ -1,7 +1,6 @@
|
|||
<body>
|
||||
<main>
|
||||
<h1>404</h1>
|
||||
<h2>Page Not Found</h2>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
<main>
|
||||
<h1>404</h1>
|
||||
<h2><?= $message ?></h2>
|
||||
<pre>(╯°□°)╯︵ ┻━┻
|
||||
┬─┬ノ( º _ ºノ)</pre>
|
||||
</main>
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<main>
|
||||
<h2>Add Anime to your List</h2>
|
||||
<form action="<?= $action_url ?>" method="post">
|
||||
<section>
|
||||
<div class="cssload-loader" hidden="hidden">
|
||||
<div class="cssload-inner cssload-one"></div>
|
||||
<div class="cssload-inner cssload-two"></div>
|
||||
<div class="cssload-inner cssload-three"></div>
|
||||
</div>
|
||||
<label for="search">Search for anime by name: <input type="search" id="search" /></label>
|
||||
<section id="series-list" class="media-wrap">
|
||||
</section>
|
||||
</section>
|
||||
<br />
|
||||
<table class="invisible form">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><label for="status">Watching Status</label></td>
|
||||
<td>
|
||||
<select name="status" id="status">
|
||||
<?php foreach($status_list as $status_key => $status_title): ?>
|
||||
<option value="<?= $status_key ?>"><?= $status_title ?></option>
|
||||
<?php endforeach ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>
|
||||
<input type="hidden" name="type" value="anime" />
|
||||
<button type="submit">Save</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</main>
|
||||
<?php endif ?>
|
|
@ -1,28 +0,0 @@
|
|||
<main>
|
||||
<?php foreach ($sections as $name => $items): ?>
|
||||
<section class="status">
|
||||
<h2><?= $name ?></h2>
|
||||
<section class="media-wrap">
|
||||
<?php foreach($items as $item): ?>
|
||||
<a href="https://hummingbird.me/anime/<?= $item['slug'] ?>">
|
||||
<article class="media" id="a-<?= $item['hummingbird_id'] ?>">
|
||||
<img src="<?= $item['cover_image'] ?>" />
|
||||
<div class="name">
|
||||
<?= $item['title'] ?>
|
||||
<?= ($item['alternate_title'] != "") ? "<br />({$item['alternate_title']})" : ""; ?>
|
||||
</div>
|
||||
<div class="table">
|
||||
<div class="row">
|
||||
<div class="completion">Episodes: <?= $item['episode_count'] ?></div>
|
||||
<div class="media_type"><?= $item['show_type'] ?></div>
|
||||
<div class="age_rating"><?= $item['age_rating'] ?></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</article>
|
||||
</a>
|
||||
<?php endforeach ?>
|
||||
</section>
|
||||
</section>
|
||||
<?php endforeach ?>
|
||||
</main>
|
|
@ -1,43 +0,0 @@
|
|||
<main>
|
||||
<?php foreach ($sections as $name => $items): ?>
|
||||
<h2><?= $name ?></h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Title</th>
|
||||
<th>Alternate Title</th>
|
||||
<th>Episode Count</th>
|
||||
<th>Episode Length</th>
|
||||
<th>Show Type</th>
|
||||
<th>Age Rating</th>
|
||||
<th>Notes</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($items as $item): ?>
|
||||
<tr>
|
||||
<td class="align_left">
|
||||
<a href="https://hummingbird.me/anime/<?= $item['slug'] ?>">
|
||||
<?= $item['title'] ?>
|
||||
</a>
|
||||
</td>
|
||||
<td class="align_left"><?= $item['alternate_title'] ?></td>
|
||||
<td><?= $item['episode_count'] ?></td>
|
||||
<td><?= $item['episode_length'] ?></td>
|
||||
<td><?= $item['show_type'] ?></td>
|
||||
<td><?= $item['age_rating'] ?></td>
|
||||
<td class="align_left"><?= $item['notes'] ?></td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<br />
|
||||
<?php endforeach ?>
|
||||
</main>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
|
||||
<script src="/public/js/table_sorter/jquery.tablesorter.min.js"></script>
|
||||
<script>
|
||||
$(function() {
|
||||
$('table').tablesorter();
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,91 @@
|
|||
<article
|
||||
class="media"
|
||||
data-kitsu-id="<?= $item['id'] ?>"
|
||||
data-mal-id="<?= $item['mal_id'] ?>"
|
||||
>
|
||||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<button title="Increment episode count" class="plus-one" hidden>+1 Episode</button>
|
||||
<?php endif ?>
|
||||
<?= $helper->picture("images/anime/{$item['anime']['id']}.webp") ?>
|
||||
|
||||
<div class="name">
|
||||
<a href="<?= $url->generate('anime.details', ['id' => $item['anime']['slug']]); ?>">
|
||||
<span class="canonical"><?= $item['anime']['title'] ?></span>
|
||||
<?php foreach ($item['anime']['titles'] as $title): ?>
|
||||
<br/>
|
||||
<small><?= $title ?></small>
|
||||
<?php endforeach ?>
|
||||
</a>
|
||||
</div>
|
||||
<div class="table">
|
||||
<?php if ($item['private'] || $item['rewatching']): ?>
|
||||
<div class="row">
|
||||
<?php foreach (['private', 'rewatching'] as $attr): ?>
|
||||
<?php if ($item[$attr]): ?>
|
||||
<span class="item-<?= $attr ?>"><?= ucfirst($attr) ?></span>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($item['rewatched'] > 0): ?>
|
||||
<div class="row">
|
||||
<div>Rewatched <?= $item['rewatched'] ?> time(s)</div>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if (count($item['anime']['streaming_links']) > 0): ?>
|
||||
<div class="row">
|
||||
<?php foreach ($item['anime']['streaming_links'] as $link): ?>
|
||||
<div class="cover-streaming-link">
|
||||
<?php if ($link['meta']['link']): ?>
|
||||
<a href="<?= $link['link'] ?>"
|
||||
title="Stream '<?= $item['anime']['title'] ?>' on <?= $link['meta']['name'] ?>">
|
||||
<?= $helper->picture("images/{$link['meta']['image']}", 'svg', [
|
||||
'class' => 'streaming-logo',
|
||||
'width' => 20,
|
||||
'height' => 20,
|
||||
'alt' => "{$link['meta']['name']} logo",
|
||||
]); ?>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<?= $helper->picture("images/{$link['meta']['image']}", 'svg', [
|
||||
'class' => 'streaming-logo',
|
||||
'width' => 20,
|
||||
'height' => 20,
|
||||
'alt' => "{$link['meta']['name']} logo",
|
||||
]); ?>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<div class="row">
|
||||
<span class="edit">
|
||||
<a class="bracketed" title="Edit information about this anime" href="<?=
|
||||
$url->generate('edit', [
|
||||
'controller' => 'anime',
|
||||
'id' => $item['id'],
|
||||
'status' => $item['watching_status']
|
||||
]);
|
||||
?>">Edit</a>
|
||||
</span>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="user-rating">Rating: <?= $item['user_rating'] ?> / 10</div>
|
||||
<div class="completion">Episodes:
|
||||
<span class="completed_number"><?= $item['episodes']['watched'] ?></span> /
|
||||
<span class="total_number"><?= $item['episodes']['total'] ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="media_type"><?= $escape->html($item['anime']['show_type']) ?></div>
|
||||
<div class="airing-status"><?= $escape->html($item['airing']['status']) ?></div>
|
||||
<div class="age-rating"><?= $escape->html($item['anime']['age_rating']) ?></div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
|
@ -1,40 +1,30 @@
|
|||
<main>
|
||||
<main class="media-list">
|
||||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<a class="bracketed" href="<?= $url->generate('anime.add.get') ?>">Add Item</a>
|
||||
<?php endif ?>
|
||||
<?php if (empty($sections)): ?>
|
||||
<h3>There's nothing here!</h3>
|
||||
<?php else: ?>
|
||||
<br />
|
||||
<label>Filter: <input type='text' class='media-filter' /></label>
|
||||
<br />
|
||||
<?php foreach ($sections as $name => $items): ?>
|
||||
<?php if (empty($items)): ?>
|
||||
<section class="status">
|
||||
<h2><?= $name ?></h2>
|
||||
<h2><?= $escape->html($name) ?></h2>
|
||||
<h3>There's nothing here!</h3>
|
||||
</section>
|
||||
<?php else: ?>
|
||||
<section class="status">
|
||||
<h2><?= $escape->html($name) ?></h2>
|
||||
<section class="media-wrap">
|
||||
<?php foreach($items as $item): ?>
|
||||
<article class="media" id="a-<?= $item['anime']['id'] ?>">
|
||||
<?php if (is_logged_in()): ?>
|
||||
<button class="plus_one" hidden>+1 Episode</button>
|
||||
<?php endif ?>
|
||||
<img src="<?= $item['anime']['cover_image'] ?>" />
|
||||
<div class="name">
|
||||
<a href="<?= $item['anime']['url'] ?>">
|
||||
<?= $item['anime']['title'] ?>
|
||||
<?= ($item['anime']['alternate_title'] != "") ? "<br />({$item['anime']['alternate_title']})" : ""; ?>
|
||||
</a>
|
||||
</div>
|
||||
<div class="table">
|
||||
<div class="row">
|
||||
<div class="user_rating">Rating: <?= ($item['rating']['value'] > 0) ? (int)($item['rating']['value'] * 2) : " - " ?> / 10</div>
|
||||
<div class="completion">Episodes:
|
||||
<span class="completed_number"><?= $item['episodes_watched'] ?></span> /
|
||||
<span class="total_number"><?= ($item['anime']['episode_count'] != 0) ? $item['anime']['episode_count'] : "-" ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="media_type"><?= $item['anime']['show_type'] ?></div>
|
||||
<div class="airing_status"><?= $item['anime']['status'] ?></div>
|
||||
<div class="age_rating"><?= $item['anime']['age_rating'] ?></div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
<?php if ($item['private'] && ! $auth->isAuthenticated()) continue; ?>
|
||||
<?php include __DIR__ . '/cover-item.php' ?>
|
||||
<?php endforeach ?>
|
||||
</section>
|
||||
</section>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
</main>
|
||||
<?php if (is_logged_in()): ?>
|
||||
<script src="<?= asset_url('js.php?g=edit') ?>"></script>
|
||||
<?php endif ?>
|
||||
</main>
|
||||
|
|
|
@ -0,0 +1,179 @@
|
|||
<?php use function Aviat\AnimeClient\getLocalImg; ?>
|
||||
<main class="details fixed">
|
||||
<section class="flex">
|
||||
<aside class="info">
|
||||
<?= $helper->picture("images/anime/{$data['id']}-original.webp") ?>
|
||||
|
||||
<br />
|
||||
|
||||
<table class="media-details">
|
||||
<tr>
|
||||
<td class="align-right">Airing Status</td>
|
||||
<td><?= $data['status'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Show Type</td>
|
||||
<td><?= $data['show_type'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Episode Count</td>
|
||||
<td><?= $data['episode_count'] ?? '-' ?></td>
|
||||
</tr>
|
||||
<?php if ( ! empty($data['episode_length'])): ?>
|
||||
<tr>
|
||||
<td>Episode Length</td>
|
||||
<td><?= $data['episode_length'] ?> minutes</td>
|
||||
</tr>
|
||||
<?php endif ?>
|
||||
<?php if ( ! empty($data['age_rating'])): ?>
|
||||
<tr>
|
||||
<td>Age Rating</td>
|
||||
<td><abbr title="<?= $data['age_rating_guide'] ?>"><?= $data['age_rating'] ?></abbr>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif ?>
|
||||
<tr>
|
||||
<td>Genres</td>
|
||||
<td>
|
||||
<?= implode(', ', $data['genres']) ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
||||
</aside>
|
||||
<article class="text">
|
||||
<h2 class="toph"><a rel="external" href="<?= $data['url'] ?>"><?= $data['title'] ?></a></h2>
|
||||
<?php foreach ($data['titles'] as $title): ?>
|
||||
<h3><?= $title ?></h3>
|
||||
<?php endforeach ?>
|
||||
<br />
|
||||
<div class="description">
|
||||
<p><?= str_replace("\n", '</p><p>', $data['synopsis']) ?></p>
|
||||
</div>
|
||||
<?php if (count($data['streaming_links']) > 0): ?>
|
||||
<hr />
|
||||
<h4>Streaming on:</h4>
|
||||
<table class="full-width invisible streaming-links">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="align-left">Service</th>
|
||||
<th>Subtitles</th>
|
||||
<th>Dubs</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($data['streaming_links'] as $link): ?>
|
||||
<tr>
|
||||
<td class="align-left">
|
||||
<?php if ($link['meta']['link'] !== FALSE): ?>
|
||||
<a
|
||||
href="<?= $link['link'] ?>"
|
||||
title="Stream '<?= $data['title'] ?>' on <?= $link['meta']['name'] ?>"
|
||||
>
|
||||
<?= $helper->picture("images/{$link['meta']['image']}", 'svg', [
|
||||
'class' => 'streaming-logo',
|
||||
'width' => 50,
|
||||
'height' => 50,
|
||||
'alt' => "{$link['meta']['name']} logo",
|
||||
]); ?>
|
||||
<?= $link['meta']['name'] ?>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<?= $helper->picture("images/{$link['meta']['image']}", 'svg', [
|
||||
'class' => 'streaming-logo',
|
||||
'width' => 50,
|
||||
'height' => 50,
|
||||
'alt' => "{$link['meta']['name']} logo",
|
||||
]); ?>
|
||||
<?= $link['meta']['name'] ?>
|
||||
<?php endif ?>
|
||||
</td>
|
||||
<td><?= implode(', ', $link['subs']) ?></td>
|
||||
<td><?= implode(', ', $link['dubs']) ?></td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif ?>
|
||||
<?php if ( ! empty($data['trailer_id'])): ?>
|
||||
<div class="responsive-iframe">
|
||||
<h4>Trailer</h4>
|
||||
<iframe
|
||||
width="560"
|
||||
height="315"
|
||||
src="https://www.youtube.com/embed/<?= $data['trailer_id'] ?>"
|
||||
frameborder="0"
|
||||
allow="autoplay; encrypted-media"
|
||||
allowfullscreen
|
||||
></iframe>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<?php if (count($data['characters']) > 0): ?>
|
||||
<section>
|
||||
<h2>Characters</h2>
|
||||
|
||||
<div class="tabs">
|
||||
<?php $i = 0 ?>
|
||||
<?php foreach ($data['characters'] as $role => $list): ?>
|
||||
<input
|
||||
type="radio" name="character-types"
|
||||
id="character-types-<?= $i ?>" <?= ($i === 0) ? 'checked' : '' ?> />
|
||||
<label for="character-types-<?= $i ?>"><?= ucfirst($role) ?></label>
|
||||
<section class="content media-wrap flex flex-wrap flex-justify-start">
|
||||
<?php foreach ($list as $id => $char): ?>
|
||||
<?php if ( ! empty($char['image']['original'])): ?>
|
||||
<article class="<?= $role === 'supporting' ? 'small-' : '' ?>character">
|
||||
<?php $link = $url->generate('character', ['slug' => $char['slug']]) ?>
|
||||
<div class="name">
|
||||
<?= $helper->a($link, $char['name']); ?>
|
||||
</div>
|
||||
<a href="<?= $link ?>">
|
||||
<?= $helper->picture("images/characters/{$id}.webp") ?>
|
||||
</a>
|
||||
</article>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
</section>
|
||||
<?php $i++; ?>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if (count($data['staff']) > 0): ?>
|
||||
<section>
|
||||
<h2>Staff</h2>
|
||||
|
||||
<div class="vertical-tabs">
|
||||
<?php $i = 0; ?>
|
||||
<?php foreach ($data['staff'] as $role => $people): ?>
|
||||
<div class="tab">
|
||||
<input type="radio" name="staff-roles" id="staff-role<?= $i ?>" <?= $i === 0 ? 'checked' : '' ?> />
|
||||
<label for="staff-role<?= $i ?>"><?= $role ?></label>
|
||||
<section class='content media-wrap flex flex-wrap flex-justify-start'>
|
||||
<?php foreach ($people as $pid => $person): ?>
|
||||
<article class='character small-person'>
|
||||
<?php $link = $url->generate('person', ['id' => $person['id']]) ?>
|
||||
<div class="name">
|
||||
<a href="<?= $link ?>">
|
||||
<?= $person['name'] ?>
|
||||
</a>
|
||||
</div>
|
||||
<a href="<?= $link ?>">
|
||||
<?= $helper->picture(getLocalImg($person['image']['original'] ?? NULL)) ?>
|
||||
</a>
|
||||
</article>
|
||||
<?php endforeach ?>
|
||||
</section>
|
||||
</div>
|
||||
<?php $i++; ?>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif ?>
|
||||
</main>
|
|
@ -1,8 +1,112 @@
|
|||
<body>
|
||||
<?php include 'nav.php' ?>
|
||||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<main>
|
||||
<h2>Edit Anime List Item</h2>
|
||||
<form action="<?= $action ?>" method="post">
|
||||
<table class="invisible form">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<h3><?= $escape->html($item['anime']['title']) ?></h3>
|
||||
<?php foreach($item['anime']['titles'] as $title): ?>
|
||||
<h4><?= $escape->html($title) ?></h4>
|
||||
<?php endforeach ?>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td rowspan="9">
|
||||
<?= $helper->picture("images/anime/{$item['anime']['id']}-original.webp", "jpg", [], ["width" => "390"]) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="private">Is Private?</label></td>
|
||||
<td>
|
||||
<input type="checkbox" name="private" id="private"
|
||||
<?php if($item['private']): ?>checked="checked"<?php endif ?>
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="watching_status">Watching Status</label></td>
|
||||
<td>
|
||||
<select name="watching_status" id="watching_status">
|
||||
<?php foreach($statuses as $status_key => $status_title): ?>
|
||||
<option <?php if($item['watching_status'] === $status_key): ?>selected="selected"<?php endif ?>
|
||||
value="<?= $status_key ?>"><?= $status_title ?></option>
|
||||
<?php endforeach ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="series_rating">Rating</label></td>
|
||||
<td>
|
||||
<input type="number" min="0" max="10" maxlength="2" name="user_rating" id="series_rating" value="<?= $item['user_rating'] ?>" id="series_rating" size="2" /> / 10
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="episodes_watched">Episodes Watched</label></td>
|
||||
<td>
|
||||
<input type="number" min="0" size="4" maxlength="4" value="<?= $item['episodes']['watched'] ?>" name="episodes_watched" id="episodes_watched" />
|
||||
<?php if($item['episodes']['total'] > 0): ?>
|
||||
/ <?= $item['episodes']['total'] ?>
|
||||
<?php endif ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="rewatching_flag">Rewatching?</label></td>
|
||||
<td>
|
||||
<input type="checkbox" name="rewatching" id="rewatching_flag"
|
||||
<?php if($item['rewatching'] === TRUE): ?>checked="checked"<?php endif ?>
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="rewatched">Rewatch Count</label></td>
|
||||
<td>
|
||||
<input type="number" min="0" id="rewatched" name="rewatched" value="<?= $item['rewatched'] ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="notes">Notes</label></td>
|
||||
<td>
|
||||
<textarea name="notes" id="notes"><?= $escape->html($item['notes']) ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>
|
||||
<input type="hidden" value="<?= $item['id'] ?>" name="id" />
|
||||
<?php if ( ! empty($item['mal_id'])): ?>
|
||||
<input type="hidden" value="<?= $item['mal_id'] ?? '' ?>" name="mal_id" />
|
||||
<?php endif ?>
|
||||
<input type="hidden" value="true" name="edit" />
|
||||
<button type="submit">Submit</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
<form class="js-delete" action="<?= $url->generate('anime.delete') ?>" method="post">
|
||||
<fieldset>
|
||||
<legend>Danger Zone</legend>
|
||||
<table class="form invisible">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="danger">
|
||||
<strong>Permanently</strong> remove this list item and <strong>all</strong> its data?
|
||||
</td>
|
||||
<td>
|
||||
<input type="hidden" value="<?= $item['id'] ?>" name="id" />
|
||||
<?php if (!empty($item['mal_id'])): ?>
|
||||
<input type="hidden" value="<?= $item['mal_id'] ?? '' ?>" name="mal_id" />
|
||||
<?php endif ?>
|
||||
<button type="submit" class="danger">Delete Entry</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</fieldset>
|
||||
</form>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
<?php endif ?>
|
|
@ -1,36 +1,110 @@
|
|||
<main>
|
||||
<main class="media-list">
|
||||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<a class="bracketed" href="<?= $url->generate('anime.add.get') ?>">Add Item</a>
|
||||
<?php endif ?>
|
||||
<?php if (empty($sections)): ?>
|
||||
<h3>There's nothing here!</h3>
|
||||
<?php else: ?>
|
||||
<br />
|
||||
<label>Filter: <input type='text' class='media-filter' /></label>
|
||||
<br />
|
||||
<?php foreach ($sections as $name => $items): ?>
|
||||
<h2><?= $name ?></h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Title</th>
|
||||
<th>Alternate Title</th>
|
||||
<th>Airing Status</th>
|
||||
<th>Score</th>
|
||||
<th>Type</th>
|
||||
<th>Progress</th>
|
||||
<th>Rated</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($items as $item): ?>
|
||||
<tr id="a-<?= $item['anime']['id'] ?>">
|
||||
<td class="align_left">
|
||||
<a href="<?= $item['anime']['url'] ?>">
|
||||
<?= $item['anime']['title'] ?>
|
||||
</a>
|
||||
</td>
|
||||
<td class="align_left"><?= $item['anime']['alternate_title'] ?></td>
|
||||
<td class="align_left"><?= $item['anime']['status'] ?></td>
|
||||
<td><?= (int)($item['rating']['value'] * 2) ?> / 10 </td>
|
||||
<td><?= $item['anime']['show_type'] ?></td>
|
||||
<td>Episodes: <?= $item['episodes_watched'] ?> / <?= $item['anime']['episode_count'] ?></td>
|
||||
<td><?= $item['anime']['age_rating'] ?></td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if (empty($items)): ?>
|
||||
<h3>There's nothing here!</h3>
|
||||
<?php else: ?>
|
||||
<table class='media-wrap'>
|
||||
<thead>
|
||||
<tr>
|
||||
<?php if($auth->isAuthenticated()): ?>
|
||||
<td class="no-border"> </td>
|
||||
<?php endif ?>
|
||||
<th>Title</th>
|
||||
<th>Airing Status</th>
|
||||
<th>Score</th>
|
||||
<th>Type</th>
|
||||
<th>Progress</th>
|
||||
<th>Rated</th>
|
||||
<th colspan="2">Attributes</th>
|
||||
<th>Notes</th>
|
||||
<th>Genres</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($items as $item): ?>
|
||||
<?php if ($item['private'] && ! $auth->isAuthenticated()) continue; ?>
|
||||
<tr id="a-<?= $item['id'] ?>">
|
||||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<td>
|
||||
<a class="bracketed" href="<?= $url->generate('edit', [
|
||||
'controller' => 'anime',
|
||||
'id' => $item['id'],
|
||||
'status' => $item['watching_status']
|
||||
]) ?>">Edit</a>
|
||||
</td>
|
||||
<?php endif ?>
|
||||
<td class="align-left justify">
|
||||
<a href="<?= $url->generate('anime.details', ['id' => $item['anime']['slug']]) ?>">
|
||||
<?= $item['anime']['title'] ?>
|
||||
</a>
|
||||
<?php foreach ($item['anime']['titles'] as $title): ?>
|
||||
<br/><?= $title ?>
|
||||
<?php endforeach ?>
|
||||
</td>
|
||||
<td><?= $item['airing']['status'] ?></td>
|
||||
<td><?= $item['user_rating'] ?> / 10 </td>
|
||||
<td><?= $item['anime']['show_type'] ?></td>
|
||||
<td id="<?= $item['anime']['slug'] ?>">
|
||||
Episodes: <br />
|
||||
<span class="completed_number"><?= $item['episodes']['watched'] ?></span> / <span class="total_number"><?= $item['episodes']['total'] ?></span>
|
||||
</td>
|
||||
<td><?= $item['anime']['age_rating'] ?></td>
|
||||
<td>
|
||||
<ul>
|
||||
<?php if ($item['rewatched'] > 0): ?>
|
||||
<li>Rewatched <?= $item['rewatched'] ?> time(s)</li>
|
||||
<?php endif ?>
|
||||
<?php foreach(['private','rewatching'] as $attr): ?>
|
||||
<?php if($item[$attr]): ?>
|
||||
<li><?= ucfirst($attr); ?></li>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</td>
|
||||
<td>
|
||||
<?php foreach($item['anime']['streaming_links'] as $link): ?>
|
||||
<?php if ($link['meta']['link'] !== FALSE): ?>
|
||||
<a href="<?= $link['link'] ?>" title="Stream '<?= $item['anime']['title'] ?>' on <?= $link['meta']['name'] ?>">
|
||||
<?= $helper->picture("images/{$link['meta']['image']}", 'svg', [
|
||||
'class' => 'streaming-logo',
|
||||
'width' => 50,
|
||||
'height' => 50,
|
||||
'alt' => "{$link['meta']['name']} logo",
|
||||
]); ?>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<?= $helper->picture("images/{$link['meta']['image']}", 'svg', [
|
||||
'class' => 'streaming-logo',
|
||||
'width' => 50,
|
||||
'height' => 50,
|
||||
'alt' => "{$link['meta']['name']} logo",
|
||||
]); ?>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
</td>
|
||||
<td>
|
||||
<p><?= $escape->html($item['notes']) ?></p>
|
||||
</td>
|
||||
<td class="align-left">
|
||||
<?php sort($item['anime']->genres) ?>
|
||||
<?= implode(', ', $item['anime']->genres) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
<?php endif ?>
|
||||
</main>
|
||||
<script src="<?= asset_url('js.php?g=table') ?>"></script>
|
||||
<script defer="defer" src="<?= $urlGenerator->assetUrl('js/tables.min.js') ?>"></script>
|
|
@ -0,0 +1,3 @@
|
|||
<main>
|
||||
<h1><?= $title ?></h1>
|
||||
</main>
|
|
@ -0,0 +1,224 @@
|
|||
<?php
|
||||
|
||||
use function Aviat\AnimeClient\getLocalImg;
|
||||
use Aviat\AnimeClient\API\Kitsu;
|
||||
|
||||
?>
|
||||
<main class="character-page details fixed">
|
||||
<section class="flex flex-no-wrap">
|
||||
<aside>
|
||||
<?= $helper->picture("images/characters/{$data['id']}-original.webp") ?>
|
||||
</aside>
|
||||
<div>
|
||||
<h2 class="toph"><?= $data['name'] ?></h2>
|
||||
<?php foreach ($data['names'] as $name): ?>
|
||||
<h3><?= $name ?></h3>
|
||||
<?php endforeach ?>
|
||||
|
||||
<?php if ( ! empty($data['otherNames'])): ?>
|
||||
<h4>Also Known As:</h4>
|
||||
<ul>
|
||||
<?php foreach ($data['otherNames'] as $name): ?>
|
||||
<li><h5><?= $name ?></h5></li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
<?php endif ?>
|
||||
<br />
|
||||
<hr />
|
||||
<div class="description">
|
||||
<p><?= str_replace("\n", '</p><p>', $data['description']) ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?php if ( ! (empty($data['media']['anime']) || empty($data['media']['manga']))): ?>
|
||||
<h3>Media</h3>
|
||||
<div class="tabs">
|
||||
<?php if ( ! empty($data['media']['anime'])): ?>
|
||||
<input checked="checked" type="radio" id="media-anime" name="media-tabs" />
|
||||
<label for="media-anime">Anime</label>
|
||||
|
||||
<section class="media-wrap content">
|
||||
<?php foreach ($data['media']['anime'] as $id => $anime): ?>
|
||||
<article class="media">
|
||||
<?php
|
||||
$link = $url->generate('anime.details', ['id' => $anime['attributes']['slug']]);
|
||||
$titles = Kitsu::filterTitles($anime['attributes']);
|
||||
?>
|
||||
<a href="<?= $link ?>">
|
||||
<?= $helper->picture("images/anime/{$id}.webp") ?>
|
||||
</a>
|
||||
<div class="name">
|
||||
<a href="<?= $link ?>">
|
||||
<?= array_shift($titles) ?>
|
||||
<?php foreach ($titles as $title): ?>
|
||||
<br />
|
||||
<small><?= $title ?></small>
|
||||
<?php endforeach ?>
|
||||
</a>
|
||||
</div>
|
||||
</article>
|
||||
<?php endforeach ?>
|
||||
</section>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ( ! empty($data['media']['manga'])): ?>
|
||||
<input type="radio" id="media-manga" name="media-tabs" />
|
||||
<label for="media-manga">Manga</label>
|
||||
|
||||
<section class="media-wrap content">
|
||||
<?php foreach ($data['media']['manga'] as $id => $manga): ?>
|
||||
<article class="media">
|
||||
<?php
|
||||
$link = $url->generate('manga.details', ['id' => $manga['attributes']['slug']]);
|
||||
$titles = Kitsu::filterTitles($manga['attributes']);
|
||||
?>
|
||||
<a href="<?= $link ?>">
|
||||
<?= $helper->picture("images/manga/{$id}.webp") ?>
|
||||
</a>
|
||||
<div class="name">
|
||||
<a href="<?= $link ?>">
|
||||
<?= array_shift($titles) ?>
|
||||
<?php foreach ($titles as $title): ?>
|
||||
<br />
|
||||
<small><?= $title ?></small>
|
||||
<?php endforeach ?>
|
||||
</a>
|
||||
</div>
|
||||
</article>
|
||||
<?php endforeach ?>
|
||||
</section>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<section>
|
||||
<?php if (count($data['castings']) > 0): ?>
|
||||
<h3>Castings</h3>
|
||||
<?php
|
||||
$vas = $data['castings']['Voice Actor'];
|
||||
unset($data['castings']['Voice Actor']);
|
||||
ksort($vas)
|
||||
?>
|
||||
|
||||
<?php foreach ($data['castings'] as $role => $entries): ?>
|
||||
<h4><?= $role ?></h4>
|
||||
<?php foreach ($entries as $language => $casting): ?>
|
||||
<h5><?= $language ?></h5>
|
||||
<table class="min-table">
|
||||
<tr>
|
||||
<th>Cast Member</th>
|
||||
<th>Series</th>
|
||||
</tr>
|
||||
<?php foreach ($casting as $cid => $c): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<article class="character">
|
||||
<?php
|
||||
$link = $url->generate('person', ['id' => $c['person']['id']]);
|
||||
?>
|
||||
<a href="<?= $link ?>">
|
||||
<?= $helper->picture(getLocalImg($c['person']['image'], TRUE)) ?>
|
||||
<div class="name">
|
||||
<?= $c['person']['name'] ?>
|
||||
</div>
|
||||
</a>
|
||||
</article>
|
||||
</td>
|
||||
<td>
|
||||
<section class="align-left media-wrap">
|
||||
<?php foreach ($c['series'] as $series): ?>
|
||||
<article class="media">
|
||||
<?php
|
||||
$link = $url->generate('anime.details', ['id' => $series['attributes']['slug']]);
|
||||
$titles = Kitsu::filterTitles($series['attributes']);
|
||||
?>
|
||||
<a href="<?= $link ?>">
|
||||
<?= $helper->picture(getLocalImg($series['attributes']['posterImage']['small'], TRUE)) ?>
|
||||
</a>
|
||||
<div class="name">
|
||||
<a href="<?= $link ?>">
|
||||
<?= array_shift($titles) ?>
|
||||
<?php foreach ($titles as $title): ?>
|
||||
<br />
|
||||
<small><?= $title ?></small>
|
||||
<?php endforeach ?>
|
||||
</a>
|
||||
</div>
|
||||
</article>
|
||||
<?php endforeach ?>
|
||||
</section>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
<?php endforeach ?>
|
||||
<?php endforeach ?>
|
||||
|
||||
<?php if ( ! empty($vas)): ?>
|
||||
<h4>Voice Actors</h4>
|
||||
|
||||
<div class="tabs">
|
||||
<?php $i = 0; ?>
|
||||
|
||||
<?php foreach ($vas as $language => $casting): ?>
|
||||
<input <?= $i === 0 ? 'checked="checked"' : '' ?> type="radio" id="character-va<?= $i ?>"
|
||||
name="character-vas"
|
||||
/>
|
||||
<label for="character-va<?= $i ?>"><?= $language ?></label>
|
||||
<section class="content">
|
||||
<table class="borderless max-table">
|
||||
<tr>
|
||||
<th>Cast Member</th>
|
||||
<th>Series</th>
|
||||
</tr>
|
||||
<?php foreach ($casting as $cid => $c): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<article class="character">
|
||||
<?php
|
||||
$link = $url->generate('person', ['id' => $c['person']['id']]);
|
||||
?>
|
||||
<a href="<?= $link ?>">
|
||||
<?= $helper->picture(getLocalImg($c['person']['image'])) ?>
|
||||
<div class="name">
|
||||
<?= $c['person']['name'] ?>
|
||||
</div>
|
||||
</a>
|
||||
</article>
|
||||
</td>
|
||||
<td width="75%">
|
||||
<section class="align-left media-wrap-flex">
|
||||
<?php foreach ($c['series'] as $series): ?>
|
||||
<article class="media">
|
||||
<?php
|
||||
$link = $url->generate('anime.details', ['id' => $series['attributes']['slug']]);
|
||||
$titles = Kitsu::filterTitles($series['attributes']);
|
||||
?>
|
||||
<a href="<?= $link ?>">
|
||||
<?= $helper->picture(getLocalImg($series['attributes']['posterImage']['small'], TRUE)) ?>
|
||||
</a>
|
||||
<div class="name">
|
||||
<a href="<?= $link ?>">
|
||||
<?= array_shift($titles) ?>
|
||||
<?php foreach ($titles as $title): ?>
|
||||
<br />
|
||||
<small><?= $title ?></small>
|
||||
<?php endforeach ?>
|
||||
</a>
|
||||
</div>
|
||||
</article>
|
||||
<?php endforeach ?>
|
||||
</section>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</table>
|
||||
</section>
|
||||
<?php $i++ ?>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
</section>
|
||||
</main>
|
|
@ -0,0 +1,42 @@
|
|||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<main>
|
||||
<h2>Add <?= ucfirst($collection_type) ?> to your Collection</h2>
|
||||
<form action="<?= $action_url ?>" method="post">
|
||||
<section>
|
||||
<div class="cssload-loader" hidden="hidden">
|
||||
<div class="cssload-inner cssload-one"></div>
|
||||
<div class="cssload-inner cssload-two"></div>
|
||||
<div class="cssload-inner cssload-three"></div>
|
||||
</div>
|
||||
<label for="search">Search for <?= $collection_type ?> by name: <input type="search" id="search" name="search" /></label>
|
||||
<section id="series-list" class="media-wrap">
|
||||
</section>
|
||||
</section>
|
||||
<br />
|
||||
<table class="invisible form">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><label for="media_id">Media</label></td>
|
||||
<td>
|
||||
<select name="media_id" id="media_id">
|
||||
<?php foreach($media_items as $id => $name): ?>
|
||||
<option value="<?= $id ?>"><?= $name ?></option>
|
||||
<?php endforeach ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="notes">Notes</label></td>
|
||||
<td><textarea id="notes" name="notes"></textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>
|
||||
<button type="submit">Save</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</main>
|
||||
<?php endif ?>
|
|
@ -0,0 +1,26 @@
|
|||
<article class="media" id="a-<?= $item['hummingbird_id'] ?>">
|
||||
<?= $helper->picture("images/anime/{$item['hummingbird_id']}.webp") ?>
|
||||
<div class="name">
|
||||
<a href="<?= $url->generate('anime.details', ['id' => $item['slug']]) ?>">
|
||||
<?= $item['title'] ?>
|
||||
<?= ($item['alternate_title'] != "") ? "<small><br />{$item['alternate_title']}</small>" : ""; ?>
|
||||
</a>
|
||||
</div>
|
||||
<div class="table">
|
||||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<div class="row">
|
||||
<span class="edit">
|
||||
<a class="bracketed"
|
||||
href="<?= $url->generate($collection_type . '.collection.edit.get', [
|
||||
'id' => $item['hummingbird_id']
|
||||
]) ?>">Edit</a>
|
||||
</span>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<div class="row">
|
||||
<div class="completion">Episodes: <?= $item['episode_count'] ?></div>
|
||||
<div class="media_type"><?= $item['show_type'] ?></div>
|
||||
<div class="age-rating"><?= $item['age_rating'] ?></div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
|
@ -0,0 +1,40 @@
|
|||
<main class="media-list">
|
||||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<a class="bracketed" href="<?= $url->generate($collection_type . '.collection.add.get') ?>">Add Item</a>
|
||||
<?php endif ?>
|
||||
<?php if (empty($sections)): ?>
|
||||
<h3>There's nothing here!</h3>
|
||||
<?php else: ?>
|
||||
<br />
|
||||
<label>Filter: <input type='text' class='media-filter' /></label>
|
||||
<br />
|
||||
<div class="tabs">
|
||||
<?php $i = 0; ?>
|
||||
<?php foreach ($sections as $name => $items): ?>
|
||||
<input <?= $i === 0 ? 'checked="checked"' : '' ?> type="radio" id="collection-tab-<?= $i ?>" name="collection-tabs" />
|
||||
<label for="collection-tab-<?= $i ?>"><h2><?= $name ?></h2></label>
|
||||
<div class="content full-height">
|
||||
<section class="media-wrap">
|
||||
<?php foreach ($items as $item): ?>
|
||||
<?php include __DIR__ . '/cover-item.php'; ?>
|
||||
<?php endforeach ?>
|
||||
</section>
|
||||
</div>
|
||||
<?php $i++; ?>
|
||||
<?php endforeach ?>
|
||||
<!-- All Tab -->
|
||||
<input type='radio' id='collection-tab-<?= $i ?>' name='collection-tabs' />
|
||||
<label for='collection-tab-<?= $i ?>'><h2>All</h2></label>
|
||||
<div class='content full-height'>
|
||||
<?php foreach ($sections as $name => $items): ?>
|
||||
<h3><?= $name ?></h3>
|
||||
<section class="media-wrap">
|
||||
<?php foreach ($items as $item): ?>
|
||||
<?php include __DIR__ . '/cover-item.php'; ?>
|
||||
<?php endforeach ?>
|
||||
</section>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</main>
|
|
@ -0,0 +1,69 @@
|
|||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<main>
|
||||
<h2>Edit Anime Collection Item</h2>
|
||||
<form action="<?= $action_url ?>" method="post">
|
||||
<table class="invisible form">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td rowspan="6" class="align-center">
|
||||
<?= $helper->picture("images/anime/{$item['hummingbird_id']}-original.webp", "jpg", [], ["width" => "390"]) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="align-right"><label for="title">Title</label></td>
|
||||
<td class="align-left">
|
||||
<input type="text" id="title" name="title" value="<?= $item['title'] ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="align-right"><label for="alternate_title">Alternate Title</label></td>
|
||||
<td class="align-left">
|
||||
<input type="text" id="alternate_title" name="alternate_title" value="<?= $item['alternate_title'] ?>"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="align-right"><label for="media_id">Media</label></td>
|
||||
<td class="align-left">
|
||||
<select name="media_id" id="media_id">
|
||||
<?php foreach($media_items as $id => $name): ?>
|
||||
<option <?= $item['media_id'] === $id ? 'selected="selected"' : '' ?> value="<?= $id ?>"><?= $name ?></option>
|
||||
<?php endforeach ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="notes">Notes</label></td>
|
||||
<td><textarea id="notes" name="notes"><?= $escape->html($item['notes']) ?></textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>
|
||||
<?php if($action === 'Edit'): ?>
|
||||
<input type="hidden" name="hummingbird_id" value="<?= $item['hummingbird_id'] ?>" />
|
||||
<?php endif ?>
|
||||
<button type="submit">Save</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
<form class="js-delete" action="<?= $url->generate($collection_type . '.collection.delete') ?>" method="post">
|
||||
<fieldset>
|
||||
<legend>Danger Zone</legend>
|
||||
<table class="form invisible">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="danger">
|
||||
<strong>Permanently</strong> remove this list item and <strong>all</strong> its data?
|
||||
</td>
|
||||
<td>
|
||||
<input type="hidden" value="<?= $item['hummingbird_id'] ?>" name="hummingbird_id" />
|
||||
<button type="submit" class="danger">Delete Entry</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</fieldset>
|
||||
</form>
|
||||
</main>
|
||||
<?php endif ?>
|
|
@ -0,0 +1,20 @@
|
|||
<tr>
|
||||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<td>
|
||||
<a class="bracketed"
|
||||
href="<?= $url->generate($collection_type . '.collection.edit.get', ['id' => $item['hummingbird_id']]) ?>">Edit</a>
|
||||
</td>
|
||||
<?php endif ?>
|
||||
<td class="align-left">
|
||||
<a href="<?= $url->generate('anime.details', ['id' => $item['slug']]) ?>">
|
||||
<?= $item['title'] ?>
|
||||
</a>
|
||||
<?= ! empty($item['alternate_title']) ? ' <br /><small> ' . $item['alternate_title'] . '</small>' : '' ?>
|
||||
</td>
|
||||
<td><?= $item['episode_count'] ?></td>
|
||||
<td><?= $item['episode_length'] ?></td>
|
||||
<td><?= $item['show_type'] ?></td>
|
||||
<td><?= $item['age_rating'] ?></td>
|
||||
<td class="align-left"><?= implode(', ', $item['genres']) ?></td>
|
||||
<td class="align-left"><?= $item['notes'] ?></td>
|
||||
</tr>
|
|
@ -0,0 +1,74 @@
|
|||
<main>
|
||||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<a class="bracketed" href="<?= $url->generate($collection_type . '.collection.add.get') ?>">Add Item</a>
|
||||
<?php endif ?>
|
||||
<?php if (empty($sections)): ?>
|
||||
<h3>There's nothing here!</h3>
|
||||
<?php else: ?>
|
||||
<br />
|
||||
<label>Filter: <input type='text' class='media-filter' /></label>
|
||||
<br />
|
||||
<?php $i = 0; ?>
|
||||
<div class="tabs">
|
||||
<?php foreach ($sections as $name => $items): ?>
|
||||
<input <?= $i === 0 ? 'checked="checked"' : '' ?> type="radio" id="collection-tab-<?= $i ?>"
|
||||
name="collection-tabs"/>
|
||||
<label for="collection-tab-<?= $i ?>"><h2><?= $name ?></h2></label>
|
||||
<div class="content full-height">
|
||||
<table class="full-width media-wrap">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<td>Actions</td>
|
||||
<?php endif ?>
|
||||
<th>Title</th>
|
||||
<th>Episode Count</th>
|
||||
<th>Episode Length</th>
|
||||
<th>Show Type</th>
|
||||
<th>Age Rating</th>
|
||||
<th>Genres</th>
|
||||
<th>Notes</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($items as $item): ?>
|
||||
<?php include __DIR__ . '/list-item.php' ?>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php $i++ ?>
|
||||
<?php endforeach ?>
|
||||
<!-- All -->
|
||||
<input type='radio' id='collection-tab-<?= $i ?>' name='collection-tabs' />
|
||||
<label for='collection-tab-<?= $i ?>'><h2>All</h2></label>
|
||||
<div class="content full-height">
|
||||
<?php foreach ($sections as $name => $items): ?>
|
||||
<h3><?= $name ?></h3>
|
||||
<table class="full-width media-wrap">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<td>Actions</td>
|
||||
<?php endif ?>
|
||||
<th>Title</th>
|
||||
<th>Episode Count</th>
|
||||
<th>Episode Length</th>
|
||||
<th>Show Type</th>
|
||||
<th>Age Rating</th>
|
||||
<th>Genres</th>
|
||||
<th>Notes</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($items as $item): ?>
|
||||
<?php include __DIR__ . '/list-item.php' ?>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</main>
|
||||
<script defer="defer" src="<?= $urlGenerator->assetUrl('js/tables.min.js') ?>"></script>
|
|
@ -0,0 +1,5 @@
|
|||
<main>
|
||||
<h1><?= $title ?></h1>
|
||||
<h2><?= $message ?></h2>
|
||||
<div><?= $long_message ?></div>
|
||||
</main>
|
|
@ -1,2 +1,22 @@
|
|||
<section id="loading-shadow" hidden="hidden">
|
||||
<div class="loading-wrapper">
|
||||
<div class="loading-content">
|
||||
<h3>Updating List Item...</h3>
|
||||
<div class="cssload-loader">
|
||||
<div class="cssload-inner cssload-one"></div>
|
||||
<div class="cssload-inner cssload-two"></div>
|
||||
<div class="cssload-inner cssload-three"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<script nomodule="nomodule" src="https://polyfill.io/v3/polyfill.min.js?features=es5%2CObject.assign"></script>
|
||||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<script nomodule='nomodule' async="async" defer="defer" src="<?= $urlGenerator->assetUrl('js/scripts-authed.min.js') ?>"></script>
|
||||
<script type="module" src="<?= $urlGenerator->assetUrl('js/src/index-authed.js') ?>"></script>
|
||||
<?php else: ?>
|
||||
<script nomodule="nomodule" async="async" defer="defer" src="<?= $urlGenerator->assetUrl('js/scripts.min.js') ?>"></script>
|
||||
<script type="module" src="<?= $urlGenerator->assetUrl('js/src/index.js') ?>"></script>
|
||||
<?php endif ?>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -1,35 +1,47 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title><?= $title ?></title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="<?= asset_url('css.php?g=base') ?>" />
|
||||
<script>
|
||||
var BASE_URL = "<?= base_url($url_type) ?>";
|
||||
var CONTROLLER = "<?= $url_type ?>";
|
||||
</script>
|
||||
<meta http-equiv="cache-control" content="no-store" />
|
||||
<meta http-equiv="Content-Security-Policy" content="script-src 'self'" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=1" />
|
||||
<?php if ($config->get('theme') !== 'auto'): ?>
|
||||
<link rel="stylesheet" href="<?= $urlGenerator->assetUrl('css/app.min.css') ?>" />
|
||||
<?php elseif ($config->get('theme') === 'auto'): ?>
|
||||
<link rel="stylesheet" href="<?= $urlGenerator->assetUrl('css/dark-auto.min.css') ?>" />
|
||||
<?php endif ?>
|
||||
<link rel="<?= $config->get('theme') === 'dark' ? '' : 'alternate ' ?>stylesheet" title="Dark Theme" href="<?= $urlGenerator->assetUrl('css/dark.min.css') ?>" />
|
||||
<link rel="icon" href="<?= $urlGenerator->assetUrl('images/icons/favicon.ico') ?>" />
|
||||
<link rel="apple-touch-icon" sizes="57x57" href="<?= $urlGenerator->assetUrl('images/icons/apple-icon-57x57.png') ?>">
|
||||
<link rel="apple-touch-icon" sizes="60x60" href="<?= $urlGenerator->assetUrl('images/icons/apple-icon-60x60.png') ?>">
|
||||
<link rel="apple-touch-icon" sizes="72x72" href="<?= $urlGenerator->assetUrl('images/icons/apple-icon-72x72.png') ?>">
|
||||
<link rel="apple-touch-icon" sizes="76x76" href="<?= $urlGenerator->assetUrl('images/icons/apple-icon-76x76.png') ?>">
|
||||
<link rel="apple-touch-icon" sizes="114x114" href="<?= $urlGenerator->assetUrl('images/icons/apple-icon-114x114.png') ?>">
|
||||
<link rel="apple-touch-icon" sizes="120x120" href="<?= $urlGenerator->assetUrl('images/icons/apple-icon-120x120.png') ?>">
|
||||
<link rel="apple-touch-icon" sizes="144x144" href="<?= $urlGenerator->assetUrl('images/icons/apple-icon-144x144.png') ?>">
|
||||
<link rel="apple-touch-icon" sizes="152x152" href="<?= $urlGenerator->assetUrl('images/icons/apple-icon-152x152.png') ?>">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="<?= $urlGenerator->assetUrl('images/icons/apple-icon-180x180.png') ?>">
|
||||
<link rel="icon" type="image/png" sizes="192x192" href="<?= $urlGenerator->assetUrl('images/icons/android-icon-192x192.png') ?>">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="<?= $urlGenerator->assetUrl('images/icons/favicon-32x32.png') ?>">
|
||||
<link rel="icon" type="image/png" sizes="96x96" href="<?= $urlGenerator->assetUrl('images/icons/favicon-96x96.png') ?>">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="<?= $urlGenerator->assetUrl('images/icons/favicon-16x16.png') ?>">
|
||||
|
||||
</head>
|
||||
<body class="<?= $url_type ?> list">
|
||||
<h1 class="flex flex-align-end flex-wrap">
|
||||
<span class="flex-no-wrap grow-1"><?= WHOSE ?> <?= ucfirst($url_type) ?> <?= (strpos($route_path, 'collection') !== FALSE) ? 'Collection' : 'List' ?> [<a href="<?= full_url("", $other_type) ?>"><?= ucfirst($other_type) ?> List</a>]</span>
|
||||
<span class="flex-no-wrap small-font">
|
||||
<?php if (is_logged_in()): ?>
|
||||
[<a href="<?= full_url("/logout", $url_type) ?>">Logout</a>]
|
||||
<?php else: ?>
|
||||
[<a href="<?= full_url("/login", $url_type) ?>"><?= WHOSE ?> Login</a>]
|
||||
<?php endif ?>
|
||||
</span>
|
||||
</h1>
|
||||
<nav>
|
||||
<ul>
|
||||
<?php foreach($nav_routes as $title => $nav_path): ?>
|
||||
<li class="<?= is_selected($nav_path, $route_path) ?>"><a href="<?= full_url($nav_path, $url_type) ?>"><?= $title ?></a></li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
<br />
|
||||
<ul>
|
||||
<li class="<?= is_not_selected('list', last_segment()) ?>"><a href="<?= full_url($route_path, $url_type) ?>">Cover View</a></li>
|
||||
<li class="<?= is_selected('list', last_segment()) ?>"><a href="<?= full_url("{$route_path}/list", $url_type) ?>">List View</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
<br />
|
||||
<body class="<?= $escape->attr($url_type) ?> list">
|
||||
<?php include 'setup-check.php' ?>
|
||||
<header>
|
||||
<?php
|
||||
include 'main-menu.php';
|
||||
if(isset($message) && is_array($message))
|
||||
{
|
||||
foreach($message as $m)
|
||||
{
|
||||
$message = $m['message'];
|
||||
$message_type = $m['message_type'];
|
||||
include 'message.php';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
</header>
|
|
@ -1,17 +1,16 @@
|
|||
<main>
|
||||
<h2><?= $config->get('whose_list'); ?>'s Login</h2>
|
||||
<?= $message ?>
|
||||
<aside>
|
||||
<form method="post" action="<?= full_url('/login', $url_type) ?>">
|
||||
<dl>
|
||||
<dt><label for="username">Username: </label></dt>
|
||||
<dd><input type="text" id="username" name="username" required="required" /></dd>
|
||||
|
||||
<dt><label for="password">Password: </label></dt>
|
||||
<dd><input type="password" id="password" name="password" required="required" /></dd>
|
||||
|
||||
<dt> </dt>
|
||||
<dd><input type="submit" value="Login" /></dd>
|
||||
</dl>
|
||||
</form>
|
||||
</aside>
|
||||
<form method="post" action="<?= $url->generate('login.post') ?>">
|
||||
<table class="form invisible">
|
||||
<tr>
|
||||
<td><label for="password">Password: </label></td>
|
||||
<td><input type="password" id="password" name="password" required="required" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td><button type="submit">Login</button></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</main>
|
|
@ -0,0 +1,88 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Aviat\AnimeClient;
|
||||
|
||||
$whose = $config->get('whose_list') . "'s ";
|
||||
$lastSegment = $urlGenerator->lastSegment();
|
||||
$extraSegment = $lastSegment === 'list' ? '/list' : '';
|
||||
$hasAnime = stripos($_SERVER['REQUEST_URI'], 'anime') !== FALSE;
|
||||
$hasManga = stripos($_SERVER['REQUEST_URI'], 'manga') !== FALSE;
|
||||
|
||||
?>
|
||||
<div id="main-nav" class="flex flex-align-end flex-wrap">
|
||||
<span class="flex-no-wrap grow-1">
|
||||
<?php if(strpos($route_path, 'collection') === FALSE): ?>
|
||||
<?= $helper->a(
|
||||
$urlGenerator->defaultUrl($url_type),
|
||||
$whose . ucfirst($url_type) . ' List'
|
||||
) ?>
|
||||
<?php if($config->get("show_{$url_type}_collection")): ?>
|
||||
[<?= $helper->a(
|
||||
$url->generate("{$url_type}.collection.view") . $extraSegment,
|
||||
ucfirst($url_type) . ' Collection'
|
||||
) ?>]
|
||||
<?php endif ?>
|
||||
<?php if($config->get("show_{$other_type}_collection")): ?>
|
||||
[<?= $helper->a(
|
||||
$url->generate("{$other_type}.collection.view") . $extraSegment,
|
||||
ucfirst($other_type) . ' Collection'
|
||||
) ?>]
|
||||
<?php endif ?>
|
||||
[<?= $helper->a(
|
||||
$urlGenerator->defaultUrl($other_type) . $extraSegment,
|
||||
ucfirst($other_type) . ' List'
|
||||
) ?>]
|
||||
<?php else: ?>
|
||||
<?= $whose . ucfirst($url_type) . ' Collection' ?>
|
||||
<?php if($config->get("show_{$other_type}_collection")): ?>
|
||||
[<?= $helper->a(
|
||||
$url->generate("{$other_type}.collection.view") . $extraSegment,
|
||||
ucfirst($other_type) . ' Collection'
|
||||
) ?>]
|
||||
<?php endif ?>
|
||||
[<?= $helper->a($urlGenerator->defaultUrl('anime') . $extraSegment, 'Anime List') ?>]
|
||||
[<?= $helper->a($urlGenerator->defaultUrl('manga') . $extraSegment, 'Manga List') ?>]
|
||||
<?php endif ?>
|
||||
<?php if ($auth->isAuthenticated() && $config->get(['cache', 'driver']) !== 'null'): ?>
|
||||
<span class="flex-no-wrap small-font">
|
||||
<button type="button" class="js-clear-cache user-btn">Clear API Cache</button>
|
||||
</span>
|
||||
<?php endif ?>
|
||||
</span>
|
||||
|
||||
<span class="flex-no-wrap small-font">[<?= $helper->a(
|
||||
$url->generate('default_user_info'),
|
||||
'About '. $config->get('whose_list')
|
||||
) ?>]</span>
|
||||
|
||||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<span class="flex-no-wrap small-font">
|
||||
<?= $helper->a(
|
||||
$url->generate('settings'),
|
||||
'Settings',
|
||||
['class' => 'bracketed']
|
||||
) ?>
|
||||
</span>
|
||||
<span class="flex-no-wrap small-font">
|
||||
<?= $helper->a(
|
||||
$url->generate('logout'),
|
||||
'Logout',
|
||||
['class' => 'bracketed']
|
||||
) ?>
|
||||
</span>
|
||||
<?php else: ?>
|
||||
<span class="flex-no-wrap small-font">
|
||||
[<?= $helper->a($url->generate('login'), "{$whose} Login") ?>]
|
||||
</span>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<nav>
|
||||
<?php if ($container->get('util')->isViewPage() && ($hasAnime || $hasManga)): ?>
|
||||
<?= $helper->menu($menu_name) ?>
|
||||
<br />
|
||||
<ul>
|
||||
<li class="<?= Util::isNotSelected('list', $lastSegment) ?>"><a href="<?= $urlGenerator->url($route_path) ?>">Cover View</a></li>
|
||||
<li class="<?= Util::isSelected('list', $lastSegment) ?>"><a href="<?= $urlGenerator->url("{$route_path}/list") ?>">List View</a></li>
|
||||
</ul>
|
||||
<?php endif ?>
|
||||
</nav>
|
|
@ -0,0 +1,39 @@
|
|||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<main>
|
||||
<h2>Add Manga to your List</h2>
|
||||
<form action="<?= $action_url ?>" method="post">
|
||||
<section>
|
||||
<div class="cssload-loader" hidden="hidden">
|
||||
<div class="cssload-inner cssload-one"></div>
|
||||
<div class="cssload-inner cssload-two"></div>
|
||||
<div class="cssload-inner cssload-three"></div>
|
||||
</div>
|
||||
<label for="search">Search for manga by name: <input type="search" id="search" /></label>
|
||||
<section id="series-list" class="media-wrap">
|
||||
</section>
|
||||
</section>
|
||||
<br />
|
||||
<table class="invisible form">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><label for="status">Reading Status</label></td>
|
||||
<td>
|
||||
<select name="status" id="status">
|
||||
<?php foreach($status_list as $status_key => $status_title): ?>
|
||||
<option value="<?= $status_key ?>"><?= $status_title ?></option>
|
||||
<?php endforeach ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>
|
||||
<input type="hidden" name="type" value="manga" />
|
||||
<button type="submit">Save</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</main>
|
||||
<?php endif ?>
|
|
@ -1,49 +1,94 @@
|
|||
<main>
|
||||
<main class="media-list">
|
||||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<a class="bracketed" href="<?= $url->generate('manga.add.get') ?>">Add Item</a>
|
||||
<?php endif ?>
|
||||
<?php if (empty($sections)): ?>
|
||||
<h3>There's nothing here!</h3>
|
||||
<?php else: ?>
|
||||
<br />
|
||||
<label>Filter: <input type='text' class='media-filter' /></label>
|
||||
<br />
|
||||
<?php foreach ($sections as $name => $items): ?>
|
||||
<?php if (empty($items)): ?>
|
||||
<section class="status">
|
||||
<h2><?= $name ?></h2>
|
||||
<h2><?= $escape->html($name) ?></h2>
|
||||
<h3>There's nothing here!</h3>
|
||||
</section>
|
||||
<?php else: ?>
|
||||
<section class="status">
|
||||
<h2><?= $escape->html($name) ?></h2>
|
||||
<section class="media-wrap">
|
||||
<?php foreach($items as $item): ?>
|
||||
<article class="media" id="manga-<?= $item['id'] ?>">
|
||||
<?php if (is_logged_in()): ?>
|
||||
<div class="edit_buttons" hidden>
|
||||
<button class="plus_one_chapter">+1 Chapter</button>
|
||||
<button class="plus_one_volume">+1 Volume</button>
|
||||
<article class="media" data-kitsu-id="<?= $item['id'] ?>" data-mal-id="<?= $item['mal_id'] ?>">
|
||||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<div class="edit-buttons" hidden>
|
||||
<button class="plus-one-chapter">+1 Chapter</button>
|
||||
<?php /* <button class="plus-one-volume">+1 Volume</button> */ ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<img src="<?= $item['manga']['poster_image'] ?>" />
|
||||
<?= $helper->picture("images/manga/{$item['manga']['id']}.webp") ?>
|
||||
<div class="name">
|
||||
<a href="https://hummingbird.me/manga/<?= $item['manga_id'] ?>">
|
||||
<?= $item['manga']['romaji_title'] ?>
|
||||
<?= (isset($item['manga']['english_title'])) ? "<br />({$item['manga']['english_title']})" : ""; ?>
|
||||
<a href="<?= $url->generate('manga.details', ['id' => $item['manga']['slug']]) ?>">
|
||||
<?= $escape->html($item['manga']['title']) ?>
|
||||
<?php foreach($item['manga']['titles'] as $title): ?>
|
||||
<br /><small><?= $title ?></small>
|
||||
<?php endforeach ?>
|
||||
</a>
|
||||
</div>
|
||||
<div class="table">
|
||||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<div class="row">
|
||||
<div class="user_rating">Rating: <?= ($item['rating'] > 0) ? (int)($item['rating'] * 2) : '-' ?> / 10</div>
|
||||
<span class="edit">
|
||||
<a class="bracketed"
|
||||
title="Edit information about this manga"
|
||||
href="<?= $url->generate('edit', [
|
||||
'controller' => 'manga',
|
||||
'id' => $item['id'],
|
||||
'status' => $name
|
||||
]) ?>">
|
||||
Edit
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<div class="row">
|
||||
<div><?= $item['manga']['type'] ?></div>
|
||||
<div class="user-rating">Rating: <?= $item['user_rating'] ?> / 10</div>
|
||||
</div>
|
||||
|
||||
<?php if ($item['rereading']): ?>
|
||||
<div class="row">
|
||||
<?php foreach(['rereading'] as $attr): ?>
|
||||
<?php if($item[$attr]): ?>
|
||||
<span class="item-<?= $attr ?>"><?= ucfirst($attr) ?></span>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($item['reread'] > 0): ?>
|
||||
<div class="row">
|
||||
<div>Reread <?= $item['reread'] ?> time(s)</div>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="chapter_completion">
|
||||
Chapters: <span class="chapters_read"><?= $item['chapters_read'] ?></span> /
|
||||
<span class="chapter_count"><?= ($item['manga']['chapter_count'] > 0) ? $item['manga']['chapter_count'] : "-" ?></span>
|
||||
Chapters: <span class="chapters_read"><?= $item['chapters']['read'] ?></span> /
|
||||
<span class="chapter_count"><?= $item['chapters']['total'] ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<?php /* </div>
|
||||
<div class="row"> */ ?>
|
||||
<div class="volume_completion">
|
||||
Volumes: <span class="volumes_read"><?= $item['volumes_read'] ?></span> /
|
||||
<span class="volume_count"><?= ($item['manga']['volume_count'] > 0) ? $item['manga']['volume_count'] : "-" ?></span>
|
||||
Volumes: <span class="volume_count"><?= $item['volumes']['total'] ?></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php /*<div class="medium_metadata">
|
||||
<div class="media_type"><?= $item['manga']['manga_type'] ?></div>
|
||||
</div> */ ?>
|
||||
</article>
|
||||
<?php endforeach ?>
|
||||
</section>
|
||||
</section>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
<?php endif ?>
|
||||
</main>
|
||||
<?php if (is_logged_in()): ?>
|
||||
<script src="<?= asset_url('js.php?g=edit') ?>"></script>
|
||||
<?php endif ?>
|
|
@ -0,0 +1,104 @@
|
|||
<main class="details fixed">
|
||||
<section class="flex flex-no-wrap">
|
||||
<aside class="info">
|
||||
<?= $helper->picture("images/manga/{$data['id']}-original.webp", 'jpg', ['class' => 'cover']) ?>
|
||||
|
||||
<br />
|
||||
|
||||
<table class="media-details">
|
||||
<tr>
|
||||
<td>Manga Type</td>
|
||||
<td><?= ucfirst($data['manga_type']) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Volume Count</td>
|
||||
<td><?= $data['volume_count'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Chapter Count</td>
|
||||
<td><?= $data['chapter_count'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Genres</td>
|
||||
<td>
|
||||
<?= implode(', ', $data['genres']); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
</aside>
|
||||
<article class="text">
|
||||
<h2 class="toph"><a rel="external" href="<?= $data['url'] ?>"><?= $data['title'] ?></a></h2>
|
||||
<?php foreach ($data['titles'] as $title): ?>
|
||||
<h3><?= $title ?></h3>
|
||||
<?php endforeach ?>
|
||||
|
||||
<br />
|
||||
<div class="description">
|
||||
<p><?= str_replace("\n", '</p><p>', $data['synopsis']) ?></p>
|
||||
</div>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<?php if (count($data['characters']) > 0): ?>
|
||||
<h2>Characters</h2>
|
||||
|
||||
<div class="tabs">
|
||||
<?php $i = 0 ?>
|
||||
<?php foreach ($data['characters'] as $role => $list): ?>
|
||||
<input
|
||||
type="radio" name="character-role-tabs"
|
||||
id="character-tabs<?= $i ?>" <?= $i === 0 ? 'checked' : '' ?> />
|
||||
<label for="character-tabs<?= $i ?>"><?= ucfirst($role) ?></label>
|
||||
<section class="content media-wrap flex flex-wrap flex-justify-start">
|
||||
<?php foreach ($list as $id => $char): ?>
|
||||
<?php if ( ! empty($char['image']['original'])): ?>
|
||||
<article class="<?= $role === 'supporting' ? 'small-' : '' ?>character">
|
||||
<?php $link = $url->generate('character', ['slug' => $char['slug']]) ?>
|
||||
<div class="name">
|
||||
<?= $helper->a($link, $char['name']); ?>
|
||||
</div>
|
||||
<a href="<?= $link ?>">
|
||||
<?= $helper->picture("images/characters/{$id}.webp") ?>
|
||||
</a>
|
||||
</article>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
</section>
|
||||
<?php $i++ ?>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if (count($data['staff']) > 0): ?>
|
||||
<h2>Staff</h2>
|
||||
|
||||
<div class="vertical-tabs">
|
||||
<?php $i = 0 ?>
|
||||
<?php foreach ($data['staff'] as $role => $people): ?>
|
||||
<div class="tab">
|
||||
<input
|
||||
type="radio" name="staff-roles" id="staff-role<?= $i ?>" <?= $i === 0 ? 'checked' : '' ?> />
|
||||
<label for="staff-role<?= $i ?>"><?= $role ?></label>
|
||||
<section class='content media-wrap flex flex-wrap flex-justify-start'>
|
||||
<?php foreach ($people as $pid => $person): ?>
|
||||
<article class='character person'>
|
||||
<?php $link = $url->generate('person', ['id' => $pid]) ?>
|
||||
<div class="name">
|
||||
<a href="<?= $link ?>">
|
||||
<?= $person['name'] ?>
|
||||
</a>
|
||||
</div>
|
||||
<a href="<?= $link ?>">
|
||||
<?= $helper->picture("images/people/{$pid}.webp") ?>
|
||||
</a>
|
||||
</article>
|
||||
<?php endforeach ?>
|
||||
</section>
|
||||
</div>
|
||||
<?php $i++ ?>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</main>
|
|
@ -0,0 +1,111 @@
|
|||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<main>
|
||||
<h2>
|
||||
Edit Manga List Item
|
||||
</h2>
|
||||
<form action="<?= $action ?>" method="post">
|
||||
<table class="invisible form">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<h3><?= $escape->html($item['manga']['title']) ?></h3>
|
||||
<?php foreach ($item['manga']['titles'] as $title): ?>
|
||||
<h4><?= $escape->html($title) ?></h4>
|
||||
<?php endforeach ?>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td rowspan="9">
|
||||
<?= $helper->picture("images/manga/{$item['manga']['id']}-original.webp", "jpg", [], ["width" => "390"]) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="status">Reading Status</label></td>
|
||||
<td>
|
||||
<select name="status" id="status">
|
||||
<?php foreach ($status_list as $val => $status): ?>
|
||||
<option <?php if ($item['reading_status'] === $val): ?>selected="selected"<?php endif ?>
|
||||
value="<?= $val ?>"><?= $status ?></option>
|
||||
<?php endforeach ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="series_rating">Rating</label></td>
|
||||
<td>
|
||||
<input type="number" min="0" max="10" maxlength="2" name="new_rating"
|
||||
value="<?= $item['user_rating'] ?>" id="series_rating" size="2"/> / 10
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="chapters_read">Chapters Read</label></td>
|
||||
<td>
|
||||
<input type="number" min="0" name="chapters_read" id="chapters_read"
|
||||
value="<?= $item['chapters']['read'] ?>"/> / <?= $item['chapters']['total'] ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="volumes_read">Volumes Read</label></td>
|
||||
<td>
|
||||
<?php /*<input type="number" disabled="disabled" min="0" name="volumes_read" id="volumes_read" value="" /> */ ?>
|
||||
- / <?= $item['volumes']['total'] ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="rereading_flag">Rereading?</label></td>
|
||||
<td>
|
||||
<input type="checkbox" name="rereading" id="rereading_flag"
|
||||
<?php if ($item['rereading'] === TRUE): ?>checked="checked"<?php endif ?>
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="reread_count">Reread Count</label></td>
|
||||
<td>
|
||||
<input type="number" min="0" id="reread_count" name="reread_count"
|
||||
value="<?= $item['reread'] ?>"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="notes">Notes</label></td>
|
||||
<td>
|
||||
<textarea name="notes" id="notes"><?= $escape->html($item['notes']) ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>
|
||||
<input type="hidden" value="<?= $item['id'] ?>" name="id"/>
|
||||
<input type="hidden" value="<?= $item['mal_id'] ?>" name="mal_id"/>
|
||||
<input type="hidden" value="<?= $item['manga']['slug'] ?>" name="manga_id"/>
|
||||
<input type="hidden" value="<?= $item['user_rating'] ?>" name="old_rating"/>
|
||||
<input type="hidden" value="true" name="edit"/>
|
||||
<button type="submit">Submit</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
<fieldset>
|
||||
<legend>Danger Zone</legend>
|
||||
<form class="js-delete" action="<?= $url->generate('manga.delete') ?>" method="post">
|
||||
<table class="form invisible">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="danger">
|
||||
<strong>Permanently</strong> remove this list item and <strong>all</strong> its data?
|
||||
</td>
|
||||
<td>
|
||||
<input type="hidden" value="<?= $item['id'] ?>" name="id"/>
|
||||
<input type="hidden" value="<?= $item['mal_id'] ?>" name="mal_id"/>
|
||||
<button type="submit" class="danger">Delete Entry</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</fieldset>
|
||||
</main>
|
||||
<?php endif ?>
|
|
@ -1,33 +1,78 @@
|
|||
<main>
|
||||
<main class="media-list">
|
||||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<a class="bracketed" href="<?= $url->generate('manga.add.get') ?>">Add Item</a>
|
||||
<?php endif ?>
|
||||
<?php if (empty($sections)): ?>
|
||||
<h3>There's nothing here!</h3>
|
||||
<?php else: ?>
|
||||
<br />
|
||||
<label>Filter: <input type='text' class='media-filter' /></label>
|
||||
<br />
|
||||
<?php foreach ($sections as $name => $items): ?>
|
||||
<h2><?= $name ?></h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Title</th>
|
||||
<th>Rating</th>
|
||||
<th>Chapters</th>
|
||||
<th>Volumes</th>
|
||||
<th>Type</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($items as $item): ?>
|
||||
<tr id="manga-<?= $item['manga']['id'] ?>">
|
||||
<td class="align_left">
|
||||
<a href="https://hummingbird.me/manga/<?= $item['manga']['id'] ?>">
|
||||
<?= $item['manga']['romaji_title'] ?>
|
||||
</a>
|
||||
<?= (array_key_exists('english_title', $item['manga'])) ? " · " . $item['manga']['english_title'] : "" ?>
|
||||
</td>
|
||||
<td><?= ($item['rating'] > 0) ? (int)($item['rating'] * 2) : '-' ?> / 10</td>
|
||||
<td><?= $item['chapters_read'] ?> / <?= ($item['manga']['chapter_count'] > 0) ? $item['manga']['chapter_count'] : "-" ?></td>
|
||||
<td><?= $item['volumes_read'] ?> / <?= ($item['manga']['volume_count'] > 0) ? $item['manga']['volume_count'] : "-" ?></td>
|
||||
<td><?= $item['manga']['manga_type'] ?></td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if (empty($items)): ?>
|
||||
<h3>There's nothing here!</h3>
|
||||
<?php else: ?>
|
||||
<table class='media-wrap'>
|
||||
<thead>
|
||||
<tr>
|
||||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<td> </td>
|
||||
<?php endif ?>
|
||||
<th>Title</th>
|
||||
<th>Rating</th>
|
||||
<th>Completed Chapters</th>
|
||||
<th># of Volumes</th>
|
||||
<th>Attributes</th>
|
||||
<th>Type</th>
|
||||
<th>Genres</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($items as $item): ?>
|
||||
<tr id="manga-<?= $item['id'] ?>">
|
||||
<?php if($auth->isAuthenticated()): ?>
|
||||
<td>
|
||||
<a class="bracketed" href="<?= $url->generate('edit', [
|
||||
'controller' => 'manga',
|
||||
'id' => $item['id'],
|
||||
'status' => $name
|
||||
]) ?>">Edit</a>
|
||||
</td>
|
||||
<?php endif ?>
|
||||
<td class="align-left">
|
||||
<a href="<?= $url->generate('manga.details', ['id' => $item['manga']['slug']]) ?>">
|
||||
<?= $item['manga']['title'] ?>
|
||||
</a>
|
||||
<?php foreach($item['manga']['titles'] as $title): ?>
|
||||
<br /><?= $title ?>
|
||||
<?php endforeach ?>
|
||||
</td>
|
||||
<td><?= $item['user_rating'] ?> / 10</td>
|
||||
<td><?= $item['chapters']['read'] ?> / <?= $item['chapters']['total'] ?></td>
|
||||
<td><?= $item['volumes']['total'] ?></td>
|
||||
<td>
|
||||
<ul>
|
||||
<?php if ($item['reread'] > 0): ?>
|
||||
<li>Reread <?= $item['reread'] ?> time(s)</li>
|
||||
<?php endif ?>
|
||||
<?php foreach(['rereading'] as $attr): ?>
|
||||
<?php if($item[$attr]): ?>
|
||||
<li><?= ucfirst($attr); ?></li>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</td>
|
||||
<td><?= $item['manga']['type'] ?></td>
|
||||
<td class="align-left">
|
||||
<?= implode(', ', $item['manga']['genres']) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
<?php endif ?>
|
||||
</main>
|
||||
<script src="<?= asset_url('js.php?g=table') ?>"></script>
|
||||
<script defer="defer" src="<?= $urlGenerator->assetUrl('js/tables.min.js') ?>"></script>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="message <?= $stat_class ?>">
|
||||
<div class="message <?= $escape->attr($message_type) ?>">
|
||||
<span class="icon"></span>
|
||||
<?= $message ?>
|
||||
<span class="close" onclick="this.parentElement.style.display='none'">x</span>
|
||||
<?= $escape->html($message) ?>
|
||||
<span class="close"></span>
|
||||
</div>
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
use function Aviat\AnimeClient\getLocalImg;
|
||||
use Aviat\AnimeClient\API\Kitsu;
|
||||
?>
|
||||
<h3>Voice Acting Roles</h3>
|
||||
<div class="tabs">
|
||||
<?php $i = 0; ?>
|
||||
<?php foreach($data['characters'] as $role => $characterList): ?>
|
||||
<input <?= $i === 0 ? 'checked="checked"' : '' ?> type="radio" name="character-type-tabs" id="character-type-<?= $i ?>" />
|
||||
<label for="character-type-<?= $i ?>"><h5><?= ucfirst($role) ?></h5></label>
|
||||
<section class="content">
|
||||
<table class="borderless max-table">
|
||||
<tr>
|
||||
<th>Character</th>
|
||||
<th>Series</th>
|
||||
</tr>
|
||||
<?php foreach ($characterList as $cid => $character): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<article class="character">
|
||||
<?php
|
||||
$link = $url->generate('character', ['slug' => $character['character']['slug']]);
|
||||
?>
|
||||
<a href="<?= $link ?>">
|
||||
<?php $imgPath = ($character['character']['image'] === NULL)
|
||||
? 'images/characters/empty.png'
|
||||
: getLocalImg($character['character']['image']['original']);
|
||||
|
||||
echo $helper->picture($imgPath);
|
||||
?>
|
||||
<div class="name">
|
||||
<?= $character['character']['canonicalName'] ?>
|
||||
</div>
|
||||
</a>
|
||||
</article>
|
||||
</td>
|
||||
<td>
|
||||
<section class="align-left media-wrap">
|
||||
<?php foreach ($character['media'] as $sid => $series): ?>
|
||||
<article class="media">
|
||||
<?php
|
||||
$link = $url->generate('anime.details', ['id' => $series['slug']]);
|
||||
$titles = Kitsu::filterTitles($series);
|
||||
?>
|
||||
<a href="<?= $link ?>">
|
||||
<?= $helper->picture("images/anime/{$sid}.webp") ?>
|
||||
</a>
|
||||
<div class="name">
|
||||
<a href="<?= $link ?>">
|
||||
<?= array_shift($titles) ?>
|
||||
<?php foreach ($titles as $title): ?>
|
||||
<br />
|
||||
<small><?= $title ?></small>
|
||||
<?php endforeach ?>
|
||||
</a>
|
||||
</div>
|
||||
</article>
|
||||
<?php endforeach ?>
|
||||
</section>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</section>
|
||||
<?php $i++ ?>
|
||||
<?php endforeach ?>
|
||||
</div>
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
use Aviat\AnimeClient\API\Kitsu;
|
||||
|
||||
?>
|
||||
<main class="details fixed">
|
||||
<section class="flex flex-no-wrap">
|
||||
<div>
|
||||
<?= $helper->picture("images/people/{$data['id']}-original.webp", 'jpg', ['class' => 'cover' ]) ?>
|
||||
</div>
|
||||
<div>
|
||||
<h2 class="toph"><?= $data['name'] ?></h2>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?php if ( ! empty($data['staff'])): ?>
|
||||
<section>
|
||||
<h3>Castings</h3>
|
||||
<div class="vertical-tabs">
|
||||
<?php $i = 0 ?>
|
||||
<?php foreach ($data['staff'] as $role => $entries): ?>
|
||||
<div class="tab">
|
||||
<input
|
||||
type="radio" name="staff-roles" id="staff-role<?= $i ?>" <?= $i === 0 ? 'checked' : '' ?> />
|
||||
<label for="staff-role<?= $i ?>"><?= $role ?></label>
|
||||
<?php foreach ($entries as $type => $casting): ?>
|
||||
<?php if ($type === 'characters') continue; ?>
|
||||
<?php if ( ! (empty($entries['manga']) || empty($entries['anime']))): ?>
|
||||
<h4><?= ucfirst($type) ?></h4>
|
||||
<?php endif ?>
|
||||
<section class="content">
|
||||
<?php foreach ($casting as $sid => $series): ?>
|
||||
<article class="media">
|
||||
<?php
|
||||
$mediaType = in_array($type, ['anime', 'manga'], TRUE) ? $type : 'anime';
|
||||
$link = $url->generate("{$mediaType}.details", ['id' => $series['slug']]);
|
||||
$titles = Kitsu::filterTitles($series);
|
||||
?>
|
||||
<a href="<?= $link ?>">
|
||||
<?= $helper->picture("images/{$type}/{$sid}.webp") ?>
|
||||
</a>
|
||||
<div class="name">
|
||||
<a href="<?= $link ?>">
|
||||
<?= array_shift($titles) ?>
|
||||
<?php foreach ($titles as $title): ?>
|
||||
<br />
|
||||
<small><?= $title ?></small>
|
||||
<?php endforeach ?>
|
||||
</a>
|
||||
</div>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
</section>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<?php $i++ ?>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ( ! (empty($data['characters']['main']) || empty($data['characters']['supporting']))): ?>
|
||||
<section>
|
||||
<?php include 'character-mapping.php' ?>
|
||||
</section>
|
||||
<?php endif ?>
|
||||
</main>
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
// Higher scoped variables:
|
||||
// $fields
|
||||
// $hiddenFields
|
||||
// $nestedPrefix
|
||||
?>
|
||||
|
||||
<?php foreach ($fields as $name => $field): ?>
|
||||
<?php $fieldname = ($section === 'config' || $nestedPrefix !== 'config') ? "{$nestedPrefix}[{$name}]" : "{$nestedPrefix}[{$section}][{$name}]"; ?>
|
||||
<?php if ($field['type'] === 'subfield'): ?>
|
||||
<section>
|
||||
<h4><?= $field['title'] ?></h4>
|
||||
<?php include_once '_form.php'; ?>
|
||||
</section>
|
||||
<?php elseif ( ! empty($field['display'])): ?>
|
||||
<article>
|
||||
<label for="<?= $fieldname ?>"><?= $field['title'] ?></label><br />
|
||||
<small><?= $field['description'] ?></small><br />
|
||||
<?= $helper->field($fieldname, $field); ?>
|
||||
</article>
|
||||
<?php else: ?>
|
||||
<?php $hiddenFields[] = $helper->field($fieldname, $field); ?>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
if ( ! $auth->isAuthenticated())
|
||||
{
|
||||
echo '<h1>Not Authorized</h1>';
|
||||
return;
|
||||
}
|
||||
|
||||
$sectionMapping = [
|
||||
'anilist' => 'Anilist API Integration',
|
||||
'config' => 'General Settings',
|
||||
'cache' => 'Caching',
|
||||
'database' => 'Collection Database Settings',
|
||||
];
|
||||
|
||||
$hiddenFields = [];
|
||||
$nestedPrefix = 'config';
|
||||
?>
|
||||
|
||||
<form action="<?= $url->generate('settings-post') ?>" method="POST">
|
||||
<main class='settings form'>
|
||||
<button type="submit">Save Changes</button>
|
||||
<div class="tabs">
|
||||
<?php $i = 0; ?>
|
||||
|
||||
<?php foreach ($form as $section => $fields): ?>
|
||||
<input <?= $i === 0 ? 'checked="checked"' : '' ?> type="radio" id="settings-tab<?= $i ?>"
|
||||
name="settings-tabs"
|
||||
/>
|
||||
<label for="settings-tab<?= $i ?>"><h3><?= $sectionMapping[$section] ?></h3></label>
|
||||
<section class="content">
|
||||
<?php require __DIR__ . '/_form.php' ?>
|
||||
<?php if ($section === 'anilist'): ?>
|
||||
<hr />
|
||||
<?php $auth = $anilistModel->checkAuth(); ?>
|
||||
<?php if (array_key_exists('errors', $auth)): ?>
|
||||
<p class="static-message error">Not Authorized.</p>
|
||||
<?= $helper->a(
|
||||
$url->generate('anilist-redirect'),
|
||||
'Link Anilist Account'
|
||||
) ?>
|
||||
<?php else: ?>
|
||||
<?php $expires = $config->get(['anilist', 'access_token_expires']); ?>
|
||||
<p class="static-message info">
|
||||
Linked to Anilist. Your access token will expire around <?= date('F j, Y, g:i a T', $expires) ?>
|
||||
</p>
|
||||
<?= $helper->a(
|
||||
$url->generate('anilist-redirect'),
|
||||
'Update Access Token'
|
||||
) ?>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
</section>
|
||||
<?php $i++; ?>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<br />
|
||||
<?php foreach ($hiddenFields as $field): ?>
|
||||
<?= $field->__toString() ?>
|
||||
<?php endforeach ?>
|
||||
<button type="submit">Save Changes</button>
|
||||
</main>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
$setupErrors = \Aviat\AnimeClient\checkFolderPermissions($container->get('config'));
|
||||
?>
|
||||
|
||||
<?php if ( ! empty($setupErrors)): ?>
|
||||
<aside class="message error">
|
||||
<h1>Issues with server setup:</h1>
|
||||
|
||||
<?php if (array_key_exists('missing', $setupErrors)): ?>
|
||||
<h3>The following folders need to be created, and writable.</h3>
|
||||
<ul>
|
||||
<?php foreach ($setupErrors['missing'] as $error): ?>
|
||||
<li><?= $error ?></li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if (array_key_exists('writable', $setupErrors)): ?>
|
||||
<h3>The following folders are not writable by the server.</h3>
|
||||
<ul>
|
||||
<?php foreach($setupErrors['writable'] as $error): ?>
|
||||
<li><?= $error ?></li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
<?php endif ?>
|
||||
</aside>
|
||||
<?php endif ?>
|
|
@ -0,0 +1,136 @@
|
|||
<?php
|
||||
use Aviat\AnimeClient\API\Kitsu;
|
||||
?>
|
||||
<main class="user-page details">
|
||||
<h2 class="toph">
|
||||
<?= $helper->a(
|
||||
"https://kitsu.io/users/{$data['slug']}",
|
||||
$data['name'], [
|
||||
'title' => 'View profile on Kitsu'
|
||||
])
|
||||
?>
|
||||
</h2>
|
||||
|
||||
<p><?= $escape->html($data['about']) ?></p>
|
||||
|
||||
<section class="flex flex-no-wrap">
|
||||
<aside class="info">
|
||||
<center>
|
||||
<?= $helper->img($urlGenerator->assetUrl($data['avatar']), ['alt' => '']); ?>
|
||||
</center>
|
||||
<br />
|
||||
<table class="media-details">
|
||||
<tr>
|
||||
<td>Location</td>
|
||||
<td><?= $data['location'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Website</td>
|
||||
<td><?= $helper->a($data['website'], $data['website']) ?></td>
|
||||
</tr>
|
||||
<?php if ( ! empty($data['waifu'])): ?>
|
||||
<tr>
|
||||
<td><?= $escape->html($data['waifu']['label']) ?></td>
|
||||
<td>
|
||||
<?php
|
||||
$character = $data['waifu']['character'];
|
||||
echo $helper->a(
|
||||
$url->generate('character', ['slug' => $character['slug']]),
|
||||
$character['canonicalName']
|
||||
);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif ?>
|
||||
</table>
|
||||
|
||||
<h3>User Stats</h3><br />
|
||||
<table class="media-details">
|
||||
<?php foreach($data['stats'] as $label => $stat): ?>
|
||||
<tr>
|
||||
<td><?= $label ?></td>
|
||||
<td><?= $stat ?></td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</table>
|
||||
</aside>
|
||||
<article>
|
||||
<?php if ( ! empty($data['favorites'])): ?>
|
||||
<h3>Favorites</h3>
|
||||
<div class="tabs">
|
||||
<?php $i = 0 ?>
|
||||
<?php if ( ! empty($data['favorites']['characters'])): ?>
|
||||
<input type="radio" name="user-favorites" id="user-fav-chars" <?= $i === 0 ? 'checked' : '' ?> />
|
||||
<label for="user-fav-chars">Characters</label>
|
||||
<section class="content full-width media-wrap">
|
||||
<?php foreach($data['favorites']['characters'] as $id => $char): ?>
|
||||
<?php if ( ! empty($char['image']['original'])): ?>
|
||||
<article class="character">
|
||||
<?php $link = $url->generate('character', ['slug' => $char['slug']]) ?>
|
||||
<div class="name"><?= $helper->a($link, $char['canonicalName']); ?></div>
|
||||
<a href="<?= $link ?>">
|
||||
<?= $helper->picture("images/characters/{$char['id']}.webp") ?>
|
||||
</a>
|
||||
</article>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
</section>
|
||||
<?php $i++; ?>
|
||||
<?php endif ?>
|
||||
<?php if ( ! empty($data['favorites']['anime'])): ?>
|
||||
<input type="radio" name="user-favorites" id="user-fav-anime" <?= $i === 0 ? 'checked' : '' ?> />
|
||||
<label for="user-fav-anime">Anime</label>
|
||||
<section class="content full-width media-wrap">
|
||||
<?php foreach($data['favorites']['anime'] as $anime): ?>
|
||||
<article class="media">
|
||||
<?php
|
||||
$link = $url->generate('anime.details', ['id' => $anime['slug']]);
|
||||
$titles = Kitsu::filterTitles($anime);
|
||||
?>
|
||||
<a href="<?= $link ?>">
|
||||
<?= $helper->picture("images/anime/{$anime['id']}.webp") ?>
|
||||
</a>
|
||||
<div class="name">
|
||||
<a href="<?= $link ?>">
|
||||
<?= array_shift($titles) ?>
|
||||
<?php foreach ($titles as $title): ?>
|
||||
<br /><small><?= $title ?></small>
|
||||
<?php endforeach ?>
|
||||
</a>
|
||||
</div>
|
||||
</article>
|
||||
<?php endforeach ?>
|
||||
</section>
|
||||
<?php $i++; ?>
|
||||
<?php endif ?>
|
||||
<?php if ( ! empty($data['favorites']['manga'])): ?>
|
||||
<input type="radio" name="user-favorites" id="user-fav-manga" <?= $i === 0 ? 'checked' : '' ?> />
|
||||
<label for="user-fav-manga">Manga</label>
|
||||
<section class="content full-width media-wrap">
|
||||
<?php foreach($data['favorites']['manga'] as $manga): ?>
|
||||
<article class="media">
|
||||
<?php
|
||||
$link = $url->generate('manga.details', ['id' => $manga['slug']]);
|
||||
$titles = Kitsu::filterTitles($manga);
|
||||
?>
|
||||
<a href="<?= $link ?>">
|
||||
<?= $helper->picture("images/manga/{$manga['id']}.webp") ?>
|
||||
</a>
|
||||
<div class="name">
|
||||
<a href="<?= $link ?>">
|
||||
<?= array_shift($titles) ?>
|
||||
<?php foreach ($titles as $title): ?>
|
||||
<br /><small><?= $title ?></small>
|
||||
<?php endforeach ?>
|
||||
</a>
|
||||
</div>
|
||||
</article>
|
||||
<?php endforeach ?>
|
||||
</section>
|
||||
<?php $i++; ?>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</article>
|
||||
</section>
|
||||
</main>
|
|
@ -0,0 +1,28 @@
|
|||
<documentation title="Closing comments instead of PHP closing tag">
|
||||
<standard>
|
||||
<![CDATA[
|
||||
The PHP closing tag on a PHP document ?> is optional to the PHP parser. However, if used, any whitespace following the closing tag, whether introduced by the developer, user, or an FTP application, can cause unwanted output, PHP errors, or if the latter are suppressed, blank pages. For this reason, all PHP files should OMIT the closing PHP tag, and instead use a comment block to mark the end of file and it's location relative to the application root. This allows you to still identify a file as being complete and not truncated.
|
||||
]]>
|
||||
</standard>
|
||||
<code_comparison>
|
||||
<code title="Examples of valid closing comments">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
echo "Here's my code!";
|
||||
|
||||
/* End of file myfile.php */
|
||||
/* Location: ./system/modules/mymodule/myfile.php */
|
||||
]]>
|
||||
</code>
|
||||
<code title="Examples of invalid closing comments">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
echo "Here's my code!";
|
||||
|
||||
?>
|
||||
]]>
|
||||
</code>
|
||||
</code_comparison>
|
||||
</documentation>
|
|
@ -0,0 +1,7 @@
|
|||
<documentation title="Unicode (UTF-8) encoding without BOM">
|
||||
<standard>
|
||||
<![CDATA[
|
||||
Files should be saved with Unicode (UTF-8) encoding. The BOM should not be used. Unlike UTF-16 and UTF-32, there's no byte order to indicate in a UTF-8 encoded file, and the BOM can have a negative side effect in PHP of sending output, preventing the application from being able to set its own headers. Unix line endings should be used (LF).
|
||||
]]>
|
||||
</standard>
|
||||
</documentation>
|
|
@ -0,0 +1,31 @@
|
|||
<documentation title="Constructor Names">
|
||||
<standard>
|
||||
<![CDATA[
|
||||
Class names should always start with an uppercase letter. Multiple words should be separated with an underscore, and not CamelCased. All other class methods should be entirely lowercased and named to clearly indicate their function, preferably including a verb. Try to avoid overly long and verbose names.
|
||||
]]>
|
||||
</standard>
|
||||
<code_comparison>
|
||||
<code title="Examples of valid constructor name">
|
||||
<![CDATA[
|
||||
class Super_class
|
||||
{
|
||||
function Super_class()
|
||||
{
|
||||
echo 'Some code here !';
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</code>
|
||||
<code title="Examples of invalid constructor name">
|
||||
<![CDATA[
|
||||
class Super_class
|
||||
{
|
||||
function __constructor()
|
||||
{
|
||||
echo 'Some code here !';
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</code>
|
||||
</code_comparison>
|
||||
</documentation>
|
|
@ -0,0 +1,21 @@
|
|||
<documentation title="Class names">
|
||||
<standard>
|
||||
<![CDATA[
|
||||
Class names should always start with an uppercase letter. Multiple words should be separated with an underscore, and not CamelCased. All other class methods should be entirely lowercased and named to clearly indicate their function, preferably including a verb. Try to avoid overly long and verbose names.
|
||||
]]>
|
||||
</standard>
|
||||
<code_comparison>
|
||||
<code title="Examples of valid class names">
|
||||
<![CDATA[
|
||||
class Super_class
|
||||
]]>
|
||||
</code>
|
||||
<code title="Examples of invalid class names">
|
||||
<![CDATA[
|
||||
class SuperClass // words not separated with underscores and words next to the first one start with an upper case
|
||||
class superclass // words not separated with underscores
|
||||
class Super_Class // words next to the first one start with an upper case
|
||||
]]>
|
||||
</code>
|
||||
</code_comparison>
|
||||
</documentation>
|
|
@ -0,0 +1,21 @@
|
|||
<documentation title="File names">
|
||||
<standard>
|
||||
<![CDATA[
|
||||
To be able to find which class is contained in a file, file names should be case-insensitively equal to class names. Some operating systems and tools are case-insensitive, though other are. So, file names should be in lower case to avoid any trouble.
|
||||
]]>
|
||||
</standard>
|
||||
<code_comparison>
|
||||
<code title="Examples of valid file names">
|
||||
<![CDATA[
|
||||
super_class.php
|
||||
]]>
|
||||
</code>
|
||||
<code title="Examples of invalid file names">
|
||||
<![CDATA[
|
||||
superclass.php // words not separated with underscores
|
||||
SuperClass.php // not in lower case and words not separated with underscores
|
||||
Super_class.php // not in lower case
|
||||
]]>
|
||||
</code>
|
||||
</code_comparison>
|
||||
</documentation>
|
|
@ -0,0 +1,27 @@
|
|||
<documentation title="Function and Method Names">
|
||||
<standard>
|
||||
<![CDATA[
|
||||
Class names should always start with an uppercase letter. Multiple words should be separated with an underscore, and not CamelCased. All other class methods should be entirely lowercased and named to clearly indicate their function, preferably including a verb. Try to avoid overly long and verbose names.
|
||||
Methods and variables that are only accessed internally by your class, such as utility and helper functions that your public methods use for code abstraction, should be prefixed with an underscore.
|
||||
]]>
|
||||
</standard>
|
||||
<code_comparison>
|
||||
<code title="Examples of valid method names">
|
||||
<![CDATA[
|
||||
function get_file_properties() // descriptive, underscore separator, and all lowercase letters
|
||||
private function _get_file_properties()
|
||||
]]>
|
||||
</code>
|
||||
<code title="Examples of invalid method names">
|
||||
<![CDATA[
|
||||
function fileproperties() // not descriptive and needs underscore separator
|
||||
function fileProperties() // not descriptive and uses CamelCase
|
||||
function getfileproperties() // Better! But still missing underscore separator
|
||||
function getFileProperties() // uses CamelCase
|
||||
function get_the_file_properties_from_the_file() // wordy
|
||||
private function get_the_file_properties() // not prefixed with an underscor, though private
|
||||
function _get_the_file_properties() // prefixed with an underscor, though public
|
||||
]]>
|
||||
</code>
|
||||
</code_comparison>
|
||||
</documentation>
|
|
@ -0,0 +1,31 @@
|
|||
<documentation title="Variable names">
|
||||
<standard>
|
||||
<![CDATA[
|
||||
Namely, variables should contain only lowercase letters, use underscore separators, and be reasonably named to indicate their purpose and contents. Very short, non-word variables should only be used as iterators in for() loops.
|
||||
Methods and variables that are only accessed internally by your class, such as utility and helper functions that your public methods use for code abstraction, should be prefixed with an underscore.
|
||||
]]>
|
||||
</standard>
|
||||
<code_comparison>
|
||||
<code title="Examples of valid variable names">
|
||||
<![CDATA[
|
||||
for ($j = 0; $j < 10; $j++)
|
||||
$str
|
||||
$buffer
|
||||
$group_id
|
||||
$last_city
|
||||
private $_internal_data;
|
||||
]]>
|
||||
</code>
|
||||
<code title="Examples of invalid variable names">
|
||||
<![CDATA[
|
||||
$j = 'foo'; // single letter variables should only be used in for() loops
|
||||
$Str // contains uppercase letters
|
||||
$bufferedText // uses CamelCasing, and could be shortened without losing semantic meaning
|
||||
$groupid // multiple words, needs underscore separator
|
||||
$name_of_last_city_used // too long
|
||||
private $internal_data; // not prefixed with an underscor, though private
|
||||
$_public_attribute; // prefixed with an underscor, though public
|
||||
]]>
|
||||
</code>
|
||||
</code_comparison>
|
||||
</documentation>
|
|
@ -0,0 +1,40 @@
|
|||
<documentation title="Strict comparison operators">
|
||||
<standard>
|
||||
<![CDATA[
|
||||
Some PHP functions return FALSE on failure, but may also have a valid return value of "" or 0, which would evaluate to FALSE in loose comparisons. Be explicit by comparing the variable type when using these return values in conditionals to ensure the return value is indeed what you expect, and not a value that has an equivalent loose-type evaluation.
|
||||
Use the same stringency in returning and checking your own variables. Use === and !== as necessary.
|
||||
]]>
|
||||
</standard>
|
||||
<code_comparison>
|
||||
<code title="Valid strict comparison">
|
||||
<![CDATA[
|
||||
if (strpos($str, 'foo') === FALSE) {
|
||||
echo 'Do something.';
|
||||
}
|
||||
|
||||
function build_string($str = "")
|
||||
{
|
||||
if ($str === "") {
|
||||
echo 'Buid string.';
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</code>
|
||||
<code title="Invalid loose comparison">
|
||||
<![CDATA[
|
||||
// If 'foo' is at the beginning of the string, strpos will return a 0,
|
||||
// resulting in this conditional evaluating as TRUE
|
||||
if (strpos($str, 'foo') == FALSE) {
|
||||
echo 'Do something.';
|
||||
}
|
||||
|
||||
function build_string($str = "")
|
||||
{
|
||||
if ($str == "") { // uh-oh! What if FALSE or the integer 0 is passed as an argument?
|
||||
echo 'Buid string.';
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</code>
|
||||
</code_comparison>
|
||||
</documentation>
|
|
@ -0,0 +1,28 @@
|
|||
<documentation title="Double-quoted strings">
|
||||
<standard>
|
||||
<![CDATA[
|
||||
Always use single quoted strings unless you need variables parsed, and in cases where you do need variables parsed, use braces to prevent greedy token parsing. You may also use double-quoted strings if the string contains single quotes, so you do not have to use escape characters.
|
||||
]]>
|
||||
</standard>
|
||||
<code_comparison>
|
||||
<code title="Examples of invalid double-quoted strings">
|
||||
<![CDATA[
|
||||
"My String" // no variable parsing, so no use for double quotes
|
||||
"My string $foo" // needs braces
|
||||
'SELECT foo FROM bar WHERE baz = \'bag\'' // ugly
|
||||
'\r\n' // it isn't wrong, but it won't be interpreted as a new line feed
|
||||
]]>
|
||||
</code>
|
||||
<code title="Examples of valid double-quoted strings">
|
||||
<![CDATA[
|
||||
'My String'
|
||||
"My string {$foo}" // variables in strings may be enclosed with braces in 2 ways
|
||||
"My string ${foo}"
|
||||
"My string {$foo['bar']}" // variables in strings may be an array entry
|
||||
"My string {$foo->bar}" // variables in strings may be an object attribute
|
||||
"SELECT foo FROM bar WHERE baz = 'bag'"
|
||||
"\n" // not specified in Code Igniter coding standard, but it should be allowed
|
||||
]]>
|
||||
</code>
|
||||
</code_comparison>
|
||||
</documentation>
|
|
@ -0,0 +1,187 @@
|
|||
<?php
|
||||
/**
|
||||
* CodeIgniter_Sniffs_Commenting_InlineCommentSniff.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2011 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
/**
|
||||
* CodeIgniter_Sniffs_Commenting_InlineCommentSniff.
|
||||
*
|
||||
* Ensure the use of single line comments within code (i.e //)
|
||||
* and blank lines between large comment blocks and code.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2011 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
namespace CodeIgniter\Sniffs\Commenting;
|
||||
|
||||
use PHP_CodeSniffer\Sniffs\Sniff;
|
||||
use PHP_CodeSniffer\Files\File;
|
||||
|
||||
class InlineCommentSniff implements Sniff
|
||||
{
|
||||
/**
|
||||
* @var int Limit defining long comments.
|
||||
* Long comments count $longCommentLimit or more lines.
|
||||
*/
|
||||
public $longCommentLimit = 5;
|
||||
|
||||
/**
|
||||
* Returns an array of tokens this test wants to listen for.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
return array(
|
||||
T_COMMENT
|
||||
);
|
||||
}//end register()
|
||||
|
||||
/**
|
||||
* Processes this test, when one of its tokens is encountered.
|
||||
*
|
||||
* @param File $phpcsFile The current file being scanned.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function process(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
|
||||
// keep testing only if it's about the first comment of the block
|
||||
$previousCommentPtr = $phpcsFile->findPrevious($tokens[$stackPtr]['code'], $stackPtr - 1);
|
||||
if ($tokens[$previousCommentPtr]['line'] !== $tokens[$stackPtr]['line'] - 1) {
|
||||
if (TRUE !== $this->_checkCommentStyle($phpcsFile, $stackPtr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$commentLines = $this->_getCommentBlock($phpcsFile, $stackPtr);
|
||||
|
||||
if (count($commentLines) >= $this->longCommentLimit) {
|
||||
$this->_checkBlankLinesAroundLongComment($phpcsFile, $commentLines);
|
||||
}
|
||||
}
|
||||
}//end process()
|
||||
|
||||
|
||||
/**
|
||||
* Add error to $phpcsFile, if comment pointed by $stackPtr doesn't start
|
||||
* with '//'.
|
||||
*
|
||||
* @param File $phpcsFile The current file being scanned.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* that has to be a comment.
|
||||
*
|
||||
* @return bool TRUE if the content of the token pointed by $stackPtr starts
|
||||
* with //, FALSE if an error was added to $phpcsFile.
|
||||
*/
|
||||
private function _checkCommentStyle(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
if ($tokens[$stackPtr]['content']{0} === '#') {
|
||||
$error = 'Perl-style comments are not allowed; use "// Comment" or DocBlock comments instead';
|
||||
$phpcsFile->addError($error, $stackPtr, 'WrongStyle');
|
||||
return FALSE;
|
||||
} else if (substr($tokens[$stackPtr]['content'], 0, 2) === '/*'
|
||||
|| $tokens[$stackPtr]['content']{0} === '*'
|
||||
) {
|
||||
$error = 'Multi lines comments are not allowed; use "// Comment" DocBlock comments instead';
|
||||
$phpcsFile->addError($error, $stackPtr, 'WrongStyle');
|
||||
return FALSE;
|
||||
} else if (substr($tokens[$stackPtr]['content'], 0, 2) !== '//') {
|
||||
$error = 'Use single line or DocBlock comments within code';
|
||||
$phpcsFile->addError($error, $stackPtr, 'WrongStyle');
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}//_checkCommentStyle()
|
||||
|
||||
|
||||
/**
|
||||
* Gather into an array all comment lines to which $stackPtr belongs.
|
||||
*
|
||||
* @param File $phpcsFile The current file being scanned.
|
||||
* @param int $stackPtr Pointer to the first comment line.
|
||||
*
|
||||
* @return type array Pointers to tokens making up the comment block.
|
||||
*/
|
||||
private function _getCommentBlock(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
$commentLines = array($stackPtr);
|
||||
$nextComment = $stackPtr;
|
||||
$lastLine = $tokens[$stackPtr]['line'];
|
||||
|
||||
while (($nextComment = $phpcsFile->findNext($tokens[$stackPtr]['code'], ($nextComment + 1), null, false)) !== false) {
|
||||
if (($tokens[$nextComment]['line'] - 1) !== $lastLine) {
|
||||
// Not part of the block.
|
||||
break;
|
||||
}
|
||||
|
||||
$lastLine = $tokens[$nextComment]['line'];
|
||||
$commentLines[] = $nextComment;
|
||||
}
|
||||
|
||||
return $commentLines;
|
||||
}//_getCommentBlock()
|
||||
|
||||
|
||||
/**
|
||||
* Add errors to $phpcsFile, if $commentLines isn't enclosed with blank lines.
|
||||
*
|
||||
* @param File $phpcsFile The current file being scanned.
|
||||
* @param array $commentLines Lines of the comment block being checked.
|
||||
*
|
||||
* @return bool TRUE if $commentLines is enclosed with at least a blank line
|
||||
* before and after, FALSE otherwise.
|
||||
*/
|
||||
private function _checkBlankLinesAroundLongComment(File $phpcsFile, array $commentLines)
|
||||
{
|
||||
$hasBlankLinesAround = TRUE;
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
|
||||
// check blank line before the long comment
|
||||
$firstCommentPtr = reset($commentLines);
|
||||
$firstPreviousSpacePtr = $firstCommentPtr - 1;
|
||||
while (T_WHITESPACE === $tokens[$firstPreviousSpacePtr]['code'] && $firstPreviousSpacePtr > 0) {
|
||||
$firstPreviousSpacePtr--;
|
||||
}
|
||||
if ($tokens[$firstPreviousSpacePtr]['line'] >= $tokens[$firstCommentPtr]['line'] - 1) {
|
||||
$error = "Please add a blank line before comments counting more than {$this->longCommentLimit} lines.";
|
||||
$phpcsFile->addError($error, $firstCommentPtr, 'LongCommentWithoutSpacing');
|
||||
$hasBlankLinesAround = FALSE;
|
||||
}
|
||||
|
||||
// check blank line after the long comment
|
||||
$lastCommentPtr = end($commentLines);
|
||||
$lastNextSpacePtr = $lastCommentPtr + 1;
|
||||
while (T_WHITESPACE === $tokens[$lastNextSpacePtr]['code'] && $lastNextSpacePtr < count($tokens)) {
|
||||
$lastNextSpacePtr++;
|
||||
}
|
||||
if ($tokens[$lastNextSpacePtr]['line'] <= $tokens[$lastCommentPtr]['line'] + 1) {
|
||||
$error = "Please add a blank line after comments counting more than {$this->longCommentLimit} lines.";
|
||||
$phpcsFile->addError($error, $lastCommentPtr, 'LongCommentWithoutSpacing');
|
||||
$hasBlankLinesAround = FALSE;
|
||||
}
|
||||
|
||||
return $hasBlankLinesAround;
|
||||
}//end _checkBlanksAroundLongComment()
|
||||
|
||||
}//end class
|
||||
|
||||
?>
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
/**
|
||||
* CodeIgniter_Sniffs_Files_ByteOrderMarkSniff.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2006 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
/**
|
||||
* CodeIgniter_Sniffs_Files_ByteOrderMarkSniff.
|
||||
*
|
||||
* Ensures that no BOM appears at the beginning of file.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2006 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
namespace CodeIgniter\Sniffs\Files;
|
||||
|
||||
use PHP_CodeSniffer\Sniffs\Sniff;
|
||||
use PHP_CodeSniffer\Files\File;
|
||||
|
||||
class ByteOrderMarkSniff implements Sniff
|
||||
{
|
||||
/**
|
||||
* Returns an array of tokens this test wants to listen for.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
return array( T_OPEN_TAG );
|
||||
}//end register()
|
||||
|
||||
/**
|
||||
* List of supported BOM definitions.
|
||||
*
|
||||
* Use encoding names as keys and hex BOM representations as values.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getBomDefinitions()
|
||||
{
|
||||
return array(
|
||||
'UTF-8' => 'efbbbf',
|
||||
'UTF-16 (BE)' => 'feff',
|
||||
'UTF-16 (LE)' => 'fffe',
|
||||
'UTF-32 (BE)' => '0000feff',
|
||||
'UTF-32 (LE)' => 'fffe0000'
|
||||
);
|
||||
}//end getBomDefinitions()
|
||||
|
||||
/**
|
||||
* Process tokens.
|
||||
*
|
||||
* Actually, only proceed when we're at index 0, this should be the only case
|
||||
* that will contain BOM. Then check if BOM definition matches what
|
||||
* we've found as file's inline HTML. Inline HTML could be longer than just BOM
|
||||
* so make sure you test as much as needed.
|
||||
*
|
||||
* @param File $phpcsFile The current file being scanned.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function process(File $phpcsFile, $stackPtr )
|
||||
{
|
||||
// We are only interested if this is the first open tag.
|
||||
if ($stackPtr !== 0) {
|
||||
if ($phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)) !== false) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
$fileStartString = $tokens[0]['content'];
|
||||
foreach ($this->getBomDefinitions() as $bomName => $expectedBomHex) {
|
||||
$bomByteLength = strlen($expectedBomHex) / 2;
|
||||
$fileStartHex = bin2hex(substr($fileStartString, 0, $bomByteLength));
|
||||
if ($fileStartHex === $expectedBomHex) {
|
||||
$error = "File contains a $bomName byte order mark (BOM).";
|
||||
$phpcsFile->addError($error, $stackPtr, 123);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}//end process()
|
||||
}
|
|
@ -0,0 +1,222 @@
|
|||
<?php
|
||||
/**
|
||||
* CodeIgniter_Sniffs_Files_Utf8EncodingSniff.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2006 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
/**
|
||||
* CodeIgniter_Sniffs_Files_Utf8EncodingSniff.
|
||||
*
|
||||
* Ensures that PHP files are encoded with Unicode (UTF-8) encoding.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2006 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
namespace CodeIgniter\Sniffs\Files;
|
||||
|
||||
use PHP_CodeSniffer\Sniffs\Sniff;
|
||||
use PHP_CodeSniffer\Files\File;
|
||||
|
||||
class Utf8EncodingSniff implements Sniff
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns an array of tokens this test wants to listen for.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
return array(
|
||||
T_OPEN_TAG
|
||||
);
|
||||
|
||||
}//end register()
|
||||
|
||||
|
||||
/**
|
||||
* Processes this test, when one of its tokens is encountered.
|
||||
*
|
||||
* @param File $phpcsFile The current file being scanned.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function process(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
// We are only interested if this is the first open tag.
|
||||
if ($stackPtr !== 0) {
|
||||
if ($phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)) !== false) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$file_path = $phpcsFile->getFilename();
|
||||
$file_name = basename($file_path);
|
||||
$file_content = file_get_contents($file_path);
|
||||
if (false === mb_check_encoding($file_content, 'UTF-8')) {
|
||||
$error = 'File "' . $file_name . '" should be saved with Unicode (UTF-8) encoding.';
|
||||
$phpcsFile->addError($error, 0);
|
||||
}
|
||||
if ( ! self::_checkUtf8W3c($file_content)) {
|
||||
$error = 'File "' . $file_name . '" should be saved with Unicode (UTF-8) encoding, but it did not successfully pass the W3C test.';
|
||||
$phpcsFile->addError($error, 0);
|
||||
}
|
||||
if ( ! self::_checkUtf8Rfc3629($file_content)) {
|
||||
$error = 'File "' . $file_name . '" should be saved with Unicode (UTF-8) encoding, but it did not meet RFC3629 requirements.';
|
||||
$phpcsFile->addError($error, 0);
|
||||
}
|
||||
}//end process()
|
||||
|
||||
|
||||
/**
|
||||
* Checks that the string $content contains only valid UTF-8 chars
|
||||
* using W3C's method.
|
||||
* Returns true if $content contains only UTF-8 chars, false otherwise.
|
||||
*
|
||||
* @param string $content String to check.
|
||||
*
|
||||
* @return bool true if $content contains only UTF-8 chars, false otherwise.
|
||||
*
|
||||
* @see http://w3.org/International/questions/qa-forms-utf-8.html
|
||||
*/
|
||||
private static function _checkUtf8W3c($content)
|
||||
{
|
||||
$content_chunks=self::mb_chunk_split($content, 4096, '');
|
||||
foreach($content_chunks as $content_chunk)
|
||||
{
|
||||
$preg_result= preg_match(
|
||||
'%^(?:
|
||||
[\x09\x0A\x0D\x20-\x7E] # ASCII
|
||||
| [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
|
||||
| \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
|
||||
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
|
||||
| \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
|
||||
| \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
|
||||
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
|
||||
| \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
|
||||
)*$%xs',
|
||||
$content_chunk
|
||||
);
|
||||
if($preg_result!==1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}//end _checkUtf8W3c()
|
||||
|
||||
/**
|
||||
* Checks that the string $content contains only valid UTF-8 chars
|
||||
* using the method described in RFC 3629.
|
||||
* Returns true if $content contains only UTF-8 chars, false otherwise.
|
||||
*
|
||||
* @param string $content String to check.
|
||||
*
|
||||
* @return bool true if $content contains only UTF-8 chars, false otherwise.
|
||||
*
|
||||
* @see http://www.php.net/manual/en/function.mb-detect-encoding.php#85294
|
||||
*/
|
||||
private static function _checkUtf8Rfc3629($content)
|
||||
{
|
||||
$len = strlen($content);
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
$c = ord($content[$i]);
|
||||
if ($c > 128) {
|
||||
if (($c >= 254)) {
|
||||
return false;
|
||||
} elseif ($c >= 252) {
|
||||
$bits=6;
|
||||
} elseif ($c >= 248) {
|
||||
$bits=5;
|
||||
} elseif ($c >= 240) {
|
||||
$bytes = 4;
|
||||
} elseif ($c >= 224) {
|
||||
$bytes = 3;
|
||||
} elseif ($c >= 192) {
|
||||
$bytes = 2;
|
||||
} else {
|
||||
return false;
|
||||
} if (($i + $bytes) > $len) {
|
||||
return false;
|
||||
} while ($bytes > 1) {
|
||||
$i++;
|
||||
$b = ord($content[$i]);
|
||||
if ($b < 128 || $b > 191) {
|
||||
return false;
|
||||
}
|
||||
$bytes--;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}//_checkUtf8Rfc3629()
|
||||
|
||||
/**
|
||||
* Splits a string to chunks of given size
|
||||
* This helps to avoid segmentation fault errors when large text is given
|
||||
* Returns array of strings after splitting
|
||||
*
|
||||
* @param string $str String to split.
|
||||
* @param int $len number of characters per chunk
|
||||
*
|
||||
* @return array string array after splitting
|
||||
*
|
||||
* @see http://php.net/manual/en/function.chunk-split.php
|
||||
*/
|
||||
private static function mb_chunk_split($str, $len, $glue)
|
||||
{
|
||||
if (empty($str)) return false;
|
||||
$array = self::mbStringToArray ($str);
|
||||
$n = -1;
|
||||
$new = Array();
|
||||
foreach ($array as $char) {
|
||||
$n++;
|
||||
if ($n < $len) $new []= $char;
|
||||
elseif ($n == $len) {
|
||||
$new []= $glue . $char;
|
||||
$n = 0;
|
||||
}
|
||||
}
|
||||
return $new;
|
||||
}//mb_chunk_split
|
||||
/**
|
||||
* Supporting function for mb_chunk_split
|
||||
*
|
||||
* @param string $str
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @see http://php.net/manual/en/function.chunk-split.php
|
||||
*/
|
||||
private static function mbStringToArray ($str)
|
||||
{
|
||||
if (empty($str)) return false;
|
||||
$len = mb_strlen($str);
|
||||
$array = array();
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
$array[] = mb_substr($str, $i, 1);
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}//end class
|
||||
|
||||
?>
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
/**
|
||||
* CodeIgniter_Sniffs_Operators_LogicalOperatorAndSniff.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2006 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
/**
|
||||
* CodeIgniter_Sniffs_Operators_LogicalOperatorAndSniff.
|
||||
*
|
||||
* Ensures that the logical operator 'AND' is in upper case and suggest the use of its symbolic equivalent.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2006 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
namespace CodeIgniter\Sniffs\Operators;
|
||||
|
||||
use PHP_CodeSniffer\Sniffs\Sniff;
|
||||
use PHP_CodeSniffer\Files\File;
|
||||
|
||||
class LogicalOperatorAndSniff implements Sniff
|
||||
{
|
||||
/**
|
||||
* Returns an array of tokens this test wants to listen for: symbolic and literal operators and.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
return array(
|
||||
T_LOGICAL_AND,
|
||||
);
|
||||
|
||||
}//end register()
|
||||
|
||||
|
||||
/**
|
||||
* Processes this test, when one of its tokens is encountered.
|
||||
*
|
||||
* @param File $phpcsFile The current file being scanned.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function process(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
|
||||
$operator_token = $tokens[$stackPtr];
|
||||
$operator_string = $operator_token['content'];
|
||||
$operator_code = $operator_token['code'];
|
||||
|
||||
if ($operator_string !== strtoupper($operator_string)) {
|
||||
$error_message = 'Logical operator should be in upper case;'
|
||||
. ' use "' . strtoupper($operator_string)
|
||||
. '" instead of "' . $operator_string . '"';
|
||||
$phpcsFile->addError($error_message, $stackPtr, 'LowercaseLogicalOperator');
|
||||
}
|
||||
|
||||
$warning_message = 'The symbolic form "&&" is preferred over the literal form "AND"';
|
||||
$phpcsFile->addWarning($warning_message, $stackPtr, 'UseOfLiteralAndOperator');
|
||||
|
||||
}//end process()
|
||||
|
||||
|
||||
}//end class
|
||||
|
||||
?>
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
/**
|
||||
* CodeIgniter_Sniffs_Operators_StrictComparisonOperatorSniff.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2006 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
/**
|
||||
* CodeIgniter_Sniffs_Operators_StrictComparisonOperatorSniff.
|
||||
*
|
||||
* Ensures that only strict comparison operators are used instead of
|
||||
* equal and not equal operators.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2006 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
namespace CodeIgniter\Sniffs\Operators;
|
||||
|
||||
use PHP_CodeSniffer\Sniffs\Sniff;
|
||||
use PHP_CodeSniffer\Files\File;
|
||||
|
||||
class StrictComparisonOperatorSniff implements Sniff
|
||||
{
|
||||
private static $_replacements = array(
|
||||
T_IS_EQUAL => '===',
|
||||
T_IS_NOT_EQUAL => '!==',
|
||||
);
|
||||
|
||||
/**
|
||||
* Returns an array of tokens this test wants to listen for.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
return array(
|
||||
T_IS_EQUAL,
|
||||
T_IS_NOT_EQUAL,
|
||||
);
|
||||
}//end register()
|
||||
|
||||
|
||||
/**
|
||||
* Processes this test, when one of its tokens is encountered.
|
||||
*
|
||||
* @param File $phpcsFile The current file being scanned.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function process(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
|
||||
$operator_token = $tokens[$stackPtr];
|
||||
$operator_string = $operator_token['content'];
|
||||
$operator_code = $operator_token['code'];
|
||||
|
||||
$error_message = '"==" and "!=" are prohibited; use "'
|
||||
. self::$_replacements[$operator_code] . '" instead of "'
|
||||
. $operator_string . '".';
|
||||
$phpcsFile->addError($error_message, $stackPtr, 'NonStrictComparisonUsed');
|
||||
}//end process()
|
||||
|
||||
|
||||
}//end class
|
||||
|
||||
?>
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
/**
|
||||
* CodeIgniter_Sniffs_Operators_UppercaseLogicalOperatorOrSniff.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2006 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
/**
|
||||
* CodeIgniter_Sniffs_Operators_UppercaseLogicalOperatorOrSniff.
|
||||
*
|
||||
* Ensures that the logical operator 'OR' is in upper cases and its symbolic equivalent.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2006 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
namespace CodeIgniter\Sniffs\Operators;
|
||||
|
||||
use PHP_CodeSniffer\Sniffs\Sniff;
|
||||
use PHP_CodeSniffer\Files\File;
|
||||
|
||||
class UppercaseLogicalOperatorOrSniff implements Sniff
|
||||
{
|
||||
/**
|
||||
* Returns an array of tokens this test wants to listen for: literal and symbolic operators or.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
return array(
|
||||
T_BOOLEAN_OR,
|
||||
T_LOGICAL_OR,
|
||||
);
|
||||
|
||||
}//end register()
|
||||
|
||||
|
||||
/**
|
||||
* Processes this test, when one of its tokens is encountered.
|
||||
*
|
||||
* @param File $phpcsFile The current file being scanned.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function process(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
|
||||
$operator_token = $tokens[$stackPtr];
|
||||
$operator_string = $operator_token['content'];
|
||||
$operator_code = $operator_token['code'];
|
||||
|
||||
if ($operator_code == T_BOOLEAN_OR) {
|
||||
$error_message = 'Logical operator "' . $operator_string
|
||||
. '" is prohibited; use "OR" instead';
|
||||
$phpcsFile->addError($error_message, $stackPtr, 'UseOf||InsteadOfOR');
|
||||
}
|
||||
// it is literal, if it is not symbolic
|
||||
else if ($operator_string !== strtoupper($operator_string)) {
|
||||
$error_message = 'Logical operator should be in upper case;'
|
||||
. ' use "' . strtoupper($operator_string)
|
||||
. '" instead of "' . $operator_string . '"';
|
||||
$phpcsFile->addError($error_message, $stackPtr, 'UseOfLowercaseOr');
|
||||
}
|
||||
}//end process()
|
||||
|
||||
|
||||
}//end class
|
||||
|
||||
?>
|
|
@ -0,0 +1,465 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* CodeIgniter_Sniffs_Strings_DoubleQuoteUsageSniff.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2011 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
namespace CodeIgniter\Sniffs\Strings;
|
||||
|
||||
use PHP_CodeSniffer\Sniffs\Sniff;
|
||||
use PHP_CodeSniffer\Files\File;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* CodeIgniter_Sniffs_Strings_DoubleQuoteUsageSniff.
|
||||
*
|
||||
* Ensures that double-quoted strings are used only to parse variables,
|
||||
* to avoid escape characters before single quotes or for chars that need
|
||||
* to be interpreted like \r, \n or \t.
|
||||
* If a double-quoted string contain both single and double quotes
|
||||
* but no variable, then a warning is raised to encourage the use of
|
||||
* single-quoted strings.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2011 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
class VariableUsageSniff implements Sniff
|
||||
{
|
||||
/**
|
||||
* Returns an array of tokens this test wants to listen for.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
/*
|
||||
return array(
|
||||
T_DOUBLE_QUOTED_STRING,
|
||||
T_CONSTANT_ENCAPSED_STRING,
|
||||
);
|
||||
*/
|
||||
return array();
|
||||
}//end register()
|
||||
|
||||
|
||||
/**
|
||||
* Processes this test, when one of its tokens is encountered.
|
||||
*
|
||||
* @param File $phpcsFile The current file being scanned.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function process(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
$string = $tokens[$stackPtr]['content'];
|
||||
// makes sure that it is about a double quote string,
|
||||
// since variables are not parsed out of double quoted string
|
||||
$openDblQtStr = substr($string, 0, 1);
|
||||
if (0 === strcmp($openDblQtStr, '"')) {
|
||||
$this->processDoubleQuotedString($phpcsFile, $stackPtr, $string);
|
||||
} else if (0 === strcmp($openDblQtStr, "'")) {
|
||||
$this->processSingleQuotedString($phpcsFile, $stackPtr, $string);
|
||||
}
|
||||
}//end process()
|
||||
|
||||
|
||||
/**
|
||||
* Processes this test, when the token encountered is a double-quoted string.
|
||||
*
|
||||
* @param File $phpcsFile The current file being scanned.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
* @param string $dblQtString The double-quoted string content,
|
||||
* i.e. without quotes.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processDoubleQuotedString (File $phpcsFile, $stackPtr, $dblQtString)
|
||||
{
|
||||
$variableFound = FALSE;
|
||||
$strTokens = token_get_all('<?php '.$dblQtString);
|
||||
$strPtr = 1; // skip php opening tag added by ourselves
|
||||
$requireDblQuotes = FALSE;
|
||||
while ($strPtr < count($strTokens)) {
|
||||
$strToken = $strTokens[$strPtr];
|
||||
if (is_array($strToken)) {
|
||||
if (in_array($strToken[0], array(T_DOLLAR_OPEN_CURLY_BRACES, T_CURLY_OPEN))) {
|
||||
$strPtr++;
|
||||
try {
|
||||
$this->_parseVariable($strTokens, $strPtr);
|
||||
} catch (Exception $err) {
|
||||
$error = 'There is no variable, object nor array between curly braces. Please use the escape char for $ or {.';
|
||||
$phpcsFile->addError($error, $stackPtr, 234);
|
||||
}
|
||||
$variableFound = TRUE;
|
||||
if ('}' !== $strTokens[$strPtr]) {
|
||||
$error = 'There is no matching closing curly brace.';
|
||||
$phpcsFile->addError($error, $stackPtr, 345);
|
||||
}
|
||||
// don't move forward, since it will be done in the main loop
|
||||
// $strPtr++;
|
||||
} else if (T_VARIABLE === $strToken[0]) {
|
||||
$variableFound = TRUE;
|
||||
$error = "Variable {$strToken[1]} in double-quoted strings should be enclosed with curly braces. Please consider {{$strToken[1]}}";
|
||||
$phpcsFile->addError($error, $stackPtr, 456);
|
||||
}
|
||||
}
|
||||
$strPtr++;
|
||||
}
|
||||
return $variableFound;
|
||||
}//end processDoubleQuotedString()
|
||||
|
||||
|
||||
/**
|
||||
* Processes this test, when the token encountered is a single-quoted string.
|
||||
*
|
||||
* @param File $phpcsFile The current file being scanned.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
* @param string $sglQtString The single-quoted string content,
|
||||
* i.e. without quotes.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processSingleQuotedString (File $phpcsFile, $stackPtr, $sglQtString)
|
||||
{
|
||||
$variableFound = FALSE;
|
||||
$strTokens = token_get_all('<?php '.$sglQtString);
|
||||
$strPtr = 1; // skip php opening tag added by ourselves
|
||||
while ($strPtr < count($strTokens)) {
|
||||
$strToken = $strTokens[$strPtr];
|
||||
if (is_array($strToken)) {
|
||||
if (T_VARIABLE === $strToken[0]) {
|
||||
$error = "Variables like {$strToken[1]} should be in double-quoted strings only.";
|
||||
$phpcsFile->addError($error, $stackPtr);
|
||||
}
|
||||
}
|
||||
$strPtr++;
|
||||
}
|
||||
return $variableFound;
|
||||
}//end processSingleQuotedString()
|
||||
|
||||
/**
|
||||
* Grammar rule to parse the use of a variable. Please notice that it
|
||||
* doesn't manage the leading $.
|
||||
*
|
||||
* _parseVariable ::= <variable>
|
||||
* | <variable>_parseObjectAttribute()
|
||||
* | <variable>_parseArrayIndexes()
|
||||
*
|
||||
* @exception Exception raised if $strTokens starting from $strPtr
|
||||
* doesn't matched the rule.
|
||||
*
|
||||
* @param array $strTokens Tokens to parse.
|
||||
* @param int $strPtr Pointer to the token where parsing starts.
|
||||
*
|
||||
* @return array The attribute name associated to index 'var', an array with
|
||||
* indexes 'obj' and 'attr' or an array with indexes 'arr' and 'idx'.
|
||||
*/
|
||||
private function _parseVariable ($strTokens, &$strPtr)
|
||||
{
|
||||
if ( ! in_array($strTokens[$strPtr][0], array(T_VARIABLE, T_STRING_VARNAME))) {
|
||||
throw new Exception ('Expected variable name.');
|
||||
}
|
||||
$var = $strTokens[$strPtr][1];
|
||||
$strPtr++;
|
||||
$startStrPtr = $strPtr;
|
||||
try {
|
||||
$attr = $this->_parseObjectAttribute($strTokens, $strPtr);
|
||||
return array ('obj' => $var, 'attr' => $attr);
|
||||
} catch (Exception $err) {
|
||||
if ($strPtr !== $startStrPtr) {
|
||||
throw $err;
|
||||
}
|
||||
}
|
||||
try {
|
||||
$idx = $this->_parseArrayIndexes($strTokens, $strPtr);
|
||||
return array ('arr' => $var, 'idx' => $idx);
|
||||
} catch (Exception $err) {
|
||||
if ($strPtr !== $startStrPtr) {
|
||||
throw $err;
|
||||
}
|
||||
}
|
||||
return array ('var' => $var);
|
||||
}//end _parseVariable()
|
||||
|
||||
|
||||
/**
|
||||
* Grammar rule to parse the use of an object attribute.
|
||||
*
|
||||
* _parseObjectAttribute ::= -><attribute>
|
||||
* | -><attribute>_parseObjectAttribute()
|
||||
* | -><attribute>_parseArrayIndexes()
|
||||
*
|
||||
* @exception Exception raised if $strTokens starting from $strPtr
|
||||
* doesn't matched the rule.
|
||||
*
|
||||
* @param array $strTokens Tokens to parse.
|
||||
* @param int $strPtr Pointer to the token where parsing starts.
|
||||
*
|
||||
* @return mixed The attribute name as a string, an array with indexes
|
||||
* 'obj' and 'attr' or an array with indexes 'arr' and 'idx'.
|
||||
*/
|
||||
private function _parseObjectAttribute ($strTokens, &$strPtr)
|
||||
{
|
||||
if (T_OBJECT_OPERATOR !== $strTokens[$strPtr][0]) {
|
||||
throw new Exception ('Expected ->.');
|
||||
}
|
||||
$strPtr++;
|
||||
if (T_STRING !== $strTokens[$strPtr][0]) {
|
||||
throw new Exception ('Expected an object attribute.');
|
||||
}
|
||||
$attr = $strTokens[$strPtr][1];
|
||||
$strPtr++;
|
||||
$startStrPtr = $strPtr;
|
||||
try {
|
||||
$sub_attr = $this->_parseObjectAttribute($strTokens, $strPtr);
|
||||
return array ('obj' => $attr, 'attr' => $sub_attr);
|
||||
} catch (Exception $err) {
|
||||
if ($strPtr !== $startStrPtr) {
|
||||
throw $err;
|
||||
}
|
||||
}
|
||||
try {
|
||||
$idx = $this->_parseArrayIndexes($strTokens, $strPtr);
|
||||
return array ('arr' => $attr, 'idx' => $idx);
|
||||
} catch (Exception $err) {
|
||||
if ($strPtr !== $startStrPtr) {
|
||||
throw $err;
|
||||
}
|
||||
}
|
||||
return $attr;
|
||||
}//end _parseObjectAttribute()
|
||||
|
||||
|
||||
/**
|
||||
* Grammar rule to parse the use of one or more array indexes.
|
||||
*
|
||||
* _parseArrayIndexes ::= _parseArrayIndex()+
|
||||
*
|
||||
* @exception Exception raised if $strTokens starting from $strPtr
|
||||
* doesn't matched the rule.
|
||||
*
|
||||
* @param array $strTokens Tokens to parse.
|
||||
* @param int $strPtr Pointer to the token where parsing starts.
|
||||
*
|
||||
* @return array Indexes in the same order as in the string.
|
||||
*/
|
||||
private function _parseArrayIndexes ($strTokens, &$strPtr)
|
||||
{
|
||||
$indexes = array($this->_parseArrayIndex($strTokens, $strPtr));
|
||||
try {
|
||||
while (1) {
|
||||
$startStrPtr = $strPtr;
|
||||
$indexes [] = $this->_parseArrayIndex($strTokens, $strPtr);
|
||||
}
|
||||
} catch (Exception $err) {
|
||||
if (0 !== ($strPtr - $startStrPtr)) {
|
||||
throw $err;
|
||||
}
|
||||
return $indexes;
|
||||
}
|
||||
}//end _parseArrayIndexes()
|
||||
|
||||
|
||||
/**
|
||||
* Grammar rule to parse the use of array index.
|
||||
*
|
||||
* _parseArrayIndex ::= [<index>]
|
||||
*
|
||||
* @exception Exception raised if $strTokens starting from $strPtr
|
||||
* doesn't matched the rule.
|
||||
*
|
||||
* @param array $strTokens Tokens to parse.
|
||||
* @param int $strPtr Pointer to the token where parsing starts.
|
||||
*
|
||||
* @return string Index between the 2 square brackets
|
||||
*/
|
||||
private function _parseArrayIndex ($strTokens, &$strPtr)
|
||||
{
|
||||
if ('[' !== $strTokens[$strPtr]) {
|
||||
throw new Exception ('Expected [.');
|
||||
}
|
||||
$strPtr++;
|
||||
if (! in_array($strTokens[$strPtr][0], array(T_CONSTANT_ENCAPSED_STRING, T_LNUMBER))) {
|
||||
throw new Exception ('Expected an array index.');
|
||||
}
|
||||
$index = $strTokens[$strPtr][1];
|
||||
$strPtr++;
|
||||
if (']' !== $strTokens[$strPtr]) {
|
||||
throw new Exception ('Expected ].');
|
||||
}
|
||||
$strPtr++;
|
||||
return $index;
|
||||
}//end _parseArrayIndex()
|
||||
|
||||
}//end class
|
||||
|
||||
/**
|
||||
* CodeIgniter_Sniffs_Strings_VariableUsageSniff.
|
||||
*
|
||||
* Ensures that variables parsed in double-quoted strings are enclosed with
|
||||
* braces to prevent greedy token parsing.
|
||||
* Single-quoted strings don't parse variables, so there is no risk of greedy
|
||||
* token parsing.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2011 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
class DoubleQuoteUsageSniff extends VariableUsageSniff
|
||||
{
|
||||
/**
|
||||
* Returns an array of tokens this test wants to listen for.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
return array(
|
||||
T_DOUBLE_QUOTED_STRING,
|
||||
T_CONSTANT_ENCAPSED_STRING,
|
||||
);
|
||||
}//end register()
|
||||
|
||||
/**
|
||||
* Processes this test, when one of its tokens is encountered.
|
||||
*
|
||||
* @param File $phpcsFile The current file being scanned.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function process(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
// no variable are in the string from here
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
$qtString = $tokens[$stackPtr]['content'];
|
||||
// makes sure that it is about a double quote string,
|
||||
// since variables are not parsed out of double quoted string
|
||||
$open_qt_str = substr($qtString, 0, 1);
|
||||
|
||||
// clean the enclosing quotes
|
||||
$qtString = substr($qtString, 1, strlen($qtString) - 1 - 1);
|
||||
|
||||
if (0 === strcmp($open_qt_str, '"')) {
|
||||
$this->processDoubleQuotedString($phpcsFile, $stackPtr, $qtString);
|
||||
} else if (0 === strcmp($open_qt_str, "'")) {
|
||||
$this->processSingleQuotedString($phpcsFile, $stackPtr, $qtString);
|
||||
}
|
||||
}//end process()
|
||||
|
||||
|
||||
/**
|
||||
* Processes this test, when the token encountered is a double-quoted string.
|
||||
*
|
||||
* @param File $phpcsFile The current file being scanned.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
* @param string $qtString The double-quoted string content,
|
||||
* i.e. without quotes.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processDoubleQuotedString (File $phpcsFile, $stackPtr, $qtString)
|
||||
{
|
||||
// so there should be at least a single quote or a special char
|
||||
// if there are the 2 kinds of quote and no special char, then add a warning
|
||||
$has_variable = parent::processDoubleQuotedString($phpcsFile, $stackPtr, '"'.$qtString.'"');
|
||||
$has_specific_sequence = $this->_hasSpecificSequence($qtString);
|
||||
$dbl_qt_at = strpos($qtString, '"');
|
||||
$smpl_qt_at = strpos($qtString, "'");
|
||||
if (false === $has_variable && false === $has_specific_sequence
|
||||
&& false === $smpl_qt_at
|
||||
) {
|
||||
$error = 'Single-quoted strings should be used unless it contains variables, special chars like \n or single quotes.';
|
||||
$phpcsFile->addError($error, $stackPtr, 111);
|
||||
} else if (false !== $smpl_qt_at && false !== $dbl_qt_at
|
||||
&& false === $has_variable && false === $has_specific_sequence
|
||||
) {
|
||||
$warning = 'It is encouraged to use a single-quoted string, since it doesn\'t contain any variable nor special char though it mixes single and double quotes.';
|
||||
$phpcsFile->addWarning($warning, $stackPtr, 222);
|
||||
}
|
||||
}//end processDoubleQuotedString()
|
||||
|
||||
|
||||
/**
|
||||
* Processes this test, when the token encountered is a single-quoted string.
|
||||
*
|
||||
* @param File $phpcsFile The current file being scanned.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
* @param string $qtString The single-quoted string content,
|
||||
* i.e. without quotes.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processSingleQuotedString (File $phpcsFile, $stackPtr, $qtString)
|
||||
{
|
||||
// if there is single quotes without additional double quotes,
|
||||
// then user is allowed to use double quote to avoid having to
|
||||
// escape single quotes. Don't add the warning, if an error was
|
||||
// already added, because a variable was found in a single-quoted
|
||||
// string.
|
||||
$has_variable = parent::processSingleQuotedString($phpcsFile, $stackPtr, "'".$qtString."'");
|
||||
$dbl_qt_at = strpos($qtString, '"');
|
||||
$smpl_qt_at = strpos($qtString, "'");
|
||||
if (false === $has_variable && false !== $smpl_qt_at && false === $dbl_qt_at) {
|
||||
$warning = 'You may also use double-quoted strings if the string contains single quotes, so you do not have to use escape characters.';
|
||||
$phpcsFile->addWarning($warning, $stackPtr, 333);
|
||||
}
|
||||
}//end processSingleQuotedString()
|
||||
|
||||
/**
|
||||
* Return TRUE, if a sequence of chars that is parsed in a specific way
|
||||
* in double-quoted strings is found, FALSE otherwise.
|
||||
*
|
||||
* @param string $string String in which sequence of special chars will
|
||||
* be researched.
|
||||
*
|
||||
* @return TRUE, if a sequence of chars that is parsed in a specific way
|
||||
* in double-quoted strings is found, FALSE otherwise.
|
||||
*
|
||||
* @link http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double
|
||||
*/
|
||||
private function _hasSpecificSequence($string)
|
||||
{
|
||||
$hasSpecificSequence = FALSE;
|
||||
$specialMeaningStrs = array('\n', '\r', '\t', '\v', '\f');
|
||||
foreach ($specialMeaningStrs as $splStr) {
|
||||
if (FALSE !== strpos($string, $splStr)) {
|
||||
$hasSpecificSequence = TRUE;
|
||||
}
|
||||
}
|
||||
$specialMeaningPtrns = array('\[0-7]{1,3}', '\x[0-9A-Fa-f]{1,2}');
|
||||
foreach ($specialMeaningPtrns as $splPtrn) {
|
||||
if (1 === preg_match("/{$splPtrn}/", $string)) {
|
||||
$hasSpecificSequence = TRUE;
|
||||
}
|
||||
}
|
||||
return $hasSpecificSequence;
|
||||
}//end _hasSpecificSequence()
|
||||
|
||||
}//end class
|
||||
|
||||
?>
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
/**
|
||||
* CodeIgniter_Sniffs_WhiteSpace_DisallowSpaceIndentSniff.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@gmail.com>
|
||||
* @copyright 2011 Thomas ERNEST
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
/**
|
||||
* CodeIgniter_Sniffs_WhiteSpace_DisallowSpaceIndentSniff.
|
||||
*
|
||||
* Ensures the use of tabs for indentation.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@gmail.com>
|
||||
* @copyright 2011 Thomas ERNEST
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
namespace CodeIgniter\Sniffs\WhiteSpace;
|
||||
|
||||
use PHP_CodeSniffer\Sniffs\Sniff;
|
||||
use PHP_CodeSniffer\Files\File;
|
||||
|
||||
class DisallowSpaceIndentSniff implements Sniff
|
||||
{
|
||||
|
||||
/**
|
||||
* A list of tokenizers this sniff supports.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $supportedTokenizers = array(
|
||||
'PHP',
|
||||
'JS',
|
||||
'CSS',
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array of tokens this test wants to listen for.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
return array(T_WHITESPACE);
|
||||
}//end register()
|
||||
|
||||
|
||||
/**
|
||||
* Processes this test, when one of its tokens is encountered.
|
||||
*
|
||||
* @param File $phpcsFile All the tokens found in the document.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function process(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
|
||||
// Make sure this is whitespace used for indentation.
|
||||
$line = $tokens[$stackPtr]['line'];
|
||||
if ($stackPtr > 0 && $tokens[($stackPtr - 1)]['line'] === $line) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (strpos($tokens[$stackPtr]['content'], " ") !== false) {
|
||||
$error = 'Tabs must be used to indent lines; spaces are not allowed for code indentation';
|
||||
$phpcsFile->addError($error, $stackPtr, 'SpacesUsedForIndentation');
|
||||
}
|
||||
}//end process()
|
||||
|
||||
|
||||
}//end class
|
||||
|
||||
?>
|
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
/**
|
||||
* CodeIgniter_Sniffs_WhiteSpace_DisallowWitheSpaceAroundPhpTagsSniff.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2006 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
/**
|
||||
* CodeIgniter_Sniffs_WhiteSpace_DisallowWitheSpaceAroundPhpTagsSniff.
|
||||
*
|
||||
* Ensures that no whitespace precedes the opening PHP tag
|
||||
* or follows the closing PHP tag.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2006 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
namespace CodeIgniter\Sniffs\WhiteSpace;
|
||||
|
||||
use PHP_CodeSniffer\Sniffs\Sniff;
|
||||
use PHP_CodeSniffer\Files\File;
|
||||
|
||||
class DisallowWitheSpaceAroundPhpTagsSniff implements Sniff
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns an array of tokens this test wants to listen for.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
return array(
|
||||
T_OPEN_TAG,
|
||||
T_CLOSE_TAG
|
||||
);
|
||||
|
||||
}//end register()
|
||||
|
||||
|
||||
/**
|
||||
* Processes this test, when one of its tokens is encountered.
|
||||
*
|
||||
* @param File $phpcsFile The current file being scanned.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function process(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
|
||||
$php_tag_token = $tokens[$stackPtr];
|
||||
$php_tag_code = $php_tag_token['code'];
|
||||
|
||||
if (T_OPEN_TAG === $php_tag_code) {
|
||||
// opening php tag should be the first token.
|
||||
// any whitespace beofre an opening php tag is tokenized
|
||||
// as T_INLINE_HTML, so no need to check the content of the token.
|
||||
$isFirst = 0 === $stackPtr;
|
||||
if ( ! $isFirst) {
|
||||
$error = 'Any char before the opening PHP tag is prohibited. Please remove newline or indentation before the opening PHP tag.';
|
||||
$phpcsFile->addError($error, $stackPtr);
|
||||
}
|
||||
} else {
|
||||
// if (T_CLOSE_TAG === $php_tag_code)
|
||||
// closing php tag should be the last token
|
||||
// and it must not contain any whitespace.
|
||||
$php_tag_string = $php_tag_token['content'];
|
||||
$isLast = count($tokens) - 1 === $stackPtr;
|
||||
// both of the two closing php tags contains 2 chars exactly.
|
||||
$containsEndTagOnly = strlen($php_tag_string) > 2;
|
||||
if ( ! $isLast || ! $containsEndTagOnly ) {
|
||||
$error = 'Any char after the closing PHP tag is prohibited. Please removes newline or spaces after the closing PHP tag.';
|
||||
$phpcsFile->addError($error, $stackPtr);
|
||||
}
|
||||
}
|
||||
}//end process()
|
||||
|
||||
|
||||
}//end class
|
||||
|
||||
?>
|
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
/**
|
||||
* CodeIgniter_Sniffs_WhiteSpace_ElseOnNewLineSniff.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2006 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
/**
|
||||
* CodeIgniter_Sniffs_WhiteSpace_ElseOnNewLineSniff.
|
||||
*
|
||||
* Ensures that control structures else and elseif stand on new lines.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2006 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
namespace CodeIgniter\Sniffs\WhiteSpace;
|
||||
|
||||
use PHP_CodeSniffer\Sniffs\Sniff;
|
||||
use PHP_CodeSniffer\Files\File;
|
||||
|
||||
class ElseOnNewLineSniff implements Sniff
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns an array of tokens this test wants to listen for.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
return array(
|
||||
T_ELSE,
|
||||
T_ELSEIF,
|
||||
);
|
||||
}//end register()
|
||||
|
||||
|
||||
/**
|
||||
* Processes this test, when one of its tokens is encountered.
|
||||
*
|
||||
* @param File $phpcsFile The current file being scanned.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function process(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
|
||||
$else_token = $tokens[$stackPtr];
|
||||
$previous_non_blank_token_ptr = $phpcsFile->findPrevious(array(T_WHITESPACE), $stackPtr - 1, null, true);
|
||||
|
||||
if (false === $previous_non_blank_token_ptr) {
|
||||
// else is no preceded with any symbol, but it is not the responsibility of this sniff.
|
||||
return;
|
||||
}
|
||||
|
||||
$previous_non_blank_token = $tokens[$previous_non_blank_token_ptr];
|
||||
if ($previous_non_blank_token['line'] === $else_token['line']) {
|
||||
$error = '"' . $else_token['content'] . '" should be on a new line.';
|
||||
$phpcsFile->addError($error, $stackPtr, 123423);
|
||||
}
|
||||
|
||||
}//end process()
|
||||
|
||||
|
||||
}//end class
|
||||
|
||||
?>
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
/**
|
||||
* CodeIgniter_Sniffs_WhiteSpace_LogicalNotSpacingSniff.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2006 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
/**
|
||||
* CodeIgniter_Sniffs_WhiteSpace_LogicalNotSpacingSniff.
|
||||
*
|
||||
* Ensures that at exactly a space precedes and follows the logical operator !.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2006 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
namespace CodeIgniter\Sniffs\WhiteSpace;
|
||||
|
||||
use PHP_CodeSniffer\Sniffs\Sniff;
|
||||
use PHP_CodeSniffer\Files\File;
|
||||
|
||||
class LogicalNotSpacingSniff implements Sniff
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns an array of tokens this test wants to listen for.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
return array(
|
||||
T_BOOLEAN_NOT,
|
||||
);
|
||||
}//end register()
|
||||
|
||||
|
||||
/**
|
||||
* Processes this test, when one of its tokens is encountered.
|
||||
*
|
||||
* @param File $phpcsFile The current file being scanned.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function process(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
|
||||
$operator_token = $tokens[$stackPtr];
|
||||
|
||||
$previous_token = $tokens[$stackPtr - 1];
|
||||
$next_token = $tokens[$stackPtr + 1];
|
||||
if (T_WHITESPACE !== $previous_token['code'] || T_WHITESPACE !== $next_token['code']) {
|
||||
$error = 'Logical operator ! should always be preceded and followed with a whitespace.';
|
||||
$phpcsFile->addError($error, $stackPtr, 'badNot');
|
||||
}
|
||||
}//end process()
|
||||
|
||||
|
||||
}//end class
|
||||
|
||||
?>
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
/**
|
||||
* CodeIgniter_Sniffs_Files_AbstractClosingCommentSniff.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2006 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
/**
|
||||
* CodeIgniter_Sniffs_Files_AbstractClosingCommentSniff.
|
||||
*
|
||||
* Defines some methods used by
|
||||
* CodeIgniter_Sniffs_Files_ClosingFileCommentSniff
|
||||
* and CodeIgniter_Sniffs_Files_ClosingLocationCommentSniff.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2006 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
namespace CodeIgniter\Sniffs\Files;
|
||||
|
||||
use PHP_CodeSniffer\Sniffs\Sniff;
|
||||
use PHP_CodeSniffer\Files\File;
|
||||
|
||||
class AbstractClosingCommentSniff implements Sniff
|
||||
{
|
||||
/**
|
||||
* As an abstract class, this sniff is not associated to any token.
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* As an abstract class, this sniff is not dedicated to process a token.
|
||||
*/
|
||||
public function process(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
$error = __CLASS__.'::'.__METHOD__.' is abstract. Please develop this method in a child class.';
|
||||
throw new PHP_CodeSniffer_Exception($error);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the comment without its delimiter(s) as well as leading
|
||||
* and traling whitespaces.
|
||||
*
|
||||
* It removes the first #, the two first / (i.e. //) or the first /*
|
||||
* and last \*\/. If a comment starts with /**, then the last * will remain
|
||||
* as well as whitespaces between this star and the comment content.
|
||||
*
|
||||
* @param string $comment Comment containing either comment delimiter(s) and
|
||||
* trailing or leading whitspaces to clean.
|
||||
*
|
||||
* @return string Comment without comment delimiter(s) and whitespaces.
|
||||
*/
|
||||
protected static function _getCommentContent ($comment)
|
||||
{
|
||||
if (self::_stringStartsWith($comment, '#')) {
|
||||
$comment = substr($comment, 1);
|
||||
} else if (self::_stringStartsWith($comment, '//')) {
|
||||
$comment = substr($comment, 2);
|
||||
} else if (self::_stringStartsWith($comment, '/*')) {
|
||||
$comment = substr($comment, 2, strlen($comment) - 2 - 2);
|
||||
}
|
||||
$comment = trim($comment);
|
||||
return $comment;
|
||||
}//_getCommentContent()
|
||||
|
||||
|
||||
/**
|
||||
* Binary safe string comparison between $needle and
|
||||
* the beginning of $haystack. Returns true if $haystack starts with
|
||||
* $needle, false otherwise.
|
||||
*
|
||||
* @param string $haystack The string to search in.
|
||||
* @param string $needle The string to search for.
|
||||
*
|
||||
* @return bool true if $haystack starts with $needle, false otherwise.
|
||||
*/
|
||||
protected static function _stringStartsWith ($haystack, $needle)
|
||||
{
|
||||
$startsWith = false;
|
||||
if (strlen($needle) <= strlen($haystack)) {
|
||||
$haystackBeginning = substr($haystack, 0, strlen($needle));
|
||||
if (0 === strcmp($haystackBeginning, $needle)) {
|
||||
$startsWith = true;
|
||||
}
|
||||
}
|
||||
return $startsWith;
|
||||
}//_stringStartsWith()
|
||||
}//end class
|
||||
|
||||
?>
|
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
/**
|
||||
* CodeIgniter_Sniffs_Files_ClosingFileCommentSniff.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2006 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
/**
|
||||
* CodeIgniter_Sniffs_Files_ClosingFileCommentSniff.
|
||||
*
|
||||
* Ensures that a comment containing the file name is available at the end of file.
|
||||
* Only other comments and whitespaces are allowed to follow this specific comment.
|
||||
*
|
||||
* It may be all kind of comment like multi-line and inline C-style comments as
|
||||
* well as PERL-style comments. Any number of white may separate comment delimiters
|
||||
* from comment content. However, content has to be equal to template
|
||||
* "End of file <file_name>". Comparison between content and template is
|
||||
* case-sensitive.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2006 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
namespace CodeIgniter\Sniffs\Files;
|
||||
|
||||
use PHP_CodeSniffer\Files\File;
|
||||
|
||||
class ClosingFileCommentSniff extends AbstractClosingCommentSniff
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns an array of tokens this test wants to listen for.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
return array(
|
||||
T_OPEN_TAG,
|
||||
);
|
||||
|
||||
}//end register()
|
||||
|
||||
|
||||
/**
|
||||
* Processes this test, when one of its tokens is encountered.
|
||||
*
|
||||
* @param File $phpcsFile The current file being scanned.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function process(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
// We are only interested if this is the first open tag.
|
||||
if ($stackPtr !== 0) {
|
||||
if ($phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)) !== false) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$fullFilename = $phpcsFile->getFilename();
|
||||
$filename = basename($fullFilename);
|
||||
$commentTemplate = "End of file $filename";
|
||||
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
$currentToken = count($tokens) - 1;
|
||||
$hasClosingFileComment = false;
|
||||
$isNotAWhitespaceOrAComment = false;
|
||||
while ($currentToken >= 0
|
||||
&& ! $isNotAWhitespaceOrAComment
|
||||
&& ! $hasClosingFileComment
|
||||
) {
|
||||
$token = $tokens[$currentToken];
|
||||
$tokenCode = $token['code'];
|
||||
if (T_COMMENT === $tokenCode) {
|
||||
$commentString = self::_getCommentContent($token['content']);
|
||||
if (0 === strcmp($commentString, $commentTemplate)) {
|
||||
$hasClosingFileComment = true;
|
||||
}
|
||||
} else if (T_WHITESPACE === $tokenCode) {
|
||||
// Whitespaces are allowed between the closing file comment,
|
||||
// other comments and end of file
|
||||
} else {
|
||||
$isNotAWhitespaceOrAComment = true;
|
||||
}
|
||||
$currentToken--;
|
||||
}
|
||||
|
||||
if ( ! $hasClosingFileComment) {
|
||||
$error = 'No comment block marks the end of file instead of the closing PHP tag. Please add a comment block containing only "' . $commentTemplate . '".';
|
||||
$phpcsFile->addError($error, $currentToken);
|
||||
}
|
||||
}//end process()
|
||||
}//end class
|
||||
|
||||
?>
|
|
@ -0,0 +1,182 @@
|
|||
<?php
|
||||
/**
|
||||
* CodeIgniter_Sniffs_Files_ClosingLocationCommentSniff.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2006 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
/**
|
||||
* CodeIgniter_Sniffs_Files_ClosingLocationCommentSniff.
|
||||
*
|
||||
* Ensures that a comment containing the file location exists at the end of file.
|
||||
* Only other comments and whitespaces are allowed between this comment and
|
||||
* the end of file.
|
||||
*
|
||||
* It may be all kind of comment like multi-line and inline C-style comments as
|
||||
* well as PERL-style comments. Any number of white may separate comment delimiters
|
||||
* from comment content. However, content has to be equal to template
|
||||
* "Location: <file_path_relative_to_application_root>".
|
||||
* Comparison between content and template is case-sensitive.
|
||||
*
|
||||
* There are several ways to configure the application root. In order of priority :
|
||||
* - Configuration variable ci_application_root.
|
||||
* - Rule property applicationRoot.
|
||||
* - Default value '/application/'
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2006 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
namespace CodeIgniter\Sniffs\Files;
|
||||
|
||||
use PHP_CodeSniffer\Files\File;
|
||||
use PHP_CodeSniffer\Util\Common;
|
||||
|
||||
class ClosingLocationCommentSniff extends AbstractClosingCommentSniff
|
||||
{
|
||||
public $applicationRoot = '/application/';
|
||||
|
||||
/**
|
||||
* Returns an array of tokens this test wants to listen for.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
return array(
|
||||
T_OPEN_TAG
|
||||
);
|
||||
|
||||
}//end register()
|
||||
|
||||
|
||||
/**
|
||||
* Processes this test, when one of its tokens is encountered.
|
||||
*
|
||||
* @param File $phpcsFile The current file being scanned.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function process(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
// We are only interested if this is the first open tag.
|
||||
if ($stackPtr !== 0) {
|
||||
if ($phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)) !== false) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$filePath = $phpcsFile->getFilename();
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
// removes the application root from the beginning of the file path
|
||||
$locationPath = self::_getLocationPath($filePath, $this->_getAppRoot());
|
||||
// add an error, if application root doesn't exist in current file path
|
||||
if (false === $locationPath) {
|
||||
$error = 'Unable to find "' . $this->_getAppRoot() . '" in file path "' . $filePath . '". Please set your project\'s application root.';
|
||||
$phpcsFile->addError($error, count($tokens) - 1);
|
||||
return;
|
||||
}
|
||||
// generates the expected comment
|
||||
$commentTemplate = "Location: $locationPath";
|
||||
|
||||
$currentToken = count($tokens) - 1;
|
||||
$hasClosingLocationComment = false;
|
||||
$isNotAWhitespaceOrAComment = false;
|
||||
while ($currentToken >= 0
|
||||
&& ! $isNotAWhitespaceOrAComment
|
||||
&& ! $hasClosingLocationComment
|
||||
) {
|
||||
$token = $tokens[$currentToken];
|
||||
$tokenCode = $token['code'];
|
||||
if (T_COMMENT === $tokenCode) {
|
||||
$commentString = self::_getCommentContent($token['content']);
|
||||
if (0 === strcmp($commentString, $commentTemplate)) {
|
||||
$hasClosingLocationComment = true;
|
||||
}
|
||||
} else if (T_WHITESPACE === $tokenCode) {
|
||||
// Whitespaces are allowed between the closing file comment,
|
||||
//other comments and end of file
|
||||
} else {
|
||||
$isNotAWhitespaceOrAComment = true;
|
||||
}
|
||||
$currentToken--;
|
||||
}
|
||||
|
||||
if ( ! $hasClosingLocationComment) {
|
||||
$error = 'No comment block marks the end of file instead of the closing PHP tag. Please add a comment block containing only "' . $commentTemplate . '".';
|
||||
$phpcsFile->addError($error, $currentToken);
|
||||
}
|
||||
}//end process()
|
||||
|
||||
|
||||
/**
|
||||
* Returns the relative path from $appRoot to $filePath, or false if
|
||||
* $appRoot cannot be found in $filePath, because $appRoot is not a parent
|
||||
* of $filePath.
|
||||
*
|
||||
* @param string $filePath Full path to the file being proceed.
|
||||
* @param string $appRoot Partial or full path to the CodeIgniter
|
||||
* application root of the file being proceed. It must not contain the
|
||||
* full path to the application root, but at least the name of the
|
||||
* application root. Parent directory of the application root are allowed
|
||||
* but not mandatory.
|
||||
*
|
||||
* @return string|bool The relative path from $appRoot to $filePath, or
|
||||
* false if $appRoot cannot be found in $filePath.
|
||||
*/
|
||||
private static function _getLocationPath ($filePath, $appRoot)
|
||||
{
|
||||
// removes the path to application root
|
||||
// from the beginning of the file path
|
||||
$appRootAt = strpos($filePath, $appRoot);
|
||||
if (false === $appRootAt) {
|
||||
return false;
|
||||
}
|
||||
$localPath = substr($filePath, $appRootAt + strlen($appRoot));
|
||||
// ensures the location path to be a relative path starting with "./".
|
||||
if ( ! self::_stringStartsWith($localPath, './')) {
|
||||
$localPath = './' . $localPath;
|
||||
} else if ( ! self::_stringStartsWith($localPath, '.')
|
||||
&& self::_stringStartsWith($localPath, '/')
|
||||
) {
|
||||
$localPath = '.' . $localPath;
|
||||
}
|
||||
return $localPath;
|
||||
}//end _getLocationPath()
|
||||
|
||||
|
||||
/**
|
||||
* Returns the application root that should be used first.
|
||||
*
|
||||
* There are several ways to configure the application root.
|
||||
* In order of priority :
|
||||
* - Configuration variable ci_application_root.
|
||||
* - Rule property applicationRoot.
|
||||
* - Default value '/application/'
|
||||
*
|
||||
* @return string Path to your project application root.
|
||||
*/
|
||||
private function _getAppRoot()
|
||||
{
|
||||
$appRoot = Common::getConfigData('ci_application_root');
|
||||
if (null === $appRoot) {
|
||||
$appRoot = $this->applicationRoot;
|
||||
}
|
||||
return $appRoot;
|
||||
}//end _getAppRoot()
|
||||
}//end class
|
||||
|
||||
?>
|
|
@ -0,0 +1,142 @@
|
|||
<?php
|
||||
/**
|
||||
* CodeIgniter_Sniffs_NamingConventions_ConstructorNameSniff.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@gmail.com>
|
||||
* @copyright 2011 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
namespace CodeIgniter\Sniffs\NamingConventions;
|
||||
|
||||
use PHP_CodeSniffer\Sniffs\AbstractScopeSniff;
|
||||
use PHP_CodeSniffer\Files\File;
|
||||
|
||||
/**
|
||||
* CodeIgniter_Sniffs_NamingConventions_ConstructorNameSniff.
|
||||
*
|
||||
* Favor PHP 4 constructor syntax, which uses "function ClassName()".
|
||||
* Avoid PHP 5 constructor syntax, which uses "function __construct()".
|
||||
*
|
||||
* @todo Try to avoid overly long and verbose names.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@gmail.com>
|
||||
* @copyright 2010 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
class ConstructorNameSniff extends AbstractScopeSniff
|
||||
{
|
||||
|
||||
|
||||
public $php5Constructors = '1';
|
||||
|
||||
|
||||
/**
|
||||
* Constructs the test with the tokens it wishes to listen for.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(array(T_CLASS, T_INTERFACE), array(T_FUNCTION), true);
|
||||
|
||||
}//end __construct()
|
||||
|
||||
|
||||
/**
|
||||
* Processes this test when one of its tokens is encountered.
|
||||
*
|
||||
* @param File $phpcsFile The current file being scanned.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
* @param int $currScope A pointer to the start of the scope.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processTokenWithinScope(
|
||||
File $phpcsFile,
|
||||
$stackPtr,
|
||||
$currScope
|
||||
) {
|
||||
$methodName = $phpcsFile->getDeclarationName($stackPtr);
|
||||
$className = $phpcsFile->getDeclarationName($currScope);
|
||||
|
||||
$isPhp4Constructor = strcasecmp($methodName, $className) === 0;
|
||||
$isPhp5Constructor = strcasecmp($methodName, '__construct') === 0;
|
||||
if ($this->php5Constructors != '0') {
|
||||
if ($isPhp4Constructor) {
|
||||
$error = "PHP4 style constructors are not allowed; use \"__construct\" instead";
|
||||
$phpcsFile->addError($error, $stackPtr);
|
||||
}
|
||||
} else {
|
||||
if ($isPhp5Constructor) {
|
||||
$error = "PHP5 style constructors are not allowed; use \"$className\" instead";
|
||||
$phpcsFile->addError($error, $stackPtr);
|
||||
}
|
||||
}
|
||||
if ( ! $isPhp4Constructor && ! $isPhp5Constructor ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
|
||||
$parentClassName = $phpcsFile->findExtendedClassName($currScope);
|
||||
$wrongConstructor = '';
|
||||
// prepares the error message and wrong constructor
|
||||
if ($this->php5Constructors != '0') {
|
||||
$error = 'PHP4 style calls to parent constructors are not allowed.';
|
||||
$error = "$error Please use \"parent::__construct\" instead.";
|
||||
if (false !== $parentClassName) {
|
||||
$wrongConstructor = $parentClassName;
|
||||
}
|
||||
// Else $wrongConstructor will be empty
|
||||
// and the test expression will always be false.
|
||||
// It doesn't check that no parent method should be called
|
||||
// when no parent class is defined.
|
||||
} else {
|
||||
$error = 'PHP5 style calls to parent constructors are not allowed.';
|
||||
if (false !== $parentClassName) {
|
||||
$error = "$error Please use \"parent::$parentClassName\" instead.";
|
||||
}
|
||||
$wrongConstructor = '__construct';
|
||||
}
|
||||
|
||||
// looks for the use of a wrong constructor.
|
||||
$endFunctionIndex = $tokens[$stackPtr]['scope_closer'];
|
||||
$doubleColonIndex = $phpcsFile->findNext(
|
||||
array(T_DOUBLE_COLON),
|
||||
$stackPtr,
|
||||
$endFunctionIndex
|
||||
);
|
||||
while ($doubleColonIndex) {
|
||||
if ($tokens[($doubleColonIndex + 1)]['code'] === T_STRING
|
||||
&& $tokens[($doubleColonIndex + 1)]['content'] === $wrongConstructor
|
||||
) {
|
||||
$phpcsFile->addError($error, ($doubleColonIndex + 1));
|
||||
}
|
||||
|
||||
$doubleColonIndex = $phpcsFile->findNext(
|
||||
array(T_DOUBLE_COLON),
|
||||
$doubleColonIndex + 1,
|
||||
$endFunctionIndex
|
||||
);
|
||||
}
|
||||
|
||||
}//end processTokenWithinScope()
|
||||
|
||||
protected function processTokenOutsideScope(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
// TODO: Implement processTokenOutsideScope() method.
|
||||
}
|
||||
|
||||
}//end class
|
||||
|
||||
?>
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
/**
|
||||
* CodeIgniter_Sniffs_NamingConventions_ValidClassNameSniff.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baoabz.com>
|
||||
* @copyright 2010 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
/**
|
||||
* CodeIgniter_Sniffs_NamingConventions_ValidClassNameSniff.
|
||||
*
|
||||
* Ensures that class and interface names have their first letter uppercase
|
||||
* and that words are separated with an underscore, and not CamelCased.
|
||||
*
|
||||
* @todo Try to avoid overly long and verbose names in using property rule and
|
||||
* configuration variable to set limits. Have a look at
|
||||
* CodeIgniter_Sniffs_NamingConventions_ValidMethodNameSniff.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baoabz.com>
|
||||
* @copyright 2010 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
namespace CodeIgniter\Sniffs\NamingConventions;
|
||||
|
||||
use PHP_CodeSniffer\Sniffs\Sniff;
|
||||
use PHP_CodeSniffer\Files\File;
|
||||
|
||||
class ValidClassNameSniff implements Sniff
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array of tokens this test wants to listen for.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
return array(
|
||||
T_CLASS,
|
||||
T_INTERFACE,
|
||||
);
|
||||
|
||||
}//end register()
|
||||
|
||||
/**
|
||||
* Processes this test, when one of its tokens is encountered.
|
||||
*
|
||||
* @param File $phpcsFile The current file being processed.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function process(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
// get the class name
|
||||
$className = trim($phpcsFile->getDeclarationName($stackPtr));
|
||||
// compute the expected class name
|
||||
// [^_] means "something different from _", but not "nothing or something different from _"
|
||||
$lcClassNameChunk = preg_replace('/([^_])([A-Z])/', '${1}_${2}', $className);
|
||||
$expectedClassName
|
||||
= strtoupper($className[0]) . strtolower(substr($lcClassNameChunk,1));
|
||||
// ensures that the current class name
|
||||
// and the expected class name are identical
|
||||
if (0 !== strcmp($className, $expectedClassName)) {
|
||||
$error = 'Class names should always have their first letter uppercase. Multiple words should be separated with an underscore, and not CamelCased. Please consider ' . $expectedClassName . ' instead of ' . $className . '.';
|
||||
$phpcsFile->addError($error, $stackPtr);
|
||||
}
|
||||
}//end process()
|
||||
|
||||
}//end class
|
||||
|
||||
?>
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
/**
|
||||
* CodeIgniter_Sniffs_NamingConventions_ValidFileNameSniff.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2011 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
/**
|
||||
* CodeIgniter_Sniffs_NamingConventions_ValidFileNameSniff.
|
||||
*
|
||||
* Tests that the file name matchs the name of the class that it contains in lower case.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baobaz.com>
|
||||
* @copyright 2011 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
namespace CodeIgniter\Sniffs\NamingConventions;
|
||||
|
||||
use PHP_CodeSniffer\Sniffs\Sniff;
|
||||
use PHP_CodeSniffer\Files\File;
|
||||
|
||||
class ValidFileNameSniff implements Sniff
|
||||
{
|
||||
/**
|
||||
* Returns an array of tokens this test wants to listen for.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
return array(
|
||||
T_CLASS,
|
||||
T_INTERFACE,
|
||||
);
|
||||
}//end register()
|
||||
|
||||
|
||||
/**
|
||||
* Processes this test, when one of its tokens is encountered.
|
||||
*
|
||||
* @param File $phpcsFile The file being scanned.
|
||||
* @param int $stackPtr The position of the current token in the
|
||||
* stack passed in $tokens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function process(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
// computes the expected filename based on the name of the class or interface that it contains.
|
||||
$decNamePtr = $phpcsFile->findNext(T_STRING, $stackPtr);
|
||||
$decName = $tokens[$decNamePtr]['content'];
|
||||
$expectedFileName = strtolower($decName);
|
||||
// extracts filename without extension from its path.
|
||||
$fullPath = $phpcsFile->getFilename();
|
||||
$fileNameAndExt = basename($fullPath);
|
||||
$fileName = substr($fileNameAndExt, 0, strrpos($fileNameAndExt, '.'));
|
||||
|
||||
if ($expectedFileName !== $fileName) {
|
||||
$errorTemplate = 'Filename "%s" doesn\'t match the name of the %s that it contains "%s" in lower case. "%s" was expected.';
|
||||
$errorMessage = sprintf(
|
||||
$errorTemplate,
|
||||
$fileName,
|
||||
strtolower($tokens[$stackPtr]['content']), // class or interface
|
||||
$decName,
|
||||
$expectedFileName
|
||||
);
|
||||
$phpcsFile->addError($errorMessage, 0);
|
||||
}
|
||||
}//end process()
|
||||
}//end class
|
||||
|
||||
?>
|
|
@ -0,0 +1,161 @@
|
|||
<?php
|
||||
/**
|
||||
* CodeIgniter_Sniffs_NamingConventions_ValidMethodNameSniff.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baoabz.com>
|
||||
* @copyright 2010 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
/**
|
||||
* CodeIgniter_Sniffs_NamingConventions_ValidMethodNameSniff.
|
||||
*
|
||||
* Ensures that class methods and functions areentirely lowercased and that
|
||||
* words are separated with an underscore, and not CamelCased.
|
||||
* Ensures that private class methods are prefixed with an underscore and that
|
||||
* all other methods are not prefixed with an underscored.
|
||||
* Ensures that names longer than 50 chars are prohibited. Likewise names longer
|
||||
* than 35 chars raise a warning.
|
||||
*
|
||||
* @todo Use a rule property or a configuration variable to allow users to set
|
||||
* their own maximum lengths for function and method names. Have a look at
|
||||
* CodeIgniter_Sniffs_Files_ClosingLocationCommentSniff and application root.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baoabz.com>
|
||||
* @copyright 2010 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
namespace CodeIgniter\Sniffs\NamingConventions;
|
||||
|
||||
use PHP_CodeSniffer\Sniffs\AbstactScopeSniff;
|
||||
use PHP_CodeSniffer\Files\File;
|
||||
|
||||
class ValidMethodNameSniff extends AbstractScopeSniff
|
||||
{
|
||||
/**
|
||||
* A list of all PHP magic methods.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $magicMethods = array(
|
||||
'construct',
|
||||
'destruct',
|
||||
'call',
|
||||
'callStatic',
|
||||
'get',
|
||||
'set',
|
||||
'isset',
|
||||
'unset',
|
||||
'sleep',
|
||||
'wakeup',
|
||||
'toString',
|
||||
'set_state',
|
||||
'clone',
|
||||
);
|
||||
|
||||
/**
|
||||
* Defines which token(s) in which scope(s) will be proceed.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(array(T_CLASS, T_INTERFACE), array(T_FUNCTION), true);
|
||||
|
||||
}//end __construct()
|
||||
|
||||
|
||||
/**
|
||||
* Processes the tokens within the scope.
|
||||
*
|
||||
* @param File $phpcsFile The file being processed.
|
||||
* @param int $stackPtr The position where this token was
|
||||
* found.
|
||||
* @param int $currScope The position of the current scope.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope)
|
||||
{
|
||||
$methodName = $phpcsFile->getDeclarationName($stackPtr);
|
||||
if ($methodName === null) {
|
||||
// Ignore closures.
|
||||
return;
|
||||
}
|
||||
|
||||
$className = $phpcsFile->getDeclarationName($currScope);
|
||||
|
||||
// Is this a magic method i.e. is prefixed with "__".
|
||||
if (0 === strcmp(substr($methodName, 0, 2), '__')) {
|
||||
$magicPart = substr($methodName, 2);
|
||||
if (in_array($magicPart, self::$magicMethods) === false) {
|
||||
$error = "Method name \"$className::$methodName\" is invalid; only PHP magic methods should be prefixed with a double underscore";
|
||||
$phpcsFile->addError($error, $stackPtr);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// PHP4 constructors are allowed to break our rules.
|
||||
if ($methodName === $className) {
|
||||
return;
|
||||
}
|
||||
|
||||
// PHP4 destructors are allowed to break our rules.
|
||||
if ($methodName === '_'.$className) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (0 !== strcmp($methodName, strtolower($methodName))) {
|
||||
$uscrdMethodName = preg_replace('/([A-Z])/', '_${1}', $methodName);
|
||||
$expectedMethodName = strtolower($uscrdMethodName);
|
||||
$error = "Class methods should be entirely lowercased. Please consider \"$expectedMethodName\" instead of \"$methodName\".";
|
||||
$phpcsFile->addError($error, $stackPtr);
|
||||
return;
|
||||
}
|
||||
|
||||
$methodProps = $phpcsFile->getMethodProperties($stackPtr);
|
||||
$scope = $methodProps['scope'];
|
||||
$scopeSpecified = $methodProps['scope_specified'];
|
||||
|
||||
// If it's a private method, it must have an underscore on the front.
|
||||
if ($scope === 'private' && $methodName{0} !== '_') {
|
||||
$error = "Private method name \"$className::$methodName\" must be prefixed with an underscore";
|
||||
$phpcsFile->addError($error, $stackPtr);
|
||||
return;
|
||||
}
|
||||
|
||||
// If it's not a private method, it must not have an underscore on the front.
|
||||
if ($scope !== 'private' && $methodName{0} === '_') {
|
||||
if (true === $scopeSpecified) {
|
||||
$error = "Public method name \"$className::$methodName\" must not be prefixed with an underscore";
|
||||
} else {
|
||||
$error = ucfirst($scope)." method name \"$className::$methodName\" must not be prefixed with an underscore";
|
||||
}
|
||||
$phpcsFile->addError($error, $stackPtr);
|
||||
return;
|
||||
}
|
||||
|
||||
// If name is too verbose,
|
||||
// then either an error or a warning is displayed.
|
||||
$error_limit = 50;
|
||||
$warning_limit = 35;
|
||||
if (strlen($methodName) > $error_limit) {
|
||||
$error = "Overly long and verbose names are prohibited. Please find a name shorter than $error_limit chars.";
|
||||
$phpcsFile->addError($error, $stackPtr);
|
||||
return;
|
||||
} else if (strlen($methodName) > $warning_limit) {
|
||||
$warning = "Try to avoid overly long and verbose names in finding a name shorter than $warning_limit chars.";
|
||||
$phpcsFile->addWarning($warning, $stackPtr);
|
||||
}
|
||||
}//end processTokenWithinScope()
|
||||
|
||||
}//end class
|
||||
|
||||
?>
|
|
@ -0,0 +1,562 @@
|
|||
<?php
|
||||
/**
|
||||
* CodeIgniter_Sniffs_NamingConventions_ValidVariableNameSniff.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baoabz.com>
|
||||
* @copyright 2010 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
/**
|
||||
* CodeIgniter_Sniffs_NamingConventions_ValidVariableNameSniff.
|
||||
*
|
||||
* Ensures that variable names contain only lowercase letters,
|
||||
* use underscore separators.
|
||||
* Ensures that class attribute names are prefixed with an underscore,
|
||||
* only when they are private.
|
||||
* Ensure that variable names are longer than 3 chars except those declared
|
||||
* in for loops.
|
||||
*
|
||||
* @todo Try to avoid overly long and verbose names in using property rule and
|
||||
* configuration variable to set limits. Have a look at
|
||||
* CodeIgniter_Sniffs_NamingConventions_ValidMethodNameSniff.
|
||||
* @todo Use a property rule or a configuration variable to allow users to set
|
||||
* minimum variable name length. Have a look at
|
||||
* CodeIgniter_Sniffs_Files_ClosingLocationCommentSniff and application root.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Thomas Ernest <thomas.ernest@baoabz.com>
|
||||
* @copyright 2010 Thomas Ernest
|
||||
* @license http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
namespace CodeIgniter\Sniffs\NamingConventions;
|
||||
|
||||
use PHP_CodeSniffer\Sniffs\AbstractVariableSniff;
|
||||
use PHP_CodeSniffer\Files\File;
|
||||
|
||||
class ValidVariableNameSniff extends AbstractVariableSniff
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Processes class member variables.
|
||||
*
|
||||
* @param File $phpcsFile The file being scanned.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processMemberVar(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
// get variable name and properties
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
$varTk = $tokens[$stackPtr];
|
||||
$varName = substr($varTk['content'], 1);
|
||||
$varProps = $phpcsFile->getMemberProperties($stackPtr);
|
||||
// check(s)
|
||||
if ( ! $this->checkLowerCase($phpcsFile, $stackPtr, $varName) ) {
|
||||
return;
|
||||
}
|
||||
if ( ! $this->checkVisibilityPrefix($phpcsFile, $stackPtr, $varName, $varProps)) {
|
||||
return;
|
||||
}
|
||||
if ( ! $this->checkLength($phpcsFile, $stackPtr, $varName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
}//end processMemberVar()
|
||||
|
||||
|
||||
/**
|
||||
* Processes normal variables.
|
||||
*
|
||||
* @param File $phpcsFile The file where this token was found.
|
||||
* @param int $stackPtr The position where the token was found.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processVariable(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
// get variable name
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
$varTk = $tokens[$stackPtr];
|
||||
$varName = substr($varTk['content'], 1);
|
||||
// skip the current object variable, i.e. $this
|
||||
if (0 === strcmp($varName, 'this')) {
|
||||
return;
|
||||
}
|
||||
// check(s)
|
||||
if ( ! $this->checkLowerCase($phpcsFile, $stackPtr, $varName)) {
|
||||
return;
|
||||
}
|
||||
if ( ! $this->checkLength($phpcsFile, $stackPtr, $varName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
}//end processVariable()
|
||||
|
||||
|
||||
/**
|
||||
* Processes variables in double quoted strings.
|
||||
*
|
||||
* @param File $phpcsFile The file where this token was found.
|
||||
* @param int $stackPtr The position where the token was found.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processVariableInString(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
$stringTk = $tokens[$stackPtr];
|
||||
$stringString = $stringTk['content'];
|
||||
$varAt = self::_getVariablePosition($stringString, 0);
|
||||
while (false !== $varAt) {
|
||||
// get variable name
|
||||
$matches = array();
|
||||
preg_match('/^\$\{?([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)\}?/', substr($stringString, $varAt), $matches);
|
||||
$varName = $matches[1];
|
||||
// check(s)
|
||||
if ( ! $this->checkLowerCase($phpcsFile, $stackPtr, $varName)) {
|
||||
return;
|
||||
}
|
||||
if ( ! $this->checkLength($phpcsFile, $stackPtr, $varName)) {
|
||||
return;
|
||||
}
|
||||
// prepare checking next variable
|
||||
$varAt = self::_getVariablePosition($stringString, $varAt + 1);
|
||||
}
|
||||
|
||||
}//end processVariableInString()
|
||||
|
||||
|
||||
/**
|
||||
* Checks that the variable name is all in lower case, else it add an error
|
||||
* to $phpcsFile. Returns true if variable name is all in lower case, false
|
||||
* otherwise.
|
||||
*
|
||||
* @param File $phpcsFile The current file being processed.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
* @param string $varName The name of the variable to
|
||||
* procced without $, { nor }.
|
||||
*
|
||||
* @return bool true if variable name is all in lower case, false otherwise.
|
||||
*/
|
||||
protected function checkLowerCase(File $phpcsFile, $stackPtr, $varName)
|
||||
{
|
||||
$isInLowerCase = true;
|
||||
if (0 !== strcmp($varName, strtolower($varName))) {
|
||||
// get the expected variable name
|
||||
$varNameWithUnderscores = preg_replace('/([A-Z])/', '_${1}', $varName);
|
||||
$expectedVarName = strtolower(ltrim($varNameWithUnderscores, '_'));
|
||||
// adapts the error message to the error case
|
||||
if (strlen($varNameWithUnderscores) > strlen($varName)) {
|
||||
$error = 'Variables should not use CamelCasing or start with a Capital.';
|
||||
} else {
|
||||
$error = 'Variables should be entirely lowercased.';
|
||||
}
|
||||
$error = $error . 'Please consider "' . $expectedVarName
|
||||
. '" instead of "' . $varName . '".';
|
||||
// adds the error and changes return value
|
||||
$phpcsFile->addError($error, $stackPtr);
|
||||
$isInLowerCase = false;
|
||||
}
|
||||
return $isInLowerCase;
|
||||
}//end checkLowerCase()
|
||||
|
||||
/**
|
||||
* Checks that an underscore is used at the beginning of a variable only if
|
||||
* it is about a private variable. If it isn't a private variable, then it
|
||||
* must not be prefixed with an underscore. Returns true if $varName is
|
||||
* properly prefixed according to the variable visibility provided in
|
||||
* $varProps, false otherwise.
|
||||
*
|
||||
* @param File $phpcsFile The current file being processed.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
* @param string $varName The name of the variable to
|
||||
* procced without $, { nor }.
|
||||
* @param array $varProps Member variable properties like
|
||||
* its visibility.
|
||||
*
|
||||
* @return bool true if variable name is prefixed with an underscore only
|
||||
* when it is about a private variable, false otherwise.
|
||||
*/
|
||||
protected function checkVisibilityPrefix(File $phpcsFile, $stackPtr, $varName, $varProps)
|
||||
{
|
||||
$isVisibilityPrefixRight = true;
|
||||
$scope = $varProps['scope'];
|
||||
// If it's a private variable, it must have an underscore on the front.
|
||||
if ($scope === 'private' && $varName{0} !== '_') {
|
||||
$error = "Private variable name \"$varName\" must be prefixed with an underscore";
|
||||
$phpcsFile->addError($error, $stackPtr);
|
||||
$isVisibilityPrefixRight = false;
|
||||
} else if ($scope !== 'private' && $varName{0} === '_') {
|
||||
// If it's not a private variable,
|
||||
// then it must not start with an underscore.
|
||||
if (isset ($scopeSpecified) && true === $scopeSpecified) {
|
||||
$error = "Public variable name \"$varName\" must not be prefixed with an underscore";
|
||||
} else {
|
||||
$error = ucfirst($scope) . " variable name \"$varName\" must not be prefixed with an underscore";
|
||||
}
|
||||
$phpcsFile->addError($error, $stackPtr);
|
||||
$isVisibilityPrefixRight = false;
|
||||
}
|
||||
return $isVisibilityPrefixRight;
|
||||
}//end checkVisibilityPrefix()
|
||||
|
||||
/**
|
||||
* Checks that variable name length is not too short. Returns true, if it
|
||||
* meets minimum length requirement, false otherwise.
|
||||
*
|
||||
* A variable name is too short if it is shorter than the minimal
|
||||
* length and it isn't in the list of allowed short names nor declared in a
|
||||
* for loop (in which it would be nested).
|
||||
* The minimal length is defined in the function. It is 3 chars now.
|
||||
* The list of allowed short names is defined in the function.
|
||||
* It is case-sensitive. It contains only 'ci' now.
|
||||
*
|
||||
* @param File $phpcsFile The current file being processed.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
* @param string $varName The name of the variable to
|
||||
* procced without $, { nor }.
|
||||
*
|
||||
* @return bool false if variable name $varName is shorter than the minimal
|
||||
* length and it isn't in the list of allowed short names nor declared in a
|
||||
* for loop (in which it would be nested), otherwise true.
|
||||
*/
|
||||
protected function checkLength(File $phpcsFile, $stackPtr, $varName)
|
||||
{
|
||||
$minLength = 3;
|
||||
$allowedShortName = array('ci');
|
||||
|
||||
$isLengthRight = true;
|
||||
// cleans variable name
|
||||
$varName = ltrim($varName, '_');
|
||||
if (strlen($varName) <= $minLength) {
|
||||
// skips adding an error, if it is a specific variable name
|
||||
if (in_array($varName, $allowedShortName)) {
|
||||
return $isLengthRight;
|
||||
}
|
||||
// skips adding an error, if the variable is in a for loop
|
||||
if (false !== self::_isInForLoop($phpcsFile, $stackPtr, $varName)) {
|
||||
return $isLengthRight;
|
||||
}
|
||||
// adds the error message finally
|
||||
$error = 'Very short'
|
||||
. (
|
||||
$minLength > 0 ?
|
||||
' (i.e. less than ' . ($minLength + 1) . ' chars)'
|
||||
: ''
|
||||
)
|
||||
. ', non-word variables like "' . $varName
|
||||
. '" should only be used as iterators in for() loops.';
|
||||
$phpcsFile->addError($error, $stackPtr);
|
||||
$isLengthRight = false;
|
||||
}
|
||||
return $isLengthRight;
|
||||
}//end checkLength()
|
||||
|
||||
/**
|
||||
* Returns the position of closest previous T_FOR, if token associated with
|
||||
* $stackPtr in $phpcsFile is in a for loop, otherwise false.
|
||||
*
|
||||
* @param File $phpcsFile The current file being processed.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
* @param string $varName The name of the variable to
|
||||
* procced without $, { nor }.
|
||||
*
|
||||
* @return int|bool Position of T_FOR if token associated with $stackPtr in
|
||||
* $phpcsFile is in the head of a for loop, otherwise false.
|
||||
*/
|
||||
private static function _isInForLoop(File $phpcsFile, $stackPtr, $varName)
|
||||
{
|
||||
$keepLookingFromPtr = $stackPtr;
|
||||
while (false !== $keepLookingFromPtr) {
|
||||
// looks if it is in (head or body) of a for loop
|
||||
$forPtr = self::_isInForLoopHead($phpcsFile, $keepLookingFromPtr);
|
||||
if (false === $forPtr) {
|
||||
$forPtr = self::_isInForLoopBody($phpcsFile, $keepLookingFromPtr);
|
||||
}
|
||||
// checks if it is declared in here and prepares next step
|
||||
if (false !== $forPtr) {
|
||||
if (false !== self::_isDeclaredInForLoop($phpcsFile, $forPtr, $varName)) {
|
||||
return $forPtr;
|
||||
}
|
||||
$keepLookingFromPtr = $forPtr;
|
||||
} else {
|
||||
$keepLookingFromPtr = false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}//end _isInForLoop()
|
||||
|
||||
/**
|
||||
* Returns the position of closest previous T_FOR, if token associated with
|
||||
* $stackPtr in $phpcsFile is in the head of a for loop, otherwise false.
|
||||
* The head is the code placed between parenthesis next to the key word
|
||||
* 'for' : for (<loop_head>) {<loop_body>}.
|
||||
*
|
||||
* @param File $phpcsFile The current file being processed.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
*
|
||||
* @return int|bool Position of T_FOR if token associated with $stackPtr in
|
||||
* $phpcsFile is in the head of a for loop, otherwise false.
|
||||
*/
|
||||
private static function _isInForLoopHead(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
$isInForLoop = false;
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
$currentTk = $tokens[$stackPtr];
|
||||
if (array_key_exists('nested_parenthesis', $currentTk)) {
|
||||
$nestedParenthesis = $currentTk['nested_parenthesis'];
|
||||
foreach ( $nestedParenthesis as $openParPtr => $closeParPtr) {
|
||||
$nonWhitspacePtr = $phpcsFile->findPrevious(
|
||||
array(T_WHITESPACE),
|
||||
$openParPtr - 1,
|
||||
null,
|
||||
true,
|
||||
null,
|
||||
true
|
||||
);
|
||||
if (false !== $nonWhitspacePtr) {
|
||||
$isFor = T_FOR === $tokens[$nonWhitspacePtr]['code'];
|
||||
if ($isFor) {
|
||||
$isInForLoop = $nonWhitspacePtr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $isInForLoop;
|
||||
}//end _isInForLoopHead()
|
||||
|
||||
/**
|
||||
* Returns the position of closest previous T_FOR, if token associated with
|
||||
* $stackPtr in $phpcsFile is in the body of a for loop, otherwise false.
|
||||
* The body are the instructions placed after parenthesis of a 'for'
|
||||
* declaration, enclosed with curly brackets usually.
|
||||
* 'for' : for (<loop_head>) {<loop_body>}.
|
||||
*
|
||||
* @param File $phpcsFile The current file being processed.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
*
|
||||
* @return int|bool Position of T_FOR if token associated with $stackPtr in
|
||||
* $phpcsFile is in the body of a for loop, otherwise false.
|
||||
*/
|
||||
private static function _isInForLoopBody(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
$isInForLoop = false;
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
// get englobing hierarchy
|
||||
$parentPtrAndCode = $tokens[$stackPtr]['conditions'];
|
||||
krsort($parentPtrAndCode);
|
||||
|
||||
// looks for a for loop having a body not enclosed with curly brackets,
|
||||
// which involves that its body contains only one instruction.
|
||||
if (is_array($parentPtrAndCode) && ! empty($parentPtrAndCode)) {
|
||||
$parentCode = reset($parentPtrAndCode);
|
||||
$parentPtr = key($parentPtrAndCode);
|
||||
$openBracketPtr = $tokens[$parentPtr]['scope_opener'];
|
||||
} else {
|
||||
$parentCode = 0;
|
||||
$parentPtr = 0;
|
||||
$openBracketPtr = 0;
|
||||
}
|
||||
$openResearchScopePtr = $stackPtr;
|
||||
// recursive search, since a for statement may englobe other inline
|
||||
// control statement or may be near to function calls, etc...
|
||||
while (false !== $openResearchScopePtr) {
|
||||
$closeParPtr = $phpcsFile->findPrevious(
|
||||
array(T_CLOSE_PARENTHESIS),
|
||||
$openResearchScopePtr,
|
||||
null,
|
||||
false,
|
||||
null,
|
||||
true
|
||||
);
|
||||
// is there a closing parenthesis with a control statement before
|
||||
// the previous instruction ?
|
||||
if (false !== $closeParPtr) {
|
||||
// is there no opening curly bracket specific to
|
||||
// set of instructions, between the closing parenthesis
|
||||
// and the current token ?
|
||||
if ($openBracketPtr < $closeParPtr) {
|
||||
// starts the search from the token before the closing
|
||||
// parenthesis, if it isn't a for statement
|
||||
$openResearchScopePtr = $closeParPtr - 1;
|
||||
// is this parenthesis associated with a for statement ?
|
||||
$closeParenthesisTk = $tokens[$closeParPtr];
|
||||
if (array_key_exists('parenthesis_owner', $closeParenthesisTk)) {
|
||||
$mayBeForPtr = $closeParenthesisTk['parenthesis_owner'];
|
||||
$mayBeForTk = $tokens[$mayBeForPtr];
|
||||
if (T_FOR === $mayBeForTk['code']) {
|
||||
return $mayBeForPtr;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// if it is about a for loop, don't go further
|
||||
// and detect it after one more loop execution, do it now
|
||||
if (T_FOR === $parentCode) {
|
||||
return $parentPtr;
|
||||
}
|
||||
// starts the search from the token before the one
|
||||
// englobing the current statement
|
||||
$openResearchScopePtr = $parentPtr - 1;
|
||||
// re-initialize variables about the englobing structure
|
||||
if (is_array($parentPtrAndCode)) {
|
||||
$parentCode = next($parentPtrAndCode);
|
||||
$parentPtr = key($parentPtrAndCode);
|
||||
$openBracketPtr = $tokens[$parentPtr]['scope_opener'];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$openResearchScopePtr = false;
|
||||
}
|
||||
}
|
||||
// looks for a for loop having a body enclosed with curly brackets
|
||||
foreach ($parentPtrAndCode as $parentPtr => $parentCode) {
|
||||
if (T_FOR === $parentCode) {
|
||||
return $parentPtr;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}//end _isInForLoopBody()
|
||||
|
||||
/**
|
||||
* Returns true if a variable declared in the head of the for loop pointed
|
||||
* by $forPtr in file $phpcsFile has the name $varName.
|
||||
*
|
||||
* @param File $phpcsFile The current file being processed.
|
||||
* @param int $forPtr The position of the 'for' token
|
||||
* in the stack passed in $tokens.
|
||||
* @param string $varName The name of the variable to
|
||||
* procced without $, { nor }.
|
||||
*
|
||||
* @return int|bool true if a variable declared in the head of the for loop
|
||||
* pointed by $forPtr in file $phpcsFile has the name $varName.
|
||||
*/
|
||||
private static function _isDeclaredInForLoop(File $phpcsFile, $forPtr, $varName)
|
||||
{
|
||||
$isDeclaredInFor = false;
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
$forVarPtrs = self::_getVarDeclaredInFor($phpcsFile, $forPtr);
|
||||
foreach ($forVarPtrs as $forVarPtr) {
|
||||
$forVarTk = $tokens[$forVarPtr];
|
||||
// get variable name
|
||||
$matches = array();
|
||||
preg_match('/^\$\{?([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)\}?/', $forVarTk['content'], $matches);
|
||||
$forVarName = $matches[1];
|
||||
if (0 === strcmp($forVarName, $varName)) {
|
||||
$isDeclaredInFor = $forVarPtr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $isDeclaredInFor;
|
||||
}//end _isDeclaredInForLoop()
|
||||
|
||||
/**
|
||||
* Returns list of pointers to variables declared in for loop associated to
|
||||
* $forPtr in file $phpcsFile.
|
||||
*
|
||||
* All pointers in the result list are pointing to token with code
|
||||
* T_VARIABLE. An exception is raised, if $forPtr doesn't point a token with
|
||||
* code T_FOR.
|
||||
*
|
||||
* @param File $phpcsFile The current file being processed.
|
||||
* @param int $forPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
*
|
||||
* @return array List of pointers to variables declared in for loop $forPtr.
|
||||
*/
|
||||
private static function _getVarDeclaredInFor(File $phpcsFile, $forPtr)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
$forTk = $tokens[$forPtr];
|
||||
if (T_FOR !== $forTk['code']) {
|
||||
throw new PHP_CodeSniffer_Exception('$forPtr must be of type T_FOR');
|
||||
}
|
||||
$openParPtr = $forTk['parenthesis_opener'];
|
||||
$openParenthesisTk = $tokens[$openParPtr];
|
||||
$endOfDeclPtr = $phpcsFile->findNext(array(T_SEMICOLON), $openParPtr);
|
||||
$forVarPtrs = array();
|
||||
$varPtr = $phpcsFile->findNext(
|
||||
array(T_VARIABLE),
|
||||
$openParPtr + 1,
|
||||
$endOfDeclPtr
|
||||
);
|
||||
while (false !== $varPtr) {
|
||||
$forVarPtrs [] = $varPtr;
|
||||
$varPtr = $phpcsFile->findNext(
|
||||
array(T_VARIABLE),
|
||||
$varPtr + 1,
|
||||
$endOfDeclPtr
|
||||
);
|
||||
}
|
||||
return $forVarPtrs;
|
||||
}//end _getVarDeclaredInFor()
|
||||
|
||||
/**
|
||||
* Returns the position of first occurrence of a PHP variable starting with
|
||||
* $ in $haystack from $offset.
|
||||
*
|
||||
* @param string $haystack The string to search in.
|
||||
* @param int $offset The optional offset parameter allows you to
|
||||
* specify which character in haystack to start
|
||||
* searching. The returned position is still
|
||||
* relative to the beginning of haystack.
|
||||
*
|
||||
* @return mixed The position as an integer
|
||||
* or the boolean false, if no variable is found.
|
||||
*/
|
||||
private static function _getVariablePosition($haystack, $offset = 0)
|
||||
{
|
||||
$var_starts_at = strpos($haystack, '$', $offset);
|
||||
$is_a_var = false;
|
||||
while (false !== $var_starts_at && ! $is_a_var) {
|
||||
// makes sure that $ is used for a variable and not as a symbol,
|
||||
// if $ is protected with the escape char, then it is a symbol.
|
||||
if (0 !== strcmp($haystack[$var_starts_at - 1], '\\')) {
|
||||
if (0 === strcmp($haystack[$var_starts_at + 1], '{')) {
|
||||
// there is an opening brace in the right place
|
||||
// so it looks for the closing brace in the right place
|
||||
$hsChunk2 = substr($haystack, $var_starts_at + 2);
|
||||
if (1 === preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\}/', $hsChunk2)) {
|
||||
$is_a_var = true;
|
||||
}
|
||||
} else {
|
||||
$hsChunk1 = substr($haystack, $var_starts_at + 1);
|
||||
if (1 === preg_match('/^[a-zA-Z_\x7f-\xff]/', $hsChunk1)) {
|
||||
// $ is used for a variable and not as a symbol,
|
||||
// since what follows $ matchs the definition of
|
||||
// a variable label for PHP.
|
||||
$is_a_var = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// update $var_starts_at for the next variable
|
||||
// only if no variable was found, since it is returned otherwise.
|
||||
if ( ! $is_a_var) {
|
||||
$var_starts_at = strpos($haystack, '$', $var_starts_at + 1);
|
||||
}
|
||||
}
|
||||
if ($is_a_var) {
|
||||
return $var_starts_at;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}//end _getVariablePosition()
|
||||
}//end class
|
||||
|
||||
?>
|
|
@ -0,0 +1,47 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<ruleset name="CodeIgniter">
|
||||
<description>CodeIgniter coding standard as described at http://codeigniter.com/user_guide/general/styleguide.html.</description>
|
||||
<rule ref="Generic.Files.LineEndings">
|
||||
<properties>
|
||||
<property name="eolChar" value="\n"/>
|
||||
</properties>
|
||||
</rule>
|
||||
|
||||
<!-- PHP files should OMIT the closing PHP tag -->
|
||||
<rule ref="Zend.Files.ClosingTag"/>
|
||||
<!-- Always use full PHP opening tags -->
|
||||
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
|
||||
|
||||
<!-- Constants should always be fully uppercase -->
|
||||
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
|
||||
<!-- TRUE, FALSE, and NULL keywords should always be fully uppercase -->
|
||||
<rule ref="Generic.PHP.UpperCaseConstant"/>
|
||||
|
||||
<!-- One statement per line -->
|
||||
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
|
||||
|
||||
<!-- Classes and functions should be commented -->
|
||||
<rule ref="PEAR.Commenting.ClassComment"/>
|
||||
<rule ref="PEAR.Commenting.FunctionComment"/>
|
||||
<rule ref="Squiz.Commenting.FunctionCommentThrowTag"/>
|
||||
<!-- Use warnings for docblock comments for files and variables, since nothing is cleary explained -->
|
||||
<rule ref="PEAR.Commenting.FileComment">
|
||||
<properties>
|
||||
<property name="error" value="false"/>
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="Squiz.Commenting.VariableComment">
|
||||
<properties>
|
||||
<property name="error" value="false"/>
|
||||
</properties>
|
||||
</rule>
|
||||
|
||||
<!-- Use Allman style indenting. With the exception of Class declarations,
|
||||
braces are always placed on a line by themselves, and indented at the same level as the control statement that "owns" them. -->
|
||||
<rule ref="Generic.Functions.OpeningFunctionBraceBsdAllman"/>
|
||||
<rule ref="PEAR.WhiteSpace.ScopeClosingBrace"/>
|
||||
<rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
|
||||
|
||||
<!-- @todo Please see PHP_CodeSniffer_Standards_CodeIgniter_CodeIgniterCodingStandard for more details about what there is to do -->
|
||||
</ruleset>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue