Example #1
0
/**
 * Preprocess variables for page.tpl.php
 * default variales for page.tpl.php:
 * $logo, $front_page, $site_name, $site_slogan, $messages
 * $title_prefix, $title_suffix, $tabs, $action_links
 * $feed_icons, $breadcrumb
 */
function water_preprocess_page(&$vars)
{
    if (isset($vars['node'])) {
        // If the node type is "blog_madness" the template suggestion will be "page--blog-madness.tpl.php".
        $vars['theme_hook_suggestions'][] = 'page__' . $vars['node']->type;
        if ($vars['node']->type == 'deprecated_organization') {
            //var_dump($vars['node']);
            //$vars['organization_geolocation'] = array($vars['node']->field_latitude['und']['0']['value'], $vars['node']->field_longitude['und']['0']['value']);
            /*
             * LOAD GMAPS MODULE
             */
            //add html element 'organization-gmap-canvas' in template file that will hold Google map
            //Load gmap3_tools.inc file
            module_load_include('inc', 'gmap3_tools');
            //all gmap3_tools_add_map() function from API file with appropriate map configuratio array
            gmap3_tools_add_map(array('mapId' => 'organization-gmap-canvas', 'mapOptions' => array('centerX' => -34.397, 'centerY' => 150.644, 'zoom' => 12), 'markers' => array(gmap3_tools_create_marker(-1, -1, 'Home', 'Home')), 'geocodeAddress' => $vars['node']->field_city['und']['0']['taxonomy_term']->name, 'gmap3ToolsOptions' => array('defaultMarkersPosition' => GMAP3_TOOLS_DEFAULT_MARKERS_POSITION_CENTER)));
        }
        //create a variable to hold rich title field added to specific content types
        $view = node_view($vars['node']);
        $vars['rich_title'] = render($view['field_rich_title']);
    }
    //var_dump($vars);
    //var_export($vars);
    //var_dump(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS));
    //    $vars['contact_form'] = drupal_render(drupal_get_form('contact_site_form'));
}
Example #2
0
/**
 * HOOK_builder_content_view()
 */
function HOOK_builder_content_view($delta = '', $content = array())
{
    $content = '';
    switch ($delta) {
        case 'node':
            $node_content = '';
            if (!empty($content['settings']['nid'])) {
                $nid = $content['settings']['nid'];
                if ($node = node_load($nid)) {
                    if (isset($content['settings']['hide_node_title']) && $content['settings']['hide_node_title']) {
                        // hide node title.
                        $node->title = FALSE;
                    }
                    $node_view = node_view($node, $content['settings']['view_mode']);
                    $node_content = render($node_view);
                }
            }
            $content['content'] = $node_content;
            break;
        case 'custom_text':
            $custom_text_value = isset($content['settings']['custom_text']['value']) ? $content['settings']['custom_text']['value'] : '';
            if (isset($content['settings']['custom_text']['format'])) {
                $custom_text_value = check_markup($custom_text_value, $content['settings']['custom_text']['format']);
            }
            $content['content'] = $custom_text_value;
            break;
            return $content;
    }
}
  /**
   * Gallery display.
   *
   * @return string
   *   Return Gallery output string.
   */
  public function gallery() {

    // Load the language manager service, so we can parse the user's current language.
    $langcode    = $this->languageManager()->getCurrentLanguage('language');

    $photographs = $this->loadAllPhotos();
    $view_mode   = 'teaser';
    $gallery     = array();

    // Loop through the loaded photograph node objects and output their rendered result into a list.
    foreach ($photographs as $photograph) {
      $render    = node_view($photograph, $view_mode, $langcode);
      $gallery[] = render($render);
    }

    // If the gallery is empty, we should apologise.
    if (empty($gallery)) {
      return [
        '#type' => 'markup',
        '#markup' => $this->t('Sorry, I have no photographs to share at the moment'),
        '#prefix' => '<h2>',
        '#suffix' => '</h2>',
      ];
    }

    // Return an item list of photographs for our gallery.
    return [
      '#theme' => 'item_list',
      '#items' => $gallery,
    ];

  }
  /**
   * Returns content for recent images.
   *
   * @return string
   *   A HTML-formatted string with the administrative page content.
   *
   */
  public function contentOverview() {
    // @todo a lot of duplicate code can be consolidated in these controllers.
    $query = db_select('node', 'n')
      ->extend('Drupal\Core\Database\Query\PagerSelectExtender');
    $query->join('photos_album', 'p', 'p.pid = n.nid');
    $query->fields('n', array('nid'));
    $query->orderBy('n.nid', 'DESC');
    $query->limit(10);
    $query->addTag('node_access');
    $results = $query->execute();

    $output = '';
    foreach ($results as $result) {
      $node = \Drupal::entityManager()->getStorage('node')->load($result->nid);
      $node_view = node_view($node, 'full');
      $output .= \Drupal::service("renderer")->render($node_view);
    }
    if ($output) {
      $pager = array(
        '#type' => 'pager'
      );
      $output .= \Drupal::service("renderer")->render($pager);
    }
    else {
      $output .= t('No albums have been created yet.');
    }

    return array(
      '#markup' => $output
    );
  }
Example #5
0
/**
 * Returns HTML for a node preview for display during node creation and editing.
 *
 * Overrides theme_node_preview() in modules/node/node.pages.inc.
 *
 * @param $variables
 *   An associative array containing:
 *   - node: The node object which is being previewed.
 *
 * @see node_preview()
 * @ingroup themeable
 */
function _pol_proc_admin_node_preview($variables)
{
    $node = $variables['node'];
    $output = '<div class="preview">';
    /*if ('policy' == $node->type) {
        dsm($variables);
        // Load the node into a context.
        ctools_include('node_view', 'page_manager', 'plugins/tasks');
        $elements = page_manager_node_view_page(clone $node);
        $output .= drupal_render($elements);
        drupal_add_css(drupal_get_path('theme', 'pol_proc_theme') . '/css/colors.css');
        drupal_add_css(drupal_get_path('theme', 'pol_proc_theme') . '/css/site.css');
      } elseif ('procedure' == $node->type) {
        $output = _pol_proc_admin_node_procedure_preview($node);
      } else { */
    $preview_trimmed_version = FALSE;
    $elements = node_view(clone $node, 'teaser');
    $trimmed = drupal_render($elements);
    $elements = node_view($node, 'full');
    $full = drupal_render($elements);
    // Do we need to preview trimmed version of post as well as full version?
    if ($trimmed != $full) {
        drupal_set_message(t('The trimmed version of your post shows what your post looks like when promoted to the main page or when exported for syndication.<span class="no-js"> You can insert the delimiter "&lt;!--break--&gt;" (without the quotes) to fine-tune where your post gets split.</span>'));
        $output .= '<h3>' . t('Preview trimmed version') . '</h3>';
        $output .= $trimmed;
        $output .= '<h3>' . t('Preview full version') . '</h3>';
        $output .= $full;
    } else {
        $output .= $full;
    }
    //}
    $output .= "</div>\n";
    return $output;
}
Example #6
0
 /**
  * Drupal example
  */
 public function getNode()
 {
     $node = new \erdiko\drupal\models\Node();
     $post = $node->getNode(1);
     $content = \drupal_render(\node_view($post));
     $content .= "<pre>" . print_r($post, true) . "</pre>";
     $this->setContent($content);
 }
Example #7
0
/**
 * Returns the item specific content as render array or html string.
 *
 * The parameter $param contains the unique load parameter of the requested item.
 *
 * @param $container_index      int     Index of proximity container (if more than one container exists in one page).
 * @param $param                string  The item specific load parameter (see also hook_proximity_ajax_load_params_alter).
 * @param $render_item          mixed   The rendered content to be returned to the client. The $render_item should be
 *                                      replaced either by a string (rendered html content), a render array or an integer (error code).
 */
function hook_proximity_ajax_render_item_alter($container_index, $param, &$render_item)
{
    // Example: the $param variable contains a node id (see hook_proximity_ajax_load_params_alter),
    // return the render array for the specific node
    if ($node = node_load($param)) {
        $render_item = node_view($node);
    }
}
 /**
  * {@inheritdoc}
  */
 public function execute($node = NULL)
 {
     foreach ($this->configuration['keywords'] as $keyword) {
         $elements = node_view(clone $node);
         if (strpos(drupal_render($elements), $keyword) !== FALSE || strpos($node->label(), $keyword) !== FALSE) {
             $node->setPublished(FALSE);
             $node->save();
             break;
         }
     }
 }
Example #9
0
 /**
  * Displays a node revision.
  *
  * @param int $node_revision
  *   The node revision ID.
  *
  * @return array
  *   An array suitable for drupal_render().
  */
 public function revisionShow($node_revision)
 {
     /** @var NodeInterface $node */
     $node = $this->entityTypeManager()->getStorage('node')->loadRevision($node_revision);
     // Determine view mode.
     $view_mode = \Drupal::config('ds_extras.settings')->get('override_node_revision_view_mode');
     drupal_static('ds_view_mode', $view_mode);
     $page = node_view($node, $view_mode);
     unset($page['nodes'][$node->id()]['#cache']);
     return $page;
 }
Example #10
0
function nbadraft_main_form_submit($form, &$form_status)
{
    $form_status['rebuild'] = TRUE;
    $draft_team_tid = $form_status['values']['draft_team'];
    $draft_year_tid = $form_status['values']['draft_year'];
    $nodes = get_draft_picks_for_team_year($draft_year_tid, $draft_team_tid);
    $form_status['storage']['results'] = array();
    foreach ($nodes as $node) {
        $form_status['storage']['results'][] = node_view($node, 'teaser');
    }
}
Example #11
0
 /**
  * {@inheritdoc}
  */
 public function getValue(ResultRow $values, $field = NULL)
 {
     $nid = parent::getValue($values, $field);
     if (!is_null($nid)) {
         // @todo Refactor to allow display price to be calculated.
         $node = node_load($nid);
         return $node->price->value;
         // !TODO Refactor so that all variants are loaded at once in the pre_render hook.
         $node = node_view(node_load($nid), 'teaser');
         return $node['display_price']['#value'];
     }
 }
Example #12
0
 /**
  * Provides the replacement html to be rendered in place of the embed code.
  *
  * Does not handle nested embeds.
  *
  * @param array $matches
  *   Array of matches by preg_replace_callback
  *
  * @return string
  *   The rendered HTML replacing the embed code
  */
 public function renderChart($matches)
 {
     /* @var $node \Drupal\Node\NodeInterface */
     $node = Node::load($matches[1]);
     if ($node == FALSE || !$node->isPublished() || !$node->access('view')) {
         return "[[chart-nid:{$matches[1]},chart-view-mode:{$matches[2]}]]";
     } else {
         $view = node_view($node, $matches[2]);
         $render = drupal_render($view);
         return $render;
     }
 }
 public function nodeView($node, $view_mode = 'full')
 {
     if (empty($node)) {
         return '';
     }
     if (is_array($node)) {
         $build = node_view_multiple($node, $view_mode);
     } else {
         $build = node_view($node, $view_mode);
     }
     return drupal_render($build);
 }
 /**
  * Tests debug markup added to Twig template output.
  */
 function testTwigDebugMarkup()
 {
     /** @var \Drupal\Core\Render\RendererInterface $renderer */
     $renderer = $this->container->get('renderer');
     $extension = twig_extension();
     \Drupal::service('theme_handler')->install(array('test_theme'));
     \Drupal::service('theme_handler')->setDefault('test_theme');
     $this->drupalCreateContentType(array('type' => 'page'));
     // Enable debug, rebuild the service container, and clear all caches.
     $parameters = $this->container->getParameter('twig.config');
     $parameters['debug'] = TRUE;
     $this->setContainerParameter('twig.config', $parameters);
     $this->rebuildContainer();
     $this->resetAll();
     $cache = $this->container->get('theme.registry')->get();
     // Create array of Twig templates.
     $templates = drupal_find_theme_templates($cache, $extension, drupal_get_path('theme', 'test_theme'));
     $templates += drupal_find_theme_templates($cache, $extension, drupal_get_path('module', 'node'));
     // Create a node and test different features of the debug markup.
     $node = $this->drupalCreateNode();
     $build = node_view($node);
     $output = $renderer->renderRoot($build);
     $this->assertTrue(strpos($output, '<!-- THEME DEBUG -->') !== FALSE, 'Twig debug markup found in theme output when debug is enabled.');
     $this->setRawContent($output);
     $this->assertTrue(strpos($output, "THEME HOOK: 'node'") !== FALSE, 'Theme call information found.');
     $this->assertTrue(strpos($output, '* node--1--full' . $extension . PHP_EOL . '   x node--1' . $extension . PHP_EOL . '   * node--page--full' . $extension . PHP_EOL . '   * node--page' . $extension . PHP_EOL . '   * node--full' . $extension . PHP_EOL . '   * node' . $extension) !== FALSE, 'Suggested template files found in order and node ID specific template shown as current template.');
     $this->assertEscaped('node--<script type="text/javascript">alert(\'yo\');</script>');
     $template_filename = $templates['node__1']['path'] . '/' . $templates['node__1']['template'] . $extension;
     $this->assertTrue(strpos($output, "BEGIN OUTPUT from '{$template_filename}'") !== FALSE, 'Full path to current template file found.');
     // Create another node and make sure the template suggestions shown in the
     // debug markup are correct.
     $node2 = $this->drupalCreateNode();
     $build = node_view($node2);
     $output = $renderer->renderRoot($build);
     $this->assertTrue(strpos($output, '* node--2--full' . $extension . PHP_EOL . '   * node--2' . $extension . PHP_EOL . '   * node--page--full' . $extension . PHP_EOL . '   * node--page' . $extension . PHP_EOL . '   * node--full' . $extension . PHP_EOL . '   x node' . $extension) !== FALSE, 'Suggested template files found in order and base template shown as current template.');
     // Create another node and make sure the template suggestions shown in the
     // debug markup are correct.
     $node3 = $this->drupalCreateNode();
     $build = array('#theme' => 'node__foo__bar');
     $build += node_view($node3);
     $output = $renderer->renderRoot($build);
     $this->assertTrue(strpos($output, "THEME HOOK: 'node__foo__bar'") !== FALSE, 'Theme call information found.');
     $this->assertTrue(strpos($output, '* node--foo--bar' . $extension . PHP_EOL . '   * node--foo' . $extension . PHP_EOL . '   * node--&lt;script type=&quot;text/javascript&quot;&gt;alert(&#039;yo&#039;);&lt;/script&gt;' . $extension . PHP_EOL . '   * node--3--full' . $extension . PHP_EOL . '   * node--3' . $extension . PHP_EOL . '   * node--page--full' . $extension . PHP_EOL . '   * node--page' . $extension . PHP_EOL . '   * node--full' . $extension . PHP_EOL . '   x node' . $extension) !== FALSE, 'Suggested template files found in order and base template shown as current template.');
     // Disable debug, rebuild the service container, and clear all caches.
     $parameters = $this->container->getParameter('twig.config');
     $parameters['debug'] = FALSE;
     $this->setContainerParameter('twig.config', $parameters);
     $this->rebuildContainer();
     $this->resetAll();
     $build = node_view($node);
     $output = $renderer->renderRoot($build);
     $this->assertFalse(strpos($output, '<!-- THEME DEBUG -->') !== FALSE, 'Twig debug markup not found in theme output when debug is disabled.');
 }
Example #15
0
/**
 * Returns the item specific content as render array or html string. The $param attribute contains the item specific parameter
 * added to the ajax request.
 *
 * @param $container_index      int     Index of proximity container (if more than one container exists in one page).
 * @param $param                string  The item specific load parameter (see also hook_proximity_ajax_load_params_alter).
 * @param $render_item          mixed   The rendered content to be returned to the client. The $render_item should be
 *                                      replaced either by a string (rendered html content), a render array or an integer (error code).
 */
function pixelgarage_proximity_ajax_render_item_alter($container_index, $param, &$render_item)
{
    // return the render array for the specific node, if available
    if ($node = node_load($param)) {
        $view_mode = 'full';
        if (property_exists($node, 'ds_switch')) {
            // take an alternate view mode set by the ds switch
            $view_mode = $node->ds_switch;
        }
        $render_item = node_view($node, $view_mode);
    }
}
Example #16
0
 /**
  * Helper function to setup the faq answer.
  *
  * @param array &$data
  *   Array reference to store display data in.
  * @param Drupal\node\NodeInterface $node
  *   The node object.
  * @param string $back_to_top
  *   An array containing the "back to top" link.
  * @param bool $teaser
  *   Whether or not to use teasers.
  * @param bool $links
  *   Whether or not to show node links.
  */
 public static function viewAnswer(&$data, \Drupal\node\NodeInterface $node, $teaser)
 {
     $faq_settings = \Drupal::config('faq.settings');
     // TODO: hide 'submitted by ... on ...'
     $view_mode = $teaser ? 'teaser' : 'full';
     $node_build = node_view($node, $view_mode);
     hide($node_build['title']);
     if (!$faq_settings->get('question_long_form')) {
         hide($node_build['field_detailed_question']);
     }
     $content = drupal_render($node_build);
     $content .= FaqViewer::initBackToTop();
     $data['body'] = SafeMarkup::set($content);
 }
/**
 * Implements hook_preprocess_region().
 */
function spartan_preprocess_region(&$vars)
{
    global $language;
    switch ($vars['region']) {
        // Menu region.
        case 'menu':
            $footer_menu_cache = cache_get("footer_menu_data:" . $language->language);
            if ($footer_menu_cache) {
                $footer_menu = $footer_menu_cache->data;
            } else {
                $footer_menu = menu_tree_output(_spartan_menu_build_tree('main-menu', array('max_depth' => 2)));
                cache_set("footer_menu_data:" . $language->language, $footer_menu);
            }
            //set the active trail
            $active_trail = menu_get_active_trail();
            foreach ($active_trail as $trail) {
                if (isset($trail['mlid']) && isset($footer_menu[$trail['mlid']])) {
                    $footer_menu[$trail['mlid']]['#attributes']['class'][] = 'active-trail';
                }
            }
            $vars['dropdown_menu'] = $footer_menu;
            break;
            // Default footer content.
        // Default footer content.
        case 'footer_first':
            $footer_menu_cache = cache_get("footer_menu_data:" . $language->language);
            if ($footer_menu_cache) {
                $footer_menu = $footer_menu_cache->data;
            } else {
                $footer_menu = menu_tree_output(_spartan_menu_build_tree('main-menu', array('max_depth' => 2)));
                cache_set("footer_menu_data:" . $language->language, $footer_menu);
            }
            //set the active trail
            $active_trail = menu_get_active_trail();
            foreach ($active_trail as $trail) {
                if (isset($trail['mlid']) && isset($footer_menu[$trail['mlid']])) {
                    $footer_menu[$trail['mlid']]['#attributes']['class'][] = 'active-trail';
                }
            }
            $vars['footer_menu'] = $footer_menu;
            $vars['site_name'] = $site_name = variable_get('site_name');
            $vars['footer_logo'] = l(theme('image', array('path' => drupal_get_path('theme', 'spartan') . "/logo-sm.png", 'alt' => "{$site_name} logo")), '', array("html" => TRUE, 'attributes' => array('class' => 'logo')));
            if (function_exists('defaultcontent_get_node') && ($node = defaultcontent_get_node("email_update"))) {
                $node = node_view($node);
                $vars['subscribe_form'] = $node['webform'];
            }
            //krumo($vars['footer_menu']);
            break;
    }
}
 /**
  * Displays the bean.
  */
 public function view($bean, $content, $view_mode = 'default', $langcode = NULL)
 {
     $query = new EntityFieldQuery();
     $query->entityCondition('entity_type', 'node')->entityCondition('bundle', 'article')->propertyCondition('status', 1)->propertyOrderBy('created', 'DESC')->range(0, $bean->settings['records_shown']);
     $result = $query->execute();
     if (empty($result)) {
         $content['nodes'] = array();
     } else {
         foreach ($result['node'] as $node) {
             $node = node_load($node->nid, $node->vid);
             $content['nodes'][$node->nid] = node_view($node, $bean->settings['node_view_mode']);
         }
     }
     $content['more_link']['#markup'] = theme('article_listing_more_link', array('text' => $bean->more_link['text'], 'path' => $bean->more_link['path']));
     return $content;
 }
Example #19
0
/**
 * Book printing recursion.
 */
function _tao_print_book_children($link, &$content, &$zomglimit, $limit = 500)
{
    if ($zomglimit < $limit) {
        $zomglimit++;
        if (!empty($link['link']['nid'])) {
            $node = node_load($link['link']['nid']);
            if ($node) {
                $content .= node_view($node);
            }
            if (!empty($link['below'])) {
                foreach ($link['below'] as $child) {
                    _tao_print_book_children($child, $content);
                }
            }
        }
    }
}
 /**
  * Tests debug markup added to Twig template output.
  */
 function testTwigDebugMarkup()
 {
     $extension = twig_extension();
     theme_enable(array('test_theme'));
     \Drupal::config('system.theme')->set('default', 'test_theme')->save();
     // Enable debug, rebuild the service container, and clear all caches.
     $this->settingsSet('twig_debug', TRUE);
     $this->rebuildContainer();
     $this->resetAll();
     $cache = $this->container->get('theme.registry')->get();
     // Create array of Twig templates.
     $templates = drupal_find_theme_templates($cache, $extension, drupal_get_path('theme', 'test_theme'));
     $templates += drupal_find_theme_templates($cache, $extension, drupal_get_path('module', 'node'));
     // Create a node and test different features of the debug markup.
     $node = $this->drupalCreateNode();
     $build = node_view($node);
     $output = drupal_render($build);
     $this->assertTrue(strpos($output, '<!-- THEME DEBUG -->') !== FALSE, 'Twig debug markup found in theme output when debug is enabled.');
     $this->assertTrue(strpos($output, "CALL: _theme('node')") !== FALSE, 'Theme call information found.');
     $this->assertTrue(strpos($output, '* node--1--full' . $extension . PHP_EOL . '   x node--1' . $extension . PHP_EOL . '   * node--page--full' . $extension . PHP_EOL . '   * node--page' . $extension . PHP_EOL . '   * node--full' . $extension . PHP_EOL . '   * node' . $extension) !== FALSE, 'Suggested template files found in order and node ID specific template shown as current template.');
     $template_filename = $templates['node__1']['path'] . '/' . $templates['node__1']['template'] . $extension;
     $this->assertTrue(strpos($output, "BEGIN OUTPUT from '{$template_filename}'") !== FALSE, 'Full path to current template file found.');
     // Create another node and make sure the template suggestions shown in the
     // debug markup are correct.
     $node2 = $this->drupalCreateNode();
     $build = node_view($node2);
     $output = drupal_render($build);
     $this->assertTrue(strpos($output, '* node--2--full' . $extension . PHP_EOL . '   * node--2' . $extension . PHP_EOL . '   * node--page--full' . $extension . PHP_EOL . '   * node--page' . $extension . PHP_EOL . '   * node--full' . $extension . PHP_EOL . '   x node' . $extension) !== FALSE, 'Suggested template files found in order and base template shown as current template.');
     // Create another node and make sure the template suggestions shown in the
     // debug markup are correct.
     $node3 = $this->drupalCreateNode();
     $build = array('#theme' => 'node__foo__bar');
     $build += node_view($node3);
     $output = drupal_render($build);
     $this->assertTrue(strpos($output, "CALL: _theme('node__foo__bar')") !== FALSE, 'Theme call information found.');
     $this->assertTrue(strpos($output, '* node--foo--bar' . $extension . PHP_EOL . '   * node--foo' . $extension . PHP_EOL . '   * node--3--full' . $extension . PHP_EOL . '   * node--3' . $extension . PHP_EOL . '   * node--page--full' . $extension . PHP_EOL . '   * node--page' . $extension . PHP_EOL . '   * node--full' . $extension . PHP_EOL . '   x node' . $extension) !== FALSE, 'Suggested template files found in order and base template shown as current template.');
     // Disable debug, rebuild the service container, and clear all caches.
     $this->settingsSet('twig_debug', FALSE);
     $this->rebuildContainer();
     $this->resetAll();
     $build = node_view($node);
     $output = drupal_render($build);
     $this->assertFalse(strpos($output, '<!-- THEME DEBUG -->') !== FALSE, 'Twig debug markup not found in theme output when debug is disabled.');
 }
/**
 * Implements hook_preprocess_region().
 */
function openomega_preprocess_region(&$vars)
{
    global $language;
    switch ($vars['region']) {
        // menu region
        case 'menu':
            $dropdown_menu = menu_tree_output(_openomega_menu_build_tree('main-menu', array('max_depth' => 2)));
            //set the active trail
            $active_trail = menu_get_active_trail();
            foreach ($active_trail as $trail) {
                if (isset($trail['mlid']) && isset($dropdown_menu[$trail['mlid']])) {
                    $dropdown_menu[$trail['mlid']]['#attributes']['class'][] = 'active-trail';
                }
            }
            // Set the tab index for those with drop downs so can access the links.
            foreach ($dropdown_menu as $key => $item) {
                if (!empty($dropdown_menu[$key]['#below'])) {
                    $dropdown_menu[$key]['#attributes']['tabindex'] = 0;
                }
            }
            $vars['dropdown_menu'] = $dropdown_menu;
            break;
            // default footer content
        // default footer content
        case 'footer_first':
            $footer_menu = menu_tree_output(_openomega_menu_build_tree('main-menu', array('max_depth' => 2)));
            //set the active trail
            $active_trail = menu_get_active_trail();
            foreach ($active_trail as $trail) {
                if (isset($trail['mlid']) && isset($footer_menu[$trail['mlid']])) {
                    $footer_menu[$trail['mlid']]['#attributes']['class'][] = 'active-trail';
                }
            }
            $vars['footer_menu'] = $footer_menu;
            $vars['site_name'] = $site_name = variable_get('site_name');
            $vars['footer_logo'] = l(theme('image', array('path' => drupal_get_path('theme', 'openomega') . "/logo-sm.png", 'alt' => "{$site_name} logo")), '', array("html" => TRUE, 'attributes' => array('class' => 'logo')));
            if (function_exists('defaultcontent_get_node') && ($node = defaultcontent_get_node("email_update"))) {
                $node = node_view($node);
                $vars['subscribe_form'] = $node['webform'];
            }
            break;
    }
}
 /**
  * {@inheritdoc}
  */
 public function hookTokens($type, $tokens, array $data = array(), array $options = array())
 {
     $replacements = array();
     if ($this->isValidTokenType($type)) {
         foreach ($tokens as $name => $original) {
             if ($this->isValidToken($original)) {
                 $render = array();
                 $entity_id = $this->getEntityIdFromToken($original);
                 $view_mode = $this->getViewModeFromToken($original);
                 $render = array();
                 switch ($type) {
                     case 'node':
                         $node = node_load($entity_id);
                         if ($this->canViewNode($node)) {
                             $render = node_view($node, $view_mode);
                         }
                         break;
                     case 'term':
                         $term = taxonomy_term_load($entity_id);
                         $render = taxonomy_term_view($term, $view_mode);
                         break;
                     case 'user':
                         $account = user_load($entity_id);
                         if (user_access('access user profiles')) {
                             $render = user_view($account, $view_mode);
                         }
                         break;
                 }
                 // Remove contextual links for inline rendered entities.
                 if (module_exists('contextual')) {
                     unset($render['#contextual_links']);
                 }
                 $replacements[$original] = $render ? drupal_render($render) : '';
             }
         }
     }
     return $replacements;
 }
 /**
  * Tests that image fields in teasers have correct resources.
  */
 function testNodeTeaser()
 {
     // Set the display options for the teaser.
     $display_options = array('type' => 'image', 'settings' => array('image_style' => 'medium', 'image_link' => 'content'));
     $display = entity_get_display('node', 'article', 'teaser');
     $display->setComponent($this->fieldName, $display_options)->save();
     // Render the teaser.
     $node_render_array = node_view($this->node, 'teaser');
     $html = \Drupal::service('renderer')->renderRoot($node_render_array);
     // Parse the teaser.
     $parser = new \EasyRdf_Parser_Rdfa();
     $graph = new \EasyRdf_Graph();
     $base_uri = \Drupal::url('<front>', [], ['absolute' => TRUE]);
     $parser->parse($graph, $html, 'rdfa', $base_uri);
     // Construct the node and image URIs for testing.
     $node_uri = $this->node->url('canonical', ['absolute' => TRUE]);
     $image_uri = ImageStyle::load('medium')->buildUrl($this->file->getFileUri());
     // Test relations from node to image.
     $expected_value = array('type' => 'uri', 'value' => $image_uri);
     $this->assertTrue($graph->hasProperty($node_uri, 'http://ogp.me/ns#image', $expected_value), 'Node to file relation found in RDF output (og:image).');
     // Test image type.
     $expected_value = array('type' => 'uri', 'value' => 'http://xmlns.com/foaf/0.1/Image');
     $this->assertTrue($graph->hasProperty($image_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'Image type found in RDF output (foaf:Image).');
 }
Example #24
0
 public function render($row)
 {
     global $base_url;
     $nid = $row->{$this->field_alias};
     if (!is_numeric($nid)) {
         return;
     }
     $display_mode = $this->options['view_mode'];
     if ($display_mode == 'default') {
         $display_mode = \Drupal::config('system.rss')->get('items.view_mode');
     }
     // Load the specified node:
     /** @var \Drupal\node\NodeInterface $node */
     $node = $this->nodes[$nid];
     if (empty($node)) {
         return;
     }
     $description_build = [];
     $node->link = $node->url('canonical', array('absolute' => TRUE));
     $node->rss_namespaces = array();
     $node->rss_elements = array(array('key' => 'pubDate', 'value' => gmdate('r', $node->getCreatedTime())), array('key' => 'dc:creator', 'value' => $node->getOwner()->getUsername()), array('key' => 'guid', 'value' => $node->id() . ' at ' . $base_url, 'attributes' => array('isPermaLink' => 'false')));
     // The node gets built and modules add to or modify $node->rss_elements
     // and $node->rss_namespaces.
     $build_mode = $display_mode;
     $build = node_view($node, $build_mode);
     unset($build['#theme']);
     if (!empty($node->rss_namespaces)) {
         $this->view->style_plugin->namespaces = array_merge($this->view->style_plugin->namespaces, $node->rss_namespaces);
     } elseif (function_exists('rdf_get_namespaces')) {
         // Merge RDF namespaces in the XML namespaces in case they are used
         // further in the RSS content.
         $xml_rdf_namespaces = array();
         foreach (rdf_get_namespaces() as $prefix => $uri) {
             $xml_rdf_namespaces['xmlns:' . $prefix] = $uri;
         }
         $this->view->style_plugin->namespaces += $xml_rdf_namespaces;
     }
     if ($display_mode != 'title') {
         // We render node contents.
         $description_build = $build;
     }
     $item = new \stdClass();
     $item->description = $description_build;
     $item->title = $node->label();
     $item->link = $node->link;
     // Provide a reference so that the render call in
     // template_preprocess_views_view_row_rss() can still access it.
     $item->elements =& $node->rss_elements;
     $item->nid = $node->id();
     $build = array('#theme' => $this->themeFunctions(), '#view' => $this->view, '#options' => $this->options, '#row' => $item);
     return $build;
 }
Example #25
0
 /**
  * Asserts that a string is (not) found in the rendered nodein a view mode.
  *
  * This helper function is used by assertNodeViewText() and
  * assertNodeViewNoText().
  *
  * @param EntityInterface $node
  *   The node.
  * @param $view_mode
  *   The view mode in which the node should be displayed.
  * @param $text
  *   Plain text to look for.
  * @param $message
  *   Message to display.
  * @param $not_exists
  *   TRUE if this text should not exist, FALSE if it should.
  *
  * @return
  *   TRUE on pass, FALSE on fail.
  */
 function assertNodeViewTextHelper(EntityInterface $node, $view_mode, $text, $message, $not_exists)
 {
     // Make sure caches on the tester side are refreshed after changes
     // submitted on the tested side.
     \Drupal::entityManager()->clearCachedFieldDefinitions();
     // Save current content so that we can restore it when we're done.
     $old_content = $this->getRawContent();
     // Render a cloned node, so that we do not alter the original.
     $clone = clone $node;
     $element = node_view($clone, $view_mode);
     $output = \Drupal::service('renderer')->renderRoot($element);
     $this->verbose(t('Rendered node - view mode: @view_mode', array('@view_mode' => $view_mode)) . '<hr />' . $output);
     // Assign content so that WebTestBase functions can be used.
     $this->setRawContent($output);
     $method = $not_exists ? 'assertNoText' : 'assertText';
     $return = $this->{$method}((string) $text, $message);
     // Restore previous content.
     $this->setRawContent($old_content);
     return $return;
 }
	</table>
</div>
<br />
<div id="tabs">
	<ul>
		<li><a href="#firstTab"><span>One</span></a></li>
		<li><a href="#secondTab"><span>Two</span></a></li>
		<li><a href="#thirdTab"><span>Three</span></a></li>
	</ul>
	<div id="firstTab">
			<!--<?php 
print $field_sgp_text[0][value];
?>
-->
			<?php 
print node_view(node_load(20));
?>
		</div>
	<div id="secondTab">
			<br />
			<?php 
//need for each loop printing database info
foreach ($field_rec_databases as $dbase_node) {
    $dbase = node_load($dbase_node['nid']);
    // START Output for database
    ?>

						<table border="1" class="db_listing">
							<tr><td colspan="2" class="db_title"><h3><?php 
    print $dbase->title;
    ?>
Example #27
0
/**
 * Theme an entity coming from the views entity plugin.
 *
 * @param $entity
 *   The complete entity.
 * @param $view_mode
 *   The name of the view mode.
 */
function ds_views_row_ENTITY_NAME($entity, $view_mode)
{
    $nid = $vars['row']->{$vars['field_alias']};
    $node = node_load($nid);
    $element = node_view($node, $view_mode);
    return drupal_render($element);
}
    <ul class="row">
      <?php 
    $c = 0;
    foreach ($nodes as $node) {
        $c++;
        ?>
        <?php 
        $view_mode = 'sidebar';
        if ($c == 1) {
            $view_mode = 'large_sidebar';
        }
        ?>
        <li class="views-row views-row-<?php 
        echo $c;
        ?>
 clearfix span2">
          <?php 
        $view = node_view($node, $view_mode);
        ?>
          <?php 
        echo render($view);
        ?>
        </li>
      <?php 
    }
    ?>
    </ul>
  <?php 
}
?>
</div>
Example #29
0
/**
function open_omega_system_themes_page_alter(&$theme_groups) {
  $hidden = array(
    'alpha',
    'omega',
  );
  foreach ($theme_groups as $state => &$group) {
    if ($state == 'disabled') {
      foreach ($theme_groups[$state] as $id => &$theme) {
        if (in_array($theme, $hidden)) {
          unset($theme_groups[$state][$id]);
        }
      }
    }
  }
}
*/
function agency_1_preprocess_region(&$vars)
{
    global $language;
    switch ($vars['region']) {
        // menu region
        case 'menu':
            $footer_menu_cache = cache_get("footer_menu_data:" . $language->language);
            if ($footer_menu_cache) {
                $footer_menu = $footer_menu_cache->data;
            } else {
                $footer_menu = menu_tree_output(_agency_1_menu_build_tree('main-menu', array('max_depth' => 2)));
                cache_set("footer_menu_data:" . $language->language, $footer_menu);
            }
            //set the active trail
            $active_trail = menu_get_active_trail();
            foreach ($active_trail as $trail) {
                if (isset($trail['mlid']) && isset($footer_menu[$trail['mlid']])) {
                    $footer_menu[$trail['mlid']]['#attributes']['class'][] = 'active-trail';
                }
            }
            $vars['dropdown_menu'] = $footer_menu;
            break;
            // default footer content
        // default footer content
        case 'footer_first':
            $footer_menu_cache = cache_get("footer_menu_data:" . $language->language);
            if ($footer_menu_cache) {
                $footer_menu = $footer_menu_cache->data;
            } else {
                $footer_menu = menu_tree_output(_agency_1_menu_build_tree('main-menu', array('max_depth' => 2)));
                cache_set("footer_menu_data", $footer_menu);
            }
            //set the active trail
            $active_trail = menu_get_active_trail();
            foreach ($active_trail as $trail) {
                if (isset($trail['mlid']) && isset($footer_menu[$trail['mlid']])) {
                    $footer_menu[$trail['mlid']]['#attributes']['class'][] = 'active-trail';
                }
            }
            $vars['footer_menu'] = $footer_menu;
            $vars['site_name'] = $site_name = variable_get('site_name');
            $vars['footer_logo'] = l(theme('image', array('path' => drupal_get_path('theme', 'agency_1') . "/logo-sm.png", 'alt' => "{$site_name} logo")), '', array("html" => TRUE, 'attributes' => array('class' => 'logo')));
            //Branding
            $vars['display_footer_branding'] = theme_get_setting('display_footer_branding');
            //Contact Us Block
            $vars['display_footer_contact'] = theme_get_setting('display_footer_contact');
            $vars['footer_contact_us_title'] = theme_get_setting('footer_contact_us_title');
            $vars['footer_contact_us_agency_title'] = theme_get_setting('footer_contact_us_agency_title');
            $vars['footer_contact_us_address_1'] = theme_get_setting('footer_contact_us_address_1');
            $vars['footer_contact_us_address_2'] = theme_get_setting('footer_contact_us_address_2');
            $vars['footer_contact_us_phone'] = theme_get_setting('footer_contact_us_phone');
            $vars['footer_contact_us_fax'] = theme_get_setting('footer_contact_us_fax');
            $vars['footer_contact_us_map_link'] = theme_get_setting('footer_contact_us_map_link');
            $vars['footer_contact_us_map_image'] = theme_get_setting('footer_contact_us_map_image');
            $vars['footer_contact_us_title_link'] = theme_get_setting('footer_contact_us_title_link');
            $vars['footer_contact_us_map_path'] = theme_get_setting('footer_contact_us_map_path');
            if (function_exists('defaultcontent_get_node') && ($node = defaultcontent_get_node("email_update"))) {
                $node = node_view($node);
                $vars['subscribe_form'] = $node['webform'];
            }
            //krumo($vars['footer_menu']);
            break;
    }
}
/**
 * Returns HTML for a node preview for display during node creation and editing.
 *
 * @param $variables
 *   An associative array containing:
 *   - node: The node object which is being previewed.
 *
 * @ingroup themeable
 */
function clf_node_preview($variables)
{
    $node = $variables['node'];
    $output = '<div class="preview">';
    if ($node->type == 'health_indicators') {
        $preview_trimmed_version = FALSE;
        $elements = node_view(clone $node, 'teaser');
        $trimmed = drupal_render($elements);
        $elements = node_view($node, 'full');
        $full = drupal_render($elements);
        // Do we need to preview trimmed version of post as well as full version?
        if ($trimmed != $full && $preview_trimmed_version == TRUE) {
            drupal_set_message(t('The trimmed version of your post shows what your post looks like when promoted to the main page or when exported for syndication.<span class="no-js"> You can insert the delimiter "&lt;!--break--&gt;" (without the quotes) to fine-tune where your post gets split.</span>'));
            $output .= '<h3>' . t('Preview trimmed version') . '</h3>';
            $output .= $trimmed;
            $output .= '<h3>' . t('Preview full2 version') . '</h3>';
            $output .= $full;
        } else {
            $output .= $full;
        }
    }
    $output .= "</div>\n";
    return $output;
}