SproutCMS

This is the code documentation for the SproutCMS project

class MultiEdit

UI system for rapid adding/editing of any number of (sub-)records

Example

$images = MultiEdit::load('gallery_images', ['gallery_id' => $gallery_id], 'record_order');
MultiEdit::itemName('Image');
MultiEdit::reorder();
MultiEdit::setPostAddJavaScriptFunc('load_thumbnails');
MultiEdit::display('images', $images, @$_SESSION['gallery']['field_errors']['multiedit_images']);

Source code (22 results)

/sprout/Controllers/Admin/HasCategoriesAdminController.php   Highlighted file source

Line 608: $data = array_merge($data, JsonForm::loadMultiEditData($conf, $default_link, $id, []));
Line 704: $data = array_merge($data, JsonForm::loadMultiEditData($conf, $default_link, $id, []));

/sprout/Controllers/Admin/HasCategoriesAdminController.php   Highlighted file source

Line 608: $data = array_merge($data, JsonForm::loadMultiEditData($conf, $default_link, $id, []));
Line 704: $data = array_merge($data, JsonForm::loadMultiEditData($conf, $default_link, $id, []));

/sprout/Controllers/Admin/ManagedAdminController.php   Highlighted file source

Line 1387: $data = array_merge($data, JsonForm::loadMultiEditData($conf, $default_link, $id, []));
Line 1575: $data = array_merge($data, JsonForm::loadMultiEditData($conf, $default_link, $id, []));

/sprout/Controllers/Admin/ManagedAdminController.php   Highlighted file source

Line 1387: $data = array_merge($data, JsonForm::loadMultiEditData($conf, $default_link, $id, []));
Line 1575: $data = array_merge($data, JsonForm::loadMultiEditData($conf, $default_link, $id, []));

/sprout/Controllers/Admin/OperatorCategoryAdminController.php   Highlighted file source

Line 19: use Sprout\Helpers\MultiEdit;
Line 79: // Grab the current ones for the multiedit
Line 80: if (! isset($view->data['multiedit_permissions'])) {
Line 81: $view->data['multiedit_permissions'] = MultiEdit::load('operatorcategory_permissions', ['operatorcategory_id' => $item_id], 'controller');
Line 167: if (@!is_array($_POST['multiedit_permissions'])) $_POST['multiedit_permissions'] = array();
Line 170: foreach ($_POST['multiedit_permissions'] as $data) {
Line 171: if (MultiEdit::recordEmpty($data)) continue;

/sprout/Controllers/Admin/OperatorCategoryAdminController.php   Highlighted file source

Line 19: use Sprout\Helpers\MultiEdit;
Line 79: // Grab the current ones for the multiedit
Line 80: if (! isset($view->data['multiedit_permissions'])) {
Line 81: $view->data['multiedit_permissions'] = MultiEdit::load('operatorcategory_permissions', ['operatorcategory_id' => $item_id], 'controller');
Line 167: if (@!is_array($_POST['multiedit_permissions'])) $_POST['multiedit_permissions'] = array();
Line 170: foreach ($_POST['multiedit_permissions'] as $data) {
Line 171: if (MultiEdit::recordEmpty($data)) continue;

/sprout/Controllers/Admin/PageAdminController.php   Highlighted file source

Line 48: use Sprout\Helpers\MultiEdit;
Line 1093: $attributes = MultiEdit::load('page_attributes', ['page_id' => $id]);
Line 1094: if (! isset($data['multiedit_attrs'])) {
Line 1095: $data['multiedit_attrs'] = $attributes;
Line 1708: if (@count($_POST['multiedit_attrs'])) {
Line 1709: foreach ($_POST['multiedit_attrs'] as $idx => $data) {
Line 1710: if (MultiEdit::recordEmpty($data)) continue;

/sprout/Controllers/Admin/PageAdminController.php   Highlighted file source

Line 48: use Sprout\Helpers\MultiEdit;
Line 1093: $attributes = MultiEdit::load('page_attributes', ['page_id' => $id]);
Line 1094: if (! isset($data['multiedit_attrs'])) {
Line 1095: $data['multiedit_attrs'] = $attributes;
Line 1708: if (@count($_POST['multiedit_attrs'])) {
Line 1709: foreach ($_POST['multiedit_attrs'] as $idx => $data) {
Line 1710: if (MultiEdit::recordEmpty($data)) continue;

/sprout/Controllers/Controller.php   Highlighted file source

Line 27: use Sprout\Helpers\MultiEdit;
Line 447: // Iterate and do two tasks: Set empty params; collate multiedits for processing below
Line 448: $multiedits = [];
Line 455: if (isset($item['multiedit'])) {
Line 456: $multiedits[] = &$item['multiedit'];
Line 463: // Iterate multiedits and do the same processing
Line 464: foreach ($multiedits as &$multi) {
Line 523: if (substr($key, 0, 9) == 'multiedit') continue;
Line 540: // Update multiedits
Line 545: if (!isset($item['multiedit'])) continue;
Line 547: $multed = $item['multiedit'];
Line 549: $multi_data_key = 'multiedit_' . $multed['id'];
Line 569: if (MultiEdit::recordEmpty($new_rec, $defaults)) {

/sprout/Controllers/Controller.php   Highlighted file source

Line 27: use Sprout\Helpers\MultiEdit;
Line 447: // Iterate and do two tasks: Set empty params; collate multiedits for processing below
Line 448: $multiedits = [];
Line 455: if (isset($item['multiedit'])) {
Line 456: $multiedits[] = &$item['multiedit'];
Line 463: // Iterate multiedits and do the same processing
Line 464: foreach ($multiedits as &$multi) {
Line 523: if (substr($key, 0, 9) == 'multiedit') continue;
Line 540: // Update multiedits
Line 545: if (!isset($item['multiedit'])) continue;
Line 547: $multed = $item['multiedit'];
Line 549: $multi_data_key = 'multiedit_' . $multed['id'];
Line 569: if (MultiEdit::recordEmpty($new_rec, $defaults)) {

/sprout/Controllers/DbToolsController.php   Highlighted file source

Line 103: [ 'url' => 'dbtools/multimake', 'name' => 'Generate multiedit', 'desc' => 'Generate multiedit code' ],
Line 2507: * Generate multiedit code
Line 2530: $this->template('Generate multiedit code');
Line 2578: $this->template('Generate multiedit code');
Line 2621: $this->template('Generate multiedit code');
Line 2628: $this->template('Generate multiedit code');
Line 2641: $template = preg_replace('/(multiedit[-_])people/', '$1' . $_POST['group'], $template);
Line 2650: $reorder = '<?php MultiEdit::reorder(); ?>';
Line 2698: $this->template('Generate multiedit code');

/sprout/Controllers/DbToolsController.php   Highlighted file source

Line 103: [ 'url' => 'dbtools/multimake', 'name' => 'Generate multiedit', 'desc' => 'Generate multiedit code' ],
Line 2507: * Generate multiedit code
Line 2530: $this->template('Generate multiedit code');
Line 2578: $this->template('Generate multiedit code');
Line 2621: $this->template('Generate multiedit code');
Line 2628: $this->template('Generate multiedit code');
Line 2641: $template = preg_replace('/(multiedit[-_])people/', '$1' . $_POST['group'], $template);
Line 2650: $reorder = '<?php MultiEdit::reorder(); ?>';
Line 2698: $this->template('Generate multiedit code');

/sprout/Helpers/Admin.php   Highlighted file source

Line 367: public static function multieditBuild($dataset, $field_names)
Line 594: * Uses a multiedit
Line 612: <div id="multiedit-attrs">
Line 637: $div.find('.value').html('<input type="hidden" name="multiedit_attrs[' + idx + '][value]" value="">');
Line 640: var val = $div.find('.value [name^="multiedit_attrs"]').val();
Line 645: $outer.find('[name=value]').attr('name', 'multiedit_attrs[' + idx + '][value]');
Line 658: MultiEdit::setPostAddJavaScriptFunc('attribute_editor');
Line 659: MultiEdit::itemName('Attribute');
Line 660: MultiEdit::display('attrs', $current_attrs);

/sprout/Helpers/JsonForm.php   Highlighted file source

Line 30: * Loads multiedit data for use on a view
Line 34: * @param array $conditions Conditions to get records in the multiedit table which relate to the base record;
Line 39: public static function loadMultiEditData(array $conf, $default_link, $record_id, array $conditions)
Line 46: if (!isset($item['multiedit'])) continue;
Line 48: $multed = $item['multiedit'];
Line 49: $id = 'multiedit_' . $multed['id'];
Line 341: } elseif (isset($item['multiedit'])) {
Line 342: // Multiedit
Line 343: $multed = $item['multiedit'];
Line 344: if (!isset($data['multiedit_' . $multed['id']])) {
Line 345: $data['multiedit_' . $multed['id']] = [];
Line 347: if (!isset($errors['multiedit_' . $multed['id']])) {
Line 348: $errors['multiedit_' . $multed['id']] = [];
Line 351: // Backup form data, then clobber it, to render using the multiedit's defaults
Line 356: $out = '<script type="text/x-template" id="' . Enc::html('multiedit-' . $multed['id']) . '">';
Line 366: MultiEdit::setPostAddJavaScriptFunc($multed['post-add-js']);
Line 369: MultiEdit::reorder();
Line 371: MultiEdit::itemName($multed['single']);
Line 378: MultiEdit::display(
Line 380: $data['multiedit_' . $multed['id']],
Line 381: $errors['multiedit_' . $multed['id']]
Line 394: "Unknown item type; expected key 'field', 'heading', 'html', 'func', 'multiedit', or 'autofill_list'"
Line 533: // Multiedits
Line 536: if (!isset($item['multiedit'])) continue;
Line 538: $multed = $item['multiedit'];
Line 539: $src = 'multiedit_' . $multed['id'];
Line 541: // User has removed all multiedit records of this type
Line 585: if (MultiEdit::recordEmpty($record, $defaults)) {

/sprout/Helpers/MultiEdit.php   Highlighted file source

Line 21: * $images = MultiEdit::load('gallery_images', ['gallery_id' => $gallery_id], 'record_order');
Line 22: * MultiEdit::itemName('Image');
Line 23: * MultiEdit::reorder();
Line 24: * MultiEdit::setPostAddJavaScriptFunc('load_thumbnails');
Line 25: * MultiEdit::display('images', $images, @$_SESSION['gallery']['field_errors']['multiedit_images']);
Line 27: class MultiEdit
Line 35: * Returns an array of data, which should be put into a view, and passed into MultiEdit::display.
Line 63: * Set the name of a javascript function to call after each multiedit item is added
Line 72: * MultiEdit::setPostAddJavaScriptFunc('alert')
Line 75: * MultiEdit::setPostAddJavaScriptFunc('console.log')
Line 78: * MultiEdit::setPostAddJavaScriptFunc('(function($div,data,idx){ console.log($div); })')
Line 87: * Enable multiedit reordering
Line 96: * Set the item name for a multiedit.
Line 106: * Displays a multiedit field
Line 107: * @param string $key Key to group records for this multiedit
Line 115: Needs::fileGroup('multiedit');
Line 144: echo " $('#multiedit-{$key}').multiedit(\n";
Line 158: * Returns true if the multiedit record is empty, false otherwise
Line 160: * @param array $record Collated [field => value] pairs which are to be saved with a multiedit record

/sprout/Helpers/Validator.php   Highlighted file source

Line 40: * // Multiedit example for a course with students
Line 54: * if (empty($_POST['multiedit_students'])) {
Line 55: * $_POST['multiedit_students'] = [];
Line 59: * foreach ($_POST['multiedit_students'] as $idx => $data) {
Line 60: * if (MultiEdit::recordEmpty($data)) continue;
Line 75: * $_SESSION['course_edit']['field_errors']['multiedit_students'][$idx] = $multi_valid->getFieldErrors();

/sprout/views/admin/operator_category_edit.php   Highlighted file source

Line 18: use Sprout\Helpers\MultiEdit;
Line 63: <div id="multiedit-permissions">
Line 92: <?php MultiEdit::display('permissions', $data['multiedit_permissions']); ?>

/sprout/views/admin/operator_category_edit.php   Highlighted file source

Line 18: use Sprout\Helpers\MultiEdit;
Line 63: <div id="multiedit-permissions">
Line 92: <?php MultiEdit::display('permissions', $data['multiedit_permissions']); ?>

/sprout/views/admin/style_guide/multiedit.php   Highlighted file source

Line 4: use Sprout\Helpers\MultiEdit;
Line 16: <div id="multiedit-demo">
Line 40: MultiEdit::display('demo', @$_POST['multiedit_demo'], []);

/sprout/views/admin/style_guide/multiedit.php   Highlighted file source

Line 4: use Sprout\Helpers\MultiEdit;
Line 16: <div id="multiedit-demo">
Line 40: MultiEdit::display('demo', @$_POST['multiedit_demo'], []);

/sprout/views/dbtools/multimake_template.php   Highlighted file source

Line 18: use Sprout\Helpers\MultiEdit;
Line 27: <div id="multiedit-people">
Line 35: <?php MultiEdit::itemName('Person'); ?>
Line 36: <?php MultiEdit::display('people', $data['multiedit_people']); ?>
Line 42: if (!isset($view->data['multiedit_people'])) {
Line 43: $view->data['multiedit_people'] = MultiEdit::load('user_people', ['user_id' => $item_id], 'record_order');
Line 48: if (!is_array(@$_POST['multiedit_people'])) {
Line 49: $_POST['multiedit_people'] = [];
Line 54: foreach ($_POST['multiedit_people'] as $idx => $data) {
Line 55: if (MultiEdit::recordEmpty($data)) continue;

/sprout/views/dbtools/multimake_template.php   Highlighted file source

Line 18: use Sprout\Helpers\MultiEdit;
Line 27: <div id="multiedit-people">
Line 35: <?php MultiEdit::itemName('Person'); ?>
Line 36: <?php MultiEdit::display('people', $data['multiedit_people']); ?>
Line 42: if (!isset($view->data['multiedit_people'])) {
Line 43: $view->data['multiedit_people'] = MultiEdit::load('user_people', ['user_id' => $item_id], 'record_order');
Line 48: if (!is_array(@$_POST['multiedit_people'])) {
Line 49: $_POST['multiedit_people'] = [];
Line 54: foreach ($_POST['multiedit_people'] as $idx => $data) {
Line 55: if (MultiEdit::recordEmpty($data)) continue;

A total of 174 lines in 22 files were found