Commit 91358679976fac7265511fcc8351fec71b22af09

Authored by Edmar Moretti
1 parent 2c3c471b

Otimização do carregamento de imagens

admin1/headjs.php 100644 → 100755
init/headjs.php 100644 → 100755
init/imagens/apple-touch-icon.png

16.1 KB | W: | H:

8.23 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
init/imagens/application-vnd-google-earth-kml.png

39.3 KB | W: | H:

23.9 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
init/imagens/applications-development-web.png

49.3 KB | W: | H:

16.9 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
init/imagens/applications-development.png

5.18 KB | W: | H:

5.75 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
init/imagens/cartogramas.png

69.9 KB | W: | H:

23.1 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
init/imagens/certificate-server.png

9.1 KB | W: | H:

6.63 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
init/imagens/docapi.png

40.2 KB | W: | H:

16.5 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
init/imagens/editor.png

86.3 KB | W: | H:

27.1 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
init/imagens/folder-image.png

14.3 KB | W: | H:

10.8 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
init/imagens/googleearth.png

29.8 KB | W: | H:

29.9 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
init/imagens/googlemaps.png

50.7 KB | W: | H:

17.2 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
init/imagens/googlemaps_noite.png

27.7 KB | W: | H:

10.9 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
init/imagens/guiamigracao.png

21.6 KB | W: | H:

15.8 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
init/imagens/gvsigtraining.png

21.2 KB | W: | H:

11.6 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
init/imagens/logo_psp.png

11.7 KB | W: | H:

6.78 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
init/imagens/mailman.jpg

1.97 KB

init/imagens/mailman.png 0 → 100755

23.7 KB

init/imagens/mashup.png

42 KB | W: | H:

20 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
init/imagens/ogc_logo.png

7.64 KB | W: | H:

3.77 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
init/imagens/openlayers.png

77.5 KB | W: | H:

27.5 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
init/imagens/openlayersdebug.png

52.8 KB | W: | H:

19.7 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
init/imagens/osm.png

91.3 KB | W: | H:

24.3 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
init/imagens/saiku_free_small.png

28.7 KB | W: | H:

12.3 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
init/imagens/sprite.php 0 → 100755
... ... @@ -0,0 +1,32 @@
  1 +<?php
  2 +include('../../pacotes/picStylizer/picStylizer.php');
  3 +
  4 +// initialize
  5 +$pS = new picStylizer();
  6 +
  7 +// define folder configuration
  8 +$config = array(
  9 + // set the origin folder
  10 + "origin" => array(
  11 + "images" => "." // folder from where the script will take the images
  12 + ),
  13 + // set destiny folder
  14 + "destiny" => array(
  15 + "styles" => "sprites.css", // define css style of sprites
  16 + "sprites" => "sprites.png", // define the sprite image result
  17 + "example" => "sprites.html", // define the html example
  18 + "ini_path" => "" // define the path
  19 + )
  20 +);
  21 +$pS->setFoldersConfig($config);
  22 +
  23 +// define minization [true/false] (default: true)
  24 +$pS->setMinization();
  25 +
  26 +// define css style by default (it will add to the sprites.css file)
  27 +$css = '';
  28 +$pS->setCssInit($css);
  29 +
  30 +// gen sprites, styles and html example
  31 +$pS->getSprite();
  32 +?>
0 33 \ No newline at end of file
... ...
init/imagens/sprites.css 0 → 100755
... ... @@ -0,0 +1 @@
  1 +.apple-touch-icon {background:url('sprites.png') 0 -0px no-repeat;width:190px; height:80px}.application-vnd-google-earth-kml {background:url('sprites.png') 0 -82px no-repeat;width:190px; height:80px}.applications-development-web {background:url('sprites.png') 0 -164px no-repeat;width:190px; height:80px}.applications-development {background:url('sprites.png') 0 -246px no-repeat;width:190px; height:80px}.cartogramas {background:url('sprites.png') 0 -328px no-repeat;width:190px; height:80px}.certificate-server {background:url('sprites.png') 0 -410px no-repeat;width:190px; height:80px}.docapi {background:url('sprites.png') 0 -492px no-repeat;width:190px; height:80px}.editor {background:url('sprites.png') 0 -574px no-repeat;width:190px; height:80px}.folder-image {background:url('sprites.png') 0 -656px no-repeat;width:190px; height:80px}.googleearth {background:url('sprites.png') 0 -738px no-repeat;width:190px; height:80px}.googlemaps {background:url('sprites.png') 0 -820px no-repeat;width:190px; height:80px}.googlemaps_noite {background:url('sprites.png') 0 -902px no-repeat;width:190px; height:80px}.guiamigracao {background:url('sprites.png') 0 -984px no-repeat;width:190px; height:80px}.gvsigtraining {background:url('sprites.png') 0 -1066px no-repeat;width:190px; height:80px}.insert-link {background:url('sprites.png') 0 -1148px no-repeat;width:190px; height:80px}.logo_psp {background:url('sprites.png') 0 -1230px no-repeat;width:190px; height:80px}.mailman {background:url('sprites.png') 0 -1312px no-repeat;width:190px; height:80px}.mashup {background:url('sprites.png') 0 -1394px no-repeat;width:190px; height:80px}.ogc_logo {background:url('sprites.png') 0 -1476px no-repeat;width:190px; height:80px}.openlayers {background:url('sprites.png') 0 -1558px no-repeat;width:190px; height:80px}.openlayersdebug {background:url('sprites.png') 0 -1640px no-repeat;width:190px; height:80px}.osm {background:url('sprites.png') 0 -1722px no-repeat;width:190px; height:80px}.saiku_free_small {background:url('sprites.png') 0 -1804px no-repeat;width:190px; height:80px}.svn-update {background:url('sprites.png') 0 -1886px no-repeat;width:190px; height:80px}.tools-report-bug {background:url('sprites.png') 0 -1968px no-repeat;width:190px; height:80px}.window-duplicate {background:url('sprites.png') 0 -2050px no-repeat;width:190px; height:80px}
0 2 \ No newline at end of file
... ...
init/imagens/sprites.html 0 → 100755
... ... @@ -0,0 +1 @@
  1 +<link rel="stylesheet" href="sprites.css"><h3>class: apple-touch-icon</h3><div class="apple-touch-icon"></div><h3>class: application-vnd-google-earth-kml</h3><div class="application-vnd-google-earth-kml"></div><h3>class: applications-development-web</h3><div class="applications-development-web"></div><h3>class: applications-development</h3><div class="applications-development"></div><h3>class: cartogramas</h3><div class="cartogramas"></div><h3>class: certificate-server</h3><div class="certificate-server"></div><h3>class: docapi</h3><div class="docapi"></div><h3>class: editor</h3><div class="editor"></div><h3>class: folder-image</h3><div class="folder-image"></div><h3>class: googleearth</h3><div class="googleearth"></div><h3>class: googlemaps</h3><div class="googlemaps"></div><h3>class: googlemaps_noite</h3><div class="googlemaps_noite"></div><h3>class: guiamigracao</h3><div class="guiamigracao"></div><h3>class: gvsigtraining</h3><div class="gvsigtraining"></div><h3>class: insert-link</h3><div class="insert-link"></div><h3>class: logo_psp</h3><div class="logo_psp"></div><h3>class: mailman</h3><div class="mailman"></div><h3>class: mashup</h3><div class="mashup"></div><h3>class: ogc_logo</h3><div class="ogc_logo"></div><h3>class: openlayers</h3><div class="openlayers"></div><h3>class: openlayersdebug</h3><div class="openlayersdebug"></div><h3>class: osm</h3><div class="osm"></div><h3>class: saiku_free_small</h3><div class="saiku_free_small"></div><h3>class: svn-update</h3><div class="svn-update"></div><h3>class: tools-report-bug</h3><div class="tools-report-bug"></div><h3>class: window-duplicate</h3><div class="window-duplicate"></div>
0 2 \ No newline at end of file
... ...
init/imagens/sprites.png 0 → 100755

443 KB

init/imagens/svn-update.png

17.7 KB | W: | H:

11.6 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
init/imagens/tools-report-bug.png

14.8 KB | W: | H:

7.77 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
init/imagens/window-duplicate.png

10.1 KB | W: | H:

7.72 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
init/index.js
1 1 botoesIni = [
2 2 {
3   - "img":"openlayers.png",
  3 + "img":"openlayers",
4 4 "href": location.href.replace("init/index.php","") + customDir + "/black_ol.htm",
5 5 "titulo":$trad(4,g_traducao_init),
6 6 "subtitulo": $trad("4a",g_traducao_init),
7 7 "fa": "map-o",
8 8 "target": "_blank"
9 9 },{
10   - "img":"osm.png",
  10 + "img":"osm",
11 11 "href": location.href.replace("init/index.php","") + customDir + "/black_osm.htm",
12 12 "titulo":$trad(23,g_traducao_init),
13 13 "subtitulo": $trad("23a",g_traducao_init),
14 14 "fa": "map-o",
15 15 "target": "_blank"
16 16 },{
17   - "img":"googlemaps.png",
  17 + "img":"googlemaps",
18 18 "href": location.href.replace("init/index.php","") + customDir + "/black_gm.phtml",
19 19 "titulo":$trad(6,g_traducao_init),
20 20 "subtitulo": $trad("6a",g_traducao_init),
21 21 "fa": "map-o",
22 22 "target": "_blank"
23 23 },{
24   - "img":"mashup.png",
  24 + "img":"mashup",
25 25 "href": "../mashups/index.php",
26 26 "titulo":$trad(18,g_traducao_init) + "<br><a href='../mashups/osm.php?temas=&largura=800&altura=500' target=_blank >OSM</a>" + " - <a href='../mashups/openlayers.php?temas=&largura=800&altura=500' target=_blank >OpenLayers</a>",
27 27 "subtitulo": $trad("18a",g_traducao_init),
28 28 "fa": "map-o",
29 29 "target": "_self"
30 30 },{
31   - "img":"googleearth.png",
  31 + "img":"googleearth",
32 32 "href": location.href.replace("init/index.php","") + customDir + "/googleearth.phtml",
33 33 "titulo":$trad(7,g_traducao_init),
34 34 "subtitulo": $trad("7a",g_traducao_init),
35 35 "fa": "map-o",
36 36 "target": "_blank"
37 37 },{
38   - "img":"cartogramas.png",
  38 + "img":"cartogramas",
39 39 "href": location.href.replace("init/index.php","") + customDir + "/black_carto_ol.htm",
40 40 "titulo":$trad(8,g_traducao_init),
41 41 "subtitulo": $trad("8a",g_traducao_init),
42 42 "fa": "map-o",
43 43 "target": "_blank"
44 44 },{
45   - "img":"editor.png",
  45 + "img":"editor",
46 46 "href": "../ferramentas/metaestat/editorlimites.php",
47 47 "titulo":$trad(9,g_traducao_init),
48 48 "subtitulo": $trad("9a",g_traducao_init),
49 49 "fa": "map-o",
50 50 "target": "_blank"
51 51 },{
52   - "img":"window-duplicate.png",
  52 + "img":"window-duplicate",
53 53 "href": "../mapas/index.php",
54 54 "titulo":$trad(34,g_traducao_init),
55 55 "subtitulo": $trad("34a",g_traducao_init),
56 56 "fa": "map-o",
57 57 "target": "_self"
58 58 },{
59   - "img":"ogc_logo.png",
  59 + "img":"ogc_logo",
60 60 "href": "../ogc/index.php",
61 61 "titulo":$trad(11,g_traducao_init),
62 62 "subtitulo": $trad("11a",g_traducao_init),
63 63 "fa": "download",
64 64 "target": "_self"
65 65 },{
66   - "img":"application-vnd-google-earth-kml.png",
  66 + "img":"application-vnd-google-earth-kml",
67 67 "href": "../kml.php",
68 68 "titulo":$trad(12,g_traducao_init),
69 69 "subtitulo": $trad("12a",g_traducao_init),
70 70 "fa": "download",
71 71 "target": "_self"
72 72 },{
73   - "img":"../imagens/saiku_free_small.png",
  73 + "img":"saiku_free_small",
74 74 "href": "../ferramentas/saiku/esquemaxml.php?locaplic="+window.location.href.replace("/init/index.php",""),
75 75 "titulo":$trad(25,g_traducao_init),
76 76 "subtitulo": $trad("25a",g_traducao_init),
77 77 "fa": "bar-chart",
78 78 "target": "_self"
79 79 },{
80   - "img":"insert-link.png",
  80 + "img":"insert-link",
81 81 "href": "../permlinks/index.php",
82 82 "titulo":$trad(13,g_traducao_init),
83 83 "subtitulo": $trad("13a",g_traducao_init),
84 84 "fa": "map-o",
85 85 "target": "_self"
86 86 },{
87   - "img":"openlayersdebug.png",
  87 + "img":"openlayersdebug",
88 88 "href": location.href.replace("init/index.php","") + customDir + "/openlayersdebug.htm",
89 89 "titulo":$trad(5,g_traducao_init),
90 90 "subtitulo": $trad("5a",g_traducao_init),
91 91 "fa": "cogs",
92 92 "target": "_blank"
93 93 },{
94   - "img":"certificate-server.png",
  94 + "img":"certificate-server",
95 95 "href": "../testainstal/index.php",
96 96 "titulo":$trad(2,g_traducao_init),
97 97 "subtitulo": $trad("2a",g_traducao_init),
98 98 "fa": "cogs",
99 99 "target": "_self"
100 100 },{
101   - "img":"applications-development-web.png",
  101 + "img":"applications-development-web",
102 102 "href": "../admin1",
103 103 "titulo":$trad(3,g_traducao_init),
104 104 "subtitulo": $trad("3a",g_traducao_init),
105 105 "fa": "cogs",
106 106 "target": "_self"
107 107 },{
108   - "img":"folder-image.png",
  108 + "img":"folder-image",
109 109 "href": "../exemplos/index.php",
110 110 "titulo":$trad(14,g_traducao_init),
111 111 "subtitulo": $trad("14a",g_traducao_init),
112 112 "fa": "cogs",
113 113 "target": "_self"
114 114 },{
115   - "img":"applications-development.png",
  115 + "img":"applications-development",
116 116 "href": "../utilitarios/index.php",
117 117 "titulo":$trad(33,g_traducao_init),
118 118 "subtitulo": $trad("33a",g_traducao_init),
119 119 "fa": "wrench",
120 120 "target": "_self"
121 121 },{
122   - "img":"guiamigracao.png",
  122 + "img":"guiamigracao",
123 123 "href": "../guia_de_migracao.txt",
124 124 "titulo":$trad(17,g_traducao_init),
125 125 "subtitulo": $trad("17a",g_traducao_init),
126 126 "fa": "cogs",
127 127 "target": "_self"
128 128 },{
129   - "img":"docapi.png",
  129 + "img":"docapi",
130 130 "href": "../documentacao",
131 131 "titulo":$trad(24,g_traducao_init),
132 132 "subtitulo": $trad("24a",g_traducao_init),
133 133 "fa": "book",
134 134 "target": "_self"
135 135 },{
136   - "img":"gvsigtraining.png",
  136 + "img":"gvsigtraining",
137 137 "href":"http://moodle.gvsig-training.com/course/view.php?id=11",
138 138 "titulo":$trad(28,g_traducao_init),
139 139 "subtitulo": $trad("28a",g_traducao_init),
140 140 "fa": "book",
141 141 "target": "_self"
142 142 },{
143   - "img":"tools-report-bug.png",
  143 + "img":"tools-report-bug",
144 144 "href":"https://softwarepublico.gov.br/gitlab/i3geo/i3geo/issues",
145 145 "titulo":$trad(16,g_traducao_init),
146 146 "subtitulo": $trad("16a",g_traducao_init),
147 147 "fa": "group",
148 148 "target": "_self"
149 149 },{
150   - "img":"../imagens/apple-touch-icon.png",
  150 + "img":"apple-touch-icon",
151 151 "href":"https://softwarepublico.gov.br/gitlab/groups/i3geo",
152 152 "titulo":$trad(30,g_traducao_init),
153 153 "subtitulo": $trad("30a",g_traducao_init),
154 154 "fa": "group",
155 155 "target": "_self"
156 156 },{
157   - "img":"logo_psp.png",
  157 + "img":"logo_psp",
158 158 "href":"https://portal.softwarepublico.gov.br/social/i3geo/",
159 159 "titulo":$trad(31,g_traducao_init),
160 160 "subtitulo": $trad("31a",g_traducao_init),
161 161 "fa": "group",
162 162 "target": "_self"
163 163 },{
164   - "img":"mailman.jpg",
  164 + "img":"mailman",
165 165 "href":"http://lists.osgeo.org/cgi-bin/mailman/listinfo/i3geo",
166 166 "titulo":$trad(32,g_traducao_init),
167 167 "subtitulo": $trad("32a",g_traducao_init),
... ... @@ -198,7 +198,7 @@ function mostraBotoesBT(men){
198 198 {"d":botoesIni,"abrir" : $trad(36,g_traducao_init)}
199 199 );
200 200 $("#botoesTpl").html(html);
201   - aplicaFavoritos()
  201 + aplicaFavoritos();
202 202 }
203 203 function findBootstrapDeviceSize() {
204 204 var dsize = ['lg', 'md', 'sm', 'xs'];
... ...
init/index.php
... ... @@ -35,6 +35,7 @@ if (file_exists ( $dir_tmp )) {
35 35 error_reporting ( 0 );
36 36 include "head.php";
37 37 ?>
  38 +<link href='imagens/sprites.css' rel='stylesheet'>
38 39 <style>
39 40 .amarelo {
40 41 color: yellow;
... ... @@ -103,11 +104,19 @@ include &quot;head.php&quot;;
103 104 style="width: 260px; min-width: 260px; max-width: 260px;">
104 105 <div class="panel panel-default">
105 106 <div class="panel-body">
  107 + <!--
106 108 <div class="thumbnail" role="button" style="height: 90px;">
107 109 <a target="{{{target}}}" href="{{{href}}}"> <img class="img-rounded"
108 110 style="height: 100%; width: 100%" src="imagens/{{{img}}}" />
109 111 </a>
110 112 </div>
  113 + -->
  114 + <div class="thumbnail" role="button" style="height: 90px;">
  115 + <a target="{{{target}}}" href="{{{href}}}"> <img class="img-rounded {{{img}}}"
  116 + style="height: 100%; width: 100%" src="../imagens/branco.gif" />
  117 + </a>
  118 + </div>
  119 +
111 120 <h4 style="height: 40px;">{{{titulo}}}</h4>
112 121 <h5 class="hidden-xs" style="height: 100px;">{{{subtitulo}}}</h5>
113 122  
... ... @@ -185,15 +194,7 @@ include &quot;head.php&quot;;
185 194 //utilizado em ms_configura.php para customizar o local da pasta de inicializacao
186 195 var customDir = "<?php echo $customDir; ?>";
187 196 </script>
188   - <script src='../pacotes/cpaint/cpaint2_compacto.inc.js'></script>
189   - <script src='../classesjs/compactados/dicionario_compacto.js'></script>
190   - <script src='../classesjs/compactados/classe_util_compacto.js'></script>
191   - <script src='../classesjs/compactados/classe_idioma_compacto.js'></script>
192   - <script src='../classesjs/compactados/classe_login_compacto.js'></script>
193   - <script src='../classesjs/compactados/classe_php_compacto.js'></script>
194   - <script src='../classesjs/compactados/mustache.js'></script>
195   - <script src='dicionario.js'></script>
196   - <script src='index.js'></script>
  197 + <script src='indexjs.php'></script>
197 198 <script>
198 199 $(document).ready(function(){
199 200 <?php
... ...
init/indexjs.php 0 → 100755
... ... @@ -0,0 +1,28 @@
  1 +<?php
  2 +if (extension_loaded ( 'zlib' )) {
  3 + ob_start ( 'ob_gzhandler' );
  4 +}
  5 +header ( "Content-type: text/javascript" );
  6 +
  7 +include ('../pacotes/cpaint/cpaint2_compacto.inc.js');
  8 +echo "\n";
  9 +include ('../classesjs/compactados/dicionario_compacto.js');
  10 +echo "\n";
  11 +include ('../classesjs/compactados/classe_util_compacto.js');
  12 +echo "\n";
  13 +include ('../classesjs/compactados/classe_idioma_compacto.js');
  14 +echo "\n";
  15 +include ('../classesjs/compactados/classe_login_compacto.js');
  16 +echo "\n";
  17 +include ('../classesjs/compactados/classe_php_compacto.js');
  18 +echo "\n";
  19 +include ('../classesjs/compactados/mustache.js');
  20 +echo "\n";
  21 +include ('dicionario.js');
  22 +echo "\n";
  23 +include ('index.js');
  24 +echo "\n";
  25 +
  26 +if (extension_loaded ( 'zlib' )) {
  27 + ob_end_flush ();
  28 +}
0 29 \ No newline at end of file
... ...
pacotes/picStylizer/LICENSE 0 → 100755
... ... @@ -0,0 +1,340 @@
  1 + GNU GENERAL PUBLIC LICENSE
  2 + Version 2, June 1991
  3 +
  4 + Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
  5 + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  6 + Everyone is permitted to copy and distribute verbatim copies
  7 + of this license document, but changing it is not allowed.
  8 +
  9 + Preamble
  10 +
  11 + The licenses for most software are designed to take away your
  12 +freedom to share and change it. By contrast, the GNU General Public
  13 +License is intended to guarantee your freedom to share and change free
  14 +software--to make sure the software is free for all its users. This
  15 +General Public License applies to most of the Free Software
  16 +Foundation's software and to any other program whose authors commit to
  17 +using it. (Some other Free Software Foundation software is covered by
  18 +the GNU Lesser General Public License instead.) You can apply it to
  19 +your programs, too.
  20 +
  21 + When we speak of free software, we are referring to freedom, not
  22 +price. Our General Public Licenses are designed to make sure that you
  23 +have the freedom to distribute copies of free software (and charge for
  24 +this service if you wish), that you receive source code or can get it
  25 +if you want it, that you can change the software or use pieces of it
  26 +in new free programs; and that you know you can do these things.
  27 +
  28 + To protect your rights, we need to make restrictions that forbid
  29 +anyone to deny you these rights or to ask you to surrender the rights.
  30 +These restrictions translate to certain responsibilities for you if you
  31 +distribute copies of the software, or if you modify it.
  32 +
  33 + For example, if you distribute copies of such a program, whether
  34 +gratis or for a fee, you must give the recipients all the rights that
  35 +you have. You must make sure that they, too, receive or can get the
  36 +source code. And you must show them these terms so they know their
  37 +rights.
  38 +
  39 + We protect your rights with two steps: (1) copyright the software, and
  40 +(2) offer you this license which gives you legal permission to copy,
  41 +distribute and/or modify the software.
  42 +
  43 + Also, for each author's protection and ours, we want to make certain
  44 +that everyone understands that there is no warranty for this free
  45 +software. If the software is modified by someone else and passed on, we
  46 +want its recipients to know that what they have is not the original, so
  47 +that any problems introduced by others will not reflect on the original
  48 +authors' reputations.
  49 +
  50 + Finally, any free program is threatened constantly by software
  51 +patents. We wish to avoid the danger that redistributors of a free
  52 +program will individually obtain patent licenses, in effect making the
  53 +program proprietary. To prevent this, we have made it clear that any
  54 +patent must be licensed for everyone's free use or not licensed at all.
  55 +
  56 + The precise terms and conditions for copying, distribution and
  57 +modification follow.
  58 +
  59 + GNU GENERAL PUBLIC LICENSE
  60 + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  61 +
  62 + 0. This License applies to any program or other work which contains
  63 +a notice placed by the copyright holder saying it may be distributed
  64 +under the terms of this General Public License. The "Program", below,
  65 +refers to any such program or work, and a "work based on the Program"
  66 +means either the Program or any derivative work under copyright law:
  67 +that is to say, a work containing the Program or a portion of it,
  68 +either verbatim or with modifications and/or translated into another
  69 +language. (Hereinafter, translation is included without limitation in
  70 +the term "modification".) Each licensee is addressed as "you".
  71 +
  72 +Activities other than copying, distribution and modification are not
  73 +covered by this License; they are outside its scope. The act of
  74 +running the Program is not restricted, and the output from the Program
  75 +is covered only if its contents constitute a work based on the
  76 +Program (independent of having been made by running the Program).
  77 +Whether that is true depends on what the Program does.
  78 +
  79 + 1. You may copy and distribute verbatim copies of the Program's
  80 +source code as you receive it, in any medium, provided that you
  81 +conspicuously and appropriately publish on each copy an appropriate
  82 +copyright notice and disclaimer of warranty; keep intact all the
  83 +notices that refer to this License and to the absence of any warranty;
  84 +and give any other recipients of the Program a copy of this License
  85 +along with the Program.
  86 +
  87 +You may charge a fee for the physical act of transferring a copy, and
  88 +you may at your option offer warranty protection in exchange for a fee.
  89 +
  90 + 2. You may modify your copy or copies of the Program or any portion
  91 +of it, thus forming a work based on the Program, and copy and
  92 +distribute such modifications or work under the terms of Section 1
  93 +above, provided that you also meet all of these conditions:
  94 +
  95 + a) You must cause the modified files to carry prominent notices
  96 + stating that you changed the files and the date of any change.
  97 +
  98 + b) You must cause any work that you distribute or publish, that in
  99 + whole or in part contains or is derived from the Program or any
  100 + part thereof, to be licensed as a whole at no charge to all third
  101 + parties under the terms of this License.
  102 +
  103 + c) If the modified program normally reads commands interactively
  104 + when run, you must cause it, when started running for such
  105 + interactive use in the most ordinary way, to print or display an
  106 + announcement including an appropriate copyright notice and a
  107 + notice that there is no warranty (or else, saying that you provide
  108 + a warranty) and that users may redistribute the program under
  109 + these conditions, and telling the user how to view a copy of this
  110 + License. (Exception: if the Program itself is interactive but
  111 + does not normally print such an announcement, your work based on
  112 + the Program is not required to print an announcement.)
  113 +
  114 +These requirements apply to the modified work as a whole. If
  115 +identifiable sections of that work are not derived from the Program,
  116 +and can be reasonably considered independent and separate works in
  117 +themselves, then this License, and its terms, do not apply to those
  118 +sections when you distribute them as separate works. But when you
  119 +distribute the same sections as part of a whole which is a work based
  120 +on the Program, the distribution of the whole must be on the terms of
  121 +this License, whose permissions for other licensees extend to the
  122 +entire whole, and thus to each and every part regardless of who wrote it.
  123 +
  124 +Thus, it is not the intent of this section to claim rights or contest
  125 +your rights to work written entirely by you; rather, the intent is to
  126 +exercise the right to control the distribution of derivative or
  127 +collective works based on the Program.
  128 +
  129 +In addition, mere aggregation of another work not based on the Program
  130 +with the Program (or with a work based on the Program) on a volume of
  131 +a storage or distribution medium does not bring the other work under
  132 +the scope of this License.
  133 +
  134 + 3. You may copy and distribute the Program (or a work based on it,
  135 +under Section 2) in object code or executable form under the terms of
  136 +Sections 1 and 2 above provided that you also do one of the following:
  137 +
  138 + a) Accompany it with the complete corresponding machine-readable
  139 + source code, which must be distributed under the terms of Sections
  140 + 1 and 2 above on a medium customarily used for software interchange; or,
  141 +
  142 + b) Accompany it with a written offer, valid for at least three
  143 + years, to give any third party, for a charge no more than your
  144 + cost of physically performing source distribution, a complete
  145 + machine-readable copy of the corresponding source code, to be
  146 + distributed under the terms of Sections 1 and 2 above on a medium
  147 + customarily used for software interchange; or,
  148 +
  149 + c) Accompany it with the information you received as to the offer
  150 + to distribute corresponding source code. (This alternative is
  151 + allowed only for noncommercial distribution and only if you
  152 + received the program in object code or executable form with such
  153 + an offer, in accord with Subsection b above.)
  154 +
  155 +The source code for a work means the preferred form of the work for
  156 +making modifications to it. For an executable work, complete source
  157 +code means all the source code for all modules it contains, plus any
  158 +associated interface definition files, plus the scripts used to
  159 +control compilation and installation of the executable. However, as a
  160 +special exception, the source code distributed need not include
  161 +anything that is normally distributed (in either source or binary
  162 +form) with the major components (compiler, kernel, and so on) of the
  163 +operating system on which the executable runs, unless that component
  164 +itself accompanies the executable.
  165 +
  166 +If distribution of executable or object code is made by offering
  167 +access to copy from a designated place, then offering equivalent
  168 +access to copy the source code from the same place counts as
  169 +distribution of the source code, even though third parties are not
  170 +compelled to copy the source along with the object code.
  171 +
  172 + 4. You may not copy, modify, sublicense, or distribute the Program
  173 +except as expressly provided under this License. Any attempt
  174 +otherwise to copy, modify, sublicense or distribute the Program is
  175 +void, and will automatically terminate your rights under this License.
  176 +However, parties who have received copies, or rights, from you under
  177 +this License will not have their licenses terminated so long as such
  178 +parties remain in full compliance.
  179 +
  180 + 5. You are not required to accept this License, since you have not
  181 +signed it. However, nothing else grants you permission to modify or
  182 +distribute the Program or its derivative works. These actions are
  183 +prohibited by law if you do not accept this License. Therefore, by
  184 +modifying or distributing the Program (or any work based on the
  185 +Program), you indicate your acceptance of this License to do so, and
  186 +all its terms and conditions for copying, distributing or modifying
  187 +the Program or works based on it.
  188 +
  189 + 6. Each time you redistribute the Program (or any work based on the
  190 +Program), the recipient automatically receives a license from the
  191 +original licensor to copy, distribute or modify the Program subject to
  192 +these terms and conditions. You may not impose any further
  193 +restrictions on the recipients' exercise of the rights granted herein.
  194 +You are not responsible for enforcing compliance by third parties to
  195 +this License.
  196 +
  197 + 7. If, as a consequence of a court judgment or allegation of patent
  198 +infringement or for any other reason (not limited to patent issues),
  199 +conditions are imposed on you (whether by court order, agreement or
  200 +otherwise) that contradict the conditions of this License, they do not
  201 +excuse you from the conditions of this License. If you cannot
  202 +distribute so as to satisfy simultaneously your obligations under this
  203 +License and any other pertinent obligations, then as a consequence you
  204 +may not distribute the Program at all. For example, if a patent
  205 +license would not permit royalty-free redistribution of the Program by
  206 +all those who receive copies directly or indirectly through you, then
  207 +the only way you could satisfy both it and this License would be to
  208 +refrain entirely from distribution of the Program.
  209 +
  210 +If any portion of this section is held invalid or unenforceable under
  211 +any particular circumstance, the balance of the section is intended to
  212 +apply and the section as a whole is intended to apply in other
  213 +circumstances.
  214 +
  215 +It is not the purpose of this section to induce you to infringe any
  216 +patents or other property right claims or to contest validity of any
  217 +such claims; this section has the sole purpose of protecting the
  218 +integrity of the free software distribution system, which is
  219 +implemented by public license practices. Many people have made
  220 +generous contributions to the wide range of software distributed
  221 +through that system in reliance on consistent application of that
  222 +system; it is up to the author/donor to decide if he or she is willing
  223 +to distribute software through any other system and a licensee cannot
  224 +impose that choice.
  225 +
  226 +This section is intended to make thoroughly clear what is believed to
  227 +be a consequence of the rest of this License.
  228 +
  229 + 8. If the distribution and/or use of the Program is restricted in
  230 +certain countries either by patents or by copyrighted interfaces, the
  231 +original copyright holder who places the Program under this License
  232 +may add an explicit geographical distribution limitation excluding
  233 +those countries, so that distribution is permitted only in or among
  234 +countries not thus excluded. In such case, this License incorporates
  235 +the limitation as if written in the body of this License.
  236 +
  237 + 9. The Free Software Foundation may publish revised and/or new versions
  238 +of the General Public License from time to time. Such new versions will
  239 +be similar in spirit to the present version, but may differ in detail to
  240 +address new problems or concerns.
  241 +
  242 +Each version is given a distinguishing version number. If the Program
  243 +specifies a version number of this License which applies to it and "any
  244 +later version", you have the option of following the terms and conditions
  245 +either of that version or of any later version published by the Free
  246 +Software Foundation. If the Program does not specify a version number of
  247 +this License, you may choose any version ever published by the Free Software
  248 +Foundation.
  249 +
  250 + 10. If you wish to incorporate parts of the Program into other free
  251 +programs whose distribution conditions are different, write to the author
  252 +to ask for permission. For software which is copyrighted by the Free
  253 +Software Foundation, write to the Free Software Foundation; we sometimes
  254 +make exceptions for this. Our decision will be guided by the two goals
  255 +of preserving the free status of all derivatives of our free software and
  256 +of promoting the sharing and reuse of software generally.
  257 +
  258 + NO WARRANTY
  259 +
  260 + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
  261 +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
  262 +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
  263 +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
  264 +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  265 +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
  266 +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
  267 +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
  268 +REPAIR OR CORRECTION.
  269 +
  270 + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
  271 +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
  272 +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
  273 +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
  274 +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
  275 +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
  276 +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
  277 +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
  278 +POSSIBILITY OF SUCH DAMAGES.
  279 +
  280 + END OF TERMS AND CONDITIONS
  281 +
  282 + How to Apply These Terms to Your New Programs
  283 +
  284 + If you develop a new program, and you want it to be of the greatest
  285 +possible use to the public, the best way to achieve this is to make it
  286 +free software which everyone can redistribute and change under these terms.
  287 +
  288 + To do so, attach the following notices to the program. It is safest
  289 +to attach them to the start of each source file to most effectively
  290 +convey the exclusion of warranty; and each file should have at least
  291 +the "copyright" line and a pointer to where the full notice is found.
  292 +
  293 + {description}
  294 + Copyright (C) {year} {fullname}
  295 +
  296 + This program is free software; you can redistribute it and/or modify
  297 + it under the terms of the GNU General Public License as published by
  298 + the Free Software Foundation; either version 2 of the License, or
  299 + (at your option) any later version.
  300 +
  301 + This program is distributed in the hope that it will be useful,
  302 + but WITHOUT ANY WARRANTY; without even the implied warranty of
  303 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  304 + GNU General Public License for more details.
  305 +
  306 + You should have received a copy of the GNU General Public License along
  307 + with this program; if not, write to the Free Software Foundation, Inc.,
  308 + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  309 +
  310 +Also add information on how to contact you by electronic and paper mail.
  311 +
  312 +If the program is interactive, make it output a short notice like this
  313 +when it starts in an interactive mode:
  314 +
  315 + Gnomovision version 69, Copyright (C) year name of author
  316 + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
  317 + This is free software, and you are welcome to redistribute it
  318 + under certain conditions; type `show c' for details.
  319 +
  320 +The hypothetical commands `show w' and `show c' should show the appropriate
  321 +parts of the General Public License. Of course, the commands you use may
  322 +be called something other than `show w' and `show c'; they could even be
  323 +mouse-clicks or menu items--whatever suits your program.
  324 +
  325 +You should also get your employer (if you work as a programmer) or your
  326 +school, if any, to sign a "copyright disclaimer" for the program, if
  327 +necessary. Here is a sample; alter the names:
  328 +
  329 + Yoyodyne, Inc., hereby disclaims all copyright interest in the program
  330 + `Gnomovision' (which makes passes at compilers) written by James Hacker.
  331 +
  332 + {signature of Ty Coon}, 1 April 1989
  333 + Ty Coon, President of Vice
  334 +
  335 +This General Public License does not permit incorporating your program into
  336 +proprietary programs. If your program is a subroutine library, you may
  337 +consider it more useful to permit linking proprietary applications with the
  338 +library. If this is what you want to do, use the GNU Lesser General
  339 +Public License instead of this License.
  340 +
... ...
pacotes/picStylizer/README.md 0 → 100755
... ... @@ -0,0 +1,46 @@
  1 +# picStylizer
  2 +
  3 +picStylizer is a PHP class that create sprite and css style file from images folder
  4 +
  5 +Notice: if you want to change the image onMouseOver (hover) you have add "_hover" at the end of filename before the extention
  6 +Example:
  7 +// initial image
  8 +icon.png
  9 +// hover image
  10 +icon_hover.png //adding _hover
  11 +// the result css code will be:
  12 +.icon {...}
  13 +.icon:hover {...}
  14 +
  15 +# Usage
  16 +
  17 +```php
  18 +// Initialize Class
  19 +$pS = new picStylizer();
  20 +
  21 +// define folder configuration
  22 +$config = array(
  23 + // set the origin folder
  24 + "origin" => array(
  25 + "images" => "origin/images" // folder from where the script will take the images
  26 + ),
  27 + // set destiny folder
  28 + "destiny" => array(
  29 + "styles" => "destiny/css/sprites.css", // define css style of sprites
  30 + "sprites" => "destiny/sprites/sprites.png", // define the sprite image result
  31 + "example" => "destiny/example/sprites.html", // define the html example
  32 + "ini_path" => "../../" // define the path
  33 + )
  34 + );
  35 +$pS->setFoldersConfig($config);
  36 +
  37 +// define minization (default: true)
  38 +$pS->setMinization();
  39 +
  40 +// define css style by default
  41 +$css = 'body {backgound-color:#000;font-family:courier;color:#fff,font-size:14px;}';
  42 +$pS->setCssInit($css);
  43 +
  44 +// gen sprites, styles and html example
  45 +$pS->getSprite();
  46 +```
... ...
pacotes/picStylizer/example.php 0 → 100755
... ... @@ -0,0 +1,32 @@
  1 +<?php
  2 +exit;
  3 +include('picStylizer.php');
  4 +
  5 +// initialize
  6 +$pS = new picStylizer();
  7 +
  8 +// define folder configuration
  9 +$config = array(
  10 + // set the origin folder
  11 + "origin" => array(
  12 + "images" => "origin/images" // folder from where the script will take the images
  13 + ),
  14 + // set destiny folder
  15 + "destiny" => array(
  16 + "styles" => "destiny/css/sprites.css", // define css style of sprites
  17 + "sprites" => "destiny/sprites/sprites.png", // define the sprite image result
  18 + "example" => "destiny/example/sprites.html", // define the html example
  19 + "ini_path" => "../../" // define the path
  20 + )
  21 + );
  22 +$pS->setFoldersConfig($config);
  23 +
  24 +// define minization [true/false] (default: true)
  25 +$pS->setMinization();
  26 +
  27 +// define css style by default (it will add to the sprites.css file)
  28 +$css = 'body {background-color:#000;font-family:courier;color:#fff;font-size:14px;}';
  29 +$pS->setCssInit($css);
  30 +
  31 +// gen sprites, styles and html example
  32 +$pS->getSprite();
... ...
pacotes/picStylizer/picStylizer.php 0 → 100755
... ... @@ -0,0 +1,437 @@
  1 +<?php
  2 +
  3 +/**
  4 + * Create a Css style and sprite from images
  5 + *
  6 + * @version 1.1
  7 + * @link https://github.com/lutian/picStylizer
  8 + * @author Lutian (Luciano Salvino)
  9 + * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  10 + * @copyright Luciano Salvino
  11 + *
  12 + * Thanks Aldo Conte for improvements on script!
  13 + * Reduces the size of CSS script and sprite in a big way
  14 + */
  15 +
  16 + class picStylizer {
  17 +
  18 + /**
  19 + * @var string The image result source
  20 + */
  21 + private $im;
  22 +
  23 + /**
  24 + * @var int W image
  25 + */
  26 + private $im_w = 0;
  27 +
  28 + /**
  29 + * @var int H image
  30 + */
  31 + private $im_h = 0;
  32 +
  33 + /**
  34 + * @var int X image
  35 + */
  36 + private $im_x = 0;
  37 +
  38 + /**
  39 + * @var int Y image
  40 + */
  41 + private $im_y = 0;
  42 +
  43 + /**
  44 + * @var string The image tmp result source
  45 + */
  46 + private $temp;
  47 +
  48 + /**
  49 + * @var int W temp
  50 + */
  51 + private $temp_w = 0;
  52 +
  53 + /**
  54 + * @var int H temp
  55 + */
  56 + private $temp_h = 0;
  57 +
  58 + /**
  59 + * @var int temp separation in px
  60 + */
  61 + private $temp_sep = 2;
  62 +
  63 + /**
  64 + * @var string temp_css
  65 + */
  66 + private $temp_css = '';
  67 +
  68 + /**
  69 + * @var string temp_css
  70 + */
  71 + private $temp_min_sep = "\n";
  72 +
  73 + /**
  74 + * @var string temp_html
  75 + */
  76 + private $temp_html = '';
  77 +
  78 + /**
  79 + * @var string version
  80 + */
  81 + private $version = '1.1';
  82 +
  83 + /**
  84 + * @var array folders_config folder
  85 + */
  86 + private $folders_config = array(
  87 + "origin" => array(
  88 + "images" => "origin/images"
  89 + ),
  90 + "destiny" => array(
  91 + "styles" => "destiny/css/sprites.css",
  92 + "sprites" => "destiny/sprites/sprites.png",
  93 + "example" => "destiny/example/sprites.html",
  94 + "ini_path" => "../../"
  95 + )
  96 + );
  97 + /*
  98 + * @var string define default css style
  99 + */
  100 + private $css_init = '';
  101 +
  102 + /**
  103 + * @var array sprites
  104 + */
  105 + private $sprites = array();
  106 +
  107 + /*
  108 + * crate a sprite from images
  109 + * @return: string $imageResult image result path
  110 + */
  111 +
  112 + public function getSprite()
  113 + {
  114 +
  115 + // first read the origin folder looking for png pictures
  116 + $arrImages = $this->readFolder($this->folders_config["origin"]["images"]);
  117 +
  118 + // save images array
  119 + $this->setSprite($arrImages);
  120 +
  121 + // create the sprite
  122 + $this->createSprite();
  123 +
  124 + }
  125 +
  126 + /*
  127 + * read folder looking for images
  128 + * @return: array $result
  129 + */
  130 + private function readFolder($dir='',$acceptedformats=array('png')) {
  131 + $result = array();
  132 + $cdir = scandir($dir);
  133 + // read origin dir
  134 + foreach ($cdir as $key => $value)
  135 + {
  136 + // exclude non files
  137 + if (!in_array($value,array(".","..")))
  138 + {
  139 + // if have sub folders loop on the same function
  140 + if (is_dir($dir . DIRECTORY_SEPARATOR . $value))
  141 + {
  142 + $result[$value] = $this->readFolder($dir . DIRECTORY_SEPARATOR . $value);
  143 + }
  144 + else
  145 + {
  146 + // exclude files with extentions not accepted
  147 + $ext = strtolower(substr($value, strrpos($value, '.') + 1));
  148 + if(in_array($ext, $acceptedformats)) {
  149 + $result[] = $value;
  150 + }
  151 + }
  152 + }
  153 + }
  154 + return $result;
  155 + }
  156 +
  157 + /*
  158 + * get the images info from array
  159 + */
  160 + private function getImageInfoFromDir($dir,$subdir='') {
  161 +
  162 + foreach($dir as $key => $value){
  163 + if(!is_int($key)) {
  164 + $this->getImageInfoFromDir($value,$subdir . $key . DIRECTORY_SEPARATOR);
  165 + } else {
  166 + $this->calculateSpriteWidthHeight($this->folders_config["origin"]["images"] . DIRECTORY_SEPARATOR . $subdir . $value);
  167 + }
  168 + }
  169 + }
  170 +
  171 + /*
  172 + * get the images info from array
  173 + */
  174 + private function getImagesFromDir($dir,$subdir='') {
  175 + foreach($dir as $key => $value){
  176 + if(!is_int($key)) {
  177 + $this->getImagesFromDir($value,$subdir . $key . DIRECTORY_SEPARATOR);
  178 + } else {
  179 + $this->proccessMedia($this->folders_config["origin"]["images"] . DIRECTORY_SEPARATOR . $subdir . $value);
  180 + }
  181 + }
  182 + }
  183 +
  184 + /*
  185 + * create the sprite
  186 + */
  187 + private function createSprite() {
  188 +
  189 + $arrImages = $this->getSprites();
  190 +
  191 +
  192 + if(count($arrImages)>0) {
  193 +
  194 + // calculate sprite width and height
  195 + $this->getImageInfoFromDir($arrImages);
  196 +
  197 + // create the empty sprite
  198 + $this->im = imagecreatetruecolor($this->im_w, $this->im_h);
  199 + imagealphablending($this->im, false);
  200 + $transparency = imagecolorallocatealpha($this->im, 0, 0, 0, 127);
  201 + imagefill($this->im, 0, 0, $transparency);
  202 + imagesavealpha($this->im, true);
  203 +
  204 + $x = 0;
  205 + $y = 0;
  206 +
  207 + $this->getImagesFromDir($arrImages);
  208 +
  209 + // save the sprite
  210 + $this->saveSprite();
  211 +
  212 + // save the css
  213 + $this->saveCss();
  214 +
  215 + // save the example html
  216 + $this->saveHtml();
  217 +
  218 + }
  219 +
  220 +
  221 +
  222 + header('location:'.$this->folders_config['destiny']['example']);
  223 + exit();
  224 +
  225 + }
  226 +
  227 + /*
  228 + * calculate sprite w & h
  229 + * @param: string $image
  230 + * @return: object $this->temp
  231 + */
  232 + private function calculateSpriteWidthHeight($image) {
  233 + if(is_file($image)) {
  234 + $arrImage = @getimagesize($image);
  235 + // updated by Aldo Conte
  236 + $tmps = $arrImage[0]+$this->temp_sep;
  237 + if ($tmps > $this->im_w) $this->im_w = $arrImage[0]+$this->temp_sep;
  238 + // end
  239 + $this->im_h += $arrImage[1]+$this->temp_sep;
  240 + }
  241 + }
  242 +
  243 + /*
  244 + * proccess media
  245 + * @param: string $image
  246 + * @return: object $this->temp
  247 + */
  248 + private function proccessMedia($image) {
  249 + if(is_file($image)) {
  250 + $arrImage = @getimagesize($image);
  251 + $this->temp_w = $arrImage[0];
  252 + $this->temp_h = $arrImage[1];
  253 +
  254 + $tmp = ImageCreateTrueColor($this->im_w, $this->im_h);
  255 + imagealphablending($tmp, false);
  256 + $col=imagecolorallocatealpha($tmp,255,255,255,0);
  257 + imagefilledrectangle($tmp,0,0,$this->im_w, $this->im_h,$col);
  258 + imagealphablending($tmp,true);
  259 +
  260 + $gd_ext = substr($image, -3);
  261 +
  262 + if(strtolower($gd_ext) == "gif") {
  263 + if (!$this->temp = imagecreatefromgif($image)) {
  264 + exit;
  265 + }
  266 + } else if(strtolower($gd_ext) == "jpg") {
  267 + if (!$this->temp = imagecreatefromjpeg($image)) {
  268 + exit;
  269 + }
  270 + } else if(strtolower($gd_ext) == "png") {
  271 + if (!$this->temp = imagecreatefrompng($image)) {
  272 + exit;
  273 + }
  274 + } else {
  275 + die;
  276 + }
  277 +
  278 + imagecopyresampled($tmp, $this->im, 0, 0, 0, 0, $this->im_w, $this->im_h, $this->im_w, $this->im_h);
  279 + imagealphablending($tmp,true);
  280 +
  281 + // add each image to sprite
  282 +
  283 + // updated by Aldo Conte
  284 + imagecopyresampled($this->im, $this->temp, 0, $this->im_y, 0, 0, $this->temp_w, $this->temp_h, $this->temp_w, $this->temp_h);
  285 + // end
  286 +
  287 + imagealphablending($this->im,true);
  288 +
  289 + $ext = substr($image, strrpos($image, '.'));
  290 +
  291 + $filename = basename($image,$ext);
  292 +
  293 + // add piece of script to css
  294 + $this->genCssPieceCode($filename);
  295 +
  296 + // add piece of script to html example
  297 + $this->genHtmlPieceCode($filename);
  298 +
  299 + $this->im_x += $this->temp_w+$this->temp_sep;
  300 + $this->im_y += $this->temp_h+$this->temp_sep;
  301 +
  302 + } else {
  303 + die;
  304 + }
  305 + }
  306 +
  307 + private function genCssPieceCode($name) {
  308 + // if filename contain "_hover" add the part of code
  309 + if(strpos($name,"_hover")!==false) $name = substr($name,0,-6).':hover';
  310 +
  311 + // updated by Aldo Conte
  312 + $temp_css_detail = "background:url('".$this->folders_config['destiny']['ini_path'].$this->folders_config['destiny']['sprites']."') 0 -".$this->im_y."px no-repeat;".$this->temp_min_sep;
  313 + // end
  314 +
  315 + $temp_css_detail .= "width:".$this->temp_w."px; height:".$this->temp_h."px".$this->temp_min_sep;
  316 + $temp_css = ".".$name." {".$temp_css_detail."}".$this->temp_min_sep;
  317 + $this->temp_css .= $temp_css;
  318 + }
  319 +
  320 + private function genHtmlPieceCode($name) {
  321 + // if filename contain "_hover" add the part of code
  322 + if(strpos($name,"_hover")===false) {
  323 + $temp_html = '<h3>class: '.$name.'</h3>';
  324 + $temp_html .= '<div class="'.$name.'">';
  325 + $temp_html .= '</div>';
  326 + $this->temp_html .= $temp_html;
  327 + }
  328 + }
  329 +
  330 + private function saveSprite() {
  331 + imagepng($this->im,$this->folders_config['destiny']['sprites'],3);
  332 + return $this->im;
  333 + imagedestroy($this->im);
  334 + }
  335 +
  336 + private function saveCss() {
  337 + $css_path = $this->folders_config['destiny']['styles'];
  338 + file_put_contents($css_path,$this->css_init.$this->temp_css);
  339 + }
  340 +
  341 + private function saveHtml() {
  342 + $html_path = $this->folders_config['destiny']['example'];
  343 + $html = '<link rel="stylesheet" href="'.$this->folders_config['destiny']['ini_path'].$this->folders_config['destiny']['styles'].'">'.$this->temp_html;
  344 + file_put_contents($html_path,$html);
  345 + }
  346 +
  347 +
  348 + /**
  349 + * Set the image temp result
  350 + * @var object $temp
  351 + * @return object
  352 + */
  353 + private function setTemp($temp)
  354 + {
  355 + return $this->temp = $temp;
  356 + }
  357 +
  358 + /**
  359 + * Get the image temp result
  360 + *
  361 + * @return object
  362 + */
  363 + private function getImageTemp()
  364 + {
  365 + return $this->temp;
  366 + }
  367 +
  368 + /**
  369 + * Set the image result
  370 + * @var object $image
  371 + * @return object
  372 + */
  373 + private function setImage($image)
  374 + {
  375 + return $this->im = $image;
  376 + }
  377 +
  378 + /**
  379 + * Get the image result
  380 + *
  381 + * @return object
  382 + */
  383 + private function getImage()
  384 + {
  385 + return $this->im;
  386 + }
  387 +
  388 + /**
  389 + * Set sprites array
  390 + *
  391 + * @return array
  392 + */
  393 + private function setSprite($sprites)
  394 + {
  395 + return $this->sprites = $sprites;
  396 + }
  397 +
  398 + /**
  399 + * Get sprites array
  400 + *
  401 + * @return array
  402 + */
  403 + private function getSprites()
  404 + {
  405 + return $this->sprites;
  406 + }
  407 +
  408 + /**
  409 + * Set css obfuscation
  410 + *
  411 + * @return string
  412 + */
  413 + public function setMinization($obs = true) {
  414 + if($obs) $this->temp_min_sep = '';
  415 + else $this->temp_min_sep = "\n";
  416 + }
  417 +
  418 + /**
  419 + * Set css init
  420 + *
  421 + * @return string
  422 + */
  423 + public function setCssInit($style) {
  424 + $this->css_init = $style.$this->temp_min_sep;
  425 + }
  426 +
  427 + /**
  428 + * Set folder config array
  429 + *
  430 + * @return array
  431 + */
  432 + public function setFoldersConfig($config)
  433 + {
  434 + return $this->folders_config = $config;
  435 + }
  436 +
  437 + }
... ...