/** * Constructor. * * @since 1.0 */ public function __construct() { self::$logger = new Logger('RecordSelectorController'); self::$logger->debug('>>__construct()'); // ensure that the super class constructor is called, indicating the rights group parent::__construct('Public'); self::$logger->debug('<<__construct'); }
/** * constructor to set up the object. * * @param string $visibility The name of the rights group that can access this controller. * * @since 1.0 */ public function __construct($visibility = 'Public') { self::$logger = new Logger('IndexController'); self::$logger->debug('>>__construct()'); // ensure that the super class constructor is called, indicating the rights group parent::__construct($visibility); self::$logger->debug('<<__construct'); }
/** * The constructor. * * @since 1.0 */ public function __construct() { self::$logger = new Logger('LogController'); self::$logger->debug('>>__construct()'); // ensure that the super class constructor is called, indicating the rights group parent::__construct('Admin'); $this->setTitle('Displaying the requested log'); self::$logger->debug('<<__construct'); }
/** * Constructor. * * @since 1.0 */ public function __construct() { self::$logger = new Logger('GenSecureQueryStringController'); self::$logger->debug('>>__construct()'); $config = ConfigProvider::getInstance(); // ensure that the super class constructor is called, indicating the rights group parent::__construct('Admin'); $this->setTitle('Generate Secure Query Strings'); self::$logger->debug('<<__construct'); }
/** * the constructor. * * @since 1.0 */ public function __construct() { self::$logger = new Logger('InstallController'); self::$logger->debug('>>__construct()'); $config = ConfigProvider::getInstance(); parent::__construct('Public'); // set up the title and meta details $this->setTitle('Installing ' . $config->get('app.title')); self::$logger->debug('<<__construct'); }
/** * constructor to set up the object. * * @since 2.0.3 */ public function __construct() { self::$logger = new Logger('PhpinfoController'); self::$logger->debug('>>__construct()'); $config = ConfigProvider::getInstance(); // ensure that the super class constructor is called, indicating the rights group parent::__construct('Admin'); // set up the title and meta details $this->setTitle('Information about the PHP installation'); self::$logger->debug('<<__construct'); }
/** * the constructor. * * @since 1.0 */ public function __construct() { self::$logger = new Logger('ListActiveRecordsController'); self::$logger->debug('>>__construct()'); $config = ConfigProvider::getInstance(); // ensure that the super class constructor is called, indicating the rights group parent::__construct('Admin'); // set up the title and meta details $this->setTitle('Listing all active records in the system'); $this->setDescription('Page to list all active records.'); $this->setKeywords('list,all,active,records'); $viewState = ViewState::getInstance(); $viewState->set('renderAdminMenu', true); self::$logger->debug('<<__construct'); }
/** * Testing the doGET method. */ public function testDoGET() { $config = ConfigProvider::getInstance(); $sessionProvider = $config->get('session.provider.name'); $session = SessionProviderFactory::getInstance($sessionProvider); $front = new FrontController(); $request = new Request(array('method' => 'GET', 'URI' => '/image/' . urlencode($config->get('app.root') . 'public/images/icons/accept.png') . '/16/16/png/0.75/false/false')); $response = $front->process($request); $this->assertEquals(200, $response->getStatus(), 'Testing the doGET method'); $this->assertEquals('image/jpeg', $response->getHeader('Content-Type'), 'Testing the doGET method'); $request = new Request(array('method' => 'GET', 'URI' => '/image/' . urlencode($config->get('app.root') . 'public/images/icons/accept.png') . '/16/16/png/0.75/false/true')); $response = $front->process($request); $this->assertEquals(200, $response->getStatus(), 'Testing the doGET method'); $this->assertEquals('image/jpeg', $response->getHeader('Content-Type'), 'Testing the doGET method with secure image and no tokens'); $tokens = Controller::generateSecurityFields(); $request = new Request(array('method' => 'GET', 'URI' => '/image/' . urlencode($config->get('app.root') . 'public/images/icons/accept.png') . '/16/16/png/0.75/false/true/' . urlencode($tokens[0]) . '/' . urlencode($tokens[1]))); $response = $front->process($request); $this->assertEquals(200, $response->getStatus(), 'Testing the doGET method'); $this->assertEquals('image/jpeg', $response->getHeader('Content-Type'), 'Testing the doGET method with secure image and valid tokens'); }
/** * constructor to set up the object. * * @since 1.0 */ public function __construct() { self::$logger = new Logger('LogoutController'); self::$logger->debug('>>__construct()'); // ensure that the super class constructor is called, indicating the rights group parent::__construct('Public'); $config = ConfigProvider::getInstance(); $sessionProvider = $config->get('session.provider.name'); $session = SessionProviderFactory::getInstance($sessionProvider); if ($session->get('currentUser') !== false) { $this->setRecord($session->get('currentUser')); } else { self::$logger->warn('Logout controller called when no user is logged in'); } // set up the title and meta details $this->setTitle('Logged out successfully.'); $this->setDescription('Logout page.'); $this->setKeywords('Logout,logon'); self::$logger->debug('<<__construct'); }
/** * constructor to set up the object. * * @since 1.0 */ public function __construct() { self::$logger = new Logger('CacheManager'); self::$logger->debug('>>__construct()'); $config = ConfigProvider::getInstance(); // ensure that the super class constructor is called, indicating the rights group parent::__construct('Admin'); $this->setTitle('Cache Manager'); $this->dataDir = $config->get('app.file.store.dir') . 'cache/'; self::$logger->debug('<<__construct'); }
/** * {@inheritdoc} */ public static function renderSecurityFields() { if (self::$logger == null) { self::$logger = new Logger('RendererProviderHTML'); } self::$logger->debug('>>renderSecurityFields()'); $config = ConfigProvider::getInstance(); $html = ''; $fields = Controller::generateSecurityFields(); if ($config->get('security.encrypt.http.fieldnames')) { $fieldname = base64_encode(SecurityUtils::encrypt('var1')); } else { $fieldname = 'var1'; } $html .= '<input type="hidden" name="' . $fieldname . '" value="' . $fields[0] . '"/>'; if ($config->get('security.encrypt.http.fieldnames')) { $fieldname = base64_encode(SecurityUtils::encrypt('var2')); } else { $fieldname = 'var2'; } $html .= '<input type="hidden" name="' . $fieldname . '" value="' . $fields[1] . '"/>'; self::$logger->debug('<<renderSecurityFields [' . $html . ']'); return $html; }
/** * Sets up the pagination start point and limit. * * @since 2.0 */ public function after_displayPageHead_callback() { $body = parent::after_displayPageHead_callback(); // set the start point for the list pagination if ($this->request->getParam('start') != null) { $this->start = $this->request->getParam('start'); $viewState = ViewState::getInstance(); $viewState->set('selectedStart', $this->start); if ($this->request->getParam('limit') != null) { $this->limit = $this->request->getParam('limit'); } else { $config = ConfigProvider::getInstance(); $this->limit = $config->get('app.list.page.amount'); } $accept = $this->request->getAccept(); if ($accept == 'application/json') { $body .= '['; } } return $body; }
/** * Renders the HTML <img> tag to the ViewImage controller, with all of the correct params to render the source * image in the desired resolution. * * @param $altText Set this value to render alternate text as part of the HTML link (defaults to no alternate text) * * @return string * * @since 1.0 */ public function renderHTMLLink($altText = '') { $config = ConfigProvider::getInstance(); if ($this->secure->getBooleanValue()) { $params = Controller::generateSecurityFields(); return '<img src="' . FrontController::generateSecureURL('act=Alpha\\Controller\\ImageController&source=' . $this->source . '&width=' . $this->width->getValue() . '&height=' . $this->height->getValue() . '&type=' . $this->sourceType->getValue() . '&quality=' . $this->quality->getValue() . '&scale=' . $this->scale->getValue() . '&secure=' . $this->secure->getValue() . '&var1=' . $params[0] . '&var2=' . $params[1]) . '"' . (empty($altText) ? '' : ' alt="' . $altText . '"') . ($config->get('cms.images.widget.bootstrap.responsive') ? ' class="img-responsive"' : '') . '/>'; } else { return '<img src="' . FrontController::generateSecureURL('act=Alpha\\Controller\\ImageController&source=' . $this->source . '&width=' . $this->width->getValue() . '&height=' . $this->height->getValue() . '&type=' . $this->sourceType->getValue() . '&quality=' . $this->quality->getValue() . '&scale=' . $this->scale->getValue() . '&secure=' . $this->secure->getValue()) . '"' . (empty($altText) ? '' : ' alt="' . $altText . '"') . ($config->get('cms.images.widget.bootstrap.responsive') ? ' class="img-responsive"' : '') . '/>'; } }
/** * constructor to set up the object. * * @since 1.0 */ public function __construct() { self::$logger = new Logger('LoginController'); self::$logger->debug('>>__construct()'); $config = ConfigProvider::getInstance(); // ensure that the super class constructor is called, indicating the rights group parent::__construct('Public'); $this->personObject = new Person(); $this->personView = View::getInstance($this->personObject); $this->setRecord($this->personObject); // set up the title and meta details $this->setTitle('Login to ' . $config->get('app.title')); $this->setDescription('Login page.'); $this->setKeywords('login,logon'); self::$logger->debug('<<__construct'); }
/** * constructor to set up the object. * * @since 1.0 */ public function __construct() { self::$logger = new Logger('FeedController'); self::$logger->debug('>>__construct()'); $config = ConfigProvider::getInstance(); // ensure that the super class constructor is called, indicating the rights group parent::__construct('Public'); self::$logger->debug('<<__construct'); }
/** * Renders the text boxes and buttons for the widget, that will appear in user forms. * * @param bool $expanded Render the related fields in expanded format or not (optional) * @param bool $buttons Render buttons for expanding/contacting the related fields (optional) * * @return string * * @since 1.0 */ public function render($expanded = false, $buttons = true) { self::$logger->debug('>>render(expanded=[' . $expanded . '], buttons=[' . $buttons . '])'); $config = ConfigProvider::getInstance(); $sessionProvider = $config->get('session.provider.name'); $session = SessionProviderFactory::getInstance($sessionProvider); $fieldname = $config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt($this->name)) : $this->name; $html = ''; // render text-box for many-to-one relations if ($this->relationObject->getRelationType() == 'MANY-TO-ONE') { // value to appear in the text-box $inputBoxValue = $this->relationObject->getRelatedClassDisplayFieldValue(); $html .= '<div class="form-group">'; $html .= '<label for="' . $this->name . '_display">' . $this->label . '</label>'; $html .= '<input type="text" size="70" class="form-control" name="' . $this->name . '_display" id="' . $this->name . '_display" value="' . $inputBoxValue . '" disabled/>'; $js = " if(window.jQuery) {\n window.jQuery.dialog = new BootstrapDialog({\n title: 'Please select',\n message: 'Loading...',\n onshow: function(dialogRef){\n dialogRef.getModalBody().load('" . $config->get('app.url') . "/recordselector/12m/'+document.getElementById('" . $fieldname . "').value+'/" . $this->name . '/' . urlencode($this->relationObject->getRelatedClass()) . '/' . $this->relationObject->getRelatedClassField() . '/' . $this->relationObject->getRelatedClassDisplayField() . "');\n },\n buttons: [\n {\n icon: 'glyphicon glyphicon-remove',\n label: 'Cancel',\n cssClass: 'btn btn-default btn-xs',\n action: function(dialogItself){\n dialogItself.close();\n }\n }\n ]\n });\n window.jQuery.dialog.open();\n }"; $tmp = new Button($js, 'Select', 'relBut', '', 'glyphicon-check'); $html .= '<div class="centered lower">' . $tmp->render() . '</div>'; // hidden field to store the actual value of the relation $html .= '<input type="hidden" name="' . $fieldname . '" id="' . $fieldname . '" value="' . $this->relationObject->getValue() . '"/>'; if ($this->relationObject->getRule() != '') { $html .= '<input type="hidden" id="' . $fieldname . '_msg" value="' . $this->relationObject->getHelper() . '"/>'; $html .= '<input type="hidden" id="' . $fieldname . '_rule" value="' . $this->relationObject->getRule() . '"/>'; } $html .= '</div>'; } // render read-only list for one-to-many relations if ($this->relationObject->getRelationType() == 'ONE-TO-MANY') { $objects = $this->relationObject->getRelatedObjects(); if (count($objects) > 0) { // render tags differently if ($this->name == 'tags' && $this->relationObject->getRelatedClass() == 'TagObject') { $html .= '<p><strong>' . $this->label . ':</strong>'; foreach ($objects as $tag) { $html .= ' <a href="' . $config->get('app.url') . '/search/' . $tag->get('content') . '">' . $tag->get('content') . '</a>'; } $html .= '</p>'; } else { $html .= '<div><strong>' . $this->label . ':</strong>'; if ($buttons) { $html .= '<div class="spread">'; $tmp = new Button("document.getElementById('relation_field_" . $this->name . "').style.display = '';", 'Show', $this->name . 'DisBut', '', 'glyphicon-list'); $html .= $tmp->render(); $tmp = new Button("document.getElementById('relation_field_" . $this->name . "').style.display = 'none';", 'Hide', $this->name . 'HidBut', '', 'glyphicon-minus'); $html .= $tmp->render(); $html .= '</div>'; } $html .= '</div>'; $html .= '<div id="relation_field_' . $this->name . '" style="display:' . ($expanded ? '' : 'none') . ';">'; $customViewControllerName = Controller::getCustomControllerName(get_class($objects[0]), 'view'); $customEditControllerName = Controller::getCustomControllerName(get_class($objects[0]), 'edit'); $request = new Request(array('method' => 'GET')); $URI = $request->getURI(); foreach ($objects as $obj) { // check to see if we are in the admin back-end if (mb_strpos($URI, '/tk/') !== false) { $viewURL = FrontController::generateSecureURL('act=Alpha\\Controller\\ActiveRecordController&ActiveRecordType=' . get_class($obj) . '&ActiveRecordOID=' . $obj->getOID()); $editURL = FrontController::generateSecureURL('act=Alpha\\Controller\\ActiveRecordController&ActiveRecordType=' . get_class($obj) . '&ActiveRecordOID=' . $obj->getOID() . '&view=edit'); } else { if (isset($customViewControllerName)) { if ($config->get('app.use.mod.rewrite')) { $viewURL = $config->get('app.url') . $customViewControllerName . '/oid/' . $obj->getOID(); } else { $viewURL = $config->get('app.url') . 'controller/' . $customViewControllerName . '.php?oid=' . $obj->getOID(); } } else { $viewURL = $config->get('app.url') . 'alpha/controller/Detail.php?bo=' . get_class($obj) . '&oid=' . $obj->getOID(); } if (isset($customEditControllerName)) { if ($config->get('app.use.mod.rewrite')) { $editURL = $config->get('app.url') . $customEditControllerName . '/oid/' . $obj->getOID(); } else { $editURL = $config->get('app.url') . 'controller/' . $customEditControllerName . '.php?oid=' . $obj->getOID(); } } else { $editURL = $config->get('app.url') . 'alpha/controller/Edit.php?bo=' . get_class($obj) . '&oid=' . $obj->getOID(); } } /* * If any display headers were set with setRelatedClassHeaderFields, use them otherwise * use the OID of the related class as the only header. */ $headerFields = $this->relationObject->getRelatedClassHeaderFields(); if (count($headerFields) > 0) { foreach ($headerFields as $field) { $label = $obj->getDataLabel($field); $value = $obj->get($field); if ($field == 'created_by' || $field == 'updated_by') { $person = new PersonObject(); $person->load($value); $value = $person->getDisplayName(); } $html .= '<em>' . $label . ': </em>' . $value . ' '; } // if the related BO has been updated, render the update time if ($obj->getCreateTS() != $obj->getUpdateTS()) { try { $html .= '<em>' . $obj->getDataLabel('updated_ts') . ': </em>' . $obj->get('updated_ts'); } catch (IllegalArguementException $e) { $html .= '<em>Updated: </em>' . $obj->get('updated_ts'); } } } else { $html .= '<em>' . $obj->getDataLabel('OID') . ': </em>' . $obj->get('OID'); } // ensures that line returns are rendered $value = str_replace("\n", '<br>', $obj->get($this->relationObject->getRelatedClassDisplayField())); $html .= '<p>' . $value . '</p>'; $html .= '<div class="centered">'; $html .= '<a href="' . $viewURL . '">View</a>'; // if the current user owns it, they get the edit link if ($session->get('currentUser') != null && $session->get('currentUser')->getOID() == $obj->getCreatorId()) { $html .= ' <a href="' . $editURL . '">Edit</a>'; } $html .= '</div>'; } $html .= '</div>'; } } } // render text-box for many-to-many relations if ($this->relationObject->getRelationType() == 'MANY-TO-MANY') { // value to appear in the text-box $inputBoxValue = $this->relationObject->getRelatedClassDisplayFieldValue($this->accessingClassName); // replace commas with line returns $inputBoxValue = str_replace(',', "\n", $inputBoxValue); $html .= '<div class="form-group">'; $html .= '<label for="' . $this->name . '_display">' . $this->label . '</label>'; $html .= '<textarea id="' . $this->name . '_display" class="form-control" rows="5" readonly>'; $html .= $inputBoxValue; $html .= '</textarea>'; $fieldname1 = $config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt($this->name)) : $this->name; $fieldname2 = $config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt($this->name . '_OID')) : $this->name . '_OID'; $js = "if(window.jQuery) {\n BootstrapDialog.show({\n title: 'Please select',\n message: 'Loading...',\n onshow: function(dialogRef){\n dialogRef.getModalBody().load('" . $config->get('app.url') . "/recordselector/m2m/'+document.getElementById('" . $fieldname2 . "').value+'/" . $this->name . '/' . urlencode($this->relationObject->getRelatedClass('left')) . '/' . $this->relationObject->getRelatedClassDisplayField('left') . '/' . urlencode($this->relationObject->getRelatedClass('right')) . '/' . $this->relationObject->getRelatedClassDisplayField('right') . '/' . urlencode($this->accessingClassName) . "/'+document.getElementById('" . $fieldname1 . "').value);\n },\n buttons: [\n {\n icon: 'glyphicon glyphicon-remove',\n label: 'Cancel',\n cssClass: 'btn btn-default btn-xs',\n action: function(dialogItself){\n dialogItself.close();\n }\n },\n {\n icon: 'glyphicon glyphicon-ok',\n label: 'Okay',\n cssClass: 'btn btn-default btn-xs',\n action: function(dialogItself) {\n setParentFieldValues();\n \$('[id=\\'" . $this->name . "_display\\']').blur();\n dialogItself.close();\n }\n }\n ]\n });\n }"; $tmp = new Button($js, 'Select', 'relBut', '', 'glyphicon-check'); $html .= '<div class="centered lower">' . $tmp->render() . '</div>'; $html .= '</div>'; // hidden field to store the OID of the current BO $html .= '<input type="hidden" name="' . $fieldname2 . '" id="' . $fieldname2 . '" value="' . $this->relationObject->getValue() . '"/>'; // hidden field to store the OIDs of the related BOs on the other side of the rel (this is what we check for when saving) if ($this->relationObject->getSide($this->accessingClassName) == 'left') { $lookupOIDs = $this->relationObject->getLookup()->loadAllFieldValuesByAttribute('leftID', $this->relationObject->getValue(), 'rightID', 'DESC'); } else { $lookupOIDs = $this->relationObject->getLookup()->loadAllFieldValuesByAttribute('rightID', $this->relationObject->getValue(), 'leftID', 'DESC'); } $html .= '<input type="hidden" name="' . $fieldname1 . '" id="' . $fieldname1 . '" value="' . implode(',', $lookupOIDs) . '"/>'; } self::$logger->debug('<<__render [html]'); return $html; }
/** * Displays a search form on the top of the page. * * @return string * * @since 1.0 */ public function after_displayPageHead_callback() { $config = ConfigProvider::getInstance(); $body = parent::after_displayPageHead_callback(); $body .= '<div align="center" class="form-group"><form class="form-inline" method="GET" id="search_form" onsubmit="document.location = \'' . $config->get('app.url') . 'search/\'+document.getElementById(\'q\').value; return false;">'; $body .= '<label for="q">Search for</label><input type="text" name="q" id="q" class="form-control" style="width:50%; margin:10px;"/>'; $button = new Button('document.location = \'' . $config->get('app.url') . '/search/\'+document.getElementById(\'q\').value', 'Search', 'searchButton'); $body .= $button->render(); $body .= '</p></form></div>'; return $body; }
/** * Testing the checkControllerDefExists method with good and bad input. * * @since 1.2.1 */ public function testCheckControllerDefExists() { $this->assertTrue(Controller::checkControllerDefExists('/'), 'Testing that the / controller always exists'); $this->assertTrue(Controller::checkControllerDefExists('ImageController'), 'Testing that a good controller classname returns true'); $this->assertFalse(Controller::checkControllerDefExists('DoesNotExist'), 'Testing that a bad controller classname returns false'); }