protected function indexElement(HTML_Element $element) { try { $property = $this->_property; $pval = $element->{$property}; if ($pval !== null) { if (array_key_exists($pval, $this->_index)) { $this->_unique = false; if ($this->_require_unique) { throw new HTML_Duplicate_Attribute_Exception($property, $pval); } $this->_index[$pval][] = $element; } else { $this->_index[$pval] = array($element); } } } catch (HTML_No_Such_Element_Attribute_Exception $e) { } if ($element instanceof HTML_Container) { $sub_elements = $element->getContents(); foreach ($sub_elements as $sub_element) { $this->indexElement($sub_element); } } }
private static function addDataParams(HTML_Element &$html_element, $employee_id, $presence_date) { $html_element->class = $html_element->id; $html_element->class = self::FIELD_VALUE_INPUT_CLASS; $html_element->addStyle('display', 'inline-block'); $html_element->setParam('data-employeeid', $employee_id); $html_element->setParam('data-presencedate', $presence_date); return $html_element; }
/** * Constructor of the class * * @param Array $panes List of panes * @param String $active Active pane * @param String $content Content of the active pane * * @return Void */ public function __construct($panes, $active, $content) { parent::__construct('', '', '', ''); $this->panes = $panes; $this->activePane = $active; $this->content = $content; }
protected function renderAttribute($name, $value, Text_Renderer $renderer) { if ($name == 'space' && $value == 'preserve') { return; } parent::renderAttribute($name, $value, $renderer); }
public function set($name, $value) { if ($name == 'text') { $this->_text = $value; } else { parent::set($name, $value); } }
/** * Adding section to accordion * * @package Skip * @since 1.0 * * @param string $title Title of the tab * @param string $content Content in the tab * @param array $args Array of [ 'id' ], [ 'classes' ], [ 'params_title' ] and [ 'params_content' ] */ public function add_element($title, $content, $args = array()) { $defaults = array('id' => id(), 'classes' => '', 'params_title' => array(), 'params_content' => array()); $args = wp_parse_args($args, $defaults); extract($args, EXTR_SKIP); $element = array('title' => $title, 'content' => $content, 'id' => $id, 'classes' => $classes, 'params_title' => $params_title, 'params_content' => $params_content); parent::add_element($element); }
public function __construct($data, $tabs_only = false) { parent::__construct(); $this->tabs_only = $tabs_only; $this->root = $this->createElement('div', null, array('id' => $this->tabId)); $this->createTabs($data); $this->appendChild($this->root); }
public function set($name, $value) { if ($name == 'code') { $this->_code = $value; } else { parent::set($name, $value); } }
public function __construct($href = '') { $this->_tag = 'base'; parent::__construct(); $this->_unpaired = true; $this->_attributes->register('id'); $this->_attributes->register('href', $href); }
public function __construct($label, $name, $value, $with_none = false, $onchange = "", $desc = "") { parent::__construct($label, $name, $value, $desc); $this->options = array(); $this->onchange = $onchange; if ($with_none) { $this->addOption(new HTML_Element_Option($GLOBALS['Language']->getText('global', 'none_dashed'), "", $this->value === "" || $this->value === null)); } }
/** * Set or get the row attributes * Differs from parent implementation by allowing the attributes * to be returned by a callback of signature function($row){} */ public function attributes($attributes = null) { // Set dynamic attributes if (is_callable($attributes)) { $this->attr_callback = $attributes; return $this; } // Normal functionality return parent::attributes($attributes); }
protected function renderAttributes(Text_Renderer $renderer) { $html = parent::renderAttributes($renderer); // todo: sort the array by predefined order $events = $this->_events->toArray(); foreach ($events as $key => $val) { if ($val !== null) { $this->renderEventAttribute($key, $val, $renderer); } } }
public function __construct($name = null, $content = '', $http_equiv = null) { $this->_tag = 'meta'; parent::__construct(); $this->_unpaired = true; $this->_attributes->register('id'); $this->_attributes->register('http-equiv', $http_equiv); $this->_attributes->register('name', $name); $this->_attributes->register('content', $content); $this->_attributes->register('scheme'); }
public function __construct($id, $start, $link, $count, $per = 10, $page_numbers = true) { parent::__construct(); if ($start < 0 || $start > $count) { $start = 0; } $link = stripslashes($link); $current = floor($start / $per) + 1; $current_records = $start + 1 . '-' . ($current * $per > $count ? $count : $current * $per); $pages = ceil($count / $per); $this->vars = array('id' => 'paginate_' . $id, 'current_records' => $current_records, 'count' => $count, 'current' => $current, 'previous' => $previous, 'next' => $next, 'link' => $link, 'pages' => $pages, 'per' => $per, 'start' => $start, 'page_numbers' => $page_numbers); $this->make(); }
protected function renderValue() { $hp = Codendi_HTMLPurifier::instance(); $html = '<input type="' . $this->getInputType() . '" id="' . $this->id . '" name="' . $hp->purify($this->name, CODENDI_PURIFIER_CONVERT_HTML) . '" value="' . parent::renderValue() . '" '; foreach ($this->params as $key => $value) { $html .= $key . '="' . $value . '" '; } $html .= ' />'; return $html; }
private static function addDataParams(HTML_Element &$html_element, $record_id, $field_name) { $html_element->class = self::$field_value_input_class; $html_element->addStyle('display', 'inline-block'); $html_element->addStyle('font-size', '1em'); $html_element->setParam('data-recordid', $record_id); $html_element->setParam('data-fieldname', $field_name); return $html_element; }
public function assignBody(HTML_Element $element) { if ($element->tag == 'body') { $this->body = $element; return; } else { if ($element instanceof HTML_Container) { try { $sub_element = $element->getAt(0); if ($sub_element->tag == 'body') { $this->body = $sub_element; return; } } catch (HTML_Index_Out_Of_Range_Exception $e) { } } } $match = $element->getElementsBy('tag', 'body'); if (!empty($match)) { $this->body = $match[0]; } else { throw new Root_Tag_Not_Found_Exception('body'); } }
/** * WP Form constructor * * @package Skip * @since 1.0 * * @param string $name The name of the form * @param string $args Array of [ 'id' ], [ 'classes' ], [ 'before_element' ], [ 'after_element' ] and [ 'params' ] */ function __construct($name, $args = array()) { global $skip_form_name; /* * Additional parent args: * 'id' * 'classes' * 'before_element' * 'after_element' * 'params' */ $defaults = array('enctype' => 'multipart/form-data', 'classes' => 'skip_form'); $args = wp_parse_args($args, $defaults); extract($args, EXTR_SKIP); if ('' == $name) { return; } $method = 'POST'; $action = $_SERVER['REQUEST_URI']; $args['close_tag'] = TRUE; parent::__construct('form', $args); $skip_form_name = $name; $this->add_param('name', $name); if ('' != $method) { $this->add_param('method', $method); } if ('' != $action) { $this->add_param('action', $action); } if ('' != $enctype) { $this->add_param('enctype', $enctype); } // Needed Fields for Form $needed_fields = wp_nonce_field('skip_form_' . $name, $name . '_wpnonce', TRUE, FALSE); $needed_fields .= '<input type="hidden" name="MAX_FILE_SIZE" value="' . max_upload() . '" />'; $this->add_element($needed_fields); }
public function getElementsBy($property, $value) { $elems_a = parent::getElementsBy($property, $value); foreach ($this->_elements as $element) { $sub_elems_a = $element->getElementsBy($property, $value); foreach ($sub_elems_a as $match) { $elems_a[] = $match; } } return $elems_a; }
$menuBar['back'] = $_SESSION['referer_link']; if (!$values['enabled']) { $values['enabled'] = 0; } //check then enter the record. $res = $this->update($values, $ushop->db_name . 'products', array('where' => 'product_id=' . $this->registry->params['id'])); if ($res) { $params['TYPE'] = 'pass'; $params['MESSAGE'] = '<h2>Product was successfully edited.</h2>'; } else { $params['TYPE'] = 'error'; $params['MESSAGE'] = '<h2>Product could not be edited.</h2>'; } // done! } else { $form->setDefaults(array('enabled' => $row->enabled, 'discontinued' => $row->discontinued, 'name' => HTML_Element::makeXmlSafe($row->name), 'sku' => $row->sku, 'category_id' => $row->category_id, 'short_description' => $row->short_description, 'description' => $row->description, 'price' => $row->price, 'price_group_id' => $row->price_group_id, 'postage' => $row->postage, 'weight' => $row->weight, 'author_id' => $row->author_id, 'isbn' => $row->isbn, 'image_status' => $row->image_status, 'quantity' => $row->quantity, 'image' => $row->image)); $tab_array = array('details' => null, 'description' => null, 'price' => null, 'attributes' => null, 'image_upload' => null); foreach ($errors as $value) { $err = $form->getElementError($value); if ($err) { $this->registry->Warning($err); } } $renderer = new UthandoForm(__SITE_PATH . '/templates/' . $this->get('admin_config.site.template')); $renderer->setFormTemplate('form'); $renderer->setHeaderTemplate('header'); $renderer->setElementTemplate('element'); $form->accept($renderer); // output the form $tabs = new HTML_Tabs($tab_array, true); $tabs->addPanels($renderer->toHtml());
if ($rows > 0) { $items = $tree->getDecendants(true); $c = 0; $data = array(); foreach ($items as $row) { if ($row['depth'] > 0) { if ($row['depth'] > 1) { $r = str_repeat(' ', $row['depth'] - 1); $r .= "• " . $row['item']; $data[$c][] = $r; } else { $data[$c][] = $row['item']; } $data[$c][] = '<a href="/menu/view/id-' . $this->registry->params['id'] . '/action-edit/item-' . $row['item_id'] . '"><img src="/images/24x24/Edit3.png" class="Tips" title="Edit Item" rel="Click to edit the ' . $row['item'] . ' menu" /></a>'; $data[$c][] = '<a href="/menu/view/id-' . $this->registry->params['id'] . '/action-delete/item-' . $row['item_id'] . '" ><img src="/images/24x24/DeleteRed.png" class="Tips" title="Delete item" rel="Click to delete the ' . $row['category'] . ' item" /></a>'; $c++; } } $header = array('Menu Item', '', ''); $table = $this->dataTable($data, $header); } else { $params = array('TYPE' => 'info', 'MESSAGE' => '<h2>There are currently no records.</h2>'); } if ($rows > 0) { $this->content .= '<div id="tableWrap">'; $this->content .= HTML_Element::makeXmlSafe($table->toHtml()); $this->content .= '</div>'; } else { $this->content .= $this->message($params); } }
// no direct access defined('PARENT_FILE') or die('Restricted access'); if ($this->authorize()) { $display = $ushop->getDisplay('authors'); $num = count($this->getResult('author_id', $ushop->db_name . 'authors')); $start = isset($this->registry->params['astart']) ? $this->registry->params['astart'] : 0; if ($num > $display) { $paginate = new HTML_Paginate('authors', $start, '/ushop/products/astart-{start}/view-attr/authors', $num, $display, false); $this->content .= $paginate->toHTML(); } if ($authors = $this->getResult('author_id, forename, surname', $ushop->db_name . 'authors', null, array('LIMIT' => "{$start}, {$display}"))) { $c = 0; $data = array(); foreach ($authors as $row) { $data[$c][] = HTML_Element::makeXmlSafe($row->forename) . ' ' . HTML_Element::makeXmlSafe($row->surname); $data[$c][] = '<a href="/ushop/products/action-edit_attribute/attr-author/id-' . $row->author_id . '" style="text-decoration:none;" ><img src="/templates/' . $this->get('admin_config.site.template') . '/images/24x24/Edit3.png" class="Tips" title="Edit Author" rel="Click to edit this author." /></a>'; $data[$c][] = '<a href="/ushop/products/action-delete_attribute/attr-author/id-' . $row->author_id . '" ><img src="/templates/' . $this->get('admin_config.site.template') . '/images/24x24/Delete.png" class="Tips" title="Delete Author" rel="Click to delete this author" /></a>'; $c++; } $header = array('Author', '', ''); $table = $this->dataTable($data, $header); $data = $table->toHtml(); } else { $params['TYPE'] = 'info'; $params['MESSAGE'] = '<h2>There are currently no records.</h2>'; $products = $this->message(array('MESSAGE' => '<h2>First define some authors.</h2>', 'TYPE' => 'info')); //$tab_array['products'] = $products; } if (isset($params)) { $authors = $this->message($params);
/** * @ignore */ function skip_html_element($tag, $args = array(), $elements = array(), $return = 'html') { $html_element = new HTML_Element($tag, $args); if (count($elements) > 0) { foreach ($elements as $element) { $html_element->add_element($element); } } return element_return($html_element, $return); }
FROM uthando_core.ushop_product_categories AS child, uthando_core.ushop_product_categories AS parent, uthando_core.ushop_products AS product WHERE child.lft BETWEEN parent.lft AND parent.rgt AND child.category_id = product.category_id GROUP BY category_id ORDER BY child.lft '); foreach ($rows as $value) { $num_products[$value->category_id] = $value->num_product; } foreach ($tree->getTree("{$start}, {$display}") as $row) { if ($row['depth'] > 0) { $r = str_repeat(str_repeat(' ', 4), $row['depth']); $r .= "• " . HTML_Element::makeXmlSafe($row['category']); $data[$c][] = $r; } else { $data[$c][] = HTML_Element::makeXmlSafe($row['category']); } $data[$c][] = $num_products[$row['category_id']] . ' [show]'; $data[$c][] = '<a href="/ushop/products/action-edit_category/id-' . $row['category_id'] . '" style="text-decoration:none;" ><img src="/templates/' . $this->get('admin_config.site.template') . '/images/24x24/Edit3.png" class="Tips" title="Edit Category" rel="Click to edit this category." /></a>'; $data[$c][] = '<a href="/ushop/products/action-delete_category/id-' . $row['category_id'] . '" ><img src="/templates/' . $this->get('admin_config.site.template') . '/images/24x24/Delete.png" class="Tips" title="Delete Category" rel="Click to delete this category" /></a>'; $c++; } $header = array('Category', 'Products', '', ''); $table = $this->dataTable($data, $header); $data = $table->toHtml(); } else { $params['TYPE'] = 'info'; $params['MESSAGE'] = '<h2>There are currently no records.</h2>'; } if (isset($params)) { $categories = $this->message($params);
/** * Rendering element * @package Skip * @since 1.0 * @return string $content The content of the element as HTML */ public function render() { if (count($this->error_msgs) > 0) { foreach ($this->error_msgs as $message) { $this->after('<div class="skip_error ui-state-error ui-corner-all"><p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>' . $message . '</p></div>'); } } return parent::render(); }
} $categories = $this->getResult('category_id', $ushop->db_name . 'product_categories'); $display = $ushop->getDisplay('product'); $num = count($this->getResult('product_id', $ushop->db_name . 'products')); $start = isset($this->registry->params['pstart']) ? $this->registry->params['pstart'] : 0; if ($num > $display) { $paginate = new HTML_Paginate('products', $start, '/ushop/products/pstart-{start}/view-products', $num, $display, false); $this->content .= $paginate->toHTML(); } if ($products = $this->getResult('product_id, sku, name, price, image, enabled, image_status, category', $ushop->db_name . 'products', array($ushop->db_name . 'product_categories'), array('ORDER BY' => 'sku ASC', 'LIMIT' => "{$start}, {$display}"))) { $c = 0; $data = array(); foreach ($products as $row) { $data[$c][] = $row->enabled ? '<a href="' . $_SERVER['REQUEST_URI'] . '/enable-0/id-' . $row->product_id . '" style="text-decoration:none;" ><img src="/images/16x16/IndicatorCircleGreenOn.png" /></a>' : '<a href="' . $_SERVER['REQUEST_URI'] . '/enable-1/id-' . $row->product_id . '" style="text-decoration:none;" ><img src="/images/16x16/IndicatorCircleRedOff.png" /></a>'; $data[$c][] = $row->sku; $data[$c][] = HTML_Element::makeXmlSafe($row->name); $data[$c][] = '£' . $row->price; $data[$c][] = $row->category; $data[$c][] = '<a href="/ushop/products/action-edit_product/id-' . $row->product_id . '" style="text-decoration:none;" ><img src="/images/24x24/Edit3.png" class="Tips" title="Edit Product" rel="Click to edit this product." /></a>'; $data[$c][] = '<a href="/ushop/products/action-delete_product/id-' . $row->product_id . '" ><img src="/images/24x24/Delete.png" class="Tips" title="Delete Product" rel="Click to delete this product" /></a>'; $c++; } $header = array('', 'SKU', 'Title', 'Price', 'Category', '', ''); $table = $this->dataTable($data, $header); $data = $table->toHtml(); } else { $params['TYPE'] = 'info'; if (!$tax_codes) { $params['MESSAGE'] = '<h2>First define some tax codes.</h2>'; } elseif (!$categories) { $params['MESSAGE'] = '<h2>First define some categories.</h2>';
/** * Constructor * * Accepts any HTML_Element as parameter. * Each HTML_Element will be displayed in its own column * * Usage: * <code> * $c = new ComponentsHTML_Columns( * new HTML_Element_Input_Text(), * new HTML_Element_Input_Text(), * new HTML_Element_Textarea(), * ); * </code> */ function __construct() { parent::__construct(null, null, null); $this->components = func_get_args(); }
public function productDetails($row) { $base_dir = realpath(__SITE_PATH . $this->img_dir); $html = file_get_contents('ushop/html/product.html', true); $params = array('LINK' => '/ushop/view/product/id-' . $row->product_id, 'CART_LINK' => '/ushop/view/cart/action-add/id-' . $row->product_id, 'SEARCH_LINK' => '#'); foreach ($row as $key => $value) { if ($key == ('name' || 'author')) { $value = HTML_Element::makeXmlSafe($value); } if ($key == 'image') { $params[strtoupper($key)] = file_exists($base_dir . '/' . $value) && $value != null ? $this->img_dir . $value : $this->img_dir . 'noimage.png'; } else { $params[strtoupper($key)] = $value; } } if (!$row->image_status) { $html = UShop_Utility::removeSection($html, 'image'); } if ($this->global['catelogue_mode']) { $html = UShop_Utility::removeSection($html, 'add_cart'); } $html = Uthando::templateParser($html, $params, '{', '}'); return $html; }
foreach ($ushop->attributes as $key => $value) { if ($value) { array_push($tab_array, 'attr/' . $key); } } $menuBar = array_merge($productsBar, $menuBar); $this->content .= $this->makeToolbar($menuBar, 24); if ($this->registry->params['view'] == 'attr') { $id = $this->registry->params[0]; } elseif ($this->registry->params['view']) { $id = $this->registry->params['view']; } else { $id = 'products'; } //$tabs = new HTML_Tabs($tab_array, true); $doc = new HTML_Element(); $tabs = $doc->createElement('ul', null, array('id' => $id, 'class' => 'product_tabs')); foreach ($tab_array as $tab) { $class = 'gradient'; $tabTitle = str_replace('attr/', '', $tab); if ($tabTitle == $id) { $class .= ' active'; } $li = $doc->createElement('li', null, array('class' => $class, 'title' => $tabTitle)); $a = $doc->createElement('a', ucwords(str_replace('_', ' ', $tabTitle)), array('href' => '/ushop/products/view-' . $tab)); $li->appendChild($a); $tabs->appendChild($li); } $doc->appendChild($tabs); $this->content .= $doc->toHtml(); $this->content .= '<div id="productsWrap" class="both">' . $data . '</div>';
<?php // no direct access defined('PARENT_FILE') or die('Restricted access'); if ($this->authorize()) { $authors = $this->getResult('author_id, forename, surname', $ushop->db_name . 'authors'); //$author_radio[] = $form->createElement('radio', null, null, 'new', '1'); //$author_radio[] = $form->createElement('radio', null, null, 'Existing', '0'); //$form->addGroup($author_radio, 'author', 'Author:'); if ($authors) { $authors_s = $form->createElement('select', 'author_id', 'Author:'); $authors_opts[0] = 'Select One'; foreach ($authors as $value) { $authors_opts[$value->author_id] = HTML_Element::makeXmlSafe($value->forename, true) . ' ' . HTML_Element::makeXmlSafe($value->surname, true); } $authors_s->loadArray($authors_opts); $form->addElement($authors_s); $errors[] = 'author_id'; } else { $authors = $this->templateParser($tmpl, array('LABEL' => 'Authors:', 'ELEMENT' => 'No authors aviliable'), '{', '}'); $form->addElement('html', $authors); } $form->addRule('author_id', 'Please select an author.', 'required'); $form->addRule('author_id', 'Please select an author.', 'nonzero'); }