Cheetah
All Classes Namespaces Files Functions Variables Pages
ChWsbAdminDashboard.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import('ChWsbMailBox');
9 
23 {
24  private $aBlocks;
25 
29  function __construct()
30  {
31  if (isset($_POST['hide_admin_help']) && $_POST['hide_admin_help']) {
32  setParam('sys_show_admin_help', '');
33  echo '1';
34  exit;
35  }
36 
37  $this->aBlocks = array(
38  'help' => 'on' == getParam('sys_show_admin_help') ? true : false,
39  'links' => true,
40  'charts' => true,
41  'stats' => true,
42  );
43  }
44 
45  function getCode()
46  {
47  $sContent = '';
48 
49  foreach($this->aBlocks as $sName => $bActive) {
50  if(!$bActive)
51  continue;
52 
53  $sMethod = 'getCode' . str_replace(' ', '', ucwords(str_replace('_', ' ', $sName)));
54  if(!method_exists($this, $sMethod))
55  continue;
56 
57  $sContent .= $this->$sMethod();
58  }
59 
60  return $sContent;
61  }
62  function getCodeLinks()
63  {
64  $sContent = $GLOBALS['oAdmTemplate']->parseHtmlByName('dashboard_links.html', array());
65  return DesignBoxAdmin(_t('_adm_box_cpt_links'), $sContent, '', '', 11);
66  }
67  function getCodeHelp()
68  {
69  $sContent = $GLOBALS['oAdmTemplate']->parseHtmlByName('dashboard_help.html', array(
70  'content' => _t('_adm_txt_dashboard_help', CH_WSB_URL_ADMIN, CH_WSB_URL_ROOT),
71  ));
72 
73  return DesignBoxAdmin(_t('_adm_box_cpt_help'), $sContent, '', '', 11);
74  }
75  function getCodeCharts()
76  {
77  $aObjects = $GLOBALS['MySQL']->getAll("SELECT * FROM `sys_objects_charts` WHERE `active` = 1 ORDER BY `order` ASC");
78  foreach ($aObjects as $k => $a)
79  $aObjects[$k]['title'] = _t($a['title']);
80  $sContent = $GLOBALS['oAdmTemplate']->parseHtmlByName('dashboard_charts.html', array(
81  'proto' => ch_proto(),
82  'admin_url' => CH_WSB_URL_ADMIN,
83  'from' => date('Y-m-d', time() - 30*24*60*60),
84  'to' => date('Y-m-d', time()),
85  'ch_repeat:objects' => $aObjects,
86  ));
87 
88  // add datepicker
89  ch_import('ChTemplFormView');
90  $oForm = new ChTemplFormView(array());
91  $oForm->addCssJs(true);
92 
93  return DesignBoxAdmin(_t('_adm_box_cpt_charts'), $sContent, '', '', 11);
94  }
95  function getCodeStats()
96  {
97  $aStats = getSiteStatArray();
98 
99  $aTmplItemsCom = $aTmplItemsImp = array();
100  foreach($aStats as $aStat) {
101  $mixedItem = $this->_getStatsItem($aStat);
102  if($mixedItem !== false)
103  $aTmplItemsCom[] = $mixedItem;
104 
105  $mixedItem = $this->_getStatsItem($aStat, 'adm_');
106  if($mixedItem !== false)
107  $aTmplItemsImp[] = $mixedItem;
108  }
109 
110  $aCommonChartData = array();
111  foreach ($aTmplItemsCom as $r)
112  $aCommonChartData[] = array(
113  'value' => $r['number'],
114  'color' => '#' . dechex(rand(0x000000, 0xFFFFFF)),
115  'highlight' => '',
116  'label' => ch_js_string($r['caption'], CH_ESCAPE_STR_APOS),
117  );
118  $sCommonChartData = json_encode($aCommonChartData);
119 
120  $GLOBALS ['oAdmTemplate']->addJsSystem(array(
121  'chart.min.js',
122  ));
123 
124  $sContent = $GLOBALS['oAdmTemplate']->parseHtmlByName('dashboard_stats.html', array(
125  'ch_repeat:items_common' => $aTmplItemsCom,
126  'ch_repeat:items_important' => $aTmplItemsImp,
127  'common_chart_data' => $sCommonChartData,
128  ));
129  return DesignBoxAdmin(_t('_adm_box_cpt_content'), $sContent, '', '', 11);
130  }
131  function _getStatsItem($aStat, $sPrefix = '')
132  {
133  if(empty($aStat[$sPrefix . 'query']))
134  return false;
135 
136  $iNumber = (int)$GLOBALS['MySQL']->getOne($aStat[$sPrefix . 'query']);
137  if(!empty($sPrefix) && $iNumber == 0)
138  return false;
139 
140  $sCaption = _t('_' . $aStat['capt'] . ($sPrefix != '' ? '_' . trim($sPrefix, '_') . '_stats' : ''));
141  $bLink = !empty($aStat[$sPrefix . 'link']);
142  if($bLink) {
143  $aStat[$sPrefix . 'link'] = str_replace(array('{site_url}', '{admin_url}'), array(CH_WSB_URL_ROOT, CH_WSB_URL_ADMIN), $aStat[$sPrefix . 'link']);
144  if(substr($aStat[$sPrefix . 'link'], 0, 4) != 'http')
145  $aStat[$sPrefix . 'link'] = CH_WSB_URL_ROOT . $aStat[$sPrefix . 'link'];
146  }
147 
148  return array(
149  'number' => $iNumber,
150  'caption' => $sCaption,
151  'ch_if:show_link' => array(
152  'condition' => $bLink,
153  'content' => array(
154  'link' => $aStat[$sPrefix . 'link'],
155  'number' => $iNumber,
156  'caption' => $sCaption
157  )
158  ),
159  'ch_if:show_text' => array(
160  'condition' => !$bLink,
161  'content' => array(
162  'number' => $iNumber,
163  'caption' => $sCaption
164  )
165  )
166  );
167  }
168 }
ChTemplFormView
Definition: ChTemplFormView.php:11
ch_js_string
ch_js_string($mixedInput, $iQuoteType=CH_ESCAPE_STR_AUTO)
Definition: utils.inc.php:1294
ChWsbAdminDashboard\getCodeLinks
getCodeLinks()
Definition: ChWsbAdminDashboard.php:62
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
ChWsbAdminDashboard\getCode
getCode()
Definition: ChWsbAdminDashboard.php:45
ChWsbAdminDashboard\getCodeHelp
getCodeHelp()
Definition: ChWsbAdminDashboard.php:67
php
$oForm
$oForm
Definition: host_tools.php:42
ChWsbAdminDashboard\_getStatsItem
_getStatsItem($aStat, $sPrefix='')
Definition: ChWsbAdminDashboard.php:131
DesignBoxAdmin
DesignBoxAdmin($sTitle, $sContent, $mixedTopItems='', $sBottomItems='', $iIndex=1)
Definition: admin_design.inc.php:50
exit
exit
Definition: cart.php:21
getParam
getParam($sParamName, $bUseCache=true)
Definition: db.inc.php:130
$sContent
$sContent
Definition: bottom_menu_compose.php:169
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
time
that in the case of a Adaptation or at a minimum such credit will if a credit for all contributing authors of the Adaptation or Collection then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors For the avoidance of You may only use the credit required by this Section for the purpose of attribution in the manner set out above by exercising Your rights under this You may not implicitly or explicitly assert or imply any connection sponsorship or endorsement by the Original Licensor and or Attribution as of You or Your use of the without the express prior written permission of the Original Licensor and or Attribution Parties Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable if You Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or You must not modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author s honor or reputation Licensor agrees that in those in which any exercise of the right granted in modification or other derogatory action prejudicial to the Original Author s honor and the Licensor will waive or not as this to the fullest extent permitted by the applicable national to enable You to reasonably exercise Your right under Warranties and Disclaimer UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN LICENSOR OFFERS THE WORK AS IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE STATUTORY OR WITHOUT WARRANTIES OF FITNESS FOR A PARTICULAR OR THE ABSENCE OF LATENT OR OTHER OR THE PRESENCE OF ABSENCE OF WHETHER OR NOT DISCOVERABLE SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED SO SUCH EXCLUSION MAY NOT APPLY TO YOU Limitation on Liability EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES Termination This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License Individuals or entities who have received Adaptations or Collections from You under this will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses and will survive any termination of this License Subject to the above terms and the license granted here is Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time
Definition: license.txt:56
ch_proto
ch_proto($sUrl=CH_WSB_URL_ROOT)
Definition: utils.inc.php:1848
getSiteStatArray
getSiteStatArray()
Definition: utils.inc.php:1184
CH_ESCAPE_STR_APOS
const CH_ESCAPE_STR_APOS
escape apostrophes only, for js strings enclosed in apostrophes, for use in
Definition: utils.inc.php:33
setParam
setParam($sParamName, $sParamValue)
Definition: db.inc.php:149
$sCaption
$sCaption
Definition: tellfriend.php:39
ChWsbAdminDashboard
Definition: ChWsbAdminDashboard.php:23
ChWsbAdminDashboard\getCodeCharts
getCodeCharts()
Definition: ChWsbAdminDashboard.php:75
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
$sName
$sName
Definition: ChWsbAdminTools.php:853
ChWsbAdminDashboard\getCodeStats
getCodeStats()
Definition: ChWsbAdminDashboard.php:95
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10
ChWsbAdminDashboard\__construct
__construct()
Definition: ChWsbAdminDashboard.php:29