Пример #1
0
 static function menu_cart(MenuItem $item)
 {
     $item->url = route('vanemart::cart');
     $item->classes[] = 'cart';
     $key = Cart::has() ? 'cart_filled' : 'cart';
     $item->caption = \Vane\Menu::caption($key);
     if (Cart::has()) {
         $sum = Cart::subtotal();
         $replaces = array('sumn' => Str::number($sum), 'summ' => Str::langNum('general.price', $sum), 'sumf' => Str::langNum('general.currency_full', $sum), 'sums' => Str::langNum('general.currency_short', $sum), 'count' => Str::langNum('general.goods', Cart::count()));
         $item->caption = Str::format($item->caption, $replaces);
         $item->hint = Str::format(\Vane\Menu::caption('cart_hint'), $replaces);
     }
 }
Пример #2
0
 static function summary($html = false)
 {
     $items = Str::langNum('general.goods', static::count(), $html);
     $sum = Str::langNum('general.price', static::subtotal(), $html);
     if ($html) {
         return HLEx::lang('cart.summary', compact('items', 'sum'), false);
     } else {
         return __('vanemart::cart.summary', compact('items', 'sum'))->get();
     }
 }
Пример #3
0
        }
    }
});
/*-----------------------------------------------------------------------
| POST BLOCK
|----------------------------------------------------------------------*/
// Fired to return a default (automatic) post text when submitting a form without one.
// If doesn't return a non-empty string post form is returned with "Empty body" error.
//
//* $options hash - 'block' Block_Post, 'type' str, 'object' int/mixed.
//
//= str body message to post
Event::listen(VANE_NS . 'post.bodyless', function (array $options) {
    $block = $options['block'];
    if ($block->userCanAttach() and $names = $block->uploadedFileNames()) {
        return __(Current::expand('post.add.bodyless_fmsg'), array('text' => Str::langNum('post.add.bodyless_ftext', count($names)), 'files' => join(', ', $names)))->get();
    }
});
// Fired when a new (prepared) Post model needs to be inserted into the database.
//
//= bool
Event::listen(VANE_NS . 'post.insert', function (Post &$post) {
    return $post->save();
});
// Fired once a new Post has been successfully placed.
Event::listen(VANE_NS . 'post.inserted', function (Post $post) {
});
// Fired at the point when attachments, if any, should be added to the created Post.
// Any produced exception will cause the Post to be deleted to maintain integrity.
//
//* $options hash - the same as in post.bodyless plus 'post' Post.
Пример #4
0
 static function langNum($strings, $number)
 {
     return Str::langNum($strings, $number, true);
 }