예제 #1
0
/**
 * @param string $value
 * @param string $out_charset
 * @param string $in_charset
 *
 * @return string
 */
function xlanguage_convert_item($value, $out_charset, $in_charset)
{
    $xoops = Xoops::getInstance();
    if (strtolower($in_charset) == strtolower($out_charset)) {
        return $value;
    }
    $xconv_handler = $xoops->getModuleHandler('xconv', 'xconv', true);
    if (is_object($xconv_handler) && ($converted_value = @$xconv_handler->convert_encoding($value, $out_charset, $in_charset))) {
        return $converted_value;
    }
    if (XoopsLocale::isMultiByte() && function_exists('mb_convert_encoding')) {
        $converted_value = @mb_convert_encoding($value, $out_charset, $in_charset);
    } elseif (function_exists('iconv')) {
        $converted_value = @iconv($in_charset, $out_charset, $value);
    }
    $value = empty($converted_value) ? $value : $converted_value;
    return $value;
}
예제 #2
0
파일: item.php 프로젝트: ming-hai/XoopsCore
 /**
  * This method returns the body to be displayed. Not to be used for editing
  *
  * @param int    $maxLength
  * @param string $format
  * @param string $stripTags
  *
  * @return mixed|string
  */
 public function body($maxLength = 0, $format = 'S', $stripTags = '')
 {
     $ret = $this->getVar('body', $format);
     $wrap_pos = strpos($ret, '[pagewrap=');
     if (!($wrap_pos === false)) {
         $wrap_pages = array();
         $wrap_code_length = strlen('[pagewrap=');
         while (!($wrap_pos === false)) {
             $end_wrap_pos = strpos($ret, ']', $wrap_pos);
             if ($end_wrap_pos) {
                 $wrap_page_name = substr($ret, $wrap_pos + $wrap_code_length, $end_wrap_pos - $wrap_code_length - $wrap_pos);
                 $wrap_pages[] = $wrap_page_name;
             }
             $wrap_pos = strpos($ret, '[pagewrap=', $end_wrap_pos - 1);
         }
         foreach ($wrap_pages as $page) {
             $wrap_page_content = $this->wrappage($page);
             $ret = str_replace("[pagewrap={$page}]", $wrap_page_content, $ret);
         }
     }
     if ($this->publisher->getConfig('item_disp_blocks_summary')) {
         $summary = $this->summary($maxLength, $format, $stripTags);
         if ($summary) {
             $ret = $this->summary() . '<br /><br />' . $ret;
         }
     }
     if (!empty($stripTags)) {
         $ret = strip_tags($ret, $stripTags);
     }
     if ($maxLength != 0) {
         if (!XoopsLocale::isMultiByte()) {
             if (strlen($ret) >= $maxLength) {
                 //$ret = PublisherUtils::substr($ret , 0, $maxLength);
                 $ret = PublisherUtils::truncateTagSafe($ret, $maxLength, $etc = '...', $break_words = false);
             }
         }
     }
     return $ret;
 }
예제 #3
0
function publisher_displayCategory(PublisherCategory $categoryObj, $level = 0)
{
    $publisher = Publisher::getInstance();
    $description = $categoryObj->getVar('description');
    if (!XoopsLocale::isMultiByte()) {
        if (strlen($description) >= 100) {
            $description = substr($description, 0, 100 - 1) . "...";
        }
    }
    $modify = "<a href='category.php?op=mod&amp;categoryid=" . $categoryObj->getVar('categoryid') . "&amp;parentid=" . $categoryObj->getVar('parentid') . "'><img src='" . PUBLISHER_URL . "/images/links/edit.gif' title='" . _AM_PUBLISHER_EDITCOL . "' alt='" . _AM_PUBLISHER_EDITCOL . "' /></a>";
    $delete = "<a href='category.php?op=del&amp;categoryid=" . $categoryObj->getVar('categoryid') . "'><img src='" . PUBLISHER_URL . "/images/links/delete.png' title='" . _AM_PUBLISHER_DELETECOL . "' alt='" . _AM_PUBLISHER_DELETECOL . "' /></a>";
    $spaces = '';
    for ($j = 0; $j < $level; ++$j) {
        $spaces .= '&nbsp;&nbsp;&nbsp;';
    }
    echo "<tr>";
    echo "<td class='even' align='left'>" . $spaces . "<a href='" . PUBLISHER_URL . "/category.php?categoryid=" . $categoryObj->getVar('categoryid') . "'><img src='" . PUBLISHER_URL . "/images/links/subcat.gif' alt='' />&nbsp;" . $categoryObj->getVar('name') . "</a></td>";
    echo "<td class='even' align='center'>" . $categoryObj->getVar('weight') . "</td>";
    echo "<td class='even' align='center'> {$modify} {$delete} </td>";
    echo "</tr>";
    $subCategoriesObj = $publisher->getCategoryHandler()->getCategories(0, 0, $categoryObj->getVar('categoryid'));
    if (count($subCategoriesObj) > 0) {
        ++$level;
        foreach ($subCategoriesObj as $thiscat) {
            publisher_displayCategory($thiscat, $level);
        }
    }
    unset($categoryObj);
}