<?php 
class ApArticleItemHelper extends AppHelper {

  var $name = 'ApArticleItem';

  var $helpers = array ('Html', 'Form');

  function generate ($data, $mode = 'view') {
    $lview = ClassRegistry::getObject('view');
    if ($data) {
      $out = '';
      switch (strtolower($mode)) {
        case 'form':
          $prefix = 'ap_f_';
          $out .= '<table border="0" class="ap_ai_form">' . "\n";
          foreach ($data as $val) {
            $out .= "<tr><td>\n";
            $out .= $lview->renderElement($prefix . $val['Item']['item_type_id'], array('data' => $val)) . "\n";
            $out .= $lview->renderElement('ap_form_common', array('data' => $val)) . "\n";
            $out .= "</td></tr>\n";
          }
          $out .= "</table>\n";
        break;
        case 'view':
        default:
          $prefix = 'ap_v_';
          foreach ($data as $val) {
            if ($val['Item']['visible'] > 0) {
              $out .= $lview->renderElement($prefix . $val['Item']['item_type_id'], array('data' => $val));
            }
          }
        break;
      }
      return $this->output($out);
    }
  }
}
?>
