Esempio n. 1
0
/**
 * Intercept page template variables
 *
 * @param $vars
 *   A sequential array of variables passed to the theme function.
 */
function vozmob_white_label_preprocess_page(&$vars)
{
    global $user;
    $headers = drupal_set_header();
    if (strpos($headers, 'HTTP/1.1 403 Forbidden') && !$user->uid) {
        $vars['content'] .= "\n" . l(t('Please login to continue'), 'user/login', array('query' => drupal_get_destination()));
    }
    // Add drupal menu for footer links
    $footer_links_source = menu_navigation_links(variable_get('menu_footer_links_source', 'menu-footer-links'));
    $vars['footer_links'] = theme('links', $footer_links_source, array('class' => 'footer-links'));
}
Esempio n. 2
0
 function system_watchdog($log_entry = array())
 {
     static $logs = array();
     $logs[] = $log_entry;
     $data = urlencode(serialize($logs));
     if (function_exists('drupal_add_http_header')) {
         // Drupal 7
         drupal_add_http_header('X-Runserver-Watchdog', $data);
     } else {
         // Drupal 6
         drupal_set_header('X-Runserver-Watchdog: ' . $data);
     }
 }
/**
 * guifi_csvproxy
**/
function guifi_csvproxy($zoneid, $action = 'help')
{
    // load nodes and zones in memory for faster execution
    $searchStatusFlag = 'Working';
    $searchServiceType = 'Proxy';
    $subzoneIds = implode(guifi_zone_childs($zoneid), ',');
    $sql_services = sprintf("SELECT\n                             s.nick,\n                             s.extra,\n                             z.title as ZoneTitle\n                           FROM  guifi_services s,\n                                 guifi_zone z\n                           WHERE\n                             s.status_flag = '%s'\n                             AND s.zone_id = z.id\n                             AND s.service_type = '%s'\n                             AND (s.zone_id = %s or s.zone_id in (%s))\n                             ORDER BY ZoneTitle asc, s.timestamp_created ASC", $searchStatusFlag, $searchServiceType, $zoneid, $subzoneIds);
    drupal_set_header('Content-Type: text/csv; charset=utf-8');
    $qservices = db_query($sql_services);
    while ($service = db_fetch_object($qservices)) {
        if (!empty($service->extra)) {
            $extraData = unserialize($service->extra);
            if (isset($extraData['proxy']) && isset($extraData['port']) && $extraData['proxy'] != '' && $extraData['port'] != '') {
                echo $service->nick . ";" . $extraData['proxy'] . ";" . $extraData['port'] . "\n";
            }
        }
    }
}
Esempio n. 4
0
function phptemplate_preprocess_page(&$vars)
{
    global $user;
    $vars['path'] = base_path() . path_to_theme() . '/';
    $vars['user'] = $user;
    // Fixup the $head_title and $title vars to display better.
    $title = drupal_get_title();
    $vars['title'] = $title;
    $headers = drupal_set_header();
    // wrap taxonomy listing pages in quotes and prefix with topic
    if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
        $title = t('Topic') . ' “' . $title . '”';
    } elseif (strpos($headers, 'HTTP/1.1 403 Forbidden') && !$user->uid) {
        $title = t('Please login to continue');
    }
    // Body class & Params
    if (module_exists('path')) {
        $alias = drupal_get_path_alias($_GET['q']);
        $vars['params'] = explode('/', $alias);
        $vars['body_id'] = $vars['params'][0];
        if (empty($vars['body_id'])) {
            $vars['body_id'] = 'home';
        }
    }
    // Base url
    $vars['baseUrl'] = 'http://' . $_SERVER['HTTP_HOST'];
    if (!drupal_is_front_page()) {
        $vars['head_title'] = $title . ' | ' . $vars['site_name'];
        if ($vars['site_slogan'] != '') {
            $vars['head_title'] .= ' – ' . $vars['site_slogan'];
        }
    }
    // Head title
    if (module_exists('page_title')) {
        $vars['head_title'] = page_title_page_get_title();
    } elseif (!drupal_is_front_page()) {
        $vars['head_title'] = $title . ' | ' . $vars['site_name'];
        if ($vars['site_slogan'] != '') {
            $vars['head_title'] .= ' – ' . $vars['site_slogan'];
        }
    }
}
function xml_atom_render($view)
{
    global $base_url;
    $xml .= '<?xml version="1.0" encoding="UTF-8" ?>' . "\n";
    $xml .= '<!-- generator="Drupal Views_Datasource.Module" -->' . "\n";
    $xml .= '<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">' . "\n";
    $xml .= '  <title>' . $view->name . '</title>' . "\n";
    $xml .= '  <link rel="alternate" type="text/html" href="' . $base_url . '"/>' . "\n";
    $xml .= '  <link rel ="self" type="application/atom+xml" href="' . $base_url . '/' . $view->display_handler->options['path'] . '"/>' . "\n";
    $xml .= '  <id>' . $base_url . '/' . $view->display_handler->options['path'] . '</id>' . "\n";
    //use path as id
    $xml .= '  <updated>###feed_updated###</updated>' . "\n";
    //will set later
    $xml .= '  <generator>Views Datasource module</generator>' . "\n";
    $feed_last_updated = 0;
    foreach ($view->result as $node) {
        $entry = array();
        foreach ($node as $field_name => $field_value) {
            $label = views_xml_strip_illegal_chars($field_name);
            $value = views_xml_strip_illegal_chars(views_xml_is_date($field_value));
            if (is_null($value) || $value === '') {
                continue;
            }
            //      if (preg_match('/\d/', $value)) {
            //        if (strtotime($value))
            //          $value = date(DATE_ISO8601, strtotime($value));
            //      }
            $label = str_replace('_value', '', str_replace("profile_values_profile_", '', $label));
            //strip out Profile: from profile fields
            if (strtolower($label) == 'nid') {
                $entry['nid'] = $value;
            }
            if (strtolower($label) == 'updated' || strtolower($label) == 'updated date' || strtolower($label) == 'node_changed') {
                if (intval($value)) {
                    //timestamp
                    $entry['updated'] = intval($value);
                } else {
                    if (getdate($value)) {
                        //string date
                        $entry['updated'] = strtotime($value);
                    }
                }
            }
            if (strtolower($label) == 'title' || strtolower($label) == 'node_title') {
                $entry['title'] = $value;
            }
            if (strtolower($label) == 'link') {
                $entry['link'] = $value;
            }
            if (strtolower($label) == 'published' || strtolower($label) == 'node_created') {
                if (intval($value)) {
                    //timestamp
                    $entry['published'] = intval($value);
                } else {
                    if (getdate($value)) {
                        //string date
                        $entry['published'] = strtotime($value);
                    }
                }
            }
            if (strtolower($label) == 'author' || strtolower($label) == 'users_name') {
                $entry['author'] = $value;
            }
            if (strtolower($label) == 'email' || strtolower($label) == 'users_mail') {
                $entry['email'] = $value;
            }
            if (strtolower($label) == 'content' || strtolower($label) == 'node_revisions_body') {
                $entry['content'] = $value;
            }
            if (strtolower($label) == 'summary' || strtolower($label) == 'node_teaser' || strtolower($label) == 'node_revisions_teaser') {
                $entry['summary'] = $value;
            }
        }
        if (isset($entry['nid']) && isset($entry['updated']) && isset($entry['link']) && isset($entry['title']) && isset($entry['published'])) {
            if (parse_url($entry['link'])) {
                $link = $entry['link'];
            } else {
                print '<b style="color:red">The link URL is not valid.</b>';
                return;
            }
        } elseif (isset($entry['nid']) && isset($entry['updated']) && isset($entry['title']) && isset($entry['published'])) {
            //make the entry path with base_url + nid {
            $entry['link'] = $base_url . '/index.php?q=node/' . $entry['nid'];
        } else {
            print '<b style="color:red">The fields "nid", "title", "post date", and "updated date" must exist.';
            return;
        }
        $link = $entry['link'];
        $link_url = parse_url($link);
        $nid = $entry['nid'];
        $updated = $entry['updated'];
        if ($updated > $feed_last_updated) {
            $feed_last_updated = $updated;
        }
        //Overall feed updated is the most recent node updated timestamp
        $title = $entry['title'];
        $published = $entry['published'];
        $author = $entry['author'];
        $email = $entry['email'];
        $content = $entry['content'];
        $summary = $entry['summary'];
        //Create an id for the entry using tag URIs
        $id = 'tag:' . $link_url['host'] . ',' . date('Y-m-d', $updated) . ':' . $link_url['path'] . '?' . $link_url['query'];
        $xml .= '  <entry>' . "\n";
        $xml .= '    <id>' . $id . '</id>' . "\n";
        $xml .= '    <updated>' . date(DATE_ATOM, $updated) . '</updated>' . "\n";
        $xml .= '    <title type="text">' . $title . '</title>' . "\n";
        $xml .= '    <link rel="alternate" type="text/html" href="' . $link . '"/>' . "\n";
        $xml .= '    <published>' . date(DATE_ATOM, $published) . '</published>' . "\n";
        if ($author) {
            if ($email) {
                $xml .= '    <author><name>' . $author . '</name><email>' . $email . '</email></author>' . "\n";
            } else {
                $xml .= '    <author><name>' . $author . '</name></author>' . "\n";
            }
        }
        if ($content) {
            $xml .= '    <content type="html" xml:base="' . $base_url . '"><![CDATA[' . $content . ']]></content>' . "\n";
        }
        if ($summary) {
            $xml .= '    <summary type="html" xml:base="' . $base_url . '"><![CDATA[' . $summary . ']]></summary>' . "\n";
        }
        $xml .= '  </entry>' . "\n";
    }
    $xml .= '</feed>' . "\n";
    $xml = str_replace('###feed_updated###', date(DATE_ATOM, $feed_last_updated), $xml);
    if ($view->override_path) {
        //inside live preview
        print htmlspecialchars($xml);
    } else {
        drupal_set_header('Content-Type: application/atom+xml');
        print $xml;
        //var_dump($label);
        module_invoke_all('exit');
        exit;
    }
}
Esempio n. 6
0
 function send_header()
 {
     if (DEBUG) {
         drupal_set_header("Content-type: text/html;charset=utf-8");
     } else {
         drupal_set_header("Content-type: image/png;charset=utf-8");
     }
 }
        $xhtml .= '  <span class="category">' . $category . '</span>' . "<br/>\r\n";
    }
    if ($hcard['email']) {
        $mail_addrs = $hcard['email'];
        foreach ($mail_addrs as $mail_type => $mail_addr) {
            $xhtml .= '  <span class="email">' . "\r\n" . '    <span class="type">' . $mail_type . ': </span>' . "\r\n" . '    <a class="value" href="mailto:' . $mail_addr . '">' . $mail_addr . '</a>' . "\r\n" . '  </span>' . "<br/>\r\n";
        }
    }
    if ($hcard['tel']) {
        $tel_nos = $hcard['tel'];
        foreach ($tel_nos as $tel_no_type => $tel_no) {
            $xhtml .= '  <span class="tel">' . '<span class="type">' . $tel_no_type . ': </span>' . '<span class="value">' . $tel_no . '</span>' . '</span>' . "<br/>\r\n";
        }
    }
    $xhtml .= '</div>' . "\r\n";
}
$xhtml .= '</body>' . "\r\n";
$xhtml .= '</html>' . "\r\n";
if ($view->override_path) {
    // inside live preview
    print htmlspecialchars($xhtml);
} else {
    if ($options['using_views_api_mode']) {
        // We're in Views API mode.
        print $xhtml;
    } else {
        drupal_set_header("Content-Type: {$content_type}; charset=utf-8");
        print $xhtml;
        exit;
    }
}
Esempio n. 8
0
/**
 * Intercept page template variables
 *
 * @param $vars
 *   A sequential array of variables passed to the theme function.
 */
function SimplyCivi_preprocess_page(&$vars)
{
    global $user;
    $vars['path'] = base_path() . path_to_theme() . '/';
    $vars['path_parent'] = base_path() . drupal_get_path('theme', 'SimplyCivi') . '/';
    $vars['user'] = $user;
    // Prep the logo for being displayed
    $site_slogan = !$vars['site_slogan'] ? '' : ' - ' . $vars['site_slogan'];
    $logo_img = '';
    $title = $text = variable_get('site_name', '');
    if ($vars['logo']) {
        $logo_img = "<img src='" . $vars['logo'] . "' alt='" . $title . "' border='0' />";
        $text = $vars['site_name'] ? $logo_img . $text : $logo_img;
    }
    $vars['logo_block'] = !$vars['site_name'] && !$vars['logo'] ? '' : l($text, '', array('attributes' => array('title' => $title . $site_slogan), 'html' => !empty($logo_img)));
    //Play nicely with the page_title module if it is there.
    if (!module_exists('page_title')) {
        // Fixup the $head_title and $title vars to display better.
        $title = drupal_get_title();
        $headers = drupal_set_header();
        // if this is a 403 and they aren't logged in, tell them they need to log in
        if (strpos($headers, 'HTTP/1.1 403 Forbidden') && !$user->uid) {
            $title = t('Please login to continue');
        }
        $vars['title'] = $title;
        if (!drupal_is_front_page()) {
            $vars['head_title'] = $title . ' | ' . $vars['site_name'];
            if ($vars['site_slogan'] != '') {
                $vars['head_title'] .= ' &ndash; ' . $vars['site_slogan'];
            }
        }
        $vars['head_title'] = strip_tags($vars['head_title']);
    }
    //Perform RTL - LTR swap and load RTL Styles.
    if ($vars['language']->dir == 'rtl') {
        // Remove SimplyCivi Grid and use RTL grid
        $css = $vars['css'];
        $css['screen,projection']['theme'][path_to_theme() . '/SimplyCivi/SimplyCivi/plugins/rtl/screen.css'] = TRUE;
        $vars['styles'] = drupal_get_css($css);
        //setup rtl css for IE
        $vars['styles_ie']['ie'] = '<link href="' . $path . 'css/ie-rtl.css" rel="stylesheet"  type="text/css"  media="screen, projection" />';
        $vars['styles_ie']['ie6'] = '<link href="' . $path . 'css/ie6-rtl.css" rel="stylesheet"  type="text/css"  media="screen, projection" />';
    }
    $vars['meta'] = '';
    // SEO optimization, add in the node's teaser, or if on the homepage, the mission statement
    // as a description of the page that appears in search engines
    if ($vars['is_front'] && $vars['mission'] != '') {
        $vars['meta'] .= '<meta name="description" content="' . SimplyCivi_trim_text($vars['mission']) . '" />' . "\n";
    } elseif (isset($vars['node']->teaser) && $vars['node']->teaser != '') {
        $vars['meta'] .= '<meta name="description" content="' . SimplyCivi_trim_text($vars['node']->teaser) . '" />' . "\n";
    } elseif (isset($vars['node']->body) && $vars['node']->body != '') {
        $vars['meta'] .= '<meta name="description" content="' . SimplyCivi_trim_text($vars['node']->body) . '" />' . "\n";
    }
    // SEO optimization, if the node has tags, use these as keywords for the page
    if (isset($vars['node']->taxonomy)) {
        $keywords = array();
        foreach ($vars['node']->taxonomy as $term) {
            $keywords[] = $term->name;
        }
        $vars['meta'] .= '<meta name="keywords" content="' . implode(',', $keywords) . '" />' . "\n";
    }
    // SEO optimization, avoid duplicate titles in search indexes for pager pages
    if (isset($_GET['page']) || isset($_GET['sort'])) {
        $vars['meta'] .= '<meta name="robots" content="noindex,follow" />' . "\n";
    }
    if (theme_get_setting('SimplyCivi_showgrid')) {
        $vars['body_classes'] .= ' showgrid ';
    }
    // Make sure framework styles are placed above all others.
    $vars['css_alt'] = SimplyCivi_css_reorder($vars['css']);
    $vars['styles'] = drupal_get_css($vars['css_alt']);
    /* I like to embed the Google search in various places, uncomment to make use of this
      // setup search for custom placement
      $search = module_invoke('google_cse', 'block', 'view', '0');
      $vars['search'] = $search['content'];
      */
    /* to remove specific CSS files from modules use this trick
      // Remove stylesheets
      $css = $vars['css'];
      unset($css['all']['module']['sites/all/modules/contrib/plus1/plus1.css']);
      $vars['styles'] = drupal_get_css($css);
      */
}
Esempio n. 9
0
function phptemplate_maintenance_page($content, $messages = TRUE, $partial = FALSE)
{
    drupal_set_header('Content-Type: text/html; charset=utf-8');
    //drupal_set_html_head('<style type="text/css" media="all">@import "'. base_path() .'misc/maintenance.css";</style>');
    drupal_set_html_head('<style type="text/css" media="all">@import "' . base_path() . drupal_get_path('theme', 'newsflash') . '/maintenance.css";</style>');
    drupal_set_html_head('<style type="text/css" media="all">@import "' . base_path() . drupal_get_path('module', 'system') . '/defaults.css";</style>');
    drupal_set_html_head('<style type="text/css" media="all">@import "' . base_path() . drupal_get_path('module', 'system') . '/system.css";</style>');
    //drupal_set_html_head('<style type="text/css" media="all">@import "'. base_path() . drupal_get_path('theme', 'newsflash') .'/style.css";</style>');
    drupal_set_html_head('<link rel="shortcut icon" href="' . base_path() . 'misc/favicon.ico" type="image/x-icon" />');
    $output = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
    $output .= '<html xmlns="http://www.w3.org/1999/xhtml">';
    $output .= '<head>';
    $output .= '<title>Tribute Media</title>';
    $output .= drupal_get_html_head();
    $output .= drupal_get_js();
    $output .= '</head>';
    $output .= '<body>';
    $output .= '<div class="logo"><img src="' . drupal_get_path('theme', 'newsflash') . '/images/tribute_comingsoon.png" id="logo"/></div>';
    //$output .= '<h1 id="title">' . drupal_get_title() . '</h1>';
    if ($messages) {
        $output .= theme('status_messages');
    }
    $output .= "\n<!-- begin content -->\n";
    //$output .= $content;
    $output .= "\n<!-- end content -->\n";
    if (!$partial) {
        $output .= '</body></html>';
    }
    return $output;
}
Esempio n. 10
0
 /**
  * @inheritDoc
  */
 public function setHttpHeader($name, $value)
 {
     drupal_set_header("{$name}: {$value}");
 }
Esempio n. 11
0
/**
 *
 * Produce the image of the map. The data is passed via the c query arguments.
 *
 */
function bawstats_render_map_image()
{
    $data = $_GET['c'];
    // Set headers
    drupal_set_header('Expires: Mon, 01 Jan 1997 05:00:00 GMT');
    drupal_set_header('Cache-Control: no-store, no-cache, must-revalidate');
    drupal_set_header('Cache-Control: post-check=0, pre-check=0', false);
    drupal_set_header('Pragma: no-cache');
    drupal_set_header('Content-type: image/png');
    $site_path = drupal_get_path('module', 'bawstats');
    $im = bawstats_create_map_image($site_path . '/icons/wmap.png', $site_path . '/icons/circ-blue.png', $site_path . '/icons/circ-green.png', $data);
    //output image to browser
    imagepng($im);
    imagedestroy($im);
}
Esempio n. 12
0
/**
 * Render users, blog and forum posts and comments, as SIOC in XML
 *
 * @param object $view
 * @return none
 */
function rdf_sioc_xml_render($view)
{
    //var_dump($view);
    //module_invoke_all('exit');
    //exit;
    global $base_url;
    $xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
    $xml .= '<!-- generator="Drupal Views_Datasource.Module" -->' . "\n";
    $xml .= "<rdf:RDF\r\n";
    $xml .= "  xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\r\n";
    $xml .= "  xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\"\r\n";
    $xml .= "  xmlns:sioc=\"http://rdfs.org/sioc/ns#\"\r\n";
    $xml .= "  xmlns:sioct=\"http://rdfs.org/sioc/terms#\"\r\n";
    $xml .= "  xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\r\n";
    $xml .= "  xmlns:dcterms=\"http://purl.org/dc/terms/\"\r\n";
    $xml .= "  xmlns:admin=\"http://webns.net/mvcb/\"\r\n";
    $xml .= "  xmlns:foaf=\"http://xmlns.com/foaf/0.1/\">\r\n";
    if ($view->base_table == 'users') {
        $has_uid = false;
        $has_name = false;
        $has_email = false;
        foreach ($view->field as $field) {
            //if (($field->field_alias == 'uid') && ($field['options']['field'] ==  'uid'))
            if ($field->options['field'] == 'uid') {
                $has_uid = true;
            }
            if ($field->options['field'] == 'name') {
                $has_name = true;
            }
            if ($field->options['field'] == 'mail') {
                $has_email = true;
            }
        }
        if (!$has_uid) {
            if ($view->override_path) {
                print '<b style="color:red">The uid field must be present.</b>';
            } else {
                drupal_set_message('The uid field must be present.', 'error');
            }
            return;
        }
        if (!$has_name) {
            if ($view->override_path) {
                print '<b style="color:red">The name field must be present.</b>';
            } else {
                drupal_set_message('The name field must be present.', 'error');
            }
            return;
        }
        if (!$has_email) {
            if ($view->override_path) {
                print '<b style="color:red">The email field must be present.</b>';
            } else {
                drupal_set_message('The email field must be present.', 'error');
            }
            return;
        }
        $xml .= "<foaf:Document rdf:about=\"" . url($view->name, array('absolute' => true)) . "\">\n";
        $xml .= "  <dc:title>SIOC user profiles for: " . variable_get('site_name', 'drupal') . "</dc:title>\n";
        $xml .= "  <dc:description>\n";
        $xml .= "    A User is an online account of a member of an online community. \n     It is connected to Items and Posts that a User creates or edits, \n     to Containers and Forums that it is subscribed to or moderates and \n     to Sites that it administers. Users can be grouped for purposes of \n     allowing access to certain Forums or enhanced community site features (weblogs, webmail, etc.).\n     A foaf:Person will normally hold a registered User account on a Site \n     (through the property foaf:holdsAccount), and will use this account \n     to create content and interact with the community. sioc:User describes \n     properties of an online account, and is used in combination with a \n     foaf:Person (using the property sioc:account_of) which describes \n     information about the individual itself.\n";
        $xml .= "  </dc:description>\n";
        $xml .= "####foaf_topics####\n";
        $xml .= "  <admin:generatorAgent rdf:resource=\"http://drupal.org/project/views_datasource\"/>\n";
        $xml .= "</foaf:Document>\n";
        foreach ($view->result as $node) {
            $xml .= rdf_sioc_xml_user_render($node);
        }
    }
    if ($view->base_table == 'node') {
        $has_nid = false;
        $has_type = false;
        $has_created = false;
        $has_changed = false;
        $has_last_updated = false;
        $has_title = false;
        $has_body = false;
        $has_uid = false;
        foreach ($view->field as $field) {
            //if (($field->field_alias == 'uid') && ($field['options']['field'] ==  'uid'))
            if ($field->options['field'] == 'nid') {
                $has_nid = true;
            }
            if ($field->options['field'] == 'type') {
                $has_type = true;
            }
            if ($field->options['field'] == 'created') {
                $has_created = true;
            }
            if ($field->options['field'] == 'changed') {
                $has_changed = true;
            }
            if ($field->options['field'] == 'last_updated') {
                $has_last_updated = true;
            }
            if ($field->options['field'] == 'title') {
                $has_title = true;
            }
            if ($field->options['field'] == 'body') {
                $has_body = true;
            }
            if ($field->options['field'] == 'uid') {
                $has_uid = true;
            }
        }
        if (!$has_nid) {
            if ($view->override_path) {
                print '<b style="color:red">The Node: Nid field must be present.</b>';
            } else {
                drupal_set_message('The Node: Nid field must be present.', 'error');
            }
            return;
        }
        if (!$has_type) {
            if ($view->override_path) {
                print '<b style="color:red">The Node: Type field must be present.</b>';
            } else {
                drupal_set_message('The Node: Type field must be present.', 'error');
            }
            return;
        }
        if (!$has_created) {
            if ($view->override_path) {
                print '<b style="color:red">The Node: Post date field must be present.</b>';
            } else {
                drupal_set_message('The Node: Post date field must be present.', 'error');
            }
            return;
        }
        if (!$has_changed) {
            if ($view->override_path) {
                print '<b style="color:red">The Node: Updated date field must be present.</b>';
            } else {
                drupal_set_message('The Node: Updated date field must be present.', 'error');
            }
            return;
        }
        if (!$has_last_updated) {
            if ($view->override_path) {
                print '<b style="color:red">The Node: Updated/commented date field must be present.</b>';
            } else {
                drupal_set_message('The Node: Updated/commented date field must be present.', 'error');
            }
            return;
        }
        if (!$has_title) {
            if ($view->override_path) {
                print '<b style="color:red">The Node: Title field must be present.</b>';
            } else {
                drupal_set_message('The Node: Title field must be present.', 'error');
            }
            return;
        }
        if (!$has_body) {
            if ($view->override_path) {
                print '<b style="color:red">The Node: Body field must be present.</b>';
            } else {
                drupal_set_message('The Node: Body field must be present.', 'error');
            }
            return;
        }
        if (!$has_uid) {
            if ($view->override_path) {
                print '<b style="color:red">The User: Uid field must be present.</b>';
            } else {
                drupal_set_message('The User: Uid field must be present.', 'error');
            }
            return;
        }
        $users = array();
        $nodes = array();
        $xml .= "<foaf:Document rdf:about=\"" . url($view->name, array('absolute' => true)) . "\">\n";
        $xml .= "  <dc:title>SIOC profile for: " . variable_get('site_name', 'drupal') . "</dc:title>\n";
        $xml .= "  <dc:description>\n";
        $xml .= "    A SIOC profile describes the structure and contents of a weblog in a machine readable form. For more information please refer to http://sioc-project.org/.\n    A Post is an article or message posted by a User to a Forum or Site. A series of Posts \n    may be threaded if they share a common subject and are connected by reply or \n    by date relationships. Posts will have content and may also have attached \n    files, which can be edited or deleted by the Moderator of the Forum or Site that \n    contains the Post.\n";
        $xml .= "  </dc:description>\n";
        //$xml .= "  <foaf:primaryTopic rdf:resource=\"$node_url\"/>\n";
        $xml .= "  <admin:generatorAgent rdf:resource=\"http://drupal.org/project/views_datasource\"/>\n";
        $xml .= "</foaf:Document>\n";
        foreach ($view->result as $node) {
            rdf_sioc_xml_node_render($node, &$users, &$nodes);
        }
        foreach ($users as $user_xml) {
            $xml .= $user_xml;
        }
        foreach ($nodes as $node_xml) {
            $xml .= $node_xml;
        }
    }
    $xml .= "</rdf:RDF>\n";
    if ($view->override_path) {
        //inside live preview
        print htmlspecialchars($xml);
    } else {
        drupal_set_header('Content-Type: application/rdf+xml');
        print $xml;
        module_invoke_all('exit');
        exit;
    }
}
 public function handle()
 {
     //A method is required, no matter what
     if (empty($this->method_name)) {
         $this->error(JSONRPC_ERROR_REQUEST, t("The received JSON not a valid JSON-RPC Request"));
     }
     $endpoint = services_get_server_info('endpoint');
     //Find the method
     $this->method = services_controller_get($this->method_name, $endpoint);
     $args = array();
     if (!isset($this->method)) {
         // No method found is a fatal error
         $this->error(JSONRPC_ERROR_PROCEDURE_NOT_FOUND, t("Invalid method @method", array('@method' => $request)));
     }
     //If needed, check if parameters can be omitted
     $arg_count = count($this->method['args']);
     if (!isset($this->params)) {
         for ($i = 0; $i < $arg_count; $i++) {
             $arg = $this->method['#args'][$i];
             if (!$arg['optional']) {
                 if (empty($this->params)) {
                     // We have required parameter, but we don't have any.
                     if (is_array($this->params)) {
                         // The request has probably been parsed correctly if params is an array,
                         // just tell the client that we're missing parameters.
                         $this->error(JSONRPC_ERROR_PARAMS, t("No parameters received, the method '@method' has required parameters.", array('@method' => $this->method_name)));
                     } else {
                         // If params isn't an array we probably have a syntax error in the json.
                         // Tell the client that there was a error while parsing the json.
                         // TODO: parse errors should be caught earlier
                         $this->error(JSONRPC_ERROR_PARSE, t("No parameters received, the likely reason is malformed json, the method '@method' has required parameters.", array('@method' => $this->method_name)));
                     }
                 }
             }
         }
     }
     // Map parameters to arguments, the 1.1 draft is more generous than the 2.0 proposal when
     // it comes to parameter passing. 1.1-d allows mixed positional and named parameters while
     // 2.0-p forces the client to choose between the two.
     //
     // 2.0 proposal on parameters: http://groups.google.com/group/json-rpc/web/json-rpc-1-2-proposal#parameters-positional-and-named
     // 1.1 draft on parameters: http://json-rpc.org/wd/JSON-RPC-1-1-WD-20060807.html#NamedPositionalParameters
     if ($this->array_is_assoc($this->params)) {
         $this->args = array();
         //Create a assoc array to look up indexes for parameter names
         $arg_dict = array();
         for ($i = 0; $i < $arg_count; $i++) {
             $arg = $this->method['args'][$i];
             $arg_dict[$arg['name']] = $i;
         }
         foreach ($this->params as $key => $value) {
             if ($this->major_version == 1 && preg_match('/^\\d+$/', $key)) {
                 //A positional argument (only allowed in v1.1 calls)
                 if ($key >= $arg_count) {
                     //Index outside bounds
                     $this->error(JSONRPC_ERROR_PARAMS, t("Positional parameter with a position outside the bounds (index: @index) received", array('@index' => $key)));
                 } else {
                     $this->args[intval($key)] = $value;
                 }
             } else {
                 //Associative key
                 if (!isset($arg_dict[$key])) {
                     //Unknown parameter
                     $this->error(JSONRPC_ERROR_PARAMS, t("Unknown named parameter '@name' received", array('@name' => $key)));
                 } else {
                     $this->args[$arg_dict[$key]] = $value;
                 }
             }
         }
     } else {
         //Non associative arrays can be mapped directly
         $param_count = count($this->params);
         if ($param_count > $arg_count) {
             $this->error(JSONRPC_ERROR_PARAMS, t("Too many arguments received, the method '@method' only takes '@num' argument(s)", array('@method' => $this->method_name, '@num' => $arg_count)));
         }
         $this->args = $this->params;
     }
     //Validate arguments
     for ($i = 0; $i < $arg_count; $i++) {
         $val = $this->args[$i];
         $arg = $this->method['args'][$i];
         if (isset($val)) {
             //If we have data
             if ($arg['type'] == 'struct' && is_array($val) && $this->array_is_assoc($val)) {
                 $this->args[$i] = $val = (object) $val;
             }
             //Only array-type parameters accepts arrays
             if (is_array($val) && $arg['type'] != 'array' && !($this->is_assoc($val) && $arg['type'] == 'struct')) {
                 $this->error_wrong_type($arg, 'array');
             } else {
                 if (($arg['type'] == 'int' || $arg['type'] == 'float') && !is_numeric($val)) {
                     $this->error_wrong_type($arg, 'string');
                 }
             }
         } else {
             if (!$arg['optional']) {
                 //Trigger error if a required parameter is missing
                 $this->error(JSONRPC_ERROR_PARAMS, t("Argument '@name' is required but was not received", array('@name' => $arg['name'])));
             }
         }
     }
     // We are returning JSON, so tell the browser.
     drupal_set_header('Content-Type: application/json; charset=utf-8');
     // Services assumes parameter positions to match the method callback's
     // function signature so we need to sort arguments by position (key)
     // before passing them to the method callback. The best solution here would
     // be to pad optional parameters using a #default key in the hook_service
     // method definitions instead of requiring all parameters to be present, as
     // we do now.
     // For reference: http://drupal.org/node/715044
     ksort($this->args);
     //Call service method
     try {
         $result = services_controller_execute($this->method, $this->args);
         return $this->result($result);
     } catch (ServicesException $e) {
         $this->error(JSONRPC_ERROR_INTERNAL_ERROR, $e->getMessage(), $e->getData());
     } catch (Exception $e) {
         $this->error(JSONRPC_ERROR_INTERNAL_ERROR, $e->getMessage());
     }
 }
Esempio n. 14
0
function guifi_users_dump_ldif($service)
{
    drupal_set_header('Content-Type: text/plain; charset=utf-8');
    print _guifi_users_dump_federated($service, TRUE);
    exit;
}
Esempio n. 15
0
function guifi_gml_links($zid, $type)
{
    $oGC = new GeoCalc();
    $minx = 180;
    $miny = 90;
    $maxx = -180;
    $maxy = -90;
    $res = db_query("SELECT id,link_type,flag " . "FROM {guifi_links} " . "WHERE link_type != 'cable' " . "GROUP BY 1,2 " . "HAVING count(*) = 2");
    $zchilds = guifi_zone_childs($zid);
    $zchilds[$zid] = 'Top';
    while ($row = db_fetch_object($res)) {
        $resnode = db_query("SELECT n.id, n.zone_id, n.nick,n.lat, n.lon, n.status_flag " . "FROM {guifi_links} l, {guifi_location} n " . "WHERE l.id = %d AND l.nid=n.id", $row->id);
        $nl = array();
        while ($n = db_fetch_object($resnode)) {
            $nl[] = $n;
        }
        if (count($nl) == 2) {
            if (in_array($nl[0]->zone_id, $zchilds) || in_array($nl[1]->zone_id, $zchilds)) {
                $distance = round($oGC->EllipsoidDistance($nl[0]->lat, $nl[0]->lon, $nl[1]->lat, $nl[1]->lon), 3);
                $status = $row->flag;
                if ($type == 'gml') {
                    $output .= '
          <gml:featureMember>
          <dlinks fid="' . $row->id . '">
          <NODE1_ID>' . $nl[0]->id . '</NODE1_ID>
          <NODE1_NAME>' . $nl[0]->nick . '</NODE1_NAME>
          <NODE2_ID>' . $nl[1]->id . '</NODE2_ID>
          <NODE2_NAME>' . $nl[1]->nick . '</NODE2_NAME>
          <KMS>' . $distance . '</KMS>
          <LINK_TYPE>' . $row->link_type . '</LINK_TYPE>
          <STATUS>' . $status . '</STATUS>
          <ogr:geometryProperty><gml:LineString><gml:coordinates>' . $nl[0]->lon . ',' . $nl[0]->lat . ' ' . $nl[1]->lon . ',' . $nl[1]->lat . '</gml:coordinates></gml:LineString></ogr:geometryProperty>
          </dlinks>
          </gml:featureMember>';
                } else {
                    $output .= $row->id . ',' . $nl[0]->id . ',' . $nl[0]->nick . ',' . $nl[1]->id . ',' . $nl[1]->nick . ',' . $distance . ',' . $row->link_type . ',' . $status . ',' . $nl[0]->lon . ',' . $nl[0]->lat . ',' . $nl[1]->lon . ',' . $nl[1]->lat . "\n";
                }
                if ($nl[0]->lon > $maxx) {
                    $maxx = $nl[0]->lon;
                }
                if ($nl[0]->lat > $maxy) {
                    $maxy = $nl[0]->lat;
                }
                if ($nl[0]->lon < $minx) {
                    $minx = $nl[0]->lon;
                }
                if ($nl[0]->lat < $miny) {
                    $miny = $nl[0]->lat;
                }
                if ($nl[1]->lon > $maxx) {
                    $maxx = $nl[1]->lon;
                }
                if ($nl[1]->lat > $maxy) {
                    $maxy = $nl[1]->lat;
                }
                if ($nl[1]->lon < $minx) {
                    $minx = $nl[1]->lon;
                }
                if ($nl[1]->lat < $miny) {
                    $miny = $nl[1]->lat;
                }
            }
        }
    }
    drupal_set_header('Content-Type: application/xml; charset=utf-8');
    if ($type == 'gml') {
        print '<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
     xmlns:xsi="http://www.w3c.org/2001/XMLSchema-instance"
     xsi:schemaLocation=". dlinks.xsd"
     xmlns:ogr="http://ogr.maptools.org/"
     xmlns:gml="http://www.opengis.net/gml">
  <gml:boundedBy>
    <gml:Box>
<gml:coord><gml:X>' . $minx . '</gml:X><gml:Y>' . $miny . '</gml:Y></gml:coord>
<gml:coord><gml:X>' . $maxx . '</gml:X><gml:Y>' . $maxy . '</gml:Y></gml:coord>
   </gml:Box>
</gml:boundedBy>';
    }
    print $output;
    if ($type == 'gml') {
        print '</ogr:FeatureCollection>';
    }
}
Esempio n. 16
0
function json_exhibit_render($view)
{
    define('EXHIBIT_DATE_FORMAT', '%Y-%m-%d %H:%M:%S');
    $json = "{\n" . '  "items":' . "\n" . str_repeat(" ", 4) . "[\n";
    $total_view_result_count = count((array) $view->result);
    //cast the result object to an array so we can count how many properties in itt;
    $view_result_count = 0;
    foreach ($view->result as $node) {
        $json .= str_repeat(" ", 6) . "{\n";
        $json .= str_repeat(" ", 8) . '"type" ' . " " . ": " . '"' . '##type##' . '",' . "\n";
        $json .= str_repeat(" ", 8) . '"label" ' . " " . " : " . '"' . '##label##' . '",' . "\n";
        $total_field_count = count((array) $node);
        //cast the node object to an array so we can count how many properties in itt
        $field_count = 0;
        foreach ($node as $field_label => $field_value) {
            $label = trim(views_json_strip_illegal_chars(views_json_encode_special_chars($field_label)));
            $value = views_json_encode_special_chars(trim(views_json_is_date($field_value)));
            if (is_null($value) || $value == '') {
                continue;
            }
            //      if (preg_match('/\d/', $value)) {
            //        if (strtotime($value))
            //          $value = gmstrftime(EXHIBIT_DATE_FORMAT, strtotime($value));
            //      }
            $label = str_replace('_value', '', str_replace("profile_values_profile_", '', $label));
            //strip out Profile: from profile fields
            if ($label == 'type') {
                $json = str_replace('##type##', $value, $json);
            } elseif ($label == 'label') {
                $json = str_replace('##label##', $value, $json);
            } else {
                $json .= str_repeat(" ", 8) . '"' . $label . '"' . " " . ": " . '"' . $value . '"' . (++$field_count == $total_field_count ? "" : ",") . "\n";
            }
        }
        if (strpos($json, '##type##') !== false) {
            $json = str_replace('##type##', isset($node->type) ? $node->type : 'Item', $json);
        }
        if (strpos($json, '##label##') !== false) {
            $json = str_replace('##label##', isset($node->title) ? $node->title : 'none', $json);
        }
        $json .= str_repeat(" ", 6) . "}" . (++$view_result_count == $total_view_result_count ? "" : ",") . "\n";
    }
    $json .= str_repeat(" ", 4) . "]\n}";
    if ($view->override_path) {
        //inside a live preview so just output the text
        print $json;
    } else {
        //real deal so switch the content type and stop further processing of the page
        drupal_set_header('Content-Type: text/javascript');
        print $json;
        module_invoke_all('exit');
        exit;
    }
}
Esempio n. 17
0
function phptemplate_views_rss_feed_recent_blog_posts_rss($view, $nodes, $type)
{
    if ($type == 'block') {
        return;
    }
    global $base_url;
    $channel = array('title' => views_get_title($view, 'page'), 'link' => url($view->feed_url ? $view->feed_url : $view->real_url, NULL, NULL, true), 'description' => $view->description);
    $item_length = 'fulltext';
    $namespaces = array('xmlns:dc="http://purl.org/dc/elements/1.1/"');
    // Except for the original being a while and this being a foreach, this is
    // completely cut & pasted from node.module.
    foreach ($nodes as $node) {
        // Load the specified node:
        $item = node_load($node->nid);
        $link = url("node/{$node->nid}", NULL, NULL, 1);
        if ($item_length != 'title') {
            $teaser = $item_length == 'teaser' ? TRUE : FALSE;
            // Filter and prepare node teaser
            if (node_hook($item, 'view')) {
                node_invoke($item, 'view', $teaser, FALSE);
            } else {
                $item = node_prepare($item, $teaser);
            }
            // Allow modules to change $node->teaser before viewing.
            node_invoke_nodeapi($item, 'view', $teaser, FALSE);
        }
        // Allow modules to add additional item fields
        $extra = node_invoke_nodeapi($item, 'rss item');
        $extra = array_merge($extra, array(array('key' => 'pubDate', 'value' => date('r', $item->created)), array('key' => 'dc:creator', 'value' => $item->name), array('key' => 'guid', 'value' => $item->nid . ' at ' . $base_url, 'attributes' => array('isPermaLink' => 'false'))));
        foreach ($extra as $element) {
            if ($element['namespace']) {
                $namespaces = array_merge($namespaces, $element['namespace']);
            }
        }
        // Prepare the item description
        switch ($item_length) {
            case 'fulltext':
                $item_text = $item->body;
                break;
            case 'teaser':
                $item_text = $item->teaser;
                if ($item->readmore) {
                    $item_text .= '<p>' . l(t('read more'), 'node/' . $item->nid, NULL, NULL, NULL, TRUE) . '</p>';
                }
                break;
            case 'title':
                $item_text = '';
                break;
        }
        $items .= format_rss_item($item->title, $link, $item_text, $extra);
    }
    $channel_defaults = array('version' => '2.0', 'title' => variable_get('site_name', 'drupal') . ' - ' . variable_get('site_slogan', ''), 'link' => $base_url, 'description' => variable_get('site_mission', ''), 'language' => $GLOBALS['locale']);
    $channel = array_merge($channel_defaults, $channel);
    $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
    $output .= "<rss version=\"" . $channel["version"] . "\" xml:base=\"" . $base_url . "\" " . implode(' ', $namespaces) . ">\n";
    $output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language']);
    $output .= "</rss>\n";
    drupal_set_header('Content-Type: text/xml; charset=utf-8');
    print $output;
    module_invoke_all('exit');
    exit;
}
 public function handle()
 {
     //A method is required, no matter what
     if (empty($this->method_name)) {
         return $this->error(JSONRPC_ERROR_REQUEST, t("The received JSON not a valid JSON-RPC Request"));
     }
     //Find the method
     $methods = services_get_all();
     $args = array();
     foreach ($methods as $method) {
         if ($method['#method'] == $this->method_name) {
             $this->method = $method;
             break;
         }
     }
     if (!isset($this->method)) {
         // No method found is a fatal error
         return $this->error(JSONRPC_ERROR_PROCEDURE_NOT_FOUND, t("Invalid method @method", array('@method' => $request)));
     }
     //If needed, check if parameters can be omitted
     $arg_count = count($this->method['#args']);
     if (!isset($this->params)) {
         for ($i = 0; $i < $arg_count; $i++) {
             $arg = $this->method['#args'][$i];
             if (!$arg['#optional']) {
                 if (empty($this->in['params'])) {
                     return $this->error(JSONRPC_ERROR_PARAMS, t("No parameters recieved, the method '@method' has required parameters.", array('@method' => $this->method_name)));
                 } else {
                     return $this->error(JSONRPC_ERROR_PARSE, t("Missing parameters, the likely reason is malformed json, the method '@method' has required parameters.", array('@method' => $this->method_name)));
                 }
             }
         }
     }
     // Map parameters to arguments, the 1.1 draft is more generous than the 2.0 proposal when
     // it comes to parameter passing. 1.1-d allows mixed positional and named parameters while
     // 2.0-p forces the client to choose between the two.
     //
     // 2.0 proposal on parameters: http://groups.google.com/group/json-rpc/web/json-rpc-1-2-proposal#parameters-positional-and-named
     // 1.1 draft on parameters: http://json-rpc.org/wd/JSON-RPC-1-1-WD-20060807.html#NamedPositionalParameters
     if ($this->array_is_assoc($this->params)) {
         $this->args = array();
         //Create a assoc array to look up indexes for parameter names
         $arg_dict = array();
         for ($i = 0; $i < $arg_count; $i++) {
             $arg = $this->method['#args'][$i];
             $arg_dict[$arg['#name']] = $i;
         }
         foreach ($this->params as $key => $value) {
             if ($this->major_version == 1 && preg_match('/^\\d+$/', $key)) {
                 //A positional argument (only allowed in v1.1 calls)
                 if ($key >= $arg_count) {
                     //Index outside bounds
                     return $this->error(JSONRPC_ERROR_PARAMS, t("Positional parameter with a position outside the bounds (index: @index) recieved", array('@index' => $key)));
                 } else {
                     $this->args[intval($key)] = $value;
                 }
             } else {
                 //Associative key
                 if (!isset($arg_dict[$key])) {
                     //Unknown parameter
                     return $this->error(JSONRPC_ERROR_PARAMS, t("Unknown named parameter '@name' recieved", array('@name' => $key)));
                 } else {
                     $this->args[$arg_dict[$key]] = $value;
                 }
             }
         }
     } else {
         //Non associative arrays can be mapped directly
         $param_count = count($this->params);
         if ($param_count > $arg_count) {
             return $this->error(JSONRPC_ERROR_PARAMS, t("Too many arguments recieved, the method '@method' only takes '@num' argument(s)", array('@method' => $this->method_name, '@num' => $arg_count)));
         }
         $this->args = $this->params;
     }
     //Validate arguments
     for ($i = 0; $i < $arg_count; $i++) {
         $val = $this->args[$i];
         $arg = $this->method['#args'][$i];
         if (isset($val)) {
             //If we have data
             //Only array-type parameters accepts arrays
             if (is_array($val) && $arg['#type'] != 'array') {
                 return $this->error_wrong_type($arg, 'array');
             } else {
                 if (($arg['#type'] == 'int' || $arg['#type'] == 'float') && !is_numeric($val)) {
                     return $this->error_wrong_type($arg, 'string');
                 }
             }
         } else {
             if (!$arg['#optional']) {
                 //Trigger error if a required parameter is missing
                 return $this->error(JSONRPC_ERROR_PARAMS, t("Argument '@name' is required but was not recieved", array('@name' => $arg['#name'])));
             }
         }
     }
     // We are returning JSON, so tell the browser.
     drupal_set_header('Content-Type: application/json; charset=utf-8');
     //Call service method
     try {
         $result = services_method_call($this->method['#method'], $this->args);
         if (is_array($result) && isset($result['#error']) && $result['#error'] === TRUE) {
             return $this->error(JSONRPC_ERROR_INTERNAL_ERROR, $result['#message']);
         } else {
             return $this->result($result);
         }
     } catch (Exception $e) {
         return $this->error(JSONRPC_ERROR_INTERNAL_ERROR, $e->getMessage());
     }
 }
Esempio n. 19
0
/**
 * Intercept page template variables
 *
 * @param $vars
 *   A sequential array of variables passed to the theme function.
 */
function phptemplate_preprocess_page(&$vars)
{
    global $user;
    $vars['path'] = base_path() . path_to_theme() . '/';
    $vars['user'] = $user;
    // Fixup the $head_title and $title vars to display better.
    $title = drupal_get_title();
    $headers = drupal_set_header();
    // wrap taxonomy listing pages in quotes and prefix with topic
    if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
        $title = t('Topic') . ' &#8220;' . $title . '&#8221;';
    } else {
        if (strpos($headers, 'HTTP/1.1 403 Forbidden') && !$user->uid) {
            $title = t('Please login to continue');
        }
    }
    $vars['title'] = $title;
    if (!drupal_is_front_page()) {
        $vars['head_title'] = $title . ' | ' . $vars['site_name'];
        if ($vars['site_slogan'] != '') {
            $vars['head_title'] .= ' &ndash; ' . $vars['site_slogan'];
        }
    }
    // determine layout
    // 3 columns
    if ($vars['layout'] == 'both') {
        $vars['left_classes'] = 'col-left span-6';
        $vars['right_classes'] = 'col-right span-6 last';
        $vars['center_classes'] = 'col-center span-12';
        $vars['body_classes'] .= ' col-3 ';
    } else {
        if ($vars['layout'] != 'none') {
            // left column & center
            if ($vars['layout'] == 'left') {
                $vars['left_classes'] = 'col-left span-6';
                $vars['center_classes'] = 'col-center span-18 last';
            } else {
                if ($vars['layout'] == 'right') {
                    $vars['right_classes'] = 'col-right span-6 last';
                    $vars['center_classes'] = 'col-center span-18';
                }
            }
            $vars['body_classes'] .= ' col-2 ';
        } else {
            $vars['center_classes'] = 'col-center span-24';
            $vars['body_classes'] .= ' col-1 ';
        }
    }
    $vars['meta'] = '';
    // SEO optimization, add in the node's teaser, or if on the homepage, the mission statement
    // as a description of the page that appears in search engines
    if ($vars['is_front'] && $vars['mission'] != '') {
        $vars['meta'] .= '<meta name="description" content="' . blueprint_trim_text($vars['mission']) . '" />' . "\n";
    } else {
        if (isset($vars['node']->teaser) && $vars['node']->teaser != '') {
            $vars['meta'] .= '<meta name="description" content="' . blueprint_trim_text($vars['node']->teaser) . '" />' . "\n";
        } else {
            if (isset($vars['node']->body) && $vars['node']->body != '') {
                $vars['meta'] .= '<meta name="description" content="' . blueprint_trim_text($vars['node']->body) . '" />' . "\n";
            }
        }
    }
    // SEO optimization, if the node has tags, use these as keywords for the page
    if (isset($vars['node']->taxonomy)) {
        $keywords = array();
        foreach ($vars['node']->taxonomy as $term) {
            $keywords[] = $term->name;
        }
        $vars['meta'] .= '<meta name="keywords" content="' . implode(',', $keywords) . '" />' . "\n";
    }
    // SEO optimization, avoid duplicate titles in search indexes for pager pages
    if (isset($_GET['page']) || isset($_GET['sort'])) {
        $vars['meta'] .= '<meta name="robots" content="noindex,follow" />' . "\n";
    }
    /* I like to embed the Google search in various places, uncomment to make use of this
      // setup search for custom placement
      $search = module_invoke('google_cse', 'block', 'view', '0');
      $vars['search'] = $search['content'];
      */
    /* to remove specific CSS files from modules use this trick
      // Remove stylesheets
      $css = $vars['css'];
      unset($css['all']['module']['sites/all/modules/contrib/plus1/plus1.css']);
      $vars['styles'] = drupal_get_css($css);   
      */
}
function xhtml_hcalendar_render($view)
{
    $xhtml .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n";
    $xhtml .= '<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr"' . ">\r\n";
    $xhtml .= '<head>' . "\r\n";
    $xhtml .= '  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' . "\r\n";
    $xhtml .= '  <meta name="KEYWORDS" content="hCalendars" />' . "\r\n";
    $xhtml .= '  <title>hCards</title>' . "\r\n";
    $xhtml .= '</head>' . "\r\n";
    $xhtml .= '<body>' . "\r\n";
    foreach ($view->result as $node) {
        $hcalendar = array();
        foreach ($node as $field_label => $field_value) {
            $label = views_rdf_strip_illegal_chars($field_label);
            $value = views_xml_strip_illegal_chars(views_xhtml_is_date($field_value));
            $label = str_replace('_value', '', str_replace("profile_values_profile_", '', $label));
            //strip out Profile: from profile fields
            if (is_null($value) || $value === '') {
                continue;
            }
            if (stripos($label, 'class') !== FALSE) {
                $hcalendar['class'] = $value;
            }
            if (stripos($label, 'category') !== FALSE) {
                $hcalendar['category'][] = $value;
            }
            if (stripos($label, 'description') !== FALSE) {
                $hcalendar['description'] = $value;
            }
            if (stripos($label, 'summary') !== FALSE) {
                $hcalendar['summary'] = $value;
            }
            if (stripos($label, 'dtstart') !== FALSE || stripos($label, 'event_start') !== FALSE || stripos($label, 'eventstarttime') !== FALSE) {
                if (preg_match('/\\d/', $value)) {
                    if (strtotime($value)) {
                        $value = date(EXHIBIT_DATE_FORMAT, strtotime($value));
                    }
                }
                $hcalendar['dtstart'] = $value;
            }
            if (stripos($label, 'dtend') !== FALSE || stripos($label, 'event_end') !== FALSE || stripos($label, 'eventendtime') !== FALSE) {
                if (preg_match('/\\d/', $value)) {
                    if (strtotime($value)) {
                        $value = date(EXHIBIT_DATE_FORMAT, strtotime($value));
                    }
                }
                $hcalendar['dtend'] = $value;
            }
            if (stripos($label, 'duration') !== FALSE) {
                $hcalendar['duration'] = $value;
            }
            if (stripos($label, 'geo_latitude') !== FALSE) {
                $hcalendar['geo']['latitude'] = $value;
            }
            if (stripos($label, 'geo_longitude') !== FALSE) {
                $hcalendar['geo']['longitude'] = $value;
            }
            if (stripos($label, 'location') !== FALSE) {
                $hcalendar['location'] = $value;
            }
            if (stripos($label, 'status') !== FALSE) {
                $hcalendar['status'] = $value;
            }
            if (stripos($label, 'uid') !== FALSE) {
                $hcalendar['uid'] = $value;
            }
            if (stripos($label, 'url') !== FALSE) {
                $hcalendar['url'] = $value;
            }
            if (stripos($label, 'last_modified') !== FALSE) {
                if (preg_match('/\\d/', $value)) {
                    if (strtotime($value)) {
                        $value = date(EXHIBIT_DATE_FORMAT, strtotime($value));
                    }
                }
                $hcalendar['last-modified'] = $value;
            }
            if (stripos($label, 'address_type') !== FALSE) {
                $hcalendar['adr']['type'] = $value;
            }
            if (stripos($label, 'post_office_box') !== FALSE) {
                $hcalendar['adr']['post-office-box'] = $value;
            }
            if (stripos($label, 'street_address') !== FALSE) {
                $hcalendar['adr']['street-address'][] = $value;
            }
            if (stripos($label, 'extended_address') !== FALSE) {
                $hcalendar['adr']['extended-address'] = $value;
            }
            if (stripos($label, 'region') !== FALSE) {
                $hcalendar['adr']['region'] = $value;
            }
            if (stripos($label, 'locality') !== FALSE) {
                $hcalendar['adr']['locality'] = $value;
            }
            if (stripos($label, 'postal_code') !== FALSE) {
                $hcalendar['adr']['postal-code'] = $value;
            }
            if (stripos($label, 'country_name') !== FALSE) {
                $hcalendar['adr']['country-name'] = $value;
            }
        }
        $xhtml .= '<div class = "vevent">' . "\r\n";
        $class = $hcalendar['class'];
        if ($class) {
            $xhtml .= '  <span class="class">' . $class . '</span>' . "<br/>\r\n";
        }
        $categories = $hcalendar['category'];
        if ($categories) {
            foreach ($categories as $category) {
                $xhtml .= '  <span class="category">' . $category . '</span>' . "<br/>\r\n";
            }
        }
        $dtstart = $hcalendar['dtstart'];
        if ($dtstart) {
            $xhtml .= '  <span class="dtstart">' . $dtstart . '</span>' . "<br/>\r\n";
        }
        $summary = $hcalendar['summary'];
        if ($summary) {
            $xhtml .= '  <span class="summary">' . $summary . '</span>' . "<br/>\r\n";
        }
        $dtend = $hcalendar['dtend'];
        if ($dtend) {
            $xhtml .= '  <span class="dtend">' . $dtend . '</span>' . "<br/>\r\n";
        }
        $location = $hcalendar['location'];
        if ($location) {
            $xhtml .= '  <span class="location">' . $location . '</span>' . "<br/>\r\n";
        }
        $geo_latitude = $hcalendar['geo-latitude'];
        $geo_longitude = $hcalendar['geo-longitude'];
        if ($geo_latitude || $geo_longitude) {
            $xhtml .= "  <div class=\"geo\">\n";
            if ($location) {
                $xhtml .= "    {$location}: ";
            }
            if ($geo_latitude) {
                $xhtml .= "    <span class=\"latitude\">{$geo_latitude}</span>; ";
            }
            if ($geo_longitude) {
                $xhtml .= "    <span class=\"longitude\">{$geo_longitude}</span>";
            }
            $xhtml .= "  </div>\n";
        }
        $status = $hcalendar['status'];
        if ($status) {
            $xhtml .= '  <span class="status">' . $status . '</span>' . "<br/>\r\n";
        }
        $duration = $hcalendar['duration'];
        if ($duration) {
            $xhtml .= '  <span class="duration">' . $duration . '</span>' . "<br/>\r\n";
        }
        $uid = $hcalendar['uid'];
        if ($uid) {
            $xhtml .= '  <span class="uid">' . $uid . '</span>' . "<br/>\r\n";
        }
        $url = $hcalendar['url'];
        if ($url) {
            $xhtml .= '  <span class="url">' . $url . '</span>' . "<br/>\r\n";
        }
        $last_modified = $hcalendar['last-modified'];
        if ($last_modified) {
            $xhtml .= '  <span class="last-modified">' . $last_modified . '</span>' . "<br/>\r\n";
        }
        $description = $hcalendar['description'];
        if ($description) {
            $xhtml .= '  <span class="description">' . $description . '</span>' . "<br/>\r\n";
        }
        $adr = $hcalendar['adr'];
        if ($adr) {
            $xhtml .= "  <div class=\"adr\">\n";
            $adr_type = $adr['address-type'];
            if ($adr_type) {
                $xhtml .= '    <span class="address-type">' . $adr_type . '</span>' . "<br/>\r\n";
            }
            $xhtml .= "  </div>";
        }
        $xhtml .= '</div>' . "\r\n";
    }
    $xhtml .= '</body>' . "\r\n";
    $xhtml .= '</html>' . "\r\n";
    drupal_set_header('Content-Type: text/html');
    //var_dump($view);
    print $xhtml;
    module_invoke_all('exit');
    exit;
}
Esempio n. 21
0
function badgirlsclub_preprocess_node($variables) {
  $cast_query = db_query('select * from content_type_bios_cast where field_uid_uid = %d', $variables['uid']);
  $account = db_fetch_object($cast_query);

    $variables['cast_member_name'] = $account->field_cast_name_value;
    $variables['cast_member_picture'] = "sites/all/themes/oxygen/images/blog_photo/uid".$variables['uid']."-".strtolower($account->field_cast_name_value).".jpg"; 
    $variables['cast_member_short_bio'] = $account->field_short_bio_value;
   
   $node = $variables['node'];
  if($node->nid == 101718) {
        drupal_add_css(drupal_get_path('theme','badgirlsclub')."/badgirlsclub_contest.css", 'theme');
        drupal_add_js(drupal_get_path('theme','thegleeproject')."/jquery.cookie.js", 'module');
        //drupal_add_js(drupal_get_path('theme','badgirlsclub')."/badgirlsclub_contest.js", 'theme');
        $variables['template_file'] = 'node-'. $node->nid;
        $variables['vote_options'] = json_encode($node->choice);
        drupal_set_header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');
  }   
}
Esempio n. 22
0
                    include_once './includes/bootstrap.inc';
                    drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
                    // reached week's maximum views, set status to "week's limit reached"
                    db_query('UPDATE {banner} SET workflow = 3 WHERE nid = %d', $banner_id);
                    $refresh = 1;
                }
            }
        }
        $output .= $this_banner->html;
        $counter++;
    }
    // once every minute update views in db
    if ($last_updated < time() - 60) {
        $struct[2] = time();
        $refresh = 1;
    }
    // dump back in cache
    $data = serialize($struct);
    rewind($fd);
    fwrite($fd, $data, strlen($data));
    flock($fd, LOCK_UN);
    fclose($fd);
    break;
}
if ($refresh) {
    include_once './includes/bootstrap.inc';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
    drupal_set_header("Content-Type: application/x-javascript; charset=utf-8");
    _banner_refresh_cache();
}
print $output;
Esempio n. 23
0
function phptemplate_preprocess_page(&$vars)
{
    $eigen_risico = variable_get('eigen_risico', '');
    $fysio = variable_get('fysio', '');
    $tandarts = variable_get('tandarts', '');
    $keuzevrijheid = variable_get('keuzevrijheid', '');
    $default_title = variable_get('default_title', '0');
    $default_sort = variable_get('default_sort', 'premium');
    $default_beperkte_zorgkeuze = variable_get('default_beperkte_zorgkeuze', '0');
    $default_vrije_zorgkeuze = variable_get('default_vrije_zorgkeuze', '0');
    drupal_add_js(array('filter' => array('eigen_risico' => $eigen_risico, 'fysio' => $fysio, 'tandarts' => $tandarts, 'keuzevrijheid' => $keuzevrijheid, 'default_title' => $default_title, 'default_sort' => $default_sort, 'default_beperkte_zorgkeuze' => $default_beperkte_zorgkeuze, 'default_vrije_zorgkeuze' => $default_vrije_zorgkeuze)), 'setting');
    drupal_add_js(array('filter_counts' => variable_get('default_count_of_contacts', 10)), 'setting');
    if ($vars['node']->type == 'insurance' && isset($_GET['eigen_risico']) && isset($_GET['fysio']) && isset($_GET['tandarts']) && isset($_GET['keuzevrijheid'])) {
        $vars['contentBottom'] = '';
    }
    global $user;
    $vars['path'] = base_path() . path_to_theme() . '/';
    $vars['user'] = $user;
    if (!(!empty($_POST['save_Vergelijken']) && arg(0) == 'compare')) {
        if ($user->uid > 0) {
            db_query("DELETE FROM {flag_content} WHERE uid = %d", $user->uid);
        } else {
            db_query("DELETE FROM {flag_content} WHERE uid = 0 AND sid = %d", flag_get_sid(0));
        }
    }
    // Fixup the $head_title and $title vars to display better.
    $title = drupal_get_title();
    $vars['title'] = $title;
    $headers = drupal_set_header();
    // wrap taxonomy listing pages in quotes and prefix with topic
    if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
        $title = t('Topic') . ' &#8220;' . $title . '&#8221;';
    } elseif (strpos($headers, 'HTTP/1.1 403 Forbidden') && !$user->uid) {
        $title = t('Please login to continue');
    }
    // Body class & Params
    if (module_exists('path')) {
        $alias = drupal_get_path_alias($_GET['q']);
        $vars['params'] = explode('/', $alias);
        $vars['body_id'] = $vars['params'][0];
        if ($vars['body_id'] == 'compare') {
            $vars['body_id'] = 'vergelijk';
        }
        if (empty($vars['body_id'])) {
            $vars['body_id'] = 'home';
        }
    }
    // Base url
    $vars['baseUrl'] = 'http://' . $_SERVER['HTTP_HOST'];
    if (!drupal_is_front_page()) {
        $vars['head_title'] = $title . ' | ' . $vars['site_name'];
        if ($vars['site_slogan'] != '') {
            $vars['head_title'] .= ' &ndash; ' . $vars['site_slogan'];
        }
    }
    // Head title
    if (module_exists('page_title')) {
        $vars['head_title'] = page_title_page_get_title();
    } elseif (!drupal_is_front_page()) {
        $vars['head_title'] = $title . ' | ' . $vars['site_name'];
        if ($vars['site_slogan'] != '') {
            $vars['head_title'] .= ' &ndash; ' . $vars['site_slogan'];
        }
    }
    // determine layout
    // 3 columns
    if ($vars['layout'] == 'both') {
        $vars['colls'] = 'bothCol';
    } else {
        if ($vars['layout'] != 'none') {
            // left column & center
            if ($vars['layout'] == 'left') {
                $vars['colls'] = 'leftCol';
            } else {
                if ($vars['layout'] == 'right') {
                    $vars['colls'] = 'rightCol';
                }
            }
        } else {
            $vars['colls'] = 'noCol';
        }
    }
    $vars['scripts'] = drupal_get_js();
}
Esempio n. 24
0
function print_pretty_CNML($cnml)
{
    $dom = new DOMDocument('1.0');
    $dom->preserveWhiteSpace = false;
    $dom->formatOutput = true;
    $dom->loadXML($cnml->asXML());
    $output = $dom->saveXML();
    drupal_set_header('Content-Type: application/xml; charset=utf-8');
    drupal_set_header("Content-length: " . strlen($output));
    echo $output;
}
Esempio n. 25
0
/**
 * Override or insert PHPTemplate variables into the templates.
 */
function phptemplate_preprocess_page(&$vars)
{
    $mime_types = array('application/vnd.wap.xhtml+xml', 'application/xhtml+xml', 'text/html');
    $mime_dtds = array('<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" 
    "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile11.dtd"> ' . "\n", '<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n", '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" 
    "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">');
    if (!isset($_SERVER["HTTP_ACCEPT"]) or empty($_SERVER["HTTP_ACCEPT"]) or stripos($_SERVER['REQUEST_URI'], 'admin') !== FALSE) {
        $my_dtd = 2;
    } elseif (stristr($_SERVER["HTTP_ACCEPT"], $mime_types[0])) {
        $my_dtd = 0;
    } elseif (stristr($_SERVER["HTTP_ACCEPT"], $mime_types[1])) {
        $my_dtd = 1;
    } else {
        $my_dtd = 2;
    }
    $my_dtd = 2;
    $vars['dtd'] = $mime_dtds[$my_dtd];
    $vars['head'] = $my_dtd != 2 ? str_replace('text/html', $mime_types[$my_dtd], $vars['head']) : $vars['head'];
    $vars['styles'] = stripos($_SERVER['REQUEST_URI'], 'admin') !== FALSE ? $vars['styles'] : '<link type="text/css" rel="stylesheet" media="all" href="' . base_path() . path_to_theme() . '/mobi.css" />' . "\n";
    $vars['head_extra'] = '<link rel="alternate" media="handheld" href="http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . '" />' . "\n";
    $vars['scripts'] = stripos($_SERVER['REQUEST_URI'], 'admin') !== FALSE ? $vars['scripts'] : '';
    $new_links = array();
    $new_link = array();
    $blah = $vars['primary_links'];
    // CHANGE TO MENU OF CHOICE
    $i = 1;
    foreach ($blah as $menu_item => $menu_value) {
        $new_links[$menu_item] = array('attributes' => array('accesskey' => $i));
        $new_link[$menu_item] = $menu_value;
        $i++;
    }
    $att = array_merge_recursive($new_links, $new_link);
    $m_l = '';
    foreach ($att as $lmenu => $latts) {
        $m_l .= "\n" . l($latts['title'], $latts['href'], array('attributes' => $latts['attributes'])) . ' | ';
    }
    $vars['mobi_links'] = rtrim($m_l, ' | ');
    #$vars['content'] = '<pre>'. print_r($_SERVER, true) .'</pre>';
    drupal_set_header('Content-Type: ' . $mime_types[$my_dtd] . '; charset=utf-8');
    drupal_set_header("Expires: " . date("D, d M Y H:i:s", time() + 60 * 60 * 24 * 7) . " GMT");
    drupal_set_header("Cache-Control: Public");
}
        $datefieldname = "pubDate";
    } else {
        $datefieldname = "ttlr:publishDate";
    }
    $arrobj = (array) $obj;
    $arrobj[$datefieldname] = date('D, d M Y H:i:s O', $post_date);
    $arrobj['ttlr:votes'] = $row->votingapi_cache_node_points_vote_sum_value;
    $arrobj['ttlr:technorati_authority'] = $row->node_data_field_url_field_technorati_authority_value;
    $arrobj['ttlr:source_profile'] = url('node/' . $row->node_node_data_field_source_nid, array('absolute' => TRUE));
    $arrobj['ttlr:orig_url'] = $row->feedapi_node_item_url;
    $source_title = $row->node_node_data_field_source_title;
    if (empty($source_title)) {
        //Use URL instead
        $source_title = $row->node_node_data_field_source_node_data_field_url_field_url_value;
    }
    $source_title = mentions_rss_safe_str($source_title);
    $arrobj[] = array('key' => 'source', 'value' => $source_title, 'attributes' => array('url' => url($row->node_node_data_field_source_node_data_field_url_field_url_value, array('absolute' => TRUE))));
    $items .= format_rss_item($title, $link, $description, $arrobj);
}
drupal_set_header('Content-Type: application/rss+xml; charset=utf-8');
$site_name = variable_get('site_name', 'Tattler Feed');
$url = url('rss/mentions');
$description = 'Mentions feed generated from a Tattler instance';
$output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
$output .= "<rss xmlns:ttlr=\"http://tattlerapp.com/rss/tattler/\" version=\"2.0\">\n";
$output .= format_rss_channel(t('@site_name Feed', array('@site_name' => $site_name)), $url, $description, $items, $langcode);
$output .= "</rss>\n";
print $output;
module_invoke_all('exit');
//e.g. let tokenauth clear the session.
exit;