public function __construct() { global $AdminWidgetsCols; if ($AdminWidgetsCols === NULL) { $AdminWidgetsCols = force_array($this->options->get('dashboard_widget_position', User::id())); } }
public function __set_admin_menu() { $admin_menus = array('dashboard' => array(array('href' => site_url('dashboard'), 'icon' => 'fa fa-dashboard', 'title' => __('Dashboard')), array('href' => site_url(array('dashboard', 'update')), 'icon' => 'fa fa-dashboard', 'title' => __('Update Center'))), 'modules' => array(array('title' => __('Modules'), 'icon' => 'fa fa-puzzle-piece', 'href' => site_url('dashboard/modules'))), 'settings' => array(array('title' => __('Settings'), 'icon' => 'fa fa-cogs', 'href' => site_url('dashboard/settings')))); foreach (force_array($this->events->apply_filters('admin_menus', $admin_menus)) as $namespace => $menus) { foreach ($menus as $menu) { Menu::add_admin_menu_core($namespace, $menu); } } }
/** * @param array $options See http://plugins.jquery.com/project/Star_Rating_widget */ function __initialize($options = array()) { parent::__initialize("div"); $this->Options = force_array($options); $this->Options['inputType'] = 'select'; if (isset($this->Options['disabled'])) { $this->Options['disabled'] = true; } store_object($this); }
/** * Push Notice notice into * * **/ public function push_notice_array($notice_array) { if (is_array($notice_array)) { foreach (force_array($notice_array) as $notice) { $this->push_notice(get_instance()->lang->line($notice)); } } else { $this->push_notice(get_instance()->lang->line($notice_array)); } }
public function registerPermissions($role, $permissions) { if (!$this->roleExists($role)) { $this->rolePermissions[$role] = []; } force_array($permissions); $n = count($permissions); for ($i = 0; $i < $n; $i++) { $this->rolePermissions[$role][] = new Permission($permissions[$i]); } }
/** * Append a single or an array of menu entries. * * @param array|MenuEntry $menuEntries */ public function add($menuEntries) { force_array($menuEntries); foreach ($menuEntries as $menuEntry) { $this->menuEntries[$menuEntry->uid] = $menuEntry; force_array($menuEntry->parentUid); foreach ($menuEntry->parentUid as $parentUid) { if ($parentUid === null) { $parentUid = $this->rootUid; } $this->setParent($menuEntry->uid, $parentUid); } } }
function run() { if (current_user()->can($this->privilege)) { create_admin_menu($this->namespace, riake(0, $this->menu_position), riake(1, $this->menu_position)); add_admin_menu($this->namespace, array('title' => $this->label, 'href' => '#', 'is_submenu' => false, 'icon' => $this->menu_icon)); add_admin_menu($this->namespace, array('title' => $this->posts_list_label, 'href' => get_instance()->url->site_url(array('admin', 'posttype', $this->namespace, 'list')))); add_admin_menu($this->namespace, array('title' => $this->new_post_label, 'href' => get_instance()->url->site_url(array('admin', 'posttype', $this->namespace, 'new')))); if ($this->comment_enabled === TRUE) { add_admin_menu($this->namespace, array('title' => $this->post_comment_label, 'href' => get_instance()->url->site_url(array('admin', 'posttype', $this->namespace, 'comments')))); } foreach (force_array($this->query->get_defined_taxonomies()) as $taxonomy) { add_admin_menu($this->namespace, array('title' => riake('taxonomy-list-label', $taxonomy, sprintf(__('%s list'), riake('namespace', $taxonomy))), 'href' => get_instance()->url->site_url(array('admin', 'posttype', $this->namespace, 'taxonomy', riake('namespace', $taxonomy), 'list')))); add_admin_menu($this->namespace, array('title' => riake('new-taxonomy-label', $taxonomy, sprintf(__('New %s'), riake('namespace', $taxonomy))), 'href' => get_instance()->url->site_url(array('admin', 'posttype', $this->namespace, 'taxonomy', riake('namespace', $taxonomy), 'new')))); } } }
function run() { $this->events->add_filter('admin_menus', function ($menus) { if (User::can($this->privilege)) { $menus[$this->namespace] = array(array('title' => $this->label, 'href' => '#', 'disable' => true, 'icon' => $this->menu_icon), array('title' => $this->posts_list_label, 'href' => site_url(array('dashboard', 'posttype', $this->namespace, 'list'))), array('title' => $this->new_post_label, 'href' => site_url(array('dashboard', 'posttype', $this->namespace, 'new')))); if ($this->comment_enabled === TRUE) { $menus[$this->namespace][] = array('title' => $this->post_comment_label, 'href' => site_url(array('dashboard', 'posttype', $this->namespace, 'comments'))); } foreach (force_array($this->query->get_defined_taxonomies()) as $taxonomy) { $menus[$this->namespace][] = array('title' => riake('taxonomy-list-label', $taxonomy, sprintf(__('%s list'), riake('namespace', $taxonomy))), 'href' => site_url(array('dashboard', 'posttype', $this->namespace, 'taxonomy', riake('namespace', $taxonomy), 'list'))); $menus[$this->namespace][] = array('title' => riake('new-taxonomy-label', $taxonomy, sprintf(__('New %s'), riake('namespace', $taxonomy))), 'href' => site_url(array('dashboard', 'posttype', $this->namespace, 'taxonomy', riake('namespace', $taxonomy), 'new'))); } } return $menus; }); }
/** * @string string $code GNU Gettext code language * @string array $aliases You can specify language aliases (in lower case) * @string string $encode Override the default GNU Gettext language encode */ function registerLanguage($code, $aliases = [], $encode = null, $iso = null) { if ($encode === null) { $encode = $this->gettextDefaultEncode; } if ($encode === null) { DEBUG && error(sprintf(_("Non hai specificato una codifica per la lingua '%s' e non ce n'è una predefinita. Impostala con la costante %s."), esc_html($code), 'GETTEXT_DEFAULT_ENCODE')); return false; } $this->languages[++$this->i] = new BozPHPLanguage($code, $encode, $iso); // Yes, the language code it's an alias to itself. That's a lazy hack! $this->aliases[strtolower($code)] = $this->i; // Each alias is associated to it's language code force_array($aliases); foreach ($aliases as $alias) { $this->aliases[$alias] = $this->i; } }
function fetch_notice_output($e, $extends_msg = '', $sort = FALSE) { if ($e === TRUE) { ?> <style> .notice_sorter { border:solid 1px #999; color:#333; } .notice_sorter thead td { padding:2px 10px; text-align:center; background:#EEE; background:-moz-linear-gradient(top,#EEE,#CCC); border:solid 1px #999; } .notice_sorter tbody td { padding:2px 10px; text-align:justify; background:#FFF; border:solid 1px #999; } </style><table class="notice_sorter"><thead> <style> .notice_sorter { border:solid 1px #999; color:#333; } .notice_sorter thead td { padding:2px 10px; text-align:center; background:#EEE; background:-moz-linear-gradient(top,#EEE,#CCC); border:solid 1px #999; } .notice_sorter tbody td { padding:2px 10px; text-align:justify; background:#FFF; border:solid 1px #999; } </style> <tr><td>Index</td><td>Code</td><td>Description</td></tr></thead><tbody><?php $index = 1; foreach ($__ as $k => $v) { ?> <tr><td><?php echo $index; ?> </td><td><?php echo $k; ?> </td><td><?php echo strip_tags($v); ?> </td></tr><?php $index++; } ?> </tbody></table><?php } else { if (is_string($e)) { $notices = force_array(get_core_vars('tendoo_notices')); if (in_array($e, $notices) || array_key_exists($e, $notices)) { return $notices[$e]; } else { if (isset($notices)) { if (array_key_exists($e, $notices)) { return $notices[$e]; } else { return tendoo_warning(__(sprintf('"%s" is not a valid error code', $e))); } } else { if ($e != '' && strlen($e) <= 50) { return tendoo_warning(__(sprintf('"%s" is not a valid error code', $e))); } else { return $e; } } } } return false; } }
$(modal).find('.modal-body').find('[data-action="activate"]').bind('click',function(){ if($(papa).length > 0) { $(papa).find('[data-action="ADMITSETDEFAULT"]').trigger('click'); $(modal).find('.modal-body').find('[data-action="activate"]').attr('disabled','disabled'); } return false; }); } }); }); </script> <?php $footer_script = ob_get_clean(); $this->gui->col_config(1, array('inner-opening-wrapper' => '<div class="row themes_grid">', 'inner-closing-wrapper' => '</div>', 'footer-script' => $footer_script)); $this->gui->cols_width(1, 4); foreach (force_array($themes_list) as $_theme) { $footer_buttons = array(); $status = riake('active', $_theme) === true ? 'disabled="disabled"' : ''; $footer_buttons[] = array('text' => __('Activate'), 'attrs' => 'data-action="ADMITSETDEFAULT" ' . $status); $footer_buttons[] = array('text' => __('Delete'), 'attrs' => 'data-action="ADMITDELETETHEME"'); $footer_buttons[] = array('text' => __('Details'), 'attrs' => 'data-action="OPENDETAILS"'); $this->gui->set_meta(array('type' => 'panel-footer', 'title' => riake('name', $_theme), 'namespace' => core_meta_namespace(array('admin', 'themes', riake('namespace', $_theme))), 'opening-wrapper' => '<div class="col-lg-3 theme_head" data-theme_namespace="' . $_theme['namespace'] . '" data-theme_name="' . $_theme['name'] . '" data-theme_thumb="' . theme_thumb($_theme['namespace']) . '" data-theme_author="' . $_theme['author'] . '" data-theme_version="' . $_theme['version'] . '"><input type="hidden" class="theme_details" value="' . htmlentities($_theme['description']) . '">', 'closing-wrapper' => '</div>', 'footer-buttons' => $footer_buttons))->push_to(1); $this->gui->set_item(array('type' => 'dom', 'value' => '<img src="' . theme_thumb($_theme['namespace']) . '" style="width:100%;min-height:250px;">'))->push_to(core_meta_namespace(array('admin', 'themes', riake('namespace', $_theme)))); } $this->gui->get();
/** * Is Active * * Checks whether a module is active * * @access public * @author blair Jersyer * @copyright 2015 * @param string $module_namespace * @param bool $fresh * @since 3.0.1 * @return bool */ static function is_active($module_namespace, $fresh = false) { global $Options; if ($fresh === TRUE) { $activated_modules = riake('actives_modules', $Options); } else { $activated_modules = self::$actives; } if (in_array($module_namespace, force_array($activated_modules), true)) { return true; } return false; }
<div class="row"> <?php foreach (force_array($this->gui->get_cols()) as $col_id => $col_data) { ?> <div class="col-lg-<?php echo riake('width', $col_data, 1) * 3; ?> "> <?php $config = riake('configs', $col_data); // Inner Opening Wrapper echo $this->events->apply_filters('gui_opening_wrapper', ''); // looping $col_data[ 'metas' ]; foreach (force_array(riake('metas', $col_data)) as $meta) { // get meta type if (in_array($meta_type = riake('type', $meta), array('box-default', 'box-primary', 'box-success', 'box-info', 'box-warning', 'box'))) { // meta icon ? $icon = riake('icon', $meta, false); // enable gui form saver $form_expire = gmt_to_local(time(), 'UTC') + GUI_EXPIRE; $ref = urlencode(current_url()); $use_namespace = riake('use_namespace', $meta, false); $class = riake('classes', riake('custom', $meta)); $id = riake('id', riake('custom', $meta)); $action = riake('action', riake('custom', $meta), site_url(array('dashboard', 'options', 'save'))); $method = riake('method', riake('custom', $meta), 'POST'); $enctype = riake('enctype', riake('custom', $meta), 'multipart/form-data'); $namespace = riake('namespace', $meta); if (riake('gui_saver', $meta)) {
/** * Creates a new row. * * @param array $data If given creates new cells in the row (see <Tr::NewCell>) * @param array $options See <Tr> for options * @return type */ function &NewRow($data = false, $options = false) { $this->current_row = new Tr($options ? $options : $this->RowOptions); $this->content($this->current_row); if ($data) { $i = 0; foreach (force_array($data) as $rowdata) { $cell = $this->current_row->NewCell($rowdata); if ($this->table && $this->table->colgroup && isset($this->table->colgroup->_content[$i]) && isset($this->table->colgroup->_content[$i]->_attributes["align"]) && $this->table->colgroup->_content[$i]->_attributes["align"]) { $cell->align = $this->table->colgroup->_content[$i]->_attributes["align"]; } $i++; } } return $this->current_row; }
/** * Default behavior when no auth module is installed **/ function display_login_fields() { foreach (force_array($this->config->item('signin_fields')) as $fields) { echo $fields; } }
<?php $this->gui->cols_width(1, 4); $this->gui->enable(array('pagination')); $this->gui->set_meta(array('type' => 'panel-ho', 'title' => __('Roles'), 'namespace' => core_meta_namespace(array('roles', 'list'))))->push_to(1); foreach (force_array($get_roles) as $_role) { $rows[] = array($_role['ID'], '<a href="' . $this->instance->url->site_url(array('admin', 'roles', 'edit', $_role['ID'])) . '">' . $_role['NAME'] . '</a>', $_role['DESCRIPTION'], timespan(strtotime($_role['DATE']), $this->instance->date->timestamp()), $_role['IS_SELECTABLE'] == "1" ? __('Yes') : __('No'), '<a href="' . $this->instance->url->site_url(array('admin', 'roles', 'delete', $_role['ID'])) . '">' . __('Delete') . '</a>'); } $this->gui->set_item(array('type' => 'table', 'cols' => array(__('Id'), __('Name'), __('Description'), __('Created'), __('Available on registration'), __('Delete')), 'rows' => $rows))->push_to(core_meta_namespace(array('roles', 'list'))); $this->gui->get();
/** * Options Management ocntroller * * * @access public * @author blair Jersyer * @copyright name date * @param string $page * @param string $arg2 * @since 3.0.1 */ function options($mode = 'list') { if (in_array($mode, array('save', 'merge'))) { if (!$this->input->post('gui_saver_ref') && !$this->input->post('gui_json')) { redirect(array('dashboard', 'options')); } if ($this->input->post('gui_saver_expiration_time') > gmt_to_local(time(), 'UTC')) { $content = array(); // loping post value foreach ($_POST as $key => $value) { if (!in_array($key, array('gui_saver_option_namespace', 'gui_saver_ref', 'gui_saver_expiration_time', 'gui_saver_use_namespace'))) { /** * Merge options which a supposed to be wrapped within the same array **/ if ($mode == 'merge' && is_array($value)) { $options = $this->options->get($key); $options = array_merge(force_array($options), $value); } // save only when it's not an array if (!is_array($_POST[$key])) { if ($this->input->post('gui_saver_use_namespace') === 'true') { $content[$key] = $mode == 'merge' ? $options : $this->input->post($key); } else { if ($mode == 'merge' && is_array($value)) { $this->options->set($key, $options, true); } else { $this->options->set($key, $this->input->post($key), true); } } } else { if ($this->input->post('gui_saver_use_namespace') === 'true') { $content[$key] = $mode == 'merge' ? $options : $_POST[$key]; } else { if ($mode == 'merge' && is_array($value)) { $this->options->set($key, $options, true); } else { $this->options->set($key, $_POST[$key], true); } } } } } // saving all post using namespace if ($this->input->post('gui_saver_use_namespace') == 'true') { $this->options->set($this->input->post('gui_saver_option_namespace'), $content, true); } if (!$this->input->post('gui_json')) { // if JSON mode is enabled redirect is disabled redirect(urldecode($this->input->post('gui_saver_ref')) . '?notice=option-saved'); } } } else { if ($mode == 'get') { echo json_decode($this->options->get($_POST['option_key'])); } else { if (in_array($mode, array('save_user_meta', 'merge_user_meta'))) { if ($this->input->post('gui_saver_expiration_time') > gmt_to_local(time(), 'UTC')) { $content = array(); // loping post value foreach ($_POST as $key => $value) { if (!in_array($key, array('gui_saver_option_namespace', 'gui_saver_ref', 'gui_saver_expiration_time', 'gui_saver_use_namespace', 'user_id'))) { if ($mode == 'merge_user_meta' && is_array($value)) { $options = $this->options->get($key); $options = array_merge(force_array($options), $value); } // save only when it's not an array if (!is_array($_POST[$key])) { if ($this->input->post('gui_saver_use_namespace') === 'true') { $content[$key] = $mode == 'merge' ? $options : $this->input->post($key); } else { if ($mode == 'merge' && is_array($value)) { $this->options->set($key, $options, true, $this->input->post('user_id')); } else { $this->options->set($key, $this->input->post($key), true, $this->input->post('user_id')); } } } else { if ($this->input->post('gui_saver_use_namespace') === 'true') { $content[$key] = $mode == 'merge' ? $options : $_POST[$key]; } else { if ($mode == 'merge' && is_array($value)) { $this->options->set($key, $options, true, $this->input->post('user_id')); } else { $this->options->set($key, $_POST[$key], true, $this->input->post('user_id')); } } } } } } } } } }
/** * Manually adds a column specification to the visualization. * * @param string $name Column name * @param string $label Column label * @param string $type Type of values * @return GoogleVisualization `$this` */ function addColumn($name, $label = false, $type = false) { $this->_columnDef[$label] = array($name, $type); if (isset(self::$Colors[$name])) { $cols = force_array($this->opt('colors')); $cols[] = self::$Colors[$name]; $this->opt('colors', $cols); } return $this; }
/** * Create a new role * * @access public * @params string role name * @params string role definition * @params string role type * @return string error code **/ function set_group($name, $definition, $type, $mode = 'create', $group_id = 0) { $name = strtolower($name); // Check wether a group using this name exists $group = $this->auth->get_group_name($name); if ($mode === 'create') { if ($group === FALSE) { $this->users->auth->create_group($name); $admin_groups = force_array($this->options->get('admin_groups')); $public_groups = force_array($this->options->get('public_groups')); // make sure to delete groups saved on option table if (!in_array($name, $admin_groups) && !in_array($name, $public_groups)) { // Saving as public group if ($type === 'public') { $public_groups[] = $name; $this->options->set('public_groups', $public_groups, true); } else { $admin_groups[] = $name; $this->options->set('admin_groups', $admin_groups, true); } return 'group-created'; } } } else { $group_name = $this->auth->get_group_name($group_id); if ($group_name) { // Update group name $this->auth->update_group($group_id, $name); // get all groups types $admin_groups = force_array($this->options->get('admin_groups')); $public_groups = force_array($this->options->get('public_groups')); // remove from admin_groups array_walk($admin_groups, function (&$item, $key, $group_name) use(&$admin_groups) { if ($group_name === $item) { unset($admin_groups[$key]); } }, $group_name); // remove from public group array_walk($public_groups, function (&$item, $key, $group_name) use(&$public_groups) { if ($group_name === $item) { unset($public_groups[$key]); } }, $group_name); // make sure to delete groups saved on option table if (!in_array($name, $admin_groups) || !in_array($name, $public_groups)) { // Saving as public group if ($type === 'public') { $public_groups[] = $name; } else { $admin_groups[] = $name; } $this->options->set('public_groups', $public_groups, true); $this->options->set('admin_groups', $admin_groups, true); return 'group-updated'; } } return 'unknow-group'; } return 'group-already-exists'; }
</li> <?php } else { ?> <li class="header"><?php _e('Nothing to display right now'); ?> </li> <?php } ?> <li> <!-- inner menu: contains the actual data --> <ul class="menu"> <?php foreach (force_array($admin_notices) as $notice) { ?> <li> <a href="<?php echo riake('link', $notice); ?> "> <i class="fa <?php echo riake('icon', $notice); ?> text-aqua"></i> <?php echo riake('message', $notice); ?> </a> </li> <?php
get_instance()->gui->get_table($namespace, $class, $attrs_string); } else { if (in_array(riake('type', $item), array('dynamic-table'))) { $namespace = riake('name', $item, 'default'); $empty_message = riake('empty_message', $item, __('No result available')); $class = riake('type', $item) == 'table' ? 'table table-striped m-b-none' : ''; $class = riake('type', $item) == 'table-panel' ? 'table table-striped m-b-none panel-body' : $class; $class .= ' ' . get_user_meta('gui_' . riake('namespace', $panel)); get_instance()->gui->set_table($namespace); get_instance()->gui->empty_message($empty_message); // Creating Cols foreach (force_array(riake('cols', $item)) as $key => $title) { get_instance()->gui->add_col($key, $title); } // Adding Row foreach (force_array(riake('rows', $item)) as $key => $row) { get_instance()->gui->add_row($row); } // Get table get_instance()->gui->get_dynamic_table($namespace, $class, $attrs_string); } else { if (riake('type', $item) == 'dom') { echo riake('value', $item); } } } } } } } }
<?php defined('BASEPATH') or exit('No direct script access allowed'); /** * File Name : body.php * Description : header file for each admin page. include <html> tag and ends at </head> closing tag * Since : 1.4 **/ $this->gui->col_width(1, 4); $this->gui->add_meta(array('namespace' => 'role_list', 'title' => __('Role List'), 'col_id' => 1, 'footer' => array('pagination' => array(true)), 'type' => 'box')); $group_array = array(); foreach (force_array($groups) as $group) { ob_start(); $permissions = $this->users->auth->list_perms($group->id); foreach ($permissions as $perm) { $colors = array('bg-red', 'bg-green', 'bg-yellow', 'bg-blue'); ?> <span class="label bg-blue"><?php echo $perm->perm_name; ?> </span> <?php } $label_permissions = ob_get_clean(); $group_array[] = array('<a href="' . site_url(array('dashboard', 'groups', 'edit', $group->id)) . '">' . $group->name . '</a>', $group->definition, in_array($group->name, $this->config->item('master_group_label')) ? __('Yes') : __('No'), $label_permissions); } $this->gui->add_item(array('type' => 'table', 'cols' => array(__('Role name'), __('Description'), __('Admin'), __('Permissions')), 'rows' => $group_array), 'role_list', 1); $this->gui->output();
public function __posttype_controller($namespace, $page = 'list', $id = 0, $taxonomy_arg1 = 'list', $taxonomy_arg2 = 0) { if ($this->current_posttype = riake($namespace, $this->config->item('posttypes'))) { $data['current_posttype'] = $this->current_posttype; $data['post_namespace'] = $namespace; if ($page === 'list') { $id = $id === 0 ? 1 : $id; $post_limit = 20; $post_nbr = count($this->current_posttype->get()); $pagination = pagination_helper($post_limit, $post_nbr, $id, site_url(array('dashboard', 'posttype', $namespace, 'list')), site_url(array('error', 'code', 'page-404'))); $this->config->set_item('pagination_data', $pagination); $post = $this->current_posttype->get(array(array('limit' => array('start' => riake('start', $pagination), 'end' => riake('end', $pagination))))); $data['post'] = $post; $data['post_list_label'] = $this->current_posttype->posts_list_label; $this->gui->set_title($this->current_posttype->posts_list_label); $this->load->view('../modules/post_type/views/list', $data, false); } else { if ($page === 'new') { $data['post_namespace'] = $namespace; $data['new_post_label'] = $this->current_posttype->new_post_label; $this->load->library('form_validation'); $this->form_validation->set_rules('post_title', __('Post title')); if ($this->form_validation->run()) { $return = $this->current_posttype->set($this->input->post('post_title'), $this->input->post('post_content'), riake('post_meta', $_POST, array()), riake('post_taxonomy', $_POST, array()), $this->input->post('post_status'), $this->input->post('post_parent'), $status = 'set'); if (riake('msg', $return) === 'custom-query-saved') { redirect(array('dashboard', 'posttype', $namespace, 'edit', riake('id', $return) . '?notice=' . riake('msg', $return))); } get_instance()->notice->push_notice($this->lang->line(riake('msg', $return))); } $this->gui->set_title($this->current_posttype->new_post_label); $this->load->view('../modules/post_type/views/create', $data, false); } else { if ($page === 'edit') { $this->load->library('form_validation'); $this->form_validation->set_rules('post_title', __('Post title')); if ($this->form_validation->run()) { $return = $this->current_posttype->update($this->input->post('post_title'), $this->input->post('post_content'), riake('post_meta', $_POST, array()), riake('post_taxonomy', $_POST, array()), $this->input->post('post_status'), $this->input->post('post_parent'), $status = 'publish', $id); if (riake('msg', $return) === 'custom-query-saved') { redirect(array('dashboard', 'posttype', $namespace, 'edit', riake('id', $return) . '?notice=' . riake('msg', $return))); } get_instance()->notice->push_notice($this->lang->line(riake('msg', $return))); } // print_array( get_core_vars( 'post' ) );die; $this->gui->set_title($this->current_posttype->edit_post_label); $this->load->view('../modules/post_type/views/edit', array('post_namespace' => $namespace, 'new_post_label' => $this->current_posttype->new_post_label, 'current_posttype' => $this->current_posttype, 'post' => farray($this->current_posttype->get(array(array('where' => array('id' => $id)))))), false); } else { if ($page === 'taxonomy') { // $id is taxonomy namespace here if (in_array($id, array_keys(force_array($taxonomy = $this->current_posttype->query->get_defined_taxonomies())))) { $data = array(); $data['current_taxonomy'] = $current_taxonomy = riake($id, $taxonomy); $data['taxonomy_namespace'] = $taxonomy_namespace = $id; $data['taxonomy'] = $taxonomy; $data['taxonomy_list_label'] = riake('taxonomy-list-label', $current_taxonomy); $data['post_namespace'] = $namespace; if ($taxonomy_arg1 === 'list') { $taxonomy_limit = 20; $taxonomy_arg2 = $taxonomy_arg2 === 0 ? 1 : $taxonomy_arg2; $taxonomies_nbr = count($this->current_posttype->query->get_taxonomies($taxonomy_namespace)); $pagination = pagination_helper($taxonomy_limit, $taxonomies_nbr, $taxonomy_arg2, site_url(array('dashboard', 'posttype', $namespace, $page, $id, $taxonomy_arg1)), site_url(array('error', 'code', 'page-404'))); $data['taxonomy_list_label'] = riake('taxonomy-list-label', $current_taxonomy); $data['taxonomies'] = $this->current_posttype->query->get_taxonomies($taxonomy_namespace, $pagination['start'], $pagination['end']); $data['taxonomies_nbr'] = $taxonomies_nbr; $data['pagination'] = $pagination; $data['current_taxonomy'] = $current_taxonomy; $this->gui->set_title(riake('new-taxonomy-label', $current_taxonomy)); $this->load->view('../modules/post_type/views/taxonomy-list', $data); } else { if ($taxonomy_arg1 === 'new') { $this->load->library('form_validation'); $this->form_validation->set_rules('taxonomy_title', __('Taxonomy Title'), 'required'); if ($this->form_validation->run()) { $result = $this->current_posttype->query->set_taxonomy($data['taxonomy_namespace'], $this->input->post('taxonomy_title'), $this->input->post('taxonomy_content'), in_array($this->input->post('taxonomy_parent'), array(false, ''), TRUE) ? null : $this->input->post('taxonomy_parent')); get_instance()->notice->push_notice($this->lang->line($result)); } $this->gui->set_title(riake('new-taxonomy-label', $current_taxonomy, __('New taxonomy'))); $this->load->view('../modules/post_type/views/taxonomy-create', $data, false); } else { if ($taxonomy_arg1 === 'edit') { $this->load->library('form_validation'); $this->form_validation->set_rules('taxonomy_title', __('Taxonomy Title'), 'required'); if ($this->form_validation->run()) { $result = $this->current_posttype->query->update_taxonomy($id, $this->input->post('taxonomy_title'), $this->input->post('taxonomy_content'), $taxonomy_arg2, in_array($this->input->post('taxonomy_parent'), array(false, ''), TRUE) ? null : $this->input->post('taxonomy_parent')); get_instance()->notice->push_notice($this->lang->line('taxonomy-set')); } $data['taxonomy_id'] = $taxonomy_arg2; $data['get_taxonomy'] = farray($this->current_posttype->query->get_taxonomies($taxonomy_namespace, $taxonomy_arg2, 'as_id')); $this->gui->set_title(riake('edit-taxonomy-label', $current_taxonomy, __('Edit taxonomy'))); $this->load->view('../modules/post_type/views/taxonomy-edit', $data); } } } } else { redirect(array('dashboard', 'error', 'unknow-taxonomy')); } } else { if ($page === 'comments') { if ($id === 'approve' && $taxonomy_arg1 != 0) { $exec = $this->current_posttype->query->comment_status($taxonomy_arg1, 1); if ($exec == 'comment-edited') { redirect(array('dashboard', 'posttype', $namespace, $page . '?notice=' . $exec)); } redirect(array('dashboard', 'posttype', $namespace, $page . '?notice=error-occured')); } else { if ($id === 'disapprove' && $taxonomy_arg1 != 0) { $exec = $this->current_posttype->query->comment_status($taxonomy_arg1, 4); if ($exec == 'comment-edited') { redirect(array('dashboard', 'posttype', $namespace, $page . '?notice=' . $exec)); } redirect(array('dashboard', 'posttype', $namespace, $page . '?notice=error-occured')); } else { if ($id === 'trash' && $taxonomy_arg1 != 0) { $exec = $this->current_posttype->query->comment_status($taxonomy_arg1, 3); if ($exec == 'comment-edited') { redirect(array('dashboard', 'posttype', $namespace, $page . '?notice=' . $exec)); } redirect(array('dashboard', 'posttype', $namespace, $page . '?notice=error-occured')); } else { if ($id === 'draft' && $taxonomy_arg1 != 0) { $exec = $this->current_posttype->query->comment_status($taxonomy_arg1, 0); if ($exec == 'comment-edited') { redirect(array('dashboard', 'posttype', $namespace, $page . '?notice=' . $exec)); } redirect(array('dashboard', 'posttype', $namespace, $page . '?notice=error-occured')); } else { if ($id === 'delete' && $taxonomy_arg1 != 0) { $exec = $this->current_posttype->query->delete_comment($taxonomy_arg1, 'as_id'); if ($exec == 'comment-edited') { redirect(array('dashboard', 'posttype', $namespace, $page . '?notice=' . $exec)); } redirect(array('dashboard', 'posttype', $namespace, $page . '?notice=error-occured')); } } } } } // $this->current_posttype->query->post_comment( 1 , 'Custom' , $author = false , $mode = 'create' , $comment_id = null , $author_name = 'Blair' , $author_email = '*****@*****.**' , $reply_to = false ); $id = $id === 0 ? 1 : $id; $comment_limit = 10; $comments_nbr = count($this->current_posttype->query->get_comments()); $pagination = pagination_helper($comment_limit, $comments_nbr, $id, site_url(array('dashboard', 'posttype', $namespace, 'comments')), site_url(array('error', 'code', 'page-404'))); $comments = $this->current_posttype->query->get_comments(array('limit' => array('start' => riake('start', $pagination), 'end' => riake('end', $pagination)))); $this->config->set_item('comments', $comments); $this->config->set_item('comments_list_label', $this->current_posttype->comments_list_label); $this->gui->set_title($this->current_posttype->comments_list_label); $this->load->view('../modules/post_type/views/comments-list', array('pagination_data' => $pagination, 'post_namespace' => $namespace, 'comments_list_label' => $this->current_posttype->comments_list_label, 'comments' => $comments), false); } else { if ($page === 'comment-edit') { } } } } } } } else { redirect(array('dashboard', 'error', 'unknow-post-type')); } }
/** * To execute update queries. */ public function update($table_name, $dbCols, $conditions, $after = '') { force_array($dbCols); $SQL = "UPDATE {$this->getTable($table_name)} SET "; $n_cols = count($dbCols); for ($i = 0; $i < $n_cols; $i++) { if ($i !== 0) { $SQL .= ', '; } $val = $this->forceType($dbCols[$i]->value, $dbCols[$i]->forceType); $SQL .= "`{$dbCols[$i]->column}` = {$val}"; } if ($after !== '') { $after = " {$after}"; } $SQL .= " WHERE {$conditions}{$after}"; return $this->query($SQL); }
<div class="box-tools pull-right"> <button class="btn btn-default btn-sm" data-widget="collapse"><i class="fa fa-minus"></i></button> </div> <h3 class="box-title"><?php echo riake('title', $panel); ?> </h3> </header> <div class="box-body clearfix"> <?php $this->load->view('dashboard/others/gui_items'); ?> </div> <footer class="panel-footer"> <?php foreach (force_array(riake('footer-buttons', $panel)) as $_button) { $class = riake('class', $_button, 'btn btn-white btn-sm'); $attrs = riake('attrs', $_button, ''); $value = riake('value', $_button, __('Sample Button')); $text = riake('text', $_button, __('Sample Button')); $name = riake('name', $_button); $type = riake('type', $_button, 'button'); $placeholder = riake('placeholder', $_button); ?> <button value="<?php echo $value; ?> " name="<?php echo $name; ?> " type="<?php
public function add_permission($role_id, $action) { $role = $this->get($role_id); if ($role) { $roles_permissions = get_meta('roles_permissions'); $permissions = riake($role_id, $roles_permissions, array($role_id => array())); if (!in_array($action, force_array($permissions))) { $roles_permissions[$role_id][] = $action; set_meta('roles_permissions', $roles_permissions); return true; } } return false; }
<?php $this->gui->cols_width(1, 4); $this->gui->set_meta(array('namespace' => core_meta_namespace(array('users', 'edit')), 'title' => __('Edit user'), 'type' => 'panel', 'form_wrap' => array('method' => 'POST')))->push_to(1); $this->gui->set_item(array('type' => 'text', 'attrs' => array('readonly' => 'readonly'), 'value' => $adminInfo['PSEUDO'], 'placeholder' => __('User Pseudo'), 'label' => __('User Pseudo')))->push_to(core_meta_namespace(array('users', 'edit'))); $this->gui->set_item(array('type' => 'text', 'name' => 'user_email', 'placeholder' => __('Enter Email'), 'text' => __('User Email'), 'label' => __('User Email'), 'value' => $adminInfo['EMAIL']))->push_to(core_meta_namespace(array('users', 'edit'))); // Get Roles $text[] = __('User Role'); $value[] = ''; foreach (force_array($get_roles) as $_role) { $value[] = riake('ID', $_role); $text[] = riake('NAME', $_role); } $this->gui->set_item(array('type' => 'select', 'name' => 'edit_priv', 'value' => $value, 'placeholder' => __('Select User Role'), 'text' => $text, 'active' => $adminInfo['REF_ROLE_ID'], 'label' => __('User Role')))->push_to(core_meta_namespace(array('users', 'edit'))); $this->gui->set_item(array('type' => 'hidden', 'name' => 'current_admin', 'value' => $adminInfo['PSEUDO']))->push_to(core_meta_namespace(array('users', 'edit'))); // Loading Generated Fields using "user_fields" hook $user_fields = trigger_filters('user_form_fields', array(get_core_vars('tendoo_user_fields'), $adminInfo['ID'])); // Filter user fields or add foreach (force_array($user_fields) as $field) { $this->gui->set_item($field)->push_to(core_meta_namespace(array('users', 'edit'))); } $this->gui->set_item(array('type' => 'buttons', 'name' => array('set_admin', 'delete_admin'), 'value' => array(__('Save User'), __('Delete User')), 'classes' => array('btn-primary', 'btn-warning'), 'button_types' => array('submit', 'submit'), 'attrs_string' => array('', 'onclick="return confirm( \'' . __('Do you really want to delete this user ?') . '\')" ')))->push_to(core_meta_namespace(array('users', 'edit'))); $this->gui->get();
} trigger_events('after_title_inition', array($current_posttype, $this->gui, $post_namespace . '-create-new', $post)); // Trigger each event bound trigger_events('before_editor_inition', array($current_posttype, $this->gui, $post_namespace . '-create-new', $post)); // Trigger each event bound if (in_array('editor', riake('displays', $current_posttype->get_config()))) { $this->gui->set_item(array('type' => 'visual_editor', 'name' => 'post_content', 'value' => riake('CONTENT', $post)))->push_to($post_namespace . '-edit-new'); } trigger_events('after_editor_inition', array($current_posttype, $this->gui, $post_namespace . '-create-new', $post)); // Trigger each event bound trigger_events('before_publish_inition', array($current_posttype, $this->gui, $post_namespace . '-create-new-sidebar', $post)); // Trigger each event bound if (in_array('publish', riake('displays', $current_posttype->get_config()))) { if ($defined_taxonomies = $current_posttype->query->get_defined_taxonomies()) { foreach (force_array($defined_taxonomies) as $tax_namespace => $_taxonomy) { //current_posttype $taxonomy_text = $taxonomy_value = array(); $taxonomies_list = $current_posttype->query->get_taxonomies($tax_namespace); foreach (force_array($taxonomies_list) as $_taxonomy) { $taxonomy_text[] = riake('TITLE', $_taxonomy); $taxonomy_value[] = riake('ID', $_taxonomy); } $this->gui->set_item(array('type' => 'multiple', 'name' => 'post_taxonomy[' . $tax_namespace . '][]', 'text' => $taxonomy_text, 'value' => $taxonomy_value, 'label' => __('Select a taxonomy'), 'active' => riake('TAXONOMIES', $post)))->push_to($post_namespace . '-edit-new-sidebar'); } } $this->gui->set_item(array('type' => 'select', 'name' => 'post_status', 'text' => array(__('Draft'), __('Publish')), 'value' => array(0, 1), 'label' => __('Status'), 'active' => riake('STATUS', $post)))->push_to($post_namespace . '-edit-new-sidebar'); } trigger_events('after_publish_inition', array($current_posttype, $this->gui, $post_namespace . '-create-new-sidebar', $post)); // Trigger each event bound $this->gui->set_item(array('type' => 'buttons', 'name' => array('submit_content'), 'value' => array(__('Submit')), 'buttons_types' => array('submit')))->push_to($post_namespace . '-edit-new-sidebar'); $this->gui->get();
$this->events->do_action_ref_array('after_post_editor', array($current_posttype, $this->gui, $post_namespace . '-create-new')); // Trigger each event bound $this->events->do_action_ref_array('before_post_publish', array($current_posttype, $this->gui, $post_namespace . '-create-new-sidebar')); // Trigger each event bound if (in_array('publish', riake('displays', $current_posttype->get_config()))) { if ($defined_taxonomies = $current_posttype->query->get_defined_taxonomies()) { foreach (force_array($defined_taxonomies) as $tax_namespace => $_taxonomy) { //current_posttype $taxonomy_array = array(); $taxonomies_list = $current_posttype->query->get_taxonomies($tax_namespace); foreach (force_array($taxonomies_list) as $_taxonomy) { $taxonomy_array[riake('ID', $_taxonomy)] = riake('TITLE', $_taxonomy); } $this->gui->add_item(array('type' => 'multiple', 'name' => 'post_taxonomy[' . $tax_namespace . '][]', 'options' => $taxonomy_array, 'label' => __('Select a taxonomy')), $post_namespace . '-create-new-sidebar', 2); } } $this->gui->add_item(array('type' => 'select', 'name' => 'post_status', 'options' => array(__('Draft'), __('Publish')), 'label' => __('Status')), $post_namespace . '-create-new-sidebar', 2); // is hierarchical if (riake('is-hierarchical', $current_posttype->get_config()) == true) { // get common post list $postlist = $current_posttype->get(); $postarray = array(-1 => __('No parent')); foreach (force_array($postlist) as $_post) { $postarray[riake('QUERY_ID', $_post)] = riake('TITLE', $_post); } $this->gui->add_item(array('type' => 'select', 'name' => 'post_parent', 'options' => $postarray, 'placeholder' => __('Choose a parent'), 'label' => __('Select Parent')), $post_namespace . '-create-new-sidebar', 2); } } $this->gui->add_item(array('type' => 'buttons', 'name' => array('submit_content'), 'value' => array(__('Submit')), 'buttons_types' => array('submit')), $post_namespace . '-create-new-sidebar', 2); // $this->events->do_action( 'after_post_publish' , array( $current_posttype , $this->gui , $post_namespace . '-create-new-sidebar' ) ); // Trigger each event bound $this->gui->output();
/** * Get the file types of a MIME. * * @param string|null $category * If NULL it search in all the categories. * @param string|null $mimetype The MIME type. * @return mixed FALSE if the MIME is not registered or an array of file types. */ public function getFiletypes($categories = null, $mimetype = null) { $all_types = []; if ($categories === null) { // Search in all the categories. foreach ($this->mimeTypes as $mimeTypes) { foreach ($mimeTypes as $mime => $types) { if ($mimetype === null || $mime === $mimetype) { $all_types = array_merge($all_types, $types); } } } } else { force_array($categories); // Search *that* category if exists foreach ($categories as $category) { if (!isset($this->mimeTypes[$category])) { DEBUG && self::printErrorUnknownCategory($category); continue; } foreach ($this->mimeTypes[$category] as $mime => $types) { if ($mimetype === null || $mime === $mimetype) { $all_types = array_merge($all_types, $types); } } } } return array_unique($all_types); }