static function tableMessageRowHTML($css_class, $name, $value) {
		$cell1 = HTML::element('td', array('class' => $css_class), $name);
		$cell2 = HTML::element('td', array('class' => 'msg'), $value);
		$text = HTML::rawElement('tr', null, $cell1 . "\n" . $cell2);
		$text .= "\n";
		return $text;
	}
 function addCategoryChooserToUploadForm($uploadFormObj)
 {
     $label = \HTML::rawElement('label', array('for' => 'attachmentCategory'), \wfMsg('selectCategory'));
     $labelCol = \HTML::rawElement('td', array('class' => 'mw-label'), $label);
     $categoryOptions = '';
     if (!$this->categoryManager->isMustSetCategory()) {
         $categoryOptions .= \HTML::rawElement('option', array('value' => ''), '');
     }
     foreach ($this->categoryManager->getCategoryList() as $category) {
         if ($this->categoryManager->isDefaultCategorySet() && $this->categoryManager->isDefaultCategory($category)) {
             $categoryOptions .= \HTML::rawElement('option', array('value' => $category, 'selected' => 'selected'), $category);
         } else {
             $categoryOptions .= \HTML::rawElement('option', array('value' => $category), $category);
         }
     }
     $categorySelect = \HTML::rawElement('select', array('id' => 'attachmentCategory', 'name' => 'attachmentCategory'), $categoryOptions);
     $categorySelectCol = \HTML::rawElement('td', array('class' => 'mw-input'), $categorySelect);
     $categoryChooserRow = \HTML::rawElement('tr', array(), $labelCol . $categorySelectCol);
     $uploadFormTextAfterSummary = $uploadFormObj->uploadFormTextAfterSummary;
     $uploadFormObj->uploadFormTextAfterSummary = $categoryChooserRow . $uploadFormTextAfterSummary;
 }
 /**
  * Renders the edit box, which is the main box with the publish button.
  * @return string HTML
  */
 private function renderEditBox()
 {
     global $wgUser;
     if ($this->article->exists()) {
         $top = wfMsgExt('inline-editor-editbox-top', 'parseinline');
     } else {
         $top = wfMsgExt('inline-editor-editbox-top-new', 'parseinline');
     }
     $top .= '<hr/>';
     $summary = wfMsgExt('inline-editor-editbox-changes-question', 'parseinline');
     $summary .= Html::input('wpSummary', $this->extendedEditPage->getSummary(), 'text', array('class' => 'summary', 'maxlength' => 250, 'spellcheck' => 'true', 'tabindex' => 1));
     $summary .= Html::rawElement('div', array('class' => 'example'), wfMsgExt('inline-editor-editbox-changes-example', 'parseinline'));
     $summary .= '<hr/>';
     $terms = Html::rawElement('div', array('class' => 'terms'), wfMsgExt('inline-editor-editbox-publish-terms', 'parseinline', '[[' . wfMsgForContent('copyrightpage') . ']]'));
     $publish = Html::rawElement('div', array('class' => 'side'), wfMsgExt('inline-editor-editbox-publish-notice', 'parseinline') . $terms);
     $publish .= Html::rawElement('a', array('id' => 'publish', 'href' => '#', 'accesskey' => wfMsg('accesskey-save'), 'title' => $wgUser->getSkin()->titleAttrib('save', 'withaccess')), wfMsgExt('inline-editor-editbox-publish-caption', 'parseinline'));
     $publish .= HTML::rawElement('input', array('id' => 'json', 'name' => 'json', 'type' => 'hidden'));
     return Html::rawElement('div', array('id' => 'editbox'), $top . $summary . $publish);
 }
	static function attrRowHTML( $cssClass, $fieldName, $value ) {
		$fieldNameAttrs = array( 'class' => $cssClass, 'style' => 'font-weight: normal;' );
		$fieldNameCell = HTML::rawElement( 'td', $fieldNameAttrs, $fieldName );
		$valueCell = HTML::element( 'td', array( 'class' => 'msg', 'style' => 'font-weight: bold;' ), $value );
		$text = HTML::rawElement( 'tr', null, $fieldNameCell . "\n" . $valueCell );
		$text .= "\n";
		return $text;
	}
Exemplo n.º 5
0
function poMakeForm($title, $readonly = false)
{
    global $wgUser, $wgProtectOwnGroups;
    $applicableRestrictionTypes = $title->getRestrictionTypes();
    // this way, do not display create for exsiting page
    $token = $wgUser->editToken();
    if (!$readonly) {
        $form = Html::openElement('form', array('method' => 'post', 'class' => 'visualClear', 'action' => $title->getLocalUrl('action=' . PROTECTOWN_ACTION)));
    } else {
        $form = Html::openElement('form', array('method' => 'post', 'class' => 'visualClear', 'action' => '#'));
    }
    $form .= Xml::openElement('div', array('class' => 'edit_col_1'));
    $form .= Xml::openElement('fieldset');
    $form .= Xml::element('legend', null, wfMsg("po-legend"));
    $form .= Xml::openElement('div', array('class' => 'content_block'));
    // for each of theses available restrictions
    foreach ($applicableRestrictionTypes as $action) {
        // 'read', 'upload', ...
        $title_action_restrictions = $title->getRestrictions($action);
        //'sysop', 'owner', ...
        // this foreach normally does only one iteration, but MediaWiki core can handle
        // multiple restrictions per one action... but the current code is not optimised
        // for that case
        // please review this if you have mutliple restrictions per action per page
        $stop = false;
        foreach ($title_action_restrictions as $current_restriction) {
            // if restricted to a level that the user can't set, or readonly, display only
            // a message about the restriction then end
            if ($readonly || !poCanTheUserSetToThisLevel($wgUser, $title, $current_restriction)) {
                $form .= wfMsg("restriction-level-{$title_action_restrictions['0']}") . ' (' . $title_action_restrictions[0] . ')';
                $form .= Xml::closeElement('div');
                //content_block
                $form .= Xml::closeElement('fieldset');
                // restrictions are inclusive (see Title.php>checkPageRestrictions()
                // so no more iteration needed
                $stop = true;
                break;
            }
        }
        // $stop = the user cannot change a restriction and a message is already displayed
        // we prematurely end this iteration because we don't add any checkboxe for that action
        if ($stop) {
            continue;
        }
        // end foreach current iteration
        if ($readonly) {
            // if we arrive here, form is readonly, but no restrictions set
            $form .= wfMsg("restriction-level-all");
            $form .= Xml::closeElement('div');
            //content_block
            $form .= Xml::closeElement('fieldset');
            continue;
            // end foreach current iteration
        }
        $form .= Xml::openElement('p', array('class' => 'mw-htmlform-field-HTMLRadioField'));
        $form .= Xml::element('label', null, wfMsg("po-whocan-{$action}"));
        $form .= Xml::openElement('span', array('class' => 'input_like'));
        # the next lines display checkboxes and eventually check them
        foreach ($wgProtectOwnGroups as $current_level) {
            // if the level is not selectable, do not display the checkboxe
            if (!poCanTheUserSetToThisLevel($wgUser, $title, $current_level)) {
                continue;
                // end foreach iteration
            }
            if ($current_level == '' && $action == 'upload') {
                continue;
            }
            $checked = false;
            if ($current_level == '' && $title_action_restrictions === array()) {
                $checked = true;
            } else {
                $checked = in_array($current_level, $title_action_restrictions);
            }
            // else, check if there is a restriction to this level
            // convert from BACK-END to FRONT-END
            $current_level = $current_level == '' ? 'everyone' : $current_level;
            $form .= Xml::openElement('span', array('class' => 'mw-htmlform-monoselect-item'));
            /* $form .= Xml::checkLabel(wfMessage("po-$current_level")->text(), "check-$action-$current_level", "check-$action-$current_level", $checked); */
            $form .= Xml::radioLabel(wfMessage("po-{$current_level}")->text(), "radio-{$action}", $current_level, "radio-{$action}-{$current_level}", $checked);
            $form .= Xml::closeElement('span');
            //mw-htmlform-monoselect-item
        }
        $form .= Xml::closeElement('span');
        //input_like
        $form .= HTML::rawElement('span', array('class' => 'sread help htmlform-tip'), wfMessage("po-help-{$action}")->parse());
        //input_like
        $form .= Xml::closeElement('p');
        //mw-htmlform-field-HTMLRadioField
    }
    $form .= Xml::closeElement('div');
    //content_block
    $form .= Xml::closeElement('fieldset');
    $form .= Html::hidden('wpToken', $token);
    if (!$readonly) {
        $form .= Xml::openElement('p', array('class' => 'submit'));
        $form .= Xml::submitButton(wfMessage('po-submit'), array('class' => 'mw-htmlform-submit'));
        $form .= Xml::closeElement('p');
    }
    $form .= Xml::closeElement('div');
    //edit_col_1
    $form .= Xml::openElement('div', array('class' => 'edit_col_2'));
    $form .= Xml::openElement('div', array('class' => 'content_block', 'id' => 'help_zone'));
    $form .= Xml::element('h4', null, wfMessage('sz-htmlform-helpzonetitle')->text());
    $form .= HTML::rawElement('p', null, wfMessage('sz-htmlform-helpzonedefault')->parse());
    $form .= Xml::closeElement('div');
    $form .= Xml::closeElement('div');
    $form .= Xml::closeElement('form');
    return $form;
}
 function composeAttachmentListTable($protectedPage, $titleRowColumns, $headerRowColumns, $attachmentRows)
 {
     global $wgLang;
     global $wgPageAttachment_colToDisplay;
     global $wgPageAttachment_colWidth;
     global $wgPageAttachment_descriptionMaxLength;
     global $wgPageAttachment_descriptionPopupWidth;
     global $wgPageAttachment_descriptionPopupHeight;
     $skinName = $this->runtimeConfig->getSkinName();
     $userLangCode = $this->runtimeConfig->getUserLanguageCode();
     $rtlLang = $this->runtimeConfig->isRightToLeftLanguage();
     $colWidths = $this->getColWidths($skinName, $userLangCode);
     $colgroupCols = '';
     foreach ($colWidths as $colWidth) {
         $colgroupCols .= \HTML::element('col', array('width' => $colWidth . '%'));
     }
     $colgroup = \HTML::rawElement('colgroup', null, $colgroupCols);
     //
     // Title Row
     //
     $titleRowColKeys = array_keys($titleRowColumns);
     $titleRowCols = '';
     foreach ($titleRowColKeys as $colKey) {
         $attrs = array('class' => 'titleRow_col_' . $colKey, 'colspan' => $this->getTitleRowColSpan($skinName, $userLangCode, $colKey));
         $titleRowCols .= \HTML::rawElement('th', $attrs, $titleRowColumns[$colKey]);
     }
     $titleRow = \HTML::rawElement('tr', array('class' => 'TitleRow'), $titleRowCols);
     //
     // Header Row
     //
     $headerRowColKeys = array_keys($headerRowColumns);
     $headerRowCols = '';
     foreach ($headerRowColKeys as $colKey) {
         $headerRowCols .= \HTML::element('th', array('class' => 'headerRow_col_' . $colKey), $headerRowColumns[$colKey]);
     }
     $headerRow = \HTML::rawElement('tr', array('class' => 'HeaderRow'), $headerRowCols);
     $thead = \HTML::rawElement('thead', null, $titleRow . $headerRow);
     //
     // Attachment Rows
     //
     $viewMoreImgURL = $this->resource->getViewMoreImageURL();
     $viewMoreImgIcon = \HTML::rawElement('img', array('src' => $viewMoreImgURL));
     $atRows = '';
     if ($this->security->isViewAttachmentsAllowed($protectedPage)) {
         if (isset($attachmentRows) && count($attachmentRows) > 0) {
             foreach ($attachmentRows as $row) {
                 $rowCols = $row;
                 $rowColKeys = array_keys($rowCols);
                 $atRowsCols = '';
                 foreach ($rowColKeys as $colKey) {
                     if ($colKey == 'Description') {
                         if ($rowCols[$colKey] == '') {
                             $atRowsCols .= \HTML::rawElement('td', array('class' => 'attachmentRow_col_' . $colKey), '');
                         } else {
                             if (strlen($rowCols[$colKey]) > $wgPageAttachment_descriptionMaxLength) {
                                 $descriptionAndIcon = '';
                                 $desc = \PageAttachment\Utility\StringUtil::trimText($rowCols[$colKey], $wgPageAttachment_descriptionMaxLength);
                                 $descriptionAndIcon = $desc . '... ' . $viewMoreImgIcon;
                                 $atRowsCols .= \HTML::rawElement('td', array('class' => 'attachmentRow_col_' . $colKey, 'onmouseover' => 'pageAttachment_showPopup(this, "' . $wgPageAttachment_descriptionPopupWidth . '", "' . $wgPageAttachment_descriptionPopupHeight . '", "' . $rowCols[$colKey] . '", ' . ($rtlLang == true ? "true" : "false") . ');', 'onmouseout' => 'pageAttachment_removePopup();'), $descriptionAndIcon);
                             } else {
                                 $atRowsCols .= \HTML::rawElement('td', array('class' => 'attachmentRow_col_' . $colKey), $rowCols[$colKey]);
                             }
                         }
                     } else {
                         $atRowsCols .= \HTML::rawElement('td', array('class' => 'attachmentRow_col_' . $colKey), $rowCols[$colKey]);
                     }
                 }
                 $atRows .= \HTML::rawElement('tr', array('class' => 'AttachmentRow'), $atRowsCols);
             }
         } else {
             $colSpan = count($colWidths);
             $atRowsCol = \HTML::element('td', array('class' => 'messageAttachmentsNone', 'colspan' => $colSpan), \wfMsg('AttachmentsNone'));
             $atRows = \HTML::rawElement('tr', array('class' => 'MessageRow'), $atRowsCol);
         }
         // Status Message
         $statusMsg = $this->session->getStatusMessage();
         if (isset($statusMsg)) {
             $statusMsg = $this->formatStatusMessage($statusMsg);
             $colSpan = count($colWidths);
             $atRowCol = \HTML::rawElement('td', array('class' => 'message', 'colspan' => $colSpan), $statusMsg);
             $atRows .= \HTML::rawElement('tr', array('class', 'MessageRow'), $atRowCol);
         }
     } else {
         if ($this->security->isViewAttachmentsRequireLogin() && !$this->security->isLoggedIn()) {
             $statusMsg = \wfMsg('YouMustBeLoggedInToViewAttachments');
         } else {
             $statusMsg = \wfMsg('ViewAttachmentIsNotPermitted');
         }
         $statusMsg = $this->formatStatusMessage($statusMsg);
         $colSpan = count($colWidths);
         $atRowCol = \HTML::rawElement('td', array('class' => 'message', 'colspan' => $colSpan), $statusMsg);
         $atRows .= \HTML::rawElement('tr', array('class', 'MessageRow'), $atRowCol);
     }
     $tbody = \HTML::rawElement('tbody', null, $atRows);
     $data = \HTML::rawElement('table', array('cellspacing' => '0'), $colgroup . $thead . $tbody);
     return $data;
 }
Exemplo n.º 7
0
	public function view( IdStack $idPath, $value ) {
		$recordCount = $value->getRecordCount();

		if ( $recordCount > 0 ) {
			$result = HTML::openElement ('ul', array( 'class' => 'collapsable-items')) ;
			$key = $value->getKey();
			$captionAttribute = $this->captionEditor->getAttribute();
			$valueAttribute = $this->valueEditor->getAttribute();
		
			for ( $i = 0; $i < $recordCount; $i++ ) {
				$record = $value->getRecord( $i );
				$idPath->pushKey( project( $record, $key ) );
				$recordId = $idPath->getId();
				$captionClass = $idPath->getClass() . "-record";
				$captionExpansionPrefix = $this->getExpansionPrefix( $captionClass, $recordId );
				$this->setExpansion( $this->childrenExpanded, $captionClass );
				$valueClass = $idPath->getClass() . "-record";
				$this->setExpansion( $this->childrenExpanded, $valueClass );
		
				$idPath->pushAttribute( $captionAttribute );
				$result .= HTML::openElement ('li') ;
				$class = 'level' . $this->headerLevel ;
				$result .= HTML::openElement ('div', array( 'class' => $class )) ;

				$text = $captionExpansionPrefix . '&#160;'
					. $this->captionEditor->view( $idPath, $record->getAttributeValue( $captionAttribute ) ) ;

				$attribs = array(); // default if not collapsible
				if ( $this->isCollapsible ) {
					// collapsible element
					$class = 'toggle ' . addCollapsablePrefixToClass( $captionClass ) ;
					$id = 'collapse-' . $recordId ;
					$attribs = array('class' => $class , 'id' => $id , 'onclick' => 'toggle(this, event);' );
				}
				$result .= HTML::rawElement ('span', $attribs, $text ) ;
				$result .= HTML::closeElement ('div');

				$idPath->popAttribute();
				$idPath->pushAttribute( $valueAttribute );

				$text = $this->valueEditor->view( $idPath, $record->getAttributeValue( $valueAttribute ) );
				$class = 'expand-' . $valueClass ;
				$id = 'collapsable-' . $recordId ;
				$result .= HTML::rawElement ('div', array('class' => $class , 'id' => $id), $text ) ;
				$result .= HTML::closeElement ('li') ;
				$idPath->popAttribute();
				$idPath->popKey();
			}

			$result .= HTML::closeElement ('ul');
		
			return $result;
		}
		else
			return "";
	}
Exemplo n.º 8
-1
 /**
  * Get the body of the ad, with all transformations applied.
  */
 public function renderHtml()
 {
     $adCaption = $this->getCaption();
     $adBody = wfMessage($this->getDbKey())->parse();
     $adMainLink = $this->getMainLink();
     $adMainLink = empty($adMainLink) ? null : Skin::makeInternalOrExternalUrl($this->getMainLink());
     $adHtml = HTML::openElement('div', array('class' => 'promotion', 'data-adname' => $this->getName()));
     $adHtml .= HTML::openElement('div', array('class' => 'header'));
     //$adHtml .= HTML::element( 'span', array( 'class' => 'icon pull-right' ) );
     if (empty($adMainLink)) {
         $adHtml .= HTML::element('span', array('class' => 'caption'), $adCaption);
     } else {
         $adHtml .= HTML::element('a', array('class' => 'caption', 'href' => $adMainLink), $adCaption);
     }
     $adHtml .= HTML::closeElement('div');
     $adHtml .= HTML::rawElement('div', array('class' => 'content'), $adBody);
     if ($adMainLink) {
         $adHtml .= HTML::openElement('div', array('class' => 'mainlink'));
         $adHtml .= HTML::element('a', array('href' => $adMainLink), 'לפרטים נוספים...');
         $adHtml .= HTML::closeElement('div');
     }
     $adHtml .= HTML::closeElement('div');
     return $adHtml;
 }