{"action":"created","comment":{"url":"https://api.github.com/repos/TimesOfMalta/phptest/pulls/comments/85813135","pull_request_review_id":6506773,"id":85813135,"diff_hunk":"@@ -28,30 +52,131 @@ function loadFeed($feedUrl)\n             throw new RuntimeException(\"Unexpected HTTP status code: $httpcode\", 8802);\n         }\n     }\n-\n     curl_close($curl);\n-\n     return $feed;\n }\n \n-$feeds = [\n-        \"jobsinmalta\" => \"https://jobsinmalta.com/jobs.rss?exclude_recruitment_agencies=1&limit=5\"\n-];\n \n-$feedUrl = $feeds[\"jobsinmalta\"];\n-try {\n-    $xml = new SimpleXMLElement(\n-            loadFeed($feedUrl), LIBXML_NOCDATA | LIBXML_NOWARNING\n-    );\n-    $channel = $xml->xpath(\"channel/item[category = 'Manufacturing']\");\n-    $rootXml = '<?xml-stylesheet type=\\'text/xsl\\'  href=\\'../xslt/list.xsl\\'?>' . \"\\n\"\n-            . '<root xmlns:jobsinmalta=\"http://jobsinmalta.com/jobsinmalta-schema\" '\n+//We have to pass the array to this function \n+//@input urls of everyfeeds\n+//@output display an Xml with all categories of the feeds without repeat\n+function categoriesXML($feedUrls){\t\n+    try \n+    {\n+        $categories = array();\n+        $rootXml = \n+            ' <?xml-stylesheet type=\"text/xsl\" href=\"./xslt/list2.xsl\"?>'\n+            .'<root xmlns:jobsinmalta=\"http://jobsinmalta.com/jobsinmalta-schema\" '\n             . 'xmlns:atom=\"http://www.w3.org/2005/Atom\" version=\"2.0\" '\n-            . 'jobsinmalta:noNamespaceSchemaLocation=\"http://jobsinmalta.com/jobsinmalta.xsd\">'\n-            . \"\\n<channel>\\n\" . $channel[0]->asXML(). \"\\n</channel>\\n\" . '</root>';\n-    $jobs  = new SimpleXMLElement($rootXml, LIBXML_NOCDATA);\n-    $jobs->addAttribute('encoding', 'utf-8');\n-    echo $jobs->asXML();\n-} catch (Exception $e) {\n-    echo IO::error($e->getMessage());\n+            . 'jobsinmalta:noNamespaceSchemaLocation=\"http://jobsinmalta.com/jobsinmalta.xsd\">'            \n+            . '</root>';\t\n+        foreach ($feedUrls as $feedUrl):\n+            $xml = new SimpleXMLElement(\n+                loadFeed($feedUrl), LIBXML_NOCDATA | LIBXML_NOWARNING\n+            );\n+            $categories = returnCategories($xml, $categories);\t\t\n+        endforeach;\n+\n+        $xmlCategories  = new SimpleXMLElement($rootXml);\n+        $xmlCategories->addChild('categories');\n+        foreach ($categories as $categorie):\n+            $categoria = (string)$categorie;\n+            $xmlCategories->categories->addChild('category', htmlspecialchars($categoria));\n+        endforeach; \n+        $xmlCategories->addAttribute('encoding', 'utf-8');  \n+        echo $xmlCategories->asXml();\n+        } \n+    catch (Exception $e) \n+    {\n+        echo IO::error($e->getMessage());\n+    }\n+} //end of onlineXML\n+\n+\n+//This function return an array of categories\n+//@input XML and Categories\n+//@output all categories of feed\n+function returnCategories($xml, $categories)\n+{\n+    foreach ($xml->channel[0]->item as $item)\n+    {\n+        if (!in_array($item->category, $categories))\n+        {\n+            $valor =  (string) ($item->category);\n+            array_push($categories, $valor); \n+        }\n+    }\n+    return ($categories);\n+}\n+\n+\n+//This function will return an xml with every vacancy of the category transfered to the function\n+//@input Category and Xml feeds url\n+//@output display a Xml document\n+function searchVacanciesByCategory($category, $feedUrls){\n+    try \n+    {\n+        $categories = array();\n+        $rootXml = \n+            '<?xml-stylesheet type=\"text/xsl\" href=\"../xslt/list3.xsl\"?>'\n+            .'<root xmlns:jobsinmalta=\"http://jobsinmalta.com/jobsinmalta-schema\" '\n+            .'xmlns:atom=\"http://www.w3.org/2005/Atom\" version=\"2.0\" '\n+            .'jobsinmalta:noNamespaceSchemaLocation=\"http://jobsinmalta.com/jobsinmalta.xsd\">';\t\n+        $final = array();\n+        foreach ($feedUrls as $feedUrl):\n+            $xml = new SimpleXMLElement(\n+                loadFeed($feedUrl), LIBXML_NOCDATA | LIBXML_NOWARNING\n+            );\n+            $vacan = vacanciesByCategory($xml->channel->item, $category);\n+            array_push($final, $vacan);\n+        endforeach;\n+        $vacancies = unifyXLM($final);\n+        foreach ($vacancies as $k=> $vacancie)\n+        {\n+            $rootXml .= \"\\n\" . $vacancies[$k]->asXML(). \"\\n\";\n+        }\n+        $rootXml .= \"\\n\\n\" . '</root>';\n+        echo $rootXml;\n+    } \n+    catch (Exception $e)\n+    {\n+        echo IO::error($e->getMessage());\n+    }\n }\n+\n+//This function removes any vacancy which no is identical to category\n+//@input all vacancies and category to match\n+//@output vacancies with the matched category\n+function vacanciesByCategory($vacancies, $category)\n+{\n+    $category = str_replace(\"%20\", \" \", $category);","path":"services/get.php","position":159,"original_position":159,"commit_id":"a0de76cf76fda9591e5884d39bac586a5d6915e5","original_commit_id":"a0de76cf76fda9591e5884d39bac586a5d6915e5","user":{"login":"isidro1984","id":6749352,"avatar_url":"https://avatars.githubusercontent.com/u/6749352?v=3","gravatar_id":"","url":"https://api.github.com/users/isidro1984","html_url":"https://github.com/isidro1984","followers_url":"https://api.github.com/users/isidro1984/followers","following_url":"https://api.github.com/users/isidro1984/following{/other_user}","gists_url":"https://api.github.com/users/isidro1984/gists{/gist_id}","starred_url":"https://api.github.com/users/isidro1984/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isidro1984/subscriptions","organizations_url":"https://api.github.com/users/isidro1984/orgs","repos_url":"https://api.github.com/users/isidro1984/repos","events_url":"https://api.github.com/users/isidro1984/events{/privacy}","received_events_url":"https://api.github.com/users/isidro1984/received_events","type":"User","site_admin":false},"body":"When the parameter \"category\" is introduced by URL, if this category has \"blank\" spaces, code didn't recognize it well. For this reason I had to use this function to change \"%20\" to  \"   \".   ","created_at":"2016-10-31T19:21:26Z","updated_at":"2016-10-31T19:21:26Z","html_url":"https://github.com/TimesOfMalta/phptest/pull/5#discussion_r85813135","pull_request_url":"https://api.github.com/repos/TimesOfMalta/phptest/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/TimesOfMalta/phptest/pulls/comments/85813135"},"html":{"href":"https://github.com/TimesOfMalta/phptest/pull/5#discussion_r85813135"},"pull_request":{"href":"https://api.github.com/repos/TimesOfMalta/phptest/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/TimesOfMalta/phptest/pulls/5","id":91056552,"html_url":"https://github.com/TimesOfMalta/phptest/pull/5","diff_url":"https://github.com/TimesOfMalta/phptest/pull/5.diff","patch_url":"https://github.com/TimesOfMalta/phptest/pull/5.patch","issue_url":"https://api.github.com/repos/TimesOfMalta/phptest/issues/5","number":5,"state":"open","locked":false,"title":"001 test modify","user":{"login":"isidro1984","id":6749352,"avatar_url":"https://avatars.githubusercontent.com/u/6749352?v=3","gravatar_id":"","url":"https://api.github.com/users/isidro1984","html_url":"https://github.com/isidro1984","followers_url":"https://api.github.com/users/isidro1984/followers","following_url":"https://api.github.com/users/isidro1984/following{/other_user}","gists_url":"https://api.github.com/users/isidro1984/gists{/gist_id}","starred_url":"https://api.github.com/users/isidro1984/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isidro1984/subscriptions","organizations_url":"https://api.github.com/users/isidro1984/orgs","repos_url":"https://api.github.com/users/isidro1984/repos","events_url":"https://api.github.com/users/isidro1984/events{/privacy}","received_events_url":"https://api.github.com/users/isidro1984/received_events","type":"User","site_admin":false},"body":"Hi Goran.\n\nI send you a pull request of my respository with the first issue.  I added up all files for merge with your repository. \n\nI await your confirmation. \n","created_at":"2016-10-26T18:03:15Z","updated_at":"2016-10-31T19:21:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c0b4edfed4a80190f9c0db9005ef2fce87844a38","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/TimesOfMalta/phptest/pulls/5/commits","review_comments_url":"https://api.github.com/repos/TimesOfMalta/phptest/pulls/5/comments","review_comment_url":"https://api.github.com/repos/TimesOfMalta/phptest/pulls/comments{/number}","comments_url":"https://api.github.com/repos/TimesOfMalta/phptest/issues/5/comments","statuses_url":"https://api.github.com/repos/TimesOfMalta/phptest/statuses/a0de76cf76fda9591e5884d39bac586a5d6915e5","head":{"label":"isidro1984:001-Test-modify","ref":"001-Test-modify","sha":"a0de76cf76fda9591e5884d39bac586a5d6915e5","user":{"login":"isidro1984","id":6749352,"avatar_url":"https://avatars.githubusercontent.com/u/6749352?v=3","gravatar_id":"","url":"https://api.github.com/users/isidro1984","html_url":"https://github.com/isidro1984","followers_url":"https://api.github.com/users/isidro1984/followers","following_url":"https://api.github.com/users/isidro1984/following{/other_user}","gists_url":"https://api.github.com/users/isidro1984/gists{/gist_id}","starred_url":"https://api.github.com/users/isidro1984/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isidro1984/subscriptions","organizations_url":"https://api.github.com/users/isidro1984/orgs","repos_url":"https://api.github.com/users/isidro1984/repos","events_url":"https://api.github.com/users/isidro1984/events{/privacy}","received_events_url":"https://api.github.com/users/isidro1984/received_events","type":"User","site_admin":false},"repo":{"id":71922937,"name":"phptest","full_name":"isidro1984/phptest","owner":{"login":"isidro1984","id":6749352,"avatar_url":"https://avatars.githubusercontent.com/u/6749352?v=3","gravatar_id":"","url":"https://api.github.com/users/isidro1984","html_url":"https://github.com/isidro1984","followers_url":"https://api.github.com/users/isidro1984/followers","following_url":"https://api.github.com/users/isidro1984/following{/other_user}","gists_url":"https://api.github.com/users/isidro1984/gists{/gist_id}","starred_url":"https://api.github.com/users/isidro1984/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isidro1984/subscriptions","organizations_url":"https://api.github.com/users/isidro1984/orgs","repos_url":"https://api.github.com/users/isidro1984/repos","events_url":"https://api.github.com/users/isidro1984/events{/privacy}","received_events_url":"https://api.github.com/users/isidro1984/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/isidro1984/phptest","description":null,"fork":true,"url":"https://api.github.com/repos/isidro1984/phptest","forks_url":"https://api.github.com/repos/isidro1984/phptest/forks","keys_url":"https://api.github.com/repos/isidro1984/phptest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/isidro1984/phptest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/isidro1984/phptest/teams","hooks_url":"https://api.github.com/repos/isidro1984/phptest/hooks","issue_events_url":"https://api.github.com/repos/isidro1984/phptest/issues/events{/number}","events_url":"https://api.github.com/repos/isidro1984/phptest/events","assignees_url":"https://api.github.com/repos/isidro1984/phptest/assignees{/user}","branches_url":"https://api.github.com/repos/isidro1984/phptest/branches{/branch}","tags_url":"https://api.github.com/repos/isidro1984/phptest/tags","blobs_url":"https://api.github.com/repos/isidro1984/phptest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/isidro1984/phptest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/isidro1984/phptest/git/refs{/sha}","trees_url":"https://api.github.com/repos/isidro1984/phptest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/isidro1984/phptest/statuses/{sha}","languages_url":"https://api.github.com/repos/isidro1984/phptest/languages","stargazers_url":"https://api.github.com/repos/isidro1984/phptest/stargazers","contributors_url":"https://api.github.com/repos/isidro1984/phptest/contributors","subscribers_url":"https://api.github.com/repos/isidro1984/phptest/subscribers","subscription_url":"https://api.github.com/repos/isidro1984/phptest/subscription","commits_url":"https://api.github.com/repos/isidro1984/phptest/commits{/sha}","git_commits_url":"https://api.github.com/repos/isidro1984/phptest/git/commits{/sha}","comments_url":"https://api.github.com/repos/isidro1984/phptest/comments{/number}","issue_comment_url":"https://api.github.com/repos/isidro1984/phptest/issues/comments{/number}","contents_url":"https://api.github.com/repos/isidro1984/phptest/contents/{+path}","compare_url":"https://api.github.com/repos/isidro1984/phptest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/isidro1984/phptest/merges","archive_url":"https://api.github.com/repos/isidro1984/phptest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/isidro1984/phptest/downloads","issues_url":"https://api.github.com/repos/isidro1984/phptest/issues{/number}","pulls_url":"https://api.github.com/repos/isidro1984/phptest/pulls{/number}","milestones_url":"https://api.github.com/repos/isidro1984/phptest/milestones{/number}","notifications_url":"https://api.github.com/repos/isidro1984/phptest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/isidro1984/phptest/labels{/name}","releases_url":"https://api.github.com/repos/isidro1984/phptest/releases{/id}","deployments_url":"https://api.github.com/repos/isidro1984/phptest/deployments","created_at":"2016-10-25T17:40:56Z","updated_at":"2016-10-26T07:03:55Z","pushed_at":"2016-10-26T16:56:55Z","git_url":"git://github.com/isidro1984/phptest.git","ssh_url":"git@github.com:isidro1984/phptest.git","clone_url":"https://github.com/isidro1984/phptest.git","svn_url":"https://github.com/isidro1984/phptest","homepage":null,"size":1372,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"TimesOfMalta:develop","ref":"develop","sha":"e4c7963f68401c9703d3f8da26e073b7b6bef3c1","user":{"login":"TimesOfMalta","id":6551668,"avatar_url":"https://avatars.githubusercontent.com/u/6551668?v=3","gravatar_id":"","url":"https://api.github.com/users/TimesOfMalta","html_url":"https://github.com/TimesOfMalta","followers_url":"https://api.github.com/users/TimesOfMalta/followers","following_url":"https://api.github.com/users/TimesOfMalta/following{/other_user}","gists_url":"https://api.github.com/users/TimesOfMalta/gists{/gist_id}","starred_url":"https://api.github.com/users/TimesOfMalta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TimesOfMalta/subscriptions","organizations_url":"https://api.github.com/users/TimesOfMalta/orgs","repos_url":"https://api.github.com/users/TimesOfMalta/repos","events_url":"https://api.github.com/users/TimesOfMalta/events{/privacy}","received_events_url":"https://api.github.com/users/TimesOfMalta/received_events","type":"Organization","site_admin":false},"repo":{"id":71478653,"name":"phptest","full_name":"TimesOfMalta/phptest","owner":{"login":"TimesOfMalta","id":6551668,"avatar_url":"https://avatars.githubusercontent.com/u/6551668?v=3","gravatar_id":"","url":"https://api.github.com/users/TimesOfMalta","html_url":"https://github.com/TimesOfMalta","followers_url":"https://api.github.com/users/TimesOfMalta/followers","following_url":"https://api.github.com/users/TimesOfMalta/following{/other_user}","gists_url":"https://api.github.com/users/TimesOfMalta/gists{/gist_id}","starred_url":"https://api.github.com/users/TimesOfMalta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TimesOfMalta/subscriptions","organizations_url":"https://api.github.com/users/TimesOfMalta/orgs","repos_url":"https://api.github.com/users/TimesOfMalta/repos","events_url":"https://api.github.com/users/TimesOfMalta/events{/privacy}","received_events_url":"https://api.github.com/users/TimesOfMalta/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/TimesOfMalta/phptest","description":null,"fork":false,"url":"https://api.github.com/repos/TimesOfMalta/phptest","forks_url":"https://api.github.com/repos/TimesOfMalta/phptest/forks","keys_url":"https://api.github.com/repos/TimesOfMalta/phptest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TimesOfMalta/phptest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TimesOfMalta/phptest/teams","hooks_url":"https://api.github.com/repos/TimesOfMalta/phptest/hooks","issue_events_url":"https://api.github.com/repos/TimesOfMalta/phptest/issues/events{/number}","events_url":"https://api.github.com/repos/TimesOfMalta/phptest/events","assignees_url":"https://api.github.com/repos/TimesOfMalta/phptest/assignees{/user}","branches_url":"https://api.github.com/repos/TimesOfMalta/phptest/branches{/branch}","tags_url":"https://api.github.com/repos/TimesOfMalta/phptest/tags","blobs_url":"https://api.github.com/repos/TimesOfMalta/phptest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TimesOfMalta/phptest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TimesOfMalta/phptest/git/refs{/sha}","trees_url":"https://api.github.com/repos/TimesOfMalta/phptest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TimesOfMalta/phptest/statuses/{sha}","languages_url":"https://api.github.com/repos/TimesOfMalta/phptest/languages","stargazers_url":"https://api.github.com/repos/TimesOfMalta/phptest/stargazers","contributors_url":"https://api.github.com/repos/TimesOfMalta/phptest/contributors","subscribers_url":"https://api.github.com/repos/TimesOfMalta/phptest/subscribers","subscription_url":"https://api.github.com/repos/TimesOfMalta/phptest/subscription","commits_url":"https://api.github.com/repos/TimesOfMalta/phptest/commits{/sha}","git_commits_url":"https://api.github.com/repos/TimesOfMalta/phptest/git/commits{/sha}","comments_url":"https://api.github.com/repos/TimesOfMalta/phptest/comments{/number}","issue_comment_url":"https://api.github.com/repos/TimesOfMalta/phptest/issues/comments{/number}","contents_url":"https://api.github.com/repos/TimesOfMalta/phptest/contents/{+path}","compare_url":"https://api.github.com/repos/TimesOfMalta/phptest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TimesOfMalta/phptest/merges","archive_url":"https://api.github.com/repos/TimesOfMalta/phptest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TimesOfMalta/phptest/downloads","issues_url":"https://api.github.com/repos/TimesOfMalta/phptest/issues{/number}","pulls_url":"https://api.github.com/repos/TimesOfMalta/phptest/pulls{/number}","milestones_url":"https://api.github.com/repos/TimesOfMalta/phptest/milestones{/number}","notifications_url":"https://api.github.com/repos/TimesOfMalta/phptest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TimesOfMalta/phptest/labels{/name}","releases_url":"https://api.github.com/repos/TimesOfMalta/phptest/releases{/id}","deployments_url":"https://api.github.com/repos/TimesOfMalta/phptest/deployments","created_at":"2016-10-20T15:45:50Z","updated_at":"2016-10-20T15:48:02Z","pushed_at":"2016-10-27T18:06:29Z","git_url":"git://github.com/TimesOfMalta/phptest.git","ssh_url":"git@github.com:TimesOfMalta/phptest.git","clone_url":"https://github.com/TimesOfMalta/phptest.git","svn_url":"https://github.com/TimesOfMalta/phptest","homepage":null,"size":7,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/TimesOfMalta/phptest/pulls/5"},"html":{"href":"https://github.com/TimesOfMalta/phptest/pull/5"},"issue":{"href":"https://api.github.com/repos/TimesOfMalta/phptest/issues/5"},"comments":{"href":"https://api.github.com/repos/TimesOfMalta/phptest/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/TimesOfMalta/phptest/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/TimesOfMalta/phptest/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/TimesOfMalta/phptest/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/TimesOfMalta/phptest/statuses/a0de76cf76fda9591e5884d39bac586a5d6915e5"}}}}
{"actor":{"display_login":"isidro1984"}}