Re: [PHP] What is the name of the pattern that will ...
On 13 June 2013 18:38, David Harkness wrote: > Hi Richard, > > On Thu, Jun 13, 2013 at 10:16 AM, Richard Quadling wrote: > >> I'm building a class which needs to have certain methods called by the >> subclass, but the subclass can extend but not obscure/override the >> behaviour. >> > > This is the Template Method pattern, though in this case you could use a > Strategy where the specific authentication implementation is in a separate > class that gets injected into the Auth class. As for your example there a a > few things I would change. > > * The template method that the subclass must implement should not be > declared by an interface. Interfaces are for declaring public contracts. > You can simply declare an abstract, protected method in Auth. This is the > contract that every subclass must fulfill. > > * I would avoid reference variables as you've indicated. If you don't want > to build a data-holder class yet, simply return an array for now. While you > cannot enforce the return type at parse time, they should be verified with > unit tests. Unit tests are critical with dynamic languages like PHP and > Python since runtime is the only way to verify behavior. > > Otherwise, your example is spot on, though the name AuthRequestMade > implies the request has already been made yet I think from your description > that this method should *make* the actual request. Here's how I would > write it with the above in place. > > class Auth { > public function MakeAuthRequest() { > // before > $this->MakeAuthRequestImpl(); // Adding "Impl" suffix is a > common convention > // after > } > > /** > * Make the actual authentication request. > * > * @return array Must contain keys "state" and "message" to hold > the result > */ > protected abstract function MakeAuthRequestImpl(); > } > > Peace, > David > > Excellent advice. I will be making an extendable data holder class. I'm going to do the sort of thing Zend_Db does for the adapter/rowset/row classes, allowing an extended class to supply the corresponding extended adapter/rowset/row classes. Each of the base classes has a job to do, but they can only operate in conjunction with an external provider. Thanks for the pointers. Richard. -- Richard Quadling Twitter : @RQuadling EE : http://e-e.com/M_248814.html Zend : http://bit.ly/9O8vFY
Re: [PHP] Detect and Redirect Mobile Users
On Jun 13, 2013, at 15:31, Camille Hodoul wrote: > Hello, > > I stumbled upon this the other day : > http://mobiledetect.net/ > I haven't tried it yet, since I have my own small user agent parser when I > need it, but it may help you if it's a pure php solution you're looking for. > > Have a nice day > > > 2013/6/13 dealTek > >> Hi all, >> >> I'm curious of a simple, common, universal way to detect a mobile user so >> I can redirect them to a mobile directory... >> >> What is best for this: Javascript - CSS - PHP? >> >> I think for my purposes if I can detect screen size or mobile browser >> agent - that would be good enough for what I need right now. >> >> Thanks in advance - Dave >> >> >> -- >> Thanks, >> Dave - DealTek >> deal...@gmail.com >> [db-3] >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > > -- > Camille Hodoul > http://camille-hodoul.com/ Some time ago, I tested php-mobile-detect and detectmobilebrowsers.com, taking the (old) wurfl database (as a reference with a bit less than 15.000 mobile devices). Tests came out as follows: php-mobile-detect: 7 seconds in 15.000 devices, 70% accuracy detectmobilebrowsers.com: 0.6 seconds in 15.000 devices, 93,5% accuracy The post I made is in spanish, but could serve as a reference: http://blog.unreal4u.com/2012/10/detectar-facilmente-un-dispositivo-movil/ As for the OP, I think that the best way would be PHP, because you can do a lot more, like not even redirecting the user but rather just load the mobile site directly, setting a session value if desktop version is forced or not. This way, any links would also be interchangeable, making it easier for you to implement specific functionality such as "send link through email" and other related things. Greetings. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Detect and Redirect Mobile Users
Hi, Post your question to http://answershat.com On Thu, Jun 13, 2013 at 4:49 AM, dealTek wrote: > Hi all, > > I'm curious of a simple, common, universal way to detect a mobile user so > I can redirect them to a mobile directory... > > What is best for this: Javascript - CSS - PHP? > > I think for my purposes if I can detect screen size or mobile browser > agent - that would be good enough for what I need right now. > > Thanks in advance - Dave > > > -- > Thanks, > Dave - DealTek > deal...@gmail.com > [db-3] > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- *Thanks & Regards, Chirag Vekariya. +91-87582 45922*
Re: [PHP] Detect and Redirect Mobile Users
http://www.answershat.com/questions/352/How-to-get-rid-of-spam-mail-in-my-mailbox On 14 June 2013 09:28, Chirag Vekariya wrote: > Hi, > Post your question to http://answershat.com > > On Thu, Jun 13, 2013 at 4:49 AM, dealTek wrote: > >> Hi all, >> >> I'm curious of a simple, common, universal way to detect a mobile user so >> I can redirect them to a mobile directory... >> >> What is best for this: Javascript - CSS - PHP? >> >> I think for my purposes if I can detect screen size or mobile browser >> agent - that would be good enough for what I need right now. >> >> Thanks in advance - Dave >> >> >> -- >> Thanks, >> Dave - DealTek >> deal...@gmail.com >> [db-3] >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > > -- > *Thanks & Regards, > Chirag Vekariya. > +91-87582 45922* -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] LightBox click detection
Hi gang: It's Friday so I am allowed to ask odd questions. Here's the problem -- I need to count the number of times a user activates a LightBox -- how do you do that? Here's a LightBox Example: http://www.webbytedd.com/c2/lightbox/ All the javascript is there (jQuery et al). Ideally, I would like to have a php/javascript combination that would: 1. Detect when a user clicked the LightBox; 2. Pass that value to PHP so I can keep count. Any ideas? Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] LightBox click detection
$('.lightbox-image-class').click(function(){ $.post('ajax.php', {click: true}); }); and do your DB work in ajax.php http://api.jquery.com/jQuery.post/ On 14 June 2013 09:52, Tedd Sperling wrote: > Hi gang: > > It's Friday so I am allowed to ask odd questions. > > Here's the problem -- I need to count the number of times a user activates a > LightBox -- how do you do that? > > Here's a LightBox Example: > >http://www.webbytedd.com/c2/lightbox/ > > All the javascript is there (jQuery et al). > > Ideally, I would like to have a php/javascript combination that would: > > 1. Detect when a user clicked the LightBox; > 2. Pass that value to PHP so I can keep count. > > Any ideas? > > Cheers, > > tedd > > _ > t...@sperling.com > http://sperling.com > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] LightBox click detection
Also, the docs and functionality for that particular plugin seem a bit weak. Maybe there's another one that has a "doneLoadingLightbox" event that you could hook into and call your ajax script inside of... On 14 June 2013 10:02, Marc Guay wrote: > $('.lightbox-image-class').click(function(){ > $.post('ajax.php', {click: true}); > }); > > and do your DB work in ajax.php > > http://api.jquery.com/jQuery.post/ > > On 14 June 2013 09:52, Tedd Sperling wrote: >> Hi gang: >> >> It's Friday so I am allowed to ask odd questions. >> >> Here's the problem -- I need to count the number of times a user activates >> a LightBox -- how do you do that? >> >> Here's a LightBox Example: >> >>http://www.webbytedd.com/c2/lightbox/ >> >> All the javascript is there (jQuery et al). >> >> Ideally, I would like to have a php/javascript combination that would: >> >> 1. Detect when a user clicked the LightBox; >> 2. Pass that value to PHP so I can keep count. >> >> Any ideas? >> >> Cheers, >> >> tedd >> >> _ >> t...@sperling.com >> http://sperling.com >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Detect and Redirect Mobile Users
> -Original Message- > From: Dead Letter.Office [mailto:dead.letter.off...@isam.co.nz] > Sent: 14 June 2013 05:22 > To: php-general@lists.php.net > > http://php.net/manual/en/misc.configuration.php#ini.browscap > http://tempdownloads.browserscap.com/ > > $browser = get_browser(null, TRUE); > if (isset($browser['ismobiledevice']) && ($browser['ismobiledevice'] > == TRUE)) { > $isMobile = TRUE; > } > else { > = FALSE; > } > unset($browser); Argh!, Argh!, Argh! -- two of my pet hates in one snippet! Comparing something ==TRUE is almost always unnecessary, and absolutely always when it's used as an element of a Boolean expression: if x evaluates to TRUE, x==TRUE is also TRUE, and if it evaluates to FALSE x==TRUE is also FALSE, so the comparison is unnecessary, redundant and wasteful. Just use x. And why use an if test on a Boolean value to see if it's TRUE or FALSE, just so you can assign TRUE or FALSE?? Since the thing you're testing has the value you want in the first place, just flipping assign it! $isMobile = isset($browser['ismobiledevice']) && $browser['ismobiledevice']; Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Portland PD507, City Campus, Leeds Metropolitan University, Portland Way, LEEDS, LS1 3HE, United Kingdom (FROM 21st JUNE: Leslie Silver Building 403a, City Campus, Woodhouse Lane, LS1 3ES) E: m.f...@leedsmet.ac.uk T: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php