Beispiel #1
0
/**
 * Render select folder box
 *
 * @param string $name Control name
 * @param Project $project
 * @param integer $selected ID of selected folder
 * @param array $attributes Select box attributes
 * @return string
 */
function select_project_folder($name, $project = null, $selected = null, $exclude = null, $attributes = null)
{
    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));
    $folders = ProjectFolders::getProjectFolders($project);
    if (is_array($folders)) {
        $sorted = array();
        foreach ($folders as $folder) {
            $sorted[$folder->getObjectName(true)] = $folder;
        }
        // foreach
        ksort($sorted);
        foreach ($sorted as $k => $folder) {
            $option_attributes = $folder->getId() == $selected ? array('selected' => true) : null;
            $options[] = option_tag($k, $folder->getId(), $option_attributes);
        }
        // foreach
    }
    // if
    return select_box($name, $options, $attributes);
}
Beispiel #2
0
 function getFolders()
 {
     if (is_null($this->folders)) {
         $this->folders = ProjectFolders::getProjectFolders($this);
     }
     // if
     return $this->folders;
 }
Beispiel #3
0
 function getFolders() {
   if(!plugin_active('files')) { return null; }
   if (is_null($this->folders)) {
     $this->folders = ProjectFolders::getProjectFolders($this);
   } // if
   return $this->folders;
 } // getFolders