00001 <?php
00002
00015
00016
00017
00018 import('core.Handler');
00019
00020 class ThesisHandler extends Handler {
00021
00025 function index() {
00026 ThesisHandler::setupTemplate();
00027 $journal = &Request::getJournal();
00028
00029 if ($journal != null) {
00030 $journalId = $journal->getJournalId();
00031 } else {
00032 Request::redirect(null, 'index');
00033 }
00034
00035 $thesisPlugin = &PluginRegistry::getPlugin('generic', 'ThesisPlugin');
00036
00037 if ($thesisPlugin != null) {
00038 $thesesEnabled = $thesisPlugin->getEnabled();
00039 }
00040
00041 if ($thesesEnabled) {
00042 $searchField = null;
00043 $searchMatch = null;
00044 $search = Request::getUserVar('search');
00045
00046 if (isset($search)) {
00047 $searchField = Request::getUserVar('searchField');
00048 $searchMatch = Request::getUserVar('searchMatch');
00049 }
00050
00051 $thesisDao = &DAORegistry::getDAO('ThesisDAO');
00052 $rangeInfo = &Handler::getRangeInfo('theses');
00053 $resultOrder = $thesisPlugin->getSetting($journalId, 'thesisOrder');
00054
00055 $theses = &$thesisDao->getActiveThesesByJournalId($journalId, $searchField, $search, $searchMatch, null, null, $resultOrder, $rangeInfo);
00056 $thesisIntroduction = $thesisPlugin->getSetting($journalId, 'thesisIntroduction');
00057
00058 $templateMgr = &TemplateManager::getManager();
00059 $templateMgr->assign('theses', $theses);
00060 $templateMgr->assign('thesisIntroduction', $thesisIntroduction);
00061 $templateMgr->assign('searchField', $searchField);
00062 $templateMgr->assign('searchMatch', $searchMatch);
00063 $templateMgr->assign('search', $search);
00064
00065 $fieldOptions = Array(
00066 THESIS_FIELD_FIRSTNAME => 'plugins.generic.thesis.studentFirstName',
00067 THESIS_FIELD_LASTNAME => 'plugins.generic.thesis.studentLastName',
00068 THESIS_FIELD_DEPARTMENT => 'plugins.generic.thesis.department',
00069 THESIS_FIELD_UNIVERSITY => 'plugins.generic.thesis.university',
00070 THESIS_FIELD_TITLE => 'plugins.generic.thesis.title',
00071 THESIS_FIELD_ABSTRACT => 'plugins.generic.thesis.abstract',
00072 THESIS_FIELD_SUBJECT => 'plugins.generic.thesis.keyword'
00073 );
00074 $templateMgr->assign('fieldOptions', $fieldOptions);
00075
00076 $templateMgr->display($thesisPlugin->getTemplatePath() . 'index.tpl');
00077 } else {
00078 Request::redirect(null, 'index');
00079 }
00080 }
00081
00085 function submit() {
00086 ThesisHandler::setupTemplate();
00087 $journal = &Request::getJournal();
00088
00089 if ($journal != null) {
00090 $journalId = $journal->getJournalId();
00091 } else {
00092 Request::redirect(null, 'index');
00093 }
00094
00095 $thesisPlugin = &PluginRegistry::getPlugin('generic', 'ThesisPlugin');
00096
00097 if ($thesisPlugin != null) {
00098 $thesesEnabled = $thesisPlugin->getEnabled();
00099 }
00100
00101 if ($thesesEnabled) {
00102 $thesisPlugin->import('StudentThesisForm');
00103 $enableUploadCode = $thesisPlugin->getSetting($journalId, 'enableUploadCode');
00104 $journalSettingsDao = &DAORegistry::getDAO('JournalSettingsDAO');
00105 $journalSettings = &$journalSettingsDao->getJournalSettings($journalId);
00106
00107 $templateMgr = &TemplateManager::getManager();
00108 $templateMgr->append('pageHierarchy', array(Request::url(null, 'thesis'), 'plugins.generic.thesis.theses'));
00109 $templateMgr->assign('journalSettings', $journalSettings);
00110 $thesisDao = &DAORegistry::getDAO('ThesisDAO');
00111
00112 $thesisForm = &new StudentThesisForm();
00113 $thesisForm->initData();
00114 $thesisForm->display();
00115
00116 } else {
00117 Request::redirect(null, 'index');
00118 }
00119 }
00120
00125 function view($args = array()) {
00126 ThesisHandler::setupTemplate();
00127 $journal = &Request::getJournal();
00128
00129 if ($journal != null) {
00130 $journalId = $journal->getJournalId();
00131 } else {
00132 Request::redirect(null, 'index');
00133 }
00134
00135 $thesisPlugin = &PluginRegistry::getPlugin('generic', 'ThesisPlugin');
00136
00137 if ($thesisPlugin != null) {
00138 $thesesEnabled = $thesisPlugin->getEnabled();
00139 }
00140
00141 $thesisId = !isset($args) || empty($args) ? null : (int) $args[0];
00142 $thesisDao = &DAORegistry::getDAO('ThesisDAO');
00143
00144 if ($thesesEnabled) {
00145 if (($thesisId != null) && ($thesisDao->getThesisJournalId($thesisId) == $journalId) && $thesisDao->isThesisActive($thesisId)) {
00146 $thesis = &$thesisDao->getThesis($thesisId);
00147
00148 $templateMgr = &TemplateManager::getManager();
00149 $templateMgr->assign('journal', $journal);
00150 $templateMgr->assign('thesis', $thesis);
00151 $templateMgr->append('pageHierarchy', array(Request::url(null, 'thesis'), 'plugins.generic.thesis.theses'));
00152 $thesisMetaCustomHeaders = $templateMgr->fetch($thesisPlugin->getTemplatePath() . 'metadata.tpl');
00153 $metaCustomHeaders = $templateMgr->get_template_vars('metaCustomHeaders');
00154 $templateMgr->assign('metaCustomHeaders', $metaCustomHeaders . "\n" . $thesisMetaCustomHeaders);
00155 $templateMgr->display($thesisPlugin->getTemplatePath() . 'view.tpl');
00156 } else {
00157 Request::redirect(null, 'thesis');
00158 }
00159 } else {
00160 Request::redirect(null, 'index');
00161 }
00162 }
00163
00167 function save() {
00168 parent::validate();
00169 $journal = &Request::getJournal();
00170
00171 if ($journal != null) {
00172 $journalId = $journal->getJournalId();
00173 } else {
00174 Request::redirect(null, 'index');
00175 }
00176
00177 $thesisPlugin = &PluginRegistry::getPlugin('generic', 'ThesisPlugin');
00178
00179 if ($thesisPlugin != null) {
00180 $thesesEnabled = $thesisPlugin->getEnabled();
00181 }
00182
00183 if ($thesesEnabled) {
00184 $thesisDao = &DAORegistry::getDAO('ThesisDAO');
00185 $thesisPlugin->import('StudentThesisForm');
00186
00187 $thesisForm = &new StudentThesisForm();
00188 $thesisForm->readInputData();
00189
00190 if ($thesisForm->validate()) {
00191 $thesisForm->execute();
00192
00193 Request::redirect(null, 'thesis');
00194
00195 } else {
00196 ThesisHandler::setupTemplate();
00197
00198 $journalSettingsDao = &DAORegistry::getDAO('JournalSettingsDAO');
00199 $journalSettings = &$journalSettingsDao->getJournalSettings($journalId);
00200
00201 $templateMgr = &TemplateManager::getManager();
00202 $templateMgr->assign('journalSettings', $journalSettings);
00203 $thesisForm->display();
00204 }
00205
00206 } else {
00207 Request::redirect(null, 'index');
00208 }
00209 }
00210
00214 function viewCaptcha($args) {
00215 $captchaId = (int) array_shift($args);
00216 import('captcha.CaptchaManager');
00217 $captchaManager =& new CaptchaManager();
00218 if ($captchaManager->isEnabled()) {
00219 $captchaDao =& DAORegistry::getDAO('CaptchaDAO');
00220 $captcha =& $captchaDao->getCaptcha($captchaId);
00221 if ($captcha) {
00222 $captchaManager->generateImage($captcha);
00223 exit();
00224 }
00225 }
00226 Request::redirect(null, 'thesis');
00227 }
00228
00233 function setupTemplate($subclass = false) {
00234 parent::validate();
00235
00236 $templateMgr = &TemplateManager::getManager();
00237 $templateMgr->assign('pageHierachy', array(array(Request::url(null, 'theses'), 'plugins.generic.thesis.theses')));
00238 }
00239 }
00240
00241 ?>