/**
  * @access public
  */
 function searchCategoryByName($name)
 {
     $query = 'SELECT id FROM ' . OOMedia::getTableName() . ' WHERE name = "' . addslashes($name) . '"';
     $sql = new sql();
     $result = $sql->get_array($query);
     $media = array();
     foreach ($result as $line) {
         $media[] = OOMediaCategory::getCategoryById($line['id']);
     }
     return $media;
 }
 /**
  * @access public
  */
 function getChildren()
 {
     if ($this->_children === null) {
         $this->_children = array();
         $qry = 'SELECT id FROM ' . OOMediaCategory::_getTableName() . ' WHERE re_id = ' . $this->getId() . ' ORDER BY name ';
         $sql = new rex_sql();
         $sql->setQuery($qry);
         $result = $sql->getArray();
         if (is_array($result)) {
             foreach ($result as $row) {
                 $id = $row['id'];
                 $this->_children[] =& OOMediaCategory::getCategoryById($id);
             }
         }
     }
     return $this->_children;
 }
     print "<tr><td class=grey>" . $I18N->msg('pool_created') . ":</td><td class=grey colspan=2>" . strftime($I18N->msg('datetimeformat'), $gf->getValue("createdate")) . " [" . $gf->getValue("createuser") . "]</td></tr>\n";
     print "<tr><td class=grey>" . $I18N->msg('pool_file_exchange') . ":</td><td class=grey colspan=2><input type=file name=file_new size=30></td></tr>";
     print "<tr><td class=grey>&nbsp;</td><td class=grey width=120><input type=submit value=\"" . $I18N->msg('pool_file_update') . "\"></td>\n";
     print "</form>\n";
     print "<form name=rex_file_cat action=index.php method=POST ENCTYPE=multipart/form-data>\n";
     print "<input type=hidden name=page value=medienpool>\n";
     print "<input type=hidden name=media_method value=delete_file>\n";
     print "<input type=hidden name=subpage value=detail>\n";
     print "<input type=hidden name=file_id value={$file_id}>\n";
     print "<input type=hidden name=rex_file_category value={$rex_file_category}>\n";
     print "<td class=grey><input type=submit value=\"" . $I18N->msg('pool_file_delete') . "\"  onclick='return confirm(\"" . $I18N->msg('delete') . " ?\")'></td></tr>\n";
     print "</form>";
     print "</table>\n";
 } else {
     $catname = $I18N->msg('pool_kats_no');
     $Cat = OOMediaCategory::getCategoryById($rex_file_category);
     if ($Cat) {
         $catname = $Cat->getName();
     }
     print "<table border=0 cellpadding=5 cellspacing=1 width=100%>\n";
     print "<tr><th align=left colspan=4>Detailinformationen | {$opener_link}</th></tr>";
     print "<tr><td class=grey width=120>Titel:</td><td class=grey colspan=2>" . htmlspecialchars(stripslashes($ftitle)) . "</td>";
     if ($ffiletype_ii) {
         $imgn = "../files/{$fname} width={$rfwidth}";
         if ($thumbs && $thumbsresize && $rfwidth > 199) {
             $imgn = "../index.php?rex_resize=200w__{$fname}";
         }
         echo "<td rowspan=10 width=220 align=center class=lgrey valign=top><br><img src={$imgn}  border=0></td>";
     }
     print "</tr>\n";
     print "<tr><td class=grey>" . $I18N->msg('pool_category') . ":</td><td class=grey colspan=2>" . $catname . "</td></tr>\n";
 }
 $link = 'index.php?page=mediapool' . $arg_url . '&amp;subpage=categories&amp;cat_id=';
 $textpath = '<li> : <a href="' . $link . '0">Start</a></li>';
 $cat_id = rex_request('cat_id', 'int');
 if ($cat_id == 0 || !($OOCat = OOMediaCategory::getCategoryById($cat_id))) {
     $OOCats = OOMediaCategory::getRootCategories();
     $cat_id = 0;
     $catpath = "|";
 } else {
     $OOCats = $OOCat->getChildren();
     // TODO getParentTree() verwenden
     $paths = explode("|", $OOCat->getPath());
     for ($i = 1; $i < count($paths); $i++) {
         $iid = current($paths);
         if ($iid != "") {
             $icat = OOMediaCategory::getCategoryById($iid);
             $textpath .= '<li> : <a href="' . $link . $iid . '">' . $icat->getName() . '</a></li>';
         }
         next($paths);
     }
     $textpath .= '<li> : <a href="' . $link . $cat_id . '">' . $OOCat->getName() . '</a></li>';
     $catpath = $OOCat->getPath() . "{$cat_id}|";
 }
 echo '<div id="rex-navi-path"><ul><li>' . $I18N->msg('pool_kat_path') . '</li> ' . $textpath . '</ul></div>';
 if ($warning != '') {
     echo rex_warning($warning);
     $warning = '';
 }
 if ($info != '') {
     echo rex_info($info);
     $info = '';
 /**
  * @access public
  */
 function getCategory()
 {
     if ($this->_cat === null) {
         $this->_cat =& OOMediaCategory::getCategoryById($this->getCategoryId());
     }
     return $this->_cat;
 }
/**
 * Erweitert das Meta-Formular um die neuen Meta-Felder
 *
 * @param string   $prefix       Feldprefix
 * @param string   $params       EP Params
 * @param callback $saveCallback Callback, dass die Daten speichert
 */
function _rex_a62_metainfo_form($prefix, $params, $saveCallback)
{
    // Beim ADD gibts noch kein activeItem
    $activeItem = null;
    if (isset($params['activeItem'])) {
        $activeItem = $params['activeItem'];
    }
    $restrictionsCondition = '';
    if ($prefix == 'art_') {
        if ($params['id'] != '') {
            $s = '';
            $OOArt = OOArticle::getArticleById($params['id'], $params['clang']);
            // Alle Metafelder des Pfades sind erlaubt
            foreach (explode('|', $OOArt->getPath()) as $pathElement) {
                if ($pathElement != '') {
                    $s .= ' OR `p`.`restrictions` LIKE "%|' . $pathElement . '|%"';
                }
            }
            $restrictionsCondition = 'AND (`p`.`restrictions` = ""' . $s . ')';
        }
    } elseif ($prefix == 'cat_') {
        $s = '';
        if ($params['id'] != '') {
            $OOCat = OOCategory::getCategoryById($params['id'], $params['clang']);
            // Alle Metafelder des Pfades sind erlaubt
            foreach (explode('|', $OOCat->getPath()) as $pathElement) {
                if ($pathElement != '') {
                    $s .= ' OR `p`.`restrictions` LIKE "%|' . $pathElement . '|%"';
                }
            }
            // Auch die Kategorie selbst kann Metafelder haben
            $s .= ' OR `p`.`restrictions` LIKE "%|' . $params['id'] . '|%"';
        }
        $restrictionsCondition = 'AND (`p`.`restrictions` = ""' . $s . ')';
    } elseif ($prefix == 'med_') {
        $catId = rex_session('media[rex_file_category]', 'int');
        if ($activeItem) {
            $catId = $activeItem->getValue('category_id');
        }
        if ($catId !== '') {
            $s = '';
            if ($catId != 0) {
                $OOCat = OOMediaCategory::getCategoryById($catId);
                // Alle Metafelder des Pfades sind erlaubt
                foreach (explode('|', $OOCat->getPath()) as $pathElement) {
                    if ($pathElement != '') {
                        $s .= ' OR `p`.`restrictions` LIKE "%|' . $pathElement . '|%"';
                    }
                }
            }
            // Auch die Kategorie selbst kann Metafelder haben
            $s .= ' OR `p`.`restrictions` LIKE "%|' . $catId . '|%"';
            $restrictionsCondition = 'AND (`p`.`restrictions` = ""' . $s . ')';
        }
    }
    $sqlFields = _rex_a62_metainfo_sqlfields($prefix, $restrictionsCondition);
    $params = rex_call_func($saveCallback, array($params, $sqlFields), false);
    return rex_a62_metaFields($sqlFields, $activeItem, 'rex_a62_metainfo_form_item', $params);
}
 /**
  * @access public
  * @deprecated 20.02.2010
  * Stattdessen getCategoryById() nutzen
  */
 function getCategoryByName($name)
 {
     $query = 'SELECT id FROM ' . OOMediaCategory::_getTableName() . ' WHERE name = "' . $name . '"';
     $sql = new rex_sql();
     //$sql->debugsql = true;
     $result = $sql->getArray($query);
     $media = array();
     if (is_array($result)) {
         foreach ($result as $line) {
             $media[] = OOMediaCategory::getCategoryById($line['id']);
         }
     }
     return $media;
 }
 function addCatOptions()
 {
     if ($this->rootId !== null) {
         if (is_array($this->rootId)) {
             foreach ($this->rootId as $rootId) {
                 if ($rootCat = OOMediaCategory::getCategoryById($rootId)) {
                     $this->addCatOption($rootCat);
                 }
             }
         } else {
             if ($rootCat = OOMediaCategory::getCategoryById($this->rootId)) {
                 $this->addCatOption($rootCat);
             }
         }
     } else {
         if ($rootCats = OOMediaCategory::getRootCategories()) {
             foreach ($rootCats as $rootCat) {
                 $this->addCatOption($rootCat);
             }
         }
     }
 }
 /**
  * @access public
  * @deprecated 20.02.2010
  * Stattdessen getCategoryById() nutzen
  */
 function getCategoryByName($name)
 {
     global $REX;
     $sql = rex_sql::factory();
     $sql->setQuery('SELECT id FROM ' . OOMediaCategory::_getTableName() . 'WHERE name="' . $name . '"');
     if ($sql->getRows() == 1) {
         return OOMediaCategory::getCategoryById($sql->getValue('id'));
     }
     return null;
 }