isLoggedIn()) { bm_loginAndPassThrough(); exit; } // on successfull login if (($action == 'login') && ($member->isLoggedIn())) $action = requestVar('nextaction'); if ($action == '') $action = 'add'; sendContentType('application/xhtml+xml', 'bookmarklet-'.$action); // check ticket $action = strtolower($action); $aActionsNotToCheck = array('login', 'add', 'edit'); if (!in_array($action, $aActionsNotToCheck)) { if (!$manager->checkTicket()) bm_doError(_ERROR_BADTICKET); } // find out what to do switch ($action) { case 'additem': bm_doAddItem(); // adds the item for real break; case 'edit': bm_doEditForm(); // shows the edit item form break; case 'edititem': // edits the item for real bm_doEditItem(); break; case 'login': // on login, 'action' gets changed to 'nextaction' bm_doError('Something went wrong'); break; case 'add': default: bm_doShowForm(); // shows the fill in form break; } function bm_doAddItem() { global $member, $manager, $CONF; $manager->loadClass('ITEM'); $result = ITEM::createFromRequest(); if ($result['status'] == 'error') bm_doError($result['message']); $blogid = getBlogIDFromItemID($result['itemid']); $blog =& $manager->getBlog($blogid); if ($result['status'] == 'newcategory') { $message = 'アイテムは追加され、新しいカテゴリーが作成されました。 ここをクリックしてカテゴリーの名前と説明を編集してください。'; $extrahead = ''; } elseif ((postVar('actiontype') == 'addnow') && $blog->pingUserland()) { $message = 'アイテムの追加に成功しました。現在weblogs.comにpingを送っています。しばらくの間お待ちください...'; $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'); // only allow if user is allowed to alter item if (!$member->canUpdateItem($itemid, $catid)) bm_doError(_ERROR_DISALLOWED); $body = postVar('body'); $title = postVar('title'); $more = postVar('more'); $closed = intPostVar('closed'); $actiontype = postVar('actiontype'); // redirect to admin area on delete (has delete confirmation) if ($actiontype == 'delete') { 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"); // create $blog =& $manager->getBlog($blogid); $catid = $blog->createNewCategory(); // show error when sth goes wrong 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')); break; case 'edit': $publish = 1; $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); // show success message if ($catid != intPostVar('catid')) bm_message(_ITEM_UPDATED, _ITEM_UPDATED, 'アイテムは追加され、新しいカテゴリーが作成されました。ここをクリックしてカテゴリーの名前と説明を編集してください。', ''); else bm_message(_ITEM_UPDATED, _ITEM_UPDATED, _ITEM_UPDATED, ''); } function bm_loginAndPassThrough() { $blogid = intRequestVar('blogid'); $log_text = requestVar('logtext'); $log_link = requestVar('loglink'); $log_linktitle = requestVar('loglinktitle'); ?> Nucleus

:

:



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

'; echo ''; } function bm_doContextMenuCode() { global $CONF; ?>