Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • PHP
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cContentTypePifaForm
  • DefaultFormModule
  • DefaultFormProcessor
  • ExampleOptionsDatasource
  • MailedFormProcessor
  • Pifa
  • PifaAbstractFormModule
  • PifaAbstractFormProcessor
  • PifaAjaxHandler
  • PifaExporter
  • PifaExternalOptionsDatasourceInterface
  • PifaField
  • PifaFieldCollection
  • PifaForm
  • PifaFormCollection
  • PifaImporter
  • PifaLeftBottomPage
  • PifaRightBottomFormDataPage
  • PifaRightBottomFormExportPage
  • PifaRightBottomFormFieldsPage
  • PifaRightBottomFormImportPage
  • PifaRightBottomFormPage

Exceptions

  • PifaDatabaseException
  • PifaException
  • PifaIllegalStateException
  • PifaMailException
  • PifaNotImplementedException
  • PifaNotYetStoredException
  • PifaValidationException
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
   1: <?php
   2: 
   3: /**
   4:  *
   5:  * @package Plugin
   6:  * @subpackage FormAssistant
   7:  * @author Marcus Gnaß <marcus.gnass@4fb.de>
   8:  * @copyright four for business AG
   9:  * @link http://www.4fb.de
  10:  */
  11: 
  12: // assert CONTENIDO framework
  13: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
  14: 
  15: /**
  16:  * Page to be displayed in the left bottom frame.
  17:  * It provides a navigation for all forms defined for the current client and the
  18:  * current language.
  19:  *
  20:  * @author Marcus Gnaß <marcus.gnass@4fb.de>
  21:  */
  22: class PifaLeftBottomPage extends cGuiPage {
  23: 
  24:     /**
  25:      * id of the PIFA content type
  26:      *
  27:      * @var int
  28:      */
  29:     protected $typeId;
  30: 
  31:     /**
  32:      * Create an instance.
  33:      */
  34:     public function __construct() {
  35: 
  36:         /**
  37:          *
  38:          * @param string $action to be performed
  39:          */
  40:         global $action;
  41: 
  42:         /**
  43:          *
  44:          * @param int $idform id of form to be edited
  45:          */
  46:         global $idform;
  47: 
  48:         parent::__construct('left_bottom', Pifa::getName());
  49: 
  50:         // get the id of the content type
  51:         $typeCollection = new cApiTypeCollection();
  52:         $typeCollection->select('type = "CMS_PIFAFORM"');
  53:         $type = $typeCollection->next();
  54:         $this->typeId = $type->get('idtype');
  55: 
  56:         $this->addScript('form_assistant.js');
  57:         $this->addScript('left_bottom.js');
  58: 
  59:         $this->set('s', 'dialog_title', Pifa::i18n('INUSE_DIALOG_TITLE'));
  60:         $this->set('s', 'menu', $this->_getMenu());
  61: 
  62:         // add translations to template
  63:         $this->set('s', 'I18N', json_encode(array(
  64:             'confirm_delete_form' => Pifa::i18n('CONFIRM_DELETE_FORM')
  65:         )));
  66:     }
  67: 
  68:     /**
  69:      * Get menu with all forms of current client in current language.
  70:      */
  71:     private function _getMenu() {
  72:         global $area;
  73: 
  74:         $cfg = cRegistry::getConfig();
  75:         $client = cRegistry::getClientId();
  76:         $lang = cRegistry::getLanguageId();
  77: 
  78:         // get all forms of current client in current language
  79:         $forms = PifaFormCollection::getByClientAndLang($client, $lang);
  80:         if (false === $forms) {
  81:             return '<!-- no forms for current client/language -->';
  82:         }
  83: 
  84:         // $formIcon = Pifa::getUrl() . 'images/icon_form.png';
  85: 
  86:         // collect usage information from the content table
  87:         $contentCollection = new cApiContentCollection();
  88:         // select all entries about the pifa content type
  89:         $formContent = $contentCollection->getFieldsByWhereClause(array(
  90:             'idartlang',
  91:             'value'
  92:         ), 'idtype = "' . $this->typeId . '"');
  93:         // get the idform and the related cApiArticleLanguage object and save them in an array
  94:         $assignedForms = array();
  95:         foreach ($formContent as $formRow) {
  96:             // read settings
  97:             $formRow['value'] = conHtmlEntityDecode($formRow['value']);
  98:             $formRow['value'] = utf8_encode($formRow['value']);
  99:             $settings = cXmlBase::xmlStringToArray($formRow['value']);
 100:             // if it was successful append the array of articles using this form
 101:             if ($settings['idform'] != '') {
 102:                 if (is_array($assignedForms[$settings['idform']])) {
 103:                     $assignedForms[$settings['idform']][] = new cApiArticleLanguage($formRow['idartlang']);
 104:                 } else {
 105:                     $assignedForms[$settings['idform']] = array(
 106:                         new cApiArticleLanguage($formRow['idartlang'])
 107:                     );
 108:                 }
 109:             }
 110:         }
 111: 
 112:         // create menu
 113:         $menu = new cGuiMenu();
 114:         while (false !== $form = $forms->next()) {
 115: 
 116:             $idform = $form->get('idform');
 117:             $formName = $form->get('name');
 118: 
 119:             $menu->setTitle($idform, $formName);
 120: 
 121:             // create link to show/edit the form
 122:             $link = new cHTMLLink();
 123:             $link->setMultiLink($area, '', $area, PifaRightBottomFormPage::SHOW_FORM);
 124:             $link->setCustom('idform', $idform);
 125:             $link->setAttribute('title', 'idform: ' . $idform);
 126:             $menu->setLink($idform, $link);
 127: 
 128:             // if this is true, then the form is in use
 129:             if (isset($assignedForms[$idform])) {
 130:                 // create a link for the action
 131:                 $link = new cHTMLLink();
 132:                 // set the class and the dialog text
 133:                 $link->setClass('in_use_link');
 134:                 $dialogText = Pifa::i18n("FOLLOWING_LIST_USES_FORM") . "<br><br>";
 135:                 foreach($assignedForms[$idform] as $article) {
 136:                     $dialogText .= '<b>' . $article->get('title') . '</b> - (' . $article->get('idart') . ')<br>';
 137:                 }
 138:                 $link->setAttribute("data-dialog-text", $dialogText);
 139:                 $link->setLink('javascript://');
 140: 
 141:                 $image = new cHTMLImage();
 142:                 $image->setSrc($cfg['path']['images'] . 'exclamation.gif');
 143:                 $link->setContent($image->render());
 144: 
 145:                 $menu->setActions($idform, 'inuse', $link);
 146:             }
 147: 
 148:             // create link to delete the form
 149:             if (cRegistry::getPerm()->have_perm_area_action('form', PifaRightBottomFormPage::DELETE_FORM)) {
 150:                 $link = new cHTMLLink();
 151:                 $link->setMultiLink($area, PifaRightBottomFormPage::DELETE_FORM, $area, PifaRightBottomFormPage::DELETE_FORM);
 152:                 $link->setCustom('idform', $idform);
 153:                 $link->setClass('pifa-icon-delete-form');
 154:                 $deleteForm = Pifa::i18n('DELETE_FORM');
 155:                 $link->setAlt($deleteForm);
 156:                 $link->setContent('<img src="' . $cfg['path']['images'] . 'delete.gif" title="' . $deleteForm . '" alt="' . $deleteForm . '">');
 157:                 // $menu->setLink($idform, $link);
 158:                 $menu->setActions($idform, 'delete', $link);
 159:             } else {
 160:                 $menu->setActions($idform, 'delete', '<img src="' . $cfg['path']['images'] . 'delete_inact.gif" title="' . $deleteForm . '" alt="' . $deleteForm . '">');
 161:             }
 162:         }
 163: 
 164:         return $menu->render(false);
 165:     }
 166: 
 167: }
 168: 
 169: /**
 170:  * Page for area "form" to be displayed in the right bottom frame.
 171:  *
 172:  * @author Marcus Gnaß <marcus.gnass@4fb.de>
 173:  */
 174: class PifaRightBottomFormPage extends cGuiPage {
 175: 
 176:     /**
 177:      * Action constant.
 178:      *
 179:      * @var string
 180:      */
 181:     const SHOW_FORM = 'pifa_show_form';
 182: 
 183:     /**
 184:      * Action constant.
 185:      *
 186:      * @var string
 187:      */
 188:     const STORE_FORM = 'pifa_store_form';
 189: 
 190:     /**
 191:      * Action constant.
 192:      *
 193:      * @var string
 194:      */
 195:     const DELETE_FORM = 'pifa_delete_form';
 196: 
 197:     /**
 198:      * model for a single PIFA form
 199:      *
 200:      * @var PifaForm
 201:      */
 202:     private $_pifaForm = NULL;
 203: 
 204:     /**
 205:      * Creates and aggregates a model for a collection of PIFA forms
 206:      * and another for a single PIFA form.
 207:      *
 208:      * If an ID for an item is given this is loaded from database
 209:      * and its values are stored in the appropriate model.
 210:      *
 211:      * @throws PifaException if form could not be loaded
 212:      */
 213:     public function __construct() {
 214: 
 215:         /**
 216:          *
 217:          * @param string $action to be performed
 218:          */
 219:         global $action;
 220: 
 221:         /**
 222:          *
 223:          * @param int $idform id of form to be edited
 224:          */
 225:         global $idform;
 226: 
 227:         /**
 228:          *
 229:          * @param int $idfield id of field to be edited
 230:          */
 231:         global $idfield;
 232: 
 233:         parent::__construct('right_bottom', Pifa::getName());
 234: 
 235:         $this->addStyle('smoothness/jquery-ui-1.8.20.custom.css');
 236:         $this->addStyle('right_bottom.css');
 237:         $this->addScript('form_assistant.js');
 238:         $this->addScript('right_bottom.js');
 239: 
 240:         // create models
 241:         $this->_pifaForm = new PifaForm();
 242: 
 243:         // load models
 244:         $idform = cSecurity::toInteger($idform);
 245:         if (0 < $idform) {
 246:             if (false === $this->_pifaForm->loadByPrimaryKey($idform)) {
 247:                 $msg = Pifa::i18n('FORM_LOAD_ERROR');
 248:                 throw new PifaException($msg);
 249:             }
 250:         }
 251: 
 252:         // add translations to template
 253:         $this->set('s', 'I18N', json_encode(array(
 254:             'cancel' => Pifa::i18n('CANCEL'),
 255:             'save' => Pifa::i18n('SAVE')
 256:         )));
 257: 
 258:         // dispatch action
 259:         try {
 260:             $this->_dispatch($action);
 261:         } catch (PifaException $e) {
 262:             $cGuiNotification = new cGuiNotification();
 263:             $notification = $cGuiNotification->returnNotification(cGuiNotification::LEVEL_ERROR, $e->getMessage());
 264:             $this->set('s', 'notification', $notification);
 265:             $this->set('s', 'content', '');
 266:         }
 267:     }
 268: 
 269:     /**
 270:      * Dispatches the given action.
 271:      *
 272:      * @param string $action to be executed
 273:      * @param string $notification
 274:      * @throws PifaException if the given action is unknown
 275:      * @throws PifaIllegalStateException if permissions are missing
 276:      */
 277:     protected function _dispatch($action, $notification = '') {
 278:         global $area;
 279: 
 280:         // check for permission
 281:         if (!cRegistry::getPerm()->have_perm_area_action($area, $action)) {
 282:             $msg = Pifa::i18n('NO_PERMISSIONS');
 283:             throw new PifaIllegalStateException($msg);
 284:         }
 285: 
 286:         if (NULL === $action) {
 287:             $cGuiNotification = new cGuiNotification();
 288:             $notification = $cGuiNotification->returnNotification(cGuiNotification::LEVEL_INFO, Pifa::i18n('please select a form'));
 289:             $this->set('s', 'notification', $notification);
 290:             $this->set('s', 'content', '');
 291:             return;
 292:         }
 293: 
 294:         // dispatch actions
 295:         switch ($action) {
 296:             case self::SHOW_FORM:
 297:                 $this->set('s', 'notification', $notification);
 298:                 try {
 299:                     $this->set('s', 'content', $this->_showForm());
 300:                 } catch (SmartyCompilerException $e) {
 301:                     $this->set('s', 'content', Pifa::notifyException($e));
 302:                 }
 303:                 break;
 304: 
 305:             case self::STORE_FORM:
 306:                 $notification = '';
 307:                 try {
 308:                     $this->_storeForm();
 309:                     $this->setReload();
 310:                     // reload right_top after saving of form
 311:                     $idform = $this->_pifaForm->get('idform');
 312:                     $url = "main.php?area=form&frame=3&idform=$idform&action=" . PifaRightBottomFormPage::SHOW_FORM;
 313:                     $url = cRegistry::getSession()->url($url);
 314:                     $this->addScript("<script type=\"text/javascript\">
 315:                         Con.getFrame('right_top').location.href = '$url';
 316:                         </script>");
 317:                 } catch (Exception $e) {
 318:                     $notification = Pifa::notifyException($e);
 319:                 }
 320:                 $this->_dispatch(self::SHOW_FORM, $notification);
 321:                 break;
 322: 
 323:             case self::DELETE_FORM:
 324:                 $notification = '';
 325:                 try {
 326:                     $this->_deleteForm();
 327:                     $cGuiNotification = new cGuiNotification();
 328:                     $this->set('s', 'notification', $cGuiNotification->returnNotification(cGuiNotification::LEVEL_OK, Pifa::i18n('FORM_DELETED')));
 329:                     $this->set('s', 'content', '');
 330:                     $this->setReload();
 331:                 } catch (Exception $e) {
 332:                     $notification = Pifa::notifyException($e);
 333:                 }
 334:                 break;
 335: 
 336:             default:
 337:                 $msg = Pifa::i18n('UNKNOWN_ACTION');
 338:                 throw new PifaException($msg);
 339:         }
 340:     }
 341: 
 342:     /**
 343:      * Build and return form for PIFA forms.
 344:      *
 345:      * @return string
 346:      */
 347:     private function _showForm() {
 348:         global $area;
 349: 
 350:         $cfg = cRegistry::getConfig();
 351: 
 352:         // get form action
 353:         $formAction = '';
 354:         if (cRegistry::getPerm()->have_perm_area_action('form', self::STORE_FORM)) {
 355:             $formAction = new cHTMLLink();
 356:             $formAction->setCLink($area, 4, self::STORE_FORM);
 357:             $formAction = $formAction->getHref();
 358:         }
 359: 
 360:         // get current or default values for form
 361:         if (!is_null($this->_pifaForm) && $this->_pifaForm->isLoaded()) {
 362:             $idform = $this->_pifaForm->get('idform');
 363:             $nameValue = $this->_pifaForm->get('name');
 364:             $dataTableValue = $this->_pifaForm->get('data_table');
 365:             $methodValue = $this->_pifaForm->get('method');
 366:             $withTimestampValue = (bool) $this->_pifaForm->get('with_timestamp');
 367:         } else {
 368:             $idform = NULL;
 369: 
 370:             // read item data from form
 371:             $nameValue = empty($_POST['name'])? '' : $_POST['name'];
 372:             $nameValue = cSecurity::unescapeDB($nameValue);
 373:             $nameValue = cSecurity::toString($nameValue);
 374:             $nameValue = trim($nameValue);
 375: 
 376:             $dataTableValue = empty($_POST['data_table'])? '' : $_POST['data_table'];
 377:             $dataTableValue = trim($dataTableValue);
 378:             $dataTableValue = cString::toLowerCase($dataTableValue);
 379:             $dataTableValue = preg_replace('/[^a-z0-9_]/', '_', $dataTableValue);
 380: 
 381:             $methodValue = '';
 382:             $withTimestampValue = true;
 383:         }
 384: 
 385:         $tpl = cSmartyBackend::getInstance(true);
 386:         $tpl->assign('formAction', $formAction);
 387:         $tpl->assign('idform', $idform);
 388:         $tpl->assign('nameValue', $nameValue);
 389:         $tpl->assign('dataTableValue', $dataTableValue);
 390:         $tpl->assign('methodValue', cString::toUpperCase($methodValue));
 391:         $tpl->assign('withTimestampValue', $withTimestampValue);
 392:         $tpl->assign('hasWithTimestamp', Pifa::TIMESTAMP_BYFORM === Pifa::getTimestampSetting());
 393:         $tpl->assign('trans', array(
 394:             'legend' => Pifa::i18n('form'),
 395:             'name' => Pifa::i18n('form name'),
 396:             'dataTable' => Pifa::i18n('data table'),
 397:             'method' => Pifa::i18n('method'),
 398:             'withTimestamp' => Pifa::i18n('with timestamp'),
 399:             'pleaseChoose' => Pifa::i18n('please choose'),
 400:             'saveForm' => Pifa::i18n('save form')
 401:         ));
 402: 
 403:         $out = $tpl->fetch($cfg['templates']['pifa_right_bottom_form']);
 404: 
 405:         return $out;
 406:     }
 407: 
 408:     /**
 409:      * Handles a POST request of the first form, showing a forms details.
 410:      *
 411:      * @throws PifaException
 412:      */
 413:     private function _storeForm() {
 414: 
 415:         // determine if item is loaded
 416:         $isLoaded = $this->_pifaForm->isLoaded();
 417: 
 418:         // read item data from form
 419:         $name = $_POST['name'];
 420:         $name = cSecurity::unescapeDB($name);
 421:         $name = cSecurity::toString($name);
 422:         $name = trim($name);
 423: 
 424:         $dataTable = $_POST['data_table'];
 425:         $dataTable = trim($dataTable);
 426:         $dataTable = cString::toLowerCase($dataTable);
 427:         $dataTable = preg_replace('/[^a-z0-9_]/', '_', $dataTable);
 428: 
 429:         $method = $_POST['method'];
 430:         $method = trim($method);
 431:         $method = cString::toUpperCase($method);
 432: 
 433:         switch (Pifa::getTimestampSetting()) {
 434:             case Pifa::TIMESTAMP_NEVER:
 435:                 $withTimestamp = false;
 436:                 break;
 437:             case Pifa::TIMESTAMP_BYFORM:
 438:                 $withTimestamp = 'on' === $_POST['with_timestamp'];
 439:                 break;
 440:             case Pifa::TIMESTAMP_ALWAYS:
 441:                 $withTimestamp = true;
 442:                 break;
 443:         }
 444: 
 445:         // validate item data
 446:         if (0 === cString::getStringLength($name)) {
 447:             $msg = Pifa::i18n('EMPTY_FORMNAME_ERROR');
 448:             throw new PifaException($msg);
 449:         }
 450:         if (0 === cString::getStringLength($dataTable)) {
 451:             $msg = Pifa::i18n('EMPTY_DATETABLENAME_ERROR');
 452:             throw new PifaException($msg);
 453:         }
 454:         if (!in_array($method, array(
 455:             'GET',
 456:             'POST'
 457:         ))) {
 458:             $msg = Pifa::i18n('FORM_METHOD_ERROR');
 459:             throw new PifaException($msg);
 460:         }
 461: 
 462:         if ($isLoaded) {
 463:             // remember old table values
 464:             $oldDataTable = $this->_pifaForm->get('data_table');
 465:             $oldWithTimestamp = (bool) $this->_pifaForm->get('with_timestamp');
 466:         } else {
 467:             // create new item for given client & language
 468:             $pifaFormCollection = new PifaFormCollection();
 469:             $this->_pifaForm = $pifaFormCollection->createNewItem(array(
 470:                 'idclient' => cRegistry::getClientId(),
 471:                 'idlang' => cRegistry::getLanguageId()
 472:             ));
 473:         }
 474: 
 475:         // set item data
 476:         // Never, really never, call Item->set() if the value doesn't differ
 477:         // from the previous one. Otherwise the genericDb thinks that the item
 478:         // is modified and tries to store it resulting in a return value of
 479:         // false!
 480:         if ($name !== $this->_pifaForm->get('name')) {
 481:             $this->_pifaForm->set('name', $name);
 482:         }
 483:         if ($dataTable !== $this->_pifaForm->get('data_table')) {
 484:             $this->_pifaForm->set('data_table', $dataTable);
 485:         }
 486:         if (0 !== strcasecmp($method, $this->_pifaForm->get('method'))) {
 487:             $this->_pifaForm->set('method', $method);
 488:         }
 489:         if ($withTimestamp !== (bool) $this->_pifaForm->get('with_timestamp')) {
 490:             $this->_pifaForm->set('with_timestamp', $withTimestamp);
 491:         }
 492: 
 493:         if ($isLoaded) {
 494:             // optionally alter data table
 495:             // HINT: passing the old values is correct!
 496:             // The new values have already been stored inside the pifaForm
 497:             // object!
 498:             $this->_pifaForm->alterTable($oldDataTable, $oldWithTimestamp);
 499:         } else {
 500:             // create table
 501:             $this->_pifaForm->createTable($withTimestamp);
 502:         }
 503: 
 504:         // store item
 505:         if (false === $this->_pifaForm->store()) {
 506:             $msg = Pifa::i18n('FORM_STORE_ERROR');
 507:             $msg = sprintf($msg, $this->_pifaForm->getLastError());
 508:             throw new PifaException($msg);
 509:         }
 510:     }
 511: 
 512:     /**
 513:      */
 514:     private function _deleteForm() {
 515:         $this->_pifaForm->delete();
 516:         $this->_pifaForm = NULL;
 517:     }
 518: 
 519: }
 520: 
 521: /**
 522:  * Page for area "form_fields" to be displayed in the right bottom frame.
 523:  *
 524:  * @author Marcus Gnaß <marcus.gnass@4fb.de>
 525:  */
 526: class PifaRightBottomFormFieldsPage extends cGuiPage {
 527: 
 528:     /**
 529:      * Action constant.
 530:      *
 531:      * @var string
 532:      */
 533:     const SHOW_FIELDS = 'pifa_show_fields';
 534: 
 535:     /**
 536:      * model for a single PIFA form
 537:      *
 538:      * @var PifaForm
 539:      */
 540:     private $_pifaForm = NULL;
 541: 
 542:     /**
 543:      * Creates and aggregates a model for a collection of PIFA forms
 544:      * and another for a single PIFA form.
 545:      *
 546:      * If an ID for an item is given this is loaded from database
 547:      * and its values are stored in the appropriate model.
 548:      *
 549:      * @throws PifaException if form could not be loaded
 550:      */
 551:     public function __construct() {
 552: 
 553:         /**
 554:          *
 555:          * @param string $action to be performed
 556:          */
 557:         global $action;
 558: 
 559:         /**
 560:          *
 561:          * @param int $idform id of form to be edited
 562:          */
 563:         global $idform;
 564: 
 565:         /**
 566:          *
 567:          * @param int $idfield id of field to be edited
 568:          */
 569:         global $idfield;
 570: 
 571:         parent::__construct('right_bottom', Pifa::getName());
 572: 
 573:         $this->addStyle('smoothness/jquery-ui-1.8.20.custom.css');
 574:         $this->addStyle('right_bottom.css');
 575:         $this->addScript('form_assistant.js');
 576:         $this->addScript('right_bottom.js');
 577: 
 578:         // create models
 579:         $this->_pifaForm = new PifaForm();
 580: 
 581:         // load models
 582:         $idform = cSecurity::toInteger($idform);
 583:         if (0 < $idform) {
 584:             $ret = $this->_pifaForm->loadByPrimaryKey($idform);
 585:             if (false === $ret) {
 586:                 $msg = Pifa::i18n('FORM_LOAD_ERROR');
 587:                 throw new PifaException($msg);
 588:             }
 589:         }
 590: 
 591:         // add translations to template
 592:         $this->set('s', 'I18N', json_encode(array(
 593:             'cancel' => Pifa::i18n('CANCEL'),
 594:             'save' => Pifa::i18n('SAVE'),
 595:             'confirm_delete_field' => Pifa::i18n('CONFIRM_DELETE_FIELD')
 596:         )));
 597: 
 598:         // dispatch action
 599:         try {
 600:             $this->_dispatch($action);
 601:         } catch (PifaException $e) {
 602:             $cGuiNotification = new cGuiNotification();
 603:             $notification = $cGuiNotification->returnNotification(cGuiNotification::LEVEL_ERROR, $e->getMessage());
 604:             $this->set('s', 'notification', $notification);
 605:             $this->set('s', 'content', '');
 606:         }
 607:     }
 608: 
 609:     /**
 610:      * Dispatches the given action.
 611:      *
 612:      * @param string $action to be executed
 613:      * @param string $notification
 614:      * @throws PifaException if the given action is unknown
 615:      * @throws PifaIllegalStateException if permissions are missing
 616:      */
 617:     protected function _dispatch($action, $notification = '') {
 618:         global $area;
 619: 
 620:         // check for permission
 621:         if (!cRegistry::getPerm()->have_perm_area_action($area, $action)) {
 622:             $msg = Pifa::i18n('NO_PERMISSIONS');
 623:             throw new PifaIllegalStateException($msg);
 624:         }
 625: 
 626:         if (NULL === $action) {
 627:             $this->set('s', 'notification', Pifa::i18n('please select a form'));
 628:             $this->set('s', 'content', '');
 629:             return;
 630:         }
 631: 
 632:         // dispatch actions
 633:         switch ($action) {
 634: 
 635:             case self::SHOW_FIELDS:
 636:                 $this->set('s', 'notification', $notification);
 637:                 try {
 638:                     $this->set('s', 'content', $this->_showFields());
 639:                 } catch (SmartyCompilerException $e) {
 640:                     $this->set('s', 'content', Pifa::notifyException($e));
 641:                 }
 642:                 break;
 643: 
 644:             default:
 645:                 $msg = Pifa::i18n('UNKNOWN_ACTION');
 646:                 throw new PifaException($msg);
 647:         }
 648:     }
 649: 
 650:     /**
 651:      */
 652:     private function _showFields() {
 653:         global $area;
 654: 
 655:         $cfg = cRegistry::getConfig();
 656: 
 657:         $idform = $idfield = NULL;
 658:         $fields = NULL;
 659:         $editField = $deleteField = NULL;
 660:         if ($this->_pifaForm->isLoaded()) {
 661: 
 662:             $idform = $this->_pifaForm->get('idform');
 663:             $idfield = $_GET['idfield'];
 664: 
 665:             $fields = $this->_pifaForm->getFields();
 666: 
 667:             if (cRegistry::getPerm()->have_perm_area_action('form_ajax', PifaAjaxHandler::GET_FIELD_FORM)) {
 668:                 $editField = new cHTMLLink();
 669:                 $editField->setCLink('form_ajax', 4, PifaAjaxHandler::GET_FIELD_FORM);
 670:                 $editField->setCustom('idform', $idform);
 671:                 $editField = $editField->getHref();
 672:             }
 673: 
 674:             if (cRegistry::getPerm()->have_perm_area_action('form_ajax', PifaAjaxHandler::DELETE_FIELD)) {
 675:                 $deleteField = new cHTMLLink();
 676:                 $deleteField->setCLink('form_ajax', 4, PifaAjaxHandler::DELETE_FIELD);
 677:                 $deleteField->setCustom('idform', $idform);
 678:                 $deleteField = $deleteField->getHref();
 679:             }
 680:         }
 681: 
 682:         // get and fill template
 683:         $tpl = cSmartyBackend::getInstance(true);
 684: 
 685:         $columnNames = array();
 686:         $includesCaptcha = false;
 687: 
 688:         foreach ($this->_pifaForm->getFields() as $field) {
 689:             $columnNames[] = $field->get('column_name');
 690:             if ((int) $field->get('field_type') === PifaField::CAPTCHA) {
 691:                 $includesCaptcha = true;
 692:             }
 693:         }
 694: 
 695:         $cGuiNotification = new cGuiNotification();
 696: 
 697:         // check for required email column at this form
 698:         if (!in_array('email', $columnNames)) {
 699:             $email_notification = $cGuiNotification->returnNotification(
 700:                 cGuiNotification::LEVEL_WARNING,
 701:                 Pifa::i18n('Currently there is no field called "email" in this form. Sending mails - if configured - to the user which entered the form data may not work!')
 702:             );
 703:             $tpl->assign('email_notification', $email_notification);
 704:         }
 705: 
 706:         // check for captcha usage
 707:         if ($includesCaptcha && (cString::getStringLength(getEffectiveSetting('pifa-recaptcha', 'sitekey', '')) === 0 || cString::getStringLength(getEffectiveSetting('pifa-recaptcha', 'secret', '')) === 0)) {
 708:             $captcha_notification = $cGuiNotification->returnNotification(
 709:                 cGuiNotification::LEVEL_WARNING,
 710:                 Pifa::i18n('This form is configured with a captcha, but its settings were not defined.') . "<br>" .
 711:                 Pifa::i18n('The captcha will not work until you provide the missing information.') . "<br>" .
 712:                 Pifa::i18n('Please save the "sitekey" and the "secret" in the client settings for the type "pifa-recaptcha". You will get this data from https://www.google.com/recaptcha.')
 713:             );
 714:             $tpl->assign('captcha_notification', $captcha_notification);
 715:         }
 716: 
 717:         // translations
 718:         $tpl->assign('trans', array(
 719:             'legend' => Pifa::i18n('fields'),
 720:             'pleaseSaveFirst' => Pifa::i18n('please save first'),
 721:             'dialogTitle' => Pifa::i18n('edit field'),
 722:             'edit' => Pifa::i18n('EDIT'),
 723:             'delete' => Pifa::i18n('DELETE'),
 724:             'obligatory' => Pifa::i18n('OBLIGATORY')
 725:         ));
 726: 
 727:         // params
 728:         $tpl->assign('ajaxParams', implode('&', array(
 729:             'area=form_ajax',
 730:             'frame=4',
 731:             'contenido=' . cRegistry::getBackendSessionId()
 732:         )));
 733:         if (cRegistry::getPerm()->have_perm_area_action('form_ajax', PifaAjaxHandler::GET_FIELD_FORM)) {
 734:             $tpl->assign('dragParams', implode('&', array(
 735:                 'area=form_ajax',
 736:                 'frame=4',
 737:                 'contenido=' . cRegistry::getBackendSessionId(),
 738:                 'action=' . PifaAjaxHandler::GET_FIELD_FORM,
 739:                 'idform=' . $idform
 740:             )));
 741:         }
 742:         if (cRegistry::getPerm()->have_perm_area_action('form_ajax', PifaAjaxHandler::REORDER_FIELDS)) {
 743:             $tpl->assign('sortParams', implode('&', array(
 744:                 'area=form_ajax',
 745:                 'frame=4',
 746:                 'contenido=' . cRegistry::getBackendSessionId(),
 747:                 'action=' . PifaAjaxHandler::REORDER_FIELDS,
 748:                 'idform=' . $this->_pifaForm->get('idform')
 749:             )));
 750:         }
 751: 
 752:         // data
 753:         $tpl->assign('idform', $idform);
 754:         $tpl->assign('idfield', $idfield);
 755: 
 756:         $tpl->assign('fields', $fields);
 757:         $tpl->assign('fieldTypes', PifaField::getFieldTypeNames());
 758: 
 759:         // for partial
 760:         $tpl->assign('editField', $editField);
 761:         $tpl->assign('deleteField', $deleteField);
 762:         // define path to partial template for displaying a single field row
 763:         $tpl->assign('partialFieldRow', $cfg['templates']['pifa_ajax_field_row']);
 764: 
 765:         $out = $tpl->fetch($cfg['templates']['pifa_right_bottom_fields']);
 766: 
 767:         return $out;
 768:     }
 769: 
 770: }
 771: 
 772: /**
 773:  * Page for area "form_data" to be displayed in the right bottom frame.
 774:  *
 775:  * @author Marcus Gnaß <marcus.gnass@4fb.de>
 776:  */
 777: class PifaRightBottomFormDataPage extends cGuiPage {
 778: 
 779:     /**
 780:      * Action constant.
 781:      *
 782:      * @var string
 783:      */
 784:     const SHOW_DATA = 'pifa_show_data';
 785: 
 786:     /**
 787:      * model for a single PIFA form
 788:      *
 789:      * @var PifaForm
 790:      */
 791:     private $_pifaForm = NULL;
 792: 
 793:     /**
 794:      * Creates and aggregates a model for a collection of PIFA forms
 795:      * and another for a single PIFA form.
 796:      *
 797:      * If an ID for an item is given this is loaded from database
 798:      * and its values are stored in the appropriate model.
 799:      *
 800:      * @throws PifaException if form could not be loaded
 801:      */
 802:     public function __construct() {
 803: 
 804:         /**
 805:          *
 806:          * @param string $action to be performed
 807:          */
 808:         global $action;
 809: 
 810:         /**
 811:          *
 812:          * @param int $idform id of form to be edited
 813:          */
 814:         global $idform;
 815: 
 816:         /**
 817:          *
 818:          * @param int $idfield id of field to be edited
 819:          */
 820:         global $idfield;
 821: 
 822:         parent::__construct('right_bottom', Pifa::getName());
 823: 
 824:         $this->addStyle('smoothness/jquery-ui-1.8.20.custom.css');
 825:         $this->addStyle('right_bottom.css');
 826:         $this->addScript('form_assistant.js');
 827:         $this->addScript('right_bottom.js');
 828: 
 829:         // create models
 830:         $this->_pifaForm = new PifaForm();
 831: 
 832:         // load models
 833:         $idform = cSecurity::toInteger($idform);
 834:         if (0 < $idform) {
 835:             if (false === $this->_pifaForm->loadByPrimaryKey($idform)) {
 836:                 $msg = Pifa::i18n('FORM_LOAD_ERROR');
 837:                 throw new PifaException($msg);
 838:             }
 839:         }
 840: 
 841:         // add translations to template
 842:         $this->set('s', 'I18N', json_encode(array(
 843:             'cancel' => Pifa::i18n('CANCEL'),
 844:             'save' => Pifa::i18n('SAVE')
 845:         )));
 846: 
 847:         // dispatch action
 848:         try {
 849:             $this->_dispatch($action);
 850:         } catch (PifaException $e) {
 851:             $cGuiNotification = new cGuiNotification();
 852:             $notification = $cGuiNotification->returnNotification(cGuiNotification::LEVEL_ERROR, $e->getMessage());
 853:             $this->set('s', 'notification', $notification);
 854:             $this->set('s', 'content', '');
 855:         }
 856:     }
 857: 
 858:     /**
 859:      * Dispatches the given action.
 860:      *
 861:      * @param string $action to be executed
 862:      * @param string $notification
 863:      * @throws PifaException if the given action is unknown
 864:      * @throws PifaIllegalStateException if permissions are missing
 865:      */
 866:     protected function _dispatch($action, $notification = '') {
 867:         global $area;
 868: 
 869:         // check for permission
 870:         if (!cRegistry::getPerm()->have_perm_area_action($area, $action)) {
 871:             $msg = Pifa::i18n('NO_PERMISSIONS');
 872:             throw new PifaIllegalStateException($msg);
 873:         }
 874: 
 875:         if (NULL === $action) {
 876:             $this->set('s', 'notification', Pifa::i18n('please select a form'));
 877:             $this->set('s', 'content', '');
 878:             return;
 879:         }
 880: 
 881:         // dispatch actions
 882:         switch ($action) {
 883: 
 884:             case self::SHOW_DATA:
 885:                 $this->set('s', 'notification', $notification);
 886:                 try {
 887:                     $this->set('s', 'content', $this->_showData());
 888:                 } catch (SmartyCompilerException $e) {
 889:                     $this->set('s', 'content', Pifa::notifyException($e));
 890:                 }
 891:                 break;
 892: 
 893:             default:
 894:                 $msg = Pifa::i18n('UNKNOWN_ACTION');
 895:                 throw new PifaException($msg);
 896:         }
 897:     }
 898: 
 899:     /**
 900:      */
 901:     private function _showData() {
 902:         $cfg = cRegistry::getConfig();
 903: 
 904:         $tpl = cSmartyBackend::getInstance(true);
 905: 
 906:         // translations
 907:         $tpl->assign('trans', array(
 908:             'legend' => Pifa::i18n('data'),
 909:             'nodata' => Pifa::i18n('NODATA'),
 910:             'pleaseSaveFirst' => Pifa::i18n('please save first'),
 911:             'export' => Pifa::i18n('download data as CSV')
 912:         ));
 913: 
 914:         $tpl->assign('form', $this->_pifaForm);
 915:         $tpl->assign('getFileUrl', 'main.php?' . implode('&', array(
 916:             'area=form_ajax',
 917:             'frame=4',
 918:             'contenido=' . cRegistry::getBackendSessionId(),
 919:             'action=' . PifaAjaxHandler::GET_FILE
 920:         )));
 921: 
 922:         try {
 923:             $tpl->assign('fields', $this->_pifaForm->getFields());
 924:         } catch (Exception $e) {
 925:             $tpl->assign('fields', Pifa::notifyException($e));
 926:         }
 927: 
 928:         $tpl->assign('withTimestamp', (bool) $this->_pifaForm->get('with_timestamp'));
 929: 
 930:         try {
 931:             $data = $this->_pifaForm->getData();
 932:             $tpl->assign('data', $data);
 933:             if (!empty($data) && cRegistry::getPerm()->have_perm_area_action('form_ajax', PifaAjaxHandler::EXPORT_DATA)) {
 934:                 $tpl->assign('exportUrl', 'main.php?' . implode('&', array(
 935:                     'area=form_ajax',
 936:                     'frame=4',
 937:                     'contenido=' . cRegistry::getBackendSessionId(),
 938:                     'action=' . PifaAjaxHandler::EXPORT_DATA,
 939:                     'idform=' . $this->_pifaForm->get('idform')
 940:                 )));
 941:             }
 942:         } catch (Exception $e) {
 943:             $tpl->assign('data', Pifa::notifyException($e));
 944:         }
 945: 
 946:         $out = $tpl->fetch($cfg['templates']['pifa_right_bottom_data']);
 947: 
 948:         return $out;
 949:     }
 950: 
 951: }
 952: 
 953: /**
 954:  * Page for area "form_export" to be displayed in the right bottom frame.
 955:  * This page allows for exporting a form as XML.
 956:  *
 957:  * @author Marcus Gnaß <marcus.gnass@4fb.de>
 958:  */
 959: class PifaRightBottomFormExportPage extends cGuiPage {
 960: 
 961:     /**
 962:      * Action constant.
 963:      *
 964:      * @var string
 965:      */
 966:     const EXPORT_FORM = 'pifa_export_form';
 967: 
 968:     /**
 969:      * model for a single PIFA form
 970:      *
 971:      * @var PifaForm
 972:      */
 973:     private $_pifaForm = NULL;
 974: 
 975:     /**
 976:      * Creates and aggregates a model for a single PIFA form.
 977:      *
 978:      * If an ID for an item is given this is loaded from database
 979:      * and its values are stored in the appropriate model.
 980:      *
 981:      * @throws PifaException if form could not be loaded
 982:      */
 983:     public function __construct() {
 984: 
 985:         /**
 986:          *
 987:          * @param string $action to be performed
 988:          */
 989:         global $action;
 990: 
 991:         /**
 992:          *
 993:          * @param int $idform id of form to be edited
 994:          */
 995:         global $idform;
 996: 
 997:         parent::__construct('right_bottom', Pifa::getName());
 998: 
 999:         $this->addStyle('smoothness/jquery-ui-1.8.20.custom.css');
1000:         $this->addStyle('right_bottom.css');
1001:         $this->addScript('form_assistant.js');
1002:         $this->addScript('right_bottom.js');
1003: 
1004:         // add translations to template
1005:         $this->set('s', 'I18N', json_encode(array(
1006:             'cancel' => Pifa::i18n('CANCEL'),
1007:             'save' => Pifa::i18n('SAVE')
1008:         )));
1009: 
1010:         // create models
1011:         $this->_pifaForm = new PifaForm();
1012: 
1013:         // load models
1014:         $idform = cSecurity::toInteger($idform);
1015:         if (0 < $idform) {
1016:             if (false === $this->_pifaForm->loadByPrimaryKey($idform)) {
1017:                 $msg = Pifa::i18n('FORM_LOAD_ERROR');
1018:                 throw new PifaException($msg);
1019:             }
1020:         }
1021: 
1022:         // dispatch action
1023:         try {
1024:             $this->_dispatch($action);
1025:         } catch (PifaException $e) {
1026:             $cGuiNotification = new cGuiNotification();
1027:             $notification = $cGuiNotification->returnNotification(cGuiNotification::LEVEL_ERROR, $e->getMessage());
1028:             $this->set('s', 'notification', $notification);
1029:             $this->set('s', 'content', '');
1030:         }
1031:     }
1032: 
1033:     /**
1034:      * Dispatches the given action.
1035:      *
1036:      * @param string $action to be executed
1037:      * @param string $notification
1038:      * @throws PifaException if the given action is unknown
1039:      * @throws PifaIllegalStateException if permissions are missing
1040:      */
1041:     protected function _dispatch($action, $notification = '') {
1042: 
1043:         // dispatch actions
1044:         switch ($action) {
1045: 
1046:             case self::EXPORT_FORM:
1047: 
1048:                 // check for permission
1049:                 if (!cRegistry::getPerm()->have_perm_area_action('form_ajax', $action)) {
1050:                     $msg = Pifa::i18n('NO_PERMISSIONS');
1051:                     throw new PifaIllegalStateException($msg);
1052:                 }
1053: 
1054:                 $this->set('s', 'notification', $notification);
1055:                 try {
1056:                     $this->set('s', 'content', $this->_exportForm());
1057:                 } catch (SmartyCompilerException $e) {
1058:                     $this->set('s', 'content', Pifa::notifyException($e));
1059:                 }
1060:                 break;
1061: 
1062:             default:
1063:                 $msg = Pifa::i18n('UNKNOWN_ACTION');
1064:                 throw new PifaException($msg);
1065:         }
1066:     }
1067: 
1068:     /**
1069:      */
1070:     private function _exportForm() {
1071:         $cfg = cRegistry::getConfig();
1072: 
1073:         $tpl = cSmartyBackend::getInstance(true);
1074: 
1075:         // translations
1076:         $tpl->assign('trans', array(
1077:             'legend' => Pifa::i18n('pifa_export_form'),
1078:             'withData' => Pifa::i18n('WITH_DATA'),
1079:             'export' => Pifa::i18n('EXPORT')
1080:         ));
1081: 
1082:         $tpl->assign('formAction', 'main.php?' . implode('&', array(
1083:             'area=form_ajax',
1084:             'frame=4',
1085:             'contenido=' . cRegistry::getBackendSessionId(),
1086:             'action=' . PifaAjaxHandler::EXPORT_FORM,
1087:             'idform=' . $this->_pifaForm->get('idform')
1088:         )));
1089: 
1090:         $tpl->assign('idform', $this->_pifaForm->get('idform'));
1091: 
1092:         $out = $tpl->fetch($cfg['templates']['pifa_right_bottom_export']);
1093: 
1094:         return $out;
1095:     }
1096: 
1097: }
1098: 
1099: /**
1100:  * Page for area "form_import" to be displayed in the right bottom frame.
1101:  * This page allows for importing a form that is available as XML.
1102:  *
1103:  * @author Marcus Gnaß <marcus.gnass@4fb.de>
1104:  */
1105: class PifaRightBottomFormImportPage extends cGuiPage {
1106: 
1107:     /**
1108:      * Action constant.
1109:      *
1110:      * @var string
1111:      */
1112:     const IMPORT_FORM = 'pifa_import_form';
1113: 
1114:     /**
1115:      * Create an instance.
1116:      * Dispatches the current action and displays a notification.
1117:      */
1118:     public function __construct() {
1119: 
1120:         /**
1121:          *
1122:          * @param string $action to be performed
1123:          */
1124:         global $action;
1125: 
1126:         parent::__construct('right_bottom', Pifa::getName());
1127: 
1128:         $this->addStyle('smoothness/jquery-ui-1.8.20.custom.css');
1129:         $this->addStyle('right_bottom.css');
1130:         $this->addScript('form_assistant.js');
1131:         $this->addScript('right_bottom.js');
1132: 
1133:         // add translations to template
1134:         $this->set('s', 'I18N', json_encode(array(
1135:             'cancel' => Pifa::i18n('CANCEL'),
1136:             'save' => Pifa::i18n('SAVE')
1137:         )));
1138: 
1139:         // dispatch action
1140:         try {
1141:             $this->_dispatch($action);
1142:         } catch (PifaException $e) {
1143:             $cGuiNotification = new cGuiNotification();
1144:             $notification = $cGuiNotification->returnNotification(cGuiNotification::LEVEL_ERROR, $e->getMessage());
1145:             $this->set('s', 'notification', $notification);
1146:             $this->set('s', 'content', '');
1147:         }
1148:     }
1149: 
1150:     /**
1151:      * Dispatches the given action.
1152:      *
1153:      * @param string $action to be executed
1154:      * @param string $notification
1155:      * @throws PifaException if the given action is unknown
1156:      * @throws PifaIllegalStateException if permissions are missing
1157:      */
1158:     protected function _dispatch($action, $notification = '') {
1159:         global $area;
1160: 
1161:         // check for permission
1162:         if (!cRegistry::getPerm()->have_perm_area_action($area, $action)) {
1163:             $msg = Pifa::i18n('NO_PERMISSIONS');
1164:             throw new PifaIllegalStateException($msg);
1165:         }
1166: 
1167:         // dispatch actions
1168:         switch ($action) {
1169: 
1170:             case self::IMPORT_FORM:
1171:                 $this->set('s', 'notification', $notification);
1172:                 try {
1173: 
1174:                     switch (cString::toUpperCase($_SERVER['REQUEST_METHOD'])) {
1175:                         case 'GET':
1176:                             $this->set('s', 'content', $this->_importFormGet());
1177:                             break;
1178: 
1179:                         case 'POST':
1180:                             $this->set('s', 'content', $this->_importFormPost());
1181:                             break;
1182:                     }
1183: 
1184:                     $this->setReload();
1185:                 } catch (SmartyCompilerException $e) {
1186:                     $this->set('s', 'content', Pifa::notifyException($e));
1187:                 }
1188:                 break;
1189: 
1190:             default:
1191:                 $msg = Pifa::i18n('UNKNOWN_ACTION');
1192:                 throw new PifaException($msg);
1193:         }
1194:     }
1195: 
1196:     /**
1197:      * Handles the GET & POST request for the form_import area.
1198:      * On a GET request a form is displayed that allows for uploading an XML
1199:      * export file and an additional checkbox to select if gathered data should
1200:      * be imported too.
1201:      * On a POST request the import of the uploaded file is performed via
1202:      * PifaImporter. Eventually a notification is displayed.
1203:      *
1204:      * @return string
1205:      */
1206:     private function _importFormGet($showTableNameField = false) {
1207:         $cfg = cRegistry::getConfig();
1208: 
1209:         $tpl = cSmartyBackend::getInstance(true);
1210: 
1211:         // translations
1212:         $tpl->assign('trans', array(
1213:             'legend' => Pifa::i18n('pifa_import_form'),
1214:             'xml' => Pifa::i18n('XML'),
1215:             'used_table_name_error' => Pifa::i18n('USED_TABLE_NAME_ERROR'),
1216:             'table_name' => Pifa::i18n('data table'),
1217:             'export' => Pifa::i18n('IMPORT')
1218:         ));
1219: 
1220:         $tpl->assign('formAction', 'main.php?' . implode('&', array(
1221:             'area=form_import',
1222:             'frame=4',
1223:             'contenido=' . cRegistry::getBackendSessionId(),
1224:             'action=' . self::IMPORT_FORM
1225:         )));
1226: 
1227:         $tpl->assign('showTableNameField', $showTableNameField);
1228: 
1229:         $out = $tpl->fetch($cfg['templates']['pifa_right_bottom_import']);
1230: 
1231:         return $out;
1232:     }
1233: 
1234:     /**
1235:      * Handles the GET & POST request for the form_import area.
1236:      * On a GET request a form is displayed that allows for uploading an XML
1237:      * export file and an additional checkbox to select if gathered data should
1238:      * be imported too.
1239:      * On a POST request the import of the uploaded file is performed via
1240:      * PifaImporter. Eventually a notification is displayed.
1241:      *
1242:      * @return string
1243:      */
1244:     private function _importFormPost() {
1245:         $cGuiNotification = new cGuiNotification();
1246: 
1247:         // read XML from file
1248:         $xml = file_get_contents($_FILES['xml']['tmp_name']);
1249:         $tableName = isset($_POST['table_name'])? $_POST['table_name'] : NULL;
1250: 
1251:         // check read operation
1252:         if (false === $xml) {
1253:             $note = Pifa::i18n('READ_XML_ERROR');
1254:             return $cGuiNotification->returnNotification(cGuiNotification::LEVEL_ERROR, $note);
1255:         }
1256: 
1257:         try {
1258: 
1259:             // perform import process
1260:             $pifaImporter = new PifaImporter();
1261:             $pifaImporter->setTableName($tableName);
1262:             $pifaImporter->import($xml);
1263: 
1264:             // display success message
1265:             $note = Pifa::i18n('IMPORT_SUCCESS');
1266:             $out = $cGuiNotification->returnNotification(cGuiNotification::LEVEL_OK, $note);
1267:         } catch (PifaDatabaseException $e) {
1268:             $out = $this->_importFormGet(true);
1269:         }
1270: 
1271:         return $out;
1272:     }
1273: 
1274: }
1275: 
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0