Exemplo n.º 1
0
 public function indexAction()
 {
     if ($this->session->get('successfu_edite')) {
         $this->view->successfu_edite = true;
         $this->session->clear('successfu_edite');
     }
     Model_Smiles::initDbInstall();
     $this->view->page_num = $page = $this->getRequest()->getRequest('page', 1);
     $data = array('start' => $page * JO_Registry::get('admin_limit') - JO_Registry::get('admin_limit'), 'limit' => JO_Registry::get('admin_limit'));
     $this->view->smiles = array();
     $smiles = Model_Smiles::getSmiles($data);
     if ($smiles) {
         foreach ($smiles as $country) {
             $this->view->smiles[] = $country;
         }
     }
     $total_records = Model_Smiles::getTotalSmiles();
     $this->view->total_pages = ceil($total_records / JO_Registry::get('admin_limit'));
     $this->view->total_rows = $total_records;
     $pagination = new Model_Pagination();
     $pagination->setLimit(JO_Registry::get('admin_limit'));
     $pagination->setPage($page);
     $pagination->setTotal($total_records);
     $pagination->setUrl($this->getRequest()->getModule() . '/smiles/?page={page}');
     $this->view->pagination = $pagination->render();
 }
Exemplo n.º 2
0
 public static function replaceEmoticons($comment)
 {
     static $orig, $repl;
     if (!isset($orig)) {
         $orig = $repl = array();
         $db = JO_Db::getDefaultAdapter();
         $tables = $db->listTables();
         if (!in_array('smiles', $tables)) {
             return $comment;
         }
         $all_list = Model_Smiles::getSmiles();
         $smilies = array();
         if ($all_list) {
             $smilies = $all_list;
         }
         if (count($smilies)) {
             usort($smilies, array('Model_Comments', '_smiley_sort'));
         }
         for ($i = 0; $i < count($smilies); $i++) {
             if (trim($smilies[$i]['code']) && file_exists(BASE_PATH . '/uploads/' . $smilies[$i]['photo']) && is_file(BASE_PATH . '/uploads/' . $smilies[$i]['photo'])) {
                 $codes = explode(',', $smilies[$i]['code']);
                 foreach ($codes as $code) {
                     $code = trim($code);
                     if ($code) {
                         $orig[] = "/(?<=.\\W|\\W.|^\\W)" . self::_preg_quote($code, "/") . "(?=.\\W|\\W.|\\W\$)/";
                         $repl[] = '<img src="uploads/' . $smilies[$i]['photo'] . '" alt="' . $smilies[$i]['name'] . '" border="0" />';
                     }
                 }
             }
         }
     }
     if (count($orig)) {
         $comment = preg_replace($orig, $repl, ' ' . $comment . ' ');
         $comment = substr($comment, 1, -1);
     }
     return $comment;
 }