function welcome_render_page_late($args)
{
    global $page_has_object;
    if (!$args['edit'] || $page_has_object) {
        return false;
    }
    // we only display the information when there are no other pages in the
    // content directory except the current one
    load_modules('glue');
    $pns = pagenames(array());
    $pns = $pns['#data'];
    if (1 < count($pns)) {
        return false;
    }
    html_add_css(base_url() . 'modules/welcome/welcome-edit.css');
    html_add_js(base_url() . 'modules/welcome/welcome.js');
    body_append('<div id="welcome-msg">' . nl());
    body_append(tab() . '<span id="welcome-first"><img style="float:left; margin:5px 10px 0 5px" src="' . base_url() . 'modules/welcome/gun32.gif">Welcome to HOTGLUE!</span><br>' . nl());
    body_append(tab() . 'Your Content Manipulation System is ready to go!' . nl());
    body_append(tab() . '<p>A short intro before you start:</p>' . nl());
    body_append(tab() . '<span id="cont"><span id="text"><b>1.</b> Right now you are in <u>editing mode</u>. You can use single and double click to access the menus - they will appear next to the mouse pointer.</span>' . nl());
    body_append(tab() . '<span id="text"><b>2.</b> Click on the canvas (white background of the page) to open a menu which will let you create new objects, upload files and embed YouTube and Vimeo videos! Once you made an object click on it to activate its contextual menu.</span>' . nl());
    body_append(tab() . '<span id="text"><b>3.</b> Double-click on the canvas will give you a menu of options to change preferences, show a grid, make new pages, set background picture and more!</span>' . nl());
    body_append(tab() . '<span id="text"><b>4.</b> Remove "' . (SHORT_URLS ? '' : '?') . 'edit" from the address of the page (the URL) to see the "view-only" version. That\'s how your page will look to everyone else!</span>' . nl());
    body_append(tab() . '<span id="text"><b>5.</b> To get back to editing mode add "' . (SHORT_URLS ? '' : '?') . 'edit" to the URL of the page.<br>(for example: ' . base_url() . '<b>' . (SHORT_URLS ? '' : '?') . 'edit</b>)</span></span>' . nl());
    body_append(tab() . '<p>We recommend you to use <a href="http://firefox.com" target="_blank">Mozilla Firefox</a> browser when editing in HOTGLUE. Firefox is a very reliable and modern web-browser, it is our favorite!' . nl());
    body_append(tab() . '<p>You can find more information on how to work with HOTGLUE on our <a href="http://hotglue.me" target="_blank">web-site</a>. Make sure to check out "<a href="http://hotglue.me/what" target="_blank">What is HOTGLUE?</a>" and "<a href="http://hotglue.me/how" target="_blank">How to HOTGLUE?</a>" pages!' . nl());
    body_append(tab() . '<p>Enjoy! <span id="welcome-light">[click this message to make it go away]</span></p>' . nl());
    body_append('</div>' . nl());
    return true;
}
Example #2
0
/**
 *	convert an associative array to a javascript block
 *
 *	@param array $container container array
 *	@return string
 */
function array_to_js($container)
{
    $ret = '<script type="text/javascript">' . nl();
    // sort container by keys
    ksort($container);
    $exists = array();
    foreach ($container as $key => $val) {
        // make sure the keys exist
        $objs = expl('.', $key);
        for ($i = 0; $i < count($objs) - 1; $i++) {
            $obj = implode('.', array_slice($objs, 0, $i + 1));
            if (!in_array($obj, $exists)) {
                if ($i == 0) {
                    $ret .= tab() . 'var ' . $obj . ' = ' . $obj . ' || {};' . nl();
                } else {
                    $ret .= tab() . $obj . ' = ' . $obj . ' || {};' . nl();
                }
                $exists[] = $obj;
            }
        }
        $ret .= tab() . '' . $key . ' = ' . json_encode($val) . ';' . nl();
    }
    $ret .= '</script>' . nl();
    return $ret;
}
Example #3
0
/**
 *	log a message to file
 *
 *	@param string $level can be error, warn, info or debug
 *	@param string $msg message
 *	@return bool true if successful, false if not
 */
function log_msg($level, $msg)
{
    global $logfile;
    global $loglevels;
    global $request_id;
    // open logfile
    if ($logfile === false) {
        $m = umask(0111);
        // having two processes appending to the same file should
        // work fine (at least on Linux)
        $logfile = @fopen(LOG_FILE, 'ab');
        umask($m);
    }
    if ($logfile === false) {
        return false;
    }
    foreach ($loglevels as $ll) {
        if ($ll == $level) {
            fwrite($logfile, date('Y-m-d H:i:s') . tab() . pad($_SERVER['REMOTE_ADDR'], 15) . tab() . sprintf('%05u', $request_id) . tab() . $level . tab() . $msg . nl());
            fflush($logfile);
            break;
        }
        if ($ll == LOG_LEVEL) {
            break;
        }
    }
    return true;
}
function welcome_render_page_late($args)
{
    global $page_has_object;
    if (!$args['edit'] || $page_has_object) {
        return false;
    }
    // we only display the information when there are no other pages in the
    // content directory except the current one
    load_modules('glue');
    $pns = pagenames(array());
    $pns = $pns['#data'];
    if (1 < count($pns)) {
        return false;
    }
    html_add_css(base_url() . 'modules/welcome/welcome-edit.css');
    html_add_js(base_url() . 'modules/welcome/welcome.js');
    body_append('<div id="welcome-msg">' . nl());
    body_append(tab() . '<span id="welcome-first">Welcome to HOTGLUE!</span><br>' . nl());
    body_append(tab() . 'Your Content Manipulation System is ready to go!' . nl());
    body_append(tab() . '<p>A short intro before you start:<br>' . nl());
    body_append(tab() . '&#164; To get back to editing mode in the future, add "' . (SHORT_URLS ? '' : '?') . 'edit" to the address in the address bar (i.e.: ' . base_url() . '<b>' . (SHORT_URLS ? '' : '?') . 'edit</b>)<br>' . nl());
    body_append(tab() . '&#164; In editing mode, you can use single and double click to access the menus.<br>' . nl());
    body_append(tab() . '&#164; Click the page\'s background once to open a menu that lets you create new objects, upload files and embed videos (YouTube and Vimeo).<br>' . nl());
    body_append(tab() . '&#164; Double-click to open a menu that allows you to change preferences, show a grid, make new pages and more.<br>' . nl());
    body_append(tab() . '&#164; Remove "' . (SHORT_URLS ? '' : '?') . 'edit" from the address in the address bar to go to the viewing-only mode of this page.</p>' . nl());
    body_append(tab() . '<p>You can find more ideas on how to use HOTGLUE at the <a href="http://hotglue.me/how_basic" target="_blank">"How-to" section of our website</a>!' . nl());
    body_append(tab() . '<p>Enjoy!<br>' . nl());
    body_append(tab() . '<span id="welcome-light">[This message goes away when you click it]</span></p>' . nl());
    body_append('</div>' . nl());
    return true;
}
/**
 *	show a site where authenticated users can create new pages
 */
function controller_create_page($args)
{
    page_canonical($args[0][0]);
    $page = $args[0][0];
    if (page_exists($page)) {
        log_msg('debug', 'controller_create_page: page ' . quot($page) . 'already exists, invoking controller_edit');
        controller_edit($args);
        return;
    }
    load_modules('glue');
    default_html(true);
    html_add_css(base_url() . 'css/hotglue_error.css');
    if (USE_MIN_FILES) {
        html_add_js(base_url() . 'js/create_page.min.js');
    } else {
        html_add_js(base_url() . 'js/create_page.js');
    }
    html_add_js_var('$.glue.page', $page);
    html_add_js_var('$.glue.q', SHORT_URLS ? '' : '?');
    $bdy =& body();
    elem_attr($bdy, 'id', 'create_page');
    body_append(tab(1) . '<div id="paper">' . nl());
    body_append(tab(2) . '<div id="wrapper">' . nl());
    body_append(tab(3) . '<div id="content">' . nl());
    body_append(tab(4) . '<div id="left-nav">' . nl());
    body_append(tab(5) . '<img src="' . htmlspecialchars(base_url(), ENT_COMPAT, 'UTF-8') . 'img/hotglue-logo.png" alt="logo">' . nl());
    body_append(tab(4) . '</div>' . nl());
    body_append(tab(4) . '<div id="main">' . nl());
    body_append(tab(5) . '<h1 id="error-title">Page does not exist yet!</h1>' . nl());
    body_append(tab(5) . '<p>' . nl());
    body_append(tab(6) . 'This page does not exist yet!<br>' . nl());
    body_append(tab(6) . 'Would you like to create the page?' . nl());
    body_append(tab(5) . '</p>' . nl());
    body_append(tab(5) . '<form><input id="create_page_btn" type="button" value="Create it!"></form>' . nl());
    body_append(tab(4) . '</div>' . nl());
    body_append(tab(3) . '</div>' . nl());
    body_append(tab(2) . '</div>' . nl());
    body_append(tab(2) . '<div style="position: absolute; left: 200px; top: -10px; z-index: 2;">' . nl());
    body_append(tab(3) . '<img src="' . htmlspecialchars(base_url(), ENT_COMPAT, 'UTF-8') . 'img/hotglue-404.png" alt="404">' . nl());
    body_append(tab(2) . '</div>' . nl());
    body_append(tab(1) . '</div>' . nl());
    echo html_finalize();
}
Example #6
0
function listeElementNoeudCourant($noeud, $numDossier, $iter = 0)
{
    $iter++;
    while ($noeud) {
        switch ($noeud->node_name()) {
            case "dossier":
                // Ajout d'un dossier
                $nom = $noeud->get_attribute('nom');
                echo tab($iter) . $iter . "-" . "dossier " . $nom . "\n";
                $dossierParent = new Dossier($numDossier);
                $dossier = new Dossier();
                $dossier->nom = $nom;
                $numNouveauDossier = $dossierParent->ajouterDossier($dossier);
                $fils = $noeud->first_child();
                listeElementNoeudCourant($fils, $numNouveauDossier, $iter);
                break;
            case "lien":
                // On récupère les variables
                $langue = $noeud->get_attribute('langue');
                $url = $noeud->get_attribute('url');
                $nom = $noeud->get_attribute('nom');
                // On crée les objets Dossier et Url
                $dossierParent = new Dossier($numDossier);
                $lien = new Url();
                // On définit les attributs de l'Url
                $lien->langue = $langue;
                $lien->url = $url;
                $lien->nom = $nom;
                // On ajoute le lien
                $dossierParent->ajouterLien($lien, 1);
                echo tab($iter) . $iter . "-" . "lien [" . $langue . '] ' . $url . ' ' . $nom . "\n";
                break;
            case "livre":
                echo tab($iter) . "livre\n";
                break;
        }
        $noeud = $noeud->next_sibling();
    }
}
Example #7
0
/**
 *	turn the page into a html string
 *
 *	@param bool &$cache is output cachable (will only modified if $cache is 
 *	true before)
 *	@return string html
 */
function html_finalize(&$cache = false)
{
    global $html;
    // return html5
    $ret = '<!DOCTYPE html>' . nl();
    $ret .= '<html';
    if (@is_array($html['header']['style'])) {
        $ret .= ' style="';
        ksort($html['header']['style']);
        foreach ($html['header']['style'] as $key => $val) {
            $ret .= htmlspecialchars($key, ENT_COMPAT, 'UTF-8') . ': ' . htmlspecialchars($val, ENT_COMPAT, 'UTF-8') . '; ';
        }
        // strip the last space
        $ret = substr($ret, 0, -1);
        $ret .= '"';
    }
    $ret .= '>' . nl();
    $ret .= '<head>' . nl();
    $ret .= '<title>' . htmlspecialchars($html['header']['title'], ENT_NOQUOTES, 'UTF-8') . '</title>' . nl();
    $ret .= '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' . nl();
    if (@is_array($html['header']['alternate'])) {
        foreach ($html['header']['alternate'] as $e) {
            $ret .= '<link rel="alternate" type="' . htmlspecialchars($e['type'], ENT_COMPAT, 'UTF-8') . '" href="' . htmlspecialchars($e['url'], ENT_COMPAT, 'UTF-8') . '" title="' . htmlspecialchars($e['title'], ENT_COMPAT, 'UTF-8') . '">' . nl();
        }
    }
    if (!empty($html['header']['favicon'])) {
        $ret .= '<link rel="shortcut icon" href="' . htmlspecialchars($html['header']['favicon'], ENT_COMPAT, 'UTF-8') . '">' . nl();
    }
    if (@is_array($html['header']['css'])) {
        _array_sort_by_prio($html['header']['css']);
        // removed the removal of duplicates here as two different media might point to the same url
        //array_unique_element($html['header']['css'], 'url');
        foreach ($html['header']['css'] as $e) {
            $ret .= '<link rel="stylesheet" type="text/css" href="' . htmlspecialchars($e['url'], ENT_COMPAT, 'UTF-8') . '"';
            if (!empty($e['media'])) {
                $ret .= ' media="' . htmlspecialchars($e['media'], ENT_COMPAT, 'UTF-8') . '"';
            }
            $ret .= '>' . nl();
        }
    }
    if (@is_array($html['header']['css_inline'])) {
        _array_sort_by_prio($html['header']['css_inline']);
        if (0 < count($html['header']['css_inline'])) {
            $ret .= '<style type="text/css">' . nl();
        }
        foreach ($html['header']['css_inline'] as $c) {
            $rule = $c['rule'];
            // if the rule ends with a newline character, remove it
            if (substr($rule, -1) == "\n") {
                $rule = substr($rule, 0, -1);
            }
            // move rule in by one tab
            $rule = str_replace("\n", "\n\t", $rule);
            $ret .= tab() . $rule . nl();
        }
        if (0 < count($html['header']['css_inline'])) {
            $ret .= '</style>' . nl();
        }
    }
    if (@is_array($html['header']['js'])) {
        _array_sort_by_prio($html['header']['js']);
        array_unique_element($html['header']['js'], 'url');
        foreach ($html['header']['js'] as $e) {
            $ret .= '<script type="text/javascript" src="' . htmlspecialchars($e['url'], ENT_COMPAT, 'UTF-8') . '"></script>' . nl();
        }
    }
    if (@is_array($html['header']['js_var'])) {
        $ret .= array_to_js($html['header']['js_var']);
    }
    if (@is_array($html['header']['js_inline'])) {
        _array_sort_by_prio($html['header']['js_inline']);
        foreach ($html['header']['js_inline'] as $c) {
            if (!empty($c['reason'])) {
                $ret .= '<!-- ' . $c['reason'] . ' -->' . nl();
                $ret .= '<script type="text/javascript">' . nl();
                // if the code ends with a newline character, remove it
                if (substr($c['code'], -1) == "\n") {
                    $c['code'] = substr($c['code'], 0, -1);
                }
                // move code in by one tab
                $c = str_replace("\n", "\n\t", $c);
                $ret .= tab() . $c['code'] . nl();
                $ret .= '</script>' . nl();
            }
        }
    }
    $ret .= '</head>' . nl();
    $ret .= elem_finalize($html['body']);
    $ret .= '</html>';
    // pass caching information up if requested
    if ($cache) {
        if (!$html['cache']) {
            $cache = false;
        }
    }
    return $ret;
}
ini_set('error_append_string', null);
if (!isset($_SESSION["uid"])) {
    header("location:miniadm.logon.php");
}
include_once dirname(__FILE__) . "/ressources/class.templates.inc";
include_once dirname(__FILE__) . "/ressources/class.users.menus.inc";
include_once dirname(__FILE__) . "/ressources/class.miniadm.inc";
include_once dirname(__FILE__) . "/ressources/class.mysql.squid.builder.php";
include_once dirname(__FILE__) . "/ressources/class.user.inc";
include_once dirname(__FILE__) . "/ressources/class.calendar.inc";
if (!$_SESSION["AsWebStatisticsAdministrator"]) {
    header("location:miniadm.index.php");
    die;
}
if (isset($_GET["tab"])) {
    tab();
    exit;
}
if (isset($_GET["flow"])) {
    section_flow();
    exit;
}
if (isset($_GET["flow1"])) {
    section_flow_graph1();
    exit;
}
if (isset($_GET["topuser"])) {
    section_topuser();
    exit;
}
if (isset($_GET["topuser1"])) {
Example #9
0
/**
 * Renders list of view modes.
 *
 * The rendered widget can be customised via the 'article_ui > view'
 * pluggable UI callback event.
 *
 * @param  array $rs Article data
 * @return string HTML
 */
function article_partial_view_modes($rs)
{
    global $step, $view, $use_textile;
    if ($step == "create") {
        $hasfilter = $use_textile !== LEAVE_TEXT_UNTOUCHED;
    } else {
        $hasfilter = $rs['textile_body'] !== LEAVE_TEXT_UNTOUCHED || $rs['textile_excerpt'] !== LEAVE_TEXT_UNTOUCHED;
    }
    if ($hasfilter) {
        $out = n . tag(tab('text', $view) . tab('html', $view) . tab('preview', $view), 'ul');
    } else {
        $out = '&#160;';
    }
    $out = pluggable_ui('article_ui', 'view', $out, $rs);
    return n . tag($out . n, 'div', array('id' => 'view_modes'));
}
Example #10
0
 /**
  * Process and display cart
  */
 public function display_cart()
 {
     $config = $this->config;
     $errorMessage = null;
     // Simplify some config variables
     $checkout = $config['checkoutPath'];
     $priceFormat = $config['priceFormat'];
     $id = $config['item']['id'];
     $name = $config['item']['name'];
     $price = $config['item']['price'];
     $qty = $config['item']['qty'];
     $dmoney = $config['item']['dmoney'];
     $url = $config['item']['url'];
     $add = $config['item']['add'];
     $vendor = $config['item']['vendor'];
     $vendorName = $config['item']['vendorname'];
     $needPackingPriceName = $config['item']['needPackingPrice'];
     $startingPriceName = $config['item']['startingprice'];
     // Use config values as literal indices for incoming POST values
     // Values are the HTML name attributes set in config.json
     if (isset($_POST[$id])) {
         $id = $_POST[$id];
         $name = $_POST[$name];
         $price = $_POST[$price];
         $qty = $_POST[$qty];
         $dmoney = $_POST[$dmoney];
         $url = $_POST[$url];
         $vendor = $_POST[$vendor];
         $vendorName = $_POST[$vendorName];
         //$promo = $_POST[$promo];
         $needPackingPrice = $_POST[$needPackingPriceName];
         $startingprice = $_POST[$startingPriceName];
         // Optional CSRF protection, see: http://conceptlogic.com/jcart/security.php
         $jcartToken = $_POST['jcartToken'];
     }
     // Only generate unique token once per session
     if (!isset($_SESSION['jcartToken'])) {
         $_SESSION['jcartToken'] = md5(session_id() . time() . $_SERVER['HTTP_USER_AGENT']);
     }
     // If enabled, check submitted token against session token for POST requests
     if ($config['csrfToken'] === 'true' && $_POST && $jcartToken != $_SESSION['jcartToken']) {
         $errorMessage = 'Invalid token!' . $jcartToken . ' / ' . $_SESSION['jcartToken'];
     }
     // Sanitize values for output in the browser
     $id = filter_var($id, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW);
     $name = filter_var($name, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW);
     $url = filter_var($url, FILTER_SANITIZE_URL);
     // Round the quantity if necessary
     if ($config['decimalPlaces'] === true) {
         $qty = round($qty, $config['decimalPlaces']);
     }
     // Add an item
     if (isset($_POST[$add])) {
         $this->add_shop($vendor, $vendorName, $this->packingPrice, $startingprice);
         $itemAdded = $this->add_item($id, $name, $price, $qty, $dmoney, $url, $vendor, $this->packingPrice, '', $needPackingPrice);
         // If not true the add item function returns the error type
         if ($itemAdded !== true) {
             $errorType = $itemAdded;
             switch ($errorType) {
                 case 'qty':
                     $errorMessage = $config['text']['quantityError'];
                     break;
                 case 'price':
                     $errorMessage = $config['text']['priceError'];
                     break;
             }
         }
     }
     // Update a single item
     if (isset($_POST['jcartUpdate'])) {
         $itemUpdated = $this->update_item($_POST['itemId'], $_POST['itemQty']);
         if ($itemUpdated !== true) {
             $errorMessage = $config['text']['quantityError'];
         }
     }
     // Update all items in the cart
     if (isset($_POST['jcartUpdateCart']) || isset($_POST['jcartCheckout'])) {
         $cartUpdated = $this->update_cart();
         if ($cartUpdated !== true) {
             $errorMessage = $config['text']['quantityError'];
         }
     }
     // Remove an item
     /* After an item is removed, its id stays set in the query string,
        preventing the same item from being added back to the cart in
        subsequent POST requests.  As result, it's not enough to check for
        GET before deleting the item, must also check that this isn't a POST
        request. */
     if (isset($_GET['jcartRemove']) && !$_POST) {
         $this->remove_item($_GET['jcartRemove']);
     }
     // Empty the cart
     if (isset($_POST['jcartEmpty'])) {
         $this->empty_cart();
     }
     // Determine which text to use for the number of items in the cart
     $itemsText = $config['text']['multipleItems'];
     if ($this->itemCount == 1) {
         $itemsText = $config['text']['singleItem'];
     }
     // Determine if this is the checkout page
     /* First we check the request uri against the config checkout (set when
        the visitor first clicks checkout), then check for the hidden input
        sent with Ajax request (set when visitor has javascript enabled and
           updates an item quantity). */
     // $isCheckout = strpos(request_uri(), $checkout);
     // if ($isCheckout !== false || (isset($_REQUEST['jcartIsCheckout']) && $_REQUEST['jcartIsCheckout'] == 'true')) {
     //    $isCheckout = true;
     // }
     // else {
     //    $isCheckout = false;
     // }
     // Overwrite the form action to post to gateway.php instead of posting back to checkout page
     // if ($isCheckout === true) {
     //    // Sanititze config path
     //    $path = filter_var($config['jcartPath'], FILTER_SANITIZE_URL);
     //    // Trim trailing slash if necessary
     //    $path = rtrim($path, '/');
     //    $checkout = $path . '/gateway.php';
     // }
     // Default input type
     // Overridden if using button images in config.php
     $inputType = 'submit';
     // If this error is true the visitor updated the cart from the checkout page using an invalid price format
     // Passed as a session var since the checkout page uses a header redirect
     // If passed via GET the query string stays set even after subsequent POST requests
     if (isset($_SESSION['quantityError']) && $_SESSION['quantityError'] === true) {
         $errorMessage = $config['text']['quantityError'];
         unset($_SESSION['quantityError']);
     }
     // Set currency symbol based on config currency code
     $currencyCode = trim(strtoupper($config['currencyCode']));
     switch ($currencyCode) {
         case 'CNY':
             $currencySymbol = '¥';
             break;
         case 'EUR':
             $currencySymbol = '&#128;';
             break;
         case 'GBP':
             $currencySymbol = '&#163;';
             break;
         case 'JPY':
             $currencySymbol = '&#165;';
             break;
         case 'CHF':
             $currencySymbol = 'CHF&nbsp;';
             break;
         case 'SEK':
         case 'DKK':
         case 'NOK':
             $currencySymbol = 'Kr&nbsp;';
             break;
         case 'PLN':
             $currencySymbol = 'z&#322;&nbsp;';
             break;
         case 'HUF':
             $currencySymbol = 'Ft&nbsp;';
             break;
         case 'CZK':
             $currencySymbol = 'K&#269;&nbsp;';
             break;
         case 'ILS':
             $currencySymbol = '&#8362;&nbsp;';
             break;
         case 'TWD':
             $currencySymbol = 'NT$';
             break;
         case 'THB':
             $currencySymbol = '&#3647;';
             break;
         case 'MYR':
             $currencySymbol = 'RM';
             break;
         case 'PHP':
             $currencySymbol = 'Php';
             break;
         case 'BRL':
             $currencySymbol = 'R$';
             break;
         case 'USD':
         default:
             $currencySymbol = '$';
             break;
     }
     ////////////////////////////////////////////////////////////////////////
     // Output the cart
     // Return specified number of tabs to improve readability of HTML output
     function tab($n)
     {
         $tabs = null;
         while ($n > 0) {
             $tabs .= "\t";
             --$n;
         }
         return $tabs;
     }
     // If there's an error message wrap it in some HTML
     if ($errorMessage) {
         $errorMessage = "<p id='jcart-error'>{$errorMessage}</p>";
     }
     $this->totalIntegral = $this->integralCal->get_integral($this->subtotal, 'Dessert');
     // Display the cart header
     echo tab(1) . "{$errorMessage}\n";
     echo tab(1) . "<form method='post' action='{$checkout}'>\n";
     echo tab(2) . "<fieldset>\n";
     echo tab(3) . "<input type='hidden' name='jcartToken' value='{$_SESSION['jcartToken']}' />\n";
     echo tab(3) . "<input type='hidden' value='{$this->itemCount}' id='merchandiseCount' />\n";
     echo tab(3) . "<table border='1'>\n";
     echo tab(4) . "<thead>\n";
     echo tab(5) . "<tr>\n";
     echo tab(6) . "<th colspan='3'>\n";
     echo tab(7) . "&nbsp;<strong id='jcart-title'>{$config['text']['cartTitle']}</strong> ({$this->itemCount})\n";
     echo tab(6) . "</th>\n";
     echo tab(5) . "</tr>" . "\n";
     echo tab(4) . "</thead>\n";
     // Display the cart footer
     echo tab(4) . "<tfoot>\n";
     echo tab(5) . "<tr>\n";
     echo tab(6) . "<th colspan='2'>\n";
     echo tab(7) . "<span id='jcart-integral'>&nbsp;{$config['text']['totalIntegral']}: <strong>" . $this->totalIntegral . "</strong></span>\n";
     echo tab(6) . "</th>\n";
     echo tab(6) . "<th colspan='1'>\n";
     echo tab(7) . "<span id='jcart-subtotal'>{$config['text']['subtotal']}: <strong>{$currencySymbol}" . number_format($this->subtotal, $priceFormat['decimals'], $priceFormat['dec_point'], $priceFormat['thousands_sep']) . "</strong></span>\n";
     echo tab(6) . "</th>\n";
     echo tab(5) . "</tr>\n";
     if (!isset($_REQUEST['openid'])) {
         echo tab(5) . "<tr>\n";
         echo tab(6) . "<th colspan='3'>\n";
         echo tab(7) . "<span id='jcart-dmoney'>&nbsp;{$config['text']['totalDMoney']}: <strong>" . $this->totalDMoney . "(" . $this->totalDMoney / 10 . "元RMB)</strong></span>\n";
         echo tab(6) . "</th>\n";
         echo tab(5) . "</tr>\n";
     }
     echo tab(4) . "</tfoot>\n";
     echo tab(4) . "<tbody>\n";
     $schoolid = @$_REQUEST['schoolid'];
     // If any items in the cart
     if ($this->itemCount > 0) {
         foreach ($this->shops as $sid => $shop) {
             //set  shop title info
             $packingPrice = $shop['packingprice'];
             $startingPrice = $shop['startingprice'];
             $startingpriceless = $this->perShopSubtotal[$sid] - $startingPrice;
             if ($startingpriceless >= 0) {
                 $startingpriceless = '';
             } else {
                 $status = 'no';
                 $startingpriceless = '<span><input type="hidden" value=' . $status . ' id="formstatus"/>(缺少' . $currencySymbol . -$startingpriceless . ')</span>';
             }
             if (empty($shop['startingprice'])) {
                 $startingPrice = 0;
             }
             if (empty($shop['packingprice'])) {
                 $packingPrice = 0;
             }
             echo tab(7) . "<tr class='jcart-title'><td colspan='2'><span>{$shop['shopname']}<br/>起送价:{$startingPrice}<br/>打包费:{$packingPrice}元/份</span>\n                </td><td><span>小计:{$currencySymbol}{$this->perShopSubtotal[$sid]}</span></br>{$startingpriceless}</td></tr>\n";
             foreach ($this->get_contents() as $item) {
                 $item['packingMessage'] = $item['needPackingPrice'] == 0 ? "(无打包费)" : "";
                 if ($item['vendor'] == $sid) {
                     echo tab(5) . "<tr>\n";
                     echo tab(6) . "<td class='jcart-item-name'>\n";
                     echo tab(7) . "{$item['name']}" . "{$item['packingMessage']}" . "\n";
                     echo tab(7) . "<input name='jcartItemName[]' type='hidden' value='{$item['name']}' />\n";
                     echo tab(6) . "</td>\n";
                     echo tab(6) . "<td class='jcart-item-qty'>\n";
                     echo tab(7) . "<input name='jcartItemId[]' type='hidden' value='{$item['id']}' />\n";
                     echo tab(7) . "<input name='jcartOriQty[]' type='hidden' value='{$item['qty']}' />\n";
                     if ($this->inOrderPreview) {
                         echo tab(7) . "{$item['qty']} \n";
                     } else {
                         echo tab(7) . "<input id='jcartItemQty-{$item['id']}' name='jcartItemQty[]' size='2' type='text' value='{$item['qty']}' />\n";
                     }
                     echo tab(6) . "</td>\n";
                     echo tab(6) . "<td class='jcart-item-price'>\n";
                     echo tab(7) . "<span>{$currencySymbol}" . number_format($item['subtotal'], $priceFormat['decimals'], $priceFormat['dec_point'], $priceFormat['thousands_sep']) . "</span><input name='jcartItemPrice[]' type='hidden' value='{$item['price']}' />\n";
                     if (!$this->inOrderPreview) {
                         echo tab(7) . "<a class='jcart-remove' href='?jcartRemove={$item['id']}'>{$config['text']['removeLink']}</a>\n";
                     }
                     echo tab(6) . "</td>\n";
                     echo tab(7) . "<input name='jartItemIntegral[]' type='hidden' value='{$item['integral']}' />\n";
                     echo tab(5) . "</tr>\n";
                 }
             }
         }
     } else {
         echo tab(5) . "<tr><td id='jcart-empty' colspan='3'>";
         //if has redirect url, that means current page is order preview.
         if ($this->redirectUrl) {
             echo tab(5) . "<div class='shoppingcart_general_none'>{$config['text']['emptyMessage']}<a href='{$this->redirectUrl}'>去点餐&gt;&gt;</a></div>";
         } else {
             echo tab(5) . "{$config['text']['emptyMessage']}";
         }
         echo tab(5) . "</td></tr>\n";
     }
     echo tab(4) . "</tbody>\n";
     echo tab(3) . "</table>\n\n";
     echo tab(2) . "</fieldset>\n";
     echo tab(1) . "</form>\n\n";
 }
Example #11
0
echo tab('files');
?>
"><a href="/admin/tests/<?php 
echo $_REQUEST['test_id'];
?>
/files/">Файлы</a></li>
          <? if($_REQUEST['test_id']): ?>
          <li class="<?php 
echo tab('test-settings');
?>
"><a href="/admin/tests/<?php 
echo $_REQUEST['test_id'];
?>
/">Настройки теста</a></li>
          <li class="<?php 
echo tab('questions');
?>
"><a href="/admin/tests/<?php 
echo $_REQUEST['test_id'];
?>
/questions/">Вопросы</a></li>
          <? endif; ?>
        </ul>
        <div class="clear"></div>
      </div>
    </div>    
    <div id="wrapper">
      <div id="main">
        <? if($flash): ?>
        <div class="block">
          <div class="content">            
Example #12
0
function miniForm($string, $id, $name, $identifier = 'miniForm')
{
    $out = "<form class='form-inline " . $identifier . "' method='post'>" . nl();
    $out .= tab() . "<input name='" . $name . "' type='hidden' value='" . $id . "' />" . nl();
    $out .= $string . nl();
    $out .= tab() . "<input class='btn iHide' type='submit' value='Update' />" . nl();
    $out .= "</form>" . nl();
    return $out;
}
Example #13
0
        fwrite($fh, "return \$this->" . $field . ";");
        br($fh);
        tab($fh);
        fwrite($fh, "}");
        br($fh);
        tab($fh);
        fwrite($fh, "public function set" . $f . "( \$" . $field . " )");
        br($fh);
        tab($fh);
        fwrite($fh, "{");
        br($fh);
        tab($fh);
        tab($fh);
        fwrite($fh, "\$this->" . $field . " = \$" . $field . ";");
        br($fh);
        tab($fh);
        fwrite($fh, "}");
        br($fh);
    }
    fwrite($fh, "}");
    br($fh);
    fwrite($fh, "?>");
    fclose($fh);
    print "File: " . $className . ".php written.";
    print "<br />";
}
?>
<form action="<?php 
echo $_SERVER['PHP_SELF'];
?>
" method="POST">
Example #14
0
function article_edit($message = "")
{
    global $txpcfg, $txp_user, $vars;
    extract(get_prefs());
    extract(gpsa(array('view', 'from_view', 'step')));
    if (!empty($GLOBALS['ID'])) {
        // newly-saved article
        $ID = intval($GLOBALS['ID']);
        $step = 'edit';
    } else {
        $ID = gps('ID');
    }
    include_once $txpcfg['txpath'] . '/lib/classTextile.php';
    $textile = new Textile();
    if (!$view) {
        $view = "text";
    }
    if (!$step) {
        $step = "create";
    }
    if ($step == "edit" && $view == "text" && !empty($ID) && $from_view != "preview" && $from_view != 'html') {
        $pull = true;
        //-- it's an existing article - off we go to the db
        $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;
        }
    } else {
        $pull = false;
        //-- assume they came from post
        if (!$from_view or $from_view == 'text') {
            extract(gpsa($vars));
        } elseif ($from_view == 'preview' or $from_view == 'html') {
            // coming from either html or preview
            if (isset($_POST['store'])) {
                $store = unserialize(base64_decode($_POST['store']));
                extract($store);
            }
        }
        foreach ($vars as $var) {
            if (isset(${$var})) {
                $store_out[$var] = ${$var};
            }
        }
    }
    $GLOBALS['step'] = $step;
    if ($step == 'create') {
        $textile_body = 1;
        $textile_excerpt = 1;
    }
    if ($step != 'create') {
        // Previous record?
        $prev_id = checkIfNeighbour('prev', $sPosted);
        // Next record?
        $next_id = checkIfNeighbour('next', $sPosted);
    }
    pagetop($Title, $message);
    echo '<form action="index.php" method="post" name="article">';
    if (!empty($store_out)) {
        echo hInput('store', base64_encode(serialize($store_out)));
    }
    echo hInput('ID', $ID), eInput('article'), sInput($step);
    echo '<input type="hidden" name="view" />', startTable('edit');
    echo '<tr><td>&nbsp;</td><td colspan="3">', $view == 'preview' ? hed(ucfirst(gTxt('preview')), 2) . graf($Title) : '', $view == 'html' ? hed('XHTML', 2) . graf($Title) : '', $view == 'text' ? br . '<input type="text" name="Title" value="' . cleanfInput($Title) . '" class="edit" size="40" tabindex="1" />' : '', '</td></tr>';
    //-- article input --------------
    echo '<tr>
  		<td valign="top">', $view == 'text' && $use_textile == 2 ? '<p><a href="#" onclick="toggleDisplay(\'textile_help\');">' . gTxt('textile_help') . '</a></p>
		<div id="textile_help" style="display:none;">' . sidehelp() . '</div>' : sp;
    if ($view == 'text') {
        echo '<p><a href="#" onclick="toggleDisplay(\'advanced\');">' . gTxt('advanced_options') . '</a></p>', '<div id="advanced" style="display:none;">', graf(gTxt('use_textile') . br . tag(checkbox2('textile_body', $textile_body) . gTxt('article'), 'label') . br . tag(checkbox2('textile_excerpt', $textile_excerpt) . gTxt('excerpt'), 'label')), $allow_form_override ? graf(gTxt('override_default_form') . br . form_pop($override_form) . popHelp('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) : '', graf(gTxt('keywords') . popHelp('keywords') . br . '<textarea name="Keywords" style="width:100px;height:80px" rows="1" cols="1">' . $Keywords . '</textarea>'), graf(gTxt('article_image') . popHelp('article_image') . br . fInput('text', 'Image', $Image, 'edit')), graf(gTxt('url_title') . popHelp('url_title') . br . fInput('text', 'url_title', $url_title, 'edit')) . '</div>
			
			<p><a href="#" onclick="toggleDisplay(\'recent\');">' . gTxt('recent_articles') . '</a>' . '</p>' . '<div id="recent" style="display:none;">';
        $recents = safe_rows_start("Title, ID", 'textpattern', "1 order by LastMod desc limit 10");
        if ($recents) {
            echo '<p>';
            while ($recent = nextRow($recents)) {
                extract($recent);
                if (!$Title) {
                    $Title = gTxt('untitled') . sp . $ID;
                }
                echo '<a href="?event=article' . a . 'step=edit' . a . 'ID=' . $ID . '">' . $Title . '</a>' . br . n;
            }
            echo '</p>';
        }
        echo '</div>';
    } else {
        echo sp;
    }
    echo '</td>
    	<td valign="top" style="width:400px">';
    if ($view == "preview") {
        if ($use_textile == 2) {
            echo $textile->TextileThis($Body);
        } else {
            if ($use_textile == 1) {
                echo nl2br($Body);
            } else {
                if ($use_textile == 0) {
                    echo $Body;
                }
            }
        }
    } elseif ($view == "html") {
        if ($use_textile == 2) {
            $bod = $textile->TextileThis($Body);
        } else {
            if ($use_textile == 1) {
                $bod = nl2br($Body);
            } else {
                if ($use_textile == 0) {
                    $bod = $Body;
                }
            }
        }
        echo tag(str_replace(array(n, t), array(br, sp . sp . sp . sp), htmlspecialchars($bod)), 'code');
    } else {
        echo '<textarea style="width:400px;height:420px" rows="1" cols="1" name="Body" tabindex="2">', htmlspecialchars($Body), '</textarea>';
    }
    //-- excerpt --------------------
    if ($articles_use_excerpts) {
        if ($view == 'text') {
            $Excerpt = str_replace("&amp;", "&", htmlspecialchars($Excerpt));
            echo graf(gTxt('excerpt') . popHelp('excerpt') . br . '<textarea style="width:400px;height:50px" rows="1" cols="1" name="Excerpt" tabindex="3">' . $Excerpt . '</textarea>');
        } else {
            echo '<hr width="50%" />';
            echo $textile_excerpt ? $view == 'preview' ? graf($textile->textileThis($Excerpt), 1) : tag(str_replace(array(n, t), array(br, sp . sp . sp . sp), htmlspecialchars($textile->TextileThis($Excerpt), 1)), 'code') : graf($Excerpt);
        }
    }
    //-- author --------------
    if ($view == "text" && $step != "create") {
        echo "<p><small>" . gTxt('posted_by') . " {$AuthorID}: ", date("H:i, d M y", $sPosted + tz_offset());
        if ($sPosted != $sLastMod) {
            echo br . gTxt('modified_by') . " {$LastModID}: ", date("H:i, d M y", $sLastMod + tz_offset());
        }
        echo '</small></p>';
    }
    echo hInput('from_view', $view), '</td>';
    echo '<td valign="top" align="left" width="20">';
    //-- layer tabs -------------------
    echo $use_textile == 2 ? tab('text', $view) . tab('html', $view) . tab('preview', $view) : '&#160;';
    echo '</td>';
    ?>
	
<td width="200" valign="top" style="padding-left:10px" align="left" id="articleside">
<?php 
    //-- prev/next article links --
    if ($view == 'text') {
        if ($step != 'create' and ($prev_id or $next_id)) {
            echo '<p>', $prev_id ? prevnext_link('&#8249;' . gTxt('prev'), 'article', 'edit', $prev_id, gTxt('prev')) : '', $next_id ? prevnext_link(gTxt('next') . '&#8250;', 'article', 'edit', $next_id, gTxt('next')) : '', '</p>';
        }
    }
    //-- status radios --------------
    echo $view == 'text' ? n . graf(status_radio($Status)) . n : '';
    //-- category selects -----------
    echo $view == 'text' ? graf(gTxt('categorize') . ' [' . eLink('category', '', '', '', gTxt('edit')) . ']' . br . category_popup('Category1', $Category1) . category_popup('Category2', $Category2)) : '';
    //-- section select --------------
    if (!$from_view && !$pull) {
        $Section = getDefaultSection();
    }
    echo $view == 'text' ? graf(gTxt('section') . ' [' . eLink('section', '', '', '', gTxt('edit')) . ']' . br . section_popup($Section)) : '';
    //-- 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;
        }
    }
    echo $use_comments == 1 && $view == 'text' ? graf(gTxt('comments') . onoffRadio("Annotate", $Annotate) . '<br />' . gTxt('comment_invitation') . '<br />' . fInput('text', 'AnnotateInvite', $AnnotateInvite, 'edit')) : '';
    //-- timestamp -------------------
    if ($step == "create" and empty($GLOBALS['ID'])) {
        if ($view == 'text') {
            //Avoiding modified date to disappear
            $persist_timestamp = !empty($store_out['year']) ? mktime($store_out['hour'], $store_out['minute'], '00', $store_out['month'], $store_out['day'], $store_out['year']) : time();
            echo graf(tag(checkbox('publish_now', '1') . gTxt('set_to_now'), 'label')), '<p>', gTxt('or_publish_at'), popHelp("timestamp"), br, tsi('year', 'Y', $persist_timestamp), tsi('month', 'm', $persist_timestamp), tsi('day', 'd', $persist_timestamp), sp, tsi('hour', 'H', $persist_timestamp), ':', tsi('minute', 'i', $persist_timestamp), '</p>';
        }
        //-- publish button --------------
        if ($view == 'text') {
            echo has_privs('article.publish') ? fInput('submit', 'publish', gTxt('publish'), "publish") : fInput('submit', 'publish', gTxt('save'), "publish");
        }
    } else {
        if ($view == 'text') {
            echo '<p>', gTxt('published_at'), popHelp("timestamp"), br, tsi('year', 'Y', $sPosted, 5), tsi('month', 'm', $sPosted, 6), tsi('day', 'd', $sPosted, 7), sp, tsi('hour', 'H', $sPosted, 8), ':', tsi('minute', 'i', $sPosted, 9), '</p>', hInput('sPosted', $sPosted), hInput('sLastMod', $sLastMod), hInput('AuthorID', $AuthorID), hInput('LastModID', $LastModID), graf(checkbox('reset_time', '1', 0) . gTxt('reset_time'));
        }
        //-- save button --------------
        if ($view == 'text') {
            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");
            }
        }
    }
    echo '</td></tr></table></form>';
}
Example #15
0
/**
 *	return a hotglue-themed error message to the client
 *
 *	the function does not return if successful.
 *	@param int $code error code
 *	@param bool $no_header don't output any header
 *	@return false if the error code is not supported yet
 */
function hotglue_error($code, $no_header = false)
{
    if (!$no_header) {
        // output header
        if (USE_HOTGLUE_ERRORS) {
            $header_only = true;
        } else {
            $header_only = false;
        }
        if (!http_error($code, $header_only)) {
            return false;
        }
    }
    // output informative message
    html_flush();
    default_html(false);
    html_add_css(base_url() . 'css/hotglue_error.css');
    $bdy =& body();
    elem_attr($bdy, 'id', 'hotglue_error');
    body_append(tab(1) . '<div id="paper">' . nl());
    body_append(tab(2) . '<div id="wrapper">' . nl());
    body_append(tab(3) . '<div id="content">' . nl());
    body_append(tab(4) . '<div id="left-nav">' . nl());
    body_append(tab(5) . '<img src="' . htmlspecialchars(base_url(), ENT_COMPAT, 'UTF-8') . 'img/hotglue-logo.png" alt="logo">' . nl());
    body_append(tab(4) . '</div>' . nl());
    body_append(tab(4) . '<div id="main">' . nl());
    if ($code == 400) {
        body_append(tab(5) . '<h1 id="error-title">ERROR 400, bad request!</h1>' . nl());
    } elseif ($code == 401) {
        body_append(tab(5) . '<h1 id="error-title">Authorization required!</h1>' . nl());
    } elseif ($code == 404) {
        body_append(tab(5) . '<h1 id="error-title">ERROR 404, not found!</h1>' . nl());
    } elseif ($code == 500) {
        body_append(tab(5) . '<h1 id="error-title">ERROR 500, server fault!</h1>' . nl());
    }
    body_append(tab(5) . '<p>' . nl());
    if ($code == 400) {
        body_append(tab(6) . 'Something got screwed up...<br>' . nl());
        body_append(tab(6) . 'The page is sending a bad request to the server!' . nl());
    } elseif ($code == 401) {
        body_append(tab(6) . 'You need to be logged in in order to do this.<br>' . nl());
    } elseif ($code == 404) {
        body_append(tab(6) . 'It looks like you got lost in cyber-space...<br>' . nl());
        body_append(tab(6) . 'The page you are trying to reach does not exist!' . nl());
    } elseif ($code == 500) {
        body_append(tab(6) . 'Are we runnining out of fuel?!<br>' . nl());
        body_append(tab(6) . 'Something is causing serious server errors!' . nl());
    }
    body_append(tab(5) . '</p>' . nl());
    body_append(tab(6) . '<a href="' . htmlspecialchars(base_url(), ENT_COMPAT, 'UTF-8') . '" id="home">take me home!</a>' . nl());
    body_append(tab(4) . '</div>' . nl());
    body_append(tab(3) . '</div>' . nl());
    body_append(tab(2) . '</div>' . nl());
    body_append(tab(2) . '<div style="position: absolute; left: 200px; top: -10px; z-index: 2;">' . nl());
    body_append(tab(3) . '<img src="' . htmlspecialchars(base_url(), ENT_COMPAT, 'UTF-8') . 'img/hotglue-404.png" alt="404">' . nl());
    body_append(tab(2) . '</div>' . nl());
    body_append(tab(1) . '</div>' . nl());
    echo html_finalize();
    die;
}
Example #16
0
function article_edit($message = '', $concurrent = FALSE, $refresh_partials = FALSE)
{
    global $vars, $txp_user, $prefs, $event;
    extract($prefs);
    /*
    $partials is an array of:
    $key => array (
    	'mode' => {PARTIAL_STATIC | PARTIAL_VOLATILE | PARTIAL_VOLATILE_VALUE},
    	'selector' => $DOM_selector,
     	'cb' => $callback_function,
     	'html' => $return_value_of_callback_function (need not be intialized here)
    )
    */
    $partials = array('sLastMod' => array('mode' => PARTIAL_VOLATILE_VALUE, 'selector' => '[name=sLastMod]', 'cb' => 'article_partial_value'), 'sPosted' => array('mode' => PARTIAL_VOLATILE_VALUE, 'selector' => '[name=sPosted]', 'cb' => 'article_partial_value'), 'custom_fields' => array('mode' => PARTIAL_STATIC, 'selector' => '#custom_field_group', 'cb' => 'article_partial_custom_fields'), 'image' => array('mode' => PARTIAL_STATIC, 'selector' => '#image_group', 'cb' => 'article_partial_image'), 'keywords' => array('mode' => PARTIAL_STATIC, 'selector' => 'p.keywords', 'cb' => 'article_partial_keywords'), 'keywords_value' => array('mode' => PARTIAL_VOLATILE_VALUE, 'selector' => '#keywords', 'cb' => 'article_partial_keywords_value'), 'url_title' => array('mode' => PARTIAL_STATIC, 'selector' => 'p.url-title', 'cb' => 'article_partial_url_title'), 'url_title_value' => array('mode' => PARTIAL_VOLATILE_VALUE, 'selector' => '#url-title', 'cb' => 'article_partial_url_title_value'), 'recent_articles' => array('mode' => PARTIAL_VOLATILE, 'selector' => '#recent_group .recent', 'cb' => 'article_partial_recent_articles'), 'title' => array('mode' => PARTIAL_STATIC, 'selector' => 'p.title', 'cb' => 'article_partial_title'), 'title_value' => array('mode' => PARTIAL_VOLATILE_VALUE, 'selector' => '#title', 'cb' => 'article_partial_title_value'), 'article_view' => array('mode' => PARTIAL_VOLATILE, 'selector' => '#article_partial_article_view', 'cb' => 'article_partial_article_view'), 'body' => array('mode' => PARTIAL_STATIC, 'selector' => 'p.body', 'cb' => 'article_partial_body'), 'excerpt' => array('mode' => PARTIAL_STATIC, 'selector' => 'p.excerpt', 'cb' => 'article_partial_excerpt'), 'author' => array('mode' => PARTIAL_VOLATILE, 'selector' => 'p.author', 'cb' => 'article_partial_author'), 'article_nav' => array('mode' => PARTIAL_VOLATILE, 'selector' => 'p.nav-tertiary', 'cb' => 'article_partial_article_nav'), 'status' => array('mode' => PARTIAL_VOLATILE, 'selector' => '#write-status', 'cb' => 'article_partial_status'), 'categories' => array('mode' => PARTIAL_STATIC, 'selector' => '#categories_group', 'cb' => 'article_partial_categories'), 'section' => array('mode' => PARTIAL_STATIC, 'selector' => 'p.section', 'cb' => 'article_partial_section'), 'comments' => array('mode' => PARTIAL_VOLATILE, 'selector' => '#write-comments', 'cb' => 'article_partial_comments'), 'posted' => array('mode' => PARTIAL_VOLATILE, 'selector' => '#write-timestamp', 'cb' => 'article_partial_posted'), 'expires' => array('mode' => PARTIAL_VOLATILE, 'selector' => '#write-expires', 'cb' => 'article_partial_expires'));
    // add partials for custom fields (and their values which is redundant by design, for plugins)
    global $cfs;
    foreach ($cfs as $k => $v) {
        $partials["custom_field_{$k}"] = array('mode' => PARTIAL_STATIC, 'selector' => "p.custom-field.custom-{$k}", 'cb' => 'article_partial_custom_field');
        $partials["custom_{$k}"] = array('mode' => PARTIAL_STATIC, 'selector' => "#custom-{$k}", 'cb' => 'article_partial_value');
    }
    extract(gpsa(array('view', 'from_view', 'step')));
    if (!empty($GLOBALS['ID'])) {
        // newly-saved article
        $ID = $GLOBALS['ID'];
        $step = 'edit';
    } else {
        $ID = gps('ID');
    }
    // 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}");
        if (empty($rs)) {
            return;
        }
        $rs['reset_time'] = $rs['publish_now'] = false;
    } 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 = textile_main_fields($store_out);
        if (!empty($rs['exp_year'])) {
            if (empty($rs['exp_month'])) {
                $rs['exp_month'] = 1;
            }
            if (empty($rs['exp_day'])) {
                $rs['exp_day'] = 1;
            }
            if (empty($rs['exp_hour'])) {
                $rs['exp_hour'] = 0;
            }
            if (empty($rs['exp_minute'])) {
                $rs['exp_minute'] = 0;
            }
            if (empty($rs['exp_second'])) {
                $rs['exp_second'] = 0;
            }
            $rs['sExpires'] = safe_strtotime($rs['exp_year'] . '-' . $rs['exp_month'] . '-' . $rs['exp_day'] . ' ' . $rs['exp_hour'] . ':' . $rs['exp_minute'] . ':' . $rs['exp_second']);
        }
        if (!empty($rs['year'])) {
            $rs['sPosted'] = safe_strtotime($rs['year'] . '-' . $rs['month'] . '-' . $rs['day'] . ' ' . $rs['hour'] . ':' . $rs['minute'] . ':' . $rs['second']);
        }
    }
    $validator = new Validator(array(new SectionConstraint($rs['Section'])));
    if (!$validator->validate()) {
        $rs['Section'] = getDefaultSection();
    }
    extract($rs);
    $GLOBALS['step'] = $step;
    if ($step == 'create') {
        $textile_body = $use_textile;
        $textile_excerpt = $use_textile;
    }
    if ($step != 'create' && isset($sPosted)) {
        // Previous record?
        $rs['prev_id'] = checkIfNeighbour('prev', $sPosted);
        // Next record?
        $rs['next_id'] = checkIfNeighbour('next', $sPosted);
    } else {
        $rs['prev_id'] = $rs['next_id'] = 0;
    }
    // let plugins chime in on partials meta data
    callback_event_ref('article_ui', 'partials_meta', 0, $rs, $partials);
    $rs['partials_meta'] =& $partials;
    // get content for volatile partials
    foreach ($partials as $k => $p) {
        if ($p['mode'] == PARTIAL_VOLATILE || $p['mode'] == PARTIAL_VOLATILE_VALUE) {
            $cb = $p['cb'];
            $partials[$k]['html'] = is_array($cb) ? call_user_func($cb, $rs, $k) : $cb($rs, $k);
        }
    }
    if ($refresh_partials) {
        global $theme;
        $response[] = $theme->announce_async($message);
        // update the volatile partials
        foreach ($partials as $k => $p) {
            // volatile partials need a target DOM selector
            if (empty($p['selector']) && $p['mode'] != PARTIAL_STATIC) {
                trigger_error("Empty selector for partial '{$k}'", E_USER_ERROR);
            } else {
                // build response script
                if ($p['mode'] == PARTIAL_VOLATILE) {
                    // volatile partials replace *all* of the existing HTML fragment for their selector
                    $response[] = '$("' . $p['selector'] . '").replaceWith("' . escape_js($p['html']) . '")';
                } elseif ($p['mode'] == PARTIAL_VOLATILE_VALUE) {
                    // volatile partial values replace the *value* of elements matching their selector
                    $response[] = '$("' . $p['selector'] . '").val("' . escape_js($p['html']) . '")';
                }
            }
        }
        send_script_response(join(";\n", $response));
        // bail out
        return;
    }
    foreach ($partials as $k => $p) {
        if ($p['mode'] == PARTIAL_STATIC) {
            $cb = $p['cb'];
            $partials[$k]['html'] = is_array($cb) ? call_user_func($cb, $rs, $k) : $cb($rs, $k);
        }
    }
    $page_title = $Title ? $Title : gTxt('write');
    pagetop($page_title, $message);
    echo n . '<div id="' . $event . '_container" class="txp-container">';
    echo n . n . '<form id="article_form" name="article_form" method="post" action="index.php" ' . ($step == 'create' ? '>' : ' class="async">');
    if (!empty($store_out)) {
        echo hInput('store', base64_encode(serialize($store_out)));
    }
    echo hInput('ID', $ID) . n . eInput('article') . n . sInput($step) . n . hInput('sPosted', $sPosted) . n . hInput('sLastMod', $sLastMod) . n . hInput('AuthorID', $AuthorID) . n . hInput('LastModID', $LastModID) . '<input type="hidden" name="view" />' . startTable('', '', 'txp-columntable') . '<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="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 --------------
        echo $partials['custom_fields']['html'];
        //-- article image --------------
        echo $partials['image']['html'];
        //-- meta info --------------
        echo '<div id="meta_group"><h3 class="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 $partials['keywords']['html'];
        // url title
        echo $partials['url_title']['html'];
        echo '</div></div>' . n;
        //-- recent articles --------------
        echo '<div id="recent_group"><h3 class="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') . '">';
        echo $partials['recent_articles']['html'];
        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="html">' . hed('HTML', 2) . hed($Title, 1, ' class="title"');
    } elseif ($view == 'text') {
        echo '<div class="text">' . n . $partials['title']['html'];
    }
    //-- body --------------------
    if ($view == 'preview') {
        echo '<div class="body">' . $Body_html . '</div>';
    } elseif ($view == 'html') {
        echo tag(str_replace(array(n, t), array(br, sp . sp . sp . sp), txpspecialchars($Body_html)), 'code', ' class="body"');
    } else {
        echo $partials['body']['html'];
    }
    //-- excerpt --------------------
    if ($articles_use_excerpts) {
        if ($view == 'preview') {
            echo n . '<hr /><div class="excerpt">' . $Excerpt_html . '</div>';
        } elseif ($view == 'html') {
            echo n . '<hr />' . tag(str_replace(array(n, t), array(br, sp . sp . sp . sp), txpspecialchars($Excerpt_html)), 'code', ' class="excerpt"');
        } else {
            echo $partials['excerpt']['html'];
        }
    }
    //-- author --------------
    if ($view == "text" && $step != "create") {
        echo $partials['author']['html'];
    }
    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') : '&#160;', $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 ($rs['prev_id'] or $rs['next_id'])) {
            echo $partials['article_nav']['html'];
        }
        //-- status radios --------------
        echo $partials['status']['html'];
        //-- sort and display  -----------
        echo pluggable_ui('article_ui', 'sort_display', n . n . tag(n . '<legend>' . gTxt('sort_display') . '</legend>' . $partials['section']['html'] . $partials['categories']['html'] . n, 'fieldset', ' id="write-sort"'), $rs);
        //-- "Comments" section
        echo n . n . '<div id="comments_group"' . ($use_comments == 1 ? '' : ' class="empty"') . '><h3 class="lever' . (get_pref('pane_article_comments_visible') ? ' expanded' : '') . '"><a href="#comments">' . gTxt('comment_settings') . '</a></h3>', '<div id="comments" class="toggle" style="display:' . (get_pref('pane_article_comments_visible') ? 'block' : 'none') . '">';
        echo $partials['comments']['html'];
        // end "Comments" section
        echo '</div></div>';
        //-- "Dates" section
        echo n . n . '<div id="dates_group"><h3 class="lever' . (get_pref('pane_article_dates_visible') ? ' expanded' : '') . '"><a href="#dates">' . gTxt('date_settings') . '</a></h3>', '<div id="dates" class="toggle" style="display:' . (get_pref('pane_article_dates_visible') ? 'block' : 'none') . '">';
        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 "Dates" section
            echo n . n . '</div></div>';
            //-- publish button --------------
            echo graf(has_privs('article.publish') ? fInput('submit', 'publish', gTxt('publish'), "publish", '', '', '', 4) : fInput('submit', 'publish', gTxt('save'), "publish", '', '', '', 4), ' id="write-publish"');
        } else {
            //-- timestamp -------------------
            echo $partials['posted']['html'];
            //-- expires -------------------
            echo $partials['expires']['html'];
            // end "Dates" section
            echo n . n . '</div></div>';
            //-- save button --------------
            if ($Status >= STATUS_LIVE and has_privs('article.edit.published') or $Status >= STATUS_LIVE and $AuthorID == $txp_user and has_privs('article.edit.own.published') or $Status < STATUS_LIVE and has_privs('article.edit') or $Status < STATUS_LIVE and $AuthorID == $txp_user and has_privs('article.edit.own')) {
                echo graf(fInput('submit', 'save', gTxt('save'), "publish", '', '', '', 4), ' id="write-save"');
            }
        }
    }
    echo '</div></td></tr></table>' . n . tInput() . n . '</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.year,#write-timestamp input.month,#write-timestamp input.day,#write-timestamp input.hour,#write-timestamp input.minute,#write-timestamp input.second').change(
\t\t\tfunction() {
\t\t\t\t\$('#publish_now').prop('checked', false);
\t\t\t\t\$('#reset_time').prop('checked', false);
\t\t\t});
EOS
);
}
Example #17
0
                    echo "</table>";
                    //echo '<span style="padding-left:110px"><a href="download.php">Download</a></br></br></span>';
                    echo "</br>";
                } else {
                    $errormsg .= "No Book Found<br />";
                }
            }
        }
    }
    if ($errormsg) {
        echo "<div id=\"footer\">{$errormsg}</div>";
    }
}
?>
		<?php 
tab("EBooks");
?>
		<table border="0" align="center">
			</br>
			</br>
			<form name="mForm" method="post" enctype="multipart/form-data"
				action="" onsubmit="return validateForm();">
				<tr>
					<td><b>Book Title</b></td>
					<td><input type="text" name="book_title">
					
					</td>
				</tr>
				<tr>
					<td><b>Author Name </b></td>
					<td><input type="text" name="auth_name">
Example #18
0
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) . ' &#183; ' . safe_strftime('%d %b %Y &#183; %X', $sPosted);
        if ($sPosted != $sLastMod) {
            echo br . gTxt('modified_by') . ': ' . htmlspecialchars($LastModID) . ' &#183; ' . safe_strftime('%d %b %Y &#183; %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('&#8249;' . gTxt('prev'), 'article', 'edit', $prev_id, gTxt('prev')) : '', $next_id ? prevnext_link(gTxt('next') . '&#8250;', '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>';
}
Example #19
0
 /**
  * Gera e retorna o código HTML da view 'view'
  * @param	Model	$model	instância do model
  * @return	string			retorna o HTML gerado
  */
 protected function getViewView(Model $model)
 {
     $class = get_class($model);
     $view = '<div>' . nl;
     foreach ($model as $property => $value) {
         if ($this->isField($property)) {
             $label = $property->Label ? $property->Label : ($property->Column ? $property->Column : $property);
             $field = $property->Column ? $property->Column : $property;
             $view .= tab() . '<p><b>' . $field . ':</b> <?php echo $' . strtolower($class) . '->' . $field . ' ?></p>' . nl;
         }
     }
     $view .= '</div>';
     return $view;
 }
Example #20
0
{
    return moveURL(long(), lat(), zoom(), $type);
}
function selfURL()
{
    return moveURL(long(), lat(), zoom(), maptype());
}
function moveURL($long, $lat, $zoom, $maptype)
{
    $params = array("zoom" => $zoom, "long" => $long, "lat" => $lat, "maptype" => $maptype, "loc" => (int) $_REQUEST['loc']);
    return "detail.php?" . http_build_query($params);
}
$tabs = new Tabs(selfURL(), "tab", array("Map"));
$tabs_html = $tabs->html();
$tab = $tabs->active();
$tab = tab();
$width = pix("x", $phone);
$height = pix("y", $phone);
$parent = false;
if ($_REQUEST['loc']) {
    $db = new db();
    $stmt = $db->connection->prepare("SELECT * FROM Buildings WHERE id = " . $_REQUEST['loc']);
    $stmt->execute();
    $data = $stmt->fetchAll();
}
if ($data[0]['parent'] != '') {
    $db = new db();
    $stmt_1 = $db->connection->prepare("SELECT * FROM Buildings WHERE id = " . $data[0]['parent']);
    $stmt_1->execute();
    $parent_data = $stmt_1->fetchAll();
    $parent = true;
Example #21
0
<div
	style="width: 600px; align: center; margin-left: 300px; margin-right: 100px;">
	<?php 
tabs_header();
?>

</head>
<body>
<?php 
#define (MAX_SIZE,'90000000');
tabs_start();
?>

<?php 
tab("");
?>

<?php 
$errormsg = "";
//Initialize errors
session_start();
//This function reads the extension of the file. It is used to determine if the file is an image by checking the extension.
function getExtension($str)
{
    $i = strrpos($str, ".");
    if (!$i) {
        return "";
    }
    $l = strlen($str) - $i;
    $ext = substr($str, $i + 1, $l);
Example #22
0
            }
        }
    }
    print "</select>";
    print "</td>\n";
    tab("10");
    print "\n";
    ?>

                                        <?php 
    //削除
    tab("10");
    print "<td><a href='#' onclick='flg({$page_id});'><img src='../images/btn_delete.png' alt='削除' widrh='27' height='27' /></a></td>\n";
    tab("9");
    print "</tr>\n\n";
    tab("9");
}
?>

                            </tbody>

                        </table>

                    </form>

					<div id="pageNav">
						<ul>
							<li><a href="#">前へ</a></li>
							<li class="navNumber"><a href="#">1</a></li>
							<li class="navNumber current"><a href="#">2</a></li>
							<li class="navNumber"><a href="#">3</a></li>
Example #23
0
if (!empty($breadcrumb)) {
    ?>
    <div class="breadcrumb"><?php 
    echo $breadcrumb;
    ?>
</div>
<?php 
}
?>
<section class="inpage post section" itemprop="blogPost" itemscope="itemscope" itemtype="http://schema.org/BlogPosting">
    <div class="section-inner">
        <div class="content">
            <?php 
if (login()) {
    echo tab($p);
}
?>
            <div class="item">
                <h1 class="title" itemprop="headline"><?php 
echo $p->title;
?>
</h1>
                <div class="desc text-left" itemprop="articleBody">
                    <?php 
echo $p->body;
?>
                </div><!--//desc-->
            </div><!--//item-->
        </div><!--//content-->
    </div><!--//section-inner-->
Example #24
0
 /**
  * Einkaufswagen anzeigen
  */
 public function display_cart()
 {
     $config = $this->config;
     $errorMessage = null;
     // Konfigurationsvariablen werden vereinfacht
     $checkout = $config['checkoutPath'];
     $priceFormat = $config['priceFormat'];
     $id = $config['item']['id'];
     $name = $config['item']['name'];
     $price = $config['item']['price'];
     $qty = $config['item']['qty'];
     $url = $config['item']['url'];
     $add = $config['item']['add'];
     // Benutze Konfigurationsvariablen als Index für einkommende POST Werte
     // Werte in dem HTML Namensatribut werden in config.json gesetzt
     $id = isset($_POST[$id]) ? $_POST[$id] : 0;
     $name = isset($_POST[$name]) ? $_POST[$name] : "";
     $price = isset($_POST[$price]) ? $_POST[$price] : "";
     $qty = isset($_POST[$qty]) ? $_POST[$qty] : "";
     $url = isset($_POST[$url]) ? $_POST[$url] : "";
     // Optionaler CSRF Schutz
     $jcartToken = isset($_POST[$url]) ? $_POST[$url] : "";
     // Nur ein eindeutiger Token wird per Session generiert
     if (!$_SESSION['jcartToken']) {
         $_SESSION['jcartToken'] = md5(session_id() . time() . $_SERVER['HTTP_USER_AGENT']);
     }
     // Falls aktiviert, wird das übermittelte Token mit dem Session Token für POST requests verglichen
     if ($config['csrfToken'] === 'true' && $_POST && $jcartToken != $_SESSION['jcartToken']) {
         $errorMessage = 'Invalid token!' . $jcartToken . ' / ' . $_SESSION['jcartToken'];
     }
     // Werte werden verschönert um im Browser angezeigt zu werden.
     $id = filter_var($id, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW);
     $name = filter_var($name, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW);
     $url = filter_var($url, FILTER_SANITIZE_URL);
     // Anzahl wird gerunded fals nötig
     if ($config['decimalPlaces'] === true) {
         $qty = round($qty, $config['decimalPlaces']);
     }
     // Produkt hinzufügen
     if (isset($_POST[$add])) {
         $itemAdded = $this->add_item($id, $name, $price, $qty, $url);
         // Falls nicht Wahr gibt die Produkhinzufügefunktion den Errortyp an
         if ($itemAdded !== true) {
             $errorType = $itemAdded;
             switch ($errorType) {
                 case 'qty':
                     $errorMessage = $config['text']['quantityError'];
                     break;
                 case 'price':
                     $errorMessage = $config['text']['priceError'];
                     break;
             }
         }
     }
     // Ein einziges Produkt aktualisieren
     if (isset($_POST['jcartUpdate'])) {
         $itemUpdated = $this->update_item($_POST['itemId'], $_POST['itemQty']);
         if ($itemUpdated !== true) {
             $errorMessage = $config['text']['quantityError'];
         }
     }
     // Alle Produkte aktualisieren
     if (isset($_POST['jcartUpdateCart']) || isset($_POST['jcartCheckout'])) {
         $cartUpdated = $this->update_cart();
         if ($cartUpdated !== true) {
             $errorMessage = $config['text']['quantityError'];
         }
     }
     // Ein Produkt aus dem Warenkorb entfernen
     if (isset($_GET['jcartRemove']) && !$_POST) {
         $this->remove_item($_GET['jcartRemove']);
     }
     // Einkaufswagen leeren
     if (isset($_POST['jcartEmpty'])) {
         $this->empty_cart();
     }
     // Bestimmt welcher Text für die Anzahl Produkte im Einkaufswagen gebraucht wird
     $itemsText = $config['text']['multipleItems'];
     if ($this->itemCount == 1) {
         $itemsText = $config['text']['singleItem'];
     }
     // Überprüft ob dies die Checkout Seite ist
     /* Zuerst wird die request URI mit der URI in der config datei verglichen 
     		(gesetzt sobald der Benutzer die Seite zum ersten Mal aufruft) 
     		danach wird nach versteckten Eingaben gesucht. */
     $isCheckout = strpos(request_uri(), $checkout);
     if ($isCheckout !== false || isset($_REQUEST['jcartIsCheckout']) == 'true') {
         $isCheckout = true;
     } else {
         $isCheckout = false;
     }
     // Überschreibt die form action zu POST zu gateway.php anstadt wieder zurück zur Checkout Seite
     if ($isCheckout === true) {
         // Konfigurationspfad wird bereinigt
         $path = filter_var($config['jcartPath'], FILTER_SANITIZE_URL);
         // Fals nötigt wird letzte Schrägstrich entfernt
         $path = rtrim($path, '/');
         $checkout = $path . '/gateway.php';
     }
     // Standardmässiger Eingabetyp
     // Wird überschrieben falls Benutzerdefinierte Bilder im config.php definiert werden.
     $inputType = 'submit';
     // Ist dieser Fehler war, hat der Benutzer den Einkaufswagen von der Checkout Seite mit einem invaliden Preisformat aktualisiert
     // Übergeben als ein Session var da die Checkout Seite einen Header redirect benutzt
     // Falls übermittelt via GET, bleibt der Query string derselbe, selbst nach weiteren POST requests
     if (isset($_SESSION['quantityError']) === true) {
         $errorMessage = $config['text']['quantityError'];
         unset($_SESSION['quantityError']);
     }
     // Setzt Währungssymbol basierend auf dem Währungscode in in der Konfiguration
     $currencyCode = trim(strtoupper($config['currencyCode']));
     switch ($currencyCode) {
         case 'EUR':
             $currencySymbol = '&#128;';
             break;
         case 'GBP':
             $currencySymbol = '&#163;';
             break;
         case 'JPY':
             $currencySymbol = '&#165;';
             break;
         case 'CHF':
             $currencySymbol = 'CHF&nbsp;';
             break;
         case 'SEK':
         case 'DKK':
         case 'NOK':
             $currencySymbol = 'Kr&nbsp;';
             break;
         case 'PLN':
             $currencySymbol = 'z&#322;&nbsp;';
             break;
         case 'HUF':
             $currencySymbol = 'Ft&nbsp;';
             break;
         case 'CZK':
             $currencySymbol = 'K&#269;&nbsp;';
             break;
         case 'ILS':
             $currencySymbol = '&#8362;&nbsp;';
             break;
         case 'TWD':
             $currencySymbol = 'NT$';
             break;
         case 'THB':
             $currencySymbol = '&#3647;';
             break;
         case 'MYR':
             $currencySymbol = 'RM';
             break;
         case 'PHP':
             $currencySymbol = 'Php';
             break;
         case 'BRL':
             $currencySymbol = 'R$';
             break;
         case 'USD':
         default:
             $currencySymbol = '$';
             break;
     }
     // Ausgabe des Einkaufswagen
     // Gibt eine spezifiziehrte Anzahl von Tabs zurück um die Leserlichkeit der HTML Ausgabe zu verbessern.
     function tab($n)
     {
         $tabs = null;
         while ($n > 0) {
             $tabs .= "\t";
             --$n;
         }
         return $tabs;
     }
     // gibt es eine Fehlermeldung, wird sie schön in HTML eingepackt
     if ($errorMessage) {
         $errorMessage = "<p id='jcart-error'>{$errorMessage}</p>";
     }
     // Der Einkaufsheader wird angezeigt
     echo tab(1) . "{$errorMessage}\n";
     echo tab(1) . "<form method='post' action='{$checkout}'>\n";
     echo tab(2) . "<fieldset>\n";
     echo tab(3) . "<input type='hidden' name='jcartToken' value='{$_SESSION['jcartToken']}' />\n";
     echo tab(3) . "<table border='1'>\n";
     echo tab(4) . "<thead>\n";
     echo tab(5) . "<tr>\n";
     echo tab(6) . "<th colspan='3'>\n";
     echo tab(7) . "<strong id='jcart-title'>{$config['text']['cartTitle']}</strong> ({$this->itemCount} {$itemsText})\n";
     echo tab(6) . "</th>\n";
     echo tab(5) . "</tr>" . "\n";
     echo tab(4) . "</thead>\n";
     // Der Einkaufswagenfooter wird angezeigt
     echo tab(4) . "<tfoot>\n";
     echo tab(5) . "<tr>\n";
     echo tab(6) . "<th colspan='3'>\n";
     // Befinden wir uns im Checkout, wird der Einkaufswagen Checkout Knopf versteckt
     if ($isCheckout !== true) {
         $src = "";
         if ($config['button']['checkout']) {
             $inputType = "image";
             $src = " src='{$config['button']['checkout']}' alt='{$config['text']['checkout']}' title='' ";
         }
         echo tab(7) . "<input type='{$inputType}' {$src} id='jcart-checkout' name='jcartCheckout' class='jcart-button' value='{$config['text']['checkout']}' />\n";
     }
     echo tab(7) . "<span id='jcart-subtotal'>{$config['text']['subtotal']}: <strong>{$currencySymbol}" . number_format($this->subtotal, $priceFormat['decimals'], $priceFormat['dec_point'], $priceFormat['thousands_sep']) . "</strong></span>\n";
     echo tab(6) . "</th>\n";
     echo tab(5) . "</tr>\n";
     echo tab(4) . "</tfoot>\n";
     echo tab(4) . "<tbody>\n";
     // Sind Produkte im Einkaufswagen
     if ($this->itemCount > 0) {
         // Anzeige der Items
         foreach ($this->get_contents() as $item) {
             echo tab(5) . "<tr>\n";
             echo tab(6) . "<td class='jcart-item-qty'>\n";
             echo tab(7) . "<input name='jcartItemId[]' type='hidden' value='{$item['id']}' />\n";
             echo tab(7) . "<input id='jcartItemQty-{$item['id']}' name='jcartItemQty[]' size='2' type='text' value='{$item['qty']}' />\n";
             echo tab(6) . "</td>\n";
             echo tab(6) . "<td class='jcart-item-name'>\n";
             if ($item['url']) {
                 echo tab(7) . "<a href='{$item['url']}'>{$item['name']}</a>\n";
             } else {
                 echo tab(7) . $item['name'] . "\n";
             }
             echo tab(7) . "<input name='jcartItemName[]' type='hidden' value='{$item['name']}' />\n";
             echo tab(6) . "</td>\n";
             echo tab(6) . "<td class='jcart-item-price'>\n";
             echo tab(7) . "<span>{$currencySymbol}" . number_format($item['subtotal'], $priceFormat['decimals'], $priceFormat['dec_point'], $priceFormat['thousands_sep']) . "</span><input name='jcartItemPrice[]' type='hidden' value='{$item['price']}' />\n";
             echo tab(7) . "<a class='jcart-remove' href='?jcartRemove={$item['id']}'>{$config['text']['removeLink']}</a>\n";
             echo tab(6) . "</td>\n";
             echo tab(5) . "</tr>\n";
         }
     } else {
         echo tab(5) . "<tr><td id='jcart-empty' colspan='3'>{$config['text']['emptyMessage']}</td></tr>\n";
     }
     echo tab(4) . "</tbody>\n";
     echo tab(3) . "</table>\n\n";
     echo tab(3) . "<div id='jcart-buttons'>\n";
     if ($config['button']['update']) {
         $inputType = "image";
         $src = " src='{$config['button']['update']}' alt='{$config['text']['update']}' title='' ";
     }
     echo tab(4) . "<input type='{$inputType}' {$src} name='jcartUpdateCart' value='{$config['text']['update']}' class='jcart-button' />\n";
     if ($config['button']['empty']) {
         $inputType = "image";
         $src = " src='{$config['button']['empty']}' alt='{$config['text']['emptyButton']}' title='' ";
     }
     echo tab(4) . "<input type='{$inputType}' {$src} name='jcartEmpty' value='{$config['text']['emptyButton']}' class='jcart-button' />\n";
     echo tab(3) . "</div>\n";
     // Befinden wir uns im Checkout, wird der PayPal Checkout Knopf angezeigt
     if ($isCheckout === true) {
         // Versteckte Eingaben erlabuen es uns zu bestimmen ob wir uns auf der Checkout Seite befinden
         // Normalerweise prüfen wir gegen die request URI, aber das AJAX update setzt den wert zu relay.php
         echo tab(3) . "<input type='hidden' id='jcart-is-checkout' name='jcartIsCheckout' value='true' />\n";
         // Der PayPal Checkout Knopf
         if ($config['button']['checkout']) {
             $inputType = "image";
             $src = " src='{$config['button']['checkout']}' alt='{$config['text']['checkoutPaypal']}' title='' ";
         }
         if ($this->itemCount <= 0) {
             $disablePaypalCheckout = " disabled='disabled'";
         }
         echo tab(3) . "<input type='{$inputType}' {$src} id='jcart-paypal-checkout' name='jcartPaypalCheckout' value='{$config['text']['checkoutPaypal']}' {$disablePaypalCheckout} />\n";
     }
     echo tab(2) . "</fieldset>\n";
     echo tab(1) . "</form>\n\n";
     echo tab(1) . "<div id='jcart-tooltip'></div>\n";
 }
Example #25
0
 /**
  * Process and display cart
  */
 public function display_cart()
 {
     $config = $this->config;
     $errorMessage = null;
     // Simplify some config variables
     $checkout = $config['checkoutPath'];
     $priceFormat = $config['priceFormat'];
     $id = $config['item']['id'];
     $name = $config['item']['name'];
     $price = $config['item']['price'];
     $qty = $config['item']['qty'];
     $url = $config['item']['url'];
     $add = $config['item']['add'];
     // Use config values as literal indices for incoming POST values
     // Values are the HTML name attributes set in config.json
     $id = $_POST[$id];
     $name = $_POST[$name];
     $price = $_POST[$price];
     $qty = $_POST[$qty];
     $url = $_POST[$url];
     // Optional CSRF protection, see: http://conceptlogic.com/jcart/security.php
     $jcartToken = $_POST['jcartToken'];
     // Only generate unique token once per session
     if (!$_SESSION['jcartToken']) {
         $_SESSION['jcartToken'] = md5(session_id() . time() . $_SERVER['HTTP_USER_AGENT']);
     }
     // If enabled, check submitted token against session token for POST requests
     if ($config['csrfToken'] === 'true' && $_POST && $jcartToken != $_SESSION['jcartToken']) {
         $errorMessage = 'Invalid token!' . $jcartToken . ' / ' . $_SESSION['jcartToken'];
     }
     // Sanitize values for output in the browser
     $id = filter_var($id, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW);
     $name = filter_var($name, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW);
     $url = filter_var($url, FILTER_SANITIZE_URL);
     // Round the quantity if necessary
     if ($config['decimalPlaces'] === true) {
         $qty = round($qty, $config['decimalPlaces']);
     }
     // Add an item
     if ($_POST[$add]) {
         $itemAdded = $this->add_item($id, $name, $price, $qty, $url);
         // If not true the add item function returns the error type
         if ($itemAdded !== true) {
             $errorType = $itemAdded;
             switch ($errorType) {
                 case 'qty':
                     $errorMessage = $config['text']['quantityError'];
                     break;
                 case 'price':
                     $errorMessage = $config['text']['priceError'];
                     break;
             }
         }
     }
     // Update a single item
     if ($_POST['jcartUpdate']) {
         $itemUpdated = $this->update_item($_POST['itemId'], $_POST['itemQty']);
         if ($itemUpdated !== true) {
             $errorMessage = $config['text']['quantityError'];
         }
     }
     // Update all items in the cart
     if ($_POST['jcartUpdateCart'] || $_POST['jcartCheckout']) {
         $cartUpdated = $this->update_cart();
         if ($cartUpdated !== true) {
             $errorMessage = $config['text']['quantityError'];
         }
     }
     // Remove an item
     /* After an item is removed, its id stays set in the query string,
        preventing the same item from being added back to the cart in
        subsequent POST requests.  As result, it's not enough to check for
        GET before deleting the item, must also check that this isn't a POST
        request. */
     if ($_GET['jcartRemove'] && !$_POST) {
         $this->remove_item($_GET['jcartRemove']);
     }
     // Empty the cart
     if ($_POST['jcartEmpty']) {
         $this->empty_cart();
     }
     // Determine which text to use for the number of items in the cart
     $itemsText = $config['text']['multipleItems'];
     if ($this->itemCount == 1) {
         $itemsText = $config['text']['singleItem'];
     }
     // Determine if this is the checkout page
     /* First we check the request uri against the config checkout (set when
        the visitor first clicks checkout), then check for the hidden input
        sent with Ajax request (set when visitor has javascript enabled and
        updates an item quantity). */
     $isCheckout = strpos(request_uri(), $checkout);
     if ($isCheckout !== false || $_REQUEST['jcartIsCheckout'] == 'true') {
         $isCheckout = true;
     } else {
         $isCheckout = false;
     }
     // Overwrite the form action to post to gateway.php instead of posting back to checkout page
     if ($isCheckout === true) {
         // Sanititze config path
         $path = filter_var($config['jcartPath'], FILTER_SANITIZE_URL);
         // Trim trailing slash if necessary
         $path = rtrim($path, '/');
         $checkout = $path . '/gateway.php';
     }
     // Default input type
     // Overridden if using button images in config.php
     $inputType = 'submit';
     // If this error is true the visitor updated the cart from the checkout page using an invalid price format
     // Passed as a session var since the checkout page uses a header redirect
     // If passed via GET the query string stays set even after subsequent POST requests
     if ($_SESSION['quantityError'] === true) {
         $errorMessage = $config['text']['quantityError'];
         unset($_SESSION['quantityError']);
     }
     // Set currency symbol based on config currency code
     $currencyCode = trim(strtoupper($config['currencyCode']));
     switch ($currencyCode) {
         case 'EUR':
             $currencySymbol = '&#128;';
             break;
         case 'GBP':
             $currencySymbol = '&#163;';
             break;
         case 'JPY':
             $currencySymbol = '&#165;';
             break;
         case 'CHF':
             $currencySymbol = 'CHF&nbsp;';
             break;
         case 'SEK':
         case 'DKK':
         case 'NOK':
             $currencySymbol = 'Kr&nbsp;';
             break;
         case 'PLN':
             $currencySymbol = 'z&#322;&nbsp;';
             break;
         case 'HUF':
             $currencySymbol = 'Ft&nbsp;';
             break;
         case 'CZK':
             $currencySymbol = 'K&#269;&nbsp;';
             break;
         case 'ILS':
             $currencySymbol = '&#8362;&nbsp;';
             break;
         case 'TWD':
             $currencySymbol = 'NT$';
             break;
         case 'THB':
             $currencySymbol = '&#3647;';
             break;
         case 'MYR':
             $currencySymbol = 'RM';
             break;
         case 'PHP':
             $currencySymbol = 'Php';
             break;
         case 'BRL':
             $currencySymbol = 'R$';
             break;
         case 'COP':
             $currencySymbol = '$';
             break;
         case 'USD':
         default:
             $currencySymbol = '$';
             break;
     }
     ////////////////////////////////////////////////////////////////////////
     // Output the cart
     // Return specified number of tabs to improve readability of HTML output
     function tab($n)
     {
         $tabs = null;
         while ($n > 0) {
             $tabs .= "\t";
             --$n;
         }
         return $tabs;
     }
     // If there's an error message wrap it in some HTML
     if ($errorMessage) {
         $errorMessage = "<p id='jcart-error'>{$errorMessage}</p>";
     }
     // Display the cart header
     echo tab(1) . "{$errorMessage}\n";
     echo tab(1) . "<form id='carrito_easyart' method='post' action='{$checkout}'>\n";
     echo tab(2) . "<fieldset>\n";
     echo tab(3) . "<input type='hidden' name='jcartToken' value='{$_SESSION['jcartToken']}' />\n";
     echo tab(3) . "<table border='1'>\n";
     echo tab(4) . "<thead>\n";
     echo tab(5) . "<tr>\n";
     echo tab(6) . "<th colspan='3'>\n";
     echo tab(7) . "<strong id='jcart-title'>{$config['text']['cartTitle']}</strong> ({$this->itemCount} {$itemsText})\n";
     echo tab(6) . "</th>\n";
     echo tab(5) . "</tr>" . "\n";
     echo tab(4) . "</thead>\n";
     // Display the cart footer
     echo tab(4) . "<tfoot>\n";
     echo tab(5) . "<tr>\n";
     echo tab(6) . "<th colspan='3'>\n";
     // If this is the checkout hide the cart checkout button
     if ($isCheckout !== true) {
         if ($config['button']['checkout']) {
             $inputType = "image";
             $src = " src='{$config['button']['checkout']}' alt='{$config['text']['checkout']}' title='' ";
         }
         echo tab(7) . "<input type='{$inputType}' {$src} id='jcart-checkout' name='jcartCheckout' class='btn btn-info jcart-button' value='{$config['text']['checkout']}' />\n";
     }
     echo tab(7) . "<h4 id='jcart-subtotal'>{$config['text']['subtotal']}: <strong style='color: #F44336'>{$currencySymbol}" . number_format($this->subtotal, $priceFormat['decimals'], $priceFormat['dec_point'], $priceFormat['thousands_sep']) . "</strong></h4>\n";
     echo tab(6) . "</th>\n";
     echo tab(5) . "</tr>\n";
     echo tab(4) . "</tfoot>\n";
     echo tab(4) . "<tbody>\n";
     // If any items in the cart
     if ($this->itemCount > 0) {
         // Display line items
         foreach ($this->get_contents() as $item) {
             echo tab(5) . "<tr>\n";
             echo tab(6) . "<td class='jcart-item-qty col-xs-2'>\n";
             echo tab(7) . "<input name='jcartItemId[]' type='hidden' value='{$item['id']}' />\n";
             echo tab(7) . "<input id='jcartItemQty-{$item['id']}' name='jcartItemQty[]' size='2' type='text' value='{$item['qty']}' />\n";
             echo tab(6) . "</td>\n";
             echo tab(6) . "<td class='jcart-item-name'>\n";
             if ($item['url']) {
                 echo tab(7) . "<a class='text-uppercase' onclick='detalles_producto({$item['id']})'>{$item['name']}</a>\n";
             } else {
                 echo tab(7) . "<a class='text-uppercase' onclick='detalles_producto({$item['id']})'>{$item['name']}</a> ";
             }
             echo tab(7) . "<input name='jcartItemName[]' type='hidden' value='{$item['name']}' />\n";
             echo tab(6) . "</td>\n";
             echo tab(6) . "<td class='jcart-item-price'>\n";
             echo tab(7) . "<span>{$currencySymbol}" . number_format($item['subtotal'], $priceFormat['decimals'], $priceFormat['dec_point'], $priceFormat['thousands_sep']) . "</span><input name='jcartItemPrice[]' type='hidden' value='{$item['price']}' />\n";
             echo tab(7) . "<a class='jcart-remove btn btn-primary' href='?jcartRemove={$item['id']}'>{$config['text']['removeLink']}</a>\n";
             echo tab(6) . "</td>\n";
             echo tab(5) . "</tr>\n";
         }
     } else {
         echo tab(5) . "<tr><td id='jcart-empty' colspan='3'>{$config['text']['emptyMessage']}</td></tr>\n";
     }
     echo tab(4) . "</tbody>\n";
     echo tab(3) . "</table>\n\n";
     echo tab(3) . "<div id='jcart-buttons'>\n";
     if ($config['button']['update']) {
         $inputType = "image";
         $src = " src='{$config['button']['update']}' alt='{$config['text']['update']}' title='' ";
     }
     echo tab(4) . "<input type='{$inputType}' {$src} name='jcartUpdateCart' value='{$config['text']['update']}' class='btn btn-info jcart-button' />\n";
     if ($config['button']['empty']) {
         $inputType = "image";
         $src = " src='{$config['button']['empty']}' alt='{$config['text']['emptyButton']}' title='' ";
     }
     echo tab(4) . "<input type='{$inputType}' {$src} name='jcartEmpty' value='{$config['text']['emptyButton']}' class='btn btn-info jcart-button' />\n";
     echo tab(3) . "</div>\n";
     // If this is the checkout display the PayPal checkout button
     if ($isCheckout === true) {
         // Hidden input allows us to determine if we're on the checkout page
         // We normally check against request uri but ajax update sets value to relay.php
         echo tab(3) . "<input type='hidden' id='jcart-is-checkout' name='jcartIsCheckout' value='true' />\n";
         // PayPal checkout button
         if ($config['button']['checkout']) {
             $inputType = "image";
             $src = " src='{$config['button']['checkout']}' alt='{$config['text']['checkoutPaypal']}' title='' ";
         }
         if ($this->itemCount <= 0) {
             $disablePaypalCheckout = " disabled='disabled'";
         }
         echo tab(3) . "<button class='btn btn-lg btn-warning'>Realizar Pedido</button>";
     }
     echo tab(2) . "</fieldset>\n" . "<div class='form-group'>" . "<label for='cliente_nombre'>Nombre y Apellidos:" . "<input type='text' name='cliente_nombre' id='cliente_nombre' class='form-control' placeholder='Nombre y apellidos' required>" . "</label>" . "<label for='cliente_telefono'>Telef&oacute;no:" . "<input type='text' name='cliente_telefono' id='cliente_telefono' class='form-control' placeholder='Telef&oacute;no' required>" . "</label>" . "<label for='cliente_mail'>e-mail:" . "<input type='text' name='cliente_mail' id='cliente_mail' class='form-control' placeholder='correo electronico' required>" . "</label>" . "</div>" . "" . "";
     echo tab(1) . "</form>\n\n";
     echo tab(1) . "<div id='jcart-tooltip'></div>\n";
 }
Example #26
0
function text_render_page_early($args)
{
    if ($args['edit']) {
        if (USE_MIN_FILES) {
            html_add_js(base_url() . 'modules/text/text-edit.min.js');
        } else {
            html_add_js(base_url() . 'modules/text/text-edit.js');
        }
        html_add_css(base_url() . 'modules/text/text-edit.css');
        html_add_js_var('$.glue.conf.text.auto_br', TEXT_AUTO_BR);
        if (TEXT_USE_WOFF_FONTS) {
            $woff_fonts = _woff_fonts();
            foreach ($woff_fonts as $font => $styles) {
                _include_woff_font($font);
                // TODO (later): check css encoding
                $rule = '.glue-font-woff-' . $font . ' {' . nl();
                // we use single quotes as they don't clash with inline styles
                $rule .= tab() . 'font-family: \'' . $font . '\';' . nl();
                $rule .= '}';
                html_add_css_inline($rule, 6);
            }
        }
    }
}
Example #27
0
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 ? '?' : '&amp;') . '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) . ' &#183; ' . safe_strftime('%d %b %Y &#183; %X', $sPosted);
        if ($sPosted != $sLastMod) {
            echo br . gTxt('modified_by') . ': ' . htmlspecialchars($LastModID) . ' &#183; ' . safe_strftime('%d %b %Y &#183; %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>' : '&#160;';
    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('&#8249;' . gTxt('prev'), 'article', 'edit', $prev_id, gTxt('prev')) : '', $next_id ? prevnext_link(gTxt('next') . '&#8250;', '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>';
}
Example #28
0
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) . ' &#183; ' . safe_strftime('%d %b %Y &#183; %X', $sPosted);
        if ($sPosted != $sLastMod) {
            echo br . gTxt('modified_by') . ': ' . htmlspecialchars($LastModID) . ' &#183; ' . safe_strftime('%d %b %Y &#183; %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') : '&#160;', $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('&#8249;' . gTxt('prev'), 'article', 'edit', $prev_id, gTxt('prev')) : '', $next_id ? prevnext_link(gTxt('next') . '&#8250;', '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
);
}
Example #29
0
 function tabbar()
 {
     $a = func_get_args();
     $n = count($a);
     if ($n > 0) {
         echo '<div class="fftabbar">';
         for ($i = 0; $i < $n; $i++) {
             tab($a[$i][0], $a[$i][1], $a[$i][2]);
         }
         echo '</div>';
     }
 }
Example #30
0
 /**
  * Process and display cart
  */
 public function display_cart()
 {
     $config = $this->config;
     $errorMessage = null;
     // Simplify some config variables
     $checkout = $config['checkoutPath'];
     $priceFormat = $config['priceFormat'];
     $id = $config['item']['id'];
     $name = $config['item']['name'];
     $price = $config['item']['price'];
     $size = $config['item']['size'];
     $color = $config['item']['color'];
     $image = $config['item']['image'];
     $qty = $config['item']['qty'];
     $url = $config['item']['url'];
     $add = $config['item']['add'];
     // Use config values as literal indices for incoming POST values
     // Values are the HTML name attributes set in config.json
     if (isset($_POST[$id])) {
         $id = $_POST[$id];
         $name = $_POST[$name];
         $price = $_POST[$price];
         $size = $_POST[$size];
         $color = $_POST[$color];
         $image = $_POST[$image];
         $qty = $_POST[$qty];
         $url = $_POST[$url];
         // Optional CSRF protection, see: http://conceptlogic.com/jcart/security.php
         $jcartToken = $_POST['jcartToken'];
     }
     // Only generate unique token once per session
     if (!isset($_SESSION['jcartToken'])) {
         $_SESSION['jcartToken'] = md5(session_id() . time() . $_SERVER['HTTP_USER_AGENT']);
     }
     // If enabled, check submitted token against session token for POST requests
     if ($config['csrfToken'] === 'true' && $_POST && $jcartToken != $_SESSION['jcartToken']) {
         $errorMessage = 'Invalid token!' . $jcartToken . ' / ' . $_SESSION['jcartToken'];
     }
     // Sanitize values for output in the browser
     $id = filter_var($id, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW);
     $name = filter_var($name, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW);
     $size = filter_var($size, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW);
     $color = filter_var($color, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW);
     $image = filter_var($image, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW);
     $url = filter_var($url, FILTER_SANITIZE_URL);
     // Round the quantity if necessary
     if ($config['decimalPlaces'] === true) {
         $qty = round($qty, $config['decimalPlaces']);
     }
     // Add an item
     if (isset($_POST[$add])) {
         $itemAdded = $this->add_item($id, $name, $price, $size, $color, $image, $qty, $url);
         // If not true the add item function returns the error type
         if ($itemAdded !== true) {
             $errorType = $itemAdded;
             switch ($errorType) {
                 case 'qty':
                     $errorMessage = $config['text']['quantityError'];
                     break;
                 case 'price':
                     $errorMessage = $config['text']['priceError'];
                     break;
             }
         }
     }
     // Update a single item
     if (isset($_POST['jcartUpdate'])) {
         $itemUpdated = $this->update_item($_POST['itemId'], $_POST['itemQty']);
         if ($itemUpdated !== true) {
             $errorMessage = $config['text']['quantityError'];
         }
     }
     // Update all items in the cart
     if (isset($_POST['jcartUpdateCart']) || isset($_POST['jcartCheckout'])) {
         $cartUpdated = $this->update_cart();
         if ($cartUpdated !== true) {
             $errorMessage = $config['text']['quantityError'];
         }
     }
     // Remove an item
     /* After an item is removed, its id stays set in the query string,
        preventing the same item from being added back to the cart in
        subsequent POST requests.  As result, it's not enough to check for
        GET before deleting the item, must also check that this isn't a POST
        request. */
     if (isset($_GET['jcartRemove']) && !$_POST) {
         $this->remove_item($_GET['jcartRemove']);
     }
     // Empty the cart
     if (isset($_POST['jcartEmpty'])) {
         $this->empty_cart();
     }
     // Determine which text to use for the number of items in the cart
     $itemsText = $config['text']['multipleItems'];
     if ($this->itemCount == 1) {
         $itemsText = $config['text']['singleItem'];
     }
     // Determine if this is the checkout page
     /* First we check the request uri against the config checkout (set when
        the visitor first clicks checkout), then check for the hidden input
        sent with Ajax request (set when visitor has javascript enabled and
        updates an item quantity). */
     $isCheckout = strpos(request_uri(), $checkout);
     if ($isCheckout !== false || isset($_REQUEST['jcartIsCheckout']) && $_REQUEST['jcartIsCheckout'] == 'true') {
         $isCheckout = true;
     } else {
         $isCheckout = false;
     }
     // Overwrite the form action to post to gateway.php instead of posting back to checkout page
     if ($isCheckout === true) {
         // Sanititze config path
         $path = filter_var($config['jcartPath'], FILTER_SANITIZE_URL);
         // Trim trailing slash if necessary
         $path = rtrim($path, '/');
         $checkout = $path . '/gateway.php';
     }
     // Default input type
     // Overridden if using button images in config.php
     $inputType = 'submit';
     // If this error is true the visitor updated the cart from the checkout page using an invalid price format
     // Passed as a session var since the checkout page uses a header redirect
     // If passed via GET the query string stays set even after subsequent POST requests
     if (isset($_SESSION['quantityError']) && $_SESSION['quantityError'] === true) {
         $errorMessage = $config['text']['quantityError'];
         unset($_SESSION['quantityError']);
     }
     // Set currency symbol based on config currency code
     $currencyCode = trim(strtoupper($config['currencyCode']));
     switch ($currencyCode) {
         case 'EUR':
             $currencySymbol = '&#128;';
             break;
         case 'GBP':
             $currencySymbol = '&#163;';
             break;
         case 'JPY':
             $currencySymbol = '&#165;';
             break;
         case 'CHF':
             $currencySymbol = 'CHF&nbsp;';
             break;
         case 'SEK':
         case 'DKK':
         case 'NOK':
             $currencySymbol = 'Kr&nbsp;';
             break;
         case 'PLN':
             $currencySymbol = 'z&#322;&nbsp;';
             break;
         case 'HUF':
             $currencySymbol = 'Ft&nbsp;';
             break;
         case 'CZK':
             $currencySymbol = 'K&#269;&nbsp;';
             break;
         case 'ILS':
             $currencySymbol = '&#8362;&nbsp;';
             break;
         case 'TWD':
             $currencySymbol = 'NT$';
             break;
         case 'THB':
             $currencySymbol = '&#3647;';
             break;
         case 'MYR':
             $currencySymbol = 'RM';
             break;
         case 'PHP':
             $currencySymbol = 'Php';
             break;
         case 'BRL':
             $currencySymbol = 'R$';
             break;
         case 'USD':
             $currencySymbol = '$';
         case 'VND':
             $currencySymbol = '  VND';
         default:
             $currencySymbol = '  VND';
             break;
     }
     ////////////////////////////////////////////////////////////////////////
     // Output the cart
     // Return specified number of tabs to improve readability of HTML output
     function tab($n)
     {
         $tabs = null;
         while ($n > 0) {
             $tabs .= "\t";
             --$n;
         }
         return $tabs;
     }
     // If there's an error message wrap it in some HTML
     if ($errorMessage) {
         $errorMessage = "<p id='jcart-error'>{$errorMessage}</p>";
     }
     // Display the cart header
     echo tab(1) . "{$errorMessage}\n";
     echo tab(1) . "<form method='post' action='{$checkout}'>\n";
     echo tab(2) . "<fieldset>\n";
     echo tab(3) . "<input type='hidden' name='jcartToken' value='{$_SESSION['jcartToken']}' />\n";
     echo tab(3) . "<strong id='jcart-title' title='{$this->itemCount}'>{$config['text']['cartTitle']} ({$this->itemCount} {$itemsText})</strong>\n";
     echo tab(3) . "<p>{$config['text']['cartTitleDetail1']} <br> {$config['text']['cartTitleDetail2']} <br> {$config['text']['cartTitleDetail3']} <br> {$config['text']['cartTitleDetail4']}</p>";
     echo tab(3) . "<table border='1' style='border-right:none' id = 'jcartTable' >\n";
     echo tab(4) . "<thead>\n";
     echo tab(5) . "<tr hidden>\n";
     echo tab(6) . "<th colspan='7'>\n";
     echo tab(6) . "</th>\n";
     echo tab(5) . "</tr>" . "\n";
     if ($this->itemCount > 0) {
         echo tab(5) . "<tr style='background-color: lightgray'>\n";
         echo tab(6) . "<th style='text-align: center;' colspan='2'>\n";
         echo tab(7) . "<strong style = 'font-size: 15px;'>Sản phẩm</strong>\n";
         echo tab(6) . "</th>\n";
         echo tab(6) . "<th style='text-align: center;'>\n";
         echo tab(7) . "<strong style = 'font-size: 15px;'>Size</strong>\n";
         echo tab(6) . "</th>\n";
         echo tab(6) . "<th style='text-align: center;'>\n";
         echo tab(7) . "<strong style = 'font-size: 15px;'>Màu</strong>\n";
         echo tab(6) . "</th>\n";
         echo tab(6) . "<th style='text-align: center;'>\n";
         echo tab(7) . "<strong style = 'font-size: 15px;'>Giá</strong>\n";
         echo tab(6) . "</th>\n";
         echo tab(6) . "<th style='text-align: center;'>\n";
         echo tab(7) . "<strong style = 'font-size: 15px;'>Số lượng</strong>\n";
         echo tab(6) . "</th>\n";
         echo tab(6) . "<th style='text-align: center;'>\n";
         echo tab(7) . "<strong style = 'font-size: 15px;'>Tổng</strong>\n";
         echo tab(6) . "</th>\n";
         echo tab(5) . "</tr>" . "\n";
     }
     echo tab(4) . "</thead>\n";
     // Display the cart footer
     echo tab(4) . "<tfoot>\n";
     echo tab(5) . "<tr>\n";
     echo tab(6) . "<th colspan='6' style='border-bottom: none'>\n";
     // If this is the checkout hide the cart checkout button
     if ($isCheckout !== true) {
         $src = '';
         //new
         if ($config['button']['checkout']) {
             $inputType = "image";
             $src = " src='{$config['button']['checkout']}' alt='{$config['text']['checkout']}' title='' ";
         }
         echo tab(7) . "<input type='{$inputType}' {$src} id='jcart-checkout' name='jcartCheckout' class='jcart-button' value='{$config['text']['checkout']}' style='display:none'/>\n";
     }
     echo tab(7) . "<span id='jcart-subtotal'>{$config['text']['subtotal']}: \n";
     echo tab(6) . "</th>\n";
     echo tab(6) . "<th style='text-align: right' rowspan='2'> <strong>" . number_format($this->subtotal) . "</span>\n";
     echo tab(5) . "</tr>\n";
     echo tab(5) . "<tr>\n";
     echo tab(6) . "<th colspan='6' style='border-top: none; color: #E46D0D'>\n";
     echo tab(7) . "LƯU Ý: ĐƠN HÀNG TRÊN CHƯA BAO GỒM <u>PHÍ SHIP</u>";
     echo tab(6) . "</th>\n";
     echo tab(5) . "</tr>\n";
     echo tab(4) . "</tfoot>\n";
     echo tab(4) . "<tbody>\n";
     // If any items in the cart
     if ($this->itemCount > 0) {
         // Display line items
         foreach ($this->get_contents() as $item) {
             //echo "<pre style='width:100%'>";
             //print_r($item);
             //echo $item['image'];
             //echo "</pre>";
             echo tab(5) . "<tr>\n";
             echo tab(6) . "<td style='text-align: center; width: 30%'>\n";
             if ($item['url']) {
                 echo tab(7) . "<a href='{$item['url']}'><img src='../{$item['image']}' style='width:100%' /></a>\n";
                 echo tab(6) . "</td>\n";
                 echo tab(6) . "<td class='jcart-item-name'>\n";
                 echo tab(7) . "<div style-'float: right'><a href='{$item['url']}'>{$item['name']}</a></div>\n";
             } else {
                 echo tab(7) . "<img src='../{$item['image']}' style='width:100%' />\n";
                 echo tab(6) . "</td>\n";
                 echo tab(6) . "<td class='jcart-item-name'>\n";
                 echo tab(7) . $item['name'] . "\n";
             }
             echo tab(7) . "<input name='jcartItemName[]' type='hidden' value='{$item['name']}' />\n";
             echo tab(6) . "</td>\n";
             echo tab(6) . "<td class='jcart-item-size'>\n";
             echo tab(7) . $item['size'] == 0 ? "" : $item['size'] . "\n";
             echo tab(7) . "<input name='jcartItemSize[]' type='hidden' value='{$item['size']}' />\n";
             echo tab(6) . "</td>\n";
             echo tab(6) . "<td class='jcart-item-color'>\n";
             echo tab(7) . $item['color'] . "\n";
             echo tab(7) . "<input name='jcartItemColor[]' type='hidden' value='{$item['color']}' />\n";
             echo tab(6) . "</td>\n";
             echo tab(6) . "<td class=''>\n";
             echo tab(7) . "<span>" . number_format($item['price']) . "</span>";
             echo tab(7) . "<input name='jcartItemPrice[]' type='hidden' value='{$item['price']}' />\n";
             echo tab(6) . "</td>\n";
             echo tab(6) . "<td class='jcart-item-qty'>\n";
             echo tab(7) . "<input name='jcartItemId[]' type='hidden' value='{$item['id']}' />\n";
             echo tab(7) . "<input id='jcartItemQty-{$item['id']}' name='jcartItemQty[]' size='2' type='number' value='{$item['qty']}' />\n";
             echo tab(6) . "</td>\n";
             echo tab(6) . "<td class='jcart-item-price'>\n";
             echo tab(7) . "<span>" . number_format($item['subtotal']) . "</span></td>\n";
             echo tab(7) . "<td style = 'border: none; width:73px'><a class='jcart-remove' href='?jcartRemove={$item['id']}'><img src='../Templates/Content/images/Cart/removeCart.png' style='width:24px; float: left; padding: 5px 10px 0 2px' /></a>\n";
             echo tab(6) . "</td>\n";
             echo tab(5) . "</tr>\n";
         }
     } else {
         echo tab(5) . "<tr><td id='jcart-empty' colspan='6'>{$config['text']['emptyMessage']}</td></tr>\n";
     }
     echo tab(4) . "</tbody>\n";
     echo tab(3) . "</table>\n\n";
     echo tab(3) . "<div id='jcart-buttons'>\n";
     $src = '';
     if ($config['button']['update']) {
         $inputType = "image";
         $src = " src='{$config['button']['update']}' alt='{$config['text']['update']}' title='' ";
     }
     //echo tab(4) . "<input type='$inputType' $src name='jcartUpdateCart' value='{$config['text']['update']}' class='jcart-button' />\n";
     if ($config['button']['empty']) {
         $inputType = "image";
         $src = " src='{$config['button']['empty']}' alt='{$config['text']['emptyButton']}' title='' ";
     }
     //echo tab(4) . "<input type='$inputType' $src name='jcartEmpty' value='{$config['text']['emptyButton']}' class='jcart-button' />\n";
     echo tab(3) . "</div>\n";
     // If this is the checkout display the PayPal checkout button
     if ($isCheckout === true) {
         // Hidden input allows us to determine if we're on the checkout page
         // We normally check against request uri but ajax update sets value to relay.php
         echo tab(3) . "<input type='hidden' id='jcart-is-checkout' name='jcartIsCheckout' value='true' />\n";
         // PayPal checkout button
         $src = '';
         //new
         if ($config['button']['checkout']) {
             $inputType = "image";
             $src = " src='{$config['button']['checkout']}' alt='{$config['text']['checkoutPaypal']}' title='' ";
         }
         $disablePaypalCheckout = $this->itemCount <= 0 ? " disabled='disabled'" : '';
         echo tab(3) . "<input type='{$inputType}' {$src} id='jcart-paypal-checkout' name='jcartPaypalCheckout' value='{$config['text']['checkoutPaypal']}' {$disablePaypalCheckout} />\n";
     }
     echo tab(2) . "</fieldset>\n";
     echo tab(1) . "</form>\n\n";
     //echo tab(1) . "<div id='jcart-tooltip'></div>\n";
 }