public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     $i = new I();
     $i->iMember = 'iString1';
     $i->name = 'd';
     assert($i->save());
     // Not Coding Standard
     $i = new I();
     $i->iMember = 'xString1';
     $i->name = 'e';
     assert($i->save());
     // Not Coding Standard
     $i = new I();
     $i->iMember = 'yString1';
     $i->name = 'f';
     assert($i->save());
     // Not Coding Standard
     $j = new J();
     $j->jMember = 'jString1';
     $j->name = 'a';
     assert($j->save());
     // Not Coding Standard
     $j = new J();
     $j->jMember = 'xString1';
     $j->name = 'b';
     assert($j->save());
     // Not Coding Standard
     $j = new J();
     $j->jMember = 'yString1';
     $j->name = 'c';
     assert($j->save());
     // Not Coding Standard
     $k = new K();
     $k->kMember = 'kString1';
     $k->name = 'g';
     assert($k->save());
     // Not Coding Standard
     $k = new K();
     $k->kMember = 'xString1';
     $k->name = 'i';
     assert($k->save());
     // Not Coding Standard
     $k = new K();
     $k->kMember = 'yString1';
     $k->name = 'h';
     assert($k->save());
     // Not Coding Standard
 }
 public function testGetStringifiedData()
 {
     $i = new I();
     $i->iMember = 'a';
     $k = new K();
     $k->kMember = 'kA1';
     $i->ks->add($k);
     $this->assertTrue($i->save());
     $content = $i->ks->getStringifiedData();
     $this->assertEquals(array('kA1'), $content);
     $iId = $i->id;
     $i->forget();
     unset($i);
     $i = I::getById($iId);
     $content = $i->ks->getStringifiedData();
     $this->assertEquals(array('kA1'), $content);
     $k = new K();
     $k->kMember = 'kA2';
     $i->ks->add($k);
     $k = new K();
     $k->kMember = 'kA3';
     $i->ks->add($k);
     $this->assertTrue($i->save());
     $content = $i->ks->getStringifiedData();
     $this->assertEquals(array('kA1', 'kA2', 'kA3'), $content);
 }
Exemplo n.º 3
0
 /**
  * run() should italicize the characters if the parameter is zero
  */
 public function testRun_doesNotItalicize_ifParameterIsZero()
 {
     $style = new \Jstewmc\Rtf\Style();
     $element = new I();
     $element->setParameter('0');
     $element->setStyle($style);
     $this->assertFalse($element->getStyle()->getCharacter()->getIsItalic());
     $element->run();
     $this->assertFalse($element->getStyle()->getCharacter()->getIsItalic());
     return;
 }
Exemplo n.º 4
0
 function test()
 {
     C::__construct();
     $X = "C";
     $m = "__construct";
     C::$m();
     $X::$m();
     F::__construct();
     I::__construct();
     $X = "F";
     $m = "__construct";
     F::$m();
     $X::$m();
     $X = "I";
     $m = "__construct";
     I::$m();
     $X::$m();
 }
 /**
  * @depends testHasManyRelationSqlQuery
  */
 public function testManyManyRelationSqlQuery()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     //I has many ls.
     $i = new I();
     $l = new L();
     $l->lMember = 'def';
     $this->assertTrue($l->save());
     $i->iMember = 'abc';
     $i->ls->add($l);
     $this->assertTrue($i->save());
     $searchAttributeData = array();
     $searchAttributeData['clauses'] = array(1 => array('attributeName' => 'ls', 'relatedAttributeName' => 'lMember', 'operatorType' => 'equals', 'value' => 'somevalue'));
     $searchAttributeData['structure'] = '1';
     $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('I');
     $quote = DatabaseCompatibilityUtil::getQuote();
     $where = RedBeanModelDataProvider::makeWhere('I', $searchAttributeData, $joinTablesAdapter);
     $compareWhere = "({$quote}l{$quote}.{$quote}lmember{$quote} = 'somevalue')";
     $this->assertEquals($compareWhere, $where);
     //Now test that the joinTablesAdapter has correct information.
     $this->assertEquals(0, $joinTablesAdapter->getFromTableJoinCount());
     $this->assertEquals(2, $joinTablesAdapter->getLeftTableJoinCount());
     $leftTables = $joinTablesAdapter->getLeftTablesAndAliases();
     $this->assertEquals('i_l', $leftTables[0]['tableName']);
     $this->assertEquals('l', $leftTables[1]['tableName']);
     //Now test that the subsetSQL query produced is correct.
     $subsetSql = I::makeSubsetOrCountSqlQuery('i', $joinTablesAdapter, 1, 5, $where, null, false, $joinTablesAdapter->getSelectDistinct());
     $compareSubsetSql = "select distinct {$quote}i{$quote}.{$quote}id{$quote} id ";
     $compareSubsetSql .= "from {$quote}i{$quote} ";
     $compareSubsetSql .= "left join {$quote}i_l{$quote} on ";
     $compareSubsetSql .= "{$quote}i_l{$quote}.{$quote}i_id{$quote} = {$quote}i{$quote}.{$quote}id{$quote} ";
     $compareSubsetSql .= "left join {$quote}l{$quote} on ";
     $compareSubsetSql .= "{$quote}l{$quote}.{$quote}id{$quote} = {$quote}i_l{$quote}.{$quote}l_id{$quote} ";
     $compareSubsetSql .= "where " . $compareWhere . ' ';
     $compareSubsetSql .= 'limit 5 offset 1';
     $this->assertEquals($compareSubsetSql, $subsetSql);
     //Make sure the sql runs properly.
     $dataProvider = new RedBeanModelDataProvider('I', null, false, $searchAttributeData);
     $data = $dataProvider->getData();
 }
Exemplo n.º 6
0
Arquivo: H.php Projeto: hfw/h
 /**
  * Matches a route and HTTP method/s against the request path, and if successful, invokes a controller and **exits**.
  *
  * When a route and method/s are matched, the HTTP response code is automatically set to `200`.
  * The controller is then invoked and responsible for the response code from then on.
  *
  * Otherwise a response code of either `404` or `405` is set.
  *
  * This also means that within a subrouter the HTTP response can go from an initial `200` to `404`/`405` if those subroutes fail.
  *
  * To allow safe fallthrough, a `404` response code will not replace an existing `405`.
  *
  * @param string[] $methods HTTP request methods, or empty to accept any method.
  * @param string $route A literal path with leading slash, or a regular expression.
  * Regular expressions are enclosed by anything other than a slash, since slashes are used for literal paths.
  * @param callable $controller Given either the [preg_match()](http://php.net/preg-match) array, or the literal path.
  * The controller can output content directly if it chooses, but it must also output headers and **exit**.
  * If not, the return value is given to {@link \H\O::mixed()}, which **exits**.
  */
 public static function route($methods, $route, callable $controller)
 {
     $match = $path = I::path();
     if ($route === $path or $route[0] !== '/' && preg_match($route, $path, $match)) {
         if (empty($methods) or in_array(I::method(), $methods)) {
             O::code(200);
             O::mixed(call_user_func($controller, $match));
             // exits
         } else {
             O::code(405);
         }
     } elseif (O::code() !== 405) {
         O::code(404);
     }
 }
 /**
 @brief Auto Add function will add all placeholders on autopilot to the Content .
 
 Basically this still is an output filter that simply adds some placeholders to a HTML page. 
 It is based on regexes at this is more error resistant that using a DOM class.
 
 @param string $Content 
     The HTML content to filter 
 
 @retval string 
     The filtered/replaced content.  
 */
 public static function AddPlaceholder($Content)
 {
     $i = I::getInstance();
     return $i->AddPlaceholder($Content);
 }
Exemplo n.º 8
0
function test(I $x)
{
    $x->foo(0);
    $x->foo(0, 1);
    $x->foo(0, 1, 2);
}
Exemplo n.º 9
0
 /**
  * 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 $objWidgetToRender 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->getLyrics(_S('ORDER
             BY %objLyricsTableFDateAdded DESC LIMIT %LowerLimit, %UpperLimit')->doToken('%LowerLimit', ((int) $objWA['objId']->toString() - 1) * 25000)->doToken('%UpperLimit', 25000)) as $k => $v) {
                 // Set some requirements ...
                 $objDTE = date('Y-m-d', (int) $v[self::$objLyricsTableFDateAdded]->toString());
                 $objLOC = URL::staticURL(new A(array(LYRICS_ITEM_URL, FRONTEND_SECTION_URL)), new A(array($v[self::$objLyricsTableFSEO], FRONTEND_LYRICS_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;
     }
     // Do a switch ...
     switch ($objW) {
         case 'widgetList':
             // Check some needed requirements ...
             if ($_GET[FRONTEND_SECTION_URL] == FRONTEND_LYRICS_URL) {
                 // Set some requirements ...
                 $objPag = isset($_GET[LYRICS_PAGE_URL]) ? $_GET[LYRICS_PAGE_URL] : new S((string) 1);
                 $objPag = new I((int) $objPag->toString());
                 // Fixes for a bugged user ...
                 if ($objPag->toInt() == 0) {
                     // 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 {
                     // Make it a string again ...
                     $objPag = new S((string) $objPag->toInt());
                 }
                 // Get your switches on ...
                 if (isset($_GET[LYRICS_ITEM_URL])) {
                     // Check that the article exists, before doing anything stupid ...
                     if ($this->checkLyricURLIsUnique($objURL = $_GET[LYRICS_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 {
                         // Make me SEO ... yah!
                         TPL::manageTTL($objTTL = $this->getLyricInfoByURL($objURL, self::$objLyricsTableFTitle));
                         TPL::manageTTL($objART = $this->getLyricInfoByURL($objURL, self::$objLyricsTableFArtist));
                         TPL::manageTTL($objALB = $this->getLyricInfoByURL($objURL, self::$objLyricsTableFAlbum));
                         TPL::manageTAG(new S('description'), new S('Titlu: ' . $objTTL . ', Artist: ' . $objART . ', Album: ' . $objALB . ', Lyrics: ' . $this->getLyricInfoByURL($objURL, self::$objLyricsTableFLyrics)->entityDecode(ENT_QUOTES)->doToken('<br />', _SP)->stripTags()->doSubStr(0, 128)));
                         // Set the template file ...
                         $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . '-Item' . TPL_EXTENSION);
                         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('LRQ'), $tpF);
                         TPL::tpExe($tpF);
                     }
                 } else {
                     if (isset($_GET[LYRICS_SEARCH_URL])) {
                         // Get audio by page ...
                         $objCnt = $this->getLyricCountForSearch($_GET[LYRICS_SEARCH_URL]);
                         $objArt = $this->getLyricsByPageAndSearch($objPag, $_GET[LYRICS_SEARCH_URL]);
                     } else {
                         // Do me SEO, yah baby! ...
                         TPL::manageTTL(_S(FRONTEND_LYRICS_URL));
                         // Make a condition to avoid dup. title tags on different pages ...
                         if ((int) $objPag->toString() >= 1 && isset($_GET[LYRICS_PAGE_URL])) {
                             TPL::manageTTL(_S(LYRICS_PAGE_URL)->appendString(_SP)->appendString($objPag));
                         }
                         // Set some requirements ...
                         $objArt = $this->getLyricsByPage($objPag);
                         $objCnt = $this->getLyricCount();
                     }
                     // Set the template file ...
                     $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION);
                     TPL::tpSet($objWA, new S('objWidgetArray'), $tpF);
                     TPL::tpSet($objArt, new S('objAr'), $tpF);
                     TPL::tpSet($this, new S('LRQ'), $tpF);
                     TPL::tpExe($tpF);
                     // Set them paginations ...
                     if ($objCnt->toInt() > (int) self::$objItemsPerPage->toString()) {
                         self::$objFrontend->setPagination($objCnt, new I((int) self::$objItemsPerPage->toString()));
                     }
                 }
             } else {
                 // Do the biggest error on the PLANET ...
                 self::renderScreenOfDeath(new S(__CLASS__), new S(LYRICS_NEED_PROPER_SECTION), new S(LYRICS_NEED_PROPER_SECTION_FIX));
             }
             // BK;
             break;
         case 'widgetTopN':
             if ($objWA['type'] == 1) {
                 $objArt = $this->_Q(_QS('doSELECT')->doToken('%what', new S('%objLyricsTableFArtist, COUNT(%objLyricsTableFTitle) as count'))->doToken('%table', self::$objLyricsTable)->doToken('%condition', new S('GROUP BY %objLyricsTableFArtist ORDER BY count DESC LIMIT 0, 30')));
             } else {
                 $objArt = $this->_Q(_QS('doSELECT')->doToken('%what', new S('%objLyricsTableFAlbum, COUNT(%objLyricsTableFTitle) as count'))->doToken('%table', self::$objLyricsTable)->doToken('%condition', new S('GROUP BY %objLyricsTableFAlbum ORDER BY count DESC LIMIT 0, 30')));
             }
             // Set the template file ...
             $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION);
             TPL::tpSet($objWA, new S('objWidgetArray'), $tpF);
             TPL::tpSet($objArt, new S('objAr'), $tpF);
             TPL::tpSet($this, new S('LRQ'), $tpF);
             TPL::tpExe($tpF);
             break;
         case 'widgetSearch':
             $this->renderForm(new S('widgetSearch'));
             break;
     }
 }
Exemplo n.º 10
0
Arquivo: O.php Projeto: hfw/h
 /**
  * Sends all pending {@link $headers}.
  * This will **exit** on the following conditions:
  *
  * - The request method is `HEAD`
  * - The response code is `3xx`, `204`, or `205`.
  * - The response has a `Last-Modified` header that is equal to the `If-Modified-Since` request header (if present).
  *   This case also results in a `304` response code.
  */
 public static function headers()
 {
     if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) and isset(self::$headers['Last-Modified']) and strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) === strtotime(self::$headers['Last-Modified'])) {
         self::code(304);
     }
     foreach (array_filter(self::$headers, 'strlen') as $name => $value) {
         header("{$name}: {$value}");
     }
     if (I::method() === 'HEAD' or preg_match('/^3|(20[45])$/', self::code())) {
         exit;
     }
 }
Exemplo n.º 11
0
 /**
  * Will return an array (associative by default), containing a row of the MySQL result. This method will provide access to the
  * MySQL result returned as an array that can then be processed;
  *
  * @param R $queryResourceSet The resource set to be fetched
  * @param I $queryFetchMode One of the mysql_fetch_array () fetch modes, as an integer
  * @author Catalin Z. Alexandru <*****@*****.**>
  * @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 private
  * @static
  */
 private static function getQueryResultRow(R $queryResourceSet, I $queryFetchMode = NULL)
 {
     if ($queryFetchMode == NULL) {
         $queryFetchMode = new I(MYSQL_ASSOC);
         $temporaryArray = mysql_fetch_array($queryResourceSet->toResource(), $queryFetchMode->toInt());
     } else {
         // Just return, taking the queryFetchMode, from the passed second parameter. We trust the developer!;
         $temporaryArray = mysql_fetch_array($queryResourceSet->toResource(), $queryFetchMode->toInt());
     }
     if ($temporaryArray != FALSE) {
         foreach ($temporaryArray as $k => $v) {
             $v != NULL ? $temporaryArray[$k] = new S($v) : ($temporaryArray[$k] = new S(_NONE));
         }
         // Return the new A, passed from mysql_fetch_array;
         return new A($temporaryArray);
     } else {
         // DO NOT MOVE. Set here to stop looping ...
         return FALSE;
     }
 }
Exemplo n.º 12
0
 /**
  * Will check if the file path cache time expired or not, returning a boolean true or false. This method is used by core
  * developers to check if the need to refresh the cache or not. The cache is refreshed upon a given time, time specified by the
  * specific project developer according to his needs;
  *
  * @param string $cacheFile Path to the executed .tp file
  * @param integer $templateCacheTime What time was the file cached, so we can calculate the difference
  * @return mixed Will return an integer, or boolean false if it can't determine the cache time
  * @author Catalin Z. Alexandru <*****@*****.**>
  * @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 private
  * @static
  */
 private static function checkCacheFile(FilePath $cacheFile, I $templateCacheTime)
 {
     if ($cacheFile->checkPathExists()->toBoolean()) {
         return $cacheFile->getPathInfo('mtime')->toInt() + $templateCacheTime->toInt() > $_SERVER['REQUEST_TIME'] ? new B(TRUE) : new B(FALSE);
     } else {
         // Do return ...
         return new B(FALSE);
     }
 }
Exemplo n.º 13
0
 /**
  * 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']);
             }
             // Do erase it ...
             $this->_Q(_QS('doDELETE')->doToken('%table', self::$objProductsIMGTable)->doToken('%condition', new S('%objProductsIMGTableFId = "%Id"'))->doToken('%Id', $_GET[PRODUCTS_ID_IMAGE]));
             // Do a redirect, and get the user back where he belongs;
             $this->setHeaderKey($objURLToGoBack, new S('Location'));
             break;
         case 'productCreate':
             // The URL to go back too;
             $objURLToGoBack = URL::rewriteURL();
             // Do some work;
             if ($this->checkPOST(self::$objProductsTableFCode)->toBoolean() == TRUE) {
                 if ($this->getPOST(self::$objProductsTableFCode)->toLength()->toInt() == 0) {
                     $this->setErrorOnInput(self::$objProductsTableFCode, new S(PRODUCTS_CODE_MUST_BE_ENTERED));
                 } else {
                     if ($this->checkCodeIsUnique($this->getPOST(self::$objProductsTableFCode))->toBoolean() == FALSE) {
                         $this->setErrorOnInput(self::$objProductsTableFCode, new S(PRODUCTS_CODE_MUST_BE_UNIQUE));
                     }
                 }
             }
             if ($this->checkPOST(self::$objProductsTableFName)->toBoolean() == TRUE) {
                 if ($this->getPOST(self::$objProductsTableFName)->toLength()->toInt() == 0) {
                     $this->setErrorOnInput(self::$objProductsTableFName, new S(PRODUCTS_NAME_MUST_BE_ENTERED));
                 } else {
                     if ($this->checkProductNameIsUnique($this->getPOST(self::$objProductsTableFName))->toBoolean() == FALSE) {
                         $this->setErrorOnInput(self::$objProductsTableFName, new S(PRODUCTS_NAME_MUST_BE_UNIQUE));
                     }
                 }
             }
             if ($this->checkPOST(self::$objProductsTableFName)->toBoolean() == TRUE) {
                 if ($this->checkProductURLIsUnique(URL::getURLFromString($this->getPOST(self::$objProductsTableFName)))->toBoolean() == FALSE) {
                     $this->setErrorOnInput(self::$objProductsTableFName, new S(PRODUCTS_URL_MUST_BE_UNIQUE));
                 }
             }
             if ($this->checkPOST(self::$objProductsTableFStoc)->toBoolean() == TRUE) {
                 if ($this->getPOST(self::$objProductsTableFStoc)->toLength()->toInt() == 0) {
                     $this->setErrorOnInput(self::$objProductsTableFStoc, new S(PRODUCTS_STOCK_MUST_BE_ENTERED));
                 } else {
                     // Get some requirements;
                     $objStock = new I((int) $this->getPOST(self::$objProductsTableFStoc)->toString());
                     // Do some MORE validation;
                     if ($objStock->toInt() < 0) {
                         $this->setErrorOnInput(self::$objProductsTableFStoc, new S(PRODUCTS_STOCK_CANNOT_BE_NEGATIVE));
                     }
                 }
             }
             if ($this->checkPOST(self::$objProductsTableFPrice)->toBoolean() == TRUE) {
                 if ($this->getPOST(self::$objProductsTableFPrice)->toLength()->toInt() == 0) {
                     $this->setErrorOnInput(self::$objProductsTableFPrice, new S(PRODUCTS_PRICE_MUST_BE_ENTERED));
                 } else {
                     // Get some requirements;
                     $objPrice = new I((int) $this->getPOST(self::$objProductsTableFPrice)->toString());
                     // Do some MORE validation;
                     if ($objPrice->toInt() < 0) {
                         $this->setErrorOnInput(self::$objProductsTableFPrice, new S(PRODUCTS_PRICE_CANNOT_BE_NEGATIVE));
                     }
                 }
             }
             // Do the form, make it happen;
             $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(PRODUCTS_ADD_PRODUCT))->setSQLAction(new S('update'))->setTableName(self::$objProductsTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objProductsTableFId)->setUploadDirectory(new S('products/pdf'))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setAJAXEnabledForm(new B(FALSE));
             // Set some EXTRA data;
             if ($this->checkPOST(self::$objProductsTableFName)->toBoolean() == TRUE) {
                 $this->setExtraUpdateData(self::$objProductsTableFSEO, URL::getURLFromString($this->getPOST(self::$objProductsTableFName)));
             }
             // Continue;
             $this->setInputType(new S('submit'))->setValue(new S(PRODUCTS_ADD_PRODUCT))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objProductsTableFCategoryId)->setLabel(new S(PRODUCTS_CATEGORY));
             // Category parent or brother of this one ...
             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::$objProductsTableFCode)->setLabel(new S(PRODUCTS_CODE))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objProductsTableFName)->setLabel(new S(PRODUCTS_NAME))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objProductsTableFURL)->setLabel(new S(PRODUCTS_URL))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objProductsTableFStoc)->setLabel(new S(PRODUCTS_STOCK))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objProductsTableFPrice)->setLabel(new S(PRODUCTS_PRICE))->setContainerDiv(new B(TRUE))->setInputType(new S('file'))->setName(self::$objProductsTableFPDF)->setLabel(new S(PRODUCTS_PDF))->setFileController(new B(TRUE))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objProductsTableFDescription)->setLabel(new S(PRODUCTS_DECRIPTION))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE));
             break;
         case 'productEdit':
             // The URL to go back too;
             $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID)));
             // Do some work;
             if ($this->checkPOST(self::$objProductsTableFCode)->toBoolean() == TRUE) {
                 if ($this->getPOST(self::$objProductsTableFCode)->toLength()->toInt() == 0) {
                     $this->setErrorOnInput(self::$objProductsTableFCode, new S(PRODUCTS_CODE_MUST_BE_ENTERED));
                 } else {
                     if ($this->getPOST(self::$objProductsTableFCode) != $this->getProductInfoById($_GET[ADMIN_ACTION_ID], self::$objProductsTableFCode)) {
                         if ($this->checkCodeIsUnique($this->getPOST(self::$objProductsTableFCode))->toBoolean() == FALSE) {
                             $this->setErrorOnInput(self::$objProductsTableFCode, new S(PRODUCTS_CODE_MUST_BE_UNIQUE));
                         }
                     }
                 }
             }
             if ($this->checkPOST(self::$objProductsTableFName)->toBoolean() == TRUE) {
                 if ($this->getPOST(self::$objProductsTableFName)->toLength()->toInt() == 0) {
                     $this->setErrorOnInput(self::$objProductsTableFName, new S(PRODUCTS_NAME_MUST_BE_ENTERED));
                 } else {
                     if ($this->getPOST(self::$objProductsTableFName) != $this->getProductInfoById($_GET[ADMIN_ACTION_ID], self::$objProductsTableFName)) {
                         if ($this->checkProductNameIsUnique($this->getPOST(self::$objProductsTableFName))->toBoolean() == FALSE) {
                             $this->setErrorOnInput(self::$objProductsTableFName, new S(PRODUCTS_NAME_MUST_BE_UNIQUE));
                         }
                         if ($this->checkPOST(self::$objProductsTableFName)->toBoolean() == TRUE) {
                             if ($this->checkProductURLIsUnique(URL::getURLFromString($this->getPOST(self::$objProductsTableFName)))->toBoolean() == FALSE) {
                                 $this->setErrorOnInput(self::$objProductsTableFName, new S(PRODUCTS_URL_MUST_BE_UNIQUE));
                             }
                         }
                     }
                 }
             }
             if ($this->checkPOST(self::$objProductsTableFStoc)->toBoolean() == TRUE) {
                 if ($this->getPOST(self::$objProductsTableFStoc)->toLength()->toInt() == 0) {
                     $this->setErrorOnInput(self::$objProductsTableFStoc, new S(PRODUCTS_STOCK_MUST_BE_ENTERED));
                 } else {
                     // Get some requirements;
                     $objStock = new I((int) $this->getPOST(self::$objProductsTableFStoc)->toString());
                     // Do some MORE validation;
                     if ($objStock->toInt() < 0) {
                         $this->setErrorOnInput(self::$objProductsTableFStoc, new S(PRODUCTS_STOCK_CANNOT_BE_NEGATIVE));
                     }
                 }
             }
             if ($this->checkPOST(self::$objProductsTableFPrice)->toBoolean() == TRUE) {
                 if ($this->getPOST(self::$objProductsTableFPrice)->toLength()->toInt() == 0) {
                     $this->setErrorOnInput(self::$objProductsTableFPrice, new S(PRODUCTS_PRICE_MUST_BE_ENTERED));
                 } else {
                     // Get some requirements;
                     $objPrice = new I((int) $this->getPOST(self::$objProductsTableFPrice)->toString());
                     // Do some MORE validation;
                     if ($objPrice->toInt() < 0) {
                         $this->setErrorOnInput(self::$objProductsTableFPrice, new S(PRODUCTS_PRICE_CANNOT_BE_NEGATIVE));
                     }
                 }
             }
             // Do the form, make it happen;
             $this->setMethod(new S('POST'))->setEnctype(new S('multipart/form-data'))->setFieldset(new S(PRODUCTS_EDIT_PRODUCT))->setSQLAction(new S('update'))->setTableName(self::$objProductsTable)->setUpdateId($_GET[ADMIN_ACTION_ID])->setUpdateField(self::$objProductsTableFId)->setName($objFormToRender)->setRedirect($objURLToGoBack)->setAJAXEnabledForm(new B(FALSE));
             // Set some EXTRA data;
             if ($this->checkPOST(self::$objProductsTableFName)->toBoolean() == TRUE) {
                 $this->setExtraUpdateData(self::$objProductsTableFSEO, URL::getURLFromString($this->getPOST(self::$objProductsTableFName)));
             }
             // Continue;
             $this->setInputType(new S('submit'))->setValue(new S(PRODUCTS_EDIT_PRODUCT))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(self::$objProductsTableFCategoryId)->setLabel(new S(PRODUCTS_CATEGORY));
             // Category parent or brother of this one ...
             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::$objProductsTableFCode)->setLabel(new S(PRODUCTS_CODE))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objProductsTableFName)->setLabel(new S(PRODUCTS_NAME))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objProductsTableFURL)->setLabel(new S(PRODUCTS_URL))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objProductsTableFStoc)->setLabel(new S(PRODUCTS_STOCK))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objProductsTableFPrice)->setLabel(new S(PRODUCTS_PRICE))->setContainerDiv(new B(TRUE))->setInputType(new S('file'))->setName(self::$objProductsTableFPDF)->setLabel(new S(PRODUCTS_PDF))->setFileController(new B(TRUE))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objProductsTableFDescription)->setLabel(new S(PRODUCTS_DECRIPTION))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE));
             break;
         case 'productErase':
             // The URL to go back too;
             $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID)));
             // First, delete existing images;
             $objProductImages = $this->_Q(_QS('doSELECT')->doToken('%what', self::$objProductsIMGTableFURL)->doToken('%table', self::$objProductsIMGTable)->doToken('%condition', new S('WHERE %objProductsIMGTableFProdId = "%Id"'))->doToken('%Id', $_GET[ADMIN_ACTION_ID]));
             // Knowing the images, delete THEM;
             foreach ($objProductImages as $k => $v) {
                 UNLINK(DOCUMENT_ROOT . UPLOAD_DIR . _S . 'products/images' . _S . $v['url']);
                 UNLINK(DOCUMENT_ROOT . UPLOAD_DIR . _S . 'products/images' . _S . '60_60_' . $v['url']);
                 UNLINK(DOCUMENT_ROOT . UPLOAD_DIR . _S . 'products/images' . _S . '100_100_' . $v['url']);
                 UNLINK(DOCUMENT_ROOT . UPLOAD_DIR . _S . 'products/images' . _S . '128_128_' . $v['url']);
                 UNLINK(DOCUMENT_ROOT . UPLOAD_DIR . _S . 'products/images' . _S . '320_240_' . $v['url']);
                 UNLINK(DOCUMENT_ROOT . UPLOAD_DIR . _S . 'products/images' . _S . '640_480_' . $v['url']);
                 UNLINK(DOCUMENT_ROOT . UPLOAD_DIR . _S . 'products/images' . _S . '800_600_' . $v['url']);
             }
             // Do erase associated images;
             $this->_Q(_QS('doDELETE')->doToken('%table', self::$objProductsIMGTable)->doToken('%condition', new S('%objProductsIMGTableFProdId = "%Id"'))->doToken('%Id', $_GET[ADMIN_ACTION_ID]));
             // Do erase associated properties ...
             $this->_Q(_QS('doDELETE')->doToken('%table', self::$objProductsPropertyTable)->doToken('%condition', new S('%objProductsPropertyTableFPId = "%Id"'))->doToken('%Id', $_GET[ADMIN_ACTION_ID]));
             // Do erase associated PDF file;
             $objPDF = $this->getProductInfoById($_GET[ADMIN_ACTION_ID], self::$objProductsTableFPDF);
             if ($objPDF->toLength()->toInt() != 0) {
                 UNLINK(DOCUMENT_ROOT . UPLOAD_DIR . _S . 'products/pdf' . _S . $objPDF);
             }
             // Do erase it ...
             $this->_Q(_QS('doDELETE')->doToken('%table', self::$objProductsTable)->doToken('%condition', new S('%objProductsTableFId = "%Id"'))->doToken('%Id', $_GET[ADMIN_ACTION_ID]));
             // Do a redirect, and get the user back where he belongs;
             $this->setHeaderKey($objURLToGoBack, new S('Location'));
             break;
         case 'categoryCreate':
             // The URL to go back too;
             $objURLToGoBack = URL::rewriteURL();
             // Do some work ...
             if ($this->checkPOST(new S('categories_show_all'))->toBoolean() == TRUE) {
                 // Redirect to proper ...
                 $this->setHeaderKey(URL::rewriteURL(new A(array(ADMIN_SHOW_ALL)), new A(array('1'))), new S('Location'));
             }
             if ($this->checkPOST(new S('add_category_submit'))->toBoolean() == TRUE) {
                 // Set some requirements;
                 $objFormHappened = new B(FALSE);
                 $objToCheck = MPTT::mpttAddUnique($this->getPOST(new S('add_category')), new S((string) $_SERVER['REQUEST_TIME']));
                 if ($objToCheck->toLength()->toInt() == 0) {
                     $this->setErrorOnInput(new S('add_category'), new S(CATEGORY_NAME_CANNOT_BE_EMPTY));
                     // Set the memory;
                     $objFormHappened->switchType();
                 } else {
                     if (self::$objMPTT->mpttCheckIfNodeExists($objToCheck)->toBoolean() == TRUE) {
                         // Check to see if the group exists, and tell the user the group exists;
                         $this->setErrorOnInput(new S('add_category'), new S(CATEGORY_ALREADY_EXISTS));
                         // Set the memory;
                         $objFormHappened->switchType();
                     }
                     if ($this->checkCategoryURLIsUnique(URL::getURLFromString($objToCheck))->toBoolean() == FALSE) {
                         $this->setErrorOnInput(new S('add_category'), new S(PRODUCTS_CATEGORY_URL_MUST_BE_UNIQUE));
                     }
                 }
                 // Get AJAX;
                 $this->getAjaxErrors();
                 if ($objFormHappened->toBoolean() == FALSE) {
                     // Remember if we should add it as a brother or child;
                     $objAddNodeAS = NULL;
                     switch ($this->getPOST(new S('add_category_as_what'))) {
                         case PRODUCTS_CATEGORY_CHILD:
                             $objAddNodeAS = new S((string) MPTT::FIRST_CHILD);
                             break;
                         case PRODUCTS_CATEGORY_LAST_CHILD:
                             $objAddNodeAS = new S((string) MPTT::LAST_CHILD);
                             break;
                         case PRODUCTS_CATEGORY_BROTHER:
                             $objAddNodeAS = new S((string) MPTT::PREVIOUS_BROTHER);
                             break;
                         case PRODUCTS_CATEGORY_NEXT_BROTHER:
                             $objAddNodeAS = new S((string) MPTT::NEXT_BROTHER);
                             break;
                     }
                     // Add the node;
                     self::$objMPTT->mpttAddNode($objToCheck, $this->getPOST(new S('add_category_parent_or_bro')), $objAddNodeAS);
                 }
             }
             // Do the form, make it happen;
             $this->setMethod(new S('POST'))->setFieldset(new S(PRODUCTS_ADD_CATEGORY))->setName($objFormToRender);
             if ($this->checkPOST(new S('add_category_submit'))->toBoolean() == TRUE) {
                 $this->setRedirect($objURLToGoBack);
             }
             $this->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setName(new S('categories_show_all'))->setValue(new S(PRODUCTS_SHOW_ALL_CATEGORIES))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('submit'))->setName(new S('add_category_submit'))->setValue(new S(PRODUCTS_ADD_CATEGORY))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setContainerDiv(new B(TRUE))->setName(new S('add_category'))->setLabel(new S(PRODUCTS_CATEGORY_NAME_LABEL))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(new S('add_category_as_what'))->setLabel(new S(PRODUCTS_AS_A))->setInputType(new S('option'))->setName(new S('as_first_child'))->setLabel(new S(PRODUCTS_CATEGORY_CHILD))->setInputType(new S('option'))->setName(new S('as_last_child'))->setLabel(new S(PRODUCTS_CATEGORY_LAST_CHILD))->setInputType(new S('option'))->setName(new S('as_previous_brother'))->setLabel(new S(PRODUCTS_CATEGORY_BROTHER))->setInputType(new S('option'))->setName(new S('as_next_brother'))->setLabel(new S(PRODUCTS_CATEGORY_NEXT_BROTHER))->setInputType(new S('select'))->setContainerDiv(new B(TRUE))->setName(new S('add_category_parent_or_bro'))->setLabel(new S(PRODUCTS_OF_CATEGORY));
             // Category parent or brother of this one ...
             foreach ($this->getCategories() as $k => $v) {
                 $this->setInputType(new S('option'))->setName($v[self::$objMPTT->objNameOfNode])->setValue($v[self::$objMPTT->objNameOfNode])->setLabel(new S(str_repeat('--' . _SP, (int) $v['depth']->toString()) . MPTT::mpttRemoveUnique(clone $v[self::$objMPTT->objNameOfNode])));
             }
             // Continue, execute the form ...
             $this->setFormEndAndExecute(new B(TRUE));
             break;
         case 'categoryEdit':
             // The URL to go back too;
             $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID)));
             $objFormHappened = new B(FALSE);
             // Do validation and error on it if something goes wrong;
             if ($this->checkPOST()->toBoolean() == TRUE) {
                 // Set some requirements;
                 $objFormHappened = new B(FALSE);
                 $objToCheck = MPTT::mpttAddUnique($this->getPOST(self::$objCategoryTableFName), $this->getCategoryInfoById($_GET[ADMIN_ACTION_ID], self::$objCategoryTableFDate));
                 if ($objToCheck->toLength()->toInt() == 0) {
                     // Check for empty group name, and error on it. We don't allow empty group names;
                     $this->setErrorOnInput(self::$objCategoryTableFName, new S(PRODUCTS_CATEGORY_NAME_EMPTY));
                     // Set the memory;
                     $objFormHappened->switchType();
                 } else {
                     if ($this->getCategoryInfoById($_GET[ADMIN_ACTION_ID], self::$objCategoryTableFName) != $objToCheck) {
                         if (self::$objMPTT->mpttCheckIfNodeExists($objToCheck)->toBoolean() == TRUE) {
                             // Check to see if the group exists;
                             $this->setErrorOnInput(self::$objCategoryTableFName, new S(PRODUCTS_CATEGORY_ALREADY_EXISTS));
                             // Set the memory;
                             $objFormHappened->switchType();
                         }
                     }
                 }
                 // Get AJAX;
                 $this->getAjaxErrors();
             }
             // Do the form, make it happen;
             $this->setMethod(new S('POST'))->setSQLAction(new S('update'))->setTableName(self::$objCategoryTable)->setUpdateId($_GET[ADMIN_ACTION_ID])->setUpdateField(self::$objCategoryTableFId)->setFieldset(new S(PRODUCTS_EDIT_CATEGORY));
             if ($this->checkPOST(self::$objCategoryTableFName)->toBoolean() == TRUE) {
                 $this->setExtraUpdateData(self::$objCategoryTableFSEO, URL::getURLFromString($this->getPOST(self::$objCategoryTableFName)));
             }
             if ($objFormHappened->toBoolean() == FALSE && $this->checkPOST()->toBoolean() == TRUE) {
                 $this->setRedirect($objURLToGoBack);
             }
             $this->setName($objFormToRender)->setAJAXEnabledForm(new B(FALSE))->setInputType(new S('submit'))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setName(new S('edit_category_submit'))->setValue(new S(PRODUCTS_EDIT_CATEGORY))->setInputType(new S('text'))->setName(self::$objCategoryTableFName)->setMPTTRemoveUnique(new B(TRUE))->setLabel(new S(PRODUCTS_NAME))->setJSRegExpReplace(new S('[^a-zA-Z0-9 -]'))->setContainerDiv(new B(TRUE))->setInputType(new S('textarea'))->setName(self::$objCategoryTableFDescription)->setLabel(new S(PRODUCTS_DECRIPTION))->setTinyMCETextarea(new B(TRUE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE));
             break;
         case 'categoryErase':
             // The URL to go back too;
             $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_ID)));
             // Memorize if it has kids ...
             $objNodeHasKids = new B(FALSE);
             // Check if the category has articles;
             if ($this->getProductCount(_S('WHERE %objProductsTableFCategoryId = "%Id"')->doToken('%Id', $_GET[ADMIN_ACTION_ID]))->toInt() != 0) {
                 // Set an error message;
                 self::$objAdministration->setErrorMessage(new S(PRODUCTS_CANNOT_DELETE_CATEGORY), $objURLToGoBack);
             } else {
                 // Do erase the group node from the table;
                 self::$objMPTT->mpttRemoveNode($this->getCategoryInfoById($_GET[ADMIN_ACTION_ID], self::$objCategoryTableFName));
                 // Do a redirect, and get the user back where he belongs;
                 $this->setHeaderKey($objURLToGoBack, new S('Location'));
             }
             // Break out ...
             break;
         case 'categoryMove':
             // Set some predefines;
             $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION, ADMIN_ACTION_TO, ADMIN_ACTION_TYPE)));
             // Get names, as they are unique;
             $objThatIsMoved = $this->getCategoryInfoById($_GET[ADMIN_ACTION_ID], self::$objCategoryTableFName);
             $objWhereToMove = $this->getCategoryInfoById($_GET[ADMIN_ACTION_TO], self::$objCategoryTableFName);
             // Get the node subtree, that's move, make sure the node we move to ain't a child;
             $objMovedNodeSubTree = self::$objMPTT->mpttGetTree($objThatIsMoved);
             // Memorize;
             $objIsChild = new B(FALSE);
             foreach ($objMovedNodeSubTree as $k => $v) {
                 if ($v[self::$objMPTT->objNameOfNode] == $objWhereToMove) {
                     $objIsChild->switchType();
                 }
             }
             // Check if it's a child or not;
             if ($objIsChild->toBoolean() == TRUE) {
                 // Set an error message;
                 self::$objAdministration->setErrorMessage(new S(PRODUCTS_CATEGORY_CANNOT_BE_MOVED), $objURLToGoBack);
             } else {
                 // Move nodes;
                 self::$objMPTT->mpttMoveNode($objThatIsMoved, $objWhereToMove, $_GET[ADMIN_ACTION_TYPE]);
                 $this->setHeaderKey($objURLToGoBack, new S('Location'));
             }
             // Break out ...
             break;
         case 'categoryMoveOperation':
             // The URL to go back too;
             $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_SUBPAGE)), new A(array(MANAGE_PRODUCTS)));
             // Do some work;
             $this->checkPOST()->toBoolean() == TRUE ? $objOLDCategoryId = $this->getPOST(new S('old_category_id')) : ($objOLDCategoryId = new S('0'));
             // Do the form, make it happen;
             $this->setMethod(new S('POST'))->setFieldset(new S(PRODUCTS_MOVE_PRODUCTS))->setSQLAction(new S('update'))->setTableName(self::$objProductsTable)->setUpdateField(self::$objProductsTableFId)->setUpdateWhere($this->doModuleToken(_S('%objProductsTableFCategoryId = "%Id"')->doToken('%Id', $objOLDCategoryId)))->setName($objFormToRender)->setRedirect($objURLToGoBack)->setInputType(new S('submit'))->setValue(new S(PRODUCTS_MOVE_PRODUCTS))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(new S('old_category_id'))->setLabel(new S(PRODUCTS_OLD_CATEGORY))->setContainerDiv(new B(TRUE));
             // Cateories;
             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])));
             }
             // Categories;
             $this->setInputType(new S('select'))->setName(self::$objProductsTableFCategoryId)->setLabel(new S(PRODUCTS_NEW_CATEGORY))->setContainerDiv(new B(TRUE));
             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 'configurationEdit':
             // Do some work;
             if ($this->checkPOST()->toBoolean() == TRUE) {
                 $objURLToGoBack = URL::rewriteURL(new A(array(ADMIN_ACTION)), new A(array($this->getPOST(new S('what')))));
             }
             // Do the form, make it happen;
             $this->setMethod(new S('POST'))->setFieldset(new S(PRODUCTS_MANAGE_CONFIGURATION))->setName($objFormToRender);
             // Set redirect;
             if ($this->checkPOST()->toBoolean() == TRUE) {
                 $this->setRedirect($objURLToGoBack);
             }
             // Continue;
             $this->setInputType(new S('submit'))->setValue(new S(ADMIN_ACTION))->setInputInfoMessage($this->getHELP($objFormToRender))->setContainerDiv(new B(TRUE))->setInputType(new S('select'))->setName(new S('what'))->setLabel(new S(PRODUCTS_CONFIG_CHOOSE))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE));
             break;
     }
 }
/**
 * execute the backend output filter
 * Only the basic ones here as sooner or later opf dashboardt will take this place
 * @param string actual content
 * @return string modified content
 */
function executeBackendOutputFilter($content)
{
    $sFilterDirectory = str_replace('\\', '/', dirname(__FILE__)) . '/filters/';
    /* ### filter type: execute droplets filter for backend ################################# */
    if (OPF_DROPLETS_BE) {
        if (file_exists($sFilterDirectory . 'filterDropletsBe.php')) {
            require_once $sFilterDirectory . 'filterDropletsBe.php';
            $content = doFilterDropletsBe($content);
        }
    }
    /* ### filter type: fill out placeholders for Javascript, CSS, Metas and Title  ################################# */
    //now available in BE too
    if (defined("OPF_INSERT_BE") and OPF_INSERT_BE) {
        if (class_exists("I")) {
            $content = I::Filter($content);
        }
    }
    /* ### filter type: protect email addresses ################################# */
    // emailfilter not needed in BE
    /* ### filter type: change [wblinkxx] into real URLs ######################## */
    // would remove the [wblinkxxx] texts in CKE for example .. so no good idea
    /* ### filter type: short url (instead of a droplet) ########### */
    // Short url not functional in BE and not needed anyway
    /* ### filter type: full qualified URLs to relative URLs##################### */
    // would disturb BE functions
    /* ### filter type: moves css definitions from <body> into <head> ########### */
    //this one truly may stay in (lots  of old modules have inline CSS )
    // maybe we even declare having css in the module html as being just ok.
    if (defined("OPF_CSS_TO_HEAD_BE") and OPF_CSS_TO_HEAD_BE) {
        if (file_exists($sFilterDirectory . 'filterCssToHead.php')) {
            require_once $sFilterDirectory . 'filterCssToHead.php';
            $content = doFilterCssToHead($content);
        }
    }
    /* ### end of filters ####################################################### */
    return $content;
}
Exemplo n.º 15
0
    /**
     * 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;
            case 'widgetList':
                // Check some needed requirements ...
                if ($_GET[FRONTEND_SECTION_URL] == FRONTEND_AUDIO_URL) {
                    // Set some requirements ...
                    $objPag = isset($_GET[AUDIO_PAGE_URL]) ? $_GET[AUDIO_PAGE_URL] : new S((string) 1);
                    $objPag = new I((int) $objPag->toString());
                    // Fixes for a bugged user ...
                    if ($objPag->toInt() == 0) {
                        // 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 {
                        // Make it a string again ...
                        $objPag = new S((string) $objPag->toInt());
                    }
                    // Get your switches on ...
                    if (isset($_GET[AUDIO_ITEM_URL])) {
                        // Check that the article exists, before doing anything stupid ...
                        if ($this->checkAudioFileURLIsUnique($objURL = $_GET[AUDIO_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 {
                            // Make me SEO ... yah!
                            TPL::manageTTL($objTTL = $this->getAudioFileInfoByURL($objURL, self::$objAudioTableFTitle));
                            TPL::manageTTL($objART = $this->getAudioFileInfoByURL($objURL, self::$objAudioTableFArtist));
                            TPL::manageTTL($objALB = $this->getAudioFileInfoByURL($objURL, self::$objAudioTableFAlbum));
                            // SEO my category, little one ...
                            TPL::manageTTL($objCAT = MPTT::mpttRemoveUnique($this->getCategoryInfoById($this->getAudioFileInfoByURL($objURL, self::$objAudioTableFCategoryId), self::$objCategoryTableFName)));
                            // Get the published date ... we need it;
                            $objPBL = new S(date(self::$objFrontend->STG->getConfigKey(new S('settings_default_date_format')), (int) $this->getAudioFileInfoByURL($objURL, self::$objAudioTableFUploadedDate)->toString()));
                            // Get the keywords ...
                            $objKEY = $this->getAudioFileInfoByURL($objURL, self::$objAudioTableFDescription)->entityDecode(ENT_QUOTES)->stripTags();
                            // Get the description ...
                            $objDSC = $this->getAudioFileInfoByURL($objURL, self::$objAudioTableFDescription)->entityDecode(ENT_QUOTES)->stripTags();
                            // Cut it down to size ...
                            if ($objDSC->toLength()->toInt() > META_DESCRIPTION_MAX) {
                                $objDSC->doSubStr(0, META_DESCRIPTION_MAX)->appendString(_SP)->appendString(_DTE);
                            }
                            if ($objKEY->toLength()->toInt() > META_DESCRIPTION_MAX) {
                                $objKEY->doSubStr(0, META_DESCRIPTION_MAX)->appendString(_SP)->appendString(_DTE);
                            }
                            // Only description if it's bigger ...
                            if ($objDSC->toLength()->toInt() != 0) {
                                $objDSC = $objDSC->prependString($objWA['audio_description'])->prependString(', ');
                            }
                            // Get the description ... but prepend it with the Title, Artist, Album ...
                            $objDSC->prependString($objPBL)->prependString($objWA['audio_uploaded_at'])->prependString(', ')->prependString($objCAT)->prependString($objWA['audio_genre'])->prependString(', ')->prependString($objALB)->prependString($objWA['audio_album'])->prependString(', ')->prependString($objART)->prependString($objWA['audio_artist'])->prependString(', ')->prependString($objTTL)->prependString($objWA['audio_title']);
                            // Add them LYRICS ...
                            if ($this->getAudioFileInfoByURL($objURL, self::$objAudioTableFLyrics)->toLength()->toInt() != 0) {
                                // Yes ...
                                $objHasLrc = new S('Da');
                            } else {
                                // Nop ...
                                $objHasLrc = new S('Nu');
                            }
                            // Add them DESCRIPTIONS ...
                            if ($this->getAudioFileInfoByURL($objURL, self::$objAudioTableFDescription)->toLength()->toInt() != 0) {
                                // Yes ...
                                $objHasDsc = new S('Da');
                            } else {
                                // Nop ...
                                $objHasDsc = new S('Nu');
                            }
                            // Modify the DESCRIPTION ...
                            $objDSC->appendString(', ')->appendString($objWA['audio_lyrics'])->appendString($objHasLrc);
                            $objDSC->appendString(', ')->appendString($objWA['audio_description'])->appendString($objHasDsc);
                            // Add the TAG, as we have description ...
                            TPL::manageTAG(new S('description'), $objDSC->entityEncode(ENT_QUOTES));
                            // Add the TAG, as we have keywords ...
                            if ($objKEY->toLength()->toInt() != 0) {
                                TPL::manageTAG(new S('keywords'), $objKEY->eregReplace('[^a-zA-Z0-9 -]', _NONE)->eregReplace(_SP, ', ')->eregReplace(', ,', ',')->entityEncode(ENT_QUOTES));
                            }
                            // Set some requirements ...
                            $objPathToItem = self::$objMPTT->mpttGetSinglePath($this->getCategoryInfoById($this->getAudioFileInfoByURL($objURL, self::$objAudioTableFCategoryId), self::$objCategoryTableFName));
                            // Update them views ...
                            $this->_Q(_QS('doUPDATE')->doToken('%table', self::$objAudioTable)->doToken('%condition', new S('%objAudioTableFViews = %objAudioTableFViews + 1
							WHERE %objAudioTableFSEO = "%Id"'))->doToken('%Id', $objURL));
                            // Set the template file ...
                            $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . '-Item' . TPL_EXTENSION);
                            TPL::tpSet($objPathToItem, new S('objPathToItem'), $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('AUD'), $tpF);
                            TPL::tpExe($tpF);
                        }
                    } else {
                        if (isset($_GET[AUDIO_CATEGORY_URL])) {
                            // Check that the category exists, before doing anything stupid ...
                            if ($this->checkCategoryURLIsUnique($objCat = $_GET[AUDIO_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! ...
                                TPL::manageTTL(MPTT::mpttRemoveUnique($this->getCategoryInfoByURL($objCat, self::$objCategoryTableFName)));
                                // Make a condition to avoid dup. title tags on different pages ...
                                if ((int) $objPag->toString() >= 1 && isset($_GET[AUDIO_PAGE_URL])) {
                                    TPL::manageTTL(_S(AUDIO_PAGE_URL)->appendString(_SP)->appendString($objPag));
                                }
                                // Set some requirements ...
                                $objCnt = $this->getApprovedAudioFileCountForCategoryURL($objCat);
                                $objArt = $this->getApprovedAudioFilesByCategoryURLAndPage($objCat, $objPag);
                            }
                        } else {
                            if (isset($_GET[AUDIO_SEARCH_URL])) {
                                // Get audio by page ...
                                $objCnt = $this->getApprovedAudioFileCountForSearch($_GET[AUDIO_SEARCH_URL]);
                                $objArt = $this->getApprovedAudioFilesByPageAndSearch($objPag, $_GET[AUDIO_SEARCH_URL]);
                            } else {
                                // Do me SEO, yah baby! ...
                                TPL::manageTTL(_S(FRONTEND_AUDIO_URL));
                                // Make a condition to avoid dup. title tags on different pages ...
                                if ((int) $objPag->toString() >= 1 && isset($_GET[AUDIO_PAGE_URL])) {
                                    TPL::manageTTL(_S(AUDIO_PAGE_URL)->appendString(_SP)->appendString($objPag));
                                }
                                // Set some requirements ...
                                $objArt = $this->getApprovedAudioFilesByPage($objPag);
                                $objCnt = $this->getApprovedAudioFileCount();
                            }
                        }
                        // Set the template file ...
                        $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION);
                        TPL::tpSet($objWA, new S('objWidgetArray'), $tpF);
                        TPL::tpSet($objArt, new S('objAr'), $tpF);
                        TPL::tpExe($tpF);
                        // Set them paginations ...
                        if ($objCnt->toInt() > (int) self::$objItemsPerPage->toString()) {
                            self::$objFrontend->setPagination($objCnt, new I((int) self::$objItemsPerPage->toString()));
                        }
                    }
                } else {
                    // Do the biggest error on the PLANET ...
                    self::renderScreenOfDeath(new S(__CLASS__), new S(AUDIO_NEED_PROPER_SECTION), new S(AUDIO_NEED_PROPER_SECTION_FIX));
                }
                // BK;
                break;
            case 'widgetComments':
                // Check if we have the proper URL enabled ...
                if (isset($_GET[AUDIO_ITEM_URL])) {
                    // Check if the comments are enabled ...
                    if ($this->getAudioFileInfoByURL($objURL = $_GET[AUDIO_ITEM_URL], self::$objAudioTableFCanComment) == 'Y') {
                        // Set some requirements ...
                        $objCommentIsOk = new S();
                        $objComments = $this->getApprovedCommentsByAudioFileURL($_GET[AUDIO_ITEM_URL], new S('ORDER BY %objCommentsTableFDate DESC'));
                        // Check for status ...
                        if (isset($_GET[AUDIO_STATUS_URL])) {
                            if ($_GET[AUDIO_STATUS_URL] == AUDIO_STATUS_OK_URL) {
                                $objCommentIsOk = new S($objWA['comment_has_been_added']);
                            }
                        }
                        // Set the template file ...
                        $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION);
                        TPL::tpSet($objCommentIsOk, new S('objCommentIsOk'), $tpF);
                        TPL::tpSet($objComments, new S('objComments'), $tpF);
                        TPL::tpSet($this->STG, new S('STG'), $tpF);
                        TPL::tpSet($this->ATH, new S('ATH'), $tpF);
                        TPL::tpExe($tpF);
                        // Set some requirements ...
                        $objShowFrm = new B(TRUE);
                        // Check if we're allowed to show the comment form ...
                        if ($this->getConfigKey(new S('audio_settings_audio_auth_to_comment')) == 'Y') {
                            if ($this->ATH->checkIfUserIsLoggedIn()->toBoolean() == TRUE) {
                                // To show ... or not ...
                                $objShowFrm = new B(TRUE);
                            } else {
                                // to show ... or not ...
                                $objShowFrm = new B(FALSE);
                            }
                        }
                        // Do some work ...
                        if ($objShowFrm->toBoolean() == TRUE) {
                            if ($this->checkPOST(self::$objCommentsTableFComment)->toBoolean() == TRUE) {
                                if ($this->getPOST(self::$objCommentsTableFComment)->toLength()->toInt() == 0) {
                                    $this->setErrorOnInput(self::$objCommentsTableFComment, new S($objWA['error_no_comment']));
                                }
                            }
                            if ($this->checkPOST(self::$objCommentsTableFName)->toBoolean() == TRUE) {
                                if ($this->getPOST(self::$objCommentsTableFName)->toLength()->toInt() == 0) {
                                    $this->setErrorOnInput(self::$objCommentsTableFName, new S($objWA['error_no_name']));
                                }
                            }
                            if ($this->checkPOST(self::$objCommentsTableFEML)->toBoolean() == TRUE) {
                                if ($this->getPOST(self::$objCommentsTableFEML)->toLength()->toInt() == 0) {
                                    $this->setErrorOnInput(self::$objCommentsTableFEML, new S($objWA['error_no_email']));
                                }
                            }
                            // Make the form ... (ya, outside the box ...);
                            $this->setMethod(new S('POST'))->setFieldset(new S($objWA['comment_add']))->setSQLAction(new S('update'))->setTableName(self::$objCommentsTable)->setUpdateId(new S('#nextTableAutoIncrement'))->setUpdateField(self::$objCommentsTableFId);
                            if ($this->checkPOST(self::$objCommentsTableFComment)->toBoolean() == TRUE) {
                                $this->setRedirect(URL::rewriteURL(new A(array(AUDIO_STATUS_URL)), new A(array(AUDIO_STATUS_OK_URL))));
                            }
                            $this->setName(new S('commentForm'))->setExtraUpdateData(self::$objCommentsTableFDate, new S((string) time()))->setExtraUpdateData(self::$objCommentsTableFAudioFileId, $this->getAudioFileInfoByURL($_GET[AUDIO_ITEM_URL], self::$objAudioTableFId))->setInputType(new S('submit'))->setValue(new S($objWA['comment_submit']))->setName(new S('submit'))->setContainerDiv(new B(TRUE));
                            // Check if the user is authenticated ...
                            if ($this->ATH->checkIfUserIsLoggedIn()->toBoolean() == TRUE) {
                                // Set the RUId;
                                $this->setExtraUpdateData(self::$objCommentsTableFRUId, $this->ATH->getCurrentUserInfoById(Authentication::$objAuthUsersTableFId));
                            } else {
                                // Set the other infos;
                                $this->setInputType(new S('text'))->setName(self::$objCommentsTableFName)->setLabel(new S($objWA['comment_name']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objCommentsTableFEML)->setLabel(new S($objWA['comment_email']))->setContainerDiv(new B(TRUE))->setInputType(new S('text'))->setName(self::$objCommentsTableFURL)->setLabel(new S($objWA['comment_website']))->setContainerDiv(new B(TRUE));
                            }
                            // Continue ...
                            $this->setInputType(new S('textarea'))->setName(self::$objCommentsTableFComment)->setLabel(new S($objWA['comment_message']))->setRows(new S('10'))->setTinyMCETextarea(new B(TRUE))->setClass(new S('tinyMCESimple'))->setContainerDiv(new B(TRUE));
                            // Notify ...
                            if ($this->checkFormHasErrors()->toBoolean() == FALSE && $this->checkPOST(self::$objCommentsTableFComment)->toBoolean() == TRUE) {
                                if ($this->ATH->checkIfUserIsLoggedIn()->toBoolean() == TRUE) {
                                    // Query the authentication ...
                                    $objUSR = $this->ATH->getCurrentUserInfoById(Authentication::$objAuthUsersTableFUName);
                                } else {
                                    // Or trust the FORM ...
                                    $objUSR = $this->getPOST(self::$objCommentsTableFName);
                                }
                                // Go and SP ... MAIL me ...
                                $objMAIL = new MAIL();
                                $objMAIL->doMAIL($this->STG->getConfigKey(new S('settings_website_notification_email')), new S(AUDIO_COMMENT_HAS_BEEN_POSTED), $this->getHELP(new S('widgetCommentsCommentPosted'))->doToken('%t', $this->getAudioFileInfoByURL($objURL, self::$objAudioTableFTitle))->doToken('%a', $this->getAudioFileInfoByURL($objURL, self::$objAudioTableFArtist))->doToken('%b', $this->getAudioFileInfoByURL($objURL, self::$objAudioTableFAlbum))->doToken('%u', $objUSR));
                                // Go deeper and notify them users ...
                                $objCommentsForItem = $this->getCommentsByAudioFileURL($objURL);
                                foreach ($objCommentsForItem as $k => $v) {
                                    $objMAIL = new MAIL();
                                    $objMAIL->doMAIL($this->ATH->getUserInfoById($v[self::$objCommentsTableFRUId], Authentication::$objAuthUsersTableFEML), new S(AUDIO_COMMENT_HAS_BEEN_POSTED), $this->getHELP(new S('widgetCommentsCommentPostedFrontend'))->doToken('%t', $this->getAudioFileInfoByURL($objURL, self::$objAudioTableFTitle))->doToken('%a', $this->getAudioFileInfoByURL($objURL, self::$objAudioTableFArtist))->doToken('%b', $this->getAudioFileInfoByURL($objURL, self::$objAudioTableFAlbum))->doToken('%u', $objUSR)->doToken('%k', URL::rewriteURL()));
                                }
                            }
                            // End form and execute ...
                            $this->setFormEndAndExecute(new B(TRUE));
                        }
                    }
                }
                // BK;
                break;
            case 'widgetUploadForm':
                // Ya, checking the STATUS ...
                if (isset($_GET[AUDIO_STATUS_URL])) {
                    // Get me going my dear one ...
                    $objConfKey = new S('audio_settings_audio_form_page_status_ok');
                    $objShowFrm = new B(FALSE);
                } else {
                    // Get me going my dear one ...
                    $objConfKey = new S('audio_settings_audio_form_page');
                    $objShowFrm = new B(TRUE);
                }
                // If we're NOT authenticated ... bang, you're DEAD ...
                if ($this->ATH->checkIfUserIsLoggedIn()->toBoolean() == FALSE) {
                    // Get me going my dear one ...
                    $objConfKey = new S('audio_settings_audio_form_not_authenticated');
                    $objShowFrm = new B(FALSE);
                }
                // Set the template file ...
                $tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION);
                TPL::tpSet($this->getConfigKey($objConfKey), new S('objContent'), $tpF);
                TPL::tpSet($objWA, new S('objWidgetArray'), $tpF);
                TPL::tpSet($objShowFrm, new S('objShowForm'), $tpF);
                TPL::tpSet($this, new S('AUD'), $tpF);
                TPL::tpExe($tpF);
                break;
            case 'widgetLastN':
                // Do CACHE ...
                if ($cId = TPL::tpIni($tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION), new I(180))) {
                    // Set the template file ...
                    TPL::tpSet($this->getApprovedAudioFiles(_S('ORDER BY %objAudioTableFUploadedDate DESC LIMIT 0, %UpperLimit')->doToken('%UpperLimit', $objWA['audio_n_count'])), new S('objLastN'), $tpF);
                    TPL::tpSet($objWA, new S('objWidgetArray'), $tpF);
                    TPL::tpSet($this, new S('AUD'), $tpF);
                    TPL::tpExe($tpF);
                    TPL::tpEnd($cId);
                }
                // BK;
                break;
            case 'widgetRandomN':
                // Do CACHE ...
                if ($cId = TPL::tpIni($tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION), new I(180))) {
                    // Set the template file ...
                    TPL::tpSet($this->getApprovedAudioFiles(_S('ORDER BY RAND() LIMIT 0, %UpperLimit')->doToken('%UpperLimit', $objWA['audio_n_count'])), new S('objRandomN'), $tpF);
                    TPL::tpSet($objWA, new S('objWidgetArray'), $tpF);
                    TPL::tpSet($this, new S('AUD'), $tpF);
                    TPL::tpExe($tpF);
                    TPL::tpEnd($cId);
                }
                // BK;
                break;
            case 'widgetRelatedN':
                // Do CACHE ...
                if ($cId = TPL::tpIni($tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION), new I(180))) {
                    // Set the template file ...
                    TPL::tpSet($this->getApprovedAudioFiles(_S('AND %objAudioTableFArtist LIKE "%Id" LIMIT 0, %UpperLimit')->doToken('%Id', $this->getAudioFileInfoByURL($objWA['audio_song_item'], self::$objAudioTableFArtist))->doToken('%UpperLimit', $objWA['audio_n_count'])), new S('objRandomN'), $tpF);
                    TPL::tpSet($objWA, new S('objWidgetArray'), $tpF);
                    TPL::tpSet($this, new S('AUD'), $tpF);
                    TPL::tpExe($tpF);
                    TPL::tpEnd($cId);
                }
                // BK;
                break;
            case 'widgetTopN':
                // Do CACHE ...
                if ($cId = TPL::tpIni($tpF = new FilePath($this->getPathToSkin()->toRelativePath() . $objW . TPL_EXTENSION), new I(180))) {
                    // Set the template file ...
                    TPL::tpSet($this->getApprovedAudioFiles(_S('ORDER BY %objAudioTableFViews DESC LIMIT 0, %UpperLimit')->doToken('%UpperLimit', $objWA['audio_n_count'])), new S('objRandomN'), $tpF);
                    TPL::tpSet($objWA, new S('objWidgetArray'), $tpF);
                    TPL::tpSet($this, new S('AUD'), $tpF);
                    TPL::tpExe($tpF);
                    TPL::tpEnd($cId);
                }
                // BK;
                break;
            case 'widgetRandomItem':
                // Do some work ...
                if ($this->checkPOST(new S('search_random_item'))->toBoolean() == TRUE) {
                    // Get me there ... quick ...
                    $this->setHeaderKey(URL::staticURL(new A(array(AUDIO_ITEM_URL, FRONTEND_SECTION_URL)), new A(array($this->getApprovedAudioFiles(_S('ORDER BY RAND() LIMIT 1'))->offsetGet(0)->offsetGet(self::$objAudioTableFSEO), FRONTEND_AUDIO_URL))), new S('Location'));
                }
                // Do the form, make it happen ...
                $this->setMethod(new S('POST'))->setName(new S('audioRandomItem'))->setInputType(new S('submit'))->setName(new S('search_random_item'))->setValue(new S($objWA['audio_random']))->setContainerDiv(new B(TRUE))->setFormEndAndExecute(new B(TRUE));
                break;
        }
    }
 function register_frontend_modfiles($file_id = "css", $return = false)
 {
     // sanitize value
     $file_id = strtolower($file_id);
     if ($file_id == "javascript") {
         $file_id = "js";
     }
     // no valid value , return whith nothing
     if ($file_id !== "css" && $file_id !== "js" && $file_id !== "jquery") {
         return;
     }
     // Variable declarations
     static $call_count = 0;
     // Add system values only once
     global $wb, $database, $include_head_link_css, $include_head_links;
     // define default baselink and filename for optional module javascript and stylesheet files
     $head_links = "";
     // Echo systemvars only once
     if (!$call_count and $file_id != "css") {
         $head_links .= wb_make_js_sys_vars();
         // Sysvars always added to Insert
         I::DelJs("wbsysvars");
     }
     // defines different "templates" for rendering the Link (css/js)
     // no templates needed for Jquery
     switch ($file_id) {
         case 'css':
             $head_links = $include_head_link_css;
             $base_link = '<link href="' . WB_URL . '/modules/{MODULE_DIRECTORY}/frontend.css"';
             $base_link .= ' rel="stylesheet" type="text/css" media="screen" />';
             $base_file = "frontend.css";
             break;
         case 'jquery':
             $head_links .= wb_bind_jquery($file_id);
             $call_count++;
             break;
         case 'js':
             $head_links = $include_head_links;
             $base_link = '<script src="' . WB_URL . '/modules/{MODULE_DIRECTORY}/frontend.js" type="text/javascript"></script>';
             $base_file = "frontend.js";
             $call_count++;
             break;
     }
     if ($file_id != 'jquery') {
         // gather information for all models embedded on actual page
         $page_id = $wb->page_id;
         $sql = 'SELECT `module` FROM `' . TABLE_PREFIX . 'sections` ';
         $sql .= 'WHERE `page_id` = ' . (int) $page_id . ' AND `module`<>\'wysiwyg\'';
         if ($query_modules = $database->query($sql)) {
             while ($row = $query_modules->fetchRow()) {
                 // check if page module directory contains a frontend.js or frontend.css file
                 if (file_exists(WB_PATH . "/modules/" . $row['module'] . "/{$base_file}")) {
                     // create link with frontend.js or frontend.css source for the current module
                     $tmp_link = str_replace("{MODULE_DIRECTORY}", $row['module'], $base_link);
                     // ensure that frontend.js or frontend.css is only added once per module type
                     // as it can be loaded already by a snippet
                     if (strpos($head_links, $tmp_link) === false) {
                         $head_links .= $tmp_link . "\n";
                     }
                 }
             }
         }
     }
     if ($return) {
         return $head_links;
     }
     print $head_links;
 }
Exemplo n.º 17
0
 /**
  * Will return a string containing three lines from the PHP file that was in a debug_backtrace, by parsing the previous, current and
  * next line from the debugged file. It's an easy way to get the content of a file in many circumstances. Also, for EVAL'ed code,
  * where we actually don't have a file, we issue a default NULL string back to the calling method so execution can go on;
  *
  * @param S $codeFile The path to the file to be GeSHi'ed
  * @param S $codeLine The number of line (+/-1) that should be GeSHi'ed
  * @author Catalin Z. Alexandru <*****@*****.**>
  * @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 private
  * @static
  */
 private static function getDebugCodeLine(S $codeFile, I $codeLine)
 {
     // S make;
     $theString = new S();
     // Get the file array from the passed argument;
     if (WIN == TRUE) {
         // Get the contents;
         if (file_exists($codeFile)) {
             // PHP Code: FILE;
             $theFileArray = file($codeFile->doToken(DOCUMENT_ROOT, _NONE)->toString(), FILE_SKIP_EMPTY_LINES);
         } else {
             // PHP Code: EVAL;
             return new S(_NONE);
         }
     } else {
         // Get the contents;
         if (file_exists($codeFile)) {
             // PHP Code: FILE;
             $theFileArray = file($codeFile->toString(), FILE_SKIP_EMPTY_LINES);
         } else {
             // PHP Code: EVAL;
             return new S(_NONE);
         }
     }
     // Files that are bellow 3 LINES have problems, so here's the fix;
     if (count($theFileArray) >= 3) {
         if (isset($theFileArray[$codeLine->toInt() - 2])) {
             $theString->setString($theFileArray[$codeLine->toInt() - 2] . $theFileArray[$codeLine->toInt() - 1] . $theFileArray[$codeLine->toInt()]);
         }
     } else {
         if (count($theFileArray) == 1) {
             $theString->setString($theFileArray[$codeLine->toInt() - 1]);
         } else {
             if (count($theFileArray) == 2) {
                 $theString->setString($theFileArray[$codeLine->toInt() - 1] . $theFileArray[$codeLine->toInt()]);
             }
         }
     }
     // We should empty theFileArray straight away, and return the string;
     unset($theFileArray);
     return $theString;
 }
Exemplo n.º 18
0
Arquivo: C.php Projeto: hfw/h
 /**
  * Polls. A cache entry is considered valid if the following conditions are met:
  *
  * - The cache file exists.
  * - Its modification time is not less than {@link $mtime}
  * - It has not expired yet according to {@link $ttl}
  *
  * @return bool
  */
 protected function isValid()
 {
     return file_exists($this->path) and filemtime($this->path) >= $this->mtime and filemtime($this->path) + $this->ttl > I::time();
 }
 /**
     @brief The Workhorse that does the actuall inserting.
 
     Inserts all necessary settings and configurations into the Template using the I(Insert) class  
 */
 public function linkSciptsAndStylesheets()
 {
     // DateTimePicker CSS
     $cssFile = WB_URL . '/modules/date_time_picker/XDSoftDateTimePicker/css/jquery.datetimepicker.css';
     I::AddCss(array('setname' => "datetimepicker_css", 'href' => $cssFile, 'media' => "screen"));
     // DateTimePicker_overrides.css
     $cssOverrides = THEME_URL . '/css/date_time_picker_override.css';
     if (is_readable(str_replace(WB_URL, WB_PATH, $cssOverrides))) {
         I::AddCss(array('setname' => "datetimepicker_overrides_css", 'href' => $cssOverrides, 'media' => "screen"));
     }
     // DateTimePicker Plugin JS File
     $jsFile = WB_URL . '/modules/date_time_picker/XDSoftDateTimePicker/js/jquery.datetimepicker.full.min.js';
     I::AddJs(array('setname' => "datetimepicker_js", 'position' => "HeadLow", 'src' => $jsFile));
     echo '<script type="text/javascript" src="' . $jsFile . '"></script>';
     $sPluginCfg = " lang: '" . strtolower(LANGUAGE) . "'";
     // take care of the leading comma (,) before each new setting
     $sPluginCfg .= $this->mask == true ? '", mask: "true' : '';
     $sPluginCfg .= $this->lazyInit == true ? ", lazyInit: 'true'" : '';
     $sPluginCfg .= $this->step != 60 ? ", step: " . $this->step : '';
     if ($this->timepicker == false) {
         $sPluginCfg .= ", timepicker: 'false'";
     } else {
         $sPluginCfg .= ", formatTimeScroller: '" . $this->sTimeFormat . "'";
     }
     if ($this->datepicker == false) {
         $sPluginCfg .= ", datepicker: 'false'";
     }
     $sPluginCfg .= ", format: '" . $this->sDateTimeFormat . "'";
     //generate inlineJS from above string and add to Queue
     if ($this->selector != '') {
         global $TEXT;
         $sJS = "\r\n\t\t\t\tvar THEME_URL = '" . THEME_URL . "';\r\n\t\t\t\t\$(document).ready(function(){\r\n\t\t\t\t\t\r\n\t\t\t\t\t\$.datetimepicker.setLocale('" . strtolower(LANGUAGE) . "');\r\n\t\t\t\t\tvar DELETE_DATE = Boolean(" . $this->delete_date_handle . ");\r\n\t\t\t\t\tvar SELECTOR = \$(\"[rel='" . $this->selector . "']\");\r\n\t\t\t\t\tSELECTOR.datetimepicker({" . $sPluginCfg . "});\r\n\t\t\t\t\t\r\n\t\t\t\t\t// add ICONS\r\n\t\t\t\t\tSELECTOR.each(function() {\t\t\r\n\t\t\t\t\t\tvar oInputField = this;\r\n\t\t\t\t\t\tvar sFieldID = this.getAttribute('id');\r\n\t\t\t\t\t\tvar CAL_ICON = ' <img alt=\"[show cal]\" rel=\"' + sFieldID + '\" id=\"show_' + sFieldID + '\" class=\"showcal\"  src=\"' + THEME_URL +'/images/calendar_16.png\" title=\"" . $TEXT['CALENDAR'] . "\">';\r\n\t\t\t\t\t\tif(DELETE_DATE == true){\r\n\t\t\t\t\t\t\tvar RESET_ICON = ' <img alt=\"[reset]\" rel=\"reset_' + sFieldID + '\" class=\"reset_datetime\" src=\"' + THEME_URL +'/images/clock_del_16.png\" title=\"" . $TEXT['DELETE_DATE'] . "\">';\r\n\t\t\t\t\t\t}else{ \r\n\t\t\t\t\t\t\tvar RESET_ICON = '';\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\$(this).after(CAL_ICON + RESET_ICON);\r\n\t\t\t\t\t\tvar RESET_ICON2 = \$(\"img.reset[rel=\" + sFieldID + \"]\");\r\n\t\t\t\t\t\tif(\$(this).val() == ''){\r\n\t\t\t\t\t\t\tRESET_ICON2.css({ opacity: 0.2 });\r\n\t\t\t\t\t\t}else{\r\n\t\t\t\t\t\t\tRESET_ICON2.css('cursor', 'pointer').click(function() {\r\n\t\t\t\t\t\t\t   \$('input#' + sFieldID).val('');\r\n\t\t\t\t\t\t\t   RESET_ICON2.css({ opacity: 0.8 });\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t}\t\r\n\t\t\t\t\t\t\$('#show_' + sFieldID).css('cursor', 'pointer').click(function(){\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t  oInputField.focus();\t\t\r\n\t\t\t\t\t\t});\t\t\r\n\t\t\t\t\t});\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t// empty date input\r\n\t\t\t\t\tif(DELETE_DATE == true){\r\n\t\t\t\t\t\t\$('.reset_datetime').click(function () {\r\n\t\t\t\t\t\t\tvar FIELD = this.getAttribute('rel');\r\n\t\t\t\t\t\t\tvar ID = '#' + FIELD.replace('reset_', '');\r\n\t\t\t\t\t\t\t\$(ID).attr('value', '');\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t});\r\n\t\t\t";
         I::AddJs(array('setname' => "DateTimePicker", 'position' => "BodyLow", 'script' => $sJS));
     }
 }
Exemplo n.º 20
0
# map() is much like array_map in php or map in ruby, perl or haskell. it requires a function as an argument
# and is available to any Enumerable object and returns an Array
# each_with_index() accepts a 2-place function with the index and value of each element within the Enumerable object

$a->map(function($x) { return $x / 5; })->each_with_index(function($i, $x) { echo $i.' => '.$x."\n"; });

echo "getting methods\n";

# the method 'methods' is availble to any object and returns an Array of all methods the objecth as available to it.

echo "sorting/joining methods : ".$a->methods()->sort()->join(' ')."\n";

# any Enumerable object can be sorted so long as the the objects contained within the Enumerable object are 'Comparable'

echo "sorting some various integers : ".A(1,4,6,4,2,23,4,4,11,111)->map(function($x) { return I::N($x); })->sort()->join(' ')."\n";

echo "assigning a string\n";

# creating a String (S) is much like creating an Array
# the String class is actually named S

$s = new S("I'm with stupid");
$s = S("Magical");

echo "the string is : ".$s."\n";

echo "interating over a string\n";

# map() on a string works but returns an Array
# reverse_each() is a superfluous iterator method like each() but in reverse
Exemplo n.º 21
0
 /**
  * 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);
 }
$c = new C();
$c->__construct();
$c->sMeth();
$c = new D();
$c->D();
$c = new E();
$c->E();
$c->__construct();
$c = new F();
$c->__construct();
$c = new G();
$c->D();
$c = new H();
$c->E();
$c->__construct();
$c = new I();
$c->__construct();
$c = new J();
$c->D();
$c->J();
$c = new K();
$c->E();
$c->K();
$c->__construct();
$c = new C();
$m = "__construct";
$c->{$m}();
$m = "sMeth";
$c->{$m}();
$c = new D();
$m = "D";
Exemplo n.º 23
0
        print "In K::K()\n";
    }
    function __construct()
    {
        print "In K::__construct()\n";
    }
}
C::__construct();
D::D();
E::E();
E::__construct();
F::__construct();
G::D();
H::E();
H::__construct();
I::__construct();
J::D();
J::J();
K::E();
K::K();
K::__construct();
$X = "C";
$m = "__construct";
C::$m();
$X::$m();
$X = "D";
$m = "D";
D::$m();
$X::$m();
$X::$m();
$X = "E";
Exemplo n.º 24
0
 public function testChangingBelongsToSideOfHasManyRelation()
 {
     $k1 = new K();
     $k2 = new K();
     $i = new I();
     $i->ks->add($k1);
     $i->ks->add($k2);
     $this->assertTrue($i->save());
     $this->assertEquals(2, $i->ks->count());
     $k1->i = null;
     $this->assertTrue($k1->save());
     $iId = $i->id;
     $i->forget();
     unset($i);
     $i = I::getById($iId);
     $this->assertEquals(1, $i->ks->count());
     $i->ks->removeByIndex(0);
     $this->assertTrue($i->save());
     $this->assertEquals(0, $i->ks->count());
     $k2Id = $k2->id;
     $k2->forget();
     unset($k2);
     $k2 = K::getById($k2Id);
     $this->assertTrue($k2->i->id < 0);
 }
Exemplo n.º 25
0
 /**
  * Will count the number of segments in an URL string, returning it as an integer. This method is used to calculate from where
  * we start processing the URL as key/var pairs. It's an internal method that's used only by core developers.
  *
  * @param S $websiteURL The string URL to count segments for
  * @return I The number of segments in the given URL
  * @copyright Elena Ramona <*****@*****.**>
  * @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 countSegments(S $websiteURL)
 {
     // Execute the count;
     if ($websiteURL != _NONE) {
         $k = new I(0);
         foreach (explode(_WS, preg_replace(self::GET_URL_PREG_SEARCH, self::GET_URL_PREG_REPLAC, $websiteURL)) as $v) {
             if ($v != _NONE) {
                 $k->doInc();
             }
         }
         return $k;
     } else {
         $k = new I(0);
         return $k;
     }
 }
Exemplo n.º 26
0
 public static function getDefaultMetadata()
 {
     $metadata = parent::getDefaultMetadata();
     $metadata[__CLASS__] = array('relations' => array());
     return $metadata;
 }
Exemplo n.º 27
0
 /**
  * Will return an unique code, based on a combination of sha1 and uniqid. First of ALL: do not relly on this method to return
  * the same hash code again and again, as for a combination of sha1 (2^64) it will never return the same code twice upon a large
  * field of possible situations. This method is rarelly used but has been promoted as a CORE method to generate a hased unique code
  * for different purposes (weak encryption, random things, etc.);
  * <code>
  * <?php
  *		// Get an unique code
  *		echo EXE::getUniqueCode (); # Will return a sha1 (uniqid ());
  * ?>
  * </code>
  *
  * @param I $objLength The length of the string to get
  * @return S The code, stripped down to the desired length
  * @author Catalin Z. Alexandru <*****@*****.**>
  * @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 2.0
  * @access public
  * @static
  * @final
  */
 public static final function getUniqueCode(I $objLength = NULL)
 {
     // Get the code, from an md5, of uniqid;
     $objCode = new S(sha1(uniqid(rand(), TRUE)));
     // Either get it FULL, or just first N chars;
     if ($objLength == NULL) {
         // Return the code;
         return $objCode;
     } else {
         // Check something ...
         if ($objLength->toInt() > $objCode->toLength()->toInt()) {
             // Return the code;
             return $objCode;
         } else {
             // Trim it down to size ...
             return $objCode->doSubStr(0, $objLength->toInt());
         }
     }
 }