page.php

来自「一款可以和GOOGLE媲美的开源统计系统,运用AJAX.功能强大. 无色提示:」· PHP 代码 · 共 983 行 · 第 1/2 页

PHP
983
字号
    /**     *    Accessor for current MIME type.     *    @return string    MIME type as string; e.g. 'text/html'     *    @access public     */    function getMimeType() {        if ($this->_headers) {            return $this->_headers->getMimeType();        }        return false;    }    /**     *    Accessor for HTTP response code.     *    @return integer    HTTP response code received.     *    @access public     */    function getResponseCode() {        if ($this->_headers) {            return $this->_headers->getResponseCode();        }        return false;    }    /**     *    Accessor for last Authentication type. Only valid     *    straight after a challenge (401).     *    @return string    Description of challenge type.     *    @access public     */    function getAuthentication() {        if ($this->_headers) {            return $this->_headers->getAuthentication();        }        return false;    }    /**     *    Accessor for last Authentication realm. Only valid     *    straight after a challenge (401).     *    @return string    Name of security realm.     *    @access public     */    function getRealm() {        if ($this->_headers) {            return $this->_headers->getRealm();        }        return false;    }    /**     *    Accessor for current frame focus. Will be     *    false as no frames.     *    @return array    Always empty.     *    @access public     */    function getFrameFocus() {        return array();    }    /**     *    Sets the focus by index. The integer index starts from 1.     *    @param integer $choice    Chosen frame.     *    @return boolean           Always false.     *    @access public     */    function setFrameFocusByIndex($choice) {        return false;    }    /**     *    Sets the focus by name. Always fails for a leaf page.     *    @param string $name    Chosen frame.     *    @return boolean        False as no frames.     *    @access public     */    function setFrameFocus($name) {        return false;    }    /**     *    Clears the frame focus. Does nothing for a leaf page.     *    @access public     */    function clearFrameFocus() {    }    /**     *    Adds a tag to the page.     *    @param SimpleTag $tag        Tag to accept.     *    @access public     */    function acceptTag(&$tag) {        if ($tag->getTagName() == "a") {            $this->_addLink($tag);        } elseif ($tag->getTagName() == "base") {            $this->_setBase($tag);        } elseif ($tag->getTagName() == "title") {            $this->_setTitle($tag);        } elseif ($this->_isFormElement($tag->getTagName())) {            for ($i = 0; $i < count($this->_open_forms); $i++) {                $this->_open_forms[$i]->addWidget($tag);            }            $this->_last_widget = &$tag;        }    }    /**     *    Opens a label for a described widget.     *    @param SimpleFormTag $tag      Tag to accept.     *    @access public     */    function acceptLabelStart(&$tag) {        $this->_label = &$tag;        unset($this->_last_widget);    }    /**     *    Closes the most recently opened label.     *    @access public     */    function acceptLabelEnd() {        if (isset($this->_label)) {            if (isset($this->_last_widget)) {                $this->_last_widget->setLabel($this->_label->getText());                unset($this->_last_widget);            } else {                $this->_left_over_labels[] = SimpleTestCompatibility::copy($this->_label);            }            unset($this->_label);        }    }    /**     *    Tests to see if a tag is a possible form     *    element.     *    @param string $name     HTML element name.     *    @return boolean         True if form element.     *    @access private     */    function _isFormElement($name) {        return in_array($name, array('input', 'button', 'textarea', 'select'));    }    /**     *    Opens a form. New widgets go here.     *    @param SimpleFormTag $tag      Tag to accept.     *    @access public     */    function acceptFormStart(&$tag) {        $this->_open_forms[] = &new SimpleForm($tag, $this);    }    /**     *    Closes the most recently opened form.     *    @access public     */    function acceptFormEnd() {        if (count($this->_open_forms)) {            $this->_complete_forms[] = array_pop($this->_open_forms);        }    }    /**     *    Opens a frameset. A frameset may contain nested     *    frameset tags.     *    @param SimpleFramesetTag $tag      Tag to accept.     *    @access public     */    function acceptFramesetStart(&$tag) {        if (! $this->_isLoadingFrames()) {            $this->_frameset = &$tag;        }        $this->_frameset_nesting_level++;    }    /**     *    Closes the most recently opened frameset.     *    @access public     */    function acceptFramesetEnd() {        if ($this->_isLoadingFrames()) {            $this->_frameset_nesting_level--;        }    }    /**     *    Takes a single frame tag and stashes it in     *    the current frame set.     *    @param SimpleFrameTag $tag      Tag to accept.     *    @access public     */    function acceptFrame(&$tag) {        if ($this->_isLoadingFrames()) {            if ($tag->getAttribute('src')) {                $this->_frames[] = &$tag;            }        }    }    /**     *    Test to see if in the middle of reading     *    a frameset.     *    @return boolean        True if inframeset.     *    @access private     */    function _isLoadingFrames() {        if (! $this->_frameset) {            return false;        }        return ($this->_frameset_nesting_level > 0);    }    /**     *    Test to see if link is an absolute one.     *    @param string $url     Url to test.     *    @return boolean        True if absolute.     *    @access protected     */    function _linkIsAbsolute($url) {        $parsed = new SimpleUrl($url);        return (boolean)($parsed->getScheme() && $parsed->getHost());    }    /**     *    Adds a link to the page.     *    @param SimpleAnchorTag $tag      Link to accept.     *    @access protected     */    function _addLink($tag) {        $this->_links[] = $tag;    }    /**     *    Marker for end of complete page. Any work in     *    progress can now be closed.     *    @access public     */    function acceptPageEnd() {        while (count($this->_open_forms)) {            $this->_complete_forms[] = array_pop($this->_open_forms);        }        foreach ($this->_left_over_labels as $label) {            for ($i = 0, $count = count($this->_complete_forms); $i < $count; $i++) {                $this->_complete_forms[$i]->attachLabelBySelector(                        new SimpleById($label->getFor()),                        $label->getText());            }        }    }    /**     *    Test for the presence of a frameset.     *    @return boolean        True if frameset.     *    @access public     */    function hasFrames() {        return (boolean)$this->_frameset;    }    /**     *    Accessor for frame name and source URL for every frame that     *    will need to be loaded. Immediate children only.     *    @return boolean/array     False if no frameset or     *                              otherwise a hash of frame URLs.     *                              The key is either a numerical     *                              base one index or the name attribute.     *    @access public     */    function getFrameset() {        if (! $this->_frameset) {            return false;        }        $urls = array();        for ($i = 0; $i < count($this->_frames); $i++) {            $name = $this->_frames[$i]->getAttribute('name');            $url = new SimpleUrl($this->_frames[$i]->getAttribute('src'));            $urls[$name ? $name : $i + 1] = $this->expandUrl($url);        }        return $urls;    }    /**     *    Fetches a list of loaded frames.     *    @return array/string    Just the URL for a single page.     *    @access public     */    function getFrames() {        $url = $this->expandUrl($this->getUrl());        return $url->asString();    }    /**     *    Accessor for a list of all links.     *    @return array   List of urls with scheme of     *                    http or https and hostname.     *    @access public     */    function getUrls() {        $all = array();        foreach ($this->_links as $link) {            $url = $this->_getUrlFromLink($link);            $all[] = $url->asString();        }        return $all;    }    /**     *    Accessor for URLs by the link label. Label will match     *    regardess of whitespace issues and case.     *    @param string $label    Text of link.     *    @return array           List of links with that label.     *    @access public     */    function getUrlsByLabel($label) {        $matches = array();        foreach ($this->_links as $link) {            if ($link->getText() == $label) {                $matches[] = $this->_getUrlFromLink($link);            }        }        return $matches;    }    /**     *    Accessor for a URL by the id attribute.     *    @param string $id       Id attribute of link.     *    @return SimpleUrl       URL with that id of false if none.     *    @access public     */    function getUrlById($id) {        foreach ($this->_links as $link) {            if ($link->getAttribute('id') === (string)$id) {                return $this->_getUrlFromLink($link);            }        }        return false;    }    /**     *    Converts a link tag into a target URL.     *    @param SimpleAnchor $link    Parsed link.     *    @return SimpleUrl            URL with frame target if any.     *    @access private     */    function _getUrlFromLink($link) {        $url = $this->expandUrl($link->getHref());        if ($link->getAttribute('target')) {            $url->setTarget($link->getAttribute('target'));        }        return $url;    }    /**     *    Expands expandomatic URLs into fully qualified     *    URLs.     *    @param SimpleUrl $url        Relative URL.     *    @return SimpleUrl            Absolute URL.     *    @access public     */    function expandUrl($url) {        if (! is_object($url)) {            $url = new SimpleUrl($url);        }        $location = $this->getBaseUrl() ? $this->getBaseUrl() : new SimpleUrl();        return $url->makeAbsolute($location->makeAbsolute($this->getUrl()));    }    /**     *    Sets the base url for the page.     *    @param SimpleTag $tag    Base URL for page.     *    @access protected     */    function _setBase(&$tag) {        $url = $tag->getAttribute('href');        $this->_base = new SimpleUrl($url);    }    /**     *    Sets the title tag contents.     *    @param SimpleTitleTag $tag    Title of page.     *    @access protected     */    function _setTitle(&$tag) {        $this->_title = &$tag;    }    /**     *    Accessor for parsed title.     *    @return string     Title or false if no title is present.     *    @access public     */    function getTitle() {        if ($this->_title) {            return $this->_title->getText();        }        return false;    }    /**     *    Finds a held form by button label. Will only     *    search correctly built forms.     *    @param SimpleSelector $selector       Button finder.     *    @return SimpleForm                    Form object containing     *                                          the button.     *    @access public     */    function &getFormBySubmit($selector) {        for ($i = 0; $i < count($this->_complete_forms); $i++) {            if ($this->_complete_forms[$i]->hasSubmit($selector)) {                return $this->_complete_forms[$i];            }        }        $null = null;        return $null;    }    /**     *    Finds a held form by image using a selector.     *    Will only search correctly built forms.     *    @param SimpleSelector $selector  Image finder.     *    @return SimpleForm               Form object containing     *                                     the image.     *    @access public     */    function &getFormByImage($selector) {        for ($i = 0; $i < count($this->_complete_forms); $i++) {            if ($this->_complete_forms[$i]->hasImage($selector)) {                return $this->_complete_forms[$i];            }        }        $null = null;        return $null;    }    /**     *    Finds a held form by the form ID. A way of     *    identifying a specific form when we have control     *    of the HTML code.     *    @param string $id     Form label.     *    @return SimpleForm    Form object containing the matching ID.     *    @access public     */    function &getFormById($id) {        for ($i = 0; $i < count($this->_complete_forms); $i++) {            if ($this->_complete_forms[$i]->getId() == $id) {                return $this->_complete_forms[$i];            }        }        $null = null;        return $null;    }    /**     *    Sets a field on each form in which the field is     *    available.     *    @param SimpleSelector $selector    Field finder.     *    @param string $value               Value to set field to.     *    @return boolean                    True if value is valid.     *    @access public     */    function setField($selector, $value) {        $is_set = false;        for ($i = 0; $i < count($this->_complete_forms); $i++) {            if ($this->_complete_forms[$i]->setField($selector, $value)) {                $is_set = true;            }        }        return $is_set;    }    /**     *    Accessor for a form element value within a page.     *    @param SimpleSelector $selector    Field finder.     *    @return string/boolean             A string if the field is     *                                       present, false if unchecked     *                                       and null if missing.     *    @access public     */    function getField($selector) {        for ($i = 0; $i < count($this->_complete_forms); $i++) {            $value = $this->_complete_forms[$i]->getValue($selector);            if (isset($value)) {                return $value;            }        }        return null;    }}?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?