Commit bdf224ca authored by changi67's avatar changi67

[ENH] Use lib function to load lib

[FIX] Wrong path in lib copyright instead of references
Checkstyle rename class too camelcase compatible name
parent 15f7a9a7
......@@ -11,7 +11,7 @@ if (strpos($_SERVER['SCRIPT_NAME'], basename(__FILE__)) !== false) {
exit;
}
class referencesLib extends TikiLib
class ReferencesLib extends TikiLib
{
public function list_references($page)
{
......@@ -423,3 +423,4 @@ class referencesLib extends TikiLib
}
}
$referenceslib = new ReferencesLib();
<?php
// (c) Copyright 2002-2012 by authors of the Tiki Wiki CMS Groupware Project
//
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
......
......@@ -250,6 +250,9 @@ class TikiLib extends TikiDb_Bridge
require_once 'lib/mime/mimelib.php';
$mimelib = new MimeLib;
return self::$libraries[$name] = $mimelib;
case 'references':
global $referenceslib; require_once 'lib/references/referenceslib.php';
return self::$libraries[$name] = $referenceslib;
}
}
......
......@@ -56,7 +56,7 @@ function wikiplugin_showreference($data, $params)
{
global $prefs;
$params['title'] = trim($params['title']);
$params['showtitle'] = trim($params['showtitle']);
$params['hlevel'] = trim($params['hlevel']);
......@@ -109,11 +109,8 @@ function wikiplugin_showreference($data, $params)
$htm = '';
include_once ('lib/references/referenceslib.php');
$referencesLib = new referencesLib();
$references = $referencesLib->list_assoc_references($page_id);
$referenceslib = TikiLib::lib('references');
$references = $referenceslib->list_assoc_references($page_id);
$referencesData = array();
$is_global = 1;
......@@ -128,11 +125,11 @@ function wikiplugin_showreference($data, $params)
}
if (is_array($referencesData)) {
$referencesData = array_unique($referencesData);
$htm .= '<div class="references">';
if ($showtitle) {
$htm .= $hlevel_start . $title . $hlevel_end;
}
......@@ -142,7 +139,7 @@ function wikiplugin_showreference($data, $params)
$htm .= '<ul style="list-style: none outside none;">';
if (count($referencesData)) {
$values = $referencesLib->get_reference_from_code_and_page($referencesData, $page_id);
$values = $referenceslib->get_reference_from_code_and_page($referencesData, $page_id);
} else {
$values = array();
}
......@@ -160,13 +157,13 @@ function wikiplugin_showreference($data, $params)
}
foreach ($referencesData as $index=>$ref) {
$ref_no = $index + 1;
$text = '';
$cssClass = '';
if (array_key_exists($ref, $values['data'])) {
if ($values['data'][$ref]['style'] != '') {
$cssClass = $values['data'][$ref]['style'];
}
......@@ -186,15 +183,15 @@ function wikiplugin_showreference($data, $params)
'</li>';
}
}
$htm .= '</ul>';
$htm .= '<hr>';
$htm .= '</div>';
}
return $htm;
}
}
......
......@@ -7,7 +7,6 @@
require_once ('tiki-setup.php');
include_once ('lib/references/referenceslib.php');
global $dbTiki;
if (!isset($prefs['feature_references']) && !$prefs['feature_references'] === 'y') {
......@@ -15,7 +14,7 @@ if (!isset($prefs['feature_references']) && !$prefs['feature_references'] === 'y
exit;
}
$referenceslib = new referencesLib;
$referenceslib = TikiLib::lib('references');
if (!isset($_REQUEST['page'])) {
$smarty->assign('msg', tra('No page indicated'));
......
......@@ -673,18 +673,17 @@ if (isset($prefs['wiki_feature_copyrights']) && $prefs['wiki_feature_copyrights'
/* Local reference handling */
if (isset($prefs['feature_references']) && $prefs['feature_references'] === 'y') {
if ($prefs['wikiplugin_addreference'] == 'y') {
include_once("lib/references/referenceslib.php");
$referencesLib = new referencesLib();
$referenceslib = TikiLib::lib('references');
$page_id = TikiLib::lib('tiki')->get_page_id_from_name($page);
if ($page_id) {
$smarty->assign('showBiblioSection', '1');
$references = $referencesLib->list_references($page_id);
$lib_references = $referencesLib->list_lib_references();
$references = $referenceslib->list_references($page_id);
$lib_references = $referenceslib->list_lib_references();
$tiki_p_use_references = $referencesLib->get_permission('tiki_p_use_references');
$tiki_p_edit_references = $referencesLib->get_permission('tiki_p_edit_references');
$tiki_p_use_references = $referenceslib->get_permission('tiki_p_use_references');
$tiki_p_edit_references = $referenceslib->get_permission('tiki_p_edit_references');
if (isset($tiki_p_use_references) && $tiki_p_use_references=='y') {
$use_references = 1;
} else {
......@@ -697,7 +696,7 @@ if (isset($prefs['feature_references']) && $prefs['feature_references'] === 'y')
$edit_references = 0;
}
$assoc_references = $referencesLib->list_assoc_references($page_id);
$assoc_references = $referenceslib->list_assoc_references($page_id);
$page_info = TikiLib::lib('tiki')->get_page_info($page);
$regex = "/{ADDREFERENCE\(?\ ?biblio_code=\"(.*)\"\)?}.*({ADDREFERENCE})?/siU";
......@@ -1203,14 +1202,14 @@ if (
$ref_style = $_REQUEST['ref_style'];
if ($ref_biblio_code!='') {
include_once("lib/copyrights/referenceslib.php");
$referencesLib = new referencesLib();
$referenceslib = TikiLib::lib('references');
if (isset($info_new['page_id'])) {
$page_id = $info_new['page_id'];
} else {
$page_id = TikiLib::lib('tiki')->get_page_id_from_name($page);
}
$referencesLib->add_reference($page_id, $_REQUEST['ref_biblio_code'], $_REQUEST['ref_author'], $_REQUEST['ref_title'], $_REQUEST['ref_part'], $_REQUEST['ref_uri'], $_REQUEST['ref_code'], $_REQUEST['ref_year'], $_REQUEST['ref_style']);
$referenceslib->add_reference($page_id, $_REQUEST['ref_biblio_code'], $_REQUEST['ref_author'], $_REQUEST['ref_title'], $_REQUEST['ref_part'], $_REQUEST['ref_uri'], $_REQUEST['ref_code'], $_REQUEST['ref_year'], $_REQUEST['ref_style']);
}
}
}
......
......@@ -9,9 +9,8 @@ require_once ('tiki-setup.php');
$access->check_feature('feature_references');
$access->check_permission(array('tiki_p_edit_references'), tra('Edit Library References'));
include_once ('lib/references/referenceslib.php');
global $dbTiki;
$referenceslib = new referencesLib;
$referenceslib = TikiLib::lib('references');
$tiki_p_use_references = $referenceslib->get_permission('tiki_p_use_references');
$tiki_p_edit_references = $referenceslib->get_permission('tiki_p_edit_references');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment