[ Index ]

PHP Cross Reference of Quick Form DataBase

title

Body

[close]

/ -> qfdb_themes_default.php (source)

   1  <?php
   2  if (!defined('QFDB_SECURITY')) {
   3      die("You can't access this file directly...");
   4  }
   5  
   6  
   7  /**
   8   * Default Theme of Quick Form DataBase (QFDB) Framework
   9   *
  10   * @author Everaldo Wanderlei Uavniczak <everaldouav [at] gmail.com>
  11   * @since 0.1
  12   * @package quickformdb
  13   * @see http://www.qfdb.net/
  14   * @license BSD License <http://www.qfdb.net/bsd_license.txt>
  15   * @todo Implement better 'help' attr in label, allow to use nicetitle
  16   */
  17  
  18  
  19  
  20  class qfdb_themes {
  21  
  22      /**
  23       * Print container with one cell
  24       *
  25       * @since: 0.1
  26       * @param: array of string - $args - Data to generate container
  27       * @return: string
  28       * @access: public
  29       * @static
  30       * @see: qfdb_themes::themes_container_two_cells()
  31       * @see: qfdb_themes::themes_label()
  32       */
  33      public static function themes_container_one_cell($args)
  34      {
  35          global $qfdb;
  36          $content = (isset($args['content'])) ? $args['content'] : '';
  37          $others = (isset($args['others']) && trim($args['others'])) ? ' '.trim($args['others']) : '';
  38          $class = (isset($args['class']) && trim($args['class'])) ? ' class="'.trim($args['class']).'"' : '';
  39          $label = (isset($args['label'])) ? $args['label'] : '';
  40  
  41          $space = ($content) ? "\n".$qfdb->i(2) : '';
  42  
  43          return "<tr>\n".
  44              $qfdb->i(1)."<td colspan=\"2\"{$others}{$class}>\n".
  45              $qfdb->i(2)."$label".$space.
  46              "$content\n".
  47              $qfdb->i(1)."</td>\n".
  48              "</tr>\n\n";
  49      } // end themes_container_one_cell()
  50  
  51  
  52  
  53      /**
  54       * Print container with two cell
  55       *
  56       * @since: 0.1
  57       * @param: array of string - $args - Data to generate container
  58       * @return: string
  59       * @access: public
  60       * @static
  61       * @see: qfdb_themes::themes_container_one_cell()
  62       * @see: qfdb_themes::themes_label()
  63       */
  64      public static function themes_container_two_cells($args)
  65      {
  66          global $qfdb;
  67  
  68          $label = (isset($args['label'])) ? ' '.$args['label'] : '';
  69          $content = (isset($args['content']) && trim($args['content'])) ? $args['content'] : '';
  70          $label_class = (isset($args['label_class']) && trim($args['label_class'])) ? ' class="'.$args['label_class'].'"' : '';
  71          $content_class = (isset($args['content_class']) && trim($args['content_class'])) ? ' class="'.$args['content_class'].'"' : '';
  72          $label_others = (isset($args['label_others']) && trim($args['label_others'])) ? ' '.trim($args['label_others']) : '';
  73          $content_others = (isset($args['content_others']) && trim($args['content_others'])) ? ' '.trim($args['content_others']) : '';
  74  
  75          return "<tr>\n".
  76              $qfdb->i(1)."<td{$label_class}{$label_others}>\n".
  77              $qfdb->i(2)."$label\n".
  78              $qfdb->i(1)."</td>\n".
  79              $qfdb->i(1)."<td{$content_class}{$content_others}>\n".
  80              $qfdb->i(2)."$content\n".
  81              $qfdb->i(1)."</td>\n".
  82              "</tr>\n\n";
  83      } // end themes_container_two_cells()
  84  
  85  
  86      /**
  87       * Print label for container
  88       *
  89       * @since: 0.1
  90       * @param: array of mixed - $obj - quickformdb::m
  91       * @return: string
  92       * @access: public
  93       * @static
  94       * @see: quickformdb::m
  95       * @see: qfdb_themes::themes_container_one_cell()
  96       * @see: qfdb_themes::themes_container_two_cells()
  97       * @see: qfdb_themes::themes_container_one_cell()
  98       * @see: qfdb_themes::themes_label()
  99       */
 100      public static function themes_label($obj)
 101      {
 102          $label = trim($obj['label']);
 103          if (!$label) {
 104              return ' ';
 105          }
 106  
 107          $class = (isset($obj['label_class']) && $obj['label_class']) ? ' class="'.trim($obj['label_class']).'"' : '';
 108          $others = (isset($obj['label_others']) && $obj['label_others']) ? ' '.trim($obj['label_others']) : '';
 109          
 110          if (isset($obj['required']) && $obj['required']=='true') {
 111              $required_str = (isset($obj['required_str']) && $obj['required_str']) ? trim($obj['required_str']): '*';
 112              $required_class = (isset($obj['required_class']) && $obj['required_class']) ? ' class="'.trim($obj['required_class']).'"' : '';
 113              $required_others = (isset($obj['required_others']) && $obj['required_others']) ? ' '.trim($obj['required_others']) : '';
 114          } else {
 115              $required_str = $required_class = $required_others = '';
 116          }
 117          
 118          if (isset($obj['help']) && trim($obj['help'])) {
 119              $help_str = (isset($obj['help_str']) && $obj['help_str']) ? trim($obj['help_str']): '[?]';
 120              $help_class = (isset($obj['help_class']) && $obj['help_class']) ? ' class="'.trim($obj['help_class']).'"' : '';
 121              $help_others = (isset($obj['help_others']) && $obj['help_others']) ? ' '.trim($obj['help_others']) : '';
 122          } else {
 123              $help_str = $help_class = $help_others = '';
 124          }
 125  
 126          $label = (isset($obj['required']) && $obj['required'] == 'true') ? $label . ' <b'.$required_class.$required_others.'>'.$required_str.'</b> ' : $label;
 127          $label = (isset($obj['help']) && $obj['help']) ? $label . ' <spam '.$help_class.$help_others.' onclick="alert(\''.$obj['help'].'\');">'.$help_str.'</spam>' : $label;
 128  
 129          if (isset($obj['id']) && $obj['id']) {
 130              return "<label{$class}{$others} for=\"{$obj['id']}\">$label</label>";
 131          } else {
 132              return "<label{$class}{$others}>$label</label>";
 133          }
 134      } // end func
 135  
 136  
 137      /**
 138       * Print a message box
 139       *
 140       * @since: 0.1
 141       * @param: array of string - $args - Data to generate a message box
 142       * @return: string
 143       * @access: public
 144       * @static
 145       */
 146      public static function themes_message_box($args)
 147      {
 148          global $qfdb;
 149  
 150          $title_others = (isset($args['title_others']) && trim($args['title_others'])) ? ' '.$args['title_others'] : '';
 151          $title_class = (isset($args['title_class']) && trim($args['title_class'])) ?     ' class="'.$args['title_class'].'"' : '';
 152          $message_class = (isset($args['message_class']) && trim($args['message_class'])) ? ' class="'.$args['message_class'].'"' : '';
 153          $title =  (isset($args['title'])) ? $args['title'] : '';
 154          $message =  (isset($args['message'])) ? $args['message'] : '';
 155          $message_others = (isset($args['message_others']) && trim($args['message_others'])) ? ' '.$args['message_others'] : '';
 156  
 157          if (!trim($title) && !trim($message)) {
 158              return '';
 159          }
 160  
 161  
 162          $return =  "\n";
 163          if ($message) {
 164                  $return .= $qfdb->i(1)."<div{$message_class}{$message_others}>\n";
 165          }
 166          if ($title) {
 167              $return .= $qfdb->i(2)."<div{$title_class}{$title_others}>".$title."</div>\n";
 168          }
 169          if ($message) {
 170              $return .= $qfdb->i(2).$message.
 171              $qfdb->i(1).'</div>'."\n";
 172          }
 173          return $return;
 174      } // end func
 175  
 176  } // end class


Generated: Fri Nov 14 17:48:13 2008 Cross-referenced by PHPXref 0.7