null, 'w'=>false, 'type'=>null, 'f'=>null, 'default_file'=>false); $page = !empty($_GET['page']) ? $_GET['page'] : 1; $nb_per_page = 20; $msg = ''; $remove_confirm = false; // Load infos. $ressources = $core->templator->canUseRessources(true); $files= $core->templator->tpl; // Media $media = new dcMedia($core); $media->chdir($core->templator->template_dir_name); // For users with only templator permission, we use sudo. $core->auth->sudo(array($media,'getDir')); $dir =& $media->dir; $items = array_values($dir['files']); // Categories try { $categories = $core->blog->getCategories(array('post_type'=>'post')); $categories_combo = array(); $l = $categories->level; $full_name = array($categories->cat_title); while ($categories->fetch()) { if ($categories->level < $l) { $full_name = array(); } elseif ($categories->level == $l) { array_pop($full_name); } $full_name[] = html::escapeHTML($categories->cat_title); $categories_combo[implode(' › ',$full_name)] = $categories->cat_id; $l = $categories->level; } } catch (Exception $e) { } $hasCategories = ($categories->isEmpty()) ? false : true; $combo_source = array( 'post.html' => 'post' ); if ($core->auth->check('pages',$core->blog->id) && $core->plugins->moduleExists('pages')) { $combo_source['page.html'] = 'page'; } if (!$categories->isEmpty()) { $combo_source['category.html'] = 'category'; } $combo_source[' — '] = 'empty'; $add_template = $copy_confirm = $copycat_confirm = false; if (!$ressources) { $core->error->add(__('The plugin is unusable with your configuration. You have to change file permissions.')); } if (!empty($_POST['filesource'])) { try { $source = $_POST['filesource']; if (empty($_POST['filename']) && $source != 'category') { throw new Exception(__('Filename is empty.')); } $name = files::tidyFileName($_POST['filename']).'.html'; if ($source == 'category') { $name = 'category-'.$_POST['filecat'].'.html'; } $core->templator->initializeTpl($name,$source); } catch (Exception $e) { $core->error->add($e->getMessage()); } if (!$core->error->flag()) { http::redirect($p_url.'&msg=new'); } } if (!empty($_POST['rmyes']) && !empty($_POST['remove']) ) { try { $file = rawurldecode($_POST['remove']); $media->removeItem($file); $core->meta->delMeta($file,'template'); } catch (Exception $e) { $core->error->add($e->getMessage()); } if (!$core->error->flag()) { http::redirect($p_url.'&msg=del'); } } if (!empty($_POST['cpyes']) && !empty($_POST['copy']) && !empty($_POST['newfile'])) { try { $file = rawurldecode($_POST['copy']); $newfile = rawurldecode($_POST['newfile']).'.html'; $core->templator->copypasteTpl($newfile,$file); } catch (Exception $e) { $core->error->add($e->getMessage()); } if (!$core->error->flag()) { http::redirect($p_url.'&msg=cpy'); } } if (!empty($_POST['cpyes']) && !empty($_POST['copycat']) && !empty($_POST['copcat'])) { try { $file = rawurldecode($_POST['copycat']); $newfile = 'category-'.rawurldecode($_POST['copcat']).'.html'; $core->templator->copypasteTpl($newfile,$file); } catch (Exception $e) { $core->error->add($e->getMessage()); } if (!$core->error->flag()) { http::redirect($p_url.'&msg=cpy'); } } if (!empty($_GET['remove'])) { $remove_confirm = true; } if (!empty($_GET['copy'])) { $copy_confirm = true; } if (!empty($_GET['copycat'])) { $copycat_confirm = true; } $msg = isset($_REQUEST['msg']) ? $_REQUEST['msg'] : ''; $msg_list = array( 'new' => __('The new template has been successfully created.'), 'del' => __('The template has been successfully removed.'), 'cpy' => __('The template has been successfully copied.') ); if (isset($msg_list[$msg])) { $msg = sprintf('
',$msg_list[$msg]); } ?>'.__('No template.').'
'; } else { $pager = new pager($page,count($items),$nb_per_page,10); $pager->html_prev = __('«prev.'); $pager->html_next = __('next»'); echo ''. ''.__('Page(s)').' : '.$pager->getLinks().'
'; for ($i=$pager->index_start, $j=0; $i<=$pager->index_end; $i++, $j++) { echo pagerTemplator::templatorItemLine($items[$i],$j); } echo ''.__('Page(s)').' : '.$pager->getLinks().'
'. '