You can use the below code in the controller and it will return an array of config variables.
$config = $this->getInvokeArg(‘bootstrap’)->getOptions();
Zend Form button with onclick attribute
$form = new Zend_Form();
$form->addElement('button', 'add', array(
'Label' => 'Add Person',
'order' => '2',
'attribs' => array('onclick'=>'addMemberToSharedCalendar(this)')
));
$form->addElement('button', 'add', array(
'Label' => 'Add Person',
'order' => '2',
'attribs' => array('onclick'=>'addMemberToSharedCalendar(this)')
));
How to Set and Get Session values in Zend Framework
//To set the session
Initialize the session name space
$this->nameSpace = new Zend_Session_Namespace('HN');
$this->nameSpace->userId = 'userId';
//To get the session value
Initialize the session name space
$this->nameSpace = new Zend_Session_Namespace('HN');
$userId = $this->nameSpace->userId;
Initialize the session name space
$this->nameSpace = new Zend_Session_Namespace('HN');
$this->nameSpace->userId = 'userId';
//To get the session value
Initialize the session name space
$this->nameSpace = new Zend_Session_Namespace('HN');
$userId = $this->nameSpace->userId;
How to get the config variables in Zend Framework
$config = new Zend_Config_Ini(
APPLICATION_PATH . '/configs/application.ini',
'production'
);
$config->resources->db->params->dbname;
$config->resources->db->params->username;
APPLICATION_PATH . '/configs/application.ini',
'production'
);
$config->resources->db->params->dbname;
$config->resources->db->params->username;
How to get the $_SERVER variables in Zend Framework
We can get this by calling the method $this->getRequest()->getServer() in the Zend_Controller_Action
How to remove the session name space in Zend Framework
Session name space can be removed using the function
Zend_Session::namespaceUnset($nameOfspace)
Zend_Session::namespaceUnset($nameOfspace)
How to remove the recipients in the Zend Framework
We can use the clearRecipients function in the Zend_Mail class
Zend_Mail::clearRecipients();
Zend_Mail::clearRecipients();
check and uncheck the all checkbox using javascript
/**
pass the checkbox_name array
**/
function checkAll(form_object, checkbox_name)
{
for(var i=0; i < form_object[checkbox_name].length; i++)
{
form_object[checkbox_name][i].checked = true;
}
}
function uncheckAll(form_object, checkbox_name)
{
for(var i=0; i < form_object[checkbox_name].length; i++){
form_object[checkbox_name][i].checked = false;
}
}
pass the checkbox_name array
**/
function checkAll(form_object, checkbox_name)
{
for(var i=0; i < form_object[checkbox_name].length; i++)
{
form_object[checkbox_name][i].checked = true;
}
}
function uncheckAll(form_object, checkbox_name)
{
for(var i=0; i < form_object[checkbox_name].length; i++){
form_object[checkbox_name][i].checked = false;
}
}
Convert video file to .flv format
xec("ffmpeg -i '/home/tut2pr8c/public_html/videos/$video_file' -ar 22050 -ab 32 -f flv -y -s 400x320 /home/tut2pr8c/public_html/video_flv/$new_video_file_name");
exec("ffmpeg -i '/home/tut2pr8c/public_html/videos/$video_file' -ar 22050 -ab 32 -f flv -y -s 400x320 /home/tut2pr8c/public_html/video_flv/$new_video_file_name");
exec("ffmpeg -i '/home/tut2pr8c/public_html/videos/$video_file' -ar 22050 -ab 32 -f flv -y -s 400x320 /home/tut2pr8c/public_html/video_flv/$new_video_file_name");
Find browser using PHP
public function getBrowserType(){
$sUserBrowserAgent = '';
if (ereg('OPERA(/| )([0-9].[0-9]{1,2})', strtoupper($_SERVER["HTTP_USER_AGENT"]), $log_version)) {
$sUserBrowserAgent = 'OPERA';
} else if (ereg('MSIE ([0-9].[0-9]{1,2})', strtoupper($_SERVER["HTTP_USER_AGENT"]), $log_version)) {
$sUserBrowserAgent = 'IE';
} else if (ereg('OMNIWEB/([0-9].[0-9]{1,2})', strtoupper($_SERVER["HTTP_USER_AGENT"]), $log_version)) {
$sUserBrowserAgent = 'OMNIWEB';
} else if (ereg('MOZILLA/([0-9].[0-9]{1,2})', strtoupper($_SERVER["HTTP_USER_AGENT"]), $log_version)) {
$sUserBrowserAgent = 'MOZILLA';
} else if (ereg('KONQUEROR/([0-9].[0-9]{1,2})', strtoupper($_SERVER["HTTP_USER_AGENT"]), $log_version)) {
$sUserBrowserAgent = 'KONQUEROR';
} else {
$sUserBrowserAgent = 'OTHER';
}
return $sUserBrowserAgent;
}
$sUserBrowserAgent = '';
if (ereg('OPERA(/| )([0-9].[0-9]{1,2})', strtoupper($_SERVER["HTTP_USER_AGENT"]), $log_version)) {
$sUserBrowserAgent = 'OPERA';
} else if (ereg('MSIE ([0-9].[0-9]{1,2})', strtoupper($_SERVER["HTTP_USER_AGENT"]), $log_version)) {
$sUserBrowserAgent = 'IE';
} else if (ereg('OMNIWEB/([0-9].[0-9]{1,2})', strtoupper($_SERVER["HTTP_USER_AGENT"]), $log_version)) {
$sUserBrowserAgent = 'OMNIWEB';
} else if (ereg('MOZILLA/([0-9].[0-9]{1,2})', strtoupper($_SERVER["HTTP_USER_AGENT"]), $log_version)) {
$sUserBrowserAgent = 'MOZILLA';
} else if (ereg('KONQUEROR/([0-9].[0-9]{1,2})', strtoupper($_SERVER["HTTP_USER_AGENT"]), $log_version)) {
$sUserBrowserAgent = 'KONQUEROR';
} else {
$sUserBrowserAgent = 'OTHER';
}
return $sUserBrowserAgent;
}
MYSQL - LEFT JOIN query
SELECT U.username, U.user_id, SR.section_id, U.access, count( DISTINCT SR.section_id ) AS section_count
FROM `users` U
LEFT JOIN `survey_replies` SR ON ( U.user_id = SR.user_id )
WHERE U.access >1
GROUP BY U.user_id
ORDER BY SR.section_id
FROM `users` U
LEFT JOIN `survey_replies` SR ON ( U.user_id = SR.user_id )
WHERE U.access >1
GROUP BY U.user_id
ORDER BY SR.section_id
Regular expression to remove the file name from the SERVER vairables
$sScriptPath = preg_replace("@/(\w){1,}.php(\w)?$@","",$_SERVER['SCRIPT_NAME']);
$sActionPage = "https://".$_SERVER['HTTP_HOST'].$sScriptPath."/member.php?action=add"
$sActionPage = "https://".$_SERVER['HTTP_HOST'].$sScriptPath."/member.php?action=add"
Javscript Date comparison with current date
var d=new Date();
var form_date = "01-08-2009";
var split_date = form_date.split("-");
var added_timestamp = Number(d.setMonth(split_date[0]-1,split_date[1]));
var form_date = parseInt(split_date[0])+"/"+parseInt(split_date[1])+"/"+parseInt(split_date[2])+" "+d.getHours()+":"+d.getMinutes()+":"+d.getSeconds();
var timestamp = Number(new Date());
if(form_date < timestamp){
alert(Please select the date greater than the current date!);
}
var form_date = "01-08-2009";
var split_date = form_date.split("-");
var added_timestamp = Number(d.setMonth(split_date[0]-1,split_date[1]));
var form_date = parseInt(split_date[0])+"/"+parseInt(split_date[1])+"/"+parseInt(split_date[2])+" "+d.getHours()+":"+d.getMinutes()+":"+d.getSeconds();
var timestamp = Number(new Date());
if(form_date < timestamp){
alert(Please select the date greater than the current date!);
}
Subscribe to:
Posts (Atom)