Skip to content

Instantly share code, notes, and snippets.

<?php
namespace Nette\Caching;
use Nette;
/**
* APC caching storage
* @author Michael Moravec
*/
@redhead
redhead / live-form-validation.js
Created August 26, 2010 21:16
Live Form Validation for Nette 2.0
/**
* Live Form Validation for Nette 2.0
*
* @author Radek Ježdík, MartyIX, David Grudl
*/
var LiveForm = {
options: {
controlErrorClass: 'form-control-error', // CSS class for an invalid control
errorMessageClass: 'form-error-message', // CSS class for an error message
@fprochazka
fprochazka / ApplicationLock.php
Created November 23, 2010 18:14
Zámek aplikace
<?php
namespace Kdyby\Security;
use Nette;
use Kdyby;
/**
* Globální zámek pro aplikaci, vyžaduje auth handler, ideálně napojit http_authentication
@fprochazka
fprochazka / ModelTools.php
Created November 26, 2010 17:51
Cachování metod
<?php
namespace Kdyby\Tools;
use Nette;
use Nette\Environment;
use Nette\ObjectMixin;
use Kdyby;
@Mikulas
Mikulas / GravatarPresenter.php
Created December 5, 2010 13:59
Gravatar cache for nette
<?php
class GravatarPresenter extends \Nette\Application\UI\Presenter
{
public function actionDefault($email, $size = 80)
{
$this->sendResponse(new GravatarResponse($email, $size));
}
}
@alexdunae
alexdunae / wordpress_custom_post_gallery.php
Created March 31, 2011 23:55
Display a custom post type's media library inline on the WordPress edit page screen
<?php
define('MY_POST_TYPE', 'my');
define('MY_POST_SLUG', 'gallery');
function my_register_post_type () {
$args = array (
'label' => 'Gallery',
'supports' => array( 'title', 'excerpt' ),
'register_meta_box_cb' => 'my_meta_box_cb',
@fprochazka
fprochazka / whereCalled.php
Created April 12, 2011 11:05
Shows where was method called
<?php
function wc($level = 1) {
if (\Nette\Debug::$productionMode) { return; }
$o = function ($t) { return (isset($t->class) ? htmlspecialchars($t->class) . "->" : NULL) . htmlspecialchars($t->function) . '()'; };
$f = function ($t) {
$file = defined('APP_DIR') ? 'app' . str_replace(realpath(APP_DIR), '', realpath($t->file)) : $t->file;
return '<a href="' . \Nette\DebugHelpers::editorLink($t->file, $t->line) . '">' . htmlspecialchars($file) . ':' . (int)$t->line . '</a>';
};
@fprochazka
fprochazka / BasePresenter.php
Created April 14, 2011 12:14 — forked from PJK/BasePresenter.php
TwigMacro
<?php
public function templatePrepareFilters($template) {
$template->registerFilter($latte = new Nette\Templates\LatteFilter());
TwigMacro::register($latte->getHandler());
}
@fprochazka
fprochazka / BaseModel.php
Created May 17, 2011 08:30
Psáno na aktuální Nette (master - 50c3c40)
<?php
abstract class BaseModel extends Nette\Object
{
/** @var NotORM */
protected $connection;
/**
/**
* Beta
*
* Sibling of netteForms.js "rewritten to jQuery"
* @author Pavel Kučera
* @author David Grudl author of netteForms.js, of the idea and the one who I copied from
*
* Disclaimer: I'm not a javascript programmer, actually I hate javascript, so consider that please if you want to complain about quality of this utility.
*
* Dependencies