Skip to content

Instantly share code, notes, and snippets.

View fprochazka's full-sized avatar
🏠
Working from home

Filip Procházka fprochazka

🏠
Working from home
View GitHub Profile
<?php
private function getExtension($name)
{
if( !isset($this->extensions[$name]) ){
$classes = array_keys($this->getRobotLoader()->indexedClasses);
foreach( $classes AS $item ){ //echo "<hr>"; _dump($item);
if( $match = String::match($item, '~^kdyby\\\\(?P<type>modifications|addons)\\\\(?P<name>[^\\\\]+)\\\\loader$~i') ){
@fprochazka
fprochazka / FormMacros.php
Created August 14, 2010 23:25 — forked from janmarek/FormMacros.php
FormMacros
<?php
namespace Nette\Templates;
use Nette\Forms\Form;
use Nette\String;
/**
* Form macros
*
<?php
if( !function_exists('mime_type_check') ){
function mime_type_check($path)
{
if( function_exists('mime_content_type') )
return mime_content_type($path);
else
return 'undefined/unknown';
}
<?php
class CallbackBody extends Callback
{
public function __construct($paramList, $code, $param1 = null, $param2 = null, $param3 = null)
{
$params = func_get_args();
$params = array_slice($params, 2);
$this->callback = create_function($paramList, $code);
$this->params = $params;
<?php
namespace NetteExtras\Forms;
class ChangeTracker extends \Nette\Forms\HiddenField
{
private $session;
private $modifiedValues;
{foreach $blocks as $block}<div {attr id($block->id) class($block->classes)} n:tag-if="$block->hasContainer">
{foreach $block->components as $component}
{control $component->name:$component->render, $component->params}
{/foreach}
</div>{/foreach}
<?php
public function getPersistentDefaults()
{
$defaults = array();
foreach ($this->getReflection()->getPersistentParams() as $nm => $meta)
$defaults[$nm] = $meta['def'];
}
return $defaults;
<?php
// new movie
$movie = new Entities\Movie;
$movie->name = 'Pulp Fiction';
// new director
$movie->director = new Entities\Director;
$movie->director->name = 'Quentin Tarantino';
<?php
class UglyComponentPointer implements \Nette\IComponent, \ArrayAccess
{
/** @var \Nette\Component */
private $pointer;
private $noesark = array();
@fprochazka
fprochazka / BasePresenter.php
Created October 8, 2010 09:30
Automatické načítání formulářů
<?php
namespace Kdyby\Presenter;
abstract class Base extends \Nette\Application\Presenter
{
// ...