Exemplo n.º 1
0
function get_cats_string($cats)
{
    global $config_vars;
    if (is_array($cats)) {
        foreach ($cats as $key => $value) {
            $cat_obj = new categorie();
            $cat_obj->generate_from_id($value['id']);
            $name = $cat_obj->get_name();
            while ($cat_obj->get_parent_id() != $config_vars['root_categorie']) {
                $old_cat_id = $cat_obj->get_parent_id();
                $cat_obj = new categorie();
                $cat_obj->generate_from_id($old_cat_id);
                $name = $cat_obj->get_name() . '/' . $name;
            }
            $cats[$key]['name'] = $name;
        }
    }
    return $cats;
}
 function generate_filename()
 {
     global $config_vars;
     //check if content is already in a cat
     if (!isset($this->cat_ids)) {
         $this->generate_content_in_cat_data();
     }
     if (sizeof($this->cat_ids) > 0) {
         $cat_obj = new categorie();
         $cat_obj->generate_from_id($this->cat_ids[0]);
         $path = $cat_obj->get_name();
         while ($cat_obj->get_parent_id() != $config_vars['root_categorie']) {
             $old_cat_id = $cat_obj->get_parent_id();
             $cat_obj = new categorie();
             $cat_obj->generate_from_id($old_cat_id);
             $path = $cat_obj->get_name() . '/' . $path;
         }
         // make $path is it doesnt exists
         if (!is_dir($config_vars['content_path_prefix'] . '/' . $path)) {
             makedir($config_vars['content_path_prefix'] . '/' . $path);
         }
         $path = $path . '/' . basename($this->name) . '.' . getext($this->file);
         $filename = $config_vars['content_path_prefix'] . '/' . $path;
         // if filename has changed check if such a file does not already exists is so add a number behind till its a new file
         if ($this->file != $filename) {
             $newfilename = $filename;
             $i = 0;
             while (is_file($newfilename)) {
                 $newfilename = getfile($filename) . "-{$i}." . getext($filename);
                 $i++;
             }
             $filename = $newfilename;
         }
         return $filename;
     } else {
         return OP_CONTENT_NOT_IN_CAT;
     }
 }