当前位置: 首页>>代码示例>>PHP>>正文


PHP is_true_val函数代码示例

本文整理汇总了PHP中is_true_val函数的典型用法代码示例。如果您正苦于以下问题:PHP is_true_val函数的具体用法?PHP is_true_val怎么用?PHP is_true_val使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了is_true_val函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _remap_cms

 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);
 }
开发者ID:randombrad,项目名称:FUEL-CMS,代码行数:34,代码来源:page_router.php

示例2: cast

 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;
 }
开发者ID:kieranklaassen,项目名称:FUEL-CMS,代码行数:18,代码来源:pagevariables_model.php

示例3: _toggle_callback

 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>';
     }
 }
开发者ID:ressphere,项目名称:cb_iloveproperty,代码行数:18,代码来源:users.php

示例4: _form

 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;
 }
开发者ID:kieranklaassen,项目名称:FUEL-CMS,代码行数:43,代码来源:users.php

示例5: __call

 /**
  * 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;
 }
开发者ID:daylightstudio,项目名称:FUEL-CMS-Forms-Module,代码行数:38,代码来源:Fuel_forms.php

示例6: __call

 /**
  * 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;
 }
开发者ID:magicjoey,项目名称:FUEL-CMS,代码行数:62,代码来源:MY_Model.php

示例7: _form

 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;
 }
开发者ID:kieranklaassen,项目名称:FUEL-CMS,代码行数:97,代码来源:module.php

示例8: if

				<?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=""')?>
开发者ID:rodrigowebe,项目名称:FUEL-CMS,代码行数:31,代码来源:inline_edit_bar.php

示例9: _process_uploads

 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'));
                 }
//.........这里部分代码省略.........
开发者ID:roliandra,项目名称:WebInterface-Fuel,代码行数:101,代码来源:module.php

示例10: upload

 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);
 }
开发者ID:kieranklaassen,项目名称:FUEL-CMS,代码行数:87,代码来源:navigation.php

示例11: upload

 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();
//.........这里部分代码省略.........
开发者ID:randombrad,项目名称:FUEL-CMS,代码行数:101,代码来源:navigation.php

示例12: _notify

 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;
     }
 }
开发者ID:kieranklaassen,项目名称:FUEL-CMS,代码行数:22,代码来源:blog.php

示例13: lang

" 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 
        }
        ?>
			
开发者ID:nonconforme,项目名称:FUEL-CMS,代码行数:30,代码来源:inline_edit_bar.php

示例14: _form

 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;
 }
开发者ID:nonconforme,项目名称:FUEL-CMS,代码行数:71,代码来源:assets.php

示例15: parameters


//.........这里部分代码省略.........
             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;
 }
开发者ID:ressphere,项目名称:cb_iloveproperty,代码行数:101,代码来源:Fuel_assets.php


注:本文中的is_true_val函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。