1 | <?php |
---|
2 | //include_once 'preg_find.php'; |
---|
3 | include_once 'get_locale.php'; |
---|
4 | //obtener el locale |
---|
5 | $locale= get_locale(); |
---|
6 | |
---|
7 | // buscar links |
---|
8 | $link_dir="./links"; |
---|
9 | |
---|
10 | // scanning for common resources |
---|
11 | $easysites=array(); |
---|
12 | foreach (scandir($link_dir) as $dir){ |
---|
13 | if (substr ( $dir, strlen($dir)-5,5)==".json" && substr ( $dir, 0,5)!="easy-") ParseFile($link_dir."/".$dir, $locale); |
---|
14 | else array_push($easysites, $dir); |
---|
15 | } |
---|
16 | foreach ($easysites as $dir){ |
---|
17 | ParseFile($link_dir."/".$dir, $locale); |
---|
18 | } |
---|
19 | |
---|
20 | |
---|
21 | function ParseFile($file, $locale){ |
---|
22 | $string = file_get_contents($file); |
---|
23 | |
---|
24 | $json=json_decode($string,true); |
---|
25 | |
---|
26 | try{ |
---|
27 | $jsonIterator = new RecursiveIteratorIterator( |
---|
28 | new RecursiveArrayIterator($json, TRUE), |
---|
29 | RecursiveIteratorIterator::SELF_FIRST); |
---|
30 | |
---|
31 | $savingname=false; // flag to ask if we are parsing name or description |
---|
32 | |
---|
33 | foreach ($jsonIterator as $key => $val) { |
---|
34 | if ($key=="linkid") $linkid=$val; |
---|
35 | if ($key=="link") $link=$val; |
---|
36 | if ($key=="icon") $icon=$val; |
---|
37 | if ($key=="type") $type=$val; |
---|
38 | if ($key=="fonticon") $fonticon=$val; |
---|
39 | if ($key=="name") |
---|
40 | $savingname=true; |
---|
41 | if ($key=="description") |
---|
42 | $savingname=false; |
---|
43 | if ($key==$locale) |
---|
44 | if ($savingname==true) $name=$val; |
---|
45 | else $description=$val; |
---|
46 | |
---|
47 | |
---|
48 | } // for each |
---|
49 | |
---|
50 | drawIcon($linkid, $link, $icon, $fonticon,$name, $description, $file, $type); |
---|
51 | |
---|
52 | |
---|
53 | } catch (Exception $e){ |
---|
54 | |
---|
55 | |
---|
56 | } |
---|
57 | } |
---|
58 | |
---|
59 | function drawIcon($linkid, $link, $icon, $fonticon, $name, $description, $file,$type){ |
---|
60 | |
---|
61 | // check if it is a easy site |
---|
62 | $path=explode("/", $file); |
---|
63 | if (substr($path[count($path)-1],0,5)=="easy-" && $icon=="") $icon="easysite.png"; |
---|
64 | |
---|
65 | |
---|
66 | if ($icon!="" && $icon!="easysite.png") echo "<div class='grid-item grid-item--width2 ".$type."' content='link-".$linkid."'>"; |
---|
67 | else echo "<div class='grid-item grid-item--width1 $type' >"; |
---|
68 | //if ($icon!="" && $icon!="easysite.png") echo "<li data-sizex='2' data-sizey='1' >"; |
---|
69 | //else echo "<li data-sizex='1' data-sizey='1' >"; |
---|
70 | echo "<div class='linkcontainer flip-container' target='$link' id='link-".$linkid."' ontouchstart=\"this.classList.toggle('hover');\">"; |
---|
71 | echo "<div class='flipper'>"; |
---|
72 | echo "<div class='front' style='background-image:url(icons/".$icon.")'>"; |
---|
73 | if ($icon=="easysite.png") echo "<div class='linktitle' style='color:#ffffff'>".$name."</div>"; |
---|
74 | echo "</div>"; |
---|
75 | |
---|
76 | echo "<div class='back' style='background-image:url(icons/".$icon.")'>"; |
---|
77 | echo "<div class='linktitle'>".$name."</div>"; |
---|
78 | echo "<div class='hr'></div>"; |
---|
79 | echo "<div class='linkdesc'>".$description."</div>"; |
---|
80 | echo "</div>"; |
---|
81 | echo "</div>"; |
---|
82 | echo "</div>"; |
---|
83 | echo "</div>"; |
---|
84 | |
---|
85 | |
---|
86 | |
---|
87 | |
---|
88 | |
---|
89 | } |
---|
90 | |
---|
91 | |
---|
92 | |
---|
93 | ?> |
---|
94 | |
---|