示例#1
0
文件: admincp.php 项目: josev814/hero
    function copy($id)
    {
        $this->load->model('content_model');
        $content = $this->content_model->get_content($id, TRUE);
        $this->load->model('content_type_model');
        $type = $this->content_type_model->get_content_type($content['type_id']);
        $this->load->library('admin_form');
        if ($type['is_standard'] == TRUE) {
            // we require Title, URL Path, and Topic fields
            $title = new Admin_form();
            $title->fieldset('Standard Page Elements');
            $title->text('Title', 'title', $content['title'], FALSE, TRUE, FALSE, TRUE);
            // if we are using the base_url in the current URL, chances are we want to keep it for future URL's
            if (isset($type['base_url']) and !empty($type['base_url']) and strpos($content['url_path'], $type['base_url']) === 0) {
                $title->hidden('base_url', $type['base_url']);
            }
            $title->text('URL Path', 'url_path', $content['url_path'], 'If you leave this blank, it will be auto-generated from the Title above.', FALSE, 'e.g., /about/contact_us', FALSE, '500px');
            // we will build the rest of the sidebar form with form_builder because we want to use it's cool
            // fieldtypes and better API
            $this->load->model('topic_model');
            $topics = $this->topic_model->get_tiered_topics();
            $options = array();
            foreach ($topics as $data) {
                $options[] = array('name' => $data['name'], 'value' => $data['id']);
            }
            $this->load->library('custom_fields/form_builder');
            $topics = $this->form_builder->add_field('multicheckbox');
            $topics->options($options)->name('topics')->label('Topics');
            $date = $this->form_builder->add_field('datetime')->name('date')->label('Publish Date');
            $end_date = $this->form_builder->add_field('datetime')->name('end_date')->label('Unpublish Date')->value($content['end_date']);
            $status = $this->form_builder->add_field('text')->readonly('readonly')->name('status')->label('Status')->value($content['status']);
            // editing, assign values
            $topics->value($content['topics']);
            //print_r($content['date']);
            $date->value($content['date']);
            $title = $title->display();
            $standard = $this->form_builder->output_admin();
        } else {
            $standard = FALSE;
            $title = FALSE;
        }
        if ($type['is_privileged'] == TRUE) {
            // we require a member group access privileges dropdown
            $this->load->model('users/usergroup_model');
            $groups = $this->usergroup_model->get_usergroups();
            $options = array();
            $options[] = array('name' => 'Public / Any Member Group', 'value' => '0');
            foreach ($groups as $group) {
                $options[] = array('name' => $group['name'], 'value' => $group['id']);
            }
            $this->load->library('custom_fields/form_builder');
            $this->form_builder->reset();
            $privileges = $this->form_builder->add_field('multicheckbox');
            $privileges->name('privileges')->options($options)->default_value(0)->label('Allowed Membership Groups')->help('If a group or groups is selected, this content will require the user be in this group to view it.  This enables you to 
					   charge for subscriptions and products that move the user to this group.')->value($content['privileges']);
            $privileges = $this->form_builder->output_admin();
        } else {
            $privileges = FALSE;
        }
        // handle custom fields
        $this->load->model('custom_fields_model');
        $custom_fieldset = new Admin_form();
        $custom_fields = $this->custom_fields_model->get_custom_fields(array('group' => $type['custom_field_group_id']));
        if (empty($custom_fields)) {
            $custom_fields = FALSE;
        } else {
            $custom_fieldset->fieldset('Custom Product Data');
            $custom_fieldset->custom_fields($custom_fields, $content);
            $custom_fields = $custom_fieldset->display();
        }
        $data = array('title' => $title, 'standard' => $standard, 'privileges' => $privileges, 'custom_fields' => $custom_fields, 'type' => $type, 'form_title' => 'Copy Content', 'form_action' => site_url('admincp/publish/post/new/'), 'invalid' => $this->input->get('invalid') ? TRUE : FALSE, 'errors' => $this->session->flashdata('errors'));
        $this->load->view('create_post', $data);
    }
示例#2
0
文件: admincp.php 项目: josev814/hero
 function collection_edit($id)
 {
     $this->load->library('admin_form');
     $form = new Admin_form();
     $form->fieldset('Collection Information');
     $this->load->model('collections_model');
     $collections = $this->collections_model->get_tiered_collections();
     $collection = $this->collections_model->get_collection($id);
     $options = array();
     $options[0] = 'No parent';
     foreach ($collections as $data) {
         $options[$data['id']] = $data['name'];
     }
     $form->dropdown('Parent', 'parent', $options, $collection['parent'], FALSE, FALSE, 'If a parent is selected, this collection will act as a sub-collection of its parent.', TRUE);
     $form->text('Collection Name', 'name', $collection['name'], FALSE, TRUE, 'e.g., Men\'s Shoes', TRUE);
     $form->textarea('Description', 'description', $collection['description'], FALSE, FALSE, 'complete', TRUE);
     // custom fields
     if (setting('collections_custom_field_group') != '') {
         $collection_data = $this->custom_fields_model->get_custom_fields(array('group' => setting('collections_custom_field_group')));
         if (!empty($collection_data)) {
             $form->fieldset('Custom Product Data');
             $form->custom_fields($collection_data, $collection);
         }
     }
     $data = array('form' => $form->display(), 'form_action' => site_url('admincp/store/post_collection/edit/' . $collection['id']), 'form_title' => 'Edit Collection');
     $this->load->view('collection_form', $data);
 }
示例#3
0
文件: admincp.php 项目: Rotron/hero
 function edit($id)
 {
     $this->load->model('usergroup_model');
     $usergroups = $this->usergroup_model->get_usergroups();
     $usergroup_options = array();
     foreach ($usergroups as $group) {
         $usergroup_options[$group['id']] = $group['name'];
     }
     $user = $this->user_model->get_user($id);
     if (!$user) {
         die(show_error('No user found with that ID.'));
     }
     $this->load->library('admin_form');
     $form = new Admin_form();
     $form->fieldset('System Information');
     $form->text('Username', 'username', $user['username'], FALSE, TRUE, FALSE, TRUE);
     $form->text('Email', 'email', $user['email'], FALSE, TRUE, '*****@*****.**', TRUE);
     $form->password('Password', 'password', '', FALSE, TRUE);
     $form->password('Repeat Password', 'password2', 'Leave blank to keep current password. Passwords must be at least 6 characters in length.', FALSE, TRUE);
     $form->fieldset('Usergroup');
     $form->dropdown('Usergroups', 'usergroups', $usergroup_options, $user['usergroups'], TRUE, TRUE);
     $form->checkbox('Administrator', 'is_admin', '1', $user['is_admin']);
     $form->fieldset('Profile Information');
     $form->names('Name', $user['first_name'], $user['last_name'], FALSE, TRUE);
     $form->custom_fields($this->user_model->get_custom_fields(), $user, TRUE);
     $data = array('user' => array(), 'usergroups' => $usergroup_options, 'default_usergroup' => $this->usergroup_model->get_default(), 'form' => $form->display(), 'form_title' => 'Edit Member Account', 'form_action' => site_url('admincp/users/post_user/edit/' . $user['id']));
     $this->load->view('user_form.php', $data);
 }
示例#4
0
文件: admincp.php 项目: Rotron/hero
 /**
  * Re-position a custom field group
  *
  * @param int $custom_field_group Custom field group ID
  * @param string $return_url A URL-encoded, base64_encoded, site_url() call (e.g., url_encode(base64_encode(site_url('admincp/'))))
  *
  * @return view
  */
 function order($custom_field_group, $return_url)
 {
     $return_url = base64_decode(urldecode($return_url));
     // load model
     $this->load->model('custom_fields_model');
     $custom_fields = $this->custom_fields_model->get_custom_fields(array('group' => $custom_field_group));
     if (empty($custom_fields)) {
         die(show_error('No custom fields in this group.'));
     }
     $this->load->library('admin_form');
     $form = new Admin_form();
     $form->fieldset('Custom Fields', array('sortable'));
     foreach ($custom_fields as $key => $field) {
         // get rid of required fields
         $custom_fields[$key]['required'] = '0';
         // no wysiwygs
         if ($field['type'] == 'wysiwyg') {
             $custom_fields[$key]['type'] = 'textarea';
         }
     }
     $form->custom_fields($custom_fields);
     $form = $form->display();
     $data = array('form' => $form, 'return_url' => urlencode(base64_encode($return_url)), 'field_group_id' => $custom_field_group);
     $this->load->view('arrange_fields.php', $data);
 }