<td class="tac"></td>
      <td class="cWillContinue"></td>
    </tr>
    <tr>
      <th class="alignleft light" colspan="7"><?php echo __('Studio') ?></th>
<?php foreach ($lessons as $lesson): ?>
      <td class="tac"><?php echo $lesson->getStudio()->getAbbreviation() ?></td>
<?php endforeach; ?>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr class="">
      <th class="alignleft light" colspan="7"><?php echo __('Lehrer') ?></th>
<?php foreach ($lessons as $lesson): ?>
      <td class="tac">
        <?php echo Swingmachine::getTeachersAsString( $class->getTeachers() , false, "," ) ?>
      </td>
<?php endforeach; ?>
      <td></td>
      <td></td>
    </tr>
    <!--
    <tr class="">
      <th class="alignleft light" colspan="8"><?php echo __('Kursbetreuer') ?></th>
<?php foreach ($lessons as $lesson): ?>
      <td class="tac">
        <?php #echo $class->getManager()->getFirstName() ?>
      </td>
<?php endforeach; ?>
      <td></td>
      <td></td>
Пример #2
0
<table class="table table-condensed table-hover rowclick">
  <tbody>
<?php
      foreach ($enrolments as $i => $enrolment): 
        $class = Swingmachine::isValidEmail( $enrolment->getPerson()->getEmail() )  ? '' : ' error text-error';
?>
    <tr class="<?php echo $class ?>">
      <td>
        <?php echo $i+1 ?>
      </td>
      <td>
        <?php echo $enrolment->getPerson() ?>
      </td>
      <td>
        <?php echo $enrolment->getPerson()->getEmail() ?>
      </td>
      <td>
          <?php #echo $enrolment->getSentAt() ?>
      </td>
      <!--
      <td>
        <?php # if (!$enrolment->getSuccess() ) : ?>
        <a href="#<?php echo $enrolment->id ?>" data-toggle="modal" class="rowclick">Vorschau</a>
      <?php # endif; ?>
      </td>
    -->
    </tr>

<div id="<?php echo $enrolment->id ?>" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  protected function execute($arguments = array(), $options = array())
  {

    if (!$options['go']) 
      $this->logBlock('Running in dry mode, no files will be created.', 'ERROR');

    $pdf_dir  = sfConfig::get('sf_data_dir').sfConfig::get("app_rockstep_pdf_dir");
    $html_dir = sfConfig::get('sf_data_dir').sfConfig::get("app_rockstep_html2pdf_dir");

    // get PDF file-info
    $pdf = array();
    $weeds = array('.', '..','.DS_Store'); 
    $directory = array_diff(scandir($pdf_dir), $weeds); 
    foreach( $directory as $id => $filename ) {
      if (is_file($pdf_dir.$filename)) {
        $info     = pathinfo($filename);
        $basename =  basename($filename,'.'.$info['extension']);
        $timestamp = filemtime($pdf_dir.$filename);
        $pdf[$basename] = $timestamp;
      }
    }
    
    // get HTML files and compare to PDF
    $files2process = array();
    $weeds = array('.', '..','.DS_Store'); 
    $directory = array_diff(scandir($html_dir), $weeds); 

    if (!$options['force']) {
      $this->logBlock(sprintf("Checking %d files in %s", count($directory), $html_dir), 'COMMENT');
    } else {
      $this->logBlock(sprintf("Processing all %d files from %s", count($directory), $html_dir), 'COMMENT');
    }

    foreach( $directory as $id => $filename ) {
      if (is_file($html_dir.$filename)) {
        //$info     = pathinfo($filename);
        $basename = basename($filename,'.pdf.html'); //.$info['extension']);        
        if (!$options['force']) {
          if (array_key_exists($basename, $pdf)) {
            if ($pdf[$basename] >= filemtime($html_dir.$filename)) {
              continue; // pdf is up to date
            }
          }
        }
        $files2process[$html_dir.$filename] = $pdf_dir.$basename.'.pdf';
      }
    }
    
    // process PDF
    $error = 0; $success = 0;
    if (count($files2process) == 0) {
      $this->logBlock('Everything is up to date.', 'INFO');
    } else {
      $this->logBlock(sprintf("%d files to process", count($files2process)), 'INFO');
      foreach ($files2process as $html_path => $pdf_path) {
        
          $css = '/backend/pdf/kursliste.css';
          $format = 'A4-L';

        /*
        if (strpos($html_path, 'Absenzen') !== false ) {
          $css = '/backend/pdf/kursliste.css';
          $format = 'A4-L';
        } else {
          $css = '/backend/pdf/class_etat.css';
          $format = 'A4-L';
        }
        */
        
        if ($options['go']) 
          Swingmachine::mpdf($html_path, $pdf_path, $css, $format);
        $this->logSection('file+', sprintf("%s", basename($pdf_path)));
        $success++;
      }
        
      if ($error > 0) {
        $this->logBlock(sprintf('An error occured. No idea what went wrong. Sorry.', $error, $success), 'ERROR');
      } else {
        $this->logBlock(sprintf('%d PDF files created', $success), 'INFO');
      }

    }
    
  }
<?php

require_once dirname(__FILE__).'/../bootstrap/unit.php';

$t = new lime_test(9);

$t->is(Swingmachine::slugify('LindyHop'),         'lindyhop',         '::slugify() converts all characters to lower case');
$t->is(Swingmachine::slugify('lindy hop'),        'lindy-hop',        '::slugify() replaces a white space by a -');
$t->is(Swingmachine::slugify('lindy    hop'),     'lindy-hop',        '::slugify() replaces several white spaces by a single -');
$t->is(Swingmachine::slugify('lindy,balboa'),     'lindy-balboa',     '::slugify() removes - at the beginning of a string');
$t->is(Swingmachine::slugify('  lindy'),          'lindy',            '::slugify() removes - at the end of a string');
$t->is(Swingmachine::slugify('lindy  '),          'lindy',            '::slugify() replaces non-ASCII characters by a -');
$t->is(Swingmachine::slugify(''),                 'n-a',              '::slugify() converts the empty string to n-a');
$t->is(Swingmachine::slugify(' - '),              'n-a',              '::slugify() converts a string that only contains non-ASCII characters to n-a');

if (function_exists('iconv'))
{
    $t->is(Swingmachine::slugify('Cours Réguliers'),  'cours-reguliers',  '::slugify() removes accents');
}
else
{
  $t->skip('::slugify() removes accents - iconv not installed');
}
Пример #5
0
  public function executeIndex(sfWebRequest $request)
  {

  $this->form = new sfForm();
  $this->form->setWidgets(array(
    'input'    => new sfWidgetFormTextArea( array(), array( 
      'rows' => 10, 'class' => 'span9'
      )),
    'role'     => new sfWidgetFormChoice( array(
      'choices' => array( 'leader' => 'leader', 'follower' => 'follower')
    )),
    'type'     => new sfWidgetFormChoice( array(
      'choices' => Doctrine::getTable('dsClassStudent')->getTypes()
      )) 
  ));

  $this->form->setDefault('input', $this->getUser()->getAttribute('import_raw'));

  // Deal with the request
  if ($request->isMethod('post'))
  {
    // Handle the form submission
    $input = $request->getPostParameter('input');
    $role = $request->getPostParameter('role');
    $this->type = $request->getPostParameter('type');

    $this->getUser()->setAttribute('import_raw', $this->input);

    // Do stuff
    $array = Swingmachine::csvstring_to_array($input, "\t");

    // validate emails
    $this->array = array();
    foreach( $array as $row ):
      // $valid = 1;
      $newrow = array(
        'firstname' => array_key_exists(0, $row) ? $row[0] : null,
        'lastname' => array_key_exists(1, $row) ? $row[1] : null,
        'email' => array_key_exists(2, $row) ? $row[2] : null,
        'student' => array_key_exists(3, $row) ? $row[3] : null,
        'note' => array_key_exists(4, $row) ? $row[4] : null
      );
      $test = $newrow['email']."";
      $newrow['email-valid'] = Swingmachine::isValidEmail($test);
      array_push($this->array, $newrow);
    endforeach;

    $this->role = $role;
    $this->new = $this->array;

    $this->getUser()->setAttribute('import_data', $this->array);
    $this->getUser()->setAttribute('import_role', $this->role);
    $this->getUser()->setAttribute('import_type', $this->type);

    $this->redirect('import_preview');

    //$this->array = $new;
    //$this->redirect('ds_class_student_import_preview');
  }

  }
static public function csvstring_to_array($string, $separatorChar = ',', $enclosureChar = '"', $newlineChar = "\n") {
    // @author: Klemen Nagode
    $array = array();
    $size = strlen($string);
    $columnIndex = 0;
    $rowIndex = 0;
    $fieldValue="";
    $isEnclosured = false;

    //$string = preg_replace('/^\p{Z}+|\p{Z}+$/u','',$string);
    //$string = preg_replace('/^[\pZ\pC]+|[\pZ\pC]+$/u', ' ', $string);

    for($i=0; $i<$size;$i++) {

        $char = $string{$i};

        // echo "<br>".$i."-".$char."--".ord($char);

        
        if (ord($char) == 160) // Non-breaking space  - A0
            $char = ' ';
        if (ord($char) == 194) // Non-breaking space  - A0
            $char = ' ';
        

        /*
        if (ord($char) == 157) // Unknown
            $char = ' '; // 0D
        if ($char == "\x0D") $char = ' '; // carriage return
        */

        $addChar = "";

        if($isEnclosured) {
            if($char==$enclosureChar) {

                if($i+1<$size && $string{$i+1}==$enclosureChar){
                    // escaped char
                    $addChar=$char;
                    $i++; // dont check next char
                }else{
                    $isEnclosured = false;
                }
            }else {
                $addChar=$char;
            }
        }else {
            if($char==$enclosureChar) {
                $isEnclosured = true;
            }else {

                if($char==$separatorChar) {

                    $array[$rowIndex][$columnIndex] = Swingmachine::supertrim($fieldValue);
                    $fieldValue="";

                    $columnIndex++;
                }elseif($char==$newlineChar) {
                    # echo $char;
                    $array[$rowIndex][$columnIndex] = Swingmachine::supertrim($fieldValue);
                    $fieldValue="";
                    $columnIndex=0;
                    $rowIndex++;
                }else {
                    $addChar=$char;
                }
            }
        }
        if($addChar!=""){
            $fieldValue.=$addChar;

        }
    }

    if($fieldValue) { // save last field
        $array[$rowIndex][$columnIndex] = Swingmachine::supertrim($fieldValue);
    }
    
    return $array;
}
Пример #7
0
  public function getTeachersAsString() {

    return Swingmachine::getTeachersAsString( $this->getTeachers() );
  }
Пример #8
0
public function generateKurslistePDF($download = null)
{
          $filename = $this->getKurslisteFilename();
          $html2pdf_dir = sfConfig::get('sf_data_dir').sfConfig::get('app_rockstep_html2pdf_dir');
          $css = '/backend/pdf/kursliste.css';
          $format = 'A4-L';
          Swingmachine::mpdf($html2pdf_dir.$filename.'.html', $filename, $css, $format, $download);

          return true;
}
Пример #9
0
  public function executeImport(sfWebRequest $request)
  {

  $this->form = new sfForm();
  $this->form->setWidgets(array(
    'input'    => new sfWidgetFormTextArea(),
    'role'     => new sfWidgetFormChoice( array('choices' => array( 'lead' => 'lead', 'follow' => 'follow'))) 
  ));

  $this->form->setDefault('input', $this->getUser()->getAttribute('import_raw'));

  // Deal with the request
  if ($request->isMethod('post'))
  {
    // Handle the form submission
    $input = $request->getPostParameter('input');
    $role = $request->getPostParameter('role');

    $this->getUser()->setAttribute('import_raw', $this->input);

    // Do stuff
    $array = Swingmachine::csvstring_to_array($input, "\t");

    // validate emails
    $this->array = array();
    foreach( $array as $row ):
      // $valid = 1;
      $test = $row[2]."";
      $valid = Swingmachine::isValidEmail($test);
      $row['email-valid'] = $valid;
      array_push($this->array, $row);
    endforeach;

    $this->role = $role;
    $this->new = $this->array;

    $this->getUser()->setAttribute('import_data', $this->array);
    $this->getUser()->setAttribute('import_role', $this->role);

    $this->redirect('@ds_class_students_importPreview?class_id='.$this->class->getId() );

    //$this->array = $new;
    //$this->redirect('ds_class_student_import_preview');
  }

  }