Exemple #1
0
 private static function getGenericView(SR_Player $player, array $items, array $args, $is_store, $text, $raw = true)
 {
     $bot = Shadowrap::instance($player);
     if (count($args) > 2) {
         return self::arrayGet($text, 'usage', Shadowhelp::getHelp($player, 'view'));
         // 			$bot->reply(self::arrayGet($text, 'usage', Shadowhelp::getHelp($player, 'viewi')));
         // 			return false;
     }
     $items = Shadowfunc::getItemsIndexed($items, $is_store, $raw);
     # Setup pattern and args
     if (count($args) === 2) {
         $pattern = $args[0];
         $page = (int) $args[1];
     } elseif (count($args) === 1) {
         if (Common::isNumeric($args[0])) {
             $pattern = NULL;
             $page = (int) $args[0];
         } else {
             $pattern = $args[0];
             $page = 1;
         }
     } else {
         $pattern = NULL;
         $page = 1;
     }
     # Filter on pattern
     if ($pattern !== NULL) {
         $items = Shadowfunc::filterIndexedBySubstring($args[0], $items);
     }
     # Display page
     if (count($items) === 0) {
         if ($pattern !== NULL) {
             return self::arrayGet($text, 'empty_search', Shadowrun4::lang('1007'));
             // 				$bot->reply(self::arrayGet($text, 'empty_search', Shadowrun4::lang('1007')));
         } else {
             return self::arrayGet($text, 'empty', Shadowrun4::lang('1008'));
             // 				$bot->reply(self::arrayGet($text, 'empty', Shadowrun4::lang('1008')));
         }
         // 			return true;
     }
     if (false === ($pageStr = Shadowfunc::getItemPage($page, $items, $is_store))) {
         return self::arrayGet($text, 'no_page', Shadowrun4::lang('1009'));
         // 			$bot->reply(self::arrayGet($text, 'no_page', Shadowrun4::lang('1009')));
         // 			return false;
     }
     $code = self::arrayGet($text, 'code', '5276');
     return $player->lang($code, array(sprintf('%s%s', self::arrayGet($text, 'prefix', Shadowrun4::lang('items')), $pageStr)));
     // 		return sprintf('%s, %s', self::arrayGet($text, 'prefix', Shadowrun4::lang('items')), $pageStr);
 }