public function setRequestProcessor()
 {
     if (isset($this->request_processor)) {
         return;
     }
     return $this->request_processor = ObjectRegistry::getInstance()->getSummaryPageRequestProcessor($this->getRequest());
 }
 protected function retrieveAndSetData()
 {
     list($manuscript_url, $manuscript_title) = $this->getManuscriptsDatabaseData();
     $text_processor = ObjectRegistry::getInstance()->getManuscriptDeskBaseTextProcessor();
     $page_texts[$manuscript_title] = $text_processor->getUnfilteredSinglePageText($manuscript_url);
     $this->page_texts = $page_texts;
     return;
 }
 /**
  * Check whether the page arguments contain valid charachters
  * 
  * @return type void
  */
 protected function checkPageArguments()
 {
     $request = $this->getRequest();
     $this->arguments = $image_arguments = $request->getText('image');
     $validator = ObjectRegistry::getInstance()->getManuscriptDeskBaseValidator();
     $validator->validateStringUrl($image_arguments);
     return;
 }
 protected function retrieveAndSetData()
 {
     $this->setCollectionMetadata();
     list($collection_urls, $collection_manuscript_titles) = $this->getCollectionDatabaseData();
     $text_processor = ObjectRegistry::getInstance()->getManuscriptDeskBaseTextProcessor();
     $page_texts = array();
     foreach ($collection_urls as $index => $url) {
         $manuscript_title = $collection_manuscript_titles[$index];
         $page_texts[$manuscript_title] = $text_processor->getUnfilteredSinglePageText($url);
     }
     $this->page_texts = $page_texts;
     return;
 }
Пример #5
0
 /**
  * Check if an object instance was registered for the identifier
  *
  * @param mixed $identifier An object that implements the ObjectInterface, an ObjectIdentifier or valid identifier string
  * @return boolean Returns TRUE on success or FALSE on failure.
  */
 public function isRegistered($identifier)
 {
     try {
         $object = $this->_registry->get($this->getIdentifier($identifier));
         //If the object implements ObjectInterface we have registered an object
         if ($object instanceof ObjectInterface) {
             $result = true;
         } else {
             $result = false;
         }
     } catch (ObjectExceptionInvalidIdentifier $e) {
         $result = false;
     }
     return $result;
 }
Пример #6
0
 /**
  * Get an instance of a class based on a class identifier
  *
  * @param ObjectIdentifier $identifier
  * @param bool              $fallback   Use fallbacks when locating the class. Default is TRUE.
  * @return  string  Return the identifier class or FALSE on failure.
  */
 protected function _locate(ObjectIdentifier $identifier, $fallback = true)
 {
     $class = $this->__registry->getClass($identifier);
     //If the class is FALSE we have tried to locate it already, do not locate it again.
     if (empty($class) && $class !== false) {
         $class = $this->_locators[$identifier->getType()]->locate($identifier, $fallback);
         //If we are falling back set the class in the registry
         if ($fallback) {
             if (!$this->__registry->get($identifier) instanceof ObjectInterface) {
                 $this->__registry->setClass($identifier, $class);
             }
         }
     }
     return $class;
 }
 private function deleteManuscriptPages($res)
 {
     if ($res->numRows() > 0) {
         /**
          * Important: can't use objectregistry here in some cases because otherwise objects will have the same variables throughout loop 
          */
         while ($s = $res->fetchObject()) {
             $user_name = $s->manuscripts_user;
             $manuscripts_title = $s->manuscripts_title;
             $collection_title = $s->manuscripts_collection;
             $manuscripts_url = $s->manuscripts_url;
             $paths = new NewManuscriptPaths($user_name, $manuscripts_title);
             $paths->setExportPaths();
             $paths->setPartialUrl();
             $deleter = new ManuscriptDeskDeleter(ObjectRegistry::getInstance()->getManuscriptDeskDeleteWrapper());
             $deleter->setNewManuscriptPaths($paths);
             $deleter->setCollectionTitle($collection_title);
             $deleter->setManuscriptsUrl($manuscripts_url);
             $deleter->deleteManuscriptPage();
         }
     }
     return;
 }
 public function setWrapper()
 {
     if (isset($this->wrapper)) {
         return;
     }
     $wrapper = ObjectRegistry::getInstance()->getNewManuscriptWrapper();
     $wrapper->setUserName($this->user_name);
     return $this->wrapper = $wrapper;
 }
Пример #9
0
 * @subpackage Extensions
 * @author Arent van Korlaar <akvankorlaar 'at' gmail 'dot' com> 
 * @copyright 2015 Arent van Korlaar
 */
/**
 * Usage: Add the following line in LocalSettings.php:
 * require_once( "$IP/extensions/HelperScripts/HelperScripts.php" );
 */
// Check environment
if (!defined('MEDIAWIKI')) {
    echo "This is an extension to the MediaWiki package and cannot be run standalone.\n";
    die(-1);
}
/* Configuration */
//Credits
$wgExtensionCredits['parserhook'][] = array('path' => __FILE__, 'name' => 'HelperScripts', 'author' => 'Arent van Korlaar', 'version' => '1.0', 'url' => 'https://manuscriptdesk.uantwerpen.be', 'description' => 'This extension provides helper scripts for the Manuscript Desk');
//Shortcut to this extension directory
$dir = __DIR__ . '/';
//Auto load classes
$wgAutoloadClasses['SpecialHelperScripts'] = $dir . 'specials/SpecialHelperScripts.php';
$wgAutoloadClasses['HelperScriptsViewer'] = $dir . 'specials/HelperScriptsViewer.php';
$wgAutoloadClasses['AlphabetNumbersUpdater'] = $dir . 'specials/AlphabetNumbersUpdater.php';
$wgAutoloadClasses['HelperScriptsDeleteWrapper'] = $dir . 'specials/HelperScriptsDeleteWrapper.php';
$wgAutoloadClasses['HelperScriptsRequestProcessor'] = $dir . 'specials/HelperScriptsRequestProcessor.php';
$wgAutoloadClasses['HelperScriptsHooks'] = $dir . 'HelperScripts.hooks.php';
$wgExtensionMessagesFiles['HelperScripts'] = $dir . 'HelperScripts.i18n.php';
$wgSpecialPages['HelperScripts'] = 'SpecialHelperScripts';
//Instantiate the NewManuscriptHooks class and register the hooks
$helperscripts_hooks = ObjectRegistry::getInstance()->getHelperScriptsHooks();
$wgHooks['BeforePageDisplay'][] = array($helperscripts_hooks, 'onBeforePageDisplay');
$wgHooks['UnitTestsList'][] = array($helperscripts_hooks, 'onUnitTestsList');
Пример #10
0
 /**
  * Check if the offset exists
  *
  * @param   int     $offset The offset
  * @return  bool
  */
 public function offsetExists($offset)
 {
     if (false === ($result = parent::offsetExists($offset))) {
         $result = apc_exists($this->_namespace . '-' . $offset);
     }
     return $result;
 }
 public function setRequestProcessor()
 {
     if (isset($this->request_processor)) {
         return;
     }
     return $this->request_processor = ObjectRegistry::getInstance()->getHelperScriptsRequestProcessor($this->getRequest());
 }
Пример #12
0
 /**
  * Clears APC cache
  *
  * @return $this
  */
 public function clear()
 {
     // Clear user cache
     apc_clear_cache('user');
     return parent::clear();
 }
 private function getCollectionMetadata($collection_title)
 {
     $wrapper = ObjectRegistry::getInstance()->getAllCollectionsWrapper();
     return $wrapper->getSingleCollectionMetadata($collection_title);
 }
 public function setRequestProcessor()
 {
     if (isset($this->request_processor)) {
         return;
     }
     return $this->request_processor = ObjectRegistry::getInstance()->getStylometricAnalysisRequestProcessor($this->getRequest());
 }
Пример #15
0
$dir = __DIR__ . '/';
//Auto load classes
$wgAutoloadClasses['NewManuscriptImageValidator'] = $dir . 'specials/NewManuscriptImageValidator.php';
$wgAutoloadClasses['NewManuscriptPaths'] = $dir . 'specials/NewManuscriptPaths.php';
$wgAutoloadClasses['NewManuscriptRequestProcessor'] = $dir . 'specials/NewManuscriptRequestProcessor.php';
$wgAutoloadClasses['NewManuscriptUploadForm'] = $dir . 'specials/NewManuscriptUploadForm.php';
$wgAutoloadClasses['NewManuscriptViewer'] = $dir . 'specials/NewManuscriptViewer.php';
$wgAutoloadClasses['NewManuscriptWrapper'] = $dir . 'specials/NewManuscriptWrapper.php';
$wgAutoloadClasses['SlicerExecuter'] = $dir . 'specials/SlicerExecuter.php';
$wgAutoloadClasses['SpecialNewManuscript'] = $dir . 'specials/SpecialNewManuscript.php';
$wgExtensionMessagesFiles['NewManuscript'] = $dir . 'NewManuscript.i18n.php';
$wgAutoloadClasses['NewManuscriptHooks'] = $dir . 'NewManuscript.hooks.php';
$wgAutoloadClasses['DatabaseTestInserter'] = $dir . '/tests/DatabaseTestInserter.php';
$wgSpecialPages['NewManuscript'] = 'SpecialNewManuscript';
//Extra files containing CSS and javascript loaded later
$wgResourceModules['ext.zoomviewercss'] = array('localBasePath' => dirname(__FILE__), 'styles' => 'css/ext.zoomviewercss.css');
$wgResourceModules['ext.manuscriptpagecss'] = array('localBasePath' => dirname(__FILE__), 'styles' => 'css/ext.manuscriptpagecss.css');
$wgResourceModules['ext.newmanuscriptbuttoncontroller'] = array('scripts' => array('js/ext.newmanuscriptbuttoncontroller.js'), 'localBasePath' => __DIR__, 'remoteExtPath' => 'NewManuscript');
//Instantiate the NewManuscriptHooks class and register the hooks
$newmanuscript_hooks = ObjectRegistry::getInstance()->getNewManuscriptHooks();
$wgHooks['EditPage::showEditForm:fields'][] = array($newmanuscript_hooks, 'onEditPageShowEditFormInitial');
$wgHooks['MediaWikiPerformAction'][] = array($newmanuscript_hooks, 'onMediaWikiPerformAction');
$wgHooks['MediaWikiPerformAction'][] = array($newmanuscript_hooks, 'onMediaWikiPerformRenderAction');
$wgHooks['RawPageViewBeforeOutput'][] = array($newmanuscript_hooks, 'onRawPageViewBeforeOutput');
$wgHooks['ParserFirstCallInit'][] = array($newmanuscript_hooks, 'register');
$wgHooks['AbortMove'][] = array($newmanuscript_hooks, 'onAbortMove');
$wgHooks['ArticleDelete'][] = array($newmanuscript_hooks, 'onArticleDelete');
$wgHooks['PageContentSave'][] = array($newmanuscript_hooks, 'onPageContentSave');
$wgHooks['BeforePageDisplay'][] = array($newmanuscript_hooks, 'onBeforePageDisplay');
$wgHooks['UnitTestsList'][] = array($newmanuscript_hooks, 'onUnitTestsList');
$wgHooks['OutputPageParserOutput'][] = array($newmanuscript_hooks, 'onOutputPageParserOutput');
    echo "This is an extension to the MediaWiki package and cannot be run standalone.\n";
    die(-1);
}
/* Configuration */
//Credits
$wgExtensionCredits['parserhook'][] = array('path' => __FILE__, 'name' => 'stylometricAnalysis', 'author' => 'Arent van Korlaar', 'version' => '1.0', 'url' => 'https://manuscriptdesk.uantwerpen.be', 'description' => 'This extension permits users to perform Stylometric Analysis on texts for the Manuscript Desk.', 'descriptionmsg' => 'stylometricanalysis-desc');
//Shortcut to this extension directory
$dir = __DIR__ . '/';
//Auto load classes
$wgAutoloadClasses['StylometricAnalysisHooks'] = $dir . '/StylometricAnalysis.hooks.php';
$wgExtensionMessagesFiles['StylometricAnalysis'] = $dir . '/StylometricAnalysis.i18n.php';
$wgAutoloadClasses['StylometricAnalysisViewer'] = $dir . '/specials/StylometricAnalysisViewer.php';
$wgAutoloadClasses['StylometricAnalysisRequestProcessor'] = $dir . '/specials/StylometricAnalysisRequestProcessor.php';
$wgAutoloadClasses['StylometricAnalysisWrapper'] = $dir . '/specials/StylometricAnalysisWrapper.php';
////Register auto load for the special page classes and register special pages
$wgAutoloadClasses['SpecialStylometricAnalysis'] = $dir . '/specials/SpecialStylometricAnalysis.php';
$wgSpecialPages['StylometricAnalysis'] = 'SpecialStylometricAnalysis';
//Extra file loaded later
$wgResourceModules['ext.stylometricanalysiscss'] = array('localBasePath' => dirname(__FILE__) . '/css', 'styles' => '/ext.stylometricanalysiscss.css');
$wgResourceModules['ext.stylometricanalysisbuttoncontroller'] = array('localBasePath' => dirname(__FILE__) . '/js', 'scripts' => '/ext.stylometricanalysisbuttoncontroller.js', 'messages' => array('stylometricanalysis-error-manycollections'));
$wgResourceModules['ext.stylometricanalysissvg'] = array('localBasePath' => dirname(__FILE__) . '/js', 'scripts' => array('/svg-pan-zoom.min.js', '/ext.stylometricanalysissvg.js'));
//Instantiate the stylometricAnalysisHooks class and register the hooks
$stylometricanalysis_hooks = ObjectRegistry::getInstance()->getStylometricAnalysisHooks();
$wgHooks['MediaWikiPerformAction'][] = array($stylometricanalysis_hooks, 'onMediaWikiPerformAction');
$wgHooks['AbortMove'][] = array($stylometricanalysis_hooks, 'onAbortMove');
$wgHooks['ArticleDelete'][] = array($stylometricanalysis_hooks, 'onArticleDelete');
$wgHooks['PageContentSave'][] = array($stylometricanalysis_hooks, 'onPageContentSave');
$wgHooks['BeforePageDisplay'][] = array($stylometricanalysis_hooks, 'onBeforePageDisplay');
$wgHooks['ResourceLoaderGetConfigVars'][] = array($stylometricanalysis_hooks, 'onResourceLoaderGetConfigVars');
$wgHooks['UnitTestsList'][] = array($stylometricanalysis_hooks, 'onUnitTestsList');
$wgHooks['OutputPageParserOutput'][] = array($stylometricanalysis_hooks, 'onOutputPageParserOutput');
Пример #17
0
 /**
  * ArticleDelete hook. Prevent users from deleting collations they have not uploaded
  */
 public function onArticleDelete(WikiPage &$wikipage, User &$user, &$reason, &$error)
 {
     try {
         $title = $wikipage->getTitle();
         if (!$this->isCollationsNamespace($title)) {
             return true;
         }
         if (!$this->currentUserIsASysop($user)) {
             $error = '<br>' . $this->getMessage('collatehooks-nodeletepermission') . '.';
             return false;
         }
         $deleter = ObjectRegistry::getInstance()->getManuscriptDeskDeleter();
         $deleter->deleteCollationData($title->getPrefixedUrl());
         return true;
     } catch (Exception $e) {
         return true;
     }
 }
Пример #18
0
 static function getInstance()
 {
     if (is_null(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Пример #19
0
    die(-1);
}
/* Configuration */
//Credits
$wgExtensionCredits['parserhook'][] = array('path' => __FILE__, 'name' => 'Collate', 'author' => 'Arent van Korlaar', 'version' => '1.0', 'url' => 'https://manuscriptdesk.uantwerpen.be', 'description' => 'This extension permits users to collate texts for the Manuscript Desk.');
//Shortcut to this extension directory
$dir = __DIR__ . '/';
$dir2 = dirname(__FILE__);
$dirbasename = basename($dir2);
//Auto load classes
$wgAutoloadClasses['CollateHooks'] = $dir . '/Collate.hooks.php';
$wgAutoloadClasses['CollatexConverter'] = $dir . '/specials/CollatexConverter.php';
$wgAutoloadClasses['CollateWrapper'] = $dir . '/specials/CollateWrapper.php';
$wgAutoloadClasses['CollateViewer'] = $dir . '/specials/CollateViewer.php';
$wgAutoloadClasses['CollateRequestProcessor'] = $dir . 'specials/CollateRequestProcessor.php';
$wgExtensionMessagesFiles['Collate'] = __DIR__ . '/Collate.i18n.php';
//Register auto load for the special page classes and register special pages
$wgAutoloadClasses['SpecialCollate'] = $dir . '/specials/SpecialCollate.php';
$wgSpecialPages['Collate'] = 'SpecialCollate';
//Extra file loaded later
$wgResourceModules['ext.collatecss'] = array('localBasePath' => dirname(__FILE__), 'styles' => '/css/ext.collatecss.css');
$wgResourceModules['ext.collatebuttoncontroller'] = array('scripts' => array('js/ext.collatebuttoncontroller.js'), 'localBasePath' => __DIR__, 'remoteExtPath' => 'Collate', 'messages' => array('collate-error-manytexts'));
//Instantiate the CollateHooks class and register the hooks
$collate_hooks = ObjectRegistry::getInstance()->getCollateHooks();
$wgHooks['MediaWikiPerformAction'][] = array($collate_hooks, 'onMediaWikiPerformAction');
$wgHooks['AbortMove'][] = array($collate_hooks, 'onAbortMove');
$wgHooks['ArticleDelete'][] = array($collate_hooks, 'onArticleDelete');
$wgHooks['PageContentSave'][] = array($collate_hooks, 'onPageContentSave');
$wgHooks['BeforePageDisplay'][] = array($collate_hooks, 'onBeforePageDisplay');
$wgHooks['ResourceLoaderGetConfigVars'][] = array($collate_hooks, 'onResourceLoaderGetConfigVars');
$wgHooks['OutputPageParserOutput'][] = array($collate_hooks, 'onOutputPageParserOutput');
 /**
  * Get and show the images and the metatable for the stylometric analysis 
  */
 private function getStylometricAnalysisResultVisualization($full_linkpath1, $visualization1, $full_linkpath2, $visualization2, $pystyl_config)
 {
     $html = '';
     $html .= "<div id='visualization-wrap' style='display:block;'>";
     $html .= "<div id='visualization-wrap1'>";
     $html .= "<h2>Visalisation 1: " . ucfirst($visualization1) . "</h2>";
     $html .= "<object class='stylometricanalysis-image' id='stylometricanalysis-svg1' type='image/svg+xml' data='{$full_linkpath1}'>Your browser does not support SVG files, and so your visualization cannot dislpay</object>";
     $html .= "</div>";
     $html .= "<div id='visualization-wrap2'>";
     $html .= "<h2>Visualisation 2: " . ucfirst($visualization2) . "</h2>";
     $html .= "<object class='stylometricanalysis-image' id='stylometricanalysis-svg2' type='image/svg+xml' data='{$full_linkpath2}'>Your browser does not support SVG files, and so your visualization cannot dislpay</object>";
     $html .= "</div>";
     $html .= "</div>";
     $html .= "<center><h2>" . $this->out->msg('stylometricanalysis-analysisconfiguration') . "</h2><br></center>";
     $page_metatable = ObjectRegistry::getInstance()->getPageMetaTable();
     $page_metatable->setInputValuesFromArray($pystyl_config);
     $html .= $page_metatable->renderTable();
     return $html;
 }
Пример #21
0
 protected function getTextProcessor()
 {
     return ObjectRegistry::getInstance()->getManuscriptDeskBaseTextProcessor();
 }