示例#1
0
 /**
  * Closes an open form tag.
  *
  * @param   string  string to be attached after the closing tag
  * @return  string
  */
 public static function close($buttons = NULL, $extra = '')
 {
     $result = '';
     if ($buttons === TRUE) {
         switch (Bluebox_Controller::getControllerMode()) {
             case 'create':
                 $buttons = self::BUTTONS_SAVE_CANCEL;
                 break;
             case 'edit':
                 $buttons = self::BUTTONS_SAVE_CLOSE;
                 break;
             case 'delete':
                 $buttons = self::BUTTONS_DELETE_CANCEL;
                 break;
             case 'view':
             default:
                 $buttons = self::BUTTONS_OKONLY;
                 break;
         }
     }
     switch ($buttons) {
         case self::BUTTONS_SAVE_CANCEL:
             $result .= '<div class="buttons form_bottom">';
             $result .= form::confirm_button();
             $result .= form::cancel_button();
             $result .= '</div>';
             break;
         case self::BUTTONS_SAVE_CLOSE:
             $result .= '<div class="buttons form_bottom">';
             $result .= form::confirm_button();
             $result .= form::cancel_button('Close');
             $result .= '</div>';
             break;
         case self::BUTTONS_DELETE_CANCEL:
             $result .= '<div class="buttons form_bottom">';
             $result .= form::confirm_button('Delete');
             $result .= form::cancel_button();
             $result .= '</div>';
             break;
         case self::BUTTONS_OKONLY:
             $result .= '<div class="buttons form_bottom">';
             $result .= form::confirm_button('Ok');
             $result .= '</div>';
             break;
         case self::BUTTONS_OK_CANCEL:
             $result .= '<div class="buttons form_bottom">';
             $result .= form::confirm_button('Ok');
             $result .= form::cancel_button();
             $result .= '</div>';
             break;
         case self::BUTTONS_YES_NO:
             $result .= '<div class="buttons form_bottom">';
             $result .= form::confirm_button('Yes');
             $result .= form::cancel_button('No');
             $result .= '</div>';
             break;
     }
     list($extra) = self::_addDefaults(__FUNCTION__, $extra);
     // Call the parent
     $result .= parent::close($extra);
     return $result;
 }
示例#2
0
文件: subview.php 项目: swk/bluebox
 /**
  * Renders all subviews passed in. Handles nested views within arrays. Uses recursion / No depth restriction.
  * 
  * @param array $subviews An array of subviews. Can contain nested arrays with additional views.
  * @return string All HTML from the subviews returned as a big string of HTML.
  */
 public function render($subviews, $section = NULL)
 {
     $html = '';
     if (!is_array($subviews)) {
         $subviews = array($subviews);
     }
     if (!is_null($section) and !is_array($section)) {
         $section = array($section);
     }
     if (is_array($section)) {
         $section = array_map('strtolower', $section);
     }
     foreach ($subviews as $subview) {
         // Handle nested views
         if (is_array($subview)) {
             self::render($subview, $section);
         } else {
             if (!$subview instanceof View) {
                 kohana::log('error', 'Can not render a subview that is not an instance of View');
                 continue;
             }
             if (isset($subview->render_conditional)) {
                 $renderConditions = $subview->render_conditional;
                 if (!is_array($renderConditions)) {
                     $renderConditions = array($renderConditions => FALSE);
                 }
                 if (Request::is_ajax()) {
                     if (isset($renderConditions['ajax']) and $renderConditions['ajax'] === FALSE) {
                         kohana::log('debug', 'Not rendering view due to ajax request');
                         continue;
                     }
                 }
                 if (isset($_REQUEST['qtipAjaxForm']) and $renderConditions['qtipAjaxForm'] === FALSE) {
                     kohana::log('debug', 'Not rendering view due to qtipAjaxForm request');
                     continue;
                 }
                 if (isset($renderConditions['mode'])) {
                     if (!is_array($renderConditions['mode'])) {
                         $renderConditions['mode'] = array($renderConditions['mode']);
                     }
                     # get mode of controller and check in renderConditions['renderMode] to see if it exists
                     if (!in_array(Bluebox_Controller::getControllerMode(), $renderConditions['mode'])) {
                         continue;
                     }
                 }
             }
             if (is_null($section)) {
                 $html .= $subview->render();
                 continue;
             }
             if (!isset($subview->section)) {
                 continue;
             }
             $subviewSection = strtolower($subview->section);
             if (in_array($subviewSection, $section)) {
                 $html .= $subview->render();
             }
         }
     }
     return $html;
 }