Pages

Thursday, November 18, 2010

Zend Framework - creating helper view (part2)

views/scripts/helpers/filename.phtml

<?php

$this->js()->enableJQuery();

$this->js()->append($this->urls()->js()."library/tiny_mce/tiny_mce.js");

$this->js()->append($this->urls()->js()."testTeamsiteedit/tinymce.init.js");

$this->js()->append($this->urls()->js()."testTeampopup.js");

/*$this->js()->append($this->urls()->js()."library/jquery/jquery-1.3.2.min.js"); */

$this->js()->append($this->urls()->js()."testTeamsiteedit/testTeamsitepopup.js");

  

$vMediaPath = $this->urls()->manMedia();

$aUserDetails = $this->aUserDetails[0];

//logo display

    if(isset($this->data->testTeam_logo) && $this->data->testTeam_logo!='')

    $vtestTeamimg = $vMediaPath.$this->data->testTeam_logo;

else

    $vtestTeamimg =$this->urls()->images()."change_logo_ig.gif";

?>

<span id="script_tinymce"></span>

<input type="hidden" name="up_testTeam_id" id="up_testTeam_id" value="<?php echo $this->data->testTeam_id; ?>" />

<input type="hidden" name="up_testTeam_url" id="up_testTeam_url" value="<?php echo $this->url(array('page'=>$this->testTeamURL),'global_routing'); ?>" />

<div class="cal_mid_left_acc">

    <div class="base_ball">

    <span><?php echo $this->escape($this->data->testTeam_name) ?></span> <em>(<?php echo $this->escape($this->data->sprt_name) ?>)</em>

    </div>

    <div class="im_man" onmouseover="this.className='im_manOver'" onmouseout="this.className='im_man'" style="border:1px:#0033FF;">

    <?php if($this->testTeam_user_permission==1){?>

         <div class="cngAvatar">

        <a onclick="changetestTeamlogo(<?php echo $this->data->testTeam_id; ?>,'<?php echo $this->url(array('page'=>$this->testTeamURL),'global_routing'); ?>')" href="Javascript:">Change Logo </a>&nbsp;&nbsp;</div>

            <a onclick="changetestTeamlogo(<?php echo $this->data->testTeam_id; ?>,'<?php echo $this->url(array('page'=>$this->testTeamURL),'global_routing'); ?>')"  href="Javascript:"><img id="testTeamImg" width="80" border="0" alt="" src="<?php echo $vtestTeamimg;?>" /></a>

    <?php } else {?>  

        <img id="testTeamImg" width="80" border="0" alt="" src="<?php echo $vtestTeamimg;?>" />

<?php }?>

</div>

<div class="acc_ig_name">

 <!--<p><?php echo $this->escape($this->data->testTeam_name) ?></p>-->

 <p>&nbsp;</p>

</div>

<div class="account_text">

    <?php if($this->testTeam_user_permission==1): ?>

        <b><?php echo $this->translate('Manage testTeam'); ?></b>

    <?php else: ?>

        <b><?php echo $this->translate('testTeam'); ?></b>

    <?php endif; ?>

  <?php if(count($this->testTeam_side_menus) > 0): ?>

      <?php foreach($this->testTeam_side_menus as $this->testTeam_side_menu): ?>

        <?php

            $url    =    "";

            if($this->testTeam_side_menu->rutr_url != ""){

                $router    =    str_replace("{testTeamURL}","",$this->testTeam_side_menu->rutr_url);

                $url    =    $this->url(array('page'=>$this->testTeamURL),'global_routing').$router;

            }else{

                $url    =    $this->url(array('page'=>$this->data->rutr_url,'controller'=>$this->testTeam_side_menu->stvw_controller,'action'=>$this->testTeam_side_menu->stvw_action),'global_routing');

            }

        ?>      

      

        <!--conditions for checking testTeam site edit menu to open a popup menu-->

        <?php           

        if($this->testTeam_side_menu->stvw_menu_title=='testTeam Site (Modify)' && $this->testTeam_user_permission==1){ ?>

        <p style="cursor:pointer"><a onclick="loadtestTeamSite('<?=$url; ?>')"><?=$this->translate($this->testTeam_side_menu->stvw_menu_title); ?></a></p>

        <?php } else if($this->testTeam_side_menu->stvw_menu_title!='testTeam Site (Modify)' ) {?>

        <p><a href="<?=$url; ?>"><?=$this->translate($this->testTeam_side_menu->stvw_menu_title); ?></a></p>

        <?php } ?>

      

          

    <?php endforeach; ?>

  <?php endif; ?>



</div>

</div>

for calling helper files to used page

---------------------------------------------------

---------------------------------------------------

EXAMPLE

<?php echo $this->testTeamsidebar(); ?>

<?php echo $this->helperfunctionname(); ?>

                      

             

Zend Framework-Creating Helper files

views/helpers/filename.php

<?php

/**

 * Zend_View_Helper_testTeamsidebar

 *

 * Helper for displaying product prices (human readable)

 *

 * @category   Storefront

 * @package    Storefront_View_Helper

 */

class Zend_View_Helper_testTeamsidebar extends Zend_View_Helper_Abstract {  

    const TEAM_MENU_TYPE    =       3;

    /**

     * A function to get team left menus text to another line

     *

     * Type:    function<br>

     * Name:    testTeamSideBar<br>

     * Author:    Rathinasamy<br>

     * Created:    Sep 01,2011<br>

     * @param void

     * @exception none

     * @return void.

     */

    public function testTeamsidebar(){

        //--    fetch related informations from

        //--    database and show them

        $request    =    Zend_Controller_Front::getInstance()->getRequest();

        $testTeamID        =    $request->getParam('test_testTeam_id');

        $userACL    =    $request->getParam('test_testTeam_user_acl');

        $userPRMSN  =   $request->getParam('test_testTeam_user_permission');  

        $testTeamUserRole    =    $userACL['role'];

      

        $this->view->assign('testTeam_user_permission',$userPRMSN);

        if($testTeamID>0)

        {  

            //---    get testTeam information using the testTeam id

            $otestTeam        =    new testTeam();

            $record        =    $otestTeam->getCompletetestTeamByID($testTeamID);

            $this->view->assign('data',$record);

          

            //--    get testTeam sidebar menu informations

            if($testTeamUserRole > 0){

                $oMenu        =    new Menu();

                $aMenus        =    $oMenu->getMenus($testTeamUserRole,self::TEAM_MENU_TYPE);

                $this->view->assign('testTeam_side_menus',$aMenus);

            }

        }

        return $this->view->render('helpers/testTeamsidebar.phtml');  

    }

}

Sunday, November 14, 2010

zend framework index creation

<?php

/** Test Program

 * Defining ROOT_DIR The root directory of the

 * application

 * @var string

 */

define('ROOT_DIR', realpath(dirname(__FILE__)));

/** Test Program

 * Definig the path seperator

 * @var string

 */

define('DS','/');

// Define path to application directory

defined('APPLICATION_PATH') or define('APPLICATION_PATH', ROOT_DIR . DS. 'application');

// Define path to librarry directory

defined('LIBRARY_PATH') or define('LIBRARY_PATH', ROOT_DIR . DS. 'library');

// Define application environment

defined('APPLICATION_ENV')

    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'local'));

// Ensure library/ is on include_path

//--    setup for the include paths

$paths = array(

    get_include_path(),

    ROOT_DIR .DS. 'library',

    APPLICATION_PATH .DS. 'modules'.DS.'storefront'.DS.'models',

);

set_include_path(implode(PATH_SEPARATOR, $paths));

//require 'error.php';

/** Zend_Application */

require_once 'Zend/Application.php';

// Create application, bootstrap, and run

$application = new Zend_Application(

    APPLICATION_ENV,

    APPLICATION_PATH . '/configs/application.ini'

);

$application->bootstrap()->run();

Friday, November 12, 2010

zend framework layout include file

topmenu.phtml
---------------------------
<?php
$isLoggedIn = Zend_Auth::getInstance()->hasIdentity();
$this->js()->addOnLoad("jQuery('.calendar_mid_text3').bind('mouseover', jsddm_open)");
$this->js()->addOnLoad("jQuery('.calendar_mid_text3').bind('mouseout', jsddm_timer)");

$this->js()->addOnLoad("jQuery('.calendar_mid_text4').bind('mouseover', jsddm_open)");
$this->js()->addOnLoad("jQuery('.calendar_mid_text4').bind('mouseout', jsddm_timer)");

$this->js()->append($this->urls()->js()."menu/menu.js");
$this->js()->append($this->urls()->js()."menu/teamMenuInit.js");


    //For Team Tab Display
    //For Team Page Display created on 28,Oct 2010
    $oTeamsiteedit = new Teamsiteedit();
    $oTeam = new Team();
    $curUrl=Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();
   
    $curUrl=explode("/",$curUrl);
    $teamURL=$curUrl[count($curUrl)-2];   
    //Team details
    $vTeamDet=$oTeam->getByUrl($teamURL,$id=0);
    //Team Grid Menu Details   
    if(count($vTeamDet)>0)
    {
        $aParam['teamid']=$vTeamDet->team_id;   
        $vTeamTabDet=$oTeamsiteedit->getTabDet($aParam);
    }
   
     //for calling carosel scripts
     if(count($vTeamTabDet)>1)
     $this->js()->append($this->urls()->js()."menu/teamMenuInit.js");
   
//--    select user teams
if($isLoggedIn){
    $user = Zend_Auth::getInstance()->getStorage()->read();
    $oTeam    =    new Team();
    $aTeams    =    $oTeam->getUserTeams($user->user_id);

    $vMenuTeamselimg    =    "menu_bottom_arrow.gif";
    $vSelController = Zend_Controller_Front::getInstance()->getRequest()->getControllerName();
    if($vSelController == 'mygrid')
        $vMenuGridsel    =    'menuSel';
    else if($vSelController == 'calendar')
        $vMenuCalsel    =    'menuSel';
    else if($vSelController == 'gallery')
    {
        $vMenuGallerysel    =    'menuSel';
        $vMenuTeamselimg    =    'menusel_bottom_arrow.gif';   
        $vArrowClass        =    'lPadding';
    }
    else
    {
        $vMenuTeamsel        =    'menuSel';   
        $vMenuTeamselimg    =    'menusel_bottom_arrow.gif';   
        $vArrowClass        =    'lPadding';
    }   
 
    ?> 
     
             

<div class="calendar">
  <div class="calendar_ll">
    <div class="calendar_left"><img src="<? echo $this->urls()->images(); ?>calender_left.gif"  alt=""/></div>
    <div class="calendar_mid">
      <?php if($isLoggedIn): ?>
      <div id="styleGrid" class="calendar_mid_text1 <? echo $vMenuGridsel?>"> <b><a href="<?php echo $this->url(array('controller'=>'mygrid','action'=>'index')) ?>">Grid</a></b> <span><img src="<? echo $this->urls()->images(); ?>menu_pix.gif" alt=""/></span> </div>
      <div id="styleCalen" class="calendar_mid_text2 <? echo $vMenuCalsel?>"> <b><a href="<?php echo $this->url(array('controller'=>'calendar','action'=>'index')) ?>">Calendar</a></b> <span><img src="<? echo $this->urls()->images(); ?>menu_pix.gif" alt=""/></span> </div>
      <div id="styleMyteam" class="calendar_mid_text3 <? echo $vMenuTeamsel?>">
          <b class="<? echo $vArrowClass ?>"><a href="#">My Teams</a></b><em><a href="#"><img src="<? echo $this->urls()->images(); ?><? echo $vMenuTeamselimg; ?>" alt="" border="0"/></a></em> <span><img src="<? echo $this->urls()->images(); ?>menu_pix.gif" alt=""/></span>
        <div id="menu_teams" class="team_store">
          <div class="team_store_left">
          <?php if(count($aTeams) > 0): ?>
              <?php foreach($aTeams as $aTeam): ?>
                <p><a href="<?php echo $this->url(array('page'=>$aTeam->rutr_url),'global_routing'); ?>/summary"><?php echo $this->escape($aTeam->team_name) ?></a></p>   
            <?php endforeach; ?>
          <?php endif; ?>
          </div>
        </div>
      </div>
      <div id="styleGal" class="calendar_mid_text4 <?=$vMenuGallerysel?>">
          <b class="<? echo $vArrowClass ?>"><a href="#">Gallery</a></b> <em><a href="#"><img src="<? echo $this->urls()->images(); ?><? echo $vMenuTeamselimg; ?>" alt="" border="0"/></a></em> <span><img src="<? echo $this->urls()->images(); ?>menu_pix.gif" alt=""/></span>
           <div id="gallery_teams" class="gallery_store">
            <div class="gallery_store_left">
                <p><a href="<?php echo $this->url(array('page'=>'gallery/index/type/1'),'global_routing'); ?>">Upload Photos</a></p>
                <p><a href="<?php echo $this->url(array('page'=>'gallery/index/type/2'),'global_routing') ?>">Upload Videos</a></p>
            </div>
         </div>
      </div>
      <div id="styleProd" class="calendar_mid_text5"> <b><a href="#">Products</a></b> <span><img src="<? echo $this->urls()->images(); ?>menu_pix.gif" alt=""/></span> </div>
     

      <!--<div class="calendar_mid_text6"> <b><a href="#">My Channels</a></b> <em><a href="#"><img src="<? echo $this->urls()->images(); ?>menu_bottom_arrow.gif" alt="" border="0"/></a></em> <span><img src="<? echo $this->urls()->images(); ?>menu_pix.gif" alt=""/></span> </div>-->
      <!--<div class="calendar_mid_text7"> <b><a href="#">>></a></b> </div>-->
      </div>
   <!-- <div class="calendar_right"><img src="<? echo $this->urls()->images(); ?>calender_right.gif" alt="" /></div>
    <div class="add"> <span><a href="#"><img src="<? echo $this->urls()->images(); ?>add_icon.gif"  alt="" border="0"/></a></span> </div>-->
      <?php else: ?>
      <!--<div class="calendar_mid_text1"> <b><a href="<?php echo $this->url(array('controller'=>'products','action'=>'index')) ?>">Products</a></b> <span><img src="<? echo $this->urls()->images(); ?>menu_pix.gif" alt=""/></span> </div>
      <div class="calendar_mid_text2"> <b><a href="<?php echo $this->url(array('controller'=>'aboutus','action'=>'index')) ?>">About Us</a></b> <span><img src="<? echo $this->urls()->images(); ?>menu_pix.gif" alt=""/></span> </div>
      <div class="calendar_mid_text3"> <b><a href="<?php echo $this->url(array('controller'=>'contactus','action'=>'index')) ?>">Contact Us</a></b> <span><img src="<? echo $this->urls()->images(); ?>menu_pix.gif" alt=""/></span> </div>
      <div class="calendar_mid_text4"> <b><a href="<?php echo $this->url(array('controller'=>'tryouts','action'=>'index')) ?>">Tryouts</a></b> <span><img src="<? echo $this->urls()->images(); ?>menu_pix.gif" alt=""/></span> </div>
        </div>-->
      <?php endif; ?>
  </div>
 
 
  <div class="calendar_rr">
      <form name="frmSearch" id="" method="post">   
    <input name="txtSearch" id="txtSearch" type="text" value="Team search" onkeypress="traceKeySearchTeam(event.keyCode)" />
    <span><a href="javascript:" onclick="searchText()"><img src="<? echo $this->urls()->images(); ?>search_log_icon.gif" alt="" border="0" /></a></span>
    </form>
    </div>
</div>
<?
}
else
{
?>
<div class="calendar">
  <div class="calendar_ll">
    <div class="calendar_left"><img src="<? echo $this->urls()->images(); ?>calender_left.gif"  alt=""/></div>
    <div class="calendar_mid">
        <!--Team tab display--> 
   
      <?php
      if(count($vTeamTabDet)>=1)
      {
       for($tabLoop=0;$tabLoop<count($vTeamTabDet);$tabLoop++)
          {
          ?>
         
          <div id="styleGrid" class="calendar_mid_text1"> <b><a href="javascript:;" onclick="viewTeamPage('<?=$vTeamTabDet[$tabLoop]['cmsc_id']?>','<?=$teamURL?>')"><?=$vTeamTabDet[$tabLoop]['cmsc_name']?></a></b> <span><img src="<? echo $this->urls()->images(); ?>menu_pix.gif" alt=""/></span> </div>
           
          <?php
          }       
       }
      ?>     
  </div>
  </div>
 
  <div class="calendar_rr">
      <form name="frmSearch" id="" method="post">
    <input type="hidden" name="hidTabId" id="hidTabId" value="" />
    <input name="txtSearch" id="txtSearch" type="text" value="Team search" onkeypress="traceKeySearchTeam(event.keyCode)" />
    <span><a href="javascript:" onclick="searchText()"><img src="<? echo $this->urls()->images(); ?>search_log_icon.gif" alt="" border="0" /></a></span>
    </form>
    </div>
</div>
<?php
}
?>
<script>
    function traceKeySearchTeam( key ){
                    if ( key == 13 ){
                        searchText();
                    }
                }
               
function searchText()
{
    if(document.frmSearch.txtSearch.value == "")
    {
        alert("Please enter any team name to search")       
        return false
    }
    else
    {
        document.frmSearch.action = g_site_path+'/search';
        document.frmSearch.submit();       
    }
}
</script>

Tuesday, November 9, 2010

Zend Framework Session handling

Starting a Session

If you want all requests to have a session facilitated by Zend_Session, then start the session in the bootstrap file:
Example #1 Starting the Global Session
  1. Zend_Session::start();
By starting the session in the bootstrap file, you avoid the possibility that your session might be started after headers have been sent to the browser, which results in an exception, and possibly a broken page for website viewers. Various advanced features require Zend_Session::start() first

Example #5 Accessing Session Data
  1. $namespace = new Zend_Session_Namespace(); // default namespace
  2.  
  3. $namespace->foo = 100;
  4.  
  5. echo "\$namespace->foo = $namespace->foo\n";
  6.  
  7. if (!isset($namespace->bar)) {
  8.     echo "\$namespace->bar not set\n";
  9. }
  10.  
  11. unset($namespace->foo);

Zend Framework- sample Layout

<?php echo $this->doctype(); ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <?php $this->css()->append($this->urls()->css()."/player.css"); ?>
    <?php $this->css()->append($this->urls()->css()."/mygrid.css"); ?>
    <?php $this->css()->append($this->urls()->css()."/gallery.css"); ?>
    <?php if(isset($this->user) && $this->user->theme_name != "")
            $this->css()->append($this->urls()->css().'/themes/player_'.$this->user->theme_name.'.css','screen',true,array('id' => 'layout_css'));   
    ?>
    <?php $this->headScript()->prependScript('var ZAAHDATEFORMAT = "'."yy-mm-dd".'";') ?>
    <?php $this->headScript()->prependScript('var g_site_path = "'.$this->baseUrl().'";') ?>
    <?php $this->headScript()->prependScript('var g_imge_path = "'.$this->urls()->images().'";') ?>
    <?php $this->headScript()->prependScript('var g_skin_path = "'.$this->urls()->skin().'";') ?>
    <?php $header =  $this->render('includes/header.phtml'); ?>
    <?php $widgets    =    $this->widget(); ?>
    <?php $topmenu    =    $this->topmenu(); ?>
    <?php $this->js()->addLibrary(); ?>
    <?php echo $this->headMeta();?>
    <?php echo $this->headTitle();?>
    <?php echo $this->headStyle();?>
    <?php echo $this->headLink();?>

</head>
<body id="playerbody">
    <div class="cornerBG">
        <div class="header">
          <div class="header_main">
            <?php
                    /*** To display Header links and header ***/
                    echo $header;
       
                    /*** To display Main menu bar ***/
                    echo $topmenu;
       
                    /*** To display body content ***/
                    echo $this->render('includes/body_content.phtml');
       
                    /*** To display bottom widgets  ***/
                    echo $widgets;
                           
                    /*** To display footer with bottom links  ***/
                    echo $this->render('includes/footer.phtml');
                ?>
          </div>
        </div>
    </div>
    <?php $this->js()->onload(); ?>
    <?php echo $this->headScript();?>
</body>
</html>

Wednesday, November 3, 2010

zend framework Post form using ajax

 //script
---------------------------------
$.ajax({
            type : "POST",
            url: g_site_path+'/teamregister/teamupdateform',
            data : $('#frmTeamstepone').serialize(),
            dataType: "json",
            success: function(data) {   
           
                 $('#hidPlyrAvalFlag').val(data.plyrAvalFlag)
                $('#hidplyrUsrid').val(data.plyrUsrid)
                if(data.teamUrl!="")
                {
                    var redirectUrl=g_site_path+"/"+data.teamUrl+"/summary";
                    setTimeout("window.location.href="+"'"+redirectUrl+"'",1000);   
                }
                else
                {
                    document.frmTeamstepone.action = g_site_path+"/teamregister/teamsteptwo";
                    document.frmTeamstepone.submit()
                }
            }
    });


//controller action code
----------------------------------------
    $vRegPostVar     = $this->_request->getPost();
   
        $oTeam  = new Team();   
        $res    =    $oTeam->insertTeamregdetails($vRegPostVar,$this->view->userid);

//model code
---------------------------------------
public function insertTeamregdetails($params,$userid)
    {
    $usr_values = array(
                        'user_fname'           => $params['plfname'],
                        'user_lname'         => $params['pllname'],
                        'user_dob'              => $dob,
                        'user_address'         => $params['pladdr'],
                        'user_city'         => $params['plcity'],
                    );
               
                    $usrupdateID    =    $oUser->update($usr_values,array('user_id = ?'=>$userid));


}