本文整理汇总了PHP中S::toString方法的典型用法代码示例。如果您正苦于以下问题:PHP S::toString方法的具体用法?PHP S::toString怎么用?PHP S::toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类S
的用法示例。
在下文中一共展示了S::toString方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getStickyArticlesByCategoryURLAndPage
/**
* Will return sticky articles by the given category name, page and sorting;
*
* This method will return all articles in the given combination of category name and page limits. It can be used to display
* articles in a category like manner by just giving two parameters obligatory. It can be used for article pages, where a
* string of articles is needed to be displayed;
*
* @param S $objCategoryURL The category URL;
* @param S $objPageInt The page to limit to;
* @param S $objOrdering What kind of ordering;
* @return array The result array;
*/
public function getStickyArticlesByCategoryURLAndPage(S $objCategoryURL, S $objPageInt, S $objOrdering = NULL)
{
// Do return ...
return $this->getArticlesByCategoryURL($objCategoryURL, _S('AND %objArticleTableFState = "%Sd"
ORDER BY %objArticleTableFDatePublished %TypeOfOrdering LIMIT %LowerLimit, %UpperLimit')->doToken('%LowerLimit', ((int) $objPageInt->toString() - 1) * (int) self::$objItemsPerPage->toString())->doToken('%UpperLimit', (int) self::$objItemsPerPage->toString())->doToken('%TypeOfOrdering', $objOrdering == NULL ? new S('DESC') : $objOrdering)->doToken('%Sd', self::STATE_STICKY));
}
示例2: writeHTFile
/**
* Writes the .htaccess file only if there is a difference between the current imploded string and the file source. This method is
* a private method used to write the .htaccess file only if there is a difference between the imploded string (from the internal
* htArray variable) and the file source. If the two strings differ, then we rewrite the .htaccess file.
*
* @param S $htString The string, parsed from file array to be written
* @return B Will return true if the file was written
* @author Catalin Z. Alexandru <catalin.zamfir@raphpframework.ro>
* @copyright Under the terms of the GNU General Public License v3
* @version $Id: 07_APC.php 313 2009-10-09 13:27:52Z catalin.zamfir $
* @since Version 1.0
* @access private
* @static
*/
private static function writeHTFile(S $htString)
{
// Do a quick .htaccess write;
if ($htFile = fopen(DOCUMENT_ROOT . '.htaccess', 'w')) {
fwrite($htFile, $htString->toString());
fclose($htFile);
// Do return ...
return new B(TRUE);
} else {
// Error me proudly;
self::renderScreenOfDeath(new S(__CLASS__), new S(CANNOT_WRITE_HTACCESS), new S(CANNOT_WRITE_HTACCESS_FIX));
}
}
示例3: associativeFromURL
/**
* Will parse the URL into an associative array. This method will get the current URL string and parse it in an associative array
* that we can then insert in the _GET superglobal to work with. It's an internal private method not used by non-core developers.
*
* @param I $segmentNumber The number of the segment to get from;
* @return A The associative array, parsed from the URL, as key/var pairs;
* @author Elena Ramona <no_reply@raphpframework.ro>
* @copyright Under the terms of the GNU General Public License v3
* @version $Id: 09_URL.php 313 2009-10-09 13:27:52Z catalin.zamfir $
* @since Version 1.0
* @access private
* @static
* @final
*/
private static final function associativeFromURL(I $segmentNumber)
{
$getURLSegments = new A(array_slice(self::$objGETURLSegment->toArray(), $segmentNumber->toInt() - 1));
$i = new I(0);
$lastURLVar = new S(_NONE);
$returnedArray = new A();
foreach ($getURLSegments as $v) {
if ($i->toInt() % 2) {
$returnedArray[$lastURLVar->toString()] = $v;
} else {
$returnedArray[$v] = new B(FALSE);
$lastURLVar->setString($v);
}
// Increment;
$i->doInc();
}
// Do return ...
return $returnedArray;
}
示例4: getProductsByPage
public function getProductsByPage(S $objPageInt, S $objOrdering = NULL)
{
// Do return ...
return $this->getProducts(_S('ORDER BY %objProductsTableFId %TypeOfOrdering LIMIT %LowerLimit, %UpperLimit')->doToken('%LowerLimit', ((int) $objPageInt->toString() - 1) * (int) self::$objItemsPerPage->toString())->doToken('%UpperLimit', (int) self::$objItemsPerPage->toString())->doToken('%TypeOfOrdering', $objOrdering == NULL ? new S('DESC') : $objOrdering));
}
示例5: unsetSessionVar
/**
* Will unset a _SESSION variable, checking that it has been set first. To actually unset a _SESSION variable you need to make sure
* that the variable was set at first, or this function would just execute and return FALSE. We provide it as an OOP way to manage
* the _SESSION superglobal in a way that gives the developer more control over the data stored in the _SESSION;
*
* @param S $theKey The key to be set in the _SESSION
* @return B Will return true if the key/var pair are set
* @author Catalin Z. Alexandru <catalin.zamfir@raphpframework.ro>
* @copyright Under the terms of the GNU General Public License v3
* @version $Id: 06_SES.php 313 2009-10-09 13:27:52Z catalin.zamfir $
* @since Version 1.0
* @access protected
* @static
* @final
*/
protected static final function unsetSessionVar(S $theKey)
{
if (isset($_SESSION[PROJECT_NAME . _U . $theKey->toString()])) {
$_SESSION[PROJECT_NAME . _U . $theKey->toString()] = _NONE;
unset($_SESSION[PROJECT_NAME . _U . $theKey->toString()]);
// Do return ...
return new B(TRUE);
} else {
// Do return ...
return new B(FALSE);
}
}
示例6: tpSet
/**
* Will set an object variable in the .php file to be extracted in the .tp file, and used there. This method, similar to the
* popular Smarty->assign, is the method that will assign variables to the template file to be executed. You need to specify
* the name of the variable inside the execution loop;
*
* @param M $tpVar The variable to be set for the current .tp
* @param S $tpVarString The name of the variable that will be set
* @param S $tpFileName Path to the .tp file where to set the requested variables
* @param S $tpAction What action to take on the variable
* @return M Will return a mixed result (either false/true or string, depends)
* @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 tpSet(M $tpVar, S $tpVarString, FilePath $tpFileName, S $tpAction = NULL)
{
// Set .tp vars;
if ($tpFileName->checkPathExists()) {
// Set the variable, taking tpAction in consideration;
if ($tpAction != NULL) {
switch ($tpAction->toString()) {
case 'capitalize':
// Make it an S, so we can be sure it's a string;
$tpVar = new S($tpVar);
// Capitalize it, with strtoupper ();
self::$objFilePathArray[$tpFileName][$tpVarString] = $tpVar->toUpper();
break;
case 'explode':
if ($tpVar instanceof A) {
foreach ($tpVar as $k => $v) {
// Parse every array key as a .tp variable;
self::$objFilePathArray[$tpFileName][$k] = $v;
}
} else {
self::renderScreenOfDeath(new S(__CLASS__), new S(CANNOT_WORK_ON_NON_ARRAY), new S(CANNOT_WORK_ON_NON_ARRAY_FIX));
}
break;
#################################################################
# Define other actions here!
}
} else {
// Set an unmodified var, as-is;
self::$objFilePathArray[$tpFileName][$tpVarString] = $tpVar;
}
} else {
self::renderScreenOfDeath(new S(__CLASS__), new S(FILE_DOESNT_EXIST), new S(FILE_DOESNT_EXIST_FIX));
}
}
示例7: 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->getApprovedAudioFiles(new S('ORDER
BY %objAudioTableFUploadedDate DESC')) as $k => $v) {
// Set some requirements ...
$objDTE = date('Y-m-d', (int) $v[self::$objAudioTableFUploadedDate]->toString());
$objLOC = URL::staticURL(new A(array(AUDIO_ITEM_URL, FRONTEND_SECTION_URL)), new A(array($v[self::$objAudioTableFSEO], FRONTEND_AUDIO_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->getApprovedAudioFiles(new S('ORDER BY %objAudioTableFUploadedDate
DESC LIMIT 0, 30')) as $k => $v) {
// Set some requirements ...
$objDTE = date(DATE_RFC822, (int) $v[self::$objAudioTableFUploadedDate]->toString());
$objLOC = URL::staticURL(new A(array(AUDIO_ITEM_URL, FRONTEND_SECTION_URL)), new A(array($v[self::$objAudioTableFSEO], FRONTEND_AUDIO_URL)));
$objTTL = $v[self::$objAudioTableFTitle]->appendString(_DCSP)->appendString($v[self::$objAudioTableFArtist])->appendString(_DCSP)->appendString($v[self::$objAudioTableFAlbum]);
$objDSC = $v[self::$objAudioTableFDescription]->entityEncode(ENT_QUOTES)->entityDecode(ENT_QUOTES)->stripTags();
// 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 (isset($objWA['cache_file'])) {
// Take the input;
$objCacheFile = $objWA['cache_file'];
} else {
// Do cache me ...
$objCacheFile = new B(TRUE);
}
if (isset($objWA['cache_time'])) {
// Get the cache time from me;
$objCacheTime = $objWA['cache_time'];
} else {
// Do a cache for: 6 hours;
$objCacheTime = new I(60 * 60 * 6);
}
// Set the template file ...
if ($cId = TPL::tpIni($tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION), $objCacheTime, $objCacheFile)) {
// 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('AUD'), $tpF);
TPL::tpExe($tpF);
TPL::tpEnd($cId);
}
// BK;
break;
//.........这里部分代码省略.........
示例8: unSetKey
/**
* Will unset the given key;
*
* This method, after we are done with our information will clear the cookie information stored at that key. This for example,
* in the authentication module will deauthenticate the user. Other uses can be thought of in other modules;s
*
* @param S $objKey The key to unset;
* @return boolean Will return true if it was able to unset the key;
*/
public function unSetKey(S $objKey)
{
switch ($this->objObjectCookie->getConfigKey(new S('authentication_cookie_store_type'))) {
case 'cookie':
// Trigger the browser cookie cleaning mechanism;
$expTme = new I($_SERVER['REQUEST_TIME'] - 31556926);
// Re-set the cookie;
setcookie($this->objProjectString . _U . $this->objObjectCookie->getObjectCLASS() . _U . $objKey, new S(), $expTme->toInt(), new S('/'));
break;
case 'session':
// Do unset ...
unset($_SESSION[$this->objProjectString->toString()][$this->objObjectCookie->getObjectCLASS()->toString()][$objKey->toString()]);
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;
}
// Do return ...
return new B(TRUE);
}
示例9: getQuery
/**
* Will return a MySQL Resource, containing the result of the passed SQL. This method will query the database and return the
* MySQL resource which will get processed and transformed into a specifc RA array (A) that you can then access for information
* you actually need;
*
* @param S $queryString The query string to be queried
* @param S $queryField The field name (unique) to index by
* @return A The returned query resource
* @author Catalin Z. Alexandru <catalin.zamfir@raphpframework.ro>
* @copyright Under the terms of the GNU General Public License v3
* @version $Id: 11_SQL.php 313 2009-10-09 13:27:52Z catalin.zamfir $
* @since Version 1.0
* @access public
* @static
*/
public static function getQuery(S $queryString, S $queryFieldId = NULL)
{
// Get the MySQL result, or go an echo an error screen if it failed ...
$queryResource = new O(mysql_query($queryString->doToken(SQL_PREFIX, self::$objSQLR)));
// Do another checking for FALSE, and return what's needed ...
if ($queryResource->checkIs('res')->toBoolean()) {
$queryResourceSet = new R($queryResource->toMix());
$arrayResourceSet = new A();
if ($queryFieldId == NULL) {
// Set the indexer to minus 1, so we can ++i;
$i = -1;
// Do the looping ...
while ($r = self::getQueryResultRow($queryResourceSet)) {
// MySQL: Numeric ...
$arrayResourceSet[++$i] = $r;
}
// Just do it;
return $arrayResourceSet;
} else {
// Do the looping ...
while ($r = self::getQueryResultRow($queryResourceSet)) {
// MySQL: Associative ...
$arrayResourceSet[$r[$queryFieldId->toString()]] = $r;
}
// Just return, we know what it is;
return $arrayResourceSet;
}
} else {
if ($queryResource->checkIs('bln')->toBoolean()) {
if ($queryResource->toMix() == TRUE) {
// Return TRUE, is not a resource ...
return new B(TRUE);
} else {
// Return FALSE, output error screen;
self::renderSQLScreenOfDeath();
}
}
}
}
示例10: setHeaderKey
/**
* Will set a key/var pair, like 'gzip', 'Content-encoding'. We use such a method so we can have a single point where we can globally
* modify the way our headers are sent to the browser or the client, thus having control over what's done and in what circumstances,
* as the HTTP protocol works by sending and receiving headers, mechanism that is the SOUL of our Web-enabled applications;
* <code>
* <?php
* // Ex: redirect the client ...
* HDR::setHeaderKey (new S ('http://google.ro'), new S ('Location'));
* ?>
* </code>
*
* @param S $headerContent The content to be set for the header key
* @param S $headerType The header key to be set
* @return B Will return true if the headers have been set
* @author Catalin Z. Alexandru <catalin.zamfir@raphpframework.ro>
* @copyright Under the terms of the GNU General Public License v3
* @link http://php.net/header
* @version $Id: 05_HDR.php 313 2009-10-09 13:27:52Z catalin.zamfir $
* @since Version 1.0
* @access public
* @static
* @final
*/
public static final function setHeaderKey(S $headerContent, S $headerType)
{
// Check if we've sent ANY headers;
if (headers_sent()) {
// Error me proudly;
self::renderScreenOfDeath(new S(__CLASS__), new S(HEADERS_ALREADY_SENT), new S(HEADERS_ALREADY_SENT_FIX));
} else {
// Add the HEADER, to the current page;
switch ($headerType) {
case 'Location':
// CALL the PHP function & exit ...
header($headerType->toString() . _CL . $headerContent->toString());
// Empty the _SESSION
if (isset($_SESSION['POST'])) {
unset($_SESSION['POST']);
}
// Empty the __FILES
if (isset($_SESSION['FILES'])) {
unset($_SESSION['FILES']);
}
// Exit!;
exit(0);
// BK;
break;
default:
// CALL the PHP function ...
header($headerType->toString() . _CL . $headerContent->toString());
// BK;
break;
}
// Do return ...
return new B(TRUE);
}
}
示例11: moveFILEUploads
/**
* Will execute necessary SQL operations on the current form ...
*
* This method, setSQLOperationsOnForm, you don't need to know the internal workings of it. This is because, as you can see
* it is a private method, and thus, it's used internally by the class, to achieve it's goals of execution. Just pass on
* and read any other 'public' or 'protected' method out there ...
*
* @param array $inputAttributes The core attributes (found in every HTML element) that can be set;
* @param string $tp The path to the .tp file where to set those variables;
*/
private static function moveFILEUploads()
{
if (isset(self::$objFormDataContainer['upload_dir'])) {
$uploadDirectory = DOCUMENT_ROOT . UPLOAD_DIR . _S . self::$objFormDataContainer['upload_dir'] . _S;
if (!is_dir($uploadDirectory)) {
// Issue a mkdir, to make the directory;
if (!mkdir($uploadDirectory, 0777, TRUE)) {
self::renderScreenOfDeath(new S(__CLASS__), new S(UPLOAD_ERROR), new S(UPLOAD_ERROR_FIX));
}
}
// We use the /tmp/php*****, generated by php, which has a slash;
self::$objImageTimestampPrefix = $_SERVER['REQUEST_TIME'];
foreach ($_SESSION['FILES'] as $k => $v) {
// Process the K ...
$k = new S($k);
$_SESSION['FILES'][$k->toString()]['name'] = new S(self::$objImageTimestampPrefix . _U . $_SESSION['FILES'][$k->toString()]['name']);
$_SESSION['FILES'][$k->toString()]['name'] = self::sanitizePATH($_SESSION['FILES'][$k->toString()]['name']);
// Process uploaded files, so that they contain the prefix;
$uploadInputFromPOST = new S(self::$objImageTimestampPrefix . _U . self::getPOST($k));
$uploadInputFromPOST = self::sanitizePATH($uploadInputFromPOST);
self::setPOST($k, $uploadInputFromPOST);
$uploadedFileMovedToDirectory = $uploadDirectory . $_SESSION['FILES'][$k->toString()]['name'];
// Do something specific for WIN ...
if (WIN == TRUE) {
$_SESSION['FILES'][$k->toString()]['tmp_name'] = new S($_SESSION['FILES'][$k->toString()]['tmp_name']);
$_SESSION['FILES'][$k->toString()]['tmp_name']->doToken(DIRECTORY_SEPARATOR, _S);
$_SESSION['FILES'][$k->toString()]['tmp_name']->doToken(dirname(dirname(DOCUMENT_ROOT)), _NONE);
$temporaryDirectory = new S(DOCUMENT_ROOT . UPLOAD_DIR . $_SESSION['FILES'][$k->toString()]['tmp_name']);
rename($temporaryDirectory, $uploadedFileMovedToDirectory);
} else {
// Rename, on Linux;
$temporaryDirectory = new S(DOCUMENT_ROOT . UPLOAD_DIR . $_SESSION['FILES'][$k->toString()]['tmp_name']);
rename($temporaryDirectory, $uploadedFileMovedToDirectory);
}
}
} else {
self::renderScreenOfDeath(new S(__CLASS__), new S(UPLOAD_DIR_NOT_SPECIFIED), new S(UPLOAD_DIR_NOT_SPECIFIED_FIX));
}
}
示例12: checkMethodIsCallable
/**
* Checks to see if whether a given method string is_callable, else outputs an error. In certain cases we are actually needed to
* check that a method is callable before we actually even try to call it. In the case of our framework, due to interfaces taht
* allow us to define a rigid architecture, this is going to rarelly be a case, but in the context of objects that are serialized
* back and forward and retrieved from different sources, such a check my be adequate;
* <code>
* <?php
* // Check a method ...
* if (EXE::checkMethodIsCallable (new S ('getExeTime'))) {
* // cause we're here, do something;
* }
* ?>
* </code>
*
* @param S $methodName The name of the method to check for callability
* @return B Will return true if method is callable
* @author Catalin Z. Alexandru <catalin.zamfir@raphpframework.ro>
* @copyright Under the terms of the GNU General Public License v3
* @version $Id: 02_EXE.php 313 2009-10-09 13:27:52Z catalin.zamfir $
* @since Version 1.0
* @access protected
* @static
* @final
*/
protected static final function checkMethodIsCallable(S $methodName)
{
// Check if the method is callable;
if (is_callable($methodName->toString())) {
// Do return ...
return new B(TRUE);
} else {
// Make an error ...
self::renderScreenOfDeath(new S(__CLASS__), new S(FATAL_ERROR), new S(FATAL_ERROR_CHECK_LOG), new S(METHOD_IS_NOT_CALLABLE));
}
}