Merge branch 'feature.better-home' of projects.ceondo.com:indefero into feature.better-home
This commit is contained in:
commit
47a077bc82
@ -162,15 +162,4 @@ class IDF_FileUtil
|
|||||||
$ext = array_merge(self::$supportedExtenstions, explode(' ' , $ext));
|
$ext = array_merge(self::$supportedExtenstions, explode(' ' , $ext));
|
||||||
return (in_array($fileinfo[2], $ext));
|
return (in_array($fileinfo[2], $ext));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static function getPictureInline($file)
|
|
||||||
{
|
|
||||||
$info = IDF_FileUtil::getMimeType($file);
|
|
||||||
$content = file_get_contents($file);
|
|
||||||
$base64 = 'data:' . $info[0] . ';base64,' . base64_encode($content);
|
|
||||||
return $base64;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -54,16 +54,16 @@ class IDF_Form_ProjectConf extends Pluf_Form
|
|||||||
|
|
||||||
// Logo part
|
// Logo part
|
||||||
$upload_path = Pluf::f('upload_path', false);
|
$upload_path = Pluf::f('upload_path', false);
|
||||||
if(false === $upload_path) {
|
if (false === $upload_path) {
|
||||||
throw new Pluf_Exception_SettingError(__('The "upload_issue_path" configuration variable was not set.'));
|
throw new Pluf_Exception_SettingError(__('The "upload_path" configuration variable was not set.'));
|
||||||
}
|
}
|
||||||
$md5 = md5(rand().microtime().Pluf_Utils::getRandomString());
|
$upload_path .= '/' . $this->project->shortname;
|
||||||
$filename = substr($md5, 0, 2).'/'.substr($md5, 2, 2).'/'.substr($md5, 4).'/%s';
|
$filename = '/%s';
|
||||||
$this->fields['logo'] = new Pluf_Form_Field_File(array('required' => false,
|
$this->fields['logo'] = new Pluf_Form_Field_File(array('required' => false,
|
||||||
'label' => __('Update the logo'),
|
'label' => __('Update the logo'),
|
||||||
'initial' => '',
|
'initial' => '',
|
||||||
'help_text' => __('The logo must be a picture with a size of 16 by 16.'),
|
'help_text' => __('The logo must be a picture with a size of 32 by 32.'),
|
||||||
'max_size' => Pluf::f('max_upload_size', 2097152),
|
'max_size' => Pluf::f('max_upload_size', 100 * 1024),
|
||||||
'move_function_params' =>
|
'move_function_params' =>
|
||||||
array('upload_path' => $upload_path,
|
array('upload_path' => $upload_path,
|
||||||
'upload_path_create' => true,
|
'upload_path_create' => true,
|
||||||
@ -84,15 +84,15 @@ class IDF_Form_ProjectConf extends Pluf_Form
|
|||||||
*/
|
*/
|
||||||
function failed()
|
function failed()
|
||||||
{
|
{
|
||||||
if(!empty($this->cleaned_data['logo'])
|
if (!empty($this->cleaned_data['logo'])
|
||||||
and file_exists(Pluf::f('upload_path').'/'.$this->cleaned_data['logo'])) {
|
&& file_exists(Pluf::f('upload_path').'/'.$this->cleaned_data['logo'])) {
|
||||||
unlink(Pluf::f('upload_path').'/'.$this->cleaned_data['logo']);
|
unlink(Pluf::f('upload_path').'/'.$this->cleaned_data['logo']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function clean()
|
public function clean()
|
||||||
{
|
{
|
||||||
if(!isset($this->cleaned_data['logo_remove'])) {
|
if (!isset($this->cleaned_data['logo_remove'])) {
|
||||||
$this->cleaned_data['logo_remove'] = false;
|
$this->cleaned_data['logo_remove'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,19 +101,18 @@ class IDF_Form_ProjectConf extends Pluf_Form
|
|||||||
|
|
||||||
public function clean_logo()
|
public function clean_logo()
|
||||||
{
|
{
|
||||||
if(!isset($this->cleaned_data['logo']) ||
|
if (empty($this->cleaned_data['logo'])) {
|
||||||
$this->cleaned_data['logo'] == "") {
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$meta = getimagesize(Pluf::f('upload_path').'/'.$this->cleaned_data['logo']);
|
$meta = getimagesize(Pluf::f('upload_path') . '/' . $this->project->shortname . $this->cleaned_data['logo']);
|
||||||
|
|
||||||
if($meta === FALSE) {
|
if ($meta === false) {
|
||||||
throw new Pluf_Form_Invalid("Error during the determination of the size of the picture");
|
throw new Pluf_Form_Invalid("Could not determine the size of the uploaded picture.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if($meta[0] !== 32 || $meta[1] !== 32) {
|
if ($meta[0] !== 32 || $meta[1] !== 32) {
|
||||||
throw new Pluf_Form_Invalid("The picture must have a size of 16 by 16.");
|
throw new Pluf_Form_Invalid("The picture must have a size of 32 by 32.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->cleaned_data['logo'];
|
return $this->cleaned_data['logo'];
|
||||||
@ -130,11 +129,11 @@ class IDF_Form_ProjectConf extends Pluf_Form
|
|||||||
$this->project->update();
|
$this->project->update();
|
||||||
|
|
||||||
// Logo part
|
// Logo part
|
||||||
if($this->cleaned_data['logo'] !== "") {
|
if ($this->cleaned_data['logo'] !== "") {
|
||||||
$conf->setVal('logo', $this->cleaned_data['logo']);
|
$conf->setVal('logo', $this->cleaned_data['logo']);
|
||||||
}
|
}
|
||||||
if($this->cleaned_data['logo_remove'] === true) {
|
if ($this->cleaned_data['logo_remove'] === true) {
|
||||||
@unlink(Pluf::f('upload_path').'/'.$conf->getVal('logo'));
|
@unlink(Pluf::f('upload_path') . '/' . $this->project->shortname . $conf->getVal('logo'));
|
||||||
$conf->delVal('logo');
|
$conf->delVal('logo');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,23 +42,11 @@ class IDF_Views
|
|||||||
$projects = self::getProjects($request->user);
|
$projects = self::getProjects($request->user);
|
||||||
$stats = self::getProjectsStatistics ($projects);
|
$stats = self::getProjectsStatistics ($projects);
|
||||||
|
|
||||||
$logos = array();
|
|
||||||
foreach ($projects as $p) {
|
|
||||||
$logo = $p->getConf()->getVal('logo');
|
|
||||||
if (!empty($logo)) {
|
|
||||||
$logo = Pluf::f('upload_path').'/'.$logo;
|
|
||||||
$logos[$p->shortname] = IDF_FileUtil::getPictureInline($logo);
|
|
||||||
} else {
|
|
||||||
$logos[$p->shortname] = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($api == true) return $projects;
|
if ($api == true) return $projects;
|
||||||
return Pluf_Shortcuts_RenderToResponse('idf/index.html',
|
return Pluf_Shortcuts_RenderToResponse('idf/index.html',
|
||||||
array('page_title' => __('Projects'),
|
array('page_title' => __('Projects'),
|
||||||
'projects' => $projects,
|
'projects' => $projects,
|
||||||
'stats' => new Pluf_Template_ContextVars($stats),
|
'stats' => new Pluf_Template_ContextVars($stats)),
|
||||||
'logos' => $logos),
|
|
||||||
$request);
|
$request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,25 @@ Pluf::loadFunction('Pluf_Shortcuts_GetFormForModel');
|
|||||||
*/
|
*/
|
||||||
class IDF_Views_Project
|
class IDF_Views_Project
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Home page of a project.
|
||||||
|
*/
|
||||||
|
public $logo_precond = array('IDF_Precondition::baseAccess');
|
||||||
|
public function logo($request, $match)
|
||||||
|
{
|
||||||
|
$prj = $request->project;
|
||||||
|
|
||||||
|
$logo = $prj->getConf()->getVal('logo');
|
||||||
|
if(empty($logo)) {
|
||||||
|
$url = Pluf::f('url_media') . '/idf/img/no_logo.png';
|
||||||
|
return new Pluf_HTTP_Response_Redirect($url);
|
||||||
|
}
|
||||||
|
|
||||||
|
$info = IDF_FileUtil::getMimeType($logo);
|
||||||
|
return new Pluf_HTTP_Response_File(Pluf::f('upload_path') . '/' . $prj->shortname . $logo,
|
||||||
|
$info[0]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Home page of a project.
|
* Home page of a project.
|
||||||
*/
|
*/
|
||||||
@ -290,16 +309,12 @@ class IDF_Views_Project
|
|||||||
}
|
}
|
||||||
|
|
||||||
$logo = $prj->getConf()->getVal('logo');
|
$logo = $prj->getConf()->getVal('logo');
|
||||||
if (!empty($logo)) {
|
|
||||||
$logo = Pluf::f('upload_path').'/'.$logo;
|
|
||||||
$logo_base64 = IDF_FileUtil::getPictureInline($logo);
|
|
||||||
}
|
|
||||||
return Pluf_Shortcuts_RenderToResponse('idf/admin/summary.html',
|
return Pluf_Shortcuts_RenderToResponse('idf/admin/summary.html',
|
||||||
array(
|
array(
|
||||||
'page_title' => $title,
|
'page_title' => $title,
|
||||||
'form' => $form,
|
'form' => $form,
|
||||||
'project' => $prj,
|
'project' => $prj,
|
||||||
'logo' => $logo_base64,
|
'logo' => $logo,
|
||||||
),
|
),
|
||||||
$request);
|
$request);
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,11 @@ $ctl[] = array('regex' => '#^/p/([\-\w]+)/$#',
|
|||||||
'base' => $base,
|
'base' => $base,
|
||||||
'model' => 'IDF_Views_Project',
|
'model' => 'IDF_Views_Project',
|
||||||
'method' => 'home');
|
'method' => 'home');
|
||||||
|
|
||||||
|
$ctl[] = array('regex' => '#^/p/([\-\w]+)/logo/$#',
|
||||||
|
'base' => $base,
|
||||||
|
'model' => 'IDF_Views_Project',
|
||||||
|
'method' => 'logo');
|
||||||
|
|
||||||
$ctl[] = array('regex' => '#^/p/([\-\w]+)/timeline/(\w+)/$#',
|
$ctl[] = array('regex' => '#^/p/([\-\w]+)/timeline/(\w+)/$#',
|
||||||
'base' => $base,
|
'base' => $base,
|
||||||
|
@ -31,10 +31,10 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th><strong>{trans 'Actual logo'}:</strong></th>
|
<th><strong>{trans 'Current logo'}:</strong></th>
|
||||||
<td>
|
<td>
|
||||||
{if $logo}
|
{if $logo}
|
||||||
<img src="{$logo}" alt="project logo" />
|
<img src="{url 'IDF_Views_Project::logo', array($project.shortname)}" alt="{trans 'project logo'}" />
|
||||||
{else}
|
{else}
|
||||||
{trans 'Your project do not have a logo configured yet.'}
|
{trans 'Your project do not have a logo configured yet.'}
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -12,17 +12,22 @@
|
|||||||
{foreach $projects as $p}
|
{foreach $projects as $p}
|
||||||
<div class="p-list-img">
|
<div class="p-list-img">
|
||||||
<a href="{url 'IDF_Views_Project::home', array($p.shortname)}">
|
<a href="{url 'IDF_Views_Project::home', array($p.shortname)}">
|
||||||
{if $logos[$p->shortname]}
|
<img src="{url 'IDF_Views_Project::logo', array($p.shortname)}" alt="{trans 'Project logo'}" />
|
||||||
<img src="{$logos[$p->shortname]}" alt="{trans 'Project logo'}" />
|
|
||||||
{else}
|
|
||||||
<img src="{media '/idf/img/no_logo.png'}" alt="{trans 'Project logo'}" />
|
|
||||||
{/if}
|
|
||||||
</a>
|
</a>
|
||||||
{if $p.private}<div class="p-list-private"><a href="{url 'IDF_Views_Project::home', array($p.shortname)}"><img style="float:right" src="{media '/idf/img/lock.png'}" alt="{trans 'Private project'}" /></a></div>{/if}
|
{if $p.private}
|
||||||
|
<div class="p-list-private">
|
||||||
|
<a href="{url 'IDF_Views_Project::home', array($p.shortname)}">
|
||||||
|
<img style="float:right" src="{media '/idf/img/lock.png'}" alt="{trans 'Private project'}" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div class="p-list-prj">
|
<div class="p-list-prj">
|
||||||
<p><a href="{url 'IDF_Views_Project::home', array($p.shortname)}"><strong>{$p}</strong></a>{if $p.private} - {trans 'Private project'}</p>{/if}</p>
|
<p>
|
||||||
{if $p.shortdesc}<p>{$p.shortdesc}</p>{/if}
|
<a href="{url 'IDF_Views_Project::home', array($p.shortname)}"><strong>{$p}</strong></a>
|
||||||
|
{if $p.private} - {trans 'Private project'}{/if}
|
||||||
|
</p>
|
||||||
|
<p>{$p.shortdesc}</p>
|
||||||
</div>
|
</div>
|
||||||
<div style="clear: both"></div>
|
<div style="clear: both"></div>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
|
@ -1049,18 +1049,21 @@ span.scm-action.property-changed {
|
|||||||
*/
|
*/
|
||||||
div.p-list-img {
|
div.p-list-img {
|
||||||
float: left;
|
float: left;
|
||||||
|
height: 32px;
|
||||||
|
margin-top: .5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.p-list-prj {
|
div.p-list-prj {
|
||||||
float: left;
|
float: left;
|
||||||
margin: 0 0 .5em 1em;
|
margin: .5em 0 .5em 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.p-list-prj p {
|
div.p-list-prj p {
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.p-list-private {
|
div.p-list-private {
|
||||||
bottom: 10px;
|
bottom: 10px;
|
||||||
|
right: -6px;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user