Skip to content

Instantly share code, notes, and snippets.

@AmyStephen
AmyStephen / articles.sql
Created July 11, 2013 14:07
Joomla Core Query
SELECT a.id, a.title, a.alias, a.introtext, a.checked_out, a.checked_out_time, a.catid, a.created, a.created_by, a.created_by_alias,
CASE WHEN a.modified = '0000-00-00 00:00:00' THEN a.created ELSE a.modified END AS modified, a.modified_by, uam.name AS modified_by_name,
CASE WHEN a.publish_up = '0000-00-00 00:00:00' THEN a.created ELSE a.publish_up END AS publish_up,a.publish_down, a.images, a.urls, a.attribs, a.metadata, a.metakey, a.metadesc, a.access, a.hits, a.xreference, a.featured, LENGTH(a.fulltext) AS readmore,
CASE WHEN badcats.id IS NOT NULL THEN 0 ELSE a.state END AS state,c.title AS category_title, c.path AS category_route, c.access AS category_access, c.alias AS category_alias,
CASE WHEN a.created_by_alias > ' ' THEN a.created_by_alias ELSE ua.name END AS author,ua.email AS author_email,contact.id AS contactid,parent.title AS parent_title, parent.id AS parent_id, parent.path AS parent_route, parent.alias AS parent_alias,ROUND(v.rating_sum / v.rating_count, 0) AS rating
@AmyStephen
AmyStephen / ProcessInput.php
Created July 11, 2013 00:23
System Plugin - onBeforeCompileHead - you can walk through any assets for the head. Where the head is rendered https://github.com/joomla/joomla-cms/blob/9c576378b4809a245f6fcf18bdbbd00baa4f7ac2/libraries/joomla/document/html/renderer/head.php
<?php
public function onBeforeCompileHead()
{
$head = JFactory::getDocument()->getHeadData();
$styleSheets = $head['styleSheets'];
$newStyleSheets = array();
foreach ($styleSheets as $key => $value)
{
@AmyStephen
AmyStephen / Filesystem.md
Last active December 19, 2015 00:58
It's a namespace.
           
| Acme                          
| | Foobar                       
| | | Controller                
| | | | FoobarController     
| | | |                           
| | | Form                       
| | | | FoobarConfigForm.php     
| | | | FoobarForm.php 
@AmyStephen
AmyStephen / Interfaces.md
Last active December 18, 2015 19:09
Molajo Locator Interfaces

Class Loader and Resource Locator

The Molajo Locator is a Resource Locator and Class Loader utilizing URI Namespaces.

Shared code

A class loader and resource locator share a significant amount of code. This shared code includes building namespace and resource maps and searching those structures. Only a small portion of the code is unique. For each type of processing expected by the application (i.e., return a path, read a file, save a Url, etc.), 'handlers' are created and contain minimal code. A ClassLoader handler, for example, simply includes the path and returns.

IoCC/DIC Bootstrap Processing

@AmyStephen
AmyStephen / Problem 1.php
Last active December 18, 2015 16:19
There are two basic issues with PSR-X. https://github.com/php-fig/fig-standards/blob/master/proposed/autoloader.md Neither one turn out to be a real problem. The first issue is only a perception problem. The second, developers can work around outside of an autoloader, if required.
<?php
// Problem 1: Problem only of perception or a Programmer Error.
//
// PSR-X allows the appearance of multiple FQNS to be assigned to a single class file.
// People might be confused and incorrectly assume the following is true.
//
// /path/to/packages/foo-bar/
// src/
// Baz.php # Foo\Bar\Baz
// Qux/
@AmyStephen
AmyStephen / PseudoCode.php
Last active December 18, 2015 00:38
Are there better approaches for accessing the container to request the creation of a dependent class when creating that class?
<?php
//Level 1
class Container implements ContainerInterface
{
public function getService($service, $options = array())
{
// returns class instance if it has been so configured and is available
@AmyStephen
AmyStephen / TheFacadeFooledMe.php
Created May 30, 2013 06:59
I will never get this time back.
<?php
/**
* Get the current value (or default) of the specified key or all User Data for null key
*
* @param null|string $key
* @param null|mixed $default
*
* @return mixed
* @since 1.0
* @throws \Molajo\User\Exception\DataException
@AmyStephen
AmyStephen / 1 Authentication.php
Last active December 17, 2015 21:09
Example of one way to avoid HTML rendering in your class. From https://twitter.com/AmyStephen/status/339777707695030272
<?php
/**
* Generate a token and email a temporary link to change password and sends to user
*
* @param string $session_id
* @param string $username
*
* @return $this|void
* @since 1.0
<?php
class ConfigurationInjector extends CustomInjector implements InjectorInterface
{
/**
* Constructor
*
* @param array $option
*
* @since 1.0
*/
@AmyStephen
AmyStephen / StandardInjector.php
Created May 17, 2013 05:35
Uses Reflection to extract Constructor Parameters
<?php
/**
* Standard Dependency Injector
*
* @package Molajo
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @copyright 2013 Amy Stephen. All rights reserved.
*/
namespace Molajo\IoC\Handler;