protected function getInput() { $this->params = $this->element->attributes(); if (!is_array($this->value)) { $this->value = explode(',', $this->value); } $group = $this->get('group', 'countries'); $options = array(); foreach ($this->{$group} as $key => $val) { if (!$val) { $options[] = JHtml::_('select.option', '-', ' ', 'value', 'text', true); } else { if ($key['0'] == '-') { $options[] = JHtml::_('select.option', '-', $val, 'value', 'text', true); } else { $val = nnText::prepareSelectItem($val); $options[] = JHtml::_('select.option', $key, $val); } } } $size = (int) $this->get('size'); $multiple = $this->get('multiple'); require_once JPATH_PLUGINS . '/system/nnframework/helpers/html.php'; return nnHtml::selectlistsimple($options, $this->name, $this->value, $this->id, $size, $multiple); }
protected function getInput() { $this->params = $this->element->attributes(); JHtml::stylesheet('nnframework/style.min.css', false, true); require_once __DIR__ . '/toggler.php'; $toggler = new nnFieldToggler(); $this->value = (int) $this->value; $label = $this->get('label'); $param_name = $this->get('name'); $noshow = $this->get('noshow', 0); $showclose = $this->get('showclose', 0); $html = array(); if ($label) { $label = nnText::html_entity_decoder(JText::_($label)); $html[] = '</div>'; if (!$noshow) { $html[] = $toggler->getInput(array('div' => 1, 'param' => 'show_assignments|' . $param_name, 'value' => '1|1,2')); } $class = 'well well-small nn_well'; if ($this->value === 1) { $class .= ' alert-success'; } else { if ($this->value === 2) { $class .= ' alert-error'; } } $html[] = '<div class="' . $class . '">'; if ($showclose && JFactory::getUser()->authorise('core.admin')) { $html[] = '<button type="button" class="close nn_remove_assignment">×</button>'; } $html[] = '<div class="control-group">'; $html[] = '<div class="control-label">'; $html[] = '<label><h4 class="nn_assignmentselection-header">' . $label . '</h4></label>'; $html[] = '</div>'; $html[] = '<div class="controls">'; $html[] = '<fieldset id="' . $this->id . '" class="radio btn-group">'; $onclick = ' onclick="nnScripts.setToggleTitleClass(this, 0)"'; $html[] = '<input type="radio" id="' . $this->id . '0" name="' . $this->name . '" value="0"' . (!$this->value ? ' checked="checked"' : '') . $onclick . '/>'; $html[] = '<label class="nn_btn-ignore" for="' . $this->id . '0">' . JText::_('NN_IGNORE') . '</label>'; $onclick = ' onclick="nnScripts.setToggleTitleClass(this, 1)"'; $html[] = '<input type="radio" id="' . $this->id . '1" name="' . $this->name . '" value="1"' . ($this->value === 1 ? ' checked="checked"' : '') . $onclick . '/>'; $html[] = '<label class="nn_btn-include" for="' . $this->id . '1">' . JText::_('NN_INCLUDE') . '</label>'; $onclick = ' onclick="nnScripts.setToggleTitleClass(this, 2)"'; $onclick .= ' onload="nnScripts.setToggleTitleClass(this, ' . $this->value . ', 7)"'; $html[] = '<input type="radio" id="' . $this->id . '2" name="' . $this->name . '" value="2"' . ($this->value === 2 ? ' checked="checked"' : '') . $onclick . '/>'; $html[] = '<label class="nn_btn-exclude" for="' . $this->id . '2">' . JText::_('NN_EXCLUDE') . '</label>'; $html[] = '</fieldset>'; $html[] = '</div>'; $html[] = '</div>'; $html[] = '<div class="clearfix"> </div>'; $html[] = $toggler->getInput(array('div' => 1, 'param' => $param_name, 'value' => '1,2')); $html[] = '<div><div>'; } else { if (!$noshow) { $html[] = $toggler->getInput(array('div' => 1)); } $html[] = $toggler->getInput(array('div' => 1)); } return '</div>' . implode('', $html); }
public function onAfterRender() { // only in html and feeds if (JFactory::getDocument()->getType() !== 'html' && JFactory::getDocument()->getType() !== 'feed') { return; } $html = JResponse::getBody(); if ($html == '') { return; } if (JFactory::getDocument()->getType() != 'html') { $this->helpers->get('replace')->replaceTags($html, 'body'); $this->helpers->get('clean')->cleanLeftoverJunk($html); JResponse::setBody($html); return; } // only do stuff in body list($pre, $body, $post) = nnText::getBody($html); $this->helpers->get('replace')->replaceTags($body, 'body'); $html = $pre . $body . $post; $this->helpers->get('clean')->cleanLeftoverJunk($html); // replace head with newly generated head // this is necessary because the plugins might have added scripts/styles to the head $this->helpers->get('head')->updateHead($html); JResponse::setBody($html); }
protected function getInput() { $this->params = $this->element->attributes(); $this->db = JFactory::getDBO(); $size = (int) $this->get('size'); $multiple = $this->get('multiple'); $show_all = $this->get('show_all'); $attribs = 'class="inputbox"'; $groups = $this->getUserGroups(); $options = array(); if ($show_all) { $option = new stdClass(); $option->value = -1; $option->text = '- ' . JText::_('JALL') . ' -'; $option->disable = ''; $options[] = $option; } foreach ($groups as $group) { $option = new stdClass(); $option->value = $group->value; $option->text = $group->text; $repeat = $show_all ? $group->level + 1 : $group->level; $option->text = str_repeat('- ', $repeat) . $option->text; $option->text = nnText::prepareSelectItem($option->text); $option->disable = ''; $options[] = $option; } require_once JPATH_PLUGINS . '/system/nnframework/helpers/html.php'; return nnHtml::selectlist($options, $this->name, $this->value, $this->id, $size, $multiple, $attribs); }
protected function getInput() { $this->params = $this->element->attributes(); $label = $this->get('label'); $format = $this->get('format'); $date = JFactory::getDate(); $tz = new DateTimeZone(JFactory::getApplication()->getCfg('offset')); $date->setTimeZone($tz); if ($format) { if (strpos($format, '%') !== false) { require_once JPATH_PLUGINS . '/system/nnframework/helpers/text.php'; $format = nnText::dateToDateFormat($format); } $html = $date->format($format, 1); } else { $html = $date->format('', 1); } if ($label) { $html = JText::sprintf($label, $html); } return '<div class="nn_block nn_title">' . $html . '</div>'; }
protected function getInput() { $this->params = $this->element->attributes(); require_once __DIR__ . '/toggler.php'; $toggler = new nnFieldToggler; $this->value = (int) $this->value; $label = $this->get('label'); $param_name = $this->get('name'); $html = array(); if ($label) { $label = nnText::html_entity_decoder(JText::_($label)); $html[] = '<div style="clear: both;"></div>'; $class = 'nn_panel nn_panel_title nn_panel_toggle'; $checked = ''; if ($this->value === 1) { $class .= ' nn_panel_include'; $checked = ' checked="checked"'; } else if ($this->value === 2) { $class .= ' nn_panel_exclude'; $checked = ' checked="checked"'; } $html[] = '<div class="' . $class . '"><label class="nn_block nn_title" for="cb_' . $param_name . '">'; $html[] = '<input id="' . $this->id . '" name="' . $this->name . '" value="1" type="checkbox" class="checkbox"' . ' onclick="nnScripts.setToggleTitleClass(this, this.checked, 2);"' . $checked . '>'; $html[] = $label; $html[] = '<div style="clear: both;"></div>'; $html[] = '</label></div>'; $html[] = $toggler->getInput(array('div' => 1, 'param' => $param_name, 'value' => '1,2')); $html[] = '<div class="nn_panel nn_panel"><div class="nn_block">'; $html[] = '<ul class="adminformlist"><li>'; } else { $html[] = '<div style="clear: both;"></div>'; $html[] = '</li></ul>'; $html[] = '<div style="clear: both;"></div>'; $html[] = '</div></div>'; $html[] = $toggler->getInput(array('div' => 1)); } return implode($html); }
function getCategories() { $query = $this->db->getQuery(true)->select('COUNT(*)')->from('#__zoo_category AS c')->where('c.published > -1'); $this->db->setQuery($query); $total = $this->db->loadResult(); if ($total > $this->max_list_count) { return -1; } $options = array(); if ($this->get('show_ignore')) { if (in_array('-1', $this->value)) { $this->value = array('-1'); } $options[] = JHtml::_('select.option', '-1', '- ' . JText::_('NN_IGNORE') . ' -', 'value', 'text', 0); $options[] = JHtml::_('select.option', '-', ' ', 'value', 'text', 1); } $query->clear()->select('a.id, a.name')->from('#__zoo_application AS a')->order('a.name, a.id'); $this->db->setQuery($query); $apps = $this->db->loadObjectList(); foreach ($apps as $i => $app) { $query->clear()->select('c.id, c.parent AS parent_id, c.name AS title, c.published')->from('#__zoo_category AS c')->where('c.application_id = ' . (int) $app->id)->where('c.published > -1')->order('c.ordering, c.name'); $this->db->setQuery($query); $items = $this->db->loadObjectList(); if ($i) { $options[] = JHtml::_('select.option', '-', ' ', 'value', 'text', 1); } // establish the hierarchy of the menu // TODO: use node model $children = array(); if ($items) { // first pass - collect children foreach ($items as $v) { $pt = $v->parent_id; $list = @$children[$pt] ? $children[$pt] : array(); array_push($list, $v); $children[$pt] = $list; } } // second pass - get an indent list of the items $list = JHtml::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0); // assemble items to the array $options[] = JHtml::_('select.option', 'app' . $app->id, '[' . $app->name . ']', 'value', 'text', 0); foreach ($list as $item) { $item->treename = ' ' . str_replace('  - ', ' ', $item->treename); $item->treename = nnText::prepareSelectItem($item->treename, $item->published); $option = JHtml::_('select.option', $item->id, $item->treename, 'value', 'text', 0); $option->level = 1; $options[] = $option; } } return $options; }
function getLevels() { $query = $this->db->getQuery(true)->select('l.akeebasubs_level_id as id, l.title AS name, l.enabled as published')->from('#__akeebasubs_levels AS l')->where('l.enabled > -1')->order('l.title, l.akeebasubs_level_id'); $this->db->setQuery($query); $list = $this->db->loadObjectList(); // assemble items to the array $options = array(); foreach ($list as $item) { $item->name = nnText::prepareSelectItem($item->name, $item->published); $options[] = JHtml::_('select.option', $item->id, $item->name, 'value', 'text', 0); } return $options; }
protected function getLabel() { $this->params = $this->element->attributes(); $label = nnText::html_entity_decoder(JText::_($this->get('label'))); $html = '<label id="' . $this->id . '-lbl" for="' . $this->id . '"'; if ($this->description) { $html .= ' class="hasTooltip" title="<strong>' . $label . '</strong><br />' . JText::_($this->description) . '">'; } else { $html .= '>'; } $html .= $label . '</label>'; return $html; }
protected function getInput() { $this->params = $this->element->attributes(); JHtml::stylesheet('nnframework/style.min.css', false, true); $label = nnText::html_entity_decoder(JText::_($this->get('label'))); $description = $this->prepareText($this->get('description')); $lang_file = $this->get('language_file'); $html = '</td></tr></table></div></div>'; $html .= '<div class="panel"><h3 class="jpane-toggler title" id="advanced-page"><span>'; $html .= $label; $html .= '</span></h3>'; $html .= '<div class="jpane-slider content"><table width="100%" class="paramlist admintable" cellspacing="1"><tr><td colspan="2" class="paramlist_value">'; if ($lang_file) { jimport('joomla.filesystem.file'); // Include extra language file $lang = str_replace('_', '-', JFactory::getLanguage()->getTag()); $inc = ''; $lang_path = 'language/' . $lang . '/' . $lang . '.' . $lang_file . '.inc.php'; if (JFile::exists(JPATH_ADMINISTRATOR . '/' . $lang_path)) { $inc = JPATH_ADMINISTRATOR . '/' . $lang_path; } else { if (JFile::exists(JPATH_SITE . '/' . $lang_path)) { $inc = JPATH_SITE . '/' . $lang_path; } } if (!$inc && $lang != 'en-GB') { $lang = 'en-GB'; $lang_path = 'language/' . $lang . '/' . $lang . '.' . $lang_file . '.inc.php'; if (JFile::exists(JPATH_ADMINISTRATOR . '/' . $lang_path)) { $inc = JPATH_ADMINISTRATOR . '/' . $lang_path; } else { if (JFile::exists(JPATH_SITE . '/' . $lang_path)) { $inc = JPATH_SITE . '/' . $lang_path; } } } if ($inc) { include $inc; } } if ($description) { if ($description['0'] != '<') { $description = '<p>' . $description . '</p>'; } $class = 'nn_panel nn_panel_description'; $html .= '<div class="' . $class . '"><div class="nn_block nn_title">'; $html .= $description; $html .= '<div style="clear: both;"></div></div></div>'; } return $html; }
private function getTitleBlock($title = '', $description = '', $start = 0) { $nostyle = $this->get('nostyle', 0); if ($title) { $title = nnText::html_entity_decoder(JText::_($title)); } if ($description) { // variables $v1 = JText::_($this->get('var1')); $v2 = JText::_($this->get('var2')); $v3 = JText::_($this->get('var3')); $v4 = JText::_($this->get('var4')); $v5 = JText::_($this->get('var5')); $description = nnText::html_entity_decoder(trim(JText::sprintf($description, $v1, $v2, $v3, $v4, $v5))); $description = str_replace('span style="font-family:monospace;"', 'span class="nn_code"', $description); } $html = array(); if ($title) { if ($nostyle) { $html[] = '<div style="clear:both;"><div>'; } else { $class = 'nn_panel nn_panel_title'; if ($start || $description) { $class .= ' nn_panel_top'; } $html[] = '<div class="' . $class . '"><div class="nn_block nn_title">'; } $html[] = $title; $html[] = '<div style="clear: both;"></div>'; $html[] = '</div></div>'; } if ($description) { if ($nostyle) { $html[] = '<div style="clear:both;"><div>'; } else { $class = 'nn_panel nn_panel_description'; if ($start) { $class .= ' nn_panel_top'; } if ($title) { $class .= ' nn_panel_hastitle'; } $html[] = '<div class="' . $class . '"><div class="nn_block nn_title">'; } $html[] = $description; $html[] = '<div style="clear: both;"></div>'; $html[] = '</div></div>'; } return implode('', $html); }
public function replace(&$string, &$match, $art = null) { $groups = explode('|', $match['4']); $match['4'] = trim(array_shift($groups)); $ignores = array(); foreach ($groups as $group) { if (strpos($group, '=') === false) { continue; } $this->helpers->get('process')->getIgnoreSetting($ignores, $group); } $html = $this->helpers->get('process')->processMatch($string, $art, $match, $ignores); $string = nnText::strReplaceOnce($match['0'], $html, $string); }
private function prepareText($string = '') { if ($string == '') { return ''; } // variables $var1 = JText::_($this->get('var1')); $var2 = JText::_($this->get('var2')); $var3 = JText::_($this->get('var3')); $var4 = JText::_($this->get('var4')); $var5 = JText::_($this->get('var5')); $string = JText::sprintf(JText::_($string), $var1, $var2, $var3, $var4, $var5); $string = trim(nnText::html_entity_decoder($string)); $string = str_replace('"', '"', $string); $string = str_replace('span style="font-family:monospace;"', 'span class="nn_code"', $string); return $string; }
protected function getInput() { $this->params = $this->element->attributes(); JHtml::stylesheet('nnframework/style.min.css', false, true); $title = $this->get('label'); $description = $this->get('description'); $class = $this->get('class'); $showclose = $this->get('showclose', 0); $start = $this->get('start', 0); $end = $this->get('end', 0); $html = array(); if ($start || !$end) { $html[] = '</div>'; if (strpos($class, 'alert') !== false) { $html[] = '<div class="alert ' . $class . '">'; } else { $html[] = '<div class="well well-small ' . $class . '">'; } if ($showclose && JFactory::getUser()->authorise('core.admin')) { $html[] = '<button type="button" class="close nn_remove_assignment">×</button>'; } if ($title) { $title = nnText::html_entity_decoder(JText::_($title)); $html[] = '<h4>' . $title . '</h4>'; } if ($description) { // variables $v1 = JText::_($this->get('var1')); $v2 = JText::_($this->get('var2')); $v3 = JText::_($this->get('var3')); $v4 = JText::_($this->get('var4')); $v5 = JText::_($this->get('var5')); $description = nnText::html_entity_decoder(trim(JText::sprintf($description, $v1, $v2, $v3, $v4, $v5))); $description = str_replace('span style="font-family:monospace;"', 'span class="nn_code"', $description); $html[] = '<div>' . $description . '</div>'; } $html[] = '<div><div>'; } if (!$start && !$end) { $html[] = '</div>'; } return '</div>' . implode('', $html); }
public function replace(&$string, &$match, $art = null) { // Check for categories... $groups = explode('|', $match['4']); $data = array(); $ignores = array(); foreach ($groups as $group) { if (!($set_data = $this->getDataByGroup($group, $ignores))) { continue; } $data[] = $set_data; } $ids = array(); foreach ($data as $dat) { $ids = array_merge($ids, $this->getArticleIdsByData($dat, $ignores)); } $html = array(); $total = count($ids); $this->helpers->get('tags')->data->article = $art; $this->helpers->get('tags')->data->total = $total; // Process empty category to allow for {if:empty} result if (!$total) { $data = $match; $data['4'] = 0; $html[] = $this->processMatch($string, $art, $data, $ignores); } // Process articles from category foreach ($ids as $i => $id) { $data = $match; $data['4'] = trim($id); $count = $i + 1; $this->helpers->get('tags')->data->count = $count; $this->helpers->get('tags')->data->even = !($count % 2); $this->helpers->get('tags')->data->uneven = $count % 2; $this->helpers->get('tags')->data->first = $count == 1; $this->helpers->get('tags')->data->last = $count >= $total; $html[] = $this->processMatch($string, $art, $data, $ignores); } $string = nnText::strReplaceOnce($match['0'], implode('', $html), $string); }
function passDate() { if (!$this->params->publish_up && !$this->params->publish_down) { // no date range set return $this->assignment == 'include'; } require_once JPATH_PLUGINS . '/system/nnframework/helpers/text.php'; nnText::fixDate($this->params->publish_up); nnText::fixDate($this->params->publish_down); $now = strtotime($this->date->format('Y-m-d H:i:s', true)); $tz = new DateTimeZone(JFactory::getApplication()->getCfg('offset')); $up = JFactory::getDate($this->params->publish_up)->setTimeZone($tz); $down = JFactory::getDate($this->params->publish_down)->setTimeZone($tz); if (isset($this->params->recurring) && $this->params->recurring) { if (!(int) $this->params->publish_up || !(int) $this->params->publish_down) { // no date range set return $this->assignment == 'include'; } $up = strtotime(date('Y') . $up->format('-m-d H:i:s')); $down = strtotime(date('Y') . $down->format('-m-d H:i:s')); // pass: // 1) now is between up and down // 2) up is later in year than down and: // 2a) now is after up // 2b) now is before down if ($up < $now && $down > $now || $up > $down && ($up < $now || $down > $now)) { return $this->assignment == 'include'; } // outside date range return $this->pass(false); } if ((int) $this->params->publish_up && strtotime($up->format('Y-m-d H:i:s')) > $now || (int) $this->params->publish_down && strtotime($down->format('Y-m-d H:i:s')) < $now) { // outside date range return $this->pass(false); } // pass return $this->assignment == 'include'; }
function processModule($id, $chrome = 'none', $ignores = array(), $overrides = array(), $area = 'articles') { $ignore_access = isset($ignores['ignore_access']) ? $ignores['ignore_access'] : $this->params->ignore_access; $ignore_state = isset($ignores['ignore_state']) ? $ignores['ignore_state'] : $this->params->ignore_state; $ignore_assignments = isset($ignores['ignore_assignments']) ? $ignores['ignore_assignments'] : $this->params->ignore_assignments; $ignore_caching = isset($ignores['ignore_caching']) ? $ignores['ignore_caching'] : $this->params->ignore_caching; $db = JFactory::getDBO(); $query = $db->getQuery(true)->select('m.*')->from('#__modules AS m')->where('m.client_id = 0'); if (is_numeric($id)) { $query->where('m.id = ' . (int) $id); } else { $query->where('m.title = ' . $db->quote(nnText::html_entity_decoder($id))); } if (!$ignore_access) { $query->where('m.access IN (' . implode(',', $this->aid) . ')'); } if (!$ignore_state) { $query->where('m.published = 1')->join('LEFT', '#__extensions AS e ON e.element = m.module AND e.client_id = m.client_id')->where('e.enabled = 1'); } if (!$ignore_assignments) { $date = JFactory::getDate(); $now = $date->toSql(); $nullDate = $db->getNullDate(); $query->where('(m.publish_up = ' . $db->quote($nullDate) . ' OR m.publish_up <= ' . $db->quote($now) . ')')->where('(m.publish_down = ' . $db->quote($nullDate) . ' OR m.publish_down >= ' . $db->quote($now) . ')'); } $query->order('m.ordering'); $db->setQuery($query); $module = $db->loadObject(); if ($module && !$ignore_assignments) { $this->applyAssignments($module); } if (empty($module)) { if ($this->params->place_comments) { return $this->params->message_start . JText::_('MA_OUTPUT_REMOVED_NOT_PUBLISHED') . $this->params->message_end; } return ''; } //determine if this is a custom module $module->user = substr($module->module, 0, 4) == 'mod_' ? 0 : 1; // set style $module->style = $chrome; if ($area == 'articles' && !$ignore_caching || !empty($overrides)) { $json = $module->params && substr(trim($module->params), 0, 1) == '{'; if ($json) { $params = json_decode($module->params); } else { // Old ini style. Needed for crappy old style modules like swMenuPro $params = JRegistryFormat::getInstance('INI')->stringToObject($module->params); } // override module parameters if (!empty($overrides)) { foreach ($overrides as $key => $val) { if (isset($module->{$key})) { $module->{$key} = $val; } else { if ($val && $val['0'] == '[' && $val[strlen($val) - 1] == ']') { $val = json_decode('{"val":' . $val . '}'); $val = $val->val; } else { if (isset($params->{$key}) && is_array($params->{$key})) { $val = explode(',', $val); } } $params->{$key} = $val; } } if ($json) { $module->params = json_encode($params); } else { $registry = new JRegistry(); $registry->loadObject($params); $module->params = $registry->toString('ini'); } } } if (isset($module->access) && !in_array($module->access, $this->aid)) { if ($this->params->place_comments) { return $this->params->message_start . JText::_('MA_OUTPUT_REMOVED_ACCESS') . $this->params->message_end; } return ''; } $document = clone JFactory::getDocument(); $document->_type = 'html'; $renderer = $document->loadRenderer('module'); $html = $renderer->render($module, array('style' => $chrome, 'name' => '')); // don't return html on article level when caching is set if ($area == 'articles' && !$ignore_caching && (isset($params->cache) && !$params->cache || isset($params->owncache) && !$params->owncache)) { return 'MA_IGNORE'; } return $html; }
static function cleanTitle($string, $striptags = 0) { require_once __DIR__ . '/text.php'; return nnText::cleanTitle($string, $striptags); }
public static function getRegexTags($tags, $include_no_attributes = true, $include_ending = true, $required_attributes = array()) { require_once __DIR__ . '/text.php'; $tags = nnText::toArray($tags); $tags = count($tags) > 1 ? '(?:' . implode('|', $tags) . ')' : $tags['0']; $spaces = self::getRegexSpaces(); $attribs = $spaces . '[^>"]*(?:"[^"]*"[^>"]*)+'; $required_attributes = nnText::toArray($required_attributes); if (!empty($required_attributes)) { $attribs = $spaces . '[^>"]*(?:"[^"]*"[^>"]*)*(?:' . implode('|', $required_attributes) . ')\\s*=\\s*(?:"[^"]*"[^>"]*)+'; } if ($include_no_attributes) { $attribs = '(?:' . $attribs . ')?'; } if (!$include_ending) { return '<' . $tags . $attribs . '>'; } return '<(?:\\/' . $tags . '|' . $tags . $attribs . ')(?:\\/|' . $spaces . ')*>'; }
protected function getInput() { $this->params = $this->element->attributes(); $size = (int) $this->get('size'); $groups = $this->get('groups'); $groups = $groups ? explode(',', $groups) : array(); if (!is_array($this->value)) { $this->value = explode(',', $this->value); } $agents = array(); /* OS */ if (empty($groups)) { $agents[] = JText::_('NN_OS'); } if (empty($groups) || in_array('os', $groups)) { $agents[] = array('Windows', 'Windows'); $agents[] = array('- Windows 8', 'Windows nt 6.2'); $agents[] = array('- Windows 7', 'Windows nt 6.1'); $agents[] = array('- Windows Vista', 'Windows nt 6.0'); $agents[] = array('- Windows Server 2003', 'Windows nt 5.2'); $agents[] = array('- Windows XP', 'Windows nt 5.1'); $agents[] = array('- Windows 2000 sp1', 'Windows nt 5.01'); $agents[] = array('- Windows 2000', 'Windows nt 5.0'); $agents[] = array('- Windows NT 4.0', 'Windows nt 4.0'); $agents[] = array('- Windows Me', 'Win 9x 4.9'); $agents[] = array('- Windows 98', 'Windows 98'); $agents[] = array('- Windows 95', 'Windows 95'); $agents[] = array('- Windows CE', 'Windows ce'); $agents[] = ''; $agents[] = array('Mac OS', '#(Mac OS|Mac_PowerPC|Macintosh)#'); $agents[] = array('- Mac OSX', 'Mac OS X'); $agents[] = array('- - Mac OSX Mountain Lion', 'Mac OS X 10.8'); $agents[] = array('- - Mac OSX Lion', 'Mac OS X 10.7'); $agents[] = array('- - Mac OSX Snow Leopard', 'Mac OS X 10.6'); $agents[] = array('- - Mac OSX Leopard', 'Mac OS X 10.5'); $agents[] = array('- - Mac OSX Tiger', 'Mac OS X 10.4'); $agents[] = array('- - Mac OSX Panther', 'Mac OS X 10.3'); $agents[] = array('- - Mac OSX Jaguar', 'Mac OS X 10.2'); $agents[] = array('- - Mac OSX Puma', 'Mac OS X 10.1'); $agents[] = array('- - Mac OSX Cheetah', 'Mac OS X 10.0'); $agents[] = array('- Mac OS (classic)', '#(Mac_PowerPC|Macintosh)#'); $agents[] = ''; $agents[] = array('Linux', '#(Linux|X11)#'); $agents[] = ''; $agents[] = JText::_('NN_OTHERS'); $agents[] = array('Open BSD', 'OpenBSD'); $agents[] = array('Sun OS', 'SunOS'); $agents[] = array('QNX', 'QNX'); $agents[] = array('BeOS', 'BeOS'); $agents[] = array('OS/2', 'OS/2'); } /* Browsers */ if (empty($groups)) { $agents[] = ''; $agents[] = ''; $agents[] = JText::_('NN_BROWSERS'); } if (empty($groups) || in_array('browsers', $groups)) { $agents[] = array('Chrome', 'Chrome'); $agents[] = array('- Chrome 30', 'Chrome/30.'); $agents[] = array('- Chrome 41-50', '#Chrome/(4[1-9]|50)\\.#'); $agents[] = array('- Chrome 31-40', '#Chrome/(3[1-9]|40)\\.#'); $agents[] = array('- Chrome 21-30', '#Chrome/(2[1-9]|30)\\.#'); $agents[] = array('- Chrome 11-20', '#Chrome/(1[1-9]|20)\\.#'); $agents[] = array('- Chrome 1-10', '#Chrome/([1-9]|10)\\.#'); $agents[] = ''; $agents[] = array('Firefox', 'Firefox'); $agents[] = array('- Firefox 31-40', '#Firefox/(3[1-9]|40)\\.#'); $agents[] = array('- Firefox 21-30', '#Firefox/(2[1-9]|30)\\.#'); $agents[] = array('- Firefox 11-20', '#Firefox/(1[1-9]|20)\\.#'); $agents[] = array('- Firefox 1-10', '#Firefox/([1-9]|10)\\.#'); $agents[] = ''; $agents[] = array('Internet Explorer', 'MSIE'); $agents[] = array('- Internet Explorer 11', 'MSIE 11'); // missing MSIE is added to agent string in assingnments/agents.php $agents[] = array('- Internet Explorer 10.6', 'MSIE 10.6'); $agents[] = array('- Internet Explorer 10.0', 'MSIE 10.0'); $agents[] = array('- Internet Explorer 10', 'MSIE 10'); $agents[] = array('- Internet Explorer 9', 'MSIE 9.'); $agents[] = array('- Internet Explorer 8', 'MSIE 8.'); $agents[] = array('- Internet Explorer 7', 'MSIE 7.'); $agents[] = array('- Internet Explorer 1-6', '#MSIE [1-6]\\.#'); $agents[] = ''; $agents[] = array('Opera', 'Opera'); $agents[] = array('- Opera 26', 'Opera/26.'); $agents[] = array('- Opera 25', 'Opera/25.'); $agents[] = array('- Opera 24', 'Opera/24.'); $agents[] = array('- Opera 23', 'Opera/23.'); $agents[] = array('- Opera 22', 'Opera/22.'); $agents[] = array('- Opera 21', 'Opera/21.'); $agents[] = array('- Opera 11-20', '#Opera/(1[1-9]|20)\\.#'); $agents[] = array('- Opera 1-10', '#Opera/([1-9]|10)\\.#'); $agents[] = ''; $agents[] = array('Safari', 'Safari'); //$agents[] = array('- Safari 8', '#Version/8\..*Safari/#'); //$agents[] = array('- Safari 7', '#Version/7\..*Safari/#'); $agents[] = array('- Safari 6', '#Version/6\\..*Safari/#'); $agents[] = array('- Safari 5', '#Version/5\\..*Safari/#'); $agents[] = array('- Safari 4', '#Version/4\\..*Safari/#'); $agents[] = array('- Safari 1-3', '#Version/[1-3]\\..*Safari/#'); } /* Mobile browsers */ if (empty($groups)) { $agents[] = ''; $agents[] = ''; $agents[] = JText::_('NN_MOBILE_BROWSERS'); } if (empty($groups) || in_array('mobile', $groups)) { $agents[] = array(JText::_('JALL'), 'mobile'); $agents[] = array('- Android', 'Android'); $agents[] = array('- Blackberry', 'Blackberry'); $agents[] = array('- IE Mobile', 'IEMobile'); $agents[] = array('- iPad', 'iPad'); $agents[] = array('- iPhone', 'iPhone'); $agents[] = array('- iPod Touch', 'iPod'); $agents[] = array('- NetFront', 'NetFront'); $agents[] = array('- Nokia', 'NokiaBrowser'); $agents[] = array('- Opera Mini', 'Opera Mini'); $agents[] = array('- Opera Mobile', 'Opera Mobi'); $agents[] = array('- UC Browser', 'UC Browser'); } $options = array(); foreach ($agents as $agent) { if (!$agent) { $options[] = JHtml::_('select.option', '-', ' ', 'value', 'text', true); } else { if (!is_array($agent)) { $options[] = JHtml::_('select.option', '-', $agent, 'value', 'text', true); } else { $agent_name = nnText::prepareSelectItem($agent['0']); $options[] = JHtml::_('select.option', $agent['1'], $agent_name); } } } require_once JPATH_PLUGINS . '/system/nnframework/helpers/html.php'; return nnHtml::selectlist($options, $this->name, $this->value, $this->id, $size, 1); }
function cleanText(&$string) { // Load common functions require_once JPATH_PLUGINS . '/system/nnframework/helpers/text.php'; // replace chr style enters with normal enters $string = str_replace(array(chr(194) . chr(160), ' ', ' '), ' ', $string); // replace linbreak tags with normal linebreaks (paragraphs, enters, etc). $enter_tags = array('p', 'br'); $regex = '#</?((' . implode(')|(', $enter_tags) . '))+[^>]*?>\\n?#si'; $string = preg_replace($regex, " \n", $string); // replace indent characters with spaces $string = preg_replace('#<' . 'img [^>]*/sourcerer/images/tab\\.png[^>]*>#si', ' ', $string); // strip all other tags $regex = '#<(/?\\w+((\\s+\\w+(\\s*=\\s*(?:".*?"|\'.*?\'|[^\'">\\s]+))?)+\\s*|\\s*)/?)>#si'; $string = preg_replace($regex, "", $string); // reset htmlentities $string = nnText::html_entity_decoder($string); // convert protected html entities &_...; -> &...; $string = preg_replace('#&_([a-z0-9\\#]+?);#i', '&\\1;', $string); }
function processMatch(&$string, &$match, $area = 'articles') { $html = ''; if ($this->params->message != '') { if ($this->params->place_comments) { $html = $this->params->message_start . $this->params->message . $this->params->message_end; } } else { if (count($match) < 10) { array_unshift($match, $match['0'], ''); $match['2'] = ''; array_push($match, '', ''); } $p_start = $match['1']; $br1a = $match['2']; $div_start = $match['3']; $br2a = $match['4']; $type = trim($match['5']); $id = trim($match['6']); $br2a = $match['7']; $div_end = $match['8']; $br2b = $match['9']; $p_end = $match['10']; $type = trim($type); $id = trim($id); $chrome = ''; $forcetitle = 0; $ignores = array(); $overrides = array(); $vars = str_replace('\\|', '[:MA_BAR:]', $id); $vars = explode('|', $vars); $id = array_shift($vars); foreach ($vars as $var) { $var = trim(str_replace('[:MA_BAR:]', '|', $var)); if (!$var) { continue; } if (strpos($var, '=') === false) { if ($this->params->override_style) { $chrome = $var; } } else { if ($type == $this->params->module_tag) { list($key, $val) = explode('=', $var, 2); $val = str_replace(array('\\{', '\\}'), array('{', '}'), $val); if ($key == 'style') { $chrome = $val; } else { if (in_array($key, array('ignore_access', 'ignore_state', 'ignore_assignments', 'ignore_caching'))) { $ignores[$key] = $val; } else { if ($key == 'showtitle') { $overrides['showtitle'] = $val; $forcetitle = $val; } } } } } } if (!$chrome) { $chrome = $forcetitle ? 'xhtml' : $this->params->style; } if ($type == $this->params->module_tag) { // module $html = $this->processModule($id, $chrome, $ignores, $overrides, $area); if ($html == 'MA_IGNORE') { return 0; } } else { // module position $html = $this->processPosition($id, $chrome); } if ($p_start && $p_end) { $p_start = ''; $p_end = ''; } $html = $br1a . $br2a . $html . $br2a . $br2b; if ($div_start) { $extra = trim(preg_replace('#\\{div(.*)\\}#si', '\\1', $div_start)); $div = ''; if ($extra) { $extra = explode('|', $extra); $extras = new stdClass(); foreach ($extra as $e) { if (strpos($e, ':') !== false) { list($key, $val) = explode(':', $e, 2); $extras->{$key} = $val; } } if (isset($extras->class)) { $div .= 'class="' . $extras->class . '"'; } $style = array(); if (isset($extras->width)) { if (is_numeric($extras->width)) { $extras->width .= 'px'; } $style[] = 'width:' . $extras->width; } if (isset($extras->height)) { if (is_numeric($extras->height)) { $extras->height .= 'px'; } $style[] = 'height:' . $extras->height; } if (isset($extras->align)) { $style[] = 'float:' . $extras->align; } else { if (isset($extras->float)) { $style[] = 'float:' . $extras->float; } } if (!empty($style)) { $div .= ' style="' . implode(';', $style) . ';"'; } } $html = trim('<div ' . trim($div)) . '>' . $html . '</div>'; $html = $p_end . $html . $p_start; } else { $html = $p_start . $html . $p_end; } nnText::fixHtmlTagStructure($html); } if ($this->params->place_comments) { $html = $this->params->comment_start . $html . $this->params->comment_end; } $string = str_replace($match['0'], $html, $string); unset($match); return 1; }
/** * combine attribute values in a tag string */ public static function combineAttributes($string1, $string2) { $attribs1 = is_array($string1) ? $string1 : nnText::getAttributes($string1); $attribs2 = is_array($string2) ? $string2 : nnText::getAttributes($string2); $dublicate_attribs = array_intersect_key($attribs1, $attribs2); // Fill $attribs with the unique ids $attribs = array_diff_key($attribs1, $attribs2) + array_diff_key($attribs2, $attribs1); // Add/combine the duplicate ids $single_value_attributes = array('id', 'href'); foreach ($dublicate_attribs as $key => $val) { if (in_array($key, $single_value_attributes)) { $attribs[$key] = $attribs2[$key]; continue; } // Combine strings, but remove duplicates // "aaa bbb" + "aaa ccc" = "aaa bbb ccc" // use a ';' as a concatenated for javascript values (keys beginning with 'on') $glue = substr($key, 0, 2) == 'on' ? ';' : ' '; $attribs[$key] = implode($glue, array_merge(explode($glue, $attribs1[$key]), explode($glue, $attribs2[$key]))); } foreach ($attribs as $key => &$val) { $val = $key . '="' . $val . '"'; } return implode(' ', $attribs); }
function getItems() { $query = $this->db->getQuery(true)->select('COUNT(*)')->from('#__k2_items AS i')->where('i.published > -1'); $this->db->setQuery($query); $total = $this->db->loadResult(); if ($total > $this->max_list_count) { return -1; } $query->clear()->select('i.id, i.title as name, c.name as cat, i.published')->from('#__k2_items AS i')->join('LEFT', '#__k2_categories AS c ON c.id = i.catid')->where('i.published > -1')->order('i.title, i.ordering, i.id'); $this->db->setQuery($query); $list = $this->db->loadObjectList(); // assemble items to the array $options = array(); foreach ($list as $item) { $item->name = $item->name . ' [' . $item->id . ']' . ($item->cat ? ' [' . $item->cat . ']' : ''); $item->name = nnText::prepareSelectItem($item->name, $item->published); $options[] = JHtml::_('select.option', $item->id, $item->name, 'value', 'text', 0); } return $options; }
function onAfterRender() { // only in html if (JFactory::getDocument()->getType() !== 'html' && JFactory::getDocument()->getType() !== 'feed') { return; } $html = JResponse::getBody(); if ($html == '') { return; } if (strpos($html, '{' . $this->params->tag) === false) { if (!$this->params->hasitems) { // remove style and script if no items are found $html = preg_replace('#\\s*<' . 'link [^>]*href="[^"]*/(tooltips/css|css/tooltips)/[^"]*\\.css[^"]*"[^>]* />#s', '', $html); $html = preg_replace('#\\s*<' . 'script [^>]*src="[^"]*/(tooltips/js|js/tooltips)/[^"]*\\.js[^"]*"[^>]*></script>#s', '', $html); $html = preg_replace('#/\\* START: Tooltips .*?/\\* END: Tooltips [a-z]* \\*/\\s*#s', '', $html); } } else { // only do stuff in body list($pre, $body, $post) = nnText::getBody($html); $this->protect($body); $this->replaceTags($body); $html = $pre . $body . $post; $this->unprotect($html); } $this->cleanLeftoverJunk($html); JResponse::setBody($html); }
function onAfterRender() { // not in pdf's if (JFactory::getDocument()->getType() == 'pdf') { return; } $html = JResponse::getBody(); if ($html == '') { return; } if (JFactory::getDocument()->getType() != 'html') { $this->replaceTags($html); $this->cleanLeftoverJunk($html); } else { // only do stuff in body list($pre, $body, $post) = nnText::getBody($html); $this->protect($body); $this->replaceTags($body); $html = $pre . $body . $post; $this->cleanLeftoverJunk($html); NNProtect::unprotect($html); // replace head with newly generated head // this is necessary because the plugins might have added scripts/styles to the head $orig_document = clone JFactory::getDocument(); $this->updateHead($html, $orig_document); unset($orig_document); } JResponse::setBody($html); }
function getItems() { $query = $this->db->getQuery(true)->select('COUNT(*)')->from('#__zoo_item AS i')->where('i.state > -1'); $this->db->setQuery($query); $total = $this->db->loadResult(); if ($total > $this->max_list_count) { return -1; } $query->clear()->select('i.id, i.name, a.name as app, i.state as published')->from('#__zoo_item AS i')->join('LEFT', '#__zoo_application AS a ON a.id = i.application_id')->where('i.state > -1')->order('i.name, i.priority, i.id'); $this->db->setQuery($query); $list = $this->db->loadObjectList(); // assemble items to the array $options = array(); foreach ($list as $item) { $item->name = $item->name . ' [' . $item->id . '] [' . $item->app . ']'; $item->name = nnText::prepareSelectItem($item->name, $item->published); $options[] = JHtml::_('select.option', $item->id, $item->name, 'value', 'text', 0); } return $options; }
protected function getInput() { $this->params = $this->element->attributes(); JHtml::_('behavior.modal', 'a.modal'); $size = $this->get('size') ? 'style="width:' . $this->get('size') . 'px"' : ''; $multiple = $this->get('multiple'); $showtype = $this->get('showtype'); $showid = $this->get('showid'); $showinput = $this->get('showinput'); // load the list of modules $query = $this->db->getQuery(true)->select('m.id, m.title, m.position, m.module, m.published, m.language')->from('#__modules AS m')->where('m.client_id = 0')->where('m.published > -2')->order('m.position, m.title, m.ordering, m.id'); $this->db->setQuery($query); $modules = $this->db->loadObjectList(); // assemble menu items to the array $options = array(); $p = 0; foreach ($modules as $item) { if ($p !== $item->position) { $pos = $item->position; if ($pos == '') { $pos = ':: ' . JText::_('JNONE') . ' ::'; } $options[] = JHtml::_('select.option', '-', '[ ' . $pos . ' ]', 'value', 'text', true); } $p = $item->position; $item->title = $item->title; if ($showtype) { $item->title .= ' [' . $item->module . ']'; } if ($showinput || $showid) { $item->title .= ' [' . $item->id . ']'; } if ($item->language && $item->language != '*') { $item->title .= ' (' . $item->language . ')'; } $item->title = nnText::prepareSelectItem($item->title, $item->published); $options[] = JHtml::_('select.option', $item->id, $item->title); } if ($showinput) { array_unshift($options, JHtml::_('select.option', '-', ' ', 'value', 'text', true)); array_unshift($options, JHtml::_('select.option', '-', '- ' . JText::_('Select Item') . ' -')); if ($multiple) { $onchange = 'if ( this.value ) { if ( ' . $this->id . '.value ) { ' . $this->id . '.value+=\',\'; } ' . $this->id . '.value+=this.value; } this.value=\'\';'; } else { $onchange = 'if ( this.value ) { ' . $this->id . '.value=this.value;' . $this->id . '_text.value=this.options[this.selectedIndex].innerHTML.replace( /^((&|&| )nbsp;|-)*/gm, \'\' ).trim(); } this.value=\'\';'; } $attribs = 'class="inputbox" onchange="' . $onchange . '"'; $html = '<table cellpadding="0" cellspacing="0"><tr><td style="padding: 0px;">' . "\n"; if (!$multiple) { $val_name = $this->value; if ($this->value) { foreach ($modules as $item) { if ($item->id == $this->value) { $val_name = $item->title; if ($showtype) { $val_name .= ' [' . $item->module . ']'; } $val_name .= ' [' . $this->value . ']'; break; } } } $html .= '<input type="text" id="' . $this->id . '_text" value="' . $val_name . '" class="inputbox" ' . $size . ' disabled="disabled" />'; $html .= '<input type="hidden" name="' . $this->name . '" id="' . $this->id . '" value="' . $this->value . '" />'; } else { $html .= '<input type="text" name="' . $this->name . '" id="' . $this->id . '" value="' . $this->value . '" class="inputbox" ' . $size . ' />'; } $html .= '</td><td style="padding: 0px;"padding-left: 5px;>' . "\n"; $html .= JHtml::_('select.genericlist', $options, '', $attribs, 'value', 'text', '', ''); $html .= '</td></tr></table>' . "\n"; } else { $attr = $size; $attr .= $multiple ? ' multiple="multiple"' : ''; $attr .= ' class="input-xxlarge"'; $html = JHtml::_('select.genericlist', $options, $this->name, trim($attr), 'value', 'text', $this->value, $this->id); $html = '<div class="input-maximize">' . $html . '</div>'; } return preg_replace('#>\\[\\[\\:(.*?)\\:\\]\\]#si', ' style="\\1">', $html); }
function getProducts() { $query = $this->db->getQuery(true)->select('COUNT(*)')->from('#__redshop_product AS p')->where('p.published > -1'); $this->db->setQuery($query); $total = $this->db->loadResult(); if ($total > $this->max_list_count) { return -1; } $query->clear()->select('p.product_id as id, p.product_name AS name, p.product_number as number, c.category_name AS cat, p.published')->from('#__redshop_product AS p')->join('LEFT', '#__redshop_product_category_xref AS x ON x.product_id = p.product_id')->join('LEFT', '#__redshop_category AS c ON c.category_id = x.category_id')->where('p.published > -1')->order('p.product_name, p.product_number'); $this->db->setQuery($query); $list = $this->db->loadObjectList(); // assemble items to the array $options = array(); foreach ($list as $item) { $item->name = $item->name . ' [' . $item->number . ']' . ($item->cat ? ' [' . $item->cat . ']' : ''); $item->name = nnText::prepareSelectItem($item->name, $item->published); $options[] = JHtml::_('select.option', $item->id, $item->name, 'value', 'text', 0); } return $options; }
protected function getInput() { $this->params = $this->element->attributes(); JHtml::stylesheet('nnframework/style.min.css', false, true); $label = nnText::html_entity_decoder(JText::_($this->get('label'))); $description = $this->get('description'); $lang_file = $this->get('language_file'); $show_apply = $this->get('show_apply'); $html = '</td></tr></table></div></div>'; $html .= '<div class="panel"><h3 class="jpane-toggler title" id="advanced-page"><span>'; $html .= $label; $html .= '</span></h3>'; $html .= '<div class="jpane-slider content"><table width="100%" class="paramlist admintable" cellspacing="1"><tr><td colspan="2" class="paramlist_value">'; if ($description) { // variables $v1 = $this->get('var1'); $v2 = $this->get('var2'); $v3 = $this->get('var3'); $v4 = $this->get('var4'); $v5 = $this->get('var5'); $description = nnText::html_entity_decoder(trim(JText::sprintf($description, $v1, $v2, $v3, $v4, $v5))); } if ($lang_file) { jimport('joomla.filesystem.file'); // Include extra language file $language = JFactory::getLanguage(); $lang = str_replace('_', '-', $language->getTag()); $inc = ''; $lang_path = 'language/' . $lang . '/' . $lang . '.' . $lang_file . '.inc.php'; if (JFile::exists(JPATH_ADMINISTRATOR . '/' . $lang_path)) { $inc = JPATH_ADMINISTRATOR . '/' . $lang_path; } else { if (JFile::exists(JPATH_SITE . '/' . $lang_path)) { $inc = JPATH_SITE . '/' . $lang_path; } } if (!$inc && $lang != 'en-GB') { $lang = 'en-GB'; $lang_path = 'language/' . $lang . '/' . $lang . '.' . $lang_file . '.inc.php'; if (JFile::exists(JPATH_ADMINISTRATOR . '/' . $lang_path)) { $inc = JPATH_ADMINISTRATOR . '/' . $lang_path; } else { if (JFile::exists(JPATH_SITE . '/' . $lang_path)) { $inc = JPATH_SITE . '/' . $lang_path; } } } if ($inc) { include $inc; } } if ($description) { $description = str_replace('span style="font-family:monospace;"', 'span class="nn_code"', $description); if ($description['0'] != '<') { $description = '<p>' . $description . '</p>'; } $class = 'nn_panel nn_panel_description'; $html .= '<div class="' . $class . '"><div class="nn_block nn_title">'; if ($show_apply) { $apply_button = '<a href="#" onclick="submitbutton( \'apply\' );" title="' . JText::_('Apply') . '"><img align="right" border="0" alt="' . JText::_('Apply') . '" src="images/tick.png"/></a>'; $html .= $apply_button; } $html .= $description; $html .= '<div style="clear: both;"></div></div></div>'; } return $html; }