Web Standards
  Home arrow Web Standards arrow Page 4 - Completing a Configuration for Chrome and ...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WEB STANDARDS

Completing a Configuration for Chrome and a Server
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-06-26

    Table of Contents:
  • Completing a Configuration for Chrome and a Server
  • PHP Serving XUL
  • Using PHP require()
  • Logic changes
  • Summary

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Completing a Configuration for Chrome and a Server - Logic changes


    (Page 4 of 5 )

    Next, we change our doCommandXUL.php frontend script to execute the logic that decides what interface to serve. The only change from the last iteration of the code is to alter the path that actually checks the result if the user entered data into the name and password fields.

    The code takes advantage of the PHPexplodefunction to break up the returned string into an array of name-value pairs.

    We use the PHPsubst(inString,startingChar,lastChar)functions to break the result array’s strings into values, given the fact that we know the length of the names being used as tags. If the first returned value istrue, we save a string that holds session information into a variable, and include the PHP file that holds the XUL interface content. If the first returned value isfalse, we build a message that flags an unregistered user:

      else {
       
    $retString = check_user($uName,$uPass);
       $resArray = explode(',',$retString);
       if ($resArray[0] == 'retcode=true') {
          $lastLoginTime = 'Last login was '.substr($resArray[1],
            
    11,strlen($resArray[1]));  // extract last session
          require('startupScreen.php');
          } 
         
    else { // invalid user, send rejection page
         echo '<h1>Sorry!</h1>';
         echo '<h2>You are not registered to use this service.</h2>';
         } // invalid user 
      
    }

      ?>

    We need to insert another subtle change into the newssearch.js file. Because the login button is no longer on our startup screen (the doCommandXUL.php file is generating it), we can no longer try to attach a login script upon initialization. We could edit the code to remove all initialization references, or (if we wanted to use the same file for both local and served versions) we could add a test to make certain the button exists before attaching an event listener:

      function initialize(){
      try {
       document.getElementById("B1").
         addEventListener("command",genericBtnHandler,true);
       document.getElementById("B2").
         addEventListener("command",genericBtnHandler,true);
       document.getElementById("B3").
         addEventListener("command",genericBtnHandler,true);
      //
      // Add a login script 
        if (document.getElementById("loginButton")) { 
          document.getElementById("loginButton").
              addEventListener("command",doLogin,true); 
           
    } 

        }
        
    catch (e) {
         alert ("Exception: " + e);
         } 
      }

    Finally, we change the segment of the XUL source in our startupScreen.php file that manages the status label to include the PHP directives to substitute the$lastLoginTimevariable into thelabelattribute of the status display:

      <hbox >
         <!-- stack info and resize horizontally -->
         <!-- right align our status bar -->

           <statusbar id="status-bar" class="chromeclass-status">
           <statusbarpanel id="status-text"
          <?php
           echo('label=\''."$lastLoginTime".'\'/>');
           ?> 
         </statusbar>
        <spacer flex="1"/>
      </hbox>

    Now referencing the doCommandXUL.php file from the Firefox URL will present the same interaction with the user, except with the interface delivered from the web server. Figure 4-11 shows our XUL-served page for a successful login and a failed login.

    More Web Standards Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Programming Firefox," published by...
     

    Buy this book now. This article is excerpted from chapter four of Programming Firefox, written by Kenneth C. Feldt (O'Reilly, 2007; ISBN: 0596102437). Check it out today at your favorite bookstore. Buy this book now.

    WEB STANDARDS ARTICLES

    - Completing a Configuration for Chrome and a ...
    - Getting Connected with Firefox and Chrome
    - Configuring Servers and Databases with Chrome
    - Configuring Firefox for Chrome and a Server
    - Designing the Elements of a Web Page
    - Matching div heights with CSS and JavaScript
    - Forms
    - Get Down With Markup
    - If I Said You Had a Beautiful Body...
    - Web Standards in Dreamweaver Part 3
    - Web Standards in Dreamweaver, Part 2
    - Web Forms
    - Making Lists Using XHTML
    - Web Standards in Dreamweaver, Part 1







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek