Revision [16744]

This is an old revision of LinkManager made by OrpN0t on 2007-05-31 10:43:48.

 


The system currently:

  1. Detects whenever a page mentions its name
  1. Detects whenever a page stops mentioning its name
  1. Allows admins to create "link groups"
  1. Allows managers to move links between "link groups" with ease
  1. Allows managers to assign weights to individual links
  1. Renders "link groups" in a variety of styles
  1. Allows content of linked pages to be embedded within the calling page

The Data Model


you may have to replace wikka_ with your used prefix --NilsLindenberg

CREATE TABLE `wikka_link_manager_groups` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(100) NOT NULL default '',
  `description` mediumtext,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `name` (`name`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;

CREATE TABLE `wikka_link_manager_links` (
  `link_id` int(11) NOT NULL auto_increment,
  `this_tag` varchar(75) NOT NULL default '',
  `page_tag` varchar(75) NOT NULL default '',
  `link_group_id` int(11) default NULL,
  `weight` int(11) default NULL,
  PRIMARY KEY  (`link_id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;


The PHP Code


I've found that it's convenient to keep a "common settings" file in the actions directory to store variables shared between actions and handlers. In my setup, I call it "common.ini.php". Here is the code:

<?php
// all
$base_url = 'http://localhost/wikka/wikka.php';
$page_var = 'wakka';

// linkmanager.php
$table_link_groups = $this->config['table_prefix'] . 'link_manager_groups';
$table_links = $this->config['table_prefix'] . 'link_manager_links';
$table_pages = $this->config['table_prefix'] . 'pages';
?>


Next up is the "linkmanager.php" file, which should also be saved in the actions directory...

%%(php)
<?php

include('actions/common.ini.php');

$is_admin = $this->IsAdmin();
$has_access = $this->HasAccess('write');

if ($has_access)
{
if (isset($_POST['update_links']))
{
mysql_query("DELETE FROM $table_links WHERE this_tag = '$this->tag'");
$links_to_move = isset($_POST['selected_links']) ? $_POST['selected_links'] : array();
if (isset($_POST['link_weights']))
{
foreach ($_POST['link_weights'] as $page_tag => $link_weight)
{
if (empty($link_weight)) $link_weight = 'NULL';
if (isset($links_to_move[$page_tag]))
{
$link_group_id = $_POST['group_select'];
unset($links_to_move[$page_tag]);
}
else
{
$link_group_id = isset($_POST['link_group_ids']) ? $_POST['link_group_ids'][$page_tag] : ;
}
mysql_query("INSERT INTO $table_links (this_tag, page_tag, link_group_id, weight) VALUES ('$this->tag', '$page_tag', $link_group_id, $link_weight)");
}
}
if (count($links_to_move)
There are 8 comments on this page. [Show comments]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki