Fix problems when friendica is installed in a subpath; small CSS-Fixes

This commit is contained in:
friendica 2012-06-04 19:18:20 +02:00
parent 7115197a33
commit 2c80f61876
8 changed files with 47 additions and 35 deletions

View file

@ -1,8 +1,15 @@
<?php
$a = get_app();
$uri = parse_url($a->get_baseurl());
$path = "";
if (strlen($uri["path"]) > 1) {
$path = $uri["path"] . "/";
}
define("CALDAV_SQL_DB", "");
define("CALDAV_SQL_PREFIX", "dav_");
define("CALDAV_URL_PREFIX", "dav/");
define("CALDAV_URL_PREFIX", $path . "dav/");
define("CALDAV_NAMESPACE_PRIVATE", 1);
define("CALDAV_NAMESPACE_FRIENDICA_NATIVE", 2);

View file

@ -480,7 +480,7 @@ function wdcal_get_list_range_params($day, $weekstartday, $num_days, $type)
/**
*
*/
function wdcal_print_feed()
function wdcal_print_feed($base_path = "")
{
$user_id = dav_compat_get_curr_user_id();
$cals = array();
@ -538,7 +538,7 @@ function wdcal_print_feed()
$ret['error'] = null;
foreach ($cals as $c) {
$events = $c->listItemsByRange($date[0], $date[1]);
$events = $c->listItemsByRange($date[0], $date[1], $base_path);
$ret["events"] = array_merge($ret["events"], $events);
}

View file

@ -113,9 +113,10 @@ abstract class AnimexxCalSource
* @abstract
* @param string $sd
* @param string $ed
* @param string $base_path
* @return array
*/
public abstract function listItemsByRange($sd, $ed);
public abstract function listItemsByRange($sd, $ed, $base_path);
/**
@ -134,4 +135,4 @@ abstract class AnimexxCalSource
return null;
}
}
}

View file

@ -249,7 +249,7 @@ class AnimexxCalSourcePrivate extends AnimexxCalSource
return $obj_id . ".ics";
}
private function jqcal2wdcal($row, $usr_id) {
private function jqcal2wdcal($row, $usr_id, $base_path) {
$evo = new DBClass_friendica_jqcalendar($row);
$not = q("SELECT COUNT(*) num FROM %s%snotifications WHERE `ical_uri` = '%s' AND `ical_recurr_uri` = '%s'",
CALDAV_SQL_DB, CALDAV_SQL_PREFIX, dbesc($row["ical_uri"]), $row["ical_recurr_uri"]
@ -274,8 +274,8 @@ class AnimexxCalSourcePrivate extends AnimexxCalSource
"location" => $evo->Location,
"attendees" => '',
"has_notification" => ($not[0]["num"] > 0 ? 1 : 0),
"url_detail" => "/dav/wdcal/" . $evo->ical_uri . "/",
"url_edit" => "/dav/wdcal/" . $evo->ical_uri . "/edit/",
"url_detail" => $base_path . $evo->ical_uri . "/",
"url_edit" => $base_path . $evo->ical_uri . "/edit/",
"special_type" => "",
);
return $arr;
@ -284,9 +284,10 @@ class AnimexxCalSourcePrivate extends AnimexxCalSource
/**
* @param string $sd
* @param string $ed
* @param string $base_path
* @return array
*/
public function listItemsByRange($sd, $ed)
public function listItemsByRange($sd, $ed, $base_path)
{
$usr_id = IntVal($this->calendarDb->uid);
@ -300,7 +301,7 @@ class AnimexxCalSourcePrivate extends AnimexxCalSource
$usr_id, $this->getNamespace(), $this->namespace_id, dbesc($von), dbesc($bis));
$events = array();
foreach ($evs as $row) $events[] = $this->jqcal2wdcal($row, $usr_id);
foreach ($evs as $row) $events[] = $this->jqcal2wdcal($row, $usr_id, $base_path);
return $events;
}

View file

@ -96,7 +96,7 @@ function wdcal_printCalendar($calendars, $calendar_preselected, $data_feed_url,
$x .= '<label style="margin-left: 10px; margin-right: 10px;"><input type="checkbox" name="cals[]" value="' . $cal["ns"] . '-' . $cal["id"] . '"';
$found = false;
foreach ($calendar_preselected as $pre) if ($pre["ns"] == $cal["ns"] && $pre["id"] == $cal["id"]) $found = true;
if ($found) $x .= 'checked';
if ($found) $x .= ' checked';
$x .= '> ' . escape_tags($cal["displayname"]) . '</label> ';
}
@ -109,7 +109,7 @@ function wdcal_printCalendar($calendars, $calendar_preselected, $data_feed_url,
$x .= '<div class="ctoolbar">
<div class="fbutton faddbtn" style="float: right;">
<div><a href="/dav/settings/"><span>' . t("Settings") . ' / ' . t("Help") . '</span></a></div>
<div><a href="' . $a->get_baseurl() . '/dav/settings/"><span>' . t("Settings") . ' / ' . t("Help") . '</span></a></div>
</div>
<div class="btnseparator"></div>
<div class="fbutton showtodaybtn">
@ -191,7 +191,7 @@ function wdcal_getDetailPage($uri, $recurr_uri)
$details = $cs->getItemByUri($uri);
} catch (Exception $e) {
notification(t("Error") . ": " . $e);
goaway("/dav/wdcal/");
goaway($a->get_baseurl() . "/dav/wdcal/");
}
}
@ -211,7 +211,7 @@ function wdcal_postEditPage($uri, $recurr_uri)
$a = get_app();
$localization = wdcal_local::getInstanceByUser($a->user["uid"]);
check_form_security_token_redirectOnErr("/dav/wdcal/", "caledit");
check_form_security_token_redirectOnErr($a->get_baseurl() . "/dav/wdcal/", "caledit");
if (isset($_REQUEST["allday"])) {
$start = $localization->date_parseLocal($_REQUEST["start_date"] . " 00:00");
@ -236,7 +236,7 @@ function wdcal_postEditPage($uri, $recurr_uri)
} catch (Exception $e) {
notification(t("Error") . ": " . $e);
}
goaway("/dav/wdcal/");
goaway($a->get_baseurl() . "/dav/wdcal/");
}
}
@ -323,8 +323,8 @@ function wdcal_getEditPage($uri, $recurr_uri)
}
$out = "<a href='/dav/wdcal/'>" . t("Go back to the calendar") . "</a><br><br>";
$out .= "<form method='POST' action='/dav/wdcal/$uri/edit/'><input type='hidden' name='form_security_token' value='" . get_form_security_token('caledit') . "'>\n";
$out = "<a href='" . $a->get_baseurl() . "/dav/wdcal/'>" . t("Go back to the calendar") . "</a><br><br>";
$out .= "<form method='POST' action='" . $a->get_baseurl() . "/dav/wdcal/$uri/edit/'><input type='hidden' name='form_security_token' value='" . get_form_security_token('caledit') . "'>\n";
$out .= "<label for='cal_subject'>Subject:</label>
<input name='color' id='cal_color' value='" . (strlen($event["Color"]) != 7 ? "#5858ff" : escape_tags($event["Color"])) . "'>
@ -389,19 +389,19 @@ function wdcal_getSettingsPage(&$a)
}
if (isset($_REQUEST["save"])) {
check_form_security_token_redirectOnErr('/dav/settings/', 'calprop');
check_form_security_token_redirectOnErr($a->get_baseurl() . '/dav/settings/', 'calprop');
set_pconfig($a->user["uid"], "dav", "dateformat", $_REQUEST["wdcal_date_format"]);
info(t('The new values have been saved.'));
}
$o = "";
$o .= "<a href='/dav/wdcal/'>" . t("Go back to the calendar") . "</a><br><br>";
$o .= "<a href='" . $a->get_baseurl() . "/dav/wdcal/'>" . t("Go back to the calendar") . "</a><br><br>";
$o .= '<h3>' . t('Calendar Settings') . '</h3>';
$current_format = wdcal_local::getInstanceByUser($a->user["uid"]);
$o .= '<form method="POST" action="/dav/settings/">';
$o .= '<form method="POST" action="' . $a->get_baseurl() . '/dav/settings/">';
$o .= "<input type='hidden' name='form_security_token' value='" . get_form_security_token('calprop') . "'>\n";
$o .= '<label for="wdcal_date_format">' . t('Date format') . ':</label><select name="wdcal_date_format" id="wdcal_date_format" size="1">';
@ -441,7 +441,7 @@ function wdcal_getSettingsPage(&$a)
<li>Add a new account</li>
<li>Other...</li>
<li>Calendar -> CalDAV-Account</li>
<li><b>Server:</b> " . $a->get_hostname() . "/dav/ / <b>Username/Password:</b> <em>the same as your friendica-login</em></li>
<li><b>Server:</b> " . $a->get_baseurl() . "/dav/ / <b>Username/Password:</b> <em>the same as your friendica-login</em></li>
</ul>";
$o .= '<h4>' . t('Synchronizing your Friendica-Contacts with the iPhone') . '</h4>';
@ -452,7 +452,7 @@ function wdcal_getSettingsPage(&$a)
<li>Add a new account</li>
<li>Other...</li>
<li>Contacts -> CardDAV-Account</li>
<li><b>Server:</b> " . $a->get_hostname() . "/dav/ / <b>Username/Password:</b> <em>the same as your friendica-login</em></li>
<li><b>Server:</b> " . $a->get_baseurl() . "/dav/ / <b>Username/Password:</b> <em>the same as your friendica-login</em></li>
</ul>";
return $o;

View file

@ -29,9 +29,6 @@ function dav_module()
function dav_init(&$a)
{
error_reporting(E_ALL);
ini_set("display_errors", 1);
/*
* Recommended settings:
* ALTER TABLE `photo` ADD INDEX ( `contact-id` )
@ -91,7 +88,7 @@ function dav_init(&$a)
if ($a->argc >= 2 && $a->argv[1] == "wdcal") {
if ($a->argc >= 3 && $a->argv[2] == "feed") {
wdcal_print_feed();
wdcal_print_feed($a->get_baseurl() . "/dav/wdcal/");
killme();
} elseif ($a->argc >= 3 && strlen($a->argv[2]) > 0) {
wdcal_addRequiredHeadersEdit();
@ -133,7 +130,8 @@ function dav_init(&$a)
// The object tree needs in turn to be passed to the server class
$server = new Sabre_DAV_Server($tree);
$server->setBaseUri("/" . CALDAV_URL_PREFIX);
$url = parse_url($a->get_baseurl());
$server->setBaseUri(CALDAV_URL_PREFIX);
$authPlugin = new Sabre_DAV_Auth_Plugin($authBackend, 'SabreDAV');
$server->addPlugin($authPlugin);
@ -186,7 +184,7 @@ function dav_content()
$cals = dav_getMyCals($a->user["uid"]);
$cals_show = array();
foreach ($cals as $e) $cals_show[] = array("ns" => $e->namespace, "id" => $e->namespace_id, "displayname" => $e->displayname);
$x = wdcal_printCalendar($cals, $cals_show, "/dav/wdcal/feed/", "week", 0, 200);
$x = wdcal_printCalendar($cals, $cals_show, $a->get_baseurl() . "/dav/wdcal/feed/", "week", 0, 200);
}
}
return $x;
@ -223,7 +221,7 @@ function dav_profile_tabs_hook(&$a, &$b)
{
$b["tabs"][] = array(
"label" => t('Calendar'),
"url" => "/dav/wdcal/",
"url" => $a->get_baseurl() . "/dav/wdcal/",
"sel" => "",
"title" => t('Extended calendar with CalDAV-support'),
);
@ -281,4 +279,4 @@ function dav_plugin_admin(&$a, &$o)
$tables = dav_get_create_statements();
foreach ($tables as $t) $o .= escape_tags($t . "\n\n");
$o .= "</pre></blockquote>";
}
}

View file

@ -515,8 +515,10 @@ border-bottom:2px solid #c3c3ff;
position: absolute; visibility: hidden; font-size: 9pt; top: 0px; left: 0px
}
.bubble-table {
width: 100%; TABLE-LAYOUT: fixed
width: 100%; TABLE-LAYOUT: fixed;
border-spacing: 0;
}
.bubble-table > tbody > tr > td { padding: 0; }
.bubble-cell-side {
width: 25px
}
@ -685,4 +687,4 @@ border-bottom:2px solid #c3c3ff;
.monthdayshow:hover
{
text-decoration:underline;
}
}

View file

@ -85,6 +85,7 @@ class FriendicaCalSourceEvents extends AnimexxCalSource
$end = wdcal_mySql2PhpTime($row["data_end"]);
if ($row["data_allday"]) $end--;
$start = wdcal_mySql2PhpTime($row["data_start"]);
$a = get_app();
$arr = array(
"uri" => $row["data_uri"],
"subject" => escape_tags($row["data_subject"]),
@ -99,7 +100,7 @@ class FriendicaCalSourceEvents extends AnimexxCalSource
"location" => $row["data_location"],
"attendees" => '',
"has_notification" => false,
"url_detail" => "/dav/wdcal/" . $row["data_uri"] . "/",
"url_detail" => $a->get_baseurl() . "/dav/wdcal/" . $row["data_uri"] . "/",
"url_edit" => "",
"special_type" => ($row["data_type"] == "birthday" ? "birthday" : ""),
);
@ -109,9 +110,10 @@ class FriendicaCalSourceEvents extends AnimexxCalSource
/**
* @param string $sd
* @param string $ed
* @param string $base_path
* @return array
*/
public function listItemsByRange($sd, $ed)
public function listItemsByRange($sd, $ed, $base_path)
{
$usr_id = IntVal($this->calendarDb->uid);
@ -149,8 +151,9 @@ class FriendicaCalSourceEvents extends AnimexxCalSource
public function getItemDetailRedirect($uri) {
$x = explode("@", $uri);
$y = explode("-", $x[0]);
$a = get_app();
if (count($y) != 3) {
goaway("/dav/wdcal/");
goaway($a->get_baseurl() . "/dav/wdcal/");
killme();
}
$a = get_app();