/** * get table of contents for a given page * * @param object &$PAGEDATA page to retrieve the table of * * @return string HTML table of contents */ function TableOfContents_getContent(&$PAGEDATA) { $kids = Pages::getInstancesByParent($PAGEDATA->id); $c = $PAGEDATA->render(); if (!count($kids->pages)) { $c .= '<em>' . __('No sub-pages') . '</em>'; } else { $c .= '<ul class="subpages">'; foreach ($kids->pages as $kid) { $c .= '<li><a href="' . $kid->getRelativeURL() . '">' . htmlspecialchars(__fromJSON($kid->name)) . '</a></li>'; } $c .= '</ul>'; } if (isset($PAGEDATA->vars['footer'])) { $c .= $PAGEDATA->vars['footer']; } return $c; }
/** * return a HTML string with "breadcrumb" links to the current page * * @param int $id ID of the root page to draw breadcrumbs from * @param int $top should this breadcrumb be wrapped? * * @return string */ function Template_breadcrumbs($id = 0, $top = 1) { if ($id) { $page = Page::getInstance($id); } else { $page = $GLOBALS['PAGEDATA']; } $c = $page->parent ? Template_breadcrumbs($page->parent, 0) . ' » ' : ''; if ($top) { $pre = '<div class="breadcrumbs">'; $suf = '</div>'; $bcfn = @$GLOBALS['PLUGINS'][$page->plugin]['frontend']['breadcrumbs']; $suf = $bcfn ? $bcfn($page->getRelativeURL()) . '</div>' : '</div>'; } else { $pre = ''; $suf = ''; } return $pre . $c . '<a href="' . $page->getRelativeURL() . '">' . htmlspecialchars(__fromJSON($page->name)) . '</a>' . $suf; }
/** * get a list of products that are related and show them * * @param array $params array of parameters passed to the Smarty function * @param object $smarty the current Smarty object * * @return string the list of products */ function Products_showRelatedProducts($params, $smarty) { global $cdnprefix; $params = array_merge(array('mode' => 'table', 'type' => '', 'thumb_width' => 180, 'thumb_height' => 180, 'button_text' => __('Related Products'), 'template_header' => false, 'template_body' => false), $params); if ($params['mode'] == 'popup') { WW_addScript('products/j/products-related-popup.js'); $button = '<button class="products-related-popup"'; if ($params['template_body']) { $button .= ' data-template-body="' . htmlspecialchars($params['template_body']) . '"'; } if ($params['template_header']) { $button .= ' data-template-header="' . htmlspecialchars($params['template_header']) . '"'; } return $button . '>' . $params['button_text'] . '</button>'; } $product = $smarty->smarty->tpl_vars['product']->value; $productID = $product->id; $type = ''; if ($params['type']) { $tid = dbOne('select id from products_relation_types where name="' . addslashes($params['type']) . '"', 'id'); if ($tid) { $type = ' and relation_id=' . $tid; } } $rs = dbAll('select distinct to_id from products_relations where from_id=' . $productID . $type); if (count($rs)) { $h = array(); $ids = array(); foreach ($rs as $r) { $ids[] = $r['to_id']; } $products = Products::getbyIds($ids); foreach ($products->product_ids as $r) { $p = Product::getInstance($r); if (!$p || !isset($p->id)) { continue; } $h[] = '<a class="product_related" href="' . $p->getRelativeUrl() . '">'; $vals = $p->vals; if (!$vals['images_directory']) { $h[] = htmlspecialchars(__FromJson($p->name)) . '</a>'; continue; } $iid = $p->getDefaultImage(); if (!$iid) { $h[] = htmlspecialchars(__FromJson($p->name)) . '</a>'; continue; } if (!isset($vals['online_store_fields']) || !$vals['online_store_fields']) { $pvat = array("vat" => $_SESSION['onlinestore_vat_percent']); require_once SCRIPTBASE . '/ww.plugins/online-store/frontend/' . 'smarty-functions.php'; $h[] = '<img src="' . $cdnprefix . '/a/w=' . $params['thumb_width'] . '/h=' . $params['thumb_height'] . '/f=getImg/' . $iid . '" />' . OnlineStore_productPriceFull2($pvat, $smarty) . '<p class="product_related_name">' . htmlspecialchars(__fromJSON($p->name)) . '</p></a>'; continue; } $h[] = '<img src="' . $cdnprefix . '/a/w=' . $params['thumb_width'] . '/h=' . $params['thumb_height'] . '/f=getImg/' . $iid . '"/>' . '<br/>' . htmlspecialchars(__fromJSON($p->name)) . '</a>'; } return count($h) ? '<div class="products_related_all">' . '<div class="product_list products_' . htmlspecialchars($params['type']) . '">' . join('', $h) . '</div></div>' : __('none yet'); } return '<p class="no_products_related">' . __('none yet') . '</p>'; }