protected function getGroups()
 {
     JFactory::getLanguage()->load('com_ganalytics');
     if ($this->notLoad) {
         return array(array(JHtml::_('select.option', $this->value)));
     }
     if ($this->value == null) {
         $this->value = array();
     }
     if (!is_array($this->value)) {
         $this->value = array($this->value);
     }
     GAnalyticsHelper::loadjQuery();
     JFactory::getDocument()->addScript(JURI::base() . 'components/com_ganalytics/libraries/jquery/multiselect/jquery.multiselect2side.js');
     JFactory::getDocument()->addStyleSheet(JURI::base() . 'components/com_ganalytics/libraries/jquery/multiselect/jquery.multiselect2side.css');
     JFactory::getDocument()->addScriptDeclaration("gajQuery(document).ready(function(){createMultiSelectCombo(gajQuery('#" . $this->id . "'));});");
     $groups = array('' => array());
     foreach ($this->value as $value) {
         $groups[''][] = JHtml::_('select.option', $value, GAnalyticsHelper::translate($value), 'value', 'text');
     }
     $xml = new SimpleXMLElement(JFile::read(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_ganalytics' . DS . 'helper' . DS . 'metrics.xml'));
     foreach ($xml->div as $group) {
         $label = GAnalyticsHelper::translate($group->div);
         if (!isset($groups[$label])) {
             $groups[$label] = array();
         }
         foreach ($group->label as $value) {
             $v = (string) $value->attributes()->for;
             if (in_array($v, $this->value)) {
                 continue;
             }
             $groups[$label][] = JHtml::_('select.option', $v, GAnalyticsHelper::translate($v), 'value', 'text');
         }
     }
     return $groups;
 }
示例#2
0
 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();
 }
示例#3
0
</button></td>
	</tr>
</table>
<?php 
}
$scriptCode = "gajQuery(document).ready(function(){\n";
?>
<fieldset class="mod-date-range-container">
<legend><?php 
$dims = array();
foreach ($dimensions as $dim) {
    $dims[] = GAnalyticsHelper::translate($dim);
}
$metrs = array();
foreach ($metrics as $metr) {
    $metrs[] = GAnalyticsHelper::translate($metr);
}
echo implode(' | ', $dims) . ' -- ' . implode(' | ', $metrs);
?>
	</legend>
	<?php 
if (in_array('ga:date', $dimensions) !== false) {
    ?>
	<div class="mod-date-range-toolbar">
		<img src="media/com_ganalytics/images/dayrange/month-disabled-32.png" class="date-range-button date-range-month"
			alt="<?php 
    echo JText::_('MOD_GANALYTICS_STATS_CHART_VIEW_IMAGE_DATE_RANGE_MONTH');
    ?>
"
			title="<?php 
    echo JText::_('MOD_GANALYTICS_STATS_CHART_VIEW_IMAGE_DATE_RANGE_MONTH');
示例#4
0
echo JHtml::_('calendar', $this->escape($this->state->get('filter.search_end')), 'filter_search_end', 'filter_search_end', '%Y-%m-%d', array('class' => 'inputbox', 'maxlength' => '10', 'size' => '10'));
?>

			<button type="submit"><?php 
echo JText::_('JSEARCH_FILTER_SUBMIT');
?>
</button>
			<button type="button" onclick="document.id('filter_search').value='';document.id('filter_search_start').value='';document.id('filter_search_end').value='';this.form.submit();"><?php 
echo JText::_('JSEARCH_FILTER_CLEAR');
?>
</button>
		</div>
	</fieldset>
	<?php 
if (GAnalyticsHelper::isPROMode()) {
    echo '<h4>' . GAnalyticsHelper::translate('ga:uniquePageViews') . ' -- ' . GAnalyticsHelper::translate('ga:pageViews') . '</h4>';
    ?>
		<table id="charts-table">
			<tr>
				<td rowspan="2" id="date-chart-cell"><div id="ga-date-chart"></div></td>
				<td><div id="ga-browser-chart"></div></td>
			</tr>
			<tr>
				<td><div id="ga-country-chart"></div></td>
			</tr>
		</table>
		<hr/><br>
	<?php 
}
?>
	<div class="clr"> </div>