/** * Get page links of specified module */ function get_page_links($module = '') { $links = array(); $select_text = 'Select a page...'; if ($module == 'Pages' || $module == 'Structure') { // get site pages $this->EE->db->select('site_pages'); $this->EE->db->where('site_id', $this->site_id); $query = $this->EE->db->get('sites'); $site_pages = unserialize(base64_decode($query->row('site_pages'))); $site_pages = $site_pages[$this->site_id]; } if ($module == 'Pages') { if (isset($site_pages['uris']) && count($site_pages['uris'])) { $entry_ids = array_keys($site_pages['uris']); $this->EE->db->select(array('entry_id', 'title')); $this->EE->db->where_in('entry_id', $entry_ids); $query = $this->EE->db->get('channel_titles'); foreach ($query->result() as $row) { if (isset($site_pages['uris'][$row->entry_id])) { $title = $row->title; $url = $this->_create_url($site_pages['uris'][$row->entry_id]); $links[] = array($title, $url); } } } } else { if ($module == 'Structure') { // include structure SQL model include_once PATH_THIRD . 'structure/sql.structure.php'; // get structure data $sql = new Sql_structure(); $data = $sql->get_data(); foreach ($data as $item) { if (isset($site_pages['uris'][$item['entry_id']])) { $title = str_repeat("-", $item['depth']) . $item['title']; $url = $this->_create_url($site_pages['uris'][$item['entry_id']]); $links[] = array($title, $url); } } } else { if ($module == 'Navee') { // include navee class include_once PATH_THIRD . 'navee/mod.navee.php'; $navee = new Navee(); // get navee navs $this->EE->db->select('navigation_id, nav_name'); $this->EE->db->where('site_id', $this->site_id); $query = $this->EE->db->get('navee_navs'); $navee_navs = $query->result_array(); // get navee data foreach ($navee_navs as $navee_nav) { $data = $navee->_getNav($navee_nav['navigation_id']); array_push($links, array('NavEE Menu ' . $navee_nav['nav_name'], '')); $links = array_merge($links, $this->_parse_navee_links($data)); } $select_text = 'Select a NavEE item...'; } } } if (count($links)) { array_unshift($links, array($select_text, '')); } return $links; }
public function settings_form() { $this->EE->lang->load('content'); $this->EE->load->helper(array('html', 'form')); $query = $this->EE->db->select('group_name, template_id, template_name') ->join('template_groups', 'templates.group_id = template_groups.group_id') ->where('templates.site_id', $this->EE->config->item('site_id')) ->order_by('group_order ASC, template_name ASC') ->get('templates'); $templates = array(); foreach ($query->result() as $row) { if ( ! isset($templates[$row->group_name])) { $templates[$row->group_name] = array(); } $templates[$row->group_name][$row->template_id] = $row->template_name; } $template_field_name = $this->is_structure_installed() ? 'structure__template_id' : 'pages__pages_template_id'; $vars['value_options'] = array( 'status' => array(), $template_field_name => array(), 'new_channel' => array(), ); $vars['fields_by_id'] = array('' => array()); $channels_by_field_group = array(); $channel_titles_by_field_group = array(); $vars['channels'] = array( '' => 'Choose a channel', ); $query = $this->EE->db->select('channel_id, field_group, status_group, channel_title') ->where('site_id', $this->EE->config->item('site_id')) ->get('channels'); foreach ($query->result() as $row) { $channels_by_field_group[$row->field_group][] = $row->channel_id; $channel_titles_by_field_group[$row->field_group][] = $row->channel_title; $channels_by_status_group[$row->status_group][] = $row->channel_id; } foreach ($query->result() as $row) { $vars['channels'][$row->channel_id] = $row->channel_title; $vars['fields_by_id'][$row->channel_id] = array(); $vars['value_options'][$template_field_name][$row->channel_id] = $templates; $vars['value_options']['status'][$row->channel_id] = array('open' => lang('open'), 'closed' => lang('closed')); $vars['value_options']['new_channel'][$row->channel_id] = array_combine($channels_by_field_group[$row->field_group], $channel_titles_by_field_group[$row->field_group]); } $query->free_result(); $query = $this->EE->db->select('status, group_id') ->where('site_id', $this->EE->config->item('site_id')) ->order_by('status_order') ->get('statuses'); $vars['statuses_by_id'] = array(); foreach ($query->result() as $row) { if (isset($channels_by_status_group[$row->group_id])) { foreach ($channels_by_status_group[$row->group_id] as $_channel_id) { $vars['value_options']['status'][$_channel_id][$row->status] = lang($row->status); } } } $query->free_result(); $query = $this->EE->db->select('group_id, group_name') ->where('site_id', $this->EE->config->item('site_id')) ->get('field_groups'); foreach ($query->result() as $row) { $row->fields = array(); $vars['fields_by_id']['group_'.$row->group_id] = array(); } $query->free_result(); $query = $this->EE->db->select('field_id, group_id, field_label') ->where('site_id', $this->EE->config->item('site_id')) ->get('channel_fields'); foreach ($query->result() as $row) { $vars['fields_by_id']['group_'.$row->group_id][$row->field_id] = $row->field_label; if (isset($channels_by_field_group[$row->group_id])) { foreach ($channels_by_field_group[$row->group_id] as $_channel_id) { $vars['fields_by_id'][$_channel_id][$row->field_id] = $row->field_label; } } } $query->free_result(); $vars['global_fields'] = array( '' => 'Choose a field', 'status' => 'Status', $this->is_structure_installed() ? 'structure__template_id' : 'pages__pages_template_id' => 'Template', 'new_channel' => 'Channel', ); if ($this->is_structure_installed()) { $parent_options = array(0 => 'NONE'); require_once PATH_THIRD.'structure/sql.structure.php'; $sql = new Sql_structure(); foreach ($sql->get_data() as $entry_id => $data) { //$parent_options[$entry_id] = str_repeat("--", $data['depth']).$data['title']; if ($data['depth'] == 0) { $parent_options[$entry_id] = $data['title']; } } for ($i = 0; $i <= 10; $i++) { $depth_options[$i] = 'Depth: '.$i; } foreach ($vars['channels'] as $channel_id => $channel_title) { $vars['value_options']['structure_parent'][$channel_id] = $parent_options; $vars['value_options']['structure_depth'][$channel_id] = $depth_options; } $this->EE->load->remove_package_path(PATH_THIRD.'structure/'); unset($sql); $vars['global_fields']['structure_parent'] = 'Structure Parent Entry'; $vars['global_fields']['structure_depth'] = 'Structure Page Depth'; } $this->settings = $this->get_settings(); if (empty($this->settings)) { /* $vars['settings'] = array( 'group_1' => array( 'status' => array( 'open' => array( 'hide_fields' => array(), ) ) ) ); */ $vars['settings'] = array( '' => array( '' => array( '' => array( 'hide_fields' => array(), ) ) ) ); } else { $vars['settings'] = $this->settings; } if (method_exists($this, 'ajax_'.$this->EE->input->get('view'))) { return call_user_func(array($this, 'ajax_'.$this->EE->input->get('view')), $vars); } $this->EE->load->library('javascript'); $this->EE->cp->load_package_js('EntryTypeFieldSettings'); $this->EE->cp->load_package_js('EntryTypeExtSettings'); foreach ($vars['settings'] as $channel_id => $row) { foreach ($row as $field_name => $type_options) { $value_options = isset($vars['value_options'][$field_name][$channel_id]) ? $vars['value_options'][$field_name][$channel_id] : array(); $options = array( 'rowTemplate' => preg_replace('/[\r\n\t]/', '', $this->EE->load->view('option_field_row_ext', array('channel_id' => $channel_id, 'field_name' => $field_name, 'i' => '{{INDEX}}', 'value' => '', 'label' => '', 'hide_fields' => array(), 'fields' => $vars['fields_by_id'][$channel_id], 'value_options' => $value_options), TRUE)), 'sortable' => false, 'fieldName' => 'channel_'.$channel_id, ); $this->EE->javascript->output(' new EntryTypeFieldSettings('.json_encode('#'.$channel_id.'_'.$field_name).', '.json_encode($options).'); '); } } return form_open('C=addons_extensions'.AMP.'M=save_extension_settings'.AMP.'file=entry_type') .$this->EE->load->view('options_ext', $vars, TRUE) .form_submit('', lang('submit'), 'class="submit"') .form_close(); }