type = 'storm_attribute'; $header = array( array( 'data' => t('Domain'), 'field' => 'domain', ), array( 'data' => t('Key'), 'field' => 'akey', ), array( 'data' => t('Value'), 'field' => 'avalue', ), array( 'data' => t('Active'), ), array( 'data' => t('Default'), ), array( 'data' => t('Weight'), 'field' => 'weight', 'sort' => 'asc', ), array( 'data' => storm_icon_add('attributes/add', $i, $_GET), 'class' => 'storm_list_operations', ), ); $s = "SELECT * FROM {stormattribute}"; $where = array(); $args = array(); $filterfields = array(); if (isset($_SESSION['stormattribute_list_filter']['domain']) && $_SESSION['stormattribute_list_filter']['domain'] != '') { $where[] = "domain='%s'"; $args[] = $_SESSION['stormattribute_list_filter']['domain']; $filterfields[] = t('Domain'); } if (isset($_SESSION['stormattribute_list_filter']['akey']) && $_SESSION['stormattribute_list_filter']['akey'] != '') { $where[] = "LOWER(akey) LIKE LOWER('%s')"; $args[] = $_SESSION['stormattribute_list_filter']['akey']; $filterfields[] = t('Key'); } if (isset($_SESSION['stormattribute_list_filter']['avalue']) && $_SESSION['stormattribute_list_filter']['avalue'] != '') { $where[] = "LOWER(avalue) LIKE LOWER('%s')"; $args[] = $_SESSION['stormattribute_list_filter']['avalue']; $filterfields[] = t('Value'); } if (isset($_SESSION['stormattribute_list_filter']['isactive']) && ($_SESSION['stormattribute_list_filter']['isactive'] != '-')) { $where[] = "isactive = %d"; $args[] = $_SESSION['stormattribute_list_filter']['isactive']; $filterfields[] = t('Active'); } if (isset($_SESSION['stormattribute_list_filter']['isdefault']) && ($_SESSION['stormattribute_list_filter']['isdefault'] != '-')) { $where[] = "isdefault = %d"; $args[] = $_SESSION['stormattribute_list_filter']['isdefault']; $filterfields[] = t('Default'); } $itemsperpage = isset($_SESSION['stormattribute_list_filter']['itemsperpage']) ? $_SESSION['stormattribute_list_filter']['itemsperpage'] : variable_get('storm_default_items_per_page', 10); $tablesort = tablesort_sql($header); if (count($filterfields) == 0) { $filterdesc = t('Not filtered'); } else { $filterdesc = t('Filtered by !fields', array('!fields' => implode(", ", array_unique($filterfields)))); } $filterdesc .= ' | '. t('!items items per page', array('!items' => $itemsperpage)); $o = drupal_get_form('storm_attribute_list_filter', $filterdesc); $s = db_rewrite_sql($s, 'stormattribute', 'aid'); $s = storm_rewrite_sql($s, $where) . $tablesort; $r = pager_query($s, $itemsperpage, 0, NULL, $args); $attributes = array(); while ($attribute = db_fetch_object($r)) { $attributes[] = $attribute; } $o .= drupal_get_form('storm_attribute_list_form', $header, $attributes); $o .= theme('pager', NULL, $itemsperpage, 0); return $o; } function storm_attribute_list_form($form_id, $header, $attributes) { $form = array(); $form['attributes']['#theme'] = 'storm_attribute_list'; $form['attributes']['header'] = array( '#value' => $header, ); foreach ($attributes as $attribute) { $i = new stdClass(); $i->type = 'storm_attribute'; $form['attributes']['attributes'][$attribute->aid]['attribute_domain_'. $attribute->aid] = array( '#value' => $attribute->domain, ); $form['attributes']['attributes'][$attribute->aid]['attribute_akey_'. $attribute->aid] = array( '#value' => $attribute->akey, ); $form['attributes']['attributes'][$attribute->aid]['attribute_avalue_'. $attribute->aid] = array( '#value' => $attribute->avalue, ); $form['attributes']['attributes'][$attribute->aid]['attribute_isactive_'. $attribute->aid] = array( '#type' => 'checkbox', '#default_value' => $attribute->isactive, ); $form['attributes']['attributes'][$attribute->aid]['attribute_default_'. $attribute->aid] = array( '#default_value' => $attribute->isdefault, ); $form['attributes']['attributes'][$attribute->aid]['attribute_weight_'. $attribute->aid] = array( '#type' => 'weight', '#default_value' => $attribute->weight, ); $form['attributes']['attributes'][$attribute->aid]['attribute_operations_'. $attribute->aid] = array( '#value' => storm_icon_edit('attributes/edit/'. $attribute->aid, $i, $_GET) .' '. storm_icon_delete('attributes/delete/'. $attribute->aid, $i, $_GET), ); } $form['submit'] = array( '#type' => 'submit', '#submit' => array('storm_attribute_list_submit'), '#value' => t('Save'), ); return $form; } function storm_attribute_list_submit($form, &$form_state) { $attributes = array(); $default_for_domain = array(); foreach ($_POST as $key => $value) { $ar = explode('_', $key); if ($ar[0]=='attribute') { if ($ar[1]=='weight') $attributes[$ar[2]]['weight'] = $value; if ($ar[1]=='isactive') $attributes[$ar[2]]['isactive'] = $value; if ($ar[1]=='default') { $domain = str_replace('|', ' ', $ar[2]); $default_for_domain[$domain] = $value; } } } $s = "UPDATE {stormattribute} SET isactive=%d, weight=%d WHERE aid=%d"; foreach ($attributes as $aid => $values) { db_query($s, $values['isactive'], $values['weight'], $aid); } foreach ($default_for_domain as $domain => $aid) { $s = "UPDATE {stormattribute} SET isdefault=0 WHERE domain='%s'"; db_query($s, $domain); $s = "UPDATE {stormattribute} SET isdefault=1 WHERE aid=%d"; db_query($s, $aid); } drupal_set_message(t('Attributes saved')); } function storm_attribute_list_filter(&$form_state, $filterdesc = 'Filter') { $domain = isset($_SESSION['stormattribute_list_filter']['domain']) ? $_SESSION['stormattribute_list_filter']['domain'] : ''; $akey = isset($_SESSION['stormattribute_list_filter']['akey']) ? $_SESSION['stormattribute_list_filter']['akey'] : ''; $avalue = isset($_SESSION['stormattribute_list_filter']['avalue']) ? $_SESSION['stormattribute_list_filter']['avalue'] : ''; $isactive = isset($_SESSION['stormattribute_list_filter']['isactive']) ? $_SESSION['stormattribute_list_filter']['isactive'] : TRUE; $isdefault = isset($_SESSION['stormattribute_list_filter']['isdefault']) ? $_SESSION['stormattribute_list_filter']['isdefault'] : FALSE; $itemsperpage = isset($_SESSION['stormattribute_list_filter']['itemsperpage']) ? $_SESSION['stormattribute_list_filter']['itemsperpage'] : variable_get('storm_default_items_per_page', 10); $_SESSION['stormattribute_list_filter']['itemsperpage'] = $itemsperpage; $form['filter'] = array( '#type' => 'fieldset', '#title' => $filterdesc, '#collapsible' => TRUE, '#collapsed' => TRUE, ); $form['filter']['group1'] = array( '#type' => 'markup', '#theme' => 'storm_form_group', ); $form['filter']['group1']['domain'] = array( '#type' => 'textfield', '#title' => t('Domain'), '#default_value' => $domain, '#size' => 30, '#autocomplete_path' => 'storm/attributes/domain/autocomplete', ); $form['filter']['group1']['akey'] = array( '#type' => 'textfield', '#title' => t('Key'), '#default_value' => $akey, '#size' => 20, ); $form['filter']['group1']['avalue'] = array( '#type' => 'textfield', '#title' => t('Value'), '#default_value' => $avalue, '#size' => 20, ); $form['filter']['group2'] = array( '#type' => 'markup', '#theme' => 'storm_form_group', ); $form['filter']['group2']['isactive'] = array( '#type' => 'select', '#title' => t('Active'), '#default_value' => $isactive, '#options' => array('-' => '-', '0' => t('No'), '1' => t('Yes')), ); $form['filter']['group2']['isdefault'] = array( '#type' => 'select', '#title' => t('Default'), '#default_value' => $isdefault, '#options' => array('-' => '-', '0' => t('No'), '1' => t('Yes')), ); $form['filter']['group3'] = array( '#type' => 'markup', '#theme' => 'storm_form_group', '#attributes' => array('class' => 'formgroup-submit'), ); $form['filter']['group3']['submit'] = array( '#type' => 'submit', '#value' => t('Filter'), '#submit' => array('storm_attribute_list_filter_filter'), ); $form['filter']['group3']['reset'] = array( '#type' => 'submit', '#value' => t('Reset'), '#submit' => array('storm_attribute_list_filter_reset'), ); $form['filter']['group3']['itemsperpage'] = array( '#type' => 'textfield', '#title' => t('Items'), '#size' => 10, '#default_value' => $itemsperpage, '#prefix' => '
' . t("This website uses cookies to differentiate between distinct users who access it. A cookie is a small alpha-numeric archive which is stored on the hard drive or in the browser of a computer, tablet, smartphone or similar device when it browses the internet. Cookies allow us to offer relevant information on our products and services and to provide you with a good experience when you browse the website.") . '
' . t("None of our cookies store any personal information such as your name or address. Please be aware that restricting cookies may impact on the functionality of this site.") . '
'; $output .= '' . '' . t("First party cookies") . ': ' . t("installed by this website.") . '
' . '' . t("Third party cookies") . ': ' . t("installed by other websites, or links which users can use to share content. A user accessing such content from this website may have cookies added from these third parties. It's not posible to control these third party cookies and so the user must review the cookie policies of these other websites for further information.") . '
' . '' . t("Session cookies") . ': ' . t("collect and store data only whilst the user is visiting the website.") . '
' . '' . t("Persistent cookies") . ': ' . t("remain stored in a computer and may be accessed and managed by the organisation responsible for the cookie for a specific length of time, or until the user deletes it.") . '
' . '' . t("Technical cookies") . ': ' . t("allow the user to make use of the different options they facilitate: for example controlling data traffic and communication, identifying a session, accessing restricted areas, carrying out a purchase, requesting a subscription or participating in an event etc.") . '
' . '' . t("Personalisation cookies") . ': ' . t("allow the user to access services with certain personalised characteristics such as language, browser type, configuration for the region from which the user accesses services etc") . '
' . '' . t("Analytical cookies") . ': ' . t("allow website managers to follow and analyse the behaviour of users on a website so that they can make improvements informed by data analysis on the use of the website by users of its services.") . '
' . '' . t("Advertising cookies") . ': ' . t("help with the management of advertising spaces which a web editor has included on a website where services are offered, based on criteria such as the type of content or the frequency with which the content is shown.") . '
'; $output .= '' . t("You can block cookies by activating the setting on your browser that allows you to refuse the setting of all or some cookies. However, if you use your browser settings to block all cookies (including essential cookies) you may not be able to access all or parts of our site or any other websites that you visit.") . '