| 1 |
<?php |
| 2 |
|
| 3 |
// No direct access |
| 4 |
defined('ABSPATH') or die('No script kiddies please!'); |
| 5 |
|
| 6 |
jimport('joomla.application.component.view'); |
| 7 |
jimport('adapter.acl.access'); |
| 8 |
|
| 9 |
/** |
| 10 |
* VikBooking Shortcode view. |
| 11 |
* @wponly |
| 12 |
* |
| 13 |
* @since 1.0 |
| 14 |
*/ |
| 15 |
class VikBookingViewShortcode extends JView |
| 16 |
{ |
| 17 |
/** |
| 18 |
* @override |
| 19 |
* View display method. |
| 20 |
* |
| 21 |
* @return void |
| 22 |
*/ |
| 23 |
public function display($tpl = null) |
| 24 |
{ |
| 25 |
$app = JFactory::getApplication(); |
| 26 |
$input = $app->input; |
| 27 |
$dbo = JFactory::getDbo(); |
| 28 |
|
| 29 |
$model = $this->getModel(); |
| 30 |
|
| 31 |
$type = $input->getString('type'); |
| 32 |
$return = $input->getBase64('return', ''); |
| 33 |
|
| 34 |
$shortcode = (array) $model->loadFormData(); |
| 35 |
|
| 36 |
JLoader::import('adapter.filesystem.folder'); |
| 37 |
|
| 38 |
// views |
| 39 |
|
| 40 |
$views = array(); |
| 41 |
|
| 42 |
// get all the views that contain a default.xml file |
| 43 |
// [0] : base path |
| 44 |
// [1] : query |
| 45 |
// [2] : true for recursive search |
| 46 |
// [3] : true to return full paths |
| 47 |
$files = JFolder::files(VBO_SITE_PATH . DIRECTORY_SEPARATOR . 'views', 'default.xml', true, true); |
| 48 |
|
| 49 |
foreach ($files as $f) |
| 50 |
{ |
| 51 |
// retrieve the view ID from the path: /views/[ID]/tmpl/default.xml |
| 52 |
if (preg_match("/[\/\\\\]views[\/\\\\](.*?)[\/\\\\]tmpl[\/\\\\]default\.xml$/i", $f, $matches)) |
| 53 |
{ |
| 54 |
$id = $matches[1]; |
| 55 |
// load the XML form |
| 56 |
$form = JForm::getInstance($id, $f); |
| 57 |
// get the view title |
| 58 |
$views[$id] = array( |
| 59 |
'name' => (string) $form->getXml()->layout->attributes()->title, |
| 60 |
'desc' => (string) $form->getXml()->layout->message, |
| 61 |
); |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
$this->shortcode = $shortcode; |
| 66 |
$this->views = $views; |
| 67 |
$this->returnLink = $return; |
| 68 |
$this->form = $form; |
| 69 |
|
| 70 |
$this->shortcodesList = JModel::getInstance('vikbooking', 'shortcodes', 'admin')->all(); |
| 71 |
|
| 72 |
$this->addToolbar($type); |
| 73 |
|
| 74 |
// display parent |
| 75 |
parent::display($tpl); |
| 76 |
} |
| 77 |
|
| 78 |
/** |
| 79 |
* Helper method to setup the toolbar. |
| 80 |
* |
| 81 |
* @return void |
| 82 |
*/ |
| 83 |
public function addToolbar($type) |
| 84 |
{ |
| 85 |
if ($type == 'edit') |
| 86 |
{ |
| 87 |
JToolbarHelper::title(JText::translate('VBOEDITSHORTCDMENUTITLE')); |
| 88 |
} |
| 89 |
else |
| 90 |
{ |
| 91 |
JToolbarHelper::title(JText::translate('VBONEWSHORTCDMENUTITLE')); |
| 92 |
} |
| 93 |
|
| 94 |
JToolbarHelper::apply('shortcode.save'); |
| 95 |
JToolbarHelper::save('shortcode.saveclose'); |
| 96 |
JToolbarHelper::save2new('shortcode.savenew'); |
| 97 |
JToolbarHelper::cancel('shortcodes.cancel'); |
| 98 |
} |
| 99 |
} |
| 100 |
|