Example #1
0
/**
 * Implements theme_breadcrumb
 */
function rwom_breadcrumb($variables)
{
    global $base_path;
    $output = "";
    $breadcrumb = array();
    //Initial push
    $home_link = "<a href='" . $base_path . "'><i class='fa fa-home'></i> Home</a>";
    array_push($breadcrumb, "<li>{$home_link}</li>");
    if (!strstr(request_path(), 'node')) {
        //dont need the last element on the path
        $path_arr = explode('/', request_path());
        array_pop($path_arr);
        $href_link = $base_path;
        //Fix this breadcrumb
        foreach ($path_arr as $path) {
            $href_link .= $path . "/";
            $formatted_link = "<a href='" . $href_link . "'>" . ucfirst($path) . "</a>";
            array_push($breadcrumb, "<li>{$formatted_link}</li>");
        }
    }
    if (!empty($breadcrumb)) {
        $output = "<ul class='breadcrumb'>" . implode($breadcrumb) . "</ul>";
    }
    return $output;
}
function desenalaw_preprocess_page(&$vars)
{
    if (request_path() == 'contact') {
        $googleMapsAPIKey = 'AIzaSyDzMhdB1eRFcpPFxwe4A0FG7M7FGc0YtVY';
        drupal_add_js("https://maps.googleapis.com/maps/api/js?key={$googleMapsAPIKey}", 'external');
    }
}
Example #3
0
function moretour_corolla_preprocess(&$variables, $hook)
{
    if ($hook != 'page' && $hook != 'html') {
        return;
    }
    if ($variables['is_front']) {
        $path = variable_get('site_frontpage');
        $path_alias = drupal_lookup_path('alias', $path);
        if ($path_alias) {
            $path = $path_alias;
        }
    } else {
        $path = request_path();
    }
    if (preg_match('#^(\\d{4})(/.*)?#', $path, $matches)) {
        $year = $matches[1];
        // Append year to the site name/title.
        if ($hook == 'page') {
            $variables['site_name'] .= " {$year}";
        } else {
            $variables['head_title'] .= " {$year}";
        }
        // Use 2013 specific logo
        if (!empty($variables['site_logo'])) {
            $variables['site_logo'] = str_replace('NOYEAR', $year, $variables['site_logo']);
        }
    }
}
 /**
  * Make the status page available when Drupal is in maintenance mode.
  *
  * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
  *   The event to process.
  */
 public function onKernelRequestMaintenance(GetResponseEvent $event)
 {
     $config = \Drupal::config('nagios.settings');
     $request = $event->getRequest();
     if ($request->attributes->get('_maintenance') == MENU_SITE_OFFLINE && request_path() == $config->get('nagios.statuspage.path')) {
         $request->attributes->set('_maintenance') == MENU_SITE_ONLINE;
     }
 }
 /**
  * @param BootstrapEvent $event
  */
 public function setRequestPath(BootstrapEvent $event)
 {
     // When clean URLs are enabled, emulate ?q=foo/bar using REQUEST_URI. It is
     // not possible to append the query string using mod_rewrite without the B
     // flag (this was added in Apache 2.2.8), because mod_rewrite unescapes the
     // path before passing it on to PHP. This is a problem when the path contains
     // e.g. "&" or "%" that have special meanings in URLs and must be encoded.
     $_GET['q'] = request_path();
 }
/**
 * Implements hook_form_FORM_ID_alter().
 */
function kalatheme_form_system_theme_settings_alter(&$form, &$form_state)
{
    // If a non-kalatheme theme is the admin theme we need to
    // load this stuff again to get grid size info and not throw
    // errors
    require_once dirname(__FILE__) . '/includes/config.inc';
    // Don't add custom form elements to Kalatheme's settings page if Kalatheme
    // isn't the default theme.
    // Also, don't add custom form elements to a subtheme's settings page if it
    // isn't the default theme.
    $default_theme = variable_get('theme_default', $GLOBALS['theme_key']);
    $theme_name_matches = array();
    preg_match('/^admin\\/appearance\\/settings\\/([^\\/]+)\\/?$/', request_path(), $theme_name_matches);
    if (isset($theme_name_matches[1]) && $default_theme != $theme_name_matches[1]) {
        return;
    }
    // Make default options collapsible
    $fieldsets = array('theme_settings', 'logo', 'favicon');
    foreach ($fieldsets as $fieldset) {
        $form[$fieldset]['#collapsible'] = TRUE;
        $form[$fieldset]['#collapsed'] = TRUE;
    }
    // Subtheme backend checks
    $form = array_merge($form, kalatheme_backend_check_form());
    // Kalatheme settings
    $form = array_merge($form, kalatheme_bootstrap_library_form());
    $form['bootstrap']['bootstrap_library']['#default_value'] = theme_get_setting('bootstrap_library');
    $form['bootstrap']['fontawesome']['#default_value'] = theme_get_setting('fontawesome');
    $form['bootstrap']['bootstrap_upload']['#default_value'] = theme_get_setting('bootstrap_upload');
    // Subtheme settings
    $form = array_merge($form, kalatheme_subtheme_form());
    // Need to pass this through to use list_allowed_values_string without errors.
    $field = array('type' => 'list_text');
    // Page title setting (only print on non-panel pages or always print).
    $form['page_title'] = array('#type' => 'fieldset', '#title' => t('Page Title'), '#weight' => 41, '#collapsible' => TRUE, '#collapsed' => TRUE, '#description' => t('By default, Kalatheme only displays page titles on pages that aren\'t rendered through Panels or Panelizer.
      If toggled on, this setting will cause Kalatheme to always print the page title, regardless of how the page is rendered.'));
    $form['page_title']['always_show_page_title'] = array('#type' => 'checkbox', '#title' => t('Always show page title.'), '#default_value' => theme_get_setting('always_show_page_title'), '#description' => t('Check here to always print page titles on panels pages.'));
    // Responsive style plugin settings.
    $form['responsive'] = array('#type' => 'fieldset', '#title' => t('Responsive'), '#weight' => 42, '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['responsive']['grid_size'] = array('#type' => 'markup', '#prefix' => '<p>', '#markup' => t('Kalatheme automatically detects the grid size of your Bootstrap library. That said, please remember that sometimes there are just bad grid size choices. For those occassions
      Kalatheme will try to handle your bad desicions as best as possible. <strong>Your grid is currently: @grid_size columns.</strong>', array('@grid_size' => kalatheme_get_grid_size())), '#suffix' => '</p>');
    $form['responsive']['responsive_toggle'] = array('#type' => 'checkbox', '#title' => t('Use responsive toggling.'), '#default_value' => theme_get_setting('responsive_toggle'), '#description' => t('Check here if you want the user to be able to set the device visbility of each panels pane and region.'));
    // Panels styles style plugin settings.
    $form['pane_styles'] = array('#type' => 'fieldset', '#title' => t('Pane and Region Styles'), '#weight' => 43, '#collapsible' => TRUE, '#collapsed' => TRUE, '#description' => t('If toggled on, the kalacustomize style plugin will allow the user to set a class for panels panes and regions.'));
    $form['pane_styles']['pane_styles_toggle'] = array('#type' => 'checkbox', '#title' => t('Use panels styles.'), '#default_value' => theme_get_setting('pane_styles_toggle'), '#description' => t('Check here if you want to set the class for each panels pane or region.'));
    $form['pane_styles']['pane_styles_settings'] = array('#type' => 'container', '#states' => array('invisible' => array(':input[name="pane_styles_toggle"]' => array('checked' => FALSE))));
    // Set defaults here instead of info because it is an array.
    $pane_classes = theme_get_setting('pane_classes') ? list_allowed_values_string(theme_get_setting('pane_classes')) : '';
    $form['pane_styles']['pane_styles_settings']['pane_classes'] = array('#type' => 'textarea', '#title' => t('Allowed values list'), '#default_value' => $pane_classes, '#rows' => 10, '#element_validate' => array('list_allowed_values_setting_validate'), '#field_has_data' => FALSE, '#field' => $field, '#field_type' => $field['type'], '#description' => '<p>' . t('The possible values this field can contain. Enter one value per line, in the format key|label.'));
    // Prepare the form with kalatheme things
    $form = kalatheme_prepare_config_form($form);
    // Make sure the callback function and other fun things are actually loaded
    $form_state['build_info']['files'][] = drupal_get_path('theme', 'kalatheme') . '/includes/config.inc';
    $form_state['build_info']['files'][] = drupal_get_path('theme', 'kalatheme') . '/kalatheme.updater.inc';
}
Example #7
0
/**
 * Implements hook_menu_link().
 */
function fly_flower_menu_link(array $variables)
{
    global $language_url;
    $element = $variables['element'];
    $sub_menu = '';
    if ($element['#below']) {
        // Prevent dropdown functions from being added to management menu
        // as to not affect navbar module.
        if ($element['#original_link']['menu_name'] == 'management' && module_exists('navbar')) {
            $sub_menu = drupal_render($element['#below']);
        } else {
            // Add our own wrapper.
            unset($element['#below']['#theme_wrappers']);
            $sub_menu = '<ul class="dropdown-menu">' . drupal_render($element['#below']) . '</ul>';
            $element['#localized_options']['attributes']['class'][] = 'dropdown-toggle';
            $element['#localized_options']['attributes']['data-toggle'] = 'dropdown';
            // Check if this element is nested within another.
            if (!empty($element['#original_link']['depth']) && $element['#original_link']['depth'] > 1) {
                // Generate as dropdown submenu.
                $element['#attributes']['class'][] = 'dropdown-submenu';
            } else {
                // Generate as standard dropdown.
                $element['#attributes']['class'][] = 'dropdown';
                $element['#localized_options']['html'] = TRUE;
                $element['#title'] .= ' <span class="caret"></span>';
            }
            // Set dropdown trigger element to # to prevent inadvertent
            // page loading with submenu click.
            $element['#localized_options']['attributes']['data-target'] = '#';
        }
    }
    // Issue #1896674 - On primary navigation menu,
    // class 'active' is not set on active menu item.
    // @see http://drupal.org/node/1896674
    if (($element['#href'] == request_path() || $element['#href'] == '<front>' && drupal_is_front_page()) && (empty($element['#localized_options']['language']) || $element['#localized_options']['language']->language == $language_url->language)) {
        $element['#attributes']['class'][] = 'active';
    }
    $output = l($element['#title'], $element['#href'], $element['#localized_options']);
    return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}
Example #8
0
/**
 * Implements template_preprocess_page
 */
function cis_theme_preprocess_page(&$variables)
{
    // special tpl for the pages/about page
    // this method avoids the need for declaring a nid
    if (request_path() == 'pages/about') {
        $variables['theme_hook_suggestions'][] = 'page__pages__about';
    }
    // walk tree looking for deeper items
    $menu = menu_tree_all_data(variable_get('menu_secondary_links_source', 'main-menu'));
    foreach ($menu as $key => $value) {
        if ($value['link']['href'] == arg(0)) {
            $active_menu = $value['below'];
            break;
        }
    }
    // only render if we have a 3rd level of nav
    if (isset($active_menu)) {
        $menu_links = menu_tree_output($active_menu);
        // Initialize some variables to prevent errors
        $output = '';
        $sub_menu = '';
        $small_link = '';
        foreach ($menu_links as $key => $link) {
            // Add special class needed for Foundation dropdown menu to work
            $small_link = $link;
            //duplicate version that won't get the dropdown class, save for later
            !empty($link['#below']) ? $link['#attributes']['class'][] = 'has-dropdown' : '';
            // Render top level and make sure we have an actual link
            if (!empty($link['#href'])) {
                $output .= '<li' . drupal_attributes($link['#attributes']) . '>' . l($link['#title'], $link['#href']);
                // Uncomment if we don't want to repeat the links under the dropdown for large-screen
                // $small_link['#attributes']['class'][] = 'show-for-small';
                $sub_menu = '<li' . drupal_attributes($small_link['#attributes']) . '>' . l($link['#title'], $link['#href']);
                // Get sub navigation links if they exist
                foreach ($link['#below'] as $key => $sub_link) {
                    if (!empty($sub_link['#href'])) {
                        $sub_menu .= '<li>' . l($sub_link['#title'], $sub_link['#href']) . '</li>';
                    }
                }
                $output .= !empty($link['#below']) ? '<ul class="dropdown">' . $sub_menu . '</ul>' : '';
                // Reset dropdown to prevent duplicates
                unset($sub_menu);
                unset($small_link);
                $small_link = '';
                $sub_menu = '';
                $output .= '</li>';
            }
        }
        // only output level 3 if we have a level 2
        if (isset($variables['secondary_menu'])) {
            $variables['third_menu_links'] = '<h3 class="element-invisible">Local level Menu</h3><ul id="third-menu" class="third link-list">' . $output . '</ul>';
        }
    }
}
Example #9
0
if ($main_menu) {
    ?>
            <?php 
    print theme('links__system_main_menu', array('links' => $main_menu, 'attributes' => array('id' => 'main-menu', 'class' => 'nav navbar-nav navbar-right')));
    ?>
          <?php 
}
?>
        </div>
      </div>
    </nav>
  </div>

  <!-- Header -->
  <?php 
if (substr(request_path(), 0, 6) != "search") {
    ?>


  <div class="intro-header">
      <div class="container">

          <div class="row">
              <div class="col-lg-12">
                  <div class="intro-message">
                    <h1 class="catchphrase">Fund Your Trip With Friends!</h1>
                      <?php 
    if ($page['search_bar']) {
        ?>
                        <div id="search_bar">
                          <?php 
Example #10
0
    ?>
    <?php 
    print theme('abuse_report', array('object' => $report));
    ?>
  <?php 
}
?>
</ul>

<?php 
// hide the controls for the main abuse page on the individual ticket page
if (!preg_match('/^admin\\/abuse\\/status/i', request_path())) {
    ?>
  <div id="abuse-report-list-controls">
    <?php 
    print l(t('Get More Tickets'), request_path());
    ?>
  </div>
<?php 
}
?>

<!--
<?php 
print theme('pager', array(), 10, 0);
$total = count($reports);
pager_default_initialize($total, 1, $element = 0);
print theme('pager', array('quantity' => $total));
?>
-->
Example #11
0
          <span>Share</span>
          <ul>
            <li><a target="_blank" href="http://www.linkedin.com/companies/7156/DataServ"><img alt="DataServ on LinkedIn" src="/<?php 
    print path_to_theme();
    ?>
/images/share-social-linkedin.png"></a></li>
            <li><a target="_blank" href="https://twitter.com/DataServ"><img alt="DataServ on Twitter" src="/<?php 
    print path_to_theme();
    ?>
/images/share-social-twitter.png"></a></li>
            <li><a target="_blank" href="http://plus.google.com"><img alt="DataServ on Google Plus" src="/<?php 
    print path_to_theme();
    ?>
/images/share-social-googleplus.png"></a></li>
            <li><a target="_blank" href="mailto:?<?php 
    print "Subject=DataServ&body=" . rawurlencode("Check out http://www.dataserv.us/" . request_path());
    ?>
"><img alt="Email to a Friend" src="/<?php 
    print path_to_theme();
    ?>
/images/share-social-email.png"></a></li>
          </ul>
        </div>
      <?php 
}
?>

    <?php 
hide($content['comments']);
hide($content['links']);
print render($content);
Example #12
0
/**
 * Assign theme hook suggestions for custom templates and pass color theme setting
 * to skin.less file.
 */
function porto_preprocess_page(&$vars, $hook)
{
    if (isset($vars['node'])) {
        $suggest = "page__node__{$vars['node']->type}";
        $vars['theme_hook_suggestions'][] = $suggest;
    }
    if (arg(0) == 'taxonomy' && arg(1) == 'term') {
        $term = taxonomy_term_load(arg(2));
        $vars['theme_hook_suggestions'][] = 'page--taxonomy--vocabulary--' . $term->vid;
    }
    if (request_path() == 'one-page') {
        $vars['theme_hook_suggestions'][] = 'page__onepage';
    }
    if (theme_get_setting('gradient') == "1" && module_exists('less')) {
        //Pass the color value from theme settings to @skinColor variable in skin.less
        drupal_add_css(drupal_get_path('theme', 'porto') . '/css/less/skin-gradient.less', array('group' => CSS_THEME, 'preprocess' => false, 'less' => array('variables' => array('@skinColor' => '#' . theme_get_setting('skin_color') . ''))));
    }
    if (theme_get_setting('gradient') == "0" && module_exists('less')) {
        //Pass the color value from theme settings to @skinColor variable in skin.less
        drupal_add_css(drupal_get_path('theme', 'porto') . '/css/less/skin.less', array('group' => CSS_THEME, 'preprocess' => false, 'less' => array('variables' => array('@skinColor' => '#' . theme_get_setting('skin_color') . ''))));
    }
}
function bizusa_preprocess_html(&$vars, $hook)
{
    /* If there is a unempty global $overrideBodyMarkup variable defined, then 
          the markup within the body tag will be overridden. We shall state this in 
          a classname associated with the body tag
      */
    if (!empty($GLOBALS['overrideBodyMarkup'])) {
        $vars['classes_array'][] = 'body-markup-overridden';
    } else {
        $vars['classes_array'][] = 'body-markup-drupal-rendered';
    }
    // Adding classes wether #navigation is here or not
    if (!empty($vars['main_menu']) or !empty($vars['sub_menu'])) {
        $vars['classes_array'][] = 'with-nav';
    }
    if (!empty($vars['secondary_menu'])) {
        $vars['classes_array'][] = 'with-subnav';
    }
    // Add a class name to the body that is related to the URL path to this page
    $classBasedOnPath = $_SERVER['REQUEST_URI'];
    $queryPos = strpos($classBasedOnPath, '?');
    if ($queryPos !== false) {
        $classBasedOnPath = substr($classBasedOnPath, 0, $queryPos);
    }
    $classBasedOnPath = str_replace('/', '-', $classBasedOnPath);
    $classBasedOnPath = str_replace('_', '-', $classBasedOnPath);
    $classBasedOnPath = str_replace(' ', '-', $classBasedOnPath);
    $classBasedOnPath = str_replace('.', '-', $classBasedOnPath);
    $classBasedOnPath = strtolower($classBasedOnPath);
    $classBasedOnPath = 'pagepath-' . trim($classBasedOnPath, '-');
    $classBasedOnPath = str_replace('--', '-', $classBasedOnPath);
    $vars['classes_array'][] = $classBasedOnPath;
    // If this is an unauthenticated user, or if this is an authenticated user, but not the admin, add a not-administrator class to the body
    global $user;
    if (empty($user) || empty($user->roles) || in_array('administrator', $user->roles) === false) {
        $vars['classes_array'][] = 'not-administrator';
    }
    // Each roll of the authenticated user shall be added as a classname onto the body tag
    if (!empty($user) || !empty($user->roles)) {
        foreach ($user->roles as $role) {
            $vars['classes_array'][] = 'role-' . strtolower(str_replace(' ', '-', $role));
        }
    }
    if ($vars['is_front'] === true) {
        drupal_add_css('/usr-dashboard/frontpage/find-and-print-compiled-less', array('type' => 'external'));
        drupal_add_js('https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false', array('type' => 'external'));
    }
    //Add 'description' & 'keywords' meta-tags in the header
    $html_head = array('front_page_description' => array('#tag' => 'meta', '#attributes' => array('name' => 'description', 'content' => 'BusinessUSA implements a "no wrong door" approach for small businesses and exporters by connecting businesses to the services and information relevant to them.')), 'front_page_keywords' => array('#tag' => 'meta', '#attributes' => array('name' => 'keywords', 'content' => 'business, usa, grant, market, logistics, forecast, wizard, guide, small, loans, women, LLC, EIN, plan, license, owned, minority, Veteran, compliance, profit, DBA, import, export, taxes, data, debt,finance, permit, invention, patent, insurance, employee, self-employed, cash')));
    //Add meta-tags only in the front-page
    foreach ($html_head as $key => $data) {
        if (request_path() == NULL || request_uri() === "/") {
            drupal_add_html_head($data, $key);
        }
    }
}
}
?>

  <?php 
if ($exposed) {
    ?>
    <div class="view-filters">
        <?php 
    //these mediatypes are just textfields
    $btns = array("Chat" => "/training-materials/chat", "Online Training" => "/training-materials/online training", "Videos" => "/training-materials/video", "View All" => "/training-materials/");
    ?>
        <ul class="training-materials-filter-list">
            <?php 
    foreach ($btns as $text => $link) {
        $sel = "";
        if ('/' . request_path() == $link) {
            $sel = ' training-materials-filter-btn-active';
        }
        ?>
                <li class="training-materials-filter-list-item"><a class="training-materials-filter-btn<?php 
        echo $sel;
        ?>
" href="<?php 
        echo $link;
        ?>
"><?php 
        echo $text;
        ?>
</a></li>
            <?php 
    }
$arr_assoc = array();
if ($terms = taxonomy_term_load_multiple(array_keys($result['taxonomy_term']))) {
    $counter = 0;
    foreach ($terms as $_term) {
        $uri = entity_uri('taxonomy_term', $_term);
        $arr_assoc[drupal_get_path_alias($uri['path'])] = $arr[$counter];
        $counter++;
    }
}
?>
 
<div class="view-product-types slider drop-shadow curved curved-hz-2">
	<ul class="bjqs">
		<a href="<?php 
global $base_url;
echo $base_url . $arr_assoc[request_path()];
?>
">
		<li class="bjqs-slide">
			<?php 
echo render($content['field_image']);
?>
			<div class="bjqs-caption">
				<!--<strong><?php 
echo $term_name;
?>
</strong>-->
				<strong><?php 
echo render($content['field_title']);
?>
</strong>
Example #16
0
/**
 * Prepares the request cycle and runs the dispatcher.
 *
 * @param string $file Path to router script; should generally be __FILE__
 *
 * @return mixed
 */
function run($file)
{
    if (php_sapi_name() === 'cli-server') {
        config('_base_path', '');
        if ($file != $_SERVER['SCRIPT_FILENAME']) {
            return false;
        }
    }
    foreach (array(400, 404, 405, 500, 503) as $code) {
        if (error($code) === null) {
            error($code, function ($message = null) use($code) {
                header('Content-Type: text/plain');
                echo $code, ' ', http_status($code);
                if (isset($message)) {
                    echo "\n{$message}";
                }
            });
        }
    }
    register_shutdown_function('shutdown');
    ob_start();
    dispatch(request_method(), request_path());
}
 /**
  * Prints Current and Request Path.
  *
  * @return \Symfony\Component\HttpFoundation\Response
  *   A response object.
  */
 public function foo()
 {
     return new Response('current_path=' . current_path() . ' request_path=' . request_path());
 }
Example #18
0
function clash_zen_get_takeovers()
{
    $node_type = "takeover";
    // Get nids for all published takeovers
    $result = db_query("SELECT nid FROM {node} WHERE type = :type AND status = 1", array(':type' => $node_type));
    $nids = array();
    // Format into  simple 1D array
    foreach ($result as $record) {
        if ($record->nid) {
            $nids[] = $record->nid;
        }
    }
    if (empty($nids)) {
        return false;
    }
    // Retrieve node data
    $nodes = node_load_multiple($nids);
    $data = array();
    // Get current path
    $path = request_path();
    if ($path === '') {
        $path = '<front>';
    }
    foreach ($nodes as $node) {
        $use_takeover = false;
        $pages = array_map("trim", explode(',', $node->field_takeover_pages[LANGUAGE_NONE][0]['value']));
        foreach ($pages as $page) {
            if (strpos($page, '*') !== false) {
                $page = '/^' . str_replace('/', '\\/', preg_quote(str_replace('*', '', $page))) . '.*$/';
                $use_takeover = (bool) preg_match($page, $path);
            } else {
                if ($path == $page) {
                    $use_takeover = true;
                }
            }
            if ($use_takeover) {
                break;
            }
        }
        // Format the node data into simple array
        if ($use_takeover) {
            $data[] = array('image' => isset($node->field_image[LANGUAGE_NONE][0]['uri']) ? file_create_url($node->field_image[LANGUAGE_NONE][0]['uri']) : "", 'background_colour' => $node->field_background_colour[LANGUAGE_NONE][0]['value'], 'link' => isset($node->field_target_link[LANGUAGE_NONE][0]['url']) ? $node->field_target_link[LANGUAGE_NONE][0]['url'] : "", 'pages' => $pages, 'created' => $node->created);
        }
    }
    if ($count = count($data) == 1) {
        return $data[0];
    } else {
        if ($count) {
            $latest = false;
            foreach ($data as $item) {
                if (!$latest || $latest->created < $item->created) {
                    $latest = $item;
                }
                return $latest;
            }
        }
    }
    return false;
}
Example #19
0
 /**
  * Replacement for the old arg() function which is removed in drupal 8.0.0-alpha13
  * TODO: this should be replaced with the a path service when these are not changing any more.
  * 
  * @param integer $id
  *   Number of the path's part.
  * @return string
  *   The part of the path which indexed by the given id.
  */
 public static function arg($id)
 {
     $url_comp = explode('/', request_path());
     if (isset($url_comp[$id])) {
         return $url_comp[$id];
     } else {
         return null;
     }
 }
 /**
  * Bootstraps the legacy global request variables.
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   The current request.
  *
  * @todo D8: Eliminate this entirely in favor of Request object.
  */
 protected function initializeRequestGlobals(Request $request)
 {
     // Provided by settings.php.
     global $base_url;
     // Set and derived from $base_url by this function.
     global $base_path, $base_root, $script_path;
     global $base_secure_url, $base_insecure_url;
     // @todo Refactor with the Symfony Request object.
     _current_path(request_path());
     if (isset($base_url)) {
         // Parse fixed base URL from settings.php.
         $parts = parse_url($base_url);
         if (!isset($parts['path'])) {
             $parts['path'] = '';
         }
         $base_path = $parts['path'] . '/';
         // Build $base_root (everything until first slash after "scheme://").
         $base_root = substr($base_url, 0, strlen($base_url) - strlen($parts['path']));
     } else {
         // Create base URL.
         $http_protocol = $request->isSecure() ? 'https' : 'http';
         $base_root = $http_protocol . '://' . $request->server->get('HTTP_HOST');
         $base_url = $base_root;
         // For a request URI of '/index.php/foo', $_SERVER['SCRIPT_NAME'] is
         // '/index.php', whereas $_SERVER['PHP_SELF'] is '/index.php/foo'.
         if ($dir = rtrim(dirname($request->server->get('SCRIPT_NAME')), '\\/')) {
             // Remove "core" directory if present, allowing install.php,
             // authorize.php, and others to auto-detect a base path.
             $core_position = strrpos($dir, '/core');
             if ($core_position !== FALSE && strlen($dir) - 5 == $core_position) {
                 $base_path = substr($dir, 0, $core_position);
             } else {
                 $base_path = $dir;
             }
             $base_url .= $base_path;
             $base_path .= '/';
         } else {
             $base_path = '/';
         }
     }
     $base_secure_url = str_replace('http://', 'https://', $base_url);
     $base_insecure_url = str_replace('https://', 'http://', $base_url);
     // Determine the path of the script relative to the base path, and add a
     // trailing slash. This is needed for creating URLs to Drupal pages.
     if (!isset($script_path)) {
         $script_path = '';
         // We don't expect scripts outside of the base path, but sanity check
         // anyway.
         if (strpos($request->server->get('SCRIPT_NAME'), $base_path) === 0) {
             $script_path = substr($request->server->get('SCRIPT_NAME'), strlen($base_path)) . '/';
             // If the request URI does not contain the script name, then clean URLs
             // are in effect and the script path can be similarly dropped from URL
             // generation. For servers that don't provide $_SERVER['REQUEST_URI'],
             // we do not know the actual URI requested by the client, and
             // request_uri() returns a URI with the script name, resulting in
             // non-clean URLs unless
             // there's other code that intervenes.
             if (strpos(request_uri(TRUE) . '/', $base_path . $script_path) !== 0) {
                 $script_path = '';
             }
             // @todo Temporary BC for install.php, authorize.php, and other scripts.
             //   - http://drupal.org/node/1547184
             //   - http://drupal.org/node/1546082
             if ($script_path !== 'index.php/') {
                 $script_path = '';
             }
         }
     }
 }
                $item = str_replace('add +', '[added]', $item);
                $rows[$i] = $item;
            }
        }
    }
    // Events
    if (!empty($events_array)) {
        foreach ($rows as $i => $item) {
            $end = strpos($item, ' node ');
            $start = 21;
            $nid = substr($item, $start, $end - $start);
            if (in_array($nid, $events_array)) {
                // find add + & replace with remove x
                // get current url
                // find current_url/add & replace with remove
                $path = request_path();
                $item = str_replace('<p class="suggest add-event">', '<p class="suggest remove-event">', $item);
                $item = str_replace('add +', 'remove x', $item);
                $item = str_replace('/add?destination=' . $path, '/remove?destination=' . $path, $item);
                $rows[$i] = $item;
            }
        }
    }
}
if (!empty($title)) {
    ?>
  <h3><?php 
    print $title;
    ?>
</h3>
<?php 
Example #22
0
function renderAgreement($type, $agreement = '', $agreement_owner = '', $target = '', $show_buttons = true)
{
    if (!$agreement) {
        //$agreement = Groups::getGroup($type, '', $organisation_owner);
    }
    $key_name = Groups::keyField($type);
    $id = $agreement->{$key_name};
    if ($agreement) {
        $s = '';
        //if ($show_buttons && user_access('vals admin register')){
        $pPath = request_path();
        $edit_action = "onclick='ajaxCall(\"agreement\", \"edit\", {type: \"{$type}\", id: {$id}, path: \"{$pPath}\", target: \"{$target}\"}, " . ($type == _STUDENT_GROUP ? "\"{$target}\");'" : "\"formResult\", \"html\", \"{$target}\");'");
        $s .= "<div class='totheright'>";
        $s .= "\t<input type='button' value='" . t('edit') . "' {$edit_action}/>";
        $s .= "</div>";
        //$sub_type_user = '';
        //}
        $s .= formatAgreementRecordNice($agreement, $target);
        return $s;
    } else {
        return tt('You have no %1$s registered yet', $type);
    }
}
Example #23
0
print $attributes;
?>
>

  <?php 
print $user_picture;
?>

  <?php 
print render($title_prefix);
?>
  <?php 
if (!$page) {
    ?>
    <?php 
    $path_items = explode('/', request_path());
    ?>
    <?php 
    if ($path_items[0] !== 'groups') {
        ?>
      <h2<?php 
        print $title_attributes;
        ?>
><a href="<?php 
        print $node_url;
        ?>
"><?php 
        print $title;
        ?>
</a></h2>
    <?php