plugins/Linkchomper.php
author Dan
Fri, 17 Oct 2008 22:04:53 -0400
changeset 0 df77b4db90d7
child 1 1666d776fa27
permissions -rw-r--r--
First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
     1
<?php
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
     2
/*
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
     3
Plugin Name: Linkchomper
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
     4
Plugin URI: http://enanocms.org/Linkchomper
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
     5
Description: Allows you to add custom links to the Links section of the sidebar. Includes click-tracking functionality.
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
     6
Author: Dan Fuhry
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
     7
Version: 0.1 beta 1
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
     8
Author URI: http://enanocms.org/
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
     9
*/
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    10
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    11
/*
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    12
 * Linkchomper for Enano CMS
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    13
 * Version 0.1 beta 1
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    14
 * Copyright (C) 2006-2007 Dan Fuhry
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    15
 *
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    16
 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    17
 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    18
 *
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    19
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    20
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    21
 */
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    22
 
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    23
global $db, $session, $paths, $template, $plugins; // Common objects
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    24
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    25
// Constants
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    26
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    27
define('LC_LINK_RAW', 1);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    28
define('LC_LINK_TRACK_CLICKS', 2);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    29
define('LC_LINK_DISABLED', 4);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    30
define('LC_LINK_INNER_IMAGE', 8);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    31
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    32
define('LC_EDIT', 1);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    33
define('LC_CREATE', 2);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    34
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    35
if ( !$version = getConfig('linkchomper_version') )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    36
{
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    37
  // Install the table
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    38
  $q = $db->sql_query('CREATE TABLE '.table_prefix.'linkchomper(
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    39
      link_id mediumint(8) NOT NULL auto_increment,
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    40
      link_name varchar(255) NOT NULL,
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    41
      link_href text NOT NULL,
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    42
      link_inner_html text NOT NULL,
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    43
      link_before_html text NOT NULL,
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    44
      link_after_html text NOT NULL,
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    45
      link_flags tinyint(1) NOT NULL DEFAULT 0,
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    46
      link_clicks bigint(15) NOT NULL DEFAULT 0,
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    47
      link_order mediumint(8) NOT NULL DEFAULT 0,
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    48
      PRIMARY KEY ( link_id )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    49
    );');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    50
  if ( !$q )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    51
  {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    52
    // Prevent Linkchomper from loading again
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    53
    $plugin_key = 'plugin_' . basename(__FILE__);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    54
    setConfig($plugin_key, '0');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    55
    $db->_die('The error occurred during an attempt to create the table for Linkchomper. For your site\'s protection, Linkchomper has disabled itself. It can be re-enabled in the administration panel.');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    56
  }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    57
  setConfig('linkchomper_version', '0.1b1');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    58
}
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    59
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    60
// Hook into the template compiler
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    61
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    62
$plugins->attachHook('links_widget', 'linkchomper_generate_html($ob);');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    63
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    64
// Add our link tracking page
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    65
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    66
$plugins->attachHook('base_classes_initted', '
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    67
  global $paths;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    68
    $paths->add_page(Array(
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    69
      \'name\'=>\'LinkChomper click tracker\',
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    70
      \'urlname\'=>\'LCClick\',
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    71
      \'namespace\'=>\'Special\',
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    72
      \'special\'=>0,\'visible\'=>0,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    73
      ));
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    74
    $paths->add_page(Array(
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    75
      \'name\'=>\'Administration\',
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    76
      \'urlname\'=>\'Linkchomper\',
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    77
      \'namespace\'=>\'Admin\',
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    78
      \'special\'=>0,\'visible\'=>0,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    79
      ));
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    80
    $paths->addAdminNode(\'Plugin configuration\', \'Linkchomper manager\', \'Linkchomper\');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    81
  ');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    82
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    83
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    84
// Function to generate HTML for the sidebar widget
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    85
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    86
function linkchomper_generate_html(&$links_array)
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    87
{
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    88
  global $db, $session, $paths, $template, $plugins; // Common objects
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    89
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    90
  $q = $db->sql_query('SELECT link_id, link_name, link_href, link_inner_html, link_before_html, link_after_html, link_flags FROM '.table_prefix.'linkchomper ORDER BY link_order ASC;');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    91
  if ( !$q )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    92
    $db->_die();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    93
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    94
  if ( $row = $db->fetchrow() )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    95
  {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    96
    do {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    97
      
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    98
      // Get flags
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
    99
      $flags =& $row['link_flags'];
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   100
      
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   101
      // Is this link disabled? If so, skip the whole painful process
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   102
      if ( $flags & LC_LINK_DISABLED )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   103
        continue;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   104
      
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   105
      // First check to see if the inner_html is an image URL. If so, generate a nice img tag for the inner HTML.
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   106
      if ( $flags & LC_LINK_INNER_IMAGE )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   107
      {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   108
        $row['link_inner_html'] = '<img alt="' . htmlspecialchars($row['link_name']) . '" src="' . htmlentities($row['link_inner_html']) . '" style="border-width: 0px;" />';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   109
      }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   110
      
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   111
      // If it's raw HTML, just send it through
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   112
      if ( $flags & LC_LINK_RAW )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   113
      {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   114
        $links_array[] = $row['link_before_html'] . $row['link_inner_html'] . $row['link_after_html'];
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   115
      }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   116
      // If we're supposed to track clicks, send a deceptive anchor
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   117
      else if ( $flags & LC_LINK_TRACK_CLICKS )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   118
      {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   119
        $url = makeUrlNS('Special', 'LCClick/' . $row['link_id'], false, true);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   120
        // Escape target URL for Javascript-safety
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   121
        $real_url = htmlspecialchars(str_replace(array('\\', '\'', '"'), array('\\\\', '\\\'', '\\"'), $row['link_href']));
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   122
        $link = $row['link_before_html'] . '<a href="' . $url . '" title="' . htmlspecialchars($row['link_href']) . '" onmouseover="void(window.status=\'' . $real_url . '\');" onmouseout="void(window.status=\'\');">' . $row['link_inner_html'] . '</a>' . $row['link_after_html'];
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   123
        $links_array[] = $link;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   124
      }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   125
      // None of those? OK just send a normal link
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   126
      else
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   127
      {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   128
        $url = htmlspecialchars($row['link_href']);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   129
        $link = $row['link_before_html'] . '<a href="' . $url . '">' . $row['link_inner_html'] . '</a>' . $row['link_after_html'];
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   130
        $links_array[] = $link;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   131
      }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   132
      
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   133
    } while ( $row = $db->fetchrow() );
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   134
  }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   135
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   136
  $db->free_result();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   137
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   138
}
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   139
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   140
// Special page handler for click tracker
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   141
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   142
function page_Special_LCClick()
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   143
{
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   144
  global $db, $session, $paths, $template, $plugins; // Common objects
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   145
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   146
  $link_id = ( $xx = $paths->getParam(0) ) ? intval($xx) : false;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   147
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   148
  if ( !$link_id )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   149
    die_friendly('Nice try', '<p>Hacking attempt</p>');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   150
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   151
  $q = $db->sql_query('SELECT link_href,link_flags FROM '.table_prefix.'linkchomper WHERE link_id=' . $link_id . ';');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   152
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   153
  if ( !$q )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   154
    $db->_die();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   155
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   156
  $row = $db->fetchrow();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   157
  $db->free_result();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   158
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   159
  if ( ! ( $row['link_flags'] & LC_LINK_TRACK_CLICKS ) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   160
  {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   161
    die_friendly('Nice try', '<p>This ain\'t no tracker link...</p>');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   162
  }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   163
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   164
  $q = $db->sql_query('UPDATE '.table_prefix.'linkchomper SET link_clicks=link_clicks+1 WHERE link_id=' . $link_id . ';');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   165
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   166
  if ( !$q )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   167
    $db->_die();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   168
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   169
  redirect($row['link_href'], 'Redirecting', 'Thanks for clicking the link, you are now being transferred to the destination.', 0);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   170
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   171
}
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   172
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   173
function linkchomper_admin_redirect_home($message = 'Your changes have been saved, and you will now be transferred back to the administration panel.')
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   174
{
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   175
  global $db, $session, $paths, $template, $plugins; // Common objects
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   176
  $url = makeUrlComplete('Special', 'Administration', 'module=' . $paths->nslist['Admin'] . 'Linkchomper');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   177
  redirect($url, 'Linkchomper changes saved', $message, 2);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   178
}
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   179
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   180
function page_Admin_Linkchomper()
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   181
{
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   182
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   183
  //@ini_set('display_errors', 'On') or die('Can\'t set display_errors');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   184
  //error_reporting(E_ALL);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   185
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   186
  global $db, $session, $paths, $template, $plugins; // Common objects
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   187
  if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   188
  {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   189
    echo '<h3>Error: Not authenticated</h3><p>It looks like your administration session is invalid or you are not authorized to access this administration page. Please <a href="' . makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true) . '">re-authenticate</a> to continue.</p>';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   190
    return;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   191
  }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   192
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   193
  if ( isset($_POST['action']) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   194
  {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   195
    if ( isset($_POST['action']['move_up']) || isset($_POST['action']['move_down']) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   196
    {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   197
      $direction = ( isset($_POST['action']['move_up']) ) ? 'up' : 'down';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   198
      $ordering  = ( isset($_POST['action']['move_up']) ) ? 'ASC' : 'DESC';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   199
      
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   200
      // Move an item up in the list
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   201
      // First step: Get IDs of the item to move and the item above it
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   202
      $id = array_keys($_POST['action']['move_' . $direction]);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   203
      $id = intval( $id[0] );
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   204
      if ( !$id )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   205
      {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   206
        echo 'Hacking attempt';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   207
        return false;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   208
      }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   209
      
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   210
      $q = $db->sql_query('SELECT link_id, link_name, link_order FROM '.table_prefix.'linkchomper ORDER BY link_order ' . $ordering . ';');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   211
      
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   212
      if ( !$q )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   213
        $db->_die();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   214
      
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   215
      $last_id = false;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   216
      $this_id = false;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   217
      
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   218
      $last_order = false;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   219
      $this_order = false;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   220
      
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   221
      $id_to   = false;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   222
      $id_from = false;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   223
      
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   224
      $order_to   = false;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   225
      $order_from = false;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   226
      
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   227
      while ( $row = $db->fetchrow() )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   228
      {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   229
        $this_id = $row['link_id'];
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   230
        $this_order = $row['link_order'];
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   231
        if ( $this_id == $id && $last_id === false )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   232
        {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   233
          linkchomper_admin_redirect_home('This item is already at the top or bottom of the list.');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   234
        }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   235
        else if ( $this_id == $id )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   236
        {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   237
          $id_from = $last_id;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   238
          $id_to   = $this_id;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   239
          $order_from = $this_order;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   240
          $order_to   = $last_order;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   241
          break;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   242
        }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   243
        $last_id = $this_id;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   244
        $last_order = $this_order;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   245
      }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   246
      
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   247
      unset($this_id, $this_order, $last_id, $last_order);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   248
      
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   249
      if ( $last_order === false || $this_order === false )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   250
      {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   251
        linkchomper_admin_redirect_home('Sanity check failed.');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   252
      }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   253
      
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   254
      $sql1 = 'UPDATE '.table_prefix.'linkchomper SET link_order=' . $order_to . ' WHERE link_id=' . $id_to . ';';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   255
      $sql2 = 'UPDATE '.table_prefix.'linkchomper SET link_order=' . $order_from . ' WHERE link_id=' . $id_from . ';';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   256
      
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   257
      if ( !$db->sql_query($sql1) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   258
      {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   259
        $db->_die();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   260
      }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   261
      
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   262
      if ( !$db->sql_query($sql2) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   263
      {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   264
        $db->_die();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   265
      }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   266
      
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   267
      linkchomper_admin_redirect_home('The item "' . $row['link_name'] . '" has been moved ' . $direction . '.');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   268
      
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   269
    }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   270
    else if ( isset($_POST['action']['delete']) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   271
    {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   272
      // Delete a link
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   273
      $id = array_keys($_POST['action']['delete']);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   274
      $id = intval( $id[0] );
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   275
      if ( !$id )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   276
      {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   277
        echo 'Hacking attempt';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   278
        return false;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   279
      }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   280
      $q = $db->sql_query('DELETE FROM '.table_prefix."linkchomper WHERE link_id=$id;");
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   281
      if ( !$q )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   282
        $db->_die();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   283
      
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   284
      linkchomper_admin_redirect_home('The selected link has been deleted.');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   285
    }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   286
    
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   287
    linkchomper_admin_redirect_home('Invalid or no action defined');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   288
  }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   289
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   290
  else if ( isset($_POST['stage2']) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   291
  {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   292
    $_GET['module'] = $paths->page;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   293
    $_POST['stage2_real'] = $_POST['stage2'];
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   294
    unset($_POST['stage2']);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   295
    page_Special_Administration();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   296
    return true;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   297
  }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   298
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   299
  else if ( isset($_POST['stage2_real']) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   300
  {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   301
  /*
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   302
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   303
  TODO:
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   304
  The idea here is to build a template-based unified edit form that will be used both for creating and editing links. Make it have
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   305
  intelligent auto-hiding/auto-(un)checking elements and make it use the standard flags field.
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   306
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   307
  */
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   308
    // allow breaking out
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   309
    switch(true){case true:
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   310
      $stage2 =& $_POST['stage2_real'];
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   311
      $err_and_revert = array(
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   312
        'error' => false
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   313
      );
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   314
      if ( isset($stage2['delete']) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   315
      {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   316
        $id = array_keys($stage2['delete']);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   317
        $id = intval( $id[0] );
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   318
        if ( !$id )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   319
        {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   320
          echo 'Hacking attempt';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   321
          return false;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   322
        }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   323
        echo '<form action="' . makeUrlNS('Admin', 'Linkchomper') . '" method="post" enctype="multipart/form-data">';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   324
        echo '<div class="tblholder">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   325
                <table border="0" cellspacing="1" cellpadding="4">';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   326
        echo '  <tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   327
                  <th>Confirm deletion</th>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   328
                </tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   329
                <td class="row1" style="text-align: center; line-height: 40px;">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   330
                  Are you sure you want to permanently delete this link?
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   331
                </td>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   332
                <tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   333
                  <th class="subhead">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   334
                    <input type="submit" name="action[delete]['.$id.']" value="Yes, delete link" />
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   335
                    <input type="submit" name="stage2[cancel]" value="Cancel" />
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   336
                  </th>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   337
                </tr>';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   338
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   339
        echo '  </table>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   340
              </div>';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   341
        echo '</form>';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   342
      }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   343
      else if ( isset($stage2['create_new']) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   344
      {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   345
        $editor = new LinkchomperFormGenerator();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   346
        $editor->echo_html();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   347
      }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   348
      else if ( isset($stage2['edit']) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   349
      {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   350
        $id = array_keys($stage2['edit']);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   351
        $id = intval( $id[0] );
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   352
        if ( !$id )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   353
        {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   354
          echo 'Hacking attempt';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   355
          return false;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   356
        }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   357
        $q = $db->sql_query('SELECT * FROM '.table_prefix."linkchomper WHERE link_id=$id;");
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   358
        if ( !$q )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   359
          $db->_die();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   360
        if ( $db->numrows() < 1 )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   361
        {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   362
          echo "Can't find link: $id";
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   363
          $db->free_result();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   364
        }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   365
        else
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   366
        {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   367
          $row = $db->fetchrow();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   368
          $db->free_result();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   369
          $editor = new LinkchomperFormGenerator();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   370
          $editor->track_clicks = ( $row['link_flags'] & LC_LINK_TRACK_CLICKS );
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   371
          $editor->raw_html = ( $row['link_flags'] & LC_LINK_RAW );
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   372
          $editor->link_flag_image = ( $row['link_flags'] & LC_LINK_INNER_IMAGE );
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   373
          $editor->link_disabled = ( $row['link_flags'] & LC_LINK_DISABLED );
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   374
          $editor->link_target = $row['link_href'];
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   375
          $editor->link_name = $row['link_name'];
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   376
          $editor->mode = LC_EDIT;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   377
          $editor->inner_html = $row['link_inner_html'];
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   378
          $editor->before_html = $row['link_before_html'];
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   379
          $editor->after_html = $row['link_after_html'];
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   380
          $editor->link_id = $row['link_id'];
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   381
          $editor->echo_html();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   382
        }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   383
      }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   384
      else if ( isset($stage2['create_new_finish']) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   385
      {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   386
        $flags = 0;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   387
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   388
        // Validation
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   389
        $errors = array();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   390
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   391
        $link_name = trim($_POST['link_name']);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   392
        if ( empty($link_name) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   393
          $errors[] = 'Please enter a name for your link.';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   394
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   395
        if ( isset($_POST['raw_html']) && isset($_POST['track_clicks']) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   396
          $errors[] = 'Raw blocks cannot be used with clicktracking.';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   397
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   398
        $link_target = trim($_POST['link_target']);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   399
        if ( empty($link_target) && !isset($_POST['raw_html']) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   400
          $errors[] = 'Please enter a target for your link.';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   401
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   402
        if ( $_POST['link_flag_img'] == '1' )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   403
        {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   404
          $inner_html = trim($_POST['link_img_path']);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   405
          if ( empty($inner_html) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   406
            $errors[] = 'Please enter a path or URL to an image file.';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   407
        }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   408
        else
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   409
        {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   410
          $inner_html = trim($_POST['link_inner_html']);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   411
          if ( empty($inner_html) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   412
            $errors[] = 'Please enter some content to go inside your link.';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   413
        }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   414
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   415
        if ( count($errors) > 0 )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   416
        {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   417
          $err_and_revert['error'] = true;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   418
          $err_and_revert['message'] = implode("<br />\n        ", $errors);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   419
        }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   420
        else
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   421
        {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   422
          if ( isset($_POST['link_disabled']) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   423
            $flags = $flags | LC_LINK_DISABLED;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   424
          if ( $_POST['link_flag_img'] == '1' )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   425
            $flags = $flags | LC_LINK_INNER_IMAGE;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   426
          if ( isset($_POST['raw_html']) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   427
            $flags = $flags | LC_LINK_RAW;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   428
          if ( isset($_POST['track_clicks']) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   429
            $flags = $flags | LC_LINK_TRACK_CLICKS;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   430
          
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   431
          $before_html = strval(trim($_POST['link_before_html']));
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   432
          $after_html  = strval(trim($_POST['link_after_html']));
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   433
          
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   434
          if ( !$session->get_permissions('php_in_pages') )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   435
          {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   436
            // Not allowed to embed PHP and Javascript
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   437
            $before_html = sanitize_html($before_html);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   438
            $after_html  = sanitize_html($after_html);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   439
            $inner_html  = sanitize_html($inner_html);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   440
          }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   441
          
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   442
          $sanitized = array(
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   443
              'link_name' => $db->escape($link_name),
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   444
              'link_target' => $db->escape($link_target),
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   445
              'link_inner_html' => $db->escape($inner_html),
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   446
              'link_before_html' => $db->escape($before_html),
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   447
              'link_after_html' => $db->escape($after_html)
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   448
            );
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   449
          
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   450
          $sql = "INSERT INTO ".table_prefix."linkchomper(link_name, link_href, link_inner_html, link_before_html, link_after_html, link_flags, link_order) VALUES('{$sanitized['link_name']}','{$sanitized['link_target']}','{$sanitized['link_inner_html']}','{$sanitized['link_before_html']}','{$sanitized['link_after_html']}', $flags, ".LC_ADMIN_ORDER_LAST.");";
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   451
          if ( !$db->sql_query($sql) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   452
            $db->_die();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   453
          
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   454
          echo '<div class="info-box">Link created.</div>';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   455
          break;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   456
        }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   457
      }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   458
      else if ( isset($stage2['edit_finish']) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   459
      {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   460
        $flags = 0;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   461
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   462
        // Validation
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   463
        $errors = array();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   464
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   465
        $link_name = trim($_POST['link_name']);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   466
        if ( empty($link_name) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   467
          $errors[] = 'Please enter a name for your link.';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   468
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   469
        if ( isset($_POST['raw_html']) && isset($_POST['track_clicks']) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   470
          $errors[] = 'Raw blocks cannot be used with clicktracking.';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   471
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   472
        $link_target = trim($_POST['link_target']);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   473
        if ( empty($link_target) && !isset($_POST['raw_html']) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   474
          $errors[] = 'Please enter a target for your link.';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   475
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   476
        if ( $_POST['link_flag_img'] == '1' )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   477
        {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   478
          $inner_html = trim($_POST['link_img_path']);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   479
          if ( empty($inner_html) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   480
            $errors[] = 'Please enter a path or URL to an image file.';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   481
        }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   482
        else
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   483
        {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   484
          $inner_html = trim($_POST['link_inner_html']);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   485
          if ( empty($inner_html) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   486
            $errors[] = 'Please enter some content to go inside your link.';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   487
        }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   488
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   489
        $link_id = intval($_POST['link_id']);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   490
        if ( $link_id < 1 )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   491
          $errors[] = 'Unable to obtain link ID';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   492
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   493
        if ( count($errors) > 0 )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   494
        {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   495
          $err_and_revert['error'] = true;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   496
          $err_and_revert['message'] = implode("<br />\n        ", $errors);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   497
        }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   498
        else
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   499
        {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   500
          if ( isset($_POST['link_disabled']) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   501
            $flags = $flags | LC_LINK_DISABLED;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   502
          if ( $_POST['link_flag_img'] == '1' )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   503
            $flags = $flags | LC_LINK_INNER_IMAGE;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   504
          if ( isset($_POST['raw_html']) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   505
            $flags = $flags | LC_LINK_RAW;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   506
          if ( isset($_POST['track_clicks']) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   507
            $flags = $flags | LC_LINK_TRACK_CLICKS;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   508
          
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   509
          $before_html = strval(trim($_POST['link_before_html']));
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   510
          $after_html  = strval(trim($_POST['link_after_html']));
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   511
          
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   512
          if ( !$session->get_permissions('php_in_pages') )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   513
          {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   514
            // Not allowed to embed PHP and Javascript
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   515
            $before_html = sanitize_html($before_html);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   516
            $after_html  = sanitize_html($after_html);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   517
            $inner_html  = sanitize_html($inner_html);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   518
          }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   519
          
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   520
          $sanitized = array(
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   521
              'link_name' => $db->escape($link_name),
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   522
              'link_target' => $db->escape($link_target),
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   523
              'link_inner_html' => $db->escape($inner_html),
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   524
              'link_before_html' => $db->escape($before_html),
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   525
              'link_after_html' => $db->escape($after_html)
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   526
            );
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   527
          
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   528
          $sql = "UPDATE ".table_prefix."linkchomper SET link_name='{$sanitized['link_name']}',link_href='{$sanitized['link_target']}',link_inner_html='{$sanitized['link_inner_html']}',link_before_html='{$sanitized['link_before_html']}',link_after_html='{$sanitized['link_after_html']}',link_flags=$flags WHERE link_id=$link_id;";
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   529
          if ( !$db->sql_query($sql) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   530
            $db->_die();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   531
          
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   532
          echo '<div class="info-box">Your changes have been saved.</div>';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   533
          break;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   534
        }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   535
      }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   536
      else if ( isset($stage2['cancel']) )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   537
      {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   538
        break;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   539
      }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   540
      else
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   541
      {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   542
        echo 'Undefined Superform handler:<pre>' . htmlspecialchars(print_r($stage2, true)) . '</pre>';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   543
      }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   544
      if ( $err_and_revert['error'] )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   545
      {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   546
        $editor = new LinkchomperFormGenerator();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   547
        $editor->error = $err_and_revert['message'];
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   548
        $editor->track_clicks = ( isset($_POST['track_clicks']) && !isset($_POST['raw_html']) );
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   549
        $editor->raw_html = ( isset($_POST['raw_html']) && !isset($_POST['track_clicks']) );
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   550
        $editor->link_flag_image = ( $_POST['link_flag_img'] == '1' );
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   551
        $editor->link_disabled = ( isset($_POST['link_disabeld']) );
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   552
        $editor->link_target = $_POST['link_target'];
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   553
        $editor->link_name = $_POST['link_name'];
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   554
        $editor->mode = ( isset($stage2['create_new_finish']) ) ? LC_CREATE : LC_EDIT;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   555
        $editor->inner_html = $_POST['link_inner_html'];
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   556
        $editor->before_html = $_POST['link_before_html'];
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   557
        $editor->after_html = $_POST['link_after_html'];
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   558
        $editor->link_id = ( isset($stage2['create_new_finish']) ) ? -1 : intval($_POST['link_id']);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   559
        $editor->echo_html();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   560
      }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   561
      return true;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   562
    }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   563
  }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   564
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   565
  echo <<<EOF
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   566
    <h3>Linkchomper link manager</h3>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   567
    <p>Linkchomper is a plugin that allows you to add custom content to the "Links" block on your sidebar. You can add tracking links, raw HTML, or just normal links.</p>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   568
EOF;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   569
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   570
  echo '<form name="main" action="'.makeUrlNS('Admin', 'Linkchomper').'" method="post">';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   571
  echo '<div class="tblholder">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   572
        <table border="0" cellspacing="1" cellpadding="4">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   573
          <tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   574
            <th>Link name</th>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   575
            <th>Link target</th>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   576
            <th>Clicks</th>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   577
            <th colspan="4" style="width: 50px;">Admin</th>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   578
          </tr>';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   579
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   580
  $q = $db->sql_query('SELECT link_id, link_name, link_href, link_flags, link_clicks, link_order FROM '.table_prefix.'linkchomper ORDER BY link_order ASC;');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   581
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   582
  if ( !$q )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   583
    $db->_die();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   584
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   585
  $num_rows = $db->numrows();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   586
  $i = 0;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   587
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   588
  if ( $row = $db->fetchrow() )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   589
  {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   590
    do {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   591
      echo '<tr>';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   592
      echo '<td class="row1">' . htmlspecialchars($row['link_name']) . '</td>';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   593
      echo '<td class="row2">' . ( ( $row['link_flags'] & LC_LINK_RAW ) ? '&lt;Raw HTML block&gt;' : '<a href="' . htmlspecialchars($row['link_href']) . '" onclick="window.open(this.href); return false;">' . htmlspecialchars($row['link_href']) . '</a>' ) . '</td>';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   594
      echo '<td class="row1" style="text-align: center;">' . ( ( $row['link_flags'] & LC_LINK_TRACK_CLICKS ) ? $row['link_clicks'] : '' ) . '</td>';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   595
      // Admin actions
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   596
      echo '<td class="row2" style="text-align: center;"><button ' . ( ( $i == 0 ) ? 'disabled="disabled"' : '' ) . ' name="action[move_up][' . $row['link_id'] . ']">&uarr;</button></td>';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   597
      echo '<td class="row1" style="text-align: center;"><button ' . ( ( $i + 1 == $num_rows ) ? 'disabled="disabled"' : '' ) . ' name="action[move_down][' . $row['link_id'] . ']">&darr;</button></td>';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   598
      echo '<td class="row2" style="text-align: center;"><button name="stage2[edit][' . $row['link_id'] . ']">Edit</button></td>';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   599
      echo '<td class="row1" style="text-align: center;"><button name="stage2[delete][' . $row['link_id'] . ']">Delete</button></td>';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   600
      echo '</tr>';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   601
      $i++;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   602
    } while ( $row = $db->fetchrow() );
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   603
  }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   604
  else
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   605
  {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   606
    echo '<tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   607
            <td class="row1" colspan="7">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   608
              You haven\'t created any links yet.
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   609
            </td>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   610
          </tr>';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   611
  }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   612
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   613
  echo '<tr style="text-align: center;">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   614
          <th class="subhead" colspan="7">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   615
            <button name="stage2[create_new]"><b>Create new link</b></button>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   616
          </th>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   617
        </tr>';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   618
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   619
  echo '</table></div>';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   620
  echo '</form>';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   621
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   622
  // */
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   623
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   624
}
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   625
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   626
// Hopefully no one will ever get 4 billion links in their sidebar.
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   627
define('LC_ADMIN_ORDER_LAST', ( pow(2, 33)-3 ));
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   628
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   629
/**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   630
 * Class to generate edit forms for Linkchomper links.
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   631
 * @package Enano
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   632
 * @subpackage Linkchomper
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   633
 * @license GNU General Public License <http://www.gnu.org/licenses/gpl.html>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   634
 */
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   635
 
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   636
class LinkchomperFormGenerator
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   637
{
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   638
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   639
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   640
   * What this editor instance does, create or edit. Should be LC_EDIT or LC_CREATE.
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   641
   * @var int
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   642
   */
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   643
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   644
  var $mode = LC_CREATE;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   645
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   646
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   647
   * The name of the link.
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   648
   * @var string
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   649
   */
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   650
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   651
  var $link_name = '';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   652
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   653
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   654
   * Link ID - only used when editing
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   655
   * @var int
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   656
   */
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   657
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   658
  var $link_id = -1;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   659
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   660
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   661
   * Flag for raw HTML switch
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   662
   * @var bool
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   663
   */
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   664
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   665
  var $raw_html = false;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   666
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   667
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   668
   * Flag for inner HTML field is an image URL
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   669
   * @var bool
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   670
   */
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   671
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   672
  var $image_url = false;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   673
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   674
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   675
   * Flag to determine if clicks will be tracked
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   676
   * @var bool
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   677
   */
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   678
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   679
  var $track_clicks = false;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   680
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   681
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   682
   * "Appear after" (link order)
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   683
   * @var int The link ID to appear after
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   684
   */
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   685
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   686
  var $appear_after = LC_ADMIN_ORDER_LAST;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   687
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   688
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   689
   * Link target.
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   690
   * @var string
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   691
   */
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   692
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   693
  var $link_target = 'http://www.example.com/';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   694
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   695
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   696
   * If the image flag is on, this should be set to true. Should only be used while editing.
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   697
   * @var bool
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   698
   */
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   699
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   700
  var $link_flag_image = false;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   701
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   702
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   703
   * Set to true if the link is disabled (hidden)
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   704
   * @var bool
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   705
   */
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   706
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   707
  var $link_disabled = false;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   708
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   709
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   710
   * The inner HTML (or image URL)
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   711
   * @var string
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   712
   */
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   713
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   714
  var $inner_html = '';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   715
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   716
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   717
   * HTML shown before the link
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   718
   * @var string
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   719
   */
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   720
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   721
  var $before_html = '';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   722
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   723
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   724
   * HTML shown after the link
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   725
   * @var string
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   726
   */
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   727
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   728
  var $after_html = '';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   729
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   730
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   731
   * Unique identifier used for Javascript bits
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   732
   * @var string
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   733
   * @access private
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   734
   */
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   735
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   736
  var $uuid = '';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   737
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   738
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   739
   * Error message to show at the top of the form. Default is false for no error.
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   740
   * @var string
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   741
   */
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   742
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   743
  var $error = '';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   744
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   745
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   746
   * Constructor.
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   747
   */
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   748
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   749
  function __construct()
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   750
  {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   751
    $uuid = md5( mt_rand() . microtime() . @file_get_contents('/proc/uptime') /* That last one's just for fun ;-) */ );
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   752
    if ( file_exists('/dev/urandom') )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   753
    {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   754
      $f = @fopen('/dev/urandom', 'r');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   755
      if ( $f )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   756
      {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   757
        $random = fread($f, 16);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   758
        $random = hexencode($random, '', '');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   759
        fclose($f);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   760
        $uuid = $random;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   761
      }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   762
    }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   763
    $this->uuid = $uuid;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   764
  }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   765
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   766
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   767
   * PHP 4 constructor
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   768
   */
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   769
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   770
  function LinkchomperFormGenerator()
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   771
  {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   772
    $this->__construct();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   773
  }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   774
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   775
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   776
   * Generates the ready to use HTML.
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   777
   * @return string
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   778
   */
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   779
   
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   780
  function get_html()
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   781
  {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   782
    global $db, $session, $paths, $template, $plugins; // Common objects
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   783
    
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   784
    if ( !empty($template->theme) && file_exists(ENANO_ROOT . '/themes/' . $template->theme . '/linkchomper_editor.tpl') )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   785
    {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   786
      $parser = $template->makeParser('linkchomper_editor.tpl');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   787
    }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   788
    else
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   789
    {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   790
      $tpl_code = <<<EOF
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   791
      <!-- start of Linkchomper editor -->
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   792
      <script type="text/javascript">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   793
        // <![CDATA[
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   794
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   795
        // Helper javascript code (uuid={UUID})
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   796
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   797
        var check_box_raw_{UUID} = function()
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   798
        {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   799
          var source = document.getElementById('raw_{UUID}');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   800
          if ( source.checked )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   801
          {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   802
            var target = document.getElementById('trk_{UUID}');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   803
            target.checked = false;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   804
            target.disabled = true;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   805
            target = document.getElementById('lc_tr_url_{UUID}');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   806
            target.style.display = 'none';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   807
            target = document.getElementById('lc_tr_beforehtml_{UUID}');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   808
            target.style.display = 'none';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   809
            target = document.getElementById('lc_tr_afterhtml_{UUID}');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   810
            target.style.display = 'none';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   811
          }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   812
          else
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   813
          {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   814
            var target = document.getElementById('trk_{UUID}');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   815
            target.disabled = false;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   816
            target = document.getElementById('lc_tr_url_{UUID}');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   817
            target.style.display = null;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   818
            target = document.getElementById('lc_tr_beforehtml_{UUID}');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   819
            target.style.display = null;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   820
            target = document.getElementById('lc_tr_afterhtml_{UUID}');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   821
            target.style.display = null;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   822
          }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   823
        }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   824
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   825
        var check_box_trk_{UUID} = function()
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   826
        {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   827
          var source = document.getElementById('trk_{UUID}');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   828
          if ( source.checked )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   829
          {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   830
            var target = document.getElementById('raw_{UUID}');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   831
            target.checked = false;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   832
            target.disabled = true;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   833
          }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   834
          else
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   835
          {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   836
            var target = document.getElementById('raw_{UUID}');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   837
            target.disabled = false;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   838
          }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   839
        }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   840
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   841
        var radio_set_image_{UUID} = function()
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   842
        {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   843
          var source = document.getElementById('is_img_{UUID}');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   844
          if ( source.checked )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   845
          {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   846
            var target;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   847
            target = document.getElementById('inner_html_{UUID}');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   848
            target.style.display = 'none';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   849
            target = document.getElementById('inner_img_{UUID}');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   850
            target.style.display = 'block';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   851
          }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   852
          else
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   853
          {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   854
            var target;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   855
            target = document.getElementById('inner_html_{UUID}');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   856
            target.style.display = 'block';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   857
            target = document.getElementById('inner_img_{UUID}');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   858
            target.style.display = 'none';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   859
          }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   860
        }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   861
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   862
        addOnloadHook(check_box_raw_{UUID});
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   863
        addOnloadHook(check_box_trk_{UUID});
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   864
        addOnloadHook(radio_set_image_{UUID});
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   865
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   866
        // ]]>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   867
      </script>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   868
      <!-- BEGIN show_error -->
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   869
      <div class="error-box">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   870
        <b>The following error occurred while <!-- BEGIN mode_is_create -->creating the link<!-- BEGINELSE mode_is_create -->saving your changes<!-- END mode_is_create -->:</b><br />
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   871
        {ERROR_MESSAGE}
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   872
      </div>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   873
      <!-- END show_error -->
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   874
      <form action="{FORM_ACTION}" method="post" enctype="multipart/form-data">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   875
        <div class="tblholder">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   876
          <table border="0" cellspacing="1" cellpadding="4">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   877
            <tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   878
              <th colspan="2">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   879
                <!-- BEGIN mode_is_create -->
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   880
                  Create new link
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   881
                <!-- END mode_is_create -->
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   882
                <!-- BEGIN mode_is_edit -->
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   883
                  Editing link: {LINK_NAME}
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   884
                <!-- END mode_is_edit -->
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   885
              </th>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   886
            </tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   887
            <tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   888
              <td class="row1" style="width: 33%;">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   889
                <label for="ln_{UUID}">Link title:</label><br />
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   890
                <small>This is only used "internally" for your convenience - the user never sees this value.</small>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   891
              </td>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   892
              <td class="row2">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   893
                <input id="ln_{UUID}" name="link_name" value="{LINK_NAME}" type="text" size="50" />
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   894
              </td>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   895
            </tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   896
            <tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   897
              <td class="row1" style="width: 33%;">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   898
                Link options:
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   899
              </td>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   900
              <td class="row2">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   901
                <p><label><input type="checkbox" name="raw_html" id="raw_{UUID}" onclick="check_box_raw_{UUID}();" <!-- BEGIN raw_html -->checked="checked"<!-- END raw_html --> /> Use my own custom HTML here and bypass Linkchomper's processor</label></p>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   902
                <p><label><input type="checkbox" name="track_clicks" id="trk_{UUID}" onclick="check_box_trk_{UUID}();" <!-- BEGIN track_clicks -->checked="checked"<!-- END track_clicks --> /> Track clicks</label></p>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   903
                <p><label><input type="checkbox" name="link_disabled" <!-- BEGIN link_disabled -->checked="checked" <!-- END link_disabled -->/> Link is disabled</label></p>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   904
              </td>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   905
            </tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   906
            <tr id="lc_tr_url_{UUID}">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   907
              <td class="row1">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   908
                Link target:<br />
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   909
                <small>This should be in the format of http://url.</small>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   910
              </td>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   911
              <td class="row2">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   912
                <input type="text" name="link_target" value="{LINK_TARGET}" size="50" />
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   913
              </td>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   914
            </tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   915
            <tr id="lc_tr_innerhtml_{UUID}">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   916
              <td class="row1">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   917
                Content inside link:<br />
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   918
                <small>You may use HTML here.</small>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   919
              </td>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   920
              <td class="row2">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   921
                Use inside link: <label><input id="is_img_{UUID}" onclick="radio_set_image_{UUID}();" type="radio" name="link_flag_img" value="1" <!-- BEGIN link_flag_image -->checked="checked" <!-- END link_flag_image -->/> Image</label> <label><input type="radio" onclick="radio_set_image_{UUID}();" name="link_flag_img" value="0" <!-- BEGINNOT link_flag_image -->checked="checked" <!-- END link_flag_image -->/> Text or HTML</label>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   922
                <div id="inner_img_{UUID}" style="margin-top: 10px;">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   923
                  Path to image, relative or absolute:<br />
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   924
                  <input type="text" size="50" name="link_img_path" value="<!-- BEGIN link_flag_image -->{HTML_INNER}<!-- END link_flag_image -->" onblur="document.getElementById('link_img_preview_{UUID}').src = this.value;" /><br />
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   925
                  <br />
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   926
                  <img alt=" " src="about:blank" id="link_img_preview_{UUID}" />
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   927
                </div>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   928
                <div id="inner_html_{UUID}" style="margin-top: 10px;">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   929
                  {TEXTAREA_HTML_INNER}
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   930
                </div>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   931
              </td>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   932
            </tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   933
            <tr id="lc_tr_beforehtml_{UUID}">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   934
              <td class="row1">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   935
                Text <u>before</u> link:<br />
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   936
                <small>You may use HTML here.</small>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   937
              </td>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   938
              <td class="row2">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   939
                {TEXTAREA_HTML_BEFORE}
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   940
              </td>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   941
            </tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   942
            <tr id="lc_tr_afterhtml_{UUID}">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   943
              <td class="row1">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   944
                Text <u>after</u> link:<br />
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   945
                <small>You may use HTML here.</small>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   946
              </td>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   947
              <td class="row2">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   948
                {TEXTAREA_HTML_AFTER}
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   949
              </td>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   950
            </tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   951
            <tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   952
              <th class="subhead" colspan="2">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   953
                <!-- BEGIN mode_is_create -->
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   954
                  <input type="submit" name="stage2[create_new_finish]" value="Create link" />
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   955
                <!-- END mode_is_create -->
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   956
                <!-- BEGIN mode_is_edit -->
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   957
                  <input type="submit" name="stage2[edit_finish]" value="Save changes" />
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   958
                <!-- END mode_is_edit -->
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   959
                <input type="submit" name="stage2[cancel]" value="Cancel" style="font-weight: normal;" />
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   960
              </th>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   961
            </tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   962
          </table>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   963
        </div>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   964
        <!-- BEGIN mode_is_edit -->
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   965
        <input type="hidden" name="link_id" value="{LINK_ID}" />
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   966
        <!-- END mode_is_edit -->
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   967
      </form>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   968
      <!-- finish of Linkchomper editor -->
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   969
EOF;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   970
      $parser = $template->makeParserText($tpl_code);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   971
    }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   972
    
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   973
    $form_action = makeUrlNS('Admin', 'Linkchomper');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   974
    
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   975
    $sanitized = array(
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   976
        'name' => &$this->link_name,
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   977
        'target' => &$this->link_target,
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   978
        'inner' => &$this->inner_html,
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   979
        'before' => &$this->before_html,
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   980
        'after' => &$this->after_html
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   981
      );
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   982
    
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   983
    foreach ( $sanitized as $id => $item )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   984
    {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   985
      unset($sanitized[$id]);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   986
      $sanitized[$id] = htmlspecialchars($item);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   987
    }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   988
    
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   989
    $textarea_html_inner  = $template->tinymce_textarea('link_inner_html',  $sanitized['inner'],  10, 60);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   990
    $textarea_html_before = $template->tinymce_textarea('link_before_html', $sanitized['before'], 10, 60);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   991
    $textarea_html_after  = $template->tinymce_textarea('link_after_html',  $sanitized['after'],  10, 60);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   992
    
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   993
    if ( $this->mode == LC_EDIT )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   994
    {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   995
      $parser->assign_vars(array(
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   996
          'LINK_ID' => $this->link_id
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   997
        ));
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   998
    }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   999
    
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1000
    $parser->assign_vars(array(
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1001
        'UUID' => $this->uuid,
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1002
        'FORM_ACTION' => $form_action,
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1003
        'LINK_NAME' => $sanitized['name'],
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1004
        'LINK_TARGET' => $sanitized['target'],
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1005
        'HTML_INNER' => $sanitized['inner'],
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1006
        'HTML_BEFORE' => $sanitized['before'],
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1007
        'HTML_AFTER' => $sanitized['after'],
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1008
        'TEXTAREA_HTML_INNER' => $textarea_html_inner,
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1009
        'TEXTAREA_HTML_BEFORE' => $textarea_html_before,
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1010
        'TEXTAREA_HTML_AFTER' => $textarea_html_after,
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1011
        'ERROR_MESSAGE' => strval($this->error)
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1012
      ));
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1013
    $parser->assign_bool(array(
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1014
        'raw_html' => $this->raw_html,
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1015
        'track_clicks' => $this->track_clicks,
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1016
        'mode_is_create' => ( $this->mode == LC_CREATE ),
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1017
        'mode_is_edit' => ( $this->mode == LC_EDIT ),
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1018
        'show_error' => ( !empty($this->error) ),
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1019
        'link_flag_image' => $this->link_flag_image,
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1020
        'link_disabled' => $this->link_disabled
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1021
      ));
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1022
    
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1023
    $html = $parser->run();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1024
    
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1025
    return $html;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1026
    
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1027
  }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1028
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1029
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1030
   * For convenience. Echoes out HTML.
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1031
   */
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1032
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1033
  function echo_html()
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1034
  {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1035
    echo $this->get_html();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1036
  }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1037
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1038
}
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1039
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1040
?>