1 | <?php |
||
3 | class ar_template_filestore extends arBase { |
||
4 | |||
5 | private function getFilestore() { |
||
6 | $context = ar::context()->getObject(); |
||
7 | if(isset($context)) { |
||
8 | $templates = $context->store->get_filestore("templates"); |
||
9 | } else { |
||
10 | global $store; |
||
11 | $templates = $store->get_filestore("templates"); |
||
12 | } |
||
13 | return $templates; |
||
14 | } |
||
15 | |||
16 | private function pathToId($path) { |
||
17 | $context = ar::context()->getObject(); |
||
18 | |||
19 | if($context->path == $path) { |
||
20 | $result = $context->id; |
||
21 | } else { |
||
22 | $result = $context->loadConfig($path)->id; |
||
23 | } |
||
24 | return $result; |
||
25 | } |
||
26 | |||
27 | private function getConfig($path) { |
||
28 | $context = ar::context()->getObject(); |
||
29 | return $context->loadConfig($path); |
||
30 | } |
||
31 | |||
32 | public function get($path, $name){ |
||
33 | $fs = $this->getfilestore(); |
||
34 | $id = $this->pathtoid($path); |
||
35 | |||
36 | return ( |
||
37 | $fs->import($id, $name) |
||
38 | ); |
||
39 | } |
||
40 | |||
41 | public function save($path, $name, $template, $local=null, $private=null) { |
||
44 | |||
45 | public function load($path, $name) { |
||
51 | |||
52 | public function ls($path) { |
||
53 | $result = []; |
||
54 | $fs = $this->getFilestore(); |
||
55 | $id = $this->pathToId($path); |
||
56 | |||
57 | $config = $this->getConfig($path); |
||
58 | |||
59 | $templates = $config->pinpTemplates; |
||
60 | if (isset($templates)) foreach($templates as $type => $names) { |
||
61 | if (isset($names)) foreach($names as $name => $languages) { |
||
62 | if (isset($languages)) foreach($languages as $language => $id ) { |
||
63 | $tempname = sprintf("%s.%s.%s",$type,$name,$language); |
||
64 | list($maintype,$subtype) = explode('.', $type, 2); |
||
65 | if(!isset($result[$name])) { |
||
66 | $result[$name] = []; |
||
67 | } |
||
68 | $result[$name][] = [ |
||
69 | 'id' => $config->id, |
||
70 | 'path' => $path, |
||
71 | 'type' => $maintype, |
||
72 | 'subtype' => $subtype, |
||
73 | 'name' => $name, |
||
74 | 'filename' => $tempname, |
||
75 | 'language' => $language, |
||
76 | 'private' => isset($config->privatetemplates[$type][$name]), |
||
77 | 'local' => !isset($config->localTemplates[$type][$name][$language]), |
||
78 | ]; |
||
79 | } |
||
80 | } |
||
81 | } |
||
82 | return $result; |
||
83 | |||
84 | } |
||
85 | |||
86 | public function rm($path, $name){ |
||
94 | |||
95 | public function exists($path, $name) { |
||
96 | $fs = $this->getFilestore(); |
||
97 | $id = $this->pathToId($path); |
||
98 | |||
99 | return ( |
||
100 | $fs->exists($id, $name . '.inc') |
||
101 | ); |
||
102 | } |
||
103 | |||
104 | public function compile($path, $name) { |
||
107 | } |
||
108 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.