/** * Set Rules * * Set the rules from the stream fields * * @access public * @param obj - fields to set rules for * @param string - method - edit or new * @param array - fields to skip * @param bool - return the array or set the validation * @param mixed - array or true */ public function set_rules($stream_fields, $method, $skips = array(), $return_array = false, $row_id = null) { if (!$stream_fields or !is_object($stream_fields)) { return array(); } $validation_rules = array(); // ------------------------------------- // Loop through and set the rules // ------------------------------------- foreach ($stream_fields as $stream_field) { if (!in_array($stream_field->field_slug, $skips)) { $rules = array(); // If we don't have the type, then no need to go on. if (!isset($this->CI->type->types->{$stream_field->field_type})) { continue; } $type = $this->CI->type->types->{$stream_field->field_type}; // ------------------------------------- // Pre Validation Event // ------------------------------------- if (method_exists($type, 'pre_validation_compile')) { $type->pre_validation_compile($stream_field); } // ------------------------------------- // Set required if necessary // ------------------------------------- if ($stream_field->is_required == 'yes') { if (isset($type->input_is_file) && $type->input_is_file === true) { $rules[] = 'streams_file_required[' . $stream_field->field_slug . ']'; } else { $rules[] = 'required'; } } // ------------------------------------- // Validation Function // ------------------------------------- // We are using a generic streams validation // function to use a validate() function // in the field type itself. // ------------------------------------- if (method_exists($type, 'validate')) { $rules[] = "streams_field_validation[{$stream_field->field_id}:{$method}]"; } // ------------------------------------- // Set unique if necessary // ------------------------------------- if ($stream_field->is_unique == 'yes') { $rules[] = 'streams_unique[' . $stream_field->field_slug . ':' . $method . ':' . $stream_field->stream_id . ':' . $row_id . ']'; } // ------------------------------------- // Set extra validation // ------------------------------------- if (isset($type->extra_validation)) { if (is_string($type->extra_validation)) { $extra_rules = explode('|', $type->extra_validation); $rules = array_merge($rules, $extra_rules); unset($extra_rules); } elseif (is_array($type->extra_validation)) { $rules = array_merge($rules, $type->extra_validation); } } // ------------------------------------- // Remove duplicate rule values // ------------------------------------- $rules = array_unique($rules); // ------------------------------------- // Add to validation rules array // and unset $rules // ------------------------------------- $validation_rules[] = array('field' => $stream_field->field_slug, 'label' => lang_label($stream_field->field_name), 'rules' => implode('|', $rules)); unset($rules); } } // ------------------------------------- // Set the rules or return them // ------------------------------------- if ($return_array) { return $validation_rules; } else { $this->CI->form_validation->set_rules($validation_rules); return true; } }
echo lang('streams:label.field_type'); ?> </th> <th><?php echo lang('pyro.actions'); ?> </th> </tr> </thead> <tbody> <?php foreach ($fields as $field) { ?> <tr> <td><?php echo lang($field->field_name) ? lang($field->field_name) : lang_label($field->field_name); ?> </td> <td><?php echo $field->field_slug; ?> </td> <td><?php echo $this->type->types->{$field->field_type}->field_type_name; ?> </td> <td class="actions"> <?php $all_buttons = array(); foreach ($buttons as $button) {
<ul class="primary-nav"> <li id="dashboard-link"><?php echo anchor('admin', lang('global:dashboard'), 'class="top-link ' . (!$this->module ? 'current ' : '') . '"'); ?> </li> <?php // Display the menu items. // We have already vetted them for permissions // in the Admin_Controller, so we can just // display them now. foreach ($menu_items as $key => $menu_item) { if (is_array($menu_item)) { echo '<li><a href="' . current_url() . '#" class="top-link">' . lang_label($key) . '</a><ul>'; foreach ($menu_item as $lang_key => $uri) { echo '<li><a href="' . site_url($uri) . '" class="">' . lang_label($lang_key) . '</a></li>'; } echo '</ul></li>'; } elseif (is_array($menu_item) and count($menu_item) == 1) { foreach ($menu_item as $lang_key => $uri) { echo '<li><a href="' . site_url($menu_item) . '" class="top-link no-submenu">' . lang_label($lang_key) . '</a></li>'; } } elseif (is_string($menu_item)) { echo '<li><a href="' . site_url($menu_item) . '" class="top-link no-submenu">' . lang_label($key) . '</a></li>'; } } ?> </ul>
?> </span></button> <a href="<?php echo site_url(isset($return) ? $return : 'admin/streams/entries/index/' . $stream->id); ?> " class="btn gray"><?php echo lang('buttons:cancel'); ?> </a> </div> <?php echo form_close(); ?> <?php } else { ?> <div class="no_data"> <?php if (isset($no_fields_message) and $no_fields_message) { echo lang_label($no_fields_message); } else { echo lang('streams:no_fields_msg_first'); } ?> </div><!--.no_data--> <?php }
?> </th> <th><?php echo lang('global:slug'); ?> </th> <th width="120"></th> </tr> </thead> <tbody> <?php foreach ($moviesliders as $movieslider) { ?> <tr> <td><?php echo lang_label($movieslider->stream_name); ?> </td> <td><?php echo $movieslider->movieslider_uri; ?> </td> <td> <a href="" class="btn">Edit</a> <a href="" class="btn">Delete</a> <a href="" class="btn">New Post</a> </td> </tr> <?php } ?>
?> </th> <th><?php echo lang('global:slug'); ?> </th> <th width="120"></th> </tr> </thead> <tbody> <?php foreach ($blogs as $blog) { ?> <tr> <td><?php echo lang_label($blog->stream_name); ?> </td> <td><?php echo $blog->blog_uri; ?> </td> <td> <a href="" class="btn">Edit</a> <a href="" class="btn">Delete</a> <a href="" class="btn">New Post</a> </td> </tr> <?php } ?>
/** * Entries Table * * Creates a table of entries. * * @param string - the stream slug * @param string - the stream namespace slug * @param [mixed - pagination, either null for no pagination or a number for per page] * @param [null - pagination uri without offset] * @param [bool - setting this to true will take care of the $this->template business * @param [array - extra params (see below)] * @return mixed - void or string * * Extra parameters to pass in $extra array: * * title - Title of the page header (if using view override) * $extra['title'] = 'Streams Sample'; * * buttons - an array of buttons (if using view override) * $extra['buttons'] = array( * 'label' => 'Delete', * 'url' => 'admin/streams_sample/delete/-entry_id-', * 'confirm' = true * ); * columns - an array of field slugs to display. This overrides view options. * $extra['columns'] = array('field_one', 'field_two'); * * sorting - bool. Whether or not to turn on the drag/drop sorting of entries. This defaults * to the sorting option of the stream. * * see docs for more explanation */ public function entries_table($stream_slug, $namespace_slug, $pagination = null, $pagination_uri = null, $view_override = false, $extra = array()) { $CI = get_instance(); // Get stream $stream = $this->stream_obj($stream_slug, $namespace_slug); if (!$stream) { $this->log_error('invalid_stream', 'entries_table'); } // ------------------------------------- // Get Header Fields // ------------------------------------- $stream_fields = $CI->streams_m->get_stream_fields($stream->id); // We need to make sure that stream_fields is // at least an empty object. if (!is_object($stream_fields)) { $stream_fields = new stdClass(); } $stream_fields->id = new stdClass(); $stream_fields->created = new stdClass(); $stream_fields->updated = new stdClass(); $stream_fields->created_by = new stdClass(); $stream_fields->id->field_name = lang('streams:id'); $stream_fields->created->field_name = lang('streams:created_date'); $stream_fields->updated->field_name = lang('streams:updated_date'); $stream_fields->created_by->field_name = lang('streams:created_by'); // ------------------------------------- // Find offset URI from array // ------------------------------------- if (is_numeric($pagination)) { $segs = explode('/', $pagination_uri); $offset_uri = count($segs) + 1; $offset = $CI->uri->segment($offset_uri, 0); // Calculate actual offset if not first page if ($offset > 0) { $offset = ($offset - 1) * $pagination; } } else { $offset_uri = null; $offset = 0; } // ------------------------------------- // Sorting // @since 2.1.5 // ------------------------------------- if ($stream->sorting == 'custom' or isset($extra['sorting']) and $extra['sorting'] === true) { $stream->sorting = 'custom'; // As an added measure of obsurity, we are going to encrypt the // slug of the module so it isn't easily changed. $CI->load->library('encrypt'); // We need some variables to use in the sort. $CI->template->append_metadata('<script type="text/javascript" language="javascript">var stream_id=' . $stream->id . '; var stream_offset=' . $offset . '; var streams_module="' . $CI->encrypt->encode($CI->module_details['slug']) . '"; </script>'); $CI->template->append_js('streams/entry_sorting.js'); } $data = array('stream' => $stream, 'stream_fields' => $stream_fields, 'buttons' => isset($extra['buttons']) ? $extra['buttons'] : null, 'filters' => isset($extra['filters']) ? $extra['filters'] : null, 'search_id' => isset($_COOKIE['streams_core_filters']) ? $_COOKIE['streams_core_filters'] : null); // ------------------------------------- // Columns // @since 2.1.5 // ------------------------------------- if (isset($extra['columns']) and is_array($extra['columns'])) { $stream->view_options = $extra['columns']; } // ------------------------------------- // Filter API // ------------------------------------- $where = array(); if ($CI->input->get('filter-' . $stream->stream_slug)) { // Get all URL variables $url_variables = $CI->input->get(); $processed = array(); // Loop and process foreach ($url_variables as $filter => $value) { // ------------------------------------- // Filter API Params // ------------------------------------- // They all start with f- // No value? No soup for you! // ------------------------------------- if (substr($filter, 0, 2) != 'f-') { continue; } // Not a filter API parameter if (strlen($value) == 0) { continue; } // No value.. boo $filter = substr($filter, 2); // Remove identifier // ------------------------------------- // Not // ------------------------------------- // Default: false // ------------------------------------- $not = substr($filter, 0, 4) == 'not-'; if ($not) { $filter = substr($filter, 4); } // Remove identifier // ------------------------------------- // Exact // ------------------------------------- // Default: false // ------------------------------------- $exact = substr($filter, 0, 6) == 'exact-'; if ($exact) { $filter = substr($filter, 6); } // Remove identifier // ------------------------------------- // Construct the where segment // ------------------------------------- if ($exact) { if ($not) { $where[] = $stream->stream_prefix . $stream->stream_slug . '.' . $filter . ' != "' . urldecode($value) . '"'; } else { $where[] = $stream->stream_prefix . $stream->stream_slug . '.' . $filter . ' = "' . urldecode($value) . '"'; } } else { if ($not) { $where[] = $stream->stream_prefix . $stream->stream_slug . '.' . $filter . ' NOT LIKE "%' . urldecode($value) . '%"'; } else { $where[] = $stream->stream_prefix . $stream->stream_slug . '.' . $filter . ' LIKE "%' . urldecode($value) . '%"'; } } } } $filter_data = $where; // ------------------------------------- // Get Entries // ------------------------------------- $limit = $pagination ? $pagination : null; $data['entries'] = $CI->streams_m->get_stream_data($stream, $stream_fields, $limit, $offset, $filter_data); // ------------------------------------- // Pagination // ------------------------------------- foreach ($filter_data as $filter) { $CI->db->where($filter, null, false); } $data['pagination'] = create_pagination($pagination_uri, $CI->db->select('id')->count_all_results($stream->stream_prefix . $stream->stream_slug), $pagination, $offset_uri); // ------------------------------------- // Build Pages // ------------------------------------- // Set title if (isset($extra['title'])) { $CI->template->title(lang_label($extra['title'])); } // Set custom no data message if (isset($extra['no_entries_message'])) { $data['no_entries_message'] = $extra['no_entries_message']; } $table = $CI->load->view('admin/partials/streams/entries', $data, true); if ($view_override) { // Hooray, we are building the template ourself. $CI->template->build('admin/partials/blank_section', array('content' => $table)); } else { // Otherwise, we are returning the table return $table; } }
?> </th> <th><?php echo lang('global:slug'); ?> </th> <th width="120"></th> </tr> </thead> <tbody> <?php foreach ($movies as $movie) { ?> <tr> <td><?php echo lang_label($movie->stream_name); ?> </td> <td><?php echo $movie->movie_uri; ?> </td> <td> <a href="" class="btn">Edit</a> <a href="" class="btn">Delete</a> <a href="" class="btn">New Post</a> </td> </tr> <?php } ?>
?> </th> <th><?php echo lang('global:slug'); ?> </th> <th width="120"></th> </tr> </thead> <tbody> <?php foreach ($news as $v) { ?> <tr> <td><?php echo lang_label($v->stream_name); ?> </td> <td><?php echo $v->news_uri; ?> </td> <td> <a href="" class="btn">Edit</a> <a href="" class="btn">Delete</a> <a href="" class="btn">New Post</a> </td> </tr> <?php } ?>
<li><a href="#page-options"><span><?php echo lang('pages:options_label'); ?> </span></a></li> </ul> <div class="form_inputs" id="page-details"> <fieldset> <ul> <li> <label for="title"><?php if ($page_type->title_label) { echo lang_label($page_type->title_label); } else { echo lang('global:title'); } ?> <span>*</span></label> <div class="input"><?php echo form_input('title', $page->title, 'id="title" maxlength="60"'); ?> </div> </li> <li> <label for="slug"><?php echo lang('global:slug'); ?>
/** * Setup Stream fields * * Sets up our validation and some other common * elements for our page create/edit functions. * * @param obj * @param string - new or edit * @param int - entry id * @return obj - the stream object */ private function _setup_stream_fields($page_type, $method = 'new', $id = null) { // Get the stream that we are using for this page type. $stream = $this->db->limit(1)->where('id', $page_type->stream_id)->get('data_streams')->row(); $this->load->driver('Streams'); $this->load->library('Form_validation'); // So we can use the callbacks in page_m $this->form_validation->set_model('page_m'); // If we have renamed the title, then we need to change that in the validation array if ($page_type->title_label) { foreach ($this->page_m->validate as $k => $v) { if ($v['field'] == 'title') { $this->page_m->validate[$k]['label'] = lang_label($page_type->title_label); } } } // Get validation for our page fields. $page_validation = $this->streams->streams->validation_array($stream->stream_slug, $stream->stream_namespace, $method, array(), $id); $this->page_m->compiled_validate = array_merge($this->page_m->validate, $page_validation); // Set the validation rules based on the compiled validation. $this->form_validation->set_rules($this->page_m->compiled_validate); return $stream; }
<section class="title"> <?php if (isset($template['page_title'])) { echo '<h4>' . lang_label($template['page_title']) . '</h4>'; } ?> </section> <section class="item"> <div class="content"> <?php echo $content; ?> </div> </section>
?> <li> <?php $name = 'f-'; // Build the name if (isset($params['not']) and $params['not']) { $name .= 'not-'; } if (isset($params['exact']) and $params['exact']) { $name .= 'exact-'; } $name .= $params['field']; // Get the value $value = end(explode('-', $this->input->get($name))); // Dropdown type echo '<label>' . lang_label(isset($params['label']) ? $params['label'] : humanize($params['field'])) . ': </label>'; if (isset($params['options'])) { echo form_dropdown($name, $params['options'], $value); } else { echo form_input($name, $value); } ?> </li> <?php } ?> <li> <div class="buttons"> <?php echo form_submit('filter-' . $stream->stream_slug, lang('buttons:filter'), 'class="button"');
public function index() { $extra['title'] = lang_label('lang:faq:streams'); $extra['buttons'] = array(array('label' => lang('faq:field_assignments'), 'url' => 'admin/faq/streams/fields/faqs'), array('label' => lang('faq:view_options'), 'url' => 'admin/faq/streams/view_options/faqs')); $this->streams->cp->entries_table('faqs', 'faq', 10, 'admin/faq/streams/index', true, $extra); }
/** * Load language, check flashdata, define https, load and setup the data * for the admin theme */ public function __construct() { parent::__construct(); // Load the Language files ready for output $this->lang->load('admin'); $this->lang->load('buttons'); // Show error and exit if the user does not have sufficient permissions if (!self::_check_access()) { $this->session->set_flashdata('error', lang('cp:access_denied')); redirect(); } // If the setting is enabled redirect request to HTTPS if ($this->settings->admin_force_https and strtolower(substr(current_url(), 4, 1)) != 's') { redirect(str_replace('http:', 'https:', current_url()) . '?session=' . session_id()); } $this->load->helper('admin_theme'); ci()->admin_theme = $this->theme_m->get_admin(); // Using a bad slug? Weak if (empty($this->admin_theme->slug)) { show_error('This site has been set to use an admin theme that does not exist.'); } // make a constant as this is used in a lot of places defined('ADMIN_THEME') or define('ADMIN_THEME', $this->admin_theme->slug); // Set the location of assets Asset::add_path('theme', $this->admin_theme->web_path . '/'); Asset::set_path('theme'); // grab the theme options if there are any ci()->theme_options = $this->pyrocache->model('theme_m', 'get_values_by', array(array('theme' => ADMIN_THEME))); // Active Admin Section (might be null, but who cares) $this->template->active_section = $this->section; Events::trigger('admin_controller'); // ------------------------------------- // Build Admin Navigation // ------------------------------------- // We'll get all of the backend modules // from the DB and run their module items. // ------------------------------------- if (is_logged_in()) { // Here's our menu array. $menu_items = array(); // This array controls the order of the admin items. $this->template->menu_order = array('lang:cp:nav_content', 'lang:cp:nav_structure', 'lang:cp:nav_data', 'lang:cp:nav_users', 'lang:cp:nav_settings', 'lang:global:profile'); // $this->template->menu_order = array('lang:cp:nav_content', 'lang:cp:nav_structure', 'lang:cp:nav_data', 'lang:cp:nav_users', 'lang:cp:nav_settings', 'lang:global:profile'); $modules = $this->module_m->get_all(array('is_backend' => true, 'group' => $this->current_user->group, 'lang' => CURRENT_LANGUAGE)); foreach ($modules as $module) { // If we do not have an admin_menu function, we use the // regular way of checking out the details.php data. if ($module['menu'] and (isset($this->permissions[$module['slug']]) or $this->current_user->group == 'admin')) { // Legacy module routing. This is just a rough // re-route and modules should change using their // upgrade() details.php functions. if ($module['menu'] == 'utilities') { $module['menu'] = 'data'; } if ($module['menu'] == 'design') { $module['menu'] = 'structure'; } $menu_items['lang:cp:nav_' . $module['menu']][$module['name']] = 'admin/' . $module['slug']; } // If a module has an admin_menu function, then // we simply run that and allow it to manipulate the // menu array. if (method_exists($module['module'], 'admin_menu')) { //echo "<pre>"; // print_r($menu_items);; $module['module']->admin_menu($menu_items); } } // We always have our // edit profile links and such. $menu_items['lang:global:profile'] = array('lang:cp:edit_profile_label' => 'edit-profile', 'lang:cp:logout_label' => 'admin/logout'); // Order the menu items. We go by our menu_order array. $ordered_menu = array(); foreach ($this->template->menu_order as $order) { if (isset($menu_items[$order])) { $ordered_menu[lang_label($order)] = $menu_items[$order]; unset($menu_items[$order]); } } // Any stragglers? if ($menu_items) { $translated_menu_items = array(); // translate any additional top level menu keys so the array_merge works foreach ($menu_items as $key => $menu_item) { $translated_menu_items[lang_label($key)] = $menu_item; } $ordered_menu = array_merge_recursive($ordered_menu, $translated_menu_items); } //unset($ordered_menu['Content']); // And there we go! These are the admin menu items. $this->template->menu_items = $ordered_menu; } // ------------------------------ // Template configuration $this->template->enable_parser(false)->set('theme_options', $this->theme_options)->set_theme(ADMIN_THEME)->set_layout('default', 'admin'); // trigger the run() method in the selected admin theme $class = 'Theme_' . ucfirst($this->admin_theme->slug); call_user_func(array(new $class(), 'run')); }
unset($all_buttons); ?> </td> </tr> <?php } ?> </tbody> </table> <?php echo $pagination['links']; ?> <?php } else { ?> <div class="no_data"> <?php if (isset($no_assignments_message) and $no_assignments_message) { echo lang_label($no_assignments_message); } else { echo lang('streams:no_field_assign'); } ?> </div><!--.no_data--> <?php }
} ?> </td> </tr> <?php } ?> </tbody> </table> <?php echo $pagination['links']; ?> <?php } else { ?> <div class="no_data"> <?php if (isset($no_entries_message) and $no_entries_message) { echo lang_label($no_entries_message); } else { echo lang('streams:no_entries'); } ?> </div><!--.no_data--> <?php }