From: Alex Sadleir Date: Tue, 31 Dec 2013 14:22:14 +0000 Subject: filter/sort table X-Git-Url: https://maxious.lambdacomplex.org/git/?p=dcaas.git&a=commitdiff&h=b3e25a9652eb2f0b192ad3a27cd3a97044c0aa24 --- filter/sort table --- --- a/.gitmodules +++ b/.gitmodules --- /dev/null +++ b/.idea/.name @@ -1,1 +1,1 @@ - +dcaas --- /dev/null +++ b/.idea/compiler.xml @@ -1,1 +1,24 @@ + + + + + + --- /dev/null +++ b/.idea/encodings.xml @@ -1,1 +1,6 @@ + + + + + --- /dev/null +++ b/.idea/misc.xml @@ -1,1 +1,8 @@ + + + + + + + --- /dev/null +++ b/.idea/modules.xml @@ -1,1 +1,10 @@ + + + + + + + + + --- /dev/null +++ b/.idea/scopes/scope_settings.xml @@ -1,1 +1,5 @@ - + + + + --- /dev/null +++ b/.idea/vcs.xml @@ -1,1 +1,8 @@ + + + + + + + --- /dev/null +++ b/.idea/workspace.xml @@ -1,1 +1,761 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + localhost + 5050 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + --- /dev/null +++ b/about.php @@ -1,1 +1,3 @@ +Icon "Cloud Computing" designed by Andrew Forrester from the Noun Project --- /dev/null +++ b/config.php @@ -1,1 +1,129 @@ +setAttribute(PDO::ATTR_ERRMODE, + PDO::ERRMODE_EXCEPTION); +} catch (PDOException $e) { + // Print PDOException message + echo $e->getMessage(); +} +function local_url() +{ + return "http://" . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), '/\\') . "/"; +} + +function includeHeader($title) +{ + ?> + + + + + + + + + + + <?= $title ?> + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+getMessage(); + } + ?> + +
+ + +query("select count(*) from dcaas_services")->fetch(PDO::FETCH_NUM); +$query_total = $db->query("select count(*) ".$query)->fetch(PDO::FETCH_NUM); +/* http://www.sqlite.org/lang_select.html +Instead of a separate OFFSET clause, the LIMIT clause may specify two scalar expressions separated by a comma. +In this case, the first expression is used as the OFFSET expression and the second as the LIMIT expression. +This is counter-intuitive, as when using the OFFSET clause the second of the two expressions is the OFFSET +and the first the LIMIT. This is intentional - it maximizes compatibility with other SQL database systems.*/ +$limit = "limit $offset, $perPage"; + +foreach ($db->query($select_columns .$query . " order by $sortby $limit", PDO::FETCH_ASSOC) as $row) { + $row['service'] = '' . $row['service_name'] . ""; + $result['records'][] = $row; +} +$result['queryRecordCount'] = intval($query_total[0]); +$result['totalRecordCount'] = intval($total[0]); +echo json_encode($result); +?> --- /dev/null +++ b/data/import.php @@ -1,1 +1,60 @@ +exec("DROP TABLE IF EXISTS dcaas_services"); + +$row = 0; +$headers = Array(); +$csvfile = '../data/DCaaS+Catalogue+September+2013 PublicDCaaS_AFI_Part_3_Sec_5_Service_.csv'; +if (($handle = fopen($csvfile, "r")) !== FALSE) { + while (($data = fgetcsv($handle, 4096, ",")) !== FALSE) { + if ($row == 0) { + /************************************** + * Create tables * + **************************************/ + // Create table messages + $create = "CREATE TABLE IF NOT EXISTS dcaas_services ("; +// id INTEGER PRIMARY KEY,"; + foreach ($data as $column) { + $column = str_replace(" ", "_", strtolower($column)); + $create .= $column . " text " . (($column == 'acnabn' || $column == 'service_name') ? " not null " : "") . ","; + $headers[] = $column; + } + //$create .= " PRIMARY KEY ( acnabn,service_name) )"; + $create .= "id INTEGER PRIMARY KEY )"; + echo $create; + $db->exec($create); + // Prepare INSERT statement to SQLite3 file db + /* Create a string for the parameter placeholders filled to the number of params */ + $placeholders = implode(',', array_fill(0, count($headers), '?')); + $insert = "INSERT INTO dcaas_services (" . implode($headers, ", ") . ") + VALUES (" . $placeholders . ")"; + echo $insert; + $stmt = $db->prepare($insert); + $db->beginTransaction(); + } else { + if (count($data) < count($headers)) { + $values = $data + array_fill(count($data), count($headers) - count($data), NULL); + } else { + $values = $data; + } + print_r($values); + $stmt->execute($data); + } + $row++; + } +// end transaction + $db->commit(); + + fclose($handle); + echo "$row rows imported"; +} + +?> + --- a/data/xls2csv.py +++ b/data/xls2csv.py @@ -12,9 +12,9 @@ def cleanseValue(column,value): if isinstance(value, basestring): value = "".join([x if ord(x) < 128 else '' for x in value]) - value = value.replace('<','>').replace('>','<').replace('\n','
').replace('\r','
') + value = value.replace('<','>').replace('>','<').replace('\n','
').replace('\r','
').strip() else: - value = str(value) + value = str(value).strip() if column == 'ACNABN' and value != None: value = value.replace(' ','').replace(".0","").replace('"','').replace(",","") value = value.replace("ABN"," ").replace("ACN"," ").replace("/"," ").replace(":"," ") --- /dev/null +++ b/dcaas.iml @@ -1,1 +1,10 @@ + + + + + + + + + --- /dev/null +++ b/img/icon_2567.svg @@ -1,1 +1,5 @@ - + + + + + --- /dev/null +++ b/img/license.txt @@ -1,1 +1,9 @@ +Thank you for using The Noun Project. This icon is licensed under Creative +Commons Attribution and must be attributed as: + Cloud Computing by Andrew Forrester from The Noun Project + +If you have a Premium Account or have purchased a license for this icon, you +don't need to worry about attribution! We will share the profits from your +purchase with this icon's designer. + --- a/index.php +++ b/index.php @@ -1,14 +1,36 @@ addTag("tag-cloud"); -$cloud->addTag("programming"); -echo $cloud->render(); -includeFooter(); ?> +
+
+
+ +
+

Hello, world!

+

This is a template for a simple marketing or informational website. It includes a large callout called a + jumbotron and three supporting pieces of content. Use it as a starting point to create something more + unique.

+ +

Learn more »

+ +
+
+ +
+ query("Select service_name from dcaas_services;") as $row) { + foreach (explode(" ", $row[0]) as $word) { + $cloud->addTag($word); + } + } + $cloud->setMinLength(4); + echo $cloud->render(); + echo "
"; + includeFooter(); + ?> + --- /dev/null +++ b/robots.txt @@ -1,1 +1,6 @@ - +# www.robotstxt.org/ +# www.google.com/support/webmasters/bin/answer.py?hl=en&answer=156449 + +User-agent: * +Disallow: /admin/ +Sitemap: http://orgs.disclosurelo.gs/sitemap.xml.php --- /dev/null +++ b/sitemap.xml.php @@ -1,1 +1,21 @@ - +"; +echo '' . "\n"; +echo " " . local_url() . "index.php1.0\n"; +/*foreach (scandir("./") as $file) { + if (strpos($file, ".php") !== false && $file != "index.php" && $file != "sitemap.xml.php") + echo " " . local_url() . "$file0.3\n"; +} */ + + +$query = "Select distinct acnabn, service_name from dcaas_services order by acnabn"; + +foreach ($db->query($query, PDO::FETCH_ASSOC) as $row) { + echo '' . local_url() . 'view.php?acnabn=' . $row['acnabn'] . "&service_name=" . $row['service_name'] . "0.6\n"; +} + +echo ''; --- /dev/null +++ b/table.php @@ -1,1 +1,92 @@ + + +
+
+
+ +

DCaaS Service Catalogue

+ + + + + + + + + + + +
trading_or_business_nameServiceservice_categoryservice_sub_category
+
+ + + + + + + + + + + --- /dev/null +++ b/view.php @@ -1,1 +1,48 @@ +prepare("Select * from dcaas_services where acnabn = :acnabn and service_name = :service_name"); +$sth->bindValue(':acnabn',$acnabn); +$sth->bindValue(':service_name',$service_name); +$sth->execute(); +$data = $sth->fetchAll(PDO::FETCH_ASSOC); +if (count($data) == 0) { + header('HTTP/1.0 404 Not Found'); + includeHeader('Not Found'); + echo "not fo