}} tags.
name:listUsers
access:public
param:string,Filter users by this string.,'USER'
returns:array
throws:Exception,if user backend not available.
//Rendering of this rule is broken as of Text_Wiki 1.2.1, usage is discouraged.//
++ HTML Markup
You can add native HTML markup using {{...}} tags.
HTML
//This rule is disabled by default.//
HTML
++ Tables
You can create tables using pairs of vertical bars:
||~ Heading one ||~ Heading two ||
|| cell one || cell two ||
|||| big ol' line ||
|| cell four || cell five ||
|| cell six || here's a very long cell ||
||~ Heading one ||~ Heading two ||
|| cell one || cell two ||
|||| big ol' line ||
|| cell four || cell five ||
|| cell six || here's a very long cell ||
|| lines must start and end || with double vertical bars || nothing ||
|| cells are separated by || double vertical bars || nothing ||
|||| you can span multiple columns by || starting each cell ||
|| with extra cell |||| separators ||
|||||| but perhaps an example is the easiest way to see ||
|| lines must start and end || with double vertical bars || nothing ||
|| cells are separated by || double vertical bars || nothing ||
|||| you can span multiple columns by || starting each cell ||
|| with extra cell |||| separators ||
|||||| but perhaps an example is the easiest way to see ||
wicked-2.0.4/data/Default/Wiki/Usage 0000664 0000765 0000024 00000000427 12557035537 014111 0 ustar Browsing the wiki is just like browsing the web. You can edit any page by clicking on the edit button on any page.
((Wiki/AddingPages)) - How to create new pages in the wiki.
((Wiki/TextFormat)) - How to format wiki pages.
((Wiki/SandBox)) - A page you can experiment on.
wicked-2.0.4/data/Default/SmashWordsTogether 0000664 0000765 0000024 00000000112 12557035537 015725 0 ustar Generic target page. You SmashWordsTogether to indicate a wiki page name. wicked-2.0.4/data/Mediawiki/Wiki/AddingPages 0000664 0000765 0000024 00000000756 12557035537 015537 0 ustar = Creating New Pages =
You don't have to specifically create nodes. You can just type away and make up a new node name (a string with an initial capital letter, some lower case letters and at least one other capital letter, enclosed in double square brackets). When you view the page again it will be a link. The first time you click on that link, the wiki will automatically create the page and you can edit it.
See [[Wiki/TextFormat]] for information on how to format pages in this wiki.
wicked-2.0.4/data/Mediawiki/Wiki/Home 0000664 0000765 0000024 00000000511 12557035537 014246 0 ustar = Welcome to the Wiki =
A Wiki is a site where everyone can collaborate on the content. The most well-known and widely used Wiki is the Wikipedia at http://www.wikipedia.org.
You can read about [[Wiki/Usage]] and [[Wiki/AddingPages]]. Currently this Wiki has no theme for discussion, so go ahead and play with it and have fun!
wicked-2.0.4/data/Mediawiki/Wiki/Page 0000664 0000765 0000024 00000000050 12557035537 014230 0 ustar Generic target page (for example usage). wicked-2.0.4/data/Mediawiki/Wiki/SandBox 0000664 0000765 0000024 00000000426 12557035537 014721 0 ustar This is the sandbox. You can try out Wiki in here, and no one will care - but don't be rude and delete this explanatory text. '''Stay below the first horizontal rule.'''
For reference, you might want to visit [[Wiki/Usage]], [[Wiki/TextFormat]] or [[Wiki/AddingPages]].
----
wicked-2.0.4/data/Mediawiki/Wiki/TextFormat 0000664 0000765 0000024 00000022640 12557035537 015462 0 ustar = Sample Page for Wiki Markup =
== General Notes ==
The markup uses the [http://www.mediawiki.org/ Mediawiki] style.
All text is entered as plain text, and will be converted to HTML entities as \
necessary. This means that <, >, &, and so on are converted for \
you (except in special situations where the characters are Wiki markup; \
the Wiki is generally smart enough to know when to convert and when not to).
Just hit "return" twice to make a paragraph break. If you want \
to keep the same logical line but have to split it across \
two physical lines (such as when your editor only shows a certain number \
of characters per line), end the line with a backslash \ and hit \
return once. This will cause the two lines to be joined on display, and the \
backslash will not show. (If you end a line with a backslash and a tab \
or space, it will ''not'' be joined with the next line, and the backslash \
will be printed.)
== Inline Formatting ==
{|
| ''emphasis text''
| ''emphasis text''
|-
| '''strong text'''
| '''strong text'''
|-
| '''''emphasis and strong'''''
| '''''emphasis and strong'''''
|-
| teletype text
| teletype text
|-
| subscript text
| subscript text
|-
| superscript text
| superscript text
|}
== Literal Text ==
If you don't want the wiki to parse some text, enclose it in ... tags.
This ''text'' gets '''parsed'''.
This ''text'' does not get '''parsed'''.
This ''text'' gets '''parsed'''.
This ''text'' does not get '''parsed'''.
== Comments ==
You can add comments to the page source code using the following markup. These comments won't be rendered in the page's output.
== Headings ==
You can make various levels of heading by putting \
plus-signs before the text (all on its own line):
=== Level 3 Heading ===
==== Level 4 Heading ====
===== Level 5 Heading =====
====== Level 6 Heading ======
=== Level 3 Heading ===
==== Level 4 Heading ====
===== Level 5 Heading =====
====== Level 6 Heading ======
== Table of Contents ==
To create a list of every heading, with a link to that heading, put a table of contents tag on its own line.
[[toc]]
== Horizontal Rules ==
Use four dashes (----) to create a horizontal rule.
----
== Lists ==
=== Bullet Lists ===
You can create bullet lists by starting a paragraph with one or \
more asterisks.
* Bullet one
** Sub-bullet
* Bullet one
** Sub-bullet
=== Numbered Lists ===
Similarly, you can create numbered lists by starting a paragraph \
with one or more hashes.
# Numero uno
# Number two
## Sub-item
# Numero uno
# Number two
## Sub-item
=== Mixing Bullet and Number List Items ===
You can mix and match bullet and number lists:
# Number one
** Bullet
** Bullet
# Number two
** Bullet
** Bullet
*** Sub-bullet
#### Sub-sub-number
#### Sub-sub-number
# Number three
** Bullet
** Bullet
# Number one
** Bullet
** Bullet
# Number two
** Bullet
** Bullet
*** Sub-bullet
#### Sub-sub-number
#### Sub-sub-number
# Number three
** Bullet
** Bullet
=== Definition Lists ===
You can create a definition (description) list with the following syntax:
;Item 1
:Something
;Item 2
:Something else
;Item 1
:Something
;Item 2
:Something else
== Block Quotes ==
You can mark a blockquote by starting a line with one or more '>' \
characters, followed by a space and the text to be quoted.
This is normal text here.
: Indent me! The quick brown fox jumps over the lazy dog. \
Now this the time for all good men to come to the aid of \
their country. Notice how we can continue the block-quote \
in the same "paragraph" by using a backslash at the end of \
the line.
: Another block, leading to...
:: Second level of indenting. This second is indented even \
more than the previous one.
Back to normal text.
This is normal text here.
: Indent me! The quick brown fox jumps over the lazy dog. \
Now this the time for all good men to come to the aid of \
their country. Notice how we can continue the block-quote \
in the same "paragraph" by using a backslash at the end of \
the line.
: Another block, leading to...
:: Second level of indenting. This second is indented even \
more than the previous one.
Back to normal text.
== Links and Images ==
=== Wiki Links ===
You can create page links by putting the name in brackets.
[[Wiki/Page]]
[[Wiki/Page]]
You can also use this format to create a "described" or "labeled" link or to add an anchor target.
[[Wiki/Page#anchor|Descriptive text for the link.]]
[[Wiki/Page#anchor|Descriptive text for the link.]]
=== URLs ===
Create a remote link simply by typing its URL: http://www.horde.org.
If you like, enclose it in brackets to create a numbered reference \
and avoid cluttering the page; [http://www.horde.org/] becomes [http://www.horde.org/].
''Rendering of URLs as numbers is broken as of Text_Wiki 1.2.1.''
Or you can have a described-reference instead of a numbered reference:
[http://www.horde.org Horde]
[http://www.horde.org Horde]
=== Images ===
You can put a picture in a page with [[Image:foo.jpg]]. You can use any file type, but most browsers only support GIF, JPEG, and PNG formats. The filename can either be a relative reference (in which case the wiki looks for a file attached to the current page - or a different wiki page if the file name is prefixed with a page name, e.g. [[Image:SomePage:foo.jpg]]), an absolute reference which begins with a slash (in which case the wiki uses it to retrieve a file relative to the web server's root), or a full, external URL.
Additional "alt", "width", and "height" attributes can follow the image filename or URL like so: [[Image:foo.jpg|A Foo JPEG|WIDTHxHEIGHTpx]].
== Application Content ==
=== Application Blocks ===
Content from other Horde applications provided by portal blocks can be embedded into a page using [[block]] tags.
To include Horde's moon phases block for example:
[[block horde/Moon phase=next hemisphere=northern]]
[[block horde/Moon phase=next hemisphere=northern]]
=== Application Links ===
Links to other Horde applications is supported if those applications support API links. The Wiki itself supports such an API to link to individual wiki pages:
[[link Link to some other wiki page|wiki/show page=Wiki/Page]]
[[link Link to some other wiki page|wiki/show page=Wiki/Page]]
== Code Blocks ==
Create code blocks by using code tags (each on its own line).
This is an example code block!
To create PHP blocks that get automatically colorized when you use PHP tags, simply surround the code with code type="php" tags (the tags themselves should each be on their own lines, and no need for the tags).
// Set up the wiki options
$options = array();
$options['view_url'] = "index.php?page=";
// load the text for the requested page
$text = implode('', file($page . '.wiki.txt'));
// create a Wiki objext with the loaded options
$wiki = new Text_Wiki($options);
// transform the wiki text.
echo $wiki->transform($text);
// Set up the wiki options
$options = array();
$options['view_url'] = "index.php?page=";
// load the text for the requested page
$text = implode('', file($page . '.wiki.txt'));
// create a Wiki objext with the loaded options
$wiki = new Text_Wiki($options);
// transform the wiki text.
echo $wiki->transform($text);
API references can be generated using tags.
name:listUsers
access:public
param:string,Filter users by this string.,'USER'
returns:array
throws:Exception,if user backend not available.
''Rendering of this rule is broken as of Text_Wiki 1.2.1, usage is discouraged.''
== Tables ==
You can create tables using pairs of vertical bars:
{|
! Heading one !! Heading two
|-
| cell one || cell two
|-
| colspan="2" | big ol' line
|-
| cell four || cell five
|-
| cell six || here's a very long cell
|}
{|
! Heading one !! Heading two
|-
| cell one || cell two
|-
| colspan="2" | big ol' line
|-
| cell four || cell five
|-
| cell six || here's a very long cell
|}
{|
| lines must start || with a vertical bar || and a dash
|-
| cells are separated by || double vertical bars || nothing
|-
| or by starting the new
| cell on a new line
| with a vertical bar
|-
| colspan="2" | you can span multiple columns by || starting the cell
|-
| with a colspan || colspan="2" | attribute
|-
| colspan="3" | but perhaps an example is the easiest way to see
|}
{|
| lines must start || with a vertical bar || and a dash
|-
| cells are separated by || double vertical bars || nothing
|-
| or by starting the new
| cell on a new line
| with a vertical bar
|-
| colspan="2" | you can span multiple columns by || starting the cell
|-
| with a colspan || colspan="2" | attribute
|-
| colspan="3" | but perhaps an example is the easiest way to see
|}
wicked-2.0.4/data/Mediawiki/Wiki/Usage 0000664 0000765 0000024 00000000427 12557035537 014430 0 ustar Browsing the wiki is just like browsing the web. You can edit any page by clicking on the edit button on any page.
[[Wiki/AddingPages]] - How to create new pages in the wiki.
[[Wiki/TextFormat]] - How to format wiki pages.
[[Wiki/SandBox]] - A page you can experiment on.
wicked-2.0.4/data/Tiki/Wiki/AddingPages 0000664 0000765 0000024 00000000750 12557035537 014526 0 ustar ! Creating New Pages
You don't have to specifically create nodes. You can just type away and make up a new node name (a string with an initial capital letter, some lower case letters and at least one other capital letter, enclosed in double square brackets). When you view the page again it will be a link. The first time you click on that link, the wiki will automatically create the page and you can edit it.
See Wiki/TextFormat for information on how to format pages in this wiki.
wicked-2.0.4/data/Tiki/Wiki/Home 0000664 0000765 0000024 00000000477 12557035537 013256 0 ustar ! Welcome to the Wiki
A Wiki is a site where everyone can collaborate on the content. The most well-known and widely used Wiki is the Wikipedia at http://www.wikipedia.org.
You can read about Wiki/Usage and Wiki/AddingPages. Currently this Wiki has no theme for discussion, so go ahead and play with it and have fun!
wicked-2.0.4/data/Tiki/Wiki/Page 0000664 0000765 0000024 00000000050 12557035537 013225 0 ustar Generic target page (for example usage). wicked-2.0.4/data/Tiki/Wiki/SandBox 0000664 0000765 0000024 00000000410 12557035537 013707 0 ustar This is the sandbox. You can try out Wiki in here, and no one will care - but don't be rude and delete this explanatory text. __Stay below the first horizontal rule.__
For reference, you might want to visit Wiki/Usage, Wiki/TextFormat or Wiki/AddingPages.
----
wicked-2.0.4/data/Tiki/Wiki/TextFormat 0000664 0000765 0000024 00000023036 12557035537 014457 0 ustar ! Sample Page for Wiki Markup
!! General Notes
The markup uses the [http://tiki.org/|Tiki Wiki] style.
All text is entered as plain text, and will be converted to HTML entities as \
necessary. This means that -+<+-, -+>+-, -+&+-, and so on are converted for \
you (except in special situations where the characters are Wiki markup; \
the Wiki is generally smart enough to know when to convert and when not to).
Just hit "return" twice to make a paragraph break. If you want \
to keep the same logical line but have to split it across \
two physical lines (such as when your editor only shows a certain number \
of characters per line), end the line with a backslash -+\+- and hit \
return once. This will cause the two lines to be joined on display, and the \
backslash will not show. (If you end a line with a backslash and a tab \
or space, it will ''not'' be joined with the next line, and the backslash \
will be printed.)
!! Inline Formatting
|| ~np~''emphasis text''~/np~ | ''emphasis text''
~np~__strong text__~/np~ | __strong text__
~np~''__emphasis and strong__''~/np~ | ''__emphasis and strong__''
~np~===underline text===~/np~ | ===underline text===
~np~-+teletype text+-~/np~ | -+teletype text+-
~np~,,subscript,, text~/np~ | ,,subscript,, text
~np~^^superscript^^ text~/np~ | ^^superscript^^ text
~np~@@--- delete text +++ insert text @@~/np~ | @@--- delete text +++ insert text @@
~np~@@--- delete only @@~/np~ | @@--- delete only @@
~np~@@+++ insert only @@~/np~ | @@+++ insert only @@
~np~~~red:red text~~~/np~ | ~~red:red text~~
~np~~~#FFFF00:yellow text~~~/np~ | ~~#FFFF00:yellow text~~ ||
!! Literal Text
If you don't want the wiki to parse some text, enclose it in ~np~~np~...~/np~~/np~ tags.
{CODE()}
This ''text'' gets __parsed__.
~np~This ''text'' does not get __parsed__.~/np~
{CODE}
This ''text'' gets __parsed__.
~np~This ''text'' does not get __parsed__.~/np~
//Rendering of escaped content is incorrectly wrapped inside tags as of Text_Wiki 1.2.1.//
!! Headings
You can make various levels of heading by putting \
plus-signs before the text (all on its own line):
{CODE()}
!!! Level 3 Heading
!!!! Level 4 Heading
!!!!! Level 5 Heading
!!!!!! Level 6 Heading
{CODE}
!!! Level 3 Heading
!!!! Level 4 Heading
!!!!! Level 5 Heading
!!!!!! Level 6 Heading
!! Text Alignment
You can center align paragraphs by starting it with an equal sign.
{CODE()}
::Center aligned text::
{CODE}
::Center aligned text::
!! Horizontal Rules
Use four dashes (-+~np~----~/np~+-) to create a horizontal rule.
----
!! Lists
!!! Bullet Lists
You can create bullet lists by starting a paragraph with one or \
more asterisks.
{CODE()}
* Bullet one
** Sub-bullet
{CODE}
* Bullet one
** Sub-bullet
!!! Numbered Lists
Similarly, you can create numbered lists by starting a paragraph \
with one or more hashes.
{CODE()}
# Numero uno
# Number two
## Sub-item
{CODE}
# Numero uno
# Number two
## Sub-item
!!! Mixing Bullet and Number List Items
You can mix and match bullet and number lists:
{CODE()}
# Number one
** Bullet
** Bullet
# Number two
** Bullet
** Bullet
*** Sub-bullet
#### Sub-sub-number
#### Sub-sub-number
# Number three
** Bullet
** Bullet
{CODE}
# Number one
** Bullet
** Bullet
# Number two
** Bullet
** Bullet
*** Sub-bullet
#### Sub-sub-number
#### Sub-sub-number
# Number three
** Bullet
** Bullet
!!! Definition Lists
You can create a definition (description) list with the following syntax:
{CODE()}
;Item 1:Something
;Item 2:Something else
{CODE}
;Item 1:Something
;Item 2:Something else
!! Block Quotes
You can mark a blockquote by starting a line with one or more '>' \
characters, followed by a space and the text to be quoted.
{CODE()}
This is normal text here.
> Indent me! The quick brown fox jumps over the lazy dog. \
Now this the time for all good men to come to the aid of \
their country. Notice how we can continue the block-quote \
in the same "paragraph" by using a backslash at the end of \
the line.
>
> Another block, leading to...
>> Second level of indenting. This second is indented even \
more than the previous one.
Back to normal text.
{CODE}
This is normal text here.
> Indent me! The quick brown fox jumps over the lazy dog. \
Now this the time for all good men to come to the aid of \
their country. Notice how we can continue the block-quote \
in the same "paragraph" by using a backslash at the end of \
the line.
>
> Another block, leading to...
>> Second level of indenting. This second is indented even \
more than the previous one.
Back to normal text.
!! Links and Images
!!! Wiki Links
SmashWordsTogether to create a page link.
You can force a Wiki page to be clickable even if it does __not__ match the page name format by putting the name in parentheses.
{CODE()}
((Wiki/Page))
{CODE}
((Wiki/Page))
You can also use this format to create a "described" or "labeled" link or to add an anchor target.
{CODE()}
((Wiki/Page#anchor|Descriptive text for the link.))
{CODE}
((Wiki/Page#anchor|Descriptive text for the link.))
You can alternatively create a "described" or "labeled" link to a wiki page by putting the page name in brackets, followed by some text.
{CODE()}
[Wiki/Page|Descriptive text for the link.]
{CODE}
[Wiki/Page|Descriptive text for the link.]
!!! URLs
Create a remote link simply by typing its URL: http://www.horde.org/.
Alternatively enclose it in brackets; -+~np~[http://www.horde.org/]~/np~+- becomes [http://www.horde.org/].
Or you can have a described-reference instead of a numbered reference:
{CODE()}
[http://www.horde.org|Horde]
{CODE}
[http://www.horde.org|Horde]
!!! On-Page Links
Create an anchor on the page by -+~np~[[# anchorName nice anchor text]]~/np~+- [[# anchorName nice anchor text]] and refer to it by -+~np~[#anchorName|use normal link renaming]~/np~+- [#anchorName|use normal link renaming].
!!! Images
You can put a picture in a page with -+~np~{img foo.jpg}~/np~+-. You can use any file type, but most browsers only support GIF, JPEG, and PNG formats. The filename can either be a relative reference (in which case the wiki looks for a file attached to the current page - or a different wiki page if the file name is prefixed with a page name, e.g. -+~np~{img SomePage:foo.jpg}~/np~+-), an absolute reference which begins with a slash (in which case the wiki uses it to retrieve a file relative to the web server's root), or a full, external URL.
Additional attributes, such as "alt" can follow the image filename or URL like so: -+~np~{img foo.jpg alt="A Foo JPEG"}~/np~+-. "link" is a special attribute which makes the image a link to the specified URL.
!! Application Content
!!! Application Blocks
Content from other Horde applications provided by portal blocks can be embedded into a page using -+[[block]]+- tags.
To include Horde's moon phases block for example:
{CODE()}
[[block horde/Moon phase=next hemisphere=northern]]
{CODE}
[[block horde/Moon phase=next hemisphere=northern]]
!!! Application Links
Links to other Horde applications is supported if those applications support API links. The Wiki itself supports such an API to link to individual wiki pages:
{CODE()}
[[link Link to some other wiki page|wiki/show page=Wiki/Page]]
{CODE}
[[link Link to some other wiki page|wiki/show page=Wiki/Page]]
!! Code Blocks
Create code blocks by using -+CODE()+- tags (each on its own line).
{CODE()}
This is an example code block!
{CODE}
To create PHP blocks that get automatically colorized when you use PHP tags, simply surround the code with -+CODE(type=php)+- tags (the tags themselves should each be on their own lines, and no need for the -++- tags).
{CODE()}
{CODE(type=php)}
// Set up the wiki options
$options = array();
$options['view_url'] = "index.php?page=";
// load the text for the requested page
$text = implode('', file($page . '.wiki.txt'));
// create a Wiki objext with the loaded options
$wiki = new Text_Wiki($options);
// transform the wiki text.
echo $wiki->transform($text);
{CODE}
{CODE}
{CODE(type=php)}
// Set up the wiki options
$options = array();
$options['view_url'] = "index.php?page=";
// load the text for the requested page
$text = implode('', file($page . '.wiki.txt'));
// create a Wiki objext with the loaded options
$wiki = new Text_Wiki($options);
// transform the wiki text.
echo $wiki->transform($text);
{CODE}
!! HTML Markup
You can add native HTML markup using -+...+- tags.
{CODE()}
HTML
{CODE}
''This rule is disabled by default.''
HTML
!! Tables
You can create tables using pairs of vertical bars:
{CODE()}
||~ Heading one |~ Heading two
cell one | cell two
| big ol' line
cell four | cell five
cell six | here's a very long cell ||
{CODE}
||~ Heading one |~ Heading two
cell one | cell two
| big ol' line
cell four | cell five
cell six | here's a very long cell ||
{CODE()}
|| lines must start and end | with double vertical bars | nothing
cells are separated by | single vertical bars | nothing
| you can span multiple columns by | starting each cell
with extra cell || separators
|| but perhaps an example is the easiest way to see ||
{CODE}
|| lines must start and end | with double vertical bars | nothing
cells are separated by | single vertical bars | nothing
| you can span multiple columns by | starting each cell
with extra cell || separators
|| but perhaps an example is the easiest way to see ||
wicked-2.0.4/data/Tiki/Wiki/Usage 0000664 0000765 0000024 00000000413 12557035537 013420 0 ustar Browsing the wiki is just like browsing the web. You can edit any page by clicking on the edit button on any page.
Wiki/AddingPages - How to create new pages in the wiki.
Wiki/TextFormat - How to format wiki pages.
Wiki/SandBox - A page you can experiment on.
wicked-2.0.4/data/Tiki/SmashWordsTogether 0000664 0000765 0000024 00000000112 12557035537 015241 0 ustar Generic target page. You SmashWordsTogether to indicate a wiki page name. wicked-2.0.4/data/.htaccess 0000664 0000765 0000024 00000000016 12557035537 012423 0 ustar Deny from all
wicked-2.0.4/docs/CHANGES 0000600 0000765 0000024 00000022247 12557035537 011637 0 ustar ------
v2.0.4
------
[jan] Update Italian translation.
[jan] Update Brazilian Portuguese translation (Luis Felipe Marzagao
).
[mjr] Fix fatal error in API due to incorrect access of protected member.
[mjr] Fix fatal error in Whups_Api::getMultiplePageInfo due to erroneous
include.
------
v2.0.3
------
[jan] Fix updating annotated links when renaming pages.
[jan] Add ReST rendering rule for horizontal rulers.
------
v2.0.2
------
[jan] Add Swedish translation (Arne Nordmark ).
[jan] Add Danish translation (Erling Preben Hansen ).
------
v2.0.1
------
[jan] Fix rendering of full text search results.
[jan] Fix rendering pages in portal blocks.
[jan] Improve finding like pages if name contains digits.
------
v2.0.0
------
[jan] Fix generating the most recent changes.
[jan] Request CAPTCHA when creating pages too.
---------
v2.0.0RC1
---------
[jan] Add table layout (Bug #12402).
[jan] Fix DB column width for page contents (Bug #12407).
[mjr] Fix creating a new page from search results (Bug #12381).
[jan] Fix syntax error in wicked CLI script (Bug #12378).
-----------
v2.0.0beta1
-----------
[jan] Fix parsing of headings in other than the default rule (Bug #12211).
[jan] Remove synchronization code.
[jan] Convert all templates to Horde_View.
[jan] Add Most Popular and Least Popular pages to sidebar selection.
[jan] Show at least 10 revisions on the RecentChanges page.
[jan] Fix sorting page lists by date.
------
v1.0.2
------
[jan] Fix accidental deletion of all attachments (Bug #10875).
[jan] Fix permission check when merging and renaming pages (Bug #11332).
------
v1.0.1
------
[gwr] Corrected teletype format for the reST renderer.
[gwr] Support rendering lists in the reST renderer.
[jan] Add Slovak translation (Martin Matuška ).
----
v1.0
----
[jan] Fix links to existing pages with non-ascii or special characters (Bug
#10672).
--------
v1.0-RC1
--------
[jan] Fix rendering attached images with Mediawiki syntax (Bug #10570).
[jan] Fix links to add new pages on pages with non-ascii names (Bug #10612).
[gwr] Support rendering bold text and code section in the rst renderer.
-----------
v1.0-ALPHA1
-----------
[jan] Move all default pages into the Wiki/ namespace (Request #7021).
[jan] Support Unicode wiki page names.
[gwr] Added support for reStructuredText export.
[jan] Add embedding of Horde blocks.
[jan] Log attachment downloads.
[jan] Replace major and minor versions with single versions (Request #7210).
[jan] Add Latvian translation (Jānis Eisaks ).
[jan] Provide default configuration files instead of .dist versions.
[jan] Require delete permissions for merging/renaming pages.
[jan] Don't use WikiWords in menus (Request #7021).
[jan] Drop support for coWiki markup.
[jan] Fix Oracle SQL scripts.
[jan] Implement pessimistic locking based on Horde_Lock.
[mjr] Add default lighttpd-style rewrite rules.
[jan] Add Brazilian Portuguese translation (Luis Felipe Marzagao
).
[cjh] Support arbitrary charsets for page names (Bug #7805).
[cjh] Fix saveTemplate API call (Duck , Bug #7620).
[jan] Add Italian translation (Fabio Pedretti ).
[jan] Add Precedence and Auto-Submitted headers to notification messages.
[cjh] Add an API method for fetching recent changes, and allow specifying
the number of days to look back in the RecentChanges page
(Duck , Request #7230).
[jan] Add script to convert data to UTF-8 in the backend.
[cjh] Allow downloading from/uploading to a remote wiki server
(Duck , Request #7191).
[cjh] Add getMultiplePageInfo() and getPageHistory() API calls, along with
page checksums (Duck , Request #7189).
[cjh] Add Download this page as... link (Duck , Request #7168).
[cjh] Add renderPage() API call (duck@obala.net).
[cjh] Add list(), getPageInfo(), show(), and pageExists() API calls
(Duck , Request #7149).
[jan] Add display and edit API methods (Duck , Request #6130).
[jan] Add Japanese translation (Takeshi Taguchi ).
[cjh] Fix permission checks for non-admins when deleting and reverting
(Bug #5806).
[cjh] Fix removing the most recent revision with some databases (Bug #5807).
[jan] Work around problems with Text_Wiki and PHP 5.2.5+ (Bug #5951).
[mms] Compress download data.
[jan] Add OpenSearch interface for page search through browser bars.
[jan] Add Ukrainian translation (Andriy Kopystyansky ).
[cjh] Support mod_rewrite style URLs with Text_Wiki 1.2 (Bug #4740).
[jan] Allow to add images from other pages (Request #5448).
[cjh] Enforce READ permissions for all page modes (Bug #5328).
[jan] Add Slovenian translation (Duck ).
[jan] Fix searching for non-ascii strings (Bug #4644).
[mms] Add initial CAPTCHA support.
[cjh] Fix deletion of the most recent revision.
[cjh] Table of Contents is now floated to the right and collapses/expands on
click.
[jan] Show similar pages before creating a new one.
[cjh] Ensure external links attached to images go through Horde::externalUrl()
(tasin@fhm.edu, Bug #3151).
[cjh] Include matching context in PageSearch results (Request #2485).
[cjh] Encode notification emails correctly (tasin@fhm.edu, Bug #3153).
[cjh] Don't create pages until they have content (Bug #2534).
[cjh] Run all revert actions through a non-JavaScript, POST
confirmation page.
[cjh] Run all page/version deletion through a non-JavaScript, POST
confirmation page.
[ben] Better support for MS-SQL.
[cjh] Add [[link ...]] syntax for calling $registry->link() in pages
(Bug #1474).
[cjh] Fix Wiki Page Block when the page being displayed has attachments
(Bug #2258).
[cjh] Only list standard pages in Wicked's "Back to" history (Bug #2252).
[cjh] Delete all attachments to a page when that page is deleted.
[cjh] Attachments can now be deleted (Bug #2246).
[cjh] Send notification emails when files are attached (Bug #2248).
[mas] Include changelogs in emails, if available. (Bug #2068)
[cjh] If there is only one search result, go directly to it.
[jan] Support type="htmlphp" attribute for code blocks.
[cjh] Show a summary of any attachments on a page (Bug #1473).
[cjh] Fix updating of attachments (Bug #1579).
[cjh] Add a config option to toggle use of pretty URLS with mod_rewrite
(Bug #1878).
[jan] Support arbitrary charsets for page contents (with Text_Wiki > 1.0.0).
[cjh] Require PERMS_EDIT to attach files to a page (tasin@fhm.edu, Bug #1880).
[cjh] Send email on MergeOrRename (Bug #916).
[cjh] Go to the newly merged or renamed page after MergeOrRename (Bug #916).
[cjh] Display the page that was edited after editing instead of going to
WikiHome (Bug #1478).
[cjh] Require PERMS_EDIT to MergeOrRename a page (Bug #915).
[cjh] Use bind variables in SQL driver (selsky@columbia.edu, #1746).
[cjh] Multiple-definition guard for separator() (Bug #1710).
[jmf] References to special pages in wiki text no longer look deleted.
[jmf] Ability to set permissions on special pages.
[jmf] Prevent loosing attachments when renaming pages.
[jan] Add test page.
[jan] Add Finnish translation (Leena Heino ).
[jmf] Add command-line script to manipulate wiki pages (Vijay Mahrra
).
[jmf] Add "Create" buttons on TitleSearch and PageSearch pages (Vijay Mahrra
).
[jmf] Add quick diff link (show changes from last version) when viewing page.
[jmf] Add configuration option to require change descriptions.
[jan] Notify about page deletions.
[jmf] Add support for displaying attached images.
[jmf] Add the ability to attach files to pages.
[jmf] Add the ability to merge and rename pages.
[jan] Add Spanish translation (Manuel Perez Ayala ).
[jmf] Implement templates (templates are pages which begin or end with
"Template").
[jan] Add Traditional Chinese translation (David Chang ).
[jan] Add history drop down list to jump to the last visited pages.
[cjh] Add MostPopular and LeastPopular wiki pages.
[cjh] Log page views.
[cjh] A parameter of autocreate=1 must now be passed to display.php for pages
that don't exist to be created automatically. This is done by default
for "?" links, but for external incoming links and results of the top
left jump box, users will get a form that allows them to confirm
creation of the new page.
[cjh] Add AllPages Page and Block implementations.
[cjh] Wicked now provides Horde_Blocks for doing TitleSearches and viewing
RecentChanges.
[cjh] TitleSearch now works and is available as a global menu option.
[cjh] Add a Preview button in the EditPage screen.
[cjh] Move BackLinks and LikePages to the toolbar.
[cjh] Store and display changelogs for page revisions.
[cjh] In the history view, diffs between page versions work now.
[jmf] Add jump box.
[jan] Update to work with Text_Wiki 0.8.
[cjh] Use Text_Diff for diff generation.
[jan] Add Page::allows().
[jan] Add Wicked::mail().
[jan] Add diff and notification support.
[jan] Add German translation.
[jan] Allow keeping guests from editing and creating pages.
[tjc] Initial version.
wicked-2.0.4/docs/CREDITS 0000664 0000765 0000024 00000002415 12557035537 011671 0 ustar =========================
Wicked Development Team
=========================
Core Developers
===============
- Tyler Colbert
- Initial codebase
- Chuck Hagenbuch
- Jan Schneider
Localization
============
====================== ===============================================
Brazilian Portuguese Luis Felipe Marzagao
Chinese (Traditional) David Chang
Danish Erling Preben Hansen
Finnish Leena Heino
German Jan Schneider
Italian Fabio Pedretti
Japanese Takeshi Taguchi
Latvian Jānis Eisaks
Slovak Martin Matuška
Jozef Sudolský
Slovenian Duck
Spanish Manuel Perez Ayala
Juan C. Blanco
Swedish Arne Nordmark
Ukrainian Andriy Kopystyansky
====================== ===============================================
wicked-2.0.4/docs/INSTALL 0000664 0000765 0000024 00000015042 12557035537 011702 0 ustar ======================
Installing Wicked H5
======================
:Contact: horde@lists.horde.org
.. contents:: Contents
.. section-numbering::
This document contains instructions for installing the Wicked Wiki application
on your system.
For information on the capabilities and features of Wicked, see the file
README_ in the top-level directory of the Wicked distribution.
Prerequisites
=============
To function properly, Wicked **requires** the following:
1. A working Horde installation.
Wicked runs within the `Horde Application Framework`_, a set of common tools
for web applications written in PHP. You must install Horde before
installing Wicked.
.. Important:: Wicked H5 requires version 5.0+ of the Horde Framework -
earlier versions of Horde will **not** work.
.. Important:: Be sure to have completed all of the steps in the
`horde/docs/INSTALL`_ file for the Horde Framework before
installing Wicked. Many of Wicked's prerequisites are also
Horde prerequisites. Additionally, many of Wicked's optional
features are configured via the Horde install.
.. _`Horde Application Framework`: http://www.horde.org/apps/horde
2. SQL support in PHP.
Wicked stores its data in an SQL database. Build PHP with whichever
SQL driver you require; see the Horde INSTALL file for details.
3. The following PEAR packages:
(See `horde/docs/INSTALL`_ for instructions on installing PEAR packages)
.. Important:: If you are going to install Wicked the recommended way,
i.e. using the PEAR installer, you can skip the remainder of
this section. Installing Wicked through PEAR will
automatically download and install all required PEAR modules.
a. The Text_Wiki PEAR module (>= 1.2.0)
Text_Wiki is responsible for all parsing of wiki markup and rendering
into the different output formats.
Installing Wicked
=================
The **RECOMMENDED** way to install Wicked is using the PEAR installer.
Alternatively, if you want to run the latest development code or get the
latest not yet released fixes, you can install Wicked from Git.
Installing with PEAR
~~~~~~~~~~~~~~~~~~~~
First follow the instructions in `horde/docs/INSTALL`_ to prepare a PEAR
environment for Horde and install the Horde Framework.
When installing Wicked through PEAR now, the installer will automatically
install any dependencies of Wicked too. If you want to install Wicked with all
optional dependencies, but without the binary PECL packages that need to be
compiled, specify both the ``-a`` and the ``-B`` flag::
pear install -a -B horde/wicked
By default, only the required dependencies will be installed::
pear install horde/wicked
If you want to install Wicked even with all binary dependencies, you need to
remove the ``-B`` flag. Please note that this might also try to install PHP
extensions through PECL that might need further configuration or activation in
your PHP configuration::
pear install -a horde/wicked
Installing from Git
~~~~~~~~~~~~~~~~~~~
See http://www.horde.org/source/git.php
Configuring Wicked
==================
1. Configuring Wicked
You must login to Horde as a Horde Administrator to finish the configuration
of Wicked. Use the Horde ``Administration`` menu item to get to the
administration page, and then click on the ``Configuration`` icon to get the
configuration page. Select ``Wiki`` from the selection list of
applications. Fill in or change any configuration values as needed. When
done click on ``Generate Wiki Configuration`` to generate the ``conf.php``
file. If your web server doesn't have write permissions to the Wicked
configuration directory or file, it will not be able to write the file. In
this case, go back to ``Configuration`` and choose one of the other methods
to create the configuration file ``wicked/config/conf.php``.
Documentation on the format and purpose of the other configuration files in
the ``config/`` directory can be found in each file. You may create
``*.local.php`` versions of these files if you wish to customize Wicked's
appearance and behavior. See the header of the configuration files for
details and examples. The defaults will be correct for most sites.
2. Creating the database tables
Once you finished the configuration in the previous step, you can create all
database tables by clicking the ``DB schema is out of date.`` link in the
Wicked row of the configuration screen.
Alternatively creating the Wicked database tables can be accomplished with
horde's ``horde-db-migrate`` utility. If your database is properly setup in
the Horde configuration, just run the following::
horde-db-migrate wicked
3. Testing Wicked
Test at least the following:
- Modify a page
- Create a new page via a WikiLink
- Delete a page
URL Styles
==========
Wicked can use two forms of URLs: mod_rewrite style, or GET style. Your web
server must have URL rewriting enabled to use the mod_rewrite style. Apache
Servers or Apache Proxy Servers may also need to have AllowEncodedSlashes
and/or AcceptPathInfo enabled to use the mod_rewrite style. The GET style URLs
should work without any special configuration.
Note for users of Lighttpd web server: The rewrite url generation relies on
rewrite rules being configured on your web server. Since lighttpd does not
support .htaccess files like Apache, there is also a configuration file for
lighttpd included that contains the necessary rewrite rules. This file is::
docs/lighttpd-ansel.conf
Instructions for using it are included in the file.
Obtaining Support
=================
If you encounter problems with Wicked, help is available!
The Horde Frequently Asked Questions List (FAQ), available on the Web at
http://wiki.horde.org/FAQ
The Horde Project runs a number of mailing lists, for individual applications
and for issues relating to the project as a whole. Information, archives, and
subscription information can be found at
http://www.horde.org/community/mail
Lastly, Horde developers, contributors and users may also be found on IRC,
on the channel #horde on the Freenode Network (irc.freenode.net).
Please keep in mind that Wicked is free software written by volunteers. For
information on reasonable support expectations, please read
http://www.horde.org/community/support
Thanks for using Wicked!
The Wicked team
.. _README: README
.. _`horde/docs/INSTALL`: ../../horde/docs/INSTALL
.. _`horde/docs/TRANSLATIONS`: ../../horde/docs/TRANSLATIONS
wicked-2.0.4/docs/lighttpd-wicked.conf 0000664 0000765 0000024 00000002127 12557035537 014603 0 ustar ## This file should be reviewed prior to inclusion in your lighttpd
## configuration. Specifically, if you have ansel somewhere other than
## /horde/wicked you will need to edit the following rules to match your server
## configuration.
## This file should be included in your lighttpd.conf file with the "include"
## directive. Example:
## include "path/to/lighttpd-wicked.conf"
## The exact path you use will of course depend on your specific configuration.
url.rewrite-once += (
"^/horde/wicked/diff\.php.*$" => "$0",
"^/horde/wicked/display\.php.*$" => "$0",
"^/horde/wicked/history\.php.*$" => "$0",
"^/horde/wicked/index.php\.*$" => "$0",
"^/horde/wicked/opensearch\.php.*$" => "$0",
"^/horde/wicked/preview\.php.*$" => "$0",
"^/horde/wicked/test\.php.*$" => "$0",
"^/horde/wicked/view\.php.*$" => "$0",
"^/horde/wicked/(themes|js)/.*$" => "$0",
"^/horde/wicked/([A-Za-z0-9/]+)/?(?:\?(.*))?$" => "/horde/wicked/display.php?page=$1&$2",
"^/horde/wicked/([A-Za-z0-9/].*)$" => "/horde/wicked/display.php?page=$1"
)
wicked-2.0.4/docs/RELEASE_NOTES 0000664 0000765 0000024 00000001621 12557035537 012622 0 ustar
*/
/**
* A block to display a Wiki page.
*
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @author Jason Felice
*/
class Wicked_Block_Page extends Horde_Core_Block
{
/**
*/
public function __construct($app, $params = array())
{
parent::__construct($app, $params);
$this->_name = _("Wiki page");
}
/**
*/
protected function _title()
{
$page = Wicked_Page::getPage($this->_params['page']);
return htmlspecialchars($page->pageName());
}
/**
*/
protected function _content()
{
$page = Wicked_Page::getPage($this->_params['page']);
return $page->render(Wicked::MODE_BLOCK);
}
/**
*/
protected function _params()
{
return array(
'page' => array(
'type' => 'text',
'name' => _("Name of wiki page to display"),
'default' => 'Wiki/Home'
)
);
}
}
wicked-2.0.4/lib/Driver/Sql.php 0000664 0000765 0000024 00000076724 12557035537 013210 0 ustar
* @author Chuck Hagenbuch
* @author Jan Schneider
* @package Wicked
*/
/**
* Wicked storage implementation for the Horde_Db database abstraction layer.
*
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @author Tyler Colbert
* @author Chuck Hagenbuch
* @author Jan Schneider
* @package Wicked
*/
class Wicked_Driver_Sql extends Wicked_Driver
{
/**
* Handle for the current database connection.
*
* @var Horde_Db_Adapter
*/
protected $_db;
/**
* A cached list of all available page names.
*
* @var array
*/
protected $_pageNames;
/**
* Constructor.
*
* @param array $params A hash containing connection parameters.
*/
public function __construct($params = array())
{
if (!isset($params['db'])) {
throw new InvalidArgumentException('Missing db parameter.');
}
$this->_db = $params['db'];
unset($params['db']);
$params = array_merge(array(
'table' => 'wicked_pages',
'historytable' => 'wicked_history',
'attachmenttable' => 'wicked_attachments',
'attachmenthistorytable' => 'wicked_attachment_history'
), $params);
parent::__construct($params);
}
/**
* Retrieves the page of a particular name from the database.
*
* @param string $pagename The name of the page to retrieve.
*
* @return array
* @throws Wicked_Exception
*/
public function retrieveByName($pagename)
{
$pages = $this->_retrieve(
$this->_params['table'],
array('page_name = ?', array($this->_convertToDriver($pagename))));
if (!empty($pages[0])) {
return $pages[0];
}
throw new Wicked_Exception($pagename . ' not found');
}
/**
* Retrieves a historic version of a page.
*
* @param string $pagename The name of the page to retrieve.
* @param string $version The version to retrieve.
*
* @return array The page hash.
* @throws Wicked_Exception
*/
public function retrieveHistory($pagename, $version)
{
if (!preg_match('/^\d+$/', $version)) {
throw new Wicked_Exception('invalid version number');
}
return $this->_retrieve(
$this->_params['historytable'],
array('page_name = ? AND page_version = ?',
array($this->_convertToDriver($pagename), (int)$version)));
}
public function getPageById($id)
{
return $this->_retrieve($this->_params['table'],
array('page_id = ?', array((int)$id)));
}
public function getAllPages()
{
return $this->_retrieve($this->_params['table'], '', 'page_name');
}
public function getHistory($pagename)
{
return $this->_retrieve(
$this->_params['historytable'],
array('page_name = ?', array($this->_convertToDriver($pagename))),
'page_version DESC');
}
/**
* Returns the most recently changed pages.
*
* @param integer $days The number of days to look back.
*
* @return array Pages.
* @throws Wicked_Exception
*/
public function getRecentChanges($days = 3)
{
$where = array('version_created > ?', array(time() - (86400 * $days)));
$result = $this->_retrieve($this->_params['table'],
$where,
'version_created DESC');
$result2 = $this->_retrieve($this->_params['historytable'],
$where,
'version_created DESC');
return array_merge($result, $result2);
}
/**
* Returns the most recently changed pages.
*
* @param integer $limit The number of most recent pages to return.
*
* @return array Pages.
* @throws Wicked_Exception
*/
public function mostRecent($limit = 10)
{
$result = $this->_retrieve($this->_params['table'],
'',
'version_created DESC',
$limit);
$result2 = $this->_retrieve($this->_params['historytable'],
'',
'version_created DESC',
$limit);
$result = array_merge($result, $result2);
usort(
$result,
function($a, $b)
{
return $b['version_created'] - $a['version_created'];
}
);
return array_slice($result, 0, $limit);
}
/**
* Returns the most popular pages.
*
* @param integer $limit The number of most popular pages to return.
*
* @return array Pages.
* @throws Wicked_Exception
*/
public function mostPopular($limit = 10)
{
return $this->_retrieve($this->_params['table'], '',
'page_hits DESC', $limit);
}
/**
* Returns the least popular pages.
*
* @param integer $limit The number of least popular pages to return.
*
* @return array Pages.
* @throws Wicked_Exception
*/
public function leastPopular($limit = 10)
{
return $this->_retrieve($this->_params['table'], '',
'page_hits ASC', $limit);
}
public function searchTitles($searchtext)
{
$searchtext = $this->_convertToDriver($searchtext);
try {
$where = $this->_db->buildClause('page_name', 'LIKE', $searchtext);
} catch (Horde_Db_Exception $e) {
throw new Wicked_Exception($e);
}
return $this->_retrieve($this->_params['table'], $where);
}
/**
* Finds pages with matches in text or title.
*
* @param string $searchtext The search expression (Google-like).
* @param boolean $title Search both page title and text?
*
* @return array A list of pages.
* @throws Wicked_Exception
*/
public function searchText($searchtext, $title = true)
{
$searchtext = $this->_convertToDriver($searchtext);
try {
$textClause = Horde_Db_SearchParser::parse('page_text', $searchtext);
} catch (Horde_Db_Exception $e) {
throw new Wicked_Exception($e);
}
if ($title) {
try {
$nameClause = Horde_Db_SearchParser::parse('page_name', $searchtext);
} catch (Horde_Db_Exception $e) {
throw new Wicked_Exception($e);
}
$where = '(' . $nameClause . ') OR (' . $textClause . ')';
} else {
$where = $textClause;
}
return $this->_retrieve($this->_params['table'], $where);
}
public function getBackLinks($pagename)
{
try {
$where = $this->_db->buildClause(
'page_text', 'LIKE', $this->_convertToDriver($pagename));
} catch (Horde_Db_Exception $e) {
throw new Wicked_Exception($e);
}
$pages = $this->_retrieve($this->_params['table'], $where);
/* We've cast a wide net, so now we filter out pages which don't
* actually refer to $pagename. */
/* @todo this should match the current wiki engine's syntax. */
$patterns = array('/\(\(' . preg_quote($pagename, '/') . '(?:\|[^)]+)?\)\)/');
if (preg_match('/^' . Wicked::REGEXP_WIKIWORD . '$/', $pagename)) {
$patterns[] = '/\b' . preg_quote($pagename, '/') . '\b/';
}
foreach ($pages as $key => $page) {
$match = false;
foreach ($patterns as $pattern) {
if (preg_match($pattern, $page['page_text'])) {
$match = true;
break;
}
}
if (!$match) {
unset($pages[$key]);
}
}
return $pages;
}
public function getMatchingPages($searchtext,
$matchType = Wicked_Page::MATCH_ANY)
{
$searchtext = strtolower($searchtext);
try {
/* Short circuit the simple case. */
if ($matchType == Wicked_Page::MATCH_ANY) {
return $this->_retrieve(
$this->_params['table'],
'LOWER(page_name) LIKE ' . $this->_db->quote('%' . $searchtext . '%'));
}
$clauses = array();
if ($matchType & Wicked_Page::MATCH_LEFT) {
$clauses[] = 'LOWER(page_name) LIKE ' . $this->_db->quote($searchtext . '%');
}
if ($matchType & Wicked_Page::MATCH_RIGHT) {
$clauses[] = 'LOWER(page_name) LIKE ' . $this->_db->quote('%' . $searchtext);
}
} catch (Horde_Db_Exception $e) {
throw new Wicked_Exception($e);
}
if (!$clauses) {
return array();
}
return $this->_retrieve($this->_params['table'],
implode(' OR ', $clauses));
}
public function getLikePages($pagename)
{
if (Horde_String::isUpper($pagename, 'UTF-8')) {
$firstword = $pagename;
$lastword = null;
} else {
/* Get the first and last word of the page name. */
$count = preg_match_all('/[A-Z][a-z0-9]*/', $pagename, $matches);
if (!$count) {
return array();
}
$matches = $matches[0];
$firstword = $matches[0];
$lastword = $matches[$count - 1];
if (strlen($firstword) == 1 && strlen($matches[1]) == 1) {
for ($i = 1; $i < $count; $i++) {
$firstword .= $matches[$i];
if (isset($matches[$i + 1]) && strlen($matches[$i + 1]) > 1) {
break;
}
}
}
if (strlen($lastword) == 1 && strlen($matches[$count - 2]) == 1) {
for ($i = $count - 2; $i > 0; $i--) {
$lastword = $matches[$i] . $lastword;
if (isset($matches[$i - 1]) && strlen($matches[$i - 1]) > 1) {
break;
}
}
}
}
try {
$where = $this->_db->buildClause('page_name', 'LIKE', $firstword);
if (!empty($lastword) && $lastword != $firstword) {
$where .= ' OR ' . $this->_db->buildClause('page_name', 'LIKE', $lastword);
}
} catch (Horde_Db_Exception $e) {
throw new Wicked_Exception($e);
}
return $this->_retrieve($this->_params['table'], $where);
}
/**
* Retrieves data on files attached to a page.
*
* @param string $pageId This is the Id of the page for which we'd
* like to find attached files.
* @param boolean $allversions Whether to include all versions. If false
* or omitted, only the most recent version
* of each attachment is returned.
* @return array An array of key/value arrays describing the attached
* files.
* @throws Wicked_Exception
*/
public function getAttachedFiles($pageId, $allversions = false)
{
$where = array('page_id = ?', array((int)$pageId));
$data = $this->_retrieve($this->_params['attachmenttable'], $where);
if ($allversions) {
$more_data = $this->_retrieve(
$this->_params['attachmenthistorytable'], $where);
$data = array_merge($data, $more_data);
}
foreach (array_keys($data) as $key) {
$data[$key]['attachment_name'] = $this->_convertFromDriver($data[$key]['attachment_name']);
}
usort(
$data,
function($a, $b)
{
if ($res = strcmp($a['attachment_name'], $b['attachment_name'])) {
return $res;
}
return ($a['attachment_version'] - $b['attachment_version']);
}
);
return $data;
}
/**
* Removes a single version or all versions of an attachment from
* $pageId.
*
* @param integer $pageId The Id of the page the file is attached to.
* @param string $attachment The name of the file.
* @param string $version If specified, the version to delete. If null,
* then all versions of $attachment will be
* removed.
*
* @throws Wicked_Exception
*/
public function removeAttachment($pageId, $attachment, $version = null)
{
/* Try to delete from the VFS first. */
parent::removeAttachment($pageId, $attachment, $version);
/* First try against the current attachments table. */
$sql = 'DELETE FROM ' . $this->_params['attachmenttable'] .
' WHERE page_id = ? AND attachment_name = ?';
$params = array((int)$pageId, $attachment);
if (!is_null($version)) {
$sql .= ' AND attachment_version = ?';
$params[] = (int)$version;
}
try {
$this->_db->beginDbTransaction();
$result = $this->_db->delete($sql, $params);
/* Now try against the attachment history table. $params is
* unchanged. */
$sql = 'DELETE FROM ' . $this->_params['attachmenthistorytable'] .
' WHERE page_id = ? AND attachment_name = ?';
if (!is_null($version)) {
$sql .= ' AND attachment_version = ?';
}
$this->_db->delete($sql, $params);
$this->_db->commitDbTransaction();
} catch (Horde_Db_Exception $e) {
$this->_db->rollbackDbTransaction();
throw new Wicked_Exception($e);
}
}
/**
* Removes all attachments from a page.
*
* @param integer $pageId A page ID.
*
* @throws Wicked_Exception
*/
public function removeAllAttachments($pageId)
{
/* Try to delete from the VFS first. */
$result = parent::removeAllAttachments($pageId);
$params = array((int)$pageId);
try {
$this->_db->beginDbTransaction();
/* First try against the current attachments table. */
$result = $this->_db->delete(
'DELETE FROM ' . $this->_params['attachmenttable']
. ' WHERE page_id = ?',
$params);
/* Now try against the attachment history table. $params is
* unchanged. */
$this->_db->delete(
'DELETE FROM ' . $this->_params['attachmenthistorytable']
. ' WHERE page_id = ?',
$params);
$this->_db->commitDbTransaction();
} catch (Horde_Db_Exception $e) {
$this->_db->rollbackDbTransaction();
throw new Wicked_Exception($e);
}
}
/**
* Handles the driver-specific portion of attaching a file.
*
* Wicked_Driver::attachFile() calls down to this method for the driver-
* specific portion, and then uses VFS to store the attachment.
*
* @param array $file See Wicked_Driver::attachFile().
*
* @return integer The new version of the file attached.
* @throws Wicked_Exception
*/
protected function _attachFile($file)
{
if ($file['change_author'] === false) {
$file['change_author'] = null;
}
$attachments = $this->_retrieve(
$this->_params['attachmenttable'],
array('page_id = ? AND attachment_name = ?',
array((int)$file['page_id'], $file['attachment_name'])));
if ($attachments) {
$version = $attachments[0]['attachment_version'] + 1;
try {
$this->_db->beginDbTransaction();
$this->_db->insert(
sprintf('INSERT INTO %s (page_id, attachment_name, attachment_version, attachment_created, change_author, change_log) SELECT page_id, attachment_name, attachment_version, attachment_created, change_author, change_log FROM %s WHERE page_id = ? AND attachment_name = ?',
$this->_params['attachmenthistorytable'],
$this->_params['attachmenttable']),
array((int)$file['page_id'],
$file['attachment_name']));
$this->_db->update(
sprintf('UPDATE %s SET attachment_version = ?, change_log = ?, change_author = ?, attachment_created = ? WHERE page_id = ? AND attachment_name = ?',
$this->_params['attachmenttable']),
array((int)$version,
$this->_convertToDriver($file['change_log']),
$this->_convertToDriver($file['change_author']),
time(),
(int)$file['page_id'],
$this->_convertToDriver($file['attachment_name'])));
$this->_db->commitDbTransaction();
} catch (Horde_Db_Exception $e) {
$this->_db->rollbackDbTransaction();
throw new Wicked_Exception($e);
}
} else {
$version = 1;
try {
$this->_db->insert(
sprintf('INSERT INTO %s (page_id, attachment_version, change_log, change_author, attachment_created, attachment_name) VALUES (?, 1, ?, ?, ?, ?)',
$this->_params['attachmenttable']),
array((int)$file['page_id'],
$this->_convertToDriver($file['change_log']),
$this->_convertToDriver($file['change_author']),
time(),
$this->_convertToDriver($file['attachment_name'])));
} catch (Horde_Db_Exception $e) {
throw new Wicked_Exception($e);
}
}
return $version;
}
/**
* Logs a page view.
*
* @param string $pagename The page that was viewed.
*
* @throws Wicked_Exception
*/
public function logPageView($pagename)
{
try {
return $this->_db->update(
'UPDATE ' . $this->_params['table']
. ' SET page_hits = page_hits + 1 WHERE page_name = ?',
array($this->_convertToDriver($pagename)));
} catch (Horde_Db_Exception $e) {
throw new Wicked_Exception($e);
}
}
/**
* Logs an attachment download.
*
* @param integer $pageid The page with the attachment.
* @param string $attachment The attachment name.
*
* @throws Wicked_Exception
*/
public function logAttachmentDownload($pageid, $attachment)
{
try {
return $this->_db->update(
'UPDATE ' . $this->_params['attachmenttable']
. ' SET attachment_hits = attachment_hits + 1'
. ' WHERE page_id = ? AND attachment_name = ?',
array((int)$pageid, $this->_convertToDriver($attachment)));
} catch (Horde_Db_Exception $e) {
throw new Wicked_Exception($e);
}
}
/**
* Creates a new page.
*
* @param string $pagename The new page's name.
* @param string $text The new page's text.
*
* @throws Wicked_Exception
*/
public function newPage($pagename, $text)
{
if (!strlen($pagename)) {
throw new Wicked_Exception(_("Page name must not be empty"));
}
if ($GLOBALS['browser']->isRobot()) {
throw new Wicked_Exception(_("Robots are not allowed to create pages"));
}
$author = $GLOBALS['registry']->getAuth();
if ($author === false) {
$author = null;
}
/* Attempt the insertion/update query. */
try {
$page_id = $this->_db->insert(
'INSERT INTO ' . $this->_params['table']
. ' (page_name, page_text, version_created, page_version,'
. ' page_hits, change_author) VALUES (?, ?, ?, 1, 0, ?)',
array($this->_convertToDriver($pagename),
$this->_convertToDriver($text),
time(),
$author));
} catch (Horde_Db_Exception $e) {
throw new Wicked_Exception($e);
}
/* Send notification. */
$url = Wicked::url($pagename, true, -1);
Wicked::mail("Created page: $url\n\n$text\n",
array('Subject' => '[' . $GLOBALS['registry']->get('name')
. '] created: ' . $pagename));
/* Call getPages with no caching so that the new list of pages is
* read in. */
$this->getPages(true, true);
return $page_id;
}
/**
* Renames a page, keeping the page's history.
*
* @param string $pagename The name of the page to rename.
* @param string $newname The page's new name.
*
* @throws Wicked_Exception
*/
public function renamePage($pagename, $newname)
{
try {
$this->_db->beginDbTransaction();
$this->_db->update(
'UPDATE ' . $this->_params['table']
. ' SET page_name = ? WHERE page_name = ?',
array($this->_convertToDriver($newname),
$this->_convertToDriver($pagename)));
$this->_db->update(
'UPDATE ' . $this->_params['historytable']
. ' SET page_name = ? WHERE page_name = ?',
array($this->_convertToDriver($newname),
$this->_convertToDriver($pagename)));
$this->_db->commitDbTransaction();
} catch (Horde_Db_Exception $e) {
$this->_db->rollbackDbTransaction();
throw new Wicked_Exception($e);
}
$changelog = sprintf(_("Renamed page from %s"), $pagename);
$newPage = $this->retrieveByName($newname);
/* Call getPages with no caching so that the new list of pages is
* read in. */
$this->getPages(true, true);
return $this->updateText($newname, $newPage['page_text'], $changelog);
}
public function updateText($pagename, $text, $changelog)
{
if (!$this->pageExists($pagename)) {
return $this->newPage($pagename, $text);
}
/* Copy the old version into the page history. */
Horde::log('Page ' . $pagename . ' saved with user agent ' . $GLOBALS['browser']->getAgentString(), 'DEBUG');
$author = $GLOBALS['registry']->getAuth();
if ($author === false) {
$author = null;
}
try {
$this->_db->beginDbTransaction();
$this->_db->insert(
sprintf('INSERT INTO %s (page_id, page_name, page_text, page_version, version_created, change_author, change_log) SELECT page_id, page_name, page_text, page_version, version_created, change_author, change_log FROM %s WHERE page_name = ?',
$this->_params['historytable'],
$this->_params['table']),
array($this->_convertToDriver($pagename)));
/* Now move on to updating the record. */
$this->_db->update(
'UPDATE ' . $this->_params['table']
. ' SET change_author = ?, page_text = ?, change_log = ?,'
. ' version_created = ?, page_version = page_version + 1'
. ' WHERE page_name = ?',
array($author,
$this->_convertToDriver($text),
$this->_convertToDriver($changelog),
time(),
$this->_convertToDriver($pagename)));
$this->_db->commitDbTransaction();
} catch (Horde_Db_Exception $e) {
$this->_db->rollbackDbTransaction();
throw new Wicked_Exception($e);
}
}
public function getPages($special = true, $no_cache = false)
{
if (!isset($this->_pageNames) || $no_cache) {
try {
$result = $this->_db->selectAssoc(
'SELECT page_id, page_name FROM ' . $this->_params['table']);
} catch (Horde_Db_Exception $e) {
throw new Wicked_Exception($e);
}
$this->_pageNames = $this->_convertFromDriver($result);
}
if ($special) {
return $this->_pageNames + $this->getSpecialPages();
}
return $this->_pageNames;
}
/**
*/
public function removeVersion($pagename, $version)
{
$values = array($this->_convertToDriver($pagename), (int)$version);
/* We need to know if we're deleting the current version. */
try {
$result = $this->_db->selectValue(
'SELECT 1 FROM ' . $this->_params['table']
. ' WHERE page_name = ? AND page_version = ?',
$values);
} catch (Horde_Db_Exception $e) {
$result = false;
}
if (!$result) {
/* Removing a historical revision - we can just slice it out of the
* history table. $values is unchanged. */
try {
$this->_db->delete(
'DELETE FROM ' . $this->_params['historytable']
. ' WHERE page_name = ? and page_version = ?',
$values);
} catch (Horde_Db_Exception $e) {
throw new Wicked_Exception($e);
}
return;
}
/* We're deleting the current version. Have to promote the next-most
* revision from the history table. */
try {
$query = 'SELECT * FROM ' . $this->_params['historytable'] .
' WHERE page_name = ? ORDER BY page_version DESC';
$query = $this->_db->addLimitOffset($query, array('limit' => 1));
$revision = $this->_db->selectOne(
$query, array($this->_convertToDriver($pagename)));
/* Replace the current version of the page with the version being
* promoted. */
$this->_db->beginDbTransaction();
$this->_db->update(
'UPDATE ' . $this->_params['table'] . ' SET' .
' page_text = ?, page_version = ?,' .
' version_created = ?, change_author = ?, change_log = ?' .
' WHERE page_name = ?',
array($revision['page_text'],
(int)$revision['page_version'],
(int)$revision['version_created'],
$revision['change_author'],
$revision['change_log'],
$this->_convertToDriver($pagename)));
/* Finally, remove the version that we promoted from the history
* table. */
$this->_db->delete(
'DELETE FROM ' . $this->_params['historytable'] .
' WHERE page_name = ? and page_version = ?',
array($this->_convertToDriver($pagename),
(int)$revision['page_version']));
$this->_db->commitDbTransaction();
} catch (Horde_Db_Exception $e) {
$this->_db->rollbackDbTransaction();
throw new Wicked_Exception($e);
}
}
/**
*/
public function removeAllVersions($pagename)
{
/* Remove attachments and do other cleanup. */
parent::removeAllVersions($pagename);
$this->_pageNames = null;
try {
$this->_db->beginDbTransaction();
$this->_db->delete(
'DELETE FROM ' . $this->_params['table']
. ' WHERE page_name = ?',
array($this->_convertToDriver($pagename)));
$this->_db->delete(
'DELETE FROM ' . $this->_params['historytable']
. ' WHERE page_name = ?',
array($this->_convertToDriver($pagename)));
$this->_db->commitDbTransaction();
} catch (Horde_Db_Exception $e) {
$this->_db->rollbackDbTransaction();
throw new Wicked_Exception($e);
}
}
/**
* Retrieves a set of pages matching an SQL WHERE clause.
*
* @param string $table Table to retrieve pages from.
* @param array|string $where Where clause for sql statement (without the
* 'WHERE'). If an array the 1st element is the
* clause with placeholder, the 2nd element the
* values.
* @param string $orderBy Order results by this column.
* @param integer $limit Maximum number of pages to fetch.
*
* @return array A list of page hashes.
* @throws Wicked_Exception
*/
protected function _retrieve($table, $where, $orderBy = null, $limit = null)
{
$query = 'SELECT * FROM ' . $table;
$values = array();
if (!empty($where)) {
$query .= ' WHERE ';
if (is_array($where)) {
$query .= $where[0];
$values = $where[1];
} else {
$query .= $where;
}
}
if (!empty($orderBy)) {
$query .= ' ORDER BY ' . $orderBy;
}
if (!empty($limit)) {
try {
$query = $this->_db->addLimitOffset($query, array('limit' => $limit));
} catch (Horde_Db_Exception $e) {
throw new Wicked_Exception($e);
}
}
try {
$result = $this->_db->select($query, $values);
} catch (Horde_Db_Exception $e) {
throw new Wicked_Exception($e);
}
$pages = array();
foreach ($result as $row) {
if (isset($row['page_name'])) {
$row['page_name'] = $this->_convertFromDriver($row['page_name']);
}
if (isset($row['page_text'])) {
$row['page_text'] = $this->_convertFromDriver($row['page_text']);
}
if (isset($row['change_log'])) {
$row['change_log'] = $this->_convertFromDriver($row['change_log']);
}
$pages[] = $row;
}
return $pages;
}
/**
* Returns the charset used by the backend.
*
* @return string The backend's charset
*/
public function getCharset()
{
return $this->_db->getOption('charset');
}
/**
* Converts a value from the driver's charset to the default charset.
*
* @param mixed $value A value to convert.
*
* @return mixed The converted value.
*/
protected function _convertFromDriver($value)
{
return Horde_String::convertCharset($value, $this->getCharset(), 'UTF-8');
}
/**
* Converts a value from the default charset to the driver's charset.
*
* @param mixed $value A value to convert.
*
* @return mixed The converted value.
*/
protected function _convertToDriver($value)
{
return Horde_String::convertCharset($value, 'UTF-8', $this->getCharset());
}
}
wicked-2.0.4/lib/Factory/Driver.php 0000664 0000765 0000024 00000004461 12557035537 014045 0 ustar
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @package Wicked
*/
/**
* Wicked_Driver factory.
*
* @author Jan Schneider
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @package Wicked
*/
class Wicked_Factory_Driver extends Horde_Core_Factory_Injector
{
/**
* @var array
*/
private $_instances = array();
/**
* Return an Wicked_Driver instance.
*
* @param Horde_Injector $injector An injector object.
*
* @return Wicked_Driver A driver instance.
* @throws Wicked_Exception
*/
public function create(Horde_Injector $injector)
{
$driver = Horde_String::ucfirst($GLOBALS['conf']['storage']['driver']);
if (empty($driver)) {
throw new Wicked_Exception('Wicked is not configured');
}
$signature = serialize(array($driver, $GLOBALS['conf']['storage']['params']['driverconfig']));
if (empty($this->_instances[$signature])) {
switch ($driver) {
case 'Sql':
$params = array('db' => $this->getDb($injector));
break;
}
$class = 'Wicked_Driver_' . $driver;
$this->_instances[$signature] = new $class($params);
}
return $this->_instances[$signature];
}
/**
* Returns a Horde_Db instance for the SQL backend.
*
* @param Horde_Injector $injector An injector object.
*
* @return Horde_Db_Adapter A correctly configured Horde_Db_Adapter
* instance.
* @throws Wicked_Exception
*/
public function getDb(Horde_Injector $injector)
{
try {
if ($GLOBALS['conf']['storage']['params']['driverconfig'] == 'horde') {
return $injector->getInstance('Horde_Db_Adapter');
}
return $injector->getInstance('Horde_Core_Factory_Db')
->create('wicked', 'storage');
} catch (Horde_Exception $e) {
throw new Wicked_Exception($e);
}
}
}
wicked-2.0.4/lib/Page/AddPage.php 0000664 0000765 0000024 00000005706 12557035537 013347 0 ustar
* @author Tyler Colbert
* @package Wicked
*/
/**
* Displays a form to add new pages.
*
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @author Jan Schneider
* @author Tyler Colbert
* @package Wicked
*/
class Wicked_Page_AddPage extends Wicked_Page
{
/**
* Display modes supported by this page.
*
* @var array
*/
public $supportedModes = array(
Wicked::MODE_DISPLAY => true
);
/**
* The page to confirm creation of.
*
* @var string
*/
protected $_newpage;
/**
* Cached search results.
*
* @var array
*/
protected $_results;
public function __construct($newpage)
{
$this->_newpage = $newpage;
$this->_results = $GLOBALS['wicked']->searchTitles($newpage);
}
/**
* Bail out if there's no page name.
*/
public function preDisplay()
{
if (!strlen($this->referrer())) {
$GLOBALS['notification']->push(_("Page name must not be empty"));
Wicked::url('', true)->redirect();
}
}
/**
* Renders this page in display mode.
*
* @throws Wicked_Exception
*/
public function display()
{
global $injector, $page_output, $wicked;
$view = $injector->createInstance('Horde_View');
$view->action = Wicked::url('NewPage');
$view->formInput = Horde_Util::formInput();
$view->referrer = $this->referrer();
$view->name = $this->pageName();
if ($this->_results) {
$page_output->addScriptFile('tables.js', 'horde');
$view->pages = array();
foreach ($this->_results as $page) {
if (!empty($page['page_history'])) {
$page = new Wicked_Page_StandardHistoryPage($page);
} else {
$page = new Wicked_Page_StandardPage($page);
}
$view->pages[] = $page->toView();
}
}
$view->templates = $wicked->getMatchingPages('Template', Wicked_Page::MATCH_ENDS);
$view->help = Horde_Help::link('wicked', 'Templates');
return $view->render('edit/create');
}
public function pageName()
{
return 'AddPage';
}
public function pageTitle()
{
return sprintf(_("Add Page: %s"), $this->referrer());
}
public function referrer()
{
return $this->_newpage;
}
/**
*
*
* @return string
*/
public function getText()
{
// New page, no text to return
return '';
}
}
wicked-2.0.4/lib/Page/AllPages.php 0000664 0000765 0000024 00000003654 12557035537 013552 0 ustar
* @author Tyler Colbert
* @package Wicked
*/
/**
* Displays a list of all pages.
*
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @author Jan Schneider
* @author Tyler Colbert
* @package Wicked
*/
class Wicked_Page_AllPages extends Wicked_Page
{
/**
* Display modes supported by this page.
*/
public $supportedModes = array(
Wicked::MODE_CONTENT => true,
Wicked::MODE_DISPLAY => true);
/**
* Renders this page in content mode.
*
* @return string The page content.
*/
public function content()
{
return $GLOBALS['wicked']->getAllPages();
}
/**
* Renders this page in display or block mode.
*
* @return string The page contents.
* @throws Wicked_Exception
*/
public function displayContents($isBlock)
{
global $injector, $page_output;
$pages = array();
foreach ($this->content() as $page) {
$page = new Wicked_Page_StandardPage($page);
$pages[] = $page->toView();
}
$page_output->addScriptFile('tables.js', 'horde');
$view = $injector->createInstance('Horde_View');
// Show search form and page header.
return $view->render('pagelist/header')
. $view->renderPartial('pagelist/page', array('collection' => $pages))
. $view->render('pagelist/footer');
}
public function pageName()
{
return 'AllPages';
}
public function pageTitle()
{
return _("All Pages");
}
}
wicked-2.0.4/lib/Page/AttachedFiles.php 0000664 0000765 0000024 00000023413 12557035537 014555 0 ustar
* @author Jason M. Felice
* @package Wicked
*/
/**
* Displays and handles attached files.
*
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @author Jan Schneider
* @author Jason M. Felice
* @package Wicked
*/
class Wicked_Page_AttachedFiles extends Wicked_Page
{
/**
* Display modes supported by this page.
*
* @var array
*/
public $supportedModes = array(
Wicked::MODE_CONTENT => true,
Wicked::MODE_EDIT => true,
Wicked::MODE_REMOVE => true,
Wicked::MODE_DISPLAY => true);
/**
* The page for which we'd like to manipulate attachments.
*
* @var string
*/
protected $_referrer = null;
/**
* Constructor.
*/
public function __construct($referrer)
{
$this->_referrer = $referrer;
}
/**
* Returns the current user's permissions for the referring page.
*
* @return integer The permissions bitmask.
*/
public function getPermissions()
{
return parent::getPermissions($this->referrer());
}
/**
* Returns this page rendered in content mode.
*
* @throws Wicked_Exception
*/
public function content()
{
global $wicked, $notification, $registry;
if (!$wicked->pageExists($this->referrer())) {
throw new Wicked_Exception(sprintf(_("Referrer \"%s\" does not exist."),
$this->referrer()));
}
$referrer_id = $wicked->getPageId($this->referrer());
$attachments = $wicked->getAttachedFiles($referrer_id, true);
foreach ($attachments as $idx => $attach) {
$attachments[$idx]['timestamp'] = $attach['attachment_created'];
$attachments[$idx]['date'] = strftime(
$GLOBALS['prefs']->getValue('date_format'),
$attach['attachment_created']
);
$attachments[$idx]['url'] = $registry->downloadUrl(
$attach['attachment_name'],
array('page' => $referrer_id,
'file' => $attach['attachment_name'],
'version' => $attach['attachment_version']));
$attachments[$idx]['delete_form'] = $this->allows(Wicked::MODE_REMOVE);
$this->_page['change_author'] = $attachments[$idx]['change_author'];
$attachments[$idx]['change_author'] = $this->author();
}
return $attachments;
}
/**
* Returns this page rendered in Display mode.
*
* @throws Wicked_Exception
*/
public function display()
{
global $registry, $wicked, $notification, $conf;
try {
$attachments = $this->content();
} catch (Wicked_Exception $e) {
$notification->push(sprintf(_("Error retrieving attachments: %s"),
$e->getMessage()),
'horde.error');
throw $e;
}
$GLOBALS['page_output']->addScriptFile('tables.js', 'horde');
$view = $GLOBALS['injector']->createInstance('Horde_View');
$view->pageName = $this->pageName();
$view->formAction = Wicked::url('AttachedFiles');
$view->deleteButton = Horde_Themes::img('delete.png');
$view->referrerLink = Wicked::url($this->referrer());
$refreshIcon = Horde::link($this->pageUrl())
. Horde::img('reload.png',
sprintf(_("Reload \"%s\""), $this->pageTitle()))
. '';
$view->refreshIcon = $refreshIcon;
$view->attachments = $attachments;
/* Get an array of unique filenames for the update form. */
$files = array();
foreach ($attachments as $attachment) {
$files[$attachment['attachment_name']] = true;
}
$files = array_keys($files);
sort($files);
$view->files = $files;
$view->canUpdate = $this->allows(Wicked::MODE_EDIT) && count($files);
$view->canAttach = $this->allows(Wicked::MODE_EDIT);
$view->requireChangelog = $conf['wicked']['require_change_log'];
$view->requiredMarker = Horde::img('required.png', '*');
$view->referrer = $this->referrer();
$view->formInput = Horde_Util::formInput();
echo $view->render('display/AttachedFiles');
}
public function pageName()
{
return 'AttachedFiles';
}
public function pageTitle()
{
return sprintf(_("Attached Files: %s"), $this->referrer());
}
public function referrer()
{
return $this->_referrer;
}
/**
* Retrieves the form fields and processes the attachment.
*/
public function handleAction()
{
global $notification, $wicked, $registry, $conf;
// Only allow POST commands.
$cmd = Horde_Util::getPost('cmd');
$version = Horde_Util::getFormData('version');
$is_update = (bool)Horde_Util::getFormData('is_update');
$filename = Horde_Util::getFormData('filename');
$change_log = Horde_Util::getFormData('change_log');
// See if we're supposed to delete an attachment.
if ($cmd == 'delete' && $filename && $version) {
if (!$this->allows(Wicked::MODE_REMOVE)) {
$notification->push(_("You do not have permission to delete attachments from this page."), 'horde.error');
return;
}
try {
$wicked->removeAttachment($wicked->getPageId($this->referrer()),
$filename, $version);
$notification->push(
sprintf(_("Successfully deleted version %s of \"%s\" from \"%s\""),
$version, $filename, $this->referrer()),
'horde.success');
} catch (Wicked_Exception $e) {
$notification->push($result->getMessage(), 'horde.error');
}
return;
}
if (empty($filename)) {
$filename = Horde_Util::dispelMagicQuotes($_FILES['attachment_file']['name']);
}
try {
$GLOBALS['browser']->wasFileUploaded('attachment_file', _("attachment"));
} catch (Horde_Browser_Exception $e) {
$notification->push($e, 'horde.error');
return;
}
if (strpos($filename, ' ') !== false) {
$notification->push(
_("Attachments with spaces can't be embedded into a page."),
'horde.warning');
}
$data = file_get_contents($_FILES['attachment_file']['tmp_name']);
if ($data === false) {
$notification->push(_("Can't read uploaded file."), 'horde.error');
return;
}
if (!$this->allows(Wicked::MODE_EDIT)) {
$notification->push(
sprintf(_("You do not have permission to edit \"%s\""),
$this->referrer()),
'horde.error');
return;
}
if ($conf['wicked']['require_change_log'] && empty($change_log)) {
$notification->push(
_("You must enter a change description to attach this file."),
'horde.error');
return;
}
$referrer_id = $wicked->getPageId($this->referrer());
try {
$attachments = $wicked->getAttachedFiles($referrer_id);
} catch (Wicked_Exception $e) {
$notification->push(sprintf(_("Error retrieving attachments: %s"),
$e->getMessage()),
'horde.error');
return;
}
$found = false;
foreach ($attachments as $attach) {
if ($filename == $attach['attachment_name']) {
$found = true;
break;
}
}
if ($is_update) {
if (!$found) {
$notification->push(
sprintf(_("Can't update \"%s\": no such attachment."),
$filename),
'horde.error');
return;
}
} else {
if ($found) {
$notification->push(
sprintf(_("There is already an attachment named \"%s\"."),
$filename),
'horde.error');
return;
}
}
$file = array('page_id' => $referrer_id,
'attachment_name' => $filename,
'change_log' => $change_log);
try {
$wicked->attachFile($file, $data);
} catch (Wicked_Exception $e) {
$notification->push($e);
Horde::log($e);
throw $e;
}
if ($is_update) {
$message = sprintf(_("Updated attachment \"%s\" on page \"%s\"."),
$filename, $this->referrer());
} else {
$message = sprintf(_("New attachment \"%s\" to page \"%s\"."),
$filename, $this->referrer());
}
$notification->push($message, 'horde.success');
$url = Wicked::url($this->referrer(), true, -1);
Wicked::mail($message . ' ' . _("View page: ") . $url . "\n",
array('Subject' => '[' . $registry->get('name')
. '] attachment: ' . $this->referrer() . ', '
. $filename));
}
}
wicked-2.0.4/lib/Page/BackLinks.php 0000664 0000765 0000024 00000004326 12557035537 013720 0 ustar
* @author Tyler Colbert
* @package Wicked
*/
/**
* Display page backlinks
*
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @author Jan Schneider
* @author Tyler Colbert
* @package Wicked
*/
class Wicked_Page_BackLinks extends Wicked_Page
{
/**
* Display modes supported by this page.
*
* @var array
*/
public $supportedModes = array(
Wicked::MODE_DISPLAY => true);
/**
* The page that we're displaying backlinks to.
*
* @var string
*/
protected $_referrer = null;
public function __construct($referrer)
{
$this->_referrer = $referrer;
}
/**
* Renders this page in display or block mode.
*
* @return string The contents.
* @throws Wicked_Exception
*/
public function displayContents($isBlock)
{
global $injector, $page_output, $wicked;
$page_output->addScriptFile('tables.js', 'horde');
$view = $injector->createInstance('Horde_View');
$content = $view->render('pagelist/header');
$summaries = $wicked->getBackLinks($this->_referrer);
foreach ($summaries as $page) {
if (!empty($page['page_history'])) {
$page = new Wicked_Page_StandardHistoryPage($page);
} else {
$page = new Wicked_Page_StandardPage($page);
}
$content .= $view->renderPartial(
'pagelist/page',
array('object' => $page->toView())
);
}
return $content . $view->render('pagelist/footer');
}
public function pageName()
{
return 'BackLinks';
}
public function pageTitle()
{
return sprintf(_("Backlinks: %s"), $this->referrer());
}
public function referrer()
{
return $this->_referrer;
}
}
wicked-2.0.4/lib/Page/DeletePage.php 0000664 0000765 0000024 00000011345 12557035537 014055 0 ustar
* @author Chuck Hagenbuch
* @package Wicked
*/
/**
* Displays a confirmation form for deleting pages.
*
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @author Jan Schneider
* @author Chuck Hagenbuch
* @package Wicked
*/
class Wicked_Page_DeletePage extends Wicked_Page
{
/**
* Display modes supported by this page.
*
* @var array
*/
public $supportedModes = array(Wicked::MODE_DISPLAY => true);
/**
* The page that we're confirming deletion for.
*
* @var string
*/
protected $_referrer = null;
public function __construct($referrer)
{
$this->_referrer = $referrer;
}
/**
* Retrieve this user's permissions for the referring page.
*
* @return integer The permissions bitmask.
*/
public function getPermissions()
{
return parent::getPermissions($this->referrer());
}
/**
* Send them back whence they came if they aren't allowed to
* delete this page.
*/
public function preDisplay()
{
$page = Wicked_Page::getPage($this->referrer());
if (!$page->allows(Wicked::MODE_REMOVE)) {
Wicked::url($this->referrer(), true)->redirect();
}
}
/**
* Render this page in Display mode.
*
* @throws Wicked_Exception
*/
public function display()
{
$version = Horde_Util::getFormData('version');
$page = Wicked_Page::getPage($this->referrer(), $version);
if (!$page->isValid()) {
Wicked::url('Wiki/Home', true)->redirect();
}
if (empty($version)) {
$msg = _("Are you sure you want to delete this page? All versions will be permanently removed.");
} else {
$msg = sprintf(_("Are you sure you want to delete version %s of this page?"),
$page->version());
}
?>
_referrer;
}
public function handleAction()
{
$pagename = $this->referrer();
$page = Wicked_Page::getPage($pagename);
if ($page->allows(Wicked::MODE_REMOVE)) {
$version = Horde_Util::getFormData('version');
if (empty($version)) {
$GLOBALS['wicked']->removeAllVersions($pagename);
$GLOBALS['notification']->push(sprintf(_("Successfully deleted \"%s\"."), $pagename), 'horde.success');
Wicked::mail("Deleted page: $pagename\n",
array('Subject' => '[' . $GLOBALS['registry']->get('name') . '] deleted: ' . $pagename));
Wicked::url('Wiki/Home', true)->redirect();
}
$GLOBALS['wicked']->removeVersion($pagename, $version);
$GLOBALS['notification']->push(sprintf(_("Deleted version %s of \"%s\"."), $version, $pagename), 'horde.success');
Wicked::mail("Deleted version: $version of $pagename\n",
array('Subject' => '[' . $GLOBALS['registry']->get('name') . '] deleted: ' . $pagename . ' [' . $version . ']'));
Wicked::url($pagename, true)->redirect();
}
$GLOBALS['notification']->push(sprintf(_("You don't have permission to delete \"%s\"."), $pagename), 'horde.warning');
Wicked::url($this->referrer(), true)->redirect();
}
}
wicked-2.0.4/lib/Page/EditPage.php 0000664 0000765 0000024 00000015647 12557035537 013551 0 ustar
* @author Jason M. Felice
* @package Wicked
*/
/**
* Displays and handles the form to edit pages.
*
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @author Jan Schneider
* @author Jason M. Felice
* @package Wicked
*/
class Wicked_Page_EditPage extends Wicked_Page
{
/**
* Display modes supported by this page.
*
* @var array
*/
public $supportedModes = array(
Wicked::MODE_DISPLAY => true,
Wicked::MODE_EDIT => true);
/**
* The page that we're editing.
*
* @var string
*/
protected $_referrer = null;
public function __construct($referrer)
{
$this->_referrer = $referrer;
if ($GLOBALS['conf']['lock']['driver'] != 'none') {
$this->supportedModes[Wicked::MODE_LOCKING] = $this->supportedModes[Wicked::MODE_UNLOCKING] = true;
}
}
/**
* Returns if the page allows a mode. Access rights and user state
* are taken into consideration.
*
* @see $supportedModes
*
* @param integer $mode The mode to check for.
*
* @return boolean True if the mode is allowed.
*/
public function allows($mode)
{
if ($mode == Wicked::MODE_EDIT) {
$page = Wicked_Page::getPage($this->referrer());
if ($page->isLocked(Wicked::lockUser())) {
return false;
}
}
return parent::allows($mode);
}
/**
* Retrieve this user's permissions for the referring page.
*
* @return integer The permissions bitmask.
*/
public function getPermissions()
{
return parent::getPermissions($this->referrer());
}
/**
* Send them back whence they came if they aren't allowed to edit
* this page.
*/
public function preDisplay()
{
if (!$this->allows(Wicked::MODE_EDIT)) {
Wicked::url($this->referrer(), true)->redirect();
}
if ($this->allows(Wicked::MODE_LOCKING)) {
$page = Wicked_Page::getPage($this->referrer());
if ($page->isLocked()) {
$page->unlock();
}
try {
$page->lock();
} catch (Wicked_Exception $e) {
$GLOBALS['notification']->push(sprintf(_("Page failed to lock: %s"), $e->getMessage()), 'horde.error');
}
}
}
/**
* Renders this page in display mode.
*
* @throws Wicked_Exception
*/
public function display()
{
$GLOBALS['page_output']->addScriptFile('edit.js');
$GLOBALS['injector']->getInstance('Horde_View_Topbar')->subinfo =
sprintf(
_("Last Modified %s by %s"),
$this->formatVersionCreated(),
$this->author()
);
$page = Wicked_Page::getPage($this->referrer());
$view = $GLOBALS['injector']->createInstance('Horde_View');
$view->action = Wicked::url('EditPage');
$view->formInput = Horde_Util::formInput();
$view->name = $page->pageName();
$view->header = $page->pageUrl()->link()
. htmlspecialchars($page->pageName()) . ' ';
if ($page->isLocked()) {
$view->header .= ' ' . Horde::img('locked.png', _("Locked"));
}
$view->cancel = $page->pageUrl()
->add('actionID', 'unlock')
->link(array('class' => 'horde-cancel'))
. _("Cancel") . '';
if (!empty($GLOBALS['conf']['wicked']['require_change_log'])) {
$view->changelogRequired = Horde::img(
'required.png',
_("Changelog is required")
);
}
if (!empty($GLOBALS['conf']['wicked']['captcha']) &&
!$GLOBALS['registry']->getAuth()) {
$figlet = new Text_Figlet();
Horde_Exception_Pear::catchError($figlet->loadFont(
$GLOBALS['conf']['wicked']['figlet_font']
));
$view->captcha = $figlet->lineEcho(Wicked::getCAPTCHA(true));
}
$view->text = Horde_Util::getFormData('page_text');
if (is_null($view->text)) {
$view->text = $page->getText();
}
return $view->render('edit/standard');
}
public function pageName()
{
return 'EditPage';
}
public function pageTitle()
{
return _("Edit Page");
}
public function referrer()
{
return $this->_referrer;
}
public function isLocked()
{
$page = Wicked_Page::getPage($this->referrer());
return $page->isLocked();
}
public function getLockRequestor()
{
$page = Wicked_Page::getPage($this->referrer());
return $page->getLockRequestor();
}
public function getLockTime()
{
$page = Wicked_Page::getPage($this->referrer());
return $page->getLockTime();
}
public function handleAction()
{
global $notification, $conf;
$page = Wicked_Page::getPage($this->referrer());
if (!$this->allows(Wicked::MODE_EDIT)) {
$notification->push(sprintf(_("You don't have permission to edit \"%s\"."), $page->pageName()));
} else {
if (!empty($GLOBALS['conf']['wicked']['captcha']) &&
!$GLOBALS['registry']->getAuth() &&
(Horde_String::lower(Horde_Util::getFormData('wicked_captcha')) != Horde_String::lower(Wicked::getCAPTCHA()))) {
$notification->push(_("Random string did not match."), 'horde.error');
return;
}
$text = Horde_Util::getFormData('page_text');
$changelog = Horde_Util::getFormData('changelog');
if ($conf['wicked']['require_change_log'] && empty($changelog)) {
$notification->push(_("You must provide a change log."), 'horde.error');
$GLOBALS['page_output']->addInlineScript(array(
'if (document.editform && document.editform.changelog) document.editform.changelog.focus()'
), true);
return;
}
if (trim($text) == trim($page->getText())) {
$notification->push(_("No changes made"), 'horde.warning');
} else {
$page->updateText($text, $changelog);
$notification->push(_("Page Saved"), 'horde.success');
}
if ($page->allows(Wicked::MODE_UNLOCKING)) {
$page->unlock();
}
}
// Show the newly saved page.
Wicked::url($this->referrer(), true)->redirect();
}
}
wicked-2.0.4/lib/Page/LeastPopular.php 0000664 0000765 0000024 00000004163 12557035537 014471 0 ustar
* @author Tyler Colbert
* @package Wicked
*/
/**
* Lists the least popular pages.
*
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @author Jan Schneider
* @author Tyler Colbert
* @package Wicked
*/
class Wicked_Page_LeastPopular extends Wicked_Page
{
/**
* Display modes supported by this page.
*
* @var array
*/
public $supportedModes = array(
Wicked::MODE_CONTENT => true,
Wicked::MODE_DISPLAY => true);
/**
* Renders this page in content mode.
*
* @param integer $numPages How many (at most) pages should we return?
*
* @return string The page contents.
*/
public function content($numPages = 10)
{
return $GLOBALS['wicked']->leastPopular($numPages);
}
/**
* Renders this page in display or block mode.
*
* @return string The content.
* @throws Wicked_Exception
*/
public function displayContents($isBlock)
{
global $injector, $page_output;
$pages = array();
foreach ($this->content(10) as $page) {
$page = new Wicked_Page_StandardPage($page);
$object = $page->toView();
$object->hits = $page->hits();
$pages[] = $object;
}
$page_output->addScriptFile('tables.js', 'horde');
$view = $injector->createInstance('Horde_View');
$view->hits = true;
return $view->render('pagelist/header')
. $view->renderPartial('pagelist/page', array('collection' => $pages))
. $view->render('pagelist/footer');
}
public function pageName()
{
return 'LeastPopular';
}
public function pageTitle()
{
return _("Least Popular");
}
}
wicked-2.0.4/lib/Page/LikePages.php 0000664 0000765 0000024 00000004334 12557035537 013722 0 ustar
* @author Tyler Colbert
* @package Wicked
*/
/**
* List similar pages.
*
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @author Jan Schneider
* @author Tyler Colbert
* @package Wicked
*/
class Wicked_Page_LikePages extends Wicked_Page
{
/**
* Display modes supported by this page.
*
* @var array
*/
public $supportedModes = array(
Wicked::MODE_DISPLAY => true);
/**
* The page that we're displaying similar pages to.
*
* @var string
*/
protected $_referrer = null;
public function __construct($referrer)
{
$this->_referrer = $referrer;
}
/**
* Renders this page in display or block mode.
*
* @return string The contents.
* @throws Wicked_Exception
*/
public function displayContents($isBlock)
{
global $injector, $page_output, $wicked;
$page_output->addScriptFile('tables.js', 'horde');
$view = $injector->createInstance('Horde_View');
$content = $view->render('pagelist/header');
$summaries = $wicked->getLikePages($this->referrer());
foreach ($summaries as $page) {
if (!empty($page['page_history'])) {
$page = new Wicked_Page_StandardHistoryPage($page);
} else {
$page = new Wicked_Page_StandardPage($page);
}
$content .= $view->renderPartial(
'pagelist/page',
array('object' => $page->toView())
);
}
return $content . $view->render('pagelist/footer');
}
public function pageName()
{
return 'LikePages';
}
public function pageTitle()
{
return sprintf(_("Similar Pages: %s"), $this->referrer());
}
public function referrer()
{
return $this->_referrer;
}
}
wicked-2.0.4/lib/Page/MergeOrRename.php 0000664 0000765 0000024 00000022712 12557035537 014546 0 ustar
* @author Jason M. Felice
* @package Wicked
*/
/**
* Special page for merging or renaming pages.
*
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @author Jan Schneider
* @author Jason M. Felice
* @package Wicked
*/
class Wicked_Page_MergeOrRename extends Wicked_Page
{
/**
* Display modes supported by this page.
*
* @var array
*/
public $supportedModes = array(
Wicked::MODE_EDIT => true,
Wicked::MODE_REMOVE => true,
Wicked::MODE_DISPLAY => true);
/**
* The page that we're displaying similar pages to.
*
* @var string
*/
protected $_referrer = null;
/**
* Validation errors.
*
* @var string
*/
protected $_errors = array();
public function __construct($referrer)
{
$this->_referrer = $referrer;
}
/**
* Returns if the page allows a mode. Access rights and user state
* are taken into consideration.
*
* @see $supportedModes
*
* @param integer $mode The mode to check for.
*
* @return boolean True if the mode is allowed.
*/
public function allows($mode)
{
if ($mode == Wicked::MODE_EDIT) {
if (!parent::allows(Wicked::MODE_REMOVE)) {
return false;
}
$page = Wicked_Page::getPage($this->referrer());
if ($page->isLocked(Wicked::lockUser())) {
return false;
}
}
return parent::allows($mode);
}
/**
* Retrieve this user's permissions for the referring page.
*
* @return integer The permissions bitmask.
*/
public function getPermissions()
{
return parent::getPermissions($this->referrer());
}
/**
* Renders this page in display mode.
*
* @throws Wicked_Exception
*/
public function display()
{
global $wicked, $registry, $notification;
$referrer = $this->referrer();
$callback = function($string) {
return '=' . str_pad(dechex(ord($string[1])), 2, '0', STR_PAD_LEFT);
};
$references = $wicked->getBackLinks($referrer);
foreach ($references as $key => $page) {
$references[$key]['page_url'] = Wicked::url($page['page_name']);
$references[$key]['page_name'] = $page['page_name'];
// Since the page name can have [ and ] and other special
// characters in it, and we don't want the browser or PHP decoding
// it, we encode it in quoted printable for the checkbox names.
$references[$key]['checkbox'] = preg_replace_callback(
'/([^a-zA-Z_0-9 ])/',
$callback,
$page['page_name']
);
}
// Propogate any validation errors.
foreach (array('new_name', 'collision') as $elt) {
if (!isset($this->_errors[$elt])) {
$this->_errors[$elt] = '';
}
}
$view = $GLOBALS['injector']->createInstance('Horde_View');
$view->pageName = 'MergeOrRename';
$view->formAction = Wicked::url('MergeOrRename');
$view->referrer = $referrer;
$view->referrerLink = Wicked::url($referrer);
$view->requiredMarker = Horde::img('required.png', '*');
$view->references = $references;
$view->referenceCount = sprintf(_("This page is referenced from %d other page(s)."), count($references));
$view->formInput = Horde_Util::formInput();
$view->errors = $this->_errors;
$view->new_name = Horde_Util::getFormData('new_name', $referrer);
echo $view->render('display/MergeOrRename');
}
public function pageName()
{
return 'MergeOrRename';
}
public function pageTitle()
{
return sprintf(_("Merge/Rename: %s"), $this->referrer());
}
public function referrer()
{
return $this->_referrer;
}
/**
* Retrieve the form fields and process the merge or rename.
*/
public function handleAction()
{
global $wicked, $notification, $registry;
if (Horde_Util::getFormData('submit') == _("Cancel")) {
Wicked::url($this->referrer(), true)->redirect();
}
$referrer = $this->referrer();
$new_name = Horde_Util::getFormData('new_name');
if (empty($new_name)) {
$this->_errors['new_name'] = _("This is a required field.");
} elseif ($new_name == $referrer) {
$this->_errors['new_name'] = _("New name is the same as old name.");
}
$collision = Horde_Util::getFormData('collision');
if (empty($collision)) {
$this->_errors['collision'] = _("This is a required field.");
}
if (count($this->_errors)) {
return;
}
$sourcePage = Wicked_Page::getPage($referrer);
if (!$this->allows(Wicked::MODE_EDIT)) {
throw new Wicked_Exception(sprintf(_("You do not have permission to edit \"%s\""),
$referrer));
}
$destPage = Wicked_Page::getPage($new_name);
if (!($destPage instanceof Wicked_Page_AddPage)) {
// Destination page exists.
if ($collision != 'merge') {
// We don't want to overwrite.
throw new Wicked_Exception(sprintf(_("Page \"%s\" already exists."),
$new_name));
}
if (!$destPage->allows(Wicked::MODE_EDIT)) {
throw new Wicked_Exception(sprintf(_("You do not have permission to edit \"%s\""),
$new_name));
}
// Merge the two pages.
$newText = $destPage->getText() . "\n----\n" . $sourcePage->getText();
$changelog = sprintf(_("Merged from %s"), $referrer);
$wicked->updateText($new_name, $newText, $changelog);
$wicked->removeAllVersions($referrer);
$notification->push(sprintf(_("Merged \"%s\" into \"%s\"."), $referrer, $new_name), 'horde.success');
$url = Wicked::url($new_name, true, -1);
$message = sprintf(_("Merged \"%s\" into \"%s\". New page: %s\n"), $referrer, $new_name, $url);
Wicked::mail($message, array(
'Subject' => '[' . $registry->get('name') . '] merged: ' . $referrer . ', ' . $new_name));
} else {
// Rename the page.
$wicked->renamePage($referrer, $new_name);
$notification->push(sprintf(_("Renamed \"%s\" to \"%s\"."), $referrer, $new_name), 'horde.success');
$url = Wicked::url($new_name, true, -1);
$message = sprintf(_("Renamed \"%s\" to \"%s\". New page: %s\n"), $referrer, $new_name, $url);
Wicked::mail($message, array(
'Subject' => '[' . $registry->get('name') . '] renamed: ' . $referrer . ', ' . $new_name));
}
// We don't check permissions on these pages since we want references
// to be fixed even if the user doing the editing couldn't fix that
// page, and fixing references is likely to never be a destructive
// action, and the user can't supply their own data for it.
$references = Horde_Util::getFormData('ref', array());
if ($references) {
$wikiWord = '/^' . Wicked::REGEXP_WIKIWORD . '$/';
$changelog = sprintf(_("Changed references from %s to %s"),
$referrer, $new_name);
// Links like ((Foobar|Description Text))
$from = array('/\(\(' . preg_quote($referrer, '/') . '(\|[^)]*?)\)\)/');
$to = array('((' . $new_name . '$1))');
// Links like ((Foobar))
if (preg_match($wikiWord, $new_name)) {
$replaceWith = $new_name;
} else {
$replaceWith = '((' . $new_name . '))';
}
$from[] = '/\(\(' . preg_quote($referrer, '/') . '\)\)/';
$to[] = $replaceWith;
// Links like FooBar
if (preg_match($wikiWord, $referrer)) {
$from[] = '/\b' . preg_quote($referrer, '/') . '\b/';
$to[] = $replaceWith;
}
foreach (array_keys($references) as $name) {
$page_name = quoted_printable_decode($name);
// Fix up for self-references.
if ($page_name == $referrer) {
$page_name = $new_name;
}
try {
$refPage = $wicked->retrieveByName($page_name);
} catch (Wicked_Exception $e) {
$notification->push(sprintf(_("Error retrieving %s: %s"),
$page_name, $e->getMessage()),
'horde.error');
continue;
}
$newText = preg_replace($from, $to, $refPage['page_text']);
$wicked->updateText($page_name, $newText, $changelog);
}
}
Wicked::url($new_name, true)->redirect();
}
}
wicked-2.0.4/lib/Page/MostPopular.php 0000664 0000765 0000024 00000004155 12557035537 014344 0 ustar
* @author Tyler Colbert
* @package Wicked
*/
/**
* Lists the most popular pages.
*
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @author Jan Schneider
* @author Tyler Colbert
* @package Wicked
*/
class Wicked_Page_MostPopular extends Wicked_Page
{
/**
* Display modes supported by this page.
*
* @var array
*/
public $supportedModes = array(
Wicked::MODE_CONTENT => true,
Wicked::MODE_DISPLAY => true);
/**
* Renders this page in content mode.
*
* @param integer $numPages How many (at most) pages should we return?
*
* @return string The page content.
*/
public function content($numPages = 10)
{
return $GLOBALS['wicked']->mostPopular($numPages);
}
/**
* Renders this page in display or block mode.
*
* @return string The content.
* @throws Wicked_Exception
*/
public function displayContents($isBlock)
{
global $injector, $page_output;
$pages = array();
foreach ($this->content(10) as $page) {
$page = new Wicked_Page_StandardPage($page);
$object = $page->toView();
$object->hits = $page->hits();
$pages[] = $object;
}
$page_output->addScriptFile('tables.js', 'horde');
$view = $injector->createInstance('Horde_View');
$view->hits = true;
return $view->render('pagelist/header')
. $view->renderPartial('pagelist/page', array('collection' => $pages))
. $view->render('pagelist/footer');
}
public function pageName()
{
return 'MostPopular';
}
public function pageTitle()
{
return _("Most Popular");
}
}
wicked-2.0.4/lib/Page/NewPage.php 0000664 0000765 0000024 00000010513 12557035537 013400 0 ustar
* @author Chuck Hagenbuch
* @package Wicked
*/
/**
* Adds a new page to the backend.
*
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @author Jan Schneider
* @author Chuck Hagenbuch
* @package Wicked
*/
class Wicked_Page_NewPage extends Wicked_Page
{
/**
* Display modes supported by this page.
*
* @var array
*/
public $supportedModes = array(
Wicked::MODE_DISPLAY => true,
Wicked::MODE_EDIT => true);
/**
* The page that we're creating.
*
* @var string
*/
protected $_referrer = null;
/**
* Page template to use.
*
* @var string
*/
protected $_template = null;
public function __construct($referrer)
{
$this->_referrer = $referrer;
$this->_template = Horde_Util::getFormData('template');
}
/**
* Retrieve this user's permissions for the referring page.
*
* @return integer The permissions bitmask.
*/
public function getPermissions()
{
return parent::getPermissions($this->referrer());
}
/**
* Send them back whence they came if they aren't allowed to edit
* this page.
*/
public function preDisplay()
{
if (!strlen($this->referrer())) {
$GLOBALS['notification']->push(_("Page name must not be empty"));
Wicked::url('', true)->redirect();
}
if (!$this->allows(Wicked::MODE_EDIT)) {
Wicked::url($this->referrer(), true)->redirect();
}
}
/**
* Renders this page in display mode.
*
* @throws Wicked_Exception
*/
public function display()
{
$GLOBALS['page_output']->addScriptFile('edit.js');
$view = $GLOBALS['injector']->createInstance('Horde_View');
$view->action = Wicked::url('NewPage');
$view->formInput = Horde_Util::formInput();
$view->referrer = $this->referrer();
if (!empty($GLOBALS['conf']['wicked']['captcha']) &&
!$GLOBALS['registry']->getAuth()) {
$figlet = new Text_Figlet();
Horde_Exception_Pear::catchError($figlet->loadFont(
$GLOBALS['conf']['wicked']['figlet_font']
));
$view->captcha = $figlet->lineEcho(Wicked::getCAPTCHA(true));
}
if ($this->_template) {
$view->text = Wicked_Page::getPage($this->_template)->getText();
}
return $view->render('edit/new');
}
public function pageName()
{
return 'NewPage';
}
public function pageTitle()
{
return _("New Page");
}
public function referrer()
{
return $this->_referrer;
}
public function handleAction()
{
global $notification, $wicked;
if (!$this->allows(Wicked::MODE_EDIT)) {
$notification->push(sprintf(_("You don't have permission to create \"%s\"."), $this->referrer()));
} else {
if (!empty($GLOBALS['conf']['wicked']['captcha']) &&
!$GLOBALS['registry']->getAuth() &&
(Horde_String::lower(Horde_Util::getFormData('wicked_captcha')) != Horde_String::lower(Wicked::getCAPTCHA()))) {
$notification->push(_("Random string did not match."), 'horde.error');
return;
}
$text = Horde_Util::getPost('page_text');
if (empty($text)) {
$notification->push(_("Pages cannot be empty."), 'horde.error');
return;
}
try {
$result = $wicked->newPage($this->referrer(), $text);
$notification->push(_("Page Created"), 'horde.success');
} catch (Wicked_Exception $e) {
$notification->push(sprintf(_("Create Failed: %s"),
$e->getMessage()), 'horde.error');
}
}
// Show the newly created page.
Wicked::url($this->referrer(), true)->redirect();
}
}
wicked-2.0.4/lib/Page/RecentChanges.php 0000664 0000765 0000024 00000007514 12557035537 014572 0 ustar
* @author Tyler Colbert
* @package Wicked
*/
/**
* Lists the most recently changed pages.
*
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @author Jan Schneider
* @author Tyler Colbert
* @package Wicked
*/
class Wicked_Page_RecentChanges extends Wicked_Page
{
/**
* Display modes supported by this page.
*
* @var array
*/
public $supportedModes = array(
Wicked::MODE_CONTENT => true,
Wicked::MODE_DISPLAY => true
);
/**
* Renders this page in content mode.
*
* @return string The page content.
* @throws Wicked_Exception
*/
public function content()
{
global $wicked;
$days = (int)Horde_Util::getGet('days', 3);
$summaries = $wicked->getRecentChanges($days);
if (count($summaries) < 10) {
$summaries = $wicked->mostRecent(10);
}
$bydate = array();
$changes = array();
foreach ($summaries as $page) {
$page = new Wicked_Page_StandardPage($page);
$createDate = $page->versionCreated();
$tm = localtime($createDate, true);
$createDate = mktime(0, 0, 0, $tm['tm_mon'], $tm['tm_mday'],
$tm['tm_year'], $tm['tm_isdst']);
$version_url = $page->pageUrl()->add('version', $page->version());
$diff_url = Horde::url('diff.php')->add(array(
'page' => $page->pageName(),
'v1' => '?',
'v2' => $page->version()
));
$diff_alt = sprintf(_("Show changes for %s"), $page->version());
$diff_img = Horde::img('diff.png', $diff_alt);
$pageInfo = array('author' => $page->author(),
'name' => $page->pageName(),
'url' => $page->pageUrl(),
'version' => $page->version(),
'version_url' => $version_url,
'version_alt' => sprintf(_("Show version %s"),
$page->version()),
'diff_url' => $diff_url,
'diff_alt' => $diff_alt,
'diff_img' => $diff_img,
'created' => $page->formatVersionCreated(),
'change_log' => $page->changeLog());
$bydate[$createDate][$page->versionCreated()][$page->version()] = $pageInfo;
}
krsort($bydate);
foreach ($bydate as $bysecond) {
$day = array();
krsort($bysecond);
foreach ($bysecond as $pageList) {
krsort($pageList);
$day = array_merge($day, array_values($pageList));
}
$changes[] = array('date' => $day[0]['created'],
'pages' => $day);
}
return $changes;
}
/**
* Renders this page in display or block mode.
*
* @return string The contents.
* @throws Wicked_Exception
*/
public function displayContents($isBlock)
{
$view = $GLOBALS['injector']->createInstance('Horde_View');
$view->changes = $this->content();
return $view->render('display/RecentChanges');
}
public function pageName()
{
return 'RecentChanges';
}
public function pageTitle()
{
return _("Recent Changes");
}
}
wicked-2.0.4/lib/Page/RevertPage.php 0000664 0000765 0000024 00000010054 12557035537 014116 0 ustar
* @author Chuck Hagenbuch
* @package Wicked
*/
/**
* Displays and handles forms for confirming reversions of page history.
*
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @author Jan Schneider
* @author Chuck Hagenbuch
* @package Wicked
*/
class Wicked_Page_RevertPage extends Wicked_Page
{
/**
* Display modes supported by this page.
*
* @var array
*/
public $supportedModes = array(Wicked::MODE_DISPLAY => true);
/**
* The page that we're confirming reversion for.
*
* @var string
*/
protected $_referrer = null;
public function __construct($referrer)
{
$this->_referrer = $referrer;
}
/**
* Retrieve this user's permissions for the referring page.
*
* @return integer The permissions bitmask.
*/
public function getPermissions()
{
return parent::getPermissions($this->referrer());
}
/**
* Send them back whence they came if they aren't allowed to
* edit this page.
*/
public function preDisplay()
{
$page = Wicked_Page::getPage($this->referrer());
if (!$page->allows(Wicked::MODE_EDIT)) {
Wicked::url($this->referrer(), true)->redirect();
}
}
/**
* Renders this page in display mode.
*
* @throws Wicked_Exception
*/
public function display()
{
$version = Horde_Util::getFormData('version');
$page = Wicked_Page::getPage($this->referrer(), $version);
$msg = sprintf(_("Are you sure you want to revert to version %s of this page?"), $version);
?>
_referrer;
}
public function handleAction()
{
global $notification;
$page = Wicked_Page::getPage($this->referrer());
if ($page->allows(Wicked::MODE_EDIT)) {
$version = Horde_Util::getPost('version');
if (empty($version)) {
$notification->push(sprintf(_("Can't revert to an unknown version.")), 'horde.error');
Wicked::url($this->referrer(), true)->redirect();
}
$oldpage = Wicked_Page::getPage($this->referrer(), $version);
$page->updateText($oldpage->getText(), 'Revert');
$notification->push(sprintf(_("Reverted to version %s of \"%s\"."), $version, $page->pageName()));
Wicked::url($page->pageName(), true)->redirect();
}
$notification->push(sprintf(_("You don't have permission to edit \"%s\"."), $page->pageName()), 'horde.warning');
Wicked::url($this->referrer(), true)->redirect();
}
}
wicked-2.0.4/lib/Page/Search.php 0000664 0000765 0000024 00000014527 12557035537 013270 0 ustar
* @author Ben Chavet
* @package Wicked
*/
/**
* Displays and handles search forms and results.
*
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @author Jan Schneider
* @author Ben Chavet
* @package Wicked
*/
class Wicked_Page_Search extends Wicked_Page
{
/**
* Display modes supported by this page.
* @var array
*/
public $supportedModes = array(
Wicked::MODE_CONTENT => true,
Wicked::MODE_DISPLAY => true
);
/**
* Cached search results.
*
* @var array
*/
protected $_results = array();
/**
* Renders this page in content mode.
*
* @param string $searchtext The title to search for.
*
* @return string The page content.
*/
public function content($searchtext = '')
{
if (empty($searchtext)) {
return array();
}
return array(
'titles' => $GLOBALS['wicked']->searchTitles($searchtext),
'pages' => $GLOBALS['wicked']->searchText($searchtext, false)
);
}
/**
* Perform any pre-display checks for permissions, searches,
* etc. Called before any output is sent so the page can do
* redirects. If the page wants to take control of flow from here,
* it can, and is entirely responsible for handling the user
* (should call exit after redirecting, for example).
*
* $param integer $mode The page render mode.
* $param array $params Any page parameters.
*/
public function preDisplay($mode, $params)
{
$this->_results = $this->content($params);
}
/**
* Renders this page in display mode.
*
* @param string $searchtext The title to search for.
*
* @return string The content.
* @throws Wicked_Exception
*/
public function display($searchtext)
{
global $injector, $notification, $page_output, $wicked;
$view = $injector->createInstance('Horde_View');
if (!$searchtext) {
return $view->render('pagelist/search')
. $view->render('pagelist/footer');
}
/* Prepare exact match section */
$exact = array();
$page = new Wicked_Page_StandardPage($searchtext);
if ($wicked->pageExists($searchtext)) {
$exact[] = $page->toView();
} else {
$exact[] = (object)array(
'author' => '',
'context' => Wicked::url($searchtext, false)
->link(array(
'title' => sprintf(_("Create %s"), $searchtext)
))
. sprintf(_("%s does not exist. You can create it now."), '' . htmlspecialchars($searchtext) . '')
. '',
'date' => '',
'name' => htmlspecialchars($searchtext),
'timestamp' => 0,
'version' => '',
'url' => Wicked::url($searchtext, false)
);
}
/* Prepare page title matches */
$titles = array();
foreach ($this->_results['titles'] as $page) {
if (!empty($page['page_history'])) {
$page = new Wicked_Page_StandardHistoryPage($page);
} else {
$page = new Wicked_Page_StandardPage($page);
}
$titles[] = $page->toView();
}
/* Prepare page text matches */
$pages = array();
foreach ($this->_results['pages'] as $page) {
if (!empty($page['page_history'])) {
$page = new Wicked_Page_StandardHistoryPage($page);
} else {
$page = new Wicked_Page_StandardPage($page);
}
$object = $page->toView();
$object->context = $this->getContext($page, $searchtext);
$pages[] = $object;
}
$page_output->addScriptFile('tables.js', 'horde');
$header = $injector->createInstance('Horde_View');
$header->th_page = _("Page");
$header->th_version = _("Current Version");
$header->th_author = _("Last Author");
$header->th_updated = _("Last Update");
$view = $injector->createInstance('Horde_View');
// Show search form and page header.
$content = $view->render('pagelist/search');
// Show exact match.
$header->title = _("Exact Match");
$content .= $header->render('pagelist/results_header')
. $view->renderPartial(
'pagelist/page',
array('collection' => $exact)
)
. $view->render('pagelist/results_footer');
// Show page title matches.
$header->title = _("Page Title Matches");
$content .= $header->render('pagelist/results_header')
. $view->renderPartial(
'pagelist/page',
array('collection' => $titles)
)
. $view->render('pagelist/results_footer');
// Show page text matches.
$header->title = _("Page Text Matches");
$content .= $header->render('pagelist/results_header')
. $view->renderPartial(
'pagelist/page',
array('collection' => $pages)
)
. $view->render('pagelist/results_footer');
return $content;
}
public function getContext($page, $searchtext)
{
try {
$text = html_entity_decode(strip_tags($page->displayContents(true)), ENT_QUOTES | ENT_XHTML, 'UTF-8');
} catch (Wicked_Exception $e) {
$text = $page->getText();
}
if (preg_match('/.{0,100}' . preg_quote($searchtext, '/') . '.{0,100}/i', $text, $context)) {
return trim(preg_replace('/' . preg_quote($searchtext, '/') . '/i', '\0', htmlspecialchars($context[0])));
}
return '';
}
public function pageName()
{
return 'Search';
}
public function pageTitle()
{
return _("Search");
}
}
wicked-2.0.4/lib/Page/StandardHistoryPage.php 0000664 0000765 0000024 00000004061 12557035537 015772 0 ustar
* @author Tyler Colbert
* @package Wicked
*/
/**
* Page class for old versions of pages.
*
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @author Jan Schneider
* @author Tyler Colbert
* @package Wicked
*/
class Wicked_Page_StandardHistoryPage extends Wicked_Page_StandardPage
{
/**
* Display modes supported by this page.
*
* @var array
*/
public $supportedModes = array(
Wicked::MODE_DISPLAY => true,
Wicked::MODE_EDIT => false,
Wicked::MODE_REMOVE => true,
Wicked::MODE_HISTORY => true,
Wicked::MODE_DIFF => true,
Wicked::MODE_LOCKING => false,
Wicked::MODE_UNLOCKING => false);
/**
* Construct a standard history page class to represent an old
* version of a wiki page.
*
* @param string $pagename The name of the page to load.
* @param integer $version The version of the page to load.
*
* @throws Wicked_Exception
*/
public function __construct($pagename, $version = null)
{
if (empty($version)) {
parent::__construct($pagename);
return;
}
// Retrieve the version.
$pages = $GLOBALS['wicked']->retrieveHistory($pagename, $version);
// If it didnt find one, return an error.
if (empty($pages[0])) {
throw new Wicked_Exception(_("History page not found"));
}
$this->_page = $pages[0];
}
public function isOld()
{
return true;
}
public function pageUrl($linkpage = null, $actionId = null)
{
return parent::pageUrl($linkpage, $actionId)->add('version', $this->version());
}
}
wicked-2.0.4/lib/Page/StandardPage.php 0000664 0000765 0000024 00000050513 12557035537 014413 0 ustar
* @author Tyler Colbert
* @package Wicked
*/
/**
* Page class for regular pages.
*
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @author Jan Schneider
* @author Tyler Colbert
* @package Wicked
*/
class Wicked_Page_StandardPage extends Wicked_Page
{
/**
* Display modes supported by this page.
*
* @var array
*/
public $supportedModes = array(
Wicked::MODE_DISPLAY => true,
Wicked::MODE_EDIT => true,
Wicked::MODE_REMOVE => true,
Wicked::MODE_HISTORY => true,
Wicked::MODE_DIFF => true);
/**
* A Horde_Locks instance for un-/locking this page.
*
* @var Horde_Lock
*/
protected $_locks = null;
/**
* Lock information if this page is currently locked.
*
* @var array
*/
protected $_lock = null;
/**
* Constructs a standard page class to represent a wiki page.
*
* @param string $pagename The name of the page to represent.
*/
public function __construct($pagename)
{
if (is_array($pagename)) {
$this->_page = $pagename;
return;
}
$page = null;
try {
$page = $GLOBALS['wicked']->retrieveByName($pagename);
} catch (Wicked_Exception $e) {
// If we can't load $pagename, see if there's default data for it.
// Protect against directory traversion.
$pagepath = realpath(WICKED_BASE . '/data/'
. $GLOBALS['conf']['wicked']['format']);
$pagefile = realpath($pagepath . '/' . $pagename);
if ($pagefile &&
Horde_String::common($pagefile, $pagepath) == $pagepath &&
substr($pagename, 0, 1) != '.' &&
file_exists($pagefile) &&
($text = file_get_contents($pagefile))) {
try {
$GLOBALS['wicked']->newPage($pagename, $text);
try {
$page = $GLOBALS['wicked']->retrieveByName($pagename);
} catch (Wicked_Exception $e) {
$GLOBALS['notification']->push(sprintf(_("Unable to create %s"), $pagename), 'horde.error');
}
} catch (Wicked_Exception $e) {}
}
}
if ($page) {
$this->_page = $page;
} else {
if ($pagename == 'Wiki/Home') {
$GLOBALS['notification']->push(_("Unable to create Wiki/Home. The wiki is not configured."), 'horde.error');
}
$this->_page = array();
}
// Make sure 'wicked' permission exists. Set reasonable defaults if
// necessary.
$perms = $GLOBALS['injector']->getInstance('Horde_Perms');
$corePerms = $GLOBALS['injector']->getInstance('Horde_Core_Perms');
if (!$perms->exists('wicked')) {
$perm = $corePerms->newPermission('wicked');
$perm->addGuestPermission(Horde_Perms::SHOW | Horde_Perms::READ, false);
$perm->addDefaultPermission(Horde_Perms::SHOW | Horde_Perms::READ | Horde_Perms::EDIT | Horde_Perms::DELETE, false);
$perms->addPermission($perm);
}
// Make sure 'wicked:pages' exists. Copy from 'wicked' if it does not
// exist.
if (!$perms->exists('wicked:pages')) {
$perm = $corePerms->newPermission('wicked:pages');
$copyFrom = $perms->getPermission('wicked');
$perm->addGuestPermission($copyFrom->getGuestPermissions(), false);
$perm->addDefaultPermission($copyFrom->getDefaultPermissions(), false);
$perm->addCreatorPermission($copyFrom->getCreatorPermissions(), false);
foreach ($copyFrom->getUserPermissions() as $user => $uperm) {
$perm->addUserPermission($user, $uperm, false);
}
foreach ($copyFrom->getGroupPermissions() as $group => $gperm) {
$perm->addGroupPermission($group, $gperm, false);
}
$perms->addPermission($perm);
}
if ($GLOBALS['conf']['lock']['driver'] != 'none') {
$this->supportedModes[Wicked::MODE_LOCKING] = $this->supportedModes[Wicked::MODE_UNLOCKING] = true;
$this->_locks = $GLOBALS['injector']->getInstance('Horde_Lock');
$locks = $this->_locks->getLocks('wicked', $pagename, Horde_Lock::TYPE_EXCLUSIVE);
if ($locks) {
$this->_lock = reset($locks);
}
}
}
/**
* Returns if the page allows a mode. Access rights and user state
* are taken into consideration.
*
* @see $supportedModes
*
* @param integer $mode The mode to check for.
*
* @return boolean True if the mode is allowed.
*/
public function allows($mode)
{
switch ($mode) {
case Wicked::MODE_EDIT:
if ($this->isLocked()) {
return Wicked::lockUser() == $this->_lock['lock_owner'];
}
break;
case Wicked::MODE_LOCKING:
if ($GLOBALS['browser']->isRobot()) {
return false;
}
if ($GLOBALS['registry']->isAdmin()) {
return true;
}
if (($this->getPermissions() & Horde_Perms::EDIT) == 0) {
return false;
}
break;
case Wicked::MODE_UNLOCKING:
if ($GLOBALS['registry']->isAdmin()) {
return true;
}
if ($this->_lock) {
return Wicked::lockUser() == $this->_lock['lock_owner'];
}
return false;
}
return parent::allows($mode);
}
/**
* @throws Wicked_Exception
*/
public function displayContents($isBlock)
{
$view = $GLOBALS['injector']->createInstance('Horde_View');
$view->text = $this->getProcessor()->transform($this->getText());
if ($isBlock) {
return $view->render('display/standard');
}
$view->showTools = true;
if ($this->allows(Wicked::MODE_EDIT) &&
!$this->isLocked(Wicked::lockUser())) {
$view->edit = Horde::widget(array(
'url' => Wicked::url('EditPage')
->add('referrer', $this->pageName()),
'title' => _("_Edit"),
'class' => 'wicked-edit',
));
}
if ($this->isLocked()) {
if ($this->allows(Wicked::MODE_UNLOCKING)) {
$view->unlock = Horde::widget(array(
'url' => $this->pageUrl(null, 'unlock')->remove('version'),
'title' => _("Un_lock"),
'class' => 'wicked-unlock',
));
}
} else {
if ($this->allows(Wicked::MODE_LOCKING)) {
$view->lock = Horde::widget(array(
'url' => $this->pageUrl(null, 'lock')->remove('version'),
'title' => _("_Lock"),
'class' => 'wicked-lock',
));
}
}
if ($this->allows(Wicked::MODE_REMOVE)) {
$params = array('referrer' => $this->pageName());
if ($this->isOld()) {
$params['version'] = $this->version();
}
$view->remove = Horde::widget(array(
'url' => Wicked::url('DeletePage')->add($params),
'title' => _("_Delete"),
'class' => 'wicked-delete',
));
}
if ($this->allows(Wicked::MODE_REMOVE) &&
!$this->isLocked(Wicked::lockUser())) {
$view->rename = Horde::widget(array(
'url' => Wicked::url('MergeOrRename')
->add('referrer', $this->pageName()),
'title' => _("_Merge/Rename")
));
}
$view->backLinks = Horde::widget(array(
'url' => Wicked::url('BackLinks')
->add('referrer', $this->pageName()),
'title' => _("_Backlinks")
));
$view->likePages = Horde::widget(array(
'url' => Wicked::url('LikePages')
->add('referrer', $this->pageName()),
'title' => _("S_imilar Pages")
));
$view->attachedFiles = Horde::widget(array(
'url' => Wicked::url('AttachedFiles')
->add('referrer', $this->pageName()),
'title' => _("Attachments")
));
if ($this->allows(Wicked::MODE_HISTORY)) {
$view->changes = Horde::widget(array(
'url' => $this->pageUrl('history.php')->remove('version'),
'title' => _("Hi_story")
));
}
if ($GLOBALS['registry']->isAdmin()) {
$permsurl = Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/admin/perms/edit.php')
->add(array(
'category' => 'wicked:pages:' . $this->pageId(),
'autocreate' => 1,
'autocreate_copy' => 'wicked',
'autocreate_guest' => Horde_Perms::SHOW | Horde_Perms::READ,
'autocreate_default' => Horde_Perms::SHOW | Horde_Perms::READ | Horde_Perms::EDIT | Horde_Perms::DELETE
));
$view->perms = Horde::widget(array(
'url' => $permsurl,
'target' => '_blank',
'title' => _("Permissio_ns")
));
}
if ($histories = $GLOBALS['session']->get('wicked', 'history')) {
$view->history = Horde::widget(array(
'url' => '#',
'onclick' => 'document.location = document.display.history[document.display.history.selectedIndex].value;',
'title' => _("Ba_ck to")
));
$view->histories = array();
foreach ($histories as $history) {
if (!strlen($history)) {
continue;
}
$view->histories[(string)Wicked::url($history)] = $history;
}
}
$pageId = $GLOBALS['wicked']->getPageId($this->pageName());
$attachments = $GLOBALS['wicked']->getAttachedFiles($pageId);
if (count($attachments)) {
$view->attachments = array();
foreach ($attachments as $attachment) {
$url = $GLOBALS['registry']
->downloadUrl(
$attachment['attachment_name'],
array(
'page' => $this->pageName(),
'file' => $attachment['attachment_name'],
'version' => $attachment['attachment_version']
)
);
$icon = $GLOBALS['injector']
->getInstance('Horde_Core_Factory_MimeViewer')
->getIcon(
Horde_Mime_Magic::filenameToMime(
$attachment['attachment_name']
)
);
$view->attachments[] = Horde::link($url)
. '
'
. htmlspecialchars($attachment['attachment_name'])
. '';
}
}
$view->downloadPlain = Wicked::url($this->pageName())
->add(array('actionID' => 'export', 'format' => 'plain'))
->link()
. _("Plain Text") . '';
$view->downloadHtml = Wicked::url($this->pageName())
->add(array('actionID' => 'export', 'format' => 'html'))
->link()
. _("HTML") . '';
$view->downloadLatex = Wicked::url($this->pageName())
->add(array('actionID' => 'export', 'format' => 'tex'))
->link()
. _("Latex") . '';
$view->downloadRest = Wicked::url($this->pageName())
->add(array('actionID' => 'export', 'format' => 'rst'))
->link()
. _("reStructuredText") . '';
return $view->render('display/standard');
}
/**
* Renders this page in History mode.
*
* @return string The content.
* @throws Wicked_Exception
*/
public function history()
{
global $injector, $page_output;
$page_output->addScriptFile('history.js');
$view = $injector->createInstance('Horde_View');
// Header.
$view->formInput = Horde_Util::formInput();
$view->name = $this->pageName();
$view->pageLink = $this->pageUrl()->link()
. htmlspecialchars($this->pageName()) . '';
$view->refreshLink = $this->pageUrl('history.php')->link()
. Horde::img('reload.png', _("Reload History")) . '';
if ($this->allows(Wicked::MODE_REMOVE)) {
$view->remove = Horde::img('delete.png', _("Delete Version"));
}
if ($this->allows(Wicked::MODE_EDIT) &&
!$this->isLocked(Wicked::lockUser())) {
$view->edit = Horde::img('edit.png', _("Edit Version"));
$view->restore = Horde::img('restore.png', _("Restore Version"));
}
$content = $view->render('history/header');
// First item is this page.
$view->showRestore = false;
$this->_setViewProperties($view, $this);
$content .= $view->render('history/summary');
// Now the rest of the histories.
$view->showRestore = true;
foreach ($GLOBALS['wicked']->getHistory($this->pageName()) as $page) {
$page = new Wicked_Page_StandardHistoryPage($page);
$this->_setViewProperties($view, $page);
$view->pversion = $page->version();
$content .= $view->render('history/summary');
}
// Footer.
return $content . $view->render('history/footer');
}
protected function _setViewProperties($view, $page)
{
$view->displayLink = $page->pageUrl()
->link(array(
'title' => sprintf(_("Display Version %s"), $page->version())
))
. htmlspecialchars($page->version()) . '';
$text = sprintf(_("Delete Version %s"), $page->version());
$view->deleteLink = Wicked::url('DeletePage')
->add(array(
'referrer' => $page->pageName(),
'version' => $page->version()
))
->link(array('title' => $text))
. Horde::img('delete.png', $text) . '';
$text = sprintf(_("Edit Version %s"), $page->version());
$view->editLink = Wicked::url('EditPage')
->add(array('referrer' => $page->pageName()))
->link(array('title' => $text))
. Horde::img('edit.png', $text) . '';
$text = sprintf(_("Revert to version %s"), $page->version());
$view->restoreLink = Wicked::url('RevertPage')
->add(array(
'referrer' => $page->pageName(),
'version' => $page->version()
))
->link(array('title' => $text))
. Horde::img('restore.png', $text) . '';
$view->author = $page->author();
$view->date = $page->formatVersionCreated();
$view->version = $page->version();
$view->changelog = $page->changeLog();
}
public function isLocked($owner = null)
{
if (empty($this->_lock)) {
return false;
}
if (is_null($owner)) {
return true;
}
return $owner != $this->_lock['lock_owner'];
}
/**
* @throws Wicked_Exception
*/
public function lock()
{
if ($this->_locks) {
$id = $this->_locks->setLock(Wicked::lockUser(), 'wicked', $this->pageName(), $GLOBALS['conf']['wicked']['lock']['time'] * 60, Horde_Lock::TYPE_EXCLUSIVE);
if ($id) {
$this->_lock = $this->_locks->getLockInfo($id);
} else {
throw new Wicked_Exception(_("The page is already locked."));
}
}
}
public function unlock()
{
if ($this->_locks && $this->_lock) {
$this->_locks->clearLock($this->_lock['lock_id']);
unset($this->_lock);
}
}
public function getLockRequestor()
{
$requestor = $this->_lock['lock_owner'];
if ($requestor) {
$name = $GLOBALS['injector']
->getInstance('Horde_Core_Factory_Identity')
->create($requestor)
->getValue('fullname');
if (!strlen($name)) {
$name = $requestor;
}
return $name;
}
return _("a guest");
}
public function getLockTime()
{
$time = ceil(($this->_lock['lock_expiry_timestamp'] - time()) / 60);
return sprintf(ngettext("%d minute", "%d minutes", $time), $time);
}
/**
* @throws Wicked_Exception
*/
public function updateText($newtext, $changelog)
{
$version = $this->version();
$result = $GLOBALS['wicked']->updateText($this->pageName(), $newtext,
$changelog);
$url = Wicked::url($this->pageName(), true, -1);
$new_page = $this->getPage($this->pageName());
$message = "Modified page: $url\n"
. 'New Revision: ' . $new_page->version() . "\n"
. ($changelog ? 'Change log: ' . $changelog . "\n" : '')
. "\n"
. $new_page->getDiff($version);
Wicked::mail($message,
array('Subject' => '[' . $GLOBALS['registry']->get('name')
. '] changed: ' . $this->pageName()));
$this->_page['page_text'] = $newtext;
}
public function pageID()
{
return isset($this->_page['page_id']) ? $this->_page['page_id'] : '';
}
public function pageName()
{
return isset($this->_page['page_name'])
? $this->_page['page_name']
: '';
}
public function getText()
{
return isset($this->_page['page_text'])
? $this->_page['page_text']
: '';
}
public function versionCreated()
{
return isset($this->_page['version_created'])
? $this->_page['version_created']
: '';
}
public function hits()
{
return !empty($this->_page['page_hits'])
? $this->_page['page_hits']
: 0;
}
public function changeLog()
{
return $this->_page['change_log'];
}
public function version()
{
if (isset($this->_page['page_version'])) {
return $this->_page['page_version'];
} else {
return '';
}
}
/**
* Renders this page in diff mode.
*
* @param string $version The version to diff this page against.
*/
public function diff($version)
{
$view = $GLOBALS['injector']->createInstance('Horde_View');
$view->link = $this->pageUrl()->link()
. htmlspecialchars($this->pageName())
. '';
$view->version1 = $version;
$view->version2 = $this->version();
$view->diff = $this->getDiff($version, 'inline');
echo $view->render('diff/diff');
}
/**
* Produces a diff for this page.
*
* @param string $version Previous version, or null if diffing with
* `before the beginning' (empty).
* @param string $renderer The diff renderer.
*/
public function getDiff($version, $renderer = 'unified')
{
if (is_null($version)) {
$old_page_text = '';
} else {
$old_page = $this->getPage($this->pageName(), $version);
$old_page_text = $old_page->getText();
}
$diff = new Horde_Text_Diff('auto',
array(explode("\n", $old_page_text),
explode("\n", $this->getText())));
$class = 'Horde_Text_Diff_Renderer_' . Horde_String::ucfirst($renderer);
$renderer = new $class();
return $renderer->render($diff);
}
}
wicked-2.0.4/lib/Text_Wiki/Parse/BBCode/Attribute.php 0000664 0000765 0000024 00000002752 12557035537 017206 0 ustar regex = '/((?:\[\[' . Wicked::REGEXP_WIKIWORD .
':\s+.*?\]\]\s*)+)/';
}
/**
* Generates a token entry for the matched text. Token options are:
*
* 'src' => The image source, typically a relative path name.
* 'opts' => Any macro options following the source.
*
* @param array &$matches The array of matches from parse().
*
* @return A delimited token number to be used as a placeholder in
* the source text.
*/
public function process(&$matches)
{
$options = array('attributes' => array());
$text = $matches[1];
while (preg_match('/^\[\[(' . Wicked::REGEXP_WIKIWORD . '):\s+(.*?)\]\]\s*(.*)$/s',
$text, $sub)) {
$options['attributes'][] = array('name' => $sub[1],
'value' => $sub[2]);
$text = $sub[3];
}
return $this->wiki->addToken($this->rule, $options);
}
}
wicked-2.0.4/lib/Text_Wiki/Parse/BBCode/Code2.php 0000664 0000765 0000024 00000000317 12557035537 016172 0 ustar The application to link to.
* 'args' => The parameters passed to the app/show method.
*
* @access public
*
* @param array &$matches The array of matches from parse().
*
* @return A delimited token number to be used as a placeholder in
* the source text.
*/
public function process(&$matches)
{
@list($title, $call) = explode('|', $matches[1], 2);
$opts = explode(' ', trim($call));
$method = trim(array_shift($opts));
parse_str(implode('&', $opts), $args);
return $this->wiki->addToken($this->rule, array('title' => trim($title),
'method' => $method,
'args' => $args));
}
}
wicked-2.0.4/lib/Text_Wiki/Parse/BBCode/Wickedblock.php 0000664 0000765 0000024 00000002361 12557035537 017460 0 ustar The image source, typically a relative path name.
* 'opts' => Any macro options following the source.
*
* @access public
*
* @param array &$matches The array of matches from parse().
*
* @return A delimited token number to be used as a placeholder in
* the source text.
*/
public function process(&$matches)
{
$args = array();
foreach (explode(' ', $matches[3], 2) as $pair) {
@list($arg, $value) = explode('=', $pair);
$args[$arg] = $value;
}
return $this->wiki->addToken(
$this->rule,
array('app' => $matches[1],
'block' => $matches[2],
'args' => $args));
}
}
wicked-2.0.4/lib/Text_Wiki/Parse/Cowiki/Attribute.php 0000664 0000765 0000024 00000002752 12557035537 017355 0 ustar regex = '/((?:\[\[' . Wicked::REGEXP_WIKIWORD .
':\s+.*?\]\]\s*)+)/';
}
/**
* Generates a token entry for the matched text. Token options are:
*
* 'src' => The image source, typically a relative path name.
* 'opts' => Any macro options following the source.
*
* @param array &$matches The array of matches from parse().
*
* @return A delimited token number to be used as a placeholder in
* the source text.
*/
public function process(&$matches)
{
$options = array('attributes' => array());
$text = $matches[1];
while (preg_match('/^\[\[(' . Wicked::REGEXP_WIKIWORD . '):\s+(.*?)\]\]\s*(.*)$/s',
$text, $sub)) {
$options['attributes'][] = array('name' => $sub[1],
'value' => $sub[2]);
$text = $sub[3];
}
return $this->wiki->addToken($this->rule, $options);
}
}
wicked-2.0.4/lib/Text_Wiki/Parse/Cowiki/Code2.php 0000664 0000765 0000024 00000000317 12557035537 016341 0 ustar The application to link to.
* 'args' => The parameters passed to the app/show method.
*
* @access public
*
* @param array &$matches The array of matches from parse().
*
* @return A delimited token number to be used as a placeholder in
* the source text.
*/
public function process(&$matches)
{
@list($title, $call) = explode('|', $matches[1], 2);
$opts = explode(' ', trim($call));
$method = trim(array_shift($opts));
parse_str(implode('&', $opts), $args);
return $this->wiki->addToken($this->rule, array('title' => trim($title),
'method' => $method,
'args' => $args));
}
}
wicked-2.0.4/lib/Text_Wiki/Parse/Cowiki/Wickedblock.php 0000664 0000765 0000024 00000002361 12557035537 017627 0 ustar The image source, typically a relative path name.
* 'opts' => Any macro options following the source.
*
* @access public
*
* @param array &$matches The array of matches from parse().
*
* @return A delimited token number to be used as a placeholder in
* the source text.
*/
public function process(&$matches)
{
$args = array();
foreach (explode(' ', $matches[3], 2) as $pair) {
@list($arg, $value) = explode('=', $pair);
$args[$arg] = $value;
}
return $this->wiki->addToken(
$this->rule,
array('app' => $matches[1],
'block' => $matches[2],
'args' => $args));
}
}
wicked-2.0.4/lib/Text_Wiki/Parse/Cowiki/Wikilink2.php 0000664 0000765 0000024 00000000337 12557035537 017252 0 ustar regex = '/((?:\[\[' . Wicked::REGEXP_WIKIWORD .
':\s+.*?\]\]\s*)+)/';
}
/**
* Generates a token entry for the matched text. Token options are:
*
* 'src' => The image source, typically a relative path name.
* 'opts' => Any macro options following the source.
*
* @param array &$matches The array of matches from parse().
*
* @return A delimited token number to be used as a placeholder in
* the source text.
*/
public function process(&$matches)
{
$options = array('attributes' => array());
$text = $matches[1];
while (preg_match('/^\[\[(' . Wicked::REGEXP_WIKIWORD . '):\s+(.*?)\]\]\s*(.*)$/s',
$text, $sub)) {
$options['attributes'][] = array('name' => $sub[1],
'value' => $sub[2]);
$text = $sub[3];
}
return $this->wiki->addToken($this->rule, $options);
}
}
wicked-2.0.4/lib/Text_Wiki/Parse/Creole/Heading2.php 0000664 0000765 0000024 00000000326 12557035537 017012 0 ustar The application to link to.
* 'args' => The parameters passed to the app/show method.
*
* @access public
*
* @param array &$matches The array of matches from parse().
*
* @return A delimited token number to be used as a placeholder in
* the source text.
*/
public function process(&$matches)
{
@list($title, $call) = explode('|', $matches[1], 2);
$opts = explode(' ', trim($call));
$method = trim(array_shift($opts));
parse_str(implode('&', $opts), $args);
return $this->wiki->addToken($this->rule, array('title' => trim($title),
'method' => $method,
'args' => $args));
}
}
wicked-2.0.4/lib/Text_Wiki/Parse/Creole/Wickedblock.php 0000664 0000765 0000024 00000002361 12557035537 017613 0 ustar The image source, typically a relative path name.
* 'opts' => Any macro options following the source.
*
* @access public
*
* @param array &$matches The array of matches from parse().
*
* @return A delimited token number to be used as a placeholder in
* the source text.
*/
public function process(&$matches)
{
$args = array();
foreach (explode(' ', $matches[3], 2) as $pair) {
@list($arg, $value) = explode('=', $pair);
$args[$arg] = $value;
}
return $this->wiki->addToken(
$this->rule,
array('app' => $matches[1],
'block' => $matches[2],
'args' => $args));
}
}
wicked-2.0.4/lib/Text_Wiki/Parse/Creole/Wikilink2.php 0000664 0000765 0000024 00000000337 12557035537 017236 0 ustar regex = '/((?:\[\[' . Wicked::REGEXP_WIKIWORD .
':\s+.*?\]\]\s*)+)/';
}
/**
* Generates a token entry for the matched text. Token options are:
*
* 'src' => The image source, typically a relative path name.
* 'opts' => Any macro options following the source.
*
* @param array &$matches The array of matches from parse().
*
* @return A delimited token number to be used as a placeholder in
* the source text.
*/
public function process(&$matches)
{
$options = array('attributes' => array());
$text = $matches[1];
while (preg_match('/^\[\[(' . Wicked::REGEXP_WIKIWORD . '):\s+(.*?)\]\]\s*(.*)$/s',
$text, $sub)) {
$options['attributes'][] = array('name' => $sub[1],
'value' => $sub[2]);
$text = $sub[3];
}
return $this->wiki->addToken($this->rule, $options);
}
}
wicked-2.0.4/lib/Text_Wiki/Parse/Default/Code2.php 0000664 0000765 0000024 00000000422 12557035537 016475 0 ustar ]*)?>(.*?)\n(\s|$);msi';
}
wicked-2.0.4/lib/Text_Wiki/Parse/Default/Freelink2.php 0000664 0000765 0000024 00000000340 12557035537 017361 0 ustar The application to link to.
* 'args' => The parameters passed to the app/show method.
*
* @access public
*
* @param array &$matches The array of matches from parse().
*
* @return A delimited token number to be used as a placeholder in
* the source text.
*/
public function process(&$matches)
{
@list($title, $call) = explode('|', $matches[1], 2);
$opts = explode(' ', trim($call));
$method = trim(array_shift($opts));
parse_str(implode('&', $opts), $args);
return $this->wiki->addToken($this->rule, array('title' => trim($title),
'method' => $method,
'args' => $args));
}
}
wicked-2.0.4/lib/Text_Wiki/Parse/Default/Toc2.php 0000664 0000765 0000024 00000003761 12557035537 016361 0 ustar ['list_start'|'list_end'|'item_start'|'item_end'|'target']
*
* 'level' => The heading level (1-6).
*
* 'count' => Which entry number this is in the list.
*
* @access public
*
* @param array &$matches The array of matches from parse().
*
* @return string A token indicating the TOC collection point.
*
*/
public function process(&$matches)
{
$count = 0;
if (isset($matches[1])) {
$attr = $this->getAttrs(trim($matches[1]));
} else {
$attr = array();
}
$output = $this->wiki->addToken(
$this->rule,
array(
'type' => 'list_start',
'level' => 0,
'attr' => $attr
)
);
foreach ($this->wiki->getTokens('Heading2') as $key => $val) {
if ($val[1]['type'] != 'start') {
continue;
}
$options = array(
'type' => 'item_start',
'id' => $val[1]['id'],
'level' => $val[1]['level'],
'count' => $count ++
);
$output .= $this->wiki->addToken($this->rule, $options);
$output .= $val[1]['text'];
$output .= $this->wiki->addToken(
$this->rule,
array(
'type' => 'item_end',
'level' => $val[1]['level']
)
);
}
$output .= $this->wiki->addToken(
$this->rule, array(
'type' => 'list_end',
'level' => 0
)
);
return "\n$output\n";
}
}
wicked-2.0.4/lib/Text_Wiki/Parse/Default/Wickedblock.php 0000664 0000765 0000024 00000002361 12557035537 017766 0 ustar The image source, typically a relative path name.
* 'opts' => Any macro options following the source.
*
* @access public
*
* @param array &$matches The array of matches from parse().
*
* @return A delimited token number to be used as a placeholder in
* the source text.
*/
public function process(&$matches)
{
$args = array();
foreach (explode(' ', $matches[3], 2) as $pair) {
@list($arg, $value) = explode('=', $pair);
$args[$arg] = $value;
}
return $this->wiki->addToken(
$this->rule,
array('app' => $matches[1],
'block' => $matches[2],
'args' => $args));
}
}
wicked-2.0.4/lib/Text_Wiki/Parse/Default/Wikilink2.php 0000664 0000765 0000024 00000000340 12557035537 017403 0 ustar regex = '/((?:\[\[' . Wicked::REGEXP_WIKIWORD .
':\s+.*?\]\]\s*)+)/';
}
/**
* Generates a token entry for the matched text. Token options are:
*
* 'src' => The image source, typically a relative path name.
* 'opts' => Any macro options following the source.
*
* @param array &$matches The array of matches from parse().
*
* @return A delimited token number to be used as a placeholder in
* the source text.
*/
public function process(&$matches)
{
$options = array('attributes' => array());
$text = $matches[1];
while (preg_match('/^\[\[(' . Wicked::REGEXP_WIKIWORD . '):\s+(.*?)\]\]\s*(.*)$/s',
$text, $sub)) {
$options['attributes'][] = array('name' => $sub[1],
'value' => $sub[2]);
$text = $sub[3];
}
return $this->wiki->addToken($this->rule, $options);
}
}
wicked-2.0.4/lib/Text_Wiki/Parse/Mediawiki/Code2.php 0000664 0000765 0000024 00000000322 12557035537 017013 0 ustar The application to link to.
* 'args' => The parameters passed to the app/show method.
*
* @access public
*
* @param array &$matches The array of matches from parse().
*
* @return A delimited token number to be used as a placeholder in
* the source text.
*/
public function process(&$matches)
{
@list($title, $call) = explode('|', $matches[1], 2);
$opts = explode(' ', trim($call));
$method = trim(array_shift($opts));
parse_str(implode('&', $opts), $args);
return $this->wiki->addToken($this->rule, array('title' => trim($title),
'method' => $method,
'args' => $args));
}
}
wicked-2.0.4/lib/Text_Wiki/Parse/Mediawiki/Wickedblock.php 0000664 0000765 0000024 00000002361 12557035537 020305 0 ustar The image source, typically a relative path name.
* 'opts' => Any macro options following the source.
*
* @access public
*
* @param array &$matches The array of matches from parse().
*
* @return A delimited token number to be used as a placeholder in
* the source text.
*/
public function process(&$matches)
{
$args = array();
foreach (explode(' ', $matches[3], 2) as $pair) {
@list($arg, $value) = explode('=', $pair);
$args[$arg] = $value;
}
return $this->wiki->addToken(
$this->rule,
array('app' => $matches[1],
'block' => $matches[2],
'args' => $args));
}
}
wicked-2.0.4/lib/Text_Wiki/Parse/Mediawiki/Wikilink2.php 0000664 0000765 0000024 00000004236 12557035537 017732 0 ustar the name of the image file
* - 'attr' => an array of attributes for the image:
* | - 'alt' => the optional alternate image text
* | - 'align' => 'left', 'center' or 'right'
* | - 'width' => 'NNNpx'
* | - 'height' => 'NNNpx'
*
* @access public
* @param array &$matches The array of matches from parse().
* @return string token to be used as replacement
*/
public function image($name, $text, $interlang, $colon)
{
$attr = array('alt' => '');
$splits = explode('|', $text);
$sep = '';
foreach ($splits as $split) {
switch (strtolower($split)) {
case 'left': case 'center': case 'right':
$attr['align'] = strtolower($split);
break;
default:
// this regex is imho not restrictive enough but should
// keep false positives to a minimum
if (preg_match('/\dpx\s*$/i', $split)) {
$split = preg_replace("/\s/", "", $split);
$split = preg_replace("/px$/i", "", $split);
list($width,$height) = explode("x", $split);
$attr['width'] = $width;
if ($height) {
$attr['height'] = $height;
}
}
else {
$attr['alt'] .= $sep . $split;
$sep = '|';
}
}
}
$options = array(
'src' => ($interlang ? $interlang . ':' : '') . $name,
'attr' => $attr);
// create and return the replacement token
return $this->wiki->addToken('Image2', $options);
}
}
wicked-2.0.4/lib/Text_Wiki/Parse/Tiki/Attribute.php 0000664 0000765 0000024 00000002752 12557035537 017030 0 ustar regex = '/((?:\[\[' . Wicked::REGEXP_WIKIWORD .
':\s+.*?\]\]\s*)+)/';
}
/**
* Generates a token entry for the matched text. Token options are:
*
* 'src' => The image source, typically a relative path name.
* 'opts' => Any macro options following the source.
*
* @param array &$matches The array of matches from parse().
*
* @return A delimited token number to be used as a placeholder in
* the source text.
*/
public function process(&$matches)
{
$options = array('attributes' => array());
$text = $matches[1];
while (preg_match('/^\[\[(' . Wicked::REGEXP_WIKIWORD . '):\s+(.*?)\]\]\s*(.*)$/s',
$text, $sub)) {
$options['attributes'][] = array('name' => $sub[1],
'value' => $sub[2]);
$text = $sub[3];
}
return $this->wiki->addToken($this->rule, $options);
}
}
wicked-2.0.4/lib/Text_Wiki/Parse/Tiki/Code2.php 0000664 0000765 0000024 00000000315 12557035537 016012 0 ustar The application to link to.
* 'args' => The parameters passed to the app/show method.
*
* @access public
*
* @param array &$matches The array of matches from parse().
*
* @return A delimited token number to be used as a placeholder in
* the source text.
*/
public function process(&$matches)
{
@list($title, $call) = explode('|', $matches[1], 2);
$opts = explode(' ', trim($call));
$method = trim(array_shift($opts));
parse_str(implode('&', $opts), $args);
return $this->wiki->addToken($this->rule, array('title' => trim($title),
'method' => $method,
'args' => $args));
}
}
wicked-2.0.4/lib/Text_Wiki/Parse/Tiki/Wickedblock.php 0000664 0000765 0000024 00000002361 12557035537 017302 0 ustar The image source, typically a relative path name.
* 'opts' => Any macro options following the source.
*
* @access public
*
* @param array &$matches The array of matches from parse().
*
* @return A delimited token number to be used as a placeholder in
* the source text.
*/
public function process(&$matches)
{
$args = array();
foreach (explode(' ', $matches[3], 2) as $pair) {
@list($arg, $value) = explode('=', $pair);
$args[$arg] = $value;
}
return $this->wiki->addToken(
$this->rule,
array('app' => $matches[1],
'block' => $matches[2],
'args' => $args));
}
}
wicked-2.0.4/lib/Text_Wiki/Parse/Tiki/Wikilink2.php 0000664 0000765 0000024 00000000335 12557035537 016723 0 ustar
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
/**
* Renders quoted text for a Wiki page.
*
* @category Horde
* @package Wicked
* @author Jan Schneider
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
class Text_Wiki_Render_Rst_Blockquote extends Text_Wiki_Render
{
/**
* Renders a token into text matching the requested format.
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*/
public function token($options)
{
// starting
if ($options['type'] == 'start') {
$this->wiki->registerRenderCallback(array($this, 'renderInsideText'));
$this->_level = $options['level'];
return '';
}
// ending
if ($options['type'] == 'end') {
$this->wiki->popRenderCallback();
return "\n";
}
}
public function renderInsideText($text)
{
return preg_replace('/(^|\n)(>*) */',
'\1' . str_repeat(' ', $this->_level * 2). '\2',
trim($text))
. "\n";
}
}
wicked-2.0.4/lib/Text_Wiki/Render/Rst/Bold.php 0000664 0000765 0000024 00000002375 12557035537 015763 0 ustar
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
/**
* Renders bold text for a Wiki page.
*
* @category Horde
* @package Wicked
* @author Gunnar Wrobel
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
class Text_Wiki_Render_Rst_Bold extends Text_Wiki_Render
{
/**
* Renders a token into text matching the requested format.
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*/
public function token($options)
{
if ($options['type'] == 'start') {
return '**';
}
if ($options['type'] == 'end') {
return '**';
}
}
}
wicked-2.0.4/lib/Text_Wiki/Render/Rst/Code.php 0000664 0000765 0000024 00000002271 12557035537 015750 0 ustar
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
/**
* Renders code segments for a Wiki page.
*
* @category Horde
* @package Wicked
* @author Gunnar Wrobel
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
class Text_Wiki_Render_Rst_Code extends Text_Wiki_Render
{
/**
* Renders a token into text matching the requested format.
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*/
public function token($options)
{
return "::\n" . join("\n ", explode("\n", $options['text'])) . "\n\n";
}
}
wicked-2.0.4/lib/Text_Wiki/Render/Rst/Deflist.php 0000664 0000765 0000024 00000004752 12557035537 016476 0 ustar
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
/**
* Renders a definition list for a Wiki page.
*
* @category Horde
* @package Wicked
* @author Gunnar Wrobel
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
class Text_Wiki_Render_Rst_Deflist extends Text_Wiki_Render
{
/**
* Renders a token into text matching the requested format.
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*/
public function token($options)
{
$type = $options['type'];
switch ($type) {
case 'list_start':
$this->wiki->registerRenderCallback(array($this, 'deflist'));
return '';
case 'list_end':
$this->wiki->popRenderCallback();
return Text_Wiki_Render_Rst_Links::append();
case 'term_end':
case 'narr_end':
return $this->wiki->delim;
case 'term_start':
case 'narr_start':
default:
return '';
}
}
public function deflist($block)
{
$elements = explode($this->wiki->delim, $block);
$term = false;
$list = array();
foreach ($elements as $element) {
if ($term === false) {
$term = $element;
} else {
$list[$term] = $element;
$term = false;
}
}
$term_length = max(array_map('strlen', array_keys($list)));
$result = '';
foreach ($list as $term => $info) {
$lead = Horde_String::pad($term . ': ', $term_length + 2);
$definition = Horde_String::wordwrap(
$lead . $info,
max(80, $term_length + 30),
"\n" . str_repeat(' ', $term_length + 3)
);
$result .= ':' . $definition . "\n";
}
$result .= "\n";
return $result;
}
}
wicked-2.0.4/lib/Text_Wiki/Render/Rst/Emphasis.php 0000664 0000765 0000024 00000002356 12557035537 016653 0 ustar
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
/**
* Renders emphasized text for a Wiki page.
*
* @category Horde
* @package Wicked
* @author Jan Schneider
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
class Text_Wiki_Render_Rst_Emphasis extends Text_Wiki_Render
{
/**
* Renders a token into text matching the requested format.
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*/
public function token($options)
{
if ($options['type'] == 'start') {
return '*';
}
if ($options['type'] == 'end') {
return '*';
}
}
}
wicked-2.0.4/lib/Text_Wiki/Render/Rst/Freelink.php 0000664 0000765 0000024 00000002647 12557035537 016644 0 ustar
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
/**
* Renders a wiki page free link for a Wiki page.
*
* @category Horde
* @package Wicked
* @author Gunnar Wrobel
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
class Text_Wiki_Render_Rst_Freelink extends Text_Wiki_Render
{
/**
* A collector for link sections below a paragraph.
*
* @var array
*/
static public $paragraph_links = array();
/**
* Renders a token into text matching the requested format.
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*/
public function token($options)
{
extract($options);
self::$paragraph_links[] = '.. _`' . $text . '`: ' . $page;
return '`' . $text . '`_';
}
}
wicked-2.0.4/lib/Text_Wiki/Render/Rst/Heading2.php 0000664 0000765 0000024 00000005446 12557035537 016526 0 ustar
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
/**
* Renders Wiki page headers to restructured text.
*
* @category Horde
* @package Wicked
* @author Gunnar Wrobel
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
class Text_Wiki_Render_Rst_Heading2 extends Text_Wiki_Render
{
/**
* The start options.
*
* @var array
*/
private $_previous;
/**
* Render the header.
*
* @param array $options The rendering options.
*
* @return string The output string.
*/
public function token($options)
{
// get nice variable names (type, level)
extract($options);
if ($type == 'start') {
$length = strlen($text);
switch ($level) {
case '1':
$overline = '=';
$underline = '=';
$length += 2;
break;
case '2':
$overline = '-';
$underline = '-';
$length += 2;
break;
case '3':
$overline = null;
$underline = '=';
break;
case '4':
$overline = null;
$underline = '*';
break;
case '5':
$overline = null;
$underline = '-';
break;
case '6':
$overline = null;
$underline = '`';
break;
}
$output = '';
if ($overline !== null) {
$output .= str_repeat($overline, $length) . "\n ";
}
$previous = $options;
$previous['length'] = $length;
$previous['underline'] = $underline;
$this->_previous[] = $previous;
return $output;
}
if ($type == 'end') {
$previous = array_pop($this->_previous);
if ($level != $previous['level']) {
return sprintf(
'UNEXPECTED HEADER LEVEL: %s [expected %s]',
$level,
$previous['level']
);
}
return "\n" . str_repeat($previous['underline'], $previous['length']) . "\n\n";
}
}
}
wicked-2.0.4/lib/Text_Wiki/Render/Rst/Horiz.php 0000664 0000765 0000024 00000002131 12557035537 016164 0 ustar
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
/**
* Renders a horizontal line for a Wiki page.
*
* @category Horde
* @package Wicked
* @author Jan Schneider
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
class Text_Wiki_Render_Rst_Horiz extends Text_Wiki_Render
{
/**
* Renders a token into text matching the requested format.
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*/
public function token($options)
{
return "----\n\n";
}
}
wicked-2.0.4/lib/Text_Wiki/Render/Rst/Links.php 0000664 0000765 0000024 00000002526 12557035537 016161 0 ustar
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
/**
* Renders collected links for a Wiki page.
*
* @category Horde
* @package Wicked
* @author Gunnar Wrobel
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
class Text_Wiki_Render_Rst_Links
{
static public function append()
{
$result = '';
$links = array_merge(
Text_Wiki_Render_Rst_Url::$paragraph_links,
Text_Wiki_Render_Rst_Freelink::$paragraph_links
);
if (!empty($links)) {
$result .= "\n";
foreach ($links as $link) {
$result .= "\n" . $link ;
}
Text_Wiki_Render_Rst_Url::$paragraph_links = array();
Text_Wiki_Render_Rst_Freelink::$paragraph_links = array();
}
return $result;
}
}
wicked-2.0.4/lib/Text_Wiki/Render/Rst/List.php 0000664 0000765 0000024 00000003423 12557035537 016011 0 ustar
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
/**
* Renders a list for a Wiki page.
*
* @category Horde
* @package Wicked
* @author Gunnar Wrobel
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
class Text_Wiki_Render_Rst_List
{
/**
* Render the list.
*
* @param array $options The rendering options.
*
* @return string The output string.
*/
public function token($options)
{
// make nice variables (type, level, count)
extract($options);
switch ($type) {
case 'bullet_list_start':
case 'number_list_start':
return '';
case 'bullet_list_end':
case 'number_list_end':
return "\n";
case 'bullet_item_start':
return str_repeat(' ', ($level - 1) * 2) . '* ';
case 'number_item_start':
return str_repeat(' ', ($level - 1) * 2) . ($count + 1) . '. ';
case 'bullet_item_end':
case 'number_item_end':
return "\n";
default:
// ignore item endings and all other types.
// item endings are taken care of by the other types
// depending on their place in the list.
return '';
break;
}
}
}
wicked-2.0.4/lib/Text_Wiki/Render/Rst/Newline.php 0000664 0000765 0000024 00000002220 12557035537 016471 0 ustar
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
/**
* Renders a newline for a Wiki page.
*
* @category Horde
* @package Wicked
* @author Gunnar Wrobel
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
class Text_Wiki_Render_Rst_Newline extends Text_Wiki_Render
{
/**
* Renders a token into text matching the requested format.
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*/
public function token($options)
{
return "\n";
}
}
wicked-2.0.4/lib/Text_Wiki/Render/Rst/Paragraph.php 0000664 0000765 0000024 00000002576 12557035537 017013 0 ustar
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
/**
* Renders Wiki page paragraphs to restructured text.
*
* @category Horde
* @package Wicked
* @author Gunnar Wrobel
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
class Text_Wiki_Render_Rst_Paragraph extends Text_Wiki_Render
{
/**
* Renders a token into text matching the requested format.
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*/
public function token($options)
{
extract($options);
if ($type == 'start') {
return '';
}
if ($type == 'end') {
$result = Text_Wiki_Render_Rst_Links::append();
return $result . "\n\n";
}
}
}
wicked-2.0.4/lib/Text_Wiki/Render/Rst/Raw.php 0000664 0000765 0000024 00000002254 12557035537 015630 0 ustar
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
/**
* Renders literal text for a Wiki page.
*
* @category Horde
* @package Wicked
* @author Gunnar Wrobel
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
class Text_Wiki_Render_Rst_Raw extends Text_Wiki_Render
{
/**
* Renders a token into text matching the requested format.
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*/
public function token($options)
{
return '``' . $options['text'] . '``';
}
}
wicked-2.0.4/lib/Text_Wiki/Render/Rst/Toc2.php 0000664 0000765 0000024 00000003057 12557035537 015710 0 ustar
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
/**
* Renders a table of contents for a Wiki page.
*
* @category Horde
* @package Wicked
* @author Gunnar Wrobel
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
class Text_Wiki_Render_Rst_Toc2 extends Text_Wiki_Render
{
/**
* Renders a token into text matching the requested format.
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*/
public function token($options)
{
if($options['type'] == 'list_start') {
return ".. contents:: Contents\n.. section-numbering::";
}
if($options['type'] == 'item_start') {
$this->wiki->registerRenderCallback(array($this, 'purge'));
}
if($options['type'] == 'item_end') {
$this->wiki->popRenderCallback();
}
return '';
}
public function purge($block)
{
return '';
}
}
wicked-2.0.4/lib/Text_Wiki/Render/Rst/Tt.php 0000664 0000765 0000024 00000002223 12557035537 015462 0 ustar
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
/**
* Renders teletype text for a Wiki page.
*
* @category Horde
* @package Wicked
* @author Gunnar Wrobel
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
class Text_Wiki_Render_Rst_Tt extends Text_Wiki_Render
{
/**
* Renders a token into text matching the requested format.
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*/
public function token($options)
{
return '``';
}
}
wicked-2.0.4/lib/Text_Wiki/Render/Rst/Url.php 0000664 0000765 0000024 00000002771 12557035537 015645 0 ustar
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
/**
* Renders a URL for a Wiki page.
*
* @category Horde
* @package Wicked
* @author Gunnar Wrobel
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
class Text_Wiki_Render_Rst_Url extends Text_Wiki_Render
{
/**
* A collector for link sections below a paragraph.
*
* @var array
*/
static public $paragraph_links = array();
/**
* Renders a token into text matching the requested format.
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*/
public function token($options)
{
extract($options);
if ($type == 'inline') {
return $text;
}
if ($type == 'descr') {
self::$paragraph_links[] = '.. _`' . $text . '`: ' . $href;
return '`' . $text . '`_';
}
}
}
wicked-2.0.4/lib/Text_Wiki/Render/Xhtml/Attribute.php 0000664 0000765 0000024 00000003645 12557035537 017373 0 ustar ';
foreach ($options['attributes'] as $attribute) {
$link = array('page' => $attribute['name'],
'anchor' => '',
'text' => $attribute['name']);
// We should do full wiki formatting, I guess, but there isn't
// a convenient way to do it.
if (preg_match('/^(' . Wicked::REGEXP_WIKIWORD . ')$/',
$attribute['value'], $matches)) {
$vlink = array('page' => $matches[1],
'anchor' => '',
'text' => $matches[1]);
$value = $this->wiki->renderObj['Wikilink']->token($vlink);
} elseif (preg_match('/^\(\((.*)\)\)$/', $attribute['value'],
$matches)) {
$vlink = array('page' => $matches[1],
'anchor' => '',
'text' => $matches[1]);
$value = $this->wiki->renderObj['Wikilink']->token($vlink);
} else {
$value = htmlspecialchars($attribute['value']);
}
$output .= '' .
$this->wiki->renderObj['Wikilink']->token($link) .
' : | ' . $value .
' |
';
}
$output .= '';
return $output;
}
}
wicked-2.0.4/lib/Text_Wiki/Render/Xhtml/Code2.php 0000664 0000765 0000024 00000001517 12557035537 016360 0 ustar setContents($options['text']);
$part->setType('application/x-extension-' . $options['attr']['type']);
$viewer = Horde_Mime_Viewer::factory(
'Horde_Core_Mime_Viewer_Syntaxhighlighter',
$part,
array('registry' => $GLOBALS['registry']));
$data = $viewer->render('inline');
$data = reset($data);
return $data['data'];
}
}
wicked-2.0.4/lib/Text_Wiki/Render/Xhtml/Freelink2.php 0000664 0000765 0000024 00000000204 12557035537 017235 0 ustar '',
'url_base' => null,
'css' => null,
'css_link' => null
);
/**
* Renders a token into text matching the requested format.
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*/
public function token($options)
{
if (!isset($options['attr']['alt'])) {
$options['attr']['alt'] = $options['src'];
}
if (strpos($options['src'], '://') === false) {
if ($options['src'][0] != '/') {
if (strpos($options['src'], ':')) {
list($page, $options['src']) = explode(':', $options['src'], 2);
} else {
$page = Horde_Util::getFormData('page');
if ($page == 'EditPage') {
$page = Horde_Util::getFormData('referrer');
}
if (empty($page)) {
$page = 'Wiki/Home';
}
}
$params = array('page' => $page,
'mime' => '1',
'file' => $options['src']);
$options['src'] = $GLOBALS['registry']
->downloadUrl($options['src'], $params)
->setRaw(true);
}
} else {
$options['src'] = new Horde_Url(Horde::externalUrl($options['src']));
$options['src']->setRaw(true);
}
// Send external links through Horde::externalUrl().
if (isset($options['attr']['link']) &&
strpos($options['attr']['link'], '://')) {
$href = htmlspecialchars($options['attr']['link']);
unset($options['attr']['link']);
return Horde::link(Horde::externalUrl($href), $href) . $this->_token($options) . '';
} else {
return $this->_token($options);
}
}
/**
* Render code from Text_Wiki's Image with Horde tweaks (remove
* getimagesize call, etc).
*
* @access private
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*/
protected function _token($options)
{
// note the image source
$src = $options['src'];
// is the source a local file or URL?
if (strpos($src, '://') === false) {
// the source refers to a local file.
// add the URL base to it.
$src = $this->getConf('base', '/') . $src;
}
// stephane@metacites.net
// is the image clickable?
if (isset($options['attr']['link'])) {
// yes, the image is clickable.
// are we linked to a URL or a wiki page?
if (strpos($options['attr']['link'], '://')) {
// it's a URL, prefix the URL base
$href = $this->getConf('url_base') . $options['attr']['link'];
} else {
// it's a WikiPage; assume it exists.
/** @todo This needs to honor sprintf wikilinks (pmjones) */
/** @todo This needs to honor interwiki (pmjones) */
/** @todo This needs to honor freelinks (pmjones) */
$href = $this->wiki->getRenderConf('xhtml', 'wikilink', 'view_url') .
$options['attr']['link'];
}
} else {
// image is not clickable.
$href = null;
}
// unset so it won't show up as an attribute
unset($options['attr']['link']);
// start the HTML output
$output = '
formatConf(' class="%s"', 'css');
// add the attributes to the output, and be sure to
// track whether or not we find an "alt" attribute
$alt = false;
foreach ($options['attr'] as $key => $val) {
// track the 'alt' attribute
if (strtolower($key) == 'alt') {
$alt = true;
}
// the 'class' attribute overrides the CSS class conf
if (strtolower($key) == 'class') {
$css = null;
}
$key = htmlspecialchars($key);
$val = htmlspecialchars($val);
$output .= " $key=\"$val\"";
}
// always add an "alt" attribute per Stephane Solliec
if (!$alt) {
$alt = htmlspecialchars(basename($options['src']));
$output .= " alt=\"$alt\"";
}
// end the image tag with the automatic CSS class (if any)
$output .= "$css />";
// was the image clickable?
if ($href) {
// yes, add the href and return
$href = htmlspecialchars($href);
$css = $this->formatConf(' class="%s"', 'css_link');
$output = "$output";
}
return $output;
}
}
wicked-2.0.4/lib/Text_Wiki/Render/Xhtml/Interwiki.php 0000664 0000765 0000024 00000003133 12557035537 017365 0 ustar array(
'MeatBall' => 'http://www.usemod.com/cgi-bin/mb.pl?%s',
'Advogato' => 'http://advogato.org/%s',
'Wiki' => 'http://c2.com/cgi/wiki?%s',
'Bookshelved' => 'http://bookshelved.org/cgi-bin/wiki.pl?%s'
),
'target' => '_blank'
);
/**
* Renders a token into text matching the requested format.
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*/
public function token($options)
{
$site = $options['site'];
$page = $options['page'];
$text = $options['text'];
if (isset($this->conf['sites'][$site])) {
$href = $this->conf['sites'][$site];
} else {
return $text;
}
// old form where page is at end,
// or new form with %s placeholder for sprintf()?
if (strpos($href, '%s') === false) {
// use the old form
$href = $href . $page;
} else {
// use the new form
$href = sprintf($href, $page);
}
// allow for alternative targets
$target = $this->getConf('target', '');
if ($target && trim($target) != '') {
$target = " target=\"$target\"";
}
return '' . $text . '';
}
}
wicked-2.0.4/lib/Text_Wiki/Render/Xhtml/Registrylink.php 0000664 0000765 0000024 00000001340 12557035537 020104 0 ustar link($options['method'], $options['args']));
} catch (Horde_Exception $e) {
return $e->getMessage();
}
return $link->link() . $options['title'] . '';
}
}
wicked-2.0.4/lib/Text_Wiki/Render/Xhtml/Toc2.php 0000664 0000765 0000024 00000004770 12557035537 016237 0 ustar null,
'css_item' => null,
'title' => 'Table of Contents',
'div_id' => 'toc',
);
protected $_last_level = null;
/**
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*/
public function token($options)
{
// type, id, level, count, attr.
extract($options);
switch ($type) {
case 'list_start':
$GLOBALS['page_output']->addScriptFile('toc.js', 'wicked');
// Add the div, class, and id.
$html = 'getConf('css_list');
if ($css) {
$html .= " class=\"$css\"";
}
$div_id = $this->getConf('div_id');
if ($div_id) {
$html .= " id=\"$div_id\"";
}
// Add the title, and done.
return $html . '>' . $this->getConf('title') . '
';
case 'list_end':
$html = '';
while ($this->_last_level > 1) {
$html .= '
';
--$this->_last_level;
}
return $html . "\n
\n\n";
case 'item_start':
$html = '';
if ($this->_last_level !== null) {
if ($level > $this->_last_level) {
while ($level > $this->_last_level) {
$html .= '';
++$this->_last_level;
}
$html .= '- _last_level) {
while ($level < $this->_last_level) {
$html .= '
';
--$this->_last_level;
}
$html .= '_last_level = $level;
$css = $this->getConf('css_item');
if ($css) {
$html .= " class=\"$css\"";
}
return $html . ">";
case 'item_end':
return '';
}
}
}
wicked-2.0.4/lib/Text_Wiki/Render/Xhtml/Url.php 0000664 0000765 0000024 00000002466 12557035537 016172 0 ustar '_blank'
);
/**
* Renders a token into text matching the requested format.
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*/
public function token($options)
{
// Create local variables from the options array (text, href,
// type).
extract($options);
// Find the rightmost dot and determine the filename
// extension.
$pos = strrpos($href, '.');
$ext = Horde_String::lower(substr($href, $pos + 1));
$href = htmlspecialchars($href);
// Allow for alternative targets on non-anchor HREFs.
if ($href[0] == '#') {
$target = '';
} else {
$target = $this->getConf('target', '');
}
$output = Horde::link(Horde::externalUrl($href), $href, 'external', htmlspecialchars($target)) . htmlspecialchars($text) . '';
// Make numbered references look like footnotes.
if ($type == 'footnote') {
$output = '' . $output . '';
}
return $output;
}
}
wicked-2.0.4/lib/Text_Wiki/Render/Xhtml/Wickedblock.php 0000664 0000765 0000024 00000001603 12557035537 017641 0 ustar getInstance('Horde_Core_Factory_BlockCollection')
->create()
->getBlock($options['app'],
$options['app'] . '_Block_' . $options['block'],
$options['args'])
->getContent();
} catch (Horde_Exception $e) {
return $e->getMessage();
}
}
}
wicked-2.0.4/lib/Text_Wiki/Render/Xhtml/Wikilink2.php 0000664 0000765 0000024 00000007340 12557035537 017267 0 ustar conf['exists_callback'])) {
$callback =& $this->conf['exists_callback'];
} else {
$callback = false;
}
if ($callback) {
// use the callback function
$exists = call_user_func($callback, $page);
} else {
// no callback, go to the naive page array.
$list = $this->getConf('pages');
if (is_array($list)) {
// yes, check against the page list
$exists = in_array($page, $list);
} else {
// no, assume it exists
$exists = true;
}
}
$anchor = $this->urlEncode(substr($anchor, 1));
if (strlen($anchor)) {
$anchor = '#' . $anchor;
}
// Does the page exist?
if ($exists) {
$href = sprintf(preg_replace('/%(?!s)/', '%%', $this->getConf('view_url')), $GLOBALS['conf']['urls']['pretty'] == 'rewrite' ? htmlspecialchars($page) : $this->urlEncode($page)) . $anchor;
// get the CSS class and generate output
$css = ' class="'.$this->textEncode($this->getConf('css')).'"';
$start = '';
$end = '';
} else {
$new_url = $this->getConf('new_url');
if (!$new_url) {
return $this->textEncode($text);
}
$href = sprintf(preg_replace('/%(?!s)/', '%%', $new_url), $GLOBALS['conf']['urls']['pretty'] == 'rewrite' ? htmlspecialchars($page) : $this->urlEncode($page));
// get the appropriate CSS class and new-link text
$css = ' class="'.$this->textEncode($this->getConf('css_new')).'"';
$new = $this->getConf('new_text');
// what kind of linking are we doing?
$pos = $this->getConf('new_text_pos');
if (! $pos || ! $new) {
// no position (or no new_text), use css only on the page name
$start = '';
$end = '';
} elseif ($pos == 'before') {
// use the new_text BEFORE the page name
$start = ''.$this->textEncode($new).'';
$end = '';
} else {
// default, use the new_text link AFTER the page name
$start = '';
$end = ''.$this->textEncode($new).'';
}
}
if (!strlen($text)) {
$start .= $this->textEncode($page);
}
if (isset($type)) {
switch ($type) {
case 'start':
$output = $start;
break;
case 'end':
$output = $end;
break;
}
} else {
$output = $start.$this->textEncode($text).$end;
}
return $output;
}
}
wicked-2.0.4/lib/Text_Wiki/Render/Rst.php 0000664 0000765 0000024 00000001661 12557035537 015100 0 ustar
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
/**
* Renders Wiki pages to restructured text
* (http://docutils.sourceforge.net/rst.html).
*
* @category Horde
* @package Wicked
* @author Gunnar Wrobel
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
class Text_Wiki_Render_Rst extends Text_Wiki_Render
{
public function pre()
{
return;
}
public function post()
{
return;
}
}
wicked-2.0.4/lib/Api.php 0000664 0000765 0000024 00000020761 12557035537 011715 0 ustar '%application%/display.php?page=|page|&version=|version|#|toc|'
);
/**
* Returns a list of available pages.
*
* @param boolean $special Include special pages
* @param boolean $no_cache Always retreive pages from backed
*
* @return array An array of all available pages.
*/
public function listPages($special = true, $no_cache = false)
{
return $GLOBALS['wicked']->getPages($special, $no_cache);
}
/**
* Return basic page information.
*
* @param string $pagename Page name
*
* @return array An array of page parameters.
* @throws Wicked_Exception
*/
public function getPageInfo($pagename)
{
$page = Wicked_Page::getPage($pagename);
return array(
'page_version' => $page->version(),
'page_checksum' => md5($page->getText()),
'version_created' => $page->versionCreated(),
'change_author' => $page->author(),
'change_log' => $page->changeLog(),
);
}
/**
* Return basic information for multiple pages.
*
* @param array $pagenames Page names
*
* @return array An array of arrays of page parameters.
* @throws Wicked_Exception
*/
public function getMultiplePageInfo($pagenames = array())
{
if (empty($pagenames)) {
$pagenames = $GLOBALS['wicked']->getPages(false);
}
$info = array();
foreach ($pagenames as $pagename) {
$page = Wicked_Page::getPage($pagename);
$info[$pagename] = array(
'page_version' => $page->version(),
'page_checksum' => md5($page->getText()),
'version_created' => $page->versionCreated(),
'change_author' => $page->author(),
'change_log' => $page->changeLog()
);
}
return $info;
}
/**
* Return page history.
*
* @param string $pagename Page name
*
* @return array An array of page parameters.
* @throws Wicked_Exception
*/
public function getPageHistory($pagename)
{
$page = Wicked_Page::getPage($pagename);
$summaries = $GLOBALS['wicked']->getHistory($pagename);
foreach ($summaries as $i => $summary) {
$summaries[$i]['page_checksum'] = md5($summary['page_text']);
unset($summaries[$i]['page_text']);
}
return $summaries;
}
/**
* Chech if a page exists
*
* @param string $pagename Page name
*
* @return boolean
*/
public function pageExists($pagename)
{
return $GLOBALS['wicked']->pageExists($pagename);
}
/**
* Returns a rendered wiki page.
*
* @param string $pagename Page to display
*
* @return array Page without CSS link
* @throws Wicked_Exception
*/
public function display($pagename)
{
$page = Wicked_Page::getPage($pagename);
$GLOBALS['wicked']->logPageView($page->pageName());
return $page->displayContents(false);
}
/**
* Returns a rendered wiki page.
*
* @param string $pagename Page to display
* @param string $format Format to render page to (Plain, XHtml)
*
* @return array Rendered page
* @throws Wicked_Exception
*/
public function renderPage($pagename, $format = 'Plain')
{
$page = Wicked_Page::getPage($pagename);
$content = $page->getProcessor()->transform($page->getText(), $format);
$GLOBALS['wicked']->logPageView($page->pageName());
return $content;
}
/**
* Updates content of a wiki page. If the page does not exist it is
* created.
*
* @param string $pagename Page to edit
* @param string $text Page content
* @param string $changelog Description of the change
*
* @throws Wicked_Exception
*/
public function edit($pagename, $text, $changelog = '')
{
$page = Wicked_Page::getPage($pagename);
if (!$page->allows(Wicked::MODE_EDIT)) {
throw new Wicked_Exception(sprintf(_("You don't have permission to edit \"%s\"."), $pagename));
}
if ($GLOBALS['conf']['wicked']['require_change_log'] &&
empty($changelog)) {
throw new Wicked_Exception(_("You must provide a change log."));
}
try {
$content = $page->getText();
} catch (Wicked_Exception $e) {
// Maybe the page does not exists, if not create it
if ($GLOBALS['wicked']->pageExists($pagename)) {
throw $e;
}
$GLOBALS['wicked']->newPage($pagename, $text);
}
if (trim($text) == trim($content)) {
throw new Wicked_Exception(_("No changes made"));
}
$page->updateText($text, $changelog);
}
/**
* Get a list of templates provided by Wicked. A template is any page
* whose name begins with "Template"
*
* @return arrary Array on success.
* @throws Wicked_Exception
*/
public function listTemplates()
{
global $wicked;
$templates = $wicked->getMatchingPages('Template', Wicked_Page::MATCH_ENDS);
$list = array(array('category' => _("Wiki Templates"),
'templates' => array()));
foreach ($templates as $page) {
$list[0]['templates'][] = array('id' => $page['page_name'],
'name' => $page['page_name']);
}
return $list;
}
/**
* Get a template specified by its name. This is effectively an alias for
* getPageSource() since Wicked templates are also normal pages.
* Wicked templates are pages that include "Template" at the beginning of
* the name.
*
* @param string $name The name of the template to fetch
*
* @return string Template data.
* @throws Wicked_Exception
*/
public function getTemplate($name)
{
return $this->getPageSource($name);
}
/**
* Get the wiki source of a page specified by its name.
*
* @param string $name The name of the page to fetch
* @param string $version Page version
*
* @return string Page data.
* @throws Wicked_Exception
*/
public function getPageSource($pagename, $version = null)
{
global $wicked;
$page = Wicked_Page::getPage($pagename, $version);
if (!$page->allows(Wicked::MODE_CONTENT)) {
throw new Wicked_Exception(_("Permission denied."));
}
if (!$page->isValid()) {
throw new Wicked_Exception(_("Invalid page requested."));
}
return $page->getText();
}
/**
* Process a completed template to update the named Wiki page. This
* method is basically a passthrough to edit().
*
* @param string $name Name of the new or modified page
* @param string $data Text content of the populated template
*
* @throws Wicked_Exception
*/
public function saveTemplate($name, $data)
{
$this->edit($name, $data, 'Template Auto-fill', false);
}
/**
* Returns the most recently changed pages.
*
* @param integer $days The number of days to look back.
*
* @return array Pages.
* @throws Wicked_Exception
*/
public function getRecentChanges($days = 3)
{
$info = array();
foreach ($GLOBALS['wicked']->getRecentChanges($days) as $page) {
$info[$page['page_name']] = array(
'page_version' => $page['page_version'],
'page_checksum' => md5($page['page_text']),
'version_created' => $page['version_created'],
'change_author' => $page['change_author'],
'change_log' => $page['change_log'],
);
}
return $info;
}
}
wicked-2.0.4/lib/Application.php 0000664 0000765 0000024 00000012724 12557035537 013447 0 ustar bindFactory('Wicked_Driver', 'Wicked_Factory_Driver', 'create');
}
/**
* Global variables defined:
* - $wicked: The Wicked_Driver object.
*/
protected function _init()
{
$GLOBALS['wicked'] = $GLOBALS['injector']->getInstance('Wicked_Driver');
}
/**
*/
public function menu($menu)
{
global $conf, $page;
if (@count($conf['menu']['pages'])) {
$pages = array(
'Wiki/Home' => _("_Home"),
'Wiki/Usage' => _("_Usage"),
'RecentChanges' => _("_Recent Changes"),
'AllPages' => _("_All Pages"),
'MostPopular' => _("Most Popular"),
'LeastPopular' => _("Least Popular"),
);
foreach ($conf['menu']['pages'] as $pagename) {
/* Determine who we should say referred us. */
$curpage = isset($page) ? $page->pageName() : null;
$referrer = Horde_Util::getFormData('referrer', $curpage);
/* Determine if we should depress the button. We have to do
* this on our own because all the buttons go to the same .php
* file, just with different args. */
if (!strstr($_SERVER['PHP_SELF'], 'prefs.php') &&
$curpage === $pagename) {
$cellclass = 'current';
} else {
$cellclass = '__noselection';
}
$url = Wicked::url($pagename)->add('referrer', $referrer);
$menu->add($url, $pages[$pagename], 'wicked-' . str_replace('/', '', $pagename), null, null, null, $cellclass);
}
}
}
/**
*/
public function perms()
{
$perms = array(
'pages' => array(
'title' => _("Pages")
)
);
foreach (array('AllPages', 'LeastPopular', 'MostPopular', 'RecentChanges') as $val) {
$perms['pages:' . $val] = array(
'title' => $val
);
}
try {
$pages = $GLOBALS['wicked']->getPages();
sort($pages);
foreach ($pages as $pagename) {
$perms['pages:' .$GLOBALS['wicked']->getPageId($pagename)] = array(
'title' => $pagename
);
}
} catch (Wicked_Exception $e) {}
return $perms;
}
/* Download data. */
/**
*/
public function download(Horde_Variables $vars)
{
global $wicked;
$page = $vars->get('page', 'Wiki/Home');
$page_id = (($id = $wicked->getPageId($page)) === false)
? $page
: $id;
$version = $vars->version;
if (empty($version)) {
try {
$attachments = $wicked->getAttachedFiles($page_id);
foreach ($attachments as $attachment) {
if ($attachment['attachment_name'] == $vars->file) {
$version = $attachment['attachment_version'];
}
}
} catch (Wicked_Exception $e) {}
if (empty($version)) {
// If we redirect here, we cause an infinite loop with inline
// attachments.
header('HTTP/1.1 404 Not Found');
exit;
}
}
try {
$data = $wicked->getAttachmentContents($page_id, $vars->file, $version);
$wicked->logAttachmentDownload($page_id, $vars->file);
} catch (Wicked_Exception $e) {
// If we redirect here, we cause an infinite loop with inline
// attachments.
header('HTTP/1.1 404 Not Found');
echo $e->getMessage();
exit;
}
$type = Horde_Mime_Magic::analyzeData($data, isset($conf['mime']['magic_db']) ? $conf['mime']['magic_db'] : null);
if ($type === false) {
$type = Horde_Mime_Magic::filenameToMime($vars->file, false);
}
return array(
'data' => $data,
'file' => $vars->file,
'type' => $type
);
}
}
wicked-2.0.4/lib/Driver.php 0000664 0000765 0000024 00000025045 12557035537 012437 0 ustar
* @package Wicked
*/
/**
* Wicked_Driver defines an API for implementing storage backends for Wicked.
*
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @author Tyler Colbert
* @package Wicked
*/
abstract class Wicked_Driver
{
/**
* Hash containing connection parameters.
*
* @var array
*/
protected $_params = array();
/**
* VFS object for storing attachments.
*
* @var VFS
*/
protected $_vfs;
/**
* Constructor.
*
* @param array $params A hash containing connection parameters.
*/
public function __construct($params = array())
{
$this->_params = $params;
}
/**
* Accessor to manage a VFS instance.
*
* @throws Wicked_Exception
*/
public function getVFS()
{
if (!$this->_vfs) {
try {
$this->_vfs = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Vfs')->create();
} catch (Horde_Vfs_Exception $e) {
throw new Wicked_Exception($e);
}
}
return $this->_vfs;
}
/**
* Retrieves the page of a particular name from the database.
*
* @param string $pagename The name of the page to retrieve
*
*/
abstract function retrieveByName($pagename);
/**
* Retrieves a historic version of a page.
*
* @param string $pagename The name of the page to retrieve.
* @param string $version The version to retrieve.
*
*/
abstract function retrieveHistory($pagename, $version);
/**
* Logs a hit to $pagename.
*
* @param string $pagename The page that was viewed.
*/
abstract function logPageView($pagename);
/**
* Creates a new page.
*
* @param string $pagename The new page's name.
* @param string $text The new page's text.
*/
abstract function newPage($pagename, $text);
abstract function updateText($pagename, $text, $changelog);
abstract function renamePage($pagename, $newname);
public function getPageId($pagename)
{
$pages = $this->getPages();
$ids = array_flip($pages);
return isset($ids[$pagename]) ? $ids[$pagename] : false;
}
public function getPage($pagename)
{
return array();
}
public function getPageById($id)
{
return array();
}
public function getSpecialPages()
{
static $pages;
if (isset($pages)) {
return $pages;
}
$dh = opendir(WICKED_BASE . '/lib/Page');
$pages = array();
while (($dent = readdir($dh)) !== false) {
if (!preg_match('/(.*)\.php$/', $dent, $matches)) {
continue;
}
$pageName = $matches[1];
if ($pageName == 'StandardPage') {
continue;
}
$pages[$pageName] = $pageName;
}
closedir($dh);
return $pages;
}
public function getPages($special = true)
{
return array();
}
public function pageExists($pagename)
{
return in_array($pagename, $this->getPages());
}
abstract function getAllPages();
abstract function getHistory($pagename);
/**
* Returns the most recently changed pages.
*
* @param integer $days The number of days to look back.
*
* @return array Pages.
*/
abstract function getRecentChanges($days = 3);
/**
* Returns the most recently changed pages.
*
* @param integer $limit The number of most recent pages to return.
*
* @return array Pages.
*/
abstract function mostRecent($limit = 10);
/**
* Returns the most popular pages.
*
* @param integer $limit The number of most popular pages to return.
*
* @return array Pages.
*/
abstract function mostPopular($limit = 10);
/**
* Returns the least popular pages.
*
* @param integer $limit The number of least popular pages to return.
*
* @return array Pages.
*/
abstract function leastPopular($limit = 10);
/**
* Finds pages with matches in text or title.
*
* @param string $searchtext The search expression (Google-like).
*
* @return array A list of pages
*/
abstract function searchText($searchtext);
abstract function getBackLinks($pagename);
abstract function getLikePages($pagename);
/**
* Retrieves data on files attached to a page.
*
* @param string $pageId This is the Id of the page for which we'd
* like to find attached files.
* @param boolean $allversions Whether to include all versions. If false
* or omitted, only the most recent version
* of each attachment is returned.
* @return array An array of key/value arrays describing the attached
* files.
*/
abstract function getAttachedFiles($pageId, $allversions = false);
/**
* Attaches a file to a page or update an attachment.
*
* @param array $file This is a key/value array describing the
* attachment:
* 'page_id' => This is the id of the page to which we would
* like to attach the file.
* 'attachment_name' => This is the filename of the attachment.
* 'change_log' => A change log entry for this attach or update
* operation. (Optional)
* 'change_author' => The user uploading this file. If not present,
* the currently logged-in user is assumed.
* @param string $data This is the contents of the file to be attached.
*
* @throws Wicked_Exception
*/
public function attachFile($file, $data)
{
$vfs = $this->getVFS();
if (!isset($file['change_author'])) {
$file['change_author'] = $GLOBALS['registry']->getAuth();
}
$result = $this->_attachFile($file);
/* We encode the path quoted printable so we won't get any nasty
* characters the filesystem might reject. */
$path = Wicked::VFS_ATTACH_PATH . '/' . $file['page_id'];
try {
$vfs->writeData($path, $file['attachment_name'] . ';' . $result, $data, true);
} catch (Horde_Vfs_Exception $e) {
throw new Wicked_Exception($e);
}
}
/**
* Remove a single version or all versions of an attachment to
* $pageId from the VFS backend.
*
* @param integer $pageId The Id of the page the file is attached to.
* @param string $attachment The name of the file.
* @param string $version If specified, the version to delete. If null,
* then all versions of $attachment will be removed.
*
* @throws Wicked_Exception
*/
public function removeAttachment($pageId, $attachment, $version = null)
{
$vfs = $this->getVFS();
$path = Wicked::VFS_ATTACH_PATH . '/' . $pageId;
$fileList = $this->getAttachedFiles($pageId, true);
foreach ($fileList as $file) {
$fileversion = $file['attachment_version'];
if ($file['attachment_name'] == $attachment &&
(is_null($version) || $fileversion == $version)) {
/* Skip any attachments that don't exist so they can
* be cleared out of the backend. */
if (!$vfs->exists($path, $attachment . ';' . $fileversion)) {
continue;
}
try {
$vfs->deleteFile($path, $attachment . ';' . $fileversion);
} catch (Horde_Vfs_Exception $e) {
throw new Wicked_Exception($e);
}
}
}
}
/**
* Removes all attachments to $pageId from the VFS backend.
*
* @param integer $pageId The Id of the page to remove attachments from.
*
* @throws Wicked_Exception
*/
public function removeAllAttachments($pageId)
{
if (empty($pageId)) {
throw new Wicked_Exception('Cannot delete all attachments of all pages at once');
}
$vfs = $this->getVFS();
if (!$vfs->isFolder(Wicked::VFS_ATTACH_PATH, $pageId)) {
return;
}
try {
$vfs->deleteFolder(Wicked::VFS_ATTACH_PATH, $pageId, true);
} catch (Horde_Vfs_Exception $e) {
throw new Wicked_Exception($e);
}
}
/**
* Handles the driver-specific portion of attaching a file.
*
* Wicked_Driver::attachFile() calls down to this method for the driver-
* specific portion, and then uses VFS to store the attachment.
*
* @param array $file See Wicked_Driver::attachFile().
*
* @return boolean The new version of the file attached
* @throws Wicked_Exception
*/
abstract protected function _attachFile($file);
/**
* Retrieves the contents of an attachment.
*
* @param string $pageId This is the name of the page to which the file
* is attached.
* @param string $filename This is the name of the attachment.
* @param string $version This is the version of the attachment.
*
* @return string The file's contents.
* @throws Wicked_Exception
*/
public function getAttachmentContents($pageId, $filename, $version)
{
$vfs = $this->getVFS();
$path = Wicked::VFS_ATTACH_PATH . '/' . $pageId;
try {
return $vfs->read($path, $filename . ';' . $version);
} catch (Horde_Vfs_Exception $e) {
throw new Wicked_Exception($e);
}
}
abstract function removeVersion($pagename, $version);
public function removeAllVersions($pagename)
{
/* When deleting a page, also delete all its attachments. */
$this->removeAllAttachments($this->getPageId($pagename));
}
abstract function searchTitles($searchtext);
/**
* Returns the charset used by the backend.
*
* @return string The backend's charset
*/
public function getCharset()
{
return 'UTF-8';
}
}
wicked-2.0.4/lib/Exception.php 0000664 0000765 0000024 00000001140 12557035537 013130 0 ustar
* @package Wicked
*/
/**
* Base exception class for Wicked.
*
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @author Michael J. Rubinsky
* @package Wicked
*/
class Wicked_Exception extends Horde_Exception_Wrapped
{
}
wicked-2.0.4/lib/Page.php 0000664 0000765 0000024 00000045564 12557035537 012070 0 ustar
* @package Wicked
*/
/**
* Abstract page class.
*
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @author Tyler Colbert
* @package Wicked
*/
class Wicked_Page
{
const MATCH_LEFT = 1;
const MATCH_RIGHT = 2;
const MATCH_ENDS = 3;
const MATCH_ANY = 4;
/**
* Display modes supported by this page. Possible modes:
*
* Wicked::MODE_CONTENT
* Wicked::MODE_DISPLAY
* Wicked::MODE_EDIT
* Wicked::MODE_REMOVE
* Wicked::MODE_HISTORY
* Wicked::MODE_DIFF
* Wicked::MODE_LOCKING
* Wicked::MODE_UNLOCKING
* Wicked::MODE_CREATE
*
* @var array
*/
public $supportedModes = array();
/**
* Instance of a Text_Wiki processor.
*
* @var Text_Wiki
*/
protected $_proc;
/**
* The loaded page info.
*
* @var array
*/
protected $_page;
/**
* Is this a validly loaded page?
*
* @return boolean True if we've loaded data, false otherwise.
*/
public function isValid()
{
return !empty($this->_page);
}
/**
* Retrieve this user's permissions for this page. If a
* permissions object does not exist, we assume reasonable
* defaults.
*
* @return integer The permissions bitmask.
*/
public function getPermissions($pageName = null)
{
global $wicked;
if (is_null($pageName)) {
$pageName = $this->pageName();
}
$pageId = $wicked->getPageId($pageName);
$permName = 'wicked:pages:' . $pageId;
$perms = $GLOBALS['injector']->getInstance('Horde_Perms');
if ($pageId !== false && $perms->exists($permName)) {
return $perms->getPermissions($permName, $GLOBALS['registry']->getAuth());
} elseif ($perms->exists('wicked:pages')) {
return $perms->getPermissions('wicked:pages', $GLOBALS['registry']->getAuth());
} else {
if (!$GLOBALS['registry']->getAuth()) {
return Horde_Perms::SHOW | Horde_Perms::READ;
} else {
return Horde_Perms::SHOW | Horde_Perms::READ | Horde_Perms::EDIT | Horde_Perms::DELETE;
}
}
}
/**
* Returns if the page allows a mode. Access rights and user state
* are taken into consideration.
*
* @see $supportedModes
*
* @param integer $mode The mode to check for.
*
* @return boolean True if the mode is allowed.
*/
public function allows($mode)
{
global $browser;
$pagePerms = $this->getPermissions();
switch ($mode) {
case Wicked::MODE_CREATE:
// Special mode for pages that don't exist yet - generic
// to all pages.
if ($browser->isRobot()) {
return false;
}
if ($GLOBALS['registry']->isAdmin()) {
return true;
}
$permName = 'wicked:pages';
$perms = $GLOBALS['injector']->getInstance('Horde_Perms');
if ($perms->exists($permName)) {
return $perms->hasPermission($permName, $GLOBALS['registry']->getAuth(), Horde_Perms::EDIT);
} else {
return $GLOBALS['registry']->getAuth();
}
break;
case Wicked::MODE_EDIT:
if ($browser->isRobot()) {
return false;
}
if ($GLOBALS['registry']->isAdmin()) {
return true;
}
if (($pagePerms & Horde_Perms::EDIT) == 0) {
return false;
}
break;
case Wicked::MODE_REMOVE:
if ($browser->isRobot()) {
return false;
}
if ($GLOBALS['registry']->isAdmin()) {
return true;
}
if (($pagePerms & Horde_Perms::DELETE) == 0) {
return false;
}
break;
// All other modes require READ permissions.
default:
if ($GLOBALS['registry']->isAdmin()) {
return true;
}
if (($pagePerms & Horde_Perms::READ) == 0) {
return false;
}
break;
}
return $this->supports($mode);
}
/**
* See if the page supports a particular mode.
* @see $supportedModes
*
* @param integer $mode Which mode to check for
*
* @return boolean True or false
*/
public function supports($mode)
{
return !empty($this->supportedModes[$mode]);
}
/**
* Returns the page we are currently on.
*
* @return Wicked_Page The current page.
* @throws Wicked_Exception
*/
static public function getCurrentPage()
{
return Wicked_Page::getPage(rtrim(Horde_Util::getFormData('page'), '/'),
Horde_Util::getFormData('version'),
Horde_Util::getFormData('referrer'));
}
/**
* Returns the requested page.
*
* @return Wicked_Page The requested page.
* @throws Wicked_Exception
*/
static public function getPage($pagename, $pagever = null, $referrer = null)
{
global $conf, $notification, $wicked;
if (empty($pagename)) {
$pagename = 'Wiki/Home';
}
$classname = 'Wicked_Page_' . $pagename;
if ($pagename == basename($pagename) && class_exists($classname)) {
return new $classname($referrer);
}
/* If we have a version, but it is actually the most recent version,
* ignore it. */
if (!empty($pagever)) {
$page = new Wicked_Page_StandardPage($pagename, false, null);
if ($page->isValid() && $page->version() == $pagever) {
return $page;
}
return new Wicked_Page_StandardHistoryPage($pagename, $pagever);
}
$page = new Wicked_Page_StandardPage($pagename);
if ($page->isValid() || !$page->allows(Wicked::MODE_EDIT)) {
return $page;
}
return new Wicked_Page_AddPage($pagename);
}
public function versionCreated()
{
throw new Wicked_Exception(_("Unsupported"));
}
public function formatVersionCreated()
{
try {
$v = $this->versionCreated();
if ($v) {
return strftime($GLOBALS['prefs']->getValue('date_format'), $v);
}
} catch (Wicked_Exception $e) {}
return _("Never");
}
public function author()
{
if (isset($this->_page['change_author'])) {
$modify = $this->_page['change_author'];
} else {
return _("Guest");
}
$identity = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create($modify);
$name = $identity->getValue('fullname');
if (!empty($name)) {
$modify = $name;
}
return $modify;
}
public function hits()
{
throw new Wicked_Exception(_("Unsupported"));
}
public function version()
{
throw new Wicked_Exception(_("Unsupported"));
}
/**
* Returns the previous version number for this page.
*
* @return string A string containing the previous version or null if this
* is the first version.
* @throws Wicked_Exception
*/
public function previousVersion()
{
global $wicked;
$this->version();
$history = $wicked->getHistory($this->pageName());
if (count($history) == 0) {
return null;
}
if ($this->isOld()) {
for ($i = 0; $i < count($history); $i++) {
if ($history[$i]['page_version'] == $this->version()) {
if ($i + 1 < count($history)) {
$i++;
break;
} else {
return null;
}
}
}
if ($i == count($history)) {
return null;
}
} else {
$i = 0;
}
return $history[$i]['page_version'];
}
public function isOld()
{
return false;
}
/**
* Renders this page in display mode.
*
* This must be overridden if the page is to be anything like a real page.
*
* @throws Wicked_Exception
*/
public function display()
{
global $injector;
// Get content first, it might throw an exception.
$inner = $this->displayContents(false);
$view = $injector->createInstance('Horde_View');
$topbar = $injector->getInstance('Horde_View_Topbar');
try {
$view->version = $this->version();
$diff_url = Horde::url('diff.php')
->add(array(
'page' => $this->pageName(),
'v1' => '?',
'v2' => $view->version
));
$diff_alt = sprintf(_("Show changes for %s"), $view->version);
$topbar->subinfo = $diff_url->link(array('title' => $diff_alt))
. sprintf(_("Last Modified %s by %s"),
$this->formatVersionCreated(),
$this->author())
. '';
} catch (Wicked_Exception $e) {
}
$view->name = $this->pageName();
if ($this->referrer()) {
$view->referrer = Wicked::url($this->referrer())->link()
. htmlspecialchars($this->referrer()) . '';
}
$view->isOld = $this->isOld();
$view->refresh = $this->pageUrl()
->link(array('title' => _("Reload Page")))
. Horde::img('reload.png', _("Reload Page")) . '';
if ($this->isLocked()) {
$this->locked = Horde::img('locked.png', _("Locked"));
}
return $view->render('display/title') . $inner;
}
/**
* Perform any pre-display checks for permissions, searches,
* etc. Called before any output is sent so the page can do
* redirects. If the page wants to take control of flow from here,
* it can, and is entirely responsible for handling the user
* (should call exit after redirecting, for example).
*
* $param integer $mode The page render mode.
* $param array $params Any page parameters.
*/
public function preDisplay($mode, $params)
{
}
/**
* Renders this page for displaying in a block.
*
* This must be overridden if the page is to be anything like a real page.
*
* @return string The content.
* @throws Wicked_Exception
*/
public function block()
{
return $this->displayContents(true);
}
public function displayContents($isBlock)
{
throw new Wicked_Exception(_("Unsupported"));
}
/**
* Renders this page in remove mode.
*/
public function remove()
{
throw new Wicked_Exception(_("Unsupported"));
}
/**
* Renders this page in history mode.
*/
public function history()
{
throw new Wicked_Exception(_("Unsupported"));
}
/**
* Renders this page in diff mode.
*
* @param string $version The version to diff this page against.
*/
public function diff($version)
{
throw new Wicked_Exception(_("Unsupported"));
}
public function getProcessor($output_format = 'Xhtml')
{
if (isset($this->_proc)) {
return $this->_proc;
}
$view_url = Wicked::url('%s')
->setRaw(true)
->add('referrer', $this->pageName());
$view_url = str_replace(urlencode('%s'), '%s', $view_url);
/* Create format-specific Text_Wiki object */
$class = 'Text_Wiki_' . $GLOBALS['conf']['wicked']['format'];
$this->_proc = new $class();
/* Use a non-printable delimiter character that is still a valid UTF-8
* character. See http://pear.php.net/bugs/bug.php?id=12490. */
$this->_proc->delim = chr(1);
/* Override rules */
$this->_proc->insertRule('Heading2', 'Heading');
$this->_proc->deleteRule('Heading');
$this->_proc->loadParseObj('Paragraph');
$skip = $this->_proc->parseObj['Paragraph']->getConf('skip');
$skip[] = 'heading2';
$this->_proc->setParseConf('Paragraph', 'skip', $skip);
if ($GLOBALS['conf']['wicked']['format'] == 'Default' ||
$GLOBALS['conf']['wicked']['format'] == 'Cowiki' ||
$GLOBALS['conf']['wicked']['format'] == 'Tiki') {
$this->_proc->insertRule('Toc2', 'Toc');
}
$this->_proc->deleteRule('Toc');
switch ($output_format) {
case 'Xhtml':
if ($GLOBALS['conf']['wicked']['format'] != 'Creole') {
$this->_proc->insertRule('Code2', 'Code');
}
$this->_proc->deleteRule('Code');
if ($GLOBALS['conf']['wicked']['format'] == 'BBCode') {
$this->_proc->insertRule('Wickedblock', 'Code2');
} else {
$this->_proc->insertRule('Wikilink2', 'Wikilink');
$this->_proc->setParseConf('Wikilink2', 'utf-8', true);
$this->_proc->insertRule('Wickedblock', 'Raw');
}
$this->_proc->deleteRule('Wikilink');
if ($GLOBALS['conf']['wicked']['format'] == 'Default' ||
$GLOBALS['conf']['wicked']['format'] == 'Cowiki' ||
$GLOBALS['conf']['wicked']['format'] == 'Tiki') {
$this->_proc->insertRule('Freelink2', 'Freelink');
}
$this->_proc->deleteRule('Freelink');
$this->_proc->insertRule('Image2', 'Image');
$this->_proc->deleteRule('Image');
$this->_proc->insertRule('RegistryLink', 'Wickedblock');
$this->_proc->insertRule('Attribute', 'RegistryLink');
$this->_proc->deleteRule('Include');
$this->_proc->deleteRule('Embed');
$this->_proc->setFormatConf('Xhtml', 'charset', 'UTF-8');
$this->_proc->setFormatConf('Xhtml', 'translate', HTML_SPECIALCHARS);
$create = $this->allows(Wicked::MODE_CREATE) ? 1 : 0;
$linkConf = array(
'pages' => $GLOBALS['wicked']->getPages(),
'view_url' => $view_url,
'new_url' => $create ? $view_url : false,
'new_text_pos' => false,
'css_new' => 'newpage',
'ext_chars' => true,
);
$this->_proc->setRenderConf('Xhtml', 'Wikilink2', $linkConf);
$this->_proc->setRenderConf('Xhtml', 'Freelink2', $linkConf);
$this->_proc->setRenderConf('Xhtml', 'Toc2',
array('title' => '' . _("Table of Contents") . '
'));
$this->_proc->setRenderConf('Xhtml', 'Table',
array('css_table' => 'horde-table'));
break;
case 'Rst':
require_once __DIR__ . '/Text_Wiki/Render/Rst.php';
break;
}
$autoloader = $GLOBALS['injector']->getInstance('Horde_Autoloader');
$autoloader->addClassPathMapper(
new Horde_Autoloader_ClassPathMapper_Prefix(
'/^Text_Wiki_Render_' . $output_format . '/',
WICKED_BASE . '/lib/Text_Wiki/Render/' . $output_format
)
);
$autoloader->addClassPathMapper(
new Horde_Autoloader_ClassPathMapper_Prefix(
'/^Text_Wiki_Parse/',
WICKED_BASE . '/lib/Text_Wiki/Parse/' . $GLOBALS['conf']['wicked']['format']
)
);
return $this->_proc;
}
public function render($mode, $params = null)
{
switch ($mode) {
case Wicked::MODE_CONTENT:
return $this->content($params);
case Wicked::MODE_DISPLAY:
return $this->display($params);
case Wicked::MODE_BLOCK:
return $this->block($params);
case Wicked::MODE_REMOVE:
return $this->remove();
case Wicked::MODE_HISTORY:
return $this->history();
case Wicked::MODE_DIFF:
return $this->diff($params);
default:
throw new Wicked_Exception(_("Unsupported"));
}
}
/**
* Returns an object with Horde_View properties.
*
* The returned object is supposed to be used with the _page.html.php
* partial.
*
* @return object A simple object.
* @throws Wicked_Exception
*/
public function toView()
{
return (object)array(
'author' => $this->author(),
'date' => $this->formatVersionCreated(),
'name' => $this->pageUrl()
->link(array(
'title' => sprintf(_("Display %s"), $this->pageName())
))
. htmlspecialchars($this->pageName()) . '',
'timestamp' => $this->versionCreated(),
'version' => $this->pageUrl()
->link(array(
'title' => sprintf(_("Display Version %s"), $this->version())
))
. $this->version() . '',
);
}
public function isLocked()
{
return false;
}
public function lock()
{
throw new Wicked_Exception(_("Unsupported"));
}
public function unlock()
{
throw new Wicked_Exception(_("Unsupported"));
}
public function updateText($newtext, $changelog)
{
throw new Wicked_Exception(_("Unsupported"));
}
public function getText()
{
throw new Wicked_Exception(_("Unsupported"));
}
public function pageName()
{
return null;
}
public function referrer()
{
return null;
}
public function changeLog()
{
return null;
}
public function pageUrl($linkpage = null, $actionId = null)
{
$params = array('page' => $this->pageName());
if ($this->referrer()) {
$params['referrer'] = $this->referrer();
}
if ($actionId) {
$params['actionID'] = $actionId;
}
if (!$linkpage) {
$url = Wicked::url($this->pageName());
unset($params['page']);
} else {
$url = Horde::url($linkpage);
}
return $url->add($params);
}
public function pageTitle()
{
return $this->pageName();
}
public function handleAction()
{
throw new Wicked_Exception(_("Unsupported"));
}
}
wicked-2.0.4/lib/Test.php 0000664 0000765 0000024 00000004504 12557035537 012120 0 ustar
* @package Wicked
*/
/**
* This class provides the Wicked configuration for the test script.
*
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @author Michael Slusarz
* @package Wicked
*/
class Wicked_Test extends Horde_Test
{
/**
* The module list
*
* @var array
*/
protected $_moduleList = array();
/**
* PHP settings list.
*
* @var array
*/
protected $_settingsList = array();
/**
* PEAR modules list.
*
* @var array
*/
protected $_pearList = array(
'Text_Wiki' => array(
'error' => 'The Text_Wiki module is required to parse and render the wiki markup in Wicked.',
'required' => true,
'function' => '_checkPearTextWikiVersion'
),
'Text_Wiki_Creole' => array(
'error' => 'The Text_Wiki_Creole module is required if you plan on using Creole formatting.',
'required' => false,
),
'Text_Wiki_Mediawiki' => array(
'error' => 'The Text_Wiki_Mediawiki module is required if you plan on using Mediawiki formatting.',
'required' => false,
),
'Text_Wiki_Tiki' => array(
'error' => 'The Text_Wiki_Tiki module is required if you plan on using Tiki formatting.',
'required' => false,
),
);
/**
* Inter-Horde application dependencies.
*
* @var array
*/
protected $_appList = array();
/**
* Additional check for PEAR Text_Wiki module for its version.
*
* @return string Returns error string on error.
*/
protected function _checkPearTextWikiVersion()
{
if (!is_callable(array('Text_Wiki', 'setRenderConf'))) {
return 'Your version of Text_Wiki is not recent enough.';
}
}
/**
* Any application specific tests that need to be done.
*
* @return string HTML output.
*/
public function appTests()
{
}
}
wicked-2.0.4/lib/Wicked.php 0000664 0000765 0000024 00000016423 12557035537 012412 0 ustar
* @package Wicked
*/
/**
* Wicked Base Class.
*
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @author Tyler Colbert
* @package Wicked
*/
class Wicked
{
/** Display mode. */
const MODE_DISPLAY = 0;
/** The edit screen. */
const MODE_EDIT = 1;
/** Page can be removed. */
const MODE_REMOVE = 2;
/** Display the page history. */
const MODE_HISTORY = 3;
/** Diff two versions of the page. */
const MODE_DIFF = 4;
/** Page can be locked. */
const MODE_LOCKING = 7;
/** Page can be unlocked. */
const MODE_UNLOCKING = 8;
/** The ability to add a page. */
const MODE_CREATE = 9;
/** Raw content mode. */
const MODE_CONTENT = 10;
/** Like display, but for a block. */
const MODE_BLOCK = 11;
/** Our wiki word regexp (needed many places).
"(!?" . // START WikiPage pattern (1)
"[A-Z\xc0-\xde]" . // 1 upper
"[A-Za-z0-9\xc0-\xfe]*" . // 0+ alpha or digit
"[a-z0-9\xdf-\xfe]+" . // 1+ lower or digit
"\/?" . // 0/1 slash
"[A-Z\xc0-\xde]" . // 1 upper
"[A-Za-z0-9\xc0-\xfe\/]*" . // 0+ or more alpha or digit or slash
")" . // END WikiPage pattern (/1)
"((\#" . // START Anchor pattern (2)(3)
"[A-Za-z0-9\xc0-\xfe]" . // 1 alpha
"(" . // start sub pattern (4)
"[-_A-Za-z0-9\xc0-\xfe:.]*" . // 0+ dash, alpha, digit, underscore,
// colon, dot
"[-_A-Za-z0-9\xc0-\xfe]" . // 1 dash, alpha, digit, or underscore
")?)?)"); // end subpatterns (/4)(/3)(/2)
*/
const REGEXP_WIKIWORD = "(!?[A-Z\xc0-\xde][A-Za-z0-9\xc0-\xfe]*[a-z0-9\xdf-\xfe]+\/?[A-Z\xc0-\xde][A-Za-z0-9\xc0-\xfe\/]*)((\#[A-Za-z0-9\xc0-\xfe]([-_A-Za-z0-9\xc0-\xfe:.]*[-_A-Za-z0-9\xc0-\xfe])?)?)";
/** Where we store our attachments in VFS. */
const VFS_ATTACH_PATH = '.horde/wicked/attachments';
/**
* Puts together the URL to a Wicked page. Uses mod_rewrite or GET
* style URLs depending on configuration.
*
* @param string $page The name of the page to target.
* @param boolean $full @see Horde::url()
* @param integer $append_session @see Horde::url()
*
* @return Horde_Url The URL of $page.
*/
public static function url($page, $full = false, $append_session = 0)
{
if ($GLOBALS['conf']['urls']['pretty'] == 'rewrite') {
$script = str_replace('%2F', '/', urlencode($page));
} else {
$script = Horde::url('display.php')->add('page', $page);
}
$url = Horde::url($script, $full, array('append_session' => $append_session));
if (!$full) {
$url->url = preg_replace('|^([a-zA-Z][a-zA-Z0-9+.-]{0,19})://[^/]*|', '', $url->url);
}
return $url;
}
/**
* Mails a notification message after encoding the headers and adding the
* standard username/time line.
*
* @param string $message The message text to send out.
* @param array $headers Additional headers to add to the email.
*/
public static function mail($message, $headers = array())
{
global $conf, $registry;
/* Make sure there's a place configured to send the email. */
if (empty($conf['wicked']['notify_address'])) {
return;
}
if ($GLOBALS['registry']->getAuth()) {
$prefix = $GLOBALS['registry']->getAuth();
} else {
$prefix = 'guest [' . $_SERVER['REMOTE_ADDR'] . ']';
}
$message = $prefix . ' ' . date('r') . "\n\n" . $message;
/* In case we don't get a user's email address to send the
* notification from, what should we fall back to for the From:
* header? */
$default_from_addr = !empty($conf['wicked']['guest_address']) ?
$conf['wicked']['guest_address'] :
$conf['wicked']['notify_address'];
if ($GLOBALS['registry']->getAuth()) {
$identity = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create();
$from = $identity->getValue('fullname');
if (empty($from)) {
$from = $registry->get('name');
}
$from_addr = $identity->getValue('from_addr');
if (empty($from_addr)) {
$from_addr = $default_from_addr;
}
} else {
$from = $registry->get('name') . ' Guest';
$from_addr = $default_from_addr;
}
$mail = new Horde_Mime_Mail(array(
'body' => $message,
'To' => $conf['wicked']['notify_address'],
'From' => $from . '<' . $from_addr . '>',
'User-Agent' => 'Wicked ' . $GLOBALS['registry']->getVersion(),
'Precedence' => 'bulk',
'Auto-Submitted' => 'auto-replied'));
foreach (array_keys($headers) as $hkey) {
$mail->addHeader($hkey, $headers[$hkey]);
}
try {
$mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
} catch (Horde_Mime_Exception $e) {
$GLOBALS['notification']->push($e);
}
}
/**
* Generate a CAPTCHA string.
*
* @param boolean $new If true, a new CAPTCHA is created and returned.
* The current, to-be-confirmed string otherwise.
*
* @return string A CAPTCHA string.
*/
public static function getCAPTCHA($new = false)
{
global $session;
if ($new || !$session->get('wicked', 'captcha')) {
$captcha = '';
for ($i = 0; $i < 5; ++$i) {
$captcha .= chr(rand(65, 90));
}
$session->set('wicked', 'captcha', $captcha);
}
return $session->get('wicked', 'captcha');
}
/**
* Returns the user name that is used for locking, either the current user
* or the current IP address.
*
* @return string The user name used for locking.
*/
public static function lockUser()
{
return $GLOBALS['registry']->getAuth() ? $GLOBALS['registry']->getAuth() : $GLOBALS['browser']->getIPAddress();
}
/**
* Sets the topbar up.
*/
public static function setTopbar()
{
$topbar = $GLOBALS['injector']->getInstance('Horde_View_Topbar');
$topbar->search = true;
$topbar->searchAction = Horde::url('display.php');
$topbar->searchParameters = array('page' => 'Search');
}
public static function addFeedLink()
{
$GLOBALS['page_output']->addLinkTag(array(
'href' => Horde::url('opensearch.php', true, -1),
'rel' => 'search',
'title' => $GLOBALS['registry']->get('name') . ' (' . Horde::url('', true) . ')',
'type' => 'application/opensearchdescription+xml'
));
}
}
wicked-2.0.4/locale/da/LC_MESSAGES/wicked.mo 0000664 0000765 0000024 00000223166 12557035537 015144 0 ustar Q ? U O !U $ qU ) U U &