added paging chunks to maplist
This commit is contained in:
		| @@ -11,7 +11,7 @@ use FML\Script\ScriptInclude; | ||||
|  | ||||
| /** | ||||
|  * Script Feature realising a Mechanism for browsing through Pages | ||||
|  * | ||||
|  *  | ||||
|  * @author steeffeen | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
|  * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 | ||||
| @@ -29,7 +29,7 @@ class Paging extends ScriptFeature { | ||||
| 	protected $pages = array(); | ||||
| 	protected $buttons = array(); | ||||
| 	protected $label = null; | ||||
| 	protected $customMinPageNumber = null; | ||||
| 	protected $startPageNumber = null; | ||||
| 	protected $customMaxPageNumber = null; | ||||
| 	protected $previousChunkAction = null; | ||||
| 	protected $nextChunkAction = null; | ||||
| @@ -37,7 +37,7 @@ class Paging extends ScriptFeature { | ||||
|  | ||||
| 	/** | ||||
| 	 * Construct a new Paging Script Feature | ||||
| 	 * | ||||
| 	 *  | ||||
| 	 * @param Label $label (optional) Page Number Label | ||||
| 	 */ | ||||
| 	public function __construct(Label $label = null) { | ||||
| @@ -48,7 +48,7 @@ class Paging extends ScriptFeature { | ||||
|  | ||||
| 	/** | ||||
| 	 * Add a new Page Control | ||||
| 	 * | ||||
| 	 *  | ||||
| 	 * @param Control $pageControl Page Control | ||||
| 	 * @param string $pageNumber (optional) Page Number | ||||
| 	 * @return \FML\Script\Features\Paging | ||||
| @@ -64,7 +64,7 @@ class Paging extends ScriptFeature { | ||||
|  | ||||
| 	/** | ||||
| 	 * Append a Page | ||||
| 	 * | ||||
| 	 *  | ||||
| 	 * @param PagingPage $page Paging Page | ||||
| 	 * @return \FML\Script\Features\Paging | ||||
| 	 */ | ||||
| @@ -75,7 +75,7 @@ class Paging extends ScriptFeature { | ||||
|  | ||||
| 	/** | ||||
| 	 * Add a new Button to browse through the Pages | ||||
| 	 * | ||||
| 	 *  | ||||
| 	 * @param Control $buttonControl Button used for Browsing | ||||
| 	 * @param int $browseAction (optional) Number of browsed Pages per Click | ||||
| 	 * @return \FML\Script\Features\Paging | ||||
| @@ -97,7 +97,7 @@ class Paging extends ScriptFeature { | ||||
|  | ||||
| 	/** | ||||
| 	 * Append a Button to browse through Pages | ||||
| 	 * | ||||
| 	 *  | ||||
| 	 * @param PagingButton $button Paging Button | ||||
| 	 * @return \FML\Script\Features\Paging | ||||
| 	 */ | ||||
| @@ -108,7 +108,7 @@ class Paging extends ScriptFeature { | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Label showing the Page Number | ||||
| 	 * | ||||
| 	 *  | ||||
| 	 * @param Label $label Page Number Label | ||||
| 	 * @return \FML\Script\Features\Paging | ||||
| 	 */ | ||||
| @@ -119,19 +119,18 @@ class Paging extends ScriptFeature { | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set a custom Minimum Page Number for using Chunks | ||||
| 	 * | ||||
| 	 * @param int $minPageNumber Custom Minimum Page Number | ||||
| 	 * Set the Start Page Number | ||||
| 	 *  | ||||
| 	 * @param int $startPageNumber Page Number to start with | ||||
| 	 * @return \FML\Script\Features\Paging | ||||
| 	 */ | ||||
| 	public function setCustomMinPageNumber($minPageNumber) { | ||||
| 		$this->customMinPageNumber = (int) $minPageNumber; | ||||
| 		return $this; | ||||
| 	public function setStartPageNumber($startPageNumber) { | ||||
| 		$this->startPageNumber = (int) $startPageNumber; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set a custom Maximum Page Number for using Chunks | ||||
| 	 * | ||||
| 	 *  | ||||
| 	 * @param int $maxPageNumber Custom Maximum Page Number | ||||
| 	 * @return \FML\Script\Features\Paging | ||||
| 	 */ | ||||
| @@ -142,7 +141,7 @@ class Paging extends ScriptFeature { | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Action triggered when the previous Chunk is needed | ||||
| 	 * | ||||
| 	 *  | ||||
| 	 * @param string $previousChunkAction Triggered Action | ||||
| 	 * @return \FML\Script\Features\Paging | ||||
| 	 */ | ||||
| @@ -153,7 +152,7 @@ class Paging extends ScriptFeature { | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Action triggered when the next Chunk is needed | ||||
| 	 * | ||||
| 	 *  | ||||
| 	 * @param string $nextChunkAction Triggered Action | ||||
| 	 * @return \FML\Script\Features\Paging | ||||
| 	 */ | ||||
| @@ -162,9 +161,21 @@ class Paging extends ScriptFeature { | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the Actions triggered when another Chunk is needed | ||||
| 	 *  | ||||
| 	 * @param string $chunkAction Triggered Action | ||||
| 	 * @return \FML\Script\Features\Paging | ||||
| 	 */ | ||||
| 	public function setChunkActions($chunkAction) { | ||||
| 		$this->setNextChunkAction($chunkAction); | ||||
| 		$this->setPreviousChunkAction($chunkAction); | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set if the Chunk Action should get the needed Page Number appended | ||||
| 	 * | ||||
| 	 *  | ||||
| 	 * @param bool $appendPageNumber Whether to append the needed Page Number | ||||
| 	 * @return \FML\Script\Features\Paging | ||||
| 	 * | ||||
| @@ -187,19 +198,15 @@ class Paging extends ScriptFeature { | ||||
| 		$currentPageVariable = self::VAR_CURRENT_PAGE; | ||||
| 		$updatePageFunction = self::FUNCTION_UPDATE_CURRENT_PAGE; | ||||
| 		 | ||||
| 		$minPage = $this->getMinPage(); | ||||
| 		$startPageNumber = $minPage->getPageNumber(); | ||||
| 		$minPageNumber = $startPageNumber; | ||||
| 		if (is_int($this->customMinPageNumber)) { | ||||
| 			$minPageNumber = $this->customMinPageNumber; | ||||
| 		} | ||||
| 		$minPageNumber = 1; | ||||
| 		$startPageNumber = (is_int($this->startPageNumber) ? $this->startPageNumber : $minPageNumber); | ||||
| 		$maxPage = $this->getMaxPage(); | ||||
| 		$maxPageNumber = $maxPage->getPageNumber(); | ||||
| 		if (is_int($this->customMaxPageNumber)) { | ||||
| 			$maxPageNumber = $this->customMaxPageNumber; | ||||
| 		$maxPageNumber = $this->customMaxPageNumber; | ||||
| 		if (!is_int($maxPageNumber)) { | ||||
| 			$maxPageNumber = $maxPage->getPageNumber(); | ||||
| 		} | ||||
| 		 | ||||
| 		$pagingId = $minPage->getControl()->getId(true); | ||||
| 		$pagingId = $maxPage->getControl()->getId(true); | ||||
| 		$pageLabelId = ''; | ||||
| 		if ($this->label) { | ||||
| 			$pageLabelId = $this->label->getId(true); | ||||
| @@ -247,6 +254,7 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct | ||||
| 			PageFound = True; | ||||
| 		} | ||||
| 	} | ||||
| 	log(Now^PageFound^CurrentPage^_Pages); | ||||
| 	if (!PageFound && _BrowseAction != 0) { | ||||
| 		declare Text ChunkAction; | ||||
| 		if (_BrowseAction < 0) { | ||||
| @@ -257,6 +265,7 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct | ||||
| 		if (_ChunkActionAppendPageNumber) { | ||||
| 			ChunkAction ^= CurrentPage; | ||||
| 		} | ||||
| 		log(Now^ChunkAction); | ||||
| 		TriggerPageAction(ChunkAction); | ||||
| 	} | ||||
| 	if (_PageLabelId == \"\") return; | ||||
| @@ -267,10 +276,10 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct | ||||
| 		$script->addScriptFunction($updatePageFunction, $functionText); | ||||
| 		return $this; | ||||
| 	} | ||||
| 	 | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the minimum Page | ||||
| 	 * | ||||
| 	 *  | ||||
| 	 * @return \FML\Script\Features\PagingPage | ||||
| 	 */ | ||||
| 	protected function getMinPage() { | ||||
| @@ -288,7 +297,7 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the maximum Page | ||||
| 	 * | ||||
| 	 *  | ||||
| 	 * @return \FML\Script\Features\PagingPage | ||||
| 	 */ | ||||
| 	protected function getMaxPage() { | ||||
| @@ -306,7 +315,7 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct | ||||
|  | ||||
| 	/** | ||||
| 	 * Build the Array Text for the Pages | ||||
| 	 * | ||||
| 	 *  | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	protected function getPagesArrayText() { | ||||
| @@ -319,7 +328,7 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct | ||||
|  | ||||
| 	/** | ||||
| 	 * Build the Array Text for the Page Buttons | ||||
| 	 * | ||||
| 	 *  | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	protected function getPageButtonsArrayText() { | ||||
|   | ||||
| @@ -81,7 +81,9 @@ class Script { | ||||
| 		else { | ||||
| 			$scriptFunction = new ScriptFunction($name, $text); | ||||
| 		} | ||||
| 		$this->functions[$scriptFunction->getName()] = $scriptFunction; | ||||
| 		if (!in_array($scriptFunction, $this->functions)) { | ||||
| 			array_push($this->functions, $scriptFunction); | ||||
| 		} | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -38,15 +38,6 @@ class ScriptFunction { | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the Name | ||||
| 	 *  | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public function getName() { | ||||
| 		return $this->name; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| 	 * Set the Text | ||||
| 	 * | ||||
|   | ||||
		Reference in New Issue
	
	Block a user