function testGetTags() { $rq = new folksoResQuery(); $sql = $rq->getTags('http://www.example.com'); $this->assertTrue(is_string($sql), 'No string returned'); $this->assertTrue(strlen($sql) > 100, 'sql output is not long enough'); $this->assertPattern('/example/', $sql, 'Not finding original url in sql'); $sql_ean = $rq->getTags('http://www.example.com', 0, false, true); $this->assertPattern('/ean13/', $sql_ean, 'Not finding ean13 in sql ' . $sql_ean); print '==================' . $sql_ean; }
/** * Returns an xml list of resources associated with the same ean-13 as * the selected resource * * Web params: GET, folksores, folksoean13list */ function resEans(folksoQuery $q, folksoDBconnect $dbc, folksoSession $fks) { $r = new folksoResponse(); try { $i = new folksoDBinteract($dbc); if ($i->db_error()) { $r->dbConnectionError($i->error_info()); return $r; } $rq = new folksoResQuery(); $sql = $rq->resEans($i->dbescape($q->res)); $i->query($sql); } catch (dbConnectionException $e) { $r->dbConnectionError($e->getMessage()); return $r; } catch (dbQueryException $e) { $r->dbQueryError($e->getMessage() . $e->sqlquery); return $r; } switch ($i->result_status) { case 'NOROWS': $r->setError(404, 'Resource not found', "The requested resource is not present in the database.\n" . " Maybe it has not been indexed yet, or an erroneous identifier " . " was used. "); return $r; break; case 'OK': if ($i->result->num_rows == 1) { $r->setError(404, 'No EAN-13 data associated with this resource', "There is no EAN-13 data yet for the resource " . $q->res . "."); return $r; } else { $r->setOk(200, 'EAN-13 data found'); } } $title_line = $i->result->fetch_object(); /**popping the title that we are not using, but we could if we needed too (see note in ResQuery) **/ $df = new folksoDisplayFactory(); $dd = $df->associatedEan13resources(); $dd->activate_style('xml'); $r->t($dd->startform()); while ($row = $i->result->fetch_object()) { $r->t($dd->line($row->id, $row->url, $row->title)); } $r->t($dd->endform()); return $r; }