function read() { // get variable and assign span with its value $this->ajax->addResult('spanresult', YDPersistent::get('xpto', "Variable doesn't exist")); // return response to client browser return $this->ajax->processResults(); }
function actionCheck() { // Get the original objects YDDebugUtil::dump(YDPersistent::get('simple_string'), 'simple_string'); YDDebugUtil::dump(YDPersistent::get('my_obj'), 'my_obj'); YDDebugUtil::dump(YDPersistent::get('simple_string_encrypted'), 'simple_string_encrypted without password'); YDDebugUtil::dump(YDPersistent::get('my_obj_encypted'), 'my_obj_encypted without password'); YDDebugUtil::dump(YDPersistent::get('simple_string_encrypted', '', 'test'), 'simple_string_encrypted with password'); YDDebugUtil::dump(YDPersistent::get('my_obj_encypted', '', 'test'), 'my_obj_encypted with password'); // Dunp the complete contents YDPersistent::dump(); }
/** * This is the class constructor for the YDRecordSet class. * * @param $records The list of records as an array (as returned by the YDDatabaseDriver::getRecords * function. * @param $page (optional) The page you want to retrieve. If omitted all records will be returned. * @param $pagesize (optional) The maximum number of rows for each page. If a page number is given, the * default will be to return a maximum of 20 rows. If no page number is given, the pagesize * will be the same as the total number of rows in the recordset. * @param $pagevar (optional) The name of the query string variable indicating the page. Defaults to "page" * @param $sizevar (optional) The name of the query string variable indicating the page size. Defaults to * "size" * @param $sortvar (optional) The name of the query string variable indicating the sort feild. Defaults to * "sortfld" * @param $sortdir (optional) The name of the query string variable indicating the direction. Defaults to * "sortdir" */ function YDRecordSet($records, $page = -1, $pagesize = null, $pagevar = 'page', $sizevar = 'size', $sortvar = 'sortfld', $sortdir = 'sortdir') { // Include the YDPersistent library include_once YD_DIR_HOME_CLS . '/YDPersistent.php'; // Define the query string variables $this->pagevar = $pagevar; $this->sizevar = $sizevar; $this->sortvar = $sortvar; $this->sortdir = $sortdir; // The sort field and direction $this->sortfield = null; $this->sortdirection = null; // The complete list of all records $this->records = $records; // Check if persistent sort is allowed or not if (YDConfig::get('YD_DB_ALLOW_PERSISTENT_SORT')) { // Sort the records persistent if (YDPersistent::get($sortvar, '') != '') { // Set the sortfield and direction $this->sortfield = YDPersistent::get($sortvar); // Get the sort direction if (strtoupper(YDPersistent::get($this->sortdir, 'DESC')) == 'DESC') { $this->sortdirection = 'DESC'; } else { $this->sortdirection = 'ASC'; } // Perform the sorting $this->records = $this->sort($this->sortfield, $this->sortdirection); } } else { // Sort the records if (!empty($_GET[$sortvar])) { // Set the sortfield and direction $this->sortfield = $_GET[$sortvar]; // Get the sort direction if (isset($_GET[$this->sortdir]) && $_GET[$this->sortdir] == 'DESC') { $this->sortdirection = 'DESC'; } else { $this->sortdirection = 'ASC'; } // Perform the sorting $this->records = $this->sort($this->sortfield, $this->sortdirection); } } // Convert the page and pagesize to integers $page = is_numeric($page) ? intval($page) : -1; $pagesize = is_numeric($pagesize) ? intval($pagesize) : YDConfig::get('YD_DB_DEFAULTPAGESIZE'); // This original recordset $this->page = $page >= 1 ? $page : 1; $page = $page >= 1 ? $page : -1; if ($page == -1) { $this->pagesize = $pagesize >= 1 ? $pagesize : sizeof($this->records); } else { $this->pagesize = $pagesize >= 1 ? $pagesize : YDConfig::get('YD_DB_DEFAULTPAGESIZE'); } // Keep the original page value $this->pageorig = $this->page; // Set the total of pages and rows $this->setTotalRows(sizeof($this->records), true); // Publish the URL as an object include_once YD_DIR_HOME_CLS . '/YDUrl.php'; $this->url = new YDUrl(YD_SELF_URI); }
/** * This is the class constructor for the YDRecordSet class. * * @param $records The list of records as an array (as returned by the YDDatabaseDriver::getRecords * function. * @param $page (optional) The page you want to retrieve. If omitted all records will be returned. * @param $pagesize (optional) The maximum number of rows for each page. If a page number is given, the * default will be to return a maximum of 20 rows. If no page number is given, the pagesize * will be the same as the total number of rows in the recordset. * @param $pagevar (optional) The name of the query string variable indicating the page. Defaults to "page" * @param $sizevar (optional) The name of the query string variable indicating the page size. Defaults to * "size" * @param $sortvar (optional) The name of the query string variable indicating the sort feild. Defaults to * "sortfld" * @param $sortdir (optional) The name of the query string variable indicating the direction. Defaults to * "sortdir" */ function YDRecordSet($records, $page = -1, $pagesize = null, $pagevar = 'page', $sizevar = 'size', $sortvar = 'sortfld', $sortdir = 'sortdir') { // Include the YDPersistent library include_once YD_DIR_HOME_CLS . '/YDPersistent.php'; // Define the query string variables $this->pagevar = $pagevar; $this->sizevar = $sizevar; $this->sortvar = $sortvar; $this->sortdir = $sortdir; // The sort field and direction $this->sortfield = null; $this->sortdirection = null; // The complete list of all records $this->records = $records; // Check if persistent sort is allowed or not if (YDConfig::get('YD_DB_ALLOW_PERSISTENT_SORT')) { // Sort the records persistent if (YDPersistent::get($sortvar, '') != '') { // Set the sortfield and direction $this->sortfield = YDPersistent::get($sortvar); // Get the sort direction if (strtoupper(YDPersistent::get($this->sortdir, 'DESC')) == 'DESC') { $this->sortdirection = 'DESC'; } else { $this->sortdirection = 'ASC'; } // Perform the sorting $this->records = $this->sort($this->sortfield, $this->sortdirection); } } else { // Sort the records if (!empty($_GET[$sortvar])) { // Set the sortfield and direction $this->sortfield = $_GET[$sortvar]; // Get the sort direction if (isset($_GET[$this->sortdir]) && $_GET[$this->sortdir] == 'DESC') { $this->sortdirection = 'DESC'; } else { $this->sortdirection = 'ASC'; } // Perform the sorting $this->records = $this->sort($this->sortfield, $this->sortdirection); } } // Set page and pagesize $this->setPage($page, $pagesize); // Publish the URL as an object include_once YD_DIR_HOME_CLS . '/YDUrl.php'; $this->url = new YDUrl(YD_SELF_URI); }
/** * This function returns if the installer step is valid. * * @returns True if valid, false otherwise. */ function isValid() { // If we have errors, return false if (sizeof($this->_errors)) { return false; } // If there are no form items, return true if (!$this->_show_form) { return true; } // If form is not valid, return false if (!$this->_form->isValid()) { return false; } // Add the form values to the object $values = $this->getValues(); $fields = YDPersistent::get('YD_INSTALLER_VALUES', array(), 'YD_INSTALLER'); foreach ($values as $field => $value) { if (in_array($field, array_keys($fields))) { $this->setField($field, $value); } } return true; }