function createTreeView($array, $currentParent, $currLevel = 0, $prevLevel = -1)
 {
     foreach ($array as $categoryId => $category) {
         if ($currentParent == $category['nivel_pai']) {
             if ($currLevel > $prevLevel) {
                 echo "<ul>";
             }
             if ($currLevel == $prevLevel) {
                 echo "</li>";
             }
             //Pasta
             if ($category['nivel'] == 'sintetico') {
                 echo "<li><i class='uk-icon-caret-right'></i>\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t<label><b>" . $category['nome'] . "</b></label>\n\t\t\t\t\t\t\t\t\t";
             } else {
                 echo "<li><i class='uk-icon-angle-double-right'></i>\n\t\t\t\t\t\t\t\t\t" . $category['nome'] . "\n\t\t\t\t\t\t\t\t\t";
             }
             //  1										<image class='icone' src='imagens/edit.png' onclick=popupatualizar('cad_ctrreceitas','nome','cod_ctrreceita','".$category['codigo']."','".str_replace(" ","_",$category['nome'])."');> <image class='icone' src='imagens/delete2.png' onclick=excluirorigem('cad_ctrreceitas','cod_ctrreceita','".$category['codigo']."')>
             //	2								<image class='icone' src='imagens/delete2.png' onclick=excluirorigem('cad_ctrreceitas','cod_ctrreceita','".$category['codigo']."')>									<image class='icone' src='imagens/edit.png' onclick=popupatualizar('cad_ctrreceitas','nome','cod_ctrreceita','".$category['codigo']."','".str_replace(" ","_",$category['nome'])."');>
             if ($currLevel > $prevLevel) {
                 $prevLevel = $currLevel;
             }
             $currLevel++;
             createTreeView($array, $categoryId, $currLevel, $prevLevel);
             $currLevel--;
         }
     }
     if ($currLevel == $prevLevel) {
         echo "</li></ul> ";
     }
 }
Exemplo n.º 2
0
function show_cms_media(&$out, &$lang)
{
    if (!canAccessCmsMedia()) {
        die("You can't access!");
    }
    require_once _base_ . "/lib/lib.form.php";
    $form = new Form();
    $res = "";
    $url = getPopupBaseUrl() . "&amp;op=cms";
    if (Get::sett('hteditor') == 'tinymce') {
        $GLOBALS['page']->add('<script type="text/javascript" type="text/javascript" src="' . $GLOBALS['where_framework_relative'] . '/addons/tiny_mce/tiny_mce_popup.js"></script>', 'page_head');
        $GLOBALS['page']->add('<script type="text/javascript">' . 'var FileBrowserDialogue = {
		    init : function () {
		        // Here goes your code for setting your custom things onLoad.
				var allLinks = document.getElementsByTagName("link");
				allLinks[allLinks.length-1].parentNode.removeChild(allLinks[allLinks.length-1]);
		    },
		    mySubmit : function (url) {
		        var URL = url;
		        var win = tinyMCEPopup.getWindowArg("window");

		        // insert information now
		        win.document.getElementById(tinyMCEPopup.getWindowArg("input")).value = URL;

		        // for image browsers: update image dimensions
		        if(win.ImageDialog) {
			        if (win.ImageDialog.getImageData) win.ImageDialog.getImageData();
			        if (win.ImageDialog.showPreviewImage) win.ImageDialog.showPreviewImage(URL);
		        }
		        // close popup window
		        tinyMCEPopup.close();
		    }
		}

		tinyMCEPopup.onInit.add(FileBrowserDialogue.init, FileBrowserDialogue);' . '</script>', 'page_head');
    }
    $res .= $form->openForm("block_form", $url);
    $res .= $form->openElementSpace();
    // ------- mostro albero ----------------------------------------------\
    include_once $GLOBALS["where_cms"] . "/admin/modules/media/media_class.php";
    $tree = createTreeView();
    if (isset($_POST[$tree->_getFolderNameId()])) {
        // Al cambio cartella:
        $folderid = $_POST[$tree->_getFolderNameId()];
    } else {
        // La prima volta che carica la pagina con l'albero:
        $folderid = $tree->getSelectedFolderId();
    }
    /*
    $rowcnt[] = '<a href="'.$sel_url.'" '
    			.( Get::sett('hteditor') == 'tinymce'
    				? 'onclick="FileBrowserDialogue.mySubmit(\''.cleanUrlPath($site_url.$row["real_fname"]).'\'); return false;"' : '' )
    			.'>'
    			.$img."</a>\n";
    */
    $path = (strlen(dirname($_SERVER['PHP_SELF'])) != 1 ? dirname($_SERVER['PHP_SELF']) : '') . '/';
    $path .= $GLOBALS["where_files_relative"];
    $site_url = "http://" . $_SERVER['HTTP_HOST'] . $path . _FPATH_INTERNAL;
    $tree->setTiny($site_url);
    $tree->show_icons = 0;
    $tree->setSelMode(true);
    $tree->setSelModeUrl(getPopupBaseUrl() . "&amp;op=select&amp;from=cms", TRUE);
    $folder = $tree->tdb->getFolderById($tree->getSelectedFolderId());
    $res .= $form->getHidden($tree->_getFolderNameId(), $tree->_getFolderNameId(), $folderid);
    $res .= $form->getHidden("folder_id", "folder_id", $tree->getSelectedFolderId());
    //$res.='<div><b>'.$lang->def("_FOLDER").':</b></div>';
    $res .= $tree->load();
    $res .= "<br />\n\n";
    $listView = $tree->getListView();
    $listView->setInsNew(false);
    $res .= $listView->printOut();
    // --------------------------------------------------------------------/
    $res .= $form->closeElementSpace();
    /*$res.=$form->openButtonSpace();
    	$res.=$form->getButton('undo', 'undo', $lang->def('_BACK'));
    	$res.=$form->closeButtonSpace(); */
    $res .= $form->closeForm();
    $out->add($res);
}