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->def('label'); $param_name = $this->def('name'); $noshow = $this->def('noshow', 0); $showclose = $this->def('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 fixLanguageStringSyntax($string = '') { $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(); 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); }
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->def('nostyle', 0); if ($title) { $title = NNText::html_entity_decoder(JText::_($title)); } if ($description) { // variables $v1 = JText::_($this->def('var1')); $v2 = JText::_($this->def('var2')); $v3 = JText::_($this->def('var3')); $v4 = JText::_($this->def('var4')); $v5 = JText::_($this->def('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); }
private function prepareText($str = '') { if ($str == '') { return ''; } // variables $v1 = JText::_($this->def('var1')); $v2 = JText::_($this->def('var2')); $v3 = JText::_($this->def('var3')); $v4 = JText::_($this->def('var4')); $v5 = JText::_($this->def('var5')); $str = JText::sprintf(JText::_($str), $v1, $v2, $v3, $v4, $v5); $str = trim(NNText::html_entity_decoder($str)); $str = str_replace('"', '"', $str); $str = str_replace('span style="font-family:monospace;"', 'span class="nn_code"', $str); return $str; }
private function prepareText($string = '') { $string = trim($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 getLabel() { $this->params = $this->element->attributes(); $resize = $this->get('resize', 0); $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; if ($resize) { JHtml::_('jquery.framework'); NNFrameworkFunctions::addScriptVersion(JUri::root(true) . '/media/nnframework/js/script.min.js'); JHtml::stylesheet('nnframework/style.min.css', false, true); $html .= '<br /><span role="button" class="nn_resize_textarea nn_maximize"' . ' data-id="' . $this->id . '" data-min="' . $this->get('height', 80) . '" data-max="' . $resize . '">' . '<span class="nn_resize_textarea_maximize">' . '[ + ]' . '</span>' . '<span class="nn_resize_textarea_minimize">' . '[ - ]' . '</span>' . '</span>'; } $html .= '</label>'; return $html; }
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'); $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 ($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); }
private function getArticleId($id, $type = 'article', $ignores = array()) { if (isset($this->articles[$type . '_' . $id])) { return $id; } if (isset($this->article_to_ids[$type . '_' . $id])) { return $this->article_to_ids[$type . '_' . $id]; } $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('a.id'); $table = 'content'; $query->from('#__' . $table . ' as a'); $where = 'a.title = ' . $db->quote(NNText::html_entity_decoder($id)); $where .= ' OR a.alias = ' . $db->quote(NNText::html_entity_decoder($id)); if (is_numeric($id)) { $where .= ' OR a.id = ' . $id; } $query->where('(' . $where . ')'); $ignore_language = isset($ignores['ignore_language']) ? $ignores['ignore_language'] : $this->params->ignore_language; if (!$ignore_language) { $query->where('a.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')'); } $ignore_state = isset($ignores['ignore_state']) ? $ignores['ignore_state'] : $this->params->ignore_state; if (!$ignore_state) { $jnow = JFactory::getDate(); $now = $jnow->toSql(); $nullDate = $db->getNullDate(); $where = 'a.state = 1'; $query->where($where)->where('( a.publish_up = ' . $db->quote($nullDate) . ' OR a.publish_up <= ' . $db->quote($now) . ' )')->where('( a.publish_down = ' . $db->quote($nullDate) . ' OR a.publish_down >= ' . $db->quote($now) . ' )'); } $ignore_access = isset($ignores['ignore_access']) ? $ignores['ignore_access'] : $this->params->ignore_access; if (!$ignore_access) { $query->where('a.access IN(' . implode(', ', $this->aid) . ')'); } $query->order('a.ordering'); $db->setQuery($query); $this->article_to_ids[$type . '_' . $id] = $db->loadResult(); return $this->article_to_ids[$type . '_' . $id]; }
protected function getInput() { $this->params = $this->element->attributes(); JHtml::stylesheet('nnframework/style.min.css', false, true); $title = $this->get('label'); $description = $this->get('description'); $xml = $this->get('xml'); $url = $this->get('url'); 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 ($title) { $title = JText::_($title); } if ($description) { $description = str_replace('span style="font-family:monospace;"', 'span class="nn_code"', $description); if ($description['0'] != '<') { $description = '<p>' . $description . '</p>'; } } if (!$xml && $this->form->getValue('element')) { if ($this->form->getValue('folder')) { $xml = 'plugins/' . $this->form->getValue('folder') . '/' . $this->form->getValue('element') . '/' . $this->form->getValue('element') . '.xml'; } else { $xml = 'administrator/modules/' . $this->form->getValue('element') . '/' . $this->form->getValue('element') . '.xml'; } } if ($xml) { $xml = JApplicationHelper::parseXMLInstallFile(JPATH_SITE . '/' . $xml); $version = 0; if ($xml && isset($xml['version'])) { $version = $xml['version']; } if ($version) { if (strpos($version, 'PRO') !== false) { $version = str_replace('PRO', '', $version); $version .= ' <small style="color:green">[PRO]</small>'; } else { if (strpos($version, 'FREE') !== false) { $version = str_replace('FREE', '', $version); $version .= ' <small style="color:green">[FREE]</small>'; } } if ($title) { $title .= ' v'; } else { $title = JText::_('Version') . ' '; } $title .= $version; } } $html = array(); if ($title) { if ($url) { $title = '<a href="' . $url . '" target="_blank" title="' . preg_replace('#<[^>]*>#', '', $title) . '">' . $title . '</a>'; } $html[] = '<h4>' . NNText::html_entity_decoder($title) . '</h4>'; } if ($description) { $html[] = $description; } if ($url) { $html[] = '<p><a href="' . $url . '" target="_blank" title="' . JText::_('NN_MORE_INFO') . '">' . JText::_('NN_MORE_INFO') . '...</a></p>'; } return '</div><div>' . implode('', $html); }
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); }
protected function getInput() { $this->params = $this->element->attributes(); $label = NNText::html_entity_decoder(JText::_($this->def('label'))); $description = $this->def('description'); $lang_file = $this->def('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 ($description) { // variables $v1 = $this->def('var1'); $v2 = $this->def('var2'); $v3 = $this->def('var3'); $v4 = $this->def('var4'); $v5 = $this->def('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">'; $html .= $description; $html .= '<div style="clear: both;"></div></div></div>'; } return $html; }
protected function getInput() { $this->params = $this->element->attributes(); JHtml::stylesheet('nnframework/style.min.css', false, true); $title = $this->def('label'); $description = $this->def('description'); $xml = $this->def('xml'); $lang_file = $this->def('language_file'); $image = $this->def('image'); $image_w = $this->def('image_w'); $image_h = $this->def('image_h'); $url = $this->def('url'); $help_url = $this->def('help_url'); if ($description) { // variables $v1 = $this->def('var1'); $v2 = $this->def('var2'); $v3 = $this->def('var3'); $v4 = $this->def('var4'); $v5 = $this->def('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 ($title) { $title = JText::_($title); } if ($description) { $description = str_replace('span style="font-family:monospace;"', 'span class="nn_code"', $description); if ($description['0'] != '<') { $description = '<p>' . $description . '</p>'; } } if ($xml) { $xml = JApplicationHelper::parseXMLInstallFile(JPATH_SITE . '/' . $xml); $version = 0; if ($xml && isset($xml['version'])) { $version = $xml['version']; } if ($version) { if (!(strpos($version, 'PRO') === false)) { $version = str_replace('PRO', '', $version); $version .= ' <small style="color:green">[PRO]</small>'; } else { if (!(strpos($version, 'FREE') === false)) { $version = str_replace('FREE', '', $version); $version .= ' <small style="color:green">[FREE]</small>'; } } if ($title) { $title .= ' v'; } else { $title = JText::_('Version') . ' '; } $title .= $version; } } if ($url) { $url = '<a href="' . $url . '" target="_blank" title="' . preg_replace('#<[^>]*>#', '', $title) . '">'; } $html = array(); $html[] = '<div class="nn_panel"><div class="nn_block nn_title">'; if ($image) { $image = str_replace('/', "\n", str_replace('\\', '/', $image)); $image = explode("\n", trim($image)); if ($image['0'] == 'administrator') { $image['0'] = JURI::base(true); } else { $image['0'] = JURI::root(true) . '/' . $image['0']; } $image = '<img src="' . implode('/', $image) . '" border="0" style="float:right;margin-left:10px" alt=""'; if ($image_w) { $image .= ' width="' . $image_w . '"'; } if ($image_h) { $image .= ' height="' . $image_h . '"'; } $image .= ' />'; if ($url) { $image = $url . $image . '</a>'; } $html[] = $image; } if ($title) { if ($url) { $title = $url . $title . '</a>'; } $html[] = '<h4 style="margin: 0px;">' . NNText::html_entity_decoder($title) . '</h4>'; } if ($description) { $html[] = $description; } if ($help_url) { $html[] = '<p><a href="' . $help_url . '" target="_blank" title="' . JText::_('NN_MORE_INFO') . '">' . JText::_('NN_MORE_INFO') . '...</a></p>'; } $html[] = '<div style="clear: both;"></div>'; $html[] = '</div></div>'; return implode('', $html); }
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; }
protected function getInput() { $start = $this->def('start'); $end = $this->def('end'); $blocktype = $this->def('blocktype'); if ($blocktype == 'spacer') { return ''; } JHtml::stylesheet('nnframework/style.min.css', false, true); if ($end) { $html = ''; $html .= '<div style="clear: both;"></div></li></ul>'; $html .= '</div></div>'; return $html; } $description = $this->def('description'); $nostyle = $this->def('nostyle'); $title = $this->def('label'); $lang_file = $this->def('language_file'); $message_type = $this->def('message_type'); $image = $this->def('image'); $image_w = $this->def('image_w'); $image_h = $this->def('image_h'); $show_apply = $this->def('show_apply'); $toggle = $this->def('toggle'); $tooltip = $this->def('tooltip'); // The main url $url = $this->def('url'); $help = $this->def('help_url'); $extension = $this->def('extension'); $xml = $this->def('xml'); $version = $this->def('version'); $version_file = $this->def('version_file'); if (!$extension) { $extension = str_replace('version_', '', $version_file); } $msg = ''; if ($description) { // variables $v1 = $this->def('var1'); $v2 = $this->def('var2'); $v3 = $this->def('var3'); $v4 = $this->def('var4'); $v5 = $this->def('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 (!$nostyle && $description['0'] != '<') { $description = '<p>' . $description . '</p>'; } } if ($nostyle && $description) { return $description; } if ($title) { $title = JText::_($title); } $user = JFactory::getUser(); if (strlen($version) && strlen($version_file) && ($user->usertype == 'Super Administrator' || $user->usertype == 'Administrator')) { // Import library dependencies require_once JPATH_PLUGINS . '/system/nnframework/helpers/versions.php'; $versions = NNVersions::getInstance(); $msg = $versions->getMessage($extension, $xml, $version); if ($version) { if (!(strpos($version, 'PRO') === false)) { $version = str_replace('PRO', '', $version); $version .= ' <small>[PRO]</small>'; } else { if (!(strpos($version, 'FREE') === false)) { $version = str_replace('FREE', '', $version); $version .= ' <small>[FREE]</small>'; } } if ($title) { $title .= ' v' . $version; } else { $title = JText::_('Version') . ' ' . $version; } } } else { if ($xml) { $xml = JApplicationHelper::parseXMLInstallFile(JPATH_SITE . '/' . $xml); if ($xml && isset($xml['version'])) { $version = $xml['version']; } if ($version) { if ($title) { $title .= ' v' . $version; } else { $title = JText::_('Version') . ' ' . $version; } } } } if ($url) { $url = '<a href="' . $url . '" target="_blank" title="' . $title . '">'; } if ($image) { $image = str_replace('/', "\n", str_replace('\\', '/', $image)); $image = explode("\n", trim($image)); if ($image['0'] == 'administrator') { $image['0'] = JURI::base(true); } else { $image['0'] = JURI::root(true) . '/' . $image['0']; } $image = $url . '<img src="' . implode('/', $image) . '" border="0" style="float:right;margin-left:10px" alt=""'; if ($image_w) { $image .= ' width="' . $image_w . '"'; } if ($image_h) { $image .= ' height="' . $image_h . '"'; } $image .= ' />'; if ($url) { $image .= '</a>'; } } if ($url) { $title = $url . $title . '</a>'; } if ($help) { $help = '<a href="' . $help . '" target="_blank" title="' . JText::_('NN_MORE_INFO') . '">' . JText::_('NN_MORE_INFO') . '...</a>'; } if ($title) { $title = NNText::html_entity_decoder($title); } $html = ''; if ($image) { $html .= $image; } if ($show_apply) { $onclick = ''; $bar = JToolBar::getInstance('toolbar'); foreach ($bar->getItems() as $b) { if (isset($b['3']) && $b['1'] == 'apply') { $onclick = 'Joomla.submitbutton(\'' . $b['3'] . '\')'; } } if ($onclick) { $html .= '<a href="#" onclick="' . $onclick . '" title="' . JText::_('Apply') . '"><img style="float:right;" border="0" alt="' . JText::_('Apply') . '" src="' . JURI::root() . 'media/nnframework/images/tick.png"/></a>'; } } if ($toggle && $description) { $el = 'document.getElementById( \'' . $this->id . 'description\' )'; $onclick = 'if( this.innerHTML == \'' . JText::_(JText::_('Show') . ' ' . $title) . '\' ){' . $el . '.style.display = \'block\';' . 'this.innerHTML = \'' . JText::_(JText::_('Hide') . ' ' . $title) . '\';' . '}else{' . $el . '.style.display = \'none\';' . 'this.innerHTML = \'' . JText::_(JText::_('Show') . ' ' . $title) . '\';' . '}' . 'this.blur();return false;'; $html .= '<div class="button2-left" style="margin:0px 0px 5px 0px;"><div class="blank"><a href="javascript://;" onclick="' . $onclick . '">' . JText::_(JText::_('Show') . ' ' . $title) . '</a></div></div>' . "\n"; $html .= '<br clear="all" />'; $html .= '<div id="' . $this->id . 'description" style="display:none;">'; } else { if ($title) { $html .= '<h4 style="margin: 0px;">' . $title . '</h4>'; } } if ($description && !$tooltip) { $html .= $description; } if ($help) { $html .= '<p>' . $help . '</p>'; } if ($description) { $html = '<div class="nn_block nn_title">' . $html . '</div>'; } if ($toggle && $description) { $html .= '</div>'; } if ($message_type) { $html = '<dl id="system-message"><dd class="' . $message_type . '"><ul><li>' . NNText::html_entity_decoder($html) . '</li></ul></dd></dl>'; } else { if (!$nostyle) { $class = 'nn_panel'; $html = '<div class="' . $class . '"><div class="nn_block nn_title">' . $html . '<div style="clear: both;"></div>'; } if ($start) { $html .= '<ul class="adminformlist"><li>'; } else { $html .= '</div></div>'; } } if ($msg) { $html = $msg . $html; } return $html; }
protected function getInput() { $this->params = $this->element->attributes(); require_once __DIR__ . '/toggler.php'; $toggler = new nnFieldToggler(); $this->value = (int) $this->value; $label = $this->def('label'); $param_name = $this->def('name'); $noshow = $this->def('noshow', 0); $showclose = $this->def('showclose', 0); $html = array(); if ($label) { $label = NNText::html_entity_decoder(JText::_($label)); $html[] = '<div style="clear: both;"></div>'; if (!$noshow) { $html[] = $toggler->getInput(array('div' => 1, 'param' => 'show_assignments|' . $param_name, 'value' => '1|1,2')); } $class = 'nn_panel nn_panel_title nn_panel_toggle'; if ($this->value === 1) { $class .= ' nn_panel_include'; } else { if ($this->value === 2) { $class .= ' nn_panel_exclude'; } } $html[] = '<div class="' . $class . '">'; if ($showclose && JFactory::getUser()->authorise('core.admin')) { $html[] = '<button type="button" class="nn_close nn_remove_assignment">×</button>'; } $html[] = '<label class="nn_block nn_title" for="cb_' . $param_name . '">'; $html[] = '<input id="cb_' . $param_name . '" type="checkbox" class="checkbox" ' . ($this->value ? 'checked="checked"' : '') . ' onchange="nnScripts.setRadio(\'' . $param_name . '\', this.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>'; $label = JText::_('NN_SELECTION'); $tip = htmlspecialchars(trim($label, ':') . '::' . JText::_('NN_SELECTION_DESC'), ENT_COMPAT, 'UTF-8'); $html[] = '<label id="' . $this->id . '-lbl" for="' . $this->id . '" class="hasTip" title="' . $tip . '">' . $label . '</label>'; $html[] = '<fieldset id="' . $this->id . '" class="radio">'; $html[] = '<div style="display:none;">'; $onclick = ' onclick="nnScripts.setToggleTitleClass(this, 0, 8)"'; $html[] = '<input type="radio" id="' . $this->id . '0" name="' . $this->name . '" value="0"' . (!$this->value ? ' checked="checked"' : '') . $onclick . '/>'; $html[] = '</div>'; $onclick = ' onclick="nnScripts.setToggleTitleClass(this, 1, 7)"'; $html[] = '<input type="radio" id="' . $this->id . '1" name="' . $this->name . '" value="1"' . ($this->value === 1 ? ' checked="checked"' : '') . $onclick . '/>'; $html[] = '<label for="' . $this->id . '1">' . JText::_('NN_INCLUDE') . '</label>'; $onclick = ' onclick="nnScripts.setToggleTitleClass(this, 2, 7)"'; $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 for="' . $this->id . '2">' . JText::_('NN_EXCLUDE') . '</label>'; $html[] = '</fieldset>'; } else { $html[] = '<div style="clear: both;"></div>'; $html[] = '</li></ul>'; $html[] = '<div style="clear: both;"></div>'; $html[] = '</div></div>'; if (!$noshow) { $html[] = $toggler->getInput(array('div' => 1)); } $html[] = $toggler->getInput(array('div' => 1)); } return implode($html); }
function processArticle($id, $art, $text = '', $type = 'article', $ignores = array(), $first = 0) { if (!$first) { // do second pass $text = $this->processArticle($id, $art, $text, $type, $ignores, 1); } if ($first) { // first pass: search for normal tags and tags around tags $regex = '#\\{(/?(?:[^\\}]*\\{[^\\}]*\\})*[^\\}]*)\\}#si'; } else { $regex_close = '#\\{/' . $this->params->tags . '\\}#si'; if (preg_match($regex_close, $text)) { return $text; } // second pass: only search for normal tags $regex = '#\\{(/?[^\\{\\}]+)\\}#si'; } if (!preg_match_all($regex, $text, $matches, PREG_SET_ORDER)) { return $text; } $db = JFactory::getDBO(); $query = $db->getQuery(true); $type = $type == 'k2' && !$this->params->dbselects_k2 ? '' : $type; $selects = $type == 'k2' ? $this->params->dbselects_k2 : $this->params->dbselects_content; if (in_array($id, array('current', 'self', '{id}', '{title}', '{alias}'))) { if (isset($art->id)) { $id = $art->id; } else { if (isset($art->link) && preg_match('#&id=([0-9]*)#', $art->link, $match)) { $id = $match['1']; } else { if ($this->option == 'com_content' && JFactory::getApplication()->input->get('view') == 'article') { $id = JFactory::getApplication()->input->getInt('id', 0); } } } } foreach ($matches as $match) { $data = trim($match['1']); if (!(strpos($data, 'intro') === false)) { $selects[] = 'introtext'; } else { if (!(strpos($data, 'full') === false)) { $selects[] = 'fulltext'; } else { if (!(strpos($data, 'text') === false)) { $selects[] = 'introtext'; $selects[] = 'fulltext'; } } } } $selects = array_unique($selects); $selects = 'a.`' . implode('`, a.`', $selects) . '`'; $query->select($selects); if ($type == 'article') { $query->select('CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END AS slug')->select('CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(":", c.id, c.alias) ELSE c.id END AS catslug')->select('c.parent_id AS parent')->join('LEFT', '#__categories AS c ON c.id = a.catid'); } $query->from('#__content as a'); $where = 'a.title = ' . $db->quote(NNText::html_entity_decoder($id)); $where .= ' OR a.alias = ' . $db->quote(NNText::html_entity_decoder($id)); if (is_numeric($id)) { $where .= ' OR a.id = ' . $id; } $query->where('(' . $where . ')'); $ignore_language = isset($ignores['ignore_language']) ? $ignores['ignore_language'] : $this->params->ignore_language; if (!$ignore_language) { $query->where('a.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')'); } $ignore_state = isset($ignores['ignore_state']) ? $ignores['ignore_state'] : $this->params->ignore_state; if (!$ignore_state) { $jnow = JFactory::getDate(); $now = $jnow->toSQL(); $nullDate = $db->getNullDate(); if ($type == 'k2') { $query->where('a.published = 1 AND trash = 0'); } else { $query->where('a.state = 1'); } $query->where('( a.publish_up = ' . $db->quote($nullDate) . ' OR a.publish_up <= ' . $db->quote($now) . ' )')->where('( a.publish_down = ' . $db->quote($nullDate) . ' OR a.publish_down >= ' . $db->quote($now) . ' )'); } $ignore_access = isset($ignores['ignore_access']) ? $ignores['ignore_access'] : $this->params->ignore_access; if (!$ignore_access) { $query->where('a.access IN(' . implode(', ', $this->params->aid) . ')'); } $query->order('a.ordering'); $db->setQuery($query); $article = $db->loadObject(); if (!$article) { return '<!-- ' . JText::_('AA_ACCESS_TO_ARTICLE_DENIED') . ' -->'; } if (isset($article->attribs)) { self::addParams($article, json_decode($article->attribs)); } else { if (isset($article->params)) { self::addParams($article, json_decode($article->params)); } } if (isset($article->images)) { self::addParams($article, json_decode($article->images)); } if (isset($article->urls)) { self::addParams($article, json_decode($article->urls)); } $ifregex = '#\\{if:([^\\}]+)\\}(.*?)(?:\\{else\\}(.*?))?\\{/if\\}#si'; if (preg_match_all($ifregex, $text, $ifs, PREG_SET_ORDER) > 0) { foreach ($ifs as $if) { $eval = trim($if['1']); if (preg_match('#(^.*?[><=]\\s*([\'"]))(.*)\\2#si', $eval, $match)) { $eval = str_replace($match['0'], $match['1'] . html_entity_decode($match['3']) . $match['2'], $eval); } $eval = str_replace('=', '==', $eval); $eval = '$pass = ( ( $article->' . $eval . ' ) ? 1 : 0 );'; $eval = str_replace('$article->!', '!$article->', $eval); // trim the text that needs to be checked and replace weird spaces $eval = preg_replace('#(\\$article->[a-z0-9-_]*)#', 'trim(str_replace(chr(194) . chr(160), " ", \\1))', $eval); $pass = 0; eval($eval); if (!$pass) { $text = str_replace($if['0'], isset($if['3']) ? $if['3'] : '', $text); } else { $text = str_replace($if['0'], $if['2'], $text); } } } if (!preg_match_all($regex, $text, $matches, PREG_SET_ORDER)) { return $text; } foreach ($matches as $match) { $data = trim($match['1']); $ok = 0; $str = ''; $data = explode(':', $data, 2); $tag = trim($data['0']); $extra = isset($data['1']) ? trim($data['1']) : ''; if ($tag == '/link') { $str = '</a>'; $ok = 1; } else { if ($tag == '/div') { $str = '</div>'; $ok = 1; } else { if ($tag == 'div' || strpos($tag, 'div ') === 0) { if ($tag != 'div') { $extra = str_replace('div ', '', $tag) . ':' . $extra; } $str = ''; 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)) { $str .= '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)) { $str .= ' style="' . implode(';', $style) . ';"'; } } $str = trim('<div ' . trim($str)) . '>'; $ok = 1; } else { if ($tag == 'link' || $tag == 'url' || !(strpos($tag, 'readmore') === false)) { if (isset($article->id)) { $slug = 'id=' . $article->slug; if ($article->catid) { $slug .= '&catid=' . $article->catslug; } $link = 'index.php?option=com_content&view=article&' . $slug; $component = JComponentHelper::getComponent('com_content'); $menus = JFactory::getApplication()->getMenu('site'); $menuitems = $menus->getItems('component_id', $component->id); $id = 0; if (is_array($menuitems)) { foreach ($menuitems as $item) { if (isset($item->query['view']) && $item->query['view'] == 'article' && isset($item->query['id']) && $item->query['id'] == $article->id) { $id = $item->id; break; } } if (!$id) { foreach ($menuitems as $item) { if (isset($item->query['view']) && in_array($item->query['view'], array('category', 'categories')) && isset($item->query['id']) && $item->query['id'] == $article->catid) { $id = $item->id; break; } } } if (!$id) { foreach ($menuitems as $item) { if (isset($item->query['view']) && in_array($item->query['view'], array('category', 'categories')) && isset($item->query['id']) && $item->query['id'] == $article->parent) { $id = $item->id; break; } } } } if ($id) { $link .= '&Itemid=' . $id; } $link = JRoute::_($link); if ($tag == 'link') { $str = '<a href="' . $link . '">'; } else { if ($tag == 'url') { $str = $link; } else { // load the content language file $lang = JFactory::getLanguage(); $lang->load('com_content'); $class = 'readmore'; $readmore = ''; if ($extra) { $extra = explode('|', $extra); if (trim($extra['0'])) { $readmore = JText::sprintf(trim($extra['0']), $article->title); if (!$readmore) { $readmore = $extra['0']; } } if (isset($extra['1'])) { $class = trim($extra['1']); } } if (!$readmore) { if (isset($article->alternative_readmore) && $article->alternative_readmore) { $readmore = $article->alternative_readmore; } else { if (!$this->params->config->get('show_readmore_title', 0)) { $readmore = JText::_('COM_CONTENT_READ_MORE_TITLE'); } else { $readmore = JText::_('COM_CONTENT_READ_MORE'); } } if ($this->params->config->get('show_readmore_title', 0)) { $readmore .= JHtml::_('string.truncate', $article->title, $this->params->config->get('readmore_limit')); } } if ($class == 'readmore') { $str = '<p class="' . $class . '"><a href="' . $link . '">' . $readmore . '</a></p>'; } else { $str = '<a class="' . $class . '" href="' . $link . '">' . $readmore . '</a>'; } } } $ok = 1; } } else { if ($tag == 'image-intro' && isset($article->image_intro) || $tag == 'image-fulltext' && isset($article->image_fulltext)) { if ($tag == 'image-intro') { $class = 'img-intro-' . htmlspecialchars($article->float_intro); $caption = $article->image_intro_caption ? 'class="caption" title="' . htmlspecialchars($article->image_intro_caption) . '" ' : ''; $src = htmlspecialchars($article->image_intro); $alt = htmlspecialchars($article->image_intro_alt); } else { $class = 'img-fulltext-' . htmlspecialchars($article->float_fulltext); $caption = $article->image_fulltext_caption ? 'class="caption" title="' . htmlspecialchars($article->image_fulltext_caption) . '" ' : ''; $src = htmlspecialchars($article->image_fulltext); $alt = htmlspecialchars($article->image_fulltext_alt); } $str = '<div class="' . $class . '"><img ' . $caption . 'src="' . $src . '" alt="' . $alt . '"/></div>'; $ok = 1; } else { if (strpos($tag, 'text') === 0 || strpos($tag, 'intro') === 0 || strpos($tag, 'full') === 0) { // TEXT data $article->text = ''; if (!(strpos($tag, 'intro') === false)) { if (isset($article->introtext)) { $article->text = $article->introtext; $ok = 1; } } else { if (!(strpos($tag, 'full') === false)) { if (isset($article->fulltext)) { $article->text = $article->fulltext; $ok = 1; } } else { if (!(strpos($tag, 'text') === false)) { if (isset($article->introtext) && isset($article->fulltext)) { $article->text = $article->introtext . $article->fulltext; $ok = 1; } } } } $str = $article->text; if ($extra) { $attribs = explode(':', $extra); $max = 0; $strip = 0; $noimages = 0; foreach ($attribs as $attrib) { $attrib = trim($attrib); switch ($attrib) { case 'strip': $strip = 1; break; case 'noimages': $noimages = 1; break; default: $max = $attrib; break; } } $word_limit = !(strpos($max, 'word') === false); if ($strip) { // remove pagenavcounter $str = preg_replace('#(<' . 'div class="pagenavcounter">.*?</div>)#si', ' ', $str); // remove pagenavbar $str = preg_replace('#(<' . 'div class="pagenavbar">(<div>.*?</div>)*</div>)#si', ' ', $str); // remove scripts $str = preg_replace('#(<' . 'script[^a-z0-9].*?</script>)#si', ' ', $str); $str = preg_replace('#(<' . 'noscript[^a-z0-9].*?</noscript>)#si', ' ', $str); // remove other tags $str = preg_replace('#(<' . '/?[a-z][a-z0-9]?.*?>)#si', ' ', $str); // remove double whitespace $str = trim(preg_replace('#\\s+#s', ' ', $str)); if ($max) { $orig_len = strlen($str); if ($word_limit) { // word limit $str = trim(preg_replace('#^(([^\\s]+\\s*){' . (int) $max . '}).*$#s', '\\1', $str)); if (strlen($str) < $orig_len) { if (preg_match('#[^a-z0-9]$#si', $str)) { $str .= ' '; } if ($this->params->use_ellipsis) { $str .= '...'; } } } else { // character limit $max = (int) $max; if ($max < $orig_len) { $str = rtrim(substr($str, 0, $max - 3)); if (preg_match('#[^a-z0-9]$#si', $str)) { $str .= ' '; } if ($this->params->use_ellipsis) { $str .= '...'; } } } } } else { if ($noimages) { // remove images $str = preg_replace('#(<p><' . 'img\\s.*?></p>|<' . 'img\\s.*?>)#si', ' ', $str); } } if (!$strip && $max && ($word_limit || (int) $max < strlen($str))) { $max = (int) $max; // store pagenavcounter & pagenav (exclude from count) preg_match('#<' . 'div class="pagenavcounter">.*?</div>#si', $str, $pagenavcounter); $pagenavcounter = isset($pagenavcounter['0']) ? $pagenavcounter['0'] : ''; if ($pagenavcounter) { $str = str_replace($pagenavcounter, '<!-- ARTA_PAGENAVCOUNTER -->', $str); } preg_match('#<' . 'div class="pagenavbar">(<div>.*?</div>)*</div>#si', $str, $pagenav); $pagenav = isset($pagenav['0']) ? $pagenav['0'] : ''; if ($pagenav) { $str = str_replace($pagenav, '<!-- ARTA_PAGENAV -->', $str); } // add explode helper strings around tags $explode_str = '<!-- ARTA_TAG -->'; $str = preg_replace('#(<\\/?[a-z][a-z0-9]?.*?>|<!--.*?-->)#si', $explode_str . '\\1' . $explode_str, $str); $str_array = explode($explode_str, $str); $str = array(); $tags = array(); $count = 0; $is_script = 0; foreach ($str_array as $i => $str_part) { if (fmod($i, 2)) { // is tag $str[] = $str_part; preg_match('#^<(\\/?([a-z][a-z0-9]*))#si', $str_part, $tag); if (!empty($tag)) { if ($tag['1'] == 'script') { $is_script = 1; } if (!$is_script && strpos($str_part, '/>') === false && !in_array($tag['2'], array('area', 'br', 'hr', 'img', 'input', 'param'))) { $tags[] = $tag['1']; } if ($tag['1'] == '/script') { $is_script = 0; } } } else { if ($is_script) { $str[] = $str_part; } else { if ($word_limit) { // word limit if ($str_part) { $words = explode(' ', trim($str_part)); $word_count = count($words); if ($max < $count + $word_count) { $words_part = array(); $word_count = 0; foreach ($words as $word) { if ($word) { $word_count++; } if ($max < $count + $word_count) { break; } $words_part[] = $word; } $string = rtrim(implode(' ', $words_part)); if (preg_match('#[^a-z0-9]$#si', $string)) { $string .= ' '; } if ($this->params->use_ellipsis) { $string .= '...'; } $str[] = $string; break; } $count += $word_count; } $str[] = $str_part; } else { // character limit if ($max < $count + strlen($str_part)) { // strpart has to be cut off $maxlen = $max - $count; if ($maxlen < 3) { $string = ''; if (preg_match('#[^a-z0-9]$#si', $str_part)) { $string .= ' '; } if ($this->params->use_ellipsis) { $string .= '...'; } $str[] = $string; } else { $string = rtrim(substr($str_part, 0, $maxlen - 3)); if (preg_match('#[^a-z0-9]$#si', $string)) { $string .= ' '; } if ($this->params->use_ellipsis) { $string .= '...'; } $str[] = $string; } break; } $count += strlen($str_part); $str[] = $str_part; } } } } // revers sort open tags krsort($tags); $tags = array_values($tags); $count = count($tags); for ($i = 0; $i < 3; $i++) { foreach ($tags as $ti => $tag) { if ($tag['0'] == '/') { for ($oi = $ti + 1; $oi < $count; $oi++) { $opentag = $tags[$oi]; if ($opentag == $tag) { break; } if ('/' . $opentag == $tag) { unset($tags[$ti]); unset($tags[$oi]); break; } } } } } foreach ($tags as $tag) { // add closing tag to end of string if ($tag['0'] != '/') { $str[] = '</' . $tag . '>'; } } $str = implode('', $str); $str = str_replace(array('<!-- ARTA_PAGENAVCOUNTER -->', '<!-- ARTA_PAGENAV -->'), array($pagenavcounter, $pagenav), $str); } } // Fix links in pagination to point to the included article instead of the main article // This doesn't seem to work correctly and causes issues with other links in the article // So commented out untill I find a better solution /*if ($art && isset($art->id) && $art->id) { $str = str_replace('view=article&id=' . $art->id, 'view=article&id=' . $article->id, $str); }*/ } else { if (ctype_alnum(str_replace(array('-', '_'), '', $tag))) { // Get data from db columns if (isset($article->{$tag})) { $str = $article->{$tag}; $ok = 1; } if ($ok && !(strpos($str, '-') == false) && !preg_match('#[a-z]#i', $str) && strtotime($str)) { if (!$extra) { $extra = JText::_('DATE_FORMAT_LC2'); } if (!(strpos($extra, '%') === false)) { $extra = NNText::dateToDateFormat($extra); } $str = JHtml::_('date', $str, $extra); } } } } } } } } if ($ok) { $text = str_replace($match['0'], $str, $text); } } return $text; }
static function html_entity_decoder($given_html, $quote_style = ENT_QUOTES, $charset = 'UTF-8') { require_once __DIR__ . '/text.php'; return NNText::html_entity_decoder($given_html, $quote_style, $charset); }