public function export() { if (!($this->_application = Zoo::getApplication())) { throw new ExportHelperException('No application selected.'); } // export frontpage $frontpage = new Category(); $frontpage->name = 'Root'; $frontpage->alias = '_root'; $frontpage->description = $this->_application->description; // export categories $categories = $this->_application->getCategories(); $categories[0] = $frontpage; foreach ($categories as $category) { $this->_addCategory($this->_categoryToXML($category, $categories)); } $this->categories = $categories; // export items $types = $this->_application->getTypes(); $item_table = YTable::getInstance('item'); foreach ($types as $type) { $items = $item_table->getByType($type->id, $this->_application->id); foreach ($items as $key => $item) { $this->_addItem($type->name, $this->_itemToXML($item)); $item->unsetElementData(); unset($items[$key]); } } return parent::export(); }
public function __construct($default = array()) { parent::__construct($default); // get application $this->application = Zoo::getApplication(); // registers tasks $this->registerTask('frontpage', 'category'); }
public function __construct($default = array()) { parent::__construct($default); // get application $this->application = Zoo::getApplication(); // register tasks $this->registerTask('add', 'edit'); $this->registerTask('apply', 'save'); $this->registerTask('saveandnew', 'save'); }
function fetchElement($name, $value, &$node, $control_name) { $application = Zoo::getApplication(); // create html $options = array(); $options[] = JHTML::_('select.option', '', '- ' . JText::_('Select Category') . ' -'); $html[] = '<div id="' . $name . '" class="zoo-categories">'; $html[] = JHTML::_('zoo.categorylist', $application, $options, $control_name . '[' . $name . ']', 'size="10"', 'value', 'text', $value); $html[] = '</div>'; return implode("\n", $html); }
public function edit() { //init vars $multiselect = $this->_config->get('multiselect', array()); $options = array(); if (!$multiselect) { $options[] = JHTML::_('select.option', '', '-' . JText::_('Select Category') . '-'); } $attribs = $multiselect ? 'size="5" multiple="multiple"' : ''; return JHTML::_('zoo.categorylist', Zoo::getApplication(), $options, 'elements[' . $this->identifier . '][category][]', $attribs, 'value', 'text', $this->_data->get('category', array())); }
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)); }
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); }
::<?php echo $row->name; ?> "> <a href="<?php echo JRoute::_($this->baseurl . '&task=edit&cid[]=' . $row->id); ?> "><?php echo $row->name; ?> </a> </span> </td> <td class="type"> <?php echo Zoo::getApplication()->getType($row->type)->name; ?> </td> <td class="published"> <span class="editlinktip hasTip" title="<?php echo JText::_('Publish Information'); ?> ::<?php echo $times; ?> "> <a href="#" rel="task-<?php echo $row->state ? 'unpublish' : 'publish'; ?> "> <img src="images/<?php
public function display() { jimport('joomla.html.pagination'); // get application $app = Zoo::getApplication(); // get request vars $db = YDatabase::getInstance(); $state_prefix = $this->option . '_' . $app->id . '.comment.'; $limit = $this->joomla->getUserStateFromRequest('global.list.limit', 'limit', $this->joomla->getCfg('list_limit'), 'int'); $offset = $this->joomla->getUserStateFromRequest($state_prefix . 'limitstart', 'limitstart', 0, 'int'); $filter_state = $this->joomla->getUserStateFromRequest($state_prefix . 'filter-state', 'filter-state', '', 'string'); $filter_item = $this->joomla->getUserStateFromRequest($state_prefix . 'filter-item', 'filter-item', 0, 'int'); $filter_author = $this->joomla->getUserStateFromRequest($state_prefix . 'filter-author', 'filter-author', '', 'string'); $search = $this->joomla->getUserStateFromRequest($state_prefix . 'search', 'search', '', 'string'); $search = JString::strtolower($search); // is filtered ? $this->is_filtered = $filter_state != '' || !empty($filter_item) || !empty($filter_author) || !empty($search); // in case limit has been changed, adjust offset accordingly $offset = $limit != 0 ? floor($offset / $limit) * $limit : 0; // set toolbar items if ($filter_item && ($item_object = YTable::getInstance('item')->get($filter_item))) { $this->joomla->set('JComponentTitle', $app->getToolbarTitle(JText::_('Comments on') . ': ' . $item_object->name)); } else { $this->joomla->set('JComponentTitle', $app->getToolbarTitle(JText::_('Comments'))); } JToolBarHelper::custom('approve', 'publish', '', 'Approve'); JToolBarHelper::custom('unapprove', 'unpublish', '', 'Unapprove'); JToolBarHelper::custom('spam', 'trash', '', 'Spam'); JToolBarHelper::deleteList(); // build where condition $where = array('b.application_id = ' . (int) $app->id); if ($filter_state === '') { $where[] = 'a.state <> 2'; // all except spam } else { $where[] = 'a.state = ' . (int) $filter_state; } if ($filter_item) { $where[] = 'a.item_id = ' . (int) $filter_item; } if ($filter_author == '_anonymous_') { $where[] = 'a.author = ""'; } elseif ($filter_author) { $where[] = 'a.author = "' . $db->getEscaped($filter_author) . '"'; } if ($search) { $where[] = 'LOWER(a.content) LIKE "%' . $db->getEscaped($search, true) . '%"'; } // build query options $options = array('select' => 'a.*', 'from' => ZOO_TABLE_COMMENT . ' AS a LEFT JOIN ' . ZOO_TABLE_ITEM . ' AS b ON a.item_id = b.id', 'conditions' => array(implode(' AND ', $where)), 'order' => 'created DESC'); // query comment table $table = YTable::getInstance('comment'); $this->comments = $table->all($limit > 0 ? array_merge($options, compact('offset', 'limit')) : $options); $this->pagination = new JPagination($table->count($options), $offset, $limit); // search filter $this->lists['search'] = $search; // state select $options = array(JHTML::_('select.option', '', '- ' . JText::_('Select Status') . ' -'), JHTML::_('select.option', '0', JText::_('Pending')), JHTML::_('select.option', '1', JText::_('Approved')), JHTML::_('select.option', '2', JText::_('Spam'))); $this->lists['select_state'] = JHTML::_('select.genericlist', $options, 'filter-state', 'class="inputbox auto-submit"', 'value', 'text', $filter_state); // item select $options = array(JHTML::_('select.option', 0, '- ' . JText::_('Select Item') . ' -')); $this->lists['select_item'] = JHTML::_('zoo.itemlist', $app, $options, 'filter-item', 'class="inputbox auto-submit"', 'value', 'text', $filter_item); // author select $options = array(JHTML::_('select.option', '', '- ' . JText::_('Select Author') . ' -'), JHTML::_('select.option', '_anonymous_', '- ' . JText::_('Anonymous') . ' -')); $this->lists['select_author'] = JHTML::_('zoo.commentauthorlist', $app, $options, 'filter-author', 'class="inputbox auto-submit"', 'value', 'text', $filter_author); // get comment params $this->params = new YParameter(); $this->params->loadArray($app->getParams()->get('global.comments.', array())); // display view $this->getView()->display(); }
public static function getImportInfoCSV($file, $contains_headers = false, $field_separator = ',', $field_enclosure = '"') { $info = array(); $application = Zoo::getApplication(); // get types $info['types'] = array(); foreach ($application->getTypes() as $type) { $info['types'][$type->id] = array(); foreach ($type->getElements() as $element) { // filter elements if (in_array($element->getElementType(), array('text', 'textarea', 'link', 'email', 'image', 'gallery', 'download', 'date', 'googlemaps'))) { $info['types'][$type->id][$element->getElementType()][] = $element; } } } // get item types $info['item_count'] = 0; $info['columns'] = array(); // get column names and row count $row = 0; $columns = 0; if (($handle = fopen($file, "r")) !== FALSE) { while (($data = fgetcsv($handle, 0, $field_separator, $field_enclosure)) !== FALSE) { if ($row == 0) { // get column names from header row if ($contains_headers) { $info['columns'] = $data; } else { $info['columns'] = array_fill(0, count($data), ''); } } // get max column count $row++; } // get item count $info['item_count'] = $contains_headers ? $row - 1 : $row; fclose($handle); } return $info; }
public function __construct($default = array()) { parent::__construct($default); // get application $this->application = Zoo::getApplication(); }
* @copyright Copyright (C) 2007 - 2011 YOOtheme GmbH * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only */ // no direct access defined('_JEXEC') or die('Restricted access'); // load config require_once JPATH_ADMINISTRATOR . '/components/com_zoo/config.php'; // load mootools JHTML::_('behavior.mootools'); // add default js JHTML::script('default.js', ZOO_SITE_URI . 'assets/js/'); // load plugins JPluginHelper::importPlugin('zoo'); // set Itemid $router = JFactory::getApplication()->getRouter(); if (!$router->getVar('Itemid')) { $menu = JSite::getMenu(true); $default = $menu->getDefault(); $active = $menu->getActive(); if ($active && $active->id == $default->id) { $router->setVar('Itemid', $default->id); } } try { // load and dispatch application if ($app = Zoo::getApplication()) { $app->dispatch(); } } catch (YException $e) { JError::raiseError(500, $e); }
public static function getTwitterClient() { // get comment params $params = new YParameter(); $params->loadArray(Zoo::getApplication()->getParams()->get('global.comments.')); if (!function_exists('curl_init')) { return null; } // load twitter classes JLoader::register('TwitterOAuth', ZOO_ADMIN_PATH . '/libraries/twitter/twitteroauth.php'); $oauth_token = null; $oauth_token_secret = null; if (isset($_SESSION['twitter_oauth_token']) && isset($_SESSION['twitter_oauth_token_secret'])) { $oauth_token = $_SESSION['twitter_oauth_token']; $oauth_token_secret = $_SESSION['twitter_oauth_token_secret']; } // Build TwitterOAuth object with client credentials. return new TwitterOAuth($params->get('twitter_consumer_key'), $params->get('twitter_consumer_secret'), $oauth_token, $oauth_token_secret); }
JHTML::script('placeholder.js', ZOO_ADMIN_URI . 'assets/js/'); JHTML::script('jquery.pnotify.js', ZOO_ADMIN_URI . 'libraries/jquery/plugins/notifier/'); JHTML::stylesheet('jquery.pnotify.default.css', ZOO_ADMIN_URI . 'libraries/jquery/plugins/notifier/'); JHTML::script('default.js', ZOO_ADMIN_URI . 'assets/js/'); 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
public static function typeList($options, $name, $attribs = null, $key = 'value', $text = 'text', $selected = null, $idtag = false, $translate = false, $filter = array()) { if (is_array($options)) { reset($options); } else { $options = array($options); } foreach (Zoo::getApplication()->getTypes() as $type) { if (empty($filter) || in_array($type->id, $filter)) { $options[] = JHTML::_('select.option', $type->id, JText::_($type->name)); } } return JHTML::_('select.genericlist', $options, $name, $attribs, $key, $text, $selected, $idtag, $translate); }
public function twitterConnect() { // get twitter client $connection = CommentHelper::getTwitterClient(); // redirect to the referer after authorize/login procedure $referer = YRequest::getString('HTTP_REFERER', '', 'server'); // retrieve request token only if token is not supplied already if ($connection && empty($connection->token)) { $uri = new JURI(); $redirect = $uri->root() . $this->link_base . '&app_id=' . Zoo::getApplication()->id . '&controller=' . $this->controller . '&task=twitterauthenticate&referer=' . urlencode($referer); // get temporary credentials $request_token = $connection->getRequestToken($redirect); // save temporary credentials to session $_SESSION['twitter_oauth_token'] = $token = $request_token['oauth_token']; $_SESSION['twitter_oauth_token_secret'] = $request_token['oauth_token_secret']; // if last connection failed don't display authorization link switch ($connection->http_code) { case 200: // build authorize URL and redirect user to Twitter $redirect = $connection->getAuthorizeURL($token); break; default: // show notification if something went wrong. JError::raiseWarning(0, JText::_('ERROR_CONNECT_TWITTER')); $redirect = $referer; } } else { // already connected $redirect = $referer; } $this->setRedirect($redirect); }