コード例 #1
0
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     if ($this->getOption('multiple')) {
         $attributes['multiple'] = 'multiple';
         if ('[]' != substr($name, -2)) {
             $name .= '[]';
         }
     }
     $options = array();
     $institutions = $this->getCollectionByIntitution();
     $html = "";
     $prev_level = 0;
     foreach ($institutions as $institution => $collections) {
         $root = $tree = new Collections();
         foreach ($collections as $item) {
             $anc = $tree->getFirstCommonAncestor($item);
             $anc->addChild($item);
             $tree = $item;
         }
         $html .= "<h2>{$institution}</h2>";
         $html .= "<div class=\"treelist\">";
         $html .= $this->displayTree($root, '', $value, $name);
         $html .= "</div>";
     }
     return $html;
 }
コード例 #2
0
</script>
<div class="container">
  <?php 
foreach ($institutions as $institution) {
    ?>
    <h2><?php 
    echo $institution->getFormatedName();
    ?>
</h2>
    <div class="treelist">
    <?php 
    $w = new sfWidgetCollectionList(array('choices' => array(), 'is_choose' => $is_choose));
    $root = $tree = new Collections();
    foreach ($institution->Collections as $item) {
        $it = sfOutputEscaper::unescape($item);
        $anc = $tree->getFirstCommonAncestor($it);
        $anc->addChild($it);
        $tree = $it;
    }
    echo $w->displayTree($root, '', array(), '', $sf_user);
    ?>

    </div>
  <?php 
}
?>
  <?php 
if ($sf_user->isAtLeast(Users::MANAGER)) {
    ?>
    <div class='new_link'><a <?php 
    echo !(isset($is_choose) && $is_choose) ? '' : 'target="_blank"';