Revision [10016]

This is an old revision of WikkaMenulets made by JavaWoman on 2005-07-16 00:49:44.

 

Wikka Menulets

Last edited by JavaWoman:
ypot
Sat, 16 Jul 2005 00:49 UTC [diff]


As part of my proposal for a general overhaul of the WikkaMenus menu management system in WikkaWiki, I suggest we replace the current system-generated items that occur in the main menu and footer menu with a series of menulets, i.e. mini-actions generating content for menu items.
Any of these mini-actions can of course be used in the page body as well.

Here's a list of potential menulets and their output, that I've uploaded to this server.
Suggestions/modifications are welcome.


{{acls}}

Prints a link to CurrentPage/acls if the user has access to the ACLs:

<?php
if ($this->page){
    if ($owner = $this->GetPageOwner()){
        if ($owner == "(Public)"){
            print $this->IsAdmin() ? "<a href=\"".$this->href("acls")."\">(Edit ACLs)</a>\n" : ""; #i18n
        } elseif ($this->UserIsOwner()){
            print "<a href=\"".$this->href("acls")."\">Edit ACLs</a>\n"; #i18n
        }
    } else {
        print ($this->GetUser()) ? " (<a href=\"".$this->href("claim")."\">Take Ownership</a>)\n" : ""; #i18n
    }
}
?>




{{attachments}}

Prints a link to the FilesHandler differently depending if there are attached documents to the current page or not: Attachments .

<?php
    // this is a menulet action relying on the files handler
    // upload path
    $upload_path = $this->config['upload_path'].'/'.$this->GetPageTag();
    $AttachmentClass = "";
        if(is_dir($upload_path) ){
            $handle = opendir($upload_path);
            while( (gettype( $name = readdir($handle)) != "boolean")){
                $name_array[] = $name;
            }
            foreach($name_array as $temp) $folder_content .= $temp;
            closedir($handle);
            if($folder_content == "...") {
                $AttachmentClass ="emptyfolder"; // the upload path is empty
            } else {
                $AttachmentClass = "fullfolder"; // the upload path contains attachments
            }
        }
        else $AttachmentClass = "inexistingfolder"; // the upload path does not exist
       
    echo  "<a href=\"".$this->href("files")."\" title=\"Click to manage attachments\" class=\"".$AttachmentClass."\">Attachments</a>\n"; #i18n
?>


Add something like this to the .css file:
.fullfolder {
    font-weight: bold;
    border: 1px solid red;
}
.emptyfolder {
}
.inexistingfolder {
}



{{contact}}

Prints a mailto: link to the Wikka administrator's address: Contact
Note: plain mailto links are a common source of spam.

<?php
/**
 * Print a spam-safe mailto: link to the administrator's email address.
 *
 * Note: plain mailto links are a common source of spam.
 */

$email = $this->GetConfigValue("admin_email");

// print spam-safe mailto link
$patterns = array("'@'", "'\.'");
$replace = array("[at]", "[dot]");
echo "<a href=\"mailto:".preg_replace($patterns, $replace, $email)."\" title=\"Send us your feedback\">Contact</a>"; #i18n

// print plain mailto link
//echo "<a href=\"mailto:".$email."\" title=\"Send us your feedback\">Contact</a>"; #i18n

// print contact link only to registered users
// echo ($this->GetUser()) ? "<a href=\"mailto:".$email."\" title=\"Send us your feedback\">Contact</a>" : ""; #i18n

?>



{{countcomments}}

Prints the total number of comments: 4268

<?php
/**
 * Print total number of comments in this wiki.
 */

$commentsdata = $this->LoadSingle("SELECT count(*) as num FROM ".$this->config["table_prefix"]."comments");
echo $commentsdata["num"];
?>



{{countowned}}

Prints the number of pages owned by the current user.

<?php
/**
 * Print number of pages owned by the current user.
 */

$str = 'SELECT COUNT(*) FROM '.$this->config["table_prefix"].'pages WHERE `owner` ';
$str .= "= '" . $this->GetUserName() . "' AND `latest` = 'Y'";
$countquery = $this->Query($str);
$count  = mysql_result($countquery, 0);
echo $this->Link('MyPages', '', $count,'','','Display a list of the pages you currently own');
?>



{{countpages}}

Prints the total number of pages: 1753

<?php
/**
 * Print the total number of pages in this wiki.
 */

$pagedata = $this->LoadSingle("SELECT count(*) as num FROM ".$this->config["table_prefix"]."pages WHERE latest = 'Y'");
echo $this->Link('PageIndex', '', $pagedata['num'],'','','Display an alphabetical page index');

?>



{{countusers}}

Prints the number of registered users: 4609

<?php
/**
 * Print number of registered users.
 */

$userdata = $this->LoadSingle("SELECT count(*) as num FROM ".$this->config["table_prefix"]."users ");
echo $userdata["num"];
?>



{{delete}}

Prints a link to CurrentPage/delete if the user has delete privileges:

<?php
echo  ($this->IsAdmin())? "<a href=\"".$this->href("delete")."\" title=\"Click to delete this page\">Delete this page</a>\n" : "";  #i18n
?>



{{edit}}

Prints a link to CurrentPage/edit: Show code

<?php
if ($this->HasAccess("write")) {
        echo  "<a href=\"".$this->href("edit")."\" title=\"Click to edit this page\">Edit this page</a>\n"; #i18n
} else {
        echo  "<a href=\"".$this->href("showcode")."\" title=\"Click to display the page source\">Show code</a>\n"; #i18n
}
?>



{{history}}

Prints a link to CurrentPage/history: Page History

<?php
        echo "<a href=\"".$this->href("history")."\" title=\"Click to view recent edits to this page\">Page History</a>\n"; #i18n
?>



{{homepage}}

Prints a link to the wiki homepage specified in the config file: HomePage

<?php
echo $this->Link($this->config['root_page']);
?>



{{lasteditauthor}}

Prints the author of the last page version: BrianKoontz

<?php
$page = $this->LoadSingle("SELECT * FROM ".$this->config['table_prefix']."pages WHERE tag='".$this->GetPageTag()."' AND latest = 'Y'");
$user = ($this->LoadUser($page["user"]))? $this->Link($page["user"]) : "anonymous";
echo $user;
?>



{{lasteditnotes}}

Prints the last edit notes: Replaces old-style internal links with new pipe-split links.

<?php
$page = $this->LoadSingle("SELECT * FROM ".$this->config['table_prefix']."pages WHERE tag='".$this->GetPageTag()."' AND latest = 'Y'");
echo ($page["note"])? $this->Format("//".$page["note"]."//") : "";
?>




Displays a wikka logo set by admins (in the future the path should be set in the config file):
logo

<?php
echo $this->Format('{{image alt="logo" title="'.$this->config['wakka_name'].'" url="images/wizard.gif" link="'.$this->config['root_page'].'"}}');
?>


My version (which needs the config entry: "wiki_logo => "yourlogo.jpg" [must be on the same server]):
<?php
//UI defines (i18n)
define('LOGO_ALT_TEXT', "logo");    # alt-text for the logo image

//print the image
if ($this->config['wiki_logo'] && file_exists($this->config['wiki_logo'])) echo $this->Format('{{image alt="LOGO_ALT_TEXT" title="'.$this->config['wakka_name'].'" url="'.$this->config['wiki_logo'].'" link="'.$this->config['root_page'].'"}}');
else echo $this->Format('{{image alt="LOGO_ALT_TEXT" title="'.$this->config['wakka_name'].'" url="images/wizard.gif" link="'.$this->config['root_page'].'"}}');
?>

--NilsLindenberg


{{mysqlversion}}

Displays the current MySQL version: n/a

<?php
/**
 * Print current MySQL version.
 */

echo mysql_get_server_info();
?>



{{owner}}

Displays page ownership infos: Owner: DarTar

<?php
if ($this->page) {
    if ($owner = $this->GetPageOwner()){
        if ($owner == "(Public)"){
            print "Public page"; #i18n
        }
        elseif ($this->UserIsOwner()) {
            if ($this->IsAdmin()) {
                print "Owner: ".$this->Link($owner, "", "", 0)."\n"; #i18n
                } else {
                print"You own this page.\n"; #i18n
            }
        } else {
            print "Owner: ".$this->Link($owner, "", "", 0)."\n"; #i18n
        }
    } else {
        print "Nobody\n"; #i18n
    }
}
?>




{{phpversion}}

Displays the current php version: n/a

<?php
/**
 * Print current PHP version.
 */

echo phpversion();
?>



{{recentchangesrss}}

Prints a link (RSS feed for recent changes) to CurrentPage/recentchanges.xml: XML

<?php
echo "<a href=\"".$this->href("recentchanges.xml")."\" title=\"Click to view recent changes in XML format.\"><img src=\"images/xml.png\" width=\"36\" height=\"14\" align=\"middle\" style=\"border : 0px;\" alt=\"XML\" /></a>"; #i18n
?>



{{referrers}}

Prints a link to CurrentPage/referrers:

<?php
if ($this->GetUser()) {
    echo "<a href='".$this->href("referrers")."' title='Click to view a list of URLs referring to this page.'>Referrers</a>\n";  #i18n
}
?>



{{revisions}}

Prints a link to CurrentPage/revisions: 2005-07-16 00:49:44

<?php
if ($this->GetPageTime()) {
        echo "<a href=\"".$this->href("revisions")."\" title=\"Click to view recent revisions list for this page\">".$this->GetPageTime()."</a>\n"; #i18n
}
?>



{{revisionsrss}}

Prints a link (RSS feed for page revisions) to CurrentPage/revisions.xml: XML

<?php
if ($this->GetPageTime()) {
    echo "<a href=\"".$this->href("revisions.xml")."\" title=\"Click to view recent page revisions in XML format.\"><img src=\"images/xml.png\" width=\"36\" height=\"14\" align=\"middle\" style=\"border : 0px;\" alt=\"XML\" /></a>"; #i18n 
}
?>




Prints a searchbox:
Search:


<?php
echo $this->FormOpen("", "TextSearch", "get");
echo 'Search: <input name="phrase" size="15" class="searchbox" />'; #i18n
echo $this->FormClose();
?>



{{skin}}

Displays a clickable link to the current skin: Unknown action ""skin""

<?php
#$skin = ($this->GetCookie("wikiskin"))? $this->GetCookie("wikiskin") : $this->GetConfigValue("stylesheet");
$defaultskin = $this->config['stylesheet'];
$skin = (!$this->GetCookie('wikiskin')) ? $defaultskin : $this->GetCookie('wikiskin'); # JW 2005-07-08 FIX possibly undefined cookie
echo '<a href="'.$this->config['base_url'].'css/'.$skin.'" title="Display stylesheet">'.$skin.'</a>';
?>




{{time}}

Prints the current time: 20:40

<?php
echo date("H:i");
?>



{{title}}

Prints the title of the current page: WikkaMenulets

<?php
echo $this->PageTitle();
?>



{{today}}

Prints the current date: September 15, 2019

<?php
echo date("F j, Y");
?>



{{url}}

Prints the complete URL of the current page: http://wikkawiki.org/WikkaMenulets

<?php
echo $this->href("", $this->GetPageTag());

//clickable link
//echo $this->Link($this->href("", $this->GetPageTag()));
?>




{{who}}

Prints the name of the current user:

<?php
if ($this->GetUser()) {
        echo "You are ".$this->Format($this->GetUserName()); #i18n
}
?>




{{wikkaname}}

Prints the name of the current Wikka: Wikka

<?php
echo $this->config['wakka_name'];
?>



{{wikkaversion}}

Prints the current wikka version: n/a

<?php
/**
 * Print current Wikka version.
 */

echo $this->VERSION;
?>


...



{{system}}

Prints system information about the system Wikka is running on:
{{system show="os"}} - prints the operating system information
{{system show="machine"}} - prints information about the machine
{{system show="host"}} - prints information about the host
{{system}} - prints all of the above


<?php
/**
 * Prints information about the system Wikka is running on.
 *
 * Syntax:
 *  {{system [show="OS|machine|host"]}}
 *
 * @package     Actions
 * @subpackage  SysInfo
 * @name        Systedm
 *
 * @author      {@link http://wikka.jsnx.com/JavaWoman JavaWoman}
 * @copyright   Copyright © 2005, Marjolein Katsma
 * @license     http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
 * @since       Wikka 1.1.6.0 ???
 *
 * @input       string  $show   optional: what type of system info to show (OS, machine or host);
 *              default: empty, shows all information
 */


// default
$show = '';

// get param and validation
$valid_show = array('os','machine','host');
if (is_array($vars))
{
    foreach ($vars as $param => $value)
    {
        switch ($param)
        {
            case 'show':
                if (in_array($value, $valid_show)) $show = strtolower($value);
                break;
        }
    }
}

// get data
$host       = php_uname('n');
$os         = php_uname('s');
$release    = php_uname('r');
$version    = php_uname('v');
$machine    = php_uname('m');

// build output
$out = '';
switch ($show)
{
    case '':
        if (isset($os)) $out .= $os.' ';
        if (isset($release)) $out .= $release.' ';
        if (isset($version)) $out .= $version.' ';
        if (isset($machine)) $out .= $machine.' ';
        if (isset($host)) $out .= '('.$host.')';
        break;
    case 'os':
        if (isset($os)) $out .= $os.' ';
        if (isset($release)) $out .= $release.' ';
        if (isset($version)) $out .= $version.' ';
        break;
    case 'machine':
        if (isset($machine)) $out .= $machine.' ';
        break;
    case 'host':
        if (isset($host)) $out .= $host.' ';
        break;
}

// show result
echo trim($out);
?>


Installed as a beta feature on this site.

--JavaWoman


CategoryDevelopmentActions CategoryDevelopmentTest
There are 18 comments on this page. [Show comments]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki