Skip to content

Instantly share code, notes, and snippets.

View Twista's full-sized avatar
😺
:q!

Michal Haták Twista

😺
:q!
View GitHub Profile
@Twista
Twista / bootstrap.php
Created September 6, 2012 06:51
nette/app/bootstrap.php
<?php
/**
* My Application bootstrap file.
*/
use Nette\Application\Routers\Route,
Nette\Application\Routers\SimpleRouter;
// Load Nette Framework
<?php
class Test {
protected $a; // set called
public $b; // nothing
public $c = 1; // nothing
public function __set($name, $value){
echo 'set called';
}
@Twista
Twista / gist:4007907
Created November 3, 2012 17:01
SitesGrid
<?php
/**
* Description of SitesGrid
*
* @author Michal Haták [Twista] <me@twista.cz>
* @package cms
*/
class SitesGrid extends Nette\Application\UI\Control {
@Twista
Twista / Presenter.php
Created November 3, 2012 17:18
SitesGrid
public function createComponentGrid() {
$grid = new SitesGrid($this->repo);
return $grid;
}
@Twista
Twista / gist:4011755
Created November 4, 2012 12:44
filtrovani
if(preg_match_all('~filtr_([0-9]+)~', implode(' ', array_keys($_POST)) ,$out)){
if(isset($out[1])){
$filtrIds = array();
foreach (array_values($out[1]) as $value) {
$filtrIds[] = preklicuj_pole_podle_dat($base->data_out('id_produkt','sprava_produktu_filtrovani_vazby_'.LAN,'id_filtr = '.$value.' AND hodnota = '.$_POST['filtr_'.$value].'','id_produkt'),'id_produkt');
}
}
$numOfFilters = count(array_keys($filtrIds));
$queryArr = array();
for ($i=0; $i < $numOfFilters; $i++) {
@Twista
Twista / gist:4030134
Created November 7, 2012 08:09
exampleTest
class ExampleTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
}
public function testHelloWorld()
{
$this->assertEquals("hello", funkceCoVRACIHello()); // true
<?php
class PropertyAccess implements \ArrayAccess {
public function offsetSet($offset, $value) {
if(isset($this->offset))
$this->offset = $value;
}
public function offsetExists($offset) {
@Twista
Twista / phpunit.sublime-build
Created November 9, 2012 00:00
phpunit sublime text 2 build
{
"cmd": ["phpunit", "-c","${project:${folder}}/phpunit.xml"],
"encoding" : "utf-8",
"selector" : "source.php",
"shell" : true,
"working_dir": "${project_path:${folder}}"
}
@Twista
Twista / Site.php
Created November 22, 2012 12:32
Site Model
<?php
/**
* Description of site
*
* @author Michal Haták [Twista] <me@twista.cz>
* @package cms
*/
class Site extends Nette\Object {
@Twista
Twista / gist:4140061
Created November 24, 2012 15:11
generovani entity
/**
* constructor
* @param Nette\Database\Table\ActiveRow $row
*/
public function __construct(Nette\Database\Table\ActiveRow $row) {
foreach ($row as $key => $value) {
if (property_exists($this,$key))
$this->{$key} = $value;
}
}