function getPendingHampers($full = false) { $pendingProducts = $this->getPending(); $pendingHampersIds = array_unique(Set::extract('/OrderedProduct/hamper_id', $pendingProducts)); $_pendingHampers = $this->Hamper->find('all', array('conditions' => array('Hamper.id' => $pendingHampersIds), 'contain' => array('Seller.name'))); if ($full) { return $_pendingHampers; } $pendingHampers = array(); foreach ($_pendingHampers as $hamper) { $pendingHampers[$hamper['Hamper']['id']] = $hamper['Hamper']['name'] . ' ' . __('di', true) . ' ' . $hamper['Seller']['name'] . ' ' . __('di', true) . ' ' . digi_date($hamper['Hamper']['delivery_date_on']); } return $pendingHampers; }
function getRelativeTime($date) { $diff = time() - strtotime($date); if ($diff < 60) { return $diff . plural("secondi", $diff) . " fa"; } $diff = round($diff / 60); if ($diff < 60) { return $diff . plural("minuti", $diff) . " fa"; } $diff = round($diff / 60); if ($diff < 24) { return $diff . plural("ore", $diff) . " fa"; } $diff = round($diff / 24); if ($diff < 7) { return $diff . plural("giorni", $diff) . " fa"; } $diff = round($diff / 7); if ($diff < 4) { return $diff . plural("settimane", $diff) . " fa"; } return "il " . digi_date($date); }
function view($data, $element = false, $paginate = false) { $this->View = ClassRegistry::getObject('view'); $return = ''; if (!empty($data)) { if ($paginate) { //paginator $return .= $this->Html->div('paging', $this->Html->tag('p', $this->Paginator->counter(array('format' => __('Pagina %page% di %pages%, %count% commenti inseriti', true))))); } $i = $this->params['paging']['Comment']['options']['limit'] * ($this->params['paging']['Comment']['options']['page'] - 1); $colorIndex = 0; $userColors = array(); foreach ($data as $comment) { $class = null; if ($i++ % 2 == 1) { $class = ' alt'; } $editComment = false; if (isset($comment['User'])) { $author = $this->Html->div('comment-author', $comment['User']['fullname']); if ($this->user_can_edit($comment['Comment']['user_id'])) { $editComment = true; } } else { $author = ''; } if ($editComment) { $editComment = $this->Html->tag('div', $this->Html->link(__('modifica', true), array('controller' => 'comments', 'action' => 'edit', $comment['Comment']['id'])), array('class' => 'edit')); } else { $editComment = ''; } // // if(isset($userColors[$comment['Comment']['user_id']])) { // $color = $userColors[$comment['Comment']['user_id']]; // } // else { // $color = "user_".++$colorIndex; // $userColors[$comment['Comment']['user_id']] = $color; // } $color = ''; $date = $this->Html->div('comment-date', digi_date($comment['Comment']['created'])); $text = $this->Html->div('comment-body', $comment['Comment']['text']); $number = $this->Paginator->link('# ' . $i, array('#' => $comment['Comment']['id'])); $number = $this->Html->div('comment-number', $number); $meta = $this->Html->tag('span', $number . $author . $date, array('class' => 'comment-metadata')); $avatar = $this->Html->image('avatars/empty.png', array('class' => "avatar {$color}")); $comment_topic = $this->Html->div('comment-topic' . $class, $meta . $text . $editComment); $return .= $this->Paginator->link('', '', array('name' => $comment['Comment']['id'])); $return .= $this->Html->div('comment', $avatar . $comment_topic); } if ($paginate) { //paginator $pages = $this->Paginator->prev('<< ' . __('precedente', true), array(), null, array('class' => 'disabled')); $pages .= ' | '; $pages .= $this->Paginator->numbers(); $pages .= ' | '; $pages .= $this->Paginator->next(__('successiva', true) . ' >>', array(), null, array('class' => 'disabled')); $return .= $this->Html->div('paging', $pages); } } else { $return = __('Per ora non ci sono commenti', true); } $return = $this->Html->div('comments', $return); return $return; }