/** * Geomula, obtiene las noticias de la geomula * @param integer $pais de un articulo * @param integer $departamento de un articulo * @param integer $provincia de un articulo * @param integer $destrito de un articulo * @return void */ function geomula($pais = 0, $departamento = NULL, $provincia = NULL, $distrito = NULL) { $from = NULL; $this->load->helper('inflector'); if ($pais != '0') { $from = $pais; $where['meta_key'] = 'pais'; $where['meta_value'] = sanitize2url($pais); } else { if ($distrito != NULL) { $from = $distrito; $where['meta_key'] = 'distrito'; $where['meta_value'] = sanitize2url($distrito); } else { if ($provincia != NULL) { $from = $provincia; $where['meta_key'] = 'provincia'; $where['meta_value'] = sanitize2url($provincia); } else { if ($departamento != NULL) { if ($departamento == '0') { $from = "Lima y Callao"; $where = '(meta_key = \'departamento\' AND meta_value = \'lima\')'; $where = $where . ' OR (meta_key = \'departamento\' AND meta_value = \'callao\')'; } else { $from = $departamento; $where['meta_key'] = 'departamento'; $where['meta_value'] = sanitize2url($departamento); } } } } } $this->load->model('post'); $limit['from'] = 0; $limit['show'] = 5; $data['consulta'] = $this->post->get_geomula($where, $limit); $data['from'] = $from; $this->load->view('ws/geomula', $data); }
/** * Inserta un post del tipo articulo * @param array $values valores a insertar * @param array $customs valores personalizados * @return integer */ function insert_article($values, $customs) { $this->load->library('session'); $this->load->helper('inflector'); $values['post_author'] = $this->session->userdata('id'); $values['post_type'] = 'post'; $values['post_name'] = sanitize2url($values['post_title']); $values['post_status'] = 'publish'; $values['guid'] = $this->options->get_('home') . date('Y/m/') . $values['post_name']; //inserta los tags $tags_id = $this->terms->insert_tags($values['tags']); //limpia los tags unset($values['tags']); if (is_array($tags_id)) { foreach ($tags_id as $value) { $tmp[] = $value; } } if (is_array($values['terms_taxonomy_id'])) { foreach ($values['terms_taxonomy_id'] as $value) { $tmp[] = $value; } } $terms_taxonomy_id = $tmp; unset($values['terms_taxonomy_id']); $post_id = $this->_insertar($values); $this->postmeta->insertar_customs_locations($customs, $post_id); $this->term_relationships->insertar($post_id, $terms_taxonomy_id); return $post_id; }
/** * Agrega o modifica un video * @param boolean $ie6 es Internet Explorer 6 * @return void */ function actualizar($ie = NULL) { $this->load->helper('url'); $this->load->helper('form'); $this->load->helper('inflector'); $this->load->library('combofiller'); $this->load->library('form_validation'); $this->form_validation->set_rules($this->_reglas()); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); if ($this->form_validation->run() == FALSE) { $data['id'] = $this->input->post('id'); $data['ret'] = $this->input->post('ret'); $data['has_category'] = FALSE; $data['titulo'] = set_value('titulo'); $data['texto'] = $this->input->post('texto'); $data['tags'] = $this->input->post('tags'); $data['files'] = $this->input->post('files'); $data['doclink'] = $this->input->post('doclink'); $data['ie6'] = $ie != NULL ? TRUE : $this->_is_ie6(); $data['categorias'] = $this->combofiller->categorias(); foreach ($data['categorias'] as $key => $value) { if ($this->input->post('' . $key . '')) { $categorias_selected[] = $key; } } if (isset($categorias_selected)) { $data['categorias_selected'] = $categorias_selected == NULL ? NULL : $categorias_selected; $data['has_category'] = TRUE; } else { $data['categorias_selected'] = NULL; } $data['departamentos'] = $this->combofiller->states(TRUE); $data['departamentos_selected'] = NULL; $data['provincias_selected'] = NULL; $data['distritos_selected'] = NULL; if ($this->input->post('departamento') != 'null') { $data['departamentos_selected'] = $this->input->post('departamento'); } if ($this->input->post('provincia') != NULL) { $data['provincias'] = $this->combofiller->provinces($this->input->post('departamento'), TRUE); if ($this->input->post('provincia') != 'null') { $data['provincias_selected'] = $this->input->post('provincia'); } } if ($this->input->post('distrito') != NULL) { $data['distritos'] = $this->combofiller->districts($this->input->post('provincia'), TRUE); if ($this->input->post('distrito') != 'null') { $data['distritos_selected'] = $this->input->post('distrito'); } } $data['paices'] = $this->combofiller->countries(); $data['paices_selected'] = $this->input->post('pais'); $data['localizar'] = $this->input->post('localizar'); $data['form'] = $this->form; $this->load->view('videos/video', $data); $this->__destruct(); } else { $this->load->model('countries'); $this->load->model('states'); $this->load->model('districts'); $this->load->model('provinces'); $this->load->model('options'); $this->load->model('postmeta'); $this->load->model('post'); $this->load->model('term_relationships'); $this->load->model('terms'); $id = $this->input->post('id'); $data['post_title'] = $this->input->post('titulo'); $data['post_content'] = "<p>" . $this->input->post('texto') . "</p>"; $data['tags'] = $this->input->post('tags'); $this->load->library('zend'); $this->zend->load('Zend/Gdata/YouTube'); $this->zend->load('Zend/Gdata/ClientLogin'); $authenticationURL = 'https://www.google.com/youtube/accounts/ClientLogin'; $httpClient = Zend_Gdata_ClientLogin::getHttpClient($username = '******', $password = '******', $service = 'youtube', $client = null, $source = 'LaMulaSRD', $loginToken = null, $loginCaptcha = null, $authenticationURL); $clientId = "ytapi-AlvaroPereyraRab-WebPublishing-afg0bc0f-0"; $developerKey = "AI39si77SKdfoJ3spb7HZHe_tUVcOKX_TAn7Fne7BU8ux6ixJ6E8ZdNmZ7UeJs7y3ZGOfVyNAzSe4nYJqIX3Lu7RNryf-dOn9A"; $httpClient->setHeaders('X-GData-Key', "key={$developerKey}"); $applicationId = "SRD-LaMula-1.0"; $yt = new Zend_Gdata_YouTube($httpClient); switch ($this->input->post('upload-content')) { //subir documentos case 'subir': if ($this->_is_ie6() == TRUE or $ie != null) { if ($_FILES['Filedata']['error'] == 0) { $aceptados = array('video/quicktime', 'video/mpeg'); if (in_array($_FILES['Filedata']['type'], $aceptados)) { $docs_id[] = $this->_upload($ie); if (is_null($docs_id[0])) { //error y debo redireccionar $this->load->library('session'); $this->session->set_flashdata('fileupload', 'Error en la carga'); redirect('videos/formulario'); } } else { $this->load->library('session'); $this->session->set_flashdata('fileupload', 'Error en la carga'); redirect('videos/formulario'); } } } else { $docs_id = split('-', $this->input->post('files')); unset($docs_id[0]); } foreach ($docs_id as $doc) { $youtube = substr($doc, 31); $videoEntry = $yt->getVideoEntry($youtube); $videoThumbnails = $videoEntry->getVideoThumbnails(); $photo_url = $videoThumbnails[0]["url"]; $tmp = '<img rel="from_video" class="alignnone fromvideo" src="' . $photo_url . '" />'; $tmp .= '<br />'; $tmp .= "[youtube]"; $tmp .= $doc; $tmp .= '[/youtube]'; $data['post_content'] = $tmp . $data['post_content']; } break; //enlazar //enlazar case 'enlazar': $url = $this->input->post('doclink'); $youtube = substr($url, 31); $videoEntry = $yt->getVideoEntry($youtube); $videoThumbnails = $videoEntry->getVideoThumbnails(); $photo_url = $videoThumbnails[0]["url"]; $tmp = '<img rel="from_video" class="alignnone fromvideo" src="' . $photo_url . '" />'; $tmp .= '[youtube]' . $url . '[/youtube]'; $tmp .= '<br />'; $data['post_content'] .= $tmp; break; } //$data['post_content'] = $data['post_content']; //consigue los id de las cata $this->load->library('combofiller'); $categorias = $this->combofiller->categorias(); $terms_taxonomy_id = NULL; foreach ($categorias as $key => $value) { if ($this->input->post('' . $key . '')) { $terms_taxonomy_id[] = $key; } } switch ($this->input->post('localizar')) { case 'mundo': $tmp = array('pais'); break; case 'peru': $tmp = array('provincia', 'distrito', 'departamento'); break; } foreach ($tmp as $custom) { if ($this->input->post($custom) != NULL) { $customs[$custom] = sanitize2url($this->input->post($custom)); } } $data['terms_taxonomy_id'] = $terms_taxonomy_id; if ($id == NULL) { $post_id = $this->post->insert_article($data, $customs); $this->term_relationships->insertar($post_id, array(32)); } else { $where['id'] = $id; $this->post->actualizar($data, $customs, $where); $this->session->set_flashdata('notice', 'Documento actualizado exitosamente'); redirect('home/dashboard'); } $this->session->set_flashdata('notice', 'Video enviado exitosamente'); redirect('home/dashboard'); } }
/** * Agrega o modifica un articulo * @param boolean $ie6 es Internet Explorer 6 * @return void */ function actualizar($ie = NULL) { $this->load->helper('url'); $this->load->helper('form'); $this->load->helper('inflector'); $this->load->library('combofiller'); $this->load->library('form_validation'); $this->form_validation->set_rules($this->_reglas()); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); if ($this->form_validation->run() == FALSE) { $data['id'] = $this->input->post('id'); $data['ret'] = $this->input->post('ret'); $data['has_category'] = FALSE; $data['titulo'] = set_value('titulo'); $data['texto'] = $this->input->post('textos'); $data['tags'] = $this->input->post('tags'); $data['files'] = $this->input->post('files'); $data['ie6'] = $ie != NULL ? TRUE : $this->_is_ie6(); $data['categorias'] = $this->combofiller->categorias(); foreach ($data['categorias'] as $key => $value) { if ($this->input->post('' . $key . '')) { $categorias_selected[] = $key; } } if (isset($categorias_selected)) { $data['categorias_selected'] = $categorias_selected == NULL ? NULL : $categorias_selected; $data['has_category'] = TRUE; } else { $data['categorias_selected'] = NULL; } $data['departamentos'] = $this->combofiller->states(TRUE); $data['departamentos_selected'] = NULL; $data['provincias_selected'] = NULL; $data['distritos_selected'] = NULL; if ($this->input->post('departamento') != 'null') { $data['departamentos_selected'] = $this->input->post('departamento'); } if ($this->input->post('provincia') != NULL) { $data['provincias'] = $this->combofiller->provinces($this->input->post('departamento'), TRUE); if ($this->input->post('provincia') != 'null') { $data['provincias_selected'] = $this->input->post('provincia'); } } if ($this->input->post('distrito') != NULL) { $data['distritos'] = $this->combofiller->districts($this->input->post('provincia'), TRUE); if ($this->input->post('distrito') != 'null') { $data['distritos_selected'] = $this->input->post('distrito'); } } $data['paices'] = $this->combofiller->countries(); $data['paices_selected'] = $this->input->post('pais'); $data['localizar'] = $this->input->post('localizar'); $data['form'] = $this->form; $this->load->view('articulos/articulo', $data); $this->__destruct(); } else { $this->load->model('countries'); $this->load->model('states'); $this->load->model('districts'); $this->load->model('provinces'); $this->load->model('options'); $this->load->model('postmeta'); $this->load->model('post'); $this->load->model('term_relationships'); $this->load->model('terms'); $id = $this->input->post('id'); $data['post_title'] = $this->input->post('titulo'); if ($this->input->post('id') == NULL) { $data['post_content'] = $this->input->post('texto'); } else { $data['post_content'] = $this->input->post('ret') . ' ' . $this->input->post('texto'); } $data['tags'] = $this->input->post('tags'); switch ($this->input->post('upload-content')) { //subir imagenes case 'subir': if ($this->_is_ie6() == TRUE or $ie != null) { if ($_FILES['Filedata']['error'] == 0) { $aceptados = array('image/jpeg', 'image/png', 'image/gif', 'image/pjpeg', 'image/x-png'); if (in_array($_FILES['Filedata']['type'], $aceptados)) { $images_id[] = $this->_upload($ie); if (is_null($images_id[0])) { //error y debo redireccionar $this->load->library('session'); $this->session->set_flashdata('fileupload', 'Error en la carga'); redirect('articulos/formulario'); } } else { $this->load->library('session'); $this->session->set_flashdata('fileupload', 'Error en la carga'); redirect('articulos/formulario'); } } } else { $images_id = split('-', $this->input->post('files')); unset($images_id[0]); } foreach ($images_id as $img) { $photo_data = $this->post->seleccionar(array('ID' => $img)); $photo_data = $photo_data->row(); $search_metadata['post_id'] = $img; $search_metadata['meta_key'] = '_wp_attached_file'; $photo_name = $this->postmeta->seleccionar($search_metadata); $photo_name = $photo_name->row_array(); $photo_name = split('/', $photo_name['meta_value']); $photo_name = $photo_name[count($photo_name) - 1]; $search_metadata['meta_key'] = '_wp_attachment_metadata'; $metadata = $this->postmeta->seleccionar($search_metadata); $metadata = $metadata->row_array(); $metadata = unserialize($metadata['meta_value']); if ($metadata['sizes']['medium']['file'] != NULL) { $metadata = $metadata['sizes']['medium']['file']; } else { $metadata = $metadata['sizes']['thumbnail']['file']; } $photo = ereg_replace($photo_name, $metadata, $photo_data->guid); $tmp = '<br /><a rel="uploaded_image" href="' . $photo_data->guid . '">'; $tmp .= '<img rel="uploaded_image" class="alignnone size-medium wp-image-' . $img . '" src="' . $photo . '" />'; $tmp .= '</a>'; $tmp .= '<br />'; $data['post_content'] .= $tmp; } break; //enlazar //enlazar case 'enlazar': $tmp = '<br /><a rel="uploaded_image" href="' . $this->input->post('photolink') . '">'; $tmp .= '<img rel="uploaded_image" class="alignnone" src="' . $this->input->post('photolink') . '" />'; $tmp .= '</a>'; $tmp .= '<br />'; $data['post_content'] .= $tmp; break; } $data['post_content'] = $data['post_content'] . ''; //consigue los id de las categorias $categorias = $this->combofiller->categorias(); $terms_taxonomy_id = NULL; foreach ($categorias as $key => $value) { if ($this->input->post('' . $key . '')) { $terms_taxonomy_id[] = $key; } } switch ($this->input->post('localizar')) { case 'mundo': $tmp = array('pais'); break; case 'peru': $tmp = array('provincia', 'distrito', 'departamento'); break; } foreach ($tmp as $custom) { if ($this->input->post($custom) != NULL) { $customs[$custom] = sanitize2url($this->input->post($custom)); } } $data['terms_taxonomy_id'] = $terms_taxonomy_id; if ($id == NULL) { $post_id = $this->post->insert_article($data, $customs); $this->term_relationships->insertar($post_id, array(30)); } else { $where['id'] = $id; $this->post->actualizar($data, $customs, $where); $this->session->set_flashdata('notice', 'Nota actualizada exitosamente'); redirect('home/dashboard'); } if ($this->is_ajax != TRUE) { $this->session->set_flashdata('notice', 'Nota enviada exitosamente'); redirect('home/dashboard'); } else { $data['accion'] = 'ok'; $this->load->view('', $data); } } }
/** * Agrega o modifica un documento * @param boolean $ie6 es Internet Explorer 6 * @return void */ function actualizar($ie = NULL) { $this->load->helper('url'); $this->load->helper('form'); $this->load->helper('inflector'); $this->load->library('combofiller'); $this->load->library('form_validation'); $this->form_validation->set_rules($this->_reglas()); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); if ($this->form_validation->run() == FALSE) { $data['id'] = $this->input->post('id'); $data['ret'] = $this->input->post('ret'); $data['has_category'] = FALSE; $data['titulo'] = set_value('titulo'); $data['texto'] = $this->input->post('texto'); $data['tags'] = $this->input->post('tags'); $data['files'] = $this->input->post('files'); $data['ie6'] = $ie != NULL ? TRUE : $this->_is_ie6(); $data['categorias'] = $this->combofiller->categorias(); foreach ($data['categorias'] as $key => $value) { if ($this->input->post('' . $key . '')) { $categorias_selected[] = $key; } } if (isset($categorias_selected)) { $data['categorias_selected'] = $categorias_selected == NULL ? NULL : $categorias_selected; $data['has_category'] = TRUE; } else { $data['categorias_selected'] = NULL; } $data['departamentos'] = $this->combofiller->states(TRUE); $data['departamentos_selected'] = NULL; $data['provincias_selected'] = NULL; $data['distritos_selected'] = NULL; if ($this->input->post('departamento') != 'null') { $data['departamentos_selected'] = $this->input->post('departamento'); } if ($this->input->post('provincia') != NULL) { $data['provincias'] = $this->combofiller->provinces($this->input->post('departamento'), TRUE); if ($this->input->post('provincia') != 'null') { $data['provincias_selected'] = $this->input->post('provincia'); } } if ($this->input->post('distrito') != NULL) { $data['distritos'] = $this->combofiller->districts($this->input->post('provincia'), TRUE); if ($this->input->post('distrito') != 'null') { $data['distritos_selected'] = $this->input->post('distrito'); } } $data['paices'] = $this->combofiller->countries(); $data['paices_selected'] = $this->input->post('pais'); $data['localizar'] = $this->input->post('localizar'); $data['form'] = $this->form; $this->load->view('documentos/documento', $data); $this->__destruct(); } else { $this->load->model('countries'); $this->load->model('states'); $this->load->model('districts'); $this->load->model('provinces'); $this->load->model('options'); $this->load->model('postmeta'); $this->load->model('post'); $this->load->model('term_relationships'); $this->load->model('terms'); $id = $this->input->post('id'); $data['post_title'] = $this->input->post('titulo'); if ($this->input->post('id') == NULL) { $data['post_content'] = $this->input->post('texto'); } else { $data['post_content'] = $this->input->post('ret') . ' ' . $this->input->post('texto'); } switch ($this->input->post('upload-content')) { //subir documentos case 'subir': if ($this->_is_ie6() == TRUE or $ie != null) { if ($_FILES['Filedata']['error'] == 0) { $aceptados = array('application/pdf', 'application/msword'); if (in_array($_FILES['Filedata']['type'], $aceptados)) { $docs_id[] = $this->_upload($ie); if (is_null($docs_id[0])) { //error y debo redireccionar $this->load->library('session'); $this->session->set_flashdata('fileupload', 'Error en la carga'); redirect('documentos/formulario'); } } else { $this->load->library('session'); $this->session->set_flashdata('fileupload', 'Error en la carga'); redirect('documentos/formulario'); } } } else { $docs_id = split('-', $this->input->post('files')); unset($docs_id[0]); } foreach ($docs_id as $doc) { $doc_data = $this->post->seleccionar(array('ID' => $doc)); $doc_data = $doc_data->row(); $search_metadata['post_id'] = $doc; $search_metadata['meta_key'] = '_wp_attached_file'; $doc_name = $this->postmeta->seleccionar($search_metadata); $doc_name = $doc_name->row_array(); $doc_name = split('/', $doc_name['meta_value']); $doc_name = $doc_name[count($doc_name) - 1]; $tmp = '<br />'; $tmp .= '<a rel="uploaded_doc" href="' . $doc_data->guid . '" title="' . $doc_name . '">'; $tmp .= $this->input->post('titulo'); $tmp .= '</a>'; $tmp .= '<br />'; $data['post_content'] .= $tmp; } break; //enlazar //enlazar case 'enlazar': $tmp = '<a rel="uploaded_doc" href="' . $this->input->post('doclink') . '">'; $tmp .= $this->input->post('titulo'); $tmp .= '</a>'; $tmp .= '<br />'; $data['post_content'] .= $tmp; break; } $data['post_content'] = $data['post_content'] . ''; //Debo armar el texto con las img $data['tags'] = $this->input->post('tags'); //consigue los id de las cata $this->load->library('combofiller'); $categorias = $this->combofiller->categorias(); $terms_taxonomy_id = NULL; foreach ($categorias as $key => $value) { if ($this->input->post('' . $key . '')) { $terms_taxonomy_id[] = $key; } } switch ($this->input->post('localizar')) { case 'mundo': $tmp = array('pais'); break; case 'peru': $tmp = array('provincia', 'distrito', 'departamento'); break; } foreach ($tmp as $custom) { if ($this->input->post($custom) != NULL) { $customs[$custom] = sanitize2url($this->input->post($custom)); } } $data['terms_taxonomy_id'] = $terms_taxonomy_id; if ($id == NULL) { $post_id = $this->post->insert_article($data, $customs); $this->term_relationships->insertar($post_id, array(33)); } else { $where['id'] = $id; $this->post->actualizar($data, $customs, $where); $this->session->set_flashdata('notice', 'Documento actualizado exitosamente'); redirect('home/dashboard'); } $this->session->set_flashdata('notice', 'Documento enviado exitosamente'); redirect('home/dashboard'); } }