コード例 #1
0
ファイル: Box.php プロジェクト: jonatanolofsson/solidba.se
 /**
  * Displays a few tools associated with the currently viewed page
  * @return string
  */
 function tools($id = false, $extras = true)
 {
     global $Controller, $ID;
     if (!$id) {
         $id = $ID;
     }
     if (is_object($id)) {
         $obj = $id;
         $id = $obj->ID;
     } else {
         $obj = $Controller->get($id);
     }
     if (!$obj) {
         return false;
     }
     $r = array();
     if ($extras === true) {
         $r[] = icon('small/eye', __('View'), url(array('id' => $id)), true);
         $extras = false;
     }
     if ($obj->mayI(EDIT)) {
         if ($editors = $obj->editable) {
             foreach ($editors as $editor => $aLevel) {
                 if ($obj->mayI($aLevel)) {
                     $r[] = icon($editor::$edit_icon, __($editor::$edit_text), url(array('edit' => $id, 'with' => $editor)), true);
                 }
             }
         }
     }
     if (is_array($extras)) {
         $r = array_merge($r, $extras);
     } elseif ($extras) {
         $r[] = $extras;
     }
     return Box::dropdown('small/bullet_wrench', false, $r);
 }
コード例 #2
0
 /**
  * Render the menu for editing
  * @param array $array
  * @return string
  */
 private function makeMenu($array)
 {
     static $i = 0;
     static $recursion = 0;
     if (count($array) == 0) {
         return;
     }
     ++$recursion;
     global $CONFIG, $USER;
     if ($this->mayI(EDIT)) {
         JS::loadjQuery(false);
         JS::lib('menusort');
     }
     /* $r=''; */
     $r = '<ul class="menulist">';
     $save = array('edit', 'with', 'id');
     while (list(, $obj) = each($array)) {
         $r .= '<li id="m' . $obj['id'] . '" class="' . (++$i % 2 ? 'odd' : 'even') . (is_a($obj['object'], 'MenuSection') ? ' menusection' : '') . '"><span class="fixed-width">' . $obj['object'] . '</span>' . Box::tools($obj['object']) . Box::dropdown('small/add', false, array(icon('small/arrow_right', __('New child page'), url(array('action' => 'newpage', 'where' => 'child', 'to' => $obj['id']), $save), true), icon('small/arrow_down', __('New page below'), url(array('action' => 'newpage', 'where' => 'below', 'to' => $obj['id']), $save), true))) . Box::dropdown('small/arrow_out', false, false, 'pagemove') . (isset($obj['children']) ? $this->makeMenu($obj['children']) : '') . '</li>';
     }
     $r .= '</ul>';
     --$recursion;
     if ($recursion == 0) {
         $i = 0;
     }
     return $r;
 }