/** * Back end for the smiley picker javascript module. * Renders a list of smileys very similar to the index action but * unfortunately still to different to be combined. * * @param mixed $view Subset to display, defaults to favorites if enabled * @param int $page Section of subset to display */ function picker_action($view = null, $page = 0) { $per_page = self::GRID_WIDTH * self::GRID_HEIGHT; $this->view = $view ?: ($this->default === 'favorites' ? 'favorites' : 'all'); $smileys = $this->view == 'favorites' ? Smiley::getByIds($this->favorites->get()) : Smiley::getGrouped($this->view); $this->page = $page; $this->pages = floor(count($smileys) / $per_page); array_walk($smileys, function ($smiley) { $smiley->link = Smiley::getURL($smiley->name); $smiley->html = Smiley::img($smiley->name); }); $this->smileys = array_slice($smileys, $page * $per_page, $per_page); $this->characters = Smiley::getUsedCharacters(); }