_a['table'] = 'idf_wikiresourcerevs'; $this->_a['model'] = __CLASS__; $this->_a['cols'] = array( // It is mandatory to have an "id" column. 'id' => array( 'type' => 'Pluf_DB_Field_Sequence', 'blank' => true, ), 'wikiresource' => array( 'type' => 'Pluf_DB_Field_Foreignkey', 'model' => 'IDF_Wiki_Resource', 'blank' => false, 'verbose' => __('resource'), 'relate_name' => 'revisions', ), 'is_head' => array( 'type' => 'Pluf_DB_Field_Boolean', 'blank' => false, 'default' => false, 'help_text' => 'If this revision is the latest, we mark it as being the head revision.', 'index' => true, ), 'summary' => array( 'type' => 'Pluf_DB_Field_Varchar', 'blank' => false, 'size' => 250, 'verbose' => __('summary'), 'help_text' => __('A one line description of the changes.'), ), 'filesize' => array( 'type' => 'Pluf_DB_Field_Integer', 'blank' => false, 'default' => 0, 'verbose' => __('file size in bytes'), ), 'submitter' => array( 'type' => 'Pluf_DB_Field_Foreignkey', 'model' => 'Pluf_User', 'blank' => false, 'verbose' => __('submitter'), 'relate_name' => 'submitted_downloads', ), 'pageusage' => array( 'type' => 'Pluf_DB_Field_Manytomany', 'model' => 'IDF_Wiki_PageRevision', 'blank' => true, 'verbose' => __('page usage'), 'help_text' => 'Records on which pages this resource revision is used.', ), 'creation_dtime' => array( 'type' => 'Pluf_DB_Field_Datetime', 'blank' => true, 'verbose' => __('creation date'), ), ); } function __toString() { return sprintf(__('id %d: %s'), $this->id, $this->summary); } function _toIndex() { return ''; } function preSave($create=false) { if ($this->id == '') { $this->creation_dtime = gmdate('Y-m-d H:i:s'); } } function postSave($create=false) { if ($create) { IDF_Timeline::insert($this, $this->get_project(), $this->get_submitter(), $this->creation_dtime); } } function getAbsoluteUrl($project) { return Pluf::f('url_upload').'/'.$project->shortname.'/files/'.$this->file; } function getFullPath() { return(Pluf::f('upload_path').'/'.$this->get_project()->shortname.'/files/'.$this->file); } /** * We drop the information from the timeline. */ function preDelete() { IDF_Timeline::remove($this); @unlink(Pluf::f('upload_path').'/'.$this->project->shortname.'/files/'.$this->file); } /** * Returns the timeline fragment for the file. * * * @param Pluf_HTTP_Request * @return Pluf_Template_SafeString */ public function timelineFragment($request) { $url = Pluf_HTTP_URL_urlForView('IDF_Views_Download::view', array($request->project->shortname, $this->id)); $out = '