* @copyright Copyright (C) 2013 Uwe Steinmann * @version Release: @package_version@ */ /** * Include parent class */ //require_once("class.Bootstrap.php"); /** * Class which outputs the html page for ExtensionMgr view * * @category DMS * @package SeedDMS * @author Uwe Steinmann * @copyright Copyright (C) 2013 Uwe Steinmann * @version Release: @package_version@ */ class SeedDMS_View_ExtensionMgr extends SeedDMS_Theme_Style { function js() { /* {{{ */ header('Content-Type: application/javascript; charset=UTF-8'); ?> $(document).ready( function() { $('body').on('click', 'a.download', function(ev){ // $('a.download').click(function(ev){ var element = $(this); $('#'+element.data('extname')+'-download').submit(); /* var element = $(this); ev.preventDefault(); $.ajax({url: '../op/op.ExtensionMgr.php', type: 'POST', dataType: "json", data: {action: 'download', 'formtoken': '', 'extname': element.data('extname')}, success: function(data) { noty({ text: data.msg, type: (data.error) ? 'error' : 'success', dismissQueue: true, layout: 'topRight', theme: 'defaultTheme', timeout: 1500, }); } }); */ }); $('body').on('click', 'a.toggle', function(ev){ // $('a.toggle').click(function(ev){ var element = $(this); ev.preventDefault(); $.ajax({url: '../op/op.ExtensionMgr.php', type: 'POST', dataType: "json", data: {action: 'toggle', 'formtoken': '', 'extname': element.data('extname')}, success: function(data) { noty({ text: data.msg, type: (data.error) ? 'error' : 'success', dismissQueue: true, layout: 'topRight', theme: 'defaultTheme', timeout: 1500, }); $('div.ajax').trigger('update'); } }); }); $('body').on('click', 'a.import', function(ev){ var element = $(this); $('#'+element.data('extname')+'-import').submit(); }); $("#extensionfilter").on("keyup", function() { var value = $(this).val().toLowerCase(); $("#extensionlist tbody tr").filter(function() { $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1) }); }); }); /* This function is called after the list of installed extension is updated */ function filterList() { var value = $("#extensionfilter").val().toLowerCase(); $("#extensionlist tbody tr").filter(function() { $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1) }); } printFileChooserJs(); } /* }}} */ function info_versions() { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; $extmgr = $this->params['extmgr']; $extname = $this->params['extname']; $extconf = $extmgr->getExtensionConfiguration(); echo "\n"; print "\n\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; $list = $extmgr->getExtensionListByName($extname); foreach($list as $re) { $extmgr->checkExtensionByName($re['name'], $re); $checkmsgs = $extmgr->getErrorMsgs(); $needsupdate = !isset($extconf[$re['name']]) || SeedDMS_Extension_Mgr::cmpVersion($re['version'], $extconf[$re['name']]['version']) > 0; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } echo "
".getMLText('name')."".getMLText('version')."
".($re['icon-data'] ? ''.$re['name'].'' : '')."".$re['title']."
".$re['description'].""; echo "
".getMLText('author').": ".$re['author']['name'].", ".$re['author']['company'].""; if($checkmsgs) echo "
getImgPath("attention.gif")."\"> ".implode('
', $checkmsgs)."
"; echo "
".$re['version']."
".$re['releasedate']."
"; echo "
"; if(!$checkmsgs && $extmgr->isWritableExtDir()) echo "
".createHiddenFieldWithKey('extensionmgr')."
"; echo "
"; echo "
\n"; } /* }}} */ function info_changelog() { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; $extmgr = $this->params['extmgr']; $extname = $this->params['extname']; $extconf = $extmgr->getExtensionConfiguration(); $list = $extmgr->getExtensionListByName($extname); /* Just show the changelog of the latest version */ $re = array_shift($list); echo '
'.$re['changelog']."
"; } /* }}} */ function changelog() { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; $extdir = $this->params['extdir']; $extmgr = $this->params['extmgr']; $extname = $this->params['extname']; $extconf = $extmgr->getExtensionConfiguration(); if(isset($extconf[$extname])) { $extconf = $extconf[$extname]; if(!empty($extconf['changelog']) && file_exists($extdir."/".$extname."/".$extconf['changelog'])) { echo '
'.file_get_contents($extdir."/".$extname."/".$extconf['changelog'])."
"; } } } /* }}} */ function readme() { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; $session = $this->params['session']; $extdir = $this->params['extdir']; $extmgr = $this->params['extmgr']; $extname = $this->params['extname']; $extconf = $extmgr->getExtensionConfiguration(); if(isset($extconf[$extname])) { $extconf = $extconf[$extname]; $Parsedown = new Parsedown(); if(file_exists($extdir."/".$extname."/README.".$session->getLanguage().".md")) { echo $Parsedown->text(file_get_contents($extdir."/".$extname."/README.".$session->getLanguage().".md")); } elseif(file_exists($extdir."/".$extname."/README.md")) { echo $Parsedown->text(file_get_contents($extdir."/".$extname."/README.md")); } } } /* }}} */ function installedList() { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; $settings = $this->params['settings']; $session = $this->params['session']; $httproot = $this->params['httproot']; $extmgr = $this->params['extmgr']; $extdir = $this->params['extdir']; $extconf = $extmgr->getExtensionConfiguration(); echo "\n"; print "\n\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; $errmsgs = array(); foreach($extconf as $extname=>$extconf) { $errmsgs = array(); $check = $extmgr->checkExtensionByDir($extname); if(!$settings->extensionIsDisabled($extname)) { // if(!isset($extconf['disable']) || $extconf['disable'] == false) { if(!$check) echo ""; else echo ""; } else { echo ""; } $errmsgs = $extmgr->getErrorMsgs(); echo ""; echo ""; echo ""; echo ""; echo "\n"; } echo "
".getMLText('name')."".getMLText('version')."
"; if($extconf['icon']) echo "\"".$extname."\""; echo "".$extconf['title']; echo "
".$extconf['description'].""; echo "
".getMLText('author').": ".$extconf['author']['name'].", ".$extconf['author']['company'].""; if($errmsgs) echo "
getImgPath("attention.gif")."\"> ".implode('
', $errmsgs)."
"; echo "
".$extconf['version']; echo "
".$extconf['releasedate'].""; echo "
"; echo "
"; if(file_exists($extdir."/".$extname."/README.".$session->getLanguage().".md") || file_exists($extdir."/".$extname."/README.md")) { echo $this->getModalBoxLink(array('target'=>'extensionReadme', 'remote'=>'out.ExtensionMgr.php?action=readme&extensionname='.$extname, 'class'=>'', 'title'=>'', 'attributes'=>array('title'=>getMLText('show_extension_readme')))); } if(!empty($extconf['changelog']) && file_exists($extdir."/".$extname."/".$extconf['changelog'])) { echo $this->getModalBoxLink(array('target'=>'extensionChangelog', 'remote'=>'out.ExtensionMgr.php?action=changelog&extensionname='.$extname, 'class'=>'', 'title'=>'', 'attributes'=>array('title'=>getMLText('show_extension_changelog')))); } if($extconf['config']) echo ""; if($settings->_enableExtensionDownload) echo "
".createHiddenFieldWithKey('extensionmgr')."
"; if(is_writeable($settings->_configFilePath) && $check) { if(!$settings->extensionIsDisabled($extname)) { echo ' '; } else { echo ' '; } } echo "
"; echo "
\n"; } /* }}} */ function show() { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; $settings = $this->params['settings']; $httproot = $this->params['httproot']; $extdir = $this->params['extdir']; $version = $this->params['version']; $extmgr = $this->params['extmgr']; $extconf = $extmgr->getExtensionConfiguration(); $currenttab = $this->params['currenttab']; $reposurl = $this->params['reposurl']; $this->htmlStartPage(getMLText("admin_tools")); $this->globalNavigation(); $this->contentStart(); $this->pageNavigation(getMLText("admin_tools"), "admin_tools"); $this->contentHeading(getMLText("extension_manager")); $this->rowStart(); $this->columnStart(4); if($settings->_enableExtensionImport && $extmgr->isWritableExtDir()) { ?>
formField( getMLText("extension_archive"), $this->getFileChooserHtml('userfile', false) ); $this->formSubmit(" ".getMLText('import_extension')); ?>
_enableExtensionImport) echo "
".getMLText('extension_mgr_no_upload')."
"; else echo "
".getMLText('extension_mgr_upload_disabled')."
"; } if(!is_writeable($settings->_configFilePath)) { $this->warningMsg(getMLText("extension_mgr_no_toggle")); } $this->columnEnd(); $this->columnStart(8); ?>
showStartPaneContent('installed', (!$currenttab || $currenttab == 'installed')); ?>
installedList(); ?>

formSubmit(" " . getMLText('refresh'));?>

showEndPaneContent('installed', $currenttab); ?> showStartPaneContent('repository', ($currenttab == 'repository')); ?> \n"; print "\n\n"; print "\n"; print "".getMLText('name')."\n"; print "".getMLText('version')."\n"; print "\n"; print "\n"; $list = $extmgr->getExtensionList(); foreach($list as $en=>$re) { if(!$re) continue; $extmgr->checkExtensionByName($en, $re); $checkmsgs = $extmgr->getErrorMsgs(); $needsupdate = !isset($extconf[$re['name']]) || SeedDMS_Extension_Mgr::cmpVersion($re['version'], $extconf[$re['name']]['version']) > 0; echo ""; echo "".($re['icon-data'] ? ''.$re['name'].'' : '').""; echo "".$re['title']; echo "
".$re['description'].""; echo "
".getMLText('author').": ".$re['author']['name'].", ".$re['author']['company'].""; if($checkmsgs) echo "
getImgPath("attention.gif")."\"> ".implode('
', $checkmsgs)."
"; echo ""; echo "".$re['version']."
".$re['releasedate'].""; echo ""; echo "
"; echo $this->getModalBoxLink(array('target'=>'extensionInfo', 'remote'=>'out.ExtensionMgr.php?action=info_versions&extensionname='.$re['name'], 'class'=>'', 'title'=>'')); echo $this->getModalBoxLink(array('target'=>'extensionChangelog', 'remote'=>'out.ExtensionMgr.php?action=info_changelog&extensionname='.$re['name'], 'class'=>'', 'title'=>'')); if(!$checkmsgs && $settings->_enableExtensionImportFromRepository && $extmgr->isWritableExtDir()) echo "
".createHiddenFieldWithKey('extensionmgr')."
"; echo "
"; echo ""; echo ""; } echo "\n"; ?>
formSubmit(" " . getMLText('force_update'));?>
showEndPaneContent('repository', $currenttab); ?>
columnEnd(); $this->rowEnd(); echo $this->getModalBox(array('id'=>'extensionInfo', 'title'=>getMLText('extension_version_list'), 'content'=>'

'.getMLText('extension_loading').'

', 'buttons'=>array(array('title'=>getMLText('close'))))); echo $this->getModalBox(array('id'=>'extensionChangelog', 'title'=>getMLText('extension_changelog'), 'content'=>'

'.getMLText('changelog_loading').'

', 'buttons'=>array(array('title'=>getMLText('close'))))); echo $this->getModalBox(array('id'=>'extensionReadme', 'title'=>getMLText('extension_readme'), 'content'=>'

'.getMLText('readme_loading').'

', 'buttons'=>array(array('title'=>getMLText('close'))))); $this->contentEnd(); $this->htmlEndPage(); } /* }}} */ } ?>