Filed Under (Joomla! 1.5) by khawaib on 29-04-2010
Joomla’s Breezing Form data variables:
// fallback if no template exists
if ($this->record_id != '')
$body .= BFText::_('PROCESS_RECORDSAVEDID')." ".$this->record_id.nl().nl();
$body .=
BFText::_('PROCESS_FORMID').": ".$this->form.nl().
BFText::_('PROCESS_FORMTITLE').": ".$this->formrow->title.nl().
BFText::_('PROCESS_FORMNAME').": ".$this->formrow->name.nl().nl().
BFText::_('PROCESS_SUBMITTEDAT').": ".$this->submitted.nl().
BFText::_('PROCESS_SUBMITTERIP').": ".$this->ip.nl().
BFText::_('PROCESS_PROVIDER').": ".$this->provider.nl().
BFText::_('PROCESS_BROWSER').": ".$this->browser.nl().
BFText::_('PROCESS_OPSYS').": ".$this->opsys.nl().nl();
if (count($this->maildata)) foreach ($this->maildata as $data)
$body .= $data[_FF_DATA_TITLE].": ".$data[_FF_DATA_VALUE].nl();
}
$attachment = NULL;
if ($this->formrow->emailxml>0) {
$attachment = $this->expxml();
if ($this->status != _FF_STATUS_OK) return;
} // if
for($i = 0; $i < $recipientsSize;$i++){
$this->sendMail($from, $fromname, $recipients[$i], $subject, $body, $attachment, $isHtml);
}
echo "test";
} // sendEmailNotification
Filed Under (Uncategorized) by khawaib on 27-04-2010
Using following code we can get joomla’s language and use it in our extensions code.
$lg = &JFactory::getLanguage();
$language = $lg->getBackwardLang();
$language will give us the current language selected.
Filed Under (Joomla! 1.0) by khawaib on 26-04-2010
$uri is global variable which holds current SEF url in Joomla 1.0
global $uri;
$thisurl = 'http://'.$_SERVER['SERVER_NAME'].DS.'component'.DS.$uri[1];
Filed Under (Ubuntu) by khawaib on 20-04-2010
Some useful Ubuntu command lines I use often:
Restart Appache
/etc/init.d/apache2 restart
Restart MySQL
/etc/init.d/mysql restart
Find Ubuntu Server Specs
cat /etc/lsb-release
Update the directory permissions
cd /var/www/vhosts/[domain.com]
chown -R [username]:psacln httpdocs
chmod -R g+w httpdocs
find httpdocs -type d -exec chmod g+s {} \;
Collect Statictics data:
/usr/local/psa/admin/sbin/statistics >/dev/null 2>&1
Filed Under (Joomla! 1.5) by khawaib on 20-04-2010
Following is a template that can be used to develop plugins to inert code into Joomla head section.
<?xml version="1.0" encoding="utf-8"?>
<install version="1.5" type="plugin" group="system">
<name>System - Name of Plugin</name>
<author>Name of author</author>
<creationDate>19th April 2010</creationDate>
<authorEmail>email@email.com</authorEmail>
<authorUrl>http://www.khawaib.co.uk</authorUrl>
<version>1.0</version>
<copyright>Copyright (c) 2010 Khawaib Ahmed. All rights reserved.</copyright>
<license>http://www.gnu.org/copyleft/gpl.html GNU/GPL</license>
<description> Plugin description.</description>
<files>
<filename plugin="phpFileName">phpFileName.php</filename>
</files>
<params>
<param name="code" type="text" default="[DEFAULT VALUE]" label="[LABEL]" description=" [DESCRIPTION]" />
</params>
</install>
<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.plugin.plugin');
class plgSystemAsynGoogleAnalytics extends JPlugin {
function plgAsynGoogleAnalytics(&$subject, $config) {
parent::__construct($subject, $config);
$this->_plugin = JPluginHelper::getPlugin( 'system', 'AsynGoogleAnalytics' );
$this->_params = new JParameter( $this->_plugin->params );
}
function onAfterRender() {
global $mainframe;
// skip if admin page
if($mainframe->isAdmin()) {
return;
}
// get params
$trackerCode = $this->params->get( 'code', '' );
//getting body code and storing as buffer
$buffer = JResponse::getBody();
//embed Google Analytics code
$javascript = "<script type=\"text/javascript\">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '".$trackerCode."']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>";
// adding the Google Analytics code in the header before the ending </head> tag and then replacing the buffer
$buffer = preg_replace ("/<\/head>/", "\n\n".$javascript."\n\n</head>", $buffer);
//output the buffer
JResponse::setBody($buffer);
return true;
}
}
?>
Filed Under (Joomla! 1.5) by khawaib on 19-04-2010
GPL guidelines for submitting extensions to Joomla Extensions Directory(JED).
1- PHP files:
1A- Notice at the top of each php file stating that it is distributed under the terms of the GPL
(see http://www.fsf.org/licensing/licenses/gpl-howto.html for details)
1B- Copyright notice at the top of each php file,
as in:
/**
* @Copyright Copyright (C) 2010- ... author-name
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
**/
2- XML File
2A- a
tag in your extension’s XML file stating that it is GPL,
as in:
<license>GNU/GPL http://www.gnu.org/copyleft/gpl.html</license>
2B- a copy of the GPL license with your package
(note: this does not need to be installed with the extension, just included with the package as a text file)
Filed Under (Joomla! 1.5) by khawaib on 13-04-2010
Use following code to turn off/remove Mootools in Joomla template on frontend.
$user =& JFactory::getUser();
if($user->get('guest') == 1) {
$search = array('mootools', 'caption.js');
// remove the js files
foreach($this->_scripts as $key => $script) {
foreach($search as $findme) {
if(stristr($key, $findme) !== false) {
unset($this->_scripts[$key]);
}
}
}
}
Filed Under (JavaScript) by khawaib on 06-04-2010
JavaScript:
Use inline JavaScript to send user back to previous page.
<input type="button" value="Go Back" onclick="history.back(-1)" />
Can also send user two steps back as well.
<input type="button" value="Go Back" onclick="history.back(-2)" />
PHP:
PHP code to send user back.
<?php
$url = htmlspecialchars($_SERVER['HTTP_REFERER']);
echo "<a href='$url'>back</a>";
?>
Filed Under (CSS) by khawaib on 06-04-2010
Input elements can be targeted by assigning tags to the same input types. It is possible that we want to style input elements as text input fields, text areas and select boxes to have different widths while button input elements to have a different style.
<input type="text" class="text" />
<input type="checkbox" class="checkbox" />
<input type="radio" class="radio" />
<input type="button" class="button" />
Can also use multiple classes:
<input type="password" class="password text" />
Now using following in css we can target each type separately.
input[type="button"] { border:2px solid #ccc; padding:3px}