From 623afb69b6a51d57ca99d1d825b6c433a93baa96 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Sun, 12 Feb 2012 16:11:41 +0100 Subject: [PATCH] Contacts: cleanup OC_L10N usage --- apps/contacts/ajax/addbook.php | 1 - apps/contacts/ajax/addcard.php | 3 +-- apps/contacts/ajax/addcontact.php | 3 +-- apps/contacts/ajax/addproperty.php | 9 ++++----- apps/contacts/ajax/chooseaddressbook.php | 1 - apps/contacts/ajax/contactdetails.php | 9 ++++----- apps/contacts/ajax/createaddressbook.php | 6 ++---- apps/contacts/ajax/deletebook.php | 1 - apps/contacts/ajax/deleteproperty.php | 6 ++---- apps/contacts/ajax/editaddressbook.php | 1 - apps/contacts/ajax/importdialog.php | 1 - apps/contacts/ajax/loadphoto.php | 1 - apps/contacts/ajax/messagebox.php | 1 - apps/contacts/ajax/savecrop.php | 1 - apps/contacts/ajax/saveproperty.php | 13 ++++++------- apps/contacts/ajax/showsetproperty.php | 3 +-- apps/contacts/ajax/updateaddressbook.php | 2 -- apps/contacts/ajax/uploadphoto.php | 13 ++++++------- apps/contacts/appinfo/app.php | 6 ++---- apps/contacts/templates/part.addcardform.php | 3 --- apps/contacts/templates/part.contact.php | 1 - apps/contacts/templates/part.edit_name_dialog.php | 1 - apps/contacts/thumbnail.php | 2 -- 23 files changed, 29 insertions(+), 59 deletions(-) diff --git a/apps/contacts/ajax/addbook.php b/apps/contacts/ajax/addbook.php index 36acb9af39..f5852183cc 100644 --- a/apps/contacts/ajax/addbook.php +++ b/apps/contacts/ajax/addbook.php @@ -7,7 +7,6 @@ */ require_once('../../../lib/base.php'); -$l10n = new OC_L10N('contacts'); OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('contacts'); $book = array( diff --git a/apps/contacts/ajax/addcard.php b/apps/contacts/ajax/addcard.php index fbf5b57ae7..b1dc69a469 100644 --- a/apps/contacts/ajax/addcard.php +++ b/apps/contacts/ajax/addcard.php @@ -31,7 +31,6 @@ function bailOut($msg) { // Check if we are a user OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('contacts'); -$l=new OC_L10N('contacts'); $aid = $_POST['id']; OC_Contacts_App::getAddressbook( $aid ); // is owner access check @@ -95,7 +94,7 @@ foreach( $add as $propname){ } $id = OC_Contacts_VCard::add($aid,$vcard->serialize()); if(!$id) { - OC_JSON::error(array('data' => array('message' => $l->t('There was an error adding the contact.')))); + OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('There was an error adding the contact.')))); OC_Log::write('contacts','ajax/addcard.php: Recieved non-positive ID on adding card: '.$id, OC_Log::ERROR); exit(); } diff --git a/apps/contacts/ajax/addcontact.php b/apps/contacts/ajax/addcontact.php index 8003432701..5d17631caa 100644 --- a/apps/contacts/ajax/addcontact.php +++ b/apps/contacts/ajax/addcontact.php @@ -34,7 +34,6 @@ function debug($msg) { // Check if we are a user OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('contacts'); -$l=new OC_L10N('contacts'); foreach ($_POST as $key=>$element) { debug('_POST: '.$key.'=>'.$element); @@ -55,7 +54,7 @@ $vcard->setString('N',$n); $id = OC_Contacts_VCard::add($aid,$vcard->serialize()); if(!$id) { - OC_JSON::error(array('data' => array('message' => $l->t('There was an error adding the contact.')))); + OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('There was an error adding the contact.')))); OC_Log::write('contacts','ajax/addcontact.php: Recieved non-positive ID on adding card: '.$id, OC_Log::ERROR); exit(); } diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php index 23f0a9379b..03a45532f9 100644 --- a/apps/contacts/ajax/addproperty.php +++ b/apps/contacts/ajax/addproperty.php @@ -26,7 +26,6 @@ require_once('../../../lib/base.php'); // Check if we are a user OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('contacts'); -$l=new OC_L10N('contacts'); $id = $_POST['id']; $vcard = OC_Contacts_App::getContactVCard( $id ); @@ -36,7 +35,7 @@ $value = $_POST['value']; if(!is_array($value)){ $value = trim($value); if(!$value && in_array($name, array('TEL', 'EMAIL', 'ORG', 'BDAY', 'NICKNAME'))) { - OC_JSON::error(array('data' => array('message' => $l->t('Cannot add empty property.')))); + OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot add empty property.')))); exit(); } } elseif($name === 'ADR') { // only add if non-empty elements. @@ -48,7 +47,7 @@ if(!is_array($value)){ } } if($empty) { - OC_JSON::error(array('data' => array('message' => $l->t('At least one of the address fields has to be filled out.')))); + OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('At least one of the address fields has to be filled out.')))); exit(); } } @@ -59,7 +58,7 @@ $current = $vcard->select($name); foreach($current as $item) { $tmpvalue = (is_array($value)?implode(';', $value):$value); if($tmpvalue == $item->value) { - OC_JSON::error(array('data' => array('message' => $l->t('Trying to add duplicate property: ').$name.': '.$tmpvalue))); + OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Trying to add duplicate property: ').$name.': '.$tmpvalue))); OC_Log::write('contacts','ajax/addproperty.php: Trying to add duplicate property: '.$name.': '.$tmpvalue, OC_Log::DEBUG); exit(); } @@ -114,7 +113,7 @@ foreach ($parameters as $key=>$element) { $checksum = md5($vcard->children[$line]->serialize()); if(!OC_Contacts_VCard::edit($id,$vcard->serialize())) { - OC_JSON::error(array('data' => array('message' => $l->t('Error adding contact property.')))); + OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error adding contact property.')))); OC_Log::write('contacts','ajax/addproperty.php: Error updating contact property: '.$name, OC_Log::ERROR); exit(); } diff --git a/apps/contacts/ajax/chooseaddressbook.php b/apps/contacts/ajax/chooseaddressbook.php index b0a10bb311..8298c16b04 100644 --- a/apps/contacts/ajax/chooseaddressbook.php +++ b/apps/contacts/ajax/chooseaddressbook.php @@ -7,7 +7,6 @@ */ require_once('../../../lib/base.php'); -$l10n = new OC_L10N('contacts'); OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('contacts'); diff --git a/apps/contacts/ajax/contactdetails.php b/apps/contacts/ajax/contactdetails.php index f7ac25ea51..f35fd595c5 100644 --- a/apps/contacts/ajax/contactdetails.php +++ b/apps/contacts/ajax/contactdetails.php @@ -34,15 +34,14 @@ function debug($msg) { // Check if we are a user OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('contacts'); -$l=new OC_L10N('contacts'); $id = isset($_GET['id'])?$_GET['id']:null; if(is_null($id)) { - bailOut($l->t('Missing ID')); + bailOut(OC_Contacts_App::$l10n->t('Missing ID')); } $vcard = OC_Contacts_App::getContactVCard( $id ); if(is_null($vcard)) { - bailOut($l->t('Error parsing VCard for ID: "'.$id.'"')); + bailOut(OC_Contacts_App::$l10n->t('Error parsing VCard for ID: "'.$id.'"')); } $details = OC_Contacts_VCard::structureContact($vcard); @@ -54,7 +53,7 @@ if(!isset($details['FN'])) { } elseif(isset($details['EMAIL'])) { $details['FN'] = array('value' => $details['EMAIL'][0]['value']); } else { - $details['FN'] = array('value' => $l->t('Unknown')); + $details['FN'] = array('value' => OC_Contacts_App::$l10n->t('Unknown')); } } @@ -73,4 +72,4 @@ if(isset($details['PHOTO'])) { } $details['id'] = $id; -OC_JSON::success(array('data' => $details)); \ No newline at end of file +OC_JSON::success(array('data' => $details)); diff --git a/apps/contacts/ajax/createaddressbook.php b/apps/contacts/ajax/createaddressbook.php index 3d766b6a60..fbd70bae58 100644 --- a/apps/contacts/ajax/createaddressbook.php +++ b/apps/contacts/ajax/createaddressbook.php @@ -8,8 +8,6 @@ */ require_once('../../../lib/base.php'); -$l10n = new OC_L10N('contacts'); - // Check if we are a user OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('contacts'); @@ -17,13 +15,13 @@ OC_JSON::checkAppEnabled('contacts'); $userid = OC_User::getUser(); $bookid = OC_Contacts_Addressbook::add($userid, strip_tags($_POST['name']), null); if(!$bookid) { - OC_JSON::error(array('data' => array('message' => $l->t('Error adding addressbook.')))); + OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error adding addressbook.')))); OC_Log::write('contacts','ajax/createaddressbook.php: Error adding addressbook: '.$_POST['name'], OC_Log::ERROR); exit(); } if(!OC_Contacts_Addressbook::setActive($bookid, 1)) { - OC_JSON::error(array('data' => array('message' => $l->t('Error activating addressbook.')))); + OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error activating addressbook.')))); OC_Log::write('contacts','ajax/createaddressbook.php: Error activating addressbook: '.$bookid, OC_Log::ERROR); //exit(); } diff --git a/apps/contacts/ajax/deletebook.php b/apps/contacts/ajax/deletebook.php index d782c9dfb8..46d8deb486 100644 --- a/apps/contacts/ajax/deletebook.php +++ b/apps/contacts/ajax/deletebook.php @@ -23,7 +23,6 @@ // Init owncloud require_once('../../../lib/base.php'); -$l10n = new OC_L10N('contacts'); // Check if we are a user OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('contacts'); diff --git a/apps/contacts/ajax/deleteproperty.php b/apps/contacts/ajax/deleteproperty.php index d745d3271d..a9afffaad4 100644 --- a/apps/contacts/ajax/deleteproperty.php +++ b/apps/contacts/ajax/deleteproperty.php @@ -26,7 +26,6 @@ require_once('../../../lib/base.php'); // Check if we are a user OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('contacts'); -$l10n = new OC_L10N('contacts'); $id = $_GET['id']; $checksum = $_GET['checksum']; @@ -34,15 +33,14 @@ $checksum = $_GET['checksum']; $vcard = OC_Contacts_App::getContactVCard( $id ); $line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum); if(is_null($line)){ - $l=new OC_L10N('contacts'); - OC_JSON::error(array('data' => array( 'message' => $l->t('Information about vCard is incorrect. Please reload the page.')))); + OC_JSON::error(array('data' => array( 'message' => OC_Contacts_App::$l10n->t('Information about vCard is incorrect. Please reload the page.')))); exit(); } unset($vcard->children[$line]); if(!OC_Contacts_VCard::edit($id,$vcard->serialize())) { - OC_JSON::error(array('data' => array('message' => $l->t('Error deleting contact property.')))); + OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error deleting contact property.')))); OC_Log::write('contacts','ajax/deleteproperty.php: Error deleting contact property', OC_Log::ERROR); exit(); } diff --git a/apps/contacts/ajax/editaddressbook.php b/apps/contacts/ajax/editaddressbook.php index ced673ce80..a6262f39b2 100644 --- a/apps/contacts/ajax/editaddressbook.php +++ b/apps/contacts/ajax/editaddressbook.php @@ -7,7 +7,6 @@ */ require_once('../../../lib/base.php'); -$l10n = new OC_L10N('contacts'); OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('contacts'); $addressbook = OC_Contacts_App::getAddressbook($_GET['bookid']); diff --git a/apps/contacts/ajax/importdialog.php b/apps/contacts/ajax/importdialog.php index 17b4cebdbd..280e462f66 100644 --- a/apps/contacts/ajax/importdialog.php +++ b/apps/contacts/ajax/importdialog.php @@ -9,7 +9,6 @@ require_once('../../../lib/base.php'); OC_JSON::checkLoggedIn(); OC_Util::checkAppEnabled('contacts'); -$l10n = new OC_L10N('contacts'); $tmpl = new OC_Template('contacts', 'part.import'); $tmpl->assign('path', $_POST['path']); $tmpl->assign('filename', $_POST['filename']); diff --git a/apps/contacts/ajax/loadphoto.php b/apps/contacts/ajax/loadphoto.php index d9f7e737b5..358e046942 100644 --- a/apps/contacts/ajax/loadphoto.php +++ b/apps/contacts/ajax/loadphoto.php @@ -26,7 +26,6 @@ require_once('../../../lib/base.php'); // Check if we are a user OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('contacts'); -$l=new OC_L10N('contacts'); // foreach ($_POST as $key=>$element) { // OC_Log::write('contacts','ajax/savecrop.php: '.$key.'=>'.$element, OC_Log::DEBUG); diff --git a/apps/contacts/ajax/messagebox.php b/apps/contacts/ajax/messagebox.php index b3cad94767..408e7a537a 100644 --- a/apps/contacts/ajax/messagebox.php +++ b/apps/contacts/ajax/messagebox.php @@ -7,7 +7,6 @@ */ require_once('../../../lib/base.php'); -$l10n = new OC_L10N('contacts'); OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('contacts'); diff --git a/apps/contacts/ajax/savecrop.php b/apps/contacts/ajax/savecrop.php index 7b7384723c..1a84f6fdfa 100644 --- a/apps/contacts/ajax/savecrop.php +++ b/apps/contacts/ajax/savecrop.php @@ -28,7 +28,6 @@ OC_Log::write('contacts','ajax/savecrop.php: Huzzah!!!', OC_Log::DEBUG); // Check if we are a user OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('contacts'); -$l=new OC_L10N('contacts'); // foreach ($_POST as $key=>$element) { // OC_Log::write('contacts','ajax/savecrop.php: '.$key.'=>'.$element, OC_Log::DEBUG); diff --git a/apps/contacts/ajax/saveproperty.php b/apps/contacts/ajax/saveproperty.php index 8f575c6b81..6c8132c1db 100644 --- a/apps/contacts/ajax/saveproperty.php +++ b/apps/contacts/ajax/saveproperty.php @@ -26,7 +26,6 @@ require_once('../../../lib/base.php'); // Check if we are a user OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('contacts'); -$l=new OC_L10N('contacts'); function bailOut($msg) { OC_JSON::error(array('data' => array('message' => $msg))); @@ -59,24 +58,24 @@ if(is_array($value)){ // FIXME: How to strip_tags for compound values? $value = trim(strip_tags($value)); } if(!$id) { - bailOut($l->t('id is not set.')); + bailOut(OC_Contacts_App::$l10n->t('id is not set.')); } if(!$checksum) { - bailOut($l->t('checksum is not set.')); + bailOut(OC_Contacts_App::$l10n->t('checksum is not set.')); } if(!$name) { - bailOut($l->t('element name is not set.')); + bailOut(OC_Contacts_App::$l10n->t('element name is not set.')); } $vcard = OC_Contacts_App::getContactVCard( $id ); $line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum); if(is_null($line)) { - bailOut($l->t('Information about vCard is incorrect. Please reload the page.'.$checksum.' "'.$line.'"')); + bailOut(OC_Contacts_App::$l10n->t('Information about vCard is incorrect. Please reload the page.'.$checksum.' "'.$line.'"')); } $element = $vcard->children[$line]->name; if($element != $name) { - bailOut($l->t('Something went FUBAR. ').$name.' != '.$element); + bailOut(OC_Contacts_App::$l10n->t('Something went FUBAR. ').$name.' != '.$element); } switch($element) { @@ -123,7 +122,7 @@ $checksum = md5($vcard->children[$line]->serialize()); debug('New checksum: '.$checksum); if(!OC_Contacts_VCard::edit($id,$vcard->serialize())) { - OC_JSON::error(array('data' => array('message' => $l->t('Error updating contact property.')))); + OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error updating contact property.')))); OC_Log::write('contacts','ajax/setproperty.php: Error updating contact property: '.$value, OC_Log::ERROR); exit(); } diff --git a/apps/contacts/ajax/showsetproperty.php b/apps/contacts/ajax/showsetproperty.php index 577230e456..73bef65535 100644 --- a/apps/contacts/ajax/showsetproperty.php +++ b/apps/contacts/ajax/showsetproperty.php @@ -34,8 +34,7 @@ $vcard = OC_Contacts_App::getContactVCard( $id ); $line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum); if(is_null($line)){ - $l=new OC_L10N('contacts'); - OC_JSON::error(array('data' => array( 'message' => $l->t('Information about vCard is incorrect. Please reload the page.')))); + OC_JSON::error(array('data' => array( 'message' => OC_Contacts_App::$l10n->t('Information about vCard is incorrect. Please reload the page.')))); exit(); } diff --git a/apps/contacts/ajax/updateaddressbook.php b/apps/contacts/ajax/updateaddressbook.php index d6c1ad179b..b43b5b93a3 100644 --- a/apps/contacts/ajax/updateaddressbook.php +++ b/apps/contacts/ajax/updateaddressbook.php @@ -8,8 +8,6 @@ require_once('../../../lib/base.php'); -$l10n = new OC_L10N('contacts'); - // Check if we are a user OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('contacts'); diff --git a/apps/contacts/ajax/uploadphoto.php b/apps/contacts/ajax/uploadphoto.php index 62cd32f5db..9780df4647 100644 --- a/apps/contacts/ajax/uploadphoto.php +++ b/apps/contacts/ajax/uploadphoto.php @@ -94,14 +94,13 @@ if (!isset($_FILES['imagefile'])) { } $error = $_FILES['imagefile']['error']; if($error !== UPLOAD_ERR_OK) { - $l=new OC_L10N('contacts'); $errors = array( - 0=>$l->t("There is no error, the file uploaded with success"), - 1=>$l->t("The uploaded file exceeds the upload_max_filesize directive in php.ini").ini_get('upload_max_filesize'), - 2=>$l->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"), - 3=>$l->t("The uploaded file was only partially uploaded"), - 4=>$l->t("No file was uploaded"), - 6=>$l->t("Missing a temporary folder") + 0=>OC_Contacts_App::$l10n->t("There is no error, the file uploaded with success"), + 1=>OC_Contacts_App::$l10n->t("The uploaded file exceeds the upload_max_filesize directive in php.ini").ini_get('upload_max_filesize'), + 2=>OC_Contacts_App::$l10n->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"), + 3=>OC_Contacts_App::$l10n->t("The uploaded file was only partially uploaded"), + 4=>OC_Contacts_App::$l10n->t("No file was uploaded"), + 6=>OC_Contacts_App::$l10n->t("Missing a temporary folder") ); bailOut($errors[$error]); } diff --git a/apps/contacts/appinfo/app.php b/apps/contacts/appinfo/app.php index 23a5a4253d..9e424aa89f 100644 --- a/apps/contacts/appinfo/app.php +++ b/apps/contacts/appinfo/app.php @@ -1,6 +1,4 @@ 10, 'href' => OC_Helper::linkTo( 'contacts', 'index.php' ), 'icon' => OC_Helper::imagePath( 'settings', 'users.svg' ), - 'name' => $l->t('Contacts') )); + 'name' => OC_Contacts_App::$l10n->t('Contacts') )); OC_APP::registerPersonal('contacts','settings'); OC_UTIL::addScript('contacts', 'loader'); -require_once('apps/contacts/lib/search.php'); \ No newline at end of file +require_once('apps/contacts/lib/search.php'); diff --git a/apps/contacts/templates/part.addcardform.php b/apps/contacts/templates/part.addcardform.php index 17207d2ebc..1ad4c18b35 100644 --- a/apps/contacts/templates/part.addcardform.php +++ b/apps/contacts/templates/part.addcardform.php @@ -1,6 +1,3 @@ -
diff --git a/apps/contacts/templates/part.contact.php b/apps/contacts/templates/part.contact.php index 19e34fd3bb..bca3d9cbc2 100644 --- a/apps/contacts/templates/part.contact.php +++ b/apps/contacts/templates/part.contact.php @@ -1,5 +1,4 @@
diff --git a/apps/contacts/templates/part.edit_name_dialog.php b/apps/contacts/templates/part.edit_name_dialog.php index d525fd1f99..bb774b62bd 100644 --- a/apps/contacts/templates/part.edit_name_dialog.php +++ b/apps/contacts/templates/part.edit_name_dialog.php @@ -1,5 +1,4 @@