Пример #1
0
 /**
  * Render a file in form/details view, stored data in $this->output
  *
  * @param   object  &$model   Element model
  * @param   object  &$params  Element params
  * @param   string  $file     Row data for this element
  *
  * @return  void
  */
 public function render(&$model, &$params, $file)
 {
     jimport('joomla.filesystem.file');
     /*
      * $$$ hugh - TESTING - if $file is empty, we're going to just build an empty bit of DOM
      * which can then be filled in with the selected image using HTML5 in browser.
      */
     if (empty($file)) {
         if ($params->get('make_thumbnail', false)) {
             $maxWidth = $params->get('thumb_max_width', 125);
             $maxHeight = $params->get('thumb_max_height', 125);
             $this->output .= '<img style="width: ' . $maxWidth . 'px;" src="" alt="" />';
         }
     } else {
         $filename = basename($file);
         $filename = strip_tags($filename);
         $ext = JFile::getExt($filename);
         if (!strstr($file, 'http://') && !strstr($file, 'https://')) {
             // $$$rob only add in livesite if we don't already have a full url (e.g. from amazons3)
             // Trim / or \ off the start of $file
             $file = JString::ltrim($file, '/\\');
             $file = COM_FABRIK_LIVESITE . $file;
         }
         $file = str_replace("\\", "/", $file);
         $file = $model->storage->preRenderPath($file);
         $layout = $model->getLayout('file');
         $displayData = new stdClass();
         $displayData->thumb = COM_FABRIK_LIVESITE . 'media/com_fabrik/images/' . $ext . '.png';
         $displayData->useThumb = $params->get('make_thumbnail', false) && JFile::exists($displayData->thumb);
         $displayData->ext = $ext;
         $displayData->filename = $filename;
         $displayData->file = $file;
         $this->output = $layout->render($displayData);
     }
 }
Пример #2
0
 function revert(&$url_array, $pos)
 {
     global $_SEF_SPACE;
     $QUERY_STRING = '';
     $url_array = array_filter($url_array);
     // V x : traling slash can cause empty array element
     $url_array = array_values($url_array);
     if (!empty($url_array[1]) && strcspn($url_array[1], ',') == strlen($url_array[1])) {
         // This is a nocache url
         $x = 0;
         $c = count($url_array);
         while ($x < $c) {
             if (isset($url_array[$x]) && $url_array[$x] != '' && isset($url_array[$x + 1]) && $url_array[$x + 1] != '') {
                 $QUERY_STRING .= '&' . $url_array[$x] . '=' . $url_array[$x + 1];
             }
             $x += 2;
         }
     } else {
         //This is a default mambo SEF url for a component
         foreach ($url_array as $value) {
             $temp = explode(",", $value);
             if (isset($temp[0]) && $temp[0] != '' && isset($temp[1]) && $temp[1] != "") {
                 $QUERY_STRING .= "&{$temp['0']}={$temp['1']}";
             }
         }
     }
     //return str_replace("&option","option",$QUERY_STRING);
     return JString::ltrim($QUERY_STRING, '&');
 }
Пример #3
0
 /**
  * @param object element model
  * @param object element params
  * @param string row data for this element
  */
 function render(&$model, &$params, $file)
 {
     jimport('joomla.filesystem.file');
     $filename = basename($file);
     $filename = strip_tags($filename);
     $ext = JFile::getExt($filename);
     //$file = str_replace("\\", "/", COM_FABRIK_LIVESITE  . $file);
     if (!strstr($file, 'http://') && !strstr($file, 'https://')) {
         // $$$rob only add in livesite if we dont already have a full url (eg from amazons3)
         // $$$ hugh trim / or \ off the start of $file
         $file = JString::ltrim($file, '/\\');
         $file = COM_FABRIK_LIVESITE . $file;
     }
     $file = str_replace("\\", "/", $file);
     $file = $model->storage->preRenderPath($file);
     $thumb_path = COM_FABRIK_BASE . 'media/com_fabrik/images/' . $ext . '.png';
     // $$$ hugh - using 'make_thumbnail' to mean 'use default $ext.png as an icon
     // instead of just putting the filename.
     if ($params->get('make_thumbnail', false) && JFile::exists($thumb_path)) {
         $thumb_file = COM_FABRIK_LIVESITE . "/media/com_fabrik/images/" . $ext . ".png";
         $this->output = "<a class=\"download-archive fabrik-filetype-{$ext}\" title=\"{$file}\" href=\"{$file}\"><img src=\"{$thumb_file}\" alt=\"{$filename}\"></a>";
     } else {
         $this->output = "<a class=\"download-archive fabrik-filetype-{$ext}\" title=\"{$file}\" href=\"{$file}\">" . $filename . "</a>";
     }
 }
Пример #4
0
 /**
  * Internally render the plugin, and add required script declarations
  * to the document
  *
  * @return  void
  */
 public function render()
 {
     $params = $this->getParams();
     $document = JFactory::getDocument();
     $document->addScript("http://api.simile-widgets.org/runway/1.0/runway-api.js");
     $c = 0;
     $images = (array) $params->get('coverflow_image');
     $titles = (array) $params->get('coverflow_title');
     $subtitles = (array) $params->get('coverflow_subtitle');
     $listIds = (array) $params->get('coverflow_table');
     $eventData = array();
     foreach ($listIds as $listId) {
         $listModel = JModelLegacy::getInstance('List', 'FabrikFEModel');
         $listModel->setId($listId);
         $list = $listModel->getTable();
         $listModel->getPagination(0, 0, 0);
         $image = $images[$c];
         $title = $titles[$c];
         $subtitle = $subtitles[$c];
         $data = $listModel->getData();
         if ($listModel->canView() || $listModel->canEdit()) {
             $elements = $listModel->getElements();
             $imageElement = FArrayHelper::getValue($elements, FabrikString::safeColName($image));
             foreach ($data as $group) {
                 if (is_array($group)) {
                     foreach ($group as $row) {
                         $event = new stdClass();
                         if (!method_exists($imageElement, 'getStorage')) {
                             switch (get_class($imageElement)) {
                                 case 'FabrikModelFabrikImage':
                                     $rootFolder = $imageElement->getParams()->get('selectImage_root_folder');
                                     $rootFolder = JString::ltrim($rootFolder, '/');
                                     $rootFolder = JString::rtrim($rootFolder, '/');
                                     $event->image = COM_FABRIK_LIVESITE . 'images/stories/' . $rootFolder . '/' . $row->{$image . '_raw'};
                                     break;
                                 default:
                                     $event->image = isset($row->{$image . '_raw'}) ? $row->{$image . '_raw'} : '';
                                     break;
                             }
                         } else {
                             $event->image = $imageElement->getStorage()->pathToURL($row->{$image . '_raw'});
                         }
                         $event->title = $title === '' ? '' : (string) strip_tags($row->{$title});
                         $event->subtitle = $subtitle === '' ? '' : (string) strip_tags($row->{$subtitle});
                         $eventData[] = $event;
                     }
                 }
             }
         }
         $c++;
     }
     $json = json_encode($eventData);
     $str = "var coverflow = new FbVisCoverflow({$json});";
     $srcs = FabrikHelperHTML::framework();
     $srcs['Coverflow'] = $this->srcBase . 'coverflow/coverflow.js';
     FabrikHelperHTML::script($srcs, $str);
 }
Пример #5
0
 function _prePayment($data)
 {
     $this->autoload();
     $pingback_url = JString::ltrim(JURI::root() . 'index.php?option=com_bookpro&controller=payment&task=postpayment&paction=display_message&status=success&method=' . $this->_element . '&res=#RC#&fres=#FC#&ac=#APP#&ref=#REF#&tran=#TRANID#&invoice=#INVOICE#&err=#EM#');
     $faild_url = JString::ltrim(JURI::root() . 'index.php?option=com_bookpro&controller=payment&task=postpayment&paction=display_message&status=failed&method=' . $this->_element);
     $config = $this->getConfig();
     $params = array('MERCHKEY' => $config->MERCHKEY, 'TRANTYPE' => 'AUTHPOST', 'AMT' => $this->formatNumber($data['total']), 'CURR' => $config->currency, 'INVOICE' => $data['order_number'], 'URLAPPROVED' => $pingback_url, 'URLOTHER' => $pingback_url);
     JbPaymentLib::write_log('nbd.txt', 'Checkout: ' . json_encode($params));
     JbPaymentLib::submitForm($params, $this->getPaymentUrl($config->testmode));
 }
Пример #6
0
 public static function updateShurls()
 {
     $pageInfo =& Sh404sefFactory::getPageInfo();
     $sefConfig =& Sh404sefFactory::getConfig();
     $pageInfo->shURL = empty($pageInfo->shURL) ? '' : $pageInfo->shURL;
     if ($sefConfig->enablePageId && !$sefConfig->stopCreatingShurls) {
         try {
             jimport('joomla.utilities.string');
             $nonSefUrl = JString::ltrim($pageInfo->currentNonSefUrl, '/');
             $nonSefUrl = shSortURL($nonSefUrl);
             // make sure we have a language
             $nonSefUrl = shSetURLVar($nonSefUrl, 'lang', $pageInfo->currentLanguageShortTag);
             // remove tracking vars (Google Analytics)
             $nonSefUrl = Sh404sefHelperGeneral::stripTrackingVarsFromNonSef($nonSefUrl);
             // try to get the current shURL, if any
             $shURL = ShlDbHelper::selectResult('#__sh404sef_pageids', array('pageid'), array('newurl' => $nonSefUrl));
             // if none, we may have to create one
             if (empty($shURL)) {
                 $shURL = self::_createShurl($nonSefUrl);
             }
             // insert in head and header, if not empty
             if (!empty($shURL)) {
                 $fullShURL = JString::ltrim($pageInfo->getDefaultFrontLiveSite(), '/') . '/' . $shURL;
                 $document = JFactory::getDocument();
                 if ($sefConfig->insertShortlinkTag) {
                     $document->addHeadLink($fullShURL, 'shortlink');
                     // also add header, especially for HEAD requests
                     JResponse::setHeader('Link', '<' . $fullShURL . '>; rel=shortlink', true);
                 }
                 if ($sefConfig->insertRevCanTag) {
                     $document->addHeadLink($fullShURL, 'canonical', 'rev', array('type' => 'text/html'));
                 }
                 if ($sefConfig->insertAltShorterTag) {
                     $document->addHeadLink($fullShURL, 'alternate shorter');
                 }
                 // store for reuse
                 $pageInfo->shURL = $shURL;
             }
         } catch (Exception $e) {
             ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
         }
     }
 }
Пример #7
0
 /**
  * @param object element model
  * @param object element params
  * @param string row data for this element
  */
 function render(&$model, &$params, $file)
 {
     jimport('joomla.filesystem.file');
     $filename = basename($file);
     $filename = strip_tags($filename);
     $ext = JFile::getExt($filename);
     if (!strstr($file, 'http://') && !strstr($file, 'https://')) {
         // $$$rob only add in livesite if we dont already have a full url (eg from amazons3)
         // $$$ hugh trim / or \ off the start of $file
         $file = JString::ltrim($file, '/\\');
         $file = COM_FABRIK_LIVESITE . $file;
     }
     $file = str_replace("\\", "/", $file);
     $file = $model->storage->preRenderPath($file);
     $this->output = "<a class=\"download-archive fabrik-filetype-{$ext}\" title=\"{$filename}\" href=\"{$file}\">";
     if ($thumb_file = $this->getThumbnail($model, $params, $file)) {
         $filename = "<img src=\"{$thumb_file}\" alt=\"{$filename}\" />";
     }
     $this->output .= $filename . "</a>";
 }
Пример #8
0
 public static function updateShurls()
 {
     $sefConfig =& shRouter::shGetConfig();
     // set the short link tag
     $shPageInfo =& shRouter::shPageInfo();
     $shPageInfo->shURL = '';
     if ($sefConfig->enablePageId && !$sefConfig->stopCreatingShurls) {
         try {
             jimport('joomla.utilities.string');
             $nonSefUrl = JString::ltrim($shPageInfo->shCurrentPageNonSef, '/');
             $nonSefUrl = shSortURL($nonSefUrl);
             // remove tracking vars (Google Analytics)
             $nonSefUrl = Sh404sefHelperGeneral::stripTrackingVarsFromNonSef($nonSefUrl);
             // try to get the current shURL, if any
             $shURL = Sh404sefHelperDb::selectResult('#__sh404sef_pageids', array('pageid'), array('newurl' => $nonSefUrl));
             // if none, we may have to create one
             if (empty($shURL)) {
                 $shURL = self::_createShurl($nonSefUrl);
             }
             // insert in head and header, if not empty
             if (!empty($shURL)) {
                 $fullShURL = JString::ltrim($GLOBALS['shConfigLiveSite'], '/') . '/' . $shURL;
                 $document =& JFactory::getDocument();
                 if ($sefConfig->insertShortlinkTag) {
                     $document->addHeadLink($fullShURL, 'shortlink');
                     // also add header, especially for HEAD requests
                     JResponse::setHeader('Link', '<' . $fullShURL . '>; rel=shortlink', true);
                 }
                 if ($sefConfig->insertRevCanTag) {
                     $document->addHeadLink($fullShURL, 'canonical', 'rev', array('type' => 'text/html'));
                 }
                 if ($sefConfig->insertAltShorterTag) {
                     $document->addHeadLink($fullShURL, 'alternate shorter');
                 }
                 // store for reuse
                 $shPageInfo->shURL = $shURL;
             }
         } catch (Sh404sefExceptionDefault $e) {
         }
     }
 }
Пример #9
0
 /**
  * Centralized location to attach asset to any page. It avoids duplicate
  * attachement
  * @staticvar boolean $added
  * @param type $path
  * @param type $type
  * @param type $assetPath
  * @return type
  */
 public function attach($path, $type, $assetPath = '')
 {
     $document = JFactory::getDocument();
     if ($document->getType() != 'html') {
         return;
     }
     if (!empty($assetPath)) {
         $path = $assetPath . $path;
     } else {
         $path = JURI::root(true) . '/components/com_community/' . JString::ltrim($path, '/');
     }
     switch ($type) {
         case 'js':
             $document->addScript($path);
             break;
         case 'css':
             //do not attach style.css if current direction is rtl (style.rtl is loaded from views/view)
             if ($document->direction == 'rtl' && strpos($path, 'style.css') !== false) {
                 break;
             }
             $document->addStyleSheet($path);
             break;
     }
 }
Пример #10
0
 public function createPageId($sefUrl, $nonSefUrl)
 {
     $shURL = '';
     if (!$this->_mustCreatePageid($nonSefUrl)) {
         return $shURL;
     }
     jimport('joomla.utilities.string');
     $sefUrl = JString::ltrim($sefUrl, '/');
     try {
         if (!empty($sefUrl)) {
             // check that we don't already have a shURL for the same SEF url, even if non-sef differ
             $result = (int) Sh404sefHelperDb::count('#__redirection', '*', $this->_db->nameQuote('oldurl') . ' = ? and ' . $this->_db->nameQuote('newurl') . ' <> ?', array($sefUrl, ''));
             if (!empty($result) && $result > 1) {
                 // we already have a SEF URL, so we must already have a shURL as well
                 return $shURL;
             }
         }
         // check this nonsef url does not already have a shURL
         $existingShurl = Sh404sefHelperDb::selectResult('#__sh404sef_pageids', 'pageid', array('newurl' => $nonSefUrl));
         // there already is a shurl for the same non-sef
         if (!empty($existingShurl)) {
             return $existingShurl;
         }
         // if we don't already have a shURL, create the new one
         $shURL = $this->_buildPageId();
         if (!empty($shURL)) {
             // insert in db
             Sh404sefHelperDb::insert('#__sh404sef_pageids', array('newurl' => $nonSefUrl, 'pageid' => $shURL, 'type' => Sh404sefHelperGeneral::COM_SH404SEF_URLTYPE_PAGEID, 'hits' => 0));
         }
     } catch (Sh404sefExceptionDefault $e) {
         _log('DB error creating pageId ' . $e->getMessage());
     }
     // don't need to add the pageid to cache, won't be needed when building up the page,
     //only when decoding incoming url
     return $shURL;
 }
Пример #11
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, '/');
}
Пример #12
0
 /**
  * Called from parseMessageForPlaceHolder to iterate through string to replace
  * {placeholder} with posted data
  *
  * @param   string  $matches  placeholder e.g. {placeholder}
  *
  * @return	string	posted data that corresponds with placeholder
  */
 protected function replaceWithFormData($matches)
 {
     // Merge any join data key val pairs down into the main data array
     $joins = JArrayHelper::getValue($this->_searchData, 'join', array());
     foreach ($joins as $k => $data) {
         foreach ($data as $k => $v) {
             $this->_searchData[$k] = $v;
         }
     }
     $match = $matches[0];
     $orig = $match;
     /* strip the {} */
     $match = JString::substr($match, 1, JString::strlen($match) - 2);
     // $$$ rob test this format searchvalue||defaultsearchvalue
     $bits = explode('||', $match);
     if (count($bits) == 2) {
         $match = self::parseMessageForPlaceHolder('{' . $bits[0] . '}', $this->_searchData, false);
         $default = $bits[1];
         if ($match == '') {
             // 	$$$ rob seems like bits[1] in fabrik plugin is already matched so return that rather then reparsing
             // $match = self::parseMessageForPlaceHolder("{".$bits[1]."}", $this->_searchData);
             return $bits[1] !== '' ? $bits[1] : $orig;
         } else {
             return $match !== '' ? $match : $orig;
         }
     }
     // $$$ hugh - NOOOOOOO!!  Screws up where people actually have mixed case element names
     // $match = JString::strtolower($match);
     $match = preg_replace("/ /", "_", $match);
     if (!strstr($match, '.')) {
         /* for some reason array_key_exists wasnt working for nested arrays?? */
         $aKeys = array_keys($this->_searchData);
         /* remove the table prefix from the post key */
         $aPrefixFields = array();
         for ($i = 0; $i < count($aKeys); $i++) {
             $aKeyParts = explode('___', $aKeys[$i]);
             if (count($aKeyParts) == 2) {
                 $tablePrefix = array_shift($aKeyParts);
                 $field = array_pop($aKeyParts);
                 $aPrefixFields[$field] = $tablePrefix;
             }
         }
         if (array_key_exists($match, $aPrefixFields)) {
             $match = $aPrefixFields[$match] . '___' . $match;
         }
         // Test to see if the made match is in the post key arrays
         $found = in_array($match, $aKeys, true);
         if ($found) {
             /* get the post data */
             $match = $this->_searchData[$match];
             if (is_array($match)) {
                 $newmatch = '';
                 // Deal with radio boxes etc inside repeat groups
                 foreach ($match as $m) {
                     if (is_array($m)) {
                         $newmatch .= ',' . implode(',', $m);
                     } else {
                         $newmatch .= ',' . $m;
                     }
                 }
                 $match = JString::ltrim($newmatch, ',');
             }
         } else {
             $match = '';
         }
     } else {
         /* could be looking for URL field type eg for $_POST[url][link] the match text will be url.link */
         $aMatch = explode(".", $match);
         $aPost = $this->_searchData;
         foreach ($aMatch as $sPossibleArrayKey) {
             if (is_array($aPost)) {
                 if (!isset($aPost[$sPossibleArrayKey])) {
                     return $orig;
                 } else {
                     $aPost = $aPost[$sPossibleArrayKey];
                 }
             }
         }
         $match = $aPost;
     }
     if ($this->_parseAddSlases) {
         $match = htmlspecialchars($match, ENT_QUOTES, 'UTF-8');
     }
     return $found ? $match : $orig;
 }
Пример #13
0
 public static function stripTrackingVarsFromSef($url)
 {
     // do we have query vars?
     $parts = explode('?', $url);
     if (empty($parts[1])) {
         // no variable parts, return identical
         return $url;
     }
     $trackingVars = self::_getTrackingVars();
     $cleaned = self::stripVarsFromNonSef('?' . $parts[1], $trackingVars);
     // rebuild and return
     $cleaned = JString::ltrim($cleaned, '?&');
     $cleaned = $parts[0] . (empty($cleaned) ? '' : '?' . $cleaned);
     return $cleaned;
 }
Пример #14
0
 /**
  * Return the absolute URI path to the resource
  */
 public function getURI($storageId)
 {
     $root = JString::rtrim(JURI::root(), '/');
     $storageId = JString::ltrim($storageId, '/');
     return $root . '/' . $storageId;
 }
Пример #15
0
 /**
  * Render PDF in the form view
  *
  * @param   object &$model  Element model
  * @param   object &$params Element params
  * @param   string $file    Row data for this element
  *
  * @return  void
  */
 public function render(&$model, &$params, $file)
 {
     jimport('joomla.filesystem.file');
     $layout = $model->getLayout('pdf');
     $displayData = new stdClass();
     $filename = basename($file);
     $filename = strip_tags($filename);
     if (!strstr($file, 'http://') && !strstr($file, 'https://')) {
         // $$$rob only add in livesite if we don't already have a full url (e.g. from amazons3)
         // $$$ hugh trim / or \ off the start of $file
         $file = JString::ltrim($file, '/\\');
         $file = COM_FABRIK_LIVESITE . $file;
     }
     $file = str_replace("\\", "/", $file);
     $file = $model->storage->preRenderPath($file);
     $displayData->file = $file;
     $displayData->filename = $filename;
     $displayData->thumb = $this->getThumbnail($model, $params, $file);
     $this->output = $layout->render($displayData);
 }
Пример #16
0
 /**
  * Shows the data formatted for the list view
  *
  * @param   string  $data      elements data
  * @param   object  &$thisRow  all the data in the lists current row
  *
  * @return  string	formatted value
  */
 public function renderListData($data, &$thisRow)
 {
     $gtree = $this->getOpts();
     $filter = JFilterInput::getInstance(null, null, 1, 1);
     foreach ($gtree as $o) {
         if ($o->value == $data) {
             return JString::ltrim($filter->clean($o->text, 'word'), '&nbsp;');
         }
     }
 }
Пример #17
0
                    if (!empty($showall)) {
                        $pageNumber = titleToLocation(JText::_('All Pages'));
                    }
                }
            }
        }
        // V 1.2.4.j 2007/04/11 : numerical ID, on some categories only
        if ($sefConfig->shInsertNumericalId && isset($sefConfig->shInsertNumericalIdCatList) && !empty($id) && $view == 'view') {
            try {
                $contentElement = ShlDbHelper::selectObject('#__content', array('id', 'catid', 'created'), array('id' => $id));
                if (!empty($contentElement)) {
                    // V 1.2.4.t
                    $foundCat = array_search(@$contentElement->catid, $sefConfig->shInsertNumericalIdCatList);
                    if ($foundCat !== null && $foundCat !== false || $sefConfig->shInsertNumericalIdCatList[0] == '') {
                        // test both in case PHP < 4.2.0
                        $shTemp = explode(' ', $contentElement->created);
                        $title[] = str_replace('-', '', $shTemp[0]) . $contentElement->id;
                    }
                }
            } catch (Exception $e) {
                ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
            }
        }
        // end of edition id insertion
        $title = array_reverse($title);
        if (!empty($pageNumber)) {
            // better add page number at end rather than beg
            $title[] = $pageNumber;
        }
        $shCustomTitleTag = JString::ltrim(implode($sefConfig->pageTitleSeparator, $title), '/' . $sefConfig->pageTitleSeparator);
}
Пример #18
0
 /**
  * Shows the data formatted for the list view
  *
  * @param   string    $data      Elements data
  * @param   stdClass  &$thisRow  All the data in the lists current row
  * @param   array     $opts      Rendering options
  *
  * @return  string	formatted value
  */
 public function renderListData($data, stdClass &$thisRow, $opts = array())
 {
     $options = $this->getOpts();
     $text = '';
     if ((string) $data !== '') {
         foreach ($options as $o) {
             if ($o->value == $data) {
                 $text = JString::ltrim(str_replace('-', '', $o->text));
             }
         }
     }
     $layoutData = new stdClass();
     $layoutData->text = $text;
     return parent::renderListData($layoutData, $thisRow, $opts);
 }
Пример #19
0
 function shDoHeadersChanges()
 {
     global $shCanonicalTag;
     $sefConfig =& shRouter::shGetConfig();
     $shPageInfo =& shRouter::shPageInfo();
     // get page details gathered by system plugin
     if (!isset($sefConfig) || empty($sefConfig->shMetaManagementActivated) || empty($shPageInfo->shCurrentPageNonSef)) {
         return;
     }
     // include plugin to build canonical if needed
     shIncludeMetaPlugin();
     // issue headers for canonical
     if (!empty($shCanonicalTag)) {
         jimport('joomla.utilities.string');
         $link = JURI::root(false, '') . JString::ltrim($shCanonicalTag, '/');
         JResponse::setHeader('Link', '<' . $link . '>; rel="canonical"');
     }
 }
Пример #20
0
 function shDoHeadersChanges()
 {
     global $shCanonicalTag;
     $sefConfig =& Sh404sefFactory::getConfig();
     if (!isset($sefConfig) || empty($sefConfig->shMetaManagementActivated) || empty($pageInfo->currentNonSefUrl)) {
         return;
     }
     // include plugin to build canonical if needed
     shIncludeMetaPlugin();
     // issue headers for canonical
     if (!empty($shCanonicalTag)) {
         jimport('joomla.utilities.string');
         $link = JURI::root(false, '') . ltrim($sefConfig->shRewriteStrings[$sefConfig->shRewriteMode], '/') . JString::ltrim($shCanonicalTag, '/');
         JResponse::setHeader('Link', '<' . htmlspecialchars($link, ENT_COMPAT, 'UTF-8') . '>; rel="canonical"');
     }
 }
Пример #21
0
 /**
  * Called from parseMessageForPlaceHolder to iterate through string to replace
  * {placeholder} with posted data
  *
  * @param   string  $matches  Placeholder e.g. {placeholder}
  *
  * @return	string	posted data that corresponds with placeholder
  */
 protected function replaceWithFormData($matches)
 {
     // Merge any join data key val pairs down into the main data array
     $joins = FArrayHelper::getValue($this->_searchData, 'join', array());
     foreach ($joins as $k => $data) {
         foreach ($data as $k => $v) {
             /*
              * Only replace if we haven't explicitly set the key in _searchData.
              * Otherwise, calc element in repeat group uses all repeating groups values rather than the
              * current one that the plugin sets when it fire its Ajax request.
              */
             if (!array_key_exists($k, $this->_searchData)) {
                 $this->_searchData[$k] = $v;
             }
         }
     }
     $match = $matches[0];
     $orig = $match;
     // Strip the {}
     $match = JString::substr($match, 1, JString::strlen($match) - 2);
     /* $$$ hugh - added dbprefix substitution
      * Not 100% if we should do this on $match before copying to $orig, but for now doing it
      * after, so we don't potentially disclose dbprefix if no substitution found.
      */
     $config = JFactory::getConfig();
     $prefix = $config->get('dbprefix');
     $match = str_replace('#__', $prefix, $match);
     // $$$ rob test this format searchvalue||defaultsearchvalue
     $bits = explode('||', $match);
     if (count($bits) == 2) {
         $match = self::parseMessageForPlaceHolder('{' . $bits[0] . '}', $this->_searchData, false);
         $default = $bits[1];
         if ($match == '') {
             // 	$$$ rob seems like bits[1] in fabrik plugin is already matched so return that rather then reparsing
             // $match = self::parseMessageForPlaceHolder("{".$bits[1]."}", $this->_searchData);
             return $bits[1] !== '' ? $bits[1] : $orig;
         } else {
             return $match !== '' ? $match : $orig;
         }
     }
     $match = preg_replace("/ /", "_", $match);
     if (!strstr($match, '.')) {
         // For some reason array_key_exists wasn't working for nested arrays??
         $aKeys = array_keys($this->_searchData);
         // Remove the table prefix from the post key
         $aPrefixFields = array();
         for ($i = 0; $i < count($aKeys); $i++) {
             $aKeyParts = explode('___', $aKeys[$i]);
             if (count($aKeyParts) == 2) {
                 $tablePrefix = array_shift($aKeyParts);
                 $field = array_pop($aKeyParts);
                 $aPrefixFields[$field] = $tablePrefix;
             }
         }
         if (array_key_exists($match, $aPrefixFields)) {
             $match = $aPrefixFields[$match] . '___' . $match;
         }
         // Test to see if the made match is in the post key arrays
         $found = in_array($match, $aKeys, true);
         if ($found) {
             // Get the post data
             $match = $this->_searchData[$match];
             if (is_array($match)) {
                 $newmatch = '';
                 // Deal with radio boxes etc. inside repeat groups
                 foreach ($match as $m) {
                     if (is_array($m)) {
                         $newmatch .= ',' . implode(',', $m);
                     } else {
                         $newmatch .= ',' . $m;
                     }
                 }
                 $match = JString::ltrim($newmatch, ',');
             }
         } else {
             $match = '';
         }
     } else {
         // Could be looking for URL field type e.g. for $_POST[url][link] the match text will be url.link
         $aMatch = explode(".", $match);
         $aPost = $this->_searchData;
         foreach ($aMatch as $sPossibleArrayKey) {
             if (is_array($aPost)) {
                 if (!isset($aPost[$sPossibleArrayKey])) {
                     return $orig;
                 } else {
                     $aPost = $aPost[$sPossibleArrayKey];
                 }
             }
         }
         $match = $aPost;
     }
     if ($this->parseAddSlases) {
         $match = htmlspecialchars($match, ENT_QUOTES, 'UTF-8');
     }
     return $found ? $match : $orig;
 }
Пример #22
0
 /**
  * @group String
  * @covers JString::ltrim
  * @dataProvider ltrimData
  */
 public function testLtrim($string, $charlist, $expect)
 {
     if ($charlist === null) {
         $actual = JString::ltrim($string);
     } else {
         $actual = JString::ltrim($string, $charlist);
     }
     $this->assertEquals($expect, $actual);
 }
Пример #23
0
 /**
 * Parses the TRACK command.
 *
 * @param string $line - The line in the cue file that contains the TRACK command.
 * @param   integer $track_on - The track currently processing.
 */
 function parseTrack($line, $track_on)
 {
     $line = substr($line, strpos($line, ' ') + 1);
     $track = JString::ltrim(substr($line, 0, strpos($line, ' ')), '0');
     //find the data type.
     $datatype = strtolower(substr($line, strpos($line, ' ') + 1));
     $this->cuesheet['tracks'][$track_on] = array('track_number' => $track, 'datatype' => $datatype);
 }
Пример #24
0
 /**
  * Upload the file
  *
  * @param   string  $tmpFile   tmp file location
  * @param   string  $filepath  final upload location
  *
  * @return  bool
  */
 public function upload($tmpFile, $filepath)
 {
     $filepath = str_replace("\\", '/', $filepath);
     $bucket = $this->getBucketName();
     $acl = $this->getAcl();
     if (!$this->bucketExists()) {
         $this->s3->putBucket($bucket, $acl, $this->getLocation());
     }
     // $$$ rob avoid urls like http://bucket.s3.amazonaws.com//home/users/path/to/file/Chrysanthemum.jpg
     $filepath = JString::ltrim($filepath, '/');
     // Move the file
     if ($this->s3->putObjectFile($tmpFile, $bucket, $filepath, $acl)) {
         $this->uploadedFilePath = $this->getS3BaseURL() . str_replace(" ", "%20", $filepath);
         return true;
     } else {
         return false;
     }
 }
Пример #25
0
 function revert(&$url_array, $pos)
 {
     $sefConfig =& shRouter::shGetConfig();
     // get DB
     $database =& JFactory::getDBO();
     $QUERY_STRING = '';
     $req = implode('/', $url_array);
     if ($req != '/') {
         $req = JString::ltrim($req, '/');
     }
     // V x
     $req = str_replace("//", "/", $req);
     _log('sef404 reverting URL : ' . $req);
     // read from db
     $sql = "SELECT oldurl, newurl FROM #__redirection WHERE oldurl = " . $database->Quote($req) . " ORDER BY rank ASC LIMIT 1";
     // V 1.2.4.q
     $database->setQuery($sql);
     $row = $database->loadObject();
     if ($row) {
         // use the cached url
         $string = $row->newurl;
         // check for urls using wrong letter case, 301 redirect to correct url case
         $shPageInfo =& shRouter::shPageInfo();
         if (empty($shPageInfo->autoRedirectsDisabled) && $sefConfig->redirectToCorrectCaseUrl) {
             // if initial query exactly matches oldurl found in db, then case is correct
             // else we redirect to the url found in db, but we also need to append query string to it !
             if ($req != $row->oldurl) {
                 // can only be different from case
                 // what is the url we should redirect to ?
                 $targetUrl = str_replace($req, $row->oldurl, $shPageInfo->shSaveRequestURI);
                 $targetUrl = $shPageInfo->URI->protocol . '://' . $shPageInfo->URI->host . (!sh404SEF_USE_NON_STANDARD_PORT || empty($shPageInfo->URI->port) ? '' : ':' . $shPageInfo->URI->port) . $targetUrl . (empty($shPageInfo->URI->anchor) ? '' : '#' . $shPageInfo->URI->anchor);
                 // perform redirect
                 _log('Redirecting to correct url case : from ' . $req . ' to ' . $targetUrl);
                 shRedirect($targetUrl);
             }
         }
         // keep going if we did not redirect to correct case
         _log('sef404 reverting URL : found : ' . $row->newurl);
         // update the count
         $database->setQuery("UPDATE #__redirection SET cpt=(cpt+1) WHERE `newurl` = " . $database->Quote($row->newurl) . " AND `oldurl` = " . $database->Quote($row->oldurl));
         // V 1.2.4.q
         $database->query();
         // now we must merge query string from request and POST data with that found in db
         // as there might be common variables. For instance, limit=5 in the DB
         // but limit=10 as been pass as POST DATA from a drop-down list item
         $otherVars = empty($shPageInfo->URI->querystring) ? array() : $shPageInfo->URI->querystring;
         $postVars = JRequest::get('post');
         $otherVars = array_merge($otherVars, $postVars);
         if (!empty($otherVars)) {
             foreach ($otherVars as $key => $value) {
                 // if var exists in the incoming url, override it with querystring or post var value
                 if (shGetURLVar($string, $key, null) !== null) {
                     // if we change the value of limit, we must reset limitstart, or we may end up
                     // with weird page number
                     if ($key == 'limit') {
                         $limit = shGetURLVar($string, 'limit', null);
                         if (!is_null($limit) && $value != $limit) {
                             // we are changing limit value : is there a limitstart ?
                             $limitstart = shGetURLVar($string, 'limitstart', null);
                             if (!is_null($limitstart)) {
                                 // calculate a new limitstart
                                 $limitstart = empty($limit) ? 0 : floor($limitstart / $limit) - 1;
                                 $limitstart = $limitstart < 0 ? 0 : $limitstart;
                                 // and set it
                                 $string = shSetURLVar($string, 'limitstart', $limitstart, $canBeEmpty = true);
                                 // kill any remaining limitstart value
                                 if (array_key_exists('limitstart', $otherVars)) {
                                     unset($otherVars['limitstart']);
                                 }
                             }
                         }
                     }
                     // now apply new value for the key
                     $string = shSetURLVar($string, $key, $value);
                 }
             }
         }
         $string = str_replace('&amp;', '&', $string);
         $QUERY_STRING = str_replace('index.php?', '', $string);
         // so weird : because of how Joomla choose to not include $limit in urls, I must remove &limit=xx from the restored url
         // I do have to store it in db however, otherwise same sef will be associated with same non-sef, and then
         // Joomla content views will be screwed up also as they guess $limit and reset JRequest('limit');
         if (!empty($QUERY_STRING)) {
             $QUERY_STRING = '&' . $QUERY_STRING;
             $option = shGetURLVar($QUERY_STRING, 'option');
             $layout = shGetURLVar($QUERY_STRING, 'layout');
             if (empty($layout)) {
                 $layout = 'default';
             }
             $view = shGetURLVar($QUERY_STRING, 'view');
             if ($option == 'com_content' && $layout != 'blog' && ($view == 'category' || $view == 'section')) {
                 $limit = shGetURLVar($QUERY_STRING, 'limit');
                 //$QUERY_STRING = shCleanUpVar( $QUERY_STRING, 'limit');
                 // but we need to keep it, because of a bug in Joomla, which I could not trace
                 // whereby the user state limit value in com_content.default.limit is that of the blog instead of that of the current view
                 global $mainframe;
                 $mainframe->setUserState('com_content.sh.' . $view . '.' . $layout . '.limit', $limit);
                 //_log( 'Removing limit from reverted url, to : ' . $QUERY_STRING);
             }
             $QUERY_STRING = JString::ltrim($QUERY_STRING, '&');
         }
     }
     return $QUERY_STRING;
 }
Пример #26
0
 /**
  * Builds an array containing the filters value and condition
  *
  * @param   string  $value      initial value
  * @param   string  $condition  intial $condition
  * @param   string  $eval       how the value should be handled
  *
  * @return  array	(value condition)
  */
 public function getFilterValue($value, $condition, $eval)
 {
     $this->escapeQueryValue($condition, $value);
     $db = FabrikWorker::getDbo();
     if (is_array($value)) {
         // Ranged search
         list($value, $condition) = $this->getRangedFilterValue($value);
     } else {
         switch ($condition) {
             case 'notequals':
             case '<>':
                 $condition = "<>";
                 // 2 = subquery so dont quote
                 $value = $eval == FABRIKFILTER_QUERY ? '(' . $value . ')' : $db->quote($value);
                 break;
             case 'equals':
             case '=':
                 $condition = "=";
                 $value = $eval == FABRIKFILTER_QUERY ? '(' . $value . ')' : $db->quote($value);
                 break;
             case 'begins':
             case 'begins with':
                 $condition = "LIKE";
                 $value = $eval == FABRIKFILTER_QUERY ? '(' . $value . ')' : $db->quote($value . '%');
                 break;
             case 'ends':
             case 'ends with':
                 // @TODO test this with subsquery
                 $condition = "LIKE";
                 $value = $eval == FABRIKFILTER_QUERY ? '(' . $value . ')' : $db->quote('%' . $value);
                 break;
             case 'contains':
                 // @TODO test this with subsquery
                 $condition = "LIKE";
                 $value = $eval == FABRIKFILTER_QUERY ? '(' . $value . ')' : $db->quote('%' . $value . '%');
                 break;
             case '>':
             case '&gt;':
             case 'greaterthan':
                 $condition = '>';
                 break;
             case '<':
             case '&lt;':
             case 'lessthan':
                 $condition = '<';
                 break;
             case '>=':
             case '&gt;=':
             case 'greaterthanequals':
                 $condition = '>=';
                 break;
             case '<=':
             case '&lt;=':
             case 'lessthanequals':
                 $condition = '<=';
                 break;
             case 'in':
                 $condition = 'IN';
                 $value = $eval == FABRIKFILTER_QUERY ? '(' . $value . ')' : '(' . $value . ')';
                 break;
             case 'not_in':
                 $condition = 'NOT IN';
                 $value = $eval == FABRIKFILTER_QUERY ? '(' . $value . ')' : '(' . $value . ')';
                 break;
         }
         switch ($condition) {
             case '>':
             case '<':
             case '>=':
             case '<=':
                 if ($eval == FABRIKFILTER_QUERY) {
                     $value = '(' . $value . ')';
                 } else {
                     if (!is_numeric($value)) {
                         $value = $db->quote($value);
                     }
                 }
                 break;
         }
         // $$$ hugh - if 'noquotes' (3) selected, strip off the quotes again!
         if ($eval == FABRKFILTER_NOQUOTES) {
             // $$$ hugh - darn, this is stripping the ' of the end of things like "select & from foo where bar = '123'"
             $value = JString::ltrim($value, "'");
             $value = JString::rtrim($value, "'");
         }
         if ($condition == '=' && $value == "'_null_'") {
             $condition = " IS NULL ";
             $value = '';
         }
     }
     return array($value, $condition);
 }
Пример #27
0
 /**
  * Get the root folder for images
  *
  * @param   string  $value  Value
  *
  * @return  string  root folder
  */
 protected function rootFolder($value = '')
 {
     $rootFolder = '';
     $params = $this->getParams();
     $canSelect = $params->get('image_front_end_select', '0') && JString::substr($value, 0, 4) !== 'http';
     $defaultImg = $params->get('imagepath');
     // Changed first || from a && - http://fabrikar.com/forums/index.php?threads/3-1rc1-image-list-options-bug.36585/#post-184266
     if ($canSelect || (JFolder::exists($defaultImg) || JFolder::exists(COM_FABRIK_BASE . $defaultImg))) {
         $rootFolder = $defaultImg;
     }
     // $$$ hugh - tidy up a bit so we don't have so many ///'s in the URL's
     $rootFolder = JString::ltrim($rootFolder, '/');
     $rootFolder = JString::rtrim($rootFolder, '/');
     $rootFolder = $rootFolder === '' ? '' : $rootFolder . '/';
     return $rootFolder;
 }
Пример #28
0
 /**
  * Get Playlist
  *
  * @return string
  */
 protected function getPlaylist()
 {
     $app = JFactory::getApplication();
     $package = $app->getUserState('com_fabrik.package', 'fabrik');
     $params = $this->getParams();
     $mediaElement = $params->get('media_media_elementList');
     $mediaElement .= '_raw';
     $titleElement = $params->get('media_title_elementList', '');
     $imageElement = $params->get('media_image_elementList', '');
     if (!empty($imageElement)) {
         $imageElement .= '_raw';
     }
     $infoElement = $params->get('media_info_elementList', '');
     $noteElement = $params->get('media_note_elementList', '');
     $dateElement = $params->get('media_published_elementList', '');
     $listid = $params->get('media_table');
     $listModel = JModelLegacy::getInstance('list', 'FabrikFEModel');
     $listModel->setId($listid);
     $list = $listModel->getTable();
     $form = $listModel->getFormModel();
     /*
      * remove filters?
      * $$$ hugh - remove pagination BEFORE calling render().  Otherwise render() applies
      * session state/defaults when it calls getPagination, which is then returned as a cached
      * object if we call getPagination after render().  So call it first, then render() will
      * get our cached pagination, rather than vice versa.
      * Changes in f3 seem to mean that we'll have to poke around in the user state,
      * rather than just call getPagination().  So we need to remember previous state of
      * limitstart and limitlength, set them to 0, render the list, then reset to original
      * values (so we don't mess with any instances of the list user may load).  This code
      * seems to kinda work.  Once I've tested it further, will probably move it into to
      * a generic viz model method, so all viz's can call it.
      */
     $context = 'com_' . $package . '.list' . $listModel->getRenderContext() . '.';
     $item = $listModel->getTable();
     $rowsPerPage = FabrikWorker::getMenuOrRequestVar('rows_per_page', $item->rows_per_page);
     $orig_limitstart = $app->getUserState('limitstart', 0);
     $orig_limitlength = $app->getUserState('limitlength', $rowsPerPage);
     $app->setUserState($context . 'limitstart', 0);
     $app->setUserState($context . 'limitlength', 0);
     $nav = $listModel->getPagination(0, 0, 0);
     $listModel->render();
     $alldata = $listModel->getData();
     $app->setUserState($context . 'limitstart', $orig_limitstart);
     $app->setUserState($context . 'limitlength', $orig_limitlength);
     $document = JFactory::getDocument();
     if ($params->get('media_which_player', 'jw') == 'xspf') {
         $retstr = "<?xml version=\"1.0\" encoding=\"" . $document->_charset . "\"?>\n";
         $retstr .= "<playlist version=\"1\" xmlns = \"http://xspf.org/ns/0/\">\n";
         $retstr .= "\t<title>" . $list->label . "</title>\n";
         $retstr .= "\t<trackList>\n";
         foreach ($alldata as $data) {
             foreach ($data as $row) {
                 if (!isset($row->{$mediaElement})) {
                     continue;
                 }
                 $location = $row->{$mediaElement};
                 if (empty($location)) {
                     continue;
                 }
                 $location = str_replace('\\', '/', $location);
                 $location = JString::ltrim($location, '/');
                 $location = COM_FABRIK_LIVESITE . $location;
                 $retstr .= "\t\t<track>\n";
                 $retstr .= "\t\t\t<location>" . $location . "</location>\n";
                 if (!empty($titleElement)) {
                     $title = $row->{$titleElement};
                     $retstr .= "\t\t\t<title>" . $title . "</title>\n";
                 }
                 if (!empty($imageElement)) {
                     $image = $row->{$imageElement};
                     if (!empty($image)) {
                         $image = str_replace('\\', '/', $image);
                         $image = JString::ltrim($image, '/');
                         $image = COM_FABRIK_LIVESITE . $image;
                         $retstr .= "\t\t\t<image>" . $image . "</image>\n";
                     }
                 }
                 if (!empty($noteElement)) {
                     $note = $row->{$noteElement};
                     $retstr .= "\t\t\t<annotation>" . $note . "</annotation>\n";
                 }
                 if (!empty($infoElement)) {
                     $link = $row->{$titleElement};
                     $retstr .= "\t\t\t<info>" . $link . "</info>\n";
                 } else {
                     $link = JRoute::_('index.php?option=com_' . $package . '&view=form&formid=' . $form->getId() . '&rowid=' . $row->__pk_val);
                     $retstr .= "\t\t\t<info>" . $link . "</info>\n";
                 }
                 $retstr .= "\t\t</track>\n";
             }
         }
         $retstr .= "\t</trackList>\n";
         $retstr .= "</playlist>\n";
     } else {
         $retstr = "<?xml version=\"1.0\" encoding=\"" . $document->_charset . "\"?>\n";
         $retstr .= '<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">' . "\n";
         $retstr .= "<channel>\n";
         $retstr .= "\t<title>" . $list->label . "</title>\n";
         foreach ($alldata as $data) {
             foreach ($data as $row) {
                 if (!isset($row->{$mediaElement})) {
                     continue;
                 }
                 $location = $row->{$mediaElement};
                 if (empty($location)) {
                     continue;
                 }
                 $location = str_replace('\\', '/', $location);
                 $location = JString::ltrim($location, '/');
                 $location = COM_FABRIK_LIVESITE . $location;
                 $retstr .= "\t\t<item>\n";
                 $retstr .= '			<media:content url="' . $location . '" />' . "\n";
                 if (!empty($titleElement)) {
                     $title = $row->{$titleElement};
                     $retstr .= "\t\t\t<title>" . $title . "</title>\n";
                 }
                 if (!empty($imageElement)) {
                     $image = $row->{$imageElement};
                     if (!empty($image)) {
                         $image = str_replace('\\', '/', $image);
                         $image = JString::ltrim($image, '/');
                         $image = COM_FABRIK_LIVESITE . $image;
                         $retstr .= '			<media:thumbnail url="' . $image . '" />' . "\n";
                     }
                 }
                 if (!empty($noteElement)) {
                     $note = $row->{$noteElement};
                     $retstr .= "\t\t\t<description>" . $note . "</description>\n";
                 }
                 if (!empty($infoElement)) {
                     $link = $row->{$titleElement};
                     $retstr .= "\t\t\t<link>" . $link . "</link>\n";
                 } else {
                     $link = JRoute::_('index.php?option=com_' . $package . '&view=form&formid=' . $form->getId() . '&rowid=' . $row->__pk_val);
                     $retstr .= "\t\t\t<link>" . $link . "</link>\n";
                 }
                 if (!empty($dateElement)) {
                     $pubDate =& JFactory::getDate($row->{$dateElement});
                     $retstr .= "\t\t\t<pubDate>" . htmlspecialchars($pubDate->toRFC822(), ENT_COMPAT, 'UTF-8') . "</pubDate>\n";
                 }
                 $retstr .= "\t\t</item>\n";
             }
         }
         $retstr .= "</channel>\n";
         $retstr .= "</rss>\n";
     }
     return $retstr;
 }
Пример #29
0
 /**
  * Search various folder locations for an image
  *
  * @param   string $file file name
  * @param   string $type type e.g. form/list/element
  * @param   string $tmpl template folder name
  *
  * @return  string    full path name if found, original filename if not found
  */
 public static function getImagePath($file, $type = 'form', $tmpl = '')
 {
     $file = JString::ltrim($file, DIRECTORY_SEPARATOR);
     $paths = self::addPath('', 'image', $type, true);
     foreach ($paths as $path) {
         $path = sprintf($path, $tmpl);
         $src = $path . $file;
         if (JFile::exists($src)) {
             return $src;
         }
     }
     return '';
 }
Пример #30
0
 /**
  * Draws the html form element
  *
  * @param   array  $data           to pre-populate element with
  * @param   int    $repeatCounter  repeat group counter
  *
  * @return  string	elements html
  */
 public function render($data, $repeatCounter = 0)
 {
     $params = $this->getParams();
     $name = $this->getHTMLName($repeatCounter);
     $value = $this->getValue($data, $repeatCounter);
     $id = $this->getHTMLId($repeatCounter);
     $rootFolder = $this->rootFolder($value);
     if ($rootFolder != '/') {
         $value = str_replace($rootFolder, '', $value);
     }
     // $$$ rob - 30/06/2011 can only select an image if its not a remote image
     $canSelect = $params->get('image_front_end_select', '0') && JString::substr($value, 0, 4) !== 'http';
     // $$$ hugh - tidy up a bit so we don't have so many ///'s in the URL's
     $rootFolder = JString::ltrim($rootFolder, '/');
     $rootFolder = JString::rtrim($rootFolder, '/');
     $rootFolder = $rootFolder === '' ? '' : $rootFolder . '/';
     // $$$ rob - 30/062011 allow for full urls in the image. (e.g from csv import)
     $defaultImage = JString::substr($value, 0, 4) == 'http' ? $value : COM_FABRIK_LIVESITE . $rootFolder . $value;
     $float = $params->get('image_float');
     $float = $float != '' ? "style='float:{$float};'" : '';
     $str = array();
     $str[] = '<div class="fabrikSubElementContainer" id="' . $id . '">';
     $rootFolder = str_replace('/', DS, $rootFolder);
     if ($canSelect && $this->isEditable()) {
         $str[] = '<img src="' . $defaultImage . '" alt="' . $value . '" ' . $float . ' class="imagedisplayor"/>';
         if (array_key_exists($name, $data)) {
             if (trim($value) == '' && $rootFolder === '') {
                 $path = "/";
             } else {
                 $bits = explode("/", $value);
                 if (count($bits) > 1) {
                     $path = '/' . array_shift($bits) . '/';
                     $path = $rootFolder . $path;
                     $val = array_shift($bits);
                 } else {
                     $path = $rootFolder;
                 }
             }
         } else {
             $path = $rootFolder;
         }
         $images = array();
         $imagenames = (array) JFolder::files(JPATH_SITE . '/' . $path);
         foreach ($imagenames as $n) {
             $images[] = JHTML::_('select.option', $n, $n);
         }
         // $$$rob not sure about his name since we are adding $repeatCounter to getHTMLName();
         $imageName = $this->getGroupModel()->canRepeat() ? FabrikString::rtrimWord($name, "][{$repeatCounter}]") . "_image][{$repeatCounter}]" : $id . '_image';
         $bits = explode('/', $value);
         $image = array_pop($bits);
         // $$$ hugh - append $rootFolder to JPATH_SITE, otherwise we're showing folders
         // they aren't supposed to be able to see.
         $folders = JFolder::folders(JPATH_SITE . DS . $rootFolder);
         // @TODO - if $folders is empty, hide the button/widget?  All they can do is select
         // from the initial image dropdown list, so no point having the widget for changing folder?
         $str[] = '<br/>' . JHTML::_('select.genericlist', $images, $imageName, 'class="inputbox imageselector" ', 'value', 'text', $image);
         $str[] = FabrikHelperHTML::folderAjaxSelect($folders);
         $str[] = '<input type="hidden" name="' . $name . '" value="' . $value . '" class="fabrikinput hiddenimagepath folderpath" />';
     } else {
         $w = new FabrikWorker();
         $value = $w->parseMessageForPlaceHolder($value, $data);
         $linkURL = $params->get('link_url', '');
         $imgstr = '<img src="' . $defaultImage . '" alt="' . $value . '" ' . $float . ' class="imagedisplayor"/>' . "\n";
         if ($linkURL) {
             $imgstr = '<a href="' . $linkURL . '" target="_blank">' . $imgstr . '</a>';
         }
         $str[] = $imgstr;
         $str[] = '<input type="hidden" name="' . $name . '" value="' . $value . '" class="fabrikinput hiddenimagepath folderpath" />';
     }
     $str[] = '</div>';
     return implode("\n", $str);
 }