Skip to content

Commit

Permalink
Merge branch 'release/1.0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
David McReynolds committed Feb 3, 2014
2 parents def05c8 + 9bfe7fc commit 3daf293
Show file tree
Hide file tree
Showing 38 changed files with 404 additions and 378 deletions.
4 changes: 2 additions & 2 deletions fuel/application/views/_layouts/sitemap_xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
<?php foreach($nav as $uri=>$page) : ?>
<?php if(is_array($page) AND isset($page['location']) AND $page['location'] != 'sitemap.xml' AND !isset($used[$page['location']])): ?>
<url>
<loc><?=site_url($page['location'])?></loc>
<loc><![CDATA[<?=site_url($page['location'])?>]]></loc>
<?php if (!empty($page['last_modified'])) : ?><lastmod><?=$page['last_modified']?></lastmod><?php endif; ?>
<changefreq><?=fuel_var('frequency', $default_frequency)?></changefreq>
</url>
<?php $used[$page['location']] = $page['location']; ?>
<?php elseif (is_string($page) AND !isset($used[$page])): ?>
<url>
<loc><?=site_url($page)?></loc>
<loc><![CDATA[<?=site_url($page)?>]]></loc>
<changefreq><?=fuel_var('frequency', $default_frequency)?></changefreq>
</url>
<?php $used[$page] = $page; ?>
Expand Down
4 changes: 2 additions & 2 deletions fuel/application/views/sitemap_xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
<?php foreach($nav as $uri=>$page) : ?>
<?php if(is_array($page) AND isset($page['location']) AND $page['location'] != 'sitemap.xml' AND !isset($used[$page['location']])): ?>
<url>
<loc><?=site_url($page['location'])?></loc>
<loc><![CDATA[<?=site_url($page['location'])?>]]></loc>
<?php if (!empty($page['last_modified'])) : ?><lastmod><?=$page['last_modified']?></lastmod><?php endif; ?>
<changefreq><?php if (!empty($page['frequency'])) : ?><?=$page['frequency']?><?php else: ?><?=$default_frequency?><?php endif; ?></changefreq>
</url>
<?php $used[$page['location']] = $page['location']; ?>
<?php elseif (is_string($page) AND !isset($used[$page])): ?>
<url>
<loc><?=site_url($page)?></loc>
<loc><![CDATA[<?=site_url($page)?>]]></loc>
<changefreq><?=$default_frequency?></changefreq>
</url>
<?php $used[$page] = $page; ?>
Expand Down
4 changes: 2 additions & 2 deletions fuel/modules/fuel/assets/js/fuel/custom_fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -665,9 +665,9 @@ fuel.fields.inline_edit_field = function(context){
if ($this.is('select') && $this.find('option').length == 0){
$this.hide();
}
if ($this.is('input, select')) $this.next('.btn_field').hide();
if ($this.is('input, select')) $this.parent().find('.edit_inline_button').hide();
} else {
$this.next('.btn_field').show();
$this.parent().find('.edit_inline_button').show();
}
}

Expand Down
2 changes: 1 addition & 1 deletion fuel/modules/fuel/config/fuel_constants.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
// INSTALL_ROOT is defined in the index.php bootstrap file
define('FUEL_VERSION', '1.0.3');
define('FUEL_VERSION', '1.0.4');
define('MODULES_FOLDER', '../modules');
define('FUEL_FOLDER', 'fuel');
define('MODULES_PATH', APPPATH.MODULES_FOLDER.'/');
Expand Down
6 changes: 3 additions & 3 deletions fuel/modules/fuel/controllers/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ protected function _process_create()
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'))
if (!$this->fuel->auth->module_has_action('save') AND $this->displayonly === FALSE)
{
show_404();
}
Expand Down Expand Up @@ -1205,9 +1205,9 @@ protected function _shell_vars($id = NULL, $action = 'create')

// other variables
$vars['id'] = $id;
$vars['versions'] = $this->fuel_archives_model->options_list($id, $this->model->table_name());
$vars['versions'] = ($this->displayonly === FALSE) ? $this->fuel_archives_model->options_list($id, $this->model->table_name()) : array();
$vars['others'] = $this->model->get_others($this->display_field, $id);
$vars['action'] = $action;
$vars['action'] = $action;

$vars['module'] = $this->module;
$vars['notifications'] = $this->load->module_view(FUEL_FOLDER, '_blocks/notifications', $vars, TRUE);
Expand Down
5 changes: 5 additions & 0 deletions fuel/modules/fuel/controllers/page_router.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public function _remap($method)
return;
}
}
else
{
$config['render_mode'] = 'cms';
$page = $this->fuel->pages->create($config);
}

$this->_remap_cms($page);
}
Expand Down
225 changes: 13 additions & 212 deletions fuel/modules/fuel/controllers/pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public function create($field = NULL, $redirect = TRUE)
// check that vars validated first to throw any errors before saving the record
if ($vars AND $id = $this->model->save($posted))
{
// run this again to include saved ID value
$vars['page_id'] = $id;
$vars = $layout->post_process_saved_values($vars);

if (empty($id) OR $this->model->get_errors())
{
Expand All @@ -75,7 +78,7 @@ public function create($field = NULL, $redirect = TRUE)

if ($this->_save_page_vars($id, $vars, $fields))
{
$this->_process_uploads();
$this->_process_uploads($vars);

$data = $this->model->find_one_array(array($this->model->table_name().'.id' => $id));

Expand Down Expand Up @@ -150,11 +153,12 @@ public function edit($id = NULL, $field = NULL, $redirect = TRUE)
// check that vars validated first to throw any errors before saving the record
if ($vars AND $this->model->save($posted))
{
$vars = $layout->post_process_saved_values($vars);

if ($this->_save_page_vars($id, $vars, $fields))
{

$this->_process_uploads();
$this->_process_uploads($vars);

$data = $this->model->find_one_array(array($this->model->table_name().'.id' => $id));

Expand Down Expand Up @@ -365,7 +369,9 @@ public function _form($id = NULL)
}
if (!empty($id))
{
$page_vars = array_merge($this->fuel_pagevariables_model->find_all_by_page_id($id), $page_vars);
$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);
}


Expand Down Expand Up @@ -668,213 +674,6 @@ public function _save_page_vars($id, $vars, $fields)
return TRUE;
}

public function XXX_save_page_vars($id, $vars)
{
//$vars = $this->input->post('vars');
$vars = array();
$vars['page_id'] = $id;

// process post vars... can't use an array because of file upload complications'
foreach($posted as $key => $val)
{
if (strncmp('vars--', $key, 6) === 0)
{
$new_key = end(explode('--', $key));
$vars[$new_key] = $val;
}
}


if (!empty($vars) && is_array($vars))
{

// run any form field post processing hooks
$layout = $this->fuel->layouts->get($this->input->post('layout', TRUE));
$fields = $layout->fields();

// add in block fields
foreach($fields as $key => $val)
{
// check blocks for post processing of variables
if (isset($val['type']) AND $val['type'] == 'block' AND isset($posted[$key]['block_name']))
{

$block_layout = $this->fuel->layouts->get($posted[$key]['block_name'], 'block');
if ($block_layout)
{
$block_fields = $block_layout->fields();
$fields = array_merge($fields, $block_fields);
}
}

// check for template layouts that may have nested fields... this is really ugly
if (!empty($val['fields']) AND is_array($val['fields']))
{
//$fields = array_merge($fields, $val['fields']);
foreach($val['fields'] as $k => $v)
{
if (isset($v['type']) AND $v['type'] == 'block' AND isset($posted[$key]))
{
if (is_array($posted[$key]) AND is_int(key($posted[$key])))
{
foreach($posted[$key] as $a => $b)
{
if (is_array($b))
{
foreach($b as $c => $d)
{
if (isset($d['block_name']))
{
$block_layout = $this->fuel->layouts->get($d['block_name'], 'block');
if ($block_layout)
{
$block_fields = $block_layout->fields();

// now switch out the key to allow it to trigger the post_process_callback...
foreach($block_fields as $e => $f)
{
$block_fields[$e]['subkey'] = $k;
$block_fields[$e]['key'] = $key;
}
$fields = array_merge($fields, $block_fields);
}
}
}
}
}
}
}
}
}
}

$this->form_builder->load_custom_fields(APPPATH.'config/custom_fields.php');
$this->form_builder->set_fields($fields);
$this->form_builder->set_field_values($vars);
$vars = $this->form_builder->post_process_field_values($vars);// manipulates the $_POST values directly

// run layout variable processing
$vars = $layout->process_saved_values($vars);

// validate before deleting
if (!$layout->validate($vars))
{
add_errors($layout->errors());
return FALSE;
}

$save = array();

$lang = $this->input->post('language', TRUE);

// clear out all other variables
$delete = array('page_id' => $id);
if ($this->input->post('language'))
{
$delete['language'] = $this->input->post('language', TRUE);
}


$this->fuel_pagevariables_model->delete($delete);
$pagevariable_table = $this->db->table_info($this->fuel_pagevariables_model->table_name());
$var_types = $pagevariable_table['type']['options'];
$page_variables_archive = array();

// field types that shouldn't be saved
$non_recordable_fields = array('section', 'copy', 'fieldset');

foreach($fields as $key => $val)
{
if (!isset($val['type']))
{
$val['type'] = 'string';
}

if (!in_array($val['type'], $non_recordable_fields))
{
$value = (!empty($vars[$key])) ? $vars[$key] : NULL;
if (is_array($value) OR $val['type'] == 'array' OR $val['type'] == 'multi')
{
//$value = array_map('zap_gremlins', $value);
//$value = serialize($value);
$val['type'] = 'array'; // force the type to be an array
}

if (!in_array($val['type'], $var_types)) $val['type'] = 'string';

$save = array('page_id' => $id, 'name' => $key, 'value' => $value, 'type' => $val['type']);
$where = array('page_id' => $id, 'name' => $key, 'language' => $lang);
if ($lang)
{
$save['language'] = $lang;
$where['language'] = $lang;
}
$where = (!empty($id)) ? $where : array();


if (!$this->fuel_pagevariables_model->save($save, $where))
{
add_error(lang('error_saving'));
return FALSE;
}
}
}

$page_variables_archive = $this->fuel_pagevariables_model->find_all_array(array('page_id' => $id));

// archive
$archive = $this->model->cleaned_data();
$archive[$this->model->key_field()] = $id;
$archive['variables'] = $page_variables_archive;

$this->model->archive($id, $archive);

// save to navigation if config allows it
if ($this->input->post('navigation_label')) {

$this->fuel->load_model('fuel_navigation');

$save = array();
$save['label'] = $this->input->post('navigation_label', TRUE);
$save['location'] = $this->input->post('location', TRUE);
$save['group_id'] = $this->fuel->config('auto_page_navigation_group_id');
$save['parent_id'] = 0;
$save['published'] = $this->input->post('published', TRUE);
if (!$this->fuel->auth->has_permission($this->permission, 'publish'))
{
$save['published'] = 'no';
}
// reset $where and create where clause to try and find an existing navigation item
$where = array();
$where['location'] = $save['location'];
$where['group_id'] = $save['group_id'];
$where['parent_id'] = $save['parent_id'];
$does_it_exist_already = $this->fuel_navigation_model->record_exists($where);
if (!$does_it_exist_already)
{
// determine parent based off of location
$location_arr = explode('/', $this->input->post('location', TRUE));
$parent_location = implode('/', array_slice($location_arr, 0, (count($location_arr) -1)));

if (!empty($parent_location)) $parent = $this->fuel_navigation_model->find_by_location($parent_location);
if (!empty($parent)) {
$save['parent_id'] = $parent['id'];
}
$this->fuel_navigation_model->add_validation('parent_id', array(&$this->fuel_navigation_model, 'no_location_and_parent_match'), lang('error_location_parents_match'), '{location}');
$this->fuel_navigation_model->save($save, array('location' => $this->input->post('location', TRUE), 'group_id' => $save['group_id']));
}
}
}
$this->fuel->admin->set_notification(lang('data_saved'), Fuel_admin::NOTIFICATION_SUCCESS);

// reset cache for that page only
if ($this->input->post('location'))
{
$this->fuel->cache->clear_page($this->input->post('location', TRUE));
}
return TRUE;
}

public function layout_fields($layout_name, $id = NULL, $lang = NULL, $vars = array())
{
// check to make sure there is no conflict between page columns and layout vars
Expand Down Expand Up @@ -1300,9 +1099,10 @@ protected function _process_upload_data($field_name, $uploaded_data, $posted)
// get the file name field
// if the file name field exists AND there is no specified hidden filename field to assign to it AND...
// the model does not have an array key field AND there is a key field value posted
if (isset($field_name) AND !is_array($this->model->key_field()) AND isset($posted[$this->model->key_field()]))
if (isset($field_name) AND !is_array($this->model->key_field()) AND isset($posted['page_id']))
{
$id = $posted[$this->model->key_field()];

$id = $posted['page_id'];
$where = array($this->fuel_pagevariables_model->table_name().'.page_id'=> $id, 'name' => $field_name);
$data = $this->fuel_pagevariables_model->find_one_array($where);

Expand All @@ -1326,6 +1126,7 @@ protected function _process_upload_data($field_name, $uploaded_data, $posted)
$save = TRUE;
}
}

if ($save)
{

Expand Down
5 changes: 5 additions & 0 deletions fuel/modules/fuel/core/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,11 @@ function get_vars($key = NULL, $scope = NULL)
{
return $this->_ci_cached_vars;
}

if (!isset($this->_ci_cached_vars[$scope]))
{
$this->_ci_cached_vars[$scope] = array();
}
return $this->_ci_cached_vars[$scope];
}

Expand Down
Loading

0 comments on commit 3daf293

Please sign in to comment.