Author: jablko
Date: Mon Oct 25 09:50:37 2010
New Revision: 8464

Log:
Use $route->resource

Modified:
   trunk/apps/qubit/modules/term/actions/editAction.class.php
   trunk/apps/qubit/modules/term/templates/editSuccess.php
   trunk/plugins/sfDrupalPlugin/lib/sfDrupalWidgetFormSchemaFormatter.class.php

Modified: trunk/apps/qubit/modules/term/actions/editAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/term/actions/editAction.class.php  Mon Oct 25 
09:36:56 2010        (r8463)
+++ trunk/apps/qubit/modules/term/actions/editAction.class.php  Mon Oct 25 
09:50:37 2010        (r8464)
@@ -45,10 +45,9 @@
     $this->form->getValidatorSchema()->setOption('allow_extra_fields', true);
 
     $this->resource = new QubitTerm;
-    if (isset($request->id))
+    if (isset($this->getRoute()->resource))
     {
-      $this->resource = QubitTerm::getById($request->id);
-
+      $this->resource = $this->getRoute()->resource;
       if (!$this->resource instanceof QubitTerm)
       {
         $this->forward404();

Modified: trunk/apps/qubit/modules/term/templates/editSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/term/templates/editSuccess.php     Mon Oct 25 
09:36:56 2010        (r8463)
+++ trunk/apps/qubit/modules/term/templates/editSuccess.php     Mon Oct 25 
09:50:37 2010        (r8464)
@@ -1,8 +1,16 @@
-<h1><?php echo (isset($sf_request->id)) ? __('Edit term') : __('Create term'); 
?></h1>
+<h1>
+  <?php if (isset($sf_request->getAttribute('sf_route')->resource)): ?>
+    <?php echo __('Edit term') ?>
+  <?php else: ?>
+    <?php echo __('Add new term') ?>
+  <?php endif; ?>
+</h1>
 
 <h1 class="label"><?php echo render_title($resource) ?></h1>
 
-<?php if (isset($sf_request->id)): ?>
+<?php echo $form->renderGlobalErrors() ?>
+
+<?php if (isset($sf_request->getAttribute('sf_route')->resource)): ?>
   <?php echo $form->renderFormTag(url_for(array($resource, 'module' => 'term', 
'action' => 'edit'))) ?>
 <?php else: ?>
   <?php echo $form->renderFormTag(url_for(array('module' => 'term', 'action' 
=> 'create'))) ?>
@@ -10,64 +18,42 @@
 
   <?php echo $form->renderHiddenFields() ?>
 
-  <fieldset class="collapsible">
-
-    <legend><?php echo __('Definition') ?></legend>
-
-    <div class="form-item">
-      <?php echo $form->taxonomy->renderLabel() ?>
-      <?php echo $form->taxonomy->renderError() ?>
-      <?php echo $form->taxonomy->render(array('class' => 
'form-autocomplete')) ?>
-      <input class="list" type="hidden" value="<?php echo 
url_for(array($resource->taxonomy, 'module' => 'taxonomy', 'action' => 
'autocomplete')) ?>"/>
-    </div>
-
-    <div class="form-item">
-
-      <?php echo $form->name->renderLabel() ?><?php if 
($resource->isProtected()): ?><?php echo image_tag('lock_mini') ?><?php endif; 
?>
-
-      <?php if ($resource->isProtected()): ?>
-        <?php echo $form->name->render(array('class' => 'disabled', 'disabled' 
=> 'disabled')) ?>
-      <?php else: ?>
-
-        <?php echo $form->name->renderError() ?>
-
-        <?php if (0 < strlen($sourceCultureValue = 
$resource->getName(array('sourceCulture' => 'true'))) && $sf_user->getCulture() 
!= $resource->getSourceCulture()): ?>
-          <div class="default-translation">
-            <?php echo $sourceCultureValue ?>
-          </div>
-        <?php endif; ?>
-
-        <?php echo $form->name ?>
-
-      <?php endif; ?>
-
-    </div>
-
-    <?php echo $form->altLabels
-      ->label(__('Use for'))
-      ->renderRow() ?>
-
-    <?php echo render_field($form->code, $resource) ?>
-
-    <?php echo $form->scopeNote
-      ->label(__('Scope note(s)'))
-      ->renderRow() ?>
-
-    <?php echo $form->sourceNote
-      ->label(__('Source note(s)'))
-      ->renderRow() ?>
-
-    <?php echo $form->displayNote
-      ->label(__('Display note(s)'))
-      ->renderRow() ?>
+  <div class="form-item">
+    <?php echo $form->taxonomy->renderLabel() ?>
+    <?php echo $form->taxonomy->renderError() ?>
+    <?php echo $form->taxonomy->render(array('class' => 'form-autocomplete')) 
?>
+    <input class="list" type="hidden" value="<?php echo url_for(array('module' 
=> 'taxonomy', 'action' => 'autocomplete')) ?>"/>
+  </div>
 
-  </fieldset>
+  <?php if ($resource->isProtected()): ?>
+    <?php echo $form->name->renderRow(array('class' => 'readOnly', 'disabled' 
=> 'disabled')) ?>
+  <?php else: ?>
+    <?php echo render_field($form->name, $resource) ?>
+  <?php endif; ?>
+
+  <?php echo $form->altLabels
+    ->label(__('Use for'))
+    ->renderRow() ?>
+
+  <?php echo render_field($form->code, $resource) ?>
+
+  <?php echo $form->scopeNote
+    ->label(__('Scope note(s)'))
+    ->renderRow() ?>
+
+  <?php echo $form->sourceNote
+    ->label(__('Source note(s)'))
+    ->renderRow() ?>
+
+  <?php echo $form->displayNote
+    ->label(__('Display note(s)'))
+    ->renderRow() ?>
 
   <fieldset class="collapsible collapsed">
 
     <legend><?php echo __('Relationships') ?></legend>
 
-    <?php if (isset($resource->id) || isset($resource->taxonomyId)): ?>
+    <?php if (isset($sf_request->getAttribute('sf_route')->resource) || 
isset($resource->taxonomy)): ?>
 
       <div class="form-item">
         <?php echo $form->parent
@@ -87,12 +73,9 @@
 
     <?php endif; ?>
 
-    <div class="form-item">
-      <?php echo $form->narrowTerms
-        ->label(__('Create narrow terms'))
-        ->renderLabel() ?>
-      <?php echo $form->narrowTerms ?>
-    </div>
+    <?php echo $form->narrowTerms
+      ->label(__('Add new narrow terms'))
+      ->renderRow() ?>
 
   </fieldset>
 
@@ -102,16 +85,19 @@
 
     <div class="content">
       <ul class="clearfix links">
-        <?php if (isset($sf_request->id)): ?>
+        <?php if (isset($sf_request->getAttribute('sf_route')->resource)): ?>
           <li><?php echo link_to(__('Cancel'), array($resource, 'module' => 
'term')) ?></li>
           <li><input class="form-submit" type="submit" value="<?php echo 
__('Save') ?>"/></li>
         <?php else: ?>
+
           <?php if (isset($resource->taxonomy)): ?>
-          <li><?php echo link_to(__('Cancel'), array($resource->taxonomy, 
'module' => 'taxonomy')) ?></li>
+            <li><?php echo link_to(__('Cancel'), array($resource->taxonomy, 
'module' => 'taxonomy')) ?></li>
           <?php else: ?>
-          <li><?php echo link_to(__('Cancel'), array('module' => 'taxonomy', 
'action' => 'list')) ?></li>
+            <li><?php echo link_to(__('Cancel'), array('module' => 'taxonomy', 
'action' => 'list')) ?></li>
           <?php endif; ?>
+
           <li><input class="form-submit" type="submit" value="<?php echo 
__('Create') ?>"/></li>
+
         <?php endif; ?>
       </ul>
     </div>

Modified: 
trunk/plugins/sfDrupalPlugin/lib/sfDrupalWidgetFormSchemaFormatter.class.php
==============================================================================
--- 
trunk/plugins/sfDrupalPlugin/lib/sfDrupalWidgetFormSchemaFormatter.class.php    
    Mon Oct 25 09:36:56 2010        (r8463)
+++ 
trunk/plugins/sfDrupalPlugin/lib/sfDrupalWidgetFormSchemaFormatter.class.php    
    Mon Oct 25 09:50:37 2010        (r8464)
@@ -5,7 +5,7 @@
 
 class sfDrupalWidgetFormSchemaFormatter extends sfWidgetFormSchemaFormatter
 {
-  // Heredocs cannot be used to initialize class members:
+  // Heredocs cannot be used to initialize class members,
   // 
http://php.net/manual/en/language.types.string.php#language.types.string.syntax.nowdoc
   protected
     $errorListFormatInARow = "<div class=\"messages error\">\n  <ul>\n    
%errors%\n  </ul>\n</div>\n",

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to