MyBB Community Forums
Easy Install Plugin Question - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Extensions (https://community.mybb.com/forum-201.html)
+--- Forum: Plugins (https://community.mybb.com/forum-73.html)
+---- Forum: Plugin Development (https://community.mybb.com/forum-68.html)
+---- Thread: Easy Install Plugin Question (/thread-22905.html)



Easy Install Plugin Question - Kodaks - 2006-01-08

Greetings everyone,
Please bear with me, I am not very experienced with plugins or php. I read the instruction in the readme for making Easy Install plugins, but when I try out my plugin nothing works. Here is the code (the file is called mybbseo.php):
<?php
function mybbseo_info()
{
   return array(
      "name"         => "MyBB SEO",
      "description"  => "--",
      "website"      => "--",
      "author"    => "--",
      "authorsite"   => "--",
      "version"      => "1.0",
      //A link to a page with update information. It should be a dynamic page because variables are passed to it
      "update"       => "--",
      //Will you allow your user to be able to update the plugin with an automatic script?
      "update_download" => TRUE,
      //Does this file have a readme? (it should be stored in "PLUGIN_NAME_readme()" function)
      "readme"       => TRUE,
      //Do you want to force people to read the readme before they install it?
      //There isn't much point in setting this to true. They need to have the plugin active before it can be used =P
      "force_readme" => FALSE,
      //EI Compatiable
      "ei"           => TRUE,
   );
}

$mybbseo_install = array();
$ei_install_index = 0;
$mybbseo_install = array();
$mybbseo_install[$ei_install_index] = array();
$mybbseo_install[$ei_install_index]['file'] = 'calendar.php';
$mybbseo_install[$ei_install_index]['find'] = array();
$mybbseo_install[$ei_install_index]['find'][] = 'addnav($lang->nav_calendar, "calendar.php");';
$mybbseo_install[$ei_install_index]['code'] = array();
$mybbseo_install[$ei_install_index]['code'][] = 'addnav($lang->nav_calendar, "calendar.html");';
$mybbseo_install[$ei_install_index]['position'] = 'replace';

//Your activation function
function mybbseo_activate(){
   global $plugin_ei, $config, $mybbseo_install;
   if(defined('EI_INSTALLED') && EI_INSTALLED){
      $plugin_ei->setupEI(mybbseo_info());
      $plugin_ei->install($mybbseo_install);
   }
}

//Your deactivation function
function test_plugin_deactivate(){
   global $plugin_ei, $config, $mybbseo_install;
   if(defined('EI_INSTALLED') && EI_INSTALLED){
      $plugin_ei->setupEI(mybbseo_info());
      $plugin_ei->uninstall($mybbseo_install);
   }
}
?>

With this plugin, I am trying to achieve a file edit in calendar.php that changes:
addnav($lang->nav_calendar, "calendar.php");
to
addnav($lang->nav_calendar, "calendar.html");

I really appreciate anybody's help. Thanks!




RE: Easy Install Plugin Question - decswxaqz - 2006-01-09

It does in fact make the changes. But because EI goes kinda crazy with newline characters (missing one at the start or the end of the line), it's moved it onto the line above which happens to be a comment.
So what happens is that it replaces the code, moves it up a line, and is ignored because it's now on a comment line....

Keep using that EI code generator and I will release an upgrade soon enough. If you want to make sure you plugin works with the newest version of EI, you can use
if(EI_VERSION >= 1.2)
EI is currently at version 1.1 so the next will be 1.2. Thanks for finding the bug and I should get round to fixing it today.


RE: Easy Install Plugin Question - Kodaks - 2006-01-10

Thanks, the next release sounds great! Cheers!


RE: Easy Install Plugin Question - decswxaqz - 2006-01-11

Sorry but this is going to take longer than I expected... Confused


RE: Easy Install Plugin Question - Kodaks - 2006-01-13

No problem, I appreciate you help!


RE: Easy Install Plugin Question - decswxaqz - 2006-01-13

I've managed to fix the problems. But I've got a new one with it updating... when the upgrades are deactivated they won't be uninstall Confused.


RE: Easy Install Plugin Question - Kodaks - 2006-01-15

No problem, is there any idea on how long this new bug will take to fix? I really appreciate all your help!

Thanks!


RE: Easy Install Plugin Question - decswxaqz - 2006-01-15

Well it's fixed. I can release it as long as people don't try to uninstall it Toungue.


RE: Easy Install Plugin Question - Kodaks - 2006-02-24

Hi, sorry to bother you. It seems that even with the new version, the calendar.php code does not change at all. Here is my plugin code:
<?php
function mybbseo_info()
{
   return array(
      "name"         => "MyBB SEO",
      "description"  => "--",
      "website"      => "--",
      "author"    => "--",
      "authorsite"   => "--",
      "version"      => "1.0",
      //A link to a page with update information. It should be a dynamic page because variables are passed to it
      "update"       => "--",
      //Will you allow your user to be able to update the plugin with an automatic script?
      "update_download" => TRUE,
      //Does this file have a readme? (it should be stored in "PLUGIN_NAME_readme()" function)
      "readme"       => TRUE,
      //Do you want to force people to read the readme before they install it?
      //There isn't much point in setting this to true. They need to have the plugin active before it can be used =P
      "force_readme" => FALSE,
      //EI Compatiable
      "ei"           => TRUE,
   );
}

$ei_install_index = 0;
$mybbseo_install = array();
$mybbseo_install[$ei_install_index] = array();
$mybbseo_install[$ei_install_index]['file'] = 'calendar.php';
$mybbseo_install[$ei_install_index]['find'] = array();
$mybbseo_install[$ei_install_index]['find'][] = 'addnav($lang->nav_calendar, "calendar.html");';
$mybbseo_install[$ei_install_index]['code'] = array();
$mybbseo_install[$ei_install_index]['code'][] = 'addnav($lang->nav_calendar, "calendar.php");';
$mybbseo_install[$ei_install_index]['position'] = 'replace';



//Your activation function
function mybbseo_activate(){
   global $plugin_ei, $config, $mybbseo_install;
   if(defined('EI_INSTALLED') && EI_INSTALLED){
      $plugin_ei->setupEI(mybbseo_info());
      $plugin_ei->install($mybbseo_install);
   }
}

//Your deactivation function
function test_plugin_deactivate(){
   global $plugin_ei, $config, $mybbseo_install;
   if(defined('EI_INSTALLED') && EI_INSTALLED){
      $plugin_ei->setupEI(mybbseo_info());
      $plugin_ei->uninstall($mybbseo_install);
   }
}
?>

Could you please tell me what I am doing wrong? Thanks!