function save_news($newsDt, $cat, $insert = false) { if ($insert == false) { //echoPre($newsDt); $tmp = $this->gen_full_image($newsDt); $news_id = $newsDt['news_id']; if ($cat['cat_id'] == '') { $cat['cat_id'] = $cat['cat_name']; } $newsDt['news_category'] = json_encode(array($cat['cat_id'])); echoPre($news_id); $newsDt['news_image_thumbnail'] = $newsDt['news_image_thumbnail'] != '' ? 'square-' . $newsDt['news_image'] : $newsDt['news_image_thumbnail']; $newsDt['news_image_potrait'] = $newsDt['news_image_potrait'] != '' ? 'poster-' . $newsDt['news_image'] : $newsDt['news_image_potrait']; $this->news_model->updateNews($newsDt, array('news_id' => $news_id)); if ($newsDt['news_type'] == "1") { $photo = $this->photonews_model->get_data_record("photonews_newsid='{$news_id}'"); $this->proses_detail_photonews($photo); } ////deleting news keyword data //$this->news_keywords_model->delete_records(array('nk_news_id' => $news_id)); ////delete news tag data //$this->tag_news_model->delete_records(array('tag_news_news_id' => $news_id)); $this->save_temp_img($tmp, $newsDt); } else { $newsDt['news_url'] = $newsDt['news_url'] . '-' . date("ymd") . get_random_alpanumeric(1); $news_id = $this->news_model->saveNewRecord($newsDt); // for insert jsview //$this->insert_jsview($news_id, $newsDt); } //echoPre($newsDt); //$this->update_jsview($news_id, $cat, $newsDt); //$this->update_rubric($news_id, $cat, $newsDt); }
function index() { if (file_exists($this->file_log_migrasi)) { $this->page = file_get_contents($this->file_log_migrasi); } else { $this->page = 1; } $offset = ($this->page - 1) * $this->limit; $where = ""; //" WHERE news_id = '1723'"; $sql = "SELECT * FROM " . $this->table_migrasi . " {$where} order by news_id DESC LIMIT {$offset},{$this->limit}"; echo $sql . '<br>'; $rows = $this->migrasi_model->query($sql)->fetchrow(); //echoPre($rows);die; $log_id = ""; if (isset($rows[0])) { foreach ($rows as $row) { //$type = "0"; //if($row['type'] == "Image") $type = "1"; //if($row['type'] == "Video") $type = "2"; $log_id .= $row['news_id'] . "\t"; $cat_old = json_decode($row["news_category"]); $cat = $this->conversi_cat($cat_old[0]); //echoPre($cat); $data = $row; $data['external_url'] = $row["news_url"]; $data['news_category'] = json_encode(array($cat['id_cat'])); $data['news_url'] = url_title($row["news_title"]) . '-' . date("ymd", strtotime($row['news_entry'])) . get_random_alpanumeric(1); unset($data['news_id']); unset($data['news_url_kplg']); unset($data['news_tag_activated']); unset($data['info_grafis']); unset($data['news_url_client']); unset($data['news_figure']); unset($data['photo_slideshow']); unset($data['news_conclusion']); unset($data['news_image']); unset($data['news_image_thumbnail']); unset($data['news_image_potrait']); unset($data['news_image_headline']); unset($data['popular_keyword']); $this->save_data($data, $row); } } file_put_contents($this->file_log_migrasi, $this->page + 1); file_put_contents($this->file_log_id, $log_id . "\t\n", FILE_APPEND); }
function savenews() { // echoPre ($_POST); die; if (isPost() && post('news_title') && post('news_title') != '' && post('news_lead') != '' && post('news_content') != '') { $newsDt = array('news_id' => post('news_id'), 'news_entry' => date('Y-m-d H:i:s'), 'news_level' => post('news_level'), 'news_top_headline' => '0', 'news_editor_pick' => post('news_editor_pick') ? '1' : '0', 'news_category' => json_encode(array(post('news_category'))), 'news_title' => post('news_title'), 'news_subtitle' => post('news_subtitle'), 'news_synopsis' => post('news_lead'), 'news_content' => post('news_content'), 'news_image_headline' => '0', 'news_imageinfo' => post('news_imageinfo'), 'news_url' => post('news_subtitle') ? url_title(post('news_title') . '-' . post('news_subtitle')) : url_title(post('news_title')), 'news_date_publish' => post('news_date_publish') ? post('news_date_publish') : date('Y-m-d H:i:s'), 'news_invalid' => '0', 'news_user_id' => sess('usr_id'), 'news_type' => '0', 'news_reporter' => $this->processReporter(post('news_contributor')), 'news_editor' => json_encode(array(array('id' => $_SESSION['usr_id'], 'user_fullname' => $_SESSION['usr_fullname']))), 'news_initial' => '', 'news_photographer' => $this->processReporter(post('news_photographer')), 'news_hastag' => post('news_hastag'), 'news_city' => post('news_city') ? post('news_city') : 'Jakarta', 'news_source' => '', 'external_url' => '', 'has_paging' => '0', 'news_top_headline' => post('news_top_headline') ? '1' : '0', 'news_hot' => post('news_hot') ? '1' : '0', 'news_image' => post('news_image'), 'news_top_headtorial' => post('news_top_headtorial') ? '1' : '0', 'news_date_headtorial' => post('news_date_headtorial') ? post('news_date_headtorial') : ""); $newsDt['news_url'] = post('news_url') ? post('news_url') : $newsDt['news_url']; if (post('news_id')) { // update json detail to server cluster $server_cluster = $this->config['server_cluster']; foreach ($server_cluster as $serv) { $cat = $this->get_cat_parent_jsview(post('news_id'), $newsDt['news_category']); $json = @file_get_contents($serv . 'update-json/' . $cat['url'] . '/' . $newsDt['news_url'] . '.html'); //echo $json; } unset($newsDt['news_id']); unset($newsDt['news_entry']); unset($newsDt['news_editor']); unset($newsDt['news_url']); //$newsDt['news_url'] = $newsDt['news_url'] . '-' . date("ymd") . get_random_alpanumeric(1); $news_id = post('news_id'); $this->news_model->updateNews($newsDt, array('news_id' => $news_id)); //deleting news keyword data $this->news_keywords_model->delete_records(array('nk_news_id' => $news_id)); //delete news tag data $this->tag_news_model->delete_records(array('tag_news_news_id' => $news_id)); //$this->_create_url_client($news_id,$newsDt); } else { $news_content = html_entity_decode($newsDt['news_content']); // $newsDt['news_content'] = '<p><b>MONEY.id - </b>' . ltrim($news_content, '<p>'); $newsDt['news_content'] = preg_replace('/^<p>/', '<p><b>MONEY.id - </b>', $news_content); $newsDt['news_url'] = htmlentities($newsDt['news_url'] . '-' . date("ymd") . get_random_alpanumeric(1)); $news_id = $this->news_model->saveNewRecord($newsDt); // for insert jsview $this->insert_jsview($news_id, $newsDt); // for get sort url $this->_create_url_client($news_id, $newsDt); } $this->processNewsTags($news_id, post('news_tags')); $this->processNewsKeywords($news_id, post('news_keywords')); $this->_prosesQuote($news_id, $_POST); //save to mdk_news_rubric $this->saveMdkNewsRubric($newsDt, $news_id); // proses news related content $this->_news_relate_content($news_id); //dfp / dsp interest $this->save_dfp_interest(post('category_interest'), $news_id, "news"); //echo "end interest"; //news paging //$this->news_paging_model->delete_data($news_id); if (post("news_paging_title") && post("news_paging_title") != '') { //$newsDt['has_paging'] = '1'; $this->prosesNewsPaging($news_id, $newsDt); $dt_news_update = array('has_paging' => '1'); $upd = $this->news_model->updateRecord($dt_news_update, array('news_id' => $news_id)); } # processing news ilustration upload # main image if ($this->processNewsIlustration($newsDt, $news_id) == false) { @header('Location: ' . $this->config['base_url'] . $this->ctrler . '/edit/&id=' . $news_id . "&t=" . date("s") . '&s=image_error'); exit; } # processing news ilustration upload for thumbnail # thumbnail image if ($this->processNewsIlustration_thumb($newsDt, $news_id) == false) { @header('Location: ' . $this->config['base_url'] . $this->ctrler . '/edit/&id=' . $news_id . "&t=" . date("s") . '&s=image_error'); exit; } //processing news ilustration upload for potrait # potrait image if ($this->processNewsIlustration_potrait($newsDt, $news_id) == false) { @header('Location: ' . $this->config['base_url'] . $this->ctrler . '/edit/&id=' . $news_id . "&t=" . date("s") . '&s=image_error'); exit; } //$this->_create_json_news($news_id); @header('Location: ' . $this->config['base_url'] . $this->ctrler . '/preview/&id=' . $news_id); //$this->redirect('/'.$this->ctrler.'/edit/&id='.$news_id."&t=".date("s")).'&s=success'; //$url = $this->config['base_url') . $this->ctrler . '/edit/&id=' . $news_id . "&t=" . date("s") . '&s=success'; //@header('Location: ' . $url); exit; } else { //$this->redirect('/'.$this->ctrler.'/addnews/'); Output::App()->redirect($this->config['base_url'] . $this->ctrler . '/addnews/'); } }
/** * function save new record or update existing one */ function saveRecord() { //echoPre ($_POST);die; if (isPost() && post('news_title') && post('news_title') != '' & post('news_synopsis') != '') { //$news_id = $this->photonews_model->addUpdate_photonews($_POST); //select previous photonews data if exist $tahun = date('Y'); $prev_row = post('news_id') ? $this->photonews_model->selRow($this->table_prefix . "news_" . $tahun, "news_id=" . post('news_id')) : array(); $prev_row = count($prev_row) > 0 ? $prev_row[0] : array(); //get mdk_user in indexed row for field news_contributor and news_editor value $mdk_user = $this->photonews_model->get_comboRow($this->table_prefix . "users", "user_id", "user_realname", "", "", "", true); #if($post['news_photographer'] && array_key_exists($post['news_photographer'], $mdk_user)){ if (post('news_photographer') && array_key_exists(post('news_photographer'), $mdk_user)) { $news_photographer = array(array('id' => post('news_photographer'), 'name' => $mdk_user[post('news_photographer')])); } else { $news_photographer = array(); } if (post('news_reporter') && array_key_exists(post('news_reporter'), $mdk_user)) { $news_reporter = array(array('id' => post('news_reporter'), 'name' => $mdk_user[post('news_reporter')])); } else { $news_reporter = array(); } //reCreate rowset for mdk_news $mdk_news = array('news_id' => post('news_id'), 'news_entry' => post('news_id') ? $prev_row['news_entry'] : date('Y-m-d H:i:s'), 'news_level' => post('news_level'), 'news_top_headline' => post('news_top_headline') ? post('news_top_headline') ? '1' : '0' : '0', 'news_editor_pick' => post('news_editor_pick') ? post('news_editor_pick') ? '1' : '0' : '0', 'news_mature' => post('news_mature') ? post('news_mature') ? '1' : '0' : '0', 'news_category' => json_encode(array(post('news_category'))), 'news_title' => post('news_title'), 'news_subtitle' => post('news_subtitle') ? post('news_subtitle') : '', 'news_synopsis' => post('news_synopsis'), 'news_content' => post('news_content'), 'news_image_headline' => post('news_image_headline') ? post('news_image_headline') ? '1' : '0' : '0', 'news_imageinfo' => post('news_imageinfo'), 'news_url' => post('news_id') ? $prev_row['news_url'] : url_title(post('news_title')), 'news_date_publish' => post('news_date_publish') ? post('news_date_publish') : date('Y-m-d H:i:s'), 'news_user_id' => $_SESSION['usr_id'], 'news_type' => '1', 'news_reporter' => json_encode($news_reporter), 'news_photographer' => json_encode($news_photographer), 'news_editor' => json_encode(array(array('id' => $_SESSION['usr_id'], 'name' => $_SESSION['usr_fullname']))), 'news_city' => post('news_city'), 'popular_keyword' => post('popular_keyword') ? post('popular_keyword') : 0, 'news_figure' => post('news_figure') ? post('news_figure') : ''); //echoPre($_POST);die; //ADD or UPDATE mdk_news record if ($mdk_news['news_id']) { // update json detail to server cluster $server_cluster = $this->config['server_cluster']; foreach ($server_cluster as $serv) { $cat = $this->get_cat_parent_jsview(post('news_id'), $mdk_news['news_category']); $json = @file_get_contents($serv . 'update-json/photo/' . $cat['url'] . '/' . $mdk_news['news_url'] . '.html'); //echo $serv . 'update-json/photo/' . $cat['url'] .'/'. $mdk_news['news_url'] . '.html'; } unset($newsDt['news_url']); $this->news_model->updateRecord($mdk_news, "news_id=" . $mdk_news['news_id']); $news_id = $mdk_news['news_id']; } else { $mdk_news['news_url'] = $mdk_news['news_url'] . '-' . date("ymd") . get_random_alpanumeric(1); $news_id = $this->news_model->saveNewRecord($mdk_news); $this->insert_jsview($news_id, $mdk_news); } $ret = $news_id; #$this->echoPre($mdk_news); //ADD or UPDATE mdk_news_rubrics $rubrics_column = $this->photonews_model->get_rowset_idsorted($this->table_prefix . "rubrics", "rubrics_id", "rubrics_invalid='0'"); $mdk_news_rubrics = array('news_rubrics_news_id' => $news_id, 'news_rubrics_rubrics_id' => post('news_category'), 'news_rubrics_news_title' => $mdk_news['news_title'], 'news_rubrics_rubrics_name' => isset($rubrics_column[post('news_category')]['rubrics_name']) ? $rubrics_column[post('news_category')]['rubrics_name'] : '', 'news_rubrics_news_editor_pick' => $mdk_news['news_editor_pick'], 'news_rubrics_news_url' => $mdk_news['news_url'], 'news_rubrics_news_type' => '1', 'news_rubrics_news_date_publish' => $mdk_news['news_date_publish'], 'news_rubrics_rubrics_common' => isset($rubrics_column[post('news_category')]['rubrics_common']) ? $rubrics_column[post('news_category')]['rubrics_common'] : '', 'news_rubrics_rubrics_common_id' => isset($rubrics_column[post('news_category')]['rubrics_parent']) ? $rubrics_column[post('news_category')]['rubrics_parent'] : ''); $this->photonews_model->delRow($this->table_prefix . "news_rubrics", "news_rubrics_news_id=" . $news_id); $news_rubrics_id = $this->photonews_model->insert($this->table_prefix . "news_rubrics", $mdk_news_rubrics); //ADD or UPDATE mdk_tags_news if (post('news_tags')) { $mdk_tags = $this->photonews_model->get_rowset_idsorted($this->table_prefix . "tags", "id"); $this->photonews_model->delRow($this->table_prefix . "tag_news", "tag_news_news_id=" . $news_id); $ids = explode(",", post('news_tags')); foreach ($ids as $id) { if (isset($mdk_tags[$id])) { $tag = array('tag_news_tag_id' => $id, 'tag_news_news_id' => $news_id, 'tag_news_tags' => $mdk_tags[$id]['tag']); $this->photonews_model->insert($this->table_prefix . "tag_news", $tag); } } } //ADD or UPDATE mdk_news_keywords if (post('news_keywords')) { $mdk_keywords = $this->photonews_model->get_rowset_idsorted($this->table_prefix . "keywords", "keyword_name"); $this->photonews_model->delRow($this->table_prefix . "news_keywords", "nk_news_id=" . $news_id); $names = explode(",", post('news_keywords')); foreach ($names as $name) { if (!isset($mdk_keywords[trim($name)])) { //insert new keyword and get keyword_id $keywords = array('nk_keyword_name' => strtolower(trim($name)), 'nk_keyword_entry' => date('Y-m-d H:i:s')); //print_r($keywords); //exit(); $keyword_id = $this->photonews_model->insert($this->table_prefix . "news_keywords", $keywords); } else { //get keyword_id from selected record in the table $keyword_id = $mdk_keywords[$name]['keyword_id']; } $keywords = array('nk_keyword_id' => $keyword_id, 'nk_news_id' => $news_id, 'nk_keyword_name' => $name); $this->photonews_model->insert($this->table_prefix . "news_keywords", $keywords); } } //delete previous photonews_detail record //$this->photonews_model->delRow($this->table_prefix . "photonews_detail", "photonews_newsid=" . $news_id); if ($mdk_news['news_id']) { //Delete directory $dirPath = $this->config['klimg_dir'] . 'photonews/' . date('Y/m/d', strtotime($mdk_news['news_entry'])) . '/' . $mdk_news['news_id'] . '/'; $this->upload->deleteDir($dirPath); } //upload main photonews image from local to image bank if (post('tPhoto_id')) { $photo_id = post('tPhoto_id'); } else { if ($_FILES['news_img_uploader_thumb']['name']) { $photo_id = $this->_upload_local_image($mdk_news, $_FILES['news_img_uploader_thumb']); } } //processing news ilustration upload for thumbnail if ($this->processNewsIlustration_thumb($mdk_news, $news_id) == false) { @header('Location: ' . $this->config['base_url'] . $this->ctrler . '/edit/&id=' . $news_id . "&t=" . date("s") . '&s=image_error'); exit; } //processing news ilustration upload for potrait if ($this->processNewsIlustration_potrait($mdk_news, $news_id) == false) { @header('Location: ' . $this->config['base_url'] . $this->ctrler . '/edit/&id=' . $news_id . "&t=" . date("s") . '&s=image_error'); exit; } //upload main photonews image from image bank to photonews image dir $update_mainPhoto = false; if (isset($photo_id)) { #$news_img = $this->upload_photonewsImg($photo_id, $news_id); $news_img = $this->_upload_photonewsImg($photo_id, $news_id); //print_r($news_img);die; //Update image path on table mdk_news of the last inserted record $dt_mdk_news = array('news_image' => $news_img['nama']); $update_mainPhoto = $this->news_model->update($this->table_prefix . "news_" . date('Y'), $dt_mdk_news, "news_id=" . $news_id); //$update_mainPhoto = true; #die(); } if (post('tPhoto_hidden') != '') { $update_mainPhoto = true; } //reCreate mdk_photonews_detail $mdk_photonews_detail = array(); $main_Photo = false; $photonews_description = post('photonews_description'); $photonews_keyword = post('photonews_keyword'); $photonews_copyright = post('photonews_copyright', false); $photonews_realpath = post('photonews_realpath'); $photonews_id = post('photonews_id'); // $arrSize = $this->img_conf_model->get_data(); // $arrSize = $arrSize['realimage']['name_size']['tumb']; foreach (post('photonews_photo_id') as $no => $photo_id) { //upload photonews_detail image $img = $this->_upload_photonewsImg($photo_id, $news_id, $no + 1, 'photonews'); #$return = $this->upload->copyAndResize($source_img, $target_imgName, $target_dir, $arrSize); //insert into photonews_detail $mdk_photonews_detail = array('photonews_newsid' => $news_id, 'photonews_title' => post('news_title'), 'photonews_url' => str_replace(array('.jpg', '.png', '.jpeg', '.gif'), '', $img['nama']), 'photonews_src' => str_replace($this->config['klimg_dir'], '', $img['target_img']), 'photonews_description' => $photonews_description[$no], 'photonews_keyword' => $photonews_keyword[$no], 'photonews_copyright' => $photonews_copyright[$no], 'photonews_realpath' => $photonews_realpath[$no], 'photonews_photo_id' => $photo_id); $id_photonews = isset($photonews_id[$no]) ? $photonews_id[$no] : ''; //$cek_detail_photo = $this->photonews_model->get_data_record("photonews_id='".$id_photonews."'"); //if(is_array($cek_detail_photo) && count($cek_detail_photo)>0){ if ($id_photonews != '') { unset($mdk_photonews_detail['photonews_url']); $this->photonews_model->update_data($mdk_photonews_detail, $id_photonews); } else { $this->photonews_model->insert_data($mdk_photonews_detail); } //cek if main photo is not set, then take from the first detail photo as the main photo if (!$update_mainPhoto && !$main_Photo) { $main_Photo = explode("/", $mdk_photonews_detail['photonews_src']); $main_Photo = end($main_Photo); } } //re Update image path on table mdk_news if its not has ben set yet if (!$update_mainPhoto && $main_Photo) { $dt_mdk_news = array('news_image' => $main_Photo); $update_mainPhoto = $this->photonews_model->update($this->table_prefix . "news_" . date('Y'), $dt_mdk_news, "news_id=" . $news_id); } $this->_news_relate_content($news_id); } //$this->_create_json_photonews($news_id); //$this->redirect((($news_id) ? '/'.$this->ctrler.'/edit/id='.$news_id.'&t='.date('s') : '/'.$this->ctrler.'/addphotonews/')); //$url = ($news_id) ? $this->config['base_url') . $this->ctrler . '/edit/&id=' . $news_id . '&t=' . date('s') : $this->config['base_url') . $this->ctrler . '/addphotonews/'; $url = $this->config['base_url'] . $this->ctrler . '/preview/&id=' . $news_id; //$url = $this->config['base_url') . $this->ctrler . '/edit/&id=' . $news_id . '&t=' . date('s') . '&s=success?' . time(); @header('Location: ' . $url); exit; }
/** * function save new record or update existing one */ function saveRecord() { // echoPre ($_POST);die; if (isPost() && post('news_title') && post('news_title') != '' & post('news_synopsis') != '') { //select previous photonews data if exist $tahun = "2013"; //date('Y'); $prev_row = post('news_id') ? $this->news_model->dt_listData("news_id=" . post('news_id')) : array(); $prev_row = count($prev_row) > 0 ? $prev_row[0] : array(); //get mdk_user in indexed row for field news_contributor and news_editor value //$mdk_user = $this->photonews_model->get_comboRow($this->table_prefix . "users", "user_id", "user_realname", "", "", "", true); $mdk_user = $this->user_model->getUser_combo("user_id", "user_realname", "", "", "", true); #if($post['news_photographer'] && array_key_exists($post['news_photographer'], $mdk_user)){ if (post('news_photographer') && array_key_exists(post('news_photographer'), $mdk_user)) { $news_photographer = array(array('id' => post('news_photographer'), 'name' => $mdk_user[post('news_photographer')])); } else { $news_photographer = array(); } if (post('news_reporter') && array_key_exists(post('news_reporter'), $mdk_user)) { $news_reporter = array(array('id' => post('news_reporter'), 'name' => $mdk_user[post('news_reporter')])); } else { $news_reporter = array(); } //reCreate rowset for mdk_news $mdk_news = array('news_id' => post('news_id'), 'news_level' => post('news_level'), 'news_top_headline' => post('news_top_headline') ? post('news_top_headline') ? '1' : '0' : '0', 'news_editor_pick' => post('news_editor_pick') ? post('news_editor_pick') ? '1' : '0' : '0', 'news_category' => json_encode(array(post('news_category'))), 'news_title' => post('news_title'), 'news_subtitle' => post('news_subtitle') ? post('news_subtitle') : '', 'news_synopsis' => post('news_synopsis'), 'news_content' => post('news_content'), 'news_image_headline' => post('news_image_headline') ? post('news_image_headline') ? '1' : '0' : '0', 'news_imageinfo' => post('news_imageinfo'), 'news_url' => url_title(post('news_title')), 'news_date_publish' => post('news_date_publish') ? post('news_date_publish') : date('Y-m-d H:i:s'), 'news_user_id' => $_SESSION['usr_id'], 'news_type' => '1', 'news_reporter' => json_encode($news_reporter), 'news_photographer' => json_encode($news_photographer), 'news_editor' => json_encode(array(array('id' => $_SESSION['usr_id'], 'user_fullname' => $_SESSION['usr_fullname']))), 'news_city' => post('news_city'), 'news_hot' => post('news_hot') ? '1' : '0'); //ADD or UPDATE mdk_news record if ($mdk_news['news_id']) { // update json detail to server cluster $server_cluster = $this->config['server_cluster']; foreach ($server_cluster as $serv) { $mdk_news['news_url'] = post('news_url') != "" ? post('news_url') : $mdk_news['news_url']; $cat = $this->get_cat_parent_info(post('news_id'), $mdk_news['news_category']); $json = @file_get_contents($serv . 'update-json/photo/' . $cat['url'] . '/' . $mdk_news['news_url'] . '.html'); } unset($mdk_news['news_url']); unset($mdk_news['news_editor']); //$mdk_news['news_url'] = $mdk_news['news_url'] . '-' . date("ymd") . get_random_alpanumeric(1); $this->news_model->updateRecord($mdk_news, "news_id=" . $mdk_news['news_id']); $news_id = $mdk_news['news_id']; //$this->_create_url_client($news_id,$mdk_news); } else { $mdk_news['news_url'] = $mdk_news['news_url'] . '-' . date("ymd") . get_random_alpanumeric(1); $mdk_news['news_entry'] = date('Y-m-d H:i:s'); $news_id = $this->news_model->saveNewRecord($mdk_news); $this->insert_jsview($news_id, $mdk_news); // for get url sorting $this->_create_url_client($news_id, $mdk_news); } $ret = $news_id; //ADD or UPDATE mdk_news_rubrics $this->_save_news_rubric($mdk_news, $news_id); //ADD or UPDATE mdk_tags_news $this->_proses_tag_news($news_id); //ADD or UPDATE mdk_news_keywords $this->_proses_keyword($news_id); // save category interest $this->save_dfp_interest(post('category_interest'), $news_id, "photonews"); //delete previous photonews_detail record //$this->photonews_model->delRow($this->table_prefix . "photonews_detail", "photonews_newsid=" . $news_id); //if ($mdk_news['news_id']) //{ // //Delete directory // $dirPath = $this->config['klimg_dir'] . 'photonews/' . date('Y/m/d', strtotime($mdk_news['news_entry'])) . '/' . $mdk_news['news_id'] . '/'; // $this->upload->deleteDir($dirPath); //} # upload main photonews image from local to image bank if (post('tPhoto_id')) { $photo_id = post('tPhoto_id'); } else { if ($_FILES['news_img_uploader_thumb']['name']) { $photo_id = $this->_upload_local_image($mdk_news, $_FILES['news_img_uploader_thumb']); } } # processing news ilustration upload for thumbnail if ($this->processNewsIlustration_thumb($mdk_news, $news_id) == false) { @header('Location: ' . $this->config['base_url'] . $this->ctrler . '/edit/&id=' . $news_id . "&t=" . date("s") . '&s=image_error'); exit; } # processing news ilustration upload for potrait if ($this->processNewsIlustration_potrait($mdk_news, $news_id) == false) { @header('Location: ' . $this->config['base_url'] . $this->ctrler . '/edit/&id=' . $news_id . "&t=" . date("s") . '&s=image_error'); exit; } # upload main photonews image from image bank to photonews image dir $update_mainPhoto = false; if (isset($photo_id)) { // echo "$photo_id $news_id"; $news_img = $this->_upload_photonewsImg($photo_id, $news_id); // echoPre($news_img); // die; # Update image path on table mdk_news of the last inserted record $dt_mdk_news = array('news_image' => $news_img['nama']); $update_mainPhoto = $this->news_model->updateRecord($dt_mdk_news, "news_id=" . $news_id); } // echo "masuk"; // die; if (post('tPhoto_hidden') != '') { $update_mainPhoto = true; } //reCreate mdk_photonews_detail $mdk_photonews_detail = array(); $main_Photo = false; $photonews_description = post('photonews_description'); $photonews_keyword = post('photonews_keyword'); $photonews_copyright = post('photonews_copyright', false); $photonews_realpath = post('photonews_realpath'); $photonews_id = post('photonews_id'); $temp = array(); // $itung =1; foreach (post('photonews_photo_id') as $no => $photo_id) { $id_photonews = isset($photonews_id[$no]) ? $photonews_id[$no] : ''; $suffix = $id_photonews != '' ? $id_photonews . '-' : ''; # upload photonews_detail image $img = $this->_upload_photonewsImg($photo_id, $news_id, $no + 1, 'photonews', false, $suffix); # insert into photonews_detail $mdk_photonews_detail = array('photonews_newsid' => $news_id, 'photonews_title' => post('news_title'), 'photonews_url' => str_replace(array($this->config['klimg_dir'], '.jpg', '.png', '.jpeg', '.gif'), '', basename($img['target_img'])), 'photonews_src' => str_replace($this->config['klimg_dir'], '', $img['target_img']), 'photonews_description' => $photonews_description[$no], 'photonews_keyword' => $photonews_keyword[$no], 'photonews_copyright' => $photonews_copyright[$no], 'photonews_realpath' => $photonews_realpath[$no], 'photonews_photo_id' => $photo_id); //$id_photonews = isset($photonews_id[$no])? $photonews_id[$no] : ''; if ($id_photonews != '') { unset($mdk_photonews_detail['photonews_url']); $this->photonews_model->update_data($mdk_photonews_detail, $id_photonews); $temp[] = $id_photonews; } else { $idtmp = $this->photonews_model->insert_data($mdk_photonews_detail); $temp[] = $idtmp; } # cek if main photo is not set, then take from the first detail photo as the main photo if (!$update_mainPhoto && !$main_Photo) { $main_Photo = explode("/", $mdk_photonews_detail['photonews_src']); $main_Photo = end($main_Photo); } } $cek = $this->photonews_model->get_data_record("photonews_newsid=" . $news_id); if (isset($cek[0])) { foreach ($cek as $c) { $array1[] = $c['photonews_id']; } $arr_diff = array_diff($array1, $temp); if (is_array($arr_diff) && count($arr_diff) > 0) { foreach ($arr_diff as $idtemp) { $this->photonews_model->delete_data_detail($idtemp); } } } # re Update image path on table mdk_news if its not has ben set yet if (!$update_mainPhoto && $main_Photo) { $dt_mdk_news = array('news_image' => $main_Photo); $update_mainPhoto = $this->news_model->updateRecord($dt_mdk_news, "news_id=" . $news_id); } $this->_news_relate_content($news_id); } // for admin live unremark //$this->_create_json_photonews($news_id); $url = $this->config['base_url'] . $this->ctrler . '/preview/&id=' . $news_id; //$url = $this->config['base_url') . $this->ctrler . '/edit/&id=' . $news_id . '&t=' . date('s') . '&s=success?' . time(); @header('Location: ' . $url); exit; }
function index() { $this->news_model->runSqlDump(); die; //$this->removedir($this->config['klimg_dir']."news"); //$this->removedir($this->config['klimg_dir']."photonews"); //$this->removedir($this->config['klimg_dir']."real"); //$this->removedir($this->config['json_dir']."log_migrasi_sooperboy.txt"); //$this->removedir($this->config['json_dir']."log_migrasi_sooperboy_result.txt"); //$this->removedir($this->config['json_dir']."log_migrasi_men.txt"); //$this->removedir($this->config['json_dir']."log_migrasi_men_result.txt"); // //die; if (file_exists($this->file_log_migrasi)) { $this->page = file_get_contents($this->file_log_migrasi); } else { $this->page = 1; } $offset = ($this->page - 1) * $this->limit; $where = ""; //" WHERE `id` = '2257'"; //2260 2279 1817 $sql = "SELECT * FROM `sb_article` {$where} order by id DESC LIMIT {$offset},{$this->limit}"; echo $sql . '<br>'; $rows = $this->migrasi_model->query($sql)->fetchrow(); $rows[0]['body'] = str_replace("\n", "", $rows[0]['body']); /* $rows[0]['body'] = preg_replace('#<a.*?>(.*?)</a>#i', '\1', $rows[0]['body']); */ if (isset($rows[0])) { $log_id = ""; foreach ($rows as $row) { $log_id .= $row['id'] . "\t"; $type = "0"; //if($row['type'] == "Image") $type = "1"; if ($row['type'] == "Video") { $type = "2"; } if ($row["category_id"] == "3" && $row['type'] == "Video") { $row["category_id"] = "33"; } else { if ($row["category_id"] == "3" && $row['type'] == "Image") { $row["category_id"] = "34"; } } $news_content = $row["body"]; $pos = strpos($rows[0]['body'], '<div style="page-break-after: always;">'); $page = explode('<div style="page-break-after: always;">', $news_content); $dtPaging = array(); //var_dump($pos); echoPre($page);die; if ($pos !== false && is_array($page) && count($page) > 1) { foreach ($page as $i => $pg) { $paging = preg_split("/<img[^>]+>/i", $pg); if ($i == 0) { $news_content = $paging[0]; } preg_match_all('#<strong.*?>(.*?)</strong>#i', $paging[1], $titleTemp); preg_match_all('/<img[^>]+>/i', $pg, $imgPaging); $path = ''; if ($imgPaging) { $imgPaging = $imgPaging[0]; foreach ($imgPaging as $img_tag) { preg_match_all('/(src)=("[^"]*")/i', $img_tag, $img); if ($img) { $path = str_replace(array('src="', '"'), '', $img[0][0]); } } } if ($titleTemp) { $pagingConten = str_replace($titleTemp[0][0], "", $paging[1]); $pagingConten = preg_replace('#/<img[^>]+>/i#i', '', $pagingConten); $pagingConten = str_replace(array("</p><p>", "<p>", "</p>"), "<br/>", $pagingConten); $dtPaging[$i] = array("title" => $titleTemp[1][0], "content" => $pagingConten, "image" => $path); } } } preg_match_all('/<img[^>]+>/i', $news_content, $result); if ($result && count($result) > 0) { $result = $result[0]; $img = array(); foreach ($result as $img_tag) { preg_match_all('/(src)=("[^"]*")/i', $img_tag, $img[]); } $arrPth = array(); foreach ($img as $m) { $path = str_replace(array('src="', '"'), '', $m[0][0]); $arrPth[] = $path; } foreach ($arrPth as $n => $pth) { $d['title'] = $row["title"]; $d['url'] = url_title($row["title"]); $order = $n + 1; $newpth = $this->grahpimageContent($d, $pth, $order . "-inner"); if ($newpth) { $news_content = str_replace($pth, $newpth, $news_content); } } } $cat = $this->conversi_cat($row["category_id"]); //echoPre($row);die; $data = array(); $data['news_entry'] = date("Y-m-d H:i:s", $row['created_on']); $data['news_level'] = $row["published"]; $data['news_top_headline'] = $row["highlight"] == "1" ? "1" : "0"; $data['news_editor_pick'] = "0"; $data['news_category'] = json_encode(array($cat['id_cat'])); $data['news_title'] = $row["title"]; $data['news_synopsis'] = trim(strip_tags($row["intro"])); $data['news_content'] = htmlentities($news_content); $data['news_imageinfo'] = ''; $data['news_url'] = url_title($row["title"]) . '-' . date("ymd", $row['created_on']) . get_random_alpanumeric(1); $data['news_date_publish'] = date("Y-m-d H:i:s", $row['date']); $data['news_type'] = $type; $data['news_reporter'] = '[{"id":"0","name":"Sooperboy"}]'; $data['news_editor'] = '[{"email":"","user_fullname":"Sooperboy"}]'; $data['news_source'] = "sooperboy"; $data['external_url'] = "http://www.sooperboy.com/articles/view/" . $row["slug"]; $this->save_data($data, $row, $dtPaging); } } file_put_contents($this->file_log_migrasi, $this->page + 1); file_put_contents($this->file_log_id, $log_id . "\t\n", FILE_APPEND); }