Indefero

Indefero Commit Details


Date:2008-08-05 08:44:27 (16 years 4 months ago)
Author:Loic d'Anterroches
Branch:dev, develop, feature-issue_links, feature.better-home, feature.content-md5, feature.diff-whitespace, feature.download-md5, feature.issue-links, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, master, release-1.1, release-1.2, release-1.3, svn
Commit:5e3b2bac28da61363c59f2bddde2210645064183
Parents: 366b73d27ed4ecbccd68a3464883d12482ba8fe2
Message:Added a download counter.

Because we like stats, even if not really reliable :)
Changes:

File differences

src/IDF/Form/UpdateUpload.php
132132
133133
134134
135
135136
136137
137138
}
// Create the upload
$this->upload->summary = trim($this->cleaned_data['summary']);
$this->upload->modif_dtime = gmdate('Y-m-d H:i:s');
$this->upload->update();
$this->upload->batchAssoc('IDF_Tag', $tags);
return $this->upload;
src/IDF/Upload.php
137137
138138
139139
140
140141
141
142
143
144
145
146
142147
143148
{
if ($this->id == '') {
$this->creation_dtime = gmdate('Y-m-d H:i:s');
$this->modif_dtime = gmdate('Y-m-d H:i:s');
}
$this->modif_dtime = gmdate('Y-m-d H:i:s');
}
function getAbsoluteUrl($project)
{
return Pluf::f('url_media').'/upload/'.$project->shortname.'/files/'.$this->file;
}
}
src/IDF/Views/Download.php
7777
7878
7979
80
81
82
8083
8184
8285
......
112115
113116
114117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
115133
116134
117135
{
$prj = $request->project;
$upload = Pluf_Shortcuts_GetObjectOr404('IDF_Upload', $match[2]);
if ($upload->project != $prj->id) {
throw new Pluf_HTTP_Error404();
}
$title = sprintf(__('Download %s'), $upload->summary);
$form = false;
if ($request->method == 'POST' and
}
/**
* Download a file.
*/
public function download($request, $match)
{
$prj = $request->project;
$upload = Pluf_Shortcuts_GetObjectOr404('IDF_Upload', $match[2]);
if ($upload->project != $prj->id) {
throw new Pluf_HTTP_Error404();
}
$upload->downloads += 1;
$upload->update();
return new Pluf_HTTP_Response_Redirect($upload->getAbsoluteUrl($prj));
}
/**
* Submit a new file for download.
*/
public $submit_precond = array('IDF_Precondition::projectMemberOrOwner');
src/IDF/conf/views.php
159159
160160
161161
162
163
164
165
166
167
162168
163169
164170
'model' => 'IDF_Views_Download',
'method' => 'view');
$ctl[] = array('regex' => '#^/p/(\w+)/downloads/(\d+)/get/$#',
'base' => $base,
'priority' => 4,
'model' => 'IDF_Views_Download',
'method' => 'download');
$ctl[] = array('regex' => '#^/p/(\w+)/downloads/create/$#',
'base' => $base,
'priority' => 4,
src/IDF/templates/downloads/view.html
33
44
55
6
6
77
88
99
......
4747
4848
4949
50
51
5052
5153
5254
{block body}
<div class="download-file">
<a href="{media}/upload/{$project.shortname}/files/{$file}">{$file}</a> - {$file.filesize|size}
<a href="{url 'IDF_Views_Download::download', array($project.shortname, $file.id)}">{$file}</a> - {$file.filesize|size}
</div>
<p><strong>{trans 'Uploaded:'}</strong> <span class="nobrk">{$file.creation_dtime|dateago}</span> <span class="nobrk">{blocktrans}by {$submitter}{/blocktrans}</span></p>
<p>
<strong>{trans 'Updated:'}</strong> <span class="nobrk">{$file.modif_dtime|dateago}</span></p>
<p>
<strong>{trans 'Downloads:'}</strong> <span class="nobrk">{$file.downloads}</span></p>
{assign $tags = $file.get_tags_list()}{if $tags.count()}
<p>
<strong>{trans 'Labels:'}</strong><br />

Archive Download the corresponding diff file

Page rendered in 0.08149s using 13 queries.