1 | <?php |
---|
2 | /* |
---|
3 | * ----------------------------------------------------------------------------- |
---|
4 | * Plugin Name: EStat |
---|
5 | * ----------------------------------------------------------------------------- |
---|
6 | * Author : Grum |
---|
7 | * email : grum@piwigo.org |
---|
8 | * website : http://www.grum.fr |
---|
9 | * |
---|
10 | * << May the Little SpaceFrog be with you! >> |
---|
11 | * |
---|
12 | * ----------------------------------------------------------------------------- |
---|
13 | * See main.inc.php for release information |
---|
14 | * |
---|
15 | * AIPInstall class => install process page when the plugin is used for the |
---|
16 | * first time |
---|
17 | * ----------------------------------------------------------------------------- |
---|
18 | */ |
---|
19 | |
---|
20 | |
---|
21 | if(!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
22 | |
---|
23 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTabSheet.class.inc.php'); |
---|
24 | include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); |
---|
25 | include_once('estat_root.class.inc.php'); |
---|
26 | |
---|
27 | |
---|
28 | class EStat_AIPInstall extends EStat_root |
---|
29 | { |
---|
30 | protected $tabsheet; |
---|
31 | |
---|
32 | public function __construct($prefixeTable, $filelocation) |
---|
33 | { |
---|
34 | parent::__construct($prefixeTable, $filelocation); |
---|
35 | $this->loadConfig(); |
---|
36 | $this->initEvents(); |
---|
37 | |
---|
38 | $this->tabsheet = new tabsheet(); |
---|
39 | |
---|
40 | if($this->config['plugin.newInstall']=='y') |
---|
41 | { |
---|
42 | $this->tabsheet->add('install', |
---|
43 | l10n('estat_install'), |
---|
44 | $this->getAdminLink()."-install"); |
---|
45 | } |
---|
46 | else |
---|
47 | { |
---|
48 | $this->tabsheet->add('update', |
---|
49 | l10n('estat_update'), |
---|
50 | $this->getAdminLink()."-update"); |
---|
51 | } |
---|
52 | } |
---|
53 | |
---|
54 | public function __destruct() |
---|
55 | { |
---|
56 | unset($this->tabsheet); |
---|
57 | parent::__destruct(); |
---|
58 | } |
---|
59 | |
---|
60 | |
---|
61 | public function loadCSS() |
---|
62 | { |
---|
63 | global $template; |
---|
64 | |
---|
65 | parent::loadCSS(); |
---|
66 | GPCCore::addUI('gpcCSS'); |
---|
67 | GPCCore::addHeaderCSS('estat.css', 'plugins/'.$this->getDirectory().'/'.$this->getPluginNameFiles().".css"); |
---|
68 | GPCCore::addHeaderCSS('estat.cssT', 'plugins/'.$this->getDirectory().'/'.$this->getPluginNameFiles().'_'.$template->get_themeconf('name').".css"); |
---|
69 | } |
---|
70 | |
---|
71 | |
---|
72 | /* |
---|
73 | display administration page |
---|
74 | */ |
---|
75 | public function manage() |
---|
76 | { |
---|
77 | global $template, $lang; |
---|
78 | |
---|
79 | // load JS scripts |
---|
80 | GPCCore::setTemplateToken(); |
---|
81 | GPCCore::addUI('inputCheckbox,progressArea'); |
---|
82 | GPCCore::addHeaderJS('estat.im', ESTAT_PATH.'js/estatIM.js', array('gpc.progressArea')); |
---|
83 | |
---|
84 | $template->set_filename('plugin_admin_content', dirname($this->getFileLocation())."/admin/estat_install_page.tpl"); |
---|
85 | |
---|
86 | // set tabsheet |
---|
87 | $this->tabsheet->select('install'); |
---|
88 | $this->tabsheet->assign(); |
---|
89 | $selected_tab=$this->tabsheet->get_selected(); |
---|
90 | $template->assign($this->tabsheet->get_titlename(), "[".$selected_tab['caption']."]"); |
---|
91 | |
---|
92 | // load IP country file properties |
---|
93 | $dbCountry=new StatDBCountry($this->fileStatDir, self::FILE_COUNTRY); |
---|
94 | $ipFileInfo=$dbCountry->getIpFileInfo(ESTAT_PATH.'data/ipCountry.bin'); |
---|
95 | |
---|
96 | // get Piwigo history table properties |
---|
97 | $piwigoHistory=$this->getPiwigoHistoryInfo(); |
---|
98 | |
---|
99 | $periods=array(); |
---|
100 | foreach($piwigoHistory['periods'] as $period=>$nbEvents) |
---|
101 | { |
---|
102 | $year=substr($period, 0, 4); |
---|
103 | $month=substr($period, 5); |
---|
104 | $periods[$period]=array( |
---|
105 | 'label' => $lang['month'][$month*1].' '.$year, |
---|
106 | 'nbEvents' => $nbEvents |
---|
107 | ); |
---|
108 | } |
---|
109 | |
---|
110 | // set template var |
---|
111 | $pluginInfo=array( |
---|
112 | 'ESTAT_VERSION' => "<i>".$this->getPluginName()."</i> ".l10n('estat_release').ESTAT_VERSION, |
---|
113 | 'ESTAT_PAGE' => 'install', |
---|
114 | 'PATH' => ESTAT_PATH, |
---|
115 | 'urlRequest' => $this->getAdminLink('ajax'), |
---|
116 | 'importLog' => ($this->config['plugin.newInstall']=='y')?true:false, |
---|
117 | 'ipNbRecords' => $ipFileInfo['nbRecords'], |
---|
118 | 'l10n_piwigoHistory' => sprintf(l10n('estat_piwigo_history_size'), $piwigoHistory['nbLogs'], $piwigoHistory['dateMin'], $piwigoHistory['dateMax']), |
---|
119 | 'piwigoHistoryPeriods' => $periods, |
---|
120 | 'l10n_logImportInProgress' => str_replace('%s', '<span id=\'iCurrentPeriod\'></span>', l10n('estat_log_import_period')) |
---|
121 | ); |
---|
122 | |
---|
123 | $template->assign('plugin', $pluginInfo); |
---|
124 | |
---|
125 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
126 | } |
---|
127 | |
---|
128 | |
---|
129 | |
---|
130 | |
---|
131 | } //class |
---|
132 | |
---|
133 | |
---|
134 | ?> |
---|