/** * Filtert Kollektionsdaten nach Strings. -> z.B. Unterscheidung Standard <-> Projekt * @param Piwik_DataTable $dataTable * @param String $filter * @param boolean $bool */ private static function filterCollectionTableContent($dataTable, $filter, $bool) { $rows = $dataTable->getRows(); Piwik_cdebug::clog('filterCollectionTableContent: rows: ' . count($rows)); foreach ($rows as $i => $row) { $label = $row->getColumn('label'); if (strpos($label, $filter) !== false xor $bool) { $dataTable->deleteRow($i); } } }
/** * L�dt Kollektions-IDs aus der TYPO3-Datenbank f�r eine bestimmte URL (und damit ID). * @param String $url * @return array */ private function getCollectionsForURL($url) { // this function is called on every piwik call // we are only interested in calls for dlf-extension if (strpos($url, "dlf") === FALSE) { return NULL; } // try to find the id of the digitalisat $urlparsed = parse_url(urldecode($url)); // default $id = 0; // 1st try: // urls like: http://digital.slub-dresden.de/werkansicht/cache.off?id=5363&tx_dlf[id]=15997&tx_dlf[page]=10 if (!empty($urlparsed['query'])) { $qfields = preg_split('/[;&]/', $urlparsed['query']); $params = array(); foreach ($qfields as $param) { $item = explode('=', $param); if (sizeof($item) == 2) { $params[$item[0]] = $item[1]; } } if (isset($params['tx_dlf[id]'])) { $id = $params['tx_dlf[id]']; } } // 2nd try: // urls like: http://digital.slub-dresden.de/werkansicht/dlf/2967/57/cache.off if ($id <= 0) { $this->clog("getCollectionsForURL: " . $urlparsed['path']); $qsplit = explode("/", $urlparsed['path']); $idpos = array_search('dlf', $qsplit) + 1; $id = intval($qsplit[$idpos]); } $this->clog("getCollectionsForURL(" . $url . "). id=/" . $id . "/"); // none was successful --> abort if ($id <= 0) { return NULL; } $mysqli = mysqli_connect("MYSQLSERVER", "USER", "PASSWORD", "DATABASE"); mysqli_set_charset($mysqli, 'utf8'); // ID DER KOLLEKTIONEN ZUORDNEN $result = mysqli_query($mysqli, "SELECT uid_foreign FROM tx_dlf_relations WHERE ident='docs_colls' AND uid_local=" . $id); Piwik_cdebug::clog("getCollectionsForURL: SELECT uid_foreign FROM tx_dlf_relations WHERE ident='docs_colls' AND uid_local=" . $id); $collections = array(); if ($result) { while ($tmpc = mysqli_fetch_row($result)) { $collections[] = $tmpc[0]; } } else { Piwik_cdebug::clog("getCollectionsForURL(" . $url . ") --> no result!"); } mysqli_close($mysqli); Piwik_cdebug::clog("getCollectionsForURL(" . $url . ")" . print_r($collections, 1)); return $collections; }