/**
	 * Test parseAttributes
	 *
	 * @param   string  $tag       tag to be parsed
	 * @param   array   $expected  resulting array of attribute values
	 *
	 * @return  void
	 *
	 * @dataProvider casesParseAttributes
	 * @covers  JUtility::parseAttributes
	 */
	public function testParseAttributes($tag, $expected)
	{
		$this->assertThat(
			JUtility::parseAttributes($tag),
			$this->equalTo($expected)
		);
	}
Example #2
0
 public static function parseJdocTags($data)
 {
     $replace = array();
     $matches = array();
     if (preg_match_all('#<jdoc:include\\ type="([^"]+)" (.*)\\/>#iU', $data, $matches)) {
         $matches[0] = array_reverse($matches[0]);
         $matches[1] = array_reverse($matches[1]);
         $matches[2] = array_reverse($matches[2]);
         $count = count($matches[1]);
         for ($i = 0; $i < $count; $i++) {
             $attribs = JUtility::parseAttributes($matches[2][$i]);
             $type = $matches[1][$i];
             if ($type != 'modules') {
                 continue;
             }
             $name = isset($attribs['name']) ? $attribs['name'] : null;
             if (empty($name)) {
                 continue;
             }
             unset($attribs['name']);
             jimport('joomla.application.module.helper');
             $modules = JModuleHelper::getModules($name);
             $moduleHtml = null;
             if (!empty($modules)) {
                 foreach ($modules as $module) {
                     $moduleHtml .= JModuleHelper::renderModule($module, $attribs);
                 }
             }
             $data = str_replace($matches[0][$i], $moduleHtml, $data);
         }
     }
     return $data;
 }
Example #3
0
 /**
  * Plugin that loads module positions within content
  *
  * @param   string $context The context of the content being passed to the plugin.
  * @param   object &$article The article object.  Note $article->text is also available
  * @param   mixed &$params The article params
  * @param   integer $page The 'page' number
  *
  * @return  mixed   true if there is an error. Void otherwise.
  *
  * @since   1.6
  */
 public function onContentPrepare($context, &$article, &$params, $page = 0)
 {
     // Don't run this plugin when the content is being indexed
     if ($context == 'com_finder.indexer') {
         return true;
     }
     // require_once( JURI::root(true).'/includes/domit/xml_saxy_lite_parser.php' );//xml_domit_lite_parser.php
     //$live_site = JURI::base();
     // Start IFRAME Replacement
     // define the regular expression for the bot
     $plugin = JPluginHelper::getPlugin('content', 'iframe');
     $pluginParams = new JRegistry($plugin->params);
     $regex = "#{iframe*(.*?)}(.*?){/iframe}#s";
     $plugin_enabled = $pluginParams->get('enabled', '1');
     if ($plugin_enabled == "0") {
         $article->text = preg_replace($regex, '', $article->text);
     } else {
         if (preg_match_all($regex, $article->text, $matches, PREG_SET_ORDER) > 0) {
             $db = JFactory::getDBO();
             //Ket noi CSDL
             $url = JRequest::getCmd('src');
             //JRequest::getCmd
             foreach ($matches as $match) {
                 $params0 = JUtility::parseAttributes($match[1]);
                 $params0['src'] = @$params0['src'] ? $params0['src'] : $pluginParams->get('src', 'http://www.luyenkim.net');
                 if ($url != '') {
                     if (strpos($url, 'http://') == false) {
                         $params0['src'] = 'http://' . $url;
                     }
                 }
                 //$params0['src'] = filter_var($params0['src'], FILTER_SANITIZE_URL);
                 $params0['height'] = @$params0['height'] ? $params0['height'] : $pluginParams->get('height', '400');
                 $params0['width'] = @$params0['width'] ? $params0['width'] : $pluginParams->get('width', '100%');
                 $params0['marginheight'] = @$params0['marginheight'] ? $params0['marginheight'] : $pluginParams->get('marginheight', '0');
                 $params0['marginwidth'] = @$params0['marginwidth'] ? $params0['marginwidth'] : $pluginParams->get('marginwidth', '0');
                 $params0['scrolling'] = @$params0['scrolling'] ? $params0['scrolling'] : $pluginParams->get('scrolling', '0');
                 $params0['frameborder'] = @$params0['frameborder'] ? $params0['frameborder'] : $pluginParams->get('frameborder', '0');
                 $params0['align'] = @$params0['align'] ? $params0['align'] : $pluginParams->get('align', 'bottom');
                 $params0['name'] = @$params0['name'] ? $params0['name'] : $pluginParams->get('name', '');
                 $params0['noframes'] = @$params0['noframes'] ? $params0['noframes'] : $pluginParams->get('noframes', '');
                 if (@$match[2]) {
                     $url = $match[2];
                 } else {
                     $url = $params0['src'];
                 }
                 $url = strip_tags(rtrim(ltrim($url)));
                 $name = $params0['name'];
                 $noframes = $params0['noframes'];
                 unset($params0['src']);
                 unset($params0['name']);
                 unset($params0['noframes']);
                 $article->text = preg_replace($regex, JHTML::iframe($url, $name, $params0, $noframes), $article->text, 1);
                 unset($params0);
             }
         }
         // End IFRAME Replacement
     }
     //end of else enable
 }
Example #4
0
 private function _parseParams($_params)
 {
     $clone = clone $this->params;
     if (!empty($_params)) {
         $array = JUtility::parseAttributes($_params);
         count($array) && $clone->loadArray($array);
         // 			if (count($array)){
         // 				foreach ($array as $param => $value){
         // 					$clone->set($param, $value);
         // 				}
         // 			}
     }
     return $clone;
 }
Example #5
0
 /**
  * @TODO
  *
  * @param string Block of text to parse
  * @return ComInstallerTemplateFilterBuffer
  */
 public function write(&$text)
 {
     $matches = array();
     if (preg_match_all('#<buffer([^>]*)/>#siU', $text, $matches)) {
         foreach ($matches[0] as $key => $match) {
             //Create attributes array
             $attributes = array('type' => 'modules', 'name' => '', 'render' => '');
             $attributes = array_merge($attributes, JUtility::parseAttributes($matches[1][$key]));
             $document = JFactory::getDocument();
             if ($attributes['render']) {
                 $replace = $document->getBuffer($attributes['type'], $attributes['name']);
             } else {
                 $buffer = $document->getBuffer();
                 $replace = $buffer[$attributes['type']][$attributes['name']];
             }
             $text = str_replace($match, $replace, $text);
         }
     }
     return $this;
 }
Example #6
0
 /**
  * Replaces the matched tags.
  *
  * @param   array  An array of matches (see preg_match_all)
  * @return  string
  */
 protected function _replace(&$matches)
 {
     jimport('joomla.utilities.utility');
     require_once __DIR__ . '/geshi/geshi.php';
     $args = JUtility::parseAttributes($matches[1]);
     $text = $matches[2];
     $lang = JArrayHelper::getValue($args, 'lang', 'php');
     $lines = JArrayHelper::getValue($args, 'lines', 'false');
     $html_entities_match = array("|\\<br \\/\\>|", "#<#", "#>#", "|&#39;|", '#&quot;#', '#&nbsp;#');
     $html_entities_replace = array("\n", '&lt;', '&gt;', "'", '"', ' ');
     $text = preg_replace($html_entities_match, $html_entities_replace, $text);
     $text = str_replace('&lt;', '<', $text);
     $text = str_replace('&gt;', '>', $text);
     $text = str_replace("\t", '  ', $text);
     $geshi = new GeSHi($text, $lang);
     if ($lines == 'true') {
         $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
     }
     $text = $geshi->parse_code();
     return $text;
 }
Example #7
0
 /**
  * Parse a document template
  *
  * @access public
  * @param string 	$data		The data too parse
  * @return The parsed contents of the template
  */
 function _parseTemplate($data)
 {
     $replace = array();
     $matches = array();
     if (preg_match_all('#<jdoc:include\\ type="([^"]+)" (.*)\\/>#iU', $data, $matches)) {
         $matches[0] = array_reverse($matches[0]);
         $matches[1] = array_reverse($matches[1]);
         $matches[2] = array_reverse($matches[2]);
         $count = count($matches[1]);
         for ($i = 0; $i < $count; $i++) {
             $attribs = JUtility::parseAttributes($matches[2][$i]);
             $type = $matches[1][$i];
             $name = isset($attribs['name']) ? $attribs['name'] : null;
             $replace[$i] = $this->getBuffer($type, $name, $attribs);
         }
         $data = str_replace($matches[0], $replace, $data);
     }
     return $data;
 }
Example #8
0
function shAddPaginationInfo($limit, $limitstart, $showall, $iteration, $url, $location, $shSeparator = null)
{
    global $mainframe;
    $sefConfig =& shRouter::shGetConfig();
    $database =& JFactory::getDBO();
    // get a default limit value, for urls where it's missing
    $listLimit = shGetDefaultDisplayNumFromURL($url, $includeBlogLinks = true);
    $defaultListLimit = shGetDefaultDisplayNumFromConfig($url, $includeBlogLinks = false);
    //echo 'Incoming pagination : $listLimit : ' . $listLimit . ' | $defaultListLimit : ' . $defaultListLimit . "\n";
    // clean suffix and index file before starting to add things to the url
    // clean suffix
    if (strpos($url, 'option=com_content') !== false && strpos($url, 'format=pdf') !== false) {
        $shSuffix = '.pdf';
    } else {
        $shSuffix = $sefConfig->suffix;
    }
    $suffixLength = JString::strLen($shSuffix);
    if (!empty($shSuffix) && $shSuffix != '/' && JString::substr($location, -$suffixLength) == $shSuffix) {
        $location = JString::substr($location, 0, JString::strlen($location) - $suffixLength);
    }
    // clean index file
    if ($sefConfig->addFile && (empty($shSuffix) || JString::subStr($location, -$suffixLength) != $shSuffix)) {
        $indexFileLength = JString::strlen($sefConfig->addFile);
        if ($sefConfig->addFile != '/' && JString::substr($location, -$indexFileLength) == $sefConfig->addFile) {
            $location = JString::substr($location, 0, JString::strlen($location) - $indexFileLength);
        }
    }
    // do we have a trailing slash ?
    if (empty($shSeparator)) {
        $shSeparator = JString::substr($location, -1) == '/' ? '' : '/';
    }
    if (!empty($limit) && is_numeric($limit)) {
        $pagenum = intval($limitstart / $limit);
        $pagenum++;
    } else {
        if (!isset($limit) && !empty($limitstart)) {
            // only limitstart
            if (strpos($url, 'option=com_content') !== false && strpos($url, 'view=article') !== false) {
                $pagenum = intval($limitstart + 1);
                // multipage article
            } else {
                $pagenum = intval($limitstart / $listLimit) + 1;
                // blogs, tables, ...
            }
        } else {
            $pagenum = $iteration;
        }
    }
    // Make sure we do not end in infite loop here.
    if ($pagenum < $iteration) {
        $pagenum = $iteration;
    }
    // shumisha added to handle table-category and table-section which may have variable number of items per page
    // There still will be a problem with filter, which may reduce the total number of items. Thus the item we are looking for
    if ($sefConfig->alwaysAppendItemsPerPage || strpos($url, 'option=com_virtuemart') && $sefConfig->shVmUsingItemsPerPage) {
        $shMultPageLength = $sefConfig->pagerep . (empty($limit) ? $listLimit : $limit);
    } else {
        $shMultPageLength = '';
    }
    // shumisha : modified to add # of items per page to URL, for table-category or section-category
    if (!empty($sefConfig->pageTexts[$GLOBALS['shMosConfig_locale']]) && false !== strpos($sefConfig->pageTexts[$GLOBALS['shMosConfig_locale']], '%s')) {
        $page = str_replace('%s', $pagenum, $sefConfig->pageTexts[$GLOBALS['shMosConfig_locale']]) . $shMultPageLength;
    } else {
        $page = $sefConfig->pagerep . $pagenum . $shMultPageLength;
    }
    // V 1.2.4.t special processing to replace page number by headings
    $shPageNumberWasReplaced = false;
    if (strpos($url, 'option=com_content') !== false && strpos($url, 'view=article') !== false && !empty($limitstart)) {
        // this is multipage article - limitstart instead of limit in J1.5
        if ($sefConfig->shMultipagesTitle) {
            parse_str($url, $shParams);
            if (!empty($shParams['id'])) {
                $shPageTitle = '';
                $sql = 'SELECT c.id, c.fulltext, c.introtext  FROM #__content AS c WHERE id=\'' . $shParams['id'] . '\'';
                $database->setQuery($sql);
                $contentElement = $database->loadObject();
                if ($database->getErrorNum()) {
                    JError::RaiseError(500, $database->stderr());
                }
                $contentText = $contentElement->introtext . $contentElement->fulltext;
                if (!empty($contentElement) && strpos($contentText, 'class="system-pagebreak') !== false) {
                    // search for mospagebreak tags
                    // copied over from pagebreak plugin
                    // expression to search for
                    $regex = '#<hr([^>]*)class=(\\"|\')system-pagebreak(\\"|\')([^>]*)\\/>#iU';
                    // find all instances of mambot and put in $matches
                    $shMatches = array();
                    preg_match_all($regex, $contentText, $shMatches, PREG_SET_ORDER);
                    // adds heading or title to <site> Title
                    if (empty($limitstart)) {
                        // if first page use heading of first mospagebreak
                        /* if ( $shMatches[0][2] ) {
                           parse_str( html_entity_decode( $shMatches[0][2] ), $args );
                           if ( @$args['heading'] ) {
                           $shPageTitle = stripslashes( $args['heading'] );
                           }
                           }*/
                    } else {
                        // for other pages use title of mospagebreak
                        if ($limitstart > 0 && $shMatches[$limitstart - 1][1]) {
                            $args = JUtility::parseAttributes($shMatches[$limitstart - 1][0]);
                            if (@$args['title']) {
                                $shPageTitle = $args['title'];
                            } else {
                                if (@$args['alt']) {
                                    $shPageTitle = $args['alt'];
                                } else {
                                    // there is a page break, but no title. Use a page number
                                    $shPageTitle = str_replace('%s', $limitstart + 1, $sefConfig->pageTexts[$GLOBALS['shMosConfig_locale']]);
                                }
                            }
                        }
                    }
                }
                if (!empty($shPageTitle)) {
                    // found a heading, we should use that as a Title
                    $location .= $shSeparator . titleToLocation($shPageTitle);
                }
                $shPageNumberWasReplaced = true;
                // always set the flag, otherwise we'll a Page-1 added
            }
        } else {
            // mutiple pages article, but we don't want to use smart title.
            // directly use limitstart
            $page = str_replace('%s', $limitstart + 1, $sefConfig->pageTexts[$GLOBALS['shMosConfig_locale']]);
        }
    }
    // maybe this is a multipage with "showall=1"
    if (strpos($url, 'option=com_content') !== false && strpos($url, 'view=article') !== false && strpos($url, 'showall=1') !== false) {
        // this is multipage article with showall
        $tempTitle = JText::_('All Pages');
        $location .= $shSeparator . titleToLocation($tempTitle);
        $shPageNumberWasReplaced = true;
        // always set the flag, otherwise we'll a Page-1 added
    }
    // make sure we remove bad characters
    $takethese = str_replace('|', '', $sefConfig->friendlytrim);
    $location = JString::trim($location, $takethese);
    // add page number
    if (!$shPageNumberWasReplaced && (!isset($limitstart) && (isset($limit) && $limit != $listLimit && $limit != $defaultListLimit) || isset($limitstart) && ($limitstart != 0 || $limitstart == 0 && (strpos($url, 'option=com_virtuemart') && $sefConfig->shVmUsingItemsPerPage && (isset($limit) && $limit != $listLimit))))) {
        $location .= $shSeparator . $page;
    }
    // add suffix
    if (!empty($shSuffix) && $location != '/' && JString::substr($location, -1) != '/') {
        $location = $shSuffix == '/' ? $location . $shSuffix : str_replace($shSuffix, '', $location) . $shSuffix;
    }
    // add default index file
    if ($sefConfig->addFile) {
        // V 1.2.4.t
        if (empty($shSuffix) || !empty($shSuffix) && JString::subStr($location, -$suffixLength) != $shSuffix) {
            $location .= (JString::substr($location, -1) == '/' ? '' : '/') . $sefConfig->addFile;
        }
    }
    return JString::ltrim($location, '/');
}
Example #9
0
 /**
  * Parse a document template
  *
  * @return  JDocumentHTML  instance of $this to allow chaining
  *
  * @since   11.1
  */
 protected function _parseTemplate()
 {
     $matches = array();
     if (preg_match_all('#<jdoc:include\\ type="([^"]+)" (.*)\\/>#iU', $this->_template, $matches)) {
         $template_tags_first = array();
         $template_tags_last = array();
         // Step through the jdocs in reverse order.
         for ($i = count($matches[0]) - 1; $i >= 0; $i--) {
             $type = $matches[1][$i];
             $attribs = empty($matches[2][$i]) ? array() : JUtility::parseAttributes($matches[2][$i]);
             $name = isset($attribs['name']) ? $attribs['name'] : null;
             // Separate buffers to be executed first and last
             if ($type == 'module' || $type == 'modules') {
                 $template_tags_first[$matches[0][$i]] = array('type' => $type, 'name' => $name, 'attribs' => $attribs);
             } else {
                 $template_tags_last[$matches[0][$i]] = array('type' => $type, 'name' => $name, 'attribs' => $attribs);
             }
         }
         // Reverse the last array so the jdocs are in forward order.
         $template_tags_last = array_reverse($template_tags_last);
         $this->_template_tags = $template_tags_first + $template_tags_last;
     }
     return $this;
 }
Example #10
0
 function _generateToc(&$row, $index)
 {
     $display_method = $this->params->get('display_method', 1);
     $limitstart = JRequest::getInt('limitstart', 0);
     $result = new stdClass();
     if (0 == $index && $this->texts[$index] != "") {
         //$result->title	= $this->params->get('intro_text') != "" ? $this->params->get('intro_text') : $this->article->title ;
         $result->title = ' - ' . JText::_($this->params->get('custom_introtext', 'FLEXIBREAK_INTRO_TEXT')) . ' - ';
         $result->name = $result->id = 'start';
         $result->link = JRoute::_(FlexicontentHelperRoute::getItemRoute($row->slug, $row->catid, 0, $row) . '&showall=&limitstart=');
         $this->pagescount++;
     } else {
         if ($this->texts[0] == "") {
             $attrs = JUtility::parseAttributes($this->pages[$index][0]);
         } else {
             $attrs = JUtility::parseAttributes($this->pages[$index - 1][0]);
         }
         $result->title = isset($attrs['title']) ? $attrs['title'] : 'unknown';
         $result->name = isset($attrs['name']) ? $attrs['name'] : preg_replace('/[ \\t]+/u', '', $result->title);
         $result->link = JRoute::_(FlexicontentHelperRoute::getItemRoute($row->slug, $row->catid, 0, $row) . '&showall=&limitstart=' . $index);
         $result->id = $result->name ? $result->name : 'start';
     }
     $curr_index = $this->texts[0] == "" ? $index + 1 : $index;
     if (!isset($this->_text)) {
         $this->_text = '';
     }
     switch ($display_method) {
         case 0:
             $this->_text .= '<a id="' . $result->id . '_toc_page"></a>' . $this->texts[$curr_index];
             // add an anchor link for scrolling
             break;
         case 1:
             $this->_text .= '<div class="articlePage" id="' . $result->id . '"> ' . $this->texts[$curr_index] . '</div>';
             break;
         case 2:
             if ($limitstart == $curr_index) {
                 $this->_text .= $this->texts[$curr_index];
             }
             break;
     }
     return $result;
 }
Example #11
0
File: t3.php Project: lazarch/t3
 function onBeforeRender()
 {
     if (defined('T3_PLUGIN') && T3::detect()) {
         $japp = JFactory::getApplication();
         JDispatcher::getInstance()->trigger('onT3BeforeRender');
         if ($japp->isAdmin()) {
             $t3app = T3::getApp();
             $t3app->addAssets();
         } else {
             $params = $japp->getTemplate(true)->params;
             if (defined('T3_THEMER') && $params->get('themermode', 1)) {
                 T3::import('admin/theme');
                 T3AdminTheme::addAssets();
             }
             //check for ajax action and render t3ajax type to before head type
             if (class_exists('T3Ajax')) {
                 T3Ajax::render();
             }
             // allow load module/modules in component using jdoc:include
             $doc = JFactory::getDocument();
             $main_content = $doc->getBuffer('component');
             if ($main_content) {
                 // parse jdoc
                 if (preg_match_all('#<jdoc:include\\ type="([^"]+)"(.*)\\/>#iU', $main_content, $matches)) {
                     $replace = array();
                     $with = array();
                     // Step through the jdocs in reverse order.
                     for ($i = 0; $i < count($matches[0]); $i++) {
                         $type = $matches[1][$i];
                         $attribs = empty($matches[2][$i]) ? array() : JUtility::parseAttributes($matches[2][$i]);
                         $name = isset($attribs['name']) ? $attribs['name'] : null;
                         $replace[] = $matches[0][$i];
                         $with[] = $doc->getBuffer($type, $name, $attribs);
                     }
                     $main_content = str_replace($replace, $with, $main_content);
                     // update buffer
                     $doc->setBuffer($main_content, 'component');
                 }
             }
         }
     }
 }
Example #12
0
 function onPrepareItemDescription(&$row, &$params, $page = 0)
 {
     $app = JFactory::getApplication();
     // expression to search for
     $regex = '#<hr([^>]*?)class=(\\"|\')system-pagebreak(\\"|\')([^>]*?)\\/*>#iU';
     // Get Plugin info
     $pluginParams = $this;
     if (!$pluginParams->get('enabled', 1)) {
         return true;
     }
     JPlugin::loadLanguage('plg_djcatalog2_pagebreak', JPATH_ADMINISTRATOR);
     // replacing readmore with <br /> - we don't need it
     $row->description = str_replace("<hr id=\"system-readmore\" />", "<br />", $row->description);
     if (strpos($row->description, 'class="system-pagebreak') === false && strpos($row->description, 'class=\'system-pagebreak') === false) {
         return true;
     }
     $view = $app->input->get('view', null, 'string');
     if (!JPluginHelper::isEnabled('djcatalog2', 'pagebreak') || $view != 'item' && $view != 'itemstable' && $view != 'items' && $view != 'producer') {
         $row->description = preg_replace($regex, '', $row->description);
         return;
     }
     // find all instances of plugin and put in $matches
     $matches = array();
     preg_match_all($regex, $row->description, $matches, PREG_SET_ORDER);
     // split the text around the plugin
     $text = preg_split($regex, $row->description);
     $title = array();
     // count the number of pages
     $n = count($text);
     if ($n > 1) {
         $pluginParams = $this->params;
         $style = $pluginParams->get('accordion', 2);
         $jinput = JFactory::getApplication()->input;
         if ($jinput->get('print', null) == '1' && $jinput->get('tmpl') == 'component') {
             $style = 'none';
         }
         $row->description = '';
         $row->description .= $text[0];
         $i = 1;
         foreach ($matches as $match) {
             if (@$match[0]) {
                 $attrs = JUtility::parseAttributes($match[0]);
                 if (@$attrs['alt']) {
                     $title[] = stripslashes($attrs['alt']);
                 } elseif (@$attrs['title']) {
                     $title[] = stripslashes($attrs['title']);
                 } else {
                     $title[] = JText::sprintf('PLG_DJCATALOG2_PAGEBREAK_TOGGLE', $i);
                 }
             } else {
                 $title[] = JText::sprintf('PLG_DJCATALOG2_PAGEBREAK_TOGGLE', $i);
             }
             $i++;
         }
         $row->tabs = '';
         $group_id = 'tab-' . htmlspecialchars($row->alias) . '-';
         if ($style == '1') {
             $row->tabs .= '<div class="accordion">';
             for ($i = 1; $i < $n; $i++) {
                 $class = $i == 1 ? 'class="accordion-body collapse in"' : 'class="accordion-body collapse"';
                 $row->tabs .= '<div class="accordion-group">';
                 $row->tabs .= '<div class="accordion-heading"><a class="accordion-toggle">' . $title[$i - 1] . '</a></div>';
                 $row->tabs .= '<div ' . $class . ' id="' . $group_id . $i . '"><div class="accordion-inner">' . $text[$i] . '</div></div>';
                 $row->tabs .= '</div>';
             }
             $row->tabs .= '</div>';
         } else {
             if ($style == '2') {
                 $row->tabs .= '<ul class="nav nav-tabs">';
                 for ($i = 1; $i < $n; $i++) {
                     $class = $i == 1 ? 'class="nav-toggler active"' : 'class="nav-toggler"';
                     $row->tabs .= '<li ' . $class . '><a>' . $title[$i - 1] . '</a></li>';
                 }
                 $row->tabs .= '</ul>';
                 $row->tabs .= '<div class="tab-content">';
                 for ($i = 1; $i < $n; $i++) {
                     $class = $i == 1 ? 'class="tab-pane active"' : 'class="tab-pane"';
                     $row->tabs .= '<div ' . $class . ' id="' . $group_id . $i . '">';
                     $row->tabs .= '<div>' . $text[$i] . '</div>';
                     $row->tabs .= '</div>';
                 }
                 $row->tabs .= '</div>';
             } else {
                 $row->tabs .= '<div class="djc_pagebreak">';
                 for ($i = 1; $i < $n; $i++) {
                     $row->tabs .= '<h3 class="djc_pagebreak-title">' . $title[$i - 1] . '</h3>';
                     $row->tabs .= '<div class="djc_pagebreak-content">' . $text[$i] . '</div>';
                 }
                 $row->tabs .= '</div>';
             }
         }
     }
     return true;
 }
Example #13
0
 /**
  * Parse a document template
  *
  * @return The parsed contents of the template
  * @since  1.0
  */
 protected function _parseTemplate()
 {
     if (empty($this->_template)) {
         throw new Exception('ParseTemplate: template entity is empty');
     }
     $replaces = array();
     foreach ($this->parsedTags as $name => $val) {
         $matches = array();
         $replaces[$name] = array();
         if (preg_match_all($val['regexp'], $this->_template->content, $matches)) {
             if (!empty($matches)) {
                 foreach ($matches as $idx => $match) {
                     $matches[$idx] = array_reverse($match);
                 }
                 $count = count($matches[1]);
                 for ($i = 0; $i < $count; $i++) {
                     $k = 1;
                     $res = array();
                     foreach ($val['matches'] as $itemName => $item) {
                         if (isset($matches[$k])) {
                             if ($itemName == 'attribs') {
                                 $val['matches'][$itemName] = JUtility::parseAttributes($matches[$k][$i]);
                             } else {
                                 $val['matches'][$itemName] = $matches[$k][$i];
                             }
                         }
                         $replaces[$name][$matches[0][$i]] = $val['matches'];
                         $k++;
                     }
                 }
             }
         }
     }
     $this->_parsed = $replaces;
     return true;
 }
Example #14
0
    $row->toc .= '<h3>' . $headingtext . '</h3>';
}
// TOC first Page link.
$class = $limitstart === 0 && $showall === 0 ? 'toclink active' : 'toclink';
$row->toc .= '<ul class="nav nav-tabs nav-stacked">
<li class="' . $class . '">

    <a href="' . JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid) . '&showall=&limitstart=') . '" class="' . $class . '">' . $heading . '</a>

</li>
';
$i = 2;
foreach ($matches as $bot) {
    $link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid) . '&showall=&limitstart=' . ($i - 1));
    if (@$bot[0]) {
        $attrs2 = JUtility::parseAttributes($bot[0]);
        if (@$attrs2['alt']) {
            $title = stripslashes($attrs2['alt']);
        } elseif (@$attrs2['title']) {
            $title = stripslashes($attrs2['title']);
        } else {
            $title = JText::sprintf('PLG_CONTENT_PAGEBREAK_PAGE_NUM', $i);
        }
    } else {
        $title = JText::sprintf('PLG_CONTENT_PAGEBREAK_PAGE_NUM', $i);
    }
    $class = $limitstart == $i - 1 ? 'toclink active' : 'toclink';
    $row->toc .= '
        <li>

            <a href="' . $link . '" class="' . $class . '">' . $title . '</a>
Example #15
0
    /**
     * Creates a Table of Contents for the pagebreak
     *
     * @param   object   &$row      The article object.  Note $article->text is also available
     * @param   array    &$matches  Array of matches of a regex in onContentPrepare
     * @param   integer  &$page     The 'page' number
     *
     * @return  void
     *
     * @since  1.6
     */
    protected function _createTOC(&$row, &$matches, &$page)
    {
        $heading = isset($row->title) ? $row->title : JText::_('PLG_CONTENT_PAGEBREAK_NO_TITLE');
        $input = JFactory::getApplication()->input;
        $limitstart = $input->getUInt('limitstart', 0);
        $showall = $input->getInt('showall', 0);
        // TOC header.
        $row->toc = '<div class="pull-right article-index">';
        if ($this->params->get('article_index') == 1) {
            $headingtext = JText::_('PLG_CONTENT_PAGEBREAK_ARTICLE_INDEX');
            if ($this->params->get('article_index_text')) {
                $headingtext = htmlspecialchars($this->params->get('article_index_text'), ENT_QUOTES, 'UTF-8');
            }
            $row->toc .= '<h3>' . $headingtext . '</h3>';
        }
        // TOC first Page link.
        $class = $limitstart === 0 && $showall === 0 ? 'toclink active' : 'toclink';
        $row->toc .= '<ul class="nav nav-tabs nav-stacked">
		<li class="' . $class . '">
			<a href="' . JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid, $row->language) . '&showall=&limitstart=') . '" class="' . $class . '">' . $heading . '</a>
		</li>
		';
        $i = 2;
        foreach ($matches as $bot) {
            $link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid, $row->language) . '&showall=&limitstart=' . ($i - 1));
            if (@$bot[0]) {
                $attrs2 = JUtility::parseAttributes($bot[0]);
                if (@$attrs2['alt']) {
                    $title = stripslashes($attrs2['alt']);
                } elseif (@$attrs2['title']) {
                    $title = stripslashes($attrs2['title']);
                } else {
                    $title = JText::sprintf('PLG_CONTENT_PAGEBREAK_PAGE_NUM', $i);
                }
            } else {
                $title = JText::sprintf('PLG_CONTENT_PAGEBREAK_PAGE_NUM', $i);
            }
            $class = $limitstart == $i - 1 ? 'toclink active' : 'toclink';
            $row->toc .= '
				<li>

					<a href="' . $link . '" class="' . $class . '">' . $title . '</a>

				</li>
				';
            $i++;
        }
        if ($this->params->get('showall')) {
            $link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid, $row->language) . '&showall=1&limitstart=');
            $class = $showall == 1 ? 'toclink active' : 'toclink';
            $row->toc .= '
			<li>

					<a href="' . $link . '" class="' . $class . '">' . JText::_('PLG_CONTENT_PAGEBREAK_ALL_PAGES') . '</a>

			</li>
			';
        }
        $row->toc .= '</ul></div>';
    }
Example #16
0
    function buildTOC($matches)
    {
        $this->toc .= "<div id='article-index' class='article-index'>";
        $limitstart = FSS_Input::getInt('page');
        $class = $limitstart === 0 ? 'toclink active' : 'toclink';
        $this->toc .= '<ul class="nav nav-tabs nav-stacked">
		<li>

			<a href="' . FSSRoute::X("&page=0") . '" class="' . $class . '">' . $this->art['title'] . '</a>

		</li>
		';
        $i = 2;
        foreach ($matches as $bot) {
            $link = FSSRoute::X("&page=" . ($i - 1));
            if (@$bot[0]) {
                $attrs2 = JUtility::parseAttributes($bot[0]);
                if (@$attrs2['alt']) {
                    $title = stripslashes($attrs2['alt']);
                } elseif (@$attrs2['title']) {
                    $title = stripslashes($attrs2['title']);
                } else {
                    $title = JText::sprintf('PLG_CONTENT_PAGEBREAK_PAGE_NUM', $i);
                }
            } else {
                $title = JText::sprintf('PLG_CONTENT_PAGEBREAK_PAGE_NUM', $i);
            }
            $class = $limitstart == $i - 1 ? 'toclink active' : 'toclink';
            $this->toc .= '
				<li>
					<a href="' . $link . '" class="' . $class . '">' . $title . '</a>

				</li>
				';
            $i++;
        }
        // all pages entry
        $lang = JFactory::getLanguage();
        $lang->load('plg_content_pagebreak', JPATH_ADMINISTRATOR, null, false, true);
        $class = $limitstart == -1 ? 'toclink active' : 'toclink';
        $this->toc .= '
				<li>
					<a href="' . FSSRoute::X("&page=-1") . '" class="' . $class . '">' . JText::_("PLG_CONTENT_PAGEBREAK_ALL_PAGES") . '</a>

				</li>
				';
        $this->toc .= '</ul></div>';
    }
 protected function getPositions($template)
 {
     $templatephpfile = JPath::clean(JPATH_THEMES . '/' . $template . '/index.php');
     $templatephp = file_get_contents($templatephpfile);
     $matches = array();
     $positions = array();
     if (preg_match_all('#<jdoc:include type="module([^"]+)" (.*)\\/>#iU', $templatephp, $matches)) {
         for ($i = count($matches[0]) - 1; $i >= 0; $i--) {
             $attribs = empty($matches[2][$i]) ? array() : JUtility::parseAttributes($matches[2][$i]);
             $name = isset($attribs['name']) ? $attribs['name'] : null;
             if ($name) {
                 $positions[] = (string) $name;
             }
         }
     } else {
         $templateDetails = JPATH_THEMES . '/' . $template . '/templateDetails.xml';
         $path = JPath::clean($templateDetails);
         if (file_exists($path) && ($xml = simplexml_load_file($path)) && isset($xml->positions[0])) {
             foreach ($xml->positions[0] as $position) {
                 $positions[] = (string) $position;
             }
         }
     }
     return $positions;
 }
 function _getPageTitle($page)
 {
     if (empty($this->articleText)) {
         return null;
     }
     //simple performance check to determine whether bot should process further
     if (strpos($this->articleText, 'class="system-pagebreak') === false && strpos($this->articleText, 'class=\'system-pagebreak') === false) {
         return null;
     }
     // regex
     $regex = '#<hr([^>]*?)class=(\\"|\')system-pagebreak(\\"|\')([^>]*?)\\/*>#iU';
     // Find all occurences
     $matches = array();
     preg_match_all($regex, $this->articleText, $matches, PREG_SET_ORDER);
     if (!isset($matches[$page - 1]) || !isset($matches[$page - 1][2])) {
         return null;
     }
     $attrs = JUtility::parseAttributes($matches[$page - 1][0]);
     if (empty($attrs['title'])) {
         return null;
     }
     return $attrs['title'];
 }
Example #19
0
File: html.php Project: akksi/jcg
 /**
  * Parse a document template
  *
  * @return	The parsed contents of the template
  */
 private function _parseTemplate()
 {
     $replace = array();
     $matches = array();
     if (preg_match_all('#<jdoc:include\\ type="([^"]+)" (.*)\\/>#iU', $this->_template, $matches)) {
         $matches[0] = array_reverse($matches[0]);
         $matches[1] = array_reverse($matches[1]);
         $matches[2] = array_reverse($matches[2]);
         $count = count($matches[1]);
         for ($i = 0; $i < $count; $i++) {
             $attribs = JUtility::parseAttributes($matches[2][$i]);
             $type = $matches[1][$i];
             $name = isset($attribs['name']) ? $attribs['name'] : null;
             $this->_template_tags[$matches[0][$i]] = array('type' => $type, 'name' => $name, 'attribs' => $attribs);
         }
     }
 }
Example #20
0
    /**
     * @return	void
     * @return	1.6
     */
    protected function _createTOC(&$row, &$matches, &$page)
    {
        $heading = isset($row->title) ? $row->title : JText::_('PLG_CONTENT_PAGEBREAK_NO_TITLE');
        // TOC header.
        $row->toc .= '<div id="article-index">';
        if ($this->params->get('article_index') == 1) {
            $headingtext = JText::_('PLG_CONTENT_PAGEBREAK_ARTICLE_INDEX');
            if ($this->params->get('article_index_text')) {
                htmlspecialchars($headingtext = $this->params->get('article_index_text'));
            }
            $row->toc .= '<h3>' . $headingtext . '</h3>';
        }
        // TOC first Page link.
        $row->toc .= '<ul>
		<li>
			
			<a href="' . JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid) . '&showall=&limitstart=') . '" class="toclink">' . $heading . '</a>
			
		</li>
		';
        $i = 2;
        foreach ($matches as $bot) {
            $link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid) . '&showall=&limitstart=' . ($i - 1));
            if (@$bot[0]) {
                $attrs2 = JUtility::parseAttributes($bot[0]);
                if (@$attrs2['alt']) {
                    $title = stripslashes($attrs2['alt']);
                } elseif (@$attrs2['title']) {
                    $title = stripslashes($attrs2['title']);
                } else {
                    $title = JText::sprintf('Page #', $i);
                }
            } else {
                $title = JText::sprintf('Page #', $i);
            }
            $row->toc .= '
				<li>
					
					<a href="' . $link . '" class="toclink">' . $title . '</a>
				
				</li>
				';
            $i++;
        }
        if ($this->params->get('showall')) {
            $link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid) . '&showall=1&limitstart=');
            $row->toc .= '
			<li>
				
					<a href="' . $link . '" class="toclink">' . JText::_('PLG_CONTENT_PAGEBREAK_ALL_PAGES') . '</a>
			
			</li>
			';
        }
        $row->toc .= '</ul></div>';
    }
Example #21
0
    /**
     * @return	void
     * @return	1.6
     */
    protected function _createTOC(&$row, &$matches, &$page)
    {
        $heading = isset($row->title) ? $row->title : Lang::txt('PLG_CONTENT_PAGEBREAK_NO_TITLE');
        $limitstart = Request::getUInt('limitstart', 0);
        $showall = Request::getInt('showall', 0);
        // TOC header.
        $row->toc = '<div id="article-index">';
        if ($this->params->get('article_index') == 1) {
            $headingtext = Lang::txt('PLG_CONTENT_PAGEBREAK_ARTICLE_INDEX');
            if ($this->params->get('article_index_text')) {
                htmlspecialchars($headingtext = $this->params->get('article_index_text'));
            }
            $row->toc .= '<h3>' . $headingtext . '</h3>';
        }
        // TOC first Page link.
        $class = $limitstart === 0 && $showall === 0 ? 'toclink active' : 'toclink';
        $row->toc .= '<ul>
		<li>

			<a href="' . Route::url(ContentHelperRoute::getArticleRoute($row->slug, $row->catid, $row->language) . '&showall=&limitstart=') . '" class="' . $class . '">' . $heading . '</a>

		</li>
		';
        $i = 2;
        foreach ($matches as $bot) {
            $link = Route::url(ContentHelperRoute::getArticleRoute($row->slug, $row->catid, $row->language) . '&showall=&limitstart=' . ($i - 1));
            if (@$bot[0]) {
                $attrs2 = JUtility::parseAttributes($bot[0]);
                if (@$attrs2['alt']) {
                    $title = stripslashes($attrs2['alt']);
                } elseif (@$attrs2['title']) {
                    $title = stripslashes($attrs2['title']);
                } else {
                    $title = Lang::txt('PLG_CONTENT_PAGEBREAK_PAGE_NUM', $i);
                }
            } else {
                $title = Lang::txt('PLG_CONTENT_PAGEBREAK_PAGE_NUM', $i);
            }
            $class = $limitstart == $i - 1 ? 'toclink active' : 'toclink';
            $row->toc .= '
				<li>

					<a href="' . $link . '" class="' . $class . '">' . $title . '</a>

				</li>
				';
            $i++;
        }
        if ($this->params->get('showall')) {
            $link = Route::url(ContentHelperRoute::getArticleRoute($row->slug, $row->catid, $row->language) . '&showall=1&limitstart=');
            $class = $showall == 1 ? 'toclink active' : 'toclink';
            $row->toc .= '
			<li>

					<a href="' . $link . '" class="' . $class . '">' . Lang::txt('PLG_CONTENT_PAGEBREAK_ALL_PAGES') . '</a>

			</li>
			';
        }
        $row->toc .= '</ul></div>';
    }
 function _generateToc(&$row, $index)
 {
     $display_method = $this->params->get('display_method', 1);
     $limitstart = JRequest::getInt('limitstart', 0);
     $page = new stdClass();
     // If intro text exists, then increment pages-counter by 1, and make page ZERO to be the intro-text page
     if (0 == $index && $this->texts[$index] != "") {
         $this->pagescount++;
         $page->title = JText::_($this->params->get('custom_introtext', 'FLEXIBREAK_INTRO_TEXT'));
         $page->name = 'start';
         $page->link = JRoute::_(self::$rowLinks[$row->slug] . '&showall=&limitstart=');
         $page->id = str_replace('"', '', str_replace("'", "", $page->name));
     } else {
         $attrs = $this->texts[0] == "" ? JUtility::parseAttributes($this->pages[$index][0]) : JUtility::parseAttributes($this->pages[$index - 1][0]);
         $page->title = isset($attrs['title']) ? $attrs['title'] : 'unknown';
         $page->name = isset($attrs['name']) ? $attrs['name'] : preg_replace('/[ \\t]+/u', '', $page->title);
         $page->link = JRoute::_(self::$rowLinks[$row->slug] . '&showall=&limitstart=' . $index);
         $page->id = $page->name ? str_replace('"', '', str_replace("'", "", $page->name)) : 'start';
     }
     $curr_index = $this->texts[0] == "" ? $index + 1 : $index;
     if (!isset($this->_text)) {
         $this->_text = '';
     }
     switch ($display_method) {
         // Add an anchor link for scrolling,
         case 0:
             $this->_text .= '<a id="' . $page->id . '_toc_page"></a>' . $this->texts[$curr_index];
             break;
             // Add a DIV container for JS based navigation
         // Add a DIV container for JS based navigation
         case 1:
             $this->_text .= '<div class="articlePage" id="' . $page->id . '"> ' . $this->texts[$curr_index] . '</div>';
             break;
             // Nor scrolled, neither JS based navigation:  Only ADD page's text, if it is the current page
         // Nor scrolled, neither JS based navigation:  Only ADD page's text, if it is the current page
         case 2:
             if ($limitstart == $curr_index) {
                 $this->_text .= $this->texts[$curr_index];
             }
             break;
     }
     return $page;
 }
Example #23
0
 private function _getPageTitle($page)
 {
     jimport('joomla.utilities.utility');
     if (empty($this->articleText)) {
         return null;
     }
     // simple performance check
     if (JString::strpos($this->articleText, 'class="system-pagebreak') === false) {
         return null;
     }
     // regex
     $regex = '#<hr(.*)class="system-pagebreak"(.*)\\/>#iU';
     // Find all occurences
     $matches = array();
     preg_match_all($regex, $this->articleText, $matches, PREG_SET_ORDER);
     if (!isset($matches[$page - 1]) || !isset($matches[$page - 1][2])) {
         return null;
     }
     $attrs = JUtility::parseAttributes($matches[$page - 1][0]);
     if (isset($attrs['alt'])) {
         return stripslashes($attrs['alt']);
     } else {
         if (isset($attrs['title'])) {
             return stripslashes($attrs['title']);
         } else {
             return null;
         }
     }
 }
Example #24
0
 public static function photogallery($text)
 {
     if (preg_match_all('#<img[^>]+>#iU', $text, $imgs)) {
         //remove the text
         $text = preg_replace('#<img[^>]+>#iU', '', $text);
         //collect all images
         $img_data = array();
         // parse image attributes
         foreach ($imgs[0] as $img_tag) {
             $img_data[$img_tag] = JUtility::parseAttributes($img_tag);
         }
         $total = count($img_data);
         if ($total > 0) {
             $text .= '<ul class="thumbnails' . ($total > 1 ? '' : ' no-slide') . '">';
             $j = 0;
             foreach ($img_data as $img => $attr) {
                 $text .= '<li class="' . ($j == 0 ? 'col-xs-12' : 'col-sm-6 col-xs-12') . '">' . ($total > 1 ? '<a title="' . $attr['alt'] . '" href="' . (isset($attr['src']) ? $attr['src'] : '') . '" class="thumbnail' . ($j == 0 ? ' active' : '') . '">' : '') . $img . ($total > 1 ? '</a>' : '') . '</li>';
                 $j++;
             }
             $text .= '</ul>';
         }
         return $text;
     } else {
         return $text;
     }
 }
Example #25
0
 /**
  * Parse each <jdoc /> and return the corresponding content
  * @param   $matches  <jdoc /> infomation
  * @return  string    block markup
  */
 protected function _parseJDoc($matches)
 {
     $type = $matches[1];
     if ($type == 'head') {
         return $matches[0];
     }
     $attribs = empty($matches[2]) ? array() : JUtility::parseAttributes($matches[2]);
     $attribs['type'] = $type;
     if (!isset($attribs['name'])) {
         $attribs['name'] = $attribs['type'];
     }
     $tp = 'tpls/system/tp.php';
     $path = '';
     if (is_file(T3_TEMPLATE_PATH . '/' . $tp)) {
         $path = T3_TEMPLATE_PATH . '/' . $tp;
     } else {
         if (is_file(T3_PATH . '/' . $tp)) {
             $path = T3_PATH . '/' . $tp;
         }
     }
     return $this->loadFile($path, $attribs);
 }
Example #26
0
 public function renderJDoc($id, $buffer)
 {
     static $buffers = array();
     if (isset($buffers[$id])) {
         return $buffers[$id];
     }
     // init cache to prevent nested parse
     $buffers[$id] = '';
     $doc = JFactory::getDocument();
     $matches = array();
     if (preg_match_all('#<jdoc:include\\ type="([^"]+)" (.*)\\/>#iU', $buffer, $matches)) {
         $tags = array();
         // Step through the jdocs in reverse order.
         for ($i = count($matches[0]) - 1; $i >= 0; $i--) {
             $type = $matches[1][$i];
             $attribs = empty($matches[2][$i]) ? array() : JUtility::parseAttributes($matches[2][$i]);
             $name = isset($attribs['name']) ? $attribs['name'] : null;
             // Separate buffers to be executed first and last
             $tags[$matches[0][$i]] = array('type' => $type, 'name' => $name, 'attribs' => $attribs);
         }
         $replace = array();
         $with = array();
         foreach ($tags as $jdoc => $args) {
             $replace[] = $jdoc;
             $with[] = $doc->getBuffer($args['type'], $args['name'], $args['attribs']);
         }
         $buffer = str_replace($replace, $with, $buffer);
     }
     $buffers[$id] = $buffer;
     return $buffers[$id];
 }
Example #27
0
 if (!empty($contentElement) && empty($showall) && strpos($contentText, 'class="system-pagebreak') !== false) {
     // search for mospagebreak tags
     // copied over from pagebreak plugin
     // expression to search for
     //$regex = '/{(mospagebreak)\s*(.*?)}/i';
     $regex = '#<hr([^>]*)class=\\"system-pagebreak\\"([^>]*)\\/>#iUu';
     // find all instances of mambot and put in $matches
     $shMatches = array();
     preg_match_all($regex, $contentText, $shMatches, PREG_SET_ORDER);
     // adds heading or title to <site> Title
     if (empty($limitstart)) {
         // if first page use heading of first mospagebreak
     } else {
         // for other pages use title of mospagebreak
         if ($limitstart > 0 && $shMatches[$limitstart - 1][1]) {
             $args = JUtility::parseAttributes($shMatches[$limitstart - 1][0]);
             if (@$args['title']) {
                 $shPageTitle = $args['title'];
             } else {
                 if (@$args['alt']) {
                     $shPageTitle = $args['alt'];
                 } else {
                     // there is a page break, but no title. Use a page number
                     $pattern = str_replace($sefConfig->pagerep, ' ', $sefConfig->pageTexts[$shPageInfo->currentLanguageTag]);
                     $shPageTitle = str_replace('%s', $limitstart + 1, $pattern);
                 }
             }
         }
     }
 }
 if (!empty($shPageTitle)) {
Example #28
0
 private function _sh404sefGetSocialButtons($sefConfig, $url = '', $context = '', $content = null, $imageSrc = '', $imageDesc = '')
 {
     // if no URL, use current
     if (empty($url)) {
         // no url set on social button tag, we should
         // use current URL, except if we are on a page
         // where this would cause the wrong url to be shared
         // try identify this condition
         if ($this->_shouldDisplaySocialButtons($sefConfig, $context, $content)) {
             Sh404sefHelperShurl::updateShurls();
             $pageInfo = Sh404sefFactory::getPageInfo();
             $url = !$this->_params->get('useShurl', true) || empty($pageInfo->shURL) ? JURI::current() : JURI::base() . ltrim($sefConfig->shRewriteStrings[$sefConfig->shRewriteMode], '/') . $pageInfo->shURL;
         } else {
             return '';
         }
     }
     // buttons html
     $buttonsHtml = '';
     // get language from Joomla
     $longLang = JFactory::getLanguage()->getTag();
     // networks use en_GB, not en-GB
     $shortLang = substr($longLang, 0, 2);
     // we wrap buttons in unordered list
     $wrapperOpen = '<li>';
     $wrapperClose = '</li>';
     // Tweet
     if ($this->_params->get('enableTweet', true) && in_array('twitter', $this->_enabledButtons)) {
         $buttonsHtml .= $wrapperOpen . '<a href="https://twitter.com/share" data-via="' . $this->_params->get('viaAccount', '') . '" data-count="' . $this->_params->get('tweetLayout', 'none') . '" data-url="' . $url . '" data-lang="' . $shortLang . '" class="twitter-share-button">Tweet</a>' . $wrapperClose;
     }
     // plus One
     if ($this->_params->get('enablePlusOne', true) && in_array('googleplusone', $this->_enabledButtons)) {
         $buttonsHtml .= $wrapperOpen . '<g:plusone callback="_sh404sefSocialTrackGPlusTracking" annotation="' . $this->_params->get('plusOneAnnotation', 'none') . '" size="' . $this->_params->get('plusOneSize', '') . '" href="' . $url . '"></g:plusone>' . $wrapperClose;
     }
     // Google plus page badge
     $page = $this->_params->get('googlePlusPage', '');
     $page = JString::trim($page, '/');
     if ($this->_params->get('enableGooglePlusPage', true) && in_array('googlepluspage', $this->_enabledButtons) && !empty($page)) {
         $buttonsHtml .= $wrapperOpen . '<a class="google-page-badge" onclick="_sh404sefSocialTrack.GPageTracking(\'/' . $page . '/\', \'' . $url . '\')" href="https://plus.google.com/' . $page . '/?prsrc=3">';
         // badge image
         switch ($this->_params->get('googlePlusPageSize', 'medium')) {
             case 'small':
                 $size = '16';
                 $buttonsHtml .= '<div style="display: inline-block;">';
                 // custom text
                 if ($this->_params->get('googlePlusCustomText', '')) {
                     $buttonsHtml .= '<span style="float: left; font: bold 13px/16px arial,sans-serif; margin-right: 4px;">' . htmlspecialchars($this->_params->get('googlePlusCustomText', '')) . '</span><span style="float: left; font: 13px/16px arial,sans-serif; margin-right: 11px;">' . htmlspecialchars($this->_params->get('googlePlusCustomText2', '')) . '</span>';
                 }
                 $buttonsHtml .= '<div style="float: left;"><img src="https://ssl.gstatic.com/images/icons/gplus-16.png" width="16" height="16" style="border: 0;"/></div><div style="clear: both"></div>';
                 break;
             case 'large':
                 $size = '64';
                 $buttonsHtml .= '<div style="display: inline-block; *display: inline;"><div style="text-align: center;"><img src="https://ssl.gstatic.com/images/icons/gplus-64.png" width="64" height="64" style="border: 0;"></img></div><div style="font: bold 13px/16px arial,sans-serif; text-align: center;">' . $this->_params->get('googlePlusCustomText', '') . '</div><div style="font: 13px/16px arial,sans-serif; text-align: center;">' . htmlspecialchars($this->_params->get('googlePlusCustomText2', '')) . '</div>';
                 break;
             default:
                 $size = '32';
                 $buttonsHtml .= '<div style="display: inline-block;">';
                 // custom text
                 if ($this->_params->get('googlePlusCustomText', '')) {
                     $buttonsHtml .= '<span style="float: left; font: bold 13px/16px arial,sans-serif; margin-right: 4px; margin-top: 7px;">' . htmlspecialchars($this->_params->get('googlePlusCustomText', '')) . '</span><span style="float: left; font: 13px/16px arial,sans-serif; margin-right: 11px; margin-top: 7px;">' . htmlspecialchars($this->_params->get('googlePlusCustomText2', '')) . '</span>';
                 }
                 $buttonsHtml .= '<div style="float: left;"><img src="https://ssl.gstatic.com/images/icons/gplus-32.png" width="32" height="32" style="border: 0;"/></div><div style="clear: both"></div>';
                 break;
         }
         $buttonsHtml .= '</div></a>' . $wrapperClose;
     }
     // Pinterest
     if ($this->_params->get('enablePinterestPinIt', 1) && in_array('pinterestpinit', $this->_enabledButtons)) {
         // we use either the first image in content, or the provided one (from a user created tag)
         if (empty($imageSrc)) {
             // we're using the first image in the content
             $regExp = '#<img([^>]*)/>#is';
             $text = empty($content->fulltext) ? $content->introtext : $content->introtext . $content->fulltext;
             $img = preg_match($regExp, $text, $match);
             if (empty($img) || empty($match[1])) {
                 // could not find an image in the article
                 // last chance is maybe webmaster is using Joomla! full text image article feature
                 // note: if we are not on the canonical page (ie the full article display), Joomla!
                 // uses the image_intro instead. However, I decided to still pin the full image
                 // in such case, as the image_intro will most often be a thumbnail
                 // Is this correct? can there be side effects?
                 $imageSrc = '';
                 if ($context == 'com_content.article' && !empty($content->images)) {
                     $registry = new JRegistry();
                     $registry->loadString($content->images);
                     $fulltextImage = $registry->get('image_fulltext');
                     if (!empty($fulltextImage)) {
                         $imageSrc = $fulltextImage;
                         $imageDesc = $registry->get('image_fulltext_alt', '');
                     }
                 }
             } else {
                 // extract image details
                 jimport('joomla.utilities.utility');
                 $attributes = JUtility::parseAttributes($match[1]);
                 $imageSrc = empty($attributes['src']) ? '' : $attributes['src'];
                 $imageDesc = empty($attributes['alt']) ? '' : $attributes['alt'];
             }
         }
         if (!empty($imageSrc)) {
             if (substr($imageSrc, 0, 4) != 'http' && substr($imageSrc, 0, 1) != '/') {
                 // relative url, prepend root url
                 $imageSrc = JURI::base() . $imageSrc;
             }
             $buttonsHtml .= $wrapperOpen;
             $buttonsHtml .= '<a href="http://pinterest.com/pin/create/button/?url=' . urlencode($url) . '&media=' . urlencode($imageSrc) . (empty($imageDesc) ? '' : '&description=' . urlencode($imageDesc)) . '" ' . 'class="pin-it-button" count-layout="' . $this->_params->get('pinItCountLayout', 'none') . '">' . $this->_params->get('pinItButtonText', 'Pin it') . '</a>';
             $buttonsHtml .= $wrapperClose;
         }
     }
     // FB Like
     if ($this->_params->get('enableFbLike', 1) && in_array('facebooklike', $this->_enabledButtons)) {
         $layout = $this->_params->get('fbLayout', '') == 'none' ? '' : $this->_params->get('fbLayout', '');
         if ($this->_params->get('fbUseHtml5', false)) {
             $buttonsHtml .= $wrapperOpen . '<div class="fb-like" data-href="' . $url . '" data-send="' . ($this->_params->get('enableFbSend', 1) ? 'true' : 'false') . '" data-action="' . $this->_params->get('fbAction', '') . '" data-width="' . $this->_params->get('fbWidth', '') . '" data-layout="' . $layout . '" data-show-faces="' . $this->_params->get('fbShowFaces', 'true') . '" data-colorscheme="' . $this->_params->get('fbColorscheme', 'light') . '"></div>' . $wrapperClose;
         } else {
             $buttonsHtml .= $wrapperOpen . '<fb:like href="' . $url . '" send="' . ($this->_params->get('enableFbSend', 1) ? 'true' : 'false') . '" action="' . $this->_params->get('fbAction', '') . '" width="' . $this->_params->get('fbWidth', '') . '" layout="' . $layout . '" show_faces="' . $this->_params->get('fbShowFaces', 'true') . '" colorscheme="' . $this->_params->get('fbColorscheme', '') . '"></fb:like>' . $wrapperClose;
         }
     } else {
         if ($this->_params->get('enableFbSend', 1) && in_array('facebooksend', $this->_enabledButtons)) {
             if ($this->_params->get('fbUseHtml5', false)) {
                 $buttonsHtml .= $wrapperOpen . '<div class="fb-send" data-href="' . $url . '" data-colorscheme="' . $this->_params->get('fbColorscheme', '') . '"></div>' . $wrapperClose;
             } else {
                 $buttonsHtml .= $wrapperOpen . '<fb:send href="' . $url . '" colorscheme="' . $this->_params->get('fbColorscheme', '') . '"></fb:send>' . $wrapperClose;
             }
         }
     }
     // perform replace
     if (!empty($buttonsHtml)) {
         $buttonsHtml = '<div class="sh404sef-social-buttons"><ul>' . $buttonsHtml . '</ul></div>';
     }
     return $buttonsHtml;
 }
Example #29
0
 /**
  * Get all image url|path in $text.
  * @param string $text
  * @return string
  */
 public static function getInlineImages($text)
 {
     $images = array();
     $searchTags = array('img' => '/<img[^>]+>/i', 'input' => '/<input[^>]+type\\s?=\\s?"image"[^>]+>/i');
     foreach ($searchTags as $tag => $regex) {
         preg_match_all($regex, $text, $m);
         if (is_array($m) && isset($m[0]) && count($m[0])) {
             foreach ($m[0] as $htmltag) {
                 $tmp = JUtility::parseAttributes($htmltag);
                 if (isset($tmp['src'])) {
                     if ($tag == 'input') {
                         array_push($images, array('src' => $tmp['src']));
                     } else {
                         array_push($images, $tmp);
                     }
                 }
             }
         }
     }
     return $images;
 }
Example #30
0
function plgContentCreateTOC(&$row, &$matches, &$page)
{
    $heading = $row->title;
    $limitstart = JRequest::getInt('limitstart', 0);
    $showall = JRequest::getInt('showall', 0);
    // TOC Header
    $row->toc = '
	<table cellpadding="0" cellspacing="0" class="contenttoc">
	<tr>
		<th>' . JText::_('Article Index') . '</th>
	</tr>
	';
    // TOC First Page link
    $class = $limitstart === 0 && $showall === 0 ? 'toclink active' : 'toclink';
    $row->toc .= '
	<tr>
		<td>
		<a href="' . JRoute::_('&showall=&limitstart=') . '" class="' . $class . '">' . $heading . '</a>
		</td>
	</tr>
	';
    $i = 2;
    foreach ($matches as $bot) {
        $link = JRoute::_('&showall=&limitstart=' . ($i - 1));
        if (@$bot[0]) {
            $attrs2 = JUtility::parseAttributes($bot[0]);
            if (@$attrs2['alt']) {
                $title = stripslashes($attrs2['alt']);
            } elseif (@$attrs2['title']) {
                $title = stripslashes($attrs2['title']);
            } else {
                $title = JText::sprintf('Page #', $i);
            }
        } else {
            $title = JText::sprintf('Page #', $i);
        }
        $class = $limitstart == $i - 1 ? 'toclink active' : 'toclink';
        $row->toc .= '
			<tr>
				<td>
				<a href="' . $link . '" class="' . $class . '">' . $title . '</a>
				</td>
			</tr>
			';
        $i++;
    }
    // Get Plugin info
    $plugin =& JPluginHelper::getPlugin('content', 'pagebreak');
    $params = new JParameter($plugin->params);
    if ($params->get('showall')) {
        $link = JRoute::_('&showall=1&limitstart=');
        $class = $showall == 1 ? 'toclink active' : 'toclink';
        $row->toc .= '
		<tr>
			<td>
				<a href="' . $link . '" class="' . $class . '">' . JText::_('All Pages') . '</a>
			</td>
		</tr>
		';
    }
    $row->toc .= '</table>';
}