Skip to content

Instantly share code, notes, and snippets.

View drmmr763's full-sized avatar

Chad Windnagle drmmr763

View GitHub Profile
@drmmr763
drmmr763 / chapter.php
Created January 6, 2013 21:20
Example of a query that is really badly written that I want to optimize. There are three tables involved: #__rootflick_submissions, #__users, #__rootflick_votes. The votes table is a simple data set which records user_id, the submission_id, and the vote value. Counting the vote values for a submitted_id should give all the votes for that submiss…
<?php
public function getSubmits()
{
$cid = JFactory::getApplication()->input->getInt('cid');
$db = $this->getDbo();
$query = $db->getQuery(true);
$query->select('a.*, i.username');
$query->from('#__rootflick_submissions as a');
@drmmr763
drmmr763 / js.php
Created February 5, 2013 00:48
sample code from an MVC joomla component
<?php
/* Model Code */
class ComponentModelView extends JModelLegacy
{
public function getItem()
{
$id = JFactory::getApplication()->input->getInt('cid');
$row = JTable::getInstance('chapter', 'RootflickTable');
@drmmr763
drmmr763 / rootflickmedia.php
Created February 10, 2013 23:12
Trying to remove directory selector from jform media type.
<?php
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
jimport('joomla.form.forrmfield');
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('media');
class JFormFieldRootflickmedia extends JFormFieldMedia {
@drmmr763
drmmr763 / item.php
Created February 28, 2013 16:15
php k2 template
<?php
/**
* @version $Id: item.php 1251 2011-10-19 17:50:13Z joomlaworks $
* @package K2
* @author JoomlaWorks http://www.joomlaworks.gr
* @copyright Copyright (c) 2006 - 2011 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
@drmmr763
drmmr763 / filterResults.php
Last active December 15, 2015 02:59
removes unmatched objects from an array of objects
<?php
public function filterResults($results)
{
$app = JFactory::getApplication();
$pattern = $app->input->get('filter_id');
// loop through results to remove unwanted results
for ($i = 0; $i <= count($results->entries)+1; $i++)
{
// loop through path way to find matches and remove if not found.
foreach ($results->entries[$i]->path_collection->entries as $result)
@drmmr763
drmmr763 / fail.txt
Created March 27, 2013 21:16
break a linux server
username@art-web-svr-01 images]$ sudo mv /* ../../../../home/username/public_html/images/
[sudo] password for username:
mv: cannot move `/backup' to `../../../../home/username/public_html/images/backup': Device or resource busy
mv: cannot move `/boot' to `../../../../home/username/public_html/images/boot': Device or resource busy
mv: cannot move `/data' to `../../../../home/username/public_html/images/data': Device or resource busy
mv: cannot move `/dev' to `../../../../home/username/public_html/images/dev': Device or resource busy
mv: cannot move `/home' to a subdirectory of itself, `../../../../home/username/public_html/images/home'
mv: cannot move `/misc' to `../../../../home/username/public_html/images/misc': Device or resource busy
mv: cannot move `/net' to `../../../../home/username/public_html/images/net': Device or resource busy
mv: cannot move `/proc' to `../../../../home/username/public_html/images/proc': Device or resource busy
@drmmr763
drmmr763 / oauth.php
Created April 1, 2013 03:18
working on a simple oauth2 app
<?php
session_start();
// define Joomla's framework path
// get bootstrap
require dirname(dirname(dirname(__FILE__))).'/bootstrap.php';
// Increase error reporting to that any errors are displayed.
// Note, you would not use these settings in production.
@drmmr763
drmmr763 / details.xsl
Last active December 16, 2015 06:39
Example of how to use PHP functions in template.php in sobipro template
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl">
<xsl:template match="/entry_details">
<xsl:output method="xml" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>
<xsl:variable name="title"><xsl:value-of select="entry/name" /></xsl:variable>
<h1><xsl:value-of select="php:function('RanchBrokers::PrettyTitle', $title)" disable-output-escaping="yes"/></h1>
</xsl:template>
</xsl:stylesheet>
<xsl:variable name="identifier"><xsl:value-of select="field_identifier" /></xsl:variable>
<h1><xsl:value-of select="php:function('Restaurant::getRestaruantData', $identifier)" disable-output-escaping="yes"/></h1>
@drmmr763
drmmr763 / helper.php
Created April 22, 2013 20:24
Little php based recursion function for putting together a list of folders in html.
<?php
/*
** recursive function which builds child / parent option list of
** select list options
*/
public function getSubfoldersList($parent_id)
{
$model = new BoxsearchModelBoxsearch();
$subfolders = $model->getSubFolders($parent_id);