2011-01-23 Google Map の地図を入れた住所録(symfony の CRUD)のサンプル (その3) ================================================================================ Google Map の位置指定をすべてJavaScript側で行います。 ■action.class.php --- forward('admin', 'list'); } public function executeList() { $c = new Criteria(); $c->addAscendingOrderByColumn(AddressPeer::ID); $this->addresss = AddressPeer::doSelect($c); if (count($this->addresss) == 0) { return; } $this->address = $this->addresss[0]; $id = $this->getRequestParameter("id"); if ($id != null) { $this->address = AddressPeer::retrieveByPk($id); } } public function executeShow() { $this->address = AddressPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($this->address); $this->addresss = array($this->address); } public function executeCreate() { $this->address = new Address(); $this->addresss = array(); $this->setTemplate('edit'); } public function executeEdit() { $this->address = AddressPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($this->address); $this->addresss = array($this->address); } public function executeUpdate() { if (!$this->getRequestParameter('id')) { $address = new Address(); } else { $address = AddressPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($address); } $address->setId($this->getRequestParameter('id')); $address->setName($this->getRequestParameter('name')); $address->setAddress($this->getRequestParameter('address')); $address->setEmail($this->getRequestParameter('email')); $address->setComment($this->getRequestParameter('comment')); $address->save(); return $this->redirect('admin/show?id='.$address->getId()); } public function executeDelete() { $address = AddressPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($address); $address->delete(); return $this->redirect('admin/list'); } } --- ■layout.php --- getRaw('sf_content') ?> --- ■listSuccess.php ---

リスト

ID, 名前をクリックすると、詳細が表示されます。

住所をクリックすると、その住所の地図が表示されます。

ID 名前 住所
getId(), 'admin/show?id='.$address->getId()) ?> getName(), 'admin/show?id='.$address->getId()) ?> getAddress() ?>
--- ■editSuccess.php ---
ID: getId() ?>
名前: getName() ?>
住所: getAddress() ?>
Email: getEmail() ?>
コメント: getComment() ?>
登録日: getCreatedAt() ?>

getId()) ?>  getId()) ?> --- ■layout.php --- getRaw('sf_content') ?> --- ■listSuccess.php ---

リスト

ID, 名前をクリックすると、詳細が表示されます。

住所をクリックすると、その住所の地図が表示されます。

ID 名前 住所
getId(), 'admin/show?id='.$address->getId()) ?> getName(), 'admin/show?id='.$address->getId()) ?> getAddress() ?>
--- ■showSuccess.php ---
ID: getId() ?>
名前: getName() ?>
住所: getAddress() ?>
Email: getEmail() ?>
コメント: getComment() ?>
登録日: getCreatedAt() ?>

getId()) ?>  getId()) ?> --- ■editSuccess.php ---
名前: 50, )) ?>
住所: '30x3', )) ?>
Email: '30x3', )) ?>
コメント: '30x3', )) ?>

getId()): ?>  getId(), 'post=true&confirm=Are you sure?') ?>  getId()) ?>   --- 以上