dbFields = array( 'label'=>'Hit Counter', 'showUniqueVisitors'=>false ); } public function form() { global $L; // Check if the plugin Simple Stats is activated if (!pluginActivated('pluginSimpleStats')) { // Show an alert about the dependency of the plugin $html = ''; // Hidden form buttons. Save and Cancel buttons. $this->formButtons = false; return $html; } // Show the description of the plugin in the settings $html = ''; // Label of the plugin to show in the sidebar $html .= '
'; $html .= ''; $html .= ''; $html .= ''.$L->get('This title is almost always used in the sidebar of the site').''; $html .= '
'; // Form "select" element for enable or disable Unique visitors properties $html .= '
'; $html .= ''; $html .= ''; $html .= '
'; return $html; } public function siteSidebar() { // Init counter to 0 $counter = 0; // Check if the plugin Simple Stats is activated if (pluginActivated('pluginSimpleStats')) { // Get the object of the plugin Simple Stats global $plugins; $simpleStats = $plugins['all']['pluginSimpleStats']; $currentDate = Date::current('Y-m-d'); if ($this->getValue('showUniqueVisitors')) { // Get the unique visitors from today $counter = $simpleStats->uniqueVisitors($currentDate); } else { // Get the visits from today $counter = $simpleStats->visits($currentDate); } } // Show in the sidebar the number of visitors $html = '
'; $html .= '

'.$this->getValue('label').'

'; $html .= '
'; $html .= '
'.$counter.'
'; $html .= '
'; $html .= '
'; return $html; } }