Jump to content

dgoosens

Members
  • Posts

    230
  • Joined

  • Last visited

Everything posted by dgoosens

  1. Quite sure that I'm not the only French speaking person that spends time around here... And, PHP Solutions also has an English version (phpsolmag.com)... So it would be interesting to see if they encounter the same difficulties.
  2. Hi, This mainly concerns the French speaking people out there. I have been buying PHP Solutions (http://phpsolmag.org) for two years now... Since January however, no new issues of the magazine have been published. I have paid for a yearly subscription and, if the magazine is discontinued... well I would just want my money back - seems legit doesn't it ? I have been trying to contact the publisher, but no one seems to answer. So, does anybody know if the magazine has been discontinued ? Will there be no more new releases ? Did anybody have the same problem and managed to contact somebody at phpsolmag ? And maybe got a refund ? Thanks in advance, dgoosens
  3. 'k this seems to work : use \XMLReader; class XMLReaderX extends XMLReader { /** * depth of the previous node * * @var int */ protected $_previousDepth = 0; /** * list of the parsed nodes * * @var array */ protected $_nodesParsed = array(); /** * keep track of the node types * * @var array */ protected $_nodesType = array(); /** * keeps track of the node number * * @var array */ protected $_nodesCount = array(); /** * list of nodes that matter for XPath * * @var array */ protected $_referencedNodeTypes = array( parent::ELEMENT, parent::ATTRIBUTE, parent::TEXT, parent::CDATA, parent::COMMENT ); /** * keep track of all the parsed paths * * @var array */ protected $_parsedPaths = array(); /** * Move to next node in document * * @throws XMLReaderException * @link http://php.net/manual/en/xmlreader.read.php * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. */ public function read() { $read = parent::read(); if(in_array($this->nodeType, $this->_referencedNodeTypes)) { if($this->depth < $this->_previousDepth) { if(!isset($this->_nodesParsed[$this->depth])) { throw new \Exception('Missing items in $_nodesParsed'); } if(!isset($this->_nodesCount[$this->depth])) { throw new \Exception('Missing items in $_nodesCounter'); } if(!isset($this->_nodesType[$this->depth])) { throw new \Exception('Missing items in $_nodesType'); } $this->_nodesParsed = array_slice($this->_nodesParsed, 0, $this->depth + 1, true); $this->_nodesCount = array_slice($this->_nodesCount, 0, $this->depth + 1, true); $this->_nodesType = array_slice($this->_nodesType, 0, $this->depth + 1, true); } if(isset($this->_nodesParsed[$this->depth]) && $this->localName == $this->_nodesParsed[$this->depth] && $this->nodeType == $this->_nodesType[$this->depth]) { $this->_nodesCount[$this->depth] = $this->_nodesCount[$this->depth] + 1; } else { $this->_nodesParsed[$this->depth] = $this->localName; $this->_nodesType[$this->depth] = $this->nodeType; $logPath = $this->_getLogPath(); if(isset($this->_parsedPaths[$logPath])) { $this->_nodesCount[$this->depth] = $this->_parsedPaths[$logPath] + 1; } else { $this->_nodesCount[$this->depth] = 1; // first node is 1, not 0 } } if($this->nodeType == parent::ELEMENT) { $this->_parsedPaths[$this->_getLogPath()] = $this->_nodesCount[$this->depth]; } $this->_previousDepth = $this->depth; } return $read; } /** * getNodePath() * * @return string XPath of the current node */ public function getNodePath() { if(count($this->_nodesCount) != count($this->_nodesParsed) && count($this->_nodesCount) != count($this->_nodesType)) { throw new \Exception('Counts do not match'); } $nodePath = ''; foreach ($this->_nodesParsed as $depth => $nodeName) { switch ($this->_nodesType[$depth]) { case parent::ELEMENT: $nodePath .= '/' . $nodeName . '[' . $this->_nodesCount[$depth] . ']'; break; case parent::ATTRIBUTE: $nodePath .= '[@' . $nodeName . ']'; break; case parent::TEXT: case parent::CDATA: $nodePath .= '/text()'; break; case parent::COMMENT: $nodePath .= '/comment()'; break; default: throw new \Exception('Unknown node type'); break; } } return $nodePath; } /** * get the path of the actual node for logging * * @return string */ protected function _getLogPath() { $path = ''; $localCopy = $this->_nodesParsed; if(isset($localCopy[$this->depth])) { unset($localCopy[$this->depth]); } foreach ($localCopy as $depth => $nodeName) { $path .= '/' . $nodeName . '[' . $this->_nodesCount[$depth] . ']'; } $path .= '/' . $this->localName; return $path; } } Let me know if you encounter any issues... GITHUB : https://github.com/dGo/XMLReaderX
  4. the above class contains errors... do not use it yet
  5. If it does not exist, invent it... There is quite some work that has to be done, but for what I am doing, this is a very good start : class XMLReaderI extends \XMLReader { /** * depth of the current node * * @var int */ private $_currentDepth = 0; /** * depth of the previous node * * @var int */ private $_previousDepth = 0; /** * list of the parsed nodes * * @var array */ private $_nodesParsed = array(); /** * keep track of the node types * * @var array */ private $_nodesType = array(); /** * keeps track of the node number * * @var array */ private $_nodesCounter = array(); /** * Move to next node in document * * @link http://php.net/manual/en/xmlreader.read.php * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. */ public function read() { $r = parent::read(); if($this->depth < $this->_previousDepth) { if(!isset($this->_nodesParsed[$this->depth])) { throw new \Exception('Missing items in $_nodesParsed'); } if(!isset($this->_nodesCounter[$this->depth])) { throw new \Exception('Missing items in $_nodesCounter'); } if(!isset($this->_nodesType[$this->depth])) { throw new \Exception('Missing items in $_nodesType'); } $this->_nodesParsed = array_slice($this->_nodesParsed, 0, $this->depth + 1, true); $this->_nodesCounter = array_slice($this->_nodesCounter, 0, $this->depth + 1, true); $this->_nodesType = array_slice($this->_nodesType, 0, $this->depth + 1, true); } if(isset($this->_nodesParsed[$this->depth]) && $this->localName == $this->_nodesParsed[$this->depth] && $this->nodeType == $this->_nodesType[$this->depth]) { $this->_nodesCounter[$this->depth] = $this->_nodesCounter[$this->depth] + 1; } else { $this->_nodesParsed[$this->depth] = $this->localName; $this->_nodesType[$this->depth] = $this->nodeType; $this->_nodesCounter[$this->depth] = 1; } $this->_previousDepth = $this->depth; return $r; } /** * getNodePath() * * @return string XPath of the current node */ public function getNodePath() { if(count($this->_nodesCounter) != count($this->_nodesParsed) && count($this->_nodesCounter) != count($this->_nodesType)) { throw new Exception('Counts do not match'); } $nodePath = ''; foreach ($this->_nodesParsed as $depth => $nodeName) { switch ($this->_nodesType[$depth]) { case parent::ELEMENT: $nodePath .= '/' . $nodeName . '[' . $this->_nodesCounter[$depth] . ']'; break; case parent::TEXT: case parent::CDATA: $nodePath .= '/text()'; break; case parent::COMMENT: $nodePath .= '/comment()'; break; case parent::ATTRIBUTE: $nodePath .= '[@' . $nodeName . ']'; break; default: break; } } return $nodePath; } }
  6. damn... SimpleXml runs for 15 seconds with XMLReader, barely 2 Keep on searching for Xpaht in XMLReader...
  7. thanks... the first trial did not run with foreach... now that I looked at it properly, it runs flawlessly cheers once more
  8. Thanks Salathe... I owe you a beer... Or at least half one XMLReader -> DOM -> getNodePath() was not what I was looking for... As you mention already, it does not include positional information. BUT... Thanks to your idea (SimpleXML -> DOM -> getNodePath()) I found the dom_import_simplexml() function I did not know yet... This does exactly what I needed : <?php function parse(SimpleXMLIterator $xi) { for ($xi->rewind(); $xi->valid(); $xi->next()) { if($xi->hasChildren()) { parse($xi->current()); } else { if(true) { //CONDITION HERE $domEl = dom_import_simplexml($xi->current()); echo $domEl->getNodePath() . PHP_EOL; } } } } $file = 'PATH/test.xml'; $xi = new SimpleXMLIterator($file, null, true); parse($xi); Now I get all the exact nodePaths Cheers
  9. It is very simple... I've got an XML document that I need to parse node by node with XMLReader. If the node's content matches a given regex pattern, I need to get the Xpath to that node.
  10. Just gave SimpleXML (Element & Iterator - http://www.php.net/manual/en/book.simplexml.php) a try... Same issue... Is very fast but it seems impossible to get the XPath of a given node.
  11. Hi, I have been searching all over the web but have not found a useful answer... Hope you guys can help me. This is the situation. I have a rather big XML file (13Mb - 4100 lines) where I need to search for data in the text elements using regex patterns. To do so, I parse the file with XMLReader (http://www.php.net/XMLReader). I have tried to use DOMDocument (http://www.php.net/m...domdocument.php), which I prefer, but it really is too slow. The script runs really well as it returns me all the matches without any issue and very very fast. BUT, I need to know the exact Xpath of every matched node and, surprisingly, XMLReader does not come with a XPath attribute or metod. So, basically, what I am searching for is a effective (speed is important) way to get to know the XPath of any node parsed with XMLReader... Any suggestions ? Thanks for your time and feedback.
  12. I agree... It takes quite some time and effort to get along with ZF... but once you're in it... you'll want to use it for more or less everything (and why not a blog...) Do buy a good book on it and start exercising !!
  13. you might want to cut the problem into different pieces... 1. form management 2. saving form input to file (I would personaly use XML for this... have a look at XMLReader and XMLWriter on php.net) 3. rendering the blog (parsing the XML files and displaying the data) you'll find tutorials for all of these elements...
  14. this database structure does not look very efficient to me... why not like this: ID | date_start | date_end | name | amount ??
  15. that's the one I started with... really good to learn PHP although it does not really go deep on OOPHP... for OOPHP, I'd suggest "Pro PHP - Patterns, Frameworks, Testing and More" by Kevin McArthur
  16. dgoosens

    zend tool

    just noticed that with the XML configuration, it was not possible anymore to create new modules... it should be like this: <?xml version="1.0"?> <projectProfile type="default" version="1.10"> <projectDirectory> <projectProfileFile filesystemName=".zfproject.xml"/> <applicationDirectory classNamePrefix="Application_"> <apisDirectory enabled="false"/> <configsDirectory> <applicationConfigFile type="ini"/> </configsDirectory> <controllersDirectory> </controllersDirectory> <formsDirectory enabled="false"/> <layoutsDirectory enabled="false"/> <modelsDirectory> </modelsDirectory> <modulesDirectory enabled="false"> <moduleDirectory moduleName="default"> <apisDirectory enabled="false"/> <configsDirectory> <applicationConfigFile type="ini"/> </configsDirectory> <controllersDirectory> <controllerFile controllerName="Index"> <actionMethod actionName="index"/> </controllerFile> <controllerFile controllerName="Error"/> <controllerFile controllerName="Test"> <actionMethod actionName="index"/> </controllerFile> [...] </controllersDirectory> <formsDirectory enabled="false"/> <layoutsDirectory enabled="false"/> <modelsDirectory> [...] </modelsDirectory> <viewsDirectory> <viewScriptsDirectory> <viewControllerScriptsDirectory forControllerName="Index"> <viewScriptFile forActionName="index"/> </viewControllerScriptsDirectory> <viewControllerScriptsDirectory forControllerName="Error"> <viewScriptFile forActionName="error"/> </viewControllerScriptsDirectory> <viewControllerScriptsDirectory forControllerName="Test"> <viewScriptFile forActionName="index"/> </viewControllerScriptsDirectory> [...] </viewScriptsDirectory> <viewHelpersDirectory/> <viewFiltersDirectory enabled="false"/> </viewsDirectory> <bootstrapFile filesystemName="Bootstrap.php"/> </moduleDirectory> <moduleDirectory moduleName="admin"> <apisDirectory enabled="false"/> <configsDirectory enabled="false"/> <controllersDirectory> <controllerFile controllerName="Index"> <actionMethod actionName="index"/> [...] </controllerFile> </controllersDirectory> <formsDirectory enabled="false"/> <layoutsDirectory enabled="false"/> <modelsDirectory> [...] </modelsDirectory> <viewsDirectory> <viewScriptsDirectory> <viewControllerScriptsDirectory forControllerName="Index"> <viewScriptFile forActionName="index"/> </viewControllerScriptsDirectory> [...] </viewControllerScriptsDirectory> </viewScriptsDirectory> <viewHelpersDirectory/> <viewFiltersDirectory/> </viewsDirectory> </moduleDirectory> [...] </modulesDirectory> <viewsDirectory> </viewsDirectory> </applicationDirectory> <dataDirectory enabled="false"> [...] </dataDirectory> <docsDirectory> [...] </docsDirectory> <libraryDirectory> [...] </libraryDirectory> <publicDirectory> [...] </publicDirectory> <projectProvidersDirectory enabled="false"/> <temporaryDirectory enabled="false"/> <testsDirectory> [...] </testsDirectory> </projectDirectory> </projectProfile> One has to leave the default nodes in place...
  17. dgoosens

    zend tool

    ok... so I figured it out... this has nothing to do with the Zend_Tool scripts but with the .zfproject.xml that was generated for the project. This XML file contains the project layout... which, obviously uses the default Zend Application layout. All I had to do there was create a new <moduleDirectory> node under <modulesDirectory> with a moduleName="default" attribute Then, cut/paste all the controller, model and view nodes in there... and that did the trick Just in case, here is a simplified version of the XML file: <?xml version="1.0"?> <projectProfile type="default" version="1.10"> <projectDirectory> <projectProfileFile filesystemName=".zfproject.xml"/> <applicationDirectory classNamePrefix="Application_"> <modulesDirectory enabled="false"> <moduleDirectory moduleName="default"> <apisDirectory enabled="false"/> <configsDirectory> <applicationConfigFile type="ini"/> </configsDirectory> <controllersDirectory> <controllerFile controllerName="Index"> <actionMethod actionName="index"/> </controllerFile> <controllerFile controllerName="Error"/> <controllerFile controllerName="Test"> <actionMethod actionName="index"/> </controllerFile> [...] </controllersDirectory> <formsDirectory enabled="false"/> <layoutsDirectory enabled="false"/> <modelsDirectory> [...] </modelsDirectory> <viewsDirectory> <viewScriptsDirectory> <viewControllerScriptsDirectory forControllerName="Index"> <viewScriptFile forActionName="index"/> </viewControllerScriptsDirectory> <viewControllerScriptsDirectory forControllerName="Error"> <viewScriptFile forActionName="error"/> </viewControllerScriptsDirectory> <viewControllerScriptsDirectory forControllerName="Test"> <viewScriptFile forActionName="index"/> </viewControllerScriptsDirectory> [...] </viewScriptsDirectory> <viewHelpersDirectory/> <viewFiltersDirectory enabled="false"/> </viewsDirectory> <bootstrapFile filesystemName="Bootstrap.php"/> </moduleDirectory> <moduleDirectory moduleName="admin"> <apisDirectory enabled="false"/> <configsDirectory enabled="false"/> <controllersDirectory> <controllerFile controllerName="Index"> <actionMethod actionName="index"/> [...] </controllerFile> </controllersDirectory> <formsDirectory enabled="false"/> <layoutsDirectory enabled="false"/> <modelsDirectory> [...] </modelsDirectory> <viewsDirectory> <viewScriptsDirectory> <viewControllerScriptsDirectory forControllerName="Index"> <viewScriptFile forActionName="index"/> </viewControllerScriptsDirectory> [...] </viewControllerScriptsDirectory> </viewScriptsDirectory> <viewHelpersDirectory/> <viewFiltersDirectory/> </viewsDirectory> </moduleDirectory> [...] </applicationDirectory> <dataDirectory enabled="false"> [...] </dataDirectory> <docsDirectory> [...] </docsDirectory> <libraryDirectory> [...] </libraryDirectory> <publicDirectory> [...] </publicDirectory> <projectProvidersDirectory enabled="false"/> <temporaryDirectory enabled="false"/> <testsDirectory> [...] </testsDirectory> </projectDirectory> </projectProfile>
  18. dgoosens

    zend tool

    lol that would be zf.sh in my case (no bloody Windows here) but, that will not help, obviously... as this only is a wrapper for zf.php that uses all the classes in Zend_Tool That's where I need to figure out where the module default settings are defined...
  19. dgoosens

    zend tool

    thanks a lot ignace, you would not know where this particular setting is located in the zend tool files would you ? I suppose that it should be fairly easy to overrule the settings for the default module so that it works just like it does for all the other modules...
  20. dgoosens

    zend tool

    hi all, I have been using zend tools within netbeans for quite a while now and this always worked like a charm... However, I am in the middle of a new development where I wanted to use a slightly different file structure, and it seems that I am no longer able to create any controllers or actions in the default module (other modules work fine). The file structure I decided to use is like this: /appplication /data /session /cache /modules /default /config /controllers /models /views /admin /config /controllers /models /views [...] /library /App /Zend /public In my opinion, this is a much cleaner file structure... but that is not the point. I did change my default config.ini file accordingly: bootstrap.path = APPLICATION_PATH "/modules/default/Bootstrap.php" bootstrap.class = "Bootstrap" appnamespace = "Application" resources.frontController.controllerDirectory = APPLICATION_PATH "/modules/default/controllers" resources.layout.layout = "layout" resources.layout.layoutPath = APPLICATION_PATH "/modules/default/views/layouts" resources.view.encoding = 'utf-8' resources.view.basePath = APPLICATION_PATH "/modules/default/views" resources.view[] = resources.frontController.moduleDirectory = APPLICATION_PATH "/modules/" resources.modules[] = resources.frontController.defaultController = "index" resources.frontController.defaultAction = "index" resources.frontController.defaultModule = "default" resources.frontController.prefixDefaultModule = false resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" and the application works fine like this... in the browser But, when trying to run a zend tool command to create a new controller or action in the default module I get the following errors: zf.sh create controller test 1 default Fatal error: Call to a member function search() on a non-object in /home/dgoosens/DEV/LIB/ZendFramework-1.10.8/library/Zend/Tool/Project/Provider/Controller.php on line 82 Call Stack: 0.0011 814336 1. {main}() /home/dgoosens/DEV/LIB/ZendFramework-1.10.8/bin/zf.php:0 0.0012 814336 2. ZF::main() /home/dgoosens/DEV/LIB/ZendFramework-1.10.8/bin/zf.php:632 0.0053 1314392 3. ZF->run() /home/dgoosens/DEV/LIB/ZendFramework-1.10.8/bin/zf.php:74 0.0053 1314392 4. ZF->_runTool() /home/dgoosens/DEV/LIB/ZendFramework-1.10.8/bin/zf.php:117 0.0064 1453760 5. Zend_Tool_Framework_Client_Abstract->dispatch() /home/dgoosens/DEV/LIB/ZendFramework-1.10.8/bin/zf.php:608 0.1268 8921832 6. Zend_Tool_Framework_Client_Abstract->_handleDispatch() /home/dgoosens/DEV/LIB/ZendFramework-1.10.8/library/Zend/Tool/Framework/Client/Abstract.php:241 0.1269 8923048 7. Zend_Tool_Framework_Client_Abstract->_handleDispatchExecution() /home/dgoosens/DEV/LIB/ZendFramework-1.10.8/library/Zend/Tool/Framework/Client/Abstract.php:318 0.1269 8923680 8. call_user_func_array() /home/dgoosens/DEV/LIB/ZendFramework-1.10.8/library/Zend/Tool/Framework/Client/Abstract.php:324 0.1269 8924424 9. Zend_Tool_Project_Provider_Controller->create() /home/dgoosens/DEV/LIB/ZendFramework-1.10.8/library/Zend/Tool/Framework/Client/Abstract.php:0 0.1667 9451320 10. Zend_Tool_Project_Provider_Controller::hasResource() /home/dgoosens/DEV/LIB/ZendFramework-1.10.8/library/Zend/Tool/Project/Provider/Controller.php:119 If I run the command without specifying "default" as a module, zend tool creates a new file structure below /application/ The same command on the admin module, runs fine... So, my guess is zend tool does not read the config.ini settings file correctly, OR that it skips all the default settings... Any of you have encountered this kind of issues ? If so, did you figure out a way to bypass this ? (I could obviously create the files manually... but having zend tool doing the work for me is so nice)
  21. I personally don't think M$ is very reliable when talking about the Web... but that's only my personal opinion... About the wrapping... Sure you can... As your menu has a fixed width, just put a DIV around it with that width and you should be fine... But this is not "the best way" I would personally put the background as one image, put the menu in a <ul><li> list and then work with borders and padding to get the same effect <ul style="background-image:url(); width:xxx"> <li><a href="" title="">menu element</a></li> <li><a href="" title="">menu element</a></li> <li><a href="" title="">menu element</a></li> <li><a href="" title="">menu element</a></li> <li><a href="" title="">menu element</a></li> [...] </ul> the hover effect your implementing can be obtained very easily with some CSS (no need to use JS here)
  22. they are the same, although they look the same to me. but the default line-spacing for IE and FF is not the same.... you might want to set that in your body{} as well about Times New Roman are you sure you want that font ? it is recommended to use a Sans Serif font for things one reads on a screen... Serif fonts are more suited for printed material. You want to consider Arial or Verdana Also, be careful with your top navigation... when reducing the window size, the right block (next to Funding) goes to the next line...
  23. you've got a typical Windows error in your code: <img src="images\thermometer.jpg" alt="" style="height:390px"> should be: <img src="images/thermometer.jpg" alt="" style="height:390px">
  24. surely not... and if learning is the objective... you're right !
  25. well you need to create a div (or other type of block) with the ID and put an image in it... <div id="myGallery"> <img src="/path/to/som/image.png" alt="some image"> </div> and you should make a JavaScript call to the function they indicate <script type="text/javascript"> $(function(){ $('#myGallery').spacegallery({loadingClass: 'loading'}); } </script> or something like that... (not easy with the little info you supply)
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.