# css-javascript-toolbox/8.0.2/models/fields/template-states.php

CSS &amp; JavaScript Toolbox, version 8.0.2. 38 lines.

- Page: https://pluginprobe.com/plugins/css-javascript-toolbox/8.0.2/code/models/fields/template-states.php
- Raw: https://pluginprobe.com/plugins/css-javascript-toolbox/8.0.2/raw/models/fields/template-states.php
- Modified: 2014-05-06T16:47:26+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/css-javascript-toolbox/8.0.2/code/models/fields/template-states.php#L10-L20`.

```php
<?php
/**
* 
*/

// Import dependencies.
cssJSToolbox::import('framework:html:list.php', 'framework:db:mysql:xtable.inc.php');

/**
* 
*/
class CJTTemplateStatesField extends CJTListField {
	
	/**
	* put your comment there...
	* 
	*/
	protected function prepareItems() {
		if (isset($this->options['result']) && ($this->options['result'] == 'fullList')) {
			$this->items['published']['text'] = cssJSToolbox::getText('published');
			$this->items['draft']['text'] = cssJSToolbox::getText('draft');
			$this->items['trash']['text'] = cssJSToolbox::getText('trash');
		}
		else {
			CJTxTable::import('author');
			$internalAuthorsFlag = CJTAuthorTable::FLAG_SYS_AUTHOR;
			// Query all template state exluding Internal authors.
			$query = "SELECT DISTINCT(state) `text` 
													FROM #__cjtoolbox_templates t
													LEFT JOIN #__cjtoolbox_authors a
													ON  t.authorId = a.id
													WHERE (a.attributes & {$internalAuthorsFlag}) = 0
													ORDER BY `text`";
			$this->items = cssJSToolbox::getInstance()->getDBDriver()->select($query);			
		}
	}
	
} // End class.
```
