Skip to content

Instantly share code, notes, and snippets.

View jbroadway's full-sized avatar

John de Plume jbroadway

View GitHub Profile
@jbroadway
jbroadway / .htaccess
Last active June 6, 2016 19:14
Elefant CMS Subfolder Proxy
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} \.(js|css)$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . subfolder.php [L]
</IfModule>
@jbroadway
jbroadway / Autoloader.old.php
Created February 1, 2012 19:46
Autoloader testing for Elefant CMS with and without a class map.
<?php
/**
* Elefant CMS - http://www.elefantcms.com/
*
* Copyright (c) 2011 Johnny Broadway
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
@jbroadway
jbroadway / PclZip.php
Created February 2, 2012 19:40
Unzip wrapper around ZipArchive and PclZip for Elefant CMS
<?php
// --------------------------------------------------------------------------------
// PhpConcept Library - Zip Module 2.8.2
// --------------------------------------------------------------------------------
// License GNU/LGPL - Vincent Blavet - August 2009
// http://www.phpconcept.net
// --------------------------------------------------------------------------------
//
// Presentation :
// PclZip is a PHP library that manage ZIP archives.
@jbroadway
jbroadway / Author.php
Created March 29, 2012 23:39
Example custom form validation in Elefant
<?php
class Author extends Model {
public static function unique_name ($value) {
$res = Author::query ()
->where ('first_name', $_POST['first_name'])
->where ('last_name', $_POST['last_name'])
->count ();
if ($res > 0) {
return false;
@jbroadway
jbroadway / forms_test.php
Created April 4, 2012 23:18
Custom validation of an array of values in Elefant framework.
; <?php /*
[name]
callback = validate_array_not_empty
; */ ?>
@jbroadway
jbroadway / conf_embed.php
Created April 8, 2012 21:37
Custom handler for displaying latest blog headlines with dates
; <?php /*
[myapp/headlines]
label = "My App: Latest Posts"
; */ ?>
@jbroadway
jbroadway / galleries.php
Created May 1, 2012 17:26
List several image galleries
<?php
$galleries = glob ('files/galleries/*');
echo '<ul>';
foreach ($galleries as $gallery) {
// list galleries here
echo '<li><a href="/myapp/gallery?path=' . str_replace ('files/', '', $gallery) . '">' . basename ($gallery) . '</a></li>';
}
echo '</ul>';
@jbroadway
jbroadway / fm.html
Created May 2, 2012 05:42
Calling the jwysiwyg file manager in Elefant without the editor
<!-- apps/test/views/fm.html -->
<script>
function filemanager () {
$.wysiwyg.fileManager.init (function (file) {
$('#file').val (file);
});
return false;
}
@jbroadway
jbroadway / URLify.php
Created May 2, 2012 22:29
URLify vs Urlizer
<?php
/**
* A PHP port of URLify.js from the Django project
* (https://github.com/django/django/blob/master/django/contrib/admin/static/admin/js/urlify.js).
* Handles symbols from Latin languages, Greek, Turkish, Russian, Ukrainian,
* Czech, Polish, and Latvian. Symbols it cannot transliterate
* it will simply omit.
*
* Usage:
@jbroadway
jbroadway / URLify.php
Created May 18, 2012 18:34
Illustrating problems with iconv() vs URLify::transliterate() for PHP.
<?php
/**
* A PHP port of URLify.js from the Django project
* (https://github.com/django/django/blob/master/django/contrib/admin/static/admin/js/urlify.js).
* Handles symbols from Latin languages, Greek, Turkish, Russian, Ukrainian,
* Czech, Polish, and Latvian. Symbols it cannot transliterate
* it will simply omit.
*
* Usage: