function tc_shopping_cart_detail($atts) { session_start(); extract(lAtts(array('checkout_section' => 'checkout'), $atts)); $cart = $_SESSION['cart']; if (empty($cart)) { $cart = new bckCart(); } if (isset($_REQUEST['empty_cart'])) { $cart->empty_cart(); $_SESSION['cart'] = $cart; } $cartHTML = startTable("shopping_cart") . tr(n . hCell("Item") . n . hCell("Quantity") . n . hCell("Price") . n . hCell("Subtotal")); foreach ($cart->items as $product) { $image = '<img src="' . product_image_display($product['image'], "small") . '" alt="Product Detail" class="thumb"/>'; $link = "<a href='" . permlinkurl_id($product['ID']) . "' title='View product detail'>" . $product['name'] . "</a>"; $cartHTML .= tr(n . td($image . $link) . n . td($product['qty']) . n . td(_tc_price_format($product['price'])) . n . td(_tc_price_format($product['price']))); } $cartHTML .= endTable(); $cartHTML .= tag(tag(tag("Empty Cart", "a", " href='?empty_cart=true' class='cartAction' id='emptyCart'"), "li") . tag(tag("Continue Shopping", "a", " href='#' class='cartAction' id='continueShopping'"), "li") . tag(tag("Checkout", "a", " href='/{$checkout_section}/' class='cartAction' id='checkout'"), "li") . tag(tag(_tc_price_format($cart->total), "span", " class='cartTotal'"), "li"), "ul"); return $cartHTML; }
function article_edit($message = '', $concurrent = FALSE) { global $vars, $txp_user, $comments_disabled_after, $txpcfg, $prefs; extract($prefs); extract(gpsa(array('view', 'from_view', 'step'))); if (!empty($GLOBALS['ID'])) { // newly-saved article $ID = $GLOBALS['ID']; $step = 'edit'; } else { $ID = gps('ID'); } include_once txpath . '/lib/classTextile.php'; $textile = new Textile(); // switch to 'text' view upon page load and after article post if (!$view || gps('save') || gps('publish')) { $view = 'text'; } if (!$step) { $step = "create"; } if ($step == "edit" && $view == "text" && !empty($ID) && $from_view != 'preview' && $from_view != 'html' && !$concurrent) { $pull = true; //-- it's an existing article - off we go to the db $ID = assert_int($ID); $rs = safe_row("*, unix_timestamp(Posted) as sPosted,\n\t\t\t\tunix_timestamp(Expires) as sExpires,\n\t\t\t\tunix_timestamp(LastMod) as sLastMod", "textpattern", "ID={$ID}"); extract($rs); $reset_time = $publish_now = $Status < 4; } else { $pull = false; //-- assume they came from post if ($from_view == 'preview' or $from_view == 'html') { $store_out = array(); $store = unserialize(base64_decode(ps('store'))); foreach ($vars as $var) { if (isset($store[$var])) { $store_out[$var] = $store[$var]; } } } else { $store_out = gpsa($vars); if ($concurrent) { $store_out['sLastMod'] = safe_field('unix_timestamp(LastMod) as sLastMod', 'textpattern', 'ID=' . $ID); } } extract($store_out); } $GLOBALS['step'] = $step; if ($step == 'create') { $textile_body = $use_textile; $textile_excerpt = $use_textile; } if ($step != 'create') { // Previous record? $prev_id = checkIfNeighbour('prev', $sPosted); // Next record? $next_id = checkIfNeighbour('next', $sPosted); } $page_title = $Title ? $Title : gTxt('write'); pagetop($page_title, $message); echo n . n . '<form name="article" method="post" action="index.php">'; if (!empty($store_out)) { echo hInput('store', base64_encode(serialize($store_out))); } echo hInput('ID', $ID) . eInput('article') . sInput($step) . '<input type="hidden" name="view" />' . startTable('edit') . '<tr>' . n . '<td id="article-col-1">'; if ($view == 'text') { //-- markup help -------------- echo side_help($textile_body, $textile_excerpt) . '<h3 class="plain"><a href="#advanced" onclick="toggleDisplay(\'advanced\'); return false;">' . gTxt('advanced_options') . '</a></h3>', '<div id="advanced" class="toggle" style="display:none">', n . graf('<label for="markup-body">' . gTxt('article_markup') . '</label>' . br . pref_text('textile_body', $textile_body, 'markup-body')), n . graf('<label for="markup-excerpt">' . gTxt('excerpt_markup') . '</label>' . br . pref_text('textile_excerpt', $textile_excerpt, 'markup-excerpt')), $allow_form_override ? graf('<label for="override-form">' . gTxt('override_default_form') . '</label>' . sp . popHelp('override_form') . br . form_pop($override_form, 'override-form')) : '', $custom_1_set ? custField(1, $custom_1_set, $custom_1) : '', $custom_2_set ? custField(2, $custom_2_set, $custom_2) : '', $custom_3_set ? custField(3, $custom_3_set, $custom_3) : '', $custom_4_set ? custField(4, $custom_4_set, $custom_4) : '', $custom_5_set ? custField(5, $custom_5_set, $custom_5) : '', $custom_6_set ? custField(6, $custom_6_set, $custom_6) : '', $custom_7_set ? custField(7, $custom_7_set, $custom_7) : '', $custom_8_set ? custField(8, $custom_8_set, $custom_8) : '', $custom_9_set ? custField(9, $custom_9_set, $custom_9) : '', $custom_10_set ? custField(10, $custom_10_set, $custom_10) : '', n . graf('<label for="keywords">' . gTxt('keywords') . '</label>' . sp . popHelp('keywords') . br . n . '<textarea id="keywords" name="Keywords" cols="18" rows="5">' . htmlspecialchars(str_replace(',', ', ', $Keywords)) . '</textarea>'), n . graf('<label for="article-image">' . gTxt('article_image') . '</label>' . sp . popHelp('article_image') . br . fInput('text', 'Image', $Image, 'edit', '', '', 22, '', 'article-image')), n . graf('<label for="url-title">' . gTxt('url_title') . '</label>' . sp . popHelp('url_title') . br . fInput('text', 'url_title', $url_title, 'edit', '', '', 22, '', 'url-title')), '</div> <h3 class="plain"><a href="#recent" onclick="toggleDisplay(\'recent\'); return false;">' . gTxt('recent_articles') . '</a>' . '</h3>' . '<div id="recent" class="toggle" style="display:none">'; $recents = safe_rows_start("Title, ID", 'textpattern', "1=1 order by LastMod desc limit 10"); if ($recents) { echo '<ul class="plain-list">'; while ($recent = nextRow($recents)) { if (!$recent['Title']) { $recent['Title'] = gTxt('untitled') . sp . $recent['ID']; } echo n . t . '<li><a href="?event=article' . a . 'step=edit' . a . 'ID=' . $recent['ID'] . '">' . escape_title($recent['Title']) . '</a></li>'; } echo '</ul>'; } echo '</div>'; } else { echo sp; } echo '</td>' . n . '<td id="article-main">'; //-- title input -------------- if ($view == 'preview') { echo hed(gTxt('preview'), 2) . hed($Title, 1); } elseif ($view == 'html') { echo hed('XHTML', 2) . hed($Title, 1); } elseif ($view == 'text') { echo n . '<p><label for="title">' . gTxt('title') . '</label>' . sp . popHelp('title') . br . '<input type="text" id="title" name="Title" value="' . escape_title($Title) . '" class="edit" size="40" tabindex="1" />'; if ($step != 'create') { include_once txpath . '/publish/taghandlers.php'; $url = permlinkurl_id($ID); if ($Status != 4 and $Status != 5) { $url .= (strpos($url, '?') === FALSE ? '?' : '&') . 'txpreview=' . intval($ID) . '.' . time(); } echo sp . sp . '<a href="' . $url . '" class="article-view">' . gTxt('view') . '</a>'; } echo '</p>'; } //-- body -------------------- if ($view == 'preview') { if ($textile_body == USE_TEXTILE) { echo $textile->TextileThis($Body); } else { if ($textile_body == CONVERT_LINEBREAKS) { echo nl2br($Body); } else { if ($textile_body == LEAVE_TEXT_UNTOUCHED) { echo $Body; } } } } elseif ($view == 'html') { if ($textile_body == USE_TEXTILE) { $bod = $textile->TextileThis($Body); } else { if ($textile_body == CONVERT_LINEBREAKS) { $bod = nl2br($Body); } else { if ($textile_body == LEAVE_TEXT_UNTOUCHED) { $bod = $Body; } } } echo tag(str_replace(array(n, t), array(br, sp . sp . sp . sp), htmlspecialchars($bod)), 'code'); } else { echo n . graf('<label for="body">' . gTxt('body') . '</label>' . sp . popHelp('body') . br . '<textarea id="body" name="Body" cols="55" rows="31" tabindex="2">' . htmlspecialchars($Body) . '</textarea>'); } //-- excerpt -------------------- if ($articles_use_excerpts) { if ($view == 'text') { echo n . graf('<label for="excerpt">' . gTxt('excerpt') . '</label>' . sp . popHelp('excerpt') . br . '<textarea id="excerpt" name="Excerpt" cols="55" rows="5" tabindex="3">' . htmlspecialchars($Excerpt) . '</textarea>'); } else { echo n . '<hr width="50%" />'; echo $textile_excerpt == USE_TEXTILE ? $view == 'preview' ? graf($textile->textileThis($Excerpt)) : tag(str_replace(array(n, t), array(br, sp . sp . sp . sp), htmlspecialchars($textile->TextileThis($Excerpt))), 'code') : graf($Excerpt); } } //-- author -------------- if ($view == "text" && $step != "create") { echo '<p class="small">' . gTxt('posted_by') . ': ' . htmlspecialchars($AuthorID) . ' · ' . safe_strftime('%d %b %Y · %X', $sPosted); if ($sPosted != $sLastMod) { echo br . gTxt('modified_by') . ': ' . htmlspecialchars($LastModID) . ' · ' . safe_strftime('%d %b %Y · %X', $sLastMod); } echo '</p>'; } echo hInput('from_view', $view), '</td>'; echo '<td id="article-tabs">'; //-- layer tabs ------------------- echo $use_textile == USE_TEXTILE || $textile_body == USE_TEXTILE ? '<ul>' . (tab('text', $view) . tab('html', $view) . tab('preview', $view)) . '</ul>' : ' '; echo '</td>'; echo '<td id="article-col-2">'; if ($view == 'text') { if ($step != 'create') { echo n . graf(href(gtxt('create_new'), 'index.php?event=article')); } //-- prev/next article links -- if ($step != 'create' and ($prev_id or $next_id)) { echo '<p>', $prev_id ? prevnext_link('‹' . gTxt('prev'), 'article', 'edit', $prev_id, gTxt('prev')) : '', $next_id ? prevnext_link(gTxt('next') . '›', 'article', 'edit', $next_id, gTxt('next')) : '', '</p>'; } //-- status radios -------------- echo n . n . '<fieldset id="write-status">' . n . '<legend>' . gTxt('status') . '</legend>' . n . status_radio($Status) . n . '</fieldset>'; //-- category selects ----------- echo n . n . '<fieldset id="write-sort">' . n . '<legend>' . gTxt('sort_display') . '</legend>' . n . graf('<label for="category-1">' . gTxt('category1') . '</label> ' . '<span class="small">[' . eLink('category', '', '', '', gTxt('edit')) . ']</span>' . br . n . category_popup('Category1', $Category1, 'category-1')) . n . graf('<label for="category-2">' . gTxt('category2') . '</label>' . br . n . category_popup('Category2', $Category2, 'category-2')); //-- section select -------------- if (!$from_view && !$pull) { $Section = getDefaultSection(); } echo n . graf('<label for="section">' . gTxt('section') . '</label> ' . '<span class="small">[' . eLink('section', '', '', '', gTxt('edit')) . ']</span>' . br . section_popup($Section, 'section')) . n . '</fieldset>' . n . n . '<h3 class="plain"><a href="#more" onclick="toggleDisplay(\'more\'); return false;">' . gTxt('more') . '</a></h3>', '<div id="more" class="toggle" style="display:none">'; //-- comments stuff -------------- if ($step == "create") { //Avoiding invite disappear when previewing $AnnotateInvite = !empty($store_out['AnnotateInvite']) ? $store_out['AnnotateInvite'] : $comments_default_invite; if ($comments_on_default == 1) { $Annotate = 1; } } if ($use_comments == 1) { echo n . n . '<fieldset id="write-comments">' . n . '<legend>' . gTxt('comments') . '</legend>'; $comments_expired = false; if ($step != 'create' && $comments_disabled_after) { $lifespan = $comments_disabled_after * 86400; $time_since = time() - $sPosted; if ($time_since > $lifespan) { $comments_expired = true; } } if ($comments_expired) { echo n . n . graf(gTxt('expired')); } else { echo n . n . graf(onoffRadio('Annotate', $Annotate)) . n . n . graf('<label for="comment-invite">' . gTxt('comment_invitation') . '</label>' . br . fInput('text', 'AnnotateInvite', $AnnotateInvite, 'edit', '', '', '', '', 'comment-invite')); } echo n . n . '</fieldset>'; } if ($step == "create" and empty($GLOBALS['ID'])) { //-- timestamp ------------------- //Avoiding modified date to disappear $persist_timestamp = !empty($store_out['year']) ? safe_strtotime($store_out['year'] . '-' . $store_out['month'] . '-' . $store_out['day'] . ' ' . $store_out['hour'] . ':' . $store_out['minute'] . ':' . $store_out['second']) : time(); echo n . n . '<fieldset id="write-timestamp">' . n . '<legend>' . gTxt('timestamp') . '</legend>' . n . graf(checkbox('publish_now', '1', $publish_now, '', 'publish_now') . '<label for="publish_now">' . gTxt('set_to_now') . '</label>') . n . graf(gTxt('or_publish_at') . sp . popHelp('timestamp')) . n . graf(gtxt('date') . sp . tsi('year', '%Y', $persist_timestamp) . ' / ' . tsi('month', '%m', $persist_timestamp) . ' / ' . tsi('day', '%d', $persist_timestamp)) . n . graf(gTxt('time') . sp . tsi('hour', '%H', $persist_timestamp) . ' : ' . tsi('minute', '%M', $persist_timestamp) . ' : ' . tsi('second', '%S', $persist_timestamp)) . n . '</fieldset>'; //-- expires ------------------- $persist_timestamp = !empty($store_out['exp_year']) ? safe_strtotime($store_out['exp_year'] . '-' . $store_out['exp_month'] . '-' . $store_out['exp_day'] . ' ' . $store_out['exp_hour'] . ':' . $store_out['exp_minute'] . ':' . $store_out['second']) : NULLDATETIME; echo n . n . '<fieldset id="write-expires">' . n . '<legend>' . gTxt('expires') . '</legend>' . n . graf(gtxt('date') . sp . tsi('exp_year', '%Y', $persist_timestamp) . ' / ' . tsi('exp_month', '%m', $persist_timestamp) . ' / ' . tsi('exp_day', '%d', $persist_timestamp)) . n . graf(gTxt('time') . sp . tsi('exp_hour', '%H', $persist_timestamp) . ' : ' . tsi('exp_minute', '%M', $persist_timestamp) . ' : ' . tsi('exp_second', '%S', $persist_timestamp)) . n . '</fieldset>' . n . n . '</div>'; //-- publish button -------------- echo has_privs('article.publish') ? fInput('submit', 'publish', gTxt('publish'), "publish", '', '', '', 4) : fInput('submit', 'publish', gTxt('save'), "publish", '', '', '', 4); } else { //-- timestamp ------------------- if (!empty($year)) { $sPosted = safe_strtotime($year . '-' . $month . '-' . $day . ' ' . $hour . ':' . $minute . ':' . $second); } echo n . n . '<fieldset id="write-timestamp">' . n . '<legend>' . gTxt('timestamp') . '</legend>' . n . graf(checkbox('reset_time', '1', $reset_time, '', 'reset_time') . '<label for="reset_time">' . gTxt('reset_time') . '</label>') . n . graf(gTxt('published_at') . sp . popHelp('timestamp')) . n . graf(gtxt('date') . sp . tsi('year', '%Y', $sPosted) . ' / ' . tsi('month', '%m', $sPosted) . ' / ' . tsi('day', '%d', $sPosted)) . n . graf(gTxt('time') . sp . tsi('hour', '%H', $sPosted) . ' : ' . tsi('minute', '%M', $sPosted) . ' : ' . tsi('second', '%S', $sPosted)) . n . hInput('sPosted', $sPosted), n . hInput('sLastMod', $sLastMod), n . hInput('AuthorID', $AuthorID), n . hInput('LastModID', $LastModID), n . '</fieldset>'; //-- expires ------------------- if (!empty($exp_year)) { if (empty($exp_month)) { $exp_month = 1; } if (empty($exp_day)) { $exp_day = 1; } if (empty($exp_hour)) { $exp_hour = 0; } if (empty($exp_minute)) { $exp_minute = 0; } if (empty($exp_second)) { $exp_second = 0; } $sExpires = safe_strtotime($exp_year . '-' . $exp_month . '-' . $exp_day . ' ' . $exp_hour . ':' . $exp_minute . ':' . $exp_second); } echo n . n . '<fieldset id="write-expires">' . n . '<legend>' . gTxt('expires') . '</legend>' . n . graf(gtxt('date') . sp . tsi('exp_year', '%Y', $sExpires) . ' / ' . tsi('exp_month', '%m', $sExpires) . ' / ' . tsi('exp_day', '%d', $sExpires)) . n . graf(gTxt('time') . sp . tsi('exp_hour', '%H', $sExpires) . ' : ' . tsi('exp_minute', '%M', $sExpires) . ' : ' . tsi('exp_second', '%S', $sExpires)) . n . hInput('sExpires', $sExpires) . n . '</fieldset>' . n . n . '</div>'; //-- save button -------------- if ($Status >= 4 and has_privs('article.edit.published') or $Status >= 4 and $AuthorID == $txp_user and has_privs('article.edit.own.published') or $Status < 4 and has_privs('article.edit') or $Status < 4 and $AuthorID == $txp_user and has_privs('article.edit.own')) { echo fInput('submit', 'save', gTxt('save'), "publish", '', '', '', 4); } } } echo '</td></tr></table></form>'; }
function mail_comment($message, $cname, $cemail, $cweb, $parentid, $discussid) { global $sitename; $parentid = assert_int($parentid); $discussid = assert_int($discussid); $article = safe_row("Section, Posted, ID, url_title, AuthorID, Title", "textpattern", "ID = {$parentid}"); extract($article); extract(safe_row("RealName, email", "txp_users", "name = '" . doSlash($AuthorID) . "'")); $evaluator =& get_comment_evaluator(); $out = gTxt('greeting') . " {$RealName}," . n . n; $out .= str_replace('{title}', $Title, gTxt('comment_recorded')) . n; $out .= permlinkurl_id($parentid) . n; if (has_privs('discuss', $AuthorID)) { $out .= hu . 'textpattern/index.php?event=discuss&step=discuss_edit&discussid=' . $discussid . n; } $out .= gTxt('status') . ": " . $evaluator->get_result('text') . '. ' . implode(',', $evaluator->get_result_message()) . n; $out .= n; $out .= gTxt('comment_name') . ": {$cname}" . n; $out .= gTxt('comment_email') . ": {$cemail}" . n; $out .= gTxt('comment_web') . ": {$cweb}" . n; $out .= gTxt('comment_comment') . ": {$message}"; $subject = strtr(gTxt('comment_received'), array('{site}' => $sitename, '{title}' => $Title)); $success = txpMail($email, $subject, $out, $cemail); }
function formatCommentsInvite($AnnotateInvite, $Section, $ID) { global $comments_mode; $dc = safe_count('txp_discuss', "parentid='{$ID}' and visible=1"); $ccount = $dc ? '[' . $dc . ']' : ''; if (!$comments_mode) { return '<a href="' . permlinkurl_id($ID) . '/#' . gTxt('comment') . '">' . $AnnotateInvite . '</a>' . $ccount; } else { return "<a href=\"" . hu . "?parentid={$ID}\" onclick=\"window.open(this.href, 'popupwindow', 'width=500,height=500,scrollbars,resizable,status'); return false;\">" . $AnnotateInvite . '</a> ' . $ccount; } }
/** * Renders article 'view' link. * * @param array $rs Article data * @return string HTML */ function article_partial_article_view($rs) { extract($rs); if ($Status != STATUS_LIVE and $Status != STATUS_STICKY) { $url = '?txpreview=' . intval($ID) . '.' . time(); // Article ID plus cachebuster. } else { include_once txpath . '/publish/taghandlers.php'; $url = permlinkurl_id($ID); } return n . href('<span class="ui-icon ui-icon-notice"></span> ' . gTxt('view'), $url, array('class' => 'txp-article-view', 'id' => 'article_partial_article_view')); }
/** * Hooks to article saving process and updates short URLs */ public static function update() { global $prefs; if (empty($prefs['rah_bitly_login']) || empty($prefs['rah_bitly_apikey']) || empty($prefs['rah_bitly_field'])) { return; } static $old = array(); static $updated = false; $id = !empty($GLOBALS['ID']) ? $GLOBALS['ID'] : ps('ID'); if (!$id || ps('_txp_token') != form_token() || intval(ps('Status')) < 4) { $old = array('permlink' => NULL, 'status' => NULL); return; } include_once txpath . '/publish/taghandlers.php'; /* Get the old article permlink before anything is saved */ if (!$old) { $old = array('permlink' => permlinkurl_id($id), 'status' => fetch('Status', 'textpattern', 'ID', $id)); return; } /* Clear the permlink cache */ unset($GLOBALS['permlinks'][$id]); /* Generate a new if permlink has changed or if article is published */ if (callback_event('rah_bitly.update') !== '') { return; } if ($updated == false && ($permlink = permlinkurl_id($id)) && ($old['permlink'] != $permlink || !ps('custom_' . $prefs['rah_bitly_field']) || $old['status'] != ps('Status'))) { $uri = self::fetch($permlink); if ($uri) { $fields = getCustomFields(); if (!isset($fields[$prefs['rah_bitly_field']])) { return; } safe_update('textpattern', 'custom_' . intval($prefs['rah_bitly_field']) . "='" . doSlash($uri) . "'", "ID='" . doSlash($id) . "'"); $_POST['custom_' . $prefs['rah_bitly_field']] = $uri; } $updated = true; } if (!empty($uri)) { echo script_js('$(\'input[name="custom_' . $prefs['rah_bitly_field'] . '"]\').val("' . escape_js($uri) . '");'); } }
function yab_shop_build_cart($cart) { $cart_display = ''; if ($cart->itemcount > 0) { foreach ($cart->get_contents() as $item) { $cart_display .= tag(href($item['name'], permlinkurl_id($item['txpid'])) . tag(tag(yab_shop_lang('price') . ': ' . yab_shop_currency_out(yab_shop_config('currency'), 'cur') . yab_shop_currency_out(yab_shop_config('currency'), 'toform', $item['price']), 'li', ' class="yab-price"') . tag(yab_shop_lang('quantity') . ': ' . $item['qty'], 'li', ' class="yab-qty"'), 'ul'), 'li', ' class="yab-item"'); } $cart_display = tag($cart_display, 'ul', ' class="yab-cart"'); $cart_display .= tag(yab_shop_lang('sub_total') . ': ' . yab_shop_currency_out(yab_shop_config('currency'), 'cur') . yab_shop_currency_out(yab_shop_config('currency'), 'toform', $cart->total), 'span', ' class="yab-subtotal"'); $cart_display .= tag(yab_shop_lang('to_checkout'), 'a', ' href="' . pagelinkurl(array('s' => yab_shop_config('checkout_section_name'))) . '" title="' . yab_shop_lang('to_checkout') . '" class="yab-to-checkout"'); } else { $cart_display = tag(yab_shop_lang('empty_cart'), 'span', ' class="yab-empty"'); } return $cart_display; }
function sed_cp_new_comment_digest($atts) { global $_sed_cp_new_cmts; /* Outputs a digest of comments since the viewer's last visit to the site (if any)... */ extract(lAtts(array('class' => __FUNCTION__, 'wraptag' => 'ul', 'break' => 'li', 'label' => '', 'labeltag' => '', 'limit' => '0', 'more' => ' …', 'max_visit' => 7200, 'empty' => gTxt('none')), $atts)); $new_comments = _sed_cp_get_comments($max_visit); if ($_sed_cp_new_cmts > 0) { $row_count = count($new_comments); if ($limit === '0' || intval($limit) < 0 || $row_count === intval($limit)) { $limit = $row_count + 1; } else { $limit = intval($limit); } foreach ($new_comments as $comment) { extract($comment); $item = href(escape_title($Title) . "({$new_com_count})", permlinkurl_id($parentid) . '#c' . $first_new); if (--$limit <= 0) { $items[] = $item . $more; break; } else { $items[] = $item; } } } else { $items[] = $empty; } return doLabel($label, $labeltag) . doWrap($items, $wraptag, $break, $class); }
function article_edit($message = '', $concurrent = FALSE) { global $vars, $txp_user, $comments_disabled_after, $txpcfg, $prefs, $event; extract($prefs); extract(gpsa(array('view', 'from_view', 'step'))); if (!empty($GLOBALS['ID'])) { // newly-saved article $ID = $GLOBALS['ID']; $step = 'edit'; } else { $ID = gps('ID'); } include_once txpath . '/lib/classTextile.php'; $textile = new Textile(); // switch to 'text' view upon page load and after article post if (!$view || gps('save') || gps('publish')) { $view = 'text'; } if (!$step) { $step = "create"; } if ($step == "edit" && $view == "text" && !empty($ID) && $from_view != 'preview' && $from_view != 'html' && !$concurrent) { $pull = true; //-- it's an existing article - off we go to the db $ID = assert_int($ID); $rs = safe_row("*, unix_timestamp(Posted) as sPosted,\n\t\t\t\tunix_timestamp(Expires) as sExpires,\n\t\t\t\tunix_timestamp(LastMod) as sLastMod", "textpattern", "ID={$ID}"); extract($rs); $reset_time = $publish_now = $Status < 4 && $sPosted <= time(); } else { $pull = false; //-- assume they came from post if ($from_view == 'preview' or $from_view == 'html') { $store_out = array(); $store = unserialize(base64_decode(ps('store'))); foreach ($vars as $var) { if (isset($store[$var])) { $store_out[$var] = $store[$var]; } } } else { $store_out = gpsa($vars); if ($concurrent) { $store_out['sLastMod'] = safe_field('unix_timestamp(LastMod) as sLastMod', 'textpattern', 'ID=' . $ID); } } $rs = $store_out; extract($store_out); } $GLOBALS['step'] = $step; if ($step == 'create') { $textile_body = $use_textile; $textile_excerpt = $use_textile; } if ($step != 'create' && $sPosted) { // Previous record? $prev_id = checkIfNeighbour('prev', $sPosted); // Next record? $next_id = checkIfNeighbour('next', $sPosted); } else { $prev_id = $next_id = 0; } $page_title = $Title ? $Title : gTxt('write'); pagetop($page_title, $message); echo n . '<div id="' . $event . '_container" class="txp-container txp-edit">'; echo n . n . '<form id="article_form" name="article_form" method="post" action="index.php">'; if (!empty($store_out)) { echo hInput('store', base64_encode(serialize($store_out))); } echo hInput('ID', $ID) . eInput('article') . sInput($step) . '<input type="hidden" name="view" />' . startTable('edit') . '<tr>' . n . '<td id="article-col-1"><div id="configuration_content">'; if ($view == 'text') { //-- markup help -------------- echo pluggable_ui('article_ui', 'sidehelp', side_help($textile_body, $textile_excerpt), $rs); //-- custom menu entries -------------- echo pluggable_ui('article_ui', 'extend_col_1', '', $rs); //-- advanced -------------- echo '<div id="advanced_group"><h3 class="plain lever' . (get_pref('pane_article_advanced_visible') ? ' expanded' : '') . '"><a href="#advanced">' . gTxt('advanced_options') . '</a></h3>' . '<div id="advanced" class="toggle" style="display:' . (get_pref('pane_article_advanced_visible') ? 'block' : 'none') . '">'; // markup selection echo pluggable_ui('article_ui', 'markup', n . graf('<label for="markup-body">' . gTxt('article_markup') . '</label>' . br . pref_text('textile_body', $textile_body, 'markup-body'), ' class="markup markup-body"') . n . graf('<label for="markup-excerpt">' . gTxt('excerpt_markup') . '</label>' . br . pref_text('textile_excerpt', $textile_excerpt, 'markup-excerpt'), ' class="markup markup-excerpt"'), $rs); // form override echo $allow_form_override ? pluggable_ui('article_ui', 'override', graf('<label for="override-form">' . gTxt('override_default_form') . '</label>' . sp . popHelp('override_form') . br . form_pop($override_form, 'override-form'), ' class="override-form"'), $rs) : ''; echo '</div></div>' . n; //-- custom fields -------------- $cf = ''; $cfs = getCustomFields(); echo '<div id="custom_field_group"' . ($cfs ? '' : ' class="empty"') . '><h3 class="plain lever' . (get_pref('pane_article_custom_field_visible') ? ' expanded' : '') . '"><a href="#custom_field">' . gTxt('custom') . '</a></h3>' . '<div id="custom_field" class="toggle" style="display:' . (get_pref('pane_article_custom_field_visible') ? 'block' : 'none') . '">'; foreach ($cfs as $i => $cf_name) { $custom_x_set = "custom_{$i}_set"; $custom_x = "custom_{$i}"; $cf .= ${$custom_x_set} !== '' ? custField($i, ${$custom_x_set}, ${$custom_x}) : ''; } echo pluggable_ui('article_ui', 'custom_fields', $cf, $rs); echo '</div></div>' . n; //-- article image -------------- echo '<div id="image_group"><h3 class="plain lever' . (get_pref('pane_article_image_visible') ? ' expanded' : '') . '"><a href="#image">' . gTxt('article_image') . '</a></h3>' . '<div id="image" class="toggle" style="display:' . (get_pref('pane_article_image_visible') ? 'block' : 'none') . '">'; echo pluggable_ui('article_ui', 'article_image', n . graf('<label for="article-image">' . gTxt('article_image') . '</label>' . sp . popHelp('article_image') . br . fInput('text', 'Image', $Image, 'edit', '', '', 22, '', 'article-image'), ' class="article-image"'), $rs); echo '</div></div>' . n; //-- meta info -------------- echo '<div id="meta_group"><h3 class="plain lever' . (get_pref('pane_article_meta_visible') ? ' expanded' : '') . '"><a href="#meta">' . gTxt('meta') . '</a></h3>' . '<div id="meta" class="toggle" style="display:' . (get_pref('pane_article_meta_visible') ? 'block' : 'none') . '">'; // keywords echo pluggable_ui('article_ui', 'keywords', n . graf('<label for="keywords">' . gTxt('keywords') . '</label>' . sp . popHelp('keywords') . br . n . '<textarea id="keywords" name="Keywords" cols="18" rows="5">' . htmlspecialchars(str_replace(',', ', ', $Keywords)) . '</textarea>', ' class="keywords"'), $rs); // url title echo pluggable_ui('article_ui', 'url_title', n . graf('<label for="url-title">' . gTxt('url_title') . '</label>' . sp . popHelp('url_title') . br . fInput('text', 'url_title', $url_title, 'edit', '', '', 22, '', 'url-title'), ' class="url-title"'), $rs); echo '</div></div>' . n; //-- recent articles -------------- echo '<div id="recent_group"><h3 class="plain lever' . (get_pref('pane_article_recent_visible') ? ' expanded' : '') . '"><a href="#recent">' . gTxt('recent_articles') . '</a>' . '</h3>' . '<div id="recent" class="toggle" style="display:' . (get_pref('pane_article_recent_visible') ? 'block' : 'none') . '">'; $recents = safe_rows_start("Title, ID", 'textpattern', "1=1 order by LastMod desc limit 10"); $ra = ''; if ($recents) { $ra = '<ul class="recent plain-list">'; while ($recent = nextRow($recents)) { if (!$recent['Title']) { $recent['Title'] = gTxt('untitled') . sp . $recent['ID']; } $ra .= n . t . '<li class="recent-article"><a href="?event=article' . a . 'step=edit' . a . 'ID=' . $recent['ID'] . '">' . escape_title($recent['Title']) . '</a></li>'; } $ra .= '</ul>'; } echo pluggable_ui('article_ui', 'recent_articles', $ra, $rs); echo '</div></div>'; } else { echo sp; } echo '</div></td>' . n . '<td id="article-main"><div id="main_content">'; //-- title input -------------- if ($view == 'preview') { echo '<div class="preview">' . hed(gTxt('preview'), 2) . hed($Title, 1, ' class="title"'); } elseif ($view == 'html') { echo '<div class="xhtml">' . hed('XHTML', 2) . hed($Title, 1, ' class="title"'); } elseif ($view == 'text') { echo '<div class="text">' . pluggable_ui('article_ui', 'title', n . '<p class="title"><label for="title">' . gTxt('title') . '</label>' . sp . popHelp('title') . br . '<input type="text" id="title" name="Title" value="' . escape_title($Title) . '" class="edit" size="40" tabindex="1" />', $rs); if ($step != 'create') { if ($Status != 4 and $Status != 5) { $url = '?txpreview=' . intval($ID) . '.' . time(); // article ID plus cachebuster } else { include_once txpath . '/publish/taghandlers.php'; $url = permlinkurl_id($ID); } echo sp . sp . '<a href="' . $url . '" class="article-view">' . gTxt('view') . '</a>'; } echo '</p>'; } //-- body -------------------- if ($view == 'preview') { echo '<div class="body">'; if ($textile_body == USE_TEXTILE) { echo $textile->TextileThis($Body); } else { if ($textile_body == CONVERT_LINEBREAKS) { echo nl2br($Body); } else { if ($textile_body == LEAVE_TEXT_UNTOUCHED) { echo $Body; } } } echo '</div>'; } elseif ($view == 'html') { if ($textile_body == USE_TEXTILE) { $bod = $textile->TextileThis($Body); } else { if ($textile_body == CONVERT_LINEBREAKS) { $bod = nl2br($Body); } else { if ($textile_body == LEAVE_TEXT_UNTOUCHED) { $bod = $Body; } } } echo tag(str_replace(array(n, t), array(br, sp . sp . sp . sp), htmlspecialchars($bod)), 'code', ' class="body"'); } else { echo pluggable_ui('article_ui', 'body', n . graf('<label for="body">' . gTxt('body') . '</label>' . sp . popHelp('body') . br . '<textarea id="body" name="Body" cols="55" rows="31" tabindex="2">' . htmlspecialchars($Body) . '</textarea>', ' class="body"'), $rs); } //-- excerpt -------------------- if ($articles_use_excerpts) { if ($view == 'text') { echo pluggable_ui('article_ui', 'excerpt', n . graf('<label for="excerpt">' . gTxt('excerpt') . '</label>' . sp . popHelp('excerpt') . br . '<textarea id="excerpt" name="Excerpt" cols="55" rows="5" tabindex="3">' . htmlspecialchars($Excerpt) . '</textarea>', ' class="excerpt"'), $rs); } else { echo n . '<hr width="50%" />'; echo '<div class="excerpt">'; echo $textile_excerpt == USE_TEXTILE ? $view == 'preview' ? graf($textile->textileThis($Excerpt)) : tag(str_replace(array(n, t), array(br, sp . sp . sp . sp), htmlspecialchars($textile->TextileThis($Excerpt))), 'code', ' class="excerpt"') : graf($Excerpt); echo '</div>'; } } //-- author -------------- if ($view == "text" && $step != "create") { echo '<p class="author small">' . gTxt('posted_by') . ': ' . htmlspecialchars($AuthorID) . ' · ' . safe_strftime('%d %b %Y · %X', $sPosted); if ($sPosted != $sLastMod) { echo br . gTxt('modified_by') . ': ' . htmlspecialchars($LastModID) . ' · ' . safe_strftime('%d %b %Y · %X', $sLastMod); } echo '</p>'; } echo hInput('from_view', $view), '</div></div></td>'; //-- layer tabs ------------------- echo '<td id="article-tabs"><div id="view_modes">'; echo pluggable_ui('article_ui', 'view', $use_textile == USE_TEXTILE || $textile_body == USE_TEXTILE ? tag(tab('text', $view) . tab('html', $view) . tab('preview', $view), 'ul') : ' ', $rs); echo '</div></td>'; echo '<td id="article-col-2"><div id="supporting_content">'; if ($view == 'text') { if ($step != 'create') { echo n . graf(href(gtxt('create_new'), 'index.php?event=article'), ' class="action-create"'); } //-- prev/next article links -- if ($step != 'create' and ($prev_id or $next_id)) { echo '<p class="article-nav">', $prev_id ? prevnext_link('‹' . gTxt('prev'), 'article', 'edit', $prev_id, gTxt('prev')) : '', $next_id ? prevnext_link(gTxt('next') . '›', 'article', 'edit', $next_id, gTxt('next')) : '', '</p>'; } //-- status radios -------------- echo pluggable_ui('article_ui', 'status', n . n . '<fieldset id="write-status">' . n . '<legend>' . gTxt('status') . '</legend>' . n . status_radio($Status) . n . '</fieldset>', $rs); //-- category selects ----------- echo pluggable_ui('article_ui', 'categories', n . n . '<fieldset id="write-sort">' . n . '<legend>' . gTxt('sort_display') . '</legend>' . n . graf('<label for="category-1">' . gTxt('category1') . '</label> ' . '<span class="edit category-edit small">[' . eLink('category', '', '', '', gTxt('edit')) . ']</span>' . br . n . category_popup('Category1', $Category1, 'category-1'), ' class="category category-1"') . n . graf('<label for="category-2">' . gTxt('category2') . '</label>' . br . n . category_popup('Category2', $Category2, 'category-2'), ' class="category category-2"'), $rs); //-- section select -------------- if (!$from_view && !$pull) { $Section = getDefaultSection(); } echo pluggable_ui('article_ui', 'section', n . graf('<label for="section">' . gTxt('section') . '</label> ' . '<span class="edit section-edit small">[' . eLink('section', '', '', '', gTxt('edit')) . ']</span>' . br . section_popup($Section, 'section'), ' class="section"') . n . '</fieldset>', $rs); //-- "More" section echo n . n . '<div id="more_group"><h3 class="plain lever' . (get_pref('pane_article_more_visible') ? ' expanded' : '') . '"><a href="#more">' . gTxt('more') . '</a></h3>', '<div id="more" class="toggle" style="display:' . (get_pref('pane_article_more_visible') ? 'block' : 'none') . '">'; //-- comments stuff -------------- if ($step == "create") { //Avoiding invite disappear when previewing $AnnotateInvite = !empty($store_out['AnnotateInvite']) ? $store_out['AnnotateInvite'] : $comments_default_invite; if ($comments_on_default == 1) { $Annotate = 1; } } if ($use_comments == 1) { $invite[] = n . n . '<fieldset id="write-comments">' . n . '<legend>' . gTxt('comments') . '</legend>'; $comments_expired = false; if ($step != 'create' && $comments_disabled_after) { $lifespan = $comments_disabled_after * 86400; $time_since = time() - $sPosted; if ($time_since > $lifespan) { $comments_expired = true; } } if ($comments_expired) { $invite[] = n . n . graf(gTxt('expired'), ' class="comment-annotate"'); } else { $invite[] = n . n . graf(onoffRadio('Annotate', $Annotate), ' class="comment-annotate"') . n . n . graf('<label for="comment-invite">' . gTxt('comment_invitation') . '</label>' . br . fInput('text', 'AnnotateInvite', $AnnotateInvite, 'edit', '', '', '', '', 'comment-invite'), ' class="comment-invite"'); } $invite[] = n . n . '</fieldset>'; echo pluggable_ui('article_ui', 'annotate_invite', join('', $invite), $rs); } if ($step == "create" and empty($GLOBALS['ID'])) { //-- timestamp ------------------- //Avoiding modified date to disappear $persist_timestamp = !empty($store_out['year']) ? safe_strtotime($store_out['year'] . '-' . $store_out['month'] . '-' . $store_out['day'] . ' ' . $store_out['hour'] . ':' . $store_out['minute'] . ':' . $store_out['second']) : time(); echo pluggable_ui('article_ui', 'timestamp', n . n . '<fieldset id="write-timestamp">' . n . '<legend>' . gTxt('timestamp') . '</legend>' . n . graf(checkbox('publish_now', '1', $publish_now, '', 'publish_now') . '<label for="publish_now">' . gTxt('set_to_now') . '</label>', ' class="publish-now"') . n . graf(gTxt('or_publish_at') . sp . popHelp('timestamp'), ' class="publish-at"') . n . graf('<span class="label">' . gtxt('date') . '</span>' . sp . tsi('year', '%Y', $persist_timestamp) . ' / ' . tsi('month', '%m', $persist_timestamp) . ' / ' . tsi('day', '%d', $persist_timestamp), ' class="date posted created"') . n . graf('<span class="label">' . gTxt('time') . '</span>' . sp . tsi('hour', '%H', $persist_timestamp) . ' : ' . tsi('minute', '%M', $persist_timestamp) . ' : ' . tsi('second', '%S', $persist_timestamp), ' class="time posted created"') . n . '</fieldset>', array('sPosted' => $persist_timestamp) + $rs); //-- expires ------------------- $persist_timestamp = !empty($store_out['exp_year']) ? safe_strtotime($store_out['exp_year'] . '-' . $store_out['exp_month'] . '-' . $store_out['exp_day'] . ' ' . $store_out['exp_hour'] . ':' . $store_out['exp_minute'] . ':' . $store_out['second']) : NULLDATETIME; echo pluggable_ui('article_ui', 'expires', n . n . '<fieldset id="write-expires">' . n . '<legend>' . gTxt('expires') . '</legend>' . n . graf('<span class="label">' . gtxt('date') . '</span>' . sp . tsi('exp_year', '%Y', $persist_timestamp) . ' / ' . tsi('exp_month', '%m', $persist_timestamp) . ' / ' . tsi('exp_day', '%d', $persist_timestamp), ' class="date expires"') . n . graf('<span class="label">' . gTxt('time') . '</span>' . sp . tsi('exp_hour', '%H', $persist_timestamp) . ' : ' . tsi('exp_minute', '%M', $persist_timestamp) . ' : ' . tsi('exp_second', '%S', $persist_timestamp), ' class="time expires"') . n . '</fieldset>', $rs); // end "More" section echo n . n . '</div></div>'; //-- publish button -------------- echo has_privs('article.publish') ? fInput('submit', 'publish', gTxt('publish'), "publish", '', '', '', 4) : fInput('submit', 'publish', gTxt('save'), "publish", '', '', '', 4); } else { //-- timestamp ------------------- if (!empty($year)) { $sPosted = safe_strtotime($year . '-' . $month . '-' . $day . ' ' . $hour . ':' . $minute . ':' . $second); } echo pluggable_ui('article_ui', 'timestamp', n . n . '<fieldset id="write-timestamp">' . n . '<legend>' . gTxt('timestamp') . '</legend>' . n . graf(checkbox('reset_time', '1', $reset_time, '', 'reset_time') . '<label for="reset_time">' . gTxt('reset_time') . '</label>', ' class="reset-time"') . n . graf(gTxt('published_at') . sp . popHelp('timestamp'), ' class="publish-at"') . n . graf('<span class="label">' . gtxt('date') . '</span>' . sp . tsi('year', '%Y', $sPosted) . ' / ' . tsi('month', '%m', $sPosted) . ' / ' . tsi('day', '%d', $sPosted), ' class="date posted created"') . n . graf('<span class="label">' . gTxt('time') . '</span>' . sp . tsi('hour', '%H', $sPosted) . ' : ' . tsi('minute', '%M', $sPosted) . ' : ' . tsi('second', '%S', $sPosted), ' class="time posted created"') . n . hInput('sPosted', $sPosted) . n . hInput('sLastMod', $sLastMod) . n . hInput('AuthorID', $AuthorID) . n . hInput('LastModID', $LastModID) . n . '</fieldset>', $rs); //-- expires ------------------- if (!empty($exp_year)) { if (empty($exp_month)) { $exp_month = 1; } if (empty($exp_day)) { $exp_day = 1; } if (empty($exp_hour)) { $exp_hour = 0; } if (empty($exp_minute)) { $exp_minute = 0; } if (empty($exp_second)) { $exp_second = 0; } $sExpires = safe_strtotime($exp_year . '-' . $exp_month . '-' . $exp_day . ' ' . $exp_hour . ':' . $exp_minute . ':' . $exp_second); } echo pluggable_ui('article_ui', 'expires', n . n . '<fieldset id="write-expires">' . n . '<legend>' . gTxt('expires') . '</legend>' . n . graf('<span class="label">' . gtxt('date') . '</span>' . sp . tsi('exp_year', '%Y', $sExpires) . ' / ' . tsi('exp_month', '%m', $sExpires) . ' / ' . tsi('exp_day', '%d', $sExpires), ' class="date expires"') . n . graf('<span class="label">' . gTxt('time') . '</span>' . sp . tsi('exp_hour', '%H', $sExpires) . ' : ' . tsi('exp_minute', '%M', $sExpires) . ' : ' . tsi('exp_second', '%S', $sExpires), ' class="time expires"') . n . hInput('sExpires', $sExpires) . n . '</fieldset>', $rs); // end "More" section echo n . n . '</div></div>'; //-- save button -------------- if ($Status >= 4 and has_privs('article.edit.published') or $Status >= 4 and $AuthorID == $txp_user and has_privs('article.edit.own.published') or $Status < 4 and has_privs('article.edit') or $Status < 4 and $AuthorID == $txp_user and has_privs('article.edit.own')) { echo fInput('submit', 'save', gTxt('save'), "publish", '', '', '', 4); } } } echo '</div></td></tr></table></form></div>' . n; // Assume users would not change the timestamp if they wanted to "publish now"/"reset time" echo script_js(<<<EOS \t\t\$('#write-timestamp input.edit').change( \t\t\tfunction() { \t\t\t\t\$('#publish_now').attr('checked', false); \t\t\t\t\$('#reset_time').attr('checked', false); \t\t\t}); EOS ); }
function article_edit_form($step, $view, $from_view, $article) { global $txpcfg, $txp_user, $article_vars; extract(get_prefs()); extract($article); if ($step != 'create') { // Previous record? $prev_id = checkIfNeighbour('prev', $sPosted); // Next record? $next_id = checkIfNeighbour('next', $sPosted); } echo n . n . '<form name="article" method="post" action="index.php" enctype="multipart/form-data">'; if ($view != 'text') { echo hInput('store', base64_encode(serialize($article))); } echo hInput('ID', $ID) . eInput('article') . sInput($step) . '<input type="hidden" name="view" />' . startTable('edit') . '<tr>' . n . '<td id="article-col-1">'; if ($view == 'text') { //-- markup help -------------- echo side_help($markup_body, $markup_excerpt) . '<h3 class="plain"><a href="#advanced" onclick="toggleDisplay(\'advanced\'); return false;">' . gTxt('advanced_options') . '</a></h3>', '<div id="advanced" style="display:none;">', n . graf('<label for="markup-body">' . gTxt('article_markup') . '</label>' . br . pref_markup('markup_body', $markup_body, 'markup-body')), n . graf('<label for="markup-excerpt">' . gTxt('excerpt_markup') . '</label>' . pref_markup('markup_excerpt', $markup_excerpt, 'markup-excerpt')), $allow_form_override ? graf('<label for="override-form">' . gTxt('override_default_form') . '</label>' . br . form_pop($override_form, 'override-form') . sp . popHelp('override_form')) : '', n . graf('<label for="article-image">' . gTxt('article_image') . '</label>' . sp . popHelp('article_image') . br . fInput('text', 'Image', $Image, 'edit', '', '', 22, '', 'article-image')), n . graf('<label for="url-title">' . gTxt('url_title') . '</label>' . sp . popHelp('url_title') . br . fInput('text', 'url_title', $url_title, 'edit', '', '', 22, '', 'url-title')) . '</div> <h3 class="plain"><a href="#recent" onclick="toggleDisplay(\'recent\'); return false;">' . gTxt('recent_articles') . '</a>' . '</h3>' . '<div id="recent" style="display:none;">'; $recents = safe_rows_start("Title, ID", 'textpattern', "1=1 order by LastMod desc limit 10"); if ($recents) { echo '<ul class="plain-list">'; while ($recent = nextRow($recents)) { if (!$recent['Title']) { $recent['Title'] = gTxt('untitled') . sp . $recent['ID']; } echo n . t . '<li><a href="?event=article' . a . 'step=edit' . a . 'ID=' . $recent['ID'] . '">' . escape_title($recent['Title']) . '</a></li>'; } echo '</ul>'; } echo '</div>'; } else { echo sp; } echo '</td>' . n . '<td id="article-main">'; //-- title input -------------- if ($view == 'preview') { echo hed(gTxt('preview'), 2) . hed($Title, 1); } elseif ($view == 'html') { echo hed('XHTML', 2) . hed($Title, 1); } else { echo '<p><label for="title">' . gTxt('title') . '</label>'; if (($Status == 4 or $Status == 5) and $step != 'create') { include_once txpath . '/publish/taghandlers.php'; echo sp . sp . '[<a href="' . permlinkurl_id($ID) . '">' . gTxt('view') . '</a>]'; } echo '<br />' . n . '<input type="text" id="title" name="Title" value="' . cleanfInput($Title) . '" class="edit" size="65" tabindex="1" /></p>'; } //-- body -------------------- if ($view == 'preview') { echo do_markup($markup_body, $Body); } elseif ($view == 'html') { $bod = do_markup($markup_body, $Body); echo tag(str_replace(array(n, t), array(br, sp . sp . sp . sp), htmlspecialchars($bod)), 'code'); } else { echo n . graf('<label for="body">' . gTxt('body') . '</label><br />' . n . '<textarea id="body" name="Body" cols="55" rows="31" tabindex="2">' . htmlspecialchars($Body) . '</textarea>'); } //-- excerpt -------------------- if ($articles_use_excerpts) { if ($view == 'text') { echo n . graf('<label for="excerpt">' . gTxt('excerpt') . '</label>' . sp . popHelp('excerpt') . br . '<textarea id="excerpt" name="Excerpt" cols="55" rows="10" tabindex="3">' . htmlspecialchars($Excerpt) . '</textarea>'); } else { echo n . '<hr width="50%" />'; echo $view == 'preview' ? graf(do_markup($markup_excerpt, $Excerpt)) : tag(str_replace(array(n, t), array(br, sp . sp . sp . sp), htmlspecialchars(do_markup($markup_excerpt, $Excerpt))), 'code'); } } //-- keywords -------------- if ($view == 'text') { echo n . graf('<label for="keywords">' . gTxt('keywords') . '</label>' . sp . popHelp('keywords') . br . '<textarea id="keywords" name="Keywords" cols="55" rows="5">' . htmlspecialchars(str_replace(',', ', ', $Keywords)) . '</textarea>'); //-- custom fields -------------- echo $custom_1_set ? custField(1, $custom_1_set, $custom_1) : '', $custom_2_set ? custField(2, $custom_2_set, $custom_2) : '', $custom_3_set ? custField(3, $custom_3_set, $custom_3) : '', $custom_4_set ? custField(4, $custom_4_set, $custom_4) : '', $custom_5_set ? custField(5, $custom_5_set, $custom_5) : '', $custom_6_set ? custField(6, $custom_6_set, $custom_6) : '', $custom_7_set ? custField(7, $custom_7_set, $custom_7) : '', $custom_8_set ? custField(8, $custom_8_set, $custom_8) : '', $custom_9_set ? custField(9, $custom_9_set, $custom_9) : '', $custom_10_set ? custField(10, $custom_10_set, $custom_10) : ''; } //-- author -------------- if ($view == "text" && $step != "create") { echo '<p class="small">' . gTxt('posted_by') . ': ' . htmlspecialchars($AuthorID) . ' · ' . safe_strftime('%d %b %Y · %X', $sPosted); if ($sPosted != $sLastMod) { echo br . gTxt('modified_by') . ': ' . htmlspecialchars($LastModID) . ' · ' . safe_strftime('%d %b %Y · %X', $sLastMod); } echo '</p>'; } echo hInput('from_view', $view); echo '</td>'; echo '<td id="article-tabs">'; //-- layer tabs ------------------- echo graf(tab('text', $view) . br . tab('html', $view) . br . tab('preview', $view)); echo '</td>'; echo '<td id="article-col-2">'; if ($view == 'text') { if ($step != 'create') { echo n . graf(href(gtxt('create_new'), 'index.php?event=article')); } //-- prev/next article links -- if ($step != 'create' and ($prev_id or $next_id)) { echo '<p>', $prev_id ? prevnext_link('‹' . gTxt('prev'), 'article', 'edit', $prev_id, gTxt('prev')) : '', $next_id ? prevnext_link(gTxt('next') . '›', 'article', 'edit', $next_id, gTxt('next')) : '', '</p>'; } //-- status radios -------------- echo n . n . fieldset(status_radio($Status), gTxt('status'), 'write-status') . n . n . fieldset(n . graf('<label for="section">' . gTxt('section') . '</label> ' . '<span class="small">[' . eLink('section', '', '', '', gTxt('edit')) . ']</span>' . br . section_popup($Section, 'section')) . n . graf('<label for="category-1">' . gTxt('category1') . '</label> ' . '<span class="small">[' . eLink('category', '', '', '', gTxt('edit')) . ']</span>' . br . n . category_popup('Category1', $Category1, 'category-1')) . n . graf('<label for="category-2">' . gTxt('category2') . '</label>' . br . n . category_popup('Category2', $Category2, 'category-2')), gTxt('sort_display'), 'write-sort') . n . n . '<h3 class="plain"><a href="#more" onclick="toggleDisplay(\'more\'); return false;">' . gTxt('more') . '</a></h3>', '<div id="more" style="display: none;">'; //-- comments stuff -------------- if ($step == "create") { //Avoiding invite disappear when previewing $AnnotateInvite = !empty($store_out['AnnotateInvite']) ? $store_out['AnnotateInvite'] : $comments_default_invite; if ($comments_on_default == 1) { $Annotate = 1; } } if ($use_comments == 1) { echo n . n . '<fieldset id="write-comments">' . n . '<legend>' . gTxt('comments') . '</legend>'; $comments_expired = false; if ($step != 'create' && $comments_disabled_after) { $lifespan = $comments_disabled_after * 86400; $time_since = time() - $sPosted; if ($time_since > $lifespan) { $comments_expired = true; } } if ($comments_expired) { echo n . n . graf(gTxt('expired')); } else { echo n . n . graf(onoffRadio('Annotate', $Annotate)) . n . n . graf('<label for="comment-invite">' . gTxt('comment_invitation') . '</label>' . br . fInput('text', 'AnnotateInvite', $AnnotateInvite, 'edit', '', '', '', '', 'comment-invite')); } echo n . n . '</fieldset>'; } if ($step == "create" and empty($GLOBALS['ID'])) { //-- timestamp ------------------- //Avoiding modified date to disappear $persist_timestamp = !empty($store_out['year']) ? safe_strtotime($store_out['year'] . '-' . $store_out['month'] . '-' . $store_out['day'] . ' ' . $store_out['hour'] . ':' . $store_out['minute'] . ':' . $store_out['second']) : time(); echo n . n . fieldset(n . graf(checkbox('publish_now', '1', $publish_now, '', 'publish_now') . '<label for="publish_now">' . gTxt('set_to_now') . '</label>') . n . graf(gTxt('or_publish_at') . sp . popHelp('timestamp')) . n . graf(gtxt('date') . sp . tsi('year', '%Y', $persist_timestamp, '', 4) . ' / ' . tsi('month', '%m', $persist_timestamp) . ' / ' . tsi('day', '%d', $persist_timestamp)) . n . graf(gTxt('time') . sp . tsi('hour', '%H', $persist_timestamp) . ' : ' . tsi('minute', '%M', $persist_timestamp) . ' : ' . tsi('second', '%S', $persist_timestamp)), gTxt('timestamp'), 'write-timestamp'); //-- expires ------------------- $persist_timestamp = !empty($store_out['exp_year']) ? safe_strtotime($store_out['exp_year'] . '-' . $store_out['exp_month'] . '-' . $store_out['exp_day'] . ' ' . $store_out['exp_hour'] . ':' . $store_out['exp_minute'] . ':' . $store_out['second']) : NULLDATETIME; echo n . n . fieldset(n . graf(gtxt('date') . sp . tsi('exp_year', '%Y', $persist_timestamp, '', 4) . ' / ' . tsi('exp_month', '%m', $persist_timestamp) . ' / ' . tsi('exp_day', '%d', $persist_timestamp)) . n . graf(gTxt('time') . sp . tsi('exp_hour', '%H', $persist_timestamp) . ' : ' . tsi('exp_minute', '%M', $persist_timestamp) . ' : ' . tsi('exp_second', '%S', $persist_timestamp)), gTxt('expires') . sp . popHelp('expires'), 'write-expires') . n . n . '</div>'; //-- publish button -------------- echo has_privs('article.publish') ? fInput('submit', 'publish', gTxt('publish'), "publish", '', '', '', 4) : fInput('submit', 'publish', gTxt('save'), "publish", '', '', '', 4); } else { //-- timestamp ------------------- if (!empty($year)) { $sPosted = safe_strtotime($year . '-' . $month . '-' . $day . ' ' . $hour . ':' . $minute . ':' . $second); } echo n . n . fieldset(n . graf(checkbox('reset_time', '1', $reset_time, '', 'reset_time') . '<label for="reset_time">' . gTxt('reset_time') . '</label>') . n . graf(gTxt('published_at') . sp . popHelp('timestamp')) . n . graf(gtxt('date') . sp . tsi('year', '%Y', $sPosted, '', 4) . ' / ' . tsi('month', '%m', $sPosted) . ' / ' . tsi('day', '%d', $sPosted)) . n . graf(gTxt('time') . sp . tsi('hour', '%H', $sPosted) . ' : ' . tsi('minute', '%M', $sPosted) . ' : ' . tsi('second', '%S', $sPosted)) . n . hInput('sPosted', $sPosted) . n . hInput('sLastMod', $sLastMod) . n . hInput('AuthorID', $AuthorID) . n . hInput('LastModID', $LastModID), gTxt('timestamp'), 'write-timestamp'); //-- expires ------------------- if (!empty($exp_year)) { if (empty($exp_month)) { $exp_month = 1; } if (empty($exp_day)) { $exp_day = 1; } if (empty($exp_hour)) { $exp_hour = 0; } if (empty($exp_minute)) { $exp_minute = 0; } if (empty($exp_second)) { $exp_second = 0; } $sExpires = safe_strtotime($exp_year . '-' . $exp_month . '-' . $exp_day . ' ' . $exp_hour . ':' . $exp_minute . ':' . $exp_second); } echo n . n . fieldset(n . graf(gtxt('date') . sp . tsi('exp_year', '%Y', $sExpires, '', 4) . ' / ' . tsi('exp_month', '%m', $sExpires) . ' / ' . tsi('exp_day', '%d', $sExpires)) . n . graf(gTxt('time') . sp . tsi('exp_hour', '%H', $sExpires) . ' : ' . tsi('exp_minute', '%M', $sExpires) . ' : ' . tsi('exp_second', '%S', $sExpires)) . n . hInput('sExpires', $sExpires), gTxt('expires') . sp . popHelp('expires'), 'write-expires') . n . n . '</div>'; //-- save button -------------- if ($Status >= 4 and has_privs('article.edit.published') or $Status >= 4 and $AuthorID == $txp_user and has_privs('article.edit.own.published') or $Status < 4 and has_privs('article.edit') or $Status < 4 and $AuthorID == $txp_user and has_privs('article.edit.own')) { echo fInput('submit', 'save', gTxt('save'), "publish", '', '', '', 4); } } } echo '</td></tr></table></form>'; }
function product_edit($event, $step, $message = '') { global $vars, $txp_user, $comments_disabled_after, $txpcfg, $prefs; extract($prefs); define("IMPATH", $path_to_site . '/' . $img_dir . '/'); extract(gpsa(array('view', 'from_view', 'step'))); if (!empty($GLOBALS['ID'])) { // newly-saved article $ID = $GLOBALS['ID']; $step = 'edit'; } else { $ID = gps('ID'); } //GET ARTICLE DATA FOR 'EDIT' & 'SAVE' STEP //================================== if ($step == "edit" || $step == "save" && !empty($ID)) { $pull = true; //-- it's an existing article - off we go to the db $ID = assert_int($ID); $rs = safe_row("*, unix_timestamp(Posted) as sPosted,\n\t\t\t\tunix_timestamp(LastMod) as sLastMod", "textpattern", "ID={$ID}"); extract($rs); if ($AnnotateInvite != $comments_default_invite) { $AnnotateInvite = $AnnotateInvite; } else { $AnnotateInvite = $comments_default_invite; } $custom_fields = safe_rows("*", "product_custom_fields", "articleID = {$ID} ORDER BY id DESC"); $step = "save"; //print_r($rs); } else { if (empty($step)) { $step = "create"; } } $textile = new Textile(); $textile_body = $use_textile; $textile_excerpt = $use_textile; $page_title = "Add a new product"; $message = ""; pagetop($page_title, $message); if (count($custom_fields) > 0) { $startFieldNum = $custom_fields[0]['id'] + 1; } else { $startFieldNum = 0; } //JS INCLUDES //================================== //print_r($prefs); echo '<script type="text/javascript" src="http://' . $siteurl . '/js/prototype.js"></script>'; echo '<script type="text/javascript" src="http://' . $siteurl . '/js/scriptaculous.js"></script>'; //CSS FOR PRODUCT DISPLAY //================================== echo n . '<style type="text/css">' . n . 'h4.productHeading{' . n . ' color:gray;' . n . ' margin-bottom:0px;' . n . '}' . n . 'h4.productHeading span{' . n . ' float:right;' . n . ' font-size:9px;' . n . ' font-style:italic;' . n . ' font-weight:normal;' . n . '}' . n . '.product-options-sub{' . n . ' padding: 10px;' . n . '}' . n . '.product-options-sub em{' . n . ' color:gray;' . n . '}' . n . '.product-options-sub legend{' . n . ' font-size:11px;' . n . '}' . n . '.product-options-sub label{' . n . ' font-size:11px;' . n . ' padding-bottom: 5px;' . n . '}' . n . '#images ul.plain-list li{' . n . ' float:left;' . n . ' margin-right:10px;' . n . ' margin-bottom:10px;' . n . ' width:375px;' . n . '}' . n . '#images ul.plain-list li img{' . n . ' border-width: 1px;' . n . ' border-color:#BBBBBB;' . n . ' border-style:solid;' . n . ' padding:3px;' . n . ' background-color: #E0E0E0;' . n . ' float:left;' . n . '}' . n . '#images ul.plain-list li .imageEdit{' . n . ' background-color:#E0E0E0;' . n . ' height: 15px;' . n . ' width: 250px;' . n . ' text-align:left;' . n . ' padding:3px 3px 3px 110px;' . n . ' margin-top:0px;' . n . '}' . n . '#images ul.plain-list li .imageUpload{' . n . ' margin-top: 5px;' . n . ' padding:3px;' . n . ' width: 275px;' . n . ' border-width: 1px;' . n . ' border-color:#E0E0E0;' . n . ' border-style:solid;' . n . '}' . n . '</style>'; echo n . '<script type="text/javascript">' . n . ' <!--' . n . ' fieldNum = ' . $startFieldNum . ';' . n . ' function addCustomField(index){' . n . ' //$("custom_fields").innerHTML = $("custom_fields").innerHTML + getCustomField(fieldNum);' . n . ' $("custom_fields").appendChild(getCustomField(fieldNum))' . n . ' fieldNum = fieldNum+1;' . n . ' }' . n . ' function deleteCustomField(index){' . n . ' if(confirm("Are you sure?")){' . n . ' $("custom_field_"+index).style.display = "none";' . n . ' $("custom_fields["+index+"][value]").value = "delete";' . n . ' $("custom_fields["+index+"][label]").value = "delete";' . n . ' }else{ return false; }' . n . ' }' . n . ' function getCustomField(index){' . n . ' var span = document.createElement("span");' . n . ' span.setAttribute("id","custom_field_"+index);' . n . ' var label = document.createElement("label");' . n . ' label.setAttribute("for","custom_fields["+index+"][label]");' . n . ' labelText = document.createTextNode("Label ");' . n . ' var input = document.createElement("input");' . n . ' input.setAttribute("id","custom_fields["+index+"][label]");' . n . ' input.setAttribute("name","custom_fields["+index+"][label]");' . n . ' var labelValue = document.createElement("label");' . n . ' labelValue.setAttribute("for","custom_fields["+index+"][value]");' . n . ' labelTextValue = document.createTextNode(" Value ");' . n . ' var inputValue = document.createElement("input");' . n . ' inputValue.setAttribute("id","custom_fields["+index+"][value]");' . n . ' inputValue.setAttribute("name","custom_fields["+index+"][value]");' . n . ' var deleteLink = document.createElement("a");' . n . ' deleteLink.setAttribute("href","javascript:void(0)");' . n . ' deleteLink.setAttribute("onclick","deleteCustomField("+index+");");' . n . ' deleteLink.setAttribute("style","font-size: 11px;");' . n . ' deleteText = document.createTextNode("Delete");' . n . ' label.appendChild(labelText);' . n . ' span.appendChild(label);' . n . ' span.appendChild(input);' . n . ' labelValue.appendChild(labelTextValue);' . n . ' span.appendChild(labelValue);' . n . ' span.appendChild(inputValue);' . n . ' deleteLink.appendChild(deleteText);' . n . ' span.appendChild(deleteLink);' . n . ' span.appendChild(document.createElement("br"));' . n . ' span.appendChild(document.createElement("br"));' . n . ' return span;' . n . ' }' . n . '//-->' . n . '</script>'; echo n . n . '<form name="product" method="post" action="index.php" enctype="multipart/form-data">'; echo '<input type="hidden" name="textile_body" value="1"/>'; echo '<input type="hidden" name="textile_excerpt" value="1"/>'; echo '<input type="hidden" name="Section" value="store"/>'; echo hInput('ID', $ID) . eInput('product') . sInput($step) . '<input type="hidden" name="view" />' . startTable('edit') . '<tr>' . n; //if ($view == 'text') //{ //-- markup help -------------- echo '<td id="article-main">'; echo "<h4 class='productHeading'>Product name</h4>"; echo '<p><input type="text" id="title" name="Title" value="' . cleanfInput($Title) . '" class="edit" size="40" tabindex="1" />'; if (($Status == 4 or $Status == 5) and $step != 'create') { include_once txpath . '/publish/taghandlers.php'; echo sp . sp . '<a href="' . permlinkurl_id($ID) . '">' . gTxt('view') . '</a>'; } echo '</p>'; echo "<h4 class='productHeading'><span>Textile & HTML allowed</span> Describe the product</h4>"; echo n . graf('<textarea id="body" name="Body" cols="55" rows="31" tabindex="2" style="height: 180px;">' . htmlspecialchars($Body) . '</textarea>'); //PRODUCT OPTIONS //================================ //echo '<div id="productOptions" style="border-width:1px; border-color:#E1E1E1; border-style:solid; padding:5px; background-color:#F3F4F4;">'; //PRODUCT & PRICE //================================ echo n . n . '<fieldset class="product-options-sub" style="background-color:white">' . '<div style="float:left; margin-right: 40px;">' . n . graf('<label for="price">Price</label> ' . br . n . '<input style="width: 50px;" type="text" name="custom_1" id="price" value="' . cleanfInput($custom_1) . '"/> <em>usd</em>') . n . '</div>' . n . graf('<label for="weight">Weight</label>' . br . n . '<input type="text" style="width: 50px;" name="custom_2" id="weight" value="' . cleanfInput($custom_2) . '"/> <em>lbs</em>'); echo n . "</fieldset>"; //CUSTOM FIELDS //================================ if (isset($ID)) { $custom_fields = get_custom_fields($ID); } else { $custom_fields = ''; } echo n . n . '<fieldset class="product-options-sub" style="background-color:white" id="custom_fields">' . n . '<legend>Custom Fields <span>[<a href="javascript:addCustomField(0);">Add a new custom field</a>]</span></legend>'; echo $custom_fields; echo n . "</fieldset>"; //CATEGORIES //================================ //if(!is_callable("rss_admin_catlist")){ echo n . n . '<fieldset class="product-options-sub" style="background-color:white">' . n . '<legend>Categorize <small>[<a href="?event=category">edit</a>]</small></legend>' . '<div style="float:left; margin-right: 10px;">' . n . graf('<label for="category-1">' . gTxt('category1') . '</label> ' . n . '<select name="Category1" id="category-1"><option></option>' . n . product_cateogry_option_list($Category1) . n . '</select>') . n . '</div>' . n . graf('<label for="category-2">' . gTxt('category2') . '</label>' . n . '<select name="Category2" id="category-2"><option></option>' . n . product_cateogry_option_list($Category2) . n . '</select>'); echo n . "</fieldset>"; //} //VENDORS //================================ echo n . n . '<fieldset class="product-options-sub" style="background-color:white">' . n . '<legend>Vendor <em>The creator or manufacturer of the product. </em></legend>' . '<div style="float:left; width:50%;">' . n . '<label for="vendor">Select existing vendor </label> ' . br . n . build_list("vendor", "txp_category", "name", "title", $custom_5, "parent='Vendors'", true) . n . '</div>' . n . graf('<label for="new_vendor_name">Or create a new vendor</label>' . br . n . '<input id="new_vendor_name" type="text" name="new_vendor_name"/>'); echo n . "</fieldset>"; //INVENTORY //================================ echo n . '<fieldset class="product-options-sub" style="background-color:white">' . n . '<legend>Inventory</legend>'; echo n . '<label for="sku">SKU <em>Stock keeping unit</em></label>' . n . br . '<input type="text" name="custom_3" id="sku" value="' . $custom_3 . '"/>' . br . br; if (isset($custom_4) && !empty($custom_4)) { $showLevel = true; $levelSelected = "selected = 'true'"; $levelStyle = 'display:block;'; } else { $showLevel = false; $levelSelected = ""; $levelStyle = 'display:none;'; } echo n . '<select name="trackOptions" id="trackOptions" onchange="if(this.value == \'doTrack\'){$(\'stockLevel\').style.display = \'block\';}else{$(\'stockLevel\').style.display = \'none\';}">' . n . n . '<option value="dontTrack">Don\'t track stock level</option>' . n . '<option value="doTrack" ' . $levelSelected . '>Keep track of stock level</option>' . n . '</select>' . br . br; echo n . '<div id="stockLevel" style="' . $levelStyle . '">' . n . '<label for="items_in_stock">Number of items in stock:</label>' . n . '<input type="text" name="custom_4" id="items_in_stock" style="width: 20px;" value="' . cleanfInput($custom_4) . '"/>' . n . '</div><!--/stockLevel-->'; echo n . "</fieldset>"; //IMAGES //================================ echo ' <script type="text/javascript"> <!-- function deleteImage(id){ if(confirm("Are you sure?")){ if(id == "1"){ $("image1").style.display = "none"; $("imageField1").value = "delete"; }else if(id == "2"){ $("image2").style.display = "none"; $("imageField2").value = "delete"; }else if(id == "3"){ $("image3").style.display = "none"; $("imageField3").value = "delete"; }else if(id == "4"){ $("image4").style.display = "none"; $("imageField4").value = "delete"; } document.forms["product"].submit(); } } function updateImage(id){ if(id == "1"){ new Effect.SlideDown($("imageUpload1")); $("updateImage1").value = $("imageField1").value; $("imageField1").value = "delete"; }else if(id == "2"){ new Effect.SlideDown($("imageUpload2")); $("updateImage2").value = $("imageField2").value; $("imageField2").value = "delete"; }else if(id == "3"){ new Effect.SlideDown($("imageUpload3")); $("updateImage3").value = $("imageField3").value; $("imageField3").value = "delete"; }else if(id == "4"){ new Effect.SlideDown($("imageUpload4")); $("updateImage4").value = $("imageField4").value; $("imageField4").value = "delete"; } } function cancelUpload(id){ if(id == "1"){ new Effect.SlideUp($("imageUpload1")); $("imageField1").value = $("updateImage1").value; }else if(id == "2"){ new Effect.SlideUp($("imageUpload2")); $("imageField2").value = $("updateImage2").value; }else if(id == "3"){ new Effect.SlideUp($("imageUpload3")); $("imageField3").value = $("updateImage3").value; }else if(id == "4"){ new Effect.SlideUp($("imageUpload4")); $("imageField4").value = $("updateImage4").value; } } --> </script> '; if ($step == "create") { echo n . '<fieldset class="product-options-sub" style="background-color:white">' . n . '<legend>Product images</legend>'; echo n . '<em>Allowed file types are JPG, GIF & PNG</em>'; echo n . '<input type="file" name="uploadFile"/>' . n; echo n . "</fieldset>"; } else { if ($step == "edit" || $step == "save" || empty($step)) { echo n . '<fieldset class="product-options-sub" id="images" style="background-color:white">' . n . '<legend>Product images</legend>'; echo n . '<ul class="plain-list" id="image_list">'; if (isset($Image) && !empty($Image)) { echo n . '<li id="image1"> <img src="' . product_image_display($Image, "small") . '" alt="Product Image"/> <div class="imageEdit" style="display:block;"> <a href="javascript:deleteImage(\'1\')">Delete Image</a> | <a href="javascript:updateImage(\'1\')">Update Image</a> <div class="imageUpload" id="imageUpload1" style="display:none;"> Browse for new image: <input type="file" name="uploadFile1"/> and <input type="submit" value="Save"/> <a href="javascript:cancelUpload(\'1\')">Cancel</a> <input type="hidden" name="updateImage1" id="updateImage1" value="0"/> </div> <input id="imageField1" type="hidden" name="Image" value="' . $Image . '"/> </div> </li>'; } if (isset($custom_6) && !empty($custom_6)) { echo n . '<li id="image2"><img src="' . product_image_display($custom_6, "small") . '" alt="Product Image"/> <div class="imageEdit" id="image1Control" style="display:block;"> <a href="javascript:deleteImage(\'2\')">Delete Image</a> | <a href="javascript:updateImage(\'2\')">Update Image</a> <div class="imageUpload" id="imageUpload2" style="display:none;"> Browse for new image: <input type="file" name="uploadFile2"/> and <input type="submit" value="Save"/> <a href="javascript:cancelUpload(\'2\')">Cancel</a> <input type="hidden" name="updateImage2" id="updateImage2" value="0"/> </div> </div><input id="imageField2" type="hidden" name="custom_6" value="' . $custom_6 . '"/></li>'; } if (isset($custom_7) && !empty($custom_7)) { echo n . '<li id="image3"><img src="' . product_image_display($custom_7, "small") . '" alt="Product Image"/> <div class="imageEdit" id="image1Control" style="display:block;"> <a href="javascript:deleteImage(\'3\')">Delete Image</a> | <a href="javascript:updateImage(\'3\')">Update Image</a> <div class="imageUpload" id="imageUpload3" style="display:none;"> Browse for new image: <input type="file" name="uploadFile3"/> and <input type="submit" value="Save"/> <a href="javascript:cancelUpload(\'3\')">Cancel</a> <input type="hidden" name="updateImage3" id="updateImage3" value="0"/> </div> </div> <input id="imageField3" type="hidden" name="custom_7" value="' . $custom_7 . '"/></li>'; } if (isset($custom_8) && !empty($custom_8)) { echo n . '<li id="image4"><img src="' . product_image_display($custom_8, "small") . '" alt="Product Image"/> <div class="imageEdit" id="image1Control" style="display:block;"> <a href="javascript:deleteImage(\'4\')">Delete Image</a> | <a href="javascript:updateImage(\'4\')">Update Image</a> <div class="imageUpload" id="imageUpload4" style="display:none;"> Browse for new image: <input type="file" name="uploadFile4"/> and <input type="submit" value="Save"/> <a href="javascript:cancelUpload(\'4\')">Cancel</a> <input type="hidden" name="updateImage4" id="updateImage4" value="0"/> </div> </div><input id="imageField4" type="hidden" name="custom_8" value="' . $custom_8 . '"/></li>'; } echo n . "</ul><br style='clear:both;'/>"; echo n . '<a href="javascript:void(0);" onclick="document.getElementById(\'otherImageUpload\').style.display = \'block\'">Add an image</a>' . n; echo n . '<div id="otherImageUpload" style="display:none; margin-top: 10px;">'; echo n . '<em>Allowed file types are JPG, GIF & PNG</em>'; echo n . '<input type="file" name="uploadFile"/> and <input type="submit" value="upload"/>' . n; echo n . '</div>'; echo n . "</fieldset>"; echo n . '<div id="data"></div>'; } } //echo '</div>'; // end productOptions // end left content area echo hInput('from_view', $view), '</td>'; echo '<td id="article-col-2" style="padding-top: 75px;">'; //start article-col-2 //PRODUCT STATUS //================================ echo n . n . '<fieldset id="write-status">' . n . '<legend>' . gTxt('status') . '</legend>' . n . status_radio_product($Status) . n . '</fieldset>'; //-- comments stuff -------------- if ($step == "create") { //Avoiding invite disappear when previewing $AnnotateInvite = !empty($store_out['AnnotateInvite']) ? $store_out['AnnotateInvite'] : $comments_default_invite; if ($comments_on_default == 1) { $Annotate = 1; } } if ($use_comments == 1) { echo n . n . '<fieldset id="write-comments">' . n . '<legend>Allow product reviews</legend>'; $comments_expired = false; if ($step != 'create' && $comments_disabled_after) { $lifespan = $comments_disabled_after * 86400; $time_since = time() - $sPosted; if ($time_since > $lifespan) { $comments_expired = true; } } if ($comments_expired) { echo n . n . graf(gTxt('expired')); } else { echo n . n . graf(onoffRadio('Annotate', $Annotate)) . n . n . graf('<label for="comment-invite">' . gTxt('comment_invitation') . '</label>' . br . fInput('text', 'AnnotateInvite', $AnnotateInvite, 'edit', '', '', '', '', 'comment-invite')); } echo n . n . '</fieldset>'; } /*if(is_callable("rss_admin_catlist")){ echo "<fieldset id='write-sort'></fieldset>"; echo rss_admin_catlist(); }*/ //wilshireone multipule categories //-- publish button -------------- echo has_privs('article.publish') ? fInput('submit', 'publish', gTxt('save'), "publish", '', '', '', 4) : fInput('submit', 'publish', gTxt('save'), "publish", '', '', '', 4); echo '</td> <!--/article-col-2-->'; //end article-col-2 echo '</td></tr></table></form>'; }
function mail_comment($message, $cname, $cemail, $cweb, $parentid, $discussid) { global $sitename; $article = safe_row("Section, Posted, ID, url_title, AuthorID, Title", "textpattern", "ID = '{$parentid}'"); extract($article); extract(safe_row("RealName, email", "txp_users", "name = '" . doSlash($AuthorID) . "'")); $out = gTxt('greeting') . " {$RealName},\r\n\r\n"; $out .= str_replace('{title}', $Title, gTxt('comment_recorded')) . "\r\n"; $out .= permlinkurl_id($parentid) . "\r\n"; if (has_privs('discuss', $AuthorID)) { $out .= hu . 'textpattern/?event=discuss&step=discuss_edit&discussid=' . $discussid . "\r\n"; } $out .= "\r\n"; $out .= gTxt('comment_name') . ": {$cname}\r\n"; $out .= gTxt('comment_email') . ": {$cemail}\r\n"; $out .= gTxt('comment_web') . ": {$cweb}\r\n"; $out .= gTxt('comment_comment') . ": {$message}"; $subject = strtr(gTxt('comment_received'), array('{site}' => $sitename, '{title}' => $Title)); $success = txpMail($email, $subject, $out, $cemail); }
function article_partial_article_view($rs) { extract($rs); if ($Status != STATUS_LIVE and $Status != STATUS_STICKY) { $url = '?txpreview=' . intval($ID) . '.' . time(); // article ID plus cachebuster } else { include_once txpath . '/publish/taghandlers.php'; $url = permlinkurl_id($ID); } return '<span id="article_partial_article_view"><a href="' . $url . '" class="article-view">' . gTxt('view') . '</a></span>'; }
function permlink($atts, $thing = NULL) { global $thisarticle; extract(lAtts(array('class' => '', 'id' => '', 'style' => '', 'title' => ''), $atts)); if (!$id) { assert_article(); } $url = $id ? permlinkurl_id($id) : permlinkurl($thisarticle); if ($url) { if ($thing === NULL) { return $url; } return tag(parse($thing), 'a', ' rel="bookmark" href="' . $url . '"' . ($title ? ' title="' . $title . '"' : '') . ($style ? ' style="' . $style . '"' : '') . ($class ? ' class="' . $class . '"' : '')); } }
public function __construct($stars, $star_width) { ob_start(); $this->dbTable = 'jmd_rate'; $this->parentid = $GLOBALS['thisarticle']['thisid']; $this->uri = permlinkurl_id($this->parentid); $this->ip = $_SERVER['REMOTE_ADDR']; $this->maxValue = $stars; $this->starWidth = $star_width; if (gps('rating')) { $this->setRating(); } }
/** * Formats comments invite link. * * @param string $AnnotateInvite * @param string $Section * @param int $ID * @return string * @deprecated in 4.0.0 */ function formatCommentsInvite($AnnotateInvite, $Section, $ID) { trigger_error(gTxt('deprecated_tag'), E_USER_NOTICE); global $comments_mode; $dc = safe_count('txp_discuss', "parentid = " . intval($ID) . " AND visible = " . VISIBLE); $ccount = $dc ? '[' . $dc . ']' : ''; if (!$comments_mode) { return '<a href="' . permlinkurl_id($ID) . '/#' . gTxt('comment') . '">' . $AnnotateInvite . '</a>' . $ccount; } else { return "<a href=\"" . hu . "?parentid={$ID}\" onclick=\"window.open(this.href, 'popupwindow', 'width=500,height=500,scrollbars,resizable,status'); return false;\">" . $AnnotateInvite . '</a> ' . $ccount; } }