Exemplo n.º 1
0
 /**
  * @param     $categoryObj
  * @param int $level
  */
 public static function displayCategory(PublisherCategory $categoryObj, $level = 0)
 {
     $publisher =& PublisherPublisher::getInstance();
     $description = $categoryObj->description();
     if (!XOOPS_USE_MULTIBYTES) {
         if (strlen($description) >= 100) {
             $description = substr($description, 0, 100 - 1) . '...';
         }
     }
     $modify = "<a href='category.php?op=mod&amp;categoryid=" . $categoryObj->categoryid() . '&amp;parentid=' . $categoryObj->parentid() . "'><img src='" . PUBLISHER_URL . "/assets/images/links/edit.gif' title='" . _AM_PUBLISHER_EDITCOL . "' alt='" . _AM_PUBLISHER_EDITCOL . "' /></a>";
     $delete = "<a href='category.php?op=del&amp;categoryid=" . $categoryObj->categoryid() . "'><img src='" . PUBLISHER_URL . "/assets/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='center'>" . $categoryObj->categoryid() . '</td>';
     echo "<td class='even' align='left'>" . $spaces . "<a href='" . PUBLISHER_URL . '/category.php?categoryid=' . $categoryObj->categoryid() . "'><img src='" . PUBLISHER_URL . "/assets/images/links/subcat.gif' alt='' />&nbsp;" . $categoryObj->name() . '</a></td>';
     echo "<td class='even' align='center'>" . $categoryObj->weight() . '</td>';
     echo "<td class='even' align='center'> {$modify} {$delete} </td>";
     echo '</tr>';
     $subCategoriesObj =& $publisher->getHandler('category')->getCategories(0, 0, $categoryObj->categoryid());
     if (count($subCategoriesObj) > 0) {
         ++$level;
         foreach ($subCategoriesObj as $key => $thiscat) {
             self::displayCategory($thiscat, $level);
         }
         unset($key, $thiscat);
     }
     //        unset($categoryObj);
 }
Exemplo n.º 2
0
/**
 * @param  null|PublisherCategory $categoryObj
 * @param  int                    $selectedid
 * @param  int                    $level
 * @param  string                 $ret
 * @return string
 */
function publisherAddCategoryOption(PublisherCategory $categoryObj, $selectedid = 0, $level = 0, $ret = '')
{
    $publisher =& PublisherPublisher::getInstance();
    $spaces = '';
    for ($j = 0; $j < $level; ++$j) {
        $spaces .= '--';
    }
    $ret .= "<option value='" . $categoryObj->categoryid() . "'";
    if (is_array($selectedid) && in_array($categoryObj->categoryid(), $selectedid)) {
        $ret .= " selected='selected'";
    } elseif ($categoryObj->categoryid() == $selectedid) {
        $ret .= " selected='selected'";
    }
    $ret .= '>' . $spaces . $categoryObj->name() . "</option>\n";
    $subCategoriesObj =& $publisher->getHandler('category')->getCategories(0, 0, $categoryObj->categoryid());
    if (count($subCategoriesObj) > 0) {
        ++$level;
        foreach ($subCategoriesObj as $catID => $subCategoryObj) {
            $ret .= publisherAddCategoryOption($subCategoryObj, $selectedid, $level);
        }
    }
    return $ret;
}