X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=nucleus%2Fbookmarklet.php;h=a7ddd842fd58cc0606dde93503ec40698566c5c8;hb=275e8ede1b20d1e47618abe32a87c67a1f650552;hp=ce4f953d606866127be8f9952511d5cf268db2d9;hpb=2359bf5e5dba90d81dd78483e37106970a62d0d7;p=nucleus-jp%2Fnucleus-next.git diff --git a/nucleus/bookmarklet.php b/nucleus/bookmarklet.php index ce4f953..a7ddd84 100644 --- a/nucleus/bookmarklet.php +++ b/nucleus/bookmarklet.php @@ -25,11 +25,20 @@ $CONF['UsingAdminArea'] = 1; // include all classes and config data include('../config.php'); +// get skin object +$skinid = $CONF['BookmarkletSkin']; +if ( !Skin::existsID($skinid) ) +{ + echo _ERROR_SKIN; + exit; +} +$skin =& $manager->getSkin($skinid, 'AdminActions', 'AdminSkin'); + // check logged-in or pass through $action = requestVar('action'); if ( !$member->isLoggedIn() ) { - bm_loginAndPassThrough($action); + bm_loginAndPassThrough($skin, $action); exit; } else if ( $action == 'login') @@ -49,16 +58,13 @@ else if ( $action == '' ) $action = 'add'; } -// send HTTP 1.1 message header for Content-Type -sendContentType('text/html', 'bookmarklet-' . $action); - // check ticket $aActionsNotToCheck = array('login', 'add', 'edit'); if ( !in_array($action, $aActionsNotToCheck) ) { if ( !$manager->checkTicket() ) { - bm_doError(_ERROR_BADTICKET); + bm_doError($skin, _ERROR_BADTICKET); } } @@ -67,32 +73,32 @@ switch ( $action ) { // adds the item for real case 'additem': - bm_doAddItem(); + bm_doAddItem($skin); break; // shows the edit item form case 'edit': - bm_doEditForm(); + bm_doEditForm($skin); break; // edits the item for real case 'edititem': - bm_doEditItem(); + bm_doEditItem($skin); break; // on login, 'action' gets changed to 'nextaction' case 'login': - bm_doError('Something went wrong'); + bm_doError($skin, 'Something went wrong'); break; // shows the fill in form case 'add': default: - bm_doShowForm(); + bm_doShowForm($skin); break; } -function bm_doAddItem() +function bm_doAddItem($skin) { global $member, $manager, $CONF; @@ -101,7 +107,7 @@ function bm_doAddItem() if ( $result['status'] == 'error' ) { - bm_doError($result['message']); + bm_doError($skin, $result['message']); } $blogid = getBlogIDFromItemID($result['itemid']); @@ -118,12 +124,12 @@ function bm_doAddItem() $extrahead = ''; } - bm_message(_ITEM_ADDED, _ITEM_ADDED, $message,$extrahead); + bm_message($skin, _ITEM_ADDED, $message,$extrahead); return; } -function bm_doEditItem() +function bm_doEditItem($skin) { global $member, $manager, $CONF; @@ -133,7 +139,7 @@ function bm_doEditItem() // only allow if user is allowed to alter item if ( !$member->canUpdateItem($itemid, $catid) ) { - bm_doError(_ERROR_DISALLOWED); + bm_doError($skin, _ERROR_DISALLOWED); } $body = postVar('body'); @@ -163,7 +169,7 @@ function bm_doEditItem() // show error when sth goes wrong if ( !$catid ) { - bm_doError('Could not create new category'); + bm_doError($skin, 'Could not create new category'); } } @@ -186,7 +192,7 @@ function bm_doEditItem() $timestamp = 0; break; default: - bm_doError('Something went wrong'); + bm_doError($skin, 'Something went wrong'); } // update item for real @@ -197,60 +203,50 @@ function bm_doEditItem() Item::delete($draftid); } - // show success message - if ( $catid != intPostVar('catid') ) + if ( $result['status'] == 'newcategory' ) { - bm_message(_ITEM_UPDATED, _ITEM_UPDATED, 'Item was added, and a new category was created. Click here to edit the name and description of the category.', ''); + $href = "index.php?action=categoryedit&blogid={$blogid}&catid={$result['catid']}"; + $onclick = 'if (event && event.preventDefault) event.preventDefault(); window.open(this.href); return false;'; + $title = _BOOKMARKLET_NEW_WINDOW; + $aTag = " "; + $message = _BOOKMARKLET_NEW_CATEGORY . $aTag . _BOOKMARKLET_NEW_CATEGORY_EDIT . ''; } else { - bm_message(_ITEM_UPDATED, _ITEM_UPDATED, _ITEM_UPDATED, ''); + $message = _ITEM_ADDED; } + // show success message + bm_message($skin, _ITEM_ADDED, $message, ''); return; } -function bm_loginAndPassThrough($action='add') +function bm_loginAndPassThrough($skin, $action='add') { + /* + * TODO: ãããåºåããã $blogid = intRequestVar('blogid'); $itemid = intRequestVar('itemid'); - $log_text = requestVar('logtext'); - $log_link = requestVar('loglink'); - $log_linktitle = requestVar('loglinktitle'); - - echo "\n"; - echo "\n"; - echo "
\n"; - echo "{$msg}
\n"; - echo '\n"; - echo "\n"; - echo "\n"; + Admin::$extrahead = $extrahead; + Admin::$headMess = $msg; + $skin->parse('adminerrorpage'); return; } -function bm_style() -{ - echo "\n"; - echo "\n"; - return; -} - function bm_doContextMenuCode($width=600, $height=500) { - global $CONF; - + global $CONF; $blogid = (integer) intGetVar('blogid'); echo "