Compare commits
576 Commits
fa0395bc7b
...
feature/ma
Author | SHA1 | Date | |
---|---|---|---|
47679cd4e4 | |||
0f8db5a3f8 | |||
c38e89d3f1 | |||
307f2ac7d7 | |||
ba57cad514 | |||
86d030bb71 | |||
3b38b5d349 | |||
28fb96db6a | |||
af4dec77d1 | |||
df7f462ead | |||
68e436cd67 | |||
6d1782cac6 | |||
74a2cf7303 | |||
4d6a1827a3 | |||
fd6577c984 | |||
62ccdc9518 | |||
e7da0d5d00 | |||
e445298159 | |||
5740c0e47f | |||
61244f783a | |||
621da92b68 | |||
5914176b8f | |||
5054d8f19b | |||
e4e952e842 | |||
8f16f33a1e | |||
d165440483 | |||
1720f6854b | |||
3e6452a44d | |||
d02732b0dd | |||
ecec1dd8df | |||
c1528d667a | |||
894d09ea6f | |||
ab3c8da4f6 | |||
760e1782d0 | |||
b8af053c43 | |||
fd6d61ec21 | |||
0c0fbab585 | |||
2c3f2d3f92 | |||
15e0ff80f3 | |||
8116e012e7 | |||
38e1b00971 | |||
7b63cbc757 | |||
8b386b8b44 | |||
9f56604917 | |||
4073b96796 | |||
59a28a353b | |||
71615050f3 | |||
5f31b6857e | |||
ef46558040 | |||
079fd3bc74 | |||
a5572e7c6a | |||
e031fd22d3 | |||
d74beb5518 | |||
055bf6ab20 | |||
45e9487b5c | |||
bf054c22c2 | |||
16100f622e | |||
5f31bff6e5 | |||
7578775fed | |||
2579b0aa06 | |||
3262ef9a62 | |||
44ea8acd39 | |||
0870623236 | |||
87bd89d223 | |||
728207d63d | |||
604c49c99d | |||
ce9078328a | |||
713fcc6ab8 | |||
dfbfbd2908 | |||
8b8aa79b6d | |||
e2d670a38c | |||
4d85b39cab | |||
33c90f06dd | |||
3771af0282 | |||
574918f1cc | |||
e128152b5f | |||
fc1371f0ed | |||
ec36c4a7a3 | |||
2c1be63257 | |||
6aca90c02f | |||
a8bab175a2 | |||
95f9f4ef05 | |||
2d868cb119 | |||
d3df35daff | |||
fdb9dcf9be | |||
2ab3c25e96 | |||
46cdf74c52 | |||
d6b735f2aa | |||
70710b24c5 | |||
57fc6fa46e | |||
dafabdbbdb | |||
34cb8bf0be | |||
0e049adc98 | |||
e2284314bd | |||
c4b9ca5ab7 | |||
e1b6fc7394 | |||
fe74619482 | |||
0766cf7e94 | |||
fc575c3078 | |||
187b6f6f05 | |||
42e1dcdff7 | |||
5b44260245 | |||
b2c55c08ce | |||
1f0f25bbde | |||
9f302e712c | |||
2b1190202a | |||
acb1081190 | |||
606b99a0f9 | |||
44f32d9e5f | |||
f5add0b4c5 | |||
1d20d63294 | |||
39da754d8b | |||
02fc372610 | |||
8aa1c787f4 | |||
8028b673fb | |||
52de72b507 | |||
f4b8634cb4 | |||
4f0a56c711 | |||
3ff5f3f1a6 | |||
151d1d0209 | |||
b13f8a5b20 | |||
1d268f9a94 | |||
a844589d7f | |||
83ea955d89 | |||
4392f61db9 | |||
a2352d79f9 | |||
56d3a26cff | |||
cc5c90e2c0 | |||
f9e079cc42 | |||
3f65a5dbd9 | |||
28036fdd05 | |||
54f3b95b88 | |||
1e2bd617fa | |||
62e7001fba | |||
bc8aa02236 | |||
5b30c0e36c | |||
da1fb26647 | |||
b1609465a9 | |||
cb2edb1543 | |||
1e1994264e | |||
f2cc0a8c47 | |||
e474123699 | |||
c3a99d5939 | |||
0212b3e405 | |||
e4ffcb52d8 | |||
37c28c3080 | |||
d154212732 | |||
be410daa8b | |||
38202d1382 | |||
1b99358597 | |||
6107861381 | |||
3d5799ae58 | |||
d649e03684 | |||
fc3d25dd18 | |||
532e0ec601 | |||
3e9f9a3fef | |||
d1b255aa8b | |||
93a0832800 | |||
4894809105 | |||
389e60980e | |||
fe6a01b2fb | |||
2b6a8b35a5 | |||
30a4d66be5 | |||
089579f39f | |||
63ea21f105 | |||
33409a18e3 | |||
2592794a49 | |||
196c5b947f | |||
b9c2972fe9 | |||
37015f7e95 | |||
c3b36dcdf7 | |||
c68b773cbb | |||
933e652dac | |||
ff1e9ebb53 | |||
599880ae27 | |||
a4da8d8624 | |||
87dfb0ae6e | |||
afbac7259a | |||
e2573f35d1 | |||
b8d4b260b6 | |||
ff06e70869 | |||
5e7326a4b6 | |||
26a227c8ae | |||
5defd2b564 | |||
74b15add36 | |||
d8d2cba308 | |||
5983a4b20f | |||
6e4dd8180e | |||
7447579ef0 | |||
ccd5b296f3 | |||
095c33e8aa | |||
4604a9af48 | |||
55d879274c | |||
85b529c22d | |||
3ba45c48f5 | |||
552a4c7aca | |||
2070987403 | |||
d9dab9c88d | |||
f9f133d3a9 | |||
f85af642d2 | |||
f3d9b58ffb | |||
8f682f7f13 | |||
26e626074a | |||
478b407646 | |||
7d210601da | |||
9563876b36 | |||
d9e27d5af7 | |||
936830ae64 | |||
e93149456a | |||
93a15ef1e4 | |||
6950413eec | |||
9162ed240e | |||
84861b5e57 | |||
43bb7a83c8 | |||
081187e3d3 | |||
b2f1bd5ba0 | |||
a471a1083e | |||
8e7f43e487 | |||
390e79ad6d | |||
6169089475 | |||
a7ce78a3fb | |||
6f023928e8 | |||
a4b7183de1 | |||
a428aeebe1 | |||
fc543729d2 | |||
8cec046d66 | |||
1f730fb7f3 | |||
964d8d4237 | |||
0d5c9efd68 | |||
d68eba5697 | |||
d5b9be0196 | |||
d0d99eaa81 | |||
15e9a54c7e | |||
b7e9a17586 | |||
61533b5a4c | |||
5864e7ee94 | |||
3fc7aa88dc | |||
1caa62500a | |||
27e88761e0 | |||
b27a6fab33 | |||
fa978728ce | |||
256a3d2459 | |||
f8f5796a66 | |||
0e0b783a80 | |||
a5125aff74 | |||
71bbe7f2d7 | |||
e2c68a14d1 | |||
5e51562aec | |||
7719a5c614 | |||
05b9a3ad8a | |||
665bed8553 | |||
9c024d1ef7 | |||
94d618b2a1 | |||
4786ee2552 | |||
39d8d4943e | |||
e63a3d0077 | |||
d580cc1a11 | |||
86034a6349 | |||
97ab5acf3e | |||
435180ebaf | |||
d2511901ec | |||
9388dc17fc | |||
a33dd341cd | |||
8e4b5eaaf8 | |||
91679b164f | |||
3c7e4b9ef4 | |||
20045c9a64 | |||
47d43f504d | |||
0502b8e735 | |||
905e8263bc | |||
8710c8a111 | |||
5d9ac2bc51 | |||
062e0543e4 | |||
b97916cfc4 | |||
7af9cafdb6 | |||
84a2fbd119 | |||
bc9c71870c | |||
912e8624b2 | |||
86406bf027 | |||
7b8d44e8c8 | |||
c10f2e5912 | |||
bef0a22758 | |||
092eb95f06 | |||
5f56022109 | |||
4b3397dd63 | |||
529f9e32a1 | |||
939adf126f | |||
63400af1db | |||
019974614c | |||
735c341729 | |||
444ff687fc | |||
f3a5fa2cdc | |||
2ed265dcf1 | |||
dbae630fdd | |||
d69976d015 | |||
2ccbc31ae0 | |||
e50d80560c | |||
7cc0333876 | |||
eb38236926 | |||
85ef4dd60e | |||
f1e29e3b0b | |||
6617a92f5f | |||
ca958b8a88 | |||
dc2e2c7f71 | |||
936fd2d1e1 | |||
7c6a397e31 | |||
7385225a2e | |||
9c335fd350 | |||
57f9169cc7 | |||
8caa80459e | |||
98953cce42 | |||
c7dd309185 | |||
48bfe5d8ab | |||
d9b5bc6507 | |||
21d1ef653f | |||
e8d43e43ff | |||
fc9788a1cd | |||
02dcc950f4 | |||
370b6714bc | |||
dc7a9f9e7a | |||
cfe18c1909 | |||
5156858205 | |||
415ba31270 | |||
c784d1bee9 | |||
a1ade5c2c7 | |||
879b612493 | |||
b4cdd2d5f7 | |||
51cabee824 | |||
d2e51e76f8 | |||
1621d6fe30 | |||
0e32512adc | |||
338f290539 | |||
2aad7e1152 | |||
e542615128 | |||
1c7797b1b1 | |||
ba0d4073d7 | |||
faac3874a8 | |||
ade107ab3c | |||
c192cf1883 | |||
4fb75b11c4 | |||
ccbb71d875 | |||
7f25b4b5e1 | |||
f0b26a251b | |||
ea068d95d0 | |||
1ccc9ab3d4 | |||
5cd19bcdce | |||
712c70b34d | |||
35ab7e7e8b | |||
4b39f93f30 | |||
d3f188684a | |||
82647a171d | |||
e44ab30665 | |||
19333bc338 | |||
4738dae7c8 | |||
a370ffff43 | |||
88f9e539f7 | |||
671b26f038 | |||
e133bd36cf | |||
251dbbe0f0 | |||
e1eb2c4c56 | |||
1078f4c188 | |||
38962cb9cf | |||
3cd699d2e2 | |||
d8b8787be9 | |||
ad3285efd9 | |||
62edca5335 | |||
ac6c5b7d3d | |||
5b5a0ed1f5 | |||
9d7857621e | |||
029cd095cb | |||
c1792907c0 | |||
fa11f5b240 | |||
f55e4dbd5f | |||
ca83472012 | |||
01af47fba1 | |||
e1462657fc | |||
72f63c5e6c | |||
1f076bc2f1 | |||
ad003c7dcf | |||
aef1ccd4a0 | |||
3684bc2e21 | |||
d1d3705a7b | |||
ecdb67a9ab | |||
4c86ce2a8a | |||
5c6bd91425 | |||
18d7e449f7 | |||
bfdaf0e7f2 | |||
ce0510687a | |||
3eb4ce4d21 | |||
674aba801e | |||
c4f486d3fa | |||
dc840a7bff | |||
316cc51387 | |||
68e59770fd | |||
a66b549a8c | |||
74b3bb42ea | |||
72a2ffe924 | |||
6393a1fced | |||
d225011ae9 | |||
bc2333bc95 | |||
675b3843ea | |||
0829d338a9 | |||
20b2bdc6c6 | |||
8492d1df2b | |||
afbadd520b | |||
ac52305002 | |||
d7d17a3051 | |||
80a6bf1535 | |||
93431e41b3 | |||
d99f2a6214 | |||
30277e6355 | |||
06d5327934 | |||
6f772a56b8 | |||
abe82e4689 | |||
379a33a4da | |||
1ba53c9e12 | |||
94906eea8c | |||
8b9b02825a | |||
8f2f90aca2 | |||
d699f9bf62 | |||
e38fdd20ee | |||
f362054ea7 | |||
f597d552be | |||
43977d1bd9 | |||
9aa4e0ae1d | |||
377cf51b44 | |||
57579a52f1 | |||
af9c6c51d4 | |||
0eaa09bea0 | |||
04478afa2f | |||
f2efb41977 | |||
d0a85b2149 | |||
68821fb0d3 | |||
f957d29779 | |||
dc7a39e193 | |||
17f93dcd34 | |||
9991b7c6a3 | |||
91bdef5cc5 | |||
244d304e04 | |||
2600bd409e | |||
0761be6613 | |||
e347aaabe9 | |||
fe3055708f | |||
62153dd1ef | |||
39048e12b3 | |||
094209823a | |||
bcdca32075 | |||
fada4f80a2 | |||
a28c51d94c | |||
df679b2a1a | |||
ec4b16b2af | |||
3c983fc6c9 | |||
7945579e80 | |||
ab1647eed3 | |||
ec7d8e69ab | |||
3cadaca746 | |||
2726bc5074 | |||
b66ef435c6 | |||
a82db6e1da | |||
e1ef31dccd | |||
bf03e85975 | |||
9ab0515954 | |||
b4742a501e | |||
4734417fe2 | |||
54ac535a49 | |||
e536f0f8f3 | |||
dc217d876a | |||
742c0327c2 | |||
ada0434caf | |||
850a475ef6 | |||
02e1f3e091 | |||
c2a3192b32 | |||
0d558b7980 | |||
e4328d8604 | |||
d8a81db78b | |||
3141f1e7c4 | |||
2e2d0f07b4 | |||
0cd357b6cb | |||
fa15da1ee2 | |||
59825259b6 | |||
ef30ae67d2 | |||
38383f5295 | |||
43cd955061 | |||
1a7b10ce3c | |||
d9d5a15376 | |||
b7fc538e78 | |||
be33305cf1 | |||
6ab24c8961 | |||
b212381bb7 | |||
05e37f19ae | |||
8a51fb9c42 | |||
e6da1d9727 | |||
34c2aa9a46 | |||
683e8bc3a8 | |||
1508539140 | |||
064ad35553 | |||
e81a098d31 | |||
01512d0605 | |||
5d8fbceb67 | |||
907c756aa2 | |||
84d50e0209 | |||
87643a5b99 | |||
de6100a546 | |||
b6c0c90943 | |||
726bdaec4c | |||
009ba01e69 | |||
bb1d2b2159 | |||
d6f58893b6 | |||
717ba19792 | |||
9ffc7527c3 | |||
eac6b7d197 | |||
6995561e4f | |||
24bd5a6fc4 | |||
1c5467e8fb | |||
0550ff11a4 | |||
f29bc8f05f | |||
d1473eaac4 | |||
2f369c4e5e | |||
27ace68b1d | |||
66a128663d | |||
b3577a7800 | |||
a5940019bc | |||
b8babf2906 | |||
7d3e75c316 | |||
33417a6acd | |||
e51d87f83f | |||
16fb8f0a96 | |||
1547b24412 | |||
517276da1d | |||
fbce7089a8 | |||
e8aa00e121 | |||
26bac169de | |||
4971570474 | |||
3b473bcefa | |||
85be709ab0 | |||
726794923d | |||
52bead5104 | |||
a6a1c3d102 | |||
66dbf54714 | |||
301a4c7302 | |||
d2e6a11e0b | |||
5fefdd94b0 | |||
9d13a193b6 | |||
3de1c9b527 | |||
34d0659036 | |||
b0c587532f | |||
1754633475 | |||
6a5efba272 | |||
0c62ed0582 | |||
483a3e943c | |||
68ab19b874 | |||
bc4dd543ae | |||
fb8e204f77 | |||
8ed1742de8 | |||
f85f9ff3c9 | |||
e75c3dada8 | |||
670d73be38 | |||
ee37338be4 | |||
b3fc29d19b | |||
a771714357 | |||
1fb29cb877 | |||
db7344bc74 | |||
20ae31b7bf | |||
8ce0b75bb4 | |||
abe01e5592 | |||
606fdc4d96 | |||
7206fa1c3c | |||
d5adec2137 | |||
33669f34b5 | |||
8da6b4f160 | |||
5ef0aaae50 | |||
67efd83ae3 | |||
3b6b5d10ff | |||
18986c6e17 | |||
b6665c8f9c | |||
91cc2fed12 |
6
.env.sample
Normal file
6
.env.sample
Normal file
@ -0,0 +1,6 @@
|
||||
COMPOSE_PATH_SEPARATOR=:
|
||||
COMPOSE_FILE=./docker-compose.yml:./adminer-compose.yml
|
||||
COMPOSE_PROFILES=app,db,cli,cache
|
||||
APP_PATH=./app
|
||||
CLI_PATH=./cli
|
||||
APP_PORT=8080
|
22
.gitignore
vendored
22
.gitignore
vendored
@ -1,8 +1,14 @@
|
||||
.env
|
||||
/vendor/
|
||||
composer.lock
|
||||
/node_modules/
|
||||
package-lock.json
|
||||
Pipfile.lock
|
||||
/logs/
|
||||
/cache/
|
||||
**/*.env
|
||||
**/vendor/
|
||||
**/composer.lock
|
||||
**/node_modules/
|
||||
**/package-lock.json
|
||||
**/Pipfile.lock
|
||||
**/logs/
|
||||
**/cache/
|
||||
**/modules/
|
||||
**/.idea/
|
||||
**/upload?/
|
||||
**/informe?/
|
||||
**/.phpunit.cache/
|
||||
**/coverage/
|
||||
|
1
.key.env.sample
Normal file
1
.key.env.sample
Normal file
@ -0,0 +1 @@
|
||||
API_KEY=
|
22
CLI.Dockerfile
Normal file
22
CLI.Dockerfile
Normal file
@ -0,0 +1,22 @@
|
||||
FROM php:8.4-cli
|
||||
|
||||
ENV TZ "${TZ}"
|
||||
ENV APP_NAME "${APP_NAME}"
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends cron rsyslog nano beanstalkd \
|
||||
&& rm -r /var/lib/apt/lists/*
|
||||
|
||||
RUN pecl install xdebug-3.4.2 \
|
||||
&& docker-php-ext-enable xdebug \
|
||||
&& echo $TZ > /etc/timezone
|
||||
|
||||
COPY --chmod=550 ./cli/start_command /root/start_command
|
||||
|
||||
COPY ./php-errors.ini /usr/local/etc/php/conf.d/docker-php-errors.ini
|
||||
COPY ./php-timezone.ini /usr/local/etc/php/conf.d/docker-php-timezone.ini
|
||||
|
||||
WORKDIR /code/bin
|
||||
|
||||
COPY --chmod=644 ./cli/crontab /var/spool/cron/crontabs/root
|
||||
|
||||
CMD [ "/root/start_command" ]
|
22
Dockerfile
22
Dockerfile
@ -1,6 +1,20 @@
|
||||
FROM php:7.4-fpm
|
||||
FROM php:8.4-fpm
|
||||
|
||||
RUN docker-php-ext-install pdo pdo_mysql
|
||||
ENV TZ=America/Santiago
|
||||
|
||||
RUN pecl install xdebug-3.0.3 \
|
||||
&& docker-php-ext-enable xdebug
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends libzip-dev libicu-dev git \
|
||||
libpng-dev unzip tzdata libxml2-dev beanstalkd \
|
||||
&& rm -r /var/lib/apt/lists/* \
|
||||
&& docker-php-ext-install pdo pdo_mysql zip intl gd bcmath dom \
|
||||
&& pecl install xdebug-3.4.2 \
|
||||
&& docker-php-ext-enable xdebug \
|
||||
&& echo $TZ > /etc/timezone
|
||||
|
||||
COPY ./php-errors.ini /usr/local/etc/php/conf.d/docker-php-errors.ini
|
||||
COPY ./php-xdebug.ini /usr/local/etc/php/conf.d/docker-php-xdebug.ini
|
||||
COPY ./php-memory.ini /usr/local/etc/php/conf.d/docker-php-memory.ini
|
||||
COPY ./php-timezone.ini /usr/local/etc/php/conf.d/docker-php-timezone.ini
|
||||
|
||||
COPY --from=composer /usr/bin/composer /usr/bin/composer
|
||||
|
||||
WORKDIR /code
|
||||
|
24
Log.Dockerfile
Normal file
24
Log.Dockerfile
Normal file
@ -0,0 +1,24 @@
|
||||
FROM php:8-apache
|
||||
|
||||
ENV COMPOSER_ALLOW_SUPERUSER=1
|
||||
ENV LOGVIEW_INSTALLATION_PATH=/app
|
||||
ENV APACHE_DOCUMENT_ROOT="${LOGVIEW_INSTALLATION_PATH}/app"
|
||||
ENV APACHE_PUBLIC_ROOT="${APACHE_DOCUMENT_ROOT}/public"
|
||||
|
||||
COPY --from=composer /usr/bin/composer /usr/bin/composer
|
||||
WORKDIR "${LOGVIEW_INSTALLATION_PATH}"
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -yq --no-install-recommends git zip unzip libzip-dev \
|
||||
&& rm -r /var/lib/apt/lists/* \
|
||||
&& git clone http://git.provm.cl/ProVM/logview.git "${LOGVIEW_INSTALLATION_PATH}" \
|
||||
&& docker-php-ext-install zip \
|
||||
&& cp "${LOGVIEW_INSTALLATION_PATH}/php-errors.ini" /usr/local/etc/php/conf.d/docker-php-errors.ini \
|
||||
&& composer -d "${LOGVIEW_INSTALLATION_PATH}/app" install \
|
||||
&& mkdir "${LOGVIEW_INSTALLATION_PATH}/app/cache" \
|
||||
&& chmod -R 777 "${LOGVIEW_INSTALLATION_PATH}/app/cache" \
|
||||
&& sed -ri -e "s!/var/www/html!${APACHE_PUBLIC_ROOT}!g" /etc/apache2/sites-available/*.conf \
|
||||
&& sed -ri -e "s!/var/www/!${APACHE_DOCUMENT_ROOT}!g" /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf \
|
||||
&& a2enmod rewrite \
|
||||
&& a2enmod actions \
|
||||
&& service apache2 restart
|
12
Pipfile
12
Pipfile
@ -1,12 +0,0 @@
|
||||
[[source]]
|
||||
name = "pypi"
|
||||
url = "https://pypi.org/simple"
|
||||
verify_ssl = true
|
||||
|
||||
[dev-packages]
|
||||
|
||||
[packages]
|
||||
gunicorn = "*"
|
||||
|
||||
[requires]
|
||||
python_version = "3.8"
|
9
Python.Dockerfile
Normal file
9
Python.Dockerfile
Normal file
@ -0,0 +1,9 @@
|
||||
FROM python:3.8
|
||||
|
||||
COPY ./bin /usr/opt/incoviba
|
||||
|
||||
WORKDIR /usr/opt/incoviba/informes
|
||||
|
||||
RUN pip install gunicorn pandas xlsxwriter httpx flask numpy
|
||||
|
||||
CMD ["gunicorn", "-w", "4", "--bind", "0.0.0.0", "app:app"]
|
15
adminer-compose.yml
Normal file
15
adminer-compose.yml
Normal file
@ -0,0 +1,15 @@
|
||||
services:
|
||||
adminer:
|
||||
profiles:
|
||||
- db
|
||||
container_name: incoviba_adminer
|
||||
image: adminer
|
||||
restart: unless-stopped
|
||||
env_file: ${APP_PATH:-.}/.adminer.env
|
||||
networks:
|
||||
- adminer_network
|
||||
ports:
|
||||
- "8083:8080"
|
||||
|
||||
networks:
|
||||
adminer_network: {}
|
11
aldarien/asset/.gitignore
vendored
11
aldarien/asset/.gitignore
vendored
@ -1,11 +0,0 @@
|
||||
composer.phar
|
||||
/vendor/
|
||||
|
||||
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
|
||||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
|
||||
# composer.lock
|
||||
|
||||
#Eclipse IDE
|
||||
.settings
|
||||
.buildpath
|
||||
.project
|
@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Aldarien
|
||||
|
||||
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.
|
@ -1,2 +0,0 @@
|
||||
# asset
|
||||
Asset manager module for my apps
|
@ -1,21 +0,0 @@
|
||||
<?php
|
||||
namespace App\Contract;
|
||||
|
||||
use App\Definition\Contract;
|
||||
use App\Service\Asset as AssetService;
|
||||
|
||||
class Asset
|
||||
{
|
||||
use Contract;
|
||||
|
||||
protected static function newInstance()
|
||||
{
|
||||
return new AssetService();
|
||||
}
|
||||
public static function get($identifier)
|
||||
{
|
||||
$instance = self::getInstance();
|
||||
return $instance->get($identifier);
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,5 +0,0 @@
|
||||
<?php
|
||||
function asset($identifier) {
|
||||
return \App\Contract\Asset::get($identifier);
|
||||
}
|
||||
?>
|
@ -1,88 +0,0 @@
|
||||
<?php
|
||||
namespace App\Service;
|
||||
|
||||
class Asset
|
||||
{
|
||||
protected $assets;
|
||||
protected $dir;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->dir = config('locations.public');
|
||||
}
|
||||
public function get($identifier)
|
||||
{
|
||||
$asset = $this->find($identifier);
|
||||
return $asset->url;
|
||||
}
|
||||
protected function find($identifier)
|
||||
{
|
||||
$type = $this->getType($identifier);
|
||||
$asset = null;
|
||||
if ($type == false) {
|
||||
foreach (array_keys($this->assets) as $type) {
|
||||
if (($asset = $this->getAsset($identifier, $type))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$asset = $this->getAsset($identifier, $type);
|
||||
}
|
||||
return $asset;
|
||||
}
|
||||
protected function getType($identifier)
|
||||
{
|
||||
if (strpos($identifier, '.') !== false) {
|
||||
list($name, $ext) = explode('.', $identifier);
|
||||
return $ext;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
protected function getAsset($identifier, $type)
|
||||
{
|
||||
if (!isset($this->assets[$type])) {
|
||||
$this->loadAssets($type);
|
||||
}
|
||||
if (!isset($this->assets[$type])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach ($this->assets[$type] as $asset) {
|
||||
if ($this->compareIdentifier($asset, $identifier)) {
|
||||
return $asset;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
protected function loadAssets($type)
|
||||
{
|
||||
$dir = $this->dir . '/' . $type . '/*.' . $type;
|
||||
$files = glob($dir);
|
||||
foreach ($files as $file) {
|
||||
$url = $this->url($file);
|
||||
$identifier = pathinfo($file)['filename'];
|
||||
|
||||
$this->assets[$type] []= (object) ['identifier' => $identifier, 'url' => $url, 'type' => $type];
|
||||
}
|
||||
}
|
||||
protected function url($file)
|
||||
{
|
||||
$url = '/' . config('app.project') . '/' . str_replace('\\', '/', str_replace(realpath(config('locations.public')), '', dirname(realpath($file)))) . '/' . basename(realpath($file));
|
||||
$url = preg_replace('/\/+/', '/', $url);
|
||||
return $url;
|
||||
}
|
||||
protected function compareIdentifier($asset, $identifier)
|
||||
{
|
||||
if (strpos($identifier, '.') !== false) {
|
||||
list($name, $ext) = explode('.', $identifier);
|
||||
if ($asset->identifier == $name and $asset->type == $ext) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if ($asset->identifier == $identifier) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
{
|
||||
"name" : "aldarien/asset",
|
||||
"description" : "Asset manager module for my apps",
|
||||
"type" : "library",
|
||||
"require" : {
|
||||
"aldarien/config" : "dev-master",
|
||||
"aldarien/contract" : "dev-master"
|
||||
},
|
||||
"require-dev" : {
|
||||
"phpunit/phpunit" : "^6.3"
|
||||
},
|
||||
"license" : "MIT",
|
||||
"authors" : [{
|
||||
"name" : "Aldarien",
|
||||
"email" : "aldarien85@gmail.com"
|
||||
}
|
||||
],
|
||||
"autoload" : {
|
||||
"psr-4" : {
|
||||
"App\\" : "app"
|
||||
},
|
||||
"files": [
|
||||
"app/Helper/functions.php"
|
||||
]
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit
|
||||
colors="true"
|
||||
verbose="true"
|
||||
bootstrap="./vendor/autoload.php"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Application Test Suite">
|
||||
<directory>./tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./app</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
@ -1,25 +0,0 @@
|
||||
<?php
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AssetTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
mkdir(root() . '/public');
|
||||
mkdir(root() . '/public/css');
|
||||
config('locations.public', root() . '/public');
|
||||
file_put_contents(root() . '/public/css/style.css', 'body {color: black;}');
|
||||
}
|
||||
public function tearDown()
|
||||
{
|
||||
unlink(root() . '/public/css/style.css');
|
||||
rmdir(root() . '/public/css');
|
||||
rmdir(root() . '/public');
|
||||
}
|
||||
|
||||
public function testAsset()
|
||||
{
|
||||
$this->assertEquals(asset('style.css'), '/css/style.css');
|
||||
}
|
||||
}
|
||||
?>
|
13
aldarien/config/.gitignore
vendored
13
aldarien/config/.gitignore
vendored
@ -1,13 +0,0 @@
|
||||
composer.phar
|
||||
/vendor/
|
||||
|
||||
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
|
||||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
|
||||
# composer.lock
|
||||
|
||||
config
|
||||
|
||||
# Eclipse IDE
|
||||
.settings
|
||||
.buildpath
|
||||
.project
|
@ -1,3 +0,0 @@
|
||||
language: php
|
||||
php: '7.1'
|
||||
install: composer update
|
@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Aldarien
|
||||
|
||||
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.
|
@ -1,4 +0,0 @@
|
||||
# config
|
||||
Config module that recovers configuration files
|
||||
|
||||
[](https://travis-ci.org/Aldarien/config)
|
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
namespace App\Contract;
|
||||
|
||||
use App\Definition\Contract;
|
||||
use App\Service\Config AS ConfigService;
|
||||
|
||||
class Config
|
||||
{
|
||||
use Contract;
|
||||
|
||||
protected static function newInstance()
|
||||
{
|
||||
return new ConfigService();
|
||||
}
|
||||
public static function get($name = null)
|
||||
{
|
||||
$instance = self::getInstance();
|
||||
return $instance->get($name);
|
||||
}
|
||||
public static function set($name, $value)
|
||||
{
|
||||
$instance = self::getInstance();
|
||||
return $instance->set($name, $value);
|
||||
}
|
||||
public static function addFile($filename)
|
||||
{
|
||||
$instance = self::getInstance();
|
||||
return $instance->loadFile($filename);
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,21 +0,0 @@
|
||||
<?php
|
||||
namespace App\Contract;
|
||||
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class YamlWrapper
|
||||
{
|
||||
public static function load($filename, $flags = 0)
|
||||
{
|
||||
return self::parse(file_get_contents($filename), $flags);
|
||||
}
|
||||
public static function parse($input, $flags = 0)
|
||||
{
|
||||
return Yaml::parse($input, $flags);
|
||||
}
|
||||
public static function dump($array, $inline = 2, $indent = 4, $flags = 0)
|
||||
{
|
||||
return Yaml::dump($array, $inline, $indent, $flags);
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,9 +0,0 @@
|
||||
<?php
|
||||
function config($name = null, $value = null) {
|
||||
if ($value == null) {
|
||||
return App\Contract\Config::get($name);
|
||||
} else {
|
||||
return App\Contract\Config::set($name, $value);
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,146 +0,0 @@
|
||||
<?php
|
||||
namespace App\Service;
|
||||
|
||||
use App\Contract\YamlWrapper;
|
||||
|
||||
class Config
|
||||
{
|
||||
protected $dir;
|
||||
protected $data;
|
||||
|
||||
public function __construct($dir = null)
|
||||
{
|
||||
if ($dir == null) {
|
||||
$dir = realpath(root() . '/config');
|
||||
}
|
||||
$this->dir = $dir;
|
||||
$this->load();
|
||||
}
|
||||
protected function load()
|
||||
{
|
||||
$files = glob($this->dir . '/*.{php,json,yml}', GLOB_BRACE);
|
||||
foreach ($files as $file) {
|
||||
$info = pathinfo($file);
|
||||
$name = $info['filename'];
|
||||
|
||||
$d = $this->getData($file);
|
||||
$data[$name] = $d;
|
||||
$data = array_merge($data, $this->translateArray($d, $name));
|
||||
foreach ($data as $key => $value) {
|
||||
$this->add($key, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
public function loadFile(string $filename)
|
||||
{
|
||||
if (!file_exists(realpath($filename))) {
|
||||
return false;
|
||||
}
|
||||
$info = pathinfo($filename);
|
||||
$name = $info['filename'];
|
||||
$d = $this->getData($filename);
|
||||
$data[$name] = $d;
|
||||
$data = array_merge($data, $this->translateArray($d, $name));
|
||||
foreach ($data as $key => $value) {
|
||||
$this->add($key, $value);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
protected function getData($filename)
|
||||
{
|
||||
$info = pathinfo($filename);
|
||||
|
||||
switch ($info['extension']) {
|
||||
case 'php':
|
||||
return include_once $filename;
|
||||
case 'json':
|
||||
return json_decode(file_get_contents($filename), true);
|
||||
case 'yml':
|
||||
return YamlWrapper::load($filename);
|
||||
default:
|
||||
throw new \DomainException('Invalid file extension for ' . $filename);
|
||||
}
|
||||
}
|
||||
protected function translateArray($array, $level)
|
||||
{
|
||||
$output = [];
|
||||
foreach ($array as $k1 => $l1) {
|
||||
$key = $level . '.' . $k1;
|
||||
if (is_array($l1)) {
|
||||
$output[$key] = $l1;
|
||||
$output = array_merge($output, $this->translateArray($l1, $key));
|
||||
} else {
|
||||
$output[$key] = $l1;
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
protected function add($field, $value)
|
||||
{
|
||||
if (isset($this->data[$field])) {
|
||||
if ($this->data[$field] == $value) {
|
||||
return;
|
||||
}
|
||||
if (is_array($this->data[$field])) {
|
||||
$this->data[$field] = $this->merge($this->data[$field], $this->replace($value));
|
||||
} else {
|
||||
$this->data[$field] = $this->replace($value);
|
||||
}
|
||||
} else {
|
||||
$this->data[$field] = $this->replace($value);
|
||||
}
|
||||
}
|
||||
protected function merge($arr1, $arr2)
|
||||
{
|
||||
$output = $arr1;
|
||||
foreach ($arr2 as $k => $value) {
|
||||
if (isset($arr1[$k])) {
|
||||
if ($arr1[$k] == $value) {
|
||||
continue;
|
||||
}
|
||||
if (is_array($arr1[$k])) {
|
||||
$output[$k] = $this->merge($arr1[$k], $value);
|
||||
} else {
|
||||
$output[$k] = array_merge([$arr1[$k]], $value);
|
||||
}
|
||||
} else {
|
||||
$output[$k] = $value;
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
protected function replace($value)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $k => $v) {
|
||||
$value[$k] = $this->replace($v);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
if (strpos($value, '{') !== false) {
|
||||
while(strpos($value, '{') !== false) {
|
||||
$ini = strpos($value, '{') + 1;
|
||||
$end = strpos($value, '}', $ini);
|
||||
$rep = substr($value, $ini, $end - $ini);
|
||||
$value = str_replace('{' . $rep . '}', $this->get($rep), $value);
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function get($name = null)
|
||||
{
|
||||
if ($name == null) {
|
||||
return $this->data;
|
||||
}
|
||||
if (isset($this->data[$name])) {
|
||||
return $this->data[$name];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public function set($name, $value)
|
||||
{
|
||||
$this->add($name, $value);
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,3 +0,0 @@
|
||||
<?php
|
||||
include_once dirname(__DIR__) . '/vendor/autoload.php';
|
||||
?>
|
@ -1,28 +0,0 @@
|
||||
{
|
||||
"name": "aldarien/config",
|
||||
"description": "Config module for my apps",
|
||||
"type": "library",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Aldarien",
|
||||
"email": "aldarien85@gmail.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"aldarien/contract": "dev-master",
|
||||
"aldarien/root": "dev-master",
|
||||
"symfony/yaml": "^3.3"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app"
|
||||
},
|
||||
"files": [
|
||||
"app/Helper/functions.php"
|
||||
]
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6.3"
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit
|
||||
colors="true"
|
||||
verbose="true"
|
||||
bootstrap="./bootstrap/autoload.php"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Application Test Suite">
|
||||
<directory>./tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./app</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
@ -1,90 +0,0 @@
|
||||
<?php
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Contract\YamlWrapper;
|
||||
|
||||
class ConfigTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
mkdir(dirname(__DIR__) . '/config');
|
||||
$str = "<?php return ['name' => 'Config', 'test_array' => ['data1' => 1, 'data2' => 2]]; ?>";
|
||||
file_put_contents(dirname(__DIR__) . '/config/app.php', $str);
|
||||
$data = ['name' => 'Config', 'test_array' => ['data1' => 1, 'data2' => 2]];
|
||||
file_put_contents(dirname(__DIR__) . '/config/json.json', json_encode($data));
|
||||
file_put_contents(dirname(__DIR__) . '/config/yaml.yml', YamlWrapper::dump($data));
|
||||
$data = ['last_name' => 'Config'];
|
||||
file_put_contents(dirname(__DIR__) . '/config/yaml.json', json_encode($data));
|
||||
}
|
||||
public function testGetNamePhp()
|
||||
{
|
||||
$name = 'Config';
|
||||
|
||||
$this->assertEquals($name, config('app.name'));
|
||||
}
|
||||
public function testGetNameJson()
|
||||
{
|
||||
$name = 'Config';
|
||||
|
||||
$this->assertEquals($name, config('json.name'));
|
||||
}
|
||||
public function testGetNameYaml()
|
||||
{
|
||||
$name = 'Config';
|
||||
|
||||
$this->assertEquals($name, config('yaml.name'));
|
||||
}
|
||||
public function testSetNamehp()
|
||||
{
|
||||
$new_name = 'Config_Test';
|
||||
config('app.name', $new_name);
|
||||
$this->assertEquals($new_name, config('app.name'));
|
||||
}
|
||||
public function testSetNameJson()
|
||||
{
|
||||
$new_name = 'Config_Test';
|
||||
config('json.name', $new_name);
|
||||
$this->assertEquals($new_name, config('json.name'));
|
||||
}
|
||||
public function testSetNameYaml()
|
||||
{
|
||||
$new_name = 'Config_Test';
|
||||
config('yaml.name', $new_name);
|
||||
$this->assertEquals($new_name, config('yaml.name'));
|
||||
}
|
||||
public function testArrayGetPhp()
|
||||
{
|
||||
$this->assertArrayHasKey('data1', config('app.test_array'));
|
||||
}
|
||||
public function testArrayGetJson()
|
||||
{
|
||||
$this->assertArrayHasKey('data1', config('json.test_array'));
|
||||
}
|
||||
public function testArrayGetYaml()
|
||||
{
|
||||
$this->assertArrayHasKey('data1', config('yaml.test_array'));
|
||||
}
|
||||
public function testSameSectionName()
|
||||
{
|
||||
$this->assertEquals('Config', config('yaml.last_name'));
|
||||
}
|
||||
public function testDuplicateValue()
|
||||
{
|
||||
config('json.name', 'Config2');
|
||||
$this->assertEquals('Config2', config('json.name'));
|
||||
}
|
||||
public function testAddFile()
|
||||
{
|
||||
$filename = dirname(__DIR__) . '/composer.json';
|
||||
App\Contract\Config::addFile($filename);
|
||||
$this->assertEquals('aldarien/config', config('composer.name'));
|
||||
}
|
||||
public function tearDown()
|
||||
{
|
||||
unlink(dirname(__DIR__) . '/config/app.php');
|
||||
unlink(dirname(__DIR__) . '/config/json.json');
|
||||
unlink(dirname(__DIR__) . '/config/yaml.yml');
|
||||
unlink(dirname(__DIR__) . '/config/yaml.json');
|
||||
rmdir(dirname(__DIR__) . '/config');
|
||||
}
|
||||
}
|
||||
?>
|
6
aldarien/contract/.gitignore
vendored
6
aldarien/contract/.gitignore
vendored
@ -1,6 +0,0 @@
|
||||
composer.phar
|
||||
/vendor/
|
||||
|
||||
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
|
||||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
|
||||
# composer.lock
|
@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Aldarien
|
||||
|
||||
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.
|
@ -1,20 +0,0 @@
|
||||
<?php
|
||||
namespace App\Definition;
|
||||
|
||||
trait Contract
|
||||
{
|
||||
protected static $instance = null;
|
||||
|
||||
private function __construct() {}
|
||||
|
||||
protected static function getInstance()
|
||||
{
|
||||
if (self::$instance == null) {
|
||||
self::$instance = static::newInstance();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
abstract protected static function newInstance();
|
||||
}
|
||||
?>
|
@ -1,18 +0,0 @@
|
||||
{
|
||||
"name": "aldarien/contract",
|
||||
"description": "Contract trait for my apps",
|
||||
"type": "library",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Aldarien",
|
||||
"email": "aldarien85@gmail.com"
|
||||
}
|
||||
],
|
||||
"require": {},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app"
|
||||
}
|
||||
}
|
||||
}
|
11
aldarien/format/.gitignore
vendored
11
aldarien/format/.gitignore
vendored
@ -1,11 +0,0 @@
|
||||
composer.phar
|
||||
/vendor/
|
||||
|
||||
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
|
||||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
|
||||
# composer.lock
|
||||
|
||||
# Eclipse IDE
|
||||
.settings
|
||||
.buildpath
|
||||
.project
|
@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Aldarien
|
||||
|
||||
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.
|
@ -1,2 +0,0 @@
|
||||
# format
|
||||
Module for formatting data, mostly numbers
|
@ -1,43 +0,0 @@
|
||||
<?php
|
||||
namespace App\Helper;
|
||||
|
||||
class Format
|
||||
{
|
||||
public static function number(float $number, $decimals)
|
||||
{
|
||||
return number_format($number, $decimals, ',', '.');
|
||||
}
|
||||
public static function pesos(float $number, bool $print = false)
|
||||
{
|
||||
return (($print) ? '$ ' : '') . self::number($number, 0);
|
||||
}
|
||||
public static function ufs(float $number, bool $print = false)
|
||||
{
|
||||
return self::number($number, 2) . (($print) ? ' UF' : '');
|
||||
}
|
||||
public static function date(string $date)
|
||||
{
|
||||
$d = \Carbon\Carbon::parse($date, config('app.timezone'));
|
||||
return $d->format("d \d\\e F Y");
|
||||
}
|
||||
public static function shortDate(string $date)
|
||||
{
|
||||
$d = \Carbon\Carbon::parse($date, config('app.timezone'));
|
||||
return $d->format('d-m-Y');
|
||||
}
|
||||
public static function localDate(string $date)
|
||||
{
|
||||
$d = \Carbon\Carbon::parse($date, config('app.timezone'));
|
||||
setlocale(LC_TIME, 'es');
|
||||
return $d->formatLocalized('%d de %B de %Y');
|
||||
}
|
||||
public static function m2(float $number, bool $print = false)
|
||||
{
|
||||
return self::number($number, 2) . (($print) ? ' m²' : '');
|
||||
}
|
||||
public static function percent(float $number, bool $print = false)
|
||||
{
|
||||
return self::number($number, 2) . (($print) ? '%' : '');
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,23 +0,0 @@
|
||||
{
|
||||
"name" : "aldarien/format",
|
||||
"description" : "Module for formatting data, mostly numbers",
|
||||
"type" : "library",
|
||||
"require-dev" : {
|
||||
"phpunit/phpunit" : "^6",
|
||||
"aldarien/config": "dev-master"
|
||||
},
|
||||
"license" : "MIT",
|
||||
"authors" : [{
|
||||
"name" : "Aldarien",
|
||||
"email" : "aldarien85@gmail.com"
|
||||
}
|
||||
],
|
||||
"autoload" : {
|
||||
"psr-4" : {
|
||||
"App\\" : "app"
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"nesbot/carbon": "^2"
|
||||
}
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
<?php
|
||||
return [
|
||||
'timezone' => 'America/Santiago'
|
||||
];
|
||||
?>
|
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit
|
||||
colors="true"
|
||||
verbose="true"
|
||||
bootstrap="./vendor/autoload.php"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Application Test Suite">
|
||||
<directory>./tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./app</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
@ -1,59 +0,0 @@
|
||||
<?php
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Helper\Format;
|
||||
|
||||
class FormatTest extends TestCase
|
||||
{
|
||||
protected $number = 5049872.31567;
|
||||
protected $date = '2016-03-25';
|
||||
|
||||
public function testFormat()
|
||||
{
|
||||
$output = '5.049.872,316';
|
||||
$result = Format::number($this->number, 3);
|
||||
$this->assertEquals($output, $result);
|
||||
}
|
||||
public function testPesosPrint()
|
||||
{
|
||||
$output = '$ 5.049.872';
|
||||
$result = Format::pesos($this->number, true);
|
||||
$this->assertEquals($output, $result);
|
||||
}
|
||||
public function testUFPrint()
|
||||
{
|
||||
$output = '5.049.872,32 UF';
|
||||
$result = Format::ufs($this->number, true);
|
||||
$this->assertEquals($output, $result);
|
||||
}
|
||||
public function testDate()
|
||||
{
|
||||
$output = '25 de March 2016';
|
||||
$result = Format::date($this->date);
|
||||
$this->assertEquals($output, $result);
|
||||
}
|
||||
public function testShortDate()
|
||||
{
|
||||
$output = '25-03-2016';
|
||||
$result = Format::shortDate($this->date);
|
||||
$this->assertEquals($output, $result);
|
||||
}
|
||||
public function testLocalDate()
|
||||
{
|
||||
$output = '25 de marzo de 2016';
|
||||
$result = Format::localDate($this->date);
|
||||
$this->assertEquals($output, $result);
|
||||
}
|
||||
public function testM2Print()
|
||||
{
|
||||
$output = '5.049.872,32 m²';
|
||||
$result = Format::m2($this->number, true);
|
||||
$this->assertEquals($output, $result);
|
||||
}
|
||||
public function testPercentPrint()
|
||||
{
|
||||
$output = '5.049.872,32%';
|
||||
$result = Format::percent($this->number, true);
|
||||
$this->assertEquals($output, $result);
|
||||
}
|
||||
}
|
||||
?>
|
7
aldarien/response/.gitignore
vendored
7
aldarien/response/.gitignore
vendored
@ -1,7 +0,0 @@
|
||||
#Eclipse IDE
|
||||
.settings
|
||||
.buildpath
|
||||
.project
|
||||
|
||||
#Composer
|
||||
vendor
|
@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Aldarien
|
||||
|
||||
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.
|
@ -1,2 +0,0 @@
|
||||
# response
|
||||
Response handler module for my apps
|
@ -1,27 +0,0 @@
|
||||
<?php
|
||||
namespace App\Contract;
|
||||
|
||||
use App\Definition\Contract;
|
||||
use App\Service\Response as ResponseService;
|
||||
|
||||
class Response
|
||||
{
|
||||
use Contract;
|
||||
|
||||
protected static function newInstance()
|
||||
{
|
||||
return new ResponseService();
|
||||
}
|
||||
public static function __callStatic($name, $params)
|
||||
{
|
||||
if (!method_exists(Response::class, $name)) {
|
||||
$instance = self::getInstance();
|
||||
if (method_exists($instance, $name)) {
|
||||
return call_user_func_array([$instance, $name], $params);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return call_user_func_array([self, $name], $params);
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
function sanitize() {
|
||||
App\Contract\Response::sanitize();
|
||||
}
|
||||
function get($query = null) {
|
||||
return App\Contract\Response::get($query);
|
||||
}
|
||||
function post($query = null) {
|
||||
return App\Contract\Response::post($query);
|
||||
}
|
||||
?>
|
@ -1,62 +0,0 @@
|
||||
<?php
|
||||
namespace App\Service;
|
||||
|
||||
class Response
|
||||
{
|
||||
protected $post;
|
||||
protected $get;
|
||||
protected $gump;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->gump = new \GUMP();
|
||||
}
|
||||
public function sanitize()
|
||||
{
|
||||
if ($_POST) {
|
||||
$this->post = $this->correctNumbers($this->gump->sanitize($_POST));
|
||||
}
|
||||
if ($_GET) {
|
||||
$this->get = $this->correctNumbers($this->gump->sanitize($_GET));
|
||||
}
|
||||
}
|
||||
public function correctNumbers(array $data)
|
||||
{
|
||||
$output = [];
|
||||
foreach ($data as $key => $value) {
|
||||
if (is_float(str_replace(',', '.', $value))) {
|
||||
$output[$key] = str_replace(',', '.', $value);
|
||||
} else {
|
||||
$output[$key] = $value;
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
public function get($query = null)
|
||||
{
|
||||
if ($this->get == null) {
|
||||
$this->sanitize();
|
||||
}
|
||||
if ($query == null) {
|
||||
return $this->get;
|
||||
}
|
||||
if (isset($this->get[$query])) {
|
||||
return $this->get[$query];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public function post($query = null)
|
||||
{
|
||||
if ($this->post == null) {
|
||||
$this->sanitize();
|
||||
}
|
||||
if ($query == null) {
|
||||
return $this->post;
|
||||
}
|
||||
if (isset($this->post[$query])) {
|
||||
return $this->post[$query];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,3 +0,0 @@
|
||||
<?php
|
||||
include_once dirname(__DIR__) . '/vendor/autoload.php';
|
||||
?>
|
@ -1,26 +0,0 @@
|
||||
{
|
||||
"name" : "aldarien/response",
|
||||
"description" : "Response handler module for my apps",
|
||||
"type" : "library",
|
||||
"require" : {
|
||||
"wixel/gump" : "^1.5",
|
||||
"aldarien/contract" : "dev-master"
|
||||
},
|
||||
"require-dev" : {
|
||||
"phpunit/phpunit" : "^6.3"
|
||||
},
|
||||
"license" : "MIT",
|
||||
"authors" : [{
|
||||
"name" : "Aldarien",
|
||||
"email" : "jpvial@gmail.com"
|
||||
}
|
||||
],
|
||||
"autoload" : {
|
||||
"psr-4" : {
|
||||
"App\\" : "app"
|
||||
},
|
||||
"files": [
|
||||
"app/Helper/functions.php"
|
||||
]
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit
|
||||
colors="true"
|
||||
verbose="true"
|
||||
bootstrap="./bootstrap/autoload.php"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Application Test Suite">
|
||||
<directory>./tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./app</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
@ -1,22 +0,0 @@
|
||||
<?php
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ResponseTest extends TestCase
|
||||
{
|
||||
protected $value = 'Test';
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$_GET['test'] = $this->value;
|
||||
$_POST['test'] = $this->value;
|
||||
}
|
||||
public function testGet()
|
||||
{
|
||||
$this->assertEquals($this->value, get('test'));
|
||||
}
|
||||
public function testPost()
|
||||
{
|
||||
$this->assertEquals($this->value, post('test'));
|
||||
}
|
||||
}
|
||||
?>
|
5
aldarien/root/.gitignore
vendored
5
aldarien/root/.gitignore
vendored
@ -1,5 +0,0 @@
|
||||
.buildpath
|
||||
.project
|
||||
.settings
|
||||
*.lock
|
||||
vendor
|
@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Aldarien
|
||||
|
||||
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.
|
@ -1,22 +0,0 @@
|
||||
# root
|
||||
get root directory path for your project
|
||||
|
||||
## Usage
|
||||
|
||||
add `Root::root('project')` or `root('project')` or `Root::root()` or `root()` where you need the root directory of your proyect.
|
||||
|
||||
## Example
|
||||
|
||||
For the structure:
|
||||
|
||||
~~~
|
||||
/usr/share/www/projects
|
||||
- myProject
|
||||
-- src
|
||||
-- tests
|
||||
~~~
|
||||
|
||||
using `Root::root('myProject')`
|
||||
|
||||
outputs:
|
||||
`/usr/share/www/projects/myProject`
|
@ -1,5 +0,0 @@
|
||||
<?php
|
||||
function root(string $proyect_name = '') {
|
||||
return \Proyect\Root\Root::root($proyect_name);
|
||||
}
|
||||
?>
|
@ -1,21 +0,0 @@
|
||||
{
|
||||
"name" : "aldarien/root",
|
||||
"description" : "Find the root path for your proyect",
|
||||
"authors" : [{
|
||||
"name" : "Aldarien"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"require-dev" : {
|
||||
"phpunit/phpunit" : "~6",
|
||||
"kint-php/kint" : "~2"
|
||||
},
|
||||
"autoload" : {
|
||||
"psr-4" : {
|
||||
"Proyect\\Root\\" : "src"
|
||||
},
|
||||
"files": [
|
||||
"app/Helper/functions.php"
|
||||
]
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.2/phpunit.xsd"
|
||||
bootstrap="vendor/autoload.php"
|
||||
forceCoversAnnotation="true"
|
||||
beStrictAboutCoversAnnotation="true"
|
||||
beStrictAboutOutputDuringTests="true"
|
||||
beStrictAboutTodoAnnotatedTests="true"
|
||||
verbose="true">
|
||||
<testsuite>
|
||||
<directory suffix="Test.php">tests</directory>
|
||||
</testsuite>
|
||||
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
@ -1,48 +0,0 @@
|
||||
<?php
|
||||
namespace Proyect\Root;
|
||||
|
||||
class Root
|
||||
{
|
||||
/**
|
||||
* gives base path for your proyect.
|
||||
* eg. <code>$proyect_name/public/index.php</code> calls for <code>$proyect_name/bootstrap/autoload.php</code>,
|
||||
* you just need to
|
||||
*
|
||||
* <code>include root() . '/bootstrap/autoload.php'</code>
|
||||
*
|
||||
* @param string $proyect_name
|
||||
* @return string
|
||||
*/
|
||||
public static function root(string $proyect_name = '')
|
||||
{
|
||||
$dir = realpath(__DIR__);
|
||||
if ($proyect_name == '') {
|
||||
return self::findComposerFile($dir);
|
||||
} else {
|
||||
$ini = strpos($dir, $proyect_name) + strlen($proyect_name);
|
||||
}
|
||||
$path = substr($dir, $ini);
|
||||
$cnt = substr_count($path, DIRECTORY_SEPARATOR);
|
||||
$root = DIRECTORY_SEPARATOR;
|
||||
for ($i = 0; $i < $cnt; $i ++) {
|
||||
$root .= '..' . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
return realpath($dir . $root);
|
||||
}
|
||||
protected static function findComposerFile($dir)
|
||||
{
|
||||
if (file_exists($dir . '/vendor/')) {
|
||||
return $dir;
|
||||
}
|
||||
|
||||
$root = realpath('/');
|
||||
if (realpath($dir) == $root) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$dir = dirname($dir);
|
||||
return self::findComposerFile($dir);
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,61 +0,0 @@
|
||||
<?php
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Proyect\Root\Root;
|
||||
|
||||
class RootTest extends TestCase
|
||||
{
|
||||
private $proyect_name = 'root';
|
||||
private $current_dir;
|
||||
|
||||
public function testBaseRoot()
|
||||
{
|
||||
$this->getCurrentDir();
|
||||
$this->assertEquals($this->getRoot(), $this->current_dir);
|
||||
$this->assertEquals($this->getBaseRoot(), $this->current_dir);
|
||||
}
|
||||
public function testBaseRootFunction()
|
||||
{
|
||||
$this->getCurrentDir();
|
||||
$this->assertEquals($this->getFRoot(), $this->current_dir);
|
||||
$this->assertEquals($this->getFBaseRoot(), $this->current_dir);
|
||||
}
|
||||
public function testSrcRoot()
|
||||
{
|
||||
$this->changeDir('src');
|
||||
$this->assertEquals(realpath($this->getRoot() . '/src'), $this->current_dir);
|
||||
$this->assertEquals(realpath($this->getBaseRoot() . '/src'), $this->current_dir);
|
||||
}
|
||||
public function testSrcRootFunction()
|
||||
{
|
||||
$this->changeDir('src');
|
||||
$this->assertEquals(realpath($this->getFRoot() . '/src'), $this->current_dir);
|
||||
$this->assertEquals(realpath($this->getFBaseRoot() . '/src'), $this->current_dir);
|
||||
}
|
||||
|
||||
private function getCurrentDir()
|
||||
{
|
||||
$this->current_dir = getcwd();
|
||||
}
|
||||
private function changeDir($dir)
|
||||
{
|
||||
chdir($dir);
|
||||
$this->getCurrentDir();
|
||||
}
|
||||
private function getRoot()
|
||||
{
|
||||
return Root::root($this->proyect_name);
|
||||
}
|
||||
private function getBaseRoot()
|
||||
{
|
||||
return Root::root();
|
||||
}
|
||||
private function getFRoot()
|
||||
{
|
||||
return root($this->proyect_name);
|
||||
}
|
||||
private function getFBaseRoot()
|
||||
{
|
||||
return root();
|
||||
}
|
||||
}
|
||||
?>
|
11
aldarien/session/.gitignore
vendored
11
aldarien/session/.gitignore
vendored
@ -1,11 +0,0 @@
|
||||
composer.phar
|
||||
/vendor/
|
||||
|
||||
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
|
||||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
|
||||
# composer.lock
|
||||
|
||||
# Eclipse IDE
|
||||
.settings
|
||||
.buildpath
|
||||
.project
|
@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Aldarien
|
||||
|
||||
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.
|
@ -1,2 +0,0 @@
|
||||
# session
|
||||
Session wrapper for aura/session
|
@ -1,29 +0,0 @@
|
||||
<?php
|
||||
namespace App\Contract;
|
||||
|
||||
use Aura\Session\SessionFactory;
|
||||
use App\Definition\Contract;
|
||||
|
||||
class Session
|
||||
{
|
||||
use Contract;
|
||||
|
||||
protected static function newInstance()
|
||||
{
|
||||
$session_factory = new SessionFactory();
|
||||
return $session_factory->newInstance($_COOKIE);
|
||||
}
|
||||
public static function get($segment, $name)
|
||||
{
|
||||
$instance = self::getInstance();
|
||||
$segment = $instance->getSegment($segment);
|
||||
return $segment->get($name);
|
||||
}
|
||||
public static function set($segment, $name, $value)
|
||||
{
|
||||
$instance = self::getInstance();
|
||||
$segment = $instance->getSegment($segment);
|
||||
$segment->set($name, $value);
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,24 +0,0 @@
|
||||
{
|
||||
"name": "aldarien/session",
|
||||
"description": "Session wrapper for aura/session",
|
||||
"type": "library",
|
||||
"require": {
|
||||
"aura/session": "^2.1",
|
||||
"aldarien/contract": "dev-master"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6.3"
|
||||
},
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Aldarien",
|
||||
"email": "aldarien85@gmail.com"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app"
|
||||
}
|
||||
}
|
||||
}
|
12
aldarien/url/.gitignore
vendored
12
aldarien/url/.gitignore
vendored
@ -1,12 +0,0 @@
|
||||
composer.phar
|
||||
/vendor/
|
||||
|
||||
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
|
||||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
|
||||
# composer.lock
|
||||
|
||||
.settings
|
||||
.buildpath
|
||||
.project
|
||||
|
||||
# Eclipse IDE
|
@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Aldarien
|
||||
|
||||
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.
|
@ -1,2 +0,0 @@
|
||||
# url
|
||||
Get relative path url
|
@ -1,21 +0,0 @@
|
||||
<?php
|
||||
namespace App\Contract;
|
||||
|
||||
use App\Definition\Contract;
|
||||
use App\Service\URL as URLService;
|
||||
|
||||
class URL
|
||||
{
|
||||
use Contract;
|
||||
|
||||
protected static function newInstance()
|
||||
{
|
||||
return new URLService();
|
||||
}
|
||||
public static function url($path = '', $variables = null)
|
||||
{
|
||||
$instance = self::getInstance();
|
||||
return $instance->url($path, $variables);
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
function url($path = '', $variables = null) {
|
||||
return App\Contract\URL::url($path, $variables);
|
||||
}
|
||||
function baseUrl() {
|
||||
return url();
|
||||
}
|
||||
?>
|
@ -1,76 +0,0 @@
|
||||
<?php
|
||||
namespace App\Service;
|
||||
|
||||
use League\Uri\Http;
|
||||
use League\Uri\Components\Host;
|
||||
use League\Uri\Components\HierarchicalPath;
|
||||
|
||||
class URL
|
||||
{
|
||||
protected $root;
|
||||
protected $relative;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->root = $this->findRoot();
|
||||
$this->relative = $this->findRelative();
|
||||
}
|
||||
|
||||
protected function findRoot()
|
||||
{
|
||||
$base = $_SERVER['HTTP_HOST'] . ((isset($_SERVER['HTTP_PORT'])) ? ':' . $_SERVER['HTTP_PORT'] : '');
|
||||
$uri = Http::createFromString(\Sabre\Uri\resolve($_SERVER['REQUEST_SCHEME'] . '://' . $base, $_SERVER['SCRIPT_NAME']));
|
||||
$host = new Host($uri->getHost());
|
||||
if ($host->isAbsolute()) {
|
||||
return $host->getRegistrableDomain();
|
||||
}
|
||||
$base = $host . (($uri->getPort()) ? ':' . $uri->getPort() : '');
|
||||
return ($uri->getScheme() ?: 'http') . '://' . $base;
|
||||
}
|
||||
protected function findRelative()
|
||||
{
|
||||
$uri = Http::createFromString($_SERVER['SCRIPT_NAME']);
|
||||
$normalized = (new HierarchicalPath($uri->getPath()))->withoutLeadingSlash()->withoutTrailingSlash()->withoutDotSegments()->withoutEmptySegments();
|
||||
if ($normalized->getDirname() == '.') {
|
||||
return '';
|
||||
}
|
||||
return $normalized->getDirname();
|
||||
}
|
||||
|
||||
|
||||
public function url($path = '', $variables = null)
|
||||
{
|
||||
$uri = Http::createFromString($path);
|
||||
if ($uri->getHost() != $this->root and $uri->getHost() != '') {
|
||||
return $path;
|
||||
}
|
||||
|
||||
$uri = \Sabre\Uri\resolve($this->getBaseUrl(), $path);
|
||||
try {
|
||||
$host = new Host(Http::createFromString($uri)->getHost());
|
||||
} catch (\League\Uri\Exception $e) {
|
||||
$uri = \Sabre\Uri\resolve($this->getBaseUrl(), '../../') . '/' . basename($path);
|
||||
$host = new Host(Http::createFromString($uri)->getHost());
|
||||
}
|
||||
|
||||
$base = new Host(Http::createFromString($this->root)->getHost());
|
||||
if ($host . '' != $base . '') {
|
||||
$host = new Host(Http::createFromString($this->root)->getHost());
|
||||
$page = str_replace($this->root, '', $uri);
|
||||
$uri = \Sabre\Uri\resolve(Http::createFromString($this->root)->getScheme() . '://' . $host->getRegistrableDomain(). '/', $page);
|
||||
}
|
||||
|
||||
if ($variables != null) {
|
||||
$uri = \Sabre\Uri\resolve($uri, '?' . http_build_query($variables));
|
||||
}
|
||||
$uri = \Sabre\Uri\normalize($uri);
|
||||
|
||||
return $uri;
|
||||
}
|
||||
protected function getBaseUrl()
|
||||
{
|
||||
$url = \Sabre\Uri\normalize(trim($this->root . '/' . $this->relative, '/') . '/');
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,28 +0,0 @@
|
||||
{
|
||||
"name" : "aldarien/url",
|
||||
"description" : "Get relative path uri",
|
||||
"type" : "library",
|
||||
"require" : {
|
||||
"aldarien/contract" : "dev-master",
|
||||
"aldarien/root" : "dev-master",
|
||||
"league/uri": "^5.2",
|
||||
"sabre/uri": "^2.1"
|
||||
},
|
||||
"require-dev" : {
|
||||
"phpunit/phpunit" : "^6.3"
|
||||
},
|
||||
"license" : "MIT",
|
||||
"authors" : [{
|
||||
"name" : "Aldarien",
|
||||
"email" : "jpvial@gmail.com"
|
||||
}
|
||||
],
|
||||
"autoload" : {
|
||||
"psr-4" : {
|
||||
"App\\" : "app"
|
||||
},
|
||||
"files": [
|
||||
"app/Helper/functions.php"
|
||||
]
|
||||
}
|
||||
}
|
10
aldarien/view/.gitignore
vendored
10
aldarien/view/.gitignore
vendored
@ -1,10 +0,0 @@
|
||||
composer.phar
|
||||
/vendor/
|
||||
|
||||
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
|
||||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
|
||||
# composer.lock
|
||||
|
||||
.settings
|
||||
.buildpath
|
||||
.project
|
@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Aldarien
|
||||
|
||||
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.
|
@ -1,2 +0,0 @@
|
||||
# view
|
||||
View module for my apps
|
@ -1,21 +0,0 @@
|
||||
<?php
|
||||
namespace App\Contract;
|
||||
|
||||
use App\Definition\Contract;
|
||||
use App\Service\View as ViewService;
|
||||
|
||||
class View
|
||||
{
|
||||
use Contract;
|
||||
|
||||
protected static function newInstance()
|
||||
{
|
||||
return new ViewService();
|
||||
}
|
||||
public static function show($template, $variables = null)
|
||||
{
|
||||
$instance = self::getInstance();
|
||||
return $instance->show($template, $variables);
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,5 +0,0 @@
|
||||
<?php
|
||||
function view($template, $variables = null) {
|
||||
return \App\Contract\View::show($template, $variables);
|
||||
}
|
||||
?>
|
@ -1,27 +0,0 @@
|
||||
<?php
|
||||
namespace App\Service;
|
||||
|
||||
use Philo\Blade\Blade;
|
||||
|
||||
class View
|
||||
{
|
||||
protected $views;
|
||||
protected $cache;
|
||||
protected $blade;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->views = config('locations.views');
|
||||
$this->cache = config('locations.cache');
|
||||
|
||||
$this->blade = new Blade($this->views, $this->cache);
|
||||
}
|
||||
public function show($template, $vars = null)
|
||||
{
|
||||
if ($vars) {
|
||||
return $this->blade->view()->make($template, $vars)->render();
|
||||
}
|
||||
return $this->blade->view()->make($template)->render();
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,9 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>View</title>
|
||||
</head>
|
||||
<body>
|
||||
View test
|
||||
</body>
|
||||
</html>
|
@ -1,28 +0,0 @@
|
||||
{
|
||||
"name": "aldarien/view",
|
||||
"description": "View module for my apps",
|
||||
"type": "library",
|
||||
"require": {
|
||||
"philo/laravel-blade": "^3.1",
|
||||
"aldarien/contract": "dev-master",
|
||||
"aldarien/config": "dev-master"
|
||||
},
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Aldarien",
|
||||
"email": "aldarien85@gmail.com"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app"
|
||||
},
|
||||
"files": [
|
||||
"app/Helper/functions.php"
|
||||
]
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6.3"
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
return [
|
||||
'base' => root(),
|
||||
'cache' => '{locations.base}/cache',
|
||||
'resources' => '{locations.base}/resources',
|
||||
'views' => '{locations.resources}/views'
|
||||
];
|
||||
?>
|
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit
|
||||
colors="true"
|
||||
verbose="true"
|
||||
bootstrap="./vendor/autoload.php"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Application Test Suite">
|
||||
<directory>./tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./app</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
@ -1,5 +0,0 @@
|
||||
<?php
|
||||
include_once dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
echo view('base');
|
||||
?>
|
@ -1,9 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>View</title>
|
||||
</head>
|
||||
<body>
|
||||
View test
|
||||
</body>
|
||||
</html>
|
@ -1,22 +0,0 @@
|
||||
<?php
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ViewTest extends TestCase
|
||||
{
|
||||
public function testView()
|
||||
{
|
||||
$output = <<<DATA
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>View</title>
|
||||
</head>
|
||||
<body>
|
||||
View test
|
||||
</body>
|
||||
</html>
|
||||
DATA;
|
||||
$this->assertEquals($output, view('base'));
|
||||
}
|
||||
}
|
||||
?>
|
9
api.compose.yml
Normal file
9
api.compose.yml
Normal file
@ -0,0 +1,9 @@
|
||||
services:
|
||||
httpclient:
|
||||
profiles:
|
||||
- testing
|
||||
container_name: incoviba_client
|
||||
image: flawiddsouza/restfox
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "${HTTPCLIENT_PORT:-4004}:4004"
|
1
app/.adminer.env.sample
Normal file
1
app/.adminer.env.sample
Normal file
@ -0,0 +1 @@
|
||||
ADMINER_DESIGN=dracula
|
4
app/.db.env.sample
Normal file
4
app/.db.env.sample
Normal file
@ -0,0 +1,4 @@
|
||||
MYSQL_ROOT_PASSWORD=
|
||||
MYSQL_DATABASE=
|
||||
MYSQL_USER=
|
||||
MYSQL_PASSWORD=
|
19
app/.env.sample
Normal file
19
app/.env.sample
Normal file
@ -0,0 +1,19 @@
|
||||
#ENVIRONMENT=
|
||||
|
||||
APP_URL=
|
||||
|
||||
COOKIE_NAME=
|
||||
COOKIE_DOMAIN=
|
||||
COOKIE_PATH=/
|
||||
MAX_LOGIN_HOURS=120
|
||||
|
||||
#REDIS_HOST=redis
|
||||
#REDIS_PORT=6379
|
||||
|
||||
DB_HOST=db
|
||||
DB_DATABASE=incoviba
|
||||
DB_USER=incoviba
|
||||
DB_PASSWORD=
|
||||
|
||||
TOKU_URL=
|
||||
TOKU_TOKEN=
|
2
app/.gitignore
vendored
Normal file
2
app/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
**/bin
|
||||
**/public/tests
|
14
app/.phpunit-watcher.yml
Normal file
14
app/.phpunit-watcher.yml
Normal file
@ -0,0 +1,14 @@
|
||||
watch:
|
||||
directories:
|
||||
- src
|
||||
- tests
|
||||
- common
|
||||
- resources
|
||||
fileMask: '*.php'
|
||||
notifications:
|
||||
passingTests: false
|
||||
failingTests: false
|
||||
hideManual: true
|
||||
phpunit:
|
||||
arguments: '--testsuite unit --log-events-text /logs/output.txt --stop-on-failure'
|
||||
timeout: 180
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
namespace App\Alias\Excel\Style;
|
||||
|
||||
use Slam\Excel\Helper\CellStyleInterface;
|
||||
use Slam\Excel\Pear\Writer\Format;
|
||||
|
||||
class Mes implements CellStyleInterface
|
||||
{
|
||||
public function decorateValue($value)
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
public function styleCell(Format $format): void
|
||||
{
|
||||
$format->setNumFormat('mmm-YY');
|
||||
$format->setAlign('center');
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
<?php
|
||||
use App\Helper\Format as F;
|
||||
class Format
|
||||
{
|
||||
public static function __callstatic($name, $params)
|
||||
{
|
||||
if (method_exists(F, $name)) {
|
||||
return F::$name($params);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,87 +0,0 @@
|
||||
<?php
|
||||
namespace App\Alias;
|
||||
|
||||
use Stringy\Stringy;
|
||||
use App\Contract\Auth;
|
||||
|
||||
class Model extends \Model
|
||||
{
|
||||
public function getTable()
|
||||
{
|
||||
return parent::_get_table_name(static::class);
|
||||
}
|
||||
protected function log()
|
||||
{
|
||||
if (strpos(get_called_class(), 'Incoviba\\common\\') !== false) {
|
||||
return;
|
||||
}
|
||||
$user = Auth::User()->id;
|
||||
$orm = $this->orm;
|
||||
$ref = new \ReflectionObject($orm);
|
||||
if (!$ref->hasProperty('_dirty_fields')) {
|
||||
return;
|
||||
}
|
||||
$dirty = $ref->getProperty('_dirty_fields');
|
||||
$dirty->setAccessible(true);
|
||||
$new_values = $dirty->getValue($orm);
|
||||
$changes = array_combine(array_keys($new_values), array_fill(0, count($new_values), ['old' => '', 'new' => '']));
|
||||
if ($this->isNew()) {
|
||||
$old = (object) array_combine(array_keys($new_values), array_fill(0, count($new_values), ''));
|
||||
} else {
|
||||
$old = model(get_called_class())->findOne($this->{$this->getId()});
|
||||
}
|
||||
foreach ($new_values as $column => $value) {
|
||||
$changes[$column] = ['column' => $column, 'old' => $old->$column, 'new' => $value];
|
||||
}
|
||||
$action = '[' . get_called_class() . ']';
|
||||
doLog($user, $action, $changes);
|
||||
}
|
||||
public function getId()
|
||||
{
|
||||
if (property_exists(get_called_class(), '_id_column')) {
|
||||
return static::$_id_column;
|
||||
}
|
||||
return $this->id;
|
||||
}
|
||||
public function save()
|
||||
{
|
||||
$ref = new \ReflectionObject($this);
|
||||
if ($ref->hasProperty('_timestamps')) {
|
||||
$ref = $ref->getProperty('_timestamps');
|
||||
$ref->setAccessible(true);
|
||||
if ($ref->getValue()) {
|
||||
if ($this->is_new()) {
|
||||
$this->setExpr('created_at', 'NOW()');
|
||||
}
|
||||
$this->setExpr('updated_at', 'NOW()');
|
||||
}
|
||||
}
|
||||
if (!\ORM::getDb()->inTransaction()) {
|
||||
\ORM::getDb()->beginTransaction();
|
||||
}
|
||||
try {
|
||||
parent::save();
|
||||
if (\ORM::getDb()->inTransaction()) {
|
||||
\ORM::getDb()->commit();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
if (\ORM::getDb()->inTransaction()) {
|
||||
\ORM::getDb()->rollBack();
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
$this->log();
|
||||
}
|
||||
public function __call($method, $args)
|
||||
{
|
||||
if (!method_exists($this, $method)) {
|
||||
$str = '' . Stringy::create($method)->underscored();
|
||||
if (method_exists($this, $str)) {
|
||||
return call_user_func_array([$this, $str], $args);
|
||||
}
|
||||
throw new \BadMethodCallException($method . ' not found in ' . get_class($this));
|
||||
}
|
||||
return call_user_func_array([$this, $str], $args);
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,20 +0,0 @@
|
||||
<?php
|
||||
namespace App\Alias;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property Date fecha
|
||||
*
|
||||
*/
|
||||
class NewEstado extends NewModel
|
||||
{
|
||||
public function fecha()
|
||||
{
|
||||
return Carbon::parse($this->fecha, config('app.timezone'));
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,9 +0,0 @@
|
||||
<?php
|
||||
namespace App\Alias;
|
||||
|
||||
class NewModel extends Model
|
||||
{
|
||||
protected static $_connection_name = 'mysql_copy';
|
||||
protected static $_timestamps = true;
|
||||
}
|
||||
?>
|
@ -1,15 +0,0 @@
|
||||
<?php
|
||||
namespace App\Alias;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property string descripcion
|
||||
*
|
||||
*/
|
||||
class NewTipo extends NewModel
|
||||
{
|
||||
protected static $_timestamps = true;
|
||||
}
|
||||
?>
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
namespace App\Alias;
|
||||
|
||||
class OldModel extends Model
|
||||
{
|
||||
protected static $_connection_name = 'mysql';
|
||||
}
|
||||
?>
|
@ -1,155 +0,0 @@
|
||||
<?php
|
||||
namespace App\Alias;
|
||||
|
||||
use Slam\Excel\Helper as ExcelHelper;
|
||||
|
||||
class PHPExcel
|
||||
{
|
||||
protected $name;
|
||||
protected $filename;
|
||||
protected $columns;
|
||||
protected $data;
|
||||
|
||||
public function __construct($name, $filename)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->filename = $filename;
|
||||
}
|
||||
public function addColumns($fields)
|
||||
{
|
||||
$columns = [];
|
||||
foreach ($fields as $i => $field) {
|
||||
if (is_object($field)) {
|
||||
if (isset($field->style)) {
|
||||
$style = $this->getExcelStyle($field->style);
|
||||
} else {
|
||||
$style = $this->getExcelStyle();
|
||||
}
|
||||
$column = new ExcelHelper\Column($field->name, $field->name, 10, $style);
|
||||
} elseif (is_array($field)) {
|
||||
if (isset($field['style'])) {
|
||||
$style = $this->getExcelStyle($field['style']);
|
||||
} else {
|
||||
$style = $this->getExcelStyle();
|
||||
}
|
||||
$column = new ExcelHelper\Column($field['name'], $field['name'], 10, $style);
|
||||
} else {
|
||||
$style = $this->getExcelStyle();
|
||||
$column = new ExcelHelper\Column($field, $field, 10, $style);
|
||||
}
|
||||
$columns []= $column;
|
||||
}
|
||||
$collection = new ExcelHelper\ColumnCollection($columns);
|
||||
$this->columns = $collection;
|
||||
}
|
||||
protected function getExcelStyle($style = 'text')
|
||||
{
|
||||
switch (strtolower($style)) {
|
||||
case 'date':
|
||||
return new ExcelHelper\CellStyle\Date();
|
||||
case 'mes':
|
||||
return new Excel\Style\Mes();
|
||||
case 'currency':
|
||||
case 'amount':
|
||||
return new ExcelHelper\CellStyle\Amount();
|
||||
case 'number':
|
||||
case 'integer':
|
||||
return new ExcelHelper\CellStyle\Integer();
|
||||
case 'percent':
|
||||
case 'percentage':
|
||||
return new ExcelHelper\CellStyle\Percentage();
|
||||
case 'text':
|
||||
case 'string':
|
||||
default:
|
||||
return new ExcelHelper\CellStyle\Text();
|
||||
}
|
||||
}
|
||||
public function addData($data)
|
||||
{
|
||||
if ($this->data == null) {
|
||||
$this->data = [];
|
||||
}
|
||||
$this->data = array_merge($data);
|
||||
}
|
||||
public function addRow($rowData)
|
||||
{
|
||||
if ($this->data == null) {
|
||||
$this->data = [];
|
||||
}
|
||||
$this->data []= $rowData;
|
||||
}
|
||||
public function addTotals($totals)
|
||||
{
|
||||
$columns = (array) $this->columns;
|
||||
$columns = array_pop($columns);
|
||||
$ts = [];
|
||||
foreach ($columns as $column) {
|
||||
$col = $column->getHeading();
|
||||
if (isset($totals[$col])) {
|
||||
$ts[$col] = $this->getTotal($col, $totals[$col]);
|
||||
continue;
|
||||
}
|
||||
$ts[$col] = '';
|
||||
}
|
||||
$this->data []= $ts;
|
||||
}
|
||||
protected function getTotal($col, $aggr)
|
||||
{
|
||||
$col_num = $this->getColNumber($col);
|
||||
$col = $this->getColName($col_num);
|
||||
switch(strtolower($aggr)) {
|
||||
case 'sum':
|
||||
$num = 109;
|
||||
break;
|
||||
case 'count':
|
||||
$num = 102;
|
||||
break;
|
||||
case 'counta':
|
||||
$num = 103;
|
||||
break;
|
||||
default:
|
||||
$num = 0;
|
||||
}
|
||||
if ($num > 0) {
|
||||
$end = count($this->data) + 2;
|
||||
$str = "=SUBTOTAL({$num};{$col}3:{$col}{$end})";
|
||||
return $str;
|
||||
}
|
||||
return $aggr;
|
||||
}
|
||||
protected function getColNumber($col)
|
||||
{
|
||||
$columns = (array) $this->columns;
|
||||
$columns = array_keys(array_pop($columns));
|
||||
return array_search($col, $columns);
|
||||
}
|
||||
protected function getColName($col_num)
|
||||
{
|
||||
$cols = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$N = strlen($cols);
|
||||
$name = '';
|
||||
if ($col_num > $N) {
|
||||
$name .= $cols[floor($col_num / $N)];
|
||||
$col_num = $N * ($col_num / $N - floor($col_num / $N));
|
||||
}
|
||||
$name .= $cols[$col_num];
|
||||
return $name;
|
||||
}
|
||||
public function informe()
|
||||
{
|
||||
header("Content-Type: application/octet-stream; charset=utf-8");
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
header('Content-Disposition: attachment; filename="' . $this->filename . '"');
|
||||
header('Cache-Control: max-age=0');
|
||||
|
||||
$pE = new ExcelHelper\TableWorkbook('php://output');
|
||||
$ws = $pE->addWorksheet($this->name);
|
||||
|
||||
$table = new ExcelHelper\Table($ws, 0, 0, $this->name, new \ArrayIterator($this->data));
|
||||
$table->setColumnCollection($this->columns);
|
||||
|
||||
$pE->writeTable($table);
|
||||
|
||||
$pE->close();
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user