Пример #1
0
 function _remap_cms()
 {
     $page_data = $this->fuel_page->properties();
     $this->load->helper('cookie');
     // set up cache info
     $cache_group = $this->config->item('page_cache_group', 'fuel');
     $cache_id = fuel_cache_id();
     $output = '';
     // grab from cache if exists without checking expiration time...
     // Also.. saving from FUEL will remove cached page so you will always preview the latest saved
     if ($this->config->item('use_page_cache', 'fuel') !== 'views' and $this->cache->get($cache_id, $cache_group, FALSE) and is_true_val($this->fuel_page->is_cached) and !is_fuelified()) {
         $output = $this->cache->get($cache_id, $cache_group);
     } else {
         if (!empty($this->fuel_page->layout)) {
             // get output
             $output = $this->fuel_page->cms_render(TRUE, FALSE);
             // save to cache but you must not be logged in for it to save
             if ($this->config->item('use_page_cache', 'fuel') !== FALSE and $this->config->item('use_page_cache', 'fuel') !== 'views' and !is_fuelified()) {
                 $this->cache->save($cache_id, $output, $cache_group, $this->config->item('page_cache_ttl', 'fuel'));
             }
         } else {
             // do any redirects... will exit script if any
             $this->_redirects();
             // else show 404
             show_404();
         }
     }
     // fuelify
     $output = $this->fuel_page->fuelify($output);
     // render output
     $this->output->set_output($output);
     // call the post render layout hook
     $this->fuel_layouts->call_hook($page_data['layout'], 'post_render', $output);
 }
 function cast($val, $type)
 {
     $return = '';
     switch ($type) {
         case 'int':
             $return = (int) $val;
             break;
         case 'boolean':
             $return = is_true_val($val);
             break;
         case 'array':
             $return = is_serialized_str($val) ? unserialize($val) : array();
             break;
         default:
             $return = $val;
     }
     return $return;
 }
Пример #3
0
 public function _toggle_callback($cols, $heading)
 {
     $valid_user = $this->fuel->auth->valid_user();
     $can_publish = ($heading == 'active' and $this->fuel->auth->has_permission($this->permission) and $cols['id'] != $valid_user['id']);
     $no = lang("form_enum_option_no");
     $yes = lang("form_enum_option_yes");
     $col_txt = lang('click_to_toggle');
     // boolean fields
     if (!is_true_val($cols[$heading])) {
         $text_class = $can_publish ? "publish_text unpublished toggle_on" : "unpublished";
         $action_class = $can_publish ? "publish_action unpublished hidden" : "unpublished hidden";
         return '<span class="publish_hover"><span class="' . $text_class . '" id="row_published_' . $cols[$this->model->key_field()] . '" data-field="' . $heading . '">' . $no . '</span><span class="' . $action_class . '">' . $col_txt . '</span></span>';
     } else {
         $text_class = $can_publish ? "publish_text published toggle_off" : "published";
         $action_class = $can_publish ? "publish_action published hidden" : "published hidden";
         return '<span class="publish_hover"><span class="' . $text_class . '" id="row_published_' . $cols[$this->model->key_field()] . '" data-field="' . $heading . '">' . $yes . '</span><span class="' . $action_class . '">' . $col_txt . '</span></span>';
     }
 }
Пример #4
0
 function _form($id = NULL)
 {
     $this->load->library('form_builder');
     $model = $this->model;
     $this->js_controller_params['method'] = 'add_edit';
     // get saved data
     $saved = array();
     if (!empty($id)) {
         $saved = $this->model->user_info($id);
     }
     // create fields... start with the table info and go from there
     $fields = $this->model->form_fields($saved);
     // set active to hidden since setting this is an buttton/action instead of a form field
     // $fields['active']['type'] = 'hidden';
     if (!empty($saved['active'])) {
         $fields['active']['value'] = $saved['active'];
     }
     $field_values = !empty($_POST) ? $_POST : $saved;
     if (!empty($saved)) {
         foreach ($saved as $key => $val) {
             if (strncmp($key, 'permissions_', 12) === 0) {
                 $field_values['permissions_' . $val['perm_id']] = TRUE;
             }
         }
     }
     $this->form_builder->form->validator =& $this->model->get_validation();
     $this->form_builder->submit_value = 'Save';
     $this->form_builder->use_form_tag = FALSE;
     $this->form_builder->set_fields($fields);
     $this->form_builder->display_errors = FALSE;
     $this->form_builder->set_field_values($field_values);
     $vars['form'] = $this->form_builder->render();
     // other variables
     $vars['id'] = $id;
     $vars['data'] = $saved;
     $vars['action'] = !empty($saved['id']) ? 'edit' : 'create';
     $vars['others'] = $this->model->get_others('name', $id);
     // active or publish fields
     $vars['activate'] = !empty($saved['active']) && is_true_val($saved['active']) ? 'Deactivate' : 'Activate';
     $vars['module'] = $this->module;
     $vars['actions'] = $this->load->module_view(FUEL_FOLDER, '_blocks/module_create_edit_actions', $vars, TRUE);
     return $vars;
 }
 /**
  * Magic method for capturing method calls on the record object that don't exist. Allows for "get_{field}" to map to just "{field}" as well as "is_{field}"" and "has_{field}".
  *
  * @access	public
  * @param	object	method name
  * @param	array	arguments
  * @return	array
  */
 public function __call($method, $args)
 {
     if (preg_match("/^set_(.*)/", $method, $found)) {
         if (property_exists($this, $found[1])) {
             $method = $found[1];
             $this->{$method} = $args[0];
             return TRUE;
         }
     } else {
         if (preg_match("/^get_(.*)/", $method, $found)) {
             if (property_exists($this, $found[1])) {
                 $method = $this->{$found}[1];
                 return $this->{$method};
             }
         } elseif (preg_match("/^is_(.*)/", $method, $found)) {
             if (property_exists($this, $found[1])) {
                 if (!empty($found[1])) {
                     return is_true_val($this->{$found}[1]);
                 }
             }
         } else {
             if (preg_match("/^has_(.*)/", $method, $found)) {
                 if (property_exists($this, $found[1])) {
                     return !empty($this->{$found}[1]);
                 }
             }
         }
     }
     return FALSE;
 }
Пример #6
0
 /**
  * Magic method for capturing method calls on the record object that don't exist. Allows for "get_{field}" to map to just "{field}" as well as "is_{field}"" and "has_{field}"
  *
  * @access	public
  * @param	object	method name
  * @param	array	arguments
  * @return	array
  */
 public function __call($method, $args)
 {
     if (preg_match("/^set_(.*)/", $method, $found)) {
         if (array_key_exists($found[1], $this->_fields)) {
             $this->_fields[$found[1]] = $args[0];
             return TRUE;
         }
     } else {
         if (preg_match("/^get_(.*)/", $method, $found)) {
             if ($this->_is_relationship_property($found[1], 'has_many')) {
                 $return_object = isset($args[0]) ? $args[0] : FALSE;
                 return $this->_get_relationship($found[1], $return_object, 'has_many');
             } else {
                 if ($this->_is_relationship_property($found[1], 'belongs_to')) {
                     $return_object = isset($args[0]) ? $args[0] : FALSE;
                     return $this->_get_relationship($found[1], $return_object, 'belongs_to');
                 } else {
                     if (array_key_exists($found[1], $this->_fields)) {
                         return $this->_fields[$found[1]];
                     }
                 }
             }
         } else {
             if (preg_match("/^is_(.*)/", $method, $found)) {
                 if (array_key_exists($found[1], $this->_fields)) {
                     $field = $this->_parent_model->field_info($found[1]);
                     if (!empty($field) and ($field['type'] == 'enum' and count($field['options']) == 2 or in_array($found[1], $this->_parent_model->boolean_fields))) {
                         return is_true_val($this->_fields[$found[1]]);
                     }
                 }
             } else {
                 if (preg_match("/^has_(.*)/", $method, $found)) {
                     $foreign_keys = $this->_parent_model->foreign_keys;
                     if (array_key_exists($found[1], $this->_fields)) {
                         return !empty($this->_fields[$found[1]]) and $this->_fields[$found[1]] != '0000-00-00' and $this->_fields[$found[1]] != '0000-00-00 00:00:00';
                     } else {
                         if (in_array($found[1] . '_id', array_keys($foreign_keys)) or $this->_is_relationship_property($found[1], 'has_many') or $this->_is_relationship_property($found[1], 'belongs_to')) {
                             $return_object = $this->{$found}[1];
                             $key_field = $this->_parent_model->key_field();
                             return isset($return_object->{$key_field});
                         }
                     }
                 } else {
                     // // take the field name plus a '_' to get the suffix
                     $suffix = substr(strrchr($method, '_'), 1);
                     // get the core field name without the suffix (+1 because of underscore)
                     $field = substr($method, 0, -(strlen($suffix) + 1));
                     return $this->format($field, $suffix, $args);
                 }
             }
         }
     }
     return FALSE;
 }
Пример #7
0
 protected function _form($id = NULL, $fields = NULL, $log_to_recent = TRUE, $display_normal_submit_cancel = TRUE)
 {
     $this->load->library('form_builder');
     //		$this->model->set_return_method('array');
     $model = $this->model;
     $this->js_controller_params['method'] = 'add_edit';
     // get saved data
     $saved = array();
     if (!empty($id) and $id != 'create') {
         $edit_method = $this->edit_method;
         if ($edit_method != 'find_one_array') {
             $saved = $this->model->{$edit_method}($id);
         } else {
             $saved = $this->model->{$edit_method}(array($this->model->table_name() . '.' . $this->model->key_field() => $id));
         }
         if (empty($saved)) {
             show_404();
         }
     }
     // create fields... start with the table info and go from there
     if (empty($fields)) {
         $fields = $this->model->form_fields($saved);
         // set published/active to hidden since setting this is an buttton/action instead of a form field
         //$fields['published']['type'] = 'hidden';
         if (is_array($fields)) {
             if (!empty($saved['published'])) {
                 $fields['published']['value'] = $saved['published'];
             }
             if (!$this->fuel_auth->has_permission($this->permission, 'publish')) {
                 unset($fields['published']);
             }
         }
     }
     if (is_array($fields)) {
         $field_values = !empty($_POST) ? $_POST : $saved;
         $this->form_builder->form->validator =& $this->model->get_validation();
         // not inline edited
         if ($display_normal_submit_cancel) {
             $this->form_builder->submit_value = 'Save';
             $this->form_builder->cancel_value = 'Cancel';
         } else {
             $this->form_builder->submit_value = NULL;
             $this->form_builder->cancel_value = NULL;
             //$this->form_builder->name_array = '__fuel_field__'.$this->module_name.'_'.$id;
             $fields['__fuel_inline_action__'] = array('type' => 'hidden');
             $fields['__fuel_inline_action__']['class'] = '__fuel_inline_action__';
             $fields['__fuel_inline_action__']['value'] = empty($id) ? 'create' : 'edit';
             $fields['__fuel_module__'] = array('type' => 'hidden');
             $fields['__fuel_module__']['value'] = $this->module;
             $fields['__fuel_module__']['class'] = '__fuel_module__';
             $this->form_builder->name_prefix = '__fuel_field__' . $this->module . '_' . (empty($id) ? 'create' : $id);
             $this->form_builder->css_class = 'inline_form';
         }
         //$this->form_builder->hidden = (array) $this->model->key_field();
         $this->form_builder->question_keys = array();
         $this->form_builder->use_form_tag = FALSE;
         $this->form_builder->set_fields($fields);
         $this->form_builder->display_errors = FALSE;
         $this->form_builder->set_field_values($field_values);
         $this->form_builder->displayonly = $this->displayonly;
         $vars['form'] = $this->form_builder->render();
     } else {
         $vars['form'] = $fields;
     }
     // other variables
     $vars['id'] = $id;
     $vars['data'] = $saved;
     $vars['action'] = !empty($saved[$this->model->key_field()]) ? 'edit' : 'create';
     $vars['versions'] = $this->archives_model->options_list($id, $this->model->table_name());
     $vars['others'] = $this->model->get_others($this->display_field, $id);
     preg_match_all('#\\{(.+)\\}+#U', $this->preview_path, $matches);
     if (!empty($matches[1])) {
         foreach ($matches[1] as $match) {
             if (!empty($vars['data'][$match])) {
                 $this->preview_path = str_replace('{' . $match . '}', $vars['data'][$match], $this->preview_path);
             }
         }
     }
     // active or publish fields
     if (isset($saved['published'])) {
         $vars['publish'] = (!empty($saved['published']) and is_true_val($saved['published'])) ? 'Unpublish' : 'Publish';
     }
     if (isset($saved['active'])) {
         $vars['activate'] = (!empty($saved['active']) and is_true_val($saved['active'])) ? 'Deactivate' : 'Activate';
     }
     $vars['module'] = $this->module;
     $actions = $this->load->module_view(FUEL_FOLDER, '_blocks/module_create_edit_actions', $vars, TRUE);
     $vars['actions'] = $actions;
     $vars['error'] = $this->model->get_errors();
     $notifications = $this->load->module_view(FUEL_FOLDER, '_blocks/notifications', $vars, TRUE);
     $vars['notifications'] = $notifications;
     // do this after rendering so it doesn't render current page'
     if (!empty($vars['data'][$this->display_field]) and $log_to_recent) {
         $this->_recent_pages($this->uri->uri_string(), $this->module_name . ': ' . $vars['data'][$this->display_field], $this->module);
     }
     return $vars;
 }
Пример #8
0
				<?php if (isset($page['published']) && !is_true_val($page['published'])) : ?>
						<li class="start unpublished round exposed"><?=lang('inline_edit_page_not_published')?></li>
				<?php endif; ?>
				
				<li class="<?=(isset($page['published']) && !is_true_val($page['published']))? 'exposed' : 'start round exposed'; ?>"><a href="#" id="__fuel_page_toolbar_toggle__" class="ico ico_fuel" title="<?=lang('inline_edit_toggle_toolbar')?>"></a></li>
				
				<li<?php if (!empty($_COOKIE['fuel_show_editable_areas']) && $_COOKIE['fuel_show_editable_areas'] == 1) : ?> class="active"<?php endif; ?>><a href="#" id="__fuel_page_edit_toggle__" class="ico ico_edit" title="<?=lang('inline_edit_toggle_editable')?>"></a></li>
			
				<?php if (isset($page['published'])) : ?>
					<?php $publish = (!is_true_val($page['published'])) ? 'unpublish' : 'publish';?>
					<li<?php if (is_true_val($page['published'])) : ?> class="active"<?php endif; ?>><a href="#" class="ico ico_<?=$publish?>" id="__fuel_page_publish_toggle__" title="<?=lang('inline_edit_toggle_publish')?>"></a></li>
					<?=$this->form->hidden('published', $page['published'], 'id="__fuel_page_published__"')?>
				<?php endif; ?>

				<?php if (isset($page['cache'])) : ?>
					<li<?php if (is_true_val($page['cache'])) : ?> class="active"<?php endif; ?>><a href="#" class="ico ico_cache" id="__fuel_page_cache_toggle__" title="<?=lang('inline_edit_toggle_cache')?>"></a></li>
					<?=$this->form->hidden('cache', $page['cache'], 'id="__fuel_page_cached__"')?>
				<?php endif; ?>
			
				
				<?php if (count($others) > 0) : ?><li> &nbsp;<?=$this->form->select('others', $others, '', 'id="__fuel_page_others__"', lang('inline_edit_other_pages'))?> </li><?php endif; ?>
				<?php if (count($layouts) > 1) : ?><li><label for="layout"><?=lang('inline_edit_layout')?></label> <?=$this->form->select('layout', $layouts, $page['layout'], 'id="__fuel_page_layout__"')?></li><?php endif; ?>
				<li class="txt"><a href="<?=fuel_url('pages/edit/'.$page['id'])?>" title="<?=lang('inline_edit_back_to_admin')?>"><?=lang('inline_edit_back_to_admin')?></a></li>
				<li class="txt"><a href="<?=fuel_url('logout/'.$last_page)?>" title="<?=lang('inline_edit_logout_title')?>"><?=lang('inline_edit_logout')?></a></li>
				
			<?php endif; ?>
		</ul>
		<div class="clear"></div>
	</div>
	<?php if (isset($page['id'])) : ?>
	<?=$this->form->hidden('id', $page['id'], 'id=""')?>
Пример #9
0
 protected function _process_uploads($posted = NULL)
 {
     if (empty($posted)) {
         $posted = $_POST;
     }
     $this->lang->load('upload');
     $errors = FALSE;
     if (!empty($_FILES)) {
         $this->load->module_model(FUEL_FOLDER, 'assets_model');
         $this->load->library('upload');
         $this->load->helper('directory');
         $config['max_size'] = $this->config->item('assets_upload_max_size', 'fuel');
         $config['max_width'] = $this->config->item('assets_upload_max_width', 'fuel');
         $config['max_height'] = $this->config->item('assets_upload_max_height', 'fuel');
         // loop through all the uploaded files
         foreach ($_FILES as $file => $file_info) {
             if ($file_info['error'] == 0) {
                 // continue processing
                 $filename = $file_info['name'];
                 $filename_arr = explode('.', $filename);
                 $filename_no_ext = $filename_arr[0];
                 $ext = end($filename_arr);
                 $test_multi = explode('___', $file);
                 $is_multi = count($test_multi) > 1;
                 $multi_root = $test_multi[0];
                 // loop through all the allowed file types that are accepted for the asset directory
                 foreach ($this->assets_model->get_dir_filetypes() as $key => $val) {
                     $file_types = explode('|', strtolower($val));
                     if (in_array(strtolower($ext), $file_types)) {
                         $asset_dir = $key;
                         break;
                     }
                 }
                 if (!empty($asset_dir)) {
                     // upload path
                     if (!empty($posted[$file . '_path'])) {
                         $config['upload_path'] = $posted[$file . '_path'];
                     } else {
                         if (!empty($posted[$multi_root . '_path'])) {
                             $config['upload_path'] = $posted[$multi_root . '_path'];
                         } else {
                             $config['upload_path'] = isset($upload_path) ? $upload_path : assets_server_path() . $asset_dir . '/';
                         }
                     }
                     if (!is_dir($config['upload_path']) and $this->config->item('assets_allow_subfolder_creation', 'fuel')) {
                         // will recursively create folder
                         //$old = umask(0)
                         @mkdir($config['upload_path'], 0777, TRUE);
                         if (!file_exists($config['upload_path'])) {
                             $errors = TRUE;
                             add_error(lang('upload_not_writable'));
                             $this->session->set_flashdata('error', lang('upload_not_writable'));
                         } else {
                             chmodr($config['upload_path'], 0777);
                         }
                         //umask($old);
                     }
                     // overwrite
                     if (isset($posted[$file . '_overwrite'])) {
                         $config['overwrite'] = is_true_val($posted[$file . '_overwrite']);
                     } else {
                         if (isset($posted[$multi_root . '_overwrite'])) {
                             $config['overwrite'] = is_true_val($posted[$multi_root . '_overwrite']);
                         } else {
                             $config['overwrite'] = TRUE;
                         }
                     }
                     // filename... lower case it for consistency
                     $config['file_name'] = url_title($filename, 'underscore', TRUE);
                     if (!empty($posted[$file . '_filename'])) {
                         $config['file_name'] = $posted[$file . '_filename'] . '.' . $ext;
                     } else {
                         if (!empty($posted[$multi_root . '_filename'])) {
                             $config['file_name'] = $posted[$multi_root . '_filename'] . '.' . $ext;
                         }
                     }
                     $config['allowed_types'] = $this->assets_model->get_dir_filetype($asset_dir) ? $this->assets_model->get_dir_filetype($asset_dir) : 'jpg|jpeg|png|gif';
                     $config['remove_spaces'] = TRUE;
                     //$config['xss_clean'] = TRUE; // causes problem with image if true... so we use the below method
                     $tmp_file = file_get_contents($file_info['tmp_name']);
                     if ($this->sanitize_images and xss_clean($tmp_file, TRUE) === FALSE) {
                         $errors = TRUE;
                         add_error(lang('upload_invalid_filetype'));
                         $this->session->set_flashdata('error', lang('upload_invalid_filetype'));
                     }
                     if (!$errors) {
                         $this->upload->initialize($config);
                         if (!$this->upload->do_upload($file)) {
                             $errors = TRUE;
                             add_error($this->upload->display_errors('', ''));
                             $this->session->set_flashdata('error', $this->upload->display_errors('', ''));
                         } else {
                             // saves data about successfully uploaded file
                             $this->upload_data[] = $this->upload->data();
                         }
                     }
                 } else {
                     $errors = TRUE;
                     add_error(lang('upload_invalid_filetype'));
                 }
             }
         }
     }
     // transfers data about successfully uploaded file to the model
     if (isset($this->model->upload_data)) {
         $this->model->upload_data = $this->upload_data;
     }
     return !$errors;
 }
Пример #10
0
 function upload()
 {
     $this->load->library('form_builder');
     $this->load->module_model(FUEL_FOLDER, 'navigation_groups_model');
     $this->load->module_model(FUEL_FOLDER, 'navigation_model');
     $this->js_controller_params['method'] = 'upload';
     if (!empty($_POST)) {
         $this->load->library('menu');
         if (!empty($_FILES['file']['name'])) {
             $error = FALSE;
             $file_info = $_FILES['file'];
             @(include $file_info['tmp_name']);
             if (!empty($nav)) {
                 $nav = $this->menu->normalize_items($nav);
                 $group_id = $this->input->post('group_id');
                 if (is_true_val($this->input->post('clear_first'))) {
                     $this->navigation_model->delete(array('group_id' => $this->input->post('group_id')));
                 }
                 // save navigation group
                 $group = $this->navigation_groups_model->find_by_key($this->input->post('group_id'));
                 if (!isset($group->id)) {
                     $save['name'] = 'main';
                     $id = $this->navigation_groups_model->save($save);
                     $group_id = $id;
                 }
                 // convert string ids to numbers so we can save
                 $ids = array();
                 $i = 1;
                 foreach ($nav as $item) {
                     $ids[$item['id']] = $i;
                     $i++;
                 }
                 // now loop through and save
                 $cnt = 0;
                 foreach ($nav as $key => $item) {
                     $save = array();
                     $save['id'] = $ids[$item['id']];
                     $save['nav_key'] = $key;
                     $save['group_id'] = $group_id;
                     $save['label'] = $item['label'];
                     $save['parent_id'] = empty($ids[$item['parent_id']]) ? 0 : $ids[$item['parent_id']];
                     $save['location'] = $item['location'];
                     $save['selected'] = !empty($item['selected']) ? $item['selected'] : $item['active'];
                     // must be different because "active" has special meaning in FUEL
                     $save['hidden'] = is_true_val($item['hidden']) ? 'yes' : 'no';
                     $save['published'] = 'yes';
                     $save['precedence'] = $cnt;
                     if (is_array($item['attributes'])) {
                         $attr = '';
                         foreach ($item['attributes'] as $key => $val) {
                             $attr .= $key . '="' . $val . '" ';
                         }
                         $attr = trim($attr);
                     } else {
                         $save['attributes'] = $item['attributes'];
                     }
                     if (!$this->navigation_model->save($save)) {
                         $error = TRUE;
                         break;
                     }
                     $cnt++;
                 }
             }
             if ($error) {
                 add_error(lang('error_nav_upload'));
             } else {
                 $this->session->set_flashdata('success', lang('success_nav_upload'));
                 redirect($this->uri->uri_string());
             }
         } else {
             add_error(lang('error_nav_upload'));
         }
     }
     $fields = array();
     $nav_groups = $this->navigation_groups_model->options_list('id', 'name', array('published' => 'yes'));
     if (empty($nav_groups)) {
         $nav_groups = array('1' => 'main');
     }
     $fields['group_id'] = array('type' => 'select', 'options' => $nav_groups, 'label' => 'Navigation Group');
     $fields['file'] = array('type' => 'file');
     $fields['clear_first'] = array('type' => 'enum', 'options' => array('yes' => 'yes', 'no' => 'no'));
     $this->form_builder->set_fields($fields);
     $this->form_builder->submit_value = '';
     $this->form_builder->use_form_tag = FALSE;
     $vars['form'] = $this->form_builder->render();
     $this->_render('navigation_upload', $vars);
 }
Пример #11
0
 function upload()
 {
     $this->load->helper('file');
     $this->load->helper('security');
     $this->load->library('form_builder');
     $this->load->module_model(FUEL_FOLDER, 'navigation_groups_model');
     $this->load->module_model(FUEL_FOLDER, 'navigation_model');
     $this->js_controller_params['method'] = 'upload';
     if (!empty($_POST)) {
         $this->load->library('menu');
         if (!empty($_FILES['file']['name'])) {
             $error = FALSE;
             $file_info = $_FILES['file'];
             // read in the file so we can filter it
             $file = read_file($file_info['tmp_name']);
             // strip any php tags
             $file = str_replace('<?php', '', $file);
             // run xss_clean on it
             $file = xss_clean($file);
             // now evaluate the string to get the nav array
             @eval($file);
             //@include($file_info['tmp_name']);
             if (!empty($nav)) {
                 $nav = $this->menu->normalize_items($nav);
                 $group_id = $this->input->post('group_id');
                 if (is_true_val($this->input->post('clear_first'))) {
                     $this->navigation_model->delete(array('group_id' => $this->input->post('group_id')));
                 }
                 // save navigation group
                 $group = $this->navigation_groups_model->find_by_key($this->input->post('group_id'));
                 // set default navigation group if it doesn't exist'
                 if (!isset($group->id)) {
                     $save['name'] = 'main';
                     $id = $this->navigation_groups_model->save($save);
                     $group_id = $id;
                 }
                 // convert string ids to numbers so we can save... must start at last id in db
                 $ids = array();
                 $i = $this->navigation_model->max_id() + 1;
                 foreach ($nav as $key => $item) {
                     // if the id is empty then we assume it is the homepage
                     if (empty($item['id'])) {
                         $item['id'] = 'home';
                         $nav[$key]['id'] = 'home';
                     }
                     $ids[$item['id']] = $i;
                     $i++;
                 }
                 // now loop through and save
                 $cnt = 0;
                 foreach ($nav as $key => $item) {
                     $save = array();
                     $save['id'] = $ids[$item['id']];
                     $save['nav_key'] = empty($key) ? 'home' : $key;
                     $save['group_id'] = $group_id;
                     $save['label'] = $item['label'];
                     $save['parent_id'] = empty($ids[$item['parent_id']]) ? 0 : $ids[$item['parent_id']];
                     $save['location'] = $item['location'];
                     $save['selected'] = !empty($item['selected']) ? $item['selected'] : $item['active'];
                     // must be different because "active" has special meaning in FUEL
                     // fix for homepage links
                     if (empty($save['selected']) and $save['nav_key'] == 'home') {
                         $save['selected'] = 'home$';
                     }
                     $save['hidden'] = is_true_val($item['hidden']) ? 'yes' : 'no';
                     $save['published'] = 'yes';
                     $save['precedence'] = $cnt;
                     if (is_array($item['attributes'])) {
                         $attr = '';
                         foreach ($item['attributes'] as $key => $val) {
                             $attr .= $key . '="' . $val . '" ';
                         }
                         $attr = trim($attr);
                     } else {
                         $save['attributes'] = $item['attributes'];
                     }
                     if (!$this->navigation_model->save($save)) {
                         $error = TRUE;
                         break;
                     }
                     $cnt++;
                 }
             } else {
                 $error = TRUE;
             }
             if ($error) {
                 add_error(lang('error_upload'));
             } else {
                 // change list view page state to show the selected group id
                 $page_state = $this->_get_page_state($this->module_uri);
                 $page_state['group_id'] = $group_id;
                 $this->_save_page_state($page_state);
                 $this->session->set_flashdata('success', lang('navigation_success_upload'));
                 redirect(fuel_url('navigation'));
             }
         } else {
             add_error(lang('error_upload'));
         }
     }
     $fields = array();
     $nav_groups = $this->navigation_groups_model->options_list('id', 'name', array('published' => 'yes'), 'id asc');
     if (empty($nav_groups)) {
         $nav_groups = array('1' => 'main');
     }
     $fields['group_id'] = array('type' => 'select', 'options' => $nav_groups, 'class' => 'add_edit navigation_group');
     $fields['file'] = array('type' => 'file', 'accept' => '');
     $fields['clear_first'] = array('type' => 'enum', 'options' => array('yes' => 'yes', 'no' => 'no'));
     $this->form_builder->set_fields($fields);
     $this->form_builder->submit_value = '';
     $this->form_builder->use_form_tag = FALSE;
     $vars['instructions'] = lang('navigation_import_instructions');
     $vars['form'] = $this->form_builder->render();
     $this->_render('upload', $vars);
 }
Пример #12
0
 function _notify($comment, $post)
 {
     // send email to post author
     if (!empty($post->author)) {
         $this->load->library('email');
         $this->email->from($this->config->item('from_email', 'fuel'), $this->config->item('site_name', 'fuel'));
         $this->email->to($post->author->email);
         $this->email->subject(lang('blog_comment_monitor_subject', $this->fuel_blog->settings('title')));
         $msg = $this->lang->line('blog_comment_monitor_msg');
         $msg .= "\n" . fuel_url('blog/comments/edit/' . $comment->id) . "\n\n";
         $msg .= is_true_val($comment->is_spam) ? lang('blog_email_flagged_as_spam') . "\n" : '';
         $msg .= lang('blog_email_published') . ": " . $comment->published . "\n";
         $msg .= lang('blog_email_author_name') . ": " . $comment->author_name . "\n";
         $msg .= lang('blog_email_author_email') . ": " . $comment->author_email . "\n";
         $msg .= lang('blog_email_author_ip') . ": " . gethostbyaddr($comment->author_ip) . " (" . $comment->author_ip . ")\n";
         $msg .= lang('blog_email_content') . ": " . $comment->content . "\n";
         $this->email->message($msg);
         return $this->email->send();
     } else {
         return FALSE;
     }
 }
Пример #13
0
" id="__fuel_page_publish_toggle__" title="<?php 
            echo lang('inline_edit_toggle_publish');
            ?>
"></a></li>
					<?php 
            echo $this->form->hidden('published', $page['published'], 'id="__fuel_page_published__"');
            ?>
				<?php 
        }
        ?>

				<?php 
        if (isset($page['cache'])) {
            ?>
					<li<?php 
            if (is_true_val($page['cache'])) {
                ?>
 class="active"<?php 
            }
            ?>
><a href="#" class="ico ico_cache" id="__fuel_page_cache_toggle__" title="<?php 
            echo lang('inline_edit_toggle_cache');
            ?>
"></a></li>
					<?php 
            echo $this->form->hidden('cache', $page['cache'], 'id="__fuel_page_cached__"');
            ?>
				<?php 
        }
        ?>
			
Пример #14
0
 public function _form($field_values = NULL, $inline = FALSE)
 {
     $this->load->library('form_builder');
     $this->load->helper('convert');
     $model = $this->model;
     $this->js_controller_params['method'] = 'add_edit';
     $fields = $this->model->form_fields();
     $fields['redirect_to'] = array('type' => 'hidden', 'value' => uri_safe_encode($this->input->get_post('redirect_to')));
     $not_hidden = array();
     if (!empty($field_values['hide_options']) and is_true_val($field_values['hide_options'])) {
         $not_hidden = array('userfile');
     } else {
         if (!empty($field_values['hide_image_options']) and is_true_val($field_values['hide_image_options'])) {
             $not_hidden = array('userfile', 'asset_folder', 'subfolder', 'userfile_file_name', 'overwrite', 'unzip');
         }
     }
     if (!empty($field_values['accept'])) {
         $fields['userfile']['accept'] = $field_values['accept'];
     }
     if (isset($field_values['multiple'])) {
         if ((bool) $field_values['multiple'] === FALSE) {
             $fields['userfile']['class'] = '';
         } else {
             // if their are multiple files being uploaded, the new file name won't really work
             unset($fields['user_file_name']);
         }
     }
     // hide certain fields if params were passed
     if (!empty($not_hidden)) {
         foreach ($fields as $key => $field) {
             if (!in_array($key, $not_hidden)) {
                 $fields[$key]['type'] = 'hidden';
             }
         }
     }
     if ($this->session->flashdata('uploaded_post')) {
         $field_values = $this->session->flashdata('uploaded_post');
     }
     // load custom fields
     $this->form_builder->load_custom_fields(APPPATH . 'config/custom_fields.php');
     $this->form_builder->submit_value = lang('btn_upload');
     $this->form_builder->use_form_tag = FALSE;
     $this->form_builder->set_fields($fields);
     $this->form_builder->display_errors = FALSE;
     $this->form_builder->set_field_values($field_values);
     /* NOT QUITE WORKING DUE TO CANCEL BUTTON */
     // if ($this->input->get_post('redirect_to'))
     // {
     // 	$this->form_builder->other_actions = $this->form->button('Back', 'back', 'style="margin: 10px 10px 0 0; float: left;" data-url="'.site_url($this->input->get_post('redirect_to')).'"');
     // }
     $vars['form'] = $this->form_builder->render();
     // other variables
     $vars['id'] = !empty($field_values['asset_folder']) ? uri_safe_encode($field_values['asset_folder']) : NULL;
     $vars['data'] = array();
     $vars['action'] = 'create';
     // $preview_key = preg_replace('#^(.*)\{(.+)\}(.*)$#', "\\2", $this->preview_path);
     // if (!empty($vars['data'][$preview_key])) $this->preview_path = preg_replace('#^(.*)\{(.+)\}(.*)$#e', "'\\1'.\$vars['data']['\\2'].'\\3'", $this->preview_path);
     // active or publish fields
     //$vars['publish'] = (!empty($saved['published']) && ($saved['published'] == 'yes')) ? 'Unpublish' : 'Publish';
     $vars['module'] = $this->module;
     $vars['actions'] = $this->load->view('_blocks/module_create_edit_actions', $vars, TRUE);
     $vars['notifications'] = $this->load->view('_blocks/notifications', $vars, TRUE);
     // setup query string
     $query_str = query_str();
     if ($inline === TRUE) {
         $vars['form_action'] = $this->module_uri . '/inline_create/' . $vars['id'] . $query_str;
     } else {
         $vars['form_action'] = $this->module_uri . '/create/' . $vars['id'] . $query_str;
     }
     return $vars;
 }
Пример #15
0
 /**
 * Uploads the files in the $_FILES array
 *
 * Accepts an associative array as which can have the following parameters:
 *
 		<ul>
 		 	<li><strong>upload_path</strong>: the server path to upload the file</li>
 		 	<li><strong>override_post_params</strong>: determines whether post parameters (e.g. {$_FILES_key}_{param}) take precedence over parameters passed to the method</li>
 		 	<li><strong>file_name</strong>: the name of the file to change to</li>
 		 	<li><strong>overwrite</strong>: boolean value that determines whether to overwrite the file or create a new file which will append a number at the end</li>
 		 	<li><strong>xss_clean</strong>: boolean value that determines whether to try and run the xss_clean function on any images that are uploaded</li>
 		 	<li><strong>encrypt_name</strong>: boolean value that determines whether to encrypt the file name and make it unique</li>
 		 	<li><strong>create_thumb</strong>: image specific boolean value that determines whether to create a thumbnail image based on the original uploaded image</li>
 		 	<li><strong>thumb_marker</strong>: the default suffix to use on a generated thumbnail. The default is "_thumb"</li>
 		 	<li><strong>maintain_ratio</strong>:image specific boolean value that determines whether to maintain the aspect ratio of the image upon resize</li>
 		 	<li><strong>master_dim</strong>: image specific boolean value that determines which dimension should be used when resizing and maintaining the aspect ratio. Options are height, width, auto</li>
 		 	<li><strong>width</strong>: sets the width of the uploaded image</li>
 		 	<li><strong>height</strong>: sets the height of the uploaded image</li>
 		 	<li><strong>resize_and_crop</strong>: image specific boolean value that determines whether to both resize and crop the image to the specified height and width</li>
 		 </ul>
 *
 * @access	public
 * @param	array	upload parameters (optional)
 * @return	boolean
 */
 public function upload($params = array())
 {
     $this->CI->load->library('upload');
     $this->CI->load->library('image_lib');
     $this->CI->load->library('encrypt');
     $valid = array('upload_path' => '', 'file_name' => '', 'overwrite' => FALSE, 'xss_clean' => FALSE, 'encrypt_name' => FALSE, 'unzip' => FALSE, 'override_post_params' => FALSE, 'posted' => $_POST, 'create_thumb' => NULL, 'thumb_marker' => '_thumb', 'maintain_ratio' => NULL, 'master_dim' => NULL, 'width' => NULL, 'height' => NULL, 'resize_and_crop' => FALSE);
     // used later
     $has_empty_filename = empty($params['file_name']) ? TRUE : FALSE;
     // set defaults
     foreach ($valid as $param => $default) {
         $params[$param] = isset($params[$param]) ? $params[$param] : $default;
     }
     // upload the file
     foreach ($_FILES as $key => $file) {
         if ($file['error'] == 0) {
             $ext = end(explode('.', $file['name']));
             $field_name = current(explode('___', $key));
             // extract out multi file upload infor
             // loop through all the allowed file types that are accepted for the asset directory
             foreach ($this->dir_filetypes() as $dir => $types) {
                 $file_types = explode('|', strtolower($types));
                 if (in_array(strtolower($ext), $file_types)) {
                     $default_asset_dir = $dir;
                     break;
                 }
             }
             if (empty($default_asset_dir)) {
                 $this->_add_error(lang('upload_invalid_filetype'));
                 return FALSE;
             }
             $non_multi_key = current(explode('___', $key));
             $posted_filename = FALSE;
             // get params based on the posted variables
             if (empty($params['override_post_params'])) {
                 $posted = array();
                 foreach ($valid as $param => $default) {
                     if ($param != 'posted') {
                         $input_key = $non_multi_key . '_' . $param;
                         $input_key_arr = explode('--', $input_key);
                         $input_key = end($input_key_arr);
                         $field_name_arr = explode('--', $field_name);
                         $field_name = end($field_name_arr);
                         // decode encrypted file path values
                         if (isset($params['posted'][$input_key])) {
                             if ($input_key == $field_name . '_upload_path') {
                                 $posted['upload_path'] = $this->CI->encrypt->decode($params['posted'][$input_key]);
                                 foreach ($params['posted'] as $k => $p) {
                                     if (!is_array($p)) {
                                         $posted['upload_path'] = str_replace('{' . $k . '}', $p, $posted['upload_path']);
                                     }
                                 }
                                 // security check to make sure that no crazy paths are being generated
                                 $posted['upload_path'] = str_replace('..' . DIRECTORY_SEPARATOR, '', $posted['upload_path']);
                             } else {
                                 $posted[$param] = $params['posted'][$input_key];
                             }
                             if ($param == 'file_name') {
                                 $posted_filename = TRUE;
                             }
                         }
                     }
                 }
                 $params = array_merge($params, $posted);
                 unset($params['override_post_params'], $params['posted']);
             }
             $asset_dir = trim(str_replace(assets_server_path(), '', $params['upload_path']), '/');
             // set restrictions
             $params['max_size'] = $this->fuel->config('assets_upload_max_size');
             $params['max_width'] = $this->fuel->config('assets_upload_max_width');
             $params['max_height'] = $this->fuel->config('assets_upload_max_height');
             if ($this->dir_filetype($asset_dir)) {
                 $params['allowed_types'] = $this->dir_filetype($asset_dir);
             } else {
                 if ($this->dir_filetype($default_asset_dir)) {
                     $params['allowed_types'] = $this->dir_filetype($default_asset_dir);
                     $asset_dir = $default_asset_dir;
                 } else {
                     $params['allowed_types'] = 'jpg|jpeg|png|gif';
                     $asset_dir = $default_asset_dir;
                 }
             }
             // set the upload path
             if (empty($params['upload_path'])) {
                 $params['upload_path'] = !empty($params[$field_name . '_path']) ? $params[$field_name . '_path'] : assets_server_path() . $asset_dir . '/';
             }
             $params['remove_spaces'] = TRUE;
             // make directory if it doesn't exist and subfolder creation is allowed'
             if (!is_dir($params['upload_path']) and $this->fuel->config('assets_allow_subfolder_creation')) {
                 // will recursively create folder
                 @mkdir($params['upload_path'], 0777, TRUE);
                 if (!file_exists($params['upload_path'])) {
                     $this->_add_error(lang('upload_not_writable'));
                 } else {
                     chmodr($params['upload_path'], 0777);
                 }
             }
             // set file name
             if (!$posted_filename) {
                 if ($has_empty_filename and !empty($params[$field_name . '_file_name'])) {
                     $params['file_name'] = $params[$field_name . '_file_name'];
                 } else {
                     if ($has_empty_filename) {
                         $file_name = pathinfo($file['name'], PATHINFO_FILENAME);
                         $params['file_name'] = url_title($file_name, 'underscore', FALSE);
                     }
                 }
             }
             // set overwrite
             $params['overwrite'] = is_true_val($params['overwrite']);
             if (is_image_file($params['file_name']) and !empty($params['xss_clean'])) {
                 $tmp_file = file_get_contents($file['tmp_name']);
                 if (xss_clean($tmp_file, TRUE) === FALSE) {
                     $this->_add_error(lang('upload_invalid_filetype'));
                 }
             }
             // if errors, then we simply return FALSE at this point and don't continue any further processing'
             if ($this->has_errors()) {
                 return FALSE;
             }
             // UPLOAD!!!
             $this->CI->upload->initialize($params);
             if (!$this->CI->upload->do_upload($key)) {
                 $this->_add_error($this->CI->upload->display_errors('', ''));
             } else {
                 $this->_data[$key] = $this->CI->upload->data();
                 // set the file perm if necessary
                 if ($this->fuel->config('set_upload_file_perms') !== FALSE and function_exists('chmod') and is_integer($this->fuel->config('set_upload_file_perms'))) {
                     chmod($this->_data[$key]['full_path'], $this->fuel->config('set_upload_file_perms'));
                 }
             }
         }
     }
     // set maintain ration if it is set to maintain_ratio
     if (!empty($params['resize_method']) and $params['resize_method'] == 'maintain_ratio') {
         $params['maintain_ratio'] = TRUE;
     }
     // now loop through the uploaded files to do any further image processing
     foreach ($this->_data as $file) {
         if (is_image_file($file['file_name']) and (isset($params['create_thumb']) or isset($params['maintain_ratio']) or !empty($params['width']) or !empty($params['height']) or !empty($params['master_dim']) or !empty($params['resize_and_crop']) or !empty($params['resize_method']))) {
             $params['source_image'] = $file['full_path'];
             // cast
             $params['maintain_ratio'] = (bool) $params['maintain_ratio'];
             // to fix issues with resize and crop
             if (empty($params['create_thumb'])) {
                 $params['thumb_marker'] = '';
             }
             $this->CI->image_lib->initialize($params);
             // check for if they want just a resize or a resize AND crop
             if (!empty($params['resize_and_crop']) or !empty($params['resize_method']) and $params['resize_method'] == 'resize_and_crop') {
                 $resize = $this->CI->image_lib->resize_and_crop();
             } else {
                 $resize = $this->CI->image_lib->resize();
             }
             if (!$resize) {
                 $this->_add_error($this->CI->image_lib->display_errors());
             }
         } else {
             if (is_true_val($params['unzip']) and $file['file_ext'] == '.zip') {
                 // unzip the contents
                 $this->unzip($file['full_path']);
                 // then delete the zip file
                 $this->delete($file['full_path']);
             }
         }
     }
     if ($this->has_errors()) {
         return FALSE;
     }
     return TRUE;
 }
Пример #16
0
 /**
  * Displays the fields to edit a record (form view)
  *
  * @access	public
  * @param	int		The ID value of the record to edit
  * @param	string	The name of a field, or fields spearated by colon to display in the form (optional)
  * @param	string	Determines whether to redirect the page after save or not
  * @return	void
  */
 function edit($id = NULL, $field = NULL, $redirect = TRUE)
 {
     // check that the action even exists and if not, show a 404
     if (!$this->fuel->auth->module_has_action('save') and $this->displayonly === FALSE) {
         show_404();
     }
     // check permissions
     if (!$this->fuel->auth->has_permission($this->module_obj->permission, 'edit') and !$this->fuel->auth->has_permission($this->module_obj->permission, 'create')) {
         show_error(lang('error_no_permissions'));
     }
     $inline = $this->fuel->admin->is_inline();
     if ($this->input->post($this->model->key_field())) {
         if ($this->_process_edit($id) and !has_errors()) {
             if ($inline === TRUE) {
                 $url = fuel_uri($this->module_uri . '/inline_edit/' . $id . '/' . $field, TRUE);
             } else {
                 $url = fuel_uri($this->module_uri . '/edit/' . $id . '/' . $field, TRUE);
             }
             if ($redirect) {
                 if (!$this->fuel->admin->has_notification(Fuel_admin::NOTIFICATION_SUCCESS)) {
                     $this->fuel->admin->set_notification(lang('data_saved'), Fuel_admin::NOTIFICATION_SUCCESS);
                 }
                 redirect($url);
             }
         }
     }
     //$vars = $this->_form($id);
     $data = $this->_saved_data($id);
     $action = !empty($data[$this->model->key_field()]) ? 'edit' : 'create';
     // check model first for preview path method
     if (method_exists($this->model, 'preview_path')) {
         $this->preview_path = $this->model->preview_path($data, $this->preview_path);
     } else {
         // otherwise, substitute data values into preview path
         $this->preview_path = $this->module_obj->url($data);
     }
     $shell_vars = $this->_shell_vars($id, $action, $data);
     $form_vars = $this->_form_vars($id, $data, $field, $inline);
     $vars = array_merge($shell_vars, $form_vars);
     $vars['data'] = $data;
     $vars['action'] = $action;
     $vars['related_items'] = $this->model->related_items($data);
     // active or publish fields
     if (isset($data['published'])) {
         $vars['publish'] = (!empty($data['published']) and is_true_val($data['published'])) ? 'unpublish' : 'publish';
     }
     if (isset($data['active'])) {
         $vars['activate'] = (!empty($data['active']) and is_true_val($data['active'])) ? 'deactivate' : 'activate';
     }
     if (!empty($field)) {
         $this->fuel->admin->set_display_mode(Fuel_admin::DISPLAY_COMPACT_NO_ACTION);
     } else {
         if ($inline === TRUE) {
             $this->fuel->admin->set_display_mode(Fuel_admin::DISPLAY_COMPACT);
         }
     }
     $crumbs = array($this->module_uri => $this->module_name);
     if (!empty($data[$this->display_field])) {
         $crumbs[''] = character_limiter(strip_tags($data[$this->display_field]), 50);
     }
     $this->fuel->admin->set_titlebar($crumbs);
     $vars['actions'] = $this->load->module_view(FUEL_FOLDER, '_blocks/module_create_edit_actions', $vars, TRUE);
     $this->fuel->admin->render($this->views['create_edit'], $vars, '', FUEL_FOLDER);
     // do this after rendering so it doesn't render current page'
     if (!empty($data[$this->display_field]) and $inline !== TRUE) {
         $this->fuel->admin->add_recent_page($this->uri->uri_string(), $this->module_name . ': ' . $data[$this->display_field], $this->module);
     }
 }
Пример #17
0
 function get_allow_comments()
 {
     $CI =& get_instance();
     if (is_null($this->props['allow_comments'])) {
         return is_true_val($this->_CI->fuel_blog->settings('allow_comments'));
     } else {
         return is_true_val($this->props['allow_comments']);
     }
 }
Пример #18
0
 /**
  * Uploads a static'navigation structure which is most like the <span class="file">fuel/application/views/_variables/nav.php</span> file
  *
  * @access	public
  * @param	array	config preferences (optional)
  * @return	boolean
  */
 public function upload($params = array())
 {
     $this->CI->load->library('menu');
     $this->CI->load->helper('file');
     $this->CI->load->helper('security');
     $valid = array('file_path' => APPPATH . 'views/_variables/nav.php', 'group_id' => 'main', 'var' => 'nav', 'clear_first' => TRUE, 'language' => 'english');
     if (!is_array($params)) {
         $this->CI->load->helper('array');
         $params = parse_string_to_array($params);
     }
     $p = array();
     foreach ($valid as $param => $default) {
         $p[$param] = isset($params[$param]) ? $params[$param] : $default;
     }
     // no longer needed
     unset($params);
     // extract out params to make it easier below
     extract($p);
     $error = FALSE;
     // read in the file so we can filter it
     $file = read_file($file_path);
     if (empty($file)) {
         return FALSE;
     }
     // strip any php tags
     $file = str_replace('<?php', '', $file);
     // run xss_clean on it
     $file = xss_clean($file);
     // now evaluate the string to get the nav array
     @eval($file);
     if (!empty(${$var})) {
         $nav = $this->CI->menu->normalize_items(${$var});
         if (is_true_val($clear_first)) {
             $this->model()->delete(array('group_id' => $group_id));
         }
         // save navigation group
         $group = $this->group($group_id);
         // set default navigation group if it doesn't exist'
         if (!isset($group->id)) {
             $group->name = 'main';
             $id = $group->save();
             $group_id = $group->id;
         }
         // convert string ids to numbers so we can save... must start at last id in db
         $ids = array();
         $i = $this->model()->max_id() + 1;
         foreach ($nav as $key => $item) {
             // if the id is empty then we assume it is the homepage
             if (empty($item['id'])) {
                 $item['id'] = 'home';
                 $nav[$key]['id'] = 'home';
             }
             $ids[$item['id']] = $i;
             $i++;
         }
         // now loop through and save
         $cnt = 0;
         foreach ($nav as $key => $item) {
             $save = array();
             $save['id'] = $ids[$item['id']];
             $save['nav_key'] = empty($key) ? 'home' : $key;
             $save['group_id'] = $group_id;
             $save['label'] = $item['label'];
             $save['parent_id'] = empty($ids[$item['parent_id']]) ? 0 : $ids[$item['parent_id']];
             $save['location'] = $item['location'];
             $save['selected'] = !empty($item['selected']) ? $item['selected'] : $item['active'];
             // must be different because "active" has special meaning in FUEL
             $save['language'] = !empty($item['language']) ? $item['language'] : $language;
             // fix for homepage links
             if (empty($save['selected']) and $save['nav_key'] == 'home') {
                 $save['selected'] = 'home$';
             }
             $save['hidden'] = is_true_val($item['hidden']) ? 'yes' : 'no';
             $save['published'] = 'yes';
             $save['precedence'] = !empty($item['precedence']) ? $item['precedence'] : $cnt;
             if (is_array($item['attributes'])) {
                 $attr = '';
                 foreach ($item['attributes'] as $key => $val) {
                     $attr .= $key . '="' . $val . '" ';
                 }
                 $attr = trim($attr);
             } else {
                 $save['attributes'] = $item['attributes'];
             }
             if (!$this->model()->save($save)) {
                 $error = TRUE;
                 break;
             }
             $cnt++;
         }
     } else {
         $error = TRUE;
     }
     return !$error;
 }
Пример #19
0
 function get_allow_comments()
 {
     if (is_null($this->_fields['allow_comments'])) {
         return is_true_val($this->_CI->fuel->blog->config('allow_comments'));
     } else {
         return is_true_val($this->_fields['allow_comments']);
     }
 }
Пример #20
0
/**
 * Sets a variable marker (pencil icon) in a page which can be used for inline editing.
 * 
 * The <dfn>id</dfn> parameter is the unique id that will be used to query the module. You can also pass an id value
 * and a field like so <dfn>id|field</dfn>. This will display only a certain field instead of the entire module form.
 * Alternatively, you can now also just pass the entire object and it will generate the id, label, module and published values automatically.
 * The <dfn>is_published</dfn> parameter specifies whether to indicate with the pencil icon that the item is active/published
 * The <dfn>label</dfn> parameter specifies the label to display next to the pencil icon.
 * The <dfn>xOffset</dfn> and <dfn>yOffset</dfn> are pixel values to offset the pencil icon.
 *
 * @access	public
 * @param	mixed
 * @param	string
 * @param	string
 * @param	boolean
 * @param	int
 * @param	int
 * @return	string
 */
function fuel_edit($id, $label = NULL, $module = 'pagevariables', $is_published = TRUE, $xoffset = NULL, $yoffset = NULL)
{
    $CI =& get_instance();
    $page = $CI->fuel->pages->active();
    if (empty($page)) {
        $page = $CI->fuel->pages->create();
    }
    if (!empty($id) and (!defined('FUELIFY') or defined('FUELIFY') and FUELIFY !== FALSE)) {
        if (is_object($id) and is_a($id, 'Data_record') and isset($id->id)) {
            $ref_id = $id->id;
            if (empty($module) or $module == 'pagevariables') {
                $module = $id->parent_model()->table_name();
                $tables = array_flip($id->parent_model()->tables());
                if (isset($tables[$module])) {
                    $module = $tables[$module];
                }
                unset($tables);
                $mod = $CI->fuel->modules->get($module, FALSE);
                if (!empty($mod)) {
                    $module = $mod->info('module_uri');
                }
            }
            if (empty($label)) {
                $label = lang('action_edit') . ': ';
                if (isset($id->title)) {
                    $label .= $id->title;
                } else {
                    if ($id->name) {
                        $label .= $id->name;
                    }
                }
            }
            if (isset($id->published)) {
                $is_published = is_true_val($id->published);
            } else {
                if (isset($id->active)) {
                    $is_published = is_true_val($id->active);
                }
            }
        } else {
            $ref_id = $id;
        }
        $marker['id'] = $ref_id;
        $marker['label'] = $label;
        $marker['module'] = $module;
        $marker['published'] = $is_published;
        $marker['xoffset'] = $xoffset;
        $marker['yoffset'] = $yoffset;
        $key = $page->add_marker($marker);
        return '<!--' . $key . '-->';
    }
    return '';
}
Пример #21
0
 public function _form($id = NULL)
 {
     $this->load->library('form_builder');
     $this->form_builder->load_custom_fields(APPPATH . 'config/custom_fields.php');
     $this->fuel->load_model('fuel_navigation');
     $this->load->helper('file');
     $this->js_controller_params['method'] = 'add_edit';
     // get saved data
     $saved = array();
     if (!empty($id)) {
         $saved = $this->model->find_one_array(array($this->model->table_name() . '.id' => $id));
         if (empty($saved)) {
             show_404();
         }
     }
     if ($this->input->get('lang')) {
         $saved['language'] = $this->input->get('lang', TRUE);
     }
     //$this->model->add_required('location');
     // create fields... start with the table info and go from there
     $fields = $this->model->form_fields($saved);
     $common_fields = $this->_common_fields($saved);
     $fields = array_merge($fields, $common_fields);
     if (!$this->fuel->auth->has_permission($this->permission, 'publish')) {
         unset($fields['published']);
     }
     // layout name tweaks
     if ($this->input->post('layout')) {
         $layout = $this->input->post('layout', TRUE);
     } else {
         if (!empty($saved['layout'])) {
             $layout = $saved['layout'];
         } else {
             $layout = $this->fuel->layouts->default_layout;
         }
     }
     // num uri params
     $fields['cache']['class'] = 'advanced';
     $field_values = !empty($_POST) ? $_POST : $saved;
     $field_values['layout'] = $layout;
     // substitute data values into preview path
     $this->preview_path = $this->module_obj->url($field_values);
     $sort_arr = empty($fields['navigation_label']) ? array('location', 'layout', 'published', 'cache') : array('location', 'layout', 'navigation_label', 'published', 'cache');
     // create page form fields
     $this->form_builder->set_validator($this->model->get_validation());
     $this->form_builder->question_keys = array();
     $this->form_builder->submit_value = NULL;
     $this->form_builder->use_form_tag = FALSE;
     $this->form_builder->set_field_order($sort_arr);
     $this->form_builder->display_errors = FALSE;
     $this->form_builder->show_required = FALSE;
     // set this one to FALSE because the layout selection will execute the js again
     $this->form_builder->auto_execute_js = FALSE;
     $this->form_builder->set_fields($fields);
     $this->form_builder->set_field_values($field_values);
     $vars['form'] = $this->form_builder->render();
     // clear the values hear to prevent issues in subsequent calls
     $this->form_builder->clear();
     $this->form_builder->submit_value = lang('btn_save');
     $this->form_builder->cancel_value = lang('btn_cancel');
     /*****************************************************************************
     		// check for twin view file, controller and extra routing to generate warnings
     		******************************************************************************/
     $view_twin = NULL;
     $import_view = FALSE;
     $routes = array();
     $uses_controller = FALSE;
     if (!empty($field_values['location'])) {
         $view_twin = APPPATH . 'views/' . $field_values['location'] . EXT;
         $import_view = FALSE;
         if (file_exists($view_twin)) {
             $view_twin_info = get_file_info($view_twin);
             if (!empty($saved)) {
                 $tz = date('T');
                 if ($view_twin_info['date'] > strtotime($saved['last_modified'] . ' ' . $tz) or $saved['last_modified'] == $saved['date_added']) {
                     $import_view = TRUE;
                 }
             }
         }
         // check if there is routing for this page and display warning
         require APPPATH . 'config/routes.php';
         $page_vars = array();
         foreach ($route as $key => $val) {
             // Convert wild-cards to RegEx
             $key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key));
             // Does the RegEx match?
             if (preg_match('#^' . $key . '$#', $field_values['location'])) {
                 $routes[] = $key;
             }
         }
         // check if a controller and method already exists
         $segments = explode('/', $field_values['location']);
         if (file_exists(APPPATH . 'controllers/' . $segments[0] . EXT)) {
             require_once APPPATH . 'controllers/' . $segments[0] . EXT;
             $controller = $segments[0];
             $method = !empty($segments[1]) ? $segments[1] : 'index';
             $class_methods = get_class_methods($segments[0]);
             if (in_array($method, $class_methods)) {
                 $uses_controller = TRUE;
             }
         }
         if (file_exists(APPPATH . 'controllers/' . $segments[0])) {
             // Is the controller in a sub-folder?
             if (is_dir(APPPATH . 'controllers/' . $segments[0])) {
                 // Set the directory and remove it from the segment array
                 if (count($segments) > 1) {
                     // Does the requested controller exist in the sub-folder?
                     if (file_exists(APPPATH . 'controllers/' . $segments[0] . '/' . $segments[1] . EXT)) {
                         require_once APPPATH . 'controllers/' . $segments[0] . '/' . $segments[1] . EXT;
                         $controller = $segments[1];
                         $method = !empty($segments[2]) ? $segments[2] : 'index';
                         $class_methods = get_class_methods($segments[1]);
                         if (in_array($method, $class_methods)) {
                             $uses_controller = TRUE;
                         }
                     }
                 } else {
                     if (file_exists(APPPATH . 'controllers/' . $segments[0] . $route['default_controller'] . EXT)) {
                         require_once APPPATH . 'controllers/' . $segments[0] . $route['default_controller'] . EXT;
                         $class_methods = get_class_methods($route['default_controller']);
                         if (in_array('index', $class_methods)) {
                             $uses_controller = TRUE;
                         }
                     }
                 }
             }
         }
     }
     $page_vars = array();
     if (!empty($_POST)) {
         $page_vars = array();
         foreach ($_POST as $key => $val) {
             $key = end(explode('--', $key));
             $page_vars[$key] = $val;
         }
     }
     if (!empty($id)) {
         $lang = $this->input->get('lang');
         if (!$lang) {
             $lang = $this->fuel->language->default_option();
         }
         $page_vars = array_merge($this->fuel_pagevariables_model->find_all_by_page_id($id, $lang), $page_vars);
         // the following will pre-populate fields of a different language to the default values
         if (empty($page_vars) and $this->fuel->language->has_multiple() and $lang != $this->fuel->language->default_option()) {
             $page_vars = $this->fuel_pagevariables_model->find_all_by_page_id($id, $this->fuel->language->default_option());
         }
     }
     // page variables
     $layout = $this->fuel->layouts->get($layout);
     if (!empty($layout)) {
         $layout->set_field_values($page_vars);
         $fields = $layout->fields();
         $import_field = $layout->import_field();
     }
     if (!empty($import_field)) {
         $this->js_controller_params['import_field'] = $import_field;
     }
     // since the form builder is cleared above, we'll add in a script tag to make sure that the initialize code gets executed again
     $this->form_builder->add_js('<script></script>');
     $this->form_builder->id = 'layout_fields';
     $this->form_builder->name_prefix = 'vars';
     $this->form_builder->set_fields($fields);
     $this->form_builder->set_field_values($page_vars);
     $conflict = $this->_has_conflict($fields);
     if (!empty($conflict)) {
         $vars['layout_fields'] = $conflict;
     } else {
         //$vars['layout_fields'] = '';
         $vars['layout_fields'] = $this->form_builder->render();
     }
     // other variables
     $vars['id'] = $id;
     $vars['data'] = $saved;
     $vars['action'] = !empty($saved['id']) ? 'edit' : 'create';
     $action_uri = $vars['action'] . '/' . $id . '/';
     $vars['form_action'] = $this->fuel->admin->is_inline() ? $this->module_uri . '/inline_' . $action_uri : $this->module_uri . '/' . $action_uri;
     $vars['versions'] = $this->fuel_archives_model->options_list($id, $this->model->table_name());
     $vars['publish'] = !empty($saved['published']) && is_true_val($saved['published']) ? 'Unpublish' : 'Publish';
     $vars['import_view'] = $import_view;
     $vars['view_twin'] = $view_twin;
     $vars['routes'] = $routes;
     $vars['uses_controller'] = $uses_controller;
     $vars['others'] = $this->model->get_others('location', $id);
     if (!empty($saved['location'])) {
         $related = $saved;
         $related['page_vars'] = $page_vars;
         $vars['related_items'] = $this->model->related_items($related);
     }
     $actions = $this->load->module_view(FUEL_FOLDER, '_blocks/module_create_edit_actions', $vars, TRUE);
     $vars['actions'] = $actions;
     $vars['error'] = $this->model->get_errors();
     if (!empty($saved['last_modified'])) {
         $vars['last_updated'] = lang('pages_last_updated_by', english_date($vars['data']['last_modified'], true), $vars['data']['email']);
     }
     $notifications = $this->load->module_view(FUEL_FOLDER, '_blocks/notifications', $vars, TRUE);
     $vars['notifications'] = $notifications;
     if ($vars['action'] == 'edit') {
         $crumbs = array($this->module_uri => $this->module_name, '' => character_limiter(strip_tags($vars['data'][$this->display_field]), 50));
     } else {
         $crumbs = array($this->module_uri => $this->module_name, '' => lang('action_create'));
     }
     $this->fuel->admin->set_titlebar($crumbs);
     // do this after rendering so it doesn't render current page'
     if (!empty($vars['data'][$this->display_field])) {
         $this->fuel->admin->add_recent_page($this->uri->uri_string(), $vars['data'][$this->display_field], $this->module);
     }
     return $vars;
 }
Пример #22
0
 private function _assign_location()
 {
     $default_home = $this->_CI->config->item('default_home_view', 'fuel');
     // if a location is provided in the init config, then use it instead of the uri segments and go no further
     if ($this->location == 'fuel_router') {
         $this->location = $default_home;
     }
     $page_data = array('id' => NULL, 'cache' => NULL, 'published' => NULL, 'layout');
     $this->_page_data = $page_data;
     if ($this->render_mode == 'views') {
         return;
     }
     $segments = $this->_CI->uri->rsegment_array();
     // in case a Matchbox module has a module name the same (like news...)
     if ($segments[count($segments)] == 'index') {
         array_pop($segments);
     }
     // MUST LOAD AFTER THE ABOVE SO THAT IT DOESN'T THROW A DB ERROR WHEN A DB ISN'T BEING USED
     // get current page segments so that we can properly iterate through to determine what the actual location
     // is and what are params being passed to the location
     $this->_CI->load->module_model(FUEL_FOLDER, 'pages_model');
     if (count($this->_CI->uri->segment_array()) == 0) {
         $page_data = $this->_CI->pages_model->find_by_location($default_home, $this->_only_published);
         $location = $default_home;
     } else {
         // if $location = xxx/yyy/zzz/, check first to see if /xxx/yyy/zzz exists in the DB, then reduce segments to xxx/yyy,
         // xxx... until one is found in the DB. If only xxx is found in the database yyy and zzz will be treated as parameters
         while (count($segments) >= 1) {
             if (count($this->_segments) > $this->_CI->config->item('max_page_params', 'fuel')) {
                 break;
             }
             $location = implode('/', $segments);
             // if a prefix for the location is provided in the config, change the location value accordingly so we can find it
             $prefix = $this->_CI->config->item('page_uri_prefix', 'fuel');
             if ($prefix) {
                 if (strpos($location, $prefix) === 0) {
                     $location = substr($location, strlen($prefix));
                 }
                 $page_data = $this->_CI->pages_model->find_by_location($location, $this->_only_published);
             } else {
                 $page_data = $this->_CI->pages_model->find_by_location($location, $this->_only_published);
             }
             if (!empty($page_data)) {
                 break;
             }
             $this->_segments[] = array_pop($segments);
         }
     }
     if (!empty($page_data)) {
         $this->id = $page_data['id'];
         $this->location = $page_data['location'];
         $this->layout = $page_data['layout'];
         $this->is_published = is_true_val($page_data['published']);
         $this->is_cached = is_true_val($page_data['cache']);
         $this->_segments = $segments;
         $this->_page_data = $page_data;
     }
     // assign page segment values
     $this->_segments = array_reverse($this->_segments);
 }
 /**
  * Casts and unserializes if necessary a single variable to it's proper type (int, boolean, array)
  *
  * @access	protected
  * @param	mixed The data to be cast
  * @return	mixed
  */
 public function cast($val, $type)
 {
     $return = '';
     switch ($type) {
         case 'int':
             $return = (int) $val;
             break;
         case 'boolean':
             $return = is_true_val($val);
             break;
         case 'array':
         case 'multi':
             if (is_string($val)) {
                 // for legacy versions
                 if (is_serialized_str($val)) {
                     $return = unserialize($val);
                 } else {
                     if ($json = json_decode($val, TRUE)) {
                         $return = $json;
                     }
                 }
             } else {
                 if (is_array($val)) {
                     $return = $val;
                 }
             }
             if (empty($return)) {
                 $return = array();
             }
             break;
         default:
             $return = $val;
     }
     return $return;
 }
Пример #24
0
 public function download()
 {
     if (!empty($_POST['group_id'])) {
         $this->load->helper('download');
         $where['group_id'] = $this->input->post('group_id', TRUE);
         $where['published'] = 'yes';
         $data = $this->model->find_all_array_assoc('nav_key', $where, 'parent_id asc, precedence asc');
         $var = '$nav';
         $str = "<?php \n";
         foreach ($data as $key => $val) {
             // add label
             $str .= $var . "['" . $key . "'] = array('label' => '" . $val['label'] . "', ";
             // add location
             if ($key != $val['location']) {
                 $str .= "'location' => '" . $val['location'] . "', ";
             }
             if (!empty($val['parent_id'])) {
                 $parent_data = $this->model->find_one_array(array('id' => $val['parent_id']));
                 $str .= "'parent_id' => '" . $parent_data['nav_key'] . "', ";
             }
             if (is_true_val($val['hidden'])) {
                 $str .= "'hidden' => 'yes', ";
             }
             if (!empty($val['attributes'])) {
                 $str .= "'attributes' => '" . $val['attributes'] . "', ";
             }
             if (!empty($val['selected'])) {
                 $str .= "'selected' => '" . $val['selected'] . "', ";
             }
             $str = substr($str, 0, -2);
             $str .= ");\n";
         }
         force_download('nav.php', $str);
     }
 }
Пример #25
0
	<?php 
echo $notifications;
?>
</div>
<div id="main_content">
	<div id="notification_extra" class="notification">
		<?php 
if (!empty($data['published']) && !is_true_val($data['published'])) {
    ?>
				<div class="warning ico ico_warn"><?php 
    echo lang('warn_not_published');
    ?>
</div>
		<?php 
} else {
    if (!empty($data['active']) && !is_true_val($data['active'])) {
        ?>
			<div class="warning ico ico_warn"><?php 
        echo lang('warn_not_active', strtolower(substr($this->module_name, 0, -1)));
        ?>
</div>
		<?php 
    }
}
?>
	</div>
	
	<?php 
if (!empty($warning_window)) {
    ?>
		<div class="warning jqmWindow jqmWindowShow" id="warning_window">
Пример #26
0
 /**
  * Returns whether the page should be cached
  *
  * @access	public
  * @param	string	The output of the page
  * @return	boolean
  */
 public function is_cached()
 {
     return is_true_val($this->is_cached);
 }
Пример #27
0
    function _form($id = NULL, $fields = NULL, $log_to_recent = TRUE, $display_normal_submit_cancel = TRUE)
    {
        $this->load->library('form_builder');
        $this->load->module_model(FUEL_FOLDER, 'navigation_model');
        $this->load->helper('file');
        $this->js_controller_params['method'] = 'add_edit';
        // get saved data
        $saved = array();
        if (!empty($id)) {
            $saved = $this->model->find_one_array(array($this->model->table_name() . '.id' => $id));
            if (empty($saved)) {
                show_404();
            }
        }
        $this->model->add_required('location');
        // create fields... start with the table info and go from there
        $fields = $this->model->form_fields();
        if (!$this->fuel_auth->has_permission($this->permission, 'publish')) {
            unset($fields['published']);
        }
        // layout name tweaks
        if ($this->input->post('layout')) {
            $layout = $this->input->post('layout');
        } else {
            if (!empty($saved['layout'])) {
                $layout = $saved['layout'];
            } else {
                $layout = $this->fuel_layouts->default_layout;
            }
        }
        $fields['layout']['type'] = 'select';
        $fields['layout']['options'] = $this->fuel_layouts->layouts_list();
        $fields['layout']['value'] = $layout;
        // num uri params
        $fields['cache']['class'] = 'advanced';
        // easy add for navigation
        if (empty($id)) {
            $fields['navigation_label'] = array('comment' => 'This field lets you quickly add a navigation item for this page. 
		It only allows you to create a navigation item during page creation. To edit the navigation item, you must click on the
		\'Navigation\' link on the left, find the navigation item you want to change and click on the edit link.');
        }
        $field_values = !empty($_POST) ? $_POST : $saved;
        if (!empty($field_values['location'])) {
            $this->preview_path = $field_values['location'];
        }
        $sort_arr = empty($fields['navigation_label']) ? array('location', 'layout', 'published', 'cache') : array('location', 'layout', 'navigation_label', 'published', 'cache');
        // not inline edited
        if (!$display_normal_submit_cancel) {
            $this->form_builder->submit_value = NULL;
            $this->form_builder->cancel_value = NULL;
            //$this->form_builder->name_array = '__fuel_field__'.$this->module_name.'_'.$id;
            $fields['__fuel_inline_action__'] = array('type' => 'hidden');
            $fields['__fuel_inline_action__']['class'] = '__fuel_inline_action__';
            $fields['__fuel_inline_action__']['value'] = empty($id) ? 'create' : 'edit';
            $fields['__fuel_module__'] = array('type' => 'hidden');
            $fields['__fuel_module__']['value'] = $this->module;
            $fields['__fuel_module__']['class'] = '__fuel_module__';
            $this->form_builder->name_prefix = '__fuel_field__' . $this->module . '_' . (empty($id) ? 'create' : $id);
            $this->form_builder->css_class = 'inline_form';
        }
        //$this->form_builder->hidden = (array) $this->model->key_field();
        $this->form_builder->question_keys = array();
        $this->form_builder->use_form_tag = FALSE;
        $this->form_builder->set_fields($fields);
        $this->form_builder->display_errors = FALSE;
        $this->form_builder->set_field_values($field_values);
        $this->form_builder->displayonly = $this->displayonly;
        // create page form fields
        $this->form_builder->form->validator =& $this->page->validator;
        $this->form_builder->submit_value = NULL;
        $this->form_builder->use_form_tag = FALSE;
        $this->form_builder->set_fields($fields);
        $this->form_builder->set_field_order($sort_arr);
        $this->form_builder->display_errors = FALSE;
        $this->form_builder->show_required = FALSE;
        $this->form_builder->set_field_values($field_values);
        $vars['form'] = $this->form_builder->render();
        $this->form_builder->submit_value = lang('btn_save');
        $this->form_builder->cancel_value = lang('btn_cancel');
        // page variables
        $fields = $this->fuel_layouts->fields($layout, empty($id));
        /*****************************************************************************
        		// check for twin view file, controller and extra routing to generate warnings
        		******************************************************************************/
        $view_twin = NULL;
        $import_view = FALSE;
        $routes = array();
        $uses_controller = FALSE;
        if (!empty($field_values['location'])) {
            $view_twin = APPPATH . 'views/' . $field_values['location'] . EXT;
            $import_view = FALSE;
            if (file_exists($view_twin)) {
                $view_twin_info = get_file_info($view_twin);
                if (!empty($saved)) {
                    $tz = date('T');
                    if ($view_twin_info['date'] > strtotime($saved['last_modified'] . ' ' . $tz) or $saved['last_modified'] == $saved['date_added']) {
                        $import_view = TRUE;
                    }
                }
            }
            // check if there is routing for this page and display warning
            require APPPATH . 'config/routes.php';
            $page_vars = array();
            foreach ($route as $key => $val) {
                // Convert wild-cards to RegEx
                $key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key));
                // Does the RegEx match?
                if (preg_match('#^' . $key . '$#', $field_values['location'])) {
                    $routes[] = $key;
                }
            }
            // check if a controller and method already exists
            $segments = explode('/', $field_values['location']);
            if (file_exists(APPPATH . 'controllers/' . $segments[0] . EXT)) {
                require_once APPPATH . 'controllers/' . $segments[0] . EXT;
                $controller = $segments[0];
                $method = !empty($segments[1]) ? $segments[1] : 'index';
                $class_methods = get_class_methods($segments[0]);
                if (in_array($method, $class_methods)) {
                    $uses_controller = TRUE;
                }
            }
            if (file_exists(APPPATH . 'controllers/' . $segments[0])) {
                // Is the controller in a sub-folder?
                if (is_dir(APPPATH . 'controllers/' . $segments[0])) {
                    // Set the directory and remove it from the segment array
                    if (count($segments) > 1) {
                        // Does the requested controller exist in the sub-folder?
                        if (file_exists(APPPATH . 'controllers/' . $segments[0] . '/' . $segments[1] . EXT)) {
                            require_once APPPATH . 'controllers/' . $segments[0] . '/' . $segments[1] . EXT;
                            $controller = $segments[1];
                            $method = !empty($segments[2]) ? $segments[2] : 'index';
                            $class_methods = get_class_methods($segments[1]);
                            if (in_array($method, $class_methods)) {
                                $uses_controller = TRUE;
                            }
                        }
                    } else {
                        if (file_exists(APPPATH . 'controllers/' . $segments[0] . $route['default_controller'] . EXT)) {
                            require_once APPPATH . 'controllers/' . $segments[0] . $route['default_controller'] . EXT;
                            $class_methods = get_class_methods($route['default_controller']);
                            if (in_array('index', $class_methods)) {
                                $uses_controller = TRUE;
                            }
                        }
                    }
                }
            }
        }
        $this->form_builder->name_prefix = 'vars';
        $this->form_builder->set_fields($fields);
        $page_vars = array();
        if (!empty($id)) {
            $page_vars = $this->pagevariables_model->find_all_by_page_id($id);
        } else {
            if (!empty($_POST)) {
                $page_vars = array();
                foreach ($_POST as $key => $val) {
                    $key = end(explode('--', $key));
                    $page_vars[$key] = $val;
                }
            }
        }
        $this->form_builder->set_field_values($page_vars);
        $conflict = $this->_has_conflict($fields);
        $vars['layout_fields'] = !empty($conflict) ? $conflict : $this->form_builder->render();
        // other variables
        $vars['id'] = $id;
        $vars['data'] = $saved;
        $vars['action'] = !empty($saved['id']) ? 'edit' : 'create';
        $vars['versions'] = $this->archives_model->options_list($id, $this->model->table_name());
        $vars['publish'] = !empty($saved['published']) && is_true_val($saved['published']) ? 'Unpublish' : 'Publish';
        $vars['import_view'] = $import_view;
        $vars['view_twin'] = $view_twin;
        $vars['routes'] = $routes;
        $vars['uses_controller'] = $uses_controller;
        $vars['others'] = $this->model->get_others('location', $id);
        if (!empty($saved['location'])) {
            $vars['page_navs'] = $this->navigation_model->find_by_location($saved['location'], FALSE);
        }
        $actions = $this->load->view('_blocks/module_create_edit_actions', $vars, TRUE);
        $vars['actions'] = $actions;
        $vars['error'] = $this->model->get_errors();
        $notifications = $this->load->view('_blocks/notifications', $vars, TRUE);
        $vars['notifications'] = $notifications;
        // do this after rendering so it doesn't render current page'
        if (!empty($vars['data'][$this->display_field])) {
            $this->_recent_pages($this->uri->uri_string(), $vars['data'][$this->display_field], $this->module);
        }
        return $vars;
    }
 public function is_spam()
 {
     return is_true_val($this->is_spam);
 }
Пример #29
0
<?php

$this->load->view('_blocks/related_items');
?>

<div id="notification_extra" class="notification">
	<?php 
if (!empty($data['published']) && !is_true_val($data['published'])) {
    ?>
			<div class="warning ico ico_warn"><?php 
    echo lang('pages_not_published');
    ?>
</div>
	<?php 
}
?>
	

	<?php 
if (!empty($routes)) {
    ?>
	<div class="warning ico ico_warn">
		<?php 
    echo lang('page_route_warning', APPPATH . 'config/routes.php');
    ?>
		<?php 
    foreach ($routes as $val) {
        ?>
			<ul>
				<li><?php 
        echo $val;
Пример #30
0
<div id="notification_extra" class="notification">
	<?php 
if (isset($this->model) and method_exists($this->model, 'notification') and $this->model->notification($data)) {
    ?>
		<div class="warning ico ico_warn"><?php 
    echo $this->model->notification($data);
    ?>
</div>
	<?php 
} elseif (isset($data['published']) and !is_true_val($data['published'])) {
    ?>
			<div class="warning ico ico_warn"><?php 
    echo lang('warn_not_published');
    ?>
</div>
	<?php 
} else {
    if (isset($data['active']) and !is_true_val($data['active']) and isset($this->model)) {
        ?>
		<div class="warning ico ico_warn"><?php 
        echo lang('warn_not_active', $this->model->singular_name());
        ?>
</div>
	<?php 
    }
}
?>
</div>