X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=nucleus%2Fbookmarklet.php;h=0388874820cac6bd523d0b63157652f7ec7d1e43;hb=e68c9a135bca5e1f54671ec0013714adb1d26f15;hp=76e0f26e36191cdb810339ff389873c9e4bb2492;hpb=ca2d0941629122298c7e9dfa98402f37e2024a96;p=nucleus-jp%2Fnucleus-jp-ancient.git diff --git a/nucleus/bookmarklet.php b/nucleus/bookmarklet.php index 76e0f26..0388874 100755 --- a/nucleus/bookmarklet.php +++ b/nucleus/bookmarklet.php @@ -1,26 +1,29 @@ -isLoggedIn()) { +if (!$member->isLoggedIn() ) { bm_loginAndPassThrough(); exit; } // on successfull login -if (($action == 'login') && ($member->isLoggedIn())) +if ( ($action == 'login') && ($member->isLoggedIn() ) ) { $action = requestVar('nextaction'); -if ($action == '') +} + +if ($action == '') { $action = 'add'; - -sendContentType('application/xhtml+xml', 'bookmarklet-'.$action); +} + +sendContentType('text/html', 'bookmarklet-' . $action); // check ticket $action = strtolower($action); $aActionsNotToCheck = array('login', 'add', 'edit'); -if (!in_array($action, $aActionsNotToCheck)) -{ - if (!$manager->checkTicket()) + +if (!in_array($action, $aActionsNotToCheck) ) { + + if (!$manager->checkTicket() ) { bm_doError(_ERROR_BADTICKET); -} + } +} // find out what to do switch ($action) { + // adds the item for real case 'additem': - bm_doAddItem(); // adds the item for real + bm_doAddItem(); break; + + // shows the edit item form case 'edit': - bm_doEditForm(); // shows the edit item form + bm_doEditForm(); break; - case 'edititem': // edits the item for real + + // edits the item for real + case 'edititem': bm_doEditItem(); break; - case 'login': // on login, 'action' gets changed to 'nextaction' + + // on login, 'action' gets changed to 'nextaction' + case 'login': bm_doError('Something went wrong'); break; + + // shows the fill in form case 'add': default: - bm_doShowForm(); // shows the fill in form + bm_doShowForm(); break; } - + function bm_doAddItem() { global $member, $manager, $CONF; - + $manager->loadClass('ITEM'); $result = ITEM::createFromRequest(); - - if ($result['status'] == 'error') + + if ($result['status'] == 'error') { bm_doError($result['message']); + } $blogid = getBlogIDFromItemID($result['itemid']); $blog =& $manager->getBlog($blogid); - + if ($result['status'] == 'newcategory') { - $message = 'アイテムは追加され、新しいカテゴリーが作成されました。 ここをクリックしてカテゴリーの名前と説明を編集してください。'; + $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 . ''; $extrahead = ''; - } elseif ((postVar('actiontype') == 'addnow') && $blog->pingUserland()) { - $message = 'アイテムの追加に成功しました。現在weblogs.comにpingを送っています。しばらくの間お待ちください...'; - $extrahead = ''; + } elseif ( (postVar('actiontype') == 'addnow') && $blog->sendPing() ) { + $message = _BOOKMARKLET_SEND_PING; + $pingUrl = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=sendping&blogid=' . intval($blogid) ); + $extrahead = ''; } else { $message = _ITEM_ADDED; $extrahead = ''; } - + bm_message(_ITEM_ADDED, _ITEM_ADDED, $message,$extrahead); } function bm_doEditItem() { global $member, $manager, $CONF; - - $itemid = intRequestVar('itemid'); - $catid = postVar('catid'); - + + $itemid = intRequestVar('itemid'); + $catid = postVar('catid'); + // only allow if user is allowed to alter item - if (!$member->canUpdateItem($itemid, $catid)) + if (!$member->canUpdateItem($itemid, $catid) ) { bm_doError(_ERROR_DISALLOWED); + } - $body = postVar('body'); - $title = postVar('title'); - $more = postVar('more'); - $closed = intPostVar('closed'); + $body = postVar('body'); + $title = postVar('title'); + $more = postVar('more'); + $closed = intPostVar('closed'); $actiontype = postVar('actiontype'); - + $draftid = intPostVar('draftid'); + // redirect to admin area on delete (has delete confirmation) if ($actiontype == 'delete') { - redirect('index.php?action=itemdelete&itemid='.$itemid); - exit; + redirect('index.php?action=itemdelete&itemid=' . $itemid); + exit; } - + // create new category if needed (only on edit/changedate) - if (strstr($catid,'newcat')) { - // get blogid - list($blogid) = sscanf($catid,"newcat-%d"); + if (strstr($catid,'newcat') ) { + // get blogid + list($blogid) = sscanf($catid, "newcat-%d"); // create $blog =& $manager->getBlog($blogid); $catid = $blog->createNewCategory(); // show error when sth goes wrong - if (!$catid) + if (!$catid) { bm_doError('Could not create new category'); - } + } + } // only edit action is allowed for bookmarklet edit switch ($actiontype) { case 'changedate': $publish = 1; $wasdraft = 0; - $timestamp = mktime(postVar('hour'), postVar('minutes'), 0, postVar('month'), postVar('day'), postVar('year')); + $timestamp = mktime(intPostVar('hour'), intPostVar('minutes'), 0, intPostVar('month'), intPostVar('day'), intPostVar('year') ); break; case 'edit': $publish = 1; $wasdraft = 0; $timestamp = 0; break; + case 'backtodrafts': + $publish = 0; + $wasdraft = 0; + $timestamp = 0; + break; default: bm_doError('Something went wrong'); } - + // update item for real ITEM::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp); - + + if ($draftid > 0) { + ITEM::delete($draftid); + } + // show success message - if ($catid != intPostVar('catid')) - bm_message(_ITEM_UPDATED, _ITEM_UPDATED, 'アイテムは追加され、新しいカテゴリーが作成されました。ここをクリックしてカテゴリーの名前と説明を編集してください。', ''); - else + if ($catid != intPostVar('catid') ) { + $href = 'index.php?action=categoryedit&blogid=' . $blog->getID() . '&catid=' . $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 . ''; + bm_message(_ITEM_UPDATED, _ITEM_UPDATED, _BOOKMARKLET_NEW_CATEGORY . $aTag . _BOOKMARKLET_NEW_CATEGORY_EDIT . '', ''); + } else { bm_message(_ITEM_UPDATED, _ITEM_UPDATED, _ITEM_UPDATED, ''); + } } function bm_loginAndPassThrough() { @@ -167,34 +208,34 @@ function bm_loginAndPassThrough() { $log_text = requestVar('logtext'); $log_link = requestVar('loglink'); $log_linktitle = requestVar('loglinktitle'); - + ?> - + > Nucleus -

- +

+

- - - - - : + + + + + :
-
: +
:


-
+

-

+

isTeamMember($blogid)) + if (!$member->isTeamMember($blogid) ) { bm_doError(_ERROR_NOTONTEAM); - + } + $logje = ''; - if ($log_text) - $logje .= '
"' . htmlspecialchars($log_text) .'"
' . "\n"; - if (!$log_linktitle) + + if ($log_text) { + $logje .= '
"' . htmlspecialchars($log_text) . '"
' . "\n"; + } + + if (!$log_linktitle) { $log_linktitle = $log_link; - if ($log_link) - $logje .= ''. htmlspecialchars($log_linktitle).''; - + } + + if ($log_link) { + $logje .= '' . htmlspecialchars($log_linktitle) . ''; + } $item['body'] = $logje; $item['title'] = htmlspecialchars($log_linktitle); $factory = new PAGEFACTORY($blogid); - $factory->createAddForm('bookmarklet',$item); + $factory->createAddForm('bookmarklet', $item); } function bm_doEditForm() { global $member, $manager; - + $itemid = intRequestVar('itemid'); - - if (!$manager->existsItem($itemid, 0, 0)) + + if (!$manager->existsItem($itemid, 0, 0) ) { bm_doError(_ERROR_NOSUCHITEM); - - if (!$member->canAlterItem($itemid)) + } + + if (!$member->canAlterItem($itemid) ) { bm_doError(_ERROR_DISALLOWED); - - $item =& $manager->getItem($itemid,1,1); - $blog =& $manager->getBlog(getBlogIDFromItemID($itemid)); - - $manager->notify('PrepareItemForEdit', array('item' => &$item)); + } + + $item =& $manager->getItem($itemid, 1, 1); + $blog =& $manager->getBlog(getBlogIDFromItemID($itemid) ); - if ($blog->convertBreaks()) { + $manager->notify('PrepareItemForEdit', array('item' => &$item) ); + + if ($blog->convertBreaks() ) { $item['body'] = removeBreaks($item['body']); $item['more'] = removeBreaks($item['more']); } - $formfactory = new PAGEFACTORY($blog->getID()); - $formfactory->createEditForm('bookmarklet',$item); - + $formfactory = new PAGEFACTORY($blog->getID() ); + $formfactory->createEditForm('bookmarklet', $item); } function bm_doError($msg) { - bm_message(_ERROR,_ERRORMSG,$msg); + bm_message(_ERROR, _ERRORMSG, $msg); die; } function bm_message($title, $head, $msg, $extrahead = '') { ?> - + > - <?php echo $title ?> + <?php echo $title ?> - + -

-

-

+

+

+

- - '; - echo ''; + echo ''; } function bm_doContextMenuCode() { global $CONF; ?> + +?> \ No newline at end of file