當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Members::toggle方法代碼示例

本文整理匯總了PHP中Members::toggle方法的典型用法代碼示例。如果您正苦於以下問題:PHP Members::toggle方法的具體用法?PHP Members::toggle怎麽用?PHP Members::toggle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Members的用法示例。


在下文中一共展示了Members::toggle方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: elseif

    Logger::error(i18n::s('No item has been found.'));
    // permission denied
} elseif (!$permitted) {
    // anonymous users are invited to log in or to register
    if (!Surfer::is_logged()) {
        Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Categories::get_url($member, 'select')));
    }
    // permission denied to authenticated user
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // build a form to associates some categories to this item
} else {
    // actual update
    if (isset($_REQUEST['anchor']) && isset($_REQUEST['member'])) {
        // on error display the form again
        if ($error = Members::toggle($_REQUEST['anchor'], $_REQUEST['member'], isset($_REQUEST['father']) ? $_REQUEST['father'] : '')) {
            Logger::error($error);
        }
    }
    // the current list of linked categories
    $categories =& Members::list_categories_by_title_for_member($member, 0, CATEGORIES_LIST_SIZE, 'raw');
    // the form to link additional categories
    if (!is_array($categories) || count($categories) < CATEGORIES_LIST_SIZE) {
        $context['text'] .= '<form method="post" action="' . $context['script_url'] . '"><div style="margin-bottom: 2em;">' . i18n::s('Select a category') . ' <select name="anchor">' . Categories::get_options($categories) . '</select>' . ' ' . Skin::build_submit_button(i18n::s('Categorize')) . '<input type="hidden" name="member" value="' . encode_field($member) . '">' . '</div></form>' . "\n";
    }
    // the current list of linked categories
    if (count($categories)) {
        // display attached categories with unlink buttons
        $context['text'] .= '<p>' . i18n::s('All categories that have been associated to this page:') . '</p>';
        // browse the list
        foreach ($categories as $category_id => $attributes) {
開發者ID:rair,項目名稱:yacs,代碼行數:31,代碼來源:select.php

示例2: elseif

}
// the title of the page
$context['page_title'] = i18n::s('Watch list');
// not found
if (!$item['id']) {
    include '../error.php';
    // operation is restricted to logged users
} elseif (!Surfer::get_id()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // you cannot watch yourself
} elseif ($track == 'user:' . Surfer::get_id()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // toggle membership status
} elseif ($error = Members::toggle($track, 'user:' . Surfer::get_id())) {
    Logger::error($error);
    // post-processing tasks
} else {
    // successful operation reflected into page title
    if (!strncmp($track, 'user:', 5)) {
        $context['page_title'] = i18n::s('The list of persons that you follow has been updated');
    } else {
        $context['page_title'] = i18n::s('Your watch list has been updated');
    }
    // follow-up commands
    $menu = array();
    if (is_object($anchor) && $anchor->is_viewable()) {
        $menu[] = Skin::build_link($anchor->get_url(), i18n::s('Done'), 'button');
    }
    // the page now appears in the watch list
開發者ID:rair,項目名稱:yacs,代碼行數:31,代碼來源:track.php


注:本文中的Members::toggle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。