Skip to content

Instantly share code, notes, and snippets.

View dongilbert's full-sized avatar
😍
Mautic WOOOO

Don Gilbert dongilbert

😍
Mautic WOOOO
View GitHub Profile
@dongilbert
dongilbert / Joomla Events
Last active December 12, 2015 10:29
List of Joomla Events found in 3.0.3 core via `grep -r "trigger('on" *` and `grep -r "triggerEvent('on" *`
onAfterDispatch
onAfterExecute
onAfterInitialise
onAfterRender
onAfterRespond
onAfterRoute
onAfterSessionStart
onBeforeCompileHead
onBeforeExecute
onBeforeIndex
@dongilbert
dongilbert / README.md
Created February 7, 2013 18:01
Build body classes for your template from common available variables.

BodyClass Generator

This method will create a string of body classes based on common variables, like the currently active option, view, and layout. It also splits the path of the currently loaded URL and puts it into the class string.

The advantages of this is that it allows you to style views as well as layouts and specific pages on your site.

Usage

@dongilbert
dongilbert / chapter.php
Last active December 10, 2015 17:49 — forked from drmmr763/chapter.php
Moved the query from the loop into a sub query and then optimized a little.
<?php
public function getSubmits()
{
$cid = JFactory::getApplication()->input->getInt('cid');
$db = $this->getDbo();
$query = $db->getQuery(true);
$query->select('a.*, i.username');
$query->select('(SELECT SUM(v.vote) FROM #__rootflick_vote AS v WHERE v.sub_id = a.id) AS vote');
@dongilbert
dongilbert / SQLInjection.php
Created December 18, 2012 12:55
Read this today on a developer thread. I was horrified, but then I realized he was working on his local machine - so no issue there. But, then I read the rest of his email/question, and in his signature, it said "Senior PHP Developer." NNNOOOOOO
<?php
mysql_connect("localhost", "uname", "pass@3") or die(mysql_error());
echo "Connected to MySQL<br />"; // working fine
mysql_select_db("dbname") or die(mysql_error());
echo "Connected to Database"; // working fine
@dongilbert
dongilbert / magic.php
Created December 12, 2012 19:44
Abstract class containing magic __set and __get methods to alleviate B/C issues with removing underscore from protected properties.
<?php
abstract class JFixProtected
{
public function __set($name, $value)
{
$name = $this->cleanPropertyName($name);
$this->$name = $value;
}
@dongilbert
dongilbert / example.php
Created December 4, 2012 20:48
Auto Loading Custom Libraries
<?php
/**
* Proposal to auto load custom libraries and register them with the
* application for use. Assume the directory structure below:
*
* /libraries
* - import.php
* - /joomla
* - /easel // The custom library
@dongilbert
dongilbert / example.md
Last active October 13, 2015 13:57
JHtml::asset()

Joomla Asset Management with JHtml

// To load a css file for a component, from within the component
EEHtml::asset('style.css');

// To load a js file for a module
EEHtml::asset('slide.js', 'mod_menu');

// To load an image for a module
echo EEHtml::asset('search.png', 'mod_product_search');
@dongilbert
dongilbert / lead_controller.php
Created December 3, 2012 15:00
Joomla Export to CSV
<?php
/**
* @version 1.0.0
* @package com_stats
* @copyright Copyright (C) 2012. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access.
defined('_JEXEC') or die;
@dongilbert
dongilbert / composer.json
Created November 29, 2012 01:03
Joomla Composer
{
"require": {
"joomla/platform": ">=13.2"
},
"minimum-stability": "dev",
"require-dev": {
"phpunit/phpunit": "3.7.*"
},
"config": {
"bin-dir": "bin",
@dongilbert
dongilbert / namespace.php
Last active May 12, 2019 11:25
Joomla Namespace Compatibility Layer
<?php
return array(
'JAccess' => 'Joomla\\Access\\Access',
'JAccessRule' => 'Joomla\\Access\\Rule',
'JAccessRules' => 'Joomla\\Access\\Rules',
'JApplicationBase' => 'Joomla\\Application\\Base',
'JApplicationCli' => 'Joomla\\Application\\Cli',
'JApplicationDaemon' => 'Joomla\\Application\\Daemon',
'JRoute' => 'Joomla\\Application\\Route',