public function display($tpl = null) { $user = JFactory::getUser(); $access = 0; $params = null; if (JRequest::getVar('source', 'component') == 'component') { $menu = JFactory::getApplication()->getMenu()->getItem(JRequest::getInt('Itemid')); $params = $menu->params; $params->set('mode', $menu->query['layout'] == 'image' ? 'image' : 'list'); $params->set('filterType', 'advanced'); $access = $menu->access; } if (JRequest::getVar('source', 'component') == 'module') { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('m.*'); $query->from('#__modules AS m'); $query->where('id = ' . JRequest::getInt('moduleid')); $db->setQuery($query); $module = $db->loadObject(); if ($module != null) { $params = new JRegistry($module->params); $params->set('mode', $params->get('mode', GAnalyticsHelper::isPROMode() ? 'image' : 'list')); if ($module->module == 'mod_ganalytics_admin_stats') { //default it to a different $params->set('type', $params->get('type', 'visits')); } $access = $module->access; } } if ($user->authorise('core.admin') || in_array((int) $access, $user->getAuthorisedViewLevels())) { $this->getModel()->setState('params', $params); $this->params = $params; $this->data = $this->get('StatsData'); $this->profile = $this->get('Profile'); } else { $this->params = $params; $this->data = null; $this->profile = null; JError::raiseWarning(0, 'JERROR_ALERTNOAUTHOR'); } parent::display($tpl); }
function checkPROMode() { $desc = "Cool you use the PRO mode!!"; $status = 'ok'; $solution = ''; if (!GAnalyticsHelper::isPROMode()) { $desc = "You are using the FREE version which doesn't have all the features the PRO version has. <a href=\"http://joomla.digital-peak.com/content/docu/doku.php/id,docu;ganalytics;pro/\" target=\"_blank\">Consider buying</a> the PRO version and get some cool graphical stuff and more."; $status = 'warning'; $solution = '.'; } return array('name' => 'GAnalytics Mode Check', 'description' => $desc, 'status' => $status, 'solution' => $solution); }
public static function convertToJsonResponse($profile, $data = null, $chartType = 'list') { $dataTable = new GvizDataTable(JRequest::getVar('tqx', '')); try { if ($chartType != 'list' && !GAnalyticsHelper::isPROMode()) { $chartType = 'list'; } if ($data === null) { $message = array_shift(JFactory::getApplication()->getMessageQueue()); if (!empty($message) && key_exists('message', $message)) { $message = $message['message']; } else { $message = print_r($message, true); } $dataTable->addError('invalid_request', JText::_('COM_GANALYTICS_JSONDFEED_VIEW_ERROR'), $message); } else { $dataTable->addWarning('other', $chartType); $headers = $data->getColumnHeaders(); //print_R($headers);die; foreach ($headers as $header) { $type = 'string'; if ($header->dataType == 'INTEGER' || $header->dataType == 'FLOAT' || $header->dataType == 'TIME') { $type = 'number'; } if (stripos($header->name, 'ga:date') !== false) { $type = 'date'; } $dataTable->addColumn($header->name, GAnalyticsHelper::translate($header->name), $type); } $dateRange = JRequest::getVar('dateRange', 'day'); //$dateFormat = $params->get('dateFormat', '%d.%m.%Y'); $counter = -1; foreach ($data->getRows() as $item) { $counter++; $rowId = -1; foreach ($item as $index => $value) { $header = $headers[$index]; $formatted = $value; $property = ''; if (stripos($header->name, 'ga:date') !== false) { $value = mktime(0, 0, 0, substr($value, 4, 2), substr($value, 6, 2), substr($value, 0, 4)); $formatted = strftime(GAnalyticsHelper::getComponentParameter('dateFormat', '%d.%m.%Y'), $value); if ($dateRange == 'week' && strftime('%u', $value) > 1 && $counter > 0 && $counter < count($data->getRows()) - 1) { break; } if ($dateRange == 'month' && strftime('%e', $value) > 1 && $counter > 0 && $counter < count($data->getRows()) - 1) { break; } } else { if (stripos($header->name, 'source') !== false && $value != '(direct)' && $chartType == 'list') { $url = $value; foreach ($headers as $index => $tmpHeader) { if (stripos($tmpHeader->name, 'referralPath') !== false && $item[$index] != '(not set)') { $url .= $item[$index]; } } $formatted = '<a href="http://' . $url . '" target="_blank">' . GAnalyticsHelper::trim($value) . '</a>'; } else { if (stripos($header->name, 'country') !== false && $chartType == 'list') { $flag = GAnalyticsHelper::convertCountryNameToISO($value); if (!empty($flag)) { $property = "style: 'background-image:url(\"" . JURI::root() . 'media/com_ganalytics/images/flags/' . strtolower($flag) . ".gif\"); background-repeat: no-repeat;background-position: 5px 4px;padding-left:30px;'"; } } else { if (stripos($header->name, 'pagePath') !== false && $chartType == 'list') { $formatted = '<a href="' . JRoute::_('index.php?option=com_ganalytics&view=page&tmpl=component&gaid=' . $profile->id . '&path=' . base64_encode($value)) . '">' . GAnalyticsHelper::trim($value) . '</a>'; } else { $value = addslashes($value); $formatted = GAnalyticsHelper::trim($value); } } } } if ($rowId == -1) { $rowId = $dataTable->newRow(); } $dataTable->addCell($rowId, $header->name, JText::_($value), JText::_($formatted), $property); } } } } catch (Exception $e) { $dataTable->addError('invalid_request', JText::_('COM_GANALYTICS_JSONDFEED_VIEW_ERROR'), $e->getMessage()); } return $dataTable->toJsonResponse(); }
GAnalyticsHelper::loadjQuery(); jimport('joomla.form.form'); $document = JFactory::getDocument(); $document->addScript((JBrowser::getInstance()->isSSLConnection() ? 'https' : 'http') . '://www.google.com/jsapi'); $document->addScript(JURI::base() . 'components/com_ganalytics/libraries/jquery/ui/jquery-ui.custom.min.js'); $document->addStyleSheet(JURI::base() . 'components/com_ganalytics/libraries/jquery/themes/aristo/jquery-ui.custom.css'); $document->addScript(JURI::base() . 'components/com_ganalytics/libraries/jquery/ext/jquery-cookie.js'); $document->addScript(JURI::base() . 'components/com_ganalytics/libraries/jquery/pnotify/jquery.pnotify.min.js'); $document->addStyleSheet(JURI::base() . 'components/com_ganalytics/libraries/jquery/pnotify/jquery.pnotify.default.css'); $document->addScript(JURI::root() . 'administrator/components/com_ganalytics/libraries/jquery/multiselect/jquery.multiselect2side.js'); $document->addStyleSheet(JURI::root() . 'administrator/components/com_ganalytics/libraries/jquery/multiselect/jquery.multiselect2side.css'); $document->addScript(JURI::base() . 'components/com_ganalytics/libraries/jquery/fancybox/jquery.easing-1.3.pack.js'); $document->addScript(JURI::base() . 'components/com_ganalytics/libraries/jquery/fancybox/jquery.mousewheel-3.0.4.pack.js'); $document->addScript(JURI::base() . 'components/com_ganalytics/libraries/jquery/fancybox/jquery.fancybox-1.3.4.pack.js'); $document->addStyleSheet(JURI::base() . 'components/com_ganalytics/libraries/jquery/fancybox/jquery.fancybox-1.3.4.css'); if (GAnalyticsHelper::isPROMode()) { $document->addScript(JURI::base() . 'components/com_ganalytics/libraries/jquery/ganalytics/chart.js'); } else { $document->addScript(JURI::base() . 'components/com_ganalytics/libraries/jquery/ganalytics/list.js'); } $document->addScript(JURI::base() . 'components/com_ganalytics/views/dashboard/tmpl/default.js'); $document->addStyleSheet(JURI::base() . 'components/com_ganalytics/views/dashboard/tmpl/default.css'); ?> <table><tr> <td style="padding-right:20px"><?php echo JText::_('COM_GANALYTICS_DASHBOARD_VIEW_SELECT_PROFILES'); ?> <div class="input-append"> <select id="profiles"> <?php $selected = false;
public function refreshUpdateSite() { if (!GAnalyticsHelper::isPROMode()) { return; } JLoader::import('joomla.application.component.helper'); $params = JComponentHelper::getParams('com_ganalytics'); if (version_compare(JVERSION, '3.0', 'ge')) { $dlid = $params->get('downloadid', ''); } else { $dlid = $params->getValue('downloadid', ''); } $dlid = trim($dlid); $extra_query = null; // If I have a valid Download ID I will need to use a non-blank // extra_query in Joomla! 3.2+ if (preg_match('/^([0-9]{1,}:)?[0-9a-f]{32}$/i', $dlid)) { $extra_query = 'dlid=' . $dlid; } // Create the update site definition we want to store to the database $update_site = array('enabled' => 1, 'last_check_timestamp' => 0, 'extra_query' => $extra_query); if (version_compare(JVERSION, '3.0.0', 'lt')) { unset($update_site['extra_query']); } $db = $this->getDbo(); // Get the extension ID to ourselves $query = $db->getQuery(true)->select($db->qn('extension_id'))->from($db->qn('#__extensions'))->where($db->qn('type') . ' = ' . $db->q('package'))->where($db->qn('element') . ' = ' . $db->q('pkg_ganalytics')); $db->setQuery($query); $extension_id = $db->loadResult(); if (empty($extension_id)) { return; } // Get the update sites for our extension $query = $db->getQuery(true)->select($db->qn('update_site_id'))->from($db->qn('#__update_sites_extensions'))->where($db->qn('extension_id') . ' = ' . $db->q($extension_id)); $db->setQuery($query); $updateSiteIDs = $db->loadColumn(0); if (count($updateSiteIDs)) { // Loop through all update sites foreach ($updateSiteIDs as $id) { $query = $db->getQuery(true)->select('*')->from($db->qn('#__update_sites'))->where($db->qn('update_site_id') . ' = ' . $db->q($id)); $db->setQuery($query); $aSite = $db->loadObject(); // Do we have the extra_query property (J 3.2+) and does it // match? if (property_exists($aSite, 'extra_query')) { if ($aSite->extra_query == $update_site['extra_query']) { continue; } } else { // Joomla! 3.1 or earlier. Updates may or may not work. continue; } $update_site['update_site_id'] = $id; $newSite = (object) $update_site; $db->updateObject('#__update_sites', $newSite, 'update_site_id', true); } } }