Importing bits and pieces
This is the initial import based on a few files I had around.
This commit is contained in:
commit
871d28cd16
20 changed files with 1994 additions and 0 deletions
includes/box
6
includes/box/package.inc.php
Normal file
6
includes/box/package.inc.php
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
$package[ 'requires' ][] = 'core';
|
||||
$package[ 'files' ][] = 'view';
|
||||
$package[ 'views' ][] = 'box';
|
||||
$package[ 'extras' ][] = 'BoxButton';
|
124
includes/box/view.inc.php
Normal file
124
includes/box/view.inc.php
Normal file
|
@ -0,0 +1,124 @@
|
|||
<?php
|
||||
|
||||
class BoxButton
|
||||
{
|
||||
protected $title;
|
||||
protected $URL;
|
||||
protected $id;
|
||||
protected $class;
|
||||
protected $style;
|
||||
|
||||
protected function __construct( $title , $URL )
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->URL = $URL;
|
||||
}
|
||||
|
||||
public function setID( $id )
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setClass( $class )
|
||||
{
|
||||
$this->class = $class;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setStyle( $style )
|
||||
{
|
||||
$this->style = $style;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render( )
|
||||
{
|
||||
return HTML::make( 'a' )
|
||||
->setAttribute( 'title' , HTML::from( $this->title ) )
|
||||
->setAttribute( 'href' , $this->URL )
|
||||
->setAttribute( 'class' ,
|
||||
'box-button' . ( ( $this->class === null )
|
||||
? '' : ( ' ' . $this->class ) ) )
|
||||
->setAttribute( 'style' , $this->style )
|
||||
->setAttribute( 'id' , $this->id )
|
||||
->appendElement( HTML::make( 'span' )
|
||||
->appendText( $this->title ) );
|
||||
}
|
||||
|
||||
|
||||
public static function create( $title , $URL )
|
||||
{
|
||||
return new BoxButton( $title , $URL );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final class View_Box
|
||||
implements View
|
||||
{
|
||||
protected $title;
|
||||
protected $class;
|
||||
protected $id;
|
||||
|
||||
protected $buttons = array( );
|
||||
protected $contents;
|
||||
|
||||
|
||||
public function __construct( $title , View $contents )
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->contents = $contents;
|
||||
}
|
||||
|
||||
|
||||
public function setClass( $class )
|
||||
{
|
||||
$this->class = $class;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function setID( $id )
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function addButton( BoxButton $button )
|
||||
{
|
||||
array_push( $this->buttons , $button );
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function render( )
|
||||
{
|
||||
$box = HTML::make( 'div' )
|
||||
->setAttribute( 'class' , 'box' . ( is_null( $this->class ) ? '' : " {$this->class}" ) )
|
||||
->setAttribute( 'id' , $this->id )
|
||||
->appendText( "\n" );
|
||||
|
||||
if ( ! is_null( $this->title ) ) {
|
||||
$box->appendElement( HTML::make( 'h2' )
|
||||
->setAttribute( 'class' , 'box-title' )
|
||||
->appendText( $this->title ) );
|
||||
}
|
||||
|
||||
if ( ! empty( $this->buttons )) {
|
||||
$buttons = HTML::make( 'div' )
|
||||
->setAttribute( 'class' , 'box-buttons' );
|
||||
foreach ( $this->buttons as $button ) {
|
||||
$buttons->appendElement( $button->render( ) );
|
||||
}
|
||||
$box->appendElement( $buttons );
|
||||
}
|
||||
|
||||
$box->appendElement( HTML::make( 'div' )
|
||||
->setAttribute( 'class' , 'box-contents' )
|
||||
->append( $this->contents->render( ) ) );
|
||||
|
||||
return $box;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue