# HG changeset patch # User cavaliet # Date 1330019579 -3600 # Node ID bb7808e180c36f859a9d986d6639d87504c9e71e # Parent 12fc4e8b6fded4420757682eec8b129804a01e20 Add configuration to enable curl request with proxy or any other CURLOPT diff -r 12fc4e8b6fde -r bb7808e180c3 Controller/WikiTagController.php --- a/Controller/WikiTagController.php Mon Feb 20 12:09:41 2012 +0100 +++ b/Controller/WikiTagController.php Thu Feb 23 18:52:59 2012 +0100 @@ -107,6 +107,7 @@ } $ordered_tags = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOrderedTagsForDoc($id_doc); + //$ordered_tags = null; return $this->render('WikiTagBundle:WikiTag:documentTags.html.twig', array('ordered_tags' => $ordered_tags, 'doc_id' => $id_doc, 'columns' => $columns_array)); } diff -r 12fc4e8b6fde -r bb7808e180c3 DependencyInjection/Configuration.php --- a/DependencyInjection/Configuration.php Mon Feb 20 12:09:41 2012 +0100 +++ b/DependencyInjection/Configuration.php Thu Feb 23 18:52:59 2012 +0100 @@ -66,6 +66,12 @@ ->prototype('variable') ->end() ->end() + ->arrayNode('curl_options') + ->treatNullLike(array()) + ->useAttributeAsKey('name') + ->prototype('variable') + ->end() + ->end() ->end(); return $treeBuilder; diff -r 12fc4e8b6fde -r bb7808e180c3 DependencyInjection/WikiTagExtension.php --- a/DependencyInjection/WikiTagExtension.php Mon Feb 20 12:09:41 2012 +0100 +++ b/DependencyInjection/WikiTagExtension.php Thu Feb 23 18:52:59 2012 +0100 @@ -53,5 +53,6 @@ $container->setParameter("wiki_tag.route_for_documents_by_tag", $config['route_for_documents_by_tag']); $container->setParameter("wiki_tag.reactive_selectors", $config['reactive_selectors']); $container->setParameter("wiki_tag.document_list_profile", $config['document_list_profile']); + $container->setParameter("wiki_tag.curl_options", $config['curl_options']); } } diff -r 12fc4e8b6fde -r bb7808e180c3 Resources/public/css/wikiTag.css --- a/Resources/public/css/wikiTag.css Mon Feb 20 12:09:41 2012 +0100 +++ b/Resources/public/css/wikiTag.css Thu Feb 23 18:52:59 2012 +0100 @@ -10,6 +10,7 @@ float: left; overflow: auto; width: 100%; + min-height: 300px; } #wikitag_table { width: 100%; diff -r 12fc4e8b6fde -r bb7808e180c3 Utils/WikiTagUtils.php --- a/Utils/WikiTagUtils.php Mon Feb 20 12:09:41 2012 +0100 +++ b/Utils/WikiTagUtils.php Thu Feb 23 18:52:59 2012 +0100 @@ -200,9 +200,25 @@ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - //TODO: change - curl_setopt($ch, CURLOPT_USERAGENT, 'http://www.iri.centrepompidou.fr'); + // default values + curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:10.0.1) Gecko/20100101 Firefox/10.0.1'); curl_setopt($ch, CURLOPT_TIMEOUT_MS, 5000); + // Set options if they are set in the config.yml file, typically for proxy configuration. + // Thanks to the configuration file, it will execute commands like "curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);" or "curl_setopt($ch, CURLOPT_PROXY, "xxx.yyy.zzz:PORT");" + $curl_options = $GLOBALS["kernel"]->getContainer()->getParameter("wiki_tag.curl_options"); + foreach ($curl_options as $key => $value) { + if(strtoupper($value)=='TRUE'){ + $value = TRUE; + } + else if (strtoupper($value)=='FALSE'){ + $value = FALSE; + } + else if (defined($value)){ + $value = constant($value); + } + curl_setopt($ch, constant($key), $value); + } + // end of treatment $res = curl_exec($ch); $curl_errno = curl_errno($ch); $curl_error = curl_error($ch);