Jul 22
icon1 admin | icon2 technical | icon4 07 22nd, 2009| icon3 No Comments »

ok i have been playing with zend at home to increase my knowledge, and i have run across this, i think its pretty handy, and gave me much insight in zend’s 1.8 bootstrapping method. i didnt use any of the dojo stuff, mainly because i plan to use jquery for all my dynamic javascripting needs.

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
    /**
     * Bootstrap autoloader for application resources
     *
     * @return Zend_Application_Module_Autoloader
     */

    public static $root = ;
    public static $registry;  
    public static $db;  
   
    public function getRoot(){
        $path = $_SERVER[‘DOCUMENT_ROOT’];
        if (substr($path,strlen($path) -1,strlen($path)) == ‘/’){
            $path = substr($path,0,strlen($path)-1);
        }
        return $path;
    }    
    protected function _initAutoload() {
        $autoloader = new Zend_Application_Module_Autoloader ( array (‘namespace’ => ‘Default’, ‘basePath’ => dirname ( __FILE__ ) ) );
        Zend_Session::setOptions(array(‘remember_me_seconds’ => 7200));
        Zend_Session::start();
        self::$root = $this->getRoot();
        self::setConfig();
        self::setRegistry();
        self::setTimeZone();
        self::setupDatabase();
        return $autoloader;
    }
    //Date time setting will be done here
    public static function setTimeZone()
    {
        date_default_timezone_set(‘Europe/London’);
    }
    //Configuration file reading & setting up configuration will be done using following.
    public static function setConfig(){
       
        $config = new Zend_Config_Ini(
            self::$root . ‘/../application/configs/application.ini’,APPLICATION_ENV);
            self::$registry->configuration = $config;
            self::$db = self::$registry->configuration->resources->toArray();
    }
   
    public static function setRegistry()
    {
        self::$registry = new Zend_Registry(array(), ArrayObject::ARRAY_AS_PROPS);
        Zend_Registry::setInstance(self::$registry);
    }

    /*DB setup done here.
    Read configuration, create db instance & set in registry to use in other part of application.*/
 
    public static function setupDatabase()  
    {  
        $config = self::$db;
        $db = Zend_Db::factory($config["db"]["adapter"], $config["db"]["params"]);  
        $db->query("SET NAMES ‘utf8′");  
        self::$registry->database = $db;  
        Zend_Db_Table::setDefaultAdapter($db);  
    }  
   
    protected function _initView() {
        // Initialize view
        $view = new Zend_View ( );
        //$view->doctype(‘XHTML1_STRICT’); /* Quick Change out depending on project */
        $view->doctype ( ‘XHTML1_TRANSITIONAL’ );    /* Quick Change out depending on project */
       
        $view->env = APPLICATION_ENV;
       
        Zend_Dojo::enableView ( $view );
        Zend_Dojo_View_Helper_Dojo::setUseDeclarative ();
        $view->dojo ()->setLocalPath ( "/js/prod/dojo/dojo.js" )
                ->setDjConfigOption ( ‘usePlainJson’, true )
                ->setDjConfigOption ( ‘parseOnLoad’, true )
                ->addStylesheetModule ( ‘dijit.themes.soria’ )
                ->addStylesheet ( ‘/js/prod/dojox/grid/resources/soriaGrid.css’ )
                ->enable ();
        // Add it to the ViewRenderer
        $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper ( ‘ViewRenderer’ );
        $viewRenderer->setView ( $view );
        // Return it, so that it can be stored by the bootstrap
        return $view;
    }
}

more can be read here i give credit to the guy who wrote this up originally and shared with the rest of the world.

Your Ad Here
Jul 15
icon1 admin | icon2 technical | icon4 07 15th, 2009| icon3 No Comments »

when i used to work at sperka int’l a while back i wrote a block of javascript for one of our clients, discounttirecenters.com

here are my shenanigans.

it was simple old style ajax image fetcher.
shows how much i love the matrix i guess.

function getimage (matrix, neo, zion, anderson) {
       
        var nebuchadnezzar = document.getElementById(matrix)
        var entermatrix = matrix
        if(window.XMLHttpRequest)
        req = new XMLHttpRequest();
                else if (window.ActiveXObject)
                        req  = new ActiveXObject(‘Microsoft.XMLHTTP’);
                req.onreadystatechange = function()
                { if(req.readyState == 4)
                        { if(req.status == 200){
                                        the_redpill = req.responseText;
                                        nebuchadnezzar.style.display = ‘block’;
                                        if (the_redpill == ) {
                                        nebuchadnezzar.innerHTML = ‘<div><a href="product_detail.php?c=’+anderson+‘&prodID=’+neo+‘"><img src="images/images_products/’+ zion+‘/normal/notire.png" width="150" /></a><br />click for more details<br />’;
                                        } else {
                                        nebuchadnezzar.innerHTML = ‘<div><a href="product_detail.php?c=’+anderson+‘&prodID=’+neo+‘"><img src="images/images_products/’+ zion+‘/normal/’+the_redpill+‘" width="150" /></a><br />click for more details<br />’;
                                        }
                               
                                       
                                }else {
                                        document.getElementById(‘errors’).innerHTML="Error: returned status <br />code " + req.status + " " + req.statusText;
                                }
                        }
                };
                req.open("GET", "option_populater.php?imagecheck=" + neo + "&whichDB=" + zion, true);
                req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                req.send(null);
}
Jul 5
icon1 admin | icon2 PLAIN | icon4 07 5th, 2009| icon3 No Comments »

here is where i walked on the 4th of july.

i thought there was going to be fireworks at the santa monica pier. but there were none, so we decided to walk to marina del rey
total miles walked? about 9 miles. very nice walk, and my feet have very beautiful blisters. mmmmm
if we walked home it would have been i guess 15 round trip?

walk

Your Ad Here
Get Adobe Flash playerPlugin by wpburn.com wordpress themes