当前位置: 首页>>代码示例>>PHP>>正文


PHP JString::rtrim方法代码示例

本文整理汇总了PHP中JString::rtrim方法的典型用法代码示例。如果您正苦于以下问题:PHP JString::rtrim方法的具体用法?PHP JString::rtrim怎么用?PHP JString::rtrim使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JString的用法示例。


在下文中一共展示了JString::rtrim方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: saveFromInput

 /**
  * Save a list of aliases as entered by user in backend to the database
  *
  * @param string $aliasList data from an html textarea field
  * @param string $nonSefUrl the non sef url to which aliases are attached
  *
  * @return boolean true on success
  */
 public function saveFromInput($aliasList, $nonSefUrl)
 {
     // split aliases from raw input data into an array
     $aliasList = explode("\n", $aliasList);
     // delete them all. We should do a transaction, but not worth it
     $query = 'DELETE from #__sh404sef_aliases where newurl = ' . $this->_db->Quote($nonSefUrl);
     $this->_db->setQuery($query);
     $this->_db->query();
     // Write new aliases. We use a raw db query instead of table
     // so as to write them all in one pass. Could be done by the table
     if (!empty($aliasList[0])) {
         $query = 'INSERT INTO #__sh404sef_aliases (newurl, alias, type) VALUES __shValues__;';
         $values = '';
         $endOfLine = array("\r\n", "\n", "\r");
         foreach ($aliasList as $alias) {
             $alias = str_replace($endOfLine, '', $alias);
             if (!empty($alias)) {
                 $values .= '(' . $this->_db->Quote($nonSefUrl) . ', ' . $this->_db->Quote(htmlspecialchars_decode($alias)) . ', ' . $this->_db->Quote(Sh404sefHelperGeneral::COM_SH404SEF_URLTYPE_ALIAS) . '),';
             }
         }
         $query = str_replace('__shValues__', JString::rtrim($values, ','), $query);
         $this->_db->setQuery($query);
         $this->_db->query();
         // check errors
         $error = $this->_db->getErrorNum();
         if (!empty($error)) {
             $this->setError('Internal database error # ' . $error);
         }
     }
     // return true if no error
     $error = $this->getError();
     return empty($error);
 }
开发者ID:justinlyon,项目名称:scc,代码行数:41,代码来源:aliases.php

示例2: vm_sef_get_category_title

function vm_sef_get_category_title(&$db, &$catDesc, $category_id, $option, $shLangName)
{
    global $shMosConfig_locale;
    $sefConfig =& shRouter::shGetConfig();
    if (empty($category_id)) {
        return '';
    }
    $q = "SELECT c.category_name, c.category_id, c.category_description, x.category_parent_id FROM #__vm_category AS c";
    $q .= "\n LEFT JOIN #__vm_category_xref AS x ON c.category_id = x.category_child_id;";
    $db->setQuery($q);
    if (!shTranslateUrl($option, $shLangName)) {
        // V 1.2.4.m
        $tree = $db->loadObjectList('category_id', false);
    } else {
        $tree = $db->loadObjectList('category_id');
    }
    $catDesc = $tree[$category_id]->category_description;
    $title = '';
    $securityCounter = 0;
    do {
        // all categories and subcategories
        $securityCounter++;
        $title .= ($sefConfig->shInsertCategoryId ? $tree[$category_id]->category_id . $sefConfig->replacement : '') . $tree[$category_id]->category_name . ' | ';
        $category_id = $tree[$category_id]->category_parent_id;
    } while ($category_id != 0 && $securityCounter < 10);
    if ($securityCounter >= 10) {
        JError::raiseError(500, 'Unable to create SEF url for Virtuemart: could not find category with id : ' . $category_id);
    }
    return JString::rtrim($title, ' | ');
}
开发者ID:sangkasi,项目名称:joomla,代码行数:30,代码来源:com_virtuemart.php

示例3: render

 /**
  * 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);
 }
开发者ID:jfquestiaux,项目名称:fabrik,代码行数:63,代码来源:coverflow.php

示例4: init

 public function init()
 {
     static $_initialized = false;
     if (!$_initialized) {
         $this->originalUri = $this->getURI();
         $uri = JURI::getInstance();
         $this->currentSefUrl = $uri->toString();
         $site = $uri->toString(array('scheme', 'host', 'port'));
         $this->basePath = JString::rtrim(str_replace($site, '', $uri->base()), '/');
         $this->loadHomepages();
     }
 }
开发者ID:alesconti,项目名称:FF_2015,代码行数:12,代码来源:pageinfo.php

示例5: su_char_limit

function su_char_limit($str, $limit = 150, $end_char = '...')
{
    if (JString::trim($str) == '') {
        return $str;
    }
    // always strip tags for text
    $str = strip_tags(JString::trim($str));
    $find = array("/\r|\n/u", "/\t/u", "/\\s\\s+/u");
    $replace = array(" ", " ", " ");
    $str = preg_replace($find, $replace, $str);
    if (JString::strlen($str) > $limit) {
        $str = JString::substr($str, 0, $limit);
        return JString::rtrim($str) . $end_char;
    } else {
        return $str;
    }
}
开发者ID:jhener79,项目名称:vlakc,代码行数:17,代码来源:tools.php

示例6: getPath

 public static function getPath($type = 'site')
 {
     jimport('joomla.filesystem.file');
     $application = JFactory::getApplication();
     if ($type == 'k2') {
         $path = JPATH_SITE . '/media/k2/galleries';
     } else {
         if ($type == 'site') {
             $user = JFactory::getUser();
             if (version_compare(JVERSION, '2.5', 'ge')) {
                 $isAdmin = $user->authorise('core.admin', 'com_sigpro');
             } else {
                 $isAdmin = $user->gid == 25;
             }
             if ($application->isAdmin() || $isAdmin) {
                 if (version_compare(JVERSION, '1.6.0', 'ge')) {
                     $defaultImagePath = 'images';
                 } else {
                     $defaultImagePath = 'images/stories';
                 }
                 $params = JComponentHelper::getParams('com_sigpro');
                 $path = JPATH_SITE . '/' . $params->get('galleries_rootfolder', $defaultImagePath);
             } else {
                 $folder = self::getUserFolder();
                 $path = JPATH_SITE . '/media/jw_sigpro/users/' . $folder;
                 if (!JFolder::exists($path)) {
                     JFolder::create($path);
                 }
             }
         } else {
             if ($type == 'users') {
                 $path = JPATH_SITE . '/media/jw_sigpro/users';
             }
         }
     }
     $path = JPath::clean($path);
     JPath::check($path);
     if (JString::substr($path, -1, 1) == DIRECTORY_SEPARATOR) {
         $path = JString::rtrim($path, DIRECTORY_SEPARATOR);
     }
     return $path;
 }
开发者ID:SeventF,项目名称:ikea.com,代码行数:42,代码来源:helper.php

示例7: render

 /**
  * 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);
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:80,代码来源:image.php

示例8: onSh404sefInsertSocialButtons

 /**
  * Insert appropriate script links into document
  */
 public function onSh404sefInsertSocialButtons(&$page, $sefConfig)
 {
     $app = JFactory::getApplication();
     // are we in the backend - that would be a mistake
     if (!defined('SH404SEF_IS_RUNNING') || $app->isAdmin()) {
         return;
     }
     // don't display on errors
     $pageInfo = Sh404sefFactory::getPageInfo();
     if (!empty($pageInfo->httpStatus) && $pageInfo->httpStatus == 404) {
         return;
     }
     // regexp to catch plugin requests
     $regExp = '#{sh404sef_social_buttons(.*)}#Us';
     // search for our marker}
     if (preg_match_all($regExp, $page, $matches, PREG_SET_ORDER) > 0) {
         // process matches
         foreach ($matches as $id => $match) {
             $url = '';
             $imageSrc = '';
             $imageDesc = '';
             // extract target URL
             if (!empty($match[1])) {
                 //normally, there is no quotes around attributes
                 // but a description will probably have spaces, so we
                 // now try to get attributes from both syntax
                 jimport('joomla.utilities.utility');
                 $attributes = JUtility::parseAttributes($match[1]);
                 $url = empty($attributes['url']) ? '' : $attributes['url'];
                 $imageSrc = empty($attributes['img']) ? '' : $attributes['img'];
                 $imageDesc = empty($attributes['desc']) ? '' : $attributes['desc'];
                 $type = empty($attributes['type']) ? '' : $attributes['type'];
                 // now process usual tags
                 $raw = explode(' ', $match[1]);
                 $attributes = array();
                 $enabledButtons = array();
                 foreach ($raw as $attribute) {
                     $attribute = JString::trim($attribute);
                     if (strpos($attribute, '=') === false) {
                         continue;
                     }
                     $bits = explode('=', $attribute);
                     if (empty($bits[1])) {
                         continue;
                     }
                     switch ($bits[0]) {
                         case 'url':
                             if (empty($url)) {
                                 $base = JURI::base(true);
                                 if (substr($bits[1], 0, 10) == 'index.php?') {
                                     $url = JURI::getInstance()->toString(array('scheme', 'host', 'port')) . JRoute::_($bits[1]);
                                 } else {
                                     if (substr($bits[1], 0, JString::strlen($base)) == $base) {
                                         $url = JURI::getInstance()->toString(array('scheme', 'host', 'port')) . $bits[1];
                                     } else {
                                         if (substr($bits[1], 0, 1) == '/') {
                                             $url = JString::rtrim(JURI::base(), '/') . $bits[1];
                                         } else {
                                             $url = $bits[1];
                                         }
                                     }
                                 }
                             }
                             break;
                         case 'type':
                             $newType = trim(strtolower($bits[1]));
                             if (!in_array($newType, $enabledButtons)) {
                                 $enabledButtons[] = $newType;
                             }
                             break;
                         case 'img':
                             $imageSrc = empty($imageSrc) ? strtolower($bits[1]) : $imageSrc;
                             break;
                     }
                 }
                 if (!empty($enabledButtons)) {
                     $this->_enabledButtons = $enabledButtons;
                 }
             }
             // get buttons html
             $buttons = $this->_sh404sefGetSocialButtons($sefConfig, $url, $context = '', $content = null, $imageSrc, $imageDesc);
             $buttons = str_replace('\'', '\\\'', $buttons);
             // replace in document
             $page = str_replace($match[0], $buttons, $page);
         }
     }
     // insert head links as needed
     $this->_insertSocialLinks($page, $sefConfig);
 }
开发者ID:lautarodragan,项目名称:ideary,代码行数:92,代码来源:sh404sefsocial.php

示例9: shIsAnyHomepage

function shIsAnyHomepage( $string) {

  static $pages = array();
  static $home = '';
  static $cleanedHomeLinks = array();

  if( !isset( $pages[$string])) {
    $pageInfo = & Sh404sefFactory::getPageInfo();
    if(empty( $cleanedHomeLinks)) {
      foreach( $pageInfo->homeLinks as $link) {
        $cleanedHomeLinks[] = shCleanUpPag( $link);
      }
    }

    $shTempString = JString::rtrim(str_replace($pageInfo->getDefaultLiveSite(), '', $string), '/');
    $shTempString = shSortUrl(shCleanUpPag($shTempString));

    // check all homepages
    $pages[$string] = false;
    foreach( $cleanedHomeLinks as $link) {
      if( $link == $shTempString) {
        $pages[$string] = true;
      }
    }

  }
  return $pages[$string];
}
开发者ID:srbsnkr,项目名称:sellingonlinemadesimple,代码行数:28,代码来源:sh404sef.class.php

示例10: testRtrim

 /**
  * @group String
  * @covers JString::rtrim
  * @dataProvider rtrimData
  */
 public function testRtrim($string, $charlist, $expect)
 {
     if ($charlist === null) {
         $actual = JString::rtrim($string);
     } else {
         $actual = JString::rtrim($string, $charlist);
     }
     $this->assertEquals($expect, $actual);
 }
开发者ID:GMaup,项目名称:joomla-platform,代码行数:14,代码来源:JStringTest.php

示例11: _log

             }
         }
     }
     //Make sure host name matches our config, we need this later.
     if (strpos($GLOBALS['shConfigLiveSite'], $shPageInfo->URI->host) === false && strpos($sefConfig->shConfig_live_secure_site, $shPageInfo->URI->host) === false) {
         _log('Redirecting to home : host don\'t match our config : ' . $GLOBALS['shConfigLiveSite'] . ' | ' . $shPageInfo->URI->host . ' | ' . $sefConfig->shConfig_live_secure_site);
         shRedirect($GLOBALS['shConfigLiveSite']);
     } else {
         $shPageInfo->shCurrentPageURL = $shPageInfo->URI->protocol . '://' . $shPageInfo->URI->host . (!sh404SEF_USE_NON_STANDARD_PORT || empty($shPageInfo->URI->port) ? '' : ':' . $shPageInfo->URI->port) . $shPageInfo->URI->path;
         _log('Current page URL : ' . $shPageInfo->shCurrentPageURL);
         $shPageInfo->shCurrentPagePath = str_replace($GLOBALS['shConfigLiveSite'], '', $shPageInfo->shCurrentPageURL);
         _log('Current page path : ' . $shPageInfo->shCurrentPagePath);
         if (empty($sefConfig->shRewriteMode)) {
             $shPageInfo->baseUrl = $shPageInfo->shCurrentPageURL;
         } else {
             $shPageInfo->baseUrl = $GLOBALS['shConfigLiveSite'] . JString::rtrim($sefConfig->shRewriteStrings[$sefConfig->shRewriteMode], '/') . $shPageInfo->shCurrentPagePath;
         }
         // V 1.2.4.s PR2 : workaround for Virtuemart cookie check issue
         // see second part in shSef404.php
         if (shIsSearchEngine()) {
             // simulate doing successfull cookie check
             _log('Setting VMCHECK cookie for search engine');
             $_COOKIE['VMCHECK'] = 'OK';
             $_REQUEST['vmcchk'] = 1;
             // from VM 1.1.2 onward, result is stored in session, not cookie
             $_SESSION['VMCHECK'] = 'OK';
         }
     }
 } else {
     JError::RaiseError(COM_SH404SEF_NOREAD . "( {$sef404} )<br />" . COM_SH404SEF_CHK_PERMS);
 }
开发者ID:justinlyon,项目名称:scc,代码行数:31,代码来源:shInit.php

示例12: onSh404sefInsertSocialButtons

 /**
  * Insert appropriate script links into document
  */
 public function onSh404sefInsertSocialButtons(&$page, $sefConfig)
 {
     $app = JFactory::getApplication();
     // are we in the backend - that would be a mistake
     if (!defined('SH404SEF_IS_RUNNING') || $app->isAdmin()) {
         return;
     }
     // don't display on errors
     $pageInfo = Sh404sefFactory::getPageInfo();
     if (!empty($pageInfo->httpStatus) && $pageInfo->httpStatus == 404) {
         return;
     }
     // regexp to catch plugin requests
     $regExp = '#{sh404sef_social_buttons(.*)}#Us';
     // search for our marker}
     if (preg_match_all($regExp, $page, $matches, PREG_SET_ORDER) > 0) {
         // process matches
         foreach ($matches as $id => $match) {
             $url = '';
             // extract target URL
             if (!empty($match[1])) {
                 $raw = explode(' ', $match[1]);
                 $attributes = array();
                 $enabledButtons = array();
                 foreach ($raw as $attribute) {
                     $attribute = JString::trim($attribute);
                     if (strpos($attribute, '=') === false) {
                         continue;
                     }
                     $bits = explode('=', $attribute);
                     if (empty($bits[1])) {
                         continue;
                     }
                     switch ($bits[0]) {
                         case 'url':
                             $base = JURI::base(true);
                             if (substr($bits[1], 0, 10) == 'index.php?') {
                                 $url = JURI::getInstance()->toString(array('scheme', 'host', 'port')) . JRoute::_($bits[1]);
                             } else {
                                 if (substr($bits[1], 0, JString::strlen($base)) == $base) {
                                     $url = JURI::getInstance()->toString(array('scheme', 'host', 'port')) . $bits[1];
                                 } else {
                                     if (substr($bits[1], 0, 1) == '/') {
                                         $url = JString::rtrim(JURI::base(), '/') . $bits[1];
                                     } else {
                                         $url = $bits[1];
                                     }
                                 }
                             }
                             break;
                         case 'type':
                             $enabledButtons[] = strtolower($bits[1]);
                             break;
                     }
                 }
                 if (!empty($enabledButtons)) {
                     $this->_enabledButtons = $enabledButtons;
                 }
             }
             // get buttons html
             $buttons = $this->_sh404sefGetSocialButtons($sefConfig, $url);
             $buttons = str_replace('\'', '\\\'', $buttons);
             // replace in document
             $page = str_replace($match[0], $buttons, $page);
         }
     }
     // insert head links as needed
     $this->_insertSocialLinks($page, $sefConfig);
 }
开发者ID:srbsnkr,项目名称:sellingonlinemadesimple,代码行数:72,代码来源:sh404sefsocial.php

示例13: shIsHomepage

function shIsHomepage($string)
{
    static $pages = array();
    static $home = '';
    global $shHomeLink;
    if (!isset($pages[$string])) {
        if (empty($home) && !empty($shHomeLink)) {
            $home = shSortUrl(shCleanUpLangAndPag($shHomeLink));
        }
        $shTempString = JString::rtrim(str_replace($GLOBALS['shConfigLiveSite'], '', $string), '/');
        $pages[$string] = shSortUrl(shCleanUpLangAndPag($shTempString)) == $home;
        // version t added sorting
    }
    return $pages[$string];
}
开发者ID:sangkasi,项目名称:joomla,代码行数:15,代码来源:sh404sef.class.php

示例14: getURI

 /**
  * Return the absolute URI path to the resource
  */
 public function getURI($storageId)
 {
     $root = JString::rtrim(JURI::root(), '/');
     $storageId = JString::ltrim($storageId, '/');
     return $root . '/' . $storageId;
 }
开发者ID:Jougito,项目名称:DynWeb,代码行数:9,代码来源:file.php

示例15: _getSmallerFile

 /**
  * Get the path (relative to site root?) to the smaller file
  *
  * @param   string  $file  large file path
  * @param   string  $type  type (thumb or crop)
  *
  * @return  string
  */
 protected function _getSmallerFile($file, $type)
 {
     $params = $this->getParams();
     $w = new FabrikWorker();
     // $$$ rob wasn't working when getting thumb path on upload
     $ulDir = JPath::clean($params->get('ul_directory'));
     $ulDir = str_replace("\\", "/", $ulDir);
     // If we're deleting a file, See http://fabrikar.com/forums/showthread.php?t=31715
     $file = str_replace("\\", "/", $file);
     // Replace things like $my->id may barf on other stuff
     $afile = str_replace(JURI::root(), '', $file);
     $afile = JString::ltrim($afile, "/");
     $ulDir = JString::ltrim($ulDir, "/");
     $ulDir = JString::rtrim($ulDir, "/");
     $ulDirbits = explode('/', $ulDir);
     $filebits = explode('/', $afile);
     $match = array();
     $replace = array();
     for ($i = 0; $i < count($filebits); $i++) {
         if (array_key_exists($i, $ulDirbits) && $filebits[$i] != $ulDirbits[$i]) {
             $match[] = $ulDirbits[$i];
             $replace[] = $filebits[$i];
         }
     }
     $ulDir = str_replace($match, $replace, $ulDir);
     // $$$ rob wasn't working when getting thumb path on upload
     $typeDir = $type == 'thumb' ? $params->get('thumb_dir') : $params->get('fileupload_crop_dir');
     $thumbdir = str_replace($match, $replace, $typeDir);
     $ulDir = $w->parseMessageForPlaceHolder($ulDir);
     $thumbdir = $w->parseMessageForPlaceHolder($thumbdir);
     $file = str_replace($ulDir, $thumbdir, $file);
     $file = $w->parseMessageForPlaceHolder($file);
     $f = basename($file);
     $dir = dirname($file);
     $ext = JFile::getExt($f);
     // Remove extension
     $fclean = str_replace('.' . $ext, '', $f);
     if ($type == 'thumb') {
         // $f replaced by $fclean, $ext
         $file = $dir . '/' . $params->get('thumb_prefix') . $fclean . $params->get('thumb_suffix') . '.' . $ext;
     } else {
         $file = $dir . '/' . $f;
     }
     return $file;
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:53,代码来源:filesystemstorage.php


注:本文中的JString::rtrim方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。