Example #1
0
 public function add($desc, $lang, $book, $remedium)
 {
     $model = new descModel();
     $model->remedium_id = $remedium;
     $model->book_id = $book;
     $model->save();
     $dict = new dictModel();
     $dict->table_name = $this->_table;
     $dict->table_id = $model->id;
     $dict->lang = $lang;
     $dict->body = $desc;
     return $dict->save();
 }
 $remedium = new remediumModel();
 if (!$remedium->find_one_by_name($remedium_name)) {
     $remedium->name = $remedium_name;
     $remedium->abbreviation = $remedium_abbr;
     $remedium->save();
 }
 $html = url_get($url2);
 $html = iconv('iso8859-2', 'utf-8', $html);
 $html = str_replace(['ć', 'Ć', 'œ'], ['e', 'AE', 'e'], $html);
 $b = [];
 if (preg_match_all('~<p align="justify">(.+?)</p>~si', $html, $b)) {
     foreach ($b[1] as $h) {
         $h = unhtml($h);
         $h = explode('.--', $h);
         if (count($h) == 1) {
             $desc = new descModel();
             $d = $desc->find('en', $book->id, $remedium->id);
             if (!$d) {
                 $desc->add($h[0], 'en', $book->id, $remedium->id);
             } else {
                 $dict = new dictModel($d);
                 $dict->body = $h[0];
                 $dict->save();
             }
         }
         if (count($h) == 2) {
             $complaint = new complaintModel();
             $complaint_name = strtolower($h[0]);
             if (strlen($complaint_name) > 25) {
                 mydie($complaint_name);
             }