Ejemplo n.º 1
0
 /**
  * Reloads the Edition panel
  *
  * @param	int		$id_page
  * @param	int		$id_article
  */
 protected function _reload_panel($id_page, $id_article)
 {
     $page = $this->page_model->get_by_id($id_page);
     $page['menu'] = $this->menu_model->get($page['id_menu']);
     // Main data
     $article = $this->article_model->get_by_id($id_article);
     $article_lang = $this->article_model->get_by_id($id_article, Settings::get_lang('default'));
     $title = empty($article_lang['title']) ? $article_lang['name'] : $article_lang['title'];
     // Correcting some lang data
     $article_lang['online'] = $article['online'];
     $this->callback[] = array('fn' => 'ION.splitPanel', 'args' => array('urlMain' => admin_url(TRUE) . 'article/edit/' . $id_page . '.' . $id_article, 'urlOptions' => admin_url(TRUE) . 'article/get_options/' . $id_page . '.' . $id_article, 'title' => lang('ionize_title_edit_article') . ' : ' . $title));
     $this->callback[] = array('fn' => $page['menu']['name'] . 'Tree.updateElement', 'args' => array($article_lang, 'article'));
 }
Ejemplo n.º 2
0
 /**
  * Returns the element definition list
  * Used to admin elements (elements_definition_list and element_definition views)
  *
  * XHR call
  *
  */
 function get_element_definition_list()
 {
     $elements = $this->element_definition_model->get_lang_list(array('order_by' => 'ordering ASC'), Settings::get_lang('default'));
     $elements_lang = $this->element_definition_model->get_all('element_definition_lang');
     // Elements
     foreach ($elements as &$element) {
         $element['languages'] = array();
         // Translated elements.
         foreach (Settings::get_languages() as $lang) {
             $element['languages'][$lang['lang']] = array('title' => '');
             foreach ($elements_lang as $ld) {
                 if ($ld['id_element_definition'] == $element['id_element_definition'] && $ld['lang'] == $lang['lang']) {
                     $element['languages'][$lang['lang']] = $ld;
                 }
             }
         }
         // Element's fields
         $element['fields'] = $this->extend_field_model->get_list(array('parent' => 'element', 'id_parent' => $element['id_element_definition']), Settings::get_lang('default'));
         // Element usages on pages, articles
         $query = $this->db->where('id_element_definition = ' . $element['id_element_definition'])->from('element')->get();
         $usages = $query->result_array();
         foreach ($usages as $index => $usageElement) {
             if ($usageElement['parent'] === 'page') {
                 // get page: parent page of element
                 $usages[$index]['page'] = $this->page_model->get_by_id($usageElement['id_parent']);
                 $usages[$index]['article'] = null;
             } else {
                 // get page: parent page of article which is parent of element
                 $usages[$index]['article'] = $this->article_model->get_by_id($usageElement['id_parent']);
                 $usages[$index]['page'] = $this->page_model->get_by_id($usages[$index]['article']['id_page']);
             }
         }
         $element['usages'] = $usages;
     }
     $this->template['elements'] = $elements;
     $this->output('element/definition/list');
 }
Ejemplo n.º 3
0
Archivo: page.php Proyecto: trk/ionize
 /**
  * Adds a link to a page
  *
  * Receives :
  * $_POST['link_type'] : 	type of the link
  * $_POST['link_rel'] : 	REL to the link (can be a page or an article)
  * $_POST['receiver_rel'] : REL of the receiver's article
  * $_POST['url'] : 			URL of the external link
  *
  */
 public function add_link()
 {
     // Clear the cache
     Cache()->clear_cache();
     // Sent by ION.dropElementAsLink() or ION.addExternalLink()
     $id_page = $this->input->post('receiver_rel');
     $link_type = $this->input->post('link_type');
     $link_id = $this->input->post('link_rel');
     // Link name (default lang title, for display)
     $title = NULL;
     switch ($link_type) {
         case 'page':
             $link = $this->page_model->get_by_id($link_id, Settings::get_lang('default'));
             $title = !empty($link['title']) ? $link['title'] : $link['name'];
             break;
         case 'article':
             $link_rel = explode('.', $link_id);
             $link = $this->article_model->get_by_id($link_rel[1], Settings::get_lang('default'));
             $title = !empty($link['title']) ? $link['title'] : $link['name'];
             break;
         case 'external':
             if ($this->input->post('url') != lang('ionize_label_drop_link_here')) {
                 $title = prep_url($this->input->post('url'));
             } else {
                 $title = $link_type = '';
             }
             break;
         case 'anchor':
             $title = $this->input->post('url');
     }
     $data = array('link_id' => $link_id, 'link_type' => $link_type, 'link' => $title);
     // Save the link
     $this->page_model->update(array('id_page' => $id_page), $data);
     // Test the external link
     /*
     if ($link_type == 'external')
     {
     	$check = check_url($title);
     	
     	if($check === FALSE)
     	{
     		$this->callback[] = array
     		(
     			'fn' => 'ION.notification',
     			'args' => array	(
     				'error',
     				lang('ionize_message_url_not_found')
     			)
     		);
     		$this->response();
     
     	}
     	elseif($check == 404)
     	{
     		$this->callback[] = array
     		(
     			'fn' => 'ION.notification',
     			'args' => array	(
     				'error',
     				lang('ionize_message_url_got_404')
     			)
     		);
     		$this->response();
     	}
     }
     */
     if ($title != '') {
         $this->callback = array(array('fn' => 'ION.HTML', 'args' => array('page/get_link', array('id_page' => $id_page), array('update' => 'linkContainer'))), array('fn' => 'ION.notification', 'args' => array('success', lang('ionize_message_link_added'))));
     }
     $this->response();
 }
Ejemplo n.º 4
0
 /**
  * Edit article by ID
  *
  * @param	integer	$id Article ID
  * @return  void
  */
 public function edit($id = 0)
 {
     if ($id == 0) {
         $this->_default();
     } else {
         // load dictionaries
         $this->dict->get_wordarray(array('form', 'articles'));
         // get object
         $mod = new Article_model();
         $i = $mod->get_by_id($id);
         // cannot edit locked items
         if ($i->xlock == 1) {
             $this->_default();
         }
         // switch editor
         // default use Tiny MCE
         if (empty($i->xschema)) {
             // tinymce
             $fields = array();
             $fields[] = array('label' => null, 'type' => 'hidden', 'value' => 0, 'name' => 'schema');
             $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $_SERVER["HTTP_REFERER"], 'name' => 'from');
             $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $i->bid, 'name' => 'bid');
             $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $i->id_area, 'name' => 'id_area');
             $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $i->lang, 'name' => 'lang');
             $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $i->code_context, 'name' => 'code_context');
             $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $i->id_page, 'name' => 'id_page');
             $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $i->xkeys, 'name' => 'xkeys');
             $fields[] = array('label' => null, 'type' => 'hidden', 'value' => stripslashes($i->name), 'name' => 'name');
             $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $i->module, 'name' => 'module');
             $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $i->param, 'name' => 'param');
             // the only field not hidden
             $fields[] = array('label' => '', 'type' => 'textarea', 'value' => $i->content, 'name' => 'content');
         } else {
             // TODO: schema editor
         }
     }
     // if submitted
     if (X4Route_core::$post) {
         $e = X4Validation_helper::form($fields, 'editor');
         if ($e) {
             $this->editing($id, $_POST);
             die;
         } else {
             X4Utils_helper::set_error($fields);
         }
     }
     // get page
     $page = $this->get_page('x3admin');
     $view = new X4View_core(X4Utils_helper::set_tpl($page->tpl));
     $view->page = $page;
     // get menus
     $view->menus = $this->site->get_menus($page->id_area);
     $view->navbar = array($this->site->get_bredcrumb($page));
     // sections
     $view->args = array();
     $view->sections = array('', '');
     // content
     $view->content = new X4View_core('editor');
     $view->content->title = _EDIT_ARTICLE;
     // form builder
     $view->content->form = X4Form_helper::doform('editor', $_SERVER["REQUEST_URI"], $fields, array(_RESET, _SUBMIT, 'buttons'));
     if (empty($i->xschema)) {
         $view->content->tinymce = new X4View_core('tinymce');
         $view->content->tinymce->id_area = $page->id_area;
         $view->content->tinymce->tinybrowser = true;
     }
     $view->render(TRUE);
 }
Ejemplo n.º 5
0
 /**
  * Delete article's version
  *
  * @access	private
  * @param   integer $id article ID
  * @param   string 	$bid BID code
  * @return  void
  */
 private function deleting_version($id)
 {
     $msg = null;
     // check permissions
     $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'articles', $id, 4);
     if (is_null($msg)) {
         // do action
         $mod = new Article_model();
         $obj = $mod->get_by_id($id, 'articles', 'id_area, lang, bid');
         $result = $mod->delete($id);
         // clear useless permissions
         if ($result[1]) {
             $perm = new Permission_model();
             $perm->deleting_by_what('articles', $id);
         }
         // set message
         $msg = AdmUtils_helper::set_msg($result);
         // set what update
         if ($result[1]) {
             $msg->update[] = array('element' => 'topic', 'url' => BASE_URL . 'articles/history/' . $obj->id_area . '/' . $obj->lang . '/' . $obj->bid, 'title' => null);
         }
     }
     $this->response($msg);
 }