Beispiel #1
0
 public function __construct($default = array())
 {
     parent::__construct($default);
     // init vars
     $this->joomla = JFactory::getApplication();
     $this->user = JFactory::getUser();
     $this->session = JFactory::getSession();
     $this->document = JFactory::getDocument();
     $this->dispatcher = JDispatcher::getInstance();
     $this->option = YRequest::getCmd('option');
     $this->link_base = 'index.php?option=' . $this->option;
     $this->controller = $this->getName();
     // add super administrator var to user
     $this->user->superadmin = UserHelper::isJoomlaSuperAdmin($this->user);
     // init additional admin vars
     if ($this->joomla->isAdmin()) {
         $this->baseurl = 'index.php?option=' . $this->option . '&controller=' . $this->getName();
     }
     // init additional site vars
     if ($this->joomla->isSite()) {
         $this->itemid = (int) $GLOBALS['Itemid'];
         $this->params = $this->joomla->getParams();
         $this->pathway = $this->joomla->getPathway();
     }
 }
Beispiel #2
0
 public static function getApplication()
 {
     // check if application object already exists
     if (isset(self::$_application)) {
         return self::$_application;
     }
     // get joomla and application table
     $joomla = JFactory::getApplication();
     $table = YTable::getInstance('application');
     // handle admin
     if ($joomla->isAdmin()) {
         // create application from user state, or search for default
         $id = $joomla->getUserState('com_zooapplication');
         $apps = $table->all(array('order' => 'name'));
         if (isset($apps[$id])) {
             self::$_application = $apps[$id];
         } else {
             if (!empty($apps)) {
                 self::$_application = array_shift($apps);
             }
         }
         return self::$_application;
     }
     // handle site
     if ($joomla->isSite()) {
         // get component params
         $params = $joomla->getParams();
         // create application from menu item params / request
         if ($item_id = YRequest::getInt('item_id')) {
             if ($item = YTable::getInstance('item')->get($item_id)) {
                 self::$_application = $item->getApplication();
             }
         } else {
             if ($category_id = YRequest::getInt('category_id')) {
                 if ($category = YTable::getInstance('category')->get($category_id)) {
                     self::$_application = $category->getApplication();
                 }
             } else {
                 if ($id = YRequest::getInt('app_id')) {
                     self::$_application = $table->get($id);
                 } else {
                     if ($id = $params->get('application')) {
                         self::$_application = $table->get($id);
                     } else {
                         // try to get application from default menu item
                         $menu = JSite::getMenu(true);
                         $default = $menu->getDefault();
                         if (isset($default->component) && $default->component == 'com_zoo') {
                             if ($app_id = $menu->getParams($default->id)->get('application')) {
                                 self::$_application = $table->get($app_id);
                             }
                         }
                     }
                 }
             }
         }
         return self::$_application;
     }
     return null;
 }
Beispiel #3
0
 public function render($params = array())
 {
     $params = new YArray($params);
     // include assets css
     JHTML::stylesheet('itemprint.css', 'administrator/components/com_zoo/elements/itemprint/assets/css/');
     if (YRequest::getBool('print', 0)) {
         return '<a class="element-print-button" onclick="window.print();return false;" href="#"></a>';
     } else {
         JHTML::_('behavior.modal', 'a.modal');
         $text = $params->get('showicon') ? '' : JText::_('Print');
         $class = $params->get('showicon') ? 'modal element-print-button' : 'modal';
         return '<a href="' . JRoute::_(RouteHelper::getItemRoute($this->_item) . '&amp;tmpl=component&amp;print=1') . '" title="' . JText::_('Print') . '" rel="{handler: \'iframe\', size: {x: 850, y: 500}}" class="' . $class . '">' . $text . '</a>';
     }
 }
Beispiel #4
0
 public static function activeFilter(YMenuItem $item)
 {
     // init vars
     $id = '';
     $app = Zoo::getApplication();
     $controller = YRequest::getWord('controller');
     $task = YRequest::getWord('task');
     $classes = array();
     // application context
     if (!empty($app)) {
         $id = $app->id . '-' . $controller;
     }
     // application configuration
     if ($controller == 'configuration' && $task) {
         if (in_array($task, array('importfrom', 'import', 'importcsv', 'importexport'))) {
             $id .= '-importexport';
         } else {
             $id .= '-' . $task;
         }
     }
     // new application
     if ($controller == 'new') {
         $id = 'new';
     }
     // application manager
     if ($controller == 'manager') {
         $id = 'manager';
         if (in_array($task, array('types', 'addtype', 'edittype', 'editelements', 'assignelements', 'assignsubmission'))) {
             $id .= '-types';
         } elseif ($task) {
             $id .= '-' . $task;
         }
     }
     // save current class attribute
     $class = $item->getAttribute('class');
     if (!empty($class)) {
         $classes[] = $class;
     }
     // set active class
     if ($item->getId() == $id || $item->hasChild($id, true)) {
         $classes[] = 'active';
     }
     // replace the old class attribute
     $item->setAttribute('class', implode(' ', $classes));
 }
Beispiel #5
0
 public function update()
 {
     // init vars
     $old = YRequest::getString('old');
     $new = YRequest::getString('new');
     $msg = null;
     try {
         $app = Zoo::getApplication();
         // update tag
         if (!empty($new) && $old != $new) {
             YTable::getInstance('tag')->update($app->id, $old, $new);
             // set redirect message
             $msg = JText::_('Tag Updated Successfully');
         }
     } catch (YException $e) {
         // raise notice on exception
         JError::raiseWarning(0, JText::_('Error Updating Tag') . ' (' . $e . ')');
     }
     $this->setRedirect($this->baseurl, $msg);
 }
Beispiel #6
0
 public function save()
 {
     // check for request forgeries
     YRequest::checkToken() or jexit('Invalid Token');
     // init vars
     $post = YRequest::get('post');
     $post['description'] = YRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW);
     try {
         // bind post
         $this->application->bind($post, array('params'));
         // set params
         $this->application->params = $this->application->getParams()->remove('content.')->remove('config.')->remove('template.')->set('content.', @$post['params']['content'])->set('config.', @$post['params']['config'])->set('template.', @$post['params']['template'])->toString();
         // save application
         YTable::getInstance('application')->save($this->application);
         // set redirect message
         $msg = JText::_('Frontpage Saved');
     } catch (YException $e) {
         // raise notice on exception
         JError::raiseNotice(0, JText::_('Error Saving Frontpage') . ' (' . $e . ')');
         $msg = null;
     }
     $this->setRedirect($this->baseurl, $msg);
 }
Beispiel #7
0
 protected function _editState($state)
 {
     // check for request forgeries
     YRequest::checkToken() or jexit('Invalid Token');
     // init vars
     $cid = YRequest::getArray('cid', array(), 'int');
     if (count($cid) < 1) {
         JError::raiseError(500, JText::_('Select a comment to edit state'));
     }
     try {
         // get comment table
         $table = YTable::getInstance('comment');
         // update comment state
         foreach ($cid as $id) {
             $comment = $table->get($id);
             $comment->state = $state;
             $table->save($comment);
         }
     } catch (YException $e) {
         // raise notice on exception
         JError::raiseNotice(0, JText::_('Error editing Comment State') . ' (' . $e . ')');
     }
     $this->setRedirect($this->baseurl);
 }
Beispiel #8
0
 public function render()
 {
     $link = YRequest::getVar('hidemainmenu') ? null : $this->_link;
     $html[] = '<li ' . JArrayHelper::toString($this->_attributes) . '>';
     $html[] = ($link ? '<a href="' . JRoute::_($link) . '">' : '<span>') . '<span>' . JText::_($this->getName()) . '</span>' . ($link ? '</a>' : '</span>');
     if (count($this->getChildren())) {
         $html[] = '<ul>';
         foreach ($this->getChildren() as $child) {
             $html[] = $child->render();
         }
         $html[] = '</ul>';
     }
     $html[] = '</li>';
     return implode("\n", $html);
 }
Beispiel #9
0
 protected function _editTrustedMode($enabled)
 {
     // check for request forgeries
     YRequest::checkToken() or jexit('Invalid Token');
     // init vars
     $cid = YRequest::getArray('cid', array(), 'int');
     if (count($cid) < 1) {
         JError::raiseError(500, JText::_('Select a submission to enable/disable Trusted Mode'));
     }
     try {
         // get item table
         $table = YTable::getInstance('submission');
         // update item state
         foreach ($cid as $id) {
             $submission = $table->get($id);
             $submission->params = $submission->getParams()->set('trusted_mode', $enabled)->toString();
             $table->save($submission);
         }
     } catch (YException $e) {
         // raise notice on exception
         JError::raiseNotice(0, JText::_('Error enabling/disabling Submission Trusted Mode') . ' (' . $e . ')');
     }
     $this->setRedirect($this->baseurl);
 }
Beispiel #10
0
" accesskey="s"/>
				<a href="#" class="cancel"><?php 
    echo JText::_('Cancel');
    ?>
</a>
				<span class="submit-message">
					<?php 
    echo JText::_('Submitting comment...');
    ?>
				</span>		
			</div>
			
			<input type="hidden" name="item_id" value="<?php 
    echo $this->item->id;
    ?>
"/>
			<input type="hidden" name="parent_id" value="0"/>
			<input type="hidden" name="redirect" value="<?php 
    echo str_replace('&', '&amp;', YRequest::getString('REQUEST_URI', '', 'server'));
    ?>
"/>
			<?php 
    echo JHTML::_('form.token');
    ?>
			
		<?php 
}
?>
		
	</form>
</div>
Beispiel #11
0
 public static function readCookies()
 {
     // get cookies
     foreach (array('hash', 'author', 'email', 'url') as $key) {
         $data[$key] = YRequest::getString(self::COOKIE_PREFIX . $key, '', 'cookie');
     }
     // verify hash
     if (self::getCookieHash($data['author'], $data['email'], $data['url']) == $data['hash']) {
         return $data;
     }
     return array('hash' => null, 'author' => null, 'email' => null, 'url' => null);
 }
Beispiel #12
0
JHTML::stylesheet('ui.css', ZOO_ADMIN_URI . 'assets/css/');
JHTMLBehavior::modal();
// init vars
$controller = YRequest::getWord('controller');
$task = YRequest::getWord('task');
$group = YRequest::getString('group');
// change application
if ($id = YRequest::getInt('changeapp')) {
    JFactory::getApplication()->setUserState('com_zooapplication', $id);
}
// load application
$application = Zoo::getApplication();
// set default controller
if (!$controller) {
    $controller = $application ? 'item' : 'new';
    YRequest::setVar('controller', $controller);
}
// set toolbar button include path
$toolbar = JToolBar::getInstance('toolbar');
$toolbar->addButtonPath(ZOO_ADMIN_PATH . '/joomla/button');
// build menu
$menu = YMenu::getInstance('nav');
// add "app" menu items
foreach (YTable::getInstance('application')->all(array('order' => 'name')) as $app) {
    $app->addMenuItems($menu);
}
// add "new" and "manager" menu item
$new = new YMenuItem('new', '<span class="icon"> </span>', 'index.php?option=com_zoo&controller=new', array('class' => 'new'));
$manager = new YMenuItem('manager', '<span class="icon"> </span>', 'index.php?option=com_zoo&controller=manager', array('class' => 'config'));
$menu->addChild($new);
$menu->addChild($manager);
Beispiel #13
0
 protected function _init()
 {
     //init vars
     $type_id = JRequest::getString('type_id');
     $hash = JRequest::getString('submission_hash');
     $this->redirect = YRequest::getString('redirect');
     // check config
     $this->_checkConfig();
     // get submission info from request
     if ($type_id) {
         if ($hash != SubmissionHelper::getSubmissionHash($this->submission->id, $type_id, $this->item_id)) {
             throw new SubmissionControllerException('Hashes did not match.');
         }
         // else get submission info from active menu
     } elseif ($this->menu_params) {
         $type_id = $this->menu_params->get('type');
         // remove item_id (menu item may not have an item_id)
         $this->item_id = null;
     }
     // set type
     $this->type = $this->submission->getType($type_id);
     // check type
     if (!$this->type) {
         throw new SubmissionControllerException('Submissions are not configured correctly.');
     }
     // set hash
     $this->hash = $hash ? $hash : SubmissionHelper::getSubmissionHash($this->submission->id, $this->type->id, $this->item_id);
     // set layout
     $this->layout = $this->submission->getForm($this->type->id)->get('layout', '');
     // check layout
     if (empty($this->layout)) {
         throw new SubmissionControllerException('Submission is not configured correctly.');
     }
     // set layout path
     $this->layout_path = 'item.';
     if ($this->renderer->pathExists('item/' . $this->type->id)) {
         $this->layout_path .= $this->type->id . '.';
     }
     $this->layout_path .= $this->layout;
     // get positions
     $positions = $this->renderer->getConfig('item')->get($this->application->getGroup() . '.' . $this->type->id . '.' . $this->layout, array());
     // get elements from positions
     $this->elements_config = array();
     foreach ($positions as $position) {
         foreach ($position as $element) {
             if ($element_obj = $this->type->getElement($element->element)) {
                 if (!$this->submission->isInTrustedMode()) {
                     $metadata = $element_obj->getMetaData();
                     if ($metadata['trusted'] == 'true') {
                         continue;
                     }
                 }
                 $this->elements_config[$element->element] = $element;
             }
         }
     }
     // get item table
     $table = YTable::getInstance('item');
     // get item
     if (!$this->item_id || !($this->item = $table->get($this->item_id))) {
         $this->item = new Item();
         $this->item->application_id = $this->application->id;
         $this->item->type = $this->type->id;
         $now = JFactory::getDate();
         $config = JFactory::getConfig();
         $offset = $config->getValue('config.offset');
         $now->setOffset($offset);
         $this->item->publish_up = $now->toFormat(SubmissionController::EDIT_DATE_FORMAT);
         $this->item->publish_down = YDatabase::getInstance()->getNullDate();
     }
 }
Beispiel #14
0
 public function _editPublished($published, $msg)
 {
     // check for request forgeries
     YRequest::checkToken() or jexit('Invalid Token');
     // init vars
     $cid = YRequest::getArray('cid', array(), 'int');
     if (count($cid) < 1) {
         JError::raiseError(500, $msg);
     }
     try {
         // get category table
         $table = YTable::getInstance('category');
         // update published state
         foreach ($cid as $id) {
             $category = $table->get($id);
             $category->setPublished($published);
             $table->save($category);
         }
     } catch (YException $e) {
         // raise notice on exception
         JError::raiseNotice(0, JText::_('Error editing Item Published State') . ' (' . $e . ')');
         $msg = null;
     }
     $this->setRedirect($this->baseurl);
 }
Beispiel #15
0
 public function getItemRoute($item)
 {
     YTable::getInstance('application')->get($item->application_id)->getCategoryTree(true);
     // have we found the link before?
     if (isset(self::$_item_links[$item->id])) {
         return self::$_item_links[$item->id];
     }
     // init vars
     $categories = $item->getRelatedCategoryIds(true);
     $categories = array_filter($categories, create_function('$id', 'return !empty($id);'));
     // build item link
     $link = RouteHelper::LINK_BASE . '&task=item&item_id=' . $item->id;
     // Priority 1: direct link to item
     $itemid = null;
     if ($menu_item = self::_findItem($item->id)) {
         $itemid = $menu_item->id;
     }
     // are we in category view?
     $category_id = null;
     if (!$itemid && (YRequest::getCmd('task') == 'category' || YRequest::getCmd('view') == 'category')) {
         $category_id = (int) YRequest::getInt('category_id', JFactory::getApplication()->getParams()->get('category'));
         $category_id = in_array($category_id, $categories) ? $category_id : null;
     }
     if (!$itemid && !$category_id) {
         $primary = $item->getPrimaryCategory();
         // Priority 2: direct link to primary category
         if ($primary && ($menu_item = self::_findCategory($primary->id))) {
             $itemid = $menu_item->id;
             // Priority 3: find in primary category path
         } else {
             if ($primary && ($menu_item = self::_findInCategoryPath($primary))) {
                 $itemid = $menu_item->id;
             } else {
                 $found = false;
                 foreach ($categories as $category) {
                     // Priority 4: direct link to any related category
                     if ($menu_item = self::_findCategory($category)) {
                         $itemid = $menu_item->id;
                         $found = true;
                         break;
                     }
                 }
                 if (!$found) {
                     $categories = $item->getRelatedCategories(true);
                     foreach ($categories as $category) {
                         // Priority 5: find in any related categorys path
                         if ($menu_item = self::_findInCategoryPath($category)) {
                             $itemid = $menu_item->id;
                             $found = true;
                             break;
                         }
                     }
                 }
                 // Priority 6: link to frontpage
                 if (!$found && ($menu_item = self::_findFrontpage($item->application_id))) {
                     $itemid = $menu_item->id;
                 }
             }
         }
     }
     if ($category_id) {
         $link .= '&category_id=' . $category_id;
     }
     if ($itemid) {
         $link .= '&Itemid=' . $itemid;
         // Priority 7: current item id
     } else {
         if ($menu = JSite::getMenu()->getActive()) {
             $link .= '&Itemid=' . $menu->id;
         }
     }
     // store link for future lookups
     self::$_item_links[$item->id] = $link;
     return $link;
 }
Beispiel #16
0
 public function addMenuItems($menu)
 {
     // get current controller
     $controller = YRequest::getWord('controller');
     $controller = in_array($controller, array('new', 'manager')) ? 'item' : $controller;
     // create application tab
     $tab = new YMenuItem($this->id, $this->name, 'index.php?option=com_zoo&controller=' . $controller . '&changeapp=' . $this->id);
     $menu->addChild($tab);
     // menu items
     $items = array('item' => JText::_('Items'), 'category' => JText::_('Categories'), 'frontpage' => JText::_('Frontpage'), 'comment' => JText::_('Comments'), 'tag' => JText::_('Tags'), 'submission' => JText::_('Submissions'));
     // add menu items
     foreach ($items as $controller => $name) {
         $tab->addChild(new YMenuItem($this->id . '-' . $controller, $name, 'index.php?option=com_zoo&controller=' . $controller . '&changeapp=' . $this->id));
     }
     // add config menu item
     $id = $this->id . '-configuration';
     $link = 'index.php?option=com_zoo&controller=configuration&changeapp=' . $this->id;
     $config = new YMenuItem($id, JText::_('Config'), $link);
     $config->addChild(new YMenuItem($id, JText::_('Application'), $link));
     $config->addChild(new YMenuItem($id . '-importexport', JText::_('Import / Export'), $link . '&task=importexport'));
     $tab->addChild($config);
 }
Beispiel #17
0
 public function feed()
 {
     // get request vars
     $category_id = (int) YRequest::getInt('category_id', $this->params->get('category'));
     // get params
     $all_categories = $this->application->getCategoryTree(true);
     // raise warning when category can not be accessed
     if (!isset($all_categories[$category_id])) {
         JError::raiseWarning(500, JText::_('Unable to access category'));
         return;
     }
     $category = $all_categories[$category_id];
     $params = $category ? $category->getParams('site') : $this->application->getParams('frontpage');
     $show_feed_link = $params->get('config.show_feed_link', 0);
     $feed_title = $params->get('config.feed_title', '');
     // init vars
     $document = JFactory::getDocument();
     // raise error when feed is link is disabled
     if (empty($show_feed_link)) {
         JError::raiseError(500, JText::_('Unable to access feed'));
         return;
     }
     // get feed items from category
     $categories = $category->getChildren(true);
     $categories[$category->id] = $category;
     $feed_limit = $this->joomla->getCfg('feed_limit');
     $feed_items = YTable::getInstance('item')->getFromCategory($this->application->id, array_keys($categories), true, null, 'created DESC', 0, $feed_limit);
     // set title
     if ($feed_title) {
         $document->setTitle(html_entity_decode($this->getView()->escape($feed_title)));
     }
     // set feed link
     $document->link = JRoute::_($this->link_base . '&task=category');
     // set renderer
     $renderer = new ItemRenderer();
     $renderer->addPath(array($this->application->getTemplate()->getPath(), ZOO_SITE_PATH));
     foreach ($feed_items as $feed_item) {
         // create feed item
         $item = new JFeedItem();
         $item->title = html_entity_decode($this->getView()->escape($feed_item->name));
         $item->link = JRoute::_(RouteHelper::getItemRoute($feed_item));
         $item->date = $feed_item->created;
         $item->author = $feed_item->getAuthor();
         $item->description = $this->_relToAbs($renderer->render('item.feed', array('item' => $feed_item)));
         // add to feed document
         $document->addItem($item);
     }
 }
Beispiel #18
0
 public function callElement()
 {
     // get request vars
     $element_identifier = YRequest::getString('elm_id', '');
     $item_id = YRequest::getInt('item_id', 0);
     $type = YRequest::getString('type', '');
     $this->method = YRequest::getCmd('method', '');
     $this->args = YRequest::getVar('args', array(), 'default', 'array');
     JArrayHelper::toString($this->args);
     // load element
     if ($item_id) {
         $item = YTable::getInstance('item')->get($item_id);
     } elseif (!empty($type)) {
         $item = new Item();
         $item->application_id = $this->application->id;
         $item->type = $type;
     }
     // execute callback method
     if ($element = $item->getElement($element_identifier)) {
         echo $element->callback($this->method, $this->args);
     }
 }
Beispiel #19
0
 public function doExport()
 {
     // check for request forgeries
     YRequest::checkToken() or jexit('Invalid Token');
     $group = $this->application->getGroup();
     require_once JPATH_ROOT . '/administrator/includes/pcl/pclzip.lib.php';
     $filepath = JPATH_ROOT . '/tmp/' . $group . '.zip';
     $read_directory = ZOO_APPLICATION_PATH . '/' . $group . '/';
     $zip = new PclZip($filepath);
     $files = YFile::readDirectoryFiles($read_directory, $read_directory, '', '/^[^\\.]/');
     $zip->create($files, PCLZIP_OPT_ADD_PATH, '../', PCLZIP_OPT_REMOVE_PATH, $read_directory);
     if (is_readable($filepath) && JFile::exists($filepath)) {
         YFile::output($filepath);
         if (!JFile::delete($filepath)) {
             JError::raiseNotice(0, JText::_('Unable to delete file') . ' (' . $filepath . ')');
             $this->setRedirect($this->baseurl . '&task=info');
         }
     } else {
         JError::raiseNotice(0, JText::_('Unable to create file') . ' (' . $filepath . ')');
         $this->setRedirect($this->baseurl . '&task=info');
     }
 }
Beispiel #20
0
 public function element()
 {
     $this->_loadGeneralCSS();
     jimport('joomla.html.pagination');
     // get database
     $this->db = JFactory::getDBO();
     // get request vars
     $this->filter_item = YRequest::getInt('item_filter', 0);
     $this->type_filter = YRequest::getArray('type_filter', array());
     $state_prefix = $this->option . '_' . $this->application->id . '.' . ($this->getTask() == 'element' ? 'element' : 'item') . '.';
     $filter_order = $this->joomla->getUserStateFromRequest($state_prefix . 'filter_order', 'filter_order', 'a.created', 'cmd');
     $filter_order_Dir = $this->joomla->getUserStateFromRequest($state_prefix . 'filter_order_Dir', 'filter_order_Dir', 'desc', 'word');
     $filter_category_id = $this->joomla->getUserStateFromRequest($state_prefix . 'filter_category_id', 'filter_category_id', '0', 'string');
     $limit = $this->joomla->getUserStateFromRequest('global.list.limit', 'limit', $this->joomla->getCfg('list_limit'), 'int');
     $limitstart = $this->joomla->getUserStateFromRequest($state_prefix . 'limitstart', 'limitstart', 0, 'int');
     $filter_type = $this->joomla->getUserStateFromRequest($state_prefix . 'filter_type', 'filter_type', '', 'string');
     $filter_author_id = $this->joomla->getUserStateFromRequest($state_prefix . 'filter_author_id', 'filter_author_id', 0, 'int');
     $search = $this->joomla->getUserStateFromRequest($state_prefix . 'search', 'search', '', 'string');
     $search = JString::strtolower($search);
     // is filtered ?
     $this->is_filtered = $filter_category_id != '0' || !empty($filter_type) || !empty($filter_author_id) || !empty($search);
     // in case limit has been changed, adjust limitstart accordingly
     $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0;
     $table = YTable::getInstance('item');
     $this->users = $table->getUsers($this->application->id);
     $this->groups = ZooHelper::getGroups();
     // get data from the table
     $where = array();
     // application filter
     $where[] = 'a.application_id = ' . (int) $this->application->id;
     // category filter
     if ($filter_category_id > 0) {
         $where[] = 'ci.category_id = ' . (int) $filter_category_id;
     } else {
         if ($filter_category_id === '') {
             $where[] = 'ci.item_id IS NULL';
         }
     }
     // type filter
     if (!empty($this->type_filter)) {
         $where[] = 'a.type IN ("' . implode('", "', $this->type_filter) . '")';
     } else {
         if (!empty($filter_type)) {
             $where[] = 'a.type = "' . (string) $filter_type . '"';
         }
     }
     // item filter
     if ($this->filter_item > 0) {
         $where[] = 'a.id != ' . (int) $this->filter_item;
     }
     // author filter
     if ($filter_author_id > 0) {
         $where[] = 'a.created_by = ' . (int) $filter_author_id;
     }
     if ($search) {
         $where[] = 'LOWER(a.name) LIKE ' . $this->db->Quote('%' . $this->db->getEscaped($search, true) . '%', false);
     }
     // access filter
     $where[] = 'a.access <= ' . (int) $this->user->get('aid', 0);
     // state filter
     $where[] = 'a.state = 1';
     $options = array('select' => 'DISTINCT a.*', 'from' => $table->getTableName() . ' AS a LEFT JOIN ' . ZOO_TABLE_CATEGORY_ITEM . ' AS ci ON a.id = ci.item_id', 'conditions' => array(implode(' AND ', $where)), 'order' => $filter_order . ' ' . $filter_order_Dir);
     $this->items = $table->all($limit > 0 ? array_merge($options, array('offset' => $limitstart, 'limit' => $limit)) : $options);
     $this->items = array_merge($this->items);
     $this->pagination = new JPagination($table->count($options), $limitstart, $limit);
     // category select
     $options = array();
     $options[] = JHTML::_('select.option', '0:0', '- ' . JText::_('Select Category') . ' -');
     $options[] = JHTML::_('select.option', '', '- ' . JText::_('uncategorized') . ' -');
     $this->lists['select_category'] = JHTML::_('zoo.categorylist', $this->application, $options, 'filter_category_id', 'class="inputbox auto-submit"', 'value', 'text', $filter_category_id);
     // type select
     $options = array(JHTML::_('select.option', '0', '- ' . JText::_('Select Type') . ' -'));
     $this->lists['select_type'] = JHTML::_('zoo.typelist', $options, 'filter_type', 'class="inputbox auto-submit"', 'value', 'text', $filter_type, false, false, $this->type_filter);
     // author select
     $options = array(JHTML::_('select.option', '0', '- ' . JText::_('Select Author') . ' -'));
     $this->lists['select_author'] = JHTML::_('zoo.itemauthorlist', $options, 'filter_author_id', 'class="inputbox auto-submit"', 'value', 'text', $filter_author_id);
     // table ordering and search filter
     $this->lists['order_Dir'] = $filter_order_Dir;
     $this->lists['order'] = $filter_order;
     $this->lists['search'] = $search;
     $this->addViewPath(ZOO_ADMIN_PATH . '/views/item/');
     $view = $this->getView('', '', '', array('base_path' => ZOO_ADMIN_PATH));
     $view->setLayout('element')->display();
 }
Beispiel #21
0
 public function getApplicationParams()
 {
     // init vars
     $template = YRequest::getCmd('template');
     $this->params = $this->application->getParams();
     // set template
     $this->params->set('template', $template);
     // display view
     $this->getView()->setLayout('_applicationparams')->display();
 }
Beispiel #22
0
 public function twitterLogout()
 {
     CommentHelper::twitterLogout();
     $this->setRedirect(YRequest::getString('HTTP_REFERER', '', 'server'));
 }