Revision 1441
Added by Luisehahne over 14 years ago
- recoded /modules/admin.php info_banner, now compare with modify in pages
- security fixes remove defined WB_PATH for backend templates
- fixed class.admin.php missing $TEXT declaration, add get_section_details
| branches/2.8.x/CHANGELOG | ||
|---|---|---|
| 11 | 11 |
! = Update/Change |
| 12 | 12 |
|
| 13 | 13 |
------------------------------------- 2.8.2 ------------------------------------- |
| 14 |
10 Apr-2011 Build 1441 Dietmar Woellbrink (Luisehahne) |
|
| 15 |
# recoded /modules/admin.php info_banner, now compare with modify in pages |
|
| 16 |
# security fixes remove defined WB_PATH for backend templates |
|
| 17 |
# fixed class.admin.php missing $TEXT declaration, add get_section_details |
|
| 14 | 18 |
26 Mar-2011 Build 1440 Dietmar Woellbrink (Luisehahne) |
| 15 | 19 |
# add missing methode is_group_match in class.wb.php |
| 16 | 20 |
17 Mar-2011 Build 1439 Werner v.d.Decken(DarkViper) |
| branches/2.8.x/wb/admin/groups/index.php | ||
|---|---|---|
| 184 | 184 |
'CHECKED' => ' checked="checked"', |
| 185 | 185 |
'ADMIN_URL' => ADMIN_URL, |
| 186 | 186 |
'WB_URL' => WB_URL, |
| 187 |
'WB_PATH' => WB_PATH, |
|
| 188 | 187 |
'THEME_URL' => THEME_URL, |
| 189 | 188 |
'FTAN' => $ftan |
| 190 | 189 |
) |
| branches/2.8.x/wb/admin/pages/index.php | ||
|---|---|---|
| 553 | 553 |
$template->set_var(array( |
| 554 | 554 |
'THEME_URL' => THEME_URL, |
| 555 | 555 |
'WB_URL' => WB_URL, |
| 556 |
'WB_PATH' => WB_PATH, |
|
| 557 | 556 |
'ADMIN_URL' => ADMIN_URL, |
| 558 | 557 |
) |
| 559 | 558 |
); |
| branches/2.8.x/wb/admin/pages/modify.php | ||
|---|---|---|
| 72 | 72 |
'MENU_TITLE' => ($results_array['menu_title']), |
| 73 | 73 |
'ADMIN_URL' => ADMIN_URL, |
| 74 | 74 |
'WB_URL' => WB_URL, |
| 75 |
'WB_PATH' => WB_PATH, |
|
| 76 | 75 |
'THEME_URL' => THEME_URL |
| 77 | 76 |
)); |
| 78 | 77 |
|
| branches/2.8.x/wb/admin/interface/version.php | ||
|---|---|---|
| 52 | 52 |
|
| 53 | 53 |
// check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled) |
| 54 | 54 |
if(!defined('VERSION')) define('VERSION', '2.8.2.RC5');
|
| 55 |
if(!defined('REVISION')) define('REVISION', '1440');
|
|
| 55 |
if(!defined('REVISION')) define('REVISION', '1441');
|
|
| 56 | 56 |
|
| 57 | 57 |
?> |
| branches/2.8.x/wb/admin/settings/index.php | ||
|---|---|---|
| 147 | 147 |
} |
| 148 | 148 |
|
| 149 | 149 |
$template->set_var(array( |
| 150 |
'WB_PATH' => WB_PATH, |
|
| 151 | 150 |
'WB_URL' => WB_URL, |
| 152 | 151 |
'THEME_URL' => THEME_URL, |
| 153 |
'ADMIN_PATH' => ADMIN_PATH, |
|
| 154 | 152 |
'ADMIN_URL' => ADMIN_URL, |
| 155 | 153 |
)); |
| 156 | 154 |
|
| branches/2.8.x/wb/admin/users/users.php | ||
|---|---|---|
| 61 | 61 |
'EMAIL' => $user['email'], |
| 62 | 62 |
'ADMIN_URL' => ADMIN_URL, |
| 63 | 63 |
'WB_URL' => WB_URL, |
| 64 |
'WB_PATH' => WB_PATH, |
|
| 65 | 64 |
'THEME_URL' => THEME_URL |
| 66 | 65 |
) |
| 67 | 66 |
); |
| branches/2.8.x/wb/admin/users/index.php | ||
|---|---|---|
| 76 | 76 |
$template->set_var(array( |
| 77 | 77 |
'ADMIN_URL' => ADMIN_URL, |
| 78 | 78 |
'WB_URL' => WB_URL, |
| 79 |
'WB_PATH' => WB_PATH, |
|
| 80 | 79 |
'THEME_URL' => THEME_URL |
| 81 | 80 |
) |
| 82 | 81 |
); |
| ... | ... | |
| 106 | 105 |
$template->set_var(array( |
| 107 | 106 |
'ADMIN_URL' => ADMIN_URL, |
| 108 | 107 |
'WB_URL' => WB_URL, |
| 109 |
'WB_PATH' => WB_PATH, |
|
| 110 | 108 |
'THEME_URL' => THEME_URL |
| 111 | 109 |
) |
| 112 | 110 |
); |
| branches/2.8.x/wb/admin/languages/details.php | ||
|---|---|---|
| 64 | 64 |
'DESIGNED_FOR' => $language_platform, |
| 65 | 65 |
'ADMIN_URL' => ADMIN_URL, |
| 66 | 66 |
'WB_URL' => WB_URL, |
| 67 |
'WB_PATH' => WB_PATH, |
|
| 68 | 67 |
'THEME_URL' => THEME_URL |
| 69 | 68 |
) |
| 70 | 69 |
); |
| branches/2.8.x/wb/admin/languages/index.php | ||
|---|---|---|
| 66 | 66 |
$template->set_var(array( |
| 67 | 67 |
'ADMIN_URL' => ADMIN_URL, |
| 68 | 68 |
'WB_URL' => WB_URL, |
| 69 |
'WB_PATH' => WB_PATH, |
|
| 70 | 69 |
'THEME_URL' => THEME_URL |
| 71 | 70 |
) |
| 72 | 71 |
); |
| branches/2.8.x/wb/admin/modules/details.php | ||
|---|---|---|
| 81 | 81 |
'DESIGNED_FOR' => $module['platform'], |
| 82 | 82 |
'ADMIN_URL' => ADMIN_URL, |
| 83 | 83 |
'WB_URL' => WB_URL, |
| 84 |
'WB_PATH' => WB_PATH, |
|
| 85 | 84 |
'THEME_URL' => THEME_URL |
| 86 | 85 |
) |
| 87 | 86 |
); |
| branches/2.8.x/wb/framework/class.admin.php | ||
|---|---|---|
| 223 | 223 |
} |
| 224 | 224 |
} |
| 225 | 225 |
} |
| 226 |
|
|
| 226 |
/* |
|
| 227 | 227 |
function get_user_details($user_id) {
|
| 228 | 228 |
global $database; |
| 229 |
$query_user = "SELECT username,display_name FROM ".TABLE_PREFIX."users WHERE user_id = '$user_id'";
|
|
| 230 |
$get_user = $database->query($query_user);
|
|
| 231 |
if($get_user->numRows() != 0) {
|
|
| 232 |
$user = $get_user->fetchRow();
|
|
| 233 |
} else {
|
|
| 234 |
$user['display_name'] = 'Unknown';
|
|
| 235 |
$user['username'] = 'unknown';
|
|
| 229 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'users` ';
|
|
| 230 |
$sql .= 'WHERE `user_id`='.(int)$user_id.' LIMIT 1';
|
|
| 231 |
if(($resUser = $database->query($sql))){
|
|
| 232 |
if(!($recUser = $resUser->fetchRow())) {
|
|
| 233 |
$recUser['display_name'] = 'Unknown';
|
|
| 234 |
$recUser['username'] = 'unknown';
|
|
| 235 |
}
|
|
| 236 | 236 |
} |
| 237 |
return $user; |
|
| 238 |
} |
|
| 239 |
|
|
| 240 |
function get_page_details($page_id) {
|
|
| 241 |
global $database; |
|
| 242 |
$query = "SELECT page_id,page_title,menu_title,modified_by,modified_when FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'"; |
|
| 243 |
$results = $database->query($query); |
|
| 244 |
if($database->is_error()) {
|
|
| 245 |
$this->print_header(); |
|
| 246 |
$this->print_error($database->get_error()); |
|
| 247 |
} |
|
| 248 |
if($results->numRows() == 0) {
|
|
| 249 |
$this->print_header(); |
|
| 250 |
$this->print_error($MESSAGE['PAGES']['NOT_FOUND']); |
|
| 251 |
} |
|
| 252 |
$results_array = $results->fetchRow(); |
|
| 253 |
return $results_array; |
|
| 254 |
} |
|
| 255 |
|
|
| 237 |
return $recUser; |
|
| 238 |
} |
|
| 239 |
*/ |
|
| 240 |
function get_user_details($user_id) {
|
|
| 241 |
global $database; |
|
| 242 |
$retval = array('username'=>'unknown','display_name'=>'Unknown','email'=>'');
|
|
| 243 |
$sql = 'SELECT `username`,`display_name`,`email` '; |
|
| 244 |
$sql .= 'FROM `'.TABLE_PREFIX.'users` '; |
|
| 245 |
$sql .= 'WHERE `user_id`='.(int)$user_id.' '; |
|
| 246 |
// $sql .= 'AND (`statusflags` & '.USERS_DELETED.') > 0'; |
|
| 247 |
if( ($resUsers = $database->query($sql)) ) {
|
|
| 248 |
if( ($recUser = $resUsers->fetchRow()) ) {
|
|
| 249 |
$retval = $recUser; |
|
| 250 |
} |
|
| 251 |
} |
|
| 252 |
return $retval; |
|
| 253 |
} |
|
| 254 |
|
|
| 255 |
// |
|
| 256 |
function get_section_details( $section_id, $backLink = 'index.php' ) {
|
|
| 257 |
global $database, $TEXT; |
|
| 258 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'sections` '; |
|
| 259 |
$sql .= 'WHERE `section_id`='.intval($section_id).' LIMIT 1'; |
|
| 260 |
if(($resSection = $database->query($sql))){
|
|
| 261 |
if(!($recSection = $resSection->fetchRow())) {
|
|
| 262 |
$this->print_header(); |
|
| 263 |
$this->print_error($TEXT['SECTION'].' '.$TEXT['NOT_FOUND'], $backLink, true); |
|
| 264 |
} |
|
| 265 |
} else {
|
|
| 266 |
$this->print_header(); |
|
| 267 |
$this->print_error($database->get_error(), $backLink, true); |
|
| 268 |
} |
|
| 269 |
return $recSection; |
|
| 270 |
} |
|
| 271 |
|
|
| 272 |
function get_page_details( $page_id, $backLink = 'index.php' ) {
|
|
| 273 |
global $database, $TEXT; |
|
| 274 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` '; |
|
| 275 |
$sql .= 'WHERE `page_id`='.(int)$page_id.' LIMIT 1'; |
|
| 276 |
if(($resPages = $database->query($sql))){
|
|
| 277 |
if(!($recPage = $resPages->fetchRow())) {
|
|
| 278 |
$this->print_header(); |
|
| 279 |
$this->print_error($TEXT['PAGE'].' '.$TEXT['NOT_FOUND'], $backLink, true); |
|
| 280 |
} |
|
| 281 |
} else {
|
|
| 282 |
$this->print_header(); |
|
| 283 |
$this->print_error($database->get_error(), $backLink, true); |
|
| 284 |
} |
|
| 285 |
return $recPage; |
|
| 286 |
} |
|
| 287 |
|
|
| 256 | 288 |
/** Function get_page_permission takes either a numerical page_id, |
| 257 | 289 |
* upon which it looks up the permissions in the database, |
| 258 |
* or an array with keys admin_groups and admin_users
|
|
| 290 |
* or an array with keys admin_groups and admin_users |
|
| 259 | 291 |
*/ |
| 292 |
/* |
|
| 260 | 293 |
function get_page_permission($page,$action='admin') {
|
| 261 | 294 |
if ($action!='viewing') $action='admin'; |
| 262 | 295 |
$action_groups=$action.'_groups'; |
| ... | ... | |
| 264 | 297 |
if (is_array($page)) {
|
| 265 | 298 |
$groups=$page[$action_groups]; |
| 266 | 299 |
$users=$page[$action_users]; |
| 267 |
} else {
|
|
| 300 |
} else {
|
|
| 268 | 301 |
global $database; |
| 269 | 302 |
$results = $database->query("SELECT $action_groups,$action_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page'");
|
| 270 | 303 |
$result = $results->fetchRow(); |
| ... | ... | |
| 283 | 316 |
} |
| 284 | 317 |
return true; |
| 285 | 318 |
} |
| 286 |
|
|
| 319 |
*/ |
|
| 287 | 320 |
|
| 321 |
function get_page_permission($page,$action='admin') {
|
|
| 322 |
if($action != 'viewing') { $action = 'admin'; }
|
|
| 323 |
$action_groups = $action.'_groups'; |
|
| 324 |
$action_users = $action.'_users'; |
|
| 325 |
$groups = $users = '0'; |
|
| 326 |
if(is_array($page)) {
|
|
| 327 |
$groups = $page[$action_groups]; |
|
| 328 |
$users = $page[$action_users]; |
|
| 329 |
} else {
|
|
| 330 |
global $database; |
|
| 331 |
$sql = 'SELECT `'.$action_groups.'`,`'.$action_users.'` '; |
|
| 332 |
$sql .= 'FROM `'.TABLE_PREFIX.'pages` '; |
|
| 333 |
$sql .= 'WHERE `page_id`='.(int)$page; |
|
| 334 |
if( ($res = $database->query($sql)) ) {
|
|
| 335 |
if( ($rec = $res->fetchRow()) ) {
|
|
| 336 |
$groups = $rec[$action_groups]; |
|
| 337 |
$users = $rec[$action_users]; |
|
| 338 |
} |
|
| 339 |
} |
|
| 340 |
} |
|
| 341 |
return ($this->ami_group_member($groups) || $this->is_group_match($this->get_user_id(), $users)); |
|
| 342 |
} |
|
| 343 |
|
|
| 288 | 344 |
// Returns a system permission for a menu link |
| 289 | 345 |
function get_link_permission($title) {
|
| 290 | 346 |
$title = str_replace('_blank', '', $title);
|
| ... | ... | |
| 318 | 374 |
$body_links = ""; |
| 319 | 375 |
// define default baselink and filename for optional module javascript and stylesheet files |
| 320 | 376 |
if($file_id == "js") {
|
| 321 |
$base_link = '<script type="text/javascript" src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/backend_body.js"></script>';
|
|
| 377 |
$base_link = '<script src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/backend_body.js" type="text/javascript"></script>';
|
|
| 322 | 378 |
$base_file = "backend_body.js"; |
| 323 | 379 |
} |
| 324 | 380 |
// check if backend_body.js files needs to be included to the <body></body> section of the backend |
| ... | ... | |
| 382 | 438 |
$base_link.= ' rel="stylesheet" type="text/css" media="screen" />'; |
| 383 | 439 |
$base_file = "backend.css"; |
| 384 | 440 |
} else {
|
| 385 |
$base_link = '<script type="text/javascript" src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/backend.js"></script>';
|
|
| 441 |
$base_link = '<script src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/backend.js" type="text/javascript"></script>';
|
|
| 386 | 442 |
$base_file = "backend.js"; |
| 387 | 443 |
} |
| 388 | 444 |
|
| ... | ... | |
| 400 | 456 |
return str_replace("{MODULE_DIRECTORY}", $tool['directory'], $base_link);
|
| 401 | 457 |
} |
| 402 | 458 |
} |
| 403 |
} elseif(isset($_GET['page_id']) or isset($_POST['page_id'])) {
|
|
| 459 |
} elseif(isset($_GET['page_id']) || isset($_POST['page_id'])) {
|
|
| 404 | 460 |
// check if displayed page in the backend contains a page module |
| 405 | 461 |
if (isset($_GET['page_id'])) {
|
| 406 | 462 |
$page_id = (int)$_GET['page_id']; |
| branches/2.8.x/wb/search/search_modext.php | ||
|---|---|---|
| 5 | 5 |
* @package search |
| 6 | 6 |
* @author WebsiteBaker Project |
| 7 | 7 |
* @copyright 2004-2009, Ryan Djurovich |
| 8 |
* @copyright 2009-2011, Website Baker Org. e.V.
|
|
| 8 |
* @copyright 2009-2010, Website Baker Org. e.V.
|
|
| 9 | 9 |
* @link http://www.websitebaker2.org/ |
| 10 | 10 |
* @license http://www.gnu.org/licenses/gpl.html |
| 11 | 11 |
* @platform WebsiteBaker 2.8.x |
| 12 |
* @requirements PHP 5.2.2 and higher
|
|
| 12 |
* @requirements PHP 4.3.4 and higher
|
|
| 13 | 13 |
* @version $Id$ |
| 14 | 14 |
* @filesource $HeadURL$ |
| 15 | 15 |
* @lastmodified $Date$ |
| 16 | 16 |
* |
| 17 | 17 |
*/ |
| 18 | 18 |
|
| 19 |
// Must include code to stop this file being access directly |
|
| 20 |
if(defined('WB_PATH') == false) { die("Cannot access this file directly"); }
|
|
| 21 |
|
|
| 22 | 19 |
// make the url-string for highlighting |
| 23 |
function make_url_searchstring($search_match, $search_url_array) |
|
| 24 |
{
|
|
| 20 |
function make_url_searchstring($search_match, $search_url_array) {
|
|
| 25 | 21 |
$link = ""; |
| 26 |
if ($search_match != 'exact') |
|
| 27 |
{
|
|
| 22 |
if ($search_match != 'exact') {
|
|
| 28 | 23 |
$str = implode(" ", $search_url_array);
|
| 29 | 24 |
$link = "?searchresult=1&sstring=".urlencode($str); |
| 30 | 25 |
} else {
|
| ... | ... | |
| 35 | 30 |
} |
| 36 | 31 |
|
| 37 | 32 |
// make date and time for "last modified by... on ..."-string |
| 38 |
function get_page_modified($page_modified_when) |
|
| 39 |
{
|
|
| 33 |
function get_page_modified($page_modified_when) {
|
|
| 40 | 34 |
global $TEXT; |
| 41 |
if($page_modified_when > 0) |
|
| 42 |
{
|
|
| 35 |
if($page_modified_when > 0) {
|
|
| 43 | 36 |
$date = gmdate(DATE_FORMAT, $page_modified_when+TIMEZONE); |
| 44 | 37 |
$time = gmdate(TIME_FORMAT, $page_modified_when+TIMEZONE); |
| 45 | 38 |
} else {
|
| ... | ... | |
| 50 | 43 |
} |
| 51 | 44 |
|
| 52 | 45 |
// make username and displayname for "last modified by... on ..."-string |
| 53 |
function get_page_modified_by($page_modified_by, $users) |
|
| 54 |
{
|
|
| 46 |
function get_page_modified_by($page_modified_by, $users) {
|
|
| 55 | 47 |
global $TEXT; |
| 56 |
// check for existing user-id |
|
| 57 |
if(!isset($users[$page_modified_by])) |
|
| 58 |
{
|
|
| 59 |
$page_modified_by = 0; |
|
| 60 |
} |
|
| 61 |
|
|
| 62 |
$username = $users[$page_modified_by]['username']; |
|
| 63 |
$displayname = $users[$page_modified_by]['display_name']; |
|
| 48 |
if($page_modified_by>0) {
|
|
| 49 |
$username = $users[$page_modified_by]['username']; |
|
| 50 |
$displayname = $users[$page_modified_by]['display_name']; |
|
| 51 |
} else {
|
|
| 52 |
$username = ""; |
|
| 53 |
$displayname = $TEXT['UNKNOWN']; |
|
| 54 |
} |
|
| 64 | 55 |
return array($username, $displayname); |
| 65 | 56 |
} |
| 66 | 57 |
|
| 67 | 58 |
// checks if _all_ searchwords matches |
| 68 |
function is_all_matched($text, $search_words) |
|
| 69 |
{
|
|
| 59 |
function is_all_matched($text, $search_words) {
|
|
| 70 | 60 |
$all_matched = true; |
| 71 |
foreach ($search_words AS $word) |
|
| 72 |
{
|
|
| 73 |
if(!preg_match('/'.$word.'/ui', $text))
|
|
| 74 |
{
|
|
| 61 |
foreach ($search_words AS $word) {
|
|
| 62 |
if(!preg_match('/'.$word.'/i', $text)) {
|
|
| 75 | 63 |
$all_matched = false; |
| 76 | 64 |
break; |
| 77 | 65 |
} |
| ... | ... | |
| 80 | 68 |
} |
| 81 | 69 |
|
| 82 | 70 |
// checks if _any_ of the searchwords matches |
| 83 |
function is_any_matched($text, $search_words) |
|
| 84 |
{
|
|
| 71 |
function is_any_matched($text, $search_words) {
|
|
| 85 | 72 |
$any_matched = false; |
| 86 | 73 |
$word = '('.implode('|', $search_words).')';
|
| 87 |
if(preg_match('/'.$word.'/ui', $text))
|
|
| 88 |
{
|
|
| 74 |
if(preg_match('/'.$word.'/i', $text)) {
|
|
| 89 | 75 |
$any_matched = true; |
| 90 | 76 |
} |
| 91 | 77 |
return $any_matched; |
| 92 | 78 |
} |
| 93 | 79 |
|
| 94 | 80 |
// collects the matches from text in excerpt_array |
| 95 |
function get_excerpts($text, $search_words, $max_excerpt_num) |
|
| 96 |
{
|
|
| 97 |
$match_array = array(); |
|
| 98 |
$excerpt_array = array(); |
|
| 81 |
function get_excerpts($text, $search_words, $max_excerpt_num) {
|
|
| 82 |
$excerpt_array = FALSE; |
|
| 99 | 83 |
$word = '('.implode('|', $search_words).')';
|
| 100 |
|
|
| 101 |
//Filter droplets from the page data |
|
| 102 |
preg_match_all('~\[\[(.*?)\]\]~', $text, $matches);
|
|
| 103 |
foreach ($matches[1] as $match) |
|
| 104 |
{
|
|
| 105 |
$text = str_replace('[['.$match.']]', '', $text);
|
|
| 106 |
} |
|
| 107 |
|
|
| 108 |
// Build the regex-string |
|
| 109 |
if(strpos(strtoupper(PHP_OS), 'WIN')===0) // windows -> see below |
|
| 110 |
{
|
|
| 111 |
$str1=".!?;"; |
|
| 112 |
$str2=".!?;"; |
|
| 113 |
} else { // linux & Co.
|
|
| 114 |
// start-sign: .!?; + INVERTED EXCLAMATION MARK - INVERTED QUESTION MARK - DOUBLE EXCLAMATION MARK - INTERROBANG - EXCLAMATION QUESTION MARK - QUESTION EXCLAMATION MARK - DOUBLE QUESTION MARK - HALFWIDTH IDEOGRAPHIC FULL STOP - IDEOGRAPHIC FULL STOP - IDEOGRAPHIC COMMA |
|
| 115 |
$str1=".!?;"."\xC2\xA1"."\xC2\xBF"."\xE2\x80\xBC"."\xE2\x80\xBD"."\xE2\x81\x89"."\xE2\x81\x88"."\xE2\x81\x87"."\xEF\xBD\xA1"."\xE3\x80\x82"."\xE3\x80\x81"; |
|
| 116 |
// stop-sign: .!?; + DOUBLE EXCLAMATION MARK - INTERROBANG - EXCLAMATION QUESTION MARK - QUESTION EXCLAMATION MARK - DOUBLE QUESTION MARK - HALFWIDTH IDEOGRAPHIC FULL STOP - IDEOGRAPHIC FULL STOP - IDEOGRAPHIC COMMA |
|
| 117 |
$str2=".!?;"."\xE2\x80\xBC"."\xE2\x80\xBD"."\xE2\x81\x89"."\xE2\x81\x88"."\xE2\x81\x87"."\xEF\xBD\xA1"."\xE3\x80\x82"."\xE3\x80\x81"; |
|
| 118 |
} |
|
| 119 |
$regex='/(?:^|\b|['.$str1.'])([^'.$str1.']{0,200}?'.$word.'[^'.$str2.']{0,200}(?:['.$str2.']|\b|$))/uis';
|
|
| 120 |
if(version_compare(PHP_VERSION, '4.3.3', '>=') && |
|
| 121 |
strpos(strtoupper(PHP_OS), 'WIN')!==0 |
|
| 122 |
) { // this may crash windows server, so skip if on windows
|
|
| 123 |
// jump from match to match, get excerpt, stop if $max_excerpt_num is reached |
|
| 124 |
$last_end = 0; $offset = 0; |
|
| 125 |
while(preg_match('/'.$word.'/uis', $text, $match_array, PREG_OFFSET_CAPTURE, $last_end))
|
|
| 126 |
{
|
|
| 127 |
$offset = ($match_array[0][1]-206 < $last_end)?$last_end:$match_array[0][1]-206; |
|
| 128 |
if(preg_match($regex, $text, $matches, PREG_OFFSET_CAPTURE, $offset)) |
|
| 129 |
{
|
|
| 130 |
$last_end = $matches[1][1]+strlen($matches[1][0])-1; |
|
| 131 |
if(!preg_match('/\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\./', $matches[1][0])) // skip excerpts with email-addresses
|
|
| 132 |
{
|
|
| 133 |
$excerpt_array[] = trim($matches[1][0]); |
|
| 134 |
} |
|
| 135 |
if(count($excerpt_array)>=$max_excerpt_num) |
|
| 136 |
{
|
|
| 137 |
$excerpt_array = array_unique($excerpt_array); |
|
| 138 |
if(count($excerpt_array) >= $max_excerpt_num) { break; }
|
|
| 139 |
} |
|
| 140 |
} else { // problem: preg_match failed - can't find a start- or stop-sign
|
|
| 141 |
$last_end += 201; // jump forward and try again |
|
| 142 |
} |
|
| 84 |
// start-sign: .!?; + INVERTED EXCLAMATION MARK - INVERTED QUESTION MARK - DOUBLE EXCLAMATION MARK - INTERROBANG - EXCLAMATION QUESTION MARK - QUESTION EXCLAMATION MARK - DOUBLE QUESTION MARK - HALFWIDTH IDEOGRAPHIC FULL STOP - IDEOGRAPHIC FULL STOP - IDEOGRAPHIC COMMA |
|
| 85 |
$p_start=".!?;"."\xC2\xA1"."\xC2\xBF"."\xE2\x80\xBC"."\xE2\x80\xBD"."\xE2\x81\x89"."\xE2\x81\x88"."\xE2\x81\x87"."\xEF\xBD\xA1"."\xE3\x80\x82"."\xE3\x80\x81"; |
|
| 86 |
// stop-sign: .!?; + DOUBLE EXCLAMATION MARK - INTERROBANG - EXCLAMATION QUESTION MARK - QUESTION EXCLAMATION MARK - DOUBLE QUESTION MARK - HALFWIDTH IDEOGRAPHIC FULL STOP - IDEOGRAPHIC FULL STOP - IDEOGRAPHIC COMMA |
|
| 87 |
$p_stop=".!?;"."\xE2\x80\xBC"."\xE2\x80\xBD"."\xE2\x81\x89"."\xE2\x81\x88"."\xE2\x81\x87"."\xEF\xBD\xA1"."\xE3\x80\x82"."\xE3\x80\x81"; |
|
| 88 |
// jump from match to match, get excerpt, stop if $max_excerpt_num is reached |
|
| 89 |
$match_array = $matches = array(); |
|
| 90 |
$startpos = $wordpos = $endpos = 0; // although preg_match with u-switch handles unicode correctly, the ...pos-variables will count bytes (not chars) |
|
| 91 |
while(preg_match("/$word/i", $text, $match_array, PREG_OFFSET_CAPTURE, $startpos)) {
|
|
| 92 |
$wordpos = $match_array[0][1]; |
|
| 93 |
$startpos = ($wordpos-200 < $endpos)?$endpos:$wordpos-200; |
|
| 94 |
$endpos = $wordpos+200; |
|
| 95 |
// look for better start position |
|
| 96 |
if(preg_match_all("/[$p_start]/u", substr($text, $startpos, $wordpos-$startpos), $matches, PREG_OFFSET_CAPTURE))
|
|
| 97 |
$startpos += $matches[0][count($matches[0])-1][1]; // set startpos at last punctuation before word |
|
| 98 |
// look for better end position |
|
| 99 |
if(preg_match_all("/[$p_stop]/u", substr($text, $wordpos, $endpos-$wordpos), $matches, PREG_OFFSET_CAPTURE))
|
|
| 100 |
$endpos = $wordpos+$matches[0][0][1]; // set endpos at first punctuation after word |
|
| 101 |
$match = substr($text, $startpos+1, $endpos-$startpos); |
|
| 102 |
if(!preg_match('/\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\./', $match)) // skip excerpts with email-addresses
|
|
| 103 |
$excerpt_array[] = trim($match); |
|
| 104 |
if(count($excerpt_array)>=$max_excerpt_num) {
|
|
| 105 |
$excerpt_array = array_unique($excerpt_array); |
|
| 106 |
if(count($excerpt_array) >= $max_excerpt_num) |
|
| 107 |
break; |
|
| 143 | 108 |
} |
| 144 |
} else { // compatible, but may be very slow with large pages
|
|
| 145 |
if(preg_match_all($regex, $text, $match_array)) |
|
| 146 |
{
|
|
| 147 |
foreach($match_array[1] AS $string) |
|
| 148 |
{
|
|
| 149 |
if(!preg_match('/\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\./', $string)) // skip excerpts with email-addresses
|
|
| 150 |
{
|
|
| 151 |
$excerpt_array[] = trim($string); |
|
| 152 |
} |
|
| 153 |
|
|
| 154 |
} |
|
| 155 |
} |
|
| 109 |
// restart at last endpos |
|
| 110 |
$startpos = $endpos; |
|
| 156 | 111 |
} |
| 157 | 112 |
return $excerpt_array; |
| 158 | 113 |
} |
| 159 | 114 |
|
| 160 | 115 |
// makes excerpt_array a string ready to print out |
| 161 |
function prepare_excerpts($excerpt_array, $search_words, $max_excerpt_num) |
|
| 162 |
{
|
|
| 116 |
function prepare_excerpts($excerpt_array, $search_words, $max_excerpt_num) {
|
|
| 163 | 117 |
// excerpts: text before and after a single excerpt, html-tag for markup |
| 164 | 118 |
$EXCERPT_BEFORE = '... '; |
| 165 | 119 |
$EXCERPT_AFTER = ' ...<br />'; |
| ... | ... | |
| 168 | 122 |
// remove duplicate matches from $excerpt_array, if any. |
| 169 | 123 |
$excerpt_array = array_unique($excerpt_array); |
| 170 | 124 |
// use the first $max_excerpt_num excerpts only |
| 171 |
if(count($excerpt_array) > $max_excerpt_num) |
|
| 172 |
{
|
|
| 125 |
if(count($excerpt_array) > $max_excerpt_num) {
|
|
| 173 | 126 |
$excerpt_array = array_slice($excerpt_array, 0, $max_excerpt_num); |
| 174 | 127 |
} |
| 175 | 128 |
// prepare search-string |
| ... | ... | |
| 177 | 130 |
// we want markup on search-results page, |
| 178 | 131 |
// but we need some 'magic' to prevent <br />, <b>... from being highlighted |
| 179 | 132 |
$excerpt = ''; |
| 180 |
foreach($excerpt_array as $str) |
|
| 181 |
{
|
|
| 182 |
$excerpt .= '#,,#'.preg_replace("/($string)/iu","#,,,,#$1#,,,,,#",$str).'#,,,#';
|
|
| 133 |
foreach($excerpt_array as $str) {
|
|
| 134 |
$excerpt .= '#,,#'.preg_replace("/($string)/i","#,,,,#$1#,,,,,#",$str).'#,,,#';
|
|
| 183 | 135 |
} |
| 184 |
$excerpt = str_replace(array('&','<','>','"','\'',"\xC2\xA0"), array('&','<','>','"',''',' '), $excerpt);
|
|
| 136 |
$excerpt = str_replace(array('&','<','>','"','\'',"\xC2\xA0"), array('&','<','>','"',''',' '), $excerpt);
|
|
| 185 | 137 |
$excerpt = str_replace(array('#,,,,#','#,,,,,#'), array($EXCERPT_MARKUP_START,$EXCERPT_MARKUP_END), $excerpt);
|
| 186 | 138 |
$excerpt = str_replace(array('#,,#','#,,,#'), array($EXCERPT_BEFORE,$EXCERPT_AFTER), $excerpt);
|
| 187 | 139 |
// prepare to write out |
| 188 |
if(DEFAULT_CHARSET != 'utf-8') |
|
| 189 |
{
|
|
| 140 |
if(DEFAULT_CHARSET != 'utf-8') {
|
|
| 190 | 141 |
$excerpt = umlauts_to_entities($excerpt, 'UTF-8'); |
| 191 | 142 |
} |
| 192 | 143 |
return $excerpt; |
| 193 | 144 |
} |
| 194 | 145 |
|
| 195 | 146 |
// work out what the link-anchor should be |
| 196 |
function make_url_target($page_link_target, $text, $search_words) |
|
| 197 |
{
|
|
| 147 |
function make_url_target($page_link_target, $text, $search_words) {
|
|
| 198 | 148 |
// 1. e.g. $page_link_target=="&monthno=5&year=2007" - module-dependent target. Do nothing. |
| 199 | 149 |
// 2. $page_link_target=="#!wb_section_..." - the user wants the section-target, so do nothing. |
| 200 | 150 |
// 3. $page_link_target=="#wb_section_..." - try to find a better target, use the section-target as fallback. |
| 201 | 151 |
// 4. $page_link_target=="" - do nothing |
| 202 |
if(version_compare(PHP_VERSION, '4.3.3', ">=") && substr($page_link_target,0,12)=='#wb_section_') |
|
| 203 |
{
|
|
| 152 |
if(version_compare(PHP_VERSION, '4.3.3', ">=") && substr($page_link_target,0,12)=='#wb_section_') {
|
|
| 204 | 153 |
$word = '('.implode('|', $search_words).')';
|
| 205 |
preg_match('/'.$word.'/ui', $text, $match, PREG_OFFSET_CAPTURE);
|
|
| 206 |
if($match && is_array($match[0])) |
|
| 207 |
{
|
|
| 154 |
preg_match('/'.$word.'/i', $text, $match, PREG_OFFSET_CAPTURE);
|
|
| 155 |
if($match && is_array($match[0])) {
|
|
| 208 | 156 |
$x=$match[0][1]; // position of first match |
| 209 | 157 |
// is there an anchor nearby? |
| 210 |
if(preg_match_all('/<(?:[^>]+id|\s*a[^>]+name)\s*=\s*"(.*)"/iU', substr($text,0,$x), $match, PREG_OFFSET_CAPTURE))
|
|
| 211 |
{
|
|
| 212 |
$anchor=''; |
|
| 213 |
foreach($match[1] AS $array) |
|
| 214 |
{
|
|
| 215 |
if($array[1] > $x) |
|
| 216 |
{
|
|
| 217 |
break; |
|
| 218 |
} |
|
| 219 |
$anchor = $array[0]; |
|
| 220 |
} |
|
| 221 |
if($anchor != '') |
|
| 222 |
{
|
|
| 223 |
$page_link_target = '#'.$anchor; |
|
| 224 |
} |
|
| 158 |
if(preg_match_all('/<\s*(?:a[^>]+?name|[^>]+?id)\s*=\s*"([^"]+)"/i', substr($text,0,$x), $match)) {
|
|
| 159 |
$page_link_target = '#'.$match[1][count($match[1])-1]; |
|
| 225 | 160 |
} |
| 226 | 161 |
} |
| 227 |
} elseif(substr($page_link_target,0,13)=='#!wb_section_') {
|
|
| 162 |
} |
|
| 163 |
elseif(substr($page_link_target,0,13)=='#!wb_section_') {
|
|
| 228 | 164 |
$page_link_target = '#'.substr($page_link_target, 2); |
| 229 | 165 |
} |
| 230 | 166 |
|
| 231 | 167 |
// since wb 2.7.1 the section-anchor is configurable - SEC_ANCHOR holds the anchor name |
| 232 |
if(substr($page_link_target,0,12)=='#wb_section_') |
|
| 233 |
{
|
|
| 234 |
if(defined('SEC_ANCHOR') && SEC_ANCHOR!='')
|
|
| 235 |
{
|
|
| 168 |
if(substr($page_link_target,0,12)=='#wb_section_') {
|
|
| 169 |
if(defined('SEC_ANCHOR') && SEC_ANCHOR!='') {
|
|
| 236 | 170 |
$sec_id = substr($page_link_target, 12); |
| 237 | 171 |
$page_link_target = '#'.SEC_ANCHOR.$sec_id; |
| 238 | 172 |
} else { // section-anchors are disabled
|
| ... | ... | |
| 244 | 178 |
} |
| 245 | 179 |
|
| 246 | 180 |
// wrapper for compatibility with old print_excerpt() |
| 247 |
function print_excerpt($page_link, $page_link_target, $page_title, $page_description, $page_modified_when, $page_modified_by, $text, $max_excerpt_num, $func_vars, $pic_link="") |
|
| 248 |
{
|
|
| 181 |
function print_excerpt($page_link, $page_link_target, $page_title, $page_description, $page_modified_when, $page_modified_by, $text, $max_excerpt_num, $func_vars, $pic_link="") {
|
|
| 249 | 182 |
$mod_vars = array( |
| 250 | 183 |
'page_link' => $page_link, |
| 251 | 184 |
'page_link_target' => $page_link_target, |
| ... | ... | |
| 267 | 200 |
* list_files_dirs() - lists all files and dirs below a given directory |
| 268 | 201 |
* clear_filelist() - keeps only wanted or removes unwanted entries in file-list. |
| 269 | 202 |
*/ |
| 270 |
|
|
| 203 |
|
|
| 271 | 204 |
// prints the excerpts for one section |
| 272 |
function print_excerpt2($mod_vars, $func_vars) |
|
| 273 |
{
|
|
| 205 |
function print_excerpt2($mod_vars, $func_vars) {
|
|
| 274 | 206 |
extract($func_vars, EXTR_PREFIX_ALL, 'func'); |
| 275 | 207 |
extract($mod_vars, EXTR_PREFIX_ALL, 'mod'); |
| 276 | 208 |
global $TEXT; |
| 277 | 209 |
// check $mod_...vars |
| 278 |
if(!isset($mod_page_link)) { $mod_page_link = $func_page_link; }
|
|
| 279 |
if(!isset($mod_page_link_target)) { $mod_page_link_target = ''; }
|
|
| 280 |
if(!isset($mod_page_title)) { $mod_page_title = $func_page_title; }
|
|
| 281 |
if(!isset($mod_page_description)) { $mod_page_description = $func_page_description; }
|
|
| 282 |
if(!isset($mod_page_modified_when)) { $mod_page_modified_when = $func_page_modified_when; }
|
|
| 283 |
if(!isset($mod_page_modified_by)) { $mod_page_modified_by = $func_page_modified_by; }
|
|
| 284 |
if(!isset($mod_text)) { $mod_text = ''; }
|
|
| 285 |
if(!isset($mod_max_excerpt_num)) { $mod_max_excerpt_num = $func_default_max_excerpt; }
|
|
| 286 |
if(!isset($mod_pic_link)) { $mod_pic_link = ''; }
|
|
| 287 |
if(!isset($mod_no_highlight)) { $mod_no_highlight = false; }
|
|
| 288 |
if(!isset($func_enable_flush)) { $func_enable_flush = false; } // set this in db: wb_search.cfg_enable_flush [READ THE DOC BEFORE]
|
|
| 289 |
if(isset($mod_ext_charset)) |
|
| 290 |
{
|
|
| 291 |
$mod_ext_charset = strtolower($mod_ext_charset); |
|
| 292 |
} else {
|
|
| 293 |
$mod_ext_charset = ''; |
|
| 294 |
} |
|
| 210 |
if(!isset($mod_page_link)) $mod_page_link = $func_page_link; |
|
| 211 |
if(!isset($mod_page_link_target)) $mod_page_link_target = ""; |
|
| 212 |
if(!isset($mod_page_title)) $mod_page_title = $func_page_title; |
|
| 213 |
if(!isset($mod_page_description)) $mod_page_description = $func_page_description; |
|
| 214 |
if(!isset($mod_page_modified_when)) $mod_page_modified_when = $func_page_modified_when; |
|
| 215 |
if(!isset($mod_page_modified_by)) $mod_page_modified_by = $func_page_modified_by; |
|
| 216 |
if(!isset($mod_text)) $mod_text = ""; |
|
| 217 |
if(!isset($mod_max_excerpt_num)) $mod_max_excerpt_num = $func_default_max_excerpt; |
|
| 218 |
if(!isset($mod_pic_link)) $mod_pic_link = ""; |
|
| 219 |
if(!isset($mod_no_highlight)) $mod_no_highlight = false; |
|
| 220 |
if(!isset($func_enable_flush)) $func_enable_flush = false; // set this in db: wb_search.cfg_enable_flush [READ THE DOC BEFORE] |
|
| 221 |
if(isset($mod_ext_charset)) $mod_ext_charset = strtolower($mod_ext_charset); |
|
| 222 |
else $mod_ext_charset = ''; |
|
| 295 | 223 |
|
| 296 | 224 |
if($mod_text == "") // nothing to do |
| 297 | 225 |
{ return false; }
|
| ... | ... | |
| 299 | 227 |
if($mod_no_highlight) // no highlighting |
| 300 | 228 |
{ $mod_page_link_target = "&nohighlight=1".$mod_page_link_target; }
|
| 301 | 229 |
// clean the text: |
| 230 |
$mod_text = preg_replace('#<(br|dt|/dd|/?(?:h[1-6]|tr|table|p|li|ul|pre|code|div|hr))[^>]*>#i', '.', $mod_text);
|
|
| 302 | 231 |
$mod_text = preg_replace('#<(!--.*--|style.*</style|script.*</script)>#iU', ' ', $mod_text);
|
| 303 |
$mod_text = preg_replace('#<(br( /)?|dt|/dd|/?(h[1-6]|tr|table|p|li|ul|pre|code|div|hr))[^>]*>#i', '.', $mod_text);
|
|
| 304 |
// $mod_text = preg_replace('/(\v\s?|\s\s)+/', ' ', $mod_text);
|
|
| 305 |
$mod_text = preg_replace('/\s\./', '.', $mod_text);
|
|
| 232 |
$mod_text = preg_replace('#\[\[.*?\]\]#', '', $mod_text); //Filter droplets from the page data
|
|
| 233 |
// strip_tags() is called below |
|
| 306 | 234 |
if($mod_ext_charset!='') { // data from external database may have a different charset
|
| 307 | 235 |
require_once(WB_PATH.'/framework/functions-utf8.php'); |
| 308 | 236 |
switch($mod_ext_charset) {
|
| ... | ... | |
| 333 | 261 |
$mod_text = charset_to_utf8($mod_text, 'UTF-8'); |
| 334 | 262 |
} |
| 335 | 263 |
} else {
|
| 336 |
$mod_text = entities_to_umlauts($mod_text, 'UTF-8'); |
|
| 264 |
$mod_text = entities_to_umlauts($mod_text, 'UTF-8');
|
|
| 337 | 265 |
} |
| 338 | 266 |
$anchor_text = $mod_text; // make an copy containing html-tags |
| 339 | 267 |
$mod_text = strip_tags($mod_text); |
| 340 |
$mod_text = str_replace(array('>','<','&','"',''',''',' '), array('>','<','&','"','\'','\'',"\xC2\xA0"), $mod_text);
|
|
| 268 |
$mod_text = str_replace(array('>','<','&','"',''',''',' '), array('>','<','&','"','\'','\'',' '), $mod_text);
|
|
| 341 | 269 |
$mod_text = '.'.trim($mod_text).'.'; |
| 342 |
// Do a fast scan over $mod_text first. This will speedup things a lot.
|
|
| 270 |
// Do a fast scan over $mod_text first. This may speedup things a lot.
|
|
| 343 | 271 |
if($func_search_match == 'all') {
|
| 344 | 272 |
if(!is_all_matched($mod_text, $func_search_words)) |
| 345 | 273 |
return false; |
| ... | ... | |
| 349 | 277 |
} |
| 350 | 278 |
// search for an better anchor - this have to be done before strip_tags() (may fail if search-string contains <, &, amp, gt, lt, ...) |
| 351 | 279 |
$anchor = make_url_target($mod_page_link_target, $anchor_text, $func_search_words); |
| 352 |
|
|
| 353 | 280 |
// make the link from $mod_page_link, add anchor |
| 354 | 281 |
$link = ""; |
| 355 | 282 |
$link = page_link($mod_page_link); |
| ... | ... | |
| 366 | 293 |
} |
| 367 | 294 |
$excerpt = prepare_excerpts($excerpt_array, $func_search_words, $mod_max_excerpt_num); |
| 368 | 295 |
} |
| 369 |
|
|
| 370 | 296 |
// handle thumbs - to deactivate this look in the module's search.php: $show_thumb (or maybe in the module's settings-page) |
| 371 | 297 |
if($mod_pic_link != "") {
|
| 372 |
$excerpt = '<table class="excerpt_thumb" width="100%" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td width="110" valign="top"><a href="'.$link.'"><img src="'.WB_URL.'/'.MEDIA_DIRECTORY.$mod_pic_link.'" alt="" /></a></td><td>'.$excerpt.'</td></tr></tbody></table>'; |
|
| 298 |
if(isset($mod_special) && $mod_special=='lightbox2_plus') |
|
| 299 |
$excerpt = '<table class="excerpt_thumb" width="100%" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td width="110" valign="top">'.$mod_special_piclink.'<img src="'.WB_URL.'/'.MEDIA_DIRECTORY.$mod_pic_link.'" alt="" /></a></td><td>'.$excerpt.'</td></tr></tbody></table>'; |
|
| 300 |
else |
|
| 301 |
$excerpt = '<table class="excerpt_thumb" width="100%" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td width="110" valign="top"><a href="'.$link.'"><img src="'.WB_URL.'/'.MEDIA_DIRECTORY.$mod_pic_link.'" alt="" /></a></td><td>'.$excerpt.'</td></tr></tbody></table>'; |
|
| 373 | 302 |
} |
| 374 | 303 |
|
| 375 | 304 |
// print-out the excerpt |
| ... | ... | |
| 377 | 306 |
$values = array(); |
| 378 | 307 |
list($date, $time) = get_page_modified($mod_page_modified_when); |
| 379 | 308 |
list($username, $displayname) = get_page_modified_by($mod_page_modified_by, $func_users); |
| 380 |
$vars = array('[LINK]', '[TITLE]', '[DESCRIPTION]', '[USERNAME]','[DISPLAY_NAME]','[DATE]','[TIME]','[TEXT_LAST_UPDATED_BY]','[TEXT_ON]','[EXCERPT]');
|
|
| 309 |
$vars = array('[LINK]', '[TITLE]','[PAGE_TITLE]' ,'[MENU_TITLE]' , '[DESCRIPTION]', '[USERNAME]','[DISPLAY_NAME]','[DATE]','[TIME]','[TEXT_LAST_UPDATED_BY]','[TEXT_ON]','[EXCERPT]');
|
|
| 381 | 310 |
$values = array( |
| 382 | 311 |
$link, |
| 383 | 312 |
$mod_page_title, |
| 313 |
$func_page_title, |
|
| 314 |
$func_page_menu_title, |
|
| 384 | 315 |
$mod_page_description, |
| 385 | 316 |
$username, |
| 386 | 317 |
$displayname, |
| ... | ... | |
| 423 | 354 |
} |
| 424 | 355 |
|
| 425 | 356 |
// keeps only wanted entries in array $files. $str have to be an eregi()-compatible regex |
| 426 |
/* |
|
| 427 |
function clear_filelist($files, $str, $keep=true) |
|
| 428 |
{
|
|
| 357 |
function clear_filelist($files, $str, $keep=true) {
|
|
| 429 | 358 |
// options: $keep = true : remove all non-matching entries |
| 430 | 359 |
// $keep = false : remove all matching entries |
| 431 | 360 |
$c_filelist = array(); |
| 432 | 361 |
if($str == '') |
| 433 | 362 |
return $files; |
| 434 |
foreach($files as $file) |
|
| 435 |
{
|
|
| 436 |
if($keep) |
|
| 437 |
{
|
|
| 438 |
if(eregi($str, $file)) |
|
| 439 |
{
|
|
| 363 |
foreach($files as $file) {
|
|
| 364 |
if($keep) {
|
|
| 365 |
if(eregi($str, $file)) {
|
|
| 440 | 366 |
$c_filelist[] = $file; |
| 441 | 367 |
} |
| 442 | 368 |
} else {
|
| 443 |
if(!eregi($str, $file)) |
|
| 444 |
{
|
|
| 369 |
if(!eregi($str, $file)) {
|
|
| 445 | 370 |
$c_filelist[] = $file; |
| 446 | 371 |
} |
| 447 | 372 |
} |
| 448 | 373 |
} |
| 449 | 374 |
return($c_filelist); |
| 450 | 375 |
} |
| 451 |
*/ |
|
| 452 |
?> |
|
| 376 |
|
|
| 377 |
function search_make_sql_part($words, $match, $columns) {
|
|
| 378 |
// $words are utf-8 encoded, will be converted to DEFAULT_CHARSET below |
|
| 379 |
if(empty($words) || empty($columns)) return('(1=1)');
|
|
| 380 |
global $database; |
|
| 381 |
|
|
| 382 |
// check if we can use SQL'S "LIKE" |
|
| 383 |
// work-around for WB'S missing-SET-NAMES-problem |
|
| 384 |
static $checked = FALSE; |
|
| 385 |
if($checked===FALSE) {
|
|
| 386 |
$checked = TRUE; |
|
| 387 |
$lowers = array('utf8'=>"\xc3\xa1", 'iso'=>"\xe1");
|
|
| 388 |
$uppers = array('utf8'=>"\xc3\x81", 'iso'=>"\xc1");
|
|
| 389 |
switch(DEFAULT_CHARSET) {
|
|
| 390 |
case 'utf-8': |
|
| 391 |
$lo = $lowers['utf8']; |
|
| 392 |
$up = $uppers['utf8']; |
|
| 393 |
break; |
|
| 394 |
case 'iso-8859-1': |
|
| 395 |
case 'iso-8859-2': |
|
| 396 |
case 'iso-8859-3': |
|
| 397 |
case 'iso-8859-4': |
|
| 398 |
case 'iso-8859-5': |
|
| 399 |
case 'iso-8859-7': |
|
| 400 |
case 'iso-8859-9': |
|
| 401 |
case 'iso-8859-10': |
|
| 402 |
$lo = $lowers['iso']; |
|
| 403 |
$up = $uppers['iso']; |
|
| 404 |
break; |
|
| 405 |
default: |
|
| 406 |
$checked = 'check failed'; // we can't handle arabic,hebrew,thai |
|
| 407 |
} |
|
| 408 |
if($checked===TRUE && $query = $database->query("SELECT UPPER('$lo')='$up'")) {
|
|
| 409 |
$res = $query->fetchRow(); |
|
| 410 |
if($res[0]==0) {
|
|
| 411 |
$checked = 'check failed'; |
|
| 412 |
} |
|
| 413 |
} else |
|
| 414 |
$checked = 'check failed'; |
|
| 415 |
} |
|
| 416 |
|
|
| 417 |
require_once(WB_PATH.'/framework/functions-utf8.php'); |
|
| 418 |
global $search_table_sql_local; |
|
| 419 |
$altnum = count($search_table_sql_local); |
|
| 420 |
|
|
| 421 |
if($match=='all') $op = 'AND'; |
|
| 422 |
else $op = ' OR'; // keep the leading space! |
|
| 423 |
|
|
| 424 |
// create sql-template |
|
| 425 |
$sql = ''; |
|
| 426 |
$i = 0; |
|
| 427 |
foreach($words as $w) {
|
|
| 428 |
if(empty($w)) continue; |
|
| 429 |
$w_alts = $e_alts = array(); |
|
| 430 |
if($altnum) {
|
|
| 431 |
for($x=0;$x<$altnum;$x++) |
|
| 432 |
$w_alts[$x] = strtr($w, $search_table_sql_local[$x]); |
|
| 433 |
} else {
|
|
| 434 |
$w_alts[0] = $w; |
|
| 435 |
} |
|
| 436 |
$w_alts = array_unique($w_alts); |
|
| 437 |
foreach($w_alts as $a) {
|
|
| 438 |
$tmp = htmlentities($a, ENT_COMPAT, 'UTF-8'); |
|
| 439 |
// if the missing-SET-NAMES-issue appears and $tmp contains non-ascii characters: exit and use the normal (slow) search-function instead |
|
| 440 |
if($checked!==TRUE && preg_match('/[\x80-\xFF]/', $tmp)) return('(1=1)'); // missing-SET-NAMES-issue
|
|
| 441 |
$e_alts[] = $tmp; |
|
| 442 |
} |
|
| 443 |
$sql .= ""; |
|
| 444 |
foreach($w_alts as $a) |
|
| 445 |
$sql .= "{{COL}} LIKE '%".addslashes(utf8_to_charset($a))."%' OR ";
|
|
| 446 |
if(isset($e_alts[$i]) && $e_alts[$i]!=$w) |
|
| 447 |
$sql .= " {{COL}} LIKE '%".addslashes($e_alts[$i])."%'";
|
|
| 448 |
else {
|
|
| 449 |
$sql = substr($sql, 0, strlen($sql)-4); |
|
| 450 |
$sql .= ''; |
|
| 451 |
} |
|
| 452 |
$sql .= " $op "; |
|
| 453 |
$i++; |
|
| 454 |
} |
|
| 455 |
$sql = substr($sql, 0, strlen($sql)-5); |
|
| 456 |
$sql_template = $sql; |
|
| 457 |
|
|
| 458 |
// create SQL-string from template |
|
| 459 |
$sql = '(';
|
|
| 460 |
foreach($columns as $c) {
|
|
| 461 |
$sql .= '(';
|
|
| 462 |
$sql .= str_replace('{{COL}}', $c, $sql_template);
|
|
| 463 |
$sql .= ") OR "; |
|
| 464 |
} |
|
| 465 |
$sql = substr($sql, 0, strlen($sql)-4); |
|
| 466 |
$sql .= ')'; |
|
| 467 |
|
|
| 468 |
return($sql); |
|
| 469 |
} |
|
| branches/2.8.x/wb/modules/jsadmin/info.php | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
|
|
| 3 |
// $Id$ |
|
| 4 |
|
|
| 5 |
// JsAdmin module for Website Baker |
|
| 6 |
// Copyright (C) 2006, Stepan Riha |
|
| 7 |
// www.nonplus.net |
|
| 8 |
|
|
| 9 |
/* |
|
| 10 |
Javascript Admin for Website Baker |
|
| 11 |
|
|
| 12 |
Software License Agreement (BSD License) |
|
| 13 |
|
|
| 14 |
Copyright (c) 2006, Stepan Riha. |
|
| 15 |
All rights reserved. |
|
| 16 |
|
|
| 17 |
Portions of this software are Copyright Yahoo! Inc. |
|
| 18 |
|
|
| 19 |
Redistribution and use of this software in source and binary forms, with |
|
| 20 |
or without modification, are permitted provided that the following |
|
| 21 |
conditions are met: |
|
| 22 |
|
|
| 23 |
* Redistributions of source code must retain the above |
|
| 24 |
copyright notice, this list of conditions and the |
|
| 25 |
following disclaimer. |
|
| 26 |
|
|
| 27 |
* Redistributions in binary form must reproduce the above |
|
| 28 |
copyright notice, this list of conditions and the |
|
| 29 |
following disclaimer in the documentation and/or other |
|
| 30 |
materials provided with the distribution. |
|
| 31 |
|
|
| 32 |
* Neither the name of Stepan Riha may be used to endorse or |
|
| 33 |
promote products derived from this software without specific prior |
|
| 34 |
written permission of Stepan Riha. |
|
| 35 |
|
|
| 36 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS |
|
| 37 |
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
|
| 38 |
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
|
| 39 |
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER |
|
| 40 |
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|
| 41 |
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
| 42 |
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
|
| 43 |
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
|
| 44 |
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
| 45 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
|
| 46 |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
| 47 |
*/ |
|
| 48 |
|
|
| 49 |
/* |
|
| 50 |
----------------------------------------------------------------------------------------------------------- |
|
| 51 |
Javascript Admin module for Website Baker v2.7 |
|
| 52 |
Copyright (C) 2006, Stepan Riha |
|
| 53 |
Adapted for Website Baker 2.7 by Swen Uth |
|
| 54 |
----------------------------------------------------------------------------------------------------------- |
|
| 55 |
v1.2 (swen, Swen Uth; Jan 24, 2008) |
|
| 56 |
+ updated YUI framework to version 2.4.1 |
|
| 57 |
+ adapted module to work with Website Baker 2.7 |
|
| 58 |
+ added multilingual support and support of the module.css and module.js files |
|
| 59 |
|
|
| 60 |
v1.0.2 (nonplus, Stepan Riha; May 5, 2006 |
|
| 61 |
initial release by Stepan Riha (all rights reserved) |
|
| 62 |
----------------------------------------------------------------------------------------------------------- |
|
| 63 |
*/ |
|
| 64 |
|
|
| 65 |
$module_directory = 'jsadmin'; |
|
| 66 |
$module_name = 'Javascript Admin'; |
|
| 67 |
$module_function = 'tool'; |
|
| 68 |
$module_version = '1.2.1'; |
|
| 69 |
$module_platform = '2.7 | 2.8.x'; |
|
| 70 |
$module_author = 'Stepan Riha, Swen Uth'; |
|
| 71 |
$module_license = 'BSD License'; |
|
| 72 |
$module_description = 'This module adds Javascript functionality to the Website Baker Admin to improve some of the UI interactions. Uses the YahooUI library.'; |
|
| 73 |
|
|
| 1 |
<?php |
|
| 2 |
/** |
|
| 3 |
* |
|
| 4 |
* @category modules |
|
| 5 |
* @package jsadmin |
|
| 6 |
* @author Independend-Software-Team |
|
| 7 |
* @author WebsiteBaker Project |
|
| 8 |
* @copyright 2004-2009, Ryan Djurovich |
|
| 9 |
* @copyright 2009-2011, Website Baker Org. e.V. |
|
| 10 |
* @link http://www.websitebaker2.org/ |
|
| 11 |
* @license http://www.gnu.org/licenses/gpl.html |
|
| 12 |
* @platform WebsiteBaker 2.8.x |
|
| 13 |
* @requirements PHP 5.2.2 and higher |
|
| 14 |
* @version $Id$ |
|
| 15 |
* @filesource $HeadURL: $ |
|
| 16 |
* @lastmodified $Date: $ |
|
| 17 |
* |
|
| 18 |
*/ |
|
| 19 |
|
|
| 20 |
$module_directory = 'jsadmin'; |
|
| 21 |
$module_name = 'Javascript Admin'; |
|
| 22 |
$module_function = 'tool'; |
|
| 23 |
$module_version = '1.3.0'; |
|
| 24 |
$module_platform = '2.7 | 2.8.x'; |
|
| 25 |
$module_author = 'Stepan Riha, Swen Uth'; |
|
| 26 |
$module_license = 'BSD License'; |
|
| 27 |
$module_description = 'This module adds Javascript functionality to the Website Baker Admin to improve some of the UI interactions. Uses the YahooUI library.'; |
|
| 28 |
|
|
| 74 | 29 |
?> |
| branches/2.8.x/wb/modules/jsadmin/jsadmin_backend_include.php | ||
|---|---|---|
| 34 | 34 |
elseif(strstr($script, $admin_folder."/settings/tool.php") |
| 35 | 35 |
&& isset($_REQUEST["tool"]) && $_REQUEST["tool"] == 'jsadmin') |
| 36 | 36 |
$page_type = 'config'; |
| 37 |
elseif(strstr($script, $admin_folder."/pages/modify.php")) |
|
| 38 |
$page_type = 'modules'; |
|
| 37 | 39 |
else |
| 38 | 40 |
$page_type = ''; |
| 41 |
|
|
| 39 | 42 |
if($page_type) {
|
| 43 |
|
|
| 40 | 44 |
require_once(WB_PATH.'/modules/jsadmin/jsadmin.php'); |
| 41 | 45 |
|
| 42 | 46 |
// Default scripts |
| 43 |
$js_buttonCell = 3;
|
|
| 47 |
$js_buttonCell = 5;
|
|
| 44 | 48 |
$js_scripts = Array(); |
| 45 | 49 |
$js_scripts[] = 'jsadmin.js'; |
| 46 | 50 |
|
| 47 |
if($page_type == 'pages') {
|
|
| 51 |
if($page_type == 'modules') {
|
|
| 48 | 52 |
if(!get_setting('mod_jsadmin_persist_order', '1')) { //Maybe Bug settings to negativ for persist , by Swen Uth
|
| 49 | 53 |
$js_scripts[] = 'restore_pages.js'; |
| 50 | 54 |
} |
| ... | ... | |
| 52 | 56 |
$js_scripts[] = 'dragdrop.js'; |
| 53 | 57 |
$js_buttonCell= 7; // This ist the Cell where the Button "Up" is , by Swen Uth |
| 54 | 58 |
} |
| 59 |
} elseif($page_type == 'pages') {
|
|
| 60 |
if(!get_setting('mod_jsadmin_persist_order', '1')) { //Maybe Bug settings to negativ for persist , by Swen Uth
|
|
| 61 |
$js_scripts[] = 'restore_pages.js'; |
|
| 62 |
} |
|
| 63 |
if(get_setting('mod_jsadmin_ajax_order_pages', '1')) {
|
|
| 64 |
$js_scripts[] = 'dragdrop.js'; |
|
| 65 |
$js_buttonCell= 7; // This ist the Cell where the Button "Up" is , by Swen Uth |
|
| 66 |
} |
|
| 55 | 67 |
} elseif($page_type == 'sections') {
|
| 56 | 68 |
if(get_setting('mod_jsadmin_ajax_order_sections', '1')) {
|
| 57 | 69 |
$js_scripts[] = 'dragdrop.js'; |
| 58 | 70 |
if(SECTION_BLOCKS) {
|
| 59 |
$js_buttonCell= 5;} |
|
| 60 |
else{ $js_buttonCell= 5;} // This ist the Cell where the Button "Up" is , by Swen Uth
|
|
| 71 |
$js_buttonCell= 5; }
|
|
| 72 |
else{ $js_buttonCell= 5; } // This ist the Cell where the Button "Up" is , by Swen Uth
|
|
| 61 | 73 |
} |
| 62 | 74 |
} elseif($page_type == 'config') {
|
| 63 | 75 |
$js_scripts[] = 'tool.js'; |
| 76 |
} else {
|
|
| 77 |
$admin->print_error('PageTtype '.$TEXT['ERROR'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
|
|
| 64 | 78 |
} |
| 65 | 79 |
?> |
| 66 |
|
|
| 67 |
<script type="text/javascript" language="JavaScript"> |
|
| 80 |
<script type="text/javascript"> |
|
| 68 | 81 |
<!-- |
| 69 | 82 |
var JsAdmin = { WB_URL : '<?php echo WB_URL ?>', ADMIN_URL : '<?php echo ADMIN_URL ?>' };
|
| 70 | 83 |
var JsAdminTheme = { THEME_URL : '<?php echo THEME_URL ?>' };
|
| 71 | 84 |
//--> |
| 72 | 85 |
</script> |
| 73 | 86 |
<?php |
| 74 |
// For variable cell structure in the tables of admin content |
|
| 75 |
echo "<script type='text/javascript'>buttonCell=".$js_buttonCell.";</script>\n"; // , by Swen Uth |
|
| 76 |
|
|
| 77 |
// Check and Load the needed YUI functions //, all by Swen Uth |
|
| 78 |
$YUI_ERROR=false; // ist there an Error |
|
| 79 |
$YUI_PUT =''; // String with javascipt includes |
|
| 80 |
$YUI_PUT_MISSING_Files=''; // Strin with missing files |
|
| 81 |
reset($js_yui_scripts); |
|
| 82 |
foreach($js_yui_scripts as $script) {
|
|
| 83 |
if(file_exists($WB_MAIN_RELATIVE_PATH.$script)){
|
|
| 84 |
$YUI_PUT=$YUI_PUT."<script type='text/javascript' src='".$WB_MAIN_RELATIVE_PATH.$script."'></script>\n"; // go and include |
|
| 85 |
} else {
|
|
| 86 |
$YUI_ERROR=true; |
|
| 87 |
$YUI_PUT_MISSING_Files=$YUI_PUT_MISSING_Files."- ".WB_URL.$script."\\n"; // catch all missing files |
|
| 88 |
} |
|
| 87 |
// For variable cell structure in the tables of admin content |
|
| 88 |
echo "<script type='text/javascript'>buttonCell=".$js_buttonCell.";</script>\n"; // , by Swen Uth |
|
| 89 |
// Check and Load the needed YUI functions //, all by Swen Uth |
|
| 90 |
$YUI_ERROR=false; // ist there an Error |
|
| 91 |
$YUI_PUT =''; // String with javascipt includes |
|
| 92 |
$YUI_PUT_MISSING_Files=''; // String with missing files |
|
| 93 |
reset($js_yui_scripts); |
|
| 94 |
foreach($js_yui_scripts as $script) {
|
|
| 95 |
if(file_exists($WB_MAIN_RELATIVE_PATH.$script)){
|
|
| 96 |
$YUI_PUT=$YUI_PUT."<script src='".$WB_MAIN_RELATIVE_PATH.$script."' type='text/javascript'></script>\n"; // go and include |
|
| 97 |
} else {
|
|
| 98 |
$YUI_ERROR=true; |
|
| 99 |
$YUI_PUT_MISSING_Files=$YUI_PUT_MISSING_Files."- ".WB_URL.$script."\\n"; // catch all missing files |
|
| 100 |
} |
|
| 89 | 101 |
} |
| 102 |
/* */ |
|
| 90 | 103 |
if(!$YUI_ERROR) |
| 91 | 104 |
{
|
| 92 |
echo $YUI_PUT; // no Error so go and include
|
|
| 93 |
// Load the needed functions
|
|
| 94 |
foreach($js_scripts as $script) {
|
|
| 95 |
echo "<script type='text/javascript' src='".$JSADMIN_PATH."/js/".$script."'></script>\n";
|
|
| 96 |
}
|
|
| 97 |
} else {
|
|
| 98 |
echo "<script type='text/javascript'>alert('YUI ERROR!! File not Found!! > \\n".$YUI_PUT_MISSING_Files." so look in the include folder or switch Javascript Admin off!');</script>\n"; //, by Swen Uth
|
|
| 99 |
}
|
|
| 105 |
echo $YUI_PUT; // no Error so go and include
|
|
| 106 |
// Load the needed functions
|
|
| 107 |
foreach($js_scripts as $script) {
|
|
| 108 |
echo "<script src='".$JSADMIN_PATH."/js/".$script."' type='text/javascript'></script>\n";
|
|
| 109 |
}
|
|
| 110 |
} else {
|
|
| 111 |
echo "<script type='text/javascript'>alert('YUI ERROR!! File not Found!! > \\n".$YUI_PUT_MISSING_Files." so look in the include folder or switch Javascript Admin off!');</script>\n"; //, by Swen Uth
|
|
| 112 |
}
|
|
| 100 | 113 |
|
| 101 |
} |
|
| 114 |
} else {
|
|
| 115 |
/* |
|
| 116 |
print '<pre><strong>function '.__FUNCTION__.'();</strong> line: '.__LINE__.' -> '; |
|
| 117 |
print_r( $page_type.'/'.$buttonCell ); print '</pre>'; // die(); |
|
| 118 |
*/ |
|
| 119 |
} |
|
| 120 |
|
|
| 121 |
|
|
| 102 | 122 |
?> |
| branches/2.8.x/wb/modules/jsadmin/js/dragdrop.js | ||
|---|---|---|
| 1 |
// Copyright 2006 Stepan Riha |
|
| 2 |
// www.nonplus.net |
|
| 3 |
// $Id: dragdrop.js 2 2006-04-18 03:04:39Z stepan $ |
|
| 4 |
/** |
|
| 5 |
* ----------------------------------------------------------------------------------------- |
|
| 6 |
* MODIFICATON FOR THE JSADMIN MODULE |
|
| 7 |
* ----------------------------------------------------------------------------------------- |
|
| 8 |
* MODIFICATION HISTORY: |
|
| 9 |
* Swen Uth; 01/24/2008 |
|
| 10 |
* +INCLUDE VARIABLE buttonCell FOR ADAPTATION TO LATER LAYOUTS |
|
| 11 |
* |
|
| 12 |
**/ |
|
| 13 |
JsAdmin.DD = {};
|
|
| 14 |
JsAdmin.movable_rows = {};
|
|
| 15 |
|
|
| 16 |
JsAdmin.init_drag_drop = function() {
|
|
| 17 |
|
|
| 18 |
// There seems to be many different ways the ordering is set up |
|
| 19 |
// pages/index.php has UL/LI containing tables with single row |
|
| 20 |
// pages/sections.php has a TABLE with many rows |
|
| 21 |
// pages/modify.php for manuals is completely weird... |
|
| 22 |
// So we only want to deal with pages & sections... |
|
| 23 |
|
|
| 24 |
var page_type = ''; |
|
| 25 |
var is_tree = false; |
|
| 26 |
|
|
| 27 |
if(document.URL.indexOf(JsAdmin.ADMIN_URL + "/pages/index.php") > -1) {
|
|
| 28 |
page_type = 'pages'; |
|
| 29 |
is_tree = true; |
|
| 30 |
|
|
| 31 |
// This page uses duplicate IDs and incorrectly nested lists: |
|
| 32 |
// <ul id="p1"> |
|
| 33 |
// <li id="p1"><table /></li> |
|
| 34 |
// <ul>... sub items ...</ul> |
|
| 35 |
// </ul> |
|
| 36 |
// |
|
| 37 |
// We need to fix that to the following: |
|
| 38 |
// <ul id="p1"> |
|
| 39 |
// <li id="uniqueID"><table /> |
|
| 40 |
// <ul>... sub items ...</ul> |
|
| 41 |
// </li> |
|
| 42 |
// </ul> |
|
| 43 |
|
|
| 44 |
// Stash all UL ids |
|
| 45 |
var ids = {};
|
|
| 46 |
var lists = document.getElementsByTagName('ul');
|
|
| 47 |
for(var i = 0; i < lists.length; i++) {
|
|
| 48 |
if(lists[i].id) {
|
|
| 49 |
ids[lists[i].id] = true; |
|
| 50 |
} |
|
| 51 |
} |
|
| 52 |
|
|
| 53 |
// Now fix all LIs |
|
| 54 |
var items = document.getElementsByTagName('li');
|
|
| 55 |
for(var i = 0; i < items.length; i++) {
|
|
| 56 |
var item = items[i]; |
|
| 57 |
|
|
| 58 |
// Fix duplicate ID |
|
| 59 |
if(ids[item.id]) {
|
|
| 60 |
item.id = JsAdmin.util.getUniqueId(); |
|
| 61 |
} |
|
| 62 |
|
|
| 63 |
// Fix UL parented by UL |
|
| 64 |
var ul = JsAdmin.util.getNextSiblingNode(item, 'ul'); |
|
| 65 |
if(ul) {
|
|
| 66 |
var lis = ul.getElementsByTagName('li');
|
|
| 67 |
if(!lis || lis.length == 0) {
|
|
| 68 |
// Remove list without items |
|
| 69 |
ul.parentNode.removeChild(ul); |
|
| 70 |
} else {
|
|
| 71 |
// Make list child of list item |
|
| 72 |
item.appendChild(ul); |
|
| 73 |
} |
|
| 74 |
} |
|
| 75 |
} |
|
| 76 |
|
|
| 77 |
} else if(document.URL.indexOf("/admin/pages/sections.php") > 0) {
|
|
| 78 |
page_type = 'sections'; |
|
| 79 |
} else {
|
|
| 80 |
// We don't do any other pages |
|
| 81 |
return; |
|
| 82 |
} |
|
| 83 |
|
|
| 84 |
var links = document.getElementsByTagName('a');
|
|
| 85 |
var reImg = /(.*)move_(down|up)\.php(.*)/; |
|
| 86 |
|
|
| 87 |
for(var i = 0; i < links.length; i++) {
|
|
| 88 |
var link = links[i]; |
|
| 89 |
var href = link.href || ''; |
|
| 90 |
var match = href.match(reImg); |
|
| 91 |
if(!match) {
|
|
| 92 |
continue; |
|
| 93 |
} |
|
| 94 |
var url = match[1]; |
|
| 95 |
var op = match[2]; |
|
| 96 |
var params = match[3]; |
|
| 97 |
var tr = JsAdmin.util.getAncestorNode(link, 'tr'); |
|
| 98 |
var item = is_tree ? JsAdmin.util.getAncestorNode(tr, 'li') : tr; |
|
| 99 |
if(!item) {
|
|
| 100 |
continue; |
|
| 101 |
} |
|
| 102 |
|
|
| 103 |
// Make sure we have a unique id |
|
| 104 |
if(!item.id || YAHOO.util.Dom.get(item.id) != item) {
|
|
| 105 |
item.id = JsAdmin.util.getUniqueId(); |
|
| 106 |
} |
|
| 107 |
|
|
| 108 |
if(is_tree) {
|
|
| 109 |
var parent = JsAdmin.util.getAncestorNode(item, 'ul'); |
|
| 110 |
new JsAdmin.DD.liDDSwap(item.id, (parent && parent.id) ? parent.id : 'top'); |
|
| 111 |
} else {
|
|
| 112 |
new JsAdmin.DD.trDDSwap(item.id); |
|
| 113 |
} |
|
| 114 |
item.className += " jsadmin_drag"; |
|
| 115 |
|
|
| 116 |
this.movable_rows[item.id] = { item: item, tr : tr, url : url, params : params };
|
|
| 117 |
} |
|
| 118 |
}; |
|
| 119 |
|
|
| 120 |
//========================================================================== |
|
| 121 |
// Drag-drop utils |
|
| 122 |
//========================================================================== |
|
| 123 |
|
|
| 124 |
JsAdmin.DD.dragee = null; |
|
| 125 |
|
|
| 126 |
JsAdmin.DD.addMoveButton = function(tr, cell, op) {
|
|
| 127 |
if(op == 'down') {
|
|
| 128 |
cell++; |
|
| 129 |
} |
|
| 130 |
var item = JsAdmin.movable_rows[tr.id]; |
|
| 131 |
if(!JsAdmin.util.isNodeType(tr, 'tr')) {
|
|
| 132 |
var rows = tr.getElementsByTagName('tr');
|
|
| 133 |
tr = rows[0]; |
|
| 134 |
} |
|
| 135 |
|
|
| 136 |
var html = '<a href="' + item.url + 'move_' + op + '.php' + item.params |
|
| 137 |
+ '"><img src="' + JsAdminTheme.THEME_URL + '/images/' + op |
|
| 138 |
+ '_16.png" border="0" alt="' + op + '" /></a>'; |
|
| 139 |
tr.cells[cell].innerHTML = html; |
|
| 140 |
}; |
|
| 141 |
|
|
| 142 |
JsAdmin.DD.deleteMoveButton = function(tr, cell, op) {
|
|
| 143 |
if(op == 'down') {
|
|
| 144 |
cell++; |
|
| 145 |
} |
|
| 146 |
if(!JsAdmin.util.isNodeType(tr, 'tr')) {
|
|
| 147 |
var rows = tr.getElementsByTagName('tr');
|
|
| 148 |
tr = rows[0]; |
|
| 149 |
} |
|
| 150 |
|
|
| 151 |
tr.cells[cell].innerHTML = ""; |
|
| 152 |
}; |
|
| 153 |
|
|
| 154 |
//========================================================================== |
|
| 155 |
// Drag-drop handling for table rows |
|
| 156 |
//========================================================================== |
|
| 157 |
|
|
| 158 |
JsAdmin.DD.trDDSwap = function(id, sGroup) {
|
|
| 159 |
this.init(id, sGroup); |
|
| 160 |
this.addInvalidHandleType('a');
|
|
| 161 |
this.addInvalidHandleType('input');
|
|
| 162 |
this.addInvalidHandleType('select');
|
|
| 163 |
this.initFrame(); |
|
| 164 |
this.buttonCell = buttonCell;//, by Swen Uth |
|
| 165 |
|
|
| 166 |
// For Connection |
|
| 167 |
this.scope = this; |
|
| 168 |
}; |
|
| 169 |
|
|
| 170 |
JsAdmin.DD.trDDSwap.prototype = new YAHOO.util.DDProxy(); |
|
| 171 |
|
|
| 172 |
JsAdmin.DD.trDDSwap.prototype.startDrag = function(x, y) {
|
|
| 173 |
if (JsAdmin.DD.dragee != this) {
|
|
| 174 |
this.rowIndex = this.getEl().rowIndex; |
|
| 175 |
this.numRows = this.getEl().parentNode.rows.length; |
|
| 176 |
this.opacity = YAHOO.util.Dom.getStyle(this.getEl(), "opacity"); |
|
| 177 |
this.background = YAHOO.util.Dom.getStyle(this.getEl(), "background"); |
|
| 178 |
YAHOO.util.Dom.setStyle(this.getEl(), "opacity", 0.5); |
|
| 179 |
YAHOO.util.Dom.setStyle(this.getEl(), "background", "transparent"); |
|
| 180 |
} |
|
| 181 |
JsAdmin.DD.dragee = this; |
|
| 182 |
}; |
|
| 183 |
|
|
| 184 |
JsAdmin.DD.trDDSwap.prototype.onDragEnter = function(e, id) {
|
|
| 185 |
var elt = id ? YAHOO.util.Dom.get(id) : null; |
|
| 186 |
var item = JsAdmin.movable_rows[this.getEl().id]; |
|
| 187 |
var rows = item.tr.parentNode.rows; |
|
| 188 |
var wasFirst = item.tr.rowIndex == 1; |
|
| 189 |
var wasLast = item.tr.rowIndex == this.numRows - 2; |
|
| 190 |
if(elt.rowIndex < item.tr.rowIndex) {
|
|
| 191 |
elt.parentNode.insertBefore(item.tr, elt); |
|
| 192 |
} else {
|
|
| 193 |
elt.parentNode.insertBefore(elt, item.tr); |
|
| 194 |
} |
|
| 195 |
// Fixup buttons |
|
| 196 |
var isFirst = item.tr.rowIndex == 1; |
|
| 197 |
var isLast = item.tr.rowIndex == this.numRows - 2; |
|
| 198 |
|
|
| 199 |
if(wasFirst != isFirst) {
|
|
| 200 |
if(isFirst) {
|
|
| 201 |
JsAdmin.DD.deleteMoveButton(item.tr, this.buttonCell, 'up'); |
|
| 202 |
JsAdmin.DD.addMoveButton(JsAdmin.util.getNextSiblingNode(item.tr), this.buttonCell, 'up'); |
|
| 203 |
} else {
|
|
| 204 |
JsAdmin.DD.addMoveButton(item.tr, this.buttonCell, 'up'); |
|
| 205 |
JsAdmin.DD.deleteMoveButton(rows[1], this.buttonCell, 'up'); |
|
| 206 |
} |
|
| 207 |
} |
|
| 208 |
if(wasLast != isLast) {
|
|
| 209 |
if(isLast) {
|
|
| 210 |
JsAdmin.DD.deleteMoveButton(item.tr, this.buttonCell, 'down'); |
|
| 211 |
JsAdmin.DD.addMoveButton(JsAdmin.util.getPreviousSiblingNode(item.tr), this.buttonCell, 'down'); |
|
| 212 |
} else {
|
|
| 213 |
JsAdmin.DD.addMoveButton(item.tr, this.buttonCell, 'down'); |
|
| 214 |
JsAdmin.DD.deleteMoveButton(rows[rows.length-2], this.buttonCell, 'down'); |
|
| 215 |
} |
|
| 216 |
} |
|
| 217 |
|
|
| 218 |
this.DDM.refreshCache(this.groups); |
|
| 219 |
}; |
|
| 220 |
|
|
| 221 |
JsAdmin.DD.trDDSwap.prototype.endDrag = function(e) {
|
|
| 222 |
YAHOO.util.Dom.setStyle(this.getEl(), "opacity", this.opacity); |
|
| 223 |
YAHOO.util.Dom.setStyle(this.getEl(), "background", "#f0f0f0"); |
|
| 224 |
|
|
| 225 |
JsAdmin.DD.dragee = null; |
|
| 226 |
|
|
| 227 |
var newIndex = this.getEl().rowIndex; |
|
| 228 |
if(newIndex != this.rowIndex) {
|
|
| 229 |
var url = JsAdmin.WB_URL + "/modules/jsadmin/move_to.php"; |
|
| 230 |
url += JsAdmin.movable_rows[this.getEl().id].params + "&position=" + newIndex; |
|
| 231 |
document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/g, "$1") + " jsadmin_busy"; |
|
| 232 |
YAHOO.util.Connect.asyncRequest('GET', url, this, null);
|
|
| 233 |
} |
|
| 234 |
}; |
|
| 235 |
|
|
| 236 |
JsAdmin.DD.trDDSwap.prototype.success = function(o) {
|
|
| 237 |
document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/g, "$1") + " jsadmin_success"; |
|
| 238 |
}; |
|
| 239 |
|
|
| 240 |
JsAdmin.DD.trDDSwap.prototype.failure = function(o) {
|
|
| 241 |
document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/, "$1") + " jsadmin_failure"; |
|
| 242 |
}; |
|
| 243 |
|
|
| 244 |
//========================================================================== |
|
| 245 |
// Drag-drop handling for list items |
|
| 246 |
//========================================================================== |
|
| 247 |
|
|
| 248 |
JsAdmin.DD.liDDSwap = function(id, sGroup) {
|
|
| 249 |
this.init(id, sGroup); |
|
| 250 |
this.addInvalidHandleType('a');
|
|
| 251 |
this.addInvalidHandleType('input');
|
|
| 252 |
this.addInvalidHandleType('select');
|
|
| 253 |
this.initFrame(); |
|
| 254 |
this.buttonCell = buttonCell;//, by Swen Uth |
|
| 255 |
this.counter = 0; |
|
| 256 |
}; |
|
| 257 |
|
|
| 258 |
JsAdmin.DD.liDDSwap.prototype = new YAHOO.util.DDProxy(); |
|
| 259 |
|
|
| 260 |
JsAdmin.DD.liDDSwap.prototype.startDrag = function(x, y) {
|
|
| 261 |
// On IE, startDrag is sometimes called twice |
|
| 262 |
if(JsAdmin.DD.dragee && JsAdmin.DD.dragee != this) {
|
|
| 263 |
JsAdmin.DD.dragee.endDrag(null); |
|
| 264 |
} |
|
| 265 |
if(JsAdmin.DD.dragee != this) {
|
|
| 266 |
this.rowIndex = JsAdmin.util.getItemIndex(this.getEl()); |
|
| 267 |
this.opacity = YAHOO.util.Dom.getStyle(this.getEl(), "opacity"); |
|
| 268 |
this.background = YAHOO.util.Dom.getStyle(this.getEl(), "background"); |
|
| 269 |
YAHOO.util.Dom.setStyle(this.getEl(), "opacity", 0.5); |
|
| 270 |
|
|
| 271 |
this.list = JsAdmin.util.getAncestorNode(this.getEl(), "ul"); |
|
| 272 |
this.list.className += " jsadmin_drag_area"; |
|
| 273 |
} |
|
| 274 |
JsAdmin.DD.dragee = this; |
|
| 275 |
}; |
|
| 276 |
|
|
| 277 |
JsAdmin.DD.liDDSwap.prototype.onDragEnter = function(e, id) {
|
|
| 278 |
// Swap with other element |
|
| 279 |
var elt = id ? YAHOO.util.Dom.get(id) : null; |
|
| 280 |
var item = JsAdmin.movable_rows[this.getEl().id]; |
|
| 281 |
var eltRowIndex = JsAdmin.util.getItemIndex(elt); |
|
| 282 |
var rowIndex = JsAdmin.util.getItemIndex(this.getEl()); |
|
| 283 |
var wasFirst = !JsAdmin.util.getPreviousSiblingNode(this.getEl()); |
|
| 284 |
var wasLast = !JsAdmin.util.getNextSiblingNode(this.getEl()); |
|
| 285 |
|
|
| 286 |
if(eltRowIndex < rowIndex) {
|
|
| 287 |
elt.parentNode.insertBefore(this.getEl(), elt); |
|
| 288 |
} else {
|
|
| 289 |
elt.parentNode.insertBefore(elt, this.getEl()); |
|
| 290 |
} |
|
| 291 |
// Fixup buttons |
|
| 292 |
var isFirst = !JsAdmin.util.getPreviousSiblingNode(this.getEl()); |
|
| 293 |
var isLast = !JsAdmin.util.getNextSiblingNode(this.getEl()); |
|
| 294 |
|
|
| 295 |
if(wasFirst != isFirst) {
|
|
| 296 |
if(isFirst) {
|
|
| 297 |
JsAdmin.DD.deleteMoveButton(item.tr, this.buttonCell, 'up'); |
|
| 298 |
JsAdmin.DD.addMoveButton(JsAdmin.util.getNextSiblingNode(item.item), this.buttonCell, 'up'); |
|
| 299 |
} else {
|
|
| 300 |
JsAdmin.DD.addMoveButton(item.item, this.buttonCell, 'up'); |
|
| 301 |
var first, prev = JsAdmin.util.getPreviousSiblingNode(item.item); |
|
| 302 |
while(prev) {
|
|
| 303 |
first = prev; |
|
| 304 |
prev = JsAdmin.util.getPreviousSiblingNode(prev); |
|
| 305 |
} |
|
| 306 |
JsAdmin.DD.deleteMoveButton(JsAdmin.movable_rows[first.id].tr, this.buttonCell, 'up'); |
|
| 307 |
} |
|
| 308 |
} |
|
| 309 |
if(wasLast != isLast) {
|
|
| 310 |
if(isLast) {
|
|
| 311 |
JsAdmin.DD.deleteMoveButton(item.tr, this.buttonCell, 'down'); |
|
| 312 |
JsAdmin.DD.addMoveButton(JsAdmin.util.getPreviousSiblingNode(item.item), this.buttonCell, 'down'); |
|
| 313 |
} else {
|
|
| 314 |
JsAdmin.DD.addMoveButton(item.item, this.buttonCell, 'down'); |
|
| 315 |
var last, next = JsAdmin.util.getNextSiblingNode(item.item); |
|
| 316 |
while(next) {
|
|
| 317 |
last = next; |
|
| 318 |
next = JsAdmin.util.getNextSiblingNode(next); |
|
| 319 |
} |
|
| 320 |
JsAdmin.DD.deleteMoveButton(JsAdmin.movable_rows[last.id].tr, this.buttonCell, 'down'); |
|
| 321 |
} |
|
| 322 |
} |
|
| 323 |
|
|
| 324 |
this.DDM.refreshCache(this.groups); |
|
| 325 |
}; |
|
| 326 |
|
|
| 327 |
JsAdmin.DD.liDDSwap.prototype.endDrag = function(e) {
|
|
| 328 |
YAHOO.util.Dom.setStyle(this.getEl(), "opacity", this.opacity); |
|
| 329 |
this.list.className = String(this.list.className).replace(/(\s*)jsadmin_([a-z]+)/g, "$1"); |
|
| 330 |
JsAdmin.DD.dragee = null; |
|
| 331 |
var newIndex = JsAdmin.util.getItemIndex(this.getEl()); |
|
| 332 |
if(newIndex != this.rowIndex) {
|
|
| 333 |
var url = JsAdmin.WB_URL + "/modules/jsadmin/move_to.php"; |
|
| 334 |
url += JsAdmin.movable_rows[this.getEl().id].params + "&position=" + (newIndex+1); |
|
| 335 |
document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/g, "$1") + " jsadmin_busy"; |
|
| 336 |
YAHOO.util.Connect.asyncRequest('GET', url, this, null);
|
|
| 337 |
} |
|
| 338 |
}; |
|
| 339 |
|
|
| 340 |
JsAdmin.DD.liDDSwap.prototype.success = function(o) {
|
|
| 341 |
document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/g, "$1") + " jsadmin_success"; |
|
| 342 |
}; |
|
| 343 |
|
|
| 344 |
JsAdmin.DD.liDDSwap.prototype.failure = function(o) {
|
|
| 345 |
document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/, "$1") + " jsadmin_failure"; |
|
| 346 |
}; |
|
| 1 |
// Copyright 2006 Stepan Riha |
|
| 2 |
// www.nonplus.net |
|
| 3 |
// $Id: dragdrop.js 2 2006-04-18 03:04:39Z stepan $ |
|
| 4 |
/** |
|
| 5 |
* ----------------------------------------------------------------------------------------- |
|
| 6 |
* MODIFICATON FOR THE JSADMIN MODULE |
|
| 7 |
* ----------------------------------------------------------------------------------------- |
|
| 8 |
* MODIFICATION HISTORY: |
|
| 9 |
* Swen Uth; 01/24/2008 |
|
| 10 |
* +INCLUDE VARIABLE buttonCell FOR ADAPTATION TO LATER LAYOUTS |
|
| 11 |
* |
|
| 12 |
**/ |
|
| 13 |
JsAdmin.DD = {};
|
|
| 14 |
JsAdmin.movable_rows = {};
|
|
| 15 |
|
|
| 16 |
JsAdmin.init_drag_drop = function() {
|
|
| 17 |
|
|
| 18 |
// There seems to be many different ways the ordering is set up |
|
| 19 |
// pages/index.php has UL/LI containing tables with single row |
|
| 20 |
// pages/sections.php has a TABLE with many rows |
|
| 21 |
// pages/modify.php for manuals is completely weird... |
|
| 22 |
// So we only want to deal with pages & sections... |
|
| 23 |
|
|
| 24 |
var page_type = ''; |
|
| 25 |
var is_tree = false; |
|
| 26 |
|
|
| 27 |
if(document.URL.indexOf(JsAdmin.ADMIN_URL + "/pages/index.php") > -1) {
|
|
| 28 |
page_type = 'pages'; |
|
| 29 |
is_tree = true; |
|
| 30 |
|
|
| 31 |
// This page uses duplicate IDs and incorrectly nested lists: |
|
| 32 |
// <ul id="p1"> |
|
| 33 |
// <li id="p1"><table /></li> |
|
| 34 |
// <ul>... sub items ...</ul> |
|
| 35 |
// </ul> |
|
| 36 |
// |
|
| 37 |
// We need to fix that to the following: |
|
| 38 |
// <ul id="p1"> |
|
| 39 |
// <li id="uniqueID"><table /> |
|
| 40 |
// <ul>... sub items ...</ul> |
|
| 41 |
// </li> |
|
Also available in: Unified diff