本文整理汇总了PHP中URL::staticURL方法的典型用法代码示例。如果您正苦于以下问题:PHP URL::staticURL方法的具体用法?PHP URL::staticURL怎么用?PHP URL::staticURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类URL
的用法示例。
在下文中一共展示了URL::staticURL方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderWidget
/**
* Will render a requested widget;
*
* This method is used to render a widget that usually is used in the frontend part of any website done with the help of this
* platform. What are widgets you ask?! Well, it's quite simple. They are pieces of PHP code, usually tied to some
* configuration options that control the way the widget functions or showns;
*
* Usually, configured widgets have enough power to be used in any way you want or need. For most of the times, the widgets
* are called in the proper section of the frontend, but this method must permit the use of widgets, independent of the place
* the developer needs them;
*
* @param $objW The widget to render;
* @return mixed Depends on the widget;
*/
public function renderWidget(S $objW, A $objWA = NULL)
{
// Make an empty array if NULL ...
if ($objWA == NULL) {
$objWA = new A();
}
// XML & RSS: Do a switch ...
switch ($objW) {
case 'widgetXML':
// BK;
break;
case 'widgetRSS':
// BK;
break;
}
// HTML: Do a switch ...
switch ($objW) {
case 'widgetCategoryList':
// Set some requirements ...
if ($objWA == NULL) {
$objWA = new A();
}
// Get the category to start from ...
if (isset($objWA['start_from_category'])) {
// Get the category LIST;
$objCategoryList = $this->getCategories(NULL, $objWA['start_from_category']);
} else {
// Get the category LIST;
$objCategoryList = $this->getCategories(NULL, NULL);
}
// Set the template file ...
$tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION);
TPL::tpSet($objCategoryList, new S('objCategoryList'), $tpF);
TPL::tpSet($objWA, new S('objWidgetArray'), $tpF);
TPL::tpSet($this, new S('ART'), $tpF);
TPL::tpExe($tpF);
break;
case 'widgetList':
// Check some needed requirements ...
if ($_GET[FRONTEND_SECTION_URL] == FRONTEND_PRODUCTS_URL) {
// Set some requirements ...
$objPag = isset($_GET[PRODUCTS_PAGE_URL]) ? $_GET[PRODUCTS_PAGE_URL] : new S((string) 1);
if (isset($_GET[PRODUCTS_ITEM_URL])) {
// Check that the article exists, before doing anything stupid ...
if ($this->checkProductURLIsUnique($objURL = $_GET[PRODUCTS_ITEM_URL])->toBoolean() == TRUE) {
// Make the proper header, at first ...
$this->setHeaderStr(new S(HDR::HEADER_404_NOT_FOUND));
// Give me back my free hardcore, Quoth the server, '404' ...
$this->setHeaderKey(URL::staticURL(new A(array(FRONTEND_ERROR_URL)), new A(array('404'))), new S('Location'));
} else {
// Do me SEO, yah baby! ...
TPL::manageTTL($this->getProductInfoByURL($objURL, self::$objProductsTableFName));
TPL::manageTAG(new S('description'), $this->getProductInfoByURL($objURL, self::$objProductsTableFDescription)->entityDecode(ENT_QUOTES)->stripTags()->doToken(_QOT, _NONE));
// Set some requirements ...
$objPathToItem = self::$objMPTT->mpttGetSinglePath($this->getCategoryInfoById($this->getProductInfoByURL($objURL, self::$objProductsTableFCategoryId), self::$objCategoryTableFName));
$objItemPpties = $this->getPropertiesByProductURL($objURL);
$objItemImages = $this->getImagesByProductURL($objURL);
if ($objItemImages->doCount()->toInt() != 0) {
$objItemHasImg = new B(TRUE);
} else {
$objItemHasImg = new B(FALSE);
}
// Set the template file ...
$tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . '-Item.tp');
TPL::tpSet($objPathToItem, new S('objPathToItem'), $tpF);
TPL::tpSet($objItemPpties, new S('objItemPpties'), $tpF);
TPL::tpSet($objItemImages, new S('objItemImages'), $tpF);
TPL::tpSet($objItemHasImg, new S('objItemHasImg'), $tpF);
TPL::tpSet($objWA, new S('objWidgetArray'), $tpF);
TPL::tpSet($objURL, new S('objURL'), $tpF);
TPL::tpSet($this->ATH, new S('ATH'), $tpF);
TPL::tpSet($this->STG, new S('STG'), $tpF);
TPL::tpSet($this, new S('PRD'), $tpF);
TPL::tpExe($tpF);
}
} else {
if (isset($_GET[PRODUCTS_CATEGORY_URL])) {
// Check that the category exists, before doing anything stupid ...
if ($this->checkCategoryURLIsUnique($objCat = $_GET[PRODUCTS_CATEGORY_URL])->toBoolean() == TRUE) {
// Make the proper header, at first ...
$this->setHeaderStr(new S(HDR::HEADER_404_NOT_FOUND));
// Give me back my free hardcore, Quoth the server, '404' ...
$this->setHeaderKey(URL::staticURL(new A(array(FRONTEND_ERROR_URL)), new A(array('404'))), new S('Location'));
} else {
// Do me SEO, yah baby! ...
err('Here');
//.........这里部分代码省略.........
示例2: renderWidget
/**
* Will render a requested widget;
*
* This method is used to render a widget that usually is used in the frontend part of any website done with the help of this
* platform. What are widgets you ask?! Well, it's quite simple. They are pieces of PHP code, usually tied to some
* configuration options that control the way the widget functions or showns;
*
* Usually, configured widgets have enough power to be used in any way you want or need. For most of the times, the widgets
* are called in the proper section of the frontend, but this method must permit the use of widgets, independent of the place
* the developer needs them;
*
* @param $objW The widget to render;
* @return mixed Depends on the widget;
*/
public function renderWidget(S $objW, A $objWA = NULL)
{
// Make an empty array if NULL ...
if ($objWA == NULL) {
$objWA = new A();
}
// XML & RSS: Do a switch ...
switch ($objW) {
case 'widgetXML':
// Yo man ... woohoooooo ...
foreach ($this->getPublishedArticles(new S('ORDER
BY %objArticleTableFDatePublished DESC')) as $k => $v) {
// Set some requirements ...
$objDTE = date('Y-m-d', (int) $v[self::$objArticleTableFDatePublished]->toString());
$objLOC = URL::staticURL(new A(array(ARTICLES_ARTICLES_URL, FRONTEND_SECTION_URL)), new A(array($v[self::$objArticleTableFSEO], FRONTEND_ARTICLE_URL)));
// Get the (INNER) CHILD of every young SEO freak ...
$objURL = $objWA['objXML']->addCHILD(Frontend::XML_URL);
// Set the XML Sitemap kids ...
$objURL->addCHILD(Frontend::XML_LOCATION, $objLOC);
$objURL->addCHILD(Frontend::XML_LAST_MOD, $objDTE);
$objURL->addCHILD(Frontend::XML_CHANGE_FREQ, self::XML_SITEMAP_FREQUENCY);
$objURL->addCHILD(Frontend::XML_PRIORITY, self::XML_SITEMAP_PRIORITY);
}
// BK;
break;
case 'widgetRSS':
// Yo man ... woohoooooo ...
if ($_GET[FRONTEND_FEED_URL] == __CLASS__) {
// Get'em 30 ...
foreach ($this->getPublishedArticles(new S('ORDER BY %objArticleTableFDatePublished
DESC LIMIT 0, 30')) as $k => $v) {
// Set some requirements ...
$objDTE = date(DATE_RFC822, (int) $v[self::$objArticleTableFDatePublished]->toString());
$objLOC = URL::staticURL(new A(array(ARTICLES_ARTICLES_URL, FRONTEND_SECTION_URL)), new A(array($v[self::$objArticleTableFSEO], FRONTEND_ARTICLE_URL)));
$objDSC = $v[self::$objArticleTableFExcerpt]->entityEncode(ENT_QUOTES)->entityDecode(ENT_QUOTES)->stripTags();
$objTTL = $v[self::$objArticleTableFTitle];
// Get the (INNER) CHILD of every young SEO freak ...
$objURL = $objWA['objXML']->addCHILD(Frontend::RSS_ITEM);
// Set the RSS kids ...
$objURL->addCHILD(Frontend::RSS_TITLE, $objTTL);
$objURL->addCHILD(Frontend::RSS_LINK, $objLOC);
$objURL->addCHILD(Frontend::RSS_GUID, $objLOC);
$objURL->addCHILD(Frontend::RSS_PUBLISHED_DATE, $objDTE);
$objURL->addCHILD(Frontend::RSS_DESCRIPTION, $objDSC);
}
}
// BK;
break;
}
// HTML: Do a switch ...
switch ($objW) {
case 'widgetCategoryList':
// Set the template file ...
if ($cId = TPL::tpIni($tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION), new I(180))) {
// Get the category to start from ...
if (isset($objWA['start_from_category'])) {
// Get the category LIST;
$objCategoryList = $this->getCategories(NULL, $objWA['start_from_category']);
} else {
// Get the category LIST;
$objCategoryList = $this->getCategories(NULL, NULL);
}
// Set the template file ...
TPL::tpSet($objCategoryList, new S('objCategoryList'), $tpF);
TPL::tpSet($objWA, new S('objWidgetArray'), $tpF);
TPL::tpSet($this, new S('ART'), $tpF);
TPL::tpExe($tpF);
TPL::tpEnd($cId);
}
// BK;
break;
case 'widgetList':
// Check some needed requirements ...
if ($_GET[FRONTEND_SECTION_URL] == FRONTEND_ARTICLE_URL) {
// Set some requirements ...
$objPag = isset($_GET[ARTICLES_PAGE_URL]) ? $_GET[ARTICLES_PAGE_URL] : new S((string) 1);
if (isset($_GET[ARTICLES_ARTICLES_URL])) {
// Check that the article exists, before doing anything stupid ...
if ($this->checkArticleURLIsUnique($objURL = $_GET[ARTICLES_ARTICLES_URL])->toBoolean() == TRUE) {
// Make the proper header, at first ...
$this->setHeaderStr(new S(HDR::HEADER_404_NOT_FOUND));
// Give me back my free hardcore, Quoth the server, '404' ...
$this->setHeaderKey(URL::staticURL(new A(array(FRONTEND_ERROR_URL)), new A(array('404'))), new S('Location'));
} else {
// Update them views ...
$this->_Q(_QS('doUPDATE')->doToken('%table', self::$objArticleTable)->doToken('%condition', _S('%objArticleTableFViews = %objArticleTableFViews + 1
//.........这里部分代码省略.........
示例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.
* 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;
//.........这里部分代码省略.........
示例5: renderWidget
/**
* Will render a requested widget;
*
* This method is used to render a widget that usually is used in the frontend part of any website done with the help of this
* platform. What are widgets you ask?! Well, it's quite simple. They are pieces of PHP code, usually tied to some
* configuration options that control the way the widget functions or showns;
*
* Usually, configured widgets have enough power to be used in any way you want or need. For most of the times, the widgets
* are called in the proper section of the frontend, but this method must permit the use of widgets, independent of the place
* the developer needs them;
*
* @param $objW The widget to render;
* @return mixed Depends on the widget;
*/
public function renderWidget(S $objW, A $objWA = NULL)
{
// Make an empty array if NULL ...
if ($objWA == NULL) {
$objWA = new A();
}
// XML & RSS: Do a switch ...
switch ($objW) {
case 'widgetXML':
// Yo man ... woohoooooo ...
foreach ($this->getTexts(new S('ORDER
BY %objTextTableFDatePublished DESC')) as $k => $v) {
// Set some requirements ...
$objSEC = $this->getCategoryInfoById($v[self::$objTextTableFCategoryId], self::$objCategoryTableFSEO);
$objDTE = date('Y-m-d', (int) $v[self::$objTextTableFDatePublished]->toString());
$objLOC = URL::staticURL(new A(array(TEXTS_TEXTS_URL, FRONTEND_SECTION_URL)), new A(array($v[self::$objTextTableFSEO], $objSEC)));
// Get the (INNER) CHILD of every young SEO freak ...
$objURL = $objWA['objXML']->addCHILD(Frontend::XML_URL);
// Set the XML Sitemap kids ...
$objURL->addCHILD(Frontend::XML_LOCATION, $objLOC);
$objURL->addCHILD(Frontend::XML_LAST_MOD, $objDTE);
$objURL->addCHILD(Frontend::XML_CHANGE_FREQ, self::XML_SITEMAP_FREQUENCY);
$objURL->addCHILD(Frontend::XML_PRIORITY, self::XML_SITEMAP_PRIORITY);
}
// BK;
break;
case 'widgetRSS':
// Yo man ... woohoooooo ...
if ($_GET[FRONTEND_FEED_URL] == __CLASS__) {
// Get'em 30 ...
foreach ($this->getTexts(new S('ORDER BY %objTextTableFDatePublished
DESC LIMIT 0, 30')) as $k => $v) {
// Set some requirements ...
$objSEC = $this->getCategoryInfoById($v[self::$objTextTableFCategoryId], self::$objCategoryTableFSEO);
$objDTE = date(DATE_RFC822, (int) $v[self::$objTextTableFDatePublished]->toString());
$objLOC = URL::staticURL(new A(array(TEXTS_TEXTS_URL, FRONTEND_SECTION_URL)), new A(array($v[self::$objTextTableFSEO], $objSEC)));
$objDSC = $v[self::$objTextTableFContent]->entityEncode(ENT_QUOTES)->entityDecode(ENT_QUOTES)->stripTags();
$objTTL = $v[self::$objTextTableFTitle];
// Get the (INNER) CHILD of every young SEO freak ...
$objURL = $objWA['objXML']->addCHILD(Frontend::RSS_ITEM);
// Set the RSS kids ...
$objURL->addCHILD(Frontend::RSS_TITLE, $objTTL);
$objURL->addCHILD(Frontend::RSS_LINK, $objLOC);
$objURL->addCHILD(Frontend::RSS_GUID, $objLOC);
$objURL->addCHILD(Frontend::RSS_PUBLISHED_DATE, $objDTE);
$objURL->addCHILD(Frontend::RSS_DESCRIPTION, $objDSC);
}
}
// BK;
break;
}
// HTML: Do a switch ...
switch ($objW) {
case 'widgetCategoryList':
// Set some requirements, if not set ...
if ($objWA == NULL) {
$objWA = new A();
}
// Get the category to start from ...
if (isset($objWA['start_from_category'])) {
// Get the category LIST;
$objCategoryList = $this->getCategories(NULL, $objWA['start_from_category']);
} else {
// Get the category LIST;
$objCategoryList = $this->getCategories(NULL, NULL);
}
// Set the template file ...
$tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION);
TPL::tpSet($objCategoryList, new S('objCategoryList'), $tpF);
TPL::tpSet($objWA, new S('objWidgetArray'), $tpF);
TPL::tpSet($this, new S('TXT'), $tpF);
TPL::tpExe($tpF);
break;
case 'widgetList':
// Do some checking ... before anything ...
if (isset($_GET[TEXTS_TEXTS_URL])) {
// Check or redirect ...
if ($this->checkTextExistsByURL($_GET[TEXTS_TEXTS_URL])->toBoolean() == FALSE) {
// The text does not exist, than redirect to 404;
$this->setHeaderStr(new S(HDR::HEADER_MOVED_PERMANENTLY));
$this->setHeaderKey(URL::staticURL(new A(array(FRONTEND_ERROR_URL)), new A(array('404'))), new S('Location'));
} else {
// Get the TEXT ...
$objTextCNT = $this->getTextInfoByURL($_GET[TEXTS_TEXTS_URL], self::$objTextTableFContent);
$objTextTTL = $this->getTextInfoByURL($_GET[TEXTS_TEXTS_URL], self::$objTextTableFTitle);
$objTextKEY = $this->getTextInfoByURL($_GET[TEXTS_TEXTS_URL], self::$objTextTableFTags);
//.........这里部分代码省略.........
示例6: 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);
//.........这里部分代码省略.........
示例7: renderFrontendPage
/**
* 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 renderFrontendPage(S $objPageToRender, S $objTypeSwitcher)
{
// Do a switch on the rendered page ...
switch ($objTypeSwitcher) {
// Authentication ... and stuff;
case FRONTEND_AUTHENTICATION_URL:
// Check the mighty authenticate ...
if (isset($_GET[AUTHENTICATION_ACTION_URL])) {
// Do a switch ...
switch ($_GET[AUTHENTICATION_ACTION_URL]) {
case AUTHENTICATION_REGISTER_URL:
// Set the template file ...
$tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'users-register.tp');
break;
case AUTHENTICATION_ACTIVATE_URL:
// Set the template file ...
$tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'users-activate.tp');
break;
case AUTHENTICATION_PROFILE_URL:
// Set the template file ...
$tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'users-profile.tp');
break;
case AUTHENTICATION_LOGOUT_URL:
// Log me OUT my wuv ...
$this->ATH->doLogOut();
// Get me HOME ... I'm LOST here ...
$this->setHeaderKey(URL::staticURL(new A(array(FRONTEND_SECTION_URL)), new A(array(FRONTEND_HOME))), new S('Location'));
break;
case AUTHENTICATION_YAHOO_BB_AUTH:
return $this->renderWidget(new S(AUTHENTICATION_YAHOO_BB_AUTH));
break;
}
} else {
// Set the template file ...
$tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'users.tp');
}
// Go my baby ... GO ...
TPL::tpSet($this->objURLImageDir, new S('objURLImageDir'), $tpF);
TPL::tpSet($this->ATH, new S('ATH'), $tpF);
TPL::tpSet($this->STG, new S('STG'), $tpF);
TPL::tpSet($this->TXT, new S('TXT'), $tpF);
TPL::tpSet($this->ART, new S('ART'), $tpF);
TPL::tpSet($this->AUD, new S('AUD'), $tpF);
TPL::tpSet($this->CNT, new S('CNT'), $tpF);
TPL::tpSet($this->FAQ, new S('FAQ'), $tpF);
TPL::tpSet($this->LRQ, new S('LRQ'), $tpF);
TPL::tpExe($tpF);
break;
case FRONTEND_ARTICLE_URL:
// Go my baby ... GO ...
$tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'news.tp');
TPL::tpSet($this->objURLImageDir, new S('objURLImageDir'), $tpF);
TPL::tpSet($this->ATH, new S('ATH'), $tpF);
TPL::tpSet($this->STG, new S('STG'), $tpF);
TPL::tpSet($this->TXT, new S('TXT'), $tpF);
TPL::tpSet($this->ART, new S('ART'), $tpF);
TPL::tpSet($this->AUD, new S('AUD'), $tpF);
TPL::tpSet($this->CNT, new S('CNT'), $tpF);
TPL::tpSet($this->FAQ, new S('FAQ'), $tpF);
TPL::tpSet($this->LRQ, new S('LRQ'), $tpF);
TPL::tpExe($tpF);
break;
case FRONTEND_CONTACT_URL:
// Go my baby ... GO ...
$tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'contact.tp');
TPL::tpSet($this->objURLImageDir, new S('objURLImageDir'), $tpF);
TPL::tpSet($this->ATH, new S('ATH'), $tpF);
TPL::tpSet($this->STG, new S('STG'), $tpF);
TPL::tpSet($this->TXT, new S('TXT'), $tpF);
TPL::tpSet($this->ART, new S('ART'), $tpF);
TPL::tpSet($this->AUD, new S('AUD'), $tpF);
TPL::tpSet($this->CNT, new S('CNT'), $tpF);
TPL::tpSet($this->FAQ, new S('FAQ'), $tpF);
TPL::tpSet($this->LRQ, new S('LRQ'), $tpF);
TPL::tpExe($tpF);
break;
case FRONTEND_FAQ_URL:
// Go my baby ... GO ...
$tpF = new FilePath($this->getPathToSkin()->toRelativePath() . 'faq.tp');
TPL::tpSet($this->objURLImageDir, new S('objURLImageDir'), $tpF);
TPL::tpSet($this->ATH, new S('ATH'), $tpF);
TPL::tpSet($this->STG, new S('STG'), $tpF);
TPL::tpSet($this->TXT, new S('TXT'), $tpF);
//.........这里部分代码省略.........