Index: trunk/extensions/DSMW/jobs/DSMWPropertyTypeJob.php |
— | — | @@ -1,80 +1,53 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | 4 | * @copyright 2009 INRIA-LORIA-Score Team |
| 5 | + * |
5 | 6 | * @author jean-philippe muller |
| 7 | + * @author Jeroen De Dauw |
6 | 8 | */ |
7 | 9 | |
8 | 10 | /** |
9 | 11 | * Job that assigns a type to some properties used in the DSMW ontology |
10 | | - * |
11 | 12 | */ |
12 | 13 | class DSMWPropertyTypeJob extends Job { |
13 | 14 | |
14 | | - function __construct( $title ) { |
15 | | - parent::__construct( 'DSMWPropertyTypeJob', $title ); |
| 15 | + public function __construct( $title ) { |
| 16 | + parent::__construct( __CLASS__, $title ); |
16 | 17 | } |
17 | 18 | |
18 | | - function run() { |
| 19 | + public function run() { |
19 | 20 | wfProfileIn( 'DSMWPropertyTypeJob::run()' ); |
20 | 21 | |
21 | | - $title = Title::newFromText( 'changeSetID', SMW_NS_PROPERTY ); |
22 | | - if ( !$title->exists() ) { |
23 | | - $article = new Article( $title ); |
24 | | - $editpage = new EditPage( $article ); |
25 | | - $editpage->textbox1 = '[[has type::String]]'; |
26 | | - $editpage->attemptSave(); |
27 | | - } |
| 22 | + $this->addProperty( 'changeSetID', '[[has type::String]]' ); |
| 23 | + $this->addProperty( 'hasSemanticQuery', '[[has type::String]]' ); |
| 24 | + $this->addProperty( 'patchID', '[[has type::String]]' ); |
| 25 | + $this->addProperty( 'siteID', '[[has type::String]]' ); |
| 26 | + $this->addProperty( 'pushFeedServer', '[[has type::URL]]' ); |
| 27 | + $this->addProperty( 'pushFeedName', '[[has type::String]]' ); |
| 28 | + $this->addProperty( 'hasOperation', '[[has type::Record]] [[has fields::String;String;Text;Text]]' ); |
28 | 29 | |
29 | | - $title = Title::newFromText( 'hasSemanticQuery', SMW_NS_PROPERTY ); |
30 | | - if ( !$title->exists() ) { |
31 | | - $article = new Article( $title ); |
32 | | - $editpage = new EditPage( $article ); |
33 | | - $editpage->textbox1 = '[[has type::String]]'; |
34 | | - $editpage->attemptSave(); |
35 | | - } |
36 | | - |
37 | | - $title = Title::newFromText( 'patchID', SMW_NS_PROPERTY ); |
38 | | - if ( !$title->exists() ) { |
39 | | - $article = new Article( $title ); |
40 | | - $editpage = new EditPage( $article ); |
41 | | - $editpage->textbox1 = '[[has type::String]]'; |
42 | | - $editpage->attemptSave(); |
43 | | - } |
44 | | - |
45 | | - $title = Title::newFromText( 'siteID', SMW_NS_PROPERTY ); |
46 | | - if ( !$title->exists() ) { |
47 | | - $article = new Article( $title ); |
48 | | - $editpage = new EditPage( $article ); |
49 | | - $editpage->textbox1 = '[[has type::String]]'; |
50 | | - $editpage->attemptSave(); |
51 | | - } |
52 | | - |
53 | | - $title = Title::newFromText( 'pushFeedServer', SMW_NS_PROPERTY ); |
54 | | - if ( !$title->exists() ) { |
55 | | - $article = new Article( $title ); |
56 | | - $editpage = new EditPage( $article ); |
57 | | - $editpage->textbox1 = '[[has type::URL]]'; |
58 | | - $editpage->attemptSave(); |
59 | | - } |
60 | | - |
61 | | - $title = Title::newFromText( 'pushFeedName', SMW_NS_PROPERTY ); |
62 | | - if ( !$title->exists() ) { |
63 | | - $article = new Article( $title ); |
64 | | - $editpage = new EditPage( $article ); |
65 | | - $editpage->textbox1 = '[[has type::String]]'; |
66 | | - $editpage->attemptSave(); |
67 | | - } |
68 | | - |
69 | | - $title = Title::newFromText( 'hasOperation', SMW_NS_PROPERTY ); |
70 | | - if ( !$title->exists() ) { |
71 | | - $article = new Article( $title ); |
72 | | - $editpage = new EditPage( $article ); |
73 | | - $editpage->textbox1 = '[[has type::Record]] |
74 | | -[[has fields::String;String;Text;Text]]'; |
75 | | - $editpage->attemptSave(); |
76 | | - } |
77 | | - |
78 | 30 | wfProfileOut( 'DSMWPropertyTypeJob::run()' ); |
| 31 | + |
79 | 32 | return true; |
80 | 33 | } |
| 34 | + |
| 35 | + /** |
| 36 | + * Adds a property. |
| 37 | + * |
| 38 | + * @since 1.1 |
| 39 | + * |
| 40 | + * @param string $titleName The name of the property |
| 41 | + * @param string $propertyProperties A string of properties to assign to the propery (such as "has type") |
| 42 | + */ |
| 43 | + protected function addProperty( $titleName, $propertyProperties ) { |
| 44 | + $title = Title::newFromText( $titleName, SMW_NS_PROPERTY ); |
| 45 | + |
| 46 | + if ( !$title->exists() ) { |
| 47 | + $article = new Article( $title ); |
| 48 | + $editpage = new EditPage( $article ); |
| 49 | + $editpage->textbox1 = $propertyProperties; |
| 50 | + $editpage->attemptSave(); |
| 51 | + } |
| 52 | + } |
| 53 | + |
81 | 54 | } |
Index: trunk/extensions/DSMW/patch/Patch.php |
— | — | @@ -40,8 +40,10 @@ |
41 | 41 | */ |
42 | 42 | public function __construct( $remote, $attachment, $operations, $siteUrl = '', $causalLink = '', $patchid = '', $previousPatch = '', $siteID = '', $Mime = '', $Size = '', $Url = '', $Date = '' ) { |
43 | 43 | global $wgServer; |
| 44 | + |
44 | 45 | $this->mRemote = $remote; |
45 | 46 | $this->mID = utils::generateID(); |
| 47 | + |
46 | 48 | if ( $remote == true ) { |
47 | 49 | $this->mPatchId = $patchid; |
48 | 50 | $this->mSiteId = $siteID; |
— | — | @@ -50,6 +52,7 @@ |
51 | 53 | $this->mPatchId = "Patch:" . $this->mID; |
52 | 54 | $this->mSiteId = DSMWSiteId::getInstance()->getSiteId(); |
53 | 55 | } |
| 56 | + |
54 | 57 | $this->mOperations = $operations; |
55 | 58 | $this->mPrevPatch = $previousPatch; |
56 | 59 | $this->mSiteUrl = $siteUrl; |
— | — | @@ -142,11 +145,8 @@ |
143 | 146 | foreach ( $this->mOperations as $operation ) { |
144 | 147 | $lineContent = $operation->getLineContent(); |
145 | 148 | $lineContent1 = utils::contentEncoding( $lineContent ); // base64 encoding |
146 | | - $type = ""; |
147 | | - if ( $operation instanceof LogootIns ) |
148 | | - $type = "Insert"; |
149 | | - else |
150 | | - $type = "Delete"; |
| 149 | + $type = $operation instanceof LogootIns ? 'Insert' : 'Delete'; |
| 150 | + |
151 | 151 | $operationID = utils::generateID(); |
152 | 152 | $text .= '|[[hasOperation::' . $operationID . ';' . $type . ';' |
153 | 153 | . $operation->getLogootPosition()->toString() . ';' . $lineContent1 . '| ]]' . $type; |
— | — | @@ -187,13 +187,8 @@ |
188 | 188 | $article->doEdit( $text, $summary = "" ); |
189 | 189 | } |
190 | 190 | |
191 | | - private function splitLine( $line ) { |
192 | | - $text = ""; |
193 | | - $arr = str_split( $line, 150 ); |
194 | | - foreach ( $arr as $element ) { |
195 | | - $text .= $element . '<br>'; |
196 | | - } |
197 | | - return $text; |
| 191 | + protected function splitLine( $line ) { |
| 192 | + return implode( '<br>', str_split( $line, 150 ) ) . '<br />'; |
198 | 193 | } |
199 | 194 | |
200 | 195 | } |
Index: trunk/extensions/DSMW/DSMW.php |
— | — | @@ -57,11 +57,6 @@ |
58 | 58 | |
59 | 59 | $wgAutoloadClasses['DSMWHooks'] = dirname( __FILE__ ) . '/DSMW.hooks.php'; |
60 | 60 | |
61 | | -$wgHooks['UnknownAction'][] = 'DSMWHooks::onUnknownAction'; |
62 | | -$wgHooks['EditPage::attemptSave'][] = 'DSMWHooks::onAttemptSave'; |
63 | | -$wgHooks['EditPageBeforeConflictDiff'][] = 'DSMWHooks::onEditConflict'; |
64 | | -$wgHooks['UploadComplete'][] = 'DSMWHooks::onUploadComplete'; |
65 | | - |
66 | 61 | $wgAutoloadClasses['logootEngine'] = "$wgDSMWIP/logootComponent/logootEngine.php"; |
67 | 62 | $wgAutoloadClasses['logoot'] = "$wgDSMWIP/logootComponent/logoot.php"; |
68 | 63 | $wgAutoloadClasses['LogootId'] = "$wgDSMWIP/logootComponent/LogootId.php"; |
— | — | @@ -104,6 +99,11 @@ |
105 | 100 | |
106 | 101 | $wgExtensionFunctions[] = 'dsmwgSetupFunction'; |
107 | 102 | |
| 103 | +$wgHooks['UnknownAction'][] = 'DSMWHooks::onUnknownAction'; |
| 104 | +$wgHooks['EditPage::attemptSave'][] = 'DSMWHooks::onAttemptSave'; |
| 105 | +$wgHooks['EditPageBeforeConflictDiff'][] = 'DSMWHooks::onEditConflict'; |
| 106 | +$wgHooks['UploadComplete'][] = 'DSMWHooks::onUploadComplete'; |
| 107 | + |
108 | 108 | $wgExtensionCredits[defined( 'SEMANTIC_EXTENSION_TYPE' ) ? 'semantic' : 'other'][] = array( |
109 | 109 | 'path' => __FILE__, |
110 | 110 | 'name' => 'Distributed Semantic MediaWiki', |