Compare commits

..

60 Commits

Author SHA1 Message Date
blizzard%redhat.com
2ca39b9b17 merge from head
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@53740 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-17 03:57:27 +00:00
blizzard%redhat.com
fe94a6ca17 merges from head
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@53737 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-17 03:27:47 +00:00
blizzard%redhat.com
dbd81545d5 remove these files from the branch, they are elsewhere in head now...
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@53733 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-17 03:14:54 +00:00
blizzard%redhat.com
eae64955ac merge modal changes from head
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@53660 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-16 16:15:13 +00:00
blizzard%redhat.com
ac2b83c0f5 merge IM fixes from head
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@53656 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-16 16:08:54 +00:00
blizzard%redhat.com
4de4b9b262 merges from head
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@53653 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-16 15:56:04 +00:00
(no author)
585367a7b8 This commit was manufactured by cvs2svn to create branch 'SUPERWIN'.
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@53594 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-16 01:52:21 +00:00
blizzard%redhat.com
8226158ae4 focus changes from head
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@53447 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-14 04:34:41 +00:00
blizzard%redhat.com
9cb5b0bd0f don't clear the xlate queue for ConfigureEvents on shell windows since the xlate queue has nothing to do with that shell window...
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@53425 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-13 15:10:10 +00:00
blizzard%redhat.com
ac24bf46fe merges from head
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@53408 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-13 04:55:21 +00:00
blizzard%redhat.com
feb3b49669 work around for lame NS_SIZE event problems...
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@53361 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-12 20:24:19 +00:00
blizzard%redhat.com
e4d84ceca8 use the external gtksuperwin library
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@53360 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-12 20:14:52 +00:00
blizzard%redhat.com
63e9105b5f add gtksuperwin to the build list
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@53359 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-12 20:13:40 +00:00
blizzard%redhat.com
21904a64db patch from claudius@netscape.com to make this build on platforms with picky c++ compilers
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@53355 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-12 18:10:02 +00:00
blizzard%redhat.com
6d8df6d4e7 add a -lgtksuperwin for the viewer since it embeds a native widget into the layout
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@53354 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-12 17:29:47 +00:00
blizzard%redhat.com
8f49d292ca merge in some of pav's IM changes...
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@53281 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-12 00:04:56 +00:00
pavlov%netscape.com
e1431cd937 fix loop in debugging code
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@53251 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-11 22:03:47 +00:00
blizzard%redhat.com
d8ee1acce8 make sure that we do a gtk_style_attach() in the realize method so the style doesn't get destroyed early...
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@53241 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-11 21:39:27 +00:00
blizzard%redhat.com
db224b8d6e merge in clipboard changes. remove some more debugging spew.
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@53089 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-10 21:29:44 +00:00
blizzard%redhat.com
37106d7fc3 remove more debugging spew
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@53088 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-10 21:05:38 +00:00
blizzard%redhat.com
0c074d2a55 remove debugging spew
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@53086 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-10 19:35:01 +00:00
blizzard%redhat.com
7d47d3aace make sure to send focus in and focus out events properly when giving focus to a superwin.
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@53085 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-10 19:31:50 +00:00
blizzard%redhat.com
4d1a2e8639 merge the license whackage
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@53020 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-09 23:06:12 +00:00
blizzard%redhat.com
8b6d035f17 add focus support
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@53016 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-09 22:53:26 +00:00
blizzard%redhat.com
4d22490af1 fix warnings due to passing bad data to the debug code
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@53008 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-09 19:48:03 +00:00
blizzard%redhat.com
4a1d8f7401 fix bogus warnings for gtk_signal_emit_stop_by_name
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52997 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-09 17:20:22 +00:00
blizzard%redhat.com
3ed82d86a0 add nsWindow::SetCursor
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52996 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-09 17:10:22 +00:00
blizzard%redhat.com
e763644046 fix background colors on windows
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52995 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-09 17:03:43 +00:00
blizzard%redhat.com
e94c0535d1 add hacks for superwin
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52971 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-08 22:56:27 +00:00
blizzard%redhat.com
201eebe4ec add mozbox code
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52965 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-08 22:34:41 +00:00
blizzard%redhat.com
91802fc4cb add superwin code for mozbox
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52964 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-08 22:34:22 +00:00
pavlov%netscape.com
68a592d45f fix debugging stuff like flashing, etc
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52963 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-08 22:32:36 +00:00
blizzard%redhat.com
60c89eba4b export our gtk header files. we'll need them for embedding.
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52953 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-08 21:52:35 +00:00
blizzard%redhat.com
ceecd95095 make sure that the child window uses the same destroy as the nsWindow class
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52950 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-08 21:40:54 +00:00
blizzard%redhat.com
220151a643 assert if we get passed bad data. this is for testing.
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52944 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-08 16:11:10 +00:00
blizzard%redhat.com
35d00c2c83 only send resize events on windows that are toplevel or have been created with a native parent
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52930 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-07 19:31:15 +00:00
blizzard%redhat.com
dfccc12330 add nsWindow::SetBackgroundColor, fix a warning
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52923 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-06 20:39:28 +00:00
(no author)
3c0a628da5 This commit was manufactured by cvs2svn to create branch 'SUPERWIN'.
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52913 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-06 03:43:57 +00:00
blizzard%redhat.com
e67e916ea6 turn off the backing store for now
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52889 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-06 00:30:53 +00:00
blizzard%redhat.com
2312b5fc11 fix problems with using nsWindow::WidgetToScreen with toplevel windows
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52863 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 21:37:52 +00:00
blizzard%redhat.com
fcb064c579 turn on backing store for the bin_window
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52856 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 16:39:20 +00:00
blizzard%redhat.com
72255234ea add expose event compression
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52854 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 15:58:56 +00:00
blizzard%redhat.com
2cff6771cb never assign a mozarea to mMozArea unless you own it.
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52853 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 15:49:31 +00:00
pavlov%netscape.com
f16eb3c3d2 fix WidgetToScreen
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52850 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 06:05:37 +00:00
pavlov%netscape.com
cc5f4699b6 remove #ifdef GTK_FIXED crap. make USE_SUPERWIN default, and fix native system color stuff (to be in head soon)
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52845 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 05:45:52 +00:00
blizzard%redhat.com
8dbfb05c9f fix some refcounting problems with the superwin and mozarea
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52821 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 23:12:20 +00:00
blizzard%redhat.com
4f6c078a40 make sure to destroy the superwin when the object goes out of scope
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52806 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 21:51:50 +00:00
blizzard%redhat.com
f303b7b880 add queued drawing
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52803 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 21:16:21 +00:00
blizzard%redhat.com
d5d532bbdf make rollup events work.
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52801 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 20:33:34 +00:00
blizzard%redhat.com
1e9545d94e scrolling added
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52797 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 20:06:53 +00:00
blizzard%redhat.com
bbaf2a8966 implement nsWindow::Resize and nsWindow::Move methods
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52772 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 03:25:04 +00:00
blizzard%redhat.com
4979b2734e first pass at getting superwin code to build. it will run now but doesn't have nsWindow::Move and nsWindow::Resize implemented...
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52747 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 23:07:52 +00:00
blizzard%redhat.com
0ba4ab32b2 fix some indenting issues
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52724 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 20:10:28 +00:00
blizzard%redhat.com
53df453f1a add gdk event handler
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52722 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 19:47:14 +00:00
blizzard%redhat.com
db90d4ddcf start adding glue code for events for the superwin and mozbox code. also, add the box and superwin as class members.
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52721 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 18:58:37 +00:00
blizzard%redhat.com
24a4aec113 change all of the debugging calls to use GtkObject or GtkWidget
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52718 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 16:38:21 +00:00
blizzard%redhat.com
74599c2956 change all of the CreateNative calls to use GtkObject instead of GtkWidget
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52717 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 16:09:35 +00:00
(no author)
9b52dc355f This commit was manufactured by cvs2svn to create branch 'SUPERWIN'.
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52698 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 07:34:51 +00:00
blizzard%redhat.com
1792ff0e46 start on the branch to get the superwin code to build.
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52591 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-02 22:21:47 +00:00
(no author)
fb08d16e05 This commit was manufactured by cvs2svn to create branch 'SUPERWIN'.
git-svn-id: svn://10.0.0.236/branches/SUPERWIN@52461 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-02 01:25:01 +00:00
148 changed files with 19303 additions and 4681 deletions

View File

@@ -0,0 +1,197 @@
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = public
PROGRAM = viewer
CPPSRCS = \
$(TOOLKIT_CPPSRCS) \
nsBaseDialog.cpp \
nsFindDialog.cpp \
nsXPBaseWindow.cpp \
nsTableInspectorDialog.cpp \
nsImageInspectorDialog.cpp \
nsPrintSetupDialog.cpp \
nsBrowserWindow.cpp \
nsEditorMode.cpp \
nsSetupRegistry.cpp \
nsThrobber.cpp \
nsViewerApp.cpp \
nsWebCrawler.cpp \
$(NULL)
EXPORT_RESOURCE_SAMPLES := \
$(wildcard $(srcdir)/samples/test*.html) \
$(wildcard $(srcdir)/samples/toolbarTest*.xul) \
$(wildcard $(srcdir)/samples/treeTest*.xul) \
$(wildcard $(srcdir)/samples/treeTest*.css) \
$(wildcard $(srcdir)/samples/slider*.xul) \
$(wildcard $(srcdir)/samples/scrollbar*.xul) \
$(srcdir)/resources/find.html \
$(srcdir)/resources/printsetup.html \
$(srcdir)/resources/image_props.html \
$(srcdir)/samples/aform.css \
$(srcdir)/samples/bform.css \
$(srcdir)/samples/cform.css \
$(srcdir)/samples/demoform.css \
$(srcdir)/samples/mozform.css \
$(srcdir)/samples/xulTest.css \
$(srcdir)/samples/Anieyes.gif \
$(srcdir)/samples/gear1.gif \
$(srcdir)/samples/rock_gra.gif \
$(srcdir)/samples/beeptest.html \
$(srcdir)/samples/soundtest.html \
$(srcdir)/samples/bg.jpg \
$(srcdir)/samples/raptor.jpg \
$(srcdir)/samples/test.wav \
$(srcdir)/samples/checkboxTest.xul \
$(NULL)
EXPORT_RESOURCE_THROBBER := $(wildcard $(srcdir)/throbber/anim*.gif)
ifeq (,$(filter beos os2 rhapsody photon,$(MOZ_WIDGET_TOOLKIT)))
DIRS += unix
UNIX_VIEWER_TK_LIBS = $(DIST)/lib/libviewer_$(MOZ_WIDGET_TOOLKIT)_s.a
else
ifeq ($(MOZ_WIDGET_TOOLKIT),beos)
BEOS_PROGRAM_RESOURCE = $(srcdir)/viewer-beos.rsrc
TOOLKIT_CPPSRCS = nsBeOSMain.cpp
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),photon)
TOOLKIT_CPPSRCS = nsPhMain.cpp nsPhMenu.cpp
endif
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk)
GTK_GLUE = -lgtksuperwin
endif
ifdef MOZ_OJI
JSJ_LIB = -ljsj
endif
XP_DIST_LIBS = \
-lraptorgfx \
-lmozjs \
-lxpcom \
$(JSJ_LIB) \
$(NULL)
XP_NS_UNDERBAR_CRAP = \
$(MOZ_NECKO_UTIL_LIBS) \
$(MOZ_TIMER_LIBS) \
$(MOZ_WIDGET_SUPPORT_LIBS) \
$(NULL)
XP_LIBS = \
$(XP_NS_UNDERBAR_CRAP) \
$(XP_DIST_LIBS) \
$(NSPR_LIBS) \
$(NULL)
ifdef MOZ_FULLCIRCLE
XP_LIBS += $(FULLCIRCLE_LIBS)
endif
LIBS = \
$(UNIX_VIEWER_TK_LIBS) \
$(GTK_GLUE) \
$(XP_LIBS) \
$(TK_LIBS) \
$(NULL)
MOTIF_LIBS = -lviewer_motif_s $(XP_LIBS) $(MOZ_MOTIF_LDFLAGS)
QT_LIBS = -lviewer_qt_s $(XP_LIBS) $(MOZ_QT_LDFLAGS)
XLIB_LIBS = -lviewer_xlib_s $(XP_LIBS) $(MOZ_XLIB_LDFLAGS)
GTK_LIBS = -lviewer_gtk_s -lgtksuperwin $(XP_LIBS) $(MOZ_GTK_LDFLAGS)
EXTRA_DEPS = \
$(addprefix $(DIST)/,$(patsubst -l%,bin/lib%.$(DLL_SUFFIX),$(XP_DIST_LIBS:-l%_s=lib/lib%_s.a))) \
$(UNIX_VIEWER_TK_LIBS) \
$(XP_NS_UNDERBAR_CRAP) \
$(NULL)
include $(topsrcdir)/config/rules.mk
CXXFLAGS += $(MOZ_TOOLKIT_REGISTRY_CFLAGS)
install:: $(PROGRAM) $(srcdir)/mozilla-viewer.sh
$(INSTALL) $(EXPORT_RESOURCE_SAMPLES) $(DIST)/bin/res/samples
$(INSTALL) $(EXPORT_RESOURCE_THROBBER) $(DIST)/bin/res/throbber
$(INSTALL) $(srcdir)/resources/viewer.properties $(DIST)/bin/res
$(INSTALL) $(srcdir)/mozilla-viewer.sh $(DIST)/bin
$(PROGRAM)_gtk: $(PROGOBJS) $(EXTRA_DEPS) Makefile Makefile.in $(DIST)/lib/libviewer_gtk_s.a
$(CCC) -o $@ $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(GTK_LIBS) $(OS_LIBS)
$(MOZ_POST_PROGRAM_COMMAND) $@
$(PROGRAM)_motif: $(PROGOBJS) $(EXTRA_DEPS) Makefile Makefile.in $(DIST)/lib/libviewer_motif_s.a
$(CCC) -o $@ $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(MOTIF_LIBS) $(OS_LIBS)
$(MOZ_POST_PROGRAM_COMMAND) $@
$(PROGRAM)_qt: $(PROGOBJS) $(EXTRA_DEPS) Makefile Makefile.in $(DIST)/lib/libviewer_qt_s.a
$(CCC) -o $@ $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(QT_LIBS) $(OS_LIBS)
$(MOZ_POST_PROGRAM_COMMAND) $@
$(PROGRAM)_xlib: $(PROGOBJS) $(EXTRA_DEPS) Makefile Makefile.in $(DIST)/lib/libviewer_xlib_s.a
$(CCC) -o $@ $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(XLIB_LIBS) $(OS_LIBS)
$(MOZ_POST_PROGRAM_COMMAND) $@
ifdef MOZ_ENABLE_GTK
install:: $(PROGRAM)_gtk
$(INSTALL) -m 555 $< $(DIST)/bin
clobber::
rm -f $(PROGRAM)_gtk
endif
ifdef MOZ_ENABLE_MOTIF
install:: $(PROGRAM)_motif
$(INSTALL) -m 555 $< $(DIST)/bin
clobber::
rm -f $(PROGRAM)_motif
endif
ifdef MOZ_ENABLE_QT
install:: $(PROGRAM)_qt
$(INSTALL) -m 555 $< $(DIST)/bin
clobber::
rm -f $(PROGRAM)_qt
endif
ifdef MOZ_ENABLE_XLIB
install:: $(PROGRAM)_xlib
$(INSTALL) -m 555 $< $(DIST)/bin
clobber::
rm -f $(PROGRAM)_xlib
endif

View File

@@ -0,0 +1,179 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include <gtk/gtk.h>
#include "gdksuperwin.h"
#include "gtkmozbox.h"
#include "nsBrowserWindow.h"
#include "resources.h"
#include "nscore.h"
#include "stdio.h"
typedef GtkItemFactoryCallback GIFC;
void gtk_ifactory_cb (nsBrowserWindow *nbw,
guint callback_action,
GtkWidget *widget)
{
nbw->DispatchMenuItem(callback_action);
}
GtkItemFactoryEntry menu_items[] =
{
{ "/_File", nsnull, nsnull, 0, "<Branch>" },
{ "/File/_New Window", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_WINDOW_OPEN, nsnull },
{ "/File/_Open...", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_FILE_OPEN, nsnull },
{ "/File/_View Source", nsnull, (GIFC)gtk_ifactory_cb, VIEW_SOURCE, nsnull },
{ "/File/_Samples", nsnull, nsnull, 0, "<Branch>" },
{ "/File/Samples/demo #0", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO0, nsnull },
{ "/File/Samples/demo #1", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO1, nsnull },
{ "/File/Samples/demo #2", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO2, nsnull },
{ "/File/Samples/demo #3", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO3, nsnull },
{ "/File/Samples/demo #4", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO4, nsnull },
{ "/File/Samples/demo #5", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO5, nsnull },
{ "/File/Samples/demo #6", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO6, nsnull },
{ "/File/Samples/demo #7", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO7, nsnull },
{ "/File/Samples/demo #8", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO8, nsnull },
{ "/File/Samples/demo #9", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO9, nsnull },
{ "/File/Samples/demo #10", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO10, nsnull },
{ "/File/Samples/demo #11", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO11, nsnull },
{ "/File/Samples/demo #12", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO12, nsnull },
{ "/File/Samples/demo #13", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO13, nsnull },
{ "/File/Samples/demo #14", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO14, nsnull },
{ "/File/Samples/demo #15", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO15, nsnull },
{ "/File/Samples/demo #16", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO16, nsnull },
{ "/File/Samples/demo #17", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO17, nsnull },
{ "/File/_Test Sites", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_TOP100, nsnull },
{ "/File/XPToolkit Tests", nsnull, nsnull, 0, "<Branch>" },
{ "/File/XPToolkit Tests/Toolbar Test 1", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_XPTOOLKITTOOLBAR1, nsnull },
{ "/File/XPToolkit Tests/Tree Test 1", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_XPTOOLKITTREE1, nsnull },
{ "/File/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/File/Print Preview", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_ONE_COLUMN, nsnull },
{ "/File/Print", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_PRINT, nsnull },
{ "/File/Print Setup", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_PRINT_SETUP, nsnull },
{ "/File/sep2", nsnull, nsnull, 0, "<Separator>" },
{ "/File/_Exit", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_EXIT, nsnull },
{ "/_Edit", nsnull, nsnull, 0, "<Branch>" },
{ "/Edit/Cu_t", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_EDIT_CUT, nsnull },
{ "/Edit/_Copy", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_EDIT_COPY, nsnull },
{ "/Edit/_Paste", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_EDIT_PASTE, nsnull },
{ "/Edit/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/Edit/Select All", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_EDIT_SELECTALL, nsnull },
{ "/Edit/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/Edit/Find in Page", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_EDIT_FINDINPAGE, nsnull },
//#ifdef DEBUG // turning off for now
{ "/_Debug", nsnull, nsnull, 0, "<Branch>" },
{ "/Debug/_Visual Debugging", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_VISUAL_DEBUGGING,nsnull },
{ "/Debug/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/Debug/Event Debugging/Toggle Paint Flashing", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_TOGGLE_PAINT_FLASHING,nsnull },
{ "/Debug/Event Debugging/Toggle Paint Dumping", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_TOGGLE_PAINT_DUMPING,nsnull },
{ "/Debug/Event Debugging/Toggle Invalidate Dumping", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_TOGGLE_INVALIDATE_DUMPING,nsnull },
{ "/Debug/Event Debugging/Toggle Event Dumping", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_TOGGLE_EVENT_DUMPING,nsnull },
{ "/Debug/Event Debugging/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/Debug/Event Debugging/Toggle Motion Event Dumping", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_TOGGLE_MOTION_EVENT_DUMPING,nsnull },
{ "/Debug/Event Debugging/Toggle Crossing Event Dumping", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_TOGGLE_CROSSING_EVENT_DUMPING,nsnull },
{ "/Debug/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/Debug/_Reflow Test", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_REFLOW_TEST, nsnull },
{ "/Debug/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/Debug/Dump _Content", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DUMP_CONTENT, nsnull },
{ "/Debug/Dump _Frames", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DUMP_FRAMES, nsnull },
{ "/Debug/Dump _Views", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DUMP_VIEWS, nsnull },
{ "/Debug/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/Debug/Dump _Style Sheets", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DUMP_STYLE_SHEETS, nsnull },
{ "/Debug/Dump _Style Contexts", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DUMP_STYLE_CONTEXTS, nsnull},
{ "/Debug/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/Debug/Show Content Size", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SHOW_CONTENT_SIZE,nsnull },
{ "/Debug/Show Frame Size", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SHOW_FRAME_SIZE, nsnull },
{ "/Debug/Show Style Size", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SHOW_STYLE_SIZE, nsnull },
{ "/Debug/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/Debug/Debug Save", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEBUGSAVE, nsnull },
{ "/Debug/Debug Output Text", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DISPLAYTEXT, nsnull },
{ "/Debug/Debug Output HTML", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DISPLAYHTML, nsnull },
{ "/Debug/Debug Toggle Selection", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_TOGGLE_SELECTION,nsnull },
{ "/Debug/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/Debug/Debug Robot", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEBUGROBOT, nsnull },
{ "/Debug/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/Debug/Show Content Quality", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SHOW_CONTENT_QUALITY, nsnull },
{ "/_Style", nsnull, nsnull, 0, "<Branch>" },
{ "/Style/Select _Style Sheet", nsnull, nsnull, 0, "<Branch>" },
{ "/Style/Select Style Sheet/List Available Sheets", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SELECT_STYLE_LIST, nsnull },
{ "/Style/Select Style Sheet/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/Style/Select Style Sheet/Select Default", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SELECT_STYLE_DEFAULT, nsnull },
{ "/Style/Select Style Sheet/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/Style/Select Style Sheet/Select Alternative 1", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SELECT_STYLE_ONE, nsnull },
{ "/Style/Select Style Sheet/Select Alternative 2", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SELECT_STYLE_TWO, nsnull },
{ "/Style/Select Style Sheet/Select Alternative 3", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SELECT_STYLE_THREE, nsnull },
{ "/Style/Select Style Sheet/Select Alternative 4", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SELECT_STYLE_FOUR, nsnull },
{ "/Style/_Compatibility Mode", nsnull, nsnull, 0, "<Branch>" },
{ "/Style/Compatibility Mode/Nav Quirks", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_NAV_QUIRKS_MODE, nsnull },
{ "/Style/Compatibility Mode/Standard", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_STANDARD_MODE, nsnull },
{ "/Style/_Widget Render Mode", nsnull, nsnull, 0, "<Branch>" },
{ "/Style/Widget Render Mode/Native", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_NATIVE_WIDGET_MODE, nsnull },
{ "/Style/Widget Render Mode/Gfx", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_GFX_WIDGET_MODE, nsnull },
//#endif
{ "/_Tools", nsnull, nsnull, 0, "<Branch>" },
{ "/Tools/_JavaScript Console", nsnull, (GIFC)gtk_ifactory_cb, JS_CONSOLE, nsnull },
{ "/Tools/_Editor Mode", nsnull, (GIFC)gtk_ifactory_cb, EDITOR_MODE, nsnull }
};
void CreateViewerMenus(nsIWidget * aParent,
gpointer data,
GtkWidget ** aMenuBarOut)
{
NS_ASSERTION(nsnull != aParent,"null parent.");
NS_ASSERTION(nsnull != aMenuBarOut,"null out param.");
GtkItemFactory *item_factory;
GtkWidget *menubar;
GdkSuperWin *gdkSuperWin;
GtkWidget *mozBox;
gdkSuperWin = (GdkSuperWin*)aParent->GetNativeData(NS_NATIVE_WIDGET);
int nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]);
item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", nsnull);
gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, data);
menubar = gtk_item_factory_get_widget (item_factory, "<main>");
gtk_menu_bar_set_shadow_type (GTK_MENU_BAR(menubar), GTK_SHADOW_NONE);
NS_ASSERTION(GDK_IS_SUPERWIN(gdkSuperWin), "code assumes a gdksuperwin.");
mozBox = gtk_mozbox_new(gdkSuperWin->bin_window);
NS_ASSERTION((mozBox != NULL), "failed to create mozBox.");
gtk_container_add(GTK_CONTAINER(mozBox), menubar);
gtk_mozbox_set_position(GTK_MOZBOX(mozBox), 0, 0 );
gtk_widget_show(mozBox);
gtk_widget_show(menubar);
*aMenuBarOut = menubar;
}

View File

@@ -1,5 +0,0 @@
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>

View File

@@ -1,25 +0,0 @@
SERVER REQUIREMENTS
- Apache 1.3 or higher with mod_rewrite enabled
- PHP 4.3.2 or higher
- CakePHP 1.1.7.3363 or higher
- MySQL (preferred) or PostgreSQL
INSTALLATION:
- All files accompanying this README should be placed into the /app directory of
your CakePHP install. Once complete, you should have a directory structure similar
to the following where (/) is the base of your domain:
/
app/
config/
controllers/
models/
webroot/
...
cake/
vendors/
- Import the database schema (/app/config/dist.sql) into your database
- Rename database.dist.php to database.php and edit the file to reflect your
database configuration
- Rename bootstrap.dist.php to bootstrap.php and follow the editing instructions
within. All fields except APP_* and MAX_YEAR are optional.

View File

@@ -1,4 +0,0 @@
<?php
class AppController extends Controller {
}
?>

View File

@@ -1,4 +0,0 @@
<?php
class AppModel extends Model {
}
?>

View File

@@ -1,76 +0,0 @@
;<?php die() ?>
; SVN FILE: $Id: acl.ini.php,v 1.3 2006-10-08 03:39:21 reed%reedloden.com Exp $
;/**
; * Short description for file.
; *
; *
; * PHP versions 4 and 5
; *
; * CakePHP : Rapid Development Framework <http://www.cakephp.org/>
; * Copyright (c) 2006, Cake Software Foundation, Inc.
; * 1785 E. Sahara Avenue, Suite 490-204
; * Las Vegas, Nevada 89104
; *
; * Licensed under The MIT License
; * Redistributions of files must retain the above copyright notice.
; *
; * @filesource
; * @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
; * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
; * @package cake
; * @subpackage cake.app.config
; * @since CakePHP v 0.10.0.1076
; * @version $Revision: 1.3 $
; * @modifiedby $LastChangedBy: phpnut $
; * @lastmodified $Date: 2006-10-08 03:39:21 $
; * @license http://www.opensource.org/licenses/mit-license.php The MIT License
; */
; acl.ini.php - Cake ACL Configuration
; ---------------------------------------------------------------------
; Use this file to specify user permissions.
; aco = access control object (something in your application)
; aro = access request object (something requesting access)
;
; User records are added as follows:
;
; [uid]
; groups = group1, group2, group3
; allow = aco1, aco2, aco3
; deny = aco4, aco5, aco6
;
; Group records are added in a similar manner:
;
; [gid]
; allow = aco1, aco2, aco3
; deny = aco4, aco5, aco6
;
; The allow, deny, and groups sections are all optional.
; NOTE: groups names *cannot* ever be the same as usernames!
;
; ACL permissions are checked in the following order:
; 1. Check for user denies (and DENY if specified)
; 2. Check for user allows (and ALLOW if specified)
; 3. Gather user's groups
; 4. Check group denies (and DENY if specified)
; 5. Check group allows (and ALLOW if specified)
; 6. If no aro, aco, or group information is found, DENY
;
; ---------------------------------------------------------------------
;-------------------------------------
;Users
;-------------------------------------
[username-goes-here]
groups = group1, group2
deny = aco1, aco2
allow = aco3, aco4
;-------------------------------------
;Groups
;-------------------------------------
[groupname-goes-here]
deny = aco5, aco6
allow = aco7, aco8

View File

@@ -1,32 +0,0 @@
<?php
/* REQUIRED - APP_NAME is used on all <title>s and mail names/subjects. APP_BASE
* should be a FQDN with protocol minus the trailing slash e.g. http://example.tld/party
*/
define('APP_NAME', '');
define('APP_EMAIL', '');
define('APP_BASE', '');
/* You should specify a Google Map API key here. Without it, all mapping features
* will be disabled. To obtain a key, visit http://www.google.com/apis/maps/
*/
define('GMAP_API_KEY', '');
/* The search API key is used to generate spelling suggestions for locations not
* not found during a Geocode operation. You may obtain a key here: http://code.google.com/apis/soapsearch/
*/
define('GSEARCH_API_KEY', '');
/* The maximum year shown for party registrations */
define('MAX_YEAR', 2007);
/* The Flickr API is used to show photos of each party on the individual party
* pages and home page. See http://flickr.com/services/api/keys/ to obtain a key
*/
define('FLICKR_API_KEY', '');
/* The tag prefix is used to limit the results returned to a specific party.
* e.g. any photo tagged with FirefoxParty11 will be shown on party 11's page.
* Photos tagged with only the prefix are shown on the front page (so choose wisely! ;) ).
*/
define('FLICKR_TAG_PREFIX', '');
?>

View File

@@ -1,147 +0,0 @@
<?php
/* SVN FILE: $Id: core.php,v 1.4 2006-10-08 03:39:21 reed%reedloden.com Exp $ */
/**
* This is core configuration file.
*
* Use it to configure core behaviour ofCake.
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2006, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.app.config
* @since CakePHP v 0.2.9
* @version $Revision: 1.4 $
* @modifiedby $LastChangedBy: phpnut $
* @lastmodified $Date: 2006-10-08 03:39:21 $
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* If you do not have mod rewrite on your system
* or if you prefer to use CakePHP pretty urls.
* uncomment the line below.
* Note: If you do have mod rewrite but prefer the
* CakePHP pretty urls, you also have to remove the
* .htaccess files
* release/.htaccess
* release/app/.htaccess
* release/app/webroot/.htaccess
*/
// define ('BASE_URL', env('SCRIPT_NAME'));
/**
* Set debug level here:
* - 0: production
* - 1: development
* - 2: full debug with sql
* - 3: full debug with sql and dump of the current object
*
* In production, the "flash messages" redirect after a time interval.
* With the other debug levels you get to click the "flash message" to continue.
*
*/
define('DEBUG', 0);
/**
* Turn of caching checking wide.
* You must still use the controller var cacheAction inside you controller class.
* You can either set it controller wide, or in each controller method.
* use var $cacheAction = true; or in the controller method $this->cacheAction = true;
*/
define('CACHE_CHECK', false);
/**
* Error constant. Used for differentiating error logging and debugging.
* Currently PHP supports LOG_DEBUG
*/
define('LOG_ERROR', 2);
/**
* CakePHP includes 3 types of session saves
* database or file. Set this to your preferred method.
* If you want to use your own save handler place it in
* app/config/name.php DO NOT USE file or database as the name.
* and use just the name portion below.
*
* Setting this to cake will save files to /cakedistro/tmp directory
* Setting it to php will use the php default save path
* Setting it to database will use the database
*
*
*/
define('CAKE_SESSION_SAVE', 'database');
/**
* If using you own table name for storing sessions
* set the table name here.
* DO NOT INCLUDE PREFIX IF YOU HAVE SET ONE IN database.php
*
*/
define('CAKE_SESSION_TABLE', 'sessions');
/**
* Set a random string of used in session.
*
*/
define('CAKE_SESSION_STRING', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi');
/**
* Set the name of session cookie
*
*/
define('CAKE_SESSION_COOKIE', 'sess');
/**
* Set level of Cake security.
*
*/
define('CAKE_SECURITY', 'high');
/**
* Set Cake Session time out.
* If CAKE_SECURITY define is set
* high: multiplied by 10
* medium: is multiplied by 100
* low is: multiplied by 300
*
* Number below is seconds.
*/
define('CAKE_SESSION_TIMEOUT', '120');
/**
* Uncomment the define below to use cake built in admin routes.
* You can set this value to anything you want.
* All methods related to the admin route should be prefixed with the
* name you set CAKE_ADMIN to.
* For example: admin_index, admin_edit
*/
// define('CAKE_ADMIN', 'admin');
/**
* The define below is used to turn cake built webservices
* on or off. Default setting is off.
*/
define('WEBSERVICES', 'off');
/**
* Compress output CSS (removing comments, whitespace, repeating tags etc.)
* This requires a/var/cache directory to be writable by the web server (caching).
* To use, prefix the CSS link URL with '/ccss/' instead of '/css/' or use Controller::cssTag().
*/
define('COMPRESS_CSS', false);
/**
* If set to true, helpers would output data instead of returning it.
*/
define('AUTO_OUTPUT', false);
/**
* If set to false, session would not automatically be started.
*/
define('AUTO_SESSION', true);
/**
* Set the max size of file to use md5() .
*/
define('MAX_MD5SIZE', (5 * 1024) * 1024);
/**
* To use Access Control Lists with Cake...
*/
define('ACL_CLASSNAME', 'DB_ACL');
define('ACL_FILENAME', 'dbacl' . DS . 'db_acl');
?>

View File

@@ -1,11 +0,0 @@
<?php
class DATABASE_CONFIG {
var $default = array('driver' => 'mysql',
'connect' => 'mysql_connect',
'host' => 'localhost',
'login' => '',
'password' => '',
'database' => '');
}
?>

View File

@@ -1,72 +0,0 @@
<?php
/* SVN FILE: $Id: inflections.php,v 1.3 2006-10-08 03:39:21 reed%reedloden.com Exp $ */
/**
* Custom Inflected Words.
*
* This file is used to hold words that are not matched in the normail Inflector::pluralize() and
* Inflector::singularize()
*
* PHP versions 4 and %
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2006, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.app.config
* @since CakePHP v 1.0.0.2312
* @version $Revision: 1.3 $
* @modifiedby $LastChangedBy: phpnut $
* @lastmodified $Date: 2006-10-08 03:39:21 $
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* This is a key => value array of regex used to match words.
* If key matches then the value is returned.
*
* $pluralRules = array('/(s)tatus$/i' => '\1\2tatuses', '/^(ox)$/i' => '\1\2en', '/([m|l])ouse$/i' => '\1ice');
*/
$pluralRules = array();
/**
* This is a key only array of plural words that should not be inflected.
* Notice the last comma
*
* $uninflectedPlural = array('.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox');
*/
$uninflectedPlural = array();
/**
* This is a key => value array of plural irregular words.
* If key matches then the value is returned.
*
* $irregularPlural = array('atlas' => 'atlases', 'beef' => 'beefs', 'brother' => 'brothers')
*/
$irregularPlural = array();
/**
* This is a key => value array of regex used to match words.
* If key matches then the value is returned.
*
* $singularRules = array('/(s)tatuses$/i' => '\1\2tatus', '/(matr)ices$/i' =>'\1ix','/(vert|ind)ices$/i')
*/
$singularRules = array();
/**
* This is a key only array of singular words that should not be inflected.
* You should not have to change this value below if you do change it use same format
* as the $uninflectedPlural above.
*/
$uninflectedSingular = $uninflectedPlural;
/**
* This is a key => value array of singular irregular words.
* Most of the time this will be a reverse of the above $irregularPlural array
* You should not have to change this value below if you do change it use same format
*
* $irregularSingular = array('atlases' => 'atlas', 'beefs' => 'beef', 'brothers' => 'brother')
*/
$irregularSingular = array_flip($irregularPlural);
?>

View File

@@ -1,43 +0,0 @@
<?php
/* SVN FILE: $Id: routes.php,v 1.5 2006-10-10 20:18:59 reed%reedloden.com Exp $ */
/**
* Short description for file.
*
* In this file, you set up routes to your controllers and their actions.
* Routes are very important mechanism that allows you to freely connect
* different urls to chosen controllers and their actions (functions).
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2006, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.app.config
* @since CakePHP v 0.2.9
* @version $Revision: 1.5 $
* @modifiedby $LastChangedBy: phpnut $
* @lastmodified $Date: 2006-10-10 20:18:59 $
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Here, we are connecting '/' (base path) to controller called 'Pages',
* its action called 'display', and we pass a param to select the view file
* to use (in this case, /app/views/pages/home.thtml)...
*/
$Route->connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
/**
* ...and connect the rest of 'Pages' controller's urls.
*/
$Route->connect('/pages/edit', array('controller' => 'pages', 'action' => 'edit'));
$Route->connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
$Route->connect('/privacy-policy', array('controller' => 'pages', 'action' => 'privacy'));
?>

View File

@@ -1,80 +0,0 @@
CREATE TABLE `comments` (
`id` int(10) NOT NULL auto_increment,
`assoc` int(10) NOT NULL default '0',
`owner` int(10) NOT NULL default '0',
`time` int(15) NOT NULL default '0',
`text` text collate utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `guests` (
`id` int(10) NOT NULL auto_increment,
`pid` int(10) NOT NULL default '0',
`uid` int(10) NOT NULL default '0',
`invited` tinyint(1) NOT NULL default '1',
PRIMARY KEY (`id`),
KEY `pid` (`pid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `pages` (
`id` int(10) NOT NULL auto_increment,
`text` text collate utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO `pages` (`id`, `text`) VALUES (1, '&lt;h2&gt;Join the Fun!&lt;/h2&gt;\n&lt;p&gt;All over the world, we&#39;re celebrating the launch of Firefox 2. Join the fun by hosting or attending a party. We&#39;re targeting the weekend of October 27th for the shared celebration, but if you&#39;re hosting, you make the call.&lt;/p&gt;\n\n&lt;p&gt;To join the fun, &lt;a href=&quot;/users/register&quot;&gt;register&lt;/a&gt; for a Firefox Party account, and sign up to host or attend.&lt;/p&gt;\n\n&lt;p style=&quot;border: 1px solid #555; background: #faffd4; padding: 5px; font&#45;weight: bold&quot;&gt;Be one of the first 50 party hosts registered and get three extra launch exclusive t&#45;shirts with your purchase of the &lt;a href=&quot;&quot;&gt;Firefox 2 Party Pack&lt;/a&gt;. We&#39;re selling the party packs and shirts at cost, so it&#39;s a great deal, and for parties with unusually large attendance, we&#39;ll be sending out additional swag for door prizes and other give&#45;aways. Stay tuned for updates!&lt;/p&gt;');
INSERT INTO `pages` (`id`, `text`) VALUES (2, '1162007940');
CREATE TABLE `parties` (
`id` int(10) NOT NULL auto_increment,
`owner` int(10) NOT NULL default '0',
`name` tinytext collate utf8_unicode_ci NOT NULL,
`vname` tinytext collate utf8_unicode_ci NOT NULL,
`address` tinytext collate utf8_unicode_ci NOT NULL,
`tz` int(2) NOT NULL default '0',
`website` text collate utf8_unicode_ci NOT NULL,
`notes` text collate utf8_unicode_ci NOT NULL,
`date` int(10) NOT NULL default '0',
`duration` tinyint(2) NOT NULL default '2',
`confirmed` tinyint(1) NOT NULL default '1',
`canceled` tinyint(1) NOT NULL default '0',
`guestcomments` tinyint(1) NOT NULL default '0',
`inviteonly` tinyint(1) NOT NULL default '0',
`invitecode` tinytext collate utf8_unicode_ci NOT NULL,
`lat` float NOT NULL default '0',
`long` float NOT NULL default '0',
`zoom` tinyint(2) NOT NULL default '1',
`useflickr` tinyint(1) NOT NULL default '0',
`flickrperms` tinyint(1) NOT NULL default '0',
`flickrid` tinytext collate utf8_unicode_ci NOT NULL,
`flickrusr` tinytext collate utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `sessions` (
`id` varchar(255) character set latin1 NOT NULL default '',
`data` text character set latin1,
`expires` int(11) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `users` (
`id` int(10) NOT NULL auto_increment,
`role` tinyint(1) NOT NULL default '0',
`email` varchar(255) collate utf8_unicode_ci NOT NULL,
`active` varchar(10) collate utf8_unicode_ci NOT NULL default '0',
`password` varchar(75) collate utf8_unicode_ci NOT NULL default '',
`salt` varchar(9) collate utf8_unicode_ci NOT NULL default '',
`name` tinytext collate utf8_unicode_ci NOT NULL,
`location` tinytext collate utf8_unicode_ci NOT NULL,
`tz` tinyint(2) NOT NULL default '0',
`website` text collate utf8_unicode_ci NOT NULL,
`lat` float NOT NULL default '0',
`long` float NOT NULL default '0',
`zoom` tinyint(2) NOT NULL default '1',
`showemail` tinyint(1) NOT NULL default '0',
`showloc` tinyint(1) NOT NULL default '1',
`showmap` tinyint(1) NOT NULL default '1',
UNIQUE KEY `email` (`email`),
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

View File

@@ -1,163 +0,0 @@
<?php
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Party Tool
*
* The Initial Developer of the Original Code is
* Ryan Flint <rflint@dslr.net>
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
uses('sanitize');
class AdminController extends AppController {
var $name = 'Admin';
var $uses = array('Party', 'User', 'Comment');
var $components = array('Unicode');
function beforeFilter() {
if (empty($_SESSION['User']) || $_SESSION['User']['role'] != 1) {
$this->redirect('/');
die();
}
}
function index() {
$this->set('parties', $this->Party->findAll(null, null, "id ASC"));
}
function users() {
$this->set('users', $this->User->findAll(null, null, "id ASC"));
}
function comments() {
$this->set('comments', $this->Comment->findAll(null, null, "id ASC"));
}
function edit($type, $id) {
if (empty($this->data)) {
switch($type) {
case 'user':
$this->User->id = $id;
$user = $this->User->read();
$this->set('user', $user);
$this->data = $user;
break;
case 'party':
$this->Party->id = $id;
$party = $this->Party->read();
$this->set('party', $party);
$this->data = $party;
$this->data['Party']['name'] = preg_replace("/&#(\d{2,5});/e",
'$this->Unicode->unicode2utf(${1})',
html_entity_decode($this->data['Party']['name']));
$this->data['Party']['vname'] = preg_replace("/&#(\d{2,5});/e",
'$this->Unicode->unicode2utf(${1})',
html_entity_decode($this->data['Party']['vname']));
$this->data['Party']['website'] = preg_replace("/&#(\d{2,5});/e",
'$this->Unicode->unicode2utf(${1})',
html_entity_decode($this->data['Party']['website']));
$this->data['Party']['address'] = preg_replace("/&#(\d{2,5});/e",
'$this->Unicode->unicode2utf(${1})',
html_entity_decode($this->data['Party']['address']));
$this->data['Party']['notes'] = preg_replace("/&#(\d{2,5});/e",
'$this->Unicode->unicode2utf(${1})',
html_entity_decode($this->data['Party']['notes']));
$this->data['Party']['flickrusr'] = preg_replace("/&#(\d{2,5});/e",
'$this->Unicode->unicode2utf(${1})',
html_entity_decode($this->data['Party']['flickrusr']));
break;
case 'comment':
$this->Comment->id = $id;
$comment = $this->Comment->read();
$this->set('comment', $comment);
$uid = $this->User->findById($comment['Comment']['owner']);
$this->set('owner', $uid['User']['name']);
$this->data = $comment;
break;
}
}
else {
switch($type) {
case 'user':
$this->User->id = $id;
$this->User->save($this->data);
break;
case 'party':
$this->Party->id = $id;
$clean = new Sanitize();
$clean->cleanArray($this->data);
$this->Party->save($this->data);
break;
case 'comment':
$this->Comment->id = $id;
$this->Comment->save($this->data);
break;
}
if ($type != 'party')
$this->redirect('/admin/'.$type.'s');
else
$this->redirect('/admin/');
}
}
function delete($type, $id) {
switch($type) {
case 'user':
$this->User->del($id);
$this->User->query("DELETE FROM guests WHERE uid = $id");
break;
case 'party':
$this->Party->del($id);
$this->Party->query("DELETE FROM guests WHERE pid = $id");
$this->Party->query("DELETE FROM comments WHERE assoc = $id");
break;
case 'comment':
$this->Comment->del($id);
break;
}
if ($type != 'party')
$this->redirect('/admin/'.$type.'s');
else
$this->redirect('/admin/');
}
}
?>

View File

@@ -1,71 +0,0 @@
<?php
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Party Tool
*
* The Initial Developer of the Original Code is
* Ryan Flint <rflint@dslr.net>
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
uses('sanitize');
class CommentsController extends AppController {
var $name = 'Comments';
var $components = array('Security');
function beforeFilter() {
$this->Security->requirePost('add');
}
function add($pid, $uid) {
if (!$this->Session->check('User') || $uid != $_SESSION['User']['id'])
$this->redirect('/');
if (!empty($this->data) && $this->Comment->canComment($pid, $uid)) {
// Explictly destroy the last model to avoid an edit instead of an insert
$this->Comment->create();
$clean = new Sanitize();
$text = $clean->html($this->data['Comment']['text']);
$this->data['Comment']['text'] = nl2br($text);
$this->data['Comment']['owner'] = $uid;
$this->data['Comment']['assoc'] = $pid;
$this->data['Comment']['time'] = mktime();
if ($this->Comment->save($this->data)) {
$this->redirect('/parties/view/'.$pid.'#c'.$this->Comment->getLastInsertID());
}
}
else
$this->redirect('/parties/view/'.$pid);
}
}
?>

View File

@@ -1,54 +0,0 @@
<?php
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Party Tool
*
* The Initial Developer of the Original Code is
* Ryan Flint <rflint@dslr.net>
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
class HashComponent extends Object {
function password($pass, $data) {
$string = $pass.uniqid(rand(), true).$data;
$salt = substr(md5($string), 0, 9);
$p = sha1($pass.$salt);
$rv = array('pass' => $p, 'salt' => $salt);
return $rv;
}
function keygen($chars) {
$key = null;
$pool = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
for ($i = 0; $i < $chars; $i++)
$key .= $pool{rand(0,61)};
return $key;
}
}

View File

@@ -1,83 +0,0 @@
<?php
class MailComponent extends Object {
var $from;
var $to;
var $reply;
var $subject;
var $message;
var $envelope;
var $head = "<strong>Firefox Party!</strong><br/>";
var $foot;
function mail($params) {
if (array_key_exists('from', $params))
$this->from = $params['from'];
if (array_key_exists('to', $params))
$this->to = $params['to'];
if (array_key_exists('reply', $params))
$this->reply = $params['reply'];
if (array_key_exists('subject', $params))
$this->subject = $params['subject'];
if (array_key_exists('message', $params))
$this->message = $params['message'];
if (array_key_exists('envelope', $params))
$this->envelope = $params['envelope'];
if (array_key_exists('type', $params)) {
switch($params['type']) {
case 'act':
$this->message = $this->head."<br/>\nThank you for registering! To activate your account, <a href=\"".$params['link']."\">click here</a> or paste the link below into your browser:<br/> ".$params['link'].$this->foot;
break;
case 'prec':
$this->message = $this->head."<br/>\nTo reset your password, <a href=\"".$params['link']."\">click here</a> or paste the link below into your browser:<br/> ".$params['link'].$this->foot;
break;
case 'invite':
$this->message = $this->head."<br/>\nYou've been invited by a friend to join them in celebrating the release of Firefox 2. Simply <a href=\"".$params['link']."\">click here</a> to confirm or cancel this invitation. If you don't already have an account, you'll need to create one.\n
If you're unable to use the link above, simply paste the following URL into your browser: ".$params['link'].$this->foot;
break;
case 'cancel':
$this->message = $this->head."<br/>\nThe party you were attending has been canceled. For more information, please <a href=\"".$params['link']."\">click here</a>, or see the link below.\n ".$params['link'].$this->foot;
break;
}
}
}
function make_headers($type='html') {
$headers = '';
switch($type) {
case 'html':
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
break;
}
if (!empty($this->from)) {
$headers .= "From: {$this->from}\r\n";
if (!empty($this->reply))
$headers .= "Reply-To: {$this->reply}\r\n";
}
return $headers;
}
function make_additional_parameters() {
if (!empty($this->envelope)) {
return '-f'.$this->envelope;
}
}
function send() {
mail($this->to, $this->subject, $this->message, $this->make_headers(), $this->make_additional_parameters());
}
}
?>

View File

@@ -1,75 +0,0 @@
<?php
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Party Tool
*
* The Initial Developer of the Original Code is
* Ryan Flint <rflint@dslr.net>
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
class UnicodeComponent extends Object {
/**
* Unicode utilities. Converts and encodes characters up to 0xFFFF (65535)
*/
function unicode2utf($char) {
if ($char < 128) {
$rv = chr($char);
}
else if ($char < 2048) {
$rv = chr(192 + (($char - ($char % 64)) / 64));
$rv .= chr(128 + ($char % 64));
}
else {
$rv = chr(224 + (($char - ($char % 4096)) / 4096));
$rv .= chr(128 + ((($char % 4096) - ($char % 64)) / 64));
$rv .= chr(128 + ($char % 64));
}
return $rv;
}
function utf2unicode($char) {
if (ord($char{0}) < 128)
$rv = ord($char);
else if (ord($char{0}) < 224)
$rv = ((ord($char{0}) - 192) * 64) + (ord($char{1}) - 128);
else if (ord($char{0}) < 240)
$rv = ((ord($char{0}) - 224) * 4096) + ((ord($char{1}) - 128) * 64 + (ord($char{2}) - 128));
else
$rv = ((ord($char{0}) - 240) * 262144) + ((ord($char{1}) - 128) * 4096) + ((ord($char{2}) - 128) * 64) + (ord($char{3}) - 128);
return $rv;
}
}

View File

@@ -1,143 +0,0 @@
<?php
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Party Tool
*
* The Initial Developer of the Original Code is
* Ryan Flint <rflint@dslr.net>
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
vendor('webServices');
class FeedsController extends AppController {
var $name = 'Feeds';
var $components = array('Unicode');
function index() {
header('Content-type: application/rss+xml');
$this->layout = 'ajax';
$this->set('count', $this->Feed->findCount());
}
function latest() {
header('Content-type: application/rss+xml');
$this->layout = 'ajax';
$this->set('latest', $this->Feed->findAll('', '', 'id DESC', 10, 1));
}
function users() {
header('Content-type: application/rss+xml');
$this->layout = 'ajax';
$this->set('count', $this->Feed->getUserCount());
}
function comments($id = null) {
$this->layout = 'ajax';
header('Content-type: application/rss+xml');
if (!is_numeric($id))
return;
$this->set('comments', $this->Feed->getComments($id));
$this->set('pid', $id);
}
function photos($id = null) {
$this->layout = 'ajax';
header('Content-type: application/atom+xml');
if (!is_numeric($id))
return;
$party = $this->Feed->findById($id);
$this->set('party', $party);
if (FLICKR_API_KEY != null && !$party['Feeds']['canceled']) {
if ($party['Feeds']['useflickr'] == 1) {
$data = array('type' => 'flickr', 'userid' => $party['Feeds']['flickrid'], 'randomize' => false);
$flickr = new webServices($data);
$photoset = $flickr->fetchPhotos(FLICKR_TAG_PREFIX.$id, 30, !$party['Feeds']['flickrperms']);
$this->set('flickr', $photoset);
}
}
}
function upcoming($limit = null) {
$this->layout = 'ajax';
header('Content-type: application/rss+xml');
($limit == null) ? $limit = 25 : $limit = intval($limit);
$this->set('latest', $this->Feed->findAll('WHERE date > '. time(), '', 'date ASC', $limit, 1));
}
function ical() {
$this->layout = 'ajax';
header('Content-type: text/calendar');
header("Content-Disposition: inline; filename=partylist.ics");
$back = time() - 172800;
$events = $this->Feed->findAll('WHERE date > '. $back, '', 'date ASC', null, 1);
$cal = array();
foreach($events as $event) {
$event['Feeds']['name'] =
preg_replace(array("/&#(\d{2,5});/e", "/(\n|\r|\f)/", "/\,/"),
array('$this->Unicode->unicode2utf(${1})', ' ', '\,'),
html_entity_decode($event['Feeds']['name']));
$event['Feeds']['address'] =
preg_replace(array("/&#(\d{2,5});/e", "/(\n|\r|\f)/", "/\,/"),
array('$this->Unicode->unicode2utf(${1})', ' ', '\,'),
html_entity_decode($event['Feeds']['address']));
$event['Feeds']['notes'] =
preg_replace(array("/&#(\d{2,5});/e", "/(\n|\r|\f)/", "/\,/"),
array('$this->Unicode->unicode2utf(${1})', ' ', '\,'),
html_entity_decode($event['Feeds']['notes']));
array_push($cal, $event);
}
$this->set('events', $cal);
}
function topguests($limit = null) {
$this->layout = 'ajax';
header('Content-type: application/rss+xml');
($limit == null) ? $limit = 25 : $limit = intval($limit);
$rv = $this->Feed->query("SELECT parties.name AS name,
guests.pid AS id,
COUNT(guests.pid) AS count
FROM guests
LEFT JOIN parties
ON guests.pid = parties.id
GROUP BY guests.pid
ORDER BY count DESC
LIMIT $limit");
$this->set('items', $rv);
}
}
?>

View File

@@ -1,92 +0,0 @@
<?php
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Party Tool
*
* The Initial Developer of the Original Code is
* Ryan Flint <rflint@dslr.net>
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
uses('sanitize');
class PagesController extends AppController {
var $name = 'Pages';
var $components = array('Unicode');
function display() {
$this->pageTitle = 'Home';
$this->set('current', 'home');
$this->set('pcount', $this->Page->findCount());
$this->set('ucount', $this->Page->getUsers());
$text = $this->Page->query('SELECT text FROM pages WHERE id = 1');
$time = $this->Page->query('SELECT text FROM pages WHERE id = 2');
$this->set('time', $time[0]['pages']['text']);
$this->set('front_text', preg_replace("/&#(\d{2,5});/e",
'$this->Unicode->unicode2utf(${1})',
html_entity_decode($text[0]['pages']['text'])));
}
function privacy() {
$this->pageTitle = 'Privacy Policy';
}
function edit() {
if (isset($_SESSION['User']['id']) && $_SESSION['User']['role'] == 1) {
if (empty($this->data)) {
$text = $this->Page->query('SELECT text FROM pages WHERE id = 1');
$time = $this->Page->query('SELECT text FROM pages WHERE id = 2');
$this->data['Pages']['text'] = preg_replace("/&#(\d{2,5});/e",
'$this->Unicode->unicode2utf(${1})',
html_entity_decode($text[0]['pages']['text']));
$this->set('selected', date('Y-m-d H:i:s', $time[0]['pages']['text']));
}
else {
// Paranoid? Nah...
if ($_SESSION['User']['role'] == 1) {
$clean = new Sanitize();
$clean->cleanArray($this->data);
$date = mktime($this->data['Pages']['date_hour'],
$this->data['Pages']['date_min'],
0,
$this->data['Pages']['date_month'],
$this->data['Pages']['date_day'],
$this->data['Pages']['date_year']);
$this->Page->execute('UPDATE pages SET text = "'.$this->data['Pages']['text'].'" WHERE pages.id = 1');
$this->Page->execute('UPDATE pages SET text = "'.$date.'" WHERE pages.id = 2');
$this->redirect('/');
}
}
}
else
die();
}
}
?>

View File

@@ -1,472 +0,0 @@
<?php
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Party Tool
*
* The Initial Developer of the Original Code is
* Ryan Flint <rflint@dslr.net>
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
uses('sanitize');
vendor('webServices');
class PartiesController extends AppController {
var $name = 'Parties';
var $uses = array('Party', 'Comment');
var $helpers = array('Html', 'Form');
var $components = array('Hash', 'Mail', 'Unicode');
function index() {
$this->pageTitle = 'Party Map';
$this->set('current', 'map');
if (!empty($this->data)) {
$gcoder = new webServices(array('type' => 'geocode'));
$loc = $gcoder->geocode($this->data['Party']['mloc']);
if ($loc)
$this->set('map', 'initMashUp('.$loc['lat'].', '.$loc['lng'].');');
else
$this->set('map', 'initMashUp();');
}
else
$this->set('map', 'initMashUp();');
}
function add() {
if (!$this->Session->check('User'))
$this->redirect('/users/login');
$this->pageTitle = 'Create Party';
$this->set('current', 'create');
$this->set('map', 'mapInit()');
if(empty($this->data)) {
$this->set('utz', $_SESSION['User']['tz']);
$this->render();
}
else {
$temp = array('lat' => $this->data['Party']['lat'],
'long' => $this->data['Party']['long'],
'tz' => $this->data['Party']['tz']);
$clean = new Sanitize();
$clean->cleanArray($this->data);
$this->data['Party']['lat'] = floatval($temp['lat']);
$this->data['Party']['long'] = floatval($temp['long']);
$this->data['Party']['tz'] = intval($temp['tz']);
$this->set('utz', $this->data['Party']['tz']);
// Convert the selected time to GMT
$secoffset = ($this->data['Party']['tz'] * 60 * 60);
$offsetdate = gmmktime($this->data['Party']['hour_hour'],
$this->data['Party']['minute_min'],
0,
$this->data['Party']['month_hour'],
$this->data['Party']['day_day'],
$this->data['Party']['year_year']);
$this->data['Party']['date'] = ($offsetdate + $secoffset);
$this->data['Party']['duration'] = intval($this->data['Party']['duration']);
$this->data['Party']['invitecode'] = $this->Hash->keygen(10);
$this->data['Party']['owner'] = $_SESSION['User']['id'];
if (!preg_match("/^(http|https)\:\/\//i", $this->data['Party']['website']) &&
!empty($this->data['Party']['website']))
$this->Party->invalidate('website');
if ($this->Party->validates($this->data)) {
if($this->Party->save($this->data)) {
$this->Session->setFlash('Your party has been created!', 'infoFlash');
$this->redirect('/parties/view/'.$this->Party->getLastInsertId());
}
}
else {
$this->Session->setFlash('Please correct the errors below.', 'errorFlash');
}
}
}
function edit($id) {
$this->Party->id = $id;
$party = $this->Party->read();
$this->set('party', $party);
$this->pageTitle = 'Edit Party';
$this->set('current', 'create');
if (empty($_SESSION['User']['id']))
$this->redirect('/users/login/');
if ($party['Party']['owner'] != $_SESSION['User']['id'])
$this->redirect('/parties/view/'.$id);
else {
if (empty($this->data)) {
$this->data = $party;
$date = array('hour' => intval(date('h', $party['Party']['date'])),
'min' => intval(date('i', $party['Party']['date'])),
'mon' => intval(date('m', $party['Party']['date'])),
'day' => intval(date('d', $party['Party']['date'])),
'year' => intval(date('Y', $party['Party']['date'])),
'tz' => $party['Party']['tz']);
$this->set('date', $date);
$this->data['Party']['name'] = preg_replace("/&#(\d{2,5});/e",
'$this->Unicode->unicode2utf(${1})',
html_entity_decode($this->data['Party']['name']));
$this->data['Party']['vname'] = preg_replace("/&#(\d{2,5});/e",
'$this->Unicode->unicode2utf(${1})',
html_entity_decode($this->data['Party']['vname']));
$this->data['Party']['website'] = preg_replace("/&#(\d{2,5});/e",
'$this->Unicode->unicode2utf(${1})',
html_entity_decode($this->data['Party']['website']));
$this->data['Party']['address'] = preg_replace("/&#(\d{2,5});/e",
'$this->Unicode->unicode2utf(${1})',
html_entity_decode($this->data['Party']['address']));
$this->data['Party']['notes'] = preg_replace("/&#(\d{2,5});/e",
'$this->Unicode->unicode2utf(${1})',
html_entity_decode($this->data['Party']['notes']));
$this->data['Party']['flickrusr'] = preg_replace("/&#(\d{2,5});/e",
'$this->Unicode->unicode2utf(${1})',
html_entity_decode($this->data['Party']['flickrusr']));
if (GMAP_API_KEY != null) {
if ($this->data['Party']['lat'])
$this->set('map', 'mapInit('.$this->data['Party']['lat'].','.$this->data['Party']['long'].','.$this->data['Party']['zoom'].')');
else
$this->set('map', 'mapInit()');
}
}
else {
$clean = new Sanitize();
$temp = array('lat' => $clean->sql($this->data['Party']['lat']),
'long' => $clean->sql($this->data['Party']['long']),
'tz' => $clean->sql($this->data['Party']['tz']));
$clean->cleanArray($this->data);
$this->data['Party']['lat'] = floatval($temp['lat']);
$this->data['Party']['long'] = floatval($temp['long']);
$this->data['Party']['tz'] = intval($temp['tz']);
$secoffset = ($this->data['Party']['tz'] * 60 * 60);
$offsetdate = gmmktime($this->data['Party']['hour_hour'],
$this->data['Party']['minute_min'],
0,
$this->data['Party']['month_hour'],
$this->data['Party']['day_day'],
$this->data['Party']['year_year']);
$this->data['Party']['date'] = ($offsetdate - $secoffset);
$this->data['Party']['owner'] = $party['Party']['owner'];
$this->data['Party']['duration'] = intval($this->data['Party']['duration']);
$date = array('hour' => intval(date('h', $party['Party']['date'])),
'min' => intval(date('i', $party['Party']['date'])),
'mon' => intval(date('m', $party['Party']['date'])),
'day' => intval(date('d', $party['Party']['date'])),
'year' => intval(date('Y', $party['Party']['date'])),
'tz' => $party['Party']['tz']);
$this->set('date', $date);
if (!preg_match("/^(http|https)\:\/\//i", $this->data['Party']['website']) &&
!empty($this->data['Party']['website']))
$this->Party->invalidate('website');
if ($this->data['Party']['flickrusr'] != $party['Party']['flickrusr']) {
$params = array('type' => 'flickr', 'username' => $this->data['Party']['flickrusr']);
$flick = new webServices($params);
$this->data['Party']['flickrid'] = $flick->getFlickrId();
}
if ($this->Party->validates($this->data)) {
if ($this->Party->save($this->data)) {
$this->Session->setFlash('Party edited successfully.', 'infoFlash');
$this->redirect('parties/view/'.$id);
}
}
}
}
}
function view($id = null, $page = null) {
if ($id == 'all') {
$this->pageTitle = 'All Parties';
$this->set('current', 'parties');
//Paginate!
$count = $this->Party->findCount();
$pages = ceil($count/100);
if ($page == null)
$page = 1;
if ($page > 1)
$this->set('prev', $page - 1);
if ($page < $pages)
$this->set('next', $page + 1);
$deck = $this->Party->findAll(null, null, "id ASC", 100, $page);
shuffle($deck);
$this->set('parties', $deck);
}
else if (is_numeric($id)) {
$party = $this->Party->findById($id);
if (empty($party['Party']['id']))
$this->redirect('/parties/view/all');
$this->set('current', 'parties');
$this->set('host', $this->Party->getHost($party['Party']['owner']));
$this->set('party', $party);
$this->set('isguest', $this->Party->isGuest($id, @$_SESSION['User']['id']));
$this->pageTitle = $party['Party']['name'];
$this->set('map', 'mapInit('.$party['Party']['lat'].','.$party['Party']['long'].
','.$party['Party']['zoom'].',\'stationary\')');
$this->set('guests', $this->Party->getGuests($party['Party']['id']));
$this->set('comments', $this->Party->getComments($id));
if (FLICKR_API_KEY != null) {
if ($party['Party']['useflickr'] == 1) {
$data = array('type' => 'flickr', 'userid' => $party['Party']['flickrid'], 'randomize' => true);
$flickr = new webServices($data);
$photoset = $flickr->fetchPhotos(FLICKR_TAG_PREFIX.$party['Party']['id'], 15, (($party['Party']['flickrperms']) ? false : true));
$this->set('flickr', array_slice($photoset, 0, 9));
}
}
}
else
$this->redirect('/parties/view/all');
}
function invite($id = null) {
$this->pageTitle = "Invite a Guest";
if (is_numeric($id)) {
$party = $this->Party->findById($id);
if (empty($party['Party']['id']) ||
$party['Party']['owner'] != $_SESSION['User']['id'] ||
$party['Party']['canceled'] == 1)
$this->redirect('/parties/view/all');
else {
$this->set('partyid', $party['Party']['id']);
$this->set('inviteurl', APP_BASE.'/parties/invited/'.$party['Party']['invitecode']);
$clean = new Sanitize();
$uid = $clean->sql($_SESSION['User']['id']);
$email = $this->Party->query("SELECT email FROM users WHERE id = ".$uid);
if (!empty($this->data)) {
if ($this->Party->validates($this->data)) {
$message = array('from' => APP_NAME.' <'.APP_EMAIL.'>',
'envelope' => APP_EMAIL,
'to' => $this->data['Party']['einvite'],
'reply' => $email[0]['users']['email'],
'subject' => 'You\'ve been invited to '.APP_NAME.'!',
'link' => APP_BASE.'/parties/invited/'.$party['Party']['invitecode'],
'type' => 'invite');
$this->Mail->mail($message);
$this->Mail->send();
$this->Session->setFlash($this->data['Party']['einvite'].' has been
invited. You can invite another guest below or <a href="'.APP_BASE.'/parties/view/'.$id.'/">click here</a>
to return to your party.', 'infoFlash');
$this->data['Party']['einvite'] = null;
}
else {
$this->validateErrors($this->Party);
$this->render();
}
}
}
}
}
function invited($icode = null, $conf = null) {
$this->pageTitle = "Confirm Invite";
if ($icode == 'cancel') {
$this->Session->delete('invite');
$this->Session->delete('invitestep');
$this->redirect('/');
}
else {
$clean = new Sanitize();
$icode = $clean->sql($icode);
$party = $this->Party->findByInvitecode($icode);
if (empty($party['Party']['id'])) {
$this->Session->setFlash('Could not find a party matching that invite code, please check it and try again.', 'errorFlash');
}
else {
if (!empty($_SESSION['User']['id']) && !empty($_SESSION['invitestep']) && $conf == 'confirm') {
$this->Party->addGuest($_SESSION['User']['id'], $_SESSION['invite']);
$this->Session->setFlash('You have been successfully added to this party.', 'infoFlash');
$this->redirect('/parties/view/'.$party['Party']['id']);
}
else if (!empty($_SESSION['User']['id'])) {
$this->set('confirm_only', true);
$this->set('party', $party);
$this->set('icode', $icode);
$this->Session->write('invitestep', 'true');
$this->Session->write('invite', $icode);
}
else {
$this->Session->write('invite', $icode);
$this->set('party', $party);
$this->set('icode', $icode);
}
}
}
}
function rsvp($pid) {
if (is_numeric($pid) && isset($_SESSION['User']['id'])) {
$party = $this->Party->findById($pid);
if (empty($party['Party']['id'])) {
$this->Session->setFlash('Invalid party id.', 'errorFlash');
$this->redirect('/parties/view/all');
}
else {
if ($party['Party']['inviteonly']) {
$this->Session->setFlash('This party invite only, you\'ll need an
invitation from the host to join in', 'errorFlash');
}
else {
$this->Party->rsvp($pid, $_SESSION['User']['id']);
$this->Session->setFlash('You have been successfully added to this party.', 'infoFlash');
$this->redirect('/parties/view/'.$pid);
}
}
}
else
$this->redirect('/parties/view/all');
}
function unrsvp($pid) {
if (is_numeric($pid) && isset($_SESSION['User']['id'])) {
$party = $this->Party->findById($pid);
if (empty($party['Party']['id'])) {
$this->Session->setFlash('Invalid party id.', 'errorFlash');
$this->redirect('/parties/view/all');
}
else {
$this->Party->unrsvp($pid, $_SESSION['User']['id']);
$this->Session->setFlash('You have been successfully removed from this party.', 'infoFlash');
$this->redirect('/parties/view/'.$pid);
}
}
else
$this->redirect('/parties/view/all');
}
function cancel($pid) {
$this->pageTitle = "Cancel Party";
if (!is_numeric($pid) || !isset($_SESSION['User']['id']))
$this->redirect('/');
else
$this->set('pid', $pid);
$party = $this->Party->findById($pid);
if ($_SESSION['User']['id'] != $party['Party']['owner'])
die();
if (!empty($this->data) && $_SESSION['User']['id'] == $party['Party']['owner']) {
if ($this->data['Party']['confcancel'] == 1) {
$guests = $this->Party->getGuests($pid);
$guest_count = count($guests);
foreach($guests as $guest) {
$message = array('from' => APP_NAME.' <'.APP_EMAIL.'>',
'envelope' => APP_EMAIL,
'to' => $guest['users']['email'],
'reply' => $_SESSION['User']['email'],
'subject' => 'Party Cancellation Notice',
'link' => APP_BASE.'/parties/view/'.$pid,
'type' => 'cancel');
$this->Mail->mail($message);
$this->Mail->send();
}
$this->Party->query("DELETE FROM guests WHERE pid = $pid LIMIT $guest_count");
$this->Party->query("UPDATE parties SET canceled = '1', invitecode = '0' WHERE parties.id = $pid LIMIT 1");
$this->redirect('/parties/view/'.$pid);
}
}
}
function uncancel($pid) {
if (!is_numeric($pid) || !isset($_SESSION['User']['id']))
$this->redirect('/');
$party = $this->Party->findById($pid);
if ($_SESSION['User']['id'] != $party['Party']['owner'])
die();
$key = $this->Hash->keygen(10);
$this->Party->query("UPDATE parties SET canceled = '0', invitecode = '$key' WHERE parties.id = $pid LIMIT 1");
$this->redirect('/parties/view/'.$pid);
}
function js($type = null, $data = null) {
$this->layout = 'ajax';
if ($type == 'html') {
header('Content-type: text/plain');
$party = $this->Party->findById($data);
$this->set('party', $party);
}
else {
header('Content-type: text/javascript');
$parties = $this->Party->findAll();
$this->set('parties', $parties);
}
}
}
?>

View File

@@ -1,437 +0,0 @@
<?php
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Party Tool
*
* The Initial Developer of the Original Code is
* Ryan Flint <rflint@dslr.net>
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
uses('sanitize');
class UsersController extends AppController {
var $name = 'Users';
var $uses = array('User', 'Party');
var $helpers = array('Html', 'Form');
var $components = array('Security', 'Hash', 'Mail');
function index() {
if (!isset($_SESSION['User'])) {
$this->redirect('/users/login');
}
$this->pageTitle = 'My Profile';
$user = $this->Session->read('User');
$this->set('parties', $this->User->memberOf($user['id']));
$this->set('hparties', $this->User->hostOf($user['id']));
$this->set('iparties', $this->User->invitedTo($user['id']));
}
function register() {
$this->pageTitle = 'Register';
$this->set('map', 'mapInit()');
if(empty($this->data)) {
$this->set('utz', '0');
$this->render();
}
else {
if ($this->User->findByEmail($this->data['User']['email']))
$this->User->invalidate('email');
if ($this->data['User']['email'] !== $this->data['User']['confemail'])
$this->User->invalidate('confemail');
if (!preg_match("/^(http|https)\:\/\//i", $this->data['User']['website']) &&
!empty($this->data['User']['website']))
$this->User->invalidate('website');
if ($this->data['User']['password'] !== $this->data['User']['confpass'])
$this->User->invalidate('confpass');
if (empty($this->data['User']['password']) || empty($this->data['User']['confpass']))
$this->User->invalidate('password');
// Repopulate the timezone with right value in case there's a validation error
$this->set('utz', $this->data['User']['tz']);
if ($this->User->validates($this->data)) {
$clean = new Sanitize();
// Generate and set the password, salt and activation key
$pass = $this->Hash->password($this->data['User']['password'],
$this->data['User']['email']);
$this->data['User']['active'] = $this->Hash->keygen(10);
$this->data['User']['password'] = $pass['pass'];
$this->data['User']['salt'] = $pass['salt'];
// Save a few fields from the wrath of cleanArray()
$temp = array('lat' => $this->data['User']['lat'],
'long' => $this->data['User']['long'],
'tz' => $this->data['User']['tz'],
'email' => $this->data['User']['email']);
// Scrub 'a dub
$clean->cleanArray($this->data);
$this->data['User']['email'] = $temp['email'];
$this->data['User']['long'] = floatval($temp['long']);
$this->data['User']['lat'] = floatval($temp['lat']);
$this->data['User']['tz'] = intval($temp['tz']);
$this->data['User']['role'] = 0;
if($this->User->save($this->data)) {
$message = array('from' => APP_NAME.' <'.APP_EMAIL.'>',
'envelope' => APP_EMAIL,
'to' => $this->data['User']['email'],
'subject' => 'Your '.APP_NAME.' Registration',
'link' => APP_BASE.'/users/activate/'.$this->data['User']['active'],
'type' => 'act');
$this->Mail->mail($message);
$this->Mail->send();
if (isset($_SESSION['invite']))
$this->Party->addGuest($this->User->getLastInsertId(), $_SESSION['invite']);
$this->Session->setFlash('Thank you for registering! To login, you\'ll
need to activate your account. Please check
your email for your activation link.', 'infoFlash');
$this->redirect('/users/login');
}
else {
$this->data['User']['password'] = null;
$this->data['User']['confpass'] = null;
$this->render();
}
}
else {
$this->data['User']['password'] = null;
$this->data['User']['confpass'] = null;
$this->Session->setFlash('There was an error in your submission. Please
correct the errors shown below and try again.',
'errorFlash');
$this->render();
}
}
}
function edit() {
if (!isset($_SESSION['User'])) {
$this->redirect('/users/login');
}
$this->set('error', false);
$this->pageTitle = 'Edit My Account';
if (empty($this->data)) {
$this->User->id = $_SESSION['User']['id'];
$this->data = $this->User->read();
$this->data['User']['password'] = "";
$this->set('utz', $this->data['User']['tz']);
$this->data['User']['name'] = preg_replace("/&#(\d{2,5});/e",
'$this->Unicode->unicode2utf(${1})',
html_entity_decode($this->data['User']['name']));
$this->data['User']['website'] = preg_replace("/&#(\d{2,5});/e",
'$this->Unicode->unicode2utf(${1})',
html_entity_decode($this->data['User']['website']));
$this->data['User']['location'] = preg_replace("/&#(\d{2,5});/e",
'$this->Unicode->unicode2utf(${1})',
html_entity_decode($this->data['User']['location']));
if (GMAP_API_KEY != null) {
if ($this->data['User']['lat'])
$this->set('map', 'mapInit('.$this->data['User']['lat'].','.$this->data['User']['long'].','.$this->data['User']['zoom'].')');
else
$this->set('map', 'mapInit()');
}
}
else {
$user = $this->User->findById($_SESSION['User']['id']);
$this->User->id = $user['User']['id'];
$this->set('utz', $user['User']['tz']);
$clean = new Sanitize();
$temp = array('password' => $this->data['User']['password'],
'confpassword' => $this->data['User']['confpassword'],
'lat' => $clean->sql($this->data['User']['lat']),
'long' => $clean->sql($this->data['User']['long']),
'tz' => $clean->sql($this->data['User']['tz']));
//Nuke everything else
$clean->cleanArray($this->data);
$this->data['User']['email'] = $user['User']['email'];
$this->data['User']['password'] = $temp['password'];
$this->data['User']['confpassword'] = $temp['confpassword'];
$this->data['User']['lat'] = floatval($temp['lat']);
$this->data['User']['long'] = floatval($temp['long']);
$this->data['User']['tz'] = intval($temp['tz']);
$this->data['User']['role'] = $user['User']['role'];
if (!preg_match("/^(http|https)\:\/\//i", $this->data['User']['website']) &&
!empty($this->data['User']['website']))
$this->User->invalidate('website');
if ($this->data['User']['password'] === $this->data['User']['confpassword'] &&
!empty($this->data['User']['password'])) {
$pass = $this->Hash->password($this->data['User']['password'], $user['User']['email']);
$this->data['User']['password'] = $pass['pass'];
$this->data['User']['salt'] = $pass['salt'];
}
else if (empty($this->data['User']['password']) && empty($this->data['User']['confpassword'])) {
$this->data['User']['password'] = $user['User']['password'];
$this->data['User']['salt'] = $user['User']['salt'];
}
else {
$this->set('error', true);
$this->User->invalidate('password');
$this->User->invalidate('confpassword');
}
if ($this->User->validates($this->data)) {
if ($this->User->save($this->data)) {
$sess = $this->User->findById($user['User']['id']);
$this->redirect('/users/');
}
}
else {
$this->validateErrors($this->User);
$this->data['User']['password'] = null;
$this->data['User']['confpassword'] = null;
$this->render();
}
}
}
function login() {
if ($this->Session->Check('User'))
$this->redirect('/users');
$this->pageTitle = 'Login';
if (!empty($this->data)) {
if (empty($this->data['User']['email']) || empty($this->data['User']['password']))
$this->render();
$user = $this->User->findByEmail($this->data['User']['email']);
$pass = sha1($this->data['User']['password'].$user['User']['salt']);
if ($user['User']['password'] == $pass) {
if ($user['User']['active'] != 1) {
$this->Session->setFlash('Your account hasn\'t been activated yet. Please
check your email (including junk/spam folders)
for your activation link, or click <a href="'
.APP_BASE.'/users/recover/activate">here</a> to
resend your activation details.', 'infoFlash');
$this->render();
}
else {
if (isset($_SESSION['invite']))
$this->Party->addGuest($user['User']['id'], $_SESSION['invite']);
$this->Session->write('User', $user['User']);
$this->redirect('/users/');
}
}
else {
$this->Session->setFlash('The email address and password you supplied do
not match. Please try again.', 'errorFlash');
}
}
}
function view($id = null) {
if (!is_numeric($id))
$this->redirect('/');
else {
$user = $this->User->findById($id);
$this->pageTitle = $user['User']['name'];
$this->set('user', $user);
if (GMAP_API_KEY != null && !empty($user['User']['lat']))
$this->set('map', 'mapInit('.$user['User']['lat'].','.$user['User']['long'].','.$user['User']['zoom'].',\'stationary\');');
$this->Party->unbindModel(array('hasMany' => array('Comment')));
$this->set('hparties', $this->User->hostOf($id));
$att = $this->User->query('SELECT parties.id, parties.name
FROM parties
LEFT JOIN guests
ON parties.id = guests.pid
WHERE guests.uid = '.$id);
$this->set('parties', $att);
}
}
function logout() {
$this->Session->destroy();
$this->Session->delete('User');
$this->redirect('/');
}
function recover($aType = null, $aCode = null, $aId = null) {
switch ($aType) {
case "password":
$this->pageTitle = "Password Recovery";
$this->set('atitle', 'Password Recovery');
$this->set('hideInput', false);
$this->set('url', 'password');
if (!empty($this->data)) {
$user = $this->User->findByEmail($this->data['User']['email']);
if (!isset($user['User']['email'])) {
$this->Session->setFlash('Could not find a user with that email address. Please check it and try again.', 'errorFlash');
$this->render();
}
else {
$code = md5($user['User']['salt'].$user['User']['email'].$user['User']['password']);
$message = array('from' => APP_NAME.' <'.APP_EMAIL.'>',
'envelope' => APP_EMAIL,
'to' => $user['User']['email'],
'subject' => APP_NAME.' Password Request',
'link' => APP_BASE.'/users/recover/password/'.$code.'/'.$user['User']['id'],
'type' => 'prec');
$this->Mail->mail($message);
$this->Mail->send();
$this->Session->setFlash('An email has been sent to '.$user['User']['email'].' with reset instructions.', 'errorFlash');
$this->redirect('users/login');
}
}
if ($aCode !== null && $aId !== null) {
$this->set('hideInput', true);
$this->set('reset', false);
$user = $this->User->findById($aId);
if (!$user) {
$this->Session->setFlash('Invalid request. Please check the URL and try again.', 'errorFlash');
$this->render();
}
if ($aCode == md5($user['User']['salt'].$user['User']['email'].$user['User']['password'])) {
$this->set('reset', true);
$this->set('code', $aCode."/".$aId);
$this->render();
}
else {
$this->Session->setFlash('Invalid request. Please check the URL and try again.', 'errorFlash');
$this->render();
}
}
break;
case "activate":
$this->pageTitle = 'Resend Activation Code';
$this->set('atitle', 'Resend Activation Code');
$this->set('hideInput', false);
$this->set('url', 'activate');
if (!empty($this->data)) {
$user = $this->User->findByEmail($this->data['User']['email']);
if (!$user) {
$this->Session->setFlash('Could not find a user with that email address. Please check it and try again.', 'errorFlash');
$this->render();
}
if ($user['User']['active'] == 1)
$this->redirect('/users/login');
else {
$message = array('from' => APP_NAME.' <'.APP_EMAIL.'>',
'envelope' => APP_EMAIL,
'to' => $this->data['User']['email'],
'subject' => 'Your '.APP_NAME.' Registration',
'link' => APP_BASE.'/users/activate/'.$user['User']['active'],
'type' => 'act');
$this->Mail->mail($message);
$this->Mail->send();
$this->Session->setFlash('Your activation code has been resent.', 'infoFlash');
$this->redirect('users/login');
}
}
break;
case "reset":
if ($aCode !== null && $aId !== null) {
if (!empty($this->data)) {
$user = $this->User->findById($aId);
if (!$user) {
$this->Session->setFlash('Invalid request. Please check the URL and try again.', 'errorFlash');
$this->render();
}
if ($aCode == md5($user['User']['salt'].$user['User']['email'].$user['User']['password'])) {
$string = $user['User']['email'] . uniqid(rand(), true) . $this->data['User']['password'];
$this->data['User']['salt'] = substr(md5($string), 0, 9);
$this->data['User']['password'] = sha1($this->data['User']['password'] . $this->data['User']['salt']);
$this->data['User']['id'] = $aId;
if ($this->User->save($this->data)) {
$this->Session->setFlash('Your password has been reset.', 'infoFlash');
$this->redirect('/users/login');
}
}
}
}
break;
default:
$this->redirect('/');
break;
}
}
function activate($aKey = null) {
if ($aKey == null)
$this->redirect('/');
else {
$user = $this->User->findByActive($aKey);
if (empty($user['User']['id'])) {
$this->Session->setFlash('Your account could not be activated. Please make
sure the URL entered is correct and try again.', 'errorFlash');
$this->redirect('/users/login');
}
else {
$this->data = $user;
$this->data['User']['active'] = 1;
if ($this->User->save($this->data)) {
$this->Session->setFlash('Your account was successfully activated.', 'infoFlash');
$this->redirect('/users/login');
}
}
}
}
}
?>

View File

@@ -1,26 +0,0 @@
<?php
/* SVN FILE: $Id: index.php,v 1.3 2006-10-08 03:39:21 reed%reedloden.com Exp $ */
/**
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2006, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.app
* @since CakePHP v 0.10.0.1076
* @version $Revision: 1.3 $
* @modifiedby $LastChangedBy: phpnut $
* @lastmodified $Date: 2006-10-08 03:39:21 $
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
require 'webroot' . DIRECTORY_SEPARATOR . 'index.php';
?>

View File

@@ -1,41 +0,0 @@
<?php
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Party Tool
*
* The Initial Developer of the Original Code is
* Ryan Flint <rflint@dslr.net>
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
class Admin extends AppModel {
var $name = 'Admin';
var $useTable = "parties";
}
?>

View File

@@ -1,61 +0,0 @@
<?php
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Party Tool
*
* The Initial Developer of the Original Code is
* Ryan Flint <rflint@dslr.net>
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
class Comment extends AppModel {
var $name = 'Comment';
var $validate = array(
'text' => "/^\S/"
);
function canComment($pid, $uid) {
$status = $this->query('SELECT owner, guestcomments FROM parties WHERE id = '.$pid);
$guest = null;
if ($status[0]['parties']['owner'] != $uid)
$guest = $this->query('SELECT uid FROM guests WHERE pid = '.$pid.' AND uid = '.$uid);
if ($status[0]['parties']['guestcomments'] == 1) {
if (!empty($guest[0]['guests']['uid']) || $uid == $status[0]['parties']['owner'])
return true;
else
return false;
}
else
return true;
}
}
?>

View File

@@ -1,51 +0,0 @@
<?php
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Party Tool
*
* The Initial Developer of the Original Code is
* Ryan Flint <rflint@dslr.net>
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
class Feed extends AppModel {
var $name = 'Feeds';
var $useTable = "parties";
function getComments($aParty) {
$rv = $this->query("SELECT * FROM comments WHERE assoc = ".$aParty." LIMIT 10");
return $rv;
}
function getUserCount() {
$rv = $this->query("SELECT COUNT(*) FROM users");
return $rv[0][0]['COUNT(*)'];
}
}
?>

View File

@@ -1,40 +0,0 @@
<?php
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Party Tool
*
* The Initial Developer of the Original Code is
* Ryan Flint <rflint@dslr.net>
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
class Guest extends AppModel {
var $name = 'Guest';
}
?>

View File

@@ -1,46 +0,0 @@
<?php
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Party Tool
*
* The Initial Developer of the Original Code is
* Ryan Flint <rflint@dslr.net>
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
class Page extends AppModel {
var $name = 'Page';
var $useTable = 'parties';
function getUsers() {
$rv = $this->query("SELECT COUNT(*) FROM users");
return $rv[0][0]["COUNT(*)"];
}
}
?>

View File

@@ -1,110 +0,0 @@
<?php
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Party Tool
*
* The Initial Developer of the Original Code is
* Ryan Flint <rflint@dslr.net>
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
class Party extends AppModel {
var $name = 'Party';
var $validate = array(
'name' => "/^\S/",
'einvite' => VALID_EMAIL,
'duration' => VALID_NUMBER
);
function getComments($pid) {
$rv = $this->query("SELECT users.id AS uid, users.name,
comments.id AS cid, comments.time, comments.text
FROM users, parties, comments
WHERE comments.assoc = ".$pid."
AND users.id = comments.owner
AND parties.id = ".$pid."
ORDER BY cid ASC");
return $rv;
}
function getHost($uid) {
$rv = $this->query("SELECT name FROM users WHERE id = ".$uid);
return @$rv[0]['users']['name'];
}
function isGuest($pid, $uid) {
$rv = $this->query('SELECT id FROM guests WHERE uid = '.$uid.' AND pid = '.$pid);
if (!empty($rv[0]['guests']['id']))
return true;
else
return false;
}
function getGuests($pid) {
$rv = $this->query("SELECT users.id, users.name, users.email, guests.invited
FROM users
LEFT JOIN guests
ON users.id = guests.uid
WHERE guests.pid = ".$pid);
return $rv;
}
function rsvp($pid, $uid) {
$party = $this->findById($pid);
if (!empty($party['Party']['id']) && !$this->isGuest($pid, $uid)) {
$this->query("INSERT INTO guests (id, pid, uid, invited)
VALUES (NULL, ".$party['Party']['id'].", ".$uid.", 0)");
}
}
function unrsvp($pid, $uid) {
$party = $this->findById($pid);
if (!empty($party['Party']['id']) && $this->isGuest($pid, $uid)) {
$this->query('DELETE FROM guests WHERE uid = '.$uid.' AND pid = '.$pid);
}
}
function addGuest($uid, $icode) {
$party = $this->findByInvitecode($icode);
if (!empty($party['Party']['id'])) {
$check = $this->query('SELECT uid FROM guests WHERE uid = '.$uid.'
AND pid = '.$party['Party']['id']);
if (empty($check[0]['guests']['uid']) && $uid != $party['Party']['owner']) {
$this->query("INSERT INTO guests (id, pid, uid, invited)
VALUES (NULL, ".$party['Party']['id'].", ".$uid.", 1)");
}
}
}
function findByInvitecode($icode) {
$rv = $this->query('SELECT * FROM parties AS Party WHERE invitecode = "'.$icode.'" LIMIT 1');
return @$rv[0];
}
}
?>

View File

@@ -1,59 +0,0 @@
<?php
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Party Tool
*
* The Initial Developer of the Original Code is
* Ryan Flint <rflint@dslr.net>
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
class User extends AppModel {
var $name = 'User';
var $validate = array(
'email' => VALID_EMAIL,
'name' => "/^\S/"
);
function memberOf($uid) {
$rv = $this->query('SELECT parties.id, parties.name FROM guests, parties WHERE guests.uid = '.$uid.' AND parties.id = guests.pid');
return $rv;
}
function hostOf($uid) {
$rv = $this->query('SELECT id, name FROM parties WHERE owner = '.$uid);
return $rv;
}
function invitedTo($uid) {
$rv = $this->query('SELECT parties.id, parties.name FROM guests, parties WHERE guests.uid = '.$uid.' AND parties.id = guests.pid AND guests.invited = 1');
return $rv;
}
}
?>

View File

@@ -1,199 +0,0 @@
<?php
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Party Tool
*
* The Initial Developer of the Original Code is
* Ryan Flint <rflint@dslr.net>
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
class webServices {
var $userid;
var $host;
var $randomize;
function webServices($data) {
switch ($data['type']) {
case "flickr":
$this->host = "api.flickr.com";
if (array_key_exists('userid', $data))
$this->userid = $data['userid'];
if (array_key_exists('randomize', $data))
$this->randomize = $data['randomize'];
if (array_key_exists('username', $data)) {
$head = "GET /services/rest/?method=flickr.people.findByUsername&api_key=".FLICKR_API_KEY."&username=".$data['username']." HTTP/1.1\r\n";
$head .= "Host: ".$this->host."\r\n";
$head .= "Connection: Close\r\n\r\n";
if ($results = $this->fetchResults($head)) {
preg_match('/nsid=\"(.*)\"/', $results, $matches);
if ($matches[1]) {
$this->userid = $matches[1];
}
else
return 0;
}
}
break;
case "gsuggest":
$this->host = "api.google.com";
break;
case "geocode":
$this->host = "maps.google.com";
break;
}
}
function getFlickrId() {
return $this->userid;
}
function fetchPhotos($tags, $num_results, $single_user) {
$params = array('api_key' => FLICKR_API_KEY,
'method' => 'flickr.photos.search',
'format' => 'php_serial',
'tags' => $tags,
'per_page' => $num_results);
if ($single_user)
$params['user_id'] = $this->userid;
$encoded_params = array();
foreach ($params as $k => $v)
$encoded_params[] = urlencode($k).'='.urlencode($v);
$head = 'GET /services/rest/?'.implode('&', $encoded_params)." HTTP/1.1 \r\n";
$head .= 'Host: '.$this->host."\r\n";
$head .= "Connection: Close\r\n\r\n";
if ($results = $this->fetchResults($head)) {
$resp = split("\r\n\r\n", $results);
$data = unserialize($resp[1]);
if ($data['stat'] == 'ok') {
$arr = array();
for ($i = 0; $i < count($data['photos']['photo']); $i++) {
$p = $data['photos']['photo'][$i];
$arr[$i] = array('id' => $p['id'],
'owner' => $p['owner'],
'secret' => $p['secret'],
'server' => $p['server'],
'farm' => $p['farm'],
'title' => $p['title']);
}
if ($this->randomize) {
// Randomize the results
shuffle($arr);
}
return $arr;
}
else
return 0;
}
else
return 0;
}
function GSuggest($phrase) {
$soapy = '<?xml version=\'1.0\' encoding=\'UTF-8\'?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Body>
<doSpellingSuggestion xmlns="urn:GoogleSearch">
<key xsi:type="xsd:string">'.GSEARCH_API_KEY.'</key>
<phrase xsi:type="xsd:string">'.$phrase.'</phrase>
</doSpellingSuggestion>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>';
$head = "POST /search/beta2 HTTP/1.1\r\n";
$head .= "Host: api.google.com\r\n";
$head .= "MessageType: CALL\r\n";
$head .= "Content-type: text/xml\r\n";
$head .= "Content-length: ".strlen($soapy)."\r\n";
$head .= "Connection: Close\r\n\r\n";
$head .= $soapy;
if ($results = $this->fetchResults($head)) {
if (preg_match('/return xsi:type="xsd:string">(.*)</', $results, $matches))
return $matches[1];
else
return 0;
}
return 0;
}
function geocode($query) {
$head = "GET /maps/geo?q=".urlencode($query)."&output=xml&key=".GMAP_API_KEY." HTTP/1.1\r\n";
$head .= "Host: maps.google.com\r\n";
$head .= "Connection: Close\r\n\r\n";
if ($results = $this->fetchResults($head)) {
if (stristr($results, '<code>200</code>')) {
preg_match('/coordinates>(.*)</', $results, $matches);
$ll = explode(',', $matches[1]);
$rv = array('lat' => $ll[1], 'lng' => $ll[0]);
return $rv;
}
}
return 0;
}
function fetchResults($headers) {
$fs = fsockopen($this->host, 80, $errno, $errstr, 30);
if (!$fs)
return 0;
else {
fwrite($fs, $headers);
stream_set_timeout($fs, 2);
$buffer = null;
while (!feof($fs))
$buffer .= fgets($fs, 128);
fclose($fs);
return $buffer;
}
}
}
?>

View File

@@ -1,18 +0,0 @@
<h1>Comments</h1>
<p>Switch view to: <a href="<?php echo $html->url('/admin/'); ?>">Parties&raquo;</a> <a href="<?php echo $html->url('/admin/users'); ?>">Users&raquo;</a></p>
<table>
<tr>
<td>ID</td>
<td>Text</td>
<td></td>
<td></td>
</tr>
<?php foreach($comments as $comment): ?>
<tr>
<td><a href="<?php echo $html->url('/parties/view/'.$comment['Comment']['assoc'].'#c'.$comment['Comment']['id']); ?>"><?php echo $comment['Comment']['id']; ?></a></td>
<td><?php echo $comment['Comment']['text']; ?></td>
<td><a href="<?php echo $html->url('/admin/edit/comment/'.$comment['Comment']['id']); ?>">Edit</a></td>
<td><a href="<?php echo $html->url('/admin/delete/comment/'.$comment['Comment']['id']); ?>" onclick="return confirm('Delete comment <?php echo $comment['Comment']['id']; ?>?')">Delete</a></td>
</tr>
<?php endforeach; ?>
</table>

View File

@@ -1,128 +0,0 @@
<?php if (isset($user)): ?>
<h1><?php echo $user['User']['name'].' (<a href="'.$html->url('/users/view/'.$user['User']['id']).'">'.$user['User']['id']; ?></a>)</h1>
<form class="fxform" action="<?php echo $html->url('/admin/edit/user/'.$user['User']['id']); ?>" method="post">
<div>
<label for="UserName" class="label-large">Name:</label>
<?php echo $html->input('User/name', array('size' => 40)); ?>
</div>
<div>
<label for="UserRole" class="label-large">Admin privileges:</label>
<?php echo $html->checkbox('User/role'); ?>
</div>
<div>
<label for="UserEmail" class="label-large">Email address:</label>
<?php echo $html->input('User/email', array('size' => 40)); ?>
</div>
<div>
<label for="UserWebsite" class="label-large">Website:</label>
<?php echo $html->input('User/website', array('size' => 40)); ?>
</div>
<div>
<label for="UserActive" class="label-large">Activation code:</label>
<?php echo $html->input('User/active', array('size' => 40)); ?>
</div>
<div>
<label for="location" class="label-large">Location:</label>
<?php echo $html->input('User/location', array('size' => 40)); ?>
</div>
<div>
<label for="UserShowemail" class="label-large">Show email:</label>
<?php echo $html->checkbox('User/showemail'); ?><br/>
</div>
<div>
<label for="UserShowloc" class="label-large">Show location:</label>
<?php echo $html->checkbox('User/showloc'); ?><br/>
</div>
<div>
<label for="UserShowmap" class="label-large">Show map:</label>
<?php echo $html->checkbox('User/showmap'); ?><br/>
</div>
<?php echo $html->hidden('User/id', array('value' => $user['User']['id'])).$html->submit('Submit'); ?>
</form>
<?php endif; if (isset($party)): ?>
<h1><?php echo $party['Party']['name'].' (<a href="'.$html->url('/parties/view/'.$party['Party']['id']).'">'.$party['Party']['id']; ?></a>)</h1>
<form class="fxform" action="<?php echo $html->url('/admin/edit/party/'.$party['Party']['id']); ?>" method="post">
<div>
<label for="PartyOwner" class="label-large">Party Owner:</label>
<?php echo $html->input('Party/owner', array('size' => 40)); ?>
</div>
<div>
<label for="PartyName" class="label-large">Party Name:</label>
<?php echo $html->input('Party/name', array('size' => 40)); ?>
</div>
<div>
<label for="PartyVname" class="label-large">Venue Name:</label>
<?php echo $html->input('Party/vname', array('size' => 40)); ?>
</div>
<div>
<label for="PartyWebsite" class="label-large">Web site:</label>
<?php echo $html->input('Party/website', array('size' => 40)); ?>
</div>
<div>
<label for="PartyAddress" class="label-large">Address:</label>
<?php echo $html->input('Party/address', array('size' => 40)); ?>
</div>
<div>
<label for="PartyDate" class="label-large">Date:</label>
<?php echo $html->input('Party/date', array('size' => 40)); ?>
</div>
<div>
<label for="PartyNotes" class="label-large">Additional Notes:</label>
<?php echo $html->textarea('Party/notes', array('rows' => 10, 'cols' => 50)); ?>
</div>
<div>
<label for="PartyConfirmed" class="label-large">Time:</label>
<?php echo $html->radio('Party/confirmed', array(0 => 'Tentative', 1 => 'Confirmed')); ?>
</div>
<div>
<label for="PartyDuration" class="label-large">Duration (in hours):</label>
<?php echo $html->input('Party/duration', array('size' => 5)); ?>
</div>
<div>
<label for="PartyCanceled" class="label-large">Canceled:</label>
<?php echo $html->checkbox('Party/canceled'); ?>
</div>
<div>
<label for="PartyUseflickr" class="label-large">Use Flickr:</label>
<?php echo $html->checkbox('Party/useflickr'); ?>
</div>
<div>
<label for="PartyFlickrperms" class="label-large">Show:</label>
<?php echo $html->radio('Party/flickrperms', array(0 => 'Only my photos', 1 => 'Anyone\'s photos')); ?>
</div>
<div>
<label for="PartyFlickrusr" class="label-large">Flickr username:</label>
<?php echo $html->input('Party/flickrusr', array('size' => 40)); ?>
</div>
<div>
<label for="PartyFlickrusr" class="label-large">Flickr id:</label>
<?php echo $html->input('Party/flickrid', array('size' => 40)); ?>
</div>
<div>
<label for="PartyInviteonly" class="label-large">Invite only:</label>
<?php echo $html->checkbox('Party/inviteonly'); ?>
</div>
<div>
<label for="PartyGuestcomments" class="label-large">Limit comments to party guests only:</label>
<?php echo $html->checkbox('Party/guestcomments'); ?>
</div>
<br/>
<?php echo $html->hidden('Party/id', array('value' => $party['Party']['id'])).$html->submit('Submit'); ?>
</form>
<?php endif; if(isset($comment)): ?>
<h1>Comment <?php echo '<a href="'.$html->url('/parties/view/'.$comment['Comment']['assoc'].'#c'.$comment['Comment']['id']).'">#'.$comment['Comment']['id']; ?></a> by <?php echo '<a href="'.$html->url('/users/view/'.$comment['Comment']['owner']).'">'.$owner; ?></a></h1>
<form class="fxform" action="<?php echo $html->url('/admin/edit/comment/'.$comment['Comment']['id']); ?>" method="post">
<div>
<label for="CommentAssoc" class="label-large">Party:</label>
<?php echo $html->input('Comment/assoc', array('size' => 40)); ?>
</div>
<div>
<label for="CommentText" class="label-large">Text:</label>
<?php echo $html->textarea('Comment/text', array('rows' => 10, 'cols' => 50)); ?>
</div>
<?php echo $html->hidden('Comment/id', array('value' => $comment['Comment']['id'])).$html->submit('Submit'); ?>
</form>
<?php endif; ?>

View File

@@ -1,18 +0,0 @@
<h1>Parties</h1>
<p>Switch view to: <a href="<?php echo $html->url('/admin/users'); ?>">Users&raquo;</a> <a href="<?php echo $html->url('/admin/comments'); ?>">Comments&raquo;</a></p>
<table>
<tr>
<td>ID</td>
<td>Name</td>
<td></td>
<td></td>
</tr>
<?php foreach($parties as $party): ?>
<tr>
<td><a href="<?php echo $html->url('/parties/view/'.$party['Party']['id']); ?>"><?php echo $party['Party']['id']; ?></a></td>
<td><?php echo $party['Party']['name']; ?></td>
<td><a href="<?php echo $html->url('/admin/edit/party/'.$party['Party']['id']); ?>">Edit</a></td>
<td><a href="<?php echo $html->url('/admin/delete/party/'.$party['Party']['id']); ?>" onclick="return confirm('Delete party <?php echo $party['Party']['id']; ?>?')">Delete</a></td>
</tr>
<?php endforeach; ?>
</table>

View File

@@ -1,18 +0,0 @@
<h1>Users</h1>
<p>Switch view to: <a href="<?php echo $html->url('/admin/'); ?>">Parties&raquo;</a> <a href="<?php echo $html->url('/admin/comments'); ?>">Comments&raquo;</a></p>
<table>
<tr>
<td>ID</td>
<td>Name</td>
<td></td>
<td></td>
</tr>
<?php foreach($users as $user): ?>
<tr>
<td><a href="<?php echo $html->url('/users/view/'.$user['User']['id']); ?>"><?php echo $user['User']['id']; ?></a></td>
<td><?php echo $user['User']['name']; ?></td>
<td><a href="<?php echo $html->url('/admin/edit/user/'.$user['User']['id']); ?>">Edit</a></td>
<td><a href="<?php echo $html->url('/admin/delete/user/'.$user['User']['id']); ?>" onclick="return confirm('Delete user <?php echo $user['User']['id']; ?>?')">Delete</a></td>
</tr>
<?php endforeach; ?>
</table>

View File

@@ -1,7 +0,0 @@
<?php if(!isset($_SESSION['User'])): ?>
<strong>Welcome, Guest!</strong>
<a href="<?php echo $html->url('/users/login'); ?>">Login</a> | <a href="<?php echo $html->url('/users/register'); ?>">Register</a>
<?php else: ?>
<strong>Welcome, <?php echo $_SESSION['User']['name']; ?>!</strong>
<a href="<?php echo $html->url('/users'); ?>">My Account</a> | <a href="<?php echo $html->url('/users/logout'); ?>">Logout</a>
<?php endif; ?>

View File

@@ -1,16 +0,0 @@
<?php echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; ?>
<rss version="0.91">
<channel>
<pubDate><?php echo date('r'); ?></pubDate>
<description><?php echo APP_NAME." - Latest Comments"; ?></description>
<link><?php echo APP_BASE.$html->url('/parties/view/'.$pid); ?></link>
<title><?php echo APP_NAME." - Latest Comments"; ?></title>
<?php foreach($comments as $comment): ?>
<item>
<title><![CDATA[<?php echo substr($comment['comments']['text'], 0, 25).'...'; ?>]]></title>
<description><?php echo $comment['comments']['text'] ?></description>
<link><?php echo APP_BASE.$html->url('/parties/view/'.$comment['comments']['assoc'].'#c'.$comment['comments']['id']); ?></link>
</item>
<?php endforeach; ?>
</channel>
</rss>

View File

@@ -1,22 +0,0 @@
BEGIN:VCALENDAR
X-WR-CALNAME:<?php echo APP_NAME."\n"; ?>
X-WR-CALDESC:Upcoming Parties
PRODID:-//MozillaPartyTool//calendar//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
<?php foreach($events as $event):
if ($event['Feeds']['canceled']) continue; ?>
BEGIN:VEVENT
UID:<?php echo APP_BASE.$html->url('/parties/view/'.$event['Feeds']['id'])."\n"; ?>
DTSTAMP:<?php echo gmdate('Ymd\This\Z', $event['Feeds']['date'])."\n"; ?>
LOCATION:<?php echo $event['Feeds']['lat'].'\, '.$event['Feeds']['long'].'('.$event['Feeds']['address'].")\n"; ?>
SUMMARY:<?php echo $event['Feeds']['name']."\n"; ?>
DTSTART:<?php echo gmdate('Ymd\This', $event['Feeds']['date'])."\n"; ?>
DURATION:PT<?php echo $event['Feeds']['duration']; ?>H
URL:<?php echo APP_BASE.$html->url('/parties/view/'.$event['Feeds']['id'])."\n"; ?>
STATUS:<?php echo (($event['Feeds']['confirmed'] == 1) ? "CONFIRMED" : "TENTATIVE")."\n"; ?>
DESCRIPTION: <?php echo $event['Feeds']['name'].'\n '.$event['Feeds']['address'].'\n '.date('h:ia', $event['Feeds']['date']).'\n '.$event['Feeds']['notes'].'\n'."\n"; ?>
END:VEVENT
<?php endforeach; ?>
END:VCALENDAR

View File

@@ -1,14 +0,0 @@
<?php echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; ?>
<rss version="0.91">
<channel>
<pubDate><?php echo date('r'); ?></pubDate>
<description><?php echo APP_NAME." - Party Count"; ?></description>
<link><?php echo APP_BASE.$html->url('/'); ?></link>
<title><?php echo APP_NAME." - Party Count"; ?></title>
<item>
<title><?php echo $count; ?></title>
<description>Total Parties</description>
<link><?php echo APP_BASE.$html->url('/parties/view/all/'); ?></link>
</item>
</channel>
</rss>

View File

@@ -1,17 +0,0 @@
<?php echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; ?>
<rss version="0.91">
<channel>
<pubDate><?php echo date('r'); ?></pubDate>
<description><?php echo APP_NAME." - Latest Parties"; ?></description>
<link><?php echo APP_BASE.$html->url('/'); ?></link>
<title><?php echo APP_NAME." - Latest Parties"; ?></title>
<?php foreach($latest as $party):
if ($party['Feeds']['canceled']) continue; ?>
<item>
<title><?php echo $party['Feeds']['name'] ?></title>
<description><?php echo $party['Feeds']['vname'] ?></description>
<link><?php echo APP_BASE.$html->url('/parties/view/'.$party['Feeds']['id']); ?></link>
</item>
<?php endforeach; ?>
</channel>
</rss>

View File

@@ -1,23 +0,0 @@
<?php echo '<?xml version="1.0" encoding="utf-8"?>'."\n"; ?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><?php echo $party['Feeds']['name']; ?></title>
<id>tag:<?php echo APP_BASE; ?>,2006:/parties/view/<?php echo $party['Feeds']['id']; ?></id>
<subtitle><?php echo APP_NAME; ?> Photostream</subtitle>
<updated><?php echo date('Y-m-d\TH:i:s\Z'); ?></updated>
<generator uri="http://www.screwedbydesign.com/software/partytool">Mozilla Party Tool</generator>
<?php foreach ($flickr as $pic): ?>
<entry>
<title><?php echo $pic['title']; ?></title>
<link rel="alternate" type="text/html" href="http://www.flickr.com/photos/<?php echo $pic['owner']."/".$pic['id']."/"; ?>"/>
<id>tag:flickr.com,2005:/photo/<?php echo $pic['id']; ?></id>
<published><?php echo date('Y-m-d\TH:i:s\Z'); ?></published>
<updated><?php echo date('Y-m-d\TH:i:s\Z'); ?></updated>
<content type="html">&lt;a href="http://www.flickr.com/photos/<?php echo $pic['owner']."/".$pic['id']."/" ?>"&gt; &lt;img src="http://static.flickr.com/<?php echo $pic['server']."/".$pic['id']."_".$pic['secret']."_m.jpg" ?>" title="<?php echo $pic['title']; ?>"/&gt;&lt;/a&gt;</content>
<author>
<name><?php echo $pic['owner']; ?></name>
<uri>http://www.flickr.com/people/<?php echo $pic['owner']; ?>/</uri>
</author>
</entry>
<?php endforeach; ?>
</feed>

View File

@@ -1,16 +0,0 @@
<?php echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; ?>
<rss version="0.91">
<channel>
<pubDate><?php echo date('r'); ?></pubDate>
<description><?php echo APP_NAME." - Top Guests"; ?></description>
<link><?php echo APP_BASE.$html->url('/parties/view/all'); ?></link>
<title><?php echo APP_NAME." - Top Guests"; ?></title>
<?php foreach($items as $item):?>
<item>
<title><?php echo $item['parties']['name'].' ('.$item[0]['count'].')'; ?></title>
<description><?php echo $item['parties']['name'].' - '.$item[0]['count'].' guest'.(($item[0]['count'] != 1) ? 's' : ''); ?></description>
<link><?php echo APP_BASE.$html->url('/parties/view/'.$item['guests']['id']); ?></link>
</item>
<?php endforeach; ?>
</channel>
</rss>

View File

@@ -1,17 +0,0 @@
<?php echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; ?>
<rss version="0.91">
<channel>
<pubDate><?php echo date('r'); ?></pubDate>
<description><?php echo APP_NAME." - Upcoming Parties"; ?></description>
<link><?php echo APP_BASE.$html->url('/'); ?></link>
<title><?php echo APP_NAME." - Upcoming Parties"; ?></title>
<?php foreach($latest as $party):
if ($party['Feeds']['canceled']) continue; ?>
<item>
<title><![CDATA[<?php echo $party['Feeds']['name'] ?>]]></title>
<description><?php echo date('Y-m-d H:i', $party['Feeds']['date']); ?></description>
<link><?php echo APP_BASE.$html->url('/parties/view/'.$party['Feeds']['id']); ?></link>
</item>
<?php endforeach; ?>
</channel>
</rss>

View File

@@ -1,14 +0,0 @@
<?php echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; ?>
<rss version="0.91">
<channel>
<pubDate><?php echo date('r'); ?></pubDate>
<description><?php echo APP_NAME." - Total Users"; ?></description>
<link><?php echo APP_BASE.$html->url('/'); ?></link>
<title><?php echo APP_NAME." - Total Users"; ?></title>
<item>
<title><?php echo $count; ?></title>
<description>Total Users</description>
<link><?php echo APP_BASE.$html->url('/'); ?></link>
</item>
</channel>
</rss>

View File

@@ -1,40 +0,0 @@
<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo APP_NAME." - ".$title_for_layout?></title>
<link rel="shortcut icon" type="image/x-icon" href="<?php echo $html->url('/favicon.ico'); ?>"/>
<link rel="stylesheet" type="text/css" href="<?php echo $html->url('/css/main.css'); ?>"/>
<link rel="alternate" type="application/rss+xml" href="<?php echo $html->url('/feeds/latest'); ?>"/>
</head>
<body<?php echo (isset($map)) ? ' onload="'.$map.'" onunload="GUnload()"' : '';?>>
<div id="container">
<p class="skipLink"><a href="#content" accesskey="2">Skip to main content</a></p>
<div id="mozilla-com"><a href="http://www.mozilla.com/">Visit Mozilla.com</a></div>
<div id="header">
<div id="key-title">
<h1><a href="<?php echo $html->url('/'); ?>" title="Return to home page" accesskey="1"><img src="<?php echo $html->url('/img/firefox-title.png'); ?>" width="276" height="54" alt="Firefox Party"/></a></h1>
<div id="user"><?php echo $this->renderElement('user_options'); ?></div>
</div>
<div id="key-menu">
<ul id="menu-firefox">
<li<?php echo (@$current == 'home') ? ' class="current"' : ''?>><a href="<?php echo $html->url('/'); ?>">Home</a></li>
<li<?php echo (@$current == 'map') ? ' class="current"' : ''?>><a href="<?php echo $html->url('/parties/'); ?>">View Map</a></li>
<li<?php echo (@$current == 'parties') ? ' class="current"' : ''?>><a href="<?php echo $html->url('/parties/view/all/'); ?>">View Parties</a></li>
<li<?php echo (@$current == 'create') ? ' class="current"' : ''?>><a href="<?php echo $html->url('/parties/add/'); ?>">Create Party</a></li>
</ul>
</div>
</div>
<div id="content">
<?php $this->controller->Session->flash(); ?>
<?php echo $content_for_layout; ?>
</div>
<div id="footer">
Copyright &copy; <?php echo date('Y'); ?> Mozilla<br/>
<a href="<?php echo $html->url('/privacy-policy'); ?>">Privacy Policy</a>
</div>
</div>
</body>
</html>

View File

@@ -1 +0,0 @@
<div id='flash' class='error'><?php echo $content_for_layout ?></div>

View File

@@ -1 +0,0 @@
<div id='flash' class='info'><?php echo $content_for_layout ?></div>

View File

@@ -1,30 +0,0 @@
<?php
$difference = $time - time();
$days_left = floor($difference/60/60/24);
?>
<div id="f-left">
<?php echo $front_text;
if (@$_SESSION['User']['role'] == 1): ?>
<a href="<?php echo $html->url('/pages/edit'); ?>">Edit</a>
<?php endif; ?>
</div>
<div id="f-right">
<div class="cbox">
<span class="ctxt"><?php echo $pcount."</span><br/>".(($pcount == 1) ? ' Party' : ' Parties'); ?>
<div class="ifeed">
<a style="padding-right: 2px;" title="Party Calendar" href="<?php echo $html->url('/feeds/ical'); ?>"><img src="<?php echo $html->url('/img/ical.png'); ?>" alt="iCAL"/></a><a title="Party Count Feed" href="<?php echo $html->url('/feeds/'); ?>"><img src="<?php echo $html->url('/img/feed16.png'); ?>" alt="RSS"/></a>
</div>
</div>
<div class="cbox">
<span class="ctxt"><?php echo $ucount."</span><br/>".(($ucount == 1) ? ' Partygoer' : ' Partygoers'); ?>
<div class="cfeed">
<a title="User Count Feed" href="<?php echo $html->url('/feeds/users/'); ?>"><img src="<?php echo $html->url('/img/feed16.png'); ?>" alt="RSS"/></a>
</div>
</div>
<?php if ($days_left > 0): ?>
<div class="cbox">
<span class="ctxt"><?php echo $days_left."</span><br/>".(($days_left == 1) ? ' Day' : ' Days'); ?> until we party!
</div>
<?php endif; ?>
</div>
<div style="clear: both"></div>

View File

@@ -1,6 +0,0 @@
<form action="<?php echo $html->url('/pages/edit'); ?>" method="post">
<h1>Front Page Text</h1>
<?php echo $html->textarea('Pages/text', array('rows' => 35, 'cols' => 80)); ?>
<h1>Countdown Timer</h1>
<?php echo $html->dateTimeOptionTag('Pages/date', 'YMD', 24, $selected).'<br/><br/>'.$html->submit('Submit'); ?>
</form>

View File

@@ -1,42 +0,0 @@
<h2>Mozilla Privacy Policy</h2>
<h3>Website Visitors</h3>
<p>Except as described below, the Mozilla Foundation and the Mozilla Corporation (collectively "Mozilla") do not collect or require visitors to its Web sites to furnish personally-identifying information such as names, email addresses and phone numbers. Like most Web site operators, Mozilla does collect non-personally-identifying information of the sort that web browsers and servers typically make available, such as the browser type, language preference, referring site, and date and time of each visitor request. Mozilla also collects potentially personally-identifying information like Internet Protocol (IP) addresses, which are non-personally-identifying in and of themselves but could be used in conjunction with other information to personally identify users.</p>
<p>Mozilla's purpose in collecting this information is to better understand how Mozilla's visitors use its Web sites. To that end, Mozilla may share potentially personally-identifying information with its employees, contractors and affiliated organizations. Mozilla may also release non-personally-identifying information about visitors, e.g. by publishing a report on Web site usage trends. Otherwise, Mozilla will not publicly release potentially personally-identifying information except under the same circumstances as Mozilla releases personally-identifying information. Those circumstances are explained in detail below.</p>
<h3>Community Members</h3>
<p>Certain members of the Mozilla community (contributors, customers, etc.) choose to interact with Mozilla in ways that require Mozilla and others to know more about them. The amount and type of information that Mozilla gathers from those members depends on the nature of the interaction. For example, members who wish to post content to certain portions of Mozilla's Web sites are asked to provide usernames that identify that content as having been posted by a particular member. Developers, by comparison, are asked to provide contact information, up to and sometimes including telephone or fax numbers, so that they can be contacted as necessary. Customers of the Mozilla store are asked to provide even more information, including billing and shipping addresses and credit card or similar information. In each case, Mozilla collects personally-identifying information only insofar as is necessary to fulfill the purpose of the community member's interaction with Mozilla.</p>
<p>Mozilla is an open organization that believes in sharing as much information as possible about its products, its operations and its associations. Accordingly, community members should assume - as should most folks who interact with Mozilla - that any personally-identifying information provided to Mozilla will be made available to the public. There are three broad exceptions to that rule:</p>
<ol>
<li>Mozilla does not publicly release information gathered in connection with commercial transactions (i.e., transactions involving money), including transactions conducted through the Mozilla Store.</li>
<li>Mozilla does not make publicly available information that is used to authenticate users the publication of which would compromise the security of Mozilla's Web sites (e.g., passwords).</li>
<li>Mozilla does not make publicly available information that it specifically promises at the time of collection to maintain in confidence.</li>
</ol>
<p>Outside those three contexts, users should assume that personally-identifying information provided through Mozilla's Web sites will be made available to the public.</p>
<h3>Interactive Product Features</h3>
<p>Certain Mozilla products contain features that report, or that permit users to report, the user's usage patterns and problems - whether caused by Mozilla's software, third party software, or third-party Web sites - to Mozilla. The reports generated by these features typically include non-personally-identifying information such as the configuration of the user's computer and the code running at the time the problem occurred. Some of these features give users the option of providing personally-identifying information, though none of these features require it. Some Mozilla software features that do permit users to provide personally-identifying information advise in advance that such information will not be made publicly available. Mozilla analyzes the information provided by these interactive product features to develop a better understanding of how its products are performing and being used. It does not use the information to track the usage of its products by identifiable individuals.</p>
<h3>Cookies</h3>
<p>A cookie is a string of information that a Web site stores on a visitor's computer, and that the visitor's browser provides to the Web site each time the visitor returns. Mozilla's Web sites use cookies to help Mozilla identify and track visitors, their usage of Mozilla Web sites, and their Web site access preferences across multiple requests and visits to Mozilla's Web sites. It is possible to link cookies to personally-identifying information, thereby permitting Web site operators to track the online movements of particular individuals. Mozilla, however, does not do so. Instead, it uses the information provided by cookies to develop a better understanding of how Mozilla's visitors use, and to facilitate those visitors' interactions with, Mozilla's Web sites. Mozilla visitors who do not wish to have cookies placed on their computers by Mozilla or its contractors should set their browsers to refuse cookies before linking to Mozilla's Web sites. Certain features of Mozilla's Web sites may not function properly without the aid of cookies.</p>
<h3>Protection of Certain Personally-Identifying Information</h3>
<p>Where Mozilla has collected personally-identifying information subject to one of the three exceptions described in the Contributors and Customers section, above, it discloses that information only to those of its employees, contractors and affiliated organizations that need to know that information in order to process it on Mozilla's behalf and that have agreed not to disclose it to others. Some of those employees, contractors and affiliated organizations may be located outside of your home country; by using Mozilla's Web sites, you consent to the transfer of your information to them. Mozilla does not rent or sell such information to anyone. Other than to its employees, contractors and affiliated organizations, as described above, Mozilla discloses such information only when required to do so by law, or when Mozilla believes in good faith that disclosure is reasonably necessary to protect the property or rights of Mozilla, members of the Mozilla community, or the public at large. Mozilla takes all measures reasonably necessary to protect against the unauthorized access, use, alteration or destruction of such information</p>
<h3>Updating of Personally-Identifying Information</h3>
<p>Mozilla permits users to freely update and correct their personally-identifying information as maintained by Mozilla. To do so, users need only look for the links and other tools available on Mozilla's Web sites or contact Mozilla by email.</p>
<h3>Privacy Policy Changes</h3>
<p>Although changes are likely to be minor, Mozilla may change its Privacy Policy from time to time. Any and all changes will be reflected on this page. Substantive changes will also be announced through the standard mechanisms through which Mozilla communicates with the Mozilla community, including Mozilla's "mozilla-announce" mailing lists.</p>

View File

@@ -1,109 +0,0 @@
<h1>Create a Party</h1>
<form class="fxform" action="<?php echo $html->url('/parties/add'); ?>" method="post">
<div>
<label for="PartyName" class="label-large">Party Name<span class="required">*</span>:</label>
<?php echo $html->input('Party/name', array('size' => 40)); ?>
<?php echo $html->tagErrorMsg('Party/name', 'Please enter a party name.')?>
</div>
<div>
<label for="PartyVname" class="label-large">Venue Name:</label>
<?php echo $html->input('Party/vname', array('size' => 40)); ?>
</div>
<div>
<label for="PartyAddress" class="label-large">Address:</label>
<?php echo $html->input('Party/address', array('size' => 40, 'id' => 'location', 'onkeypress' => 'capture(event)', 'onblur' => 'update()')); ?>
<div id="locerr" class="info" style="display: none">Did you mean: <a id="locerrlink" onclick="geocode_suggest()" href="#"></a>? <a href="#" onclick="shide()"><span style="font-size: x-small">(close)</span></a></div>
</div>
<p>Enter your party's time and date (in your local time) here. If you're not ready to commit to a specific time or date, select the 'Tentative'
radio button. Otherwise select 'Confirmed'.</p>
<div>
<label for="PartyYear" class="label-large">Date:</label>
<?php echo $html->yearOptionTag('Party/year', null, date('Y'), MAX_YEAR, date('Y'), null, null, false); ?>-<?php echo $html->hourOptionTag('Party/month', null, false, date('m')); ?>-<?php echo $html->dayOptionTag('Party/day', null, date('d'), null, false); ?>
</div>
<div>
<label for="PartyHour" class="label-large">Time:</label>
<?php echo $html->hourOptionTag('Party/hour', null, true);?>:<?php echo $html->minuteOptionTag('Party/minute');?>
<?php echo $html->radio('Party/confirmed', array(0 => 'Tentative', 1 => 'Confirmed')); ?><br/>
</div>
<p>The timezone is used to calculate the appropriate GMT time from the local time specified above. This is done to show
the party in the local time of the person viewing it.</p>
<div>
<label for="PartyTz" class="label-large">Timezone<span class="required">*</span>:</label>
<?php
$tzs = array('-12' => 'GMT-12',
'-11' => 'GMT-11',
'-10' => 'GMT-10',
'-9' => 'GMT-9',
'-8' => 'GMT-8',
'-7' => 'GMT-7',
'-6' => 'GMT-6',
'-5' => 'GMT-5',
'-4' => 'GMT-4',
'-3' => 'GMT-3',
'-2' => 'GMT-2',
'-1' => 'GMT-1',
'0' => 'GMT+0',
'1' => 'GMT+1',
'2' => 'GMT+2',
'3' => 'GMT+3',
'4' => 'GMT+4',
'5' => 'GMT+5',
'6' => 'GMT+6',
'7' => 'GMT+7',
'8' => 'GMT+8',
'9' => 'GMT+9',
'10' => 'GMT+10',
'11' => 'GMT+11',
'12' => 'GMT+12',
'13' => 'GMT+13');
echo $html->selectTag('Party/tz', $tzs, $utz, null, null, false);
?>
(this page was loaded at <?php echo gmdate("Y-m-d H:i:s"); ?> GMT)
</div>
<div>
<label for="PartyDuration" class="label-large">Duration (in hours):</label>
<?php echo $html->input('Party/duration', array('size' => 5)); ?>
</div>
<p>Enter a website (complete with http://) that guests can visit to learn more about your party. If you don't have one, simply leave it blank.</p>
<div>
<label for="PartyWebsite" class="label-large">Web site:</label>
<?php echo $html->input('Party/website', array('size' => 40)); ?>
<?php echo $html->tagErrorMsg('Party/website', 'Invalid URL.')?>
</div>
<p>If you choose to make your party invite only, you will have to send guests an invite containing a random invite code to allow them to join your party.</p>
<div>
<label for="PartyInviteonly" class="label-large">Invite only</label>
<?php echo $html->checkbox('Party/inviteonly'); ?>
</div>
<?php if(GMAP_API_KEY != null): ?>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=<?php echo GMAP_API_KEY; ?>"
type="text/javascript"></script>
<script src="<?php echo $html->url('/js/maps.js'); ?>" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
function update() {
var loc = document.getElementById("location").value;
geocode(loc);
}
function capture(event) {
if (event.keyCode == 13) {
event.preventDefault();
update();
}
}
//]]>
</script>
<p>Drag the map or the marker to specify a location. Set the zoom by using the '+' or '-' buttons on the left.</p>
<p id="map" class="med-map-r"></p>
<?php echo $html->hidden('Party/lat', array('id' => 'lat'));
echo $html->hidden('Party/long', array('id' => 'long'));
echo $html->hidden('Party/zoom', array('id' => 'zoom'));
echo $html->hidden('Party/geocoded', array('id' => 'geocoded', 'value' => 0)); ?>
<?php endif; ?>
<div>
<label for="PartyNotes" class="label-large">Additional Notes</label>
<?php echo $html->textarea('Party/notes', array('rows' => 10, 'cols' => 50)); ?>
</div>
<?php echo $html->submit('Create Party'); ?>
</form>

View File

@@ -1,7 +0,0 @@
<h1>Cancel Party</h1>
<div class="error">Warning! Canceling your party will remove all guests and send them a cancellation notice.</div>
<p>If you're sure you want to cancel your party simply hit the button below. Otherwise,
<a href="<?php echo $html->url('/parties/view/'.$pid); ?>">click here</a> to return to your party.</p>
<form action="<?php echo $html->url('/parties/cancel/'.$pid); ?>" method="post">
<?php echo $html->hidden('Party/confcancel', array('value' => 1)).$html->submit('Cancel Party'); ?>
</form>

View File

@@ -1,131 +0,0 @@
<form class="fxform" action="<?php echo $html->url('/parties/edit/'.$party['Party']['id']); ?>" method="post">
<?php echo $html->hidden('Party/id'); ?>
<h1>Details</h1>
<div>
<label for="PartyName" class="label-large">Party Name:</label>
<?php echo $html->input('Party/name', array('size' => 40)); ?>
</div>
<div>
<label for="PartyVname" class="label-large">Venue Name:</label>
<?php echo $html->input('Party/vname', array('size' => 40)); ?>
</div>
<div>
<label for="PartyWebsite" class="label-large">Web site:</label>
<?php echo $html->input('Party/website', array('size' => 40)); ?>
<?php echo $html->tagErrorMsg('Party/website', 'Invalid URL.')?>
</div>
<div>
<label for="PartyAddress" class="label-large">Address:</label>
<?php echo $html->input('Party/address', array('size' => 40, 'id' => 'location', 'onkeypress' => 'capture(event)', 'onblur' => 'update()')); ?>
<div id="suggest" style="display: none">Did you mean <span style="font-style: italic"><a id="suggest2" href="#" onclick=""></a></span>?</div>
</div>
<?php if(GMAP_API_KEY != null): ?>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=<?php echo GMAP_API_KEY; ?>"
type="text/javascript"></script>
<script src="<?php echo $html->url('/js/maps.js'); ?>" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
function update(aSuggest) {
var loc;
if (!aSuggest)
loc = document.getElementById("location").value;
else
loc = aSuggest;
if (loc != "")
geocode(loc);
}
function capture(event) {
if (event.keyCode == 13) {
event.preventDefault();
update();
}
}
//]]>
</script>
<p id="map" class="med-map-r"></p>
<div>
<label for="PartyNotes" class="label-large">Additional Notes:</label>
<?php echo $html->textarea('Party/notes', array('rows' => 10, 'cols' => 50)); ?>
</div>
<h1>Date</h1>
<div>
<label for="PartyYear" class="label-large">Date:</label>
<?php echo $html->yearOptionTag('Party/year', null, date('Y'), MAX_YEAR, $date['year'], null, null, false); ?>-<?php echo $html->hourOptionTag('Party/month', null, false, $date['mon']); ?>-<?php echo $html->dayOptionTag('Party/day', null, $date['day'], null, false); ?>
</div>
<div>
<label for="PartyHour" class="label-large">Time:</label>
<?php echo $html->hourOptionTag('Party/hour', null, true, $date['hour']);?>:<?php echo $html->minuteOptionTag('Party/minute', null, $date['min']);?>
<?php echo $html->radio('Party/confirmed', array(0 => 'Tentative', 1 => 'Confirmed')); ?>
</div>
<div>
<label for="PartyTz" class="label-large">Timezone:</label>
<?php
$tzs = array('-12' => 'GMT-12',
'-11' => 'GMT-11',
'-10' => 'GMT-10',
'-9' => 'GMT-9',
'-8' => 'GMT-8',
'-7' => 'GMT-7',
'-6' => 'GMT-6',
'-5' => 'GMT-5',
'-4' => 'GMT-4',
'-3' => 'GMT-3',
'-2' => 'GMT-2',
'-1' => 'GMT-1',
'0' => 'GMT+0',
'1' => 'GMT+1',
'2' => 'GMT+2',
'3' => 'GMT+3',
'4' => 'GMT+4',
'5' => 'GMT+5',
'6' => 'GMT+6',
'7' => 'GMT+7',
'8' => 'GMT+8',
'9' => 'GMT+9',
'10' => 'GMT+10',
'11' => 'GMT+11',
'12' => 'GMT+12',
'13' => 'GMT+13');
echo $html->selectTag('Party/tz', $tzs, $date['tz'], null, null, false);?>
(current time is <?php echo gmdate("Y-m-d H:i:s"); ?>GMT)
</div>
<div>
<label for="PartyDuration" class="label-large">Duration (in hours):</label>
<?php echo $html->input('Party/duration', array('size' => 5)); ?>
</div>
<h1><span style="color: #0063dc">flick</span><span style="color: #ff0084">r<sup style="font-size: 8px">TM</sup></span> Options</h1>
<p>To show photos of your party, simply tag them with <strong><?php echo FLICKR_TAG_PREFIX.$party['Party']['id'] ?></strong> and fill out the information below.</p>
<div>
<label for="PartyUseflickr" class="label-large">Show photostream:</label>
<?php echo $html->checkbox('Party/useflickr'); ?>
</div>
<p>If you choose to show photos from anyone using your party's tag please note that no photos will show until two or more people are using the tag.</p>
<div>
<label for="PartyFlickrperms" class="label-large">Show:</label>
<?php echo $html->radio('Party/flickrperms', array(0 => 'Only my photos', 1 => 'Anyone\'s photos')); ?>
</div>
<div>
<label for="PartyFlickrusr" class="label-large">Flickr username:</label>
<?php echo $html->input('Party/flickrusr', array('size' => 40)); ?>
</div>
<h1>Privacy</h1>
<div>
<label for="PartyInviteonly" class="label-large">Invite only:</label>
<?php echo $html->checkbox('Party/inviteonly'); ?>
</div>
<div>
<label for="PartyGuestcomments" class="label-large">Limit comments to party guests only:</label>
<?php echo $html->checkbox('Party/guestcomments'); ?>
</div>
<br/>
<?php echo $html->hidden('Party/lat', array('id' => 'lat'));
echo $html->hidden('Party/long', array('id' => 'long'));
echo $html->hidden('Party/zoom', array('id' => 'zoom'));
echo $html->hidden('Party/geocoded', array('id' => 'geocoded', 'value' => 0)); ?>
<?php endif; ?>
<?php echo $html->submit('Update'); ?>
</form>

View File

@@ -1,19 +0,0 @@
<?php if(GMAP_API_KEY != null): ?>
<div style="text-align: center">
<form action="<?php echo $html->url('/parties/'); ?>" class="fxform" onsubmit="search(event)" method="post">
<label for="PartyMloc"><strong>Find a party:</strong></label>
<?php echo $html->input('Party/mloc', array('size' => 60, 'id' => 'location')).' '.$html->submit('Search'); ?>
<div id="locerr" class="info" style="display: none">Did you mean: <a id="locerrlink" onclick="geocode_suggest()" href="#"></a>? <a href="#" onclick="shide()"><span style="font-size: x-small">(close)</span></a></div>
</form>
</div>
<br/>
<script src="http://maps.google.com/maps?file=api&amp;v=2.67&amp;key=<?php echo GMAP_API_KEY; ?>"
type="text/javascript"></script>
<script src="<?php echo $html->url('/js/maps.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $html->url('/parties/js'); ?>" type="text/javascript"></script>
<div id="map" class="large-map"></div>
<div id="map-load" style="visibility: hidden" class="load">
<img src="<?php echo $html->url('/img/throbber.gif'); ?>"/>
Loading...
</div>
<?php endif; ?>

View File

@@ -1,9 +0,0 @@
<h1>Invite a guest</h1>
<p>To invite a guest, simply enter their email address into the field below,
or hand them a link to
<strong><?php echo $inviteurl; ?></strong></p>
<form action="<?php echo $html->url('/parties/invite/'.$partyid) ?>" method="post">
<label for="PartyEinvite">Guest's email address:</label>
<?php echo $html->input('Party/einvite')."\n".$html->submit('Submit')."\n"; ?>
<?php echo $html->tagErrorMsg('Party/einvite', 'Invalid email address')?>
</form>

View File

@@ -1,36 +0,0 @@
<h1>Confirm Invite</h1>
<?php if (isset($party) && !isset($confirm_only)): ?>
<p>You've been invited to attend <a href="<?php echo $html->url('/parties/view/'.$party['Party']['id']); ?>"><?php echo $party['Party']['name']; ?></a>.
To join this party please select one of the options below, or <a href="<?php echo $html->url('/parties/invited/cancel/');?>">click here</a> to cancel this invitation.</p>
<div style="text-align: center">
<div style="width: 50%; float: left;">
<h2>New User</h2>
<p>Simply register for an account, and you'll be added as a guest as soon as you finish.
<a href="<?php echo $html->url('/users/register'); ?>">Create account &raquo;</a></p>
</div>
<div style="width: 50%; float: right">
<h2>Existing User</h2>
<p>Login to add yourself to the guest list.</p>
<form class="fxform" action="<?php echo $html->url('/users/login'); ?>" method="post">
<div>
<label class="label-large" for="UserEmail">Email Address:</label>
<?php echo $html->input('User/email', array('size' => 20)); ?>
</div>
<div>
<label class="label-large" for="UserPassword">Password:</label>
<?php echo $html->password('User/password', array('size' => 20)).
$html->hidden('User/icode', array('value' => $icode));?>
</div>
<div>
<?php echo $html->submit('Login'); ?>
</div>
</form>
</div>
<div style="clear: both;"></div>
</div>
<?php endif;
if (isset($party) && isset($confirm_only)): ?>
<p>You've been invited to attend <a href="<?php echo $html->url('/parties/view/'.$party['Party']['id']); ?>"><?php echo $party['Party']['name']; ?></a>.
To join this party, <a href="<?php echo $html->url('/parties/invited/'.$icode.'/confirm');?>">click here</a>, or cancel this invitation by <a href="<?php echo $html->url('/parties/invited/cancel/');?>">clicking here</a>.</p>
<?php endif; ?>

View File

@@ -1,11 +0,0 @@
<?php if (isset($party)): ?>
<strong><?php echo $party['Party']['name']?></strong><br/><?php echo $party['Party']['vname']; ?><br/><a href="<?php echo $html->url('/parties/view/'.$party['Party']['id'])?>">View Party</a>
<?php else: ?>
function addParties() {
<?php foreach ($parties as $party):
if (!empty($party['Party']['lat']) && !empty($party['Party']['long']) && !$party['Party']['canceled']): ?>
addParty(<?php echo $party['Party']['lat'];?>, <?php echo $party['Party']['long']?>, <?php echo $party['Party']['id']; ?>);
<?php endif; endforeach;?>
}
//
<?php endif; ?>

View File

@@ -1,140 +0,0 @@
<?php
if (isset($party)): ?>
<h1><?php echo $party['Party']['name']; ?></h1>
<br/>
<?php if ($party['Party']['canceled']): ?>
<div class="error">This party has been canceled</div>
<?php endif; ?>
Host: <a href="<?php echo $html->url('/users/view/'.$party['Party']['owner']).'">'.$host; ?></a><br/>
<?php
if (!empty($party['Party']['address']))
echo 'Location: '.$party['Party']['address']."<br/>\n";
if (!empty($party['Party']['vname']))
echo 'Venue: '.$party['Party']['vname']."<br/>\n";
echo 'Date: '.(($party['Party']['confirmed'] == 1) ? gmdate('Y-m-d h:ia', $party['Party']['date'] + (@$_SESSION['User']['tz'] * 60 * 60))." GMT".@$_SESSION['User']['tz'] : "TBA")."<br/>\n";
echo 'Duration: '.$party['Party']['duration'].' hour'.(($party['Party']['duration'] == 1) ? '' : 's')."\n<br/>";
if (!empty($party['Party']['website']) && preg_match("/^(http|https)\:\/\//i", $party['Party']['website']))
echo 'Website: <a href="'.$party['Party']['website'].'" rel="nofollow">'.$party['Party']['website']."</a><br/>\n";
if (!empty($party['Party']['notes']))
echo 'Notes: '.$party['Party']['notes']."<br/>\n";
?>
<br/>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=<?php echo GMAP_API_KEY; ?>"
type="text/javascript"></script>
<script src="<?php echo $html->url('/js/maps.js'); ?>" type="text/javascript"></script>
<div id="map" class="small-map"></div>
<h1>Who's coming</h1>
<div>
<?php if (!empty($guests)):
$i = 0;
$c = count($guests) - 1;
foreach ($guests as $guest): ?>
<a href="<?php echo $html->url('/users/view/'.$guest['users']['id']); ?>"><?php echo $guest['users']['name']; ?></a><?php echo ($i < $c) ? ", " : ""; ?>
<?php $i++;
endforeach;
else:
echo "No guests yet, be the first!";
endif;
if (isset($_SESSION['User']['id']) && @$_SESSION['User']['id'] != $party['Party']['owner'] && ($party['Party']['inviteonly'] != 1 || $isguest && !$party['Party']['canceled'])):?>
<br/><br/>
<form action="<?php
echo $html->url('/parties/'.((!$isguest) ? 'rsvp/' : 'unrsvp/').$party['Party']['id']); ?>" method="post">
<?php if(!$isguest): ?>
<button>Count me in!</button>
<?php else: ?>
<button>Remove me</button>
<?php endif; ?>
</form>
<?php endif; ?>
<? if ($party['Party']['inviteonly'] == 1 && (!$isguest && @$_SESSION['User']['id'] != $party['Party']['owner'] && !$party['Party']['canceled'])):?>
<p>This party is invite only. You'll need an invite code from the host to join in.</p>
<?php endif; ?>
</div>
<?php if (@$_SESSION['User']['id'] == $party['Party']['owner']):?>
<h1>Party options</h1>
<a href="<?php echo $html->url('/parties/edit/'.$party['Party']['id']);?>">Edit party</a>
<?php if (!$party['Party']['canceled']): ?>| <a href="<?php echo $html->url('/parties/invite/'.$party['Party']['id']);?>">Invite a guest</a>
<?php endif; echo (($party['Party']['canceled'] == 1) ? ' | <a href="'.$html->url('/parties/uncancel/'.$party['Party']['id']).'">
Reactivate this party</a>' : '| <a href="'.$html->url('/parties/cancel/'.$party['Party']['id']).'" onclick="return confirm(\'Are you sure you want to cancel your party?\')"><span style="color: #bc1313">Cancel this party</span></a>'); ?>
<?php endif; ?>
<?php if (isset($flickr)): ?>
<h1 id="photos">Photos <a title="Photo Feed" href="<?php echo $html->url('/feeds/photos/'.$party['Party']['id']); ?>"><img src="<?php echo $html->url('/img/feed16.png'); ?>" alt="Atom"/></a></h1>
<div style="text-align: center">
<?php if (empty($flickr)): ?>
<p>No photos yet. Tag your flickr pictures with <?php echo FLICKR_TAG_PREFIX.$party['Party']['id']; ?> to display them here.</p>
<?php else:
foreach ($flickr as $pic): ?>
<a href="http://www.flickr.com/photos/<?php echo $pic['owner']."/".$pic['id']."/" ?>"><img src="http://static.flickr.com/<?php echo $pic['server']."/".$pic['id']."_".$pic['secret']."_s.jpg" ?>" title="<?php echo $pic['title']; ?>"/></a>
<?php endforeach;
endif; ?>
<br/>
</div>
<?php endif;
if (!empty($comments)): ?>
<h1 id="comments">Comments <a title="Comment Feed" href="<?php echo $html->url('/feeds/comments/'.$party['Party']['id']); ?>"><img src="<?php echo $html->url('/img/feed16.png'); ?>" alt="RSS"/></a></h1>
<?php $i = 0;
foreach ($comments as $comment):
if ($i % 2 == 0)
$class = "";
else
$class = "comment-mod";
$i++;?>
<div id="c<?php echo $comment['comments']['cid'];?>" class="comment <?php echo $class;?>">
<span class="comment-content"><?php echo $comment['comments']['text']; ?></span>
<span class="comment-tag"><br/><br/>Posted by <a href="<?php echo $html->url('/users/view/'.$comment['users']['uid']); ?>">
<?php echo $comment['users']['name']; ?></a> on <?php echo gmdate('Y-m-d h:ia', $comment['comments']['time'] + (@$_SESSION['User']['tz'] * 60 * 60)); ?></span>
</span>
</div>
<?php endforeach;
endif;
if (isset($_SESSION['User'])):
if (($party['Party']['guestcomments'] && $isguest) || !$party['Party']['guestcomments'] || @$_SESSION['User']['id'] == $party['Party']['owner']): ?>
<h1>Add a comment</h1>
<form action="<?php echo $html->url('/comments/add/'.$party['Party']['id'].'/'.$_SESSION['User']['id']); ?>" method="post">
<div>
<?php echo $html->textarea('Comment/text', array('rows' => 10, 'cols' => 50))."<br/>".$html->submit('Submit'); ?>
</div>
</form>
<?php endif;
endif;
endif; ?>
<?php if (isset($parties)):
if (isset($prev))
echo '<a href="'.$html->url('/parties/view/all/'.$prev).'">&laquo; Previous Page</a> ';
if (isset($prev) && isset($next))
echo ' | ';
if (isset($next))
echo '<a href="'.$html->url('/parties/view/all/'.$next).'">Next Page &raquo;</a>';
$i = 0;
foreach ($parties as $party):
if ($party['Party']['canceled'] != 1): ?>
<div>
<h1><?php echo $party['Party']['name']; ?></h1>
<p>
<?php
if (!empty($party['Party']['address']))
echo 'Location: '.$party['Party']['address']."<br/>\n";
if (!empty($party['Party']['vname']))
echo 'Venue: '.$party['Party']['vname']."<br/>\n";
echo 'Date: '.(($party['Party']['confirmed'] == 1) ? gmdate('Y-m-d h:ia', $party['Party']['date'] + (@$_SESSION['User']['tz'] * 60 * 60))." GMT".@$_SESSION['User']['tz'] : "TBA")."<br/>\n";
echo '<a href="'.$html->url('/parties/view/'.$party['Party']['id']).'">View Party</a>';
?>
</p>
</div>
<?php endif; endforeach;
if (isset($prev))
echo '<a href="'.$html->url('/parties/view/all/'.$prev).'">&laquo; Previous Page</a> ';
if (isset($prev) && isset($next))
echo ' | ';
if (isset($next))
echo '<a href="'.$html->url('/parties/view/all/'.$next).'">Next Page &raquo;</a>';
endif;?>

View File

@@ -1,105 +0,0 @@
<?php if ($error): ?>
<div class="error">
There was an error in your submission, please try again.
</div>
<?php endif; ?>
<form class="fxform" action="<?php echo $html->url('/users/edit'); ?>" method="post">
<?php echo $html->hidden('User/id'); ?>
<h1>Profile</h1>
<div>
<label for="UserName" class="label-large">Name:</label>
<?php echo $html->input('User/name', array('size' => 40)); ?>
<?php echo $html->tagErrorMsg('User/name', 'You must enter a name.')?>
</div>
<div>
<label for="UserWebsite" class="label-large">Website:</label>
<?php echo $html->input('User/website', array('size' => 40)); ?>
<?php echo $html->tagErrorMsg('User/website', 'Invalid URL.')?>
</div>
<div>
<label for="location" class="label-large">Location:</label>
<?php echo $html->input('User/location', array('id' => 'location', 'size' => 40, 'onkeypress' => 'capture(event)')); ?>
</div>
<div>
<label for="UserTz" class="label-large">Timezone:</label>
<?php
$tzs = array('-12' => 'GMT-12',
'-11' => 'GMT-11',
'-10' => 'GMT-10',
'-9' => 'GMT-9',
'-8' => 'GMT-8',
'-7' => 'GMT-7',
'-6' => 'GMT-6',
'-5' => 'GMT-5',
'-4' => 'GMT-4',
'-3' => 'GMT-3',
'-2' => 'GMT-2',
'-1' => 'GMT-1',
'0' => 'GMT+0',
'1' => 'GMT+1',
'2' => 'GMT+2',
'3' => 'GMT+3',
'4' => 'GMT+4',
'5' => 'GMT+5',
'6' => 'GMT+6',
'7' => 'GMT+7',
'8' => 'GMT+8',
'9' => 'GMT+9',
'10' => 'GMT+10',
'11' => 'GMT+11',
'12' => 'GMT+12',
'13' => 'GMT+13');
echo $html->selectTag('User/tz', $tzs, $utz, null, null, false);
?>
(current time is <?php echo gmdate("Y-m-d H:i:s"); ?> GMT)
</div>
<?php if(GMAP_API_KEY != null): ?>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=<?php echo GMAP_API_KEY; ?>"
type="text/javascript"></script>
<script src="<?php echo $html->url('/js/maps.js'); ?>" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
function update() {
var loc = document.getElementById("location").value;
geocode(loc);
}
function capture(event) {
if (event.keyCode == 13) {
event.preventDefault();
update();
}
}
//]]>
</script>
<p id="map" class="small-map"></p>
<?php echo $html->hidden('User/lat', array('id' => 'lat'));
echo $html->hidden('User/long', array('id' => 'long'));
echo $html->hidden('User/zoom', array('id' => 'zoom')); ?>
<?php endif; ?>
<h1>Privacy</h1>
<div>
<label for="UserShowemail" class="label-large">Show email:</label>
<?php echo $html->checkbox('User/showemail'); ?><br/>
</div>
<div>
<label for="UserShowloc" class="label-large">Show location:</label>
<?php echo $html->checkbox('User/showloc'); ?><br/>
</div>
<div>
<label for="UserShowmap" class="label-large">Show map:</label>
<?php echo $html->checkbox('User/showmap'); ?><br/>
</div>
<h1>Password</h1>
<div>
<label for="UserPassword" class="label-large">New password:</label>
<?php echo $html->password('User/password', array('size' => 20, 'autocomplete' => 'off')); ?>
</div>
<div>
<label for="UserConfpassword" class="label-large">Confirm new password:</label>
<?php echo $html->password('User/confpassword', array('size' => 20, 'autocomplete' => 'off')); ?>
<?php echo $html->tagErrorMsg('User/confpassword', 'The supplied passwords do not match!')?>
</div>
<?php echo $html->submit('Update'); ?>
</form>

View File

@@ -1,61 +0,0 @@
<h1>My Profile</h1>
<br/>
<h2>Parties I'm attending</h2>
<p>
<?php
$num_parties = count($parties);
if ($num_parties == 0)
echo 'None yet. <a href="'.$html->url('/parties/view/all').'">Find one!</a>';
else {
$c = $num_parties - 1;
$i = 0;
foreach ($parties as $party) {
echo '<a href="'.$html->url('/parties/view/'.$party['parties']['id']).'">'.$party['parties']['name'].'</a>';
echo ($i < $c) ? ', ' : '';
$i++;
}
}
?>
</p>
<h2>Parties I'm hosting</h2>
<p>
<?php
$num_parties = count($hparties);
if (empty($hparties))
echo 'None yet. <a href="'.$html->url('/parties/add').'">Create one!</a>';
else {
$c = $num_parties - 1;
$i = 0;
foreach ($hparties as $party) {
echo '<a href="'.$html->url('/parties/view/'.$party['parties']['id']).'">'.$party['parties']['name'].'</a>';
echo ($i < $c) ? ', ' : '';
$i++;
}
}
?>
<h2>Parties I've been invited to</h2>
<p>
<?php
$num_parties = count($iparties);
if (empty($iparties))
echo 'None yet.';
else {
$c = $num_parties - 1;
$i = 0;
foreach ($iparties as $party) {
echo '<a href="'.$html->url('/parties/view/'.$party['parties']['id']).'">'.$party['parties']['name'].'</a>';
echo ($i < $c) ? ', ' : '';
$i++;
}
}
?>
</p>
<h2>Account Options</h2>
<p>
<a href="<?php echo $html->url('/users/edit'); ?>">Edit my account</a>
<br/>
<a href="<?php echo $html->url('/users/logout'); ?>">Logout</a>
</p>

View File

@@ -1,17 +0,0 @@
<h1>Login</h1>
<form class="fxform" action="<?php echo $html->url('/users/login'); ?>" method="post">
<div>
<label class="label-large" for="UserEmail">Email Address:</label>
<?php echo $html->input('User/email', array('size' => 40)); ?>
</div>
<div>
<label class="label-large" for="UserPassword">Password:</label>
<?php echo $html->password('User/password', array('size' => 40)); ?>
</div>
<div>
<?php echo $html->submit('Login'); ?>
</div>
<p>
<a href="<?php echo $html->url('/users/register'); ?>">Create an account</a> | <a href="<?php echo $html->url('/users/recover/password'); ?>">Forgot your password?</a>
</p>
</form>

View File

@@ -1,26 +0,0 @@
<h1><?php echo $atitle; ?></h1>
<form class="fxform" action="<?php
if (isset($reset))
echo $html->url('/users/recover/reset/'.$code);
else
echo $html->url('/users/recover/'.$url); ?>" method="post">
<?php if (isset($error)): ?>
<div class="error">
<?php echo $error; ?>
</div>
<?php endif; ?>
<div>
<?php if (!$hideInput): ?>
<label class="label-large" for="UserEmail">Email address:</label>
<?php echo $html->input('User/email'); ?>
<?php endif;
if (isset($reset)): ?>
<label class="label-large" for="UserPassword">New password:</label>
<?php echo $html->password('User/password'); ?>
<br/>
<label class="label-large" for="UserConfirm">Confirm password:</label>
<?php echo $html->password('User/confirm'); ?>
<?php endif; ?>
</div>
<?php echo $html->submit('Submit'); ?>
</form>

View File

@@ -1,110 +0,0 @@
<h1>Register</h1>
<form class="fxform" action="<?php echo $html->url('/users/register'); ?>" method="post">
<p>Your e-mail address is used as your username to login. You'll also receive a confirmation e-mail to
this address. In order for your account to be activated successfully, you must specify a valid e-mail address.</p>
<div>
<label class="label-large" for="UserEmail">Email address<span class="required">*</span>:</label>
<?php echo $html->input('User/email', array('size' => 40)); ?>
<?php echo $html->tagErrorMsg('User/email', 'The email address you entered is invalid or has already been registered.')?>
</div>
<div>
<label class="label-large" for="UserConfemail">Confirm Email address<span class="required">*</span>:</label>
<?php echo $html->input('User/confemail', array('size' => 40)); ?>
<?php echo $html->tagErrorMsg('User/confemail', 'The email addresses you entered do not match.')?>
</div>
<p>How do you want to be known to visitors of <?php echo APP_NAME; ?>?</p>
<div>
<label class="label-large" for="UserName">Name<span class="required">*</span>:</label>
<?php echo $html->input('User/name', array('size' => 40)); ?>
<?php echo $html->tagErrorMsg('User/name', 'You must enter a name.')?>
</div>
<p>If you choose to enter it, your location will be shown on your profile. This
field is optional.
<div>
<label class="label-large" for="UserLocation">Location:</label>
<?php echo $html->input('User/location', array('id' => 'location', 'size' => 40, 'onkeypress' => 'capture(event)', 'onblur' => 'update()')); ?>
<div id="locerr" class="info" style="display: none">Did you mean: <a id="locerrlink" onclick="geocode_suggest()" href="#"></a>? <a href="#" onclick="shide()"><span style="font-size: x-small">(close)</span></a></div>
</div>
<p>If you have a website, enter the URL here. (including the http:// ) Your website will be
shown to site visitors on your author profile page. This field is optional; if you don't
have a website or don't want it linked to from <?php echo APP_NAME; ?>, leave this box blank.</p>
<div>
<label class="label-large" for="UserWebsite">Website:</label>
<?php echo $html->input('User/website', array('size' => 40)); ?>
<?php echo $html->tagErrorMsg('User/website', 'Invalid URL.')?>
</div>
<div>
<label class="label-large" for="UserTz">Timezone<span class="required">*</span>:</label>
<?php
$tzs = array('-12' => 'GMT-12',
'-11' => 'GMT-11',
'-10' => 'GMT-10',
'-9' => 'GMT-9',
'-8' => 'GMT-8',
'-7' => 'GMT-7',
'-6' => 'GMT-6',
'-5' => 'GMT-5',
'-4' => 'GMT-4',
'-3' => 'GMT-3',
'-2' => 'GMT-2',
'-1' => 'GMT-1',
'0' => 'GMT+0',
'1' => 'GMT+1',
'2' => 'GMT+2',
'3' => 'GMT+3',
'4' => 'GMT+4',
'5' => 'GMT+5',
'6' => 'GMT+6',
'7' => 'GMT+7',
'8' => 'GMT+8',
'9' => 'GMT+9',
'10' => 'GMT+10',
'11' => 'GMT+11',
'12' => 'GMT+12',
'13' => 'GMT+13');
echo $html->selectTag('User/tz', $tzs, $utz, null, null, false);
?>
(this page was loaded at <?php echo gmdate("Y-m-d H:i:s"); ?> GMT)
</div>
<div>
<label class="label-large" for="password">Password<span class="required">*</span>:</label>
<?php echo $html->password('User/password', array('size' => 40)); ?>
<?php echo $html->tagErrorMsg('User/password', 'You must enter a password.')?>
</div>
<div>
<label class="label-large" for="confpassword">Confirm password<span class="required">*</span>:</label>
<?php echo $html->password('User/confpass', array('size' => 40)); ?>
<?php echo $html->tagErrorMsg('User/confpass', 'The passwords you supplied do not match.')?>
</div>
<?php if(GMAP_API_KEY != null): ?>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=<?php echo GMAP_API_KEY; ?>"
type="text/javascript"></script>
<script src="<?php echo $html->url('/js/maps.js'); ?>" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
function update() {
var loc = document.getElementById("location").value;
geocode(loc);
}
function capture(event) {
if (event.keyCode == 13) {
event.preventDefault();
update();
}
}
//]]>
</script>
<p><span class="required">*</span> Required field</p>
<p>Drag the map or the marker to specify your location. Set the zoom by using the '+' or '-' buttons on the left.</p>
<p id="map" class="med-map-r"></p>
<div>
<?php echo $html->hidden('User/lat', array('id' => 'lat'));
echo $html->hidden('User/long', array('id' => 'long'));
echo $html->hidden('User/zoom', array('id' => 'zoom'));
echo $html->hidden('User/geocoded', array('id' => 'geocoded', 'value' => 0));
echo $html->hidden('User/icode', array('value' => @$icode)); ?>
</div>
<?php endif; ?>
<?php echo $html->submit('Register'); ?>
</form>

View File

@@ -1,44 +0,0 @@
<?php
if (!empty($user['User']['name']))
echo "<h1>".$user['User']['name']."</h1><br/>";
if ($user['User']['showemail'] == 1 && @$_SESSION['User'])
echo "Email: ".$user['User']['email']."<br/>";
if ($user['User']['showloc'] == 1 && !empty($user['User']['location']))
echo "Location: ".$user['User']['location']."<br/>";
if (!empty($user['User']['website']) && preg_match("/^(http|https)\:\/\//i", $user['User']['website']))
echo 'Website: <a href="'.$user['User']['website'].'" rel="nofollow">'.$user['User']['website'].'</a><br/>';
if (!empty($parties)) {
echo "Attending: ";
$c = count($parties) - 1;
$i = 0;
foreach ($parties as $party) {
echo '<a href="'.$html->url('/parties/view/'.$party['parties']['id']).'">'.$party['parties']['name'].'</a>';
echo ($i < $c) ? ', ' : '<br/>';
$i++;
}
}
if (!empty($hparties)) {
echo "Hosting: ";
$c = count($hparties) - 1;
$i = 0;
foreach ($hparties as $party) {
echo '<a href="'.$html->url('/parties/view/'.$party['parties']['id']).'">'.$party['parties']['name'].'</a>';
echo ($i < $c) ? ', ' : '<br/>';
$i++;
}
}
?>
<?php if(isset($map) && $user['User']['showmap'] == 1): ?>
<br/>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=<?php echo GMAP_API_KEY; ?>" type="text/javascript"></script>
<script src="<?php echo $html->url('/js/maps.js'); ?>" type="text/javascript"></script>
<div id="map" style="height: 200px; width: 350px;"></div>
<?php endif; ?>

View File

@@ -1,6 +0,0 @@
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>

View File

@@ -1,101 +0,0 @@
<?php
/* SVN FILE: $Id: css.php,v 1.4 2006-10-08 03:39:23 reed%reedloden.com Exp $ */
/**
* Short description for file.
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2006, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.app.webroot
* @since CakePHP v 0.2.9
* @version $Revision: 1.4 $
* @modifiedby $LastChangedBy: phpnut $
* @lastmodified $Date: 2006-10-08 03:39:23 $
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
header('HTTP/1.1 404 Not Found');
}
/**
* Enter description here...
*/
require(LIBS . 'folder.php');
require(LIBS . 'legacy.php');
/**
* Enter description here...
*
* @param unknown_type $path
* @param unknown_type $name
* @return unknown
*/
function make_clean_css($path, $name) {
require(VENDORS . 'csspp' . DS . 'csspp.php');
$data =file_get_contents($path);
$csspp =new csspp();
$output=$csspp->compress($data);
$ratio =100 - (round(strlen($output) / strlen($data), 3) * 100);
$output=" /* file: $name, ratio: $ratio% */ " . $output;
return $output;
}
/**
* Enter description here...
*
* @param unknown_type $path
* @param unknown_type $content
* @return unknown
*/
function write_css_cache($path, $content) {
if (!is_dir(dirname($path))) {
mkdir(dirname($path));
}
$cache=new File($path);
return $cache->write($content);
}
if (preg_match('|\.\.|', $url) || !preg_match('|^ccss/(.+)$|i', $url, $regs)) {
die('Wrong file name.');
}
$filename = 'css/' . $regs[1];
$filepath = CSS . $regs[1];
$cachepath = CACHE . 'css' . DS . str_replace(array('/','\\'), '-', $regs[1]);
if (!file_exists($filepath)) {
die('Wrong file name.');
}
if (file_exists($cachepath)) {
$templateModified=filemtime($filepath);
$cacheModified =filemtime($cachepath);
if ($templateModified > $cacheModified) {
$output=make_clean_css($filepath, $filename);
write_css_cache($cachepath, $output);
} else {
$output = file_get_contents($cachepath);
}
} else {
$output=make_clean_css($filepath, $filename);
write_css_cache($cachepath, $output);
}
header("Date: " . date("D, j M Y G:i:s ", $templateModified) . 'GMT');
header("Content-Type: text/css");
header("Expires: " . gmdate("D, j M Y H:i:s", time() + DAY) . " GMT");
header("Cache-Control: cache"); // HTTP/1.1
header("Pragma: cache"); // HTTP/1.0
print $output;
?>

View File

@@ -1,230 +0,0 @@
.error, .error_message {
background: #ffa5a5;
border: 1px solid red;
text-align: center;
font-weight: bold;
padding: 5px;
margin: 5px 0 5px 0;
}
.form_error {
background: #ffa5a5;
border: 1px solid red;
}
.info {
background: #fffe94;
border: 1px solid yellow;
text-align: center;
font-weight: bold;
padding: 5px;
margin: 5px 0 5px 0;
}
.att { color: #d4d4d4; }
#f-left {
width: 75%;
float: left;
}
#f-right {
width: 25%;
float: right;
}
.cbox {
text-align: center;
border: 1px solid #808080;
background: #eee;
padding: 5px;
margin: 10px;
}
.cbox a { outline: none; }
.ctxt {
font-size: 200%;
font-weight: bold;
}
.cfeed {
position: relative;
bottom: 15px;
float: right;
height: 16px;
width: 16px;
}
.ifeed {
position: relative;
bottom: 15px;
float: right;
height: 16px;
width: 34px;
}
.required { color: red; font-weight: bold;}
.fxform div { margin: 1em 0; }
.label-large, .label-medium, .label-small {
border-bottom: 1px dashed #eee;
float: left;
font-weight: bold;
}
.label-large { width: 14em; }
.large-map { width: 700px; height: 500px; margin: 0 auto; }
.med-map-r { width: 500px; height: 300px; margin: 0 auto; }
.med-map-r div { margin: 0; }
.small-map { width: 400px; height: 200px;}
.small-map div { margin: 0; }
.load { width: 700px; margin: 0 auto; padding-top: 5px; }
.comment {
border: 1px solid #ccc;
border-top: 0;
padding: 10px 5px 0 5px;
}
.comment-mod { background: #ecedf3; }
.comment-content { font-size: 125%; padding-bottom: 50px; }
.comment-tag { font-size: 75%; }
h1 { border-bottom: 1px solid #ccc;
margin-bottom: 0;}
#footer { padding: 30px 0 20px 0; }
img { border: none }
body {
background: #fff url("../img/body_back.png") top repeat-x;
color: #555;
font-family: arial, sans-serif;
margin: 0 10px;
padding: 0;
font-size: x-small;
voice-family: "\"}\"";
voice-family: inherit;
font-size: small;
}
a { color: #34518c; text-decoration: none; }
a:hover { text-decoration: underline; }
#container {
width: 740px;
margin: 0 auto;
}
#mozilla-com a {
float: right;
display: block;
outline: none;
text-indent: -5000em;
width: 110px;
height: 25px;
text-decoration: none;
background: url("../img/mozilla-org.png") no-repeat;
}
#key-menu {
background: #B2C1C8 url("../img/header-bottom.gif") 0 100% no-repeat;
padding: 0 0 10px 0;
overflow: auto;
margin-bottom: 1em;
}
* html #key-menu {
overflow: visible;
height: 1px;
}
#key-menu ul, #key-menu li {
margin: 0;
padding: 0;
list-style: none;
}
#key-menu ul {
padding: 14px 12px 0 12px;
background: url("../img/header-top.gif") 0 0 no-repeat;
}
#key-menu li {
float: left;
background: url("../img/tabs.gif") 100% -50px;
padding-right: 5px;
margin-right: 2px;
border-bottom: 1px solid #849CA4;
margin-bottom: -10px;
}
#key-menu li a, #key-menu li span {
display: block;
float: left;
padding: 3px 15px 2px 20px;
background: url("../img/tabs.gif") 0 -50px;
color: #5A7CBA;
text-decoration: none;
}
#key-menu li:hover a {
background-position: 0 -100px;
}
#key-menu li:hover {
background-position: 100% -100px;
}
#key-menu li.current {
background: url("../img/tabs.gif") 100% 0;
border-bottom-color: white;
}
#key-menu li.current a, #key-menu li.current span {
background: url("../img/tabs.gif") 0 0;
color: #999;
}
#key-menu a:focus { outline: none; }
#header {
clear: both;
padding-top: 40px;
position: relative;
} * html #header { padding-top: 20px; }
#header h1 {
height: 46px;
margin: 0;
font-size: 2px;
position: absolute;
top: 0;
left: -4px;
border: none;
z-index: 5000;
}
#user {
position: absolute;
right: 0;
top: 9px;
margin-left: 200px;
font-family: tahoma, arial, sans-serif;
font-size: 95%;
}
.skipLink {
position: absolute;
left: -1200px;
width: 990px;
}
#map {
border: 1px solid #555;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 365 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 394 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 443 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 562 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 825 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

View File

@@ -1,87 +0,0 @@
<?php
/* SVN FILE: $Id: index.php,v 1.4 2006-10-08 03:39:23 reed%reedloden.com Exp $ */
/**
* Short description for file.
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2006, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.app.webroot
* @since CakePHP v 0.2.9
* @version $Revision: 1.4 $
* @modifiedby $LastChangedBy: phpnut $
* @lastmodified $Date: 2006-10-08 03:39:23 $
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Do not change
*/
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
/**
* These defines should only be edited if you have cake installed in
* a directory layout other than the way it is distributed.
* Each define has a commented line of code that explains what you would change.
*
*/
if (!defined('ROOT')) {
//define('ROOT', 'FULL PATH TO DIRECTORY WHERE APP DIRECTORY IS LOCATED DO NOT ADD A TRAILING DIRECTORY SEPARATOR';
//You should also use the DS define to seperate your directories
define('ROOT', dirname(dirname(dirname(__FILE__))));
}
if (!defined('APP_DIR')) {
//define('APP_DIR', 'DIRECTORY NAME OF APPLICATION';
define('APP_DIR', basename(dirname(dirname(__FILE__))));
}
/**
* This only needs to be changed if the cake installed libs are located
* outside of the distributed directory structure.
*/
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
//define ('CAKE_CORE_INCLUDE_PATH', FULL PATH TO DIRECTORY WHERE CAKE CORE IS INSTALLED DO NOT ADD A TRAILING DIRECTORY SEPARATOR';
//You should also use the DS define to seperate your directories
define('CAKE_CORE_INCLUDE_PATH', ROOT);
}
///////////////////////////////
//DO NOT EDIT BELOW THIS LINE//
///////////////////////////////
if (!defined('WEBROOT_DIR')) {
define('WEBROOT_DIR', basename(dirname(__FILE__)));
}
if (!defined('WWW_ROOT')) {
define('WWW_ROOT', dirname(__FILE__) . DS);
}
if (!defined('CORE_PATH')) {
if (function_exists('ini_set')) {
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . CAKE_CORE_INCLUDE_PATH . PATH_SEPARATOR . ROOT . DS . APP_DIR . DS);
define('APP_PATH', null);
define('CORE_PATH', null);
} else {
define('APP_PATH', ROOT . DS . APP_DIR . DS);
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
}
}
require CORE_PATH . 'cake' . DS . 'bootstrap.php';
if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') {
} else {
$Dispatcher=new Dispatcher();
$Dispatcher->dispatch($url);
}
if (DEBUG) {
echo "<!-- " . round(getMicrotime() - $TIME_START, 4) . "s -->";
}
?>

View File

@@ -1,172 +0,0 @@
var map;
var marker;
var mouseloc;
function wheelZoom(event) {
function out() {
map.setCenter(mouseloc);
map.zoomOut();
}
if (event.cancelable) event.preventDefault();
{
(event.detail || -event.wheelDelta) < 0 ? map.zoomIn(mouseloc, true) : out();
}
return false;
}
function mapInit(aLat, aLng, aZoom, aState) {
map = new GMap2(document.getElementById("map"));
map.addControl((aState == "stationary") ? new GSmallZoomControl() : new GSmallMapControl());
if (aLat) {
map.setCenter(new GLatLng(aLat, aLng), aZoom);
if (marker) {
map.removeOverlay(marker);
}
marker = new GMarker(new GLatLng(aLat, aLng), (aState != "stationary") ? {draggable: true} : {draggable: false});
}
else {
map.setCenter(new GLatLng(14.944785, -156.796875), 1);
if (marker) {
map.removeOverlay(marker);
}
marker = new GMarker(new GLatLng(14.944785, -156.796875), (aState != "stationary") ? {draggable: true} : {draggable: false});
}
map.addOverlay(marker);
if (aState != "stationary") {
GEvent.addListener(marker, "dragend", function() { onDragEnd(); });
GEvent.addListener(map, "moveend", function(){ onMoveEnd(); });
}
}
function search(event) {
document.getElementById('map-load').setAttribute('style', '');
if (event.cancelable) event.preventDefault();
{
var q = document.getElementById('location').value;
var gcoder = new GClientGeocoder();
gcoder.getLatLng(q, function (point) {
if (!point) {
suggest(q);
document.getElementById('map-load').setAttribute('style', 'visibility: hidden');
}
else {
map.setZoom(10);
map.panTo(point);
document.getElementById('map-load').setAttribute('style', 'visibility: hidden');
}
});
}
return false;
}
function geocode(aLoc) {
var gcoder = new GClientGeocoder();
gcoder.getLatLng(aLoc, function (point) {
if (!point) {
suggest(aLoc);
}
else {
map.setZoom(10);
map.panTo(point);
map.removeOverlay(marker);
marker = new GMarker(point, {draggable: true});
GEvent.addListener(marker, "dragend", function() { onDragEnd(); });
map.addOverlay(marker);
}
});
}
function suggest(loc) {
GDownloadUrl("/js/suggest.php?s=" + loc, function(data, responseCode) {
if (data != 0) {
document.getElementById('locerrlink').innerHTML = data;
document.getElementById('locerr').setAttribute('style', '');
}
});
}
function geocode_suggest() {
var str = document.getElementById('locerrlink').innerHTML;
document.getElementById('location').value = str;
document.getElementById('locerr').setAttribute('style', 'display: none');
geocode(str);
}
function onMoveEnd() {
var point = map.getCenter();
map.removeOverlay(marker);
marker = new GMarker(point, {draggable: true});
map.addOverlay(marker);
GEvent.addListener(marker, "dragend", function() { onDragEnd(); });
editForm();
}
function onDragEnd() {
var point = marker.getPoint()
map.panTo(point);
}
function initMashUp(lat, lng) {
map = new GMap2(document.getElementById("map"));
map.enableDoubleClickZoom();
map.enableContinuousZoom();
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(0, -5.25), 1);
GEvent.addDomListener(document.getElementById("map"), "DOMMouseScroll", wheelZoom);
GEvent.addDomListener(document.getElementById("map"), "mousewheel", wheelZoom);
GEvent.addListener(map, "mousemove", function(point) { mouseloc = point; });
GEvent.addListener(map, "click", function(overlay, point) {
if (overlay) {
if (overlay.mid) {
downloadMarker(overlay.mid, overlay);
}
}
});
if (lat && lng)
map.setCenter(new GLatLng(lat, lng), 10);
else
map.setCenter(new GLatLng(0, -5.25), 1);
addParties();
}
function editForm() {
var ll = map.getCenter();
document.getElementById('lat').value = ll.lat();
document.getElementById('long').value = ll.lng();
document.getElementById('zoom').value = map.getZoom();
}
function shide() {
document.getElementById('locerr').setAttribute('style', 'display: none');
}
function downloadMarker(mid, overlay) {
document.getElementById('map-load').setAttribute('style', '');
GDownloadUrl("/parties/js/html/" + mid, function(data, responseCode) {
if (data != "" && responseCode == 200) {
document.getElementById('map-load').setAttribute('style', 'visibility: hidden');
overlay.openInfoWindowHtml(data);
}
});
}
function addParty(aLat, aLng, aId) {
var point = new GLatLng(aLat, aLng);
var icon = new GIcon();
icon.image = "/img/marker.png";
icon.iconSize = new GSize(12, 20);
icon.iconAnchor = new GPoint(6, 20);
icon.infoWindowAnchor = new GPoint(5, 1);
var mark = new GMarker(point, icon);
mark.mid = aId;
map.addOverlay(mark);
}

View File

@@ -1,47 +0,0 @@
<?php
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Party Tool
*
* The Initial Developer of the Original Code is
* Ryan Flint <rflint@dslr.net>
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
if (empty($_REQUEST['s']))
die();
include('../../vendors/webServices.php');
include('../../config/bootstrap.php');
$suggest = new webServices(array('type' => 'gsuggest'));
$string = $suggest->GSuggest($_REQUEST['s']);
header('Content-type: text/plain');
echo $string;
?>

View File

@@ -1,43 +0,0 @@
<?php
/* SVN FILE: $Id: vendors.php,v 1.4 2006-10-08 03:39:24 reed%reedloden.com Exp $ */
/**
* Short description for file.
*
* This file includes js vendor-files from /vendor/ directory if they need to
* be accessible to the public.
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2006, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.app.webroot.js
* @since CakePHP v 0.2.9
* @version $Revision: 1.4 $
* @modifiedby $LastChangedBy: phpnut $
* @lastmodified $Date: 2006-10-08 03:39:24 $
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Enter description here...
*/
$file = $_GET['file'];
$pos = strpos($file, '..');
if ($pos === false) {
if(is_file('../../vendors/javascript/'.$file) && (preg_match('/(\/.+)\\.js/', $file)))
{
readfile('../../vendors/javascript/'.$file);
}
} else {
header('HTTP/1.1 404 Not Found');
}
?>

View File

@@ -0,0 +1,67 @@
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = xpwidgets support
#
# Dont build the DSO under the 'build' directory as windows does.
#
# The DSOs get built in the toolkit dir itself. Do this so that
# multiple implementations of widget can be built on the same
# source tree.
#
ifndef MOZ_MONOLITHIC_TOOLKIT
ifdef MOZ_ENABLE_GTK
DIRS += gtksuperwin
DIRS += gtk
endif
ifdef MOZ_ENABLE_MOTIF
DIRS += motif
endif
ifdef MOZ_ENABLE_XLIB
DIRS += xlib
endif
ifdef MOZ_ENABLE_QT
DIRS += qt
endif
else
DIRS += $(MOZ_WIDGET_TOOLKIT)
endif
# unix_services are only useful in unix, duh...
ifeq (,$(filter beos os2 rhapsody photon,$(MOZ_WIDGET_TOOLKIT)))
DIRS += unix_services
endif
include $(topsrcdir)/config/rules.mk

View File

@@ -0,0 +1,100 @@
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
LIBRARY_NAME = widget_gtk
REQUIRES = util img xpcom raptor netlib
CPPSRCS = \
nsAppShell.cpp \
nsButton.cpp \
nsCheckButton.cpp \
nsClipboard.cpp \
nsComboBox.cpp \
nsContextMenu.cpp \
nsDragService.cpp \
nsFilePicker.cpp \
nsFileWidget.cpp \
nsFontRetrieverService.cpp \
nsFontSizeIterator.cpp \
nsGtkEventHandler.cpp \
nsGtkUtils.cpp \
nsLabel.cpp \
nsListBox.cpp \
nsLookAndFeel.cpp \
nsMenu.cpp \
nsMenuBar.cpp \
nsMenuItem.cpp \
nsPopUpMenu.cpp \
nsRadioButton.cpp \
nsScrollbar.cpp \
nsSound.cpp \
nsTextAreaWidget.cpp \
nsTextHelper.cpp \
nsTextWidget.cpp \
nsToolkit.cpp \
nsWidget.cpp \
nsWidgetFactory.cpp \
nsWindow.cpp \
$(NULL)
SHARED_LIBRARY_LIBS = $(DIST)/lib/libraptorbasewidget_s.a
EXTRA_DSO_LDOPTS = \
$(MKSHLIB_FORCE_ALL) \
$(SHARED_LIBRARY_LIBS) \
$(MKSHLIB_UNFORCE_ALL) \
$(MOZ_COMPONENT_LIBS) \
-lraptorgfx \
$(NULL)
ifndef MOZ_MONOLITHIC_TOOLKIT
EXTRA_DSO_LDOPTS += -L$(DIST)/lib -lgtksuperwin $(MOZ_GTK_LDFLAGS)
else
EXTRA_DSO_LDOPTS += $(TK_LIBS)
endif
include $(topsrcdir)/config/rules.mk
ifndef MOZ_MONOLITHIC_TOOLKIT
CXXFLAGS += $(MOZ_GTK_CFLAGS)
CFLAGS += $(MOZ_GTK_CFLAGS)
else
CXXFLAGS += $(TK_CFLAGS)
CFLAGS += $(TK_CFLAGS)
endif
DEFINES += -D_IMPL_NS_WIDGET -DUSE_XIM
ifeq ($(OS_ARCH), Linux)
DEFINES += -D_BSD_SOURCE
endif
INCLUDES += \
-I$(srcdir)/../xpwidgets \
-I$(srcdir) \
$(NULL)
$(LIBRARY) $(SHARED_LIBRARY): $(SHARED_LIBRARY_LIBS) Makefile

View File

@@ -0,0 +1,292 @@
/* XPM */
static char * mozilla_icon_xpm[] = {
"32 32 257 2",
" c None",
". c #AA7303",
"+ c #A67003",
"@ c #B77C03",
"# c #8D6003",
"$ c #8D6004",
"% c #6C4A04",
"& c #3A2804",
"* c #6B4802",
"= c #9B6903",
"- c #5A2C04",
"; c #411B04",
"> c #9D6A03",
", c #7A5203",
"' c #510D04",
") c #6B1104",
"! c #7D5503",
"~ c #674604",
"{ c #C21E04",
"] c #C21D04",
"^ c #523804",
"/ c #513702",
"( c #552904",
"_ c #DD2204",
": c #DF2204",
"< c #582904",
"[ c #5F3F02",
"} c #6B2504",
"| c #FE2604",
"1 c #AB7303",
"2 c #9B6904",
"3 c #C31F04",
"4 c #FE2704",
"5 c #A81904",
"6 c #926304",
"7 c #4D3302",
"8 c #483104",
"9 c #C61E04",
"0 c #B11B04",
"a c #891604",
"b c #761204",
"c c #614304",
"d c #775102",
"e c #795102",
"f c #785102",
"g c #C58603",
"h c #642404",
"i c #B21A04",
"j c #1F0604",
"k c #550E04",
"l c #631004",
"m c #402404",
"n c #AF7703",
"o c #3D2902",
"p c #7F5602",
"q c #805604",
"r c #0C0904",
"s c #080604",
"t c #080706",
"u c #090604",
"v c #060404",
"w c #620F04",
"x c #7A1304",
"y c #030204",
"z c #570E04",
"A c #721204",
"B c #270704",
"C c #080504",
"D c #0A0604",
"E c #533804",
"F c #A56F02",
"G c #B87C03",
"H c #3B2804",
"I c #A51904",
"J c #FC2704",
"K c #D62004",
"L c #691004",
"M c #C01E04",
"N c #6D1004",
"O c #9C1804",
"P c #B31C04",
"Q c #150404",
"R c #801404",
"S c #DD2304",
"T c #120404",
"U c #130404",
"V c #500C04",
"W c #CC1E04",
"X c #AA1A04",
"Y c #100904",
"Z c #B47A03",
"` c #A77103",
" . c #513704",
".. c #891704",
"+. c #F62604",
"@. c #BA1D04",
"#. c #3C0A04",
"$. c #EB2304",
"%. c #DE2304",
"&. c #560E04",
"*. c #E82304",
"=. c #FE2804",
"-. c #BE1D04",
";. c #F12404",
">. c #661004",
",. c #020204",
"'. c #5E0F04",
"). c #A61A04",
"!. c #4A3204",
"~. c #BC7E03",
"{. c #8E6002",
"]. c #684604",
"^. c #390D04",
"/. c #EE2404",
"(. c #FE2904",
"_. c #7D1304",
":. c #8C1504",
"<. c #200604",
"[. c #A81A04",
"}. c #E72204",
"|. c #DA2004",
"1. c #070204",
"2. c #280704",
"3. c #543904",
"4. c #9F6C02",
"5. c #674602",
"6. c #B47B04",
"7. c #311004",
"8. c #B11C04",
"9. c #AA1B04",
"0. c #6A1104",
"a. c #801504",
"b. c #2B0704",
"c. c #09090A",
"d. c #450B04",
"e. c #360904",
"f. c #DC2204",
"g. c #EE2504",
"h. c #C11D04",
"i. c #6F1104",
"j. c #704B04",
"k. c #9C6902",
"l. c #A56F03",
"m. c #5F4004",
"n. c #8D1604",
"o. c #440A04",
"p. c #1A0504",
"q. c #931604",
"r. c #621004",
"s. c #7F1404",
"t. c #921704",
"u. c #F82504",
"v. c #F52504",
"w. c #981804",
"x. c #241804",
"y. c #5B3E04",
"z. c #D82204",
"A. c #D02004",
"B. c #DA2104",
"C. c #D52104",
"D. c #2A1A04",
"E. c #AC7403",
"F. c #2B1C04",
"G. c #D04004",
"H. c #FC3C04",
"I. c #F94E04",
"J. c #881504",
"K. c #FC2604",
"L. c #792804",
"M. c #AC7503",
"N. c #9A6803",
"O. c #782804",
"P. c #F66504",
"Q. c #F94B04",
"R. c #F46804",
"S. c #F46604",
"T. c #F76504",
"U. c #FB4204",
"V. c #C13D04",
"W. c #5D0E04",
"X. c #DA2204",
"Y. c #741604",
"Z. c #8C5E03",
"`. c #885B03",
" + c #8B1904",
".+ c #DE2204",
"++ c #D22D04",
"@+ c #C42D04",
"#+ c #580E04",
"$+ c #9F1804",
"%+ c #895D04",
"&+ c #D62204",
"*+ c #371904",
"=+ c #2C1A04",
"-+ c #4A0C04",
";+ c #140404",
">+ c #AB1A04",
",+ c #DA2304",
"'+ c #6A4702",
")+ c #754F02",
"!+ c #821404",
"~+ c #462B04",
"{+ c #B37A03",
"]+ c #B17803",
"^+ c #714C04",
"/+ c #580F04",
"(+ c #E32204",
"_+ c #DD2104",
":+ c #611D04",
"<+ c #BA7F03",
"[+ c #B27803",
"}+ c #6F1D04",
"|+ c #FD2704",
"1+ c #F22504",
"2+ c #634304",
"3+ c #875B03",
"4+ c #734F02",
"5+ c #805704",
"6+ c #1D0504",
"7+ c #DB2204",
"8+ c #EA2404",
"9+ c #2E0804",
"0+ c #815803",
"a+ c #941704",
"b+ c #C11E04",
"c+ c #391B04",
"d+ c #A77104",
"e+ c #B67C04",
"f+ c #371D04",
"g+ c #360A04",
"h+ c #573A04",
"i+ c #372604",
"j+ c #3E2104",
"k+ c #B57A03",
"l+ c #B57B03",
"m+ c #603F04",
"n+ c #430A04",
"o+ c #351904",
"p+ c #A36E03",
"q+ c #BE8103",
"r+ c #1D1404",
"s+ c #483004",
"t+ c #A26E03",
"u+ c #6D4B02",
"v+ c #825804",
"w+ c #0B0804",
"x+ c #976603",
"y+ c #815703",
"z+ c #926404",
"A+ c #895D03",
"B+ c #614202",
"C+ c #9A6804",
"D+ c #C88704",
"E+ c #C18303",
"F+ c #654302",
"G+ c #744F02",
"H+ c #704B02",
" ",
" . ",
" + @ ",
" # $ ",
" % & * ",
" = - ; > ",
" , ' ) ! ",
" ~ { ] ^ ",
" / ( _ : < [ ",
" . } | | } 1 ",
" 2 3 | 4 5 6 ",
" 7 8 9 0 a b c ",
" d e f f f d d d d d d g h i j k l m n d d d d d d d d d d d o ",
" p q r s s s s t s s u v w x y z A B C D D D D D s s s s E F ",
" G H I J 4 | 4 | K L L M N O P Q R | S T U V W X Y Z ",
" ` ...+.| 4 @.#.$.4 | %.&.*.4 =.-.;.>.,.'.).!.~. ",
" {.].^./.(.X _.;.| :.T <.[.| }.z | |.1.2.3.4. ",
" 5.6.7.8.9.0.a.b.c.d.e.f.g.h.&.| i.u j.k. ",
" l.m.n.o.p.q._.r.a.s.t.u.v.w.x.Z ",
" {.y.P z.R A.v.x j B.| C.D.E. ",
" F.G.H.I.4 | 4 t.J.f.K.L.M. ",
" N.O.P.Q.R.S.T.U.V.W.X.4 Y.Z. ",
" `. +4 =.| | .+++@+#+$+| K %+ ",
" %+&+| | | I *+=+-+;+>+,+&+x.'+ ",
" )+=+X.=.| !+~+{+]+^+,./+(+_+:+<+ ",
" [+}+|+1+) 2+3+ 4+5+6+7+8+9+0+ ",
" $ a+b+c+d+ e+f+0.g+h+ ",
" i+A j+k+ l+m+n+o+p+ ",
" q+r+s+t+ u+v+w+x+ ",
" y+z+A+ B+C+2 ",
" D+ E+F+ ",
" G+ H+ "};

View File

@@ -0,0 +1,63 @@
/* XPM */
static char * mozicon50_xpm[] = {
"50 51 9 1",
" c None",
". c #000000",
"+ c #FF0000",
"@ c #808000",
"# c #800000",
"$ c #FF6633",
"% c #990066",
"& c #FF00FF",
"* c #222222",
" ",
" @ ",
" $@ ",
" @@ ",
" @@$ ",
" $@*@ ",
" @@.@ ",
" @..@ ",
" $@..@@ ",
" $@##*@ ",
" @*#+.@ ",
" @.++.@$ ",
" $@.++.@$ ",
" @*#++#*@ ",
" @.++++.@ ",
" $@.++++.@$ ",
" @*#++++**@ ",
" @.#++++#.@ ",
" $@.++####.@ ",
" @@*+#*##*.@@ ",
"*@@@@@@@@@@@@@@@@@@@.#+..*##*#@@@@@@@@@@@@@@@@@@@*",
" *@@*................+#..*###.................@@* ",
" %@@@.#++++++++++++#**#*#++.###++*...#+++#.*@@* ",
" *@@.#+++++++++#.##++#+#+*.#+++#..##++#.@@@% ",
" $@..+++++++.#++++++##++++#++#...++*.@@$ ",
" @@*.#+++++.#+++++*.#++++##++#.*...@@ ",
" $@@.#+++#*++++#....#+++*#+++...*@$ ",
" *@@..++#*++#**.*.*+++#.#++*..@@$ ",
" $@*.++******#+++++#+#+++..@@ ",
" $@@.##..*$#**#+#*#++++..@@ ",
" $@@.#+#***##...#++++.*@@ ",
" %@@*++++++++#.#++++.@@ ",
" @.#+++++++++.##+++.@$ ",
" @.+$$$$$+$$$#*#+++*@@ ",
" $@*+$$$$$$$+$#.#+++#.@ ",
" @*#+++++++++++.#++++.@ ",
" @.#+++++++#*++.##+++.@$ ",
" $@.+++++++....#..+#++*@@ ",
" @@*+++++#.*@@@...*+++#.@ ",
" @.#++++#.@@@ @@..#++++.@ ",
" @.++++*.@@$ %@@..+++#.@@ ",
" $@.+++..@@* $@*.#+#**@ ",
" @@#+#.*@$% $@@.##..@ ",
" @.##.@@ @@..#.@$ ",
" $@.*.@@$ @@**.@$ ",
" $@.*@@ %$@@.*@ ",
" @.@@$ *@@.@ ",
" @@@$ %@@@$ ",
" $@@% %@@@ ",
" @@ $@ ",
" $ * "};

View File

@@ -0,0 +1,459 @@
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "prmon.h"
#include "nsCOMPtr.h"
#include "nsAppShell.h"
#include "nsIAppShell.h"
#include "nsIServiceManager.h"
#include "nsIEventQueueService.h"
#include "nsICmdLineService.h"
#include "nsGtkEventHandler.h"
#include <stdlib.h>
#ifdef MOZ_GLE
#include <gle/gle.h>
#endif
#include "nsIWidget.h"
#include "nsIPref.h"
#include "glib.h"
struct OurGdkIOClosure {
GdkInputFunction function;
gpointer data;
};
static gboolean
our_gdk_io_invoke(GIOChannel* source, GIOCondition condition, gpointer data)
{
OurGdkIOClosure* ioc = (OurGdkIOClosure*) data;
if (ioc) {
(*ioc->function)(ioc->data, g_io_channel_unix_get_fd(source),
GDK_INPUT_READ);
}
return TRUE;
}
static void
our_gdk_io_destroy(gpointer data)
{
OurGdkIOClosure* ioc = (OurGdkIOClosure*) data;
if (ioc) {
g_free(ioc);
}
}
static gint
our_gdk_input_add (gint source,
GdkInputFunction function,
gpointer data,
gint priority)
{
guint result;
OurGdkIOClosure *closure = g_new (OurGdkIOClosure, 1);
GIOChannel *channel;
closure->function = function;
closure->data = data;
channel = g_io_channel_unix_new (source);
result = g_io_add_watch_full (channel, priority, G_IO_IN,
our_gdk_io_invoke,
closure, our_gdk_io_destroy);
g_io_channel_unref (channel);
return result;
}
//-------------------------------------------------------------------------
//
// XPCOM CIDs
//
//-------------------------------------------------------------------------
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_CID(kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID);
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
// a linked, ordered list of event queues and their tokens
class EventQueueToken {
public:
EventQueueToken(nsIEventQueue *aQueue, const gint aToken);
virtual ~EventQueueToken();
nsIEventQueue *mQueue;
gint mToken;
EventQueueToken *mNext;
};
EventQueueToken::EventQueueToken(nsIEventQueue *aQueue, const gint aToken) {
mQueue = aQueue;
NS_IF_ADDREF(mQueue);
mToken = aToken;
mNext = 0;
}
EventQueueToken::~EventQueueToken(){
NS_IF_RELEASE(mQueue);
}
class EventQueueTokenQueue {
public:
EventQueueTokenQueue();
virtual ~EventQueueTokenQueue();
nsresult PushToken(nsIEventQueue *aQueue, gint aToken);
PRBool PopToken(nsIEventQueue *aQueue, gint *aToken);
private:
EventQueueToken *mHead;
};
EventQueueTokenQueue::EventQueueTokenQueue() {
mHead = 0;
}
EventQueueTokenQueue::~EventQueueTokenQueue() {
// if we reach this point with an empty token queue, well, fab. however,
// we expect the first event queue to still be active. so we take
// special care to unhook that queue (not that failing to do so seems
// to hurt anything). more queues than that would be an error.
//NS_ASSERTION(!mHead || !mHead->mNext, "event queue token list deleted when not empty");
// (and skip the assertion for now. we're leaking event queues because they
// are referenced by things that leak, so this assertion goes off a lot.)
if (mHead) {
gdk_input_remove(mHead->mToken);
delete mHead;
// and leak the rest. it's an error, anyway
}
}
nsresult EventQueueTokenQueue::PushToken(nsIEventQueue *aQueue, gint aToken) {
EventQueueToken *newToken = new EventQueueToken(aQueue, aToken);
NS_ASSERTION(newToken, "couldn't allocate token queue element");
if (!newToken)
return NS_ERROR_OUT_OF_MEMORY;
newToken->mNext = mHead;
mHead = newToken;
return NS_OK;
}
PRBool EventQueueTokenQueue::PopToken(nsIEventQueue *aQueue, gint *aToken) {
EventQueueToken *token, *lastToken;
PRBool found = PR_FALSE;
NS_ASSERTION(mHead, "attempt to retrieve event queue token from empty queue");
if (mHead)
NS_ASSERTION(mHead->mQueue == aQueue, "retrieving event queue from past head of queue queue");
token = mHead;
lastToken = 0;
while (token && token->mQueue != aQueue) {
lastToken = token;
token = token->mNext;
}
if (token) {
if (lastToken)
lastToken->mNext = token->mNext;
else
mHead = token->mNext;
found = PR_TRUE;
*aToken = token->mToken;
delete token;
}
return found;
}
//-------------------------------------------------------------------------
//
// nsAppShell constructor
//
//-------------------------------------------------------------------------
nsAppShell::nsAppShell()
{
NS_INIT_REFCNT();
mDispatchListener = 0;
mEventQueueTokens = new EventQueueTokenQueue();
// throw on error would really be civilized here
NS_ASSERTION(mEventQueueTokens, "couldn't allocate event queue token queue");
}
//-------------------------------------------------------------------------
//
// nsAppShell destructor
//
//-------------------------------------------------------------------------
nsAppShell::~nsAppShell()
{
delete mEventQueueTokens;
}
//-------------------------------------------------------------------------
//
// nsISupports implementation macro
//
//-------------------------------------------------------------------------
NS_IMPL_ISUPPORTS1(nsAppShell, nsIAppShell)
//-------------------------------------------------------------------------
NS_IMETHODIMP nsAppShell::SetDispatchListener(nsDispatchListener* aDispatchListener)
{
mDispatchListener = aDispatchListener;
return NS_OK;
}
static void event_processor_callback(gpointer data,
gint source,
GdkInputCondition condition)
{
nsIEventQueue *eventQueue = (nsIEventQueue*)data;
if (eventQueue)
eventQueue->ProcessPendingEvents();
}
#define PREF_NCOLS "browser.ncols"
#define PREF_INSTALLCMAP "browser.installcmap"
static void
HandleColormapPrefs( void )
{
PRInt32 ivalue = 0;
PRBool bvalue;
nsresult rv;
/* The default is to do nothing. INSTALLCMAP has precedence over
NCOLS. Ignore the fact we can't do this if it fails, as it is
not critical */
NS_WITH_SERVICE(nsIPref, prefs, kPrefServiceCID, &rv);
if (NS_FAILED(rv) || (!prefs))
return;
/* first check ncols */
rv = prefs->GetIntPref(PREF_NCOLS, &ivalue);
if (NS_SUCCEEDED(rv) && ivalue >= 0 && ivalue <= 255 ) {
gdk_rgb_set_min_colors( ivalue );
return;
}
/* next check installcmap */
rv = prefs->GetBoolPref(PREF_INSTALLCMAP, &bvalue);
if (NS_SUCCEEDED(rv)) {
if ( PR_TRUE == bvalue )
gdk_rgb_set_min_colors( 255 ); // force it
else
gdk_rgb_set_min_colors( 0 );
}
}
//-------------------------------------------------------------------------
//
// Create the application shell
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsAppShell::Create(int *bac, char **bav)
{
gchar *home=nsnull;
gchar *path=nsnull;
int argc = bac ? *bac : 0;
char **argv = bav;
#if 1
nsresult rv;
NS_WITH_SERVICE(nsICmdLineService, cmdLineArgs, kCmdLineServiceCID, &rv);
if (NS_SUCCEEDED(rv))
{
rv = cmdLineArgs->GetArgc(&argc);
if(NS_FAILED(rv))
argc = bac ? *bac : 0;
rv = cmdLineArgs->GetArgv(&argv);
if(NS_FAILED(rv))
argv = bav;
}
#endif
gtk_set_locale ();
gtk_init (&argc, &argv);
// It is most convenient for us to intercept our events after
// they have been converted to GDK, but before GTK+ gets them
gdk_event_handler_set (handle_gdk_event, NULL, NULL);
#ifdef MOZ_GLE
gle_init (&argc, &argv);
#endif
// delete the cmdLineArgs thing?
HandleColormapPrefs();
gdk_rgb_init();
home = g_get_home_dir();
if ((char*)nsnull != home) {
path = g_strdup_printf("%s%c%s", home, G_DIR_SEPARATOR, ".gtkrc");
if ((char *)nsnull != path) {
gtk_rc_parse(path);
g_free(path);
}
}
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Spinup - do any preparation necessary for running a message loop
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsAppShell::Spinup()
{
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Spindown - do any cleanup necessary for finishing a message loop
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsAppShell::Spindown()
{
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Run
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsAppShell::Run()
{
NS_ADDREF_THIS();
nsresult rv = NS_OK;
nsIEventQueue * EQueue = nsnull;
// Get the event queue service
NS_WITH_SERVICE(nsIEventQueueService, eventQService, kEventQueueServiceCID, &rv);
if (NS_FAILED(rv)) {
NS_ASSERTION("Could not obtain event queue service", PR_FALSE);
return rv;
}
#ifdef DEBUG
printf("Got the event queue from the service\n");
#endif /* DEBUG */
//Get the event queue for the thread.
rv = eventQService->GetThreadEventQueue(PR_GetCurrentThread(), &EQueue);
// If a queue already present use it.
if (EQueue)
goto done;
// Create the event queue for the thread
rv = eventQService->CreateThreadEventQueue();
if (NS_OK != rv) {
NS_ASSERTION("Could not create the thread event queue", PR_FALSE);
return rv;
}
//Get the event queue for the thread
rv = eventQService->GetThreadEventQueue(PR_GetCurrentThread(), &EQueue);
if (NS_OK != rv) {
NS_ASSERTION("Could not obtain the thread event queue", PR_FALSE);
return rv;
}
done:
#ifdef DEBUG
printf("Calling gdk_input_add with event queue\n");
#endif /* DEBUG */
// (has to be called explicitly for this, the primordial appshell, because
// of startup ordering problems.)
ListenToEventQueue(EQueue, PR_TRUE);
gtk_main();
NS_IF_RELEASE(EQueue);
Release();
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Exit a message handler loop
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsAppShell::Exit()
{
gtk_main_quit ();
return NS_OK;
}
// does nothing. used by xp code with non-gtk expectations.
// this method will be removed once xp eventloops are working.
NS_IMETHODIMP nsAppShell::GetNativeEvent(PRBool &aRealEvent, void *& aEvent)
{
aRealEvent = PR_FALSE;
aEvent = 0;
return NS_OK;
}
// simply executes one iteration of the event loop. used by xp code with
// non-gtk expectations.
// this method will be removed once xp eventloops are working.
NS_IMETHODIMP nsAppShell::DispatchNativeEvent(PRBool aRealEvent, void *aEvent)
{
g_main_iteration(PR_TRUE);
return NS_OK;
}
NS_IMETHODIMP nsAppShell::ListenToEventQueue(nsIEventQueue *aQueue,
PRBool aListen)
{
// tell gdk to listen to the event queue or not
gint queueToken;
if (aListen) {
queueToken = our_gdk_input_add(aQueue->GetEventQueueSelectFD(),
event_processor_callback,
aQueue, G_PRIORITY_DEFAULT_IDLE);
mEventQueueTokens->PushToken(aQueue, queueToken);
} else {
if (mEventQueueTokens->PopToken(aQueue, &queueToken))
gdk_input_remove(queueToken);
}
return NS_OK;
}

View File

@@ -0,0 +1,50 @@
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsAppShell_h__
#define nsAppShell_h__
#include "nsIAppShell.h"
#include <gtk/gtk.h>
/**
* Native GTK+ Application shell wrapper
*/
class EventQueueTokenQueue;
class nsAppShell : public nsIAppShell
{
public:
nsAppShell();
virtual ~nsAppShell();
NS_DECL_ISUPPORTS
NS_DECL_NSIAPPSHELL
private:
nsDispatchListener *mDispatchListener;
EventQueueTokenQueue *mEventQueueTokens;
};
#endif // nsAppShell_h__

View File

@@ -0,0 +1,156 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include <gtk/gtk.h>
#include "nsGtkEventHandler.h"
#include "nsButton.h"
#include "nsString.h"
NS_IMPL_ADDREF_INHERITED(nsButton, nsWidget)
NS_IMPL_RELEASE_INHERITED(nsButton, nsWidget)
NS_IMPL_QUERY_INTERFACE2(nsButton, nsIButton, nsIWidget)
//-------------------------------------------------------------------------
//
// nsButton constructor
//
//-------------------------------------------------------------------------
nsButton::nsButton() : nsWidget() , nsIButton()
{
}
//-------------------------------------------------------------------------
//
// Create the native Button widget
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsButton::CreateNative(GtkObject *parentWindow)
{
#ifdef USE_SUPERWIN
if (!GDK_IS_SUPERWIN(parentWindow)) {
g_print("Damn, brother. That's not a superwin.\n");
return NS_ERROR_FAILURE;
}
GdkSuperWin *superwin = GDK_SUPERWIN(parentWindow);
mMozBox = gtk_mozbox_new(superwin->bin_window);
#endif
mWidget = gtk_button_new_with_label("");
gtk_widget_set_name(mWidget, "nsButton");
#ifdef USE_SUPERWIN
// make sure that we put the scrollbar into the mozbox
gtk_container_add(GTK_CONTAINER(mMozBox), mWidget);
#endif /* USE_SUPERWIN */
return NS_OK;
}
//-------------------------------------------------------------------------
//
// nsButton destructor
//
//-------------------------------------------------------------------------
nsButton::~nsButton()
{
}
void nsButton::InitCallbacks(char * aName)
{
InstallButtonPressSignal(mWidget);
InstallButtonReleaseSignal(mWidget);
InstallEnterNotifySignal(mWidget);
InstallLeaveNotifySignal(mWidget);
// These are needed so that the events will go to us and not our parent.
AddToEventMask(mWidget,
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_EXPOSURE_MASK |
GDK_FOCUS_CHANGE_MASK |
GDK_KEY_PRESS_MASK |
GDK_KEY_RELEASE_MASK |
GDK_LEAVE_NOTIFY_MASK |
GDK_POINTER_MOTION_MASK);
}
//-------------------------------------------------------------------------
//
// Set this button label
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsButton::SetLabel(const nsString& aText)
{
NS_ALLOC_STR_BUF(label, aText, 256);
gtk_label_set(GTK_LABEL(GTK_BIN (mWidget)->child), label);
NS_FREE_STR_BUF(label);
return (NS_OK);
}
//-------------------------------------------------------------------------
//
// Get this button label
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsButton::GetLabel(nsString& aBuffer)
{
char * text;
gtk_label_get(GTK_LABEL(GTK_BIN (mWidget)->child), &text);
aBuffer.SetLength(0);
aBuffer.Append(text);
return (NS_OK);
}
//-------------------------------------------------------------------------
//
// set font for button
//
//-------------------------------------------------------------------------
/* virtual */
void nsButton::SetFontNative(GdkFont *aFont)
{
GtkStyle *style = gtk_style_copy(GTK_BIN (mWidget)->child->style);
// gtk_style_copy ups the ref count of the font
gdk_font_unref (style->font);
style->font = aFont;
gdk_font_ref(style->font);
gtk_widget_set_style(GTK_BIN (mWidget)->child, style);
gtk_style_unref(style);
}

View File

@@ -0,0 +1,53 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsButton_h__
#define nsButton_h__
#include "nsWidget.h"
#include "nsIButton.h"
/**
* Native GTK+ button wrapper
*/
class nsButton : public nsWidget,
public nsIButton
{
public:
nsButton();
virtual ~nsButton();
NS_DECL_ISUPPORTS_INHERITED
// nsIButton part
NS_IMETHOD SetLabel(const nsString& aText);
NS_IMETHOD GetLabel(nsString& aBuffer);
virtual void SetFontNative(GdkFont *aFont);
protected:
NS_METHOD CreateNative(GtkObject *parentWindow);
virtual void InitCallbacks(char * aName = nsnull);
};
#endif // nsButton_h__

View File

@@ -0,0 +1,250 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsCheckButton.h"
#include "nsString.h"
NS_IMPL_ADDREF_INHERITED(nsCheckButton, nsWidget)
NS_IMPL_RELEASE_INHERITED(nsCheckButton, nsWidget)
NS_IMPL_QUERY_INTERFACE2(nsCheckButton, nsICheckButton, nsIWidget)
//-------------------------------------------------------------------------
//
// nsCheckButton constructor
//
//-------------------------------------------------------------------------
nsCheckButton::nsCheckButton() : nsWidget() , nsICheckButton()
{
NS_INIT_REFCNT();
mLabel = nsnull;
mCheckButton = nsnull;
mState = PR_FALSE;
}
//-------------------------------------------------------------------------
//
// nsCheckButton destructor
//
//-------------------------------------------------------------------------
nsCheckButton::~nsCheckButton()
{
}
void
nsCheckButton::OnDestroySignal(GtkWidget* aGtkWidget)
{
if (aGtkWidget == mCheckButton) {
mCheckButton = nsnull;
}
else if (aGtkWidget == mLabel) {
mLabel = nsnull;
}
else {
nsWidget::OnDestroySignal(aGtkWidget);
}
}
//-------------------------------------------------------------------------
//
// Create the native CheckButton widget
//
//-------------------------------------------------------------------------
NS_METHOD nsCheckButton::CreateNative(GtkObject *parentWindow)
{
mWidget = gtk_event_box_new();
mCheckButton = gtk_check_button_new();
gtk_container_add(GTK_CONTAINER(mWidget), mCheckButton);
gtk_widget_show(mCheckButton);
gtk_widget_set_name(mWidget, "nsCheckButton");
return NS_OK;
}
void nsCheckButton::InitCallbacks(char * aName)
{
InstallButtonPressSignal(mCheckButton);
InstallButtonReleaseSignal(mCheckButton);
InstallEnterNotifySignal(mWidget);
InstallLeaveNotifySignal(mWidget);
// These are needed so that the events will go to us and not our parent.
AddToEventMask(mWidget,
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_EXPOSURE_MASK |
GDK_FOCUS_CHANGE_MASK |
GDK_KEY_PRESS_MASK |
GDK_KEY_RELEASE_MASK |
GDK_LEAVE_NOTIFY_MASK |
GDK_POINTER_MOTION_MASK);
// Add in destroy callback
gtk_signal_connect(GTK_OBJECT(mCheckButton),
"destroy",
GTK_SIGNAL_FUNC(DestroySignal),
this);
InstallSignal((GtkWidget *)mCheckButton,
(gchar *)"toggled",
GTK_SIGNAL_FUNC(nsCheckButton::ToggledSignal));
}
//-------------------------------------------------------------------------
//
// Set this button label
//
//-------------------------------------------------------------------------
NS_METHOD nsCheckButton::SetState(const PRBool aState)
{
mState = aState;
if (mWidget && mCheckButton)
{
GtkToggleButton * item = GTK_TOGGLE_BUTTON(mCheckButton);
item->active = (gboolean) mState;
gtk_widget_queue_draw(GTK_WIDGET(item));
}
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Set this button label
//
//-------------------------------------------------------------------------
NS_METHOD nsCheckButton::GetState(PRBool& aState)
{
aState = mState;
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Set this Checkbox label
//
//-------------------------------------------------------------------------
NS_METHOD nsCheckButton::SetLabel(const nsString& aText)
{
if (mWidget) {
NS_ALLOC_STR_BUF(label, aText, 256);
if (mLabel) {
gtk_label_set(GTK_LABEL(mLabel), label);
} else {
mLabel = gtk_label_new(label);
gtk_misc_set_alignment (GTK_MISC (mLabel), 0.0, 0.5);
gtk_container_add(GTK_CONTAINER(mCheckButton), mLabel);
gtk_widget_show(mLabel);
gtk_signal_connect(GTK_OBJECT(mLabel),
"destroy",
GTK_SIGNAL_FUNC(DestroySignal),
this);
}
NS_FREE_STR_BUF(label);
}
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Get this button label
//
//-------------------------------------------------------------------------
NS_METHOD nsCheckButton::GetLabel(nsString& aBuffer)
{
aBuffer.SetLength(0);
if (mWidget) {
char * text;
if (mLabel) {
gtk_label_get(GTK_LABEL(mLabel), &text);
aBuffer.Append(text);
}
}
return NS_OK;
}
/* virtual */ void
nsCheckButton::OnToggledSignal(const gboolean aState)
{
// Untoggle the sonofabitch
if (mWidget && mCheckButton)
{
GtkToggleButton * item = GTK_TOGGLE_BUTTON(mCheckButton);
item->active = !item->active;
gtk_widget_queue_draw(GTK_WIDGET(item));
}
}
//////////////////////////////////////////////////////////////////////
/* static */ gint
nsCheckButton::ToggledSignal(GtkWidget * aWidget,
gpointer aData)
{
NS_ASSERTION( nsnull != aWidget, "widget is null");
nsCheckButton * button = (nsCheckButton *) aData;
NS_ASSERTION( nsnull != button, "instance pointer is null");
button->OnToggledSignal(GTK_TOGGLE_BUTTON(aWidget)->active);
return PR_TRUE;
}
//////////////////////////////////////////////////////////////////////
// SetBackgroundColor for CheckButton
/*virtual*/
void nsCheckButton::SetBackgroundColorNative(GdkColor *aColorNor,
GdkColor *aColorBri,
GdkColor *aColorDark)
{
// use same style copy as SetFont
GtkStyle *style = gtk_style_copy(GTK_WIDGET (g_list_nth_data(gtk_container_children(GTK_CONTAINER (mWidget)),0))->style);
style->bg[GTK_STATE_NORMAL]=*aColorNor;
// Mouse over button
style->bg[GTK_STATE_PRELIGHT]=*aColorBri;
// Button is down
style->bg[GTK_STATE_ACTIVE]=*aColorDark;
// other states too? (GTK_STATE_ACTIVE, GTK_STATE_PRELIGHT,
// GTK_STATE_SELECTED, GTK_STATE_INSENSITIVE)
gtk_widget_set_style(GTK_WIDGET (g_list_nth_data(gtk_container_children(GTK_CONTAINER (mWidget)),0)), style);
// set style for eventbox too
gtk_widget_set_style(mWidget, style);
gtk_style_unref(style);
}

View File

@@ -0,0 +1,75 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsCheckButton_h__
#define nsCheckButton_h__
#include "nsWidget.h"
#include "nsICheckButton.h"
/**
* Native GTK+ Checkbox wrapper
*/
class nsCheckButton : public nsWidget,
public nsICheckButton
{
public:
nsCheckButton();
virtual ~nsCheckButton();
NS_DECL_ISUPPORTS_INHERITED
// nsICheckButton part
NS_IMETHOD SetLabel(const nsString &aText);
NS_IMETHOD GetLabel(nsString &aBuffer);
NS_IMETHOD SetState(const PRBool aState);
NS_IMETHOD GetState(PRBool& aState);
virtual void OnToggledSignal(const gboolean aState);
protected:
NS_IMETHOD CreateNative(GtkObject *parentWindow);
virtual void InitCallbacks(char * aName = nsnull);
virtual void OnDestroySignal(GtkWidget* aGtkWidget);
// Sets background for checkbutton
virtual void SetBackgroundColorNative(GdkColor *aColorNor,
GdkColor *aColorBri,
GdkColor *aColorDark);
GtkWidget *mLabel;
GtkWidget *mCheckButton;
// We need to maintain our own state to be in sync with the
// gecko check controlling frame.
PRBool mState;
private:
static gint ToggledSignal(GtkWidget * aWidget,
gpointer aData);
};
#endif // nsCheckButton_h__

View File

@@ -0,0 +1,872 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsClipboard.h"
#include "nsCOMPtr.h"
#include "nsISupportsArray.h"
#include "nsIClipboardOwner.h"
#include "nsITransferable.h" // kTextMime
#include "nsISupportsPrimitives.h"
#include "nsIWidget.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsWidgetsCID.h"
#include "nsXPIDLString.h"
#include "nsPrimitiveHelpers.h"
#include "nsVoidArray.h"
// The class statics:
GtkWidget* nsClipboard::sWidget = 0;
#if defined(DEBUG_mcafee) || defined(DEBUG_pavlov)
#define DEBUG_CLIPBOARD
#endif
enum {
TARGET_NONE,
TARGET_TEXT_PLAIN,
TARGET_TEXT_XIF,
TARGET_TEXT_UNICODE,
TARGET_TEXT_HTML,
TARGET_AOLMAIL,
TARGET_IMAGE_PNG,
TARGET_IMAGE_JPEG,
TARGET_IMAGE_GIF,
// compatibility types
TARGET_UTF8,
TARGET_UNKNOWN,
TARGET_LAST
};
static GdkAtom sSelTypes[TARGET_LAST];
//-------------------------------------------------------------------------
//
// nsClipboard constructor
//
//-------------------------------------------------------------------------
nsClipboard::nsClipboard() : nsBaseClipboard()
{
#ifdef DEBUG_CLIPBOARD
g_print("nsClipboard::nsClipboard()\n");
#endif /* DEBUG_CLIPBOARD */
//NS_INIT_REFCNT();
mIgnoreEmptyNotification = PR_FALSE;
mClipboardOwner = nsnull;
mTransferable = nsnull;
mSelectionData.data = nsnull;
mSelectionData.length = 0;
// initialize the widget, etc we're binding to
Init();
}
// XXX if GTK's internal code changes this isn't going to work
// copied from gtk code because it is a static function we can't get to it.
// need to bug owen taylor about getting this code public.
typedef struct _GtkSelectionTargetList GtkSelectionTargetList;
struct _GtkSelectionTargetList {
GdkAtom selection;
GtkTargetList *list;
};
static const char *gtk_selection_handler_key = "gtk-selection-handlers";
void __gtk_selection_target_list_remove (GtkWidget *widget)
{
GtkSelectionTargetList *sellist;
GList *tmp_list;
GList *lists;
lists = (GList*)gtk_object_get_data (GTK_OBJECT (widget), gtk_selection_handler_key);
tmp_list = lists;
while (tmp_list)
{
sellist = (GtkSelectionTargetList*)tmp_list->data;
gtk_target_list_unref (sellist->list);
g_free (sellist);
tmp_list = tmp_list->next;
}
g_list_free (lists);
gtk_object_set_data (GTK_OBJECT (widget), gtk_selection_handler_key, NULL);
}
//-------------------------------------------------------------------------
//
// nsClipboard destructor
//
//-------------------------------------------------------------------------
nsClipboard::~nsClipboard()
{
#ifdef DEBUG_CLIPBOARD
printf("nsClipboard::~nsClipboard()\n");
#endif /* DEBUG_CLIPBOARD */
// Remove all our event handlers:
if (sWidget &&
(gdk_selection_owner_get(GDK_SELECTION_PRIMARY) == sWidget->window))
gtk_selection_remove_all(sWidget);
// free the selection data, if any
if (mSelectionData.data != nsnull)
g_free(mSelectionData.data);
nsClipboard *cb = (nsClipboard*)gtk_object_get_data(GTK_OBJECT(sWidget), "cb");
if (cb != nsnull)
{
NS_RELEASE(cb);
gtk_object_remove_data(GTK_OBJECT(sWidget), "cb");
}
if (sWidget)
{
gtk_widget_destroy(sWidget);
sWidget = nsnull;
}
}
//
// GTK Weirdness!
// This is here in the hope of being able to call
// gtk_selection_add_targets(w, GDK_SELECTION_PRIMARY,
// targets,
// 1);
// instead of
// gtk_selection_add_target(sWidget,
// GDK_SELECTION_PRIMARY,
// GDK_SELECTION_TYPE_STRING,
// GDK_SELECTION_TYPE_STRING);
// but it turns out that this changes the whole gtk selection model;
// when calling add_targets copy uses selection_clear_event and the
// data structure needs to be filled in in a way that we haven't
// figured out; when using add_target copy uses selection_get and
// the data structure is already filled in as much as it needs to be.
// Some gtk internals wizard will need to solve this mystery before
// we can use add_targets().
//static GtkTargetEntry targets[] = {
// { "strings n stuff", GDK_SELECTION_TYPE_STRING, GDK_SELECTION_TYPE_STRING }
//};
//
//-------------------------------------------------------------------------
void nsClipboard::Init(void)
{
#ifdef DEBUG_CLIPBOARD
g_print("nsClipboard::Init\n");
#endif
sSelTypes[TARGET_NONE] = GDK_NONE;
sSelTypes[TARGET_TEXT_PLAIN] = gdk_atom_intern(kTextMime, FALSE);
sSelTypes[TARGET_TEXT_XIF] = gdk_atom_intern(kXIFMime, FALSE);
sSelTypes[TARGET_TEXT_UNICODE] = gdk_atom_intern(kUnicodeMime, FALSE);
sSelTypes[TARGET_UTF8] = gdk_atom_intern("UTF8", FALSE);
sSelTypes[TARGET_TEXT_HTML] = gdk_atom_intern(kHTMLMime, FALSE);
sSelTypes[TARGET_AOLMAIL] = gdk_atom_intern(kAOLMailMime, FALSE);
sSelTypes[TARGET_IMAGE_PNG] = gdk_atom_intern(kPNGImageMime, FALSE);
sSelTypes[TARGET_IMAGE_JPEG] = gdk_atom_intern(kJPEGImageMime, FALSE);
sSelTypes[TARGET_IMAGE_GIF] = gdk_atom_intern(kGIFImageMime, FALSE);
// compatibility with other apps
// create invisible widget to use for the clipboard
sWidget = gtk_invisible_new();
// add the clipboard pointer to the widget so we can get it.
gtk_object_set_data(GTK_OBJECT(sWidget), "cb", this);
NS_ADDREF_THIS();
// Handle selection requests if we called gtk_selection_add_target:
gtk_signal_connect(GTK_OBJECT(sWidget), "selection_get",
GTK_SIGNAL_FUNC(nsClipboard::SelectionGetCB),
nsnull);
// When someone else takes the selection away:
gtk_signal_connect(GTK_OBJECT(sWidget), "selection_clear_event",
GTK_SIGNAL_FUNC(nsClipboard::SelectionClearCB),
nsnull);
// Set up the paste handler:
gtk_signal_connect(GTK_OBJECT(sWidget), "selection_received",
GTK_SIGNAL_FUNC(nsClipboard::SelectionReceivedCB),
nsnull);
}
//-------------------------------------------------------------------------
NS_IMETHODIMP nsClipboard::SetNativeClipboardData()
{
mIgnoreEmptyNotification = PR_TRUE;
#ifdef DEBUG_CLIPBOARD
printf(" nsClipboard::SetNativeClipboardData()\n");
#endif /* DEBUG_CLIPBOARD */
// make sure we have a good transferable
if (nsnull == mTransferable) {
printf("nsClipboard::SetNativeClipboardData(): no transferable!\n");
return NS_ERROR_FAILURE;
}
// are we already the owner?
if (gdk_selection_owner_get(GDK_SELECTION_PRIMARY) == sWidget->window)
{
// if so, clear all the targets
__gtk_selection_target_list_remove(sWidget);
// gtk_selection_remove_all(sWidget);
}
// we arn't already the owner, so we will become it
gint have_selection = gtk_selection_owner_set(sWidget,
GDK_SELECTION_PRIMARY,
GDK_CURRENT_TIME);
if (have_selection == 0)
return NS_ERROR_FAILURE;
// get flavor list that includes all flavors that can be written (including ones
// obtained through conversion)
nsCOMPtr<nsISupportsArray> flavorList;
nsresult errCode = mTransferable->FlavorsTransferableCanExport ( getter_AddRefs(flavorList) );
if ( NS_FAILED(errCode) )
return NS_ERROR_FAILURE;
PRUint32 cnt;
flavorList->Count(&cnt);
for ( PRUint32 i=0; i<cnt; ++i )
{
nsCOMPtr<nsISupports> genericFlavor;
flavorList->GetElementAt ( i, getter_AddRefs(genericFlavor) );
nsCOMPtr<nsISupportsString> currentFlavor ( do_QueryInterface(genericFlavor) );
if ( currentFlavor ) {
nsXPIDLCString flavorStr;
currentFlavor->ToString(getter_Copies(flavorStr));
gint format = GetFormat(flavorStr);
// add these types as selection targets
RegisterFormat(format);
}
}
mIgnoreEmptyNotification = PR_FALSE;
return NS_OK;
}
void nsClipboard::AddTarget(GdkAtom aAtom)
{
gtk_selection_add_target(sWidget,
GDK_SELECTION_PRIMARY,
aAtom, aAtom);
}
gint nsClipboard::GetFormat(const char* aMimeStr)
{
gint type = TARGET_NONE;
nsCAutoString mimeStr ( CBufDescriptor(NS_CONST_CAST(char*,aMimeStr), PR_TRUE, PL_strlen(aMimeStr)+1) );
#ifdef DEBUG_CLIPBOARD
g_print(" nsClipboard::GetFormat(%s)\n", aMimeStr);
#endif
if (mimeStr.Equals(kTextMime)) {
type = TARGET_TEXT_PLAIN;
} else if (mimeStr.Equals("STRING")) {
type = TARGET_TEXT_PLAIN;
} else if (mimeStr.Equals(kXIFMime)) {
type = TARGET_TEXT_XIF;
} else if (mimeStr.Equals(kUnicodeMime)) {
type = TARGET_TEXT_UNICODE;
} else if (mimeStr.Equals(kHTMLMime)) {
type = TARGET_TEXT_HTML;
} else if (mimeStr.Equals(kAOLMailMime)) {
type = TARGET_AOLMAIL;
} else if (mimeStr.Equals(kPNGImageMime)) {
type = TARGET_IMAGE_PNG;
} else if (mimeStr.Equals(kJPEGImageMime)) {
type = TARGET_IMAGE_JPEG;
} else if (mimeStr.Equals(kGIFImageMime)) {
type = TARGET_IMAGE_GIF;
}
#ifdef WE_DO_DND
else if (mimeStr.Equals(kDropFilesMime)) {
format = CF_HDROP;
} else {
format = ::RegisterClipboardFormat(aMimeStr);
}
#endif
return type;
}
void nsClipboard::RegisterFormat(gint format)
{
#ifdef DEBUG_CLIPBOARD
g_print(" nsClipboard::RegisterFormat(%s)\n", gdk_atom_name(sSelTypes[format]));
#endif
/* when doing the selection_add_target, each case should have the same last parameter
which matches the case match */
switch(format)
{
case TARGET_TEXT_PLAIN:
// text/plain (default)
AddTarget(sSelTypes[format]);
// STRING (what X uses)
AddTarget(GDK_SELECTION_TYPE_STRING);
break;
case TARGET_TEXT_XIF:
// text/xif (default)
AddTarget(sSelTypes[format]);
break;
case TARGET_TEXT_UNICODE:
// text/unicode (default)
AddTarget(sSelTypes[format]);
// UTF8 (what X uses)
AddTarget(sSelTypes[TARGET_UTF8]);
break;
case TARGET_TEXT_HTML:
// text/html (default)
AddTarget(sSelTypes[format]);
break;
case TARGET_AOLMAIL:
// text/aolmail (default)
AddTarget(sSelTypes[format]);
break;
case TARGET_IMAGE_PNG:
// image/png (default)
AddTarget(sSelTypes[format]);
break;
case TARGET_IMAGE_JPEG:
// image/jpeg (default)
AddTarget(sSelTypes[format]);
break;
case TARGET_IMAGE_GIF:
// image/gif (default)
AddTarget(sSelTypes[format]);
break;
default:
// if we don't match something above, then just add it like its something we know about...
AddTarget(sSelTypes[format]);
}
}
PRBool nsClipboard::DoRealConvert(GdkAtom type)
{
#ifdef DEBUG_CLIPBOARD
g_print(" nsClipboard::DoRealConvert(%li)\n {\n", type);
#endif
int e = 0;
// Set a flag saying that we're blocking waiting for the callback:
mBlocking = PR_TRUE;
//
// ask X what kind of data we can get
//
#ifdef DEBUG_CLIPBOARD
g_print(" Doing real conversion of atom type '%s'\n", gdk_atom_name(type));
#endif
gtk_selection_convert(sWidget,
GDK_SELECTION_PRIMARY,
type,
GDK_CURRENT_TIME);
// Now we need to wait until the callback comes in ...
// i is in case we get a runaway (yuck).
#ifdef DEBUG_CLIPBOARD
printf(" Waiting for the callback... mBlocking = %d\n", mBlocking);
#endif /* DEBUG_CLIPBOARD */
for (e=0; mBlocking == PR_TRUE && e < 1000; ++e)
{
gtk_main_iteration_do(PR_TRUE);
}
#ifdef DEBUG_CLIPBOARD
g_print(" }\n");
#endif
if (mSelectionData.length > 0)
return PR_TRUE;
return PR_FALSE;
}
/* return PR_TRUE if we have converted or PR_FALSE if we havn't and need to keep being called */
PRBool nsClipboard::DoConvert(gint format)
{
#ifdef DEBUG_CLIPBOARD
g_print(" nsClipboard::DoConvert(%s)\n", gdk_atom_name(sSelTypes[format]));
#endif
/* when doing the selection_add_target, each case should have the same last parameter
which matches the case match */
PRBool r = PR_FALSE;
switch(format)
{
case TARGET_TEXT_PLAIN:
r = DoRealConvert(sSelTypes[format]);
if (r) return r;
r = DoRealConvert(GDK_SELECTION_TYPE_STRING);
if (r) return r;
break;
case TARGET_TEXT_XIF:
r = DoRealConvert(sSelTypes[format]);
if (r) return r;
break;
case TARGET_TEXT_UNICODE:
r = DoRealConvert(sSelTypes[format]);
if (r) return r;
r = DoRealConvert(sSelTypes[TARGET_UTF8]);
if (r) return r;
break;
case TARGET_TEXT_HTML:
r = DoRealConvert(sSelTypes[format]);
if (r) return r;
break;
case TARGET_AOLMAIL:
r = DoRealConvert(sSelTypes[format]);
if (r) return r;
break;
case TARGET_IMAGE_PNG:
r = DoRealConvert(sSelTypes[format]);
if (r) return r;
break;
case TARGET_IMAGE_JPEG:
r = DoRealConvert(sSelTypes[format]);
if (r) return r;
break;
case TARGET_IMAGE_GIF:
r = DoRealConvert(sSelTypes[format]);
if (r) return r;
break;
default:
g_print("DoConvert called with bogus format\n");
}
return r;
}
//-------------------------------------------------------------------------
//
// The blocking Paste routine
//
//-------------------------------------------------------------------------
NS_IMETHODIMP
nsClipboard::GetNativeClipboardData(nsITransferable * aTransferable)
{
#ifdef DEBUG_CLIPBOARD
printf("nsClipboard::GetNativeClipboardData()\n");
#endif /* DEBUG_CLIPBOARD */
// make sure we have a good transferable
if (nsnull == aTransferable) {
printf(" GetNativeClipboardData: Transferable is null!\n");
return NS_ERROR_FAILURE;
}
// get flavor list that includes all acceptable flavors (including ones obtained through
// conversion)
nsCOMPtr<nsISupportsArray> flavorList;
nsresult errCode = aTransferable->FlavorsTransferableCanImport ( getter_AddRefs(flavorList) );
if ( NS_FAILED(errCode) )
return NS_ERROR_FAILURE;
// Walk through flavors and see which flavor matches the one being pasted:
PRUint32 cnt;
flavorList->Count(&cnt);
nsCAutoString foundFlavor;
for ( PRUint32 i = 0; i < cnt; ++i ) {
nsCOMPtr<nsISupports> genericFlavor;
flavorList->GetElementAt ( i, getter_AddRefs(genericFlavor) );
nsCOMPtr<nsISupportsString> currentFlavor ( do_QueryInterface(genericFlavor) );
if ( currentFlavor ) {
nsXPIDLCString flavorStr;
currentFlavor->ToString ( getter_Copies(flavorStr) );
gint format = GetFormat(flavorStr);
if (DoConvert(format)) {
foundFlavor = flavorStr;
break;
}
}
}
#ifdef DEBUG_CLIPBOARD
printf(" Got the callback: '%s', %d\n",
mSelectionData.data, mSelectionData.length);
#endif /* DEBUG_CLIPBOARD */
// We're back from the callback, no longer blocking:
mBlocking = PR_FALSE;
//
// Now we have data in mSelectionData.data.
// We just have to copy it to the transferable.
//
#if 0
// pinkerton - we have the flavor already from above, so we don't need
// to re-derrive it.
nsString *name = new nsString((const char*)gdk_atom_name(mSelectionData.type));
int format = GetFormat(*name);
df->SetString((const char*)gdk_atom_name(sSelTypes[format]));
#endif
nsCOMPtr<nsISupports> genericDataWrapper;
nsPrimitiveHelpers::CreatePrimitiveForData ( foundFlavor, mSelectionData.data, mSelectionData.length, getter_AddRefs(genericDataWrapper) );
aTransferable->SetTransferData(foundFlavor,
genericDataWrapper,
mSelectionData.length);
//delete name;
// transferable is now copying the data, so we can free it.
// g_free(mSelectionData.data);
mSelectionData.data = nsnull;
mSelectionData.length = 0;
return NS_OK;
}
/**
* Called when the data from a paste comes in (recieved from gdk_selection_convert)
*
* @param aWidget the widget
* @param aSelectionData gtk selection stuff
* @param aTime time the selection was requested
*/
void
nsClipboard::SelectionReceivedCB (GtkWidget *aWidget,
GtkSelectionData *aSelectionData,
guint aTime)
{
#ifdef DEBUG_CLIPBOARD
printf(" nsClipboard::SelectionReceivedCB\n {\n");
#endif /* DEBUG_CLIPBOARD */
nsClipboard *cb =(nsClipboard *)gtk_object_get_data(GTK_OBJECT(aWidget),
"cb");
if (!cb)
{
g_print("no clipboard found.. this is bad.\n");
return;
}
cb->SelectionReceiver(aWidget, aSelectionData);
#ifdef DEBUG_CLIPBOARD
g_print(" }\n");
#endif
}
/**
* local method (called from nsClipboard::SelectionReceivedCB)
*
* @param aWidget the widget
* @param aSelectionData gtk selection stuff
*/
void
nsClipboard::SelectionReceiver (GtkWidget *aWidget,
GtkSelectionData *aSD)
{
gint type;
mBlocking = PR_FALSE;
if (aSD->length < 0)
{
printf(" Error retrieving selection: length was %d\n",
aSD->length);
return;
}
type = TARGET_NONE;
for (int i=0; i < TARGET_LAST; i++)
{
if (sSelTypes[i] == aSD->type)
{
type = i;
break;
}
}
switch (type)
{
case GDK_TARGET_STRING:
case TARGET_UTF8:
case TARGET_TEXT_PLAIN:
case TARGET_TEXT_XIF:
case TARGET_TEXT_UNICODE:
case TARGET_TEXT_HTML:
#ifdef DEBUG_CLIPBOARD
g_print(" Copying mSelectionData pointer -- ");
#endif
mSelectionData = *aSD;
mSelectionData.data = g_new(guchar, aSD->length + 1);
#ifdef DEBUG_CLIPBOARD
g_print(" Data = %s\n Length = %i\n", aSD->data, aSD->length);
#endif
memcpy(mSelectionData.data,
aSD->data,
aSD->length);
// Null terminate in case anyone cares,
// and so we can print the string for debugging:
mSelectionData.data[aSD->length] = '\0';
mSelectionData.length = aSD->length;
return;
default:
mSelectionData = *aSD;
mSelectionData.data = g_new(guchar, aSD->length + 1);
memcpy(mSelectionData.data,
aSD->data,
aSD->length);
mSelectionData.length = aSD->length;
return;
}
}
/**
* Some platforms support deferred notification for putting data on the clipboard
* This method forces the data onto the clipboard in its various formats
* This may be used if the application going away.
*
* @result NS_OK if successful.
*/
NS_IMETHODIMP nsClipboard::ForceDataToClipboard()
{
#ifdef DEBUG_CLIPBOARD
printf(" nsClipboard::ForceDataToClipboard()\n");
#endif /* DEBUG_CLIPBOARD */
// make sure we have a good transferable
if (nsnull == mTransferable) {
return NS_ERROR_FAILURE;
}
return NS_OK;
}
NS_IMETHODIMP
nsClipboard::HasDataMatchingFlavors(nsISupportsArray* aFlavorList, PRBool * outResult)
{
*outResult = PR_TRUE; // say we always do.
return NS_OK;
}
/**
* This is the callback which is called when another app
* requests the selection.
*
* @param widget The widget
* @param aSelectionData Selection data
* @param info Value passed in from the callback init
* @param time Time when the selection request came in
*/
void nsClipboard::SelectionGetCB(GtkWidget *widget,
GtkSelectionData *aSelectionData,
guint aInfo,
guint aTime)
{
#ifdef DEBUG_CLIPBOARD
printf("nsClipboard::SelectionGetCB\n");
#endif /* DEBUG_CLIPBOARD */
nsClipboard *cb = (nsClipboard *)gtk_object_get_data(GTK_OBJECT(widget),
"cb");
void *clipboardData;
PRUint32 dataLength;
nsresult rv;
// Make sure we have a transferable:
if (!cb->mTransferable) {
printf("Clipboard has no transferable!\n");
return;
}
#ifdef DEBUG_CLIPBOARD
g_print(" aInfo == %d -", aInfo);
#endif
char* dataFlavor = nsnull;
// switch aInfo (atom) to our enum
int type = (int)aInfo;
for (int i=0; i < TARGET_LAST; i++)
{
if (sSelTypes[i] == aInfo)
{
type = i;
break;
}
}
switch(type)
{
case GDK_TARGET_STRING:
case TARGET_TEXT_PLAIN:
dataFlavor = kTextMime;
break;
case TARGET_TEXT_XIF:
dataFlavor = kXIFMime;
break;
case TARGET_TEXT_UNICODE:
case TARGET_UTF8:
dataFlavor = kUnicodeMime;
break;
case TARGET_TEXT_HTML:
dataFlavor = kHTMLMime;
break;
case TARGET_AOLMAIL:
dataFlavor = kAOLMailMime;
break;
case TARGET_IMAGE_PNG:
dataFlavor = kPNGImageMime;
break;
case TARGET_IMAGE_JPEG:
dataFlavor = kJPEGImageMime;
break;
case TARGET_IMAGE_GIF:
dataFlavor = kGIFImageMime;
break;
default:
{
/* handle outside things */
}
}
#ifdef DEBUG_CLIPBOARD
g_print("- aInfo is for %s\n", gdk_atom_name(aInfo));
#endif
// Get data out of transferable.
nsCOMPtr<nsISupports> genericDataWrapper;
rv = cb->mTransferable->GetTransferData(dataFlavor,
getter_AddRefs(genericDataWrapper),
&dataLength);
nsPrimitiveHelpers::CreateDataFromPrimitive ( dataFlavor, genericDataWrapper, &clipboardData, dataLength );
if (NS_SUCCEEDED(rv) && clipboardData && dataLength > 0) {
size_t size = 1;
// find the number of bytes in the data for the below thing
// size_t size = sizeof((void*)((unsigned char)clipboardData[0]));
// g_print("************ ***************** ******************* %i\n", size);
gtk_selection_data_set(aSelectionData,
aInfo, size*8,
(unsigned char *)clipboardData,
dataLength);
nsCRT::free ( NS_REINTERPRET_CAST(char*, clipboardData) );
}
else
printf("Transferable didn't support the data flavor\n");
}
/**
* Called when another app requests selection ownership
*
* @param aWidget the widget
* @param aEvent the GdkEvent for the selection
* @param aData value passed in from the callback init
*/
void nsClipboard::SelectionClearCB(GtkWidget *aWidget,
GdkEventSelection *aEvent,
gpointer aData)
{
#ifdef DEBUG_CLIPBOARD
printf(" nsClipboard::SelectionClearCB\n");
#endif /* DEBUG_CLIPBOARD */
nsClipboard *cb = (nsClipboard *)gtk_object_get_data(GTK_OBJECT(aWidget),
"cb");
cb->EmptyClipboard();
}
/**
* The routine called when another app asks for the content of the selection
*
* @param aWidget the widget
* @param aSelectionData gtk selection stuff
* @param aData value passed in from the callback init
*/
void
nsClipboard::SelectionRequestCB (GtkWidget *aWidget,
GtkSelectionData *aSelectionData,
gpointer aData)
{
#ifdef DEBUG_CLIPBOARD
printf(" nsClipboard::SelectionRequestCB\n");
#endif /* DEBUG_CLIPBOARD */
}
/**
* ...
*
* @param aWidget the widget
* @param aSelectionData gtk selection stuff
* @param aData value passed in from the callback init
*/
void
nsClipboard::SelectionNotifyCB (GtkWidget *aWidget,
GtkSelectionData *aSelectionData,
gpointer aData)
{
#ifdef DEBUG_CLIPBOARD
printf(" nsClipboard::SelectionNotifyCB\n");
#endif /* DEBUG_CLIPBOARD */
}

View File

@@ -0,0 +1,132 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsClipboard_h__
#define nsClipboard_h__
#include "nsBaseClipboard.h"
#include <gtk/gtk.h>
#include <gtk/gtkinvisible.h>
class nsITransferable;
class nsIClipboardOwner;
class nsIWidget;
/**
* Native Gtk Clipboard wrapper
*/
class nsClipboard : public nsBaseClipboard
{
public:
nsClipboard();
virtual ~nsClipboard();
// nsIClipboard
NS_IMETHOD ForceDataToClipboard();
NS_IMETHOD HasDataMatchingFlavors(nsISupportsArray* aFlavorList, PRBool * outResult);
// invisible widget. also used by dragndrop
static GtkWidget *sWidget;
protected:
NS_IMETHOD SetNativeClipboardData();
NS_IMETHOD GetNativeClipboardData(nsITransferable * aTransferable);
PRBool mIgnoreEmptyNotification;
void AddTarget(GdkAtom aAtom);
gint GetFormat(const char* aMimeStr);
void RegisterFormat(gint format);
PRBool DoRealConvert(GdkAtom type);
PRBool DoConvert(gint format);
void Init(void);
// Used for communicating pasted data
// from the asynchronous X routines back to a blocking paste:
GtkSelectionData mSelectionData;
PRBool mBlocking;
void SelectionReceiver(GtkWidget *aWidget,
GtkSelectionData *aSD);
/**
* This is the callback which is called when another app
* requests the selection.
*
* @param widget The widget
* @param aSelectionData Selection data
* @param info Value passed in from the callback init
* @param time Time when the selection request came in
*/
static void SelectionGetCB(GtkWidget *aWidget,
GtkSelectionData *aSelectionData,
guint /*info*/,
guint /*time*/);
/**
* Called when another app requests selection ownership
*
* @param aWidget the widget
* @param aEvent the GdkEvent for the selection
* @param aData value passed in from the callback init
*/
static void SelectionClearCB(GtkWidget *aWidget,
GdkEventSelection *aEvent,
gpointer aData);
/**
* The routine called when another app asks for the content of the selection
*
* @param aWidget the widget
* @param aSelectionData gtk selection stuff
* @param aData value passed in from the callback init
*/
static void SelectionRequestCB(GtkWidget *aWidget,
GtkSelectionData *aSelectionData,
gpointer data);
/**
* Called when the data from a paste comes in
*
* @param aWidget the widget
* @param aSelectionData gtk selection stuff
* @param aTime time the selection was requested
*/
static void SelectionReceivedCB(GtkWidget *aWidget,
GtkSelectionData *aSelectionData,
guint aTime);
static void SelectionNotifyCB(GtkWidget *aWidget,
GtkSelectionData *aSelectionData,
gpointer aData);
};
#endif // nsClipboard_h__

View File

@@ -0,0 +1,357 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include <gtk/gtk.h>
#include "nsComboBox.h"
#include "nsGUIEvent.h"
#include "nsString.h"
#define DBG 0
#define INITIAL_MAX_ITEMS 128
#define ITEMS_GROWSIZE 128
NS_IMPL_ADDREF_INHERITED(nsComboBox, nsWidget)
NS_IMPL_RELEASE_INHERITED(nsComboBox, nsWidget)
NS_IMPL_QUERY_INTERFACE3(nsComboBox, nsIComboBox, nsIListWidget, nsIWidget)
//-------------------------------------------------------------------------
//
// nsComboBox constructor
//
//-------------------------------------------------------------------------
nsComboBox::nsComboBox() : nsWidget(), nsIListWidget(), nsIComboBox()
{
NS_INIT_REFCNT();
mMultiSelect = PR_FALSE;
mItems = nsnull;
mNumItems = 0;
}
//-------------------------------------------------------------------------
//
// nsComboBox:: destructor
//
//-------------------------------------------------------------------------
nsComboBox::~nsComboBox()
{
if (mItems) {
for (GList *items = mItems; items; items = (GList*) g_list_next(items)){
g_free(items->data);
}
g_list_free(mItems);
}
gtk_widget_destroy(mCombo);
}
void nsComboBox::InitCallbacks(char * aName)
{
InstallButtonPressSignal(mWidget);
InstallButtonReleaseSignal(mWidget);
InstallEnterNotifySignal(mWidget);
InstallLeaveNotifySignal(mWidget);
// These are needed so that the events will go to us and not our parent.
AddToEventMask(mWidget,
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_EXPOSURE_MASK |
GDK_FOCUS_CHANGE_MASK |
GDK_KEY_PRESS_MASK |
GDK_KEY_RELEASE_MASK |
GDK_LEAVE_NOTIFY_MASK |
GDK_POINTER_MOTION_MASK);
}
//-------------------------------------------------------------------------
//
// initializer
//
//-------------------------------------------------------------------------
NS_METHOD nsComboBox::SetMultipleSelection(PRBool aMultipleSelections)
{
mMultiSelect = aMultipleSelections;
return NS_OK;
}
//-------------------------------------------------------------------------
//
// AddItemAt
//
//-------------------------------------------------------------------------
NS_METHOD nsComboBox::AddItemAt(nsString &aItem, PRInt32 aPosition)
{
NS_ALLOC_STR_BUF(val, aItem, 256);
mItems = g_list_insert( mItems, g_strdup(val), aPosition );
mNumItems++;
if (mCombo) {
gtk_combo_set_popdown_strings( GTK_COMBO( mCombo ), mItems );
}
NS_FREE_STR_BUF(val);
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Finds an item at a postion
//
//-------------------------------------------------------------------------
PRInt32 nsComboBox::FindItem(nsString &aItem, PRInt32 aStartPos)
{
NS_ALLOC_STR_BUF(val, aItem, 256);
int i;
PRInt32 inx = -1;
GList *items = g_list_nth(mItems, aStartPos);
for(i=0; items != NULL; items = (GList *) g_list_next(items), i++ )
{
if(!strcmp(val, (gchar *) items->data))
{
inx = i;
break;
}
}
NS_FREE_STR_BUF(val);
return inx;
}
//-------------------------------------------------------------------------
//
// CountItems - Get Item Count
//
//-------------------------------------------------------------------------
PRInt32 nsComboBox::GetItemCount()
{
return (PRInt32)mNumItems;
}
//-------------------------------------------------------------------------
//
// Removes an Item at a specified location
//
//-------------------------------------------------------------------------
PRBool nsComboBox::RemoveItemAt(PRInt32 aPosition)
{
if (aPosition >= 0 && aPosition < mNumItems) {
g_free(g_list_nth(mItems, aPosition)->data);
mItems = g_list_remove_link(mItems, g_list_nth(mItems, aPosition));
mNumItems--;
if (mCombo) {
gtk_combo_set_popdown_strings(GTK_COMBO( mCombo ), mItems);
}
return PR_TRUE;
}
else
return PR_FALSE;
}
//-------------------------------------------------------------------------
//
// Removes an Item at a specified location
//
//-------------------------------------------------------------------------
PRBool nsComboBox::GetItemAt(nsString& anItem, PRInt32 aPosition)
{
if (aPosition >= 0 && aPosition < mNumItems) {
anItem = (gchar *) g_list_nth(mItems, aPosition)->data;
return PR_TRUE;
}
return PR_FALSE;
}
//-------------------------------------------------------------------------
//
// Gets the selected of selected item
//
//-------------------------------------------------------------------------
NS_METHOD nsComboBox::GetSelectedItem(nsString& aItem)
{
aItem.Truncate();
if (mCombo) {
aItem = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO(mCombo)->entry));
}
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Gets the list of selected otems
//
//-------------------------------------------------------------------------
PRInt32 nsComboBox::GetSelectedIndex()
{
nsString nsstring;
GetSelectedItem(nsstring);
return FindItem(nsstring, 0);
}
//-------------------------------------------------------------------------
//
// SelectItem
//
//-------------------------------------------------------------------------
NS_METHOD nsComboBox::SelectItem(PRInt32 aPosition)
{
GList *pos;
if (!mItems)
return NS_ERROR_FAILURE;
pos = g_list_nth(mItems, aPosition);
if (!pos)
return NS_ERROR_FAILURE;
if (mCombo) {
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(mCombo)->entry),
(gchar *) pos->data);
}
return NS_OK;
}
//-------------------------------------------------------------------------
//
// GetSelectedCount
//
//-------------------------------------------------------------------------
PRInt32 nsComboBox::GetSelectedCount()
{
if (!mMultiSelect) {
PRInt32 inx = GetSelectedIndex();
return (inx == -1? 0 : 1);
} else {
return 0;
}
}
//-------------------------------------------------------------------------
//
// GetSelectedIndices
//
//-------------------------------------------------------------------------
NS_METHOD nsComboBox::GetSelectedIndices(PRInt32 aIndices[], PRInt32 aSize)
{
// this is an error
return NS_ERROR_FAILURE;
}
//-------------------------------------------------------------------------
//
// Deselect
//
//-------------------------------------------------------------------------
NS_METHOD nsComboBox::Deselect()
{
if (mMultiSelect) {
return NS_ERROR_FAILURE;
}
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Create the native GtkCombo widget
//
//-------------------------------------------------------------------------
NS_METHOD nsComboBox::CreateNative(GtkObject *parentWindow)
{
mWidget = ::gtk_event_box_new();
::gtk_widget_set_name(mWidget, "nsComboBox");
mCombo = ::gtk_combo_new();
gtk_widget_show(mCombo);
/* make the stuff uneditable */
gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(mCombo)->entry), PR_FALSE);
gtk_signal_connect(GTK_OBJECT(mCombo),
"destroy",
GTK_SIGNAL_FUNC(DestroySignal),
this);
gtk_signal_connect(GTK_OBJECT(GTK_COMBO(mCombo)->popwin),
"unmap",
GTK_SIGNAL_FUNC(UnmapSignal),
this);
gtk_container_add(GTK_CONTAINER(mWidget), mCombo);
return NS_OK;
}
void
nsComboBox::OnDestroySignal(GtkWidget* aGtkWidget)
{
if (aGtkWidget == mCombo) {
mCombo = nsnull;
}
else {
nsWidget::OnDestroySignal(aGtkWidget);
}
}
gint
nsComboBox::UnmapSignal(GtkWidget* aGtkWidget, nsComboBox* aCombo)
{
if (!aCombo) return PR_FALSE;
aCombo->OnUnmapSignal(aGtkWidget);
return PR_TRUE;
}
void
nsComboBox::OnUnmapSignal(GtkWidget * aWidget)
{
if (!aWidget) return;
// Generate a NS_CONTROL_CHANGE event and send it to the frame
nsGUIEvent event;
event.eventStructType = NS_GUI_EVENT;
nsPoint point(0,0);
InitEvent(event, NS_CONTROL_CHANGE, &point);
DispatchWindowEvent(&event);
}
//-------------------------------------------------------------------------
//
// Get handle for style
//
//-------------------------------------------------------------------------
/*virtual*/
void nsComboBox::SetFontNative(GdkFont *aFont)
{
GtkStyle *style = gtk_style_copy(GTK_WIDGET (g_list_nth_data(gtk_container_children(GTK_CONTAINER (mWidget)),0))->style);
// gtk_style_copy ups the ref count of the font
gdk_font_unref (style->font);
style->font = aFont;
gdk_font_ref(style->font);
gtk_widget_set_style(GTK_BIN (mWidget)->child, style);
gtk_style_unref(style);
}

View File

@@ -0,0 +1,75 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsComboBox_h__
#define nsComboBox_h__
#include "nsWidget.h"
#include "nsIComboBox.h"
/**
* Native GTK+ Listbox wrapper
*/
class nsComboBox : public nsWidget,
public nsIListWidget,
public nsIComboBox
{
public:
nsComboBox();
virtual ~nsComboBox();
NS_DECL_ISUPPORTS_INHERITED
// nsIComboBox interface
NS_IMETHOD AddItemAt(nsString &aItem, PRInt32 aPosition);
virtual PRInt32 FindItem(nsString &aItem, PRInt32 aStartPos);
virtual PRInt32 GetItemCount();
virtual PRBool RemoveItemAt(PRInt32 aPosition);
virtual PRBool GetItemAt(nsString& anItem, PRInt32 aPosition);
NS_IMETHOD GetSelectedItem(nsString& aItem);
virtual PRInt32 GetSelectedIndex();
NS_IMETHOD SelectItem(PRInt32 aPosition);
NS_IMETHOD Deselect() ;
// nsIComboBox interface
NS_IMETHOD SetMultipleSelection(PRBool aMultipleSelections);
PRInt32 GetSelectedCount();
NS_IMETHOD GetSelectedIndices(PRInt32 aIndices[], PRInt32 aSize);
virtual void SetFontNative(GdkFont *aFont);
protected:
NS_IMETHOD CreateNative(GtkObject *parentWindow);
virtual void InitCallbacks(char * aName = nsnull);
virtual void OnDestroySignal(GtkWidget* aGtkWidget);
virtual void OnUnmapSignal(GtkWidget* aWidget);
static gint UnmapSignal(GtkWidget* aGtkWidget, nsComboBox* aCombo);
GtkWidget *mCombo; /* workaround for gtkcombo bug */
GList *mItems;
PRBool mMultiSelect;
int mNumItems;
};
#endif // nsComboBox_h__

View File

@@ -0,0 +1,744 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include <gtk/gtk.h>
#include "nsContextMenu.h"
#include "nsIComponentManager.h"
#include "nsIDOMElement.h"
#include "nsIDOMNode.h"
#include "nsIMenuBar.h"
#include "nsIMenuItem.h"
#include "nsIMenuListener.h"
#include "nsString.h"
#include "nsGtkEventHandler.h"
#include "nsCOMPtr.h"
#include "nsWidgetsCID.h"
static NS_DEFINE_CID(kMenuCID, NS_MENU_CID);
static NS_DEFINE_CID(kMenuItemCID, NS_MENUITEM_CID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
//-------------------------------------------------------------------------
nsresult nsContextMenu::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
*aInstancePtr = NULL;
if (aIID.Equals(nsIMenu::GetIID())) {
*aInstancePtr = (void*)(nsIMenu*) this;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*)(nsISupports*)(nsIMenu*)this;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsIMenuListener::GetIID())) {
*aInstancePtr = (void*)(nsIMenuListener*)this;
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
//-------------------------------------------------------------------------
NS_IMPL_ADDREF(nsContextMenu)
NS_IMPL_RELEASE(nsContextMenu)
//-------------------------------------------------------------------------
//
// nsContextMenu constructor
//
//-------------------------------------------------------------------------
nsContextMenu::nsContextMenu()
{
NS_INIT_REFCNT();
mNumMenuItems = 0;
mMenu = nsnull;
mParent = nsnull;
mListener = nsnull;
mConstructCalled = PR_FALSE;
mDOMNode = nsnull;
mWebShell = nsnull;
mDOMElement = nsnull;
mAlignment = "topleft";
mAnchorAlignment = "none";
}
//-------------------------------------------------------------------------
//
// nsContextMenu destructor
//
//-------------------------------------------------------------------------
nsContextMenu::~nsContextMenu()
{
}
//-------------------------------------------------------------------------
//
// Create the proper widget
//
//-------------------------------------------------------------------------
NS_METHOD nsContextMenu::Create(nsISupports *aParent,
const nsString& anAlignment,
const nsString& anAnchorAlignment)
{
if(aParent)
{
nsIWidget *parent = nsnull;
aParent->QueryInterface(nsIWidget::GetIID(), (void**) &parent);
if(parent)
{
mParent = parent;
NS_RELEASE(parent);
}
}
mAlignment = anAlignment;
mAnchorAlignment = anAnchorAlignment;
mMenu = gtk_menu_new();
gtk_signal_connect (GTK_OBJECT (mMenu), "map",
GTK_SIGNAL_FUNC(menu_map_handler),
this);
gtk_signal_connect (GTK_OBJECT (mMenu), "unmap",
GTK_SIGNAL_FUNC(menu_unmap_handler),
this);
return NS_OK;
}
//-------------------------------------------------------------------------
NS_METHOD nsContextMenu::GetParent(nsISupports*& aParent)
{
aParent = nsnull;
if (nsnull != mParent) {
return mParent->QueryInterface(kISupportsIID,
(void**)&aParent);
}
return NS_ERROR_FAILURE;
}
//-------------------------------------------------------------------------
NS_METHOD nsContextMenu::AddItem(nsISupports * aItem)
{
if(aItem)
{
nsIMenuItem * menuitem = nsnull;
aItem->QueryInterface(nsIMenuItem::GetIID(),
(void**)&menuitem);
if(menuitem)
{
AddMenuItem(menuitem); // nsMenu now owns this
NS_RELEASE(menuitem);
}
else
{
nsIMenu * menu = nsnull;
aItem->QueryInterface(nsIMenu::GetIID(),
(void**)&menu);
if(menu)
{
AddMenu(menu); // nsMenu now owns this
NS_RELEASE(menu);
}
}
}
return NS_OK;
}
//-------------------------------------------------------------------------
NS_METHOD nsContextMenu::AddMenuItem(nsIMenuItem * aMenuItem)
{
GtkWidget *widget;
void *voidData;
aMenuItem->GetNativeData(voidData);
widget = GTK_WIDGET(voidData);
gtk_menu_shell_append (GTK_MENU_SHELL (mMenu), widget);
// XXX add aMenuItem to internal data structor list
// Need to be adding an nsISupports *, not nsIMenuItem *
nsISupports * supports = nsnull;
aMenuItem->QueryInterface(kISupportsIID,
(void**)&supports);
{
mMenuItemVoidArray.AppendElement(supports);
mNumMenuItems++;
}
return NS_OK;
}
//-------------------------------------------------------------------------
NS_METHOD nsContextMenu::AddMenu(nsIMenu * aMenu)
{
nsString Label;
GtkWidget *newmenu=nsnull;
char *labelStr;
void *voidData=NULL;
aMenu->GetLabel(Label);
labelStr = Label.ToNewCString();
// Create nsMenuItem
nsIMenuItem * pnsMenuItem = nsnull;
nsresult rv = nsComponentManager::CreateInstance(kMenuItemCID,
nsnull,
nsIMenuItem::GetIID(),
(void**)&pnsMenuItem);
if (NS_OK == rv) {
nsISupports * supports = nsnull;
QueryInterface(kISupportsIID, (void**) &supports);
pnsMenuItem->Create(supports, labelStr, PR_FALSE); //PR_TRUE);
NS_RELEASE(supports);
pnsMenuItem->QueryInterface(kISupportsIID, (void**) &supports);
AddItem(supports); // Parent should now own menu item
NS_RELEASE(supports);
void * menuitem = nsnull;
pnsMenuItem->GetNativeData(menuitem);
voidData = NULL;
aMenu->GetNativeData(&voidData);
newmenu = GTK_WIDGET(voidData);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), newmenu);
NS_RELEASE(pnsMenuItem);
}
nsCRT::free(labelStr);
return NS_OK;
}
//-------------------------------------------------------------------------
NS_METHOD nsContextMenu::AddSeparator()
{
// Create nsMenuItem
nsIMenuItem * pnsMenuItem = nsnull;
nsresult rv = nsComponentManager::CreateInstance(
kMenuItemCID, nsnull, nsIMenuItem::GetIID(), (void**)&pnsMenuItem);
if (NS_OK == rv) {
nsString tmp = "separator";
nsISupports * supports = nsnull;
QueryInterface(kISupportsIID, (void**) &supports);
pnsMenuItem->Create(supports, tmp, PR_TRUE);
NS_RELEASE(supports);
pnsMenuItem->QueryInterface(kISupportsIID, (void**) &supports);
AddItem(supports); // Parent should now own menu item
NS_RELEASE(supports);
NS_RELEASE(pnsMenuItem);
}
return NS_OK;
}
//-------------------------------------------------------------------------
NS_METHOD nsContextMenu::GetItemCount(PRUint32 &aCount)
{
// this should be right.. does it need to be +1 ?
aCount = g_list_length(GTK_MENU_SHELL(mMenu)->children);
//g_print("nsMenu::GetItemCount = %i\n", aCount);
return NS_OK;
}
//-------------------------------------------------------------------------
NS_METHOD nsContextMenu::GetItemAt(const PRUint32 aCount, nsISupports *& aMenuItem)
{
return NS_OK;
}
//-------------------------------------------------------------------------
NS_METHOD nsContextMenu::InsertItemAt(const PRUint32 aCount, nsISupports * aMenuItem)
{
return NS_OK;
}
//-------------------------------------------------------------------------
NS_METHOD nsContextMenu::InsertSeparator(const PRUint32 aCount)
{
return NS_OK;
}
//-------------------------------------------------------------------------
NS_METHOD nsContextMenu::RemoveItem(const PRUint32 aCount)
{
#if 0
// this may work here better than Removeall(), but i'm not sure how to test this one
nsISupports *item = mMenuItemVoidArray[aPos];
delete item;
mMenuItemVoidArray.RemoveElementAt(aPos);
#endif
/*
gtk_menu_shell_remove (GTK_MENU_SHELL (mMenu), item);
nsCRT::free(labelStr);
voidData = NULL;
aMenu->GetNativeData(&voidData);
newmenu = GTK_WIDGET(voidData);
gtk_menu_item_remove_submenu (GTK_MENU_ITEM (item));
*/
return NS_OK;
}
//-------------------------------------------------------------------------
NS_METHOD nsContextMenu::RemoveAll()
{
//g_print("nsMenu::RemoveAll()\n");
#undef DEBUG_pavlov
#ifdef DEBUG_pavlov
// this doesn't work quite right, but this is about all that should really be needed
int i=0;
nsIMenu *menu = nsnull;
nsIMenuItem *menuitem = nsnull;
nsISupports *item = nsnull;
for (i=mMenuItemVoidArray.Count(); i>0; i--)
{
item = (nsISupports*)mMenuItemVoidArray[i-1];
if(nsnull != item)
{
if (NS_OK == item->QueryInterface(nsIMenuItem::GetIID(), (void**)&menuitem))
{
// we do this twice because we have to do it once for QueryInterface,
// then we want to get rid of it.
// g_print("remove nsMenuItem\n");
NS_RELEASE(menuitem);
NS_RELEASE(item);
menuitem = nsnull;
} else if (NS_OK == item->QueryInterface(nsIMenu::GetIID(), (void**)&menu)) {
#ifdef NOISY_MENUS
g_print("remove nsMenu\n");
#endif
NS_RELEASE(menu);
NS_RELEASE(item);
menu = nsnull;
}
// mMenuItemVoidArray.RemoveElementAt(i-1);
}
}
mMenuItemVoidArray.Clear();
return NS_OK;
#else
for (int i = mMenuItemVoidArray.Count(); i > 0; i--) {
if(nsnull != mMenuItemVoidArray[i-1]) {
nsIMenuItem * menuitem = nsnull;
((nsISupports*)mMenuItemVoidArray[i-1])->QueryInterface(nsIMenuItem::GetIID(),
(void**)&menuitem);
if(menuitem) {
void *gtkmenuitem = nsnull;
menuitem->GetNativeData(gtkmenuitem);
if (gtkmenuitem) {
gtk_widget_ref(GTK_WIDGET(gtkmenuitem));
//gtk_widget_destroy(GTK_WIDGET(gtkmenuitem));
g_print("%p, %p\n",
GTK_WIDGET(GTK_CONTAINER(GTK_MENU_SHELL(GTK_MENU(mMenu)))),
GTK_WIDGET(GTK_WIDGET(gtkmenuitem)->parent));
gtk_container_remove(GTK_CONTAINER(GTK_MENU_SHELL(GTK_MENU(mMenu))),
GTK_WIDGET(gtkmenuitem));
}
} else {
nsIMenu * menu= nsnull;
((nsISupports*)mMenuItemVoidArray[i-1])->QueryInterface(nsIMenu::GetIID(),
(void**)&menu);
if(menu)
{
void * gtkmenu = nsnull;
menu->GetNativeData(&gtkmenu);
if(gtkmenu){
g_print("nsMenu::RemoveAll() trying to remove nsMenu");
//gtk_menu_item_remove_submenu (GTK_MENU_ITEM (item));
}
}
}
}
}
//g_print("end RemoveAll\n");
return NS_OK;
#endif
}
//-------------------------------------------------------------------------
NS_METHOD nsContextMenu::GetNativeData(void ** aData)
{
*aData = (void *)mMenu;
return NS_OK;
}
//-------------------------------------------------------------------------
NS_METHOD nsContextMenu::AddMenuListener(nsIMenuListener * aMenuListener)
{
mListener = aMenuListener;
NS_ADDREF(mListener);
return NS_OK;
}
//-------------------------------------------------------------------------
NS_METHOD nsContextMenu::RemoveMenuListener(nsIMenuListener * aMenuListener)
{
if (aMenuListener == mListener) {
NS_IF_RELEASE(mListener);
}
return NS_OK;
}
//-------------------------------------------------------------------------
// nsIMenuListener interface
//-------------------------------------------------------------------------
nsEventStatus nsContextMenu::MenuItemSelected(const nsMenuEvent & aMenuEvent)
{
if (nsnull != mListener) {
mListener->MenuSelected(aMenuEvent);
}
return nsEventStatus_eIgnore;
}
void menu_popup_position(GtkMenu *menu,
gint *x,
gint *y,
gpointer data)
{
nsContextMenu *cm = (nsContextMenu*)data;
*x = cm->GetX();
*y = cm->GetY();
}
nsEventStatus nsContextMenu::MenuSelected(const nsMenuEvent & aMenuEvent)
{
MenuConstruct(aMenuEvent,
mParent,
mDOMNode,
mWebShell);
//GtkWidget *parent = GTK_WIDGET(mParent->GetNativeData(NS_NATIVE_WIDGET));
gtk_menu_popup (GTK_MENU(mMenu),
(GtkWidget*)nsnull, (GtkWidget*)nsnull,
menu_popup_position,
this, 1, GDK_CURRENT_TIME);
/*
if (nsnull != mListener) {
mListener->MenuSelected(aMenuEvent);
}
*/
return nsEventStatus_eIgnore;
}
//-------------------------------------------------------------------------
nsIMenuItem * nsContextMenu::FindMenuItem(nsIContextMenu * aMenu, PRUint32 aId)
{
return nsnull;
}
//-------------------------------------------------------------------------
nsEventStatus nsContextMenu::MenuDeselected(const nsMenuEvent & aMenuEvent)
{
if (nsnull != mListener) {
mListener->MenuDeselected(aMenuEvent);
}
return nsEventStatus_eIgnore;
}
//-------------------------------------------------------------------------
nsEventStatus nsContextMenu::MenuConstruct(const nsMenuEvent &aMenuEvent,
nsIWidget *aParentWindow,
void *menuNode,
void *aWebShell)
{
//g_print("nsMenu::MenuConstruct called \n");
if(menuNode){
SetDOMNode((nsIDOMNode*)menuNode);
}
if(!aWebShell){
aWebShell = mWebShell;
}
// First open the menu.
nsCOMPtr<nsIDOMElement> domElement = do_QueryInterface(mDOMNode);
if (domElement)
domElement->SetAttribute("open", "true");
// Begin menuitem inner loop
nsCOMPtr<nsIDOMNode> menuitemNode;
((nsIDOMNode*)mDOMNode)->GetFirstChild(getter_AddRefs(menuitemNode));
unsigned short menuIndex = 0;
while (menuitemNode) {
nsCOMPtr<nsIDOMElement> menuitemElement(do_QueryInterface(menuitemNode));
if (menuitemElement) {
nsString menuitemNodeType;
nsString menuitemName;
menuitemElement->GetNodeName(menuitemNodeType);
if (menuitemNodeType.Equals("menuitem")) {
// LoadMenuItem
LoadMenuItem(this,
menuitemElement,
menuitemNode,
menuIndex,
(nsIWebShell*)aWebShell);
} else if (menuitemNodeType.Equals("separator")) {
AddSeparator();
} else if (menuitemNodeType.Equals("menu")) {
// Load a submenu
LoadSubMenu(this, menuitemElement, menuitemNode);
}
}
++menuIndex;
nsCOMPtr<nsIDOMNode> oldmenuitemNode(menuitemNode);
oldmenuitemNode->GetNextSibling(getter_AddRefs(menuitemNode));
} // end menu item innner loop
return nsEventStatus_eIgnore;
}
//-------------------------------------------------------------------------
nsEventStatus nsContextMenu::MenuDestruct(const nsMenuEvent & aMenuEvent)
{
// Close the node.
nsCOMPtr<nsIDOMElement> domElement = do_QueryInterface(mDOMNode);
if (domElement)
domElement->RemoveAttribute("open");
//g_print("nsMenu::MenuDestruct called \n");
mConstructCalled = PR_FALSE;
RemoveAll();
return nsEventStatus_eIgnore;
}
//----------------------------------------
void nsContextMenu::LoadMenuItem(nsIMenu *pParentMenu,
nsIDOMElement *menuitemElement,
nsIDOMNode *menuitemNode,
unsigned short menuitemIndex,
nsIWebShell *aWebShell)
{
static const char* NS_STRING_TRUE = "true";
nsString disabled;
nsString menuitemName;
nsString menuitemCmd;
menuitemElement->GetAttribute(nsAutoString("disabled"), disabled);
menuitemElement->GetAttribute(nsAutoString("name"), menuitemName);
menuitemElement->GetAttribute(nsAutoString("cmd"), menuitemCmd);
// Create nsMenuItem
nsIMenuItem * pnsMenuItem = nsnull;
nsresult rv = nsComponentManager::CreateInstance(kMenuItemCID,
nsnull,
nsIMenuItem::GetIID(),
(void**)&pnsMenuItem);
if (NS_OK == rv) {
pnsMenuItem->Create(pParentMenu, menuitemName, PR_FALSE);
nsISupports * supports = nsnull;
pnsMenuItem->QueryInterface(kISupportsIID, (void**) &supports);
pParentMenu->AddItem(supports); // Parent should now own menu item
NS_RELEASE(supports);
if(disabled == NS_STRING_TRUE) {
pnsMenuItem->SetEnabled(PR_FALSE);
}
// Create MenuDelegate - this is the intermediator inbetween
// the DOM node and the nsIMenuItem
// The nsWebShellWindow wacthes for Document changes and then notifies the
// the appropriate nsMenuDelegate object
nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(menuitemNode));
if (!domElement) {
//return NS_ERROR_FAILURE;
return;
}
nsAutoString cmdAtom("onclick");
nsString cmdName;
domElement->GetAttribute(cmdAtom, cmdName);
pnsMenuItem->SetCommand(cmdName);
// DO NOT use passed in webshell because of messed up windows dynamic loading
// code.
pnsMenuItem->SetWebShell(mWebShell);
pnsMenuItem->SetDOMElement(domElement);
NS_RELEASE(pnsMenuItem);
}
return;
}
//----------------------------------------
void nsContextMenu::LoadSubMenu(nsIMenu *pParentMenu,
nsIDOMElement *menuElement,
nsIDOMNode *menuNode)
{
nsString menuName;
menuElement->GetAttribute(nsAutoString("name"), menuName);
//printf("Creating Menu [%s] \n", menuName.ToNewCString()); // this leaks
// Create nsMenu
nsIMenu * pnsMenu = nsnull;
nsresult rv = nsComponentManager::CreateInstance(kMenuCID,
nsnull,
nsIMenu::GetIID(),
(void**)&pnsMenu);
if (NS_OK == rv) {
// Call Create
nsISupports * supports = nsnull;
pParentMenu->QueryInterface(kISupportsIID, (void**) &supports);
pnsMenu->Create(supports, menuName);
NS_RELEASE(supports); // Balance QI
// Set nsMenu Name
pnsMenu->SetLabel(menuName);
supports = nsnull;
pnsMenu->QueryInterface(kISupportsIID, (void**) &supports);
pParentMenu->AddItem(supports); // parent takes ownership
NS_RELEASE(supports);
pnsMenu->SetWebShell(mWebShell);
pnsMenu->SetDOMNode(menuNode);
/*
// Begin menuitem inner loop
unsigned short menuIndex = 0;
nsCOMPtr<nsIDOMNode> menuitemNode;
menuNode->GetFirstChild(getter_AddRefs(menuitemNode));
while (menuitemNode) {
nsCOMPtr<nsIDOMElement> menuitemElement(do_QueryInterface(menuitemNode));
if (menuitemElement) {
nsString menuitemNodeType;
menuitemElement->GetNodeName(menuitemNodeType);
#ifdef DEBUG_saari
printf("Type [%s] %d\n", menuitemNodeType.ToNewCString(), menuitemNodeType.Equals("separator"));
#endif
if (menuitemNodeType.Equals("menuitem")) {
// Load a menuitem
LoadMenuItem(pnsMenu, menuitemElement, menuitemNode, menuIndex, mWebShell);
} else if (menuitemNodeType.Equals("separator")) {
pnsMenu->AddSeparator();
} else if (menuitemNodeType.Equals("menu")) {
// Add a submenu
LoadSubMenu(pnsMenu, menuitemElement, menuitemNode);
}
}
++menuIndex;
nsCOMPtr<nsIDOMNode> oldmenuitemNode(menuitemNode);
oldmenuitemNode->GetNextSibling(getter_AddRefs(menuitemNode));
} // end menu item innner loop
*/
}
}
//----------------------------------------
void nsContextMenu::LoadMenuItem(nsIContextMenu *pParentMenu,
nsIDOMElement *menuitemElement,
nsIDOMNode *menuitemNode,
unsigned short menuitemIndex,
nsIWebShell *aWebShell)
{
}
//----------------------------------------
void nsContextMenu::LoadSubMenu(nsIContextMenu *pParentMenu,
nsIDOMElement *menuElement,
nsIDOMNode *menuNode)
{
}
//-------------------------------------------------------------------------
NS_METHOD nsContextMenu::SetLocation(PRInt32 aX, PRInt32 aY)
{
mX = aX;
mY = aY;
return NS_OK;
}
// local methods
gint nsContextMenu::GetX(void)
{
return mX;
}
gint nsContextMenu::GetY(void)
{
return mY;
}
// end silly local methods
//-------------------------------------------------------------------------
NS_METHOD nsContextMenu::SetDOMNode(nsIDOMNode *aMenuNode)
{
mDOMNode = aMenuNode;
return NS_OK;
}
//-------------------------------------------------------------------------
NS_METHOD nsContextMenu::SetDOMElement(nsIDOMElement *aMenuElement)
{
mDOMElement = aMenuElement;
return NS_OK;
}
//-------------------------------------------------------------------------
NS_METHOD nsContextMenu::SetWebShell(nsIWebShell *aWebShell)
{
mWebShell = aWebShell;
return NS_OK;
}

Some files were not shown because too many files have changed in this diff Show More