Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Page Agence
- */
- class Agence extends Page
- {
- static $db = array (
- 'Preposition'=>'Text',
- 'Paragraphe1'=>'Text',
- 'Paragraphe2'=>'Text',
- 'Paragraphe3'=>'Text',
- 'Agrement'=>'Text',
- 'InfoBulle'=>'Text',
- 'coox'=>'Int',
- 'cooy'=>'Int'
- );
- static $has_many = array (
- 'Villes'=>'Ville'
- );
- function getCMSFields()
- {
- $fields = parent::getCMSFields();
- // on définit les options du select dans un tableau
- //$agrement = array(
- // 1 => "Société agréée par l'Etat.",
- // 2 => "Société agréée par l'Etat \"au titre de l'agrément qualité\".",
- // );
- // on déclare le select
- $fields->addFieldToTab('Root.Content.Positionner', new NumericField('coox'));
- $fields->addFieldToTab('Root.Content.Positionner', new NumericField('cooy'));
- $fields->addFieldToTab('Root.Content.Positionner',
- new LiteralField(
- $name = "lacarte",
- $content = '
- <script>
- jQuery(document).ready(function(){
- jQuery("#carte").css({cursor: "crosshair"});
- jQuery("#map-container").css({position: "relative"});
- croixx = jQuery("#Form_EditForm_coox").attr("value");
- croixy = jQuery("#Form_EditForm_cooy").attr("value");
- jQuery("#croix").css({position: "absolute", top: croixy+"px", left: croixx+"px"});
- // jQuery("#croix").css({position: "absolute", top: "0px", left: "0px"});
- function findPos(el) {
- var x = y = 0;
- if(el.offsetParent) {
- x = el.offsetLeft;
- y = el.offsetTop;
- while(el = el.offsetParent) {
- x += el.offsetLeft;
- y += el.offsetTop;
- }
- }
- return {"x":x, "y":y};
- }
- mondiv = document.getElementById("carte");
- mondiv.onclick = function(e) {
- var ev = e || window.event;
- var pos = findPos(this);
- var diffx = ev.clientX - pos.x;
- var diffy = ev.clientY - pos.y;
- jQuery("#Form_EditForm_coox").attr("value", diffx);
- jQuery("#Form_EditForm_cooy").attr("value", diffy);
- jQuery("#croix").css({top: diffy+"px", left: diffx+"px"});
- };
- });
- </script>
- <div id="map-container">
- <img id="carte" src="themes/all4home/images/carte.jpg" />
- <img id="croix" src="themes/all4home/images/locate.gif" />
- </div>'));
- $fields->addFieldToTab('Root.Content.Main', new TextField('Preposition'), 'Content');
- $fields->addFieldToTab('Root.Content.Main', new TextareaField('Paragraphe1'), 'Content');
- $fields->addFieldToTab('Root.Content.Main', new TextareaField('Paragraphe2'), 'Content');
- $fields->addFieldToTab('Root.Content.Main', new TextareaField('Paragraphe3'), 'Content');
- $fields->addFieldToTab('Root.Content.Main', new TextField('Agrement','Agrément'), 'Content');
- //$fields->addFieldToTab("Root.Content.Main", new DropdownField('Agrement', 'Agrément', $agrement, $value = 1, $form = null, $emptyOption = "Choisissez votre agrément" ));
- $fields->addFieldToTab('Root.Content.Main', new TextareaField('InfoBulle'), 'Content');
- $tablefield = new HasManyComplexTableField(
- $this,
- 'Villes',
- 'Ville',
- array (
- 'Nom'=>'Nom',
- ),
- 'getCMSFields_forPopup'
- );
- $tablefield->setAddTitle('Une ville');
- $fields->addFieldToTab('Root.Content.Villes', $tablefield);
- return $fields;
- }
- function nbagences() {
- return DataObject::get_one('ReseauListe')->Nombretotal;
- //$nombre = DataObject::get('Agence');
- //return ($nombre ) ? ($nombre ->Count() + 3 - 1) : 0;
- }
- }
- class Agence_Controller extends Page_Controller
- {
- function ListeVille($num = 99)
- {
- $liste=DataObject::get("Ville","MyAgencePageID = $this->ID",null,null,$num);
- return ($liste)?$liste:null;
- }
- public function getCustomSearchContext()
- {
- $fields = $this->scaffoldSearchFields();
- $filters = array (
- 'codepostal'=> new StartsWithFilter('Ville.codepostal'),
- 'Nom'=> new PartialMatchFilter('Ville.Nom')
- );
- return new SearchContext(
- $this->class,
- $fields,
- $filters
- );
- }
- }
- ?>
Add Comment
Please, Sign In to add comment