Пример #1
0
/**
 * Render folder tree
 *
 * @param string $name Control name
 * @param Project $project
 * @param integer $selected ID of selected folder
 * @param array $attributes Select box attributes
 * @return string
 */
function render_folder_tree($folder, $depth = 0, $project = null, $selected = null, $attributes = null)
{
    if ($depth > 5) {
        return;
    }
    if (is_null($project)) {
        $project = active_project();
    }
    // if
    if (!$project instanceof Project) {
        throw new InvalidInstanceError('$project', $project, 'Project');
    }
    // if
    if (is_array($attributes)) {
        if (!isset($attributes['class'])) {
            $attributes['class'] = 'select_folder';
        }
    } else {
        $attributes = array('class' => 'select_folder');
    }
    // if
    $options = array(option_tag(lang('none'), 0));
    $html = '';
    if ($folder instanceof ProjectFolder) {
        $folders = ProjectFolders::getProjectFolderTree($project, $folder->getId());
    } else {
        $folders = ProjectFolders::getProjectFolderTree($project);
    }
    if (is_array($folders)) {
        $html .= '<ul>';
        foreach ($folders as $folder) {
            $class = $folder->getId() == $selected ? $class = 'class="selected"' : '';
            //$html .= '<li>' . $folder->getName() . render_folder_tree( $folder, $depth, $project, $selected, $attributes ) . '</li>';
            $html .= '<li><a href="' . $folder->getBrowseUrl() . '" ' . $class . '>' . clean($folder->getName()) . '</a>';
            if ($folder->canEdit(logged_user())) {
                $html .= ' <a href="' . $folder->getEditUrl() . '" class="blank" title="' . lang('edit folder') . '"><img src="' . icon_url('edit.gif') . '" alt="" /></a>';
            }
            // if
            if ($folder->canDelete(logged_user())) {
                $html .= ' <a href="' . $folder->getDeleteUrl() . '" class="blank" title="' . lang('delete folder') . '"><img src="' . icon_url('cancel_gray.gif') . '" alt="" /></a>';
            }
            // if
            $html .= render_folder_tree($folder, $depth + 1, $project, $selected, $attributes);
            $html .= '</li>';
        }
        // foreach
        $html .= '</ul>';
    }
    // if
    return $html;
}
 /**
 * Show file details
 *
 * @param void
 * @return null
 */
 function file_details() {
   $this->addHelper('textile');
   
   $file = ProjectFiles::findById(get_id());
   if (!($file instanceof ProjectFile)) {
     flash_error(lang('file dnx'));
     $this->redirectToReferer(get_url('files'));
   } // if
   
   if (!$file->canView(logged_user())) {
     flash_error(lang('no access permissions'));
     $this->redirectToReferer(get_url('files'));
   } // if
   
   $revisions = $file->getRevisions();
   if (!count($revisions)) {
     flash_error(lang('no file revisions in file'));
     $this->redirectToReferer(get_url('files'));
   } // if
   
   $this->canGoOn();
   tpl_assign('file', $file);
   tpl_assign('folder', $file->getFolder());
   tpl_assign('last_revision', $file->getLastRevision());
   tpl_assign('revisions', $revisions);
   
   // This variables are required for the sidebar
   tpl_assign('current_folder', $file->getFolder());
   tpl_assign('order', null);
   tpl_assign('page', null);
   tpl_assign('folders', active_project()->getFolders());
   tpl_assign('folder_tree', ProjectFolders::getProjectFolderTree(active_project()));
   tpl_assign('important_files', active_project()->getImportantFiles());
   
   $this->setSidebar(get_template_path('index_sidebar', 'files'));
 } // file_details