My favorites | Sign in
Project Logo
                
Changes to /qt-blog/views/posts/admin_edit.ctp
r0 vs. r13   Edit
  Compare: vs.   Format:
Revision r13
Go to: 
Project members, sign in to write a code review
/qt-blog/views/posts/admin_edit.ctp   r0 /qt-blog/views/posts/admin_edit.ctp   r13
  1 <?php
  2 // var_dump($this->data);
  3 // import markup from baked template (lazy)
  4 $formMarkup = new Callback(
  5 create_function('$view',
  6 'return $view->requestAction("/admin/posts/template/edit/", array("return"));'
  7 ), $this
  8 );
  9 $name = substr(__FILE__, strlen(VIEWS));
  10 $template = template($name)
  11 // use baked template as markup source
  12 ->sourceCollect($formMarkup, 'formMarkup')
  13 ->parse()
  14 ->source('formMarkup')->returnReplace()
  15 ->find('fieldset:eq(1)')
  16 ->find('.input:has(input[name*=published])')
  17 ->replaceWith('
  18 <div>
  19 <label>Published</label>
  20 <input name="published" type="radio" value="1" /> YES
  21 <input name="published" type="radio" value="0"/> NO
  22 </div>')
  23 ->end()
  24 ->find('.input:has(input[name*=Tag])')
  25 ->find('input[type=hidden]')->remove()->end()
  26 ->find('select')->attr('name', 'Tag')->end()
  27 ->end()
  28 ->end()
  29 /* IMPORTED TEMPLATE PREPARATION */
  30 ->find('form')
  31 // form[action] is broken like other URLs from imported template
  32 ->attr('action', '/admin/posts/edit')
  33 // remove form's internal fieldset (will be readded)
  34 ->find('fieldset:has(input[name=_method])')->remove()->end()
  35 ->end()
  36 ->plugin('CakeForms')
  37 ->formToCakeForm(
  38 array('Post', array('action' => 'edit')), $form)
  39 // ->dump()
  40 ->save()
  41 ;
  42 require($template);
Hosted by Google Code