当前位置: 首页>>代码示例>>PHP>>正文


PHP drupal_set_header函数代码示例

本文整理汇总了PHP中drupal_set_header函数的典型用法代码示例。如果您正苦于以下问题:PHP drupal_set_header函数的具体用法?PHP drupal_set_header怎么用?PHP drupal_set_header使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了drupal_set_header函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: vozmob_white_label_preprocess_page

/**
 * 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'));
}
开发者ID:vojodotco,项目名称:vozmob,代码行数:17,代码来源:template.php

示例2: system_watchdog

 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);
     }
 }
开发者ID:redb,项目名称:MNPP,代码行数:13,代码来源:runserver-prepend.php

示例3: guifi_csvproxy

/**
 * 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";
            }
        }
    }
}
开发者ID:itorres,项目名称:drupal-guifi,代码行数:21,代码来源:guifi_csvproxy.inc.php

示例4: phptemplate_preprocess_page

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'];
        }
    }
}
开发者ID:andrygorokhovets,项目名称:vergelijkz,代码行数:42,代码来源:template.php

示例5: xml_atom_render


//.........这里部分代码省略.........
                    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;
    }
}
开发者ID:edchacon,项目名称:scratchpads,代码行数:101,代码来源:views-view-xml.tpl.php

示例6: send_header

 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");
     }
 }
开发者ID:xanthakita,项目名称:toque,代码行数:8,代码来源:Graph3d.php

示例7: foreach

        $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;
    }
}
开发者ID:sojo,项目名称:d6_friendsofsilence,代码行数:31,代码来源:views-views-xhtml-style-hcard.tpl.php

示例8: SimplyCivi_preprocess_page

/**
 * 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);
      */
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:89,代码来源:template.php

示例9: phptemplate_maintenance_page

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;
}
开发者ID:noslokire,项目名称:Project-206,代码行数:30,代码来源:template.php

示例10: setHttpHeader

 /**
  * @inheritDoc
  */
 public function setHttpHeader($name, $value)
 {
     drupal_set_header("{$name}: {$value}");
 }
开发者ID:rollox,项目名称:civicrm-core,代码行数:7,代码来源:Drupal6.php

示例11: bawstats_render_map_image

/**
 *
 * 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);
}
开发者ID:ibevamp,项目名称:t30,代码行数:20,代码来源:render_map.inc.php

示例12: rdf_sioc_xml_render


//.........这里部分代码省略.........
            }
            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;
    }
}
开发者ID:edchacon,项目名称:scratchpads,代码行数:101,代码来源:views-view-rdf.tpl.php

示例13: handle


//.........这里部分代码省略.........
                     // 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());
     }
 }
开发者ID:hugowetterberg,项目名称:jsonrpc_server,代码行数:101,代码来源:JsonRpcServer.php

示例14: guifi_users_dump_ldif

function guifi_users_dump_ldif($service)
{
    drupal_set_header('Content-Type: text/plain; charset=utf-8');
    print _guifi_users_dump_federated($service, TRUE);
    exit;
}
开发者ID:itorres,项目名称:drupal-guifi,代码行数:6,代码来源:guifi_users.inc.php

示例15: guifi_gml_links

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>';
    }
}
开发者ID:itorres,项目名称:drupal-guifi,代码行数:84,代码来源:guifi_gml.inc.php


注:本文中的drupal_set_header函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。