First module: office
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Sun, 13 May 2012 16:51:11 +0000 (18:51 +0200)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Sun, 13 May 2012 16:51:11 +0000 (18:51 +0200)
Getting ready: layout, i18n
I have to write a new form for this module which will let us create
a new office. Right now without javascript, but if I want it to seem
"professional" I will have to finish using javascript...

13 files changed:
apps/companyfront/config/app.yml
apps/companyfront/config/routing.yml
apps/companyfront/config/view.yml
apps/companyfront/modules/office/actions/actions.class.php [new file with mode: 0644]
apps/companyfront/modules/office/i18n/office_form.es.xml [new file with mode: 0644]
apps/companyfront/modules/office/templates/_form.php [new file with mode: 0644]
apps/companyfront/modules/office/templates/editSuccess.php [new file with mode: 0644]
apps/companyfront/modules/office/templates/indexSuccess.php [new file with mode: 0644]
apps/companyfront/modules/office/templates/newSuccess.php [new file with mode: 0644]
apps/companyfront/modules/office/templates/showSuccess.php [new file with mode: 0644]
apps/companyfront/templates/layout.php
test/functional/companyfront/officeActionsTest.php [new file with mode: 0644]
web/companyfront.php [new file with mode: 0644]

index f88da69..5b598b9 100644 (file)
@@ -2,4 +2,14 @@
 # http://www.symfony-project.org/reference/1_4/en/11-App
 
 # default values
-#all:
+all:
+  max_jobs_on_category: 3
+
+  sf_guard_plugin:
+     remember_key_expiration_age: 2592000             # 30 days in seconds
+     remember_cookie_name:        mobicomRemember     # used by sfGuardSecurityUser.class.php
+     success_signin_url:          @homepage           # the plugin uses the referer as default
+     success_signout_url:         @sf_guard_signin    # used by BasesfGuardAuthActions.class.php. After logout we are redirected to this page
+     signin_url_path:             login               # used by sfGuardRememberMeFilter.class.php. The Remember cookie must not be used when using the login page
+     remember_cookie_path:        /companyfront.php   # used by sfGuardSecurityUser.class.php. The scope of the Remeber cookie
+
index 4f466dd..746237e 100644 (file)
@@ -6,6 +6,12 @@ homepage:
   url:   /
   param: { module: default, action: index }
 
+office_index:
+  url:     /office/index
+  class:   sfDoctrineRoute
+  param:   { module: office, action: index }
+  options: { model: Office, type: object }
+
 # generic rules
 # please, remove them by adding more specific rules
 default_index:
index 407733d..5db0828 100644 (file)
@@ -12,9 +12,9 @@ default:
     #language:     en
     #robots:       index, follow
 
-  stylesheets:    [main.css]
+  stylesheets:    [inadminpanel/style.css, inadminpanel/niceforms-default.css, jquery.treeTable.css]
 
-  javascripts:    []
+  javascripts:    [jquery-1.6.2.min.js, jquery.treeTable.js, inadminpanel/ddaccordion.js]
 
   has_layout:     true
   layout:         layout
diff --git a/apps/companyfront/modules/office/actions/actions.class.php b/apps/companyfront/modules/office/actions/actions.class.php
new file mode 100644 (file)
index 0000000..ce035a7
--- /dev/null
@@ -0,0 +1,79 @@
+<?php
+
+/**
+ * office actions.
+ *
+ * @package    mobiads
+ * @subpackage office
+ * @author     Your name here
+ * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
+ */
+class officeActions extends sfActions
+{
+  public function executeIndex(sfWebRequest $request)
+  {
+    $this->offices = Doctrine_Core::getTable('Office')
+      ->createQuery('a')
+      ->execute();
+  }
+
+  public function executeShow(sfWebRequest $request)
+  {
+    $this->office = Doctrine_Core::getTable('Office')->find(array($request->getParameter('id')));
+    $this->forward404Unless($this->office);
+  }
+
+  public function executeNew(sfWebRequest $request)
+  {
+    $this->form = new OfficeForm();
+  }
+
+  public function executeCreate(sfWebRequest $request)
+  {
+    $this->forward404Unless($request->isMethod(sfRequest::POST));
+
+    $this->form = new OfficeForm();
+
+    $this->processForm($request, $this->form);
+
+    $this->setTemplate('new');
+  }
+
+  public function executeEdit(sfWebRequest $request)
+  {
+    $this->forward404Unless($office = Doctrine_Core::getTable('Office')->find(array($request->getParameter('id'))), sprintf('Object office does not exist (%s).', $request->getParameter('id')));
+    $this->form = new OfficeForm($office);
+  }
+
+  public function executeUpdate(sfWebRequest $request)
+  {
+    $this->forward404Unless($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT));
+    $this->forward404Unless($office = Doctrine_Core::getTable('Office')->find(array($request->getParameter('id'))), sprintf('Object office does not exist (%s).', $request->getParameter('id')));
+    $this->form = new OfficeForm($office);
+
+    $this->processForm($request, $this->form);
+
+    $this->setTemplate('edit');
+  }
+
+  public function executeDelete(sfWebRequest $request)
+  {
+    $request->checkCSRFProtection();
+
+    $this->forward404Unless($office = Doctrine_Core::getTable('Office')->find(array($request->getParameter('id'))), sprintf('Object office does not exist (%s).', $request->getParameter('id')));
+    $office->delete();
+
+    $this->redirect('office/index');
+  }
+
+  protected function processForm(sfWebRequest $request, sfForm $form)
+  {
+    $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
+    if ($form->isValid())
+    {
+      $office = $form->save();
+
+      $this->redirect('office/edit?id='.$office->getId());
+    }
+  }
+}
diff --git a/apps/companyfront/modules/office/i18n/office_form.es.xml b/apps/companyfront/modules/office/i18n/office_form.es.xml
new file mode 100644 (file)
index 0000000..7cbdd30
--- /dev/null
@@ -0,0 +1,67 @@
+<?xml version="1.0" ?>
+<xliff version="1.0">
+  <file original="global" source-language="en" datatype="plaintext">
+    <body>
+      <trans-unit>
+        <source>Company Administrator User Id: </source>
+        <target>Id del Usuario Administrador de Empresa: </target>
+      </trans-unit>
+      <trans-unit>
+        <source>Company Id: </source>
+        <target>Id de la Empresa: </target>
+      </trans-unit>
+      <trans-unit>
+        <source>Longitude (180 to -180): </source>
+        <target>Longitud (180 a -180): </target>
+      </trans-unit>
+         <trans-unit>
+        <source>Latitude (90 to -90): </source>
+        <target>Latitud (90 a -90): </target>
+      </trans-unit>
+      <trans-unit>
+        <source>Address: </source>
+        <target>Direccion: </target>
+      </trans-unit>
+         <trans-unit>
+        <source>Wrong Longitude</source>
+        <target>Longitud erronea</target>
+      </trans-unit>
+         <trans-unit>
+        <source>The longitude field is required</source>
+        <target>Se requiere el campo longitud</target>
+      </trans-unit>
+         <trans-unit>
+        <source>Longitude "%value%" must not exceed the %max% value</source>
+        <target>La longitud "%value%" no debe exceder el valor %max%</target>
+      </trans-unit>
+         <trans-unit>
+        <source>Longitude "%value%" must be equal or higher than %min%</source>
+        <target>La longitud "%value%" debe ser igual o mayor que %min%</target>
+      </trans-unit>
+         <trans-unit>
+        <source>Wrong Latitude</source>
+        <target>Latitud erronea</target>
+      </trans-unit>
+      <trans-unit>
+        <source>The latitude field is required</source>
+        <target>Se requiere el campo latitud</target>
+      </trans-unit>
+      <trans-unit>
+        <source>Latitude "%value%" must not exceed the %max% value</source>
+        <target>La latitud "%value%" no debe exceder el valor %max%</target>
+      </trans-unit>
+      <trans-unit>
+        <source>Latitude "%value%" must be equal or higher than %min%</source>
+        <target>La latitud "%value%" debe ser igual o mayor que %min%</target>
+      </trans-unit>
+      <trans-unit>
+        <source>Invalid address field</source>
+        <target>Campo calle erroneo</target>
+      </trans-unit>
+         <trans-unit>
+        <source>Address "%value%" must have %max_length% characters or less</source>
+        <target>La direccion "%value%" debe tener %max_length% characters o menos</target>
+      </trans-unit>
+    </body>
+  </file>
+</xliff>
diff --git a/apps/companyfront/modules/office/templates/_form.php b/apps/companyfront/modules/office/templates/_form.php
new file mode 100644 (file)
index 0000000..0792e22
--- /dev/null
@@ -0,0 +1,74 @@
+<?php use_stylesheets_for_form($form) ?>
+<?php use_javascripts_for_form($form) ?>
+
+<form action="<?php echo url_for('office/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id='.$form->getObject()->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
+<?php if (!$form->getObject()->isNew()): ?>
+<input type="hidden" name="sf_method" value="put" />
+<?php endif; ?>
+  <table>
+    <tfoot>
+      <tr>
+        <td colspan="2">
+          <?php echo $form->renderHiddenFields(false) ?>
+          &nbsp;<a href="<?php echo url_for('office/index') ?>">Back to list</a>
+          <?php if (!$form->getObject()->isNew()): ?>
+            &nbsp;<?php echo link_to('Delete', 'office/delete?id='.$form->getObject()->getId(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?>
+          <?php endif; ?>
+          <input type="submit" value="Save" />
+        </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['city_id']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['city_id']->renderError() ?>
+          <?php echo $form['city_id'] ?>
+        </td>
+      </tr>
+      <tr>
+        <th><?php echo $form['office_gps']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['office_gps']->renderError() ?>
+          <?php echo $form['office_gps'] ?>
+        </td>
+      </tr>
+      <tr>
+        <th><?php echo $form['office_street_address']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['office_street_address']->renderError() ?>
+          <?php echo $form['office_street_address'] ?>
+        </td>
+      </tr>
+      <tr>
+        <th><?php echo $form['office_zip']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['office_zip']->renderError() ?>
+          <?php echo $form['office_zip'] ?>
+        </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>
+    </tbody>
+  </table>
+</form>
diff --git a/apps/companyfront/modules/office/templates/editSuccess.php b/apps/companyfront/modules/office/templates/editSuccess.php
new file mode 100644 (file)
index 0000000..8e1c570
--- /dev/null
@@ -0,0 +1,3 @@
+<h1>Edit Office</h1>
+
+<?php include_partial('form', array('form' => $form)) ?>
diff --git a/apps/companyfront/modules/office/templates/indexSuccess.php b/apps/companyfront/modules/office/templates/indexSuccess.php
new file mode 100644 (file)
index 0000000..a2b7a2d
--- /dev/null
@@ -0,0 +1,32 @@
+<h1>Offices List</h1>
+
+<table>
+  <thead>
+    <tr>
+      <th>Id</th>
+      <th>Company</th>
+      <th>City</th>
+      <th>Office gps</th>
+      <th>Office street address</th>
+      <th>Office zip</th>
+      <th>Created at</th>
+      <th>Updated at</th>
+    </tr>
+  </thead>
+  <tbody>
+    <?php foreach ($offices as $office): ?>
+    <tr>
+      <td><a href="<?php echo url_for('office/show?id='.$office->getId()) ?>"><?php echo $office->getId() ?></a></td>
+      <td><?php echo $office->getCompanyId() ?></td>
+      <td><?php echo $office->getCityId() ?></td>
+      <td><?php echo $office->getOfficeGps() ?></td>
+      <td><?php echo $office->getOfficeStreetAddress() ?></td>
+      <td><?php echo $office->getOfficeZip() ?></td>
+      <td><?php echo $office->getCreatedAt() ?></td>
+      <td><?php echo $office->getUpdatedAt() ?></td>
+    </tr>
+    <?php endforeach; ?>
+  </tbody>
+</table>
+
+  <a href="<?php echo url_for('office/new') ?>">New</a>
diff --git a/apps/companyfront/modules/office/templates/newSuccess.php b/apps/companyfront/modules/office/templates/newSuccess.php
new file mode 100644 (file)
index 0000000..9113985
--- /dev/null
@@ -0,0 +1,3 @@
+<h1>New Office</h1>
+
+<?php include_partial('form', array('form' => $form)) ?>
diff --git a/apps/companyfront/modules/office/templates/showSuccess.php b/apps/companyfront/modules/office/templates/showSuccess.php
new file mode 100644 (file)
index 0000000..637f502
--- /dev/null
@@ -0,0 +1,42 @@
+<table>
+  <tbody>
+    <tr>
+      <th>Id:</th>
+      <td><?php echo $office->getId() ?></td>
+    </tr>
+    <tr>
+      <th>Company:</th>
+      <td><?php echo $office->getCompanyId() ?></td>
+    </tr>
+    <tr>
+      <th>City:</th>
+      <td><?php echo $office->getCityId() ?></td>
+    </tr>
+    <tr>
+      <th>Office gps:</th>
+      <td><?php echo $office->getOfficeGps() ?></td>
+    </tr>
+    <tr>
+      <th>Office street address:</th>
+      <td><?php echo $office->getOfficeStreetAddress() ?></td>
+    </tr>
+    <tr>
+      <th>Office zip:</th>
+      <td><?php echo $office->getOfficeZip() ?></td>
+    </tr>
+    <tr>
+      <th>Created at:</th>
+      <td><?php echo $office->getCreatedAt() ?></td>
+    </tr>
+    <tr>
+      <th>Updated at:</th>
+      <td><?php echo $office->getUpdatedAt() ?></td>
+    </tr>
+  </tbody>
+</table>
+
+<hr />
+
+<a href="<?php echo url_for('office/edit?id='.$office->getId()) ?>">Edit</a>
+&nbsp;
+<a href="<?php echo url_for('office/index') ?>">List</a>
index b37659b..9302c0e 100644 (file)
   <head>
     <?php include_http_metas() ?>
     <?php include_metas() ?>
-    <?php include_title() ?>
+    <?php //include_title() ?>
+       <title>Mobi - Mobile Ads</title>
     <link rel="shortcut icon" href="/favicon.ico" />
     <?php include_stylesheets() ?>
     <?php include_javascripts() ?>
+
+       <script type="text/javascript">
+       ddaccordion.init({
+       headerclass: "submenuheader", //Shared CSS class name of headers group
+       contentclass: "submenu", //Shared CSS class name of contents group
+       revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
+       mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
+       collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
+       defaultexpanded: [], //index of content(s) open by default [index1, index2, etc] [] denotes no content
+       onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
+       animatedefault: false, //Should contents open by default be animated into view?
+       persiststate: true, //persist state of opened contents within browser session?
+       toggleclass: ["", ""], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
+       togglehtml: ["suffix", "<img src='/images/inadminpanel/images/plus.gif' class='statusicon' />", "<img src='/images/inadminpanel/images/minus.gif' class='statusicon' />"], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
+       animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
+       oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
+               //do nothing
+       },
+       onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
+               //do nothing
+       }
+})
+  </script>
   </head>
   <body>
-    <?php echo $sf_content ?>
+  <div id="main_container">
+       <div class="header">
+       <div class="logo"><a href="#"><img src="" alt="" title="" border="0" /></a></div>
+       <div class="right_header">Welcome Admin | <a href="<?php echo url_for('sf_guard_signout') ?>" class="logout">Logout</a></div>
+       </div>
+       <div class="main_content">
+               <div class="menu">
+        <ul>
+        <li><a class="current" href="<?php echo url_for('homepage') ?>">Home</a></li>
+        <li><a>Manage Categories<!--[if IE 7]><!--></a><!--<![endif]-->
+        <!--[if lte IE 6]><table><tr><td><![endif]-->
+               <ul>
+               <li><a href="<?php echo url_for('categempresa/new') ?>" title="">Add New Category</a></li>
+            <li><a href="" title="">Delete Category</a></li>
+            <li><a href="" title="">Associate Categories</a></li>
+            </ul>
+        <!--[if lte IE 6]></td></tr></table></a><![endif]-->
+        </li>
+        <li><a>Manage Offices<!--[if IE 7]><!--></a><!--<![endif]-->
+        <!--[if lte IE 6]><table><tr><td><![endif]-->
+            <ul>
+                <li><a href="<?php echo url_for('office/new') ?>" title="">Create New Office</a></li>
+            </ul>
+        <!--[if lte IE 6]></td></tr></table></a><![endif]-->
+        </li>
+        <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="" title="">Associate Ad with Company Category</a></li>
+             </ul>
+         <!--[if lte IE 6]></td></tr></table></a><![endif]-->
+         </li>
+         </ul>
+            </div>
+       <div class="center_content">  
+    <div class="left_content">
+               <div class="sidebar_search">
+            <form>
+            <input type="text" name="" class="search_input" value="search keyword" onclick="this.value=''" />
+            <input type="image" class="search_submit" src="/images/inadminpanel/images/search.png" />
+            </form>            
+            </div>
+            <div class="sidebarmenu">
+            
+                <a class="menuitem submenuheader" href="">Ads</a>
+                <div class="submenu">
+                    <ul>
+                    <li><a href="<?php echo url_for('anuncio/index') ?>">Ads Index</a></li>
+                    </ul>
+                </div>
+                <a class="menuitem submenuheader" href="" >Offices</a>
+                <div class="submenu">
+                    <ul>
+                    <li><a href="<?php echo url_for('office/index') ?>">Offices Index</a></li>
+                    <li><a href="">Sidebar submenu</a></li>
+                    </ul>
+                </div>
+                <a class="menuitem submenuheader" href="">Company Categories</a>
+                <div class="submenu">
+                    <ul>
+                    <li><a href="<?php echo url_for('categempresa/index') ?>">Company Categories Index</a></li>
+                    </ul>
+                </div>
+                <a class="menuitem" href="">User Reference</a>
+                <a class="menuitem" href="">Blue button</a>
+                
+                <a class="menuitem_green" href="">Green button</a>
+                
+                <a class="menuitem_red" href="">Red button</a>
+                    
+            </div>
+               </div>
+       
+                <div class="right_content"> 
+
+                       <?php echo $sf_content ?>
+
+                </div>
+      </div>
+       <div class="clear"></div>
+       </div> <!--end of main content-->
+
+       <div class="footer">
+               <div class="left_footer">MOBIE ADS | Powered by <a href="http://uah.es">UAH</a></div>
+       <div class="right_footer"><a href="http://uah.es"><img src="" alt="" title="" border="0" /></a></div>
+    </div>
+</div>
   </body>
 </html>
diff --git a/test/functional/companyfront/officeActionsTest.php b/test/functional/companyfront/officeActionsTest.php
new file mode 100644 (file)
index 0000000..c9bc6fe
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+
+include(dirname(__FILE__).'/../../bootstrap/functional.php');
+
+$browser = new sfTestFunctional(new sfBrowser());
+
+$browser->
+  get('/office/index')->
+
+  with('request')->begin()->
+    isParameter('module', 'office')->
+    isParameter('action', 'index')->
+  end()->
+
+  with('response')->begin()->
+    isStatusCode(200)->
+    checkElement('body', '!/This is a temporary page/')->
+  end()
+;
diff --git a/web/companyfront.php b/web/companyfront.php
new file mode 100644 (file)
index 0000000..55c54b7
--- /dev/null
@@ -0,0 +1,6 @@
+<?php
+
+require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php');
+
+$configuration = ProjectConfiguration::getApplicationConfiguration('companyfront', 'prod', false);
+sfContext::createInstance($configuration)->dispatch();