Skip to content

Instantly share code, notes, and snippets.

@nickweavers
nickweavers / gist:9940340
Created April 2, 2014 18:38
A view/tmpl file to show send a files contents to the browser with appropriate headers
<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
header("Cache- Control: no-cache, must-revalidate" ); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
$doc = $this->archivingModel->getFile($this->form_data['id_file']);
$file_type = $doc->content_type;
$content_body = $doc->content_body;
header("Content-Type: " . $file_type);
@nickweavers
nickweavers / gist:9939652
Last active August 29, 2015 13:58
A Joomla model that gets a file from RackSpace's cloud
function getFile($id_file) {
$fileRecord = $this->getFileRecord($id_file);
$client = new Rackspace(Rackspace::UK_IDENTITY_ENDPOINT, array( // Note the use of
'username' => USER,
'apiKey' => PSWD
));
// Create a service object to use the object store service. We give it the region name on LON (For London) as this is where are server and cloud files are
<?php
/**
* A test vehicle to allow myself to learn the new RackSpace OpenCloud PHP SDK
*
*/
// include the Rackspace Cloud files PHP API
require 'rackspace_config.php';
require 'libraries/rackspace/vendor/autoload.php';
use OpenCloud\Rackspace;
@nickweavers
nickweavers / tabbed menu page
Created June 24, 2011 19:37
tabbed menu page using YUI3
/**
* This javascript program is used on the Seller Form to create a tabbed menu above a content div.
* The menu consists of a div for each tab with a link inside to capture the click. The click is used
* to send an http request for page content that corresponds to the tab.
*/
YUI({
// we must tell the autoloader to get code from our server as we are using https
base: 'libraries/js/yui_3.3.0/build/', timeout: 10000
YUI({
// we must tell the autoloader to get code from our server as we are using https
base: 'templates/dealdirect/js/yui_3.0.0/yui/build/', timeout: 10000
}).use('event', 'node', 'io-base', 'node-event-simulate', function(Y) {
Y.on('domready', clickListener);
function clickListener() {
(
function buildEmployeePanel() {
Ext.namespace('NS1');
NS1.currentlySelectedEmployeeID = '';
NS1.currentlySelectedPersonID = '';
// editConfig
// -------------------------------------------------------------------------------------------------------------
// Create an array variable called employeeSelectorFields holding the variable mapping used by
// employeeSelectorStore
// -------------------------------------------------------------------------------------------------------------
( function() {
// byEvent
// -------------------------------------------------------------------------------------------------------------
// Create an array variable called eventFields holding the variable mapping used by eventStore
// -------------------------------------------------------------------------------------------------------------
var eventFields = [
{name: 'id_booking', type: 'string', mapping: 'id_booking'},
{name: 'id_booking_ref', type: 'string', mapping: 'id_booking'},
{name: 'id_event', type: 'string', mapping: 'id_event'},
{name: 'id_event_ref', type: 'string', mapping: 'id_event'},
<?php
/**
* @copyright Copyright (C) 2009 - 2012 SiteWeavers. All rights reserved.
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" >
(function() {
var personFields = [
{name: 'id_person', type: 'string', mapping: 'id_person'},
{name: 'id_person_ref', type: 'string', mapping: 'id_person'},
{name: 'first_name', type: 'string', mapping: 'first_name'},
{name: 'initials', type: 'string', mapping: 'initials'},
{name: 'last_name', type: 'string', mapping: 'last_name'},
{name: 'id_title', type: 'string', mapping: 'id_title'},
{name: 'title', type: 'string', mapping: 'title'},
<?php
$path = 'phploader/phploader/loader.php';
if (file_exists($path)) {
require_once $path;
$loader = new YAHOO_util_Loader("3.0.0");
$loader->base = "templates/".$this->template."/js/yui_3.0.0/";
//Specify YUI components to load
$loader->load("yui", "dom", "event", "event-resize");
//Output the tags (this call would most likely be placed in the document head
$css = $loader->css();