/** * Returns the next available member id. */ public function next($membership) { $settings = $this->settings + array('pattern' => '', 'suffix' => 1, 'length' => 5, 'advanced' => array()); $settings['advanced'] += array('separator' => '-', 'maxlength' => '', 'case' => 'none', 'ignore_words' => ''); // Build the member id. $member_id = token_replace($settings['pattern'], array('membership_entity' => $membership), array('sanitize' => TRUE, 'clear' => TRUE, 'callback' => '_membership_entity_token_member_id_token_callback', 'settings' => $settings['advanced'])); // Empty member_ids do not need any cleaning. if ($member_id !== '' && $member_id !== NULL) { $member_id = _membership_entity_token_clean_separator($member_id, $settings['advanced']['separator']); } // Optionally add a unique suffix. if (!empty($settings['suffix'])) { $length = $settings['length']; $suffix = 1; // Find the most recent matching member id. $query = db_select('membership_entity', 'm'); $query->addExpression('MAX(member_id)', 'member_id'); $id = $query->condition('member_id', db_like($member_id) . '%', 'LIKE')->execute()->fetchField(); // If a member id already exists increment suffix by 1. if (!empty($id)) { $id = (int) str_replace($member_id, '', $id); $suffix = $id + 1; } $member_id .= str_pad($suffix, $length, '0', STR_PAD_LEFT); } return $member_id; }
/** * {@inheritdoc} */ function entityFindCandidate($entity, $entity_type, $distinction_key) { // This is cached.. $patterns = variable_get('crumbs_' . $entity_type . '_parent_patterns', array()); if (empty($patterns[$distinction_key])) { return NULL; } // Use token to resolve the pattern. $info = entity_get_info($entity_type); $token_data = array($info['token type'] => $entity); $token_options = array('language' => $GLOBALS['language'], 'callback' => 'crumbs_clean_token_values'); $parent = token_replace($patterns[$distinction_key], $token_data, $token_options); if (empty($parent)) { // Token collapsed.. } // Only accept candidates where all tokens are fully resolved. // This means we can't have literal '[' in the path - so be it. if (FALSE !== strpos($parent, '[')) { return NULL; } return $parent; }
/** * Overrides LinkitSearchPluginEntity::createDescription(). */ function createDescription($data) { $description = token_replace(check_plain($this->conf['result_description']), array('term' => $data), array('clear' => TRUE)); return $description; }
function research_menu_item_link($link) { if (empty($link['localized_options'])) { $link['localized_options'] = array(); } if (module_exists('token')) { $query = ""; if (array_key_exists('options', $link) && array_key_exists('query', $link['options'])) { $query = token_replace($link['options']['query'], 'global'); } $href = token_replace($link['href'], 'global'); $title = token_replace($link['title'], 'global'); } return l($title, $href, array('query' => $query)); }
<th>Total</th> <td><?php echo money_format('%(#10n', $commercial_cost_total); ?> </td> <td><?php echo money_format('%(#10n', $member_cost_total); ?> </td> </tr> <tfoot> </table> <div id="boilerplate"><?php if (module_exists('token')) { echo token_replace(variable_get('merci_contract_boilerplate', ''), array('node' => $node)); } else { echo variable_get('merci_contract_boilerplate', ''); } ?> </div> <div id="footer"><?php if (module_exists('token')) { echo token_replace(variable_get('merci_contract_footer', ''), array('node' => $node)); } else { echo variable_get('merci_contract_footer', ''); } ?> </div> </div> </body>
/** * latest_series() - gets the most recent series from the database according to the latest post-modified date and uses the latest_series template from series options for how it is displayed. * * @package Organize Series WordPress Plugin * @since 2.1 * * @uses get_option() - to get the 'latest_series_template' from the options table. * * @uses token_replace() - to replace all the %tokens% in the template for latest_series as set on the series options page. * @uses get_series_ordered - to get all the series according to how it should be ordered. * * @param bool $display - if true the 'latest_series_template' will be echoed else it will be returned. *@param array $args - allow for setting criteria for the latest series being pulled from the database. * * @return string $result - the assembled latest_series code. */ function latest_series($display = true, $args = '') { global $wpdb, $orgseries; $defaults = array('orderby' => 'post_modified', 'order' => 'ASC', 'hide_empty' => true, 'number' => '5'); $args = wp_parse_args($args, $defaults); $args['number'] = absint($args['number']); extract($args, EXTR_SKIP); $settings = $orgseries->settings; $count = $number; $terms = get_series_ordered($args); $result = ''; $result = stripslashes($settings['latest_series_before_template']); $k = 0; foreach ($terms as $latestseries) { if ($k < $count) { $result .= token_replace(stripslashes($settings['latest_series_inner_template']), 'latest_series', $latestseries->term_id); } $k++; } $result .= stripslashes($settings['latest_series_after_template']); if ($display) { echo $result; } else { return $result; } }
<div class="left"> <?php if (!empty($cchunk->field_title['und']['0']['value'])) { ?> <h2><?php print $cchunk->field_title['und']['0']['value']; ?> </h2> <?php } ?> </div> </div> <div class="left"> <?php print token_replace($cchunk->field_sectioncontent['und']['0']['value']); ?> </div> <div class="right"> <?php $anchors = field_collection_item_load($cchunk->field_anchorlinkslist['und'][0]['value']); if (!empty($anchors->field_anchorlinkslisttitle['und']['0']['value'])) { ?> <h3><?php print $anchors->field_anchorlinkslisttitle['und']['0']['value']; ?> </h3> <?php } ?> <ul>
/** * Create a search row description. * * If there is a "result_description", run it thro token_replace. * * @param object $data * An entity object that will be used in the token_place function. * * @return * A string containing the row description. * * @see token_replace() */ function createDescription($data) { $description = token_replace(check_plain($this->conf['result_description']), array($this->plugin['entity_type'] => $data), array('clear' => TRUE)); return $description; }
/** * @param string $selector * @param string $value * * @throws NoSuchElement * * @When /^(?:|I )fill "([^"]*)" with "([^"]*)"$/ */ public function fillField($selector, $value) { $this->element('field', $selector)->setValue(token_replace($value)); }
/** * Handles arguments for views. * * Replaces tokens using token_replace(). * * @param array $args * Usually $this->field['settings']['handler_settings']['view']['args']. * * @return array * The arguments to be send to the View. */ protected function handleArgs($args) { // Parameters for token_replace(). $data = array(); $options = array('clear' => TRUE); if ($entity = $this->entity) { // D7 HACK: For new entities, entity and revision id are not set. This leads to // * token replacement emitting PHP warnings // * views choking on empty arguments // We workaround this by filling in '0' for these IDs // and use a clone to leave no traces of our unholy doings. $info = entity_get_info($this->instance['entity_type']); if (!isset($entity->{$info['entity keys']['id']})) { $entity = clone $entity; $entity->{$info['entity keys']['id']} = '0'; if (!empty($info['entity keys']['revision'])) { $entity->{$info['entity keys']['revision']} = '0'; } } $data[$info['token type']] = $entity; } // Replace tokens for each argument. foreach ($args as $key => $arg) { $args[$key] = token_replace($arg, $data, $options); } return $args; }
// foreach ?> </tbody> <tfoot> <tr class="<?php echo $even_odd; ?> "> <th>Total</th> <td><?php echo money_format('%(#10n', $comreservationsal_cost_total); ?> </td> <td><?php echo money_format('%(#10n', $member_cost_total); ?> </td> </tr> <tfoot> </table> <div id="boilerplate"><?php module_exists('token') ? print token_replace(variable_get('reservations_contract_boilerplate', ''), array('node' => $node)) : (print variable_get('reservations_contract_boilerplate', '')); ?> </div> <div id="footer"><?php module_exists('token') ? print token_replace(variable_get('reservations_contract_footer', ''), array('node' => $node)) : (print variable_get('reservations_contract_footer', '')); ?> </div> </div> </body>
* @see https://drupal.org/node/1728216 */ ?> <article class="<?php print $classes; ?> clearfix"<?php print $attributes; ?> > <header> <div class="cm_image"> <?php if (token_replace('[comment:author:field-user-image:file]', array('comment' => $comment)) != '[comment:author:field-user-image:file]') { $comment_author_pic_file = token_replace('[comment:author:field-user-image:file]', array('comment' => $comment)); } else { $comment_author_pic_file = "bramy.jpg"; } ?> <img src="/sites/default/files/styles/thumbnail/public/<?php echo $comment_author_pic_file; ?> "> <!-- <?php print $picture; ?> --> </div>
/** * * @param drealtyConnectionEntity $connection * @param drealtyRetsResource $resource * @param drealtyRetsClass $class * @param string $key_field * @return int */ function fetch_listings_offset_not_supported_price(drealtyConnectionEntity $connection, $resource, $class, $key_field) { $rets = $this->dc->rets; $chunks = 0; $offset_amount = $class->offset_amount; $offset_max = $class->offset_max; $offset_start = 0; $offset_end = $offset_start + $offset_amount; $query = token_replace($class->override_status_query_text, array('drealty-class' => $class)); $options = array('count' => 1, 'Format' => 'COMPACT-DECODED', 'Select' => $key_field); if ($this->dc->connect($connection->conid)) { $search = $rets->SearchQuery($resource->systemname, $class->systemname, $query, $options); if ($error = $rets->Error()) { drush_log(dt("drealty encountered an error: (Type: @type Code: @code Msg: @text)", array("@type" => $error['type'], "@code" => $error['code'], "@text" => $error['text']), 'error')); } $total = $rets->TotalRecordsFound($search); $rets->FreeResult($search); $offset_query = "{$query},({$class->offset_field}={$offset_start}-{$offset_end})"; $count = 0; $options['Select'] = $this->get_fields($connection->conid, $class->cid); if ($class->process_images) { $options['Select'] .= ',' . $class->photo_timestamp_field; } while ($count < $total) { $search = $rets->SearchQuery($resource->systemname, $class->systemname, $offset_query, $options); if ($rets->NumRows($search) > 0) { while ($listing = $rets->FetchRow($search)) { $listing['hash'] = $this->calculate_hash($listing, $connection, $class); $this->queue->createItem($listing); $count++; } } $rets->FreeResult($search); drush_log("Resource: {$resource->systemname} Class: {$class->systemname} Listings Downloaded: {$count} Query: {$offset_query}"); if ($offset_end < $offset_max) { $offset_start = $offset_end + 1; $offset_end += $offset_amount; $offset_query = "{$query},({$class->offset_field}={$offset_start}-{$offset_end})"; } else { $offset_query = "{$query},({$class->offset_field}={$offset_max}+)"; } } $this->dc->disconnect(); } else { $error = $rets->Error(); watchdog('drealty', "drealty encountered an error: (Type: @type Code: @code Msg: @text)", array("@type" => $error['type'], "@code" => $error['code'], "@text" => $error['text']), WATCHDOG_ERROR); drush_log(dt("drealty encountered an error: (Type: @type Code: @code Msg: @text)", array("@type" => $error['type'], "@code" => $error['code'], "@text" => $error['text']), 'error')); } unset($listings); }
return; } foreach (array_keys($result['message']) as $mid) { $i++; // Load the message. $message = message_load($mid); $tokens = array('message:field-node-reference:url', 'message:field-node-reference:title'); $save_message = FALSE; foreach ($tokens as $token) { // Check that the token is not hard coded. if (isset($message->arguments['@{' . $token . '}'])) { continue; } $save_message = TRUE; // Creating a hard coded value for the toekn. $token_options = message_get_property_values($message, 'data', 'token options'); $context = array('message' => $message); $message->arguments['@{' . $token . '}'] = token_replace('[' . $token . ']', $context, $token_options); } if ($save_message) { $param = array('@mid' => $mid, '@tokens' => implode(' ', $tokens)); drush_log(dt($mid . '\\ ' . $max . ') Processing the @tokens in the message @mid', $param), 'success'); // Saving the message and the display message for the user. message_save($message); // The script taking to much memory. Stop it and display message. if (round(memory_get_usage() / 1048576) >= $memory_limit) { return drush_set_error('OS_ACTIVITY OUT_OF_MEMORY', dt('Stopped before out of memory. Last message ID was @mid', array('@mid' => $mid))); } } } }
/** * Handles arguments for views. * * Replaces tokens using token_replace(). * * @param array $args * Usually $this->field['settings']['handler_settings']['view']['args']. * * @return array * The arguments to be send to the View. */ protected function handleArgs($args) { // Parameters for token_replace(). $data = array(); $options = array('clear' => TRUE); // Check if the entity has an ID. If not, don't pass the entity to token_replace(). if ($this->entity) { list($id, $vid, $bundle) = entity_extract_ids($this->instance['entity_type'], $this->entity); if (!empty($id)) { // Only pass the entity to token_replace() if it has a valid ID. $data = array($this->entity_type_token => $this->entity); } } // Replace tokens for each argument. foreach ($args as $key => $arg) { $args[$key] = token_replace($arg, $data, $options); } return $args; }
/** * Build the search row description. * * If there is a "result_description", run it thro token_replace. * * @param object $data * An object that will be used in the token_place function * * @see token_replace() */ function buildDescription($data) { if (isset($this->profile->data[$this->plugin['name']]['result_description'])) { $description = token_replace(check_plain($this->profile->data[$this->plugin['name']]['result_description']), array($this->plugin_name => $data), array('clear' => TRUE)); return $description; } }
$secondary_image_2 = field_get_items('node', $node, 'field_pro_secondary_image_2'); if (!empty($secondary_image_2)) { $image_item = array('style_name' => '100x100', 'path' => $secondary_image_2[0]['uri'], 'width' => '', 'height' => '', 'alt' => $secondary_image_2[0]['alt'], 'title' => $secondary_image_2[0]['title']); $output = theme('image_style', $image_item); print $output; } ?> </div></a><?php } ?> <?php if ($node->field_pro_secondary_image_3) { ?> <a class="colorbox" href=" <?php $secondary_image_3 = token_replace('[node:field_pro_secondary_image_3]', array('node' => $node)); print $secondary_image_3; ?> "> <div class="secondary-images-third secondary-images"> <?php $secondary_image_3 = field_get_items('node', $node, 'field_pro_secondary_image_3'); if (!empty($secondary_image_3)) { $image_item = array('style_name' => '100x100', 'path' => $secondary_image_3[0]['uri'], 'width' => '', 'height' => '', 'alt' => $secondary_image_3[0]['alt'], 'title' => $secondary_image_3[0]['title']); $output = theme('image_style', $image_item); print $output; } ?> </div></a><?php
/** * Implements EntityReferenceHandler::getLabel(). */ public function getLabel($entity) { return token_replace($this->field['settings']['handler_settings']['display'], array('geoname' => $entity)); }
/** * This will return a provided thumbnail image for a video. * * @param $field * This is the field providing settings for the video thumbnail. * @param $item * This is the data returned by the field. It requires at the least to be an array with 'value' and 'provider'. * $item['value'] will be the video code, and $item['provider'] will be the provider, such as youtube. * @param $formatter * This is the formatter for the view. This will nearly always be video_thumbnail. * @param $node * This is the node object containing the field. * @param $no_link * Optional. If FALSE, then we provide a link to the node. * (In retrospect, this should have been $link, defaulting to TRUE. * TODO: fix? problem though is that this goes deeper up the tree.) * @param $options * Optional array. This is to pass optional overrides. currently: * $options['width'] and $options['height'], if provided, will override any field settings for the thumbnail w/h. * $options['link_url'], if provided, will cause the thumbnail link to go to another URL other than node/nid. $no_link must be FALSE. * $options['title'], if provided, will set the title of the link and image. * $options['link_title'], if provided, will set the title of the link when no image is provided. otherwise, it defaults to 'See video'. * $options['image_title'], if provided, will set the title attribute of the href link, defaulting to $options['link_title']. * $options['image_alt'], if provided, will set the alt attribute of the href link, defaulting to $options['link_title']. * $options['thumbnail_url'], if provided, will completely override the thumbnail image entirely. * $options['attributes'], if provided, sets the attributes for the displayed image. * @return * The thumbnail output. */ function nys_emvideo_video_thumbnail($field, $item, $formatter, $node, $no_link = FALSE, $options = array()) { // Thickbox requires some output, so make sure we have at least a blank string. $output = ''; if (arg(0) == 'senator' && (arg(2) == 'video' || arg(2) == 'gallery') || arg(0) == 'media' || arg(0) == 'video') { $width = 120; $height = 90; } else { $width = isset($options['width']) ? $options['width'] : ($field['widget']['thumbnail_width'] ? $field['widget']['thumbnail_width'] : variable_get('emvideo_default_video_width', EMVIDEO_DEFAULT_THUMBNAIL_WIDTH)); $height = isset($options['height']) ? $options['height'] : ($field['widget']['thumbnail_height'] ? $field['widget']['thumbnail_height'] : variable_get('emvideo_default_video_height', EMVIDEO_DEFAULT_THUMBNAIL_HEIGHT)); } // Get a thumbnail URL. This can be an override through $options['thumbnail_url'], // defined by the provider (the usual case), or a default image. if (isset($options['thumbnail_url']) || $item['value'] && $item['provider']) { // If we've set $options['thumbnail_url'], then we'll just use that. $thumbnail_url = isset($options['thumbnail_url']) ? $options['thumbnail_url'] : ''; // Otherwise, if we have emthumb installed, then give it a chance to override our thumbnail. if (empty($thumbnail_url) && function_exists('emthumb_thumbnail_url')) { $thumbnail_url = emthumb_thumbnail_url($item); } // If we don't have a custom thumbnail, then see if the provider gives us a thumbnail. if (empty($thumbnail_url)) { $thumbnail_url = emfield_include_invoke('emvideo', $item['provider'], 'thumbnail', $field, $item, $formatter, $node, $width, $height, $options); } } // If we still don't have a thumbnail, then apply a default thumbnail, if it exists. if (empty($thumbnail_url)) { $default_thumbnail_url = $field['widget']['thumbnail_default_path'] ? $field['widget']['thumbnail_default_path'] : variable_get('emvideo_default_thumbnail_path', NULL); if ($default_thumbnail_url) { $thumbnail_url = base_path() . $default_thumbnail_url; } } // Define the thumbnail link's path. $link_url = isset($options['link_url']) ? $options['link_url'] : 'node/' . $node->nid; // Define the title/alt to display for the link hover. $link_title = isset($options['link_title']) ? $options['link_title'] : (isset($options['title']) ? $options['title'] : (isset($field['widget']['thumbnail_link_title']) ? $field['widget']['thumbnail_link_title'] : variable_get('emvideo_default_thumbnail_link_title', t('See video')))); if (module_exists('token')) { // Allow the editor to use [title] tokens. $link_title = token_replace($link_title, 'global', $node); } $image_title = isset($options['image_title']) ? $options['image_title'] : $link_title; $image_alt = isset($options['image_alt']) ? $options['image_alt'] : $link_title; if ($thumbnail_url) { //$width = isset($options['width']) ? $options['width'] : NULL; $width = isset($width) ? $width : ($field['widget']['thumbnail_width'] ? $field['widget']['thumbnail_width'] : variable_get('emvideo_default_thumbnail_width', EMVIDEO_DEFAULT_THUMBNAIL_WIDTH)); //$height = isset($options['height']) ? $options['height'] : NULL; $height = isset($height) ? $height : ($field['widget']['thumbnail_height'] ? $field['widget']['thumbnail_height'] : variable_get('emvideo_default_thumbnail_height', EMVIDEO_DEFAULT_THUMBNAIL_HEIGHT)); $attributes = isset($options['attributes']) ? $options['attributes'] : array(); $attributes['width'] = isset($attributes['width']) ? $attributes['width'] : $width; $attributes['height'] = isset($attributes['height']) ? $attributes['height'] : $height; $image = theme('image', $thumbnail_url, $image_alt, $image_title, $attributes, FALSE); if ($no_link) { // Thickbox requires the thumbnail returned without the link. $output = $image; } else { $output = l($image, $link_url, array('html' => TRUE)); } } else { // If all else fails, then just print a 'see video' type link. if (!$no_link) { $output = l($link_title, $link_url); } } return $output; }
?> <?php print render($tabs); ?> <?php } ?> </div> <?php } ?> <?php } ?> <?php print check_markup(token_replace($cchunks_content[$k]), 'full_html', '', FALSE); ?> </div> <div class="node-sidebar col-md-3"> <?php if (!empty($cchunks_sidebar[$k])) { ?> <?php print $cchunks_sidebar[$k]; ?> <?php } ?> </div> </div>
/** * Generate the first breadcrumb items basing on a custom menu. */ function _europa_breadcrumb_menu(&$variables) { $menu_links = menu_tree('menu-dt-breadcrumb-menu'); $new_items = array(); global $language; $front = drupal_is_front_page(); if (!empty($menu_links)) { $i = 0; foreach ($menu_links as $key => $menu_item) { if (is_numeric($key)) { // We don't want to show the home link in the home page. if (!($front && $menu_item['#href'] == '<front>')) { $options = array('language' => $language); $title = token_replace($menu_item['#title'], $menu_item, $options); $new_items[] = _easy_breadcrumb_build_item($title, array(), $menu_item['#href']); $i++; } } } if (!empty($new_items)) { // The menu is used as the starting point of the breadcrumb. $variables['breadcrumb'] = array_merge($new_items, $variables['breadcrumb']); // Alter the number of segments in the breadcrumb. $variables['segments_quantity'] += $i; } } }
/** * Build the search row description. * * If there is a "result_description", run it thro token_replace. * * @param object $data * An entity object that will be used in the token_place function. * * @see token_replace() */ function buildDescription($data) { $description = token_replace(check_plain($this->conf['result_description']), array($this->plugin['entity_type'] => $data), array('clear' => TRUE)); if (isset($this->conf['reverse_menu_trail']) && $this->conf['reverse_menu_trail']) { $description .= $this->buildReverseMenuTrail($data); } return $description; }
?> </div> <?php } ?> <?php if (isset($fields['share']) && isset($fields['share']->content)) { ?> <div class="information-row asset-download"> <h3><?php print t('Embed'); ?> </h3> <?php print token_replace($fields['share']->content); ?> </div> <?php } ?> </div> <div class="asset-technical-information"> <ul id="asset-tabs"> <li> <?php print l('Description', 'asset/detail/' . $fields['asset_id']->raw, array('fragment' => 'tab-metadata-dc', 'attributes' => array('name' => 'tab-metadata-dc'))); ?> </li>