# default values
all:
max_offices_on_pager: 3
- max_ads_on_pager: 3
+ max_ads_on_pager: 2
sf_guard_plugin:
remember_key_expiration_age: 2592000 # 30 days in seconds
<td colspan="2">
<?php echo $form->renderHiddenFields(false) ?>
<a href="<?php echo url_for('ad/index') ?>">Back to list</a>
- <?php if (!$form->getObject()->isNew()): ?>
- <?php echo link_to('Delete', 'ad/delete?id='.$form->getObject()->getId(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?>
- <?php endif; ?>
- <input type="submit" value="Save" />
+ <input type="submit" value="Update" />
</td>
</tr>
</tfoot>
<tbody>
<?php echo $form->renderGlobalErrors() ?>
- <tr>
- <th><?php echo $form['company_id']->renderLabel() ?></th>
- <td>
- <?php echo $form['company_id']->renderError() ?>
- <?php echo $form['company_id'] ?>
- </td>
- </tr>
- <tr>
- <th><?php echo $form['company_categ_id']->renderLabel() ?></th>
- <td>
- <?php echo $form['company_categ_id']->renderError() ?>
- <?php echo $form['company_categ_id'] ?>
- </td>
- </tr>
- <tr>
- <th><?php echo $form['ad_mobile_image_link']->renderLabel() ?></th>
- <td>
- <?php echo $form['ad_mobile_image_link']->renderError() ?>
- <?php echo $form['ad_mobile_image_link'] ?>
- </td>
- </tr>
- <tr>
- <th><?php echo $form['created_at']->renderLabel() ?></th>
- <td>
- <?php echo $form['created_at']->renderError() ?>
- <?php echo $form['created_at'] ?>
- </td>
- </tr>
- <tr>
- <th><?php echo $form['updated_at']->renderLabel() ?></th>
- <td>
- <?php echo $form['updated_at']->renderError() ?>
- <?php echo $form['updated_at'] ?>
- </td>
- </tr>
+ <?php echo $form ?>
</tbody>
</table>
</form>
<table id="rounded-corner">
<thead>
<tr>
- <th scope="col" class="rounded-company"><?php echo __('Phone Image Link') ?></th>
+ <th scope="col" class="rounded-company"><?php echo __('Phone Image') ?></th>
<th scope="col" class="rounded"><?php echo __('Company Category') ?></th>
<th scope="col" class="rounded"><?php echo __('Ad Name') ?></th>
<th scope="col" class="rounded"><?php echo __('Edit') ?></th>
<tbody>
<?php foreach ($ads as $ad): ?>
<tr>
- <td><?php echo $ad->getAd()->getAdMobileImageLink() ?></td>
+ <td><img src="<?php echo $ad->getAd()->getAdMobileImageLink() ?>" alt="<?php echo $ad->getAdName() ?>"/></td>
<td><?php echo $ad->getAd()->getCompanyCategId() ?></td>
<td><?php echo $ad->getAdName() ?></td>
- <td><a href="<?php echo url_for('ad/edit?id='.$ad->getId()) ?>"><img src="/images/pencil_add.png" alt="" title="" border="0" /></a></td>
- <td><?php echo link_to('<img src="/images/inadminpanel/images/trash.png" alt="" title="" border="0" />', 'ad/delete?id='.$ad->getId(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?></td>
+ <td><a href="<?php echo url_for('ad/edit?id='.$ad->getAd()->getId()) ?>"><img src="/images/pencil_add.png" alt="" title="" border="0" /></a></td>
+ <td><?php echo link_to('<img src="/images/inadminpanel/images/trash.png" alt="" title="" border="0" />', 'ad/delete?id='.$ad->getAd()->getId(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?></td>
</tr>
<?php endforeach; ?>
-<h1>Edit Ad</h1>
+<h2><?php echo __('Edit Ad') ?></h2>
+
<?php include_partial('form', array('form' => $form)) ?>
</div>
<?php endif; ?>
- <a href="<?php echo url_for('ad/new') ?>" class="bt_green"><span class="bt_green_lft"></span><strong><?php echo __('Ad Office') ?></strong><span class="bt_green_r"></span></a>
+ <a href="<?php echo url_for('ad/new') ?>" class="bt_green"><span class="bt_green_lft"></span><strong><?php echo __('New Ad') ?></strong><span class="bt_green_r"></span></a>
-<h1>New Ad</h1>
+<h2><?php echo __('New Ad') ?></h2>
<?php include_partial('form', array('form' => $form)) ?>
<li><a>Manage Ads<!--[if IE 7]><!--></a><!--<![endif]-->
<!--[if lte IE 6]><table><tr><td><![endif]-->
<ul>
- <li><a href="<?php echo url_for('anuncio/new') ?>" title="">Create New Add</a></li>
+ <li><a href="<?php echo url_for('ad/new') ?>" title="">Create New Add</a></li>
<li><a href="" title="">Associate Ad with Company Category</a></li>
</ul>
<!--[if lte IE 6]></td></tr></table></a><![endif]-->
</div>
<div class="sidebarmenu">
- <a class="menuitem submenuheader" href="">Ads</a>
+ <a class="menuitem submenuheader" href="<?php echo url_for('ad/index') ?>">Ads</a>
<div class="submenu">
<ul>
- <li><a href="<?php echo url_for('anuncio/index') ?>">Ads Index</a></li>
+ <li><a href="<?php echo url_for('ad/index') ?>">Ads Index</a></li>
</ul>
</div>
- <a class="menuitem submenuheader" href="" >Offices</a>
+ <a class="menuitem submenuheader" href="<?php echo url_for('office/index') ?>" >Offices</a>
<div class="submenu">
<ul>
<li><a href="<?php echo url_for('office/index') ?>">Offices Index</a></li>
{
public function configure()
{
+ //$this->useFields(array('language_id', 'ad_id', 'ad_name', 'ad_description', 'ad_mobile_text', 'ad_link'));
+ unset($this['ad_id']);
+
+ if ($this->object->exists())
+ {
+ $this->widgetSchema['delete'] = new sfWidgetFormInputCheckbox();
+ $this->validatorSchema['delete'] = new sfValidatorPass();
+ }
}
}
*
* @package mobiads
* @subpackage form
- * @author Your name here
- * @version SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
+ * @author Gustavo Martin Morcuende
+ * @version
*/
class AdForm extends BaseAdForm
{
+ protected $scheduledForDeletion = array();
+
public function configure()
{
+ $this->useFields(array('company_categ_id', 'ad_mobile_image_link'));
+
+ // Ad creation form
+ $adDescription = new AdDescription();
+ $adDescription->Ad = $this->getObject();
+ $newAdDescriptionForm = new AdDescriptionForm($adDescription);
+
+ $this->embedForm('new', $newAdDescriptionForm);
+
+ $this->embedRelation('AdDescription');
+
+ }
+
+ protected function doBind(array $values)
+ {
+ if ('' === trim($values['new']['ad_description']) && '' === trim($values['new']['ad_mobile_text'])
+ && '' === trim($values['new']['ad_name']) && '' === trim($values['new']['ad_link']))
+ {
+ unset($values['new'], $this['new']);
+ }
+
+ if (isset($values['AdDescription']))
+ {
+ foreach ($values['AdDescription'] as $i => $adDescriptionValues)
+ {
+ if (isset($adDescriptionValues['delete']) && $adDescriptionValues['id'])
+ {
+ $this->scheduledForDeletion[$i] = $adDescriptionValues['id'];
+ }
+ }
+ }
+
+
+ parent::doBind($values);
+ }
+
+ /**
+ * Updates object with provided values, dealing with evantual relation deletion
+ *
+ * @see sfFormDoctrine::doUpdateObject()
+ */
+ protected function doUpdateObject($values)
+ {
+ if (count($this->scheduledForDeletion))
+ {
+ foreach ($this->scheduledForDeletion as $index => $id)
+ {
+ unset($values['AdDescription'][$index]);
+ unset($this->object['AdDescription'][$index]);
+ Doctrine::getTable('AdDescription')->findOneById($id)->delete();
+ }
+ }
+
+ $this->getObject()->fromArray($values);
+ }
+
+ /**
+ * Saves embedded form objects.
+ *
+ * @param mixed $con An optional connection object
+ * @param array $forms An array of forms
+ */
+ public function saveEmbeddedForms($con = null, $forms = null)
+ {
+ if (null === $con)
+ {
+ $con = $this->getConnection();
+ }
+
+ if (null === $forms)
+ {
+ $forms = $this->embeddedForms;
+ }
+
+ foreach ($forms as $form)
+ {
+ if ($form instanceof sfFormObject)
+ {
+ if (!in_array($form->getObject()->getId(), $this->scheduledForDeletion))
+ {
+ $form->saveEmbeddedForms($con);
+ $form->getObject()->save($con);
+ }
+ }
+ else
+ {
+ $this->saveEmbeddedForms($con, $form->getEmbeddedForms());
+ }
+ }
}
}