function actionDefault() { // Create the URL object $url = new YDUrl('http://www.yellowduck.be/index.xml'); // The different parts echo '<br>URL: ' . $url->getUrl(); echo '<br>Scheme: ' . $url->getScheme(); echo '<br>Host: ' . $url->getHost(); echo '<br>Port: ' . $url->getPort(); echo '<br>User: '******'<br>Password: '******'<br>Path: ' . $url->getPath(); echo '<br>Query: ' . $url->getQuery(); echo '<br>Fragment: ' . $url->getFragment(); // Get the contents YDDebugUtil::dump($url->getContents(), 'URL contents'); }
function actionMerge() { $urla = new YDUrl('http://www.yellowduck.be/directory/test/index.php?do=x&id=1&var[]=big&good=#10'); $urlb = new YDUrl('http://www.yellowduck.be/directory/test/index.php?do=x&id=3&name=blah&var[]=small&good=yes'); $urlc = new YDUrl('http://www.yellowduck.be/directory/test/index.php?var[]=medium&c=123'); // Show the original URLs YDDebugUtil::dump($urla->getUrl(), 'URL A'); YDDebugUtil::dump($urlb->getUrl(), 'URL B'); YDDebugUtil::dump($urlc->getUrl(), 'URL C'); // Merge the objects $urla->merge($urlb); $urlb->merge(array($urla, $urlc)); // Show the new URLs YDDebugUtil::dump($urla->getUrl(), 'The new URL A - merged B'); YDDebugUtil::dump($urlb->getUrl(), 'The new URL B - merged A and C'); }
function actionAlter() { // Create the URL object $url = new YDUrl('http://www.yellowduck.be:8080/directory/test/?do=x&id=1#10'); // Show the original URL YDDebugUtil::dump($url->getUrl(), 'The original URL'); // Get the contents of a query variable $do = $url->getQueryVar('do', 'y'); // Update a query variable $url->setQueryVar('do', 'y'); // setQueryVar can also be used to add a query variable $url->setQueryVar('new', 'value'); // Deleting a query variable $url->deleteQueryVar('new'); // Set a named part $url->setNamedPart('host', 'yellowduck.be'); $url->setNamedPart('user', 'pieter'); $url->setNamedPart('pass', 'kermit'); $url->setNamedPart('port', '8081'); $url->setNamedPart('path', '/dir/index.php'); $url->setNamedPart('fragment', '12'); $url->setQueryVar('id', '22'); // Show the new URL YDDebugUtil::dump($url->getUrl(), 'The new URL'); }
/** * This function returns the path string to a node * * @param $separator Html separator string * @param $classParents Html class for html links of parents * @param $classCurrent Html class for span ( current element ) * * @returns An html string */ function getBreadcrum($separator, $classParents, $classCurrent) { // init array for results $res = array(); // init url object $url = new YDUrl(YD_SELF_SCRIPT); // cycle elements to get titles foreach ($this->getPath() as $elements) { // set url var ID to this element $url->setQueryVar('id', $elements['component_id']); $url->setQueryVar('component', $elements['type']); // compute class name if ($this->_id != $elements['content_id']) { $res[] = '<a class="' . $classParents . '" href="' . $url->getUrl() . '">' . $elements['title'] . '</a>'; } else { $res[] = '<span class="' . $classCurrent . '">' . $elements['title'] . '</span>'; } } // return html string return implode($separator, $res); }