11<?php
22
3+ use dokuwiki \Search \Indexer ;
4+
35/**
46 * DokuWiki Plugin gitbacked (Action Component)
57 *
@@ -68,8 +70,8 @@ private function initRepo()
6870 Git::setBin (empty ($ repoWorkDir ) ? Git::getBin ()
6971 : Git::getBin () . ' --work-tree ' . escapeshellarg ($ repoWorkDir ));
7072 $ params = str_replace (
71- array ( '%mail% ' , '%user% ' ) ,
72- array ( $ this ->getAuthorMail (), $ this ->getAuthor ()) ,
73+ [ '%mail% ' , '%user% ' ] ,
74+ [ $ this ->getAuthorMail (), $ this ->getAuthor ()] ,
7375 $ this ->getConf ('addParams ' )
7476 );
7577 if ($ params ) {
@@ -131,7 +133,7 @@ private function computeLocalPath()
131133 global $ conf ;
132134 $ repoPath = str_replace ('\\' , '/ ' , realpath (GitBackedUtil::getEffectivePath ($ this ->getConf ('repoPath ' ))));
133135 $ datadir = $ conf ['datadir ' ]; // already normalized
134- if (!( substr ($ datadir , 0 , strlen ($ repoPath )) === $ repoPath) ) {
136+ if (substr ($ datadir , 0 , strlen ($ repoPath )) !== $ repoPath ) {
135137 throw new Exception ('Datadir not inside repoPath ?? ' );
136138 }
137139 return substr ($ datadir , strlen ($ repoPath ) + 1 );
@@ -140,8 +142,8 @@ private function computeLocalPath()
140142 private function updatePage ($ page )
141143 {
142144
143- if (is_callable ('\\ dokuwiki \\ Search \\ Indexer::getInstance ' )) {
144- $ Indexer = \ dokuwiki \ Search \ Indexer::getInstance ();
145+ if (is_callable (Indexer::class . ' ::getInstance ' )) {
146+ $ Indexer = Indexer::getInstance ();
145147 $ success = $ Indexer ->addPage ($ page , false , false );
146148 } elseif (class_exists ('Doku_Indexer ' )) {
147149 $ success = idx_addPage ($ page , false , false );
@@ -226,8 +228,8 @@ public function handleMediaDeletion(Event &$event, $param)
226228 $ mediaName = $ event ->data ['name ' ];
227229
228230 $ message = str_replace (
229- array ( '%media% ' , '%user% ' ) ,
230- array ( $ mediaName , $ this ->getAuthor ()) ,
231+ [ '%media% ' , '%user% ' ] ,
232+ [ $ mediaName , $ this ->getAuthor ()] ,
231233 $ this ->getConf ('commitMediaMsgDel ' )
232234 );
233235
@@ -241,8 +243,8 @@ public function handleMediaUpload(Event &$event, $param)
241243 $ mediaName = $ event ->data [2 ];
242244
243245 $ message = str_replace (
244- array ( '%media% ' , '%user% ' ) ,
245- array ( $ mediaName , $ this ->getAuthor ()) ,
246+ [ '%media% ' , '%user% ' ] ,
247+ [ $ mediaName , $ this ->getAuthor ()] ,
246248 $ this ->getConf ('commitMediaMsg ' )
247249 );
248250
@@ -282,8 +284,8 @@ public function handleIOWikiPageWrite(Event &$event, $param)
282284 }
283285
284286 $ message = str_replace (
285- array ( '%page% ' , '%summary% ' , '%user% ' ) ,
286- array ( $ pageName , $ editSummary , $ this ->getAuthor ()) ,
287+ [ '%page% ' , '%summary% ' , '%user% ' ] ,
288+ [ $ pageName , $ editSummary , $ this ->getAuthor ()] ,
287289 $ msgTemplate
288290 );
289291
@@ -303,11 +305,7 @@ public function handleIOWikiPageWrite(Event &$event, $param)
303305 */
304306 public function notifyCreateNewError ($ repo_path , $ reference , $ error_message )
305307 {
306- $ template_replacements = array (
307- 'GIT_REPO_PATH ' => $ repo_path ,
308- 'GIT_REFERENCE ' => (empty ($ reference ) ? 'n/a ' : $ reference ),
309- 'GIT_ERROR_MESSAGE ' => $ error_message
310- );
308+ $ template_replacements = ['GIT_REPO_PATH ' => $ repo_path , 'GIT_REFERENCE ' => (empty ($ reference ) ? 'n/a ' : $ reference ), 'GIT_ERROR_MESSAGE ' => $ error_message ];
311309 return $ this ->notifyByMail ('mail_create_new_error_subject ' , 'mail_create_new_error ' , $ template_replacements );
312310 }
313311
@@ -321,10 +319,7 @@ public function notifyCreateNewError($repo_path, $reference, $error_message)
321319 */
322320 public function notifyRepoPathError ($ repo_path , $ error_message )
323321 {
324- $ template_replacements = array (
325- 'GIT_REPO_PATH ' => $ repo_path ,
326- 'GIT_ERROR_MESSAGE ' => $ error_message
327- );
322+ $ template_replacements = ['GIT_REPO_PATH ' => $ repo_path , 'GIT_ERROR_MESSAGE ' => $ error_message ];
328323 return $ this ->notifyByMail ('mail_repo_path_error_subject ' , 'mail_repo_path_error ' , $ template_replacements );
329324 }
330325
@@ -341,13 +336,7 @@ public function notifyRepoPathError($repo_path, $error_message)
341336 */
342337 public function notifyCommandError ($ repo_path , $ cwd , $ command , $ status , $ error_message )
343338 {
344- $ template_replacements = array (
345- 'GIT_REPO_PATH ' => $ repo_path ,
346- 'GIT_CWD ' => $ cwd ,
347- 'GIT_COMMAND ' => $ command ,
348- 'GIT_COMMAND_EXITCODE ' => $ status ,
349- 'GIT_ERROR_MESSAGE ' => $ error_message
350- );
339+ $ template_replacements = ['GIT_REPO_PATH ' => $ repo_path , 'GIT_CWD ' => $ cwd , 'GIT_COMMAND ' => $ command , 'GIT_COMMAND_EXITCODE ' => $ status , 'GIT_ERROR_MESSAGE ' => $ error_message ];
351340 return $ this ->notifyByMail ('mail_command_error_subject ' , 'mail_command_error ' , $ template_replacements );
352341 }
353342
@@ -365,11 +354,7 @@ public function notifyCommandSuccess($repo_path, $cwd, $command)
365354 if (!$ this ->getConf ('notifyByMailOnSuccess ' )) {
366355 return false ;
367356 }
368- $ template_replacements = array (
369- 'GIT_REPO_PATH ' => $ repo_path ,
370- 'GIT_CWD ' => $ cwd ,
371- 'GIT_COMMAND ' => $ command
372- );
357+ $ template_replacements = ['GIT_REPO_PATH ' => $ repo_path , 'GIT_CWD ' => $ cwd , 'GIT_COMMAND ' => $ command ];
373358 return $ this ->notifyByMail ('mail_command_success_subject ' , 'mail_command_success ' , $ template_replacements );
374359 }
375360
@@ -403,6 +388,7 @@ public function notifyByMail($subject_id, $template_id, $template_replacements)
403388 //dbglog("GitBacked - template html['".$template_id."']: ".$template_html);
404389 $ mailer ->subject ($ this ->getLang ($ subject_id ));
405390 $ mailer ->setBody ($ template_text , $ template_replacements , null , $ template_html );
391+
406392 $ ret = $ mailer ->send ();
407393
408394 return $ ret ;
0 commit comments