Merge branch 'master' into calendar_repeat

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

View File

@ -6,15 +6,51 @@
* See the COPYING-README file. * 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::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::checkAppEnabled('contacts');
$ids = OC_Contacts_Addressbook::activeIds(OCP\USER::getUser()); $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 = new OCP\Template("contacts", "part.contacts");
$tmpl->assign('contacts', $contacts, false); $tmpl->assign('books', $contacts_addressbook, false);
$page = $tmpl->fetchPage(); $page = $tmpl->fetchPage();
OCP\JSON::success(array('data' => array( 'page' => $page ))); OCP\JSON::success(array('data' => array( 'page' => $page )));
?>

View File

@ -2,9 +2,12 @@
font-weight: bold; font-weight: bold;
}*/ }*/
#leftcontent { top: 3.5em !important; padding: 0; margin: 0; } #leftcontent { top: 3.5em !important; padding: 0; margin: 0; }
#leftcontent a { padding: 0 0 0 25px; }
#rightcontent { top: 3.5em !important; padding-top: 5px; } #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; } #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; }
#contacts a { height: 23px; display: block; margin: 0 0 0 0; padding: 0 0 0 25px; } #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;} #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; } #contacts_newcontact { float: left; margin: 0.2em 0 0 1em; }
#chooseaddressbook { float: right; margin: 0.2em 1em 0 0; } #chooseaddressbook { float: right; margin: 0.2em 1em 0 0; }

View File

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

View File

@ -33,15 +33,15 @@ $id = isset($_['id']) ? $_['id'] : '';
</span> </span>
<dl id="identityprops" class="form"> <dl id="identityprops" class="form">
<dt class="hidden" id="org_label" data-element="ORG"><label for="org"><?php echo $l->t('Organization'); ?></label></dt> <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> <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> <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> <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> <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> <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'); ?>" /> <?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> <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> </dl>
@ -121,19 +121,3 @@ $id = isset($_['id']) ? $_['id'] : '';
<div id="edit_photo_dialog" title="Edit photo"> <div id="edit_photo_dialog" title="Edit photo">
<div id="edit_photo_dialog_img"></div> <div id="edit_photo_dialog_img"></div>
</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 ): <?php
$display = trim($contact['fullname']); foreach($_['books'] as $id => $addressbook) {
if(!$display) { echo '<h3 class="addressbook" data-id="'.$id.'">'.$addressbook['displayname'].'</h3>';
$vcard = OC_Contacts_App::getContactVCard($contact['id']); echo '<ul class="contacts hidden" data-id="'.$id.'">';
if(!is_null($vcard)) { foreach($addressbook['contacts'] as $contact) {
$struct = OC_Contacts_VCard::structureContact($vcard); 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>';
$display = isset($struct['EMAIL'][0])?$struct['EMAIL'][0]['value']:'[UNKNOWN]';
}
} }
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']; $requesttoken = $_['requesttoken'];
OCP\Util::writeLog('contacts','templates/part.cropphoto.php: tmpkey: '.$tmpkey, OCP\Util::DEBUG); OCP\Util::writeLog('contacts','templates/part.cropphoto.php: tmpkey: '.$tmpkey, OCP\Util::DEBUG);
?> ?>
<script language="Javascript"> <script type="text/javascript">
jQuery(function($) { jQuery(function($) {
$('#cropbox').Jcrop({ $('#cropbox').Jcrop({
onChange: showCoords, onChange: showCoords,

View File

@ -16,7 +16,7 @@ body { background:#fefefe; font:normal .8em/1.6em "Lucida Grande", Arial, Verdan
/* HEADERS */ /* 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; #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); -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 */ 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 */ background: linear-gradient(top, #35537a 0%,#1d2d42 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#35537a', endColorstr='#1d2d42',GradientType=0 ); /* IE6-9 */ } 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 */ /* INPUTS */
input[type="text"], input[type="password"] { cursor:text; } 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[type="text"], #body-login input[type="password"] { width: 13em; }
#body-login input.login { width: auto; float: right; } #body-login input.login { width: auto; float: right; }
#remember_login { margin:.8em .2em 0 1em; } #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"].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; } 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;} #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 { 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+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; } #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 */ /* VARIOUS REUSABLE SELECTORS */
.hidden { display:none; } .hidden { display:none; }

View File

@ -6,10 +6,10 @@ OC_App::loadApps();
if ($service == 'core.css'){ if ($service == 'core.css'){
$minimizer = new OC_Minimizer_CSS(); $minimizer = new OC_Minimizer_CSS();
$files = $minimizer->findFiles(OC_Util::$core_styles); $files = $minimizer->findFiles(OC_Util::$core_styles);
$minimizer->output($files); $minimizer->output($files, $service);
} }
else if ($service == 'core.js'){ else if ($service == 'core.js'){
$minimizer = new OC_Minimizer_JS(); $minimizer = new OC_Minimizer_JS();
$files = $minimizer->findFiles(OC_Util::$core_scripts); $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'];?>"> <body id="<?php echo $_['bodyid'];?>">
<header><div id="header"> <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> <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" /> <input id="searchbox" class="svg" type="search" name="query" value="<?php if(isset($_POST['query'])){echo htmlentities($_POST['query']);};?>" autocomplete="off" />
</form> </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> </div></header>
<nav><div id="navigation"> <nav><div id="navigation">

View File

@ -282,7 +282,7 @@ class OC{
if(substr(OC::$REQUESTEDFILE, -3) == 'css'){ if(substr(OC::$REQUESTEDFILE, -3) == 'css'){
$file = 'apps/' . OC::$REQUESTEDAPP . '/' . OC::$REQUESTEDFILE; $file = 'apps/' . OC::$REQUESTEDAPP . '/' . OC::$REQUESTEDFILE;
$minimizer = new OC_Minimizer_CSS(); $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; exit;
}elseif(substr(OC::$REQUESTEDFILE, -3) == 'php'){ }elseif(substr(OC::$REQUESTEDFILE, -3) == 'php'){
require_once(OC::$APPSROOT . '/apps/' . OC::$REQUESTEDAPP . '/' . OC::$REQUESTEDFILE); 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); abstract public function minimizeFiles($files);
public function output($files) { public function output($files, $cache_key) {
header('Content-Type: '.$this->contentType); header('Content-Type: '.$this->contentType);
OC_Response::enableCaching(); OC_Response::enableCaching();
$last_modified = $this->getLastModified($files); $last_modified = $this->getLastModified($files);
OC_Response::setLastModifiedHeader($last_modified); OC_Response::setLastModifiedHeader($last_modified);
$out = $this->minimizeFiles($files); $gzout = false;
OC_Response::setETagHeader(md5($out)); $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)); header('Content-Length: '.strlen($out));
echo $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); row.append(appTd);
var messageTd=$('<td/>'); var messageTd=$('<td/>');
messageTd.text(entry.message); messageTd.text(entry.message.replace(/</, "&lt;").replace(/>/, "&gt;"));
row.append(messageTd); row.append(messageTd);
var timeTd=$('<td/>'); var timeTd=$('<td/>');