function css($atts) { global $css, $doctype; extract(lAtts(array('format' => 'url', 'media' => 'screen', 'n' => $css, 'name' => $css, 'rel' => 'stylesheet', 'title' => ''), $atts)); if (isset($atts['n'])) { $name = $n; trigger_error(gTxt('deprecated_attribute', array('{name}' => 'n')), E_USER_NOTICE); } if (empty($name)) { $name = 'default'; } if (has_handler('css.url')) { $url = callback_event('css.url', '', false, compact('name')); } else { $url = hu . 'css.php?n=' . urlencode($name); } if ($format == 'link') { return tag_void('link', array('rel' => $rel, 'type' => $doctype != 'html5' ? 'text/css' : '', 'media' => $media, 'title' => $title, 'href' => $url)); } return txpspecialchars($url); }
/** * The main Page editor panel. * * @param string|array $message The activity message */ function page_edit($message = '') { global $event, $step; pagetop(gTxt('edit_pages'), $message); extract(array_map('assert_string', gpsa(array('copy', 'save_error', 'savenew')))); $name = sanitizeForPage(assert_string(gps('name'))); $newname = sanitizeForPage(assert_string(gps('newname'))); if ($step == 'page_delete' || empty($name) && $step != 'page_new' && !$savenew) { $name = safe_field("page", 'txp_section', "name = 'default'"); } elseif ((($copy || $savenew) && $newname || $newname && $newname != $name) && !$save_error) { $name = $newname; } $titleblock = inputLabel('new_page', fInput('text', 'newname', $name, 'input-medium', '', '', INPUT_MEDIUM, '', 'new_page', false, true), 'page_name', array('', 'instructions_page_name'), array('class' => 'txp-form-field')); if ($name === '') { $titleblock .= hInput('savenew', 'savenew'); } else { $titleblock .= hInput('name', $name); } $titleblock .= eInput('page') . sInput('page_save'); $html = !$save_error ? fetch('user_html', 'txp_page', 'name', $name) : gps('html'); // Format of each entry is popTagLink -> array ( gTxt() string, class/ID). $tagbuild_items = array('page_article' => array('page_article_hed', 'article-tags'), 'page_article_nav' => array('page_article_nav_hed', 'article-nav-tags'), 'page_nav' => array('page_nav_hed', 'nav-tags'), 'page_xml' => array('page_xml_hed', 'xml-tags'), 'page_misc' => array('page_misc_hed', 'misc-tags'), 'page_file' => array('page_file_hed', 'file-tags')); $tagbuild_links = ''; foreach ($tagbuild_items as $tb => $item) { $tagbuild_links .= wrapRegion($item[1] . '_group', taglinks($tb), $item[1], $item[0], 'page_' . $item[1]); } // Pages code columm. echo n . tag(hed(gTxt('tab_pages'), 1, array('class' => 'txp-heading')) . form($titleblock . inputLabel('html', '<textarea class="code" id="html" name="html" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_LARGE . '" dir="ltr">' . txpspecialchars($html) . '</textarea>', 'page_code', array('', 'instructions_page_code'), array('class' => 'txp-form-field')), '', '', 'post', '', '', 'page_form'), 'div', array('class' => 'txp-layout-4col-cell-1-2-3', 'id' => 'main_content', 'role' => 'region')); // Pages create/switcher column. $buttonExtras = ''; if ($name) { $buttonExtras .= href('<span class="ui-icon ui-icon-copy"></span> ' . gTxt('duplicate'), '#', array('class' => 'txp-clone', 'data-form' => 'page_form')); } $buttons = graf(tag_void('input', array('class' => 'publish', 'type' => 'submit', 'method' => 'post', 'value' => gTxt('save'), 'form' => 'page_form')), ' class="txp-save"') . graf(sLink('page', 'page_new', '<span class="ui-icon ui-extra-icon-new-document"></span> ' . gTxt('create_new_page'), 'txp-new') . $buttonExtras, array('class' => 'txp-actions')); echo n . tag($buttons . page_list($name) . n, 'div', array('class' => 'txp-layout-4col-cell-4alt', 'id' => 'content_switcher', 'role' => 'region')); // Pages tag builder column. TODO: make this a modal? // echo n.tag( // hed(gTxt('tagbuilder'), 2). // $tagbuild_links // , 'div', array( // 'class' => '', // 'id' => 'tagbuild_links', // )); }
/** * The main stylesheet editor panel. * * @param string|array $message The activity message */ function css_edit($message = '') { global $event, $step; pagetop(gTxt('edit_css'), $message); $default_name = safe_field("css", 'txp_section', "name = 'default'"); extract(array_map('assert_string', gpsa(array('copy', 'save_error', 'savenew')))); $name = sanitizeForPage(assert_string(gps('name'))); $newname = sanitizeForPage(assert_string(gps('newname'))); if ($step == 'css_delete' || empty($name) && $step != 'pour' && !$savenew) { $name = $default_name; } elseif ((($copy || $savenew) && $newname || $newname && $newname != $name) && !$save_error) { $name = $newname; } $titleblock = inputLabel('new_style', fInput('text', 'newname', $name, 'input-medium', '', '', INPUT_MEDIUM, '', 'new_style', false, true), 'css_name', array('', 'instructions_style_name'), array('class' => 'txp-form-field')); if ($name === '') { $titleblock .= hInput('savenew', 'savenew'); } else { $titleblock .= hInput('name', $name); } $titleblock .= eInput('css') . sInput('css_save'); $thecss = gps('css'); if (!$save_error) { $thecss = fetch('css', 'txp_css', 'name', $name); } // Styles code columm. echo n . tag(hed(gTxt('tab_style'), 1, array('class' => 'txp-heading')) . form($titleblock . inputLabel('css', '<textarea class="code" id="css" name="css" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_LARGE . '" dir="ltr">' . txpspecialchars($thecss) . '</textarea>', 'css_code', array('', 'instructions_style_code'), array('class' => 'txp-form-field')), '', '', 'post', '', '', 'style_form'), 'div', array('class' => 'txp-layout-4col-cell-1-2-3', 'id' => 'main_content', 'role' => 'region')); // Styles create/switcher column. $buttonExtras = ''; if ($name) { $buttonExtras .= href('<span class="ui-icon ui-icon-copy"></span> ' . gTxt('duplicate'), '#', array('class' => 'txp-clone', 'data-form' => 'style_form')); } $buttons = graf(tag_void('input', array('class' => 'publish', 'type' => 'submit', 'method' => 'post', 'value' => gTxt('save'), 'form' => 'style_form')), ' class="txp-save"') . graf(sLink('css', 'pour', '<span class="ui-icon ui-extra-icon-new-document"></span> ' . gTxt('create_new_css'), 'txp-new') . $buttonExtras, array('class' => 'txp-actions')); echo n . tag($buttons . css_list($name, $default_name) . n, 'div', array('class' => 'txp-layout-4col-cell-4alt', 'id' => 'content_switcher', 'role' => 'region')); }
/** * Generates a field used to store and set a date. * * @param string $name The field * @param string $datevar The strftime format the date is displayed * @param int $time The displayed date as a UNIX timestamp * @param int $tab The HTML tabindex * @param string $id The HTML id * @return string HTML * @access private * @example * echo tsi('year', '%Y', 1200000000); */ function tsi($name, $datevar, $time, $tab = 0, $id = '') { static $placeholders = array('%Y' => 'yyyy', '%m' => 'mm', '%d' => 'dd', '%H' => 'hh', '%M' => 'mn', '%S' => 'ss'); $value = $placeholder = ''; $size = INPUT_TINY; $pattern = '([0-5][0-9])'; if ((int) $time) { $value = safe_strftime($datevar, (int) $time); } if (isset($placeholders[$datevar])) { $placeholder = gTxt($placeholders[$datevar]); } if ($datevar == '%Y' || $name == 'year' || $name == 'exp_year') { $class = 'input-year'; $size = INPUT_XSMALL; $pattern = '[0-9]{4}'; } if ($datevar == '%m' || $name == 'month' || $name == 'exp_month') { $class = 'input-month'; $pattern = '(0[1-9]|1[012])'; } if ($datevar == '%d' || $name == 'day' || $name == 'exp_day') { $class = 'input-day'; $pattern = '(0[1-9]|1[0-9]|2[0-9]|3[01])'; } if ($datevar == '%H' || $name == 'hour' || $name == 'exp_hour') { $class = 'input-hour'; $pattern = '(0[0-9]|1[0-9]|2[0-3])'; } if ($datevar == '%M' || $name == 'minute' || $name == 'exp_minute') { $class = 'input-minute'; } if ($datevar == '%S' || $name == 'second' || $name == 'exp_second') { $class = 'input-second'; } return n . tag_void('input', array('class' => $class, 'id' => $id, 'name' => $name, 'type' => 'text', 'inputmode' => 'numeric', 'pattern' => $pattern, 'size' => (int) $size, 'maxlength' => $size, 'title' => gTxt('article_' . $name), 'aria-label' => gTxt('article_' . $name), 'placeholder' => $placeholder, 'tabindex' => (int) $tab, 'value' => $value)); }
/** * Generates a field used to store and set a date. * * @param string $name The field * @param string $datevar The strftime format the date is displayed * @param int $time The displayed date as a UNIX timestamp * @param int $tab The HTML tabindex * @return string HTML * @access private * @example * echo tsi('year', '%Y', 1200000000); */ function tsi($name, $datevar, $time, $tab = 0) { static $placeholders = array('%Y' => 'yyyy', '%m' => 'mm', '%d' => 'dd', '%H' => 'hh', '%M' => 'mn', '%S' => 'ss'); $value = $placeholder = ''; $size = INPUT_TINY; if ((int) $time) { $value = safe_strftime($datevar, (int) $time); } if (isset($placeholders[$datevar])) { $placeholder = gTxt($placeholders[$datevar]); } if ($datevar == '%Y' || $name == 'year' || $name == 'exp_year') { $size = INPUT_XSMALL; } return n . tag_void('input', array('type' => 'text', 'name' => $name, 'value' => $value, 'size' => (int) $size, 'maxlength' => $size, 'class' => $name, 'tabindex' => (int) $tab, 'title' => gTxt('article_' . $name), 'placeholder' => $placeholder)); }
/** * Renders the main Form editor panel. * * @param string|array $message The activity message */ function form_edit($message = '') { global $event, $step, $essential_forms; pagetop(gTxt('edit_forms'), $message); extract(array_map('assert_string', gpsa(array('copy', 'save_error', 'savenew')))); $name = sanitizeForPage(assert_string(gps('name'))); $type = assert_string(gps('type')); $newname = sanitizeForPage(assert_string(gps('newname'))); if ($step == 'form_delete' || empty($name) && $step != 'form_create' && !$savenew) { $name = 'default'; } elseif ((($copy || $savenew) && $newname || $newname && $newname !== $name) && !$save_error) { $name = $newname; } $Form = gps('Form'); if (!$save_error) { $rs = safe_row("*", 'txp_form', "name = '" . doSlash($name) . "'"); extract($rs); } if (in_array($name, $essential_forms)) { $name_widgets = inputLabel('new_form', fInput('text', 'newname', $name, 'input-medium', '', '', INPUT_MEDIUM, '', 'new_form', true), 'form_name', array('', 'instructions_form_name'), array('class' => 'txp-form-field')); $type_widgets = inputLabel('type', formTypes($type, false, 'type', true), 'form_type', array('', 'instructions_form_type'), array('class' => 'txp-form-field')); } else { $name_widgets = inputLabel('new_form', fInput('text', 'newname', $name, 'input-medium', '', '', INPUT_MEDIUM, '', 'new_form', false, true), 'form_name', array('', 'instructions_form_name'), array('class' => 'txp-form-field')); $type_widgets = inputLabel('type', formTypes($type, false), 'form_type', array('', 'instructions_form_type'), array('class' => 'txp-form-field')); } if ($name === '') { $name_widgets .= hInput('savenew', 'savenew'); } else { $name_widgets .= hInput('name', $name); } $name_widgets .= eInput('form') . sInput('form_save'); $buttonExtras = ''; if ($name) { $buttonExtras .= href('<span class="ui-icon ui-icon-copy"></span> ' . gTxt('duplicate'), '#', array('class' => 'txp-clone', 'data-form' => 'form_form')); } $buttons = graf(tag_void('input', array('class' => 'publish', 'type' => 'submit', 'method' => 'post', 'value' => gTxt('save'), 'form' => 'form_form')), ' class="txp-save"') . graf(sLink('form', 'form_create', '<span class="ui-icon ui-extra-icon-new-document"></span> ' . gTxt('create_new_form'), 'txp-new') . $buttonExtras, array('class' => 'txp-actions')); // Generate the tagbuilder links. // Format of each entry is popTagLink -> array ( gTxt string, class/ID ). $tagbuild_items = array('article' => array('articles', 'article-tags'), 'link' => array('links', 'link-tags'), 'comment' => array('comments', 'comment-tags'), 'comment_details' => array('comment_details', 'comment-detail-tags'), 'comment_form' => array('comment_form', 'comment-form-tags'), 'search_result' => array('search_results_form', 'search-result-tags'), 'file_download' => array('file_download_tags', 'file-tags'), 'category' => array('category_tags', 'category-tags'), 'section' => array('section_tags', 'section-tags')); $tagbuild_links = ''; foreach ($tagbuild_items as $tb => $item) { $tagbuild_links .= wrapRegion($item[1] . '_group', popTagLinks($tb), $item[1], $item[0], $item[1]); } // Forms code columm. echo n . tag(hed(gTxt('tab_forms') . popHelp('forms_overview'), 1, array('class' => 'txp-heading')) . form($name_widgets . $type_widgets . inputLabel('form', '<textarea class="code" id="form" name="Form" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_LARGE . '" dir="ltr">' . txpspecialchars($Form) . '</textarea>', 'form_code', array('', 'instructions_form_code'), array('class' => 'txp-form-field')) . (empty($type) ? graf(gTxt('only_articles_can_be_previewed')) : ''), '', '', 'post', '', '', 'form_form'), 'div', array('class' => 'txp-layout-4col-cell-1-2-3', 'id' => 'main_content', 'role' => 'region')); // Forms create/switcher column. echo n . tag($buttons . form_list($name) . n, 'div', array('class' => 'txp-layout-4col-cell-4alt', 'id' => 'content_switcher', 'role' => 'region')); // Forms tag builder column. TODO: make this a modal? // echo n.tag( // hed(gTxt('tagbuilder'), 2). // $tagbuild_links.n // , 'div', array( // 'id' => 'tagbuild_links', // 'class' => '', // )); }
/** * Renders a page navigation form. * * @param string $event Event * @param int $page Current page number * @param int $numPages Total pages * @param string $sort Sort criterion * @param string $dir Sort direction, either "asc" or "desc" * @param string $crit Search criterion * @param string $search_method Search method * @param int $total Total search term hit count [0] * @param int $limit First visible search term hit number [0] * @param string $step Step * @param int $list Number of displayed page links discounting jump links, previous and next * @return string HTML */ function nav_form($event, $page, $numPages, $sort = '', $dir = '', $crit = '', $search_method = '', $total = 0, $limit = 0, $step = 'list', $list = 5) { $out = array(); if ($crit != '' && $total > 1) { $out[] = announce(gTxt('showing_search_results', array('{from}' => ($page - 1) * $limit + 1, '{to}' => min($total, $page * $limit), '{total}' => $total)), TEXTPATTERN_ANNOUNCE_REGULAR); } if ($numPages > 1) { $nav = array(); $list--; $page = max(min($page, $numPages), 1); $start = max(1, min($numPages - $list, $page - floor($list / 2))); $end = min($numPages, $start + $list); $parameters = array('event' => $event, 'step' => $step, 'dir' => $dir, 'crit' => $crit, 'search_method' => $search_method); // Previous page. if ($page > 1) { $nav[] = n . PrevNextLink($event, $page - 1, gTxt('prev'), 'prev', $sort, $dir, $crit, $search_method, $step); } else { $nav[] = n . span(span(gTxt('prev'), array('class' => 'ui-icon ui-icon-arrowthick-1-w')), array('class' => 'disabled', 'aria-disabled' => 'true', 'aria-label' => gTxt('prev'))); } $nav[] = form(n . tag(gTxt('page'), 'label', array('for' => 'current-page')) . n . tag_void('input', array('class' => 'current-page', 'id' => 'current-page', 'name' => 'page', 'type' => 'text', 'size' => INPUT_XSMALL, 'inputmode' => 'numeric', 'pattern' => '[0-9]+', 'value' => $page)) . n . gTxt('of') . n . span($numPages, array('class' => 'total-pages')) . eInput($event) . hInput('sort', $sort) . hInput('dir', $dir) . hInput('crit', $crit) . hInput('search_method', $search_method), '', '', 'get'); // Next page. if ($page < $numPages) { $nav[] = n . PrevNextLink($event, $page + 1, gTxt('next'), 'next', $sort, $dir, $crit, $search_method, $step); } else { $nav[] = n . span(span(gTxt('next'), array('class' => 'ui-icon ui-icon-arrowthick-1-e')), array('class' => 'disabled', 'aria-disabled' => 'true', 'aria-label' => gTxt('next'))); } $out[] = n . tag(join($nav) . n, 'nav', array('class' => 'prev-next')); } return join('', $out); }