Example #1
0
 /**
  * Validates the url field to verify it's actually a url.
  */
 public function follow_url_validate($form, FormStateInterface $form_state)
 {
     $url = trim($form['#value']);
     $networks = follow_networks_load($form['#follow_uid']);
     $info = $networks[$form['#follow_network']];
     $regex = follow_build_url_regex($info);
     $parsed = follow_parse_url($url);
     if ($url && !preg_match($regex, $parsed['path'])) {
         if (!empty($info['domain'])) {
             $message = t('The specified url is invalid for the domain %domain.  Make sure you use http://.', array('%domain' => $info['domain']));
         } else {
             $message = t('The specified path is invalid.  Please enter a path on this site (e.g. rss.xml or taxonomy/term/1/feed).');
         }
         $form_state->setError($form, $message);
     }
 }
Example #2
0
/**
 * Override or insert variables into the page templates.
 *
 * @param $vars
 *   An array of variables to pass to the theme template.
 * @param $hook
 *   The name of the template being rendered ("page" in this case.)
 */
function lullacog_preprocess_page(&$vars, $hook)
{
    global $theme;
    global $user;
    _lullacog_add_body_classes($vars);
    _lullacog_process_menus($vars);
    // Re-add the site-name. For SEO purposes, we always want the site name in a
    // hidden h1. We can then toggle a visible site name using the $toggle_name var.
    $vars['toggle_name'] = theme_get_setting('toggle_name');
    $vars['site_name'] = variable_get('site_name', 'Drupal');
    // If imagecache is enabled and we're using a custom logo, use our imagecache preset.
    if ($vars['logo'] && function_exists('imagecache_create_url') && !theme_get_setting('default_logo')) {
        $vars['logo'] = strpos($vars['logo'], '/') == 0 ? substr($vars['logo'], 1) : $vars['logo'];
        $vars['logo'] = imagecache_create_url('header_logo', $vars['logo']);
    }
    $vars['logo_url'] = $vars['base_path'];
    // Load up the site follow links into a var so we can hard code them in the theme.
    if (function_exists('follow_links_load') && ($links = follow_links_load())) {
        $vars['follow_site'] = theme('follow_links', array('links' => $links, 'networks' => follow_networks_load(0)));
    }
}