WebConsults.EUQuicksearchKategorien |
Tuesday, September 2. 2008Overlying DIV
Just a simple JavaScript example how to display a overlying div on the whole page which is blocking all underlying links and forms and also handles problems with selectboxes in IE Browsers. Sometimes it is neccesary if you wan´t to prevent the user clicking around on the site example during an html loading process.
Sometimes it can be more usefull to only put it on a part of the site so the user can still access main site navigation.
<div id="overlyingdiv" style="visibility: hidden; position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; filter:alpha(opacity=50); -moz-opacity: 0.50; background-color: #999999; text-align: center;"> <iframe width="100%" height="100%" style="background-color:transparent;"> </iframe> <div style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; filter:alpha(opacity=50); -moz-opacity: 0.50; background-color: #999999; text-align: center;"> <div style="display:block; margin:0 auto; position:absolute; top: 50%; left:50%;"><img src="loader.giff" alt="" /><br /> Loading Data...</div> </div> </div>' function l(){ $('overlyingdiv').style.visibility='visible'; } function loadingBlockerDisable(){ $('overlyingdiv').style.visibility='hidden'; } Thursday, August 28. 2008My Skill Cloud
At the moment the job market for IT Professionals is doing really well so also recruitment agencys or job sites have new ideas.
Now you can create a skill clound and search jobs by your given skills, i just tested out and here is my skill cloud but i am not sure if they aren´t doing a simple keyword search with no relevation of the skill weight cause they suggested me ASP jobs in first result.
Monday, August 25. 2008Webconsults at SymfonyCamp 2008
I just signed up Symfony Camp 2008,
a 2 day meeting in the mid of the Netherlands. Interesting not too comercial Symfony Camp with a lot of experts from the Symphony Scene, interesting topics like and "Friday 17.30 Drinks and BBQ", Debugging, symfony performance, Propel vs Doctrine or Lessons learned at Yahoo.
I am not sure yet if i will book a hotel or sleep in the provided dutch army tents.
Monday, August 11. 2008HTML Frontend Developer Jobs on the marked
Today i just got once more an offer for an contract as HTML Frontend Developer with just HTML, CSS and JavaScript skills,
i am wondering who might be specialized in Frontend jobs just for HTML GUIs. 1998 Years ago everybody told 90DM(45EUR) for HTML coding is a lot too much HTML can be done by everybody and sure there will be no more jobs for HTML
Monday, August 4. 2008Putting RSS content via simplexml into Symfony/Propel objects
When i tried to read from an rss file to import into symfony i got an error
Fatal error: Call to undefined method SimpleXMLElement::__toString() in ....lib/symfony/plugins/sfPropelPlugin/lib/vendor/creole/common/PreparedStatementCommon.php on line 596While for printing out a string readen by SimpleXML is jost okay, for Symfony it is not. $rsscontent=file_get_contents($rssfeed); $rssfile=simplexml_load_string($rsscontent); foreach($rssfile->channel->item as $rssitem){ $c = new Criteria(); $strName=$rssitem->name; $c->add(ProcuctPeer::Name, $strName); $objProduct=ProductPeer::doSelect($c); $strName=(string)$rssitem->name;
For setting values also the simplexml object of type string works.
$objProduct->setName($rssitem->name)
Friday, July 4. 2008Messages from Ajax Requests
Giving back errors from AJAX requests is not that easy all the time.
One possibility is to give back an Error Message by the AJAX Result,
but this is not that comfortable at any time you have to put an error handling inside your AJAX call which is returning the message to the user.
Another solution are session based error messages for that you have to implement an Ajax error handling class.
For this messages you create a div layer inside your HTML.
<div id="messagefield" style="visibility: hidden;"> <a href="#" onclick="CloseMessageField()">close</a> <div id="messagefieldtext"></div> </div>'; <?PHP if($strMessageText){ echo "<script type='text/javascript'> ShowMessageField() </script>"; } ?>This example is using Prototype. <script language='JavaScript'> function CloseMessageField() { document.getElementById('messagefield').style.visibility = 'hidden'; } function ShowMessageField() { document.getElementById('messagefield').style.visibility = 'visible'; } function RefreshMessageField(){ ajaxRequest=new Ajax.Request('/your/messege/ajax/url', { method:'get', onSuccess: function(transport) { if(transport.responseText.length > 1){ document.getElementById('messagefieldtext').innerHTML=document.getElementById('messagefieldtext').innerHTML+transport.responseText; ShowMessageField(); } } } ); } </script>Now you create an the AJAX Server by just returning simple HTML code instead XML you save some time if(is_array($_SESSION['errors'] && count($_SESSION['errors']) > 0){ //returning the errors foreach($_SESSION['errors'] as $strError){ echo $strError; } //reset the error string $_SESSION['errors']=array(); }Now you can give out Errors to a message window just by adding them to a Session like $_SESSION['errors'][]="There has been an error by saving your entry"or you can even use it to catch PHP Errors by using the set_error_handler function to see the PHP Errors which were thrown during the AJAX request execution. Any time you have a failed AJAX request you just call the RefreshMessageField() function instead from the returned AJAX response messages. Within your AJAX request you just have to differ between successful answer or showing the error message window. This example is a bit simplified i wrote myself an own Error handling class which supports multiple reporting modes which differ between a Development mode and Production mode but this should give you an overview how the process works. Tuesday, June 17. 2008JavaScript Sandbox Proxy in PHP
Well for your website you´ll often have to include external JavaScript like tags of ad partners, external adserver etc.
These foreign JavaScript is always a security risk, if a optional enemy is able to change the external JS he might take effect of CrossSite Scripting on your site. So how to protect against XSS from partners you need to include but which are possibly evil.
Well there might be the solution of a PHP based JavaScript interpreter wich could handle external JS in a server based sandbox,
J4P5 might be a solution to it it makes you able to run JavaScript from your PHP Server so it´s a kind of interpreter to it. Based on your server you need to evaluate the JS generated code if it is not generating possibly eval JavaScript. It might cause some disadvatages like if ad tags try to determine your browser, ip, and maybe some JS scripts are not working of cause will not have a good effect on performance but might prevent some XSS security issues, specially if you include JS from an untrustable third party.
I ll try it out in the next time.
Monday, June 16. 2008DesignPatterns: Factory a bit more Generic
Well the task was type of data should be shown in HTML types, textfields, calendars and so on.
What i created is a FieldType factory which could load a special childclass if it is defined and would otherwise use the standard data class to handle it, this makes it possible to have a standard behavior for new data which might approach later and you don´t have to create a new class at once. Only if a special behavior is wanted you need to create a sub class for your field type.
I used some kind of Factory::Pattern to load the class which is returning the standard class if a child class for the field type is not existing, usually i hate classes or function being called by dynamic names but in this case it is very useful doesn´t mean a security risk cause the class has to be loaded in your php code before and will not bee included by thinks like
include "$classname".php or something
class Field_standard{ public $value=""; ... other functions ... public function getHtmlForm(){ return '<input type="text" name="'.$this->strName.'" value="'.$this->getValue().'" />'; } } class Field_text Extends Field_standard{ public function getHtmlForm(){ return '<textarea name="'.$this->strName.'">'.$this->getValue().'</textarea>'; } } class FieldFactory{ static public function create($strFieldName, $strFieldType) { $classname="Field_$strType"; if (class_exists($classname, false)) { return new $classname($strFieldName, $strFieldType); }else{ return new CellField_standard($strFieldName, $strFieldType, $strDefaultValue,$strDescription,$boolEditable); } } }//class Friday, June 13. 2008strstr type problem
Well using strstr function i found a variable type handling problem
PHP Version 5.1.2
try
$intSomeID="4";
$strCatList="4,5,6,7";
while
//unexpected behavior
var_dump(strstr($strCatList,$intSomeID)); returns bool(false)
//right behavior
var_dump(strstr($strCatList,"$intSomeID")); returns string "4,5,6,7";
well i always used strstr to string comparsion if something is included inside string and never hat this array before.
Usually you could implode the categorys to an array and use in_array function but it is not needed in that point.
So you have to take care with your variable types using strstr functions.
I wouldn´t call it a bug but something where you have to take care off.
Wednesday, June 11. 2008Legacy of the Past will be challenges of the Future
I just read about the 10th Birthday of PHP Lib
As a up to date PHP Developer i always like to use newest functions, features and techniques. But unfortunately at some projects this isn´t possible. Like some companies do not always use the newest PHP Version. Well usually you could install it but there might be some scripts which will cause problems on a new version.
Like i had the problem on a project where i had to work on PHP for which is running for years and they didn´t wan´t to change to PHP 5 cause there were some third party library's not supporting it. Thinks like that force you to step someway backward in technology and to abstain from using newest technologies.
If there is a project just functional coded, without OOP, without a structure which divides PHP HTML code.
Of cause you could refactor the Project using newest technologies, like MVC Pattern, Templates and so on but mostly it will not be possible in the time you were asked to do it so unfortunately you´ll have to handle the old spaghetti code.
So you have to find solutions which are not touching the complete old code but building up new features in a way they are a bit more maintainable then the old code. You could use a cool Framework like Zend or maybe Template System like smarty, but it doesn´t make the code more readable for somebody who doesn´t know these things, and even if it´s just a small feature which you add it´s more overhead than usage.
From my impression at the moment the ability to code inside old projects will be highly requested the next common years. There is already a lot of undocumented legacy code written by people who maybe did PHP or even programming at all for first time, with a lot of bad coding behaviors and even wholes in security. So what will be really interesting is not always building the newest and best the future technology but how can i manage to bring also code form the past up to date. Today theres Zend Framework, Symfony or maybe cake up to date but what in about 2,5 or 10 years, they might be as popular as PHPLib is now but there will be some code left.
Thursday, June 5. 2008What's new: PHP 5.3 in detail - get_called_class()While the first PHP5.3 release candidate is right round the corner, we're going to explain you some benefits of the new features and language constructs in our new series "What's New: PHP 5.3 in detail". Every developer, that is a little bit into PHP & design patterns, should stumbled about this issue: How the heck can i implement a singleton method into my abstract class. Caused by internal handling in PHP prior to version 5.3, it wasn't possible to do it without dirty workarounds (e.g. propertys with className)
Continue reading "What's new: PHP 5.3 in detail - get_called_class()" Wednesday, June 4. 2008OpenID Article on Zend Developer Zone
Vikram Vaswani Posted an Interesting Article "Getting Started with OpenID and PHP" on ze Zend Developer Zone
Giving example of an OpenID loggin mechanism using the PHP OpenID Library's file storage class or alternatively the PearAuthentication::OpenID_Consumer PEAR
« previous page
(Page 2 of 2, totaling 27 entries)
|