diff options
author | redmatrix <redmatrix@redmatrix.me> | 2015-06-25 18:23:48 -0700 |
---|---|---|
committer | redmatrix <redmatrix@redmatrix.me> | 2015-06-25 18:23:48 -0700 |
commit | b06b6f798fbfde8ab7f0ed25145b53560e6b4968 (patch) | |
tree | b2dc8fa88a16aa5e435484b44217a2223b987d59 | |
parent | 5f3edabd4529471b2ab33532ad38bbd65758b0cd (diff) | |
download | volse-hubzilla-b06b6f798fbfde8ab7f0ed25145b53560e6b4968.tar.gz volse-hubzilla-b06b6f798fbfde8ab7f0ed25145b53560e6b4968.tar.bz2 volse-hubzilla-b06b6f798fbfde8ab7f0ed25145b53560e6b4968.zip |
localise event calendar
-rw-r--r-- | include/attach.php | 124 | ||||
-rw-r--r-- | include/js_strings.php | 45 | ||||
-rwxr-xr-x | view/tpl/event_head.tpl | 15 | ||||
-rwxr-xr-x | view/tpl/js_strings.tpl | 10 |
4 files changed, 139 insertions, 55 deletions
diff --git a/include/attach.php b/include/attach.php index dd4f174dd..812090d5c 100644 --- a/include/attach.php +++ b/include/attach.php @@ -398,6 +398,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { return $ret; } + // The 'update' option sets db values without uploading a new attachment // 'replace' replaces the existing uploaded data // 'revision' creates a new revision with new upload data @@ -415,21 +416,13 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { $filename = basename($_FILES['userfile']['name']); $filesize = intval($_FILES['userfile']['size']); - - - - - - - } $existing_size = 0; if($options === 'replace') { - /** @BUG $replace is undefined here */ $x = q("select id, hash, filesize from attach where id = %d and uid = %d limit 1", - intval($replace), + intval($arr['id']), intval($channel_id) ); if(! $x) { @@ -457,33 +450,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { $hash = $x[0]['hash']; } - // Check storage limits - if($options !== 'update') { - $maxfilesize = get_config('system','maxfilesize'); - if(($maxfilesize) && ($filesize > $maxfilesize)) { - $ret['message'] = sprintf( t('File exceeds size limit of %d'), $maxfilesize); - @unlink($src); - return $ret; - } - - $limit = service_class_fetch($channel_id, 'attach_upload_limit'); - - if($limit !== false) { - $r = q("select sum(filesize) as total from attach where aid = %d ", - intval($channel['channel_account_id']) - ); - if(($r) && (($r[0]['total'] + $filesize) > ($limit - $existing_size))) { - $ret['message'] = upgrade_message(true) . sprintf(t("You have reached your limit of %1$.0f Mbytes attachment storage."), $limit / 1024000); - @unlink($src); - return $ret; - } - } - $mimetype = z_mime_content_type($filename); - } - - if(! $hash) - $hash = random_string(); $is_photo = 0; @@ -524,28 +491,76 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { $folder_hash = ''; } - $r = q("select filename from attach where ( filename = '%s' OR filename like '%s' ) and folder = '%s' ", - dbesc($filename), - dbesc($filename . '(%)'), - dbesc($folder_hash) - ); + if(! $options) { - if($r) { - $x = 1; + // A freshly uploaded file. Check for duplicate and resolve with the channel's overwrite settings. - do { - $found = false; - foreach($r as $rr) { - if($rr['filename'] === $filename . '(' . $x . ')') { - $found = true; - break; + $r = q("select filename, id, hash, filesize from attach where filename = '%s' and folder = '%s' ", + dbesc($filename), + dbesc($folder_hash) + ); + if($r) { + $overwrite = get_pconfig($channel_id,'system','overwrite_dup_files'); + if($overwrite) { + $options = 'replace'; + $existing_id = $x[0]['id']; + $existing_size = intval($x[0]['filesize']); + $hash = $x[0]['hash']; + } + else { + $r = q("select filename from attach where ( filename = '%s' OR filename like '%s' ) and folder = '%s' ", + dbesc($filename), + dbesc($filename . '(%)'), + dbesc($folder_hash) + ); + + if($r) { + $x = 1; + + do { + $found = false; + foreach($r as $rr) { + if($rr['filename'] === $filename . '(' . $x . ')') { + $found = true; + break; + } + } + if($found) + $x++; + } + while($found); + $filename = $filename . '(' . $x . ')'; } } - if($found) - $x++; - } - while($found); - $filename = $filename . '(' . $x . ')'; + } + } + + if(! $hash) + $hash = random_string(); + + // Check storage limits + if($options !== 'update') { + $maxfilesize = get_config('system','maxfilesize'); + + if(($maxfilesize) && ($filesize > $maxfilesize)) { + $ret['message'] = sprintf( t('File exceeds size limit of %d'), $maxfilesize); + @unlink($src); + return $ret; + } + + $limit = service_class_fetch($channel_id, 'attach_upload_limit'); + + if($limit !== false) { + $r = q("select sum(filesize) as total from attach where aid = %d ", + intval($channel['channel_account_id']) + ); + if(($r) && (($r[0]['total'] + $filesize) > ($limit - $existing_size))) { + $ret['message'] = upgrade_message(true) . sprintf(t("You have reached your limit of %1$.0f Mbytes attachment storage."), $limit / 1024000); + @unlink($src); + return $ret; + } + } + $mimetype = z_mime_content_type($filename); } $os_basepath = 'store/' . $channel['channel_address'] . '/' ; @@ -560,7 +575,8 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { $os_relpath .= $hash; - @file_put_contents($os_basepath . $os_relpath,@file_get_contents($src)); + if($src) + @file_put_contents($os_basepath . $os_relpath,@file_get_contents($src)); $created = datetime_convert(); diff --git a/include/js_strings.php b/include/js_strings.php index cae8da5de..a21461a52 100644 --- a/include/js_strings.php +++ b/include/js_strings.php @@ -39,7 +39,50 @@ function js_strings() { '$t14' => t('about a year'), '$t15' => t('%d years'), '$t16' => t(' '), // wordSeparator - '$t17' => ((t('timeago.numbers') != 'timeago.numbers') ? t('timeago.numbers') : '[]') + '$t17' => ((t('timeago.numbers') != 'timeago.numbers') ? t('timeago.numbers') : '[]'), + '$January' => t('January'), + '$February' => t('February'), + '$March' => t('March'), + '$April' => t('April'), + '$May' => t('May','long'), + '$June' => t('June'), + '$July' => t('July'), + '$August' => t('August'), + '$September' => t('September'), + '$October' => t('October'), + '$November' => t('November'), + '$December' => t('December'), + '$Jan' => t('Jan'), + '$Feb' => t('Feb'), + '$Mar' => t('Mar'), + '$Apr' => t('Apr'), + '$MayShort' => t('May','short'), + '$Jun' => t('Jun'), + '$Jul' => t('Jul'), + '$Aug' => t('Aug'), + '$Sep' => t('Sep'), + '$Oct' => t('Oct'), + '$Nov' => t('Nov'), + '$Dec' => t('Dec'), + '$Sunday' => t('Sunday'), + '$Monday' => t('Monday'), + '$Tuesday' => t('Tuesday'), + '$Wednesday' => t('Wednesday'), + '$Thursday' => t('Thursday'), + '$Friday' => t('Friday'), + '$Saturday' => t('Saturday'), + '$Sun' => t('Sun'), + '$Mon' => t('Mon'), + '$Tue' => t('Tue'), + '$Wed' => t('Wed'), + '$Thu' => t('Thu'), + '$Fri' => t('Fri'), + '$Sat' => t('Sat'), + '$today' => t('today','calendar'), + '$month' => t('month','calendar'), + '$week' => t('week','calendar'), + '$day' => t('day','calendar'), + '$allday' => t('All day','calendar') )); } diff --git a/view/tpl/event_head.tpl b/view/tpl/event_head.tpl index 6b59eef27..fd0ef0d9b 100755 --- a/view/tpl/event_head.tpl +++ b/view/tpl/event_head.tpl @@ -29,6 +29,21 @@ center: 'title', right: 'month,agendaWeek,agendaDay' }, + monthNames: aStr['monthNames'], + monthNamesShort: aStr['monthNamesShort'], + dayNames: aStr['dayNames'], + dayNamesShort: aStr['dayNamesShort'], + buttonText: { + prev: "<span class='fc-text-arrow'>‹</span>", + next: "<span class='fc-text-arrow'>›</span>", + prevYear: "<span class='fc-text-arrow'>«</span>", + nextYear: "<span class='fc-text-arrow'>»</span>", + today: aStr['today'], + month: aStr['month'], + week: aStr['week'], + day: aStr['day'] + }, + allDayText: aStr['allday'], timeFormat: 'H(:mm)', eventClick: function(calEvent, jsEvent, view) { showEvent(calEvent.id); diff --git a/view/tpl/js_strings.tpl b/view/tpl/js_strings.tpl index 2e7e85604..38cf8edbd 100755 --- a/view/tpl/js_strings.tpl +++ b/view/tpl/js_strings.tpl @@ -40,6 +40,16 @@ 't15' : "{{$t15}}", 't16' : "{{$t16}}", 't17' : "{{$t17}}", + + 'monthNames' : [ "{{$January}}","{{$February}}","{{$March}}","{{$April}}","{{$May}}","{{$June}}","{{$July}}","{{$August}}","{{$September}}","{{$October}}","{{$November}}","{{$December}}" ], + 'monthNamesShort' : [ "{{$Jan}}","{{$Feb}}","{{$Mar}}","{{$Apr}}","{{$MayShort}}","{{$Jun}}","{{$Jul}}","{{$Aug}}","{{$Sep}}","{{$Oct}}","{{$Nov}}","{{$Dec}}" ], + 'dayNames' : ["{{$Sunday}}","{{$Monday}}","{{$Tuesday}}","{{$Wednesday}}","{{$Thursday}}","{{$Friday}}","{{$Saturday}}"], + 'dayNamesShort' : ["{{$Sun}}","{{$Mon}}","{{$Tue}}","{{$Wed}}","{{$Thu}}","{{$Fri}}","{{$Sat}}"], + 'today' : "{{$today}}", + 'month' : "{{$month}}", + 'week' : "{{$week}}", + 'day' : "{{$day}}", + 'allday' : "{{$allday}}" }; </script> |