コード例 #1
0
ファイル: formline.php プロジェクト: iensenfirippu/RTK
 /**
  * A widget containing a line of user inputs for a form element
  * @param string $name The HTML name (and #id) of the input element(s) and label
  * @param string $title The text written next to the input element(s)
  * @param string $inputs The input element(s) for the form line
  **/
 public function __construct($name, $title, $inputs)
 {
     parent::__construct('div', array('class' => 'formline'));
     // Add the label
     $this->AddContainer(new HtmlElement('label', array('for' => $name), $title), 'LABEL');
     // Create the input group
     $group = new HtmlElement('div', array('class' => 'formgroup'));
     if (is_a($inputs, 'HtmlElement')) {
         $group->AddChild($inputs);
     } elseif (RTK::ArrayIsLongerThan($array, 0)) {
         foreach ($inputs as $input) {
             if (is_a($input, 'HtmlElement')) {
                 $group->AddChild($input);
             }
         }
     }
     $this->AddContainer($group, 'GROUP');
     // Add the error section
     $this->AddContainer(new HtmlElement(), 'ERROR');
 }
コード例 #2
0
ファイル: commentview.php プロジェクト: iensenfirippu/RTK
 /**
  * Recursively traverses the tree of comments and builds the markup accordingly
  * @param HtmlElement $box the box to put the resulting markup into
  * @param Comment[] $comments the comments for the current recursion
  **/
 private function TraverseComment(&$box, $comments)
 {
     if (sizeof($comments) > 0) {
         foreach ($comments as $comment) {
             if (is_a($comment, 'Comment')) {
                 $args = null;
                 if (Login::IsLoggedIn()) {
                     $args = array('onclick' => 'SelectComment(' . $comment->GetId() . ')');
                 }
                 $childbox = new RTK_Box($comment->GetId(), 'comment');
                 $infobox = new RTK_Box($comment->GetId(), 'commentinfo', $args);
                 $infobox->AddChild(new RTK_Textview($comment->GetUser()->GetUserName() . ':', true, null, 'commentposter'));
                 $infobox->AddChild(new RTK_Textview($comment->GetContents(), true, null, 'commentmessage'));
                 $infobox->AddChild(new RTK_Textview('Posted ' . $comment->GetTime(), true, null, 'commenttime'));
                 $childbox->AddChild($infobox);
                 if (!empty($comment->GetComments())) {
                     $this->TraverseComment($childbox, $comment->GetComments());
                 }
                 $box->AddChild($childbox);
             }
         }
     }
 }
コード例 #3
0
ファイル: htmldocument.php プロジェクト: iensenfirippu/RTK
 public function __tostring()
 {
     //$html = '<!doctype '.$this->_doctype.'>'.RTK_OUTPUTNEWLINE;
     $html = '<!doctype html>' . RTK_OUTPUTNEWLINE;
     // To make sure that stylesheets are always loaded in the same order (important for some rules), sort the stylesheet collection
     // TODO: This wont always be the preferable solution so a "weight" or "importance" system might need to be implemented
     sort($this->_stylesheets);
     if ($this->_favicon != null) {
         $this->AddElement(new HtmlElement('link', array('rel' => 'icon', 'type' => 'image/png', 'href' => $this->_favicon)), 'HEAD', 'FAVICON');
     }
     $this->AddElement(new HtmlElement('title', null, $this->_title), 'HEAD', 'TITLE');
     foreach ($this->_stylesheets as $stylesheet) {
         $this->_references['HEAD']->AddChild($stylesheet);
     }
     foreach ($this->_javascripts as $javascript) {
         $this->_references['HEAD']->AddChild($javascript);
     }
     $this->_stylesheets = array();
     $this->_javascripts = array();
     if (sizeof($this->_popups) > 0) {
         $popups = new HtmlElement('div', array('id' => 'Popups'));
         $popups->AddChild(new HtmlElement('script', array('language' => 'javascript'), 'function ClosePopup(divid) { var popups = document.getElementById(\'Popups\'); if (popups.children.length > 2) { var popup = document.getElementById(divid); popup.parentNode.removeChild(popup); } else { popups.parentNode.removeChild(popups); } }'));
         foreach ($this->_popups as $popup) {
             $popups->AddChild($popup);
         }
         $this->_references['BODY']->AddChild($popups, 0);
     }
     $newline = false;
     foreach ($this->_elements as $HtmlElement) {
         if ($newline) {
             $html .= OUTPUTNEWLINE;
         } else {
             $newline = true;
         }
         $html .= $HtmlElement;
     }
     return $html;
 }
コード例 #4
0
ファイル: Form.php プロジェクト: iensenfirippu/securipe
 /**
  * Add a custom HtmlElement into the form (not recommended)
  * @param string $name The name/id of the element
  * @param string $title The text written on the element
  * @param HtmlElement $HtmlElement The element to add
  * @param HtmlElement $container (optional) The "container" to add it to
  **/
 public function AddElement($name, $title, $htmlelement, $container = null)
 {
     $field = new HtmlElement('div', array('class' => 'formline'));
     $field->AddChild(new HtmlElement('label', array('for' => $name), $title));
     $group = new HtmlElement('div', array('class' => 'formgroup'));
     $group->AddChild($htmlelement);
     $field->AddChild($group);
     $this->AddToContainer($field, $container);
 }
コード例 #5
0
ファイル: Listview.php プロジェクト: iensenfirippu/securipe
 /**
  * Appends a row to the listview
  * @param string[] $row The values to put into the row
  * @param integer $i The index of the row
  **/
 private function AppendRow($row, $i)
 {
     $line = new HtmlElement('tr', array('class' => $this->GetRowClass($i)));
     $rowsize = sizeof($row) - 1;
     for ($i = 0; $i <= $rowsize; $i++) {
         if (is_a($row[$i], 'HtmlElement')) {
             $line->AddChild(new HtmlElement('td', array('class' => $this->GetCellClass($i, $rowsize)), EMPTYSTRING, $row[$i]));
         } else {
             $line->AddChild(new HtmlElement('td', array('class' => $this->GetCellClass($i, $rowsize)), $row[$i]));
         }
     }
     //$this->AddChild($line);
     $this->AddToContainer($line, 'table');
 }