本文整理汇总了PHP中attrs函数的典型用法代码示例。如果您正苦于以下问题:PHP attrs函数的具体用法?PHP attrs怎么用?PHP attrs使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了attrs函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display_month
function display_month()
{
global $phpc_month, $phpc_year, $phpc_home_url, $phpcid;
$months = array();
for ($i = 1; $i <= 12; $i++) {
$m = month_name($i);
$months["{$phpc_home_url}?action=display_month&phpcid={$phpcid}&month={$i}&year={$phpc_year}"] = $m;
}
$years = array();
for ($i = $phpc_year - 5; $i <= $phpc_year + 5; $i++) {
$years["{$phpc_home_url}?action=display_month&phpcid={$phpcid}&month={$phpc_month}&year={$i}"] = $i;
}
$next_month = $phpc_month + 1;
$next_year = $phpc_year;
if ($next_month > 12) {
$next_month -= 12;
$next_year++;
}
$prev_month = $phpc_month - 1;
$prev_year = $phpc_year;
if ($prev_month < 1) {
$prev_month += 12;
$prev_year--;
}
$heading = tag('', tag('a', attrs('class="phpc-icon-link"', "href=\"{$phpc_home_url}?action=display_month&phpcid={$phpcid}&month={$prev_month}&year={$prev_year}\""), tag('span', attrs('class="fa fa-chevron-left"'), '')), create_dropdown_list(month_name($phpc_month), $months), create_dropdown_list($phpc_year, $years), tag('a', attrs('class="phpc-icon-link"', "href=\"{$phpc_home_url}?action=display_month&phpcid={$phpcid}&month={$next_month}&year={$next_year}\""), tag('span', attrs('class="fa fa-chevron-right"'), '')));
return create_display_table($heading, create_month($phpc_month, $phpc_year));
}
示例2: 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('div', attrs('class="phpc-sub-title"'), __('Create Calendar')), tag('table', attributes('class="phpc-container form"'), tag('tfoot', tag('tr', tag('td', ''), tag('td', create_hidden('phpc_token', $phpc_token), create_hidden('action', 'calendar_form'), create_hidden('submit_form', 'submit_form'), create_submit(__('Submit'))))), $tbody));
}
示例3: 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);
}
示例4: 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}\"")))))));
}
示例5: message_redirect
function message_redirect($message, $page)
{
global $phpc_prefix;
if (empty($_SESSION["{$phpc_prefix}messages"])) {
$_SESSION["{$phpc_prefix}messages"] = array();
}
if (is_a($message, 'Html')) {
$message = $message->toString();
}
$_SESSION["{$phpc_prefix}messages"][] = $message;
redirect($page);
$continue_url = $page . '&clearmsg=1';
return tag('div', attrs('class="phpc-box"'), "{$message} ", tag('a', attrs("href=\"{$continue_url}\""), __("continue")));
}
示例6: display_form
function display_form()
{
global $phpc_script, $phpc_token, $phpcdb, $vars, $phpc_cal;
$groups = array();
foreach ($phpc_cal->get_groups() as $group) {
$groups[$group['gid']] = $group['name'];
}
$size = sizeof($groups);
if ($size > 6) {
$size = 6;
}
$user = $phpcdb->get_user($vars["uid"]);
$user_groups = array();
foreach ($user->get_groups() as $group) {
$user_groups[] = $group['gid'];
}
return tag('form', attributes("action=\"{$phpc_script}\"", 'method="post"'), tag('div', attributes("class=\"phpc-container\""), tag('h2', __('Edit User Groups')), tag('div', create_select('groups[]', $groups, $user_groups, attrs('multiple', "size=\"{$size}\""))), tag('div', create_hidden('phpc_token', $phpc_token), create_hidden('uid', $vars['uid']), create_hidden('action', 'user_groups'), create_hidden('submit_form', 'submit_form'), create_submit(__('Submit')))));
}
示例7: create_day_menu
function create_day_menu()
{
global $phpc_month, $phpc_day, $phpc_year;
$html = tag('div', attrs('class="phpc-bar ui-widget-content"'));
$monthname = month_name($phpc_month);
$lasttime = mktime(0, 0, 0, $phpc_month, $phpc_day - 1, $phpc_year);
$lastday = date('j', $lasttime);
$lastmonth = date('n', $lasttime);
$lastyear = date('Y', $lasttime);
$lastmonthname = month_name($lastmonth);
$last_args = array('year' => $lastyear, 'month' => $lastmonth, 'day' => $lastday);
menu_item_prepend($html, "{$lastmonthname} {$lastday}", 'display_day', $last_args);
$nexttime = mktime(0, 0, 0, $phpc_month, $phpc_day + 1, $phpc_year);
$nextday = date('j', $nexttime);
$nextmonth = date('n', $nexttime);
$nextyear = date('Y', $nexttime);
$nextmonthname = month_name($nextmonth);
$next_args = array('year' => $nextyear, 'month' => $nextmonth, 'day' => $nextday);
menu_item_append($html, "{$nextmonthname} {$nextday}", 'display_day', $next_args);
return $html;
}
示例8: display_week
function display_week()
{
global $vars, $phpc_home_url, $phpcid, $phpc_year, $phpc_month, $phpc_day;
if (!isset($vars['week'])) {
$week_of_year = week_of_year($phpc_month, $phpc_day, $phpc_year);
} else {
if (!is_numeric($vars['week'])) {
soft_error(__('Invalid date.'));
}
$week_of_year = $vars['week'];
}
$day_of_year = 1 + ($week_of_year - 1) * 7 - day_of_week(1, 1, $phpc_year);
$from_stamp = mktime(0, 0, 0, 1, $day_of_year, $phpc_year);
$start_day = date("j", $from_stamp);
$start_month = date("n", $from_stamp);
$start_year = date("Y", $from_stamp);
$last_day = $day_of_year + 6;
$to_stamp = mktime(23, 59, 59, 1, $last_day, $phpc_year);
$end_day = date("j", $to_stamp);
$end_month = date("n", $to_stamp);
$end_year = date("Y", $to_stamp);
$title = month_name($start_month) . " {$start_year}";
if ($end_month != $start_month) {
$title .= " - " . month_name($end_month) . " {$end_year}";
}
$prev_week = $week_of_year - 1;
$prev_year = $phpc_year;
if ($prev_week < 1) {
$prev_year--;
$prev_week = week_of_year($start_month, $start_day - 7, $start_year);
}
$next_week = $week_of_year + 1;
$next_year = $phpc_year;
if ($next_week > weeks_in_year($phpc_year)) {
$next_week = week_of_year($end_month, $end_day + 1, $end_year);
$next_year++;
}
$heading = tag('', tag('a', attrs('class="phpc-icon-link"', "href=\"{$phpc_home_url}?action=display_week&phpcid={$phpcid}&week={$prev_week}&year={$prev_year}\""), tag('span', attrs('class="fa fa-chevron-left"'), '')), $title, tag('a', attrs('class="phpc-icon-link"', "href=\"{$phpc_home_url}?action=display_week&phpcid={$phpcid}&week={$next_week}&year={$next_year}\""), tag('span', attrs('class="fa fa-chevron-right"'), '')));
return create_display_table($heading, create_week($from_stamp, $phpc_year, get_events($from_stamp, $to_stamp)));
}
示例9: config_form
function config_form()
{
global $phpc_script, $phpc_user_tz, $phpc_user_lang, $phpc_token, $phpcdb, $phpc_user;
$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);
$calendars = array("" => __("None"));
foreach ($phpcdb->get_calendars() as $calendar) {
$calendars[$calendar->get_cid()] = $calendar->get_title();
}
$default_input = create_select('default_cid', $calendars, $phpc_user->get_default_cid());
$table = tag('table', attrs('class="phpc-form"'));
if (is_user()) {
$table->add(tag('tr', tag('th', __('Default Calendar')), tag('td', $default_input)));
}
$table->add(tag('tr', tag('th', __('Timezone')), tag('td', $tz_input)));
$table->add(tag('tr', tag('th', __('Language')), tag('td', $lang_input)));
$form = tag('form', attributes("action=\"{$phpc_script}\"", 'method="post"'), tag('div', attrs('class="phpc-sub-title"'), __('Settings')), $table, create_hidden('phpc_token', $phpc_token), create_hidden('action', 'user_settings_submit'), create_submit(__('Submit')));
return tag('div', attrs('id="phpc-config"'), $form);
}
示例10: field_list
function field_list()
{
global $phpc_script, $phpcid, $phpc_cal, $vars;
$tbody = tag('tbody');
$have_contents = false;
foreach ($phpc_cal->get_fields() as $field) {
$have_contents = true;
$name = empty($field['name']) ? __('No Name') : $field['name'];
$fid = $field['fid'];
$tbody->add(tag('tr', tag('td', $name), tag('td', escape_entities($field['required'])), tag('td', escape_entities($field['format'])), tag('td', create_action_link(__('Edit'), 'field_form', array('fid' => $fid)), " ", create_action_link(__('Delete'), 'field_delete', array('fid' => $fid), attrs('class="phpc-confirm-field"')))));
}
if (!$have_contents) {
$tbody->add(tag('tr', tag('td', attrs('colspan=4'), __('No fields.'))));
}
$table = tag('table', attrs('class="phpc-container"'), tag('thead', tag('tr', attrs('class="ui-widget-header"'), tag('th', __('Name')), tag('th', __('Required?')), tag('th', __('Format')), tag('th', __('Actions')))), $tbody);
$dialog = tag('div', attrs('id="phpc-dialog-field"', 'title="' . __("Confirmation required") . '"'), __("Permanently delete this field?"));
return tag('div', attrs('id="phpc-fields"'), tag('div', attrs('class="phpc-sub-title"'), __('Calendar Fields')), $dialog, $table, create_action_link(__('Create Field'), 'field_form', array('cid' => $phpcid), attrs('class="phpc-button"')));
}
示例11: display_form
function display_form()
{
global $phpc_script, $phpc_year, $phpc_month, $phpc_day, $vars, $phpcdb, $phpc_cal, $phpc_user, $phpc_token, $phpcid;
$hour24 = $phpc_cal->hours_24;
$date_format = $phpc_cal->date_format;
$form = new Form($phpc_script, __('Event Form'));
$cid_select = new FormDropdownQuestion('cid', __('Calendar'));
foreach ($phpcdb->get_calendars() as $calendar) {
if ($calendar->can_write()) {
$cid_select->add_option($calendar->cid, $calendar->title);
}
}
$form->add_part($cid_select);
$subject_part = new FormFreeQuestion('subject', __('Subject'), false, $phpc_cal->subject_max, true);
$subject_part->setAutocomplete("off");
$form->add_part($subject_part);
$form->add_part(new FormLongFreeQuestion('description', tag('', __('Description'), tag('br'), tag('a', attrs('href="http://daringfireball.net/projects/markdown/syntax"', 'target="_new"'), __('syntax')))));
$when_group = new FormGroup(__('When'), 'phpc-when');
if (isset($vars['eid'])) {
$when_group->add_part(new FormCheckBoxQuestion('phpc-modify', false, __('Change the event date and time')));
}
$when_group->add_part(new FormDateTimeQuestion('start', __('From'), $hour24, $date_format));
$when_group->add_part(new FormDateTimeQuestion('end', __('To'), $hour24, $date_format));
$time_type = new FormDropDownQuestion('time-type', __('Time Type'));
$time_type->add_option('normal', __('Normal'));
$time_type->add_option('full', __('Full Day'));
$time_type->add_option('tba', __('To Be Announced'));
$when_group->add_part($time_type);
$form->add_part($when_group);
$repeat_type = new FormDropdownQuestion('repeats', __('Repeats'), array(), true, 'never');
$repeat_type->add_option('never', __('Never'));
$daily_group = new FormGroup();
$repeat_type->add_option('daily', __('Daily'), NULL, $daily_group);
$weekly_group = new FormGroup();
$repeat_type->add_option('weekly', __('Weekly'), NULL, $weekly_group);
$monthly_group = new FormGroup();
$repeat_type->add_option('monthly', __('Monthly'), NULL, $monthly_group);
$yearly_group = new FormGroup();
$repeat_type->add_option('yearly', __('Yearly'), NULL, $yearly_group);
$every_day = new FormDropdownQuestion('every-day', __('Every'), __('Repeat every how many days?'));
$every_day->add_options(create_sequence(1, 30));
$daily_group->add_part($every_day);
$daily_group->add_part(new FormDateQuestion('daily-until', __('Until'), $date_format));
$every_week = new FormDropdownQuestion('every-week', __('Every'), __('Repeat every how many weeks?'));
$every_week->add_options(create_sequence(1, 30));
$weekly_group->add_part($every_week);
$weekly_group->add_part(new FormDateQuestion('weekly-until', __('Until'), $date_format));
$every_month = new FormDropdownQuestion('every-month', __('Every'), __('Repeat every how many months?'));
$every_month->add_options(create_sequence(1, 30));
$monthly_group->add_part($every_month);
$monthly_group->add_part(new FormDateQuestion('monthly-until', __('Until'), $date_format));
$every_year = new FormDropdownQuestion('every-year', __('Every'), __('Repeat every how many years?'));
$every_year->add_options(create_sequence(1, 30));
$yearly_group->add_part($every_year);
$yearly_group->add_part(new FormDateQuestion('yearly-until', __('Until'), $date_format));
$when_group->add_part($repeat_type);
if ($phpc_cal->can_create_readonly()) {
$form->add_part(new FormCheckBoxQuestion('readonly', false, __('Read-only')));
}
$categories = new FormDropdownQuestion('catid', __('Category'));
$categories->add_option('', __('None'));
$have_categories = false;
foreach ($phpc_cal->get_visible_categories($phpc_user->get_uid()) as $category) {
$categories->add_option($category['catid'], $category['name']);
$have_categories = true;
}
if ($have_categories) {
$form->add_part($categories);
}
if (isset($vars['phpcid'])) {
$form->add_hidden('phpcid', $vars['phpcid']);
}
foreach ($phpc_cal->get_fields() as $field) {
$form->add_part(new FormFreeQuestion('phpc-field-' . $field['fid'], $field['name']));
}
$form->add_hidden('phpc_token', $phpc_token);
$form->add_hidden('action', 'event_form');
$form->add_hidden('submit_form', 'submit_form');
$form->add_part(new FormSubmitButton(__("Submit Event")));
if (isset($vars['eid'])) {
$form->add_hidden('eid', $vars['eid']);
$occs = $phpcdb->get_occurrences_by_eid($vars['eid']);
$event = $occs[0];
$defaults = array('cid' => $event->get_cid(), 'subject' => $event->get_raw_subject(), 'description' => $event->get_raw_desc(), 'start-date' => $event->get_short_start_date(), 'end-date' => $event->get_short_end_date(), 'start-time' => $event->get_start_time(), 'end-time' => $event->get_end_time(), 'readonly' => $event->is_readonly());
foreach ($event->get_fields() as $field) {
$defaults["phpc-field-{$field['fid']}"] = $field['value'];
}
if (!empty($event->catid)) {
$defaults['catid'] = $event->catid;
}
switch ($event->get_time_type()) {
case 0:
$defaults['time-type'] = 'normal';
break;
case 1:
$defaults['time-type'] = 'full';
break;
case 2:
$defaults['time-type'] = 'tba';
break;
//.........这里部分代码省略.........
示例12: display_event
function display_event()
{
global $vars, $phpcdb, $phpc_year, $phpc_month, $phpc_day, $phpc_cal;
if (!empty($vars['content']) && $vars['content'] == 'json') {
return display_event_json();
}
if (isset($vars['oid'])) {
$entry = $phpcdb->get_event_by_oid($vars['oid']);
if (!$entry) {
return tag('p', __('There is no event for that OID.'));
}
$event = new PhpcEvent($entry);
} elseif (isset($vars['eid'])) {
$entry = $phpcdb->get_event_by_eid($vars['eid']);
if (!$entry) {
return tag('p', __('There is no event with that EID.'));
}
$event = new PhpcEvent($entry);
}
if (!isset($event)) {
soft_error(__("Invalid arguments."));
}
if (!$event->can_read()) {
return tag('p', __("You do not have permission to read this event."));
}
$event_header = tag('div', attributes('class="phpc-event-header"'), tag('div', __('created by') . ' ', tag('cite', $event->get_author()), ' ' . __('on') . ' ' . $event->get_ctime_string()));
if (!empty($event->mtime)) {
$event_header->add(tag('div', __('Last modified on '), $event->get_mtime_string()));
}
$category = $event->get_category();
if (!empty($category)) {
$event_header->add(tag('div', __('Category') . ': ' . $category));
}
// Add modify/delete links if this user has access to this event.
$event_menu = '';
if ($event->can_modify()) {
$event_menu = tag('div', attrs('class="phpc-bar ui-widget-content"'), create_event_link(__('Modify'), 'event_form', $event->get_eid()), "\n", create_event_link(__('Delete'), 'event_delete', $event->get_eid(), attrs('class="phpc-confirm"')));
}
$desc_tag = tag('div', attributes('class="phpc-desc"'), tag('h3', __("Description")), tag('p', $event->get_desc()));
$occurrences_tag = tag('ul');
$occurrences = $phpcdb->get_occurrences_by_eid($event->get_eid());
$set_date = false;
foreach ($occurrences as $occurrence) {
if (!$set_date) {
$phpc_year = $occurrence->get_start_year();
$phpc_month = $occurrence->get_start_month();
$phpc_day = $occurrence->get_start_day();
}
$oid = $occurrence->get_oid();
$occ_tag = tag('li', attrs('class="ui-widget-content"'), $occurrence->get_date_string() . ' ' . __('at') . ' ' . $occurrence->get_time_span_string());
if ($event->can_modify()) {
$occ_tag->add(" ", create_occurrence_link(__('Edit'), 'occur_form', $oid), " ", create_occurrence_link(__('Remove'), 'occurrence_delete', $oid, attrs('class="phpc-confirm-occ"')));
}
$occurrences_tag->add($occ_tag);
}
// Add occurrence link if this user has access to this event.
$occurrences_menu = '';
if ($event->can_modify()) {
$occurrences_menu = tag('div', attrs('class="phpc-bar ui-widget-content"'), create_event_link(__('Add Occurrence'), 'occur_form', $event->get_eid()));
}
foreach ($event->get_fields() as $field) {
$def = $phpc_cal->get_field($field['fid']);
$event_header->add(tag('div', $def['name'] . ": " . $field['value']));
}
$dialog = tag('div', attrs('id="phpc-dialog"', 'title="' . __("Confirmation required") . '"'), __("Permanently delete this event?"));
$dialog2 = tag('div', attrs('id="phpc-dialog-occ"', 'title="' . __("Confirmation required") . '"'), __("Permanently delete this occurrence?"));
return tag('div', attributes('class="phpc-main phpc-event"'), $dialog, $dialog2, $event_menu, tag('h2', $event->get_subject()), $event_header, $desc_tag, tag('div', attrs('class="phpc-occ"'), tag('h3', __('Occurrences')), $occurrences_menu, $occurrences_tag));
}
示例13: attrs
<?php
/**
* @var string|null $name
* @var string $__content
* @var array $__attrs
*/
?>
<div class="component Hello-World" <?php
echo attrs($__attrs);
?>
>
<h1>Hello<br/>
<small>my name is</small>
</h1>
<div class="content">
<?php
echo $__content;
?>
</div>
</div>
示例14: die
/*
* Copyright 2012 Sean Proctor
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
if (!defined('IN_PHPC')) {
die("Invalid setup");
}
try {
require_once "{$phpc_includes_path}/calendar.php";
require_once "{$phpc_includes_path}/setup.php";
$calendar_title = $phpc_cal->get_title();
$content = tag('div', attributes('class="php-calendar ui-widget"'), userMenu(), tag('br', attributes('style="clear:both;"')), tag('h1', attrs('class="ui-widget-header"'), tag('a', attributes("href='{$phpc_home_url}?phpcid={$phpc_cal->get_cid()}'"), $calendar_title)), display_phpc());
} catch (Exception $e) {
$calendar_title = $e->getMessage();
$content = tag('div', attributes('class="php-calendar"'), $e->getMessage());
}
$head = tag('div', attrs('class="phpc-head"'), get_header_tags("static"));
echo $head->toString();
echo $content->toString();
示例15: get_form
function get_form($defaults = array())
{
$form_attrs = attrs("action=\"{$this->action}\"", 'method="POST"');
if ($this->method !== false) {
$form_attrs->add("method=\"{$this->method}\"");
}
$table = tag('table', attrs("class=\"{$this->class}\""));
foreach ($this->list as $child) {
$table->add($child->get_html($this, $defaults));
}
$form = tag('form', $form_attrs);
$hidden_div = tag('div');
$have_hidden = false;
foreach ($this->hidden as $name => $value) {
$have_hidden = true;
$hidden_div->add(tag('input', attrs('type="hidden"', "name=\"{$name}\"", "value=\"{$value}\"", "id=\"{$name}\"")));
}
if ($have_hidden) {
$form->add($hidden_div);
}
$form->add($table);
return $form;
}