- Timestamp:
- 03/24/10 15:14:25 (11 years ago)
- Location:
- trunk/server/www/app
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/www/app/config/sql/schema.php
r329 r330 1 1 <?php 2 2 /* SVN FILE: $Id$ */ 3 /* App schema generated on: 2010-03-2 3 15:03:08 : 1269352928*/3 /* App schema generated on: 2010-03-24 14:03:22 : 1269436882*/ 4 4 class AppSchema extends CakeSchema { 5 5 var $name = 'App'; … … 182 182 'state' => array('type' => 'integer', 'null' => false, 'default' => '1'), 183 183 'state_info' => array('type' => 'string', 'null' => false, 'default' => NULL), 184 'verified' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => 4), 185 'description' => array('type' => 'text', 'null' => false, 'default' => NULL), 186 'description_html' => array('type' => 'text', 'null' => false, 'default' => NULL), 184 187 'created' => array('type' => 'datetime', 'null' => true, 'default' => NULL), 185 188 'updated' => array('type' => 'datetime', 'null' => true, 'default' => NULL), -
trunk/server/www/app/controllers/jobs_controller.php
r329 r330 50 50 public function add($request_id = null) 51 51 { 52 $this->helpers[] = 'Javascript'; 53 52 54 if (!empty($this->data)) { 53 55 // Load the request … … 104 106 )); 105 107 108 // Finally add the description to the result. 109 $this->Job->Result->set($this->data['Result']); 110 $this->Job->Result->save(); 111 106 112 // All done! 107 113 $this->redirect(array('controller' => 'requests', 'action' => 'view', $this->data['Job']['request_id'])); … … 109 115 110 116 if (empty($this->data)) { 111 $this->data = array('Job' => array( 112 'request_id' => $request_id, 113 )); 117 $this->data = array( 118 'Job' => array( 119 'request_id' => $request_id, 120 ), 121 'Result' => array( 122 'verified' => 0, 123 'description' => '', 124 ), 125 ); 114 126 } 115 127 … … 117 129 $applications = $this->Job->Application->find('list'); 118 130 119 $this->set(compact('platforms', 'applications')); 131 $verify = array( 132 Result::VERIFY_PENDING => __('Not manually verified', true), 133 Result::VERIFY_PASS => __('Correct result', true), 134 Result::VERIFY_FAIL => __('Incorrect result', true), 135 ); 136 137 $this->set(compact('platforms', 'applications', 'verify')); 120 138 $this->render('edit'); 121 139 } … … 163 181 public function edit($id = null) 164 182 { 183 $this->helpers[] = 'Javascript'; 184 165 185 if (!empty($this->data)) { 166 186 if (!$this->Job->Request->checkAccess($this->AuthCert->user('id'), 'write', $this->data['Job']['request_id'])) { … … 170 190 171 191 if ($this->Job->save($this->data)) { 192 $this->data['Result']['id'] = $this->Job->field('result_id'); 193 $this->Job->Result->save($this->data); 194 172 195 $this->Session->setFlash(__('The Job has been saved', true)); 173 $this->redirect(array('controller' => 're quests', 'action'=>'view', $this->data['Job']['request_id']));196 $this->redirect(array('controller' => 'results', 'action'=>'view', $this->data['Result']['id'])); 174 197 } else { 175 198 $this->Session->setFlash(__('The Job could not be saved. Please, try again.', true)); … … 179 202 if (empty($this->data)) { 180 203 $this->Job->id = $id; 181 $this->Job->contain('Request' );204 $this->Job->contain('Request', 'Result'); 182 205 $this->data = $this->Job->read(); 183 206 } … … 185 208 $platforms = $this->Job->Platform->find('list'); 186 209 $applications = $this->Job->Application->find('list'); 187 $this->set(compact('platforms', 'applications')); 210 211 $verify = array( 212 Result::VERIFY_PENDING => __('Not manually verified', true), 213 Result::VERIFY_PASS => __('Correct result', true), 214 Result::VERIFY_FAIL => __('Incorrect result', true), 215 ); 216 217 $this->set(compact('platforms', 'applications', 'verify')); 188 218 } 189 219 -
trunk/server/www/app/controllers/requests_controller.php
r325 r330 112 112 } 113 113 114 115 114 /** 116 115 * Edit a request description … … 136 135 )); 137 136 } 137 138 138 /** 139 139 * Add a new request -
trunk/server/www/app/controllers/results_controller.php
r325 r330 40 40 { 41 41 parent::beforeFilter(); 42 $this->AuthCert->allow('view', ' download');42 $this->AuthCert->allow('view', 'edit', 'download'); 43 43 } 44 44 … … 49 49 * 50 50 * @param string $id The result ID 51 * @param string $type The access type. Should be 'read' or 'write' 51 52 * @param return array An array containing the result. 52 53 */ 53 private function _getResult($id )54 private function _getResult($id, $type = 'read') 54 55 { 55 56 if (!$id) { … … 59 60 60 61 $result = $this->Result->read(null, $id); 61 if (empty($result) || !$this->Result->checkAccess($this->AuthCert->user('id'), 'read', $id)) {62 if (empty($result) || !$this->Result->checkAccess($this->AuthCert->user('id'), $type, $id)) { 62 63 $this->Session->setFlash(__('Invalid Result.', true)); 63 64 $this->redirect(array('controller' => 'requests', 'action'=>'add')); … … 106 107 107 108 /** 109 * Edit a result description 110 * 111 * @param string $id The result ID 112 * @return void 113 */ 114 public function edit($id = null) 115 { 116 $this->helpers[] = 'ResultModel'; 117 $this->helpers[] = 'Javascript'; 118 119 $this->Result->contain(array( 120 'Job', 121 'Job.Application', 122 'Job.Platform', 123 'Mimetype', 124 'Mimetype.Format', 125 )); 126 $result = $this->_getResult($id, 'write'); 127 128 if (!empty($this->data)) { 129 $this->data['Result']['id'] = $id; 130 if (!$this->Result->save($this->data)) { 131 $this->Session->setFlash(__('Unable to save the description', true)); 132 } else { 133 $this->redirect(array('action' => 'view', $id)); 134 } 135 } 136 137 $verify = array( 138 Result::VERIFY_PENDING => __('Not manually verified', true), 139 Result::VERIFY_PASS => __('Correct result', true), 140 Result::VERIFY_FAIL => __('Incorrect result', true), 141 ); 142 143 $this->set(compact('result', 'verify')); 144 } 145 146 /** 108 147 * Action to download a single result 109 148 * -
trunk/server/www/app/models/result.php
r325 r330 29 29 * Request states 30 30 */ 31 const STATE_UPLOADING =1;32 const STATE_POSTPROCESSOR_QUEUED = 2;33 const STATE_SCAN_FOUND =4;34 const STATE_POSTPROCESSOR_FAILED = 8;35 const STATE_FINISHED = 16;31 const STATE_UPLOADING = 1; 32 const STATE_POSTPROCESSOR_QUEUED = 2; 33 const STATE_SCAN_FOUND = 4; 34 const STATE_POSTPROCESSOR_FAILED = 8; 35 const STATE_FINISHED = 16; 36 36 /**#@-*/ 37 37 38 /**#@+ 39 * Manual verification states 40 */ 41 const VERIFY_PENDING = 0; 42 const VERIFY_PASS = 1; 43 const VERIFY_FAIL = 2; 44 /**#@-*/ 45 38 46 /** @var array A result belongs to a job and a factory that created it */ 39 47 public $belongsTo = array('Factory', 'Format'); … … 145 153 $this->Job->saveField('result_id', ''); 146 154 $this->deleteFile(); 155 156 return true; 157 } 158 159 /** 160 * Convert the Markdown description to HTML before saving 161 * @return boolean True to continue saving 162 */ 163 public function beforeSave() 164 { 165 if (isset($this->data['Result']['description'])) { 166 // Convert the description to HTML 167 App::import('Vendor', 'markdown'); 168 App::import('Vendor', 'HTMLPurifier', array('file' => 'htmlpurifier/HTMLPurifier.standalone.php')); 169 170 $config = HTMLPurifier_Config::createDefault(); 171 $config->set('Cache.SerializerPath', CACHE . DS . 'htmlpurifier'); 172 $purifier = new HTMLPurifier($config); 173 174 $desc_html = Markdown($this->data['Result']['description']); 175 $this->data['Result']['description_html'] = $purifier->purify($desc_html); 176 177 // Save the Markdown version to file 178 $path = FILES . $this->field('path') . DS . 'description.txt'; 179 file_put_contents($path, $this->data['Result']['description']); 180 } 147 181 148 182 return true; -
trunk/server/www/app/views/elements/testsuite.ctp
r315 r330 20 20 <td><?php foreach ($request['Validator'] as $validator) { echo $validatorModel->getStateIcon($validator) . ' '; } ?></td> 21 21 <?php foreach ($applications as $application):?> 22 <td> 23 <?php 24 foreach ($request['Job'] as $job) { 25 $match = ( 26 $job['Application']['name'] == $application['Application']['name'] 27 && $job['version'] == $application['Application']['version'] 28 && $job['Format']['code'] == 'odf' 29 ); 22 <?php 23 foreach ($request['Job'] as $job) { 24 $match = ( 25 $job['Application']['name'] == $application['Application']['name'] 26 && $job['version'] == $application['Application']['version'] 27 && $job['Format']['code'] == 'odf' 28 ); 30 29 31 if ($match) { 32 if (!$job['Result'] || !$job['Result']['id']) { 33 echo $html->image('/img/icons/validator-pending.png'); 34 break; 30 if ($match) { 31 $class = 'white'; 32 if ($job['Result']) { 33 switch($job['Result']['verified']) { 34 case Result::VERIFY_PASS: $class = 'green'; break; 35 case Result::VERIFY_FAIL: $class = 'red'; break; 35 36 } 37 } 38 echo '<td class="' . $class . '">'; 36 39 37 if (isset($job['Result']['Validator'])) { 38 foreach ($job['Result']['Validator'] as $validator) { 39 echo $validatorModel->getStateIcon($validator) . ' '; 40 } 41 } 42 43 $request['result_count']--; 40 if (!$job['Result'] || !$job['Result']['id']) { 41 echo $html->image('/img/icons/validator-pending.png'); 44 42 break; 45 43 } 44 45 if (isset($job['Result']['Validator'])) { 46 foreach ($job['Result']['Validator'] as $validator) { 47 echo $validatorModel->getStateIcon($validator) . ' '; 48 } 49 } 50 51 $request['result_count']--; 52 break; 46 53 } 54 } 47 55 48 if (!$match) { 49 echo '-'; 50 } 51 ?> 52 </td> 56 if (!$match) { 57 echo '<td> -'; 58 } 59 ?></td> 53 60 <?php endforeach;?> 54 61 <td> -
trunk/server/www/app/views/helpers/result_model.php
r292 r330 26 26 class ResultModelHelper extends AppHelper 27 27 { 28 public $helpers = array('Html'); 29 28 30 /** 29 31 * Convert Result state to a human readable message … … 60 62 } 61 63 } 64 65 /** 66 * Convert the verification state to a human readable message 67 */ 68 public function getVerified($result) 69 { 70 if (!is_array($result)) { 71 return ''; 72 } 73 74 if (!isset($result['Result'])) { 75 $result = array('Result' => $result); 76 } 77 78 switch ($result['Result']['verified']) { 79 case Result::VERIFY_PASS: 80 return $this->output($this->Html->image('icons/validator-valid.png') . ' ' . __('Correct result', true)); 81 case Result::VERIFY_FAIL: 82 return $this->output($this->Html->image('icons/validator-invalid.png') . ' ' . __('Incorrect result', true)); 83 default: 84 return $this->output(''); 85 } 86 } 62 87 } 63 88 -
trunk/server/www/app/views/jobs/edit.ctp
r325 r330 1 <?php 2 $html->css('wmd', null, array(), false); 3 $javascript->link('showdown', false); 4 $javascript->link('wmd', false); 5 ?> 6 1 7 <div class="jobs form"> 2 8 <?php echo $form->create('Job', array('type' => 'file'));?> 3 <fieldset> 4 <legend> 9 <h3> 5 10 <?php if ($this->action == 'add' || $this->action == 'admin_add') { 6 11 __('Add a manual result'); 7 12 } else { 8 __(' Editthis result');13 __('Settings for this result'); 9 14 } 10 15 ?> 11 </ legend>16 </h3> 12 17 <?php 13 18 if ($this->action == 'edit' || $this->action == 'admin_edit') { … … 27 32 echo $form->input('version'); 28 33 ?> 29 </fieldset> 34 35 <h3><?php __('Manual verification');?></h3> 36 <p><?php __('Have you manually checked if this conversion result is correct?');?></p> 37 <div class="input"> 38 <?php echo $form->radio('Result.verified', $verify, array('legend' => false, 'default' => $this->data['Result']['verified']));?> 39 </div> 40 41 <h3><?php __('Description');?></h3> 42 <div id="wmd-button-bar"></div> 43 <textarea id="wmd-input" name="data[Result][description]"><?php echo h($this->data['Result']['description']);?></textarea> 44 <div id="wmd-preview" class="polaroid"></div> 30 45 <?php echo $form->submit();?> 31 46 </div> -
trunk/server/www/app/views/results/view.ctp
r325 r330 21 21 22 22 </dd> 23 <dt><?php __('Application'); ?></dt> 24 <dd> 25 <?php echo $result['Job']['Application']['name'];?> <?php echo $result['Job']['version'];?> 26 (<?php echo $result['Job']['Platform']['name'];?>) 27 28 </dd> 23 29 <dt><?php __('Format'); ?></dt> 24 30 <dd> … … 29 35 <dd> 30 36 <?php echo $resultModel->getState($result); ?> 37 38 </dd> 39 <dt><?php __('Manual verification'); ?></dt> 40 <dd> 41 <?php echo $resultModel->getVerified($result); ?> 31 42 32 43 </dd> … … 67 78 68 79 if ($writeAccess) { 69 if (!$result['Factory']['id']) { 80 if ($result['Factory']['id']) { 81 echo ' - ' . $html->link(__('Edit', true), array('controller' => 'results', 'action' => 'edit', $result['Result']['id'])); 82 } else { 70 83 echo ' - ' . $html->link(__('Edit', true), array('controller' => 'jobs', 'action' => 'edit', $result['Job']['id'])); 71 84 } … … 77 90 </dl> 78 91 </div> 92 93 <?php 94 if (!empty($result['Result']['description_html'])) { 95 echo '<h3>' . __('Description', true) . '</h3>'; 96 echo $result['Result']['description_html']; 97 } 98 ?> 79 99 80 100 <?php if ($result['Factory']['id']):?> -
trunk/server/www/app/webroot/css/cake.override.css
r329 r330 222 222 223 223 .galleries.view h2 a { font-weight: normal; color: #006bbe; } 224 225 td.red { background-color: #faa; } 226 td.green { background-color: #af8; } 224 227 225 228 /* Mailinglist registration callout */
Note: See TracChangeset
for help on using the changeset viewer.