コード例 #1
0
ファイル: Actions.php プロジェクト: klando/pgpiwik
 public function __construct()
 {
     self::$actionCategoryDelimiter = Zend_Registry::get('config')->General->action_category_delimiter;
     $this->columnToSortByBeforeTruncation = 'nb_visits';
     $this->maximumRowsInDataTableLevelZero = Zend_Registry::get('config')->General->datatable_archiving_maximum_rows_actions;
     $this->maximumRowsInSubDataTable = Zend_Registry::get('config')->General->datatable_archiving_maximum_rows_subtable_actions;
 }
コード例 #2
0
ファイル: Actions.php プロジェクト: BackupTheBerlios/oos-svn
	public function __construct()
	{
		self::$actionCategoryDelimiter =  Zend_Registry::get('config')->General->action_category_delimiter;
		self::$defaultActionName = Zend_Registry::get('config')->General->action_default_name;
		self::$defaultActionNameWhenNotDefined = Zend_Registry::get('config')->General->action_default_name_when_not_defined;
		self::$defaultActionUrlWhenNotDefined = Zend_Registry::get('config')->General->action_default_url_when_not_defined;
		$this->columnToSortByBeforeTruncation = 'nb_visits';
		$this->maximumRowsInDataTableLevelZero = Zend_Registry::get('config')->General->datatable_archiving_maximum_rows_actions;
		$this->maximumRowsInSubDataTable = Zend_Registry::get('config')->General->datatable_archiving_maximum_rows_subtable_actions;
	}
コード例 #3
0
ファイル: Actions.php プロジェクト: Doluci/tomatocart
 public function __construct()
 {
     // for BC, we read the old style delimiter first (see #1067)
     $actionDelimiter = Zend_Registry::get('config')->General->action_category_delimiter;
     if (empty($actionDelimiter)) {
         self::$actionUrlCategoryDelimiter = Zend_Registry::get('config')->General->action_url_category_delimiter;
         self::$actionTitleCategoryDelimiter = Zend_Registry::get('config')->General->action_title_category_delimiter;
     } else {
         self::$actionUrlCategoryDelimiter = self::$actionTitleCategoryDelimiter = $actionDelimiter;
     }
     self::$defaultActionName = Zend_Registry::get('config')->General->action_default_name;
     self::$defaultActionNameWhenNotDefined = Zend_Registry::get('config')->General->action_default_name_when_not_defined;
     self::$defaultActionUrlWhenNotDefined = Zend_Registry::get('config')->General->action_default_url_when_not_defined;
     $this->columnToSortByBeforeTruncation = 'nb_visits';
     $this->maximumRowsInDataTableLevelZero = Zend_Registry::get('config')->General->datatable_archiving_maximum_rows_actions;
     $this->maximumRowsInSubDataTable = Zend_Registry::get('config')->General->datatable_archiving_maximum_rows_subtable_actions;
 }
コード例 #4
0
ファイル: API.php プロジェクト: nnnnathann/piwik
 /**
  * Add transitions data to the report.
  * Fake ArchiveProcessing to do the queries live.
  */
 private function addLiveTransitionsDataToReport(&$report, $pageUrl, $idSite, $period, $date, $segment, $limitBeforeGrouping)
 {
     // get idaction of page url
     $actionsPlugin = new Piwik_Actions();
     $idaction = $actionsPlugin->getIdActionFromSegment($pageUrl, 'idaction');
     // prepare archive processing that can be reused by the archiving code
     $archiveProcessing = new Piwik_ArchiveProcessing_Day();
     $archiveProcessing->setSite(new Piwik_Site($idSite));
     $archiveProcessing->setPeriod(Piwik_Period::advancedFactory($period, $date));
     $archiveProcessing->setSegment(new Piwik_Segment($segment, $idSite));
     $archiveProcessing->initForLiveUsage();
     // launch the archiving code - but live
     $transitionsArchiving = new Piwik_Transitions();
     $data = $transitionsArchiving->queryInternalReferrers($idaction, $archiveProcessing, $limitBeforeGrouping);
     $report['previousPages'] =& $data['previousPages'];
     $report['pageMetrics']['loops'] = intval($data['loops']);
     $data = $transitionsArchiving->queryFollowingActions($idaction, $archiveProcessing, $limitBeforeGrouping);
     foreach ($data as $tableName => $table) {
         $report[$tableName] = $table;
     }
     $data = $transitionsArchiving->queryExternalReferrers($idaction, $archiveProcessing, $limitBeforeGrouping);
     $report['pageMetrics']['entries'] = 0;
     $report['referrers'] = array();
     foreach ($data->getRows() as $row) {
         $referrerId = $row->getColumn('label');
         $visits = $row->getColumn(Piwik_Archive::INDEX_NB_VISITS);
         if ($visits) {
             // load details (i.e. subtables)
             $details = array();
             if ($idSubTable = $row->getIdSubDataTable()) {
                 $subTable = Piwik_DataTable_Manager::getInstance()->getTable($idSubTable);
                 foreach ($subTable->getRows() as $subRow) {
                     $details[] = array('label' => $subRow->getColumn('label'), 'referrals' => $subRow->getColumn(Piwik_Archive::INDEX_NB_VISITS));
                 }
             }
             $report['referrers'][] = array('label' => $this->getReferrerLabel($referrerId), 'shortName' => Piwik_getRefererTypeFromShortName($referrerId), 'visits' => $visits, 'details' => $details);
             $report['pageMetrics']['entries'] += $visits;
         }
     }
     // if there's no data for referrers, Piwik_API_ResponseBuilder::handleMultiDimensionalArray
     // does not detect the multi dimensional array and the data is rendered differently, which
     // causes an exception.
     if (count($report['referrers']) == 0) {
         $report['referrers'][] = array('label' => $this->getReferrerLabel(Piwik_Common::REFERER_TYPE_DIRECT_ENTRY), 'shortName' => Piwik_getRefererTypeLabel(Piwik_Common::REFERER_TYPE_DIRECT_ENTRY), 'visits' => 0);
     }
 }
コード例 #5
0
 protected static function getUnknownActionName($type)
 {
     if (empty(self::$defaultActionNameWhenNotDefined)) {
         self::$defaultActionNameWhenNotDefined = Piwik_Translate('General_NotDefined', Piwik_Translate('Actions_ColumnPageName'));
         self::$defaultActionUrlWhenNotDefined = Piwik_Translate('General_NotDefined', Piwik_Translate('Actions_ColumnPageURL'));
     }
     if ($type == Piwik_Tracker_Action::TYPE_ACTION_NAME) {
         return self::$defaultActionNameWhenNotDefined;
     }
     return self::$defaultActionUrlWhenNotDefined;
 }
コード例 #6
0
ファイル: API.php プロジェクト: nomoto-ubicast/piwik
 /**
  * Derive the action ID from the request action name and type.
  */
 private function deriveIdAction($actionName, $actionType)
 {
     $actionsPlugin = new Piwik_Actions();
     switch ($actionType) {
         case 'url':
             $originalActionName = $actionName;
             $actionName = Piwik_Common::unsanitizeInputValue($actionName);
             $id = $actionsPlugin->getIdActionFromSegment($actionName, 'idaction_url');
             if ($id < 0) {
                 // an example where this is needed is urls containing < or >
                 $actionName = $originalActionName;
                 $id = $actionsPlugin->getIdActionFromSegment($actionName, 'idaction_url');
             }
             return $id;
         case 'title':
             $id = $actionsPlugin->getIdActionFromSegment($actionName, 'idaction_name');
             if ($id < 0) {
                 $unkown = Piwik_Actions_ArchivingHelper::getUnknownActionName(Piwik_Tracker_Action::TYPE_ACTION_NAME);
                 if (trim($actionName) == trim($unkown)) {
                     $id = $actionsPlugin->getIdActionFromSegment('', 'idaction_name');
                 }
             }
             return $id;
         default:
             throw new Exception('Unknown action type');
     }
 }
コード例 #7
0
 /**
  * Will search in the DataTable for a Label matching the searched string
  * and return only the matching row, or an empty datatable
  */
 protected function getFilterPageDatatableSearch($callBackParameters, $search, $actionType, $table = false, $searchTree = false)
 {
     if ($searchTree === false) {
         // build the query parts that are searched inside the tree
         if ($actionType == Piwik_Tracker_Action::TYPE_ACTION_NAME) {
             $searchedString = Piwik_Common::unsanitizeInputValue($search);
         } else {
             $idSite = $callBackParameters[1];
             try {
                 $searchedString = Piwik_Tracker_Action::excludeQueryParametersFromUrl($search, $idSite);
             } catch (Exception $e) {
                 $searchedString = $search;
             }
         }
         $searchTree = Piwik_Actions::getActionExplodedNames($searchedString, $actionType);
     }
     if ($table === false) {
         // fetch the data table
         $table = call_user_func_array(array('Piwik_Archive', 'getDataTableFromArchive'), $callBackParameters);
         if ($table instanceof Piwik_DataTable_Array) {
             // search an array of tables, e.g. when using date=last30
             // note that if the root is an array, we filter all children
             // if an array occurs inside the nested table, we only look for the first match (see below)
             $newTableArray = new Piwik_DataTable_Array();
             $newTableArray->metadata = $table->metadata;
             $newTableArray->setKeyName($table->getKeyName());
             foreach ($table->getArray() as $label => $subTable) {
                 $subTable = $this->doFilterPageDatatableSearch($callBackParameters, $subTable, $searchTree);
                 $newTableArray->addTable($subTable, $label);
             }
             return $newTableArray;
         }
     }
     return $this->doFilterPageDatatableSearch($callBackParameters, $table, $searchTree);
 }
コード例 #8
0
ファイル: Actions.php プロジェクト: Gninety/Microweber
 /**
  * Compute all the actions along with their hierarchies.
  * 
  * For each action we process the "interest statistics" : 
  * visits, unique visitors, bouce count, sum visit length.
  * 
  * 
  */
 public function archiveDay($notification)
 {
     /* @var $archiveProcessing Piwik_ArchiveProcessing */
     $archiveProcessing = $notification->getNotificationObject();
     if (!$archiveProcessing->shouldProcessReportsForPlugin($this->getPluginName())) {
         return;
     }
     $this->actionsTablesByType = array(Piwik_Tracker_Action::TYPE_ACTION_URL => array(), Piwik_Tracker_Action::TYPE_DOWNLOAD => array(), Piwik_Tracker_Action::TYPE_OUTLINK => array(), Piwik_Tracker_Action::TYPE_ACTION_NAME => array());
     // This row is used in the case where an action is know as an exit_action
     // but this action was not properly recorded when it was hit in the first place
     // so we add this fake row information to make sure there is a nb_hits, etc. column for every action
     $this->defaultRow = new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS => array(Piwik_Archive::INDEX_NB_VISITS => 1, Piwik_Archive::INDEX_NB_UNIQ_VISITORS => 1, Piwik_Archive::INDEX_PAGE_NB_HITS => 1)));
     /*
      * Handling a custom segment when processing Page reports
      */
     $segment = $archiveProcessing->getSegment();
     $segmentSql = $segment->getSql();
     $sqlJoinVisitTable = $sqlSegmentWhere = '';
     if (!$segment->isEmpty()) {
         $sqlJoinVisitTable = "LEFT JOIN " . Piwik_Common::prefixTable('log_visit') . " as log_visit ON (log_visit.idvisit = log_link_visit_action.idvisit)";
         $sqlSegmentWhere = ' AND ' . $segmentSql['sql'];
     }
     $sqlBind = $segmentSql['bind'];
     /*
      * Page URLs and Page names, general stats
      */
     $queryString = "SELECT name,\n\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\tidaction,\n\t\t\t\t\t\t\tcount(distinct log_link_visit_action.idvisit) as `" . Piwik_Archive::INDEX_NB_VISITS . "`, \n\t\t\t\t\t\t\tcount(distinct log_link_visit_action.idvisitor) as `" . Piwik_Archive::INDEX_NB_UNIQ_VISITORS . "`,\n\t\t\t\t\t\t\tcount(*) as `" . Piwik_Archive::INDEX_PAGE_NB_HITS . "`\t\t\t\t\t\t\t\n\t\t\t\t\tFROM " . Piwik_Common::prefixTable('log_link_visit_action') . " as log_link_visit_action\n\t\t\t\t\t\t\tLEFT JOIN " . Piwik_Common::prefixTable('log_action') . " as log_action ON (log_link_visit_action.%s = idaction)\n\t\t\t\t\t\t\t{$sqlJoinVisitTable}\n\t\t\t\t\tWHERE server_time >= ?\n\t\t\t\t\t\tAND server_time <= ?\n\t\t\t\t\t\tAND log_link_visit_action.idsite = ?\n\t\t\t\t \t\tAND %s > 0\n\t\t\t\t \t\t{$sqlSegmentWhere}\n\t\t\t\t\tGROUP BY idaction\n\t\t\t\t\tORDER BY `" . Piwik_Archive::INDEX_PAGE_NB_HITS . "` DESC";
     $this->archiveDayQueryProcess($queryString, "idaction_url", $sqlBind, $archiveProcessing);
     $this->archiveDayQueryProcess($queryString, "idaction_name", $sqlBind, $archiveProcessing);
     /*
      * Entry actions for Page URLs and Page names
      */
     $queryString = "SELECT %s as idaction,\n\t\t\t\t\t\t\tcount(distinct idvisitor) as `" . Piwik_Archive::INDEX_PAGE_ENTRY_NB_UNIQ_VISITORS . "`, \n\t\t\t\t\t\t\tcount(*) as `" . Piwik_Archive::INDEX_PAGE_ENTRY_NB_VISITS . "`,\n\t\t\t\t\t\t\tsum(visit_total_actions) as `" . Piwik_Archive::INDEX_PAGE_ENTRY_NB_ACTIONS . "`,\n\t\t\t\t\t\t\tsum(visit_total_time) as `" . Piwik_Archive::INDEX_PAGE_ENTRY_SUM_VISIT_LENGTH . "`,\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tsum(case visit_total_actions when 1 then 1 else 0 end) as `" . Piwik_Archive::INDEX_PAGE_ENTRY_BOUNCE_COUNT . "`\n\t\t\t\t\tFROM " . Piwik_Common::prefixTable('log_visit') . " \n\t\t\t\t\tWHERE visit_last_action_time >= ?\n\t\t\t\t\t\tAND visit_last_action_time <= ?\n\t\t\t\t\t\tAND idsite = ?\n\t\t\t\t \t\tAND %s > 0\n\t\t\t\t \t\t{$sqlSegmentWhere}\n\t\t\t\t\tGROUP BY %s, idaction";
     $this->archiveDayQueryProcess($queryString, "visit_entry_idaction_url", $sqlBind, $archiveProcessing);
     $this->archiveDayQueryProcess($queryString, "visit_entry_idaction_name", $sqlBind, $archiveProcessing);
     /*
      * Exit actions
      */
     $queryString = "SELECT %s as idaction,\n\t\t\t\t\t\t\tcount(distinct idvisitor) as `" . Piwik_Archive::INDEX_PAGE_EXIT_NB_UNIQ_VISITORS . "`,\n\t\t\t\t\t\t\tcount(*) as `" . Piwik_Archive::INDEX_PAGE_EXIT_NB_VISITS . "`\n\t\t\t\t \tFROM " . Piwik_Common::prefixTable('log_visit') . " \n\t\t\t\t \tWHERE visit_last_action_time >= ?\n\t\t\t\t\t\tAND visit_last_action_time <= ?\n\t\t\t\t \t\tAND idsite = ?\n\t\t\t\t \t\tAND %s > 0\n\t\t\t\t \t\t{$sqlSegmentWhere}\n\t\t\t\t \tGROUP BY %s, idaction";
     $this->archiveDayQueryProcess($queryString, "visit_exit_idaction_url", $sqlBind, $archiveProcessing);
     $this->archiveDayQueryProcess($queryString, "visit_exit_idaction_name", $sqlBind, $archiveProcessing);
     /*
      * Time per action
      */
     $queryString = "SELECT %s as idaction,\n\t\t\t\t\t\t\tsum(time_spent_ref_action) as `" . Piwik_Archive::INDEX_PAGE_SUM_TIME_SPENT . "`\n\t\t\t\t\tFROM " . Piwik_Common::prefixTable('log_link_visit_action') . " AS log_link_visit_action\n\t\t\t\t\t\t\t{$sqlJoinVisitTable}\n\t\t\t\t\tWHERE server_time >= ?\n\t\t\t\t\t\tAND server_time <= ?\n\t\t\t\t \t\tAND log_link_visit_action.idsite = ?\n\t\t\t\t \t\tAND time_spent_ref_action > 0\n\t\t\t\t \t\tAND %s > 0\n\t\t\t\t \t\t{$sqlSegmentWhere}\n\t\t\t\t \tGROUP BY %s, idaction";
     $this->archiveDayQueryProcess($queryString, "idaction_url_ref", $sqlBind, $archiveProcessing);
     $this->archiveDayQueryProcess($queryString, "idaction_name_ref", $sqlBind, $archiveProcessing);
     // Empty static cache
     self::$cacheParsedAction = array();
     // Record the final datasets
     $this->archiveDayRecordInDatabase($archiveProcessing);
 }
コード例 #9
0
ファイル: API.php プロジェクト: nomoto-ubicast/piwik
 public function getSiteSearchCategories($idSite, $period, $date, $segment = false)
 {
     Piwik_Actions::checkCustomVariablesPluginEnabled();
     $customVariables = Piwik_CustomVariables_API::getInstance()->getCustomVariables($idSite, $period, $date, $segment, $expanded = false, $_leavePiwikCoreVariables = true);
     $customVarNameToLookFor = Piwik_Tracker_Action::CVAR_KEY_SEARCH_CATEGORY;
     $dataTable = new Piwik_DataTable();
     // Handle case where date=last30&period=day
     // TODO: this logic should really be refactored somewhere, this is ugly!
     if ($customVariables instanceof Piwik_DataTable_Array) {
         $dataTable = new Piwik_DataTable_Array();
         $dataTable->metadata = $customVariables->metadata;
         $dataTable->setKeyName($customVariables->getKeyName());
         $customVariableDatatables = $customVariables->getArray();
         $dataTables = $dataTable->getArray();
         foreach ($customVariableDatatables as $key => $customVariableTableForDate) {
             // we do not enter the IF, in the case idSite=1,3 AND period=day&date=datefrom,dateto,
             if (isset($dataTable->metadata[$key]['period'])) {
                 $row = $customVariableTableForDate->getRowFromLabel($customVarNameToLookFor);
                 if ($row) {
                     $dateRewrite = $dataTable->metadata[$key]['period']->getDateStart()->toString();
                     $idSubtable = $row->getIdSubDataTable();
                     $categories = Piwik_CustomVariables_API::getInstance()->getCustomVariablesValuesFromNameId($idSite, $period, $dateRewrite, $idSubtable, $segment);
                     $dataTable->addTable($categories, $key);
                 }
             }
         }
     } elseif ($customVariables instanceof Piwik_DataTable) {
         $row = $customVariables->getRowFromLabel($customVarNameToLookFor);
         if ($row) {
             $idSubtable = $row->getIdSubDataTable();
             $dataTable = Piwik_CustomVariables_API::getInstance()->getCustomVariablesValuesFromNameId($idSite, $period, $date, $idSubtable, $segment);
         }
     }
     $this->filterActionsDataTable($dataTable);
     $this->addPagesPerSearchColumn($dataTable, $columnToRead = 'nb_actions');
     return $dataTable;
 }
コード例 #10
0
ファイル: API.php プロジェクト: BackupTheBerlios/oos-svn
	/**
	 * Will search in the DataTable for a Label matching the searched string
	 * and return only the matching row, or an empty datatable
	 */
	protected function getFilterPageDatatableSearch( $callBackParameters, $search, $actionType, $table = false, $searchTree = false, $searchCurrentLevel = 0 )
	{
		if($table === false)
		{
			$table = call_user_func_array(array('Piwik_Archive', 'getDataTableFromArchive'), $callBackParameters);
		}
		if($searchTree === false)
		{
    		if($actionType == Piwik_Tracker_Action::TYPE_ACTION_NAME)
    		{
    			$searchedString = Piwik_Common::unsanitizeInputValue($search);
    		}
    		else
    		{
    			$searchedString = Piwik_Tracker_Action::excludeQueryParametersFromUrl($search, $idSite = $callBackParameters[1]);
    		}
			$searchTree = Piwik_Actions::getActionExplodedNames($searchedString, $actionType);
		}
		if(!($table instanceof Piwik_DataTable))
		{
			throw new Exception("For this API function, date=lastN or date=previousM is not supported");
		}
		$rows = $table->getRows();
		$labelSearch = $searchTree[$searchCurrentLevel];
		$isEndSearch = ((count($searchTree)-1) == $searchCurrentLevel);
		foreach($rows as $key => $row)
		{
			$found = false;
			// Found a match at this level
			$label = $row->getColumn('label');
			if($label === $labelSearch)
			{
				// Is this the end of the search tree? then we found the requested row
				if($isEndSearch)
				{
//					var_dump($label); var_dump($labelSearch); exit;
					$table = new Piwik_DataTable();
					$table->addRow($row);
					return $table;
				}
				
				// If we still need to search deeper, call search 
				$idSubTable = $row->getIdSubDataTable();
				// Update the idSubtable in the callback parameter list, to fetch this subtable from the archive
				$callBackParameters[6] = $idSubTable;
				$subTable = call_user_func_array(array('Piwik_Archive', 'getDataTableFromArchive'), $callBackParameters);
				$found = $this->getFilterPageDatatableSearch($callBackParameters, $search, $actionType, $subTable, $searchTree, $searchCurrentLevel+1);
				if($found)
				{
					return $found;
				}
			}
			if(!$found)
			{
				$table->deleteRow($key);
			}
		}
		// Case the DataTable was searched but nothing was found, @see getFilterPageDatatableSearch()
		if($searchCurrentLevel == 0)
		{
			return new Piwik_DataTable;
		}
		return false;
	}