# http://corporateservices.southdublin.ie/index.php?option=com_contact&catid=151&Itemid=115 $i = 0; foreach ($rows as $row) { if ($i > 0) { $namecell = $row->find("td a", 0); $name = strip_tags(str_replace("Cllr.", "", $namecell)); #->innertext $name = preg_replace('`&([a-z]+)(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig);`i', "\\1", $name); $name = trim($name); //utf8_decode($name); # <a href="index.php?option=com_contact&task=view&contact_id=21&Itemid=115" class="category"> $url = "http://corporateservices.southdublin.ie/" . $namecell->href; #http://corporateservices.southdublin.ie/index.php?option=com_contact&task=view&contact_id=32&Itemid=115 $url = str_replace("&", "&", $url); print $url; $moredetails = get_extras($url); $councillors["{$name}"] = array("LEA" => $lea, "Url" => $url, "Party" => $moredetails["party"], "Email" => $moredetails["email"], "Phone" => $moredetails["phone"], "Mobile" => $moredetails["mobile"], "Image" => $moredetails["image"], "Address" => $moredetails["address"]); } $i++; } } scraperwiki::sqliteexecute("drop table councillors"); scraperwiki::sqliteexecute("create table if not exists councillors (`auth` string, `lea` string, `url` string, `name` string,`party` string, `email` string, `phone` string, `mobile` string, `image` string, `address` string)"); scraperwiki::sqlitecommit(); foreach ($councillors as $name => $values) { scraperwiki::sqliteexecute("insert or replace into councillors values (:auth, :lea, :url, :name, :party, :email, :phone, :mobile, :image, :address)", array("auth" => $council, "lea" => $values["LEA"], "url" => $values["Url"], "name" => $name, "party" => $values["Party"], "email" => $values["Email"], "phone" => $values["Phone"], "mobile" => $values["Mobile"], "image" => $values["Image"], "address" => $values["Address"])); } function get_extras($url) { $localhtml = scraperwiki::scrape($url); $localdom = new simple_html_dom();
function findLinks($titleurl, $depth, $maxDepth, $meetings) { #static $maxDepth = 4; print "titleurl" . $titleurl . "\n"; $dom = new simple_html_dom(); $html = scraperwiki::scrape($titleurl); $dom->load($html); print "depth" . $depth . "\n"; print "maxdepth" . $maxDepth . "\n"; if ($depth > 1) { $rows = $dom->find("div[id=data1] table tbody tr"); } else { $rows = $dom->find("div[id=data] table tbody tr"); } unset($rows[0]); if ($depth <= $maxDepth) { $count = 0; # $i=0; foreach ($rows as $row) { print "row" . "\n"; /* $check0 = $row->find("td a",0); print "check0" . $check0 . "\n"; $check1 = $row->find("td a",1); print "check1" . $check1 . "\n"; if ( (!empty($check0)) && (!empty($check1)) ) { print "both not empty" . "\n"; } if ( (empty($check0)) && (empty($check1)) ) { print "both empty" . "\n"; } if ( (!empty($check0)) && (!empty($check1)) ) { */ $uribase = "http://www.fingalcoco.ie/minutes/"; #print "row1" . $row ."\n"; #print "row2" . $rows[1] ."\n"; if ($depth > 2) { $titleurl = $row->find("td a", 1); } else { $titleurl = $row->find("td a", 0); } #$titleurl = $row->find("td a",0); #print "titleurl1" . $titleurl . "\n"; #$titleurl = $row->href; $title = strip_tags($titleurl); #print "title" . $title . "\n"; #print "titleurl2" . $titleurl . "\n"; $titleurl = $uribase . $titleurl->href; $titleurl = str_replace('../../minutes/', '', $titleurl); #$titleurl = $uribase . $titleurl; print "titleurl3" . $titleurl . "\n"; #year,comittee,meetingdate,minuteref,url if ($depth == 1) { $committee = ""; $year = $title; $meetingdate = ""; } elseif ($depth == 2) { $committee = $title; $year = $meetings["year"]; #print "year" . $meetings["year"]; $meetingdate = ""; } elseif ($depth == 3) { $committee = $meetings["committee"]; #print "3committee" . $meetings["committee"]; $year = $meetings["year"]; #print "3year" . $meetings["year"]; $meetingdate = $title; } elseif ($depth == 4) { $committee = $meetings["committee"]; #print "4committee" . $meetings["committee"]; $year = $meetings["year"]; #print "4year" . $meetings["year"]; $meetingdate = $meetings["meetingdate"]; #print "4meetingdate" . $meetings["meetingdate"]; } else { $committee = "committeeelse"; $year = "yearelse"; $meetingdate = "meetingdateelse"; } if ($depth == 4) { print "yes"; #$meetingdetails = get_meetingdetails($titleurl); $meetingdetails = get_extras($titleurl); print "meetingdetails" . print_r($meetingdetails) . "\n"; /* $councillors["$name"] = array( "name" => $meetingdetails["name"], "Url" => $meetingdetails["url"], "Reply" => $meetingdetails["reply"], "Question" => $meetingdetails["question"], "Cllrq" => $meetingdetails["cllrq"], "Qtype" => $meetingdetails["qtype"], #, #, "Response" => $meetingdetails["response"] #, #, ); #} $name = $councillors["name"]; $url = $councillors["url"]; $reply = $councillors["reply"]; $question = $councillors["question"]; $cllrq = $councillors["cllrq"]; $qtype = $councillors["qtype"]; $response = $councillors["response"]; */ $reply = $meetingdetails["reply"]; $question = $meetingdetails["question"]; $cllrq = $meetingdetails["cllrq"]; $qtype = $meetingdetails["qtype"]; $response = $meetingdetails["response"]; } else { $url = "urlelse"; $reply = "replyelse"; $question = "questionelse"; $cllrq = "cllrqelse"; $qtype = "qtypeelse"; $response = "responseelse"; } $meetings = array('depth' => $depth, 'year' => $year, 'committee' => $committee, 'meetingdate' => $meetingdate, 'title' => $title, 'titleurl' => $titleurl, 'name' => $name, 'reply' => $reply, 'question' => $question, 'cllrq' => $cllrq, 'qtype' => $qtype, 'response' => $response); scraperwiki::save(array('titleurl', 'title'), $meetings); #} findLinks($titleurl, $depth + 1, $maxDepth, $meetings); # } # $i++; # if($i==3) break; } } }
/** * Extras Enabled * * @return (bool) True if Boilerplate Extras are enabled. */ function extras_enabled() { $extras = get_extras(); return !empty($extras); }
<?php # Load Extras check require_once '_includes/core/functions/extras.php'; $_includes = array(); # If Extras are enabled, include # them. # # @NOTE Additional includes are added # to the $_includes array from this file. if (extras_enabled()) { $_includes = array_merge($_includes, get_extras()); } # Get theme functions.php # # @NOTE This is optional but can be useful # for applying filters as they need to be # declared before they get executed! if (file_exists('_templates/functions.php')) { $_includes[] = '_templates/functions.php'; } # Get Functions $_functions = glob('_includes/core/functions/*.php'); # Include functions if (is_array($_functions)) { $_includes = array_merge($_includes, $_functions); } # Get Plugin functions.php $_plugin_functions = glob('_plugins/**/functions.php'); # Include Plugin functions.php if (is_array($_plugin_functions)) {