Ejemplo n.º 1
0
	function edit($option, $tabpane, $pkg, $form, $page, $ids, $newtype)
	{
		global $database;
		$database = JFactory::getDBO();
		$row = new facileFormsElements($database);
		if ($newtype=='')
			$row->load($ids[0]);
		else {
			$row->form = $form;
			$row->page = $page;
			$row->published = 1;
			$row->logging = 1;
			$row->posx = 0;
			$row->posy = 0;
			$row->width = 0;
			$row->height = 0;
			$row->flag1 = 0;
			$row->flag2 = 0;
			$row->script1flag1 = 1;
			$row->script1flag2 = 0;
			$row->script2flag1 = 1;
			$row->script2flag2 = 0;
			$row->script2flag3 = 0;
			$row->script2flag4 = 0;
			$row->script2flag5 = 0;
			$database->setQuery(
				"select max(ordering)+1 from #__facileforms_elements ".
				 "where form=$form and page=$page"
			);
			$row->ordering = $database->loadResult();

			switch ($newtype) {
				case 'Rectangle':
					$row->type      = $newtype;
					$row->logging   = 0;
					$row->posx      = 10;
					$row->posy      = 10;
					$row->width     = 100;
					$row->height    = 50;
					$row->data1     = '1px solid black';    // border
					$row->data2     = '#eeeeee';            // background color
					break;
				case 'Hidden Input':
					$row->type      = $newtype;
					$row->data1     = 'Hiddeninput';
					break;
				case 'Image':
					$row->type      = $newtype;
					$row->logging   = 0;
					$row->posx      = 10;
					$row->posy      = 50;
					$row->data1     = '{ff_images}/pizzashop/margherita.jpg';
					$row->data2     = 'Margherita';
					break;
				case 'Tooltip':
					$row->type      = $newtype;
					$row->logging   = 0;
					$row->posx      = 100;
					$row->posy      = 50;
					$row->flag1     = 0; // 0-tooltip 1-warning 2-custom
					$row->data2     = 'Some <em>hint</em> or <strong>warning</strong> for the user';
					break;
				case 'Checkbox':
					$row->type      = $newtype;
					$row->posx      = 10;
					$row->posy      = 50;
					$row->data1     = 'cb';
					$row->data2     = 'Checkbox';
					break;
				case 'Radio Button':
					$row->type      = $newtype;
					$row->posx      = 10;
					$row->posy      = 50;
					$row->data1     = 'rb';
					$row->data2     = 'Radiobutton';
					break;
				case 'Regular Button':
					$row->type      = $newtype;
					$row->class2    = 'button';
					$row->logging   = 0;
					$row->posx      = 10;
					$row->posy      = 100;
					$row->data2     = 'Regularbutton';
					break;
				case 'Graphic Button':
					$row->type      = $newtype;
					$row->class2    = 'button';
					$row->logging   = 0;
					$row->posx      = 10;
					$row->posy      = 40;
					$row->flag1     = 1; // caption below
					$row->data1     = '{ff_images}/icons/movert_f2.png';
					$row->data2     = 'Next';
					break;
				case 'Icon':
					$row->type      = $newtype;
					$row->logging   = 0;
					$row->posx      = 10;
					$row->posy      = 80;
					$row->flag1     = 1; // caption below
					$row->data1     = '{mossite}/components/com_breezingforms/images/next.png';
					$row->data3     = '{mossite}/components/com_breezingforms/images/next_f2.png';
					$row->data2     = '<font size="2"><strong>Next</strong></font>';
					break;
				case 'Text':
					$row->type      = $newtype;
					$row->class2    = 'inputbox';
					$row->posx      = 10;
					$row->posy      = 10;
					$row->width     = 6;
					$row->height    = 6;
					break;
				case 'File Upload':
					$row->type      = $newtype;
					$row->class2    = 'inputbox';
					$row->posx      = 10;
					$row->posy      = 30;
					$row->width     = 50;
					$row->height    = 2000000;
					$row->data1     = '{ff_uploads}';
					$row->data2     = 'text/*,application/zip';
					break;
				case 'Textarea':
					$row->type      = $newtype;
					$row->class2    = 'inputbox';
					$row->posx      = 10;
					$row->posy      = 20;
					$row->width     = 20;
					$row->height    = 15;
					break;
				case 'Select List':
					$row->type      = $newtype;
					$row->class2    = 'inputbox';
					$row->posx      = 50;
					$row->posy      = 30;
					$row->data1     = 1;
					$row->data2     = "1;Select Color;''\r\n".
									  "0;Red;red\r\n".
									  "0;Green;green\r\n".
									  "0;Blue;blue\r\n";
					break;
				case 'Query List':
					$row->type      = $newtype;
					$row->class2    = 'moduletable';
					$row->posx      = 5;
					$row->posxmode  = 1;
					$row->posy      = 100;
					$row->width     = 90;
					$row->widthmode = 1;
					$row->height    = 15;
					$row->flag1     = 1; // show header
					$row->flag2     = 1; // selection checkboxes
					$row->data1     = "0\n".    // border
									  "0\n".    // cellspacing
									  "0\n".    // cellpadding
									  "\n".     // <tr(header)> class
									  "\n".     // <tr(row1)> class
									  "\n".     // <tr(row2)> class
									  "\n";     // <tr(footer)> class
					break;
				case 'Captcha':
					$row->type      = 'Captcha';
					$row->posx      = 10;
					$row->posy      = 20;
					break;
				default: // assume Static Text/HTML
					$row->type = 'Static Text/HTML';
					$row->logging   = 0;
					$row->posx      = 10;
					$row->posy      = 20;
					$row->data1     = 'The text to display';
					break;
			} // switch
		} // if
		$lists = array();

		$database->setQuery(
			"select id, concat(package,'::',name) as text ".
			"from #__facileforms_scripts ".
			"where published=1 and type='Element Init' ".
			"order by text, id desc"
		);
		$lists['scripts1'] = $database->loadObjectList();
		if ($database->getErrorNum()) {
			echo $database->stderr();
			return false;
		} // if

		$database->setQuery(
			"select id, concat(package,'::',name) as text ".
			"from #__facileforms_scripts ".
			"where published=1 and type='Element Action' ".
			"order by text, id desc"
		);
		$lists['scripts2'] = $database->loadObjectList();
		if ($database->getErrorNum()) {
			echo $database->stderr();
			return false;
		} // if

		$database->setQuery(
			"select id, concat(package,'::',name) as text ".
			"from #__facileforms_scripts ".
			"where published=1 and type='Element Validation' ".
			"order by text, id desc"
		);
		$lists['scripts3'] = $database->loadObjectList();
		if ($database->getErrorNum()) {
			echo $database->stderr();
			return false;
		} // if

		$order = JHTML::_('list.genericordering',
					 "select ordering as value, title as text ".
					   "from #__facileforms_elements ".
					  "where form=$form and page=$page ".
					  "order by ordering"
				 );
		$lists['ordering'] =
			JHTML::_('select.genericlist',
				$order, 'ordering', 'class="inputbox" size="1" style="z-index:1" ',
				'value', 'text', intval($row->ordering)
			);

		HTML_facileFormsElement::edit($option, $tabpane, $pkg, $row, $lists);
	} // edit