Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Pages: 1 [2] 3 4

Author Topic: [ADDON] phpEventCalendar  (Read 25982 times)

Anders Hansen

  • Newbie
  • *
  • Karma: 0
  • Posts: 35
  • Yehaaaaa
    • Kaff
Re: [ADDON] phpEventCalendar
« Reply #15 on: November 24, 2007, 01:43:45 AM »

Sorry mike1.. Does not seems to be the problem here.. I stil have a white page..
Logged

mike1

  • Full Member
  • ***
  • Karma: 6
  • Posts: 199
Re: [ADDON] phpEventCalendar
« Reply #16 on: November 24, 2007, 01:50:39 AM »

replace functions.php with this

Code: [Select]
<?php

/*******************************************************
* functions.php -
* phpEventCalendar global include file
*******************************************************/

# ###################################################################

function monthPullDown($month$montharray)
{
echo "<select name=\"month\">\n";

$selected[$month 1] = ' selected="selected"';

for($i=0;$i 12$i++) {
$val $i 1;
$sel = (isset($selected[$i])) ? $selected[$i] : "";
echo " <option value=\"$val\"$sel>$montharray[$i]</option>\n";
}
echo "</select>\n\n";
}

# ###################################################################

function yearPullDown($year)
{
echo "<select name=\"year\">\n";

$selected[$year] = ' selected="selected"';
$years_before_and_after 3;
$start_year $year $years_before_and_after;
$end_year   $year $years_before_and_after;

for($i=$start_year;$i <= $end_year$i++) {
$sel = (isset($selected[$i])) ? $selected[$i] : "";
echo " <option value=\"$i\"$sel>$i</option>\n";
}
echo "</select>\n\n";
}

# ###################################################################

function dayPullDown($day)
{
echo "<select name=\"day\">\n";

$selected[$day] = ' selected="selected"';

for($i=1;$i <= 31$i++) {
$sel = (isset($selected[$i])) ? $selected[$i] : "";
echo " <option value=\"$i\"$sel>$i</option>\n";
}
echo "</select>\n\n";
}

# ###################################################################

function hourPullDown($hour$namepre)
{
echo "\n<select name=\"" $namepre "_hour\">\n";

$selected[$hour] = ' selected="selected"';

for($i=0;$i <= 12$i++) {
$sel = (isset($selected[$i])) ? $selected[$i] : "";
echo " <option value=\"$i\"$sel>$i</option>\n";
}
echo "</select>\n\n";
}

# ###################################################################

function minPullDown($min$namepre)
{
echo "\n<select name=\"" $namepre "_min\">\n";

$selected[$min] = ' selected="selected"';

for($i=0;$i 60$i+=5) {
$disp_min sprintf("%02d"$i);
$sel = (isset($selected[$i])) ? $selected[$i] : "";
echo "\t<option value=\"$i\"$sel>$disp_min</option>\n";
}

echo "</select>\n\n";
}

# ###################################################################

function amPmPullDown($pm$namepre)
{
$sel ' selected="selected"';
$am  null;
if ($pm) { $pm $sel; } else { $am $sel; }

echo "\n<select name=\"" $namepre "_am_pm\">\n";
echo " <option value=\"0\"$am>am</option>\n";
echo " <option value=\"1\"$pm>pm</option>\n";
echo "</select>\n\n";
}

# ###################################################################

function javaScript()
{
?>

<script language="javascript">
function submitMonthYear() {
document.monthYear.method = "post";
document.monthYear.action =
"index.php?month=" + document.monthYear.month.value +
"&year=" + document.monthYear.year.value;
document.monthYear.submit();
}

function postMessage(day, month, year) {
eval(
"page" + day + " = window.open('eventform.php?d=" + day + "&m=" +
month + "&y=" + year + "', 'postScreen', 'toolbar=0,scrollbars=1," +
"location=0,statusbar=0,menubar=0,resizable=1,width=340,height=400');"
);
}

function openPosting(pId) {
eval(
"page" + pId + " = window.open('eventdisplay.php?id=" + pId +
"', 'mssgDisplay', 'toolbar=0,scrollbars=1,location=0,statusbar=0," +
"menubar=0,resizable=1,width=340,height=400');"
);
}

</script>
<?php
}

function 
search_javaScript()
{
?>

<script language="javascript">

function openPosting(pId) {
eval(
"page" + pId + " = window.open('cal/eventdisplay.php?id=" + pId +
"', 'mssgDisplay', 'toolbar=0,scrollbars=1,location=0,statusbar=0," +
"menubar=0,resizable=1,width=340,height=400');"
);
}
</script>
<?php
}
# ###################################################################

function scrollArrows($m$y)
{
// set variables for month scrolling
$nextyear  = ($m != 12) ? $y $y 1;
$prevyear  = ($m != 1)  ? $y $y 1;
$prevmonth = ($m == 1)  ? 12 $m 1;
$nextmonth = ($m == 12) ? 1  $m 1;

return "
<a href=\"index.php?month=" 
$prevmonth "&year=" $prevyear "\">
<img src=\"images/leftArrow.gif\" border=\"0\"></a>
<a href=\"index.php?month=" 
$nextmonth "&year=" $nextyear "\">
<img src=\"images/rightArrow.gif\" border=\"0\"></a>
"
;
}

# ###################################################################

function writeCalendar($month$year)
{
$str getDayNameHeader();
$eventdata getEventDataArray($month$year);

# get first row position of first day of month.
$weekpos getFirstDayOfMonthPosition($month$year);

# get number of days in month
$days date("t"mktime(0,0,0,$month,1,$year));

# initialize day variable to zero, unless $weekpos is zero
if ($weekpos == 0$day 1; else $day 0;

# initialize today's date variables for color change
$timestamp mktime() + CURR_TIME_OFFSET 3600;
$d date('j'$timestamp); 
$m date('n'$timestamp); 
$y date('Y'$timestamp);

# lookup for testing whether day is today
$today["$y-$m-$d"] = 1;

# loop writes empty cells until it reaches position of 1st day of 
# month ($wPos).  It writes the days, then fills the last row with empty 
# cells after last day
while($day <= $days) {
$str .="<tr>\n";

# write row
for($i=0;$i 7$i++) {
# if cell is a day of month
if($day && $day <= $days) {
# set css class today if cell represents current date
$class = (isset($today["$year-$month-$day"])) ? 'today' 'day';

$str .= "
<td class=\"
{$class}_cell\" valign=\"top\">
<span class=\"day_number\">\n"
;

if ($_SESSION[db('website').'Logged_In'] == token()) {
$str .= "
<a href=\"javascript: postMessage(
$day$month$year)\">
$day</a>";
} else {
$str .= "$day";
}
$str .= "</span><br>";

if (isset($eventdata[$day]["title"])) {
// enforce title limit
$eventcount count($eventdata[$day]["title"]);

if (MAX_TITLES_DISPLAYED $eventcount) {
$eventcount MAX_TITLES_DISPLAYED;
}

// write title link if day's postings 
for($j=0;$j $eventcount;$j++) {
$str .= "
<span class=\"title_txt\">
-<a href=\"javascript:openPosting("
$eventdata[$day]["id"][$j] . ")\">"
$eventdata[$day]["title"][$j] . "</a></span>"
$eventdata[$day]["timestr"][$j];
}
}

$str .= "</td>\n";
$day++;
} elseif($day == 0)  {
     
$str .= "
<td class=\"empty_day_cell\" valign=\"top\">&nbsp;</td>\n"
;
$weekpos--;
if ($weekpos == 0$day++;
     
} else {
$str .= "
<td class=\"empty_day_cell\" valign=\"top\">&nbsp;</td>\n"
;
}
     
}
$str .= "</tr>\n\n";
}
$str .= "</table>\n\n";
return $str;
}

# ###################################################################

function getDayNameHeader()
{
global $lang;

// adjust day name order if weekstart not Sunday
if (WEEK_START != 0) {
for($i=0$i WEEK_START$i++) {
$tempday array_shift($lang['abrvdays']);
array_push($lang['abrvdays'], $tempday);
}
}

$s "<table cellpadding=\"1\" cellspacing=\"1\" border=\"0\">\n<tr>\n";

foreach($lang['abrvdays'] as $day) {
$s .= "\t<td class=\"column_header\">&nbsp;$day</td>\n";
}

$s .= "</tr>\n\n";
return $s;
}

# ###################################################################

function getEventDataArray($month$year)
{
$eventdata null;
mysql_connect(DB_HOSTDB_USERDB_PASS) or die(mysql_error());
mysql_select_db(DB_NAME) or die(mysql_error());

$sql "SELECT id, d, title, start_time, end_time, ";

if (TIME_DISPLAY_FORMAT == "12hr") {
$sql .= "TIME_FORMAT(start_time, '%l:%i%p') AS stime, ";
$sql .= "TIME_FORMAT(end_time, '%l:%i%p') AS etime ";
} elseif (TIME_DISPLAY_FORMAT == "24hr") {
$sql .= "TIME_FORMAT(start_time, '%H:%i') AS stime, ";
$sql .= "TIME_FORMAT(end_time, '%H:%i') AS etime ";
} else {
echo "Bad time display format, check your configuration file.";
}

$sql .= "
FROM " 
DB_TABLE_PREFIX "mssgs WHERE m = $month AND y = $year
ORDER BY start_time"
;

$result mysql_query($sql) or die(mysql_error());

while($row mysql_fetch_assoc($result)) {
$day $row["d"];
$eventdata[$day]["id"][] = $row["id"];

# set title string; limit char length and append ellipsis if necessary
$title stripslashes($row["title"]);
$eventdata[$day]["title"][] = (strlen($title) > TITLE_CHAR_LIMIT)
substr($title0TITLE_CHAR_LIMIT) . '...'
$title

# set time string
if (!($row["start_time"] == "55:55:55" 
&& $row["end_time"] == "55:55:55")) {
$starttime 
= ($row["start_time"] == "55:55:55") ? "- -" $row["stime"];
$endtime 
= ($row["end_time"] == "55:55:55") ? "- -" $row["etime"];

$timestr "
<div align=\"right\" class=\"time_str\">
(
$starttime - $endtime)&nbsp;</div>\n";
} else {
$timestr "<br />";
}
$eventdata[$day]["timestr"][] = $timestr;
}
return $eventdata;
}

# ###################################################################

function getFirstDayOfMonthPosition($month$year)
{
$weekpos date("w"mktime(0,0,0,$month,1,$year));

// adjust position if weekstart not Sunday
if (WEEK_START != 0) {
if ($weekpos WEEK_START) {
$weekpos $weekpos WEEK_START;
} else {
$weekpos $weekpos WEEK_START;
}
}
return $weekpos;
}

# ###################################################################

?>

Logged

mike1

  • Full Member
  • ***
  • Karma: 6
  • Posts: 199
Re: [ADDON] phpEventCalendar
« Reply #17 on: November 24, 2007, 01:55:30 AM »

change include strings from snewsMU.php to config.php (MEMU config, not calendar config)
Logged

Anders Hansen

  • Newbie
  • *
  • Karma: 0
  • Posts: 35
  • Yehaaaaa
    • Kaff
Re: [ADDON] phpEventCalendar
« Reply #18 on: November 24, 2007, 02:08:18 AM »

seems like we are going somwhere.. We have finaly got the cal up and running, a bit hard to start the css.. so ass you can see in the page, it looks a litle different from what I am hoping for.

http://www.xclusive.name/kaff/cal/
Logged

mike1

  • Full Member
  • ***
  • Karma: 6
  • Posts: 199
Re: [ADDON] phpEventCalendar
« Reply #19 on: November 24, 2007, 02:12:39 AM »

nice to see you have it working  :)
Logged

Anders Hansen

  • Newbie
  • *
  • Karma: 0
  • Posts: 35
  • Yehaaaaa
    • Kaff
Re: [ADDON] phpEventCalendar
« Reply #20 on: November 24, 2007, 02:39:26 PM »

I removed the cal_pages and included the important line into the original default_pages function. Remember to edit the defuault.php to use defualt_pages instead of cal_pages.

Code: [Select]
function default_pages() {
$categorySEF = get_id('category'); $pageSEF = get_id('article'); $home = l('home_sef');
$class = (empty($categorySEF) || $categorySEF == $home && empty($pageSEF)) ? ' class="current"' : '';
if (s('disable_home') != 'on') {
echo '<li><a'.$class.' href="'.db('website').'" title="'.l('home').'">'.l('home').'</a></li>';
$class = ($categorySEF == 'archive') ? ' class="current"' : '';
} # closes "if"
          if (s('disable_archive') != 'on') {
$class = ($categorySEF == 'archive') ? ' class="current"': '';
echo '<li><a'.$class.' href="'.db('website').'archive/" title="'.l('archive').'">'.l('archive').'</a></li>';
} # closes "if"

------------------
          if (s('disable_cal') != 'on') {
$class = ($categorySEF == 'cal') ? ' class="current"': '';
echo '<li><a'.$class.' href="'.db('website').'cal/" title="'.l('events').'">'.l('events').'</a></li>';
} # closes "if"
------------------

      if (s('disable_contact') != 'on') {
$class = ($categorySEF == 'contact') ? ' class="current"': '';
echo '<li><a'.$class.' href="'.db('website').'contact/" title="'.l('contact').'">'.l('contact').'</a></li>';
} # closes "if"
      if (s('disable_sitemap') != 'on') {
$class = ($categorySEF == 'sitemap') ? ' class="current"': '';
echo '<li><a'.$class.' href="'.db('website').'sitemap/" title="'.l('sitemap').'">'.l('sitemap').'</a></li>';
} # closes "if"
## MULTI_USER - Displays the public "Register" link in pages menu
if (s('registration_off') != 'on') {
if ($_SESSION[db('website').'Logged_In'] != token()) {
$class = ($categorySEF == 'register') ? ' class="current"': '';
echo '<li><a'.$class.' href="'.db('website').'register/" title="'.l('register').'">'.l('register').'</a></li>';
} // closes 2nd "if"
} // closes 1st "if"
## END MULTI_USER
}

As you can see this defalt_pages function is already altered, made by keyrocks in the snewsMEMU. Because I wanted to have the calendar into the menu in the original text, I made these changes to leave out the cal_pages function and make the paged function more smooth. This works fine for me, and should do so in the package if you chose to make  changes to your mod.

I'm also looking for a solution to include the cal_breadcrumbs and cal_title into the original functions aswell.

Some other questions: I am struggling with the calender css, is there any default css calss made in the function.php that I dont see?

It seems to be 2 problems with the way I'm puting the calendar into the default_pages function. The first one si If you look at the calendar in the browser http://www.xclusive.name/kaff/cal/ you vil notise that link:active tag markes the wrong link. It say that its at home instead of calendar. Is there an explenation? If I should gues, the problem is related to this line    $class = ($categorySEF == 'cal') ? ' class="current"': '';       but why, I don't know.

The second is that you cant use the catergories links on the left side, it would not expand so that you can se the articles under each categori. The strange thing is that I can use everything else.

I have also experienced that the User Status box sometime will be empty. Is this a bug in you package Keyrocks?
« Last Edit: November 24, 2007, 04:02:26 PM by Anders Hansen »
Logged

Anders Hansen

  • Newbie
  • *
  • Karma: 0
  • Posts: 35
  • Yehaaaaa
    • Kaff
Re: [ADDON] phpEventCalendar
« Reply #21 on: November 24, 2007, 03:46:30 PM »

After looking at the cal_title and cal_breadcrumbs, it seems that you have to make a big change to the PEC to get it to work and include it into the snewsMEMU, atleast more than I can manage to do, since I dont know the script to well, and I don't do programing.

If Keyrocks could be so kind to do a thing like that, he would be one of the greatest men on the earth. :D

I realy would like this to work 100% and to be included as an option in to admin so you can chose to use the "cal" or not.

What do you say Keyrock, is this a task you would manage to do?
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: [ADDON] phpEventCalendar
« Reply #22 on: November 24, 2007, 04:20:24 PM »

Quote from: Anders Hansen
I have also experienced that the User Status box sometime will be empty. Is this a bug in you package Keyrocks?

Not that I am aware of... I have never had this experience with my installations.

Quote from: Anders Hansen
If Keyrocks could be so kind to do a thing like that, he would be one of the greatest men on the earth.
What do you say Keyrock, is this a task you would manage to do?

Thank you for the kind comment. I would... if I had the time... but I am far behind on several other projects that must be completed first. Please remember that we sNews Dudes volunteer our time to help members get their sNews packages installed and running... and anything more that we might provide beyond that is done if and when we have the time to do so. We encourage all members to modify and add more functionality to sNews the same way we did... by doing and learning by trial and error along the way. :)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

mike1

  • Full Member
  • ***
  • Karma: 6
  • Posts: 199
Re: [ADDON] phpEventCalendar
« Reply #23 on: November 24, 2007, 08:12:30 PM »

I removed the cal_pages and included the important line into the original default_pages function. Remember to edit the defuault.php to use defualt_pages instead of cal_pages.

Code: [Select]
function default_pages() {
$categorySEF = get_id('category'); $pageSEF = get_id('article'); $home = l('home_sef');
$class = (empty($categorySEF) || $categorySEF == $home && empty($pageSEF)) ? ' class="current"' : '';
if (s('disable_home') != 'on') {
echo '<li><a'.$class.' href="'.db('website').'" title="'.l('home').'">'.l('home').'</a></li>';
$class = ($categorySEF == 'archive') ? ' class="current"' : '';
} # closes "if"
          if (s('disable_archive') != 'on') {
$class = ($categorySEF == 'archive') ? ' class="current"': '';
echo '<li><a'.$class.' href="'.db('website').'archive/" title="'.l('archive').'">'.l('archive').'</a></li>';
} # closes "if"

------------------
          if (s('disable_cal') != 'on') {
$class = ($categorySEF == 'cal') ? ' class="current"': '';
echo '<li><a'.$class.' href="'.db('website').'cal/" title="'.l('events').'">'.l('events').'</a></li>';
} # closes "if"
------------------

      if (s('disable_contact') != 'on') {
$class = ($categorySEF == 'contact') ? ' class="current"': '';
echo '<li><a'.$class.' href="'.db('website').'contact/" title="'.l('contact').'">'.l('contact').'</a></li>';
} # closes "if"
      if (s('disable_sitemap') != 'on') {
$class = ($categorySEF == 'sitemap') ? ' class="current"': '';
echo '<li><a'.$class.' href="'.db('website').'sitemap/" title="'.l('sitemap').'">'.l('sitemap').'</a></li>';
} # closes "if"
## MULTI_USER - Displays the public "Register" link in pages menu
if (s('registration_off') != 'on') {
if ($_SESSION[db('website').'Logged_In'] != token()) {
$class = ($categorySEF == 'register') ? ' class="current"': '';
echo '<li><a'.$class.' href="'.db('website').'register/" title="'.l('register').'">'.l('register').'</a></li>';
} // closes 2nd "if"
} // closes 1st "if"
## END MULTI_USER
}

As you can see this defalt_pages function is already altered, made by keyrocks in the snewsMEMU. Because I wanted to have the calendar into the menu in the original text, I made these changes to leave out the cal_pages function and make the paged function more smooth. This works fine for me, and should do so in the package if you chose to make  changes to your mod.

I'm also looking for a solution to include the cal_breadcrumbs and cal_title into the original functions aswell.

Some other questions: I am struggling with the calender css, is there any default css calss made in the function.php that I dont see?

It seems to be 2 problems with the way I'm puting the calendar into the default_pages function. The first one si If you look at the calendar in the browser http://www.xclusive.name/kaff/cal/ you vil notise that link:active tag markes the wrong link. It say that its at home instead of calendar. Is there an explenation? If I should gues, the problem is related to this line    $class = ($categorySEF == 'cal') ? ' class="current"': '';       but why, I don't know.

The second is that you cant use the catergories links on the left side, it would not expand so that you can se the articles under each categori. The strange thing is that I can use everything else.

I have also experienced that the User Status box sometime will be empty. Is this a bug in you package Keyrocks?

The default installation instructions and package rectifies some of these problems.  For example, leaving the doctype unchanged rectifies the css problem, and using the  cal_pages function rectifies the class="current" issue.  Then, add the calendar link to the default_pages for the rest of the site.

Everything in the default calendar package and instructions is there for a reason.  Edit at your own risk  ;)
« Last Edit: November 24, 2007, 08:17:23 PM by mike1 »
Logged

Anders Hansen

  • Newbie
  • *
  • Karma: 0
  • Posts: 35
  • Yehaaaaa
    • Kaff
Re: [ADDON] phpEventCalendar
« Reply #24 on: November 26, 2007, 06:48:31 AM »

Ok. So fare I have redone to the default instructions, but I still have det problem that I described when you press any category while viewing the callendar.. Some Ideas?

So fare thanx for all you help..  both of you..

And keyrocks: It seems like there is a conflict with the user status box with this addon.. The text inside disapers some times..
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: [ADDON] phpEventCalendar
« Reply #25 on: November 27, 2007, 10:41:57 PM »

@ Anders... how are you making out with the phpEvent Calendar project?
I am caught up with my other projects... and have installed this in my MEMU package today... it was a little tricky following through all the notes in this topic though. I now have NO css applied from the default sNews template. How did you manage to get the CSS display problem solved?
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

mike1

  • Full Member
  • ***
  • Karma: 6
  • Posts: 199
Re: [ADDON] phpEventCalendar
« Reply #26 on: November 28, 2007, 12:59:43 AM »

screenshot and/or link?

if you added a base href in the title() function, you'll have issues.
If you change the doctype, you'll have issues (although if you look at Anders' source code on his website, you'll see that hes thought of a creative solution)

I ran into a little issue with the package today.  I found that relative links in the extra(); function have issues.  For example, if you have "Contact us" in the extra box with an href of "contact/", it wont work because it goes to cal/contact/.  A workaround for this is absolute URLs.  A real fix would be to adda  base href in the title function, although a significant portion of the calendar would need to be rewritten to add cal/ to the links.

And now for the bonus :)
Is there interest in a recurring events within the month feature?  If so, I'll post the code up here.  The method is crude (looping through checkboxes), but it works. 
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: [ADDON] phpEventCalendar
« Reply #27 on: November 28, 2007, 03:11:16 AM »

1 - screenshot and/or link?

2 - I ran into a little issue with the package today.  I found that relative links in the extra(); function have issues.  For example, if you have "Contact us" in the extra box with an href of "contact/", it wont work because it goes to cal/contact/.  A workaround for this is absolute URLs.  A real fix would be to adda  base href in the title function, although a significant portion of the calendar would need to be rewritten to add cal/ to the links.

3 - And now for the bonus :) Is there interest in a recurring events within the month feature?  If so, I'll post the code up here.  The method is crude (looping through checkboxes), but it works. 
1 - My project is on localhost... nothing to see really... the calendar's template has no css applied... was out for most of the evening... just had a look in the templates/default.php file and I see the problem. The stylesheet link string is not accessing my style.css file... because it is located in sNews/templates/default/css/style.css... a long ways off. We'll have to figure a way to make this switchable so that when we change templates from the Admin panel... (using Bakercad's Template Switch Mod) the right stylesheet will always apply to the calendar's template file.

2 & 3 - If its worthing anything to you Mike... I believe this calendar can be an excellent addon to sNews. I have several clients that want a full-sized calendar... and one with recurring events... which is particularly useful for scheduling meetings and events that happen on the same day every month all year long. It's good for clubs... non-profit organizations... and community portals. It appears you have come to know the calendar script very well... so you I suggest you should continue as the "Project Leader" on improving it... if you are up to it that is. For instance... you've noted that URL issue... and that could likely be solved by using variables to replace stuff throughout the files. And since you know your way around it better than the rest of us... you have the credentials to do it. So... You are nominated to continue refining this calendar script as an sNews Addon.  ;)
« Last Edit: November 28, 2007, 03:29:18 AM by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Anders Hansen

  • Newbie
  • *
  • Karma: 0
  • Posts: 35
  • Yehaaaaa
    • Kaff
Re: [ADDON] phpEventCalendar
« Reply #28 on: November 28, 2007, 05:29:04 AM »

Hello Keyrocks and Mike1.

Keyrocks: You had the same problem as myself at the start. I did not understand why the css file did not load. But I got the hang of it, and I hope you have an idé of how to make it work with the MEMU. I have to give you a big thanks for making the package. I actually got my university to open there eyes for the site I am building.

It seems like I good idé to add the calendar to the MEMU, I should realy be thankfull if you manage to include the calender into the site.
 
I get another fontsize than the snews template because of a different doctype in the cal default.php. If you have a solution with that problem, I am thankfull if you could tel me. If it is possible to change it to xhtml like in the MEMU it would be great. I'm not good with codes, so I would like to have some help there if it's possible. Somthing else that i have noticed is that it either looks like there is a tag or a class/id in the css that is not ass it should be. When I press the Your Profile in the status box it looks like the adminpanel is bleeding or something. One of the things is that the "save button is at the top left side of the extrabox on the top. It seems like it it is just when you are logged in as an siteadmin. I dont know if you have seen it, but since i have a black background, it is much easyer to spot.. 

And mike1: Nice that you found the issue with relative liks in extras. Thats the same thing I tried to explain, but my english is not the greatest, so It would be some difficulties understanding what I was trying to explain.

The addon to the cal to sound great. To make recurring events would be nice to have..

Karma from me to both of you..
« Last Edit: November 28, 2007, 06:22:49 AM by Anders Hansen »
Logged

mike1

  • Full Member
  • ***
  • Karma: 6
  • Posts: 199
Re: [ADDON] phpEventCalendar
« Reply #29 on: November 28, 2007, 07:16:45 AM »

Adds recurring events for the month

New eventform.php
Code: [Select]
<?php
session_start
();
require(
"config.php");
require(
"./lang/lang.admin." LANGUAGE_CODE ".php");
require(
"functions.php");
include(
"../snews.php");

$id   = (isset($_GET['id'])) ? $_GET['id'] : null;

if (
$_SESSION[db('website').'Logged_In'] == token()) {
if (empty($id)) {
displayEditForm('Add');
} else {
if ($_SESSION[db('website').'Logged_In'] == token()) {
displayEditForm('Edit'$id);
} else {
echo $lang['accessdenied'];
}
}
} else {
echo $lang['accessdenied'];
}

# ###########################################################

function 
displayEditForm($mode$id="")
{
global $lang;

if ($mode == "Add") {
$d  $_GET['d'];
$m  $_GET['m'];
$y  $_GET['y'];
$text  $title "";
$headerstr  $lang['addheader'];
$buttonstr  $lang['addbutton'];
$pgtitle  $lang['addeventtitle'];
$qstr  "?flag=add";
$stime_vals null;
$etime_vals null;
} elseif ($mode == "Edit") {

mysql_connect(DB_HOSTDB_USERDB_PASS) or die(mysql_error());
mysql_select_db(DB_NAME) or die(mysql_error());

$sql "SELECT y, m, d, start_time, end_time, title, text ";
$sql .= "FROM " DB_TABLE_PREFIX "mssgs WHERE id = $id";

$result mysql_query($sql) or die(mysql_error());
$row mysql_fetch_assoc($result);

if (!empty($row)) {
$qstr  "?flag=edit&id=$id";
$headerstr  $lang['editheader'];
$buttonstr $lang['editbutton'];
$pgtitle  $lang['editeventtitle'];
$title  stripslashes($row["title"]);
$text  stripslashes($row["text"]);
$m  $row["m"];
$d  $row["d"];
$y  $row["y"];
}

$stime_vals getPullDownTimeValues($row["start_time"]);
$etime_vals getPullDownTimeValues($row["end_time"]);
#, $ehour, $eminute, $epm);
} else {
$lang['accesswarning'];
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><?php echo $pgtitle ?></title>
<link rel="stylesheet" type="text/css" href="css/popwin.css">

<script language="JavaScript">
function formSubmit() {
if (document.eventForm.title.value != "") {
document.eventForm.method = "post";
document.eventForm.action = "eventsubmit.php<?php echo $qstr ?>";
document.eventForm.submit();
} else {
alert("<?php echo $lang['titlemissing'?>");
}
}
</script>

</head>
<body>
<span class="add_new_header"><?php echo $headerstr ?></span>
<br><img src="images/clear.gif" width="1" height="5"><br>
<table border=0 cellspacing=7 cellpadding=0>
<form name="eventForm">
<tr>
<td nowrap valign="top" align="right" nowrap><span class="form_labels"></span></td>
<td><?php monthPullDown($m$lang['months']); dayPullDown($d); yearPullDown($y); ?></td>
</tr>
<tr>
<td nowrap valign="top" align="right" nowrap>
<span class="form_labels"><?php echo $lang['title']?></span></td>
<td><input type="text" name="title" size="29" value="<?php echo $title ?>" maxlength="50"></td>
</tr>
<tr>
<td nowrap valign="top" align="right" nowrap>
<span class="form_labels"><?php echo $lang['text']?></span></td>
<td><textarea cols=22 rows=6 name="text"><?php echo $text ?></textarea></td>
</tr>
<tr>
<td valign="top" align="right" nowrap><span class="form_labels"><?php echo $lang['starttime'?></span></td>
<td><?php hourPullDown($stime_vals['hour'], "start"); ?><b>:</b><?php minPullDown($stime_vals['minute'], "start"); amPmPullDown($stime_vals['pm'], "start"); ?></td>
</tr>
<tr>
<td valign="top" align="right" nowrap><span class="form_labels"><?php echo $lang['endtime'?></span></td>
<td><?php hourPullDown($etime_vals['hour'], "end"); ?><b>:</b><?php minPullDown($etime_vals['minute'], "end"); amPmPullDown($etime_vals['pm'], "end"); ?></td>
</tr>
            <tr>
<? if ($mode == "Add") { ?>
<td nowrap valign="top" align="right">Or</td>
<td width="208"></td>
</tr>
<tr>
<td nowrap valign="top" align="right"><span class="form_labels">Reoccuring Event:<br>
</span><span class="form_labels">Days of this month:</span></td>
<td width="208">
<table border="0" cellspacing="2" cellpadding="0">
<tr height="19">
<td align="right" width="41" height="19">1<input type="checkbox" name="1" value="1" border="0"></td>
<td align="right" width="38" height="19">2<input type="checkbox" name="2" value="1" border="0"></td>
<td align="right" width="38" height="19">3<input type="checkbox" name="3" value="1" border="0"></td>
<td align="right" width="40" height="19">4<input type="checkbox" name="4" value="1" border="0"></td>
<td align="right" width="39" height="19">5<input type="checkbox" name="5" value="1" border="0"></td>
</tr>
<tr height="19">
<td align="right" width="41" height="19">6<input type="checkbox" name="6" value="1" border="0"></td>
<td align="right" width="38" height="19">7<input type="checkbox" name="7" value="1" border="0"></td>
<td align="right" width="38" height="19">8<input type="checkbox" name="8" value="1" border="0"></td>
<td align="right" width="40" height="19">9<input type="checkbox" name="9" value="1" border="0"></td>
<td align="right" width="39" height="19">10<input type="checkbox" name="10" value="1" border="0"></td>
</tr>
<tr height="19">
<td align="right" width="41" height="19">11<input type="checkbox" name="11" value="1" border="0"></td>
<td align="right" width="38" height="19">12<input type="checkbox" name="12" value="1" border="0"></td>
<td align="right" width="38" height="19">13<input type="checkbox" name="13" value="1" border="0"></td>
<td align="right" width="40" height="19">14<input type="checkbox" name="14" value="1" border="0"></td>
<td align="right" width="39" height="19">15<input type="checkbox" name="15" value="1" border="0"></td>
</tr>
<tr height="19">
<td align="right" width="41" height="19">16<input type="checkbox" name="16" value="1" border="0"></td>
<td align="right" width="38" height="19">17<input type="checkbox" name="17" value="1" border="0"></td>
<td align="right" width="38" height="19">18<input type="checkbox" name="18" value="1" border="0"></td>
<td align="right" width="40" height="19">19<input type="checkbox" name="19" value="1" border="0"></td>
<td align="right" width="39" height="19">20<input type="checkbox" name="20" value="1" border="0"></td>
</tr>
<tr height="19">
<td align="right" width="41" height="19">21<input type="checkbox" name="21" value="1" border="0"></td>
<td align="right" width="38" height="19">22<input type="checkbox" name="22" value="1" border="0"></td>
<td align="right" width="38" height="19">23<input type="checkbox" name="23" value="1" border="0"></td>
<td align="right" width="40" height="19">24<input type="checkbox" name="24" value="1" border="0"></td>
<td align="right" width="39" height="19">25<input type="checkbox" name="25" value="1" border="0"></td>
</tr>
<tr height="19">
<td align="right" width="41" height="19">26<input type="checkbox" name="26" value="1" border="0"></td>
<td align="right" width="38" height="19">27<input type="checkbox" name="27" value="1" border="0"></td>
<td align="right" width="38" height="19">28<input type="checkbox" name="28" value="1" border="0"></td>
<td align="right" width="40" height="19">29<input type="checkbox" name="29" value="1" border="0"></td>
<td align="right" width="39" height="19">30<input type="checkbox" name="30" value="1" border="0"></td>
</tr>
<tr height="19">
<td align="right" width="41" height="19">31<input type="checkbox" name="31" value="1" border="0"></td>
<td align="right" width="38" height="19"></td>
<td align="right" width="38" height="19"></td>
<td align="right" width="40" height="19"></td>
<td align="right" width="39" height="19"></td>
</tr>
</table>
</td><? } ?>
</tr>
            <tr><td></td><td><br><input type="button" value="<?php echo $buttonstr ?>" onClick="formSubmit()">&nbsp;<input type="button" value="<?php echo $lang['cancel'?>" onClick="window.close();"></td></tr>
</form>
</table>
</body>
</html>
<?php
}

# ###########################################################

function getPullDownTimeValues($time
{
$hour = (int) substr($time02);
$minute = (int) substr($time32);
$pm     false;

if ($hour == 55) {
$hour 0;
$minute 0;
} elseif ($hour 12) {
$hour $hour 12;
$pm true;
} elseif ($hour == 12) {
$pm true;
} elseif ($hour == 0) {
$hour 12;
$pm false;
}
return Array('hour' => $hour'minute' => $minute'pm' => $pm);
}

# ###########################################################
?>


New eventsubmit.php
Code: [Select]
<?php
session_start
();
require(
"config.php");
require(
"./lang/lang.admin." LANGUAGE_CODE ".php");
require(
"functions.php");
include(
"../snews.php");

if (
$_SESSION[db('website').'Logged_In'] == token()) {
switch ($_GET['flag']) {
case "add" :
submitEventData();
break;
case "edit":
$id = (int) $_GET['id'];

if (!empty($id))
submitEventData($id);
else
$lang['accesswarning'];
break;
case "delete":
$month  = (int) $_GET['month'];
$year = (int) $_GET['year'];
$id  = (int) $_GET['id'];

if (!(empty($id) && empty($month) && empty($year)))
deleteEvent($id$month$year);
else
$lang['accesswarning'];
break;
default:
$lang['accesswarning'];
}
} else {
echo $lang['accessdenied'];
}


function 
submitEventData ($id="")
{
global $lang;

$title  addslashes($_POST['title']);
$title strip_tags($title);
$text  addslashes($_POST['text']);
$text strip_tags($text);
$month  $_POST['month'];
$day  $_POST['day'];
$year  $_POST['year'];
$shour  $_POST['start_hour'];
$sminute  $_POST['start_min'];
$s_ampm  $_POST['start_am_pm'];
$ehour  $_POST['end_hour'];
$eminute  $_POST['end_min'];
$e_ampm  $_POST['end_am_pm'];
$a1 $_POST['1'];
$a2 $_POST['2'];
$a3 $_POST['3'];
$a4 $_POST['4'];
$a5 $_POST['5'];
$a6 $_POST['6'];
$a7 $_POST['7'];
$a8 $_POST['8'];
$a9 $_POST['9'];
$a10 $_POST['10'];
$a11 $_POST['11'];
$a12 $_POST['12'];
$a13 $_POST['13'];
$a14 $_POST['14'];
$a15 $_POST['15'];
$a16 $_POST['16'];
$a17 $_POST['17'];
$a18 $_POST['18'];
$a19 $_POST['19'];
$a20 $_POST['20'];
$a21 $_POST['21'];
$a22 $_POST['22'];
$a23 $_POST['23'];
$a24 $_POST['24'];
$a25 $_POST['25'];
$a26 $_POST['26'];
$a27 $_POST['27'];
$a28 $_POST['28'];
$a29 $_POST['29'];
$a30 $_POST['30'];
$a31 $_POST['31'];
//$reoccurevent = $HTTP_POST_VARS['reoccurevent'];

if ($shour == && $sminute == && $s_ampm == 0) {
$starttime "55:55:55";
} else {
if (
$s_ampm == && $shour != 12$shour $shour 12;
if (
$s_ampm == && $shour == 12$shour 0;
$starttime "$shour:$sminute:00";
}

if (
$ehour == && $eminute == && $e_ampm == 0) {
$endtime "55:55:55";
} else {
if (
$e_ampm == && $ehour != 12$ehour $ehour 12;
if (
$e_ampm == && $ehour == 12$ehour 0;
$endtime "$ehour:$eminute:00";
}

mysql_connect(DB_HOSTDB_USERDB_PASS) or die(mysql_error());
mysql_select_db(DB_NAME) or die(mysql_error());

if (
$id) {
$sql "UPDATE " DB_TABLE_PREFIX "mssgs SET m='$month', d='$day', y='$year', ";
$sql .= "start_time='$starttime', end_time='$endtime', title='$title', text='$text' ";
$sql .= "WHERE id=$id";
$result $lang['updated'];
mysql_query($sql) or die(mysql_error());
} else {
// If any of the reoccuring check boxes are checked then add all of them
// or else just add a one day event
$reoccur = array($a1,$a2,$a3,$a4,$a5,$a6,$a7,$a8,$a9,$a10,$a11,$a12,$a13,$a14,$a15,$a16,$a17,$a18,$a19,$a20,$a21,$a22,$a23,$a24,$a25,$a26,$a27,$a28,$a29,$a30,$a31);
for(
$count 0$count <= count($reoccur); $count++)
{
if (
$reoccur[$count] == '1') {$reoccurevent 1;}
}

// Add Reoccuring event
if ($reoccurevent == '1')
{
for(
$count 0$count <= count($reoccur); $count++)
{
if (
$reoccur[$count] == '1')
{
$count++;
$sql "INSERT INTO " DB_TABLE_PREFIX "mssgs SET m=$month, d=$count, y=$year, ";
$sql .= "start_time='$starttime', end_time='$endtime', title='$title', text='$text'";
$count--;
mysql_query($sql) or die(mysql_error());
}
}

}
// Add one day event
else
{
$sql "INSERT INTO " DB_TABLE_PREFIX "mssgs SET m=$month, d=$day, y=$year, ";
$sql .= "start_time='$starttime', end_time='$endtime', title='$title', text='$text'";
mysql_query($sql) or die(mysql_error());
}
$result $lang['added'];
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/popwin.css">
<script language="JavaScript">
opener.location =
"index.php?month=<?php echo $month ?>&year=<?php echo $year ?>";
window.setTimeout('window.close()', 1000);
</script>
</head>
<body>

<div align=\"center\" class=\"display_txt\">
<?php echo stripslashes($title?> <?php echo $result ?></div>

</body>
</html>
<?php
}

function 
deleteEvent($id$m$y)
{
mysql_connect(DB_HOSTDB_USERDB_PASS) or die(mysql_error());
mysql_select_db(DB_NAME) or die(mysql_error());

$sql "DELETE FROM " DB_TABLE_PREFIX "mssgs WHERE id = $id";
$result mysql_query($sql) or die(mysql_error());

header("Location: index.php?month=$m&year=$y");
}
?>


Make a small change to functions.php (window sizing issue)
In functions.php, find
Code: [Select]
function postMessage(day, month, year) {and you will see about 4 lines down
Code: [Select]
width=340,height=400(or some other numbers)
change it to
Code: [Select]
width=540,height=600'
Remember to change the include file paths for integration in MESU/MEMU package'
« Last Edit: November 28, 2007, 07:32:37 AM by mike1 »
Logged
Pages: 1 [2] 3 4