Skip to content

Instantly share code, notes, and snippets.

@eddieajau
eddieajau / date.php
Created September 20, 2011 22:10
Joomla platform JHtmlDate::ago concept
class JHtmlDHDate
{
/**
* Outputs a relative time.
*
* @param mixed $date A string or DateTime object representing the time in the past to compare to now.
*
* @return string
*
* @since 1.0.1
@eddieajau
eddieajau / database_iterator.php
Created February 21, 2012 07:28
Joomla Database Iterator
<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
@eddieajau
eddieajau / gist:2505017
Created April 27, 2012 01:57
A class method that can be used to import a CSV file of any size using SplFileObject.
/**
* Import a CSV file.
*
* @param string $fileName The name of the file to import. If omitted, the state is used.
* @param integer $offset The number of lines/rows to ignore (default = 0).
*
* @return void
*
* @since 1.0
* @throws InvalidArgumentException if file name is invalid or does not exist.
@eddieajau
eddieajau / PSR-1.md
Created May 4, 2012 23:29
PSR-1,2 Combined variant

PSR-1 PHP Code Style Standard

Version: 1 2012-05-??

This standard comprises the code style requirements for interoperability (Section 1) and the best practices guidelines (Section 2) for PHP projects.

O Definitions

studly-caps refers to a naming convention where all 'words' in the name are conactenated and have only the first letter in uppercase followed by lower case letters (for example "StudlyCaps").

@eddieajau
eddieajau / debug.php
Created May 10, 2012 05:18
Printing a clean debug backtrace in PHP.
// PHP < 5.3.6
foreach (debug_backtrace() as $trace)
{
echo sprintf("\n%s:%s %s::%s", $trace['file'], $trace['line'], $trace['class'], $trace['function']);
}
die;
// PHP >= 5.3.6
debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
die;
@eddieajau
eddieajau / libraries_cms_version_compatibility.php
Created December 13, 2012 04:33
Joomla version compatibility class.
<?php
class JVersionCompatibility
{
/**
* Class constructor.
*
* @param SimpleXmlElement $node The compatibility node from a manifest file.
*
* @see https://github.com/joomla/joomla-cms/issues/598 for XML specification.
*/
@eddieajau
eddieajau / joomla_components.xml
Created January 27, 2013 23:44
Eclipse snippet category for general purpose Joomla 2.5/3 Component snippets. Includes: * PHP File Header * XML Installation File (Component) * INI File Header * Master Component File * Master Controller * Basic View * Basic Model * Basic View with Toolbar * Basic Controller Display Override * Basic Component Helper * Basic config.xml * Basic ac…
<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<snippets>
<category filters="*" id="category_1275479375591" initial_state="1" label="Joomla Components" largeicon="" smallicon="">
<description><![CDATA[Snippets that support the general needs for any Joomla component.]]></description>
<item category="category_1275479375591" class="" editorclass="" id="item_1275479460203" label="PHP File Header" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
<description><![CDATA[The standard header for a PHP file.]]></description>
<content><![CDATA[<?php
/**
* @version $Id$
* @package ${PACKAGE}
@eddieajau
eddieajau / backend_lists_20130124.xml
Created January 27, 2013 23:58
Eclipse snippet category for backend component lists in Joomla 2.5 (all except view layouts are applicable for Joomla 3.0). Includes: Controller Set Default View, Backend List View, Backend List Layout, Backend List Model, Backend List Layout Search Filter, Backend List Model Search Filters (state), Backend List Model Search Filters (query), Bac…
<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<snippets>
<category filters="*" id="category_1276571415504" initial_state="1" label="Backend Lists" largeicon="" smallicon="">
<description><![CDATA[Snippets specifically for creating backend list views.]]></description>
<item category="category_1276571415504" class="" editorclass="" id="item_1276485904815" label="Controller Set Default View" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
<description><![CDATA[This snippet is intended for the master controller and adds the "default_view" property to class definition. The default view is assumed to be the name of the component (less the com_ prefix). If you want to change the default view then add this snippet.]]></description>
<content><![CDATA[ /**
* @var string The default view.
* @since ${SINCE}
*/
@eddieajau
eddieajau / backend_edit_pages.xml
Created January 28, 2013 00:05
Eclipse snippet category for backend component edit pages in Joomla 2.5 (all except view layouts are applicable for Joomla 3.0). Includes: Backend Item Sub-controller, Backend Item Model, Backend Item XML Form, Backend Item Edit View, backend Item Edit Layout, Backend Item Edit Params Sub-layout, Backend Item Edit Metadata Sub-layout, Backend It…
<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<snippets>
<category filters="*" id="category_1276571442053" initial_state="1" label="Backend Edit Pages" largeicon="" smallicon="">
<description><![CDATA[Snippets specifically for creating backend edit views.]]></description>
<item category="category_1276571442053" class="" editorclass="" id="item_1276505902148" label="Backend Item Subcontroller" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
<description><![CDATA[This snippet adds the basic sub-controller for single item.]]></description>
<content><![CDATA[jimport('joomla.application.component.controllerform');
/**
* ${VIEW} Subcontroller.
@eddieajau
eddieajau / backend_support.xml
Created January 28, 2013 01:18
Eclipse snippet category for backend component support code in Joomla 2.5 (all except CSS should be applicable for Joomla 3.0). Includes: Add submenu method for backend component helper, Add submenu call to master backend controller, Adds a call to JSubMenuHelper that will show a link to the categories view., Text prefix for item subcontroller, …
<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<snippets>
<category filters="*" id="category_1303255935762" initial_state="1" label="Backend Support" largeicon="" smallicon="">
<description><![CDATA[Additional snippets that support backend components.]]></description>
<item category="category_1303255935762" class="" editorclass="" id="item_1303256255316" label="Add submenu method for backend component helper" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
<description><![CDATA[This snippet provides the addSubmenu method that should be added to the backend helper class (usually found in /com_{component}/helpers/{component}.php). One sub-menu entry is provided - copy and paste to suit the number of views that need to be supported. Remember to add the hook into the controller to invoke this method.]]></description>
<content><![CDATA[ /**
* Configure the Linkbar.
*
* @param string $vName The name of