This repository has been archived by the owner on Sep 13, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
333 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
/** | ||
* Application/plugin/ItemThumbnail/hook.php | ||
* | ||
* @author Matthijs van Henten <matthijs@ischen.nl> | ||
* @package default | ||
*/ | ||
|
||
|
||
@list( , $controller, $action, $item_id ) = $request->pathParts; | ||
?> | ||
|
||
<?php | ||
if ( $start ) { | ||
Nano_Autoloader::registerNamespace( 'Builder', dirname(__FILE__) ); | ||
$this->router->prepend( '/admin/plugin/thumb/\w+(/\d+)?', 'ItemThumb_Plugin' ); | ||
} | ||
?> | ||
|
||
<?php if ( $end ): ?> | ||
<?php endif; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
/** | ||
* Application/plugin/Builder/lib/Abc.php | ||
* | ||
* @author Matthijs van Henten <matthijs@ischen.nl> | ||
* @package Pico | ||
*/ | ||
|
||
|
||
abstract class Builder_Abc { | ||
private $_constructor_args; | ||
|
||
|
||
|
||
/** | ||
* | ||
* | ||
* @param unknown $args | ||
*/ | ||
public function __construct( $args ) { | ||
$this->_constructor_args = $args; //func_get_args(); | ||
} | ||
|
||
|
||
|
||
/** | ||
* | ||
* | ||
* @return unknown | ||
*/ | ||
public function __toString() { | ||
return $this->as_string(); | ||
} | ||
|
||
|
||
/** | ||
* | ||
* | ||
* @param unknown $name | ||
* @return unknown | ||
*/ | ||
public function __get( $name ) { | ||
if ( ($property = "_$name") | ||
&& (isset($this->$property) || property_exists( $this, $property ))) { | ||
if ( ! isset( $this->$property ) | ||
&& method_exists( $this, "_build_$property" ) ) { | ||
$method = "_build_$property"; | ||
$this->$property = $this->$method(); | ||
} | ||
return $this->$property; | ||
} | ||
} | ||
|
||
|
||
|
||
/** | ||
* | ||
* | ||
* @param unknown $name | ||
* @return unknown | ||
*/ | ||
public function arg( $name ) { | ||
if ( isset( $this->_constructor_args[$name] ) ) { | ||
return $this->_constructor_args[$name]; | ||
} | ||
|
||
return array(); | ||
} | ||
|
||
|
||
|
||
/** | ||
* | ||
* | ||
* @param unknown $args | ||
* @return unknown | ||
*/ | ||
public function element( $args ) { | ||
$args = array_merge( array( 'type' => 'div', 'attributes' => array() ), $args ); | ||
|
||
return new Nano_Element( $args['type'], $args['attributes']); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
/** | ||
* Application/plugin/Builder/lib/Block.php | ||
* | ||
* @author Matthijs van Henten <matthijs@ischen.nl> | ||
* @package Pico | ||
*/ | ||
|
||
|
||
class Builder_Block extends Builder_Abc { | ||
|
||
protected $_element; | ||
|
||
|
||
|
||
/** | ||
* | ||
* | ||
* @return unknown | ||
*/ | ||
public function as_string() { | ||
return (string) $this->element; | ||
} | ||
|
||
|
||
|
||
/** | ||
* | ||
* | ||
* @return unknown | ||
*/ | ||
protected function _build__element() { | ||
$div = new Nano_Element( 'div' ); | ||
$div->setVertile(); | ||
|
||
return $div; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
/** | ||
* Application/plugin/Builder/lib/Page.php | ||
* | ||
* @author Matthijs van Henten <matthijs@ischen.nl> | ||
* @package Pico | ||
*/ | ||
|
||
|
||
class Builder_Page extends Builder_Abc { | ||
protected $_doctype = 'html'; | ||
|
||
protected $_html; | ||
protected $_body; | ||
protected $_head; | ||
|
||
|
||
//$builder = new Builder_Page(array( | ||
// 'head' => array( | ||
// 'children' => array( | ||
// 'type' => 'link', | ||
// 'attibutes' => array( | ||
// 'href' => 'style.css', | ||
// 'rel' => 'stylesheet', | ||
// ) | ||
// ) | ||
// ), | ||
// 'children' => array( | ||
// array( | ||
// 'type' => 'block', | ||
// ) | ||
// ) | ||
//)); | ||
|
||
|
||
/** | ||
* | ||
* | ||
* @return unknown | ||
*/ | ||
public function as_string() { | ||
$doctype = sprintf('<!DOCTYPE %s>', $this->doctype ); | ||
|
||
return join( "\n", array( $doctype, $this->html ) ); | ||
} | ||
|
||
|
||
|
||
/** | ||
* | ||
* | ||
* @return unknown | ||
*/ | ||
protected function _build__html() { | ||
$html = new Nano_Element( 'html' ); | ||
$html->addChild( $this->head ); | ||
$html->addChild( $this->body ); | ||
|
||
return $html; | ||
} | ||
|
||
|
||
|
||
/** | ||
* | ||
* | ||
* @return unknown | ||
*/ | ||
protected function _build__head() { | ||
$head = new Nano_Element( 'head' ); | ||
$head->setVertile(); | ||
|
||
$args = $this->arg('head'); | ||
|
||
if ( isset( $args['children'] ) ) { | ||
foreach ( $args['children'] as $child ) { | ||
$head->addChild( $this->element( $child )) ; | ||
} | ||
} | ||
|
||
return $head; | ||
} | ||
|
||
|
||
|
||
/** | ||
* | ||
* | ||
* @return unknown | ||
*/ | ||
protected function _build__body() { | ||
$body = new Nano_Element( 'body' ); | ||
$body->setVertile(); | ||
|
||
return $body; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
/** | ||
* Application/plugin/Builder/t/Block.php | ||
* | ||
* @author Matthijs van Henten <matthijs@ischen.nl> | ||
* @package Pico | ||
*/ | ||
|
||
|
||
class Builder_PageTest extends PHPUnit_Framework_TestCase{ | ||
private $config; | ||
|
||
/** | ||
* | ||
*/ | ||
protected function setUp() { | ||
require_once dirname(dirname(__FILE__)) . '/../Nano/library/Nano/Autoloader.php'; | ||
Nano_Autoloader::register(); | ||
Nano_Autoloader::registerNamespace( 'Builder', dirname(__FILE__) . '/../lib' ); | ||
} | ||
|
||
|
||
|
||
/** | ||
* | ||
*/ | ||
public function testStringify() { | ||
$builder = new Builder_Block(); | ||
$expect = ' <div> | ||
</div> | ||
'; | ||
|
||
$this->assertEquals($expect, (string) $builder ); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
/** | ||
* Application/plugin/Builder/t/Page.php | ||
* | ||
* @author Matthijs van Henten <matthijs@ischen.nl> | ||
* @package Pico | ||
*/ | ||
|
||
|
||
class Builder_PageTest extends PHPUnit_Framework_TestCase{ | ||
private $config; | ||
|
||
/** | ||
* | ||
*/ | ||
protected function setUp() { | ||
require_once dirname(dirname(__FILE__)) . '/../Nano/library/Nano/Autoloader.php'; | ||
Nano_Autoloader::register(); | ||
Nano_Autoloader::registerNamespace( 'Builder', dirname(__FILE__) . '/../lib' ); | ||
} | ||
|
||
|
||
|
||
/** | ||
* | ||
*/ | ||
public function testSmoke() { | ||
$builder = new Builder_Page(array( | ||
'head' => array( | ||
'children' => array( | ||
array( | ||
'type' => 'link', | ||
'attributes' => array( | ||
'href' => 'style.css', | ||
'rel' => 'stylesheet', | ||
)) | ||
) | ||
), | ||
'children' => array( | ||
array( | ||
'type' => 'block', | ||
) | ||
) | ||
)); | ||
|
||
echo $builder; | ||
} | ||
|
||
|
||
} |