/** * Subscribe to a Premium offer. * * @return \Cake\Network\Response */ public function subscribe() { $this->loadComponent('Transaction'); $this->loadModel('PremiumOffers'); $this->loadModel('PremiumDiscounts'); $offer = $this->PremiumOffers->find('offerByPeriod', ['period' => $this->request->data['period']]); if (!$offer) { $this->Flash->error(__("This offer does not exist.")); return $this->redirect(['action' => 'index']); } //Check the discount code. $discountPercentage = null; if (!empty($this->request->data['discount'])) { $discount = $this->PremiumDiscounts->find('discountByCodeAndOffer', ['code' => $this->request->data['discount'], 'offer_id' => $offer->id]); if (is_null($discount) || !$this->PremiumDiscounts->isDiscountValid($discount)) { $this->Flash->error(__("Your discount code isn't valid or has already been used.")); return $this->redirect(['action' => 'index']); } else { $discountPercentage = $discount->discount; } } $price = Number::format($offer->price, ['locale' => 'en_US']); $tax = Number::format($offer->tax, ['locale' => 'en_US']); $custom = ['user_id' => $this->request->session()->read('Auth.User.id'), 'offer_id' => $offer->id, 'period' => $offer->period, 'discount_id' => isset($discount) ? $discount->id : null]; $paypalUrl = $this->Transaction->getPaypalUrl($price, $tax, __n('Premium {0} month', 'Premium {0} months', $offer->period, $offer->period), http_build_query($custom), $discountPercentage); if (!$paypalUrl) { $this->Flash->error(__("Unable to get the Paypal URL, please contact an administrator or try again later.")); return $this->redirect(['action' => 'index']); } $this->redirect($paypalUrl); }
public function beforeRender() { parent::beforeRender(); $breadcrumbs = array(array('link' => Router::url(array('controller' => 'pages', 'action' => 'index')), 'text' => __('Home'), 'active' => ''), array('link' => Router::url(array('controller' => 'condos', 'action' => 'index')), 'text' => __n('Condo', 'Condos', 2), 'active' => ''), array('link' => Router::url(array('controller' => 'condos', 'action' => 'view', $this->getPhkRequestVar('condo_id'))), 'text' => $this->getPhkRequestVar('condo_text'), 'active' => ''), array('link' => '', 'text' => __('Drafts'), 'active' => 'active')); $headerTitle = __('Drafts'); $this->set(compact('breadcrumbs', 'headerTitle')); }
/** * Returns a fuzzy time difference as 'nearly x units' or 'over x units' * * @param string $dateFrom From datetime in 'YYYY-MM-DD HH:MM:SS' format * @param string $dateTo To datetime in 'YYYY-MM-DD HH:MM:SS' format * @return string * @access public * @static * @note first parameter show be smaller than second parameter. * dates should be in this format 'yyyy-mm-dd 00:00:00' (time optional) */ public static function getDiff($dateFrom, $dateTo = null) { $dateTo = ($dateTo === null) ? date('Y-m-d H:i:s') : $dateTo; $from = self::_isValidDate($dateFrom); $to = self::_isValidDate($dateTo); if ($from && $to) { $dateDiff = self::_getDiff($from, $to); $dd['years'] = $dateDiff / YEAR; $dd['months'] = $dateDiff / MONTH; $dd['weeks'] = $dateDiff / WEEK; $dd['days'] = $dateDiff / DAY; $dd['hours'] = $dateDiff / HOUR; $dd['minutes'] = $dateDiff / MINUTE; $dd['seconds'] = $dateDiff; foreach ($dd as $period => $amt) { $whole = floor($amt); $fract = $amt - $whole; if ($whole >= 1 || $fract >= 0.94) { if ($fract >= 0.94) { return (__('almost', true) . " " . ($whole + 1) . " " . __n(rtrim($period, "s"), $period, $whole + 1, true)); } return (__("over ", true) . $whole . " " . __n(rtrim($period, "s"), $period, $whole, true)); } } } return ""; }
/** * set menu items * * @return void * @access protected * @throws */ protected function _setMenu() { $menuItems = array('Aros', 'AccessUsers'); $translationDomain = 'access'; $this->set(compact('menuItems', 'translationDomain')); $this->set('title_for_layout', __d('access', 'Access Setup')); $this->set('user_at_string', __n('User', 'Users', 1) . ' ' . $this->Session->read('Auth.User.name') . ' @ ' . __d('access', 'Access Setup')); }
public function index() { $page = isset($this->params['page']) ? (int) $this->params['page'] : 1; $perPage = 20; $pagination = $this->User->paginate($page, $perPage); $pagination['url'] = Router::getRoute('adminUserPaged'); $this->data->set('pagination', $pagination); $this->data->set('Users', $this->User->findAll(array('offset' => ($page - 1) * $perPage, 'limit' => $perPage))); $this->data->set('pageTitle', __n(':1 Benutzer', ':1 Benutzer', $pagination['total'])); }
public function minutes_to_hours($minutes) { if ($minutes <= 60) { return sprintf(__n("%d minute", "%d minutes", $minutes), $minutes); } else { $hours = floor($minutes / 60); $mins = $minutes - $hours * 60; $mins = str_pad($mins, 2, "0", STR_PAD_LEFT); return sprintf(__n("%d h", "%d h", $hours), $hours) . ' ' . sprintf(__n("%s", "%s", $mins), $mins); } }
public function index() { $this->BlogPost->unbind('Tag'); $page = @$this->params['page'] or 1; $BlogPosts = $this->BlogPost->findAll(array('offset' => ($page - 1) * $this->BlogPost->perPage, 'limit' => $this->BlogPost->perPage, 'depth' => 1)); $this->data->set('BlogPosts', $BlogPosts); $pagination = $this->BlogPost->paginate($page, $this->BlogPost->perPage); $pagination['url'] = Router::getRoute('adminBlogPostPaged'); $this->data->set('pagination', $pagination); // page title $this->data->set('pageTitle', __n(':1 Blogeintrag', ':1 Blogeinträge', $pagination['total'])); }
/** * beforeRender callback * * @param * @return * @access public * @throws */ public function beforeRender() { $this->set('title_for_layout', ''); $this->theme = Configure::read('Application.theme'); $this->set('unread_notifications', $this->Notify->countNotifications(AuthComponent::user('id'))); $this->set('user_at_string', __n('User', 'Users', 1) . ' ' . $this->Session->read('Auth.User.name') . ' @ ' . __('pHkapa')); // if is set layout for error , clear menuItems if ($this->_setErrorLayout()) { $menuItems = array(); $this->set(compact('menuItems')); } }
function set_crumb($action = null, $controller = null) { if ($action == null) { $action = $this->controller->action; } if ($controller == null) { $controller = $this->controller->name; } // Only return a crumb if the language value is assigned something. $language_format = __('% ' . $action, true); if ($language_format != '% ' . $action) { return sprintf($language_format, __n($controller, $controller, 1, true)); } }
/** * testSubstitutionPlural * * @return void */ public function testSubstitutionPlural() { $return = __n('single', 'plural {number}', 1); $this->assertSame('single', $return); $return = __n('single', 'plural {number}', 0); $this->assertSame('plural 0', $return); $return = __n('single', 'plural {number}', 2); $this->assertSame('plural 2', $return); $return = __n('single {color}', 'plural {number} {color}', 1, array('color' => 'blue')); $this->assertSame('single blue', $return); $return = __n('single {color}', 'plural {number} {color}', 0, array('color' => 'blue')); $this->assertSame('plural 0 blue', $return); $return = __n('single {color}', 'plural {number} {color}', 2, array('color' => 'blue')); $this->assertSame('plural 2 blue', $return); }
/** * Returns a formatted-for-humans file size. * * @param integer $size Size in bytes * * @return string Human readable size * * @since 1.0.0 */ public function toReadableSize($size) { switch (true) { case $size < 1024: return sprintf(__n('%d Byte', '%d Bytes', $size, true), $size); case round($size / 1024) < 1024: return sprintf(__('%d KB', true), $this->precision($size / 1024, 0)); case round($size / 1024 / 1024, 2) < 1024: return sprintf(__('%.2f MB', true), $this->precision($size / 1024 / 1024, 2)); case round($size / 1024 / 1024 / 1024, 2) < 1024: return sprintf(__('%.2f GB', true), $this->precision($size / 1024 / 1024 / 1024, 2)); default: return sprintf(__('%.2f TB', true), $this->precision($size / 1024 / 1024 / 1024 / 1024, 2)); } }
static function duration($duration) { $ret = array(); $days = floor($duration / 1440); if ($days) { $duration -= $days * 1440; $ret[] = $days . ' ' . __n('day', 'days', $days, true); } $hours = floor($duration / 60); if ($hours) { $duration -= $hours * 60; $ret[] = $hours . ' ' . __n('hour', 'hours', $hours, true); } if ($duration || empty($ret)) { $ret[] = $duration . ' ' . __n('minute', 'minutes', $duration, true); } return implode(', ', $ret); }
public function display($likes, $userKey = 'username') { $n = count($likes); if ($n > 0) { if ($n == 1) { $like = $likes[0]; $text = $this->Html->link($like['User'][$userKey], array('controller' => 'users', 'action' => 'view', $like['User']['id'])); } else { if ($n > 1) { $users = array(); foreach ($likes as $like) { $users[] = $like['User'][$userKey]; } $text = $this->Html->link(__n('%s people', '%s people', $n, $n), '#', array('title' => $this->Text->toList($users, __('and')))); } } echo __dn('like', '%s liked this.', '%s liked this.', $n, $text); } }
public function add() { $this->viewBuilder()->layout('json'); // Ensure user doesn't exceed picture limit $userId = $this->Auth->user('id'); $currentCount = $this->Pictures->getCountForUser($userId); $maxPicturesPerUser = Configure::read('maxPicturesPerUser'); if ($currentCount >= $maxPicturesPerUser) { $msg = 'Sorry, you\'ve reached your limit of ' . $maxPicturesPerUser . __n(' picture', ' pictures', $maxPicturesPerUser); throw new ForbiddenException($msg); } $picture = $this->Pictures->newEntity(); if ($this->request->is('post')) { $this->request->data['filename'] = $this->request->data('Filedata'); $this->request->data['is_primary'] = false; $this->request->data['user_id'] = $userId; $picture = $this->Pictures->patchEntity($picture, $this->request->data); if ($picture->errors()) { $exceptionMsg = 'There was an error uploading that picture. Please try again.'; $exceptionMsg .= '<ul>'; foreach ($picture->errors() as $field => $errors) { foreach ($errors as $label => $message) { $exceptionMsg .= '<li>' . $message . '</li>'; } } $exceptionMsg .= '</ul>'; throw new BadRequestException($exceptionMsg); } else { $picture = $this->Pictures->save($picture); if ($picture) { $message = 'Picture successfully uploaded'; $this->set(['message' => $message, 'picture' => $picture->filename, 'pictureId' => $picture->id]); } else { $msg = 'There was an error uploading that picture. Please try again.'; throw new InternalErrorException($msg); } } } else { throw new BadRequestException('No picture was uploaded'); } $this->set('_serialize', ['message', 'picture', 'pictureId']); }
/** * agestring smarty modifier * * @param int $age age in seconds * @return string human readable string */ function smarty_modifier_agestring($age) { if ($age > 60 * 60 * 24 * 365 * 2) { $years = (int) ($age / 60 / 60 / 24 / 365); return sprintf(__n('%1$d year ago', '%1$d years ago', $years), $years); } else { if ($age > 60 * 60 * 24 * (365 / 12) * 2) { $months = (int) ($age / 60 / 60 / 24 / (365 / 12)); return sprintf(__n('%1$d month ago', '%1$d months ago', $months), $months); } else { if ($age > 60 * 60 * 24 * 7 * 2) { $weeks = (int) ($age / 60 / 60 / 24 / 7); return sprintf(__n('%1$d week ago', '%1$d weeks ago', $weeks), $weeks); } else { if ($age > 60 * 60 * 24 * 2) { $days = (int) ($age / 60 / 60 / 24); return sprintf(__n('%1$d day ago', '%1$d days ago', $days), $days); } else { if ($age > 60 * 60 * 2) { $hours = (int) ($age / 60 / 60); return sprintf(__n('%1$d hour ago', '%1$d hours ago', $hours), $hours); } else { if ($age > 60 * 2) { $min = (int) ($age / 60); return sprintf(__n('%1$d min ago', '%1$d min ago', $min), $min); } else { if ($age > 2) { $sec = (int) $age; return sprintf(__n('%1$d sec ago', '%1$d sec ago', $sec), $sec); } } } } } } } return __('right now'); }
/** * test __n() * * @return void */ public function testTranslatePlural() { Configure::write('Config.language', 'rule_1_po'); $result = __n('%d = 1', '%d = 0 or > 1', 0); $expected = '%d = 0 or > 1 (translated)'; $this->assertEquals($expected, $result); $result = __n('%d = 1', '%d = 0 or > 1', 1); $expected = '%d = 1 (translated)'; $this->assertEquals($expected, $result); $result = __n('%d = 1 (from core)', '%d = 0 or > 1 (from core)', 2); $expected = '%d = 0 or > 1 (from core translated)'; $this->assertEquals($expected, $result); $result = __n('%d item.', '%d items.', 1, 1); $expected = '1 item.'; $this->assertEquals($expected, $result); $result = __n('%d item for id %s', '%d items for id %s', 2, 2, '1234'); $expected = '2 items for id 1234'; $this->assertEquals($expected, $result); $result = __n('%d item for id %s', '%d items for id %s', 2, array(2, '1234')); $expected = '2 items for id 1234'; $this->assertEquals($expected, $result); }
public function beforeRender() { parent::beforeRender(); $breadcrumbs = array(array('link' => Router::url(array('controller' => 'pages', 'action' => 'index')), 'text' => __('Home'), 'active' => ''), array('link' => Router::url(array('controller' => 'condos', 'action' => 'index')), 'text' => __n('Condo', 'Condos', 2), 'active' => ''), array('link' => Router::url(array('controller' => 'condos', 'action' => 'view', $this->getPhkRequestVar('condo_id'))), 'text' => $this->getPhkRequestVar('condo_text'), 'active' => ''), array('link' => '', 'text' => __n('Support', 'Supports', 2), 'active' => 'active')); switch ($this->action) { case 'view': $breadcrumbs[3] = array('link' => Router::url(array('controller' => 'supports', 'action' => 'index', '?' => $this->request->query)), 'text' => __n('Support', 'Supports', 2), 'active' => ''); $breadcrumbs[4] = array('link' => '', 'text' => $this->getPhkRequestVar('support_text'), 'active' => 'active'); break; case 'edit': $breadcrumbs[3] = array('link' => Router::url(array('controller' => 'supports', 'action' => 'index', '?' => $this->request->query)), 'text' => __n('Support', 'Supports', 2), 'active' => ''); $breadcrumbs[4] = array('link' => '', 'text' => $this->getPhkRequestVar('support_text'), 'active' => 'active'); break; } $headerTitle = __n('Support', 'Supports', 2); $this->set(compact('breadcrumbs', 'headerTitle')); }
/** * Returns either a relative date or a formatted date depending * on the difference between the current time and given datetime. * $datetime should be in a <i>strtotime</i> - parsable format, like MySQL's datetime datatype. * * Options: * * - 'format' => a fall back format if the relative time is longer than the duration specified by end * - 'end' => The end of relative time telling * - 'userOffset' => Users offset from GMT (in hours) * * Relative dates look something like this: * 3 weeks, 4 days ago * 15 seconds ago * * Default date formatting is d/m/yy e.g: on 18/2/09 * * The returned string includes 'ago' or 'on' and assumes you'll properly add a word * like 'Posted ' before the function output. * * @param string $dateString Datetime string or Unix timestamp * @param array $options Default format if timestamp is used in $dateString * @return string Relative time string. */ function timeAgoInWords($dateTime, $options = array()) { $userOffset = null; if (is_array($options) && isset($options['userOffset'])) { $userOffset = $options['userOffset']; } $now = time(); if (!is_null($userOffset)) { $now = $this->convert(time(), $userOffset); } $inSeconds = $this->fromString($dateTime, $userOffset); $backwards = $inSeconds > $now; $format = 'j/n/y'; $end = '+1 month'; if (is_array($options)) { if (isset($options['format'])) { $format = $options['format']; unset($options['format']); } if (isset($options['end'])) { $end = $options['end']; unset($options['end']); } } else { $format = $options; } if ($backwards) { $futureTime = $inSeconds; $pastTime = $now; } else { $futureTime = $now; $pastTime = $inSeconds; } $diff = $futureTime - $pastTime; // If more than a week, then take into account the length of months if ($diff >= 604800) { $current = array(); $date = array(); list($future['H'], $future['i'], $future['s'], $future['d'], $future['m'], $future['Y']) = explode('/', date('H/i/s/d/m/Y', $futureTime)); list($past['H'], $past['i'], $past['s'], $past['d'], $past['m'], $past['Y']) = explode('/', date('H/i/s/d/m/Y', $pastTime)); $years = $months = $weeks = $days = $hours = $minutes = $seconds = 0; if ($future['Y'] == $past['Y'] && $future['m'] == $past['m']) { $months = 0; $years = 0; } else { if ($future['Y'] == $past['Y']) { $months = $future['m'] - $past['m']; } else { $years = $future['Y'] - $past['Y']; $months = $future['m'] + (12 * $years - $past['m']); if ($months >= 12) { $years = floor($months / 12); $months = $months - $years * 12; } if ($future['m'] < $past['m'] && $future['Y'] - $past['Y'] == 1) { $years--; } } } if ($future['d'] >= $past['d']) { $days = $future['d'] - $past['d']; } else { $daysInPastMonth = date('t', $pastTime); $daysInFutureMonth = date('t', mktime(0, 0, 0, $future['m'] - 1, 1, $future['Y'])); if (!$backwards) { $days = $daysInPastMonth - $past['d'] + $future['d']; } else { $days = $daysInFutureMonth - $past['d'] + $future['d']; } if ($future['m'] != $past['m']) { $months--; } } if ($months == 0 && $years >= 1 && $diff < $years * 31536000) { $months = 11; $years--; } if ($months >= 12) { $years = $years + 1; $months = $months - 12; } if ($days >= 7) { $weeks = floor($days / 7); $days = $days - $weeks * 7; } } else { $years = $months = $weeks = 0; $days = floor($diff / 86400); $diff = $diff - $days * 86400; $hours = floor($diff / 3600); $diff = $diff - $hours * 3600; $minutes = floor($diff / 60); $diff = $diff - $minutes * 60; $seconds = $diff; } $relativeDate = ''; $diff = $futureTime - $pastTime; if ($diff > abs($now - $this->fromString($end))) { $relativeDate = sprintf(__('on %s', true), date($format, $inSeconds)); } else { if ($years > 0) { // years and months and days $relativeDate .= ($relativeDate ? ', ' : '') . $years . ' ' . __n('year', 'years', $years, true); $relativeDate .= $months > 0 ? ($relativeDate ? ', ' : '') . $months . ' ' . __n('month', 'months', $months, true) : ''; $relativeDate .= $weeks > 0 ? ($relativeDate ? ', ' : '') . $weeks . ' ' . __n('week', 'weeks', $weeks, true) : ''; $relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . $days . ' ' . __n('day', 'days', $days, true) : ''; } elseif (abs($months) > 0) { // months, weeks and days $relativeDate .= ($relativeDate ? ', ' : '') . $months . ' ' . __n('month', 'months', $months, true); $relativeDate .= $weeks > 0 ? ($relativeDate ? ', ' : '') . $weeks . ' ' . __n('week', 'weeks', $weeks, true) : ''; $relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . $days . ' ' . __n('day', 'days', $days, true) : ''; } elseif (abs($weeks) > 0) { // weeks and days $relativeDate .= ($relativeDate ? ', ' : '') . $weeks . ' ' . __n('week', 'weeks', $weeks, true); $relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . $days . ' ' . __n('day', 'days', $days, true) : ''; } elseif (abs($days) > 0) { // days and hours $relativeDate .= ($relativeDate ? ', ' : '') . $days . ' ' . __n('day', 'days', $days, true); $relativeDate .= $hours > 0 ? ($relativeDate ? ', ' : '') . $hours . ' ' . __n('hour', 'hours', $hours, true) : ''; } elseif (abs($hours) > 0) { // hours and minutes $relativeDate .= ($relativeDate ? ', ' : '') . $hours . ' ' . __n('hour', 'hours', $hours, true); $relativeDate .= $minutes > 0 ? ($relativeDate ? ', ' : '') . $minutes . ' ' . __n('minute', 'minutes', $minutes, true) : ''; } elseif (abs($minutes) > 0) { // minutes only $relativeDate .= ($relativeDate ? ', ' : '') . $minutes . ' ' . __n('minute', 'minutes', $minutes, true); } else { // seconds only $relativeDate .= ($relativeDate ? ', ' : '') . $seconds . ' ' . __n('second', 'seconds', $seconds, true); } if (!$backwards) { $relativeDate = sprintf(__('%s ago', true), $relativeDate); } } return $this->output($relativeDate); }
* @package cake * @subpackage cake.cake.console.libs * @since CakePHP(tm) v 1.2.0.5012 * @version $Revision: 1.1 $ * @modifiedby $LastChangedBy: phpnut $ * @lastmodified $Date: 2007-05-25 05:54:16 $ * @license http://www.opensource.org/licenses/mit-license.php The MIT License */ /** * Only used when -debug option */ return null; $singularReturn = __('Singular string return __()', true); $singularEcho = __('Singular string echo __()'); $pluralReturn = __n('% apple in the bowl (plural string return __n())', '% apples in the blowl (plural string 2 return __n())', 3, true); $pluralEcho = __n('% apple in the bowl (plural string 2 echo __n())', '% apples in the blowl (plural string 2 echo __n()', 3); $singularDomainReturn = __d('controllers', 'Singular string domain lookup return __d()', true); $singularDomainEcho = __d('controllers', 'Singular string domain lookup echo __d()'); $pluralDomainReturn = __dn('controllers', '% pears in the bowl (plural string domain lookup return __dn())', '% pears in the blowl (plural string domain lookup return __dn())', 3, true); $pluralDomainEcho = __dn('controllers', '% pears in the bowl (plural string domain lookup echo __dn())', '% pears in the blowl (plural string domain lookup echo __dn())', 3); $singularDomainCategoryReturn = __dc('controllers', 'Singular string domain and category lookup return __dc()', 5, true); $singularDomainCategoryEcho = __dc('controllers', 'Singular string domain and category lookup echo __dc()', 5); $pluralDomainCategoryReturn = __dcn('controllers', '% apple in the bowl (plural string 1 domain and category lookup return __dcn())', '% apples in the blowl (plural string 2 domain and category lookup return __dcn())', 3, 5, true); $pluralDomainCategoryEcho = __dcn('controllers', '% apple in the bowl (plural string 1 domain and category lookup echo __dcn())', '% apples in the blowl (plural string 2 domain and category lookup echo __dcn())', 3, 5); $categoryReturn = __c('Category string lookup line return __c()', 5, true); $categoryEcho = __c('Category string lookup line echo __c()', 5); /** * Language string extractor * * @package cake * @subpackage cake.cake.console.libs
/** * testFloatValue method * * @return void */ public function testFloatValue() { Configure::write('Config.language', 'rule_9_po'); $result = __n('%d = 1', '%d = 0 or > 1', (double) 1); $expected = '%d is 1 (translated)'; $this->assertEquals($expected, $result); $result = __n('%d = 1', '%d = 0 or > 1', (double) 2); $expected = "%d ends in 2-4, not 12-14 (translated)"; $this->assertEquals($expected, $result); $result = __n('%d = 1', '%d = 0 or > 1', (double) 5); $expected = "%d everything else (translated)"; $this->assertEquals($expected, $result); }
public function beforeRender() { $breadcrumbs = array(array('link' => Router::url(array('controller' => 'pages', 'action' => 'index')), 'text' => __('Home'), 'active' => ''), array('link' => Router::url(array('controller' => 'condos', 'action' => 'index')), 'text' => __n('Condo', 'Condos', 2), 'active' => ''), array('link' => Router::url(array('controller' => 'condos', 'action' => 'view', $this->Session->read('Condo.ViewID'))), 'text' => $this->Session->read('Condo.ViewName'), 'active' => ''), array('link' => Router::url(array('controller' => 'fractions', 'action' => 'view', $this->Session->read('Condo.Fraction.ViewID'))), 'text' => $this->Session->read('Condo.Fraction.ViewName'), 'active' => ''), array('link' => '', 'text' => ___n('Manager', 'Managers', 2), 'active' => 'active')); $this->set(compact('breadcrumbs')); }
public function beforeRender() { if (!$this->Session->check('Condo.ViewID')) { $breadcrumbs = array(array('link' => Router::url(array('controller' => 'pages', 'action' => 'index')), 'text' => __('Home'), 'active' => ''), array('link' => '', 'text' => __n('Condo', 'Condos', 2), 'active' => 'active')); $headerTitle = __('Condos'); } else { $breadcrumbs = array(array('link' => Router::url(array('controller' => 'pages', 'action' => 'index')), 'text' => __('Home'), 'active' => ''), array('link' => Router::url(array('controller' => 'condos', 'action' => 'index')), 'text' => __n('Condo', 'Condos', 2), 'active' => ''), array('link' => '', 'text' => $this->Session->read('Condo.ViewName'), 'active' => 'active')); $headerTitle = $this->Session->read('Condo.ViewName'); } $this->set(compact('breadcrumbs', 'headerTitle')); }
public function beforeRender() { $breadcrumbs = array(array('link' => Router::url(array('controller' => 'pages', 'action' => 'index')), 'text' => __('Home'), 'active' => ''), array('link' => Router::url(array('controller' => 'condos', 'action' => 'index')), 'text' => __n('Condo', 'Condos', 2), 'active' => ''), array('link' => Router::url(array('controller' => 'condos', 'action' => 'view', $this->Session->read('Condo.ViewID'))), 'text' => $this->Session->read('Condo.ViewName'), 'active' => ''), array('link' => Router::url(array('controller' => 'fractions', 'action' => 'index')), 'text' => __n('Fraction', 'Fractions', 2), 'active' => ''), array('link' => Router::url(array('controller' => 'fractions', 'action' => 'view', $this->Session->read('Condo.Fraction.ViewID'))), 'text' => $this->Session->read('Condo.Fraction.ViewName'), 'active' => ''), array('link' => Router::url(array('controller' => 'fraction_owners', 'action' => 'index')), 'text' => __n('Owner', 'Owners', 2), 'active' => ''), array('link' => Router::url(array('controller' => 'fraction_owners', 'action' => 'view', $this->Session->read('Condo.Owner.ViewID'))), 'text' => $this->Session->read('Condo.Owner.ViewName'), 'active' => ''), array('link' => Router::url(array('controller' => 'owner_receipts', 'action' => 'index')), 'text' => __n('Receipt', 'Receipts', 2), 'active' => '')); switch ($this->action) { case 'add_notes': $breadcrumbs[7] = array('link' => Router::url(array('controller' => 'owner_receipts', 'action' => 'index')), 'text' => __n('Receipt', 'Receipts', 2), 'active' => ''); $breadcrumbs[8] = array('link' => Router::url(array('controller' => 'owner_receipts', 'action' => 'view', $this->Session->read('Condo.Receipt.ViewID'))), 'text' => $this->Session->read('Condo.Receipt.ViewName'), 'active' => ''); $breadcrumbs[9] = array('link' => '', 'text' => __('Pick Notes'), 'active' => 'active'); break; case 'view': $breadcrumbs[7] = array('link' => Router::url(array('controller' => 'owner_receipts', 'action' => 'index')), 'text' => __n('Receipt', 'Receipts', 2), 'active' => ''); $breadcrumbs[8] = array('link' => '', 'text' => $this->Session->read('Condo.Receipt.ViewName'), 'active' => 'active'); break; case 'edit': $breadcrumbs[7] = array('link' => Router::url(array('controller' => 'owner_receipts', 'action' => 'index')), 'text' => __n('Receipt', 'Receipts', 2), 'active' => ''); $breadcrumbs[8] = array('link' => '', 'text' => $this->Session->read('Condo.Receipt.ViewName'), 'active' => 'active'); break; case 'cancel': $breadcrumbs[7] = array('link' => Router::url(array('controller' => 'owner_receipts', 'action' => 'index')), 'text' => __n('Receipt', 'Receipts', 2), 'active' => ''); $breadcrumbs[8] = array('link' => '', 'text' => $this->Session->read('Condo.Receipt.ViewName'), 'active' => 'active'); break; case 'pay_receipt': $breadcrumbs[7] = array('link' => Router::url(array('controller' => 'owner_receipts', 'action' => 'index')), 'text' => __n('Receipt', 'Receipts', 2), 'active' => ''); $breadcrumbs[8] = array('link' => '', 'text' => $this->Session->read('Condo.Receipt.ViewName'), 'active' => 'active'); break; } $this->set(compact('breadcrumbs')); }
/** * fraction_attachments method * * @return void */ public function fraction_attachments() { $breadcrumbs = array(array('link' => Router::url(array('controller' => 'pages', 'action' => 'index')), 'text' => __('Home'), 'active' => ''), array('link' => Router::url(array('controller' => 'condos', 'action' => 'index')), 'text' => __n('Condo', 'Condos', 2), 'active' => ''), array('link' => Router::url(array('controller' => 'condos', 'action' => 'view', $this->Session->read('Condo.ViewID'))), 'text' => $this->Session->read('Condo.ViewName'), 'active' => ''), array('link' => Router::url(array('controller' => 'fractions', 'action' => 'index')), 'text' => __n('Fraction', 'Fractions', 2), 'active' => ''), array('link' => Router::url(array('controller' => 'fractions', 'action' => 'view', $this->Session->read('Condo.Fraction.ViewID'))), 'text' => $this->Session->read('Condo.Fraction.ViewName'), 'active' => ''), array('link' => '', 'text' => __n('Attachment', 'Attachments', 2), 'active' => 'active')); $this->set(compact('breadcrumbs')); $this->render('notfound'); }
/** * Sets flash messages based on component properties successEmails, redundantEmails, and errorEmails * * @return void */ public function setInvitationFlashMessages() { $seCount = count($this->successEmails); if ($seCount) { $list = $this->arrayToList($this->successEmails); $msg = 'Questionnaire ' . __n('invitation', 'invitations', $seCount) . ' sent to ' . $list; $this->Flash->success($msg); } $reCount = count($this->redundantEmails); if ($reCount) { $list = $this->arrayToList($this->redundantEmails); $msg = $list . __n(' has', ' have', $reCount) . ' already received a questionnaire invitation'; $this->Flash->set($msg); } $eeCount = count($this->errorEmails); if ($eeCount) { $list = $this->arrayToList($this->errorEmails); $msg = "There was an error inviting {$list}."; $msg .= ' Please try again or contact an administrator if you need assistance.'; $this->Flash->error($msg); } $rieCount = count($this->uninvApprovedEmails); if ($rieCount) { $list = $this->arrayToList($this->uninvApprovedEmails); $msg = 'The uninvited ' . __n('response', 'responses', $rieCount); $msg .= ' received from ' . $list . __n(' has', ' have', $rieCount) . ' been approved'; $this->Flash->success($msg); } }
/** * pluralFromCore method * * @return void */ protected function _pluralFromCore() { $plurals = array(); for ($number = 0; $number <= 25; $number++) { $plurals[] = sprintf(__n('%d = 1 (from core)', '%d = 0 or > 1 (from core)', (double) $number), (double) $number); } return $plurals; }
/** * test __n() * * @access public * @return void */ function test__n() { Configure::write('Config.language', 'rule_1_po'); $result = __n('%d = 1', '%d = 0 or > 1', 0, true); $expected = '%d = 0 or > 1 (translated)'; $this->assertEqual($result, $expected); $result = __n('%d = 1', '%d = 0 or > 1', 1, true); $expected = '%d = 1 (translated)'; $this->assertEqual($result, $expected); $result = __n('%d = 1 (from core)', '%d = 0 or > 1 (from core)', 2, true); $expected = '%d = 0 or > 1 (from core translated)'; $this->assertEqual($result, $expected); ob_start(); __n('%d = 1 (from core)', '%d = 0 or > 1 (from core)', 2); $result = ob_get_clean(); $expected = '%d = 0 or > 1 (from core translated)'; $this->assertEqual($result, $expected); }
public function beforeRender() { $breadcrumbs = array(array('link' => Router::url(array('controller' => 'pages', 'action' => 'index')), 'text' => __('Home'), 'active' => ''), array('link' => Router::url(array('controller' => 'condos', 'action' => 'index')), 'text' => __n('Condo', 'Condos', 2), 'active' => ''), array('link' => Router::url(array('controller' => 'condos', 'action' => 'view', $this->Session->read('Condo.ViewID'))), 'text' => $this->Session->read('Condo.ViewName'), 'active' => ''), array('link' => '', 'text' => __n('Fraction', 'Fractions', 2), 'active' => 'active')); switch ($this->action) { case 'view': $breadcrumbs[3] = array('link' => Router::url(array('controller' => 'fractions', 'action' => 'index')), 'text' => __n('Fraction', 'Fractions', 2), 'active' => ''); $breadcrumbs[4] = array('link' => '', 'text' => $this->Session->read('Condo.Fraction.ViewName'), 'active' => 'active'); break; case 'edit': $breadcrumbs[3] = array('link' => Router::url(array('controller' => 'fractions', 'action' => 'index')), 'text' => __n('Fraction', 'Fractions', 2), 'active' => ''); $breadcrumbs[4] = array('link' => '', 'text' => $this->Session->read('Condo.Fraction.ViewName'), 'active' => 'active'); break; } $this->set(compact('breadcrumbs')); }
/** * ReadQuery * * Read query into parameters * * @access protected */ protected function ReadQuery() { if (!isset($this->params['searchtype'])) { $this->params['searchtype'] = GITPHP_SEARCH_COMMIT; } if ($this->params['searchtype'] == GITPHP_SEARCH_FILE) { if (!GitPHP_Config::GetInstance()->GetValue('filesearch', true)) { throw new GitPHP_MessageException(__('File search has been disabled'), true); } } if (!isset($this->params['search']) || strlen($this->params['search']) < 2) { throw new GitPHP_MessageException(sprintf(__n('You must enter search text of at least %1$d character', 'You must enter search text of at least %1$d characters', 2), 2), true); } if (isset($_GET['h'])) { $this->params['hash'] = $_GET['h']; } else { $this->params['hash'] = 'HEAD'; } if (isset($_GET['pg'])) { $this->params['page'] = $_GET['pg']; } else { $this->params['page'] = 0; } }
/** * addFromMovement method * * @return void */ public function addFromMovement($movementId = null) { $this->Movement = ClassRegistry::init('Movement'); if ($movementId != null && !$this->Movement->exists($movementId)) { $this->Flash->error(__('Invalid movement operation')); $this->redirect(array('controller' => 'movements', 'action' => 'index', '?' => $this->request->query)); } if ($this->request->is('post')) { $this->MovementOperation->create(); if ($this->MovementOperation->save($this->request->data)) { $this->Flash->success(__('The movement operation has been saved')); if ($movementId != null) { $this->redirect(array('controller' => 'movements', 'action' => 'edit', $movementId, '?' => $this->request->query)); } else { $this->redirect(array('controller' => 'movements', 'action' => 'add', '?' => $this->request->query)); } } else { $this->Flash->error(__('The movement operation could not be saved. Please, try again.')); } } if (!$this->getPhkRequestVar('account_id')) { $this->Flash->error(__('Invalid account')); $this->redirect(array('controller' => 'accounts', 'action' => 'index')); } $breadcrumbs = array(array('link' => Router::url(array('controller' => 'pages', 'action' => 'index')), 'text' => __('Home'), 'active' => ''), array('link' => Router::url(array('controller' => 'condos', 'action' => 'index')), 'text' => __n('Condo', 'Condos', 2), 'active' => ''), array('link' => Router::url(array('controller' => 'condos', 'action' => 'view', $this->getPhkRequestVar('condo_id'))), 'text' => $this->getPhkRequestVar('condo_text'), 'active' => ''), array('link' => Router::url(array('controller' => 'accounts', 'action' => 'index', '?' => array('condo_id' => $this->getPhkRequestVar('condo_id')))), 'text' => __n('Account', 'Accounts', 2), 'active' => ''), array('link' => Router::url(array('controller' => 'accounts', 'action' => 'view', $this->getPhkRequestVar('account_id'), '?' => array('condo_id' => $this->getPhkRequestVar('condo_id')))), 'text' => $this->getPhkRequestVar('account_text'), 'active' => ''), array('link' => Router::url(array('controller' => 'movements', 'action' => 'index', '?' => $this->request->query)), 'text' => __n('Movement', 'Movements', 2), 'active' => ''), array('link' => '', 'text' => __('Add Movement Operation'), 'active' => 'active')); $this->set(compact('breadcrumbs', 'movementId')); }