function iflychat_get_current_guest_id() { if (isset($_SESSION) && isset($_SESSION['iflychat_guest_id'])) { //if(!isset($_COOKIE) || !isset($_COOKIE['drupalchat_guest_id'])) { setrawcookie('iflychat_guest_id', rawurlencode($_SESSION['iflychat_guest_id']), time() + 60 * 60 * 24 * 365); setrawcookie('iflychat_guest_session', rawurlencode($_SESSION['iflychat_guest_session']), time() + 60 * 60 * 24 * 365); //} } else { if (isset($_COOKIE) && isset($_COOKIE['iflychat_guest_id']) && isset($_COOKIE['iflychat_guest_session']) && $_COOKIE['iflychat_guest_session'] == iflychat_compute_guest_session($_COOKIE['iflychat_guest_id'])) { $_SESSION['iflychat_guest_id'] = check_plain($_COOKIE['iflychat_guest_id']); $_SESSION['iflychat_guest_session'] = check_plain($_COOKIE['iflychat_guest_session']); } else { $characters = 'abcdefghijklmnopqrstuvwxyz0123456789'; $iflychatId = time(); for ($i = 0; $i < 5; $i++) { $iflychatId .= $characters[rand(0, strlen($characters) - 1)]; } $_SESSION['iflychat_guest_id'] = $iflychatId; $_SESSION['iflychat_guest_session'] = iflychat_compute_guest_session($_SESSION['iflychat_guest_id']); setrawcookie('iflychat_guest_id', rawurlencode($_SESSION['iflychat_guest_id']), time() + 60 * 60 * 24 * 365); setrawcookie('iflychat_guest_session', rawurlencode($_SESSION['iflychat_guest_session']), time() + 60 * 60 * 24 * 365); } } return $_SESSION['iflychat_guest_id']; }
/** * Overrides theme_menu_local_action(). * * Overrides Bootstrap module's override. All we're doing is making the action * link buttons bigger by removing the 'btn-xs' class. * * @see bootstrap_menu_local_action() */ function bootstrap_material_menu_local_action($variables) { $link = $variables['element']['#link']; $options = isset($link['localized_options']) ? $link['localized_options'] : array(); // If the title is not HTML, sanitize it. if (empty($options['html'])) { $link['title'] = check_plain($link['title']); } $icon = _bootstrap_iconize_text($link['title']); // Format the action link. $output = ''; if (isset($link['href'])) { // Turn link into a mini-button and colorize based on title. if ($class = _bootstrap_colorize_text($link['title'])) { if (!isset($options['attributes']['class'])) { $options['attributes']['class'] = array(); } $string = is_string($options['attributes']['class']); if ($string) { $options['attributes']['class'] = explode(' ', $options['attributes']['class']); } $options['attributes']['class'][] = 'btn'; $options['attributes']['class'][] = 'btn-' . $class; if ($string) { $options['attributes']['class'] = implode(' ', $options['attributes']['class']); } } // Force HTML so we can render any icon that may have been added. $options['html'] = !empty($options['html']) || !empty($icon) ? TRUE : FALSE; $output .= l($icon . $link['title'], $link['href'], $options); } else { $output .= $icon . $link['title']; } return $output; }
public static function isPaymentValid($oplataSettings, $response) { list($orderId, ) = explode(self::ORDER_SEPARATOR, $response['order_id']); $order = uc_order_load($orderId); if ($order === FALSE || uc_order_status_data($order->order_status, 'state') != 'in_checkout') { return t('An error has occurred during payment. Please contact us to ensure your order has submitted.'); } if ($oplataSettings->merchant_id != $response['merchant_id']) { return t('An error has occurred during payment. Merchant data is incorrect.'); } $originalResponse = $response; foreach ($response as $k => $v) { if (!in_array($k, self::$responseFields)) { unset($response[$k]); } } if (self::getSignature($response, $oplataSettings->secret_key) != $originalResponse['signature']) { return t('An error has occurred during payment. Signature is not valid.'); } if (drupal_strtolower($originalResponse['sender_email']) !== drupal_strtolower($order->primary_email)) { uc_order_comment_save($order->order_id, 0, t('Customer used a different e-mail address during payment: !email', array('!email' => check_plain($originalResponse['sender_email']))), 'admin'); } uc_order_comment_save($order->order_id, 0, "Order status: {$response['order_status']}", 'admin'); return true; }
/** * Override or insert variables into the page template. */ function garland_preprocess_page(&$vars) { $vars['tabs2'] = menu_secondary_local_tasks(); if (isset($vars['main_menu'])) { $vars['primary_nav'] = theme('links__system_main_menu', array('links' => $vars['main_menu'], 'attributes' => array('class' => array('links', 'main-menu')), 'heading' => array('text' => t('Main menu'), 'level' => 'h2', 'class' => array('element-invisible')))); } else { $vars['primary_nav'] = FALSE; } if (isset($vars['secondary_menu'])) { $vars['secondary_nav'] = theme('links__system_secondary_menu', array('links' => $vars['secondary_menu'], 'attributes' => array('class' => array('links', 'secondary-menu')), 'heading' => array('text' => t('Secondary menu'), 'level' => 'h2', 'class' => array('element-invisible')))); } else { $vars['secondary_nav'] = FALSE; } // Prepare header. $site_fields = array(); if (!empty($vars['site_name'])) { $site_fields[] = check_plain($vars['site_name']); } if (!empty($vars['site_slogan'])) { $site_fields[] = check_plain($vars['site_slogan']); } $vars['site_title'] = implode(' ', $site_fields); if (!empty($site_fields)) { $site_fields[0] = '<span>' . $site_fields[0] . '</span>'; } $vars['site_html'] = implode(' ', $site_fields); // Set a variable for the site name title and logo alt attributes text. $slogan_text = filter_xss_admin(variable_get('site_slogan', '')); $site_name_text = filter_xss_admin(variable_get('site_name', 'Drupal')); $vars['site_name_and_slogan'] = $site_name_text . ' ' . $slogan_text; }
/** * Implements theme_bootstrap_btn_dropdown(). */ function theme_bootstrap_btn_dropdown($variables) { $type_class = ''; $sub_links = ''; $variables['attributes']['class'][] = 'btn-group'; // Type class. if (isset($variables['type'])) { $type_class .= ' btn-' . $variables['type']; } else { $type_class .= ' btn-default'; } // Start markup. $output = '<div' . drupal_attributes($variables['attributes']) . '>'; // Add as string if its not a link. if (is_array($variables['label'])) { $output .= l($variables['label']['title'], ${$variables}['label']['href'], $variables['label']); } $output .= '<a class="btn' . $type_class . ' dropdown-toggle" data-toggle="dropdown" href="#">'; // It is a link, create one. if (is_string($variables['label'])) { $output .= check_plain($variables['label']); } if (is_array($variables['links'])) { $sub_links = theme('links', array('links' => $variables['links'], 'attributes' => array('class' => array('dropdown-menu')))); } // Finish markup. $output .= '<span class="caret"></span></a>' . $sub_links . '</div>'; return $output; }
function list_build_row($item, &$form_state, $operations) { // Set up sorting switch ($form_state['values']['order']) { case 'disabled': $this->sorts[$item->name] = empty($item->disabled) . $item->admin_title; break; case 'title': $this->sorts[$item->name] = $item->admin_title; break; case 'name': $this->sorts[$item->name] = $item->name; break; case 'category': $this->sorts[$item->name] = ($item->category ? $item->category : t('Mini panels')) . $item->admin_title; break; case 'layout': $this->sorts[$item->name] = $item->display->layout . $item->admin_title; break; case 'storage': $this->sorts[$item->name] = $item->type . $item->admin_title; break; } $layout = !empty($this->layouts[$item->display->layout]) ? $this->layouts[$item->display->layout]['title'] : t('Missing layout'); $category = $item->category ? check_plain($item->category) : t('Mini panels'); $this->rows[$item->name] = array('data' => array(array('data' => check_plain($item->admin_title), 'class' => 'ctools-export-ui-title'), array('data' => check_plain($item->name), 'class' => 'ctools-export-ui-name'), array('data' => $category, 'class' => 'ctools-export-ui-category'), array('data' => $layout, 'class' => 'ctools-export-ui-layout'), array('data' => $item->type, 'class' => 'ctools-export-ui-storage'), array('data' => theme('links', $operations), 'class' => 'ctools-export-ui-operations')), 'title' => !empty($item->admin_description) ? check_plain($item->admin_description) : '', 'class' => !empty($item->disabled) ? 'ctools-export-ui-disabled' : 'ctools-export-ui-enabled'); }
/** * Override theme_username() function. * Removes the text '(not verified)' for anonymous users. */ function quickdrupal_username($object) { if ($object->uid && $object->name) { if (drupal_strlen($object->name) > 20) { $name = drupal_substr($object->name, 0, 15) . '...'; } else { $name = $object->name; } if (user_access('access user profiles')) { $output = l($name, 'user/' . $object->uid, array('attributes' => array('title' => t('View user profile.')))); } else { $output = check_plain($name); } } else { if ($object->name) { if (!empty($object->homepage)) { $output = l($object->name, $object->homepage, array('attributes' => array('rel' => 'nofollow'))); } else { $output = check_plain($object->name); } } else { $output = check_plain(variable_get('anonymous', t('Anonymous'))); } } return $output; }
/** * Builds inner content, then hands off to layout-specified theme function for * final render step. * * This is the outermost method in the Panels render pipeline. It calls the * inner methods, which return a content array, which is in turn passed to the * theme function specified in the layout plugin. * * @return string * Themed & rendered HTML output. */ function render() { if (!empty($this->plugins['layout']['css'])) { if (file_exists(path_to_theme() . '/' . $this->plugins['layout']['css'])) { drupal_add_css(path_to_theme() . '/' . $this->plugins['layout']['css']); } else { drupal_add_css($this->plugins['layout']['path'] . '/' . $this->plugins['layout']['css']); } } // This now comes after the CSS is added, because panels-within-panels must // have their CSS added in the right order; inner content before outer content. if (empty($this->display->cache['method']) || !empty($this->display->skip_cache)) { $content = $this->render_regions(); } else { $cache = panels_get_cached_content($this->display, $this->display->args, $this->display->context); if ($cache === FALSE) { $cache = new panels_cache_object(); $cache->set_content($this->render_regions()); panels_set_cached_content($cache, $this->display, $this->display->args, $this->display->context); } $content = $cache->content; } $output = theme($this->plugins['layout']['theme'], check_plain($this->display->css_id), $content, $this->display->layout_settings, $this->display, $this->plugins['layout'], $this); return $output; }
public function build($form, &$form_state) { $relationships = ablecore_menu_get_path_relationships(); $form['#tree'] = true; if (count($relationships) <= 0) { $form['#no-results'] = true; return $form; } foreach ($relationships as $id => $relationship) { $form['relationships'][$id]['pid'] = array('#type' => 'hidden', '#value' => $relationship->get('pid')); $form['relationships'][$id]['path'] = array('#markup' => check_plain($relationship->get('path'))); $menu_link = $relationship->menuLink(); if (!$menu_link) { continue; } $form['relationships'][$id]['menu_link'] = array('#type' => 'link', '#title' => $menu_link['link_title'], '#href' => 'admin/structure/menu/item/' . $menu_link['mlid'] . '/edit'); $form['relationships'][$id]['type'] = array('#markup' => ucfirst(check_plain($relationship->get('type')))); $form['relationships'][$id]['edit'] = array('#type' => 'link', '#title' => t('edit'), '#href' => 'admin/config/ablecore/menu-relationships/' . $relationship->get('pid') . '/edit'); $form['relationships'][$id]['delete'] = array('#type' => 'link', '#title' => t('delete'), '#href' => 'admin/config/ablecore/menu-relationships/' . $relationship->get('pid') . '/delete'); $form['relationships'][$id]['weight'] = array('#type' => 'weight', '#title' => t('Weight for @title', array('@title' => $relationship->get('path'))), '#title_display' => 'invisible', '#default_value' => $relationship->get('weight')); } $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save changes')); return $form; }
/** * {@inheritdoc} */ public function preBuild(array &$build, \Drupal\openlayers\Types\ObjectInterface $context = NULL) { $map_id = $context->getId(); $layers = $this->getOption('layers', array()); $items = array(); $map_layers = $context->getObjects('layer'); $element_type = $this->getOption('multiselect', FALSE) ? 'checkbox' : 'radio'; // Only handle layers available in the map and configured in the control. // @TODO: use Form API (with form_process_* and stuff) $labels = $this->getOption('layer_labels', array()); foreach ($map_layers as $i => $map_layer) { if (isset($layers[$map_layer->machine_name])) { $classes = array(drupal_html_class($map_layer->machine_name)); $checked = ''; if ($element_type == 'checkbox') { if ($map_layer->getOption('visible', 1)) { $checked = 'checked '; $classes[] = 'active'; } } $label = check_plain($map_layer->name); if (isset($labels[$map_layer->machine_name])) { $label = openlayers_i18n_string('openlayers:layerswitcher:' . $this->machine_name . ':' . $map_layer->machine_name . ':label', $labels[$map_layer->machine_name], array('sanitize' => TRUE)); } $items[] = array('data' => '<label><input type="' . $element_type . '" name="layer" ' . $checked . 'value="' . $map_layer->machine_name . '">' . $label . '</label>', 'id' => drupal_html_id($map_id . '-' . $map_layer->machine_name), 'class' => $classes); } } $title = openlayers_i18n_string('openlayers:layerswitcher:' . $this->machine_name . ':title', $this->getOption('label', 'Layers'), array('sanitize' => TRUE)); $layerswitcher = array('#theme' => 'item_list', '#type' => 'ul', '#title' => $title, '#items' => $items, '#attributes' => array('id' => drupal_html_id($this->machine_name . '-items'))); $this->setOption('element', '<div id="' . drupal_html_id($this->machine_name) . '" class="' . drupal_html_class($this->machine_name) . ' layerswitcher">' . drupal_render($layerswitcher) . '</div>'); }
/** * Override or insert variables into the page template. */ function garland_preprocess_page(&$vars) { $vars['tabs2'] = menu_secondary_local_tasks(); if (isset($vars['main_menu'])) { $vars['primary_nav'] = theme('links', $vars['main_menu'], array('class' => array('links', 'main-menu')), array('text' => t('Main menu'), 'level' => 'h2', 'class' => array('element-invisible'))); } else { $vars['primary_nav'] = FALSE; } if (isset($vars['secondary_menu'])) { $vars['secondary_nav'] = theme('links', $vars['secondary_menu'], array('class' => array('links', 'secondary-menu')), array('text' => t('Secondary menu'), 'level' => 'h2', 'class' => array('element-invisible'))); } else { $vars['secondary_nav'] = FALSE; } $vars['ie_styles'] = garland_get_ie_styles(); // Prepare header $site_fields = array(); if (!empty($vars['site_name'])) { $site_fields[] = check_plain($vars['site_name']); } if (!empty($vars['site_slogan'])) { $site_fields[] = check_plain($vars['site_slogan']); } $vars['site_title'] = implode(' ', $site_fields); if (!empty($site_fields)) { $site_fields[0] = '<span>' . $site_fields[0] . '</span>'; } $vars['site_html'] = implode(' ', $site_fields); // Hook into color.module if (module_exists('color')) { _color_page_alter($vars); } }
/** * 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')); }
/** * Tests node type links. */ function testNode() { $type = $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); // Create a content-type with special characters. $type = $this->drupalCreateContentType(array('type' => 'special', 'name' => 'Cool & Special')); $permissions = $this->basePermissions + array('administer content types', 'access content', 'create article content', 'create special content'); $this->admin_user = $this->drupalCreateUser($permissions); $this->drupalLogin($this->admin_user); // Verify that dynamic links are displayed. $this->drupalGet(''); $this->assertElementByXPath('//div[@id="admin-menu"]', array(), t('Administration menu found.')); $this->assertElementByXPath('//div[@id="admin-menu"]//a[contains(@href, :path)]', array(':path' => 'admin/structure/types'), "Structure » Content types link found."); // Verify link title output escaping. $this->assertNoRaw('Cool & Special'); $this->assertRaw(check_plain('Cool & Special')); // Verify Manage content type links. $links = array('admin/structure/types/manage/article' => 'Article', 'admin/structure/types/manage/special' => 'Cool & Special'); foreach ($links as $path => $title) { $this->assertElementByXPath('//div[@id="admin-menu"]//a[contains(@href, :path) and text()=:title]', array(':path' => $path, ':title' => $title), "Structure » Content types » {$title} link found."); } // Verify Add content links. // @todo Fix expansion of node/add. return; $links = array('node/add/article' => 'Article', 'node/add/special' => 'Cool & Special'); foreach ($links as $path => $title) { $this->assertElementByXPath('//div[@id="admin-menu"]//a[contains(@href, :path) and text()=:title]', array(':path' => $path, ':title' => $title), "Add content » {$title} link found."); } }
/** * Implementation of hook_token_values() */ function messaging_token_values($type, $object = NULL, $options = array()) { $language = isset($options['language']) ? $options['language'] : $GLOBALS['language']; switch ($type) { case 'message': if ($message = messaging_check_object($object, 'Messaging_Message')) { $values['message-subject'] = check_plain($message->get_subject()); $values['message-body'] = filter_xss($message->get_body()); $values['message-author-name'] = check_plain($message->get_sender_name()); $values['message-method'] = messaging_method_info($message->method, 'name'); $timezone = isset($options['timezone']) ? $options['timezone'] : variable_get('date_default_timezone', 0); $values['message-date'] = format_date($message->sent, 'medium', '', $timezone, $language->language); return $values; } break; case 'destination': // Messaging destinations if ($destination = messaging_check_object($object, 'Messaging_Destination')) { $values['destination-address'] = $destination->format_address(FALSE); $values['destination-type'] = $destination->address_name(); return $values; } break; } }
function phptemplate_username($object) { if ($object->uid && $object->name) { // Shorten the name when it is too long or it will break many tables. if (arg(0) == 'user' or 'groups') { $name = $object->name; } else { if (drupal_strlen($object->name) > 20) { $name = drupal_substr($object->name, 0, 15) . '...'; } else { $name = $object->name; } } if (user_access('access user profiles')) { $output = l($name, 'user/' . $object->uid, array('title' => t('View user profile.'))); } else { $output = check_plain($name); } } else { if ($object->name) { // Sometimes modules display content composed by people who are // not registered members of the site (e.g. mailing list or news // aggregator modules). This clause enables modules to display // the true author of the content. if ($object->homepage) { $output = l($object->name, $object->homepage, array('class' => 'anonymous', 'title' => t('not verified'))); } else { $output = '<span class="anonymous" title="' . t('not verified') . '">' . check_plain($object->name) . '</span>'; } } else { $output = variable_get('anonymous', t('Anonymous')); } } return $output; }
/** * Build a row based on the item. */ 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'); $this->rows[$name]['data'][] = array('data' => finder_ui_info($item), 'class' => array('ctools-export-ui-title')); $this->rows[$name]['data'][] = array('data' => check_plain($item->{$schema['export']['export type string']}), 'class' => array('ctools-export-ui-storage')); $this->rows[$name]['data'][] = array('data' => l($item->path, $item->path), 'class' => array('ctools-export-ui-path')); $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']}; } }
/** * Calls a transaction request */ function ideal_payment_api_transreq_call($order) { //Get user ID global $user; if ($user) { $user_id = $user->uid; } $path_module = drupal_get_path('module', 'ideal_payment_api'); require_once $path_module . '/lib/iDEALConnector.php'; $iDEALConnector = new iDEALConnector(); $order['description'] = check_plain($order['description']); if (drupal_strlen($order['description']) > 32) { //@TODO: run this trough a general error handler. $order['description_orig'] = $order['description']; $order['description'] = drupal_substr($order['description'], 0, 32); watchdog('ideal_api', t('iDEAL decription too long. Changed from %orig to %shortened', array('%orig' => $order['description_orig'], '%shortened' => $order['description']))); } //issuerid is min. 4 chars, add leading 0's $order['issuer_id'] = str_pad($order['issuer_id'], 4, '0', STR_PAD_LEFT); //Send TransactionRequest $response = $iDEALConnector->RequestTransaction($order['issuer_id'], $order['order_id'], $order['amount'], $order['description'], $order['order_id'], $iDEALConnector->config['EXPIRATIONPERIOD'], $iDEALConnector->config['MERCHANTRETURNURL']); if (!$response->errCode) { return $response; } else { watchdog('ideal_api', $response->errCode . ': ' . $response->errMsg, NULL, WATCHDOG_ERROR); return $response; } }
/** * Override or insert variables into the html template. * * @param $vars * An array of variables to pass to the theme template. */ function fontfolio_preprocess_html(&$vars) { // We want to use core's body class 'no-sidebars' but is useless for us // because it doesn't ccounts fontfolio's 'sidebar' region as sidebar. // So we first remove it. $vars['classes_array'] = array_diff($vars['classes_array'], array('no-sidebars')); // And restore it if appropriate. if (empty($vars['page']['sidebar'])) { $vars['classes_array'][] = 'no-sidebars'; } $vars['path_to_fontfolio'] = drupal_get_path('theme', 'fontfolio'); $vars['base_path'] = base_path(); // Attributes for html element. $vars['html_attributes_array'] = array('lang' => $vars['language']->language, 'dir' => $vars['language']->dir); // Send X-UA-Compatible HTTP header to force IE to use the most recent // rendering engine or use Chrome's frame rendering engine if available. // This also prevents the IE compatibility mode button to appear when using // conditional classes on the html tag. if (is_null(drupal_get_http_header('X-UA-Compatible'))) { drupal_add_http_header('X-UA-Compatible', 'IE=edge,chrome=1'); } // We want to insert inline css rules based on fonfolio theme settings. $bg_color = check_plain(theme_get_setting('body_bg_color')); $data = 'body { background-color: ' . $bg_color . '}'; drupal_add_css($data, 'inline'); }
public function build($form, &$form_state) { $remotes = \publisher_get_remotes(); $form['#tree'] = true; if ($remotes === false) { $form['#no-results'] = true; return $form; } foreach ($remotes as $id => $remote) { $form['remotes'][$id]['name'] = array('#markup' => \check_plain($remote->label)); $form['remotes'][$id]['url'] = array('#markup' => \check_plain($remote->url)); $form['remotes'][$id]['api_key'] = array('#markup' => \check_plain($remote->api_key)); $send_receive = 'Send and Receive'; if (!$remote->send && $remote->receive) { $send_receive = 'Receive Only'; } elseif ($remote->send && !$remote->receive) { $send_receive = 'Send Only'; } elseif (!$remote->send && !$remote->receive) { $send_receive = 'No Communication'; } $form['remotes'][$id]['send_receive'] = array('#markup' => \check_plain($send_receive)); $form['remotes'][$id]['configure'] = array('#type' => 'link', '#title' => t('configure'), '#href' => 'admin/config/publisher/remotes/' . $remote->name); // Add enable and disable. $form['remotes'][$id]['endis'] = array('#type' => 'link', '#title' => t('disable'), '#href' => 'admin/config/publisher/remotes/' . $remote->name . '/toggle'); if (!$remote->enabled) { $form['remotes'][$id]['endis']['#title'] = t('enable'); } $form['remotes'][$id]['delete'] = array('#type' => 'link', '#title' => t('delete'), '#href' => 'admin/config/publisher/remotes/' . $remote->name . '/delete'); $form['remotes'][$id]['weight'] = array('#type' => 'weight', '#title' => t('Weight for @title', array('@title' => $remote->label)), '#title_display' => 'invisible', '#default_value' => $remote->weight); } $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save changes')); return $form; }
function cubert_preprocess_field(&$vars) { $element = $vars['element']; $field_name = $element['#field_name']; $type = !empty($element['#entity_type']) ? $element['#entity_type'] : NULL; $bundle = !empty($element['#bundle']) ? $element['#bundle'] : NULL; $access = !empty($element['#access']) ? $element['#access'] : FALSE; if ($type == 'node' && $bundle == 'project_issue' && $access) { $existing_classes = !empty($vars['classes_array']) ? $vars['classes_array'] : array(); $new_classes = array(); if ($field_name == 'field_issue_status' || $field_name == 'field_issue_priority') { $status_code = !empty($element['#items'][0]['value']) ? $element['#items'][0]['value'] : NULL; if (!empty($status_code)) { if ($field_name == 'field_issue_status') { $status_id = 'issue_status_styles_' . $status_code; $arr_status_classes[] = 'status-field'; } if ($field_name == 'field_issue_priority') { $status_id = 'issue_priority_styles_' . $status_code; $arr_status_classes[] = 'priority-field'; } $str_status_classes = check_plain(preg_replace('!\\s+!', ' ', variable_get($status_id, ''))); $new_classes = explode(' ', $str_status_classes); } } if (!empty($element['edit_form'])) { $new_classes[] = 'mode-read'; } $vars['classes_array'] = array_merge($existing_classes, $new_classes); } }
function list_build_row($profile, &$form_state, $operations) { parent::list_build_row($profile, $form_state, $operations); $name = $profile->name; $row_data =& $this->rows[$name]['data']; // We want the operations last so remove it now, add our stuff and add it // again later when we're done. $operations = array_pop($row_data); $row_data[]['data'] = check_plain($profile->config['search_request']['search_well_profile']); $row_data[]['data'] = check_plain($profile->config['search_request']['query']); $row_data[]['data'] = $profile->config['user_interaction']['exposed'] ? t('Yes') : t('No'); $row_data[]['data'] = $profile->weight; $row_data[] = $operations; // Prepare for the sorting (the parent handles name and title). $weight = $profile->weight; $exposed = $profile->config['user_interaction']['exposed']; switch ($form_state['values']['order']) { case 'weight': $this->sorts[$name] = $weight; break; case 'exposed': $this->sorts[$name] = $exposed; break; } }
function cstark_link($variables) { if (_cstark_is_term_active($variables['path'])) { $variables['options']['attributes']['class'][] = 'active'; } return '<a href="' . check_plain(url($variables['path'], $variables['options'])) . '"' . drupal_attributes($variables['options']['attributes']) . '>' . ($variables['options']['html'] ? $variables['text'] : check_plain($variables['text'])) . '</a>'; }
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')); }
function solrmlt_suggestions($block_id, $nid) { try { $solr = apachesolr_get_solr(); $fields = array('mlt.mintf', 'mlt.mindf', 'mlt.minwl', 'mlt.maxwl', 'mlt.maxqt', 'mlt.boost', 'mlt.qf'); $block = apachesolr_mlt_load_block($block_id); $params = array('qt' => 'mlt', 'fl' => 'nid,title,url', 'mlt.fl' => implode(',', $block['mlt_fl'])); foreach ($fields as $field) { $drupal_fieldname = str_replace('.', '_', $field); if (!empty($block[$drupal_fieldname])) { $params[$field] = check_plain($block[$drupal_fieldname]); } } $query = apachesolr_drupal_query('id:' . apachesolr_document_id($nid)); // This hook allows modules to modify the query and params objects. apachesolr_modify_query($query, $params, 'apachesolr_mlt'); if (empty($query)) { return; } $response = $solr->search($query->get_query_basic(), 0, $block['num_results'], $params); if ($response->response) { $docs = (array) end($response->response); } return $docs; } catch (Exception $e) { watchdog('Apache Solr', $e->getMessage(), NULL, WATCHDOG_ERROR); } }
/** * Override or insert variables into the page template. */ function garland_preprocess_page(&$vars) { $vars['tabs2'] = menu_secondary_local_tasks(); if (isset($vars['main_menu'])) { $vars['primary_nav'] = theme('links', array('links' => $vars['main_menu'], 'attributes' => array('class' => array('links', 'main-menu')), 'heading' => array('text' => t('Main menu'), 'level' => 'h2', 'class' => array('element-invisible')))); } else { $vars['primary_nav'] = FALSE; } if (isset($vars['secondary_menu'])) { $vars['secondary_nav'] = theme('links', array('links' => $vars['secondary_menu'], 'attributes' => array('class' => array('links', 'secondary-menu')), 'heading' => array('text' => t('Secondary menu'), 'level' => 'h2', 'class' => array('element-invisible')))); } else { $vars['secondary_nav'] = FALSE; } // Prepare header $site_fields = array(); if (!empty($vars['site_name'])) { $site_fields[] = check_plain($vars['site_name']); } if (!empty($vars['site_slogan'])) { $site_fields[] = check_plain($vars['site_slogan']); } $vars['site_title'] = implode(' ', $site_fields); if (!empty($site_fields)) { $site_fields[0] = '<span>' . $site_fields[0] . '</span>'; } $vars['site_html'] = implode(' ', $site_fields); }
/** * Implements EntityReferenceHandler::getReferencableEntities(). * * Completely bypass buildEntityFieldQuery(), as we want a regular SQL query * in order to group and order the timeslots by their containing schedules. */ public function getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 25) { // We also come here when getting entities for the default value widget. // There's no way to check this is what we're doing so just return nothing // if the settings are missing. if (empty($this->field['settings']['handler_settings']['behaviors']['session_timeslot']['status'])) { return array(); } // Figure out which fields are on schedules and point to timeslots. $timetable_set = timetable_get_timetable_set($this->field); $schedule_timeslot_field_name = $timetable_set['schedule']['field_name']; $schedule_entity_type = $timetable_set['schedule']['entity_type']; // Get details about the schedule entity type for the query. $schedule_entity_info = entity_get_info($schedule_entity_type); $schedule_entity_base_table = $schedule_entity_info['base table']; $schedule_entity_id_key = $schedule_entity_info['entity keys']['id']; $schedule_entity_label_key = $schedule_entity_info['entity keys']['label']; $results = db_query("SELECT\n ts.id,\n time.field_timeslot_time_value AS timeslot_value,\n time.field_timeslot_time_value2 AS timeslot_value2,\n schedule.{$schedule_entity_label_key} AS schedule_label\n FROM {eck_timeslot} ts\n JOIN {field_data_field_timeslot_time} time\n ON ts.id = time.entity_id\n JOIN {field_data_{$schedule_timeslot_field_name}} sts\n ON ts.id = sts.{$schedule_timeslot_field_name}_target_id\n JOIN {{$schedule_entity_base_table}} schedule\n ON sts.entity_id = schedule.{$schedule_entity_id_key}\n ")->fetchAllAssoc('id', PDO::FETCH_ASSOC); // TODO: get this from the field instance so we match whatever format the // site builder wants. $timefield_display_format = array('hour' => 'G', 'minute' => 'i', 'separator' => ':', 'period' => 'none', 'period_separator' => ''); $timeslot_options = array(); foreach ($results as $timeslot_id => $timeslot_data) { $timeslot_options[$timeslot_id] = check_plain($timeslot_data['schedule_label']) . ': ' . timefield_integer_to_time($timefield_display_format, $timeslot_data['timeslot_value']) . '-' . timefield_integer_to_time($timefield_display_format, $timeslot_data['timeslot_value2']); } $options = array('timeslot' => $timeslot_options); return $options; }
/** * Perform a single batch operation. * * Callback for batch_set(). * * @param $MULTIPLE_PARAMS * Additional parameters specific to the batch. These are specified in the * array passed to batch_set(). * @param $context * The batch context array, passed by reference. This contains the following * properties: * - 'finished': A float number between 0 and 1 informing the processing * engine of the completion level for the operation. 1 (or no value * explicitly set) means the operation is finished: the operation will not * be called again, and execution passes to the next operation or the * callback_batch_finished() implementation. Any other value causes this * operation to be called again; however it should be noted that the value * set here does not persist between executions of this callback: each time * it is set to 1 by default by the batch system. * - 'sandbox': This may be used by operations to persist data between * successive calls to the current operation. Any values set in * $context['sandbox'] will be there the next time this function is called * for the current operation. For example, an operation may wish to store a * pointer in a file or an offset for a large query. The 'sandbox' array key * is not initially set when this callback is first called, which makes it * useful for determining whether it is the first call of the callback or * not: * @code * if (empty($context['sandbox'])) { * // Perform set-up steps here. * } * @endcode * The values in the sandbox are stored and updated in the database between * http requests until the batch finishes processing. This avoids problems * if the user navigates away from the page before the batch finishes. * - 'message': A text message displayed in the progress page. * - 'results': The array of results gathered so far by the batch processing. * This array is highly useful for passing data between operations. After * all operations have finished, this is passed to callback_batch_finished() * where results may be referenced to display information to the end-user, * such as how many total items were processed. */ function callback_batch_operation($MULTIPLE_PARAMS, &$context) { if (!isset($context['sandbox']['progress'])) { $context['sandbox']['progress'] = 0; $context['sandbox']['current_node'] = 0; $context['sandbox']['max'] = db_query('SELECT COUNT(DISTINCT nid) FROM {node}')->fetchField(); } // For this example, we decide that we can safely process // 5 nodes at a time without a timeout. $limit = 5; // With each pass through the callback, retrieve the next group of nids. $result = db_query_range("SELECT nid FROM {node} WHERE nid > %d ORDER BY nid ASC", $context['sandbox']['current_node'], 0, $limit); while ($row = db_fetch_array($result)) { // Here we actually perform our processing on the current node. $node = node_load($row['nid'], NULL, TRUE); $node->value1 = $options1; $node->value2 = $options2; node_save($node); // Store some result for post-processing in the finished callback. $context['results'][] = check_plain($node->title); // Update our progress information. $context['sandbox']['progress']++; $context['sandbox']['current_node'] = $node->nid; $context['message'] = t('Now processing %node', array('%node' => $node->title)); } // Inform the batch engine that we are not finished, // and provide an estimation of the completion level we reached. if ($context['sandbox']['progress'] != $context['sandbox']['max']) { $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; } }
/** * Returns HTML for a set of filter tips. * * @param array $variables * An associative array containing: * - tips: An array containing descriptions and a CSS ID in the form of * 'module-name/filter-id' (only used when $long is TRUE) for each * filter in one or more text formats. Example: * @code * array( * 'Full HTML' => array( * 0 => array( * 'tip' => 'Web page addresses and e-mail addresses turn into links automatically.', * 'id' => 'filter/2', * ), * ), * ); * @endcode * - long: (optional) Whether the passed-in filter tips contain extended * explanations, i.e. intended to be output on the path 'filter/tips' * (TRUE), or are in a short format, i.e. suitable to be displayed below a * form element. Defaults to FALSE. * * @return string * The constructed HTML. * * @see theme_filter_tips() * @see _filter_tips() * * @ingroup theme_functions */ function bootstrap_filter_tips($variables) { $format_id = arg(2); $current_path = current_path(); $tips = _filter_tips(-1, TRUE); // Create a place holder for the tabs. $build['tabs'] = array('#theme' => 'item_list', '#items' => array(), '#attributes' => array('class' => array('nav', 'nav-tabs'), 'role' => 'tablist')); // Create a placeholder for the panes. $build['panes'] = array('#theme_wrappers' => array('container'), '#attributes' => array('class' => array('tab-content'))); foreach ($tips as $name => $list) { $machine_name = str_replace('-', '_', drupal_html_class($name)); $tab = array('data' => array('#type' => 'link', '#title' => check_plain($name), '#href' => $current_path, '#attributes' => array('role' => 'tab', 'data-toggle' => 'tab'), '#options' => array('fragment' => $machine_name))); if (!$format_id || $format_id === $machine_name) { $tab['class'][] = 'active'; $format_id = $machine_name; } $build['tabs']['#items'][] = $tab; // Extract the actual tip. $tiplist = array(); foreach ($list as $tip) { $tiplist[] = $tip['tip']; } // Construct the pane. $pane = array('#theme_wrappers' => array('container'), '#attributes' => array('class' => array('tab-pane', 'fade'), 'id' => $machine_name), 'list' => array('#theme' => 'item_list', '#items' => $tiplist)); if ($format_id === $machine_name) { $pane['#attributes']['class'][] = 'active'; $pane['#attributes']['class'][] = 'in'; $format_id = $machine_name; } $build['panes'][] = $pane; } return drupal_render($build); }
function deco_preprocess_page(&$vars) { $vars['sidebar_triple'] = FALSE; if (!empty($vars['page']['sidebar_second']) && !empty($vars['page']['sidebar_right_sec']) && !empty($vars['page']['sidebar_first'])) { $vars['classes_array'][] .= ' sidebar-triple'; $vars['sidebar_triple'] = TRUE; } if (!empty($vars['page']['sidebar_right_sec']) && empty($vars['page']['sidebar_second'])) { $vars['page']['sidebar_second'] = $vars['page']['sidebar_right_sec']; $vars['page']['sidebar_right_sec'] = ''; } // set variables for the logo and slogan $site_fields = array(); if ($vars['site_name']) { $site_fields[] = check_plain($vars['site_name']); } if ($vars['site_slogan']) { $site_fields[] = '- ' . check_plain($vars['site_slogan']); } $vars['site_title'] = implode(' ', $site_fields); if (isset($site_fields[0])) { $site_fields[0] = '<span class="site-name">' . $site_fields[0] . '</span>'; } if (isset($site_fields[1])) { $site_fields[1] = '<span class="site-slogan">' . $site_fields[1] . '</span>'; } $vars['site_title_html'] = implode(' ', $site_fields); $vars['primary_menu'] = str_replace('class="menu"', 'class="links primary-links"', render(menu_tree(variable_get('menu_main_links_source', 'main-menu')))); $vars['secondary_menu'] = str_replace('class="menu"', 'class="links secondary-links"', render(menu_tree(variable_get('menu_secondary_links_source', 'secondary-menu')))); }
/** * 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')); }