/** * Returns the local absolute URL to the (current) weblog frontpage. * @return string */ function snippet_home() { return get_log_url('index'); }
/** * Make a link to an entry, using the settings for how they should be formed. * * @param mixed $data * @param string $weblog * @param string $anchor * @param string $parameter * @param boolean $para_weblog */ function make_filelink($data = "", $weblog = "", $anchor = "comm", $parameter = "", $para_weblog = false) { global $db, $Weblogs, $Current_weblog, $Cfg, $Paths; // Set the weblog, if it isn't set already. if ($weblog == "") { $weblog = $Current_weblog; } // Set the 'log_url' path, if it isn't set already. if (empty($Paths['log_url'])) { $Paths['log_url'] = dirname(get_log_url('index')) . "/"; if ($Paths['log_url'] == "//") { $Paths['log_url'] = "/"; } } // Set $entry (and $code) if (empty($data)) { // Using current entry - the db object must exist and be set $entry = $db->entry; $code = $entry['code']; } elseif (is_array($data)) { // Using passed/inputed entry $entry = $data; $code = $entry['code']; } elseif (is_numeric($data)) { $code = $data; // Using the entry with the given $code // If it's not the current one, we need to load it if (!isset($db) || $code != $db->entry['code']) { $fl_db = new db(FALSE); $fl_db->read_entry($code); $entry = $fl_db->entry; } else { $entry = $db->entry; } } else { debug('Entry code must be an integer/numeric - no output.'); return; } if (!$Weblogs[$weblog]['live_entries']) { $filelink = $Paths['pivot_url'] . $Weblogs[$weblog]['entry_path'] . $Weblogs[$weblog]['entry_filename']; } else { if (isset($Cfg['mod_rewrite']) && $Cfg['mod_rewrite'] != 0 && $entry['date'] != "") { // if $entry['date'] is not set, we cant make the non-crufty url, // and we fall back to the crufty one.. switch ($Cfg['mod_rewrite']) { // archive/2005/04/20/title_of_entry case "1": $name = strlen($entry['title']) > 1 ? $entry['title'] : substr(strip_tags($entry['introduction']), 0, 70); $name = safe_string(trim($name), TRUE); if (strlen($name) > 30) { $name = substr($name, 0, 30); } list($yr, $mo, $da, $ho, $mi) = split("-", $entry['date']); $filelink = $Paths['log_url'] . "/archive/{$yr}/{$mo}/{$da}/" . $name; // Reverted it to original, since suggested fix breaks htaccess mod rewrite // $filelink = $Paths['log_url'] . $Weblogs[$weblog]['archive_path'] . "/$yr/$mo/$da/".$name; break; // archive/2005-04-20/title_of_entry // archive/2005-04-20/title_of_entry case "2": $name = strlen($entry['title']) > 1 ? $entry['title'] : substr(strip_tags($entry['introduction']), 0, 70); $name = safe_string(trim($name), TRUE); if (strlen($name) > 30) { $name = substr($name, 0, 30); } list($yr, $mo, $da, $ho, $mi) = split("-", $entry['date']); $filelink = $Paths['log_url'] . "/archive/{$yr}-{$mo}-{$da}/" . $name; // Reverted it to original, since suggested fix breaks htaccess mod rewrite // $filelink = $Paths['log_url'] . $Weblogs[$weblog]['archive_path'] . "/$yr-$mo-$da/".$name; break; // entry/1234 // entry/1234 case "3": $filelink = $Paths['log_url'] . "/entry/" . $code; break; // entry/1234/title_of_entry // entry/1234/title_of_entry case "4": $name = strlen($entry['title']) > 1 ? $entry['title'] : substr(strip_tags($entry['introduction']), 0, 70); $name = safe_string(trim($name), TRUE); if (strlen($name) > 30) { $name = substr($name, 0, 30); } $filelink = $Paths['log_url'] . "/entry/" . $code . "/{$name}"; break; } } else { $filelink = $Paths['pivot_url'] . "entry.php?id=%1{$parameter}"; } } // Add a weblog parameter if asked for, or if multiple weblogs, and the current weblog is not the first one.. if ($para_weblog || para_weblog_needed($weblog)) { if (!$Weblogs[$weblog]['live_entries']) { $filelink .= "?w=" . para_weblog($weblog); } else { if (strpos($filelink, "?") > 0) { // if there's already a '?' in the link, we add the parameter using &w= $filelink .= "&w=" . para_weblog($weblog); } else { // else we treat it as an extra 'folder' $filelink .= "/" . para_weblog($weblog); } } } $filelink = fixPath($filelink); $filelink = str_replace("%1", $code, $filelink); $filelink = format_date("", $filelink, $entry['title']); if ($anchor != "") { $filelink .= "#" . $anchor; } return $filelink; }
/** * Sets the local absolute URL to the (current) weblog directory. * * @return void */ function set_paths_log_url() { global $Paths; $Paths['log_url'] = dirname(get_log_url('index')) . "/"; if ($Paths['log_url'] == "//") { $Paths['log_url'] = "/"; } }