protected function setupReportFactory()
 {
     if ($this->reportFactory instanceof I2CE_Swiss_CustomReports_Reports) {
         return $this->reportFactory;
     } else {
         $relConfig = $this->factory->getStorage('/')->traverse('../reports', false, false);
         if (!$relConfig instanceof I2CE_MagicDataNode) {
             I2CE::raiseError("Bad magic data path to reports");
             return false;
         }
         $init_options = array('root_url_postfix' => 'reports', 'root_path' => $relConfig->getPath(false), 'root_type' => 'CustomReports_Reports');
         try {
             $swiss_factory = new I2CE_SwissMagicFactory($this->factory->getPage(), $init_options);
         } catch (Exception $e) {
             I2CE::raiseError("Could not create swissmagic for reports:" . $e->getMessage());
             return false;
         }
         try {
             $swiss_factory->setRootSwiss();
         } catch (Exception $e) {
             I2CE::raiseError("Could not create root swissmagic for reports:" . $e->getMessage());
             return false;
         }
         $this->reportFactory = $swiss_factory;
         return $this->reportFactory;
     }
 }
 protected function action_config()
 {
     $init_options = array('root_path' => '/modules/SVS', 'root_path_create' => true, 'root_url' => 'SVS/config', 'root_type' => 'SVS_Menu');
     try {
         $swiss_factory = new I2CE_SwissMagicFactory($this, $init_options);
     } catch (Exception $e) {
         I2CE::raiseError("Could not create swissmagic for selectable" . $e->getMessage());
         return false;
     }
     try {
         $swiss_factory->setRootSwiss();
     } catch (Exception $e) {
         I2CE::raiseError("Could not create root swissmagic for selectable" . $e->getMessage());
         return false;
     }
     $swiss_path = $this->request_remainder;
     array_shift($swiss_path);
     $action = array_shift($swiss_path);
     if ($action == 'update' && $this->isPost()) {
         if ($swiss_factory->updateValues($this->post())) {
             $this->userMessage("Updated SVS");
             I2CE::raiseError("good update");
         } else {
             I2CE::raiseError("bad update");
             $this->userMessage("Unable To Update SVS");
         }
     }
     $action = 'edit';
     return $swiss_factory->displayValues($this->template->getElementById('siteContent'), $swiss_path, $action);
 }
 public function action()
 {
     parent::action();
     $init_options = array('root_path' => '/modules/forms/storage_options/CSD/remote_services', 'root_path_create' => true, 'root_url' => 'remote_directory_selector', 'root_type' => 'ServiceDirectorySelector');
     try {
         $swiss_factory = new I2CE_SwissMagicFactory($this, $init_options);
     } catch (Exception $e) {
         I2CE::raiseError("Could not create swissmagic for selectable" . $e->getMessage());
         return false;
     }
     try {
         $swiss_factory->setRootSwiss();
     } catch (Exception $e) {
         I2CE::raiseError("Could not create root swissmagic for selectable" . $e->getMessage());
         return false;
     }
     $swiss_path = $this->request_remainder;
     $action = array_shift($swiss_path);
     if ($action == 'update' && $this->isPost()) {
         if ($swiss_factory->updateValues($this->post())) {
             $this->userMessage("Updated Remote Directories");
         } else {
             $this->userMessage("Unable To Update Remote Directories");
         }
         $this->setRedirect('home');
     }
     $action = 'edit';
     return $swiss_factory->displayValues($this->template->getElementById('siteContent'), $swiss_path, $action);
 }
 public function action()
 {
     parent::action();
     // Add js file for displaying printf arguments
     $this->template->addHeaderLink('printf.js');
     $init_options = array('root_path' => '/I2CE/page', 'root_url' => 'PageBuilder', 'root_type' => 'PageBuilder');
     try {
         $swiss_factory = new I2CE_SwissMagicFactory($this, $init_options);
     } catch (Exception $e) {
         I2CE::raiseError("Could not create swissmagic for selectable" . $e->getMessage());
         return false;
     }
     try {
         $swiss_factory->setRootSwiss();
     } catch (Exception $e) {
         I2CE::raiseError("Could not create root swissmagic for selectable" . $e->getMessage());
         return false;
     }
     //grab the action from the request
     $action = array_shift($this->request_remainder);
     $swiss_path = $this->request_remainder;
     if ($action == 'update' && $this->isPost()) {
         if ($this->get('noRedirect')) {
             $redirect = false;
         } else {
             $redirect = true;
         }
         $msgs = array('not_updated' => 'Unable to Update Values', 'updated' => 'Updated Values');
         foreach ($msgs as $k => &$v) {
             I2CE::getConfig()->setIfIsSet($v, "/I2CE/page/text/user_messages/{$k}");
         }
         I2CE::raiseError(print_r($this->post(), true));
         if ($swiss_factory->updateValues($this->post(), $redirect)) {
             $msg = $msgs['updated'];
         } else {
             $msg = $msgs['not_updated'];
         }
         if ($redirect) {
             $this->userMessage($msg, 'notice', true);
             $swiss = $swiss_factory->getSwiss($swiss_path);
             if ($swiss instanceof I2CE_Swiss) {
                 $redirect = $swiss->getURLRoot('edit') . $swiss->getPath() . $swiss->getURLQueryString();
             } else {
                 $redirect = 'PageBuilder';
             }
             $this->setRedirect($redirect);
             return true;
         }
     } else {
         if ($action == 'delete') {
             return $this->actionDelete($init_options['root_path']);
         }
     }
     $action = 'edit';
     return $swiss_factory->displayValues($this->template->getElementById('siteContent'), $swiss_path, $action);
 }
 protected function tryFactory($which)
 {
     if ($this->page == 'view' && $which == "reportViews") {
         $this->template->setAttribute("class", "active", "menuCustomReports", "a[@href='CustomReports/view/reportViews']");
     } else {
         //$this->template->appendFileById( "customReports_nav_menu.html", "ul", "menuCustomReports" );
         $this->template->setAttribute("class", "active", "menuConfigure", "a[@href='configure']");
         $this->template->appendFileById("menu_configure.html", "ul", "menuConfigure");
     }
     $this->template->setAttribute("class", "active", "menuCustomReports", "//li/a[@href='CustomReports/edit/" . $which . "']");
     $factory_actions = array('view', 'edit', 'update');
     $root_types = array('relationships' => 'FormRelationships', 'reports' => 'CustomReports_Reports', 'reportViews' => 'CustomReports_ReportViews');
     if (in_array($this->page, $factory_actions) && array_key_exists($which, $root_types)) {
         $init_options = array('root_url_postfix' => $which, 'root_path' => '/modules/CustomReports/' . $which, 'root_path_create' => true, 'root_type' => $root_types[$which]);
         try {
             $swiss_factory = new I2CE_SwissMagicFactory($this, $init_options);
         } catch (Exception $e) {
             I2CE::raiseError("Could not create swissmagic for {$which}:" . $e->getMessage());
             return false;
         }
         try {
             $swiss_factory->setRootSwiss();
         } catch (Exception $e) {
             I2CE::raiseError("Could not create root swissmagic for {$which}:" . $e->getMessage());
             return false;
         }
         $swiss_path = $this->request_remainder;
         array_shift($swiss_path);
         $action = $this->page;
         if ($action == 'update' && $this->isPost()) {
             if ($this->get('noRedirect')) {
                 $redirect = false;
             } else {
                 $redirect = true;
             }
             $msgs = array('not_updated' => 'Unable to Update Values', 'updated' => 'Updated Values');
             foreach ($msgs as $k => &$v) {
                 I2CE::getConfig()->setIfIsSet($v, "/modules/CustomReports/text/user_messages/{$k}");
             }
             if ($swiss_factory->updateValues($this->post(), $redirect)) {
                 $msg = $msgs['updated'];
             } else {
                 $msg = $msgs['not_updated'];
             }
             if ($redirect) {
                 $this->userMessage($msg, 'notice', true);
                 $swiss = $swiss_factory->getSwiss($swiss_path);
                 if ($swiss instanceof I2CE_Swiss) {
                     $redirect = $swiss->getURLRoot('edit') . $swiss->getPath() . $swiss->getURLQueryString();
                 } else {
                     $redirect = 'CustomReports/edit/' . $which;
                 }
                 $this->setRedirect($redirect);
                 return true;
             }
         }
         if ($action == 'update') {
             $action = 'edit';
         }
         return $swiss_factory->displayValues($this->template->getElementById('siteContent'), $swiss_path, $action);
     }
     return 'not_handled';
     //we did not handle this with the factory
 }
 public function action()
 {
     parent::action();
     $this->template->setAttribute("class", "active", "menuConfigure", "a[@href='configure']");
     $this->template->appendFileById("menu_configure.html", "ul", "menuConfigure");
     $this->template->setAttribute("class", "active", "menuLocaleSelector", "a[@href='localeSelector/edit']");
     if ($this->page == 'userPreferred') {
         return $this->setUserPreferred();
     }
     if (!$this->hasPermission('task(locales_can_edit_site_locales)')) {
         $this->userMessage("You don't have permission to view set the site locale", 'notice');
         $this->setRedirect("./");
         return false;
     }
     if ($this->page == 'sitePreferred') {
         return $this->setSitePreferred();
     }
     $init_options = array('root_path' => '/locales/selectable', 'root_url_postfix' => 'selectable', 'root_path_create' => true, 'root_type' => 'Locales');
     try {
         $swiss_factory = new I2CE_SwissMagicFactory($this, $init_options);
     } catch (Exception $e) {
         I2CE::raiseError("Could not create swissmagic for selectable" . $e->getMessage());
         return false;
     }
     try {
         $swiss_factory->setRootSwiss();
     } catch (Exception $e) {
         I2CE::raiseError("Could not create root swissmagic for selectable" . $e->getMessage());
         return false;
     }
     $swiss_path = $this->request_remainder;
     array_shift($swiss_path);
     $action = $this->page;
     if ($action == 'update' && $this->isPost()) {
         if ($this->get('noRedirect')) {
             $redirect = false;
         } else {
             $redirect = true;
         }
         if ($swiss_factory->updateValues($this->post(), $redirect)) {
             $msg = "Updated Values";
         } else {
             $msg = "Unable to Update Values";
         }
         if ($redirect) {
             $this->userMessage($msg, 'notice', true);
             $swiss = $swiss_factory->getSwiss($swiss_path);
             if ($swiss instanceof I2CE_Swiss) {
                 $redirect = $swiss->getURLRoot('edit') . $swiss->getPath() . $swiss->getURLQueryString();
             } else {
                 $redirect = 'localeSelector/';
             }
             $this->setRedirect($redirect);
             return true;
         }
     }
     if ($action == 'update') {
         $action = 'edit';
     }
     return $swiss_factory->displayValues($this->template->getElementById('siteContent'), $swiss_path, $action);
 }
 protected function action_configure_relationship_definition($swiss_path, $node)
 {
     if ($this->module = 'I2CE') {
         $url_base = $this->page . "/configure/relationship_definition/";
     } else {
         $url_base = $this->module . "/" . $this->page . "/configure/relationship_definition";
     }
     $init_options = array('root_url' => $url_base, 'root_path' => $this->relConfig->getPath(false), 'root_path_create' => false, 'root_type' => 'FormRelationship');
     try {
         $swiss_factory = new I2CE_SwissMagicFactory($this, $init_options);
     } catch (Exception $e) {
         I2CE::raiseError("Could not create swissmagic for relationship_definition:" . $e->getMessage());
         return false;
     }
     try {
         $swiss_factory->setRootSwiss();
     } catch (Exception $e) {
         I2CE::raiseError("Could not create root swissmagic for relationship_definition:" . $e->getMessage());
         return false;
     }
     $action = array_shift($swiss_path);
     if (!$action) {
         $action = 'edit';
     }
     if ($action == 'update' && $this->isPost()) {
         if ($this->get('noRedirect')) {
             $redirect = false;
         } else {
             $redirect = true;
         }
         $msgs = array('not_updated' => 'Unable to Update Values', 'updated' => 'Updated Values');
         foreach ($msgs as $k => &$v) {
             I2CE::getConfig()->setIfIsSet($v, "/modules/CustomReports/text/user_messages/{$k}");
         }
         if ($swiss_factory->updateValues($this->post(), $redirect)) {
             $msg = $msgs['updated'];
         } else {
             $msg = $msgs['not_updated'];
         }
         if ($redirect) {
             $this->userMessage($msg, 'notice', true);
             $swiss = $swiss_factory->getSwiss($swiss_path);
             if ($swiss instanceof I2CE_Swiss) {
                 $redirect = $swiss->getURLRoot('edit') . $swiss->getPath() . $swiss->getURLQueryString();
             } else {
                 $redirect = $url_base;
             }
             $this->setRedirect($redirect);
             return true;
         }
     }
     if ($action == 'update') {
         $action = 'edit';
     }
     return $swiss_factory->displayValues($node, $swiss_path, $action);
 }