-
Notifications
You must be signed in to change notification settings - Fork 1
/
JSONIndex.php
61 lines (50 loc) · 1.36 KB
/
JSONIndex.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
namespace Nelliel\API\JSON;
if (!defined('NELLIEL_VERSION'))
{
die("NOPE.AVI");
}
class JSONIndex extends JSONOutput
{
function __construct($domain, $file_handler)
{
$this->domain = $domain;
$this->file_handler = $file_handler;
$this->data_array['index'] = array();
}
public function prepareData($data, $store = false)
{
$index_array = array();
$index_array['thread_count'] = nel_cast_to_datatype($data['thread_count'], 'integer');
$index_array = nel_plugins()->processHook('nel-json-prepare-post', [$data], $index_array);
if ($store)
{
$this->data_array['index'] = $index_array;
}
return $index_array;
}
public function storeData($data)
{
$this->data_array['index'] = $data;
}
public function retrieveData($all_data = null)
{
if($all_data)
{
return $this->data_array;
}
else
{
return $this->data_array['index'];
}
}
public function writeStoredData($file_path, $file_name)
{
$json_data = json_encode($this->data_array);
$this->file_handler->writeFile($file_path . $file_name . JSON_EXT, $json_data);
}
public function addThreadData($thread_data)
{
$this->data_array['thread-list'][] = $thread_data;
}
}