Blame view

php/classes/CatalogCacheMgr.php 1.89 KB
d18b535d   elena   catalog draft + c...
1
2
3
4
5
<?php

/**
 * @class CatalogCacheMgr
 */
5446b8f0   Benjamin Renard   Move CacheTools i...
6

5446b8f0   Benjamin Renard   Move CacheTools i...
7
class CatalogCacheMgr extends TimeTableCacheMgr
d18b535d   elena   catalog draft + c...
8
{
ba9b1b7d   Benjamin Renard   Rework of TT and ...
9
	const DEFAULT_PARAM_ID_PREFIX = 'cat_param_id_';
d18b535d   elena   catalog draft + c...
10
11

	function __construct() {
0fea5567   Benjamin Renard   First step for re...
12
		$this->objectMgr  = new CatalogMgr();
d18b535d   elena   catalog draft + c...
13
	}
5446b8f0   Benjamin Renard   Move CacheTools i...
14

0fea5567   Benjamin Renard   First step for re...
15
16
17
18
	protected function getCacheFileName() {
	  return "cacheCat";
	}

ba9b1b7d   Benjamin Renard   Rework of TT and ...
19
	protected function resetCache($options = array()) {
0fea5567   Benjamin Renard   First step for re...
20
    $this->cache = new CatalogCacheObject();
ba9b1b7d   Benjamin Renard   Rework of TT and ...
21
22
23
24
		if (!empty($options['nparams'])) {
			for ($i = 0; $i < (int)$options['nparams']; $i++) {
				$this->cache->addParameter(CatalogCacheMgr::DEFAULT_PARAM_ID_PREFIX.(string)($i+1), 'column_'.(string)($i+1), 1, 0);
			}
342b20ca   Benjamin Renard   Fix inheritence b...
25
		}
ba9b1b7d   Benjamin Renard   Rework of TT and ...
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
		else if (!empty($options['parameters'])) {
			$index = 0;
			foreach ($options['parameters'] as $parameter) {
				if (array_key_exists('id',$parameter) && !empty($parameter['id'])) {
					$id = $parameter['id'];
				}
				else if (array_key_exists('ID',$parameter) && !empty($parameter['ID'])) {
					$id = $parameter['ID'];
				}
				else {
					$id = 'cat_param_id_'.$index;
				}
				$this->cache->addParameter($id, $parameter['name'], intval($parameter['size']), intval($parameter['type']));
				++$index;
			}
342b20ca   Benjamin Renard   Fix inheritence b...
41
		}
ba9b1b7d   Benjamin Renard   Rework of TT and ...
42
43
		return array('parameters' => $this->cache->getParametersInfo());
  }
342b20ca   Benjamin Renard   Fix inheritence b...
44

42e2e019   Benjamin Renard   Next step for cac...
45
46
	protected function loadAdditionalDescription($options) {
		$params_desc = $this->objectMgr->getCatalogParamDescription($options);
342b20ca   Benjamin Renard   Fix inheritence b...
47
		if (!$params_desc['success']) {
ba9b1b7d   Benjamin Renard   Rework of TT and ...
48
			return array();
901ba3f3   Elena.Budnik   upload catalog
49
		}
ba9b1b7d   Benjamin Renard   Rework of TT and ...
50
		return array('parameters' => $params_desc['parameters']);
d18b535d   elena   catalog draft + c...
51
	}
5446b8f0   Benjamin Renard   Move CacheTools i...
52

e82af71b   elena   catalog draft
53

342b20ca   Benjamin Renard   Fix inheritence b...
54
	public function initFromUploadedFile($name, $format)
5446b8f0   Benjamin Renard   Move CacheTools i...
55
	{
342b20ca   Benjamin Renard   Fix inheritence b...
56
57
58
		$result = parent::initFromUploadedFile($name, $format);
		if (!$result['success']) {
			return $result;
d18b535d   elena   catalog draft + c...
59
		}
5446b8f0   Benjamin Renard   Move CacheTools i...
60

ba9b1b7d   Benjamin Renard   Rework of TT and ...
61
62
63
64
65
		$info = $this->objectMgr->getUploadedObject($name, $format,TRUE);
		foreach ($info['parameters'] as $parameter) {
			$this->cache->addParameter($parameter['id'], $parameter['name'], intval($parameter['size']), intval($parameter['type']));
		}

53048303   Benjamin Renard   Cleanup TimeTable...
66
		return $result+ array('parameters' => $info['parameters']);
f9c8b272   elena   edit catalog
67
	}
342b20ca   Benjamin Renard   Fix inheritence b...
68
69

}
5446b8f0   Benjamin Renard   Move CacheTools i...
70
?>