本文整理汇总了PHP中B::toBoolean方法的典型用法代码示例。如果您正苦于以下问题:PHP B::toBoolean方法的具体用法?PHP B::toBoolean怎么用?PHP B::toBoolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类B
的用法示例。
在下文中一共展示了B::toBoolean方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderForm
/**
* Will render a specified form, the name of the form given by the first parameter;
*
* This method will render one of the forms for our object, invoked by giving the proper form identifier to the current form.
* We have chosen this method of invoking forms, because we just had too many this->renderSomethingMethod (), which really had
* an impact on code massiveness. Also, having code organized in switch/case statements leads us to be able to share common
* settings between different forms, as we've done with the methods defined in the __CALL method above;
*
* For example, if we wanted to share some common configuration between a create and an edit form, we could have introduced
* two switches in this method, one that would have set the common options, and the second, would have just passed through
* again, and get the already set configuration options, using them. This means that if we needed to change behavior of
* some interconnected forms, that would mean modifying the needed code one place only, which is a big advantage over
* having separated methods for each form. Maybe if we extended this object, you guys could understand the functionality;
*
* @param string $objFormToRender The name of the form to render;
* @return mixed Depends on the rendered form if it returns something or not;
*/
public function renderForm(S $objFormToRender, A $objFormArray = NULL)
{
// Make them defaults ...
if ($objFormArray == NULL) {
$objFormArray = new A();
}
// Do a switch ...
switch ($objFormToRender) {
case 'propertyCreate':
// Set the URL to go back;
$objURLToGoBack = URL::rewriteURL();
// Do some work;
if ($this->checkPOST()->toBoolean() == TRUE) {
if ($this->checkPOST(self::$objProductsPropertyTableFKey)->toBoolean() == FALSE) {
$this->setErrorOnInput(self::$objProductsPropertyTableFKey, new S(PRODUCTS_PROPERTY_CANNOT_BE_EMPTY));
}
if ($this->checkPOST(self::$objProductsPropertyTableFVar)->toBoolean() == FALSE) {
$this->setErrorOnInput(self::$objProductsPropertyTableFVar, new S(PRODUCTS_VALUE_CANNOT_BE_EMPTY));
}
}
// Do the form, make it happen;
$this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(PRODUCTS_ADD_PROPERTY))->setSQLAction(new S('update'))->setTableName(self::$objProductsPropertyTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objProductsPropertyTableFId)->setExtraUpdateData(self::$objProductsPropertyTableFPId, $_GET[ADMIN_ACTION_ID])->setName($objFormToRender)->setRedirect($objURLToGoBack)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setValue(new S(PRODUCTS_ADD_PROPERTY))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objProductsPropertyTableFKey)->setLabel(new S(PRODUCTS_PROPERTY))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objProductsPropertyTableFVar)->setLabel(new S(PRODUCTS_VALUE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE));
break;
case 'propertyEdit':
// Set the URL to go back;
$objURLToGoBack = URL::rewriteURL(new A(array(PRODUCTS_ACTION_PROPERTY, PRODUCTS_ID_PROPERTY)));
// Do some work;
if ($this->checkPOST()->toBoolean() == TRUE) {
if ($this->checkPOST(self::$objProductsPropertyTableFKey)->toBoolean() == FALSE) {
$this->setErrorOnInput(self::$objProductsPropertyTableFKey, new S(PRODUCTS_PROPERTY_CANNOT_BE_EMPTY));
}
if ($this->checkPOST(self::$objProductsPropertyTableFVar)->toBoolean() == FALSE) {
$this->setErrorOnInput(self::$objProductsPropertyTableFVar, new S(PRODUCTS_VALUE_CANNOT_BE_EMPTY));
}
}
$this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(PRODUCTS_EDIT_PROPERTY))->setSQLAction(new S('update'))->setTableName(self::$objProductsPropertyTable)->setUpdateId($_GET[PRODUCTS_ID_PROPERTY])->setUpdateField(self::$objProductsPropertyTableFId)->setName($objFormToRender)->setRedirect($objURLToGoBack)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setValue(new S(PRODUCTS_EDIT_PROPERTY))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objProductsPropertyTableFKey)->setLabel(new S(PRODUCTS_PROPERTY))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objProductsPropertyTableFVar)->setLabel(new S(PRODUCTS_VALUE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE));
break;
case 'propertyErase':
// Set the URL to go back too;
$objURLToGoBack = URL::rewriteURL(new A(array(PRODUCTS_ACTION_PROPERTY, PRODUCTS_ID_PROPERTY)));
// Do erase it ...
$this->_Q(_QS('doDELETE')->doToken('%table', self::$objProductsPropertyTable)->doToken('%condition', new S('%objProductsPropertyTableFId = "%Id"'))->doToken('%Id', $_GET[PRODUCTS_ID_PROPERTY]));
// Do a redirect, and get the user back where he belongs;
$this->setHeaderKey($objURLToGoBack, new S('Location'));
break;
case 'imageCreate':
// Set the URL to go back too;
$objURLToGoBack = URL::rewriteURL();
// Do some work;
if ($this->checkPOST(self::$objProductsIMGTableFTitle)->toBoolean() == TRUE) {
if ($this->getPOST(self::$objProductsIMGTableFTitle)->toLength()->toInt() == 0) {
$this->setErrorOnInput(self::$objProductsIMGTableFTitle, new S(PRODUCTS_IMAGE_TITLE_CANNOT_BE_EMPTY));
}
}
// Do the form, make it happen;
$this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(PRODUCTS_ADD_IMAGE))->setSQLAction(new S('update'))->setTableName(self::$objProductsIMGTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objProductsIMGTableFId)->setUploadDirectory(new S('products/images/' . $_GET[ADMIN_ACTION_ID]))->setUploadImageResize(new A(array(60 => 60, 100 => 100, 128 => 128, 320 => 240, 640 => 480, 800 => 600)))->setExtraUpdateData(self::$objProductsIMGTableFProdId, $_GET[ADMIN_ACTION_ID])->setName($objFormToRender)->setRedirect($objURLToGoBack)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setInputInfoMessage($this->getHELP($objFormToRender))->setValue(new S(PRODUCTS_ADD_IMAGE))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objProductsIMGTableFTitle)->setLabel(new S(PRODUCTS_IMAGE_TITLE))->setContainerDiv(new B(TRUE))->setInputType(new S('file'))->setName(self::$objProductsIMGTableFURL)->setLabel(new S(PRODUCTS_IMAGE))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objProductsIMGTableFCaption)->setLabel(new S(PRODUCTS_CAPTION))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE));
break;
case 'imageEdit':
// Set the URL to go back too;
$objURLToGoBack = URL::rewriteURL(new A(array(PRODUCTS_ACTION_IMAGE, PRODUCTS_ID_IMAGE)));
// Do the form, make it happen;
if ($this->checkPOST(self::$objProductsIMGTableFTitle)->toBoolean() == TRUE) {
if ($this->getPOST(self::$objProductsIMGTableFTitle)->toLength()->toInt() == 0) {
$this->setErrorOnInput(self::$objProductsIMGTableFTitle, new S(PRODUCTS_IMAGE_TITLE_CANNOT_BE_EMPTY));
}
}
$this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(PRODUCTS_EDIT_IMAGE))->setSQLAction(new S('update'))->setTableName(self::$objProductsIMGTable)->setUpdateId($_GET[PRODUCTS_ID_IMAGE])->setUpdateField(self::$objProductsIMGTableFId)->setName($objFormToRender)->setRedirect($objURLToGoBack)->setAJAXEnabledForm(new B(FALSE))->setUploadDirectory(new S('products/images/' . $_GET[ADMIN_ACTION_ID]))->setUploadImageResize(new A(array(60 => 60, 100 => 100, 128 => 128, 320 => 240, 640 => 480, 800 => 600)))->setInputType(new S('submit'))->setValue(new S(PRODUCTS_EDIT_IMAGE))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objProductsIMGTableFTitle)->setLabel(new S(PRODUCTS_IMAGE_TITLE))->setContainerDiv(new B(TRUE))->setInputType(new S('file'))->setName(self::$objProductsIMGTableFURL)->setLabel(new S(PRODUCTS_IMAGE))->setFileController(new B(TRUE))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objProductsIMGTableFCaption)->setLabel(new S(PRODUCTS_CAPTION))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE));
break;
case 'imageErase':
// Set the URL to back too;
$objURLToGoBack = URL::rewriteURL(new A(array(PRODUCTS_ACTION_IMAGE, PRODUCTS_ID_IMAGE)));
// First, delete existing images;
$objProductImages = $this->_Q(_QS('doSELECT')->doToken('%what', self::$objProductsIMGTableFURL)->doToken('%table', self::$objProductsIMGTable)->doToken('%condition', new S('WHERE %objProductsIMGTableFId = "%Id"'))->doToken('%Id', $_GET[PRODUCTS_ID_IMAGE]));
// Knowing the images, delete THEM;
foreach ($objProductImages as $k => $v) {
UNLINK(DOCUMENT_ROOT . UPLOAD_DIR . _S . 'products/images/' . $_GET[ADMIN_ACTION_ID] . _S . $v['url']);
UNLINK(DOCUMENT_ROOT . UPLOAD_DIR . _S . 'products/images/' . $_GET[ADMIN_ACTION_ID] . _S . '60_60_' . $v['url']);
UNLINK(DOCUMENT_ROOT . UPLOAD_DIR . _S . 'products/images/' . $_GET[ADMIN_ACTION_ID] . _S . '100_100_' . $v['url']);
UNLINK(DOCUMENT_ROOT . UPLOAD_DIR . _S . 'products/images/' . $_GET[ADMIN_ACTION_ID] . _S . '128_128_' . $v['url']);
UNLINK(DOCUMENT_ROOT . UPLOAD_DIR . _S . 'products/images/' . $_GET[ADMIN_ACTION_ID] . _S . '320_240_' . $v['url']);
UNLINK(DOCUMENT_ROOT . UPLOAD_DIR . _S . 'products/images/' . $_GET[ADMIN_ACTION_ID] . _S . '640_480_' . $v['url']);
UNLINK(DOCUMENT_ROOT . UPLOAD_DIR . _S . 'products/images/' . $_GET[ADMIN_ACTION_ID] . _S . '800_600_' . $v['url']);
}
//.........这里部分代码省略.........
示例2: renderForm
/**
* Will render a specified form, the name of the form given by the first parameter;
*
* This method will render one of the forms for our object, invoked by giving the proper form identifier to the current form.
* We have chosen this method of invoking forms, because we just had too many this->renderSomethingMethod (), which really had
* an impact on code massiveness. Also, having code organized in switch/case statements leads us to be able to share common
* settings between different forms, as we've done with the methods defined in the __CALL method above;
*
* For example, if we wanted to share some common configuration between a create and an edit form, we could have introduced
* two switches in this method, one that would have set the common options, and the second, would have just passed through
* again, and get the already set configuration options, using them. This means that if we needed to change behavior of
* some interconnected forms, that would mean modifying the needed code one place only, which is a big advantage over
* having separated methods for each form. Maybe if we extended this object, you guys could understand the functionality;
*
* @param string $objFormToRender The name of the form to render;
* @return mixed Depends on the rendered form if it returns something or not;
*/
public function renderForm(S $objFormToRender, A $objFormArray = NULL)
{
// Make them defaults ...
if ($objFormArray == NULL) {
$objFormArray = new A();
}
// Do a switch ...
switch ($objFormToRender) {
case 'articleSearch':
// Get some predefines;
if (isset($_GET[ADMIN_ACTION_BY])) {
$objSearchBy = $_GET[ADMIN_ACTION_BY];
} else {
$objSearchBy = new S();
}
if (isset($_GET[ADMIN_ACTION_SEARCH])) {
$objSearchWas = $_GET[ADMIN_ACTION_SEARCH];
} else {
$objSearchWas = new S();
}
// Do some work;
if ($this->checkPOST(new S('search_submit'))->toBoolean() == TRUE) {
if ($this->getPOST(new S('search_by'))->toLength()->toInt() == 0) {
if (isset($_GET[ADMIN_ACTION_SEARCH])) {
// Erase search terms ...
$this->setHeaderKey(URL::rewriteURL(new A(array(ADMIN_ACTION_SEARCH, ADMIN_ACTION_BY))), new S('Location'));
}
// Set an input error;
$this->setErrorOnInput(new S('search_by'), new S(ARTICLES_SEARCH_FIELD_IS_EMPTY));
// Unset the post ...
$this->unsetPOST();
} else {
// Get what to search and where ...
$objWhatToSearch = $this->getPOST(new S('search_by'));
$objWhereToSearch = $this->getPOST(new S('search_field'));
// And go there ...
$this->setHeaderKey(URL::rewriteURL(new A(array(ADMIN_ACTION_SEARCH, ADMIN_ACTION_BY)), new A(array($objWhatToSearch, $objWhereToSearch))), new S('Location'));
}
}
// Check the option that has been selected;
$objWasSelected = new A(array(new B($objSearchBy == ARTICLES_SEARCH_TITLE ? TRUE : FALSE), new B($objSearchBy == ARTICLES_SEARCH_CONTENT ? TRUE : FALSE), new B($objSearchBy == ARTICLES_SEARCH_CATEGORY ? TRUE : FALSE), new B($objSearchBy == ARTICLES_SEARCH_TAGS ? TRUE : FALSE), new B($objSearchBy == ARTICLES_SEARCH_EXCERPT ? TRUE : FALSE)));
// Do the form, make it happen;
$this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(ARTICLES_SEARCH_BY))->setName($objFormToRender)->setInputType(new S('text'))->setInputInfoMessage($this->getHELP($objFormToRender))->setName(new S('search_by'))->setvalue($objSearchWas)->setLabel(new S(ARTICLES_SEARCH_BY))->setJSRegExpReplace(new S('[^a-zA-Z0-9 -]'))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(new S('search_field'))->setContainerDiv(new B(TRUE))->setLabel(new S(ARTICLES_SEARCH_IN))->setInputType(new S('option'))->setName(new S('article_title'))->setValue(new S(ARTICLES_SEARCH_TITLE))->setLabel(new S(ARTICLES_SEARCH_TITLE))->setSelected($objWasSelected[0])->setInputType(new S('option'))->setName(new S('article_content'))->setValue(new S(ARTICLES_SEARCH_CONTENT))->setLabel(new S(ARTICLES_SEARCH_CONTENT))->setSelected($objWasSelected[1])->setInputType(new S('option'))->setName(new S('article_category'))->setValue(new S(ARTICLES_SEARCH_CATEGORY))->setLabel(new S(ARTICLES_SEARCH_CATEGORY))->setSelected($objWasSelected[2])->setInputType(new S('option'))->setName(new S('article_tags'))->setValue(new S(ARTICLES_SEARCH_TAGS))->setLabel(new S(ARTICLES_SEARCH_TAGS))->setSelected($objWasSelected[3])->setInputType(new S('option'))->setName(new S('article_excerpt'))->setValue(new S(ARTICLES_SEARCH_EXCERPT))->setLabel(new S(ARTICLES_SEARCH_EXCERPT))->setSelected($objWasSelected[4])->setInputType(new S('submit'))->setContainerDiv(new B(TRUE))->setValue(new S(ARTICLES_SEARCH_BY))->setName(new S('search_submit'))->setFormEndAndExecute(new B(TRUE));
break;
case 'articleCreate':
// The URL to go back too;
$objURLToGoBack = URL::rewriteURL();
// Do some work;
if ($this->checkPOST(self::$objArticleTableFTitle)->toBoolean() == TRUE) {
// Set what to check
$objToCheck = $this->getPOST(self::$objArticleTableFTitle);
if ($objToCheck->toLength()->toInt() == 0) {
$this->setErrorOnInput(self::$objArticleTableFTitle, new S(ARTICLES_TITLE_CANNOT_BE_EMPTY));
} else {
// Check title is unique;
if ($this->checkArticleTitleIsUnique($objToCheck)->toBoolean() == FALSE) {
$this->setErrorOnInput(self::$objArticleTableFTitle, new S(ARTICLES_TITLE_MUST_BE_UNIQUE));
}
}
}
if ($this->checkPOST(self::$objArticleTableFContent)->toBoolean() == TRUE) {
// Set what to check
$objToCheck = $this->getPOST(self::$objArticleTableFContent);
if ($objToCheck->toLength()->toInt() == 0) {
$this->setErrorOnInput(self::$objArticleTableFContent, new S(ARTICLES_CONTENT_CANNOT_BE_EMPTY));
}
}
// Check & Get;
$this->getAjaxErrors();
// Do the form, make it happen;
$this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(ARTICLES_ADD_ARTICLE))->setSQLAction(new S('update'))->setTableName(self::$objArticleTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objArticleTableFId);
// Do some extra work;
if ((int) $this->ATH->getCurrentUserInfoById(Authentication::$objAuthUsersTableFId)->toString() != 1) {
// In case we're not the BIG MAN, we're the author ...
$this->setExtraUpdateData(self::$objArticleTableFAuthorId, $this->ATH->getCurrentUserInfoById(Authentication::$objAuthUsersTableFId));
}
// Set the published date;
$this->setExtraUpdateData(self::$objArticleTableFDatePublished, new S((string) $_SERVER['REQUEST_TIME']));
$this->setExtraUpdateData(self::$objArticleTableFDateUpdated, new S((string) $_SERVER['REQUEST_TIME']));
// Add the URL;
if ($this->checkPOST(self::$objArticleTableFTitle)->toBoolean() == TRUE) {
$this->setExtraUpdateData(self::$objArticleTableFSEO, URL::getURLFromString(new S($this->getPOST(self::$objArticleTableFTitle) . _U . new S((string) $_SERVER['REQUEST_TIME']))));
}
//.........这里部分代码省略.........
示例3: renderForm
/**
* Will render a specified form, the name of the form given by the first parameter;
*
* This method will render one of the forms for our object, invoked by giving the proper form identifier to the current form.
* We have chosen this method of invoking forms, because we just had too many this->renderSomethingMethod (), which really had
* an impact on code massiveness. Also, having code organized in switch/case statements leads us to be able to share common
* settings between different forms, as we've done with the methods defined in the __CALL method above;
*
* For example, if we wanted to share some common configuration between a create and an edit form, we could have introduced
* two switches in this method, one that would have set the common options, and the second, would have just passed through
* again, and get the already set configuration options, using them. This means that if we needed to change behavior of
* some interconnected forms, that would mean modifying the needed code one place only, which is a big advantage over
* having separated methods for each form. Maybe if we extended this object, you guys could understand the functionality;
*
* @param string $objFormToRender The name of the form to render;
* @return mixed Depends on the rendered form if it returns something or not;
*/
public function renderForm(S $objFormToRender, A $objFA = NULL)
{
// Make them defaults ...
if ($objFA == NULL) {
$objFA = new A();
}
// Do a switch ...
switch ($objFormToRender) {
case 'uploadForm':
// The URL to go back too;
$objURLToGoBack = URL::rewriteURL(new A(array(AUDIO_STATUS_URL)), new A(array(AUDIO_STATUS_OK_URL)));
// Do some work ...
if ($this->checkPOST(self::$objAudioTableFTitle)->toBoolean() == TRUE) {
// Check non empty ...
if ($this->getPOST(self::$objAudioTableFTitle)->toLength()->toInt() == 0) {
$this->setErrorOnInput(self::$objAudioTableFTitle, new S($objFA['error_title_empty']));
}
}
if ($this->checkPOST(self::$objAudioTableFArtist)->toBoolean() == TRUE) {
// Check non empty ...
if ($this->getPOST(self::$objAudioTableFArtist)->toLength()->toInt() == 0) {
$this->setErrorOnInput(self::$objAudioTableFArtist, new S($objFA['error_artist_empty']));
}
}
if ($this->checkPOST(self::$objAudioTableFAlbum)->toBoolean() == TRUE) {
// Check non empty ...
if ($this->getPOST(self::$objAudioTableFAlbum)->toLength()->toInt() == 0) {
$this->setErrorOnInput(self::$objAudioTableFAlbum, new S($objFA['error_album_empty']));
}
}
// Check & Get;
$this->getAjaxErrors();
// Do the form, make it happen;
$this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S($objFA['upload_audio_file']))->setSQLAction(new S('update'))->setTableName(self::$objAudioTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objAudioTableFId)->setExtraUpdateData(self::$objAudioTableFUploadedDate, new S((string) $_SERVER['REQUEST_TIME']))->setExtraUpdateData(self::$objAudioTableFUploaderId, $this->ATH->getCurrentUserInfoById(Authentication::$objAuthUsersTableFId))->setExtraUpdateData(self::$objAudioTableFApproved, new S('N'))->setUploadDirectory(new S('audio/mp3/' . date('Y/m/d', $_SERVER['REQUEST_TIME'])))->setUploadImageResize(new A(array(128 => 128, 640 => 480, 800 => 600)));
// Add the URL ...
if ($this->checkPOST(self::$objAudioTableFTitle)->toBoolean() == TRUE && $this->checkPOST(self::$objAudioTableFArtist)->toBoolean() == TRUE) {
// CLONE them little monkeys ...
$objURL = clone $this->getPOST(self::$objAudioTableFTitle);
$objART = clone $this->getPOST(self::$objAudioTableFArtist);
// CONCAT'enate them ...
$this->setExtraUpdateData(self::$objAudioTableFSEO, URL::getURLFromString($objURL->appendString(_U)->appendString($objART)->appendString(_U)->appendString((string) $_SERVER['REQUEST_TIME'])));
}
// Continue ...
$this->setName($objFormToRender)->setRedirect($objURLToGoBack)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setValue(new S($objFA['upload_audio_file']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAudioTableFTitle)->setLabel(new S($objFA['audio_file_title']))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(self::$objAudioTableFCategoryId)->setLabel(new S($objFA['audio_file_category']))->setContainerDiv(new B(TRUE));
// Categories ...
foreach ($this->getCategories() as $k => $v) {
$this->setInputType(new S('option'))->setName($v[self::$objMPTT->objIdField])->setValue($v[self::$objMPTT->objIdField])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . MPTT::mpttRemoveUnique($v[self::$objMPTT->objNameOfNode])));
}
// Continue ...
$this->setInputType(new S('text'))->setName(self::$objAudioTableFArtist)->setLabel(new S($objFA['audio_file_artist']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAudioTableFAlbum)->setLabel(new S($objFA['audio_file_album']))->setContainerDiv(new B(TRUE))->setInputType(new S('file'))->setName(self::$objAudioTableFFile)->setLabel(new S($objFA['audio_file_file']))->setContainerDiv(new B(TRUE))->setInputType(new S('file'))->setName(self::$objAudioTableFArtwork)->setLabel(new S($objFA['audio_file_artwork']))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAudioTableFLyrics)->setLabel(new S($objFA['audio_file_lyrics']))->setTinyMCETextarea(new B(TRUE))->setClass(new S('tinyMCESimple'))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objAudioTableFDescription)->setLabel(new S($objFA['audio_file_description']))->setTinyMCETextarea(new B(TRUE))->setClass(new S('tinyMCESimple'))->setContainerDiv(new B(TRUE));
// Notify ...
if ($this->checkFormHasErrors()->toBoolean() == FALSE) {
// Go ...
$objMAIL = new MAIL();
$objMAIL->doMAIL($this->STG->getConfigKey(new S('settings_website_notification_email')), new S(AUDIO_FRONT_FILE_HAS_BEEN_UPLOADED), $this->getHELP(new S('uploadFormEMLMessage'))->doToken('%t', $this->getPOST(self::$objAudioTableFTitle))->doToken('%a', $this->getPOST(self::$objAudioTableFArtist))->doToken('%b', $this->getPOST(self::$objAudioTableFAlbum))->doToken('%u', $this->ATH->getCurrentUserInfoById(Authentication::$objAuthUsersTableFUName)));
}
// End form and execute ...
$this->setFormEndAndExecute(new B(TRUE));
break;
case 'audioSearchOnFrontend':
// Do the form, make it happen ...
$this->setMethod(new S('POST'))->setName($objFormToRender);
// Do some work ...
if ($this->checkPOST(new S('search'))->toBoolean() == TRUE) {
// Get the title, and check it's name ...
if ($this->getPOST(new S('audio_file_title'))->toLength()->toInt() == 0) {
// Well, sadly, we have an issue ...
$this->setErrorOnInput(new S('audio_file_title'), new S($objFA['error_empty_search']));
} else {
// Notify ...
$objMAIL = new MAIL();
$objMAIL->doMAIL($this->STG->getConfigKey(new S('settings_website_notification_email')), new S(AUDIO_SEARCH_HAS_BEEN_PERFORMED), $this->getHELP(new S('audioSearchOnFrontend'))->doToken('%s', $this->getPOST(new S('audio_file_title'))));
// Go ...
$this->setHeaderKey($objURLToGoBack = URL::staticURL(new A(array(FRONTEND_SECTION_URL, AUDIO_SEARCH_URL)), new A(array(FRONTEND_AUDIO_URL, $this->getPOST(new S('audio_file_title'))->entityDecode(ENT_QUOTES)->stripSlashes()))), new S('Location'));
}
}
// Continue ...
$this->setInputType(new S('submit'))->setName(new S('search'))->setValue(new S($objFA['search_submit']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(new S('audio_file_title'));
// If it's set ... add the VALUE ...
if (isset($_GET[AUDIO_SEARCH_URL])) {
$this->setValue($_GET[AUDIO_SEARCH_URL]);
}
// Continue ...
//.........这里部分代码省略.........
示例4: renderForm
/**
* Will render a specified form, the name of the form given by the first parameter;
*
* This method will render one of the forms for our object, invoked by giving the proper form identifier to the current form.
* We have chosen this method of invoking forms, because we just had too many this->renderSomethingMethod (), which really had
* an impact on code massiveness. Also, having code organized in switch/case statements leads us to be able to share common
* settings between different forms, as we've done with the methods defined in the __CALL method above;
*
* For example, if we wanted to share some common configuration between a create and an edit form, we could have introduced
* two switches in this method, one that would have set the common options, and the second, would have just passed through
* again, and get the already set configuration options, using them. This means that if we needed to change behavior of
* some interconnected forms, that would mean modifying the needed code one place only, which is a big advantage over
* having separated methods for each form. Maybe if we extended this object, you guys could understand the functionality;
*
* @param string $objFormToRender The name of the form to render;
* @return mixed Depends on the rendered form if it returns something or not;
*/
public function renderForm(S $objFormToRender, A $objFormArray = NULL)
{
// Make them defaults ...
if ($objFormArray == NULL) {
$objFormArray = new A();
}
// Do a switch ...
switch ($objFormToRender) {
case 'newsletterSearch':
break;
case 'newsletterCreate':
// The URL to go back too;
$objURLToGoBack = URL::rewriteURL();
// Do some work;
if ($this->checkPOST(self::$objLetterTableFEML)->toBoolean() == TRUE) {
if ($this->checkSubscriberAddressIsUnique($this->getPOST(self::$objLetterTableFEML))->toBoolean() == FALSE) {
$this->setErrorOnInput(self::$objLetterTableFEML, new S(NEWSLETTER_EMAIL_MUST_BE_UNIQUE));
}
if ($this->getPOST(self::$objLetterTableFEML)->toLength()->toInt() == 0) {
$this->setErrorOnInput(self::$objLetterTableFEML, new S(NEWSLETTER_FIELD_IS_EMPTY));
}
}
if ($this->checkPOST(self::$objLetterTableFFirstName)->toBoolean() == TRUE) {
if ($this->getPOST(self::$objLetterTableFFirstName)->toLength()->toInt() == 0) {
$this->setErrorOnInput(self::$objLetterTableFFirstName, new S(NEWSLETTER_FIELD_IS_EMPTY));
}
}
if ($this->checkPOST(self::$objLetterTableFLastName)->toBoolean() == TRUE) {
if ($this->getPOST(self::$objLetterTableFLastName)->toLength()->toInt() == 0) {
$this->setErrorOnInput(self::$objLetterTableFLastName, new S(NEWSLETTER_FIELD_IS_EMPTY));
}
}
// Get AJAX;
$this->getAjaxErrors();
// Do the form, make it happen;
$this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(NEWSLETTER_ADD))->setSQLAction(new S('update'))->setTableName(self::$objLetterTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objLetterTableFId)->setExtraUpdateData(self::$objLetterTableFSubscribed, new S((string) time()))->setExtraUpdateData(self::$objLetterTableFConfirmed, new S('Y'));
if ($this->checkPOST(self::$objLetterTableFEML)->toBoolean() == TRUE) {
$this->setRedirect($objURLToGoBack);
}
$this->setName($objFormToRender)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setName(new S('submit'))->setValue(new S(NEWSLETTER_ADD))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objLetterTableFEML)->setLabel(new S(NEWSLETTER_EMAIL))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objLetterTableFFirstName)->setLabel(new S(NEWSLETTER_FIRSTNAME))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objLetterTableFLastName)->setLabel(new S(NEWSLETTER_LASTNAME))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(self::$objLetterTableFType)->setLabel(new S(NEWSLETTER_TYPE))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('nw_html'))->setValue(new S('HTML'))->setLabel(new S(NEWSLETTER_HTML))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('nw_txt'))->setValue(new S('PLAIN'))->setLabel(new S(NEWSLETTER_PLAIN))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setLabel(new S(NEWSLETTER_CATEGORY))->setName(self::$objLetterTableFCategoryId)->setContainerDiv(new B(TRUE));
// Categories ...
foreach ($this->getCategories() as $k => $v) {
$this->setInputType(new S('option'))->setName($v[self::$objMPTT->objIdField])->setValue($v[self::$objMPTT->objIdField])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . MPTT::mpttRemoveUnique($v[self::$objMPTT->objNameOfNode])));
}
// Continue ...
$this->setFormEndAndExecute(new B(TRUE));
break;
case 'newsletterEdit':
// The URL to go back too;
$objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID)));
// Do some work;
if ($this->checkPOST(self::$objLetterTableFEML)->toBoolean() == TRUE) {
if ($this->getPOST(self::$objLetterTableFEML) != $this->getSubscriberInfoById($_GET[ADMIN_ACTION_ID], self::$objLetterTableFEML)) {
if ($this->checkSubscriberAddressIsUnique($this->getPOST(self::$objLetterTableFEML))->toBoolean() == FALSE) {
$this->setErrorOnInput(self::$objLetterTableFEML, new S(NEWSLETTER_EMAIL_MUST_BE_UNIQUE));
}
}
if ($this->getPOST(self::$objLetterTableFEML)->toLength()->toInt() == 0) {
$this->setErrorOnInput(self::$objLetterTableFEML, new S(NEWSLETTER_FIELD_IS_EMPTY));
}
}
if ($this->checkPOST(self::$objLetterTableFFirstName)->toBoolean() == TRUE) {
if ($this->getPOST(self::$objLetterTableFFirstName)->toLength()->toInt() == 0) {
$this->setErrorOnInput(self::$objLetterTableFFirstName, new S(NEWSLETTER_FIELD_IS_EMPTY));
}
}
if ($this->checkPOST(self::$objLetterTableFLastName)->toBoolean() == TRUE) {
if ($this->getPOST(self::$objLetterTableFLastName)->toLength()->toInt() == 0) {
$this->setErrorOnInput(self::$objLetterTableFLastName, new S(NEWSLETTER_FIELD_IS_EMPTY));
}
}
// Get AJAX;
$this->getAjaxErrors();
// Do the form, make it happen;
$this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(NEWSLETTER_EDIT))->setSQLAction(new S('update'))->setTableName(self::$objLetterTable)->setUpdateId($_GET[ADMIN_ACTION_ID])->setUpdateField(self::$objLetterTableFId);
if ($this->checkPOST(self::$objLetterTableFEML)->toBoolean() == TRUE) {
$this->setRedirect($objURLToGoBack);
}
$this->setName($objFormToRender)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setName(new S('submit'))->setValue(new S(NEWSLETTER_EDIT))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objLetterTableFEML)->setLabel(new S(NEWSLETTER_EMAIL))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objLetterTableFFirstName)->setLabel(new S(NEWSLETTER_FIRSTNAME))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objLetterTableFLastName)->setLabel(new S(NEWSLETTER_LASTNAME))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(self::$objLetterTableFType)->setLabel(new S(NEWSLETTER_TYPE))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('nw_html'))->setValue(new S('HTML'))->setLabel(new S(NEWSLETTER_HTML))->setContainerDiv(new B(TRUE))->setInputType(new S('option'))->setName(new S('nw_txt'))->setValue(new S('PLAIN'))->setLabel(new S(NEWSLETTER_PLAIN))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setLabel(new S(NEWSLETTER_CATEGORY))->setName(self::$objLetterTableFCategoryId)->setContainerDiv(new B(TRUE));
// Categories ...
foreach ($this->getCategories() as $k => $v) {
$this->setInputType(new S('option'))->setName($v[self::$objMPTT->objIdField])->setValue($v[self::$objMPTT->objIdField])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . MPTT::mpttRemoveUnique($v[self::$objMPTT->objNameOfNode])));
}
//.........这里部分代码省略.........
示例5: tpExe
/**
* Will execute the passed .tp FilePath, and extract the variables as references (or overwrites). Assigning the variables is
* not enough. You need to make a CALL to TPL::tpExe ($tpF) to execute the specified $tpF file;
*
* @param string $tpFileName The path to the .tp file to be executed
* @param boolean $tpAsAJAXResponse Set to TRUE when echo'ing the .tp as an AJAX response
* @return boolean Will return true if the file has been executed properly
* @author Catalin Z. Alexandru <catalin.zamfir@raphpframework.ro>
* @copyright Under the terms of the GNU General Public License v3
* @version $Id: 10_TPL.php 315 2009-10-11 07:11:31Z catalin.zamfir $
* @since Version 1.0
* @access public
* @static
* @final
*/
public static final function tpExe(FilePath $tpFileName, B $tpAsAJAXResponse = NULL)
{
// Set some requirements ...
if ($tpAsAJAXResponse == NULL) {
$tpAsAJAXResponse = new B(FALSE);
}
// Make sure we're actually there ...
if ($tpFileName->checkPathExists()) {
self::$objFilePathArray[$tpFileName]['dummy_' . $_SERVER['REQUEST_TIME']] = new S('do_not_cache');
if (extract(self::$objFilePathArray[$tpFileName]->toArray(), EXTR_REFS)) {
// If it's an AJAX request for HTML, CLEAN it;
if ($tpAsAJAXResponse->toBoolean() == TRUE) {
TPL::discardOutputStream(new B(TRUE));
TPL::switchHTML();
}
// Require the template file ...
require $tpFileName->toString();
// Unset all predefined variables, for a memory clean-up;
unset(self::$objFilePathArray[$tpFileName]);
// Do me a favor and STOP right here ...
if ($tpAsAJAXResponse->toBoolean() == TRUE) {
// DIE;
TPL::disableFurtherOutput();
}
// Return the status;
return new B(TRUE);
} else {
self::renderScreenOfDeath(new S(__CLASS__), new S(CANNOT_EXTRACT_VARS), new S(CANNOT_EXTRACT_VARS_FIX));
}
} else {
self::renderScreenOfDeath(new S(__CLASS__), new S(FILE_DOESNT_EXIST), new S(FILE_DOESNT_EXIST_FIX));
}
}
示例6: renderScreenOfDeath
/**
* Will render the 'Screen Of Death', by using tested and well working PHP functions. This method relies on the fact that, at least
* the framework abstract classes are working. Non-core developers should not modify anything here as they can get their hands
* dirty really quick and destroy something without even knowing it;
*
* @param S $errFrom Error from where did it came
* @param S $errString What's the string of the error
* @param S $errTip Do you have an information to show
* @param S $debugErrorString Should we show the debugger
* @param B $errFATAL Is this error FATAL
* @return S Will return the error screen string, or just void, depends on what kind of error we caught
* @author Catalin Z. Alexandru <catalin.zamfir@raphpframework.ro>
* @copyright Under the terms of the GNU General Public License v3
* @version $Id: 08_ERR.php 313 2009-10-09 13:27:52Z catalin.zamfir $
* @since Version 1.0
* @access protected
* @static
* @final
*/
protected static function renderScreenOfDeath(S $errFrom, S $errString = NULL, S $errTip = NULL, S $debugErrorString = NULL, B $errFATAL = NULL)
{
// Set the execution time, discard the output stream, and set the error status to TRUE;
self::setExeTime(new S(__FUNCTION__));
// Add header, if it's a CSS file, on an error!;
switch (checkIfItsACSSFile() or checkIfItsAJSSFile()) {
case TRUE:
// Set the text/HTML, header!;
self::setHeaderKey(new S('text/html'), new S('Content-type:'));
break;
}
// Se the errorStatus to TRUE;
self::setErrorStatus();
$catchedKrumoContent = _NONE;
// Change behaviour, if this is a FATAL error;
if ($errFATAL != NULL && $errFATAL->toBoolean() == TRUE) {
$errString = new S(FATAL_ERROR);
$errTip = new S(FATAL_ERROR_CHECK_LOG);
// Clean the output buffer;
self::$objOutputBuffer = _NONE;
} else {
// Clean the output buffer;
self::discardOutputStream(new B(TRUE));
// Execute the KRUMO PLUGIN Framework;
$catchedKrumoContent = self::getKrumoContent();
}
// Get the file contents;
$debugContent = new FileContent(FORM_TP_DIR . _S . 'frm_error_screen.tp');
// Do an if, for the [%CODE%] part of our template;
if (GESHI >= 1 && DEBUG >= 1) {
// Replace [%CODE%], with GeSHi parsed code from our PHP files;
// Really helpfull when trying to find hidden bugs;
$debugContent->doToken('[%CODE%]', self::getDebugBacktrace(array_reverse(debug_backtrace())));
$debugContent->doToken('[%KRUMO%]', $catchedKrumoContent);
} else {
// Replace [%CODE%], with _NONE, hiding the output;
// Well, can't help the developer here!;
$debugContent->doToken('[%CODE%]', _NONE);
$debugContent->doToken('[%KRUMO%]', _NONE);
// Set as 'Hacking attempt';
$errString = VIEW_FILE_DIRECTLY_DENIED;
$errTip = VIEW_FILE_DIRECTLY_DENIED_FIX;
$debugErrorString = HACKING_ATTEMPT_BANG_YOU_DEAD;
}
// Start replacing information in the 'frm_error_screen.tp';
$debugContent->doToken('[%HSIMG%]', DOCUMENT_HOST . IMAGE_DIR . _WS);
$debugContent->doToken('[%HSJSS%]', DOCUMENT_HOST . JAVASCRIPT_DIR . _WS);
$debugContent->doToken('[%ERBGR%]', ERBGR);
$debugContent->doToken('[%ERPIX%]', ERPIX);
$debugContent->doToken('[%ERPXL%]', ERPXL);
$debugContent->doToken('[%MEMORY%]', memory_get_usage() / 1024);
$debugContent->doToken('[%PID%]', getmypid());
$debugContent->doToken('[%MICROTIME%]', self::getExeTime(new S(__CLASS__), new S(__FUNCTION__)));
$debugContent->doToken('[%ERROR_FROM%]', $errFrom);
$debugContent->doToken('[%ERROR_DATE%]', date(DATE_STRING, $_SERVER['REQUEST_TIME']));
$debugContent->doToken('[%ERROR_EMSG%]', $errString);
$debugContent->doToken('[%ERROR_ETIP%]', $errTip);
$debugContent->doToken('[%ERROR_FROM_PHP%]', $debugErrorString);
// Try to MAIL ... If we got this far, we have MAIL ...
if (self::checkClassExistence(new S('MAIL'))->toBoolean() == TRUE) {
// Set some requirements ...
if ($errString == NULL) {
$errString = new S();
}
if ($errTip == NULL) {
$errTip = new S();
}
// Make'em as new as possible ...
$objEML = new MAIL();
$objEML->setFrom(new S(MAIL_FROM));
$objEML->setStringAttachment(new S($debugContent));
$objEML->doMAIL(new S(MAIL_FROM), $errString, new S($errTip . _DCSP . URL::rewriteURL() . _DCSP . $_SERVER['HTTP_USER_AGENT'] . _DCSP . $_SERVER['REMOTE_ADDR']));
}
// Exit, with an error screen. We could also die, it would mean the same;
if ($errFATAL != NULL && $errFATAL->toBoolean() == TRUE) {
// Return the content;
if (OB_GZIP == TRUE && OB_GZIP_LEVEL > 0 && OB_GZIP_LEVEL <= 9) {
return gzencode($debugContent, OB_GZIP_LEVEL);
} else {
return $debugContent;
}
//.........这里部分代码省略.........
示例7: renderForm
/**
* Will render a specified form, the name of the form given by the first parameter;
*
* This method will render one of the forms for our object, invoked by giving the proper form identifier to the current form.
* have chosen this method of invoking forms, because we just had too many this->renderSomethingMethod (), which really had
* an impact on code massiveness. Also, having code organized in switch/case statements leads us to be able to share common
* settings between different forms, as we've done with the methods defined in the __CALL method above;
*
* For example, if we wanted to share some common configuration between a create and an edit form, we could have introduced
* two switches in this method, one that would have set the common options, and the second, would have just passed through
* again, and get the already set configuration options, using them. This means that if we needed to change behavior of
* some interconnected forms, that would mean modifying the needed code one place only, which is a big advantage over
* having separated methods for each form. Maybe if we extended this object, you guys could understand the functionality best;
*
* @param string $objFormToRender The name of the form to render;
* @return mixed Depends on the rendered form if it returns something or not;
*/
public function renderForm(S $objFormToRender, A $objFA = NULL)
{
// Make them defaults ...
if ($objFA == NULL) {
$objFA = new A();
}
// Do a switch ...
switch ($objFormToRender) {
case 'adminLoginScreen':
// Do some URL mangling, redirect back to a pure index;
URL::doCleanURLPath();
// Add a <title> tag, saying we need to log in;
$this->manageTTL(new S(AUTHENTICATION_LOGIN_FORM));
// Get the personalized CSS;
$this->manageCSS(new FilePath($this->getPathToSkin()->toRelativePath() . SKIN_CSS_DIR . _S . 'renderAdminLoginScreen.css'), new S(__FUNCTION__));
// Do the authentication mechanism, check the _POST;
if ($this->checkPOST()->toBoolean() == TRUE) {
if ($this->doLogIn($this->getPOST(self::$objAuthUsersTableFUName), $this->getPOST(self::$objAuthUsersTableFUPass))->toBoolean() == TRUE) {
// OK;
$this->setHeaderKey(URL::rewriteURL(new A(array(ADMIN_PAGE)), new A(array(ADMIN_DASHBOARD))), new S('Location'));
} else {
// Do an error, and retain the user;
$this->setErrorOnInput(self::$objAuthUsersTableFUName, new S(AUTHENTICATION_ACCESS_DENIED));
}
}
// Do the form, make it happen;
$this->setMethod(new S('POST'))->setName($objFormToRender)->setFieldset(new S(AUTHENTICATION_LOGIN_FORM))->setInputType(new S('submit'))->setName(new S('submit'))->setValue(new S(AUTHENTICATION_LOGIN_GO))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFUName)->setLabel(new S(AUTHENTICATION_USERNAME))->setJSRegExpReplace(new S('[^a-zA-Z0-9 .-]'))->setTooltip($this->getHELP(new S('adminLoginScreenU')))->setContainerDiv(new B(TRUE))->setInputType(new S('password'))->setName(self::$objAuthUsersTableFUPass)->setLabel(new S(AUTHENTICATION_PASSWORD))->setTooltip($this->getHELP(new S('adminLoginScreenP')))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE));
break;
case 'userLogIn':
// Do the authentication mechanism, check the _POST;
if ($this->checkPOST(new S('submit_log_in'))->toBoolean() == TRUE) {
// ELSE ... go authenticate us ...
if ($this->doLogIn($this->getPOST(new S('user_username')), $this->getPOST(new S('user_password')))->toBoolean() == TRUE) {
// Set the proper POST ...
$this->setPOST(self::$objAuthUsersTableFIp, new S($_SERVER['REMOTE_ADDR']));
// Make and auto-executing form ...
$this->setMethod(new S('POST'))->setSQLAction(new S('update'))->setTableName(self::$objAuthUsersTable)->setUpdateId($this->getUserInfoByName($this->getPOST(new S('user_username')), self::$objAuthUsersTableFId))->setUpdateField(self::$objAuthUsersTableFId)->setName($objFormToRender)->setInputType(new S('text'))->setName(self::$objAuthUsersTableFIp)->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE));
// Ok ... do nothin' ...
$this->setHeaderKey(URL::staticURL(new A(array(FRONTEND_SECTION_URL)), new A(array(FRONTEND_HOME))), new S('Location'));
} else {
// Do an error, and retain the user;
$this->setErrorOnInput(new S('user_username'), new S($objFA['log_in_failed']));
}
}
// Do the form, make it happen;
$this->setMethod(new S('POST'))->setName($objFormToRender)->setInputType(new S('submit'))->setName(new S('submit_log_in'))->setValue(new S($objFA['log_in']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(new S('user_username'))->setLabel(new S($objFA['log_in_username']))->setJSRegExpReplace(new S('[^a-zA-Z0-9 .-]'))->setContainerDiv(new B(TRUE))->setInputType(new S('password'))->setName(new S('user_password'))->setLabel(new S($objFA['log_in_password']))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE));
break;
case 'userSignUp':
// Set some predefines;
$objURLToGoBack = URL::rewriteURL(new A(array(AUTHENTICATION_STATUS_URL)), new A(array(AUTHENTICATION_STATUS_OK_URL)));
// Check if both password fields have been entered correctly;
if ($this->checkPOST(new S('submit_signup'))->toBoolean() == TRUE) {
// Check username ...
if ($this->getPOST(self::$objAuthUsersTableFUName)->toLength()->toInt() == 0) {
//Check non-empty username, and error if the username is empty;
$this->setErrorOnInput(self::$objAuthUsersTableFUName, new S($objFA['error_username_mandatory']));
} else {
// Check USERNAME;
if ($this->checkUserNameExists($this->getPOST(self::$objAuthUsersTableFUName))->toBoolean() == TRUE) {
$this->setErrorOnInput(self::$objAuthUsersTableFUName, new S($objFA['error_username_exists']));
}
// Check EMAIL;
if ($this->checkUserMailExists($this->getPOST(self::$objAuthUsersTableFEML))->toBoolean() == TRUE) {
$this->setErrorOnInput(self::$objAuthUsersTableFEML, new S($objFA['error_email_exists']));
}
}
// Check password;
if ($this->getPOST(self::$objAuthUsersTableFUPass) != $this->getPOST(new S('confirmation_password'))) {
// Check password mismatch, and error on it if so;
$this->setErrorOnInput(self::$objAuthUsersTableFUPass, new S($objFA['error_passwords_do_not_match']));
}
// Check phone number has 10 chars, only if it is required;
if (self::PHONE_IS_REQUIRED == 1) {
if ($this->getPOST(self::$objAuthUsersTableFPhone)->toLength()->toInt() != 10) {
$this->setErrorOnInput(self::$objAuthUsersTableFPhone, new S($objFA['error_phone_ten_chars']));
}
}
}
// Get AJAX;
$this->getAjaxErrors();
// Do the form, make it happen;
$this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S($objFA['form_signup']))->setSQLAction(new S('update'))->setTableName(self::$objAuthUsersTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objAuthUsersTableFId)->setExtraUpdateData(self::$objAuthUsersTableFRegOn, new S((string) $_SERVER['REQUEST_TIME']))->setExtraUpdateData(self::$objAuthUsersTableFUGId, $objFA['default_group_id'])->setExtraUpdateData(self::$objAuthUsersTableFActivated, new S('N'))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setName(new S('submit_signup'))->setValue(new S($objFA['form_submit']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFUName)->setLabel(new S($objFA['form_username']))->setContainerDiv(new B(TRUE))->setJSRegExpReplace(new S('[^a-zA-Z0-9 .-]'))->setInputType(new S('password'))->setName(self::$objAuthUsersTableFUPass)->setLabel(new S($objFA['form_password']))->setContainerDiv(new B(TRUE))->setInputType(new S('password'))->setName(new S('confirmation_password'))->setLabel(new S($objFA['form_password_confirm']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFEML)->setRegExpType(new S('preg'))->setRegExpErrMsg(new S($objFA['form_regexp_invalid_email']))->setPHPRegExpCheck(new S(self::REGEXP_PHP_CHECK_EMAIL))->setJSRegExpReplace(new S('[^a-zA-Z0-9.@_-]'))->setLabel(new S($objFA['form_email']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFPhone)->setLabel(new S($objFA['form_phone']))->setContainerDiv(new B(TRUE))->setJSRegExpReplace(new S('[^0-9]'))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFLName)->setLabel(new S($objFA['form_last_name']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objAuthUsersTableFFName)->setLabel(new S($objFA['form_first_name']))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objAuthUsersTableFCountry)->setLabel(new S($objFA['form_country']));
// Get the COUNTRIES;
//.........这里部分代码省略.........
示例8: setKey
/**
* Will set the given cookie information;
*
* This method will set the key/var pair of cookie information needed for the given module. In case of _SESSION it will store
* the information by arrays, while cookies will have an identifier string that's long enough to be unique. Each module that
* requests a cookie object has its own cookie scope;
*
* @param S $objKey The key to set;
* @param S $objContent The content to set;
* @param B $objExpTime The expire time to take in account;
*/
public function setKey(S $objKey, S $objContent, B $objExpTime)
{
// Switch ...
switch ($this->objObjectCookie->getConfigKey(new S('authentication_cookie_store_type'))) {
case 'cookie':
// Set the expire time, to current + SESSION_COOKIE_LIFETIME;
$objExpTime->toBoolean() != TRUE ? $expTme = new I(0) : ($expTme = new I($_SERVER['REQUEST_TIME'] + SESSION_COOKIE_LIFETIME));
// Trigger the browser cookie setter, and set the proper key/vars;
setcookie($this->objProjectString . _U . $this->objObjectCookie->getObjectCLASS() . _U . $objKey, $objContent, $expTme->toInt(), new S('/'));
// Redirect to same page, each time;
TPL::setHeaderKey(URL::rewriteURL(), new S('Location'));
break;
case 'session':
// Just use the _SESSION to store it;
$_SESSION[$this->objProjectString->toString()][$this->objObjectCookie->getObjectCLASS()->toString()][$objKey->toString()] = $objContent;
break;
default:
// Make an error on it, cause yeah ...
self::renderScreenOfDeath(new S(__CLASS__), new S(SESSION_TYPE_ERROR), new S(SESSION_TYPE_ERROR_FIX));
break;
}
}
示例9: renderForm
/**
* Will render a specified form, the name of the form given by the first parameter;
*
* This method will render one of the forms for our object, invoked by giving the proper form identifier to the current form.
* We have chosen this method of invoking forms, because we just had too many this->renderSomethingMethod (), which really had
* an impact on code massiveness. Also, having code organized in switch/case statements leads us to be able to share common
* settings between different forms, as we've done with the methods defined in the __CALL method above;
*
* For example, if we wanted to share some common configuration between a create and an edit form, we could have introduced
* two switches in this method, one that would have set the common options, and the second, would have just passed through
* again, and get the already set configuration options, using them. This means that if we needed to change behavior of
* some interconnected forms, that would mean modifying the needed code one place only, which is a big advantage over
* having separated methods for each form. Maybe if we extended this object, you guys could understand the functionality best;
*
* @param string $objFormToRender The name of the form to render;
* @return mixed Depends on the rendered form if it returns something or not;
*/
public function renderForm(S $objFormToRender, A $objFA = NULL)
{
// Make them defaults ...
if ($objFA == NULL) {
$objFA = new A();
}
// Do a switch ...
switch ($objFormToRender) {
case 'textSearch':
// Get some predefines;
if (isset($_GET[ADMIN_ACTION_BY])) {
$objSearchBy = $_GET[ADMIN_ACTION_BY];
} else {
$objSearchBy = new S();
}
if (isset($_GET[ADMIN_ACTION_SEARCH])) {
$objSearchWas = $_GET[ADMIN_ACTION_SEARCH];
} else {
$objSearchWas = new S();
}
// Do some work;
if ($this->checkPOST(new S('search_submit'))->toBoolean() == TRUE) {
if ($this->getPOST(new S('search_by'))->toLength()->toInt() == 0) {
if (isset($_GET[ADMIN_ACTION_SEARCH])) {
// Erase search terms ...
$this->setHeaderKey(URL::rewriteURL(new A(array(ADMIN_ACTION_SEARCH, ADMIN_ACTION_BY))), new S('Location'));
}
// Set an input error;
$this->setErrorOnInput(new S('search_by'), new S(ARTICLE_SEARCH_FIELD_IS_EMPTY));
// Unset the post ...
$this->unsetPOST();
} else {
// Get what to search and where ...
$objWhatToSearch = $this->getPOST(new S('search_by'));
$objWhereToSearch = $this->getPOST(new S('search_field'));
// And go there ...
$this->setHeaderKey(URL::rewriteURL(new A(array(ADMIN_ACTION_SEARCH, ADMIN_ACTION_BY)), new A(array($objWhatToSearch, $objWhereToSearch))), new S('Location'));
}
}
// Check the option that has been selected;
$objWasSelected = new A(array(new B($objSearchBy == TEXTS_SEARCH_TITLE ? TRUE : FALSE), new B($objSearchBy == TEXTS_SEARCH_CONTENT ? TRUE : FALSE)));
// Do the form, make it happen;
$this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(TEXTS_SEARCH_BY))->setName($objFormToRender)->setInputType(new S('text'))->setInputInfoMessage($this->getHELP($objFormToRender))->setName(new S('search_by'))->setvalue($objSearchWas)->setLabel(new S(TEXTS_SEARCH_BY))->setJSRegExpReplace(new S('[^a-zA-Z0-9 -]'))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(new S('search_field'))->setContainerDiv(new B(TRUE))->setLabel(new S(TEXTS_SEARCH_IN))->setInputType(new S('option'))->setName(new S('article_title'))->setValue(new S(TEXTS_SEARCH_TITLE))->setLabel(new S(TEXTS_SEARCH_TITLE))->setSelected($objWasSelected[0])->setInputType(new S('option'))->setName(new S('article_content'))->setValue(new S(TEXTS_SEARCH_CONTENT))->setLabel(new S(TEXTS_SEARCH_CONTENT))->setSelected($objWasSelected[1])->setInputType(new S('submit'))->setContainerDiv(new B(TRUE))->setValue(new S(TEXTS_SEARCH_BY))->setName(new S('search_submit'))->setFormEndAndExecute(new B(TRUE));
break;
case 'textCreate':
// The URL to go back too;
$objURLToGoBack = URL::rewriteURL();
// Do some work;
if ($this->checkPOST(self::$objTextTableFTitle)->toBoolean() == TRUE) {
if ($this->getPOST(self::$objTextTableFTitle)->toLength()->toInt() == 0) {
$this->setErrorOnInput(self::$objTextTableFTitle, new S(TEXTS_TITLE_CANNOT_BE_EMPTY));
} else {
// Set some requirements ...
$objToCheck = $this->getPOST(self::$objTextTableFTitle);
// Check title is unique;
if ($this->checkTextTitleIsUnique($objToCheck)->toBoolean() == FALSE) {
$this->setErrorOnInput(self::$objTextTableFTitle, new S(TEXTS_TITLE_MUST_BE_UNIQUE));
}
// Check URL is unique;
if ($this->checkTextURLIsUnique(URL::getURLFromString(clone $objToCheck))->toBoolean() == FALSE) {
$this->setErrorOnInput(self::$objTextTableFTitle, new S(TEXTS_URL_MUST_BE_UNIQUE));
}
}
if ($this->getPOST(self::$objTextTableFContent)->toLength()->toInt() == 0) {
$this->setErrorOnInput(self::$objTextTableFContent, new S(TEXTS_CONTENT_CANNOT_BE_EMPTY));
}
}
// Get AJAX;
$this->getAjaxErrors();
// Do the form, make it happen;
$this->setMethod(new S('POST'))->setName($objFormToRender)->setAJAXEnabledForm(new B(FALSE))->setFieldset(new S(TEXTS_ADD_ARTICLE))->setRedirect($objURLToGoBack)->setSQLAction(new S('update'))->setTableName(self::$objTextTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objTextTableFId);
if ($this->checkPOST(self::$objTextTableFTitle)->toBoolean() == TRUE) {
$this->setExtraUpdateData(self::$objTextTableFSEO, URL::getURLFromString($this->getPOST(self::$objTextTableFTitle)));
}
// ONLY if != BIG-MAN;
if ((int) $this->ATH->getCurrentUserInfoById(Authentication::$objAuthUsersTableFId)->toString() != 1) {
$this->setExtraUpdateData(self::$objTextTableAuthorId, $this->ATH->getCurrentUserInfoById(Authentication::$objAuthUsersTableFId));
}
// Add the SEO ...
$this->setExtraUpdateData(self::$objTextTableFDatePublished, new S((string) $_SERVER['REQUEST_TIME']))->setInputType(new S('submit'))->setValue(new S(TEXTS_ADD_ARTICLE))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objTextTableFTags)->setLabel(new S(TEXTS_TAGS))->setJSRegExpReplace(new S(self::REGEXP_JS_TAGS))->setContainerDiv(new B(TRUE));
// If we're the BIG MAN, we can set the author of an entry;
if ((int) $this->ATH->getCurrentUserInfoById(Authentication::$objAuthUsersTableFId)->toString() == 1) {
$this->setInputType(new S('select'))->setName(self::$objTextTableFAuthorId)->setLabel(new S(TEXTS_AUTHOR))->setContainerDiv(new B(TRUE));
//.........这里部分代码省略.........
示例10: convertPOSTToSESSIONString
/**
* Will convert the _SESSION['POST'] to framework strings;
*
* This method will take any information sent by the _POST method, and convert them to strings, putting them in the _SESSION
* also, to allow our mechanism of redirection if the form is valid to work properly;
*/
private static function convertPOSTToSESSIONString()
{
if (self::checkPOST()->toBoolean() == TRUE) {
$objDoEncodeAgain = new B(FALSE);
// Check if we should ENCODE it again;
foreach ($_SESSION['POST'] as $k => $v) {
if (!$_SESSION['POST'][$k] instanceof S) {
$objDoEncodeAgain = new B(TRUE);
break;
}
}
if ($objDoEncodeAgain->toBoolean() == TRUE) {
foreach ($_SESSION['POST'] as $k => $v) {
// Do the samba ...
$v = new S($v);
$_SESSION['POST'][$k] = $v;
# REMEMBER ME: Could help, at searching with QUOTES,
# to do an encoding, and stripslashes afterwards; TO BE TRIED;
# Code: $_SESSION['POST'][$k] = $v->entityDecode (ENT_QUOTES)->stripSlashes ();
}
}
}
}
示例11: renderForm
/**
* Will render a specified form, the name of the form given by the first parameter;
*
* This method will render one of the forms for our object, invoked by giving the proper form identifier to the current form. We
* have chosen this method of invoking forms, because we just had too many this->renderSomethingMethod (), which really had
* an impact on code massiveness. Also, having code organized in switch/case statements leads us to be able to share common
* settings between different forms, as we've done with the methods defined in the __CALL method above;
*
* For example, if we wanted to share some common configuration between a create and an edit form, we could have introduced
* two switches in this method, one that would have set the common options, and the second, would have just passed through
* again, and get the already set configuration options, using them. This means that if we needed to change behavior of
* some interconnected forms, that would mean modifying the needed code one place only, which is a big advantage over
* having separated methods for each form. Maybe if we extended this object, you guys could understand the functionality better;
*
* @param string $objFormToRender The name of the form to render;
* @return mixed Depends on the rendered form if it returns something or not;
*/
public function renderForm(S $objFormToRender, A $objFormArray = NULL)
{
// Make them defaults ...
if ($objFormArray == NULL) {
$objFormArray = new A();
}
// Do a switch ...
switch ($objFormToRender) {
case 'widgetSearch':
// Do the form, make it happen ...
$this->setMethod(new S('POST'))->setName($objFormToRender);
// Do some work ...
if ($this->checkPOST(new S('search_lyrics'))->toBoolean() == TRUE) {
// Get the title, and check it's name ...
if ($this->getPOST(new S('lyrics_search_keyword'))->toLength()->toInt() == 0) {
// Well, sadly, we have an issue ...
$this->setErrorOnInput(new S('lyrics_search_keyword'), new S('Nu ai completat cautarea!'));
} else {
// Go ...
$this->setHeaderKey($objURLToGoBack = URL::staticURL(new A(array(FRONTEND_SECTION_URL, LYRICS_SEARCH_URL)), new A(array(FRONTEND_LYRICS_URL, $this->getPOST(new S('lyrics_search_keyword'))->entityDecode(ENT_QUOTES)->stripSlashes()))), new S('Location'));
}
}
// Continue ...
$this->setInputType(new S('text'))->setName(new S('lyrics_search_keyword'));
// If it's set ... add the VALUE ...
if (isset($_GET[LYRICS_SEARCH_URL])) {
$this->setValue($_GET[LYRICS_SEARCH_URL]);
}
// Continue ...
$this->setLabel(new S('Cuvant'))->setContainerDiv(new B(TRUE))->setInputType(new S('submit'))->setName(new S('search_lyrics'))->setValue(new S('Cauta'))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE));
break;
case 'lyricCreate':
// The URL to go back too;
$objURLToGoBack = URL::rewriteURL();
$objErrorHappen = new B(FALSE);
// Do some work;
if ($this->checkPOST(self::$objLyricsTableFTitle)->toBoolean() == TRUE) {
// Check != 0 ...
if ($this->getPOST(self::$objLyricsTableFTitle)->toLength()->toInt() == 0) {
self::setErrorOnInput(self::$objLyricsTableFTitle, new S(LYRICS_TITLE_CANNOT_BE_EMPTY));
$objErrorHappen = new B(TRUE);
}
}
if ($this->checkPOST(self::$objLyricsTableFArtist)->toBoolean() == TRUE) {
// Check != 0 ...
if ($this->getPOST(self::$objLyricsTableFArtist)->toLength()->toInt() == 0) {
self::setErrorOnInput(self::$objLyricsTableFArtist, new S(LYRICS_ARTIST_CANNOT_BE_EMPTY));
$objErrorHappen = new B(TRUE);
}
}
if ($this->checkPOST(self::$objLyricsTableFAlbum)->toBoolean() == TRUE) {
// Check != 0 ...
if ($this->getPOST(self::$objLyricsTableFAlbum)->toLength()->toInt() == 0) {
self::setErrorOnInput(self::$objLyricsTableFAlbum, new S(LYRICS_ALBUM_CANNOT_BE_EMPTY));
$objErrorHappen = new B(TRUE);
}
}
// Get AJAX;
$this->getAjaxErrors();
// Do the form, make it happen;
$this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(LYRICS_ADD_LYRIC))->setSQLAction(new S('update'))->setTableName(self::$objLyricsTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objLyricsTableFId)->setExtraUpdateData(self::$objLyricsTableFDateAdded, new S((string) $_SERVER['REQUEST_TIME']));
if ($this->checkPOST(self::$objLyricsTableFTitle)->toBoolean() == TRUE && $objErrorHappen->toBoolean() == FALSE) {
$this->setExtraUpdateData(self::$objLyricsTableFSEO, URL::getURLFromString(new S($this->getPOST(self::$objLyricsTableFTitle) . _U . $this->getPOST(self::$objLyricsTableFArtist) . _U . $this->getPOST(self::$objLyricsTableFAlbum) . _U . $_SERVER['REQUEST_TIME'])));
}
$this->setName($objFormToRender)->setRedirect($objURLToGoBack)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setInputInfoMessage($this->getHELP($objFormToRender))->setValue(new S(LYRICS_ADD_LYRIC))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objLyricsTableFTitle)->setLabel(new S(LYRICS_TITLE))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objLyricsTableFArtist)->setLabel(new S(LYRICS_ARTIST))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objLyricsTableFAlbum)->setLabel(new S(LYRICS_ALBUM))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objLyricsTableFLyrics)->setLabel(new S(LYRICS_LYRIC))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE));
break;
case 'lyricEdit':
// The URL to go back too;
$objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID)));
$objErrorHappen = new B(FALSE);
// Do some work;
if ($this->checkPOST(self::$objLyricsTableFTitle)->toBoolean() == TRUE) {
// Check != 0 ...
if ($this->getPOST(self::$objLyricsTableFTitle)->toLength()->toInt() == 0) {
self::setErrorOnInput(self::$objLyricsTableFTitle, new S(LYRICS_TITLE_CANNOT_BE_EMPTY));
$objErrorHappen = new B(TRUE);
}
}
if ($this->checkPOST(self::$objLyricsTableFArtist)->toBoolean() == TRUE) {
// Check != 0 ...
if ($this->getPOST(self::$objLyricsTableFArtist)->toLength()->toInt() == 0) {
self::setErrorOnInput(self::$objLyricsTableFArtist, new S(LYRICS_ARTIST_CANNOT_BE_EMPTY));
$objErrorHappen = new B(TRUE);
//.........这里部分代码省略.........