Пример #1
0
 /**
  * A widget for containing/structuring other widgets (div)
  * @param string $id The HTML #id of the box
  * @param string $class The HTML .class of box
  * @param HtmlAttributes $args Allows custom html tag arguments to be specified (not recommended)
  **/
 public function __construct($id = null, $class = null, $args = null)
 {
     HtmlAttributes::Assure($args);
     $args->Add('id', $id);
     $args->Add('class', $class);
     parent::__construct('div', $args);
 }
Пример #2
0
 /**
  * A widget containing a menu
  * @param string $id The HTML #id of the element
  * @param string $class The HTML .class of element
  * @param string[][] $links The links in the menu
  * @param string $selected The title of the selected item in the menu
  * @param HtmlAttributes $args Allows custom html tag arguments to be specified (not recommended)
  **/
 public function __construct($id, $class, $links, $selected = null, $args = null)
 {
     HtmlAttributes::Assure($args);
     $args->Add('id', $id);
     $args->Add('class', $class);
     $url = $title = null;
     $items = array();
     foreach ($links as $link) {
         if (_array::IsLongerThan($link, 1)) {
             $url = $link[0];
             $title = $link[1];
         } else {
             $url = $title = $link;
         }
         $linkargs = null;
         $forcehttps = false;
         if (_string::StartsWith($title, '_')) {
             $title = _string::RemovePrefix($title, '_');
             $forcehttps = true;
         }
         if ($selected != null && $selected == $title) {
             $linkargs = array('selected' => true);
         }
         $items[] = new RTK_Link($url, $title, $forcehttps, $linkargs);
     }
     parent::__construct($items, $args);
 }
Пример #3
0
 /**
  * A widget for displaying a list of items
  * @param string[] $columnheaders The headers in the top row
  * @param boolean $alternaterow Determines if different styling should be applied to every other row
  * @param boolean $alternatecell Determines if different styling should be applied to every other cell
  * @param HtmlAttributes $args Allows custom html tag arguments to be specified (not recommended)
  **/
 public function __construct($columnheaders, $alternaterow = true, $alternatecell = false, $args = null)
 {
     HtmlAttributes::Assure($args);
     $args->Add('class', 'listview', false);
     parent::__construct();
     $this->AddContainer(new HtmlElement('div', $args, EMPTYSTRING, new HtmlElement('table')), 'table');
     //$this->SetPointer('table');
     if ($alternaterow == false) {
         $this->_alternaterow = null;
     } else {
         $this->_alternaterow = true;
     }
     if ($alternatecell == false) {
         $this->_alternatecell = null;
     } else {
         $this->_alternatecell = true;
     }
     if (sizeof($columnheaders) > 0) {
         for ($i = 0; $i < sizeof($columnheaders); $i++) {
             $string = $columnheaders[$i];
             if (is_string($string) && strlen($string) > 0 && $string[0] == '_') {
                 $this->_compressedcols[] = $i;
                 $columnheaders[$i] = substr($columnheaders[$i], 1);
             }
         }
         $this->AddHeader($columnheaders);
     }
 }
Пример #4
0
 /**
  * A widget for displaying an image (img)
  * @param string $imgurl The url of the image
  * @param string $alttext A text that will be shown if the image could not be loaded
  * @param boolean $forcehttps Specify if the link has to have https 
  * @param HtmlAttributes $args Allows custom html tag arguments to be specified (not recommended)
  **/
 public function __construct($imgurl = EMPTYSTRING, $alttext = EMPTYSTRING, $args = null)
 {
     HtmlAttributes::Assure($args);
     $args->Add('src', $imgurl, true);
     $args->Add('alt', $alttext, true);
     parent::__construct();
     $this->AddChild(new HtmlElement('img', $args));
 }
Пример #5
0
 /**
  * A button widget
  * @param string $name The name/id of the button
  * @param string $title The text written on the button
  * @param HtmlAttributes $args Allows custom html tag arguments to be specified (not recommended)
  **/
 public function __construct($name = 'submit', $title = 'Submit', $args = null)
 {
     HtmlAttributes::Assure($args);
     $args->Add('type', 'submit', false);
     $args->Add('name', $name, false);
     $args->Add('class', 'submit', false);
     $args->Add('value', $title, false);
     parent::__construct('input', $args);
 }
Пример #6
0
 /**
  * A widget containing text (essentially just a div or span with text)
  * @param string $text The text to display
  * @param boolean $inline Determines if the widget should be span(true) or div(false)
  * @param string $id The HTML #id of the element
  * @param string $class The HTML .class of element
  * @param HtmlAttributes $args Allows custom html tag arguments to be specified (not recommended)
  **/
 public function __construct($text = EMPTYSTRING, $inline = false, $id = null, $class = null, $args = null)
 {
     HtmlAttributes::Assure($args);
     if (Value::SetAndNotNull($id)) {
         $args->Add('id', $id);
     }
     if (Value::SetAndNotNull($class)) {
         $args->Add('class', $class);
     }
     $tag = $inline ? 'span' : 'div';
     parent::__construct($tag, $args, $text);
 }
Пример #7
0
 /**
  * A widget containing a user input form
  * @param string $name The HTML #id and name of the element
  * @param string $action The url that should handle the request (leave blank for current page)
  * @param string $method POST or GET
  * @param boolean $usetoken Includes a security token on all forms, pass false to opt out (not recommended)
  * @param HtmlAttributes $args Allows custom html tag arguments to be specified (not recommended)
  **/
 public function __construct($name = EMPTYSTRING, $action = EMPTYSTRING, $method = 'POST', $usetoken = true, $args = null)
 {
     HtmlAttributes::Assure($args);
     $args->Add('name', $name);
     $args->Add('id', $name);
     $args->Add('action', $action);
     $args->Add('method', $method);
     parent::__construct('form', $args);
     if ($usetoken) {
         $this->AddHiddenField('securitytoken', Site::CreateSecurityToken());
     }
     $this->_containers = array();
 }
Пример #8
0
 /**
  * A widget containing the links to different pages for a common URL
  * @param string $baseurl The base part of the URL that all links in the paginition shares
  * @param integer $amount The amount of items to divide into pages
  * @param integer $perpage The amount of items per page
  * @param HtmlAttributes $args Allows custom html tag arguments to be specified (not recommended)
  **/
 public function __construct($baseurl, $amount, $perpage, $page, $args = null)
 {
     HtmlAttributes::Assure($args);
     $args->Add('class', 'pagination', false);
     if ($amount > $perpage || PAGINATIONSHOWEMPTY) {
         parent::__construct('ul', $args);
         $firstpage = 1;
         $lastpage = ceil($amount / $perpage);
         $lowerlimit = $page - PAGINATIONLINKS;
         $upperlimit = $page + PAGINATIONLINKS;
         $nolink = new HtmlElement('li', EMPTYSTRING, '&nbsp;');
         // First, previous
         if ($page > $firstpage) {
             $this->AddChild(new HtmlElement('li', EMPTYSTRING, EMPTYSTRING, new HtmlElement('a', array('href' => $baseurl . $firstpage . SINGLESLASH), PAGINATIONFIRST)));
             $this->AddChild(new HtmlElement('li', EMPTYSTRING, EMPTYSTRING, new HtmlElement('a', array('href' => $baseurl . ($page - 1) . SINGLESLASH), PAGINATIONPREV)));
         } else {
             $this->AddChild($nolink);
             $this->AddChild($nolink);
         }
         // Available page numbers
         for ($i = $lowerlimit; $i <= $upperlimit; $i++) {
             if ($i == $page) {
                 $this->AddChild(new HtmlElement('li', array('class' => 'current'), $page));
             } elseif ($i >= $firstpage && $i <= $lastpage) {
                 $this->AddChild(new HtmlElement('li', EMPTYSTRING, EMPTYSTRING, new HtmlElement('a', array('href' => $baseurl . $i . SINGLESLASH), $i)));
             } else {
                 $this->AddChild($nolink);
             }
         }
         // Next Page, Last Page
         if ($page < $lastpage) {
             $this->AddChild(new HtmlElement('li', EMPTYSTRING, EMPTYSTRING, new HtmlElement('a', array('href' => $baseurl . ($page + 1) . SINGLESLASH), PAGINATIONNEXT)));
             $this->AddChild(new HtmlElement('li', EMPTYSTRING, EMPTYSTRING, new HtmlElement('a', array('href' => $baseurl . $lastpage . SINGLESLASH), PAGINATIONLAST)));
         } else {
             $this->AddChild($nolink);
             $this->AddChild($nolink);
         }
     } else {
         parent::__construct();
     }
 }
Пример #9
0
 /**
  * A widget containing a clickable link (a)
  * @param string $url The url of the link
  * @param string $name The title of the list
  * @param boolean $forcehttps Specify if the link has to have https
  * @param HtmlAttributes $args Allows custom html tag arguments to be specified (not recommended)
  **/
 public function __construct($url = EMPTYSTRING, $name = EMPTYSTRING, $forcehttps = false, $args = null)
 {
     HtmlAttributes::Assure($args);
     $args->Add('href', Site::GetBaseURL($forcehttps) . $url);
     parent::__construct('a', $args, $name);
 }
Пример #10
0
 /**
  * Adds a javascript to the HTML document
  * @param string $filename The name of the file to add
  * @param HtmlAttributes $args Allows custom html tag arguments to be specified (not recommended)
  */
 public function AddJavascript($filename, $args = null)
 {
     HtmlAttributes::Assure($args);
     $args->Add('src', $filename);
     $this->_javascripts[$filename] = new HtmlElement('script', $args);
 }