Пример #1
0
 /**
  * Creates and returns the HTML representatation of the change set.
  * 
  * @since 0.1
  * 
  * @param SWLChangeSet $changeSet
  * 
  * @return string
  */
 protected static function getChangeListHTML(SWLChangeSet $changeSet)
 {
     $propertyHTML = array();
     foreach ($changeSet->getAllProperties() as $property) {
         $propertyHTML[] = self::getPropertyHTML($property, $changeSet->getAllPropertyChanges($property));
     }
     return implode('', $propertyHTML);
 }
 /**
  * Creates and returns the HTML representatation of the change set.
  *
  * @since 0.1
  *
  * @param SWLChangeSet $changeSet
  * @param SWLGroup $group
  *
  * @return string
  */
 protected static function getChangeListHTML(SWLChangeSet $changeSet, SWLGroup $group)
 {
     $propertyHTML = array();
     $customTexts = new SWLCustomTexts($group);
     foreach ($changeSet->getAllProperties() as $property) {
         $propertyHTML[] = self::getPropertyHTML($property, $changeSet->getAllPropertyChanges($property), $customTexts);
     }
     return implode('', $propertyHTML);
 }
 /**
  * Merges in the changes of another change set.
  * Duplicate changes are detected and only kept as a single change.
  * This is usefull for merging sets with (possibly overlapping) changes belonging to a single edit.
  * 
  * @since 0.1
  * 
  * @param SWLChangeSet $set
  */
 public function mergeInChangeSet(SWLChangeSet $set)
 {
     foreach ($set->getAllProperties() as $property) {
         foreach ($set->getChanges()->getPropertyChanges($property) as $change) {
             if (!$this->hasChange($property, $change)) {
                 $this->addChange($property, $change);
             }
         }
         foreach ($set->getInsertions()->getPropertyValues($property) as $dataItem) {
             if (!$this->hasInsertion($property, $dataItem)) {
                 $this->addInsertion($property, $dataItem);
             }
         }
         foreach ($set->getDeletions()->getPropertyValues($property) as $dataItem) {
             if (!$this->hasInsertion($property, $dataItem)) {
                 $this->addDeletion($property, $dataItem);
             }
         }
     }
 }
	/**
	 * Gets the HTML for a single change set (edit).
	 * 
	 * @since 0.1
	 * 
	 * @param SWLChangeSet $changeSet
	 * 
	 * @return string
	 */
	protected function getChangeSetHTML( SWLChangeSet $changeSet ) {
		global $wgLang;
		
		$edit = $changeSet->getEdit();
		
		$html = '';
		
		$html .= '<li>';
		
		$html .= 
			'<p>' .
				$wgLang->time( $edit->getTime(), true ) . ' ' .
				Html::element(
					'a',
					array( 'href' => $edit->getTitle()->getLocalURL() ),
					$edit->getTitle()->getText()
				) . ' (' .
				Html::element(
					'a',
					array( 'href' => $edit->getTitle()->getLocalURL( 'action=history' ) ),
					wfMsg( 'hist' )
				) . ') . . ' .
				Html::element(
					'a',
					array( 'href' => $edit->getUser()->getUserPage()->getLocalURL() ),
					$edit->getUser()->getName()
				) . ' (' .
				Html::element(
					'a',
					array( 'href' => $edit->getUser()->getTalkPage()->getLocalURL() ),
					wfMsg( 'talkpagelinktext' )
				) . ' | ' .
				( $edit->getUser()->isAnon() ? '' :
					Html::element(
						'a',
						array( 'href' => SpecialPage::getTitleFor( 'Contributions', $edit->getUser()->getName() )->getLocalURL() ),
						wfMsg( 'contribslink' )						
					) . ' | '
				) .
				Html::element(
					'a',
					array( 'href' => SpecialPage::getTitleFor( 'Block', $edit->getUser()->getName() )->getLocalURL() ),
					wfMsg( 'blocklink' )
				) . ')' .
				( $edit->getTime() > $this->lastViewed ? ' [NEW]' : '' )	.
			'</p>'
		;
		
		$propertyHTML= array();
		
		foreach ( $changeSet->getAllProperties() as /* SMWDIProperty */ $property ) {
			$propertyHTML[] = $this->getPropertyHTML( $property, $changeSet->getAllPropertyChanges( $property ) );
		}
		
		$html .= implode( '', $propertyHTML );
		
		$html .=  '</li>';
		
		return $html;
	}