$validators = array('rosterCount'=>array('Digits','messages'=>'Allow numberic only'));
$filters = array('*'=> 'StringTrim','*' => 'StripTags');
$input = new Zend_Filter_Input($filters,$validators,$request->getPost());
$vRosterCount = $input->getEscaped('rosterCount');
Thursday, October 28, 2010
Jquery carousel-Riding carousels with jQuery
Ref:http://sorgalla.com/projects/jcarousel/#Configuration
<script type="text/javascript" src="/path/to/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="/path/to/lib/jquery.jcarousel.min.js"></script> <link rel="stylesheet" type="text/css" href="/path/to/skin/skin.css" /> //script part // for carosel jQuery(document).ready(function() { var id=10; var listOfEle = jQuery(".carousel_list_customize_"+id+" ul li"); if(listOfEle.length >= 2 ){ $(".carousel_list_customize_"+id).jCarouselLite({ btnNext: "#photo_nav_next_"+id, btnPrev: "#photo_nav_prev_"+id, scroll: 2, visible: 2 }); } }); //Html
------------------ <div style="width:200px; height:10px; float:left"> <div align="left" style="float:left" class="linkPrevious"><a id="photo_nav_prev_10"> <<</a></div> <div align="left" class="carousel_list_customize_10" style="width:300px; float:left"> <ul id="mycarousel" style="float:left"> <?php for($vLoop=0;$vLoop<30;$vLoop++){ ?> <li> <a href="#">testing<?=$vLoop?></a> </li> <?php } ?> </ul> </div> <div align="left" class="linkNext"> <a id="photo_nav_next_10">>></a> </div> </div>
Wednesday, October 27, 2010
Zend framework application/Bootstrap
<?php
/**
* Application bootstrap or initialization calss
*
*/
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
/**
* Used to hold the logger object
* @var Zend_Log
*/
protected $_logger;
/**
* Setup the logging
*/
protected function _initLogging()
{
$system = $this->getOption("system");
$enableReport = isset($system['log']['report']['enable']) ? $system['log']['report']['enable'] : false;
Zend_Registry::set('enableReport',$enableReport);
$enableLog = isset($system['log']['debug']['enable']) ? $system['log']['debug']['enable'] : false;
if($enableLog == false)
return;
//-- continue if logging is enabled
$logPath = (isset($system['paths']['log']) && $system['paths']['log'] != "") ? $system['paths']['log'] : ROOT_DIR.DS."var".DS."log".DS."debug";
$logFile = $logPath.DS.date("dmY").".txt";
$enableFB = isset($system['log']['debug']['firebug']) ? $system['log']['debug']['firebug'] : false;
$critOnly = isset($system['log']['debug']['critonly']) ? $system['log']['debug']['critonly'] : false;
$logger = new Zend_Log();
$writer = ($enableFB) ? new Zend_Log_Writer_Firebug() : new Zend_Log_Writer_Stream($logFile);
$logger->addWriter($writer);
if ($critOnly){
$filter = new Zend_Log_Filter_Priority(Zend_Log::CRIT);
$logger->addFilter($filter);
}
$this->_logger = $logger;
$this->_logger->info('Bootstrap ' . __METHOD__);
Zend_Registry::set('log', $logger);
}
/**
* Set the config values to the registry
*/
protected function _initConfig(){
$this->_logger->info('Bootstrap ' . __METHOD__);
Zend_Registry::set('config', $this->getOptions());
}
/**
* Inits the autoloader
*
* Created: Sep 10, 2012
*/
protected function _initAutoloader(){
$this->bootstrap("frontController");
$front = $this->frontController;
$autoloader = Zend_Loader_Autoloader::getInstance();
$modules = $front->getControllerDirectory();
$default = $front->getDefaultModule();
$autoloader->setFallbackAutoloader(true);
foreach (array_keys($modules) as $module) {
$autoloader->pushAutoloader(new Zend_Application_Module_Autoloader(array(
"namespace" => ucwords($module),
"basePath" => $front->getModuleDirectory($module),
)));
}
return $autoloader;
}
/**
* Ints the locale and translator
*
* Created: Sep 10, 2012
* @return Zend_Locale
*/
protected function _initLocale(){
$session = new Zend_Session_Namespace('zaah_language');
$config = $this->getOptions();
/**
* Cache options
*/
if(isset($config['system']['cache']['translate']) && $config['system']['cache']['translate'] == true){
$frontendOptions = array('cache_id_prefix' => 'Translate_', 'lifetime' =>86400, 'automatic_serialization'=>true);
$backendOptions = array('cache_dir' => ROOT_DIR . '/var/cache/translate');
$cache = Zend_Cache::factory('Core', 'File', $frontendOptions,$backendOptions);
Zend_Translate::setCache($cache);
}
//-- determines which locale need to load
if (isset($session->language)) {
$requestedLanguage = $session->language; //user set locale manually
} else {
$requestedLanguage = "en_US"; //user set no session so default to browser
}
$locale = new Zend_Locale($requestedLanguage);
Zend_Registry::set('Zend_Locale', $locale);
$translate = new Zend_Translate('csv', APPLICATION_PATH."/locale", NULL, array('scan' => Zend_Translate::LOCALE_DIRECTORY,'locale'=>'en_US'));
//Check we have a language file for it
if (in_array($requestedLanguage, $translate->getList())) {
$language = $requestedLanguage; //if requested language is in our list, use it
} else {
$language = 'en_US';
}
$translate->setLocale($language);
Zend_Registry::set('locale',$locale);
Zend_Registry::set('localeName',$locale->getLanguage()."_".$locale->getRegion());
Zend_Registry::set('Zend_Translate', $translate);
return $locale;
}
/**
* Inits the database configurations
*
* Created: Sep 13, 2012
*/
protected function _initDatabaseSetting(){
$config = $this->getOptions();
/**
* Cache options
*/
if(isset($config['system']['cache']['db_meta']) && $config['system']['cache']['db_meta'] == true){
$frontendOptions = array('cache_id_prefix' => 'DbMeta_', 'lifetime' =>86400, 'automatic_serialization'=>true);
$backendOptions = array('cache_dir' => ROOT_DIR . '/var/cache/db');
$cache = Zend_Cache::factory('Core', 'File', $frontendOptions,$backendOptions);
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
}
}
/**
* Inits the mem cache objects
*
* Created: Sep 13, 2012
*/
protected function _initCache(){
$config = $this->getOptions();
if (isset($config['cache'])) {
$cache = Zend_Cache::factory(
$config['cache']['frontend']['type'],
$config['cache']['backend']['type'],
$config['cache']['frontend']['options'],
$config['cache']['backend']['options']
);
Zend_Registry::set('cache', $cache);
}
}
/**
* Inits the front controller
*
* Created: Sep 10, 2012
* @return Zend_Controller_Front
*/
protected function _initFrontTController() {
$frontController = Zend_Controller_Front::getInstance();
if($frontController->getParam('bootstrap') === null) {
$frontController->setParam('bootstrap', $this);
}
return $frontController;
}
/**
* Inits the custom router informations
*
* Created: Sep 16, 2012
* @return void
*/
protected function _initRoutes(){
//-- get the instance of the front controller
$front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();
$router->addRoute(
'global_routing',
new TeamRouter('page',
array(
'module' => 'storefront',
'controller' => 'index',
'action' => 'index',
'page'=>null
)
)
);
}
/**
* Function to assign the user object to the view
*
* Created: Jul 30, 2012
*/
protected function _initUser(){
$this->bootstrap('view');
$view = $this->getResource('view');
$isLoggedIn = Zend_Auth::getInstance()->hasIdentity();
if($isLoggedIn){
//-- fetch the stuff details
$view->user = Zend_Auth::getInstance()->getStorage()->read();
}
}
/**
* Runs the application
*
* Created: Jul 30, 2012
*/
public function run(){
$this->_logger->info('Bootstrap ' . __METHOD__);
/*
try{
$this->frontController->throwExceptions(true);
$response = $this->frontController->dispatch();
}catch(Exception $e){
$this->frontController->throwExceptions(false);
$router = $this->frontController->getRouter();
//--
$router->addRoute(
'global_routing',
new TeamRouter('page',
array(
'module' => 'storefront',
'controller' => 'index',
'action' => 'index',
'page'=>null
)
)
);
$this->frontController->setRouter($router);
$response = $this->frontController->dispatch();
}
$this->sendResponse($response);
*/
$response = $this->frontController->dispatch();
$this->sendResponse($response);
}
/**
* Sends response to the browser
* Created: Jul 30, 2012
* @param Zend_Controller_Response_Http $response
*/
public function sendResponse(Zend_Controller_Response_Http $response){
$this->_logger->info('Bootstrap ' . __METHOD__);
$system = $this->getOption("system");
$compress_option_config = isset($system['phpSpeedy']) ? $system['phpSpeedy'] : array();
if(isset($compress_option_config['active']) && $compress_option_config['active'] == 1){
include_once ROOT_DIR.DS."library".DS."PhpSpeedy".DS."php_speedy.php";
$response->sendResponse();
$compressor->finish();
}else{
$response->sendResponse();
}
}
}
/**
* Application bootstrap or initialization calss
*
*/
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
/**
* Used to hold the logger object
* @var Zend_Log
*/
protected $_logger;
/**
* Setup the logging
*/
protected function _initLogging()
{
$system = $this->getOption("system");
$enableReport = isset($system['log']['report']['enable']) ? $system['log']['report']['enable'] : false;
Zend_Registry::set('enableReport',$enableReport);
$enableLog = isset($system['log']['debug']['enable']) ? $system['log']['debug']['enable'] : false;
if($enableLog == false)
return;
//-- continue if logging is enabled
$logPath = (isset($system['paths']['log']) && $system['paths']['log'] != "") ? $system['paths']['log'] : ROOT_DIR.DS."var".DS."log".DS."debug";
$logFile = $logPath.DS.date("dmY").".txt";
$enableFB = isset($system['log']['debug']['firebug']) ? $system['log']['debug']['firebug'] : false;
$critOnly = isset($system['log']['debug']['critonly']) ? $system['log']['debug']['critonly'] : false;
$logger = new Zend_Log();
$writer = ($enableFB) ? new Zend_Log_Writer_Firebug() : new Zend_Log_Writer_Stream($logFile);
$logger->addWriter($writer);
if ($critOnly){
$filter = new Zend_Log_Filter_Priority(Zend_Log::CRIT);
$logger->addFilter($filter);
}
$this->_logger = $logger;
$this->_logger->info('Bootstrap ' . __METHOD__);
Zend_Registry::set('log', $logger);
}
/**
* Set the config values to the registry
*/
protected function _initConfig(){
$this->_logger->info('Bootstrap ' . __METHOD__);
Zend_Registry::set('config', $this->getOptions());
}
/**
* Inits the autoloader
*
* Created: Sep 10, 2012
*/
protected function _initAutoloader(){
$this->bootstrap("frontController");
$front = $this->frontController;
$autoloader = Zend_Loader_Autoloader::getInstance();
$modules = $front->getControllerDirectory();
$default = $front->getDefaultModule();
$autoloader->setFallbackAutoloader(true);
foreach (array_keys($modules) as $module) {
$autoloader->pushAutoloader(new Zend_Application_Module_Autoloader(array(
"namespace" => ucwords($module),
"basePath" => $front->getModuleDirectory($module),
)));
}
return $autoloader;
}
/**
* Ints the locale and translator
*
* Created: Sep 10, 2012
* @return Zend_Locale
*/
protected function _initLocale(){
$session = new Zend_Session_Namespace('zaah_language');
$config = $this->getOptions();
/**
* Cache options
*/
if(isset($config['system']['cache']['translate']) && $config['system']['cache']['translate'] == true){
$frontendOptions = array('cache_id_prefix' => 'Translate_', 'lifetime' =>86400, 'automatic_serialization'=>true);
$backendOptions = array('cache_dir' => ROOT_DIR . '/var/cache/translate');
$cache = Zend_Cache::factory('Core', 'File', $frontendOptions,$backendOptions);
Zend_Translate::setCache($cache);
}
//-- determines which locale need to load
if (isset($session->language)) {
$requestedLanguage = $session->language; //user set locale manually
} else {
$requestedLanguage = "en_US"; //user set no session so default to browser
}
$locale = new Zend_Locale($requestedLanguage);
Zend_Registry::set('Zend_Locale', $locale);
$translate = new Zend_Translate('csv', APPLICATION_PATH."/locale", NULL, array('scan' => Zend_Translate::LOCALE_DIRECTORY,'locale'=>'en_US'));
//Check we have a language file for it
if (in_array($requestedLanguage, $translate->getList())) {
$language = $requestedLanguage; //if requested language is in our list, use it
} else {
$language = 'en_US';
}
$translate->setLocale($language);
Zend_Registry::set('locale',$locale);
Zend_Registry::set('localeName',$locale->getLanguage()."_".$locale->getRegion());
Zend_Registry::set('Zend_Translate', $translate);
return $locale;
}
/**
* Inits the database configurations
*
* Created: Sep 13, 2012
*/
protected function _initDatabaseSetting(){
$config = $this->getOptions();
/**
* Cache options
*/
if(isset($config['system']['cache']['db_meta']) && $config['system']['cache']['db_meta'] == true){
$frontendOptions = array('cache_id_prefix' => 'DbMeta_', 'lifetime' =>86400, 'automatic_serialization'=>true);
$backendOptions = array('cache_dir' => ROOT_DIR . '/var/cache/db');
$cache = Zend_Cache::factory('Core', 'File', $frontendOptions,$backendOptions);
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
}
}
/**
* Inits the mem cache objects
*
* Created: Sep 13, 2012
*/
protected function _initCache(){
$config = $this->getOptions();
if (isset($config['cache'])) {
$cache = Zend_Cache::factory(
$config['cache']['frontend']['type'],
$config['cache']['backend']['type'],
$config['cache']['frontend']['options'],
$config['cache']['backend']['options']
);
Zend_Registry::set('cache', $cache);
}
}
/**
* Inits the front controller
*
* Created: Sep 10, 2012
* @return Zend_Controller_Front
*/
protected function _initFrontTController() {
$frontController = Zend_Controller_Front::getInstance();
if($frontController->getParam('bootstrap') === null) {
$frontController->setParam('bootstrap', $this);
}
return $frontController;
}
/**
* Inits the custom router informations
*
* Created: Sep 16, 2012
* @return void
*/
protected function _initRoutes(){
//-- get the instance of the front controller
$front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();
$router->addRoute(
'global_routing',
new TeamRouter('page',
array(
'module' => 'storefront',
'controller' => 'index',
'action' => 'index',
'page'=>null
)
)
);
}
/**
* Function to assign the user object to the view
*
* Created: Jul 30, 2012
*/
protected function _initUser(){
$this->bootstrap('view');
$view = $this->getResource('view');
$isLoggedIn = Zend_Auth::getInstance()->hasIdentity();
if($isLoggedIn){
//-- fetch the stuff details
$view->user = Zend_Auth::getInstance()->getStorage()->read();
}
}
/**
* Runs the application
*
* Created: Jul 30, 2012
*/
public function run(){
$this->_logger->info('Bootstrap ' . __METHOD__);
/*
try{
$this->frontController->throwExceptions(true);
$response = $this->frontController->dispatch();
}catch(Exception $e){
$this->frontController->throwExceptions(false);
$router = $this->frontController->getRouter();
//--
$router->addRoute(
'global_routing',
new TeamRouter('page',
array(
'module' => 'storefront',
'controller' => 'index',
'action' => 'index',
'page'=>null
)
)
);
$this->frontController->setRouter($router);
$response = $this->frontController->dispatch();
}
$this->sendResponse($response);
*/
$response = $this->frontController->dispatch();
$this->sendResponse($response);
}
/**
* Sends response to the browser
* Created: Jul 30, 2012
* @param Zend_Controller_Response_Http $response
*/
public function sendResponse(Zend_Controller_Response_Http $response){
$this->_logger->info('Bootstrap ' . __METHOD__);
$system = $this->getOption("system");
$compress_option_config = isset($system['phpSpeedy']) ? $system['phpSpeedy'] : array();
if(isset($compress_option_config['active']) && $compress_option_config['active'] == 1){
include_once ROOT_DIR.DS."library".DS."PhpSpeedy".DS."php_speedy.php";
$response->sendResponse();
$compressor->finish();
}else{
$response->sendResponse();
}
}
}
Zend framework application.ini file settings
[local]
;set timezone
phpsettings.date.timezone = "America/Chicago"
;include path
includePaths.library = ROOT_DIR "/library"
;bootstrap
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
;autoloadernamespaces
autoloadernamespaces.0 = "Tutorial_"
autoloadernamespaces.1 = "Zend_"
;resources.frontController
resources.frontController.plugins.moduleswitcher = "Tutorial_Controller_Plugin_ModuleSwitcher"
resources.frontController.plugins.hasaccess = "Tutorial_Controller_Plugin_HasAccess"
;resources.view
resources.view.helperPath.Tutorial_View_Helper = ROOT_DIR "/library/Tutorial/View/Helper"
; configuration defined by application developer
; required paths informations
system.paths.var = ROOT_DIR "/var"
system.paths.log = ROOT_DIR "/var/log/debug"
system.paths.report = ROOT_DIR "/var/log/report"
;The config which must disable / change in production server
;error reporting
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
;database settings
database.adapter = pdo_mysql
database.params.host =
database.params.username =
database.params.password =
database.params.dbname =
database.params.profiler.enabled = true
database.params.profiler.class = Zend_Db_Profiler_Firebug
;system or application related configuration
;logging and debugging
system.log.error.enable = true
system.log.debug.enable = true
system.log.debug.firebug = false
system.log.debug.critonly = false
system.log.report.enable = false
;javascript compress option
system.view.js.minify.enable = false
system.view.js.minify.prefix = ycomp
system.view.js.compress.enable = false
system.view.js.compress.prefix =
;css compress option
system.view.css.minify.enable = false
system.view.css.minify.prefix = min
system.view.css.compress.enable = false
system.view.css.compress.prefix =
; page compression option
system.phpSpeedy.active = 0
system.phpSpeedy.minify.page = 1
system.phpSpeedy.gzip.page = 1
; date format to be used in all view
system.view.date.format = "Y-m-d"
; cache configuration
system.cache.translate = true;
system.cache.db_meta = true;
; database cache settings
cache.frontend.type = Core
cache.frontend.options.lifetime = 86400
cache.frontend.options.automatic_serialization = true
cache.frontend.options.cache_id_prefix = TutorialV2_
cache.frontend.options.cache = true
cache.backend.type = Memcached
cache.backend.options.servers.1.host = localhost
cache.backend.options.servers.1.port = 8086
cache.backend.options.servers.1.persistent = true
cache.backend.options.servers.1.weight = 1
cache.backend.options.servers.1.timeout = 5
cache.backend.options.servers.1.retry_interval = 15
; each modules view settings
system.storefront.layout.encoding = "UTF-8"
system.storefront.layout.doctype = "XHTML1_TRANSITIONAL"
system.storefront.layout.contenttype = "text/html; charset=UTF-8"
system.storefront.layout.title.name = "Tutorial - Tutorial | Manage Your Sporting Activities"
system.storefront.layout.title.seperator = ": :"
system.storefront.layout.name = "default"
system.storefront.template.name = "one-coloumn"
system.storefront.layout.skin = "red"
system.admin.layout.encoding = "UTF-8"
system.admin.layout.doctype = "XHTML1_TRANSITIONAL"
system.admin.layout.contenttype = "text/html; charset=UTF-8"
system.admin.layout.title.name = "Tutorial - Tutorial | Manage Your Sporting Activities"
system.admin.layout.title.seperator = ": :"
system.admin.layout.name = "default"
system.admin.template.name = "one-coloumn"
system.admin.layout.skin = "red"
system.services.layout = false
;ssl config
modules.storefront.checkout.index.require_ssl = true
modules.storefront.checkout.save-shipping-billing.require_ssl = true
modules.storefront.checkout.show-popup.require_ssl = optional
;set timezone
phpsettings.date.timezone = "America/Chicago"
;include path
includePaths.library = ROOT_DIR "/library"
;bootstrap
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
;autoloadernamespaces
autoloadernamespaces.0 = "Tutorial_"
autoloadernamespaces.1 = "Zend_"
;resources.frontController
resources.frontController.plugins.moduleswitcher = "Tutorial_Controller_Plugin_ModuleSwitcher"
resources.frontController.plugins.hasaccess = "Tutorial_Controller_Plugin_HasAccess"
;resources.view
resources.view.helperPath.Tutorial_View_Helper = ROOT_DIR "/library/Tutorial/View/Helper"
; configuration defined by application developer
; required paths informations
system.paths.var = ROOT_DIR "/var"
system.paths.log = ROOT_DIR "/var/log/debug"
system.paths.report = ROOT_DIR "/var/log/report"
;The config which must disable / change in production server
;error reporting
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
;database settings
database.adapter = pdo_mysql
database.params.host =
database.params.username =
database.params.password =
database.params.dbname =
database.params.profiler.enabled = true
database.params.profiler.class = Zend_Db_Profiler_Firebug
;system or application related configuration
;logging and debugging
system.log.error.enable = true
system.log.debug.enable = true
system.log.debug.firebug = false
system.log.debug.critonly = false
system.log.report.enable = false
;javascript compress option
system.view.js.minify.enable = false
system.view.js.minify.prefix = ycomp
system.view.js.compress.enable = false
system.view.js.compress.prefix =
;css compress option
system.view.css.minify.enable = false
system.view.css.minify.prefix = min
system.view.css.compress.enable = false
system.view.css.compress.prefix =
; page compression option
system.phpSpeedy.active = 0
system.phpSpeedy.minify.page = 1
system.phpSpeedy.gzip.page = 1
; date format to be used in all view
system.view.date.format = "Y-m-d"
; cache configuration
system.cache.translate = true;
system.cache.db_meta = true;
; database cache settings
cache.frontend.type = Core
cache.frontend.options.lifetime = 86400
cache.frontend.options.automatic_serialization = true
cache.frontend.options.cache_id_prefix = TutorialV2_
cache.frontend.options.cache = true
cache.backend.type = Memcached
cache.backend.options.servers.1.host = localhost
cache.backend.options.servers.1.port = 8086
cache.backend.options.servers.1.persistent = true
cache.backend.options.servers.1.weight = 1
cache.backend.options.servers.1.timeout = 5
cache.backend.options.servers.1.retry_interval = 15
; each modules view settings
system.storefront.layout.encoding = "UTF-8"
system.storefront.layout.doctype = "XHTML1_TRANSITIONAL"
system.storefront.layout.contenttype = "text/html; charset=UTF-8"
system.storefront.layout.title.name = "Tutorial - Tutorial | Manage Your Sporting Activities"
system.storefront.layout.title.seperator = ": :"
system.storefront.layout.name = "default"
system.storefront.template.name = "one-coloumn"
system.storefront.layout.skin = "red"
system.admin.layout.encoding = "UTF-8"
system.admin.layout.doctype = "XHTML1_TRANSITIONAL"
system.admin.layout.contenttype = "text/html; charset=UTF-8"
system.admin.layout.title.name = "Tutorial - Tutorial | Manage Your Sporting Activities"
system.admin.layout.title.seperator = ": :"
system.admin.layout.name = "default"
system.admin.template.name = "one-coloumn"
system.admin.layout.skin = "red"
system.services.layout = false
;ssl config
modules.storefront.checkout.index.require_ssl = true
modules.storefront.checkout.save-shipping-billing.require_ssl = true
modules.storefront.checkout.show-popup.require_ssl = optional
Monday, October 25, 2010
Tny MCE Editor Problem
When you open mce-editor in popup just include following function
/**************Tiny Mce on POPUP**********************/
toggleEditor('con_des'); //text area id
function toggleEditor(id) {
if (tinyMCE.getInstanceById(id) == null){
tinyMCE.execCommand('mceAddControl', false, id);
} else {
tinyMCE.execCommand('mceRemoveControl', false, id);
}
}
/***********************************************************/
/**************Tiny Mce on POPUP**********************/
toggleEditor('con_des'); //text area id
function toggleEditor(id) {
if (tinyMCE.getInstanceById(id) == null){
tinyMCE.execCommand('mceAddControl', false, id);
} else {
tinyMCE.execCommand('mceRemoveControl', false, id);
}
}
/***********************************************************/
Apply Editor ONLY to Specific textarea?
just add the attribute 'editor_selector' in tinyMCE.init . The value for this attribute is a css class name which should be used in the textarea where you want to apply editor
For ex:
tinyMCE.init({
// General options
mode : "textareas",
theme : "advanced",
plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
editor_selector :"mceEditor", // css class
...... etc.
content_css : "../name.css", // css path
.... etc
);
and in the textarea tag
<textarea name="description" style="width:100%;" class="mceEditor">
For ex:
tinyMCE.init({
// General options
mode : "textareas",
theme : "advanced",
plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
editor_selector :"mceEditor", // css class
...... etc.
content_css : "../name.css", // css path
.... etc
);
and in the textarea tag
<textarea name="description" style="width:100%;" class="mceEditor">
Ajax Page post
After including the jquery then call following function
(http://code.jquery.com/jquery-1.4.3.min.js)
<script src=jquery-1.4.3.min.js></script>
functions.js
------------------------
function saveTeamName()
{
var teamURL=$('#teamURL').val()
var teamID=$('#teamID').val()
var teamName=$('#txtTeamName').val()
vData = 'teamid='+teamID+'&teamname='+teamName;
$.ajax({
type : "POST",
url : g_site_path+"/"+teamURL+"/save-team-name",
data : vData,
dataType : 'html',
success: function(html){
if(html=='ext')
$('#ErrMsg').html('Page Name Already exist.');
else
{
$('#ErrMsg').html('Your Page Updated successfully.');
$('#ErrMsg').hide('slow')
$('#teamNameDiv').show('slow')
document.getElementById('teamNameDiv').innerHTML=teamName
$('#chgTeamNameDiv').hide('slow')
}
}
});
(http://code.jquery.com/jquery-1.4.3.min.js)
<script src=jquery-1.4.3.min.js></script>
functions.js
------------------------
function saveTeamName()
{
var teamURL=$('#teamURL').val()
var teamID=$('#teamID').val()
var teamName=$('#txtTeamName').val()
vData = 'teamid='+teamID+'&teamname='+teamName;
$.ajax({
type : "POST",
url : g_site_path+"/"+teamURL+"/save-team-name",
data : vData,
dataType : 'html',
success: function(html){
if(html=='ext')
$('#ErrMsg').html('Page Name Already exist.');
else
{
$('#ErrMsg').html('Your Page Updated successfully.');
$('#ErrMsg').hide('slow')
$('#teamNameDiv').show('slow')
document.getElementById('teamNameDiv').innerHTML=teamName
$('#chgTeamNameDiv').hide('slow')
}
}
});
Java script
Page Scrolling Scripts
Ref: http://www.mediacollege.com/internet/javascript/page/scroll.html
Ref: http://www.mediacollege.com/internet/javascript/page/scroll.html
How to Scroll a Page With JavaScript
This page demonstrates how to use the JavaScript scrollBy and setTimeout methods to make a web page scroll down automatically. Change the timeout value to alter the scrolling speed in milliseconds. The example function below (arbitrarily called pageScroll) shows how this can work:function pageScroll() { window.scrollBy(0,50); // horizontal and vertical scroll increments scrolldelay = setTimeout('pageScroll()',100); // scrolls every 100 milliseconds }To being scrolling automatically when the page loads, add the following code to the body tag:
<body onLoad="pageScroll()">To begin scrolling when prompted by the user, call the function from a link or button:
Text Link
<a href="javascript:pageScroll()">Scroll Page</a>Scroll Page (Note: If you click this link, you'll need to click the link at the bottom of the page to cancel the scrolling)
Button
<input type="button" onClick="pageScroll()" value="Scroll Page">
Stop Scrolling
The pageScroll() function causes the page to keep scrolling forever. The following function will stop the scrolling, and can be called in the same way:function stopScroll() { clearTimeout(scrolldelay); } <a href="javascript:stopScroll()">Stop Scrolling</a>Stop Scroll
Scroll Directly to a Particular Point
Use the scroll() method to jump to a particular point on the page. The target position is specified in pixels from the top left corner of the page, horizontally and vertically.function jumpScroll() { window.scroll(0,150); // horizontal and vertical scroll targets } <a href="javascript:jumpScroll()">Jump to another place on the page</a>
Wednesday, October 13, 2010
Javascript Validation with Regular Expression
Form validation
checkWholeForm()
checkUsername()
checkEmail()
function numeric_validate(val)
checkWholeForm()
------------------------------------------
function checkWholeForm(theForm) { var why = ""; why += checkEmail(theForm.email.value); why += checkPhone(theForm.phone.value); why += checkPassword(theForm.password.value); why += checkUsername(theForm.username.value); why += isEmpty(theForm.notempty.value); why += isDifferent(theForm.different.value); for (i=0, n=theForm.radios.length; i<n; i++) { if (theForm.radios[i].checked) { var checkvalue = theForm.radios[i].value; break; } } why += checkRadio(checkvalue); why += checkDropdown(theForm.choose.selectedIndex); if (why != "") { alert(why); return false; } return true; } -----------------------------------------------
checkUsername()
----------------------------------------------------------------------
function checkUsername (strng) { var error = ""; if (strng == "") { error = "You didn't enter a username.\n"; } --------------- if ((strng.length < 4) || (strng.length > 10)) { error = "The username is the wrong length.\n"; } ---------------- var illegalChars = /\W/; // allow only letters, numbers, and underscores if (illegalChars.test(strng)) { error = "The username contains illegal characters.\n"; } --------------------------------------------------------------------
checkPassword()
function checkPassword (strng) { var error = ""; if (strng == "") { error = "You didn't enter a password.\n"; } var illegalChars = /[\W_]/; // allow only letters and numbers if ((strng.length < 6) || (strng.length > 8)) { error = "The password is the wrong length.\n"; } else if (illegalChars.test(strng)) { error = "The password contains illegal characters.\n"; } -------------------------------------------------------------- else if (!((strng.search(/[a-z]+/) > -1) && (strng.search(/[A-Z]+/) > -1) && (strng.search(/[0-9]+/) > -1))) { error = "The password must contain at least one uppercase letter, one lowercase letter, and one numeral.\n"; } ----------------------------------------------------------
checkEmail()
var emailFilter=/^.+@.+\..{2,3,4,6}$/; if (!(emailFilter.test(strng))) { error = "Please enter a valid email address.\n"; } --------------- var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/ if (strng.match(illegalChars)) { error = "The email address contains illegal characters.\n"; } ------------------------------------------------------------------
checkPhone()
var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters if (isNaN(parseInt(stripped))) { error = "The phone number contains illegal characters."; } ------------ if (!(stripped.length == 10)) { error = "The phone number is the wrong length. Make sure you included an area code.\n"; } --------------------------------------------------------
checkRadio()
for (i=0, n=theForm.radios.length; i<n; i++) { if (theForm.radios[i].checked) { var checkvalue = theForm.radios[i].value; break; } } why += checkRadio(checkvalue); function checkRadio(checkvalue) { var error = ""; if (!(checkvalue)) { error = "Please check a radio button.\n"; } return error; } -------------------------------------------------------
check Dropdown()
function checkDropdown(choice) { var error = ""; if (choice == 0) { error = "You didn't choose an option from the drop-down list.\n"; } return error; } ------------------------------------------------------- Numeric /Numbers only validation
function numeric_validate(val)
{
var rege = /^\d+$/;
if(rege.test(val))
return true
else
return false
}
Sunday, October 3, 2010
Zend frame work run complex queries(select/join/innerjoin/union)
mysql query just ex:
/*************************************************************************/
SELECT T.* FROM(
SELECT
team_user_id,
user.user_fname,
user.user_lname,
user.user_email
FROM
test_team team
INNER JOIN test_users user ON user.user_id=team_user_id
WHERE
team_id=24 AND team_status=1 AND user_status=1
UNION
SELECT
user.user_id,
user.user_fname,
user.user_lname,
user.user_email
FROM
`test_team` AS `t`
INNER JOIN `test_team_players` AS `tp` ON t.team_id = tp.plyr_team_id
INNER JOIN `test_relationships` rlsp ON rlsp.rlsp_rsty_id = 2
INNER JOIN `test_users` AS `user` ON user.user_id = rlsp.rlsp_relation_user_id
WHERE
(user.user_status=1 and t.team_status=1 and tp.plyr_status=1 and t.team_id=24 and rlsp.rlsp_user_id = tp.plyr_user_id)
)as T order by T.user_lname
/*****************************************************************/
//Zend converted queries will be
/****************************************************************/
$pmSort = 'user_lname DESC';
$qry1=$this->select()
->setIntegrityCheck(false)
->from(array('team'=>'test_team'),array('team_id','team_name','team_sprt_id','team_user_id'))
->joinInner(array('user'=>'test_users'),'user.user_id=team_user_id',array('user_fname','user_lname','user_email'))
->where("team_id='$pmTeamID' and team_status=1 and user_status=1");
$qry2=$this->select()
->setIntegrityCheck(false)
->from(array('t'=>'test_team'),array('team_id'))
->joinInner(array('tp'=>'test_team_players'),'t.team_id = tp.plyr_team_id',array('plyr_id'))
->joinInner(array('rlsp'=>'test_relationships'),'rlsp.rlsp_rsty_id = 2',array('rlsp_id'))
->joinInner(array('user'=>'test_users'),'user.user_id = rlsp.rlsp_relation_user_id',array('user_id','user_fname','user_lname','user_email'))
->where("user.user_status=1 and t.team_status=1 and tp.plyr_status=1 and t.team_id='$pmTeamID' and rlsp.rlsp_user_id = tp.plyr_user_id");
$select = $this->select()
->setIntegrityCheck(false)
->union(array($qry1, $qry2));
$select1 = $this->select()
->setIntegrityCheck(false)
->from(array('T'=> $select ) )
->order($pmSort);
echo $select1;
/************************************************************************/
/*************************************************************************/
SELECT T.* FROM(
SELECT
team_user_id,
user.user_fname,
user.user_lname,
user.user_email
FROM
test_team team
INNER JOIN test_users user ON user.user_id=team_user_id
WHERE
team_id=24 AND team_status=1 AND user_status=1
UNION
SELECT
user.user_id,
user.user_fname,
user.user_lname,
user.user_email
FROM
`test_team` AS `t`
INNER JOIN `test_team_players` AS `tp` ON t.team_id = tp.plyr_team_id
INNER JOIN `test_relationships` rlsp ON rlsp.rlsp_rsty_id = 2
INNER JOIN `test_users` AS `user` ON user.user_id = rlsp.rlsp_relation_user_id
WHERE
(user.user_status=1 and t.team_status=1 and tp.plyr_status=1 and t.team_id=24 and rlsp.rlsp_user_id = tp.plyr_user_id)
)as T order by T.user_lname
/*****************************************************************/
//Zend converted queries will be
/****************************************************************/
$pmSort = 'user_lname DESC';
$qry1=$this->select()
->setIntegrityCheck(false)
->from(array('team'=>'test_team'),array('team_id','team_name','team_sprt_id','team_user_id'))
->joinInner(array('user'=>'test_users'),'user.user_id=team_user_id',array('user_fname','user_lname','user_email'))
->where("team_id='$pmTeamID' and team_status=1 and user_status=1");
$qry2=$this->select()
->setIntegrityCheck(false)
->from(array('t'=>'test_team'),array('team_id'))
->joinInner(array('tp'=>'test_team_players'),'t.team_id = tp.plyr_team_id',array('plyr_id'))
->joinInner(array('rlsp'=>'test_relationships'),'rlsp.rlsp_rsty_id = 2',array('rlsp_id'))
->joinInner(array('user'=>'test_users'),'user.user_id = rlsp.rlsp_relation_user_id',array('user_id','user_fname','user_lname','user_email'))
->where("user.user_status=1 and t.team_status=1 and tp.plyr_status=1 and t.team_id='$pmTeamID' and rlsp.rlsp_user_id = tp.plyr_user_id");
$select = $this->select()
->setIntegrityCheck(false)
->union(array($qry1, $qry2));
$select1 = $this->select()
->setIntegrityCheck(false)
->from(array('T'=> $select ) )
->order($pmSort);
echo $select1;
/************************************************************************/
Subscribe to:
Posts (Atom)