Merge branch 'master' into oc_error

This commit is contained in:
Georg Ehrke 2012-06-18 14:34:49 +02:00
commit e31c9a7b6f
15 changed files with 261 additions and 97 deletions

View file

@ -6,15 +6,51 @@
* See the COPYING-README file.
*/
function cmp($a, $b)
{
if ($a['displayname'] == $b['displayname']) {
return 0;
}
return ($a['displayname'] < $b['displayname']) ? -1 : 1;
}
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
$ids = OC_Contacts_Addressbook::activeIds(OCP\USER::getUser());
$contacts = OC_Contacts_VCard::all($ids);
$contacts_alphabet = OC_Contacts_VCard::all($ids);
$active_addressbooks = OC_Contacts_Addressbook::active(OCP\USER::getUser());
// Our new array for the contacts sorted by addressbook
$contacts_addressbook = array();
foreach($contacts_alphabet as $contact) {
if(!isset($contacts_addressbook[$contact['addressbookid']])) {
$contacts_addressbook[$contact['addressbookid']] = array('contacts' => array());
}
$display = trim($contact['fullname']);
if(!$display) {
$vcard = OC_Contacts_App::getContactVCard($contact['id']);
if(!is_null($vcard)) {
$struct = OC_Contacts_VCard::structureContact($vcard);
$display = isset($struct['EMAIL'][0])?$struct['EMAIL'][0]['value']:'[UNKNOWN]';
}
}
$contacts_addressbook[$contact['addressbookid']]['contacts'][] = array('id' => $contact['id'], 'addressbookid' => $contact['addressbookid'], 'displayname' => htmlspecialchars($display));
}
foreach($contacts_addressbook as $addressbook_id => $contacts) {
foreach($active_addressbooks as $addressbook) {
if($addressbook_id == $addressbook['id']) {
$contacts_addressbook[$addressbook_id]['displayname'] = $addressbook['displayname'];
}
}
}
uasort($contacts_addressbook, 'cmp');
$tmpl = new OCP\Template("contacts", "part.contacts");
$tmpl->assign('contacts', $contacts, false);
$tmpl->assign('books', $contacts_addressbook, false);
$page = $tmpl->fetchPage();
OCP\JSON::success(array('data' => array( 'page' => $page )));
?>

View file

@ -2,9 +2,12 @@
font-weight: bold;
}*/
#leftcontent { top: 3.5em !important; padding: 0; margin: 0; }
#leftcontent a { padding: 0 0 0 25px; }
#rightcontent { top: 3.5em !important; padding-top: 5px; }
#contacts { background: #fff; width: 20em; left: 12.5em; top: 3.7em; bottom:3em; position: fixed; overflow: auto; padding: 0; margin: 0; }
#contacts a { height: 23px; display: block; margin: 0 0 0 0; padding: 0 0 0 25px; }
#leftcontent h3 { cursor: pointer; -moz-transition: background 300ms ease 0s; background: none no-repeat scroll 1em center #eee; border-bottom: 1px solid #ddd; border-top: 1px solid #fff; display: block; max-width: 100%; padding: 0.5em 0.8em; color: #666; text-shadow: 0 1px 0 #f8f8f8; font-size: 1.2em; }
#leftcontent h3:hover { background-color: #DBDBDB; border-bottom: 1px solid #CCCCCC; border-top: 1px solid #D4D4D4; color: #333333; }
#contacts { position: fixed; background: #fff; max-width: 100%; width: 20em; left: 12.5em; top: 3.7em; bottom: 3em; overflow: auto; padding: 0; margin: 0; }
.contacts a { height: 23px; display: block; left: 12.5em; margin: 0 0 0 0; padding: 0 0 0 25px; }
#bottomcontrols { padding: 0; bottom:0px; height:2.8em; width: 20em; margin:0; background:#eee; border-top:1px solid #ccc; position:fixed; -moz-box-shadow: 0 -3px 3px -3px #000; -webkit-box-shadow: 0 -3px 3px -3px #000; box-shadow: 0 -3px 3px -3px #000;}
#contacts_newcontact { float: left; margin: 0.2em 0 0 1em; }
#chooseaddressbook { float: right; margin: 0.2em 1em 0 0; }

View file

@ -171,13 +171,14 @@ Contacts={
});*/
// Name has changed. Update it and reorder.
// TODO: Take addressbook into account
$('#fn').change(function(){
var name = $('#fn').val().strip_tags();
var item = $('#contacts [data-id="'+Contacts.UI.Card.id+'"]');
var item = $('.contacts [data-id="'+Contacts.UI.Card.id+'"]');
$(item).find('a').html(name);
Contacts.UI.Card.fn = name;
var added = false;
$('#contacts li').each(function(){
$('.contacts li[data-bookid="'+Contacts.UI.Card.bookid+'"]').each(function(){
if ($(this).text().toLowerCase() > name.toLowerCase()) {
$(this).before(item).fadeIn('fast');
added = true;
@ -185,7 +186,7 @@ Contacts={
}
});
if(!added) {
$('#leftcontent ul').append(item);
$('#leftcontent ul[data-id="'+Contacts.UI.Card.bookid+'"]').append(item);
}
Contacts.UI.Contacts.scrollTo(Contacts.UI.Card.id);
});
@ -245,19 +246,21 @@ Contacts={
honpre:'',
honsuf:'',
data:undefined,
update:function(id) {
var newid;
update:function(id, bookid) {
var newid, firstitem;
if(!id) {
newid = $('#contacts li:first-child').data('id');
firstitem = $('#contacts:first-child li:first-child');
newid = firstitem.data('id');
bookid = firstitem.data('bookid');
} else {
newid = id;
}
var localLoadContact = function(id) {
if($('#contacts li').length > 0) {
$('#leftcontent li[data-id="'+newid+'"]').addClass('active');
var localLoadContact = function(newid, bookid) {
if($('.contacts li').length > 0) {
firstitem.addClass('active');
$.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':newid},function(jsondata){
if(jsondata.status == 'success'){
Contacts.UI.Card.loadContact(jsondata.data);
Contacts.UI.Card.loadContact(jsondata.data, bookid);
} else {
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
}
@ -271,14 +274,14 @@ Contacts={
if(jsondata.status == 'success'){
$('#rightcontent').html(jsondata.data.page).ready(function() {
Contacts.UI.loadHandlers();
localLoadContact(newid);
localLoadContact(newid, bookid);
});
} else {
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
}
});
}
else if($('#contacts li').length == 0) {
else if($('.contacts li').length == 0) {
// load intro page
$.getJSON(OC.filePath('contacts', 'ajax', 'loadintro.php'),{},function(jsondata){
if(jsondata.status == 'success'){
@ -291,7 +294,7 @@ Contacts={
});
}
else {
localLoadContact();
localLoadContact(newid, bookid);
}
},
doExport:function() {
@ -315,7 +318,7 @@ Contacts={
var id = jsondata.data.id;
$.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':id},function(jsondata){
if(jsondata.status == 'success'){
Contacts.UI.Card.loadContact(jsondata.data);
Contacts.UI.Card.loadContact(jsondata.data, aid);
$('#leftcontent .active').removeClass('active');
var item = $('<li data-id="'+jsondata.data.id+'" class="active"><a href="index.php?id='+jsondata.data.id+'" style="background: url('+OC.filePath('contacts', '', 'thumbnail.php')+'?id='+jsondata.data.id+') no-repeat scroll 0% 0% transparent;">'+Contacts.UI.Card.fn+'</a></li>');
var added = false;
@ -370,7 +373,7 @@ Contacts={
if(answer == true) {
$.post(OC.filePath('contacts', 'ajax', 'deletecard.php'),{'id':Contacts.UI.Card.id},function(jsondata){
if(jsondata.status == 'success'){
var newid = '';
var newid = '', bookid;
var curlistitem = $('#leftcontent [data-id="'+jsondata.data.id+'"]');
var newlistitem = curlistitem.prev();
if(newlistitem == undefined) {
@ -379,13 +382,14 @@ Contacts={
curlistitem.remove();
if(newlistitem != undefined) {
newid = newlistitem.data('id');
bookid = newlistitem.data('id');
}
$('#rightcontent').data('id',newid);
this.id = this.fn = this.fullname = this.shortname = this.famname = this.givname = this.addname = this.honpre = this.honsuf = '';
this.data = undefined;
if($('#contacts li').length > 0) { // Load first in list.
Contacts.UI.Card.update(newid);
if($('.contacts li').length > 0) { // Load first in list.
Contacts.UI.Card.update(newid, bookid);
} else {
// load intro page
$.getJSON(OC.filePath('contacts', 'ajax', 'loadintro.php'),{},function(jsondata){
@ -408,9 +412,10 @@ Contacts={
});
return false;
},
loadContact:function(jsondata){
loadContact:function(jsondata, bookid){
this.data = jsondata;
this.id = this.data.id;
this.bookid = bookid;
$('#rightcontent').data('id',this.id);
this.populateNameFields();
this.loadPhoto();
@ -1498,39 +1503,50 @@ Contacts={
update:function(){
$.getJSON(OC.filePath('contacts', 'ajax', 'contacts.php'),{},function(jsondata){
if(jsondata.status == 'success'){
$('#contacts').html(jsondata.data.page);
$('#contacts').html(jsondata.data.page).ready(function() {
/*setTimeout(function() {
$('.contacts li').unbind('inview');
$('.contacts li:visible').bind('inview', function(event, isInView, visiblePartX, visiblePartY) {
if (isInView) {
if (!$(this).find('a').attr('style')) {
$(this).find('a').css('background','url('+OC.filePath('contacts', '', 'thumbnail.php')+'?id='+$(this).data('id')+') no-repeat');
}
}
})}, 100);
setTimeout(Contacts.UI.Contacts.lazyupdate, 500);*/
});
Contacts.UI.Card.update();
}
else{
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
}
});
setTimeout(function() {
$('#contacts li').unbind('inview');
$('#contacts li').bind('inview', function(event, isInView, visiblePartX, visiblePartY) {
/*setTimeout(function() {
$('.contacts li').unbind('inview');
$('.contacts li:visible').bind('inview', function(event, isInView, visiblePartX, visiblePartY) {
if (isInView) {
if (!$(this).find('a').attr('style')) {
$(this).find('a').css('background','url('+OC.filePath('contacts', '', 'thumbnail.php')+'?id='+$(this).data('id')+') no-repeat');
}
}
})}, 500);
setTimeout(Contacts.UI.Contacts.lazyupdate, 500);
setTimeout(Contacts.UI.Contacts.lazyupdate, 500);*/
},
// Add thumbnails to the contact list as they become visible in the viewport.
lazyupdate:function(){
$('#contacts li').live('inview', function(){
$('.contacts li').live('inview', function(){
if (!$(this).find('a').attr('style')) {
$(this).find('a').css('background','url('+OC.filePath('contacts', '', 'thumbnail.php')+'?id='+$(this).data('id')+') no-repeat');
}
});
},
refreshThumbnail:function(id){
var item = $('#contacts [data-id="'+id+'"]').find('a');
var item = $('.contacts [data-id="'+id+'"]').find('a');
item.html(Contacts.UI.Card.fn);
item.css('background','url('+OC.filePath('contacts', '', 'thumbnail.php')+'?id='+id+'&refresh=1'+Math.random()+') no-repeat');
},
scrollTo:function(id){
$('#contacts').animate({
$('.contacts').animate({
scrollTop: $('#leftcontent li[data-id="'+id+'"]').offset().top-20}, 'slow','swing');
}
}
@ -1552,24 +1568,25 @@ $(document).ready(function(){
$('#contacts_newcontact').keydown(Contacts.UI.Card.editNew);
// Load a contact.
$('#contacts').keydown(function(event) {
$('.contacts').keydown(function(event) {
if(event.which == 13) {
$('#contacts').click();
$('.contacts').click();
}
});
$('#contacts').click(function(event){
$(document).on('click', '.contacts', function(event){
var $tgt = $(event.target);
if ($tgt.is('li') || $tgt.is('a')) {
var item = $tgt.is('li')?$($tgt):($tgt).parent();
var id = item.data('id');
var bookid = item.data('bookid');
item.addClass('active');
var oldid = $('#rightcontent').data('id');
if(oldid != 0){
$('#contacts li[data-id="'+oldid+'"]').removeClass('active');
$('.contacts li[data-id="'+oldid+'"]').removeClass('active');
}
$.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':id},function(jsondata){
if(jsondata.status == 'success'){
Contacts.UI.Card.loadContact(jsondata.data);
Contacts.UI.Card.loadContact(jsondata.data, bookid);
}
else{
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
@ -1579,7 +1596,12 @@ $(document).ready(function(){
return false;
});
$('#contacts li').bind('inview', function(event, isInView, visiblePartX, visiblePartY) {
$(document).on('click', '.addressbook', function(event){
$(this).next().slideToggle(300);
return false;
});
/*$('.contacts li').bind('inview', function(event, isInView, visiblePartX, visiblePartY) {
if (isInView) { //NOTE: I've kept all conditions for future reference ;-)
// element is now visible in the viewport
if (visiblePartY == 'top') {
@ -1591,14 +1613,14 @@ $(document).ready(function(){
if (!$(this).find('a').attr('style')) {
//alert($(this).data('id') + ' has background: ' + $(this).attr('style'));
$(this).find('a').css('background','url('+OC.filePath('contacts', '', 'thumbnail.php')+'?id='+$(this).data('id')+') no-repeat');
}/* else {
alert($(this).data('id') + ' has style ' + $(this).attr('style').match('url'));
}*/
}// else {
// alert($(this).data('id') + ' has style ' + $(this).attr('style').match('url'));
//}
}
} else {
// element has gone out of viewport
}
});
});*/
$('.contacts_property').live('change', function(){
Contacts.UI.Card.saveProperty(this);
@ -1678,3 +1700,4 @@ $(document).ready(function(){
$('#contacts_propertymenu_dropdown a').click(propertyMenuItem);
$('#contacts_propertymenu_dropdown a').keydown(propertyMenuItem);
});
Contacts.UI.Contacts.update();

View file

@ -3,16 +3,15 @@
var categories = <?php echo json_encode($_['categories']); ?>;
var lang = '<?php echo OCP\Config::getUserValue(OCP\USER::getUser(), 'core', 'lang', 'en'); ?>';
</script>
<div id="leftcontent" class="leftcontent">
<ul id="contacts">
<?php echo $this->inc("part.contacts"); ?>
</ul>
</div>
<div id="bottomcontrols">
<form>
<button class="svg" id="contacts_newcontact" title="<?php echo $l->t('Add Contact'); ?>"><img class="svg" src="<?php echo OCP\Util::linkTo('contacts', 'img/contact-new.svg'); ?>" alt="<?php echo $l->t('Add Contact'); ?>" /></button>
<button class="svg" id="chooseaddressbook" title="<?php echo $l->t('Addressbooks'); ?>"><img class="svg" src="core/img/actions/settings.svg" alt="<?php echo $l->t('Addressbooks'); ?>" /></button>
</form>
<div id="leftcontent">
<div id="contacts">
</div>
<div id="bottomcontrols">
<form>
<button class="svg" id="contacts_newcontact" title="<?php echo $l->t('Add Contact'); ?>"><img class="svg" src="<?php echo OCP\Util::linkTo('contacts', 'img/contact-new.svg'); ?>" alt="<?php echo $l->t('Add Contact'); ?>" /></button>
<button class="svg" id="chooseaddressbook" title="<?php echo $l->t('Addressbooks'); ?>"><img class="svg" src="core/img/actions/settings.svg" alt="<?php echo $l->t('Addressbooks'); ?>" /></button>
</form>
</div>
</div>
<div id="rightcontent" class="rightcontent" data-id="<?php echo $_['id']; ?>">
<?php

View file

@ -33,15 +33,15 @@ $id = isset($_['id']) ? $_['id'] : '';
</span>
<dl id="identityprops" class="form">
<dt class="hidden" id="org_label" data-element="ORG"><label for="org"><?php echo $l->t('Organization'); ?></label></dt>
<dd class="propertycontainer hidden" id="org_value" data-element="ORG"><input id="org" required="required" name="value[ORG]" type="text" class="contacts_property big" name="value" value="" placeholder="<?php echo $l->t('Organization'); ?>" /><a role="button" class="action delete" title="<?php echo $l->t('Delete'); ?>"></a></dd>
<dd class="propertycontainer hidden" id="org_value" data-element="ORG"><input id="org" required="required" type="text" class="contacts_property big" name="value" value="" placeholder="<?php echo $l->t('Organization'); ?>" /><a role="button" class="action delete" title="<?php echo $l->t('Delete'); ?>"></a></dd>
<dt class="hidden" id="nickname_label" data-element="NICKNAME"><label for="nickname"><?php echo $l->t('Nickname'); ?></label></dt>
<dd class="propertycontainer hidden" id="nickname_value" data-element="NICKNAME"><input id="nickname" required="required" name="value[NICKNAME]" type="text" class="contacts_property big" name="value" value="" placeholder="<?php echo $l->t('Enter nickname'); ?>" /><a role="button" class="action delete" title="<?php echo $l->t('Delete'); ?>"></a></dd>
<dd class="propertycontainer hidden" id="nickname_value" data-element="NICKNAME"><input id="nickname" required="required" type="text" class="contacts_property big" name="value" value="" placeholder="<?php echo $l->t('Enter nickname'); ?>" /><a role="button" class="action delete" title="<?php echo $l->t('Delete'); ?>"></a></dd>
<dt class="hidden" id="url_label" data-element="URL"><label for="url"><?php echo $l->t('Web site'); ?></label></dt>
<dd class="propertycontainer hidden" id="url_value" data-element="URL"><input id="url" required="required" name="value[URL]" type="url" class="contacts_property big" name="value" value="" placeholder="<?php echo $l->t('http://www.somesite.com'); ?>" /><a role="button" class="action globe" title="<?php echo $l->t('Go to web site'); ?>"><a role="button" class="action delete" title="<?php echo $l->t('Delete'); ?>"></a></dd>
<dd class="propertycontainer hidden" id="url_value" data-element="URL"><input id="url" required="required" type="url" class="contacts_property big" name="value" value="" placeholder="<?php echo $l->t('http://www.somesite.com'); ?>" /><a role="button" class="action globe" title="<?php echo $l->t('Go to web site'); ?>"><a role="button" class="action delete" title="<?php echo $l->t('Delete'); ?>"></a></dd>
<dt class="hidden" id="bday_label" data-element="BDAY"><label for="bday"><?php echo $l->t('Birthday'); ?></label></dt>
<dd class="propertycontainer hidden" id="bday_value" data-element="BDAY"><input id="bday" required="required" name="value" type="text" class="contacts_property big" value="" placeholder="<?php echo $l->t('dd-mm-yyyy'); ?>" /><a role="button" class="action delete" title="<?php echo $l->t('Delete'); ?>"></a></dd>
<dt class="hidden" id="categories_label" data-element="CATEGORIES"><label for="categories"><?php echo $l->t('Groups'); ?></label></dt>
<dd class="propertycontainer hidden" id="categories_value" data-element="CATEGORIES"><input id="categories" required="required" name="value[CATEGORIES]" type="text" class="contacts_property bold" name="value" value="" placeholder="
<dd class="propertycontainer hidden" id="categories_value" data-element="CATEGORIES"><input id="categories" required="required" type="text" class="contacts_property bold" name="value" value="" placeholder="
<?php echo $l->t('Separate groups with commas'); ?>" />
<a role="button" class="action delete" title="<?php echo $l->t('Delete'); ?>"></a><a role="button" class="action edit" title="<?php echo $l->t('Edit groups'); ?>"></a></dd>
</dl>
@ -121,19 +121,3 @@ $id = isset($_['id']) ? $_['id'] : '';
<div id="edit_photo_dialog" title="Edit photo">
<div id="edit_photo_dialog_img"></div>
</div>
<script language="Javascript">
$(document).ready(function(){
if('<?php echo $id; ?>'!='') {
$.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':'<?php echo $id; ?>'},function(jsondata){
if(jsondata.status == 'success'){
$('#leftcontent li[data-id="<?php echo $id; ?>"]').addClass('active');
Contacts.UI.Card.loadContact(jsondata.data);
Contacts.UI.loadHandlers();
}
else{
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
}
});
}
});
</script>

View file

@ -1,12 +1,10 @@
<?php foreach( $_['contacts'] as $contact ):
$display = trim($contact['fullname']);
if(!$display) {
$vcard = OC_Contacts_App::getContactVCard($contact['id']);
if(!is_null($vcard)) {
$struct = OC_Contacts_VCard::structureContact($vcard);
$display = isset($struct['EMAIL'][0])?$struct['EMAIL'][0]['value']:'[UNKNOWN]';
}
<?php
foreach($_['books'] as $id => $addressbook) {
echo '<h3 class="addressbook" data-id="'.$id.'">'.$addressbook['displayname'].'</h3>';
echo '<ul class="contacts hidden" data-id="'.$id.'">';
foreach($addressbook['contacts'] as $contact) {
echo '<li role="button" data-bookid="'.$contact['addressbookid'].'" data-id="'.$contact['id'].'"><a href="index.php?id='.$contact['id'].'" style="background: url('.link_to('contacts','thumbnail.php').'?id='.$contact['id'].') no-repeat scroll 0 0 transparent;">'.$contact['displayname'].'</a></li>';
}
echo '</ul>';
}
?>
<li role="button" book-id="<?php echo $contact['addressbookid']; ?>" data-id="<?php echo $contact['id']; ?>"><a href="index.php?id=<?php echo $contact['id']; ?>"><?php echo htmlspecialchars($display); ?></a></li>
<?php endforeach; ?>

View file

@ -4,7 +4,7 @@ $tmpkey = $_['tmpkey'];
$requesttoken = $_['requesttoken'];
OCP\Util::writeLog('contacts','templates/part.cropphoto.php: tmpkey: '.$tmpkey, OCP\Util::DEBUG);
?>
<script language="Javascript">
<script type="text/javascript">
jQuery(function($) {
$('#cropbox').Jcrop({
onChange: showCoords,

View file

@ -16,7 +16,7 @@ body { background:#fefefe; font:normal .8em/1.6em "Lucida Grande", Arial, Verdan
/* HEADERS */
#body-user #header, #body-settings #header { position:fixed; top:0; z-index:100; width:100%; height:2.5em; padding:.5em; background:#1d2d44; -moz-box-shadow:0 0 10px rgba(0, 0, 0, .5), inset 0 -2px 10px #222; -webkit-box-shadow:0 0 10px rgba(0, 0, 0, .5), inset 0 -2px 10px #222; box-shadow:0 0 10px rgba(0, 0, 0, .5), inset 0 -2px 10px #222; }
#body-user #header, #body-settings #header { position:fixed; top:0; left:0; right:0; z-index:100; height:2.5em; line-height:2.5em; padding:.5em; background:#1d2d44; -moz-box-shadow:0 0 10px rgba(0, 0, 0, .5), inset 0 -2px 10px #222; -webkit-box-shadow:0 0 10px rgba(0, 0, 0, .5), inset 0 -2px 10px #222; box-shadow:0 0 10px rgba(0, 0, 0, .5), inset 0 -2px 10px #222; }
#body-login #header { margin: -2em auto 0; text-align:center; height:10em; padding:1em 0 .5em;
-moz-box-shadow:0 0 1em rgba(0, 0, 0, .5); -webkit-box-shadow:0 0 1em rgba(0, 0, 0, .5); box-shadow:0 0 1em rgba(0, 0, 0, .5);
background: #1d2d44; /* Old browsers */
@ -28,8 +28,9 @@ background: -ms-linear-gradient(top, #35537a 0%,#1d2d42 100%); /* IE10+ */
background: linear-gradient(top, #35537a 0%,#1d2d42 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#35537a', endColorstr='#1d2d42',GradientType=0 ); /* IE6-9 */ }
#owncloud { float:left; }
#owncloud { float:left; vertical-align:middle; }
.header-right { float:right; vertical-align:middle; padding:0 0.5em; }
.header-right > * { vertical-align:middle; }
/* INPUTS */
input[type="text"], input[type="password"] { cursor:text; }
@ -49,7 +50,7 @@ input[type="checkbox"] { width:auto; }
#body-login input[type="text"], #body-login input[type="password"] { width: 13em; }
#body-login input.login { width: auto; float: right; }
#remember_login { margin:.8em .2em 0 1em; }
.searchbox input[type="search"] { position:fixed; font-size:1.2em; top:.4em; right:3em; padding:.2em .5em .2em 1.5em; background:#fff url('../img/actions/search.svg') no-repeat .5em center; border:0; -moz-border-radius:1em; -webkit-border-radius:1em; border-radius:1em; -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=70)"; filter:alpha(opacity=70);opacity:.7; -webkit-transition:opacity 300ms; -moz-transition:opacity 300ms; -o-transition:opacity 300ms; transition:opacity 300ms; }
.searchbox input[type="search"] { font-size:1.2em; padding:.2em .5em .2em 1.5em; background:#fff url('../img/actions/search.svg') no-repeat .5em center; border:0; -moz-border-radius:1em; -webkit-border-radius:1em; border-radius:1em; -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=70)"; filter:alpha(opacity=70);opacity:.7; -webkit-transition:opacity 300ms; -moz-transition:opacity 300ms; -o-transition:opacity 300ms; transition:opacity 300ms; }
input[type="submit"].enabled { background:#66f866; border:1px solid #5e5; -moz-box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #cfc inset; -webkit-box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #cfc inset; box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #cfc inset; }
input[type="submit"].highlight{ background:#ffc100; border:1px solid #db0; text-shadow:#ffeedd 0 1px 0; -moz-box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #ffeedd inset; -webkit-box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #ffeedd inset; box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #ffeedd inset; }
#select_all{ margin-top: .4em !important;}
@ -101,8 +102,6 @@ label.infield { cursor: text !important; }
#expand { position:relative; z-index:100; margin-bottom:-.5em; padding:.5em 10.1em .7em 1.2em; cursor:pointer; }
#expand+span { position:absolute; z-index:99; margin:-1.7em 0 0 2.5em; font-size:1.2em; color:#666; text-shadow:#f8f8f8 0 1px 0; -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; filter:alpha(opacity=0); opacity:0; -webkit-transition:opacity 300ms; -moz-transition:opacity 300ms; -o-transition:opacity 300ms; transition:opacity 300ms; }
#expand:hover+span, #expand+span:hover { -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; filter:alpha(opacity=100); opacity:1; cursor:pointer; }
#logout { position:absolute; right:0; top:0; padding:1.2em 2em .55em 1.2em; }
/* VARIOUS REUSABLE SELECTORS */
.hidden { display:none; }

View file

@ -6,10 +6,10 @@ OC_App::loadApps();
if ($service == 'core.css'){
$minimizer = new OC_Minimizer_CSS();
$files = $minimizer->findFiles(OC_Util::$core_styles);
$minimizer->output($files);
$minimizer->output($files, $service);
}
else if ($service == 'core.js'){
$minimizer = new OC_Minimizer_JS();
$files = $minimizer->findFiles(OC_Util::$core_scripts);
$minimizer->output($files);
$minimizer->output($files, $service);
}

View file

@ -45,10 +45,10 @@
<body id="<?php echo $_['bodyid'];?>">
<header><div id="header">
<a href="<?php echo link_to('', 'index.php'); ?>" title="" id="owncloud"><img class="svg" src="<?php echo image_path('', 'logo-wide.svg'); ?>" alt="ownCloud" /></a>
<form class="searchbox" action="#" method="post">
<a class="header-right" id="logout" href="<?php echo link_to('', 'index.php'); ?>?logout=true"><img class="svg" alt="<?php echo $l->t('Log out');?>" title="<?php echo $l->t('Log out');?>" src="<?php echo image_path('', 'actions/logout.svg'); ?>" /></a>
<form class="searchbox header-right" action="#" method="post">
<input id="searchbox" class="svg" type="search" name="query" value="<?php if(isset($_POST['query'])){echo htmlentities($_POST['query']);};?>" autocomplete="off" />
</form>
<a id="logout" href="<?php echo link_to('', 'index.php'); ?>?logout=true"><img class="svg" alt="<?php echo $l->t('Log out');?>" title="<?php echo $l->t('Log out');?>" src="<?php echo image_path('', 'actions/logout.svg'); ?>" /></a>
</div></header>
<nav><div id="navigation">

View file

@ -282,7 +282,7 @@ class OC{
if(substr(OC::$REQUESTEDFILE, -3) == 'css'){
$file = 'apps/' . OC::$REQUESTEDAPP . '/' . OC::$REQUESTEDFILE;
$minimizer = new OC_Minimizer_CSS();
$minimizer->output(array(array(OC::$APPSROOT, OC::$APPSWEBROOT, $file)));
$minimizer->output(array(array(OC::$APPSROOT, OC::$APPSWEBROOT, $file)), $file);
exit;
}elseif(substr(OC::$REQUESTEDFILE, -3) == 'php'){
require_once(OC::$APPSROOT . '/apps/' . OC::$REQUESTEDAPP . '/' . OC::$REQUESTEDFILE);

78
lib/cache/fileglobal.php vendored Normal file
View file

@ -0,0 +1,78 @@
<?php
/**
* Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
class OC_Cache_FileGlobal{
protected function getCacheDir() {
$cache_dir = get_temp_dir().'/owncloud-'.OC_Util::getInstanceId().'/';
if (!is_dir($cache_dir)) {
mkdir($cache_dir);
}
return $cache_dir;
}
protected function fixKey($key) {
return str_replace('/', '_', $key);
}
public function get($key) {
$key = $this->fixKey($key);
if ($this->hasKey($key)) {
$cache_dir = $this->getCacheDir();
return file_get_contents($cache_dir.$key);
}
return null;
}
public function set($key, $value, $ttl=0) {
$key = $this->fixKey($key);
$cache_dir = $this->getCacheDir();
if ($cache_dir and file_put_contents($cache_dir.$key, $value)) {
if ($ttl === 0) {
$ttl = 86400; // 60*60*24
}
return touch($cache_dir.$key, time() + $ttl);
}
return false;
}
public function hasKey($key) {
$key = $this->fixKey($key);
$cache_dir = $this->getCacheDir();
if ($cache_dir && is_file($cache_dir.$key)) {
$mtime = filemtime($cache_dir.$key);
if ($mtime < time()) {
unlink($cache_dir.$key);
return false;
}
return true;
}
return false;
}
public function remove($key) {
$cache_dir = $this->getCacheDir();
if(!$cache_dir){
return false;
}
$key = $this->fixKey($key);
return unlink($cache_dir.$key);
}
public function clear(){
$cache_dir = $this->getCacheDir();
if($cache_dir and is_dir($cache_dir)){
$dh=opendir($cache_dir);
while($file=readdir($dh)){
if($file!='.' and $file!='..'){
unlink($cache_dir.$file);
}
}
}
}
}

View file

@ -26,14 +26,30 @@ abstract class OC_Minimizer
abstract public function minimizeFiles($files);
public function output($files) {
public function output($files, $cache_key) {
header('Content-Type: '.$this->contentType);
OC_Response::enableCaching();
$last_modified = $this->getLastModified($files);
OC_Response::setLastModifiedHeader($last_modified);
$out = $this->minimizeFiles($files);
OC_Response::setETagHeader(md5($out));
$gzout = false;
$cache = new OC_Cache_FileGlobal();
if (!OC_Request::isNoCache() && (!defined('DEBUG') || !DEBUG)){
$gzout = $cache->get($cache_key.'.gz');
OC_Response::setETagHeader(md5($gzout));
}
if (!$gzout) {
$out = $this->minimizeFiles($files);
$gzout = gzencode($out);
$cache->set($cache_key.'.gz', $gzout);
}
if ($encoding = OC_Request::acceptGZip()) {
header('Content-Encoding: '.$encoding);
$out = $gzout;
} else {
$out = gzdecode($gzout);
}
header('Content-Length: '.strlen($out));
echo $out;
}

28
lib/request.php Normal file
View file

@ -0,0 +1,28 @@
<?php
/**
* Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
class OC_Request {
static public function isNoCache() {
if (!isset($_SERVER['HTTP_CACHE_CONTROL'])) {
return false;
}
return $_SERVER['HTTP_CACHE_CONTROL'] == 'no-cache';
}
static public function acceptGZip() {
if (!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {
return false;
}
$HTTP_ACCEPT_ENCODING = $_SERVER["HTTP_ACCEPT_ENCODING"];
if( strpos($HTTP_ACCEPT_ENCODING, 'x-gzip') !== false )
return 'x-gzip';
else if( strpos($HTTP_ACCEPT_ENCODING,'gzip') !== false )
return 'gzip';
return false;
}
}

View file

@ -39,7 +39,7 @@ OC.Log={
row.append(appTd);
var messageTd=$('<td/>');
messageTd.text(entry.message);
messageTd.text(entry.message.replace(/</, "&lt;").replace(/>/, "&gt;"));
row.append(messageTd);
var timeTd=$('<td/>');