* ajdust webapp style for task #972.

This commit is contained in:
wangyidong
2012-12-21 06:31:31 +00:00
parent 5d807f9325
commit a73e19a558
9 changed files with 137 additions and 75 deletions

View File

@@ -206,4 +206,34 @@ class fileModel extends model
{
return str_replace('src="data/upload', 'onload="setImageSize(this,' . $maxSize . ' )" src="data/upload', $content);
}
/**
* Replace a file.
*
* @access public
* @return bool
*/
public function replaceFile($fileID, $postName = 'upFile')
{
if($files = $this->getUpload($postName))
{
$file = $files[0];
$filePath = $this->dao->select('pathname')->from(TABLE_FILE)->where('id')->eq($fileID)->fetch('', false);
$pathName = $filePath->pathname;
$realPathName= $this->savePath . $pathName;
if(!is_dir(dirname($realPathName)))mkdir(dirname($realPathName));
move_uploaded_file($file['tmpname'], $realPathName);
$fileInfo->addedBy = $this->app->user->account;
$fileInfo->addedDate = helper::now();
$fileInfo->size = $file['size'];
$this->dao->update(TABLE_FILE)->data($fileInfo, false)->where('id')->eq($fileID)->exec(false);
return true;
}
else
{
return false;
}
}
}

View File

@@ -87,7 +87,7 @@ class webapp extends control
{
$this->webapp->update($webappID);
if(dao::isError())die(js::error(dao::getError()));
die(js::reload('parent.parent'));
die(js::reload('parent'));
}
$this->view->modules = $this->webapp->getModules();

View File

@@ -8,4 +8,8 @@
.exttable {border-color:#CCC9C9; border-top:none;}
.exttable td{border-color:#CCC9C9}
#webapps li {float:left; width:25%; list-style:none}
#webapps li table {border:0px; width:95%; background:#f0f0f0}
#webapps li table .webapp-name{font-size:14px}
small{font-weight:normal}

View File

@@ -7,23 +7,28 @@ function popup(width, height)
if(width == 0 || height == 0) $("a.popup").colorbox({width:width, height:height});
}
var show = false;
var url = '';
function toggleShowapp(webappID)
var show = new Array();
var url = new Array();
function toggleShowapp(webappID, webappName)
{
height = document.body.clientHeight - 60;
if(!show)
if(show[webappID] == undefined)
{
if(url == '') url = $('#useapp' + webappID).attr('href');
height = document.documentElement.clientHeight - 110;
if(url[webappID] == undefined) url[webappID] = $('#useapp' + webappID).attr('href');
$('#useapp' + webappID).attr('href', '#iframe' + webappID);
var html = "<tr id='iframe" + webappID + "'><td colspan='2'><p align='right'><button class='button-c' onclick='toggleShowapp(" + webappID + ")'>" + packup + "</button></p><iframe src='" + url + "' height='" + height + "' width='100%'></iframe></td></tr>";
$('#webapp' + webappID).append(html);
show = true;
var html = "<tr id='iframe" + webappID + "'><td><p>" + webappName + "<span class='f-right'><button class='button-c' onclick='toggleShowapp(" + webappID + ", \" " + webappName + "\")'>" + packup + "</button></sapn></p><iframe src='" + url[webappID] + "' height='" + height + "' width='100%'></iframe></td></tr>";
$('#webapps').parent().parent().after(html);
show[webappID] = true;
}
else if(show[webappID])
{
$('#iframe' + webappID).hide();
show[webappID] = false;
}
else
{
$('#iframe' + webappID).remove();
show = false;
$('#iframe' + webappID).show();
show[webappID] = true;
}
}

View File

@@ -192,7 +192,9 @@ class webappModel extends model
*/
public function getLocalAppByID($webappID)
{
return $this->dao->select('*')->from(TABLE_WEBAPP)->where('id')->eq($webappID)->fetch();
$webapp = $this->dao->select('*')->from(TABLE_WEBAPP)->where('id')->eq($webappID)->fetch();
if($webapp and is_numeric($webapp->icon)) $webapp->icon = $this->loadModel('file')->getByID($webapp->icon);
return $webapp;
}
/**
@@ -212,7 +214,7 @@ class webappModel extends model
$installWebapp->name = $webapp->name;
$installWebapp->author = $webapp->author;
$installWebapp->url = $webapp->url;
$installWebapp->icon = $this->config->webapp->url . $webapp->icon;
$installWebapp->icon = $webapp->icon ? $this->config->webapp->url . $webapp->icon : '';
$installWebapp->target = $webapp->target;
$installWebapp->size = $webapp->size;
$installWebapp->desc = $webapp->desc;
@@ -232,8 +234,27 @@ class webappModel extends model
*/
public function update($webappID)
{
$data = fixer::input('post')->get();
$this->dao->update(TABLE_WEBAPP)->data($data)->where('id')->eq($webappID)->exec();
$webapp = $this->getLocalAppByID($webappID);
$data = fixer::input('post')->remove('files')->get();
$this->dao->update(TABLE_WEBAPP)->data($data)->where('id')->eq($webappID)->check('url', 'unique', "id != $webappID", false)->exec();
if(!dao::isError())
{
if($_FILES)
{
$this->loadModel('file');
if(empty($webapp->icon))
{
$icon = $this->file->saveUpload('webapp', $webappID);
$this->dao->update(TABLE_WEBAPP)->set('icon')->eq(key($icon))->where('id')->eq($webappID)->exec();
}
else
{
$this->file->replaceFile($webapp->icon->id, 'files');
}
}
}
}
/**

View File

@@ -11,7 +11,7 @@
*/
?>
<?php include '../../common/view/header.lite.html.php';?>
<form method='post' target='hiddenwin'>
<form method='post' target='hiddenwin' enctype='multipart/form-data'>
<table class='table-1'>
<caption><?php echo $lang->webapp->edit?></caption>
<tr>
@@ -40,6 +40,17 @@
<th><?php echo $lang->webapp->desc?></th>
<td><?php echo html::textarea('desc', $webapp->desc, "class='area-1' rows='5'")?></td>
</tr>
<?php if($webapp->addType == 'custom'):?>
<tr>
<th><?php echo $lang->webapp->icon?></th>
<td>
<?php
if($webapp->icon) echo "<p><img src='{$webapp->icon->webPath}' /></p>";
echo html::file('files', '', "class='text-3'");
?>
</td>
</tr>
<?php endif;?>
<tr><td colspan='2' align='center'><?php echo html::submitButton()?></td></tr>
</table>
</form>

View File

@@ -15,44 +15,44 @@
<table class='table-1'>
<tr>
<td>
<ul id='webapps'>
<?php foreach($webapps as $webapp):?>
<table class='table-1 exttable' id='webapp<?php echo $webapp->id?>'>
<caption><img src='<?php echo $webapp->icon?>'> <?php echo "$webapp->name";?></caption>
<tr valign='middle'>
<td>
<div class='mb-10px'><?php echo $webapp->desc;?></div>
<div>
<?php
echo "{$lang->webapp->author} : <i>{$webapp->author}</i> ";
echo "{$lang->webapp->addType}: <i>{$lang->webapp->addTypeList[$webapp->addType]}</i> ";
?>
</div>
</td>
<td class='w-220px a-right'>
<?php
$uninstallCode = html::a(inlink('uninstall', "webapp=$webapp->id"), $lang->webapp->uninstall, 'hiddenwin', "class='button-c'");
$url = $webapp->addType == 'custom' ? $webapp->url : $config->webapp->url . "/webapp-showapp-{$webapp->appid}.html";
$method = '';
$popup = '';
$target = '_self';
if($webapp->target == 'blank') $target = '_blank';
if($webapp->target == 'iframe')$method = "toggleShowapp($webapp->id);";
if($webapp->target == 'popup')
{
$width = 0;
$height = 0;
if($webapp->size) list($width, $height) = explode('x', $webapp->size);
$method = "popup($width, $height);";
$popup = 'popup';
}
$useAppCode = html::a($url, $lang->webapp->useapp, $target, "id='useapp$webapp->id' class='button-c $popup' onclick='addView($webapp->id);$method'");
$editAppCode = html::a(inlink('edit', "webappID=$webapp->id"), $lang->edit, '', "class='button-c webapp'");
echo $useAppCode . $editAppCode . $uninstallCode;
?>
</td>
</tr>
</table>
<li>
<table class='fixed exttable' id='webapp<?php echo $webapp->id?>'>
<tr>
<td rowspan='4' width='73' height='73'><img src='<?php echo empty($webapp->icon) ? '/theme/default/images/main/webapp-default.png' : ($webapp->addType == 'custom' ? '' : $config->webapp->url) . $webapp->icon?>' width='72' height='72' /></td>
<td class='webapp-name'><h4><?php echo $webapp->name?></h4></td>
</tr>
<tr><td><span title='<?php echo $webapp->desc?>'><?php echo empty($webapp->desc) ? '&nbsp;' : $webapp->desc?></span></td></tr>
<tr><td><?php echo $lang->webapp->addTypeList[$webapp->addType];?></td></tr>
<tr>
<td>
<?php
$uninstallCode = html::a(inlink('uninstall', "webapp=$webapp->id"), $lang->webapp->uninstall, 'hiddenwin', "class='button-c'");
$url = $webapp->addType == 'custom' ? $webapp->url : $config->webapp->url . "/webapp-showapp-{$webapp->appid}.html";
$method = '';
$popup = '';
$target = '_self';
if($webapp->target == 'blank') $target = '_blank';
if($webapp->target == 'iframe')$method = "toggleShowapp($webapp->id, \"$webapp->name\");";
if($webapp->target == 'popup')
{
$width = 0;
$height = 0;
if($webapp->size) list($width, $height) = explode('x', $webapp->size);
$method = "popup($width, $height);";
$popup = 'popup';
}
$useAppCode = html::a($url, $lang->webapp->useapp, $target, "id='useapp$webapp->id' class='button-c $popup' onclick='addView($webapp->id);$method'");
$editAppCode = html::a(inlink('edit', "webappID=$webapp->id"), $lang->edit, '', "class='button-c webapp'");
echo $useAppCode . $editAppCode . $uninstallCode;
?>
</td>
</tr>
</table>
</li>
<?php endforeach;?>
</ul>
</td>
</tr>
</table>

View File

@@ -37,30 +37,21 @@
<td class='divider'></td>
<td>
<?php if($webapps):?>
<?php foreach($webapps as $webapp):?>
<table class='table-1 exttable'>
<caption>
<div class='f-left'><?php echo "<img src='{$config->webapp->url}{$webapp->icon}' /> " . $webapp->name;?></div>
</caption>
<tr valign='middle'>
<td>
<div class='mb-10px'><?php echo $webapp->desc;?></div>
<div>
<?php
echo "<strong>{$lang->webapp->author}</strong> {$webapp->author} ";
echo "<strong>{$lang->webapp->target}</strong> {$lang->webapp->targetList[$webapp->target]} ";
if(!empty($webapp->size)) echo "<strong>{$lang->webapp->size}</strong> {$webapp->size} ";
echo "<strong>{$lang->webapp->downloads}</strong> {$webapp->downloads} ";
echo "<strong>{$lang->webapp->grade}</strong> ", html::printStars($webapp->stars);
?>
</div>
</td>
<td class='w-200px a-right'>
<?php echo isset($installeds[$webapp->id]) ? html::commonButton($lang->webapp->installed, "disabled='disabled' style='color:gray'") : html::a(inLink('install', "webappID={$webapp->id}"), $lang->webapp->install, '_self', "class='button-c iframe'")?>
</td></tr>
<ul id='webapps'>
<?php foreach($webapps as $webapp):?>
<li>
<table class='fixed exttable'>
<tr>
<td rowspan='4' width='73' height='73'><img src='<?php echo empty($webapp->icon) ? '/theme/default/images/main/webapp-default.png' : $config->webapp->url . $webapp->icon?>' width='72' height='72' /></td>
<td class='webapp-name'><h4><?php echo $webapp->name?></h4></td>
</tr>
<tr><td><span title='<?php echo $webapp->desc?>'><?php echo empty($webapp->desc) ? '&nbsp;' : $webapp->desc?></span></td></tr>
<tr><td><?php echo isset($installeds[$webapp->id]) ? html::commonButton($lang->webapp->installed, "disabled='disabled' style='color:gray'") : html::a(inLink('install', "webappID={$webapp->id}"), $lang->webapp->install, '_self', "class='button-c iframe'")?></td></tr>
</table>
</li>
<?php endforeach;?>
<?php if($pager) $pager->show();?>
</ul>
<p class='c-left'><?php if($pager) $pager->show();?></p>
<?php else:?>
<div class='box-title'><?php echo $lang->webapp->errorOccurs;?></div>
<div class='box-content'><?php echo $lang->webapp->errorGetExtensions;?></div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB