Esempio n. 1
0
 /**
  * Build a row based on the item.
  *
  * By default all of the rows are placed into a table by the render
  * method, so this is building up a row suitable for theme('table').
  * This doesn't have to be true if you override both.
  */
 function list_build_row($item, &$form_state, $operations)
 {
     // Set up sorting
     $name = $item->{$this->plugin['export']['key']};
     $schema = ctools_export_get_schema($this->plugin['schema']);
     switch ($form_state['values']['order']) {
         case 'disabled':
             $this->sorts[$name] = empty($item->disabled) . $name;
             break;
         case 'name':
             $this->sorts[$name] = $name;
             break;
         case 'storage':
             $this->sorts[$name] = $item->{$schema['export']['export type string']} . $name;
             break;
     }
     $this->rows[$name]['data'] = array();
     $this->rows[$name]['class'] = !empty($item->disabled) ? array('ctools-export-ui-disabled') : array('ctools-export-ui-enabled');
     $this->rows[$name]['data'][] = array('data' => check_plain($item->name), 'class' => array('ctools-export-ui-name'));
     $this->rows[$name]['data'][] = array('data' => check_plain($item->size), 'class' => array('ctools-export-ui-size'));
     $this->rows[$name]['data'][] = array('data' => check_plain($item->block) ? t('Yes') : t('No'), 'class' => array('ctools-export-ui-block'));
     $this->rows[$name]['data'][] = array('data' => check_plain($item->{$schema['export']['export type string']}), 'class' => array('ctools-export-ui-storage'));
     $ops = theme('links__ctools_dropbutton', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline'))));
     $this->rows[$name]['data'][] = array('data' => $ops, 'class' => array('ctools-export-ui-operations'));
 }
 public function list_build_row($item, &$form_state, $operations)
 {
     // Set up sorting
     $name = $item->name;
     $schema = ctools_export_get_schema($this->plugin['schema']);
     switch ($form_state['values']['order']) {
         case 'disabled':
             $this->sorts[$name] = $item->weight;
             break;
         case 'disabled_title':
             $this->sorts[$name] = empty($item->disabled) . $item->admin_title;
             break;
         case 'title':
             $this->sorts[$name] = $item->admin_title;
             break;
         case 'name':
             $this->sorts[$name] = $name;
             break;
         case 'storage':
             $this->sorts[$name] = $item->{$schema['export']['export type string']} . $name;
             break;
     }
     $ops = theme('links__ctools_dropbutton', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline'))));
     $role_list = $this->buildRoleList($item->role_rids);
     $this->rows[$name] = array('data' => array(array('data' => check_plain($item->admin_title), 'class' => array('ctools-export-ui-title')), array('data' => check_plain($name), 'class' => array('ctools-export-ui-name')), array('data' => check_plain($item->{$schema['export']['export type string']}), 'class' => array('ctools-export-ui-storage')), array('data' => check_plain($role_list), 'class' => array('ctools-export-ui-roles')), array('data' => check_plain($item->weight), 'class' => array('ctools-export-ui-weight')), array('data' => $ops, 'class' => array('ctools-export-ui-operations'))), 'class' => array(!empty($item->disabled) ? 'ctools-export-ui-disabled' : 'ctools-export-ui-enabled'));
 }
 /**
  * Build a row based on the item.
  *
  * By default all of the rows are placed into a table by the render
  * method, so this is building up a row suitable for theme('table').
  * This doesn't have to be true if you override both.
  */
 function list_build_row($item, &$form_state, $operations)
 {
     // Warn users if network id has no value. This can happen immediatly after
     // the module is installed.
     if (variable_get('dfp_network_id', '') == '') {
         drupal_set_message(t('DFP ad tags will not work until you have <a href="/admin/structure/dfp_ads/settings">set your network id</a> as provided by Google.'), 'warning', FALSE);
     }
     // Set up sorting
     $name = $item->{$this->plugin['export']['key']};
     $schema = ctools_export_get_schema($this->plugin['schema']);
     switch ($form_state['values']['order']) {
         case 'disabled':
             $this->sorts[$name] = empty($item->disabled) . $name;
             break;
         case 'name':
             $this->sorts[$name] = $name;
             break;
         case 'storage':
             $this->sorts[$name] = $item->{$schema['export']['export type string']} . $name;
             break;
     }
     $this->rows[$name]['data'] = array();
     $this->rows[$name]['class'] = !empty($item->disabled) ? array('ctools-export-ui-disabled') : array('ctools-export-ui-enabled');
     $this->rows[$name]['data'][] = array('data' => check_plain($item->slot), 'class' => array('ctools-export-ui-slot'));
     $this->rows[$name]['data'][] = array('data' => check_plain($item->size), 'class' => array('ctools-export-ui-size'));
     $this->rows[$name]['data'][] = array('data' => check_plain($item->block) ? t('Yes') : t('No'), 'class' => array('ctools-export-ui-block'));
     $this->rows[$name]['data'][] = array('data' => check_plain($item->{$schema['export']['export type string']}), 'class' => array('ctools-export-ui-storage'));
     $ops = theme('links__ctools_dropbutton', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline'))));
     $this->rows[$name]['data'][] = array('data' => $ops, 'class' => array('ctools-export-ui-operations'));
 }
Esempio n. 4
0
 /**
  * Build a row based on the item.
  *
  * By default all of the rows are placed into a table by the render
  * method, so this is building up a row suitable for theme('table').
  * This doesn't have to be true if you override both.
  */
 public function list_build_row($item, &$form_state, $operations)
 {
     // Set up sorting.
     $name = $item->{$this->plugin['export']['key']};
     $schema = ctools_export_get_schema($this->plugin['schema']);
     list($plugin_manager, $plugin_id) = explode(':', $item->factory_service);
     list($module, $plugin_type) = explode('.', $plugin_manager);
     // Note: $item->{$schema['export']['export type string']} should have
     // already been set up by export.inc so we can use it safely.
     switch ($form_state['values']['order']) {
         case 'disabled':
             $this->sorts[$name] = empty($item->disabled) . $name;
             break;
         case 'title':
             $this->sorts[$name] = $item->{$this->plugin['export']['admin_title']};
             break;
         case 'name':
             $this->sorts[$name] = $name;
             break;
         case 'class':
             $this->sorts[$name] = $name;
             break;
         case 'storage':
             $this->sorts[$name] = $item->{$schema['export']['export type string']} . $name;
             break;
     }
     switch ($item->type) {
         case t('Default'):
         default:
             $type = t('In code');
             break;
         case t('Normal'):
             $type = t('In database');
             break;
         case t('Overridden'):
             $type = t('Database overriding code');
     }
     $this->rows[$name]['data'] = array();
     $this->rows[$name]['class'] = !empty($item->disabled) ? array('ctools-export-ui-disabled') : array('ctools-export-ui-enabled');
     // If we have an admin title, make it the first row.
     if (!empty($this->plugin['export']['admin_title'])) {
         $this->rows[$name]['data'][] = array('data' => check_plain($item->{$this->plugin['export']['admin_title']}), 'class' => array('ctools-export-ui-title'));
     }
     $this->rows[$name]['data'][] = array('data' => check_plain($name), 'class' => array('ctools-export-ui-name'));
     $this->rows[$name]['data'][] = array('data' => check_plain($item->factory_service), 'class' => array('ctools-export-ui-service'));
     $this->rows[$name]['data'][] = array('data' => $type, 'class' => array('ctools-export-ui-storage'));
     $ops = theme('links__ctools_dropbutton', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline'))));
     $this->rows[$name]['data'][] = array('data' => $ops, 'class' => array('ctools-export-ui-operations'));
     // Add an automatic mouseover of the description if one exists.
     if (!empty($this->plugin['export']['admin_description'])) {
         $this->rows[$name]['title'] = $item->{$this->plugin['export']['admin_description']};
     }
 }
Esempio n. 5
0
 /**
  * Build a row based on the item.
  *
  * By default all of the rows are placed into a table by the render
  * method, so this is building up a row suitable for theme('table').
  * This doesn't have to be true if you override both.
  */
 public function list_build_row($item, &$form_state, $operations)
 {
     // Set up sorting.
     $name = $item->{$this->plugin['export']['key']};
     $schema = ctools_export_get_schema($this->plugin['schema']);
     list($plugin_manager, $plugin_id) = explode(':', $item->factory_service);
     list($module, $plugin_type) = explode('.', $plugin_manager);
     $object = \Drupal\openlayers\Openlayers::load($plugin_type, $item->machine_name);
     // Note: $item->{$schema['export']['export type string']} should have
     // already been set up by export.inc so we can use it safely.
     switch ($form_state['values']['order']) {
         case 'disabled':
             $this->sorts[$name] = empty($item->disabled) . $name;
             break;
         case 'title':
             $this->sorts[$name] = $item->{$this->plugin['export']['admin_title']};
             break;
         case 'name':
             $this->sorts[$name] = $name;
             break;
         case 'class':
             $this->sorts[$name] = $name;
             break;
         case 'storage':
             $this->sorts[$name] = $item->{$schema['export']['export type string']} . $name;
             break;
     }
     // Generate a map and use the style on it to make a preview.
     $map = Openlayers::load('map', 'openlayers_ui_map_style_demo');
     foreach ($map->getCollection()->getFlatList(array('layer')) as $layer) {
         $layer->setStyle($object);
         $map->getCollection()->import(array($layer));
     }
     $map_build = $map->build();
     $map_render = drupal_render($map_build);
     $this->rows[$name]['data'] = array();
     $this->rows[$name]['class'] = !empty($item->disabled) ? array('ctools-export-ui-disabled') : array('ctools-export-ui-enabled');
     $this->rows[$name]['data'][] = array('data' => $map_render, 'class' => array('ctools-export-ui-title'));
     // If we have an admin title, make it the first row.
     if (!empty($this->plugin['export']['admin_title'])) {
         $this->rows[$name]['data'][] = array('data' => check_plain($item->{$this->plugin['export']['admin_title']}), 'class' => array('ctools-export-ui-title'));
     }
     $this->rows[$name]['data'][] = array('data' => check_plain($name), 'class' => array('ctools-export-ui-name'));
     $this->rows[$name]['data'][] = array('data' => check_plain($item->factory_service), 'class' => array('ctools-export-ui-service'));
     $this->rows[$name]['data'][] = array('data' => check_plain($item->{$schema['export']['export type string']}), 'class' => array('ctools-export-ui-storage'));
     $ops = theme('links__ctools_dropbutton', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline'))));
     $this->rows[$name]['data'][] = array('data' => $ops, 'class' => array('ctools-export-ui-operations'));
     // Add an automatic mouseover of the description if one exists.
     if (!empty($this->plugin['export']['admin_description'])) {
         $this->rows[$name]['title'] = $item->{$this->plugin['export']['admin_description']};
     }
 }
Esempio n. 6
0
 /**
  * Save the picture mapping.
  *
  * @return
  *   If the record insert or update failed, returns FALSE. If it succeeded,
  *   returns SAVED_NEW or SAVED_UPDATED, depending on the operation performed.
  */
 public function save()
 {
     $update = array();
     $this->cleanMappings();
     $data = $this->toArray();
     if (isset($this->id) && $this->id) {
         $update = array('id');
         $data['id'] = $this->id;
     }
     $return = drupal_write_record('picture_mapping', $data, $update);
     $this->setValues(ctools_export_get_schema('picture_mapping'), $data);
     $this->loadBreakpointGroup();
     return $return;
 }
 /**
  * Build a row based on the item.
  *
  * By default all of the rows are placed into a table by the render
  * method, so this is building up a row suitable for theme('table').
  * This doesn't have to be true if you override both.
  */
 function list_build_row($item, &$form_state, $operations)
 {
     // Set up sorting
     $name = $item->{$this->plugin['export']['key']};
     $schema = ctools_export_get_schema($this->plugin['schema']);
     // Note: $item->{$schema['export']['export type string']} should have already been set up by export.inc so
     // we can use it safely.
     switch ($form_state['values']['order']) {
         case 'disabled':
             $this->sorts[$name] = empty($item->disabled) . $name;
             break;
         case 'title':
             $this->sorts[$name] = $item->{$this->plugin['export']['admin_title']};
             break;
         case 'name':
             $this->sorts[$name] = $name;
             break;
         case 'storage':
             $this->sorts[$name] = $item->{$schema['export']['export type string']} . $name;
             break;
     }
     $this->rows[$name]['data'] = array();
     $this->rows[$name]['class'] = !empty($item->disabled) ? array('ctools-export-ui-disabled') : array('ctools-export-ui-enabled');
     // If we have an admin title, make it the first row.
     if (!empty($this->plugin['export']['admin_title'])) {
         $this->rows[$name]['data'][] = array('data' => check_plain($item->{$this->plugin['export']['admin_title']}), 'class' => array('ctools-export-ui-title'));
     }
     $layers_types = openlayers_layer_types();
     $this->rows[$name]['data'][] = array('data' => $item->title, 'class' => array('ctools-export-ui-title'));
     $this->rows[$name]['data'][] = array('data' => $layers_types[$item->data['layer_type']]['title'], 'class' => array('ctools-export-ui-layer-type'));
     $this->rows[$name]['data'][] = array('data' => $item->description, 'class' => array('ctools-export-ui-description'));
     $this->rows[$name]['data'][] = array('data' => check_plain($item->{$schema['export']['export type string']}), 'class' => array('ctools-export-ui-storage'));
     // This should be in the module openlayers_views, but I'm still looking
     // for a solution to do it properly.
     if ($item->data['layer_type'] == 'openlayers_views_vector') {
         $operations['edit']['href'] = 'admin/structure/views/view/' . $item->data['views']['view'] . '/edit/' . $item->data['views']['display'];
         $operations['disable']['href'] = 'admin/structure/views/view/' . $item->data['views']['view'] . '/disable/' . $item->data['views']['display'];
         $operations['clone']['href'] = 'admin/structure/views/view/' . $item->data['views']['view'] . '/clone/' . $item->data['views']['display'];
         $operations['export']['href'] = 'admin/structure/views/view/' . $item->data['views']['view'] . '/export/' . $item->data['views']['display'];
     }
     $ops = theme('links__ctools_dropbutton', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline'))));
     $this->rows[$name]['data'][] = array('data' => $ops, 'class' => array('ctools-export-ui-operations'));
     // Add an automatic mouseover of the description if one exists.
     if (!empty($this->plugin['export']['admin_description'])) {
         $this->rows[$name]['title'] = $item->{$this->plugin['export']['admin_description']};
     }
 }
 /**
  * Build a row based on the item.
  *
  * By default all of the rows are placed into a table by the render
  * method, so this is building up a row suitable for theme('table').
  * This doesn't have to be true if you override both.
  */
 function list_build_row($item, &$form_state, $operations)
 {
     // Set up sorting
     $name = $item->{$this->plugin['export']['key']};
     $schema = ctools_export_get_schema($this->plugin['schema']);
     dsm($item);
     $instance = is_object($item->data) ? $item->data : (object) unserialize($item->data);
     $visibility = array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.'));
     $pages = $instance->pages != substr($instance->pages, 0, 40) ? substr($instance->pages, 0, 40) . '...' : substr($instance->pages, 0, 40);
     // Note: $item->{$schema['export']['export type string']} should have already been set up by export.inc so
     // we can use it safely.
     switch ($form_state['values']['order']) {
         case 'disabled':
             $this->sorts[$name] = empty($item->disabled) . $name;
             break;
         case 'title':
             $this->sorts[$name] = $item->{$this->plugin['export']['admin_title']};
             break;
         case 'name':
             $this->sorts[$name] = $name;
             break;
         case 'storage':
             $this->sorts[$name] = $item->{$schema['export']['export type string']} . $name;
             break;
     }
     $this->rows[$name]['data'] = array();
     $this->rows[$name]['class'] = !empty($item->disabled) ? array('ctools-export-ui-disabled') : array('ctools-export-ui-enabled');
     // If we have an admin title, make it the first row.
     if (!empty($this->plugin['export']['admin_title'])) {
         $this->rows[$name]['data'][] = array('data' => check_plain($item->{$this->plugin['export']['admin_title']}), 'class' => array('ctools-export-ui-title'));
     }
     $this->rows[$name]['data'][] = array('data' => check_plain($name), 'class' => array('ctools-export-ui-name'));
     $this->rows[$name]['data'][] = array('data' => check_plain($item->{$schema['export']['export type string']}), 'class' => array('ctools-export-ui-storage'));
     $ops = theme('links__ctools_dropbutton', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline'))));
     // Show element, style, visibility and pages.
     $this->rows[$name]['data'][] = array('data' => check_plain($instance->element));
     $this->rows[$name]['data'][] = array('data' => check_plain($instance->style));
     $this->rows[$name]['data'][] = array('data' => $visibility[$instance->visibility]);
     $this->rows[$name]['data'][] = array('data' => check_plain($pages));
     $this->rows[$name]['data'][] = array('data' => $ops, 'class' => array('ctools-export-ui-operations'));
     // Add an automatic mouseover of the description if one exists.
     if (!empty($this->plugin['export']['admin_description'])) {
         $this->rows[$name]['title'] = $item->{$this->plugin['export']['admin_description']};
     }
 }
 /**
  * Build a row based on the item.
  *
  * By default all of the rows are placed into a table by the render
  * method, so this is building up a row suitable for theme('table').
  * This doesn't have to be true if you override both.
  */
 function list_build_row($item, &$form_state, $operations)
 {
     // Set up sorting
     $name = $item->{$this->plugin['export']['key']};
     $schema = ctools_export_get_schema($this->plugin['schema']);
     // Load Custom Formatters engines.
     $engines = module_invoke_all('custom_formatters_engine_info');
     // Hide Formatters using missing engines.
     if (!isset($engines[$item->mode])) {
         unset($this->row);
         return;
     }
     // Note: $item->{$schema['export']['export type string']} should have already been set up by export.inc so
     // we can use it safely.
     switch ($form_state['values']['order']) {
         case 'disabled':
             $this->sorts[$name] = empty($item->disabled) . $name;
             break;
         case 'title':
             $this->sorts[$name] = $item->{$this->plugin['export']['admin_title']};
             break;
         case 'name':
             $this->sorts[$name] = $name;
             break;
         case 'storage':
             $this->sorts[$name] = $item->{$schema['export']['export type string']} . $name;
             break;
     }
     $this->rows[$name]['data'] = array();
     $this->rows[$name]['class'] = !empty($item->disabled) ? array('ctools-export-ui-disabled') : array('ctools-export-ui-enabled');
     // If we have an admin title, make it the first row.
     if (!empty($this->plugin['export']['admin_title'])) {
         $this->rows[$name]['data'][] = array('data' => check_plain($item->{$this->plugin['export']['admin_title']}), 'class' => array('ctools-export-ui-title'));
     }
     $this->rows[$name]['data'][] = array('data' => check_plain($name), 'class' => array('ctools-export-ui-name'));
     $this->rows[$name]['data'][] = array('data' => check_plain($engines[$item->mode]['label']), 'class' => array('ctools-export-ui-format'));
     $this->rows[$name]['data'][] = array('data' => !empty($item->fapi) && drupal_strlen($item->fapi) > 17 ? t('Yes') : t('No'), 'class' => array('ctools-export-ui-fapi'));
     $this->rows[$name]['data'][] = array('data' => check_plain($item->{$schema['export']['export type string']}), 'class' => array('ctools-export-ui-storage'));
     $ops = theme('links__ctools_dropbutton', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline'))));
     $this->rows[$name]['data'][] = array('data' => $ops, 'class' => array('ctools-export-ui-operations'));
     // Add an automatic mouseover of the description if one exists.
     if (!empty($this->plugin['export']['admin_description'])) {
         $this->rows[$name]['title'] = $item->{$this->plugin['export']['admin_description']};
     }
 }
 /**
  * Build a row based on the item.
  *
  * By default all of the rows are placed into a table by the render
  * method, so this is building up a row suitable for theme('table').
  * This doesn't have to be true if you override both.
  */
 function list_build_row($item, &$form_state, $operations)
 {
     // Set up sorting
     $name = $item->{$this->plugin['export']['key']};
     $schema = ctools_export_get_schema($this->plugin['schema']);
     // Note: $item->{$schema['export']['export type string']} should have already been set up by export.inc so
     // we can use it safely.
     switch ($form_state['values']['order']) {
         case 'disabled':
             $this->sorts[$name] = empty($item->disabled) . $name;
             break;
         case 'title':
             $this->sorts[$name] = $item->{$this->plugin['export']['admin_title']};
             break;
         case 'name':
             $this->sorts[$name] = $name;
             break;
         case 'storage':
             $this->sorts[$name] = $item->{$schema['export']['export type string']} . $name;
             break;
     }
     $this->rows[$name]['data'] = array();
     $this->rows[$name]['class'] = !empty($item->disabled) ? array('ctools-export-ui-disabled') : array('ctools-export-ui-enabled');
     // Add the icon as an image in the row if it exists.
     if (isset($item->data['externalGraphic'])) {
         $style = theme('image', array('path' => $item->data['externalGraphic']));
     } else {
         $style = openlayers_ui_style_preview($item);
     }
     $this->rows[$name]['data'][] = array('data' => $style, 'class' => array('ctools-export-ui-preview'));
     // If we have an admin title, make it the first row.
     if (!empty($this->plugin['export']['admin_title'])) {
         $this->rows[$name]['data'][] = array('data' => check_plain($item->{$this->plugin['export']['admin_title']}), 'class' => array('ctools-export-ui-title'));
     }
     $this->rows[$name]['data'][] = array('data' => $item->title, 'class' => array('ctools-export-ui-title'));
     $this->rows[$name]['data'][] = array('data' => $item->description, 'class' => array('ctools-export-ui-description'));
     $this->rows[$name]['data'][] = array('data' => check_plain($item->{$schema['export']['export type string']}), 'class' => array('ctools-export-ui-storage'));
     $ops = theme('links__ctools_dropbutton', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline'))));
     $this->rows[$name]['data'][] = array('data' => $ops, 'class' => array('ctools-export-ui-operations'));
     // Add an automatic mouseover of the description if one exists.
     if (!empty($this->plugin['export']['admin_description'])) {
         $this->rows[$name]['title'] = $item->{$this->plugin['export']['admin_description']};
     }
 }
 /**
  * Build a row based on the item.
  *
  * By default all of the rows are placed into a table by the render
  * method, so this is building up a row suitable for theme('table').
  * This doesn't have to be true if you override both.
  */
 function list_build_row($item, &$form_state, $operations)
 {
     // Set up sorting
     $name = $item->{$this->plugin['export']['key']};
     $schema = ctools_export_get_schema($this->plugin['schema']);
     // Note: $item->{$schema['export']['export type string']} should have already been set up by export.inc so
     // we can use it safely.
     switch ($form_state['values']['order']) {
         case 'disabled':
             $this->sorts[$name] = empty($item->disabled) . $name;
             break;
         case 'title':
             $this->sorts[$name] = $item->{$this->plugin['export']['admin_title']};
             break;
         case 'name':
             $this->sorts[$name] = $name;
             break;
         case 'storage':
             $this->sorts[$name] = $item->{$schema['export']['export type string']} . $name;
             break;
     }
     $this->rows[$name]['data'] = array();
     $this->rows[$name]['class'] = !empty($item->disabled) ? array('ctools-export-ui-disabled') : array('ctools-export-ui-enabled');
     // If we have an admin title, make it the first row.
     if (!empty($this->plugin['export']['admin_title'])) {
         $this->rows[$name]['data'][] = array('data' => check_plain($item->{$this->plugin['export']['admin_title']}), 'class' => array('ctools-export-ui-title'));
     }
     $layers = openlayers_layers_load();
     foreach ($item->data['layers'] as $layer) {
         $layers_names[] = empty($layers[$layer]->title) ? $layer : filter_xss_admin($layers[$layer]->title);
     }
     sort($layers_names);
     $layers_names = implode(',', $layers_names);
     $this->rows[$name]['data'][] = array('data' => $item->title, 'class' => array('ctools-export-ui-title'));
     $this->rows[$name]['data'][] = array('data' => $layers_names, 'class' => array('ctools-export-ui-layers'));
     $this->rows[$name]['data'][] = array('data' => $item->description, 'class' => array('ctools-export-ui-description'));
     $this->rows[$name]['data'][] = array('data' => check_plain($item->{$schema['export']['export type string']}), 'class' => array('ctools-export-ui-storage'));
     $ops = theme('links__ctools_dropbutton', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline'))));
     $this->rows[$name]['data'][] = array('data' => $ops, 'class' => array('ctools-export-ui-operations'));
     // Add an automatic mouseover of the description if one exists.
     if (!empty($this->plugin['export']['admin_description'])) {
         $this->rows[$name]['title'] = $item->{$this->plugin['export']['admin_description']};
     }
 }
 /**
  * Build a row based on the item.
  *
  * By default all of the rows are placed into a table by the render
  * method, so this is building up a row suitable for theme('table').
  * This doesn't have to be true if you override both.
  */
 function list_build_row($item, &$form_state, $operations)
 {
     // Set up sorting
     $name = $item->{$this->plugin['export']['key']};
     $schema = ctools_export_get_schema($this->plugin['schema']);
     // Note: $item->{$schema['export']['export type string']} should have already been set up by export.inc so
     // we can use it safely.
     switch ($form_state['values']['order']) {
         case 'disabled':
             $this->sorts[$name] = empty($item->disabled) . $name;
             break;
         case 'title':
             $this->sorts[$name] = $item->{$this->plugin['export']['admin_title']};
             break;
         case 'name':
             $this->sorts[$name] = $name;
             break;
         case 'weight':
             $this->sorts[$name] = $item->weight;
             break;
         case 'storage':
             $this->sorts[$name] = $item->{$schema['export']['export type string']} . $name;
             break;
     }
     $this->rows[$name]['data'] = array();
     // Add the draggable class.
     $this->rows[$name]['class'] = array('draggable');
     $this->rows[$name]['class'][] = !empty($item->disabled) ? 'ctools-export-ui-disabled' : 'ctools-export-ui-enabled';
     // If we have an admin title, make it the first row.
     if (!empty($this->plugin['export']['admin_title'])) {
         $this->rows[$name]['data'][] = array('data' => check_plain($item->{$this->plugin['export']['admin_title']}), 'class' => array('ctools-export-ui-title'));
     }
     $this->rows[$name]['data'][] = array('data' => check_plain($name), 'class' => array('ctools-export-ui-name'));
     $this->rows[$name]['data'][] = array('data' => check_plain($item->{$schema['export']['export type string']}), 'class' => array('ctools-export-ui-storage'));
     $ops = theme('links__ctools_dropbutton', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline'))));
     // Add the order column. This is only a placeholder replaced later in the form theme function.
     $this->rows[$name]['data'][] = array('data' => check_plain($item->weight));
     $this->rows[$name]['data'][] = array('data' => $ops, 'class' => array('ctools-export-ui-operations'));
     // Add an automatic mouseover of the description if one exists.
     if (!empty($this->plugin['export']['admin_description'])) {
         $this->rows[$name]['title'] = $item->{$this->plugin['export']['admin_description']};
     }
 }
 /**
  * Build a row based on the item.
  *
  * By default all of the rows are placed into a table by the render
  * method, so this is building up a row suitable for theme('table').
  * This doesn't have to be true if you override both.
  */
 function list_build_row($item, &$form_state, $operations)
 {
     // Set up sorting
     $name = $item->{$this->plugin['export']['key']};
     $schema = ctools_export_get_schema($this->plugin['schema']);
     // Note: $item->{$schema['export']['export type string']} should have already been set up by export.inc so
     // we can use it safely.
     switch ($form_state['values']['order']) {
         case 'disabled':
             $this->sorts[$name] = empty($item->disabled) . $name;
             break;
         case 'title':
             $this->sorts[$name] = $item->{$this->plugin['export']['admin_title']};
             break;
         case 'name':
             $this->sorts[$name] = $name;
             break;
         case 'storage':
             $this->sorts[$name] = $item->{$schema['export']['export type string']} . $name;
             break;
     }
     $this->rows[$name]['data'] = array();
     $this->rows[$name]['class'] = !empty($item->disabled) ? array('ctools-export-ui-disabled') : array('ctools-export-ui-enabled');
     // If we have an admin title, make it the first row.
     if (!empty($this->plugin['export']['admin_title'])) {
         $this->rows[$name]['data'][] = array('data' => check_plain($item->{$this->plugin['export']['admin_title']}), 'class' => array('ctools-export-ui-title'));
     }
     $this->rows[$name]['data'][] = array('data' => check_plain($name), 'class' => array('ctools-export-ui-name'));
     $this->rows[$name]['data'][] = array('data' => check_plain($item->{$schema['export']['export type string']}), 'class' => array('ctools-export-ui-storage'));
     // To display whether this has any description
     $snippet = $this->load_item($name);
     $label = "No";
     if ($snippet->rid) {
         $label = 'Yes';
     }
     $this->rows[$name]['data'][] = array('data' => $label, 'class' => array('ctools-export-ui-title'));
     // short down the list of operation as per permission
     $snippet_operations = array();
     foreach ($operations as $key => $value) {
         $do_list = $key == 'enable' || $key == 'disable' ? TRUE : $this->access($key, $item);
         if ($do_list) {
             $snippet_operations[$key] = $value;
         }
     }
     $ops = theme('links__ctools_dropbutton', array('links' => $snippet_operations, 'attributes' => array('class' => array('links', 'inline'))));
     $this->rows[$name]['data'][] = array('data' => $ops, 'class' => array('ctools-export-ui-operations'));
     // Add an automatic mouseover of the description if one exists.
     if (!empty($this->plugin['export']['admin_description'])) {
         $this->rows[$name]['title'] = $item->{$this->plugin['export']['admin_description']};
     }
 }
 /**
  * Handle the submission of the edit form.
  *
  * At this point, submission is successful. Our only responsibility is
  * to copy anything out of values onto the item that we are able to edit.
  *
  * If the keys all match up to the schema, this method will not need to be
  * overridden.
  */
 function edit_form_submit(&$form, &$form_state)
 {
     if (!empty($this->plugin['form']['submit'])) {
         // Pass $form by reference.
         $this->plugin['form']['submit']($form, $form_state);
     }
     // Transfer data from the form to the $item based upon schema values.
     $schema = ctools_export_get_schema($this->plugin['schema']);
     foreach (array_keys($schema['fields']) as $key) {
         if (isset($form_state['values'][$key])) {
             $form_state['item']->{$key} = $form_state['values'][$key];
         }
     }
 }
 /**
  * Submit the filter/sort form.
  *
  * This submit handler is actually responsible for building up all of the
  * rows that will later be rendered, since it is doing the filtering and
  * sorting.
  *
  * For the most part, you should not need to override this method, as the
  * fiddly bits call through to other functions.
  */
 function list_form_submit(&$form, &$form_state)
 {
     // Filter and re-sort the pages.
     $plugin = $this->plugin;
     $schema = ctools_export_get_schema($this->plugin['schema']);
     $prefix = ctools_export_ui_plugin_base_path($plugin);
     foreach ($this->items as $name => $item) {
         // Call through to the filter and see if we're going to render this
         // row. If it returns TRUE, then this row is filtered out.
         if ($this->list_filter($form_state, $item)) {
             continue;
         }
         // Note: Creating this list seems a little clumsy, but can't think of
         // better ways to do this.
         $allowed_operations = drupal_map_assoc(array_keys($plugin['allowed operations']));
         //Cannot find the code that returns the list of possible operations, so I'm going to add extras here, which is not neat.
         //$allowed_operations['edit terms'] = 'edit terms';
         $not_allowed_operations = array('import');
         if ($item->{$schema['export']['export type string']} == t('Normal')) {
             $not_allowed_operations[] = 'revert';
         } elseif ($item->{$schema['export']['export type string']} == t('Overridden')) {
             $not_allowed_operations[] = 'delete';
         } else {
             $not_allowed_operations[] = 'revert';
             $not_allowed_operations[] = 'delete';
         }
         //$not_allowed_operations[] = empty($item->disabled) ? 'enable' : 'disable';
         //Forcing 'disable' and 'enable' to be disabled always. This should be done in the install schema with 'can disable' => FALSE, but that would
         //mean reinstalling the module and I don't think it works properly.
         $not_allowed_operations[] = 'disable';
         $not_allowed_operations[] = 'enable';
         foreach ($not_allowed_operations as $op) {
             // Remove the operations that are not allowed for the specific
             // exportable.
             unset($allowed_operations[$op]);
         }
         $operations = array();
         foreach ($allowed_operations as $op) {
             $operations[$op] = array('title' => $plugin['allowed operations'][$op]['title'], 'href' => ctools_export_ui_plugin_menu_path($plugin, $op, $name));
             if (!empty($plugin['allowed operations'][$op]['ajax'])) {
                 $operations[$op]['attributes'] = array('class' => array('use-ajax'));
             }
             if (!empty($plugin['allowed operations'][$op]['token'])) {
                 $operations[$op]['query'] = array('token' => drupal_get_token($op));
             }
         }
         $this->list_build_row($item, $form_state, $operations);
     }
     // Now actually sort
     if ($form_state['values']['sort'] == 'desc') {
         arsort($this->sorts);
     } else {
         asort($this->sorts);
     }
     // Nuke the original.
     $rows = $this->rows;
     $this->rows = array();
     // And restore.
     foreach ($this->sorts as $name => $title) {
         $this->rows[$name] = $rows[$name];
     }
 }
 /**
  * Provide the actual editing form.
  */
 function edit_form(&$form, &$form_state)
 {
     $export_key = $this->plugin['export']['key'];
     $item = $form_state['item'];
     $schema = ctools_export_get_schema($this->plugin['schema']);
     if (!empty($this->plugin['export']['admin_title'])) {
         $form['info'][$this->plugin['export']['admin_title']] = array('#type' => 'textfield', '#title' => t('Title'), '#default_value' => $item->{$this->plugin['export']['admin_title']});
     }
     $form['info'][$export_key] = array('#title' => t($schema['export']['key name']), '#type' => 'textfield', '#default_value' => $item->{$export_key}, '#description' => t('The unique ID for this @export.', array('@export' => $this->plugin['title singular'])), '#required' => TRUE, '#maxlength' => 255);
     if (!empty($this->plugin['export']['admin_title'])) {
         $form['info'][$export_key]['#type'] = 'machine_name';
         $form['info'][$export_key]['#machine_name'] = array('exists' => 'ctools_export_ui_edit_name_exists', 'source' => array('info', $this->plugin['export']['admin_title']));
     }
     if ($form_state['op'] === 'edit') {
         $form['info'][$export_key]['#disabled'] = TRUE;
         $form['info'][$export_key]['#value'] = $item->{$export_key};
     }
     if (!empty($this->plugin['export']['admin_description'])) {
         $form['info'][$this->plugin['export']['admin_description']] = array('#type' => 'textarea', '#title' => t('Description'), '#default_value' => $item->{$this->plugin['export']['admin_description']});
     }
     // Add plugin's form definitions.
     if (!empty($this->plugin['form']['settings'])) {
         // Pass $form by reference.
         $this->plugin['form']['settings']($form, $form_state);
     }
     // Add the buttons if the wizard is not in use.
     if (empty($form_state['form_info'])) {
         // Make sure that whatever happens, the buttons go to the bottom.
         $form['buttons']['#weight'] = 100;
         // Add buttons.
         $form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Save'));
         $form['buttons']['delete'] = array('#type' => 'submit', '#value' => $item->export_type & EXPORT_IN_CODE ? t('Revert') : t('Delete'), '#access' => $form_state['op'] === 'edit' && $item->export_type & EXPORT_IN_DATABASE, '#submit' => array('ctools_export_ui_edit_item_form_delete'));
     }
 }
 /**
  * Build a row based on the item.
  *
  * By default all of the rows are placed into a table by the render
  * method, so this is building up a row suitable for theme('table').
  * This doesn't have to be true if you override both.
  */
 public function list_build_row($item, &$form_state, $operations)
 {
     // Set up sorting.
     $name = $item->{$this->plugin['export']['key']};
     $schema = ctools_export_get_schema($this->plugin['schema']);
     // Started and duration.
     $item->lock_id = isset($item->lock_id) ? $item->lock_id : $item->isLocked();
     $item->log_entry = isset($item->log_entry) ? $item->log_entry : $item->loadLatestLogEntry();
     $item->progress = isset($item->progress) ? $item->progress : $item->getProgress();
     if ($item->log_entry->lid && $item->lock_id && $item->log_entry->lid !== $item->lock_id) {
         $item->log_entry = $item->loadLogEntry($item->lock_id);
     }
     // Note: $item->{$schema['export']['export type string']} should have
     // already been set up by export.inc so we can use it safely.
     switch ($form_state['values']['order']) {
         case 'disabled':
             $this->rows[$name]['sort'] = array((int) (!empty($item->disabled)), $item->getModuleName(), empty($this->plugin['export']['admin_title']) ? $name : $item->{$this->plugin['export']['admin_title']});
             break;
         case 'title':
             $this->rows[$name]['sort'] = array($item->{$this->plugin['export']['admin_title']});
             break;
         case 'start_time':
             $this->rows[$name]['sort'] = array($item->log_entry->start_time);
             break;
         case 'duration':
             $this->rows[$name]['sort'] = array($item->log_entry->getDuration());
             break;
         case 'storage':
             $this->rows[$name]['sort'] = array($item->{$schema['export']['export type string']} . $name);
             break;
     }
     // Setup row.
     $this->rows[$name]['id'] = $name;
     $this->rows[$name]['data'] = array();
     // Enabled/disabled.
     $this->rows[$name]['class'] = !empty($item->disabled) ? array('ctools-export-ui-disabled') : array('ctools-export-ui-enabled');
     // Module.
     $this->rows[$name]['data'][] = array('data' => check_plain($item->getModuleName()), 'class' => array('ctools-export-ui-module'), 'title' => strip_tags($item->getModuleDescription()));
     // If we have an admin title, make it the first row.
     if (!empty($this->plugin['export']['admin_title'])) {
         $this->rows[$name]['data'][] = array('data' => check_plain($item->{$this->plugin['export']['admin_title']}), 'class' => array('ctools-export-ui-title'), 'title' => strip_tags($item->name));
     }
     // Schedule settings.
     $label = $item->getPlugin('scheduler')->formatLabel($item);
     $label = str_replace("\n", '<br/>', $label);
     if ($behind = $item->isBehindSchedule()) {
         $this->jobs_behind++;
         $label = "<em>{$label}</em><br/>" . format_interval($behind) . ' ' . t('behind schedule');
     }
     $this->rows[$name]['data'][] = array('data' => $label, 'class' => array('ctools-export-ui-scheduled'), 'title' => strip_tags($item->getPlugin('scheduler')->formatLabelVerbose($item)));
     $this->rows[$name]['data'][] = array('data' => $item->log_entry->formatStartTime(), 'class' => array('ctools-export-ui-start-time'), 'title' => strip_tags($item->log_entry->formatInitMessage()));
     $progress = $item->lock_id ? $item->formatProgress() : '';
     $this->rows[$name]['data'][] = array('data' => '<span class="duration-time" data-src="' . $item->log_entry->getDuration() . '">' . $item->log_entry->formatDuration() . '</span> <span class="duration-progress">' . $progress . '</span>', 'class' => array('ctools-export-ui-duration'), 'title' => strip_tags($item->log_entry->formatEndTime()));
     // Status.
     if ($item->lock_id && $item->log_entry->lid == $item->lock_id) {
         list($status, $title) = $item->getPlugin('launcher')->formatRunning($item);
     } elseif ($item->log_entry->start_time && !$item->log_entry->end_time) {
         list($status, $title) = $item->getPlugin('launcher')->formatUnfinished($item);
     } else {
         list($status, $title) = $item->log_entry->formatSeverity();
         $title = $item->log_entry->message ? $item->log_entry->message : $title;
     }
     $this->rows[$name]['data'][] = array('data' => $status, 'class' => array('ctools-export-ui-status'), 'title' => strip_tags($title));
     // Storage.
     $this->rows[$name]['data'][] = array('data' => check_plain($item->{$schema['export']['export type string']}), 'class' => array('ctools-export-ui-storage'));
     // Operations.
     $ops = theme('links__ctools_dropbutton', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline'))));
     $this->rows[$name]['data'][] = array('data' => $ops, 'class' => array('ctools-export-ui-operations'));
     // Add an automatic mouseover of the description if one exists.
     if (!empty($this->plugin['export']['admin_description'])) {
         $this->rows[$name]['title'] = strip_tags($item->{$this->plugin['export']['admin_description']});
     }
 }
 /**
  * Provide the actual editing form.
  */
 function edit_form(&$form, &$form_state)
 {
     $export_key = $this->plugin['export']['key'];
     $item = $form_state['item'];
     $schema = ctools_export_get_schema($this->plugin['schema']);
     if (!empty($this->plugin['export']['admin_title'])) {
         $form['info'][$this->plugin['export']['admin_title']] = array('#type' => 'textfield', '#title' => t('Administrative title'), '#description' => t('This will appear in the administrative interface to easily identify it.'), '#default_value' => $item->{$this->plugin['export']['admin_title']});
     }
     $form['info'][$export_key] = array('#title' => t($schema['export']['key name']), '#type' => 'textfield', '#default_value' => $item->{$export_key}, '#description' => t('The unique ID for this @export.', array('@export' => $this->plugin['title singular'])), '#required' => TRUE, '#maxlength' => 255);
     if (!empty($this->plugin['export']['admin_title'])) {
         $form['info'][$export_key]['#type'] = 'machine_name';
         $form['info'][$export_key]['#machine_name'] = array('exists' => 'ctools_export_ui_edit_name_exists', 'source' => array('info', $this->plugin['export']['admin_title']));
     }
     if ($form_state['op'] === 'edit') {
         $form['info'][$export_key]['#disabled'] = TRUE;
         $form['info'][$export_key]['#value'] = $item->{$export_key};
     }
     if (!empty($this->plugin['export']['admin_description'])) {
         $form['info'][$this->plugin['export']['admin_description']] = array('#type' => 'textarea', '#title' => t('Administrative description'), '#default_value' => $item->{$this->plugin['export']['admin_description']});
     }
     // Add the buttons if the wizard is not in use.
     if (empty($form_state['form_info'])) {
         // Add buttons.
         $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save'));
         // Cancel buttons.
         $form['actions']['cancel'] = array('#type' => 'submit', '#value' => t('Cancel'));
     }
     // Add plugin's form definitions.
     if (!empty($this->plugin['form']['settings'])) {
         // Pass $form by reference.
         $this->plugin['form']['settings']($form, $form_state);
     }
 }