plugins/Linkchomper.php
author Dan Fuhry <dan@enanocms.org>
Fri, 09 Jul 2010 21:33:35 -0400
changeset 1 1666d776fa27
parent 0 df77b4db90d7
permissions -rw-r--r--
Removed PHP 4 compatibility, moved the plugin up to 1.1.7 level 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
          
1
1666d776fa27 Removed PHP 4 compatibility, moved the plugin up to 1.1.7 level APIs
Dan Fuhry <dan@enanocms.org>
parents: 0
diff changeset
   434
          $perms = $session->fetch_page_acl('LinkChomper', 'System');
1666d776fa27 Removed PHP 4 compatibility, moved the plugin up to 1.1.7 level APIs
Dan Fuhry <dan@enanocms.org>
parents: 0
diff changeset
   435
          if ( !$perms->get_permissions('html_in_pages') )
0
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   436
          {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   437
            // 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
   438
            $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
   439
            $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
   440
            $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
   441
          }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   442
          
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   443
          $sanitized = array(
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   444
              '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
   445
              '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
   446
              '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
   447
              '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
   448
              '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
   449
            );
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   450
          
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   451
          $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
   452
          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
   453
            $db->_die();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   454
          
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   455
          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
   456
          break;
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
      }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   459
      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
   460
      {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   461
        $flags = 0;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   462
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   463
        // Validation
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   464
        $errors = array();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   465
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   466
        $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
   467
        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
   468
          $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
   469
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   470
        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
   471
          $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
   472
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   473
        $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
   474
        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
   475
          $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
   476
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   477
        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
   478
        {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   479
          $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
   480
          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
   481
            $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
   482
        }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   483
        else
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   484
        {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   485
          $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
   486
          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
   487
            $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
   488
        }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   489
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   490
        $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
   491
        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
   492
          $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
   493
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   494
        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
   495
        {
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['error'] = true;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   497
          $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
   498
        }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   499
        else
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   500
        {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   501
          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
   502
            $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
   503
          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
   504
            $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
   505
          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
   506
            $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
   507
          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
   508
            $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
   509
          
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   510
          $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
   511
          $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
   512
          
1
1666d776fa27 Removed PHP 4 compatibility, moved the plugin up to 1.1.7 level APIs
Dan Fuhry <dan@enanocms.org>
parents: 0
diff changeset
   513
          $perms = $session->fetch_page_acl('LinkChomper', 'System');
1666d776fa27 Removed PHP 4 compatibility, moved the plugin up to 1.1.7 level APIs
Dan Fuhry <dan@enanocms.org>
parents: 0
diff changeset
   514
          if ( !$perms->get_permissions('php_in_pages') )
0
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   515
          {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   516
            // 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
   517
            $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
   518
            $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
   519
            $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
   520
          }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   521
          
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   522
          $sanitized = array(
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   523
              '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
   524
              '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
   525
              '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
   526
              '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
   527
              '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
   528
            );
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   529
          
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   530
          $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
   531
          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
   532
            $db->_die();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   533
          
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   534
          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
   535
          break;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   536
        }
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
      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
   539
      {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   540
        break;
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
      else
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
        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
   545
      }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   546
      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
   547
      {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   548
        $editor = new LinkchomperFormGenerator();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   549
        $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
   550
        $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
   551
        $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
   552
        $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
   553
        $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
   554
        $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
   555
        $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
   556
        $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
   557
        $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
   558
        $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
   559
        $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
   560
        $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
   561
        $editor->echo_html();
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
      return true;
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
  }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   566
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   567
  echo <<<EOF
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   568
    <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
   569
    <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
   570
EOF;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   571
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   572
  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
   573
  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
   574
        <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
   575
          <tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   576
            <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
   577
            <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
   578
            <th>Clicks</th>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   579
            <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
   580
          </tr>';
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
  $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
   583
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   584
  if ( !$q )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   585
    $db->_die();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   586
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   587
  $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
   588
  $i = 0;
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
  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
   591
  {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   592
    do {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   593
      echo '<tr>';
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">' . 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
   595
      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
   596
      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
   597
      // Admin actions
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 ' . ( ( $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
   599
      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
   600
      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
   601
      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
   602
      echo '</tr>';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   603
      $i++;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   604
    } 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
   605
  }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   606
  else
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   607
  {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   608
    echo '<tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   609
            <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
   610
              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
   611
            </td>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   612
          </tr>';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   613
  }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   614
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   615
  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
   616
          <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
   617
            <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
   618
          </th>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   619
        </tr>';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   620
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   621
  echo '</table></div>';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   622
  echo '</form>';
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
}
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   627
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   628
// 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
   629
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
   630
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   631
/**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   632
 * 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
   633
 * @package Enano
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   634
 * @subpackage Linkchomper
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   635
 * @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
   636
 */
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
class LinkchomperFormGenerator
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
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   641
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   642
   * 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
   643
   * @var int
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   644
   */
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
  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
   647
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   648
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   649
   * 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
   650
   * @var string
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   651
   */
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
  var $link_name = '';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   654
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   655
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   656
   * 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
   657
   * @var int
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   658
   */
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
  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
   661
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   662
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   663
   * 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
   664
   * @var bool
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   665
   */
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
  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
   668
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   669
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   670
   * 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
   671
   * @var bool
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   672
   */
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
  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
   675
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   676
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   677
   * 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
   678
   * @var bool
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   679
   */
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
  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
   682
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   683
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   684
   * "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
   685
   * @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
   686
   */
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
  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
   689
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   690
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   691
   * Link target.
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   692
   * @var string
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   693
   */
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
  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
   696
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   697
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   698
   * 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
   699
   * @var bool
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   700
   */
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
  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
   703
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   704
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   705
   * 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
   706
   * @var bool
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   707
   */
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
  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
   710
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   711
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   712
   * 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
   713
   * @var string
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   714
   */
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
  var $inner_html = '';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   717
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   718
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   719
   * 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
   720
   * @var string
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   721
   */
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
  var $before_html = '';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   724
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   725
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   726
   * 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
   727
   * @var string
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   728
   */
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
  var $after_html = '';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   731
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   732
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   733
   * 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
   734
   * @var string
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   735
   * @access private
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   736
   */
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
  var $uuid = '';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   739
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   740
  /**
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   741
   * 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
   742
   * @var string
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   743
   */
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
  var $error = '';
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   746
  
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
   * Constructor.
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   749
   */
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
  function __construct()
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   752
  {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   753
    $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
   754
    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
   755
    {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   756
      $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
   757
      if ( $f )
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   758
      {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   759
        $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
   760
        $random = hexencode($random, '', '');
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   761
        fclose($f);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   762
        $uuid = $random;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   763
      }
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
    $this->uuid = $uuid;
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
  
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
   * 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
   770
   * @return string
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
   
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   773
  function get_html()
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
    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
   776
    
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   777
    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
   778
    {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   779
      $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
   780
    }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   781
    else
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   782
    {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   783
      $tpl_code = <<<EOF
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   784
      <!-- 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
   785
      <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
   786
        // <![CDATA[
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
        // 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
   789
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   790
        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
   791
        {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   792
          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
   793
          if ( source.checked )
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
            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
   796
            target.checked = false;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   797
            target.disabled = true;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   798
            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
   799
            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
   800
            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
   801
            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
   802
            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
   803
            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
   804
          }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   805
          else
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   806
          {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   807
            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
   808
            target.disabled = false;
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_url_{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 = null;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   811
            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
   812
            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
   813
            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
   814
            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
   815
          }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   816
        }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   817
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   818
        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
   819
        {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   820
          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
   821
          if ( source.checked )
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
            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
   824
            target.checked = false;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   825
            target.disabled = true;
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
          else
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   828
          {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   829
            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
   830
            target.disabled = false;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   831
          }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   832
        }
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
        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
   835
        {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   836
          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
   837
          if ( source.checked )
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
            var target;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   840
            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
   841
            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
   842
            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
   843
            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
   844
          }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   845
          else
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   846
          {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   847
            var target;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   848
            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
   849
            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
   850
            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
   851
            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
   852
          }
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
        
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   855
        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
   856
        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
   857
        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
   858
        
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
      </script>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   861
      <!-- BEGIN show_error -->
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   862
      <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
   863
        <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
   864
        {ERROR_MESSAGE}
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   865
      </div>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   866
      <!-- END show_error -->
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   867
      <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
   868
        <div class="tblholder">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   869
          <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
   870
            <tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   871
              <th colspan="2">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   872
                <!-- 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
   873
                  Create new link
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   874
                <!-- 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
   875
                <!-- 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
   876
                  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
   877
                <!-- 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
   878
              </th>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   879
            </tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   880
            <tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   881
              <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
   882
                <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
   883
                <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
   884
              </td>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   885
              <td class="row2">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   886
                <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
   887
              </td>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   888
            </tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   889
            <tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   890
              <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
   891
                Link options:
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   892
              </td>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   893
              <td class="row2">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   894
                <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
   895
                <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
   896
                <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
   897
              </td>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   898
            </tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   899
            <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
   900
              <td class="row1">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   901
                Link target:<br />
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   902
                <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
   903
              </td>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   904
              <td class="row2">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   905
                <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
   906
              </td>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   907
            </tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   908
            <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
   909
              <td class="row1">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   910
                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
   911
                <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
   912
              </td>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   913
              <td class="row2">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   914
                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
   915
                <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
   916
                  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
   917
                  <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
   918
                  <br />
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   919
                  <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
   920
                </div>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   921
                <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
   922
                  {TEXTAREA_HTML_INNER}
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   923
                </div>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   924
              </td>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   925
            </tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   926
            <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
   927
              <td class="row1">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   928
                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
   929
                <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
   930
              </td>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   931
              <td class="row2">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   932
                {TEXTAREA_HTML_BEFORE}
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   933
              </td>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   934
            </tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   935
            <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
   936
              <td class="row1">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   937
                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
   938
                <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
   939
              </td>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   940
              <td class="row2">
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   941
                {TEXTAREA_HTML_AFTER}
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   942
              </td>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   943
            </tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   944
            <tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   945
              <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
   946
                <!-- 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
   947
                  <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
   948
                <!-- 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
   949
                <!-- 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
   950
                  <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
   951
                <!-- 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
   952
                <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
   953
              </th>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   954
            </tr>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   955
          </table>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   956
        </div>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   957
        <!-- 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
   958
        <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
   959
        <!-- 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
   960
      </form>
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   961
      <!-- 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
   962
EOF;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   963
      $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
   964
    }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   965
    
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   966
    $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
   967
    
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   968
    $sanitized = array(
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   969
        '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
   970
        '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
   971
        '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
   972
        '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
   973
        '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
   974
      );
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   975
    
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   976
    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
   977
    {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   978
      unset($sanitized[$id]);
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   979
      $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
   980
    }
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
    $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
   983
    $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
   984
    $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
   985
    
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   986
    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
   987
    {
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   988
      $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
   989
          '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
   990
        ));
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   991
    }
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
    $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
   994
        'UUID' => $this->uuid,
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
   995
        '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
   996
        '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
   997
        '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
   998
        '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
   999
        '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
  1000
        '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
  1001
        '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
  1002
        '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
  1003
        '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
  1004
        '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
  1005
      ));
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1006
    $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
  1007
        '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
  1008
        '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
  1009
        '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
  1010
        '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
  1011
        '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
  1012
        '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
  1013
        '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
  1014
      ));
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1015
    
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1016
    $html = $parser->run();
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1017
    
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1018
    return $html;
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1019
    
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1020
  }
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
   * 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
  1024
   */
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1025
  
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1026
  function echo_html()
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
    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
  1029
  }
df77b4db90d7 First commit. Hopefully a working revision, seems to work OK on both banshee and caoineag APIs
Dan
parents:
diff changeset
  1030
  
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
?>