Skip to content

Commit

Permalink
v1.1.0 launch
Browse files Browse the repository at this point in the history
  • Loading branch information
Krytic committed Feb 20, 2016
1 parent 42c3326 commit bee02f7
Show file tree
Hide file tree
Showing 14 changed files with 595 additions and 185 deletions.
9 changes: 9 additions & 0 deletions Upload/inc/languages/english/wiki.lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
$l['errorsocc'] = "The following errors occured:<br />{1}";
$l['nocat'] = "You must specify the title of a category to filter.";
$l['noarticlescat'] = "There are no articles in this category.";
$l['wiki_myalerts_not_installed'] = "Watching Articles is not available.";
$l['wiki_already_watching'] = "You are already watching this article.";
$l['wiki_not_already_watching'] = "You are already not watching this article.";
/* --- Buttons and Options --- */
$l['title'] = "Article Title";
$l['content'] = "Article Content";
Expand All @@ -43,6 +46,8 @@
$l['lastpost'] = "Last Editor";
$l['protect'] = "Protect Article";
$l['export'] = "Export Articles";
$l['wiki_watch'] = "Watch";
$l['wiki_unwatch'] = "Unwatch";
/* --- Who's Online --- */
$l['viewing_wiki'] = "Viewing the Wiki";
$l['wiki_new'] = "Creating a new Wiki Article";
Expand All @@ -56,5 +61,9 @@
/* --- Redirects --- */
$l['wasprotected'] = "You have successfully protected the article. Now redirecting you back to the article.";
$l['posted'] = "The article has been posted. Now redirecting you to the wiki index.";
$l['wiki_now_watching'] = "You are now watching this article.";
$l['wiki_now_not_watching'] = "You are no longer watching this article.";
/* --- Miscellaneous --- */
$l['wiki_watching_alert_string'] = 'A Wiki Article you are watching has been updated!';

?>
164 changes: 101 additions & 63 deletions Upload/inc/plugins/wiki.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
die('Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.');
}

define("WIKI_VERSION", "1.0.2"); // cheeky placement means that we're able to access this constant from anywhere.
define("WIKI_VERSION", "1.1.0"); // cheeky placement means that we're able to access this constant from anywhere.

$plugins->add_hook('global_start', 'wiki_build_link_definitions');
$plugins->add_hook('global_start', 'wiki_global_start');
$plugins->add_hook('fetch_wol_activity_end', 'wiki_fetch_wol');
$plugins->add_hook('build_friendly_wol_location_end', 'wiki_build_friendly');
$plugins->add_hook('parse_message', 'wiki_parse_mycode');
Expand All @@ -44,7 +44,7 @@ function wiki_info()
'version' => WIKI_VERSION,
'guid' => '', // no longer available on MyBB Mods site
'compatibility' => '18*',
);
);
}

function wiki_install()
Expand All @@ -68,7 +68,7 @@ function wiki_is_installed()

function wiki_uninstall()
{
global $db;
global $db, $cache;

// Template Deletion
$db->delete_query("templategroups", "title = 'Wiki'");
Expand All @@ -84,6 +84,29 @@ function wiki_uninstall()
// Clear caches
$db->delete_query("datacache", 'title="wiki_articles"');
$db->delete_query("datacache", 'title="wiki_permissions"');

require_once(MYBB_ROOT."admin/inc/functions_themes.php");

// Stylesheet Deletion
$query = $db->simple_select("themes", "tid");
while($tid = $db->fetch_field($query, "tid"))
{
$css_file = MYBB_ROOT."cache/themes/theme{$tid}/wiki.css";
if(file_exists($css_file))
unlink($css_file);
}

update_theme_stylesheet_list("1");

if (class_exists('MybbStuff_MyAlerts_AlertTypeManager')) {
$alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::getInstance();

if (!$alertTypeManager) {
$alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::createInstance($db, $cache);
}

$alertTypeManager->deleteByCode('mybb_wiki_alert_code');
}
}

function wiki_activate()
Expand All @@ -99,7 +122,7 @@ function wiki_activate()
$ins = array(
"prefix" => "wiki",
"title" => "Wiki",
);
);

$db->insert_query("templategroups", $ins);
}
Expand All @@ -120,7 +143,7 @@ function wiki_activate()
"sid" => "-2",
"version" => $mybb->version + 1,
"dateline" => time(),
);
);

$db->insert_query("templates", $ins);
}
Expand Down Expand Up @@ -165,43 +188,43 @@ function wiki_fetch_wol(&$user_activity)
switch($filename)
{
case "wiki":
if($parameters['action'] == 'new')
{
$user_activity['activity'] = "wiki_new";
}
elseif($parameters['action'] == 'edit')
{
$user_activity['activity'] = "wiki_edit";
}
elseif($parameters['action'] == 'protect')
{
$user_activity['activity'] = "wiki_protect";
}
elseif($parameters['action'] == 'categories')
{
$user_activity['activity'] = "wiki_categories";
}
elseif($parameters['action'] == 'export')
{
$user_activity['activity'] = "wiki_export";
}
elseif($parameters['action'] == 'diff')
{
$user_activity['activity'] = "wiki_diff";
}
elseif($parameters['action'] == 'category_listing')
{
$user_activity['activity'] = "wiki_category_listing";
}
elseif($parameters['action'] == 'contributors')
{
$user_activity['activity'] = "wiki_contributors";
}
else
{
$user_activity['activity'] = "wiki_view";
}
break;
if($parameters['action'] == 'new')
{
$user_activity['activity'] = "wiki_new";
}
elseif($parameters['action'] == 'edit')
{
$user_activity['activity'] = "wiki_edit";
}
elseif($parameters['action'] == 'protect')
{
$user_activity['activity'] = "wiki_protect";
}
elseif($parameters['action'] == 'categories')
{
$user_activity['activity'] = "wiki_categories";
}
elseif($parameters['action'] == 'export')
{
$user_activity['activity'] = "wiki_export";
}
elseif($parameters['action'] == 'diff')
{
$user_activity['activity'] = "wiki_diff";
}
elseif($parameters['action'] == 'category_listing')
{
$user_activity['activity'] = "wiki_category_listing";
}
elseif($parameters['action'] == 'contributors')
{
$user_activity['activity'] = "wiki_contributors";
}
else
{
$user_activity['activity'] = "wiki_view";
}
break;
}

return $user_activity;
Expand All @@ -216,32 +239,32 @@ function wiki_build_friendly(&$plugin_array)
switch($plugin_array['user_activity']['activity'])
{
case "wiki_view":
$plugin_array['location_name'] = $lang->viewing_wiki;
break;
$plugin_array['location_name'] = $lang->viewing_wiki;
break;
case "wiki_new":
$plugin_array['location_name'] = $lang->wiki_new;
$plugin_array['location_name'] = $lang->wiki_new;
case "wiki_edit":
break;
$plugin_array['location_name'] = $lang->wiki_edit;
break;
break;
$plugin_array['location_name'] = $lang->wiki_edit;
break;
case "wiki_protect":
$plugin_array['location_name'] = $lang->wiki_protect;
break;
$plugin_array['location_name'] = $lang->wiki_protect;
break;
case "wiki_categories":
$plugin_array['location_name'] = $lang->wiki_categories;
break;
$plugin_array['location_name'] = $lang->wiki_categories;
break;
case "wiki_export":
$plugin_array['location_name'] = $lang->wiki_export;
break;
$plugin_array['location_name'] = $lang->wiki_export;
break;
case "wiki_diff":
$plugin_array['location_name'] = $lang->wiki_diff;
break;
$plugin_array['location_name'] = $lang->wiki_diff;
break;
case "wiki_category_listing":
$plugin_array['location_name'] = $lang->wiki_category_listing;
break;
$plugin_array['location_name'] = $lang->wiki_category_listing;
break;
case "wiki_contributors":
$plugin_array['location_name'] = $lang->wiki_wol_contributors;
break;
$plugin_array['location_name'] = $lang->wiki_wol_contributors;
break;
}

return $plugin_array;
Expand Down Expand Up @@ -274,11 +297,13 @@ function wiki_do_mycode_with_id($matches)
}

/**
* GLOBAL START
* Builds a list of links for the wiki -- for instance WIKI_URL holds the base URL for the wiki wherever you are. loaded globally.
* Also handles MyAlerts formatting
*/
function wiki_build_link_definitions()
function wiki_global_start()
{
global $mybb;
global $mybb, $lang;

if($mybb->settings['seourls'] == "yes" || ($mybb->settings['seourls'] == "auto" && isset($_SERVER['SEO_SUPPORT']) && $_SERVER['SEO_SUPPORT'] == 1))
{
Expand Down Expand Up @@ -306,6 +331,19 @@ function wiki_build_link_definitions()
define("WIKI_CATEGORY_LISTING", "wiki.php");
define("WIKI_CONTRIBUTORS", "wiki.php");
}

if (class_exists('MybbStuff_MyAlerts_AlertFormatterManager')) {
require_once MYBB_ROOT . "inc/plugins/wiki/WikiCustomAlertFormatter.php";
$formatterManager = MybbStuff_MyAlerts_AlertFormatterManager::getInstance();

if (!$formatterManager) {
$formatterManager = MybbStuff_MyAlerts_AlertFormatterManager::createInstance($mybb, $lang);
}

$formatterManager->registerFormatter(
new WikiCustomAlertFormatter($mybb, $lang, 'mybb_wiki_alert_code')
);
}
}

?>
44 changes: 44 additions & 0 deletions Upload/inc/plugins/wiki/WikiCustomAlertFormatter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/**
* Alert formatter for my custom alert type.
*/
class WikiCustomAlertFormatter extends MybbStuff_MyAlerts_Formatter_AbstractFormatter
{
/**
* Format an alert into it's output string to be used in both the main alerts listing page and the popup.
*
* @param MybbStuff_MyAlerts_Entity_Alert $alert The alert to format.
*
* @return string The formatted alert string.
*/
public function formatAlert(MybbStuff_MyAlerts_Entity_Alert $alert, array $outputAlert)
{
return $this->lang->sprintf($this->lang->wiki_watching_alert_string);
}

/**
* Init function called before running formatAlert(). Used to load language files and initialize other required
* resources.
*
* @return void
*/
public function init()
{
if (!$this->lang->wiki) {
$this->lang->load('wiki');
}
}

/**
* Build a link to an alert's content so that the system can redirect to it.
*
* @param MybbStuff_MyAlerts_Entity_Alert $alert The alert to build the link for.
*
* @return string The built alert, preferably an absolute link.
*/
public function buildShowLink(MybbStuff_MyAlerts_Entity_Alert $alert)
{
return "wiki.php?action=view&id=" . $alert->getObjectId();
}
}
Loading

0 comments on commit bee02f7

Please sign in to comment.