# HG changeset patch # User cavaliet # Date 1404485837 -7200 # Node ID 65c12455ce74951360137cb991cd3844ee9c196c # Parent 88405a9b804a487b28bb277bc80c863186e07f3a adapt code to be compatible with dinosaur php 5.3 diff -r 88405a9b804a -r 65c12455ce74 .gitignore diff -r 88405a9b804a -r 65c12455ce74 Command/ProgressContainerAwareCommand.php diff -r 88405a9b804a -r 65c12455ce74 Controller/WikiTagController.php --- a/Controller/WikiTagController.php Tue Apr 08 13:13:30 2014 +0200 +++ b/Controller/WikiTagController.php Fri Jul 04 16:57:17 2014 +0200 @@ -69,8 +69,9 @@ $columns_array = $profile_array[$profile_name]; } + $url_templates = $this->container->getParameter("wiki_tag.url_templates"); return $this->render('WikiTagBundle:WikiTag:javascript.html.twig', - array('wikipedia_api_url' => $this->container->getParameter("wiki_tag.url_templates")["wikipedia_api"], + array('wikipedia_api_url' => $url_templates["wikipedia_api"], 'categories' => $categories, 'tags_list' => $tags_list, 'columns' => $columns_array, @@ -113,13 +114,14 @@ } $ordered_tags = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOrderedTagsForDoc($id_doc); + $url_templates = $this->container->getParameter("wiki_tag.url_templates"); //$ordered_tags = null; return $this->render('WikiTagBundle:WikiTag:documentTags.html.twig', array('ordered_tags' => $ordered_tags, 'doc_id' => $id_doc, 'columns' => $columns_array, 'profile_name' => $profile_name, - 'wikipedia_opensearch_url' => $this->container->getParameter("wiki_tag.url_templates")["wikipedia_opensearch"])); + 'wikipedia_opensearch_url' => $url_templates["wikipedia_opensearch"])); } /** @@ -408,12 +410,13 @@ $columns_array = $profile_array[$profile_name]; } $ordered_tags = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOrderedTagsForDoc($id_doc); + $url_templates = $this->container->getParameter("wiki_tag.url_templates"); return $this->render('WikiTagBundle:WikiTag:tagTable.html.twig', array('ordered_tags' => $ordered_tags, 'doc_id' => $id_doc, 'columns' => $columns_array, 'profile_name' => $profile_name, - 'wikipedia_opensearch_url' => $this->container->getParameter("wiki_tag.url_templates")["wikipedia_opensearch"])); + 'wikipedia_opensearch_url' => $url_templates["wikipedia_opensearch"])); } @@ -507,6 +510,7 @@ $search_def[$l[0]] = $l[0].WikiTagController::$SEARCH_STAR_CHARACTER; } + $url_templates = $this->container->getParameter("wiki_tag.url_templates"); return $this->render('WikiTagBundle:WikiTag:TagList.html.twig', array('tags' => $tags, 'searched' => $searched, @@ -522,7 +526,7 @@ 'next_page' => $next_page, 'reverse_sort' => $reverse_sort, 'route_for_documents_by_tag' => $this->container->getParameter("wiki_tag.route_for_documents_by_tag"), - 'wikipedia_opensearch_url' => $this->container->getParameter("wiki_tag.url_templates")["wikipedia_opensearch"])); + 'wikipedia_opensearch_url' => $url_templates["wikipedia_opensearch"])); } /** @@ -631,6 +635,7 @@ $sort = $ar[4]; $reverse_sort = $ar[5]; + $url_templates = $this->container->getParameter("wiki_tag.url_templates"); return $this->render('WikiTagBundle:WikiTag:TagListTable.html.twig', array('tags' => $tags, 'searched' => $searched, @@ -639,7 +644,7 @@ 'num_page' => $num_page, 'reverse_sort' => $reverse_sort, 'route_for_documents_by_tag' => $this->container->getParameter("wiki_tag.route_for_documents_by_tag"), - 'wikipedia_opensearch_url' => $this->container->getParameter("wiki_tag.url_templates")["wikipedia_opensearch"])); + 'wikipedia_opensearch_url' => $url_templates["wikipedia_opensearch"])); } /** diff -r 88405a9b804a -r 65c12455ce74 DataFixtures/ORM/LoadDocumentData.php diff -r 88405a9b804a -r 65c12455ce74 DoctrineMigrations/Version20140129151724.php --- a/DoctrineMigrations/Version20140129151724.php Tue Apr 08 13:13:30 2014 +0200 +++ b/DoctrineMigrations/Version20140129151724.php Fri Jul 04 16:57:17 2014 +0200 @@ -50,12 +50,12 @@ echo "\n".count($tags)." tags to search."; foreach($tags as $tag){ $l = $tag->getLabel(); - $uri = WikiTagUtils::getDbpediaUri($tag->getWikipediaPageId(), [], false, "pageid"); + $uri = WikiTagUtils::getDbpediaUri($tag->getWikipediaPageId(), array(), false, "pageid"); $tag->setDbpediaUri($uri); $em->persist($tag); - if($uri!=NULL && $uri!=""){ - $nb_set++; - } + if($uri!=NULL && $uri!=""){ + $nb_set++; + } if( $i % 50 == 0 ){ $em->flush(); echo "\n FLUSH"; @@ -76,7 +76,7 @@ echo "\n".count($tags)." tags to search."; foreach($tags as $tag){ $l = $tag->getLabel(); - $uri = WikiTagUtils::getDbpediaUri($tag->getWikipediaUrl(), [], false, "wikiurl"); + $uri = WikiTagUtils::getDbpediaUri($tag->getWikipediaUrl(), array(), false, "wikiurl"); $tag->setDbpediaUri($uri); $em->persist($tag); if($uri!=NULL && $uri!=""){ @@ -102,7 +102,7 @@ echo "\n".count($tags)." tags to search."; foreach($tags as $tag){ $l = $tag->getLabel(); - $uri = WikiTagUtils::getDbpediaUri($tag->getLabel(), [], false); + $uri = WikiTagUtils::getDbpediaUri($tag->getLabel(), array(), false); $tag->setDbpediaUri($uri); $em->persist($tag); if($uri!=NULL && $uri!=""){ diff -r 88405a9b804a -r 65c12455ce74 Model/DocumentTag.php --- a/Model/DocumentTag.php Tue Apr 08 13:13:30 2014 +0200 +++ b/Model/DocumentTag.php Fri Jul 04 16:57:17 2014 +0200 @@ -220,7 +220,8 @@ */ public function getWikipediaVersionPermalink() { - return sprintf($GLOBALS["kernel"]->getContainer()->getParameter("wiki_tag.url_templates")["wikipedia_permalink"], $this->wikipediaRevisionId); + $url_templates = $GLOBALS["kernel"]->getContainer()->getParameter("wiki_tag.url_templates"); + return sprintf($url_templates["wikipedia_permalink"], $this->wikipediaRevisionId); } } \ No newline at end of file diff -r 88405a9b804a -r 65c12455ce74 Model/ModelException.php diff -r 88405a9b804a -r 65c12455ce74 README.md diff -r 88405a9b804a -r 65c12455ce74 Resources/public/css/clickmenu.css diff -r 88405a9b804a -r 65c12455ce74 Resources/public/images/arrow_refresh.png diff -r 88405a9b804a -r 65c12455ce74 Resources/public/images/cross.png diff -r 88405a9b804a -r 65c12455ce74 Resources/public/images/myshadow.png diff -r 88405a9b804a -r 65c12455ce74 Resources/public/images/tick.png diff -r 88405a9b804a -r 65c12455ce74 Resources/public/js/jquery.clickmenu.js diff -r 88405a9b804a -r 65c12455ce74 Resources/public/js/jquery.cookie.js diff -r 88405a9b804a -r 65c12455ce74 Services/DocumentService.php diff -r 88405a9b804a -r 65c12455ce74 Services/WikiTagServiceException.php diff -r 88405a9b804a -r 65c12455ce74 Tests/Services/DocumentServiceTest.php diff -r 88405a9b804a -r 65c12455ce74 Utils/FilteredSchemaTool.php diff -r 88405a9b804a -r 65c12455ce74 Utils/WikiTagUtils.php --- a/Utils/WikiTagUtils.php Tue Apr 08 13:13:30 2014 +0200 +++ b/Utils/WikiTagUtils.php Fri Jul 04 16:57:17 2014 +0200 @@ -224,7 +224,8 @@ } } - $url = $GLOBALS["kernel"]->getContainer()->getParameter("wiki_tag.url_templates")["wikipedia_api"].'?'.$params_str; + $url_templates = $GLOBALS["kernel"]->getContainer()->getParameter("wiki_tag.url_templates"); + $url = $url_templates["wikipedia_api"].'?'.$params_str; $res = WikiTagUtils::curlRequest($url); $val = json_decode($res, true); @@ -260,10 +261,11 @@ /** * Builds DbPedia URI */ - public static function getDbpediaUri($label, $params=[], $throw_error=true, $req_param="label") + public static function getDbpediaUri($label, $params=array(), $throw_error=true, $req_param="label") { // Get lang from url - $dbp_url = $GLOBALS["kernel"]->getContainer()->getParameter("wiki_tag.url_templates")["dbpedia_sparql"]; + $url_templates = $GLOBALS["kernel"]->getContainer()->getParameter("wiki_tag.url_templates"); + $dbp_url = $url_templates["dbpedia_sparql"]; $lang = substr($dbp_url, 7, 2); // filter with regexp to avoid results with "category:LABEL" or other "abc:LABEL" $query = 'select distinct * where { ?s rdfs:label "'.$label.'"@'.$lang.' . FILTER (regex(?s, "^http\\\\://[^:]+$")) }'; @@ -274,10 +276,10 @@ $query = 'select distinct * where { ?s foaf:isPrimaryTopicOf <'.$label.'> }'; } - $params = [ + $params = array( "query" => $query, "format" => 'application/json', - ]; + ); $params_str = ''; foreach ($params as $key => $value) { @@ -289,7 +291,8 @@ } } - $url = $GLOBALS["kernel"]->getContainer()->getParameter("wiki_tag.url_templates")["dbpedia_sparql"].'?'.$params_str; + $url_templates = $GLOBALS["kernel"]->getContainer()->getParameter("wiki_tag.url_templates"); + $url = $url_templates["dbpedia_sparql"].'?'.$params_str; $res = WikiTagUtils::curlRequest($url, $throw_error); $val = json_decode($res, true);