View source
<?php
global $base_url;
require_once realpath('./') . '/' . drupal_get_path('module', 'sgrid') . '/sgrid_theme.inc';
function sgrid_views_api() {
return array(
'api' => 3.0,
);
}
function sgrid_perm() {
return array(
'sort Sortable Grid Views',
);
}
function form_save_order($form, $viewname) {
$form = array();
$form['viewdisplay'] = array(
'#type' => 'hidden',
'#value' => $viewname,
);
$form['itemsorder'] = array(
'#type' => 'textfield',
'#maxlength' => 1000,
'#attributes' => array(
'class' => 'sortorder',
),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save order'),
);
return $form;
}
function form_save_order_submit($form, $form_state) {
db_query("DELETE FROM {sgrid} WHERE view_display = '%s'", $form_state['values']['viewdisplay']);
foreach (explode(',', $form_state['values']['itemsorder']) as $index => $name) {
$nid = substr(strrchr($name, '_'), 1);
db_query("INSERT INTO {sgrid} (nid, rank, view_display) VALUES (%d, %d, '%s')", $nid, $index, $form_state['values']['viewdisplay']);
}
}