Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. Just wrap you site-wide configuration settings in a configuration object (or an array) and pass that to your company object using Dependency Injection. Something like: class Company { private $_name; public function __construct($cfg) { $this->_name = $cfg['company_name']; } } An example DI container can be found here: https://github.com/fabpot/Pimple A use-case can be found here: https://github.com/fabpot/Silex/blob/master/src/Silex/Application.php
  2. I like Pimple as a DI container: https://github.com/fabpot/Pimple A use-case can be found at: https://github.com/fabpot/Silex/blob/master/src/Silex/Application.php
  3. I don't get why you have a UserProfile at all... It has no id, so it's not an entity. It wraps data which I feel should belong to the User object, and it's only responsibilities are formatting. IMO, at best, your UserProfile IS a View. But since this formatting is part of your domain these should also be in your User class. Just like the below function would: public function getFullName() { return $this->getTitle() . '. ' . $this->getFirstname() . ' (' . $this->getAlias() . ') ' . $this->getLastName(); } If you have a requirement that states that you always should address the user with it's full name. Admin and Mod are Special Case's of User so these should inherit from User (but since PHP does not support method overloading, it's better to make these responsibilities also part of User and just check with isModerator() and isAdmin() of some sort). I also fail to see how Friend and Banned could be Decorators? Banned could be a Value Object that tells how the user was banned (perm, temp) and how long (in case of temp) but not a Decorator. And Friend should be just an instance of a User as element in a _friends property array. $user1->isFriendsWith($user2); //implementation public function isFriendsWith(User $u) { Assert::true(!$this->equals($u)); return $this->_friends->contains($u); }
  4. So now you have payed $200 to find out you still need to learn to program...
  5. The script appeared to hang and returned nothing. Still don't quite understand though why it works outside of the loop without the escapeshellarg() and not inside the loop. Other people have reported the same problem but they didn't have the same case as me (passed the var as second parameter) hopefully this post will help someone in the future who made the same silly mistake
  6. Phew. Found it I just needed to add escapeshellarg Can't believe I didn't try it in the first place, since it's on the PHP exec() function manual..
  7. This code works outside of the while, but not inside while ($row = mysql_fetch_assoc($res)) { $host = $row['host']; $cmd = exec("mysql -h$host -e \"show status like 'wsrep_cluster_size'\""); echo $cmd; } I have found nothing on google, stackoverflow or the php manual that explains why this does not appear to work inside a loop?
  8. It's possible that Google SE reads HTML and executes JS just like a browser does (except there will be no UI). In most cases this also means it follows the correct path (fallback to href when onclick does not return something usable for example).
  9. You can always at a later point refactor your code and create re-usable components out of it. For example: class tvfilename extends RecursiveIteratorIterator { When a string is provided we assume it's a directory path: public function __construct($input, $filter = null) { if (is_string($input)) { parent::__construct(new RecursiveDirectoryIterator($input, $filter)); } else { parent::__construct($input); } } When traversing you would pass the filename/whatever to a parser: public function current() { return $this->_parser->parse(parent::current()); } So at this point you should get an StdClass from current() with properties, if you want it to be of a certain class then you should also supply a factory to your parser: class EpisodeParser { private $_factory; public function __construct(Factory $factory = null) { $this->_factory = $factory; } public function parse($string) { // parsing if (!is_null($this->_factory)) { $parsed = $this->_factory->make($parsed); } return $parsed; } } All the responsibilities divvid up You would use it like this: $tv = new tvfilename\tvfilename('/path/to/dir', array('*.txt', '*.db', '*.url')); foreach ($tv as $episode) { echo 'SEASON: ', $episode->season, "\r\n", 'EPISODE: ', $episode->episode, "\r\n" 'SERIE: ', $episode->serie; } A simple intuitive interface
  10. Even simpler then: switch (strtolower($_GET['brand'])) { case 'compaq': echo '<img src=".." ..'; break; }
  11. Be sure to donate some of that money you just made with some help from us
  12. The Egg of Columbus: http://jsfiddle.net/BJ9XP/2/
  13. Just change the src="" of the <img/> and point it to the new location (you may need to append something like ?_=Math.rand() to the image filename for it to work).
  14. Well we can reasonably assume it will only be used to traverse directories, so i see no need to divving up the responsibilities. In what other ways are you planning on using it? Why have you started this project in the first place?
  15. You should add more responsibilities to your object, currently it does nearly nothing: $tv = new tvfilename\tvfilename('/path/to/dir', array('*.txt', '*.db', '*.url')); foreach ($tv as $episode) { echo 'SEASON: ', $episode->season, "\r\n", 'EPISODE: ', $episode->episode, "\r\n" 'SERIE: ', $episode->serie; } You could abstract what it traverses and get something like: $tv = new tvfilename\tvfilename(new tvfilename\RecursiveDirectoryFilterIterator('/path/to/dir', array('*.txt', '*.db', '*.url'))); Or in case of a DB: $tv = new tvfilename\tvfilename(new tvfilename\DbRecordIterator($dbAdapter));
  16. wigwambam already showed you:
  17. Now only if those pirates would just name those files consistently...
  18. ROFLMFAO ... you just started writing JS or something? *Creative* solution Do as jesirose said: window.location.href = "informationPage.html?desc=" + desc; And what scootsah said: <textarea disabled id="infoArea"><?php echo htmlentities(strip_tags($_GET['desc'])); ?></textarea> But it's quite possible the .html has to be .php otherwise the PHP will not get parsed (until you tell it to parse .html as well of course).
  19. I think you mean a new row in the orders table? No point in creating a new table for each customer. Look through these forums, these questions have been asked plenty. Example: http://www.phpfreaks.com/forums/index.php?topic=359091.msg1697657#msg1697657 http://www.phpfreaks.com/forums/index.php?topic=359225.msg1698394#msg1698394
  20. see here create a foreign key in phpmyadmin
  21. Are you sure you really need to match a user for each given city? What are your criteria to allow user A to search for cities B, C, and D and user E for cities C, D, and F? Is it possible you could also just group them, so that user's of group A can search in cities B, C, and D and that users in group E can search in cities C, D, and F? PS: Using a tool like PHPMaker to generate the skeleton of your project is great, like UML tools assist in generating Java code. But not for programming an enitre app.. If this is for some client then possibly at some point you will have to hand-edit the code and PHPMaker will complain (or worse overwrite) your changes. PHP/programming is not so hard, MANY have gone before you!
  22. If you use a library like jQuery you don't even have to worry about the whole AJAX part. Running AJAX with jQuery is as simple as (term is what the user typed): $.get('data.js?term=' + term, callback); As demonstrated below: // Example Code, Not Suitable For Production function runLiveSearch(conf) { conf = conf || {}; var term = conf.term || '', minLength = conf.minLength || 3, callback = conf.callback || {}; if (term.length >= minLength) { $.get('data.js?term=' + term, callback); } } $('#live-search').keypress(function() { runLiveSearch({term: $(this).val(), callback: function(data) { // process }}); });
  23. WE CAN NOT HELP YOU IF YOU KEEP WITHOLDING INFORMATION. I ALSO TOOK UP CAPS FOR WRITING SINCE YOU ARE SO USED TO IT, I HOPE YOU DON'T MIND. IMO ARE YOU DOING THIS: $ACCOUNT->GET_SPECIFEC_ATT('$BRANCH_NAME', ''); IT SHOULD BE $ACCOUNT->GET_SPECIFEC_ATT('BRANCH_NAME', '');
  24. Since you have an API, developers already adhere to something. Why would jQuery.load be insecure? We are going to need more info. If they can't compromise you through your API, I would allow the developers as much freedom as possible. Allowing creativity is key to attracting parties.
×
×
  • 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.