1 | <?php |
---|
2 | class floPure |
---|
3 | { |
---|
4 | function floPure_version_compare($a, $b) |
---|
5 | { |
---|
6 | $pattern = array('/([a-z])/ei', '/\.+/', '/\.\Z|\A\./'); |
---|
7 | $replacement = array( "'.'.intval('\\1', 36).'.'", '.', ''); |
---|
8 | |
---|
9 | $array = preg_replace($pattern, $replacement, array($a, $b)); |
---|
10 | |
---|
11 | return version_compare($array[0], $array[1], '>='); |
---|
12 | } |
---|
13 | function theme_version_search($dir) |
---|
14 | { |
---|
15 | global $template, $page; |
---|
16 | load_language('template.lang', PHPWG_ROOT_PATH.'template/floPure/tools/'); |
---|
17 | $header_msgs = array(); |
---|
18 | $dh = opendir ($dir); |
---|
19 | while (($file = readdir ($dh)) !== false ) { |
---|
20 | if ($file !== '.' && $file !== '..' && $file !== '.svn') { // enleve svn |
---|
21 | $path =$dir.'/'.$file; |
---|
22 | if (is_dir($path)) { |
---|
23 | $this->theme_version_search($path); |
---|
24 | } |
---|
25 | else |
---|
26 | { |
---|
27 | $page = explode('.', $file); |
---|
28 | $nb = count($page); |
---|
29 | $nom_fichier = $page[0]; |
---|
30 | for ($i = 1; $i < $nb-1; $i++){ |
---|
31 | $nom_fichier .= '.'.$page[$i]; |
---|
32 | } |
---|
33 | if(isset($page[1])){ |
---|
34 | $ext_fichier = $page[$nb-1]; |
---|
35 | } |
---|
36 | else { |
---|
37 | $ext_fichier = ''; |
---|
38 | } |
---|
39 | if($nom_fichier == 'themeconf.inc' and $ext_fichier == 'php') { |
---|
40 | include($path); |
---|
41 | if (isset($themeconf['eid'])) |
---|
42 | { |
---|
43 | if($this->is_not_up_to_date($themeconf['version'],$themeconf['eid']) ) |
---|
44 | { |
---|
45 | |
---|
46 | $msg=l10n('theme_update_needed_1').$themeconf['theme'].l10n('theme_update_needed_2').$themeconf['eid'].l10n('theme_update_needed_3').$themeconf['theme'].l10n('theme_update_needed_4'); |
---|
47 | $template->append('header_msgs', $msg); |
---|
48 | } |
---|
49 | } |
---|
50 | |
---|
51 | } |
---|
52 | } |
---|
53 | } |
---|
54 | } |
---|
55 | closedir ($dh); // on ferme le repertoire courant |
---|
56 | } |
---|
57 | function is_not_up_to_date($v_local, $eid) |
---|
58 | { |
---|
59 | |
---|
60 | global $template, $user, $page; |
---|
61 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
62 | load_language('template.lang', PHPWG_ROOT_PATH.'template/floPure/tools/'); |
---|
63 | |
---|
64 | // Retrieve PEM versions |
---|
65 | $version = PHPWG_VERSION; |
---|
66 | $versions_to_check = array(); |
---|
67 | $url = PEM_URL . '/api/get_version_list.php?category_id=12&format=php'; |
---|
68 | if (fetchRemote($url, $result) and $pem_versions = @unserialize($result)) |
---|
69 | { |
---|
70 | if (!preg_match('/^\d+\.\d+\.\d+/', $version)) |
---|
71 | { |
---|
72 | $version = $pem_versions[0]['name']; |
---|
73 | } |
---|
74 | $branch = substr($version, 0, strrpos($version, '.')); |
---|
75 | foreach ($pem_versions as $pem_version) |
---|
76 | { |
---|
77 | if (strpos($pem_version['name'], $branch) === 0) |
---|
78 | { |
---|
79 | $versions_to_check[] = $pem_version['id']; |
---|
80 | } |
---|
81 | } |
---|
82 | } |
---|
83 | |
---|
84 | // Retrieve PEM template infos |
---|
85 | $url = PEM_URL . '/api/get_revision_list.php?format=php&last_revision_only=true'; |
---|
86 | $url .= '&version=' . implode(',', $versions_to_check); |
---|
87 | //$url .= '&lang=' . substr($user['language'], 0, 2); |
---|
88 | $url .= '&extension_include='.$eid; |
---|
89 | fetchRemote($url, $result); |
---|
90 | $pem_res = @unserialize($result); |
---|
91 | foreach($pem_res as $pem_floPure) |
---|
92 | { |
---|
93 | if (!is_array($pem_floPure)) |
---|
94 | { |
---|
95 | $template->assign( |
---|
96 | array( |
---|
97 | 'erreur' => 'erreur url : '.$url, |
---|
98 | ) |
---|
99 | ); |
---|
100 | } |
---|
101 | if (!$this->floPure_version_compare($v_local, $pem_floPure['revision_name'])) |
---|
102 | { |
---|
103 | return true; |
---|
104 | } |
---|
105 | else |
---|
106 | { |
---|
107 | return false; |
---|
108 | } |
---|
109 | } |
---|
110 | } |
---|
111 | |
---|
112 | } |
---|
113 | ?> |
---|