コード例 #1
0
function phptemplate_preprocess(&$vars, $hook)
{
    if ($hook == 'page') {
        // Add a 'page-node' class if this is a node that is rendered as page
        if (isset($vars['node']) && $vars['node']->type) {
            $vars['body_classes'] .= ' page-node';
        }
        // Add Feed icon
        $array_q = explode('/', $_GET['q']);
        if ($array_q[0] == 'blog') {
            drupal_add_feed(url('blog/rss.xml', array('absolute' => TRUE)));
        } elseif ($array_q[0] == 'projects') {
            drupal_add_feed(url('projects/rss.xml', array('absolute' => TRUE)));
        } elseif ($array_q[0] == '字') {
            drupal_add_feed(url('字/rss.xml', array('absolute' => TRUE)));
        } else {
            drupal_add_feed(url('rss.xml', array('absolute' => TRUE)));
        }
        $vars['head'] = drupal_get_html_head();
        // Refresh $head variable
        $vars['feed_icons'] = drupal_get_feeds();
        // Refresh $feed_icons variable
    }
    // Replace funny chinese characters in section name
    //$vars['body_classes'] = str_replace('-e6-bc-a2-e5-ad-97-e6-84-9f-e3-81-98', 'kanjikanji', $vars['body_classes']);
}
コード例 #2
0
 /**
  * Enhances a page object based on a render array.
  *
  * @param \Drupal\Core\Page\HtmlPage $page
  *   The page object to enhance.
  * @param array $page_array
  *   The page array to extract onto the page object.
  *
  * @return \Drupal\Core\Page\HtmlPage
  *   The modified page object.
  */
 public function preparePage(HtmlPage $page, &$page_array)
 {
     $page_array['#page'] = $page;
     // HTML element attributes.
     $language_interface = $this->languageManager->getCurrentLanguage();
     $html_attributes = $page->getHtmlAttributes();
     $html_attributes['lang'] = $language_interface->id;
     $html_attributes['dir'] = $language_interface->direction ? 'rtl' : 'ltr';
     $this->setDefaultMetaTags($page);
     // @todo: collect feed links from #attached rather than a static once
     // http://drupal.org/node/2256365 is completed.
     foreach (drupal_get_feeds() as $feed) {
         // Force the URL to be absolute, for consistency with other <link> tags
         // output by Drupal.
         $link = new FeedLinkElement($feed['title'], url($feed['url'], array('absolute' => TRUE)));
         $page->addLinkElement($link);
     }
     return $page;
 }
コード例 #3
0
ファイル: template.php プロジェクト: dalia-m-elsayed/spica
function aurora_preprocess_block(&$vars)
{
    // Logo Block
    if ($vars['block']->delta == 'blockify-logo') {
        $vars['theme_hook_suggestions'][] = 'block__logo';
        $site_name = filter_xss_admin(variable_get('site_name', 'Drupal'));
        // Strip the base_path from the beginning of the logo path.
        $path = preg_replace('|^' . base_path() . '|', '', theme_get_setting('logo'));
        $image = array('#theme' => 'image', '#path' => $path, '#alt' => t('!site_name Logo', array('!site_name' => $site_name)));
        $vars['logo'] = $image;
        $vars['sitename'] = $site_name;
        $vars['sitepath'] = url('<front>');
    } else {
        if ($vars['block']->delta == 'blockify-site-name') {
            $vars['theme_hook_suggestions'][] = 'block__site_name';
            $site_name = filter_xss_admin(variable_get('site_name', 'Drupal'));
            $vars['sitename'] = $site_name;
            $vars['sitepath'] = url('<front>');
        } else {
            if ($vars['block']->delta == 'blockify-site-slogan') {
                $vars['theme_hook_suggestions'][] = 'block__site_slogan';
                $slogan = filter_xss_admin(variable_get('site_slogan', 'Drupal'));
                $vars['slogan'] = $slogan;
            } else {
                if ($vars['block']->delta == 'blockify-page-title') {
                    $vars['theme_hook_suggestions'][] = 'block__page_title';
                    $vars['page_title'] = drupal_get_title();
                    // Add this for legacy support. Should not be used in the template. #2370653
                    $vars['title'] = $vars['page_title'];
                } else {
                    if ($vars['block']->delta == 'blockify-messages') {
                        $vars['theme_hook_suggestions'][] = 'block__messages';
                    } else {
                        if ($vars['block']->delta == 'blockify-breadcrumb') {
                            $vars['theme_hook_suggestions'][] = 'block__breadcrumbs';
                            $breadcrumbs = drupal_get_breadcrumb();
                            $vars['breadcrumbs'] = theme('breadcrumb', array('breadcrumb' => $breadcrumbs));
                        } else {
                            if ($vars['block']->delta == 'blockify-tabs') {
                                $vars['theme_hook_suggestions'][] = 'block__tabs';
                                $primary = menu_primary_local_tasks();
                                $secondary = menu_secondary_local_tasks();
                                $tabs = array('primary' => $primary, 'secondary' => $secondary);
                                $tabs = theme('menu_local_tasks', $tabs);
                                $vars['tabs'] = $tabs;
                            } else {
                                if ($vars['block']->delta == 'blockify-actions') {
                                    $vars['theme_hook_suggestions'][] = 'block__actions';
                                    $actions = menu_local_actions();
                                    $vars['actions'] = $actions;
                                } else {
                                    if ($vars['block']->delta == 'blockify-feed-icons') {
                                        $vars['theme_hook_suggestions'][] = 'block__feed_icons';
                                        $icons = drupal_get_feeds();
                                        $vars['icons'] = $icons;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
コード例 #4
0
 /**
  * Enhances a page object based on a render array.
  *
  * @param \Drupal\Core\Page\HtmlPage $page
  *   The page object to enhance.
  * @param array $page_array
  *   The page array to extract onto the page object.
  *
  * @return \Drupal\Core\Page\HtmlPage
  *   The modified page object.
  */
 public function preparePage(HtmlPage $page, &$page_array)
 {
     $page_array['#page'] = $page;
     // HTML element attributes.
     $language_interface = $this->languageManager->getCurrentLanguage();
     $html_attributes = $page->getHtmlAttributes();
     $html_attributes['lang'] = $language_interface->getId();
     $html_attributes['dir'] = $language_interface->getDirection();
     $this->setDefaultMetaTags($page);
     // @todo: collect feed links from #attached rather than a static once
     // http://drupal.org/node/2256365 is completed.
     foreach (drupal_get_feeds() as $feed) {
         // Force the URL to be absolute, for consistency with other <link> tags
         // output by Drupal.
         $link = new FeedLinkElement($feed['title'], _url($feed['url'], array('absolute' => TRUE)));
         $page->addLinkElement($link);
     }
     // Add libraries and CSS used by this theme.
     $active_theme = \Drupal::theme()->getActiveTheme();
     foreach ($active_theme->getLibraries() as $library) {
         $page_array['#attached']['library'][] = $library;
     }
     foreach ($active_theme->getStyleSheets() as $media => $stylesheets) {
         foreach ($stylesheets as $stylesheet) {
             $page_array['#attached']['css'][$stylesheet] = array('group' => CSS_AGGREGATE_THEME, 'every_page' => TRUE, 'media' => $media);
         }
     }
     return $page;
 }
コード例 #5
0
/**
 ***********************************************************************************
 * Preprocess page templates
 */
function leggy_preprocess(&$vars, $hook)
{
    if ($hook == 'page') {
        // Add a 'page-node' class if this is a node that is rendered as page
        if (isset($vars['node']) && $vars['node']->type) {
            $vars['body_classes'] .= ' page-node';
        }
        // remove 'Notification settings' tab from user page
        $array_q = explode('/', $_REQUEST['q']);
        if ($array_q[0] == 'user') {
            _leggy_removetab('Notification settings', $vars);
            _leggy_removetab('Track', $vars);
        }
        // Add Feed icon
        if ($array_q[0] == 'geek') {
            drupal_add_feed(url('geek/feed', array('absolute' => TRUE)), 'VictoriaC RSS | Geek');
        } elseif ($array_q[0] == 'life') {
            drupal_add_feed(url('life/feed', array('absolute' => TRUE)), 'VictoriaC RSS | Life');
        } elseif ($array_q[0] == 'today') {
            drupal_add_feed(url('today/feed', array('absolute' => TRUE)), 'VictoriaC RSS | Today');
        } elseif ($array_q[0] == '漢字感じ') {
            drupal_add_feed(url('漢字感じ/feed', array('absolute' => TRUE)), 'VictoriaC RSS | 漢字感じ');
        } else {
            drupal_add_feed(url('feed', array('absolute' => TRUE)), 'VictoriaC RSS | All');
        }
        $vars['head'] = drupal_get_html_head();
        // Refresh $head variable
        $vars['feed_icons'] = drupal_get_feeds();
        // Refresh $feed_icons variable
    }
    // Replace funny kanji characters in section name
    $vars['body_classes'] = str_replace('-e6-bc-a2-e5-ad-97-e6-84-9f-e3-81-98', 'kanjikanji', $vars['body_classes']);
}