Link to glossary entry.

@param \core_search\document $doc
@return \moodle_url
969420
public function get_doc_url(\core_search\document $doc) {
        global $USER;

        // The post is already in static cache, we fetch it in self::search_access.
        $entry = $this->get_entry($doc->get('itemid'));
        $contextmodule = \context::instance_by_id($doc->get('contextid'));

        if ($entry->approved == false && $entry->userid != $USER->id) {
            // The URL should change when the entry is not approved and it was not created by the user.
            $docparams = array('id' => $contextmodule->instanceid, 'mode' => 'approval');
        } else {
            $docparams = array('id' => $contextmodule->instanceid, 'mode' => 'entry', 'hook' => $doc->get('itemid'));

        }
        return new \moodle_url('/mod/glossary/view.php', $docparams);
    }
422676
public function get_doc_url(\core_search\document $doc) {
        // Get correct URL to section that contains label, from course format.
        $cminfo = $this->get_cm($this->get_module_name(), strval($doc->get('itemid')), $doc->get('courseid'));
        $format = course_get_format($cminfo->get_course());
        $url = $format->get_view_url($cminfo->sectionnum);

        // Add the ID of the label to the section URL.
        $url->set_anchor('module-' . $cminfo->id);
        return $url;
    }
262750
public function get_url() {
        $logurl = new \moodle_url('/notes/index.php', array('course' => $this->courseid, 'user' => $this->relateduserid));
        $logurl->set_anchor('note-' . $this->objectid);
        return $logurl;
    }
1259941
function getPath(\DOMDocument $document)
    {
        $name = $document->documentElement->localName;
        if (empty($this->version)) {
            $this->loadVersion($document);
        }
        $path = $this->getFullPath($name);

        return $path;
    }
739291
private function filterDocBlock($docs)
    {
        foreach ($docs as &$line) {
            $line = preg_replace('~\s*\*\s*~', '', $line);
            $line = preg_replace('~^/$~', '', $line);
        }
        $docs = array_values(array_filter($docs));
        
        return $docs;
    }
208643
public function detectNamespacesFromDocument( $doc )
	{
		$namespaces	= self::getNamespacesFromDocument( $element );
		$this->namespaces	= array_merge( $this->namespaces, $namespaces );
		return count( $namespaces );
	}
813881
public function attach($document)
    {
        if (isset($this->connection)) {
            $document = $this->connection->unmarshall($document);
        }

        // wrap document as NObject instance to make sure it can be override by hooks
        $document = new NObject($document);

        $this->applyHook('attaching', $document);

        if (isset($this->options['model'])) {
            $Model = $this->options['model'];
            $model = new $Model($document->toArray(), array(
                'collection' => $this,
            ));
        } else {
            $model = new Model($document->toArray(), array(
                'collection' => $this,
            ));
        }

        $this->applyHook('attached', $model);

        return $model;
    }
297403
public static function parse($doc)
    {
        $block = new DocBlock();
        $lines = explode("\n", $doc);

        // remove first line
        unset($lines[0]);

        foreach ($lines as $line) {
            $line = trim($line);
            $line = substr($line, 2);

            if (isset($line[0]) && $line[0] == '@') {
                $line = substr($line, 1);
                $sp   = strpos($line, ' ');
                $bp   = strpos($line, '(');

                if ($sp !== false || $bp !== false) {
                    if ($sp !== false && $bp === false) {
                        $pos = $sp;
                    } elseif ($sp === false && $bp !== false) {
                        $pos = $bp;
                    } else {
                        $pos = $sp < $bp ? $sp : $bp;
                    }

                    $key   = substr($line, 0, $pos);
                    $value = substr($line, $pos);
                } else {
                    $key   = $line;
                    $value = null;
                }

                $key   = trim($key);
                $value = trim($value);

                if (!empty($key)) {
                    // if key contains backslashes its a namespace use only the
                    // short name
                    $pos = strrpos($key, '\\');
                    if ($pos !== false) {
                        $key = substr($key, $pos + 1);
                    }

                    $block->addAnnotation($key, $value);
                }
            }
        }

        return $block;
    }
133417
public function getDocument($document, $rootNode)
	{
		if ($rootNode == null)
		{
			$rootNode = "page";
		}
		return $this->_persistUtil->getDocument($document, $rootNode);
	}
1157636
public function attach_files($doc) {
        global $DB;

        $entryid = $doc->get('itemid');

        try {
            $entry = $this->get_entry($entryid);
        } catch (\dml_missing_record_exception $e) {
            debugging('Could not get record to attach files to '.$doc->get('id'), DEBUG_DEVELOPER);
            return;
        }

        $cm = $this->get_cm('data', $entry->dataid, $doc->get('courseid'));
        $context = \context_module::instance($cm->id);

        // Get the files and attach them.
        $fs = get_file_storage();
        $files = $fs->get_area_files($context->id, 'mod_data', 'content', $entryid, 'filename', false);
        foreach ($files as $file) {
            $doc->add_stored_file($file);
        }
    }
165248
public function format(\DOMDocument $document) : \DOMDocument
    {
        $element = $document->createElement('feed');
        $element->setAttribute('xmlns', 'http://www.w3.org/2005/Atom');
        $document->appendChild($element);

        return $document;
    }
442056
public function setDocument(\Neobazaar\Entity\Document $document = null)
    {
        $this->document = $document;
    
        return $this;
    }
1228290
public static function process(array $docs)
    {
        return self::flatmap(function ($doc) {
            return self::flatmap(function ($tag) {
                return self::flatmap(function ($type) {
                    return self::processType($type);
                }, self::processTag($tag));
            }, $doc->getTags());
        }, $docs);
    }
950429
protected function kneadHref( \DOMDocument $doc, $type, $pos ) {

		$urls = $doc->getElementsByTagName( 'a' );
		foreach ( $urls as $url ) {
			/** @var \DOMElement $url */
			$current_url = '' . $url->getAttribute( 'href' ); // Stringify

			// Is this the the attributionUrl?
			if ( $url->getAttribute( 'rel' ) === 'cc:attributionURL' ) {
				$url->parentNode->replaceChild(
					$doc->createTextNode( $url->nodeValue ),
					$url
				);
				continue;
			}

			// Don't touch empty urls
			if ( ! trim( $current_url ) ) {
				continue;
			}

			// WordPress auto wraps images in a href tags.
			// For example: <a href="some_image-original.png"><img src="some_image-300x200.png" /></a>
			// This causes an EPUB validation error of: hyperlink to non-standard resource ( of type 'image/...' )
			// We fix this by removing the href
			if ( $url->childNodes->length ) {
				foreach ( $url->childNodes as $node ) {
					/** @var \DOMElement $node */
					if ( 'img' === $node->nodeName && $this->fuzzyImageNameMatch( $current_url, $node->getAttribute( 'src' ) ) ) {
						$url->removeAttribute( 'href' );
						continue 2;
					}
				}
			}

			// Determine if we are trying to link to our own internal content
			$internal_url = $this->fuzzyHrefMatch( $current_url, $pos );
			if ( false !== $internal_url ) {
				$url->setAttribute( 'href', $internal_url );
				continue;
			}

			// Canonicalize, fix typos, remove garbage
			if ( isset( $current_url[0] ) && '#' !== $current_url[0] ) {
				$url->setAttribute( 'href', \Pressbooks\Sanitize\canonicalize_url( $current_url ) );
			}
		}

		return $doc;
	}
991076
public function getLocaleForDocument($document)
    {
        $oid = $this->getObjectIdentifier($document);
        $this->assertDocumentExists($document);

        return $this->documentLocaleMap[$oid];
    }
1342724
public function update($docId, $doc)
    {
        return $this->montage->request(
            'post',
            $this->montage->url('document-detail', $this->schema->name, $docId),
            ['body' => json_encode($doc)]
        );
    }
582371
public Content getDocLink(LinkInfoImpl.Kind context, MemberDoc doc, String label) {
        return getDocLink(context, doc.containingClass(), doc,
                new StringContent(label));
    }