当前位置: 首页>>代码示例>>PHP>>正文


PHP attributes函数代码示例

本文整理汇总了PHP中attributes函数的典型用法代码示例。如果您正苦于以下问题:PHP attributes函数的具体用法?PHP attributes怎么用?PHP attributes使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了attributes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: category_delete

function category_delete()
{
    global $vars, $phpcdb, $phpcid, $phpc_script;
    $html = tag('div', attributes('class="phpc-container"'));
    if (empty($vars["catid"])) {
        return message_redirect(__('No category selected.'), "{$phpc_script}?action=cadmin&phpcid={$phpcid}");
    }
    if (is_array($vars["catid"])) {
        $ids = $vars["catid"];
    } else {
        $ids = array($vars["catid"]);
    }
    $categories = array();
    foreach ($ids as $id) {
        $categories[] = $phpcdb->get_category($id);
    }
    foreach ($categories as $category) {
        if (empty($category['cid']) && !is_admin() || !$phpcdb->get_calendar($category['cid'])->can_admin()) {
            $html->add(tag('p', __("You do not have permission to delete category: ") . $category['catid']));
            continue;
        }
        if ($phpcdb->delete_category($category['catid'])) {
            $html->add(tag('p', __("Removed category: ") . $category['catid']));
        } else {
            $html->add(tag('p', __("Could not remove category: ") . $category['catid']));
        }
    }
    return message_redirect($html, "{$phpc_script}?action=cadmin&phpcid={$phpcid}");
}
开发者ID:hubandbob,项目名称:php-calendar,代码行数:29,代码来源:category_delete.php

示例2: user_enable

function user_enable()
{
    global $vars, $phpcid, $phpcdb, $phpc_script;
    $html = tag('div', attributes('class="phpc-container"'));
    if (!is_admin()) {
        $html->add(tag('p', __('You must be an admin to enable users.')));
        return $html;
    }
    if (empty($vars["uid"])) {
        $html->add(tag('p', __('No user selected.')));
        return $html;
    }
    if (is_array($vars["uid"])) {
        $ids = $vars["uid"];
    } else {
        $ids = array($vars["uid"]);
    }
    foreach ($ids as $id) {
        if ($phpcdb->enable_user($id)) {
            $html->add(tag('p', __("Enabled user: {$id}")));
        } else {
            $html->add(tag('p', __("Could not enable user: {$id}")));
        }
    }
    return message_redirect($html, "{$phpc_script}?action=admin&phpcid={$phpcid}");
}
开发者ID:hubandbob,项目名称:php-calendar,代码行数:26,代码来源:user_enable.php

示例3: occurrence_delete

function occurrence_delete()
{
    global $vars, $phpcdb, $phpcid, $phpc_script;
    $html = tag('div', attributes('class="phpc-container"'));
    if (empty($vars["oid"])) {
        $message = __('No occurrence selected.');
        $html->add(tag('p', $message));
        return $html;
    }
    if (is_array($vars["oid"])) {
        $oids = $vars["oid"];
    } else {
        $oids = array($vars["oid"]);
    }
    $removed_occurs = array();
    $unremoved_occurs = array();
    $permission_denied = array();
    foreach ($oids as $oid) {
        $occur = $phpcdb->get_occurrence_by_oid($oid);
        if (!$occur->can_modify()) {
            $permission_denied[] = $oid;
        } else {
            if ($phpcdb->delete_occurrence($oid)) {
                $removed_occurs[] = $oid;
                // TODO: Verify that the event still has occurences.
                $eid = $occur->get_eid();
            } else {
                $unremoved_occurs[] = $oid;
            }
        }
    }
    if (sizeof($removed_occurs) > 0) {
        if (sizeof($removed_occurs) == 1) {
            $text = __("Removed occurrence");
        } else {
            $text = __("Removed occurrences");
        }
        $text .= ': ' . implode(', ', $removed_occurs);
        $html->add(tag('p', $text));
    }
    if (sizeof($unremoved_occurs) > 0) {
        if (sizeof($unremoved_occurs) == 1) {
            $text = __("Could not remove occurrence");
        } else {
            $text = __("Could not remove occurrences");
        }
        $text .= ': ' . implode(', ', $unremoved_occurs);
        $html->add(tag('p', $text));
    }
    if (sizeof($permission_denied) > 0) {
        if (sizeof($permission_denied) == 1) {
            $text = __("You do not have permission to remove the occurrence.");
        } else {
            $text = __("You do not have permission to remove occurrences.");
        }
        $text .= ': ' . implode(', ', $permission_denied);
        $html->add(tag('p', $text));
    }
    return message_redirect($html, "{$phpc_script}?action=display_event&phpcid={$phpcid}&eid={$eid}");
}
开发者ID:hubandbob,项目名称:php-calendar,代码行数:60,代码来源:occurrence_delete.php

示例4: make

 /**
  * Return a resised image.
  *
  * @param string $url
  * @param string $format
  * @param string $alt
  * @param array  $attributes
  * @param bool   $secure
  *
  * @return string
  */
 public function make($url, $format = '', $alt = null, $attributes = [], $secure = false)
 {
     $format = $this->formats->get($format);
     $resized = $this->getResized($url, $format);
     $attributes = attributes(array_merge(['alt' => $alt, 'src' => asset(str_replace(public_path(), '', $resized), $secure)], $this->getSize($format, $resized), $attributes));
     return "<img{$attributes}>";
 }
开发者ID:hpkns,项目名称:picturesque,代码行数:18,代码来源:PictureBuilder.php

示例5: event_delete

function event_delete()
{
    global $config;
    if (!is_user() && $config['anon_permission'] < 2) {
        soft_error(_('You do not have permission to delete events.'));
    }
    $del_array = explode('&', $_SERVER['QUERY_STRING']);
    $html = tag('div', attributes('class="box"', 'style="width: 50%"'));
    $ids = 0;
    foreach ($del_array as $del_value) {
        list($drop, $id) = explode("=", $del_value);
        if (preg_match('/^id$/', $drop) == 0) {
            continue;
        }
        $ids++;
        $event = get_event_by_id($id);
        if (!check_user($event['uid']) && $config['anon_permission'] < 2) {
            $html->add(tag('p', _('You do not have permission to remove item') . ": {$id}"));
            continue;
        }
        if (remove_event($id)) {
            $html->add(tag('p', _('Removed item') . ": {$id}"));
        } else {
            $html->add(tag('p', _('Could not remove item') . ": {$id}"));
        }
    }
    if ($ids == 0) {
        $html->add(tag('p', _('No items selected.')));
    }
    return $html;
}
开发者ID:noprom,项目名称:cryptdb,代码行数:31,代码来源:event_delete.php

示例6: calendar_delete

function calendar_delete()
{
    global $vars, $phpcdb, $phpc_script;
    $html = tag('div', attributes('class="phpc-container"'));
    if (empty($vars["cid"])) {
        $html->add(tag('p', __('No calendar selected.')));
        return $html;
    }
    $id = $vars["cid"];
    $calendar = $phpcdb->get_calendar($id);
    if (empty($calendar)) {
        soft_error(__("Invalid calendar ID."));
    }
    if (empty($vars["confirm"])) {
        $html->add(tag('p', __('Confirm you want to delete calendar:') . $calendar->get_title()));
        $html->add(" [ ", create_action_link(__('Confirm'), "calendar_delete", array("cid" => $id, "confirm" => "1")), " ] ");
        $html->add(" [ ", create_action_link(__('Deny'), "display_month"), " ] ");
        return $html;
    }
    if (!$calendar->can_admin()) {
        $html->add(tag('p', __("You do not have permission to remove calendar") . ": {$id}"));
        return $html;
    }
    if ($phpcdb->delete_calendar($id)) {
        $html->add(tag('p', __("Removed calendar") . ": {$id}"));
    } else {
        $html->add(tag('p', __("Could not remove calendar") . ": {$id}"));
    }
    return message_redirect($html, "{$phpc_script}?action=admin");
}
开发者ID:php-calendar,项目名称:php-calendar,代码行数:30,代码来源:calendar_delete.php

示例7: category_submit

function category_submit()
{
    global $vars, $phpcdb, $phpc_script, $phpc_cal;
    if (empty($vars["text-color"]) || empty($vars["bg-color"])) {
        $page = "{$phpc_script}?action=category_form";
        if (!empty($vars["cid"])) {
            $page .= "&cid={$vars["cid"]}";
        }
        if (!empty($vars["catid"])) {
            $page .= "&catid={$vars["catid"]}";
        }
        return message_redirect(__("Color not specified."), $page);
    }
    // The current widget produces hex values without the "#".
    //   We may in the future want to allow different input, so store the
    //   values with the "#"
    $text_color = '#' . $vars["text-color"];
    $bg_color = '#' . $vars["bg-color"];
    if (empty($vars['gid']) || strlen($vars['gid']) == 0) {
        $gid = 0;
    } else {
        $gid = $vars['gid'];
    }
    if (!check_color($text_color) || !check_color($bg_color)) {
        soft_error(__("Invalid color."));
    }
    if (!isset($vars['catid'])) {
        $modify = false;
        if (!isset($vars['cid'])) {
            $cid = null;
            if (!is_admin()) {
                permission_error(__('You do not have permission to add categories to all calendars.'));
            }
        } else {
            $cid = $vars['cid'];
            $calendar = $phpcdb->get_calendar($cid);
            if (!$calendar->can_admin()) {
                permission_error(__('You do not have permission to add categories to this calendar.'));
            }
        }
        $catid = $phpcdb->create_category($cid, $vars["name"], $text_color, $bg_color, $gid);
    } else {
        $modify = true;
        $catid = $vars['catid'];
        $category = $phpcdb->get_category($catid);
        if (!(empty($category['cid']) && is_admin() || $phpcdb->get_calendar($category["cid"])->can_admin())) {
            soft_error(__("You do not have permission to modify this category."));
        }
        $phpcdb->modify_category($catid, $vars['name'], $text_color, $bg_color, $gid);
    }
    $page = "{$phpc_script}?action=cadmin&phpcid=" . $vars['phpcid'];
    if ($modify) {
        return message_redirect(__("Modified category: ") . $catid, $page);
    }
    if ($catid > 0) {
        return message_redirect(__("Created category: ") . $catid, $page);
    }
    return tag('div', attributes('class="phpc-error"'), __('Error submitting category.'));
}
开发者ID:php-calendar,项目名称:php-calendar,代码行数:59,代码来源:category_submit.php

示例8: login_form

function login_form()
{
    global $vars, $phpc_script;
    $submit_data = tag('td', attributes('colspan="2"'), create_hidden('action', 'login'), create_submit(__('Log in')));
    if (!empty($vars['lasturl'])) {
        $submit_data->prepend(create_hidden('lasturl', escape_entities(urlencode($vars['lasturl']))));
    }
    return tag('form', attributes("action=\"{$phpc_script}\"", 'method="post"'), tag('table', tag('caption', __('Log in')), tag('thead', tag('tr', tag('th', attributes('colspan="2"'), __('You must have cookies enabled to login.')))), tag('tfoot', tag('tr', $submit_data)), tag('tbody', tag('tr', tag('th', __('Username')), tag('td', create_text('username'))), tag('tr', tag('th', __('Password')), tag('td', create_password('password'))))));
}
开发者ID:hubandbob,项目名称:php-calendar,代码行数:9,代码来源:login.php

示例9: search_form

function search_form()
{
    global $day, $month, $year, $phpc_script, $month_names, $sort_options, $order_options;
    $day_sequence = create_sequence(1, 31);
    $month_sequence = create_sequence(1, 12);
    $year_sequence = create_sequence(1970, 2037);
    $html_table = tag('table', attributes('class="phpc-main"'), tag('caption', _('Search')), tag('tfoot', tag('tr', tag('td', attributes('colspan="2"'), create_submit(_('Submit'))))), tag('tr', tag('td', _('Phrase') . ': '), tag('td', tag('input', attributes('type="text"', 'name="searchstring"', 'size="32"')), create_hidden('action', 'search'))), tag('tr', tag('td', _('From') . ': '), tag('td', create_select('sday', $day_sequence, $day), create_select('smonth', $month_names, $month), create_select('syear', $year_sequence, $year))), tag('tr', tag('td', _('To') . ': '), tag('td', create_select('eday', $day_sequence, $day), create_select('emonth', $month_names, $month), create_select('eyear', $year_sequence, $year))), tag('tr', tag('td', _('Sort By') . ': '), tag('td', create_select('sort', $sort_options, false))), tag('tr', tag('td', _('Order') . ': '), tag('td', create_select('order', $order_options, false))));
    return tag('form', attributes("action=\"{$phpc_script}\"", 'method="post"'), $html_table);
}
开发者ID:noprom,项目名称:cryptdb,代码行数:9,代码来源:search.php

示例10: display_form

function display_form()
{
    global $phpc_script, $phpc_token;
    $tbody = tag('tbody');
    foreach (get_config_options() as $element) {
        $text = $element[1];
        $input = create_config_input($element);
        $tbody->add(tag('tr', tag('th', $text), tag('td', $input)));
    }
    return tag('form', attributes("action=\"{$phpc_script}\"", 'method="post"'), tag('table', attributes("class=\"phpc-container\""), tag('caption', __('Create Calendar')), tag('tfoot', tag('tr', tag('td', attributes('colspan="2"'), create_hidden('phpc_token', $phpc_token), create_hidden('action', 'calendar_form'), create_hidden('submit_form', 'submit_form'), create_submit(__('Submit'))))), $tbody));
}
开发者ID:php-calendar,项目名称:php-calendar,代码行数:11,代码来源:calendar_form.php

示例11: config_form

function config_form()
{
    global $phpc_script, $phpc_user_tz, $phpc_user_lang, $phpc_token;
    $tz_input = create_multi_select('timezone', get_timezone_list(), $phpc_user_tz);
    $languages = array("" => __("Default"));
    foreach (get_languages() as $lang) {
        $languages[$lang] = $lang;
    }
    $lang_input = create_select('language', $languages, $phpc_user_lang);
    $form = tag('form', attributes("action=\"{$phpc_script}\"", 'method="post"'), tag('table', attributes("class=\"phpc-container\""), tag('caption', __('Settings')), tag('tfoot', tag('tr', tag('td', attributes('colspan="2"'), create_hidden('phpc_token', $phpc_token), create_hidden('action', 'settings'), create_hidden('phpc_submit', 'settings'), create_submit(__('Submit'))))), tag('tbody', tag('tr', tag('th', __('Timezone')), tag('td', $tz_input)), tag('tr', tag('th', __('Language')), tag('td', $lang_input)))));
    return tag('div', attrs('id="phpc-config"'), $form);
}
开发者ID:Godjqb,项目名称:Php-test,代码行数:12,代码来源:settings.php

示例12: field_submit

function field_submit()
{
    global $vars, $phpcdb, $phpc_script, $phpc_cal;
    $form_page = "{$phpc_script}?action=field_form";
    if (!empty($vars["cid"])) {
        $form_page .= "&cid={$vars["cid"]}";
    }
    if (!empty($vars["fid"])) {
        $form_page .= "&fid={$vars["fid"]}";
    }
    if (empty($vars["name"])) {
        return input_error(__("Name not specified."), $form_page);
    }
    $required = !empty($vars['name']) && $vars['required'] == '1';
    if (empty($vars['format'])) {
        $format = false;
    } else {
        $format = $vars['format'];
    }
    if (!isset($vars['fid'])) {
        $modify = false;
        if (!isset($vars['cid'])) {
            $cid = null;
            if (!is_admin()) {
                permission_error(__('You do not have permission to add fields to all calendars.'));
            }
        } else {
            $cid = $vars['cid'];
            $calendar = $phpcdb->get_calendar($cid);
            if (!$calendar->can_admin()) {
                permission_error(__('You do not have permission to add fields to this calendar.'));
            }
        }
        $fid = $phpcdb->create_field($cid, $vars["name"], $required, $format);
    } else {
        $modify = true;
        $fid = $vars['fid'];
        $field = $phpcdb->get_field($fid);
        if (!(empty($field['cid']) && is_admin() || $phpcdb->get_calendar($field["cid"])->can_admin())) {
            permission_error(__("You do not have permission to modify this field."));
        }
        $phpcdb->modify_field($fid, $vars['name'], $required, $format);
    }
    $page = "{$phpc_script}?action=cadmin&phpcid={$vars['phpcid']}#phpc-fields";
    if ($modify) {
        return message_redirect(__("Modified field: ") . $fid, $page);
    }
    if ($fid > 0) {
        return message_redirect(__("Created field: ") . $fid, $page);
    }
    return tag('div', attributes('class="phpc-error"'), __('Error submitting field.'));
}
开发者ID:hubandbob,项目名称:php-calendar,代码行数:52,代码来源:field_submit.php

示例13: display_form

function display_form()
{
    global $phpc_script, $phpc_token, $phpcdb;
    $groups = array();
    foreach ($phpcdb->get_groups() as $group) {
        $groups[$group['gid']] = $group['name'];
    }
    $size = sizeof($groups);
    if ($size > 6) {
        $size = 6;
    }
    return tag('form', attributes("action=\"{$phpc_script}\"", 'method="post"'), tag('table', attributes("class=\"phpc-container\""), tag('caption', __('Create User')), tag('tfoot', tag('tr', tag('td', attributes('colspan="2"'), create_hidden('phpc_token', $phpc_token), create_hidden('action', 'user_create'), create_hidden('submit_form', 'submit_form'), create_submit(__('Submit'))))), tag('tbody', tag('tr', tag('th', __('User Name')), tag('td', create_text('user_name'))), tag('tr', tag('th', __('Password')), tag('td', create_password('password1'))), tag('tr', tag('th', __('Confirm Password')), tag('td', create_password('password2'))), tag('tr', tag('th', __('Make Admin')), tag('td', create_checkbox('make_admin', '1', false, __('Admin')))), tag('tr', tag('th', __('Groups')), tag('td', create_select('groups[]', $groups, false, attrs('multiple', "size=\"{$size}\"")))))));
}
开发者ID:php-calendar,项目名称:php-calendar,代码行数:13,代码来源:user_create.php

示例14: default_calendar

function default_calendar()
{
    global $vars, $phpcdb, $phpc_script, $phpc_user;
    $html = tag('div', attributes('class="phpc-container"'));
    if (empty($vars["cid"])) {
        $html->add(tag('p', __('No calendar selected.')));
        return $html;
    }
    if ($phpc_user->is_admin()) {
        $phpcdb->set_config('default_cid', $vars['cid']);
        $html->add(tag('p', __('Default calendar set to: ') . $vars['cid']));
    }
    return message_redirect($html, "{$phpc_script}?action=admin");
}
开发者ID:hubandbob,项目名称:php-calendar,代码行数:14,代码来源:default_calendar.php

示例15: search_results

function search_results()
{
    global $vars, $phpcdb, $phpcid, $sort_options, $order_options;
    $searchstring = $vars['searchstring'];
    if (!empty($vars['search-from-date']) && strlen($vars['search-from-date']) > 0) {
        $start = get_timestamp('search-from');
    } else {
        $start = false;
    }
    if (!empty($vars['search-to-date']) && strlen($vars['search-to-date']) > 0) {
        $end = get_timestamp('search-to');
    } else {
        $end = false;
    }
    // make sure sort is valid
    $sort = htmlentities($vars['sort']);
    if (array_search($sort, array_keys($sort_options)) === false) {
        soft_error(__('Invalid sort option') . ": {$sort}");
    }
    // make sure order is valid
    $order = htmlentities($vars['order']);
    if (array_search($order, array_keys($order_options)) === false) {
        soft_error(__('Invalid order option') . ": {$order}");
    }
    $keywords = explode(" ", $searchstring);
    $results = $phpcdb->search($phpcid, $keywords, $start, $end, $sort, $order);
    $tags = array();
    foreach ($results as $event) {
        if (!$event->can_read()) {
            continue;
        }
        $name = $event->get_author();
        $subject = $event->get_subject();
        $desc = $event->get_desc();
        $date = $event->get_date_string();
        $time = $event->get_time_string();
        $eid = $event->get_eid();
        $tags[] = tag('tr', tag('td', tag('strong', create_event_link($subject, 'display_event', $eid))), tag('td', "{$date} {$time}"), tag('td', $desc));
    }
    if (sizeof($tags) == 0) {
        $html = tag('div', tag('strong', __('No events matched your search criteria.')));
    } else {
        $html = tag('table', attributes('class="phpc-main"'), tag('caption', __('Search Results')), tag('thead', tag('tr', tag('th', __('Subject')), tag('th', __('Date Time')), tag('th', __('Description')))));
        foreach ($tags as $tag) {
            $html->add($tag);
        }
    }
    return $html;
}
开发者ID:Godjqb,项目名称:Php-test,代码行数:49,代码来源:search.php


注:本文中的attributes函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。